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

msc-select-list

v1.0.1

Published

<msc-select-list /> provides a common UI as <select /> and group checkboxs as its drop menu. So user could experience it as usual and have multi-select feature.

Downloads

5

Readme

msc-select-list

Published on webcomponents.org DeepScan grade

Although <select /> supports attribute multiple to let user select multiple options. But the UI will become list and can't hide anymore. It is not easy for user to know press ctrl & click for multi-select option.

<msc-select-list /> provides a common UI as select and group checkboxs as its drop menu. So user could experience it as usual and have multi-select feature.

<msc-select-list />

Basic Usage

<msc-select-list /> is a web component. All we need to do is put the required script into your HTML document. Then follow 's html structure and everything will be all set.

  • Required Script
<script
  type="module"
  src="https://your-domain/wc-msc-select-list.js">        
</script>
  • Structure

Put <msc-select-list /> into HTML document. It will have different functions and looks with attribute mutation.

<msc-select-list>
  <script type="application/json">
    {
      "options": [
        {
          "content": "iPhone 12",
          "value": "iphone12",
          "checked": true
        },
        {
          "content": "iPhone SE",
          "value": "iphonese",
          "disabled": true
        },
        {
          "content": "iPhone 13",
          "value": "iphone13"
        },
        {
          "content": "iPhone 14",
          "value": "iphone14"
        },
        {
          "content": "iPhone 14 Pro",
          "value": "iphone14pro"
        }
      ],
      "placeholder": "Select (multiple)",
      "size": 5,
      "sound": true,
      "vibrate": true
    }
  </script>
</msc-select-list>

Otherwise, developers could also choose remoteconfig to fetch config for <msc-select-list />.

<msc-select-list
  remoteconfig="https://your-domain/api-path"
>
</msc-select-list>

JavaScript Instantiation

<msc-select-list /> could also use JavaScript to create DOM element. Here comes some examples.

<script type="module">
import { MscSelectList } from 'https://your-domain/wc-msc-select-list.js';

// use DOM api
const nodeA = document.createElement('msc-select-list');
document.body.appendChild(nodeA);
nodeA.options = [
  {
    content: 'iPhone 12',
    value: 'iphone12'
  },
  {
    content: 'iPhone SE',
    value: 'iphonese'
  },
  {
    content: 'iPhone 13',
    value: 'iphone13'
  }
];
nodeA.values = ['iphone12'];

// new instance with Class
const nodeB = new MscSelectList();
document.body.appendChild(nodeB);
nodeB.params = [
  {
    content: 'iPhone 12',
    value: 'iphone12'
  },
  {
    content: 'iPhone SE',
    value: 'iphonese'
  },
  {
    content: 'iPhone 13',
    value: 'iphone13'
  }
];

// new instance with Class & default config
const config = {
  options: [
    {
      content: 'iPhone 12',
      value: 'iphone12',
      checked: true
    },
    {
      content: 'iPhone SE',
      value: 'iphonese',
      disabled: true
    },
    {
      content: 'iPhone 13',
      value: 'iphone13'
    },
    {
      content: 'iPhone 14',
      value: "iphone14"
    }
  ],
  placeholder: 'Select (multiple)',
  size: 5,
  sound: true,
  vibrate: true
};

const nodeC = new MscSelectList(config);
document.body.appendChild(nodeC);
</script>

Storage

<msc-select-list /> will generate an input[type=hidden] as storage and put success selected options' value data as its value. <input /> default name is msc-select-list, developers can switch any name they liked.

<msc-select-list>
  <input type="hidden" name="msc-select-list" value="..." />
</msc-select-list>

Style Customization

Developers could apply styles to decorate <msc-select-list />'s looking.

<style>
msc-select-list {
  /* select */
  --msc-select-list-select-background-color: rgba(255 255 255);
  --msc-select-list-select-text-color: rgba(91 99 106);
  --msc-select-list-select-border-color: rgba(110 119 128);
  --msc-select-list-select-theme-color: rgba(53 116 224);

  /* drop menu */
  --msc-select-list-background-color: rgba(255 255 255);
  --msc-select-list-label-color: rgba(35 42 49);
  --msc-select-list-line-color: rgba(198 198 200);
  --msc-select-list-border-color: rgba(198 198 200);
  --msc-select-list-box-shadow: 0 0 1px rgba(0 0 0/.1), 0 2px 4px rgba(0 0 0/.08);
  --msc-select-list-listing-padding-inline: 12px;
  --msc-select-list-listing-padding-block: 12px;

  /* scroll */
  --msc-select-list-scrollbar-thumb-color: rgba(0 0 0/.2);

  /* checkbox */
  --msc-select-list-checkbox-accent-color: rgba(53 116 224);
  --msc-select-list-checkbox-border-color: rgba(131 138 146);
  --msc-select-list-checkbox-background-color: rgba(255 255 255);
  --msc-select-list-checkbox-checkmark-color: rgba(255 255 255);
  --msc-select-list-checkbox-border-color--disabled: rgba(178 185 192);
  --msc-select-list-checkbox-background-color--disabled: rgba(245 248 250);
  --msc-select-list-checkbox-checkmark-color--disabled: rgba(255 255 255);

  /* ripple */
  --msc-select-list-ripple-color: rgba(0 0 0/.15);

  /* drop menu unit (hover) */
  --msc-select-list-overlay: 29 34 40;
}
</style>

Attributes

<msc-select-list /> supports some attributes to let it become more convenience & useful.

  • options

Set options for <msc-select-list />. It should be JSON string. Each element sholud contain content & value (checked & disabled are optional). Default is [] (not set).

<msc-select-list
  options='[{"content":"iPhone 12","value":"iphone12","checked":true},{"content":"iPhone SE","value":"iphonese","disabled":true},{"content":"iPhone 13","value":"iphone13","disabled":true},{"content":"iPhone 14","value":"iphone14"},{"content":"iPhone 14 Pro","value":"iphone14pro"}]'
>
  ...
</msc-select-list>
  • placeholder

Set placeholder for <msc-select-list />. Default is select please (not set).

<msc-select-list
  placeholder="select please"
>
  ...
</msc-select-list>
  • size

Set size for <msc-select-list />. Drop menu apply size for how many options display in a fold (max). Default is 5 (not set).

<msc-select-list
  size="5"
>
  ...
</msc-select-list>
  • sound

Set sound effect for <msc-select-list /> when drop menu tapped.

<msc-select-list
  sound
>
  ...
</msc-select-list>
  • vibrate

Set vibrate effect for <msc-select-list /> when drop menu tapped.

<msc-select-list
  vibrate
>
  ...
</msc-select-list>

Properties

| Property Name | Type | Description | | ----------- | ----------- | ----------- | | options | Array | Getter / Setter for options. Each element sholud contain content & value (checked & disabled are optional). Default is []. ex: selectList.options = [{ content:'option1', value:'option1'}]; | | values | Array | Getter / Setter for values. ex: selectList.values = ['option1', 'option2']; | | placeholder | string | Getter / Setter for placeholder. <msc-select-list /> will display this value when no option selected. Default is select please. | | size | Number | Getter / Setter for size. Drop menu apply size for how many options display in a fold (max). Default is 5. | | sound | Boolean | Getter / Setter for sound. Set sound effect or not when drop menu tapped. Default is false. | | vibrate | Boolean | Getter / Setter for vibrate. Set vibrate effect or not when drop menu tapped. Default is false. |

Event

| Event Signature | Description | | ----------- | ----------- | | msc-select-list-change | Fired when user select option. |

Reference