Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
select-pure
Advanced tools
Custom JavaScript <select> component. Easy-to-use, accessible, mobile friendly and super efficient
<select>
component. Easy-to-use, accessible, mobile friendly and super efficient.SelectPure is a Web Component (Custom Element) which makes it super easy to use and customize. Main goal is to use extended API of the native HTML <select>
element and provide additional features, like autocomplete, custom styling and many more. The package itself is stable to be used, however, if you've found any issues, please report them here or create a PR of your own.
If you want to use older version, please refer to this README.
SelectPure is very easy to use. At first you have to install a package
yarn add select-pure
or
npm i select-pure --save
then include it in your JavaScript file
import 'select-pure';
and use in the similar way as you would use a native HTML <select>
.
<select-pure name="country" id="country">
<option-pure value="" disabled hidden>-- Please select a country --</option-pure>
<option-pure value="UA">Ukraine</option-pure>
<option-pure value="PL">Poland</option-pure>
<option-pure value="DE">Germany</option-pure>
<option-pure value="US">USA</option-pure>
<option-pure value="US" disabled>Russia</option-pure>
</select-pure>
In order to call API methods of the SelectPure
, subscribe to callbacks or use it's properties, you can simple use querySelector
.
const selectPure = document.querySelector("select-pure");
console.log(selectPure.selectedIndex);
selectPure.disable();
<select-pure>
supports the following attributes: name
, id
, multiple
, default-label
and disabled
.
<option-pure>
supports value
, label
, disabled
, selected
and hidden
attributes.
property | description |
---|---|
selectedIndex | Returns index of the selected option. You can also manipulate selected value with changing this property (selectPure.selectedIndex = 2 ). Just like in the native <select> . |
value | Returns selected value. |
selectedOptions | Returns and array of selected <option> s. Works only in multiple mode. |
values | Returns and array of selected values. Works only in multiple mode. |
If you want to set a callback for when the new value is selected, you can just use the traditional addEventListener
.
const selectPure = document.querySelector("select-pure");
selectPure.addEventListener("change", (event) => {
// You can use
// event.target.value or
// event.currentTarget.value
});
method | description |
---|---|
disable() | Disables select. |
enable() | Enables select. |
open() | Opens a dropdown. |
close() | Closes a dropdown. |
SelectPure offers high level of customisation. You can match any design you want by just providing a simple set of css variables. Below you can find their names and default values that are included in the package.
select-pure {
--select-height: 44px;
--select-width: 100%;
--border-radius: 4px;
--border-width: 1px;
--border-color: #000;
--padding: 0 10px;
--dropdown-z-index: 2;
--disabled-background-color: #bdc3c7;
--disabled-color: #ecf0f1;
--background-color: #fff;
--color: #000;
--hover-background-color: #e3e3e3;
--hover-color: #000;
--selected-background-color: #e3e3e3;
--selected-color: #000;
--dropdown-gap: 0;
--font-size: 14px;
--font-family: inherit;
--font-weight: 400;
--select-outline: 2px solid #e3e3e3;
}
<form>
supportIf you place <select-pure>
inside a <form>
and specify a name
or id
attribute, it will then append a hidden input
with a given name inside a <form>
and trigger change
event, when value is selected.
2.1
MIT
FAQs
Custom JavaScript <select> component. Easy-to-use, accessible, mobile friendly and super efficient
The npm package select-pure receives a total of 530 weekly downloads. As such, select-pure popularity was classified as not popular.
We found that select-pure demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.