reactive-md 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +53 -40
- package/CONTRIBUTING.md +4 -0
- package/README.en.md +3 -2
- package/README.md +3 -2
- package/SECURITY.md +71 -68
- package/dist-library/reactive-md-react.js +1099 -964
- package/dist-library/reactive-md.css +1 -1
- package/dist-library/reactive-md.js +1 -1
- package/dist-library/{runtime-D4phFXOr.js → runtime-CPzMEMcW.js} +2232 -2058
- package/dist-library/types/local/compiler.d.ts +3 -3
- package/dist-library/types/local/heading-anchors.d.ts +6 -0
- package/dist-library/types/local/index.d.ts +1 -1
- package/dist-library/types/local/limits.d.ts +1 -0
- package/dist-library/types/local/parser.d.ts +2 -2
- package/dist-library/types/local/types.d.ts +8 -0
- package/docs/compatibility.md +68 -67
- package/docs/component-development.md +206 -0
- package/docs/component-protocol.md +685 -0
- package/docs/local-guide.md +941 -936
- package/docs/local-integration.md +218 -193
- package/docs/local-interaction-syntax.md +439 -437
- package/docs/performance.md +67 -30
- package/docs/releasing.md +5 -5
- package/examples/conformance/README.md +51 -11
- package/examples/conformance/component-protocol-1.json +194 -0
- package/examples/conformance/component-protocol-1.schema.json +76 -0
- package/examples/conformance/local-draft-1.json +50 -49
- package/examples/integration/README.md +2 -2
- package/examples/local/README.md +66 -66
- package/examples/local/charts.reactive.md +73 -73
- package/package.json +77 -75
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { a as e, c as t, d as n, i as r, l as i, n as a, r as o, t as
|
|
2
|
-
import { Component as
|
|
3
|
-
import { Fragment as
|
|
1
|
+
import { a as e, c as t, d as n, i as r, l as i, n as a, r as o, s, t as c, u as l } from "./runtime-CPzMEMcW.js";
|
|
2
|
+
import { Component as u, createContext as d, createElement as f, useCallback as p, useContext as m, useEffect as h, useId as g, useMemo as _, useRef as v, useState as y, useSyncExternalStore as b } from "react";
|
|
3
|
+
import { Fragment as x, jsx as S, jsxs as C } from "react/jsx-runtime";
|
|
4
4
|
// src/local/math-view.tsx
|
|
5
|
-
var
|
|
5
|
+
var w = (e, t, ...n) => f(e, t, ...n), T = {
|
|
6
6
|
" ": "space",
|
|
7
7
|
",": "thinspace",
|
|
8
8
|
":": "medspace",
|
|
@@ -16,14 +16,14 @@ var C = (e, t, ...n) => d(e, t, ...n), w = {
|
|
|
16
16
|
"#": "hash",
|
|
17
17
|
_: "underscore",
|
|
18
18
|
$: "dollar"
|
|
19
|
-
},
|
|
20
|
-
function k(e) {
|
|
21
|
-
return e.length > O ? `${e.slice(0, O)}…` : e;
|
|
22
|
-
}
|
|
19
|
+
}, E = 5e4, D = 2e4, O = 120, k = 2e3;
|
|
23
20
|
function A(e) {
|
|
24
|
-
|
|
21
|
+
return e.length > k ? `${e.slice(0, k)}…` : e;
|
|
22
|
+
}
|
|
23
|
+
function j(e) {
|
|
24
|
+
if (e.length > E) throw Error("数学源码超过长度上限。");
|
|
25
25
|
let t = [], n = (e) => {
|
|
26
|
-
if (t.length >=
|
|
26
|
+
if (t.length >= D) throw Error("数学输入包含过多记号。");
|
|
27
27
|
t.push(e);
|
|
28
28
|
}, r = 0;
|
|
29
29
|
for (; r < e.length;) {
|
|
@@ -60,7 +60,7 @@ function A(e) {
|
|
|
60
60
|
}
|
|
61
61
|
n({
|
|
62
62
|
kind: "command",
|
|
63
|
-
value: Object.hasOwn(
|
|
63
|
+
value: Object.hasOwn(T, t) ? T[t] : t,
|
|
64
64
|
offset: r
|
|
65
65
|
}), r += 2;
|
|
66
66
|
} else if (t >= "0" && t <= "9") {
|
|
@@ -93,7 +93,7 @@ function A(e) {
|
|
|
93
93
|
offset: e.length
|
|
94
94
|
}), t;
|
|
95
95
|
}
|
|
96
|
-
var
|
|
96
|
+
var M = {
|
|
97
97
|
alpha: "α",
|
|
98
98
|
beta: "β",
|
|
99
99
|
gamma: "γ",
|
|
@@ -135,7 +135,7 @@ var j = {
|
|
|
135
135
|
Phi: "Φ",
|
|
136
136
|
Psi: "Ψ",
|
|
137
137
|
Omega: "Ω"
|
|
138
|
-
},
|
|
138
|
+
}, N = {
|
|
139
139
|
cdot: "·",
|
|
140
140
|
times: "×",
|
|
141
141
|
div: "÷",
|
|
@@ -205,7 +205,7 @@ var j = {
|
|
|
205
205
|
underscore: "_",
|
|
206
206
|
dollar: "$",
|
|
207
207
|
colon: ":"
|
|
208
|
-
},
|
|
208
|
+
}, P = /* @__PURE__ */ new Set([
|
|
209
209
|
"sin",
|
|
210
210
|
"cos",
|
|
211
211
|
"tan",
|
|
@@ -223,7 +223,7 @@ var j = {
|
|
|
223
223
|
"inf",
|
|
224
224
|
"arg",
|
|
225
225
|
"gcd"
|
|
226
|
-
]),
|
|
226
|
+
]), F = {
|
|
227
227
|
space: "0.25em",
|
|
228
228
|
thinspace: "0.167em",
|
|
229
229
|
medspace: "0.222em",
|
|
@@ -245,17 +245,17 @@ var j = {
|
|
|
245
245
|
source;
|
|
246
246
|
depth = 0;
|
|
247
247
|
constructor(e) {
|
|
248
|
-
this.source = e, this.tokens =
|
|
248
|
+
this.source = e, this.tokens = j(e);
|
|
249
249
|
}
|
|
250
250
|
enter() {
|
|
251
|
-
if (this.depth += 1, this.depth >
|
|
251
|
+
if (this.depth += 1, this.depth > O) throw --this.depth, Error("数学公式嵌套过深。");
|
|
252
252
|
}
|
|
253
253
|
leave() {
|
|
254
254
|
--this.depth;
|
|
255
255
|
}
|
|
256
256
|
render() {
|
|
257
257
|
let e = this.parseRow({});
|
|
258
|
-
return e.length === 1 ? e[0] :
|
|
258
|
+
return e.length === 1 ? e[0] : w("mrow", null, ...e);
|
|
259
259
|
}
|
|
260
260
|
peek(e = 0) {
|
|
261
261
|
return this.tokens[Math.min(this.pos + e, this.tokens.length - 1)];
|
|
@@ -295,10 +295,10 @@ var j = {
|
|
|
295
295
|
}
|
|
296
296
|
parseAtomBody() {
|
|
297
297
|
let e = this.peek(), t;
|
|
298
|
-
return e.kind === "number" ? (this.take(), t =
|
|
298
|
+
return e.kind === "number" ? (this.take(), t = w("mn", null, e.value)) : e.kind === "letter" ? (this.take(), t = w("mi", null, e.value)) : e.kind === "punct" ? t = this.parsePunctuation(e) : e.kind === "newline" ? (this.take(), t = w("mspace", { linebreak: "newline" })) : e.kind === "command" ? t = this.parseCommand(e) : (this.take(), t = w("mtext", null, "")), this.applyScripts(t);
|
|
299
299
|
}
|
|
300
300
|
parsePunctuation(e) {
|
|
301
|
-
return this.take(), e.value === "{" ? (--this.pos, this.parseBraceGroup()) : e.value === "}" || e.value === "&" || e.value === "#" ?
|
|
301
|
+
return this.take(), e.value === "{" ? (--this.pos, this.parseBraceGroup()) : e.value === "}" || e.value === "&" || e.value === "#" ? w("mo", null, e.value) : w("mo", e.value === "(" || e.value === ")" || e.value === "[" || e.value === "]" || e.value === "|" ? {
|
|
302
302
|
fence: "true",
|
|
303
303
|
stretchy: "true"
|
|
304
304
|
} : null, e.value);
|
|
@@ -308,62 +308,62 @@ var j = {
|
|
|
308
308
|
if (t === "frac" || t === "dfrac" || t === "tfrac") return this.take(), this.parseFraction();
|
|
309
309
|
if (t === "sqrt") return this.take(), this.parseRoot();
|
|
310
310
|
if (t === "left") return this.take(), this.parseLeft();
|
|
311
|
-
if (t === "right") return this.take(), this.readDelimiter() ??
|
|
311
|
+
if (t === "right") return this.take(), this.readDelimiter() ?? w("mrow", null);
|
|
312
312
|
if (t === "begin") return this.take(), this.parseEnvironment();
|
|
313
|
-
if (t === "end") return this.take(), this.readRawGroup(),
|
|
314
|
-
if (t === "text" || t === "textrm" || t === "mbox" || t === "operatorname") return this.take(),
|
|
313
|
+
if (t === "end") return this.take(), this.readRawGroup(), w("mtext", null, "\\end");
|
|
314
|
+
if (t === "text" || t === "textrm" || t === "mbox" || t === "operatorname") return this.take(), w("mtext", null, this.readRawGroup());
|
|
315
315
|
if (t === "mathrm" || t === "mathbf" || t === "mathit" || t === "mathsf") {
|
|
316
316
|
this.take();
|
|
317
317
|
let e = this.readRawGroup();
|
|
318
|
-
return
|
|
318
|
+
return w("mtext", { mathvariant: t === "mathrm" ? "normal" : t === "mathbf" ? "bold" : t === "mathit" ? "italic" : "sans-serif" }, e);
|
|
319
319
|
}
|
|
320
|
-
if (t === "overline" || t === "bar" || t === "hat" || t === "tilde" || t === "vec" || t === "dot" || t === "ddot") return this.take(),
|
|
321
|
-
if (ee.has(t)) return this.take(),
|
|
322
|
-
if (Object.hasOwn(
|
|
323
|
-
if (
|
|
320
|
+
if (t === "overline" || t === "bar" || t === "hat" || t === "tilde" || t === "vec" || t === "dot" || t === "ddot") return this.take(), w("mover", { accent: "true" }, this.parseRequiredArgument(), w("mo", { stretchy: "true" }, t === "overline" || t === "bar" ? "¯" : t === "hat" ? "^" : t === "tilde" ? "~" : t === "vec" ? "→" : t === "dot" ? "˙" : "¨"));
|
|
321
|
+
if (ee.has(t)) return this.take(), w("mrow", null);
|
|
322
|
+
if (Object.hasOwn(F, t)) return this.take(), w("mspace", { width: F[t] });
|
|
323
|
+
if (P.has(t)) return this.take(), w("mo", {
|
|
324
324
|
mathvariant: "normal",
|
|
325
325
|
form: "prefix"
|
|
326
326
|
}, t);
|
|
327
|
-
if (Object.hasOwn(
|
|
328
|
-
if (Object.hasOwn(
|
|
327
|
+
if (Object.hasOwn(M, t)) return this.take(), w("mi", null, M[t]);
|
|
328
|
+
if (Object.hasOwn(N, t)) {
|
|
329
329
|
this.take();
|
|
330
|
-
let e =
|
|
331
|
-
return
|
|
330
|
+
let e = N[t];
|
|
331
|
+
return w("mo", e === "(" || e === ")" || e === "[" || e === "]" || e === "{" || e === "}" || e === "|" || e === "‖" || e === "⟨" || e === "⟩" ? {
|
|
332
332
|
fence: "true",
|
|
333
333
|
stretchy: "true"
|
|
334
334
|
} : null, e);
|
|
335
335
|
}
|
|
336
|
-
return this.take(),
|
|
336
|
+
return this.take(), w("mtext", null, `\\${t}`);
|
|
337
337
|
}
|
|
338
338
|
parseBraceGroup() {
|
|
339
|
-
if (!this.atPunct("{")) return
|
|
339
|
+
if (!this.atPunct("{")) return w("mrow", null);
|
|
340
340
|
this.take();
|
|
341
341
|
let e = this.parseRow({ chars: /* @__PURE__ */ new Set(["}"]) });
|
|
342
|
-
return this.atPunct("}") && this.take(),
|
|
342
|
+
return this.atPunct("}") && this.take(), w("mrow", null, ...e);
|
|
343
343
|
}
|
|
344
344
|
parseFraction() {
|
|
345
|
-
return
|
|
345
|
+
return w("mfrac", null, this.parseRequiredArgument(), this.parseRequiredArgument());
|
|
346
346
|
}
|
|
347
347
|
parseRoot() {
|
|
348
348
|
let e = null;
|
|
349
349
|
if (this.atPunct("[")) {
|
|
350
350
|
this.take();
|
|
351
351
|
let t = this.parseRow({ chars: /* @__PURE__ */ new Set(["]"]) });
|
|
352
|
-
this.atPunct("]") && this.take(), e =
|
|
352
|
+
this.atPunct("]") && this.take(), e = w("mrow", null, ...t);
|
|
353
353
|
}
|
|
354
354
|
let t = this.parseRequiredArgument();
|
|
355
|
-
return e ?
|
|
355
|
+
return e ? w("mroot", null, t, e) : w("msqrt", null, t);
|
|
356
356
|
}
|
|
357
357
|
parseRequiredArgument() {
|
|
358
358
|
return this.atPunct("{") ? this.parseBraceGroup() : this.parseAtom();
|
|
359
359
|
}
|
|
360
360
|
parseLeft() {
|
|
361
361
|
let e = this.readDelimiter(), t = this.parseRow({ commands: /* @__PURE__ */ new Set(["right"]) }), n = null;
|
|
362
|
-
return this.atCommand("right") && (this.take(), n = this.readDelimiter()), !e && !n ?
|
|
362
|
+
return this.atCommand("right") && (this.take(), n = this.readDelimiter()), !e && !n ? w("mrow", null, ...t) : w("mrow", null, e, ...t, n);
|
|
363
363
|
}
|
|
364
364
|
readDelimiter() {
|
|
365
365
|
let e = this.peek();
|
|
366
|
-
if (e.kind === "punct") return e.value === "." ? (this.take(), null) : "()[]|".includes(e.value) ? (this.take(),
|
|
366
|
+
if (e.kind === "punct") return e.value === "." ? (this.take(), null) : "()[]|".includes(e.value) ? (this.take(), w("mo", {
|
|
367
367
|
fence: "true",
|
|
368
368
|
stretchy: "true"
|
|
369
369
|
}, e.value)) : null;
|
|
@@ -380,7 +380,7 @@ var j = {
|
|
|
380
380
|
langle: "⟨",
|
|
381
381
|
rangle: "⟩"
|
|
382
382
|
}, n = Object.hasOwn(t, e.value) ? t[e.value] : void 0;
|
|
383
|
-
if (n) return this.take(),
|
|
383
|
+
if (n) return this.take(), w("mo", {
|
|
384
384
|
fence: "true",
|
|
385
385
|
stretchy: "true"
|
|
386
386
|
}, n);
|
|
@@ -389,7 +389,7 @@ var j = {
|
|
|
389
389
|
}
|
|
390
390
|
parseEnvironment() {
|
|
391
391
|
let e = this.readRawGroup().trim();
|
|
392
|
-
if (e !== "cases") return
|
|
392
|
+
if (e !== "cases") return w("mtext", null, `\\begin{${e}}`);
|
|
393
393
|
let t = [], n = 0;
|
|
394
394
|
for (; !this.atCommand("end") && this.peek().kind !== "eof" && n < 500;) {
|
|
395
395
|
n += 1;
|
|
@@ -400,21 +400,21 @@ var j = {
|
|
|
400
400
|
commands: /* @__PURE__ */ new Set(["end"]),
|
|
401
401
|
newline: !0
|
|
402
402
|
});
|
|
403
|
-
if (e.push(
|
|
403
|
+
if (e.push(w("mtd", { columnalign: "left" }, ...t)), !this.atPunct("&")) break;
|
|
404
404
|
this.take();
|
|
405
405
|
}
|
|
406
|
-
if (t.push(
|
|
406
|
+
if (t.push(w("mtr", null, ...e)), this.peek().kind === "newline") this.take();
|
|
407
407
|
else {
|
|
408
408
|
if (this.atCommand("end") || this.peek().kind === "eof") break;
|
|
409
409
|
this.take();
|
|
410
410
|
}
|
|
411
411
|
}
|
|
412
412
|
this.atCommand("end") && (this.take(), this.readRawGroup());
|
|
413
|
-
let r =
|
|
413
|
+
let r = w("mtable", {
|
|
414
414
|
columnalign: "left",
|
|
415
415
|
columnspacing: "1em"
|
|
416
416
|
}, ...t);
|
|
417
|
-
return
|
|
417
|
+
return w("mrow", null, w("mo", {
|
|
418
418
|
fence: "true",
|
|
419
419
|
stretchy: "true"
|
|
420
420
|
}, "{"), r);
|
|
@@ -424,10 +424,10 @@ var j = {
|
|
|
424
424
|
for (;;) if (this.atPunct("^")) this.take(), n = this.parseScriptArgument(), r = !0;
|
|
425
425
|
else if (this.atPunct("_")) this.take(), t = this.parseScriptArgument(), r = !0;
|
|
426
426
|
else break;
|
|
427
|
-
return r ? t !== null && n !== null ?
|
|
427
|
+
return r ? t !== null && n !== null ? w("msubsup", null, e, t, n) : n === null ? w("msub", null, e, t) : w("msup", null, e, n) : e;
|
|
428
428
|
}
|
|
429
429
|
parseScriptArgument() {
|
|
430
|
-
return this.atPunct("{") ? this.parseBraceGroup() : this.atPunct("+") || this.atPunct("-") ?
|
|
430
|
+
return this.atPunct("{") ? this.parseBraceGroup() : this.atPunct("+") || this.atPunct("-") ? w("mrow", null, w("mo", null, this.take().value), this.parseAtom()) : this.parseAtom();
|
|
431
431
|
}
|
|
432
432
|
readRawGroup() {
|
|
433
433
|
if (!this.atPunct("{")) return "";
|
|
@@ -446,46 +446,46 @@ var j = {
|
|
|
446
446
|
}
|
|
447
447
|
};
|
|
448
448
|
function ne({ source: e, display: t = !1 }) {
|
|
449
|
-
let n =
|
|
450
|
-
if (e.length >
|
|
449
|
+
let n = A(e), r;
|
|
450
|
+
if (e.length > E) r = w("mtext", null, n);
|
|
451
451
|
else try {
|
|
452
452
|
r = new te(e).render();
|
|
453
453
|
} catch {
|
|
454
|
-
r =
|
|
454
|
+
r = w("mtext", null, n);
|
|
455
455
|
}
|
|
456
|
-
let i = e.length >
|
|
457
|
-
return
|
|
456
|
+
let i = e.length > k ? n : e;
|
|
457
|
+
return w("math", {
|
|
458
458
|
display: t ? "block" : "inline",
|
|
459
459
|
className: t ? "local-math local-math-block" : "local-math",
|
|
460
460
|
"aria-label": i
|
|
461
|
-
},
|
|
461
|
+
}, w("semantics", null, w("mrow", null, r), w("annotation", { encoding: "application/x-tex" }, i)));
|
|
462
462
|
}
|
|
463
463
|
// src/local/visuals.tsx
|
|
464
|
-
var
|
|
465
|
-
"
|
|
466
|
-
"
|
|
467
|
-
"
|
|
468
|
-
"
|
|
469
|
-
"
|
|
470
|
-
"
|
|
471
|
-
"
|
|
472
|
-
"
|
|
473
|
-
], re = 520, ie = 320, ae = 520, oe = 320, se = 520,
|
|
474
|
-
function
|
|
464
|
+
var I = [
|
|
465
|
+
"var(--chart-1)",
|
|
466
|
+
"var(--chart-2)",
|
|
467
|
+
"var(--chart-3)",
|
|
468
|
+
"var(--chart-4)",
|
|
469
|
+
"var(--chart-5)",
|
|
470
|
+
"var(--chart-6)",
|
|
471
|
+
"var(--chart-7)",
|
|
472
|
+
"var(--chart-8)"
|
|
473
|
+
], re = 520, ie = 320, ae = 520, oe = 320, se = 520, ce = 120, L = 46, le = 150, ue = 12.5, de = 10, R = 100, z = 2, fe = 15, pe = /^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/, me = /^\s*\{\{([\s\S]*)\}\}\s*$/;
|
|
474
|
+
function B(e) {
|
|
475
475
|
if (!Number.isFinite(e)) return "—";
|
|
476
476
|
if (Object.is(e, -0)) return "0";
|
|
477
477
|
let t = Math.abs(e);
|
|
478
478
|
return t >= 0xe8d4a51000 || t > 0 && t < 1e-4 ? e.toExponential(3).replace(/(\.\d*?)0+e/, "$1e").replace(/\.e/, "e") : Number(e.toFixed(6)).toString();
|
|
479
479
|
}
|
|
480
|
-
function
|
|
480
|
+
function he(e) {
|
|
481
481
|
if (!Number.isFinite(e)) return "—";
|
|
482
482
|
let t = Math.abs(e);
|
|
483
483
|
return t >= 1e6 || t > 0 && t < .001 ? e.toExponential(2) : Number(e.toFixed(4)).toString();
|
|
484
484
|
}
|
|
485
|
-
function
|
|
485
|
+
function V(e) {
|
|
486
486
|
return e instanceof Error ? e.message : String(e);
|
|
487
487
|
}
|
|
488
|
-
function
|
|
488
|
+
function H(e, t, n, r = "") {
|
|
489
489
|
let i = t?.[n];
|
|
490
490
|
if (i === void 0) return r;
|
|
491
491
|
try {
|
|
@@ -494,12 +494,12 @@ function B(e, t, n, r = "") {
|
|
|
494
494
|
return r;
|
|
495
495
|
}
|
|
496
496
|
}
|
|
497
|
-
function
|
|
497
|
+
function ge(e, t, n, r) {
|
|
498
498
|
let i = t?.[n];
|
|
499
499
|
if (i === void 0) return r;
|
|
500
500
|
let a = i.trim();
|
|
501
501
|
if (!a) return null;
|
|
502
|
-
let o =
|
|
502
|
+
let o = me.exec(a);
|
|
503
503
|
try {
|
|
504
504
|
let t = o ? e.evaluate(o[1].trim()) : Number(a);
|
|
505
505
|
return typeof t == "number" && Number.isFinite(t) ? t : null;
|
|
@@ -507,13 +507,13 @@ function de(e, t, n, r) {
|
|
|
507
507
|
return null;
|
|
508
508
|
}
|
|
509
509
|
}
|
|
510
|
-
function
|
|
510
|
+
function _e(e, t, n, r) {
|
|
511
511
|
let i = t?.[n];
|
|
512
512
|
if (i === void 0) return r;
|
|
513
513
|
let a = i.trim();
|
|
514
514
|
if (!a || a === "true") return !0;
|
|
515
515
|
if (a === "false") return !1;
|
|
516
|
-
let o =
|
|
516
|
+
let o = me.exec(a);
|
|
517
517
|
if (!o) return r;
|
|
518
518
|
try {
|
|
519
519
|
let t = e.evaluate(o[1].trim());
|
|
@@ -522,20 +522,20 @@ function V(e, t, n, r) {
|
|
|
522
522
|
return r;
|
|
523
523
|
}
|
|
524
524
|
}
|
|
525
|
-
function
|
|
526
|
-
let i =
|
|
525
|
+
function ve(e, t, n, r) {
|
|
526
|
+
let i = ge(e, t, n, r);
|
|
527
527
|
return i === null || !Number.isFinite(i) ? r : Math.trunc(i);
|
|
528
528
|
}
|
|
529
|
-
function
|
|
529
|
+
function ye(e, t) {
|
|
530
530
|
return e.length > t ? `${e.slice(0, Math.max(1, t - 1))}…` : e;
|
|
531
531
|
}
|
|
532
|
-
function
|
|
532
|
+
function be(e, t = 8, n = 2) {
|
|
533
533
|
if (!e) return [""];
|
|
534
534
|
let r = [], i = e;
|
|
535
535
|
for (; i && r.length < n - 1;) r.push(i.slice(0, t)), i = i.slice(t);
|
|
536
536
|
return (i || r.length === 0) && r.push(i.length > t ? `${i.slice(0, Math.max(1, t - 1))}…` : i), r;
|
|
537
537
|
}
|
|
538
|
-
function
|
|
538
|
+
function xe(e, t) {
|
|
539
539
|
let n = Array.from(e), r = Array.from(t), i = Math.min(n.length, r.length);
|
|
540
540
|
for (let e = 0; e < i; e += 1) {
|
|
541
541
|
let t = (n[e].codePointAt(0) ?? 0) - (r[e].codePointAt(0) ?? 0);
|
|
@@ -543,13 +543,13 @@ function he(e, t) {
|
|
|
543
543
|
}
|
|
544
544
|
return n.length - r.length;
|
|
545
545
|
}
|
|
546
|
-
function
|
|
546
|
+
function Se(e, t, n = 5) {
|
|
547
547
|
if (!Number.isFinite(e) || !Number.isFinite(t) || t <= e) return [e];
|
|
548
548
|
let r = (t - e) / Math.max(1, n - 1), i = 10 ** Math.floor(Math.log10(r)), a = r / i, o = (a <= 1 ? 1 : a <= 2 ? 2 : a <= 5 ? 5 : 10) * i, s = Math.ceil(e / o) * o, c = [];
|
|
549
549
|
for (let e = s; e <= t + o * 1e-9 && c.length < 40; e += o) c.push(Number(e.toFixed(10)));
|
|
550
550
|
return c;
|
|
551
551
|
}
|
|
552
|
-
function
|
|
552
|
+
function Ce(e, t) {
|
|
553
553
|
let n = Infinity, r = -Infinity;
|
|
554
554
|
for (let t of e) Number.isFinite(t) && (t < n && (n = t), t > r && (r = t));
|
|
555
555
|
if (!Number.isFinite(n) || !Number.isFinite(r)) return {
|
|
@@ -568,19 +568,19 @@ function _e(e, t) {
|
|
|
568
568
|
max: r
|
|
569
569
|
};
|
|
570
570
|
}
|
|
571
|
-
function
|
|
572
|
-
return Math.max(46, ...e.map((e) =>
|
|
571
|
+
function we(e, t) {
|
|
572
|
+
return Math.max(46, ...e.map((e) => he(e).length * 6 + (t ? 24 : 10)));
|
|
573
573
|
}
|
|
574
|
-
function
|
|
574
|
+
function Te(e, t, n) {
|
|
575
575
|
let r = e.currentTarget, i = r.ownerSVGElement ?? r.closest("svg");
|
|
576
576
|
if (!i) return;
|
|
577
577
|
let a = Array.from(i.querySelectorAll(t)), o = a.indexOf(r);
|
|
578
578
|
o < 0 || a.length === 0 || (e.preventDefault(), a[(o + n + a.length) % a.length]?.focus());
|
|
579
579
|
}
|
|
580
|
-
function
|
|
580
|
+
function Ee(e) {
|
|
581
581
|
return e.key === "Enter" || e.key === " " || e.key === "Spacebar";
|
|
582
582
|
}
|
|
583
|
-
function
|
|
583
|
+
function De(e) {
|
|
584
584
|
return e === null ? {
|
|
585
585
|
text: "",
|
|
586
586
|
kind: "null",
|
|
@@ -590,7 +590,7 @@ function H(e) {
|
|
|
590
590
|
kind: "string",
|
|
591
591
|
error: null
|
|
592
592
|
} : typeof e == "number" ? Number.isFinite(e) ? {
|
|
593
|
-
text:
|
|
593
|
+
text: B(e),
|
|
594
594
|
kind: "number",
|
|
595
595
|
error: null
|
|
596
596
|
} : {
|
|
@@ -607,19 +607,19 @@ function H(e) {
|
|
|
607
607
|
error: "数组需要先用 len 等函数转换"
|
|
608
608
|
};
|
|
609
609
|
}
|
|
610
|
-
function
|
|
610
|
+
function Oe(e, t) {
|
|
611
611
|
let n = "", r = null;
|
|
612
612
|
for (let i of e ?? []) if (i.type === "text" || i.type === "inlineCode" || i.type === "code") n += i.value ?? "";
|
|
613
613
|
else if (i.type === "interpolation") try {
|
|
614
|
-
let e =
|
|
614
|
+
let e = De(t.evaluate((i.value ?? "").trim()));
|
|
615
615
|
e.error && (r ??= e.error), n += e.text;
|
|
616
616
|
} catch (e) {
|
|
617
|
-
r ??=
|
|
617
|
+
r ??= V(e), n += "无法计算";
|
|
618
618
|
}
|
|
619
619
|
else if (i.type === "inlineMath" || i.type === "math") n += i.value ?? "";
|
|
620
620
|
else if (i.type === "image") n += i.alt ?? "";
|
|
621
621
|
else if (i.children && i.children.length > 0) {
|
|
622
|
-
let e =
|
|
622
|
+
let e = Oe(i.children, t);
|
|
623
623
|
n += e.text, r ??= e.error;
|
|
624
624
|
} else i.value && (n += i.value);
|
|
625
625
|
return {
|
|
@@ -627,10 +627,10 @@ function xe(e, t) {
|
|
|
627
627
|
error: r
|
|
628
628
|
};
|
|
629
629
|
}
|
|
630
|
-
function
|
|
630
|
+
function ke(e, t) {
|
|
631
631
|
let n = e.children ?? [], r = n.filter((e) => !(e.type === "text" && !(e.value ?? "").trim()));
|
|
632
632
|
if (r.length === 1 && r[0].type === "interpolation") try {
|
|
633
|
-
let i = t.evaluate((r[0].value ?? "").trim()), a =
|
|
633
|
+
let i = t.evaluate((r[0].value ?? "").trim()), a = De(i);
|
|
634
634
|
return {
|
|
635
635
|
node: e,
|
|
636
636
|
children: n,
|
|
@@ -648,11 +648,11 @@ function Se(e, t) {
|
|
|
648
648
|
value: void 0,
|
|
649
649
|
kind: "error",
|
|
650
650
|
numeric: null,
|
|
651
|
-
error:
|
|
651
|
+
error: V(t)
|
|
652
652
|
};
|
|
653
653
|
}
|
|
654
|
-
let i =
|
|
655
|
-
if (r.length > 0 && r.every((e) => e.type === "text") &&
|
|
654
|
+
let i = Oe(n, t);
|
|
655
|
+
if (r.length > 0 && r.every((e) => e.type === "text") && pe.test(i.text.trim())) {
|
|
656
656
|
let t = Number(i.text.trim());
|
|
657
657
|
if (Number.isFinite(t)) return {
|
|
658
658
|
node: e,
|
|
@@ -675,26 +675,26 @@ function Se(e, t) {
|
|
|
675
675
|
error: i.error
|
|
676
676
|
};
|
|
677
677
|
}
|
|
678
|
-
function
|
|
678
|
+
function Ae(e) {
|
|
679
679
|
return e ? e.error ? "无法计算" : e.text : "";
|
|
680
680
|
}
|
|
681
|
-
function
|
|
681
|
+
function je(e, t) {
|
|
682
682
|
let n = e.children?.find((e) => e.type === "table");
|
|
683
683
|
if (!n) return null;
|
|
684
684
|
let r = n.children?.filter((e) => e.type === "tableRow") ?? [];
|
|
685
685
|
if (r.length === 0) return null;
|
|
686
|
-
let i = (r[0].children ?? []).map((e) =>
|
|
686
|
+
let i = (r[0].children ?? []).map((e) => ke(e, t));
|
|
687
687
|
return {
|
|
688
688
|
tableNode: n,
|
|
689
689
|
header: i,
|
|
690
|
-
headerText: i.map(
|
|
690
|
+
headerText: i.map(Ae),
|
|
691
691
|
rows: r.slice(1).map((e, n) => ({
|
|
692
692
|
index: n,
|
|
693
|
-
cells: (e.children ?? []).map((e) =>
|
|
693
|
+
cells: (e.children ?? []).map((e) => ke(e, t))
|
|
694
694
|
}))
|
|
695
695
|
};
|
|
696
696
|
}
|
|
697
|
-
function
|
|
697
|
+
function Me(e, t) {
|
|
698
698
|
let n = !1;
|
|
699
699
|
for (let r of e.rows) {
|
|
700
700
|
let e = r.cells[t];
|
|
@@ -706,11 +706,11 @@ function Te(e, t) {
|
|
|
706
706
|
return n;
|
|
707
707
|
}
|
|
708
708
|
function U({ className: e, label: t, children: n }) {
|
|
709
|
-
let r =
|
|
710
|
-
return /* @__PURE__ */
|
|
709
|
+
let r = g();
|
|
710
|
+
return /* @__PURE__ */ C("figure", {
|
|
711
711
|
className: `local-visual ${e}`,
|
|
712
712
|
"aria-labelledby": r,
|
|
713
|
-
children: [/* @__PURE__ */
|
|
713
|
+
children: [/* @__PURE__ */ S("figcaption", {
|
|
714
714
|
id: r,
|
|
715
715
|
className: "local-visual-title",
|
|
716
716
|
children: t
|
|
@@ -718,38 +718,38 @@ function U({ className: e, label: t, children: n }) {
|
|
|
718
718
|
});
|
|
719
719
|
}
|
|
720
720
|
function W({ message: e, kind: t = "status" }) {
|
|
721
|
-
return /* @__PURE__ */
|
|
721
|
+
return /* @__PURE__ */ S("p", {
|
|
722
722
|
className: `local-visual-message local-visual-${t}`,
|
|
723
723
|
role: t,
|
|
724
724
|
children: e
|
|
725
725
|
});
|
|
726
726
|
}
|
|
727
|
-
function
|
|
728
|
-
return e.length === 0 ? null : /* @__PURE__ */
|
|
727
|
+
function Ne({ notes: e }) {
|
|
728
|
+
return e.length === 0 ? null : /* @__PURE__ */ S("ul", {
|
|
729
729
|
className: "local-visual-notes",
|
|
730
730
|
role: "status",
|
|
731
|
-
children: e.map((e, t) => /* @__PURE__ */
|
|
731
|
+
children: e.map((e, t) => /* @__PURE__ */ S("li", { children: e }, `${e}-${t}`))
|
|
732
732
|
});
|
|
733
733
|
}
|
|
734
|
-
function
|
|
735
|
-
return /* @__PURE__ */
|
|
734
|
+
function Pe({ items: e, hidden: t, onToggle: n, label: r }) {
|
|
735
|
+
return /* @__PURE__ */ S("div", {
|
|
736
736
|
className: "local-visual-legend",
|
|
737
737
|
role: "group",
|
|
738
738
|
"aria-label": r,
|
|
739
739
|
children: e.map((e, r) => {
|
|
740
740
|
let i = t.has(r);
|
|
741
|
-
return /* @__PURE__ */
|
|
741
|
+
return /* @__PURE__ */ C("button", {
|
|
742
742
|
type: "button",
|
|
743
743
|
className: `local-visual-legend-item${i ? " is-off" : ""}`,
|
|
744
744
|
"aria-pressed": !i,
|
|
745
745
|
disabled: e.disabled,
|
|
746
746
|
onClick: () => n(r),
|
|
747
747
|
title: i ? `显示 ${e.name}` : `隐藏 ${e.name}`,
|
|
748
|
-
children: [/* @__PURE__ */
|
|
748
|
+
children: [/* @__PURE__ */ S("span", {
|
|
749
749
|
className: "local-visual-swatch",
|
|
750
750
|
style: { backgroundColor: e.color },
|
|
751
751
|
"aria-hidden": "true"
|
|
752
|
-
}), /* @__PURE__ */
|
|
752
|
+
}), /* @__PURE__ */ C("span", {
|
|
753
753
|
className: "local-visual-legend-text",
|
|
754
754
|
children: [e.name, e.detail ? `(${e.detail})` : ""]
|
|
755
755
|
})]
|
|
@@ -757,21 +757,21 @@ function De({ items: e, hidden: t, onToggle: n, label: r }) {
|
|
|
757
757
|
})
|
|
758
758
|
});
|
|
759
759
|
}
|
|
760
|
-
function
|
|
761
|
-
let [r, i] =
|
|
762
|
-
|
|
760
|
+
function Fe({ node: e, runtime: t, render: n }) {
|
|
761
|
+
let [r, i] = y(""), [a, o] = y(null), [s, c] = y(1), l = t.resetToken(e);
|
|
762
|
+
h(() => {
|
|
763
763
|
i(""), o(null), c(1);
|
|
764
764
|
}, [l]);
|
|
765
|
-
let u =
|
|
766
|
-
if (!g || g.header.length === 0) return /* @__PURE__ */
|
|
765
|
+
let u = H(t, e.attrs, "label", "表格"), d = _e(t, e.attrs, "searchable", !0), f = _e(t, e.attrs, "sortable", !0), p = ve(t, e.attrs, "page-size", 10), m = Math.max(1, p), g = je(e, t);
|
|
766
|
+
if (!g || g.header.length === 0) return /* @__PURE__ */ S(U, {
|
|
767
767
|
className: "local-visual-table-block",
|
|
768
768
|
label: u,
|
|
769
|
-
children: /* @__PURE__ */
|
|
769
|
+
children: /* @__PURE__ */ S(W, {
|
|
770
770
|
message: "表格需要一个非空的 Markdown 表格。",
|
|
771
771
|
kind: "alert"
|
|
772
772
|
})
|
|
773
773
|
});
|
|
774
|
-
let _ = g.header.map((e, t) =>
|
|
774
|
+
let _ = g.header.map((e, t) => Me(g, t)), v = r.trim().toLowerCase(), b = [...g.rows.filter((e) => !v || e.cells.some((e) => Ae(e).toLowerCase().includes(v)))];
|
|
775
775
|
if (a) {
|
|
776
776
|
let e = _[a.column];
|
|
777
777
|
b.sort((t, n) => {
|
|
@@ -779,11 +779,11 @@ function Oe({ node: e, runtime: t, render: n }) {
|
|
|
779
779
|
if (e) {
|
|
780
780
|
let e = r?.numeric ?? -Infinity, t = i?.numeric ?? -Infinity;
|
|
781
781
|
o = e === t ? 0 : e < t ? -1 : 1;
|
|
782
|
-
} else o =
|
|
782
|
+
} else o = xe(Ae(r), Ae(i));
|
|
783
783
|
return o === 0 ? t.index - n.index : a.direction === "asc" ? o : -o;
|
|
784
784
|
});
|
|
785
785
|
}
|
|
786
|
-
let
|
|
786
|
+
let x = Math.max(1, Math.ceil(b.length / m)), w = Math.min(s, x), T = b.slice((w - 1) * m, w * m), E = (e) => {
|
|
787
787
|
c(1), o((t) => !t || t.column !== e ? {
|
|
788
788
|
column: e,
|
|
789
789
|
direction: "asc"
|
|
@@ -792,13 +792,13 @@ function Oe({ node: e, runtime: t, render: n }) {
|
|
|
792
792
|
direction: "desc"
|
|
793
793
|
} : null);
|
|
794
794
|
}, D = (e) => !a || a.column !== e ? "" : a.direction === "asc" ? "(升序)" : "(降序)";
|
|
795
|
-
return /* @__PURE__ */
|
|
795
|
+
return /* @__PURE__ */ C(U, {
|
|
796
796
|
className: "local-visual-table-block",
|
|
797
797
|
label: u,
|
|
798
798
|
children: [
|
|
799
|
-
d ? /* @__PURE__ */
|
|
799
|
+
d ? /* @__PURE__ */ C("label", {
|
|
800
800
|
className: "local-visual-search",
|
|
801
|
-
children: [/* @__PURE__ */
|
|
801
|
+
children: [/* @__PURE__ */ S("span", { children: "搜索" }), /* @__PURE__ */ S("input", {
|
|
802
802
|
type: "search",
|
|
803
803
|
value: r,
|
|
804
804
|
placeholder: "搜索所有列",
|
|
@@ -808,64 +808,68 @@ function Oe({ node: e, runtime: t, render: n }) {
|
|
|
808
808
|
}
|
|
809
809
|
})]
|
|
810
810
|
}) : null,
|
|
811
|
-
/* @__PURE__ */
|
|
811
|
+
/* @__PURE__ */ S("div", {
|
|
812
812
|
className: "local-visual-table-scroll",
|
|
813
|
-
children: /* @__PURE__ */
|
|
813
|
+
children: /* @__PURE__ */ C("table", {
|
|
814
814
|
className: "local-visual-table",
|
|
815
815
|
children: [
|
|
816
|
-
/* @__PURE__ */
|
|
816
|
+
/* @__PURE__ */ S("caption", {
|
|
817
817
|
className: "local-visual-sr-only",
|
|
818
818
|
children: u
|
|
819
819
|
}),
|
|
820
|
-
/* @__PURE__ */
|
|
820
|
+
/* @__PURE__ */ S("thead", { children: /* @__PURE__ */ S("tr", { children: g.header.map((e, t) => {
|
|
821
821
|
let n = a && a.column === t ? a.direction === "asc" ? "ascending" : "descending" : "none";
|
|
822
|
-
return /* @__PURE__ */
|
|
822
|
+
return /* @__PURE__ */ S("th", {
|
|
823
823
|
scope: "col",
|
|
824
824
|
"aria-sort": n,
|
|
825
|
-
|
|
825
|
+
className: _[t] ? "is-numeric" : void 0,
|
|
826
|
+
children: f ? /* @__PURE__ */ C("button", {
|
|
826
827
|
type: "button",
|
|
827
828
|
className: `local-visual-sort-button${a && a.column === t ? " is-sorted" : ""}`,
|
|
828
829
|
onClick: () => E(t),
|
|
829
830
|
title: "点击切换升序、降序和原始顺序",
|
|
830
|
-
children: [
|
|
831
|
-
}) :
|
|
831
|
+
children: [Ae(e), D(t)]
|
|
832
|
+
}) : Ae(e)
|
|
832
833
|
}, `head-${t}`);
|
|
833
834
|
}) }) }),
|
|
834
|
-
/* @__PURE__ */
|
|
835
|
+
/* @__PURE__ */ S("tbody", { children: T.map((e) => /* @__PURE__ */ S("tr", { children: g.header.map((t, r) => {
|
|
835
836
|
let i = e.cells[r];
|
|
836
|
-
return /* @__PURE__ */
|
|
837
|
-
className: "
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
837
|
+
return /* @__PURE__ */ S("td", {
|
|
838
|
+
className: _[r] ? "is-numeric" : void 0,
|
|
839
|
+
children: i?.error ? /* @__PURE__ */ S("span", {
|
|
840
|
+
className: "local-visual-cell-error",
|
|
841
|
+
title: i.error,
|
|
842
|
+
children: "无法计算"
|
|
843
|
+
}) : n(i?.children ?? [])
|
|
844
|
+
}, `cell-${e.index}-${r}`);
|
|
841
845
|
}) }, `row-${e.index}`)) })
|
|
842
846
|
]
|
|
843
847
|
})
|
|
844
848
|
}),
|
|
845
|
-
b.length === 0 ? /* @__PURE__ */
|
|
846
|
-
|
|
849
|
+
b.length === 0 ? /* @__PURE__ */ S(W, { message: "没有匹配结果" }) : null,
|
|
850
|
+
x > 1 ? /* @__PURE__ */ C("nav", {
|
|
847
851
|
className: "local-visual-pagination",
|
|
848
852
|
"aria-label": "表格分页",
|
|
849
853
|
children: [
|
|
850
|
-
/* @__PURE__ */
|
|
854
|
+
/* @__PURE__ */ S("button", {
|
|
851
855
|
type: "button",
|
|
852
856
|
disabled: w <= 1,
|
|
853
857
|
onClick: () => c((e) => Math.max(1, e - 1)),
|
|
854
858
|
children: "上一页"
|
|
855
859
|
}),
|
|
856
|
-
/* @__PURE__ */
|
|
860
|
+
/* @__PURE__ */ C("span", { children: [
|
|
857
861
|
"第 ",
|
|
858
862
|
w,
|
|
859
863
|
" / ",
|
|
860
|
-
|
|
864
|
+
x,
|
|
861
865
|
" 页 · 共 ",
|
|
862
866
|
b.length,
|
|
863
867
|
" 行"
|
|
864
868
|
] }),
|
|
865
|
-
/* @__PURE__ */
|
|
869
|
+
/* @__PURE__ */ S("button", {
|
|
866
870
|
type: "button",
|
|
867
|
-
disabled: w >=
|
|
868
|
-
onClick: () => c((e) => Math.min(
|
|
871
|
+
disabled: w >= x,
|
|
872
|
+
onClick: () => c((e) => Math.min(x, e + 1)),
|
|
869
873
|
children: "下一页"
|
|
870
874
|
})
|
|
871
875
|
]
|
|
@@ -873,14 +877,14 @@ function Oe({ node: e, runtime: t, render: n }) {
|
|
|
873
877
|
]
|
|
874
878
|
});
|
|
875
879
|
}
|
|
876
|
-
var
|
|
880
|
+
var Ie = [
|
|
877
881
|
"bar",
|
|
878
882
|
"line",
|
|
879
883
|
"area",
|
|
880
884
|
"scatter",
|
|
881
885
|
"donut"
|
|
882
886
|
];
|
|
883
|
-
function
|
|
887
|
+
function Le(e, t, n, r, i, a) {
|
|
884
888
|
let o = (n, r) => [e + n * Math.cos(r), t + n * Math.sin(r)], [s, c] = o(n, i), [l, u] = o(n, a), [d, f] = o(r, a), [p, m] = o(r, i), h = +(a - i > Math.PI);
|
|
885
889
|
return [
|
|
886
890
|
`M ${s} ${c}`,
|
|
@@ -890,56 +894,56 @@ function Ae(e, t, n, r, i, a) {
|
|
|
890
894
|
"Z"
|
|
891
895
|
].join(" ");
|
|
892
896
|
}
|
|
893
|
-
function
|
|
894
|
-
let [n, r] =
|
|
895
|
-
|
|
897
|
+
function Re({ node: e, runtime: t }) {
|
|
898
|
+
let [n, r] = y(/* @__PURE__ */ new Set()), [i, a] = y(/* @__PURE__ */ new Set()), [o, s] = y(null), c = t.resetToken(e);
|
|
899
|
+
h(() => {
|
|
896
900
|
r(/* @__PURE__ */ new Set()), a(/* @__PURE__ */ new Set()), s(null);
|
|
897
901
|
}, [c]);
|
|
898
|
-
let l =
|
|
899
|
-
if (!_ || _.header.length === 0) return /* @__PURE__ */
|
|
902
|
+
let l = g(), u = H(t, e.attrs, "title", "") || H(t, e.attrs, "label", "") || "图表", d = (e.attrs?.kind ?? "bar").trim().toLowerCase(), f = Ie.includes(d) ? d : null, p = H(t, e.attrs, "x-label", ""), m = H(t, e.attrs, "y-label", ""), _ = je(e, t);
|
|
903
|
+
if (!_ || _.header.length === 0) return /* @__PURE__ */ S(U, {
|
|
900
904
|
className: "local-visual-chart",
|
|
901
905
|
label: u,
|
|
902
|
-
children: /* @__PURE__ */
|
|
906
|
+
children: /* @__PURE__ */ S(W, {
|
|
903
907
|
message: "chart 正文需要一个非空的 Markdown 表格。",
|
|
904
908
|
kind: "alert"
|
|
905
909
|
})
|
|
906
910
|
});
|
|
907
|
-
let
|
|
911
|
+
let v = _.headerText.map((e) => e.trim()), b = _.rows.map((e) => ({
|
|
908
912
|
index: e.index,
|
|
909
913
|
cells: e.cells,
|
|
910
|
-
texts:
|
|
914
|
+
texts: v.map((t, n) => Ae(e.cells[n]))
|
|
911
915
|
}));
|
|
912
|
-
if (!f) return /* @__PURE__ */
|
|
916
|
+
if (!f) return /* @__PURE__ */ S(U, {
|
|
913
917
|
className: "local-visual-chart",
|
|
914
918
|
label: u,
|
|
915
|
-
children: /* @__PURE__ */
|
|
919
|
+
children: /* @__PURE__ */ S(W, {
|
|
916
920
|
message: `未知图表类型“${d}”。`,
|
|
917
921
|
kind: "alert"
|
|
918
922
|
})
|
|
919
923
|
});
|
|
920
|
-
let
|
|
921
|
-
(E < 0 || E >=
|
|
924
|
+
let x = [], w = [], T = (e.attrs?.x ?? "").trim(), E = T ? v.indexOf(T) : 0;
|
|
925
|
+
(E < 0 || E >= v.length) && w.push(`x 列“${T}”不存在。`);
|
|
922
926
|
let D = (e.attrs?.y ?? "").split(",").map((e) => e.trim()).filter(Boolean), O = [];
|
|
923
927
|
if (f === "donut") {
|
|
924
928
|
if (D.length > 1) w.push("donut 只能使用一个数值列,请在 y 中指定唯一列。");
|
|
925
929
|
else if (D.length === 1) {
|
|
926
|
-
let e =
|
|
930
|
+
let e = v.indexOf(D[0]);
|
|
927
931
|
e < 0 ? w.push(`y 列“${D[0]}”不存在。`) : O = [e];
|
|
928
|
-
} else
|
|
932
|
+
} else v.length === 2 ? O = [1] : w.push("donut 多于两列时必须用 y 指定唯一数值列。");
|
|
929
933
|
} else if (D.length > 0) for (let e of D) {
|
|
930
|
-
let t =
|
|
934
|
+
let t = v.indexOf(e);
|
|
931
935
|
t < 0 ? w.push(`y 列“${e}”不存在。`) : O.includes(t) || O.push(t);
|
|
932
936
|
}
|
|
933
|
-
else O =
|
|
934
|
-
if (w.length === 0 && O.length === 0 && w.push("图表至少需要一个数值系列。"), w.length > 0) return /* @__PURE__ */
|
|
937
|
+
else O = v.map((e, t) => t).filter((e) => e !== E);
|
|
938
|
+
if (w.length === 0 && O.length === 0 && w.push("图表至少需要一个数值系列。"), w.length > 0) return /* @__PURE__ */ S(U, {
|
|
935
939
|
className: `local-visual-chart local-visual-chart-${f}`,
|
|
936
940
|
label: u,
|
|
937
|
-
children: w.map((e, t) => /* @__PURE__ */
|
|
941
|
+
children: w.map((e, t) => /* @__PURE__ */ S(W, {
|
|
938
942
|
message: e,
|
|
939
943
|
kind: "alert"
|
|
940
944
|
}, `${e}-${t}`))
|
|
941
945
|
});
|
|
942
|
-
let k = O.map((e) =>
|
|
946
|
+
let k = O.map((e) => v[e] || `系列 ${e + 1}`), A = 0, j = 0, M = b.map((e) => {
|
|
943
947
|
let t = e.cells[E], n = e.texts[E] || `第 ${e.index + 1} 项`, r = t && t.numeric !== null ? t.numeric : null, i = O.map((t) => {
|
|
944
948
|
let n = e.cells[t];
|
|
945
949
|
return !n || n.kind === "empty" || n.numeric === null ? (A += 1, null) : (f === "donut" && n.numeric < 0 && (j += 1), n.numeric);
|
|
@@ -952,9 +956,9 @@ function je({ node: e, runtime: t }) {
|
|
|
952
956
|
cells: e.cells
|
|
953
957
|
};
|
|
954
958
|
});
|
|
955
|
-
A > 0 &&
|
|
956
|
-
for (let e of O)
|
|
957
|
-
f === "donut" && j > 0 &&
|
|
959
|
+
A > 0 && x.push(`${A} 个数值为空或无法计算,图表中保留空缺。`);
|
|
960
|
+
for (let e of O) Me(_, e) || x.push(`列“${v[e]}”不是纯数值列,非数值按空缺处理。`);
|
|
961
|
+
f === "donut" && j > 0 && x.push(`环形图数值必须非负,已忽略 ${j} 个负值。`), f === "scatter" && !Me(_, E) && x.push(`scatter 的横轴列“${v[E]}”需要数值。`);
|
|
958
962
|
let N = (e) => {
|
|
959
963
|
s(null), r((t) => {
|
|
960
964
|
let n = new Set(t);
|
|
@@ -965,24 +969,24 @@ function je({ node: e, runtime: t }) {
|
|
|
965
969
|
let n = new Set(t);
|
|
966
970
|
return n.has(e) ? n.delete(e) : n.add(e), n;
|
|
967
971
|
});
|
|
968
|
-
},
|
|
972
|
+
}, F = k.map((e, t) => ({
|
|
969
973
|
name: e,
|
|
970
|
-
color:
|
|
974
|
+
color: I[t % I.length]
|
|
971
975
|
}));
|
|
972
976
|
if (f === "donut") {
|
|
973
977
|
let e = M.map((e) => e.values[0]), t = e.map((e) => e !== null && e >= 0 ? e : 0), n = t.reduce((e, t, n) => i.has(n) ? e : e + t, 0), r = M.map((n, r) => ({
|
|
974
978
|
name: n.label,
|
|
975
|
-
color:
|
|
976
|
-
detail: e[r] === null ? "—" :
|
|
979
|
+
color: I[r % I.length],
|
|
980
|
+
detail: e[r] === null ? "—" : B(e[r]),
|
|
977
981
|
disabled: t[r] <= 0
|
|
978
982
|
}));
|
|
979
|
-
if (n <= 0) return /* @__PURE__ */
|
|
983
|
+
if (n <= 0) return /* @__PURE__ */ C(U, {
|
|
980
984
|
className: "local-visual-chart local-visual-chart-donut",
|
|
981
985
|
label: u,
|
|
982
986
|
children: [
|
|
983
|
-
/* @__PURE__ */
|
|
984
|
-
/* @__PURE__ */
|
|
985
|
-
/* @__PURE__ */
|
|
987
|
+
/* @__PURE__ */ S(W, { message: "暂无占比" }),
|
|
988
|
+
/* @__PURE__ */ S(Ne, { notes: x }),
|
|
989
|
+
/* @__PURE__ */ S(Pe, {
|
|
986
990
|
items: r,
|
|
987
991
|
hidden: i,
|
|
988
992
|
onToggle: P,
|
|
@@ -1002,45 +1006,45 @@ function je({ node: e, runtime: t }) {
|
|
|
1002
1006
|
value: o,
|
|
1003
1007
|
start: l,
|
|
1004
1008
|
end: u,
|
|
1005
|
-
color:
|
|
1009
|
+
color: I[r % I.length],
|
|
1006
1010
|
x: a,
|
|
1007
1011
|
y: 140
|
|
1008
1012
|
});
|
|
1009
1013
|
});
|
|
1010
|
-
let f = o ? `${o.label}:${
|
|
1011
|
-
return /* @__PURE__ */
|
|
1014
|
+
let f = o ? `${o.label}:${B(o.value)}` : "聚焦扇区或图例查看数值";
|
|
1015
|
+
return /* @__PURE__ */ C(U, {
|
|
1012
1016
|
className: "local-visual-chart local-visual-chart-donut",
|
|
1013
1017
|
label: u,
|
|
1014
1018
|
children: [
|
|
1015
|
-
/* @__PURE__ */
|
|
1019
|
+
/* @__PURE__ */ S("div", {
|
|
1016
1020
|
className: "local-visual-readout",
|
|
1017
1021
|
id: l,
|
|
1018
1022
|
"aria-live": "polite",
|
|
1019
1023
|
children: f
|
|
1020
1024
|
}),
|
|
1021
|
-
/* @__PURE__ */
|
|
1025
|
+
/* @__PURE__ */ S("div", {
|
|
1022
1026
|
className: "local-visual-svg-wrap",
|
|
1023
|
-
children: /* @__PURE__ */
|
|
1027
|
+
children: /* @__PURE__ */ C("svg", {
|
|
1024
1028
|
className: "local-visual-svg",
|
|
1025
1029
|
viewBox: `0 0 ${re} 290`,
|
|
1026
1030
|
role: "group",
|
|
1027
1031
|
"aria-label": `${u},环形图,共 ${M.length} 项`,
|
|
1028
1032
|
"aria-describedby": l,
|
|
1029
|
-
children: [/* @__PURE__ */
|
|
1033
|
+
children: [/* @__PURE__ */ C("g", {
|
|
1030
1034
|
className: "local-visual-donut-center",
|
|
1031
1035
|
"aria-hidden": "true",
|
|
1032
|
-
children: [/* @__PURE__ */
|
|
1036
|
+
children: [/* @__PURE__ */ S("text", {
|
|
1033
1037
|
x: a,
|
|
1034
1038
|
y: 138,
|
|
1035
1039
|
textAnchor: "middle",
|
|
1036
1040
|
className: "local-visual-donut-total",
|
|
1037
|
-
children:
|
|
1038
|
-
}), /* @__PURE__ */
|
|
1041
|
+
children: B(n)
|
|
1042
|
+
}), /* @__PURE__ */ S("text", {
|
|
1039
1043
|
x: a,
|
|
1040
1044
|
y: 158,
|
|
1041
1045
|
textAnchor: "middle",
|
|
1042
1046
|
className: "local-visual-donut-caption",
|
|
1043
|
-
children:
|
|
1047
|
+
children: ye(k[0], 14)
|
|
1044
1048
|
})]
|
|
1045
1049
|
}), d.map((e) => {
|
|
1046
1050
|
let t = {
|
|
@@ -1054,199 +1058,201 @@ function je({ node: e, runtime: t }) {
|
|
|
1054
1058
|
"data-chart-mark": "",
|
|
1055
1059
|
tabIndex: 0,
|
|
1056
1060
|
role: "img",
|
|
1057
|
-
"aria-label": `${e.label}:${
|
|
1061
|
+
"aria-label": `${e.label}:${B(e.value)}`,
|
|
1058
1062
|
onFocus: () => s(t),
|
|
1059
1063
|
onBlur: () => s(null),
|
|
1060
1064
|
onPointerEnter: () => s(t),
|
|
1061
1065
|
onPointerLeave: () => s(null),
|
|
1062
1066
|
onKeyDown: (e) => {
|
|
1063
|
-
e.key === "ArrowRight" || e.key === "ArrowDown" ?
|
|
1067
|
+
e.key === "ArrowRight" || e.key === "ArrowDown" ? Te(e, "[data-chart-mark]", 1) : (e.key === "ArrowLeft" || e.key === "ArrowUp") && Te(e, "[data-chart-mark]", -1);
|
|
1064
1068
|
}
|
|
1065
1069
|
};
|
|
1066
|
-
return e.end - e.start >= Math.PI * 2 - 1e-6 ? /* @__PURE__ */
|
|
1070
|
+
return e.end - e.start >= Math.PI * 2 - 1e-6 ? /* @__PURE__ */ S("circle", {
|
|
1067
1071
|
className: "local-visual-donut-slice",
|
|
1068
1072
|
cx: a,
|
|
1069
1073
|
cy: 140,
|
|
1070
1074
|
r: 78,
|
|
1071
1075
|
fill: "none",
|
|
1072
|
-
stroke: e.color,
|
|
1076
|
+
style: { stroke: e.color },
|
|
1073
1077
|
strokeWidth: 40,
|
|
1074
1078
|
...n,
|
|
1075
|
-
children: /* @__PURE__ */
|
|
1076
|
-
}, e.key) : /* @__PURE__ */
|
|
1079
|
+
children: /* @__PURE__ */ S("title", { children: `${e.label}:${B(e.value)}` })
|
|
1080
|
+
}, e.key) : /* @__PURE__ */ S("path", {
|
|
1077
1081
|
className: "local-visual-donut-slice",
|
|
1078
|
-
d:
|
|
1079
|
-
fill: e.color,
|
|
1082
|
+
d: Le(a, 140, 98, 58, e.start, e.end),
|
|
1083
|
+
style: { fill: e.color },
|
|
1080
1084
|
...n,
|
|
1081
|
-
children: /* @__PURE__ */
|
|
1085
|
+
children: /* @__PURE__ */ S("title", { children: `${e.label}:${B(e.value)}` })
|
|
1082
1086
|
}, e.key);
|
|
1083
1087
|
})]
|
|
1084
1088
|
})
|
|
1085
1089
|
}),
|
|
1086
|
-
/* @__PURE__ */
|
|
1090
|
+
/* @__PURE__ */ S(Pe, {
|
|
1087
1091
|
items: r,
|
|
1088
1092
|
hidden: i,
|
|
1089
1093
|
onToggle: P,
|
|
1090
1094
|
label: "图例,可开关扇区"
|
|
1091
1095
|
}),
|
|
1092
|
-
/* @__PURE__ */
|
|
1096
|
+
/* @__PURE__ */ S(Ne, { notes: x })
|
|
1093
1097
|
]
|
|
1094
1098
|
});
|
|
1095
1099
|
}
|
|
1096
|
-
let
|
|
1097
|
-
if (
|
|
1100
|
+
let ee = k.map((e, t) => t).filter((e) => !n.has(e));
|
|
1101
|
+
if (ee.length === 0) return /* @__PURE__ */ C(U, {
|
|
1098
1102
|
className: `local-visual-chart local-visual-chart-${f}`,
|
|
1099
1103
|
label: u,
|
|
1100
|
-
children: [/* @__PURE__ */
|
|
1101
|
-
items:
|
|
1104
|
+
children: [/* @__PURE__ */ S(W, { message: "所有系列已在图例中关闭" }), /* @__PURE__ */ S(Pe, {
|
|
1105
|
+
items: F,
|
|
1102
1106
|
hidden: n,
|
|
1103
1107
|
onToggle: N,
|
|
1104
1108
|
label: "图例,可开关系列"
|
|
1105
1109
|
})]
|
|
1106
1110
|
});
|
|
1107
|
-
let
|
|
1108
|
-
|
|
1109
|
-
let
|
|
1110
|
-
for (let e of
|
|
1111
|
+
let te = Me(_, E), ne = f === "scatter" ? !0 : f === "line" || f === "area" ? te : !1, ae = ne ? M.filter((e) => e.xValue !== null) : M;
|
|
1112
|
+
ne && ae.length < M.length && x.push(`${M.length - ae.length} 行横轴为空或不是数值,未参与绘制。`);
|
|
1113
|
+
let oe = [];
|
|
1114
|
+
for (let e of ae) for (let t of ee) {
|
|
1111
1115
|
let n = e.values[t];
|
|
1112
|
-
n !== null &&
|
|
1116
|
+
n !== null && oe.push(n);
|
|
1113
1117
|
}
|
|
1114
|
-
if (
|
|
1118
|
+
if (ae.length === 0) return /* @__PURE__ */ C(U, {
|
|
1115
1119
|
className: `local-visual-chart local-visual-chart-${f}`,
|
|
1116
1120
|
label: u,
|
|
1117
1121
|
children: [
|
|
1118
|
-
/* @__PURE__ */
|
|
1119
|
-
/* @__PURE__ */
|
|
1120
|
-
/* @__PURE__ */
|
|
1121
|
-
items:
|
|
1122
|
+
/* @__PURE__ */ S(W, { message: "没有可绘制的数据行" }),
|
|
1123
|
+
/* @__PURE__ */ S(Ne, { notes: x }),
|
|
1124
|
+
/* @__PURE__ */ S(Pe, {
|
|
1125
|
+
items: F,
|
|
1122
1126
|
hidden: n,
|
|
1123
1127
|
onToggle: N,
|
|
1124
1128
|
label: "图例,可开关系列"
|
|
1125
1129
|
})
|
|
1126
1130
|
]
|
|
1127
1131
|
});
|
|
1128
|
-
if (
|
|
1132
|
+
if (oe.length === 0) return /* @__PURE__ */ C(U, {
|
|
1129
1133
|
className: `local-visual-chart local-visual-chart-${f}`,
|
|
1130
1134
|
label: u,
|
|
1131
1135
|
children: [
|
|
1132
|
-
/* @__PURE__ */
|
|
1133
|
-
/* @__PURE__ */
|
|
1134
|
-
/* @__PURE__ */
|
|
1135
|
-
items:
|
|
1136
|
+
/* @__PURE__ */ S(W, { message: "没有可读取的数值" }),
|
|
1137
|
+
/* @__PURE__ */ S(Ne, { notes: x }),
|
|
1138
|
+
/* @__PURE__ */ S(Pe, {
|
|
1139
|
+
items: F,
|
|
1136
1140
|
hidden: n,
|
|
1137
1141
|
onToggle: N,
|
|
1138
1142
|
label: "图例,可开关系列"
|
|
1139
1143
|
})
|
|
1140
1144
|
]
|
|
1141
1145
|
});
|
|
1142
|
-
let
|
|
1143
|
-
if (
|
|
1146
|
+
let se = Ce(oe, f === "bar" || f === "area"), ce = Se(se.min, se.max, 5), L = we(ce, !!m), le = 506 - L, ue = (e) => 16 + (se.max - e) / (se.max - se.min) * 258, de = ue(Math.max(se.min, Math.min(se.max, 0))), R = ne && ae.length > 0 ? Ce(ae.map((e) => e.xValue).filter((e) => e !== null), !1) : null, z = le / Math.max(1, M.length), fe = (e) => L + z * (e + .5), pe = (e) => L + (e - R.min) / (R.max - R.min) * le, me = (e, t) => R ? e.xValue === null ? null : pe(e.xValue) : fe(t), V = [];
|
|
1147
|
+
if (R) V.push(...Se(R.min, R.max, 5));
|
|
1144
1148
|
else {
|
|
1145
1149
|
let e = Math.max(1, Math.ceil(M.length / 6));
|
|
1146
|
-
for (let t = 0; t < M.length; t += e)
|
|
1150
|
+
for (let t = 0; t < M.length; t += e) V.push(t);
|
|
1147
1151
|
let t = M.length - 1;
|
|
1148
|
-
t >= 0 &&
|
|
1152
|
+
t >= 0 && V[V.length - 1] !== t && (V.length > 1 && t - V[V.length - 1] < e * .6 ? V[V.length - 1] = t : V.push(t));
|
|
1149
1153
|
}
|
|
1150
|
-
let
|
|
1154
|
+
let ge = (e) => R ? L + (e - R.min) / (R.max - R.min) * le : fe(e), _e = o && !R ? null : o ? /* @__PURE__ */ S("line", {
|
|
1151
1155
|
className: "local-visual-guide",
|
|
1152
1156
|
x1: Math.max(L, Math.min(506, o.x)),
|
|
1153
1157
|
x2: Math.max(L, Math.min(506, o.x)),
|
|
1154
1158
|
y1: 16,
|
|
1155
1159
|
y2: 274
|
|
1156
|
-
}) : null,
|
|
1160
|
+
}) : null, ve = (e) => ({
|
|
1157
1161
|
"data-chart-mark": "",
|
|
1158
1162
|
tabIndex: 0,
|
|
1159
1163
|
role: "img",
|
|
1160
|
-
"aria-label": `${e.series},${e.label}:${
|
|
1164
|
+
"aria-label": `${e.series},${e.label}:${B(e.value)}`,
|
|
1161
1165
|
onFocus: () => s(e),
|
|
1162
1166
|
onBlur: () => s(null),
|
|
1163
1167
|
onPointerEnter: () => s(e),
|
|
1164
1168
|
onPointerLeave: () => s(null),
|
|
1165
1169
|
onKeyDown: (e) => {
|
|
1166
|
-
e.key === "ArrowRight" || e.key === "ArrowDown" ?
|
|
1170
|
+
e.key === "ArrowRight" || e.key === "ArrowDown" ? Te(e, "[data-chart-mark]", 1) : (e.key === "ArrowLeft" || e.key === "ArrowUp") && Te(e, "[data-chart-mark]", -1);
|
|
1167
1171
|
}
|
|
1168
|
-
}),
|
|
1172
|
+
}), be = (e, t, n, r, i) => ({
|
|
1169
1173
|
key: `${e}:${t.index}`,
|
|
1170
1174
|
series: k[e],
|
|
1171
1175
|
label: t.label,
|
|
1172
1176
|
value: n,
|
|
1173
1177
|
x: r,
|
|
1174
1178
|
y: i
|
|
1175
|
-
}),
|
|
1179
|
+
}), xe = [];
|
|
1176
1180
|
if (f === "bar") {
|
|
1177
|
-
let e =
|
|
1181
|
+
let e = z * .76, t = Math.max(1, e / Math.max(1, ee.length));
|
|
1178
1182
|
M.forEach((n, r) => {
|
|
1179
|
-
|
|
1183
|
+
ee.forEach((i, a) => {
|
|
1180
1184
|
let o = n.values[i];
|
|
1181
1185
|
if (o === null) return;
|
|
1182
|
-
let s = L +
|
|
1183
|
-
|
|
1186
|
+
let s = L + z * r + (z - e) / 2 + a * t, c = Math.max(1, Math.abs(ue(o) - de)), l = o >= 0 ? de - c : de, u = be(i, n, o, s + t / 2, l + c / 2);
|
|
1187
|
+
xe.push(/* @__PURE__ */ S("rect", {
|
|
1184
1188
|
className: "local-visual-bar",
|
|
1185
1189
|
x: s,
|
|
1186
1190
|
y: l,
|
|
1187
1191
|
width: Math.max(1.5, t - 1),
|
|
1188
1192
|
height: c,
|
|
1189
1193
|
rx: 2,
|
|
1190
|
-
fill:
|
|
1191
|
-
...
|
|
1192
|
-
children: /* @__PURE__ */
|
|
1194
|
+
style: { fill: I[i % I.length] },
|
|
1195
|
+
...ve(u),
|
|
1196
|
+
children: /* @__PURE__ */ S("title", { children: `${u.series},${u.label}:${B(u.value)}` })
|
|
1193
1197
|
}, `bar-${i}-${n.index}`));
|
|
1194
1198
|
});
|
|
1195
1199
|
});
|
|
1196
1200
|
}
|
|
1197
|
-
let
|
|
1198
|
-
if (f === "line" || f === "area") for (let e of
|
|
1201
|
+
let Ee = [], De = [], Oe = [];
|
|
1202
|
+
if (f === "line" || f === "area") for (let e of ee) {
|
|
1199
1203
|
let t = [], n = [], r = () => {
|
|
1200
1204
|
n.length > 0 && t.push(n), n = [];
|
|
1201
1205
|
};
|
|
1202
1206
|
M.forEach((t, i) => {
|
|
1203
|
-
let a = t.values[e], o =
|
|
1207
|
+
let a = t.values[e], o = me(t, i);
|
|
1204
1208
|
a === null || o === null ? r() : n.push({
|
|
1205
1209
|
row: t,
|
|
1206
1210
|
value: a,
|
|
1207
1211
|
x: o,
|
|
1208
|
-
y:
|
|
1212
|
+
y: ue(a)
|
|
1209
1213
|
});
|
|
1210
1214
|
}), r();
|
|
1211
1215
|
for (let n of t) {
|
|
1212
1216
|
if (n.length >= 2) {
|
|
1213
1217
|
let t = n.map((e, t) => `${t === 0 ? "M" : "L"} ${e.x} ${e.y}`).join(" ");
|
|
1214
|
-
if (
|
|
1218
|
+
if (Ee.push(/* @__PURE__ */ S("path", {
|
|
1215
1219
|
className: "local-visual-line",
|
|
1216
1220
|
d: t,
|
|
1217
1221
|
fill: "none",
|
|
1218
|
-
stroke:
|
|
1222
|
+
style: { stroke: I[e % I.length] },
|
|
1219
1223
|
strokeWidth: 2.4,
|
|
1220
1224
|
strokeLinejoin: "round",
|
|
1221
1225
|
strokeLinecap: "round"
|
|
1222
1226
|
}, `line-${e}-${n[0].row.index}`)), f === "area") {
|
|
1223
1227
|
let t = de, r = n[0], i = n[n.length - 1], a = `M ${r.x} ${t} ${n.map((e) => `L ${e.x} ${e.y}`).join(" ")} L ${i.x} ${t} Z`;
|
|
1224
|
-
|
|
1228
|
+
De.push(/* @__PURE__ */ S("path", {
|
|
1225
1229
|
className: "local-visual-area",
|
|
1226
1230
|
d: a,
|
|
1227
|
-
fill:
|
|
1231
|
+
style: { fill: I[e % I.length] }
|
|
1228
1232
|
}, `area-${e}-${r.row.index}`));
|
|
1229
1233
|
}
|
|
1230
1234
|
}
|
|
1231
1235
|
for (let t of n) {
|
|
1232
|
-
let n =
|
|
1233
|
-
|
|
1236
|
+
let n = be(e, t.row, t.value, t.x, t.y);
|
|
1237
|
+
Oe.push(/* @__PURE__ */ C("g", {
|
|
1234
1238
|
className: "local-visual-point-group",
|
|
1235
|
-
children: [/* @__PURE__ */
|
|
1239
|
+
children: [/* @__PURE__ */ S("circle", {
|
|
1236
1240
|
className: "local-visual-hit",
|
|
1237
1241
|
cx: t.x,
|
|
1238
1242
|
cy: t.y,
|
|
1239
1243
|
r: 12,
|
|
1240
1244
|
fill: "transparent",
|
|
1241
|
-
...
|
|
1242
|
-
children: /* @__PURE__ */
|
|
1243
|
-
}), /* @__PURE__ */
|
|
1245
|
+
...ve(n),
|
|
1246
|
+
children: /* @__PURE__ */ S("title", { children: `${n.series},${n.label}:${B(n.value)}` })
|
|
1247
|
+
}), /* @__PURE__ */ S("circle", {
|
|
1244
1248
|
className: "local-visual-point",
|
|
1245
1249
|
cx: t.x,
|
|
1246
1250
|
cy: t.y,
|
|
1247
1251
|
r: 4.5,
|
|
1248
|
-
|
|
1249
|
-
|
|
1252
|
+
style: {
|
|
1253
|
+
fill: I[e % I.length],
|
|
1254
|
+
stroke: "var(--surface)"
|
|
1255
|
+
},
|
|
1250
1256
|
strokeWidth: 1.5,
|
|
1251
1257
|
pointerEvents: "none"
|
|
1252
1258
|
})]
|
|
@@ -1255,132 +1261,134 @@ function je({ node: e, runtime: t }) {
|
|
|
1255
1261
|
}
|
|
1256
1262
|
}
|
|
1257
1263
|
f === "scatter" && M.forEach((e, t) => {
|
|
1258
|
-
let n =
|
|
1259
|
-
n !== null &&
|
|
1264
|
+
let n = me(e, t);
|
|
1265
|
+
n !== null && ee.forEach((t) => {
|
|
1260
1266
|
let r = e.values[t];
|
|
1261
1267
|
if (r === null) return;
|
|
1262
|
-
let i =
|
|
1263
|
-
|
|
1268
|
+
let i = ue(r), a = be(t, e, r, n, i);
|
|
1269
|
+
Oe.push(/* @__PURE__ */ C("g", {
|
|
1264
1270
|
className: "local-visual-point-group",
|
|
1265
|
-
children: [/* @__PURE__ */
|
|
1271
|
+
children: [/* @__PURE__ */ S("circle", {
|
|
1266
1272
|
className: "local-visual-hit",
|
|
1267
1273
|
cx: n,
|
|
1268
1274
|
cy: i,
|
|
1269
1275
|
r: 15,
|
|
1270
1276
|
fill: "transparent",
|
|
1271
|
-
...
|
|
1272
|
-
children: /* @__PURE__ */
|
|
1273
|
-
}), /* @__PURE__ */
|
|
1277
|
+
...ve(a),
|
|
1278
|
+
children: /* @__PURE__ */ S("title", { children: `${a.series},${a.label}:${B(a.value)}` })
|
|
1279
|
+
}), /* @__PURE__ */ S("circle", {
|
|
1274
1280
|
className: "local-visual-point",
|
|
1275
1281
|
cx: n,
|
|
1276
1282
|
cy: i,
|
|
1277
1283
|
r: 6,
|
|
1278
|
-
|
|
1279
|
-
|
|
1284
|
+
style: {
|
|
1285
|
+
fill: I[t % I.length],
|
|
1286
|
+
stroke: "var(--surface)"
|
|
1287
|
+
},
|
|
1280
1288
|
strokeWidth: 1.5,
|
|
1281
1289
|
pointerEvents: "none"
|
|
1282
1290
|
})]
|
|
1283
1291
|
}, `scatter-${t}-${e.index}`));
|
|
1284
1292
|
});
|
|
1285
1293
|
});
|
|
1286
|
-
let
|
|
1287
|
-
return /* @__PURE__ */
|
|
1294
|
+
let ke = o ? `${o.series} · ${o.label}:${B(o.value)}` : "聚焦或指向图形,用方向键切换读数", Fe = `${u},${f} 图,共 ${M.length} 项,${ee.length} 个系列`;
|
|
1295
|
+
return /* @__PURE__ */ C(U, {
|
|
1288
1296
|
className: `local-visual-chart local-visual-chart-${f}`,
|
|
1289
1297
|
label: u,
|
|
1290
1298
|
children: [
|
|
1291
|
-
/* @__PURE__ */
|
|
1299
|
+
/* @__PURE__ */ S("div", {
|
|
1292
1300
|
className: "local-visual-readout",
|
|
1293
1301
|
id: l,
|
|
1294
1302
|
"aria-live": "polite",
|
|
1295
|
-
children:
|
|
1303
|
+
children: ke
|
|
1296
1304
|
}),
|
|
1297
|
-
/* @__PURE__ */
|
|
1305
|
+
/* @__PURE__ */ S("div", {
|
|
1298
1306
|
className: "local-visual-svg-wrap",
|
|
1299
|
-
children: /* @__PURE__ */
|
|
1307
|
+
children: /* @__PURE__ */ C("svg", {
|
|
1300
1308
|
className: "local-visual-svg",
|
|
1301
1309
|
viewBox: `0 0 ${re} ${ie}`,
|
|
1302
1310
|
role: "group",
|
|
1303
|
-
"aria-label":
|
|
1311
|
+
"aria-label": Fe,
|
|
1304
1312
|
"aria-describedby": l,
|
|
1305
1313
|
children: [
|
|
1306
|
-
ce.map((e) => /* @__PURE__ */
|
|
1314
|
+
ce.map((e) => /* @__PURE__ */ C("g", { children: [/* @__PURE__ */ S("line", {
|
|
1307
1315
|
className: "local-visual-grid-line",
|
|
1308
1316
|
x1: L,
|
|
1309
1317
|
x2: 506,
|
|
1310
|
-
y1:
|
|
1311
|
-
y2:
|
|
1312
|
-
}), /* @__PURE__ */
|
|
1318
|
+
y1: ue(e),
|
|
1319
|
+
y2: ue(e)
|
|
1320
|
+
}), /* @__PURE__ */ S("text", {
|
|
1313
1321
|
className: "local-visual-axis-label",
|
|
1314
1322
|
x: L - 6,
|
|
1315
|
-
y:
|
|
1323
|
+
y: ue(e),
|
|
1316
1324
|
textAnchor: "end",
|
|
1317
1325
|
dominantBaseline: "middle",
|
|
1318
|
-
children:
|
|
1326
|
+
children: he(e)
|
|
1319
1327
|
})] }, `y-${e}`)),
|
|
1320
|
-
|
|
1328
|
+
se.min < 0 && se.max > 0 ? /* @__PURE__ */ S("line", {
|
|
1321
1329
|
className: "local-visual-zero-line",
|
|
1322
1330
|
x1: L,
|
|
1323
1331
|
x2: 506,
|
|
1324
1332
|
y1: de,
|
|
1325
1333
|
y2: de
|
|
1326
1334
|
}) : null,
|
|
1327
|
-
/* @__PURE__ */
|
|
1335
|
+
/* @__PURE__ */ S("line", {
|
|
1328
1336
|
className: "local-visual-axis-line",
|
|
1329
1337
|
x1: L,
|
|
1330
1338
|
x2: 506,
|
|
1331
1339
|
y1: 274,
|
|
1332
1340
|
y2: 274
|
|
1333
1341
|
}),
|
|
1334
|
-
|
|
1335
|
-
let t =
|
|
1336
|
-
return /* @__PURE__ */
|
|
1342
|
+
V.map((e) => {
|
|
1343
|
+
let t = ge(e), n = R ? he(e) : ye(M[e]?.label ?? "", 8);
|
|
1344
|
+
return /* @__PURE__ */ C("g", { children: [/* @__PURE__ */ S("line", {
|
|
1337
1345
|
className: "local-visual-tick",
|
|
1338
1346
|
x1: t,
|
|
1339
1347
|
x2: t,
|
|
1340
1348
|
y1: 274,
|
|
1341
1349
|
y2: 279
|
|
1342
|
-
}), /* @__PURE__ */
|
|
1350
|
+
}), /* @__PURE__ */ C("text", {
|
|
1343
1351
|
className: "local-visual-axis-label",
|
|
1344
1352
|
x: t,
|
|
1345
1353
|
y: 293,
|
|
1346
1354
|
textAnchor: "middle",
|
|
1347
|
-
children: [n, !
|
|
1355
|
+
children: [n, !R && M[e] ? /* @__PURE__ */ S("title", { children: M[e].label }) : null]
|
|
1348
1356
|
})] }, `x-${e}`);
|
|
1349
1357
|
}),
|
|
1350
|
-
p ? /* @__PURE__ */
|
|
1358
|
+
p ? /* @__PURE__ */ S("text", {
|
|
1351
1359
|
className: "local-visual-axis-title",
|
|
1352
1360
|
x: (L + 506) / 2,
|
|
1353
1361
|
y: 318,
|
|
1354
1362
|
textAnchor: "middle",
|
|
1355
1363
|
children: p
|
|
1356
1364
|
}) : null,
|
|
1357
|
-
|
|
1365
|
+
m ? /* @__PURE__ */ S("text", {
|
|
1358
1366
|
className: "local-visual-axis-title",
|
|
1359
1367
|
transform: "translate(12 145) rotate(-90)",
|
|
1360
1368
|
textAnchor: "middle",
|
|
1361
|
-
children:
|
|
1369
|
+
children: m
|
|
1362
1370
|
}) : null,
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1371
|
+
De,
|
|
1372
|
+
Ee,
|
|
1373
|
+
_e,
|
|
1374
|
+
xe,
|
|
1375
|
+
Oe
|
|
1368
1376
|
]
|
|
1369
1377
|
})
|
|
1370
1378
|
}),
|
|
1371
|
-
/* @__PURE__ */
|
|
1372
|
-
items:
|
|
1379
|
+
/* @__PURE__ */ S(Pe, {
|
|
1380
|
+
items: F,
|
|
1373
1381
|
hidden: n,
|
|
1374
1382
|
onToggle: N,
|
|
1375
1383
|
label: "图例,可开关系列"
|
|
1376
1384
|
}),
|
|
1377
|
-
/* @__PURE__ */
|
|
1385
|
+
/* @__PURE__ */ S(Ne, { notes: x })
|
|
1378
1386
|
]
|
|
1379
1387
|
});
|
|
1380
1388
|
}
|
|
1381
|
-
var
|
|
1382
|
-
function
|
|
1383
|
-
let n =
|
|
1389
|
+
var ze = /* @__PURE__ */ new WeakMap();
|
|
1390
|
+
function Be(e, t) {
|
|
1391
|
+
let n = ze.get(e);
|
|
1384
1392
|
return n && n.revision === t || (n = {
|
|
1385
1393
|
revision: t,
|
|
1386
1394
|
requestedPoints: /* @__PURE__ */ new Map(),
|
|
@@ -1389,10 +1397,10 @@ function Ne(e, t) {
|
|
|
1389
1397
|
limit: i
|
|
1390
1398
|
},
|
|
1391
1399
|
samples: /* @__PURE__ */ new Map()
|
|
1392
|
-
},
|
|
1400
|
+
}, ze.set(e, n)), n;
|
|
1393
1401
|
}
|
|
1394
|
-
function
|
|
1395
|
-
let p =
|
|
1402
|
+
function Ve(n, i, a, s, c, l, u, d, f) {
|
|
1403
|
+
let p = Be(d, f), m = p.samples.get(i);
|
|
1396
1404
|
if (m) return m;
|
|
1397
1405
|
let h = (e) => {
|
|
1398
1406
|
let t = {
|
|
@@ -1432,12 +1440,12 @@ function Pe(n, i, a, s, c, l, u, d, f) {
|
|
|
1432
1440
|
points: [],
|
|
1433
1441
|
endpoint: null,
|
|
1434
1442
|
error: e.message
|
|
1435
|
-
}) : (v.push(`曲线 ${n + 1}:无法计算(${
|
|
1443
|
+
}) : (v.push(`曲线 ${n + 1}:无法计算(${V(e)})。`), {
|
|
1436
1444
|
source: i,
|
|
1437
1445
|
expression: null,
|
|
1438
1446
|
points: [],
|
|
1439
1447
|
endpoint: null,
|
|
1440
|
-
error:
|
|
1448
|
+
error: V(e)
|
|
1441
1449
|
});
|
|
1442
1450
|
}
|
|
1443
1451
|
});
|
|
@@ -1449,12 +1457,12 @@ function Pe(n, i, a, s, c, l, u, d, f) {
|
|
|
1449
1457
|
};
|
|
1450
1458
|
return p.samples.set(i, x), x;
|
|
1451
1459
|
}
|
|
1452
|
-
function
|
|
1460
|
+
function He(e) {
|
|
1453
1461
|
if (e.length === 0) return 0;
|
|
1454
1462
|
let t = [...e].sort((e, t) => e - t), n = Math.floor(t.length / 2);
|
|
1455
1463
|
return t.length % 2 == 0 ? (t[n - 1] + t[n]) / 2 : t[n];
|
|
1456
1464
|
}
|
|
1457
|
-
function
|
|
1465
|
+
function Ue(e, t, n, r) {
|
|
1458
1466
|
let i = [], a = [], o = (e, i) => {
|
|
1459
1467
|
let a = Math.abs(i.y - e.y), o = e.y * i.y < 0 && Math.min(Math.abs(e.y), Math.abs(i.y)) > Math.max(1, n * 8), s = a > t * .8 && a > Math.max(r, 1e-9) * 10;
|
|
1460
1468
|
return o || s;
|
|
@@ -1472,277 +1480,271 @@ function Ie(e, t, n, r) {
|
|
|
1472
1480
|
}
|
|
1473
1481
|
return a.length > 0 && i.push(a), i;
|
|
1474
1482
|
}
|
|
1475
|
-
function
|
|
1476
|
-
let [n, r] =
|
|
1477
|
-
|
|
1483
|
+
function We({ node: e, runtime: t }) {
|
|
1484
|
+
let [n, r] = y(null), a = t.resetToken(e);
|
|
1485
|
+
h(() => {
|
|
1478
1486
|
r(null);
|
|
1479
1487
|
}, [a]);
|
|
1480
|
-
let o =
|
|
1488
|
+
let o = g(), s = H(t, e.attrs, "label", "") || "函数图", c = H(t, e.attrs, "x-label", "x"), l = H(t, e.attrs, "y-label", "y"), u = ge(t, e.attrs, "min", -10), d = ge(t, e.attrs, "max", 10), f = Math.min(2e3, Math.max(2, ve(t, e.attrs, "samples", 200))), p = (e.children ?? []).filter((e) => e.type === "math" || e.type === "inlineMath"), m = (() => {
|
|
1481
1489
|
try {
|
|
1482
1490
|
return { ...t.snapshot().state };
|
|
1483
1491
|
} catch {
|
|
1484
1492
|
return {};
|
|
1485
1493
|
}
|
|
1486
|
-
})(),
|
|
1494
|
+
})(), v = 0;
|
|
1487
1495
|
try {
|
|
1488
|
-
|
|
1496
|
+
v = t.snapshot().revision;
|
|
1489
1497
|
} catch {
|
|
1490
|
-
|
|
1498
|
+
v = 0;
|
|
1491
1499
|
}
|
|
1492
|
-
let b = p.map((e) => `${e.id}\u0000${e.value ?? ""}`).join(""),
|
|
1500
|
+
let b = p.map((e) => `${e.id}\u0000${e.value ?? ""}`).join(""), x = `${e.id}\u0000${u}\u0000${d}\u0000${f}\u0000${b}`, w = _(() => p.length === 0 || u === null || d === null || !(d > u) ? {
|
|
1493
1501
|
ok: !0,
|
|
1494
1502
|
curves: [],
|
|
1495
1503
|
notes: []
|
|
1496
|
-
} :
|
|
1497
|
-
|
|
1504
|
+
} : Ve(e.id, x, p, m, u, d, f, t, v), [
|
|
1505
|
+
x,
|
|
1498
1506
|
e.id,
|
|
1499
|
-
|
|
1507
|
+
v,
|
|
1500
1508
|
t
|
|
1501
1509
|
]);
|
|
1502
|
-
if (p.length === 0) return /* @__PURE__ */
|
|
1510
|
+
if (p.length === 0) return /* @__PURE__ */ S(U, {
|
|
1503
1511
|
className: "local-visual-plot",
|
|
1504
1512
|
label: s,
|
|
1505
|
-
children: /* @__PURE__ */
|
|
1513
|
+
children: /* @__PURE__ */ S(W, {
|
|
1506
1514
|
message: "plot 正文需要一个或多个 $$ 公式块。",
|
|
1507
1515
|
kind: "alert"
|
|
1508
1516
|
})
|
|
1509
1517
|
});
|
|
1510
|
-
if (u === null || d === null || !(d > u)) return /* @__PURE__ */
|
|
1518
|
+
if (u === null || d === null || !(d > u)) return /* @__PURE__ */ S(U, {
|
|
1511
1519
|
className: "local-visual-plot",
|
|
1512
1520
|
label: s,
|
|
1513
|
-
children: /* @__PURE__ */
|
|
1521
|
+
children: /* @__PURE__ */ S(W, {
|
|
1514
1522
|
message: "plot 的 min 必须小于 max。",
|
|
1515
1523
|
kind: "alert"
|
|
1516
1524
|
})
|
|
1517
1525
|
});
|
|
1518
|
-
if (!w.ok) return /* @__PURE__ */
|
|
1526
|
+
if (!w.ok) return /* @__PURE__ */ S(U, {
|
|
1519
1527
|
className: "local-visual-plot",
|
|
1520
1528
|
label: s,
|
|
1521
|
-
children: /* @__PURE__ */
|
|
1529
|
+
children: /* @__PURE__ */ S(W, {
|
|
1522
1530
|
message: w.message,
|
|
1523
1531
|
kind: "alert"
|
|
1524
1532
|
})
|
|
1525
1533
|
});
|
|
1526
|
-
let { curves: T, notes: E } = w, D = T.flatMap((e) => e.points.filter((e) => e.y !== null && Number.isFinite(e.y))), O = /* @__PURE__ */
|
|
1534
|
+
let { curves: T, notes: E } = w, D = T.flatMap((e) => e.points.filter((e) => e.y !== null && Number.isFinite(e.y))), O = /* @__PURE__ */ S("div", {
|
|
1527
1535
|
className: "local-visual-plot-legend",
|
|
1528
1536
|
role: "list",
|
|
1529
1537
|
"aria-label": "曲线图例",
|
|
1530
|
-
children: T.map((e, t) => /* @__PURE__ */
|
|
1538
|
+
children: T.map((e, t) => /* @__PURE__ */ C("div", {
|
|
1531
1539
|
className: "local-visual-plot-legend-item",
|
|
1532
1540
|
role: "listitem",
|
|
1533
|
-
children: [/* @__PURE__ */
|
|
1541
|
+
children: [/* @__PURE__ */ S("span", {
|
|
1534
1542
|
className: "local-visual-swatch",
|
|
1535
|
-
style: { backgroundColor:
|
|
1543
|
+
style: { backgroundColor: I[t % I.length] },
|
|
1536
1544
|
"aria-hidden": "true"
|
|
1537
1545
|
}), /* @__PURE__ */ S("span", {
|
|
1538
1546
|
className: "local-visual-plot-legend-text",
|
|
1539
|
-
children:
|
|
1547
|
+
children: /* @__PURE__ */ S("span", {
|
|
1540
1548
|
className: "local-visual-plot-formula",
|
|
1541
|
-
children: /* @__PURE__ */
|
|
1542
|
-
})
|
|
1543
|
-
className: "local-visual-endpoint",
|
|
1544
|
-
children: [
|
|
1545
|
-
"终点 x = ",
|
|
1546
|
-
R(d),
|
|
1547
|
-
":",
|
|
1548
|
-
e.error ? "无法计算" : e.endpoint === null ? "无定义" : R(e.endpoint)
|
|
1549
|
-
]
|
|
1550
|
-
})]
|
|
1549
|
+
children: /* @__PURE__ */ S(ne, { source: e.source })
|
|
1550
|
+
})
|
|
1551
1551
|
})]
|
|
1552
1552
|
}, `curve-legend-${t}`))
|
|
1553
1553
|
});
|
|
1554
|
-
if (D.length === 0) return /* @__PURE__ */
|
|
1554
|
+
if (D.length === 0) return /* @__PURE__ */ C(U, {
|
|
1555
1555
|
className: "local-visual-plot",
|
|
1556
1556
|
label: s,
|
|
1557
1557
|
children: [
|
|
1558
|
-
/* @__PURE__ */
|
|
1559
|
-
/* @__PURE__ */
|
|
1558
|
+
/* @__PURE__ */ S(W, { message: "当前范围内没有可绘制的值" }),
|
|
1559
|
+
/* @__PURE__ */ S(Ne, { notes: E }),
|
|
1560
1560
|
O
|
|
1561
1561
|
]
|
|
1562
1562
|
});
|
|
1563
|
-
let k =
|
|
1563
|
+
let k = Ce(D.map((e) => e.y), !1), A = Se(k.min, k.max, 5), j = Se(u, d, 5), M = we(A, !!l), N = 506 - M, P = (e) => M + (e - u) / (d - u) * N, F = (e) => 16 + (k.max - e) / (k.max - k.min) * 258, ee = He(D.map((e) => Math.abs(e.y))), te = [];
|
|
1564
1564
|
for (let e of T) for (let t = 1; t < e.points.length; t += 1) {
|
|
1565
1565
|
let n = e.points[t - 1], r = e.points[t];
|
|
1566
|
-
n.y !== null && r.y !== null &&
|
|
1566
|
+
n.y !== null && r.y !== null && te.push(Math.abs(r.y - n.y));
|
|
1567
1567
|
}
|
|
1568
|
-
let
|
|
1568
|
+
let re = He(te), ie = k.max - k.min, se = T.map((e) => Ue(e.points, ie, ee, re)), ce = {
|
|
1569
1569
|
steps: 0,
|
|
1570
1570
|
limit: i
|
|
1571
1571
|
}, L = (e, t) => {
|
|
1572
1572
|
if (!e.expression) return null;
|
|
1573
1573
|
try {
|
|
1574
|
-
let n = e.expression.evaluate(t,
|
|
1574
|
+
let n = e.expression.evaluate(t, m, ce);
|
|
1575
1575
|
return typeof n == "number" && Number.isFinite(n) ? n : null;
|
|
1576
1576
|
} catch {
|
|
1577
1577
|
return null;
|
|
1578
1578
|
}
|
|
1579
|
-
}, le = (e) => Math.max(u, Math.min(d, e)),
|
|
1579
|
+
}, le = (e) => Math.max(u, Math.min(d, e)), ue = (d - u) / 100, de = (e) => {
|
|
1580
1580
|
let t = e.currentTarget.getBoundingClientRect();
|
|
1581
1581
|
if (t.width === 0) return;
|
|
1582
1582
|
let n = Math.max(0, Math.min(1, (e.clientX - t.left) / t.width));
|
|
1583
1583
|
r(u + n * (d - u));
|
|
1584
|
-
},
|
|
1584
|
+
}, R = (e) => {
|
|
1585
1585
|
let t = e.shiftKey ? 10 : 1, i = n;
|
|
1586
|
-
if (e.key === "ArrowRight") i = (n ?? (u + d) / 2) +
|
|
1587
|
-
else if (e.key === "ArrowLeft") i = (n ?? (u + d) / 2) -
|
|
1586
|
+
if (e.key === "ArrowRight") i = (n ?? (u + d) / 2) + ue * t;
|
|
1587
|
+
else if (e.key === "ArrowLeft") i = (n ?? (u + d) / 2) - ue * t;
|
|
1588
1588
|
else if (e.key === "Home") i = u;
|
|
1589
1589
|
else if (e.key === "End") i = d;
|
|
1590
1590
|
else return;
|
|
1591
1591
|
e.preventDefault(), r(le(i));
|
|
1592
|
-
},
|
|
1593
|
-
let n = L(e,
|
|
1594
|
-
return `曲线 ${t + 1}:${e.error ? "无法计算" : n === null ? "无定义" :
|
|
1595
|
-
}).join(";")}`,
|
|
1596
|
-
let n = L(e,
|
|
1597
|
-
return n === null || !e.expression ? null : /* @__PURE__ */
|
|
1592
|
+
}, z = n === null ? null : le(n), fe = z === null ? `区间 [${B(u)}, ${B(d)}] · ${f} 个采样点;用方向键或指针读取数值` : `x = ${B(z)};${T.map((e, t) => {
|
|
1593
|
+
let n = L(e, z);
|
|
1594
|
+
return `曲线 ${t + 1}:${e.error ? "无法计算" : n === null ? "无定义" : B(n)}`;
|
|
1595
|
+
}).join(";")}`, pe = z === null ? null : T.map((e, t) => {
|
|
1596
|
+
let n = L(e, z);
|
|
1597
|
+
return n === null || !e.expression ? null : /* @__PURE__ */ S("circle", {
|
|
1598
1598
|
className: "local-visual-active-point",
|
|
1599
|
-
cx: P(
|
|
1600
|
-
cy:
|
|
1599
|
+
cx: P(z),
|
|
1600
|
+
cy: F(n),
|
|
1601
1601
|
r: 4.5,
|
|
1602
|
-
|
|
1603
|
-
|
|
1602
|
+
style: {
|
|
1603
|
+
fill: I[t % I.length],
|
|
1604
|
+
stroke: "var(--surface)"
|
|
1605
|
+
},
|
|
1604
1606
|
strokeWidth: 1.5
|
|
1605
1607
|
}, `active-${t}`);
|
|
1606
1608
|
});
|
|
1607
|
-
return /* @__PURE__ */
|
|
1609
|
+
return /* @__PURE__ */ C(U, {
|
|
1608
1610
|
className: "local-visual-plot",
|
|
1609
1611
|
label: s,
|
|
1610
1612
|
children: [
|
|
1611
|
-
/* @__PURE__ */
|
|
1613
|
+
/* @__PURE__ */ S("div", {
|
|
1612
1614
|
className: "local-visual-readout",
|
|
1613
1615
|
id: o,
|
|
1614
1616
|
"aria-live": "polite",
|
|
1615
|
-
children:
|
|
1617
|
+
children: fe
|
|
1616
1618
|
}),
|
|
1617
|
-
/* @__PURE__ */
|
|
1619
|
+
/* @__PURE__ */ S("div", {
|
|
1618
1620
|
className: "local-visual-svg-wrap",
|
|
1619
|
-
children: /* @__PURE__ */
|
|
1621
|
+
children: /* @__PURE__ */ C("svg", {
|
|
1620
1622
|
className: "local-visual-svg",
|
|
1621
1623
|
viewBox: `0 0 ${ae} ${oe}`,
|
|
1622
1624
|
role: "group",
|
|
1623
|
-
"aria-label": `${s},区间 ${
|
|
1625
|
+
"aria-label": `${s},区间 ${B(u)} 到 ${B(d)},${f} 个采样点`,
|
|
1624
1626
|
"aria-describedby": o,
|
|
1625
1627
|
tabIndex: 0,
|
|
1626
|
-
onPointerMove:
|
|
1628
|
+
onPointerMove: de,
|
|
1627
1629
|
onPointerLeave: () => r(null),
|
|
1628
1630
|
onFocus: () => r((e) => e ?? (u + d) / 2),
|
|
1629
1631
|
onBlur: () => r(null),
|
|
1630
|
-
onKeyDown:
|
|
1632
|
+
onKeyDown: R,
|
|
1631
1633
|
children: [
|
|
1632
|
-
A.map((e) => /* @__PURE__ */
|
|
1634
|
+
A.map((e) => /* @__PURE__ */ C("g", { children: [/* @__PURE__ */ S("line", {
|
|
1633
1635
|
className: "local-visual-grid-line",
|
|
1634
1636
|
x1: M,
|
|
1635
1637
|
x2: 506,
|
|
1636
|
-
y1:
|
|
1637
|
-
y2:
|
|
1638
|
-
}), /* @__PURE__ */
|
|
1638
|
+
y1: F(e),
|
|
1639
|
+
y2: F(e)
|
|
1640
|
+
}), /* @__PURE__ */ S("text", {
|
|
1639
1641
|
className: "local-visual-axis-label",
|
|
1640
1642
|
x: M - 6,
|
|
1641
|
-
y:
|
|
1643
|
+
y: F(e),
|
|
1642
1644
|
textAnchor: "end",
|
|
1643
1645
|
dominantBaseline: "middle",
|
|
1644
|
-
children:
|
|
1646
|
+
children: he(e)
|
|
1645
1647
|
})] }, `y-${e}`)),
|
|
1646
|
-
k.min < 0 && k.max > 0 ? /* @__PURE__ */
|
|
1648
|
+
k.min < 0 && k.max > 0 ? /* @__PURE__ */ S("line", {
|
|
1647
1649
|
className: "local-visual-zero-line",
|
|
1648
1650
|
x1: M,
|
|
1649
1651
|
x2: 506,
|
|
1650
|
-
y1:
|
|
1651
|
-
y2:
|
|
1652
|
+
y1: F(0),
|
|
1653
|
+
y2: F(0)
|
|
1652
1654
|
}) : null,
|
|
1653
|
-
/* @__PURE__ */
|
|
1655
|
+
/* @__PURE__ */ S("line", {
|
|
1654
1656
|
className: "local-visual-axis-line",
|
|
1655
1657
|
x1: M,
|
|
1656
1658
|
x2: 506,
|
|
1657
1659
|
y1: 274,
|
|
1658
1660
|
y2: 274
|
|
1659
1661
|
}),
|
|
1660
|
-
j.map((e) => /* @__PURE__ */
|
|
1662
|
+
j.map((e) => /* @__PURE__ */ C("g", { children: [/* @__PURE__ */ S("line", {
|
|
1661
1663
|
className: "local-visual-tick",
|
|
1662
1664
|
x1: P(e),
|
|
1663
1665
|
x2: P(e),
|
|
1664
1666
|
y1: 274,
|
|
1665
1667
|
y2: 279
|
|
1666
|
-
}), /* @__PURE__ */
|
|
1668
|
+
}), /* @__PURE__ */ S("text", {
|
|
1667
1669
|
className: "local-visual-axis-label",
|
|
1668
1670
|
x: P(e),
|
|
1669
1671
|
y: 293,
|
|
1670
1672
|
textAnchor: "middle",
|
|
1671
|
-
children:
|
|
1673
|
+
children: he(e)
|
|
1672
1674
|
})] }, `x-${e}`)),
|
|
1673
|
-
c ? /* @__PURE__ */
|
|
1675
|
+
c ? /* @__PURE__ */ S("text", {
|
|
1674
1676
|
className: "local-visual-axis-title",
|
|
1675
1677
|
x: (M + 506) / 2,
|
|
1676
1678
|
y: 318,
|
|
1677
1679
|
textAnchor: "middle",
|
|
1678
1680
|
children: c
|
|
1679
1681
|
}) : null,
|
|
1680
|
-
l ? /* @__PURE__ */
|
|
1682
|
+
l ? /* @__PURE__ */ S("text", {
|
|
1681
1683
|
className: "local-visual-axis-title",
|
|
1682
1684
|
transform: "translate(12 145) rotate(-90)",
|
|
1683
1685
|
textAnchor: "middle",
|
|
1684
1686
|
children: l
|
|
1685
1687
|
}) : null,
|
|
1686
|
-
|
|
1688
|
+
se.map((e, t) => e.map((e, n) => {
|
|
1687
1689
|
if (e.length < 2) return null;
|
|
1688
|
-
let r = e.map((e, t) => `${t === 0 ? "M" : "L"} ${P(e.x)} ${
|
|
1689
|
-
return /* @__PURE__ */
|
|
1690
|
+
let r = e.map((e, t) => `${t === 0 ? "M" : "L"} ${P(e.x)} ${F(e.y)}`).join(" ");
|
|
1691
|
+
return /* @__PURE__ */ S("path", {
|
|
1690
1692
|
className: "local-visual-plot-line",
|
|
1691
1693
|
d: r,
|
|
1692
1694
|
fill: "none",
|
|
1693
|
-
stroke:
|
|
1695
|
+
style: { stroke: I[t % I.length] },
|
|
1694
1696
|
strokeWidth: 2.4,
|
|
1695
1697
|
strokeLinejoin: "round",
|
|
1696
1698
|
strokeLinecap: "round"
|
|
1697
1699
|
}, `curve-${t}-${n}`);
|
|
1698
1700
|
})),
|
|
1699
|
-
|
|
1701
|
+
z === null ? null : /* @__PURE__ */ S("line", {
|
|
1700
1702
|
className: "local-visual-guide",
|
|
1701
|
-
x1: P(
|
|
1702
|
-
x2: P(
|
|
1703
|
+
x1: P(z),
|
|
1704
|
+
x2: P(z),
|
|
1703
1705
|
y1: 16,
|
|
1704
1706
|
y2: 274
|
|
1705
1707
|
}),
|
|
1706
|
-
|
|
1708
|
+
pe
|
|
1707
1709
|
]
|
|
1708
1710
|
})
|
|
1709
1711
|
}),
|
|
1710
|
-
/* @__PURE__ */
|
|
1712
|
+
/* @__PURE__ */ S(Ne, { notes: E }),
|
|
1711
1713
|
O
|
|
1712
1714
|
]
|
|
1713
1715
|
});
|
|
1714
1716
|
}
|
|
1715
|
-
function
|
|
1716
|
-
let [r, i] =
|
|
1717
|
-
|
|
1717
|
+
function Ge({ node: e, runtime: t, render: n }) {
|
|
1718
|
+
let [r, i] = y(null), a = t.resetToken(e);
|
|
1719
|
+
h(() => {
|
|
1718
1720
|
i(null);
|
|
1719
1721
|
}, [a]);
|
|
1720
|
-
let o =
|
|
1721
|
-
if (!c) return /* @__PURE__ */
|
|
1722
|
+
let o = H(t, e.attrs, "title", "") || "时间轴", s = H(t, e.attrs, "unit", "分钟"), c = je(e, t);
|
|
1723
|
+
if (!c) return /* @__PURE__ */ S(U, {
|
|
1722
1724
|
className: "local-visual-timeline",
|
|
1723
1725
|
label: o,
|
|
1724
|
-
children: /* @__PURE__ */
|
|
1726
|
+
children: /* @__PURE__ */ S(W, {
|
|
1725
1727
|
message: "timeline 正文需要一个 Markdown 表格。",
|
|
1726
1728
|
kind: "alert"
|
|
1727
1729
|
})
|
|
1728
1730
|
});
|
|
1729
1731
|
let l = c.headerText.map((e) => e.trim()), u = l.indexOf("事项"), d = l.indexOf("开始"), f = l.indexOf("时长"), p = l.indexOf("说明");
|
|
1730
|
-
if (u < 0 || d < 0 || f < 0) return /* @__PURE__ */
|
|
1732
|
+
if (u < 0 || d < 0 || f < 0) return /* @__PURE__ */ S(U, {
|
|
1731
1733
|
className: "local-visual-timeline",
|
|
1732
1734
|
label: o,
|
|
1733
|
-
children: /* @__PURE__ */
|
|
1735
|
+
children: /* @__PURE__ */ S(W, {
|
|
1734
1736
|
message: "timeline 表格需要“事项”“开始”“时长”三列。",
|
|
1735
1737
|
kind: "alert"
|
|
1736
1738
|
})
|
|
1737
1739
|
});
|
|
1738
|
-
let
|
|
1740
|
+
let m = [], g = [], _ = [];
|
|
1739
1741
|
if (c.rows.forEach((e, t) => {
|
|
1740
1742
|
let n = e.cells[d], r = e.cells[f], i = n?.numeric ?? null, a = r?.numeric ?? null;
|
|
1741
1743
|
if (i === null || a === null || i < 0 || a < 0) {
|
|
1742
1744
|
g.push(t + 1);
|
|
1743
1745
|
return;
|
|
1744
1746
|
}
|
|
1745
|
-
let o =
|
|
1747
|
+
let o = Ae(e.cells[u]) || `事项 ${t + 1}`;
|
|
1746
1748
|
_.push({
|
|
1747
1749
|
key: `item-${e.index}`,
|
|
1748
1750
|
title: o,
|
|
@@ -1751,19 +1753,19 @@ function Re({ node: e, runtime: t, render: n }) {
|
|
|
1751
1753
|
description: p >= 0 ? e.cells[p]?.children ?? [] : [],
|
|
1752
1754
|
sourceIndex: t
|
|
1753
1755
|
});
|
|
1754
|
-
}), g.length > 0 &&
|
|
1756
|
+
}), g.length > 0 && m.push(`第 ${g.join("、")} 行的开始或时长不是非负数字,未显示。`), _.length === 0) return /* @__PURE__ */ C(U, {
|
|
1755
1757
|
className: "local-visual-timeline",
|
|
1756
1758
|
label: o,
|
|
1757
|
-
children: [/* @__PURE__ */
|
|
1759
|
+
children: [/* @__PURE__ */ S(W, { message: "没有有效的时间轴事项。" }), /* @__PURE__ */ S(Ne, { notes: m })]
|
|
1758
1760
|
});
|
|
1759
|
-
let
|
|
1761
|
+
let v = [..._].sort((e, t) => e.start - t.start || e.sourceIndex - t.sourceIndex), b = v.reduce((e, t) => Math.max(e, t.start + t.duration), 0), w = Math.max(1, b), T = Se(0, w, 5);
|
|
1760
1762
|
(T.length === 0 || T[0] !== 0) && T.unshift(0), T[T.length - 1] < w && T.push(w);
|
|
1761
|
-
let E = s ? ` ${s}` : "", D = (e) => `${
|
|
1762
|
-
return /* @__PURE__ */
|
|
1763
|
+
let E = s ? ` ${s}` : "", D = (e) => `${B(e)}${E}`, O = v.find((e) => e.key === r) ?? null;
|
|
1764
|
+
return /* @__PURE__ */ C(U, {
|
|
1763
1765
|
className: "local-visual-timeline",
|
|
1764
1766
|
label: o,
|
|
1765
1767
|
children: [
|
|
1766
|
-
/* @__PURE__ */
|
|
1768
|
+
/* @__PURE__ */ S("div", {
|
|
1767
1769
|
className: "local-visual-timeline-axis",
|
|
1768
1770
|
"aria-hidden": "true",
|
|
1769
1771
|
children: T.map((e, t) => {
|
|
@@ -1774,18 +1776,18 @@ function Re({ node: e, runtime: t, render: n }) {
|
|
|
1774
1776
|
left: `${n}%`,
|
|
1775
1777
|
transform: "translateX(-50%)"
|
|
1776
1778
|
};
|
|
1777
|
-
return /* @__PURE__ */
|
|
1779
|
+
return /* @__PURE__ */ S("span", {
|
|
1778
1780
|
className: "local-visual-timeline-tick",
|
|
1779
1781
|
style: r,
|
|
1780
|
-
children:
|
|
1782
|
+
children: he(e)
|
|
1781
1783
|
}, `tick-${e}`);
|
|
1782
1784
|
})
|
|
1783
1785
|
}),
|
|
1784
|
-
/* @__PURE__ */
|
|
1786
|
+
/* @__PURE__ */ S("ol", {
|
|
1785
1787
|
className: "local-visual-timeline-list",
|
|
1786
|
-
children:
|
|
1787
|
-
let t = e.start + e.duration, n = e.start / w * 100, a = e.duration / w * 100, o =
|
|
1788
|
-
return /* @__PURE__ */
|
|
1788
|
+
children: v.map((e) => {
|
|
1789
|
+
let t = e.start + e.duration, n = e.start / w * 100, a = e.duration / w * 100, o = v.indexOf(e);
|
|
1790
|
+
return /* @__PURE__ */ C("li", {
|
|
1789
1791
|
className: `local-visual-timeline-item${r === e.key ? " is-active" : ""}`,
|
|
1790
1792
|
tabIndex: 0,
|
|
1791
1793
|
"aria-label": `${e.title},开始 ${D(e.start)},结束 ${D(t)},时长 ${D(e.duration)}${e.description.length > 0 ? ",有说明" : ""}`,
|
|
@@ -1796,16 +1798,16 @@ function Re({ node: e, runtime: t, render: n }) {
|
|
|
1796
1798
|
onKeyDown: (e) => {
|
|
1797
1799
|
e.key === "Escape" && (e.preventDefault(), i(null));
|
|
1798
1800
|
},
|
|
1799
|
-
children: [/* @__PURE__ */
|
|
1801
|
+
children: [/* @__PURE__ */ C("div", {
|
|
1800
1802
|
className: "local-visual-timeline-head",
|
|
1801
|
-
children: [/* @__PURE__ */
|
|
1803
|
+
children: [/* @__PURE__ */ C("span", {
|
|
1802
1804
|
className: "local-visual-timeline-title",
|
|
1803
|
-
children: [/* @__PURE__ */
|
|
1805
|
+
children: [/* @__PURE__ */ S("span", {
|
|
1804
1806
|
className: "local-visual-swatch",
|
|
1805
|
-
style: { backgroundColor:
|
|
1807
|
+
style: { backgroundColor: I[o % I.length] },
|
|
1806
1808
|
"aria-hidden": "true"
|
|
1807
1809
|
}), e.title]
|
|
1808
|
-
}), /* @__PURE__ */
|
|
1810
|
+
}), /* @__PURE__ */ C("span", {
|
|
1809
1811
|
className: "local-visual-timeline-times",
|
|
1810
1812
|
children: [
|
|
1811
1813
|
"开始 ",
|
|
@@ -1817,31 +1819,93 @@ function Re({ node: e, runtime: t, render: n }) {
|
|
|
1817
1819
|
D(e.duration)
|
|
1818
1820
|
]
|
|
1819
1821
|
})]
|
|
1820
|
-
}), /* @__PURE__ */
|
|
1822
|
+
}), /* @__PURE__ */ S("div", {
|
|
1821
1823
|
className: "local-visual-timeline-track",
|
|
1822
1824
|
"aria-hidden": "true",
|
|
1823
|
-
children: /* @__PURE__ */
|
|
1825
|
+
children: /* @__PURE__ */ S("span", {
|
|
1824
1826
|
className: `local-visual-timeline-bar${e.duration === 0 ? " is-zero" : ""}`,
|
|
1825
1827
|
style: {
|
|
1826
1828
|
left: `${n}%`,
|
|
1827
1829
|
width: `${a}%`,
|
|
1828
|
-
backgroundColor:
|
|
1830
|
+
backgroundColor: I[o % I.length]
|
|
1829
1831
|
}
|
|
1830
1832
|
})
|
|
1831
1833
|
})]
|
|
1832
1834
|
}, e.key);
|
|
1833
1835
|
})
|
|
1834
1836
|
}),
|
|
1835
|
-
/* @__PURE__ */
|
|
1837
|
+
/* @__PURE__ */ S("div", {
|
|
1836
1838
|
className: "local-visual-timeline-detail",
|
|
1837
1839
|
"aria-live": "polite",
|
|
1838
|
-
children: O ? /* @__PURE__ */
|
|
1840
|
+
children: O ? /* @__PURE__ */ C(x, { children: [/* @__PURE__ */ S("strong", { children: O.title }), O.description.length > 0 ? n(O.description) : /* @__PURE__ */ S("span", { children: "没有说明。" })] }) : /* @__PURE__ */ S("span", { children: "聚焦或指向事项查看说明。" })
|
|
1839
1841
|
}),
|
|
1840
|
-
/* @__PURE__ */
|
|
1842
|
+
/* @__PURE__ */ S(Ne, { notes: m })
|
|
1841
1843
|
]
|
|
1842
1844
|
});
|
|
1843
1845
|
}
|
|
1844
|
-
|
|
1846
|
+
var Ke = /[\u1100-\u115f\u2e80-\u303f\u3040-\u33ff\u3400-\u4dbf\u4e00-\u9fff\uac00-\ud7af\uf900-\ufaff\ufe30-\ufe4f\uff00-\uff60\uffe0-\uffe6]/u;
|
|
1847
|
+
function qe(e) {
|
|
1848
|
+
let t = 0;
|
|
1849
|
+
for (let n of e) Ke.test(n) ? t += 1 : /\s/u.test(n) ? t += .3 : t += .58;
|
|
1850
|
+
return t * ue;
|
|
1851
|
+
}
|
|
1852
|
+
function Je(e, t) {
|
|
1853
|
+
if (qe(e) <= t) return e;
|
|
1854
|
+
let n = "";
|
|
1855
|
+
for (let r of e) {
|
|
1856
|
+
if (qe(`${n}${r}…`) > t) break;
|
|
1857
|
+
n += r;
|
|
1858
|
+
}
|
|
1859
|
+
return `${n.trimEnd()}…`;
|
|
1860
|
+
}
|
|
1861
|
+
function Ye(e) {
|
|
1862
|
+
let t = [], n = "";
|
|
1863
|
+
for (let r of e) n && qe(n + r) > R ? (t.push(n), n = r) : n += r;
|
|
1864
|
+
if (n && t.push(n), t.length <= z) return t;
|
|
1865
|
+
let r = t.slice(0, z);
|
|
1866
|
+
return r[1] = Je(t.slice(1).join(""), R), r;
|
|
1867
|
+
}
|
|
1868
|
+
function Xe(e) {
|
|
1869
|
+
let t = Ye(e);
|
|
1870
|
+
return {
|
|
1871
|
+
width: t.reduce((e, t) => Math.max(e, qe(t)), 0) + 10,
|
|
1872
|
+
height: t.length * fe + 6,
|
|
1873
|
+
lines: t
|
|
1874
|
+
};
|
|
1875
|
+
}
|
|
1876
|
+
function Ze(e) {
|
|
1877
|
+
let t = /* @__PURE__ */ new Map();
|
|
1878
|
+
for (let n of e) {
|
|
1879
|
+
let e = `${n.from}\u0000${n.to}`;
|
|
1880
|
+
t.set(e, (t.get(e) ?? 0) + 1);
|
|
1881
|
+
}
|
|
1882
|
+
let n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map();
|
|
1883
|
+
for (let i of e) {
|
|
1884
|
+
let e = `${i.from}\u0000${i.to}`, a = t.get(e) ?? 1, o = n.get(e) ?? 0;
|
|
1885
|
+
n.set(e, o + 1), r.set(i.key, (o - (a - 1) / 2) * 12);
|
|
1886
|
+
}
|
|
1887
|
+
return r;
|
|
1888
|
+
}
|
|
1889
|
+
function Qe(e, t, n) {
|
|
1890
|
+
let { width: r, height: i, positions: a } = e, o = Ze(t), s = Infinity, c = Infinity, l = -Infinity, u = -Infinity;
|
|
1891
|
+
for (let e of t) {
|
|
1892
|
+
if (!e.label) continue;
|
|
1893
|
+
let t = a.get(e.from), r = a.get(e.to);
|
|
1894
|
+
if (!t || !r) continue;
|
|
1895
|
+
let i = et(n, t, r, o.get(e.key) ?? 0, e.from === e.to), d = Xe(e.label);
|
|
1896
|
+
s = Math.min(s, i.labelX - d.width / 2), c = Math.min(c, i.labelY - d.height / 2), l = Math.max(l, i.labelX + d.width / 2), u = Math.max(u, i.labelY + d.height / 2);
|
|
1897
|
+
}
|
|
1898
|
+
if (!Number.isFinite(s)) return e;
|
|
1899
|
+
let d = Math.max(0, de - s), f = Math.max(0, de - c), p = Math.max(0, l + de - r), m = Math.max(0, u + de - i);
|
|
1900
|
+
if (d === 0 && f === 0 && p === 0 && m === 0) return e;
|
|
1901
|
+
for (let e of a.values()) e.x += d, e.y += f;
|
|
1902
|
+
return {
|
|
1903
|
+
width: r + d + p,
|
|
1904
|
+
height: i + f + m,
|
|
1905
|
+
positions: a
|
|
1906
|
+
};
|
|
1907
|
+
}
|
|
1908
|
+
function $e(e, t, n) {
|
|
1845
1909
|
let r = e.map((e) => e.id), i = new Map(r.map((e, t) => [e, t])), a = new Set(r), o = new Map(r.map((e) => [e, []]));
|
|
1846
1910
|
for (let e of t) e.from !== e.to && a.has(e.from) && a.has(e.to) && o.get(e.from).push(e.to);
|
|
1847
1911
|
let s = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Set(), u = [], d = [], f = 0, p = (e) => {
|
|
@@ -1876,42 +1940,38 @@ function ze(e, t, n) {
|
|
|
1876
1940
|
}
|
|
1877
1941
|
let b = Math.max(1, ...y) + 1, x = Array.from({ length: b }, () => []);
|
|
1878
1942
|
for (let e of r) x[y[m.get(e)]].push(e);
|
|
1879
|
-
let S = x.filter((e) => e.length > 0), C = Math.max(1, ...S.map((e) => e.length)), w = /* @__PURE__ */ new Map();
|
|
1880
|
-
if (n === "down") {
|
|
1881
|
-
let
|
|
1882
|
-
return S.forEach((t, n) => {
|
|
1883
|
-
let r = 53 + n * 120;
|
|
1884
|
-
t.forEach((n, i) => {
|
|
1885
|
-
let a = t.length === 1 ? e / 2 : 104 + i * (312 / (t.length - 1));
|
|
1886
|
-
w.set(n, {
|
|
1887
|
-
x: a,
|
|
1888
|
-
y: r
|
|
1889
|
-
});
|
|
1890
|
-
});
|
|
1891
|
-
}), {
|
|
1892
|
-
width: e,
|
|
1893
|
-
height: t,
|
|
1894
|
-
positions: w
|
|
1895
|
-
};
|
|
1896
|
-
}
|
|
1897
|
-
let T = Math.max(se, 208 + (S.length - 1) * 150), E = Math.max(240, 106 + (C - 1) * 74);
|
|
1898
|
-
return S.forEach((e, t) => {
|
|
1899
|
-
let n = S.length === 1 ? T / 2 : 104 + t * ((T - 88 - I) / (S.length - 1));
|
|
1943
|
+
let S = x.filter((e) => e.length > 0), C = Math.max(1, ...S.map((e) => e.length)), w = /* @__PURE__ */ new Map(), T, E;
|
|
1944
|
+
if (n === "down") T = se, E = Math.max(240, 106 + (S.length - 1) * 120), S.forEach((e, t) => {
|
|
1945
|
+
let n = 53 + t * 120;
|
|
1900
1946
|
e.forEach((t, r) => {
|
|
1901
|
-
let i = e.length === 1 ?
|
|
1947
|
+
let i = e.length === 1 ? T / 2 : 104 + r * ((T - 88 - ce) / (e.length - 1));
|
|
1902
1948
|
w.set(t, {
|
|
1903
|
-
x:
|
|
1904
|
-
y:
|
|
1949
|
+
x: i,
|
|
1950
|
+
y: n
|
|
1951
|
+
});
|
|
1952
|
+
});
|
|
1953
|
+
});
|
|
1954
|
+
else {
|
|
1955
|
+
let e = t.reduce((e, t) => t.label ? Math.max(e, Xe(t.label).width) : e, 0), n = Math.max(le, ce + (e > 0 ? e + 24 : 0));
|
|
1956
|
+
T = Math.max(se, 208 + (S.length - 1) * n), E = Math.max(240, 106 + (C - 1) * 74), S.forEach((e, t) => {
|
|
1957
|
+
let n = S.length === 1 ? T / 2 : 104 + t * ((T - 88 - ce) / (S.length - 1));
|
|
1958
|
+
e.forEach((t, r) => {
|
|
1959
|
+
let i = e.length === 1 ? E / 2 : 53 + r * ((E - 60 - L) / (e.length - 1));
|
|
1960
|
+
w.set(t, {
|
|
1961
|
+
x: n,
|
|
1962
|
+
y: i
|
|
1963
|
+
});
|
|
1905
1964
|
});
|
|
1906
1965
|
});
|
|
1907
|
-
}
|
|
1966
|
+
}
|
|
1967
|
+
return Qe({
|
|
1908
1968
|
width: T,
|
|
1909
1969
|
height: E,
|
|
1910
1970
|
positions: w
|
|
1911
|
-
};
|
|
1971
|
+
}, t, n);
|
|
1912
1972
|
}
|
|
1913
|
-
function
|
|
1914
|
-
let a =
|
|
1973
|
+
function et(e, t, n, r, i) {
|
|
1974
|
+
let a = ce, o = L;
|
|
1915
1975
|
if (i) return e === "right" ? {
|
|
1916
1976
|
d: `M ${t.x + 20} ${t.y - o / 2} C ${t.x + 64} ${t.y - o / 2 - 64}, ${t.x - 64} ${t.y - o / 2 - 64}, ${t.x - 20} ${t.y - o / 2}`,
|
|
1917
1977
|
labelX: t.x,
|
|
@@ -1927,7 +1987,7 @@ function Be(e, t, n, r, i) {
|
|
|
1927
1987
|
return {
|
|
1928
1988
|
d: `M ${e} ${i} L ${o} ${s}`,
|
|
1929
1989
|
labelX: (e + o) / 2,
|
|
1930
|
-
labelY: (i + s) / 2 -
|
|
1990
|
+
labelY: (i + s) / 2 - 12
|
|
1931
1991
|
};
|
|
1932
1992
|
}
|
|
1933
1993
|
let e = t.x + r, i = n.x + r, s = t.y + o / 2, c = n.y - o / 2, l = Math.max(70, Math.abs(i - e) * .45);
|
|
@@ -1941,7 +2001,7 @@ function Be(e, t, n, r, i) {
|
|
|
1941
2001
|
let e = t.x + r, i = n.x + r, a = t.y + o / 2, s = n.y - o / 2;
|
|
1942
2002
|
return {
|
|
1943
2003
|
d: `M ${e} ${a} L ${i} ${s}`,
|
|
1944
|
-
labelX: (e + i) / 2 +
|
|
2004
|
+
labelX: (e + i) / 2 + 10,
|
|
1945
2005
|
labelY: (a + s) / 2
|
|
1946
2006
|
};
|
|
1947
2007
|
}
|
|
@@ -1952,131 +2012,135 @@ function Be(e, t, n, r, i) {
|
|
|
1952
2012
|
labelY: (l + u) / 2
|
|
1953
2013
|
};
|
|
1954
2014
|
}
|
|
1955
|
-
function
|
|
1956
|
-
let [r, i] =
|
|
1957
|
-
|
|
2015
|
+
function tt({ node: e, runtime: t, render: n }) {
|
|
2016
|
+
let [r, i] = y(null), [a, o] = y(null), s = t.resetToken(e);
|
|
2017
|
+
h(() => {
|
|
1958
2018
|
i(null), o(null);
|
|
1959
2019
|
}, [s]);
|
|
1960
|
-
let c =
|
|
1961
|
-
for (let e of
|
|
2020
|
+
let c = g().replace(/[^a-zA-Z0-9_-]/g, ""), l = `local-diagram-arrow-${c}`, u = `local-diagram-description-${c}`, d = H(t, e.attrs, "label", "") || "图解", f = (e.attrs?.direction ?? "right").trim().toLowerCase() === "down" ? "down" : "right", p = e.children?.filter((e) => e.type === "component") ?? [], m = [], _ = [], v = /* @__PURE__ */ new Set();
|
|
2021
|
+
for (let e of p) {
|
|
1962
2022
|
if (e.name !== "node") continue;
|
|
1963
2023
|
let n = (e.attrs?.id ?? "").trim();
|
|
1964
2024
|
if (!n) {
|
|
1965
|
-
|
|
2025
|
+
m.push("存在缺少 id 的节点,已忽略。");
|
|
1966
2026
|
continue;
|
|
1967
2027
|
}
|
|
1968
|
-
if (
|
|
1969
|
-
|
|
2028
|
+
if (v.has(n)) {
|
|
2029
|
+
m.push(`节点 id 重复:${n},已忽略后续节点。`);
|
|
1970
2030
|
continue;
|
|
1971
2031
|
}
|
|
1972
|
-
|
|
1973
|
-
let r =
|
|
1974
|
-
|
|
2032
|
+
v.add(n);
|
|
2033
|
+
let r = H(t, e.attrs, "tone", "neutral").trim(), i = r === "success" || r === "warning" ? r : "neutral";
|
|
2034
|
+
_.push({
|
|
1975
2035
|
id: n,
|
|
1976
|
-
label:
|
|
2036
|
+
label: H(t, e.attrs, "label", n) || n,
|
|
1977
2037
|
tone: i,
|
|
1978
2038
|
children: e.children ?? []
|
|
1979
2039
|
});
|
|
1980
2040
|
}
|
|
1981
|
-
let
|
|
1982
|
-
for (let e of
|
|
2041
|
+
let b = [], w = /* @__PURE__ */ new Set();
|
|
2042
|
+
for (let e of p) {
|
|
1983
2043
|
if (e.name !== "edge") continue;
|
|
1984
2044
|
let n = (e.attrs?.from ?? "").trim(), r = (e.attrs?.to ?? "").trim();
|
|
1985
|
-
if (!n || !r || !
|
|
1986
|
-
|
|
2045
|
+
if (!n || !r || !v.has(n) || !v.has(r)) {
|
|
2046
|
+
m.push(`边 ${n || "?"} → ${r || "?"} 的端点不存在,已忽略。`);
|
|
1987
2047
|
continue;
|
|
1988
2048
|
}
|
|
1989
|
-
let i =
|
|
1990
|
-
|
|
2049
|
+
let i = H(t, e.attrs, "label", ""), a = `${n}\u0000${r}\u0000${i}`;
|
|
2050
|
+
w.has(a) ? m.push(`重复的边:${n} → ${r}${i ? `(${i})` : ""},已忽略。`) : (w.add(a), b.push({
|
|
1991
2051
|
key: a,
|
|
1992
2052
|
from: n,
|
|
1993
2053
|
to: r,
|
|
1994
2054
|
label: i
|
|
1995
2055
|
}));
|
|
1996
2056
|
}
|
|
1997
|
-
if (
|
|
2057
|
+
if (_.length === 0) return /* @__PURE__ */ C(U, {
|
|
1998
2058
|
className: "local-visual-diagram",
|
|
1999
|
-
label:
|
|
2000
|
-
children: [/* @__PURE__ */
|
|
2059
|
+
label: d,
|
|
2060
|
+
children: [/* @__PURE__ */ S(W, {
|
|
2001
2061
|
message: "diagram 至少需要一个 node。",
|
|
2002
2062
|
kind: "alert"
|
|
2003
|
-
}), /* @__PURE__ */
|
|
2063
|
+
}), /* @__PURE__ */ S(Ne, { notes: m })]
|
|
2004
2064
|
});
|
|
2005
|
-
let
|
|
2065
|
+
let T = null;
|
|
2006
2066
|
try {
|
|
2007
2067
|
let n = t.get(e);
|
|
2008
|
-
typeof n == "string" && (
|
|
2068
|
+
typeof n == "string" && (T = n);
|
|
2009
2069
|
} catch {
|
|
2010
|
-
|
|
2070
|
+
T = null;
|
|
2011
2071
|
}
|
|
2012
|
-
let
|
|
2072
|
+
let E = new Set(_.map((e) => e.id)), D = (e.attrs?.initial ?? "").trim(), O = D && E.has(D) ? D : _[0].id, k = T && E.has(T) ? T : r && E.has(r) ? r : O, A = _.find((e) => e.id === k) ?? _[0], j = (n) => {
|
|
2013
2073
|
i(n), o(null);
|
|
2014
2074
|
try {
|
|
2015
2075
|
let r = t.set(e, n);
|
|
2016
2076
|
r.length > 0 && o(r.map((e) => e.message).join(";"));
|
|
2017
2077
|
} catch (e) {
|
|
2018
|
-
o(
|
|
2078
|
+
o(V(e));
|
|
2019
2079
|
}
|
|
2020
|
-
},
|
|
2021
|
-
for (let e of
|
|
2022
|
-
let t =
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
let t = A.positions.get(e.from), n = A.positions.get(e.to);
|
|
2027
|
-
if (!t || !n) return null;
|
|
2028
|
-
let r = `${e.from}\u0000${e.to}`, i = j.get(r) ?? 1, a = M.get(r) ?? 0;
|
|
2029
|
-
M.set(r, a + 1);
|
|
2030
|
-
let o = (a - (i - 1) / 2) * 12, s = Be(u, t, n, o, e.from === e.to);
|
|
2031
|
-
return /* @__PURE__ */ S("g", {
|
|
2080
|
+
}, M = $e(_, b, f), N = Ze(b), P = [], F = [];
|
|
2081
|
+
for (let e of b) {
|
|
2082
|
+
let t = M.positions.get(e.from), n = M.positions.get(e.to);
|
|
2083
|
+
if (!t || !n) continue;
|
|
2084
|
+
let r = et(f, t, n, N.get(e.key) ?? 0, e.from === e.to);
|
|
2085
|
+
if (P.push(/* @__PURE__ */ S("g", {
|
|
2032
2086
|
className: "local-visual-edge",
|
|
2033
|
-
children:
|
|
2034
|
-
d:
|
|
2087
|
+
children: /* @__PURE__ */ S("path", {
|
|
2088
|
+
d: r.d,
|
|
2035
2089
|
fill: "none",
|
|
2036
|
-
stroke: "var(--
|
|
2090
|
+
style: { stroke: "var(--ink-muted)" },
|
|
2037
2091
|
strokeWidth: 1.6,
|
|
2038
|
-
markerEnd: `url(#${
|
|
2039
|
-
})
|
|
2092
|
+
markerEnd: `url(#${l})`
|
|
2093
|
+
})
|
|
2094
|
+
}, `edge-${e.key}`)), !e.label) continue;
|
|
2095
|
+
let i = Xe(e.label);
|
|
2096
|
+
F.push(/* @__PURE__ */ S("g", {
|
|
2097
|
+
className: "local-visual-edge-label-group",
|
|
2098
|
+
children: /* @__PURE__ */ S("text", {
|
|
2040
2099
|
className: "local-visual-edge-label",
|
|
2041
|
-
x:
|
|
2042
|
-
y:
|
|
2100
|
+
x: r.labelX,
|
|
2101
|
+
y: r.labelY,
|
|
2043
2102
|
textAnchor: "middle",
|
|
2044
2103
|
dominantBaseline: "middle",
|
|
2045
|
-
children: e
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2104
|
+
children: i.lines.map((e, t) => /* @__PURE__ */ S("tspan", {
|
|
2105
|
+
x: r.labelX,
|
|
2106
|
+
y: r.labelY + (t - (i.lines.length - 1) / 2) * fe,
|
|
2107
|
+
children: e
|
|
2108
|
+
}, t))
|
|
2109
|
+
})
|
|
2110
|
+
}, `edge-label-${e.key}`));
|
|
2111
|
+
}
|
|
2112
|
+
return /* @__PURE__ */ C(U, {
|
|
2050
2113
|
className: "local-visual-diagram",
|
|
2051
|
-
label:
|
|
2114
|
+
label: d,
|
|
2052
2115
|
children: [
|
|
2053
|
-
/* @__PURE__ */
|
|
2116
|
+
/* @__PURE__ */ S("div", {
|
|
2054
2117
|
className: "local-visual-svg-wrap",
|
|
2055
|
-
children: /* @__PURE__ */
|
|
2118
|
+
children: /* @__PURE__ */ C("svg", {
|
|
2056
2119
|
className: "local-visual-svg local-visual-diagram-svg",
|
|
2057
|
-
viewBox: `0 0 ${
|
|
2120
|
+
viewBox: `0 0 ${M.width} ${M.height}`,
|
|
2058
2121
|
role: "group",
|
|
2059
|
-
"aria-label": `${
|
|
2122
|
+
"aria-label": `${d},包含 ${_.length} 个节点和 ${b.length} 条边;用 Tab 聚焦节点,回车选择`,
|
|
2123
|
+
"aria-describedby": u,
|
|
2060
2124
|
children: [
|
|
2061
|
-
/* @__PURE__ */
|
|
2062
|
-
id:
|
|
2125
|
+
/* @__PURE__ */ S("defs", { children: /* @__PURE__ */ S("marker", {
|
|
2126
|
+
id: l,
|
|
2063
2127
|
viewBox: "0 0 10 10",
|
|
2064
2128
|
refX: "9",
|
|
2065
2129
|
refY: "5",
|
|
2066
2130
|
markerWidth: "7",
|
|
2067
2131
|
markerHeight: "7",
|
|
2068
2132
|
orient: "auto-start-reverse",
|
|
2069
|
-
children: /* @__PURE__ */
|
|
2133
|
+
children: /* @__PURE__ */ S("path", {
|
|
2070
2134
|
d: "M 0 0 L 10 5 L 0 10 z",
|
|
2071
|
-
fill: "var(--
|
|
2135
|
+
style: { fill: "var(--ink-muted)" }
|
|
2072
2136
|
})
|
|
2073
2137
|
}) }),
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
let t =
|
|
2138
|
+
P,
|
|
2139
|
+
_.map((e) => {
|
|
2140
|
+
let t = M.positions.get(e.id);
|
|
2077
2141
|
if (!t) return null;
|
|
2078
|
-
let n = e.id ===
|
|
2079
|
-
return /* @__PURE__ */
|
|
2142
|
+
let n = e.id === k, r = be(e.label, 8, 2);
|
|
2143
|
+
return /* @__PURE__ */ C("g", {
|
|
2080
2144
|
className: `local-visual-node local-visual-node-${e.tone}${n ? " is-selected" : ""}`,
|
|
2081
2145
|
"data-diagram-node": "",
|
|
2082
2146
|
transform: `translate(${t.x} ${t.y})`,
|
|
@@ -2084,24 +2148,24 @@ function Ve({ node: e, runtime: t, render: n }) {
|
|
|
2084
2148
|
tabIndex: 0,
|
|
2085
2149
|
"aria-pressed": n,
|
|
2086
2150
|
"aria-label": e.label,
|
|
2087
|
-
onClick: () =>
|
|
2151
|
+
onClick: () => j(e.id),
|
|
2088
2152
|
onKeyDown: (t) => {
|
|
2089
|
-
|
|
2153
|
+
Ee(t) ? (t.preventDefault(), j(e.id)) : t.key === "ArrowRight" || t.key === "ArrowDown" ? Te(t, "[data-diagram-node]", 1) : (t.key === "ArrowLeft" || t.key === "ArrowUp") && Te(t, "[data-diagram-node]", -1);
|
|
2090
2154
|
},
|
|
2091
2155
|
children: [
|
|
2092
|
-
/* @__PURE__ */
|
|
2093
|
-
/* @__PURE__ */
|
|
2156
|
+
/* @__PURE__ */ S("title", { children: e.label }),
|
|
2157
|
+
/* @__PURE__ */ S("rect", {
|
|
2094
2158
|
className: "local-visual-node-shape",
|
|
2095
2159
|
x: -60,
|
|
2096
2160
|
y: -23,
|
|
2097
|
-
width:
|
|
2098
|
-
height:
|
|
2161
|
+
width: ce,
|
|
2162
|
+
height: L,
|
|
2099
2163
|
rx: 10
|
|
2100
2164
|
}),
|
|
2101
|
-
/* @__PURE__ */
|
|
2165
|
+
/* @__PURE__ */ S("text", {
|
|
2102
2166
|
className: "local-visual-node-text",
|
|
2103
2167
|
textAnchor: "middle",
|
|
2104
|
-
children: r.map((e, t) => /* @__PURE__ */
|
|
2168
|
+
children: r.map((e, t) => /* @__PURE__ */ S("tspan", {
|
|
2105
2169
|
x: 0,
|
|
2106
2170
|
y: (t - (r.length - 1) / 2) * 16 + 4,
|
|
2107
2171
|
children: e
|
|
@@ -2109,66 +2173,116 @@ function Ve({ node: e, runtime: t, render: n }) {
|
|
|
2109
2173
|
})
|
|
2110
2174
|
]
|
|
2111
2175
|
}, `node-${e.id}`);
|
|
2112
|
-
})
|
|
2176
|
+
}),
|
|
2177
|
+
F
|
|
2113
2178
|
]
|
|
2114
2179
|
})
|
|
2115
2180
|
}),
|
|
2116
|
-
/* @__PURE__ */
|
|
2181
|
+
/* @__PURE__ */ S("div", {
|
|
2117
2182
|
className: "local-visual-diagram-detail",
|
|
2118
2183
|
"aria-live": "polite",
|
|
2119
|
-
children:
|
|
2184
|
+
children: A ? /* @__PURE__ */ C(x, { children: [/* @__PURE__ */ S("strong", { children: A.label }), A.children.length > 0 ? n(A.children) : /* @__PURE__ */ S("span", { children: "该节点没有说明。" })] }) : /* @__PURE__ */ S("span", { children: "点击或用 Tab 聚焦节点后按回车查看说明。" })
|
|
2185
|
+
}),
|
|
2186
|
+
/* @__PURE__ */ C("ul", {
|
|
2187
|
+
id: u,
|
|
2188
|
+
className: "local-visual-sr-only",
|
|
2189
|
+
"aria-label": "节点与连线",
|
|
2190
|
+
children: [_.map((e) => /* @__PURE__ */ S("li", { children: e.label }, `description-node-${e.id}`)), b.map((e) => {
|
|
2191
|
+
let t = _.find((t) => t.id === e.from), n = _.find((t) => t.id === e.to);
|
|
2192
|
+
return /* @__PURE__ */ C("li", { children: [
|
|
2193
|
+
t?.label ?? e.from,
|
|
2194
|
+
" → ",
|
|
2195
|
+
n?.label ?? e.to,
|
|
2196
|
+
e.label ? `(${e.label})` : ""
|
|
2197
|
+
] }, `description-edge-${e.key}`);
|
|
2198
|
+
})]
|
|
2120
2199
|
}),
|
|
2121
|
-
a ? /* @__PURE__ */
|
|
2200
|
+
a ? /* @__PURE__ */ S(W, {
|
|
2122
2201
|
message: a,
|
|
2123
2202
|
kind: "alert"
|
|
2124
2203
|
}) : null,
|
|
2125
|
-
/* @__PURE__ */
|
|
2126
|
-
/* @__PURE__ */ S("details", {
|
|
2127
|
-
className: "local-visual-details",
|
|
2128
|
-
children: [/* @__PURE__ */ x("summary", { children: "查看节点与连线" }), /* @__PURE__ */ S("ul", {
|
|
2129
|
-
className: "local-visual-diagram-list",
|
|
2130
|
-
children: [p.map((e) => /* @__PURE__ */ x("li", { children: /* @__PURE__ */ x("strong", { children: e.label }) }, `list-${e.id}`)), _.map((e) => {
|
|
2131
|
-
let t = p.find((t) => t.id === e.from), n = p.find((t) => t.id === e.to);
|
|
2132
|
-
return /* @__PURE__ */ S("li", { children: [
|
|
2133
|
-
t?.label ?? e.from,
|
|
2134
|
-
" → ",
|
|
2135
|
-
n?.label ?? e.to,
|
|
2136
|
-
e.label ? `(${e.label})` : ""
|
|
2137
|
-
] }, `edge-list-${e.key}`);
|
|
2138
|
-
})]
|
|
2139
|
-
})]
|
|
2140
|
-
})
|
|
2204
|
+
/* @__PURE__ */ S(Ne, { notes: m })
|
|
2141
2205
|
]
|
|
2142
2206
|
});
|
|
2143
2207
|
}
|
|
2144
|
-
function
|
|
2208
|
+
function nt(e) {
|
|
2145
2209
|
switch (e.node.name) {
|
|
2146
|
-
case "table": return /* @__PURE__ */
|
|
2147
|
-
case "chart": return /* @__PURE__ */
|
|
2148
|
-
case "plot": return /* @__PURE__ */
|
|
2149
|
-
case "timeline": return /* @__PURE__ */
|
|
2150
|
-
case "diagram": return /* @__PURE__ */
|
|
2210
|
+
case "table": return /* @__PURE__ */ S(Fe, { ...e });
|
|
2211
|
+
case "chart": return /* @__PURE__ */ S(Re, { ...e });
|
|
2212
|
+
case "plot": return /* @__PURE__ */ S(We, { ...e });
|
|
2213
|
+
case "timeline": return /* @__PURE__ */ S(Ge, { ...e });
|
|
2214
|
+
case "diagram": return /* @__PURE__ */ S(tt, { ...e });
|
|
2151
2215
|
default: return null;
|
|
2152
2216
|
}
|
|
2153
2217
|
}
|
|
2218
|
+
// src/local/heading-anchors.ts
|
|
2219
|
+
function rt(e, t) {
|
|
2220
|
+
return (e ?? []).map((e) => {
|
|
2221
|
+
switch (e.type) {
|
|
2222
|
+
case "text":
|
|
2223
|
+
case "inlineCode":
|
|
2224
|
+
case "inlineMath":
|
|
2225
|
+
case "fallback": return e.value ?? "";
|
|
2226
|
+
case "image": return e.alt ?? "";
|
|
2227
|
+
case "break": return " ";
|
|
2228
|
+
case "interpolation": try {
|
|
2229
|
+
let n = s(e.value ?? "").evaluate(t);
|
|
2230
|
+
return Array.isArray(n) ? "无法计算" : n === null ? "" : String(n);
|
|
2231
|
+
} catch {
|
|
2232
|
+
return "无法计算";
|
|
2233
|
+
}
|
|
2234
|
+
default: return rt(e.children, t);
|
|
2235
|
+
}
|
|
2236
|
+
}).join("");
|
|
2237
|
+
}
|
|
2238
|
+
function it(e) {
|
|
2239
|
+
return e.trim().toLowerCase().replace(/[^\p{L}\p{N}\p{M}\s_-]/gu, "").replace(/\s+/g, "-") || "section";
|
|
2240
|
+
}
|
|
2241
|
+
function at(e, t) {
|
|
2242
|
+
let n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map();
|
|
2243
|
+
function a(o) {
|
|
2244
|
+
for (let s of o) {
|
|
2245
|
+
if (s.type === "heading") {
|
|
2246
|
+
let a = it(rt(s.children, e.initialState)), o = a, c = i.get(a) ?? 0;
|
|
2247
|
+
for (; r.has(o);) c += 1, o = `${a}-${c}`;
|
|
2248
|
+
i.set(a, c);
|
|
2249
|
+
let l = `${t}-${o}`;
|
|
2250
|
+
n.set(s, l), r.set(o, l);
|
|
2251
|
+
}
|
|
2252
|
+
s.children && a(s.children);
|
|
2253
|
+
}
|
|
2254
|
+
}
|
|
2255
|
+
return a(e.nodes), {
|
|
2256
|
+
ids: n,
|
|
2257
|
+
resolve(e) {
|
|
2258
|
+
if (!e.startsWith("#")) return e;
|
|
2259
|
+
try {
|
|
2260
|
+
let t = r.get(decodeURIComponent(e.slice(1)));
|
|
2261
|
+
return t ? `#${t}` : e;
|
|
2262
|
+
} catch {
|
|
2263
|
+
return e;
|
|
2264
|
+
}
|
|
2265
|
+
}
|
|
2266
|
+
};
|
|
2267
|
+
}
|
|
2154
2268
|
// src/local/LocalDocumentView.tsx
|
|
2155
|
-
var
|
|
2269
|
+
var ot = d(null);
|
|
2156
2270
|
function G() {
|
|
2157
|
-
let e =
|
|
2271
|
+
let e = m(ot);
|
|
2158
2272
|
if (!e) throw Error("LocalViewContext 未初始化");
|
|
2159
2273
|
return e;
|
|
2160
2274
|
}
|
|
2161
|
-
var
|
|
2275
|
+
var st = /^\s*\{\{([\s\S]*)\}\}\s*$/, ct = {
|
|
2162
2276
|
revision: 0,
|
|
2163
2277
|
state: {}
|
|
2164
2278
|
};
|
|
2165
2279
|
function K(e, t) {
|
|
2166
2280
|
return e.attrs?.[t];
|
|
2167
2281
|
}
|
|
2168
|
-
function
|
|
2282
|
+
function lt(e, t, n) {
|
|
2169
2283
|
let r = K(t, n);
|
|
2170
2284
|
if (r === void 0) return { present: !1 };
|
|
2171
|
-
let i =
|
|
2285
|
+
let i = st.exec(r);
|
|
2172
2286
|
if (!i) return {
|
|
2173
2287
|
present: !0,
|
|
2174
2288
|
ok: !0,
|
|
@@ -2187,26 +2301,26 @@ function Ke(e, t, n) {
|
|
|
2187
2301
|
};
|
|
2188
2302
|
}
|
|
2189
2303
|
}
|
|
2190
|
-
function
|
|
2304
|
+
function ut(e) {
|
|
2191
2305
|
return e === null ? "" : typeof e == "string" ? e : typeof e == "number" ? Number.isFinite(e) ? String(e) : null : typeof e == "boolean" ? e ? "true" : "false" : null;
|
|
2192
2306
|
}
|
|
2193
2307
|
function q(e, t, n, r = "") {
|
|
2194
2308
|
let i = K(t, n);
|
|
2195
2309
|
if (i === void 0) return r;
|
|
2196
|
-
let a =
|
|
2310
|
+
let a = st.exec(i);
|
|
2197
2311
|
try {
|
|
2198
|
-
return a ?
|
|
2312
|
+
return a ? ut(e.evaluate(a[1])) ?? "无法计算" : e.text(i);
|
|
2199
2313
|
} catch {
|
|
2200
2314
|
return "无法计算";
|
|
2201
2315
|
}
|
|
2202
2316
|
}
|
|
2203
|
-
function
|
|
2317
|
+
function dt(e, t, n, r) {
|
|
2204
2318
|
let i = K(t, n);
|
|
2205
2319
|
if (i === void 0) return {
|
|
2206
2320
|
ok: !0,
|
|
2207
2321
|
value: r
|
|
2208
2322
|
};
|
|
2209
|
-
let a =
|
|
2323
|
+
let a = st.exec(i);
|
|
2210
2324
|
if (!a) return {
|
|
2211
2325
|
ok: !0,
|
|
2212
2326
|
value: i === "true"
|
|
@@ -2221,11 +2335,11 @@ function Je(e, t, n, r) {
|
|
|
2221
2335
|
return { ok: !1 };
|
|
2222
2336
|
}
|
|
2223
2337
|
}
|
|
2224
|
-
function
|
|
2225
|
-
let i =
|
|
2338
|
+
function ft(e, t, n, r = !1) {
|
|
2339
|
+
let i = dt(e, t, n, r);
|
|
2226
2340
|
return i.ok ? i.value : r;
|
|
2227
2341
|
}
|
|
2228
|
-
function
|
|
2342
|
+
function pt(e) {
|
|
2229
2343
|
try {
|
|
2230
2344
|
return e.snapshot().revision;
|
|
2231
2345
|
} catch {
|
|
@@ -2235,7 +2349,7 @@ function Xe(e) {
|
|
|
2235
2349
|
function J(e, t, n, r) {
|
|
2236
2350
|
let i = K(t, n);
|
|
2237
2351
|
if (i === void 0) return r;
|
|
2238
|
-
let a =
|
|
2352
|
+
let a = st.exec(i);
|
|
2239
2353
|
try {
|
|
2240
2354
|
let t = a ? e.evaluate(a[1]) : Number(i);
|
|
2241
2355
|
return typeof t == "number" && Number.isFinite(t) ? t : r;
|
|
@@ -2250,13 +2364,13 @@ function Y(e, t) {
|
|
|
2250
2364
|
return null;
|
|
2251
2365
|
}
|
|
2252
2366
|
}
|
|
2253
|
-
function
|
|
2254
|
-
return
|
|
2367
|
+
function mt(e) {
|
|
2368
|
+
return ut(e) ?? "";
|
|
2255
2369
|
}
|
|
2256
2370
|
function X(e) {
|
|
2257
|
-
let { runtime: t, report: n } = G(), [r, i] =
|
|
2371
|
+
let { runtime: t, report: n } = G(), [r, i] = y(null);
|
|
2258
2372
|
return {
|
|
2259
|
-
write:
|
|
2373
|
+
write: p((r) => {
|
|
2260
2374
|
try {
|
|
2261
2375
|
let a = t.set(e, r);
|
|
2262
2376
|
return a.length ? (i(a.map((e) => e.message).join(";")), n(a), !1) : (i(null), !0);
|
|
@@ -2272,8 +2386,8 @@ function X(e) {
|
|
|
2272
2386
|
setError: i
|
|
2273
2387
|
};
|
|
2274
2388
|
}
|
|
2275
|
-
function
|
|
2276
|
-
let { runtime: t } = G(), n =
|
|
2389
|
+
function ht(e) {
|
|
2390
|
+
let { runtime: t } = G(), n = dt(t, e, "disabled", !1);
|
|
2277
2391
|
return n.ok ? {
|
|
2278
2392
|
disabled: n.value,
|
|
2279
2393
|
invalid: !1
|
|
@@ -2282,26 +2396,26 @@ function Qe(e) {
|
|
|
2282
2396
|
invalid: !0
|
|
2283
2397
|
};
|
|
2284
2398
|
}
|
|
2285
|
-
function
|
|
2399
|
+
function gt(e, t, n) {
|
|
2286
2400
|
let r = 0;
|
|
2287
2401
|
try {
|
|
2288
2402
|
r = e.resetToken(t);
|
|
2289
2403
|
} catch {
|
|
2290
2404
|
r = 0;
|
|
2291
2405
|
}
|
|
2292
|
-
let i =
|
|
2293
|
-
a.current = n,
|
|
2406
|
+
let i = v(r), a = v(n);
|
|
2407
|
+
a.current = n, h(() => {
|
|
2294
2408
|
i.current !== r && (i.current = r, a.current());
|
|
2295
2409
|
}, [r]);
|
|
2296
2410
|
}
|
|
2297
2411
|
function Z({ message: e = "无法计算" }) {
|
|
2298
|
-
return /* @__PURE__ */
|
|
2412
|
+
return /* @__PURE__ */ S("span", {
|
|
2299
2413
|
className: "local-error",
|
|
2300
2414
|
role: "alert",
|
|
2301
2415
|
children: e
|
|
2302
2416
|
});
|
|
2303
2417
|
}
|
|
2304
|
-
var
|
|
2418
|
+
var _t = class extends u {
|
|
2305
2419
|
state = { failed: !1 };
|
|
2306
2420
|
static getDerivedStateFromError() {
|
|
2307
2421
|
return { failed: !0 };
|
|
@@ -2310,16 +2424,16 @@ var et = class extends l {
|
|
|
2310
2424
|
this.state.failed && e.revision !== this.props.revision && this.setState({ failed: !1 });
|
|
2311
2425
|
}
|
|
2312
2426
|
render() {
|
|
2313
|
-
return this.state.failed ? /* @__PURE__ */
|
|
2427
|
+
return this.state.failed ? /* @__PURE__ */ S(Z, {}) : this.props.children;
|
|
2314
2428
|
}
|
|
2315
|
-
},
|
|
2429
|
+
}, vt = /* @__PURE__ */ new Set([
|
|
2316
2430
|
"table",
|
|
2317
2431
|
"chart",
|
|
2318
2432
|
"plot",
|
|
2319
2433
|
"timeline",
|
|
2320
2434
|
"diagram"
|
|
2321
2435
|
]);
|
|
2322
|
-
function
|
|
2436
|
+
function yt(e, t, n) {
|
|
2323
2437
|
if (!e) return null;
|
|
2324
2438
|
let r = e.trim();
|
|
2325
2439
|
if (!r) return null;
|
|
@@ -2335,59 +2449,75 @@ function nt(e, t, n) {
|
|
|
2335
2449
|
return null;
|
|
2336
2450
|
}
|
|
2337
2451
|
}
|
|
2338
|
-
function
|
|
2452
|
+
function bt(e) {
|
|
2339
2453
|
return `h${Math.min(6, Math.max(1, e ?? 1))}`;
|
|
2340
2454
|
}
|
|
2341
|
-
function Q(e, t, n) {
|
|
2342
|
-
return !t || t.length === 0 ? null : t.map((t,
|
|
2455
|
+
function Q(e, t, n, r = !0) {
|
|
2456
|
+
return !t || t.length === 0 ? null : t.map((t, i) => wt(e, t, i, n, r));
|
|
2343
2457
|
}
|
|
2344
|
-
function
|
|
2345
|
-
|
|
2458
|
+
function xt(e, t) {
|
|
2459
|
+
if (typeof t.value == "string") return t.value;
|
|
2460
|
+
let { start: n, end: r } = t.range;
|
|
2461
|
+
return Number.isInteger(n) && Number.isInteger(r) && n >= 0 && r >= n ? e.runtime.document.source.slice(n, r) : "";
|
|
2346
2462
|
}
|
|
2347
|
-
function
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2463
|
+
function St(e, t, n, r) {
|
|
2464
|
+
return /* @__PURE__ */ S("span", {
|
|
2465
|
+
className: r ? "local-fallback local-fallback-block" : "local-fallback local-fallback-inline",
|
|
2466
|
+
title: "未支持的语法,已按源码原样显示",
|
|
2467
|
+
"data-local-fallback": "",
|
|
2468
|
+
children: xt(e, t)
|
|
2469
|
+
}, n);
|
|
2470
|
+
}
|
|
2471
|
+
function Ct(e, t, n) {
|
|
2472
|
+
return !t || t.length === 0 ? null : t.map((t, r) => t.type === "paragraph" || t.type === "root" ? /* @__PURE__ */ S("span", { children: Q(e, t.children, n, !1) }, t.id || `inline-${r}`) : wt(e, t, r, n, !1));
|
|
2473
|
+
}
|
|
2474
|
+
function wt(e, t, n, r, i = !0) {
|
|
2475
|
+
let a = t.id || `${t.type}-${n}`;
|
|
2476
|
+
if (t.type === "component") return /* @__PURE__ */ S(_t, {
|
|
2477
|
+
revision: pt(e.runtime),
|
|
2478
|
+
children: Et(t, r)
|
|
2479
|
+
}, a);
|
|
2353
2480
|
switch (t.type) {
|
|
2354
|
-
case "root": return /* @__PURE__ */
|
|
2355
|
-
case "heading": return
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
case "
|
|
2360
|
-
case "
|
|
2361
|
-
case "
|
|
2481
|
+
case "root": return /* @__PURE__ */ S("div", { children: Q(e, t.children, r) }, a);
|
|
2482
|
+
case "heading": return f(bt(t.depth), {
|
|
2483
|
+
key: a,
|
|
2484
|
+
id: e.anchors.ids.get(t)
|
|
2485
|
+
}, Q(e, t.children, r, !1));
|
|
2486
|
+
case "paragraph": return /* @__PURE__ */ S("p", { children: Q(e, t.children, r, !1) }, a);
|
|
2487
|
+
case "text": return /* @__PURE__ */ S("span", { children: t.value ?? "" }, a);
|
|
2488
|
+
case "emphasis": return /* @__PURE__ */ S("em", { children: Q(e, t.children, r, !1) }, a);
|
|
2489
|
+
case "strong": return /* @__PURE__ */ S("strong", { children: Q(e, t.children, r, !1) }, a);
|
|
2490
|
+
case "delete": return /* @__PURE__ */ S("del", { children: Q(e, t.children, r, !1) }, a);
|
|
2491
|
+
case "inlineCode": return /* @__PURE__ */ S("code", {
|
|
2362
2492
|
className: "md-inline-code",
|
|
2363
2493
|
children: t.value ?? ""
|
|
2364
|
-
},
|
|
2494
|
+
}, a);
|
|
2365
2495
|
case "code": {
|
|
2366
2496
|
let e = t.lang ? `language-${t.lang}` : void 0;
|
|
2367
|
-
return /* @__PURE__ */
|
|
2497
|
+
return /* @__PURE__ */ S("pre", {
|
|
2368
2498
|
className: "md-code",
|
|
2369
|
-
children: /* @__PURE__ */
|
|
2499
|
+
children: /* @__PURE__ */ S("code", {
|
|
2370
2500
|
className: e,
|
|
2371
2501
|
children: t.value ?? ""
|
|
2372
2502
|
})
|
|
2373
|
-
},
|
|
2503
|
+
}, a);
|
|
2374
2504
|
}
|
|
2375
|
-
case "blockquote": return /* @__PURE__ */
|
|
2376
|
-
case "break": return /* @__PURE__ */
|
|
2377
|
-
case "thematicBreak": return /* @__PURE__ */
|
|
2378
|
-
case "list": return t.ordered ? /* @__PURE__ */
|
|
2505
|
+
case "blockquote": return /* @__PURE__ */ S("blockquote", { children: Q(e, t.children, r) }, a);
|
|
2506
|
+
case "break": return /* @__PURE__ */ S("br", {}, a);
|
|
2507
|
+
case "thematicBreak": return /* @__PURE__ */ S("hr", {}, a);
|
|
2508
|
+
case "list": return t.ordered ? /* @__PURE__ */ S("ol", {
|
|
2379
2509
|
start: t.start ?? 1,
|
|
2380
2510
|
className: "md-list",
|
|
2381
2511
|
children: Q(e, t.children, r)
|
|
2382
|
-
},
|
|
2512
|
+
}, a) : /* @__PURE__ */ S("ul", {
|
|
2383
2513
|
className: "md-list",
|
|
2384
2514
|
children: Q(e, t.children, r)
|
|
2385
|
-
},
|
|
2515
|
+
}, a);
|
|
2386
2516
|
case "listItem": {
|
|
2387
2517
|
let n = typeof t.checked == "boolean";
|
|
2388
|
-
return /* @__PURE__ */
|
|
2518
|
+
return /* @__PURE__ */ C("li", {
|
|
2389
2519
|
className: n ? "md-list-item md-task-item" : "md-list-item",
|
|
2390
|
-
children: [n ? /* @__PURE__ */
|
|
2520
|
+
children: [n ? /* @__PURE__ */ S("input", {
|
|
2391
2521
|
type: "checkbox",
|
|
2392
2522
|
className: "md-task-checkbox",
|
|
2393
2523
|
checked: t.checked === !0,
|
|
@@ -2395,117 +2525,119 @@ function at(e, t, n, r) {
|
|
|
2395
2525
|
tabIndex: -1,
|
|
2396
2526
|
"aria-label": t.checked ? "已完成" : "未完成"
|
|
2397
2527
|
}) : null, Q(e, t.children, r)]
|
|
2398
|
-
},
|
|
2528
|
+
}, a);
|
|
2399
2529
|
}
|
|
2400
2530
|
case "link": {
|
|
2401
|
-
let n =
|
|
2402
|
-
if (!n) return /* @__PURE__ */
|
|
2531
|
+
let n = yt(t.url, "link", e.urlPolicy);
|
|
2532
|
+
if (!n) return /* @__PURE__ */ S("span", {
|
|
2403
2533
|
className: "md-link-rejected",
|
|
2404
2534
|
title: "已拒绝不安全的链接地址",
|
|
2405
|
-
children: Q(e, t.children, r)
|
|
2406
|
-
},
|
|
2407
|
-
let
|
|
2408
|
-
return /* @__PURE__ */
|
|
2409
|
-
href:
|
|
2535
|
+
children: Q(e, t.children, r, !1)
|
|
2536
|
+
}, a);
|
|
2537
|
+
let i = e.anchors.resolve(n), o = /^https?:/i.test(i);
|
|
2538
|
+
return /* @__PURE__ */ S("a", {
|
|
2539
|
+
href: i,
|
|
2410
2540
|
title: t.title ?? void 0,
|
|
2411
|
-
target:
|
|
2412
|
-
rel:
|
|
2413
|
-
children: Q(e, t.children, r)
|
|
2414
|
-
},
|
|
2541
|
+
target: o ? "_blank" : void 0,
|
|
2542
|
+
rel: o ? "noopener noreferrer" : void 0,
|
|
2543
|
+
children: Q(e, t.children, r, !1)
|
|
2544
|
+
}, a);
|
|
2415
2545
|
}
|
|
2416
2546
|
case "image": {
|
|
2417
|
-
let n =
|
|
2418
|
-
return n ? /* @__PURE__ */
|
|
2547
|
+
let n = yt(t.url, "image", e.urlPolicy);
|
|
2548
|
+
return n ? /* @__PURE__ */ S("img", {
|
|
2419
2549
|
className: "md-image",
|
|
2420
2550
|
src: n,
|
|
2421
2551
|
alt: t.alt ?? "",
|
|
2422
2552
|
title: t.title ?? void 0,
|
|
2423
2553
|
loading: "lazy",
|
|
2424
2554
|
referrerPolicy: "no-referrer"
|
|
2425
|
-
},
|
|
2555
|
+
}, a) : /* @__PURE__ */ C("span", {
|
|
2426
2556
|
className: "md-image-rejected",
|
|
2427
2557
|
children: [
|
|
2428
2558
|
"[已拒绝不安全的图片",
|
|
2429
2559
|
t.alt ? `:${t.alt}` : "",
|
|
2430
2560
|
"]"
|
|
2431
2561
|
]
|
|
2432
|
-
},
|
|
2562
|
+
}, a);
|
|
2433
2563
|
}
|
|
2434
2564
|
case "table": {
|
|
2435
|
-
let [n, ...
|
|
2436
|
-
return /* @__PURE__ */
|
|
2565
|
+
let [n, ...i] = t.children ?? [];
|
|
2566
|
+
return /* @__PURE__ */ S("div", {
|
|
2437
2567
|
className: "md-table-scroll",
|
|
2438
|
-
children: /* @__PURE__ */
|
|
2568
|
+
children: /* @__PURE__ */ C("table", {
|
|
2439
2569
|
className: "md-table",
|
|
2440
|
-
children: [n ? /* @__PURE__ */
|
|
2570
|
+
children: [n ? /* @__PURE__ */ S("thead", { children: /* @__PURE__ */ S("tr", { children: Tt(e, n, "th", t.align, r) }) }) : null, i.length ? /* @__PURE__ */ S("tbody", { children: i.map((n, i) => /* @__PURE__ */ S("tr", { children: Tt(e, n, "td", t.align, r) }, n.id || `${a}-row-${i}`)) }) : null]
|
|
2441
2571
|
})
|
|
2442
|
-
},
|
|
2572
|
+
}, a);
|
|
2443
2573
|
}
|
|
2444
|
-
case "tableRow": return /* @__PURE__ */
|
|
2574
|
+
case "tableRow": return /* @__PURE__ */ S("tr", { children: Tt(e, t, "td", void 0, r) }, a);
|
|
2445
2575
|
case "tableCell": {
|
|
2446
2576
|
let n = t.align?.[0] ?? void 0;
|
|
2447
|
-
return /* @__PURE__ */
|
|
2577
|
+
return /* @__PURE__ */ S("td", {
|
|
2448
2578
|
style: { textAlign: n ?? void 0 },
|
|
2449
|
-
children: Q(e, t.children, r)
|
|
2450
|
-
},
|
|
2579
|
+
children: Q(e, t.children, r, !1)
|
|
2580
|
+
}, a);
|
|
2451
2581
|
}
|
|
2452
2582
|
case "interpolation": try {
|
|
2453
|
-
let n =
|
|
2583
|
+
let n = ut(e.runtime.evaluate(t.value ?? ""));
|
|
2454
2584
|
if (n === null) throw Error("无法显示数组");
|
|
2455
|
-
return /* @__PURE__ */
|
|
2585
|
+
return /* @__PURE__ */ S("span", {
|
|
2456
2586
|
className: "local-interpolation",
|
|
2457
2587
|
children: n
|
|
2458
|
-
},
|
|
2588
|
+
}, a);
|
|
2459
2589
|
} catch {
|
|
2460
|
-
return /* @__PURE__ */
|
|
2590
|
+
return /* @__PURE__ */ S(Z, {}, a);
|
|
2461
2591
|
}
|
|
2462
2592
|
case "math":
|
|
2463
2593
|
case "inlineMath": {
|
|
2464
2594
|
let n = t.type === "math";
|
|
2465
|
-
return /* @__PURE__ */
|
|
2595
|
+
return /* @__PURE__ */ S("span", {
|
|
2466
2596
|
className: n ? "local-math-display" : "local-math-inline",
|
|
2467
|
-
children: /* @__PURE__ */
|
|
2468
|
-
revision:
|
|
2469
|
-
children: /* @__PURE__ */
|
|
2597
|
+
children: /* @__PURE__ */ S(_t, {
|
|
2598
|
+
revision: pt(e.runtime),
|
|
2599
|
+
children: /* @__PURE__ */ S(ne, {
|
|
2470
2600
|
source: t.value ?? "",
|
|
2471
2601
|
display: n
|
|
2472
2602
|
})
|
|
2473
2603
|
})
|
|
2474
|
-
},
|
|
2604
|
+
}, a);
|
|
2475
2605
|
}
|
|
2476
|
-
case "html": return /* @__PURE__ */
|
|
2606
|
+
case "html": return /* @__PURE__ */ S("span", {
|
|
2477
2607
|
className: "md-raw-html",
|
|
2478
2608
|
children: t.value ?? ""
|
|
2479
|
-
},
|
|
2609
|
+
}, a);
|
|
2610
|
+
case "fallback": return St(e, t, a, i);
|
|
2611
|
+
case "footnoteReference": return St(e, t, a, !1);
|
|
2612
|
+
case "footnoteDefinition": return St(e, t, a, i);
|
|
2480
2613
|
case "comment":
|
|
2481
|
-
case "definition":
|
|
2482
|
-
|
|
2483
|
-
default: return t.children && t.children.length ? /* @__PURE__ */ x("span", { children: Q(e, t.children, r) }, i) : typeof t.value == "string" ? /* @__PURE__ */ x("span", { children: t.value }, i) : null;
|
|
2614
|
+
case "definition": return null;
|
|
2615
|
+
default: return t.children && t.children.length ? /* @__PURE__ */ S("span", { children: Q(e, t.children, r, i) }, a) : typeof t.value == "string" ? /* @__PURE__ */ S("span", { children: t.value }, a) : null;
|
|
2484
2616
|
}
|
|
2485
2617
|
}
|
|
2486
|
-
function
|
|
2618
|
+
function Tt(e, t, n, r, i) {
|
|
2487
2619
|
return (t.children ?? []).map((a, o) => {
|
|
2488
2620
|
let s = a.align?.[0] ?? t.align?.[o] ?? r?.[o] ?? void 0;
|
|
2489
|
-
return n === "th" ? /* @__PURE__ */
|
|
2621
|
+
return n === "th" ? /* @__PURE__ */ S("th", {
|
|
2490
2622
|
style: { textAlign: s ?? void 0 },
|
|
2491
|
-
children: Q(e, a.children, i)
|
|
2492
|
-
}, a.id || `${t.id}-h-${o}`) : /* @__PURE__ */
|
|
2623
|
+
children: Q(e, a.children, i, !1)
|
|
2624
|
+
}, a.id || `${t.id}-h-${o}`) : /* @__PURE__ */ S("td", {
|
|
2493
2625
|
style: { textAlign: s ?? void 0 },
|
|
2494
|
-
children: Q(e, a.children, i)
|
|
2626
|
+
children: Q(e, a.children, i, !1)
|
|
2495
2627
|
}, a.id || `${t.id}-c-${o}`);
|
|
2496
2628
|
});
|
|
2497
2629
|
}
|
|
2498
|
-
function
|
|
2630
|
+
function Et(e, t) {
|
|
2499
2631
|
let n = e.name ?? "";
|
|
2500
|
-
if (
|
|
2632
|
+
if (vt.has(n)) return /* @__PURE__ */ S(Dt, {
|
|
2501
2633
|
node: e,
|
|
2502
2634
|
visible: t
|
|
2503
2635
|
});
|
|
2504
|
-
let r =
|
|
2505
|
-
return r ? /* @__PURE__ */
|
|
2636
|
+
let r = un[n];
|
|
2637
|
+
return r ? /* @__PURE__ */ S(r, {
|
|
2506
2638
|
node: e,
|
|
2507
2639
|
visible: t
|
|
2508
|
-
}) : /* @__PURE__ */
|
|
2640
|
+
}) : /* @__PURE__ */ C("span", {
|
|
2509
2641
|
className: "component-error",
|
|
2510
2642
|
children: [
|
|
2511
2643
|
"未知组件“",
|
|
@@ -2514,9 +2646,9 @@ function st(e, t) {
|
|
|
2514
2646
|
]
|
|
2515
2647
|
});
|
|
2516
2648
|
}
|
|
2517
|
-
function
|
|
2649
|
+
function Dt({ node: e, visible: t }) {
|
|
2518
2650
|
let { runtime: n, render: r } = G();
|
|
2519
|
-
return /* @__PURE__ */
|
|
2651
|
+
return /* @__PURE__ */ S(nt, {
|
|
2520
2652
|
node: e,
|
|
2521
2653
|
runtime: n,
|
|
2522
2654
|
render: r,
|
|
@@ -2524,56 +2656,56 @@ function ct({ node: e, visible: t }) {
|
|
|
2524
2656
|
});
|
|
2525
2657
|
}
|
|
2526
2658
|
function $({ message: e }) {
|
|
2527
|
-
return e ? /* @__PURE__ */
|
|
2659
|
+
return e ? /* @__PURE__ */ S("span", {
|
|
2528
2660
|
className: "field-error",
|
|
2529
2661
|
role: "alert",
|
|
2530
2662
|
children: e
|
|
2531
2663
|
}) : null;
|
|
2532
2664
|
}
|
|
2533
|
-
function
|
|
2665
|
+
function Ot(e, t) {
|
|
2534
2666
|
if (t.required && e.length === 0) return "请填写此字段";
|
|
2535
|
-
if (e.length > 1e5) return `最多允许 ${
|
|
2667
|
+
if (e.length > 1e5) return `最多允许 ${l} 个字符`;
|
|
2536
2668
|
if (t.email && e !== "" && !n(e)) return "请输入有效的邮箱地址";
|
|
2537
2669
|
let r = e.length;
|
|
2538
2670
|
return t.minLength !== void 0 && t.minLength > 0 && e !== "" && r < t.minLength ? `至少需要 ${t.minLength} 个字符` : t.maxLength !== void 0 && t.maxLength >= 0 && r > t.maxLength ? `最多允许 ${t.maxLength} 个字符` : null;
|
|
2539
2671
|
}
|
|
2540
|
-
function
|
|
2541
|
-
let t =
|
|
2542
|
-
N.current = b,
|
|
2672
|
+
function kt({ node: e }) {
|
|
2673
|
+
let t = g(), { runtime: n } = G(), { write: r, error: i, setError: a } = X(e), o = q(n, e, "label", e.name ?? "输入"), s = q(n, e, "placeholder", ""), c = (K(e, "type") ?? "text") === "email", l = ft(n, e, "required", !1), { disabled: u, invalid: d } = ht(e), f = K(e, "min-length"), p = K(e, "max-length"), m = f === void 0 ? void 0 : Math.max(0, Math.floor(J(n, e, "min-length", 0))), _ = p === void 0 ? void 0 : Math.max(0, Math.floor(J(n, e, "max-length", 0))), b = mt(Y(n, e)), [x, w] = y(b), [T, E] = y(!1), [D, O] = y(!1), [k, A] = y(null), j = v(!1), M = v(b), N = v(b);
|
|
2674
|
+
N.current = b, h(() => {
|
|
2543
2675
|
M.current !== b && (M.current = b, !T && !j.current && w(b));
|
|
2544
|
-
}, [b, T]),
|
|
2676
|
+
}, [b, T]), gt(n, e, () => {
|
|
2545
2677
|
j.current = !1, w(N.current), O(!1), A(null), a(null);
|
|
2546
2678
|
});
|
|
2547
|
-
let P = (e) =>
|
|
2679
|
+
let P = (e) => Ot(e, {
|
|
2548
2680
|
required: l,
|
|
2549
|
-
minLength:
|
|
2550
|
-
maxLength:
|
|
2681
|
+
minLength: m,
|
|
2682
|
+
maxLength: _,
|
|
2551
2683
|
email: c
|
|
2552
2684
|
});
|
|
2553
|
-
return /* @__PURE__ */
|
|
2685
|
+
return /* @__PURE__ */ C("div", {
|
|
2554
2686
|
className: `md-control local-input${c ? " local-input-email" : ""}`,
|
|
2555
2687
|
children: [
|
|
2556
|
-
/* @__PURE__ */
|
|
2688
|
+
/* @__PURE__ */ S("label", {
|
|
2557
2689
|
className: "md-label",
|
|
2558
2690
|
htmlFor: `${t}-input`,
|
|
2559
2691
|
children: o
|
|
2560
2692
|
}),
|
|
2561
|
-
/* @__PURE__ */
|
|
2693
|
+
/* @__PURE__ */ S("input", {
|
|
2562
2694
|
id: `${t}-input`,
|
|
2563
2695
|
className: "md-text-input",
|
|
2564
2696
|
type: c ? "email" : "text",
|
|
2565
|
-
value:
|
|
2697
|
+
value: x,
|
|
2566
2698
|
placeholder: s || void 0,
|
|
2567
2699
|
disabled: u,
|
|
2568
2700
|
required: l,
|
|
2569
|
-
minLength:
|
|
2570
|
-
maxLength:
|
|
2701
|
+
minLength: m,
|
|
2702
|
+
maxLength: _,
|
|
2571
2703
|
"aria-invalid": k || i ? !0 : void 0,
|
|
2572
2704
|
onFocus: () => E(!0),
|
|
2573
2705
|
onBlur: () => {
|
|
2574
2706
|
E(!1), O(!0);
|
|
2575
|
-
let e = P(
|
|
2576
|
-
A(e), !e &&
|
|
2707
|
+
let e = P(x);
|
|
2708
|
+
A(e), !e && x !== b && r(x);
|
|
2577
2709
|
},
|
|
2578
2710
|
onChange: (e) => {
|
|
2579
2711
|
let t = e.target.value;
|
|
@@ -2588,46 +2720,46 @@ function ut({ node: e }) {
|
|
|
2588
2720
|
w(t), D && A(P(t)), P(t) === null && r(t);
|
|
2589
2721
|
}
|
|
2590
2722
|
}),
|
|
2591
|
-
/* @__PURE__ */
|
|
2723
|
+
/* @__PURE__ */ S($, { message: d ? "无法计算" : k ?? i })
|
|
2592
2724
|
]
|
|
2593
2725
|
});
|
|
2594
2726
|
}
|
|
2595
|
-
function
|
|
2596
|
-
let t =
|
|
2597
|
-
N.current = b,
|
|
2727
|
+
function At({ node: e }) {
|
|
2728
|
+
let t = g(), { runtime: n } = G(), { write: r, error: i, setError: a } = X(e), o = q(n, e, "label", "文本"), s = q(n, e, "placeholder", ""), c = Math.min(40, Math.max(1, Math.floor(J(n, e, "rows", 4)))), l = ft(n, e, "required", !1), { disabled: u, invalid: d } = ht(e), f = K(e, "min-length"), p = K(e, "max-length"), m = f === void 0 ? void 0 : Math.max(0, Math.floor(J(n, e, "min-length", 0))), _ = p === void 0 ? void 0 : Math.max(0, Math.floor(J(n, e, "max-length", 0))), b = mt(Y(n, e)), [x, w] = y(b), [T, E] = y(!1), [D, O] = y(!1), [k, A] = y(null), j = v(!1), M = v(b), N = v(b);
|
|
2729
|
+
N.current = b, h(() => {
|
|
2598
2730
|
M.current !== b && (M.current = b, !T && !j.current && w(b));
|
|
2599
|
-
}, [b, T]),
|
|
2731
|
+
}, [b, T]), gt(n, e, () => {
|
|
2600
2732
|
j.current = !1, w(N.current), O(!1), A(null), a(null);
|
|
2601
2733
|
});
|
|
2602
|
-
let P = (e) =>
|
|
2734
|
+
let P = (e) => Ot(e, {
|
|
2603
2735
|
required: l,
|
|
2604
|
-
minLength:
|
|
2605
|
-
maxLength:
|
|
2736
|
+
minLength: m,
|
|
2737
|
+
maxLength: _
|
|
2606
2738
|
});
|
|
2607
|
-
return /* @__PURE__ */
|
|
2739
|
+
return /* @__PURE__ */ C("div", {
|
|
2608
2740
|
className: "md-control local-textarea",
|
|
2609
2741
|
children: [
|
|
2610
|
-
/* @__PURE__ */
|
|
2742
|
+
/* @__PURE__ */ S("label", {
|
|
2611
2743
|
className: "md-label",
|
|
2612
2744
|
htmlFor: `${t}-textarea`,
|
|
2613
2745
|
children: o
|
|
2614
2746
|
}),
|
|
2615
|
-
/* @__PURE__ */
|
|
2747
|
+
/* @__PURE__ */ S("textarea", {
|
|
2616
2748
|
id: `${t}-textarea`,
|
|
2617
2749
|
className: "md-text-input",
|
|
2618
2750
|
rows: c,
|
|
2619
|
-
value:
|
|
2751
|
+
value: x,
|
|
2620
2752
|
placeholder: s || void 0,
|
|
2621
2753
|
disabled: u,
|
|
2622
2754
|
required: l,
|
|
2623
|
-
minLength:
|
|
2624
|
-
maxLength:
|
|
2755
|
+
minLength: m,
|
|
2756
|
+
maxLength: _,
|
|
2625
2757
|
"aria-invalid": k || i ? !0 : void 0,
|
|
2626
2758
|
onFocus: () => E(!0),
|
|
2627
2759
|
onBlur: () => {
|
|
2628
2760
|
E(!1), O(!0);
|
|
2629
|
-
let e = P(
|
|
2630
|
-
A(e), !e &&
|
|
2761
|
+
let e = P(x);
|
|
2762
|
+
A(e), !e && x !== b && r(x);
|
|
2631
2763
|
},
|
|
2632
2764
|
onChange: (e) => {
|
|
2633
2765
|
let t = e.target.value;
|
|
@@ -2642,11 +2774,11 @@ function dt({ node: e }) {
|
|
|
2642
2774
|
w(t), D && A(P(t)), P(t) === null && r(t);
|
|
2643
2775
|
}
|
|
2644
2776
|
}),
|
|
2645
|
-
/* @__PURE__ */
|
|
2777
|
+
/* @__PURE__ */ S($, { message: d ? "无法计算" : k ?? i })
|
|
2646
2778
|
]
|
|
2647
2779
|
});
|
|
2648
2780
|
}
|
|
2649
|
-
function
|
|
2781
|
+
function jt(e) {
|
|
2650
2782
|
let t = e.trim();
|
|
2651
2783
|
if (t === "" || t === "-" || t === "+" || t === "." || t === "-.") return { kind: "empty" };
|
|
2652
2784
|
let n = Number(t);
|
|
@@ -2655,7 +2787,7 @@ function ft(e) {
|
|
|
2655
2787
|
value: n
|
|
2656
2788
|
} : { kind: "invalid" };
|
|
2657
2789
|
}
|
|
2658
|
-
function
|
|
2790
|
+
function Mt(e, t, n, r) {
|
|
2659
2791
|
let i = 1e-9 * Math.max(1, Math.abs(e));
|
|
2660
2792
|
if (t !== void 0 && e < t - i) return `不能小于 ${t}`;
|
|
2661
2793
|
if (n !== void 0 && e > n + i) return `不能大于 ${n}`;
|
|
@@ -2663,28 +2795,28 @@ function pt(e, t, n, r) {
|
|
|
2663
2795
|
let a = (e - (t ?? 0)) / r;
|
|
2664
2796
|
return Math.abs(a - Math.round(a)) > 1e-9 * Math.max(1, Math.abs(a)) ? `需要按步长 ${r} 取值` : null;
|
|
2665
2797
|
}
|
|
2666
|
-
function
|
|
2667
|
-
let t =
|
|
2668
|
-
M.current =
|
|
2669
|
-
j.current !==
|
|
2670
|
-
}, [
|
|
2671
|
-
A.current = !1,
|
|
2798
|
+
function Nt({ node: e }) {
|
|
2799
|
+
let t = g(), { runtime: n } = G(), { write: r, error: i, setError: a } = X(e), o = q(n, e, "label", "数字"), { disabled: s, invalid: c } = ht(e), l = K(e, "min") !== void 0, u = K(e, "max") !== void 0, d = l ? J(n, e, "min", 0) : void 0, f = u ? J(n, e, "max", 0) : void 0, p = J(n, e, "step", 1), m = Y(n, e), _ = typeof m == "number" && Number.isFinite(m) ? String(m) : "", [b, x] = y(_), [w, T] = y(!1), [E, D] = y(!1), [O, k] = y(null), A = v(!1), j = v(_), M = v(_);
|
|
2800
|
+
M.current = _, h(() => {
|
|
2801
|
+
j.current !== _ && (j.current = _, !w && !A.current && x(_));
|
|
2802
|
+
}, [_, w]), gt(n, e, () => {
|
|
2803
|
+
A.current = !1, x(M.current), D(!1), k(null), a(null);
|
|
2672
2804
|
});
|
|
2673
2805
|
let N = (e, t) => {
|
|
2674
|
-
let n =
|
|
2806
|
+
let n = jt(e);
|
|
2675
2807
|
if (n.kind !== "valid") return t && k("请输入有效数字"), !1;
|
|
2676
|
-
let i =
|
|
2808
|
+
let i = Mt(n.value, d, f, p);
|
|
2677
2809
|
return i ? (t && k(i), !1) : (k(null), r(n.value));
|
|
2678
2810
|
};
|
|
2679
|
-
return /* @__PURE__ */
|
|
2811
|
+
return /* @__PURE__ */ C("div", {
|
|
2680
2812
|
className: "md-control local-number",
|
|
2681
2813
|
children: [
|
|
2682
|
-
/* @__PURE__ */
|
|
2814
|
+
/* @__PURE__ */ S("label", {
|
|
2683
2815
|
className: "md-label",
|
|
2684
2816
|
htmlFor: `${t}-number`,
|
|
2685
2817
|
children: o
|
|
2686
2818
|
}),
|
|
2687
|
-
/* @__PURE__ */
|
|
2819
|
+
/* @__PURE__ */ S("input", {
|
|
2688
2820
|
id: `${t}-number`,
|
|
2689
2821
|
className: "md-text-input",
|
|
2690
2822
|
type: "text",
|
|
@@ -2698,7 +2830,7 @@ function mt({ node: e }) {
|
|
|
2698
2830
|
},
|
|
2699
2831
|
onChange: (e) => {
|
|
2700
2832
|
let t = e.target.value;
|
|
2701
|
-
|
|
2833
|
+
x(t), a(null), A.current || N(t, E);
|
|
2702
2834
|
},
|
|
2703
2835
|
onCompositionStart: () => {
|
|
2704
2836
|
A.current = !0;
|
|
@@ -2707,7 +2839,7 @@ function mt({ node: e }) {
|
|
|
2707
2839
|
A.current = !1, N(e.currentTarget.value, E);
|
|
2708
2840
|
}
|
|
2709
2841
|
}),
|
|
2710
|
-
d !== void 0 || f !== void 0 || p !== void 0 ? /* @__PURE__ */
|
|
2842
|
+
d !== void 0 || f !== void 0 || p !== void 0 ? /* @__PURE__ */ C("span", {
|
|
2711
2843
|
className: "md-hint",
|
|
2712
2844
|
children: [
|
|
2713
2845
|
d === void 0 ? "" : `最小 ${d}`,
|
|
@@ -2716,25 +2848,25 @@ function mt({ node: e }) {
|
|
|
2716
2848
|
p === void 0 ? "" : ` · 步长 ${p}`
|
|
2717
2849
|
]
|
|
2718
2850
|
}) : null,
|
|
2719
|
-
/* @__PURE__ */
|
|
2851
|
+
/* @__PURE__ */ S($, { message: c ? "无法计算" : O ?? i })
|
|
2720
2852
|
]
|
|
2721
2853
|
});
|
|
2722
2854
|
}
|
|
2723
|
-
function
|
|
2724
|
-
let t =
|
|
2725
|
-
return /* @__PURE__ */
|
|
2855
|
+
function Pt({ node: e }) {
|
|
2856
|
+
let t = g(), { runtime: n } = G(), { write: r, error: i } = X(e), a = q(n, e, "label", "滑块"), { disabled: o, invalid: s } = ht(e), c = J(n, e, "min", 0), l = J(n, e, "max", 100), u = J(n, e, "step", 1), d = Y(n, e), f = Math.min(l, Math.max(c, typeof d == "number" && Number.isFinite(d) ? d : c));
|
|
2857
|
+
return /* @__PURE__ */ C("div", {
|
|
2726
2858
|
className: "md-control md-slider local-slider",
|
|
2727
2859
|
children: [
|
|
2728
|
-
/* @__PURE__ */
|
|
2860
|
+
/* @__PURE__ */ C("label", {
|
|
2729
2861
|
className: "md-label",
|
|
2730
2862
|
htmlFor: `${t}-slider`,
|
|
2731
|
-
children: [/* @__PURE__ */
|
|
2863
|
+
children: [/* @__PURE__ */ S("span", { children: a }), /* @__PURE__ */ S("span", {
|
|
2732
2864
|
className: "md-slider-value",
|
|
2733
2865
|
"aria-hidden": "true",
|
|
2734
2866
|
children: f
|
|
2735
2867
|
})]
|
|
2736
2868
|
}),
|
|
2737
|
-
/* @__PURE__ */
|
|
2869
|
+
/* @__PURE__ */ S("input", {
|
|
2738
2870
|
id: `${t}-slider`,
|
|
2739
2871
|
type: "range",
|
|
2740
2872
|
min: c,
|
|
@@ -2744,55 +2876,55 @@ function ht({ node: e }) {
|
|
|
2744
2876
|
disabled: o,
|
|
2745
2877
|
onChange: (e) => r(Number(e.target.value))
|
|
2746
2878
|
}),
|
|
2747
|
-
/* @__PURE__ */
|
|
2879
|
+
/* @__PURE__ */ S($, { message: s ? "无法计算" : i })
|
|
2748
2880
|
]
|
|
2749
2881
|
});
|
|
2750
2882
|
}
|
|
2751
|
-
function
|
|
2752
|
-
let t =
|
|
2753
|
-
return /* @__PURE__ */
|
|
2883
|
+
function Ft({ node: e }) {
|
|
2884
|
+
let t = g(), { runtime: n } = G(), { write: r, error: i } = X(e), a = q(n, e, "label", "开关"), { disabled: o, invalid: s } = ht(e), c = Y(n, e) === !0;
|
|
2885
|
+
return /* @__PURE__ */ C("div", {
|
|
2754
2886
|
className: "md-control md-toggle local-toggle",
|
|
2755
|
-
children: [/* @__PURE__ */
|
|
2887
|
+
children: [/* @__PURE__ */ C("label", {
|
|
2756
2888
|
className: "md-toggle-label",
|
|
2757
2889
|
htmlFor: `${t}-toggle`,
|
|
2758
|
-
children: [/* @__PURE__ */
|
|
2890
|
+
children: [/* @__PURE__ */ S("input", {
|
|
2759
2891
|
id: `${t}-toggle`,
|
|
2760
2892
|
type: "checkbox",
|
|
2761
2893
|
checked: c,
|
|
2762
2894
|
disabled: o,
|
|
2763
2895
|
onChange: (e) => r(e.target.checked)
|
|
2764
|
-
}), /* @__PURE__ */
|
|
2765
|
-
}), /* @__PURE__ */
|
|
2896
|
+
}), /* @__PURE__ */ S("span", { children: a })]
|
|
2897
|
+
}), /* @__PURE__ */ S($, { message: s ? "无法计算" : i })]
|
|
2766
2898
|
});
|
|
2767
2899
|
}
|
|
2768
|
-
function
|
|
2769
|
-
let t =
|
|
2770
|
-
return /* @__PURE__ */
|
|
2900
|
+
function It({ node: e }) {
|
|
2901
|
+
let t = g(), { runtime: n } = G(), { write: r, error: i } = X(e), a = q(n, e, "label", "勾选"), { disabled: o, invalid: s } = ht(e), c = Y(n, e) === !0;
|
|
2902
|
+
return /* @__PURE__ */ C("div", {
|
|
2771
2903
|
className: "md-control local-checkbox",
|
|
2772
|
-
children: [/* @__PURE__ */
|
|
2904
|
+
children: [/* @__PURE__ */ C("label", {
|
|
2773
2905
|
className: "md-toggle-label",
|
|
2774
2906
|
htmlFor: `${t}-checkbox`,
|
|
2775
|
-
children: [/* @__PURE__ */
|
|
2907
|
+
children: [/* @__PURE__ */ S("input", {
|
|
2776
2908
|
id: `${t}-checkbox`,
|
|
2777
2909
|
type: "checkbox",
|
|
2778
2910
|
checked: c,
|
|
2779
2911
|
disabled: o,
|
|
2780
2912
|
onChange: (e) => r(e.target.checked)
|
|
2781
|
-
}), /* @__PURE__ */
|
|
2782
|
-
}), /* @__PURE__ */
|
|
2913
|
+
}), /* @__PURE__ */ S("span", { children: a })]
|
|
2914
|
+
}), /* @__PURE__ */ S($, { message: s ? "无法计算" : i })]
|
|
2783
2915
|
});
|
|
2784
2916
|
}
|
|
2785
|
-
function
|
|
2786
|
-
let t =
|
|
2787
|
-
return /* @__PURE__ */
|
|
2917
|
+
function Lt({ node: e }) {
|
|
2918
|
+
let t = g(), { runtime: n } = G(), { write: r, error: i } = X(e), a = q(n, e, "label", "日期"), { disabled: o, invalid: s } = ht(e), c = ft(n, e, "required", !1), l = q(n, e, "min", ""), u = q(n, e, "max", ""), d = Y(n, e), f = typeof d == "string" ? d : "", [p, m] = y(!1), h = p && c && f === "" ? "请选择日期" : null;
|
|
2919
|
+
return /* @__PURE__ */ C("div", {
|
|
2788
2920
|
className: "md-control local-date",
|
|
2789
2921
|
children: [
|
|
2790
|
-
/* @__PURE__ */
|
|
2922
|
+
/* @__PURE__ */ S("label", {
|
|
2791
2923
|
className: "md-label",
|
|
2792
2924
|
htmlFor: `${t}-date`,
|
|
2793
2925
|
children: a
|
|
2794
2926
|
}),
|
|
2795
|
-
/* @__PURE__ */
|
|
2927
|
+
/* @__PURE__ */ S("input", {
|
|
2796
2928
|
id: `${t}-date`,
|
|
2797
2929
|
className: "md-text-input",
|
|
2798
2930
|
type: "date",
|
|
@@ -2801,93 +2933,94 @@ function vt({ node: e }) {
|
|
|
2801
2933
|
max: u || void 0,
|
|
2802
2934
|
required: c,
|
|
2803
2935
|
disabled: o,
|
|
2804
|
-
"aria-invalid":
|
|
2936
|
+
"aria-invalid": h || i ? !0 : void 0,
|
|
2805
2937
|
onBlur: () => m(!0),
|
|
2806
2938
|
onChange: (e) => {
|
|
2807
2939
|
m(!0), r(e.target.value);
|
|
2808
2940
|
}
|
|
2809
2941
|
}),
|
|
2810
|
-
/* @__PURE__ */
|
|
2942
|
+
/* @__PURE__ */ S($, { message: s ? "无法计算" : h ?? i })
|
|
2811
2943
|
]
|
|
2812
2944
|
});
|
|
2813
2945
|
}
|
|
2814
|
-
function
|
|
2946
|
+
function Rt(e) {
|
|
2815
2947
|
return (e.children ?? []).filter((e) => e.type === "component" && e.name === "option").map((e, t) => ({
|
|
2816
2948
|
value: K(e, "value") ?? `option-${t + 1}`,
|
|
2817
2949
|
node: e
|
|
2818
2950
|
}));
|
|
2819
2951
|
}
|
|
2820
|
-
function
|
|
2952
|
+
function zt(e, t) {
|
|
2821
2953
|
if (!t) return "";
|
|
2822
2954
|
let n = "";
|
|
2823
2955
|
for (let r of t) if (r.type === "text" || r.type === "inlineCode") n += r.value ?? "";
|
|
2956
|
+
else if (r.type === "fallback") n += r.value ?? "";
|
|
2824
2957
|
else if (r.type === "interpolation") try {
|
|
2825
|
-
n +=
|
|
2958
|
+
n += ut(e.evaluate(r.value ?? "")) ?? "";
|
|
2826
2959
|
} catch {
|
|
2827
2960
|
n += "无法计算";
|
|
2828
2961
|
}
|
|
2829
|
-
else r.type === "break" ? n += " " : n +=
|
|
2962
|
+
else r.type === "break" ? n += " " : n += zt(e, r.children);
|
|
2830
2963
|
return n;
|
|
2831
2964
|
}
|
|
2832
|
-
function
|
|
2833
|
-
return
|
|
2965
|
+
function Bt(e, t) {
|
|
2966
|
+
return zt(e, t.children) || K(t, "value") || "";
|
|
2834
2967
|
}
|
|
2835
|
-
function
|
|
2968
|
+
function Vt() {
|
|
2836
2969
|
return null;
|
|
2837
2970
|
}
|
|
2838
|
-
function
|
|
2839
|
-
let t =
|
|
2840
|
-
return c.length === 0 ? /* @__PURE__ */
|
|
2971
|
+
function Ht({ node: e }) {
|
|
2972
|
+
let t = g(), { runtime: n } = G(), { write: r, error: i } = X(e), a = q(n, e, "label", "选择"), { disabled: o, invalid: s } = ht(e), c = Rt(e), l = Y(n, e), u = typeof l == "string" ? l : "", d = c.some((e) => e.value === u) ? u : c[0]?.value ?? "";
|
|
2973
|
+
return c.length === 0 ? /* @__PURE__ */ S(Z, { message: "缺少选项" }) : /* @__PURE__ */ C("div", {
|
|
2841
2974
|
className: "md-control md-select local-select",
|
|
2842
2975
|
children: [
|
|
2843
|
-
/* @__PURE__ */
|
|
2976
|
+
/* @__PURE__ */ S("label", {
|
|
2844
2977
|
className: "md-label",
|
|
2845
2978
|
htmlFor: `${t}-select`,
|
|
2846
2979
|
children: a
|
|
2847
2980
|
}),
|
|
2848
|
-
/* @__PURE__ */
|
|
2981
|
+
/* @__PURE__ */ S("select", {
|
|
2849
2982
|
id: `${t}-select`,
|
|
2850
2983
|
className: "md-select-input",
|
|
2851
2984
|
value: d,
|
|
2852
2985
|
disabled: o,
|
|
2853
2986
|
onChange: (e) => r(e.target.value),
|
|
2854
|
-
children: c.map((e) => /* @__PURE__ */
|
|
2987
|
+
children: c.map((e) => /* @__PURE__ */ S("option", {
|
|
2855
2988
|
value: e.value,
|
|
2856
|
-
children:
|
|
2989
|
+
children: Bt(n, e.node) || e.value
|
|
2857
2990
|
}, e.node.id))
|
|
2858
2991
|
}),
|
|
2859
|
-
/* @__PURE__ */
|
|
2992
|
+
/* @__PURE__ */ S($, { message: s ? "无法计算" : i })
|
|
2860
2993
|
]
|
|
2861
2994
|
});
|
|
2862
2995
|
}
|
|
2863
|
-
function
|
|
2864
|
-
let n =
|
|
2865
|
-
if (u.length === 0) return /* @__PURE__ */
|
|
2866
|
-
let
|
|
2996
|
+
function Ut({ node: e, visible: t }) {
|
|
2997
|
+
let n = g(), r = G(), { runtime: i } = r, { write: a, error: o } = X(e), s = q(i, e, "label", "选项"), { disabled: c, invalid: l } = ht(e), u = Rt(e), d = Y(i, e), f = typeof d == "string" ? d : "", p = u.findIndex((e) => e.value === f), m = p >= 0 ? p : 0, h = v([]);
|
|
2998
|
+
if (u.length === 0) return /* @__PURE__ */ S(Z, { message: "缺少选项" });
|
|
2999
|
+
let _ = (e) => {
|
|
2867
3000
|
let t = u[e];
|
|
2868
|
-
t && (a(t.value),
|
|
3001
|
+
t && (a(t.value), h.current[e]?.focus());
|
|
2869
3002
|
}, y = (e, t) => {
|
|
2870
3003
|
let n = -1;
|
|
2871
|
-
e.key === "ArrowRight" || e.key === "ArrowDown" ? n = (t + 1) % u.length : e.key === "ArrowLeft" || e.key === "ArrowUp" ? n = (t - 1 + u.length) % u.length : e.key === "Home" ? n = 0 : e.key === "End" && (n = u.length - 1), !(n < 0) && (e.preventDefault(),
|
|
3004
|
+
e.key === "ArrowRight" || e.key === "ArrowDown" ? n = (t + 1) % u.length : e.key === "ArrowLeft" || e.key === "ArrowUp" ? n = (t - 1 + u.length) % u.length : e.key === "Home" ? n = 0 : e.key === "End" && (n = u.length - 1), !(n < 0) && (e.preventDefault(), _(n));
|
|
2872
3005
|
};
|
|
2873
|
-
return /* @__PURE__ */
|
|
3006
|
+
return /* @__PURE__ */ C("div", {
|
|
2874
3007
|
className: "md-control local-choices",
|
|
2875
3008
|
children: [
|
|
2876
|
-
/* @__PURE__ */
|
|
3009
|
+
/* @__PURE__ */ S("span", {
|
|
2877
3010
|
className: "md-label",
|
|
2878
3011
|
id: `${n}-choices-label`,
|
|
2879
3012
|
children: s
|
|
2880
3013
|
}),
|
|
2881
|
-
/* @__PURE__ */
|
|
3014
|
+
/* @__PURE__ */ S("div", {
|
|
2882
3015
|
className: "local-choice-list",
|
|
2883
3016
|
role: "radiogroup",
|
|
2884
3017
|
"aria-labelledby": `${n}-choices-label`,
|
|
2885
3018
|
"aria-disabled": c || void 0,
|
|
2886
3019
|
children: u.map((e, n) => {
|
|
2887
3020
|
let i = e.value === f;
|
|
2888
|
-
return /* @__PURE__ */
|
|
3021
|
+
return /* @__PURE__ */ S("button", {
|
|
2889
3022
|
ref: (e) => {
|
|
2890
|
-
|
|
3023
|
+
h.current[n] = e;
|
|
2891
3024
|
},
|
|
2892
3025
|
type: "button",
|
|
2893
3026
|
role: "radio",
|
|
@@ -2897,98 +3030,98 @@ function wt({ node: e, visible: t }) {
|
|
|
2897
3030
|
className: `local-choice${i ? " is-selected" : ""}`,
|
|
2898
3031
|
onClick: () => a(e.value),
|
|
2899
3032
|
onKeyDown: (e) => y(e, n),
|
|
2900
|
-
children:
|
|
3033
|
+
children: Ct(r, e.node.children, t)
|
|
2901
3034
|
}, e.node.id);
|
|
2902
3035
|
})
|
|
2903
3036
|
}),
|
|
2904
|
-
/* @__PURE__ */
|
|
3037
|
+
/* @__PURE__ */ S($, { message: l ? "无法计算" : o })
|
|
2905
3038
|
]
|
|
2906
3039
|
});
|
|
2907
3040
|
}
|
|
2908
|
-
function
|
|
2909
|
-
let n =
|
|
2910
|
-
return u.length === 0 ? /* @__PURE__ */
|
|
3041
|
+
function Wt({ node: e, visible: t }) {
|
|
3042
|
+
let n = g(), r = G(), { runtime: i } = r, { write: a, error: o } = X(e), s = q(i, e, "label", "选项"), { disabled: c, invalid: l } = ht(e), u = Rt(e), d = Y(i, e), f = typeof d == "string" ? d : "", p = n;
|
|
3043
|
+
return u.length === 0 ? /* @__PURE__ */ S(Z, { message: "缺少选项" }) : /* @__PURE__ */ C("fieldset", {
|
|
2911
3044
|
className: "md-control local-radio-group",
|
|
2912
3045
|
disabled: c,
|
|
2913
3046
|
children: [
|
|
2914
|
-
/* @__PURE__ */
|
|
3047
|
+
/* @__PURE__ */ S("legend", {
|
|
2915
3048
|
className: "md-label",
|
|
2916
3049
|
children: s
|
|
2917
3050
|
}),
|
|
2918
|
-
u.map((e) => /* @__PURE__ */
|
|
3051
|
+
u.map((e) => /* @__PURE__ */ C("label", {
|
|
2919
3052
|
className: "local-radio-option",
|
|
2920
|
-
children: [/* @__PURE__ */
|
|
3053
|
+
children: [/* @__PURE__ */ S("input", {
|
|
2921
3054
|
type: "radio",
|
|
2922
3055
|
name: p,
|
|
2923
3056
|
value: e.value,
|
|
2924
3057
|
checked: f === e.value,
|
|
2925
3058
|
onChange: () => a(e.value)
|
|
2926
|
-
}), /* @__PURE__ */
|
|
3059
|
+
}), /* @__PURE__ */ S("span", { children: Ct(r, e.node.children, t) })]
|
|
2927
3060
|
}, e.node.id)),
|
|
2928
|
-
/* @__PURE__ */
|
|
3061
|
+
/* @__PURE__ */ S($, { message: l ? "无法计算" : o })
|
|
2929
3062
|
]
|
|
2930
3063
|
});
|
|
2931
3064
|
}
|
|
2932
|
-
function
|
|
3065
|
+
function Gt(e) {
|
|
2933
3066
|
return ((e.children ?? []).find((e) => e.type === "list")?.children ?? []).filter((e) => e.type === "listItem").map((e, t) => ({
|
|
2934
3067
|
id: `item-${t + 1}`,
|
|
2935
3068
|
node: e
|
|
2936
3069
|
}));
|
|
2937
3070
|
}
|
|
2938
|
-
function
|
|
2939
|
-
let n =
|
|
2940
|
-
if (u.length === 0) return /* @__PURE__ */
|
|
3071
|
+
function Kt({ node: e, visible: t }) {
|
|
3072
|
+
let n = g(), r = G(), { runtime: i } = r, { write: a, error: o } = X(e), s = q(i, e, "label", "清单"), { disabled: c, invalid: l } = ht(e), u = Gt(e), d = Y(i, e), f = Array.isArray(d) ? d.filter((e) => typeof e == "string") : [];
|
|
3073
|
+
if (u.length === 0) return /* @__PURE__ */ S(Z, { message: "清单需要任务列表" });
|
|
2941
3074
|
let p = (e, t) => {
|
|
2942
3075
|
let n = new Set(f);
|
|
2943
3076
|
t ? n.add(e) : n.delete(e), a(u.filter((e) => n.has(e.id)).map((e) => e.id));
|
|
2944
3077
|
};
|
|
2945
|
-
return /* @__PURE__ */
|
|
3078
|
+
return /* @__PURE__ */ C("fieldset", {
|
|
2946
3079
|
className: "local-checklist",
|
|
2947
3080
|
disabled: c,
|
|
2948
3081
|
children: [
|
|
2949
|
-
/* @__PURE__ */
|
|
3082
|
+
/* @__PURE__ */ S("legend", {
|
|
2950
3083
|
className: "md-label",
|
|
2951
3084
|
children: s
|
|
2952
3085
|
}),
|
|
2953
|
-
u.map((e) => /* @__PURE__ */
|
|
3086
|
+
u.map((e) => /* @__PURE__ */ C("div", {
|
|
2954
3087
|
className: "local-checklist-item",
|
|
2955
|
-
children: [/* @__PURE__ */
|
|
3088
|
+
children: [/* @__PURE__ */ S("input", {
|
|
2956
3089
|
id: `${n}-${e.id}`,
|
|
2957
3090
|
type: "checkbox",
|
|
2958
3091
|
checked: f.includes(e.id),
|
|
2959
3092
|
onChange: (t) => p(e.id, t.target.checked)
|
|
2960
|
-
}), /* @__PURE__ */
|
|
3093
|
+
}), /* @__PURE__ */ S("label", {
|
|
2961
3094
|
className: "local-checklist-text",
|
|
2962
3095
|
htmlFor: `${n}-${e.id}`,
|
|
2963
|
-
children:
|
|
3096
|
+
children: Ct(r, e.node.children, t)
|
|
2964
3097
|
})]
|
|
2965
3098
|
}, e.id)),
|
|
2966
|
-
/* @__PURE__ */
|
|
3099
|
+
/* @__PURE__ */ S($, { message: l ? "无法计算" : o })
|
|
2967
3100
|
]
|
|
2968
3101
|
});
|
|
2969
3102
|
}
|
|
2970
|
-
function
|
|
3103
|
+
function qt(e) {
|
|
2971
3104
|
let t = Math.max(0, Math.floor(e)), n = Math.floor(t / 60), r = t % 60;
|
|
2972
3105
|
return n === 0 ? `${r} 秒` : `${n}:${String(r).padStart(2, "0")}`;
|
|
2973
3106
|
}
|
|
2974
|
-
function
|
|
2975
|
-
let { runtime: t } = G(), { write: n, error: r } = X(e), i = q(t, e, "label", "计数"), { disabled: a, invalid: o } =
|
|
3107
|
+
function Jt({ node: e }) {
|
|
3108
|
+
let { runtime: t } = G(), { write: n, error: r } = X(e), i = q(t, e, "label", "计数"), { disabled: a, invalid: o } = ht(e), s = J(t, e, "min", 0), c = K(e, "max") === void 0 ? void 0 : J(t, e, "max", 0), l = J(t, e, "step", 1), u = Y(t, e), d = typeof u == "number" && Number.isFinite(u) ? u : s, f = Number.isFinite(l) && l > 0 ? l : 1, p = 1e-9 * Math.max(1, Math.abs(d)), m = d - f >= s - p, h = c === void 0 || d + f <= c + p, g = (e) => {
|
|
2976
3109
|
let t = Number((d + e * f).toFixed(12));
|
|
2977
3110
|
n(t);
|
|
2978
3111
|
};
|
|
2979
|
-
return /* @__PURE__ */
|
|
3112
|
+
return /* @__PURE__ */ C("div", {
|
|
2980
3113
|
className: "local-counter",
|
|
2981
3114
|
role: "group",
|
|
2982
3115
|
"aria-label": i,
|
|
2983
3116
|
children: [
|
|
2984
|
-
/* @__PURE__ */
|
|
3117
|
+
/* @__PURE__ */ S("span", {
|
|
2985
3118
|
className: "md-label",
|
|
2986
3119
|
children: i
|
|
2987
3120
|
}),
|
|
2988
|
-
/* @__PURE__ */
|
|
3121
|
+
/* @__PURE__ */ C("div", {
|
|
2989
3122
|
className: "local-counter-row",
|
|
2990
3123
|
children: [
|
|
2991
|
-
/* @__PURE__ */
|
|
3124
|
+
/* @__PURE__ */ S("button", {
|
|
2992
3125
|
type: "button",
|
|
2993
3126
|
className: "md-button md-button-secondary local-counter-button",
|
|
2994
3127
|
"aria-label": `${i} 减少`,
|
|
@@ -2996,12 +3129,12 @@ function kt({ node: e }) {
|
|
|
2996
3129
|
onClick: () => g(-1),
|
|
2997
3130
|
children: "−"
|
|
2998
3131
|
}),
|
|
2999
|
-
/* @__PURE__ */
|
|
3132
|
+
/* @__PURE__ */ S("span", {
|
|
3000
3133
|
className: "local-counter-value",
|
|
3001
3134
|
"aria-live": "polite",
|
|
3002
3135
|
children: d
|
|
3003
3136
|
}),
|
|
3004
|
-
/* @__PURE__ */
|
|
3137
|
+
/* @__PURE__ */ S("button", {
|
|
3005
3138
|
type: "button",
|
|
3006
3139
|
className: "md-button md-button-secondary local-counter-button",
|
|
3007
3140
|
"aria-label": `${i} 增加`,
|
|
@@ -3009,7 +3142,7 @@ function kt({ node: e }) {
|
|
|
3009
3142
|
onClick: () => g(1),
|
|
3010
3143
|
children: "+"
|
|
3011
3144
|
}),
|
|
3012
|
-
/* @__PURE__ */
|
|
3145
|
+
/* @__PURE__ */ S("button", {
|
|
3013
3146
|
type: "button",
|
|
3014
3147
|
className: "md-button md-button-quiet local-counter-reset",
|
|
3015
3148
|
disabled: a,
|
|
@@ -3022,83 +3155,83 @@ function kt({ node: e }) {
|
|
|
3022
3155
|
})
|
|
3023
3156
|
]
|
|
3024
3157
|
}),
|
|
3025
|
-
/* @__PURE__ */
|
|
3158
|
+
/* @__PURE__ */ S($, { message: o ? "无法计算" : r })
|
|
3026
3159
|
]
|
|
3027
3160
|
});
|
|
3028
3161
|
}
|
|
3029
|
-
function
|
|
3030
|
-
let { runtime: n } = G(), r = q(n, e, "label", "计时器"), i = J(n, e, "duration", 60), a = Math.floor(i), o = Y(n, e), s = typeof o == "number" && Number.isFinite(o) ? Math.max(0, Math.ceil(o)) : a, [c, l] =
|
|
3031
|
-
|
|
3032
|
-
let [g,
|
|
3162
|
+
function Yt({ node: e, visible: t }) {
|
|
3163
|
+
let { runtime: n } = G(), r = q(n, e, "label", "计时器"), i = J(n, e, "duration", 60), a = Math.floor(i), o = Y(n, e), s = typeof o == "number" && Number.isFinite(o) ? Math.max(0, Math.ceil(o)) : a, [c, l] = y(!1), [u, d] = y(!1), f = v(0), m = v(s);
|
|
3164
|
+
m.current = s;
|
|
3165
|
+
let [g, _] = y(null), b = p((t) => {
|
|
3033
3166
|
try {
|
|
3034
3167
|
let r = n.set(e, t);
|
|
3035
|
-
r.length &&
|
|
3168
|
+
r.length && _(r.map((e) => e.message).join(";"));
|
|
3036
3169
|
} catch {}
|
|
3037
3170
|
}, [e, n]);
|
|
3038
|
-
return
|
|
3171
|
+
return h(() => {
|
|
3039
3172
|
if (!c) return;
|
|
3040
3173
|
let e = window.setInterval(() => {
|
|
3041
|
-
let e = Math.max(0, Math.ceil((
|
|
3042
|
-
e !==
|
|
3174
|
+
let e = Math.max(0, Math.ceil((f.current - performance.now()) / 1e3));
|
|
3175
|
+
e !== m.current && (m.current = e, b(e)), e <= 0 && (l(!1), d(!0));
|
|
3043
3176
|
}, 200);
|
|
3044
3177
|
return () => window.clearInterval(e);
|
|
3045
|
-
}, [c, b]),
|
|
3178
|
+
}, [c, b]), h(() => {
|
|
3046
3179
|
if (t || !c) return;
|
|
3047
|
-
let e = Math.max(0, Math.ceil((
|
|
3048
|
-
|
|
3180
|
+
let e = Math.max(0, Math.ceil((f.current - performance.now()) / 1e3));
|
|
3181
|
+
m.current = e, b(e), l(!1);
|
|
3049
3182
|
}, [
|
|
3050
3183
|
t,
|
|
3051
3184
|
c,
|
|
3052
3185
|
b
|
|
3053
|
-
]),
|
|
3054
|
-
l(!1), d(!1),
|
|
3055
|
-
}), !Number.isFinite(i) || a <= 0 ? /* @__PURE__ */
|
|
3186
|
+
]), gt(n, e, () => {
|
|
3187
|
+
l(!1), d(!1), _(null);
|
|
3188
|
+
}), !Number.isFinite(i) || a <= 0 ? /* @__PURE__ */ S(Z, { message: "计时时长必须是大于 0 的秒数" }) : /* @__PURE__ */ C("div", {
|
|
3056
3189
|
className: "local-timer",
|
|
3057
3190
|
role: "group",
|
|
3058
3191
|
"aria-label": r,
|
|
3059
3192
|
children: [
|
|
3060
|
-
/* @__PURE__ */
|
|
3193
|
+
/* @__PURE__ */ C("div", {
|
|
3061
3194
|
className: "local-timer-head",
|
|
3062
|
-
children: [/* @__PURE__ */
|
|
3195
|
+
children: [/* @__PURE__ */ S("span", {
|
|
3063
3196
|
className: "md-label",
|
|
3064
3197
|
children: r
|
|
3065
|
-
}), /* @__PURE__ */
|
|
3198
|
+
}), /* @__PURE__ */ S("span", {
|
|
3066
3199
|
className: "local-timer-value",
|
|
3067
3200
|
role: "timer",
|
|
3068
3201
|
"aria-label": `剩余 ${s} 秒`,
|
|
3069
|
-
children:
|
|
3202
|
+
children: qt(s)
|
|
3070
3203
|
})]
|
|
3071
3204
|
}),
|
|
3072
|
-
/* @__PURE__ */
|
|
3205
|
+
/* @__PURE__ */ C("div", {
|
|
3073
3206
|
className: "local-timer-controls",
|
|
3074
3207
|
children: [
|
|
3075
|
-
/* @__PURE__ */
|
|
3208
|
+
/* @__PURE__ */ S("button", {
|
|
3076
3209
|
type: "button",
|
|
3077
3210
|
className: "md-button md-button-primary",
|
|
3078
3211
|
onClick: () => {
|
|
3079
3212
|
if (c) return;
|
|
3080
3213
|
let e = s > 0 ? s : a;
|
|
3081
|
-
s <= 0 && (
|
|
3214
|
+
s <= 0 && (m.current = a, b(a)), f.current = performance.now() + e * 1e3, d(!1), _(null), l(!0);
|
|
3082
3215
|
},
|
|
3083
3216
|
disabled: c,
|
|
3084
3217
|
children: "开始"
|
|
3085
3218
|
}),
|
|
3086
|
-
/* @__PURE__ */
|
|
3219
|
+
/* @__PURE__ */ S("button", {
|
|
3087
3220
|
type: "button",
|
|
3088
3221
|
className: "md-button md-button-secondary",
|
|
3089
3222
|
onClick: () => {
|
|
3090
3223
|
if (!c) return;
|
|
3091
|
-
let e = Math.max(0, Math.ceil((
|
|
3092
|
-
|
|
3224
|
+
let e = Math.max(0, Math.ceil((f.current - performance.now()) / 1e3));
|
|
3225
|
+
m.current = e, b(e), l(!1);
|
|
3093
3226
|
},
|
|
3094
3227
|
disabled: !c,
|
|
3095
3228
|
children: "暂停"
|
|
3096
3229
|
}),
|
|
3097
|
-
/* @__PURE__ */
|
|
3230
|
+
/* @__PURE__ */ S("button", {
|
|
3098
3231
|
type: "button",
|
|
3099
3232
|
className: "md-button md-button-quiet",
|
|
3100
3233
|
onClick: () => {
|
|
3101
|
-
l(!1), d(!1),
|
|
3234
|
+
l(!1), d(!1), _(null), m.current = a;
|
|
3102
3235
|
try {
|
|
3103
3236
|
n.reset(e);
|
|
3104
3237
|
} catch {}
|
|
@@ -3107,61 +3240,61 @@ function At({ node: e, visible: t }) {
|
|
|
3107
3240
|
})
|
|
3108
3241
|
]
|
|
3109
3242
|
}),
|
|
3110
|
-
/* @__PURE__ */
|
|
3243
|
+
/* @__PURE__ */ S("span", {
|
|
3111
3244
|
className: "local-timer-status",
|
|
3112
3245
|
role: "status",
|
|
3113
3246
|
"aria-live": "polite",
|
|
3114
3247
|
children: u ? "计时完成" : c ? "计时中" : "已暂停"
|
|
3115
3248
|
}),
|
|
3116
|
-
/* @__PURE__ */
|
|
3249
|
+
/* @__PURE__ */ S($, { message: g })
|
|
3117
3250
|
]
|
|
3118
3251
|
});
|
|
3119
3252
|
}
|
|
3120
|
-
function
|
|
3121
|
-
let { runtime: t } = G(), n = q(t, e, "label", "进度"), r = J(t, e, "max", 100), i =
|
|
3122
|
-
if (!Number.isFinite(r) || r <= 0) return /* @__PURE__ */
|
|
3123
|
-
if (!i.present || !i.ok) return /* @__PURE__ */
|
|
3253
|
+
function Xt({ node: e }) {
|
|
3254
|
+
let { runtime: t } = G(), n = q(t, e, "label", "进度"), r = J(t, e, "max", 100), i = lt(t, e, "value");
|
|
3255
|
+
if (!Number.isFinite(r) || r <= 0) return /* @__PURE__ */ S(Z, { message: "进度上限必须是正数" });
|
|
3256
|
+
if (!i.present || !i.ok) return /* @__PURE__ */ S(Z, {});
|
|
3124
3257
|
let a = i.value, o = typeof a == "number" ? a : typeof a == "string" && a.trim() !== "" ? Number(a) : NaN;
|
|
3125
|
-
if (!Number.isFinite(o)) return /* @__PURE__ */
|
|
3126
|
-
if (o < 0 || o > r) return /* @__PURE__ */
|
|
3258
|
+
if (!Number.isFinite(o)) return /* @__PURE__ */ S(Z, {});
|
|
3259
|
+
if (o < 0 || o > r) return /* @__PURE__ */ S(Z, { message: `进度值需要在 0 到 ${r} 之间` });
|
|
3127
3260
|
let s = o / r * 100;
|
|
3128
|
-
return /* @__PURE__ */
|
|
3261
|
+
return /* @__PURE__ */ C("div", {
|
|
3129
3262
|
className: "local-progress",
|
|
3130
|
-
children: [/* @__PURE__ */
|
|
3263
|
+
children: [/* @__PURE__ */ C("div", {
|
|
3131
3264
|
className: "local-progress-head",
|
|
3132
|
-
children: [/* @__PURE__ */
|
|
3265
|
+
children: [/* @__PURE__ */ S("span", {
|
|
3133
3266
|
className: "md-label",
|
|
3134
3267
|
children: n
|
|
3135
|
-
}), /* @__PURE__ */
|
|
3268
|
+
}), /* @__PURE__ */ C("span", {
|
|
3136
3269
|
className: "local-progress-value",
|
|
3137
3270
|
children: [Math.round(s), "%"]
|
|
3138
3271
|
})]
|
|
3139
|
-
}), /* @__PURE__ */
|
|
3272
|
+
}), /* @__PURE__ */ S("div", {
|
|
3140
3273
|
className: "local-progress-track",
|
|
3141
3274
|
role: "progressbar",
|
|
3142
3275
|
"aria-label": n || "进度",
|
|
3143
3276
|
"aria-valuemin": 0,
|
|
3144
3277
|
"aria-valuemax": r,
|
|
3145
3278
|
"aria-valuenow": o,
|
|
3146
|
-
children: /* @__PURE__ */
|
|
3279
|
+
children: /* @__PURE__ */ S("div", {
|
|
3147
3280
|
className: "local-progress-fill",
|
|
3148
3281
|
style: { width: `${s}%` }
|
|
3149
3282
|
})
|
|
3150
3283
|
})]
|
|
3151
3284
|
});
|
|
3152
3285
|
}
|
|
3153
|
-
function
|
|
3154
|
-
let { runtime: n, render: r } = G(), i = q(n, e, "title", ""), a =
|
|
3155
|
-
return /* @__PURE__ */
|
|
3286
|
+
function Zt({ node: e, visible: t }) {
|
|
3287
|
+
let { runtime: n, render: r } = G(), i = q(n, e, "title", ""), a = ft(n, e, "reset", !0), [o, s] = y(null);
|
|
3288
|
+
return /* @__PURE__ */ C("section", {
|
|
3156
3289
|
className: "local-panel",
|
|
3157
3290
|
"aria-label": i || "参数面板",
|
|
3158
3291
|
children: [
|
|
3159
|
-
i || a ? /* @__PURE__ */
|
|
3292
|
+
i || a ? /* @__PURE__ */ C("div", {
|
|
3160
3293
|
className: "local-panel-head",
|
|
3161
|
-
children: [i ? /* @__PURE__ */
|
|
3294
|
+
children: [i ? /* @__PURE__ */ S("h3", {
|
|
3162
3295
|
className: "local-panel-title",
|
|
3163
3296
|
children: i
|
|
3164
|
-
}) : /* @__PURE__ */
|
|
3297
|
+
}) : /* @__PURE__ */ S("span", {}), a ? /* @__PURE__ */ S("button", {
|
|
3165
3298
|
type: "button",
|
|
3166
3299
|
className: "md-button md-button-quiet local-panel-reset",
|
|
3167
3300
|
onClick: () => {
|
|
@@ -3175,63 +3308,63 @@ function Mt({ node: e, visible: t }) {
|
|
|
3175
3308
|
children: "恢复默认"
|
|
3176
3309
|
}) : null]
|
|
3177
3310
|
}) : null,
|
|
3178
|
-
/* @__PURE__ */
|
|
3311
|
+
/* @__PURE__ */ S("div", {
|
|
3179
3312
|
className: "local-panel-body",
|
|
3180
3313
|
children: r(e.children ?? [], t)
|
|
3181
3314
|
}),
|
|
3182
|
-
/* @__PURE__ */
|
|
3315
|
+
/* @__PURE__ */ S($, { message: o })
|
|
3183
3316
|
]
|
|
3184
3317
|
});
|
|
3185
3318
|
}
|
|
3186
|
-
function
|
|
3319
|
+
function Qt({ node: e, visible: t }) {
|
|
3187
3320
|
let { runtime: n, render: r } = G(), i = q(n, e, "title", "");
|
|
3188
|
-
return /* @__PURE__ */
|
|
3321
|
+
return /* @__PURE__ */ C("section", {
|
|
3189
3322
|
className: "md-card local-card",
|
|
3190
|
-
children: [i ? /* @__PURE__ */
|
|
3323
|
+
children: [i ? /* @__PURE__ */ S("h3", {
|
|
3191
3324
|
className: "md-card-title",
|
|
3192
3325
|
children: i
|
|
3193
|
-
}) : null, /* @__PURE__ */
|
|
3326
|
+
}) : null, /* @__PURE__ */ S("div", {
|
|
3194
3327
|
className: "md-card-body",
|
|
3195
3328
|
children: r(e.children ?? [], t)
|
|
3196
3329
|
})]
|
|
3197
3330
|
});
|
|
3198
3331
|
}
|
|
3199
|
-
function
|
|
3332
|
+
function $t({ node: e, visible: t }) {
|
|
3200
3333
|
let { runtime: n, render: r } = G(), i = Math.min(4, Math.max(1, Math.floor(J(n, e, "columns", 2))));
|
|
3201
|
-
return /* @__PURE__ */
|
|
3334
|
+
return /* @__PURE__ */ S("div", {
|
|
3202
3335
|
className: "local-grid",
|
|
3203
3336
|
style: { "--local-grid-columns": String(i) },
|
|
3204
3337
|
children: r(e.children ?? [], t)
|
|
3205
3338
|
});
|
|
3206
3339
|
}
|
|
3207
|
-
function
|
|
3340
|
+
function en({ node: e, visible: t }) {
|
|
3208
3341
|
let { render: n } = G();
|
|
3209
|
-
return /* @__PURE__ */
|
|
3342
|
+
return /* @__PURE__ */ S("div", {
|
|
3210
3343
|
className: "local-tabpanel-body",
|
|
3211
3344
|
children: n(e.children ?? [], t)
|
|
3212
3345
|
});
|
|
3213
3346
|
}
|
|
3214
|
-
function
|
|
3347
|
+
function tn() {
|
|
3215
3348
|
return null;
|
|
3216
3349
|
}
|
|
3217
|
-
function
|
|
3218
|
-
let n =
|
|
3219
|
-
if (
|
|
3220
|
-
|
|
3221
|
-
}), c.length === 0) return /* @__PURE__ */
|
|
3222
|
-
let
|
|
3350
|
+
function nn({ node: e, visible: t }) {
|
|
3351
|
+
let n = g(), { runtime: r, render: i } = G(), { write: a, error: o } = X(e), s = q(r, e, "label", ""), c = (e.children ?? []).filter((e) => e.type === "component" && e.name === "tab"), l = c.map((e, t) => K(e, "value") ?? `tab-${t + 1}`), u = c.map((e, t) => q(r, e, "label", l[t])), d = K(e, "initial") ?? l[0] ?? "", f = K(e, "bind") !== void 0, p = Y(r, e), m = typeof p == "string" ? p : "", [h, _] = y(() => l.includes(d) ? d : l[0] ?? ""), b = v([]);
|
|
3352
|
+
if (gt(r, e, () => {
|
|
3353
|
+
_(l.includes(d) ? d : l[0] ?? "");
|
|
3354
|
+
}), c.length === 0) return /* @__PURE__ */ S(Z, { message: "标签页至少需要一个 tab" });
|
|
3355
|
+
let x = f ? l.includes(m) ? m : l[0] : l.includes(h) ? h : l[0], w = Math.max(0, l.indexOf(x)), T = (e) => {
|
|
3223
3356
|
let t = l[e];
|
|
3224
|
-
t !== void 0 && (f ? a(t) :
|
|
3357
|
+
t !== void 0 && (f ? a(t) : _(t), b.current[e]?.focus());
|
|
3225
3358
|
};
|
|
3226
|
-
return /* @__PURE__ */
|
|
3359
|
+
return /* @__PURE__ */ C("section", {
|
|
3227
3360
|
className: "local-tabs",
|
|
3228
3361
|
"aria-label": s || "选项卡",
|
|
3229
3362
|
children: [
|
|
3230
|
-
s ? /* @__PURE__ */
|
|
3363
|
+
s ? /* @__PURE__ */ S("div", {
|
|
3231
3364
|
className: "local-tabs-label",
|
|
3232
3365
|
children: s
|
|
3233
3366
|
}) : null,
|
|
3234
|
-
/* @__PURE__ */
|
|
3367
|
+
/* @__PURE__ */ S("div", {
|
|
3235
3368
|
className: "local-tablist",
|
|
3236
3369
|
role: "tablist",
|
|
3237
3370
|
"aria-label": s || "选项卡",
|
|
@@ -3240,8 +3373,8 @@ function Lt({ node: e, visible: t }) {
|
|
|
3240
3373
|
e.key === "ArrowRight" ? t = (w + 1) % c.length : e.key === "ArrowLeft" ? t = (w - 1 + c.length) % c.length : e.key === "Home" ? t = 0 : e.key === "End" && (t = c.length - 1), !(t < 0) && (e.preventDefault(), T(t));
|
|
3241
3374
|
},
|
|
3242
3375
|
children: c.map((e, t) => {
|
|
3243
|
-
let r = l[t], i = r ===
|
|
3244
|
-
return /* @__PURE__ */
|
|
3376
|
+
let r = l[t], i = r === x;
|
|
3377
|
+
return /* @__PURE__ */ S("button", {
|
|
3245
3378
|
ref: (e) => {
|
|
3246
3379
|
b.current[t] = e;
|
|
3247
3380
|
},
|
|
@@ -3253,15 +3386,15 @@ function Lt({ node: e, visible: t }) {
|
|
|
3253
3386
|
"aria-controls": `${n}-panel-${t}`,
|
|
3254
3387
|
tabIndex: i ? 0 : -1,
|
|
3255
3388
|
onClick: () => {
|
|
3256
|
-
f ? a(r) :
|
|
3389
|
+
f ? a(r) : _(r);
|
|
3257
3390
|
},
|
|
3258
3391
|
children: u[t]
|
|
3259
3392
|
}, e.id);
|
|
3260
3393
|
})
|
|
3261
3394
|
}),
|
|
3262
3395
|
c.map((e, r) => {
|
|
3263
|
-
let a = l[r] ===
|
|
3264
|
-
return /* @__PURE__ */
|
|
3396
|
+
let a = l[r] === x;
|
|
3397
|
+
return /* @__PURE__ */ S("div", {
|
|
3265
3398
|
id: `${n}-panel-${r}`,
|
|
3266
3399
|
className: "local-tabpanel",
|
|
3267
3400
|
role: "tabpanel",
|
|
@@ -3271,46 +3404,46 @@ function Lt({ node: e, visible: t }) {
|
|
|
3271
3404
|
children: i(e.children ?? [], t && a)
|
|
3272
3405
|
}, e.id);
|
|
3273
3406
|
}),
|
|
3274
|
-
/* @__PURE__ */
|
|
3407
|
+
/* @__PURE__ */ S($, { message: o })
|
|
3275
3408
|
]
|
|
3276
3409
|
});
|
|
3277
3410
|
}
|
|
3278
|
-
function
|
|
3411
|
+
function rn({ node: e, visible: t }) {
|
|
3279
3412
|
let { runtime: n, render: r } = G(), i = q(n, e, "label", "");
|
|
3280
|
-
return /* @__PURE__ */
|
|
3413
|
+
return /* @__PURE__ */ C("div", {
|
|
3281
3414
|
className: "local-accordion",
|
|
3282
3415
|
role: "group",
|
|
3283
3416
|
"aria-label": i || "折叠面板",
|
|
3284
|
-
children: [i ? /* @__PURE__ */
|
|
3417
|
+
children: [i ? /* @__PURE__ */ S("div", {
|
|
3285
3418
|
className: "local-accordion-label",
|
|
3286
3419
|
children: i
|
|
3287
3420
|
}) : null, r(e.children ?? [], t)]
|
|
3288
3421
|
});
|
|
3289
3422
|
}
|
|
3290
|
-
function
|
|
3291
|
-
let n =
|
|
3292
|
-
|
|
3423
|
+
function an({ node: e, visible: t }) {
|
|
3424
|
+
let n = g(), { runtime: r, render: i } = G(), a = q(r, e, "label", "折叠内容"), o = ft(r, e, "open", !1), [s, c] = y(o);
|
|
3425
|
+
gt(r, e, () => {
|
|
3293
3426
|
c(o);
|
|
3294
3427
|
});
|
|
3295
3428
|
let l = `${n}-disclosure-trigger`, u = `${n}-disclosure-panel`;
|
|
3296
|
-
return /* @__PURE__ */
|
|
3429
|
+
return /* @__PURE__ */ C("div", {
|
|
3297
3430
|
className: "local-disclosure",
|
|
3298
|
-
children: [/* @__PURE__ */
|
|
3431
|
+
children: [/* @__PURE__ */ S("h3", {
|
|
3299
3432
|
className: "local-disclosure-heading",
|
|
3300
|
-
children: /* @__PURE__ */
|
|
3433
|
+
children: /* @__PURE__ */ C("button", {
|
|
3301
3434
|
id: l,
|
|
3302
3435
|
type: "button",
|
|
3303
3436
|
className: "local-disclosure-trigger",
|
|
3304
3437
|
"aria-expanded": s,
|
|
3305
3438
|
"aria-controls": u,
|
|
3306
3439
|
onClick: () => c((e) => !e),
|
|
3307
|
-
children: [/* @__PURE__ */
|
|
3440
|
+
children: [/* @__PURE__ */ S("span", {
|
|
3308
3441
|
className: `local-chevron${s ? " is-open" : ""}`,
|
|
3309
3442
|
"aria-hidden": "true",
|
|
3310
3443
|
children: "▸"
|
|
3311
|
-
}), /* @__PURE__ */
|
|
3444
|
+
}), /* @__PURE__ */ S("span", { children: a })]
|
|
3312
3445
|
})
|
|
3313
|
-
}), /* @__PURE__ */
|
|
3446
|
+
}), /* @__PURE__ */ S("div", {
|
|
3314
3447
|
id: u,
|
|
3315
3448
|
className: "local-disclosure-panel",
|
|
3316
3449
|
role: "region",
|
|
@@ -3320,9 +3453,9 @@ function zt({ node: e, visible: t }) {
|
|
|
3320
3453
|
})]
|
|
3321
3454
|
});
|
|
3322
3455
|
}
|
|
3323
|
-
function
|
|
3324
|
-
let { runtime: n, render: r } = G(), i =
|
|
3325
|
-
return
|
|
3456
|
+
function on({ node: e, visible: t }) {
|
|
3457
|
+
let { runtime: n, render: r } = G(), i = dt(n, e, "when", !1), a = i.ok ? i.value : !1, o = !i.ok, s = v(null), c = v(a), l = v(!1);
|
|
3458
|
+
return h(() => {
|
|
3326
3459
|
if (c.current && !a) {
|
|
3327
3460
|
if (l.current) {
|
|
3328
3461
|
let e = s.current?.closest(".local-document");
|
|
@@ -3331,7 +3464,7 @@ function Bt({ node: e, visible: t }) {
|
|
|
3331
3464
|
l.current = !1;
|
|
3332
3465
|
}
|
|
3333
3466
|
c.current = a;
|
|
3334
|
-
}, [a]), /* @__PURE__ */
|
|
3467
|
+
}, [a]), /* @__PURE__ */ C(x, { children: [o ? /* @__PURE__ */ S(Z, {}) : null, /* @__PURE__ */ S("div", {
|
|
3335
3468
|
ref: s,
|
|
3336
3469
|
className: "local-if md-if",
|
|
3337
3470
|
role: "group",
|
|
@@ -3348,34 +3481,34 @@ function Bt({ node: e, visible: t }) {
|
|
|
3348
3481
|
children: r(e.children ?? [], t && a)
|
|
3349
3482
|
})] });
|
|
3350
3483
|
}
|
|
3351
|
-
function
|
|
3484
|
+
function sn({ node: e, visible: t }) {
|
|
3352
3485
|
let { runtime: n, render: r } = G(), i = q(n, e, "title", ""), a = K(e, "tone") ?? "info", o = a === "success" || a === "warning" ? a : "info", s = o === "warning" ? "alert" : "status";
|
|
3353
|
-
return /* @__PURE__ */
|
|
3486
|
+
return /* @__PURE__ */ C("div", {
|
|
3354
3487
|
className: `local-alert local-alert-${o}`,
|
|
3355
3488
|
role: s,
|
|
3356
|
-
children: [i ? /* @__PURE__ */
|
|
3489
|
+
children: [i ? /* @__PURE__ */ S("div", {
|
|
3357
3490
|
className: "local-alert-title",
|
|
3358
3491
|
children: i
|
|
3359
|
-
}) : null, /* @__PURE__ */
|
|
3492
|
+
}) : null, /* @__PURE__ */ S("div", {
|
|
3360
3493
|
className: "local-alert-body",
|
|
3361
3494
|
children: r(e.children ?? [], t)
|
|
3362
3495
|
})]
|
|
3363
3496
|
});
|
|
3364
3497
|
}
|
|
3365
|
-
function
|
|
3498
|
+
function cn({ node: e, visible: t }) {
|
|
3366
3499
|
let n = G(), { runtime: r } = n, i = K(e, "tone") ?? "neutral";
|
|
3367
|
-
return /* @__PURE__ */
|
|
3500
|
+
return /* @__PURE__ */ S("span", {
|
|
3368
3501
|
className: `md-badge md-badge-${i === "success" || i === "warning" ? i : "neutral"} local-badge`,
|
|
3369
|
-
children:
|
|
3502
|
+
children: Ct(n, e.children, t)
|
|
3370
3503
|
});
|
|
3371
3504
|
}
|
|
3372
|
-
function
|
|
3373
|
-
let n =
|
|
3374
|
-
return /* @__PURE__ */
|
|
3505
|
+
function ln({ node: e, visible: t }) {
|
|
3506
|
+
let n = g(), r = G(), { runtime: i } = r, a = q(i, e, "text", "提示"), [o, s] = y(!1), c = `${n}-tooltip`;
|
|
3507
|
+
return /* @__PURE__ */ C("span", {
|
|
3375
3508
|
className: "local-tooltip",
|
|
3376
3509
|
onMouseEnter: () => s(!0),
|
|
3377
3510
|
onMouseLeave: () => s(!1),
|
|
3378
|
-
children: [/* @__PURE__ */
|
|
3511
|
+
children: [/* @__PURE__ */ S("span", {
|
|
3379
3512
|
className: "local-tooltip-trigger",
|
|
3380
3513
|
tabIndex: 0,
|
|
3381
3514
|
"aria-describedby": c,
|
|
@@ -3384,8 +3517,8 @@ function Ut({ node: e, visible: t }) {
|
|
|
3384
3517
|
onKeyDown: (e) => {
|
|
3385
3518
|
e.key === "Escape" && (e.stopPropagation(), s(!1));
|
|
3386
3519
|
},
|
|
3387
|
-
children:
|
|
3388
|
-
}), /* @__PURE__ */
|
|
3520
|
+
children: Ct(r, e.children, t)
|
|
3521
|
+
}), /* @__PURE__ */ S("span", {
|
|
3389
3522
|
id: c,
|
|
3390
3523
|
role: "tooltip",
|
|
3391
3524
|
className: `local-tooltip-bubble${o ? " is-visible" : ""}`,
|
|
@@ -3393,109 +3526,111 @@ function Ut({ node: e, visible: t }) {
|
|
|
3393
3526
|
})]
|
|
3394
3527
|
});
|
|
3395
3528
|
}
|
|
3396
|
-
var
|
|
3397
|
-
panel:
|
|
3398
|
-
card:
|
|
3399
|
-
grid:
|
|
3400
|
-
tabs:
|
|
3401
|
-
tab:
|
|
3402
|
-
accordion:
|
|
3403
|
-
disclosure:
|
|
3404
|
-
if:
|
|
3405
|
-
alert:
|
|
3406
|
-
badge:
|
|
3407
|
-
tooltip:
|
|
3408
|
-
input:
|
|
3409
|
-
textarea:
|
|
3410
|
-
number:
|
|
3411
|
-
slider:
|
|
3412
|
-
toggle:
|
|
3413
|
-
checkbox:
|
|
3414
|
-
date:
|
|
3415
|
-
select:
|
|
3416
|
-
choices:
|
|
3417
|
-
"radio-group":
|
|
3418
|
-
option:
|
|
3419
|
-
node:
|
|
3420
|
-
edge:
|
|
3421
|
-
counter:
|
|
3422
|
-
timer:
|
|
3423
|
-
checklist:
|
|
3424
|
-
progress:
|
|
3529
|
+
var un = {
|
|
3530
|
+
panel: Zt,
|
|
3531
|
+
card: Qt,
|
|
3532
|
+
grid: $t,
|
|
3533
|
+
tabs: nn,
|
|
3534
|
+
tab: en,
|
|
3535
|
+
accordion: rn,
|
|
3536
|
+
disclosure: an,
|
|
3537
|
+
if: on,
|
|
3538
|
+
alert: sn,
|
|
3539
|
+
badge: cn,
|
|
3540
|
+
tooltip: ln,
|
|
3541
|
+
input: kt,
|
|
3542
|
+
textarea: At,
|
|
3543
|
+
number: Nt,
|
|
3544
|
+
slider: Pt,
|
|
3545
|
+
toggle: Ft,
|
|
3546
|
+
checkbox: It,
|
|
3547
|
+
date: Lt,
|
|
3548
|
+
select: Ht,
|
|
3549
|
+
choices: Ut,
|
|
3550
|
+
"radio-group": Wt,
|
|
3551
|
+
option: Vt,
|
|
3552
|
+
node: en,
|
|
3553
|
+
edge: tn,
|
|
3554
|
+
counter: Jt,
|
|
3555
|
+
timer: Yt,
|
|
3556
|
+
checklist: Kt,
|
|
3557
|
+
progress: Xt
|
|
3425
3558
|
};
|
|
3426
|
-
function
|
|
3427
|
-
let i = _(n);
|
|
3428
|
-
|
|
3429
|
-
let
|
|
3430
|
-
|
|
3431
|
-
}, []),
|
|
3559
|
+
function dn({ document: e, runtime: t, onDiagnostics: n, urlPolicy: r }) {
|
|
3560
|
+
let i = g(), a = _(() => at(e, `local-heading-${i}`), [e, i]), o = v(n);
|
|
3561
|
+
o.current = n;
|
|
3562
|
+
let s = p((e) => {
|
|
3563
|
+
o.current?.(e);
|
|
3564
|
+
}, []), c = p((e) => {
|
|
3432
3565
|
try {
|
|
3433
3566
|
return t.subscribe(e);
|
|
3434
3567
|
} catch {
|
|
3435
3568
|
return () => {};
|
|
3436
3569
|
}
|
|
3437
|
-
}, [t]),
|
|
3570
|
+
}, [t]), l = p(() => {
|
|
3438
3571
|
try {
|
|
3439
3572
|
return t.snapshot();
|
|
3440
3573
|
} catch {
|
|
3441
|
-
return
|
|
3574
|
+
return ct;
|
|
3442
3575
|
}
|
|
3443
3576
|
}, [t]);
|
|
3444
|
-
|
|
3445
|
-
let
|
|
3577
|
+
b(c, l, l);
|
|
3578
|
+
let u = {
|
|
3446
3579
|
runtime: t,
|
|
3447
|
-
urlPolicy: r
|
|
3448
|
-
|
|
3580
|
+
urlPolicy: r,
|
|
3581
|
+
anchors: a
|
|
3582
|
+
}, d = (e, n = !0) => /* @__PURE__ */ S(ot.Provider, {
|
|
3449
3583
|
value: {
|
|
3450
3584
|
runtime: t,
|
|
3451
|
-
render:
|
|
3585
|
+
render: d,
|
|
3452
3586
|
visible: n,
|
|
3453
|
-
report:
|
|
3454
|
-
urlPolicy: r
|
|
3587
|
+
report: s,
|
|
3588
|
+
urlPolicy: r,
|
|
3589
|
+
anchors: a
|
|
3455
3590
|
},
|
|
3456
|
-
children: Q(
|
|
3591
|
+
children: Q(u, e ?? [], n)
|
|
3457
3592
|
});
|
|
3458
|
-
return /* @__PURE__ */
|
|
3593
|
+
return /* @__PURE__ */ S("article", {
|
|
3459
3594
|
className: "md-document local-document",
|
|
3460
3595
|
"aria-label": "交互文档",
|
|
3461
|
-
children:
|
|
3596
|
+
children: d(e.nodes, !0)
|
|
3462
3597
|
});
|
|
3463
3598
|
}
|
|
3464
|
-
function
|
|
3465
|
-
let r =
|
|
3599
|
+
function fn({ source: e, onDiagnostics: t, urlPolicy: n }) {
|
|
3600
|
+
let r = _(() => a(e), [e]), i = _(() => {
|
|
3466
3601
|
if (!r.ok) return null;
|
|
3467
3602
|
try {
|
|
3468
|
-
return
|
|
3603
|
+
return c(r.document);
|
|
3469
3604
|
} catch {
|
|
3470
3605
|
return null;
|
|
3471
3606
|
}
|
|
3472
|
-
}, [r]), o =
|
|
3607
|
+
}, [r]), o = v(t);
|
|
3473
3608
|
o.current = t;
|
|
3474
|
-
let
|
|
3475
|
-
|
|
3476
|
-
let l =
|
|
3477
|
-
return
|
|
3609
|
+
let s = v(i);
|
|
3610
|
+
s.current = i;
|
|
3611
|
+
let l = v(0);
|
|
3612
|
+
return h(() => (l.current += 1, () => {
|
|
3478
3613
|
--l.current;
|
|
3479
|
-
}), []),
|
|
3614
|
+
}), []), h(() => {
|
|
3480
3615
|
o.current?.(r.diagnostics);
|
|
3481
|
-
}, [r]),
|
|
3616
|
+
}, [r]), h(() => {
|
|
3482
3617
|
let e = i;
|
|
3483
3618
|
return () => {
|
|
3484
3619
|
queueMicrotask(() => {
|
|
3485
|
-
if (!(
|
|
3620
|
+
if (!(s.current === e && l.current > 0)) try {
|
|
3486
3621
|
e?.dispose();
|
|
3487
3622
|
} catch {}
|
|
3488
3623
|
});
|
|
3489
3624
|
};
|
|
3490
|
-
}, [i]), !r.ok || !i ? /* @__PURE__ */
|
|
3625
|
+
}, [i]), !r.ok || !i ? /* @__PURE__ */ C("div", {
|
|
3491
3626
|
className: "md-document local-document local-inactive",
|
|
3492
3627
|
role: "alert",
|
|
3493
|
-
children: [/* @__PURE__ */
|
|
3628
|
+
children: [/* @__PURE__ */ S("p", {
|
|
3494
3629
|
className: "local-inactive-title",
|
|
3495
3630
|
children: r.ok ? "交互初始化失败,预览已停用。" : "文档包含语法错误,交互预览已停用。"
|
|
3496
|
-
}), r.diagnostics.length ? /* @__PURE__ */
|
|
3631
|
+
}), r.diagnostics.length ? /* @__PURE__ */ S("ul", {
|
|
3497
3632
|
className: "local-inactive-list",
|
|
3498
|
-
children: r.diagnostics.map((e, t) => /* @__PURE__ */
|
|
3633
|
+
children: r.diagnostics.map((e, t) => /* @__PURE__ */ C("li", { children: [
|
|
3499
3634
|
e.message,
|
|
3500
3635
|
"(第 ",
|
|
3501
3636
|
e.line,
|
|
@@ -3504,11 +3639,11 @@ function Kt({ source: e, onDiagnostics: t, urlPolicy: n }) {
|
|
|
3504
3639
|
" 列)"
|
|
3505
3640
|
] }, `${e.code}-${t}`))
|
|
3506
3641
|
}) : null]
|
|
3507
|
-
}) : /* @__PURE__ */
|
|
3642
|
+
}) : /* @__PURE__ */ S(dn, {
|
|
3508
3643
|
document: r.document,
|
|
3509
3644
|
runtime: i,
|
|
3510
3645
|
onDiagnostics: t,
|
|
3511
3646
|
urlPolicy: n
|
|
3512
3647
|
}, e);
|
|
3513
3648
|
}
|
|
3514
|
-
export {
|
|
3649
|
+
export { dn as LocalDocumentView, fn as LocalReactiveDocument };
|