npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@anypoint-web-components/anypoint-checkbox

v1.2.5

Published

Anypoint and Material DS styled checkbox

Downloads

2,815

Readme

Deprecated

This component has been moved to anypoint-web-components/awc.

====

Anypoint and Material DS styled checkbox.

Published on NPM

tests

Working with forms

At the moment of publication of the element, the spec allowing custom elements to be accepted by the <form> element (Form-associated custom elements) is work in progress. Custom form element has to be used with custom elements that needs to be registered in a form. We suggest using iron-form.

Form-associated custom elements

This element supports form-associated custom elements spec that allows to use custom elements with <form> and <fieldset> elements. A browser may not yet support this feature. If the API is enable then the form element returns anypoint-checkbox is form.elements list and collect value of the control when submitted.

Usage

Checkboxes should be used with forms to select one of the available options. Unlike switch button which toggle action selects the control and immediately executes system related action, change of state of a checkbox does not carry any other related action than selecting an option. In other words, when change of the state of the control triggers change in the UI a switch button should be used instead of a checkbox.

Installation

npm i --save @anypoint-web-components/anypoint-checkbox

In a HTML document

<html>
  <head>
    <script type="module">
      import '@anypoint-web-components/anypoint-checkbox/anypoint-checkbox.js';
    </script>
  </head>
  <body>
    <anypoint-checkbox>Regular checkbox</anypoint-checkbox>
    <anypoint-checkbox checked>Checked checkbox</anypoint-checkbox>
    <anypoint-checkbox indeterminate>Indeterminate checkbox</anypoint-checkbox>
    <anypoint-checkbox required>Required checkbox</anypoint-checkbox>
    <anypoint-checkbox disabled>Disabled checkbox</anypoint-checkbox>
  </body>
</html>

In a LitElement

import { LitElement, html } from 'lit-element';
import '@anypoint-web-components/anypoint-checkbox/anypoint-checkbox.js';

class SimpleElement extends ControlStateMixin(ButtonStateMixin(LitElement)) {
  render() {
    return html`
    <anypoint-checkbox>Regular checkbox</anypoint-checkbox>
    <anypoint-checkbox checked>Checked checkbox</anypoint-checkbox>
    <anypoint-checkbox indeterminate>Indeterminate checkbox</anypoint-checkbox>
    <anypoint-checkbox required>Required checkbox</anypoint-checkbox>
    <anypoint-checkbox disabled>Disabled checkbox</anypoint-checkbox>
    `;
  }
}
window.customElements.define('simple-element', SimpleElement);

Using with custom forms

npm i --save @polymer/iron-form
<script type="module" src="node_modules/@polymer/iron-form/iron-form.js"></script>
<script type="module" src="node_modules/@anypoint-web-components/anypoint-checkbox/anypoint-checkbox.js"></script>
<script type="module" src="node_modules/@anypoint-web-components/anypoint-button/anypoint-button.js"></script>
<iron-form>
  <form>
   <anypoint-checkbox name="subscribe" value="newsletter">Subscribe to our newsletter</anypoint-checkbox>
   <anypoint-checkbox name="terms" value="accepted" checked required>Agree to terms and conditions</anypoint-checkbox>
   <anypoint-checkbox name="disabled" value="noop" disabled>This is never included</anypoint-checkbox>
  </form>
  <anypoint-button id="submit"></anypoint-button>
</iron-form>
<script>
  document.getElementById('submit').addEventListener('click', () => {
    const values = document.querySelector('iron-form').serializeForm();
    console.log(values);
  });
</script>

Development

git clone https://github.com/anypoint-web-components/anypoint-checkbox
cd anypoint-checkbox
npm install

Running the demo locally

npm start

Running the tests

npm test