Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

select-pure

Package Overview
Dependencies
Maintainers
1
Versions
61
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

select-pure

Pure JavaScript select component.

  • 0.5.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
604
increased by45.89%
Maintainers
1
Weekly downloads
 
Created
Source

SelectPure JavaScript component

npm version gzip size brotli size npm Build Status codecov

Installation

NPM
npm i select-pure --save
Yarn
yarn add select-pure
CDN
<script src="https://unpkg.com/select-pure@latest/dist/bundle.min.js"></script>

Usage

import SelectPure from "select-pure";

new SelectPure(element, config);

`element` // Required. Either selector or HTML node.
`config` // Required. Configuration object.

Configuration

PropertyRequiredTypeDescription
optiontrueArrayCollection of options to be rendered. Each option consists of value, label and optional property disabled. Properties for the single option object are listed below.
classNamesfalseObjectObject with custom classNames to be used inside select. In the next major version default classNames will be removed and this property will become required.
multiplefalseBooleantrue if multiple options can be selected.
autocompletefalseBooleanAdds autocomplete input. Disabled by default.
iconfalseStringIf specified - <i></i> will be inserted inside select-pure__selected-label. Works only with multiple option set to true.
inlineIconfalseHMTLElementCustom cross icon for multiple select.
valuefalseString | ArrayInitially selected value. If not provided - first option will be selected. If multiple is true -- Array should be provided.
placeholderfalseStringPlaceholder for cases when value is not selected by default.
onChangefalseFunctionCallback that returns value when option is being selected. Returns Array if multiple is true.
option

Properties of a single option passed to the options Array in configuration.

PropertyRequiredTypeDescription
valuetrueStringValue of an option.
labeltrueStringLabel of an option.
disabledfalseBooleantrue if option is disabled. false by default.
classNames

In the next major version default classNames will be removed and this property will become required.

PropertyDefault valueDescription
select"select-pure__select"Wrapper div.
dropdownShown"select-pure__select--opened"Applied to the wrapper when dropdown is shown.
multiselect"select-pure__select--multiple"Applied to the wrapper if it's a multiselect.
label"select-pure__label"Label span.
placeholder"select-pure__placeholder"Placeholder span.
dropdown"select-pure__options"Options dropdown.
option"select-pure__option"Single option.
autocompleteInput"select-pure__autocomplete"Autocomplete input
selectedLabel"select-pure__selected-label"Selected label for multiselect.
selectedOption"select-pure__option--selected"Applied to option when selected.
placeholderHidden"select-pure__placeholder--hidden"Hides placeholder when the value is selected.
optionHidden"select-pure__option--hidden"Hides options that does not match autocomplete input.

API

MethodDescription
value()Returns currently selected value.
reset()Resets currently selected value.

Structure

select-pure/
└── lib/
    └── select-pure.min.js

TODO

  • API method for updating select.
  • Mobile select support.
  • Drop support of default classNames (starting from 1.x.x versions).
  • Drop support of default icon, support only inline SVG instead. (starting from 1.x.x versions).

License

MIT

Keywords

FAQs

Package last updated on 29 Feb 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc