@chain-ui/core 0.1.1
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/README.md +38 -0
- package/dist/index.cjs +1 -0
- package/dist/index.css +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1051 -0
- package/dist/src/components/alert/alert.d.ts +15 -0
- package/dist/src/components/alert/alert.stories.d.ts +13 -0
- package/dist/src/components/alert/alert.test.d.ts +1 -0
- package/dist/src/components/alert/index.d.ts +2 -0
- package/dist/src/components/badge/badge.d.ts +12 -0
- package/dist/src/components/badge/badge.stories.d.ts +13 -0
- package/dist/src/components/badge/badge.test.d.ts +1 -0
- package/dist/src/components/badge/index.d.ts +2 -0
- package/dist/src/components/button/button.d.ts +13 -0
- package/dist/src/components/button/button.stories.d.ts +11 -0
- package/dist/src/components/button/button.test.d.ts +1 -0
- package/dist/src/components/button/index.d.ts +2 -0
- package/dist/src/components/divider/divider.d.ts +8 -0
- package/dist/src/components/divider/divider.stories.d.ts +12 -0
- package/dist/src/components/divider/divider.test.d.ts +1 -0
- package/dist/src/components/divider/index.d.ts +2 -0
- package/dist/src/components/form-item/form-item.d.ts +15 -0
- package/dist/src/components/form-item/form-item.stories.d.ts +16 -0
- package/dist/src/components/form-item/form-item.test.d.ts +1 -0
- package/dist/src/components/form-item/index.d.ts +2 -0
- package/dist/src/components/index.d.ts +12 -0
- package/dist/src/components/input/index.d.ts +2 -0
- package/dist/src/components/input/input.d.ts +18 -0
- package/dist/src/components/input/input.stories.d.ts +20 -0
- package/dist/src/components/input/input.test.d.ts +1 -0
- package/dist/src/components/modal/index.d.ts +2 -0
- package/dist/src/components/modal/modal.d.ts +25 -0
- package/dist/src/components/modal/modal.stories.d.ts +12 -0
- package/dist/src/components/modal/modal.test.d.ts +1 -0
- package/dist/src/components/pagination/index.d.ts +2 -0
- package/dist/src/components/pagination/pagination.d.ts +23 -0
- package/dist/src/components/pagination/pagination.stories.d.ts +12 -0
- package/dist/src/components/pagination/pagination.test.d.ts +1 -0
- package/dist/src/components/select/index.d.ts +2 -0
- package/dist/src/components/select/select.d.ts +35 -0
- package/dist/src/components/select/select.stories.d.ts +21 -0
- package/dist/src/components/select/select.test.d.ts +1 -0
- package/dist/src/components/space/index.d.ts +2 -0
- package/dist/src/components/space/space.d.ts +9 -0
- package/dist/src/components/space/space.stories.d.ts +10 -0
- package/dist/src/components/space/space.test.d.ts +1 -0
- package/dist/src/components/table/index.d.ts +2 -0
- package/dist/src/components/table/table.d.ts +54 -0
- package/dist/src/components/table/table.stories.d.ts +13 -0
- package/dist/src/components/table/table.test.d.ts +1 -0
- package/dist/src/components/tag/index.d.ts +2 -0
- package/dist/src/components/tag/tag.d.ts +10 -0
- package/dist/src/components/tag/tag.stories.d.ts +12 -0
- package/dist/src/components/tag/tag.test.d.ts +1 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/theme/index.d.ts +1 -0
- package/dist/src/utils/index.d.ts +1 -0
- package/package.json +54 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,1051 @@
|
|
|
1
|
+
import e, { forwardRef as t, useCallback as n, useEffect as r, useId as i, useMemo as a, useRef as o, useState as s } from "react";
|
|
2
|
+
import { Fragment as c, jsx as l, jsxs as u } from "react/jsx-runtime";
|
|
3
|
+
import { createPortal as d } from "react-dom";
|
|
4
|
+
//#region src/components/button/button.tsx
|
|
5
|
+
var f = t(function({ variant: e = "solid", color: t = "primary", size: n = "md", shape: r = "default", disabled: i = !1, loading: a = !1, icon: o, iconRight: s, children: c, onClick: d, className: f, htmlType: p, ariaLabel: m, ...h }, g) {
|
|
6
|
+
let _ = i || a;
|
|
7
|
+
return /* @__PURE__ */ u("button", {
|
|
8
|
+
ref: g,
|
|
9
|
+
type: p,
|
|
10
|
+
className: [
|
|
11
|
+
"chain-btn",
|
|
12
|
+
`chain-btn--${e}`,
|
|
13
|
+
`chain-btn--${t}`,
|
|
14
|
+
`chain-btn--${n}`,
|
|
15
|
+
r !== "default" && `chain-btn--${r}`,
|
|
16
|
+
_ && "chain-btn--disabled",
|
|
17
|
+
a && "chain-btn--loading",
|
|
18
|
+
f
|
|
19
|
+
].filter(Boolean).join(" "),
|
|
20
|
+
disabled: _,
|
|
21
|
+
"aria-disabled": _ || void 0,
|
|
22
|
+
"aria-busy": a || void 0,
|
|
23
|
+
"aria-label": m,
|
|
24
|
+
onClick: (e) => {
|
|
25
|
+
_ || d?.(e);
|
|
26
|
+
},
|
|
27
|
+
...h,
|
|
28
|
+
children: [
|
|
29
|
+
a && /* @__PURE__ */ l("span", {
|
|
30
|
+
className: "chain-btn__spinner",
|
|
31
|
+
"aria-hidden": "true"
|
|
32
|
+
}),
|
|
33
|
+
!a && o && /* @__PURE__ */ l("span", {
|
|
34
|
+
className: "chain-btn__icon",
|
|
35
|
+
children: o
|
|
36
|
+
}),
|
|
37
|
+
c && /* @__PURE__ */ l("span", { children: c }),
|
|
38
|
+
!a && s && /* @__PURE__ */ l("span", {
|
|
39
|
+
className: "chain-btn__icon--right",
|
|
40
|
+
children: s
|
|
41
|
+
})
|
|
42
|
+
]
|
|
43
|
+
});
|
|
44
|
+
}), p = t(function({ value: e, defaultValue: t, onChange: n, variant: r = "outline", size: i = "md", status: a = "default", disabled: o = !1, readOnly: c = !1, prefix: d, suffix: f, allowClear: p = !1, clearAriaLabel: m = "Clear input", showCount: h = !1, maxLength: g, className: _, style: v, ...y }, b) {
|
|
45
|
+
let [x, S] = s(t ?? ""), C = e !== void 0, w = C ? e : x, T = (e) => {
|
|
46
|
+
if (o || c) return;
|
|
47
|
+
let t = e.target.value;
|
|
48
|
+
C || S(t), n?.(t, e);
|
|
49
|
+
}, E = () => {
|
|
50
|
+
C || S(""), n?.("", { target: { value: "" } });
|
|
51
|
+
}, D = p && w.length > 0 && !o && !c;
|
|
52
|
+
return /* @__PURE__ */ u("div", {
|
|
53
|
+
className: [
|
|
54
|
+
"chain-input",
|
|
55
|
+
`chain-input--${r}`,
|
|
56
|
+
`chain-input--${i}`,
|
|
57
|
+
a !== "default" && `chain-input--${a}`,
|
|
58
|
+
o && "chain-input--disabled",
|
|
59
|
+
c && "chain-input--readonly",
|
|
60
|
+
_
|
|
61
|
+
].filter(Boolean).join(" "),
|
|
62
|
+
style: v,
|
|
63
|
+
children: [
|
|
64
|
+
d && /* @__PURE__ */ l("span", {
|
|
65
|
+
className: "chain-input__prefix",
|
|
66
|
+
children: d
|
|
67
|
+
}),
|
|
68
|
+
/* @__PURE__ */ l("input", {
|
|
69
|
+
ref: b,
|
|
70
|
+
className: "chain-input__field",
|
|
71
|
+
value: w,
|
|
72
|
+
defaultValue: C ? void 0 : t,
|
|
73
|
+
onChange: T,
|
|
74
|
+
disabled: o,
|
|
75
|
+
readOnly: c,
|
|
76
|
+
maxLength: g,
|
|
77
|
+
"aria-disabled": o || void 0,
|
|
78
|
+
"aria-invalid": a === "error" || void 0,
|
|
79
|
+
...y
|
|
80
|
+
}),
|
|
81
|
+
(D || h || f) && /* @__PURE__ */ u("span", {
|
|
82
|
+
className: "chain-input__suffix",
|
|
83
|
+
children: [
|
|
84
|
+
D && /* @__PURE__ */ l("span", {
|
|
85
|
+
className: "chain-input__clear",
|
|
86
|
+
onClick: E,
|
|
87
|
+
role: "button",
|
|
88
|
+
tabIndex: 0,
|
|
89
|
+
"aria-label": m,
|
|
90
|
+
children: "×"
|
|
91
|
+
}),
|
|
92
|
+
h && /* @__PURE__ */ u("span", {
|
|
93
|
+
className: "chain-input__count",
|
|
94
|
+
children: [w.length, g !== void 0 && ` / ${g}`]
|
|
95
|
+
}),
|
|
96
|
+
f
|
|
97
|
+
]
|
|
98
|
+
})
|
|
99
|
+
]
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
//#endregion
|
|
103
|
+
//#region src/components/form-item/form-item.tsx
|
|
104
|
+
function m(t, n) {
|
|
105
|
+
if (n === "default" || !e.isValidElement(t)) return t;
|
|
106
|
+
let r = t.type;
|
|
107
|
+
return typeof r == "function" || typeof r == "object" && r ? e.cloneElement(t, { status: n }) : t;
|
|
108
|
+
}
|
|
109
|
+
var h = t(function({ label: t, labelWidth: n = 120, labelAlign: r = "right", required: i = !1, requiredMark: a = "*", colon: o = !0, colonText: s = ":", status: c = "default", help: d, layout: f = "horizontal", children: p, className: h, style: g, ..._ }, v) {
|
|
110
|
+
let y = t != null, b = () => {
|
|
111
|
+
if (!y) return null;
|
|
112
|
+
let e = o && typeof t == "string" && t.length > 0;
|
|
113
|
+
return /* @__PURE__ */ u("label", {
|
|
114
|
+
className: ["chain-form-item__label", r === "right" && "chain-form-item__label--right"].filter(Boolean).join(" "),
|
|
115
|
+
style: { width: typeof n == "number" ? `${n}px` : n },
|
|
116
|
+
children: [
|
|
117
|
+
i && /* @__PURE__ */ l("span", {
|
|
118
|
+
className: "chain-form-item__label-required",
|
|
119
|
+
"aria-hidden": "true",
|
|
120
|
+
children: a
|
|
121
|
+
}),
|
|
122
|
+
/* @__PURE__ */ l("span", {
|
|
123
|
+
className: "chain-form-item__label-text",
|
|
124
|
+
children: t
|
|
125
|
+
}),
|
|
126
|
+
e && /* @__PURE__ */ l("span", {
|
|
127
|
+
className: "chain-form-item__label-colon",
|
|
128
|
+
children: s
|
|
129
|
+
})
|
|
130
|
+
]
|
|
131
|
+
});
|
|
132
|
+
}, x = [
|
|
133
|
+
"chain-form-item",
|
|
134
|
+
`chain-form-item--${f}`,
|
|
135
|
+
c !== "default" && `chain-form-item--${c}`,
|
|
136
|
+
i && "chain-form-item--required",
|
|
137
|
+
h
|
|
138
|
+
].filter(Boolean).join(" "), S = ["chain-form-item__help", c !== "default" && `chain-form-item__help--${c}`].filter(Boolean).join(" "), C = c !== "default" && e.Children.count(p) === 1 ? m(e.Children.toArray(p)[0], c) : p;
|
|
139
|
+
return /* @__PURE__ */ u("div", {
|
|
140
|
+
ref: v,
|
|
141
|
+
className: x,
|
|
142
|
+
style: g,
|
|
143
|
+
..._,
|
|
144
|
+
children: [
|
|
145
|
+
b(),
|
|
146
|
+
/* @__PURE__ */ l("div", {
|
|
147
|
+
className: "chain-form-item__control",
|
|
148
|
+
children: C
|
|
149
|
+
}),
|
|
150
|
+
d && /* @__PURE__ */ l("div", {
|
|
151
|
+
className: S,
|
|
152
|
+
children: d
|
|
153
|
+
})
|
|
154
|
+
]
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
//#endregion
|
|
158
|
+
//#region src/components/select/select.tsx
|
|
159
|
+
function g(e, t) {
|
|
160
|
+
return e === t.value;
|
|
161
|
+
}
|
|
162
|
+
var _ = t(function({ value: e, defaultValue: t, onChange: i, options: a = [], variant: c = "outline", size: f = "md", status: p = "default", disabled: m = !1, loading: h = !1, allowClear: _ = !1, placeholder: v = "Please select", mode: y = "single", showSearch: b = !1, prefix: x, suffix: S, emptyText: C = "暂无数据", clearAriaLabel: w = "Clear selection", searchPlaceholder: T = "Search", expandAriaLabel: E = "Expand", collapseAriaLabel: D = "Collapse", removeAriaLabel: O = "Remove", dropdownClassName: k, dropdownStyle: A, getPopupContainer: j, className: M, style: N, ...P }, F) {
|
|
163
|
+
let I = e !== void 0, [ee, te] = s(t ?? (y === "multiple" ? [] : "")), L = I ? e : ee, [R, z] = s(!1), [B, V] = s(-1), [H, U] = s(""), [W, ne] = s({
|
|
164
|
+
top: 0,
|
|
165
|
+
left: 0,
|
|
166
|
+
width: 0
|
|
167
|
+
}), G = o(null), re = o(null), ie = o(null), K = o(null), q = m || h, J = n((e, t) => {
|
|
168
|
+
I || te(e), i?.(e, t);
|
|
169
|
+
}, [I, i]), ae = a.filter((e) => y === "multiple" && Array.isArray(L) ? L.some((t) => g(t, e)) : g(L, e)), oe = b && H ? a.filter((e) => String(e.label).toLowerCase().includes(H.toLowerCase())) : a, Y = oe.filter((e) => !e.disabled), X = n(() => {
|
|
170
|
+
if (!G.current) return;
|
|
171
|
+
let e = G.current.getBoundingClientRect();
|
|
172
|
+
ne({
|
|
173
|
+
top: e.bottom + 4,
|
|
174
|
+
left: e.left,
|
|
175
|
+
width: e.width
|
|
176
|
+
});
|
|
177
|
+
}, []), Z = n(() => {
|
|
178
|
+
q || (X(), z(!0), V(-1), U(""));
|
|
179
|
+
}, [q, X]), Q = n(() => {
|
|
180
|
+
z(!1), V(-1), U("");
|
|
181
|
+
}, []), $ = n((e, t) => {
|
|
182
|
+
if (!e.disabled) if (y === "multiple") {
|
|
183
|
+
let n = Array.isArray(L) ? L : [];
|
|
184
|
+
J(n.some((t) => g(t, e)) ? n.filter((t) => !g(t, e)) : [...n, e.value], t);
|
|
185
|
+
} else J(e.value, t), Q();
|
|
186
|
+
}, [
|
|
187
|
+
y,
|
|
188
|
+
L,
|
|
189
|
+
J,
|
|
190
|
+
Q
|
|
191
|
+
]), se = n((e) => {
|
|
192
|
+
e.stopPropagation(), J(y === "multiple" ? [] : "", e);
|
|
193
|
+
}, [y, J]), ce = n((e, t) => {
|
|
194
|
+
t.stopPropagation(), y === "multiple" && Array.isArray(L) && J(L.filter((t) => !g(t, e)), t);
|
|
195
|
+
}, [
|
|
196
|
+
y,
|
|
197
|
+
L,
|
|
198
|
+
J
|
|
199
|
+
]), le = () => {
|
|
200
|
+
if (y === "multiple" && Array.isArray(L) && L.length > 0) return null;
|
|
201
|
+
if (y === "single" && L !== "" && L !== void 0) {
|
|
202
|
+
let e = a.find((e) => g(L, e));
|
|
203
|
+
return e ? e.label : String(L);
|
|
204
|
+
}
|
|
205
|
+
return null;
|
|
206
|
+
}, ue = n(() => {
|
|
207
|
+
q || (R ? Q() : Z());
|
|
208
|
+
}, [
|
|
209
|
+
q,
|
|
210
|
+
R,
|
|
211
|
+
Z,
|
|
212
|
+
Q
|
|
213
|
+
]), de = n((e) => {
|
|
214
|
+
if (!q) switch (e.key) {
|
|
215
|
+
case "Enter":
|
|
216
|
+
case " ":
|
|
217
|
+
e.preventDefault(), R ? B >= 0 && B < Y.length && $(Y[B], e) : Z();
|
|
218
|
+
break;
|
|
219
|
+
case "ArrowDown":
|
|
220
|
+
e.preventDefault(), R ? V((e) => e < Y.length - 1 ? e + 1 : 0) : (Z(), V(0));
|
|
221
|
+
break;
|
|
222
|
+
case "ArrowUp":
|
|
223
|
+
e.preventDefault(), R && V((e) => e > 0 ? e - 1 : Y.length - 1);
|
|
224
|
+
break;
|
|
225
|
+
case "Escape":
|
|
226
|
+
e.preventDefault(), Q(), G.current?.focus();
|
|
227
|
+
break;
|
|
228
|
+
case "Tab":
|
|
229
|
+
R && Q();
|
|
230
|
+
break;
|
|
231
|
+
}
|
|
232
|
+
}, [
|
|
233
|
+
q,
|
|
234
|
+
R,
|
|
235
|
+
B,
|
|
236
|
+
Y,
|
|
237
|
+
$,
|
|
238
|
+
Z,
|
|
239
|
+
Q
|
|
240
|
+
]), fe = n((e, t) => {
|
|
241
|
+
$(e, t);
|
|
242
|
+
}, [$]), pe = n((e) => {
|
|
243
|
+
se(e);
|
|
244
|
+
}, [se]), me = n((e) => {
|
|
245
|
+
U(e.target.value), V(-1);
|
|
246
|
+
}, []);
|
|
247
|
+
r(() => {
|
|
248
|
+
if (!R) return;
|
|
249
|
+
let e = (e) => {
|
|
250
|
+
let t = e.target;
|
|
251
|
+
re.current?.contains(t) || G.current?.contains(t) || Q();
|
|
252
|
+
};
|
|
253
|
+
return document.addEventListener("mousedown", e, !0), () => document.removeEventListener("mousedown", e, !0);
|
|
254
|
+
}, [R, Q]), r(() => {
|
|
255
|
+
if (!R) return;
|
|
256
|
+
let e = () => X();
|
|
257
|
+
return window.addEventListener("scroll", e, !0), window.addEventListener("resize", e), () => {
|
|
258
|
+
window.removeEventListener("scroll", e, !0), window.removeEventListener("resize", e);
|
|
259
|
+
};
|
|
260
|
+
}, [R, X]), r(() => {
|
|
261
|
+
R && b && requestAnimationFrame(() => ie.current?.focus());
|
|
262
|
+
}, [R, b]), r(() => {
|
|
263
|
+
if (B < 0 || !K.current) return;
|
|
264
|
+
let e = K.current.querySelectorAll(".chain-select__item")[B];
|
|
265
|
+
e && typeof e.scrollIntoView == "function" && e.scrollIntoView({ block: "nearest" });
|
|
266
|
+
}, [B]);
|
|
267
|
+
let he = _ && !q && (y === "multiple" ? Array.isArray(L) && L.length > 0 : L !== "" && L !== void 0), ge = [
|
|
268
|
+
"chain-select",
|
|
269
|
+
`chain-select--${c}`,
|
|
270
|
+
`chain-select--${f}`,
|
|
271
|
+
p !== "default" && `chain-select--${p}`,
|
|
272
|
+
q && "chain-select--disabled",
|
|
273
|
+
h && "chain-select--loading",
|
|
274
|
+
y === "multiple" && "chain-select--multiple",
|
|
275
|
+
R && "chain-select--open",
|
|
276
|
+
M
|
|
277
|
+
].filter(Boolean).join(" "), _e = le(), ve = () => {
|
|
278
|
+
if (!R) return null;
|
|
279
|
+
let e = j?.() ?? document.body;
|
|
280
|
+
return d(/* @__PURE__ */ u("div", {
|
|
281
|
+
ref: re,
|
|
282
|
+
className: ["chain-select__dropdown", k].filter(Boolean).join(" "),
|
|
283
|
+
style: {
|
|
284
|
+
top: W.top,
|
|
285
|
+
left: W.left,
|
|
286
|
+
width: W.width,
|
|
287
|
+
...A
|
|
288
|
+
},
|
|
289
|
+
children: [b && /* @__PURE__ */ l("div", {
|
|
290
|
+
className: "chain-select__search",
|
|
291
|
+
children: /* @__PURE__ */ l("input", {
|
|
292
|
+
ref: ie,
|
|
293
|
+
className: "chain-select__search-input",
|
|
294
|
+
placeholder: T,
|
|
295
|
+
value: H,
|
|
296
|
+
onChange: me,
|
|
297
|
+
role: "searchbox",
|
|
298
|
+
onClick: (e) => e.stopPropagation()
|
|
299
|
+
})
|
|
300
|
+
}), oe.length === 0 ? /* @__PURE__ */ l("div", {
|
|
301
|
+
className: "chain-select__empty",
|
|
302
|
+
children: C
|
|
303
|
+
}) : /* @__PURE__ */ l("ul", {
|
|
304
|
+
ref: K,
|
|
305
|
+
className: "chain-select__list",
|
|
306
|
+
role: "listbox",
|
|
307
|
+
children: oe.map((e, t) => {
|
|
308
|
+
let n = y === "multiple" && Array.isArray(L) ? L.some((t) => g(t, e)) : g(L, e);
|
|
309
|
+
return /* @__PURE__ */ u("li", {
|
|
310
|
+
className: [
|
|
311
|
+
"chain-select__item",
|
|
312
|
+
n && "chain-select__item--selected",
|
|
313
|
+
t === B && "chain-select__item--highlighted",
|
|
314
|
+
e.disabled && "chain-select__item--disabled"
|
|
315
|
+
].filter(Boolean).join(" "),
|
|
316
|
+
role: "option",
|
|
317
|
+
"aria-selected": n,
|
|
318
|
+
"aria-disabled": e.disabled || void 0,
|
|
319
|
+
onClick: (t) => {
|
|
320
|
+
e.disabled || fe(e, t);
|
|
321
|
+
},
|
|
322
|
+
onMouseEnter: () => {
|
|
323
|
+
e.disabled || V(t);
|
|
324
|
+
},
|
|
325
|
+
children: [/* @__PURE__ */ l("span", { children: e.label }), n && /* @__PURE__ */ l("span", {
|
|
326
|
+
className: "chain-select__item-check",
|
|
327
|
+
"aria-hidden": "true",
|
|
328
|
+
children: "✓"
|
|
329
|
+
})]
|
|
330
|
+
}, e.value);
|
|
331
|
+
})
|
|
332
|
+
})]
|
|
333
|
+
}), e);
|
|
334
|
+
};
|
|
335
|
+
return /* @__PURE__ */ u("div", {
|
|
336
|
+
ref: F,
|
|
337
|
+
className: ge,
|
|
338
|
+
style: N,
|
|
339
|
+
...P,
|
|
340
|
+
children: [/* @__PURE__ */ u("div", {
|
|
341
|
+
ref: G,
|
|
342
|
+
className: "chain-select__trigger",
|
|
343
|
+
role: "combobox",
|
|
344
|
+
"aria-expanded": R,
|
|
345
|
+
"aria-haspopup": "listbox",
|
|
346
|
+
"aria-disabled": q || void 0,
|
|
347
|
+
tabIndex: q ? -1 : 0,
|
|
348
|
+
onClick: ue,
|
|
349
|
+
onKeyDown: de,
|
|
350
|
+
children: [
|
|
351
|
+
x && /* @__PURE__ */ l("span", {
|
|
352
|
+
className: "chain-select__prefix",
|
|
353
|
+
children: x
|
|
354
|
+
}),
|
|
355
|
+
/* @__PURE__ */ l("div", {
|
|
356
|
+
className: "chain-select__trigger-inner",
|
|
357
|
+
children: y === "multiple" && Array.isArray(L) && L.length > 0 ? /* @__PURE__ */ l("div", {
|
|
358
|
+
className: "chain-select__tags",
|
|
359
|
+
children: ae.map((e) => /* @__PURE__ */ u("span", {
|
|
360
|
+
className: "chain-select__tag",
|
|
361
|
+
children: [/* @__PURE__ */ l("span", { children: e.label }), /* @__PURE__ */ l("button", {
|
|
362
|
+
type: "button",
|
|
363
|
+
className: "chain-select__tag-remove",
|
|
364
|
+
"aria-label": O,
|
|
365
|
+
onClick: (t) => ce(e, t),
|
|
366
|
+
children: "×"
|
|
367
|
+
})]
|
|
368
|
+
}, e.value))
|
|
369
|
+
}) : _e ? /* @__PURE__ */ l("span", {
|
|
370
|
+
className: "chain-select__value",
|
|
371
|
+
children: _e
|
|
372
|
+
}) : /* @__PURE__ */ l("span", {
|
|
373
|
+
className: "chain-select__placeholder",
|
|
374
|
+
children: v
|
|
375
|
+
})
|
|
376
|
+
}),
|
|
377
|
+
he && /* @__PURE__ */ l("span", {
|
|
378
|
+
className: "chain-select__clear",
|
|
379
|
+
role: "button",
|
|
380
|
+
"aria-label": w,
|
|
381
|
+
onClick: pe,
|
|
382
|
+
children: "×"
|
|
383
|
+
}),
|
|
384
|
+
h ? /* @__PURE__ */ l("span", {
|
|
385
|
+
className: "chain-select__spinner",
|
|
386
|
+
"aria-hidden": "true"
|
|
387
|
+
}) : /* @__PURE__ */ l("span", {
|
|
388
|
+
className: "chain-select__arrow",
|
|
389
|
+
"aria-label": R ? D : E,
|
|
390
|
+
children: "▼"
|
|
391
|
+
}),
|
|
392
|
+
S && /* @__PURE__ */ l("span", {
|
|
393
|
+
className: "chain-select__suffix",
|
|
394
|
+
children: S
|
|
395
|
+
})
|
|
396
|
+
]
|
|
397
|
+
}), ve()]
|
|
398
|
+
});
|
|
399
|
+
}), v = {
|
|
400
|
+
sm: "400px",
|
|
401
|
+
md: "520px",
|
|
402
|
+
lg: "720px"
|
|
403
|
+
}, y = "a[href], button:not([disabled]), textarea:not([disabled]), input:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex=\"-1\"])", b = t(function({ open: e = !1, onCancel: t, title: a, children: c, footer: p, onOk: m, okText: h = "确定", okButtonProps: g, cancelText: _ = "取消", cancelButtonProps: b, confirmLoading: x = !1, closable: S = !0, closeAriaLabel: C = "Close", maskClosable: w = !0, keyboard: T = !0, destroyOnClose: E = !1, size: D = "md", width: O, centered: k = !1, getContainer: A, className: j, style: M, ...N }, P) {
|
|
404
|
+
let F = i(), [I, ee] = s(!1), [te, L] = s(!1), [R, z] = s(!1), B = o(null), V = o(null), H = o(null), U = o(0), W = e || I, ne = n((e) => {
|
|
405
|
+
B.current = e, typeof P == "function" ? P(e) : P && (P.current = e);
|
|
406
|
+
}, [P]);
|
|
407
|
+
r(() => {
|
|
408
|
+
if (e) H.current = document.activeElement, requestAnimationFrame(() => {
|
|
409
|
+
ee(!0);
|
|
410
|
+
});
|
|
411
|
+
else {
|
|
412
|
+
L(!0);
|
|
413
|
+
let e = setTimeout(() => {
|
|
414
|
+
L(!1), ee(!1);
|
|
415
|
+
}, 250);
|
|
416
|
+
return () => clearTimeout(e);
|
|
417
|
+
}
|
|
418
|
+
}, [e]), r(() => {
|
|
419
|
+
if (!W) return;
|
|
420
|
+
let e = window.innerWidth - document.documentElement.clientWidth;
|
|
421
|
+
U.current = e;
|
|
422
|
+
let t = document.body.style.overflow, n = document.body.style.paddingRight;
|
|
423
|
+
return document.body.style.overflow = "hidden", e > 0 && (document.body.style.paddingRight = `${e}px`), () => {
|
|
424
|
+
document.body.style.overflow = t, document.body.style.paddingRight = n;
|
|
425
|
+
};
|
|
426
|
+
}, [W]), r(() => {
|
|
427
|
+
if (!W) return;
|
|
428
|
+
let e = setTimeout(() => {
|
|
429
|
+
V.current?.focus();
|
|
430
|
+
}, 50);
|
|
431
|
+
return () => clearTimeout(e);
|
|
432
|
+
}, [W]), r(() => {
|
|
433
|
+
!W && H.current && (H.current.focus(), H.current = null);
|
|
434
|
+
}, [W]), r(() => {
|
|
435
|
+
if (!W || !T) return;
|
|
436
|
+
let e = (e) => {
|
|
437
|
+
e.key === "Escape" && t?.();
|
|
438
|
+
};
|
|
439
|
+
return document.addEventListener("keydown", e), () => document.removeEventListener("keydown", e);
|
|
440
|
+
}, [
|
|
441
|
+
W,
|
|
442
|
+
T,
|
|
443
|
+
t
|
|
444
|
+
]);
|
|
445
|
+
let G = n((e) => {
|
|
446
|
+
w && e.target === e.currentTarget && t?.();
|
|
447
|
+
}, [w, t]), re = n(async () => {
|
|
448
|
+
if (!m) return;
|
|
449
|
+
let e = m();
|
|
450
|
+
if (e instanceof Promise) {
|
|
451
|
+
z(!0);
|
|
452
|
+
try {
|
|
453
|
+
await e, z(!1), t?.();
|
|
454
|
+
} catch {
|
|
455
|
+
z(!1);
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
}, [m, t]), ie = n((e) => {
|
|
459
|
+
if (e.key !== "Tab") return;
|
|
460
|
+
let t = V.current;
|
|
461
|
+
if (!t) return;
|
|
462
|
+
let n = t.querySelectorAll(y);
|
|
463
|
+
if (n.length === 0) {
|
|
464
|
+
e.preventDefault();
|
|
465
|
+
return;
|
|
466
|
+
}
|
|
467
|
+
let r = n[0], i = n[n.length - 1];
|
|
468
|
+
e.shiftKey ? document.activeElement === r && (e.preventDefault(), i.focus()) : document.activeElement === i && (e.preventDefault(), r.focus());
|
|
469
|
+
}, []), K = O ?? v[D] ?? v.md, q = x || R, J = [
|
|
470
|
+
"chain-modal",
|
|
471
|
+
I && !te && "chain-modal--open",
|
|
472
|
+
te && "chain-modal--hidden",
|
|
473
|
+
k && "chain-modal--centered",
|
|
474
|
+
j
|
|
475
|
+
].filter(Boolean).join(" ");
|
|
476
|
+
return !W && E ? null : d(/* @__PURE__ */ u("div", {
|
|
477
|
+
ref: ne,
|
|
478
|
+
className: J,
|
|
479
|
+
style: M,
|
|
480
|
+
role: "dialog",
|
|
481
|
+
"aria-modal": "true",
|
|
482
|
+
"aria-labelledby": a ? F : void 0,
|
|
483
|
+
...N,
|
|
484
|
+
children: [/* @__PURE__ */ l("div", {
|
|
485
|
+
className: "chain-modal__mask",
|
|
486
|
+
onMouseDown: G
|
|
487
|
+
}), /* @__PURE__ */ l("div", {
|
|
488
|
+
className: "chain-modal__wrap",
|
|
489
|
+
children: /* @__PURE__ */ u("div", {
|
|
490
|
+
ref: V,
|
|
491
|
+
className: "chain-modal__content",
|
|
492
|
+
tabIndex: -1,
|
|
493
|
+
style: { width: typeof K == "number" ? `${K}px` : K },
|
|
494
|
+
onKeyDown: ie,
|
|
495
|
+
children: [
|
|
496
|
+
a !== void 0 || S ? /* @__PURE__ */ u("div", {
|
|
497
|
+
className: "chain-modal__header",
|
|
498
|
+
children: [a && /* @__PURE__ */ l("h2", {
|
|
499
|
+
id: F,
|
|
500
|
+
className: "chain-modal__title",
|
|
501
|
+
children: a
|
|
502
|
+
}), S && /* @__PURE__ */ l("button", {
|
|
503
|
+
type: "button",
|
|
504
|
+
className: "chain-modal__close",
|
|
505
|
+
"aria-label": C,
|
|
506
|
+
onClick: t,
|
|
507
|
+
children: "×"
|
|
508
|
+
})]
|
|
509
|
+
}) : null,
|
|
510
|
+
c && /* @__PURE__ */ l("div", {
|
|
511
|
+
className: "chain-modal__body",
|
|
512
|
+
children: c
|
|
513
|
+
}),
|
|
514
|
+
p === void 0 ? p === null ? null : /* @__PURE__ */ u("div", {
|
|
515
|
+
className: "chain-modal__footer",
|
|
516
|
+
children: [/* @__PURE__ */ l(f, {
|
|
517
|
+
...b,
|
|
518
|
+
onClick: t,
|
|
519
|
+
children: _
|
|
520
|
+
}), /* @__PURE__ */ l(f, {
|
|
521
|
+
variant: "solid",
|
|
522
|
+
color: "primary",
|
|
523
|
+
...g,
|
|
524
|
+
loading: q,
|
|
525
|
+
onClick: re,
|
|
526
|
+
children: h
|
|
527
|
+
})]
|
|
528
|
+
}) : p
|
|
529
|
+
]
|
|
530
|
+
})
|
|
531
|
+
})]
|
|
532
|
+
}), A?.() ?? document.body);
|
|
533
|
+
});
|
|
534
|
+
//#endregion
|
|
535
|
+
//#region src/components/table/table.tsx
|
|
536
|
+
function x(e, t, n) {
|
|
537
|
+
if (typeof n == "function") return n(e);
|
|
538
|
+
let r = e[n];
|
|
539
|
+
return String(r ?? t);
|
|
540
|
+
}
|
|
541
|
+
function S(e, t) {
|
|
542
|
+
if (t != null) return Array.isArray(t) ? t.reduce((e, t) => {
|
|
543
|
+
if (typeof e == "object" && e) return e[t];
|
|
544
|
+
}, e) : e[t];
|
|
545
|
+
}
|
|
546
|
+
var C = t(function({ dataSource: e, columns: t, rowKey: r = "key", rowSelection: i, loading: o = !1, emptyText: s = "暂无数据", pagination: c, bordered: d = !0, size: p = "md", locale: m, scroll: h, onRow: g, className: _, style: v, ...y }, b) {
|
|
547
|
+
let C = {
|
|
548
|
+
total: m?.total ?? "共",
|
|
549
|
+
items: m?.items ?? "条",
|
|
550
|
+
prevPage: m?.prevPage ?? "上一页",
|
|
551
|
+
nextPage: m?.nextPage ?? "下一页"
|
|
552
|
+
}, w = i?.type === "radio", T = i != null, E = a(() => i?.selectedRowKeys ?? [], [i?.selectedRowKeys]), D = n(() => {
|
|
553
|
+
if (!i) return;
|
|
554
|
+
let t = e.filter((e) => !i.getCheckboxProps?.(e)?.disabled).map((e, t) => x(e, t, r));
|
|
555
|
+
if (w) return;
|
|
556
|
+
let n = t.every((e) => E.includes(e)), a;
|
|
557
|
+
if (n) a = E.filter((e) => !t.includes(e));
|
|
558
|
+
else {
|
|
559
|
+
let e = new Set(E);
|
|
560
|
+
t.forEach((t) => e.add(t)), a = Array.from(e);
|
|
561
|
+
}
|
|
562
|
+
let o = e.filter((e, t) => a.includes(x(e, t, r)));
|
|
563
|
+
i.onChange?.(a, o), i.onSelect?.(e[0], !n, o);
|
|
564
|
+
}, [
|
|
565
|
+
i,
|
|
566
|
+
e,
|
|
567
|
+
E,
|
|
568
|
+
w,
|
|
569
|
+
r
|
|
570
|
+
]), O = n((t, n) => {
|
|
571
|
+
if (!i) return;
|
|
572
|
+
let a = x(t, n, r), o, s = E.includes(a);
|
|
573
|
+
if (w) {
|
|
574
|
+
if (s) return;
|
|
575
|
+
o = [a];
|
|
576
|
+
} else o = s ? E.filter((e) => e !== a) : [...E, a];
|
|
577
|
+
let c = e.filter((e, t) => o.includes(x(e, t, r)));
|
|
578
|
+
i.onChange?.(o, c), i.onSelect?.(t, !s, c);
|
|
579
|
+
}, [
|
|
580
|
+
i,
|
|
581
|
+
e,
|
|
582
|
+
E,
|
|
583
|
+
w,
|
|
584
|
+
r
|
|
585
|
+
]), k = e.map((e, t) => i?.getCheckboxProps?.(e)?.disabled ? null : x(e, t, r)).filter(Boolean), A = k.length > 0 && k.every((e) => E.includes(e)), j = E.some((e) => k.includes(e)) && !A, M = c ? c.current ?? 1 : 1, N = c ? c.pageSize ?? 10 : 10, P = c ? c.total ?? e.length : e.length, F = Math.max(1, Math.ceil(P / N)), I = n((e) => {
|
|
586
|
+
c && c.onChange?.(e, N);
|
|
587
|
+
}, [c, N]);
|
|
588
|
+
return /* @__PURE__ */ u("div", {
|
|
589
|
+
ref: b,
|
|
590
|
+
className: [
|
|
591
|
+
"chain-table",
|
|
592
|
+
`chain-table--${p}`,
|
|
593
|
+
d && "chain-table--bordered",
|
|
594
|
+
o && "chain-table--loading",
|
|
595
|
+
_
|
|
596
|
+
].filter(Boolean).join(" "),
|
|
597
|
+
style: v,
|
|
598
|
+
role: "table",
|
|
599
|
+
...y,
|
|
600
|
+
children: [
|
|
601
|
+
/* @__PURE__ */ l("div", {
|
|
602
|
+
className: "chain-table__container",
|
|
603
|
+
style: h ? {
|
|
604
|
+
maxHeight: h.y,
|
|
605
|
+
overflow: h.x ? "auto" : void 0
|
|
606
|
+
} : void 0,
|
|
607
|
+
children: /* @__PURE__ */ u("table", {
|
|
608
|
+
className: "chain-table__table",
|
|
609
|
+
children: [
|
|
610
|
+
/* @__PURE__ */ u("colgroup", { children: [T && /* @__PURE__ */ l("col", { style: { width: 48 } }), t.map((e) => /* @__PURE__ */ l("col", { style: { width: e.width } }, e.key))] }),
|
|
611
|
+
/* @__PURE__ */ l("thead", {
|
|
612
|
+
className: "chain-table__header",
|
|
613
|
+
children: /* @__PURE__ */ u("tr", {
|
|
614
|
+
className: "chain-table__header-row",
|
|
615
|
+
children: [T && /* @__PURE__ */ l("th", {
|
|
616
|
+
className: "chain-table__selection chain-table__header-cell",
|
|
617
|
+
role: "columnheader",
|
|
618
|
+
children: !w && /* @__PURE__ */ l("span", {
|
|
619
|
+
className: "chain-table__checkbox",
|
|
620
|
+
children: /* @__PURE__ */ l("input", {
|
|
621
|
+
type: "checkbox",
|
|
622
|
+
checked: A,
|
|
623
|
+
ref: (e) => {
|
|
624
|
+
e && (e.indeterminate = j);
|
|
625
|
+
},
|
|
626
|
+
onChange: D,
|
|
627
|
+
"aria-label": "Select all"
|
|
628
|
+
})
|
|
629
|
+
})
|
|
630
|
+
}), t.map((e) => /* @__PURE__ */ l("th", {
|
|
631
|
+
className: ["chain-table__header-cell", e.align && `chain-table__header-cell--align-${e.align}`].filter(Boolean).join(" "),
|
|
632
|
+
role: "columnheader",
|
|
633
|
+
children: e.title
|
|
634
|
+
}, e.key))]
|
|
635
|
+
})
|
|
636
|
+
}),
|
|
637
|
+
/* @__PURE__ */ l("tbody", {
|
|
638
|
+
className: "chain-table__body",
|
|
639
|
+
children: e.length === 0 ? /* @__PURE__ */ l("tr", {
|
|
640
|
+
className: "chain-table__row",
|
|
641
|
+
children: /* @__PURE__ */ l("td", {
|
|
642
|
+
className: "chain-table__cell chain-table__empty",
|
|
643
|
+
colSpan: t.length + +!!T,
|
|
644
|
+
role: "status",
|
|
645
|
+
"aria-live": "polite",
|
|
646
|
+
children: s
|
|
647
|
+
})
|
|
648
|
+
}) : e.map((e, n) => {
|
|
649
|
+
let a = x(e, n, r), o = E.includes(a), s = i?.getCheckboxProps?.(e)?.disabled ?? !1, c = g?.(e, n);
|
|
650
|
+
return /* @__PURE__ */ u("tr", {
|
|
651
|
+
className: [
|
|
652
|
+
"chain-table__row",
|
|
653
|
+
o && "chain-table__row--selected",
|
|
654
|
+
c?.className
|
|
655
|
+
].filter(Boolean).join(" "),
|
|
656
|
+
role: "row",
|
|
657
|
+
onClick: c?.onClick,
|
|
658
|
+
onDoubleClick: c?.onDoubleClick,
|
|
659
|
+
children: [T && /* @__PURE__ */ l("td", {
|
|
660
|
+
className: "chain-table__selection chain-table__cell",
|
|
661
|
+
role: "cell",
|
|
662
|
+
children: /* @__PURE__ */ l("span", {
|
|
663
|
+
className: "chain-table__checkbox",
|
|
664
|
+
children: /* @__PURE__ */ l("input", {
|
|
665
|
+
type: w ? "radio" : "checkbox",
|
|
666
|
+
name: w ? "chain-table-radio" : void 0,
|
|
667
|
+
checked: o,
|
|
668
|
+
disabled: s,
|
|
669
|
+
onChange: () => O(e, n),
|
|
670
|
+
"aria-label": i.selectAriaLabel ?? "Select row"
|
|
671
|
+
})
|
|
672
|
+
})
|
|
673
|
+
}), t.map((t) => {
|
|
674
|
+
let r = S(e, t.dataIndex), i = t.render ? t.render(r, e, n) : r == null ? "-" : String(r);
|
|
675
|
+
return /* @__PURE__ */ l("td", {
|
|
676
|
+
className: [
|
|
677
|
+
"chain-table__cell",
|
|
678
|
+
t.align && `chain-table__cell--align-${t.align}`,
|
|
679
|
+
t.ellipsis && "chain-table__cell--ellipsis"
|
|
680
|
+
].filter(Boolean).join(" "),
|
|
681
|
+
role: "cell",
|
|
682
|
+
title: t.ellipsis && typeof i == "string" ? i : void 0,
|
|
683
|
+
children: i
|
|
684
|
+
}, t.key);
|
|
685
|
+
})]
|
|
686
|
+
}, a);
|
|
687
|
+
})
|
|
688
|
+
})
|
|
689
|
+
]
|
|
690
|
+
})
|
|
691
|
+
}),
|
|
692
|
+
o && /* @__PURE__ */ l("div", {
|
|
693
|
+
className: "chain-table__loading-overlay",
|
|
694
|
+
children: /* @__PURE__ */ l("span", { className: "chain-table__loading-spinner" })
|
|
695
|
+
}),
|
|
696
|
+
c !== void 0 && c !== !1 && /* @__PURE__ */ u("div", {
|
|
697
|
+
className: "chain-table__pagination",
|
|
698
|
+
children: [/* @__PURE__ */ u("span", {
|
|
699
|
+
className: "chain-table__pagination-total",
|
|
700
|
+
children: [
|
|
701
|
+
C.total,
|
|
702
|
+
" ",
|
|
703
|
+
P,
|
|
704
|
+
" ",
|
|
705
|
+
C.items
|
|
706
|
+
]
|
|
707
|
+
}), /* @__PURE__ */ u("div", {
|
|
708
|
+
className: "chain-table__pagination-nav",
|
|
709
|
+
children: [
|
|
710
|
+
/* @__PURE__ */ l(f, {
|
|
711
|
+
size: "sm",
|
|
712
|
+
disabled: M <= 1,
|
|
713
|
+
onClick: () => I(M - 1),
|
|
714
|
+
children: C.prevPage
|
|
715
|
+
}),
|
|
716
|
+
/* @__PURE__ */ u("span", { children: [
|
|
717
|
+
M,
|
|
718
|
+
" / ",
|
|
719
|
+
F
|
|
720
|
+
] }),
|
|
721
|
+
/* @__PURE__ */ l(f, {
|
|
722
|
+
size: "sm",
|
|
723
|
+
disabled: M >= F,
|
|
724
|
+
onClick: () => I(M + 1),
|
|
725
|
+
children: C.nextPage
|
|
726
|
+
})
|
|
727
|
+
]
|
|
728
|
+
})]
|
|
729
|
+
})
|
|
730
|
+
]
|
|
731
|
+
});
|
|
732
|
+
}), w = t(function({ color: e = "default", variant: t = "light", size: n = "md", closable: r = !1, onClose: i, children: a, className: o, ...s }, c) {
|
|
733
|
+
return /* @__PURE__ */ u("span", {
|
|
734
|
+
ref: c,
|
|
735
|
+
className: [
|
|
736
|
+
"chain-tag",
|
|
737
|
+
`chain-tag--${t}`,
|
|
738
|
+
`chain-tag--${e}`,
|
|
739
|
+
`chain-tag--${n}`,
|
|
740
|
+
r && "chain-tag--closable",
|
|
741
|
+
o
|
|
742
|
+
].filter(Boolean).join(" "),
|
|
743
|
+
...s,
|
|
744
|
+
children: [/* @__PURE__ */ l("span", {
|
|
745
|
+
className: "chain-tag__text",
|
|
746
|
+
children: a
|
|
747
|
+
}), r && /* @__PURE__ */ l("span", {
|
|
748
|
+
className: "chain-tag__close",
|
|
749
|
+
role: "button",
|
|
750
|
+
tabIndex: 0,
|
|
751
|
+
onClick: i,
|
|
752
|
+
onKeyDown: (e) => {
|
|
753
|
+
(e.key === "Enter" || e.key === " ") && (e.preventDefault(), i?.(e));
|
|
754
|
+
},
|
|
755
|
+
"aria-label": "Close",
|
|
756
|
+
children: "×"
|
|
757
|
+
})]
|
|
758
|
+
});
|
|
759
|
+
}), T = t(function({ count: e, dot: t = !1, color: n = "error", size: r = "md", overflowCount: i = 99, showZero: a = !1, offset: o, children: s, className: d, style: f, ...p }, m) {
|
|
760
|
+
let h = !t && e !== void 0 && !a && e === 0, g = e === void 0 && !t, _ = (() => {
|
|
761
|
+
if (t || e === void 0) return null;
|
|
762
|
+
let n = typeof e == "number" ? e : void 0;
|
|
763
|
+
return n !== void 0 && n > i ? `${i}+` : String(e);
|
|
764
|
+
})();
|
|
765
|
+
if (h) return s ? /* @__PURE__ */ l(c, { children: s }) : null;
|
|
766
|
+
let v = /* @__PURE__ */ l("span", {
|
|
767
|
+
className: [
|
|
768
|
+
[
|
|
769
|
+
"chain-badge__content",
|
|
770
|
+
t ? "chain-badge__content--dot" : "chain-badge__content--number",
|
|
771
|
+
!s && `chain-badge__content--${r}`
|
|
772
|
+
].filter(Boolean).join(" "),
|
|
773
|
+
`chain-badge--${n}`,
|
|
774
|
+
s && `chain-badge--${r}`
|
|
775
|
+
].filter(Boolean).join(" "),
|
|
776
|
+
style: o ? {
|
|
777
|
+
marginLeft: o[0],
|
|
778
|
+
marginTop: o[1]
|
|
779
|
+
} : void 0,
|
|
780
|
+
children: _
|
|
781
|
+
}, "badge");
|
|
782
|
+
return s ? /* @__PURE__ */ u("span", {
|
|
783
|
+
ref: m,
|
|
784
|
+
className: ["chain-badge", d].filter(Boolean).join(" "),
|
|
785
|
+
style: f,
|
|
786
|
+
...p,
|
|
787
|
+
children: [s, v]
|
|
788
|
+
}) : /* @__PURE__ */ l("span", {
|
|
789
|
+
ref: m,
|
|
790
|
+
className: ["chain-badge", d].filter(Boolean).join(" "),
|
|
791
|
+
style: f,
|
|
792
|
+
...p,
|
|
793
|
+
children: g ? null : v
|
|
794
|
+
});
|
|
795
|
+
});
|
|
796
|
+
//#endregion
|
|
797
|
+
//#region src/components/pagination/pagination.tsx
|
|
798
|
+
function E(e, t) {
|
|
799
|
+
if (t <= 7) return Array.from({ length: t }, (e, t) => t + 1);
|
|
800
|
+
let n = [];
|
|
801
|
+
n.push(1), e > 3 && n.push("ellipsis");
|
|
802
|
+
let r = Math.max(2, e - 1), i = Math.min(t - 1, e + 1);
|
|
803
|
+
for (let e = r; e <= i; e++) n.push(e);
|
|
804
|
+
return e < t - 2 && n.push("ellipsis"), n.push(t), n;
|
|
805
|
+
}
|
|
806
|
+
var D = t(function({ value: e, defaultValue: t = 1, pageSize: r = 10, total: i = 0, onChange: o, showSizeChanger: c = !1, pageSizeOptions: d = [
|
|
807
|
+
10,
|
|
808
|
+
20,
|
|
809
|
+
50,
|
|
810
|
+
100
|
|
811
|
+
], showQuickJumper: f = !1, showTotal: p = !0, size: m = "md", disabled: h = !1, locale: g, className: _, ...v }, y) {
|
|
812
|
+
let [b, x] = s(t), S = e !== void 0, C = S ? e : b, [w, T] = s(""), [D, O] = s(r), k = S ? r : D, A = {
|
|
813
|
+
total: g?.total ?? "共",
|
|
814
|
+
items: g?.items ?? "条",
|
|
815
|
+
prevPage: g?.prevPage ?? "上一页",
|
|
816
|
+
nextPage: g?.nextPage ?? "下一页",
|
|
817
|
+
jumpTo: g?.jumpTo ?? "前往"
|
|
818
|
+
}, j = Math.max(1, Math.ceil(i / k)), M = Math.max(1, Math.min(C, j)), N = a(() => E(M, j), [M, j]), P = n((e) => {
|
|
819
|
+
if (h) return;
|
|
820
|
+
let t = Math.max(1, Math.min(e, j));
|
|
821
|
+
S || x(t), o?.(t, k);
|
|
822
|
+
}, [
|
|
823
|
+
h,
|
|
824
|
+
j,
|
|
825
|
+
S,
|
|
826
|
+
o,
|
|
827
|
+
k
|
|
828
|
+
]), F = n((e) => {
|
|
829
|
+
if (h) return;
|
|
830
|
+
O(e);
|
|
831
|
+
let t = Math.ceil(i / e), n = Math.min(M, t);
|
|
832
|
+
S || (x(n), O(e)), o?.(n, e);
|
|
833
|
+
}, [
|
|
834
|
+
h,
|
|
835
|
+
i,
|
|
836
|
+
M,
|
|
837
|
+
S,
|
|
838
|
+
o
|
|
839
|
+
]), I = n(() => {
|
|
840
|
+
let e = parseInt(w, 10);
|
|
841
|
+
isNaN(e) || (P(e), T(""));
|
|
842
|
+
}, [w, P]);
|
|
843
|
+
return /* @__PURE__ */ u("div", {
|
|
844
|
+
ref: y,
|
|
845
|
+
className: [
|
|
846
|
+
"chain-pagination",
|
|
847
|
+
`chain-pagination--${m}`,
|
|
848
|
+
h && "chain-pagination--disabled",
|
|
849
|
+
_
|
|
850
|
+
].filter(Boolean).join(" "),
|
|
851
|
+
...v,
|
|
852
|
+
children: [
|
|
853
|
+
p && /* @__PURE__ */ u("span", {
|
|
854
|
+
className: "chain-pagination__total",
|
|
855
|
+
children: [
|
|
856
|
+
A.total,
|
|
857
|
+
" ",
|
|
858
|
+
i,
|
|
859
|
+
" ",
|
|
860
|
+
A.items
|
|
861
|
+
]
|
|
862
|
+
}),
|
|
863
|
+
/* @__PURE__ */ u("ul", {
|
|
864
|
+
className: "chain-pagination__list",
|
|
865
|
+
children: [
|
|
866
|
+
/* @__PURE__ */ l("li", {
|
|
867
|
+
className: ["chain-pagination__prev", (h || M <= 1) && "chain-pagination__item--disabled"].filter(Boolean).join(" "),
|
|
868
|
+
children: /* @__PURE__ */ l("button", {
|
|
869
|
+
type: "button",
|
|
870
|
+
disabled: h || M <= 1,
|
|
871
|
+
onClick: () => P(M - 1),
|
|
872
|
+
children: A.prevPage
|
|
873
|
+
})
|
|
874
|
+
}),
|
|
875
|
+
N.map((e, t) => e === "ellipsis" ? /* @__PURE__ */ l("li", {
|
|
876
|
+
className: "chain-pagination__item chain-pagination__item--disabled",
|
|
877
|
+
children: /* @__PURE__ */ l("span", { children: "..." })
|
|
878
|
+
}, `ellipsis-${t}`) : /* @__PURE__ */ l("li", {
|
|
879
|
+
className: ["chain-pagination__item", e === M && "chain-pagination__item--active"].filter(Boolean).join(" "),
|
|
880
|
+
children: /* @__PURE__ */ l("button", {
|
|
881
|
+
type: "button",
|
|
882
|
+
disabled: h,
|
|
883
|
+
onClick: () => P(e),
|
|
884
|
+
children: e
|
|
885
|
+
})
|
|
886
|
+
}, e)),
|
|
887
|
+
/* @__PURE__ */ l("li", {
|
|
888
|
+
className: ["chain-pagination__next", (h || M >= j) && "chain-pagination__item--disabled"].filter(Boolean).join(" "),
|
|
889
|
+
children: /* @__PURE__ */ l("button", {
|
|
890
|
+
type: "button",
|
|
891
|
+
disabled: h || M >= j,
|
|
892
|
+
onClick: () => P(M + 1),
|
|
893
|
+
children: A.nextPage
|
|
894
|
+
})
|
|
895
|
+
})
|
|
896
|
+
]
|
|
897
|
+
}),
|
|
898
|
+
c && /* @__PURE__ */ l("select", {
|
|
899
|
+
className: "chain-pagination__size-changer",
|
|
900
|
+
value: k,
|
|
901
|
+
disabled: h,
|
|
902
|
+
onChange: (e) => F(Number(e.target.value)),
|
|
903
|
+
children: d.map((e) => /* @__PURE__ */ u("option", {
|
|
904
|
+
value: e,
|
|
905
|
+
children: [
|
|
906
|
+
e,
|
|
907
|
+
" ",
|
|
908
|
+
A.items
|
|
909
|
+
]
|
|
910
|
+
}, e))
|
|
911
|
+
}),
|
|
912
|
+
f && /* @__PURE__ */ u("div", {
|
|
913
|
+
className: "chain-pagination__jump",
|
|
914
|
+
children: [/* @__PURE__ */ l("input", {
|
|
915
|
+
type: "text",
|
|
916
|
+
value: w,
|
|
917
|
+
disabled: h,
|
|
918
|
+
onChange: (e) => T(e.target.value),
|
|
919
|
+
onKeyDown: (e) => {
|
|
920
|
+
e.key === "Enter" && I();
|
|
921
|
+
},
|
|
922
|
+
placeholder: ""
|
|
923
|
+
}), /* @__PURE__ */ l("button", {
|
|
924
|
+
type: "button",
|
|
925
|
+
disabled: h,
|
|
926
|
+
onClick: I,
|
|
927
|
+
children: A.jumpTo
|
|
928
|
+
})]
|
|
929
|
+
})
|
|
930
|
+
]
|
|
931
|
+
});
|
|
932
|
+
}), O = {
|
|
933
|
+
success: "✓",
|
|
934
|
+
warning: "!",
|
|
935
|
+
error: "✗",
|
|
936
|
+
info: "ℹ"
|
|
937
|
+
}, k = t(function({ color: e = "info", size: t = "md", message: n, description: r, showIcon: i = !0, closable: a = !1, closeAriaLabel: o = "Close", onClose: s, open: c = !0, action: d, children: f, className: p, ...m }, h) {
|
|
938
|
+
return c ? /* @__PURE__ */ u("div", {
|
|
939
|
+
ref: h,
|
|
940
|
+
className: [
|
|
941
|
+
"chain-alert",
|
|
942
|
+
`chain-alert--${e}`,
|
|
943
|
+
`chain-alert--${t}`,
|
|
944
|
+
a && "chain-alert--closable",
|
|
945
|
+
p
|
|
946
|
+
].filter(Boolean).join(" "),
|
|
947
|
+
role: "alert",
|
|
948
|
+
...m,
|
|
949
|
+
children: [
|
|
950
|
+
i && /* @__PURE__ */ l("span", {
|
|
951
|
+
className: "chain-alert__icon",
|
|
952
|
+
"aria-hidden": "true",
|
|
953
|
+
children: O[e]
|
|
954
|
+
}),
|
|
955
|
+
/* @__PURE__ */ u("div", {
|
|
956
|
+
className: "chain-alert__content",
|
|
957
|
+
children: [
|
|
958
|
+
/* @__PURE__ */ l("div", {
|
|
959
|
+
className: "chain-alert__message",
|
|
960
|
+
children: n
|
|
961
|
+
}),
|
|
962
|
+
r && /* @__PURE__ */ l("div", {
|
|
963
|
+
className: "chain-alert__description",
|
|
964
|
+
children: r
|
|
965
|
+
}),
|
|
966
|
+
f
|
|
967
|
+
]
|
|
968
|
+
}),
|
|
969
|
+
d && /* @__PURE__ */ l("div", {
|
|
970
|
+
className: "chain-alert__action",
|
|
971
|
+
children: d
|
|
972
|
+
}),
|
|
973
|
+
a && /* @__PURE__ */ l("button", {
|
|
974
|
+
type: "button",
|
|
975
|
+
className: "chain-alert__close",
|
|
976
|
+
"aria-label": o,
|
|
977
|
+
onClick: s,
|
|
978
|
+
children: "×"
|
|
979
|
+
})
|
|
980
|
+
]
|
|
981
|
+
}) : null;
|
|
982
|
+
}), A = {
|
|
983
|
+
sm: "var(--space-1)",
|
|
984
|
+
md: "var(--space-2)",
|
|
985
|
+
lg: "var(--space-4)"
|
|
986
|
+
}, j = t(function({ size: e = "md", direction: t = "horizontal", align: n = "center", wrap: r = !1, children: i, className: a, style: o, ...s }, c) {
|
|
987
|
+
let u = typeof e == "number" ? `${e}px` : A[e] ?? A.md;
|
|
988
|
+
return /* @__PURE__ */ l("div", {
|
|
989
|
+
ref: c,
|
|
990
|
+
className: [
|
|
991
|
+
"chain-space",
|
|
992
|
+
`chain-space--${t}`,
|
|
993
|
+
`chain-space--align-${n}`,
|
|
994
|
+
r && "chain-space--wrap",
|
|
995
|
+
a
|
|
996
|
+
].filter(Boolean).join(" "),
|
|
997
|
+
style: {
|
|
998
|
+
gap: u,
|
|
999
|
+
...o
|
|
1000
|
+
},
|
|
1001
|
+
...s,
|
|
1002
|
+
children: i
|
|
1003
|
+
});
|
|
1004
|
+
}), M = t(function({ orientation: e = "horizontal", type: t = "solid", size: n = "md", children: r, className: i, ...a }, o) {
|
|
1005
|
+
return e === "vertical" ? /* @__PURE__ */ l("hr", {
|
|
1006
|
+
ref: o,
|
|
1007
|
+
className: [
|
|
1008
|
+
"chain-divider",
|
|
1009
|
+
"chain-divider--vertical",
|
|
1010
|
+
`chain-divider--${t}`,
|
|
1011
|
+
`chain-divider--${n}`,
|
|
1012
|
+
i
|
|
1013
|
+
].filter(Boolean).join(" "),
|
|
1014
|
+
role: "separator",
|
|
1015
|
+
"aria-orientation": "vertical",
|
|
1016
|
+
...a
|
|
1017
|
+
}) : r ? /* @__PURE__ */ u("div", {
|
|
1018
|
+
ref: o,
|
|
1019
|
+
className: [
|
|
1020
|
+
"chain-divider",
|
|
1021
|
+
"chain-divider--horizontal",
|
|
1022
|
+
`chain-divider--${t}`,
|
|
1023
|
+
`chain-divider--${n}`,
|
|
1024
|
+
"chain-divider--with-text",
|
|
1025
|
+
i
|
|
1026
|
+
].filter(Boolean).join(" "),
|
|
1027
|
+
role: "separator",
|
|
1028
|
+
...a,
|
|
1029
|
+
children: [
|
|
1030
|
+
/* @__PURE__ */ l("span", { className: "chain-divider__line" }),
|
|
1031
|
+
/* @__PURE__ */ l("span", {
|
|
1032
|
+
className: "chain-divider__text",
|
|
1033
|
+
children: r
|
|
1034
|
+
}),
|
|
1035
|
+
/* @__PURE__ */ l("span", { className: "chain-divider__line" })
|
|
1036
|
+
]
|
|
1037
|
+
}) : /* @__PURE__ */ l("hr", {
|
|
1038
|
+
ref: o,
|
|
1039
|
+
className: [
|
|
1040
|
+
"chain-divider",
|
|
1041
|
+
"chain-divider--horizontal",
|
|
1042
|
+
`chain-divider--${t}`,
|
|
1043
|
+
`chain-divider--${n}`,
|
|
1044
|
+
i
|
|
1045
|
+
].filter(Boolean).join(" "),
|
|
1046
|
+
role: "separator",
|
|
1047
|
+
...a
|
|
1048
|
+
});
|
|
1049
|
+
});
|
|
1050
|
+
//#endregion
|
|
1051
|
+
export { k as Alert, T as Badge, f as Button, M as Divider, h as FormItem, p as Input, b as Modal, D as Pagination, _ as Select, j as Space, C as Table, w as Tag };
|