@baishuyun/ui-base 2.0.0 → 2.2.0

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 (75) hide show
  1. package/dist/Card/{Card-DMXtN2pu.js → Card-CXULQNHa.js} +1 -1
  2. package/dist/Card/index.js +1 -1
  3. package/dist/CheckBox/CheckBox-Bu40TO29.js +84 -0
  4. package/dist/CheckBox/index.js +37 -0
  5. package/dist/ColorPicker/ColorPicker-CwFsihkL.js +207 -0
  6. package/dist/ColorPicker/index.js +1 -1
  7. package/dist/Icon/{Icon-C0bjP9U6.js → Icon-BlkVlKDd.js} +1 -1
  8. package/dist/Icon/index.js +1 -1
  9. package/dist/InputTag/index.js +2 -2
  10. package/dist/Modal/{Modal-C1LEJ6Y0.js → Modal-BZTEGGa0.js} +1 -1
  11. package/dist/Modal/index.js +1 -1
  12. package/dist/NotFoundContent/NotFoundContent-h0-oIXlk.js +6 -0
  13. package/dist/NotFoundContent/index.js +4 -0
  14. package/dist/Radio/index.js +105 -0
  15. package/dist/Segmented/Segmented-UgzW78Ey.js +75 -0
  16. package/dist/Segmented/index.js +4 -0
  17. package/dist/Select/Select-C3abXG27.js +855 -0
  18. package/dist/Select/index.js +6 -0
  19. package/dist/Tree/index.js +4 -0
  20. package/dist/Tree/utils/index.js +40 -0
  21. package/dist/components/CheckBox/CheckBox.d.ts +46 -0
  22. package/dist/components/CheckBox/CheckboxIcon.d.ts +6 -0
  23. package/dist/components/CheckBox/Group.d.ts +30 -0
  24. package/dist/components/CheckBox/constants.d.ts +11 -0
  25. package/dist/components/CheckBox/context/context.d.ts +8 -0
  26. package/dist/components/CheckBox/index.d.ts +9 -0
  27. package/dist/components/NotFoundContent/NotFoundContent.d.ts +9 -0
  28. package/dist/components/NotFoundContent/index.d.ts +1 -0
  29. package/dist/components/Radio/Group.d.ts +3 -0
  30. package/dist/components/Radio/Radio.d.ts +3 -0
  31. package/dist/components/Radio/constants.d.ts +6 -0
  32. package/dist/components/Radio/context/context.d.ts +9 -0
  33. package/dist/components/Radio/index.d.ts +7 -0
  34. package/dist/components/Radio/interface.d.ts +98 -0
  35. package/dist/components/Segmented/Segmented.d.ts +6 -0
  36. package/dist/components/Segmented/Segmented.type.d.ts +31 -0
  37. package/dist/components/Segmented/index.d.ts +2 -0
  38. package/dist/components/Select/HighlightText/HighlightText.d.ts +7 -0
  39. package/dist/components/Select/OptionList/MultOptionList/MultOptionList.d.ts +11 -0
  40. package/dist/components/Select/OptionList/OptionList.d.ts +6 -0
  41. package/dist/components/Select/OptionList/SingleOptionList/SingleOptionList.d.ts +11 -0
  42. package/dist/components/Select/OptionList/TreeOptionList/TreeOptionList.d.ts +21 -0
  43. package/dist/components/Select/OptionList/filter.d.ts +4 -0
  44. package/dist/components/Select/Select.d.ts +3 -0
  45. package/dist/components/Select/SelectInput/SelectInput.d.ts +10 -0
  46. package/dist/components/Select/SelectInput/SelectMultipleInput/OptionTag/OptionTag.d.ts +12 -0
  47. package/dist/components/Select/SelectInput/SelectMultipleInput/SelectMultipleInput.d.ts +8 -0
  48. package/dist/components/Select/SelectInput/SelectSingleInput/SelectSingleInput.d.ts +8 -0
  49. package/dist/components/Select/SelectInputSearch/SelectInputSearch.d.ts +6 -0
  50. package/dist/components/Select/SelectPanel/SelectPanel.d.ts +3 -0
  51. package/dist/components/Select/constants.d.ts +59 -0
  52. package/dist/components/Select/context/SelectContext.d.ts +52 -0
  53. package/dist/components/Select/index.d.ts +3 -0
  54. package/dist/components/Select/interface.d.ts +192 -0
  55. package/dist/components/Select/utils/fieldAccessor.d.ts +30 -0
  56. package/dist/components/Select/utils/tree.d.ts +2 -0
  57. package/dist/components/Tree/Tree.d.ts +6 -0
  58. package/dist/components/Tree/TreeNode/TreeNode.d.ts +21 -0
  59. package/dist/components/Tree/context/TreeContext.d.ts +15 -0
  60. package/dist/components/Tree/index.d.ts +3 -0
  61. package/dist/components/Tree/types/node.d.ts +12 -0
  62. package/dist/components/Tree/types/tree.d.ts +84 -0
  63. package/dist/components/Tree/utils/index.d.ts +11 -0
  64. package/dist/components/index.d.ts +5 -0
  65. package/dist/index.js +45 -35
  66. package/dist/style.css +1 -1
  67. package/dist/vendors/Tree-CCY2gtpG.js +225 -0
  68. package/dist/vendors/fuse.js-D1DCbUBb.js +1022 -0
  69. package/dist/vendors/index-ByQkttKA.js +59 -0
  70. package/dist/vendors/lodash-es-CZfJRWhO.js +305 -0
  71. package/dist/vendors/{simplebar-react-svBEsTVC.js → simplebar-react-Bf9Zq-21.js} +1 -1
  72. package/package.json +9 -7
  73. package/dist/ColorPicker/ColorPicker-CpPLwHR2.js +0 -253
  74. package/dist/vendors/fuse.js-l0sNRNKZ.js +0 -1
  75. package/dist/vendors/lodash-es-DP1ViCXF.js +0 -262
@@ -0,0 +1,855 @@
1
+ import { jsx as t, jsxs as O, Fragment as te } from "react/jsx-runtime";
2
+ import { createContext as ne, useContext as le, memo as se, forwardRef as me, useState as ie, useRef as Q, useLayoutEffect as Ge, useDeferredValue as fe, useMemo as F, useCallback as z, Suspense as ze, useId as De, useImperativeHandle as We } from "react";
3
+ import { c as E } from "../vendors/clsx-OuTLNxxd.js";
4
+ import { I as H } from "../Icon/Icon-BlkVlKDd.js";
5
+ import { useHover as Ue, useControllableValue as He, useToggle as $e } from "ahooks";
6
+ import { AnimatePresence as _e, motion as Y } from "motion/react";
7
+ import { n as ue, h as je, e as qe, c as Ke, b as de } from "../vendors/lodash-es-CZfJRWhO.js";
8
+ import { I as pe, u as j, P as Je } from "../vendors/index-ByQkttKA.js";
9
+ import { H as ge, T as Qe } from "../vendors/Tree-CCY2gtpG.js";
10
+ import { Input as Xe } from "antd";
11
+ import X from "../CheckBox/index.js";
12
+ import { N as Z } from "../NotFoundContent/NotFoundContent-h0-oIXlk.js";
13
+ import { F as Ye } from "../vendors/fuse.js-D1DCbUBb.js";
14
+ import { S as Ze } from "../vendors/simplebar-react-Bf9Zq-21.js";
15
+ import { useFloating as et, flip as tt, shift as nt, offset as lt, size as st, autoUpdate as it, useClick as rt, useDismiss as ct, useInteractions as ot, FloatingPortal as at } from "@floating-ui/react";
16
+ var U = /* @__PURE__ */ ((e) => (e.SINGLE = "single", e.MULTIPLE = "multiple", e))(U || {}), R = /* @__PURE__ */ ((e) => (e[e.SINGLE = 0] = "SINGLE", e[e.MULTIPLE = 1] = "MULTIPLE", e[e.TREE = 2] = "TREE", e[e.TREE_TAGS = 3] = "TREE_TAGS", e[e.MEMBER = 4] = "MEMBER", e[e.DEPARTEMENT = 5] = "DEPARTEMENT", e))(R || {});
17
+ const ut = {
18
+ 0: "single",
19
+ 2: "single",
20
+ 1: "multiple",
21
+ 3: "multiple",
22
+ 4: "multiple",
23
+ 5: "multiple"
24
+ /* MULTIPLE */
25
+ }, he = {
26
+ label: "label",
27
+ value: "value",
28
+ children: "children"
29
+ }, ye = ne({
30
+ value: void 0,
31
+ setValue: ue,
32
+ isOpen: !1,
33
+ setIsOpen: ue
34
+ }), be = ne({
35
+ fieldNames: {
36
+ label: "label",
37
+ value: "value",
38
+ children: "children"
39
+ },
40
+ disabled: !1
41
+ }), ve = ne({}), re = () => {
42
+ const e = le(ye);
43
+ if (!e)
44
+ throw new Error("Select.* components must be used within a SelectStateContext provider");
45
+ return e;
46
+ }, q = () => {
47
+ const e = le(be);
48
+ if (!e)
49
+ throw new Error("Select.* components must be used within a SelectConfigContext provider");
50
+ return e;
51
+ }, Se = () => le(ve);
52
+ function K(e) {
53
+ const n = e;
54
+ return {
55
+ /**
56
+ * 获取选项的标签文本
57
+ */
58
+ getLabel: (l) => l[n.label],
59
+ /**
60
+ * 获取选项的值
61
+ */
62
+ getValue: (l) => l[n.value],
63
+ /**
64
+ * 获取选项的子项
65
+ */
66
+ getChildren: (l) => {
67
+ if (n.children)
68
+ return l[n.children];
69
+ },
70
+ /**
71
+ * 创建标准化的选项对象(用于向后兼容)
72
+ */
73
+ normalizeOption: (l) => ({
74
+ ...l,
75
+ label: l[n.label],
76
+ value: l[n.value],
77
+ children: n.children ? l[n.children] : void 0
78
+ }),
79
+ /**
80
+ * 获取字段名映射
81
+ */
82
+ getFieldNames: () => n
83
+ };
84
+ }
85
+ const Ne = se((e) => {
86
+ const { value: n, inputValueStyle: l } = e, { fieldNames: i, otherInputPosition: r } = q(), { isSelectedOtherOption: c, otherOptionValue: o } = Se(), b = K(i), d = je(n);
87
+ let s;
88
+ return c && o && r === "inline" ? s = o : e.labelRender && d ? s = e.labelRender(d) : d ? s = b.getLabel(d) : s = "", /* @__PURE__ */ t(
89
+ "div",
90
+ {
91
+ className: E("bsy-select-input-container__input-value overflow-hidden"),
92
+ style: l,
93
+ children: /* @__PURE__ */ t("div", { className: "bsy-select-input-container__input-value-text", children: s })
94
+ }
95
+ );
96
+ });
97
+ Ne.displayName = "BsySelectSingleInput";
98
+ const ee = {
99
+ "bsy-input-tag__container": "_bsy-input-tag__container_18guu_1",
100
+ "bsy-input-tag__item": "_bsy-input-tag__item_18guu_7",
101
+ "bsy-input-tag__item--disabled": "_bsy-input-tag__item--disabled_18guu_20"
102
+ }, A = me(
103
+ ({ children: e, style: n, disabled: l }, i) => /* @__PURE__ */ t(
104
+ "div",
105
+ {
106
+ "data-bsy-input-tag": "true",
107
+ className: E({
108
+ [ee["bsy-input-tag__item"]]: !0,
109
+ [ee["bsy-input-tag__item--disabled"]]: l
110
+ }),
111
+ ref: i,
112
+ style: n,
113
+ children: e
114
+ }
115
+ )
116
+ );
117
+ A.Container = (e) => /* @__PURE__ */ t("div", { className: E(ee["bsy-input-tag__container"]), children: e.children });
118
+ A.displayName = "BsyOptionTag";
119
+ const dt = "_select_multiple_input__container_8pd2n_1", pt = "_select_multiple_input__measurement_layer_8pd2n_6", ht = "_select_multiple_input__close_btn_8pd2n_14", mt = "_select_multiple_input__tag_content_8pd2n_24", G = {
120
+ select_multiple_input__container: dt,
121
+ select_multiple_input__measurement_layer: pt,
122
+ select_multiple_input__close_btn: ht,
123
+ select_multiple_input__tag_content: mt
124
+ }, ft = 4, xe = se((e) => {
125
+ const { value: n, labelRender: l, tagStyle: i } = e, { setValue: r } = re(), { fieldNames: c, disabled: o } = q(), b = K(c), d = (n == null ? void 0 : n.length) ?? 0, [s, p] = ie(0), f = Q(null), S = Q(null);
126
+ Ge(() => {
127
+ if (!f.current) return;
128
+ const m = new ResizeObserver((g) => {
129
+ var V;
130
+ const u = g[0];
131
+ if (!u) return;
132
+ const h = u.contentRect.width, I = u.target.querySelectorAll('.measure-list [data-bsy-input-tag="true"]');
133
+ if (I.length === 0) {
134
+ p((n == null ? void 0 : n.length) ?? 0);
135
+ return;
136
+ }
137
+ const w = ((V = S.current) == null ? void 0 : V.offsetWidth) || 65;
138
+ let P = 0, C = 0;
139
+ for (let M = 0; M < I.length; M++) {
140
+ const T = I[M].clientWidth + ft, D = M < d - 1 ? w : 0;
141
+ if (P + T + D <= h)
142
+ P += T, C = M + 1;
143
+ else
144
+ break;
145
+ }
146
+ C === 0 && d === 1 && (C = 1), s !== C && p(C);
147
+ });
148
+ return m.observe(f.current), () => m.disconnect();
149
+ }, [d, s, n.length]);
150
+ const N = d - s, y = fe(N), a = /* @__PURE__ */ t("div", { className: `${G.select_multiple_input__measurement_layer} measure-list`, children: /* @__PURE__ */ O(A.Container, { children: [
151
+ n == null ? void 0 : n.map((m, g) => {
152
+ const u = (h) => /* @__PURE__ */ t("div", { style: h, className: "bsy-input-tag__item-icon cursor-pointer", children: /* @__PURE__ */ t(
153
+ H,
154
+ {
155
+ name: "close",
156
+ style: { fontSize: 12 },
157
+ className: G.select_multiple_input__close_btn
158
+ }
159
+ ) });
160
+ return /* @__PURE__ */ O(A, { style: i, children: [
161
+ l && l(m, u),
162
+ !l && /* @__PURE__ */ O("div", { className: G.select_multiple_input__tag_content, children: [
163
+ /* @__PURE__ */ t("span", { children: b.getLabel(m) }),
164
+ /* @__PURE__ */ t(u, {})
165
+ ] })
166
+ ] }, g);
167
+ }),
168
+ s < d && y > 0 && /* @__PURE__ */ O(A, { ref: S, children: [
169
+ `+ ${N}`,
170
+ /* @__PURE__ */ t("span", { className: "text-[#666]", children: "..." })
171
+ ] })
172
+ ] }) }), _ = (m) => {
173
+ if (o) return;
174
+ const g = n.filter(
175
+ (h) => b.getValue(h) !== b.getValue(m)
176
+ ), u = g.map((h) => b.getValue(h));
177
+ r(u, g);
178
+ };
179
+ return /* @__PURE__ */ O(
180
+ "div",
181
+ {
182
+ ref: f,
183
+ className: E(
184
+ "bsy-select-input-container__input-value",
185
+ G.select_multiple_input__container,
186
+ "multiple"
187
+ ),
188
+ children: [
189
+ a,
190
+ /* @__PURE__ */ O(A.Container, { children: [
191
+ n == null ? void 0 : n.slice(0, s).map((m, g) => {
192
+ const u = (h) => /* @__PURE__ */ t(
193
+ "div",
194
+ {
195
+ style: h,
196
+ className: E("bsy-input-tag__item-icon", {
197
+ [G.select_multiple_input__close_btn]: !o,
198
+ [G.select_multiple_input__close_btn + "--disabled"]: o
199
+ }),
200
+ onClick: (x) => {
201
+ x.stopPropagation(), _(m);
202
+ },
203
+ children: /* @__PURE__ */ t(H, { name: "close", style: { fontSize: 12 } })
204
+ }
205
+ );
206
+ return /* @__PURE__ */ O(
207
+ A,
208
+ {
209
+ style: {
210
+ ...i,
211
+ flexShrink: s === 1 ? 1 : 0
212
+ },
213
+ disabled: o,
214
+ children: [
215
+ l && l(m, u),
216
+ !l && /* @__PURE__ */ O("div", { className: G.select_multiple_input__tag_content, children: [
217
+ /* @__PURE__ */ t("span", { className: "truncate", children: b.getLabel(m) }),
218
+ /* @__PURE__ */ t(u, {})
219
+ ] })
220
+ ]
221
+ },
222
+ g
223
+ );
224
+ }),
225
+ s < d && y > 0 && /* @__PURE__ */ O(A, { ref: S, children: [
226
+ `+ ${N} `,
227
+ /* @__PURE__ */ t("span", { className: "text-[#666]", children: "..." })
228
+ ] })
229
+ ] })
230
+ ]
231
+ }
232
+ );
233
+ });
234
+ xe.displayName = "BsySelectMultipleInput";
235
+ const _t = (e, n) => {
236
+ const l = [], i = (r) => {
237
+ r.forEach((c) => {
238
+ const { [n.children]: o, ...b } = c;
239
+ l.push(b), o && i(o);
240
+ });
241
+ };
242
+ return i(e), l;
243
+ }, Oe = ({
244
+ placeholder: e,
245
+ mode: n,
246
+ clearable: l,
247
+ onClear: i,
248
+ disabled: r = !1,
249
+ labelRender: c,
250
+ options: o = [],
251
+ type: b,
252
+ prefix: d,
253
+ suffixIcon: s,
254
+ ghost: p,
255
+ inputValueStyle: f,
256
+ tagStyle: S
257
+ }) => {
258
+ const N = Q(null), y = Ue(r ? null : N), { isOpen: a, value: _ } = re(), { fieldNames: m } = q(), g = F(() => {
259
+ if (qe(_))
260
+ return [];
261
+ const u = Ke(_) ? _ : [_];
262
+ if (b === R.TREE) {
263
+ const h = K(m), x = _t(o, m);
264
+ return u.map((I) => x.find((w) => h.getValue(w) === I)).filter((I) => !!I);
265
+ }
266
+ return u.map((h) => o.find((x) => x[m.value] === h)).filter((h) => !!h);
267
+ }, [_, o, b, m]);
268
+ return /* @__PURE__ */ t(
269
+ "div",
270
+ {
271
+ className: E("bsy-select-input-container", {
272
+ disabled: r,
273
+ multiple: n === U.MULTIPLE,
274
+ active: a,
275
+ "ghost-style": p
276
+ }),
277
+ ref: N,
278
+ children: /* @__PURE__ */ O("div", { className: E("bsy-select-input-container-input"), children: [
279
+ d && /* @__PURE__ */ t("div", { className: "bsy-select-input-container-input-prefix", children: d }),
280
+ g != null && g.length ? /* @__PURE__ */ O(te, { children: [
281
+ n === U.SINGLE && /* @__PURE__ */ t(
282
+ Ne,
283
+ {
284
+ value: g,
285
+ labelRender: c,
286
+ inputValueStyle: f
287
+ }
288
+ ),
289
+ n === U.MULTIPLE && /* @__PURE__ */ t(
290
+ xe,
291
+ {
292
+ value: g,
293
+ labelRender: c,
294
+ tagStyle: S
295
+ }
296
+ )
297
+ ] }) : /* @__PURE__ */ t("div", { className: "bsy-select-input-container__input-value-placeholder truncate", children: e }),
298
+ /* @__PURE__ */ t("div", { className: E("bsy-select-input-container__icon"), children: /* @__PURE__ */ t(_e, { mode: "wait", children: g != null && g.length && l && y ? /* @__PURE__ */ t(Y.div, { ...pe, children: /* @__PURE__ */ t(
299
+ H,
300
+ {
301
+ name: "cancel",
302
+ className: "icon hover:text-[#0265ff] text-[#666]",
303
+ role: "button",
304
+ "aria-label": "clear",
305
+ onClick: (u) => {
306
+ u.stopPropagation(), i == null || i();
307
+ }
308
+ }
309
+ ) }, "cancel") : /* @__PURE__ */ t(Y.div, { ...pe, children: s ? s(a, r) : /* @__PURE__ */ t(
310
+ H,
311
+ {
312
+ name: "arrow-down",
313
+ className: E("icon", {
314
+ active: a,
315
+ "text-[#c2c2c2]": r,
316
+ "text-[#666]": !r
317
+ })
318
+ }
319
+ ) }, "arrow") }) })
320
+ ] })
321
+ }
322
+ );
323
+ };
324
+ Oe.displayName = "BsySelectInput";
325
+ const Ee = (e) => {
326
+ const { t: n } = j(), { searchPlaceholder: l = n("search"), value: i = "", onChange: r } = e;
327
+ return /* @__PURE__ */ t("div", { className: "bsy-select-input-search", children: /* @__PURE__ */ O("div", { className: "bsy-select-input-search-input", children: [
328
+ /* @__PURE__ */ t("div", { className: "bsy-select-input-search-input__icon flex items-center justify-center", children: /* @__PURE__ */ t(H, { name: "search", style: { color: "#666", fontSize: 16 } }) }),
329
+ /* @__PURE__ */ t("div", { className: "bsy-select-input-search-input__container", children: /* @__PURE__ */ t(
330
+ "input",
331
+ {
332
+ type: "text",
333
+ placeholder: l,
334
+ value: i,
335
+ onChange: (c) => r == null ? void 0 : r(c.target.value),
336
+ role: "searchbox",
337
+ "aria-label": "search options"
338
+ }
339
+ ) }),
340
+ i && /* @__PURE__ */ t(
341
+ "div",
342
+ {
343
+ className: "bsy-select-input-search-input__icon flex items-center justify-center cursor-pointer",
344
+ onClick: () => r == null ? void 0 : r(""),
345
+ role: "button",
346
+ "aria-label": "clear search",
347
+ children: /* @__PURE__ */ t(H, { name: "close" })
348
+ }
349
+ )
350
+ ] }) });
351
+ };
352
+ Ee.displayName = "BsySelectInputSearch";
353
+ const Ie = se((e) => {
354
+ const {
355
+ options: n,
356
+ value: l,
357
+ onSelect: i,
358
+ searchValue: r = "",
359
+ fieldNames: c,
360
+ optionRender: o,
361
+ optionStyle: b
362
+ } = e, { otherInputPosition: d } = q(), {
363
+ otherOptionValue: s,
364
+ setOtherOptionValue: p,
365
+ onOtherInputChange: f,
366
+ isSelectedOtherOption: S = !1
367
+ } = Se(), N = Q(null), y = K(c);
368
+ return /* @__PURE__ */ t("ul", { role: "listbox", children: n.map((a, _) => {
369
+ const m = y.getValue(a), g = y.getLabel(a), u = a.systemField || !1, h = a.isOther === !0, x = h && d === "inline" && g.length > 6 ? g.slice(0, 6) + "..." : g, I = h ? S : m === l;
370
+ return /* @__PURE__ */ O(
371
+ "li",
372
+ {
373
+ role: "option",
374
+ "aria-selected": I,
375
+ className: E("cursor-pointer rounded-[4px] py-[7px] px-[10px] min-h-[34px]", {
376
+ "hover:bg-[#f3f3f3]": !I,
377
+ "text-[#4d609f]": u && !I,
378
+ "text-[#0265ff] bg-[#f0f6ff]": I,
379
+ "flex items-center": h && d === "inline"
380
+ }),
381
+ style: b,
382
+ onClick: () => {
383
+ i(m, a);
384
+ },
385
+ children: [
386
+ /* @__PURE__ */ t("div", { title: g, children: o ? o(a, { index: _ }, I) : /* @__PURE__ */ t(ge, { text: x, highlight: r }) }),
387
+ h && d === "inline" && /* @__PURE__ */ t(
388
+ "div",
389
+ {
390
+ className: "ml-2 flex-1",
391
+ onClick: (w) => w.stopPropagation(),
392
+ style: {
393
+ minWidth: "146px"
394
+ },
395
+ children: /* @__PURE__ */ t(
396
+ Xe,
397
+ {
398
+ ref: N,
399
+ value: s,
400
+ onChange: (w) => {
401
+ const P = w.target.value;
402
+ p == null || p(P), f == null || f(P);
403
+ },
404
+ onPressEnter: () => {
405
+ s && i(m, a);
406
+ },
407
+ onBlur: () => {
408
+ s && i(m, a);
409
+ },
410
+ placeholder: "请输入内容"
411
+ }
412
+ )
413
+ }
414
+ )
415
+ ]
416
+ },
417
+ `${m}-${_}`
418
+ );
419
+ }) });
420
+ });
421
+ Ie.displayName = "BsySingleSelect";
422
+ const Ve = (e) => {
423
+ const { t: n } = j(), { options: l, searchValue: i = "", value: r, onSelect: c, fieldNames: o, optionRender: b } = e, d = K(o), s = r || [], p = l.filter((y) => !y.isOther), f = p.length > 0 && p.every((y) => s.includes(d.getValue(y))), S = (y) => {
424
+ const a = p.filter((_) => y.includes(d.getValue(_)));
425
+ c(y, a);
426
+ }, N = () => {
427
+ const y = f ? [] : p.map((_) => d.getValue(_)), a = f ? [] : p.filter((_) => s.includes(d.getValue(_)));
428
+ c(y, a);
429
+ };
430
+ return /* @__PURE__ */ t("div", { className: "bsy-multiple-select", children: /* @__PURE__ */ O("ul", { className: "bsy-multiple-select-list", children: [
431
+ /* @__PURE__ */ t(
432
+ "li",
433
+ {
434
+ className: E(
435
+ "flex items-center gap-[8px]",
436
+ "cursor-pointer hover:bg-[#f3f3f3] rounded-[4px] min-h-[34px]",
437
+ "bsy-multiple-select-item"
438
+ ),
439
+ children: /* @__PURE__ */ t(
440
+ X,
441
+ {
442
+ checked: f,
443
+ onChange: N,
444
+ indeterminate: s.length > 0 && s.length < p.length,
445
+ style: { padding: "7px 10px" },
446
+ children: /* @__PURE__ */ t("span", { className: "font-bold text-[#0265ff]", children: n(i ? "allSelectedBySearch" : "allSelect") })
447
+ }
448
+ )
449
+ }
450
+ ),
451
+ /* @__PURE__ */ t(X.Group, { value: s, onChange: S, children: p.map((y, a) => {
452
+ const _ = d.getValue(y), m = d.getLabel(y), g = s.includes(_), u = y.systemField || !1;
453
+ return /* @__PURE__ */ t(
454
+ "li",
455
+ {
456
+ className: E(
457
+ "flex items-center gap-[8px] min-h-[34px]",
458
+ "cursor-pointer rounded-[4px]",
459
+ "bsy-multiple-select-item",
460
+ {
461
+ "hover:bg-[#f3f3f3]": !0,
462
+ "text-[#0265ff]": g,
463
+ "text-[#4d609f]": u && !g
464
+ }
465
+ ),
466
+ children: /* @__PURE__ */ t(X, { value: _, style: { padding: "7px 10px" }, children: b ? b(y, { index: a }, g) : /* @__PURE__ */ t(ge, { text: m, highlight: i }) })
467
+ },
468
+ `${_}-${a}`
469
+ );
470
+ }) })
471
+ ] }) });
472
+ };
473
+ Ve.displayName = "BsyMultipleSelect";
474
+ const gt = (e) => {
475
+ const { options: n, searchValue: l, value: i, onSelect: r, fieldNames: c } = e;
476
+ return /* @__PURE__ */ t("div", { className: "bsy-tree-select", children: /* @__PURE__ */ t("div", { className: "bsy-tree-select-nodes", children: /* @__PURE__ */ t(
477
+ Qe,
478
+ {
479
+ data: n,
480
+ searchValue: l,
481
+ fieldNames: c ? {
482
+ title: c.label,
483
+ value: c.value,
484
+ children: c.children
485
+ } : void 0,
486
+ selectedKeys: i ? [i] : [],
487
+ onSelect: r
488
+ }
489
+ ) }) });
490
+ }, yt = (e, n) => {
491
+ const l = [], i = (r) => {
492
+ if (r)
493
+ for (const c of r)
494
+ l.push(c), i(c[n.children]);
495
+ };
496
+ return i(e), l;
497
+ }, Ce = (e, n, l) => e.reduce((i, r) => {
498
+ const c = r[l.children] ? Ce(r[l.children], n, l) : void 0;
499
+ if (n.has(r[l.value]) || c && c.length > 0) {
500
+ const o = n.has(r[l.value]) ? r[l.children] : c;
501
+ i.push({ ...r, children: o });
502
+ }
503
+ return i;
504
+ }, []), bt = (e) => {
505
+ const { options: n = [], searchValue: l = "", type: i, filterOption: r, optionRender: c, optionStyle: o } = e, { t: b } = j(), { value: d, setIsOpen: s, setValue: p } = re(), { fieldNames: f } = q(), S = F(() => i === R.TREE ? yt(n, f) : n, [n, f, i]), N = F(
506
+ () => new Ye(S, {
507
+ keys: [f.label],
508
+ ignoreLocation: !0,
509
+ threshold: 0.3
510
+ }),
511
+ [S, f]
512
+ ), y = z(
513
+ (u, h) => {
514
+ s == null || s(!1), p(u, h);
515
+ },
516
+ [s, p]
517
+ ), a = z(
518
+ (u, h) => {
519
+ p(u, h);
520
+ },
521
+ [p]
522
+ ), _ = z(
523
+ (u, h) => {
524
+ s == null || s(!1), p(u, h);
525
+ },
526
+ [s, p]
527
+ ), m = () => {
528
+ if (!r || de(l))
529
+ return n;
530
+ const u = N.search(l), h = new Set(u.map((x) => x.item[f.value]));
531
+ return i === R.TREE ? Ce(n, h, f) : n.filter((x) => h.has(x[f.value]));
532
+ };
533
+ return /* @__PURE__ */ t(te, { children: (() => {
534
+ const u = {
535
+ options: m(),
536
+ searchValue: l,
537
+ optionStyle: o
538
+ };
539
+ if (!de(l) && u.options.length === 0)
540
+ return /* @__PURE__ */ t(Z, { text: b("noDataFound") });
541
+ switch (i) {
542
+ case R.SINGLE:
543
+ return /* @__PURE__ */ t(
544
+ Ie,
545
+ {
546
+ ...u,
547
+ value: d,
548
+ fieldNames: f,
549
+ onSelect: y,
550
+ optionRender: c
551
+ }
552
+ );
553
+ case R.MULTIPLE:
554
+ return /* @__PURE__ */ t(
555
+ Ve,
556
+ {
557
+ ...u,
558
+ value: d,
559
+ fieldNames: f,
560
+ onSelect: a,
561
+ optionRender: c
562
+ }
563
+ );
564
+ case R.TREE:
565
+ return /* @__PURE__ */ t(
566
+ gt,
567
+ {
568
+ ...u,
569
+ value: d,
570
+ fieldNames: f,
571
+ onSelect: _
572
+ }
573
+ );
574
+ default:
575
+ return null;
576
+ }
577
+ })() });
578
+ }, Le = (e) => {
579
+ const {
580
+ options: n = [],
581
+ type: l = R.SINGLE,
582
+ filterOption: i = !0,
583
+ onSearch: r,
584
+ showSearch: c,
585
+ searchPlaceholder: o,
586
+ onPopupScroll: b
587
+ } = e, { t: d } = j(), [s, p] = ie(), f = fe(s), S = (a) => {
588
+ p(a), r == null || r(a);
589
+ }, N = () => e.fetching ? /* @__PURE__ */ t(Z, { text: d("dataSearching") }) : n.length === 0 && !s ? /* @__PURE__ */ t(Z, { text: d("noData") }) : /* @__PURE__ */ t(
590
+ bt,
591
+ {
592
+ searchValue: f,
593
+ options: n,
594
+ type: l,
595
+ filterOption: i,
596
+ optionRender: e.optionRender,
597
+ optionStyle: e.optionStyle
598
+ }
599
+ ), y = (a) => {
600
+ const _ = a != null && a.currentTarget ? a : { currentTarget: a };
601
+ b == null || b(_);
602
+ };
603
+ return /* @__PURE__ */ t(Y.div, { ...Je, children: /* @__PURE__ */ t("div", { className: "bsy-select-panel", children: /* @__PURE__ */ O(ze, { children: [
604
+ c && /* @__PURE__ */ t(
605
+ Ee,
606
+ {
607
+ value: s,
608
+ onChange: S,
609
+ searchPlaceholder: o
610
+ }
611
+ ),
612
+ /* @__PURE__ */ t(
613
+ "div",
614
+ {
615
+ className: E({
616
+ "pt-[4px]": c
617
+ }),
618
+ children: /* @__PURE__ */ t(Ze, { style: { maxHeight: 300 }, onScroll: y, children: N() })
619
+ }
620
+ )
621
+ ] }) }) });
622
+ };
623
+ Le.displayName = "BsySelectPanel";
624
+ const vt = (e) => {
625
+ const { isOpen: n, close: l, showMask: i, zIndex: r, zIndexMask: c, offset: o, popupMinWidth: b } = e, { refs: d, floatingStyles: s, context: p } = et({
626
+ open: n,
627
+ onOpenChange: (_) => {
628
+ _ || l();
629
+ },
630
+ placement: "bottom-start",
631
+ whileElementsMounted: it,
632
+ middleware: [
633
+ tt(),
634
+ nt({ padding: 8 }),
635
+ lt({
636
+ mainAxis: (o == null ? void 0 : o.y) || 0,
637
+ crossAxis: (o == null ? void 0 : o.x) || 0
638
+ }),
639
+ st({
640
+ apply({ rects: _, elements: m }) {
641
+ Object.assign(m.floating.style, {
642
+ minWidth: b,
643
+ width: `${_.reference.width}px`,
644
+ zIndex: r
645
+ });
646
+ }
647
+ })
648
+ ]
649
+ }), f = rt(p), S = ct(p, {
650
+ outsidePress: !0
651
+ }), { getReferenceProps: N, getFloatingProps: y } = ot([f, S]), a = F(() => i && n && c !== void 0 ? {
652
+ zIndex: c + 1,
653
+ position: "relative"
654
+ } : {}, [i, n, c]);
655
+ return {
656
+ refs: d,
657
+ floatingStyles: s,
658
+ context: p,
659
+ getReferenceProps: N,
660
+ getFloatingProps: y,
661
+ referenceStyle: a
662
+ };
663
+ }, St = me((e, n) => {
664
+ const {
665
+ options: l = [],
666
+ type: i = R.SINGLE,
667
+ fieldNames: r,
668
+ clearable: c = !0,
669
+ disabled: o = !1,
670
+ placeholder: b,
671
+ labelRender: d,
672
+ onOtherInputChange: s,
673
+ onOpenChange: p,
674
+ onPopupScroll: f,
675
+ prefix: S,
676
+ suffixIcon: N,
677
+ ghost: y,
678
+ inputValueStyle: a,
679
+ tagStyle: _,
680
+ zIndex: m = 1101,
681
+ zIndexMask: g = 1100,
682
+ otherInputPosition: u = "bottom",
683
+ popupMinWidth: h
684
+ } = e, x = ut[i], { t: I } = j(), w = De(), { onChange: P } = e, C = r || he, [V, M] = He(e, {
685
+ defaultValue: x === U.SINGLE ? void 0 : [],
686
+ defaultValuePropName: "defaultValue",
687
+ valuePropName: "value",
688
+ trigger: "__NO_CUSTOM_CHANGE__"
689
+ }), [k, T] = ie(() => {
690
+ const v = l.every((L) => L[C.value] !== V), B = l.find((L) => L.isOther === !0);
691
+ return v && B ? V : "";
692
+ }), D = z(
693
+ (v, B) => {
694
+ M(v), P && P(v, B);
695
+ },
696
+ [P, M]
697
+ ), [$, { set: ce }] = $e(!1), W = z(
698
+ (v) => {
699
+ ce(v), p == null || p(v);
700
+ },
701
+ [ce, p]
702
+ ), { isSelectedOtherOption: J, shouldShowOtherInput: we } = F(() => {
703
+ const v = l.find((L) => L[C.value] === V);
704
+ return v ? {
705
+ isSelectedOtherOption: v.isOther === !0,
706
+ shouldShowOtherInput: v.isOther === !0
707
+ } : l.find((L) => L.isOther === !0) && V ? { isSelectedOtherOption: !0, shouldShowOtherInput: !0 } : { isSelectedOtherOption: !1, shouldShowOtherInput: !1 };
708
+ }, [V, l, C]), oe = z(() => {
709
+ if (V) {
710
+ const v = l.every((L) => L[C.value] !== V), B = l.find((L) => L.isOther === !0);
711
+ return v && B ? B[C.value] : V;
712
+ } else
713
+ return V;
714
+ }, [V, l, C]), Pe = F(
715
+ () => ({
716
+ value: oe(),
717
+ setValue: D,
718
+ isOpen: $,
719
+ setIsOpen: W
720
+ }),
721
+ [oe, D, $, W]
722
+ ), Re = F(
723
+ () => ({
724
+ fieldNames: r || he,
725
+ disabled: o,
726
+ otherInputPosition: u
727
+ }),
728
+ [r, o, u]
729
+ ), Me = F(
730
+ () => ({
731
+ isSelectedOtherOption: J,
732
+ otherOptionValue: k,
733
+ setOtherOptionValue: T,
734
+ onOtherInputChange: s
735
+ }),
736
+ [J, k, T, s]
737
+ ), { refs: ae, floatingStyles: Te, getReferenceProps: Ae, getFloatingProps: Fe, referenceStyle: ke } = vt({
738
+ isOpen: $,
739
+ close: () => {
740
+ W(!1);
741
+ },
742
+ showMask: e.showMask,
743
+ zIndex: m,
744
+ zIndexMask: g,
745
+ popupMinWidth: h,
746
+ offset: {
747
+ x: 0,
748
+ y: 4
749
+ }
750
+ }), Be = z(() => {
751
+ J && (T(""), s == null || s("")), W(!1), D(x === U.SINGLE ? void 0 : []);
752
+ }, [J, s, D, x, W]);
753
+ return We(
754
+ n,
755
+ () => ({
756
+ getOtherOptionValue: () => k,
757
+ setOtherOptionValue: (v) => {
758
+ T(v), s == null || s(v);
759
+ }
760
+ }),
761
+ [k, s]
762
+ ), /* @__PURE__ */ t(ye.Provider, { value: Pe, children: /* @__PURE__ */ t(be.Provider, { value: Re, children: /* @__PURE__ */ t(ve.Provider, { value: Me, children: /* @__PURE__ */ O(
763
+ "div",
764
+ {
765
+ className: E("bsy-select-container text-sm", e.className),
766
+ style: e.style,
767
+ children: [
768
+ /* @__PURE__ */ t(
769
+ "div",
770
+ {
771
+ ref: ae.setReference,
772
+ className: E("bsy-select-input-event", e.inputClassName),
773
+ ...Ae(),
774
+ style: ke,
775
+ onClick: () => {
776
+ e.disabled || W(!0);
777
+ },
778
+ role: "combobox",
779
+ "aria-expanded": $,
780
+ "aria-haspopup": "listbox",
781
+ "aria-controls": w,
782
+ "aria-disabled": o,
783
+ children: /* @__PURE__ */ t(
784
+ Oe,
785
+ {
786
+ mode: x,
787
+ clearable: c,
788
+ disabled: o,
789
+ placeholder: b || I("select"),
790
+ labelRender: d,
791
+ options: l,
792
+ type: i,
793
+ prefix: S,
794
+ suffixIcon: N,
795
+ ghost: y,
796
+ inputValueStyle: a,
797
+ tagStyle: _,
798
+ onClear: Be
799
+ }
800
+ )
801
+ }
802
+ ),
803
+ /* @__PURE__ */ t(at, { children: /* @__PURE__ */ t(_e, { children: $ && /* @__PURE__ */ O(te, { children: [
804
+ e.showMask && /* @__PURE__ */ t(
805
+ "div",
806
+ {
807
+ className: "bsy-select-mask",
808
+ style: {
809
+ zIndex: g
810
+ }
811
+ }
812
+ ),
813
+ /* @__PURE__ */ t(
814
+ "div",
815
+ {
816
+ ref: ae.setFloating,
817
+ style: Te,
818
+ ...Fe(),
819
+ id: w,
820
+ children: /* @__PURE__ */ t(Le, { ...e, options: l, onPopupScroll: f })
821
+ }
822
+ )
823
+ ] }) }) }),
824
+ we && u === "bottom" ? e.otherOptionRender ? e.otherOptionRender(k, l) : /* @__PURE__ */ t(
825
+ "div",
826
+ {
827
+ className: E(
828
+ "mt-[6px] w-full px-[10px] py-[7px] bg-white rounded-[4px]",
829
+ "border border-[#e0e0e0]"
830
+ ),
831
+ children: /* @__PURE__ */ t(
832
+ "input",
833
+ {
834
+ value: k,
835
+ onChange: (v) => {
836
+ T(v.target.value), s == null || s(v.target.value);
837
+ },
838
+ className: "w-full outline-none border-none placeholder:text-[#999]",
839
+ placeholder: "请输入内容",
840
+ "aria-label": "其他选项输入框",
841
+ role: "textbox"
842
+ }
843
+ )
844
+ }
845
+ ) : null
846
+ ]
847
+ }
848
+ ) }) }) });
849
+ });
850
+ St.displayName = "BsySelect";
851
+ export {
852
+ U as M,
853
+ St as S,
854
+ R as a
855
+ };