@pibit.ai/cure-design-system 0.6.41 → 0.6.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/primitives/hierarchical-select/HierarchicalSelect.d.ts.map +1 -1
- package/dist/primitives/hierarchical-select/HierarchicalSelect.js +47 -41
- package/dist/primitives/hierarchical-select/components/HierarchicalItem.d.ts.map +1 -1
- package/dist/primitives/hierarchical-select/components/HierarchicalItem.js +54 -48
- package/dist/primitives/hierarchical-select/utils/selection.d.ts.map +1 -1
- package/dist/primitives/hierarchical-select/utils/selection.js +63 -63
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HierarchicalSelect.d.ts","sourceRoot":"","sources":["../../../src/primitives/hierarchical-select/HierarchicalSelect.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,KAAK,EAAE,uBAAuB,EAAgD,MAAM,SAAS,CAAC;AAuBrG,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,EAClC,IAAW,EACX,IAAI,EACJ,YAAY,EACZ,aAAa,EACb,eAAe,EACf,QAAQ,EACR,iBAA8C,EAC9C,SAAe,EACf,SAAS,EACT,aAAoB,EACpB,eAAe,GAClB,EAAE,uBAAuB,CAAC,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"HierarchicalSelect.d.ts","sourceRoot":"","sources":["../../../src/primitives/hierarchical-select/HierarchicalSelect.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,KAAK,EAAE,uBAAuB,EAAgD,MAAM,SAAS,CAAC;AAuBrG,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,EAClC,IAAW,EACX,IAAI,EACJ,YAAY,EACZ,aAAa,EACb,eAAe,EACf,QAAQ,EACR,iBAA8C,EAC9C,SAAe,EACf,SAAS,EACT,aAAoB,EACpB,eAAe,GAClB,EAAE,uBAAuB,CAAC,CAAC,CAAC,2CA8O5B;yBA1Pe,kBAAkB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { jsxs as T, jsx as
|
|
2
|
-
import { useState as
|
|
1
|
+
import { jsxs as T, jsx as l } from "react/jsx-runtime";
|
|
2
|
+
import { useState as P, useMemo as a, useEffect as R, useCallback as S } from "react";
|
|
3
3
|
import { HierarchicalItem as U } from "./components/HierarchicalItem.js";
|
|
4
4
|
import { getAllParentIds as W, toggleSelection as X, getVisibleLeafIds as Y, getSelectAllState as Z, toggleSelectAll as z, getSelectionState as K } from "./utils/selection.js";
|
|
5
5
|
import { searchTree as ee } from "./utils/search.js";
|
|
@@ -20,39 +20,39 @@ function le({
|
|
|
20
20
|
transformData: E,
|
|
21
21
|
reconstructData: v,
|
|
22
22
|
onChange: I,
|
|
23
|
-
searchPlaceholder:
|
|
23
|
+
searchPlaceholder: $ = "Search objects or fields",
|
|
24
24
|
maxHeight: N = 400,
|
|
25
|
-
className:
|
|
26
|
-
showSelectAll:
|
|
25
|
+
className: D,
|
|
26
|
+
showSelectAll: H = !0,
|
|
27
27
|
childCountLabel: Q
|
|
28
28
|
}) {
|
|
29
|
-
const [u, V] =
|
|
30
|
-
|
|
29
|
+
const [u, V] = P(""), [C, w] = P(() => /* @__PURE__ */ new Set()), t = a(() => E(h, m), [h, m, E]), f = a(() => W(t), [t]), q = a(() => Array.from(f).sort().join("\0"), [f]);
|
|
30
|
+
R(() => {
|
|
31
31
|
w(new Set(f));
|
|
32
32
|
}, [q]);
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
const n = a(() => ee(t, u), [t, u]), i = !!u.trim();
|
|
34
|
+
R(() => {
|
|
35
|
+
i && w((e) => {
|
|
36
36
|
const s = new Set(e);
|
|
37
|
-
return
|
|
37
|
+
return n.visibleIds.forEach((r) => {
|
|
38
38
|
let o = t.parentMap.get(r);
|
|
39
39
|
for (; o; )
|
|
40
40
|
s.add(o), o = t.parentMap.get(o) ?? null;
|
|
41
41
|
}), s;
|
|
42
42
|
});
|
|
43
|
-
}, [
|
|
43
|
+
}, [i, n.visibleIds, t]);
|
|
44
44
|
const B = S(
|
|
45
45
|
(e) => {
|
|
46
46
|
const r = u.trim().length > 0 && e.trim().length === 0;
|
|
47
47
|
V(e), r && w(new Set(f));
|
|
48
48
|
},
|
|
49
49
|
[u, f]
|
|
50
|
-
), p = a(() =>
|
|
50
|
+
), p = a(() => i ? n.visibleIds : void 0, [i, n.visibleIds]), _ = S(
|
|
51
51
|
(e) => {
|
|
52
|
-
const s =
|
|
52
|
+
const s = i ? n.visibleIds : void 0, r = X(e, t, s), o = v(r, h, m);
|
|
53
53
|
I(o);
|
|
54
54
|
},
|
|
55
|
-
[t,
|
|
55
|
+
[t, i, n.visibleIds, v, h, m, I]
|
|
56
56
|
), F = a(() => Y(t, p).length, [t, p]), j = a(() => Z(t, p), [t, p]), g = F === 0, M = S(() => {
|
|
57
57
|
if (g) return;
|
|
58
58
|
const e = z(t, p), s = v(e, h, m);
|
|
@@ -62,36 +62,36 @@ function le({
|
|
|
62
62
|
const r = new Set(s);
|
|
63
63
|
return r.has(e) ? r.delete(e) : r.add(e), r;
|
|
64
64
|
});
|
|
65
|
-
}, []),
|
|
65
|
+
}, []), A = a(() => {
|
|
66
66
|
const e = [], s = (r) => {
|
|
67
67
|
(r === null ? t.rootIds : t.childrenMap.get(r) || []).forEach((c) => {
|
|
68
|
-
if (
|
|
68
|
+
if (i && !n.visibleIds.has(c))
|
|
69
69
|
return;
|
|
70
70
|
const x = t.items.get(c);
|
|
71
71
|
x && (e.push({
|
|
72
72
|
id: c,
|
|
73
73
|
item: x,
|
|
74
|
-
isMatched:
|
|
75
|
-
}), x.hasChildren &&
|
|
74
|
+
isMatched: n.matchedIds.has(c)
|
|
75
|
+
}), x.hasChildren && C.has(c) && s(c));
|
|
76
76
|
});
|
|
77
77
|
};
|
|
78
78
|
return s(null), e;
|
|
79
|
-
}, [t,
|
|
79
|
+
}, [t, i, n.visibleIds, n.matchedIds, C]), J = S(
|
|
80
80
|
(e) => {
|
|
81
|
-
if (!
|
|
82
|
-
const s =
|
|
81
|
+
if (!i) return null;
|
|
82
|
+
const s = n.resultCounts.get(e);
|
|
83
83
|
return s === void 0 ? null : `${s} ${s === 1 ? "result" : "results"}`;
|
|
84
84
|
},
|
|
85
|
-
[
|
|
86
|
-
), k = t.items.size > 0, O =
|
|
87
|
-
return /* @__PURE__ */ T("div", { className: b("flex flex-col border border-primary rounded-lg bg-primary overflow-hidden",
|
|
88
|
-
/* @__PURE__ */
|
|
85
|
+
[i, n.resultCounts]
|
|
86
|
+
), k = t.items.size > 0, O = H && k && (!i || A.length > 0), L = i ? "Select all results" : "Select All";
|
|
87
|
+
return /* @__PURE__ */ T("div", { className: b("flex flex-col border border-primary rounded-lg bg-primary overflow-hidden", D), children: [
|
|
88
|
+
/* @__PURE__ */ l("div", { className: "border-b border-secondary p-2", children: /* @__PURE__ */ l(
|
|
89
89
|
te,
|
|
90
90
|
{
|
|
91
91
|
size: d == "xs" ? "sm" : d,
|
|
92
92
|
value: u,
|
|
93
93
|
onChange: B,
|
|
94
|
-
placeholder:
|
|
94
|
+
placeholder: $
|
|
95
95
|
}
|
|
96
96
|
) }),
|
|
97
97
|
O && /* @__PURE__ */ T(
|
|
@@ -104,30 +104,36 @@ function le({
|
|
|
104
104
|
onClick: M,
|
|
105
105
|
"aria-disabled": g,
|
|
106
106
|
children: [
|
|
107
|
-
j === "indeterminate" ? /* @__PURE__ */
|
|
108
|
-
|
|
107
|
+
j === "indeterminate" ? /* @__PURE__ */ l(se, { name: "MinusSquare", className: "size-4 text-utility-brand-600" }) : /* @__PURE__ */ l(
|
|
108
|
+
"span",
|
|
109
109
|
{
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
110
|
+
onClick: (e) => e.stopPropagation(),
|
|
111
|
+
children: /* @__PURE__ */ l(
|
|
112
|
+
re,
|
|
113
|
+
{
|
|
114
|
+
isSelected: j === "selected",
|
|
115
|
+
isDisabled: g,
|
|
116
|
+
onChange: M,
|
|
117
|
+
"aria-label": L
|
|
118
|
+
}
|
|
119
|
+
)
|
|
114
120
|
}
|
|
115
121
|
),
|
|
116
|
-
/* @__PURE__ */
|
|
122
|
+
/* @__PURE__ */ l("span", { className: b("font-medium text-primary", y[d]), children: L })
|
|
117
123
|
]
|
|
118
124
|
}
|
|
119
125
|
),
|
|
120
|
-
/* @__PURE__ */
|
|
126
|
+
/* @__PURE__ */ l(
|
|
121
127
|
"div",
|
|
122
128
|
{
|
|
123
129
|
className: "overflow-y-auto",
|
|
124
130
|
style: { maxHeight: typeof N == "number" ? `${N}px` : N },
|
|
125
131
|
role: "listbox",
|
|
126
132
|
"aria-multiselectable": "true",
|
|
127
|
-
children: k ?
|
|
133
|
+
children: k ? A.length === 0 ? /* @__PURE__ */ l("div", { className: b("flex items-center justify-center py-8 text-tertiary", y[d]), children: "No results found" }) : A.map(({ id: e, item: s, isMatched: r }) => {
|
|
128
134
|
const o = s.depth === 0 ? J(e) : null, c = K(e, t), x = s.disabled === !0;
|
|
129
|
-
return /* @__PURE__ */
|
|
130
|
-
/* @__PURE__ */
|
|
135
|
+
return /* @__PURE__ */ l("div", { children: /* @__PURE__ */ T("div", { className: "flex items-center", children: [
|
|
136
|
+
/* @__PURE__ */ l("div", { className: "flex-1", children: /* @__PURE__ */ l(
|
|
131
137
|
U,
|
|
132
138
|
{
|
|
133
139
|
size: d,
|
|
@@ -137,15 +143,15 @@ function le({
|
|
|
137
143
|
searchQuery: u,
|
|
138
144
|
onToggle: _,
|
|
139
145
|
isExpandable: s.hasChildren,
|
|
140
|
-
isExpanded:
|
|
146
|
+
isExpanded: C.has(e),
|
|
141
147
|
onExpandToggle: () => G(e),
|
|
142
148
|
isDisabled: x,
|
|
143
149
|
childCountLabel: Q
|
|
144
150
|
}
|
|
145
151
|
) }),
|
|
146
|
-
o && /* @__PURE__ */
|
|
152
|
+
o && /* @__PURE__ */ l("span", { className: b("text-tertiary pr-3 whitespace-nowrap", y[d]), children: o })
|
|
147
153
|
] }) }, e);
|
|
148
|
-
}) : /* @__PURE__ */
|
|
154
|
+
}) : /* @__PURE__ */ l("div", { className: b("flex items-center justify-center py-8 text-tertiary", y[d]), children: "No items available" })
|
|
149
155
|
}
|
|
150
156
|
)
|
|
151
157
|
] });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HierarchicalItem.d.ts","sourceRoot":"","sources":["../../../../src/primitives/hierarchical-select/components/HierarchicalItem.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAkBtD,eAAO,MAAM,gBAAgB;oIAW1B,qBAAqB;;
|
|
1
|
+
{"version":3,"file":"HierarchicalItem.d.ts","sourceRoot":"","sources":["../../../../src/primitives/hierarchical-select/components/HierarchicalItem.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAkBtD,eAAO,MAAM,gBAAgB;oIAW1B,qBAAqB;;CAmFvB,CAAC"}
|
|
@@ -1,95 +1,101 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useCallback as
|
|
1
|
+
import { jsxs as o, jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback as x } from "react";
|
|
3
3
|
import { ChevronDown as g } from "@untitledui/icons";
|
|
4
4
|
import { HighlightedText as w } from "./HighlightedText.js";
|
|
5
|
-
import { cx as
|
|
5
|
+
import { cx as l } from "../../../utils/cn.js";
|
|
6
6
|
import { Icon as _ } from "../../icon/icon.js";
|
|
7
|
-
import { Checkbox as
|
|
8
|
-
import { ButtonUtility as
|
|
9
|
-
const
|
|
7
|
+
import { Checkbox as k } from "../../checkbox/checkbox.js";
|
|
8
|
+
import { ButtonUtility as I } from "../../button/button-utility.js";
|
|
9
|
+
const L = 24, C = {
|
|
10
10
|
xs: "text-xs",
|
|
11
11
|
sm: "text-sm",
|
|
12
12
|
md: "text-md",
|
|
13
13
|
lg: "text-lg"
|
|
14
14
|
}, v = { singular: "subfield", plural: "subfields" }, H = ({
|
|
15
|
-
size:
|
|
15
|
+
size: n = "md",
|
|
16
16
|
item: t,
|
|
17
|
-
selectionState:
|
|
18
|
-
searchQuery:
|
|
17
|
+
selectionState: c,
|
|
18
|
+
searchQuery: d,
|
|
19
19
|
onToggle: m,
|
|
20
20
|
isExpandable: y = !1,
|
|
21
|
-
isExpanded:
|
|
21
|
+
isExpanded: s = !1,
|
|
22
22
|
onExpandToggle: a,
|
|
23
|
-
isDisabled:
|
|
24
|
-
childCountLabel:
|
|
23
|
+
isDisabled: r = !1,
|
|
24
|
+
childCountLabel: p = v
|
|
25
25
|
}) => {
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
}, [
|
|
29
|
-
(
|
|
30
|
-
|
|
26
|
+
const h = x(() => {
|
|
27
|
+
r || m(t.id);
|
|
28
|
+
}, [r, t.id, m]), N = x(
|
|
29
|
+
(i) => {
|
|
30
|
+
i.stopPropagation(), a == null || a();
|
|
31
31
|
},
|
|
32
32
|
[a]
|
|
33
|
-
),
|
|
34
|
-
return /* @__PURE__ */
|
|
33
|
+
), f = c === "selected", b = c === "indeterminate", u = t.depth === 0;
|
|
34
|
+
return /* @__PURE__ */ o(
|
|
35
35
|
"div",
|
|
36
36
|
{
|
|
37
|
-
className:
|
|
37
|
+
className: l(
|
|
38
38
|
"flex items-center justify-between gap-2 py-2.5 px-3 transition-colors",
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
r ? "cursor-not-allowed opacity-50" : "cursor-pointer hover:bg-secondary_subtle/50",
|
|
40
|
+
u && "bg-secondary_subtle/30"
|
|
41
41
|
),
|
|
42
|
-
style: { paddingLeft: `${12 + t.depth *
|
|
43
|
-
onClick:
|
|
42
|
+
style: { paddingLeft: `${12 + t.depth * L}px` },
|
|
43
|
+
onClick: h,
|
|
44
44
|
role: "option",
|
|
45
|
-
"aria-selected":
|
|
46
|
-
"aria-disabled":
|
|
45
|
+
"aria-selected": f,
|
|
46
|
+
"aria-disabled": r,
|
|
47
47
|
children: [
|
|
48
|
-
/* @__PURE__ */
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
/* @__PURE__ */ o("div", { className: "flex min-w-0 flex-1 items-center gap-2", children: [
|
|
49
|
+
b && !r ? /* @__PURE__ */ e(_, { name: "MinusSquare", className: "size-4 shrink-0 text-utility-brand-600" }) : /* @__PURE__ */ e(
|
|
50
|
+
"span",
|
|
51
51
|
{
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
52
|
+
onClick: (i) => i.stopPropagation(),
|
|
53
|
+
children: /* @__PURE__ */ e(
|
|
54
|
+
k,
|
|
55
|
+
{
|
|
56
|
+
isSelected: f,
|
|
57
|
+
isDisabled: r,
|
|
58
|
+
onChange: h,
|
|
59
|
+
"aria-label": t.label
|
|
60
|
+
}
|
|
61
|
+
)
|
|
56
62
|
}
|
|
57
63
|
),
|
|
58
|
-
/* @__PURE__ */
|
|
59
|
-
/* @__PURE__ */
|
|
64
|
+
/* @__PURE__ */ o("div", { className: "flex min-w-0 flex-1 items-center gap-2", children: [
|
|
65
|
+
/* @__PURE__ */ e(
|
|
60
66
|
"span",
|
|
61
67
|
{
|
|
62
|
-
className:
|
|
68
|
+
className: l(
|
|
63
69
|
"text-secondary truncate",
|
|
64
|
-
|
|
65
|
-
|
|
70
|
+
u && "font-semibold text-primary",
|
|
71
|
+
C[n]
|
|
66
72
|
),
|
|
67
|
-
children:
|
|
73
|
+
children: d ? /* @__PURE__ */ e(w, { text: t.label, highlight: d }) : t.label
|
|
68
74
|
}
|
|
69
75
|
),
|
|
70
|
-
t.hasChildren && t.childCount > 0 && /* @__PURE__ */
|
|
76
|
+
t.hasChildren && t.childCount > 0 && /* @__PURE__ */ o("span", { className: l("text-tertiary whitespace-nowrap", C[n]), children: [
|
|
71
77
|
t.childCount,
|
|
72
78
|
" ",
|
|
73
|
-
t.childCount === 1 ?
|
|
79
|
+
t.childCount === 1 ? p.singular : p.plural
|
|
74
80
|
] })
|
|
75
81
|
] })
|
|
76
82
|
] }),
|
|
77
|
-
y ? /* @__PURE__ */
|
|
78
|
-
|
|
83
|
+
y ? /* @__PURE__ */ e(
|
|
84
|
+
I,
|
|
79
85
|
{
|
|
80
86
|
size: "3xs",
|
|
81
87
|
color: "tertiary",
|
|
82
|
-
icon: /* @__PURE__ */
|
|
88
|
+
icon: /* @__PURE__ */ e(
|
|
83
89
|
g,
|
|
84
90
|
{
|
|
85
91
|
"data-icon": !0,
|
|
86
92
|
size: 16,
|
|
87
|
-
className:
|
|
93
|
+
className: l("transition-transform duration-200", s && "rotate-180")
|
|
88
94
|
}
|
|
89
95
|
),
|
|
90
|
-
tooltip:
|
|
91
|
-
"aria-expanded":
|
|
92
|
-
onClick:
|
|
96
|
+
tooltip: s ? "Collapse" : "Expand",
|
|
97
|
+
"aria-expanded": s,
|
|
98
|
+
onClick: N
|
|
93
99
|
}
|
|
94
100
|
) : null
|
|
95
101
|
]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"selection.d.ts","sourceRoot":"","sources":["../../../../src/primitives/hierarchical-select/utils/selection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAU/D;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,EAAE,UAAU,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,cAAc,
|
|
1
|
+
{"version":3,"file":"selection.d.ts","sourceRoot":"","sources":["../../../../src/primitives/hierarchical-select/utils/selection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAU/D;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,EAAE,UAAU,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,cAAc,CA+BhH;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,EAAE,UAAU,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,cAAc,CA+F9G;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,cAAc,GAAG,GAAG,CAAC,MAAM,CAAC,CAQjE;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,cAAc,EAAE,UAAU,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,MAAM,EAAE,CAQ1F;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,cAAc,EAAE,UAAU,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,cAAc,CAYhG;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,cAAc,EAAE,UAAU,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,cAAc,CAyC9F;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,cAAc,GAAG,MAAM,CAS/D"}
|
|
@@ -1,107 +1,107 @@
|
|
|
1
1
|
function g(t, e) {
|
|
2
|
-
var
|
|
3
|
-
return ((
|
|
2
|
+
var n;
|
|
3
|
+
return ((n = t.items.get(e)) == null ? void 0 : n.disabled) === !0;
|
|
4
4
|
}
|
|
5
5
|
function C(t, e) {
|
|
6
|
-
return e.filter((
|
|
6
|
+
return e.filter((n) => !g(t, n));
|
|
7
7
|
}
|
|
8
|
-
function S(t, e,
|
|
8
|
+
function S(t, e, n) {
|
|
9
9
|
var p;
|
|
10
|
-
const
|
|
11
|
-
if (
|
|
12
|
-
const
|
|
13
|
-
return
|
|
10
|
+
const s = e.childrenMap.get(t) || [];
|
|
11
|
+
if (s.length === 0) {
|
|
12
|
+
const c = e.items.get(t);
|
|
13
|
+
return c != null && c.selected ? "selected" : "unselected";
|
|
14
14
|
}
|
|
15
15
|
if (g(e, t)) return "unselected";
|
|
16
|
-
let l = C(e,
|
|
17
|
-
if (
|
|
16
|
+
let l = C(e, s);
|
|
17
|
+
if (n && (l = l.filter((c) => n.has(c))), l.length === 0)
|
|
18
18
|
return (p = e.items.get(t)) != null && p.selected ? "selected" : "unselected";
|
|
19
|
-
const d = l.map((
|
|
20
|
-
return
|
|
19
|
+
const d = l.map((c) => S(c, e, n)), i = d.every((c) => c === "selected"), h = d.every((c) => c === "unselected");
|
|
20
|
+
return i ? "selected" : h ? "unselected" : "indeterminate";
|
|
21
21
|
}
|
|
22
|
-
function E(t, e,
|
|
22
|
+
function E(t, e, n) {
|
|
23
23
|
if (g(e, t))
|
|
24
24
|
return e;
|
|
25
|
-
const
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
if (!g(e, a) && (!
|
|
29
|
-
const
|
|
30
|
-
|
|
25
|
+
const s = new Map(e.items), d = S(t, e, n) !== "selected", i = /* @__PURE__ */ new Set(), h = (o) => {
|
|
26
|
+
const u = e.childrenMap.get(o) || [];
|
|
27
|
+
u.length > 0 && i.add(o), u.forEach((a) => {
|
|
28
|
+
if (!g(e, a) && (!n || n.has(a))) {
|
|
29
|
+
const m = s.get(a), w = e.childrenMap.get(a) || [];
|
|
30
|
+
m && (w.length === 0 ? s.set(a, { ...m, selected: d }) : i.add(a)), h(a);
|
|
31
31
|
}
|
|
32
32
|
});
|
|
33
|
-
}, p =
|
|
34
|
-
p && (
|
|
35
|
-
const r = Array.from(
|
|
33
|
+
}, p = s.get(t), c = e.childrenMap.get(t) || [];
|
|
34
|
+
p && (c.length === 0 ? g(e, t) || s.set(t, { ...p, selected: d }) : i.add(t)), h(t);
|
|
35
|
+
const r = Array.from(i).sort((o, u) => {
|
|
36
36
|
const a = e.depthMap.get(o) ?? 0;
|
|
37
|
-
return (e.depthMap.get(
|
|
37
|
+
return (e.depthMap.get(u) ?? 0) - a;
|
|
38
38
|
});
|
|
39
39
|
for (const o of r) {
|
|
40
|
-
const
|
|
41
|
-
if (
|
|
42
|
-
const a = S(o, { ...e, items:
|
|
43
|
-
|
|
44
|
-
...
|
|
40
|
+
const u = s.get(o);
|
|
41
|
+
if (u) {
|
|
42
|
+
const a = S(o, { ...e, items: s });
|
|
43
|
+
s.set(o, {
|
|
44
|
+
...u,
|
|
45
45
|
selected: a !== "unselected"
|
|
46
46
|
});
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
let f = e.parentMap.get(t);
|
|
50
50
|
for (; f; ) {
|
|
51
|
-
const o =
|
|
51
|
+
const o = s.get(f);
|
|
52
52
|
if (o) {
|
|
53
|
-
const
|
|
54
|
-
|
|
53
|
+
const u = S(f, { ...e, items: s });
|
|
54
|
+
s.set(f, {
|
|
55
55
|
...o,
|
|
56
|
-
selected:
|
|
56
|
+
selected: u !== "unselected"
|
|
57
57
|
});
|
|
58
58
|
}
|
|
59
59
|
f = e.parentMap.get(f) ?? null;
|
|
60
60
|
}
|
|
61
|
-
return { ...e, items:
|
|
61
|
+
return { ...e, items: s };
|
|
62
62
|
}
|
|
63
63
|
function y(t) {
|
|
64
64
|
const e = /* @__PURE__ */ new Set();
|
|
65
|
-
return t.items.forEach((
|
|
66
|
-
|
|
65
|
+
return t.items.forEach((n, s) => {
|
|
66
|
+
n.hasChildren && e.add(s);
|
|
67
67
|
}), e;
|
|
68
68
|
}
|
|
69
|
-
function
|
|
70
|
-
const
|
|
71
|
-
return t.items.forEach((
|
|
72
|
-
!
|
|
73
|
-
}),
|
|
69
|
+
function M(t, e) {
|
|
70
|
+
const n = [];
|
|
71
|
+
return t.items.forEach((s, l) => {
|
|
72
|
+
!s.hasChildren && !s.disabled && (!e || e.has(l)) && n.push(l);
|
|
73
|
+
}), n;
|
|
74
74
|
}
|
|
75
75
|
function A(t, e) {
|
|
76
76
|
var l;
|
|
77
|
-
const
|
|
78
|
-
if (
|
|
79
|
-
let
|
|
80
|
-
for (const d of
|
|
81
|
-
(l = t.items.get(d)) != null && l.selected &&
|
|
82
|
-
return
|
|
77
|
+
const n = M(t, e);
|
|
78
|
+
if (n.length === 0) return "unselected";
|
|
79
|
+
let s = 0;
|
|
80
|
+
for (const d of n)
|
|
81
|
+
(l = t.items.get(d)) != null && l.selected && s++;
|
|
82
|
+
return s === 0 ? "unselected" : s === n.length ? "selected" : "indeterminate";
|
|
83
83
|
}
|
|
84
84
|
function B(t, e) {
|
|
85
|
-
const
|
|
86
|
-
for (const
|
|
87
|
-
const r = l.get(
|
|
88
|
-
r && !r.disabled && l.set(
|
|
85
|
+
const s = A(t, e) !== "selected", l = new Map(t.items), d = M(t, e);
|
|
86
|
+
for (const c of d) {
|
|
87
|
+
const r = l.get(c);
|
|
88
|
+
r && !r.disabled && l.set(c, { ...r, selected: s });
|
|
89
89
|
}
|
|
90
|
-
const
|
|
91
|
-
for (const
|
|
92
|
-
let r = t.parentMap.get(
|
|
90
|
+
const i = /* @__PURE__ */ new Set();
|
|
91
|
+
for (const c of d) {
|
|
92
|
+
let r = t.parentMap.get(c);
|
|
93
93
|
for (; r; )
|
|
94
|
-
|
|
94
|
+
i.add(r), r = t.parentMap.get(r) ?? null;
|
|
95
95
|
}
|
|
96
|
-
const h = Array.from(
|
|
97
|
-
const f = t.depthMap.get(
|
|
96
|
+
const h = Array.from(i).sort((c, r) => {
|
|
97
|
+
const f = t.depthMap.get(c) ?? 0;
|
|
98
98
|
return (t.depthMap.get(r) ?? 0) - f;
|
|
99
99
|
}), p = { ...t, items: l };
|
|
100
|
-
for (const
|
|
101
|
-
const r = l.get(
|
|
100
|
+
for (const c of h) {
|
|
101
|
+
const r = l.get(c);
|
|
102
102
|
if (r) {
|
|
103
|
-
const f = S(
|
|
104
|
-
l.set(
|
|
103
|
+
const f = S(c, p);
|
|
104
|
+
l.set(c, {
|
|
105
105
|
...r,
|
|
106
106
|
selected: f !== "unselected"
|
|
107
107
|
});
|
|
@@ -111,8 +111,8 @@ function B(t, e) {
|
|
|
111
111
|
}
|
|
112
112
|
function P(t) {
|
|
113
113
|
let e = 0;
|
|
114
|
-
return t.items.forEach((
|
|
115
|
-
!
|
|
114
|
+
return t.items.forEach((n) => {
|
|
115
|
+
!n.hasChildren && n.selected && e++;
|
|
116
116
|
}), e;
|
|
117
117
|
}
|
|
118
118
|
export {
|
|
@@ -120,7 +120,7 @@ export {
|
|
|
120
120
|
y as getAllParentIds,
|
|
121
121
|
A as getSelectAllState,
|
|
122
122
|
S as getSelectionState,
|
|
123
|
-
|
|
123
|
+
M as getVisibleLeafIds,
|
|
124
124
|
B as toggleSelectAll,
|
|
125
125
|
E as toggleSelection
|
|
126
126
|
};
|