@seanyeh77/ui 0.12.1 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle.js +6 -6
- package/dist/bundle.js.map +1 -1
- package/dist/{format-entry-jAIdVjUz.js → format-entry-DgBikvR_.js} +2 -1
- package/dist/format-entry-DgBikvR_.js.map +1 -0
- package/dist/format.js +1 -1
- package/dist/index.d.ts +10 -5
- package/dist/index.js +301 -141
- package/dist/index.js.map +1 -1
- package/dist/styles.css +96 -5
- package/docs/LayerGraph.md +4 -2
- package/docs/ProjectSwitcher.md +2 -1
- package/docs/Tour.md +1 -1
- package/docs/guidelines.md +1 -1
- package/package.json +2 -2
- package/dist/format-entry-jAIdVjUz.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { a as parseDate, c as addMessages, d as unitFor, i as format, l as setLocale, n as fileSize, o as sameDay, r as fmtDate, s as I18N, t as dayAdd, u as tr } from "./format-entry-
|
|
2
|
+
import { a as parseDate, c as addMessages, d as unitFor, i as format, l as setLocale, n as fileSize, o as sameDay, r as fmtDate, s as I18N, t as dayAdd, u as tr } from "./format-entry-DgBikvR_.js";
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
5
5
|
import { Tooltip as Tooltip$1 } from "@base-ui/react/tooltip";
|
|
@@ -4632,6 +4632,54 @@ function KpiCard(props) {
|
|
|
4632
4632
|
]
|
|
4633
4633
|
});
|
|
4634
4634
|
}
|
|
4635
|
+
// src/components/Switch/Switch.tsx
|
|
4636
|
+
/** An on/off setting that applies at once. The thumb stretches like a droplet while it moves. */
|
|
4637
|
+
function Switch({ checked, onChange, label, disabled, className }) {
|
|
4638
|
+
const on = !!checked;
|
|
4639
|
+
const [pressing, setPressing] = React.useState(false);
|
|
4640
|
+
const W = 48;
|
|
4641
|
+
const H = 28;
|
|
4642
|
+
const th = pressing ? 28 : on ? 24 : 16;
|
|
4643
|
+
const gap = (H - th) / 2;
|
|
4644
|
+
const stretch = pressing ? 6 : 0;
|
|
4645
|
+
const left = on ? W - gap - th - stretch : gap;
|
|
4646
|
+
const right = on ? gap : W - gap - th - stretch;
|
|
4647
|
+
return /* @__PURE__ */ jsx("button", {
|
|
4648
|
+
type: "button",
|
|
4649
|
+
role: "switch",
|
|
4650
|
+
"aria-checked": on,
|
|
4651
|
+
"aria-label": label,
|
|
4652
|
+
disabled,
|
|
4653
|
+
className: cx("ui-switch", on && "is-on", className),
|
|
4654
|
+
onClick: () => onChange?.(!on),
|
|
4655
|
+
onPointerDown: () => setPressing(true),
|
|
4656
|
+
onPointerUp: () => setPressing(false),
|
|
4657
|
+
onPointerLeave: () => setPressing(false),
|
|
4658
|
+
onPointerCancel: () => setPressing(false),
|
|
4659
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
4660
|
+
className: "ui-switch-thumb",
|
|
4661
|
+
style: {
|
|
4662
|
+
left,
|
|
4663
|
+
right,
|
|
4664
|
+
height: th,
|
|
4665
|
+
marginTop: -th / 2,
|
|
4666
|
+
transition: `${dropTransition("left", "right", on)}, height 150ms ease, margin-top 150ms ease, background-color .2s ease`
|
|
4667
|
+
},
|
|
4668
|
+
children: /* @__PURE__ */ jsx("svg", {
|
|
4669
|
+
width: 12,
|
|
4670
|
+
height: 12,
|
|
4671
|
+
viewBox: "0 0 24 24",
|
|
4672
|
+
fill: "none",
|
|
4673
|
+
stroke: "currentColor",
|
|
4674
|
+
strokeWidth: 3.5,
|
|
4675
|
+
strokeLinecap: "round",
|
|
4676
|
+
strokeLinejoin: "round",
|
|
4677
|
+
"aria-hidden": "true",
|
|
4678
|
+
children: /* @__PURE__ */ jsx("path", { d: on ? "M5 12.5l4.5 4.5L19 7" : "M7 7l10 10M17 7L7 17" })
|
|
4679
|
+
})
|
|
4680
|
+
})
|
|
4681
|
+
});
|
|
4682
|
+
}
|
|
4635
4683
|
// src/components/LayerGraph/LayerGraph.tsx
|
|
4636
4684
|
const scrollMemory = /* @__PURE__ */ new Map();
|
|
4637
4685
|
let measure;
|
|
@@ -4885,6 +4933,7 @@ function LayerGraph(p) {
|
|
|
4885
4933
|
onScroll();
|
|
4886
4934
|
};
|
|
4887
4935
|
const selEdge = pickEdge && edges.find((e) => edgeId(e) === p.selectedEdge) || null;
|
|
4936
|
+
const selListEdge = pickEdge && p.edges.find((e) => edgeId(e) === p.selectedEdge) || null;
|
|
4888
4937
|
const nodeIdsAll = new Set(all.map((n) => n.id));
|
|
4889
4938
|
const uses = {};
|
|
4890
4939
|
for (const e of p.edges) if (sharedIds.has(e.to) && e.from !== e.to && nodeIdsAll.has(e.from)) (uses[e.to] ??= {})[e.from] = (uses[e.to]?.[e.from] ?? 0) + (e.count || 0);
|
|
@@ -4919,12 +4968,12 @@ function LayerGraph(p) {
|
|
|
4919
4968
|
};
|
|
4920
4969
|
W += shift;
|
|
4921
4970
|
}
|
|
4922
|
-
const boxesLeft = Math.min(...main.map((n) => pos[n.id].x));
|
|
4923
|
-
const boxesRight = Math.max(0, ...main.map((n) => pos[n.id].x + NW));
|
|
4924
|
-
const laneX = (e) => onLeft(e) ? boxesLeft - LANE - upsL.indexOf(e) * LANE_STEP : boxesRight + LANE + upsR.indexOf(e) * LANE_STEP;
|
|
4925
|
-
const upLabelX = boxesLeft - LANE + 8;
|
|
4926
|
-
const upLabelEndL = boxesRight + LANE - 8;
|
|
4927
|
-
if (upsR.length) W = Math.max(W, boxesRight + LANE + (upsR.length - 1) * LANE_STEP + PAD);
|
|
4971
|
+
const boxesLeft = () => Math.min(...main.map((n) => pos[n.id].x));
|
|
4972
|
+
const boxesRight = () => Math.max(0, ...main.map((n) => pos[n.id].x + NW));
|
|
4973
|
+
const laneX = (e) => onLeft(e) ? boxesLeft() - LANE - upsL.indexOf(e) * LANE_STEP : boxesRight() + LANE + upsR.indexOf(e) * LANE_STEP;
|
|
4974
|
+
const upLabelX = () => boxesLeft() - LANE + 8;
|
|
4975
|
+
const upLabelEndL = () => boxesRight() + LANE - 8;
|
|
4976
|
+
if (upsR.length) W = Math.max(W, boxesRight() + LANE + (upsR.length - 1) * LANE_STEP + PAD);
|
|
4928
4977
|
const choose = (e) => {
|
|
4929
4978
|
const id = edgeId(e);
|
|
4930
4979
|
const next = p.selectedEdge === id ? null : id;
|
|
@@ -5210,7 +5259,7 @@ function LayerGraph(p) {
|
|
|
5210
5259
|
idx,
|
|
5211
5260
|
e,
|
|
5212
5261
|
text,
|
|
5213
|
-
tx: L ? upLabelX : upLabelEndL,
|
|
5262
|
+
tx: L ? upLabelX() : upLabelEndL(),
|
|
5214
5263
|
ty: Math.round((y0 + y1) / 2),
|
|
5215
5264
|
left: !L,
|
|
5216
5265
|
r,
|
|
@@ -5377,18 +5426,19 @@ function LayerGraph(p) {
|
|
|
5377
5426
|
const hits = (x0, x1, y0, y1) => placed.some((q) => x0 < q[1] + (q[4] || 0) && q[0] < x1 + (q[4] || 0) && y0 < q[3] && q[2] < y1);
|
|
5378
5427
|
const cross = (q, x0, lw, y0, y1) => x0 < q[1] - 1 && q[0] + 1 < x0 + lw && y0 < q[3] - 1 && q[2] + 1 < y1;
|
|
5379
5428
|
const gapTo = (b, x0, lw, y0, y1) => Math.hypot(Math.max(0, b[0] - (x0 + lw), x0 - b[1]), Math.max(0, b[2] - y1, y0 - b[3]));
|
|
5380
|
-
const
|
|
5429
|
+
const isMine = (idx, x0, lw, y0, y1) => {
|
|
5430
|
+
let self = Infinity;
|
|
5431
|
+
let other = Infinity;
|
|
5432
|
+
for (const sg of segs) {
|
|
5433
|
+
const d = gapTo(sg.box, x0, lw, y0, y1);
|
|
5434
|
+
if (sg.idx === idx) self = Math.min(self, d);
|
|
5435
|
+
else other = Math.min(other, d);
|
|
5436
|
+
}
|
|
5437
|
+
return self + 4 < other && other >= 8;
|
|
5438
|
+
};
|
|
5439
|
+
const alongLine = (m, own = true) => {
|
|
5381
5440
|
const pts = ptsOf[m.idx] ?? [];
|
|
5382
|
-
const mine = (x0, lw, y0, y1) =>
|
|
5383
|
-
let self = Infinity;
|
|
5384
|
-
let other = Infinity;
|
|
5385
|
-
for (const sg of segs) {
|
|
5386
|
-
const d = gapTo(sg.box, x0, lw, y0, y1);
|
|
5387
|
-
if (sg.idx === m.idx) self = Math.min(self, d);
|
|
5388
|
-
else other = Math.min(other, d);
|
|
5389
|
-
}
|
|
5390
|
-
return self + 4 < other && other >= 8;
|
|
5391
|
-
};
|
|
5441
|
+
const mine = (x0, lw, y0, y1) => isMine(m.idx, x0, lw, y0, y1);
|
|
5392
5442
|
const ok = (x0, lw, y0, y1) => (!own || mine(x0, lw, y0, y1)) && x0 >= PAD / 2 && x0 + lw <= W - PAD / 2 && y0 >= 2 && y1 <= H - 2 && !hits(x0 - 2, x0 + lw + 2, y0 - 2, y1 + 2) && !boxRects.some((q) => x0 < q[1] + 4 && q[0] < x0 + lw + 4 && y0 < q[3] + 4 && q[2] < y1 + 4) && !segs.some((sg) => sg.idx === m.idx ? cross(sg.box, x0, lw, y0, y1) : x0 < sg.box[1] + 2 && sg.box[0] < x0 + lw + 2 && y0 < sg.box[3] + 2 && sg.box[2] < y1 + 2);
|
|
5393
5443
|
for (const lines of wraps(m.text)) {
|
|
5394
5444
|
const lw = Math.ceil(Math.max(...lines.map(labelWidth)));
|
|
@@ -5423,9 +5473,44 @@ function LayerGraph(p) {
|
|
|
5423
5473
|
}
|
|
5424
5474
|
return null;
|
|
5425
5475
|
};
|
|
5426
|
-
const
|
|
5476
|
+
const numbered = [];
|
|
5477
|
+
const numberOn = (m, near) => {
|
|
5478
|
+
const pts = ptsOf[m.idx] ?? [];
|
|
5479
|
+
const cx = near.x0 + near.lw / 2;
|
|
5480
|
+
const cy = near.top;
|
|
5481
|
+
let best = null;
|
|
5482
|
+
for (let k = 0; k + 1 < pts.length; k++) {
|
|
5483
|
+
const [x1, y1] = pts[k];
|
|
5484
|
+
const [x2, y2] = pts[k + 1];
|
|
5485
|
+
const len = Math.hypot(x2 - x1, y2 - y1);
|
|
5486
|
+
for (let t = 12; t <= len - 12; t += 4) {
|
|
5487
|
+
const x = x1 + (x2 - x1) * t / len;
|
|
5488
|
+
const y = y1 + (y2 - y1) * t / len;
|
|
5489
|
+
const clear = !segs.some((sg) => sg.idx !== m.idx && gapTo(sg.box, x - 14, 28, y - 14, y + 14) === 0) && !boxRects.some((q) => x + 14 > q[0] && x - 14 < q[1] && y + 14 > q[2] && y - 14 < q[3]) && !hits(x - 14, x + 14, y - 14, y + 14) && !numbered.some((o) => Math.hypot(o.x - x, o.y - y) < 28);
|
|
5490
|
+
const d = Math.hypot(x - cx, y - cy);
|
|
5491
|
+
if (!best || clear && !best.clear || clear === best.clear && d < best.d) best = {
|
|
5492
|
+
x,
|
|
5493
|
+
y,
|
|
5494
|
+
d,
|
|
5495
|
+
clear
|
|
5496
|
+
};
|
|
5497
|
+
}
|
|
5498
|
+
}
|
|
5499
|
+
const at = best ?? {
|
|
5500
|
+
x: m.tx,
|
|
5501
|
+
y: m.ty - 20
|
|
5502
|
+
};
|
|
5503
|
+
numbered.push({
|
|
5504
|
+
n: numbered.length + 1,
|
|
5505
|
+
m,
|
|
5506
|
+
x: Math.round(at.x),
|
|
5507
|
+
y: Math.round(at.y)
|
|
5508
|
+
});
|
|
5509
|
+
return numbered.length;
|
|
5510
|
+
};
|
|
5511
|
+
const labelEl = (m, x0, top, lines = [m.text], over = false, num = 0) => /* @__PURE__ */ jsx("span", {
|
|
5427
5512
|
"aria-hidden": pickEdge ? true : void 0,
|
|
5428
|
-
className: cx("ui-lg-label", over && "is-over", pickEdge && "is-clickable", pickEdge && hover === edgeId(m.e) && "is-hover", m.r && "is-related", m.dim && "is-dim", peek && !m.r && hover !== edgeId(m.e) && m.e !== selEdge && "is-quiet"),
|
|
5513
|
+
className: cx("ui-lg-label", over && "is-over", num > 0 && "is-numbered", num > 0 && (hover === edgeId(m.e) || m.e === selEdge) && "is-shown", pickEdge && "is-clickable", pickEdge && hover === edgeId(m.e) && "is-hover", m.r && "is-related", m.dim && "is-dim", peek && !m.r && hover !== edgeId(m.e) && m.e !== selEdge && "is-quiet"),
|
|
5429
5514
|
style: {
|
|
5430
5515
|
left: x0,
|
|
5431
5516
|
top
|
|
@@ -5458,6 +5543,8 @@ function LayerGraph(p) {
|
|
|
5458
5543
|
lh: 16,
|
|
5459
5544
|
lines: [m.text]
|
|
5460
5545
|
};
|
|
5546
|
+
labels.push(labelEl(m, spot.x0, spot.top, spot.lines, true, numberOn(m, spot)));
|
|
5547
|
+
return;
|
|
5461
5548
|
}
|
|
5462
5549
|
placed.push([
|
|
5463
5550
|
spot.x0,
|
|
@@ -5491,7 +5578,7 @@ function LayerGraph(p) {
|
|
|
5491
5578
|
const start0 = Math.max(10, Math.min(H - 10, m.ty));
|
|
5492
5579
|
const find = (x0, lw, lh, withLines) => {
|
|
5493
5580
|
const over = (q, y0, y1) => x0 < q[1] + 4 && q[0] < x0 + lw + 4 && y0 < q[3] + 4 && q[2] < y1 + 4;
|
|
5494
|
-
const bad = (y0, y1) => hits(x0, x0 + lw, y0 - 4, y1 + 4) || boxRects.some((q) => over(q, y0, y1)) || withLines && segs.some((g) => g.idx === m.idx ? cross(g.box, x0, lw, y0, y1) : over(g.box, y0, y1));
|
|
5581
|
+
const bad = (y0, y1) => hits(x0, x0 + lw, y0 - 4, y1 + 4) || boxRects.some((q) => over(q, y0, y1)) || withLines && segs.some((g) => g.idx === m.idx ? cross(g.box, x0, lw, y0, y1) : over(g.box, y0, y1)) || withLines && !isMine(m.idx, x0, lw, y0, y1);
|
|
5495
5582
|
for (let k = 0; k <= 16; k++) for (const dir of k ? [-1, 1] : [0]) {
|
|
5496
5583
|
const t = start0 + dir * k * 18;
|
|
5497
5584
|
if (t - lh / 2 >= 2 && t + lh / 2 <= H - 2 && !bad(t - lh / 2, t + lh / 2)) return t;
|
|
@@ -5523,13 +5610,15 @@ function LayerGraph(p) {
|
|
|
5523
5610
|
const x0 = x0Of(w);
|
|
5524
5611
|
const top = find(x0, w, 16, false);
|
|
5525
5612
|
if (top == null) crowd.add(g);
|
|
5526
|
-
|
|
5613
|
+
const at = {
|
|
5527
5614
|
x0,
|
|
5528
5615
|
top: top ?? start0,
|
|
5529
5616
|
lw: w,
|
|
5530
5617
|
lh: 16,
|
|
5531
5618
|
lines: [m.text]
|
|
5532
5619
|
};
|
|
5620
|
+
labels.push(labelEl(m, at.x0, at.top, at.lines, true, numberOn(m, at)));
|
|
5621
|
+
return;
|
|
5533
5622
|
}
|
|
5534
5623
|
placed.push([
|
|
5535
5624
|
spot.x0,
|
|
@@ -5640,6 +5729,10 @@ function LayerGraph(p) {
|
|
|
5640
5729
|
};
|
|
5641
5730
|
}
|
|
5642
5731
|
}
|
|
5732
|
+
if (over) {
|
|
5733
|
+
labels.push(labelEl(m, spot.x0, spot.top, spot.lines, true, numberOn(m, spot)));
|
|
5734
|
+
return;
|
|
5735
|
+
}
|
|
5643
5736
|
placed.push([
|
|
5644
5737
|
spot.x0,
|
|
5645
5738
|
spot.x0 + spot.lw,
|
|
@@ -5653,6 +5746,17 @@ function LayerGraph(p) {
|
|
|
5653
5746
|
};
|
|
5654
5747
|
marks.sort((m, n) => Number(!!m.up) - Number(!!n.up) || m.ty - n.ty || m.tx - n.tx).forEach((m) => place(m, false));
|
|
5655
5748
|
later.forEach((m) => place(m, true));
|
|
5749
|
+
for (const o of numbered) labels.push(/* @__PURE__ */ jsx("span", {
|
|
5750
|
+
className: cx("ui-lg-num", o.m.dim && "is-dim", (hover === edgeId(o.m.e) || o.m.e === selEdge) && "is-on"),
|
|
5751
|
+
style: {
|
|
5752
|
+
left: o.x,
|
|
5753
|
+
top: o.y
|
|
5754
|
+
},
|
|
5755
|
+
"aria-hidden": "true",
|
|
5756
|
+
onPointerEnter: pickEdge ? () => setHover(edgeId(o.m.e)) : void 0,
|
|
5757
|
+
onPointerLeave: pickEdge ? () => setHover(null) : void 0,
|
|
5758
|
+
children: o.n
|
|
5759
|
+
}, "n" + o.m.idx));
|
|
5656
5760
|
return {
|
|
5657
5761
|
paths,
|
|
5658
5762
|
labels,
|
|
@@ -5661,7 +5765,8 @@ function LayerGraph(p) {
|
|
|
5661
5765
|
crowd,
|
|
5662
5766
|
wide,
|
|
5663
5767
|
least,
|
|
5664
|
-
covered
|
|
5768
|
+
covered,
|
|
5769
|
+
numbered
|
|
5665
5770
|
};
|
|
5666
5771
|
};
|
|
5667
5772
|
for (const id in laneCount) {
|
|
@@ -5699,7 +5804,9 @@ function LayerGraph(p) {
|
|
|
5699
5804
|
W = Math.ceil(drawn.wide);
|
|
5700
5805
|
drawn = draw();
|
|
5701
5806
|
}
|
|
5702
|
-
const { paths, labels, hitPaths } = drawn;
|
|
5807
|
+
const { paths, labels, hitPaths, numbered } = drawn;
|
|
5808
|
+
const firstX = Math.min(...main.filter((n) => pos[n.id]).map((n) => boxOf(n.id).x), W);
|
|
5809
|
+
const selBox = sel != null && pos[sel] ? boxOf(sel) : null;
|
|
5703
5810
|
const sizeText = (n) => withNum(p.sizeLabel, n, () => byCount(n, "1 個項目", "{n} 個項目"));
|
|
5704
5811
|
const externalText = p.externalLabel ?? tr("repo 外");
|
|
5705
5812
|
const useText = p.useLabel ?? tr("使用 {n} 次");
|
|
@@ -5813,7 +5920,7 @@ function LayerGraph(p) {
|
|
|
5813
5920
|
id: `${uid}-le`,
|
|
5814
5921
|
className: "ui-lg-listtitle",
|
|
5815
5922
|
children: p.listLabels?.edges ?? tr("關係")
|
|
5816
|
-
}), /* @__PURE__ */ jsx("ul", { children: p.edges.filter((e) => nodeIds.has(e.from) && nodeIds.has(e.to)).map((e, i) => listItem(edgeId(e) + ":" + i, e ===
|
|
5923
|
+
}), /* @__PURE__ */ jsx("ul", { children: p.edges.filter((e) => nodeIds.has(e.from) && nodeIds.has(e.to)).map((e, i) => listItem(edgeId(e) + ":" + i, e === selListEdge, focus && !related(e) && !(selShared && e.to === selShared), pickEdge ? () => choose(e) : void 0, /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
5817
5924
|
/* @__PURE__ */ jsx("span", {
|
|
5818
5925
|
className: "ui-lg-code",
|
|
5819
5926
|
children: nameOf(e.from)
|
|
@@ -5831,6 +5938,32 @@ function LayerGraph(p) {
|
|
|
5831
5938
|
})]
|
|
5832
5939
|
});
|
|
5833
5940
|
const showList = p.listView !== false && view === "list";
|
|
5941
|
+
const started = React.useRef("");
|
|
5942
|
+
React.useLayoutEffect(() => {
|
|
5943
|
+
const el = scrollRef.current;
|
|
5944
|
+
if (!el || showList || !fitted?.full || started.current === memKey) return;
|
|
5945
|
+
started.current = memKey;
|
|
5946
|
+
if (scrollMemory.get(memKey)) return;
|
|
5947
|
+
const x = selBox ? selBox.x + selBox.w / 2 - el.clientWidth / (2 * scale) : firstX - 16;
|
|
5948
|
+
el.scrollLeft = Math.max(0, x * scale);
|
|
5949
|
+
});
|
|
5950
|
+
const selX = selBox?.x;
|
|
5951
|
+
const selW = selBox?.w;
|
|
5952
|
+
React.useEffect(() => {
|
|
5953
|
+
const el = scrollRef.current;
|
|
5954
|
+
if (!el || showList || selX == null || selW == null) return;
|
|
5955
|
+
const l = selX * scale;
|
|
5956
|
+
const r = (selX + selW) * scale;
|
|
5957
|
+
if (l < el.scrollLeft) el.scrollLeft = Math.max(0, l - 16);
|
|
5958
|
+
else if (r > el.scrollLeft + el.clientWidth) el.scrollLeft = r - el.clientWidth + 16;
|
|
5959
|
+
}, [
|
|
5960
|
+
sel,
|
|
5961
|
+
selX,
|
|
5962
|
+
selW,
|
|
5963
|
+
scale,
|
|
5964
|
+
showList,
|
|
5965
|
+
scrollRef
|
|
5966
|
+
]);
|
|
5834
5967
|
const toggleShown = p.labelToggle !== false && !showList && p.edges.some((e) => lab(e));
|
|
5835
5968
|
React.useLayoutEffect(() => {
|
|
5836
5969
|
const el = scrollRef.current;
|
|
@@ -5897,13 +6030,23 @@ function LayerGraph(p) {
|
|
|
5897
6030
|
children: [
|
|
5898
6031
|
p.listView === false && !toggleShown ? null : /* @__PURE__ */ jsxs("div", {
|
|
5899
6032
|
className: "ui-lg-bar",
|
|
5900
|
-
children: [toggleShown ? /* @__PURE__ */ jsx(IconButton, {
|
|
6033
|
+
children: [toggleShown && p.labelToggle === "icon" ? /* @__PURE__ */ jsx(IconButton, {
|
|
5901
6034
|
className: "ui-lg-labels-btn",
|
|
5902
6035
|
icon: "tag",
|
|
5903
6036
|
filled: labelsOn,
|
|
5904
6037
|
label: tr("顯示線上文字"),
|
|
5905
6038
|
"aria-pressed": labelsOn,
|
|
5906
6039
|
onClick: switchLabels
|
|
6040
|
+
}) : toggleShown ? /* @__PURE__ */ jsxs("label", {
|
|
6041
|
+
className: "ui-lg-labels-switch",
|
|
6042
|
+
children: [/* @__PURE__ */ jsx(Switch, {
|
|
6043
|
+
checked: labelsOn,
|
|
6044
|
+
onChange: switchLabels,
|
|
6045
|
+
label: tr("線上文字")
|
|
6046
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
6047
|
+
"aria-hidden": "true",
|
|
6048
|
+
children: tr("線上文字")
|
|
6049
|
+
})]
|
|
5907
6050
|
}) : null, p.listView === false ? null : /* @__PURE__ */ jsx(Tabs, {
|
|
5908
6051
|
label: tr("顯示方式"),
|
|
5909
6052
|
value: view,
|
|
@@ -5975,6 +6118,18 @@ function LayerGraph(p) {
|
|
|
5975
6118
|
show: overflows,
|
|
5976
6119
|
done: scrolled
|
|
5977
6120
|
}),
|
|
6121
|
+
showList || !numbered.length ? null : /* @__PURE__ */ jsx("ol", {
|
|
6122
|
+
className: "ui-lg-numlist",
|
|
6123
|
+
"aria-label": tr("編號的線"),
|
|
6124
|
+
children: numbered.map((o) => /* @__PURE__ */ jsxs("li", {
|
|
6125
|
+
className: cx(o.m.dim && "is-dim"),
|
|
6126
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
6127
|
+
className: "ui-lg-num is-static",
|
|
6128
|
+
"aria-hidden": "true",
|
|
6129
|
+
children: o.n
|
|
6130
|
+
}), /* @__PURE__ */ jsx("span", { children: labelParts(o.m.text) })]
|
|
6131
|
+
}, o.n))
|
|
6132
|
+
}),
|
|
5978
6133
|
shared.length && !showList ? /* @__PURE__ */ jsxs("div", {
|
|
5979
6134
|
className: "ui-lg-shared",
|
|
5980
6135
|
children: [/* @__PURE__ */ jsx("div", {
|
|
@@ -6535,23 +6690,33 @@ const PS_STATUS = {
|
|
|
6535
6690
|
/** The outlined chip in the top bar: which project is shown and whether its data is live; opens a list to switch. */
|
|
6536
6691
|
function ProjectSwitcher({ project, status = "live", statusLabel, options = [], value, onChange, footer, className }) {
|
|
6537
6692
|
const st = PS_STATUS[status] ? status : "live";
|
|
6538
|
-
const
|
|
6693
|
+
const stText = statusLabel || tr(PS_STATUS[st]);
|
|
6694
|
+
const label = `${project} · ${stText}`;
|
|
6539
6695
|
const chip = /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("span", {
|
|
6540
6696
|
className: "ui-projsw-dot",
|
|
6541
6697
|
"aria-hidden": "true"
|
|
6542
|
-
}), /* @__PURE__ */
|
|
6698
|
+
}), /* @__PURE__ */ jsxs("span", {
|
|
6543
6699
|
className: "ui-projsw-text",
|
|
6544
|
-
|
|
6700
|
+
"aria-hidden": "true",
|
|
6701
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
6702
|
+
className: "ui-projsw-name",
|
|
6703
|
+
children: project
|
|
6704
|
+
}), /* @__PURE__ */ jsxs("span", {
|
|
6705
|
+
className: "ui-projsw-status",
|
|
6706
|
+
children: [" · ", stText]
|
|
6707
|
+
})]
|
|
6545
6708
|
})] });
|
|
6546
6709
|
if (!options.length || !onChange) return /* @__PURE__ */ jsx("span", {
|
|
6547
6710
|
className: cx("ui-projsw", "is-" + st, "is-static", className),
|
|
6548
6711
|
role: "status",
|
|
6549
6712
|
"aria-label": label,
|
|
6713
|
+
title: label,
|
|
6550
6714
|
children: chip
|
|
6551
6715
|
});
|
|
6552
6716
|
return /* @__PURE__ */ jsxs(Menu$1.Root, { children: [/* @__PURE__ */ jsxs(Menu$1.Trigger, {
|
|
6553
6717
|
className: cx("ui-projsw", "is-" + st, className),
|
|
6554
6718
|
"aria-label": tr("切換專案,目前是 {name}", { name: label }),
|
|
6719
|
+
title: label,
|
|
6555
6720
|
children: [chip, /* @__PURE__ */ jsx(Icon, {
|
|
6556
6721
|
name: "caret-down",
|
|
6557
6722
|
size: 14,
|
|
@@ -6920,54 +7085,6 @@ function Suggestion({ title, before, after, copyText: copyValue, copyLabel, onCo
|
|
|
6920
7085
|
]
|
|
6921
7086
|
});
|
|
6922
7087
|
}
|
|
6923
|
-
// src/components/Switch/Switch.tsx
|
|
6924
|
-
/** An on/off setting that applies at once. The thumb stretches like a droplet while it moves. */
|
|
6925
|
-
function Switch({ checked, onChange, label, disabled, className }) {
|
|
6926
|
-
const on = !!checked;
|
|
6927
|
-
const [pressing, setPressing] = React.useState(false);
|
|
6928
|
-
const W = 48;
|
|
6929
|
-
const H = 28;
|
|
6930
|
-
const th = pressing ? 28 : on ? 24 : 16;
|
|
6931
|
-
const gap = (H - th) / 2;
|
|
6932
|
-
const stretch = pressing ? 6 : 0;
|
|
6933
|
-
const left = on ? W - gap - th - stretch : gap;
|
|
6934
|
-
const right = on ? gap : W - gap - th - stretch;
|
|
6935
|
-
return /* @__PURE__ */ jsx("button", {
|
|
6936
|
-
type: "button",
|
|
6937
|
-
role: "switch",
|
|
6938
|
-
"aria-checked": on,
|
|
6939
|
-
"aria-label": label,
|
|
6940
|
-
disabled,
|
|
6941
|
-
className: cx("ui-switch", on && "is-on", className),
|
|
6942
|
-
onClick: () => onChange?.(!on),
|
|
6943
|
-
onPointerDown: () => setPressing(true),
|
|
6944
|
-
onPointerUp: () => setPressing(false),
|
|
6945
|
-
onPointerLeave: () => setPressing(false),
|
|
6946
|
-
onPointerCancel: () => setPressing(false),
|
|
6947
|
-
children: /* @__PURE__ */ jsx("span", {
|
|
6948
|
-
className: "ui-switch-thumb",
|
|
6949
|
-
style: {
|
|
6950
|
-
left,
|
|
6951
|
-
right,
|
|
6952
|
-
height: th,
|
|
6953
|
-
marginTop: -th / 2,
|
|
6954
|
-
transition: `${dropTransition("left", "right", on)}, height 150ms ease, margin-top 150ms ease, background-color .2s ease`
|
|
6955
|
-
},
|
|
6956
|
-
children: /* @__PURE__ */ jsx("svg", {
|
|
6957
|
-
width: 12,
|
|
6958
|
-
height: 12,
|
|
6959
|
-
viewBox: "0 0 24 24",
|
|
6960
|
-
fill: "none",
|
|
6961
|
-
stroke: "currentColor",
|
|
6962
|
-
strokeWidth: 3.5,
|
|
6963
|
-
strokeLinecap: "round",
|
|
6964
|
-
strokeLinejoin: "round",
|
|
6965
|
-
"aria-hidden": "true",
|
|
6966
|
-
children: /* @__PURE__ */ jsx("path", { d: on ? "M5 12.5l4.5 4.5L19 7" : "M7 7l10 10M17 7L7 17" })
|
|
6967
|
-
})
|
|
6968
|
-
})
|
|
6969
|
-
});
|
|
6970
|
-
}
|
|
6971
7088
|
// src/components/Tag/Tag.tsx
|
|
6972
7089
|
/** What kind of thing an item is (「外部」「範本」): small gray text. Status uses Badge instead. */
|
|
6973
7090
|
function Tag({ children, className }) {
|
|
@@ -7125,58 +7242,82 @@ function bounds(target) {
|
|
|
7125
7242
|
bottom
|
|
7126
7243
|
};
|
|
7127
7244
|
}
|
|
7128
|
-
|
|
7129
|
-
|
|
7130
|
-
*
|
|
7131
|
-
|
|
7245
|
+
const area = (a, b) => Math.max(0, Math.min(a.left + a.width, b.left + b.width) - Math.max(a.left, b.left)) * Math.max(0, Math.min(a.top + a.height, b.top + b.height) - Math.max(a.top, b.top));
|
|
7246
|
+
/** Where the card goes for a highlighted box. Below, above, right, left (above first with side 'top'): the first
|
|
7247
|
+
* where the card fits inside the window and covers neither the target nor the parts the step keeps visible. When
|
|
7248
|
+
* none does (after the tour scrolled to make room, see makeRoom), the one that covers the least of the target, then
|
|
7249
|
+
* of those parts. Returns the card's box: it is placed at that box's top-left corner. */
|
|
7250
|
+
function placeCard(rect, cardH, prefer, area_, cardW = 320, keep = []) {
|
|
7132
7251
|
const margin = typeof document === "undefined" ? 12 : edge();
|
|
7133
|
-
const
|
|
7134
|
-
const
|
|
7135
|
-
const
|
|
7252
|
+
const vw = typeof window === "undefined" ? 0 : window.innerWidth;
|
|
7253
|
+
const vh = area_?.bottom ?? (typeof window === "undefined" ? 0 : window.innerHeight);
|
|
7254
|
+
const vt = area_?.top ?? 0;
|
|
7136
7255
|
if (!rect) return {
|
|
7137
7256
|
mode: "center",
|
|
7138
|
-
|
|
7139
|
-
|
|
7140
|
-
|
|
7141
|
-
|
|
7142
|
-
|
|
7143
|
-
|
|
7144
|
-
|
|
7145
|
-
height: 0
|
|
7146
|
-
}
|
|
7147
|
-
};
|
|
7148
|
-
const other = prefer === "bottom" ? "top" : "bottom";
|
|
7149
|
-
const side = fits(prefer) ? prefer : fits(other) ? other : null;
|
|
7150
|
-
if (side) return {
|
|
7151
|
-
mode: side,
|
|
7152
|
-
side,
|
|
7153
|
-
offset: GAP,
|
|
7154
|
-
margin,
|
|
7155
|
-
line: rect
|
|
7257
|
+
box: {
|
|
7258
|
+
left: (vw - cardW) / 2,
|
|
7259
|
+
top: Math.max(vt + margin, (vt + vh) / 2 - cardH / 2),
|
|
7260
|
+
width: cardW,
|
|
7261
|
+
height: cardH
|
|
7262
|
+
},
|
|
7263
|
+
fits: true
|
|
7156
7264
|
};
|
|
7157
|
-
const
|
|
7158
|
-
const
|
|
7159
|
-
const
|
|
7160
|
-
|
|
7161
|
-
|
|
7162
|
-
|
|
7163
|
-
|
|
7164
|
-
|
|
7165
|
-
|
|
7265
|
+
const clampX = (x) => Math.max(margin, Math.min(vw - margin - cardW, x));
|
|
7266
|
+
const clampY = (y) => Math.max(vt + margin, Math.min(vh - margin - cardH, y));
|
|
7267
|
+
const midX = rect.left + rect.width / 2 - cardW / 2;
|
|
7268
|
+
const midY = rect.top + rect.height / 2 - cardH / 2;
|
|
7269
|
+
const at = {
|
|
7270
|
+
bottom: {
|
|
7271
|
+
left: midX,
|
|
7272
|
+
top: rect.top + rect.height + GAP
|
|
7273
|
+
},
|
|
7274
|
+
top: {
|
|
7275
|
+
left: midX,
|
|
7276
|
+
top: rect.top - GAP - cardH
|
|
7277
|
+
},
|
|
7278
|
+
right: {
|
|
7279
|
+
left: rect.left + rect.width + GAP,
|
|
7280
|
+
top: midY
|
|
7281
|
+
},
|
|
7282
|
+
left: {
|
|
7283
|
+
left: rect.left - GAP - cardW,
|
|
7284
|
+
top: midY
|
|
7285
|
+
}
|
|
7166
7286
|
};
|
|
7167
|
-
const
|
|
7168
|
-
|
|
7287
|
+
const options = (prefer === "top" ? [
|
|
7288
|
+
"top",
|
|
7289
|
+
"bottom",
|
|
7290
|
+
"right",
|
|
7291
|
+
"left"
|
|
7292
|
+
] : [
|
|
7293
|
+
"bottom",
|
|
7294
|
+
"top",
|
|
7295
|
+
"right",
|
|
7296
|
+
"left"
|
|
7297
|
+
]).map((side) => {
|
|
7298
|
+
const want = at[side];
|
|
7299
|
+
const box = {
|
|
7300
|
+
left: clampX(want.left),
|
|
7301
|
+
top: clampY(want.top),
|
|
7302
|
+
width: cardW,
|
|
7303
|
+
height: cardH
|
|
7304
|
+
};
|
|
7305
|
+
const inside = side === "bottom" || side === "top" ? box.top === want.top : box.left === want.left;
|
|
7306
|
+
const onTarget = area(box, rect);
|
|
7307
|
+
const onKept = keep.reduce((n, k) => n + area(box, k), 0);
|
|
7308
|
+
return {
|
|
7309
|
+
mode: side,
|
|
7310
|
+
box,
|
|
7311
|
+
fits: inside && !onTarget && !onKept,
|
|
7312
|
+
onTarget,
|
|
7313
|
+
onKept
|
|
7314
|
+
};
|
|
7315
|
+
});
|
|
7316
|
+
const best = options.find((o) => o.fits) ?? [...options].sort((x, y) => x.onTarget - y.onTarget || x.onKept - y.onKept)[0];
|
|
7169
7317
|
return {
|
|
7170
|
-
mode:
|
|
7171
|
-
|
|
7172
|
-
|
|
7173
|
-
margin,
|
|
7174
|
-
line: {
|
|
7175
|
-
left: rect.left,
|
|
7176
|
-
top: bottom,
|
|
7177
|
-
width: rect.width,
|
|
7178
|
-
height: 0
|
|
7179
|
-
}
|
|
7318
|
+
mode: best.mode,
|
|
7319
|
+
box: best.box,
|
|
7320
|
+
fits: best.fits
|
|
7180
7321
|
};
|
|
7181
7322
|
}
|
|
7182
7323
|
/** The first-use walkthrough: the page goes dark except the part being introduced, with a card beside it. */
|
|
@@ -7185,6 +7326,7 @@ function Tour({ open, steps, onClose, skippable = true, step: controlled, onStep
|
|
|
7185
7326
|
const i = Math.max(0, Math.min(steps.length - 1, controlled ?? inner));
|
|
7186
7327
|
const step = steps[i];
|
|
7187
7328
|
const [rect, setRect] = React.useState(null);
|
|
7329
|
+
const [kept, setKept] = React.useState([]);
|
|
7188
7330
|
const next = React.useRef(null);
|
|
7189
7331
|
const [cardH, setCardH] = React.useState(0);
|
|
7190
7332
|
const [cardW, setCardW] = React.useState(320);
|
|
@@ -7238,6 +7380,12 @@ function Tour({ open, steps, onClose, skippable = true, step: controlled, onStep
|
|
|
7238
7380
|
}, [open]);
|
|
7239
7381
|
const target = step?.target;
|
|
7240
7382
|
const pad = step?.padding ?? 6;
|
|
7383
|
+
const keepList = step?.keepVisible == null ? [] : Array.isArray(step.keepVisible) ? step.keepVisible : [step.keepVisible];
|
|
7384
|
+
const keepKey = keepList.map((k) => typeof k === "string" ? k : "#").join("|");
|
|
7385
|
+
const keepRef = React.useRef(keepList);
|
|
7386
|
+
React.useLayoutEffect(() => {
|
|
7387
|
+
keepRef.current = keepList;
|
|
7388
|
+
});
|
|
7241
7389
|
const hasStep = !!step;
|
|
7242
7390
|
React.useEffect(() => {
|
|
7243
7391
|
if (!open || !hasStep) return;
|
|
@@ -7272,10 +7420,21 @@ function Tour({ open, steps, onClose, skippable = true, step: controlled, onStep
|
|
|
7272
7420
|
height: Math.max(0, Math.min(window.innerHeight - 3, r.bottom + pad) - t)
|
|
7273
7421
|
};
|
|
7274
7422
|
}
|
|
7275
|
-
const
|
|
7423
|
+
const ks = [];
|
|
7424
|
+
for (const kt of keepRef.current) {
|
|
7425
|
+
const kr = findTarget(kt)?.getBoundingClientRect();
|
|
7426
|
+
if (kr && kr.width) ks.push({
|
|
7427
|
+
left: kr.left,
|
|
7428
|
+
top: kr.top,
|
|
7429
|
+
width: kr.width,
|
|
7430
|
+
height: kr.height
|
|
7431
|
+
});
|
|
7432
|
+
}
|
|
7433
|
+
const k = JSON.stringify([v, ks]);
|
|
7276
7434
|
if (k !== last) {
|
|
7277
7435
|
last = k;
|
|
7278
7436
|
setRect(v);
|
|
7437
|
+
setKept(ks);
|
|
7279
7438
|
}
|
|
7280
7439
|
raf = requestAnimationFrame(tick);
|
|
7281
7440
|
};
|
|
@@ -7286,7 +7445,8 @@ function Tour({ open, steps, onClose, skippable = true, step: controlled, onStep
|
|
|
7286
7445
|
hasStep,
|
|
7287
7446
|
i,
|
|
7288
7447
|
target,
|
|
7289
|
-
pad
|
|
7448
|
+
pad,
|
|
7449
|
+
keepKey
|
|
7290
7450
|
]);
|
|
7291
7451
|
const observer = React.useRef(null);
|
|
7292
7452
|
const card = React.useCallback((el) => {
|
|
@@ -7312,7 +7472,12 @@ function Tour({ open, steps, onClose, skippable = true, step: controlled, onStep
|
|
|
7312
7472
|
const r = el.getBoundingClientRect();
|
|
7313
7473
|
const top = r.top - pad;
|
|
7314
7474
|
const bottom = r.bottom + pad;
|
|
7315
|
-
if (
|
|
7475
|
+
if (placeCard({
|
|
7476
|
+
left: r.left - pad,
|
|
7477
|
+
top,
|
|
7478
|
+
width: r.width + 2 * pad,
|
|
7479
|
+
height: bottom - top
|
|
7480
|
+
}, cardH, step?.side ?? "bottom", ar, cardW, kept).fits) return;
|
|
7316
7481
|
const want = bottom - top + GAP + cardH + 2 * m <= ar.bottom - ar.top ? ar.top + m + pad : ar.top + m + cardH + GAP + pad;
|
|
7317
7482
|
let box = el.parentElement;
|
|
7318
7483
|
while (box && !(/(auto|scroll)/.test(getComputedStyle(box).overflowY) && box.scrollHeight > box.clientHeight)) box = box.parentElement;
|
|
@@ -7334,15 +7499,11 @@ function Tour({ open, steps, onClose, skippable = true, step: controlled, onStep
|
|
|
7334
7499
|
measured,
|
|
7335
7500
|
cardH
|
|
7336
7501
|
]);
|
|
7337
|
-
const
|
|
7338
|
-
const place = placeCard(rect, cardH, step?.side ?? "bottom",
|
|
7339
|
-
const
|
|
7340
|
-
const
|
|
7341
|
-
|
|
7342
|
-
line?.top,
|
|
7343
|
-
line?.width,
|
|
7344
|
-
line?.height
|
|
7345
|
-
]);
|
|
7502
|
+
const room = open && step ? bounds(findTarget(step.target)) : void 0;
|
|
7503
|
+
const place = placeCard(rect, cardH, step?.side ?? "bottom", room, cardW, kept);
|
|
7504
|
+
const ax = place.box.left;
|
|
7505
|
+
const ay = place.box.top;
|
|
7506
|
+
const anchor = React.useMemo(() => ({ getBoundingClientRect: () => new DOMRect(ax, ay, 0, 0) }), [ax, ay]);
|
|
7346
7507
|
if (!open || !step) return null;
|
|
7347
7508
|
const lastStep = i === steps.length - 1;
|
|
7348
7509
|
return /* @__PURE__ */ jsx(Popover$1.Root, {
|
|
@@ -7361,13 +7522,12 @@ function Tour({ open, steps, onClose, skippable = true, step: controlled, onStep
|
|
|
7361
7522
|
}), /* @__PURE__ */ jsx(Popover$1.Positioner, {
|
|
7362
7523
|
className: "ui-float ui-tour-float",
|
|
7363
7524
|
anchor,
|
|
7364
|
-
side:
|
|
7365
|
-
align: "
|
|
7366
|
-
sideOffset:
|
|
7367
|
-
collisionPadding: place.margin,
|
|
7525
|
+
side: "bottom",
|
|
7526
|
+
align: "start",
|
|
7527
|
+
sideOffset: 0,
|
|
7368
7528
|
collisionAvoidance: {
|
|
7369
7529
|
side: "none",
|
|
7370
|
-
align: "
|
|
7530
|
+
align: "none",
|
|
7371
7531
|
fallbackAxisSide: "none"
|
|
7372
7532
|
},
|
|
7373
7533
|
children: /* @__PURE__ */ jsxs(Popover$1.Popup, {
|