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.
Build custom select menus in React. Provides a low level way to build the select menu you need.
npm install selectly --save
bower install selectly --save
import { Select, Trigger, OptionList, Option, utils } from 'Selectly'
const { getToggledValues } = utils
class MultiSelect extends Component {
constructor(props) {
super(props)
this.state = {
defaultValue: 'Select a color',
currentValues: []
}
}
_handleChange(value) {
this.setState({
currentValues: getToggledValues(this.state.currentValues, value)
})
}
render() {
const { defaultValue, currentValues } = this.state
return (
<Select
multiple
onChange={value => this._handleChange(value)}
>
<Trigger>
{ currentValues.length > 0
? currentValues.join(', ')
: defaultValue
}
</Trigger>
<OptionList tag="ul" className="react-select-menu">
<Option value="red">Red</Option>
<Option value="green">Green</Option>
<Option value="blue">Blue</Option>
</OptionList>
</Select>
)
}
}
children
: PropTypes.node.isRequired (Accepts 2 children)The first child is used as the trigger
and the second child is used as the options
that will be displayed upon clicking the trigger.
multiple
: PropTypes.boolWhen true
this allows multiple options to be selected.
disabled
: PropTypes.boolPuts the select menu in a disabled state.
autoWidth
: PropTypes.boolDetermines if the options
should be the same width as the trigger
.
onChange
: PropTypes.funcCallback when an option has been selected. Passes back the value that was selected.
Trigger
, OptionList
, and Option
are exported directly from React ARIA
buildOptionsLookup
: (array options)Returns a flat object to allow optgroup options to be accessed easier.
[
{ label: 'Dogs', optgroup: [
{ value: 'frenchy', label: 'French Bulldog' },
{ value: 'pit-bull', label: 'Pit Bull' }
]},
{ label: 'Cats', optgroup: [
{ value: 'munchkin', label: 'Munchkin' },
{ value: 'persian', label: 'Persian' }
]}
]
turns into
{
'frenchy': { value: 'frenchy', label: 'French Bulldog' },
'pit-bull': { value: 'pit-bull', label: 'Pit Bull' },
'munchkin': { value: 'munchkin', label: 'Munchkin' },
'persian': { value: 'persian', label: 'Persian' }
}
getAllValues
: (object options)Returns an array of all option values.
getToggledValues
: (object prevValues, [array, string] nextValues)Returns a new array of values either added or removed.
getCurrentOptions
: (object options, [array, string] currentValue)Returns an array of the current option or options.
isOptionSelected
: ([array, string] currentValue, string value)Determines if value
exists in or matches currentValue
. Returns true
or false
.
clone repo
git clone git@github.com:souporserious/selectly.git
move into folder
cd ~/selectly
install dependencies
npm install
run dev mode
npm run dev
open your browser and visit: http://localhost:8080/
0.5.0
Replaced parts with React ARIA where applicable
Added better documentation
Breaking Changes:
Added mandatory components Trigger
, OptionList
, and Option
FAQs
Build custom, accessible, select menus for React.
The npm package selectly receives a total of 150 weekly downloads. As such, selectly popularity was classified as not popular.
We found that selectly 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.