stone-kit
Version:
uikit for redesign
80 lines (79 loc) • 2.49 kB
JavaScript
import { jsxs as d, Fragment as y, jsx as n } from "react/jsx-runtime";
import { s as t, O as F } from "../../../Option-DdjBe9yb.js";
import { NewIcon as w } from "../../NewIcon/ui/NewIcon.js";
import { c as H } from "../../../index-YnD2EP-S.js";
import { useState as I } from "react";
const J = H.bind(t), z = ({
category: o,
selectedOptions: i,
disabledOptions: r,
clickableOptions: s,
handleOptionClick: p,
sizeIcon: l,
isDisabledNotClickable: f,
mode: h
}) => {
const [a, g] = I(!1), N = i.map((e) => JSON.stringify(e)), c = h === "category", v = h === "double", b = c && o.options.every((e) => N.includes(JSON.stringify(e))), k = s ? s.includes(o.value.toString()) : !0, C = i.some((e) => e.value === o.value), u = () => f && s ? !s.includes(o.value.toString()) : r.some(
(e) => e.value === o.value
), D = c ? b ? "selectChecked" : "selectUncheckedHollow" : v && C ? "selectChecked" : "selectUncheckedHollow", S = o.options.length > 1;
return /* @__PURE__ */ d(y, { children: [
/* @__PURE__ */ d(
"div",
{
className: J(
t.option,
t.category,
{
[t.optionDisabled]: u(),
[t.optionClickable]: k
}
),
onClick: () => {
u() && !C || (v && !a && g(!0), p(c ? o.options : o));
},
children: [
/* @__PURE__ */ d("div", { className: t.leftSide, children: [
/* @__PURE__ */ n(
w,
{
size: l ?? "20",
name: D
}
),
/* @__PURE__ */ n("div", { className: t.optionLabel, children: o.label })
] }),
S && /* @__PURE__ */ n("div", { className: t.iconArrow, onClick: (e) => {
e.stopPropagation(), g((m) => !m);
}, children: /* @__PURE__ */ n(
w,
{
name: "arrowShort",
deg: a ? "180" : "0",
size: l ?? "24"
}
) })
]
}
),
a && S && o.options.map((e, m) => {
const x = u() ? [...r, ...o.options] : r;
return /* @__PURE__ */ n(
F,
{
option: e,
disabledOptions: x,
selectedOptions: i,
handleOptionClick: () => p(e),
sizeIcon: l,
clickableOptions: s,
isOptionCategory: !0,
isDisabledNotClickable: f
},
m
);
})
] });
};
export {
z as Category
};