aicde-ui 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +27 -0
- package/README.md +87 -2
- package/dist/index.cjs +3163 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +973 -0
- package/dist/index.d.ts +973 -0
- package/dist/index.js +3051 -0
- package/dist/index.js.map +1 -0
- package/dist/style.css +1710 -0
- package/package.json +75 -4
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,3163 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all)
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from))
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
|
|
31
|
+
// src/index.ts
|
|
32
|
+
var index_exports = {};
|
|
33
|
+
__export(index_exports, {
|
|
34
|
+
Alert: () => Alert,
|
|
35
|
+
Autocomplete: () => Autocomplete,
|
|
36
|
+
Avatar: () => Avatar,
|
|
37
|
+
AvatarGroup: () => AvatarGroup,
|
|
38
|
+
BackTop: () => BackTop,
|
|
39
|
+
Badge: () => Badge,
|
|
40
|
+
Banner: () => Banner,
|
|
41
|
+
Breadcrumb: () => Breadcrumb,
|
|
42
|
+
Button: () => Button,
|
|
43
|
+
Calendar: () => Calendar,
|
|
44
|
+
Card: () => Card2,
|
|
45
|
+
Carousel: () => Carousel,
|
|
46
|
+
Cascader: () => Cascader,
|
|
47
|
+
Checkbox: () => Checkbox,
|
|
48
|
+
CheckboxGroup: () => CheckboxGroup,
|
|
49
|
+
Collapse: () => Collapse,
|
|
50
|
+
ColorPicker: () => ColorPicker,
|
|
51
|
+
ColorSwatches: () => ColorSwatches,
|
|
52
|
+
CommandPalette: () => CommandPalette,
|
|
53
|
+
ContextMenu: () => ContextMenu,
|
|
54
|
+
DataTable: () => DataTable,
|
|
55
|
+
DatePicker: () => DatePicker,
|
|
56
|
+
DateRangeInputs: () => DateRangeInputs,
|
|
57
|
+
Descriptions: () => Descriptions,
|
|
58
|
+
Divider: () => Divider,
|
|
59
|
+
Drawer: () => Drawer,
|
|
60
|
+
Dropdown: () => Dropdown,
|
|
61
|
+
Empty: () => Empty,
|
|
62
|
+
Field: () => Field,
|
|
63
|
+
FloatButton: () => FloatButton,
|
|
64
|
+
ImagePreview: () => ImagePreview,
|
|
65
|
+
Input: () => Input,
|
|
66
|
+
InputNumber: () => InputNumber,
|
|
67
|
+
Kbd: () => Kbd,
|
|
68
|
+
KbdCombo: () => KbdCombo,
|
|
69
|
+
List: () => List,
|
|
70
|
+
Menu: () => Menu,
|
|
71
|
+
Modal: () => Modal,
|
|
72
|
+
OtpInput: () => OtpInput,
|
|
73
|
+
Pagination: () => Pagination,
|
|
74
|
+
Popover: () => Popover,
|
|
75
|
+
Progress: () => Progress,
|
|
76
|
+
Radio: () => Radio,
|
|
77
|
+
RadioGroup: () => RadioGroup,
|
|
78
|
+
RangePicker: () => RangePicker,
|
|
79
|
+
Rating: () => Rating,
|
|
80
|
+
Result: () => Result,
|
|
81
|
+
Segmented: () => Segmented,
|
|
82
|
+
Select: () => Select,
|
|
83
|
+
Skeleton: () => Skeleton,
|
|
84
|
+
SkeletonGroup: () => SkeletonGroup,
|
|
85
|
+
Slider: () => Slider,
|
|
86
|
+
Spinner: () => Spinner,
|
|
87
|
+
StatRow: () => StatRow,
|
|
88
|
+
Statistic: () => Statistic,
|
|
89
|
+
Steps: () => Steps,
|
|
90
|
+
Switch: () => Switch,
|
|
91
|
+
Table: () => Table,
|
|
92
|
+
Tabs: () => Tabs,
|
|
93
|
+
Tag: () => Tag,
|
|
94
|
+
TagInput: () => TagInput,
|
|
95
|
+
Textarea: () => Textarea,
|
|
96
|
+
ThemeProvider: () => ThemeProvider,
|
|
97
|
+
Timeline: () => Timeline,
|
|
98
|
+
Toaster: () => Toaster,
|
|
99
|
+
Tooltip: () => Tooltip,
|
|
100
|
+
Transfer: () => Transfer,
|
|
101
|
+
Tree: () => Tree,
|
|
102
|
+
Upload: () => Upload,
|
|
103
|
+
cx: () => cx,
|
|
104
|
+
normOption: () => normOption,
|
|
105
|
+
notify: () => notify,
|
|
106
|
+
pageWindow: () => pageWindow,
|
|
107
|
+
toast: () => toast,
|
|
108
|
+
useControllable: () => useControllable,
|
|
109
|
+
useId: () => useId2,
|
|
110
|
+
useReducedMotion: () => useReducedMotion
|
|
111
|
+
});
|
|
112
|
+
module.exports = __toCommonJS(index_exports);
|
|
113
|
+
|
|
114
|
+
// src/components/Button.tsx
|
|
115
|
+
var React2 = __toESM(require("react"), 1);
|
|
116
|
+
|
|
117
|
+
// src/utils.ts
|
|
118
|
+
var React = __toESM(require("react"), 1);
|
|
119
|
+
function cx(...a) {
|
|
120
|
+
return a.filter(Boolean).join(" ");
|
|
121
|
+
}
|
|
122
|
+
function useControllable(value, defaultValue, onChange) {
|
|
123
|
+
const [inner, setInner] = React.useState(defaultValue);
|
|
124
|
+
const controlled = value !== void 0;
|
|
125
|
+
const current = controlled ? value : inner;
|
|
126
|
+
const onChangeRef = React.useRef(onChange);
|
|
127
|
+
onChangeRef.current = onChange;
|
|
128
|
+
const set = React.useCallback((v) => {
|
|
129
|
+
var _a;
|
|
130
|
+
if (!controlled) setInner(v);
|
|
131
|
+
(_a = onChangeRef.current) == null ? void 0 : _a.call(onChangeRef, v);
|
|
132
|
+
}, [controlled]);
|
|
133
|
+
return [current, set];
|
|
134
|
+
}
|
|
135
|
+
function useReducedMotion() {
|
|
136
|
+
const [reduce, setReduce] = React.useState(false);
|
|
137
|
+
React.useEffect(() => {
|
|
138
|
+
var _a;
|
|
139
|
+
if (typeof window === "undefined" || !window.matchMedia) return;
|
|
140
|
+
const mq = window.matchMedia("(prefers-reduced-motion: reduce)");
|
|
141
|
+
setReduce(mq.matches);
|
|
142
|
+
const on = (e) => setReduce(e.matches);
|
|
143
|
+
(_a = mq.addEventListener) == null ? void 0 : _a.call(mq, "change", on);
|
|
144
|
+
return () => {
|
|
145
|
+
var _a2;
|
|
146
|
+
return (_a2 = mq.removeEventListener) == null ? void 0 : _a2.call(mq, "change", on);
|
|
147
|
+
};
|
|
148
|
+
}, []);
|
|
149
|
+
return reduce;
|
|
150
|
+
}
|
|
151
|
+
function useId2(prefix = "a") {
|
|
152
|
+
const raw = React.useId();
|
|
153
|
+
return prefix + "-" + raw.replace(/[^a-zA-Z0-9_-]/g, "");
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// src/components/Button.tsx
|
|
157
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
158
|
+
var Button = React2.forwardRef(function Button2({ variant = "outline", size = "md", loading, icon, iconOnly, block, className, children, disabled, type = "button", onClick, ...rest }, ref) {
|
|
159
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
160
|
+
"button",
|
|
161
|
+
{
|
|
162
|
+
ref,
|
|
163
|
+
type,
|
|
164
|
+
className: cx(
|
|
165
|
+
"a-btn",
|
|
166
|
+
"a-btn--" + variant,
|
|
167
|
+
size !== "md" && "a-btn--" + size,
|
|
168
|
+
iconOnly && "a-btn--icon",
|
|
169
|
+
block && "a-btn--block",
|
|
170
|
+
loading && "is-loading",
|
|
171
|
+
className
|
|
172
|
+
),
|
|
173
|
+
disabled,
|
|
174
|
+
"aria-disabled": loading && !disabled ? true : void 0,
|
|
175
|
+
"aria-busy": loading || void 0,
|
|
176
|
+
onClick: (e) => {
|
|
177
|
+
if (loading) {
|
|
178
|
+
e.preventDefault();
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
onClick == null ? void 0 : onClick(e);
|
|
182
|
+
},
|
|
183
|
+
...rest,
|
|
184
|
+
children: [
|
|
185
|
+
!loading && icon,
|
|
186
|
+
children
|
|
187
|
+
]
|
|
188
|
+
}
|
|
189
|
+
);
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
// src/components/Divider.tsx
|
|
193
|
+
var React3 = __toESM(require("react"), 1);
|
|
194
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
195
|
+
var Divider = React3.forwardRef(function Divider2({ vertical, align = "center", className, children, ...rest }, ref) {
|
|
196
|
+
if (vertical) return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { ref, role: "separator", "aria-orientation": "vertical", className: cx("a-divider", "a-divider--vertical", className), ...rest });
|
|
197
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { ref, role: "separator", className: cx("a-divider", align === "left" && "a-divider--left", className), ...rest, children });
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
// src/components/FloatButton.tsx
|
|
201
|
+
var React4 = __toESM(require("react"), 1);
|
|
202
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
203
|
+
var FloatButton = React4.forwardRef(function FloatButton2({ color = "coral", size = "md", extended, static: isStatic, icon, className, children, type = "button", ...rest }, ref) {
|
|
204
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
205
|
+
"button",
|
|
206
|
+
{
|
|
207
|
+
ref,
|
|
208
|
+
type,
|
|
209
|
+
className: cx("a-fab", color === "navy" && "a-fab--navy", size === "sm" && "a-fab--sm", extended && "a-fab--extended", isStatic && "a-fab--static", className),
|
|
210
|
+
...rest,
|
|
211
|
+
children: [
|
|
212
|
+
icon,
|
|
213
|
+
extended && children
|
|
214
|
+
]
|
|
215
|
+
}
|
|
216
|
+
);
|
|
217
|
+
});
|
|
218
|
+
var UP = /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "M12 19V5M5 12l7-7 7 7" }) });
|
|
219
|
+
function BackTop({ threshold = 300, className, onClick, color = "navy", icon = UP, ...rest }) {
|
|
220
|
+
const [visible, setVisible] = React4.useState(false);
|
|
221
|
+
const reduce = useReducedMotion();
|
|
222
|
+
React4.useEffect(() => {
|
|
223
|
+
const on = () => setVisible(window.scrollY > threshold);
|
|
224
|
+
on();
|
|
225
|
+
window.addEventListener("scroll", on, { passive: true });
|
|
226
|
+
return () => window.removeEventListener("scroll", on);
|
|
227
|
+
}, [threshold]);
|
|
228
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
229
|
+
FloatButton,
|
|
230
|
+
{
|
|
231
|
+
"aria-label": "\u56DE\u5230\u9802\u90E8",
|
|
232
|
+
color,
|
|
233
|
+
icon,
|
|
234
|
+
className: cx("a-backtop", visible && "is-visible", className),
|
|
235
|
+
tabIndex: visible ? void 0 : -1,
|
|
236
|
+
onClick: (e) => {
|
|
237
|
+
onClick == null ? void 0 : onClick(e);
|
|
238
|
+
window.scrollTo({ top: 0, behavior: reduce ? "auto" : "smooth" });
|
|
239
|
+
},
|
|
240
|
+
...rest
|
|
241
|
+
}
|
|
242
|
+
);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
// src/components/ThemeProvider.tsx
|
|
246
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
247
|
+
function ThemeProvider({ theme = "default", mode = "system", children, ...rest }) {
|
|
248
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
249
|
+
"div",
|
|
250
|
+
{
|
|
251
|
+
"data-theme-style": theme === "default" ? void 0 : theme,
|
|
252
|
+
"data-theme": mode === "system" ? void 0 : mode,
|
|
253
|
+
...rest,
|
|
254
|
+
children
|
|
255
|
+
}
|
|
256
|
+
);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
// src/components/Tabs.tsx
|
|
260
|
+
var React5 = __toESM(require("react"), 1);
|
|
261
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
262
|
+
function Tabs({ items, activeKey, defaultActiveKey, onChange, variant = "line", className, ...rest }) {
|
|
263
|
+
var _a, _b;
|
|
264
|
+
const [active, setActive] = useControllable(activeKey, (_b = defaultActiveKey != null ? defaultActiveKey : (_a = items[0]) == null ? void 0 : _a.key) != null ? _b : "", onChange);
|
|
265
|
+
const id = useId2("tabs");
|
|
266
|
+
const listRef = React5.useRef(null);
|
|
267
|
+
const inkRef = React5.useRef(null);
|
|
268
|
+
const first = React5.useRef(true);
|
|
269
|
+
const moveInk = React5.useCallback(() => {
|
|
270
|
+
const list = listRef.current, ink = inkRef.current;
|
|
271
|
+
if (!list || !ink) return;
|
|
272
|
+
const cur = list.querySelector("[role=tab][aria-selected=true]");
|
|
273
|
+
if (!cur) return;
|
|
274
|
+
if (first.current) ink.style.transition = "none";
|
|
275
|
+
ink.style.width = cur.offsetWidth + "px";
|
|
276
|
+
ink.style.transform = "translateX(" + cur.offsetLeft + "px)";
|
|
277
|
+
if (first.current) {
|
|
278
|
+
void ink.offsetWidth;
|
|
279
|
+
ink.style.transition = "";
|
|
280
|
+
first.current = false;
|
|
281
|
+
}
|
|
282
|
+
}, []);
|
|
283
|
+
React5.useLayoutEffect(moveInk, [active, items, moveInk]);
|
|
284
|
+
React5.useEffect(() => {
|
|
285
|
+
var _a2;
|
|
286
|
+
window.addEventListener("resize", moveInk);
|
|
287
|
+
(_a2 = document.fonts) == null ? void 0 : _a2.ready.then(moveInk);
|
|
288
|
+
return () => window.removeEventListener("resize", moveInk);
|
|
289
|
+
}, [moveInk]);
|
|
290
|
+
const onKeyDown = (e) => {
|
|
291
|
+
var _a2, _b2;
|
|
292
|
+
if (e.key !== "ArrowRight" && e.key !== "ArrowLeft") return;
|
|
293
|
+
const enabled = items.filter((i) => !i.disabled);
|
|
294
|
+
const k = enabled.findIndex((i) => i.key === active);
|
|
295
|
+
const next = enabled[(k + (e.key === "ArrowRight" ? 1 : -1) + enabled.length) % enabled.length];
|
|
296
|
+
if (!next) return;
|
|
297
|
+
e.preventDefault();
|
|
298
|
+
setActive(next.key);
|
|
299
|
+
(_b2 = (_a2 = listRef.current) == null ? void 0 : _a2.querySelector("#" + id + "-tab-" + CSS.escape(next.key))) == null ? void 0 : _b2.focus();
|
|
300
|
+
};
|
|
301
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: cx("a-tabs", variant === "pill" && "a-tabs--pill", className), ...rest, children: [
|
|
302
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "a-tabs__list", role: "tablist", ref: listRef, onKeyDown, children: [
|
|
303
|
+
items.map((it) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
304
|
+
"button",
|
|
305
|
+
{
|
|
306
|
+
type: "button",
|
|
307
|
+
role: "tab",
|
|
308
|
+
id: id + "-tab-" + it.key,
|
|
309
|
+
"aria-selected": it.key === active,
|
|
310
|
+
"aria-controls": id + "-panel-" + it.key,
|
|
311
|
+
tabIndex: it.key === active ? 0 : -1,
|
|
312
|
+
disabled: it.disabled,
|
|
313
|
+
onClick: () => setActive(it.key),
|
|
314
|
+
children: it.label
|
|
315
|
+
},
|
|
316
|
+
it.key
|
|
317
|
+
)),
|
|
318
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "a-tabs__ink", "aria-hidden": "true", ref: inkRef })
|
|
319
|
+
] }),
|
|
320
|
+
items.map((it) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
321
|
+
"div",
|
|
322
|
+
{
|
|
323
|
+
className: "a-tabs__panel",
|
|
324
|
+
role: "tabpanel",
|
|
325
|
+
id: id + "-panel-" + it.key,
|
|
326
|
+
"aria-labelledby": id + "-tab-" + it.key,
|
|
327
|
+
hidden: it.key !== active,
|
|
328
|
+
children: it.key === active ? it.children : null
|
|
329
|
+
},
|
|
330
|
+
it.key
|
|
331
|
+
))
|
|
332
|
+
] });
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
// src/components/Pagination.tsx
|
|
336
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
337
|
+
function pageWindow(cur, total) {
|
|
338
|
+
if (total <= 7) return Array.from({ length: total }, (_, i) => i + 1);
|
|
339
|
+
if (cur <= 4) return [1, 2, 3, 4, 5, "\u2026", total];
|
|
340
|
+
if (cur >= total - 3) return [1, "\u2026", total - 4, total - 3, total - 2, total - 1, total];
|
|
341
|
+
return [1, "\u2026", cur - 1, cur, cur + 1, "\u2026", total];
|
|
342
|
+
}
|
|
343
|
+
var L = /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("path", { d: "M15 6l-6 6 6 6" }) });
|
|
344
|
+
var R = /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("path", { d: "M9 6l6 6-6 6" }) });
|
|
345
|
+
function Pagination({ total, current, defaultCurrent = 1, onChange, className, "aria-label": label = "\u5206\u9801", ...rest }) {
|
|
346
|
+
const t = Math.max(1, total);
|
|
347
|
+
const [raw, setPage] = useControllable(current, defaultCurrent, onChange);
|
|
348
|
+
const cur = Math.min(t, Math.max(1, raw));
|
|
349
|
+
const go = (p) => {
|
|
350
|
+
if (p >= 1 && p <= t && p !== cur) setPage(p);
|
|
351
|
+
};
|
|
352
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("nav", { className: cx("a-pagination", className), "aria-label": label, ...rest, children: [
|
|
353
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { type: "button", "aria-label": "\u4E0A\u4E00\u9801", disabled: cur === 1, onClick: () => go(cur - 1), children: L }),
|
|
354
|
+
pageWindow(cur, t).map(
|
|
355
|
+
(p, i) => p === "\u2026" ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "a-pagination__gap", children: "\u2026" }, "gap" + i) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { type: "button", "aria-current": p === cur ? "page" : void 0, onClick: () => go(p), children: p }, p)
|
|
356
|
+
),
|
|
357
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { type: "button", "aria-label": "\u4E0B\u4E00\u9801", disabled: cur === t, onClick: () => go(cur + 1), children: R })
|
|
358
|
+
] });
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
// src/components/Dropdown.tsx
|
|
362
|
+
var React6 = __toESM(require("react"), 1);
|
|
363
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
364
|
+
function Dropdown({ trigger, items, align = "left", open, defaultOpen = false, onOpenChange, onSelect, className, ...rest }) {
|
|
365
|
+
const [isOpen, setOpen] = useControllable(open, defaultOpen, onOpenChange);
|
|
366
|
+
const rootRef = React6.useRef(null);
|
|
367
|
+
const id = useId2("dd");
|
|
368
|
+
React6.useEffect(() => {
|
|
369
|
+
if (!isOpen) return;
|
|
370
|
+
const onDoc = (e) => {
|
|
371
|
+
var _a;
|
|
372
|
+
if (!((_a = rootRef.current) == null ? void 0 : _a.contains(e.target))) setOpen(false);
|
|
373
|
+
};
|
|
374
|
+
const onKey = (e) => {
|
|
375
|
+
if (e.key === "Escape") setOpen(false);
|
|
376
|
+
};
|
|
377
|
+
document.addEventListener("click", onDoc);
|
|
378
|
+
document.addEventListener("keydown", onKey);
|
|
379
|
+
return () => {
|
|
380
|
+
document.removeEventListener("click", onDoc);
|
|
381
|
+
document.removeEventListener("keydown", onKey);
|
|
382
|
+
};
|
|
383
|
+
}, [isOpen, setOpen]);
|
|
384
|
+
const trig = trigger;
|
|
385
|
+
const triggerEl = React6.cloneElement(trig, {
|
|
386
|
+
"aria-haspopup": "menu",
|
|
387
|
+
"aria-expanded": isOpen,
|
|
388
|
+
"aria-controls": id,
|
|
389
|
+
onClick: (e) => {
|
|
390
|
+
var _a, _b;
|
|
391
|
+
(_b = (_a = trig.props).onClick) == null ? void 0 : _b.call(_a, e);
|
|
392
|
+
setOpen(!isOpen);
|
|
393
|
+
}
|
|
394
|
+
});
|
|
395
|
+
const onMenuKey = (e) => {
|
|
396
|
+
var _a;
|
|
397
|
+
if (e.key !== "ArrowDown" && e.key !== "ArrowUp") return;
|
|
398
|
+
e.preventDefault();
|
|
399
|
+
const its = Array.from(e.currentTarget.querySelectorAll("[role=menuitem]:not(:disabled)"));
|
|
400
|
+
const k = its.indexOf(document.activeElement);
|
|
401
|
+
(_a = its[(k + (e.key === "ArrowDown" ? 1 : -1) + its.length) % its.length]) == null ? void 0 : _a.focus();
|
|
402
|
+
};
|
|
403
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { ref: rootRef, className: cx("a-dropdown", align === "right" && "a-dropdown--right", isOpen && "is-open", className), ...rest, children: [
|
|
404
|
+
triggerEl,
|
|
405
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "a-dropdown__menu", role: "menu", id, onKeyDown: onMenuKey, children: items.map((it) => it.divider ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "a-dropdown__sep", role: "separator" }, it.key) : /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
406
|
+
"button",
|
|
407
|
+
{
|
|
408
|
+
type: "button",
|
|
409
|
+
role: "menuitem",
|
|
410
|
+
className: cx(it.danger && "is-danger"),
|
|
411
|
+
disabled: it.disabled,
|
|
412
|
+
tabIndex: isOpen ? 0 : -1,
|
|
413
|
+
onClick: () => {
|
|
414
|
+
var _a;
|
|
415
|
+
(_a = it.onClick) == null ? void 0 : _a.call(it);
|
|
416
|
+
onSelect == null ? void 0 : onSelect(it.key);
|
|
417
|
+
setOpen(false);
|
|
418
|
+
},
|
|
419
|
+
children: [
|
|
420
|
+
it.icon,
|
|
421
|
+
it.label
|
|
422
|
+
]
|
|
423
|
+
},
|
|
424
|
+
it.key
|
|
425
|
+
)) })
|
|
426
|
+
] });
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
// src/components/Breadcrumb.tsx
|
|
430
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
431
|
+
function Breadcrumb({ items, className, "aria-label": label = "\u9EB5\u5305\u5C51", ...rest }) {
|
|
432
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("nav", { className: cx("a-breadcrumb", className), "aria-label": label, ...rest, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("ol", { children: items.map((it, i) => {
|
|
433
|
+
var _a;
|
|
434
|
+
const last = i === items.length - 1;
|
|
435
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("li", { "aria-current": last ? "page" : void 0, children: last || !it.href && !it.onClick ? it.label : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("a", { href: (_a = it.href) != null ? _a : "#", onClick: it.onClick, children: it.label }) }, i);
|
|
436
|
+
}) }) });
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
// src/components/Steps.tsx
|
|
440
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
441
|
+
function Steps({ items, current = 0, className, ...rest }) {
|
|
442
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("ol", { className: cx("a-steps", className), ...rest, children: items.map((it, i) => /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("li", { className: cx(i < current && "is-done", i === current && "is-current"), "aria-current": i === current ? "step" : void 0, children: [
|
|
443
|
+
it.title,
|
|
444
|
+
it.description != null && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "a-steps__desc", children: it.description })
|
|
445
|
+
] }, i)) });
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
// src/components/Menu.tsx
|
|
449
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
450
|
+
var RESET = { border: 0, background: "none", width: "100%", font: "inherit", textAlign: "left" };
|
|
451
|
+
function Menu({ items, activeKey, defaultActiveKey = "", onSelect, className, "aria-label": label = "\u9078\u55AE", ...rest }) {
|
|
452
|
+
const [active, setActive] = useControllable(activeKey, defaultActiveKey, onSelect);
|
|
453
|
+
const contains = (it) => {
|
|
454
|
+
var _a;
|
|
455
|
+
return it.key === active || !!((_a = it.children) == null ? void 0 : _a.some(contains));
|
|
456
|
+
};
|
|
457
|
+
const renderItem = (it) => {
|
|
458
|
+
var _a, _b;
|
|
459
|
+
if (it.type === "group") return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "a-menu__label", children: it.label }, it.key);
|
|
460
|
+
if ((_a = it.children) == null ? void 0 : _a.length) {
|
|
461
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("details", { open: (_b = it.defaultOpen) != null ? _b : contains(it), children: [
|
|
462
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("summary", { children: [
|
|
463
|
+
it.icon,
|
|
464
|
+
it.label
|
|
465
|
+
] }),
|
|
466
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { children: it.children.map(renderItem) })
|
|
467
|
+
] }, it.key);
|
|
468
|
+
}
|
|
469
|
+
const content = /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_jsx_runtime10.Fragment, { children: [
|
|
470
|
+
it.icon,
|
|
471
|
+
it.label,
|
|
472
|
+
it.badge != null && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "a-menu__badge", children: it.badge })
|
|
473
|
+
] });
|
|
474
|
+
const common = {
|
|
475
|
+
className: "a-menu__item",
|
|
476
|
+
"aria-current": it.key === active ? "page" : void 0,
|
|
477
|
+
onClick: () => setActive(it.key)
|
|
478
|
+
};
|
|
479
|
+
return it.href ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("a", { href: it.href, ...common, children: content }, it.key) : /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("button", { type: "button", style: RESET, ...common, children: content }, it.key);
|
|
480
|
+
};
|
|
481
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("nav", { className: cx("a-menu", className), "aria-label": label, ...rest, children: items.map(renderItem) });
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
// src/components/CommandPalette.tsx
|
|
485
|
+
var React8 = __toESM(require("react"), 1);
|
|
486
|
+
|
|
487
|
+
// src/useDialog.ts
|
|
488
|
+
var React7 = __toESM(require("react"), 1);
|
|
489
|
+
var FOCUSABLE = [
|
|
490
|
+
"a[href]",
|
|
491
|
+
"area[href]",
|
|
492
|
+
"button:not([disabled])",
|
|
493
|
+
'input:not([disabled]):not([type="hidden"])',
|
|
494
|
+
"select:not([disabled])",
|
|
495
|
+
"textarea:not([disabled])",
|
|
496
|
+
"iframe",
|
|
497
|
+
"audio[controls]",
|
|
498
|
+
"video[controls]",
|
|
499
|
+
'[contenteditable]:not([contenteditable="false"])',
|
|
500
|
+
'[tabindex]:not([tabindex="-1"])'
|
|
501
|
+
].join(",");
|
|
502
|
+
function focusables(root) {
|
|
503
|
+
return Array.from(root.querySelectorAll(FOCUSABLE)).filter((el) => !el.closest("[hidden],[inert]") && el.getAttribute("aria-hidden") !== "true");
|
|
504
|
+
}
|
|
505
|
+
function useDialog(open, requestClose, closeOnBackdrop = true, options = {}) {
|
|
506
|
+
const ref = React7.useRef(null);
|
|
507
|
+
const reduce = useReducedMotion();
|
|
508
|
+
const closeRef = React7.useRef(requestClose);
|
|
509
|
+
closeRef.current = requestClose;
|
|
510
|
+
const openRef = React7.useRef(open);
|
|
511
|
+
openRef.current = open;
|
|
512
|
+
const opener = React7.useRef(null);
|
|
513
|
+
const native = React7.useRef(false);
|
|
514
|
+
const { initialFocus, lockScroll = true } = options;
|
|
515
|
+
React7.useEffect(() => {
|
|
516
|
+
var _a, _b;
|
|
517
|
+
const d = ref.current;
|
|
518
|
+
if (!d) return;
|
|
519
|
+
let t;
|
|
520
|
+
const finishClose = () => {
|
|
521
|
+
var _a2;
|
|
522
|
+
d.classList.remove("is-closing");
|
|
523
|
+
if (d.open) (_a2 = d.close) == null ? void 0 : _a2.call(d);
|
|
524
|
+
d.removeAttribute("open");
|
|
525
|
+
const o = opener.current;
|
|
526
|
+
opener.current = null;
|
|
527
|
+
if (o && o.isConnected && typeof o.focus === "function") o.focus();
|
|
528
|
+
};
|
|
529
|
+
if (open) {
|
|
530
|
+
d.classList.remove("is-closing");
|
|
531
|
+
if (!d.open) {
|
|
532
|
+
const active = d.ownerDocument.activeElement;
|
|
533
|
+
opener.current = active instanceof HTMLElement && active !== d.ownerDocument.body ? active : null;
|
|
534
|
+
native.current = typeof d.showModal === "function";
|
|
535
|
+
if (native.current) d.showModal();
|
|
536
|
+
else d.setAttribute("open", "");
|
|
537
|
+
}
|
|
538
|
+
if (!d.contains(d.ownerDocument.activeElement) || d.ownerDocument.activeElement === d) {
|
|
539
|
+
const target = (_b = (_a = initialFocus == null ? void 0 : initialFocus.current) != null ? _a : d.querySelector("[autofocus]")) != null ? _b : focusables(d)[0];
|
|
540
|
+
if (target) target.focus();
|
|
541
|
+
else {
|
|
542
|
+
if (!d.hasAttribute("tabindex")) d.tabIndex = -1;
|
|
543
|
+
d.focus();
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
} else if (d.open || d.hasAttribute("open")) {
|
|
547
|
+
if (reduce) finishClose();
|
|
548
|
+
else {
|
|
549
|
+
d.classList.add("is-closing");
|
|
550
|
+
t = setTimeout(finishClose, 160);
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
return () => {
|
|
554
|
+
if (t) clearTimeout(t);
|
|
555
|
+
};
|
|
556
|
+
}, [open, reduce, initialFocus]);
|
|
557
|
+
React7.useEffect(() => {
|
|
558
|
+
var _a;
|
|
559
|
+
if (!open || !lockScroll) return;
|
|
560
|
+
const body = (_a = ref.current) == null ? void 0 : _a.ownerDocument.body;
|
|
561
|
+
if (!body) return;
|
|
562
|
+
const prev = body.style.overflow;
|
|
563
|
+
body.style.overflow = "hidden";
|
|
564
|
+
return () => {
|
|
565
|
+
body.style.overflow = prev;
|
|
566
|
+
};
|
|
567
|
+
}, [open, lockScroll]);
|
|
568
|
+
React7.useEffect(() => {
|
|
569
|
+
const d = ref.current;
|
|
570
|
+
if (!d) return;
|
|
571
|
+
const onCancel = (e) => {
|
|
572
|
+
e.preventDefault();
|
|
573
|
+
closeRef.current();
|
|
574
|
+
};
|
|
575
|
+
const onClose = () => {
|
|
576
|
+
if (openRef.current) closeRef.current();
|
|
577
|
+
};
|
|
578
|
+
const onKey = (e) => {
|
|
579
|
+
if (e.key === "Escape" && !native.current) {
|
|
580
|
+
e.preventDefault();
|
|
581
|
+
closeRef.current();
|
|
582
|
+
return;
|
|
583
|
+
}
|
|
584
|
+
if (e.key !== "Tab") return;
|
|
585
|
+
const list = focusables(d);
|
|
586
|
+
if (!list.length) {
|
|
587
|
+
e.preventDefault();
|
|
588
|
+
return;
|
|
589
|
+
}
|
|
590
|
+
const first = list[0], last = list[list.length - 1], cur = d.ownerDocument.activeElement;
|
|
591
|
+
if (e.shiftKey && (cur === first || cur === d || !d.contains(cur))) {
|
|
592
|
+
e.preventDefault();
|
|
593
|
+
last.focus();
|
|
594
|
+
} else if (!e.shiftKey && (cur === last || !d.contains(cur))) {
|
|
595
|
+
e.preventDefault();
|
|
596
|
+
first.focus();
|
|
597
|
+
}
|
|
598
|
+
};
|
|
599
|
+
d.addEventListener("cancel", onCancel);
|
|
600
|
+
d.addEventListener("close", onClose);
|
|
601
|
+
d.addEventListener("keydown", onKey);
|
|
602
|
+
return () => {
|
|
603
|
+
d.removeEventListener("cancel", onCancel);
|
|
604
|
+
d.removeEventListener("close", onClose);
|
|
605
|
+
d.removeEventListener("keydown", onKey);
|
|
606
|
+
};
|
|
607
|
+
}, []);
|
|
608
|
+
const onClick = React7.useCallback((e) => {
|
|
609
|
+
if (closeOnBackdrop && e.target === e.currentTarget) closeRef.current();
|
|
610
|
+
}, [closeOnBackdrop]);
|
|
611
|
+
return { ref, onClick };
|
|
612
|
+
}
|
|
613
|
+
function mergeRefs(...refs) {
|
|
614
|
+
return (el) => {
|
|
615
|
+
for (const r of refs) {
|
|
616
|
+
if (typeof r === "function") r(el);
|
|
617
|
+
else if (r) r.current = el;
|
|
618
|
+
}
|
|
619
|
+
};
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
// src/components/CommandPalette.tsx
|
|
623
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
624
|
+
var text = (n) => typeof n === "string" || typeof n === "number" ? String(n) : Array.isArray(n) ? n.map(text).join(" ") : React8.isValidElement(n) ? text(n.props.children) : "";
|
|
625
|
+
function CommandPalette({
|
|
626
|
+
groups,
|
|
627
|
+
open,
|
|
628
|
+
defaultOpen = false,
|
|
629
|
+
onOpenChange,
|
|
630
|
+
placeholder = "\u641C\u5C0B\u6307\u4EE4\u2026",
|
|
631
|
+
emptyText = "\u6C92\u6709\u7B26\u5408\u7684\u6307\u4EE4",
|
|
632
|
+
hotkey = true,
|
|
633
|
+
showFooter = true,
|
|
634
|
+
className,
|
|
635
|
+
"aria-label": label = "\u6307\u4EE4\u9762\u677F"
|
|
636
|
+
}) {
|
|
637
|
+
const [isOpen, setOpen] = useControllable(open, defaultOpen, onOpenChange);
|
|
638
|
+
const { ref, onClick } = useDialog(isOpen, () => setOpen(false));
|
|
639
|
+
const [q, setQ] = React8.useState("");
|
|
640
|
+
const [active, setActive] = React8.useState(0);
|
|
641
|
+
const inputRef = React8.useRef(null);
|
|
642
|
+
const listRef = React8.useRef(null);
|
|
643
|
+
const id = useId2("cmd");
|
|
644
|
+
React8.useEffect(() => {
|
|
645
|
+
if (!hotkey) return;
|
|
646
|
+
const on = (e) => {
|
|
647
|
+
if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === "k") {
|
|
648
|
+
e.preventDefault();
|
|
649
|
+
setOpen(!isOpen);
|
|
650
|
+
}
|
|
651
|
+
};
|
|
652
|
+
document.addEventListener("keydown", on);
|
|
653
|
+
return () => document.removeEventListener("keydown", on);
|
|
654
|
+
}, [hotkey, isOpen, setOpen]);
|
|
655
|
+
React8.useEffect(() => {
|
|
656
|
+
if (isOpen) {
|
|
657
|
+
setQ("");
|
|
658
|
+
setActive(0);
|
|
659
|
+
setTimeout(() => {
|
|
660
|
+
var _a;
|
|
661
|
+
return (_a = inputRef.current) == null ? void 0 : _a.focus();
|
|
662
|
+
}, 0);
|
|
663
|
+
}
|
|
664
|
+
}, [isOpen]);
|
|
665
|
+
const query = q.trim().toLowerCase();
|
|
666
|
+
const filtered = groups.map((g) => ({ ...g, items: g.items.filter((it) => {
|
|
667
|
+
var _a;
|
|
668
|
+
return !query || (text(it.label) + " " + ((_a = it.keywords) != null ? _a : "")).toLowerCase().includes(query);
|
|
669
|
+
}) })).filter((g) => g.items.length);
|
|
670
|
+
const flat = filtered.flatMap((g) => g.items);
|
|
671
|
+
React8.useEffect(() => {
|
|
672
|
+
setActive(0);
|
|
673
|
+
}, [query]);
|
|
674
|
+
React8.useEffect(() => {
|
|
675
|
+
var _a, _b;
|
|
676
|
+
(_b = (_a = listRef.current) == null ? void 0 : _a.querySelector("[aria-selected=true]")) == null ? void 0 : _b.scrollIntoView({ block: "nearest" });
|
|
677
|
+
}, [active]);
|
|
678
|
+
const run = (it) => {
|
|
679
|
+
var _a;
|
|
680
|
+
(_a = it.onSelect) == null ? void 0 : _a.call(it);
|
|
681
|
+
if (it.href) window.location.href = it.href;
|
|
682
|
+
setOpen(false);
|
|
683
|
+
};
|
|
684
|
+
const onKeyDown = (e) => {
|
|
685
|
+
if (e.key === "ArrowDown") {
|
|
686
|
+
e.preventDefault();
|
|
687
|
+
setActive((a) => Math.min(flat.length - 1, a + 1));
|
|
688
|
+
} else if (e.key === "ArrowUp") {
|
|
689
|
+
e.preventDefault();
|
|
690
|
+
setActive((a) => Math.max(0, a - 1));
|
|
691
|
+
} else if (e.key === "Enter" && flat[active]) {
|
|
692
|
+
e.preventDefault();
|
|
693
|
+
run(flat[active]);
|
|
694
|
+
}
|
|
695
|
+
};
|
|
696
|
+
let n = -1;
|
|
697
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("dialog", { ref, onClick, className: cx("a-command", className), "aria-label": label, children: [
|
|
698
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "a-command__search", children: [
|
|
699
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", children: [
|
|
700
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("circle", { cx: "11", cy: "11", r: "7" }),
|
|
701
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("path", { d: "m20 20-3.5-3.5" })
|
|
702
|
+
] }),
|
|
703
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
704
|
+
"input",
|
|
705
|
+
{
|
|
706
|
+
ref: inputRef,
|
|
707
|
+
value: q,
|
|
708
|
+
onChange: (e) => setQ(e.target.value),
|
|
709
|
+
onKeyDown,
|
|
710
|
+
placeholder,
|
|
711
|
+
"aria-label": "\u641C\u5C0B",
|
|
712
|
+
role: "combobox",
|
|
713
|
+
"aria-expanded": true,
|
|
714
|
+
"aria-controls": id,
|
|
715
|
+
"aria-activedescendant": flat[active] ? id + "-" + flat[active].key : void 0
|
|
716
|
+
}
|
|
717
|
+
)
|
|
718
|
+
] }),
|
|
719
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "a-command__list", role: "listbox", id, ref: listRef, children: [
|
|
720
|
+
filtered.map((g, gi) => /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(React8.Fragment, { children: [
|
|
721
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "a-command__group", children: g.label }),
|
|
722
|
+
g.items.map((it) => {
|
|
723
|
+
const idx = ++n;
|
|
724
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
|
|
725
|
+
"button",
|
|
726
|
+
{
|
|
727
|
+
id: id + "-" + it.key,
|
|
728
|
+
type: "button",
|
|
729
|
+
role: "option",
|
|
730
|
+
className: "a-command__item",
|
|
731
|
+
"aria-selected": idx === active,
|
|
732
|
+
tabIndex: -1,
|
|
733
|
+
onMouseMove: () => setActive(idx),
|
|
734
|
+
onClick: () => run(it),
|
|
735
|
+
children: [
|
|
736
|
+
it.icon,
|
|
737
|
+
it.label,
|
|
738
|
+
it.shortcut && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("kbd", { className: "a-kbd", children: it.shortcut })
|
|
739
|
+
]
|
|
740
|
+
},
|
|
741
|
+
it.key
|
|
742
|
+
);
|
|
743
|
+
})
|
|
744
|
+
] }, gi)),
|
|
745
|
+
!flat.length && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "a-command__empty", children: emptyText })
|
|
746
|
+
] }),
|
|
747
|
+
showFooter && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "a-command__foot", children: [
|
|
748
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("span", { children: [
|
|
749
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("kbd", { className: "a-kbd", children: "\u2191" }),
|
|
750
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("kbd", { className: "a-kbd", children: "\u2193" }),
|
|
751
|
+
"\u79FB\u52D5"
|
|
752
|
+
] }),
|
|
753
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("span", { children: [
|
|
754
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("kbd", { className: "a-kbd", children: "\u21B5" }),
|
|
755
|
+
"\u57F7\u884C"
|
|
756
|
+
] }),
|
|
757
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("span", { children: [
|
|
758
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("kbd", { className: "a-kbd", children: "Esc" }),
|
|
759
|
+
"\u95DC\u9589"
|
|
760
|
+
] })
|
|
761
|
+
] })
|
|
762
|
+
] });
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
// src/components/ContextMenu.tsx
|
|
766
|
+
var React9 = __toESM(require("react"), 1);
|
|
767
|
+
var import_react_dom = require("react-dom");
|
|
768
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
769
|
+
function ContextMenu({ items, onSelect, children, onContextMenu, className, ...rest }) {
|
|
770
|
+
var _a, _b;
|
|
771
|
+
const [pos, setPos] = React9.useState(null);
|
|
772
|
+
const [placed, setPlaced] = React9.useState(null);
|
|
773
|
+
const [shown, setShown] = React9.useState(false);
|
|
774
|
+
const menuRef = React9.useRef(null);
|
|
775
|
+
React9.useLayoutEffect(() => {
|
|
776
|
+
const m = menuRef.current;
|
|
777
|
+
if (!pos || !m) {
|
|
778
|
+
setPlaced(null);
|
|
779
|
+
return;
|
|
780
|
+
}
|
|
781
|
+
const w = m.offsetWidth, h = m.offsetHeight;
|
|
782
|
+
const x = pos.x + w > window.innerWidth - 8 ? pos.x - w : pos.x;
|
|
783
|
+
const y = pos.y + h > window.innerHeight - 8 ? pos.y - h : pos.y;
|
|
784
|
+
setPlaced({ left: Math.max(8, x), top: Math.max(8, y), origin: (x < pos.x ? "right" : "left") + " " + (y < pos.y ? "bottom" : "top") });
|
|
785
|
+
}, [pos]);
|
|
786
|
+
React9.useEffect(() => {
|
|
787
|
+
if (!placed) {
|
|
788
|
+
setShown(false);
|
|
789
|
+
return;
|
|
790
|
+
}
|
|
791
|
+
setShown(false);
|
|
792
|
+
const r = requestAnimationFrame(() => setShown(true));
|
|
793
|
+
return () => cancelAnimationFrame(r);
|
|
794
|
+
}, [placed]);
|
|
795
|
+
React9.useEffect(() => {
|
|
796
|
+
var _a2, _b2;
|
|
797
|
+
if (shown) (_b2 = (_a2 = menuRef.current) == null ? void 0 : _a2.querySelector("[role=menuitem]:not(:disabled)")) == null ? void 0 : _b2.focus({ preventScroll: true });
|
|
798
|
+
}, [shown]);
|
|
799
|
+
React9.useEffect(() => {
|
|
800
|
+
if (!pos) return;
|
|
801
|
+
const close = () => setPos(null);
|
|
802
|
+
const onDoc = (e) => {
|
|
803
|
+
var _a2;
|
|
804
|
+
if (!((_a2 = menuRef.current) == null ? void 0 : _a2.contains(e.target))) close();
|
|
805
|
+
};
|
|
806
|
+
const onKey = (e) => {
|
|
807
|
+
if (e.key === "Escape") close();
|
|
808
|
+
};
|
|
809
|
+
document.addEventListener("mousedown", onDoc);
|
|
810
|
+
document.addEventListener("keydown", onKey);
|
|
811
|
+
window.addEventListener("scroll", close, { capture: true, passive: true });
|
|
812
|
+
window.addEventListener("blur", close);
|
|
813
|
+
return () => {
|
|
814
|
+
document.removeEventListener("mousedown", onDoc);
|
|
815
|
+
document.removeEventListener("keydown", onKey);
|
|
816
|
+
window.removeEventListener("scroll", close, { capture: true });
|
|
817
|
+
window.removeEventListener("blur", close);
|
|
818
|
+
};
|
|
819
|
+
}, [pos]);
|
|
820
|
+
const onMenuKey = (e) => {
|
|
821
|
+
var _a2;
|
|
822
|
+
if (e.key !== "ArrowDown" && e.key !== "ArrowUp") return;
|
|
823
|
+
e.preventDefault();
|
|
824
|
+
const its = Array.from(e.currentTarget.querySelectorAll("[role=menuitem]:not(:disabled)"));
|
|
825
|
+
const k = its.indexOf(document.activeElement);
|
|
826
|
+
(_a2 = its[(k + (e.key === "ArrowDown" ? 1 : -1) + its.length) % its.length]) == null ? void 0 : _a2.focus();
|
|
827
|
+
};
|
|
828
|
+
const menu = pos && typeof document !== "undefined" ? (0, import_react_dom.createPortal)(
|
|
829
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
830
|
+
"div",
|
|
831
|
+
{
|
|
832
|
+
ref: menuRef,
|
|
833
|
+
className: cx("a-context", shown && "is-open"),
|
|
834
|
+
role: "menu",
|
|
835
|
+
style: { left: (_a = placed == null ? void 0 : placed.left) != null ? _a : pos.x, top: (_b = placed == null ? void 0 : placed.top) != null ? _b : pos.y, transformOrigin: placed == null ? void 0 : placed.origin },
|
|
836
|
+
onKeyDown: onMenuKey,
|
|
837
|
+
children: items.map((it) => it.divider ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "a-context__sep", role: "separator" }, it.key) : /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
838
|
+
"button",
|
|
839
|
+
{
|
|
840
|
+
type: "button",
|
|
841
|
+
role: "menuitem",
|
|
842
|
+
className: cx(it.danger && "is-danger"),
|
|
843
|
+
disabled: it.disabled,
|
|
844
|
+
onClick: () => {
|
|
845
|
+
var _a2;
|
|
846
|
+
(_a2 = it.onClick) == null ? void 0 : _a2.call(it);
|
|
847
|
+
onSelect == null ? void 0 : onSelect(it.key);
|
|
848
|
+
setPos(null);
|
|
849
|
+
},
|
|
850
|
+
children: [
|
|
851
|
+
it.label,
|
|
852
|
+
it.shortcut && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("kbd", { className: "a-kbd", children: it.shortcut })
|
|
853
|
+
]
|
|
854
|
+
},
|
|
855
|
+
it.key
|
|
856
|
+
))
|
|
857
|
+
}
|
|
858
|
+
),
|
|
859
|
+
document.body
|
|
860
|
+
) : null;
|
|
861
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
862
|
+
"div",
|
|
863
|
+
{
|
|
864
|
+
className,
|
|
865
|
+
onContextMenu: (e) => {
|
|
866
|
+
onContextMenu == null ? void 0 : onContextMenu(e);
|
|
867
|
+
if (e.defaultPrevented) return;
|
|
868
|
+
e.preventDefault();
|
|
869
|
+
setPos({ x: e.clientX, y: e.clientY });
|
|
870
|
+
},
|
|
871
|
+
...rest,
|
|
872
|
+
children: [
|
|
873
|
+
children,
|
|
874
|
+
menu
|
|
875
|
+
]
|
|
876
|
+
}
|
|
877
|
+
);
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
// src/components/Input.tsx
|
|
881
|
+
var React11 = __toESM(require("react"), 1);
|
|
882
|
+
|
|
883
|
+
// src/fieldContext.ts
|
|
884
|
+
var React10 = __toESM(require("react"), 1);
|
|
885
|
+
var FieldContext = React10.createContext(null);
|
|
886
|
+
function useFieldControl(props) {
|
|
887
|
+
var _a, _b, _c, _d;
|
|
888
|
+
const f = React10.useContext(FieldContext);
|
|
889
|
+
const describedBy = [props["aria-describedby"], f == null ? void 0 : f.describedBy].filter(Boolean).join(" ") || void 0;
|
|
890
|
+
return {
|
|
891
|
+
id: (_a = props.id) != null ? _a : f == null ? void 0 : f.id,
|
|
892
|
+
"aria-labelledby": (_b = props["aria-labelledby"]) != null ? _b : props["aria-label"] ? void 0 : f == null ? void 0 : f.labelledBy,
|
|
893
|
+
"aria-label": props["aria-label"],
|
|
894
|
+
"aria-describedby": describedBy,
|
|
895
|
+
"aria-invalid": (_c = props["aria-invalid"]) != null ? _c : (f == null ? void 0 : f.invalid) ? true : void 0,
|
|
896
|
+
required: (_d = props.required) != null ? _d : f == null ? void 0 : f.required
|
|
897
|
+
};
|
|
898
|
+
}
|
|
899
|
+
|
|
900
|
+
// src/components/Input.tsx
|
|
901
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
902
|
+
var Input = React11.forwardRef(function Input2({ size = "md", prefix, className, onChange, onValueChange, id, required, "aria-describedby": describedBy, "aria-invalid": invalid, "aria-label": ariaLabel, "aria-labelledby": labelledBy, ...rest }, ref) {
|
|
903
|
+
const a11y = useFieldControl({ id, required, "aria-describedby": describedBy, "aria-invalid": invalid, "aria-label": ariaLabel, "aria-labelledby": labelledBy });
|
|
904
|
+
const input = /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
905
|
+
"input",
|
|
906
|
+
{
|
|
907
|
+
ref,
|
|
908
|
+
className: cx("a-input", size !== "md" && "a-input--" + size, className),
|
|
909
|
+
onChange: (e) => {
|
|
910
|
+
onChange == null ? void 0 : onChange(e);
|
|
911
|
+
onValueChange == null ? void 0 : onValueChange(e.target.value);
|
|
912
|
+
},
|
|
913
|
+
...a11y,
|
|
914
|
+
...rest
|
|
915
|
+
}
|
|
916
|
+
);
|
|
917
|
+
return prefix ? /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("span", { className: "a-input-wrap", children: [
|
|
918
|
+
prefix,
|
|
919
|
+
input
|
|
920
|
+
] }) : input;
|
|
921
|
+
});
|
|
922
|
+
var Field = React11.forwardRef(function Field2({ label, help, error, as = "label", htmlFor, required, className, children, ...rest }, ref) {
|
|
923
|
+
const Tag3 = as;
|
|
924
|
+
const auto = useId2("field");
|
|
925
|
+
const controlId = htmlFor != null ? htmlFor : auto;
|
|
926
|
+
const msgId = controlId + "-msg";
|
|
927
|
+
const labelId = controlId + "-label";
|
|
928
|
+
const hasError = error != null && error !== false;
|
|
929
|
+
const msg = hasError ? error : help;
|
|
930
|
+
const hasMsg = msg != null && msg !== false;
|
|
931
|
+
const ctx = React11.useMemo(
|
|
932
|
+
() => ({ id: controlId, describedBy: hasMsg ? msgId : void 0, labelledBy: label != null ? labelId : void 0, invalid: hasError, required }),
|
|
933
|
+
[controlId, msgId, labelId, label != null, hasMsg, hasError, required]
|
|
934
|
+
);
|
|
935
|
+
const labelText = label != null && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
|
|
936
|
+
label,
|
|
937
|
+
required && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { "aria-hidden": "true", children: " *" })
|
|
938
|
+
] });
|
|
939
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(Tag3, { ref, className: cx("a-field", hasError && "is-error", className), ...rest, children: [
|
|
940
|
+
label != null && (as === "div" ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("label", { className: "a-label", htmlFor: controlId, id: labelId, children: labelText }) : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "a-label", id: labelId, children: labelText })),
|
|
941
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(FieldContext.Provider, { value: ctx, children }),
|
|
942
|
+
hasMsg && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "a-help", id: msgId, role: hasError ? "alert" : void 0, children: msg })
|
|
943
|
+
] });
|
|
944
|
+
});
|
|
945
|
+
|
|
946
|
+
// src/components/Textarea.tsx
|
|
947
|
+
var React12 = __toESM(require("react"), 1);
|
|
948
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
949
|
+
var Textarea = React12.forwardRef(function Textarea2({ value, defaultValue = "", onValueChange, onChange, maxLength, showCount = true, className, id, required, "aria-describedby": describedBy, "aria-invalid": invalid, "aria-label": ariaLabel, "aria-labelledby": labelledBy, ...rest }, ref) {
|
|
950
|
+
const [val, setVal] = useControllable(value, defaultValue, onValueChange);
|
|
951
|
+
const count = showCount && maxLength != null;
|
|
952
|
+
const a11y = useFieldControl({ id, required, "aria-describedby": describedBy, "aria-invalid": invalid, "aria-label": ariaLabel, "aria-labelledby": labelledBy });
|
|
953
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_jsx_runtime14.Fragment, { children: [
|
|
954
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
955
|
+
"textarea",
|
|
956
|
+
{
|
|
957
|
+
ref,
|
|
958
|
+
className: cx("a-input", "a-textarea", className),
|
|
959
|
+
value: val,
|
|
960
|
+
maxLength,
|
|
961
|
+
onChange: (e) => {
|
|
962
|
+
onChange == null ? void 0 : onChange(e);
|
|
963
|
+
setVal(e.target.value);
|
|
964
|
+
},
|
|
965
|
+
...a11y,
|
|
966
|
+
...rest
|
|
967
|
+
}
|
|
968
|
+
),
|
|
969
|
+
count && /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("span", { className: cx("a-field__count", val.length >= maxLength && "is-full"), "aria-live": "polite", children: [
|
|
970
|
+
val.length,
|
|
971
|
+
" / ",
|
|
972
|
+
maxLength
|
|
973
|
+
] })
|
|
974
|
+
] });
|
|
975
|
+
});
|
|
976
|
+
|
|
977
|
+
// src/components/Select.tsx
|
|
978
|
+
var React13 = __toESM(require("react"), 1);
|
|
979
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
980
|
+
var Select = React13.forwardRef(function Select2({
|
|
981
|
+
options,
|
|
982
|
+
size = "md",
|
|
983
|
+
placeholder,
|
|
984
|
+
className,
|
|
985
|
+
children,
|
|
986
|
+
onChange,
|
|
987
|
+
onValueChange,
|
|
988
|
+
id,
|
|
989
|
+
required,
|
|
990
|
+
"aria-describedby": describedBy,
|
|
991
|
+
"aria-invalid": invalid,
|
|
992
|
+
"aria-label": ariaLabel,
|
|
993
|
+
"aria-labelledby": labelledBy,
|
|
994
|
+
value,
|
|
995
|
+
defaultValue,
|
|
996
|
+
...rest
|
|
997
|
+
}, ref) {
|
|
998
|
+
const a11y = useFieldControl({ id, required, "aria-describedby": describedBy, "aria-invalid": invalid, "aria-label": ariaLabel, "aria-labelledby": labelledBy });
|
|
999
|
+
const uncontrolledDefault = value === void 0 && defaultValue === void 0 && placeholder != null ? "" : defaultValue;
|
|
1000
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
|
1001
|
+
"select",
|
|
1002
|
+
{
|
|
1003
|
+
ref,
|
|
1004
|
+
className: cx("a-input", "a-select", size !== "md" && "a-input--" + size, className),
|
|
1005
|
+
onChange: (e) => {
|
|
1006
|
+
onChange == null ? void 0 : onChange(e);
|
|
1007
|
+
onValueChange == null ? void 0 : onValueChange(e.target.value);
|
|
1008
|
+
},
|
|
1009
|
+
value,
|
|
1010
|
+
defaultValue: uncontrolledDefault,
|
|
1011
|
+
...a11y,
|
|
1012
|
+
...rest,
|
|
1013
|
+
children: [
|
|
1014
|
+
placeholder != null && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("option", { value: "", disabled: true, children: placeholder }),
|
|
1015
|
+
options == null ? void 0 : options.map((o) => {
|
|
1016
|
+
var _a;
|
|
1017
|
+
return typeof o === "string" ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("option", { value: o, children: o }, o) : /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("option", { value: o.value, disabled: o.disabled, children: (_a = o.label) != null ? _a : o.value }, o.value);
|
|
1018
|
+
}),
|
|
1019
|
+
children
|
|
1020
|
+
]
|
|
1021
|
+
}
|
|
1022
|
+
);
|
|
1023
|
+
});
|
|
1024
|
+
|
|
1025
|
+
// src/components/Switch.tsx
|
|
1026
|
+
var React14 = __toESM(require("react"), 1);
|
|
1027
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
1028
|
+
var Switch = React14.forwardRef(function Switch2({ checked, defaultChecked = false, onChange, size = "md", className, children, style, ...rest }, ref) {
|
|
1029
|
+
const [on, setOn] = useControllable(checked, defaultChecked);
|
|
1030
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("label", { className: cx("a-switch", size === "sm" && "a-switch--sm", className), style, children: [
|
|
1031
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1032
|
+
"input",
|
|
1033
|
+
{
|
|
1034
|
+
ref,
|
|
1035
|
+
type: "checkbox",
|
|
1036
|
+
role: "switch",
|
|
1037
|
+
checked: on,
|
|
1038
|
+
onChange: (e) => {
|
|
1039
|
+
setOn(e.target.checked);
|
|
1040
|
+
onChange == null ? void 0 : onChange(e.target.checked, e);
|
|
1041
|
+
},
|
|
1042
|
+
...rest
|
|
1043
|
+
}
|
|
1044
|
+
),
|
|
1045
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "a-switch__track", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "a-switch__thumb" }) }),
|
|
1046
|
+
children
|
|
1047
|
+
] });
|
|
1048
|
+
});
|
|
1049
|
+
|
|
1050
|
+
// src/components/Checkbox.tsx
|
|
1051
|
+
var React15 = __toESM(require("react"), 1);
|
|
1052
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
1053
|
+
var Checkbox = React15.forwardRef(function Checkbox2({ checked, defaultChecked = false, indeterminate = false, onChange, className, style, children, ...rest }, ref) {
|
|
1054
|
+
const inner = React15.useRef(null);
|
|
1055
|
+
React15.useImperativeHandle(ref, () => inner.current);
|
|
1056
|
+
const [on, setOn] = useControllable(checked, defaultChecked);
|
|
1057
|
+
React15.useEffect(() => {
|
|
1058
|
+
if (inner.current) inner.current.indeterminate = indeterminate;
|
|
1059
|
+
}, [indeterminate, on]);
|
|
1060
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("label", { className: cx("a-check", className), style, children: [
|
|
1061
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
1062
|
+
"input",
|
|
1063
|
+
{
|
|
1064
|
+
ref: inner,
|
|
1065
|
+
type: "checkbox",
|
|
1066
|
+
checked: on,
|
|
1067
|
+
"aria-checked": indeterminate ? "mixed" : void 0,
|
|
1068
|
+
onChange: (e) => {
|
|
1069
|
+
setOn(e.target.checked);
|
|
1070
|
+
onChange == null ? void 0 : onChange(e.target.checked, e);
|
|
1071
|
+
},
|
|
1072
|
+
...rest
|
|
1073
|
+
}
|
|
1074
|
+
),
|
|
1075
|
+
children
|
|
1076
|
+
] });
|
|
1077
|
+
});
|
|
1078
|
+
var normOption = (o) => {
|
|
1079
|
+
var _a;
|
|
1080
|
+
return typeof o === "string" ? { value: o, label: o, disabled: false } : { value: o.value, label: (_a = o.label) != null ? _a : o.value, disabled: !!o.disabled };
|
|
1081
|
+
};
|
|
1082
|
+
function CheckboxGroup({ options, value, defaultValue = [], onChange, vertical, disabled, className, ...rest }) {
|
|
1083
|
+
const [val, setVal] = useControllable(value, defaultValue, onChange);
|
|
1084
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { role: "group", className: cx("a-check-group", vertical && "a-check-group--vertical", className), ...rest, children: options.map(normOption).map((o) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
1085
|
+
Checkbox,
|
|
1086
|
+
{
|
|
1087
|
+
checked: val.includes(o.value),
|
|
1088
|
+
disabled: disabled || o.disabled,
|
|
1089
|
+
onChange: (c) => setVal(c ? [...val, o.value] : val.filter((v) => v !== o.value)),
|
|
1090
|
+
children: o.label
|
|
1091
|
+
},
|
|
1092
|
+
o.value
|
|
1093
|
+
)) });
|
|
1094
|
+
}
|
|
1095
|
+
|
|
1096
|
+
// src/components/Radio.tsx
|
|
1097
|
+
var React16 = __toESM(require("react"), 1);
|
|
1098
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
1099
|
+
var Radio = React16.forwardRef(function Radio2({ className, style, children, ...rest }, ref) {
|
|
1100
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("label", { className: cx("a-check", className), style, children: [
|
|
1101
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("input", { ref, type: "radio", ...rest }),
|
|
1102
|
+
children
|
|
1103
|
+
] });
|
|
1104
|
+
});
|
|
1105
|
+
function RadioGroup({ options, value, defaultValue = "", onChange, name, vertical, disabled, className, ...rest }) {
|
|
1106
|
+
const auto = useId2("radio");
|
|
1107
|
+
const [val, setVal] = useControllable(value, defaultValue, onChange);
|
|
1108
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { role: "radiogroup", className: cx("a-check-group", vertical && "a-check-group--vertical", className), ...rest, children: options.map(normOption).map((o) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
1109
|
+
Radio,
|
|
1110
|
+
{
|
|
1111
|
+
name: name != null ? name : auto,
|
|
1112
|
+
value: o.value,
|
|
1113
|
+
checked: val === o.value,
|
|
1114
|
+
disabled: disabled || o.disabled,
|
|
1115
|
+
onChange: () => setVal(o.value),
|
|
1116
|
+
children: o.label
|
|
1117
|
+
},
|
|
1118
|
+
o.value
|
|
1119
|
+
)) });
|
|
1120
|
+
}
|
|
1121
|
+
|
|
1122
|
+
// src/components/Segmented.tsx
|
|
1123
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
1124
|
+
function Segmented({ options, value, defaultValue, onChange, name, className, ...rest }) {
|
|
1125
|
+
var _a, _b;
|
|
1126
|
+
const auto = useId2("seg");
|
|
1127
|
+
const list = options.map(normOption);
|
|
1128
|
+
const [val, setVal] = useControllable(value, (_b = defaultValue != null ? defaultValue : (_a = list[0]) == null ? void 0 : _a.value) != null ? _b : "", onChange);
|
|
1129
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { role: "radiogroup", className: cx("a-segmented", className), ...rest, children: list.map((o) => /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("label", { children: [
|
|
1130
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("input", { type: "radio", name: name != null ? name : auto, value: o.value, checked: val === o.value, disabled: o.disabled, onChange: () => setVal(o.value) }),
|
|
1131
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { children: o.label })
|
|
1132
|
+
] }, o.value)) });
|
|
1133
|
+
}
|
|
1134
|
+
|
|
1135
|
+
// src/components/Slider.tsx
|
|
1136
|
+
var React17 = __toESM(require("react"), 1);
|
|
1137
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
1138
|
+
var Slider = React17.forwardRef(function Slider2({ value, defaultValue, onChange, min = 0, max = 100, step = 1, showValue = true, unit = "", className, style, ...rest }, ref) {
|
|
1139
|
+
const [val, setVal] = useControllable(value, defaultValue != null ? defaultValue : min, onChange);
|
|
1140
|
+
const pct = max > min ? (val - min) / (max - min) * 100 : 0;
|
|
1141
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: cx("a-slider-row", className), style, children: [
|
|
1142
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
1143
|
+
"input",
|
|
1144
|
+
{
|
|
1145
|
+
ref,
|
|
1146
|
+
className: "a-slider",
|
|
1147
|
+
type: "range",
|
|
1148
|
+
min,
|
|
1149
|
+
max,
|
|
1150
|
+
step,
|
|
1151
|
+
value: val,
|
|
1152
|
+
style: { "--v": pct + "%" },
|
|
1153
|
+
onChange: (e) => setVal(Number(e.target.value)),
|
|
1154
|
+
...rest
|
|
1155
|
+
}
|
|
1156
|
+
),
|
|
1157
|
+
showValue && /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("span", { className: "a-slider-value", children: [
|
|
1158
|
+
val,
|
|
1159
|
+
unit
|
|
1160
|
+
] })
|
|
1161
|
+
] });
|
|
1162
|
+
});
|
|
1163
|
+
|
|
1164
|
+
// src/components/DatePicker.tsx
|
|
1165
|
+
var React18 = __toESM(require("react"), 1);
|
|
1166
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
1167
|
+
var DatePicker = React18.forwardRef(function DatePicker2({ type = "date", ...rest }, ref) {
|
|
1168
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Input, { ref, type, ...rest });
|
|
1169
|
+
});
|
|
1170
|
+
function DateRangeInputs({ start = {}, end = {}, separator = "\u2192", className }) {
|
|
1171
|
+
var _a;
|
|
1172
|
+
const startVal = (_a = start.value) != null ? _a : void 0;
|
|
1173
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: ["a-date-range", className].filter(Boolean).join(" "), children: [
|
|
1174
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(DatePicker, { ...start }),
|
|
1175
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { "aria-hidden": "true", children: separator }),
|
|
1176
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(DatePicker, { min: startVal, ...end })
|
|
1177
|
+
] });
|
|
1178
|
+
}
|
|
1179
|
+
|
|
1180
|
+
// src/components/Upload.tsx
|
|
1181
|
+
var React19 = __toESM(require("react"), 1);
|
|
1182
|
+
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
1183
|
+
var fmtSize = (b) => b < 1024 ? b + " B" : b < 1048576 ? Math.round(b / 1024) + " KB" : (b / 1048576).toFixed(1) + " MB";
|
|
1184
|
+
var Upload = React19.forwardRef(function Upload2({ accept, multiple, disabled, title, hint, onChange, showList = true, name, className, ...rest }, ref) {
|
|
1185
|
+
const [drag, setDrag] = React19.useState(false);
|
|
1186
|
+
const [files, setFiles] = React19.useState([]);
|
|
1187
|
+
const take = (list) => {
|
|
1188
|
+
if (!list) return;
|
|
1189
|
+
const arr = Array.from(list);
|
|
1190
|
+
const next = multiple ? arr : arr.slice(0, 1);
|
|
1191
|
+
setFiles(next);
|
|
1192
|
+
onChange == null ? void 0 : onChange(next);
|
|
1193
|
+
};
|
|
1194
|
+
const over = (e) => {
|
|
1195
|
+
if (disabled) return;
|
|
1196
|
+
e.preventDefault();
|
|
1197
|
+
setDrag(true);
|
|
1198
|
+
};
|
|
1199
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: cx("a-upload-wrap", className), ...rest, children: [
|
|
1200
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
|
|
1201
|
+
"label",
|
|
1202
|
+
{
|
|
1203
|
+
className: cx("a-upload", drag && "is-drag"),
|
|
1204
|
+
"aria-disabled": disabled || void 0,
|
|
1205
|
+
onDragEnter: over,
|
|
1206
|
+
onDragOver: over,
|
|
1207
|
+
onDragLeave: (e) => {
|
|
1208
|
+
if (!e.currentTarget.contains(e.relatedTarget)) setDrag(false);
|
|
1209
|
+
},
|
|
1210
|
+
onDrop: (e) => {
|
|
1211
|
+
e.preventDefault();
|
|
1212
|
+
setDrag(false);
|
|
1213
|
+
if (!disabled) take(e.dataTransfer.files);
|
|
1214
|
+
},
|
|
1215
|
+
children: [
|
|
1216
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("input", { ref, type: "file", name, accept, multiple, disabled, onChange: (e) => take(e.target.files) }),
|
|
1217
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { className: "a-upload__icon", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("svg", { viewBox: "0 0 24 24", children: [
|
|
1218
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("path", { d: "M12 16V4M7 9l5-5 5 5" }),
|
|
1219
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("path", { d: "M4 16v4h16v-4" })
|
|
1220
|
+
] }) }),
|
|
1221
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { className: "a-upload__title", children: title != null ? title : /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(import_jsx_runtime22.Fragment, { children: [
|
|
1222
|
+
"\u628A\u6A94\u6848\u62D6\u5230\u9019\u88E1\uFF0C\u6216 ",
|
|
1223
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("b", { children: "\u9EDE\u64CA\u9078\u64C7" })
|
|
1224
|
+
] }) }),
|
|
1225
|
+
hint != null && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { className: "a-upload__hint", children: hint })
|
|
1226
|
+
]
|
|
1227
|
+
}
|
|
1228
|
+
),
|
|
1229
|
+
showList && files.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("ul", { className: "a-upload-list", children: files.map((f, i) => /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("li", { children: [
|
|
1230
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { children: f.name }),
|
|
1231
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("small", { children: fmtSize(f.size) })
|
|
1232
|
+
] }, f.name + i)) })
|
|
1233
|
+
] });
|
|
1234
|
+
});
|
|
1235
|
+
|
|
1236
|
+
// src/components/Rating.tsx
|
|
1237
|
+
var React20 = __toESM(require("react"), 1);
|
|
1238
|
+
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
1239
|
+
function Rating({ value, defaultValue = 0, onChange, count = 5, readOnly, size = "md", character = "\u2605", className, ...rest }) {
|
|
1240
|
+
const id = useId2("rate");
|
|
1241
|
+
const [val, setVal] = useControllable(value, defaultValue, onChange);
|
|
1242
|
+
const stars = Array.from({ length: count }, (_, i) => count - i);
|
|
1243
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("fieldset", { className: cx("a-rating", size === "sm" && "a-rating--sm", className), ...rest, children: stars.map((n) => /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(React20.Fragment, { children: [
|
|
1244
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("input", { type: "radio", id: id + "-" + n, name: id, value: n, checked: val === n, disabled: readOnly, onChange: () => setVal(n) }),
|
|
1245
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("label", { htmlFor: id + "-" + n, "aria-label": n + " \u661F", children: character })
|
|
1246
|
+
] }, n)) });
|
|
1247
|
+
}
|
|
1248
|
+
|
|
1249
|
+
// src/components/Autocomplete.tsx
|
|
1250
|
+
var React21 = __toESM(require("react"), 1);
|
|
1251
|
+
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
1252
|
+
var norm = (o) => {
|
|
1253
|
+
var _a;
|
|
1254
|
+
return typeof o === "string" ? { value: o, label: o } : { value: o.value, label: (_a = o.label) != null ? _a : o.value };
|
|
1255
|
+
};
|
|
1256
|
+
function highlight(label, q) {
|
|
1257
|
+
if (!q) return label;
|
|
1258
|
+
const k = label.toLowerCase().indexOf(q.toLowerCase());
|
|
1259
|
+
if (k < 0) return label;
|
|
1260
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(import_jsx_runtime24.Fragment, { children: [
|
|
1261
|
+
label.slice(0, k),
|
|
1262
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("mark", { children: label.slice(k, k + q.length) }),
|
|
1263
|
+
label.slice(k + q.length)
|
|
1264
|
+
] });
|
|
1265
|
+
}
|
|
1266
|
+
var Autocomplete = React21.forwardRef(function Autocomplete2({ options, value, defaultValue = "", onChange, onSelect, emptyText = "\u6C92\u6709\u7B26\u5408\u7684\u7D50\u679C", size = "md", className, wrapperClassName, onFocus, onBlur, onKeyDown, ...rest }, ref) {
|
|
1267
|
+
const id = useId2("combo");
|
|
1268
|
+
const [text2, setText] = useControllable(value, defaultValue, onChange);
|
|
1269
|
+
const [open, setOpen] = React21.useState(false);
|
|
1270
|
+
const [active, setActive] = React21.useState(-1);
|
|
1271
|
+
const listRef = React21.useRef(null);
|
|
1272
|
+
const q = text2.trim();
|
|
1273
|
+
const items = options.map(norm).filter((o) => !q || o.label.toLowerCase().includes(q.toLowerCase()));
|
|
1274
|
+
React21.useEffect(() => {
|
|
1275
|
+
var _a;
|
|
1276
|
+
if (active < 0 || !listRef.current) return;
|
|
1277
|
+
const el = listRef.current.children[active];
|
|
1278
|
+
(_a = el == null ? void 0 : el.scrollIntoView) == null ? void 0 : _a.call(el, { block: "nearest" });
|
|
1279
|
+
}, [active]);
|
|
1280
|
+
const pick = (o) => {
|
|
1281
|
+
setText(o.label);
|
|
1282
|
+
setOpen(false);
|
|
1283
|
+
setActive(-1);
|
|
1284
|
+
onSelect == null ? void 0 : onSelect(o.value);
|
|
1285
|
+
};
|
|
1286
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: cx("a-combo", open && "is-open", wrapperClassName), children: [
|
|
1287
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
1288
|
+
"input",
|
|
1289
|
+
{
|
|
1290
|
+
ref,
|
|
1291
|
+
className: cx("a-input", size !== "md" && "a-input--" + size, className),
|
|
1292
|
+
role: "combobox",
|
|
1293
|
+
"aria-autocomplete": "list",
|
|
1294
|
+
"aria-expanded": open,
|
|
1295
|
+
"aria-controls": id,
|
|
1296
|
+
"aria-activedescendant": active >= 0 && items[active] ? id + "-" + active : void 0,
|
|
1297
|
+
autoComplete: "off",
|
|
1298
|
+
value: text2,
|
|
1299
|
+
onChange: (e) => {
|
|
1300
|
+
setText(e.target.value);
|
|
1301
|
+
setOpen(true);
|
|
1302
|
+
setActive(-1);
|
|
1303
|
+
},
|
|
1304
|
+
onFocus: (e) => {
|
|
1305
|
+
setOpen(true);
|
|
1306
|
+
onFocus == null ? void 0 : onFocus(e);
|
|
1307
|
+
},
|
|
1308
|
+
onBlur: (e) => {
|
|
1309
|
+
setOpen(false);
|
|
1310
|
+
setActive(-1);
|
|
1311
|
+
onBlur == null ? void 0 : onBlur(e);
|
|
1312
|
+
},
|
|
1313
|
+
onKeyDown: (e) => {
|
|
1314
|
+
onKeyDown == null ? void 0 : onKeyDown(e);
|
|
1315
|
+
if (e.key === "ArrowDown") {
|
|
1316
|
+
e.preventDefault();
|
|
1317
|
+
setOpen(true);
|
|
1318
|
+
setActive((a) => Math.min(items.length - 1, a + 1));
|
|
1319
|
+
} else if (e.key === "ArrowUp") {
|
|
1320
|
+
e.preventDefault();
|
|
1321
|
+
setActive((a) => Math.max(0, a - 1));
|
|
1322
|
+
} else if (e.key === "Enter" && open && items[active]) {
|
|
1323
|
+
e.preventDefault();
|
|
1324
|
+
pick(items[active]);
|
|
1325
|
+
} else if (e.key === "Escape") {
|
|
1326
|
+
setOpen(false);
|
|
1327
|
+
setActive(-1);
|
|
1328
|
+
}
|
|
1329
|
+
},
|
|
1330
|
+
...rest
|
|
1331
|
+
}
|
|
1332
|
+
),
|
|
1333
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("ul", { className: "a-combo__list", role: "listbox", id, ref: listRef, children: [
|
|
1334
|
+
items.map((o, i) => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
1335
|
+
"li",
|
|
1336
|
+
{
|
|
1337
|
+
id: id + "-" + i,
|
|
1338
|
+
role: "option",
|
|
1339
|
+
"aria-selected": i === active,
|
|
1340
|
+
onMouseDown: (e) => {
|
|
1341
|
+
e.preventDefault();
|
|
1342
|
+
pick(o);
|
|
1343
|
+
},
|
|
1344
|
+
onMouseEnter: () => setActive(i),
|
|
1345
|
+
children: highlight(o.label, q)
|
|
1346
|
+
},
|
|
1347
|
+
o.value
|
|
1348
|
+
)),
|
|
1349
|
+
items.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("li", { className: "a-combo__empty", children: emptyText })
|
|
1350
|
+
] })
|
|
1351
|
+
] });
|
|
1352
|
+
});
|
|
1353
|
+
|
|
1354
|
+
// src/components/InputNumber.tsx
|
|
1355
|
+
var React22 = __toESM(require("react"), 1);
|
|
1356
|
+
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
1357
|
+
var decimals = (n) => {
|
|
1358
|
+
const s = String(n);
|
|
1359
|
+
const i = s.indexOf(".");
|
|
1360
|
+
return i < 0 ? 0 : s.length - i - 1;
|
|
1361
|
+
};
|
|
1362
|
+
var InputNumber = React22.forwardRef(function InputNumber2({ value, defaultValue, onChange, min = -Infinity, max = Infinity, step = 1, size = "md", disabled, className, wrapperClassName, onBlur, ...rest }, ref) {
|
|
1363
|
+
const clamp = (n) => {
|
|
1364
|
+
const d = decimals(step);
|
|
1365
|
+
const v = Math.min(max, Math.max(min, n));
|
|
1366
|
+
return d ? Number(v.toFixed(d)) : v;
|
|
1367
|
+
};
|
|
1368
|
+
const [val, setVal] = useControllable(value, defaultValue != null ? defaultValue : Number.isFinite(min) ? min : 0, onChange);
|
|
1369
|
+
const [draft, setDraft] = React22.useState(null);
|
|
1370
|
+
const commit = (n) => {
|
|
1371
|
+
setDraft(null);
|
|
1372
|
+
const c = clamp(Number.isNaN(n) ? val : n);
|
|
1373
|
+
if (c !== val) setVal(c);
|
|
1374
|
+
};
|
|
1375
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: cx("a-number", size === "sm" && "a-number--sm", wrapperClassName), children: [
|
|
1376
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("button", { type: "button", "aria-label": "\u6E1B\u5C11", disabled: disabled || val <= min, onClick: () => commit(val - step), children: "\u2212" }),
|
|
1377
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
1378
|
+
"input",
|
|
1379
|
+
{
|
|
1380
|
+
ref,
|
|
1381
|
+
type: "number",
|
|
1382
|
+
className,
|
|
1383
|
+
inputMode: "decimal",
|
|
1384
|
+
min: Number.isFinite(min) ? min : void 0,
|
|
1385
|
+
max: Number.isFinite(max) ? max : void 0,
|
|
1386
|
+
step,
|
|
1387
|
+
disabled,
|
|
1388
|
+
value: draft != null ? draft : String(val),
|
|
1389
|
+
onChange: (e) => setDraft(e.target.value),
|
|
1390
|
+
onBlur: (e) => {
|
|
1391
|
+
if (draft !== null) commit(parseFloat(draft));
|
|
1392
|
+
onBlur == null ? void 0 : onBlur(e);
|
|
1393
|
+
},
|
|
1394
|
+
onKeyDown: (e) => {
|
|
1395
|
+
if (e.key === "Enter" && draft !== null) commit(parseFloat(draft));
|
|
1396
|
+
},
|
|
1397
|
+
...rest
|
|
1398
|
+
}
|
|
1399
|
+
),
|
|
1400
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("button", { type: "button", "aria-label": "\u589E\u52A0", disabled: disabled || val >= max, onClick: () => commit(val + step), children: "+" })
|
|
1401
|
+
] });
|
|
1402
|
+
});
|
|
1403
|
+
|
|
1404
|
+
// src/components/ColorPicker.tsx
|
|
1405
|
+
var React23 = __toESM(require("react"), 1);
|
|
1406
|
+
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
1407
|
+
var ColorPicker = React23.forwardRef(function ColorPicker2({ value, defaultValue = "#fc5454", onChange, showValue = true, className, style, ...rest }, ref) {
|
|
1408
|
+
const [hex, setHex] = useControllable(value, defaultValue, onChange);
|
|
1409
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("label", { className: cx("a-color", className), style, children: [
|
|
1410
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("input", { ref, type: "color", value: hex, onChange: (e) => setHex(e.target.value), ...rest }),
|
|
1411
|
+
showValue && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { className: "a-color__value", children: hex.toUpperCase() })
|
|
1412
|
+
] });
|
|
1413
|
+
});
|
|
1414
|
+
function ColorSwatches({ colors, value, defaultValue, onChange, name, className, ...rest }) {
|
|
1415
|
+
var _a, _b;
|
|
1416
|
+
const auto = useId2("sw");
|
|
1417
|
+
const list = colors.map((c) => {
|
|
1418
|
+
var _a2;
|
|
1419
|
+
return typeof c === "string" ? { value: c, label: c } : { value: c.value, label: (_a2 = c.label) != null ? _a2 : c.value };
|
|
1420
|
+
});
|
|
1421
|
+
const [val, setVal] = useControllable(value, (_b = defaultValue != null ? defaultValue : (_a = list[0]) == null ? void 0 : _a.value) != null ? _b : "", onChange);
|
|
1422
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("fieldset", { className: cx("a-swatches", className), ...rest, children: list.map((c) => /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("label", { children: [
|
|
1423
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("input", { type: "radio", name: name != null ? name : auto, value: c.value, "aria-label": c.label, checked: val === c.value, onChange: () => setVal(c.value) }),
|
|
1424
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { style: { "--c": c.value } })
|
|
1425
|
+
] }, c.value)) });
|
|
1426
|
+
}
|
|
1427
|
+
|
|
1428
|
+
// src/components/OtpInput.tsx
|
|
1429
|
+
var React24 = __toESM(require("react"), 1);
|
|
1430
|
+
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
1431
|
+
function OtpInput({
|
|
1432
|
+
length = 6,
|
|
1433
|
+
groupSize = 0,
|
|
1434
|
+
value,
|
|
1435
|
+
defaultValue = "",
|
|
1436
|
+
onChange,
|
|
1437
|
+
onComplete,
|
|
1438
|
+
error,
|
|
1439
|
+
success,
|
|
1440
|
+
disabled,
|
|
1441
|
+
autoFocus,
|
|
1442
|
+
className,
|
|
1443
|
+
...rest
|
|
1444
|
+
}) {
|
|
1445
|
+
const [code, setCode] = useControllable(value, defaultValue, onChange);
|
|
1446
|
+
const refs = React24.useRef([]);
|
|
1447
|
+
const boxRef = React24.useRef(null);
|
|
1448
|
+
const chars = Array.from({ length }, (_, i) => {
|
|
1449
|
+
var _a;
|
|
1450
|
+
return (_a = code[i]) != null ? _a : "";
|
|
1451
|
+
});
|
|
1452
|
+
React24.useEffect(() => {
|
|
1453
|
+
const el = boxRef.current;
|
|
1454
|
+
if (!el || !error) return;
|
|
1455
|
+
el.classList.remove("is-error");
|
|
1456
|
+
void el.offsetWidth;
|
|
1457
|
+
el.classList.add("is-error");
|
|
1458
|
+
}, [error]);
|
|
1459
|
+
const focusAt = (i) => {
|
|
1460
|
+
const el = refs.current[Math.max(0, Math.min(length - 1, i))];
|
|
1461
|
+
el == null ? void 0 : el.focus();
|
|
1462
|
+
el == null ? void 0 : el.select();
|
|
1463
|
+
};
|
|
1464
|
+
const update = (next) => {
|
|
1465
|
+
const s = next.join("").slice(0, length);
|
|
1466
|
+
setCode(s);
|
|
1467
|
+
if (s.length === length && !next.slice(0, length).includes("")) onComplete == null ? void 0 : onComplete(s);
|
|
1468
|
+
};
|
|
1469
|
+
const fill = (start, digits) => {
|
|
1470
|
+
const next = [...chars];
|
|
1471
|
+
let i = start;
|
|
1472
|
+
for (const d of digits) {
|
|
1473
|
+
if (i >= length) break;
|
|
1474
|
+
next[i++] = d;
|
|
1475
|
+
}
|
|
1476
|
+
update(next);
|
|
1477
|
+
focusAt(i);
|
|
1478
|
+
};
|
|
1479
|
+
const inputs = [];
|
|
1480
|
+
chars.forEach((ch, i) => {
|
|
1481
|
+
if (groupSize > 0 && i > 0 && i % groupSize === 0) inputs.push(/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { className: "a-otp__sep", "aria-hidden": "true" }, "sep" + i));
|
|
1482
|
+
inputs.push(
|
|
1483
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
1484
|
+
"input",
|
|
1485
|
+
{
|
|
1486
|
+
ref: (el) => {
|
|
1487
|
+
refs.current[i] = el;
|
|
1488
|
+
},
|
|
1489
|
+
inputMode: "numeric",
|
|
1490
|
+
maxLength: 1,
|
|
1491
|
+
placeholder: " ",
|
|
1492
|
+
autoComplete: i === 0 ? "one-time-code" : "off",
|
|
1493
|
+
"aria-label": "\u7B2C " + (i + 1) + " \u4F4D",
|
|
1494
|
+
autoFocus: autoFocus && i === 0,
|
|
1495
|
+
disabled,
|
|
1496
|
+
value: ch,
|
|
1497
|
+
onFocus: (e) => e.target.select(),
|
|
1498
|
+
onChange: (e) => {
|
|
1499
|
+
const d = e.target.value.replace(/\D/g, "");
|
|
1500
|
+
if (!d) {
|
|
1501
|
+
const next = [...chars];
|
|
1502
|
+
next[i] = "";
|
|
1503
|
+
update(next);
|
|
1504
|
+
return;
|
|
1505
|
+
}
|
|
1506
|
+
fill(i, d);
|
|
1507
|
+
},
|
|
1508
|
+
onKeyDown: (e) => {
|
|
1509
|
+
if (e.key === "Backspace" && !chars[i] && i > 0) {
|
|
1510
|
+
e.preventDefault();
|
|
1511
|
+
const next = [...chars];
|
|
1512
|
+
next[i - 1] = "";
|
|
1513
|
+
update(next);
|
|
1514
|
+
focusAt(i - 1);
|
|
1515
|
+
} else if (e.key === "ArrowLeft") {
|
|
1516
|
+
e.preventDefault();
|
|
1517
|
+
focusAt(i - 1);
|
|
1518
|
+
} else if (e.key === "ArrowRight") {
|
|
1519
|
+
e.preventDefault();
|
|
1520
|
+
focusAt(i + 1);
|
|
1521
|
+
}
|
|
1522
|
+
},
|
|
1523
|
+
onPaste: (e) => {
|
|
1524
|
+
const d = e.clipboardData.getData("text").replace(/\D/g, "");
|
|
1525
|
+
if (!d) return;
|
|
1526
|
+
e.preventDefault();
|
|
1527
|
+
fill(i, d);
|
|
1528
|
+
}
|
|
1529
|
+
},
|
|
1530
|
+
i
|
|
1531
|
+
)
|
|
1532
|
+
);
|
|
1533
|
+
});
|
|
1534
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { ref: boxRef, role: "group", className: cx("a-otp", error && "is-error", success && "is-success", className), ...rest, children: inputs });
|
|
1535
|
+
}
|
|
1536
|
+
|
|
1537
|
+
// src/components/Cascader.tsx
|
|
1538
|
+
var React25 = __toESM(require("react"), 1);
|
|
1539
|
+
var import_jsx_runtime28 = require("react/jsx-runtime");
|
|
1540
|
+
var labelOf = (o) => {
|
|
1541
|
+
var _a;
|
|
1542
|
+
return (_a = o.label) != null ? _a : o.value;
|
|
1543
|
+
};
|
|
1544
|
+
function resolve(options, path) {
|
|
1545
|
+
const out = [];
|
|
1546
|
+
let level = options;
|
|
1547
|
+
for (const v of path) {
|
|
1548
|
+
const hit = level == null ? void 0 : level.find((o) => o.value === v);
|
|
1549
|
+
if (!hit) break;
|
|
1550
|
+
out.push(hit);
|
|
1551
|
+
level = hit.children;
|
|
1552
|
+
}
|
|
1553
|
+
return out;
|
|
1554
|
+
}
|
|
1555
|
+
function Cascader({ options, value, defaultValue = [], onChange, placeholder = "\u8ACB\u9078\u64C7", disabled, separator = " / ", className, ...rest }) {
|
|
1556
|
+
const id = useId2("cas");
|
|
1557
|
+
const [path, setPath] = useControllable(value, defaultValue);
|
|
1558
|
+
const [open, setOpen] = React25.useState(false);
|
|
1559
|
+
const [active, setActive] = React25.useState(path);
|
|
1560
|
+
const rootRef = React25.useRef(null);
|
|
1561
|
+
const triggerRef = React25.useRef(null);
|
|
1562
|
+
React25.useEffect(() => {
|
|
1563
|
+
if (!open) return;
|
|
1564
|
+
const onDoc = (e) => {
|
|
1565
|
+
const t = e.target;
|
|
1566
|
+
if (!t.isConnected) return;
|
|
1567
|
+
if (rootRef.current && !rootRef.current.contains(t)) setOpen(false);
|
|
1568
|
+
};
|
|
1569
|
+
const onKey = (e) => {
|
|
1570
|
+
var _a;
|
|
1571
|
+
if (e.key === "Escape") {
|
|
1572
|
+
setOpen(false);
|
|
1573
|
+
(_a = triggerRef.current) == null ? void 0 : _a.focus();
|
|
1574
|
+
}
|
|
1575
|
+
};
|
|
1576
|
+
document.addEventListener("mousedown", onDoc);
|
|
1577
|
+
document.addEventListener("keydown", onKey);
|
|
1578
|
+
return () => {
|
|
1579
|
+
document.removeEventListener("mousedown", onDoc);
|
|
1580
|
+
document.removeEventListener("keydown", onKey);
|
|
1581
|
+
};
|
|
1582
|
+
}, [open]);
|
|
1583
|
+
const chosen = resolve(options, path);
|
|
1584
|
+
const text2 = chosen.length ? chosen.map(labelOf).join(separator) : placeholder;
|
|
1585
|
+
const activeOpts = resolve(options, active);
|
|
1586
|
+
const cols = [options];
|
|
1587
|
+
activeOpts.forEach((o) => {
|
|
1588
|
+
var _a;
|
|
1589
|
+
if ((_a = o.children) == null ? void 0 : _a.length) cols.push(o.children);
|
|
1590
|
+
});
|
|
1591
|
+
const choose = (depth, o) => {
|
|
1592
|
+
var _a, _b;
|
|
1593
|
+
const next = [...active.slice(0, depth), o.value];
|
|
1594
|
+
setActive(next);
|
|
1595
|
+
if (!((_a = o.children) == null ? void 0 : _a.length)) {
|
|
1596
|
+
const opts = resolve(options, next);
|
|
1597
|
+
setPath(next);
|
|
1598
|
+
onChange == null ? void 0 : onChange(next, opts.map(labelOf));
|
|
1599
|
+
setOpen(false);
|
|
1600
|
+
(_b = triggerRef.current) == null ? void 0 : _b.focus();
|
|
1601
|
+
}
|
|
1602
|
+
};
|
|
1603
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { ref: rootRef, className: cx("a-cascader", open && "is-open", className), ...rest, children: [
|
|
1604
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
1605
|
+
"button",
|
|
1606
|
+
{
|
|
1607
|
+
ref: triggerRef,
|
|
1608
|
+
type: "button",
|
|
1609
|
+
className: cx("a-input", "a-select", "a-cascader__trigger", !chosen.length && "is-empty"),
|
|
1610
|
+
"aria-haspopup": "listbox",
|
|
1611
|
+
"aria-expanded": open,
|
|
1612
|
+
"aria-controls": id,
|
|
1613
|
+
disabled,
|
|
1614
|
+
onClick: () => {
|
|
1615
|
+
setActive(path);
|
|
1616
|
+
setOpen((o) => !o);
|
|
1617
|
+
},
|
|
1618
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { children: text2 })
|
|
1619
|
+
}
|
|
1620
|
+
),
|
|
1621
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: "a-cascader__panel", id, "aria-hidden": !open || void 0, onClick: (e) => e.preventDefault(), children: cols.map((col, depth) => /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("ul", { className: "a-cascader__col", role: "listbox", children: col.map((o) => {
|
|
1622
|
+
var _a;
|
|
1623
|
+
const parent = !!((_a = o.children) == null ? void 0 : _a.length);
|
|
1624
|
+
const on = active[depth] === o.value;
|
|
1625
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
1626
|
+
"button",
|
|
1627
|
+
{
|
|
1628
|
+
type: "button",
|
|
1629
|
+
className: parent ? "has-children" : void 0,
|
|
1630
|
+
disabled: o.disabled,
|
|
1631
|
+
"aria-expanded": parent ? on : void 0,
|
|
1632
|
+
"aria-selected": !parent ? on : void 0,
|
|
1633
|
+
onClick: () => choose(depth, o),
|
|
1634
|
+
children: labelOf(o)
|
|
1635
|
+
}
|
|
1636
|
+
) }, o.value);
|
|
1637
|
+
}) }, depth)) })
|
|
1638
|
+
] });
|
|
1639
|
+
}
|
|
1640
|
+
|
|
1641
|
+
// src/components/Transfer.tsx
|
|
1642
|
+
var React26 = __toESM(require("react"), 1);
|
|
1643
|
+
var import_jsx_runtime29 = require("react/jsx-runtime");
|
|
1644
|
+
var norm2 = (o) => {
|
|
1645
|
+
var _a;
|
|
1646
|
+
return typeof o === "string" ? { value: o, label: o, disabled: false } : { value: o.value, label: (_a = o.label) != null ? _a : o.value, disabled: !!o.disabled };
|
|
1647
|
+
};
|
|
1648
|
+
function TransferList({ title, list, checked, fresh, setChecked }) {
|
|
1649
|
+
const pick = list.filter((o) => !o.disabled).map((o) => o.value);
|
|
1650
|
+
const on = checked.filter((v) => pick.includes(v));
|
|
1651
|
+
const all = pick.length > 0 && on.length === pick.length;
|
|
1652
|
+
const some = on.length > 0 && !all;
|
|
1653
|
+
const allRef = React26.useRef(null);
|
|
1654
|
+
React26.useEffect(() => {
|
|
1655
|
+
if (allRef.current) allRef.current.indeterminate = some;
|
|
1656
|
+
}, [some]);
|
|
1657
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "a-transfer__list", children: [
|
|
1658
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "a-transfer__head", children: [
|
|
1659
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("label", { className: "a-check", children: [
|
|
1660
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
1661
|
+
"input",
|
|
1662
|
+
{
|
|
1663
|
+
ref: allRef,
|
|
1664
|
+
type: "checkbox",
|
|
1665
|
+
checked: all,
|
|
1666
|
+
disabled: !pick.length,
|
|
1667
|
+
"aria-label": "\u5168\u9078",
|
|
1668
|
+
onChange: (e) => setChecked(e.target.checked ? pick : [])
|
|
1669
|
+
}
|
|
1670
|
+
),
|
|
1671
|
+
title
|
|
1672
|
+
] }),
|
|
1673
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("small", { children: on.length ? on.length + " / " + list.length : list.length })
|
|
1674
|
+
] }),
|
|
1675
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: "a-transfer__body", children: list.map((o) => /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("label", { className: cx("a-check", fresh.includes(o.value) && "is-new"), children: [
|
|
1676
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
1677
|
+
"input",
|
|
1678
|
+
{
|
|
1679
|
+
type: "checkbox",
|
|
1680
|
+
checked: checked.includes(o.value),
|
|
1681
|
+
disabled: o.disabled,
|
|
1682
|
+
onChange: (e) => setChecked(e.target.checked ? [...checked, o.value] : checked.filter((v) => v !== o.value))
|
|
1683
|
+
}
|
|
1684
|
+
),
|
|
1685
|
+
o.label
|
|
1686
|
+
] }, o.value)) })
|
|
1687
|
+
] });
|
|
1688
|
+
}
|
|
1689
|
+
function Transfer({ items, value, defaultValue = [], onChange, titles = ["\u53EF\u9078", "\u5DF2\u9078"], className, ...rest }) {
|
|
1690
|
+
const [right, setRight] = useControllable(value, defaultValue, onChange);
|
|
1691
|
+
const [checkL, setCheckL] = React26.useState([]);
|
|
1692
|
+
const [checkR, setCheckR] = React26.useState([]);
|
|
1693
|
+
const [fresh, setFresh] = React26.useState([]);
|
|
1694
|
+
const all = items.map(norm2);
|
|
1695
|
+
const leftList = all.filter((o) => !right.includes(o.value));
|
|
1696
|
+
const rightList = all.filter((o) => right.includes(o.value));
|
|
1697
|
+
const toRight = checkL.filter((v) => leftList.some((o) => o.value === v));
|
|
1698
|
+
const toLeft = checkR.filter((v) => rightList.some((o) => o.value === v));
|
|
1699
|
+
React26.useEffect(() => {
|
|
1700
|
+
if (!fresh.length) return;
|
|
1701
|
+
const t = setTimeout(() => setFresh([]), 900);
|
|
1702
|
+
return () => clearTimeout(t);
|
|
1703
|
+
}, [fresh]);
|
|
1704
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: cx("a-transfer", className), ...rest, children: [
|
|
1705
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(TransferList, { title: titles[0], list: leftList, checked: checkL, fresh, setChecked: setCheckL }),
|
|
1706
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "a-transfer__ops", children: [
|
|
1707
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
1708
|
+
"button",
|
|
1709
|
+
{
|
|
1710
|
+
type: "button",
|
|
1711
|
+
className: "a-btn a-btn--outline a-btn--sm a-btn--icon",
|
|
1712
|
+
"aria-label": "\u79FB\u5230\u53F3\u908A",
|
|
1713
|
+
disabled: !toRight.length,
|
|
1714
|
+
onClick: () => {
|
|
1715
|
+
setRight([...right, ...toRight]);
|
|
1716
|
+
setFresh(toRight);
|
|
1717
|
+
setCheckL([]);
|
|
1718
|
+
},
|
|
1719
|
+
children: "\u203A"
|
|
1720
|
+
}
|
|
1721
|
+
),
|
|
1722
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
1723
|
+
"button",
|
|
1724
|
+
{
|
|
1725
|
+
type: "button",
|
|
1726
|
+
className: "a-btn a-btn--outline a-btn--sm a-btn--icon",
|
|
1727
|
+
"aria-label": "\u79FB\u5230\u5DE6\u908A",
|
|
1728
|
+
disabled: !toLeft.length,
|
|
1729
|
+
onClick: () => {
|
|
1730
|
+
setRight(right.filter((v) => !toLeft.includes(v)));
|
|
1731
|
+
setFresh(toLeft);
|
|
1732
|
+
setCheckR([]);
|
|
1733
|
+
},
|
|
1734
|
+
children: "\u2039"
|
|
1735
|
+
}
|
|
1736
|
+
)
|
|
1737
|
+
] }),
|
|
1738
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(TransferList, { title: titles[1], list: rightList, checked: checkR, fresh, setChecked: setCheckR })
|
|
1739
|
+
] });
|
|
1740
|
+
}
|
|
1741
|
+
|
|
1742
|
+
// src/components/TagInput.tsx
|
|
1743
|
+
var React27 = __toESM(require("react"), 1);
|
|
1744
|
+
var import_jsx_runtime30 = require("react/jsx-runtime");
|
|
1745
|
+
function TagInput({ value, defaultValue = [], onChange, max, placeholder = "\u8F38\u5165\u5F8C\u6309 Enter", disabled, inputLabel = "\u65B0\u589E\u6A19\u7C64", className, ...rest }) {
|
|
1746
|
+
const [tags, setTags] = useControllable(value, defaultValue, onChange);
|
|
1747
|
+
const [text2, setText] = React27.useState("");
|
|
1748
|
+
const [fresh, setFresh] = React27.useState(null);
|
|
1749
|
+
const [dup, setDup] = React27.useState(null);
|
|
1750
|
+
const inputRef = React27.useRef(null);
|
|
1751
|
+
const full = max != null && tags.length >= max;
|
|
1752
|
+
React27.useEffect(() => {
|
|
1753
|
+
if (!dup) return;
|
|
1754
|
+
const t = setTimeout(() => setDup(null), 450);
|
|
1755
|
+
return () => clearTimeout(t);
|
|
1756
|
+
}, [dup]);
|
|
1757
|
+
const add = (raw) => {
|
|
1758
|
+
const next = [...tags];
|
|
1759
|
+
let last = null;
|
|
1760
|
+
for (const r of raw) {
|
|
1761
|
+
const t = r.trim();
|
|
1762
|
+
if (!t) continue;
|
|
1763
|
+
if (next.includes(t)) {
|
|
1764
|
+
setDup((d) => {
|
|
1765
|
+
var _a;
|
|
1766
|
+
return { tag: t, n: ((_a = d == null ? void 0 : d.n) != null ? _a : 0) + 1 };
|
|
1767
|
+
});
|
|
1768
|
+
continue;
|
|
1769
|
+
}
|
|
1770
|
+
if (max != null && next.length >= max) break;
|
|
1771
|
+
next.push(t);
|
|
1772
|
+
last = t;
|
|
1773
|
+
}
|
|
1774
|
+
if (next.length !== tags.length) {
|
|
1775
|
+
setTags(next);
|
|
1776
|
+
setFresh(last);
|
|
1777
|
+
}
|
|
1778
|
+
};
|
|
1779
|
+
return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { className: cx("a-taginput", className), "data-max": max, onClick: () => {
|
|
1780
|
+
var _a;
|
|
1781
|
+
return (_a = inputRef.current) == null ? void 0 : _a.focus();
|
|
1782
|
+
}, ...rest, children: [
|
|
1783
|
+
tags.map((t) => /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("span", { className: cx("a-tag", fresh === t && "is-new", (dup == null ? void 0 : dup.tag) === t && "is-dup"), children: [
|
|
1784
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)("span", { children: t }),
|
|
1785
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
1786
|
+
"button",
|
|
1787
|
+
{
|
|
1788
|
+
type: "button",
|
|
1789
|
+
className: "a-tag__close",
|
|
1790
|
+
"aria-label": "\u79FB\u9664" + t,
|
|
1791
|
+
disabled,
|
|
1792
|
+
onClick: (e) => {
|
|
1793
|
+
e.stopPropagation();
|
|
1794
|
+
setTags(tags.filter((x) => x !== t));
|
|
1795
|
+
},
|
|
1796
|
+
children: "\xD7"
|
|
1797
|
+
}
|
|
1798
|
+
)
|
|
1799
|
+
] }, (dup == null ? void 0 : dup.tag) === t ? t + "-dup" + dup.n : t)),
|
|
1800
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
1801
|
+
"input",
|
|
1802
|
+
{
|
|
1803
|
+
ref: inputRef,
|
|
1804
|
+
value: text2,
|
|
1805
|
+
placeholder: full ? "" : placeholder,
|
|
1806
|
+
"aria-label": inputLabel,
|
|
1807
|
+
disabled: disabled || full,
|
|
1808
|
+
onChange: (e) => {
|
|
1809
|
+
const v = e.target.value;
|
|
1810
|
+
if (/[,,]/.test(v)) {
|
|
1811
|
+
add(v.split(/[,,]/));
|
|
1812
|
+
setText("");
|
|
1813
|
+
} else setText(v);
|
|
1814
|
+
},
|
|
1815
|
+
onKeyDown: (e) => {
|
|
1816
|
+
if (e.nativeEvent.isComposing) return;
|
|
1817
|
+
if (e.key === "Enter") {
|
|
1818
|
+
e.preventDefault();
|
|
1819
|
+
add([text2]);
|
|
1820
|
+
setText("");
|
|
1821
|
+
} else if (e.key === "Backspace" && !text2 && tags.length) setTags(tags.slice(0, -1));
|
|
1822
|
+
},
|
|
1823
|
+
onPaste: (e) => {
|
|
1824
|
+
const p = e.clipboardData.getData("text");
|
|
1825
|
+
if (!/[,,\n]/.test(p)) return;
|
|
1826
|
+
e.preventDefault();
|
|
1827
|
+
add((text2 + p).split(/[,,\n]/));
|
|
1828
|
+
setText("");
|
|
1829
|
+
},
|
|
1830
|
+
onBlur: () => {
|
|
1831
|
+
if (text2.trim()) {
|
|
1832
|
+
add([text2]);
|
|
1833
|
+
setText("");
|
|
1834
|
+
}
|
|
1835
|
+
}
|
|
1836
|
+
}
|
|
1837
|
+
)
|
|
1838
|
+
] });
|
|
1839
|
+
}
|
|
1840
|
+
|
|
1841
|
+
// src/components/Card.tsx
|
|
1842
|
+
var import_react = require("react");
|
|
1843
|
+
var import_jsx_runtime31 = require("react/jsx-runtime");
|
|
1844
|
+
var CardMedia = ({ className, ...rest }) => /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { className: cx("a-card__media", className), ...rest });
|
|
1845
|
+
var CardBody = ({ className, ...rest }) => /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { className: cx("a-card__body", className), ...rest });
|
|
1846
|
+
var CardFooter = ({ className, ...rest }) => /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { className: cx("a-card__footer", className), ...rest });
|
|
1847
|
+
var CardRoot = (0, import_react.forwardRef)(function Card({ cover, coverAlt = "", eyebrow, title, footer, interactive, outline, horizontal, href, className, children, ...rest }, ref) {
|
|
1848
|
+
const Comp = href ? "a" : "article";
|
|
1849
|
+
const hasBody = eyebrow != null || title != null || children != null;
|
|
1850
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(
|
|
1851
|
+
Comp,
|
|
1852
|
+
{
|
|
1853
|
+
ref,
|
|
1854
|
+
href,
|
|
1855
|
+
className: cx("a-card", (interactive || href) && "a-card--interactive", outline && "a-card--outline", horizontal && "a-card--horizontal", className),
|
|
1856
|
+
...rest,
|
|
1857
|
+
children: [
|
|
1858
|
+
cover != null && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(CardMedia, { children: typeof cover === "string" ? /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("img", { src: cover, alt: coverAlt }) : cover }),
|
|
1859
|
+
hasBody && /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(CardBody, { children: [
|
|
1860
|
+
eyebrow != null && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("span", { className: "a-card__eyebrow", children: eyebrow }),
|
|
1861
|
+
title != null && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("h3", { className: "a-card__title", children: title }),
|
|
1862
|
+
typeof children === "string" ? /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("p", { className: "a-card__text", children }) : children
|
|
1863
|
+
] }),
|
|
1864
|
+
footer != null && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(CardFooter, { children: footer })
|
|
1865
|
+
]
|
|
1866
|
+
}
|
|
1867
|
+
);
|
|
1868
|
+
});
|
|
1869
|
+
var Card2 = Object.assign(CardRoot, { Media: CardMedia, Body: CardBody, Footer: CardFooter });
|
|
1870
|
+
|
|
1871
|
+
// src/components/Tag.tsx
|
|
1872
|
+
var import_react2 = require("react");
|
|
1873
|
+
var import_jsx_runtime32 = require("react/jsx-runtime");
|
|
1874
|
+
var Tag = (0, import_react2.forwardRef)(function Tag2({ color = "default", dot, closable, onClose, closeLabel, className, children, ...rest }, ref) {
|
|
1875
|
+
const reduce = useReducedMotion();
|
|
1876
|
+
const [removing, setRemoving] = (0, import_react2.useState)(false);
|
|
1877
|
+
const [gone, setGone] = (0, import_react2.useState)(false);
|
|
1878
|
+
if (gone) return null;
|
|
1879
|
+
const close = () => {
|
|
1880
|
+
if (removing) return;
|
|
1881
|
+
setRemoving(true);
|
|
1882
|
+
setTimeout(() => {
|
|
1883
|
+
setGone(true);
|
|
1884
|
+
onClose == null ? void 0 : onClose();
|
|
1885
|
+
}, reduce ? 0 : 160);
|
|
1886
|
+
};
|
|
1887
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("span", { ref, className: cx("a-tag", color !== "default" && `a-tag--${color}`, dot && "a-tag--dot", removing && "is-removing", className), ...rest, children: [
|
|
1888
|
+
children,
|
|
1889
|
+
closable && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("button", { type: "button", className: "a-tag__close", "aria-label": closeLabel != null ? closeLabel : typeof children === "string" ? `\u79FB\u9664${children}` : "\u79FB\u9664", onClick: close, children: "\xD7" })
|
|
1890
|
+
] });
|
|
1891
|
+
});
|
|
1892
|
+
|
|
1893
|
+
// src/components/Badge.tsx
|
|
1894
|
+
var import_react3 = require("react");
|
|
1895
|
+
var import_jsx_runtime33 = require("react/jsx-runtime");
|
|
1896
|
+
var Badge = (0, import_react3.forwardRef)(function Badge2({ count, max = 99, dot, inline, color = "coral", showZero, className, children, ...rest }, ref) {
|
|
1897
|
+
const text2 = typeof count === "number" ? count > max ? `${max}+` : String(count) : count;
|
|
1898
|
+
const hidden = !dot && (count == null || count === 0 && !showZero);
|
|
1899
|
+
const countCls = cx("a-badge__count", color === "navy" && "a-badge__count--navy");
|
|
1900
|
+
if (inline) {
|
|
1901
|
+
return hidden ? null : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("span", { ref, className: cx(countCls, "a-badge__count--inline", className), ...rest, children: text2 });
|
|
1902
|
+
}
|
|
1903
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("span", { ref, className: cx("a-badge", dot && "a-badge--dot", className), ...rest, children: [
|
|
1904
|
+
children,
|
|
1905
|
+
!hidden && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("span", { className: countCls, children: dot ? null : text2 })
|
|
1906
|
+
] });
|
|
1907
|
+
});
|
|
1908
|
+
|
|
1909
|
+
// src/components/Avatar.tsx
|
|
1910
|
+
var import_react4 = require("react");
|
|
1911
|
+
var import_jsx_runtime34 = require("react/jsx-runtime");
|
|
1912
|
+
var Avatar = (0, import_react4.forwardRef)(function Avatar2({ src, alt = "", name, size = "md", shape = "circle", color = "sky", className, style, children, ...rest }, ref) {
|
|
1913
|
+
const [broken, setBroken] = (0, import_react4.useState)(false);
|
|
1914
|
+
const initial = name ? Array.from(name.trim())[0] : null;
|
|
1915
|
+
const s = typeof size === "number" ? { ...style, ["--s"]: `${size}px` } : style;
|
|
1916
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
1917
|
+
"span",
|
|
1918
|
+
{
|
|
1919
|
+
ref,
|
|
1920
|
+
role: src && !broken ? void 0 : "img",
|
|
1921
|
+
"aria-label": src && !broken ? void 0 : (name != null ? name : alt) || void 0,
|
|
1922
|
+
className: cx("a-avatar", typeof size === "string" && size !== "md" && `a-avatar--${size}`, shape === "square" && "a-avatar--square", color !== "sky" && `a-avatar--${color}`, className),
|
|
1923
|
+
style: s,
|
|
1924
|
+
...rest,
|
|
1925
|
+
children: src && !broken ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("img", { src, alt: alt || name || "", onError: () => setBroken(true) }) : children != null ? children : initial
|
|
1926
|
+
}
|
|
1927
|
+
);
|
|
1928
|
+
});
|
|
1929
|
+
var AvatarGroup = (0, import_react4.forwardRef)(function AvatarGroup2({ max, size, className, children, ...rest }, ref) {
|
|
1930
|
+
const items = import_react4.Children.toArray(children);
|
|
1931
|
+
const shown = max != null && items.length > max ? items.slice(0, max) : items;
|
|
1932
|
+
const extra = items.length - shown.length;
|
|
1933
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { ref, className: cx("a-avatar-group", className), ...rest, children: [
|
|
1934
|
+
shown,
|
|
1935
|
+
extra > 0 && /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(Avatar, { size, children: [
|
|
1936
|
+
"+",
|
|
1937
|
+
extra
|
|
1938
|
+
] })
|
|
1939
|
+
] });
|
|
1940
|
+
});
|
|
1941
|
+
|
|
1942
|
+
// src/components/Tooltip.tsx
|
|
1943
|
+
var import_react5 = require("react");
|
|
1944
|
+
var import_jsx_runtime35 = require("react/jsx-runtime");
|
|
1945
|
+
var VOID = /* @__PURE__ */ new Set(["input", "img", "textarea", "select", "br", "hr", "video", "iframe"]);
|
|
1946
|
+
function Tooltip({ title, placement = "top", children, wrap }) {
|
|
1947
|
+
const attrs = {
|
|
1948
|
+
"data-a-tip": title,
|
|
1949
|
+
"data-a-tip-pos": placement === "bottom" ? "bottom" : void 0,
|
|
1950
|
+
"aria-description": title
|
|
1951
|
+
};
|
|
1952
|
+
const el = children;
|
|
1953
|
+
const canClone = !wrap && (0, import_react5.isValidElement)(children) && typeof el.type === "string" && !VOID.has(el.type);
|
|
1954
|
+
if (canClone) return (0, import_react5.cloneElement)(el, attrs);
|
|
1955
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("span", { tabIndex: 0, style: { display: "inline-block" }, ...attrs, children });
|
|
1956
|
+
}
|
|
1957
|
+
|
|
1958
|
+
// src/components/Collapse.tsx
|
|
1959
|
+
var import_react6 = require("react");
|
|
1960
|
+
var import_jsx_runtime36 = require("react/jsx-runtime");
|
|
1961
|
+
var Collapse = (0, import_react6.forwardRef)(function Collapse2({ items, accordion, activeKeys, defaultActiveKeys = [], onChange, className, ...rest }, ref) {
|
|
1962
|
+
const [keys, setKeys] = useControllable(activeKeys, defaultActiveKeys, onChange);
|
|
1963
|
+
const toggle = (k) => {
|
|
1964
|
+
const open = keys.includes(k);
|
|
1965
|
+
setKeys(open ? keys.filter((x) => x !== k) : accordion ? [k] : [...keys, k]);
|
|
1966
|
+
};
|
|
1967
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { ref, className: cx("a-collapse", className), ...rest, children: items.map((it) => /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("details", { open: keys.includes(it.key), children: [
|
|
1968
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
1969
|
+
"summary",
|
|
1970
|
+
{
|
|
1971
|
+
"aria-disabled": it.disabled || void 0,
|
|
1972
|
+
onClick: (e) => {
|
|
1973
|
+
e.preventDefault();
|
|
1974
|
+
if (!it.disabled) toggle(it.key);
|
|
1975
|
+
},
|
|
1976
|
+
style: it.disabled ? { opacity: 0.45, cursor: "not-allowed" } : void 0,
|
|
1977
|
+
children: it.title
|
|
1978
|
+
}
|
|
1979
|
+
),
|
|
1980
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: "a-collapse__body", children: it.content })
|
|
1981
|
+
] }, it.key)) });
|
|
1982
|
+
});
|
|
1983
|
+
|
|
1984
|
+
// src/components/Table.tsx
|
|
1985
|
+
var import_react7 = require("react");
|
|
1986
|
+
var import_jsx_runtime37 = require("react/jsx-runtime");
|
|
1987
|
+
var getKey = (row, i, rowKey) => rowKey == null ? String(i) : typeof rowKey === "function" ? rowKey(row) : String(row[rowKey]);
|
|
1988
|
+
var rawValue = (row, c) => {
|
|
1989
|
+
var _a;
|
|
1990
|
+
return row[String((_a = c.dataIndex) != null ? _a : c.key)];
|
|
1991
|
+
};
|
|
1992
|
+
var cell = (row, c, i) => c.render ? c.render(row, i) : rawValue(row, c);
|
|
1993
|
+
var thStyle = (w) => w == null ? void 0 : { width: w };
|
|
1994
|
+
var SR_ONLY = { position: "absolute", width: 1, height: 1, padding: 0, margin: -1, overflow: "hidden", clip: "rect(0,0,0,0)", whiteSpace: "nowrap", border: 0 };
|
|
1995
|
+
var Caption = ({ children }) => children == null ? null : /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("caption", { style: SR_ONLY, children });
|
|
1996
|
+
function TableInner({ columns, dataSource, rowKey, striped, hover, compact, empty = "\u6C92\u6709\u8CC7\u6599", className, wrapClassName, caption, ...rest }, ref) {
|
|
1997
|
+
return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: cx("a-table-wrap", wrapClassName), children: /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("table", { ref, className: cx("a-table", striped && "a-table--striped", hover && "a-table--hover", compact && "a-table--compact", className), ...rest, children: [
|
|
1998
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Caption, { children: caption }),
|
|
1999
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("tr", { children: columns.map((c) => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("th", { className: c.align === "right" ? "is-num" : void 0, style: thStyle(c.width), children: c.title }, c.key)) }) }),
|
|
2000
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)("tbody", { children: dataSource.length ? dataSource.map((row, i) => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("tr", { children: columns.map((c) => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("td", { className: c.align === "right" ? "is-num" : void 0, children: cell(row, c, i) }, c.key)) }, getKey(row, i, rowKey))) : /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("tr", { className: "a-table__empty", children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("td", { colSpan: columns.length, children: empty }) }) })
|
|
2001
|
+
] }) });
|
|
2002
|
+
}
|
|
2003
|
+
var Table = (0, import_react7.forwardRef)(TableInner);
|
|
2004
|
+
var SEARCH_ICON = /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", children: [
|
|
2005
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)("circle", { cx: "11", cy: "11", r: "7" }),
|
|
2006
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)("path", { d: "m20 20-3.5-3.5" })
|
|
2007
|
+
] });
|
|
2008
|
+
function DataTableInner({
|
|
2009
|
+
columns,
|
|
2010
|
+
dataSource,
|
|
2011
|
+
rowKey,
|
|
2012
|
+
striped,
|
|
2013
|
+
hover = true,
|
|
2014
|
+
compact,
|
|
2015
|
+
empty,
|
|
2016
|
+
className,
|
|
2017
|
+
wrapClassName,
|
|
2018
|
+
caption,
|
|
2019
|
+
searchable,
|
|
2020
|
+
searchPlaceholder = "\u641C\u5C0B",
|
|
2021
|
+
filter,
|
|
2022
|
+
selectable,
|
|
2023
|
+
selectedKeys,
|
|
2024
|
+
defaultSelectedKeys = [],
|
|
2025
|
+
onSelectionChange,
|
|
2026
|
+
toolbarExtra,
|
|
2027
|
+
emptyText,
|
|
2028
|
+
rowLabel,
|
|
2029
|
+
...rest
|
|
2030
|
+
}, ref) {
|
|
2031
|
+
const reduce = useReducedMotion();
|
|
2032
|
+
const [sort, setSort] = (0, import_react7.useState)(null);
|
|
2033
|
+
const [query, setQuery] = (0, import_react7.useState)("");
|
|
2034
|
+
const [selected, setSelected] = useControllable(selectedKeys, defaultSelectedKeys, onSelectionChange);
|
|
2035
|
+
const rowRefs = (0, import_react7.useRef)(/* @__PURE__ */ new Map());
|
|
2036
|
+
const firstTops = (0, import_react7.useRef)(null);
|
|
2037
|
+
const allRef = (0, import_react7.useRef)(null);
|
|
2038
|
+
const valueOf = (row, c) => {
|
|
2039
|
+
if (c.sortValue) return c.sortValue(row);
|
|
2040
|
+
const v = rawValue(row, c);
|
|
2041
|
+
return typeof v === "number" ? v : String(v != null ? v : "");
|
|
2042
|
+
};
|
|
2043
|
+
const keyed = (0, import_react7.useMemo)(() => dataSource.map((row, i) => ({ row, key: getKey(row, i, rowKey) })), [dataSource, rowKey]);
|
|
2044
|
+
const visible = (0, import_react7.useMemo)(() => {
|
|
2045
|
+
const q = query.trim().toLowerCase();
|
|
2046
|
+
let list = !q ? keyed : keyed.filter(({ row }) => filter ? filter(row, q) : columns.some((c) => String(valueOf(row, c)).toLowerCase().includes(q)));
|
|
2047
|
+
if (sort) {
|
|
2048
|
+
const c = columns.find((x) => x.key === sort.key);
|
|
2049
|
+
if (c) {
|
|
2050
|
+
const num = c.sortable === "number";
|
|
2051
|
+
list = [...list].sort((a, b) => {
|
|
2052
|
+
const x = valueOf(a.row, c), y = valueOf(b.row, c);
|
|
2053
|
+
const r = num || typeof x === "number" && typeof y === "number" ? (parseFloat(String(x).replace(/[^\d.-]/g, "")) || 0) - (parseFloat(String(y).replace(/[^\d.-]/g, "")) || 0) : String(x).localeCompare(String(y), "zh-Hant");
|
|
2054
|
+
return sort.dir === "asc" ? r : -r;
|
|
2055
|
+
});
|
|
2056
|
+
}
|
|
2057
|
+
}
|
|
2058
|
+
return list;
|
|
2059
|
+
}, [keyed, query, sort, columns, filter]);
|
|
2060
|
+
const visibleKeys = visible.map((v) => v.key);
|
|
2061
|
+
const onCount = visibleKeys.filter((k) => selected.includes(k)).length;
|
|
2062
|
+
(0, import_react7.useEffect)(() => {
|
|
2063
|
+
if (allRef.current) allRef.current.indeterminate = onCount > 0 && onCount < visibleKeys.length;
|
|
2064
|
+
});
|
|
2065
|
+
(0, import_react7.useLayoutEffect)(() => {
|
|
2066
|
+
const first = firstTops.current;
|
|
2067
|
+
firstTops.current = null;
|
|
2068
|
+
if (!first || reduce) return;
|
|
2069
|
+
rowRefs.current.forEach((tr, k) => {
|
|
2070
|
+
const top = first.get(k);
|
|
2071
|
+
if (top == null) return;
|
|
2072
|
+
const dy = top - tr.getBoundingClientRect().top;
|
|
2073
|
+
if (dy && tr.animate) tr.animate([{ transform: `translateY(${dy}px)` }, { transform: "none" }], { duration: 280, easing: "cubic-bezier(0.22,1,0.36,1)" });
|
|
2074
|
+
});
|
|
2075
|
+
}, [sort, reduce]);
|
|
2076
|
+
const toggleSort = (key) => {
|
|
2077
|
+
const m = /* @__PURE__ */ new Map();
|
|
2078
|
+
rowRefs.current.forEach((tr, k) => m.set(k, tr.getBoundingClientRect().top));
|
|
2079
|
+
firstTops.current = m;
|
|
2080
|
+
setSort((s) => s && s.key === key && s.dir === "asc" ? { key, dir: "desc" } : { key, dir: "asc" });
|
|
2081
|
+
};
|
|
2082
|
+
const toggleRow = (k, on) => setSelected(on ? [...selected, k] : selected.filter((x) => x !== k));
|
|
2083
|
+
const toggleAll = (on) => setSelected(on ? Array.from(/* @__PURE__ */ new Set([...selected, ...visibleKeys])) : selected.filter((k) => !visibleKeys.includes(k)));
|
|
2084
|
+
const colSpan = columns.length + (selectable ? 1 : 0);
|
|
2085
|
+
const defaultRowLabel = (row, i) => {
|
|
2086
|
+
const c = columns[0];
|
|
2087
|
+
const v = c ? valueOf(row, c) : "";
|
|
2088
|
+
return String(v).trim() || `\u7B2C ${i + 1} \u5217`;
|
|
2089
|
+
};
|
|
2090
|
+
return /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { style: { width: "100%" }, children: [
|
|
2091
|
+
(searchable || selectable || toolbarExtra) && /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { className: "a-table-toolbar", children: [
|
|
2092
|
+
searchable ? /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("span", { className: "a-input-wrap", children: [
|
|
2093
|
+
SEARCH_ICON,
|
|
2094
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)("input", { className: "a-input a-input--sm", type: "search", value: query, placeholder: searchPlaceholder, "aria-label": searchPlaceholder, onChange: (e) => setQuery(e.target.value) })
|
|
2095
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("span", {}),
|
|
2096
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("span", { style: { display: "flex", alignItems: "center", gap: 12 }, children: [
|
|
2097
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)("span", { className: "a-table-toolbar__info", "aria-live": "polite", children: selected.length ? /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(import_jsx_runtime37.Fragment, { children: [
|
|
2098
|
+
"\u5DF2\u9078 ",
|
|
2099
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)("b", { children: selected.length }),
|
|
2100
|
+
" \u7B46"
|
|
2101
|
+
] }) : `\u5171 ${visible.length} \u7B46` }),
|
|
2102
|
+
toolbarExtra
|
|
2103
|
+
] })
|
|
2104
|
+
] }),
|
|
2105
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: cx("a-table-wrap", wrapClassName), children: /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("table", { ref, className: cx("a-table", striped && "a-table--striped", hover && "a-table--hover", compact && "a-table--compact", className), ...rest, children: [
|
|
2106
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Caption, { children: caption }),
|
|
2107
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("tr", { children: [
|
|
2108
|
+
selectable && /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("th", { className: "a-table__check", children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("label", { className: "a-check", children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("input", { ref: allRef, type: "checkbox", "aria-label": "\u5168\u9078", checked: visibleKeys.length > 0 && onCount === visibleKeys.length, onChange: (e) => toggleAll(e.target.checked) }) }) }),
|
|
2109
|
+
columns.map((c) => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|
|
2110
|
+
"th",
|
|
2111
|
+
{
|
|
2112
|
+
className: c.align === "right" ? "is-num" : void 0,
|
|
2113
|
+
style: thStyle(c.width),
|
|
2114
|
+
"aria-sort": c.sortable ? (sort == null ? void 0 : sort.key) === c.key ? sort.dir === "asc" ? "ascending" : "descending" : "none" : void 0,
|
|
2115
|
+
children: c.sortable ? /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("button", { type: "button", className: "a-th-sort", onClick: () => toggleSort(c.key), children: c.title }) : c.title
|
|
2116
|
+
},
|
|
2117
|
+
c.key
|
|
2118
|
+
))
|
|
2119
|
+
] }) }),
|
|
2120
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)("tbody", { children: visible.length ? visible.map(({ row, key }, i) => {
|
|
2121
|
+
const on = selected.includes(key);
|
|
2122
|
+
return /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(
|
|
2123
|
+
"tr",
|
|
2124
|
+
{
|
|
2125
|
+
className: on ? "is-selected" : void 0,
|
|
2126
|
+
ref: (el) => {
|
|
2127
|
+
if (el) rowRefs.current.set(key, el);
|
|
2128
|
+
else rowRefs.current.delete(key);
|
|
2129
|
+
},
|
|
2130
|
+
children: [
|
|
2131
|
+
selectable && /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("td", { className: "a-table__check", children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("label", { className: "a-check", children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("input", { type: "checkbox", "aria-label": "\u9078\u53D6 " + (rowLabel ? rowLabel(row, i) : defaultRowLabel(row, i)), checked: on, onChange: (e) => toggleRow(key, e.target.checked) }) }) }),
|
|
2132
|
+
columns.map((c) => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("td", { className: c.align === "right" ? "is-num" : void 0, children: cell(row, c, i) }, c.key))
|
|
2133
|
+
]
|
|
2134
|
+
},
|
|
2135
|
+
key
|
|
2136
|
+
);
|
|
2137
|
+
}) : /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("tr", { className: "a-table__empty", children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("td", { colSpan, children: query.trim() ? emptyText ? emptyText(query.trim()) : `\u627E\u4E0D\u5230\u7B26\u5408\u300C${query.trim()}\u300D\u7684\u8CC7\u6599` : empty != null ? empty : "\u6C92\u6709\u8CC7\u6599" }) }) })
|
|
2138
|
+
] }) })
|
|
2139
|
+
] });
|
|
2140
|
+
}
|
|
2141
|
+
var DataTable = (0, import_react7.forwardRef)(DataTableInner);
|
|
2142
|
+
|
|
2143
|
+
// src/components/Empty.tsx
|
|
2144
|
+
var import_react8 = require("react");
|
|
2145
|
+
var import_jsx_runtime38 = require("react/jsx-runtime");
|
|
2146
|
+
var BOX = /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", children: [
|
|
2147
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)("path", { d: "M3 7l9-4 9 4-9 4z" }),
|
|
2148
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)("path", { d: "M3 7v10l9 4 9-4V7" }),
|
|
2149
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)("path", { d: "M12 11v10" })
|
|
2150
|
+
] });
|
|
2151
|
+
var Empty = (0, import_react8.forwardRef)(function Empty2({ icon = BOX, title = "\u6C92\u6709\u8CC7\u6599", description, action, className, ...rest }, ref) {
|
|
2152
|
+
return /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { ref, className: cx("a-empty", className), ...rest, children: [
|
|
2153
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: "a-empty__icon", children: icon }),
|
|
2154
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)("h3", { className: "a-empty__title", children: title }),
|
|
2155
|
+
description != null && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("p", { className: "a-empty__text", children: description }),
|
|
2156
|
+
action
|
|
2157
|
+
] });
|
|
2158
|
+
});
|
|
2159
|
+
|
|
2160
|
+
// src/components/Statistic.tsx
|
|
2161
|
+
var import_react9 = require("react");
|
|
2162
|
+
var import_jsx_runtime39 = require("react/jsx-runtime");
|
|
2163
|
+
var Statistic = (0, import_react9.forwardRef)(function Statistic2({ label, value, decimals: decimals2 = 0, prefix, suffix, trend, animate = true, duration = 900, locale, formatter, className, ...rest }, ref) {
|
|
2164
|
+
var _a, _b;
|
|
2165
|
+
const reduce = useReducedMotion();
|
|
2166
|
+
const [shown, setShown] = (0, import_react9.useState)(animate ? 0 : value);
|
|
2167
|
+
const elRef = (0, import_react9.useRef)(null);
|
|
2168
|
+
const fromRef = (0, import_react9.useRef)(animate ? 0 : value);
|
|
2169
|
+
const startedRef = (0, import_react9.useRef)(!animate);
|
|
2170
|
+
(0, import_react9.useEffect)(() => {
|
|
2171
|
+
if (reduce) {
|
|
2172
|
+
setShown(value);
|
|
2173
|
+
fromRef.current = value;
|
|
2174
|
+
startedRef.current = true;
|
|
2175
|
+
return;
|
|
2176
|
+
}
|
|
2177
|
+
let raf = 0;
|
|
2178
|
+
const run = () => {
|
|
2179
|
+
const from = fromRef.current, t0 = performance.now();
|
|
2180
|
+
const tick = (now) => {
|
|
2181
|
+
const p = Math.min(1, (now - t0) / duration), e = 1 - Math.pow(1 - p, 3);
|
|
2182
|
+
const v = from + (value - from) * e;
|
|
2183
|
+
setShown(v);
|
|
2184
|
+
fromRef.current = v;
|
|
2185
|
+
if (p < 1) raf = requestAnimationFrame(tick);
|
|
2186
|
+
};
|
|
2187
|
+
raf = requestAnimationFrame(tick);
|
|
2188
|
+
};
|
|
2189
|
+
if (startedRef.current) {
|
|
2190
|
+
run();
|
|
2191
|
+
return () => cancelAnimationFrame(raf);
|
|
2192
|
+
}
|
|
2193
|
+
const el = elRef.current;
|
|
2194
|
+
if (!el || typeof IntersectionObserver === "undefined") {
|
|
2195
|
+
startedRef.current = true;
|
|
2196
|
+
run();
|
|
2197
|
+
return () => cancelAnimationFrame(raf);
|
|
2198
|
+
}
|
|
2199
|
+
const io = new IntersectionObserver((es) => {
|
|
2200
|
+
if (es.some((x) => x.isIntersecting)) {
|
|
2201
|
+
io.disconnect();
|
|
2202
|
+
startedRef.current = true;
|
|
2203
|
+
run();
|
|
2204
|
+
}
|
|
2205
|
+
}, { threshold: 0.4 });
|
|
2206
|
+
io.observe(el);
|
|
2207
|
+
return () => {
|
|
2208
|
+
io.disconnect();
|
|
2209
|
+
cancelAnimationFrame(raf);
|
|
2210
|
+
};
|
|
2211
|
+
}, [value, duration, reduce]);
|
|
2212
|
+
const fmt = formatter != null ? formatter : ((n) => n.toLocaleString(locale, { minimumFractionDigits: decimals2, maximumFractionDigits: decimals2 }));
|
|
2213
|
+
const dir = (_a = trend == null ? void 0 : trend.direction) != null ? _a : "up";
|
|
2214
|
+
const tone = (_b = trend == null ? void 0 : trend.tone) != null ? _b : dir === "up" ? "good" : "bad";
|
|
2215
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { ref, className: cx("a-stat", className), ...rest, children: [
|
|
2216
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("span", { className: "a-stat__label", children: label }),
|
|
2217
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("span", { className: "a-stat__value", children: [
|
|
2218
|
+
prefix,
|
|
2219
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("span", { ref: elRef, children: fmt(shown) }),
|
|
2220
|
+
suffix != null && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("small", { children: suffix })
|
|
2221
|
+
] }),
|
|
2222
|
+
trend && /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("span", { className: cx("a-stat__trend", tone === "bad" && "a-stat__trend--down"), children: [
|
|
2223
|
+
dir === "up" ? "\u25B2" : "\u25BC",
|
|
2224
|
+
" ",
|
|
2225
|
+
trend.value
|
|
2226
|
+
] })
|
|
2227
|
+
] });
|
|
2228
|
+
});
|
|
2229
|
+
var StatRow = (0, import_react9.forwardRef)(function StatRow2({ className, ...rest }, ref) {
|
|
2230
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { ref, className: cx("a-stat-row", className), ...rest });
|
|
2231
|
+
});
|
|
2232
|
+
|
|
2233
|
+
// src/components/Timeline.tsx
|
|
2234
|
+
var import_react10 = require("react");
|
|
2235
|
+
var import_jsx_runtime40 = require("react/jsx-runtime");
|
|
2236
|
+
var Timeline = (0, import_react10.forwardRef)(function Timeline2({ items, className, ...rest }, ref) {
|
|
2237
|
+
return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("ol", { ref, className: cx("a-timeline", className), ...rest, children: items.map((it, i) => {
|
|
2238
|
+
var _a;
|
|
2239
|
+
return /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("li", { className: it.status && it.status !== "default" ? `is-${it.status}` : void 0, children: [
|
|
2240
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)("span", { className: "a-timeline__title", children: it.title }),
|
|
2241
|
+
it.content,
|
|
2242
|
+
it.time != null && /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("span", { className: "a-timeline__time", children: it.time })
|
|
2243
|
+
] }, (_a = it.key) != null ? _a : i);
|
|
2244
|
+
}) });
|
|
2245
|
+
});
|
|
2246
|
+
|
|
2247
|
+
// src/components/List.tsx
|
|
2248
|
+
var import_react11 = require("react");
|
|
2249
|
+
var import_jsx_runtime41 = require("react/jsx-runtime");
|
|
2250
|
+
var List = (0, import_react11.forwardRef)(function List2({ items, hover, className, ...rest }, ref) {
|
|
2251
|
+
return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("ul", { ref, className: cx("a-list", hover && "a-list--hover", className), ...rest, children: items.map((it, i) => {
|
|
2252
|
+
var _a;
|
|
2253
|
+
return /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(
|
|
2254
|
+
"li",
|
|
2255
|
+
{
|
|
2256
|
+
onClick: it.onClick,
|
|
2257
|
+
tabIndex: it.onClick ? 0 : void 0,
|
|
2258
|
+
role: it.onClick ? "button" : void 0,
|
|
2259
|
+
onKeyDown: it.onClick ? (e) => {
|
|
2260
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
2261
|
+
e.preventDefault();
|
|
2262
|
+
it.onClick();
|
|
2263
|
+
}
|
|
2264
|
+
} : void 0,
|
|
2265
|
+
style: it.onClick ? { cursor: "pointer" } : void 0,
|
|
2266
|
+
children: [
|
|
2267
|
+
it.avatar,
|
|
2268
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: "a-list__main", children: [
|
|
2269
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("span", { className: "a-list__title", children: it.title }),
|
|
2270
|
+
it.description != null && /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("span", { className: "a-list__desc", children: it.description })
|
|
2271
|
+
] }),
|
|
2272
|
+
it.extra != null && /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("span", { className: "a-list__extra", children: it.extra })
|
|
2273
|
+
]
|
|
2274
|
+
},
|
|
2275
|
+
(_a = it.key) != null ? _a : i
|
|
2276
|
+
);
|
|
2277
|
+
}) });
|
|
2278
|
+
});
|
|
2279
|
+
|
|
2280
|
+
// src/components/Descriptions.tsx
|
|
2281
|
+
var import_react12 = require("react");
|
|
2282
|
+
var import_jsx_runtime42 = require("react/jsx-runtime");
|
|
2283
|
+
var Descriptions = (0, import_react12.forwardRef)(function Descriptions2({ items, columns = 2, className, style, ...rest }, ref) {
|
|
2284
|
+
const s = columns !== 2 && columns !== 3 ? { ...style, ["--cols"]: columns } : style;
|
|
2285
|
+
return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("dl", { ref, className: cx("a-desc", columns === 3 && "a-desc--3", className), style: s, ...rest, children: items.map((it, i) => {
|
|
2286
|
+
var _a;
|
|
2287
|
+
return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { className: it.wide ? "is-wide" : void 0, children: [
|
|
2288
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)("dt", { children: it.label }),
|
|
2289
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)("dd", { children: it.children })
|
|
2290
|
+
] }, (_a = it.key) != null ? _a : i);
|
|
2291
|
+
}) });
|
|
2292
|
+
});
|
|
2293
|
+
|
|
2294
|
+
// src/components/Kbd.tsx
|
|
2295
|
+
var import_react13 = require("react");
|
|
2296
|
+
var import_jsx_runtime43 = require("react/jsx-runtime");
|
|
2297
|
+
var Kbd = (0, import_react13.forwardRef)(function Kbd2({ className, ...rest }, ref) {
|
|
2298
|
+
return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("kbd", { ref, className: cx("a-kbd", className), ...rest });
|
|
2299
|
+
});
|
|
2300
|
+
var KbdCombo = (0, import_react13.forwardRef)(function KbdCombo2({ keys, separator = "+", className, ...rest }, ref) {
|
|
2301
|
+
return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("span", { ref, className: cx("a-kbd-combo", className), ...rest, children: keys.map((k, i) => /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(import_react13.Fragment, { children: [
|
|
2302
|
+
i > 0 && separator,
|
|
2303
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Kbd, { children: k })
|
|
2304
|
+
] }, i)) });
|
|
2305
|
+
});
|
|
2306
|
+
|
|
2307
|
+
// src/components/Carousel.tsx
|
|
2308
|
+
var import_react14 = require("react");
|
|
2309
|
+
var import_jsx_runtime44 = require("react/jsx-runtime");
|
|
2310
|
+
var ChevL = /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("path", { d: "M15 6l-6 6 6 6" }) });
|
|
2311
|
+
var ChevR = /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("path", { d: "M9 6l6 6-6 6" }) });
|
|
2312
|
+
var Carousel = (0, import_react14.forwardRef)(function Carousel2({ children, peek, autoplay, showArrows = true, showDots = true, onChange, className, ...rest }, ref) {
|
|
2313
|
+
const reduce = useReducedMotion();
|
|
2314
|
+
const track = (0, import_react14.useRef)(null);
|
|
2315
|
+
const root = (0, import_react14.useRef)(null);
|
|
2316
|
+
const slides = import_react14.Children.toArray(children);
|
|
2317
|
+
const [index, setIndex] = (0, import_react14.useState)(0);
|
|
2318
|
+
const [edge, setEdge] = (0, import_react14.useState)({ start: true, end: slides.length <= 1 });
|
|
2319
|
+
const paused = (0, import_react14.useRef)(false);
|
|
2320
|
+
const goTo = (0, import_react14.useCallback)((i) => {
|
|
2321
|
+
const t = track.current;
|
|
2322
|
+
if (!t) return;
|
|
2323
|
+
const el = t.children[Math.max(0, Math.min(slides.length - 1, i))];
|
|
2324
|
+
if (el) t.scrollTo({ left: el.offsetLeft - t.offsetLeft, behavior: reduce ? "auto" : "smooth" });
|
|
2325
|
+
}, [slides.length, reduce]);
|
|
2326
|
+
const step = (0, import_react14.useCallback)((d) => {
|
|
2327
|
+
var _a, _b;
|
|
2328
|
+
const t = track.current;
|
|
2329
|
+
if (!t) return;
|
|
2330
|
+
const w = (_b = (_a = t.children[0]) == null ? void 0 : _a.offsetWidth) != null ? _b : t.clientWidth;
|
|
2331
|
+
t.scrollBy({ left: d * w, behavior: reduce ? "auto" : "smooth" });
|
|
2332
|
+
}, [reduce]);
|
|
2333
|
+
(0, import_react14.useImperativeHandle)(ref, () => ({ goTo, next: () => step(1), prev: () => step(-1) }), [goTo, step]);
|
|
2334
|
+
const sync = (0, import_react14.useCallback)(() => {
|
|
2335
|
+
const t = track.current;
|
|
2336
|
+
if (!t) return;
|
|
2337
|
+
const max = t.scrollWidth - t.clientWidth;
|
|
2338
|
+
setEdge({ start: t.scrollLeft <= 2, end: t.scrollLeft >= max - 2 });
|
|
2339
|
+
let best = 0, dist = Infinity;
|
|
2340
|
+
Array.from(t.children).forEach((c, i) => {
|
|
2341
|
+
const d = Math.abs(c.offsetLeft - t.offsetLeft - t.scrollLeft);
|
|
2342
|
+
if (d < dist) {
|
|
2343
|
+
dist = d;
|
|
2344
|
+
best = i;
|
|
2345
|
+
}
|
|
2346
|
+
});
|
|
2347
|
+
if (t.scrollLeft >= max - 2) best = slides.length - 1;
|
|
2348
|
+
setIndex((prev) => {
|
|
2349
|
+
if (prev !== best) onChange == null ? void 0 : onChange(best);
|
|
2350
|
+
return best;
|
|
2351
|
+
});
|
|
2352
|
+
}, [slides.length, onChange]);
|
|
2353
|
+
(0, import_react14.useEffect)(() => {
|
|
2354
|
+
const t = track.current;
|
|
2355
|
+
if (!t) return;
|
|
2356
|
+
let raf = 0;
|
|
2357
|
+
const onScroll = () => {
|
|
2358
|
+
cancelAnimationFrame(raf);
|
|
2359
|
+
raf = requestAnimationFrame(sync);
|
|
2360
|
+
};
|
|
2361
|
+
t.addEventListener("scroll", onScroll, { passive: true });
|
|
2362
|
+
window.addEventListener("resize", onScroll);
|
|
2363
|
+
sync();
|
|
2364
|
+
return () => {
|
|
2365
|
+
t.removeEventListener("scroll", onScroll);
|
|
2366
|
+
window.removeEventListener("resize", onScroll);
|
|
2367
|
+
cancelAnimationFrame(raf);
|
|
2368
|
+
};
|
|
2369
|
+
}, [sync]);
|
|
2370
|
+
(0, import_react14.useEffect)(() => {
|
|
2371
|
+
if (!autoplay || reduce || slides.length < 2) return;
|
|
2372
|
+
const id = window.setInterval(() => {
|
|
2373
|
+
if (paused.current || document.hidden) return;
|
|
2374
|
+
const t = track.current;
|
|
2375
|
+
if (!t) return;
|
|
2376
|
+
if (t.scrollLeft >= t.scrollWidth - t.clientWidth - 2) goTo(0);
|
|
2377
|
+
else step(1);
|
|
2378
|
+
}, autoplay);
|
|
2379
|
+
return () => clearInterval(id);
|
|
2380
|
+
}, [autoplay, reduce, slides.length, goTo, step]);
|
|
2381
|
+
const pause = (v) => () => {
|
|
2382
|
+
paused.current = v;
|
|
2383
|
+
};
|
|
2384
|
+
return /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)(
|
|
2385
|
+
"div",
|
|
2386
|
+
{
|
|
2387
|
+
ref: root,
|
|
2388
|
+
className: cx("a-carousel", peek && "a-carousel--peek", className),
|
|
2389
|
+
role: "region",
|
|
2390
|
+
"aria-roledescription": "carousel",
|
|
2391
|
+
onPointerEnter: pause(true),
|
|
2392
|
+
onPointerLeave: pause(false),
|
|
2393
|
+
onFocus: pause(true),
|
|
2394
|
+
onBlur: (e) => {
|
|
2395
|
+
var _a;
|
|
2396
|
+
if (!((_a = root.current) == null ? void 0 : _a.contains(e.relatedTarget))) paused.current = false;
|
|
2397
|
+
},
|
|
2398
|
+
onKeyDown: (e) => {
|
|
2399
|
+
if (e.key === "ArrowRight") {
|
|
2400
|
+
e.preventDefault();
|
|
2401
|
+
step(1);
|
|
2402
|
+
} else if (e.key === "ArrowLeft") {
|
|
2403
|
+
e.preventDefault();
|
|
2404
|
+
step(-1);
|
|
2405
|
+
}
|
|
2406
|
+
},
|
|
2407
|
+
...rest,
|
|
2408
|
+
children: [
|
|
2409
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)("div", { ref: track, className: "a-carousel__track", tabIndex: 0, children: slides.map((s, i) => /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("div", { className: "a-carousel__slide", role: "group", "aria-roledescription": "slide", "aria-label": `${i + 1} / ${slides.length}`, children: s }, i)) }),
|
|
2410
|
+
showArrows && slides.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)(import_jsx_runtime44.Fragment, { children: [
|
|
2411
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)("button", { type: "button", className: "a-carousel__btn a-carousel__btn--prev", "aria-label": "\u4E0A\u4E00\u5F35", disabled: edge.start, onClick: () => step(-1), children: ChevL }),
|
|
2412
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)("button", { type: "button", className: "a-carousel__btn a-carousel__btn--next", "aria-label": "\u4E0B\u4E00\u5F35", disabled: edge.end, onClick: () => step(1), children: ChevR })
|
|
2413
|
+
] }),
|
|
2414
|
+
showDots && slides.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("div", { className: "a-carousel__dots", children: slides.map((_, i) => /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("button", { type: "button", "aria-label": `\u7B2C ${i + 1} \u5F35`, "aria-current": i === index ? "true" : "false", onClick: () => goTo(i) }, i)) })
|
|
2415
|
+
]
|
|
2416
|
+
}
|
|
2417
|
+
);
|
|
2418
|
+
});
|
|
2419
|
+
|
|
2420
|
+
// src/components/Calendar.tsx
|
|
2421
|
+
var import_react15 = require("react");
|
|
2422
|
+
|
|
2423
|
+
// src/components/dateUtils.tsx
|
|
2424
|
+
var import_jsx_runtime45 = require("react/jsx-runtime");
|
|
2425
|
+
var pad = (n) => String(n).padStart(2, "0");
|
|
2426
|
+
var toKey = (d) => `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}`;
|
|
2427
|
+
var fromKey = (k) => {
|
|
2428
|
+
const [y, m, d] = k.split("-").map(Number);
|
|
2429
|
+
return new Date(y, (m || 1) - 1, d || 1);
|
|
2430
|
+
};
|
|
2431
|
+
var WEEK = ["\u65E5", "\u4E00", "\u4E8C", "\u4E09", "\u56DB", "\u4E94", "\u516D"];
|
|
2432
|
+
function monthGrid(year, month) {
|
|
2433
|
+
const first = new Date(year, month, 1);
|
|
2434
|
+
const start = new Date(year, month, 1 - first.getDay());
|
|
2435
|
+
return Array.from({ length: 42 }, (_, i) => new Date(start.getFullYear(), start.getMonth(), start.getDate() + i));
|
|
2436
|
+
}
|
|
2437
|
+
var ChevL2 = /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("path", { d: "M15 6l-6 6 6 6" }) });
|
|
2438
|
+
var ChevR2 = /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("path", { d: "M9 6l6 6-6 6" }) });
|
|
2439
|
+
|
|
2440
|
+
// src/components/Calendar.tsx
|
|
2441
|
+
var import_jsx_runtime46 = require("react/jsx-runtime");
|
|
2442
|
+
var Calendar = (0, import_react15.forwardRef)(function Calendar2({ value, defaultValue = "", onChange, defaultMonth, disabledDate, renderDay, className, ...rest }, ref) {
|
|
2443
|
+
const [sel, setSel] = useControllable(value, defaultValue, onChange);
|
|
2444
|
+
const init = fromKey(defaultMonth || sel || toKey(/* @__PURE__ */ new Date()));
|
|
2445
|
+
const [view, setView] = (0, import_react15.useState)({ y: init.getFullYear(), m: init.getMonth(), dir: "", n: 0 });
|
|
2446
|
+
const today = toKey(/* @__PURE__ */ new Date());
|
|
2447
|
+
const move = (d) => setView((v) => {
|
|
2448
|
+
const t = new Date(v.y, v.m + d, 1);
|
|
2449
|
+
return { y: t.getFullYear(), m: t.getMonth(), dir: d > 0 ? "next" : "prev", n: v.n + 1 };
|
|
2450
|
+
});
|
|
2451
|
+
return /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)("div", { ref, className: cx("a-calendar", className), ...rest, children: [
|
|
2452
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsxs)("div", { className: "a-calendar__head", children: [
|
|
2453
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)("button", { type: "button", "aria-label": "\u4E0A\u500B\u6708", onClick: () => move(-1), children: ChevL2 }),
|
|
2454
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsxs)("b", { "aria-live": "polite", children: [
|
|
2455
|
+
view.y,
|
|
2456
|
+
" \u5E74 ",
|
|
2457
|
+
view.m + 1,
|
|
2458
|
+
" \u6708"
|
|
2459
|
+
] }),
|
|
2460
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)("button", { type: "button", "aria-label": "\u4E0B\u500B\u6708", onClick: () => move(1), children: ChevR2 })
|
|
2461
|
+
] }),
|
|
2462
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)("div", { className: "a-calendar__week", "aria-hidden": "true", children: WEEK.map((w) => /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("span", { children: w }, w)) }),
|
|
2463
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)("div", { className: cx("a-calendar__grid", view.dir && `is-${view.dir}`), children: monthGrid(view.y, view.m).map((d) => {
|
|
2464
|
+
const k = toKey(d), out = d.getMonth() !== view.m, dis = disabledDate == null ? void 0 : disabledDate(k);
|
|
2465
|
+
return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
|
|
2466
|
+
"button",
|
|
2467
|
+
{
|
|
2468
|
+
type: "button",
|
|
2469
|
+
"aria-label": `${d.getMonth() + 1} \u6708 ${d.getDate()} \u65E5`,
|
|
2470
|
+
"aria-selected": k === sel,
|
|
2471
|
+
disabled: dis,
|
|
2472
|
+
className: cx(out && "is-out", k === today && "is-today") || void 0,
|
|
2473
|
+
onClick: () => {
|
|
2474
|
+
setSel(k);
|
|
2475
|
+
if (out) move(d < new Date(view.y, view.m, 1) ? -1 : 1);
|
|
2476
|
+
},
|
|
2477
|
+
children: renderDay ? renderDay(d, k) : d.getDate()
|
|
2478
|
+
},
|
|
2479
|
+
k
|
|
2480
|
+
);
|
|
2481
|
+
}) }, view.n)
|
|
2482
|
+
] });
|
|
2483
|
+
});
|
|
2484
|
+
|
|
2485
|
+
// src/components/RangePicker.tsx
|
|
2486
|
+
var import_react16 = require("react");
|
|
2487
|
+
var import_jsx_runtime47 = require("react/jsx-runtime");
|
|
2488
|
+
var RangePicker = (0, import_react16.forwardRef)(function RangePicker2({ value, defaultValue = ["", ""], onChange, defaultMonth, disabledDate, className, ...rest }, ref) {
|
|
2489
|
+
const [range, setRange] = useControllable(value, defaultValue, onChange);
|
|
2490
|
+
const [start, end] = range;
|
|
2491
|
+
const [hover, setHover] = (0, import_react16.useState)("");
|
|
2492
|
+
const init = fromKey(defaultMonth || start || toKey(/* @__PURE__ */ new Date()));
|
|
2493
|
+
const [view, setView] = (0, import_react16.useState)({ y: init.getFullYear(), m: init.getMonth(), dir: "", n: 0 });
|
|
2494
|
+
const today = toKey(/* @__PURE__ */ new Date());
|
|
2495
|
+
const move = (d) => setView((v) => {
|
|
2496
|
+
const t = new Date(v.y, v.m + d, 1);
|
|
2497
|
+
return { y: t.getFullYear(), m: t.getMonth(), dir: d > 0 ? "next" : "prev", n: v.n + 1 };
|
|
2498
|
+
});
|
|
2499
|
+
const pick = (k) => {
|
|
2500
|
+
if (!start || end || k < start) setRange([k, ""]);
|
|
2501
|
+
else setRange([start, k]);
|
|
2502
|
+
};
|
|
2503
|
+
const shownEnd = end || (start && hover >= start ? hover : "");
|
|
2504
|
+
return /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { ref, className: cx("a-calendar", "a-calendar--range", className), ...rest, children: [
|
|
2505
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: "a-calendar__head", children: [
|
|
2506
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("button", { type: "button", "aria-label": "\u4E0A\u500B\u6708", onClick: () => move(-1), children: ChevL2 }),
|
|
2507
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("b", { "aria-live": "polite", children: [
|
|
2508
|
+
view.y,
|
|
2509
|
+
" \u5E74 ",
|
|
2510
|
+
view.m + 1,
|
|
2511
|
+
" \u6708"
|
|
2512
|
+
] }),
|
|
2513
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("button", { type: "button", "aria-label": "\u4E0B\u500B\u6708", onClick: () => move(1), children: ChevR2 })
|
|
2514
|
+
] }),
|
|
2515
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("div", { className: "a-calendar__week", "aria-hidden": "true", children: WEEK.map((w) => /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { children: w }, w)) }),
|
|
2516
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("div", { className: cx("a-calendar__grid", view.dir && `is-${view.dir}`), onPointerLeave: () => setHover(""), children: monthGrid(view.y, view.m).map((d) => {
|
|
2517
|
+
const k = toKey(d), out = d.getMonth() !== view.m;
|
|
2518
|
+
const isStart = k === start, isEnd = !!shownEnd && k === shownEnd;
|
|
2519
|
+
const inRange = !!start && !!shownEnd && k > start && k < shownEnd;
|
|
2520
|
+
return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
2521
|
+
"button",
|
|
2522
|
+
{
|
|
2523
|
+
type: "button",
|
|
2524
|
+
"aria-label": `${d.getMonth() + 1} \u6708 ${d.getDate()} \u65E5`,
|
|
2525
|
+
"aria-selected": isStart || !!end && k === end,
|
|
2526
|
+
disabled: disabledDate == null ? void 0 : disabledDate(k),
|
|
2527
|
+
className: cx(out && "is-out", k === today && "is-today", isStart && "is-start", isStart && shownEnd && shownEnd !== start && "has-end", isEnd && "is-end", inRange && "is-in-range") || void 0,
|
|
2528
|
+
onPointerEnter: () => {
|
|
2529
|
+
if (start && !end) setHover(k);
|
|
2530
|
+
},
|
|
2531
|
+
onClick: () => pick(k),
|
|
2532
|
+
children: d.getDate()
|
|
2533
|
+
},
|
|
2534
|
+
k
|
|
2535
|
+
);
|
|
2536
|
+
}) }, view.n)
|
|
2537
|
+
] });
|
|
2538
|
+
});
|
|
2539
|
+
|
|
2540
|
+
// src/components/Tree.tsx
|
|
2541
|
+
var import_react17 = require("react");
|
|
2542
|
+
var import_jsx_runtime48 = require("react/jsx-runtime");
|
|
2543
|
+
var FOLDER = /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("path", { d: "M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z" }) });
|
|
2544
|
+
var FILE = /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", children: [
|
|
2545
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.jsx)("path", { d: "M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z" }),
|
|
2546
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.jsx)("path", { d: "M14 3v5h5" })
|
|
2547
|
+
] });
|
|
2548
|
+
var Tree = (0, import_react17.forwardRef)(function Tree2({ data, defaultExpandedKeys = [], expandedKeys, onExpandChange, selectedKey, defaultSelectedKey = "", onSelect, className, ...rest }, ref) {
|
|
2549
|
+
const [open, setOpen] = useControllable(expandedKeys, defaultExpandedKeys, onExpandChange);
|
|
2550
|
+
const [sel, setSel] = useControllable(selectedKey, defaultSelectedKey);
|
|
2551
|
+
const choose = (n) => {
|
|
2552
|
+
setSel(n.key);
|
|
2553
|
+
onSelect == null ? void 0 : onSelect(n.key, n);
|
|
2554
|
+
};
|
|
2555
|
+
const render = (nodes) => /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("ul", { children: nodes.map((n) => {
|
|
2556
|
+
var _a, _b;
|
|
2557
|
+
return /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("li", { children: n.children ? /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("details", { open: open.includes(n.key), children: [
|
|
2558
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("summary", { onClick: (e) => {
|
|
2559
|
+
e.preventDefault();
|
|
2560
|
+
setOpen(open.includes(n.key) ? open.filter((k) => k !== n.key) : [...open, n.key]);
|
|
2561
|
+
}, children: [
|
|
2562
|
+
(_a = n.icon) != null ? _a : FOLDER,
|
|
2563
|
+
n.label
|
|
2564
|
+
] }),
|
|
2565
|
+
render(n.children)
|
|
2566
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)(
|
|
2567
|
+
"span",
|
|
2568
|
+
{
|
|
2569
|
+
className: "a-tree__leaf",
|
|
2570
|
+
tabIndex: 0,
|
|
2571
|
+
role: "button",
|
|
2572
|
+
"aria-current": sel === n.key ? "true" : void 0,
|
|
2573
|
+
onClick: () => choose(n),
|
|
2574
|
+
onKeyDown: (e) => {
|
|
2575
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
2576
|
+
e.preventDefault();
|
|
2577
|
+
choose(n);
|
|
2578
|
+
}
|
|
2579
|
+
},
|
|
2580
|
+
children: [
|
|
2581
|
+
(_b = n.icon) != null ? _b : FILE,
|
|
2582
|
+
n.label
|
|
2583
|
+
]
|
|
2584
|
+
}
|
|
2585
|
+
) }, n.key);
|
|
2586
|
+
}) });
|
|
2587
|
+
return /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("div", { ref, className: cx("a-tree", className), ...rest, children: render(data) });
|
|
2588
|
+
});
|
|
2589
|
+
|
|
2590
|
+
// src/components/ImagePreview.tsx
|
|
2591
|
+
var import_react18 = require("react");
|
|
2592
|
+
var import_jsx_runtime49 = require("react/jsx-runtime");
|
|
2593
|
+
var EASE = "cubic-bezier(0.22,1,0.36,1)";
|
|
2594
|
+
var ImagePreview = (0, import_react18.forwardRef)(function ImagePreview2({ src, previewSrc, alt, width = 160, height = 110, className, style, onClick, ...rest }, ref) {
|
|
2595
|
+
const reduce = useReducedMotion();
|
|
2596
|
+
const thumb = (0, import_react18.useRef)(null);
|
|
2597
|
+
const dlg = (0, import_react18.useRef)(null);
|
|
2598
|
+
const big = (0, import_react18.useRef)(null);
|
|
2599
|
+
const [open, setOpen] = (0, import_react18.useState)(false);
|
|
2600
|
+
const closing = (0, import_react18.useRef)(false);
|
|
2601
|
+
(0, import_react18.useImperativeHandle)(ref, () => thumb.current);
|
|
2602
|
+
const fromThumb = () => {
|
|
2603
|
+
var _a;
|
|
2604
|
+
const t = (_a = thumb.current) == null ? void 0 : _a.querySelector("img"), b = big.current;
|
|
2605
|
+
if (!t || !b) return null;
|
|
2606
|
+
const a = t.getBoundingClientRect(), z = b.getBoundingClientRect();
|
|
2607
|
+
if (!z.width) return null;
|
|
2608
|
+
const s = a.width / z.width;
|
|
2609
|
+
return { transform: `translate(${a.left + a.width / 2 - (z.left + z.width / 2)}px, ${a.top + a.height / 2 - (z.top + z.height / 2)}px) scale(${s})`, opacity: 0.5 };
|
|
2610
|
+
};
|
|
2611
|
+
(0, import_react18.useEffect)(() => {
|
|
2612
|
+
var _a, _b;
|
|
2613
|
+
const d = dlg.current;
|
|
2614
|
+
if (!d || !open) return;
|
|
2615
|
+
if (!d.open) (_a = d.showModal) == null ? void 0 : _a.call(d);
|
|
2616
|
+
closing.current = false;
|
|
2617
|
+
const k = fromThumb();
|
|
2618
|
+
if (k && !reduce && ((_b = big.current) == null ? void 0 : _b.animate)) big.current.animate([k, { transform: "none", opacity: 1 }], { duration: 340, easing: EASE });
|
|
2619
|
+
}, [open]);
|
|
2620
|
+
const close = () => {
|
|
2621
|
+
var _a;
|
|
2622
|
+
const d = dlg.current;
|
|
2623
|
+
if (!d || closing.current) return;
|
|
2624
|
+
closing.current = true;
|
|
2625
|
+
const finish = () => {
|
|
2626
|
+
var _a2;
|
|
2627
|
+
d.classList.remove("is-closing");
|
|
2628
|
+
d.close();
|
|
2629
|
+
setOpen(false);
|
|
2630
|
+
(_a2 = thumb.current) == null ? void 0 : _a2.focus();
|
|
2631
|
+
};
|
|
2632
|
+
const k = fromThumb();
|
|
2633
|
+
if (!k || reduce || !((_a = big.current) == null ? void 0 : _a.animate)) {
|
|
2634
|
+
finish();
|
|
2635
|
+
return;
|
|
2636
|
+
}
|
|
2637
|
+
d.classList.add("is-closing");
|
|
2638
|
+
big.current.animate([{ transform: "none", opacity: 1 }, k], { duration: 200, easing: EASE, fill: "forwards" }).onfinish = finish;
|
|
2639
|
+
};
|
|
2640
|
+
return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(import_jsx_runtime49.Fragment, { children: [
|
|
2641
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
|
|
2642
|
+
"button",
|
|
2643
|
+
{
|
|
2644
|
+
ref: thumb,
|
|
2645
|
+
type: "button",
|
|
2646
|
+
className: cx("a-image", className),
|
|
2647
|
+
style: { width, height, ...style },
|
|
2648
|
+
"aria-haspopup": "dialog",
|
|
2649
|
+
onClick: (e) => {
|
|
2650
|
+
onClick == null ? void 0 : onClick(e);
|
|
2651
|
+
if (!e.defaultPrevented) setOpen(true);
|
|
2652
|
+
},
|
|
2653
|
+
...rest,
|
|
2654
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("img", { src, alt, loading: "lazy" })
|
|
2655
|
+
}
|
|
2656
|
+
),
|
|
2657
|
+
open && /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(
|
|
2658
|
+
"dialog",
|
|
2659
|
+
{
|
|
2660
|
+
ref: dlg,
|
|
2661
|
+
className: "a-lightbox",
|
|
2662
|
+
"aria-label": alt,
|
|
2663
|
+
onCancel: (e) => {
|
|
2664
|
+
e.preventDefault();
|
|
2665
|
+
close();
|
|
2666
|
+
},
|
|
2667
|
+
onClick: close,
|
|
2668
|
+
children: [
|
|
2669
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("figure", { children: [
|
|
2670
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)("img", { ref: big, src: previewSrc != null ? previewSrc : src, alt }),
|
|
2671
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)("figcaption", { children: alt })
|
|
2672
|
+
] }),
|
|
2673
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)("button", { type: "button", className: "a-lightbox__close", "aria-label": "\u95DC\u9589", onClick: (e) => {
|
|
2674
|
+
e.stopPropagation();
|
|
2675
|
+
close();
|
|
2676
|
+
}, children: "\xD7" })
|
|
2677
|
+
]
|
|
2678
|
+
}
|
|
2679
|
+
)
|
|
2680
|
+
] });
|
|
2681
|
+
});
|
|
2682
|
+
|
|
2683
|
+
// src/components/Modal.tsx
|
|
2684
|
+
var React28 = __toESM(require("react"), 1);
|
|
2685
|
+
var import_jsx_runtime50 = require("react/jsx-runtime");
|
|
2686
|
+
var Modal = React28.forwardRef(function Modal2({ open, onClose, title, footer, closeOnBackdrop = true, initialFocus, lockScroll, className, children, ...rest }, forwarded) {
|
|
2687
|
+
const { ref, onClick } = useDialog(open, onClose, closeOnBackdrop, { initialFocus, lockScroll });
|
|
2688
|
+
const titleId = useId2("modal");
|
|
2689
|
+
const bodyId = titleId + "-body";
|
|
2690
|
+
const merged = React28.useMemo(() => mergeRefs(ref, forwarded), [ref, forwarded]);
|
|
2691
|
+
return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
2692
|
+
"dialog",
|
|
2693
|
+
{
|
|
2694
|
+
ref: merged,
|
|
2695
|
+
onClick,
|
|
2696
|
+
className: cx("a-modal", className),
|
|
2697
|
+
"aria-labelledby": title != null ? titleId : void 0,
|
|
2698
|
+
"aria-describedby": bodyId,
|
|
2699
|
+
"aria-modal": "true",
|
|
2700
|
+
...rest,
|
|
2701
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { className: "a-modal__panel", children: [
|
|
2702
|
+
title != null && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("h3", { className: "a-modal__title", id: titleId, children: title }),
|
|
2703
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)("div", { className: "a-modal__body", id: bodyId, children }),
|
|
2704
|
+
footer != null && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("div", { className: "a-modal__footer", children: footer })
|
|
2705
|
+
] })
|
|
2706
|
+
}
|
|
2707
|
+
);
|
|
2708
|
+
});
|
|
2709
|
+
|
|
2710
|
+
// src/components/Drawer.tsx
|
|
2711
|
+
var import_jsx_runtime51 = require("react/jsx-runtime");
|
|
2712
|
+
function Drawer({ open, onClose, title, footer, side = "right", closeOnBackdrop = true, hideClose, className, children, ...rest }) {
|
|
2713
|
+
const { ref, onClick } = useDialog(open, onClose, closeOnBackdrop);
|
|
2714
|
+
const titleId = useId2("drawer");
|
|
2715
|
+
return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("dialog", { ref, onClick, className: cx("a-drawer", side === "left" && "a-drawer--left", className), "aria-labelledby": title ? titleId : void 0, ...rest, children: /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("div", { className: "a-drawer__panel", children: [
|
|
2716
|
+
(title != null || !hideClose) && /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("div", { className: "a-drawer__header", children: [
|
|
2717
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)("h3", { className: "a-drawer__title", id: titleId, children: title }),
|
|
2718
|
+
!hideClose && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("button", { type: "button", className: "a-btn a-btn--ghost a-btn--icon a-btn--sm", "aria-label": "\u95DC\u9589", onClick: onClose, children: "\xD7" })
|
|
2719
|
+
] }),
|
|
2720
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)("div", { className: "a-drawer__body", children }),
|
|
2721
|
+
footer != null && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("div", { className: "a-drawer__footer", children: footer })
|
|
2722
|
+
] }) });
|
|
2723
|
+
}
|
|
2724
|
+
|
|
2725
|
+
// src/components/Toast.tsx
|
|
2726
|
+
var React29 = __toESM(require("react"), 1);
|
|
2727
|
+
var import_react_dom2 = require("react-dom");
|
|
2728
|
+
var import_jsx_runtime52 = require("react/jsx-runtime");
|
|
2729
|
+
var entries = [];
|
|
2730
|
+
var seq = 0;
|
|
2731
|
+
var listeners = /* @__PURE__ */ new Set();
|
|
2732
|
+
var emit = () => listeners.forEach((l) => l());
|
|
2733
|
+
var subscribe = (l) => {
|
|
2734
|
+
listeners.add(l);
|
|
2735
|
+
return () => {
|
|
2736
|
+
listeners.delete(l);
|
|
2737
|
+
};
|
|
2738
|
+
};
|
|
2739
|
+
var getSnapshot = () => entries;
|
|
2740
|
+
var EMPTY = [];
|
|
2741
|
+
var getServerSnapshot = () => EMPTY;
|
|
2742
|
+
function dismiss(id) {
|
|
2743
|
+
if (!entries.some((e) => e.id === id && !e.leaving)) return;
|
|
2744
|
+
entries = entries.map((e) => e.id === id ? { ...e, leaving: true } : e);
|
|
2745
|
+
emit();
|
|
2746
|
+
setTimeout(() => {
|
|
2747
|
+
entries = entries.filter((e) => e.id !== id);
|
|
2748
|
+
emit();
|
|
2749
|
+
}, 200);
|
|
2750
|
+
}
|
|
2751
|
+
function push(e, max) {
|
|
2752
|
+
const id = ++seq;
|
|
2753
|
+
entries = [...entries, { ...e, id, leaving: false }];
|
|
2754
|
+
const same = entries.filter((x) => x.kind === e.kind);
|
|
2755
|
+
if (same.length > max) {
|
|
2756
|
+
const drop = new Set(same.slice(0, same.length - max).map((x) => x.id));
|
|
2757
|
+
entries = entries.filter((x) => !drop.has(x.id));
|
|
2758
|
+
}
|
|
2759
|
+
emit();
|
|
2760
|
+
return () => dismiss(id);
|
|
2761
|
+
}
|
|
2762
|
+
function toast(message, opts = {}) {
|
|
2763
|
+
var _a, _b;
|
|
2764
|
+
return push({ kind: "toast", message, type: (_a = opts.type) != null ? _a : "info", duration: (_b = opts.duration) != null ? _b : 3200 }, 4);
|
|
2765
|
+
}
|
|
2766
|
+
function notify(opts) {
|
|
2767
|
+
var _a, _b;
|
|
2768
|
+
return push({
|
|
2769
|
+
kind: "notice",
|
|
2770
|
+
title: opts.title,
|
|
2771
|
+
text: opts.text,
|
|
2772
|
+
actions: opts.actions,
|
|
2773
|
+
type: (_a = opts.type) != null ? _a : "info",
|
|
2774
|
+
duration: opts.duration === 0 ? 0 : (_b = opts.duration) != null ? _b : 4500
|
|
2775
|
+
}, 3);
|
|
2776
|
+
}
|
|
2777
|
+
function useLife(e, resume) {
|
|
2778
|
+
const [inn, setIn] = React29.useState(false);
|
|
2779
|
+
const timer = React29.useRef(void 0);
|
|
2780
|
+
React29.useEffect(() => {
|
|
2781
|
+
const r = requestAnimationFrame(() => requestAnimationFrame(() => setIn(true)));
|
|
2782
|
+
if (e.duration) timer.current = setTimeout(() => dismiss(e.id), e.duration);
|
|
2783
|
+
return () => {
|
|
2784
|
+
cancelAnimationFrame(r);
|
|
2785
|
+
clearTimeout(timer.current);
|
|
2786
|
+
};
|
|
2787
|
+
}, [e.id, e.duration]);
|
|
2788
|
+
return {
|
|
2789
|
+
inn,
|
|
2790
|
+
onPointerEnter: () => clearTimeout(timer.current),
|
|
2791
|
+
onPointerLeave: () => {
|
|
2792
|
+
if (e.duration) {
|
|
2793
|
+
clearTimeout(timer.current);
|
|
2794
|
+
timer.current = setTimeout(() => dismiss(e.id), resume);
|
|
2795
|
+
}
|
|
2796
|
+
}
|
|
2797
|
+
};
|
|
2798
|
+
}
|
|
2799
|
+
function ToastItem({ e }) {
|
|
2800
|
+
const { inn, ...hover } = useLife(e, 1500);
|
|
2801
|
+
return /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)("div", { className: cx("a-toast", e.type !== "info" && "a-toast--" + e.type, inn && "is-in", e.leaving && "is-out"), ...hover, children: [
|
|
2802
|
+
/* @__PURE__ */ (0, import_jsx_runtime52.jsx)("span", { className: "a-toast__dot" }),
|
|
2803
|
+
/* @__PURE__ */ (0, import_jsx_runtime52.jsx)("span", { className: "a-toast__msg", children: e.message }),
|
|
2804
|
+
/* @__PURE__ */ (0, import_jsx_runtime52.jsx)("button", { type: "button", className: "a-toast__close", "aria-label": "\u95DC\u9589", onClick: () => dismiss(e.id), children: "\xD7" })
|
|
2805
|
+
] });
|
|
2806
|
+
}
|
|
2807
|
+
var ICON = {
|
|
2808
|
+
info: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("svg", { viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("path", { d: "M12 11v6M12 7h.01" }) }),
|
|
2809
|
+
success: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("svg", { viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("path", { d: "M6 12.5l4 4L18 8" }) }),
|
|
2810
|
+
error: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("svg", { viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("path", { d: "M12 7v6M12 17h.01" }) })
|
|
2811
|
+
};
|
|
2812
|
+
function NoticeItem({ e }) {
|
|
2813
|
+
var _a;
|
|
2814
|
+
const { inn, ...hover } = useLife(e, 2e3);
|
|
2815
|
+
return /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)("div", { className: cx("a-notice", "a-notice--" + e.type, inn && "is-in", e.leaving && "is-out"), ...hover, children: [
|
|
2816
|
+
/* @__PURE__ */ (0, import_jsx_runtime52.jsx)("span", { className: "a-notice__icon", children: ICON[e.type] }),
|
|
2817
|
+
/* @__PURE__ */ (0, import_jsx_runtime52.jsxs)("div", { className: "a-notice__main", children: [
|
|
2818
|
+
/* @__PURE__ */ (0, import_jsx_runtime52.jsx)("b", { className: "a-notice__title", children: e.title }),
|
|
2819
|
+
e.text != null && /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("div", { className: "a-notice__text", children: e.text }),
|
|
2820
|
+
!!((_a = e.actions) == null ? void 0 : _a.length) && /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("div", { className: "a-notice__actions", children: e.actions.map((a, k) => /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
|
|
2821
|
+
"button",
|
|
2822
|
+
{
|
|
2823
|
+
type: "button",
|
|
2824
|
+
className: cx("a-btn", "a-btn--sm", k === 0 ? "a-btn--primary" : "a-btn--ghost"),
|
|
2825
|
+
onClick: () => {
|
|
2826
|
+
var _a2;
|
|
2827
|
+
(_a2 = a.onClick) == null ? void 0 : _a2.call(a);
|
|
2828
|
+
dismiss(e.id);
|
|
2829
|
+
},
|
|
2830
|
+
children: a.label
|
|
2831
|
+
},
|
|
2832
|
+
k
|
|
2833
|
+
)) })
|
|
2834
|
+
] }),
|
|
2835
|
+
/* @__PURE__ */ (0, import_jsx_runtime52.jsx)("button", { type: "button", className: "a-notice__close", "aria-label": "\u95DC\u9589", onClick: () => dismiss(e.id), children: "\xD7" })
|
|
2836
|
+
] });
|
|
2837
|
+
}
|
|
2838
|
+
function Toaster() {
|
|
2839
|
+
const list = React29.useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
|
|
2840
|
+
const [mounted, setMounted] = React29.useState(false);
|
|
2841
|
+
React29.useEffect(() => setMounted(true), []);
|
|
2842
|
+
if (!mounted) return null;
|
|
2843
|
+
const toasts = list.filter((e) => e.kind === "toast");
|
|
2844
|
+
const notices = list.filter((e) => e.kind === "notice").reverse();
|
|
2845
|
+
return (0, import_react_dom2.createPortal)(
|
|
2846
|
+
/* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(import_jsx_runtime52.Fragment, { children: [
|
|
2847
|
+
/* @__PURE__ */ (0, import_jsx_runtime52.jsx)("div", { className: "a-toaster", role: "status", "aria-live": "polite", children: toasts.map((e) => /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(ToastItem, { e }, e.id)) }),
|
|
2848
|
+
/* @__PURE__ */ (0, import_jsx_runtime52.jsx)("div", { className: "a-notifier", role: "region", "aria-label": "\u901A\u77E5", "aria-live": "polite", children: notices.map((e) => /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(NoticeItem, { e }, e.id)) })
|
|
2849
|
+
] }),
|
|
2850
|
+
document.body
|
|
2851
|
+
);
|
|
2852
|
+
}
|
|
2853
|
+
|
|
2854
|
+
// src/components/Alert.tsx
|
|
2855
|
+
var React30 = __toESM(require("react"), 1);
|
|
2856
|
+
var import_jsx_runtime53 = require("react/jsx-runtime");
|
|
2857
|
+
var ICONS = {
|
|
2858
|
+
info: /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("svg", { className: "a-alert__icon", viewBox: "0 0 24 24", "aria-hidden": "true", children: [
|
|
2859
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)("circle", { cx: "12", cy: "12", r: "9" }),
|
|
2860
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)("path", { d: "M12 11v5M12 8h.01" })
|
|
2861
|
+
] }),
|
|
2862
|
+
success: /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("svg", { className: "a-alert__icon", viewBox: "0 0 24 24", "aria-hidden": "true", children: [
|
|
2863
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)("circle", { cx: "12", cy: "12", r: "9" }),
|
|
2864
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)("path", { d: "M8 12.5l2.5 2.5L16 9.5" })
|
|
2865
|
+
] }),
|
|
2866
|
+
warning: /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("svg", { className: "a-alert__icon", viewBox: "0 0 24 24", "aria-hidden": "true", children: [
|
|
2867
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)("path", { d: "M12 3.5 2.5 20h19z" }),
|
|
2868
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)("path", { d: "M12 10v4M12 17h.01" })
|
|
2869
|
+
] }),
|
|
2870
|
+
error: /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("svg", { className: "a-alert__icon", viewBox: "0 0 24 24", "aria-hidden": "true", children: [
|
|
2871
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)("circle", { cx: "12", cy: "12", r: "9" }),
|
|
2872
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)("path", { d: "M15 9l-6 6M9 9l6 6" })
|
|
2873
|
+
] })
|
|
2874
|
+
};
|
|
2875
|
+
var Alert = React30.forwardRef(function Alert2({ type = "info", title, icon, className, children, role, ...rest }, ref) {
|
|
2876
|
+
return /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("div", { ref, role: role != null ? role : type === "error" ? "alert" : "status", className: cx("a-alert", type !== "info" && "a-alert--" + type, className), ...rest, children: [
|
|
2877
|
+
icon === void 0 ? ICONS[type] : icon,
|
|
2878
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("div", { className: "a-alert__content", children: [
|
|
2879
|
+
title != null && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("b", { className: "a-alert__title", children: title }),
|
|
2880
|
+
children
|
|
2881
|
+
] })
|
|
2882
|
+
] });
|
|
2883
|
+
});
|
|
2884
|
+
|
|
2885
|
+
// src/components/Progress.tsx
|
|
2886
|
+
var React31 = __toESM(require("react"), 1);
|
|
2887
|
+
var import_jsx_runtime54 = require("react/jsx-runtime");
|
|
2888
|
+
var Progress = React31.forwardRef(function Progress2({ value = 0, color = "coral", indeterminate, label, className, "aria-label": ariaLabel, ...rest }, ref) {
|
|
2889
|
+
const v = Math.min(100, Math.max(0, value));
|
|
2890
|
+
return /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("div", { ref, className: cx("a-progress", color !== "coral" && "a-progress--" + color, indeterminate && "a-progress--indeterminate", className), ...rest, children: [
|
|
2891
|
+
/* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
|
|
2892
|
+
"div",
|
|
2893
|
+
{
|
|
2894
|
+
className: "a-progress__track",
|
|
2895
|
+
role: "progressbar",
|
|
2896
|
+
"aria-label": ariaLabel,
|
|
2897
|
+
"aria-valuemin": indeterminate ? void 0 : 0,
|
|
2898
|
+
"aria-valuemax": indeterminate ? void 0 : 100,
|
|
2899
|
+
"aria-valuenow": indeterminate ? void 0 : v,
|
|
2900
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("div", { className: "a-progress__bar", style: indeterminate ? void 0 : { "--v": v / 100 } })
|
|
2901
|
+
}
|
|
2902
|
+
),
|
|
2903
|
+
label === void 0 ? indeterminate ? null : Math.round(v) + "%" : label
|
|
2904
|
+
] });
|
|
2905
|
+
});
|
|
2906
|
+
|
|
2907
|
+
// src/components/Skeleton.tsx
|
|
2908
|
+
var React32 = __toESM(require("react"), 1);
|
|
2909
|
+
var import_jsx_runtime55 = require("react/jsx-runtime");
|
|
2910
|
+
var Skeleton = React32.forwardRef(function Skeleton2({ variant = "text", width, height, className, style, ...rest }, ref) {
|
|
2911
|
+
return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
2912
|
+
"span",
|
|
2913
|
+
{
|
|
2914
|
+
ref,
|
|
2915
|
+
"aria-hidden": "true",
|
|
2916
|
+
className: cx("a-skeleton", variant !== "text" && "a-skeleton--" + variant, className),
|
|
2917
|
+
style: { width, height, ...style },
|
|
2918
|
+
...rest
|
|
2919
|
+
}
|
|
2920
|
+
);
|
|
2921
|
+
});
|
|
2922
|
+
function SkeletonGroup({ className, ...rest }) {
|
|
2923
|
+
return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("div", { className: cx("a-skeleton-group", className), "aria-busy": "true", ...rest });
|
|
2924
|
+
}
|
|
2925
|
+
|
|
2926
|
+
// src/components/Spinner.tsx
|
|
2927
|
+
var React33 = __toESM(require("react"), 1);
|
|
2928
|
+
var import_jsx_runtime56 = require("react/jsx-runtime");
|
|
2929
|
+
var Spinner = React33.forwardRef(function Spinner2({ size = "md", className, "aria-label": label = "\u8F09\u5165\u4E2D", ...rest }, ref) {
|
|
2930
|
+
return /* @__PURE__ */ (0, import_jsx_runtime56.jsx)("span", { ref, role: "status", "aria-label": label, className: cx("a-spinner", size !== "md" && "a-spinner--" + size, className), ...rest });
|
|
2931
|
+
});
|
|
2932
|
+
|
|
2933
|
+
// src/components/Popover.tsx
|
|
2934
|
+
var React34 = __toESM(require("react"), 1);
|
|
2935
|
+
var import_jsx_runtime57 = require("react/jsx-runtime");
|
|
2936
|
+
var supports = () => typeof HTMLElement !== "undefined" && "showPopover" in HTMLElement.prototype;
|
|
2937
|
+
function Popover({ children, content, title, footer, open, defaultOpen = false, onOpenChange, className, style, ...rest }) {
|
|
2938
|
+
const [isOpen, setOpen] = useControllable(open, defaultOpen, onOpenChange);
|
|
2939
|
+
const popRef = React34.useRef(null);
|
|
2940
|
+
const trigRef = React34.useRef(null);
|
|
2941
|
+
const id = useId2("pop");
|
|
2942
|
+
const [native, setNative] = React34.useState(true);
|
|
2943
|
+
const place = React34.useCallback(() => {
|
|
2944
|
+
const pop = popRef.current, inv = trigRef.current;
|
|
2945
|
+
if (!pop || !inv) return;
|
|
2946
|
+
const r = inv.getBoundingClientRect(), w = pop.offsetWidth, h = pop.offsetHeight;
|
|
2947
|
+
let left = r.left;
|
|
2948
|
+
if (w && left + w > window.innerWidth - 16) left = Math.max(16, r.right - w);
|
|
2949
|
+
const below = r.bottom + 8;
|
|
2950
|
+
const top = h && below + h > window.innerHeight - 16 && r.top - 8 - h > 16 ? r.top - 8 - h : below;
|
|
2951
|
+
pop.style.left = left + "px";
|
|
2952
|
+
pop.style.top = top + "px";
|
|
2953
|
+
}, []);
|
|
2954
|
+
React34.useEffect(() => {
|
|
2955
|
+
setNative(supports());
|
|
2956
|
+
}, []);
|
|
2957
|
+
React34.useLayoutEffect(() => {
|
|
2958
|
+
var _a, _b;
|
|
2959
|
+
const pop = popRef.current;
|
|
2960
|
+
if (!pop || !native) return;
|
|
2961
|
+
const shown = pop.matches(":popover-open");
|
|
2962
|
+
if (isOpen && !shown) {
|
|
2963
|
+
(_a = pop.showPopover) == null ? void 0 : _a.call(pop);
|
|
2964
|
+
place();
|
|
2965
|
+
}
|
|
2966
|
+
if (!isOpen && shown) (_b = pop.hidePopover) == null ? void 0 : _b.call(pop);
|
|
2967
|
+
}, [isOpen, native, place]);
|
|
2968
|
+
React34.useEffect(() => {
|
|
2969
|
+
const pop = popRef.current;
|
|
2970
|
+
if (!pop || !native) return;
|
|
2971
|
+
const onToggle = (e) => {
|
|
2972
|
+
const ns = e.newState;
|
|
2973
|
+
if (ns === "open") place();
|
|
2974
|
+
if (ns === "closed" && isOpen) setOpen(false);
|
|
2975
|
+
};
|
|
2976
|
+
pop.addEventListener("toggle", onToggle);
|
|
2977
|
+
return () => pop.removeEventListener("toggle", onToggle);
|
|
2978
|
+
}, [native, isOpen, setOpen, place]);
|
|
2979
|
+
React34.useEffect(() => {
|
|
2980
|
+
if (native || !isOpen) return;
|
|
2981
|
+
place();
|
|
2982
|
+
const onDoc = (e) => {
|
|
2983
|
+
var _a, _b;
|
|
2984
|
+
const t = e.target;
|
|
2985
|
+
if (!((_a = popRef.current) == null ? void 0 : _a.contains(t)) && !((_b = trigRef.current) == null ? void 0 : _b.contains(t))) setOpen(false);
|
|
2986
|
+
};
|
|
2987
|
+
const onKey = (e) => {
|
|
2988
|
+
if (e.key === "Escape") setOpen(false);
|
|
2989
|
+
};
|
|
2990
|
+
document.addEventListener("mousedown", onDoc);
|
|
2991
|
+
document.addEventListener("keydown", onKey);
|
|
2992
|
+
return () => {
|
|
2993
|
+
document.removeEventListener("mousedown", onDoc);
|
|
2994
|
+
document.removeEventListener("keydown", onKey);
|
|
2995
|
+
};
|
|
2996
|
+
}, [native, isOpen, setOpen, place]);
|
|
2997
|
+
React34.useEffect(() => {
|
|
2998
|
+
if (!isOpen) return;
|
|
2999
|
+
window.addEventListener("scroll", place, { passive: true, capture: true });
|
|
3000
|
+
window.addEventListener("resize", place);
|
|
3001
|
+
return () => {
|
|
3002
|
+
window.removeEventListener("scroll", place, { capture: true });
|
|
3003
|
+
window.removeEventListener("resize", place);
|
|
3004
|
+
};
|
|
3005
|
+
}, [isOpen, place]);
|
|
3006
|
+
const trig = children;
|
|
3007
|
+
const trigger = React34.cloneElement(trig, {
|
|
3008
|
+
ref: (el) => {
|
|
3009
|
+
trigRef.current = el;
|
|
3010
|
+
},
|
|
3011
|
+
"aria-expanded": isOpen,
|
|
3012
|
+
"aria-controls": id,
|
|
3013
|
+
"aria-haspopup": "dialog",
|
|
3014
|
+
onClick: (e) => {
|
|
3015
|
+
var _a, _b, _c;
|
|
3016
|
+
(_b = (_a = trig.props).onClick) == null ? void 0 : _b.call(_a, e);
|
|
3017
|
+
const shown = native ? !!((_c = popRef.current) == null ? void 0 : _c.matches(":popover-open")) : isOpen;
|
|
3018
|
+
setOpen(!shown);
|
|
3019
|
+
}
|
|
3020
|
+
});
|
|
3021
|
+
const fallbackStyle = native ? void 0 : { display: isOpen ? "block" : "none", opacity: 1, transform: "none", zIndex: 60 };
|
|
3022
|
+
return /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(import_jsx_runtime57.Fragment, { children: [
|
|
3023
|
+
trigger,
|
|
3024
|
+
/* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(
|
|
3025
|
+
"div",
|
|
3026
|
+
{
|
|
3027
|
+
ref: popRef,
|
|
3028
|
+
id,
|
|
3029
|
+
role: "dialog",
|
|
3030
|
+
...native ? { popover: "auto" } : {},
|
|
3031
|
+
className: cx("a-popover", className),
|
|
3032
|
+
style: { ...fallbackStyle, ...style },
|
|
3033
|
+
...rest,
|
|
3034
|
+
children: [
|
|
3035
|
+
title != null && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("b", { className: "a-popover__title", children: title }),
|
|
3036
|
+
content,
|
|
3037
|
+
footer != null && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("div", { className: "a-popover__footer", children: footer })
|
|
3038
|
+
]
|
|
3039
|
+
}
|
|
3040
|
+
)
|
|
3041
|
+
] });
|
|
3042
|
+
}
|
|
3043
|
+
|
|
3044
|
+
// src/components/Result.tsx
|
|
3045
|
+
var React35 = __toESM(require("react"), 1);
|
|
3046
|
+
var import_jsx_runtime58 = require("react/jsx-runtime");
|
|
3047
|
+
var ICONS2 = {
|
|
3048
|
+
success: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("path", { d: "M6 12.5l4 4L18 8" }) }),
|
|
3049
|
+
error: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("path", { d: "M7 7l10 10M17 7 7 17" }) }),
|
|
3050
|
+
info: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("path", { d: "M12 11v6M12 7h.01" }) })
|
|
3051
|
+
};
|
|
3052
|
+
var Result = React35.forwardRef(function Result2({ status = "success", title, description, actions, icon, className, children, ...rest }, ref) {
|
|
3053
|
+
return /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)("div", { ref, className: cx("a-result", status !== "success" && "a-result--" + status, className), ...rest, children: [
|
|
3054
|
+
/* @__PURE__ */ (0, import_jsx_runtime58.jsx)("div", { className: "a-result__icon", children: icon != null ? icon : ICONS2[status] }),
|
|
3055
|
+
/* @__PURE__ */ (0, import_jsx_runtime58.jsx)("h3", { className: "a-result__title", children: title }),
|
|
3056
|
+
description != null && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("p", { className: "a-result__text", children: description }),
|
|
3057
|
+
children,
|
|
3058
|
+
actions != null && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("div", { className: "a-result__actions", children: actions })
|
|
3059
|
+
] });
|
|
3060
|
+
});
|
|
3061
|
+
|
|
3062
|
+
// src/components/Banner.tsx
|
|
3063
|
+
var React36 = __toESM(require("react"), 1);
|
|
3064
|
+
var import_jsx_runtime59 = require("react/jsx-runtime");
|
|
3065
|
+
function Banner({ color = "navy", flush, tag, closable = true, onClose, className, children, ...rest }) {
|
|
3066
|
+
const [state, setState] = React36.useState("open");
|
|
3067
|
+
const reduce = useReducedMotion();
|
|
3068
|
+
React36.useEffect(() => {
|
|
3069
|
+
if (state !== "closing") return;
|
|
3070
|
+
const t = setTimeout(() => {
|
|
3071
|
+
setState("closed");
|
|
3072
|
+
onClose == null ? void 0 : onClose();
|
|
3073
|
+
}, reduce ? 0 : 200);
|
|
3074
|
+
return () => clearTimeout(t);
|
|
3075
|
+
}, [state, reduce, onClose]);
|
|
3076
|
+
if (state === "closed") return null;
|
|
3077
|
+
return /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)("div", { role: "region", "aria-label": "\u516C\u544A", className: cx("a-banner", color === "coral" && "a-banner--coral", flush && "a-banner--flush", state === "closing" && "is-closing", className), ...rest, children: [
|
|
3078
|
+
tag != null && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("span", { className: "a-banner__tag", children: tag }),
|
|
3079
|
+
/* @__PURE__ */ (0, import_jsx_runtime59.jsx)("span", { children }),
|
|
3080
|
+
closable && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("button", { type: "button", className: "a-banner__close", "aria-label": "\u95DC\u9589\u516C\u544A", onClick: () => setState("closing"), children: "\xD7" })
|
|
3081
|
+
] });
|
|
3082
|
+
}
|
|
3083
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
3084
|
+
0 && (module.exports = {
|
|
3085
|
+
Alert,
|
|
3086
|
+
Autocomplete,
|
|
3087
|
+
Avatar,
|
|
3088
|
+
AvatarGroup,
|
|
3089
|
+
BackTop,
|
|
3090
|
+
Badge,
|
|
3091
|
+
Banner,
|
|
3092
|
+
Breadcrumb,
|
|
3093
|
+
Button,
|
|
3094
|
+
Calendar,
|
|
3095
|
+
Card,
|
|
3096
|
+
Carousel,
|
|
3097
|
+
Cascader,
|
|
3098
|
+
Checkbox,
|
|
3099
|
+
CheckboxGroup,
|
|
3100
|
+
Collapse,
|
|
3101
|
+
ColorPicker,
|
|
3102
|
+
ColorSwatches,
|
|
3103
|
+
CommandPalette,
|
|
3104
|
+
ContextMenu,
|
|
3105
|
+
DataTable,
|
|
3106
|
+
DatePicker,
|
|
3107
|
+
DateRangeInputs,
|
|
3108
|
+
Descriptions,
|
|
3109
|
+
Divider,
|
|
3110
|
+
Drawer,
|
|
3111
|
+
Dropdown,
|
|
3112
|
+
Empty,
|
|
3113
|
+
Field,
|
|
3114
|
+
FloatButton,
|
|
3115
|
+
ImagePreview,
|
|
3116
|
+
Input,
|
|
3117
|
+
InputNumber,
|
|
3118
|
+
Kbd,
|
|
3119
|
+
KbdCombo,
|
|
3120
|
+
List,
|
|
3121
|
+
Menu,
|
|
3122
|
+
Modal,
|
|
3123
|
+
OtpInput,
|
|
3124
|
+
Pagination,
|
|
3125
|
+
Popover,
|
|
3126
|
+
Progress,
|
|
3127
|
+
Radio,
|
|
3128
|
+
RadioGroup,
|
|
3129
|
+
RangePicker,
|
|
3130
|
+
Rating,
|
|
3131
|
+
Result,
|
|
3132
|
+
Segmented,
|
|
3133
|
+
Select,
|
|
3134
|
+
Skeleton,
|
|
3135
|
+
SkeletonGroup,
|
|
3136
|
+
Slider,
|
|
3137
|
+
Spinner,
|
|
3138
|
+
StatRow,
|
|
3139
|
+
Statistic,
|
|
3140
|
+
Steps,
|
|
3141
|
+
Switch,
|
|
3142
|
+
Table,
|
|
3143
|
+
Tabs,
|
|
3144
|
+
Tag,
|
|
3145
|
+
TagInput,
|
|
3146
|
+
Textarea,
|
|
3147
|
+
ThemeProvider,
|
|
3148
|
+
Timeline,
|
|
3149
|
+
Toaster,
|
|
3150
|
+
Tooltip,
|
|
3151
|
+
Transfer,
|
|
3152
|
+
Tree,
|
|
3153
|
+
Upload,
|
|
3154
|
+
cx,
|
|
3155
|
+
normOption,
|
|
3156
|
+
notify,
|
|
3157
|
+
pageWindow,
|
|
3158
|
+
toast,
|
|
3159
|
+
useControllable,
|
|
3160
|
+
useId,
|
|
3161
|
+
useReducedMotion
|
|
3162
|
+
});
|
|
3163
|
+
//# sourceMappingURL=index.cjs.map
|