@q1travel/design-system 0.6.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { jsxs as i, jsx as e, Fragment as
|
|
2
|
-
import { forwardRef as ot, createElement as Be, createContext as it, useContext as ct, useState as
|
|
1
|
+
import { jsxs as i, jsx as e, Fragment as ee } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as ot, createElement as Be, createContext as it, useContext as ct, useState as A, useRef as q, useCallback as Ne, useEffect as O, useLayoutEffect as fe, useMemo as ie, useId as P, isValidElement as Ze, Fragment as Qe, cloneElement as Tt } from "react";
|
|
3
3
|
import { createPortal as dt } from "react-dom";
|
|
4
4
|
const zt = (t) => t.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), ut = (...t) => t.filter((n, r, a) => !!n && n.trim() !== "" && a.indexOf(n) === r).join(" ").trim();
|
|
5
5
|
var Rt = {
|
|
@@ -41,7 +41,7 @@ const Lt = ot(
|
|
|
41
41
|
]
|
|
42
42
|
)
|
|
43
43
|
);
|
|
44
|
-
const
|
|
44
|
+
const W = (t, n) => {
|
|
45
45
|
const r = ot(
|
|
46
46
|
({ className: a, ...s }, l) => Be(Lt, {
|
|
47
47
|
ref: l,
|
|
@@ -52,69 +52,69 @@ const L = (t, n) => {
|
|
|
52
52
|
);
|
|
53
53
|
return r.displayName = `${t}`, r;
|
|
54
54
|
};
|
|
55
|
-
const Wt =
|
|
55
|
+
const Wt = W("ArrowLeft", [
|
|
56
56
|
["path", { d: "m12 19-7-7 7-7", key: "1l729n" }],
|
|
57
57
|
["path", { d: "M19 12H5", key: "x3x0zl" }]
|
|
58
58
|
]);
|
|
59
|
-
const mt =
|
|
59
|
+
const mt = W("ArrowRight", [
|
|
60
60
|
["path", { d: "M5 12h14", key: "1ays0h" }],
|
|
61
61
|
["path", { d: "m12 5 7 7-7 7", key: "xquz4c" }]
|
|
62
62
|
]);
|
|
63
|
-
const Ft =
|
|
63
|
+
const Ft = W("Calendar", [
|
|
64
64
|
["path", { d: "M8 2v4", key: "1cmpym" }],
|
|
65
65
|
["path", { d: "M16 2v4", key: "4m81vk" }],
|
|
66
66
|
["rect", { width: "18", height: "18", x: "3", y: "4", rx: "2", key: "1hopcy" }],
|
|
67
67
|
["path", { d: "M3 10h18", key: "8toen8" }]
|
|
68
68
|
]);
|
|
69
|
-
const
|
|
70
|
-
const ae =
|
|
69
|
+
const ce = W("Check", [["path", { d: "M20 6 9 17l-5-5", key: "1gmf2c" }]]);
|
|
70
|
+
const ae = W("ChevronDown", [
|
|
71
71
|
["path", { d: "m6 9 6 6 6-6", key: "qrunsl" }]
|
|
72
72
|
]);
|
|
73
|
-
const Ue =
|
|
73
|
+
const Ue = W("ChevronLeft", [
|
|
74
74
|
["path", { d: "m15 18-6-6 6-6", key: "1wnfg3" }]
|
|
75
75
|
]);
|
|
76
|
-
const
|
|
76
|
+
const me = W("ChevronRight", [
|
|
77
77
|
["path", { d: "m9 18 6-6-6-6", key: "mthhwq" }]
|
|
78
78
|
]);
|
|
79
|
-
const ht =
|
|
80
|
-
const Ve =
|
|
79
|
+
const ht = W("ChevronUp", [["path", { d: "m18 15-6-6-6 6", key: "153udz" }]]);
|
|
80
|
+
const Ve = W("CircleAlert", [
|
|
81
81
|
["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
|
|
82
82
|
["line", { x1: "12", x2: "12", y1: "8", y2: "12", key: "1pkeuh" }],
|
|
83
83
|
["line", { x1: "12", x2: "12.01", y1: "16", y2: "16", key: "4dfq90" }]
|
|
84
84
|
]);
|
|
85
|
-
const pt =
|
|
85
|
+
const pt = W("CircleCheck", [
|
|
86
86
|
["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
|
|
87
87
|
["path", { d: "m9 12 2 2 4-4", key: "dzmm74" }]
|
|
88
88
|
]);
|
|
89
|
-
const ft =
|
|
89
|
+
const ft = W("CircleX", [
|
|
90
90
|
["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
|
|
91
91
|
["path", { d: "m15 9-6 6", key: "1uzhvr" }],
|
|
92
92
|
["path", { d: "m9 9 6 6", key: "z0biqf" }]
|
|
93
93
|
]);
|
|
94
|
-
const Kt =
|
|
94
|
+
const Kt = W("Clock", [
|
|
95
95
|
["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
|
|
96
96
|
["polyline", { points: "12 6 12 12 16 14", key: "68esgv" }]
|
|
97
97
|
]);
|
|
98
|
-
const we =
|
|
98
|
+
const we = W("Copy", [
|
|
99
99
|
["rect", { width: "14", height: "14", x: "8", y: "8", rx: "2", ry: "2", key: "17jyea" }],
|
|
100
100
|
["path", { d: "M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2", key: "zix9uf" }]
|
|
101
101
|
]);
|
|
102
|
-
const _t =
|
|
102
|
+
const _t = W("Ellipsis", [
|
|
103
103
|
["circle", { cx: "12", cy: "12", r: "1", key: "41hilf" }],
|
|
104
104
|
["circle", { cx: "19", cy: "12", r: "1", key: "1wjl8i" }],
|
|
105
105
|
["circle", { cx: "5", cy: "12", r: "1", key: "1pcz8c" }]
|
|
106
106
|
]);
|
|
107
|
-
const Je =
|
|
107
|
+
const Je = W("FileCode", [
|
|
108
108
|
["path", { d: "M10 12.5 8 15l2 2.5", key: "1tg20x" }],
|
|
109
109
|
["path", { d: "m14 12.5 2 2.5-2 2.5", key: "yinavb" }],
|
|
110
110
|
["path", { d: "M14 2v4a2 2 0 0 0 2 2h4", key: "tnqrlb" }],
|
|
111
111
|
["path", { d: "M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7z", key: "1mlx9k" }]
|
|
112
112
|
]);
|
|
113
|
-
const Pt =
|
|
113
|
+
const Pt = W("File", [
|
|
114
114
|
["path", { d: "M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z", key: "1rqfz7" }],
|
|
115
115
|
["path", { d: "M14 2v4a2 2 0 0 0 2 2h4", key: "tnqrlb" }]
|
|
116
116
|
]);
|
|
117
|
-
const Ot =
|
|
117
|
+
const Ot = W("FolderOpen", [
|
|
118
118
|
[
|
|
119
119
|
"path",
|
|
120
120
|
{
|
|
@@ -123,7 +123,7 @@ const Ot = L("FolderOpen", [
|
|
|
123
123
|
}
|
|
124
124
|
]
|
|
125
125
|
]);
|
|
126
|
-
const Bt =
|
|
126
|
+
const Bt = W("Folder", [
|
|
127
127
|
[
|
|
128
128
|
"path",
|
|
129
129
|
{
|
|
@@ -132,13 +132,13 @@ const Bt = L("Folder", [
|
|
|
132
132
|
}
|
|
133
133
|
]
|
|
134
134
|
]);
|
|
135
|
-
const Ht =
|
|
135
|
+
const Ht = W("Frown", [
|
|
136
136
|
["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
|
|
137
137
|
["path", { d: "M16 16s-1.5-2-4-2-4 2-4 2", key: "epbg0q" }],
|
|
138
138
|
["line", { x1: "9", x2: "9.01", y1: "9", y2: "9", key: "yxxnd0" }],
|
|
139
139
|
["line", { x1: "15", x2: "15.01", y1: "9", y2: "9", key: "1p4y9e" }]
|
|
140
140
|
]);
|
|
141
|
-
const jt =
|
|
141
|
+
const jt = W("Heart", [
|
|
142
142
|
[
|
|
143
143
|
"path",
|
|
144
144
|
{
|
|
@@ -147,41 +147,41 @@ const jt = L("Heart", [
|
|
|
147
147
|
}
|
|
148
148
|
]
|
|
149
149
|
]);
|
|
150
|
-
const qe =
|
|
150
|
+
const qe = W("Info", [
|
|
151
151
|
["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
|
|
152
152
|
["path", { d: "M12 16v-4", key: "1dtifu" }],
|
|
153
153
|
["path", { d: "M12 8h.01", key: "e9boi3" }]
|
|
154
154
|
]);
|
|
155
|
-
const ve =
|
|
155
|
+
const ve = W("LoaderCircle", [
|
|
156
156
|
["path", { d: "M21 12a9 9 0 1 1-6.219-8.56", key: "13zald" }]
|
|
157
157
|
]);
|
|
158
|
-
const Ut =
|
|
158
|
+
const Ut = W("Lock", [
|
|
159
159
|
["rect", { width: "18", height: "11", x: "3", y: "11", rx: "2", ry: "2", key: "1w4ew1" }],
|
|
160
160
|
["path", { d: "M7 11V7a5 5 0 0 1 10 0v4", key: "fwvmzm" }]
|
|
161
161
|
]);
|
|
162
|
-
const Vt =
|
|
162
|
+
const Vt = W("Meh", [
|
|
163
163
|
["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
|
|
164
164
|
["line", { x1: "8", x2: "16", y1: "15", y2: "15", key: "1xb1d9" }],
|
|
165
165
|
["line", { x1: "9", x2: "9.01", y1: "9", y2: "9", key: "yxxnd0" }],
|
|
166
166
|
["line", { x1: "15", x2: "15.01", y1: "9", y2: "9", key: "1p4y9e" }]
|
|
167
167
|
]);
|
|
168
|
-
const Gt =
|
|
168
|
+
const Gt = W("Monitor", [
|
|
169
169
|
["rect", { width: "20", height: "14", x: "2", y: "3", rx: "2", key: "48i651" }],
|
|
170
170
|
["line", { x1: "8", x2: "16", y1: "21", y2: "21", key: "1svkeh" }],
|
|
171
171
|
["line", { x1: "12", x2: "12", y1: "17", y2: "21", key: "vw1qmm" }]
|
|
172
172
|
]);
|
|
173
|
-
const Yt =
|
|
173
|
+
const Yt = W("Moon", [
|
|
174
174
|
["path", { d: "M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z", key: "a7tn18" }]
|
|
175
175
|
]);
|
|
176
|
-
const Xt =
|
|
176
|
+
const Xt = W("RotateCw", [
|
|
177
177
|
["path", { d: "M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8", key: "1p45f6" }],
|
|
178
178
|
["path", { d: "M21 3v5h-5", key: "1q7to0" }]
|
|
179
179
|
]);
|
|
180
|
-
const Ie =
|
|
180
|
+
const Ie = W("Search", [
|
|
181
181
|
["circle", { cx: "11", cy: "11", r: "8", key: "4ej97u" }],
|
|
182
182
|
["path", { d: "m21 21-4.3-4.3", key: "1qie3q" }]
|
|
183
183
|
]);
|
|
184
|
-
const Zt =
|
|
184
|
+
const Zt = W("ShieldCheck", [
|
|
185
185
|
[
|
|
186
186
|
"path",
|
|
187
187
|
{
|
|
@@ -191,13 +191,13 @@ const Zt = L("ShieldCheck", [
|
|
|
191
191
|
],
|
|
192
192
|
["path", { d: "m9 12 2 2 4-4", key: "dzmm74" }]
|
|
193
193
|
]);
|
|
194
|
-
const Qt =
|
|
194
|
+
const Qt = W("Smile", [
|
|
195
195
|
["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
|
|
196
196
|
["path", { d: "M8 14s1.5 2 4 2 4-2 4-2", key: "1y1vjs" }],
|
|
197
197
|
["line", { x1: "9", x2: "9.01", y1: "9", y2: "9", key: "yxxnd0" }],
|
|
198
198
|
["line", { x1: "15", x2: "15.01", y1: "9", y2: "9", key: "1p4y9e" }]
|
|
199
199
|
]);
|
|
200
|
-
const Jt =
|
|
200
|
+
const Jt = W("Sun", [
|
|
201
201
|
["circle", { cx: "12", cy: "12", r: "4", key: "4exip2" }],
|
|
202
202
|
["path", { d: "M12 2v2", key: "tus03m" }],
|
|
203
203
|
["path", { d: "M12 20v2", key: "1lh1kg" }],
|
|
@@ -208,7 +208,7 @@ const Jt = L("Sun", [
|
|
|
208
208
|
["path", { d: "m6.34 17.66-1.41 1.41", key: "1m8zz5" }],
|
|
209
209
|
["path", { d: "m19.07 4.93-1.41 1.41", key: "1shlcs" }]
|
|
210
210
|
]);
|
|
211
|
-
const Ae =
|
|
211
|
+
const Ae = W("TriangleAlert", [
|
|
212
212
|
[
|
|
213
213
|
"path",
|
|
214
214
|
{
|
|
@@ -219,7 +219,7 @@ const Ae = L("TriangleAlert", [
|
|
|
219
219
|
["path", { d: "M12 9v4", key: "juzpu7" }],
|
|
220
220
|
["path", { d: "M12 17h.01", key: "p32p05" }]
|
|
221
221
|
]);
|
|
222
|
-
const _e =
|
|
222
|
+
const _e = W("X", [
|
|
223
223
|
["path", { d: "M18 6 6 18", key: "1bl5f8" }],
|
|
224
224
|
["path", { d: "m6 6 12 12", key: "d8bk6v" }]
|
|
225
225
|
]), en = {
|
|
@@ -234,13 +234,13 @@ function tn() {
|
|
|
234
234
|
return t;
|
|
235
235
|
}
|
|
236
236
|
function jn({ children: t }) {
|
|
237
|
-
const [n, r] =
|
|
238
|
-
const
|
|
239
|
-
|
|
237
|
+
const [n, r] = A([]), a = q(0), s = q(/* @__PURE__ */ new Map()), l = q(!1), o = q(null), [u, d] = A(!1), p = Ne((g) => {
|
|
238
|
+
const w = s.current.get(g);
|
|
239
|
+
w && (window.clearTimeout(w.handle), s.current.delete(g)), r((b) => b.filter((N) => N.id !== g));
|
|
240
240
|
}, []), c = Ne(
|
|
241
|
-
({ tone: g = "default", title:
|
|
241
|
+
({ tone: g = "default", title: w, description: b, actionLabel: N, preserve: v, duration: D = 4e3 }) => {
|
|
242
242
|
const C = a.current += 1;
|
|
243
|
-
if (r((h) => [...h, { id: C, tone: g, title:
|
|
243
|
+
if (r((h) => [...h, { id: C, tone: g, title: w, description: b, actionLabel: N, preserve: v }]), !v) {
|
|
244
244
|
const h = l.current ? 0 : window.setTimeout(() => p(C), D);
|
|
245
245
|
s.current.set(C, { remaining: D, start: Date.now(), handle: h });
|
|
246
246
|
}
|
|
@@ -251,19 +251,19 @@ function jn({ children: t }) {
|
|
|
251
251
|
if (l.current) return;
|
|
252
252
|
l.current = !0;
|
|
253
253
|
const g = Date.now();
|
|
254
|
-
s.current.forEach((
|
|
255
|
-
window.clearTimeout(
|
|
254
|
+
s.current.forEach((w) => {
|
|
255
|
+
window.clearTimeout(w.handle), w.remaining = Math.max(0, w.remaining - (g - w.start));
|
|
256
256
|
});
|
|
257
257
|
}
|
|
258
258
|
function _() {
|
|
259
259
|
if (!l.current) return;
|
|
260
260
|
l.current = !1;
|
|
261
261
|
const g = Date.now();
|
|
262
|
-
s.current.forEach((
|
|
263
|
-
|
|
262
|
+
s.current.forEach((w, b) => {
|
|
263
|
+
w.start = g, w.handle = window.setTimeout(() => p(b), w.remaining);
|
|
264
264
|
});
|
|
265
265
|
}
|
|
266
|
-
|
|
266
|
+
O(
|
|
267
267
|
() => () => {
|
|
268
268
|
s.current.forEach((g) => window.clearTimeout(g.handle));
|
|
269
269
|
},
|
|
@@ -271,16 +271,16 @@ function jn({ children: t }) {
|
|
|
271
271
|
), fe(() => {
|
|
272
272
|
const g = o.current;
|
|
273
273
|
if (!g) return;
|
|
274
|
-
const
|
|
274
|
+
const w = [...g.querySelectorAll(".q1-toast")], b = 12, N = 14;
|
|
275
275
|
let v = 0, D = 0;
|
|
276
|
-
for (let x =
|
|
277
|
-
const
|
|
278
|
-
|
|
276
|
+
for (let x = w.length - 1; x >= 0; x -= 1) {
|
|
277
|
+
const y = w[x], k = w.length - 1 - x;
|
|
278
|
+
k === 0 && (D = y.offsetHeight), y.style.setProperty("--depth", String(k)), y.style.setProperty("--y", `${-v}px`), y.style.zIndex = String(100 + x), v += y.offsetHeight + b;
|
|
279
279
|
}
|
|
280
|
-
const C = D + Math.min(
|
|
280
|
+
const C = D + Math.min(w.length - 1, 2) * N, h = w.length === 0 ? 0 : u ? Math.max(v - b, 0) : C;
|
|
281
281
|
g.style.setProperty("--toast-stack-h", `${h}px`);
|
|
282
282
|
}, [n, u]);
|
|
283
|
-
const m =
|
|
283
|
+
const m = ie(() => ({ push: c, dismiss: p }), [c, p]);
|
|
284
284
|
return /* @__PURE__ */ i(bt.Provider, { value: m, children: [
|
|
285
285
|
t,
|
|
286
286
|
/* @__PURE__ */ e(
|
|
@@ -305,9 +305,9 @@ function jn({ children: t }) {
|
|
|
305
305
|
g.currentTarget.contains(g.relatedTarget) || (d(!1), _());
|
|
306
306
|
},
|
|
307
307
|
children: n.map((g) => {
|
|
308
|
-
const
|
|
308
|
+
const w = g.tone === "default" ? null : en[g.tone];
|
|
309
309
|
return /* @__PURE__ */ i("div", { className: `q1-toast q1-toast--${g.tone}`, "aria-atomic": "true", children: [
|
|
310
|
-
|
|
310
|
+
w ? /* @__PURE__ */ e(w, { className: "q1-toast__icon", size: 16, strokeWidth: 2, "aria-hidden": "true" }) : null,
|
|
311
311
|
/* @__PURE__ */ i("div", { className: "q1-toast__body", children: [
|
|
312
312
|
/* @__PURE__ */ e("p", { className: "q1-toast__title", children: g.title }),
|
|
313
313
|
g.description ? /* @__PURE__ */ e("p", { className: "q1-toast__description", children: g.description }) : null
|
|
@@ -339,7 +339,7 @@ async function gt(t) {
|
|
|
339
339
|
}
|
|
340
340
|
}
|
|
341
341
|
function Se() {
|
|
342
|
-
const [t, n] =
|
|
342
|
+
const [t, n] = A(!1), r = q(void 0), { push: a } = tn(), s = Ne(
|
|
343
343
|
async (o, u = "已复制到剪贴板") => {
|
|
344
344
|
try {
|
|
345
345
|
await gt(o), n(!0), r.current && clearTimeout(r.current), r.current = setTimeout(() => n(!1), 1500), a({ title: u });
|
|
@@ -368,7 +368,7 @@ function Un({
|
|
|
368
368
|
className: s ? `copy-button ${s}` : "copy-button",
|
|
369
369
|
"aria-label": n,
|
|
370
370
|
onClick: () => o(t, r),
|
|
371
|
-
children: l ? /* @__PURE__ */ e(
|
|
371
|
+
children: l ? /* @__PURE__ */ e(ce, { size: a, strokeWidth: 2, "aria-hidden": "true" }) : /* @__PURE__ */ e(we, { size: a, strokeWidth: 2, "aria-hidden": "true" })
|
|
372
372
|
}
|
|
373
373
|
);
|
|
374
374
|
}
|
|
@@ -416,7 +416,7 @@ function Nt({
|
|
|
416
416
|
suffix: s,
|
|
417
417
|
shortcut: l
|
|
418
418
|
}) {
|
|
419
|
-
return /* @__PURE__ */ i(
|
|
419
|
+
return /* @__PURE__ */ i(ee, { children: [
|
|
420
420
|
t ? /* @__PURE__ */ i("span", { role: "status", children: [
|
|
421
421
|
/* @__PURE__ */ e(ve, { className: "button__spinner", size: 14, strokeWidth: 1.8, "aria-hidden": "true" }),
|
|
422
422
|
/* @__PURE__ */ e("span", { className: "q1-sr-only", children: n || "加载中…" })
|
|
@@ -428,41 +428,62 @@ function Nt({
|
|
|
428
428
|
}
|
|
429
429
|
function kt(t) {
|
|
430
430
|
const {
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
431
|
+
variant: n,
|
|
432
|
+
size: r,
|
|
433
|
+
svgOnly: a,
|
|
434
|
+
iconOnly: s,
|
|
435
|
+
circle: l,
|
|
436
|
+
rounded: o,
|
|
437
|
+
loading: u,
|
|
438
|
+
loadingLabel: d,
|
|
439
|
+
disabled: p,
|
|
440
|
+
type: c = "button",
|
|
441
|
+
shortcut: f,
|
|
442
|
+
className: _,
|
|
443
|
+
children: m,
|
|
444
|
+
prefix: g,
|
|
445
|
+
suffix: w,
|
|
446
|
+
onClick: b,
|
|
447
|
+
"aria-label": N,
|
|
448
|
+
ariaLabel: v,
|
|
449
|
+
ariaKeyshortcuts: D,
|
|
450
|
+
"aria-keyshortcuts": C,
|
|
451
|
+
"aria-describedby": h,
|
|
452
|
+
"aria-disabled": x,
|
|
453
|
+
tabIndex: y,
|
|
454
|
+
onFocus: k,
|
|
455
|
+
onBlur: $,
|
|
456
|
+
onKeyDown: I,
|
|
457
|
+
ref: S,
|
|
458
|
+
...L
|
|
459
|
+
} = t, F = yt({
|
|
460
|
+
variant: n,
|
|
461
|
+
size: r,
|
|
462
|
+
svgOnly: a,
|
|
463
|
+
iconOnly: s,
|
|
464
|
+
circle: l,
|
|
465
|
+
rounded: o,
|
|
466
|
+
loading: u,
|
|
467
|
+
className: _
|
|
468
|
+
}), G = N ?? v, X = C ?? D, V = u && !p;
|
|
449
469
|
return /* @__PURE__ */ e(
|
|
450
470
|
"button",
|
|
451
471
|
{
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
"aria-
|
|
460
|
-
"aria-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
472
|
+
...L,
|
|
473
|
+
ref: S,
|
|
474
|
+
type: c,
|
|
475
|
+
className: F,
|
|
476
|
+
disabled: p || void 0,
|
|
477
|
+
"aria-disabled": V ? !0 : x,
|
|
478
|
+
tabIndex: V ? 0 : y,
|
|
479
|
+
"aria-label": G,
|
|
480
|
+
"aria-keyshortcuts": X,
|
|
481
|
+
"aria-describedby": h,
|
|
482
|
+
onClick: u ? (re) => re.preventDefault() : b,
|
|
483
|
+
onFocus: k,
|
|
484
|
+
onBlur: $,
|
|
485
|
+
onKeyDown: I,
|
|
486
|
+
children: Nt({ loading: u, loadingLabel: d, prefix: g, children: m, suffix: w, shortcut: f })
|
|
466
487
|
}
|
|
467
488
|
);
|
|
468
489
|
}
|
|
@@ -482,9 +503,9 @@ function Vn(t) {
|
|
|
482
503
|
ariaLabel: _,
|
|
483
504
|
ariaKeyshortcuts: m,
|
|
484
505
|
"aria-describedby": g,
|
|
485
|
-
onFocus:
|
|
506
|
+
onFocus: w,
|
|
486
507
|
onBlur: b,
|
|
487
|
-
onKeyDown:
|
|
508
|
+
onKeyDown: N,
|
|
488
509
|
ref: v
|
|
489
510
|
} = t, D = yt(t), C = s || r;
|
|
490
511
|
return /* @__PURE__ */ e(
|
|
@@ -499,15 +520,16 @@ function Vn(t) {
|
|
|
499
520
|
"aria-keyshortcuts": m,
|
|
500
521
|
"aria-describedby": g,
|
|
501
522
|
onClick: C ? (x) => x.preventDefault() : c,
|
|
502
|
-
onFocus:
|
|
523
|
+
onFocus: w,
|
|
503
524
|
onBlur: b,
|
|
504
|
-
onKeyDown:
|
|
525
|
+
onKeyDown: N,
|
|
505
526
|
children: Nt({ loading: r, loadingLabel: a, prefix: d, children: u, suffix: p, shortcut: o })
|
|
506
527
|
}
|
|
507
528
|
);
|
|
508
529
|
}
|
|
509
530
|
function Gn({ "aria-label": t, ariaLabel: n, ...r }) {
|
|
510
|
-
|
|
531
|
+
const a = t ?? n;
|
|
532
|
+
return a?.trim() || console.warn("IconButton: 缺少 aria-label,纯图标按钮必须提供可访问名称。"), /* @__PURE__ */ e(kt, { ...r, svgOnly: !0, "aria-label": a });
|
|
511
533
|
}
|
|
512
534
|
function xe(t, n) {
|
|
513
535
|
return `${t}-${n ? "message" : "description"}`;
|
|
@@ -548,7 +570,7 @@ function Ye(...t) {
|
|
|
548
570
|
};
|
|
549
571
|
}
|
|
550
572
|
function Xe(t, n, r) {
|
|
551
|
-
|
|
573
|
+
O(() => {
|
|
552
574
|
}, [n, t, r]);
|
|
553
575
|
}
|
|
554
576
|
function Yn({
|
|
@@ -567,21 +589,21 @@ function Yn({
|
|
|
567
589
|
wide: _,
|
|
568
590
|
size: m = "md",
|
|
569
591
|
className: g,
|
|
570
|
-
...
|
|
592
|
+
...w
|
|
571
593
|
}) {
|
|
572
|
-
const b =
|
|
594
|
+
const b = P(), N = t ?? b, v = n === void 0, D = q(null), C = ie(() => Ye(D, o), [o]);
|
|
573
595
|
Xe("Input", v, D);
|
|
574
|
-
const h = r || a ? xe(
|
|
596
|
+
const h = r || a ? xe(N, !!a) : void 0, x = T("form-control", m !== "md" ? `form-control--${m}` : "", g ?? ""), y = T("input-control", f ? "input-control--rounded" : ""), k = /* @__PURE__ */ e(
|
|
575
597
|
"input",
|
|
576
598
|
{
|
|
577
599
|
ref: C,
|
|
578
|
-
id:
|
|
600
|
+
id: N,
|
|
579
601
|
className: x,
|
|
580
602
|
"aria-describedby": wt(l, h),
|
|
581
603
|
"aria-invalid": s || a ? !0 : void 0,
|
|
582
|
-
...
|
|
604
|
+
...w
|
|
583
605
|
}
|
|
584
|
-
),
|
|
606
|
+
), $ = u || d || f ? /* @__PURE__ */ i("span", { className: y, children: [
|
|
585
607
|
u ? /* @__PURE__ */ e(
|
|
586
608
|
"span",
|
|
587
609
|
{
|
|
@@ -590,7 +612,7 @@ function Yn({
|
|
|
590
612
|
children: u
|
|
591
613
|
}
|
|
592
614
|
) : null,
|
|
593
|
-
|
|
615
|
+
k,
|
|
594
616
|
d ? /* @__PURE__ */ e(
|
|
595
617
|
"span",
|
|
596
618
|
{
|
|
@@ -599,11 +621,11 @@ function Yn({
|
|
|
599
621
|
children: d
|
|
600
622
|
}
|
|
601
623
|
) : null
|
|
602
|
-
] }) :
|
|
603
|
-
return v ?
|
|
624
|
+
] }) : k;
|
|
625
|
+
return v ? $ : /* @__PURE__ */ e(Ge, { controlId: N, label: n, description: r, error: a, wide: _, children: $ });
|
|
604
626
|
}
|
|
605
627
|
function vt(t = "", n) {
|
|
606
|
-
const [r, a] =
|
|
628
|
+
const [r, a] = A(t), s = q(null), l = () => {
|
|
607
629
|
a(""), s.current?.focus(), n?.();
|
|
608
630
|
};
|
|
609
631
|
return { value: r, setValue: a, inputRef: s, clear: l, onKeyDown: (u) => {
|
|
@@ -694,38 +716,38 @@ function Qn({
|
|
|
694
716
|
onInput: f,
|
|
695
717
|
..._
|
|
696
718
|
}) {
|
|
697
|
-
const m =
|
|
698
|
-
Xe("Textarea",
|
|
699
|
-
const [v, D] =
|
|
719
|
+
const m = P(), g = t ?? m, w = n === void 0, b = q(null), N = ie(() => Ye(b, o), [o]);
|
|
720
|
+
Xe("Textarea", w, b);
|
|
721
|
+
const [v, D] = A(
|
|
700
722
|
() => typeof _.defaultValue == "string" ? _.defaultValue.length : 0
|
|
701
|
-
), C = typeof _.value == "string" ? _.value.length : v, h = c !== void 0, x = !
|
|
723
|
+
), C = typeof _.value == "string" ? _.value.length : v, h = c !== void 0, x = !w && (r || a) ? xe(g, !!a) : void 0, y = T(
|
|
702
724
|
"form-control",
|
|
703
725
|
"form-control--textarea",
|
|
704
726
|
d !== "md" ? `form-control--${d}` : "",
|
|
705
727
|
p ?? ""
|
|
706
|
-
),
|
|
728
|
+
), k = /* @__PURE__ */ e(
|
|
707
729
|
"textarea",
|
|
708
730
|
{
|
|
709
731
|
id: g,
|
|
710
|
-
ref:
|
|
711
|
-
className:
|
|
732
|
+
ref: N,
|
|
733
|
+
className: y,
|
|
712
734
|
maxLength: c,
|
|
713
735
|
"aria-describedby": wt(l, x),
|
|
714
736
|
"aria-invalid": s || a ? !0 : void 0,
|
|
715
|
-
onInput: h ? (
|
|
716
|
-
D(
|
|
737
|
+
onInput: h ? (I) => {
|
|
738
|
+
D(I.currentTarget.value.length), f?.(I);
|
|
717
739
|
} : f,
|
|
718
740
|
..._
|
|
719
741
|
}
|
|
720
|
-
),
|
|
721
|
-
|
|
742
|
+
), $ = h ? /* @__PURE__ */ i("span", { className: "textarea-control", children: [
|
|
743
|
+
k,
|
|
722
744
|
/* @__PURE__ */ i("span", { className: "textarea-control__count", "aria-live": "polite", children: [
|
|
723
745
|
C,
|
|
724
746
|
"/",
|
|
725
747
|
c
|
|
726
748
|
] })
|
|
727
|
-
] }) :
|
|
728
|
-
return
|
|
749
|
+
] }) : k;
|
|
750
|
+
return w ? $ : /* @__PURE__ */ e(Ge, { controlId: g, label: n, description: r, error: a, wide: u, children: $ });
|
|
729
751
|
}
|
|
730
752
|
function Jn({
|
|
731
753
|
id: t,
|
|
@@ -777,14 +799,14 @@ function xt({
|
|
|
777
799
|
type: o,
|
|
778
800
|
...u
|
|
779
801
|
}) {
|
|
780
|
-
const d =
|
|
781
|
-
Xe(f ? "Radio" : "Checkbox", c, g),
|
|
802
|
+
const d = P(), p = t ?? d, c = n === void 0, f = o === "radio", _ = !f && (r || a) ? xe(p, !!a) : void 0, m = f ? "control-option__visual control-option__visual--radio" : "control-option__visual", g = q(null), w = ie(() => Ye(g, l), [l]);
|
|
803
|
+
Xe(f ? "Radio" : "Checkbox", c, g), O(() => {
|
|
782
804
|
g.current && (g.current.indeterminate = !f && !!s);
|
|
783
805
|
}, [s, f]);
|
|
784
806
|
const b = /* @__PURE__ */ e(
|
|
785
807
|
"input",
|
|
786
808
|
{
|
|
787
|
-
ref:
|
|
809
|
+
ref: w,
|
|
788
810
|
id: p,
|
|
789
811
|
type: o,
|
|
790
812
|
"aria-describedby": _,
|
|
@@ -827,7 +849,7 @@ function aa({ type: t, label: n, description: r, extra: a, className: s, ...l })
|
|
|
827
849
|
r ? /* @__PURE__ */ e("span", { className: "choicebox__description", children: r }) : null,
|
|
828
850
|
a ? /* @__PURE__ */ e("span", { className: "choicebox__extra", children: a }) : null
|
|
829
851
|
] }),
|
|
830
|
-
/* @__PURE__ */ e("span", { className: "choicebox__indicator", "aria-hidden": "true", children: t === "checkbox" ? /* @__PURE__ */ e(
|
|
852
|
+
/* @__PURE__ */ e("span", { className: "choicebox__indicator", "aria-hidden": "true", children: t === "checkbox" ? /* @__PURE__ */ e(ce, { className: "choicebox__check", size: 12, strokeWidth: 3 }) : null })
|
|
831
853
|
] });
|
|
832
854
|
}
|
|
833
855
|
function ra({
|
|
@@ -846,38 +868,38 @@ function ra({
|
|
|
846
868
|
id: _,
|
|
847
869
|
className: m,
|
|
848
870
|
name: g,
|
|
849
|
-
inputMode:
|
|
871
|
+
inputMode: w,
|
|
850
872
|
spellCheck: b,
|
|
851
|
-
"aria-label":
|
|
873
|
+
"aria-label": N,
|
|
852
874
|
"aria-labelledby": v,
|
|
853
875
|
ref: D,
|
|
854
876
|
...C
|
|
855
877
|
}) {
|
|
856
|
-
const [h, x] =
|
|
878
|
+
const [h, x] = A(""), [y, k] = A(!1), [$, I] = A(0), S = q(null), L = q(null), F = P(), G = `${F}-list`, X = `${F}-err`, V = n ?? "", re = V === "" ? void 0 : t.find((M) => M.value === V), B = !l && !o, Y = y && B, U = h === "" ? t : t.filter((M) => M.label.toLowerCase().includes(h.toLowerCase())), Q = Y && U[$] ? `${F}-opt-${$}` : void 0, he = !!p, Ce = !!u || he, ze = [d, he ? X : null].filter(Boolean).join(" ") || void 0, De = {};
|
|
857
879
|
for (const [M, R] of Object.entries(C))
|
|
858
880
|
M.startsWith("data-") && (De[M] = R);
|
|
859
|
-
const
|
|
881
|
+
const E = Ne(
|
|
860
882
|
(M) => {
|
|
861
|
-
|
|
883
|
+
L.current = M;
|
|
862
884
|
const R = typeof D == "function" ? D(M) : void 0;
|
|
863
885
|
return D && typeof D != "function" && (D.current = M), () => {
|
|
864
|
-
|
|
886
|
+
L.current = null, typeof R == "function" ? R() : typeof D == "function" ? D(null) : D && (D.current = null);
|
|
865
887
|
};
|
|
866
888
|
},
|
|
867
889
|
[D]
|
|
868
890
|
);
|
|
869
|
-
|
|
870
|
-
}, [
|
|
871
|
-
if (!
|
|
891
|
+
O(() => {
|
|
892
|
+
}, [N, v]), O(() => {
|
|
893
|
+
if (!y) return;
|
|
872
894
|
function M(R) {
|
|
873
|
-
S.current && !S.current.contains(R.target) &&
|
|
895
|
+
S.current && !S.current.contains(R.target) && k(!1);
|
|
874
896
|
}
|
|
875
897
|
return document.addEventListener("mousedown", M), () => document.removeEventListener("mousedown", M);
|
|
876
|
-
}, [
|
|
877
|
-
B ||
|
|
898
|
+
}, [y]), O(() => {
|
|
899
|
+
B || k(!1);
|
|
878
900
|
}, [B]);
|
|
879
901
|
function z(M, R = 0) {
|
|
880
|
-
const j = M.findIndex((
|
|
902
|
+
const j = M.findIndex((Z) => !Z.disabled);
|
|
881
903
|
return j === -1 ? R : j;
|
|
882
904
|
}
|
|
883
905
|
function H(M, R = 0) {
|
|
@@ -888,47 +910,47 @@ function ra({
|
|
|
888
910
|
function te(M, R) {
|
|
889
911
|
if (U.length === 0) return 0;
|
|
890
912
|
let j = M;
|
|
891
|
-
for (let
|
|
913
|
+
for (let Z = 0; Z < U.length; Z++)
|
|
892
914
|
if (j = (j + R + U.length) % U.length, !U[j].disabled) return j;
|
|
893
915
|
return M;
|
|
894
916
|
}
|
|
895
917
|
function ne() {
|
|
896
|
-
const M =
|
|
897
|
-
x(""),
|
|
918
|
+
const M = V === "" ? -1 : t.findIndex((R) => R.value === V);
|
|
919
|
+
x(""), I(M === -1 ? z(t) : M), k(!0);
|
|
898
920
|
}
|
|
899
|
-
function
|
|
900
|
-
!B || M.disabled || (r?.(M.value, M),
|
|
921
|
+
function J(M) {
|
|
922
|
+
!B || M.disabled || (r?.(M.value, M), k(!1), L.current?.focus());
|
|
901
923
|
}
|
|
902
|
-
function
|
|
903
|
-
r?.("", void 0), x(""),
|
|
924
|
+
function le() {
|
|
925
|
+
r?.("", void 0), x(""), k(!1), L.current?.focus();
|
|
904
926
|
}
|
|
905
927
|
function Re(M) {
|
|
906
928
|
if (!M.nativeEvent.isComposing && B) {
|
|
907
|
-
if (!
|
|
908
|
-
M.key === "ArrowDown" || M.key === "Enter" ? (M.preventDefault(), ne()) : M.key === "Escape" && f &&
|
|
929
|
+
if (!y) {
|
|
930
|
+
M.key === "ArrowDown" || M.key === "Enter" ? (M.preventDefault(), ne()) : M.key === "Escape" && f && V !== "" && le();
|
|
909
931
|
return;
|
|
910
932
|
}
|
|
911
933
|
if (M.key === "ArrowDown")
|
|
912
|
-
M.preventDefault(),
|
|
934
|
+
M.preventDefault(), I((R) => te(R, 1));
|
|
913
935
|
else if (M.key === "ArrowUp")
|
|
914
|
-
M.preventDefault(),
|
|
936
|
+
M.preventDefault(), I((R) => te(R, -1));
|
|
915
937
|
else if (M.key === "Home")
|
|
916
|
-
M.preventDefault(),
|
|
938
|
+
M.preventDefault(), I((R) => z(U, R));
|
|
917
939
|
else if (M.key === "End")
|
|
918
|
-
M.preventDefault(),
|
|
940
|
+
M.preventDefault(), I((R) => H(U, R));
|
|
919
941
|
else if (M.key === "Enter")
|
|
920
|
-
M.preventDefault(), U[
|
|
942
|
+
M.preventDefault(), U[$] && J(U[$]);
|
|
921
943
|
else if (M.key === "Escape")
|
|
922
|
-
M.preventDefault(),
|
|
944
|
+
M.preventDefault(), k(!1);
|
|
923
945
|
else if (M.key === "Tab") {
|
|
924
946
|
const R = S.current?.querySelector(
|
|
925
947
|
'.combobox__empty a[href], .combobox__empty button:not([disabled]), .combobox__empty input:not([disabled]), .combobox__empty select:not([disabled]), .combobox__empty textarea:not([disabled]), .combobox__empty [tabindex]:not([tabindex="-1"])'
|
|
926
948
|
);
|
|
927
|
-
R && !M.shiftKey ? (M.preventDefault(), R.focus()) :
|
|
949
|
+
R && !M.shiftKey ? (M.preventDefault(), R.focus()) : k(!1);
|
|
928
950
|
}
|
|
929
951
|
}
|
|
930
952
|
}
|
|
931
|
-
const
|
|
953
|
+
const se = T(
|
|
932
954
|
"combobox",
|
|
933
955
|
s !== "md" ? `combobox--${s}` : "",
|
|
934
956
|
Ce ? "combobox--error" : "",
|
|
@@ -939,13 +961,13 @@ function ra({
|
|
|
939
961
|
return /* @__PURE__ */ i(
|
|
940
962
|
"div",
|
|
941
963
|
{
|
|
942
|
-
className:
|
|
964
|
+
className: se,
|
|
943
965
|
ref: S,
|
|
944
966
|
onBlur: (M) => {
|
|
945
|
-
M.currentTarget.contains(M.relatedTarget) ||
|
|
967
|
+
M.currentTarget.contains(M.relatedTarget) || k(!1);
|
|
946
968
|
},
|
|
947
969
|
onKeyDown: (M) => {
|
|
948
|
-
M.key !== "Escape" || M.target ===
|
|
970
|
+
M.key !== "Escape" || M.target === L.current || !Y || (M.preventDefault(), k(!1), L.current?.focus());
|
|
949
971
|
},
|
|
950
972
|
...De,
|
|
951
973
|
children: [
|
|
@@ -954,62 +976,62 @@ function ra({
|
|
|
954
976
|
/* @__PURE__ */ e(
|
|
955
977
|
"input",
|
|
956
978
|
{
|
|
957
|
-
ref:
|
|
958
|
-
id: _ ?? `${
|
|
979
|
+
ref: E,
|
|
980
|
+
id: _ ?? `${F}-input`,
|
|
959
981
|
type: "text",
|
|
960
982
|
role: "combobox",
|
|
961
983
|
className: "combobox__input",
|
|
962
984
|
placeholder: a,
|
|
963
|
-
value: Y ? h :
|
|
985
|
+
value: Y ? h : re?.label ?? "",
|
|
964
986
|
disabled: l,
|
|
965
987
|
readOnly: o,
|
|
966
988
|
name: g,
|
|
967
|
-
inputMode:
|
|
989
|
+
inputMode: w,
|
|
968
990
|
spellCheck: b,
|
|
969
|
-
"aria-label":
|
|
991
|
+
"aria-label": N,
|
|
970
992
|
"aria-labelledby": v,
|
|
971
993
|
"aria-expanded": Y,
|
|
972
|
-
"aria-controls":
|
|
994
|
+
"aria-controls": G,
|
|
973
995
|
"aria-autocomplete": "list",
|
|
974
|
-
"aria-activedescendant":
|
|
996
|
+
"aria-activedescendant": Q,
|
|
975
997
|
"aria-invalid": Ce ? !0 : void 0,
|
|
976
998
|
"aria-describedby": ze,
|
|
977
999
|
onChange: (M) => {
|
|
978
1000
|
if (!B) return;
|
|
979
|
-
const R = M.target.value, j = R === "" ? t : t.filter((
|
|
980
|
-
x(R),
|
|
1001
|
+
const R = M.target.value, j = R === "" ? t : t.filter((Z) => Z.label.toLowerCase().includes(R.toLowerCase()));
|
|
1002
|
+
x(R), I(z(j)), k(!0);
|
|
981
1003
|
},
|
|
982
|
-
onFocus: () => B && !
|
|
983
|
-
onMouseDown: () => B && !
|
|
1004
|
+
onFocus: () => B && !y && ne(),
|
|
1005
|
+
onMouseDown: () => B && !y && ne(),
|
|
984
1006
|
onKeyDown: Re
|
|
985
1007
|
}
|
|
986
1008
|
),
|
|
987
|
-
f &&
|
|
1009
|
+
f && V !== "" && B ? /* @__PURE__ */ e("button", { type: "button", className: "combobox__clear", "aria-label": "清除选择", onClick: le, children: /* @__PURE__ */ e(_e, { size: 14, strokeWidth: 2, "aria-hidden": "true" }) }) : null
|
|
988
1010
|
] }),
|
|
989
1011
|
Y ? /* @__PURE__ */ i("div", { className: "combobox__popup", children: [
|
|
990
|
-
/* @__PURE__ */ e("ul", { className: "combobox__listbox", id:
|
|
991
|
-
const j =
|
|
1012
|
+
/* @__PURE__ */ e("ul", { className: "combobox__listbox", id: G, role: "listbox", "aria-label": a, children: U.map((M, R) => {
|
|
1013
|
+
const j = V !== "" && M.value === V;
|
|
992
1014
|
return /* @__PURE__ */ i(
|
|
993
1015
|
"li",
|
|
994
1016
|
{
|
|
995
|
-
id: `${
|
|
1017
|
+
id: `${F}-opt-${R}`,
|
|
996
1018
|
role: "option",
|
|
997
1019
|
"aria-selected": j,
|
|
998
1020
|
"aria-disabled": M.disabled || void 0,
|
|
999
1021
|
className: T(
|
|
1000
1022
|
"combobox__option",
|
|
1001
|
-
R ===
|
|
1023
|
+
R === $ && "combobox__option--active",
|
|
1002
1024
|
M.disabled && "combobox__option--disabled"
|
|
1003
1025
|
),
|
|
1004
|
-
onMouseEnter: () => !M.disabled &&
|
|
1005
|
-
onMouseDown: (
|
|
1006
|
-
|
|
1026
|
+
onMouseEnter: () => !M.disabled && I(R),
|
|
1027
|
+
onMouseDown: (Z) => {
|
|
1028
|
+
Z.preventDefault(), J(M);
|
|
1007
1029
|
},
|
|
1008
1030
|
children: [
|
|
1009
1031
|
M.prefix ? /* @__PURE__ */ e("span", { className: "combobox__option-prefix", "aria-hidden": "true", children: M.prefix }) : null,
|
|
1010
1032
|
/* @__PURE__ */ e("span", { className: "combobox__option-label", children: M.label }),
|
|
1011
1033
|
M.suffix ? /* @__PURE__ */ e("span", { className: "combobox__option-suffix", "aria-hidden": "true", children: M.suffix }) : null,
|
|
1012
|
-
j ? /* @__PURE__ */ e(
|
|
1034
|
+
j ? /* @__PURE__ */ e(ce, { className: "combobox__option-check", size: 14, strokeWidth: 2, "aria-hidden": "true" }) : null
|
|
1013
1035
|
]
|
|
1014
1036
|
},
|
|
1015
1037
|
M.value
|
|
@@ -1017,7 +1039,7 @@ function ra({
|
|
|
1017
1039
|
}) }),
|
|
1018
1040
|
U.length === 0 ? /* @__PURE__ */ e("div", { className: "combobox__empty", role: "status", "aria-live": "polite", children: c }) : null
|
|
1019
1041
|
] }) : null,
|
|
1020
|
-
he ? /* @__PURE__ */ e("p", { className: "combobox__error-text", id:
|
|
1042
|
+
he ? /* @__PURE__ */ e("p", { className: "combobox__error-text", id: X, children: p }) : null
|
|
1021
1043
|
]
|
|
1022
1044
|
}
|
|
1023
1045
|
);
|
|
@@ -1032,7 +1054,7 @@ function la({
|
|
|
1032
1054
|
fullWidth: o = !1,
|
|
1033
1055
|
iconOnly: u = !1
|
|
1034
1056
|
}) {
|
|
1035
|
-
const d =
|
|
1057
|
+
const d = P();
|
|
1036
1058
|
if (t.length === 0) return null;
|
|
1037
1059
|
const p = r ?? d, c = t.find((_) => _.value === a && !_.disabled) ?? t.find((_) => !_.disabled) ?? t[0], f = T("switch-control", `switch-control--${l}`, o ? "switch-control--full" : "");
|
|
1038
1060
|
return /* @__PURE__ */ e("div", { className: f, role: "radiogroup", "aria-label": n, children: t.map((_) => /* @__PURE__ */ i("label", { className: "switch-control__option", title: _.tooltip, children: [
|
|
@@ -1064,7 +1086,7 @@ function sa({
|
|
|
1064
1086
|
labelSide: d = "right",
|
|
1065
1087
|
ariaLabel: p
|
|
1066
1088
|
}) {
|
|
1067
|
-
const [c, f] =
|
|
1089
|
+
const [c, f] = A(n), _ = t !== void 0, m = _ ? t : c, g = P(), w = P(), b = l ? { "--toggle-on": l } : void 0;
|
|
1068
1090
|
return /* @__PURE__ */ i(
|
|
1069
1091
|
"button",
|
|
1070
1092
|
{
|
|
@@ -1073,17 +1095,17 @@ function sa({
|
|
|
1073
1095
|
"aria-checked": m,
|
|
1074
1096
|
"aria-label": o ? void 0 : p,
|
|
1075
1097
|
"aria-labelledby": o ? g : void 0,
|
|
1076
|
-
"aria-describedby": o && u ?
|
|
1098
|
+
"aria-describedby": o && u ? w : void 0,
|
|
1077
1099
|
disabled: a,
|
|
1078
1100
|
className: `toggle-field toggle-field--${d}`,
|
|
1079
1101
|
onClick: () => {
|
|
1080
|
-
const
|
|
1081
|
-
_ || f(
|
|
1102
|
+
const N = !m;
|
|
1103
|
+
_ || f(N), r?.(N);
|
|
1082
1104
|
},
|
|
1083
1105
|
children: [
|
|
1084
1106
|
o ? /* @__PURE__ */ i("span", { className: "toggle-field__text", children: [
|
|
1085
1107
|
/* @__PURE__ */ e("span", { className: "toggle-field__label", id: g, children: o }),
|
|
1086
|
-
u ? /* @__PURE__ */ e("span", { className: "toggle-field__description", id:
|
|
1108
|
+
u ? /* @__PURE__ */ e("span", { className: "toggle-field__description", id: w, children: u }) : null
|
|
1087
1109
|
] }) : null,
|
|
1088
1110
|
/* @__PURE__ */ e("span", { className: `toggle toggle--${s}`, style: b, "aria-hidden": "true", children: /* @__PURE__ */ e("span", { className: "toggle__thumb" }) })
|
|
1089
1111
|
]
|
|
@@ -1091,7 +1113,7 @@ function sa({
|
|
|
1091
1113
|
);
|
|
1092
1114
|
}
|
|
1093
1115
|
function Ct({ tokens: t }) {
|
|
1094
|
-
return /* @__PURE__ */ e(
|
|
1116
|
+
return /* @__PURE__ */ e(ee, { children: t.map(
|
|
1095
1117
|
(n, r) => n.type ? /* @__PURE__ */ e("span", { className: `tok-${n.type}`, children: n.text }, r) : /* @__PURE__ */ e("span", { children: n.text }, r)
|
|
1096
1118
|
) });
|
|
1097
1119
|
}
|
|
@@ -1102,7 +1124,7 @@ function ia({ children: t }) {
|
|
|
1102
1124
|
return /* @__PURE__ */ e("code", { className: "code-inline", children: t });
|
|
1103
1125
|
}
|
|
1104
1126
|
function ca(t) {
|
|
1105
|
-
const { lineNumbers: n = !0 } = t, { copied: r, copy: a, reset: s } = Se(), [l, o] =
|
|
1127
|
+
const { lineNumbers: n = !0 } = t, { copied: r, copy: a, reset: s } = Se(), [l, o] = A(0), u = t.tabs ? t.tabs[l] ?? t.tabs[0] : void 0, d = u ? u.lines : t.lines ?? [], p = u ? u.filename : t.filename, c = d.map((_) => _.tokens.map((m) => m.text).join("")).join(`
|
|
1106
1128
|
`);
|
|
1107
1129
|
let f = 0;
|
|
1108
1130
|
return /* @__PURE__ */ i("div", { className: "codeblock", children: [
|
|
@@ -1131,7 +1153,7 @@ function ca(t) {
|
|
|
1131
1153
|
className: "codeblock__copy",
|
|
1132
1154
|
"aria-label": "复制代码",
|
|
1133
1155
|
onClick: () => a(c, "已复制代码"),
|
|
1134
|
-
children: r ? /* @__PURE__ */ e(
|
|
1156
|
+
children: r ? /* @__PURE__ */ e(ce, { size: 14, strokeWidth: 2, "aria-hidden": "true" }) : /* @__PURE__ */ e(we, { size: 14, strokeWidth: 2, "aria-hidden": "true" })
|
|
1135
1157
|
}
|
|
1136
1158
|
)
|
|
1137
1159
|
] }),
|
|
@@ -1161,7 +1183,7 @@ function da({
|
|
|
1161
1183
|
ariaLabel: n,
|
|
1162
1184
|
variant: r = "default"
|
|
1163
1185
|
}) {
|
|
1164
|
-
const a =
|
|
1186
|
+
const a = P(), s = t.find((c) => !c.disabled), [l, o] = A(s?.id ?? ""), u = t.find((c) => c.id === l), d = q(/* @__PURE__ */ new Map());
|
|
1165
1187
|
function p(c) {
|
|
1166
1188
|
const f = t.filter((g) => !g.disabled);
|
|
1167
1189
|
if (f.length === 0) return;
|
|
@@ -1241,7 +1263,7 @@ function da({
|
|
|
1241
1263
|
}
|
|
1242
1264
|
const Dt = it(null);
|
|
1243
1265
|
function ua({ multiple: t, children: n }) {
|
|
1244
|
-
const [r, a] =
|
|
1266
|
+
const [r, a] = A(null);
|
|
1245
1267
|
return /* @__PURE__ */ e("div", { className: "collapse-group", children: /* @__PURE__ */ e(Dt.Provider, { value: t ? null : { openId: r, setOpenId: a }, children: n }) });
|
|
1246
1268
|
}
|
|
1247
1269
|
function ma({
|
|
@@ -1250,7 +1272,7 @@ function ma({
|
|
|
1250
1272
|
small: r,
|
|
1251
1273
|
children: a
|
|
1252
1274
|
}) {
|
|
1253
|
-
const s = ct(Dt), l =
|
|
1275
|
+
const s = ct(Dt), l = P(), [o, u] = A(n ?? !1);
|
|
1254
1276
|
fe(() => {
|
|
1255
1277
|
s && n && s.setOpenId(l);
|
|
1256
1278
|
}, []);
|
|
@@ -1268,7 +1290,7 @@ function ma({
|
|
|
1268
1290
|
},
|
|
1269
1291
|
children: [
|
|
1270
1292
|
/* @__PURE__ */ e("span", { className: "collapse__title", children: p }),
|
|
1271
|
-
/* @__PURE__ */ e(
|
|
1293
|
+
/* @__PURE__ */ e(me, { className: "collapse__chevron", size: 16, strokeWidth: 2, "aria-hidden": "true" })
|
|
1272
1294
|
]
|
|
1273
1295
|
}
|
|
1274
1296
|
),
|
|
@@ -1276,46 +1298,46 @@ function ma({
|
|
|
1276
1298
|
] });
|
|
1277
1299
|
}
|
|
1278
1300
|
function ha({ sections: t, triggerLabel: n = "打开命令面板", hotkey: r }) {
|
|
1279
|
-
const [a, s] =
|
|
1301
|
+
const [a, s] = A(!1), [l, o] = A(""), [u, d] = A(0), p = q(null), c = q(null), f = q(null), _ = q(null), m = ie(() => {
|
|
1280
1302
|
const b = l.trim().toLowerCase();
|
|
1281
|
-
let
|
|
1303
|
+
let N = 0;
|
|
1282
1304
|
return t.map((v) => ({
|
|
1283
1305
|
heading: v.heading,
|
|
1284
|
-
items: v.items.filter((D) => b.length === 0 || D.label.toLowerCase().includes(b)).map((D) => ({ item: D, flatIndex:
|
|
1306
|
+
items: v.items.filter((D) => b.length === 0 || D.label.toLowerCase().includes(b)).map((D) => ({ item: D, flatIndex: N++ }))
|
|
1285
1307
|
})).filter((v) => v.items.length > 0);
|
|
1286
|
-
}, [t, l]), g = m.reduce((b,
|
|
1287
|
-
|
|
1308
|
+
}, [t, l]), g = m.reduce((b, N) => b + N.items.length, 0);
|
|
1309
|
+
O(() => {
|
|
1288
1310
|
if (!a) return;
|
|
1289
1311
|
o(""), d(0);
|
|
1290
1312
|
const b = document.activeElement;
|
|
1291
1313
|
_.current = b && b !== document.body ? b : p.current;
|
|
1292
|
-
const
|
|
1314
|
+
const N = window.setTimeout(() => f.current?.focus(), 0);
|
|
1293
1315
|
return document.body.style.overflow = "hidden", () => {
|
|
1294
|
-
window.clearTimeout(
|
|
1316
|
+
window.clearTimeout(N), document.body.style.overflow = "";
|
|
1295
1317
|
const v = _.current;
|
|
1296
1318
|
(v && document.contains(v) ? v : p.current)?.focus();
|
|
1297
1319
|
};
|
|
1298
|
-
}, [a]),
|
|
1320
|
+
}, [a]), O(() => {
|
|
1299
1321
|
if (!r) return;
|
|
1300
|
-
function b(
|
|
1301
|
-
|
|
1322
|
+
function b(N) {
|
|
1323
|
+
N.repeat || (N.metaKey || N.ctrlKey) && N.key.toLowerCase() === "k" && (N.preventDefault(), s((v) => !v));
|
|
1302
1324
|
}
|
|
1303
1325
|
return document.addEventListener("keydown", b), () => document.removeEventListener("keydown", b);
|
|
1304
1326
|
}, [r]);
|
|
1305
|
-
function
|
|
1327
|
+
function w(b) {
|
|
1306
1328
|
if (!b.nativeEvent.isComposing) {
|
|
1307
1329
|
if (b.key === "Escape")
|
|
1308
1330
|
b.preventDefault(), s(!1);
|
|
1309
1331
|
else if (b.key === "ArrowDown")
|
|
1310
|
-
b.preventDefault(), d((
|
|
1332
|
+
b.preventDefault(), d((N) => Math.max(Math.min(N + 1, g - 1), 0));
|
|
1311
1333
|
else if (b.key === "ArrowUp")
|
|
1312
|
-
b.preventDefault(), d((
|
|
1334
|
+
b.preventDefault(), d((N) => Math.max(N - 1, 0));
|
|
1313
1335
|
else if (b.key === "Enter" && g > 0)
|
|
1314
1336
|
b.preventDefault(), s(!1);
|
|
1315
1337
|
else if (b.key === "Tab") {
|
|
1316
|
-
const
|
|
1338
|
+
const N = Array.from(
|
|
1317
1339
|
c.current?.querySelectorAll("button:not([disabled]), input") ?? []
|
|
1318
|
-
), v =
|
|
1340
|
+
), v = N[0], D = N[N.length - 1];
|
|
1319
1341
|
b.shiftKey && document.activeElement === v ? (b.preventDefault(), D?.focus()) : !b.shiftKey && document.activeElement === D && (b.preventDefault(), v?.focus());
|
|
1320
1342
|
}
|
|
1321
1343
|
}
|
|
@@ -1326,7 +1348,7 @@ function ha({ sections: t, triggerLabel: n = "打开命令面板", hotkey: r })
|
|
|
1326
1348
|
n,
|
|
1327
1349
|
/* @__PURE__ */ e("kbd", { className: "command-palette__hint", children: "⌘K" })
|
|
1328
1350
|
] }),
|
|
1329
|
-
a ? /* @__PURE__ */ i("div", { className: "command-palette", role: "dialog", "aria-modal": "true", "aria-label": "命令面板", onKeyDown:
|
|
1351
|
+
a ? /* @__PURE__ */ i("div", { className: "command-palette", role: "dialog", "aria-modal": "true", "aria-label": "命令面板", onKeyDown: w, children: [
|
|
1330
1352
|
/* @__PURE__ */ e(
|
|
1331
1353
|
"button",
|
|
1332
1354
|
{
|
|
@@ -1359,7 +1381,7 @@ function ha({ sections: t, triggerLabel: n = "打开命令面板", hotkey: r })
|
|
|
1359
1381
|
g,
|
|
1360
1382
|
" 个结果"
|
|
1361
1383
|
] }),
|
|
1362
|
-
/* @__PURE__ */ e("div", { className: "command-palette__body", id: "command-palette-list", role: "listbox", "aria-label": "命令", children: m.length > 0 ? m.map((b,
|
|
1384
|
+
/* @__PURE__ */ e("div", { className: "command-palette__body", id: "command-palette-list", role: "listbox", "aria-label": "命令", children: m.length > 0 ? m.map((b, N) => (
|
|
1363
1385
|
// 相邻组间的分隔线由 CSS(.command-palette__group + .command-palette__group)天然提供,
|
|
1364
1386
|
// heading 缺省的段即呈现为"只有分隔线、没有标题"。
|
|
1365
1387
|
/* @__PURE__ */ i("section", { className: "command-palette__group", children: [
|
|
@@ -1382,7 +1404,7 @@ function ha({ sections: t, triggerLabel: n = "打开命令面板", hotkey: r })
|
|
|
1382
1404
|
},
|
|
1383
1405
|
v.label
|
|
1384
1406
|
))
|
|
1385
|
-
] }, b.heading ?? `divider-${
|
|
1407
|
+
] }, b.heading ?? `divider-${N}`)
|
|
1386
1408
|
)) : /* @__PURE__ */ e("p", { className: "command-palette__empty", children: `没有匹配「${l}」的命令` }) })
|
|
1387
1409
|
] })
|
|
1388
1410
|
] }) : null
|
|
@@ -1400,15 +1422,15 @@ function pa({
|
|
|
1400
1422
|
loading: d,
|
|
1401
1423
|
onConfirm: p
|
|
1402
1424
|
}) {
|
|
1403
|
-
const [c, f] =
|
|
1404
|
-
if (
|
|
1425
|
+
const [c, f] = A(""), [_, m] = A(null), g = q(null), w = q(null), b = P(), N = P(), v = c === o && !d;
|
|
1426
|
+
if (O(() => {
|
|
1405
1427
|
if (!t) return;
|
|
1406
1428
|
f(""), m(null);
|
|
1407
1429
|
const h = document.body.style.overflow;
|
|
1408
1430
|
document.body.style.overflow = "hidden";
|
|
1409
1431
|
const x = window.setTimeout(() => {
|
|
1410
|
-
const
|
|
1411
|
-
(
|
|
1432
|
+
const y = w.current;
|
|
1433
|
+
(y && !y.disabled ? y : g.current)?.focus();
|
|
1412
1434
|
}, 0);
|
|
1413
1435
|
return () => {
|
|
1414
1436
|
window.clearTimeout(x), document.body.style.overflow = h;
|
|
@@ -1432,8 +1454,8 @@ function pa({
|
|
|
1432
1454
|
h.preventDefault();
|
|
1433
1455
|
return;
|
|
1434
1456
|
}
|
|
1435
|
-
const
|
|
1436
|
-
h.shiftKey && document.activeElement ===
|
|
1457
|
+
const y = x[0], k = x[x.length - 1];
|
|
1458
|
+
h.shiftKey && document.activeElement === y ? (h.preventDefault(), k.focus()) : !h.shiftKey && document.activeElement === k && (h.preventDefault(), y.focus());
|
|
1437
1459
|
}
|
|
1438
1460
|
}
|
|
1439
1461
|
return /* @__PURE__ */ i("div", { className: "modal", onKeyDown: C, children: [
|
|
@@ -1464,7 +1486,7 @@ function pa({
|
|
|
1464
1486
|
] }),
|
|
1465
1487
|
/* @__PURE__ */ i("div", { className: "modal__body", children: [
|
|
1466
1488
|
/* @__PURE__ */ e("p", { children: a }),
|
|
1467
|
-
/* @__PURE__ */ i("label", { className: "destructive-modal__prompt", id:
|
|
1489
|
+
/* @__PURE__ */ i("label", { className: "destructive-modal__prompt", id: N, htmlFor: `${N}-input`, children: [
|
|
1468
1490
|
"若要确认,请输入",
|
|
1469
1491
|
l,
|
|
1470
1492
|
"「",
|
|
@@ -1474,10 +1496,10 @@ function pa({
|
|
|
1474
1496
|
/* @__PURE__ */ e(
|
|
1475
1497
|
"input",
|
|
1476
1498
|
{
|
|
1477
|
-
ref:
|
|
1478
|
-
id: `${
|
|
1499
|
+
ref: w,
|
|
1500
|
+
id: `${N}-input`,
|
|
1479
1501
|
className: "modal-input",
|
|
1480
|
-
"aria-labelledby":
|
|
1502
|
+
"aria-labelledby": N,
|
|
1481
1503
|
"aria-invalid": _ ? !0 : void 0,
|
|
1482
1504
|
disabled: d,
|
|
1483
1505
|
value: c,
|
|
@@ -1525,40 +1547,40 @@ function fa({
|
|
|
1525
1547
|
footer: s,
|
|
1526
1548
|
height: l
|
|
1527
1549
|
}) {
|
|
1528
|
-
const o = q(null), u =
|
|
1529
|
-
if (
|
|
1550
|
+
const o = q(null), u = P(), [d, p] = A(0), c = q(null), f = q(!1);
|
|
1551
|
+
if (O(() => {
|
|
1530
1552
|
if (!t) return;
|
|
1531
|
-
const
|
|
1553
|
+
const N = document.body.style.overflow;
|
|
1532
1554
|
document.body.style.overflow = "hidden";
|
|
1533
1555
|
const v = window.setTimeout(
|
|
1534
1556
|
() => o.current?.querySelector("button, input, [tabindex]")?.focus(),
|
|
1535
1557
|
0
|
|
1536
1558
|
);
|
|
1537
1559
|
return () => {
|
|
1538
|
-
window.clearTimeout(v), document.body.style.overflow =
|
|
1560
|
+
window.clearTimeout(v), document.body.style.overflow = N, p(0);
|
|
1539
1561
|
};
|
|
1540
1562
|
}, [t]), !t) return null;
|
|
1541
|
-
function _(
|
|
1542
|
-
if (
|
|
1543
|
-
|
|
1544
|
-
else if (
|
|
1563
|
+
function _(N) {
|
|
1564
|
+
if (N.key === "Escape")
|
|
1565
|
+
N.preventDefault(), n();
|
|
1566
|
+
else if (N.key === "Tab") {
|
|
1545
1567
|
const v = Array.from(
|
|
1546
1568
|
o.current?.querySelectorAll("button:not([disabled]), input:not([disabled]), select") ?? []
|
|
1547
1569
|
);
|
|
1548
1570
|
if (v.length === 0) return;
|
|
1549
1571
|
const D = v[0], C = v[v.length - 1];
|
|
1550
|
-
|
|
1572
|
+
N.shiftKey && document.activeElement === D ? (N.preventDefault(), C.focus()) : !N.shiftKey && document.activeElement === C && (N.preventDefault(), D.focus());
|
|
1551
1573
|
}
|
|
1552
1574
|
}
|
|
1553
|
-
function m(
|
|
1554
|
-
c.current =
|
|
1575
|
+
function m(N) {
|
|
1576
|
+
c.current = N.clientY, f.current = !1, N.target.setPointerCapture(N.pointerId);
|
|
1555
1577
|
}
|
|
1556
|
-
function g(
|
|
1578
|
+
function g(N) {
|
|
1557
1579
|
if (c.current === null) return;
|
|
1558
|
-
const v = Math.max(0,
|
|
1580
|
+
const v = Math.max(0, N.clientY - c.current);
|
|
1559
1581
|
v > 4 && (f.current = !0), p(v);
|
|
1560
1582
|
}
|
|
1561
|
-
function
|
|
1583
|
+
function w() {
|
|
1562
1584
|
c.current !== null && d > 80 ? n() : p(0), c.current = null;
|
|
1563
1585
|
}
|
|
1564
1586
|
function b() {
|
|
@@ -1587,7 +1609,7 @@ function fa({
|
|
|
1587
1609
|
"aria-label": "关闭抽屉",
|
|
1588
1610
|
onPointerDown: m,
|
|
1589
1611
|
onPointerMove: g,
|
|
1590
|
-
onPointerUp:
|
|
1612
|
+
onPointerUp: w,
|
|
1591
1613
|
onPointerCancel: b,
|
|
1592
1614
|
onClick: () => {
|
|
1593
1615
|
f.current || n(), f.current = !1;
|
|
@@ -1675,22 +1697,22 @@ function Na({
|
|
|
1675
1697
|
inline: a,
|
|
1676
1698
|
topics: s
|
|
1677
1699
|
}) {
|
|
1678
|
-
const [l, o] =
|
|
1679
|
-
function
|
|
1700
|
+
const [l, o] = A(!!a), [u, d] = A(null), [p, c] = A(!1), f = q(null), _ = q([]), m = P(), g = P();
|
|
1701
|
+
function w() {
|
|
1680
1702
|
o(!1), f.current?.focus();
|
|
1681
1703
|
}
|
|
1682
|
-
function b(
|
|
1683
|
-
|
|
1704
|
+
function b(y) {
|
|
1705
|
+
y.preventDefault(), c(!0), a || (o(!1), f.current?.focus());
|
|
1684
1706
|
}
|
|
1685
|
-
const
|
|
1686
|
-
function D(
|
|
1687
|
-
d(
|
|
1707
|
+
const N = ke.findIndex((y) => y.value === u), v = N === -1 ? 0 : N;
|
|
1708
|
+
function D(y) {
|
|
1709
|
+
d(y), c(!1);
|
|
1688
1710
|
}
|
|
1689
|
-
function C(
|
|
1690
|
-
const
|
|
1691
|
-
if (
|
|
1692
|
-
|
|
1693
|
-
const S = (
|
|
1711
|
+
function C(y, k) {
|
|
1712
|
+
const $ = y.key === "ArrowRight" || y.key === "ArrowDown", I = y.key === "ArrowLeft" || y.key === "ArrowUp";
|
|
1713
|
+
if (!$ && !I) return;
|
|
1714
|
+
y.preventDefault();
|
|
1715
|
+
const S = (k + ($ ? 1 : ke.length - 1)) % ke.length;
|
|
1694
1716
|
D(ke[S].value), _.current[S]?.focus();
|
|
1695
1717
|
}
|
|
1696
1718
|
const h = /* @__PURE__ */ i(
|
|
@@ -1699,36 +1721,36 @@ function Na({
|
|
|
1699
1721
|
className: "feedback__panel",
|
|
1700
1722
|
id: m,
|
|
1701
1723
|
onSubmit: b,
|
|
1702
|
-
onKeyDown: (
|
|
1703
|
-
!a &&
|
|
1724
|
+
onKeyDown: (y) => {
|
|
1725
|
+
!a && y.key === "Escape" && w();
|
|
1704
1726
|
},
|
|
1705
1727
|
children: [
|
|
1706
1728
|
/* @__PURE__ */ i("div", { className: "feedback__head", children: [
|
|
1707
1729
|
/* @__PURE__ */ e("span", { className: "feedback__prompt", id: g, children: n }),
|
|
1708
|
-
/* @__PURE__ */ e("div", { className: "feedback__emotions", role: "radiogroup", "aria-labelledby": g, children: ke.map(({ value:
|
|
1730
|
+
/* @__PURE__ */ e("div", { className: "feedback__emotions", role: "radiogroup", "aria-labelledby": g, children: ke.map(({ value: y, label: k, Icon: $ }, I) => /* @__PURE__ */ e(
|
|
1709
1731
|
"button",
|
|
1710
1732
|
{
|
|
1711
1733
|
ref: (S) => {
|
|
1712
|
-
_.current[
|
|
1734
|
+
_.current[I] = S;
|
|
1713
1735
|
},
|
|
1714
1736
|
type: "button",
|
|
1715
1737
|
role: "radio",
|
|
1716
1738
|
className: "feedback__emotion",
|
|
1717
|
-
"aria-label":
|
|
1718
|
-
"aria-checked": u ===
|
|
1719
|
-
tabIndex:
|
|
1720
|
-
onClick: () => D(
|
|
1721
|
-
onKeyDown: (S) => C(S,
|
|
1722
|
-
children: /* @__PURE__ */ e(
|
|
1739
|
+
"aria-label": k,
|
|
1740
|
+
"aria-checked": u === y,
|
|
1741
|
+
tabIndex: I === v ? 0 : -1,
|
|
1742
|
+
onClick: () => D(y),
|
|
1743
|
+
onKeyDown: (S) => C(S, I),
|
|
1744
|
+
children: /* @__PURE__ */ e($, { size: 16, strokeWidth: 1.8, "aria-hidden": "true" })
|
|
1723
1745
|
},
|
|
1724
|
-
|
|
1746
|
+
y
|
|
1725
1747
|
)) })
|
|
1726
1748
|
] }),
|
|
1727
1749
|
s ? /* @__PURE__ */ i("label", { className: "feedback__field", children: [
|
|
1728
1750
|
/* @__PURE__ */ e("span", { className: "q1-sr-only", children: "反馈主题" }),
|
|
1729
1751
|
/* @__PURE__ */ i("select", { className: "feedback__select", defaultValue: "", children: [
|
|
1730
1752
|
/* @__PURE__ */ e("option", { value: "", disabled: !0, children: "选择主题…" }),
|
|
1731
|
-
s.map((
|
|
1753
|
+
s.map((y) => /* @__PURE__ */ e("option", { value: y, children: y }, y))
|
|
1732
1754
|
] })
|
|
1733
1755
|
] }) : null,
|
|
1734
1756
|
/* @__PURE__ */ i("label", { className: "feedback__field", children: [
|
|
@@ -1796,7 +1818,7 @@ function wa({
|
|
|
1796
1818
|
label: n = "项目目录",
|
|
1797
1819
|
defaultExpanded: r = []
|
|
1798
1820
|
}) {
|
|
1799
|
-
const [a, s] =
|
|
1821
|
+
const [a, s] = A(() => new Set(r)), [l, o] = A(() => t.length ? `/${t[0].name}` : ""), u = q(/* @__PURE__ */ new Map()), d = ie(() => {
|
|
1800
1822
|
const m = [];
|
|
1801
1823
|
return $t(t, 1, "", a, m), m;
|
|
1802
1824
|
}, [t, a]), p = d.some((m) => m.path === l) ? l : d[0]?.path ?? "";
|
|
@@ -1804,19 +1826,19 @@ function wa({
|
|
|
1804
1826
|
o(m), window.requestAnimationFrame(() => u.current.get(m)?.focus());
|
|
1805
1827
|
}
|
|
1806
1828
|
function f(m, g) {
|
|
1807
|
-
s((
|
|
1808
|
-
const b = new Set(
|
|
1829
|
+
s((w) => {
|
|
1830
|
+
const b = new Set(w);
|
|
1809
1831
|
return g ?? !b.has(m) ? b.add(m) : b.delete(m), b;
|
|
1810
1832
|
});
|
|
1811
1833
|
}
|
|
1812
1834
|
function _(m) {
|
|
1813
1835
|
const g = d.findIndex((b) => b.path === p);
|
|
1814
1836
|
if (g === -1) return;
|
|
1815
|
-
const
|
|
1816
|
-
m.key === "ArrowDown" ? (m.preventDefault(), g < d.length - 1 && c(d[g + 1].path)) : m.key === "ArrowUp" ? (m.preventDefault(), g > 0 && c(d[g - 1].path)) : m.key === "ArrowRight" ? (m.preventDefault(),
|
|
1837
|
+
const w = d[g];
|
|
1838
|
+
m.key === "ArrowDown" ? (m.preventDefault(), g < d.length - 1 && c(d[g + 1].path)) : m.key === "ArrowUp" ? (m.preventDefault(), g > 0 && c(d[g - 1].path)) : m.key === "ArrowRight" ? (m.preventDefault(), w.hasChildren && !a.has(w.path) ? f(w.path, !0) : w.hasChildren && g < d.length - 1 && c(d[g + 1].path)) : m.key === "ArrowLeft" ? (m.preventDefault(), w.hasChildren && a.has(w.path) ? f(w.path, !1) : w.parentPath && c(w.parentPath)) : m.key === "Home" ? (m.preventDefault(), c(d[0].path)) : m.key === "End" ? (m.preventDefault(), c(d[d.length - 1].path)) : (m.key === "Enter" || m.key === " ") && (m.preventDefault(), w.hasChildren && f(w.path));
|
|
1817
1839
|
}
|
|
1818
1840
|
return /* @__PURE__ */ e("ul", { className: "file-tree", role: "tree", "aria-label": n, onKeyDown: _, children: d.map((m) => {
|
|
1819
|
-
const g = a.has(m.path),
|
|
1841
|
+
const g = a.has(m.path), w = g ? Ot : Bt;
|
|
1820
1842
|
return /* @__PURE__ */ e(
|
|
1821
1843
|
"li",
|
|
1822
1844
|
{
|
|
@@ -1836,8 +1858,8 @@ function wa({
|
|
|
1836
1858
|
b.stopPropagation(), o(m.path), m.hasChildren && f(m.path);
|
|
1837
1859
|
},
|
|
1838
1860
|
children: /* @__PURE__ */ i("span", { className: "file-tree__row", children: [
|
|
1839
|
-
m.hasChildren ? /* @__PURE__ */ e(
|
|
1840
|
-
m.type === "folder" ? /* @__PURE__ */ e(
|
|
1861
|
+
m.hasChildren ? /* @__PURE__ */ e(me, { className: `file-tree__chevron${g ? " file-tree__chevron--open" : ""}`, size: 14, strokeWidth: 2, "aria-hidden": "true" }) : /* @__PURE__ */ e("span", { className: "file-tree__chevron-spacer", "aria-hidden": "true" }),
|
|
1862
|
+
m.type === "folder" ? /* @__PURE__ */ e(w, { className: "file-tree__icon", size: 15, strokeWidth: 2, "aria-hidden": "true" }) : /* @__PURE__ */ e(Pt, { className: "file-tree__icon", size: 15, strokeWidth: 2, "aria-hidden": "true" }),
|
|
1841
1863
|
/* @__PURE__ */ e("span", { className: "file-tree__name", children: m.name })
|
|
1842
1864
|
] })
|
|
1843
1865
|
},
|
|
@@ -1860,7 +1882,7 @@ function xa({
|
|
|
1860
1882
|
}) {
|
|
1861
1883
|
return /* @__PURE__ */ i("label", { className: "label", htmlFor: t, children: [
|
|
1862
1884
|
r,
|
|
1863
|
-
n ? /* @__PURE__ */ i(
|
|
1885
|
+
n ? /* @__PURE__ */ i(ee, { children: [
|
|
1864
1886
|
/* @__PURE__ */ e("span", { className: "label__required", "aria-hidden": "true", children: "*" }),
|
|
1865
1887
|
/* @__PURE__ */ e("span", { className: "q1-sr-only", children: "(必填)" })
|
|
1866
1888
|
] }) : null
|
|
@@ -1871,8 +1893,8 @@ function Te({
|
|
|
1871
1893
|
getText: n,
|
|
1872
1894
|
onClose: r
|
|
1873
1895
|
}) {
|
|
1874
|
-
const [a, s] =
|
|
1875
|
-
|
|
1896
|
+
const [a, s] = A(-1), l = q([]), o = q({ buffer: "", timer: 0 });
|
|
1897
|
+
O(() => () => window.clearTimeout(o.current.timer), []);
|
|
1876
1898
|
function u(c) {
|
|
1877
1899
|
s(c), l.current[c]?.focus();
|
|
1878
1900
|
}
|
|
@@ -1907,7 +1929,7 @@ function Ca({
|
|
|
1907
1929
|
entries: n,
|
|
1908
1930
|
children: r
|
|
1909
1931
|
}) {
|
|
1910
|
-
const [a, s] =
|
|
1932
|
+
const [a, s] = A(null), l = q(null), o = q(null), u = q(0), d = P(), p = a !== null, c = n.flatMap((h, x) => rn(h) ? [x] : []), { itemRefs: f, focusItem: _, reset: m, onMenuKeyDown: g } = Te({
|
|
1911
1933
|
focusableIndices: c,
|
|
1912
1934
|
getText: (h) => {
|
|
1913
1935
|
const x = n[h];
|
|
@@ -1915,7 +1937,7 @@ function Ca({
|
|
|
1915
1937
|
},
|
|
1916
1938
|
onClose: () => b()
|
|
1917
1939
|
});
|
|
1918
|
-
function
|
|
1940
|
+
function w(h, x) {
|
|
1919
1941
|
s({ x: h, y: x }), window.requestAnimationFrame(() => _(c[0]));
|
|
1920
1942
|
}
|
|
1921
1943
|
function b(h = !0) {
|
|
@@ -1924,35 +1946,35 @@ function Ca({
|
|
|
1924
1946
|
fe(() => {
|
|
1925
1947
|
if (!a || !o.current) return;
|
|
1926
1948
|
const h = o.current.getBoundingClientRect();
|
|
1927
|
-
let { x, y
|
|
1928
|
-
x + h.width > window.innerWidth - 8 && (x = Math.max(8, x - h.width)),
|
|
1929
|
-
}, [a]),
|
|
1949
|
+
let { x, y } = a;
|
|
1950
|
+
x + h.width > window.innerWidth - 8 && (x = Math.max(8, x - h.width)), y + h.height > window.innerHeight - 8 && (y = Math.max(8, y - h.height)), (x !== a.x || y !== a.y) && s({ x, y });
|
|
1951
|
+
}, [a]), O(() => {
|
|
1930
1952
|
if (!p) return;
|
|
1931
1953
|
function h(x) {
|
|
1932
1954
|
o.current && !o.current.contains(x.target) && b(!1);
|
|
1933
1955
|
}
|
|
1934
1956
|
return document.addEventListener("mousedown", h), () => document.removeEventListener("mousedown", h);
|
|
1935
1957
|
}, [p]);
|
|
1936
|
-
function
|
|
1937
|
-
h.preventDefault(),
|
|
1958
|
+
function N(h) {
|
|
1959
|
+
h.preventDefault(), w(h.clientX, h.clientY);
|
|
1938
1960
|
}
|
|
1939
1961
|
function v(h) {
|
|
1940
1962
|
if (h.shiftKey && h.key === "F10" || h.key === "ContextMenu") {
|
|
1941
1963
|
h.preventDefault();
|
|
1942
1964
|
const x = l.current.getBoundingClientRect();
|
|
1943
|
-
|
|
1965
|
+
w(x.left + 16, x.top + 16);
|
|
1944
1966
|
}
|
|
1945
1967
|
}
|
|
1946
1968
|
function D(h) {
|
|
1947
1969
|
const x = h.touches[0];
|
|
1948
1970
|
u.current = window.setTimeout(() => {
|
|
1949
|
-
x &&
|
|
1971
|
+
x && w(x.clientX, x.clientY);
|
|
1950
1972
|
}, 500);
|
|
1951
1973
|
}
|
|
1952
1974
|
function C() {
|
|
1953
1975
|
window.clearTimeout(u.current);
|
|
1954
1976
|
}
|
|
1955
|
-
return /* @__PURE__ */ i(
|
|
1977
|
+
return /* @__PURE__ */ i(ee, { children: [
|
|
1956
1978
|
/* @__PURE__ */ e(
|
|
1957
1979
|
"div",
|
|
1958
1980
|
{
|
|
@@ -1962,7 +1984,7 @@ function Ca({
|
|
|
1962
1984
|
role: "button",
|
|
1963
1985
|
"aria-haspopup": "menu",
|
|
1964
1986
|
"aria-label": `${t}(右键或 Shift+F10 打开菜单)`,
|
|
1965
|
-
onContextMenu:
|
|
1987
|
+
onContextMenu: N,
|
|
1966
1988
|
onKeyDown: v,
|
|
1967
1989
|
onTouchStart: D,
|
|
1968
1990
|
onTouchEnd: C,
|
|
@@ -1982,15 +2004,15 @@ function Ca({
|
|
|
1982
2004
|
children: n.map((h, x) => h.type === "separator" ? /* @__PURE__ */ e("div", { className: "menu__separator", role: "separator" }, `sep-${x}`) : h.type === "link" ? /* @__PURE__ */ i(
|
|
1983
2005
|
"a",
|
|
1984
2006
|
{
|
|
1985
|
-
ref: (
|
|
1986
|
-
f.current[x] =
|
|
2007
|
+
ref: (y) => {
|
|
2008
|
+
f.current[x] = y;
|
|
1987
2009
|
},
|
|
1988
2010
|
role: "menuitem",
|
|
1989
2011
|
tabIndex: -1,
|
|
1990
2012
|
href: h.href,
|
|
1991
2013
|
className: "menu__item",
|
|
1992
|
-
onClick: (
|
|
1993
|
-
|
|
2014
|
+
onClick: (y) => {
|
|
2015
|
+
y.preventDefault(), b();
|
|
1994
2016
|
},
|
|
1995
2017
|
children: [
|
|
1996
2018
|
h.icon ? /* @__PURE__ */ e("span", { className: "menu__item-icon", children: h.icon }) : null,
|
|
@@ -2002,8 +2024,8 @@ function Ca({
|
|
|
2002
2024
|
) : /* @__PURE__ */ i(
|
|
2003
2025
|
"button",
|
|
2004
2026
|
{
|
|
2005
|
-
ref: (
|
|
2006
|
-
f.current[x] =
|
|
2027
|
+
ref: (y) => {
|
|
2028
|
+
f.current[x] = y;
|
|
2007
2029
|
},
|
|
2008
2030
|
type: "button",
|
|
2009
2031
|
role: "menuitem",
|
|
@@ -2030,28 +2052,28 @@ function Da({
|
|
|
2030
2052
|
disabled: r,
|
|
2031
2053
|
align: a = "end"
|
|
2032
2054
|
}) {
|
|
2033
|
-
const [s, l] =
|
|
2055
|
+
const [s, l] = A(!1), o = q(null), u = P(), d = t.flatMap((b, N) => b.disabled ? [] : [N]), { itemRefs: p, focusItem: c, reset: f, onMenuKeyDown: _ } = Te({
|
|
2034
2056
|
focusableIndices: d,
|
|
2035
2057
|
getText: (b) => t[b].label,
|
|
2036
2058
|
onClose: () => g()
|
|
2037
2059
|
});
|
|
2038
2060
|
function m(b) {
|
|
2039
2061
|
l(!0);
|
|
2040
|
-
const
|
|
2041
|
-
window.requestAnimationFrame(() => c(
|
|
2062
|
+
const N = b === "first" ? d[0] : d[d.length - 1];
|
|
2063
|
+
window.requestAnimationFrame(() => c(N));
|
|
2042
2064
|
}
|
|
2043
2065
|
function g(b = !0) {
|
|
2044
2066
|
l(!1), f(), b && o.current?.focus();
|
|
2045
2067
|
}
|
|
2046
|
-
|
|
2068
|
+
O(() => {
|
|
2047
2069
|
if (!s) return;
|
|
2048
|
-
function b(
|
|
2070
|
+
function b(N) {
|
|
2049
2071
|
const v = o.current?.closest(".dots-menu");
|
|
2050
|
-
v && !v.contains(
|
|
2072
|
+
v && !v.contains(N.target) && g(!1);
|
|
2051
2073
|
}
|
|
2052
2074
|
return document.addEventListener("mousedown", b), () => document.removeEventListener("mousedown", b);
|
|
2053
2075
|
}, [s]);
|
|
2054
|
-
function
|
|
2076
|
+
function w(b) {
|
|
2055
2077
|
b.key === "ArrowDown" || b.key === "Enter" || b.key === " " ? (b.preventDefault(), m("first")) : b.key === "ArrowUp" && (b.preventDefault(), m("last"));
|
|
2056
2078
|
}
|
|
2057
2079
|
return /* @__PURE__ */ i("div", { className: "dots-menu", children: [
|
|
@@ -2067,7 +2089,7 @@ function Da({
|
|
|
2067
2089
|
"aria-controls": s ? u : void 0,
|
|
2068
2090
|
disabled: r,
|
|
2069
2091
|
onClick: () => s ? g() : m("first"),
|
|
2070
|
-
onKeyDown:
|
|
2092
|
+
onKeyDown: w,
|
|
2071
2093
|
children: /* @__PURE__ */ e(_t, { size: n === "sm" ? 14 : n === "lg" ? 20 : 16, strokeWidth: 2, "aria-hidden": "true" })
|
|
2072
2094
|
}
|
|
2073
2095
|
),
|
|
@@ -2079,11 +2101,11 @@ function Da({
|
|
|
2079
2101
|
"aria-label": "更多操作",
|
|
2080
2102
|
className: `menu__popup menu__popup--${a}`,
|
|
2081
2103
|
onKeyDown: _,
|
|
2082
|
-
children: t.map((b,
|
|
2104
|
+
children: t.map((b, N) => /* @__PURE__ */ e(
|
|
2083
2105
|
"button",
|
|
2084
2106
|
{
|
|
2085
2107
|
ref: (v) => {
|
|
2086
|
-
p.current[
|
|
2108
|
+
p.current[N] = v;
|
|
2087
2109
|
},
|
|
2088
2110
|
type: "button",
|
|
2089
2111
|
role: "menuitem",
|
|
@@ -2156,13 +2178,13 @@ function qa({ title: t, children: n, tone: r, icon: a, action: s, onDismiss: l,
|
|
|
2156
2178
|
u
|
|
2157
2179
|
), f = /* @__PURE__ */ i("p", { className: "banner__content", children: [
|
|
2158
2180
|
/* @__PURE__ */ e("span", { className: "banner__title", children: t }),
|
|
2159
|
-
n != null ? /* @__PURE__ */ i(
|
|
2181
|
+
n != null ? /* @__PURE__ */ i(ee, { children: [
|
|
2160
2182
|
" — ",
|
|
2161
2183
|
n
|
|
2162
2184
|
] }) : null
|
|
2163
2185
|
] }), _ = s ? p ? /* @__PURE__ */ e("a", { className: "banner__cta", href: s.href, children: s.label }) : /* @__PURE__ */ i("a", { className: "banner__action", href: s.href, children: [
|
|
2164
2186
|
s.label,
|
|
2165
|
-
/* @__PURE__ */ e(
|
|
2187
|
+
/* @__PURE__ */ e(me, { "aria-hidden": "true", size: 16, strokeWidth: 2 })
|
|
2166
2188
|
] }) : null, m = !p && l ? /* @__PURE__ */ e("button", { className: "banner__close", type: "button", "aria-label": "关闭横幅", onClick: l, children: /* @__PURE__ */ e(_e, { "aria-hidden": "true", size: 16, strokeWidth: 2 }) }) : null;
|
|
2167
2189
|
if (o) {
|
|
2168
2190
|
const g = Number.isFinite(o.value) ? Math.min(100, Math.max(0, o.value)) : 0;
|
|
@@ -2219,9 +2241,9 @@ function Ia(t) {
|
|
|
2219
2241
|
hover: _,
|
|
2220
2242
|
secondary: m,
|
|
2221
2243
|
divided: g,
|
|
2222
|
-
direction:
|
|
2244
|
+
direction: w,
|
|
2223
2245
|
shadow: b,
|
|
2224
|
-
bordered:
|
|
2246
|
+
bordered: N,
|
|
2225
2247
|
className: v,
|
|
2226
2248
|
children: D,
|
|
2227
2249
|
...C
|
|
@@ -2263,7 +2285,7 @@ function Sa({ className: t, ...n }) {
|
|
|
2263
2285
|
return /* @__PURE__ */ e("nav", { className: T("q1-navigation", t), ...n });
|
|
2264
2286
|
}
|
|
2265
2287
|
function Ta({ label: t, action: n, children: r, className: a, ...s }) {
|
|
2266
|
-
const l =
|
|
2288
|
+
const l = P(), o = t !== void 0;
|
|
2267
2289
|
return /* @__PURE__ */ i(
|
|
2268
2290
|
"section",
|
|
2269
2291
|
{
|
|
@@ -2286,7 +2308,7 @@ function za(t) {
|
|
|
2286
2308
|
n && "q1-navigation__item--active",
|
|
2287
2309
|
r && "q1-navigation__item--disabled",
|
|
2288
2310
|
d
|
|
2289
|
-
), _ = /* @__PURE__ */ i(
|
|
2311
|
+
), _ = /* @__PURE__ */ i(ee, { children: [
|
|
2290
2312
|
a ? /* @__PURE__ */ e("span", { className: "q1-navigation__item-icon", "aria-hidden": "true", children: a }) : null,
|
|
2291
2313
|
/* @__PURE__ */ i("span", { className: "q1-navigation__item-content", children: [
|
|
2292
2314
|
/* @__PURE__ */ e("span", { className: "q1-navigation__item-label", children: u }),
|
|
@@ -2303,7 +2325,7 @@ function za(t) {
|
|
|
2303
2325
|
href: r ? void 0 : p,
|
|
2304
2326
|
"aria-disabled": r || void 0,
|
|
2305
2327
|
"aria-current": n ? "page" : void 0,
|
|
2306
|
-
onClick: r ? (
|
|
2328
|
+
onClick: r ? (w) => w.preventDefault() : m.onClick,
|
|
2307
2329
|
children: _
|
|
2308
2330
|
}
|
|
2309
2331
|
) : /* @__PURE__ */ e("button", { type: "button", className: f, disabled: r, ...c, children: _ }),
|
|
@@ -2318,7 +2340,7 @@ function Ra({
|
|
|
2318
2340
|
onExpandedChange: s,
|
|
2319
2341
|
children: l
|
|
2320
2342
|
}) {
|
|
2321
|
-
const o =
|
|
2343
|
+
const o = P(), [u, d] = A(a), p = r !== void 0, c = p ? r : u;
|
|
2322
2344
|
return /* @__PURE__ */ i("div", { className: "q1-navigation__group", children: [
|
|
2323
2345
|
/* @__PURE__ */ i(
|
|
2324
2346
|
"button",
|
|
@@ -2334,25 +2356,25 @@ function Ra({
|
|
|
2334
2356
|
children: [
|
|
2335
2357
|
n ? /* @__PURE__ */ e("span", { className: "q1-navigation__group-icon", "aria-hidden": "true", children: n }) : null,
|
|
2336
2358
|
/* @__PURE__ */ e("span", { className: "q1-navigation__group-label", children: t }),
|
|
2337
|
-
/* @__PURE__ */ e(
|
|
2359
|
+
/* @__PURE__ */ e(me, { className: "q1-navigation__group-chevron", size: 16, strokeWidth: 2, "aria-hidden": "true" })
|
|
2338
2360
|
]
|
|
2339
2361
|
}
|
|
2340
2362
|
),
|
|
2341
2363
|
/* @__PURE__ */ e("div", { className: "q1-navigation__group-content", id: o, role: "group", hidden: !c, children: l })
|
|
2342
2364
|
] });
|
|
2343
2365
|
}
|
|
2344
|
-
const
|
|
2345
|
-
let
|
|
2366
|
+
const oe = 8, tt = 8, We = typeof document > "u" ? O : fe;
|
|
2367
|
+
let de = null, $e = 0, He = !1;
|
|
2346
2368
|
function un() {
|
|
2347
2369
|
if (typeof document > "u") return null;
|
|
2348
|
-
if (!
|
|
2370
|
+
if (!de || de.parentElement !== document.body) {
|
|
2349
2371
|
const t = document.body.querySelector(':scope > [data-q1-portal="context-switcher"]');
|
|
2350
|
-
|
|
2372
|
+
de = t ?? document.createElement("div"), He = !t, t || (de.setAttribute("data-q1-portal", "context-switcher"), document.body.append(de));
|
|
2351
2373
|
}
|
|
2352
|
-
return $e += 1,
|
|
2374
|
+
return $e += 1, de;
|
|
2353
2375
|
}
|
|
2354
2376
|
function mn() {
|
|
2355
|
-
$e = Math.max(0, $e - 1), !($e > 0) && (He &&
|
|
2377
|
+
$e = Math.max(0, $e - 1), !($e > 0) && (He && de?.remove(), de = null, He = !1);
|
|
2356
2378
|
}
|
|
2357
2379
|
function La({
|
|
2358
2380
|
currentContext: t,
|
|
@@ -2367,109 +2389,109 @@ function La({
|
|
|
2367
2389
|
onFooterAction: p,
|
|
2368
2390
|
label: c
|
|
2369
2391
|
}) {
|
|
2370
|
-
const [f, _] =
|
|
2392
|
+
const [f, _] = A(a), [m, g] = A(null), [w, b] = A({
|
|
2371
2393
|
align: "start",
|
|
2372
2394
|
side: "bottom",
|
|
2373
2395
|
direction: "ltr",
|
|
2374
|
-
left:
|
|
2375
|
-
top:
|
|
2376
|
-
}),
|
|
2377
|
-
function
|
|
2378
|
-
|
|
2396
|
+
left: oe,
|
|
2397
|
+
top: oe
|
|
2398
|
+
}), N = r !== void 0, v = N ? r : f, D = c ? `${c} ${t.textValue}` : t.textValue, C = q(null), h = q(null), x = q(null), y = q("selected"), k = q(!1), $ = q("trigger"), I = q(v), S = P();
|
|
2399
|
+
function L(E) {
|
|
2400
|
+
N || _(E), s?.(E);
|
|
2379
2401
|
}
|
|
2380
|
-
const
|
|
2381
|
-
...n.flatMap((
|
|
2382
|
-
...(d ?? []).map((
|
|
2383
|
-
], [d, n]),
|
|
2384
|
-
(
|
|
2385
|
-
), [
|
|
2386
|
-
for (const
|
|
2387
|
-
const z =
|
|
2388
|
-
(H) => H.kind === "item" && H.group.id ===
|
|
2402
|
+
const F = ie(() => [
|
|
2403
|
+
...n.flatMap((E) => E.items.map((z) => ({ kind: "item", group: E, item: z }))),
|
|
2404
|
+
...(d ?? []).map((E) => ({ kind: "action", action: E }))
|
|
2405
|
+
], [d, n]), G = ie(() => F.flatMap(
|
|
2406
|
+
(E, z) => E.kind === "item" ? !E.item.disabled && E.item.id !== o ? [z] : [] : E.action.disabled ? [] : [z]
|
|
2407
|
+
), [F, o]), X = (E) => F[E]?.kind === "item" ? F[E].item.textValue : F[E]?.action.textValue ?? "", V = ie(() => {
|
|
2408
|
+
for (const E of n) {
|
|
2409
|
+
const z = F.findIndex(
|
|
2410
|
+
(H) => H.kind === "item" && H.group.id === E.id && H.item.id === E.selectedId && !H.item.disabled && H.item.id !== o
|
|
2389
2411
|
);
|
|
2390
2412
|
if (z >= 0) return z;
|
|
2391
2413
|
}
|
|
2392
|
-
return
|
|
2393
|
-
}, [
|
|
2394
|
-
focusableIndices:
|
|
2395
|
-
getText:
|
|
2396
|
-
onClose: () =>
|
|
2414
|
+
return G[0];
|
|
2415
|
+
}, [F, G, n, o]), { itemRefs: re, focusItem: B, reset: Y, onMenuKeyDown: U } = Te({
|
|
2416
|
+
focusableIndices: G,
|
|
2417
|
+
getText: X,
|
|
2418
|
+
onClose: () => Q(!0)
|
|
2397
2419
|
});
|
|
2398
|
-
function
|
|
2399
|
-
|
|
2420
|
+
function Q(E) {
|
|
2421
|
+
$.current = E ? "trigger" : "preserve", L(!1), Y(), k.current = !1, E && C.current?.focus();
|
|
2400
2422
|
}
|
|
2401
|
-
function he(
|
|
2402
|
-
|
|
2423
|
+
function he(E) {
|
|
2424
|
+
y.current = E, $.current = "trigger", k.current = !1, L(!0);
|
|
2403
2425
|
}
|
|
2404
|
-
|
|
2405
|
-
const
|
|
2406
|
-
return g(
|
|
2426
|
+
O(() => {
|
|
2427
|
+
const E = un();
|
|
2428
|
+
return g(E), () => mn();
|
|
2407
2429
|
}, []), We(() => {
|
|
2408
|
-
const
|
|
2409
|
-
if (
|
|
2410
|
-
|
|
2430
|
+
const E = I.current;
|
|
2431
|
+
if (I.current = v, !E && v) {
|
|
2432
|
+
$.current = "trigger";
|
|
2411
2433
|
return;
|
|
2412
2434
|
}
|
|
2413
|
-
|
|
2435
|
+
!E || v || (Y(), k.current = !1, $.current === "trigger" && C.current?.focus());
|
|
2414
2436
|
}, [v, Y]), We(() => {
|
|
2415
|
-
if (!v || !m ||
|
|
2416
|
-
const
|
|
2417
|
-
if (
|
|
2418
|
-
if (
|
|
2437
|
+
if (!v || !m || k.current) return;
|
|
2438
|
+
const E = window.requestAnimationFrame(() => {
|
|
2439
|
+
if (k.current) return;
|
|
2440
|
+
if (k.current = !0, G.length === 0) {
|
|
2419
2441
|
x.current?.focus();
|
|
2420
2442
|
return;
|
|
2421
2443
|
}
|
|
2422
|
-
const z =
|
|
2444
|
+
const z = y.current === "last" ? G[G.length - 1] : V;
|
|
2423
2445
|
z !== void 0 && B(z);
|
|
2424
2446
|
});
|
|
2425
|
-
return () => window.cancelAnimationFrame(
|
|
2426
|
-
}, [B,
|
|
2447
|
+
return () => window.cancelAnimationFrame(E);
|
|
2448
|
+
}, [B, G, v, m, V]), We(() => {
|
|
2427
2449
|
if (!v || !m) return;
|
|
2428
|
-
function
|
|
2429
|
-
const ne = C.current,
|
|
2430
|
-
if (!ne || !
|
|
2431
|
-
const
|
|
2432
|
-
let
|
|
2433
|
-
const At = j === "rtl" ?
|
|
2450
|
+
function E() {
|
|
2451
|
+
const ne = C.current, J = x.current;
|
|
2452
|
+
if (!ne || !J) return;
|
|
2453
|
+
const le = ne.getBoundingClientRect(), Re = h.current?.getBoundingClientRect(), se = J.getBoundingClientRect(), M = window.innerWidth, R = window.innerHeight, j = getComputedStyle(ne).direction === "rtl" ? "rtl" : "ltr";
|
|
2454
|
+
let Z = "start";
|
|
2455
|
+
const At = j === "rtl" ? le.right - se.width : le.left, St = j === "rtl" ? le.left : le.right - se.width;
|
|
2434
2456
|
let pe = At;
|
|
2435
|
-
(pe <
|
|
2436
|
-
let Le = "bottom", be = (Re?.bottom ??
|
|
2437
|
-
be +
|
|
2438
|
-
(ge) => ge.align ===
|
|
2457
|
+
(pe < oe || pe + se.width > M - oe) && (Z = "end", pe = St), pe = Math.max(oe, Math.min(pe, M - se.width - oe));
|
|
2458
|
+
let Le = "bottom", be = (Re?.bottom ?? le.bottom) + tt;
|
|
2459
|
+
be + se.height > R - oe && (Le = "top", be = le.top - se.height - tt), be = Math.max(oe, Math.min(be, R - se.height - oe)), b(
|
|
2460
|
+
(ge) => ge.align === Z && ge.side === Le && ge.direction === j && ge.left === pe && ge.top === be ? ge : { align: Z, side: Le, direction: j, left: pe, top: be }
|
|
2439
2461
|
);
|
|
2440
2462
|
}
|
|
2441
2463
|
let z = 0;
|
|
2442
2464
|
function H() {
|
|
2443
2465
|
z || (z = window.requestAnimationFrame(() => {
|
|
2444
|
-
z = 0,
|
|
2466
|
+
z = 0, E();
|
|
2445
2467
|
}));
|
|
2446
2468
|
}
|
|
2447
|
-
|
|
2469
|
+
E();
|
|
2448
2470
|
const te = typeof ResizeObserver > "u" ? null : new ResizeObserver(H);
|
|
2449
2471
|
return x.current && te?.observe(x.current), h.current && te?.observe(h.current), window.addEventListener("resize", H), window.addEventListener("scroll", H, !0), () => {
|
|
2450
2472
|
window.removeEventListener("resize", H), window.removeEventListener("scroll", H, !0), te?.disconnect(), z && window.cancelAnimationFrame(z);
|
|
2451
2473
|
};
|
|
2452
|
-
}, [u, v, m]),
|
|
2474
|
+
}, [u, v, m]), O(() => {
|
|
2453
2475
|
if (!v) return;
|
|
2454
|
-
function
|
|
2476
|
+
function E(z) {
|
|
2455
2477
|
const H = z.target;
|
|
2456
|
-
!C.current?.contains(H) && !x.current?.contains(H) &&
|
|
2478
|
+
!C.current?.contains(H) && !x.current?.contains(H) && Q(!1);
|
|
2457
2479
|
}
|
|
2458
|
-
return document.addEventListener("pointerdown",
|
|
2480
|
+
return document.addEventListener("pointerdown", E), () => document.removeEventListener("pointerdown", E);
|
|
2459
2481
|
}, [v]);
|
|
2460
|
-
function Ce(
|
|
2461
|
-
|
|
2482
|
+
function Ce(E) {
|
|
2483
|
+
E.key === "ArrowDown" || E.key === "Enter" || E.key === " " ? (E.preventDefault(), v || he("selected")) : E.key === "ArrowUp" ? (E.preventDefault(), v || he("last")) : E.key === "Escape" && v && (E.preventDefault(), Q(!0));
|
|
2462
2484
|
}
|
|
2463
|
-
function ze(
|
|
2464
|
-
if (
|
|
2465
|
-
C.current?.focus(),
|
|
2485
|
+
function ze(E) {
|
|
2486
|
+
if (E.key === "Tab") {
|
|
2487
|
+
C.current?.focus(), Q(!1);
|
|
2466
2488
|
return;
|
|
2467
2489
|
}
|
|
2468
|
-
if (
|
|
2469
|
-
|
|
2490
|
+
if (G.length === 0 && (E.key === "ArrowDown" || E.key === "ArrowUp" || E.key === "Home" || E.key === "End" || E.key.length === 1 && /\S/.test(E.key))) {
|
|
2491
|
+
E.preventDefault();
|
|
2470
2492
|
return;
|
|
2471
2493
|
}
|
|
2472
|
-
U(
|
|
2494
|
+
U(E);
|
|
2473
2495
|
}
|
|
2474
2496
|
const De = v && m ? dt(
|
|
2475
2497
|
/* @__PURE__ */ i(
|
|
@@ -2481,41 +2503,41 @@ function La({
|
|
|
2481
2503
|
tabIndex: -1,
|
|
2482
2504
|
className: "q1-context-switcher__popup",
|
|
2483
2505
|
"aria-label": c ?? t.textValue,
|
|
2484
|
-
dir:
|
|
2485
|
-
"data-align":
|
|
2486
|
-
"data-side":
|
|
2487
|
-
style: { left:
|
|
2506
|
+
dir: w.direction,
|
|
2507
|
+
"data-align": w.align,
|
|
2508
|
+
"data-side": w.side,
|
|
2509
|
+
style: { left: w.left, top: w.top },
|
|
2488
2510
|
onKeyDown: ze,
|
|
2489
2511
|
children: [
|
|
2490
|
-
/* @__PURE__ */ e("div", { className: "q1-context-switcher__groups", children: n.map((
|
|
2512
|
+
/* @__PURE__ */ e("div", { className: "q1-context-switcher__groups", children: n.map((E) => /* @__PURE__ */ i(
|
|
2491
2513
|
"div",
|
|
2492
2514
|
{
|
|
2493
2515
|
className: "q1-context-switcher__group",
|
|
2494
2516
|
role: "group",
|
|
2495
|
-
"aria-label":
|
|
2517
|
+
"aria-label": E.textValue,
|
|
2496
2518
|
children: [
|
|
2497
|
-
/* @__PURE__ */ e("div", { className: "q1-context-switcher__group-label", "aria-hidden": "true", children:
|
|
2498
|
-
|
|
2499
|
-
const H =
|
|
2500
|
-
(
|
|
2519
|
+
/* @__PURE__ */ e("div", { className: "q1-context-switcher__group-label", "aria-hidden": "true", children: E.label }),
|
|
2520
|
+
E.items.map((z) => {
|
|
2521
|
+
const H = F.findIndex(
|
|
2522
|
+
(J) => J.kind === "item" && J.group.id === E.id && J.item.id === z.id
|
|
2501
2523
|
), te = z.id === o, ne = !!(z.disabled || te);
|
|
2502
2524
|
return /* @__PURE__ */ i(
|
|
2503
2525
|
"button",
|
|
2504
2526
|
{
|
|
2505
|
-
ref: (
|
|
2506
|
-
|
|
2527
|
+
ref: (J) => {
|
|
2528
|
+
re.current[H] = J;
|
|
2507
2529
|
},
|
|
2508
2530
|
type: "button",
|
|
2509
2531
|
role: "menuitemradio",
|
|
2510
2532
|
tabIndex: -1,
|
|
2511
2533
|
className: "q1-context-switcher__item",
|
|
2512
2534
|
"aria-label": z.textValue,
|
|
2513
|
-
"aria-checked":
|
|
2535
|
+
"aria-checked": E.selectedId === z.id,
|
|
2514
2536
|
"aria-disabled": ne || void 0,
|
|
2515
2537
|
"aria-busy": te || void 0,
|
|
2516
2538
|
"data-context-id": z.id,
|
|
2517
2539
|
onClick: () => {
|
|
2518
|
-
ne || (
|
|
2540
|
+
ne || ($.current = "trigger", l(z), N || Q(!0));
|
|
2519
2541
|
},
|
|
2520
2542
|
children: [
|
|
2521
2543
|
z.avatar ? /* @__PURE__ */ e("span", { className: "q1-context-switcher__avatar", "aria-hidden": "true", children: z.avatar }) : null,
|
|
@@ -2523,7 +2545,7 @@ function La({
|
|
|
2523
2545
|
/* @__PURE__ */ e("span", { className: "q1-context-switcher__item-label", children: z.label }),
|
|
2524
2546
|
z.description ? /* @__PURE__ */ e("span", { className: "q1-context-switcher__description", children: z.description }) : null
|
|
2525
2547
|
] }),
|
|
2526
|
-
te ? /* @__PURE__ */ e(ve, { className: "q1-context-switcher__pending", size: 16, strokeWidth: 2, "aria-hidden": "true" }) :
|
|
2548
|
+
te ? /* @__PURE__ */ e(ve, { className: "q1-context-switcher__pending", size: 16, strokeWidth: 2, "aria-hidden": "true" }) : E.selectedId === z.id ? /* @__PURE__ */ e(ce, { className: "q1-context-switcher__check", size: 16, strokeWidth: 2, "aria-hidden": "true" }) : null
|
|
2527
2549
|
]
|
|
2528
2550
|
},
|
|
2529
2551
|
z.id
|
|
@@ -2531,33 +2553,33 @@ function La({
|
|
|
2531
2553
|
})
|
|
2532
2554
|
]
|
|
2533
2555
|
},
|
|
2534
|
-
|
|
2556
|
+
E.id
|
|
2535
2557
|
)) }),
|
|
2536
|
-
d?.length ? /* @__PURE__ */ e("div", { className: "q1-context-switcher__footer", children: d.map((
|
|
2537
|
-
const z =
|
|
2558
|
+
d?.length ? /* @__PURE__ */ e("div", { className: "q1-context-switcher__footer", children: d.map((E) => {
|
|
2559
|
+
const z = F.findIndex((H) => H.kind === "action" && H.action.id === E.id);
|
|
2538
2560
|
return /* @__PURE__ */ i(
|
|
2539
2561
|
"button",
|
|
2540
2562
|
{
|
|
2541
2563
|
ref: (H) => {
|
|
2542
|
-
|
|
2564
|
+
re.current[z] = H;
|
|
2543
2565
|
},
|
|
2544
2566
|
type: "button",
|
|
2545
2567
|
role: "menuitem",
|
|
2546
2568
|
tabIndex: -1,
|
|
2547
2569
|
className: "q1-context-switcher__action",
|
|
2548
|
-
"aria-label":
|
|
2549
|
-
"aria-disabled":
|
|
2550
|
-
disabled:
|
|
2551
|
-
"data-context-action-id":
|
|
2570
|
+
"aria-label": E.textValue,
|
|
2571
|
+
"aria-disabled": E.disabled || void 0,
|
|
2572
|
+
disabled: E.disabled,
|
|
2573
|
+
"data-context-action-id": E.id,
|
|
2552
2574
|
onClick: () => {
|
|
2553
|
-
|
|
2575
|
+
$.current = "trigger", p?.(E), N || Q(!0);
|
|
2554
2576
|
},
|
|
2555
2577
|
children: [
|
|
2556
|
-
|
|
2557
|
-
/* @__PURE__ */ e("span", { className: "q1-context-switcher__item-label", children:
|
|
2578
|
+
E.icon ? /* @__PURE__ */ e("span", { className: "q1-context-switcher__action-icon", "aria-hidden": "true", children: E.icon }) : null,
|
|
2579
|
+
/* @__PURE__ */ e("span", { className: "q1-context-switcher__item-label", children: E.label })
|
|
2558
2580
|
]
|
|
2559
2581
|
},
|
|
2560
|
-
|
|
2582
|
+
E.id
|
|
2561
2583
|
);
|
|
2562
2584
|
}) }) : null
|
|
2563
2585
|
]
|
|
@@ -2576,7 +2598,7 @@ function La({
|
|
|
2576
2598
|
"aria-expanded": v,
|
|
2577
2599
|
"aria-controls": S,
|
|
2578
2600
|
"aria-label": D,
|
|
2579
|
-
onClick: () => v ?
|
|
2601
|
+
onClick: () => v ? Q(!0) : he("selected"),
|
|
2580
2602
|
onKeyDown: Ce,
|
|
2581
2603
|
children: [
|
|
2582
2604
|
t.avatar ? /* @__PURE__ */ e("span", { className: "q1-context-switcher__avatar", "aria-hidden": "true", children: t.avatar }) : null,
|
|
@@ -2603,34 +2625,34 @@ function hn({
|
|
|
2603
2625
|
tip: o = !0,
|
|
2604
2626
|
center: u = !1
|
|
2605
2627
|
}) {
|
|
2606
|
-
const [d, p] =
|
|
2628
|
+
const [d, p] = A(!1), [c, f] = A({
|
|
2607
2629
|
p: n,
|
|
2608
2630
|
left: 0,
|
|
2609
2631
|
top: 0,
|
|
2610
2632
|
caret: 0
|
|
2611
|
-
}), _ = q(null), m = q(null), g = q(null),
|
|
2612
|
-
const
|
|
2613
|
-
if (!
|
|
2614
|
-
const
|
|
2633
|
+
}), _ = q(null), m = q(null), g = q(null), w = P(), b = Ne(() => {
|
|
2634
|
+
const y = m.current, k = g.current;
|
|
2635
|
+
if (!y || !k) return;
|
|
2636
|
+
const $ = 8, I = 8, S = y.getBoundingClientRect(), L = k.offsetWidth, F = k.offsetHeight, G = document.documentElement.clientWidth, X = document.documentElement.clientHeight, V = S.left + S.width / 2, re = S.top + S.height / 2;
|
|
2615
2637
|
let B = n;
|
|
2616
|
-
n === "top" && S.top -
|
|
2638
|
+
n === "top" && S.top - I - F < $ && S.bottom + I + F <= X - $ ? B = "bottom" : n === "bottom" && S.bottom + I + F > X - $ && S.top - I - F >= $ ? B = "top" : n === "left" && S.left - I - L < $ && S.right + I + L <= G - $ ? B = "right" : n === "right" && S.right + I + L > G - $ && S.left - I - L >= $ && (B = "left");
|
|
2617
2639
|
let Y, U;
|
|
2618
|
-
B === "top" || B === "bottom" ? (Y = l === "start" ? S.left : l === "end" ? S.right -
|
|
2619
|
-
const
|
|
2620
|
-
f({ p: B, left: Y, top: U, caret:
|
|
2640
|
+
B === "top" || B === "bottom" ? (Y = l === "start" ? S.left : l === "end" ? S.right - L : V - L / 2, U = B === "top" ? S.top - I - F : S.bottom + I) : (U = l === "start" ? S.top : l === "end" ? S.bottom - F : re - F / 2, Y = B === "left" ? S.left - I - L : S.right + I), Y = Math.max($, Math.min(Y, G - $ - L)), U = Math.max($, Math.min(U, X - $ - F));
|
|
2641
|
+
const Q = B === "top" || B === "bottom" ? Math.max(12, Math.min(L - 12, V - Y)) : Math.max(12, Math.min(F - 12, re - U));
|
|
2642
|
+
f({ p: B, left: Y, top: U, caret: Q });
|
|
2621
2643
|
}, [n, l]);
|
|
2622
2644
|
fe(() => {
|
|
2623
2645
|
if (d)
|
|
2624
2646
|
return b(), window.addEventListener("scroll", b, !0), window.addEventListener("resize", b), () => {
|
|
2625
2647
|
window.removeEventListener("scroll", b, !0), window.removeEventListener("resize", b);
|
|
2626
2648
|
};
|
|
2627
|
-
}, [d, b]),
|
|
2649
|
+
}, [d, b]), O(
|
|
2628
2650
|
() => () => {
|
|
2629
2651
|
_.current && clearTimeout(_.current);
|
|
2630
2652
|
},
|
|
2631
2653
|
[]
|
|
2632
2654
|
);
|
|
2633
|
-
function
|
|
2655
|
+
function N() {
|
|
2634
2656
|
_.current && clearTimeout(_.current), _.current = setTimeout(() => p(!0), r);
|
|
2635
2657
|
}
|
|
2636
2658
|
function v() {
|
|
@@ -2647,39 +2669,39 @@ function hn({
|
|
|
2647
2669
|
o ? "" : "q1-tooltip__bubble--no-tip",
|
|
2648
2670
|
u ? "q1-tooltip__bubble--center" : ""
|
|
2649
2671
|
);
|
|
2650
|
-
function h(
|
|
2651
|
-
|
|
2672
|
+
function h(y) {
|
|
2673
|
+
y.key === "Escape" && v();
|
|
2652
2674
|
}
|
|
2653
2675
|
s && (!Ze(s) || s.type === Qe) && console.warn(
|
|
2654
2676
|
`Tooltip:children 必须是单个合法元素/组件(不能是纯文本、Fragment 或多个子节点),已回退为默认触发器${a ? `(文案:"${a}")` : "——但没有传 triggerLabel,会渲染成一个看不出用途的空文案按钮"}。`
|
|
2655
2677
|
);
|
|
2656
2678
|
const x = s && Ze(s) && s.type !== Qe ? Tt(s, {
|
|
2657
|
-
"aria-describedby":
|
|
2658
|
-
onFocus: (
|
|
2659
|
-
s.props.onFocus?.(
|
|
2679
|
+
"aria-describedby": w,
|
|
2680
|
+
onFocus: (y) => {
|
|
2681
|
+
s.props.onFocus?.(y), N();
|
|
2660
2682
|
},
|
|
2661
|
-
onBlur: (
|
|
2662
|
-
s.props.onBlur?.(
|
|
2683
|
+
onBlur: (y) => {
|
|
2684
|
+
s.props.onBlur?.(y), v();
|
|
2663
2685
|
},
|
|
2664
|
-
onKeyDown: (
|
|
2665
|
-
s.props.onKeyDown?.(
|
|
2686
|
+
onKeyDown: (y) => {
|
|
2687
|
+
s.props.onKeyDown?.(y), h(y);
|
|
2666
2688
|
}
|
|
2667
2689
|
}) : /* @__PURE__ */ e(
|
|
2668
2690
|
"button",
|
|
2669
2691
|
{
|
|
2670
2692
|
type: "button",
|
|
2671
2693
|
className: "q1-tooltip__trigger",
|
|
2672
|
-
"aria-describedby":
|
|
2673
|
-
onFocus:
|
|
2694
|
+
"aria-describedby": w,
|
|
2695
|
+
onFocus: N,
|
|
2674
2696
|
onBlur: v,
|
|
2675
2697
|
onKeyDown: h,
|
|
2676
2698
|
children: a
|
|
2677
2699
|
}
|
|
2678
2700
|
);
|
|
2679
|
-
return /* @__PURE__ */ i("span", { ref: m, className: "q1-tooltip", onMouseEnter:
|
|
2701
|
+
return /* @__PURE__ */ i("span", { ref: m, className: "q1-tooltip", onMouseEnter: N, onMouseLeave: v, children: [
|
|
2680
2702
|
x,
|
|
2681
2703
|
dt(
|
|
2682
|
-
/* @__PURE__ */ e("span", { ref: g, role: "tooltip", id:
|
|
2704
|
+
/* @__PURE__ */ e("span", { ref: g, role: "tooltip", id: w, className: C, style: D, children: t }),
|
|
2683
2705
|
document.body
|
|
2684
2706
|
)
|
|
2685
2707
|
] });
|
|
@@ -2709,7 +2731,7 @@ function Fa({
|
|
|
2709
2731
|
align: l = "start",
|
|
2710
2732
|
children: o
|
|
2711
2733
|
}) {
|
|
2712
|
-
const [u, d] =
|
|
2734
|
+
const [u, d] = A(!1), p = T(
|
|
2713
2735
|
"context-card-wrap",
|
|
2714
2736
|
`context-card-wrap--${s}`,
|
|
2715
2737
|
l !== "start" ? `context-card-wrap--align-${l}` : "",
|
|
@@ -2769,13 +2791,13 @@ function Ka({
|
|
|
2769
2791
|
...a ? { "--book-band": a } : null,
|
|
2770
2792
|
...s ? { "--book-text": s } : null,
|
|
2771
2793
|
...m ? { "--book-width": m } : null
|
|
2772
|
-
},
|
|
2794
|
+
}, w = l ? /* @__PURE__ */ e("span", { className: "book__icon", "aria-hidden": "true", children: l }) : null;
|
|
2773
2795
|
return /* @__PURE__ */ e("div", { className: _, style: g, ...f, children: /* @__PURE__ */ i("div", { className: "book__inner", children: [
|
|
2774
2796
|
/* @__PURE__ */ i("div", { className: "book__cover", children: [
|
|
2775
2797
|
o ? /* @__PURE__ */ e("span", { className: "book__illustration", "aria-hidden": "true", children: o }) : null,
|
|
2776
|
-
n === "stripe" && !o ? /* @__PURE__ */ e("span", { className: "book__band", "aria-hidden": "true", children:
|
|
2798
|
+
n === "stripe" && !o ? /* @__PURE__ */ e("span", { className: "book__band", "aria-hidden": "true", children: w }) : null,
|
|
2777
2799
|
/* @__PURE__ */ i("span", { className: "book__label", children: [
|
|
2778
|
-
n === "simple" || o ?
|
|
2800
|
+
n === "simple" || o ? w : null,
|
|
2779
2801
|
/* @__PURE__ */ e("span", { className: "book__title", children: t })
|
|
2780
2802
|
] }),
|
|
2781
2803
|
/* @__PURE__ */ e("span", { className: "book__gutter", "aria-hidden": "true" })
|
|
@@ -2799,8 +2821,8 @@ function fn({ className: t } = {}) {
|
|
|
2799
2821
|
] });
|
|
2800
2822
|
}
|
|
2801
2823
|
function _n({ address: t, className: n }) {
|
|
2802
|
-
const r = t.lastIndexOf("/"), a = r > 0 ? t.slice(0, r) : t, s = r > 0 ? t.slice(r) : "", [l, o] =
|
|
2803
|
-
|
|
2824
|
+
const r = t.lastIndexOf("/"), a = r > 0 ? t.slice(0, r) : t, s = r > 0 ? t.slice(r) : "", [l, o] = A(!1), u = q(void 0);
|
|
2825
|
+
O(() => () => clearTimeout(u.current), []);
|
|
2804
2826
|
const d = async () => {
|
|
2805
2827
|
try {
|
|
2806
2828
|
await gt(t), o(!0), clearTimeout(u.current), u.current = setTimeout(() => o(!1), 1500);
|
|
@@ -2812,7 +2834,7 @@ function _n({ address: t, className: n }) {
|
|
|
2812
2834
|
/* @__PURE__ */ e("span", { className: "browser__url-head", children: a }),
|
|
2813
2835
|
s ? /* @__PURE__ */ e("span", { className: "browser__url-tail", children: s }) : null
|
|
2814
2836
|
] }),
|
|
2815
|
-
/* @__PURE__ */ e("button", { type: "button", className: "browser__address-copy", onClick: d, "aria-label": "复制网址", children: l ? /* @__PURE__ */ e(
|
|
2837
|
+
/* @__PURE__ */ e("button", { type: "button", className: "browser__address-copy", onClick: d, "aria-label": "复制网址", children: l ? /* @__PURE__ */ e(ce, { className: "browser__address-icon", size: 12, strokeWidth: 2, "aria-hidden": "true" }) : /* @__PURE__ */ e(we, { className: "browser__address-icon", size: 12, strokeWidth: 2, "aria-hidden": "true" }) }),
|
|
2816
2838
|
/* @__PURE__ */ e("span", { className: "q1-sr-only", role: "status", "aria-live": "polite", children: l ? "已复制网址" : "" })
|
|
2817
2839
|
] });
|
|
2818
2840
|
}
|
|
@@ -2849,8 +2871,8 @@ const Et = (t) => t !== void 0 && Number.isFinite(t) && t > 0 ? t : void 0, Mt =
|
|
|
2849
2871
|
return n ? new RegExp("\\p{Script=Han}", "u").test(n[0]) ? n[0] : n.split(/\s+/).slice(0, 2).map((r) => r[0]).join("").toUpperCase() : "";
|
|
2850
2872
|
};
|
|
2851
2873
|
function yn({ title: t, src: n, letter: r, glyph: a, placeholder: s = !1, icon: l, iconColor: o, size: u, className: d }) {
|
|
2852
|
-
const [p, c] =
|
|
2853
|
-
return /* @__PURE__ */ i("span", { className: T("avatar",
|
|
2874
|
+
const [p, c] = A(null), f = Et(u), _ = !!n && p !== n, m = t.trim() || "头像", g = r ? { variant: "avatar--letter", node: r } : a ? { variant: "avatar--glyph", node: a } : { variant: "avatar--letter", node: gn(t) }, w = s ? "avatar--placeholder" : _ ? "avatar--image" : g.variant, b = s ? { "aria-hidden": !0 } : _ ? {} : { role: "img", "aria-label": m };
|
|
2875
|
+
return /* @__PURE__ */ i("span", { className: T("avatar", w, d), style: Mt(f), ...b, children: [
|
|
2854
2876
|
_ ? /* @__PURE__ */ e(
|
|
2855
2877
|
"img",
|
|
2856
2878
|
{
|
|
@@ -2882,11 +2904,11 @@ function Ba({
|
|
|
2882
2904
|
reverse: l = !1,
|
|
2883
2905
|
className: o
|
|
2884
2906
|
}) {
|
|
2885
|
-
const u = Et(r), d = u ?? 32, p = a !== void 0 && Number.isFinite(a) && a >= 0 ? Math.floor(a) : void 0, c = p !== void 0 && t.length > p ? t.slice(0, p) : t, f = t.length - c.length, _ = c.length + (f > 0 ? 1 : 0), m = s !== "auto" && Number.isFinite(s) ? Math.max(0, s) : Math.round(d * 0.3), g = { ...Mt(u), "--q1-avatar-overlap": `${m}px` },
|
|
2907
|
+
const u = Et(r), d = u ?? 32, p = a !== void 0 && Number.isFinite(a) && a >= 0 ? Math.floor(a) : void 0, c = p !== void 0 && t.length > p ? t.slice(0, p) : t, f = t.length - c.length, _ = c.length + (f > 0 ? 1 : 0), m = s !== "auto" && Number.isFinite(s) ? Math.max(0, s) : Math.round(d * 0.3), g = { ...Mt(u), "--q1-avatar-overlap": `${m}px` }, w = (N) => l ? void 0 : _ - 1 - N, b = n ? { role: "group", "aria-label": n } : {};
|
|
2886
2908
|
return /* @__PURE__ */ i("span", { className: T("avatar-group", o), style: g, ...b, children: [
|
|
2887
|
-
c.map((
|
|
2909
|
+
c.map((N, v) => (
|
|
2888
2910
|
// 成员不再 aria-hidden——每个 Avatar 自带 aria-label(名字),读屏逐个念。
|
|
2889
|
-
/* @__PURE__ */ e("span", { className: "avatar-group__item", style: { zIndex:
|
|
2911
|
+
/* @__PURE__ */ e("span", { className: "avatar-group__item", style: { zIndex: w(v) }, children: /* @__PURE__ */ e(yn, { ...N, size: u }) }, `${N.title}-${v}`)
|
|
2890
2912
|
)),
|
|
2891
2913
|
f > 0 ? (
|
|
2892
2914
|
// +N 独立可访问名「还有 N 位成员」,不再 aria-hidden。
|
|
@@ -2894,7 +2916,7 @@ function Ba({
|
|
|
2894
2916
|
"span",
|
|
2895
2917
|
{
|
|
2896
2918
|
className: "avatar avatar--overflow avatar-group__item",
|
|
2897
|
-
style: { zIndex:
|
|
2919
|
+
style: { zIndex: w(c.length) },
|
|
2898
2920
|
role: "img",
|
|
2899
2921
|
"aria-label": `还有 ${f} 位成员`,
|
|
2900
2922
|
children: [
|
|
@@ -2913,7 +2935,7 @@ function Ha({
|
|
|
2913
2935
|
className: a,
|
|
2914
2936
|
children: s
|
|
2915
2937
|
}) {
|
|
2916
|
-
if (s && r) return /* @__PURE__ */ e(
|
|
2938
|
+
if (s && r) return /* @__PURE__ */ e(ee, { children: s });
|
|
2917
2939
|
const l = T(
|
|
2918
2940
|
"skeleton",
|
|
2919
2941
|
`skeleton--${t}`,
|
|
@@ -3012,7 +3034,7 @@ function Ya({
|
|
|
3012
3034
|
className: "twc__copy",
|
|
3013
3035
|
"aria-label": `复制${t}`,
|
|
3014
3036
|
onClick: () => l(o, r),
|
|
3015
|
-
children: s ? /* @__PURE__ */ e(
|
|
3037
|
+
children: s ? /* @__PURE__ */ e(ce, { size: 14, strokeWidth: 2, "aria-hidden": "true" }) : /* @__PURE__ */ e(we, { size: 14, strokeWidth: 2, "aria-hidden": "true" })
|
|
3016
3038
|
}
|
|
3017
3039
|
)
|
|
3018
3040
|
] });
|
|
@@ -3044,7 +3066,7 @@ function Xa({
|
|
|
3044
3066
|
u(s ?? d.join(`
|
|
3045
3067
|
`), "已复制命令"), l?.();
|
|
3046
3068
|
},
|
|
3047
|
-
children: o ? /* @__PURE__ */ e(
|
|
3069
|
+
children: o ? /* @__PURE__ */ e(ce, { size: 14, strokeWidth: 2, "aria-hidden": "true" }) : /* @__PURE__ */ e(we, { size: 14, strokeWidth: 2, "aria-hidden": "true" })
|
|
3048
3070
|
}
|
|
3049
3071
|
)
|
|
3050
3072
|
] });
|
|
@@ -3077,7 +3099,7 @@ function Za({
|
|
|
3077
3099
|
label: l,
|
|
3078
3100
|
indeterminate: o = !1
|
|
3079
3101
|
}) {
|
|
3080
|
-
const { boxPx: u, radius: d, strokeWidth: p, valueFontSize: c } = vn[n], f = 2 * Math.PI * d, _ = Math.min(100, Math.max(0, t ?? 0)), m = 50, g = o ? 25 : _,
|
|
3102
|
+
const { boxPx: u, radius: d, strokeWidth: p, valueFontSize: c } = vn[n], f = 2 * Math.PI * d, _ = Math.min(100, Math.max(0, t ?? 0)), m = 50, g = o ? 25 : _, w = o ? 0 : Cn(_, p, f), b = o ? 0 : Math.max(0, 100 - _ - w), N = -90 + (g + w / 2) / 100 * 360, v = o ? "primary" : Dn(_, s, a);
|
|
3081
3103
|
return /* @__PURE__ */ i(
|
|
3082
3104
|
"span",
|
|
3083
3105
|
{
|
|
@@ -3100,7 +3122,7 @@ function Za({
|
|
|
3100
3122
|
fill: "none",
|
|
3101
3123
|
strokeLinecap: "round",
|
|
3102
3124
|
strokeDasharray: `${b / 100 * f} ${f}`,
|
|
3103
|
-
transform: `rotate(${
|
|
3125
|
+
transform: `rotate(${N} ${m} ${m})`
|
|
3104
3126
|
}
|
|
3105
3127
|
),
|
|
3106
3128
|
/* @__PURE__ */ e(
|
|
@@ -3220,7 +3242,7 @@ function er({ previous: t, next: n }) {
|
|
|
3220
3242
|
/* @__PURE__ */ e("span", { className: "pagination__label", children: "下一页" }),
|
|
3221
3243
|
/* @__PURE__ */ i("span", { className: "pagination__title-frame", children: [
|
|
3222
3244
|
/* @__PURE__ */ e("span", { className: "pagination__title", children: n.title }),
|
|
3223
|
-
/* @__PURE__ */ e("span", { className: "pagination__chevron-slot", "aria-hidden": "true", children: /* @__PURE__ */ e(
|
|
3245
|
+
/* @__PURE__ */ e("span", { className: "pagination__chevron-slot", "aria-hidden": "true", children: /* @__PURE__ */ e(me, { className: "pagination__chevron", size: 20, strokeWidth: 2 }) })
|
|
3224
3246
|
] })
|
|
3225
3247
|
]
|
|
3226
3248
|
}
|
|
@@ -3233,7 +3255,7 @@ function tr({
|
|
|
3233
3255
|
noBorder: r,
|
|
3234
3256
|
initialExpanded: a = !1
|
|
3235
3257
|
}) {
|
|
3236
|
-
const [s, l] =
|
|
3258
|
+
const [s, l] = A(a), o = P(), u = s ? t : t.slice(0, n), d = t.length - n;
|
|
3237
3259
|
return /* @__PURE__ */ i("div", { className: "show-more", children: [
|
|
3238
3260
|
/* @__PURE__ */ e("ul", { className: "show-more__list", id: o, children: u.map((p) => /* @__PURE__ */ e("li", { className: "show-more__row", children: p }, p)) }),
|
|
3239
3261
|
d > 0 ? /* @__PURE__ */ e("div", { className: `show-more__trigger-row${r ? " show-more__trigger-row--no-border" : ""}`, children: /* @__PURE__ */ i(
|
|
@@ -3389,8 +3411,8 @@ function Ke(t) {
|
|
|
3389
3411
|
a && s && a.setAttribute("content", s);
|
|
3390
3412
|
}
|
|
3391
3413
|
function An() {
|
|
3392
|
-
const [t, n] =
|
|
3393
|
-
return
|
|
3414
|
+
const [t, n] = A(lt);
|
|
3415
|
+
return O(() => {
|
|
3394
3416
|
Ke(t);
|
|
3395
3417
|
const a = window.matchMedia("(prefers-color-scheme: dark)"), s = () => t === "system" && Ke("system"), l = () => n(lt());
|
|
3396
3418
|
return a.addEventListener("change", s), window.addEventListener(Fe, l), window.addEventListener("storage", l), () => {
|
|
@@ -3406,7 +3428,7 @@ const Sn = [
|
|
|
3406
3428
|
{ mode: "dark", label: "深色", Icon: Yt }
|
|
3407
3429
|
];
|
|
3408
3430
|
function or({ small: t, disabled: n }) {
|
|
3409
|
-
const r =
|
|
3431
|
+
const r = P(), [a, s] = An();
|
|
3410
3432
|
return /* @__PURE__ */ i(
|
|
3411
3433
|
"fieldset",
|
|
3412
3434
|
{
|
|
@@ -3450,14 +3472,14 @@ function cr({
|
|
|
3450
3472
|
function o(u) {
|
|
3451
3473
|
const d = s.current;
|
|
3452
3474
|
if (!d) return;
|
|
3453
|
-
const p = Array.from(d.children), c = l ? d.scrollLeft : d.scrollTop, f = l ? d.clientWidth : d.clientHeight, _ = c + (u === 1 ? f : 0), m = (D) => l ? D.offsetLeft : D.offsetTop, g = (D) => l ? D.offsetLeft + D.offsetWidth : D.offsetTop + D.offsetHeight,
|
|
3454
|
-
if (!
|
|
3475
|
+
const p = Array.from(d.children), c = l ? d.scrollLeft : d.scrollTop, f = l ? d.clientWidth : d.clientHeight, _ = c + (u === 1 ? f : 0), m = (D) => l ? D.offsetLeft : D.offsetTop, g = (D) => l ? D.offsetLeft + D.offsetWidth : D.offsetTop + D.offsetHeight, w = u === 1 ? p.find((D) => g(D) > _ + 1) : [...p].reverse().find((D) => m(D) < c - 1);
|
|
3476
|
+
if (!w) return;
|
|
3455
3477
|
const b = qt() ? "auto" : "smooth";
|
|
3456
3478
|
if (l) {
|
|
3457
|
-
|
|
3479
|
+
w.scrollIntoView({ behavior: b, inline: "start", block: "nearest" });
|
|
3458
3480
|
return;
|
|
3459
3481
|
}
|
|
3460
|
-
const
|
|
3482
|
+
const N = parseFloat(getComputedStyle(d).paddingTop) || 0, v = w.getBoundingClientRect().top - d.getBoundingClientRect().top - N;
|
|
3461
3483
|
d.scrollTo({ top: d.scrollTop + v, behavior: b });
|
|
3462
3484
|
}
|
|
3463
3485
|
return /* @__PURE__ */ i("div", { className: l ? "scroller-buttons" : "scroller-buttons scroller-buttons--vertical", children: [
|
|
@@ -3479,13 +3501,13 @@ function cr({
|
|
|
3479
3501
|
className: "scroller-buttons__control",
|
|
3480
3502
|
"aria-label": `${l ? "向右滚动" : "向下滚动"}${n}`,
|
|
3481
3503
|
onClick: () => o(1),
|
|
3482
|
-
children: l ? /* @__PURE__ */ e(
|
|
3504
|
+
children: l ? /* @__PURE__ */ e(me, { size: 16, strokeWidth: 2, "aria-hidden": "true" }) : /* @__PURE__ */ e(ae, { size: 16, strokeWidth: 2, "aria-hidden": "true" })
|
|
3483
3505
|
}
|
|
3484
3506
|
)
|
|
3485
3507
|
] });
|
|
3486
3508
|
}
|
|
3487
3509
|
function dr({ label: t, unit: n, min: r = 0, max: a = 100, step: s = 1, defaultValue: l }) {
|
|
3488
|
-
const [o, u] =
|
|
3510
|
+
const [o, u] = A(l), d = P(), p = (o - r) / (a - r) * 100;
|
|
3489
3511
|
return /* @__PURE__ */ i("div", { className: "slider-field", children: [
|
|
3490
3512
|
/* @__PURE__ */ i("div", { className: "slider-field__head", children: [
|
|
3491
3513
|
/* @__PURE__ */ e("label", { className: "slider-field__label", htmlFor: d, children: t }),
|
|
@@ -3511,7 +3533,7 @@ function dr({ label: t, unit: n, min: r = 0, max: a = 100, step: s = 1, defaultV
|
|
|
3511
3533
|
] });
|
|
3512
3534
|
}
|
|
3513
3535
|
function ur({ min: t = 0, max: n = 100, step: r = 1, defaultLow: a, defaultHigh: s, disabled: l }) {
|
|
3514
|
-
const [o, u] =
|
|
3536
|
+
const [o, u] = A(a), [d, p] = A(s), c = P(), f = P(), _ = (o - t) / (n - t) * 100, m = (d - t) / (n - t) * 100, g = (b) => u(Math.min(b, d)), w = (b) => p(Math.max(b, o));
|
|
3515
3537
|
return /* @__PURE__ */ i("div", { className: `range-slider${l ? " range-slider--disabled" : ""}`, children: [
|
|
3516
3538
|
/* @__PURE__ */ e("label", { className: "q1-sr-only", htmlFor: c, children: "区间下限" }),
|
|
3517
3539
|
/* @__PURE__ */ e(
|
|
@@ -3556,7 +3578,7 @@ function ur({ min: t = 0, max: n = 100, step: r = 1, defaultLow: a, defaultHigh:
|
|
|
3556
3578
|
step: r,
|
|
3557
3579
|
value: d,
|
|
3558
3580
|
disabled: l,
|
|
3559
|
-
onChange: (b) =>
|
|
3581
|
+
onChange: (b) => w(Number(b.target.value))
|
|
3560
3582
|
}
|
|
3561
3583
|
)
|
|
3562
3584
|
] }),
|
|
@@ -3572,20 +3594,20 @@ function ur({ min: t = 0, max: n = 100, step: r = 1, defaultLow: a, defaultHigh:
|
|
|
3572
3594
|
step: r,
|
|
3573
3595
|
value: d,
|
|
3574
3596
|
disabled: l,
|
|
3575
|
-
onChange: (b) =>
|
|
3597
|
+
onChange: (b) => w(Number(b.target.value))
|
|
3576
3598
|
}
|
|
3577
3599
|
)
|
|
3578
3600
|
] });
|
|
3579
3601
|
}
|
|
3580
3602
|
function Ee({ crumb: t }) {
|
|
3581
|
-
const n = /* @__PURE__ */ i(
|
|
3603
|
+
const n = /* @__PURE__ */ i(ee, { children: [
|
|
3582
3604
|
t.icon ? /* @__PURE__ */ e("span", { className: "breadcrumb__icon", "aria-hidden": "true", children: t.icon }) : null,
|
|
3583
3605
|
t.label
|
|
3584
3606
|
] });
|
|
3585
3607
|
return t.isCurrent ? /* @__PURE__ */ e("span", { className: "breadcrumb__link breadcrumb__link--current", "aria-current": "page", children: n }) : t.isDisabled ? /* @__PURE__ */ e("span", { className: "breadcrumb__link breadcrumb__link--disabled", "aria-disabled": "true", children: n }) : /* @__PURE__ */ e("a", { className: "breadcrumb__link", href: t.href ?? "#breadcrumb", children: n });
|
|
3586
3608
|
}
|
|
3587
3609
|
function Me() {
|
|
3588
|
-
return /* @__PURE__ */ e(
|
|
3610
|
+
return /* @__PURE__ */ e(me, { className: "breadcrumb__separator", "aria-hidden": "true", size: 16, strokeWidth: 2 });
|
|
3589
3611
|
}
|
|
3590
3612
|
function mr({
|
|
3591
3613
|
items: t,
|
|
@@ -3599,7 +3621,7 @@ function mr({
|
|
|
3599
3621
|
] }, s.label)) }) });
|
|
3600
3622
|
}
|
|
3601
3623
|
function hr({ items: t, label: n }) {
|
|
3602
|
-
const [r, a] =
|
|
3624
|
+
const [r, a] = A(!1), s = t[0], l = t[t.length - 1], o = t.slice(1, -1);
|
|
3603
3625
|
return /* @__PURE__ */ e("nav", { className: "breadcrumb", "aria-label": n, "data-expanded": r ? "true" : "false", children: /* @__PURE__ */ i("ol", { className: "breadcrumb__list", children: [
|
|
3604
3626
|
/* @__PURE__ */ i("li", { className: "breadcrumb__item", children: [
|
|
3605
3627
|
/* @__PURE__ */ e(Ee, { crumb: s }),
|
|
@@ -3627,8 +3649,8 @@ function hr({ items: t, label: n }) {
|
|
|
3627
3649
|
] }) });
|
|
3628
3650
|
}
|
|
3629
3651
|
function pr({ open: t, onClose: n, title: r, side: a = "right", children: s, footer: l }) {
|
|
3630
|
-
const o = q(null), u =
|
|
3631
|
-
if (
|
|
3652
|
+
const o = q(null), u = P();
|
|
3653
|
+
if (O(() => {
|
|
3632
3654
|
if (!t) return;
|
|
3633
3655
|
const p = window.setTimeout(
|
|
3634
3656
|
() => o.current?.querySelector("button, input, [tabindex]")?.focus(),
|
|
@@ -3648,7 +3670,7 @@ function pr({ open: t, onClose: n, title: r, side: a = "right", children: s, foo
|
|
|
3648
3670
|
p.shiftKey && document.activeElement === f ? (p.preventDefault(), _.focus()) : !p.shiftKey && document.activeElement === _ && (p.preventDefault(), f.focus());
|
|
3649
3671
|
}
|
|
3650
3672
|
}
|
|
3651
|
-
return /* @__PURE__ */ i(
|
|
3673
|
+
return /* @__PURE__ */ i(ee, { children: [
|
|
3652
3674
|
/* @__PURE__ */ e("div", { className: "sheet__backdrop", "aria-hidden": "true", onMouseDown: (p) => p.preventDefault() }),
|
|
3653
3675
|
/* @__PURE__ */ i(
|
|
3654
3676
|
"div",
|
|
@@ -3672,11 +3694,11 @@ function pr({ open: t, onClose: n, title: r, side: a = "right", children: s, foo
|
|
|
3672
3694
|
] });
|
|
3673
3695
|
}
|
|
3674
3696
|
function fr({ label: t, entries: n, variant: r = "default", size: a = "md", align: s = "start", menuButtonLabel: l, icon: o }) {
|
|
3675
|
-
const [u, d] =
|
|
3697
|
+
const [u, d] = A(!1), [p, c] = A(-1), f = q(null), _ = q([]), m = q({ buffer: "", timer: 0 }), g = P(), w = n.map((h, x) => x);
|
|
3676
3698
|
function b(h) {
|
|
3677
3699
|
c(h), _.current[h]?.focus();
|
|
3678
3700
|
}
|
|
3679
|
-
function
|
|
3701
|
+
function N(h) {
|
|
3680
3702
|
d(!0);
|
|
3681
3703
|
const x = h === "first" ? 0 : n.length - 1;
|
|
3682
3704
|
window.requestAnimationFrame(() => b(x));
|
|
@@ -3684,23 +3706,23 @@ function fr({ label: t, entries: n, variant: r = "default", size: a = "md", alig
|
|
|
3684
3706
|
function v(h = !0) {
|
|
3685
3707
|
d(!1), c(-1), h && f.current?.focus();
|
|
3686
3708
|
}
|
|
3687
|
-
|
|
3709
|
+
O(() => {
|
|
3688
3710
|
if (!u) return;
|
|
3689
3711
|
function h(x) {
|
|
3690
|
-
const
|
|
3691
|
-
|
|
3712
|
+
const y = f.current?.closest(".split-button");
|
|
3713
|
+
y && !y.contains(x.target) && v(!1);
|
|
3692
3714
|
}
|
|
3693
3715
|
return document.addEventListener("mousedown", h), () => document.removeEventListener("mousedown", h);
|
|
3694
3716
|
}, [u]);
|
|
3695
3717
|
function D(h) {
|
|
3696
|
-
h.key === "ArrowDown" || h.key === "Enter" || h.key === " " ? (h.preventDefault(),
|
|
3718
|
+
h.key === "ArrowDown" || h.key === "Enter" || h.key === " " ? (h.preventDefault(), N("first")) : h.key === "ArrowUp" && (h.preventDefault(), N("last"));
|
|
3697
3719
|
}
|
|
3698
3720
|
function C(h) {
|
|
3699
|
-
const x =
|
|
3721
|
+
const x = w.indexOf(p);
|
|
3700
3722
|
if (h.key === "ArrowDown")
|
|
3701
|
-
h.preventDefault(), b(
|
|
3723
|
+
h.preventDefault(), b(w[(x + 1) % w.length]);
|
|
3702
3724
|
else if (h.key === "ArrowUp")
|
|
3703
|
-
h.preventDefault(), b(
|
|
3725
|
+
h.preventDefault(), b(w[(x - 1 + w.length) % w.length]);
|
|
3704
3726
|
else if (h.key === "Home")
|
|
3705
3727
|
h.preventDefault(), b(0);
|
|
3706
3728
|
else if (h.key === "End")
|
|
@@ -3709,8 +3731,8 @@ function fr({ label: t, entries: n, variant: r = "default", size: a = "md", alig
|
|
|
3709
3731
|
h.preventDefault(), v();
|
|
3710
3732
|
else if (h.key.length === 1 && /\S/.test(h.key)) {
|
|
3711
3733
|
window.clearTimeout(m.current.timer), m.current.buffer += h.key.toLowerCase(), m.current.timer = window.setTimeout(() => m.current.buffer = "", 500);
|
|
3712
|
-
const
|
|
3713
|
-
|
|
3734
|
+
const y = w.find((k) => n[k].label.toLowerCase().startsWith(m.current.buffer));
|
|
3735
|
+
y !== void 0 && b(y);
|
|
3714
3736
|
}
|
|
3715
3737
|
}
|
|
3716
3738
|
return /* @__PURE__ */ i("div", { className: `split-button split-button--${r} split-button--${a}`, children: [
|
|
@@ -3728,7 +3750,7 @@ function fr({ label: t, entries: n, variant: r = "default", size: a = "md", alig
|
|
|
3728
3750
|
"aria-haspopup": "menu",
|
|
3729
3751
|
"aria-expanded": u,
|
|
3730
3752
|
"aria-controls": u ? g : void 0,
|
|
3731
|
-
onClick: () => u ? v() :
|
|
3753
|
+
onClick: () => u ? v() : N("first"),
|
|
3732
3754
|
onKeyDown: D,
|
|
3733
3755
|
children: /* @__PURE__ */ e(ae, { size: a === "sm" ? 14 : 16, strokeWidth: 2, "aria-hidden": "true" })
|
|
3734
3756
|
}
|
|
@@ -3744,8 +3766,8 @@ function fr({ label: t, entries: n, variant: r = "default", size: a = "md", alig
|
|
|
3744
3766
|
children: n.map((h, x) => /* @__PURE__ */ i(
|
|
3745
3767
|
"button",
|
|
3746
3768
|
{
|
|
3747
|
-
ref: (
|
|
3748
|
-
_.current[x] =
|
|
3769
|
+
ref: (y) => {
|
|
3770
|
+
_.current[x] = y;
|
|
3749
3771
|
},
|
|
3750
3772
|
type: "button",
|
|
3751
3773
|
role: "menuitem",
|
|
@@ -3765,20 +3787,20 @@ function fr({ label: t, entries: n, variant: r = "default", size: a = "md", alig
|
|
|
3765
3787
|
}
|
|
3766
3788
|
const Tn = (t) => t.type === "item" && !t.disabled && !t.locked || t.type === "link";
|
|
3767
3789
|
function _r({ label: t, entries: n, withChevron: r, align: a = "start", triggerContent: s }) {
|
|
3768
|
-
const [l, o] =
|
|
3790
|
+
const [l, o] = A(!1), [u, d] = A({
|
|
3769
3791
|
align: a,
|
|
3770
3792
|
side: "bottom"
|
|
3771
|
-
}), p = q(null), c = q(null), f =
|
|
3793
|
+
}), p = q(null), c = q(null), f = P();
|
|
3772
3794
|
fe(() => {
|
|
3773
3795
|
if (!l) return;
|
|
3774
3796
|
function C() {
|
|
3775
|
-
const
|
|
3776
|
-
if (!
|
|
3777
|
-
const
|
|
3797
|
+
const y = p.current, k = c.current;
|
|
3798
|
+
if (!y || !k) return;
|
|
3799
|
+
const $ = y.getBoundingClientRect(), I = k.getBoundingClientRect();
|
|
3778
3800
|
let S = a;
|
|
3779
|
-
a === "start" &&
|
|
3780
|
-
const
|
|
3781
|
-
d({ align: S, side:
|
|
3801
|
+
a === "start" && $.left + I.width > window.innerWidth ? S = "end" : a === "end" && $.right - I.width < 0 && (S = "start");
|
|
3802
|
+
const L = $.bottom + I.height > window.innerHeight ? "top" : "bottom";
|
|
3803
|
+
d({ align: S, side: L });
|
|
3782
3804
|
}
|
|
3783
3805
|
let h = 0;
|
|
3784
3806
|
function x() {
|
|
@@ -3790,7 +3812,7 @@ function _r({ label: t, entries: n, withChevron: r, align: a = "start", triggerC
|
|
|
3790
3812
|
window.removeEventListener("resize", x), h && window.cancelAnimationFrame(h);
|
|
3791
3813
|
};
|
|
3792
3814
|
}, [l, a]);
|
|
3793
|
-
const _ = n.flatMap((C, h) => Tn(C) ? [h] : []), { itemRefs: m, focusItem: g, reset:
|
|
3815
|
+
const _ = n.flatMap((C, h) => Tn(C) ? [h] : []), { itemRefs: m, focusItem: g, reset: w, onMenuKeyDown: b } = Te({
|
|
3794
3816
|
focusableIndices: _,
|
|
3795
3817
|
getText: (C) => {
|
|
3796
3818
|
const h = n[C];
|
|
@@ -3798,15 +3820,15 @@ function _r({ label: t, entries: n, withChevron: r, align: a = "start", triggerC
|
|
|
3798
3820
|
},
|
|
3799
3821
|
onClose: () => v()
|
|
3800
3822
|
});
|
|
3801
|
-
function
|
|
3823
|
+
function N(C) {
|
|
3802
3824
|
o(!0);
|
|
3803
3825
|
const h = C === "first" ? _[0] : _[_.length - 1];
|
|
3804
3826
|
window.requestAnimationFrame(() => g(h));
|
|
3805
3827
|
}
|
|
3806
3828
|
function v(C = !0) {
|
|
3807
|
-
o(!1),
|
|
3829
|
+
o(!1), w(), d({ align: a, side: "bottom" }), C && p.current?.focus();
|
|
3808
3830
|
}
|
|
3809
|
-
|
|
3831
|
+
O(() => {
|
|
3810
3832
|
if (!l) return;
|
|
3811
3833
|
function C(h) {
|
|
3812
3834
|
const x = m.current[0]?.closest(".menu");
|
|
@@ -3815,7 +3837,7 @@ function _r({ label: t, entries: n, withChevron: r, align: a = "start", triggerC
|
|
|
3815
3837
|
return document.addEventListener("mousedown", C), () => document.removeEventListener("mousedown", C);
|
|
3816
3838
|
}, [l]);
|
|
3817
3839
|
function D(C) {
|
|
3818
|
-
C.key === "ArrowDown" || C.key === "Enter" || C.key === " " ? (C.preventDefault(),
|
|
3840
|
+
C.key === "ArrowDown" || C.key === "Enter" || C.key === " " ? (C.preventDefault(), N("first")) : C.key === "ArrowUp" && (C.preventDefault(), N("last"));
|
|
3819
3841
|
}
|
|
3820
3842
|
return /* @__PURE__ */ i("div", { className: "menu", children: [
|
|
3821
3843
|
/* @__PURE__ */ i(
|
|
@@ -3828,7 +3850,7 @@ function _r({ label: t, entries: n, withChevron: r, align: a = "start", triggerC
|
|
|
3828
3850
|
"aria-expanded": l,
|
|
3829
3851
|
"aria-controls": l ? f : void 0,
|
|
3830
3852
|
"aria-label": s ? t : void 0,
|
|
3831
|
-
onClick: () => l ? v() :
|
|
3853
|
+
onClick: () => l ? v() : N("first"),
|
|
3832
3854
|
onKeyDown: D,
|
|
3833
3855
|
children: [
|
|
3834
3856
|
s ?? t,
|
|
@@ -3854,15 +3876,15 @@ function _r({ label: t, entries: n, withChevron: r, align: a = "start", triggerC
|
|
|
3854
3876
|
return /* @__PURE__ */ i(
|
|
3855
3877
|
"a",
|
|
3856
3878
|
{
|
|
3857
|
-
ref: (
|
|
3858
|
-
m.current[h] =
|
|
3879
|
+
ref: (k) => {
|
|
3880
|
+
m.current[h] = k;
|
|
3859
3881
|
},
|
|
3860
3882
|
role: "menuitem",
|
|
3861
3883
|
tabIndex: -1,
|
|
3862
3884
|
href: C.href,
|
|
3863
3885
|
className: "menu__item",
|
|
3864
|
-
onClick: (
|
|
3865
|
-
|
|
3886
|
+
onClick: (k) => {
|
|
3887
|
+
k.preventDefault(), v();
|
|
3866
3888
|
},
|
|
3867
3889
|
children: [
|
|
3868
3890
|
C.icon ? /* @__PURE__ */ e("span", { className: "menu__item-icon", children: C.icon }) : null,
|
|
@@ -3872,12 +3894,12 @@ function _r({ label: t, entries: n, withChevron: r, align: a = "start", triggerC
|
|
|
3872
3894
|
},
|
|
3873
3895
|
C.label
|
|
3874
3896
|
);
|
|
3875
|
-
const x = !C.disabled && !C.locked,
|
|
3897
|
+
const x = !C.disabled && !C.locked, y = C.suffix ?? (C.locked ? /* @__PURE__ */ e(Ut, { size: 16, strokeWidth: 2, "aria-hidden": "true" }) : null);
|
|
3876
3898
|
return /* @__PURE__ */ i(
|
|
3877
3899
|
"button",
|
|
3878
3900
|
{
|
|
3879
|
-
ref: (
|
|
3880
|
-
m.current[h] =
|
|
3901
|
+
ref: (k) => {
|
|
3902
|
+
m.current[h] = k;
|
|
3881
3903
|
},
|
|
3882
3904
|
type: "button",
|
|
3883
3905
|
role: "menuitem",
|
|
@@ -3889,7 +3911,7 @@ function _r({ label: t, entries: n, withChevron: r, align: a = "start", triggerC
|
|
|
3889
3911
|
children: [
|
|
3890
3912
|
C.icon ? /* @__PURE__ */ e("span", { className: "menu__item-icon", children: C.icon }) : null,
|
|
3891
3913
|
/* @__PURE__ */ e("span", { className: "menu__item-label", children: C.label }),
|
|
3892
|
-
|
|
3914
|
+
y ? /* @__PURE__ */ e("span", { className: "menu__item-suffix", children: y }) : null
|
|
3893
3915
|
]
|
|
3894
3916
|
},
|
|
3895
3917
|
C.label
|
|
@@ -3900,44 +3922,44 @@ function _r({ label: t, entries: n, withChevron: r, align: a = "start", triggerC
|
|
|
3900
3922
|
] });
|
|
3901
3923
|
}
|
|
3902
3924
|
function br({ options: t, defaultSelected: n = [], placeholder: r, onChange: a }) {
|
|
3903
|
-
const [s, l] =
|
|
3904
|
-
function m(
|
|
3905
|
-
u(
|
|
3925
|
+
const [s, l] = A(!1), [o, u] = A(n), [d, p] = A({ row: 0, col: 0 }), c = q(null), f = q(null), _ = q([]);
|
|
3926
|
+
function m(k) {
|
|
3927
|
+
u(k), a?.(k);
|
|
3906
3928
|
}
|
|
3907
|
-
const g = (
|
|
3908
|
-
function k
|
|
3909
|
-
m(g(
|
|
3929
|
+
const g = (k) => o.includes(k);
|
|
3930
|
+
function w(k) {
|
|
3931
|
+
m(g(k) ? o.filter(($) => $ !== k) : [...o, k]);
|
|
3910
3932
|
}
|
|
3911
|
-
function b(
|
|
3912
|
-
m([
|
|
3933
|
+
function b(k) {
|
|
3934
|
+
m([k]);
|
|
3913
3935
|
}
|
|
3914
|
-
function
|
|
3936
|
+
function N() {
|
|
3915
3937
|
m([...t]);
|
|
3916
3938
|
}
|
|
3917
|
-
function v(
|
|
3918
|
-
return g(
|
|
3939
|
+
function v(k) {
|
|
3940
|
+
return g(k) ? o.length === t.length ? { label: "仅选此项", run: () => b(k) } : { label: "全选", run: () => N() } : o.length === 0 ? { label: "勾选", run: () => w(k) } : { label: "仅选此项", run: () => b(k) };
|
|
3919
3941
|
}
|
|
3920
|
-
function D(
|
|
3921
|
-
p({ row:
|
|
3942
|
+
function D(k, $) {
|
|
3943
|
+
p({ row: k, col: $ }), window.requestAnimationFrame(() => _.current[k]?.[$]?.focus());
|
|
3922
3944
|
}
|
|
3923
3945
|
function C() {
|
|
3924
3946
|
l(!0), window.requestAnimationFrame(() => D(0, 0));
|
|
3925
3947
|
}
|
|
3926
|
-
function h(
|
|
3927
|
-
l(!1),
|
|
3948
|
+
function h(k = !0) {
|
|
3949
|
+
l(!1), k && f.current?.focus();
|
|
3928
3950
|
}
|
|
3929
|
-
|
|
3951
|
+
O(() => {
|
|
3930
3952
|
if (!s) return;
|
|
3931
|
-
function
|
|
3932
|
-
c.current && !c.current.contains(
|
|
3953
|
+
function k($) {
|
|
3954
|
+
c.current && !c.current.contains($.target) && h(!1);
|
|
3933
3955
|
}
|
|
3934
|
-
return document.addEventListener("mousedown",
|
|
3956
|
+
return document.addEventListener("mousedown", k), () => document.removeEventListener("mousedown", k);
|
|
3935
3957
|
}, [s]);
|
|
3936
|
-
function x(
|
|
3937
|
-
const { row:
|
|
3938
|
-
|
|
3958
|
+
function x(k) {
|
|
3959
|
+
const { row: $, col: I } = d;
|
|
3960
|
+
k.key === "ArrowDown" ? (k.preventDefault(), D(Math.min($ + 1, t.length - 1), I)) : k.key === "ArrowUp" ? (k.preventDefault(), D(Math.max($ - 1, 0), I)) : k.key === "ArrowRight" ? (k.preventDefault(), D($, 1)) : k.key === "ArrowLeft" ? (k.preventDefault(), D($, 0)) : k.key === "Home" ? (k.preventDefault(), D(0, I)) : k.key === "End" ? (k.preventDefault(), D(t.length - 1, I)) : k.key === "Escape" && (k.preventDefault(), h());
|
|
3939
3961
|
}
|
|
3940
|
-
const
|
|
3962
|
+
const y = o.length === 0 ? r : o.length === 1 ? o[0] : `已选 ${o.length} 项`;
|
|
3941
3963
|
return /* @__PURE__ */ i("div", { className: "multi-select", ref: c, children: [
|
|
3942
3964
|
/* @__PURE__ */ i(
|
|
3943
3965
|
"button",
|
|
@@ -3949,7 +3971,7 @@ function br({ options: t, defaultSelected: n = [], placeholder: r, onChange: a }
|
|
|
3949
3971
|
"aria-expanded": s,
|
|
3950
3972
|
onClick: () => s ? h() : C(),
|
|
3951
3973
|
children: [
|
|
3952
|
-
/* @__PURE__ */ e("span", { className: o.length === 0 ? "multi-select__placeholder" : void 0, children:
|
|
3974
|
+
/* @__PURE__ */ e("span", { className: o.length === 0 ? "multi-select__placeholder" : void 0, children: y }),
|
|
3953
3975
|
/* @__PURE__ */ e(ae, { size: 16, strokeWidth: 2, "aria-hidden": "true" })
|
|
3954
3976
|
]
|
|
3955
3977
|
}
|
|
@@ -3961,7 +3983,7 @@ function br({ options: t, defaultSelected: n = [], placeholder: r, onChange: a }
|
|
|
3961
3983
|
{
|
|
3962
3984
|
type: "button",
|
|
3963
3985
|
className: "multi-select__bulk-button",
|
|
3964
|
-
onClick: () => o.length === t.length ? m([]) :
|
|
3986
|
+
onClick: () => o.length === t.length ? m([]) : N(),
|
|
3965
3987
|
children: o.length === t.length ? "全部清除" : "全选"
|
|
3966
3988
|
}
|
|
3967
3989
|
),
|
|
@@ -3971,53 +3993,53 @@ function br({ options: t, defaultSelected: n = [], placeholder: r, onChange: a }
|
|
|
3971
3993
|
t.length
|
|
3972
3994
|
] })
|
|
3973
3995
|
] }),
|
|
3974
|
-
t.map((
|
|
3975
|
-
_.current[
|
|
3976
|
-
const
|
|
3996
|
+
t.map((k, $) => {
|
|
3997
|
+
_.current[$] = _.current[$] ?? [];
|
|
3998
|
+
const I = g(k), S = v(k);
|
|
3977
3999
|
return /* @__PURE__ */ i("div", { className: "multi-select__row", role: "presentation", children: [
|
|
3978
4000
|
/* @__PURE__ */ i(
|
|
3979
4001
|
"button",
|
|
3980
4002
|
{
|
|
3981
|
-
ref: (
|
|
3982
|
-
|
|
4003
|
+
ref: (L) => {
|
|
4004
|
+
L && (_.current[$][0] = L);
|
|
3983
4005
|
},
|
|
3984
4006
|
type: "button",
|
|
3985
4007
|
role: "option",
|
|
3986
|
-
"aria-selected":
|
|
3987
|
-
"aria-label": `选择 ${
|
|
3988
|
-
tabIndex: d.row ===
|
|
4008
|
+
"aria-selected": I,
|
|
4009
|
+
"aria-label": `选择 ${k}`,
|
|
4010
|
+
tabIndex: d.row === $ && d.col === 0 ? 0 : -1,
|
|
3989
4011
|
className: "multi-select__option",
|
|
3990
|
-
onFocus: () => p({ row:
|
|
3991
|
-
onClick: () => k
|
|
4012
|
+
onFocus: () => p({ row: $, col: 0 }),
|
|
4013
|
+
onClick: () => w(k),
|
|
3992
4014
|
children: [
|
|
3993
|
-
/* @__PURE__ */ e("span", { className: `multi-select__check${
|
|
3994
|
-
/* @__PURE__ */ e("span", { className: "multi-select__option-label", children:
|
|
4015
|
+
/* @__PURE__ */ e("span", { className: `multi-select__check${I ? " multi-select__check--on" : ""}`, "aria-hidden": "true", children: I ? /* @__PURE__ */ e(ce, { size: 12, strokeWidth: 3 }) : null }),
|
|
4016
|
+
/* @__PURE__ */ e("span", { className: "multi-select__option-label", children: k })
|
|
3995
4017
|
]
|
|
3996
4018
|
}
|
|
3997
4019
|
),
|
|
3998
4020
|
/* @__PURE__ */ e(
|
|
3999
4021
|
"button",
|
|
4000
4022
|
{
|
|
4001
|
-
ref: (
|
|
4002
|
-
|
|
4023
|
+
ref: (L) => {
|
|
4024
|
+
L && (_.current[$][1] = L);
|
|
4003
4025
|
},
|
|
4004
4026
|
type: "button",
|
|
4005
|
-
"aria-label": `${S.label}:${
|
|
4006
|
-
tabIndex: d.row ===
|
|
4027
|
+
"aria-label": `${S.label}:${k}`,
|
|
4028
|
+
tabIndex: d.row === $ && d.col === 1 ? 0 : -1,
|
|
4007
4029
|
className: "multi-select__only",
|
|
4008
|
-
onFocus: () => p({ row:
|
|
4030
|
+
onFocus: () => p({ row: $, col: 1 }),
|
|
4009
4031
|
onClick: S.run,
|
|
4010
4032
|
children: S.label
|
|
4011
4033
|
}
|
|
4012
4034
|
)
|
|
4013
|
-
] },
|
|
4035
|
+
] }, k);
|
|
4014
4036
|
})
|
|
4015
4037
|
] }) : null
|
|
4016
4038
|
] });
|
|
4017
4039
|
}
|
|
4018
4040
|
function gr({ open: t, onClose: n, title: r, children: a, footer: s, initialFocusRef: l, dismissable: o = !0, sticky: u = !1 }) {
|
|
4019
|
-
const d = q(null), p =
|
|
4020
|
-
if (
|
|
4041
|
+
const d = q(null), p = P();
|
|
4042
|
+
if (O(() => {
|
|
4021
4043
|
if (!t) return;
|
|
4022
4044
|
const f = document.body.style.overflow;
|
|
4023
4045
|
document.body.style.overflow = "hidden";
|
|
@@ -4027,7 +4049,7 @@ function gr({ open: t, onClose: n, title: r, children: a, footer: s, initialFocu
|
|
|
4027
4049
|
return () => {
|
|
4028
4050
|
window.clearTimeout(_), document.body.style.overflow = f;
|
|
4029
4051
|
};
|
|
4030
|
-
}, [t, l]),
|
|
4052
|
+
}, [t, l]), O(() => {
|
|
4031
4053
|
if (!t || !o) return;
|
|
4032
4054
|
function f(_) {
|
|
4033
4055
|
_.key === "Escape" && (d.current?.contains(document.activeElement) || (_.preventDefault(), n()));
|
|
@@ -4040,8 +4062,8 @@ function gr({ open: t, onClose: n, title: r, children: a, footer: s, initialFocu
|
|
|
4040
4062
|
else if (f.key === "Tab") {
|
|
4041
4063
|
const _ = 'button:not([disabled]), input:not([disabled]), [tabindex="0"]', m = Array.from(d.current?.querySelectorAll(_) ?? []);
|
|
4042
4064
|
if (m.length === 0) return;
|
|
4043
|
-
const g = m[0],
|
|
4044
|
-
f.shiftKey && document.activeElement === g ? (f.preventDefault(), (
|
|
4065
|
+
const g = m[0], w = m[m.length - 1], b = document.querySelector(".q1-toast-region")?.lastElementChild, N = Array.from(b?.querySelectorAll(_) ?? []);
|
|
4066
|
+
f.shiftKey && document.activeElement === g ? (f.preventDefault(), (N.length > 0 ? N[N.length - 1] : w).focus()) : !f.shiftKey && document.activeElement === w && (f.preventDefault(), (N.length > 0 ? N[0] : g).focus());
|
|
4045
4067
|
}
|
|
4046
4068
|
}
|
|
4047
4069
|
return /* @__PURE__ */ i("div", { className: "modal", onKeyDown: c, children: [
|
|
@@ -4076,11 +4098,11 @@ function yr({ children: t }) {
|
|
|
4076
4098
|
return /* @__PURE__ */ e("div", { className: "modal__inset", children: t });
|
|
4077
4099
|
}
|
|
4078
4100
|
const zn = ["日", "一", "二", "三", "四", "五", "六"];
|
|
4079
|
-
function
|
|
4101
|
+
function K(t) {
|
|
4080
4102
|
const n = String(t.getMonth() + 1).padStart(2, "0"), r = String(t.getDate()).padStart(2, "0");
|
|
4081
4103
|
return `${t.getFullYear()}-${n}-${r}`;
|
|
4082
4104
|
}
|
|
4083
|
-
function
|
|
4105
|
+
function ue(t, n) {
|
|
4084
4106
|
return new Date(t.getFullYear(), t.getMonth(), t.getDate() + n);
|
|
4085
4107
|
}
|
|
4086
4108
|
function Pe(t, n) {
|
|
@@ -4090,23 +4112,23 @@ function je(t) {
|
|
|
4090
4112
|
return new Date(t.getFullYear(), t.getMonth(), 1);
|
|
4091
4113
|
}
|
|
4092
4114
|
function ye(t, n) {
|
|
4093
|
-
return !!t && !!n &&
|
|
4115
|
+
return !!t && !!n && K(t) === K(n);
|
|
4094
4116
|
}
|
|
4095
4117
|
function Rn(t, n) {
|
|
4096
4118
|
return Math.round((n.getTime() - t.getTime()) / 864e5) + 1;
|
|
4097
4119
|
}
|
|
4098
4120
|
function Ln(t) {
|
|
4099
|
-
const n = je(t), r =
|
|
4121
|
+
const n = je(t), r = ue(n, -n.getDay());
|
|
4100
4122
|
return Array.from({ length: 42 }, (a, s) => {
|
|
4101
|
-
const l =
|
|
4123
|
+
const l = ue(r, s);
|
|
4102
4124
|
return { date: l, inMonth: l.getMonth() === n.getMonth() };
|
|
4103
4125
|
});
|
|
4104
4126
|
}
|
|
4105
4127
|
function Oe(t, n, r) {
|
|
4106
|
-
return !!(n &&
|
|
4128
|
+
return !!(n && K(t) < K(n) || r && K(t) > K(r));
|
|
4107
4129
|
}
|
|
4108
4130
|
function st(t, n, r) {
|
|
4109
|
-
return n &&
|
|
4131
|
+
return n && K(t) < K(n) ? n : r && K(t) > K(r) ? r : t;
|
|
4110
4132
|
}
|
|
4111
4133
|
function Wn({
|
|
4112
4134
|
value: t,
|
|
@@ -4116,65 +4138,65 @@ function Wn({
|
|
|
4116
4138
|
maxValue: s,
|
|
4117
4139
|
today: l = /* @__PURE__ */ new Date()
|
|
4118
4140
|
}) {
|
|
4119
|
-
const [o, u] =
|
|
4141
|
+
const [o, u] = A(
|
|
4120
4142
|
() => je(st(t.start ?? l, a, s))
|
|
4121
|
-
), [d, p] =
|
|
4122
|
-
|
|
4123
|
-
if (!
|
|
4124
|
-
const
|
|
4125
|
-
|
|
4143
|
+
), [d, p] = A(null), [c, f] = A(() => st(t.start ?? l, a, s)), [_, m] = A(""), g = q(/* @__PURE__ */ new Map()), w = q(null), b = Ln(o);
|
|
4144
|
+
O(() => {
|
|
4145
|
+
if (!w.current) return;
|
|
4146
|
+
const y = g.current.get(w.current);
|
|
4147
|
+
w.current = null, y?.focus();
|
|
4126
4148
|
});
|
|
4127
|
-
const
|
|
4128
|
-
function v(
|
|
4149
|
+
const N = t.start && !t.end && d ? K(d) < K(t.start) ? { start: d, end: t.start } : { start: t.start, end: d } : t;
|
|
4150
|
+
function v(y) {
|
|
4129
4151
|
if (!t.start || t.end) {
|
|
4130
|
-
n({ start:
|
|
4152
|
+
n({ start: y, end: null }), m(`开始日期 ${K(y)},请选择结束日期`);
|
|
4131
4153
|
return;
|
|
4132
4154
|
}
|
|
4133
|
-
const [
|
|
4134
|
-
n({ start:
|
|
4155
|
+
const [k, $] = K(y) < K(t.start) ? [y, t.start] : [t.start, y];
|
|
4156
|
+
n({ start: k, end: $ }), m(`已选择 ${K(k)} 至 ${K($)},共 ${Rn(k, $)} 天`);
|
|
4135
4157
|
}
|
|
4136
|
-
function D(
|
|
4137
|
-
Oe(
|
|
4158
|
+
function D(y) {
|
|
4159
|
+
Oe(y, a, s) || ((y.getMonth() !== o.getMonth() || y.getFullYear() !== o.getFullYear()) && u(je(y)), f(y), w.current = K(y));
|
|
4138
4160
|
}
|
|
4139
|
-
function C(
|
|
4140
|
-
let
|
|
4141
|
-
switch (
|
|
4161
|
+
function C(y) {
|
|
4162
|
+
let k = null;
|
|
4163
|
+
switch (y.key) {
|
|
4142
4164
|
case "ArrowLeft":
|
|
4143
|
-
|
|
4165
|
+
k = ue(c, y.shiftKey ? -7 : -1);
|
|
4144
4166
|
break;
|
|
4145
4167
|
case "ArrowRight":
|
|
4146
|
-
|
|
4168
|
+
k = ue(c, y.shiftKey ? 7 : 1);
|
|
4147
4169
|
break;
|
|
4148
4170
|
case "ArrowUp":
|
|
4149
|
-
|
|
4171
|
+
k = ue(c, -7);
|
|
4150
4172
|
break;
|
|
4151
4173
|
case "ArrowDown":
|
|
4152
|
-
|
|
4174
|
+
k = ue(c, 7);
|
|
4153
4175
|
break;
|
|
4154
4176
|
case "Home":
|
|
4155
|
-
|
|
4177
|
+
k = ue(c, -c.getDay());
|
|
4156
4178
|
break;
|
|
4157
4179
|
case "End":
|
|
4158
|
-
|
|
4180
|
+
k = ue(c, 6 - c.getDay());
|
|
4159
4181
|
break;
|
|
4160
4182
|
case "PageUp":
|
|
4161
|
-
|
|
4183
|
+
k = Pe(c, -1);
|
|
4162
4184
|
break;
|
|
4163
4185
|
case "PageDown":
|
|
4164
|
-
|
|
4186
|
+
k = Pe(c, 1);
|
|
4165
4187
|
break;
|
|
4166
4188
|
case "Enter":
|
|
4167
4189
|
case " ":
|
|
4168
|
-
|
|
4190
|
+
y.preventDefault(), Oe(c, a, s) || v(c);
|
|
4169
4191
|
return;
|
|
4170
4192
|
default:
|
|
4171
4193
|
return;
|
|
4172
4194
|
}
|
|
4173
|
-
|
|
4195
|
+
y.preventDefault(), k && D(k);
|
|
4174
4196
|
}
|
|
4175
|
-
function h(
|
|
4176
|
-
const
|
|
4177
|
-
u(
|
|
4197
|
+
function h(y) {
|
|
4198
|
+
const k = Pe(o, y);
|
|
4199
|
+
u(k), f(k);
|
|
4178
4200
|
}
|
|
4179
4201
|
const x = `${o.getFullYear()} 年 ${o.getMonth() + 1} 月`;
|
|
4180
4202
|
return /* @__PURE__ */ i("div", { className: `calendar calendar--${r}`, children: [
|
|
@@ -4198,45 +4220,45 @@ function Wn({
|
|
|
4198
4220
|
className: "calendar__nav-btn",
|
|
4199
4221
|
"aria-label": "下一月",
|
|
4200
4222
|
onClick: () => h(1),
|
|
4201
|
-
children: /* @__PURE__ */ e(
|
|
4223
|
+
children: /* @__PURE__ */ e(me, { size: 16, strokeWidth: 2 })
|
|
4202
4224
|
}
|
|
4203
4225
|
)
|
|
4204
4226
|
] })
|
|
4205
4227
|
] }),
|
|
4206
|
-
/* @__PURE__ */ e("div", { className: "calendar__weekdays", "aria-hidden": "true", children: zn.map((
|
|
4207
|
-
/* @__PURE__ */ e("div", { className: "calendar__grid", role: "grid", "aria-label": x, onKeyDown: C, children: b.map(({ date:
|
|
4208
|
-
const
|
|
4228
|
+
/* @__PURE__ */ e("div", { className: "calendar__weekdays", "aria-hidden": "true", children: zn.map((y, k) => /* @__PURE__ */ e("span", { className: "calendar__weekday", children: y }, `${y}-${k}`)) }),
|
|
4229
|
+
/* @__PURE__ */ e("div", { className: "calendar__grid", role: "grid", "aria-label": x, onKeyDown: C, children: b.map(({ date: y, inMonth: k }) => {
|
|
4230
|
+
const $ = !k || Oe(y, a, s), I = ye(y, N.start), S = ye(y, N.end), L = !!N.start && !!N.end && !ye(N.start, N.end), F = L && K(y) > K(N.start) && K(y) < K(N.end), G = T(
|
|
4209
4231
|
"calendar__cell",
|
|
4210
|
-
|
|
4211
|
-
|
|
4212
|
-
|
|
4213
|
-
),
|
|
4232
|
+
F ? "calendar__cell--in-range" : "",
|
|
4233
|
+
L && I ? "calendar__cell--range-start" : "",
|
|
4234
|
+
L && S ? "calendar__cell--range-end" : ""
|
|
4235
|
+
), X = T(
|
|
4214
4236
|
"calendar__day",
|
|
4215
|
-
|
|
4216
|
-
|
|
4217
|
-
S &&
|
|
4218
|
-
|
|
4237
|
+
k ? "" : "calendar__day--outside",
|
|
4238
|
+
I && N.start ? "calendar__day--start" : "",
|
|
4239
|
+
S && L ? "calendar__day--end" : "",
|
|
4240
|
+
k && !$ && ye(y, l) ? "calendar__day--today" : ""
|
|
4219
4241
|
);
|
|
4220
|
-
return /* @__PURE__ */ e("div", { className:
|
|
4242
|
+
return /* @__PURE__ */ e("div", { className: G, role: "gridcell", children: /* @__PURE__ */ e(
|
|
4221
4243
|
"button",
|
|
4222
4244
|
{
|
|
4223
4245
|
type: "button",
|
|
4224
|
-
ref: (
|
|
4225
|
-
|
|
4246
|
+
ref: (V) => {
|
|
4247
|
+
V ? g.current.set(K(y), V) : g.current.delete(K(y));
|
|
4226
4248
|
},
|
|
4227
|
-
className:
|
|
4228
|
-
tabIndex:
|
|
4229
|
-
disabled:
|
|
4230
|
-
"aria-disabled":
|
|
4231
|
-
"aria-selected": (
|
|
4232
|
-
"aria-current":
|
|
4233
|
-
onClick: () =>
|
|
4234
|
-
onMouseEnter: () => p(
|
|
4249
|
+
className: X,
|
|
4250
|
+
tabIndex: k && !$ && ye(y, c) ? 0 : -1,
|
|
4251
|
+
disabled: $,
|
|
4252
|
+
"aria-disabled": $ || void 0,
|
|
4253
|
+
"aria-selected": (I || S) && N.start ? !0 : void 0,
|
|
4254
|
+
"aria-current": k && ye(y, l) ? "date" : void 0,
|
|
4255
|
+
onClick: () => !$ && v(y),
|
|
4256
|
+
onMouseEnter: () => p(y),
|
|
4235
4257
|
onMouseLeave: () => p(null),
|
|
4236
|
-
onFocus: () => f(
|
|
4237
|
-
children:
|
|
4258
|
+
onFocus: () => f(y),
|
|
4259
|
+
children: y.getDate()
|
|
4238
4260
|
}
|
|
4239
|
-
) },
|
|
4261
|
+
) }, K(y));
|
|
4240
4262
|
}) }),
|
|
4241
4263
|
/* @__PURE__ */ e("span", { className: "q1-sr-only", "aria-live": "polite", children: _ })
|
|
4242
4264
|
] });
|
|
@@ -4251,14 +4273,14 @@ function Fn({
|
|
|
4251
4273
|
/* @__PURE__ */ i("div", { className: "cal-inputs__field", children: [
|
|
4252
4274
|
/* @__PURE__ */ e("span", { className: "cal-inputs__label", children: "开始" }),
|
|
4253
4275
|
/* @__PURE__ */ i("div", { className: "cal-inputs__row", children: [
|
|
4254
|
-
/* @__PURE__ */ e("span", { className: "cal-inputs__value", children: t.start ?
|
|
4276
|
+
/* @__PURE__ */ e("span", { className: "cal-inputs__value", children: t.start ? K(t.start) : "请选择" }),
|
|
4255
4277
|
n ? /* @__PURE__ */ e("span", { className: "cal-inputs__time", children: "00:00" }) : null
|
|
4256
4278
|
] })
|
|
4257
4279
|
] }),
|
|
4258
4280
|
/* @__PURE__ */ i("div", { className: "cal-inputs__field", children: [
|
|
4259
4281
|
/* @__PURE__ */ e("span", { className: "cal-inputs__label", children: "结束" }),
|
|
4260
4282
|
/* @__PURE__ */ i("div", { className: "cal-inputs__row", children: [
|
|
4261
|
-
/* @__PURE__ */ e("span", { className: "cal-inputs__value", children: t.end ?
|
|
4283
|
+
/* @__PURE__ */ e("span", { className: "cal-inputs__value", children: t.end ? K(t.end) : "请选择" }),
|
|
4262
4284
|
n ? /* @__PURE__ */ e("span", { className: "cal-inputs__time", children: "23:59" }) : null
|
|
4263
4285
|
] })
|
|
4264
4286
|
] }),
|
|
@@ -4283,15 +4305,15 @@ function Nr({
|
|
|
4283
4305
|
value: u,
|
|
4284
4306
|
onChange: d
|
|
4285
4307
|
}) {
|
|
4286
|
-
const [p, c] =
|
|
4287
|
-
|
|
4308
|
+
const [p, c] = A(!1), f = q(null), _ = q(null);
|
|
4309
|
+
O(() => {
|
|
4288
4310
|
if (!p) return;
|
|
4289
|
-
const
|
|
4290
|
-
...
|
|
4311
|
+
const N = f.current?.querySelector(".cal-popover"), v = () => N ? [
|
|
4312
|
+
...N.querySelectorAll(
|
|
4291
4313
|
'button:not([disabled]), input:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"]):not([disabled])'
|
|
4292
4314
|
)
|
|
4293
4315
|
].filter((x) => x.offsetParent !== null) : [];
|
|
4294
|
-
(
|
|
4316
|
+
(N?.querySelector('.calendar__day[tabindex="0"]') ?? v()[0])?.focus();
|
|
4295
4317
|
function C(x) {
|
|
4296
4318
|
f.current && !f.current.contains(x.target) && c(!1);
|
|
4297
4319
|
}
|
|
@@ -4300,18 +4322,18 @@ function Nr({
|
|
|
4300
4322
|
c(!1), _.current?.focus();
|
|
4301
4323
|
return;
|
|
4302
4324
|
}
|
|
4303
|
-
if (x.key === "Tab" &&
|
|
4304
|
-
const
|
|
4305
|
-
if (
|
|
4306
|
-
const
|
|
4307
|
-
|
|
4325
|
+
if (x.key === "Tab" && N) {
|
|
4326
|
+
const y = v();
|
|
4327
|
+
if (y.length === 0) return;
|
|
4328
|
+
const k = y[0], $ = y[y.length - 1], I = document.activeElement;
|
|
4329
|
+
N.contains(I) ? x.shiftKey && I === k ? (x.preventDefault(), $.focus()) : !x.shiftKey && I === $ && (x.preventDefault(), k.focus()) : (x.preventDefault(), (x.shiftKey ? $ : k).focus());
|
|
4308
4330
|
}
|
|
4309
4331
|
}
|
|
4310
4332
|
return document.addEventListener("mousedown", C), document.addEventListener("keydown", h), () => {
|
|
4311
4333
|
document.removeEventListener("mousedown", C), document.removeEventListener("keydown", h);
|
|
4312
4334
|
};
|
|
4313
4335
|
}, [p]);
|
|
4314
|
-
const m = !!u.start && !!u.end, g = m ? `${
|
|
4336
|
+
const m = !!u.start && !!u.end, g = m ? `${K(u.start)} ~ ${K(u.end)}` : "选择日期区间", w = /* @__PURE__ */ e(Wn, { value: u, onChange: d, size: r, minValue: a, maxValue: s, today: o }), b = /* @__PURE__ */ e(
|
|
4315
4337
|
Fn,
|
|
4316
4338
|
{
|
|
4317
4339
|
value: u,
|
|
@@ -4340,7 +4362,7 @@ function Nr({
|
|
|
4340
4362
|
className: "cal-field__trigger",
|
|
4341
4363
|
"aria-haspopup": "dialog",
|
|
4342
4364
|
"aria-expanded": p,
|
|
4343
|
-
onClick: () => c((
|
|
4365
|
+
onClick: () => c((N) => !N),
|
|
4344
4366
|
children: [
|
|
4345
4367
|
/* @__PURE__ */ e(Ft, { size: 15, strokeWidth: 2, "aria-hidden": "true" }),
|
|
4346
4368
|
/* @__PURE__ */ e("span", { className: "cal-field__label", children: g })
|
|
@@ -4353,7 +4375,7 @@ function Nr({
|
|
|
4353
4375
|
type: "button",
|
|
4354
4376
|
className: "cal-field__caret",
|
|
4355
4377
|
"aria-label": "展开日历",
|
|
4356
|
-
onClick: () => c((
|
|
4378
|
+
onClick: () => c((N) => !N),
|
|
4357
4379
|
children: /* @__PURE__ */ e(ae, { size: 15, strokeWidth: 2 })
|
|
4358
4380
|
}
|
|
4359
4381
|
) : m ? /* @__PURE__ */ e(
|
|
@@ -4376,12 +4398,12 @@ function Nr({
|
|
|
4376
4398
|
role: "dialog",
|
|
4377
4399
|
"aria-modal": "true",
|
|
4378
4400
|
"aria-label": "选择日期区间",
|
|
4379
|
-
children: t === "horizontal" ? /* @__PURE__ */ i(
|
|
4380
|
-
|
|
4401
|
+
children: t === "horizontal" ? /* @__PURE__ */ i(ee, { children: [
|
|
4402
|
+
w,
|
|
4381
4403
|
b
|
|
4382
|
-
] }) : /* @__PURE__ */ i(
|
|
4404
|
+
] }) : /* @__PURE__ */ i(ee, { children: [
|
|
4383
4405
|
b,
|
|
4384
|
-
|
|
4406
|
+
w
|
|
4385
4407
|
] })
|
|
4386
4408
|
}
|
|
4387
4409
|
) : null
|
|
@@ -4393,8 +4415,8 @@ function kr({
|
|
|
4393
4415
|
activeLabel: n,
|
|
4394
4416
|
onPick: r
|
|
4395
4417
|
}) {
|
|
4396
|
-
const [a, s] =
|
|
4397
|
-
return
|
|
4418
|
+
const [a, s] = A(!1), l = q(null);
|
|
4419
|
+
return O(() => {
|
|
4398
4420
|
if (!a) return;
|
|
4399
4421
|
function o(u) {
|
|
4400
4422
|
l.current && !l.current.contains(u.target) && s(!1);
|
|
@@ -4535,7 +4557,7 @@ export {
|
|
|
4535
4557
|
sa as Toggle,
|
|
4536
4558
|
hn as Tooltip,
|
|
4537
4559
|
lr as Video,
|
|
4538
|
-
|
|
4560
|
+
ue as addDays,
|
|
4539
4561
|
Se as useCopy,
|
|
4540
4562
|
na as useRadio,
|
|
4541
4563
|
tn as useToast
|