@baishuyun/ui-base 2.0.0 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/dist/Card/{Card-DMXtN2pu.js → Card-CXULQNHa.js} +1 -1
  2. package/dist/Card/index.js +1 -1
  3. package/dist/CheckBox/CheckBox-Bu40TO29.js +84 -0
  4. package/dist/CheckBox/index.js +37 -0
  5. package/dist/ColorPicker/ColorPicker-CwFsihkL.js +207 -0
  6. package/dist/ColorPicker/index.js +1 -1
  7. package/dist/Icon/{Icon-C0bjP9U6.js → Icon-BlkVlKDd.js} +1 -1
  8. package/dist/Icon/index.js +1 -1
  9. package/dist/InputTag/index.js +2 -2
  10. package/dist/Modal/{Modal-C1LEJ6Y0.js → Modal-BZTEGGa0.js} +1 -1
  11. package/dist/Modal/index.js +1 -1
  12. package/dist/NotFoundContent/NotFoundContent-h0-oIXlk.js +6 -0
  13. package/dist/NotFoundContent/index.js +4 -0
  14. package/dist/Radio/index.js +105 -0
  15. package/dist/Segmented/Segmented-UgzW78Ey.js +75 -0
  16. package/dist/Segmented/index.js +4 -0
  17. package/dist/Select/Select-C3abXG27.js +855 -0
  18. package/dist/Select/index.js +6 -0
  19. package/dist/Tree/index.js +4 -0
  20. package/dist/Tree/utils/index.js +40 -0
  21. package/dist/components/CheckBox/CheckBox.d.ts +46 -0
  22. package/dist/components/CheckBox/CheckboxIcon.d.ts +6 -0
  23. package/dist/components/CheckBox/Group.d.ts +30 -0
  24. package/dist/components/CheckBox/constants.d.ts +11 -0
  25. package/dist/components/CheckBox/context/context.d.ts +8 -0
  26. package/dist/components/CheckBox/index.d.ts +9 -0
  27. package/dist/components/NotFoundContent/NotFoundContent.d.ts +9 -0
  28. package/dist/components/NotFoundContent/index.d.ts +1 -0
  29. package/dist/components/Radio/Group.d.ts +3 -0
  30. package/dist/components/Radio/Radio.d.ts +3 -0
  31. package/dist/components/Radio/constants.d.ts +6 -0
  32. package/dist/components/Radio/context/context.d.ts +9 -0
  33. package/dist/components/Radio/index.d.ts +7 -0
  34. package/dist/components/Radio/interface.d.ts +98 -0
  35. package/dist/components/Segmented/Segmented.d.ts +6 -0
  36. package/dist/components/Segmented/Segmented.type.d.ts +31 -0
  37. package/dist/components/Segmented/index.d.ts +2 -0
  38. package/dist/components/Select/HighlightText/HighlightText.d.ts +7 -0
  39. package/dist/components/Select/OptionList/MultOptionList/MultOptionList.d.ts +11 -0
  40. package/dist/components/Select/OptionList/OptionList.d.ts +6 -0
  41. package/dist/components/Select/OptionList/SingleOptionList/SingleOptionList.d.ts +11 -0
  42. package/dist/components/Select/OptionList/TreeOptionList/TreeOptionList.d.ts +21 -0
  43. package/dist/components/Select/OptionList/filter.d.ts +4 -0
  44. package/dist/components/Select/Select.d.ts +3 -0
  45. package/dist/components/Select/SelectInput/SelectInput.d.ts +10 -0
  46. package/dist/components/Select/SelectInput/SelectMultipleInput/OptionTag/OptionTag.d.ts +12 -0
  47. package/dist/components/Select/SelectInput/SelectMultipleInput/SelectMultipleInput.d.ts +8 -0
  48. package/dist/components/Select/SelectInput/SelectSingleInput/SelectSingleInput.d.ts +8 -0
  49. package/dist/components/Select/SelectInputSearch/SelectInputSearch.d.ts +6 -0
  50. package/dist/components/Select/SelectPanel/SelectPanel.d.ts +3 -0
  51. package/dist/components/Select/constants.d.ts +59 -0
  52. package/dist/components/Select/context/SelectContext.d.ts +52 -0
  53. package/dist/components/Select/index.d.ts +3 -0
  54. package/dist/components/Select/interface.d.ts +192 -0
  55. package/dist/components/Select/utils/fieldAccessor.d.ts +30 -0
  56. package/dist/components/Select/utils/tree.d.ts +2 -0
  57. package/dist/components/Tree/Tree.d.ts +6 -0
  58. package/dist/components/Tree/TreeNode/TreeNode.d.ts +21 -0
  59. package/dist/components/Tree/context/TreeContext.d.ts +15 -0
  60. package/dist/components/Tree/index.d.ts +3 -0
  61. package/dist/components/Tree/types/node.d.ts +12 -0
  62. package/dist/components/Tree/types/tree.d.ts +84 -0
  63. package/dist/components/Tree/utils/index.d.ts +11 -0
  64. package/dist/components/index.d.ts +5 -0
  65. package/dist/index.js +45 -35
  66. package/dist/style.css +1 -1
  67. package/dist/vendors/Tree-CCY2gtpG.js +225 -0
  68. package/dist/vendors/fuse.js-D1DCbUBb.js +1022 -0
  69. package/dist/vendors/index-ByQkttKA.js +59 -0
  70. package/dist/vendors/lodash-es-CZfJRWhO.js +305 -0
  71. package/dist/vendors/{simplebar-react-svBEsTVC.js → simplebar-react-Bf9Zq-21.js} +1 -1
  72. package/package.json +1 -1
  73. package/dist/ColorPicker/ColorPicker-CpPLwHR2.js +0 -253
  74. package/dist/vendors/fuse.js-l0sNRNKZ.js +0 -1
  75. package/dist/vendors/lodash-es-DP1ViCXF.js +0 -262
@@ -0,0 +1,225 @@
1
+ import { jsx as a, jsxs as N, Fragment as O } from "react/jsx-runtime";
2
+ import M, { useMemo as j, useCallback as I, createContext as R, useContext as V, useEffect as $ } from "react";
3
+ import { I as z } from "../Icon/Icon-BlkVlKDd.js";
4
+ import { c as E } from "./clsx-OuTLNxxd.js";
5
+ import { n as _ } from "./lodash-es-CZfJRWhO.js";
6
+ import { B as A } from "../CheckBox/CheckBox-Bu40TO29.js";
7
+ import F from "../Radio/index.js";
8
+ import { useControllableValue as B } from "ahooks";
9
+ import { getMatchingNodesPaths as W, getNodePath as q } from "../Tree/utils/index.js";
10
+ const L = ({ text: e, highlight: s }) => {
11
+ const [t, o] = j(
12
+ () => e && s ? [e.toLowerCase(), s.toLowerCase()] : [],
13
+ [e, s]
14
+ ), g = I(() => {
15
+ if (!s.trim())
16
+ return [{ text: e, isMatch: !1 }];
17
+ const l = o ? t == null ? void 0 : t.indexOf(o) : -1;
18
+ return l === -1 || l === void 0 ? [{ text: e, isMatch: !1 }] : [
19
+ { text: e.slice(0, l), isMatch: !1 },
20
+ { text: e.slice(l, l + s.length), isMatch: !0 },
21
+ { text: e.slice(l + s.length), isMatch: !1 }
22
+ ].filter((c) => c.text);
23
+ }, [e, s, t, o])(), f = {
24
+ color: "#0265ff",
25
+ fontWeight: 500
26
+ };
27
+ return /* @__PURE__ */ a("div", { className: "select-none text-ellipsis overflow-hidden whitespace-nowrap truncate w-full", children: g.map(
28
+ (l, c) => l.isMatch ? /* @__PURE__ */ a("span", { style: f, children: l.text }, c) : /* @__PURE__ */ a("span", { children: l.text }, c)
29
+ ) });
30
+ };
31
+ L.displayName = "HighlightText";
32
+ const G = M.memo(L), P = R({
33
+ searchValue: "",
34
+ selectedKeys: [],
35
+ expandedKeys: [],
36
+ parentCheckable: !1,
37
+ onSelect: _,
38
+ onExpand: _,
39
+ icon: void 0,
40
+ switcherIcon: void 0,
41
+ checkType: "default",
42
+ showSwitcher: !0
43
+ }), J = 22, H = ({ node: e, level: s = 0, fieldNames: t }) => {
44
+ var r;
45
+ const o = V(P), {
46
+ searchValue: v,
47
+ selectedKeys: g,
48
+ expandedKeys: f,
49
+ onSelect: l,
50
+ onExpand: c,
51
+ onDeSelect: x,
52
+ parentCheckable: w,
53
+ checkType: d,
54
+ showSwitcher: k
55
+ } = V(P), h = e[t.children] && e[t.children].length > 0, m = g.includes(e[t.value]), p = h ? f.includes(e[t.value]) : !1, y = () => {
56
+ if (e.checkable === !1) {
57
+ h && (c == null || c(e[t.value], !p));
58
+ return;
59
+ }
60
+ if (h) {
61
+ w ? C() : c == null || c(e[t.value], !p);
62
+ return;
63
+ }
64
+ C();
65
+ }, C = () => {
66
+ m ? x == null || x(e[t.value]) : l == null || l(e[t.value], e);
67
+ }, K = (n) => {
68
+ n.stopPropagation(), h && (c == null || c(e[t.value], !p));
69
+ }, S = (n = !1) => {
70
+ const i = e.icon || o.icon;
71
+ if (!i) return null;
72
+ const u = typeof i == "function" ? i(e) : i;
73
+ return M.isValidElement(u) ? /* @__PURE__ */ a(
74
+ "span",
75
+ {
76
+ className: E({
77
+ "text-[#0265ff]": n,
78
+ "text-[#73819c]": !n
79
+ }),
80
+ children: u
81
+ }
82
+ ) : null;
83
+ }, T = (n) => h ? o.switcherIcon ? o.switcherIcon(n) : /* @__PURE__ */ a(
84
+ z,
85
+ {
86
+ name: "arrow-right",
87
+ className: E("transition-transform duration-300 ease-in-out text-[#666]", {
88
+ "rotate-90": n
89
+ })
90
+ }
91
+ ) : null, b = () => h && !w || d === "default" || e.checkable === !1 ? null : /* @__PURE__ */ N("div", { className: "ml-auto shrink-0", children: [
92
+ d === "radio" && /* @__PURE__ */ a(F, { checked: m }),
93
+ d === "checkbox" && /* @__PURE__ */ a(A, { checked: m })
94
+ ] });
95
+ return /* @__PURE__ */ N(O, { children: [
96
+ /* @__PURE__ */ a(
97
+ "div",
98
+ {
99
+ className: E("rounded-[4px] cursor-pointer", {
100
+ "text-[#0265ff] bg-[#f0f6ff]": m && d === "default",
101
+ "hover:bg-[#f3f3f3]": !m || d !== "default"
102
+ }),
103
+ onClick: y,
104
+ children: /* @__PURE__ */ N(
105
+ "div",
106
+ {
107
+ className: "flex items-center px-[10px] py-[7px] gap-x-[6px]",
108
+ style: { marginLeft: `${s * J}px` },
109
+ children: [
110
+ /* @__PURE__ */ a(
111
+ "div",
112
+ {
113
+ className: E("w-4 h-4 flex items-center justify-center flex-shrink-0", {
114
+ hidden: !k
115
+ }),
116
+ onClick: K,
117
+ children: T(p)
118
+ }
119
+ ),
120
+ S(m),
121
+ M.isValidElement(e[t.title]) ? e[t.title] : /* @__PURE__ */ a(G, { text: e[t.title], highlight: v }),
122
+ b()
123
+ ]
124
+ }
125
+ )
126
+ }
127
+ ),
128
+ h && /* @__PURE__ */ a(
129
+ "div",
130
+ {
131
+ className: "grid transition-[grid-template-rows] duration-300 ease-in-out",
132
+ style: { gridTemplateRows: p ? "1fr" : "0fr" },
133
+ children: /* @__PURE__ */ a("div", { className: "overflow-hidden", children: (r = e[t.children]) == null ? void 0 : r.map((n) => /* @__PURE__ */ a(
134
+ H,
135
+ {
136
+ node: n,
137
+ level: s + 1,
138
+ fieldNames: t
139
+ },
140
+ n[t.value]
141
+ )) })
142
+ }
143
+ )
144
+ ] });
145
+ }, Q = (e) => {
146
+ const {
147
+ data: s,
148
+ searchValue: t = "",
149
+ fieldNames: o = { title: "title", value: "value", children: "children" },
150
+ icon: v,
151
+ switcherIcon: g,
152
+ onSelect: f,
153
+ parentCheckable: l = !1,
154
+ checkType: c = "default",
155
+ defaultExpandedKeys: x,
156
+ showSwitcher: w = !0,
157
+ onDeSelect: d
158
+ } = e, [k, h] = B(e, {
159
+ defaultValuePropName: "defaultSelectedKeys",
160
+ valuePropName: "selectedKeys",
161
+ defaultValue: [],
162
+ trigger: "__DO_NOT_CALLED__"
163
+ }), m = () => {
164
+ var n;
165
+ const r = /* @__PURE__ */ new Set();
166
+ return (n = e.selectedKeys) != null && n.length ? (e.selectedKeys.forEach((i) => {
167
+ const u = q(s, i, o);
168
+ u && u.length > 1 && u.slice(0, -1).forEach((D) => r.add(D));
169
+ }), [...r]) : [];
170
+ }, [p, y] = B(e, {
171
+ valuePropName: "expandedKeys",
172
+ defaultValuePropName: "defaultExpandedKeys",
173
+ defaultValue: m(),
174
+ trigger: "onExpand"
175
+ });
176
+ $(() => {
177
+ if (!t) {
178
+ if (k.length || x != null && x.length) return;
179
+ y([]);
180
+ return;
181
+ }
182
+ const r = /* @__PURE__ */ new Set(), n = W(s, t, o);
183
+ if (n.length === 0) {
184
+ y([]);
185
+ return;
186
+ }
187
+ n.forEach((i) => i.slice(0, -1).forEach((u) => r.add(u))), r.size !== 0 && y([...r]);
188
+ }, [t]);
189
+ const C = I(
190
+ (r, n) => {
191
+ h((i) => c === "checkbox" ? [.../* @__PURE__ */ new Set([...i, r])] : [r]), f && (f == null || f(r, n));
192
+ },
193
+ [f, h, c]
194
+ ), K = (r, n) => {
195
+ C(r, n);
196
+ }, S = I(
197
+ (r) => {
198
+ h((n) => n.filter((i) => i !== r)), d == null || d(r);
199
+ },
200
+ [h, d]
201
+ ), T = (r, n) => {
202
+ const i = n ? [...p, r] : p.filter((u) => u !== r);
203
+ y(i);
204
+ };
205
+ if (!(s != null && s.length)) return null;
206
+ const b = {
207
+ searchValue: t,
208
+ selectedKeys: k,
209
+ expandedKeys: p,
210
+ onSelect: K,
211
+ onDeSelect: S,
212
+ onExpand: T,
213
+ icon: v,
214
+ switcherIcon: g,
215
+ checkType: c,
216
+ parentCheckable: l,
217
+ showSwitcher: w
218
+ };
219
+ return /* @__PURE__ */ a(P.Provider, { value: b, children: /* @__PURE__ */ a("div", { className: "bsy-tree text-sm", children: s.map((r) => /* @__PURE__ */ a(H, { node: r, fieldNames: o }, r[o.value])) }) });
220
+ };
221
+ Q.displayName = "BsyTree";
222
+ export {
223
+ G as H,
224
+ Q as T
225
+ };