UNPKG

@uva-glass/component-library

Version:

React components UvA

63 lines (62 loc) 2.51 kB
import { jsxs as a, jsx as c } from "react/jsx-runtime"; import { useRef as d } from "react"; import { c as g } from "../../clsx-OuTLNxxd.js"; import { CheckboxButton as w } from "../CheckboxButton/CheckboxButton.js"; import { Label as C } from "../Label/Label.js"; import { Icon as N } from "../Icon/Icon.js"; import '../../assets/CheckboxButtonBar.css';const n = { "checkbox-button-bar__container": "_checkbox-button-bar__container_1b278_1", "checkbox-button-bar__container--label-left": "_checkbox-button-bar__container--label-left_1b278_6", "checkbox-button-bar__container--label-top": "_checkbox-button-bar__container--label-top_1b278_12", "checkbox-button-bar__row-container": "_checkbox-button-bar__row-container_1b278_19", "checkbox-button-bar__row": "_checkbox-button-bar__row_1b278_19", "checkbox-button-bar__error": "_checkbox-button-bar__error_1b278_30" }, y = ({ checkboxes: i, defaultValues: t, label: l, labelPosition: s = "top", required: h = !1, notValidatedText: b = "", disableGroup: u = !1, onSetValues: m }) => { const e = d(t ? t.map(String) : []), x = (o, r) => { o === null ? e.current = e.current.filter((_) => _ !== r) : e.current = [...e.current, r], m(e.current); }, k = (o, r) => o === 0 && r !== 1 ? "start" : o < r - 1 ? "middle" : r === 1 ? "single" : "end"; return /* @__PURE__ */ a( "div", { className: g( n["checkbox-button-bar__container"], n[`checkbox-button-bar__container--label-${s}`] ), children: [ l && /* @__PURE__ */ c(C, { htmlFor: "", required: h, children: l }), /* @__PURE__ */ a("div", { className: n["checkbox-button-bar__row-container"], children: [ /* @__PURE__ */ c("div", { className: n["checkbox-button-bar__row"], children: i.map(({ label: o, value: r, disabled: _ }, f) => /* @__PURE__ */ c( w, { label: o, value: r, isChecked: t ? t.includes(r) : !1, variant: k(f, i.length), disabled: _ || u, notValid: b !== "", onSetValue: (p) => x(p, r) }, `${r}` )) }), b !== "" && /* @__PURE__ */ a("div", { className: n["checkbox-button-bar__error"], children: [ /* @__PURE__ */ c(N, { name: "ExclamationTriangleFill", size: 24 }), b ] }) ] }) ] } ); }; export { y as CheckboxButtonBar }; //# sourceMappingURL=CheckboxButtonBar.js.map