![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
@snack-uikit/toggles
Advanced tools
Компоненты, реализующие переключатели.
npm i @snack-uikit/toggles
Хук для элементов внутри группы переключателей.
value: string
Уникальное значение для элемента в группе
function ToggleCard(props: ToggleCardProps) {
const { isChecked, handleClick, multipleSelection } = useToggleGroup(props.id);
return (
<Card {...props} checked={isChecked} onClick={handleClick} multipleSelection={multipleSelection}/>
);
}
const [value, setValue] = useState<string | undefined>(undefined);
function ToggleCard(props: ToggleCardProps) {
const { isChecked, handleClick, multipleSelection } = useToggleGroup(id);
return (
<Card {...props} checked={isChecked} onClick={handleClick} multipleSelection={multipleSelection}/>
);
}
// ITEMS -some array with ToggleCardProps
// ...
return (
<ToggleGroup selectionMode='single' value={value} onChange={setValue}>
{ITEMS.map(props => (
<ToggleCard key={props.id} {...props} />
))}
</ToggleGroup>
);
// ...
return (
<>
{items.map(({ checked, setChecked, data }) =>
<CustomRadioButton
// повторяет нативное поведение радиогруппы: по клику можно выбрать, но нельзя снять выбор
onClick={() => setChecked(true)}
checked={checked}
data={data}
/>
)}
</>
);
name | type | default value | description |
---|---|---|---|
id | string | - | HTML-аттрибут id |
name | string | - | HTML-аттрибут name |
value | string | - | HTML-аттрибут value |
tabIndex | number | - | HTML-аттрибут tab-index |
autofocus | boolean | - | HTML-аттрибут autofocus |
checked | boolean | - | HTML-аттрибут checked |
defaultChecked | boolean | - | HTML-аттрибут checked по-умолчанию |
disabled | boolean | - | HTML-аттрибут disabled |
onChange | (checked: boolean) => void | - | Колбек смены значения |
onClick | MouseEventHandler<HTMLInputElement> | - | Колбек клика |
onBlur | FocusEventHandler<HTMLInputElement> | - | Колбек потери фокуса |
onFocus | FocusEventHandler<HTMLInputElement> | - | Колбек приобретения фокуса |
className | string | - | CSS-класс |
size | enum Size: "s" , "m" | m | Размер |
inputRef | RefObject<HTMLInputElement> | - | |
indeterminate | boolean | - | Состояние частичного выбора |
indeterminateDefault | boolean | - | Состояние частичного выбора по-умолчанию |
name | type | default value | description |
---|---|---|---|
id | string | - | HTML-аттрибут id |
name | string | - | HTML-аттрибут name |
value | string | - | HTML-аттрибут value |
tabIndex | number | - | HTML-аттрибут tab-index |
autofocus | boolean | - | HTML-аттрибут autofocus |
checked | boolean | - | HTML-аттрибут checked |
defaultChecked | boolean | - | HTML-аттрибут checked по-умолчанию |
disabled | boolean | - | HTML-аттрибут disabled |
onChange | (checked: boolean) => void | - | Колбек смены значения |
onClick | MouseEventHandler<HTMLInputElement> | - | Колбек клика |
onBlur | FocusEventHandler<HTMLInputElement> | - | Колбек потери фокуса |
onFocus | FocusEventHandler<HTMLInputElement> | - | Колбек приобретения фокуса |
className | string | - | CSS-класс |
size | enum Size: "s" , "m" | m | Размер |
inputRef | RefObject<HTMLInputElement> | - | |
showIcon | boolean | - | Показывать ли иконку в переключателе |
loading | boolean | - |
name | type | default value | description |
---|---|---|---|
id | string | - | HTML-аттрибут id |
name | string | - | HTML-аттрибут name |
value | string | - | HTML-аттрибут value |
tabIndex | number | - | HTML-аттрибут tab-index |
autofocus | boolean | - | HTML-аттрибут autofocus |
checked | boolean | - | HTML-аттрибут checked |
defaultChecked | boolean | - | HTML-аттрибут checked по-умолчанию |
disabled | boolean | - | HTML-аттрибут disabled |
onChange | (checked: boolean) => void | - | Колбек смены значения |
onClick | MouseEventHandler<HTMLInputElement> | - | Колбек клика |
onBlur | FocusEventHandler<HTMLInputElement> | - | Колбек потери фокуса |
onFocus | FocusEventHandler<HTMLInputElement> | - | Колбек приобретения фокуса |
className | string | - | CSS-класс |
size | enum Size: "s" , "m" | - | Размер |
inputRef | RefObject<HTMLInputElement> | - |
name | type | default value | description |
---|---|---|---|
id | string | - | HTML-аттрибут id |
name | string | - | HTML-аттрибут name |
value | string | - | HTML-аттрибут value |
tabIndex | number | - | HTML-аттрибут tab-index |
autofocus | boolean | - | HTML-аттрибут autofocus |
checked | boolean | - | HTML-аттрибут checked |
defaultChecked | boolean | - | HTML-аттрибут checked по-умолчанию |
disabled | boolean | - | HTML-аттрибут disabled |
onChange | (checked: boolean) => void | - | Колбек смены значения |
onClick | MouseEventHandler<HTMLInputElement> | - | Колбек клика |
onBlur | FocusEventHandler<HTMLInputElement> | - | Колбек потери фокуса |
onFocus | FocusEventHandler<HTMLInputElement> | - | Колбек приобретения фокуса |
className | string | - | CSS-класс |
size | enum Size: "s" , "m" | m | Размер |
inputRef | RefObject<HTMLInputElement> | - | |
icon | enum FavoriteIcon: "star" , "heart" | heart | Иконка |
onKeyUp | KeyboardEventHandler<HTMLDivElement> | - | Колбек нажатия клавиши клавиатуры |
name | type | default value | description |
---|---|---|---|
defaultValue | string | string[] | - | Начальное состояние |
value | string | string[] | - | Controlled состояние |
onChange | ((value: string) => void) | ((value: string[]) => void) | - | Controlled обработчик измения состояния |
selectionMode | "single" | "multiple" | single | Режим выбора |
name | type | default value | description |
---|---|---|---|
value* | string | - |
FAQs
Unknown package
We found that @snack-uikit/toggles demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers 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.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.