@stanfordspezi/spezi-web-design-system
Version:
Stanford Biodesign Digital Health Spezi Web Design System
49 lines (48 loc) • 1.11 kB
JavaScript
import { jsx as r } from "react/jsx-runtime";
import { u as f } from "./index-DOCb3WPZ.mjs";
import { C as x } from "./Checkbox-DJfQtvL9.mjs";
import { S as C } from "./SideLabel-BKQ9iBHW.mjs";
import { c as i } from "./index-2NvaPZWc.mjs";
const G = ({
options: o,
value: c,
onChange: s,
defaultValue: u = [],
className: d,
direction: m = "column",
...t
}) => {
const [l, n] = f({
prop: c,
defaultProp: u,
onChange: s,
caller: "CheckboxGroup"
}), p = (e, a) => {
const h = a ? [...l, e] : l.filter((b) => b !== e);
n(h);
};
return /* @__PURE__ */ r(
"div",
{
"data-slot": "checkbox-group",
role: "group",
className: i(
"flex gap-x-4 gap-y-2",
m === "column" ? "flex-col" : "flex-wrap",
d
),
...t,
children: o.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
};