
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
@rootre/forms-dropdown
Advanced tools
Generic and lightweight React dropdown component.
With yarn
yarn add @rootre/forms-dropdown
or with npm
npm install @rootre/forms-dropdown
import React from 'react';
import Dropdown from '@rootre/forms-dropdown';
import '@rootre/forms-dropdown/styles.css';
export default function App() {
const items = [
{label: 'Cat'},
{label: 'Dog'},
{label: 'Rabbit'},
{label: 'Parrot'},
];
return (
<div>
<Dropdown
items={items}
afterChange={item => {
console.log('selected item:', item);
}}
/>
</div>
);
}
Your item object can be anything, only mandatory field
is label
key that is shown in component HTML.
You can pass react useState instances to control dropdown's behavior:
import React, {useState} from 'react';
import Dropdown from '@rootre/forms-dropdown';
import '@rootre/forms-dropdown/styles.css';
export default function App() {
const items = [
{label: 'Cat'},
{label: 'Dog'},
{label: 'Rabbit'},
{label: 'Parrot'},
];
const activeItemController = useState(items[0]); // bare in mind that controllers override initials
const openController = useState(false);
const [, setActiveItem] = activeItemController;
const [, setOpen] = openController;
return (
<div>
<button onClick={() => setActiveItem(items[2])}>Set Rabbit</button>
<button onClick={() => setOpen(true)}>Open dropdown</button>
<Dropdown
items={items}
controllers={{
active: activeItemController,
open: openController,
}}
/>
</div>
);
}
Controllers override initials, so if you want set controller for active item (controllers.active) you set initial active item in
useState(initialItem)
Component classes are bundled via CSS modules and uses local ident name: dropdown_[local]
import '@rootre/forms-dropdown/styles.css';
Importing whole css file get you all basic formatting.
Optionally, if you use overrides: itemTemplate
or itemsTemplate
you could use
defaults from original sass file:
import '@rootre/forms-dropdown/styles.scss';
It gets you following defaults:
.activeItem {} /* selected item */
.content {} /* wrapping div of opened dropdown contents */
.dropdown {} /* the whole dropdown */
.item {} /* item in opened dropdown list */
.list {} /* wrapping div of opened dropdown list */
Check out basic demo page
(label: string) => React.Component
default:
function activeItemTemplate(label) {
return <span>{label}</span>;
}
(item: object) => void
default: () => {}
(isOpen: boolean) => void
default: () => {}
object
Array.<function>
default:
React.useState(null)
Controller for getting/setting active item
Array.<function>
default:
React.useState(false)
Controller for opening/closing dropdown
boolean
default:
false
Passing true renders the component disabled/unclickable
boolean
default:
false
If true, an error class is added. Default styling paints borders in red
boolean
default:
false
If dropdown should be rendered open or not
object
default:
null
Item that will be shown on first render
(item: object, handleSelect: function, index: number, labelKey: string) => React.Component
default:
function itemTemplate(item, handleSelect, index, labelKey) {
return (
<div key={index} onClick={() => handleSelect(item)}>
<span>{item[labelKey]}</span>
</div>
);
}
Use for custom formatting items in dropdown
(items: object[], handleSelect: function, labelKey: string, itemTemplate: function) => React.Component
default:
function itemsTemplate(items, handleSelect, labelKey, itemTemplate) {
return (
<div className={styles.list}>
{items.map((item, index) => itemTemplate(item, handleSelect, index, labelKey))}
</div>
)
}
Use if you want to override the whole list of items in dropdown
Array.<object>
default:
[]
Can be array of any objects you want, but each object has to have labelKey
property set
string
default:
label
Determines which item's object property will be used for rendering label inside dropdown
string
default:
''
A placeholder text for dropdown
FAQs
Dropdown component AKA selectbox for various usages
The npm package @rootre/forms-dropdown receives a total of 1 weekly downloads. As such, @rootre/forms-dropdown popularity was classified as not popular.
We found that @rootre/forms-dropdown 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
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.