@payfit/unity-components
Version:
53 lines (52 loc) • 1.37 kB
JavaScript
import { SelectListOptGroup as e } from "../select-list/parts/SelectListOptGroup.js";
import { SelectListOption as t } from "../select-list/parts/SelectListOption.js";
import { SelectList as n } from "../select-list/SelectList.js";
import { jsx as r } from "react/jsx-runtime";
//#region src/components/filter/Filter.controls.tsx
function i(e) {
return "children" in e && e.children.length > 0;
}
function a(a, o) {
let s = (n) => /* @__PURE__ */ r(e, {
items: n.children,
label: n.label,
children: (e) => /* @__PURE__ */ r(t, {
id: e.id,
textValue: e.label,
children: e.label
})
}), c = (e) => /* @__PURE__ */ r(t, {
id: e.id,
textValue: e.label,
children: e.label
});
return (e, t) => /* @__PURE__ */ r(n, {
...o,
items: a,
value: e,
selectionMode: "multiple",
onChange: (e) => {
t(e);
},
escapeKeyBehavior: "none",
sortSelectedFirst: !0,
className: "uy:scroll-pb-500",
children: (e) => i(e) ? s(e) : c(e)
});
}
function o(e) {
return (t) => {
if (t === "all") return e.flatMap((e) => i(e) ? e.children : e).map((e) => e.label).join(", ");
let n = [];
for (let r of e) {
if (i(r)) {
n.push(...r.children.filter((e) => t.has(e.id)));
continue;
}
t.has(r.id) && n.push(r);
}
return n.map((e) => e.label).join(", ");
};
}
//#endregion
export { a as selectListFilter, o as selectListLabel };