UNPKG

@stanfordspezi/spezi-web-design-system

Version:

Stanford Biodesign Digital Health Spezi Web Design System

48 lines (47 loc) 1.07 kB
import { jsx as r } from "react/jsx-runtime"; import { u as b } from "./index-CBSFK5oB.mjs"; import { C as x } from "./Checkbox-BGzAZBtE.mjs"; import { S as C } from "./SideLabel-JL7Te7Jc.mjs"; import { c as i } from "./index-2NvaPZWc.mjs"; const G = ({ options: c, value: o, onChange: s, defaultValue: u = [], className: m, direction: d = "column", ...n }) => { const [l, t] = b({ prop: o, defaultProp: u, onChange: s, caller: "CheckboxGroup" }), p = (e, a) => { const f = a ? [...l, e] : l.filter((h) => h !== e); t(f); }; return /* @__PURE__ */ r( "div", { role: "group", className: i( "flex gap-x-4 gap-y-2", d === "column" ? "flex-col" : "flex-wrap", m ), ...n, children: c.map((e) => /* @__PURE__ */ r(C, { label: e.label, children: /* @__PURE__ */ r( x, { checked: l.includes(e.value), disabled: e.disabled, onCheckedChange: (a) => p(e.value, !!a) } ) }, e.value)) } ); }; export { G as C };