@baishuyun/ui-base 6.23.4 → 6.24.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 (39) hide show
  1. package/dist/Amap/index.js +1 -1
  2. package/dist/Calendar/{Calendar-BKIWDQuM.js → Calendar-Iyzwzp_2.js} +1 -1
  3. package/dist/Calendar/index.js +3 -3
  4. package/dist/Card/index.js +1 -1
  5. package/dist/CheckBox/{CheckBox-BErX3YWP.js → CheckBox-BzEWkFYf.js} +15 -15
  6. package/dist/CheckBox/{CheckBox-Dp7hxT2F.js → CheckBox-DwM2Jof2.js} +1 -1
  7. package/dist/CheckBox/index.js +3 -3
  8. package/dist/ColorPicker/index.js +1 -1
  9. package/dist/ConfigProvider/index.js +1 -1
  10. package/dist/DatePicker/{DatePicker-f_fVD2Ba.js → DatePicker-B3AcIGVB.js} +1 -1
  11. package/dist/DatePicker/{DatePickerPanel-5aZUPcVN.js → DatePickerPanel-WIC4IcER.js} +1 -1
  12. package/dist/DatePicker/index.js +2 -2
  13. package/dist/DropDown/index.js +1 -1
  14. package/dist/Editor/index.js +3 -3
  15. package/dist/Gantt/index.js +1 -1
  16. package/dist/Icon/index.js +1 -1
  17. package/dist/InputTag/index.js +1 -1
  18. package/dist/Loading/index.js +1 -1
  19. package/dist/Modal/index.js +1 -1
  20. package/dist/NotFoundContent/index.js +1 -1
  21. package/dist/Overlay/index.js +1 -1
  22. package/dist/Radio/index.js +1 -1
  23. package/dist/ScrollBar/index.js +1 -1
  24. package/dist/Segmented/index.js +1 -1
  25. package/dist/Select/Select-BdTsElGr.js +776 -0
  26. package/dist/Select/index.js +5 -5
  27. package/dist/Table/index.js +1 -1
  28. package/dist/Tabs/{Tabs-BupQZHao.js → Tabs-BXW_WHe7.js} +4 -4
  29. package/dist/Tabs/index.js +2 -2
  30. package/dist/Tooltip/index.js +1 -1
  31. package/dist/Tree/index.js +3 -3
  32. package/dist/components/Select/HighlightText/HighlightText.d.ts +1 -0
  33. package/dist/components/Select/interface.d.ts +8 -1
  34. package/dist/index.js +8 -8
  35. package/dist/style.css +1 -1
  36. package/dist/vendors/{Tree-DWK-JPnJ.js → Tree-BX1wWVS4.js} +10 -10
  37. package/dist/vendors/{version-D40Io1_9.js → version-BoH6YX7g.js} +1 -1
  38. package/package.json +1 -1
  39. package/dist/Select/Select-ByqucfXU.js +0 -770
@@ -1,770 +0,0 @@
1
- import { t as e } from "../Icon/Icon-DrdQOEJE.js";
2
- import { a as t, i as n } from "../Overlay/OverlayContext-CVSFoyqN.js";
3
- import { t as r } from "../vendors/useLocale-Be4e7Xfn.js";
4
- import { n as i, r as a } from "../vendors/animations-ISccYUE3.js";
5
- import { t as o } from "../vendors/useLatchedPopupPortalRoot-CC6af8t-.js";
6
- import { t as s } from "../vendors/cssVars-UpriQzph.js";
7
- import { t as c } from "./SelectInputSearch-MApQHnU9.js";
8
- import { n as l, t as u } from "../vendors/Tree-DWK-JPnJ.js";
9
- import { t as d } from "../CheckBox/CheckBox-Dp7hxT2F.js";
10
- import { t as f } from "../NotFoundContent/NotFoundContent-DJUQ0_2D.js";
11
- import { t as p } from "../ScrollBar/ScrollBar-IMTuAOF5.js";
12
- import { t as m } from "../vendors/useFloatingPortal-DJ1iKmW-.js";
13
- import { first as h, isArray as g, isEmpty as _, isNil as v, noop as y } from "lodash-es";
14
- import { Fragment as b, jsx as x, jsxs as S } from "react/jsx-runtime";
15
- import { Suspense as C, createContext as w, forwardRef as T, memo as E, useCallback as D, useContext as O, useDeferredValue as k, useId as ee, useImperativeHandle as te, useLayoutEffect as A, useMemo as j, useRef as M, useState as N } from "react";
16
- import { Input as P } from "antd";
17
- import F from "clsx";
18
- import { useControllableValue as ne, useHover as re, useToggle as ie } from "ahooks";
19
- import { AnimatePresence as ae, motion as I } from "motion/react";
20
- import { FloatingPortal as oe } from "@floating-ui/react";
21
- import L from "fuse.js";
22
- //#region src/components/Select/constants.ts
23
- var R = /* @__PURE__ */ function(e) {
24
- return e.SINGLE = "single", e.MULTIPLE = "multiple", e;
25
- }({}), z = /* @__PURE__ */ function(e) {
26
- return 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;
27
- }({}), se = {
28
- [z.SINGLE]: R.SINGLE,
29
- [z.TREE]: R.SINGLE,
30
- [z.MULTIPLE]: R.MULTIPLE,
31
- [z.TREE_TAGS]: R.MULTIPLE,
32
- [z.MEMBER]: R.MULTIPLE,
33
- [z.DEPARTEMENT]: R.MULTIPLE
34
- }, ce = {
35
- label: "label",
36
- value: "value",
37
- children: "children"
38
- }, le = w({
39
- value: void 0,
40
- setValue: y,
41
- isOpen: !1,
42
- setIsOpen: y
43
- }), ue = w({
44
- fieldNames: {
45
- label: "label",
46
- value: "value",
47
- children: "children"
48
- },
49
- disabled: !1
50
- }), de = w({}), B = () => {
51
- let e = O(le);
52
- if (!e) throw Error("Select.* components must be used within a SelectStateContext provider");
53
- return e;
54
- }, V = () => {
55
- let e = O(ue);
56
- if (!e) throw Error("Select.* components must be used within a SelectConfigContext provider");
57
- return e;
58
- }, H = () => O(de);
59
- //#endregion
60
- //#region src/components/Select/utils/fieldAccessor.ts
61
- function U(e) {
62
- let t = e;
63
- return {
64
- getLabel: (e) => e[t.label],
65
- getValue: (e) => e[t.value],
66
- getChildren: (e) => {
67
- if (t.children) return e[t.children];
68
- },
69
- normalizeOption: (e) => ({
70
- ...e,
71
- label: e[t.label],
72
- value: e[t.value],
73
- children: t.children ? e[t.children] : void 0
74
- }),
75
- getFieldNames: () => t
76
- };
77
- }
78
- //#endregion
79
- //#region src/components/Select/SelectInput/SelectSingleInput/SelectSingleInput.tsx
80
- var W = E((e) => {
81
- let { value: t, inputValueStyle: n } = e, { fieldNames: r, otherInputPosition: i } = V(), { isSelectedOtherOption: a, otherOptionValue: o } = H(), s = U(r), c = h(t), l;
82
- return l = a && o && i === "inline" ? o : e.labelRender && c ? e.labelRender(c) : c ? s.getLabel(c) : "", /* @__PURE__ */ x("div", {
83
- className: F("bsy-select-input-container__input-value overflow-hidden"),
84
- style: n,
85
- children: /* @__PURE__ */ x("div", {
86
- className: "bsy-select-input-container__input-value-text",
87
- children: l
88
- })
89
- });
90
- });
91
- W.displayName = "BsySelectSingleInput";
92
- //#endregion
93
- //#region src/components/Select/SelectInput/SelectMultipleInput/OptionTag/option-tag.module.scss
94
- var G = {
95
- "bsy-input-tag__container": "_bsy-input-tag__container_1bb6m_1",
96
- "bsy-input-tag__item": "_bsy-input-tag__item_1bb6m_7",
97
- "bsy-input-tag__item--disabled": "_bsy-input-tag__item--disabled_1bb6m_20",
98
- "bsy-input-tag__item-icon": "_bsy-input-tag__item-icon_1bb6m_24"
99
- }, K = T(({ children: e, style: t, disabled: n }, r) => /* @__PURE__ */ x("div", {
100
- "data-bsy-input-tag": "true",
101
- className: F({
102
- [G["bsy-input-tag__item"]]: !0,
103
- [G["bsy-input-tag__item--disabled"]]: n
104
- }),
105
- ref: r,
106
- style: t,
107
- children: e
108
- }));
109
- K.Container = (e) => /* @__PURE__ */ x("div", {
110
- className: F(G["bsy-input-tag__container"]),
111
- children: e.children
112
- }), K.displayName = "BsyOptionTag";
113
- //#endregion
114
- //#region src/components/Select/SelectInput/SelectMultipleInput/select-multiple-input.module.scss
115
- var fe = "_select_multiple_input__container_15izh_1", pe = "_select_multiple_input__measurement_layer_15izh_6", me = "_select_multiple_input__close_btn_15izh_14", q = "_select_multiple_input__ellipsis_15izh_24", J = "_select_multiple_input__tag_content_15izh_27", Y = {
116
- select_multiple_input__container: fe,
117
- select_multiple_input__measurement_layer: pe,
118
- select_multiple_input__close_btn: me,
119
- "select_multiple_input__close_btn--disabled": "_select_multiple_input__close_btn--disabled_15izh_21",
120
- select_multiple_input__ellipsis: q,
121
- select_multiple_input__tag_content: J
122
- }, X = 4, Z = E((t) => {
123
- let { value: n, labelRender: r, tagStyle: i } = t, { setValue: a } = B(), { fieldNames: o, disabled: s } = V(), c = U(o), l = n?.length ?? 0, [u, d] = N(0), f = M(null), p = M(null);
124
- A(() => {
125
- if (!f.current) return;
126
- let e = new ResizeObserver((e) => {
127
- let t = e[0];
128
- if (!t) return;
129
- let r = t.contentRect.width, i = t.target.querySelectorAll(".measure-list [data-bsy-input-tag=\"true\"]");
130
- if (i.length === 0) {
131
- d(n?.length ?? 0);
132
- return;
133
- }
134
- let a = p.current?.offsetWidth || 65, o = 0, s = 0;
135
- for (let e = 0; e < i.length; e++) {
136
- let t = i[e].clientWidth + X, n = e < l - 1 ? a : 0;
137
- if (o + t + n <= r) o += t, s = e + 1;
138
- else break;
139
- }
140
- s === 0 && l === 1 && (s = 1), u !== s && d(s);
141
- });
142
- return e.observe(f.current), () => e.disconnect();
143
- }, [
144
- l,
145
- u,
146
- n.length
147
- ]);
148
- let m = l - u, h = k(m), g = /* @__PURE__ */ x("div", {
149
- className: `${Y.select_multiple_input__measurement_layer} measure-list`,
150
- children: /* @__PURE__ */ S(K.Container, { children: [n?.map((t, n) => {
151
- let a = (t) => /* @__PURE__ */ x("div", {
152
- style: t,
153
- className: F(G["bsy-input-tag__item-icon"], "cursor-pointer"),
154
- children: /* @__PURE__ */ x(e, {
155
- name: "close",
156
- style: { fontSize: 12 },
157
- className: Y.select_multiple_input__close_btn
158
- })
159
- });
160
- return /* @__PURE__ */ S(K, {
161
- style: i,
162
- children: [r && r(t, a), !r && /* @__PURE__ */ S("div", {
163
- className: Y.select_multiple_input__tag_content,
164
- children: [/* @__PURE__ */ x("span", { children: c.getLabel(t) }), /* @__PURE__ */ x(a, {})]
165
- })]
166
- }, n);
167
- }), u < l && h > 0 && /* @__PURE__ */ S(K, {
168
- ref: p,
169
- children: [`+ ${m}`, /* @__PURE__ */ x("span", {
170
- className: Y.select_multiple_input__ellipsis,
171
- children: "..."
172
- })]
173
- })] })
174
- }), _ = (e) => {
175
- if (s) return;
176
- let t = n.filter((t) => c.getValue(t) !== c.getValue(e));
177
- a(t.map((e) => c.getValue(e)), t);
178
- };
179
- return /* @__PURE__ */ S("div", {
180
- ref: f,
181
- className: F("bsy-select-input-container__input-value", Y.select_multiple_input__container, "multiple"),
182
- children: [g, /* @__PURE__ */ S(K.Container, { children: [n?.slice(0, u).map((t, n) => {
183
- let a = (n) => /* @__PURE__ */ x("div", {
184
- style: n,
185
- className: F(G["bsy-input-tag__item-icon"], {
186
- [Y.select_multiple_input__close_btn]: !s,
187
- [Y.select_multiple_input__close_btn + "--disabled"]: s
188
- }),
189
- onClick: (e) => {
190
- e.stopPropagation(), _(t);
191
- },
192
- children: /* @__PURE__ */ x(e, {
193
- name: "close",
194
- style: { fontSize: 12 }
195
- })
196
- });
197
- return /* @__PURE__ */ S(K, {
198
- style: {
199
- ...i,
200
- flexShrink: u === 1 ? 1 : 0
201
- },
202
- disabled: s,
203
- children: [r && r(t, a), !r && /* @__PURE__ */ S("div", {
204
- className: Y.select_multiple_input__tag_content,
205
- children: [/* @__PURE__ */ x("span", {
206
- className: "truncate",
207
- children: c.getLabel(t)
208
- }), /* @__PURE__ */ x(a, {})]
209
- })]
210
- }, n);
211
- }), u < l && h > 0 && /* @__PURE__ */ S(K, {
212
- ref: p,
213
- children: [`+ ${m} `, /* @__PURE__ */ x("span", {
214
- className: Y.select_multiple_input__ellipsis,
215
- children: "..."
216
- })]
217
- })] })]
218
- });
219
- });
220
- Z.displayName = "BsySelectMultipleInput";
221
- //#endregion
222
- //#region src/components/Select/utils/tree.ts
223
- var he = (e, t) => {
224
- let n = [], r = (e) => {
225
- e.forEach((e) => {
226
- let { [t.children]: i, ...a } = e;
227
- n.push(a), i && r(i);
228
- });
229
- };
230
- return r(e), n;
231
- }, ge = ({ placeholder: t, mode: n, clearable: r, onClear: a, disabled: o = !1, labelRender: s, options: c = [], type: l, prefix: u, suffixIcon: d, ghost: f, inputValueStyle: p, tagStyle: m }) => {
232
- let h = M(null), _ = re(o ? null : h), { isOpen: y, value: C, getCachedOptionByValue: w } = B(), { fieldNames: T } = V(), E = j(() => {
233
- if (v(C)) return [];
234
- let e = g(C) ? C : [C];
235
- if (l === z.TREE) {
236
- let t = U(T), n = he(c, T);
237
- return e.map((e) => n.find((n) => t.getValue(n) === e) || w?.(e)).filter((e) => !!e);
238
- }
239
- return e.map((e) => c.find((t) => t[T.value] === e) || w?.(e)).filter((e) => !!e);
240
- }, [
241
- C,
242
- c,
243
- l,
244
- T,
245
- w
246
- ]);
247
- return /* @__PURE__ */ x("div", {
248
- className: F("bsy-select-input-container", {
249
- disabled: o,
250
- multiple: n === R.MULTIPLE,
251
- active: y,
252
- "ghost-style": f
253
- }),
254
- ref: h,
255
- children: /* @__PURE__ */ S("div", {
256
- className: F("bsy-select-input-container-input"),
257
- children: [
258
- u && /* @__PURE__ */ x("div", {
259
- className: "bsy-select-input-container-input-prefix",
260
- children: u
261
- }),
262
- E?.length ? /* @__PURE__ */ S(b, { children: [n === R.SINGLE && /* @__PURE__ */ x(W, {
263
- value: E,
264
- labelRender: s,
265
- inputValueStyle: p
266
- }), n === R.MULTIPLE && /* @__PURE__ */ x(Z, {
267
- value: E,
268
- labelRender: s,
269
- tagStyle: m
270
- })] }) : /* @__PURE__ */ x("div", {
271
- className: "bsy-select-input-container__input-value-placeholder truncate",
272
- children: t
273
- }),
274
- /* @__PURE__ */ x("div", {
275
- className: F("bsy-select-input-container__icon"),
276
- children: /* @__PURE__ */ x(ae, {
277
- mode: "wait",
278
- children: E?.length && r && _ ? /* @__PURE__ */ x(I.div, {
279
- className: "bsy-select-input-container__icon-motion",
280
- ...i,
281
- children: /* @__PURE__ */ x(e, {
282
- name: "cancel",
283
- className: "icon bsy-select-input-clear",
284
- role: "button",
285
- "aria-label": "clear",
286
- onClick: (e) => {
287
- e.stopPropagation(), a?.();
288
- }
289
- })
290
- }, "cancel") : /* @__PURE__ */ x(I.div, {
291
- className: "bsy-select-input-container__icon-motion",
292
- ...i,
293
- children: d ? d(y, o) : /* @__PURE__ */ x(e, {
294
- name: "arrow-down",
295
- className: F("icon", { active: y })
296
- })
297
- }, "arrow")
298
- })
299
- })
300
- ]
301
- })
302
- });
303
- };
304
- ge.displayName = "BsySelectInput";
305
- //#endregion
306
- //#region src/components/Select/OptionList/SingleOptionList/SingleOptionList.tsx
307
- var Q = E((e) => {
308
- let { options: t, value: n, onSelect: i, searchValue: a = "", fieldNames: o, optionRender: s, optionStyle: c } = e, { t: u } = r(), { otherInputPosition: d } = V(), { otherOptionValue: f, setOtherOptionValue: p, onOtherInputChange: m, isSelectedOtherOption: h = !1 } = H(), g = M(null), _ = U(o);
309
- return /* @__PURE__ */ x("ul", {
310
- role: "listbox",
311
- children: t.map((e, t) => {
312
- let r = _.getValue(e), o = _.getLabel(e), v = e.systemField || !1, y = e.isOther === !0, b = e.disabled === !0, C = y && d === "inline" && o.length > 6 ? o.slice(0, 6) + "..." : o, w = y ? h : r === n;
313
- return /* @__PURE__ */ S("li", {
314
- role: "option",
315
- "aria-selected": w,
316
- "aria-disabled": b,
317
- className: F("rounded-[4px] py-[7px] px-[10px] min-h-[34px]", {
318
- "cursor-pointer": !b,
319
- "cursor-not-allowed bg-transparent": b,
320
- "bsy-select-option--disabled": b,
321
- "bsy-select-option--hoverable": !b && !w,
322
- "bsy-select-option--system": !b && v && !w,
323
- "bsy-select-option--selected": !b && w,
324
- "flex items-center": y && d === "inline"
325
- }),
326
- style: c,
327
- onClick: () => {
328
- b || i(r, e);
329
- },
330
- children: [/* @__PURE__ */ x("div", {
331
- title: o,
332
- children: s ? s(e, { index: t }, w) : /* @__PURE__ */ x(l, {
333
- text: C,
334
- highlight: a
335
- })
336
- }), y && d === "inline" && /* @__PURE__ */ x("div", {
337
- className: "ml-2 flex-1",
338
- onClick: (e) => e.stopPropagation(),
339
- style: { minWidth: "146px" },
340
- children: /* @__PURE__ */ x(P, {
341
- ref: g,
342
- value: f,
343
- disabled: b,
344
- onChange: (e) => {
345
- let t = e.target.value;
346
- p?.(t), m?.(t);
347
- },
348
- onPressEnter: () => {
349
- !b && f && i(r, e);
350
- },
351
- onBlur: () => {
352
- !b && f && i(r, e);
353
- },
354
- placeholder: u("context"),
355
- "aria-label": u("otherOptionInput")
356
- })
357
- })]
358
- }, `${r}-${t}`);
359
- })
360
- });
361
- });
362
- Q.displayName = "BsySingleSelect";
363
- //#endregion
364
- //#region src/components/Select/OptionList/MultOptionList/MultOptionList.tsx
365
- var $ = (e) => {
366
- let { t } = r(), { options: n, searchValue: i = "", value: a, onSelect: o, fieldNames: s, optionRender: c } = e, u = U(s), f = a || [], p = n.filter((e) => !e.isOther), m = p.filter((e) => !e.disabled), h = m.map((e) => u.getValue(e)), g = m.length > 0 && m.every((e) => f.includes(u.getValue(e)));
367
- return /* @__PURE__ */ x("div", {
368
- className: "bsy-multiple-select",
369
- children: /* @__PURE__ */ S("ul", {
370
- className: "bsy-multiple-select-list",
371
- children: [/* @__PURE__ */ x("li", {
372
- className: F("flex items-center gap-[8px]", "cursor-pointer rounded-[4px] min-h-[34px]", "bsy-select-option--hoverable", "bsy-multiple-select-item"),
373
- children: /* @__PURE__ */ x(d, {
374
- checked: g,
375
- disabled: m.length === 0,
376
- onChange: () => {
377
- let e = g ? f.filter((e) => !h.includes(e)) : [...f, ...h.filter((e) => !f.includes(e))];
378
- o(e, p.filter((t) => e.includes(u.getValue(t))));
379
- },
380
- indeterminate: m.some((e) => f.includes(u.getValue(e))) && !g,
381
- style: { padding: "7px 10px" },
382
- children: /* @__PURE__ */ x("span", {
383
- className: "font-bold bsy-select-option--all",
384
- children: t(i ? "allSelectedBySearch" : "allSelect")
385
- })
386
- })
387
- }), /* @__PURE__ */ x(d.Group, {
388
- value: f,
389
- onChange: (e) => {
390
- o(e, p.filter((t) => e.includes(u.getValue(t))));
391
- },
392
- children: p.map((e, t) => {
393
- let n = u.getValue(e), r = u.getLabel(e), a = f.includes(n), o = e.systemField || !1, s = e.disabled === !0;
394
- return /* @__PURE__ */ x("li", {
395
- "aria-disabled": s,
396
- className: F("flex items-center gap-[8px] min-h-[34px]", "rounded-[4px]", "bsy-multiple-select-item", {
397
- "cursor-pointer": !s,
398
- "cursor-not-allowed bg-transparent": s,
399
- "bsy-select-option--disabled": s,
400
- "bsy-select-option--hoverable": !s,
401
- "bsy-select-option--system": !s && o && !a
402
- }),
403
- children: /* @__PURE__ */ x(d, {
404
- value: n,
405
- disabled: s,
406
- style: { padding: "7px 10px" },
407
- children: c ? c(e, { index: t }, a) : /* @__PURE__ */ x(l, {
408
- text: r,
409
- highlight: i
410
- })
411
- })
412
- }, `${n}-${t}`);
413
- })
414
- })]
415
- })
416
- });
417
- };
418
- $.displayName = "BsyMultipleSelect";
419
- //#endregion
420
- //#region src/components/Select/OptionList/TreeOptionList/TreeOptionList.tsx
421
- var _e = (e) => {
422
- let { options: t, searchValue: n, value: r, onSelect: i, fieldNames: a } = e;
423
- return /* @__PURE__ */ x("div", {
424
- className: "bsy-tree-select",
425
- children: /* @__PURE__ */ x("div", {
426
- className: "bsy-tree-select-nodes",
427
- children: /* @__PURE__ */ x(u, {
428
- data: t,
429
- searchValue: n,
430
- fieldNames: a ? {
431
- title: a.label,
432
- value: a.value,
433
- children: a.children
434
- } : void 0,
435
- selectedKeys: r ? [r] : [],
436
- onSelect: i
437
- })
438
- })
439
- });
440
- }, ve = (e, t) => {
441
- let n = [], r = (e) => {
442
- if (e) for (let i of e) n.push(i), r(i[t.children]);
443
- };
444
- return r(e), n;
445
- }, ye = (e, t, n) => e.reduce((e, r) => {
446
- let i = r[n.children] ? ye(r[n.children], t, n) : void 0;
447
- if (t.has(r[n.value]) || i && i.length > 0) {
448
- let a = t.has(r[n.value]) ? r[n.children] : i;
449
- e.push({
450
- ...r,
451
- children: a
452
- });
453
- }
454
- return e;
455
- }, []), be = (e) => {
456
- let { options: t = [], searchValue: n = "", type: i, filterOption: a, optionRender: o, optionStyle: s, notFoundContent: c } = e, { t: l } = r(), { value: u, setIsOpen: d, setValue: p } = B(), { fieldNames: m } = V(), h = j(() => i === z.TREE ? ve(t, m) : t, [
457
- t,
458
- m,
459
- i
460
- ]), g = j(() => new L(h, {
461
- keys: [m.label],
462
- ignoreLocation: !0,
463
- threshold: .3
464
- }), [h, m]), v = D((e, t) => {
465
- d?.(!1), p(e, t);
466
- }, [d, p]), y = D((e, t) => {
467
- p(e, t);
468
- }, [p]), S = D((e, t) => {
469
- d?.(!1), p(e, t);
470
- }, [d, p]), C = () => {
471
- if (!a || _(n)) return t;
472
- let e = g.search(n), r = new Set(e.map((e) => e.item[m.value]));
473
- return i === z.TREE ? ye(t, r, m) : t.filter((e) => r.has(e[m.value]));
474
- };
475
- return /* @__PURE__ */ x(b, { children: (() => {
476
- let e = {
477
- options: C(),
478
- searchValue: n,
479
- optionStyle: s
480
- };
481
- if (!_(n) && e.options.length === 0) return c === void 0 ? /* @__PURE__ */ x(f, {
482
- className: "bsy-select-empty",
483
- text: l("noDataFound")
484
- }) : c;
485
- switch (i) {
486
- case z.SINGLE: return /* @__PURE__ */ x(Q, {
487
- ...e,
488
- value: u,
489
- fieldNames: m,
490
- onSelect: v,
491
- optionRender: o
492
- });
493
- case z.MULTIPLE: return /* @__PURE__ */ x($, {
494
- ...e,
495
- value: u,
496
- fieldNames: m,
497
- onSelect: y,
498
- optionRender: o
499
- });
500
- case z.TREE: return /* @__PURE__ */ x(_e, {
501
- ...e,
502
- value: u,
503
- fieldNames: m,
504
- onSelect: S
505
- });
506
- default: return null;
507
- }
508
- })() });
509
- }, xe = (e) => {
510
- let { options: t = [], type: n = z.SINGLE, filterOption: i = !0, onSearch: a, showSearch: o, searchPlaceholder: s, onPopupScroll: l, notFoundContent: u, themeStyle: d } = e, { t: m } = r(), { searchValue: h = "", setSearchValue: g } = B(), _ = k(h), v = () => e.fetching ? /* @__PURE__ */ x(f, {
511
- className: "bsy-select-empty",
512
- text: m("dataSearching")
513
- }) : t.length === 0 && !h ? u === void 0 ? /* @__PURE__ */ x(f, {
514
- className: "bsy-select-empty",
515
- text: m("noData")
516
- }) : u : /* @__PURE__ */ x(be, {
517
- searchValue: _,
518
- options: t,
519
- type: n,
520
- filterOption: i,
521
- optionRender: e.optionRender,
522
- optionStyle: e.optionStyle,
523
- notFoundContent: u
524
- }), y = D((e) => {
525
- l?.(e);
526
- }, [l]);
527
- return /* @__PURE__ */ x("div", {
528
- className: "bsy-select-panel",
529
- style: d,
530
- children: /* @__PURE__ */ S(C, { children: [o && /* @__PURE__ */ x(c, {
531
- value: h,
532
- onChange: (e) => g?.(e),
533
- onSearch: a,
534
- searchPlaceholder: s
535
- }), /* @__PURE__ */ x("div", {
536
- className: F({ "pt-[4px]": o }),
537
- children: /* @__PURE__ */ x(p, {
538
- style: { maxHeight: 300 },
539
- onScroll: y,
540
- children: v()
541
- })
542
- })] })
543
- });
544
- };
545
- xe.displayName = "BsySelectPanel";
546
- //#endregion
547
- //#region src/components/Select/style/resolveSelectThemeVars.ts
548
- var Se = (e) => {
549
- if (!e) return {};
550
- let t = {}, n = e.colorPrimary;
551
- return s(t, "--bsy-select-color-bg", e.colorBgContainer), s(t, "--bsy-select-color-bg-elevated", e.colorBgElevated ?? e.colorBgContainer), s(t, "--bsy-select-color-text", e.colorText), s(t, "--bsy-select-color-input-value", e.colorInputValue), s(t, "--bsy-select-color-text-placeholder", e.colorTextPlaceholder), s(t, "--bsy-select-color-icon", e.colorIcon), s(t, "--bsy-select-color-icon-hover", e.colorIconHover ?? n), s(t, "--bsy-select-color-border", e.colorBorder), s(t, "--bsy-select-color-border-hover", e.colorBorderHover ?? n), s(t, "--bsy-select-color-bg-disabled", e.colorBgDisabled), s(t, "--bsy-select-color-text-disabled", e.colorTextDisabled), s(t, "--bsy-select-color-border-disabled", e.colorBorderDisabled), s(t, "--bsy-select-item-hover-bg", e.itemHoverBg), s(t, "--bsy-select-item-active-bg", e.itemActiveBg), s(t, "--bsy-select-item-active-color", e.itemActiveColor ?? n), s(t, "--bsy-select-item-color-disabled", e.itemColorDisabled), s(t, "--bsy-select-item-system-color", e.itemSystemColor), s(t, "--bsy-select-color-highlight", e.colorHighlight ?? n), s(t, "--bsy-select-tag-bg", e.tagBg), s(t, "--bsy-select-tag-color", e.tagColor), s(t, "--bsy-select-tag-bg-disabled", e.tagBgDisabled), s(t, "--bsy-select-tag-color-disabled", e.tagColorDisabled), t;
552
- }, Ce = T((e, i) => {
553
- let { options: s = [], type: c = z.SINGLE, fieldNames: l, clearable: u = !0, disabled: d = !1, placeholder: f, labelRender: p, onOtherInputChange: h, onOpenChange: g, onPopupScroll: _, prefix: v, suffixIcon: y, ghost: b, inputValueStyle: C, tagStyle: w, zIndex: T, zIndexMask: E, otherInputPosition: O = "bottom", getPopupContainer: k, theme: A } = e, P = Number.parseFloat(e.popupMinWidth ?? ""), re = e.popupMatchSelectWidth ?? (Number.isFinite(P) ? P : !0), L = se[c], B = t(T), V = E ?? B - 1, { t: H } = r(), U = ee(), { onChange: W } = e, G = l || ce, [K, fe] = ne(e, {
554
- defaultValue: L === R.SINGLE ? void 0 : [],
555
- defaultValuePropName: "defaultValue",
556
- valuePropName: "value",
557
- trigger: "__NO_CUSTOM_CHANGE__"
558
- }), [pe, me] = N(""), q = M(/* @__PURE__ */ new Map()), [J, Y] = N(() => {
559
- if (L === R.SINGLE) {
560
- let e = s.every((e) => e[G.value] !== K), t = s.find((e) => e.isOther === !0);
561
- return e && t ? K : void 0;
562
- }
563
- }), X = D((e, t) => {
564
- if (fe(e), t) {
565
- let n = /* @__PURE__ */ new Map();
566
- if (Array.isArray(e)) {
567
- let r = Array.isArray(t) ? t : [];
568
- e.forEach((e) => {
569
- let t = r.find((t) => t?.[G.value] === e);
570
- e !== null && t && n.set(e, t);
571
- });
572
- } else e !== null && !Array.isArray(t) && n.set(e, t);
573
- q.current = n;
574
- }
575
- W && W(e, t);
576
- }, [
577
- W,
578
- fe,
579
- G
580
- ]), [Z, { set: he }] = ie(!1), Q = D((e) => {
581
- e !== Z && (he(e), g?.(e));
582
- }, [
583
- he,
584
- g,
585
- Z
586
- ]), { isSelectedOtherOption: $, shouldShowOtherInput: _e } = j(() => {
587
- if (L === R.MULTIPLE) return {
588
- isSelectedOtherOption: !1,
589
- shouldShowOtherInput: !1
590
- };
591
- let e = s.find((e) => e[G.value] === K);
592
- return e ? {
593
- isSelectedOtherOption: e.isOther === !0,
594
- shouldShowOtherInput: e.isOther === !0
595
- } : s.find((e) => e.isOther === !0) && K ? {
596
- isSelectedOtherOption: !0,
597
- shouldShowOtherInput: !0
598
- } : {
599
- isSelectedOtherOption: !1,
600
- shouldShowOtherInput: !1
601
- };
602
- }, [
603
- K,
604
- s,
605
- G,
606
- L
607
- ]), ve = D(() => {
608
- if (K) {
609
- if (L === R.SINGLE) {
610
- let e = s.every((e) => e[G.value] !== K), t = s.find((e) => e.isOther === !0);
611
- if (e && t) return t[G.value];
612
- }
613
- return K;
614
- } else return K;
615
- }, [
616
- K,
617
- s,
618
- G,
619
- L
620
- ]), ye = j(() => ({
621
- value: ve(),
622
- setValue: X,
623
- isOpen: Z,
624
- setIsOpen: Q,
625
- getCachedOptionByValue: (e) => q.current.get(e),
626
- searchValue: pe,
627
- setSearchValue: me
628
- }), [
629
- ve,
630
- X,
631
- Z,
632
- Q,
633
- pe
634
- ]), be = j(() => Se(A), [A]), Ce = j(() => ({
635
- fieldNames: l || ce,
636
- disabled: d,
637
- otherInputPosition: O
638
- }), [
639
- l,
640
- d,
641
- O
642
- ]), we = j(() => ({
643
- isSelectedOtherOption: $,
644
- otherOptionValue: J,
645
- setOtherOptionValue: Y,
646
- onOtherInputChange: h
647
- }), [
648
- $,
649
- J,
650
- Y,
651
- h
652
- ]), { refs: Te, floatingStyles: Ee, getReferenceProps: De, getFloatingProps: Oe, referenceStyle: ke } = m({
653
- isOpen: Z,
654
- close: () => {
655
- Q(!1);
656
- },
657
- showMask: e.showMask,
658
- zIndex: B,
659
- zIndexMask: V,
660
- popupMatchSelectWidth: re,
661
- offset: {
662
- x: 0,
663
- y: 4
664
- }
665
- }), { portalRoot: Ae, portalMountKey: je, handleExitComplete: Me } = o(Z, k), Ne = D(() => {
666
- $ && (Y(""), h?.("")), Q(!1), q.current.clear(), X(L === R.SINGLE ? void 0 : []);
667
- }, [
668
- $,
669
- h,
670
- X,
671
- L,
672
- Q
673
- ]);
674
- return te(i, () => ({
675
- getOtherOptionValue: () => J,
676
- setOtherOptionValue: (e) => {
677
- Y(e), h?.(e);
678
- }
679
- }), [J, h]), /* @__PURE__ */ x(le.Provider, {
680
- value: ye,
681
- children: /* @__PURE__ */ x(ue.Provider, {
682
- value: Ce,
683
- children: /* @__PURE__ */ x(de.Provider, {
684
- value: we,
685
- children: /* @__PURE__ */ S("div", {
686
- className: F("bsy-select-container text-sm", e.className),
687
- style: {
688
- ...be,
689
- ...e.style
690
- },
691
- children: [
692
- /* @__PURE__ */ x("div", {
693
- ref: Te.setReference,
694
- className: F("bsy-select-input-event", e.inputClassName),
695
- ...De(),
696
- style: ke,
697
- onClick: () => {
698
- e.disabled || Q(!Z);
699
- },
700
- role: "combobox",
701
- "aria-expanded": Z,
702
- "aria-haspopup": "listbox",
703
- "aria-controls": U,
704
- "aria-disabled": d,
705
- children: /* @__PURE__ */ x(ge, {
706
- mode: L,
707
- clearable: u,
708
- disabled: d,
709
- placeholder: f || H("select"),
710
- labelRender: p,
711
- options: s,
712
- type: c,
713
- prefix: v,
714
- suffixIcon: y,
715
- ghost: b,
716
- inputValueStyle: C,
717
- tagStyle: w,
718
- onClear: Ne
719
- })
720
- }),
721
- /* @__PURE__ */ S(oe, {
722
- root: Ae,
723
- children: [Z && e.showMask ? /* @__PURE__ */ x("div", {
724
- className: "bsy-select-mask",
725
- style: { zIndex: V }
726
- }) : null, /* @__PURE__ */ x(n, {
727
- zIndex: B,
728
- children: /* @__PURE__ */ x(ae, {
729
- onExitComplete: Me,
730
- children: Z ? /* @__PURE__ */ x(I.div, {
731
- ref: Te.setFloating,
732
- style: {
733
- ...Ee,
734
- zIndex: B
735
- },
736
- ...Oe(),
737
- id: U,
738
- ...a,
739
- children: /* @__PURE__ */ x(xe, {
740
- ...e,
741
- options: s,
742
- onPopupScroll: _,
743
- themeStyle: be
744
- })
745
- }, "bsy-select-panel") : null
746
- })
747
- })]
748
- }, je),
749
- _e && O === "bottom" ? e.otherOptionRender ? e.otherOptionRender(J, s) : /* @__PURE__ */ x("div", {
750
- className: "bsy-select-other-input",
751
- children: /* @__PURE__ */ x("input", {
752
- value: J || "",
753
- onChange: (e) => {
754
- Y(e.target.value), h?.(e.target.value);
755
- },
756
- className: "w-full outline-none border-none",
757
- placeholder: H("context"),
758
- "aria-label": H("otherOptionInput"),
759
- role: "textbox"
760
- })
761
- }) : null
762
- ]
763
- })
764
- })
765
- })
766
- });
767
- });
768
- Ce.displayName = "BsySelect";
769
- //#endregion
770
- export { R as n, z as r, Ce as t };