@baishuyun/ui-base 2.1.0 → 2.2.2

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