@vustcc/react 0.1.0-alpha.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/CHANGELOG.md +14 -0
- package/LICENSE +21 -0
- package/README.md +85 -0
- package/dist/components/VustActionMenu/VustActionMenu.d.ts +20 -0
- package/dist/components/VustAlert/VustAlert.d.ts +20 -0
- package/dist/components/VustBreadcrumb/VustBreadcrumb.d.ts +7 -0
- package/dist/components/VustBreadcrumbItem/VustBreadcrumbItem.d.ts +6 -0
- package/dist/components/VustButton/VustButton.d.ts +10 -0
- package/dist/components/VustCard/VustCard.d.ts +16 -0
- package/dist/components/VustCheckbox/VustCheckbox.d.ts +16 -0
- package/dist/components/VustDateTimeRangePicker/VustDateTimeRangePicker.d.ts +44 -0
- package/dist/components/VustDescriptions/VustDescriptions.d.ts +23 -0
- package/dist/components/VustDialog/VustDialog.d.ts +20 -0
- package/dist/components/VustDrawer/VustDrawer.d.ts +18 -0
- package/dist/components/VustEmpty/VustEmpty.d.ts +14 -0
- package/dist/components/VustFormItem/VustFormItem.d.ts +15 -0
- package/dist/components/VustIcon/VustIcon.d.ts +10 -0
- package/dist/components/VustInput/VustInput.d.ts +40 -0
- package/dist/components/VustLoading/VustLoading.d.ts +10 -0
- package/dist/components/VustMenu/VustMenu.d.ts +19 -0
- package/dist/components/VustModal/VustModal.d.ts +20 -0
- package/dist/components/VustPagination/VustPagination.d.ts +15 -0
- package/dist/components/VustSelect/VustSelect.d.ts +33 -0
- package/dist/components/VustSelectionBar/VustSelectionBar.d.ts +18 -0
- package/dist/components/VustSwitch/VustSwitch.d.ts +8 -0
- package/dist/components/VustTable/VustTable.d.ts +59 -0
- package/dist/components/VustTabs/VustTabs.d.ts +15 -0
- package/dist/components/VustTag/VustTag.d.ts +8 -0
- package/dist/components/VustToast/VustToast.d.ts +16 -0
- package/dist/components/VustTooltip/VustTooltip.d.ts +15 -0
- package/dist/index.d.ts +54 -0
- package/dist/index.js +1513 -0
- package/dist/internal/floating-position.d.ts +15 -0
- package/dist/internal/modal-lifecycle.d.ts +1 -0
- package/dist/style.css +2 -0
- package/package.json +50 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,1513 @@
|
|
|
1
|
+
import { createContext as e, useCallback as t, useContext as n, useEffect as r, useId as i, useLayoutEffect as a, useMemo as o, useRef as s, useState as c } from "react";
|
|
2
|
+
import { getIcon as l } from "@vustcc/icons";
|
|
3
|
+
import { jsx as u, jsxs as d } from "react/jsx-runtime";
|
|
4
|
+
import { createPortal as f } from "react-dom";
|
|
5
|
+
//#region src/components/VustIcon/VustIcon.tsx
|
|
6
|
+
var p = ({ name: e = "fallback", namespace: t = "common", size: n = 24, label: r = "", decorative: i = !0, className: a = "", style: s, ...c }) => {
|
|
7
|
+
let d = o(() => {
|
|
8
|
+
let t = (e ?? "").trim().toLowerCase();
|
|
9
|
+
return /^[a-z0-9-]+$/.test(t) ? t : "fallback";
|
|
10
|
+
}, [e]), f = o(() => l(d, t), [d, t]), p = {
|
|
11
|
+
"--vl-icon-size": o(() => typeof n == "number" ? `${n}px` : n, [n]),
|
|
12
|
+
...s
|
|
13
|
+
};
|
|
14
|
+
return /* @__PURE__ */ u("span", {
|
|
15
|
+
className: `vl-icon ${a}`.trim(),
|
|
16
|
+
style: p,
|
|
17
|
+
"aria-hidden": i ? "true" : void 0,
|
|
18
|
+
role: i ? void 0 : "img",
|
|
19
|
+
"aria-label": i ? void 0 : r || d,
|
|
20
|
+
dangerouslySetInnerHTML: { __html: f },
|
|
21
|
+
...c
|
|
22
|
+
});
|
|
23
|
+
}, m = ({ type: e = "secondary", size: t = "default", disabled: n = !1, loading: r = !1, onClick: i, className: a = "", children: o, ...s }) => {
|
|
24
|
+
let c = (e) => {
|
|
25
|
+
n || r || i?.(e);
|
|
26
|
+
}, l = n || r;
|
|
27
|
+
return /* @__PURE__ */ d("button", {
|
|
28
|
+
className: `vl-button vl-button--${e} vl-button--${t} ${r ? "is-loading" : ""} ${a}`.trim(),
|
|
29
|
+
disabled: l,
|
|
30
|
+
type: "button",
|
|
31
|
+
onClick: c,
|
|
32
|
+
...s,
|
|
33
|
+
children: [r && /* @__PURE__ */ u("span", {
|
|
34
|
+
className: "vl-button-loading-icon",
|
|
35
|
+
children: /* @__PURE__ */ u("svg", {
|
|
36
|
+
className: "vl-spinner",
|
|
37
|
+
viewBox: "0 0 50 50",
|
|
38
|
+
children: /* @__PURE__ */ u("circle", {
|
|
39
|
+
className: "path",
|
|
40
|
+
cx: "25",
|
|
41
|
+
cy: "25",
|
|
42
|
+
r: "20",
|
|
43
|
+
fill: "none",
|
|
44
|
+
strokeWidth: "5"
|
|
45
|
+
})
|
|
46
|
+
})
|
|
47
|
+
}), /* @__PURE__ */ u("span", {
|
|
48
|
+
className: "vl-button-content",
|
|
49
|
+
children: o
|
|
50
|
+
})]
|
|
51
|
+
});
|
|
52
|
+
}, h = ({ value: e, onChange: t, activeText: n = "", disabled: r = !1, className: i = "", ...a }) => /* @__PURE__ */ d("button", {
|
|
53
|
+
type: "button",
|
|
54
|
+
className: `vl-switch ${e ? "is-active" : ""} ${r ? "is-disabled" : ""} ${i}`.trim(),
|
|
55
|
+
onClick: () => {
|
|
56
|
+
r || t?.(!e);
|
|
57
|
+
},
|
|
58
|
+
role: "switch",
|
|
59
|
+
"aria-checked": e,
|
|
60
|
+
disabled: r,
|
|
61
|
+
...a,
|
|
62
|
+
children: [/* @__PURE__ */ u("div", {
|
|
63
|
+
className: "vl-switch-track",
|
|
64
|
+
children: /* @__PURE__ */ u("div", { className: "vl-switch-handle" })
|
|
65
|
+
}), n && /* @__PURE__ */ u("span", {
|
|
66
|
+
className: "vl-switch-label",
|
|
67
|
+
children: n
|
|
68
|
+
})]
|
|
69
|
+
}), g = ({ title: e, description: t, type: n = "info", showIcon: r = !1, closable: i = !1, onClose: a, closeLabel: o = "Close alert", className: s = "", children: l, ...f }) => {
|
|
70
|
+
let [m, h] = c(!0);
|
|
71
|
+
if (!m) return null;
|
|
72
|
+
let g = (e) => {
|
|
73
|
+
h(!1), a?.();
|
|
74
|
+
}, _ = (e) => e === "success" ? "success" : e === "error" ? "error" : e === "warning" ? "warning" : "info";
|
|
75
|
+
return /* @__PURE__ */ d("div", {
|
|
76
|
+
className: `vl-alert is-${n} ${s}`.trim(),
|
|
77
|
+
role: "alert",
|
|
78
|
+
...f,
|
|
79
|
+
children: [
|
|
80
|
+
r && /* @__PURE__ */ u("div", {
|
|
81
|
+
className: "vl-alert-icon",
|
|
82
|
+
children: /* @__PURE__ */ u(p, {
|
|
83
|
+
name: _(n),
|
|
84
|
+
size: 16
|
|
85
|
+
})
|
|
86
|
+
}),
|
|
87
|
+
/* @__PURE__ */ d("div", {
|
|
88
|
+
className: "vl-alert-content",
|
|
89
|
+
children: [e && /* @__PURE__ */ u("h4", {
|
|
90
|
+
className: "vl-alert-title",
|
|
91
|
+
children: e
|
|
92
|
+
}), /* @__PURE__ */ u("div", {
|
|
93
|
+
className: "vl-alert-description",
|
|
94
|
+
children: l || t
|
|
95
|
+
})]
|
|
96
|
+
}),
|
|
97
|
+
i && /* @__PURE__ */ u("button", {
|
|
98
|
+
type: "button",
|
|
99
|
+
className: "vl-alert-close",
|
|
100
|
+
"aria-label": o,
|
|
101
|
+
onClick: g,
|
|
102
|
+
children: "×"
|
|
103
|
+
})
|
|
104
|
+
]
|
|
105
|
+
});
|
|
106
|
+
}, _ = ({ shadow: e = "always", contentStyle: t, contentRole: n = "content", fullHeight: r = !1, header: i, className: a = "", children: o, ...s }) => /* @__PURE__ */ d("div", {
|
|
107
|
+
className: `vl-card is-shadow-${e} ${r ? "is-full-height" : ""} ${a}`.trim(),
|
|
108
|
+
...s,
|
|
109
|
+
children: [i && /* @__PURE__ */ u("div", {
|
|
110
|
+
className: "vl-card-header",
|
|
111
|
+
children: i
|
|
112
|
+
}), /* @__PURE__ */ u("div", {
|
|
113
|
+
className: `${n === "header" ? "vl-card-header" : "vl-card-content"} ${r ? "is-full-height" : ""}`.trim(),
|
|
114
|
+
style: t,
|
|
115
|
+
children: o
|
|
116
|
+
})]
|
|
117
|
+
}), v = ({ checked: e, disabled: t = !1, onChange: n, indeterminate: a = !1, id: o, name: c, ariaLabel: l, ariaLabelledby: f, ariaDescribedby: p, className: m = "", children: h, ...g }) => {
|
|
118
|
+
let _ = s(null), v = i(), y = o ?? v;
|
|
119
|
+
r(() => {
|
|
120
|
+
_.current && (_.current.indeterminate = a);
|
|
121
|
+
}, [a]);
|
|
122
|
+
let b = (e) => {
|
|
123
|
+
t || n?.(e.target.checked);
|
|
124
|
+
};
|
|
125
|
+
return /* @__PURE__ */ d("label", {
|
|
126
|
+
htmlFor: y,
|
|
127
|
+
className: `vl-checkbox ${e ? "is-active" : ""} ${a ? "is-indeterminate" : ""} ${t ? "is-disabled" : ""} ${m}`.trim(),
|
|
128
|
+
...g,
|
|
129
|
+
children: [/* @__PURE__ */ d("span", {
|
|
130
|
+
className: "vl-checkbox-input",
|
|
131
|
+
children: [/* @__PURE__ */ u("input", {
|
|
132
|
+
ref: _,
|
|
133
|
+
id: y,
|
|
134
|
+
name: c,
|
|
135
|
+
type: "checkbox",
|
|
136
|
+
className: "vl-checkbox-original",
|
|
137
|
+
checked: e,
|
|
138
|
+
disabled: t,
|
|
139
|
+
"aria-label": l,
|
|
140
|
+
"aria-labelledby": f,
|
|
141
|
+
"aria-describedby": p,
|
|
142
|
+
onChange: b,
|
|
143
|
+
"aria-checked": a ? "mixed" : e
|
|
144
|
+
}), /* @__PURE__ */ u("span", { className: "vl-checkbox-inner" })]
|
|
145
|
+
}), h && /* @__PURE__ */ u("span", {
|
|
146
|
+
className: "vl-checkbox-label",
|
|
147
|
+
children: h
|
|
148
|
+
})]
|
|
149
|
+
});
|
|
150
|
+
}, y = ({ description: e = "暂无数据", icon: t = "empty", iconNode: n, extra: r, className: i = "", children: a, ...o }) => /* @__PURE__ */ d("div", {
|
|
151
|
+
className: `vl-empty ${i}`.trim(),
|
|
152
|
+
...o,
|
|
153
|
+
children: [
|
|
154
|
+
/* @__PURE__ */ u("div", {
|
|
155
|
+
className: "vl-empty-icon",
|
|
156
|
+
children: n || /* @__PURE__ */ u(p, {
|
|
157
|
+
name: t,
|
|
158
|
+
size: 48
|
|
159
|
+
})
|
|
160
|
+
}),
|
|
161
|
+
/* @__PURE__ */ u("p", {
|
|
162
|
+
className: "vl-empty-description",
|
|
163
|
+
children: a || e
|
|
164
|
+
}),
|
|
165
|
+
r && /* @__PURE__ */ u("div", {
|
|
166
|
+
className: "vl-empty-extra",
|
|
167
|
+
children: r
|
|
168
|
+
})
|
|
169
|
+
]
|
|
170
|
+
}), b = ({ label: e, required: t = !1, hint: n, htmlFor: r, error: a, labelId: o, hintId: s, errorId: c, className: l = "", children: f, ...p }) => {
|
|
171
|
+
let m = i(), h = o ?? `${m}-label`, g = s ?? `${m}-hint`, _ = c ?? `${m}-error`;
|
|
172
|
+
return /* @__PURE__ */ d("div", {
|
|
173
|
+
className: `vl-form-item ${l}`.trim(),
|
|
174
|
+
...p,
|
|
175
|
+
children: [e && /* @__PURE__ */ d("label", {
|
|
176
|
+
id: h,
|
|
177
|
+
className: "vl-form-item-label",
|
|
178
|
+
htmlFor: r,
|
|
179
|
+
children: [t && /* @__PURE__ */ u("span", {
|
|
180
|
+
className: "vl-form-item-required",
|
|
181
|
+
children: "*"
|
|
182
|
+
}), e]
|
|
183
|
+
}), /* @__PURE__ */ d("div", {
|
|
184
|
+
className: "vl-form-item-content",
|
|
185
|
+
children: [
|
|
186
|
+
f,
|
|
187
|
+
n && /* @__PURE__ */ u("div", {
|
|
188
|
+
id: g,
|
|
189
|
+
className: "vl-form-item-hint",
|
|
190
|
+
children: n
|
|
191
|
+
}),
|
|
192
|
+
a && /* @__PURE__ */ u("div", {
|
|
193
|
+
id: _,
|
|
194
|
+
className: "vl-form-item-error",
|
|
195
|
+
role: "alert",
|
|
196
|
+
children: a
|
|
197
|
+
})
|
|
198
|
+
]
|
|
199
|
+
})]
|
|
200
|
+
});
|
|
201
|
+
}, x = ({ loading: e, text: t, cover: n = !1, className: r = "", children: i, ...a }) => /* @__PURE__ */ d("div", {
|
|
202
|
+
className: `vl-loading-host ${n ? "is-cover" : ""} ${e ? "is-loading" : ""} ${r}`.trim(),
|
|
203
|
+
"aria-busy": e,
|
|
204
|
+
...a,
|
|
205
|
+
children: [i, e && /* @__PURE__ */ u("div", {
|
|
206
|
+
className: "vl-loading-mask",
|
|
207
|
+
role: "status",
|
|
208
|
+
"aria-live": "polite",
|
|
209
|
+
children: /* @__PURE__ */ d("div", {
|
|
210
|
+
className: "vl-loading-spinner",
|
|
211
|
+
children: [/* @__PURE__ */ u("svg", {
|
|
212
|
+
className: "vl-spinner",
|
|
213
|
+
viewBox: "0 0 50 50",
|
|
214
|
+
children: /* @__PURE__ */ u("circle", {
|
|
215
|
+
className: "path",
|
|
216
|
+
cx: "25",
|
|
217
|
+
cy: "25",
|
|
218
|
+
r: "20",
|
|
219
|
+
fill: "none",
|
|
220
|
+
strokeWidth: "5"
|
|
221
|
+
})
|
|
222
|
+
}), t && /* @__PURE__ */ u("p", {
|
|
223
|
+
className: "vl-loading-text",
|
|
224
|
+
children: t
|
|
225
|
+
})]
|
|
226
|
+
})
|
|
227
|
+
})]
|
|
228
|
+
}), S = ({ type: e = "default", effect: t = "light", className: n = "", children: r, ...i }) => /* @__PURE__ */ u("span", {
|
|
229
|
+
className: `vl-tag vl-tag--${e} vl-tag--${t} ${n}`.trim(),
|
|
230
|
+
...i,
|
|
231
|
+
children: r
|
|
232
|
+
}), C = e("/"), w = ({ separator: e = "/", className: t = "", children: n, ...r }) => /* @__PURE__ */ u(C.Provider, {
|
|
233
|
+
value: e,
|
|
234
|
+
children: /* @__PURE__ */ u("nav", {
|
|
235
|
+
className: `vl-breadcrumb ${t}`.trim(),
|
|
236
|
+
"aria-label": "Breadcrumb",
|
|
237
|
+
...r,
|
|
238
|
+
children: n
|
|
239
|
+
})
|
|
240
|
+
}), T = ({ className: e = "", children: t, ...r }) => {
|
|
241
|
+
let i = n(C);
|
|
242
|
+
return /* @__PURE__ */ d("span", {
|
|
243
|
+
className: `vl-breadcrumb-item ${e}`.trim(),
|
|
244
|
+
...r,
|
|
245
|
+
children: [/* @__PURE__ */ u("span", {
|
|
246
|
+
className: "vl-breadcrumb-label",
|
|
247
|
+
children: t
|
|
248
|
+
}), /* @__PURE__ */ u("span", {
|
|
249
|
+
className: "vl-breadcrumb-separator",
|
|
250
|
+
role: "presentation",
|
|
251
|
+
children: i
|
|
252
|
+
})]
|
|
253
|
+
});
|
|
254
|
+
};
|
|
255
|
+
//#endregion
|
|
256
|
+
//#region src/components/VustInput/VustInput.tsx
|
|
257
|
+
function E({ value: e, type: t = "text", placeholder: n, disabled: r = !1, readOnly: a, maxLength: o, rows: s = 3, showPassword: l = !1, min: f, max: m, step: h, autoComplete: g, onChange: _, onFocus: v, onBlur: y, invalid: b = !1, id: x, name: S, ariaLabel: C, ariaLabelledby: w, ariaDescribedby: T, className: E = "", ...D }) {
|
|
258
|
+
let [O, k] = c(!1), A = i(), j = x ?? A, M = (e) => {
|
|
259
|
+
let n = t === "number" ? e.target.value === "" ? null : Number(e.target.value) : e.target.value;
|
|
260
|
+
_?.(n);
|
|
261
|
+
}, N = () => {
|
|
262
|
+
k((e) => !e);
|
|
263
|
+
}, P = t === "password" && O ? "text" : t, F = e == null ? "" : String(e);
|
|
264
|
+
return /* @__PURE__ */ u("div", {
|
|
265
|
+
className: `vl-input-wrapper is-${t} ${r ? "is-disabled" : ""} ${E}`.trim(),
|
|
266
|
+
...D,
|
|
267
|
+
children: t === "textarea" ? /* @__PURE__ */ u("textarea", {
|
|
268
|
+
className: "vl-textarea",
|
|
269
|
+
id: j,
|
|
270
|
+
name: S,
|
|
271
|
+
"aria-label": C,
|
|
272
|
+
"aria-labelledby": w,
|
|
273
|
+
"aria-describedby": T,
|
|
274
|
+
value: F,
|
|
275
|
+
placeholder: n,
|
|
276
|
+
disabled: r,
|
|
277
|
+
readOnly: a,
|
|
278
|
+
maxLength: o,
|
|
279
|
+
rows: s,
|
|
280
|
+
onChange: M,
|
|
281
|
+
onFocus: v,
|
|
282
|
+
onBlur: y,
|
|
283
|
+
"aria-invalid": b || void 0
|
|
284
|
+
}) : /* @__PURE__ */ d("div", {
|
|
285
|
+
className: "vl-input-inner-wrapper",
|
|
286
|
+
children: [/* @__PURE__ */ u("input", {
|
|
287
|
+
className: "vl-input",
|
|
288
|
+
id: j,
|
|
289
|
+
name: S,
|
|
290
|
+
"aria-label": C,
|
|
291
|
+
"aria-labelledby": w,
|
|
292
|
+
"aria-describedby": T,
|
|
293
|
+
type: P,
|
|
294
|
+
value: F,
|
|
295
|
+
placeholder: n,
|
|
296
|
+
disabled: r,
|
|
297
|
+
readOnly: a,
|
|
298
|
+
maxLength: o,
|
|
299
|
+
min: f,
|
|
300
|
+
max: m,
|
|
301
|
+
step: h,
|
|
302
|
+
autoComplete: g,
|
|
303
|
+
onChange: M,
|
|
304
|
+
onFocus: v,
|
|
305
|
+
onBlur: y,
|
|
306
|
+
"aria-invalid": b || void 0
|
|
307
|
+
}), l && t === "password" && /* @__PURE__ */ u("button", {
|
|
308
|
+
type: "button",
|
|
309
|
+
className: "vl-input-password-toggle",
|
|
310
|
+
onClick: N,
|
|
311
|
+
disabled: r,
|
|
312
|
+
"aria-label": O ? "Hide password" : "Show password",
|
|
313
|
+
"aria-pressed": O,
|
|
314
|
+
children: /* @__PURE__ */ u(p, {
|
|
315
|
+
name: O ? "eye-off" : "lock",
|
|
316
|
+
size: 16
|
|
317
|
+
})
|
|
318
|
+
})]
|
|
319
|
+
})
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
//#endregion
|
|
323
|
+
//#region src/components/VustMenu/VustMenu.tsx
|
|
324
|
+
var D = ({ value: e, items: t = [], onChange: n, className: r = "", ...i }) => {
|
|
325
|
+
let a = s(null), o = (e) => {
|
|
326
|
+
n?.(e);
|
|
327
|
+
};
|
|
328
|
+
return /* @__PURE__ */ u("nav", {
|
|
329
|
+
ref: a,
|
|
330
|
+
className: `vl-menu ${r}`.trim(),
|
|
331
|
+
"aria-label": "Menu",
|
|
332
|
+
onKeyDown: (e) => {
|
|
333
|
+
if (![
|
|
334
|
+
"ArrowDown",
|
|
335
|
+
"ArrowUp",
|
|
336
|
+
"Home",
|
|
337
|
+
"End"
|
|
338
|
+
].includes(e.key)) return;
|
|
339
|
+
let t = [...a.current?.querySelectorAll(".vl-menu-item-button") ?? []], n = t.indexOf(document.activeElement), r = e.key === "Home" ? 0 : e.key === "End" ? t.length - 1 : (n + (e.key === "ArrowDown" ? 1 : -1) + t.length) % t.length;
|
|
340
|
+
e.preventDefault(), t[r]?.focus();
|
|
341
|
+
},
|
|
342
|
+
...i,
|
|
343
|
+
children: t.map((t) => /* @__PURE__ */ d("div", {
|
|
344
|
+
className: "vl-menu-group",
|
|
345
|
+
children: [/* @__PURE__ */ u("div", {
|
|
346
|
+
className: "vl-menu-group-title",
|
|
347
|
+
children: t.label
|
|
348
|
+
}), /* @__PURE__ */ u("ul", {
|
|
349
|
+
className: "vl-menu-items",
|
|
350
|
+
children: t.children.map((t) => /* @__PURE__ */ u("li", {
|
|
351
|
+
className: `vl-menu-item ${e === t.key ? "is-active" : ""}`.trim(),
|
|
352
|
+
children: /* @__PURE__ */ u("button", {
|
|
353
|
+
type: "button",
|
|
354
|
+
className: "vl-menu-item-button",
|
|
355
|
+
"aria-current": e === t.key ? "page" : void 0,
|
|
356
|
+
onClick: () => o(t.key),
|
|
357
|
+
children: /* @__PURE__ */ u("span", {
|
|
358
|
+
className: "vl-menu-item-label",
|
|
359
|
+
children: t.label
|
|
360
|
+
})
|
|
361
|
+
})
|
|
362
|
+
}, t.key))
|
|
363
|
+
})]
|
|
364
|
+
}, t.key))
|
|
365
|
+
});
|
|
366
|
+
}, O = ({ value: e, tabs: t = [], onChange: n, className: r = "", ...i }) => {
|
|
367
|
+
let a = (e) => {
|
|
368
|
+
e.disabled || n?.(e.name);
|
|
369
|
+
}, o = (e, n) => {
|
|
370
|
+
if (![
|
|
371
|
+
"ArrowLeft",
|
|
372
|
+
"ArrowRight",
|
|
373
|
+
"Home",
|
|
374
|
+
"End"
|
|
375
|
+
].includes(e.key)) return;
|
|
376
|
+
e.preventDefault();
|
|
377
|
+
let r = t.map((e, t) => ({
|
|
378
|
+
tab: e,
|
|
379
|
+
tabIndex: t
|
|
380
|
+
})).filter(({ tab: e }) => !e.disabled), i = r.findIndex(({ tabIndex: e }) => e === n), o = e.key === "Home" ? r[0] : e.key === "End" ? r.at(-1) : r[(i + (e.key === "ArrowRight" ? 1 : -1) + r.length) % r.length];
|
|
381
|
+
o && (a(o.tab), document.querySelector(`[data-tab-name="${o.tab.name}"]`)?.focus());
|
|
382
|
+
};
|
|
383
|
+
return /* @__PURE__ */ u("div", {
|
|
384
|
+
className: `vl-tabs ${r}`.trim(),
|
|
385
|
+
...i,
|
|
386
|
+
children: /* @__PURE__ */ u("div", {
|
|
387
|
+
className: "vl-tabs-nav",
|
|
388
|
+
role: "tablist",
|
|
389
|
+
children: t.map((n) => /* @__PURE__ */ u("button", {
|
|
390
|
+
type: "button",
|
|
391
|
+
className: `vl-tabs-item ${e === n.name ? "is-active" : ""} ${n.disabled ? "is-disabled" : ""}`.trim(),
|
|
392
|
+
role: "tab",
|
|
393
|
+
"aria-selected": e === n.name,
|
|
394
|
+
tabIndex: e === n.name ? 0 : -1,
|
|
395
|
+
disabled: n.disabled,
|
|
396
|
+
"data-tab-name": n.name,
|
|
397
|
+
onClick: () => a(n),
|
|
398
|
+
onKeyDown: (e) => o(e, t.indexOf(n)),
|
|
399
|
+
children: n.label
|
|
400
|
+
}, n.name))
|
|
401
|
+
})
|
|
402
|
+
});
|
|
403
|
+
}, k = ({ title: e, items: t = [], data: n, column: r = 1, border: i = !1, slots: a, className: o = "", ...s }) => {
|
|
404
|
+
let c = (e) => {
|
|
405
|
+
if (e.render) return e.render(e, n);
|
|
406
|
+
if (e.slot && a && a[e.slot]) return a[e.slot](e, n);
|
|
407
|
+
if (e.value !== void 0 && e.value !== null) return e.value;
|
|
408
|
+
if (n) {
|
|
409
|
+
if (e.label && n[e.label] !== void 0) {
|
|
410
|
+
let t = n[e.label];
|
|
411
|
+
return typeof t == "boolean" ? String(t) : t;
|
|
412
|
+
}
|
|
413
|
+
if (e.slot && n[e.slot] !== void 0) {
|
|
414
|
+
let t = n[e.slot];
|
|
415
|
+
return typeof t == "boolean" ? String(t) : t;
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
return "--";
|
|
419
|
+
};
|
|
420
|
+
return /* @__PURE__ */ d("div", {
|
|
421
|
+
className: `vl-descriptions ${i ? "is-border" : ""} ${o}`.trim(),
|
|
422
|
+
...s,
|
|
423
|
+
children: [e && /* @__PURE__ */ u("div", {
|
|
424
|
+
className: "vl-descriptions-title",
|
|
425
|
+
children: e
|
|
426
|
+
}), /* @__PURE__ */ u("div", {
|
|
427
|
+
className: "vl-descriptions-grid",
|
|
428
|
+
style: { gridTemplateColumns: `repeat(${r}, 1fr)` },
|
|
429
|
+
children: t.map((e, t) => /* @__PURE__ */ d("div", {
|
|
430
|
+
className: "vl-descriptions-item",
|
|
431
|
+
style: { gridColumn: `span ${e.span || 1}` },
|
|
432
|
+
children: [/* @__PURE__ */ u("div", {
|
|
433
|
+
className: "vl-descriptions-label",
|
|
434
|
+
children: e.label
|
|
435
|
+
}), /* @__PURE__ */ u("div", {
|
|
436
|
+
className: "vl-descriptions-content",
|
|
437
|
+
children: c(e)
|
|
438
|
+
})]
|
|
439
|
+
}, t))
|
|
440
|
+
})]
|
|
441
|
+
});
|
|
442
|
+
}, A = ({ text: e, position: n = "top", delay: a = 200, children: o, disabled: l = !1, className: p = "", ...m }) => {
|
|
443
|
+
let h = i(), [g, _] = c(!1), [v, y] = c(!1), [b, x] = c({}), [S, C] = c(n), w = s(null), T = s(null), E = s(null), D = s(null), O = t((e) => {
|
|
444
|
+
if (!w.current || !e) return;
|
|
445
|
+
let t = w.current.getBoundingClientRect(), r = e.getBoundingClientRect(), i = window.innerWidth, a = window.innerHeight, o = 0, s = 0, c = t.top + t.height / 2, l = t.left + t.width / 2, u = n, d = (e) => e === "top" ? t.top - r.height - 8 >= 5 : e === "bottom" ? t.bottom + r.height + 8 <= a - 5 : e === "left" ? t.left - r.width - 8 >= 5 : t.right + r.width + 8 <= i - 5, f = {
|
|
446
|
+
top: "bottom",
|
|
447
|
+
bottom: "top",
|
|
448
|
+
left: "right",
|
|
449
|
+
right: "left"
|
|
450
|
+
};
|
|
451
|
+
switch (!d(u) && d(f[u]) && (u = f[u]), C(u), u) {
|
|
452
|
+
case "top":
|
|
453
|
+
case "bottom":
|
|
454
|
+
o = u === "top" ? t.top - r.height - 8 : t.bottom + 8, s = l - r.width / 2, s < 5 && (s = 5);
|
|
455
|
+
let e = s + r.width, n = i - 5;
|
|
456
|
+
e > n && (s = Math.max(5, s - (e - n)));
|
|
457
|
+
break;
|
|
458
|
+
case "left":
|
|
459
|
+
case "right":
|
|
460
|
+
o = c - r.height / 2, s = u === "left" ? t.left - r.width - 8 : t.right + 8;
|
|
461
|
+
break;
|
|
462
|
+
}
|
|
463
|
+
o = Math.min(Math.max(o, 5), Math.max(5, a - 5 - r.height)), s = Math.min(Math.max(s, 5), Math.max(5, i - 5 - r.width)), x({
|
|
464
|
+
position: "fixed",
|
|
465
|
+
top: `${o}px`,
|
|
466
|
+
left: `${s}px`
|
|
467
|
+
});
|
|
468
|
+
}, [n]), k = t((e) => {
|
|
469
|
+
T.current = e, e && O(e);
|
|
470
|
+
}, [O]);
|
|
471
|
+
return r(() => {
|
|
472
|
+
if (!v) return;
|
|
473
|
+
let e = () => {
|
|
474
|
+
T.current && O(T.current);
|
|
475
|
+
};
|
|
476
|
+
return window.addEventListener("resize", e), window.addEventListener("scroll", e, !0), () => {
|
|
477
|
+
window.removeEventListener("resize", e), window.removeEventListener("scroll", e, !0);
|
|
478
|
+
};
|
|
479
|
+
}, [v, O]), r(() => () => {
|
|
480
|
+
E.current && window.clearTimeout(E.current), D.current && window.clearTimeout(D.current);
|
|
481
|
+
}, []), /* @__PURE__ */ d("div", {
|
|
482
|
+
className: `vl-tooltip-wrapper ${p}`.trim(),
|
|
483
|
+
ref: w,
|
|
484
|
+
"aria-describedby": v && e ? h : void 0,
|
|
485
|
+
onMouseEnter: () => {
|
|
486
|
+
l || (E.current && window.clearTimeout(E.current), D.current && window.clearTimeout(D.current), g ? y(!0) : E.current = window.setTimeout(() => {
|
|
487
|
+
_(!0), E.current = window.setTimeout(() => {
|
|
488
|
+
y(!0);
|
|
489
|
+
}, 20);
|
|
490
|
+
}, a));
|
|
491
|
+
},
|
|
492
|
+
onMouseLeave: () => {
|
|
493
|
+
E.current && window.clearTimeout(E.current), D.current && window.clearTimeout(D.current), y(!1), D.current = window.setTimeout(() => {
|
|
494
|
+
_(!1);
|
|
495
|
+
}, 200);
|
|
496
|
+
},
|
|
497
|
+
...m,
|
|
498
|
+
children: [o, g && e && !l && typeof document < "u" && f(/* @__PURE__ */ d("div", {
|
|
499
|
+
ref: k,
|
|
500
|
+
id: h,
|
|
501
|
+
className: `vl-tooltip-content ${v ? "is-visible" : ""}`.trim(),
|
|
502
|
+
role: "tooltip",
|
|
503
|
+
style: b,
|
|
504
|
+
"data-position": S,
|
|
505
|
+
children: [e, /* @__PURE__ */ u("span", {
|
|
506
|
+
className: "vl-tooltip-arrow",
|
|
507
|
+
"data-position": S
|
|
508
|
+
})]
|
|
509
|
+
}), document.body)]
|
|
510
|
+
});
|
|
511
|
+
}, j = ({ toasts: e = [], onClose: t, closeLabel: n = "Close notification", className: r = "", ...i }) => {
|
|
512
|
+
let a = (e) => e === "success" ? "success" : e === "error" ? "error" : e === "warning" ? "warning" : "info";
|
|
513
|
+
return typeof document > "u" ? null : f(/* @__PURE__ */ u("div", {
|
|
514
|
+
className: `vl-toast-container ${r}`.trim(),
|
|
515
|
+
"aria-live": "polite",
|
|
516
|
+
"aria-relevant": "additions",
|
|
517
|
+
...i,
|
|
518
|
+
children: e.map((e) => /* @__PURE__ */ d("div", {
|
|
519
|
+
className: `vl-toast-item is-${e.type}`,
|
|
520
|
+
role: e.type === "error" ? "alert" : "status",
|
|
521
|
+
children: [
|
|
522
|
+
/* @__PURE__ */ u("div", {
|
|
523
|
+
className: "vl-toast-icon",
|
|
524
|
+
children: /* @__PURE__ */ u(p, {
|
|
525
|
+
name: a(e.type),
|
|
526
|
+
size: 20
|
|
527
|
+
})
|
|
528
|
+
}),
|
|
529
|
+
/* @__PURE__ */ d("div", {
|
|
530
|
+
className: "vl-toast-content",
|
|
531
|
+
children: [/* @__PURE__ */ u("h4", {
|
|
532
|
+
className: "vl-toast-title",
|
|
533
|
+
children: e.title
|
|
534
|
+
}), /* @__PURE__ */ u("p", {
|
|
535
|
+
className: "vl-toast-message",
|
|
536
|
+
children: e.message
|
|
537
|
+
})]
|
|
538
|
+
}),
|
|
539
|
+
/* @__PURE__ */ u("button", {
|
|
540
|
+
type: "button",
|
|
541
|
+
className: "vl-toast-close",
|
|
542
|
+
"aria-label": n,
|
|
543
|
+
onClick: () => t?.(e.id),
|
|
544
|
+
children: "×"
|
|
545
|
+
})
|
|
546
|
+
]
|
|
547
|
+
}, e.id))
|
|
548
|
+
}), document.body);
|
|
549
|
+
}, M = 0, N = "", P = [
|
|
550
|
+
"button:not([disabled])",
|
|
551
|
+
"[href]",
|
|
552
|
+
"input:not([disabled])",
|
|
553
|
+
"select:not([disabled])",
|
|
554
|
+
"textarea:not([disabled])",
|
|
555
|
+
"[tabindex]:not([tabindex=\"-1\"])"
|
|
556
|
+
].join(",");
|
|
557
|
+
function F(e, t) {
|
|
558
|
+
let n = document.activeElement;
|
|
559
|
+
M++ === 0 && (N = document.body.style.overflow, document.body.style.overflow = "hidden"), queueMicrotask(() => {
|
|
560
|
+
(e.querySelector(P) ?? e).focus();
|
|
561
|
+
});
|
|
562
|
+
let r = (n) => {
|
|
563
|
+
if (n.key === "Escape") {
|
|
564
|
+
n.preventDefault(), t();
|
|
565
|
+
return;
|
|
566
|
+
}
|
|
567
|
+
if (n.key !== "Tab") return;
|
|
568
|
+
let r = [...e.querySelectorAll(P)];
|
|
569
|
+
if (r.length === 0) {
|
|
570
|
+
n.preventDefault(), e.focus();
|
|
571
|
+
return;
|
|
572
|
+
}
|
|
573
|
+
let i = r[0], a = r[r.length - 1];
|
|
574
|
+
n.shiftKey && document.activeElement === i ? (n.preventDefault(), a.focus()) : !n.shiftKey && document.activeElement === a && (n.preventDefault(), i.focus());
|
|
575
|
+
};
|
|
576
|
+
return document.addEventListener("keydown", r), () => {
|
|
577
|
+
document.removeEventListener("keydown", r), M = Math.max(0, M - 1), M === 0 && (document.body.style.overflow = N), n?.isConnected && n.focus();
|
|
578
|
+
};
|
|
579
|
+
}
|
|
580
|
+
//#endregion
|
|
581
|
+
//#region src/components/VustDialog/VustDialog.tsx
|
|
582
|
+
var I = ({ visible: e, title: t, width: n = "500px", closeOnClickOverlay: a = !0, zIndex: o = "var(--vdl-z-index-modal)", onClose: c, footer: l, className: p = "", style: m, children: h, ...g }) => {
|
|
583
|
+
let _ = s(null), v = i();
|
|
584
|
+
if (r(() => {
|
|
585
|
+
if (!(!e || !_.current)) return F(_.current, () => c?.());
|
|
586
|
+
}, [e, c]), !e) return null;
|
|
587
|
+
let y = (e) => {
|
|
588
|
+
a && e.target === e.currentTarget && c?.();
|
|
589
|
+
}, b = {
|
|
590
|
+
zIndex: o,
|
|
591
|
+
...m
|
|
592
|
+
};
|
|
593
|
+
return f(/* @__PURE__ */ u("div", {
|
|
594
|
+
className: `vl-dialog-overlay ${p}`.trim(),
|
|
595
|
+
style: b,
|
|
596
|
+
onClick: y,
|
|
597
|
+
role: "presentation",
|
|
598
|
+
...g,
|
|
599
|
+
children: /* @__PURE__ */ d("div", {
|
|
600
|
+
ref: _,
|
|
601
|
+
className: "vl-dialog-card",
|
|
602
|
+
style: {
|
|
603
|
+
width: n,
|
|
604
|
+
maxWidth: "95%"
|
|
605
|
+
},
|
|
606
|
+
role: "dialog",
|
|
607
|
+
"aria-modal": "true",
|
|
608
|
+
"aria-labelledby": v,
|
|
609
|
+
tabIndex: -1,
|
|
610
|
+
children: [
|
|
611
|
+
/* @__PURE__ */ d("div", {
|
|
612
|
+
className: "vl-dialog-header",
|
|
613
|
+
"data-slot": "header",
|
|
614
|
+
children: [/* @__PURE__ */ u("span", {
|
|
615
|
+
id: v,
|
|
616
|
+
className: "vl-dialog-title",
|
|
617
|
+
children: t
|
|
618
|
+
}), /* @__PURE__ */ u("button", {
|
|
619
|
+
type: "button",
|
|
620
|
+
className: "vl-dialog-close-btn",
|
|
621
|
+
onClick: c,
|
|
622
|
+
"aria-label": "Close dialog",
|
|
623
|
+
children: "×"
|
|
624
|
+
})]
|
|
625
|
+
}),
|
|
626
|
+
/* @__PURE__ */ u("div", {
|
|
627
|
+
className: "vl-dialog-body",
|
|
628
|
+
children: h
|
|
629
|
+
}),
|
|
630
|
+
l && /* @__PURE__ */ u("div", {
|
|
631
|
+
className: "vl-dialog-footer",
|
|
632
|
+
"data-slot": "footer",
|
|
633
|
+
children: l
|
|
634
|
+
})
|
|
635
|
+
]
|
|
636
|
+
})
|
|
637
|
+
}), document.body);
|
|
638
|
+
}, L = ({ visible: e, title: t = "", width: n = "420px", closeOnOverlay: a = !0, onClose: o, footer: c, className: l = "", style: p, children: m, ...h }) => {
|
|
639
|
+
let g = s(null), _ = i();
|
|
640
|
+
if (r(() => {
|
|
641
|
+
if (!(!e || !g.current)) return F(g.current, () => o?.());
|
|
642
|
+
}, [e, o]), !e) return null;
|
|
643
|
+
let v = (e) => {
|
|
644
|
+
a && e.target === e.currentTarget && o?.();
|
|
645
|
+
}, y = {
|
|
646
|
+
width: n,
|
|
647
|
+
...p
|
|
648
|
+
};
|
|
649
|
+
return f(/* @__PURE__ */ u("div", {
|
|
650
|
+
className: `vl-drawer-overlay ${l}`.trim(),
|
|
651
|
+
onClick: v,
|
|
652
|
+
role: "presentation",
|
|
653
|
+
...h,
|
|
654
|
+
children: /* @__PURE__ */ d("div", {
|
|
655
|
+
ref: g,
|
|
656
|
+
className: "vl-drawer-panel",
|
|
657
|
+
style: y,
|
|
658
|
+
role: "dialog",
|
|
659
|
+
"aria-modal": "true",
|
|
660
|
+
"aria-labelledby": _,
|
|
661
|
+
tabIndex: -1,
|
|
662
|
+
children: [
|
|
663
|
+
/* @__PURE__ */ d("div", {
|
|
664
|
+
className: "vl-drawer-header",
|
|
665
|
+
"data-slot": "header",
|
|
666
|
+
children: [/* @__PURE__ */ u("h3", {
|
|
667
|
+
id: _,
|
|
668
|
+
className: "vl-drawer-title",
|
|
669
|
+
children: t
|
|
670
|
+
}), /* @__PURE__ */ u("button", {
|
|
671
|
+
type: "button",
|
|
672
|
+
className: "vl-drawer-close-btn",
|
|
673
|
+
onClick: o,
|
|
674
|
+
"aria-label": "Close drawer",
|
|
675
|
+
children: "×"
|
|
676
|
+
})]
|
|
677
|
+
}),
|
|
678
|
+
/* @__PURE__ */ u("div", {
|
|
679
|
+
className: "vl-drawer-body",
|
|
680
|
+
children: m
|
|
681
|
+
}),
|
|
682
|
+
c && /* @__PURE__ */ u("div", {
|
|
683
|
+
className: "vl-drawer-footer",
|
|
684
|
+
"data-slot": "footer",
|
|
685
|
+
children: c
|
|
686
|
+
})
|
|
687
|
+
]
|
|
688
|
+
})
|
|
689
|
+
}), document.body);
|
|
690
|
+
}, R = ({ visible: e, title: t, message: n, confirmText: a = "确定", cancelText: o = "取消", type: c = "primary", onConfirm: l, onCancel: p, className: m = "", ...h }) => {
|
|
691
|
+
let g = s(null), _ = i();
|
|
692
|
+
return r(() => {
|
|
693
|
+
if (!(!e || !g.current)) return F(g.current, () => p?.());
|
|
694
|
+
}, [e, p]), e ? f(/* @__PURE__ */ u("div", {
|
|
695
|
+
className: `vl-modal-overlay ${m}`.trim(),
|
|
696
|
+
onClick: (e) => {
|
|
697
|
+
e.target === e.currentTarget && p?.();
|
|
698
|
+
},
|
|
699
|
+
role: "presentation",
|
|
700
|
+
...h,
|
|
701
|
+
children: /* @__PURE__ */ d("div", {
|
|
702
|
+
ref: g,
|
|
703
|
+
className: "vl-modal-card",
|
|
704
|
+
role: "alertdialog",
|
|
705
|
+
"aria-modal": "true",
|
|
706
|
+
"aria-labelledby": _,
|
|
707
|
+
tabIndex: -1,
|
|
708
|
+
children: [
|
|
709
|
+
/* @__PURE__ */ u("div", {
|
|
710
|
+
className: "vl-modal-header",
|
|
711
|
+
"data-slot": "header",
|
|
712
|
+
children: /* @__PURE__ */ u("h3", {
|
|
713
|
+
id: _,
|
|
714
|
+
className: "vl-modal-title",
|
|
715
|
+
children: t
|
|
716
|
+
})
|
|
717
|
+
}),
|
|
718
|
+
/* @__PURE__ */ u("div", {
|
|
719
|
+
className: "vl-modal-body",
|
|
720
|
+
children: /* @__PURE__ */ u("p", {
|
|
721
|
+
className: "vl-modal-message",
|
|
722
|
+
children: n
|
|
723
|
+
})
|
|
724
|
+
}),
|
|
725
|
+
/* @__PURE__ */ d("div", {
|
|
726
|
+
className: "vl-modal-footer",
|
|
727
|
+
"data-slot": "footer",
|
|
728
|
+
children: [/* @__PURE__ */ u("button", {
|
|
729
|
+
type: "button",
|
|
730
|
+
className: "vl-modal-btn is-cancel",
|
|
731
|
+
onClick: p,
|
|
732
|
+
children: o
|
|
733
|
+
}), /* @__PURE__ */ u("button", {
|
|
734
|
+
type: "button",
|
|
735
|
+
className: `vl-modal-btn is-${c}`,
|
|
736
|
+
onClick: l,
|
|
737
|
+
children: a
|
|
738
|
+
})]
|
|
739
|
+
})
|
|
740
|
+
]
|
|
741
|
+
})
|
|
742
|
+
}), document.body) : null;
|
|
743
|
+
}, z = ({ currentPage: e, totalPages: t, maxVisibleButtons: n = 5, onPageChange: r, ariaLabel: i = "Pagination", previousLabel: a = "Previous page", nextLabel: s = "Next page", className: c = "", ...l }) => {
|
|
744
|
+
let f = o(() => {
|
|
745
|
+
let r = t, i = e, a = n, o = [];
|
|
746
|
+
if (r <= a) for (let e = 1; e <= r; e++) o.push(e);
|
|
747
|
+
else {
|
|
748
|
+
let e = Math.floor(a / 2), t = Math.max(1, i - e), n = Math.min(r, i + e);
|
|
749
|
+
i - t < e && (n += e - (i - t)), n - i < e && (t -= e - (n - i)), t = Math.max(1, t), n = Math.min(r, n), t > 1 && (o.push(1), t > 2 && o.push("..."));
|
|
750
|
+
for (let e = t; e <= n; e++) o.push(e);
|
|
751
|
+
n < r && (n < r - 1 && o.push("..."), o.push(r));
|
|
752
|
+
}
|
|
753
|
+
return o;
|
|
754
|
+
}, [
|
|
755
|
+
e,
|
|
756
|
+
t,
|
|
757
|
+
n
|
|
758
|
+
]);
|
|
759
|
+
if (t <= 1) return null;
|
|
760
|
+
let p = (t) => {
|
|
761
|
+
typeof t == "number" && t !== e && r?.(t);
|
|
762
|
+
};
|
|
763
|
+
return /* @__PURE__ */ d("nav", {
|
|
764
|
+
className: `vl-pagination ${c}`.trim(),
|
|
765
|
+
"aria-label": i,
|
|
766
|
+
...l,
|
|
767
|
+
children: [
|
|
768
|
+
/* @__PURE__ */ u("button", {
|
|
769
|
+
type: "button",
|
|
770
|
+
className: "vl-pagination-btn",
|
|
771
|
+
onClick: () => p(e - 1),
|
|
772
|
+
disabled: e === 1,
|
|
773
|
+
"aria-label": a,
|
|
774
|
+
children: "<"
|
|
775
|
+
}),
|
|
776
|
+
f.map((t, n) => {
|
|
777
|
+
let r = t === e, i = typeof t == "string";
|
|
778
|
+
return i ? /* @__PURE__ */ u("span", {
|
|
779
|
+
className: "vl-pagination-ellipsis",
|
|
780
|
+
"aria-hidden": "true",
|
|
781
|
+
children: "…"
|
|
782
|
+
}, n) : /* @__PURE__ */ u("button", {
|
|
783
|
+
type: "button",
|
|
784
|
+
className: `vl-pagination-btn ${r ? "active" : ""} ${i ? "ellipsis" : ""}`.trim(),
|
|
785
|
+
onClick: () => p(t),
|
|
786
|
+
"aria-current": r ? "page" : void 0,
|
|
787
|
+
"aria-label": `Page ${t}`,
|
|
788
|
+
children: t
|
|
789
|
+
}, n);
|
|
790
|
+
}),
|
|
791
|
+
/* @__PURE__ */ u("button", {
|
|
792
|
+
type: "button",
|
|
793
|
+
className: "vl-pagination-btn",
|
|
794
|
+
onClick: () => p(e + 1),
|
|
795
|
+
disabled: e === t,
|
|
796
|
+
"aria-label": s,
|
|
797
|
+
children: ">"
|
|
798
|
+
})
|
|
799
|
+
]
|
|
800
|
+
});
|
|
801
|
+
};
|
|
802
|
+
//#endregion
|
|
803
|
+
//#region src/internal/floating-position.ts
|
|
804
|
+
function B({ anchor: e, floating: t, preferred: n = "bottom", gap: r = 4, margin: i = 8, maxHeight: a = 260, matchWidth: o = !1 }) {
|
|
805
|
+
let s = e.getBoundingClientRect(), c = window.innerWidth, l = window.innerHeight, u = Math.max(0, l - s.bottom - r - i), d = Math.max(0, s.top - r - i), f = Math.min(t.scrollHeight, a), p = n === "bottom" ? u : d, m = p < f && (n === "bottom" ? d : u) > p ? n === "bottom" ? "top" : "bottom" : n, h = m === "bottom" ? u : d, g = Math.max(0, c - i * 2), _ = Math.min(Math.max(t.scrollWidth, o ? s.width : 0), g), v = Math.min(Math.max(s.left, i), Math.max(i, c - i - _));
|
|
806
|
+
return {
|
|
807
|
+
placement: m,
|
|
808
|
+
style: {
|
|
809
|
+
position: "fixed",
|
|
810
|
+
minWidth: o ? `${Math.min(s.width, g)}px` : 0,
|
|
811
|
+
maxWidth: `${g}px`,
|
|
812
|
+
maxHeight: `${Math.min(a, h)}px`,
|
|
813
|
+
left: `${v}px`,
|
|
814
|
+
top: m === "bottom" ? `${s.bottom + r}px` : "auto",
|
|
815
|
+
bottom: m === "top" ? `${l - s.top + r}px` : "auto",
|
|
816
|
+
visibility: "visible"
|
|
817
|
+
}
|
|
818
|
+
};
|
|
819
|
+
}
|
|
820
|
+
//#endregion
|
|
821
|
+
//#region src/components/VustSelect/VustSelect.tsx
|
|
822
|
+
var ee = 24, V = ({ value: e, options: n, placeholder: l = "请选择", disabled: p = !1, id: m, name: h, ariaLabel: g, ariaLabelledby: _, ariaDescribedby: v, onChange: y, onOptionDisabled: b, onDropdownScroll: x, onDropdownReachBottom: S, dropdownFooter: C, className: w = "", ...T }) => {
|
|
823
|
+
let [E, D] = c(!1), [O, k] = c("bottom"), [A, j] = c({ visibility: "hidden" }), M = s(null), N = s(null), [P, F] = c(-1), I = i(), L = m ?? I, R = `${I}-listbox`, z = o(() => {
|
|
824
|
+
let t = n.find((t) => t.value === e);
|
|
825
|
+
return t ? t.label : l;
|
|
826
|
+
}, [
|
|
827
|
+
e,
|
|
828
|
+
n,
|
|
829
|
+
l
|
|
830
|
+
]), V = t(() => {
|
|
831
|
+
if (!M.current || !N.current || !E) return;
|
|
832
|
+
let e = B({
|
|
833
|
+
anchor: M.current,
|
|
834
|
+
floating: N.current,
|
|
835
|
+
matchWidth: !0
|
|
836
|
+
});
|
|
837
|
+
k(e.placement), j(e.style);
|
|
838
|
+
}, [E]);
|
|
839
|
+
a(() => {
|
|
840
|
+
E ? V() : j({ visibility: "hidden" });
|
|
841
|
+
}, [
|
|
842
|
+
E,
|
|
843
|
+
V,
|
|
844
|
+
n.length,
|
|
845
|
+
C
|
|
846
|
+
]), r(() => {
|
|
847
|
+
let e = (e) => {
|
|
848
|
+
M.current && !M.current.contains(e.target) && (!N.current || !N.current.contains(e.target)) && D(!1);
|
|
849
|
+
};
|
|
850
|
+
return document.addEventListener("click", e), window.addEventListener("resize", V), window.addEventListener("scroll", V, !0), () => {
|
|
851
|
+
document.removeEventListener("click", e), window.removeEventListener("resize", V), window.removeEventListener("scroll", V, !0);
|
|
852
|
+
};
|
|
853
|
+
}, [V]);
|
|
854
|
+
let H = () => {
|
|
855
|
+
p || D((t) => {
|
|
856
|
+
let r = !t;
|
|
857
|
+
if (r) {
|
|
858
|
+
let t = n.findIndex((t) => t.value === e && !t.disabled);
|
|
859
|
+
F(t >= 0 ? t : n.findIndex((e) => !e.disabled));
|
|
860
|
+
}
|
|
861
|
+
return r;
|
|
862
|
+
});
|
|
863
|
+
}, U = (e) => {
|
|
864
|
+
if (!n.length) return;
|
|
865
|
+
let t = P;
|
|
866
|
+
for (let r = 0; r < n.length; r += 1) if (t = (t + e + n.length) % n.length, !n[t]?.disabled) {
|
|
867
|
+
F(t), requestAnimationFrame(() => N.current?.querySelector(`[data-option-index="${t}"]`)?.scrollIntoView({ block: "nearest" }));
|
|
868
|
+
return;
|
|
869
|
+
}
|
|
870
|
+
}, W = (e) => {
|
|
871
|
+
if (!p) if ([
|
|
872
|
+
"ArrowDown",
|
|
873
|
+
"ArrowUp",
|
|
874
|
+
"Home",
|
|
875
|
+
"End"
|
|
876
|
+
].includes(e.key)) if (e.preventDefault(), E || H(), e.key === "ArrowDown") U(1);
|
|
877
|
+
else if (e.key === "ArrowUp") U(-1);
|
|
878
|
+
else {
|
|
879
|
+
let t = n.map((e, t) => ({
|
|
880
|
+
option: e,
|
|
881
|
+
index: t
|
|
882
|
+
})).filter(({ option: e }) => !e.disabled);
|
|
883
|
+
F(e.key === "Home" ? t[0]?.index ?? -1 : t.at(-1)?.index ?? -1);
|
|
884
|
+
}
|
|
885
|
+
else e.key === "Enter" || e.key === " " ? (e.preventDefault(), E ? P >= 0 && n[P] && G(n[P]) : H()) : e.key === "Escape" && E && (e.preventDefault(), D(!1));
|
|
886
|
+
}, G = (e) => {
|
|
887
|
+
if (!p) {
|
|
888
|
+
if (e.disabled) {
|
|
889
|
+
b?.(e);
|
|
890
|
+
return;
|
|
891
|
+
}
|
|
892
|
+
y?.(e.value), D(!1);
|
|
893
|
+
}
|
|
894
|
+
}, K = (e) => {
|
|
895
|
+
x?.(e);
|
|
896
|
+
let t = e.currentTarget;
|
|
897
|
+
t.scrollHeight - t.scrollTop - t.clientHeight <= ee && S?.(e);
|
|
898
|
+
};
|
|
899
|
+
return /* @__PURE__ */ d("div", {
|
|
900
|
+
className: `vl-select ${E ? "is-open" : ""} ${p ? "is-disabled" : ""} ${w}`.trim(),
|
|
901
|
+
ref: M,
|
|
902
|
+
...T,
|
|
903
|
+
children: [
|
|
904
|
+
/* @__PURE__ */ d("button", {
|
|
905
|
+
id: L,
|
|
906
|
+
type: "button",
|
|
907
|
+
className: "vl-select-trigger",
|
|
908
|
+
role: "combobox",
|
|
909
|
+
disabled: p,
|
|
910
|
+
"aria-label": g,
|
|
911
|
+
"aria-labelledby": _,
|
|
912
|
+
"aria-describedby": v,
|
|
913
|
+
"aria-expanded": E,
|
|
914
|
+
"aria-controls": R,
|
|
915
|
+
"aria-haspopup": "listbox",
|
|
916
|
+
onClick: H,
|
|
917
|
+
onKeyDown: W,
|
|
918
|
+
children: [/* @__PURE__ */ u("span", {
|
|
919
|
+
className: "vl-select-label",
|
|
920
|
+
children: z
|
|
921
|
+
}), /* @__PURE__ */ u("span", { className: "vl-select-arrow" })]
|
|
922
|
+
}),
|
|
923
|
+
h ? /* @__PURE__ */ u("input", {
|
|
924
|
+
type: "hidden",
|
|
925
|
+
name: h,
|
|
926
|
+
value: e ?? "",
|
|
927
|
+
disabled: p
|
|
928
|
+
}) : null,
|
|
929
|
+
E && f(/* @__PURE__ */ d("ul", {
|
|
930
|
+
ref: N,
|
|
931
|
+
id: R,
|
|
932
|
+
role: "listbox",
|
|
933
|
+
className: "vl-select-options",
|
|
934
|
+
style: A,
|
|
935
|
+
"data-placement": O,
|
|
936
|
+
onScroll: K,
|
|
937
|
+
children: [n.map((t, n) => {
|
|
938
|
+
let r = e === t.value;
|
|
939
|
+
return /* @__PURE__ */ u("li", {
|
|
940
|
+
className: `vl-select-option ${r ? "selected" : ""} ${t.disabled ? "disabled" : ""}`.trim(),
|
|
941
|
+
role: "option",
|
|
942
|
+
"aria-selected": r,
|
|
943
|
+
"aria-disabled": t.disabled || void 0,
|
|
944
|
+
"data-option-index": n,
|
|
945
|
+
"data-active": P === n || void 0,
|
|
946
|
+
title: t.hint,
|
|
947
|
+
onClick: () => G(t),
|
|
948
|
+
children: t.label
|
|
949
|
+
}, t.value);
|
|
950
|
+
}), C ? /* @__PURE__ */ u("li", {
|
|
951
|
+
className: "vl-select-footer",
|
|
952
|
+
children: C
|
|
953
|
+
}) : null]
|
|
954
|
+
}), document.body)
|
|
955
|
+
]
|
|
956
|
+
});
|
|
957
|
+
}, H = "vust-action-menu-open", U = ({ actions: e, label: n = "操作", disabled: i = !1, defaultIcon: a = "settings", className: o = "", ...l }) => {
|
|
958
|
+
let [m, h] = c(!1), [g, _] = c(!1), [v, y] = c({}), [b, x] = c("bottom"), S = s(null), C = s(null), w = t(() => {
|
|
959
|
+
if (!S.current || !C.current || !m) return;
|
|
960
|
+
let e = B({
|
|
961
|
+
anchor: S.current,
|
|
962
|
+
floating: C.current
|
|
963
|
+
});
|
|
964
|
+
x(e.placement), y(e.style), _(!0);
|
|
965
|
+
}, [m]);
|
|
966
|
+
r(() => {
|
|
967
|
+
m && w();
|
|
968
|
+
}, [m, w]), r(() => {
|
|
969
|
+
let e = (e) => {
|
|
970
|
+
let t = e.target;
|
|
971
|
+
S.current && !S.current.contains(t) && (!C.current || !C.current.contains(t)) && (h(!1), _(!1));
|
|
972
|
+
}, t = (e) => {
|
|
973
|
+
e.detail !== S.current && (h(!1), _(!1));
|
|
974
|
+
};
|
|
975
|
+
return document.addEventListener("click", e), document.addEventListener(H, t), window.addEventListener("resize", w), window.addEventListener("scroll", w, !0), () => {
|
|
976
|
+
document.removeEventListener("click", e), document.removeEventListener(H, t), window.removeEventListener("resize", w), window.removeEventListener("scroll", w, !0);
|
|
977
|
+
};
|
|
978
|
+
}, [w]);
|
|
979
|
+
let T = (e) => {
|
|
980
|
+
if (e.stopPropagation(), !i) {
|
|
981
|
+
if (m) {
|
|
982
|
+
h(!1), _(!1);
|
|
983
|
+
return;
|
|
984
|
+
}
|
|
985
|
+
_(!1), h(!0), document.dispatchEvent(new CustomEvent(H, { detail: S.current }));
|
|
986
|
+
}
|
|
987
|
+
}, E = (e, t) => {
|
|
988
|
+
t.stopPropagation(), !e.disabled && (e.handler(), h(!1), _(!1));
|
|
989
|
+
}, D = (e) => {
|
|
990
|
+
let t = [...C.current?.querySelectorAll(".vl-dropdown-item:not(:disabled)") ?? []];
|
|
991
|
+
t[(e + t.length) % t.length]?.focus();
|
|
992
|
+
}, O = (e) => {
|
|
993
|
+
[
|
|
994
|
+
"Enter",
|
|
995
|
+
" ",
|
|
996
|
+
"ArrowDown"
|
|
997
|
+
].includes(e.key) && (e.preventDefault(), _(!1), h(!0), document.dispatchEvent(new CustomEvent(H, { detail: S.current })), requestAnimationFrame(() => {
|
|
998
|
+
w(), D(0);
|
|
999
|
+
}));
|
|
1000
|
+
}, k = (e) => {
|
|
1001
|
+
let t = [...C.current?.querySelectorAll(".vl-dropdown-item:not(:disabled)") ?? []], n = t.indexOf(document.activeElement);
|
|
1002
|
+
e.key === "ArrowDown" || e.key === "ArrowUp" ? (e.preventDefault(), D(n + (e.key === "ArrowDown" ? 1 : -1))) : e.key === "Home" || e.key === "End" ? (e.preventDefault(), D(e.key === "Home" ? 0 : t.length - 1)) : e.key === "Escape" && (e.preventDefault(), h(!1), _(!1), S.current?.querySelector(".vl-action-btn")?.focus());
|
|
1003
|
+
};
|
|
1004
|
+
return /* @__PURE__ */ d("div", {
|
|
1005
|
+
className: `vl-action-menu ${o}`.trim(),
|
|
1006
|
+
ref: S,
|
|
1007
|
+
...l,
|
|
1008
|
+
children: [/* @__PURE__ */ d("button", {
|
|
1009
|
+
type: "button",
|
|
1010
|
+
className: "vl-action-btn",
|
|
1011
|
+
disabled: i,
|
|
1012
|
+
onClick: T,
|
|
1013
|
+
onKeyDown: O,
|
|
1014
|
+
"aria-haspopup": "menu",
|
|
1015
|
+
"aria-expanded": m,
|
|
1016
|
+
children: [/* @__PURE__ */ u(p, {
|
|
1017
|
+
className: "vl-action-btn-icon",
|
|
1018
|
+
name: "settings",
|
|
1019
|
+
size: 16
|
|
1020
|
+
}), /* @__PURE__ */ u("span", {
|
|
1021
|
+
className: "vl-action-btn-text",
|
|
1022
|
+
children: n
|
|
1023
|
+
})]
|
|
1024
|
+
}), m && f(/* @__PURE__ */ u("div", {
|
|
1025
|
+
ref: C,
|
|
1026
|
+
className: `vl-dropdown ${g ? "is-positioned" : ""}`.trim(),
|
|
1027
|
+
role: "menu",
|
|
1028
|
+
style: v,
|
|
1029
|
+
"data-placement": b,
|
|
1030
|
+
onClick: (e) => e.stopPropagation(),
|
|
1031
|
+
onKeyDown: k,
|
|
1032
|
+
children: e.map((e, t) => {
|
|
1033
|
+
let n = (e.className || "").trim(), r = e.disabled, i = /* @__PURE__ */ d("button", {
|
|
1034
|
+
type: "button",
|
|
1035
|
+
className: `vl-dropdown-item ${n} ${r ? "is-disabled" : ""}`.trim(),
|
|
1036
|
+
disabled: r,
|
|
1037
|
+
role: "menuitem",
|
|
1038
|
+
onClick: (t) => E(e, t),
|
|
1039
|
+
children: [/* @__PURE__ */ u(p, {
|
|
1040
|
+
className: "vl-dropdown-icon",
|
|
1041
|
+
name: e.icon || a,
|
|
1042
|
+
size: 16
|
|
1043
|
+
}), /* @__PURE__ */ u("span", {
|
|
1044
|
+
className: "vl-dropdown-label",
|
|
1045
|
+
children: e.label
|
|
1046
|
+
})]
|
|
1047
|
+
});
|
|
1048
|
+
return /* @__PURE__ */ u(A, {
|
|
1049
|
+
text: e.tooltip || "",
|
|
1050
|
+
disabled: !e.tooltip,
|
|
1051
|
+
position: "right",
|
|
1052
|
+
className: "vl-dropdown-tooltip-wrapper",
|
|
1053
|
+
children: i
|
|
1054
|
+
}, t);
|
|
1055
|
+
})
|
|
1056
|
+
}), document.body)]
|
|
1057
|
+
});
|
|
1058
|
+
}, W = (e) => {
|
|
1059
|
+
if (e !== void 0) return typeof e == "number" ? `${e}px` : e;
|
|
1060
|
+
}, G = (e) => ({
|
|
1061
|
+
width: W(e.width),
|
|
1062
|
+
minWidth: W(e.minWidth),
|
|
1063
|
+
textAlign: e.headerAlign || e.align || "center"
|
|
1064
|
+
}), K = (e) => ({
|
|
1065
|
+
width: W(e.width),
|
|
1066
|
+
minWidth: W(e.minWidth),
|
|
1067
|
+
textAlign: e.align || "left"
|
|
1068
|
+
});
|
|
1069
|
+
function te({ data: e, columns: t, border: n = !1, emptyText: r = "暂无数据", rowKey: i, slots: a, headerSlots: o, emptySlot: s, onRowMouseEnter: c, onRowContextMenu: l, selectable: f = !1, selectedRowKeys: p = [], onSelectedRowKeysChange: m, onSelectionChange: h, rowSelectable: g, selectAllLabel: _ = "Select all rows on this page", selectRowLabel: y = "Select row", selectionColumnWidth: b = 48, className: x = "", ...S }) {
|
|
1070
|
+
let C = (e, n) => {
|
|
1071
|
+
let r = (n === "left" ? t.slice(0, e) : t.slice(e + 1)).filter((e) => e.fixed === n).reduce((e, t) => e + (typeof t.width == "number" ? t.width : 0), 0);
|
|
1072
|
+
return n === "left" && f ? r + b : r;
|
|
1073
|
+
}, w = (e, t, n = !1) => {
|
|
1074
|
+
let r = n ? G(e) : K(e);
|
|
1075
|
+
return e.fixed ? {
|
|
1076
|
+
...r,
|
|
1077
|
+
position: "sticky",
|
|
1078
|
+
[e.fixed]: C(t, e.fixed)
|
|
1079
|
+
} : r;
|
|
1080
|
+
}, T = (e, t) => typeof i == "function" ? i(e) : i ? e[i] : t, E = (e, t) => g?.(e, t) ?? !0, D = e.map((e, t) => ({
|
|
1081
|
+
row: e,
|
|
1082
|
+
index: t,
|
|
1083
|
+
key: T(e, t)
|
|
1084
|
+
})).filter(({ row: e, index: t }) => E(e, t)), O = new Set(p), k = D.length > 0 && D.every(({ key: e }) => O.has(e)), A = !k && D.some(({ key: e }) => O.has(e)), j = (e, t) => typeof y == "function" ? y(e, t) : y, M = (e) => {
|
|
1085
|
+
m?.(e), h?.(e);
|
|
1086
|
+
}, N = (e, t, n) => {
|
|
1087
|
+
if (!E(e, t)) return;
|
|
1088
|
+
let r = new Set(p), i = T(e, t);
|
|
1089
|
+
n ? r.add(i) : r.delete(i), M([...r]);
|
|
1090
|
+
}, P = (e) => {
|
|
1091
|
+
let t = new Set(p);
|
|
1092
|
+
for (let { key: n } of D) e ? t.add(n) : t.delete(n);
|
|
1093
|
+
M([...t]);
|
|
1094
|
+
};
|
|
1095
|
+
return /* @__PURE__ */ u("div", {
|
|
1096
|
+
className: `vl-table-container ${n ? "vl-table-border" : ""} ${x}`.trim(),
|
|
1097
|
+
"data-native-context-menu": "true",
|
|
1098
|
+
...S,
|
|
1099
|
+
children: /* @__PURE__ */ u("div", {
|
|
1100
|
+
className: "vl-table-wrapper",
|
|
1101
|
+
children: /* @__PURE__ */ d("table", {
|
|
1102
|
+
className: "vl-table",
|
|
1103
|
+
children: [/* @__PURE__ */ u("thead", { children: /* @__PURE__ */ d("tr", {
|
|
1104
|
+
className: "vl-table-header-row",
|
|
1105
|
+
children: [f && /* @__PURE__ */ u("th", {
|
|
1106
|
+
className: "vl-table-header-cell vl-table-selection-cell is-fixed-left",
|
|
1107
|
+
style: {
|
|
1108
|
+
width: b,
|
|
1109
|
+
minWidth: b,
|
|
1110
|
+
left: 0
|
|
1111
|
+
},
|
|
1112
|
+
"data-slot": "selection-header",
|
|
1113
|
+
children: /* @__PURE__ */ u("div", {
|
|
1114
|
+
className: "vl-cell vl-table-selection-control",
|
|
1115
|
+
children: /* @__PURE__ */ u(v, {
|
|
1116
|
+
checked: k,
|
|
1117
|
+
indeterminate: A,
|
|
1118
|
+
disabled: D.length === 0,
|
|
1119
|
+
ariaLabel: _,
|
|
1120
|
+
"data-ui": "table-select-all",
|
|
1121
|
+
onChange: P
|
|
1122
|
+
})
|
|
1123
|
+
})
|
|
1124
|
+
}), t.map((e, t) => /* @__PURE__ */ u("th", {
|
|
1125
|
+
className: `vl-table-header-cell ${e.fixed ? `is-fixed-${e.fixed}` : ""}`.trim(),
|
|
1126
|
+
style: w(e, t, !0),
|
|
1127
|
+
children: /* @__PURE__ */ u("div", {
|
|
1128
|
+
className: "vl-cell",
|
|
1129
|
+
children: e.renderHeader ? e.renderHeader(e, t) : e.headerSlot && o && o[e.headerSlot] ? o[e.headerSlot]({
|
|
1130
|
+
column: e,
|
|
1131
|
+
index: t
|
|
1132
|
+
}) : e.label
|
|
1133
|
+
})
|
|
1134
|
+
}, t))]
|
|
1135
|
+
}) }), /* @__PURE__ */ u("tbody", { children: e.length > 0 ? e.map((e, n) => /* @__PURE__ */ d("tr", {
|
|
1136
|
+
className: `vl-table-row ${f && O.has(T(e, n)) ? "is-selected" : ""}`.trim(),
|
|
1137
|
+
onMouseEnter: (t) => c?.(e, t, n),
|
|
1138
|
+
onContextMenu: (t) => l?.(e, t, n),
|
|
1139
|
+
children: [f && /* @__PURE__ */ u("td", {
|
|
1140
|
+
className: "vl-table-cell vl-table-selection-cell is-fixed-left",
|
|
1141
|
+
style: {
|
|
1142
|
+
width: b,
|
|
1143
|
+
minWidth: b,
|
|
1144
|
+
left: 0
|
|
1145
|
+
},
|
|
1146
|
+
"data-slot": "selection-cell",
|
|
1147
|
+
children: /* @__PURE__ */ u("div", {
|
|
1148
|
+
className: "vl-cell vl-table-selection-control",
|
|
1149
|
+
children: /* @__PURE__ */ u(v, {
|
|
1150
|
+
checked: O.has(T(e, n)),
|
|
1151
|
+
disabled: !E(e, n),
|
|
1152
|
+
ariaLabel: j(e, n),
|
|
1153
|
+
"data-ui": "table-row-selection",
|
|
1154
|
+
onChange: (t) => N(e, n, t)
|
|
1155
|
+
})
|
|
1156
|
+
})
|
|
1157
|
+
}), t.map((t, r) => /* @__PURE__ */ u("td", {
|
|
1158
|
+
className: `vl-table-cell ${t.fixed ? `is-fixed-${t.fixed}` : ""}`.trim(),
|
|
1159
|
+
style: w(t, r),
|
|
1160
|
+
children: /* @__PURE__ */ u("div", {
|
|
1161
|
+
className: "vl-cell",
|
|
1162
|
+
children: t.renderCell ? t.renderCell(e, t, n) : t.slot && a && a[t.slot] ? a[t.slot]({
|
|
1163
|
+
row: e,
|
|
1164
|
+
column: t,
|
|
1165
|
+
index: n
|
|
1166
|
+
}) : t.prop ? String(e[t.prop] ?? "") : ""
|
|
1167
|
+
})
|
|
1168
|
+
}, r))]
|
|
1169
|
+
}, T(e, n))) : /* @__PURE__ */ u("tr", { children: /* @__PURE__ */ u("td", {
|
|
1170
|
+
colSpan: t.length + +!!f,
|
|
1171
|
+
className: "vl-table-empty-cell",
|
|
1172
|
+
children: s || /* @__PURE__ */ u("div", {
|
|
1173
|
+
className: "vl-table-empty",
|
|
1174
|
+
children: r
|
|
1175
|
+
})
|
|
1176
|
+
}) }) })]
|
|
1177
|
+
})
|
|
1178
|
+
})
|
|
1179
|
+
});
|
|
1180
|
+
}
|
|
1181
|
+
//#endregion
|
|
1182
|
+
//#region src/components/VustSelectionBar/VustSelectionBar.tsx
|
|
1183
|
+
var q = ({ count: e, label: t, clearLabel: n, clearDisabled: r = !1, ariaLabel: i, onClear: a, children: o, className: s = "", ...c }) => /* @__PURE__ */ d("div", {
|
|
1184
|
+
className: `vl-selection-bar ${s}`.trim(),
|
|
1185
|
+
...c,
|
|
1186
|
+
"data-ui": "selection-bar",
|
|
1187
|
+
children: [/* @__PURE__ */ d("div", {
|
|
1188
|
+
className: "vl-selection-summary",
|
|
1189
|
+
role: "status",
|
|
1190
|
+
"aria-live": "polite",
|
|
1191
|
+
"aria-atomic": "true",
|
|
1192
|
+
"aria-label": i,
|
|
1193
|
+
"data-slot": "selection-summary",
|
|
1194
|
+
children: [/* @__PURE__ */ u("span", {
|
|
1195
|
+
className: "vl-selection-label",
|
|
1196
|
+
children: t
|
|
1197
|
+
}), /* @__PURE__ */ u("span", {
|
|
1198
|
+
className: "vl-selection-count",
|
|
1199
|
+
children: e
|
|
1200
|
+
})]
|
|
1201
|
+
}), /* @__PURE__ */ d("div", {
|
|
1202
|
+
className: "vl-selection-actions",
|
|
1203
|
+
"data-slot": "selection-actions",
|
|
1204
|
+
children: [o, n && /* @__PURE__ */ u(m, {
|
|
1205
|
+
disabled: r,
|
|
1206
|
+
"data-ui": "clear-selection",
|
|
1207
|
+
onClick: a,
|
|
1208
|
+
children: n
|
|
1209
|
+
})]
|
|
1210
|
+
})]
|
|
1211
|
+
});
|
|
1212
|
+
//#endregion
|
|
1213
|
+
//#region src/components/VustDateTimeRangePicker/VustDateTimeRangePicker.tsx
|
|
1214
|
+
function ne(e) {
|
|
1215
|
+
return e ? new Date(e) : /* @__PURE__ */ new Date();
|
|
1216
|
+
}
|
|
1217
|
+
function J(e) {
|
|
1218
|
+
return new Date(e.getFullYear(), e.getMonth(), 1, 0, 0, 0, 0);
|
|
1219
|
+
}
|
|
1220
|
+
function Y(e) {
|
|
1221
|
+
return new Date(e.getFullYear(), e.getMonth(), e.getDate(), 0, 0, 0, 0);
|
|
1222
|
+
}
|
|
1223
|
+
function re(e) {
|
|
1224
|
+
return new Date(e.getFullYear(), e.getMonth(), e.getDate(), 23, 59, 59, 999);
|
|
1225
|
+
}
|
|
1226
|
+
function ie(e, t) {
|
|
1227
|
+
let n = new Date(e);
|
|
1228
|
+
return n.setDate(n.getDate() + t), n;
|
|
1229
|
+
}
|
|
1230
|
+
function X(e) {
|
|
1231
|
+
let t = String(e.getMonth() + 1).padStart(2, "0"), n = String(e.getDate()).padStart(2, "0");
|
|
1232
|
+
return `${e.getFullYear()}-${t}-${n}`;
|
|
1233
|
+
}
|
|
1234
|
+
function Z(e) {
|
|
1235
|
+
if (!e) return "--";
|
|
1236
|
+
let t = new Date(e);
|
|
1237
|
+
return `${t.getFullYear()}-${String(t.getMonth() + 1).padStart(2, "0")}-${String(t.getDate()).padStart(2, "0")} ${String(t.getHours()).padStart(2, "0")}:${String(t.getMinutes()).padStart(2, "0")}`;
|
|
1238
|
+
}
|
|
1239
|
+
function Q(e) {
|
|
1240
|
+
let t = e.startAt ?? null, n = e.endAt ?? null;
|
|
1241
|
+
return t !== null && n !== null && t > n ? {
|
|
1242
|
+
startAt: n,
|
|
1243
|
+
endAt: t
|
|
1244
|
+
} : {
|
|
1245
|
+
startAt: t,
|
|
1246
|
+
endAt: n
|
|
1247
|
+
};
|
|
1248
|
+
}
|
|
1249
|
+
var ae = [
|
|
1250
|
+
{
|
|
1251
|
+
label: "最近 15 分钟",
|
|
1252
|
+
value: "15m"
|
|
1253
|
+
},
|
|
1254
|
+
{
|
|
1255
|
+
label: "最近 1 小时",
|
|
1256
|
+
value: "1h"
|
|
1257
|
+
},
|
|
1258
|
+
{
|
|
1259
|
+
label: "最近 24 小时",
|
|
1260
|
+
value: "24h"
|
|
1261
|
+
},
|
|
1262
|
+
{
|
|
1263
|
+
label: "最近 7 天",
|
|
1264
|
+
value: "7d"
|
|
1265
|
+
},
|
|
1266
|
+
{
|
|
1267
|
+
label: "今天",
|
|
1268
|
+
value: "today"
|
|
1269
|
+
}
|
|
1270
|
+
], $ = ({ value: e, placeholder: n = "请选择时间范围", startLabel: i = "开始时间", endLabel: a = "结束时间", shortcutsLabel: l = "常用范围", calendarLabel: p = "选择日期", timeLabel: m = "选择时间", clearLabel: h = "清空", confirmLabel: g = "确定", cancelLabel: _ = "取消", locale: v = "zh", weekDays: y = [
|
|
1271
|
+
"日",
|
|
1272
|
+
"一",
|
|
1273
|
+
"二",
|
|
1274
|
+
"三",
|
|
1275
|
+
"四",
|
|
1276
|
+
"五",
|
|
1277
|
+
"六"
|
|
1278
|
+
], shortcuts: b = ae, disabled: x = !1, onChange: S, onApply: C, className: w = "", ...T }) => {
|
|
1279
|
+
let E = s(null), D = s(null), [O, k] = c(!1), [A, j] = c("start"), [M, N] = c(() => Q(e)), [P, F] = c(() => J(/* @__PURE__ */ new Date())), [I, L] = c({}), [R, z] = c("bottom"), ee = o(() => Array.from({ length: 24 }, (e, t) => t), []), V = o(() => Array.from({ length: 12 }, (e, t) => t * 5), []), H = o(() => !e.startAt && !e.endAt ? n : `${Z(e.startAt)} - ${Z(e.endAt)}`, [e, n]), U = o(() => ne(M[A === "start" ? "startAt" : "endAt"]), [M, A]), W = U.getHours(), G = Math.floor(U.getMinutes() / 5) * 5, K = o(() => P.toLocaleDateString(v === "zh" ? "zh-CN" : "en-US", {
|
|
1280
|
+
year: "numeric",
|
|
1281
|
+
month: "long"
|
|
1282
|
+
}), [P, v]), te = o(() => {
|
|
1283
|
+
let e = J(P), t = ie(e, -e.getDay());
|
|
1284
|
+
return Array.from({ length: 42 }, (e, n) => {
|
|
1285
|
+
let r = ie(t, n), i = r.getTime(), a = M.startAt ? Y(new Date(M.startAt)).getTime() : null, o = M.endAt ? Y(new Date(M.endAt)).getTime() : null, s = a !== null && o !== null ? Math.min(a, o) : null, c = a !== null && o !== null ? Math.max(a, o) : null;
|
|
1286
|
+
return {
|
|
1287
|
+
date: r,
|
|
1288
|
+
key: X(r),
|
|
1289
|
+
label: String(r.getDate()),
|
|
1290
|
+
muted: r.getMonth() !== P.getMonth(),
|
|
1291
|
+
today: X(r) === X(/* @__PURE__ */ new Date()),
|
|
1292
|
+
selectedStart: a === i,
|
|
1293
|
+
selectedEnd: o === i,
|
|
1294
|
+
inRange: s !== null && c !== null && i > s && i < c
|
|
1295
|
+
};
|
|
1296
|
+
});
|
|
1297
|
+
}, [P, M]), q = t(() => {
|
|
1298
|
+
let e = E.current;
|
|
1299
|
+
if (!e || !D.current) return;
|
|
1300
|
+
let t = B({
|
|
1301
|
+
anchor: e,
|
|
1302
|
+
floating: D.current,
|
|
1303
|
+
gap: 8,
|
|
1304
|
+
maxHeight: window.innerHeight - 16
|
|
1305
|
+
});
|
|
1306
|
+
z(t.placement), L({
|
|
1307
|
+
...t.style,
|
|
1308
|
+
width: `${Math.min(620, window.innerWidth - 16)}px`
|
|
1309
|
+
});
|
|
1310
|
+
}, []), $ = t(() => {
|
|
1311
|
+
k(!1);
|
|
1312
|
+
}, []), oe = t((e) => {
|
|
1313
|
+
let t = e.target;
|
|
1314
|
+
E.current?.contains(t) || D.current?.contains(t) || $();
|
|
1315
|
+
}, [$]), se = t((e) => {
|
|
1316
|
+
e.key === "Escape" && $();
|
|
1317
|
+
}, [$]);
|
|
1318
|
+
r(() => {
|
|
1319
|
+
O || N(Q(e));
|
|
1320
|
+
}, [e, O]), r(() => (O && (q(), window.addEventListener("resize", q), window.addEventListener("scroll", q, !0), document.addEventListener("mousedown", oe), document.addEventListener("keydown", se)), () => {
|
|
1321
|
+
window.removeEventListener("resize", q), window.removeEventListener("scroll", q, !0), document.removeEventListener("mousedown", oe), document.removeEventListener("keydown", se);
|
|
1322
|
+
}), [
|
|
1323
|
+
O,
|
|
1324
|
+
q,
|
|
1325
|
+
oe,
|
|
1326
|
+
se
|
|
1327
|
+
]);
|
|
1328
|
+
let ce = () => {
|
|
1329
|
+
if (x) return;
|
|
1330
|
+
let t = Q(e);
|
|
1331
|
+
N(t);
|
|
1332
|
+
let n = t.startAt ?? t.endAt ?? Date.now();
|
|
1333
|
+
F(J(new Date(n))), k(!0);
|
|
1334
|
+
}, le = (e) => {
|
|
1335
|
+
F((t) => new Date(t.getFullYear(), t.getMonth() + e, 1));
|
|
1336
|
+
}, ue = (e) => {
|
|
1337
|
+
let t = U, n = new Date(e.getFullYear(), e.getMonth(), e.getDate(), t.getHours(), t.getMinutes(), 0, 0), r = A === "start" ? "startAt" : "endAt";
|
|
1338
|
+
N((e) => Q({
|
|
1339
|
+
...e,
|
|
1340
|
+
[r]: n.getTime()
|
|
1341
|
+
}));
|
|
1342
|
+
}, de = (e, t) => {
|
|
1343
|
+
let n = U, r = new Date(n.getFullYear(), n.getMonth(), n.getDate(), e, t, 0, 0), i = A === "start" ? "startAt" : "endAt";
|
|
1344
|
+
N((e) => Q({
|
|
1345
|
+
...e,
|
|
1346
|
+
[i]: r.getTime()
|
|
1347
|
+
}));
|
|
1348
|
+
}, fe = (e) => {
|
|
1349
|
+
let t = /* @__PURE__ */ new Date(), n;
|
|
1350
|
+
n = e === "today" ? {
|
|
1351
|
+
startAt: Y(t).getTime(),
|
|
1352
|
+
endAt: re(t).getTime()
|
|
1353
|
+
} : {
|
|
1354
|
+
startAt: t.getTime() - {
|
|
1355
|
+
"15m": 900 * 1e3,
|
|
1356
|
+
"1h": 3600 * 1e3,
|
|
1357
|
+
"24h": 1440 * 60 * 1e3,
|
|
1358
|
+
"7d": 10080 * 60 * 1e3
|
|
1359
|
+
}[e],
|
|
1360
|
+
endAt: t.getTime()
|
|
1361
|
+
}, N(n), F(J(new Date(n.startAt ?? Date.now())));
|
|
1362
|
+
}, pe = () => {
|
|
1363
|
+
let e = {
|
|
1364
|
+
startAt: null,
|
|
1365
|
+
endAt: null
|
|
1366
|
+
};
|
|
1367
|
+
N(e), S?.(e), C?.(e), $();
|
|
1368
|
+
}, me = () => {
|
|
1369
|
+
let e = Q(M);
|
|
1370
|
+
S?.(e), C?.(e), $();
|
|
1371
|
+
};
|
|
1372
|
+
return /* @__PURE__ */ d("div", {
|
|
1373
|
+
className: `vl-date-time-range-picker ${w}`.trim(),
|
|
1374
|
+
"data-ui": "date-time-range-picker",
|
|
1375
|
+
...T,
|
|
1376
|
+
children: [/* @__PURE__ */ u("button", {
|
|
1377
|
+
ref: E,
|
|
1378
|
+
type: "button",
|
|
1379
|
+
className: `range-trigger ${!e.startAt && !e.endAt ? "is-placeholder" : ""}`.trim(),
|
|
1380
|
+
disabled: x,
|
|
1381
|
+
onClick: () => O ? $() : ce(),
|
|
1382
|
+
children: /* @__PURE__ */ u("span", {
|
|
1383
|
+
className: "trigger-text",
|
|
1384
|
+
children: H
|
|
1385
|
+
})
|
|
1386
|
+
}), O && f(/* @__PURE__ */ d("div", {
|
|
1387
|
+
ref: D,
|
|
1388
|
+
className: "range-panel",
|
|
1389
|
+
style: I,
|
|
1390
|
+
"data-placement": R,
|
|
1391
|
+
children: [
|
|
1392
|
+
/* @__PURE__ */ d("aside", {
|
|
1393
|
+
className: "shortcut-column",
|
|
1394
|
+
children: [/* @__PURE__ */ u("div", {
|
|
1395
|
+
className: "panel-title",
|
|
1396
|
+
children: l
|
|
1397
|
+
}), b.map((e) => /* @__PURE__ */ u("button", {
|
|
1398
|
+
type: "button",
|
|
1399
|
+
className: "shortcut-button",
|
|
1400
|
+
onClick: () => fe(e.value),
|
|
1401
|
+
children: e.label
|
|
1402
|
+
}, e.value))]
|
|
1403
|
+
}),
|
|
1404
|
+
/* @__PURE__ */ d("section", {
|
|
1405
|
+
className: "calendar-column",
|
|
1406
|
+
children: [
|
|
1407
|
+
/* @__PURE__ */ u("div", {
|
|
1408
|
+
className: "panel-title",
|
|
1409
|
+
children: p
|
|
1410
|
+
}),
|
|
1411
|
+
/* @__PURE__ */ d("div", {
|
|
1412
|
+
className: "boundary-switch",
|
|
1413
|
+
children: [/* @__PURE__ */ d("button", {
|
|
1414
|
+
type: "button",
|
|
1415
|
+
className: `boundary-button ${A === "start" ? "is-active" : ""}`.trim(),
|
|
1416
|
+
onClick: () => j("start"),
|
|
1417
|
+
children: [/* @__PURE__ */ u("span", { children: i }), /* @__PURE__ */ u("strong", { children: Z(M.startAt) })]
|
|
1418
|
+
}), /* @__PURE__ */ d("button", {
|
|
1419
|
+
type: "button",
|
|
1420
|
+
className: `boundary-button ${A === "end" ? "is-active" : ""}`.trim(),
|
|
1421
|
+
onClick: () => j("end"),
|
|
1422
|
+
children: [/* @__PURE__ */ u("span", { children: a }), /* @__PURE__ */ u("strong", { children: Z(M.endAt) })]
|
|
1423
|
+
})]
|
|
1424
|
+
}),
|
|
1425
|
+
/* @__PURE__ */ d("div", {
|
|
1426
|
+
className: "calendar-header",
|
|
1427
|
+
children: [
|
|
1428
|
+
/* @__PURE__ */ u("button", {
|
|
1429
|
+
type: "button",
|
|
1430
|
+
className: "month-button",
|
|
1431
|
+
onClick: () => le(-1),
|
|
1432
|
+
children: "‹"
|
|
1433
|
+
}),
|
|
1434
|
+
/* @__PURE__ */ u("span", { children: K }),
|
|
1435
|
+
/* @__PURE__ */ u("button", {
|
|
1436
|
+
type: "button",
|
|
1437
|
+
className: "month-button",
|
|
1438
|
+
onClick: () => le(1),
|
|
1439
|
+
children: "›"
|
|
1440
|
+
})
|
|
1441
|
+
]
|
|
1442
|
+
}),
|
|
1443
|
+
/* @__PURE__ */ u("div", {
|
|
1444
|
+
className: "week-grid",
|
|
1445
|
+
children: y.map((e) => /* @__PURE__ */ u("span", { children: e }, e))
|
|
1446
|
+
}),
|
|
1447
|
+
/* @__PURE__ */ u("div", {
|
|
1448
|
+
className: "day-grid",
|
|
1449
|
+
children: te.map((e) => /* @__PURE__ */ u("button", {
|
|
1450
|
+
type: "button",
|
|
1451
|
+
className: `day-button ${e.muted ? "is-muted" : ""} ${e.today ? "is-today" : ""} ${e.selectedStart ? "is-selected-start" : ""} ${e.selectedEnd ? "is-selected-end" : ""} ${e.inRange ? "is-in-range" : ""}`.trim(),
|
|
1452
|
+
onClick: () => ue(e.date),
|
|
1453
|
+
children: e.label
|
|
1454
|
+
}, e.key))
|
|
1455
|
+
})
|
|
1456
|
+
]
|
|
1457
|
+
}),
|
|
1458
|
+
/* @__PURE__ */ d("section", {
|
|
1459
|
+
className: "time-column",
|
|
1460
|
+
children: [/* @__PURE__ */ u("div", {
|
|
1461
|
+
className: "panel-title",
|
|
1462
|
+
children: m
|
|
1463
|
+
}), /* @__PURE__ */ d("div", {
|
|
1464
|
+
className: "time-lists",
|
|
1465
|
+
children: [/* @__PURE__ */ u("div", {
|
|
1466
|
+
className: "time-list",
|
|
1467
|
+
children: ee.map((e) => /* @__PURE__ */ u("button", {
|
|
1468
|
+
type: "button",
|
|
1469
|
+
className: `time-option ${W === e ? "is-active" : ""}`.trim(),
|
|
1470
|
+
onClick: () => de(e, G),
|
|
1471
|
+
children: String(e).padStart(2, "0")
|
|
1472
|
+
}, e))
|
|
1473
|
+
}), /* @__PURE__ */ u("div", {
|
|
1474
|
+
className: "time-list",
|
|
1475
|
+
children: V.map((e) => /* @__PURE__ */ u("button", {
|
|
1476
|
+
type: "button",
|
|
1477
|
+
className: `time-option ${G === e ? "is-active" : ""}`.trim(),
|
|
1478
|
+
onClick: () => de(W, e),
|
|
1479
|
+
children: String(e).padStart(2, "0")
|
|
1480
|
+
}, e))
|
|
1481
|
+
})]
|
|
1482
|
+
})]
|
|
1483
|
+
}),
|
|
1484
|
+
/* @__PURE__ */ d("footer", {
|
|
1485
|
+
className: "panel-actions",
|
|
1486
|
+
children: [
|
|
1487
|
+
/* @__PURE__ */ u("button", {
|
|
1488
|
+
type: "button",
|
|
1489
|
+
className: "text-button",
|
|
1490
|
+
onClick: pe,
|
|
1491
|
+
children: h
|
|
1492
|
+
}),
|
|
1493
|
+
/* @__PURE__ */ u("span", { className: "action-spacer" }),
|
|
1494
|
+
/* @__PURE__ */ u("button", {
|
|
1495
|
+
type: "button",
|
|
1496
|
+
className: "text-button",
|
|
1497
|
+
onClick: $,
|
|
1498
|
+
children: _
|
|
1499
|
+
}),
|
|
1500
|
+
/* @__PURE__ */ u("button", {
|
|
1501
|
+
type: "button",
|
|
1502
|
+
className: "confirm-button",
|
|
1503
|
+
onClick: me,
|
|
1504
|
+
children: g
|
|
1505
|
+
})
|
|
1506
|
+
]
|
|
1507
|
+
})
|
|
1508
|
+
]
|
|
1509
|
+
}), document.body)]
|
|
1510
|
+
});
|
|
1511
|
+
};
|
|
1512
|
+
//#endregion
|
|
1513
|
+
export { U as VustActionMenu, g as VustAlert, w as VustBreadcrumb, T as VustBreadcrumbItem, m as VustButton, _ as VustCard, v as VustCheckbox, $ as VustDateTimeRangePicker, k as VustDescriptions, I as VustDialog, L as VustDrawer, y as VustEmpty, b as VustFormItem, p as VustIcon, E as VustInput, x as VustLoading, D as VustMenu, R as VustModal, z as VustPagination, V as VustSelect, q as VustSelectionBar, h as VustSwitch, te as VustTable, O as VustTabs, S as VustTag, j as VustToast, A as VustTooltip };
|