asterui 0.12.26 → 0.12.27

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.
Files changed (163) hide show
  1. package/dist/components/Descriptions.d.ts +35 -3
  2. package/dist/components/Empty.d.ts +10 -1
  3. package/dist/components/Image.d.ts +13 -1
  4. package/dist/components/List.d.ts +74 -8
  5. package/dist/components/Table.d.ts +64 -10
  6. package/dist/components/Timeline.d.ts +62 -7
  7. package/dist/index.d.ts +4 -6
  8. package/dist/index.js +148 -150
  9. package/dist/index.js.map +1 -1
  10. package/dist/index10.js +1 -1
  11. package/dist/index100.js +5 -32
  12. package/dist/index100.js.map +1 -1
  13. package/dist/index101.js +13 -5
  14. package/dist/index101.js.map +1 -1
  15. package/dist/index102.js +43 -11
  16. package/dist/index102.js.map +1 -1
  17. package/dist/index103.js +11 -44
  18. package/dist/index103.js.map +1 -1
  19. package/dist/index104.js +12 -10
  20. package/dist/index104.js.map +1 -1
  21. package/dist/index105.js +7 -14
  22. package/dist/index105.js.map +1 -1
  23. package/dist/index106.js +12 -7
  24. package/dist/index106.js.map +1 -1
  25. package/dist/index107.js +29 -11
  26. package/dist/index107.js.map +1 -1
  27. package/dist/index108.js +16 -29
  28. package/dist/index108.js.map +1 -1
  29. package/dist/index109.js +31 -16
  30. package/dist/index109.js.map +1 -1
  31. package/dist/index110.js +517 -30
  32. package/dist/index110.js.map +1 -1
  33. package/dist/index111.js +45 -515
  34. package/dist/index111.js.map +1 -1
  35. package/dist/index22.js +1 -1
  36. package/dist/index23.js +127 -93
  37. package/dist/index23.js.map +1 -1
  38. package/dist/index39.js +162 -115
  39. package/dist/index39.js.map +1 -1
  40. package/dist/index40.js +398 -40
  41. package/dist/index40.js.map +1 -1
  42. package/dist/index41.js +132 -389
  43. package/dist/index41.js.map +1 -1
  44. package/dist/index42.js +252 -91
  45. package/dist/index42.js.map +1 -1
  46. package/dist/index43.js +143 -247
  47. package/dist/index43.js.map +1 -1
  48. package/dist/index44.js +15 -154
  49. package/dist/index44.js.map +1 -1
  50. package/dist/index45.js +17 -15
  51. package/dist/index45.js.map +1 -1
  52. package/dist/index46.js +136 -16
  53. package/dist/index46.js.map +1 -1
  54. package/dist/index47.js +118 -133
  55. package/dist/index47.js.map +1 -1
  56. package/dist/index48.js +35 -13
  57. package/dist/index48.js.map +1 -1
  58. package/dist/index49.js +34 -35
  59. package/dist/index49.js.map +1 -1
  60. package/dist/index50.js +81 -34
  61. package/dist/index50.js.map +1 -1
  62. package/dist/index51.js +166 -71
  63. package/dist/index51.js.map +1 -1
  64. package/dist/index52.js +144 -167
  65. package/dist/index52.js.map +1 -1
  66. package/dist/index53.js +11 -152
  67. package/dist/index53.js.map +1 -1
  68. package/dist/index54.js +55 -10
  69. package/dist/index54.js.map +1 -1
  70. package/dist/index55.js +12 -55
  71. package/dist/index55.js.map +1 -1
  72. package/dist/index56.js +7 -14
  73. package/dist/index56.js.map +1 -1
  74. package/dist/index57.js +333 -6
  75. package/dist/index57.js.map +1 -1
  76. package/dist/index58.js +47 -334
  77. package/dist/index58.js.map +1 -1
  78. package/dist/index59.js +122 -47
  79. package/dist/index59.js.map +1 -1
  80. package/dist/index60.js +108 -120
  81. package/dist/index60.js.map +1 -1
  82. package/dist/index61.js +167 -107
  83. package/dist/index61.js.map +1 -1
  84. package/dist/index62.js +29 -167
  85. package/dist/index62.js.map +1 -1
  86. package/dist/index63.js +120 -30
  87. package/dist/index63.js.map +1 -1
  88. package/dist/index64.js +80 -116
  89. package/dist/index64.js.map +1 -1
  90. package/dist/index65.js +19 -85
  91. package/dist/index65.js.map +1 -1
  92. package/dist/index66.js +73 -19
  93. package/dist/index66.js.map +1 -1
  94. package/dist/index67.js +54 -71
  95. package/dist/index67.js.map +1 -1
  96. package/dist/index68.js +44 -56
  97. package/dist/index68.js.map +1 -1
  98. package/dist/index69.js +49 -42
  99. package/dist/index69.js.map +1 -1
  100. package/dist/index70.js +121 -50
  101. package/dist/index70.js.map +1 -1
  102. package/dist/index71.js +102 -118
  103. package/dist/index71.js.map +1 -1
  104. package/dist/index72.js +72 -105
  105. package/dist/index72.js.map +1 -1
  106. package/dist/index73.js +67 -73
  107. package/dist/index73.js.map +1 -1
  108. package/dist/index74.js +19 -66
  109. package/dist/index74.js.map +1 -1
  110. package/dist/index75.js +55 -18
  111. package/dist/index75.js.map +1 -1
  112. package/dist/index76.js +251 -55
  113. package/dist/index76.js.map +1 -1
  114. package/dist/index77.js +22 -254
  115. package/dist/index77.js.map +1 -1
  116. package/dist/index78.js +31 -22
  117. package/dist/index78.js.map +1 -1
  118. package/dist/index79.js +93 -30
  119. package/dist/index79.js.map +1 -1
  120. package/dist/index80.js +626 -86
  121. package/dist/index80.js.map +1 -1
  122. package/dist/index81.js +73 -322
  123. package/dist/index81.js.map +1 -1
  124. package/dist/index82.js +39 -79
  125. package/dist/index82.js.map +1 -1
  126. package/dist/index83.js +23 -40
  127. package/dist/index83.js.map +1 -1
  128. package/dist/index84.js +207 -23
  129. package/dist/index84.js.map +1 -1
  130. package/dist/index85.js +148 -199
  131. package/dist/index85.js.map +1 -1
  132. package/dist/index86.js +152 -147
  133. package/dist/index86.js.map +1 -1
  134. package/dist/index87.js +143 -156
  135. package/dist/index87.js.map +1 -1
  136. package/dist/index88.js +35 -65
  137. package/dist/index88.js.map +1 -1
  138. package/dist/index89.js +234 -35
  139. package/dist/index89.js.map +1 -1
  140. package/dist/index90.js +31 -231
  141. package/dist/index90.js.map +1 -1
  142. package/dist/index91.js +210 -34
  143. package/dist/index91.js.map +1 -1
  144. package/dist/index92.js +418 -187
  145. package/dist/index92.js.map +1 -1
  146. package/dist/index93.js +686 -376
  147. package/dist/index93.js.map +1 -1
  148. package/dist/index94.js +165 -738
  149. package/dist/index94.js.map +1 -1
  150. package/dist/index95.js +253 -173
  151. package/dist/index95.js.map +1 -1
  152. package/dist/index96.js +64 -256
  153. package/dist/index96.js.map +1 -1
  154. package/dist/index97.js +121 -61
  155. package/dist/index97.js.map +1 -1
  156. package/dist/index98.js +14 -126
  157. package/dist/index98.js.map +1 -1
  158. package/dist/index99.js +31 -12
  159. package/dist/index99.js.map +1 -1
  160. package/package.json +1 -1
  161. package/dist/components/Indicator.d.ts +0 -7
  162. package/dist/index112.js +0 -53
  163. package/dist/index112.js.map +0 -1
package/dist/index92.js CHANGED
@@ -1,213 +1,444 @@
1
- import { jsxs as k, jsx as r } from "react/jsx-runtime";
2
- import { useState as C, useMemo as S, useCallback as j } from "react";
3
- function B({
4
- items: s,
5
- selectedKeys: n,
6
- onSelectChange: p,
7
- title: x,
8
- showSearch: g,
9
- filterOption: y,
10
- render: N,
11
- showSelectAll: w,
12
- disabled: u,
13
- listStyle: T
14
- }) {
15
- const [l, L] = C(""), b = S(() => l ? s.filter((e) => y(l, e)) : s, [s, l, y]), m = b.filter((e) => !e.disabled), d = m.length > 0 && m.every((e) => n.includes(e.key)), h = m.some((e) => n.includes(e.key)), i = () => {
16
- if (!u)
17
- if (d)
18
- p(n.filter((e) => !m.some((a) => a.key === e)));
19
- else {
20
- const e = m.map((o) => o.key), a = [.../* @__PURE__ */ new Set([...n, ...e])];
21
- p(a);
22
- }
23
- }, M = (e, a) => {
24
- u || a || (n.includes(e) ? p(n.filter((o) => o !== e)) : p([...n, e]));
1
+ import { jsx as k, jsxs as ue } from "react/jsx-runtime";
2
+ import he, { forwardRef as Ne, useCallback as D, useMemo as G, useState as V, createContext as Te, useRef as Ee, useEffect as Ie, useContext as Le } from "react";
3
+ const ke = Te(null);
4
+ function De() {
5
+ const e = Le(ke);
6
+ if (!e)
7
+ throw new Error("Tree components must be used within a Tree");
8
+ return e;
9
+ }
10
+ function Se(e) {
11
+ const a = [], c = (d) => {
12
+ d.forEach((f) => {
13
+ a.push(f.key), f.children && c(f.children);
14
+ });
25
15
  };
26
- return /* @__PURE__ */ k(
16
+ return c(e), a;
17
+ }
18
+ function de(e) {
19
+ const a = [], c = (d) => {
20
+ d.children && d.children.forEach((f) => {
21
+ a.push(f.key), c(f);
22
+ });
23
+ };
24
+ return c(e), a;
25
+ }
26
+ function ye(e) {
27
+ const a = /* @__PURE__ */ new Map(), c = (d, f) => {
28
+ d.forEach((u) => {
29
+ a.set(u.key, f), u.children && c(u.children, u.key);
30
+ });
31
+ };
32
+ return c(e, null), a;
33
+ }
34
+ function pe(e, a) {
35
+ for (const c of e) {
36
+ if (c.key === a) return c;
37
+ if (c.children) {
38
+ const d = pe(c.children, a);
39
+ if (d) return d;
40
+ }
41
+ }
42
+ return null;
43
+ }
44
+ function Ae(e, a) {
45
+ const c = [], d = (f) => {
46
+ f.forEach((u) => {
47
+ c.push(u), u.children && a.includes(u.key) && d(u.children);
48
+ });
49
+ };
50
+ return d(e), c;
51
+ }
52
+ function Me(e, a) {
53
+ const c = ye(e), d = [];
54
+ let f = c.get(a);
55
+ for (; f; )
56
+ d.push(f), f = c.get(f);
57
+ return d;
58
+ }
59
+ function be({ node: e, level: a }) {
60
+ const {
61
+ checkable: c,
62
+ checkboxColor: d,
63
+ checkboxSize: f,
64
+ selectable: u,
65
+ showLine: J,
66
+ showIcon: E,
67
+ blockNode: Q,
68
+ expandedKeys: I,
69
+ selectedKeys: S,
70
+ loadingKeys: X,
71
+ switcherIcon: C,
72
+ titleRender: q,
73
+ filterTreeNode: L,
74
+ onToggle: N,
75
+ onSelect: A,
76
+ onCheck: M,
77
+ onRightClick: H,
78
+ getCheckedState: Y,
79
+ focusedKey: T,
80
+ setFocusedKey: w,
81
+ flattenedNodes: K,
82
+ baseTestId: Z
83
+ } = De(), $ = Ee(null), j = e.children && e.children.length > 0, b = e.isLeaf ?? !j, g = I.includes(e.key), p = S.includes(e.key), ee = X.includes(e.key), F = T === e.key, { checked: R, indeterminate: _ } = Y(e), O = L ? L(e) : !1, m = e.disabled;
84
+ Ie(() => {
85
+ F && $.current && $.current.focus();
86
+ }, [F]);
87
+ const x = (s) => {
88
+ s.stopPropagation(), !b && !m && N(e.key, e);
89
+ }, te = (s) => {
90
+ u && e.selectable !== !1 && !m && A(e.key, e);
91
+ }, z = (s) => {
92
+ s.stopPropagation(), !m && !e.disableCheckbox && M(e.key, e);
93
+ }, ne = (s) => {
94
+ H && (s.preventDefault(), H({ event: s, node: e }));
95
+ }, se = (s) => {
96
+ const v = K.findIndex((i) => i.key === e.key);
97
+ switch (s.key) {
98
+ case "ArrowDown": {
99
+ s.preventDefault();
100
+ const i = K[v + 1];
101
+ i && w(i.key);
102
+ break;
103
+ }
104
+ case "ArrowUp": {
105
+ s.preventDefault();
106
+ const i = K[v - 1];
107
+ i && w(i.key);
108
+ break;
109
+ }
110
+ case "ArrowRight": {
111
+ if (s.preventDefault(), !b && !g)
112
+ N(e.key, e);
113
+ else if (j && g) {
114
+ const i = e.children[0];
115
+ w(i.key);
116
+ }
117
+ break;
118
+ }
119
+ case "ArrowLeft": {
120
+ s.preventDefault(), !b && g && N(e.key, e);
121
+ break;
122
+ }
123
+ case "Enter":
124
+ case " ": {
125
+ s.preventDefault(), c && e.checkable !== !1 ? M(e.key, e) : u && e.selectable !== !1 ? A(e.key, e) : b || N(e.key, e);
126
+ break;
127
+ }
128
+ case "Home": {
129
+ s.preventDefault();
130
+ const i = K[0];
131
+ i && w(i.key);
132
+ break;
133
+ }
134
+ case "End": {
135
+ s.preventDefault();
136
+ const i = K[K.length - 1];
137
+ i && w(i.key);
138
+ break;
139
+ }
140
+ }
141
+ }, re = {
142
+ xs: "checkbox-xs",
143
+ sm: "checkbox-sm",
144
+ md: "",
145
+ lg: "checkbox-lg",
146
+ xl: "checkbox-xl"
147
+ }, ce = {
148
+ primary: "checkbox-primary",
149
+ secondary: "checkbox-secondary",
150
+ accent: "checkbox-accent",
151
+ neutral: "checkbox-neutral",
152
+ info: "checkbox-info",
153
+ success: "checkbox-success",
154
+ warning: "checkbox-warning",
155
+ error: "checkbox-error"
156
+ }, ie = re[f], ae = ce[d], le = () => ee ? /* @__PURE__ */ k("span", { className: "loading loading-spinner loading-xs" }) : b ? /* @__PURE__ */ k("span", { className: "w-4 h-4" }) : C ? typeof C == "function" ? C(g) : C : /* @__PURE__ */ k(
157
+ "svg",
158
+ {
159
+ className: `w-4 h-4 transition-transform duration-200 ${g ? "rotate-90" : ""}`,
160
+ fill: "none",
161
+ viewBox: "0 0 24 24",
162
+ stroke: "currentColor",
163
+ "aria-hidden": "true",
164
+ children: /* @__PURE__ */ k("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M9 5l7 7-7 7" })
165
+ }
166
+ ), B = () => q ? q(e) : e.title, P = p ? "selected" : g ? "expanded" : "collapsed";
167
+ return /* @__PURE__ */ ue(
27
168
  "div",
28
169
  {
29
- className: "flex flex-col border border-base-300 rounded-lg bg-base-100 overflow-hidden",
30
- style: { width: 200, height: 300, ...T },
170
+ className: "tree-node",
171
+ role: "treeitem",
172
+ "aria-expanded": b ? void 0 : g,
173
+ "aria-selected": p,
174
+ "aria-checked": c ? _ ? "mixed" : R : void 0,
175
+ "aria-disabled": m,
176
+ "aria-level": a + 1,
177
+ "data-testid": `${Z}-node-${e.key}`,
178
+ "data-state": P,
179
+ "data-key": e.key,
31
180
  children: [
32
- /* @__PURE__ */ k("div", { className: "flex items-center gap-2 px-3 py-2 border-b border-base-300 bg-base-200", children: [
33
- w && /* @__PURE__ */ r(
34
- "input",
35
- {
36
- type: "checkbox",
37
- className: "checkbox checkbox-sm checkbox-primary",
38
- checked: d,
39
- ref: (e) => {
40
- e && (e.indeterminate = h && !d);
41
- },
42
- onChange: i,
43
- disabled: u || m.length === 0
44
- }
45
- ),
46
- /* @__PURE__ */ r("span", { className: "flex-1 font-medium text-sm truncate", children: x }),
47
- /* @__PURE__ */ k("span", { className: "text-xs text-base-content/50", children: [
48
- n.filter((e) => b.some((a) => a.key === e)).length,
49
- "/",
50
- b.length
51
- ] })
52
- ] }),
53
- g && /* @__PURE__ */ r("div", { className: "px-2 py-2 border-b border-base-300", children: /* @__PURE__ */ r(
54
- "input",
55
- {
56
- type: "text",
57
- className: "input input-sm w-full",
58
- placeholder: "Search...",
59
- value: l,
60
- onChange: (e) => L(e.target.value),
61
- disabled: u
62
- }
63
- ) }),
64
- /* @__PURE__ */ r("div", { className: "flex-1 overflow-auto", children: b.length > 0 ? b.map((e) => /* @__PURE__ */ k(
181
+ /* @__PURE__ */ ue(
65
182
  "div",
66
183
  {
184
+ ref: $,
67
185
  className: [
68
- "flex items-center gap-2 px-3 py-2 cursor-pointer hover:bg-base-200 transition-colors",
69
- n.includes(e.key) && "bg-primary/10",
70
- (u || e.disabled) && "opacity-50 cursor-not-allowed"
186
+ "flex items-center py-1 px-1 rounded transition-colors outline-none",
187
+ "focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-1",
188
+ u && !m && "cursor-pointer hover:bg-base-200",
189
+ p && "bg-primary/10 text-primary",
190
+ m && "opacity-50 cursor-not-allowed",
191
+ O && "bg-warning/20",
192
+ Q && "w-full"
71
193
  ].filter(Boolean).join(" "),
72
- onClick: () => M(e.key, !!e.disabled),
194
+ style: { paddingLeft: `${a * 20}px` },
195
+ tabIndex: F ? 0 : -1,
196
+ onClick: te,
197
+ onContextMenu: ne,
198
+ onKeyDown: se,
199
+ onFocus: () => w(e.key),
73
200
  children: [
74
- /* @__PURE__ */ r(
201
+ /* @__PURE__ */ k(
202
+ "span",
203
+ {
204
+ className: [
205
+ "w-5 h-5 flex items-center justify-center flex-shrink-0",
206
+ !b && !m && "cursor-pointer hover:bg-base-300 rounded"
207
+ ].filter(Boolean).join(" "),
208
+ onClick: x,
209
+ "aria-hidden": "true",
210
+ children: le()
211
+ }
212
+ ),
213
+ c && e.checkable !== !1 && /* @__PURE__ */ k("span", { className: "mr-1 flex-shrink-0", onClick: z, children: /* @__PURE__ */ k(
75
214
  "input",
76
215
  {
77
216
  type: "checkbox",
78
- className: "checkbox checkbox-sm checkbox-primary",
79
- checked: n.includes(e.key),
80
- disabled: u || e.disabled,
81
- onChange: () => {
82
- }
217
+ className: `checkbox ${ie} ${ae}`,
218
+ checked: R,
219
+ ref: (s) => {
220
+ s && (s.indeterminate = _);
221
+ },
222
+ disabled: m || e.disableCheckbox,
223
+ onChange: z,
224
+ tabIndex: -1,
225
+ "aria-hidden": "true",
226
+ "data-state": _ ? "indeterminate" : R ? "checked" : "unchecked"
83
227
  }
84
- ),
85
- /* @__PURE__ */ r("span", { className: "flex-1 truncate text-sm", children: N(e) })
228
+ ) }),
229
+ E && e.icon && /* @__PURE__ */ k("span", { className: "mr-1 flex-shrink-0", "aria-hidden": "true", children: e.icon }),
230
+ /* @__PURE__ */ k("span", { className: "flex-1 truncate select-none", children: B() })
86
231
  ]
87
- },
88
- e.key
89
- )) : /* @__PURE__ */ r("div", { className: "flex items-center justify-center h-full text-base-content/50 text-sm", children: "No data" }) })
232
+ }
233
+ ),
234
+ j && g && /* @__PURE__ */ k(
235
+ "div",
236
+ {
237
+ className: J ? "border-l border-base-300 ml-2.5" : "",
238
+ role: "group",
239
+ "aria-label": `${e.title} children`,
240
+ children: e.children.map((s) => /* @__PURE__ */ k(be, { node: s, level: a + 1 }, s.key))
241
+ }
242
+ )
90
243
  ]
91
244
  }
92
245
  );
93
246
  }
94
- function G({
95
- dataSource: s,
96
- targetKeys: n,
97
- defaultTargetKeys: p = [],
98
- onChange: x,
99
- onSelectChange: g,
100
- titles: y = ["Source", "Target"],
101
- render: N = (d) => d.title,
102
- showSearch: w = !1,
103
- filterOption: u = (d, h) => (typeof h.title == "string" ? h.title : String(h.title)).toLowerCase().includes(d.toLowerCase()),
104
- showSelectAll: T = !0,
105
- disabled: l = !1,
106
- listStyle: L,
107
- className: b = "",
108
- ...m
109
- }) {
110
- const [d, h] = C(p), [i, M] = C([]), [e, a] = C([]), o = n ?? d, K = S(
111
- () => s.filter((t) => !o.includes(t.key)),
112
- [s, o]
113
- ), V = S(
114
- () => s.filter((t) => o.includes(t.key)),
115
- [s, o]
116
- ), W = j(
117
- (t) => {
118
- M(t), g?.(t, e);
119
- },
120
- [e, g]
121
- ), $ = j(
122
- (t) => {
123
- a(t), g?.(i, t);
124
- },
125
- [i, g]
126
- ), q = j(() => {
127
- if (l || i.length === 0) return;
128
- const t = i.filter((f) => {
129
- const v = s.find((I) => I.key === f);
130
- return v && !v.disabled;
131
- });
132
- if (t.length === 0) return;
133
- const c = [...o, ...t];
134
- n === void 0 && h(c), M([]), x?.(c, "right", t);
135
- }, [l, i, o, n, x, s]), z = j(() => {
136
- if (l || e.length === 0) return;
137
- const t = e.filter((f) => {
138
- const v = s.find((I) => I.key === f);
139
- return v && !v.disabled;
140
- });
141
- if (t.length === 0) return;
142
- const c = o.filter((f) => !t.includes(f));
143
- n === void 0 && h(c), a([]), x?.(c, "left", t);
144
- }, [l, e, o, n, x, s]), A = i.some((t) => {
145
- const c = s.find((f) => f.key === t);
146
- return c && !c.disabled;
147
- }), D = e.some((t) => {
148
- const c = s.find((f) => f.key === t);
149
- return c && !c.disabled;
150
- });
151
- return /* @__PURE__ */ k("div", { className: `flex items-center gap-4 ${b}`, ...m, children: [
152
- /* @__PURE__ */ r(
153
- B,
154
- {
155
- items: K,
156
- selectedKeys: i,
157
- onSelectChange: W,
158
- title: y[0],
159
- showSearch: w,
160
- filterOption: u,
161
- render: N,
162
- showSelectAll: T,
163
- disabled: l,
164
- listStyle: L,
165
- direction: "left"
247
+ function fe(e) {
248
+ return null;
249
+ }
250
+ fe.displayName = "Tree.Node";
251
+ function $e(e) {
252
+ return e.type === fe || typeof e.type == "function" && e.type.displayName === "Tree.Node";
253
+ }
254
+ const _e = Object.assign(
255
+ Ne(function({
256
+ treeData: a,
257
+ children: c,
258
+ checkable: d = !1,
259
+ checkboxColor: f = "primary",
260
+ checkboxSize: u = "sm",
261
+ selectable: J = !0,
262
+ multiple: E = !1,
263
+ defaultExpandAll: Q = !1,
264
+ defaultExpandedKeys: I = [],
265
+ expandedKeys: S,
266
+ defaultSelectedKeys: X = [],
267
+ selectedKeys: C,
268
+ defaultCheckedKeys: q = [],
269
+ checkedKeys: L,
270
+ onExpand: N,
271
+ onSelect: A,
272
+ onCheck: M,
273
+ showLine: H = !1,
274
+ showIcon: Y = !1,
275
+ checkStrictly: T = !1,
276
+ autoExpandParent: w = !0,
277
+ blockNode: K = !1,
278
+ switcherIcon: Z,
279
+ titleRender: $,
280
+ filterTreeNode: j,
281
+ loadData: b,
282
+ onRightClick: g,
283
+ fieldNames: p,
284
+ className: ee = "",
285
+ "data-testid": F,
286
+ ...R
287
+ }, _) {
288
+ const O = F ?? "tree", m = D((t, o, n) => {
289
+ }, []), x = G(() => {
290
+ if (a) {
291
+ if (p) {
292
+ const o = (n) => {
293
+ const r = p.key ? n[p.key] : n.key, l = p.title ? n[p.title] : n.title, h = p.children ? n[p.children] : n.children;
294
+ return {
295
+ ...n,
296
+ key: r,
297
+ title: l,
298
+ children: Array.isArray(h) ? h.map((y) => o(y)) : void 0
299
+ };
300
+ };
301
+ return a.map(o);
302
+ }
303
+ return a;
166
304
  }
167
- ),
168
- /* @__PURE__ */ k("div", { className: "flex flex-col gap-2", children: [
169
- /* @__PURE__ */ r(
170
- "button",
171
- {
172
- type: "button",
173
- className: "btn btn-sm btn-outline",
174
- onClick: q,
175
- disabled: l || !A,
176
- "aria-label": "Move to target",
177
- children: /* @__PURE__ */ r("svg", { className: "w-4 h-4", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ r("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M9 5l7 7-7 7" }) })
305
+ const t = (o) => {
306
+ const n = [];
307
+ return he.Children.forEach(o, (r) => {
308
+ if (he.isValidElement(r) && $e(r)) {
309
+ const l = r.props, h = r.key;
310
+ if (!h) {
311
+ console.warn("Tree.Node requires a key prop");
312
+ return;
313
+ }
314
+ const y = {
315
+ key: h,
316
+ title: l.title,
317
+ icon: l.icon,
318
+ disabled: l.disabled,
319
+ disableCheckbox: l.disableCheckbox,
320
+ selectable: l.selectable,
321
+ checkable: l.checkable,
322
+ isLeaf: l.isLeaf,
323
+ children: l.children ? t(l.children) : void 0
324
+ };
325
+ n.push(y);
326
+ }
327
+ }), n;
328
+ };
329
+ return t(c);
330
+ }, [a, c, p]), [te, z] = V([]), ne = G(() => {
331
+ if (Q)
332
+ return Se(x);
333
+ if (w && I.length > 0) {
334
+ const t = new Set(I);
335
+ return I.forEach((o) => {
336
+ Me(x, o).forEach((n) => t.add(n));
337
+ }), Array.from(t);
338
+ }
339
+ return I;
340
+ }, []), [se, re] = V(ne), [ce, ie] = V(X), [ae, le] = V(q), [B, P] = V(null), s = S ?? se, v = C ?? ce, i = L ?? ae, oe = G(() => ye(x), [x]), U = G(() => Ae(x, s), [x, s]), xe = D(
341
+ (t) => {
342
+ if (T)
343
+ return { checked: i.includes(t.key), indeterminate: !1 };
344
+ if (!t.children || t.children.length === 0)
345
+ return { checked: i.includes(t.key), indeterminate: !1 };
346
+ const o = de(t), n = o.filter((r) => i.includes(r));
347
+ return n.length === 0 ? { checked: i.includes(t.key), indeterminate: !1 } : n.length === o.length ? { checked: !0, indeterminate: !1 } : { checked: !1, indeterminate: !0 };
348
+ },
349
+ [i, T]
350
+ ), ge = D(
351
+ async (t, o) => {
352
+ const n = s.includes(t);
353
+ if (b && !n && !o.isLeaf && (!o.children || o.children.length === 0)) {
354
+ z((l) => [...l, t]);
355
+ try {
356
+ await b(o);
357
+ } finally {
358
+ z((l) => l.filter((h) => h !== t));
359
+ }
178
360
  }
179
- ),
180
- /* @__PURE__ */ r(
181
- "button",
182
- {
183
- type: "button",
184
- className: "btn btn-sm btn-outline",
185
- onClick: z,
186
- disabled: l || !D,
187
- "aria-label": "Move to source",
188
- children: /* @__PURE__ */ r("svg", { className: "w-4 h-4", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ r("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M15 19l-7-7 7-7" }) })
361
+ const r = n ? s.filter((l) => l !== t) : [...s, t];
362
+ S === void 0 && re(r), N?.(r, { node: o, expanded: !n });
363
+ },
364
+ [s, S, N, b]
365
+ ), me = D(
366
+ (t, o) => {
367
+ let n;
368
+ E ? v.includes(t) ? n = v.filter((r) => r !== t) : n = [...v, t] : n = v.includes(t) ? [] : [t], C === void 0 && ie(n), A?.(n, { node: o, selected: n.includes(t) });
369
+ },
370
+ [v, E, C, A]
371
+ ), ve = D(
372
+ (t, o) => {
373
+ const n = i.includes(t);
374
+ let r = [...i];
375
+ if (T)
376
+ n ? r = r.filter((l) => l !== t) : r.push(t);
377
+ else {
378
+ const l = de(o);
379
+ n ? r = r.filter((y) => y !== t && !l.includes(y)) : (r.push(t), l.forEach((y) => {
380
+ r.includes(y) || r.push(y);
381
+ }));
382
+ let h = oe.get(t) ?? null;
383
+ for (; h; ) {
384
+ const y = pe(x, h);
385
+ y && y.children && (y.children.every(
386
+ (W) => r.includes(W.key) || de(W).every((Ke) => r.includes(Ke))
387
+ ) ? r.includes(h) || r.push(h) : r = r.filter((W) => W !== h)), h = oe.get(h) ?? null;
388
+ }
189
389
  }
190
- )
191
- ] }),
192
- /* @__PURE__ */ r(
193
- B,
390
+ L === void 0 && le(r), M?.(r, { node: o, checked: !n });
391
+ },
392
+ [i, L, M, oe, x, T]
393
+ ), Ce = D(() => {
394
+ !B && U.length > 0 && P(U[0].key);
395
+ }, [B, U]), we = {
396
+ checkable: d,
397
+ checkboxColor: f,
398
+ checkboxSize: u,
399
+ selectable: J,
400
+ multiple: E,
401
+ showLine: H,
402
+ showIcon: Y,
403
+ blockNode: K,
404
+ checkStrictly: T,
405
+ expandedKeys: s,
406
+ selectedKeys: v,
407
+ checkedKeys: i,
408
+ loadingKeys: te,
409
+ switcherIcon: Z,
410
+ titleRender: $,
411
+ filterTreeNode: j,
412
+ onToggle: ge,
413
+ onSelect: me,
414
+ onCheck: ve,
415
+ onRightClick: g,
416
+ getCheckedState: xe,
417
+ focusedKey: B,
418
+ setFocusedKey: P,
419
+ flattenedNodes: U,
420
+ registerNode: m,
421
+ baseTestId: O
422
+ };
423
+ return /* @__PURE__ */ k(ke.Provider, { value: we, children: /* @__PURE__ */ k(
424
+ "div",
194
425
  {
195
- items: V,
196
- selectedKeys: e,
197
- onSelectChange: $,
198
- title: y[1],
199
- showSearch: w,
200
- filterOption: u,
201
- render: N,
202
- showSelectAll: T,
203
- disabled: l,
204
- listStyle: L,
205
- direction: "right"
426
+ ref: _,
427
+ className: `tree ${ee}`,
428
+ role: "tree",
429
+ "aria-multiselectable": E,
430
+ "data-testid": O,
431
+ onFocus: Ce,
432
+ ...R,
433
+ children: x.map((t) => /* @__PURE__ */ k(be, { node: t, level: 0 }, t.key))
206
434
  }
207
- )
208
- ] });
209
- }
435
+ ) });
436
+ }),
437
+ {
438
+ Node: fe
439
+ }
440
+ );
210
441
  export {
211
- G as Transfer
442
+ _e as Tree
212
443
  };
213
444
  //# sourceMappingURL=index92.js.map