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