UNPKG

sate-lib

Version:

A lightweight and modular React component library designed for modern web interfaces. **SATE Lib** powers the [sate.menu](https://sate.menu) platform with reusable, scalable, and themeable UI components.

1 lines 922 B
import{jsx as e,jsxs as i}from"react/jsx-runtime";import{useState as o}from"react";import{Icon as r}from"../icon/icon.js";import{Badge as t}from"../badge/badge.js";import l from"./filter-chip.styles.module.js";function n({options:n,selected:a,onChange:c,mode:m="multiple",size:s="medium",className:d=""}){let p=void 0!==a,[u,f]=o([]),b=p?a:u;return e("div",{className:[l.root,d].filter(Boolean).join(" "),role:"single"===m?"radiogroup":"group",children:n.map(({value:o,label:n,icon:a,badge:d,disabled:u})=>{let g=b.includes(o),h=a||d;return i("button",{type:"button",role:"single"===m?"radio":"checkbox","aria-checked":g,"aria-disabled":u,disabled:u,onClick:()=>{let e;e="single"===m?[o]:b.includes(o)?b.filter(e=>e!==o):[...b,o],!p&&f(e),c?.(e)},className:[l.item,l[s],h?l.hasIcon:l.noIcon,g&&l.selected].filter(Boolean).join(" "),children:[d&&e(t,{...d}),a&&e(r,{name:a,size:24}),n]},o)})})}export{n as FilterChipGroup};