@seclab-dev/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 +65 -0
- package/dist/components/SecLabActionMenu/SecLabActionMenu.d.ts +21 -0
- package/dist/components/SecLabAlert/SecLabAlert.d.ts +18 -0
- package/dist/components/SecLabBreadcrumb/SecLabBreadcrumb.d.ts +7 -0
- package/dist/components/SecLabBreadcrumbItem/SecLabBreadcrumbItem.d.ts +6 -0
- package/dist/components/SecLabButton/SecLabButton.d.ts +10 -0
- package/dist/components/SecLabCard/SecLabCard.d.ts +16 -0
- package/dist/components/SecLabCheckbox/SecLabCheckbox.d.ts +10 -0
- package/dist/components/SecLabDateTimeRangePicker/SecLabDateTimeRangePicker.d.ts +44 -0
- package/dist/components/SecLabDescriptions/SecLabDescriptions.d.ts +23 -0
- package/dist/components/SecLabDialog/SecLabDialog.d.ts +20 -0
- package/dist/components/SecLabDrawer/SecLabDrawer.d.ts +18 -0
- package/dist/components/SecLabEmpty/SecLabEmpty.d.ts +14 -0
- package/dist/components/SecLabFormItem/SecLabFormItem.d.ts +10 -0
- package/dist/components/SecLabIcon/SecLabIcon.d.ts +10 -0
- package/dist/components/SecLabInput/SecLabInput.d.ts +37 -0
- package/dist/components/SecLabLoading/SecLabLoading.d.ts +10 -0
- package/dist/components/SecLabMenu/SecLabMenu.d.ts +21 -0
- package/dist/components/SecLabModal/SecLabModal.d.ts +20 -0
- package/dist/components/SecLabPagination/SecLabPagination.d.ts +12 -0
- package/dist/components/SecLabSelect/SecLabSelect.d.ts +22 -0
- package/dist/components/SecLabSwitch/SecLabSwitch.d.ts +8 -0
- package/dist/components/SecLabTable/SecLabTable.d.ts +42 -0
- package/dist/components/SecLabTabs/SecLabTabs.d.ts +17 -0
- package/dist/components/SecLabTag/SecLabTag.d.ts +8 -0
- package/dist/components/SecLabToast/SecLabToast.d.ts +14 -0
- package/dist/components/SecLabTooltip/SecLabTooltip.d.ts +15 -0
- package/dist/index.d.ts +52 -0
- package/dist/index.js +1134 -0
- package/dist/style.css +2 -0
- package/package.json +45 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,1134 @@
|
|
|
1
|
+
import { createContext as e, useCallback as t, useContext as n, useEffect as r, useMemo as i, useRef as a, useState as o } from "react";
|
|
2
|
+
import { getIcon as s } from "@seclab-dev/icons";
|
|
3
|
+
import { jsx as c, jsxs as l } from "react/jsx-runtime";
|
|
4
|
+
import { createPortal as u } from "react-dom";
|
|
5
|
+
//#region src/components/SecLabIcon/SecLabIcon.tsx
|
|
6
|
+
var d = ({ name: e = "fallback", namespace: t = "common", size: n = 24, label: r = "", decorative: a = !0, className: o = "", style: l, ...u }) => {
|
|
7
|
+
let d = i(() => {
|
|
8
|
+
let t = (e ?? "").trim().toLowerCase();
|
|
9
|
+
return /^[a-z0-9-]+$/.test(t) ? t : "fallback";
|
|
10
|
+
}, [e]), f = i(() => s(d, t), [d, t]), p = {
|
|
11
|
+
"--sl-icon-size": i(() => typeof n == "number" ? `${n}px` : n, [n]),
|
|
12
|
+
...l
|
|
13
|
+
};
|
|
14
|
+
return /* @__PURE__ */ c("span", {
|
|
15
|
+
className: `sl-icon ${o}`.trim(),
|
|
16
|
+
style: p,
|
|
17
|
+
"aria-hidden": a ? "true" : void 0,
|
|
18
|
+
role: a ? void 0 : "img",
|
|
19
|
+
"aria-label": a ? void 0 : r || d,
|
|
20
|
+
dangerouslySetInnerHTML: { __html: f },
|
|
21
|
+
...u
|
|
22
|
+
});
|
|
23
|
+
}, f = ({ type: e = "secondary", size: t = "default", disabled: n = !1, loading: r = !1, onClick: i, className: a = "", children: o, ...s }) => {
|
|
24
|
+
let u = (e) => {
|
|
25
|
+
n || r || i?.(e);
|
|
26
|
+
}, d = n || r;
|
|
27
|
+
return /* @__PURE__ */ l("button", {
|
|
28
|
+
className: `sl-button sl-button--${e} sl-button--${t} ${r ? "is-loading" : ""} ${a}`.trim(),
|
|
29
|
+
disabled: d,
|
|
30
|
+
type: "button",
|
|
31
|
+
onClick: u,
|
|
32
|
+
...s,
|
|
33
|
+
children: [r && /* @__PURE__ */ c("span", {
|
|
34
|
+
className: "sl-button-loading-icon",
|
|
35
|
+
children: /* @__PURE__ */ c("svg", {
|
|
36
|
+
className: "sl-spinner",
|
|
37
|
+
viewBox: "0 0 50 50",
|
|
38
|
+
children: /* @__PURE__ */ c("circle", {
|
|
39
|
+
className: "path",
|
|
40
|
+
cx: "25",
|
|
41
|
+
cy: "25",
|
|
42
|
+
r: "20",
|
|
43
|
+
fill: "none",
|
|
44
|
+
strokeWidth: "5"
|
|
45
|
+
})
|
|
46
|
+
})
|
|
47
|
+
}), /* @__PURE__ */ c("span", {
|
|
48
|
+
className: "sl-button-content",
|
|
49
|
+
children: o
|
|
50
|
+
})]
|
|
51
|
+
});
|
|
52
|
+
}, p = ({ value: e, onChange: t, activeText: n = "", disabled: r = !1, className: i = "", ...a }) => /* @__PURE__ */ l("div", {
|
|
53
|
+
className: `sl-switch ${e ? "is-active" : ""} ${r ? "is-disabled" : ""} ${i}`.trim(),
|
|
54
|
+
onClick: () => {
|
|
55
|
+
r || t?.(!e);
|
|
56
|
+
},
|
|
57
|
+
...a,
|
|
58
|
+
children: [/* @__PURE__ */ c("div", {
|
|
59
|
+
className: "sl-switch-track",
|
|
60
|
+
children: /* @__PURE__ */ c("div", { className: "sl-switch-handle" })
|
|
61
|
+
}), n && /* @__PURE__ */ c("span", {
|
|
62
|
+
className: "sl-switch-label",
|
|
63
|
+
children: n
|
|
64
|
+
})]
|
|
65
|
+
}), m = ({ title: e, description: t, type: n = "info", showIcon: r = !1, closable: i = !1, onClose: a, className: s = "", children: u, ...f }) => {
|
|
66
|
+
let [p, m] = o(!0);
|
|
67
|
+
if (!p) return null;
|
|
68
|
+
let h = (e) => {
|
|
69
|
+
m(!1), a?.();
|
|
70
|
+
}, g = (e) => e === "success" ? "success" : e === "error" ? "error" : e === "warning" ? "warning" : "info";
|
|
71
|
+
return /* @__PURE__ */ l("div", {
|
|
72
|
+
className: `sl-alert is-${n} ${s}`.trim(),
|
|
73
|
+
role: "alert",
|
|
74
|
+
...f,
|
|
75
|
+
children: [
|
|
76
|
+
r && /* @__PURE__ */ c("div", {
|
|
77
|
+
className: "sl-alert-icon",
|
|
78
|
+
children: /* @__PURE__ */ c(d, {
|
|
79
|
+
name: g(n),
|
|
80
|
+
size: 16
|
|
81
|
+
})
|
|
82
|
+
}),
|
|
83
|
+
/* @__PURE__ */ l("div", {
|
|
84
|
+
className: "sl-alert-content",
|
|
85
|
+
children: [e && /* @__PURE__ */ c("h4", {
|
|
86
|
+
className: "sl-alert-title",
|
|
87
|
+
children: e
|
|
88
|
+
}), /* @__PURE__ */ c("div", {
|
|
89
|
+
className: "sl-alert-description",
|
|
90
|
+
children: u || t
|
|
91
|
+
})]
|
|
92
|
+
}),
|
|
93
|
+
i && /* @__PURE__ */ c("button", {
|
|
94
|
+
type: "button",
|
|
95
|
+
className: "sl-alert-close",
|
|
96
|
+
onClick: h,
|
|
97
|
+
children: "×"
|
|
98
|
+
})
|
|
99
|
+
]
|
|
100
|
+
});
|
|
101
|
+
}, h = ({ shadow: e = "always", contentStyle: t, contentRole: n = "content", fullHeight: r = !1, header: i, className: a = "", children: o, ...s }) => /* @__PURE__ */ l("div", {
|
|
102
|
+
className: `sl-card is-shadow-${e} ${r ? "is-full-height" : ""} ${a}`.trim(),
|
|
103
|
+
...s,
|
|
104
|
+
children: [i && /* @__PURE__ */ c("div", {
|
|
105
|
+
className: "sl-card-header",
|
|
106
|
+
children: i
|
|
107
|
+
}), /* @__PURE__ */ c("div", {
|
|
108
|
+
className: `${n === "header" ? "sl-card-header" : "sl-card-content"} ${r ? "is-full-height" : ""}`.trim(),
|
|
109
|
+
style: t,
|
|
110
|
+
children: o
|
|
111
|
+
})]
|
|
112
|
+
}), g = ({ checked: e = !1, disabled: t = !1, onChange: n, className: r = "", children: i, ...a }) => {
|
|
113
|
+
let o = (e) => {
|
|
114
|
+
t || n?.(e.target.checked);
|
|
115
|
+
};
|
|
116
|
+
return /* @__PURE__ */ l("label", {
|
|
117
|
+
className: `sl-checkbox ${e ? "is-active" : ""} ${t ? "is-disabled" : ""} ${r}`.trim(),
|
|
118
|
+
...a,
|
|
119
|
+
children: [/* @__PURE__ */ l("span", {
|
|
120
|
+
className: "sl-checkbox-input",
|
|
121
|
+
children: [/* @__PURE__ */ c("input", {
|
|
122
|
+
type: "checkbox",
|
|
123
|
+
className: "sl-checkbox-original",
|
|
124
|
+
checked: e,
|
|
125
|
+
disabled: t,
|
|
126
|
+
onChange: o
|
|
127
|
+
}), /* @__PURE__ */ c("span", { className: "sl-checkbox-inner" })]
|
|
128
|
+
}), i && /* @__PURE__ */ c("span", {
|
|
129
|
+
className: "sl-checkbox-label",
|
|
130
|
+
children: i
|
|
131
|
+
})]
|
|
132
|
+
});
|
|
133
|
+
}, _ = ({ description: e = "暂无数据", icon: t = "empty", iconNode: n, extra: r, className: i = "", children: a, ...o }) => /* @__PURE__ */ l("div", {
|
|
134
|
+
className: `sl-empty ${i}`.trim(),
|
|
135
|
+
...o,
|
|
136
|
+
children: [
|
|
137
|
+
/* @__PURE__ */ c("div", {
|
|
138
|
+
className: "sl-empty-icon",
|
|
139
|
+
children: n || /* @__PURE__ */ c(d, {
|
|
140
|
+
name: t,
|
|
141
|
+
size: 48
|
|
142
|
+
})
|
|
143
|
+
}),
|
|
144
|
+
/* @__PURE__ */ c("p", {
|
|
145
|
+
className: "sl-empty-description",
|
|
146
|
+
children: a || e
|
|
147
|
+
}),
|
|
148
|
+
r && /* @__PURE__ */ c("div", {
|
|
149
|
+
className: "sl-empty-extra",
|
|
150
|
+
children: r
|
|
151
|
+
})
|
|
152
|
+
]
|
|
153
|
+
}), v = ({ label: e, required: t = !1, hint: n, className: r = "", children: i, ...a }) => /* @__PURE__ */ l("div", {
|
|
154
|
+
className: `sl-form-item ${r}`.trim(),
|
|
155
|
+
...a,
|
|
156
|
+
children: [e && /* @__PURE__ */ l("label", {
|
|
157
|
+
className: "sl-form-item-label",
|
|
158
|
+
children: [t && /* @__PURE__ */ c("span", {
|
|
159
|
+
className: "sl-form-item-required",
|
|
160
|
+
children: "*"
|
|
161
|
+
}), e]
|
|
162
|
+
}), /* @__PURE__ */ l("div", {
|
|
163
|
+
className: "sl-form-item-content",
|
|
164
|
+
children: [i, n && /* @__PURE__ */ c("div", {
|
|
165
|
+
className: "sl-form-item-hint",
|
|
166
|
+
children: n
|
|
167
|
+
})]
|
|
168
|
+
})]
|
|
169
|
+
}), y = ({ loading: e, text: t, cover: n = !1, className: r = "", children: i, ...a }) => /* @__PURE__ */ l("div", {
|
|
170
|
+
className: `sl-loading-host ${n ? "is-cover" : ""} ${e ? "is-loading" : ""} ${r}`.trim(),
|
|
171
|
+
...a,
|
|
172
|
+
children: [i, e && /* @__PURE__ */ c("div", {
|
|
173
|
+
className: "sl-loading-mask",
|
|
174
|
+
children: /* @__PURE__ */ l("div", {
|
|
175
|
+
className: "sl-loading-spinner",
|
|
176
|
+
children: [/* @__PURE__ */ c("svg", {
|
|
177
|
+
className: "sl-spinner",
|
|
178
|
+
viewBox: "0 0 50 50",
|
|
179
|
+
children: /* @__PURE__ */ c("circle", {
|
|
180
|
+
className: "path",
|
|
181
|
+
cx: "25",
|
|
182
|
+
cy: "25",
|
|
183
|
+
r: "20",
|
|
184
|
+
fill: "none",
|
|
185
|
+
strokeWidth: "5"
|
|
186
|
+
})
|
|
187
|
+
}), t && /* @__PURE__ */ c("p", {
|
|
188
|
+
className: "sl-loading-text",
|
|
189
|
+
children: t
|
|
190
|
+
})]
|
|
191
|
+
})
|
|
192
|
+
})]
|
|
193
|
+
}), b = ({ type: e = "default", effect: t = "light", className: n = "", children: r, ...i }) => /* @__PURE__ */ c("span", {
|
|
194
|
+
className: `sl-tag sl-tag--${e} sl-tag--${t} ${n}`.trim(),
|
|
195
|
+
...i,
|
|
196
|
+
children: r
|
|
197
|
+
}), x = e("/"), S = ({ separator: e = "/", className: t = "", children: n, ...r }) => /* @__PURE__ */ c(x.Provider, {
|
|
198
|
+
value: e,
|
|
199
|
+
children: /* @__PURE__ */ c("nav", {
|
|
200
|
+
className: `sl-breadcrumb ${t}`.trim(),
|
|
201
|
+
"aria-label": "Breadcrumb",
|
|
202
|
+
...r,
|
|
203
|
+
children: n
|
|
204
|
+
})
|
|
205
|
+
}), C = ({ className: e = "", children: t, ...r }) => {
|
|
206
|
+
let i = n(x);
|
|
207
|
+
return /* @__PURE__ */ l("span", {
|
|
208
|
+
className: `sl-breadcrumb-item ${e}`.trim(),
|
|
209
|
+
...r,
|
|
210
|
+
children: [/* @__PURE__ */ c("span", {
|
|
211
|
+
className: "sl-breadcrumb-label",
|
|
212
|
+
children: t
|
|
213
|
+
}), /* @__PURE__ */ c("span", {
|
|
214
|
+
className: "sl-breadcrumb-separator",
|
|
215
|
+
role: "presentation",
|
|
216
|
+
children: i
|
|
217
|
+
})]
|
|
218
|
+
});
|
|
219
|
+
}, w = ({ value: e = "", type: t = "text", placeholder: n, disabled: r = !1, readonly: i, readOnly: a, maxlength: s, maxLength: u, rows: f = 3, showPassword: p = !1, min: m, max: h, step: g, autocomplete: _, autoComplete: v, onChange: y, onFocus: b, onBlur: x, className: S = "", ...C }) => {
|
|
220
|
+
let [w, T] = o(!1), E = (e) => {
|
|
221
|
+
y?.(e.target.value);
|
|
222
|
+
}, D = () => {
|
|
223
|
+
T((e) => !e);
|
|
224
|
+
}, O = i ?? a, k = s ?? u, A = _ ?? v, j = t === "password" && w ? "text" : t, M = e == null ? "" : String(e);
|
|
225
|
+
return /* @__PURE__ */ c("div", {
|
|
226
|
+
className: `sl-input-wrapper is-${t} ${r ? "is-disabled" : ""} ${S}`.trim(),
|
|
227
|
+
...C,
|
|
228
|
+
children: t === "textarea" ? /* @__PURE__ */ c("textarea", {
|
|
229
|
+
className: "sl-textarea",
|
|
230
|
+
value: M,
|
|
231
|
+
placeholder: n,
|
|
232
|
+
disabled: r,
|
|
233
|
+
readOnly: O,
|
|
234
|
+
maxLength: k,
|
|
235
|
+
rows: f,
|
|
236
|
+
onChange: E,
|
|
237
|
+
onFocus: b,
|
|
238
|
+
onBlur: x
|
|
239
|
+
}) : /* @__PURE__ */ l("div", {
|
|
240
|
+
className: "sl-input-inner-wrapper",
|
|
241
|
+
children: [/* @__PURE__ */ c("input", {
|
|
242
|
+
className: "sl-input",
|
|
243
|
+
type: j,
|
|
244
|
+
value: M,
|
|
245
|
+
placeholder: n,
|
|
246
|
+
disabled: r,
|
|
247
|
+
readOnly: O,
|
|
248
|
+
maxLength: k,
|
|
249
|
+
min: m,
|
|
250
|
+
max: h,
|
|
251
|
+
step: g,
|
|
252
|
+
autoComplete: A,
|
|
253
|
+
onChange: E,
|
|
254
|
+
onFocus: b,
|
|
255
|
+
onBlur: x
|
|
256
|
+
}), p && t === "password" && /* @__PURE__ */ c("button", {
|
|
257
|
+
type: "button",
|
|
258
|
+
className: "sl-input-password-toggle",
|
|
259
|
+
onClick: D,
|
|
260
|
+
children: /* @__PURE__ */ c(d, {
|
|
261
|
+
name: w ? "eye-off" : "lock",
|
|
262
|
+
size: 16
|
|
263
|
+
})
|
|
264
|
+
})]
|
|
265
|
+
})
|
|
266
|
+
});
|
|
267
|
+
}, T = ({ value: e = "", items: t = [], onSelect: n, onChange: r, className: i = "", ...a }) => {
|
|
268
|
+
let o = (e) => {
|
|
269
|
+
r?.(e), n?.(e);
|
|
270
|
+
};
|
|
271
|
+
return /* @__PURE__ */ c("nav", {
|
|
272
|
+
className: `sl-menu ${i}`.trim(),
|
|
273
|
+
role: "menu",
|
|
274
|
+
...a,
|
|
275
|
+
children: t.map((t) => /* @__PURE__ */ l("div", {
|
|
276
|
+
className: "sl-menu-group",
|
|
277
|
+
children: [/* @__PURE__ */ c("div", {
|
|
278
|
+
className: "sl-menu-group-title",
|
|
279
|
+
children: t.label
|
|
280
|
+
}), /* @__PURE__ */ c("ul", {
|
|
281
|
+
className: "sl-menu-items",
|
|
282
|
+
children: t.children.map((t) => /* @__PURE__ */ c("li", {
|
|
283
|
+
className: `sl-menu-item ${e === t.key ? "is-active" : ""}`.trim(),
|
|
284
|
+
role: "menuitem",
|
|
285
|
+
onClick: () => o(t.key),
|
|
286
|
+
children: /* @__PURE__ */ c("span", {
|
|
287
|
+
className: "sl-menu-item-label",
|
|
288
|
+
children: t.label
|
|
289
|
+
})
|
|
290
|
+
}, t.key))
|
|
291
|
+
})]
|
|
292
|
+
}, t.key))
|
|
293
|
+
});
|
|
294
|
+
}, E = ({ value: e = "", tabs: t = [], onTabChange: n, onChange: r, className: i = "", ...a }) => {
|
|
295
|
+
let o = (e) => {
|
|
296
|
+
e.disabled || (r?.(e.name), n?.(e.name));
|
|
297
|
+
};
|
|
298
|
+
return /* @__PURE__ */ c("div", {
|
|
299
|
+
className: `sl-tabs ${i}`.trim(),
|
|
300
|
+
...a,
|
|
301
|
+
children: /* @__PURE__ */ c("div", {
|
|
302
|
+
className: "sl-tabs-nav",
|
|
303
|
+
role: "tablist",
|
|
304
|
+
children: t.map((t) => /* @__PURE__ */ c("div", {
|
|
305
|
+
className: `sl-tabs-item ${e === t.name ? "is-active" : ""} ${t.disabled ? "is-disabled" : ""}`.trim(),
|
|
306
|
+
role: "tab",
|
|
307
|
+
"aria-selected": e === t.name,
|
|
308
|
+
onClick: () => o(t),
|
|
309
|
+
children: t.label
|
|
310
|
+
}, t.name))
|
|
311
|
+
})
|
|
312
|
+
});
|
|
313
|
+
}, D = ({ title: e, items: t = [], data: n, column: r = 1, border: i = !1, slots: a, className: o = "", ...s }) => {
|
|
314
|
+
let u = (e) => {
|
|
315
|
+
if (e.render) return e.render(e, n);
|
|
316
|
+
if (e.slot && a && a[e.slot]) return a[e.slot](e, n);
|
|
317
|
+
if (e.value !== void 0 && e.value !== null) return e.value;
|
|
318
|
+
if (n) {
|
|
319
|
+
if (e.label && n[e.label] !== void 0) {
|
|
320
|
+
let t = n[e.label];
|
|
321
|
+
return typeof t == "boolean" ? String(t) : t;
|
|
322
|
+
}
|
|
323
|
+
if (e.slot && n[e.slot] !== void 0) {
|
|
324
|
+
let t = n[e.slot];
|
|
325
|
+
return typeof t == "boolean" ? String(t) : t;
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
return "--";
|
|
329
|
+
};
|
|
330
|
+
return /* @__PURE__ */ l("div", {
|
|
331
|
+
className: `sl-descriptions ${i ? "is-border" : ""} ${o}`.trim(),
|
|
332
|
+
...s,
|
|
333
|
+
children: [e && /* @__PURE__ */ c("div", {
|
|
334
|
+
className: "sl-descriptions-title",
|
|
335
|
+
children: e
|
|
336
|
+
}), /* @__PURE__ */ c("div", {
|
|
337
|
+
className: "sl-descriptions-grid",
|
|
338
|
+
style: { gridTemplateColumns: `repeat(${r}, 1fr)` },
|
|
339
|
+
children: t.map((e, t) => /* @__PURE__ */ l("div", {
|
|
340
|
+
className: "sl-descriptions-item",
|
|
341
|
+
style: { gridColumn: `span ${e.span || 1}` },
|
|
342
|
+
children: [/* @__PURE__ */ c("div", {
|
|
343
|
+
className: "sl-descriptions-label",
|
|
344
|
+
children: e.label
|
|
345
|
+
}), /* @__PURE__ */ c("div", {
|
|
346
|
+
className: "sl-descriptions-content",
|
|
347
|
+
children: u(e)
|
|
348
|
+
})]
|
|
349
|
+
}, t))
|
|
350
|
+
})]
|
|
351
|
+
});
|
|
352
|
+
}, O = ({ text: e, position: n = "top", delay: i = 200, children: s, disabled: d = !1, className: f = "", ...p }) => {
|
|
353
|
+
let [m, h] = o(!1), [g, _] = o(!1), [v, y] = o({}), b = a(null), x = a(null), S = a(null), C = a(null), w = t((e) => {
|
|
354
|
+
if (!b.current || !e) return;
|
|
355
|
+
let t = b.current.getBoundingClientRect(), r = e.getBoundingClientRect(), i = window.innerWidth, a = 0, o = 0, s = t.top + t.height / 2, c = t.left + t.width / 2;
|
|
356
|
+
switch (n) {
|
|
357
|
+
case "top":
|
|
358
|
+
case "bottom":
|
|
359
|
+
a = n === "top" ? t.top - r.height - 8 : t.bottom + 8, o = c - r.width / 2, o < 5 && (o = 5);
|
|
360
|
+
let e = o + r.width, l = i - 5;
|
|
361
|
+
e > l && (o = Math.max(5, o - (e - l)));
|
|
362
|
+
break;
|
|
363
|
+
case "left":
|
|
364
|
+
case "right":
|
|
365
|
+
a = s - r.height / 2, o = n === "left" ? t.left - r.width - 8 : t.right + 8;
|
|
366
|
+
break;
|
|
367
|
+
}
|
|
368
|
+
y({
|
|
369
|
+
top: `${a + window.scrollY}px`,
|
|
370
|
+
left: `${o + window.scrollX}px`
|
|
371
|
+
});
|
|
372
|
+
}, [n]), T = t((e) => {
|
|
373
|
+
x.current = e, e && w(e);
|
|
374
|
+
}, [w]);
|
|
375
|
+
return r(() => {
|
|
376
|
+
if (!g) return;
|
|
377
|
+
let e = () => {
|
|
378
|
+
x.current && w(x.current);
|
|
379
|
+
};
|
|
380
|
+
return window.addEventListener("resize", e), window.addEventListener("scroll", e, { passive: !0 }), () => {
|
|
381
|
+
window.removeEventListener("resize", e), window.removeEventListener("scroll", e);
|
|
382
|
+
};
|
|
383
|
+
}, [g, w]), r(() => () => {
|
|
384
|
+
S.current && window.clearTimeout(S.current), C.current && window.clearTimeout(C.current);
|
|
385
|
+
}, []), /* @__PURE__ */ l("div", {
|
|
386
|
+
className: `sl-tooltip-wrapper ${f}`.trim(),
|
|
387
|
+
ref: b,
|
|
388
|
+
onMouseEnter: () => {
|
|
389
|
+
d || (S.current && window.clearTimeout(S.current), C.current && window.clearTimeout(C.current), m ? _(!0) : S.current = window.setTimeout(() => {
|
|
390
|
+
h(!0), S.current = window.setTimeout(() => {
|
|
391
|
+
_(!0);
|
|
392
|
+
}, 20);
|
|
393
|
+
}, i));
|
|
394
|
+
},
|
|
395
|
+
onMouseLeave: () => {
|
|
396
|
+
S.current && window.clearTimeout(S.current), C.current && window.clearTimeout(C.current), _(!1), C.current = window.setTimeout(() => {
|
|
397
|
+
h(!1);
|
|
398
|
+
}, 200);
|
|
399
|
+
},
|
|
400
|
+
...p,
|
|
401
|
+
children: [s, m && e && !d && typeof document < "u" && u(/* @__PURE__ */ l("div", {
|
|
402
|
+
ref: T,
|
|
403
|
+
className: `sl-tooltip-content ${g ? "is-visible" : ""}`.trim(),
|
|
404
|
+
style: v,
|
|
405
|
+
"data-position": n,
|
|
406
|
+
children: [e, /* @__PURE__ */ c("span", {
|
|
407
|
+
className: "sl-tooltip-arrow",
|
|
408
|
+
"data-position": n
|
|
409
|
+
})]
|
|
410
|
+
}), document.body)]
|
|
411
|
+
});
|
|
412
|
+
}, k = ({ toasts: e = [], onClose: t, className: n = "", ...r }) => {
|
|
413
|
+
let i = (e) => e === "success" ? "success" : e === "error" ? "error" : e === "warning" ? "warning" : "info", a = (e, n) => {
|
|
414
|
+
e.stopPropagation(), t?.(n);
|
|
415
|
+
};
|
|
416
|
+
return typeof document > "u" ? null : u(/* @__PURE__ */ c("div", {
|
|
417
|
+
className: `sl-toast-container ${n}`.trim(),
|
|
418
|
+
...r,
|
|
419
|
+
children: e.map((e) => /* @__PURE__ */ l("div", {
|
|
420
|
+
className: `sl-toast-item is-${e.type}`,
|
|
421
|
+
role: "alert",
|
|
422
|
+
onClick: () => t?.(e.id),
|
|
423
|
+
children: [
|
|
424
|
+
/* @__PURE__ */ c("div", {
|
|
425
|
+
className: "sl-toast-icon",
|
|
426
|
+
children: /* @__PURE__ */ c(d, {
|
|
427
|
+
name: i(e.type),
|
|
428
|
+
size: 20
|
|
429
|
+
})
|
|
430
|
+
}),
|
|
431
|
+
/* @__PURE__ */ l("div", {
|
|
432
|
+
className: "sl-toast-content",
|
|
433
|
+
children: [/* @__PURE__ */ c("h4", {
|
|
434
|
+
className: "sl-toast-title",
|
|
435
|
+
children: e.title
|
|
436
|
+
}), /* @__PURE__ */ c("p", {
|
|
437
|
+
className: "sl-toast-message",
|
|
438
|
+
children: e.message
|
|
439
|
+
})]
|
|
440
|
+
}),
|
|
441
|
+
/* @__PURE__ */ c("button", {
|
|
442
|
+
className: "sl-toast-close",
|
|
443
|
+
onClick: (t) => a(t, e.id),
|
|
444
|
+
children: "×"
|
|
445
|
+
})
|
|
446
|
+
]
|
|
447
|
+
}, e.id))
|
|
448
|
+
}), document.body);
|
|
449
|
+
}, A = ({ visible: e, title: t, width: n = "500px", closeOnClickOverlay: r = !0, zIndex: i = "var(--sdl-z-index-modal)", onClose: a, footer: o, className: s = "", style: d, children: f, ...p }) => {
|
|
450
|
+
if (!e) return null;
|
|
451
|
+
let m = (e) => {
|
|
452
|
+
r && e.target === e.currentTarget && a?.();
|
|
453
|
+
}, h = {
|
|
454
|
+
zIndex: i,
|
|
455
|
+
...d
|
|
456
|
+
};
|
|
457
|
+
return u(/* @__PURE__ */ c("div", {
|
|
458
|
+
className: `sl-dialog-overlay ${s}`.trim(),
|
|
459
|
+
style: h,
|
|
460
|
+
onClick: m,
|
|
461
|
+
role: "presentation",
|
|
462
|
+
...p,
|
|
463
|
+
children: /* @__PURE__ */ l("div", {
|
|
464
|
+
className: "sl-dialog-card",
|
|
465
|
+
style: {
|
|
466
|
+
width: n,
|
|
467
|
+
maxWidth: "95%"
|
|
468
|
+
},
|
|
469
|
+
role: "dialog",
|
|
470
|
+
"aria-modal": "true",
|
|
471
|
+
children: [
|
|
472
|
+
/* @__PURE__ */ l("div", {
|
|
473
|
+
className: "sl-dialog-header",
|
|
474
|
+
"data-slot": "header",
|
|
475
|
+
children: [/* @__PURE__ */ c("span", {
|
|
476
|
+
className: "sl-dialog-title",
|
|
477
|
+
children: t
|
|
478
|
+
}), /* @__PURE__ */ c("button", {
|
|
479
|
+
type: "button",
|
|
480
|
+
className: "sl-dialog-close-btn",
|
|
481
|
+
onClick: a,
|
|
482
|
+
"aria-label": "Close dialog",
|
|
483
|
+
children: "×"
|
|
484
|
+
})]
|
|
485
|
+
}),
|
|
486
|
+
/* @__PURE__ */ c("div", {
|
|
487
|
+
className: "sl-dialog-body",
|
|
488
|
+
children: f
|
|
489
|
+
}),
|
|
490
|
+
o && /* @__PURE__ */ c("div", {
|
|
491
|
+
className: "sl-dialog-footer",
|
|
492
|
+
"data-slot": "footer",
|
|
493
|
+
children: o
|
|
494
|
+
})
|
|
495
|
+
]
|
|
496
|
+
})
|
|
497
|
+
}), document.body);
|
|
498
|
+
}, j = ({ visible: e, title: t = "", width: n = "420px", closeOnOverlay: r = !0, onClose: i, footer: a, className: o = "", style: s, children: d, ...f }) => {
|
|
499
|
+
if (!e) return null;
|
|
500
|
+
let p = (e) => {
|
|
501
|
+
r && e.target === e.currentTarget && i?.();
|
|
502
|
+
}, m = {
|
|
503
|
+
width: n,
|
|
504
|
+
...s
|
|
505
|
+
};
|
|
506
|
+
return u(/* @__PURE__ */ c("div", {
|
|
507
|
+
className: `sl-drawer-overlay ${o}`.trim(),
|
|
508
|
+
onClick: p,
|
|
509
|
+
role: "presentation",
|
|
510
|
+
...f,
|
|
511
|
+
children: /* @__PURE__ */ l("div", {
|
|
512
|
+
className: "sl-drawer-panel",
|
|
513
|
+
style: m,
|
|
514
|
+
role: "dialog",
|
|
515
|
+
"aria-modal": "true",
|
|
516
|
+
"aria-label": t || void 0,
|
|
517
|
+
children: [
|
|
518
|
+
/* @__PURE__ */ l("div", {
|
|
519
|
+
className: "sl-drawer-header",
|
|
520
|
+
"data-slot": "header",
|
|
521
|
+
children: [/* @__PURE__ */ c("h3", {
|
|
522
|
+
className: "sl-drawer-title",
|
|
523
|
+
children: t
|
|
524
|
+
}), /* @__PURE__ */ c("button", {
|
|
525
|
+
type: "button",
|
|
526
|
+
className: "sl-drawer-close-btn",
|
|
527
|
+
onClick: i,
|
|
528
|
+
"aria-label": "Close drawer",
|
|
529
|
+
children: "×"
|
|
530
|
+
})]
|
|
531
|
+
}),
|
|
532
|
+
/* @__PURE__ */ c("div", {
|
|
533
|
+
className: "sl-drawer-body",
|
|
534
|
+
children: d
|
|
535
|
+
}),
|
|
536
|
+
a && /* @__PURE__ */ c("div", {
|
|
537
|
+
className: "sl-drawer-footer",
|
|
538
|
+
"data-slot": "footer",
|
|
539
|
+
children: a
|
|
540
|
+
})
|
|
541
|
+
]
|
|
542
|
+
})
|
|
543
|
+
}), document.body);
|
|
544
|
+
}, M = ({ visible: e, title: t, message: n, confirmText: r = "确定", cancelText: i = "取消", type: a = "primary", onConfirm: o, onCancel: s, className: d = "", ...f }) => e ? u(/* @__PURE__ */ c("div", {
|
|
545
|
+
className: `sl-modal-overlay ${d}`.trim(),
|
|
546
|
+
onClick: (e) => {
|
|
547
|
+
e.target === e.currentTarget && s?.();
|
|
548
|
+
},
|
|
549
|
+
role: "presentation",
|
|
550
|
+
...f,
|
|
551
|
+
children: /* @__PURE__ */ l("div", {
|
|
552
|
+
className: "sl-modal-card",
|
|
553
|
+
role: "alertdialog",
|
|
554
|
+
"aria-modal": "true",
|
|
555
|
+
children: [
|
|
556
|
+
/* @__PURE__ */ c("div", {
|
|
557
|
+
className: "sl-modal-header",
|
|
558
|
+
"data-slot": "header",
|
|
559
|
+
children: /* @__PURE__ */ c("h3", {
|
|
560
|
+
className: "sl-modal-title",
|
|
561
|
+
children: t
|
|
562
|
+
})
|
|
563
|
+
}),
|
|
564
|
+
/* @__PURE__ */ c("div", {
|
|
565
|
+
className: "sl-modal-body",
|
|
566
|
+
children: /* @__PURE__ */ c("p", {
|
|
567
|
+
className: "sl-modal-message",
|
|
568
|
+
children: n
|
|
569
|
+
})
|
|
570
|
+
}),
|
|
571
|
+
/* @__PURE__ */ l("div", {
|
|
572
|
+
className: "sl-modal-footer",
|
|
573
|
+
"data-slot": "footer",
|
|
574
|
+
children: [/* @__PURE__ */ c("button", {
|
|
575
|
+
type: "button",
|
|
576
|
+
className: "sl-modal-btn is-cancel",
|
|
577
|
+
onClick: s,
|
|
578
|
+
children: i
|
|
579
|
+
}), /* @__PURE__ */ c("button", {
|
|
580
|
+
type: "button",
|
|
581
|
+
className: `sl-modal-btn is-${a}`,
|
|
582
|
+
onClick: o,
|
|
583
|
+
children: r
|
|
584
|
+
})]
|
|
585
|
+
})
|
|
586
|
+
]
|
|
587
|
+
})
|
|
588
|
+
}), document.body) : null, N = ({ currentPage: e, totalPages: t, maxVisibleButtons: n = 5, onPageChange: r, className: a = "", ...o }) => {
|
|
589
|
+
let s = i(() => {
|
|
590
|
+
let r = t, i = e, a = n, o = [];
|
|
591
|
+
if (r <= a) for (let e = 1; e <= r; e++) o.push(e);
|
|
592
|
+
else {
|
|
593
|
+
let e = Math.floor(a / 2), t = Math.max(1, i - e), n = Math.min(r, i + e);
|
|
594
|
+
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("..."));
|
|
595
|
+
for (let e = t; e <= n; e++) o.push(e);
|
|
596
|
+
n < r && (n < r - 1 && o.push("..."), o.push(r));
|
|
597
|
+
}
|
|
598
|
+
return o;
|
|
599
|
+
}, [
|
|
600
|
+
e,
|
|
601
|
+
t,
|
|
602
|
+
n
|
|
603
|
+
]);
|
|
604
|
+
if (t <= 1) return null;
|
|
605
|
+
let u = (t) => {
|
|
606
|
+
typeof t == "number" && t !== e && r?.(t);
|
|
607
|
+
};
|
|
608
|
+
return /* @__PURE__ */ l("div", {
|
|
609
|
+
className: `sl-pagination ${a}`.trim(),
|
|
610
|
+
...o,
|
|
611
|
+
children: [
|
|
612
|
+
/* @__PURE__ */ c("button", {
|
|
613
|
+
type: "button",
|
|
614
|
+
className: "sl-pagination-btn",
|
|
615
|
+
onClick: () => u(e - 1),
|
|
616
|
+
disabled: e === 1,
|
|
617
|
+
children: "<"
|
|
618
|
+
}),
|
|
619
|
+
s.map((t, n) => {
|
|
620
|
+
let r = t === e, i = typeof t == "string";
|
|
621
|
+
return /* @__PURE__ */ c("button", {
|
|
622
|
+
type: "button",
|
|
623
|
+
className: `sl-pagination-btn ${r ? "active" : ""} ${i ? "ellipsis" : ""}`.trim(),
|
|
624
|
+
onClick: () => u(t),
|
|
625
|
+
disabled: i,
|
|
626
|
+
children: t
|
|
627
|
+
}, n);
|
|
628
|
+
}),
|
|
629
|
+
/* @__PURE__ */ c("button", {
|
|
630
|
+
type: "button",
|
|
631
|
+
className: "sl-pagination-btn",
|
|
632
|
+
onClick: () => u(e + 1),
|
|
633
|
+
disabled: e === t,
|
|
634
|
+
children: ">"
|
|
635
|
+
})
|
|
636
|
+
]
|
|
637
|
+
});
|
|
638
|
+
}, P = ({ value: e, options: n, placeholder: s = "请选择", disabled: d = !1, onChange: f, onOptionDisabled: p, className: m = "", ...h }) => {
|
|
639
|
+
let [g, _] = o(!1), [v, y] = o({}), b = a(null), x = i(() => {
|
|
640
|
+
let t = n.find((t) => t.value === e);
|
|
641
|
+
return t ? t.label : s;
|
|
642
|
+
}, [
|
|
643
|
+
e,
|
|
644
|
+
n,
|
|
645
|
+
s
|
|
646
|
+
]), S = t(() => {
|
|
647
|
+
if (!b.current || !g) return;
|
|
648
|
+
let e = b.current.getBoundingClientRect();
|
|
649
|
+
y({
|
|
650
|
+
minWidth: `${e.width}px`,
|
|
651
|
+
top: `${e.bottom + window.scrollY + 4}px`,
|
|
652
|
+
left: `${e.left + window.scrollX}px`,
|
|
653
|
+
position: "absolute"
|
|
654
|
+
});
|
|
655
|
+
}, [g]);
|
|
656
|
+
r(() => {
|
|
657
|
+
g && S();
|
|
658
|
+
}, [g, S]), r(() => {
|
|
659
|
+
let e = (e) => {
|
|
660
|
+
b.current && !b.current.contains(e.target) && _(!1);
|
|
661
|
+
};
|
|
662
|
+
return document.addEventListener("click", e), window.addEventListener("resize", S), window.addEventListener("scroll", S, !0), () => {
|
|
663
|
+
document.removeEventListener("click", e), window.removeEventListener("resize", S), window.removeEventListener("scroll", S, !0);
|
|
664
|
+
};
|
|
665
|
+
}, [S]);
|
|
666
|
+
let C = () => {
|
|
667
|
+
d || _((e) => !e);
|
|
668
|
+
}, w = (e) => {
|
|
669
|
+
if (!d) {
|
|
670
|
+
if (e.disabled) {
|
|
671
|
+
p?.(e);
|
|
672
|
+
return;
|
|
673
|
+
}
|
|
674
|
+
f?.(e.value), _(!1);
|
|
675
|
+
}
|
|
676
|
+
};
|
|
677
|
+
return /* @__PURE__ */ l("div", {
|
|
678
|
+
className: `sl-select ${g ? "is-open" : ""} ${d ? "is-disabled" : ""} ${m}`.trim(),
|
|
679
|
+
ref: b,
|
|
680
|
+
...h,
|
|
681
|
+
children: [/* @__PURE__ */ l("div", {
|
|
682
|
+
className: "sl-select-trigger",
|
|
683
|
+
onClick: C,
|
|
684
|
+
children: [/* @__PURE__ */ c("span", {
|
|
685
|
+
className: "sl-select-label",
|
|
686
|
+
children: x
|
|
687
|
+
}), /* @__PURE__ */ c("span", { className: "sl-select-arrow" })]
|
|
688
|
+
}), g && u(/* @__PURE__ */ c("ul", {
|
|
689
|
+
className: "sl-select-options",
|
|
690
|
+
style: v,
|
|
691
|
+
children: n.map((t) => /* @__PURE__ */ c("li", {
|
|
692
|
+
className: `sl-select-option ${e === t.value ? "selected" : ""} ${t.disabled ? "disabled" : ""}`.trim(),
|
|
693
|
+
title: t.hint,
|
|
694
|
+
onClick: () => w(t),
|
|
695
|
+
children: t.label
|
|
696
|
+
}, t.value))
|
|
697
|
+
}), document.body)]
|
|
698
|
+
});
|
|
699
|
+
}, F = ({ actions: e, label: n = "操作", disabled: i = !1, defaultIcon: s = "settings", className: f = "", ...p }) => {
|
|
700
|
+
let [m, h] = o(!1), [g, _] = o({}), v = a(null), y = a(null), b = t(() => {
|
|
701
|
+
if (!v.current || !m) return;
|
|
702
|
+
let e = v.current.getBoundingClientRect();
|
|
703
|
+
_({
|
|
704
|
+
top: `${e.bottom + window.scrollY + 4}px`,
|
|
705
|
+
left: `${e.right + window.scrollX}px`,
|
|
706
|
+
transform: "translateX(-100%)",
|
|
707
|
+
position: "absolute"
|
|
708
|
+
});
|
|
709
|
+
}, [m]);
|
|
710
|
+
r(() => {
|
|
711
|
+
m && b();
|
|
712
|
+
}, [m, b]), r(() => {
|
|
713
|
+
let e = (e) => {
|
|
714
|
+
let t = e.target;
|
|
715
|
+
v.current && !v.current.contains(t) && (!y.current || !y.current.contains(t)) && h(!1);
|
|
716
|
+
};
|
|
717
|
+
return document.addEventListener("click", e), window.addEventListener("resize", b), window.addEventListener("scroll", b, !0), () => {
|
|
718
|
+
document.removeEventListener("click", e), window.removeEventListener("resize", b), window.removeEventListener("scroll", b, !0);
|
|
719
|
+
};
|
|
720
|
+
}, [b]);
|
|
721
|
+
let x = (e) => {
|
|
722
|
+
e.stopPropagation(), !i && h((e) => !e);
|
|
723
|
+
}, S = (e, t) => {
|
|
724
|
+
t.stopPropagation(), !e.disabled && (e.handler(), h(!1));
|
|
725
|
+
};
|
|
726
|
+
return /* @__PURE__ */ l("div", {
|
|
727
|
+
className: `sl-action-menu ${f}`.trim(),
|
|
728
|
+
ref: v,
|
|
729
|
+
...p,
|
|
730
|
+
children: [/* @__PURE__ */ l("button", {
|
|
731
|
+
type: "button",
|
|
732
|
+
className: "sl-action-btn",
|
|
733
|
+
disabled: i,
|
|
734
|
+
onClick: x,
|
|
735
|
+
children: [/* @__PURE__ */ c(d, {
|
|
736
|
+
className: "sl-action-btn-icon",
|
|
737
|
+
name: "settings",
|
|
738
|
+
size: 16
|
|
739
|
+
}), /* @__PURE__ */ c("span", {
|
|
740
|
+
className: "sl-action-btn-text",
|
|
741
|
+
children: n
|
|
742
|
+
})]
|
|
743
|
+
}), m && u(/* @__PURE__ */ c("div", {
|
|
744
|
+
ref: y,
|
|
745
|
+
className: "sl-dropdown",
|
|
746
|
+
style: g,
|
|
747
|
+
onClick: (e) => e.stopPropagation(),
|
|
748
|
+
children: e.map((e, t) => {
|
|
749
|
+
let n = (e.className || e.class || "").trim(), r = e.disabled, i = /* @__PURE__ */ l("button", {
|
|
750
|
+
type: "button",
|
|
751
|
+
className: `sl-dropdown-item ${n} ${r ? "is-disabled" : ""}`.trim(),
|
|
752
|
+
disabled: r,
|
|
753
|
+
onClick: (t) => S(e, t),
|
|
754
|
+
children: [/* @__PURE__ */ c(d, {
|
|
755
|
+
className: "sl-dropdown-icon",
|
|
756
|
+
name: e.icon || s,
|
|
757
|
+
size: 16
|
|
758
|
+
}), /* @__PURE__ */ c("span", {
|
|
759
|
+
className: "sl-dropdown-label",
|
|
760
|
+
children: e.label
|
|
761
|
+
})]
|
|
762
|
+
});
|
|
763
|
+
return /* @__PURE__ */ c(O, {
|
|
764
|
+
text: e.tooltip || "",
|
|
765
|
+
disabled: !e.tooltip,
|
|
766
|
+
position: "right",
|
|
767
|
+
className: "sl-dropdown-tooltip-wrapper",
|
|
768
|
+
children: i
|
|
769
|
+
}, t);
|
|
770
|
+
})
|
|
771
|
+
}), document.body)]
|
|
772
|
+
});
|
|
773
|
+
}, I = (e) => {
|
|
774
|
+
if (e !== void 0) return typeof e == "number" ? `${e}px` : e;
|
|
775
|
+
}, L = (e) => ({
|
|
776
|
+
width: I(e.width),
|
|
777
|
+
minWidth: I(e.minWidth),
|
|
778
|
+
textAlign: e.headerAlign || e.align || "center"
|
|
779
|
+
}), R = (e) => ({
|
|
780
|
+
width: I(e.width),
|
|
781
|
+
minWidth: I(e.minWidth),
|
|
782
|
+
textAlign: e.align || "left"
|
|
783
|
+
});
|
|
784
|
+
function z({ data: e, columns: t, border: n = !1, emptyText: r = "暂无数据", slots: i, headerSlots: a, emptySlot: o, onRowMouseEnter: s, onRowContextMenu: u, className: d = "", ...f }) {
|
|
785
|
+
return /* @__PURE__ */ c("div", {
|
|
786
|
+
className: `sl-table-container ${n ? "sl-table-border" : ""} ${d}`.trim(),
|
|
787
|
+
"data-native-context-menu": "true",
|
|
788
|
+
...f,
|
|
789
|
+
children: /* @__PURE__ */ c("div", {
|
|
790
|
+
className: "sl-table-wrapper",
|
|
791
|
+
children: /* @__PURE__ */ l("table", {
|
|
792
|
+
className: "sl-table",
|
|
793
|
+
children: [/* @__PURE__ */ c("thead", { children: /* @__PURE__ */ c("tr", {
|
|
794
|
+
className: "sl-table-header-row",
|
|
795
|
+
children: t.map((e, t) => /* @__PURE__ */ c("th", {
|
|
796
|
+
className: `sl-table-header-cell ${e.fixed ? `is-fixed-${e.fixed}` : ""}`.trim(),
|
|
797
|
+
style: L(e),
|
|
798
|
+
children: /* @__PURE__ */ c("div", {
|
|
799
|
+
className: "sl-cell",
|
|
800
|
+
children: e.renderHeader ? e.renderHeader(e, t) : e.headerSlot && a && a[e.headerSlot] ? a[e.headerSlot]({
|
|
801
|
+
column: e,
|
|
802
|
+
index: t
|
|
803
|
+
}) : e.label
|
|
804
|
+
})
|
|
805
|
+
}, t))
|
|
806
|
+
}) }), /* @__PURE__ */ c("tbody", { children: e.length > 0 ? e.map((e, n) => /* @__PURE__ */ c("tr", {
|
|
807
|
+
className: "sl-table-row",
|
|
808
|
+
onMouseEnter: (t) => s?.(e, t, n),
|
|
809
|
+
onContextMenu: (t) => u?.(e, t, n),
|
|
810
|
+
children: t.map((t, r) => /* @__PURE__ */ c("td", {
|
|
811
|
+
className: `sl-table-cell ${t.fixed ? `is-fixed-${t.fixed}` : ""}`.trim(),
|
|
812
|
+
style: R(t),
|
|
813
|
+
children: /* @__PURE__ */ c("div", {
|
|
814
|
+
className: "sl-cell",
|
|
815
|
+
children: t.renderCell ? t.renderCell(e, t, n) : t.slot && i && i[t.slot] ? i[t.slot]({
|
|
816
|
+
row: e,
|
|
817
|
+
column: t,
|
|
818
|
+
index: n
|
|
819
|
+
}) : t.prop ? String(e[t.prop] ?? "") : ""
|
|
820
|
+
})
|
|
821
|
+
}, r))
|
|
822
|
+
}, n)) : /* @__PURE__ */ c("tr", { children: /* @__PURE__ */ c("td", {
|
|
823
|
+
colSpan: t.length,
|
|
824
|
+
className: "sl-table-empty-cell",
|
|
825
|
+
children: o || /* @__PURE__ */ c("div", {
|
|
826
|
+
className: "sl-table-empty",
|
|
827
|
+
children: r
|
|
828
|
+
})
|
|
829
|
+
}) }) })]
|
|
830
|
+
})
|
|
831
|
+
})
|
|
832
|
+
});
|
|
833
|
+
}
|
|
834
|
+
//#endregion
|
|
835
|
+
//#region src/components/SecLabDateTimeRangePicker/SecLabDateTimeRangePicker.tsx
|
|
836
|
+
function ee(e) {
|
|
837
|
+
return e ? new Date(e) : /* @__PURE__ */ new Date();
|
|
838
|
+
}
|
|
839
|
+
function B(e) {
|
|
840
|
+
return new Date(e.getFullYear(), e.getMonth(), 1, 0, 0, 0, 0);
|
|
841
|
+
}
|
|
842
|
+
function V(e) {
|
|
843
|
+
return new Date(e.getFullYear(), e.getMonth(), e.getDate(), 0, 0, 0, 0);
|
|
844
|
+
}
|
|
845
|
+
function te(e) {
|
|
846
|
+
return new Date(e.getFullYear(), e.getMonth(), e.getDate(), 23, 59, 59, 999);
|
|
847
|
+
}
|
|
848
|
+
function H(e, t) {
|
|
849
|
+
let n = new Date(e);
|
|
850
|
+
return n.setDate(n.getDate() + t), n;
|
|
851
|
+
}
|
|
852
|
+
function U(e) {
|
|
853
|
+
let t = String(e.getMonth() + 1).padStart(2, "0"), n = String(e.getDate()).padStart(2, "0");
|
|
854
|
+
return `${e.getFullYear()}-${t}-${n}`;
|
|
855
|
+
}
|
|
856
|
+
function W(e) {
|
|
857
|
+
if (!e) return "--";
|
|
858
|
+
let t = new Date(e);
|
|
859
|
+
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")}`;
|
|
860
|
+
}
|
|
861
|
+
function G(e) {
|
|
862
|
+
let t = e.startAt ?? null, n = e.endAt ?? null;
|
|
863
|
+
return t !== null && n !== null && t > n ? {
|
|
864
|
+
startAt: n,
|
|
865
|
+
endAt: t
|
|
866
|
+
} : {
|
|
867
|
+
startAt: t,
|
|
868
|
+
endAt: n
|
|
869
|
+
};
|
|
870
|
+
}
|
|
871
|
+
var ne = [
|
|
872
|
+
{
|
|
873
|
+
label: "最近 15 分钟",
|
|
874
|
+
value: "15m"
|
|
875
|
+
},
|
|
876
|
+
{
|
|
877
|
+
label: "最近 1 小时",
|
|
878
|
+
value: "1h"
|
|
879
|
+
},
|
|
880
|
+
{
|
|
881
|
+
label: "最近 24 小时",
|
|
882
|
+
value: "24h"
|
|
883
|
+
},
|
|
884
|
+
{
|
|
885
|
+
label: "最近 7 天",
|
|
886
|
+
value: "7d"
|
|
887
|
+
},
|
|
888
|
+
{
|
|
889
|
+
label: "今天",
|
|
890
|
+
value: "today"
|
|
891
|
+
}
|
|
892
|
+
], K = ({ value: e = {
|
|
893
|
+
startAt: null,
|
|
894
|
+
endAt: null
|
|
895
|
+
}, placeholder: n = "请选择时间范围", startLabel: s = "开始时间", endLabel: d = "结束时间", shortcutsLabel: f = "常用范围", calendarLabel: p = "选择日期", timeLabel: m = "选择时间", clearLabel: h = "清空", confirmLabel: g = "确定", cancelLabel: _ = "取消", locale: v = "zh", weekDays: y = [
|
|
896
|
+
"日",
|
|
897
|
+
"一",
|
|
898
|
+
"二",
|
|
899
|
+
"三",
|
|
900
|
+
"四",
|
|
901
|
+
"五",
|
|
902
|
+
"六"
|
|
903
|
+
], shortcuts: b = ne, disabled: x = !1, onChange: S, onApply: C, className: w = "", ...T }) => {
|
|
904
|
+
let E = a(null), D = a(null), [O, k] = o(!1), [A, j] = o("start"), [M, N] = o(() => G(e)), [P, F] = o(() => B(/* @__PURE__ */ new Date())), [I, L] = o({}), R = i(() => Array.from({ length: 24 }, (e, t) => t), []), z = i(() => Array.from({ length: 12 }, (e, t) => t * 5), []), K = i(() => !e.startAt && !e.endAt ? n : `${W(e.startAt)} - ${W(e.endAt)}`, [e, n]), q = i(() => ee(M[A === "start" ? "startAt" : "endAt"]), [M, A]), J = q.getHours(), Y = Math.floor(q.getMinutes() / 5) * 5, re = i(() => P.toLocaleDateString(v === "zh" ? "zh-CN" : "en-US", {
|
|
905
|
+
year: "numeric",
|
|
906
|
+
month: "long"
|
|
907
|
+
}), [P, v]), ie = i(() => {
|
|
908
|
+
let e = B(P), t = H(e, -e.getDay());
|
|
909
|
+
return Array.from({ length: 42 }, (e, n) => {
|
|
910
|
+
let r = H(t, n), i = r.getTime(), a = M.startAt ? V(new Date(M.startAt)).getTime() : null, o = M.endAt ? V(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;
|
|
911
|
+
return {
|
|
912
|
+
date: r,
|
|
913
|
+
key: U(r),
|
|
914
|
+
label: String(r.getDate()),
|
|
915
|
+
muted: r.getMonth() !== P.getMonth(),
|
|
916
|
+
today: U(r) === U(/* @__PURE__ */ new Date()),
|
|
917
|
+
selectedStart: a === i,
|
|
918
|
+
selectedEnd: o === i,
|
|
919
|
+
inRange: s !== null && c !== null && i > s && i < c
|
|
920
|
+
};
|
|
921
|
+
});
|
|
922
|
+
}, [P, M]), X = t(() => {
|
|
923
|
+
let e = E.current;
|
|
924
|
+
if (!e) return;
|
|
925
|
+
let t = e.getBoundingClientRect(), n = Math.min(Math.max(8, t.left), window.innerWidth - 620 - 8), r = Math.min(t.bottom + 8, window.innerHeight - 468);
|
|
926
|
+
L({
|
|
927
|
+
width: "620px",
|
|
928
|
+
left: `${n}px`,
|
|
929
|
+
top: `${Math.max(8, r)}px`,
|
|
930
|
+
position: "fixed"
|
|
931
|
+
});
|
|
932
|
+
}, []), Z = t(() => {
|
|
933
|
+
k(!1);
|
|
934
|
+
}, []), Q = t((e) => {
|
|
935
|
+
let t = e.target;
|
|
936
|
+
E.current?.contains(t) || D.current?.contains(t) || Z();
|
|
937
|
+
}, [Z]), $ = t((e) => {
|
|
938
|
+
e.key === "Escape" && Z();
|
|
939
|
+
}, [Z]);
|
|
940
|
+
r(() => {
|
|
941
|
+
O || N(G(e));
|
|
942
|
+
}, [e, O]), r(() => (O && (X(), window.addEventListener("resize", X), window.addEventListener("scroll", X, !0), document.addEventListener("mousedown", Q), document.addEventListener("keydown", $)), () => {
|
|
943
|
+
window.removeEventListener("resize", X), window.removeEventListener("scroll", X, !0), document.removeEventListener("mousedown", Q), document.removeEventListener("keydown", $);
|
|
944
|
+
}), [
|
|
945
|
+
O,
|
|
946
|
+
X,
|
|
947
|
+
Q,
|
|
948
|
+
$
|
|
949
|
+
]);
|
|
950
|
+
let ae = () => {
|
|
951
|
+
if (x) return;
|
|
952
|
+
let t = G(e);
|
|
953
|
+
N(t);
|
|
954
|
+
let n = t.startAt ?? t.endAt ?? Date.now();
|
|
955
|
+
F(B(new Date(n))), k(!0);
|
|
956
|
+
}, oe = (e) => {
|
|
957
|
+
F((t) => new Date(t.getFullYear(), t.getMonth() + e, 1));
|
|
958
|
+
}, se = (e) => {
|
|
959
|
+
let t = q, n = new Date(e.getFullYear(), e.getMonth(), e.getDate(), t.getHours(), t.getMinutes(), 0, 0), r = A === "start" ? "startAt" : "endAt";
|
|
960
|
+
N((e) => G({
|
|
961
|
+
...e,
|
|
962
|
+
[r]: n.getTime()
|
|
963
|
+
}));
|
|
964
|
+
}, ce = (e, t) => {
|
|
965
|
+
let n = q, r = new Date(n.getFullYear(), n.getMonth(), n.getDate(), e, t, 0, 0), i = A === "start" ? "startAt" : "endAt";
|
|
966
|
+
N((e) => G({
|
|
967
|
+
...e,
|
|
968
|
+
[i]: r.getTime()
|
|
969
|
+
}));
|
|
970
|
+
}, le = (e) => {
|
|
971
|
+
let t = /* @__PURE__ */ new Date(), n;
|
|
972
|
+
n = e === "today" ? {
|
|
973
|
+
startAt: V(t).getTime(),
|
|
974
|
+
endAt: te(t).getTime()
|
|
975
|
+
} : {
|
|
976
|
+
startAt: t.getTime() - {
|
|
977
|
+
"15m": 900 * 1e3,
|
|
978
|
+
"1h": 3600 * 1e3,
|
|
979
|
+
"24h": 1440 * 60 * 1e3,
|
|
980
|
+
"7d": 10080 * 60 * 1e3
|
|
981
|
+
}[e],
|
|
982
|
+
endAt: t.getTime()
|
|
983
|
+
}, N(n), F(B(new Date(n.startAt ?? Date.now())));
|
|
984
|
+
}, ue = () => {
|
|
985
|
+
let e = {
|
|
986
|
+
startAt: null,
|
|
987
|
+
endAt: null
|
|
988
|
+
};
|
|
989
|
+
N(e), S?.(e), C?.(e), Z();
|
|
990
|
+
}, de = () => {
|
|
991
|
+
let e = G(M);
|
|
992
|
+
S?.(e), C?.(e), Z();
|
|
993
|
+
};
|
|
994
|
+
return /* @__PURE__ */ l("div", {
|
|
995
|
+
className: `sl-date-time-range-picker ${w}`.trim(),
|
|
996
|
+
"data-ui": "date-time-range-picker",
|
|
997
|
+
...T,
|
|
998
|
+
children: [/* @__PURE__ */ c("button", {
|
|
999
|
+
ref: E,
|
|
1000
|
+
type: "button",
|
|
1001
|
+
className: `range-trigger ${!e.startAt && !e.endAt ? "is-placeholder" : ""}`.trim(),
|
|
1002
|
+
disabled: x,
|
|
1003
|
+
onClick: () => O ? Z() : ae(),
|
|
1004
|
+
children: /* @__PURE__ */ c("span", {
|
|
1005
|
+
className: "trigger-text",
|
|
1006
|
+
children: K
|
|
1007
|
+
})
|
|
1008
|
+
}), O && u(/* @__PURE__ */ l("div", {
|
|
1009
|
+
ref: D,
|
|
1010
|
+
className: "range-panel",
|
|
1011
|
+
style: I,
|
|
1012
|
+
children: [
|
|
1013
|
+
/* @__PURE__ */ l("aside", {
|
|
1014
|
+
className: "shortcut-column",
|
|
1015
|
+
children: [/* @__PURE__ */ c("div", {
|
|
1016
|
+
className: "panel-title",
|
|
1017
|
+
children: f
|
|
1018
|
+
}), b.map((e) => /* @__PURE__ */ c("button", {
|
|
1019
|
+
type: "button",
|
|
1020
|
+
className: "shortcut-button",
|
|
1021
|
+
onClick: () => le(e.value),
|
|
1022
|
+
children: e.label
|
|
1023
|
+
}, e.value))]
|
|
1024
|
+
}),
|
|
1025
|
+
/* @__PURE__ */ l("section", {
|
|
1026
|
+
className: "calendar-column",
|
|
1027
|
+
children: [
|
|
1028
|
+
/* @__PURE__ */ c("div", {
|
|
1029
|
+
className: "panel-title",
|
|
1030
|
+
children: p
|
|
1031
|
+
}),
|
|
1032
|
+
/* @__PURE__ */ l("div", {
|
|
1033
|
+
className: "boundary-switch",
|
|
1034
|
+
children: [/* @__PURE__ */ l("button", {
|
|
1035
|
+
type: "button",
|
|
1036
|
+
className: `boundary-button ${A === "start" ? "is-active" : ""}`.trim(),
|
|
1037
|
+
onClick: () => j("start"),
|
|
1038
|
+
children: [/* @__PURE__ */ c("span", { children: s }), /* @__PURE__ */ c("strong", { children: W(M.startAt) })]
|
|
1039
|
+
}), /* @__PURE__ */ l("button", {
|
|
1040
|
+
type: "button",
|
|
1041
|
+
className: `boundary-button ${A === "end" ? "is-active" : ""}`.trim(),
|
|
1042
|
+
onClick: () => j("end"),
|
|
1043
|
+
children: [/* @__PURE__ */ c("span", { children: d }), /* @__PURE__ */ c("strong", { children: W(M.endAt) })]
|
|
1044
|
+
})]
|
|
1045
|
+
}),
|
|
1046
|
+
/* @__PURE__ */ l("div", {
|
|
1047
|
+
className: "calendar-header",
|
|
1048
|
+
children: [
|
|
1049
|
+
/* @__PURE__ */ c("button", {
|
|
1050
|
+
type: "button",
|
|
1051
|
+
className: "month-button",
|
|
1052
|
+
onClick: () => oe(-1),
|
|
1053
|
+
children: "‹"
|
|
1054
|
+
}),
|
|
1055
|
+
/* @__PURE__ */ c("span", { children: re }),
|
|
1056
|
+
/* @__PURE__ */ c("button", {
|
|
1057
|
+
type: "button",
|
|
1058
|
+
className: "month-button",
|
|
1059
|
+
onClick: () => oe(1),
|
|
1060
|
+
children: "›"
|
|
1061
|
+
})
|
|
1062
|
+
]
|
|
1063
|
+
}),
|
|
1064
|
+
/* @__PURE__ */ c("div", {
|
|
1065
|
+
className: "week-grid",
|
|
1066
|
+
children: y.map((e) => /* @__PURE__ */ c("span", { children: e }, e))
|
|
1067
|
+
}),
|
|
1068
|
+
/* @__PURE__ */ c("div", {
|
|
1069
|
+
className: "day-grid",
|
|
1070
|
+
children: ie.map((e) => /* @__PURE__ */ c("button", {
|
|
1071
|
+
type: "button",
|
|
1072
|
+
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(),
|
|
1073
|
+
onClick: () => se(e.date),
|
|
1074
|
+
children: e.label
|
|
1075
|
+
}, e.key))
|
|
1076
|
+
})
|
|
1077
|
+
]
|
|
1078
|
+
}),
|
|
1079
|
+
/* @__PURE__ */ l("section", {
|
|
1080
|
+
className: "time-column",
|
|
1081
|
+
children: [/* @__PURE__ */ c("div", {
|
|
1082
|
+
className: "panel-title",
|
|
1083
|
+
children: m
|
|
1084
|
+
}), /* @__PURE__ */ l("div", {
|
|
1085
|
+
className: "time-lists",
|
|
1086
|
+
children: [/* @__PURE__ */ c("div", {
|
|
1087
|
+
className: "time-list",
|
|
1088
|
+
children: R.map((e) => /* @__PURE__ */ c("button", {
|
|
1089
|
+
type: "button",
|
|
1090
|
+
className: `time-option ${J === e ? "is-active" : ""}`.trim(),
|
|
1091
|
+
onClick: () => ce(e, Y),
|
|
1092
|
+
children: String(e).padStart(2, "0")
|
|
1093
|
+
}, e))
|
|
1094
|
+
}), /* @__PURE__ */ c("div", {
|
|
1095
|
+
className: "time-list",
|
|
1096
|
+
children: z.map((e) => /* @__PURE__ */ c("button", {
|
|
1097
|
+
type: "button",
|
|
1098
|
+
className: `time-option ${Y === e ? "is-active" : ""}`.trim(),
|
|
1099
|
+
onClick: () => ce(J, e),
|
|
1100
|
+
children: String(e).padStart(2, "0")
|
|
1101
|
+
}, e))
|
|
1102
|
+
})]
|
|
1103
|
+
})]
|
|
1104
|
+
}),
|
|
1105
|
+
/* @__PURE__ */ l("footer", {
|
|
1106
|
+
className: "panel-actions",
|
|
1107
|
+
children: [
|
|
1108
|
+
/* @__PURE__ */ c("button", {
|
|
1109
|
+
type: "button",
|
|
1110
|
+
className: "text-button",
|
|
1111
|
+
onClick: ue,
|
|
1112
|
+
children: h
|
|
1113
|
+
}),
|
|
1114
|
+
/* @__PURE__ */ c("span", { className: "action-spacer" }),
|
|
1115
|
+
/* @__PURE__ */ c("button", {
|
|
1116
|
+
type: "button",
|
|
1117
|
+
className: "text-button",
|
|
1118
|
+
onClick: Z,
|
|
1119
|
+
children: _
|
|
1120
|
+
}),
|
|
1121
|
+
/* @__PURE__ */ c("button", {
|
|
1122
|
+
type: "button",
|
|
1123
|
+
className: "confirm-button",
|
|
1124
|
+
onClick: de,
|
|
1125
|
+
children: g
|
|
1126
|
+
})
|
|
1127
|
+
]
|
|
1128
|
+
})
|
|
1129
|
+
]
|
|
1130
|
+
}), document.body)]
|
|
1131
|
+
});
|
|
1132
|
+
};
|
|
1133
|
+
//#endregion
|
|
1134
|
+
export { F as SecLabActionMenu, m as SecLabAlert, S as SecLabBreadcrumb, C as SecLabBreadcrumbItem, f as SecLabButton, h as SecLabCard, g as SecLabCheckbox, K as SecLabDateTimeRangePicker, D as SecLabDescriptions, A as SecLabDialog, j as SecLabDrawer, _ as SecLabEmpty, v as SecLabFormItem, d as SecLabIcon, w as SecLabInput, y as SecLabLoading, T as SecLabMenu, M as SecLabModal, N as SecLabPagination, P as SecLabSelect, p as SecLabSwitch, z as SecLabTable, E as SecLabTabs, b as SecLabTag, k as SecLabToast, O as SecLabTooltip };
|