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