@baishuyun/ui-base 2.3.2 → 2.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Card/{Card-BE6v4I-A.js → Card-CaKTq_1y.js} +17 -17
- package/dist/Card/index.js +2 -2
- package/dist/CheckBox/CheckBox-Cz6KW9Lw.js +33 -0
- package/dist/CheckBox/{CheckBox--rXaUgMO.js → CheckBox-l__wOnmH.js} +25 -25
- package/dist/CheckBox/index.js +3 -3
- package/dist/ColorPicker/ColorPicker-C1kG_eI-.js +168 -0
- package/dist/ColorPicker/index.js +4 -5
- package/dist/DropDown/DropDown-BAPBTglm.js +162 -0
- package/dist/DropDown/index.js +6 -6
- package/dist/Editor/{Buttons--dMLPuk2.js → Buttons-CsKKYGbV.js} +207 -204
- package/dist/Editor/ToolbarPlugin/Buttons/index.js +12 -13
- package/dist/Editor/index.js +207 -196
- package/dist/Icon/Icon-CTZCSuVg.js +19 -0
- package/dist/Icon/index.js +1 -1
- package/dist/InputTag/{InputTag-B6N5MZA2.js → InputTag-V4UnUnGJ.js} +33 -33
- package/dist/InputTag/index.js +2 -2
- package/dist/Loading/index.js +1 -1
- package/dist/Modal/{Modal-FVJpbEgw.js → Modal-DQ5bptu_.js} +1 -1
- package/dist/Modal/index.js +2 -2
- package/dist/NotFoundContent/index.js +1 -1
- package/dist/Radio/{Radio-dyoBNiKF.js → Radio-CZOrtNyn.js} +25 -25
- package/dist/Radio/index.js +1 -1
- package/dist/Segmented/{Segmented-Dd8glDXI.js → Segmented-DEGgLO-b.js} +15 -15
- package/dist/Segmented/index.js +1 -1
- package/dist/Select/Select-BoNqxIRo.js +729 -0
- package/dist/Select/{SelectInputSearch-CIXBNLFi.js → SelectInputSearch-DMY6Y9B6.js} +2 -2
- package/dist/Select/index.js +10 -10
- package/dist/Tabs/{Tabs-C79GTyGd.js → Tabs-BqT-_eVo.js} +138 -138
- package/dist/Tabs/index.js +4 -5
- package/dist/Tree/index.js +4 -4
- package/dist/Tree/utils/index.js +1 -1
- package/dist/index.js +19 -20
- package/dist/vendors/Tree-nIRgDY2s.js +231 -0
- package/dist/vendors/{color-BPWy9DvT.js → color-CyuNdAfc.js} +2 -2
- package/package.json +4 -2
- package/dist/CheckBox/CheckBox-Db8X-pw9.js +0 -33
- package/dist/ColorPicker/ColorPicker-BBP-4-so.js +0 -168
- package/dist/DropDown/DropDown-CKXi9mXN.js +0 -162
- package/dist/Icon/Icon-DppVOyPK.js +0 -19
- package/dist/Select/Select-Bd2ECrB0.js +0 -729
- package/dist/vendors/Tree-CQR9fvpA.js +0 -231
- package/dist/vendors/clsx-DNOE4Gl8.js +0 -16
- package/dist/vendors/fuse.js-BKtvbTjL.js +0 -877
- package/dist/vendors/lexical-hZliMgDv.js +0 -6439
- package/dist/vendors/lodash-es-Bu9xU1fK.js +0 -334
- package/dist/vendors/simplebar-react-CFlS-Nm9.js +0 -370
- package/dist/vendors/tinycolor2-DToeAEPD.js +0 -726
- /package/dist/Loading/{Loading-Bi5NO-Ky.js → Loading-Dy5A--HK.js} +0 -0
- /package/dist/NotFoundContent/{NotFoundContent-CTPpcZOt.js → NotFoundContent-1-41e1rN.js} +0 -0
- /package/dist/vendors/{animations-C5JKFkz4.js → animations-DvjIfVz9.js} +0 -0
- /package/dist/vendors/{useFloatingPortal-BA6P5GxV.js → useFloatingPortal-W4pliYWU.js} +0 -0
- /package/dist/vendors/{useLocale-BfT0V1j4.js → useLocale-BXnqO-Ju.js} +0 -0
|
@@ -0,0 +1,729 @@
|
|
|
1
|
+
import { t as e } from "../Icon/Icon-CTZCSuVg.js";
|
|
2
|
+
import { t } from "../vendors/useLocale-BXnqO-Ju.js";
|
|
3
|
+
import { n, t as r } from "../vendors/animations-DvjIfVz9.js";
|
|
4
|
+
import { t as i } from "./SelectInputSearch-DMY6Y9B6.js";
|
|
5
|
+
import { n as a, t as o } from "../vendors/Tree-nIRgDY2s.js";
|
|
6
|
+
import { t as s } from "../CheckBox/CheckBox-Cz6KW9Lw.js";
|
|
7
|
+
import { t as c } from "../NotFoundContent/NotFoundContent-1-41e1rN.js";
|
|
8
|
+
import { t as l } from "../vendors/useFloatingPortal-W4pliYWU.js";
|
|
9
|
+
import { first as u, isArray as d, isEmpty as f, isNil as p, noop as m } from "lodash-es";
|
|
10
|
+
import { Fragment as h, jsx as g, jsxs as _ } from "react/jsx-runtime";
|
|
11
|
+
import { Suspense as v, createContext as y, forwardRef as b, memo as x, useCallback as S, useContext as C, useDeferredValue as w, useId as T, useImperativeHandle as E, useLayoutEffect as D, useMemo as O, useRef as k, useState as A } from "react";
|
|
12
|
+
import j from "clsx";
|
|
13
|
+
import { useControllableValue as ee, useHover as te, useToggle as ne } from "ahooks";
|
|
14
|
+
import { Input as M } from "antd";
|
|
15
|
+
import { AnimatePresence as re, motion as N } from "motion/react";
|
|
16
|
+
import { FloatingPortal as ie } from "@floating-ui/react";
|
|
17
|
+
import P from "fuse.js";
|
|
18
|
+
import F from "simplebar-react";
|
|
19
|
+
//#region src/components/Select/constants.ts
|
|
20
|
+
var I = /* @__PURE__ */ function(e) {
|
|
21
|
+
return e.SINGLE = "single", e.MULTIPLE = "multiple", e;
|
|
22
|
+
}({}), L = /* @__PURE__ */ function(e) {
|
|
23
|
+
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;
|
|
24
|
+
}({}), ae = {
|
|
25
|
+
[L.SINGLE]: I.SINGLE,
|
|
26
|
+
[L.TREE]: I.SINGLE,
|
|
27
|
+
[L.MULTIPLE]: I.MULTIPLE,
|
|
28
|
+
[L.TREE_TAGS]: I.MULTIPLE,
|
|
29
|
+
[L.MEMBER]: I.MULTIPLE,
|
|
30
|
+
[L.DEPARTEMENT]: I.MULTIPLE
|
|
31
|
+
}, oe = {
|
|
32
|
+
label: "label",
|
|
33
|
+
value: "value",
|
|
34
|
+
children: "children"
|
|
35
|
+
}, se = y({
|
|
36
|
+
value: void 0,
|
|
37
|
+
setValue: m,
|
|
38
|
+
isOpen: !1,
|
|
39
|
+
setIsOpen: m
|
|
40
|
+
}), ce = y({
|
|
41
|
+
fieldNames: {
|
|
42
|
+
label: "label",
|
|
43
|
+
value: "value",
|
|
44
|
+
children: "children"
|
|
45
|
+
},
|
|
46
|
+
disabled: !1
|
|
47
|
+
}), le = y({}), R = () => {
|
|
48
|
+
let e = C(se);
|
|
49
|
+
if (!e) throw Error("Select.* components must be used within a SelectStateContext provider");
|
|
50
|
+
return e;
|
|
51
|
+
}, z = () => {
|
|
52
|
+
let e = C(ce);
|
|
53
|
+
if (!e) throw Error("Select.* components must be used within a SelectConfigContext provider");
|
|
54
|
+
return e;
|
|
55
|
+
}, B = () => C(le);
|
|
56
|
+
//#endregion
|
|
57
|
+
//#region src/components/Select/utils/fieldAccessor.ts
|
|
58
|
+
function V(e) {
|
|
59
|
+
let t = e;
|
|
60
|
+
return {
|
|
61
|
+
getLabel: (e) => e[t.label],
|
|
62
|
+
getValue: (e) => e[t.value],
|
|
63
|
+
getChildren: (e) => {
|
|
64
|
+
if (t.children) return e[t.children];
|
|
65
|
+
},
|
|
66
|
+
normalizeOption: (e) => ({
|
|
67
|
+
...e,
|
|
68
|
+
label: e[t.label],
|
|
69
|
+
value: e[t.value],
|
|
70
|
+
children: t.children ? e[t.children] : void 0
|
|
71
|
+
}),
|
|
72
|
+
getFieldNames: () => t
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
//#endregion
|
|
76
|
+
//#region src/components/Select/SelectInput/SelectSingleInput/SelectSingleInput.tsx
|
|
77
|
+
var H = x((e) => {
|
|
78
|
+
let { value: t, inputValueStyle: n } = e, { fieldNames: r, otherInputPosition: i } = z(), { isSelectedOtherOption: a, otherOptionValue: o } = B(), s = V(r), c = u(t), l;
|
|
79
|
+
return l = a && o && i === "inline" ? o : e.labelRender && c ? e.labelRender(c) : c ? s.getLabel(c) : "", /* @__PURE__ */ g("div", {
|
|
80
|
+
className: j("bsy-select-input-container__input-value overflow-hidden"),
|
|
81
|
+
style: n,
|
|
82
|
+
children: /* @__PURE__ */ g("div", {
|
|
83
|
+
className: "bsy-select-input-container__input-value-text",
|
|
84
|
+
children: l
|
|
85
|
+
})
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
H.displayName = "BsySelectSingleInput";
|
|
89
|
+
//#endregion
|
|
90
|
+
//#region src/components/Select/SelectInput/SelectMultipleInput/OptionTag/option-tag.module.scss
|
|
91
|
+
var U = {
|
|
92
|
+
"bsy-input-tag__container": "_bsy-input-tag__container_18guu_1",
|
|
93
|
+
"bsy-input-tag__item": "_bsy-input-tag__item_18guu_7",
|
|
94
|
+
"bsy-input-tag__item--disabled": "_bsy-input-tag__item--disabled_18guu_20",
|
|
95
|
+
"bsy-input-tag__item-icon": "_bsy-input-tag__item-icon_18guu_24"
|
|
96
|
+
}, W = b(({ children: e, style: t, disabled: n }, r) => /* @__PURE__ */ g("div", {
|
|
97
|
+
"data-bsy-input-tag": "true",
|
|
98
|
+
className: j({
|
|
99
|
+
[U["bsy-input-tag__item"]]: !0,
|
|
100
|
+
[U["bsy-input-tag__item--disabled"]]: n
|
|
101
|
+
}),
|
|
102
|
+
ref: r,
|
|
103
|
+
style: t,
|
|
104
|
+
children: e
|
|
105
|
+
}));
|
|
106
|
+
W.Container = (e) => /* @__PURE__ */ g("div", {
|
|
107
|
+
className: j(U["bsy-input-tag__container"]),
|
|
108
|
+
children: e.children
|
|
109
|
+
}), W.displayName = "BsyOptionTag";
|
|
110
|
+
//#endregion
|
|
111
|
+
//#region src/components/Select/SelectInput/SelectMultipleInput/select-multiple-input.module.scss
|
|
112
|
+
var G = "_select_multiple_input__container_8pd2n_1", K = "_select_multiple_input__measurement_layer_8pd2n_6", q = "_select_multiple_input__close_btn_8pd2n_14", J = "_select_multiple_input__tag_content_8pd2n_24", Y = {
|
|
113
|
+
select_multiple_input__container: G,
|
|
114
|
+
select_multiple_input__measurement_layer: K,
|
|
115
|
+
select_multiple_input__close_btn: q,
|
|
116
|
+
"select_multiple_input__close_btn--disabled": "_select_multiple_input__close_btn--disabled_8pd2n_21",
|
|
117
|
+
select_multiple_input__tag_content: J
|
|
118
|
+
}, X = 4, Z = x((t) => {
|
|
119
|
+
let { value: n, labelRender: r, tagStyle: i } = t, { setValue: a } = R(), { fieldNames: o, disabled: s } = z(), c = V(o), l = n?.length ?? 0, [u, d] = A(0), f = k(null), p = k(null);
|
|
120
|
+
D(() => {
|
|
121
|
+
if (!f.current) return;
|
|
122
|
+
let e = new ResizeObserver((e) => {
|
|
123
|
+
let t = e[0];
|
|
124
|
+
if (!t) return;
|
|
125
|
+
let r = t.contentRect.width, i = t.target.querySelectorAll(".measure-list [data-bsy-input-tag=\"true\"]");
|
|
126
|
+
if (i.length === 0) {
|
|
127
|
+
d(n?.length ?? 0);
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
let a = p.current?.offsetWidth || 65, o = 0, s = 0;
|
|
131
|
+
for (let e = 0; e < i.length; e++) {
|
|
132
|
+
let t = i[e].clientWidth + X, n = e < l - 1 ? a : 0;
|
|
133
|
+
if (o + t + n <= r) o += t, s = e + 1;
|
|
134
|
+
else break;
|
|
135
|
+
}
|
|
136
|
+
s === 0 && l === 1 && (s = 1), u !== s && d(s);
|
|
137
|
+
});
|
|
138
|
+
return e.observe(f.current), () => e.disconnect();
|
|
139
|
+
}, [
|
|
140
|
+
l,
|
|
141
|
+
u,
|
|
142
|
+
n.length
|
|
143
|
+
]);
|
|
144
|
+
let m = l - u, h = w(m), v = /* @__PURE__ */ g("div", {
|
|
145
|
+
className: `${Y.select_multiple_input__measurement_layer} measure-list`,
|
|
146
|
+
children: /* @__PURE__ */ _(W.Container, { children: [n?.map((t, n) => {
|
|
147
|
+
let a = (t) => /* @__PURE__ */ g("div", {
|
|
148
|
+
style: t,
|
|
149
|
+
className: "bsy-input-tag__item-icon cursor-pointer",
|
|
150
|
+
children: /* @__PURE__ */ g(e, {
|
|
151
|
+
name: "close",
|
|
152
|
+
style: { fontSize: 12 },
|
|
153
|
+
className: Y.select_multiple_input__close_btn
|
|
154
|
+
})
|
|
155
|
+
});
|
|
156
|
+
return /* @__PURE__ */ _(W, {
|
|
157
|
+
style: i,
|
|
158
|
+
children: [r && r(t, a), !r && /* @__PURE__ */ _("div", {
|
|
159
|
+
className: Y.select_multiple_input__tag_content,
|
|
160
|
+
children: [/* @__PURE__ */ g("span", { children: c.getLabel(t) }), /* @__PURE__ */ g(a, {})]
|
|
161
|
+
})]
|
|
162
|
+
}, n);
|
|
163
|
+
}), u < l && h > 0 && /* @__PURE__ */ _(W, {
|
|
164
|
+
ref: p,
|
|
165
|
+
children: [`+ ${m}`, /* @__PURE__ */ g("span", {
|
|
166
|
+
className: "text-[#666]",
|
|
167
|
+
children: "..."
|
|
168
|
+
})]
|
|
169
|
+
})] })
|
|
170
|
+
}), y = (e) => {
|
|
171
|
+
if (s) return;
|
|
172
|
+
let t = n.filter((t) => c.getValue(t) !== c.getValue(e));
|
|
173
|
+
a(t.map((e) => c.getValue(e)), t);
|
|
174
|
+
};
|
|
175
|
+
return /* @__PURE__ */ _("div", {
|
|
176
|
+
ref: f,
|
|
177
|
+
className: j("bsy-select-input-container__input-value", Y.select_multiple_input__container, "multiple"),
|
|
178
|
+
children: [v, /* @__PURE__ */ _(W.Container, { children: [n?.slice(0, u).map((t, n) => {
|
|
179
|
+
let a = (n) => /* @__PURE__ */ g("div", {
|
|
180
|
+
style: n,
|
|
181
|
+
className: j("bsy-input-tag__item-icon", {
|
|
182
|
+
[Y.select_multiple_input__close_btn]: !s,
|
|
183
|
+
[Y.select_multiple_input__close_btn + "--disabled"]: s
|
|
184
|
+
}),
|
|
185
|
+
onClick: (e) => {
|
|
186
|
+
e.stopPropagation(), y(t);
|
|
187
|
+
},
|
|
188
|
+
children: /* @__PURE__ */ g(e, {
|
|
189
|
+
name: "close",
|
|
190
|
+
style: { fontSize: 12 }
|
|
191
|
+
})
|
|
192
|
+
});
|
|
193
|
+
return /* @__PURE__ */ _(W, {
|
|
194
|
+
style: {
|
|
195
|
+
...i,
|
|
196
|
+
flexShrink: u === 1 ? 1 : 0
|
|
197
|
+
},
|
|
198
|
+
disabled: s,
|
|
199
|
+
children: [r && r(t, a), !r && /* @__PURE__ */ _("div", {
|
|
200
|
+
className: Y.select_multiple_input__tag_content,
|
|
201
|
+
children: [/* @__PURE__ */ g("span", {
|
|
202
|
+
className: "truncate",
|
|
203
|
+
children: c.getLabel(t)
|
|
204
|
+
}), /* @__PURE__ */ g(a, {})]
|
|
205
|
+
})]
|
|
206
|
+
}, n);
|
|
207
|
+
}), u < l && h > 0 && /* @__PURE__ */ _(W, {
|
|
208
|
+
ref: p,
|
|
209
|
+
children: [`+ ${m} `, /* @__PURE__ */ g("span", {
|
|
210
|
+
className: "text-[#666]",
|
|
211
|
+
children: "..."
|
|
212
|
+
})]
|
|
213
|
+
})] })]
|
|
214
|
+
});
|
|
215
|
+
});
|
|
216
|
+
Z.displayName = "BsySelectMultipleInput";
|
|
217
|
+
//#endregion
|
|
218
|
+
//#region src/components/Select/utils/tree.ts
|
|
219
|
+
var Q = (e, t) => {
|
|
220
|
+
let n = [], r = (e) => {
|
|
221
|
+
e.forEach((e) => {
|
|
222
|
+
let { [t.children]: i, ...a } = e;
|
|
223
|
+
n.push(a), i && r(i);
|
|
224
|
+
});
|
|
225
|
+
};
|
|
226
|
+
return r(e), n;
|
|
227
|
+
}, ue = ({ placeholder: t, mode: n, clearable: i, onClear: a, disabled: o = !1, labelRender: s, options: c = [], type: l, prefix: u, suffixIcon: f, ghost: m, inputValueStyle: v, tagStyle: y }) => {
|
|
228
|
+
let b = k(null), x = te(o ? null : b), { isOpen: S, value: C, getCachedOptionByValue: w } = R(), { fieldNames: T } = z(), E = O(() => {
|
|
229
|
+
if (p(C)) return [];
|
|
230
|
+
let e = d(C) ? C : [C];
|
|
231
|
+
if (l === L.TREE) {
|
|
232
|
+
let t = V(T), n = Q(c, T);
|
|
233
|
+
return e.map((e) => n.find((n) => t.getValue(n) === e) || w?.(e)).filter((e) => !!e);
|
|
234
|
+
}
|
|
235
|
+
return e.map((e) => c.find((t) => t[T.value] === e) || w?.(e)).filter((e) => !!e);
|
|
236
|
+
}, [
|
|
237
|
+
C,
|
|
238
|
+
c,
|
|
239
|
+
l,
|
|
240
|
+
T,
|
|
241
|
+
w
|
|
242
|
+
]);
|
|
243
|
+
return /* @__PURE__ */ g("div", {
|
|
244
|
+
className: j("bsy-select-input-container", {
|
|
245
|
+
disabled: o,
|
|
246
|
+
multiple: n === I.MULTIPLE,
|
|
247
|
+
active: S,
|
|
248
|
+
"ghost-style": m
|
|
249
|
+
}),
|
|
250
|
+
ref: b,
|
|
251
|
+
children: /* @__PURE__ */ _("div", {
|
|
252
|
+
className: j("bsy-select-input-container-input"),
|
|
253
|
+
children: [
|
|
254
|
+
u && /* @__PURE__ */ g("div", {
|
|
255
|
+
className: "bsy-select-input-container-input-prefix",
|
|
256
|
+
children: u
|
|
257
|
+
}),
|
|
258
|
+
E?.length ? /* @__PURE__ */ _(h, { children: [n === I.SINGLE && /* @__PURE__ */ g(H, {
|
|
259
|
+
value: E,
|
|
260
|
+
labelRender: s,
|
|
261
|
+
inputValueStyle: v
|
|
262
|
+
}), n === I.MULTIPLE && /* @__PURE__ */ g(Z, {
|
|
263
|
+
value: E,
|
|
264
|
+
labelRender: s,
|
|
265
|
+
tagStyle: y
|
|
266
|
+
})] }) : /* @__PURE__ */ g("div", {
|
|
267
|
+
className: "bsy-select-input-container__input-value-placeholder truncate",
|
|
268
|
+
children: t
|
|
269
|
+
}),
|
|
270
|
+
/* @__PURE__ */ g("div", {
|
|
271
|
+
className: j("bsy-select-input-container__icon"),
|
|
272
|
+
children: /* @__PURE__ */ g(re, {
|
|
273
|
+
mode: "wait",
|
|
274
|
+
children: E?.length && i && x ? /* @__PURE__ */ g(N.div, {
|
|
275
|
+
...r,
|
|
276
|
+
children: /* @__PURE__ */ g(e, {
|
|
277
|
+
name: "cancel",
|
|
278
|
+
className: "icon hover:text-[#0265ff] text-[#666]",
|
|
279
|
+
role: "button",
|
|
280
|
+
"aria-label": "clear",
|
|
281
|
+
onClick: (e) => {
|
|
282
|
+
e.stopPropagation(), a?.();
|
|
283
|
+
}
|
|
284
|
+
})
|
|
285
|
+
}, "cancel") : /* @__PURE__ */ g(N.div, {
|
|
286
|
+
...r,
|
|
287
|
+
children: f ? f(S, o) : /* @__PURE__ */ g(e, {
|
|
288
|
+
name: "arrow-down",
|
|
289
|
+
className: j("icon", {
|
|
290
|
+
active: S,
|
|
291
|
+
"text-[#c2c2c2]": o,
|
|
292
|
+
"text-[#666]": !o
|
|
293
|
+
})
|
|
294
|
+
})
|
|
295
|
+
}, "arrow")
|
|
296
|
+
})
|
|
297
|
+
})
|
|
298
|
+
]
|
|
299
|
+
})
|
|
300
|
+
});
|
|
301
|
+
};
|
|
302
|
+
ue.displayName = "BsySelectInput";
|
|
303
|
+
//#endregion
|
|
304
|
+
//#region src/components/Select/OptionList/SingleOptionList/SingleOptionList.tsx
|
|
305
|
+
var $ = x((e) => {
|
|
306
|
+
let { options: t, value: n, onSelect: r, searchValue: i = "", fieldNames: o, optionRender: s, optionStyle: c } = e, { otherInputPosition: l } = z(), { otherOptionValue: u, setOtherOptionValue: d, onOtherInputChange: f, isSelectedOtherOption: p = !1 } = B(), m = k(null), h = V(o);
|
|
307
|
+
return /* @__PURE__ */ g("ul", {
|
|
308
|
+
role: "listbox",
|
|
309
|
+
children: t.map((e, t) => {
|
|
310
|
+
let o = h.getValue(e), v = h.getLabel(e), y = e.systemField || !1, b = e.isOther === !0, x = b && l === "inline" && v.length > 6 ? v.slice(0, 6) + "..." : v, S = b ? p : o === n;
|
|
311
|
+
return /* @__PURE__ */ _("li", {
|
|
312
|
+
role: "option",
|
|
313
|
+
"aria-selected": S,
|
|
314
|
+
className: j("cursor-pointer rounded-[4px] py-[7px] px-[10px] min-h-[34px]", {
|
|
315
|
+
"hover:bg-[#f3f3f3]": !S,
|
|
316
|
+
"text-[#4d609f]": y && !S,
|
|
317
|
+
"text-[#0265ff] bg-[#f0f6ff]": S,
|
|
318
|
+
"flex items-center": b && l === "inline"
|
|
319
|
+
}),
|
|
320
|
+
style: c,
|
|
321
|
+
onClick: () => {
|
|
322
|
+
r(o, e);
|
|
323
|
+
},
|
|
324
|
+
children: [/* @__PURE__ */ g("div", {
|
|
325
|
+
title: v,
|
|
326
|
+
children: s ? s(e, { index: t }, S) : /* @__PURE__ */ g(a, {
|
|
327
|
+
text: x,
|
|
328
|
+
highlight: i
|
|
329
|
+
})
|
|
330
|
+
}), b && l === "inline" && /* @__PURE__ */ g("div", {
|
|
331
|
+
className: "ml-2 flex-1",
|
|
332
|
+
onClick: (e) => e.stopPropagation(),
|
|
333
|
+
style: { minWidth: "146px" },
|
|
334
|
+
children: /* @__PURE__ */ g(M, {
|
|
335
|
+
ref: m,
|
|
336
|
+
value: u,
|
|
337
|
+
onChange: (e) => {
|
|
338
|
+
let t = e.target.value;
|
|
339
|
+
d?.(t), f?.(t);
|
|
340
|
+
},
|
|
341
|
+
onPressEnter: () => {
|
|
342
|
+
u && r(o, e);
|
|
343
|
+
},
|
|
344
|
+
onBlur: () => {
|
|
345
|
+
u && r(o, e);
|
|
346
|
+
},
|
|
347
|
+
placeholder: "请输入内容"
|
|
348
|
+
})
|
|
349
|
+
})]
|
|
350
|
+
}, `${o}-${t}`);
|
|
351
|
+
})
|
|
352
|
+
});
|
|
353
|
+
});
|
|
354
|
+
$.displayName = "BsySingleSelect";
|
|
355
|
+
//#endregion
|
|
356
|
+
//#region src/components/Select/OptionList/MultOptionList/MultOptionList.tsx
|
|
357
|
+
var de = (e) => {
|
|
358
|
+
let { t: n } = t(), { options: r, searchValue: i = "", value: o, onSelect: c, fieldNames: l, optionRender: u } = e, d = V(l), f = o || [], p = r.filter((e) => !e.isOther), m = p.length > 0 && p.every((e) => f.includes(d.getValue(e)));
|
|
359
|
+
return /* @__PURE__ */ g("div", {
|
|
360
|
+
className: "bsy-multiple-select",
|
|
361
|
+
children: /* @__PURE__ */ _("ul", {
|
|
362
|
+
className: "bsy-multiple-select-list",
|
|
363
|
+
children: [/* @__PURE__ */ g("li", {
|
|
364
|
+
className: j("flex items-center gap-[8px]", "cursor-pointer hover:bg-[#f3f3f3] rounded-[4px] min-h-[34px]", "bsy-multiple-select-item"),
|
|
365
|
+
children: /* @__PURE__ */ g(s, {
|
|
366
|
+
checked: m,
|
|
367
|
+
onChange: () => {
|
|
368
|
+
c(m ? [] : p.map((e) => d.getValue(e)), m ? [] : p.filter((e) => f.includes(d.getValue(e))));
|
|
369
|
+
},
|
|
370
|
+
indeterminate: f.length > 0 && f.length < p.length,
|
|
371
|
+
style: { padding: "7px 10px" },
|
|
372
|
+
children: /* @__PURE__ */ g("span", {
|
|
373
|
+
className: "font-bold text-[#0265ff]",
|
|
374
|
+
children: n(i ? "allSelectedBySearch" : "allSelect")
|
|
375
|
+
})
|
|
376
|
+
})
|
|
377
|
+
}), /* @__PURE__ */ g(s.Group, {
|
|
378
|
+
value: f,
|
|
379
|
+
onChange: (e) => {
|
|
380
|
+
c(e, p.filter((t) => e.includes(d.getValue(t))));
|
|
381
|
+
},
|
|
382
|
+
children: p.map((e, t) => {
|
|
383
|
+
let n = d.getValue(e), r = d.getLabel(e), o = f.includes(n), c = e.systemField || !1;
|
|
384
|
+
return /* @__PURE__ */ g("li", {
|
|
385
|
+
className: j("flex items-center gap-[8px] min-h-[34px]", "cursor-pointer rounded-[4px]", "bsy-multiple-select-item", {
|
|
386
|
+
"hover:bg-[#f3f3f3]": !0,
|
|
387
|
+
"text-[#0265ff]": o,
|
|
388
|
+
"text-[#4d609f]": c && !o
|
|
389
|
+
}),
|
|
390
|
+
children: /* @__PURE__ */ g(s, {
|
|
391
|
+
value: n,
|
|
392
|
+
style: { padding: "7px 10px" },
|
|
393
|
+
children: u ? u(e, { index: t }, o) : /* @__PURE__ */ g(a, {
|
|
394
|
+
text: r,
|
|
395
|
+
highlight: i
|
|
396
|
+
})
|
|
397
|
+
})
|
|
398
|
+
}, `${n}-${t}`);
|
|
399
|
+
})
|
|
400
|
+
})]
|
|
401
|
+
})
|
|
402
|
+
});
|
|
403
|
+
};
|
|
404
|
+
de.displayName = "BsyMultipleSelect";
|
|
405
|
+
//#endregion
|
|
406
|
+
//#region src/components/Select/OptionList/TreeOptionList/TreeOptionList.tsx
|
|
407
|
+
var fe = (e) => {
|
|
408
|
+
let { options: t, searchValue: n, value: r, onSelect: i, fieldNames: a } = e;
|
|
409
|
+
return /* @__PURE__ */ g("div", {
|
|
410
|
+
className: "bsy-tree-select",
|
|
411
|
+
children: /* @__PURE__ */ g("div", {
|
|
412
|
+
className: "bsy-tree-select-nodes",
|
|
413
|
+
children: /* @__PURE__ */ g(o, {
|
|
414
|
+
data: t,
|
|
415
|
+
searchValue: n,
|
|
416
|
+
fieldNames: a ? {
|
|
417
|
+
title: a.label,
|
|
418
|
+
value: a.value,
|
|
419
|
+
children: a.children
|
|
420
|
+
} : void 0,
|
|
421
|
+
selectedKeys: r ? [r] : [],
|
|
422
|
+
onSelect: i
|
|
423
|
+
})
|
|
424
|
+
})
|
|
425
|
+
});
|
|
426
|
+
}, pe = (e, t) => {
|
|
427
|
+
let n = [], r = (e) => {
|
|
428
|
+
if (e) for (let i of e) n.push(i), r(i[t.children]);
|
|
429
|
+
};
|
|
430
|
+
return r(e), n;
|
|
431
|
+
}, me = (e, t, n) => e.reduce((e, r) => {
|
|
432
|
+
let i = r[n.children] ? me(r[n.children], t, n) : void 0;
|
|
433
|
+
if (t.has(r[n.value]) || i && i.length > 0) {
|
|
434
|
+
let a = t.has(r[n.value]) ? r[n.children] : i;
|
|
435
|
+
e.push({
|
|
436
|
+
...r,
|
|
437
|
+
children: a
|
|
438
|
+
});
|
|
439
|
+
}
|
|
440
|
+
return e;
|
|
441
|
+
}, []), he = (e) => {
|
|
442
|
+
let { options: n = [], searchValue: r = "", type: i, filterOption: a, optionRender: o, optionStyle: s } = e, { t: l } = t(), { value: u, setIsOpen: d, setValue: p } = R(), { fieldNames: m } = z(), _ = O(() => i === L.TREE ? pe(n, m) : n, [
|
|
443
|
+
n,
|
|
444
|
+
m,
|
|
445
|
+
i
|
|
446
|
+
]), v = O(() => new P(_, {
|
|
447
|
+
keys: [m.label],
|
|
448
|
+
ignoreLocation: !0,
|
|
449
|
+
threshold: .3
|
|
450
|
+
}), [_, m]), y = S((e, t) => {
|
|
451
|
+
d?.(!1), p(e, t);
|
|
452
|
+
}, [d, p]), b = S((e, t) => {
|
|
453
|
+
p(e, t);
|
|
454
|
+
}, [p]), x = S((e, t) => {
|
|
455
|
+
d?.(!1), p(e, t);
|
|
456
|
+
}, [d, p]), C = () => {
|
|
457
|
+
if (!a || f(r)) return n;
|
|
458
|
+
let e = v.search(r), t = new Set(e.map((e) => e.item[m.value]));
|
|
459
|
+
return i === L.TREE ? me(n, t, m) : n.filter((e) => t.has(e[m.value]));
|
|
460
|
+
};
|
|
461
|
+
return /* @__PURE__ */ g(h, { children: (() => {
|
|
462
|
+
let e = {
|
|
463
|
+
options: C(),
|
|
464
|
+
searchValue: r,
|
|
465
|
+
optionStyle: s
|
|
466
|
+
};
|
|
467
|
+
if (!f(r) && e.options.length === 0) return /* @__PURE__ */ g(c, { text: l("noDataFound") });
|
|
468
|
+
switch (i) {
|
|
469
|
+
case L.SINGLE: return /* @__PURE__ */ g($, {
|
|
470
|
+
...e,
|
|
471
|
+
value: u,
|
|
472
|
+
fieldNames: m,
|
|
473
|
+
onSelect: y,
|
|
474
|
+
optionRender: o
|
|
475
|
+
});
|
|
476
|
+
case L.MULTIPLE: return /* @__PURE__ */ g(de, {
|
|
477
|
+
...e,
|
|
478
|
+
value: u,
|
|
479
|
+
fieldNames: m,
|
|
480
|
+
onSelect: b,
|
|
481
|
+
optionRender: o
|
|
482
|
+
});
|
|
483
|
+
case L.TREE: return /* @__PURE__ */ g(fe, {
|
|
484
|
+
...e,
|
|
485
|
+
value: u,
|
|
486
|
+
fieldNames: m,
|
|
487
|
+
onSelect: x
|
|
488
|
+
});
|
|
489
|
+
default: return null;
|
|
490
|
+
}
|
|
491
|
+
})() });
|
|
492
|
+
}, ge = (e) => {
|
|
493
|
+
let { options: r = [], type: a = L.SINGLE, filterOption: o = !0, onSearch: s, showSearch: l, searchPlaceholder: u, onPopupScroll: d } = e, { t: f } = t(), { searchValue: p = "", setSearchValue: m } = R(), h = w(p), y = (e) => {
|
|
494
|
+
m?.(e), s?.(e);
|
|
495
|
+
}, b = () => e.fetching ? /* @__PURE__ */ g(c, { text: f("dataSearching") }) : r.length === 0 && !p ? /* @__PURE__ */ g(c, { text: f("noData") }) : /* @__PURE__ */ g(he, {
|
|
496
|
+
searchValue: h,
|
|
497
|
+
options: r,
|
|
498
|
+
type: a,
|
|
499
|
+
filterOption: o,
|
|
500
|
+
optionRender: e.optionRender,
|
|
501
|
+
optionStyle: e.optionStyle
|
|
502
|
+
}), x = (e) => {
|
|
503
|
+
let t = e?.currentTarget ? e : { currentTarget: e };
|
|
504
|
+
d?.(t);
|
|
505
|
+
};
|
|
506
|
+
return /* @__PURE__ */ g(N.div, {
|
|
507
|
+
...n,
|
|
508
|
+
children: /* @__PURE__ */ g("div", {
|
|
509
|
+
className: "bsy-select-panel",
|
|
510
|
+
children: /* @__PURE__ */ _(v, { children: [l && /* @__PURE__ */ g(i, {
|
|
511
|
+
value: p,
|
|
512
|
+
onChange: y,
|
|
513
|
+
searchPlaceholder: u
|
|
514
|
+
}), /* @__PURE__ */ g("div", {
|
|
515
|
+
className: j({ "pt-[4px]": l }),
|
|
516
|
+
children: /* @__PURE__ */ g(F, {
|
|
517
|
+
style: { maxHeight: 300 },
|
|
518
|
+
onScroll: x,
|
|
519
|
+
children: b()
|
|
520
|
+
})
|
|
521
|
+
})] })
|
|
522
|
+
})
|
|
523
|
+
});
|
|
524
|
+
};
|
|
525
|
+
ge.displayName = "BsySelectPanel";
|
|
526
|
+
//#endregion
|
|
527
|
+
//#region src/components/Select/Select.tsx
|
|
528
|
+
var _e = b((e, n) => {
|
|
529
|
+
let { options: r = [], type: i = L.SINGLE, fieldNames: a, clearable: o = !0, disabled: s = !1, placeholder: c, labelRender: u, onOtherInputChange: d, onOpenChange: f, onPopupScroll: p, prefix: m, suffixIcon: v, ghost: y, inputValueStyle: b, tagStyle: x, zIndex: C = 1101, zIndexMask: w = 1100, otherInputPosition: D = "bottom", popupMinWidth: te } = e, M = ae[i], { t: N } = t(), P = T(), { onChange: F } = e, R = a || oe, [z, B] = ee(e, {
|
|
530
|
+
defaultValue: M === I.SINGLE ? void 0 : [],
|
|
531
|
+
defaultValuePropName: "defaultValue",
|
|
532
|
+
valuePropName: "value",
|
|
533
|
+
trigger: "__NO_CUSTOM_CHANGE__"
|
|
534
|
+
}), [V, H] = A(""), U = k(/* @__PURE__ */ new Map()), [W, G] = A(() => {
|
|
535
|
+
if (M === I.SINGLE) {
|
|
536
|
+
let e = r.every((e) => e[R.value] !== z), t = r.find((e) => e.isOther === !0);
|
|
537
|
+
return e && t ? z : void 0;
|
|
538
|
+
}
|
|
539
|
+
}), K = S((e, t) => {
|
|
540
|
+
if (B(e), t) {
|
|
541
|
+
let n = /* @__PURE__ */ new Map();
|
|
542
|
+
if (Array.isArray(e)) {
|
|
543
|
+
let r = Array.isArray(t) ? t : [];
|
|
544
|
+
e.forEach((e) => {
|
|
545
|
+
let t = r.find((t) => t?.[R.value] === e);
|
|
546
|
+
e !== null && t && n.set(e, t);
|
|
547
|
+
});
|
|
548
|
+
} else e !== null && !Array.isArray(t) && n.set(e, t);
|
|
549
|
+
U.current = n;
|
|
550
|
+
}
|
|
551
|
+
F && F(e, t);
|
|
552
|
+
}, [
|
|
553
|
+
F,
|
|
554
|
+
B,
|
|
555
|
+
R
|
|
556
|
+
]), [q, { set: J }] = ne(!1), Y = S((e) => {
|
|
557
|
+
e !== q && (J(e), f?.(e));
|
|
558
|
+
}, [
|
|
559
|
+
J,
|
|
560
|
+
f,
|
|
561
|
+
q
|
|
562
|
+
]), { isSelectedOtherOption: X, shouldShowOtherInput: Z } = O(() => {
|
|
563
|
+
if (M === I.MULTIPLE) return {
|
|
564
|
+
isSelectedOtherOption: !1,
|
|
565
|
+
shouldShowOtherInput: !1
|
|
566
|
+
};
|
|
567
|
+
let e = r.find((e) => e[R.value] === z);
|
|
568
|
+
return e ? {
|
|
569
|
+
isSelectedOtherOption: e.isOther === !0,
|
|
570
|
+
shouldShowOtherInput: e.isOther === !0
|
|
571
|
+
} : r.find((e) => e.isOther === !0) && z ? {
|
|
572
|
+
isSelectedOtherOption: !0,
|
|
573
|
+
shouldShowOtherInput: !0
|
|
574
|
+
} : {
|
|
575
|
+
isSelectedOtherOption: !1,
|
|
576
|
+
shouldShowOtherInput: !1
|
|
577
|
+
};
|
|
578
|
+
}, [
|
|
579
|
+
z,
|
|
580
|
+
r,
|
|
581
|
+
R,
|
|
582
|
+
M
|
|
583
|
+
]), Q = S(() => {
|
|
584
|
+
if (z) {
|
|
585
|
+
if (M === I.SINGLE) {
|
|
586
|
+
let e = r.every((e) => e[R.value] !== z), t = r.find((e) => e.isOther === !0);
|
|
587
|
+
if (e && t) return t[R.value];
|
|
588
|
+
}
|
|
589
|
+
return z;
|
|
590
|
+
} else return z;
|
|
591
|
+
}, [
|
|
592
|
+
z,
|
|
593
|
+
r,
|
|
594
|
+
R,
|
|
595
|
+
M
|
|
596
|
+
]), $ = O(() => ({
|
|
597
|
+
value: Q(),
|
|
598
|
+
setValue: K,
|
|
599
|
+
isOpen: q,
|
|
600
|
+
setIsOpen: Y,
|
|
601
|
+
getCachedOptionByValue: (e) => U.current.get(e),
|
|
602
|
+
searchValue: V,
|
|
603
|
+
setSearchValue: H
|
|
604
|
+
}), [
|
|
605
|
+
Q,
|
|
606
|
+
K,
|
|
607
|
+
q,
|
|
608
|
+
Y,
|
|
609
|
+
V
|
|
610
|
+
]), de = O(() => ({
|
|
611
|
+
fieldNames: a || oe,
|
|
612
|
+
disabled: s,
|
|
613
|
+
otherInputPosition: D
|
|
614
|
+
}), [
|
|
615
|
+
a,
|
|
616
|
+
s,
|
|
617
|
+
D
|
|
618
|
+
]), fe = O(() => ({
|
|
619
|
+
isSelectedOtherOption: X,
|
|
620
|
+
otherOptionValue: W,
|
|
621
|
+
setOtherOptionValue: G,
|
|
622
|
+
onOtherInputChange: d
|
|
623
|
+
}), [
|
|
624
|
+
X,
|
|
625
|
+
W,
|
|
626
|
+
G,
|
|
627
|
+
d
|
|
628
|
+
]), { refs: pe, floatingStyles: me, getReferenceProps: he, getFloatingProps: _e, referenceStyle: ve } = l({
|
|
629
|
+
isOpen: q,
|
|
630
|
+
close: () => {
|
|
631
|
+
Y(!1);
|
|
632
|
+
},
|
|
633
|
+
showMask: e.showMask,
|
|
634
|
+
zIndex: C,
|
|
635
|
+
zIndexMask: w,
|
|
636
|
+
popupMinWidth: te,
|
|
637
|
+
offset: {
|
|
638
|
+
x: 0,
|
|
639
|
+
y: 4
|
|
640
|
+
}
|
|
641
|
+
}), ye = S(() => {
|
|
642
|
+
X && (G(""), d?.("")), Y(!1), U.current.clear(), K(M === I.SINGLE ? void 0 : []);
|
|
643
|
+
}, [
|
|
644
|
+
X,
|
|
645
|
+
d,
|
|
646
|
+
K,
|
|
647
|
+
M,
|
|
648
|
+
Y
|
|
649
|
+
]);
|
|
650
|
+
return E(n, () => ({
|
|
651
|
+
getOtherOptionValue: () => W,
|
|
652
|
+
setOtherOptionValue: (e) => {
|
|
653
|
+
G(e), d?.(e);
|
|
654
|
+
}
|
|
655
|
+
}), [W, d]), /* @__PURE__ */ g(se.Provider, {
|
|
656
|
+
value: $,
|
|
657
|
+
children: /* @__PURE__ */ g(ce.Provider, {
|
|
658
|
+
value: de,
|
|
659
|
+
children: /* @__PURE__ */ g(le.Provider, {
|
|
660
|
+
value: fe,
|
|
661
|
+
children: /* @__PURE__ */ _("div", {
|
|
662
|
+
className: j("bsy-select-container text-sm", e.className),
|
|
663
|
+
style: e.style,
|
|
664
|
+
children: [
|
|
665
|
+
/* @__PURE__ */ g("div", {
|
|
666
|
+
ref: pe.setReference,
|
|
667
|
+
className: j("bsy-select-input-event", e.inputClassName),
|
|
668
|
+
...he(),
|
|
669
|
+
style: ve,
|
|
670
|
+
onClick: () => {
|
|
671
|
+
e.disabled || Y(!0);
|
|
672
|
+
},
|
|
673
|
+
role: "combobox",
|
|
674
|
+
"aria-expanded": q,
|
|
675
|
+
"aria-haspopup": "listbox",
|
|
676
|
+
"aria-controls": P,
|
|
677
|
+
"aria-disabled": s,
|
|
678
|
+
children: /* @__PURE__ */ g(ue, {
|
|
679
|
+
mode: M,
|
|
680
|
+
clearable: o,
|
|
681
|
+
disabled: s,
|
|
682
|
+
placeholder: c || N("select"),
|
|
683
|
+
labelRender: u,
|
|
684
|
+
options: r,
|
|
685
|
+
type: i,
|
|
686
|
+
prefix: m,
|
|
687
|
+
suffixIcon: v,
|
|
688
|
+
ghost: y,
|
|
689
|
+
inputValueStyle: b,
|
|
690
|
+
tagStyle: x,
|
|
691
|
+
onClear: ye
|
|
692
|
+
})
|
|
693
|
+
}),
|
|
694
|
+
/* @__PURE__ */ g(ie, { children: /* @__PURE__ */ g(re, { children: q && /* @__PURE__ */ _(h, { children: [e.showMask && /* @__PURE__ */ g("div", {
|
|
695
|
+
className: "bsy-select-mask",
|
|
696
|
+
style: { zIndex: w }
|
|
697
|
+
}), /* @__PURE__ */ g("div", {
|
|
698
|
+
ref: pe.setFloating,
|
|
699
|
+
style: me,
|
|
700
|
+
..._e(),
|
|
701
|
+
id: P,
|
|
702
|
+
children: /* @__PURE__ */ g(ge, {
|
|
703
|
+
...e,
|
|
704
|
+
options: r,
|
|
705
|
+
onPopupScroll: p
|
|
706
|
+
})
|
|
707
|
+
})] }) }) }),
|
|
708
|
+
Z && D === "bottom" ? e.otherOptionRender ? e.otherOptionRender(W, r) : /* @__PURE__ */ g("div", {
|
|
709
|
+
className: j("mt-[6px] w-full px-[10px] py-[7px] bg-white rounded-[4px]", "border border-[#e0e0e0]"),
|
|
710
|
+
children: /* @__PURE__ */ g("input", {
|
|
711
|
+
value: W || "",
|
|
712
|
+
onChange: (e) => {
|
|
713
|
+
G(e.target.value), d?.(e.target.value);
|
|
714
|
+
},
|
|
715
|
+
className: "w-full outline-none border-none placeholder:text-[#999]",
|
|
716
|
+
placeholder: N("context"),
|
|
717
|
+
"aria-label": "其他选项输入框",
|
|
718
|
+
role: "textbox"
|
|
719
|
+
})
|
|
720
|
+
}) : null
|
|
721
|
+
]
|
|
722
|
+
})
|
|
723
|
+
})
|
|
724
|
+
})
|
|
725
|
+
});
|
|
726
|
+
});
|
|
727
|
+
_e.displayName = "BsySelect";
|
|
728
|
+
//#endregion
|
|
729
|
+
export { I as n, L as r, _e as t };
|