@seanyeh77/ui 0.11.0 → 0.12.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/dist/bundle.js +9 -9
- package/dist/bundle.js.map +1 -1
- package/dist/{format-entry-Cvq4QsNK.d.ts → format-entry-BJI8MU2K.d.ts} +4 -1
- package/dist/{format-entry-CkHGBG0X.js → format-entry-jAIdVjUz.js} +14 -2
- package/dist/format-entry-jAIdVjUz.js.map +1 -0
- package/dist/format.d.ts +2 -2
- package/dist/format.js +1 -1
- package/dist/index.d.ts +25 -11
- package/dist/index.js +138 -51
- package/dist/index.js.map +1 -1
- package/dist/styles.css +40 -2
- package/docs/CommandPalette.md +2 -2
- package/docs/DataTable.md +1 -1
- package/docs/Graph.md +1 -1
- package/docs/LayerGraph.md +6 -4
- package/docs/Tabs.md +2 -1
- package/docs/guidelines.md +3 -3
- package/package.json +2 -2
- package/dist/format-entry-CkHGBG0X.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, 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-jAIdVjUz.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";
|
|
@@ -2306,7 +2306,7 @@ function score(it, q) {
|
|
|
2306
2306
|
}
|
|
2307
2307
|
/** One search for everything, opened with Ctrl K (⌘K). A panel in the middle of the screen; results sorted by relevance. */
|
|
2308
2308
|
function CommandPalette(props) {
|
|
2309
|
-
const { open, onOpenChange, items, onSelect, placeholder, recent, recentLabel, emptyText, kinds, filter = true, onQueryChange, loading, limit = 50, hotkey = true, defaultQuery = "", label } = props;
|
|
2309
|
+
const { open, onOpenChange, items, onSelect, placeholder, recent, recentLabel, emptyText, noResultsText, kinds, filter = true, onQueryChange, loading, limit = 50, hotkey = true, defaultQuery = "", label } = props;
|
|
2310
2310
|
const [q, setQ] = React.useState(defaultQuery);
|
|
2311
2311
|
const [active, setActive] = React.useState(0);
|
|
2312
2312
|
useReturnFocus(open);
|
|
@@ -2389,13 +2389,18 @@ function CommandPalette(props) {
|
|
|
2389
2389
|
] }) : t
|
|
2390
2390
|
});
|
|
2391
2391
|
};
|
|
2392
|
-
const
|
|
2392
|
+
const none = (t) => typeof noResultsText === "function" ? noResultsText(t) : (noResultsText ?? tr("找不到符合「{q}」的結果")).replace("{q}", t);
|
|
2393
|
+
const empty = query ? none(q.trim()) : emptyText || tr("輸入名稱開始搜尋");
|
|
2393
2394
|
const said = !open ? "" : !query ? "" : loading ? tr("搜尋中") : shown.length ? tr("找到 {n} 筆結果", { n: shown.length }) : empty;
|
|
2394
2395
|
React.useEffect(() => {
|
|
2395
2396
|
if (!said) return;
|
|
2396
2397
|
const t = setTimeout(() => announce(said), 400);
|
|
2397
2398
|
return () => clearTimeout(t);
|
|
2398
|
-
}, [
|
|
2399
|
+
}, [
|
|
2400
|
+
said,
|
|
2401
|
+
query,
|
|
2402
|
+
loading
|
|
2403
|
+
]);
|
|
2399
2404
|
return /* @__PURE__ */ jsx(Dialog$1.Root, {
|
|
2400
2405
|
open,
|
|
2401
2406
|
onOpenChange,
|
|
@@ -2556,6 +2561,20 @@ function Tabs({ items, value, onChange, label, unit, className }) {
|
|
|
2556
2561
|
const [box, setBox] = React.useState(null);
|
|
2557
2562
|
const [forward, setForward] = React.useState(true);
|
|
2558
2563
|
const [moving, bump] = useMoving();
|
|
2564
|
+
const [more, setMore] = React.useState({
|
|
2565
|
+
left: false,
|
|
2566
|
+
right: false
|
|
2567
|
+
});
|
|
2568
|
+
const edges = React.useCallback(() => {
|
|
2569
|
+
const el = track.current;
|
|
2570
|
+
if (!el) return;
|
|
2571
|
+
const left = el.scrollLeft > 1;
|
|
2572
|
+
const right = el.scrollLeft + el.clientWidth < el.scrollWidth - 1;
|
|
2573
|
+
setMore((m) => m.left === left && m.right === right ? m : {
|
|
2574
|
+
left,
|
|
2575
|
+
right
|
|
2576
|
+
});
|
|
2577
|
+
}, []);
|
|
2559
2578
|
useFocusRescue(track, () => refs.current[Math.max(0, items.findIndex((t) => t.id === value))]);
|
|
2560
2579
|
devWarn(items.some((t) => t.count != null && !(t.unit || unit)), "Tabs", "a count has no unit, so it reads as a bare number. Pass unit, e.g. unit: '筆', on Tabs or on the item.");
|
|
2561
2580
|
const idx = Math.max(0, items.findIndex((t) => t.id === value));
|
|
@@ -2563,28 +2582,38 @@ function Tabs({ items, value, onChange, label, unit, className }) {
|
|
|
2563
2582
|
const el = refs.current[idx];
|
|
2564
2583
|
const tr = track.current;
|
|
2565
2584
|
if (!el || !tr) return;
|
|
2566
|
-
const measure = () =>
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2585
|
+
const measure = () => {
|
|
2586
|
+
setBox({
|
|
2587
|
+
left: el.offsetLeft,
|
|
2588
|
+
right: tr.clientWidth - el.offsetLeft - el.offsetWidth
|
|
2589
|
+
});
|
|
2590
|
+
edges();
|
|
2591
|
+
};
|
|
2570
2592
|
measure();
|
|
2593
|
+
if (el.offsetLeft < tr.scrollLeft) tr.scrollLeft = el.offsetLeft - 4;
|
|
2594
|
+
else if (el.offsetLeft + el.offsetWidth > tr.scrollLeft + tr.clientWidth) tr.scrollLeft = el.offsetLeft + el.offsetWidth - tr.clientWidth + 4;
|
|
2571
2595
|
const ro = new ResizeObserver(measure);
|
|
2572
2596
|
ro.observe(tr);
|
|
2573
2597
|
for (const t of refs.current) if (t) ro.observe(t);
|
|
2574
2598
|
return () => ro.disconnect();
|
|
2575
|
-
}, [
|
|
2599
|
+
}, [
|
|
2600
|
+
idx,
|
|
2601
|
+
items.length,
|
|
2602
|
+
edges
|
|
2603
|
+
]);
|
|
2576
2604
|
const go = (i) => {
|
|
2577
2605
|
if (i === idx || !items[i]) return;
|
|
2578
2606
|
setForward(i > idx);
|
|
2579
2607
|
bump();
|
|
2580
2608
|
onChange?.(items[i].id);
|
|
2581
|
-
announce(items[i].label + (items[i].count != null ? " " + format.number(items[i].count ?? 0) + (items[i].unit || unit ? " " +
|
|
2609
|
+
announce(items[i].label + (items[i].count != null ? " " + format.number(items[i].count ?? 0) + (items[i].unit || unit ? " " + unitFor(items[i].unit || unit, items[i].count ?? 0) : "") : ""));
|
|
2582
2610
|
};
|
|
2583
2611
|
return /* @__PURE__ */ jsxs("div", {
|
|
2584
2612
|
ref: track,
|
|
2585
|
-
className: cx("ui-tabs", className),
|
|
2613
|
+
className: cx("ui-tabs", more.left && "has-more-left", more.right && "has-more-right", className),
|
|
2586
2614
|
role: "tablist",
|
|
2587
2615
|
"aria-label": label,
|
|
2616
|
+
onScroll: edges,
|
|
2588
2617
|
children: [box ? /* @__PURE__ */ jsx("span", {
|
|
2589
2618
|
className: "ui-tabs-ind",
|
|
2590
2619
|
"aria-hidden": "true",
|
|
@@ -2619,7 +2648,7 @@ function Tabs({ items, value, onChange, label, unit, className }) {
|
|
|
2619
2648
|
className: "ui-tab-count",
|
|
2620
2649
|
children: [format.number(t.count), t.unit || unit ? /* @__PURE__ */ jsxs(Fragment, { children: [" ", /* @__PURE__ */ jsx("span", {
|
|
2621
2650
|
className: "ui-unit",
|
|
2622
|
-
children:
|
|
2651
|
+
children: unitFor(t.unit || unit, t.count)
|
|
2623
2652
|
})] }) : null]
|
|
2624
2653
|
}) : null
|
|
2625
2654
|
]
|
|
@@ -3529,6 +3558,7 @@ function DataTable(p) {
|
|
|
3529
3558
|
"aria-label": tr("檢視"),
|
|
3530
3559
|
children: p.views.map((v) => {
|
|
3531
3560
|
const on = v.id === view;
|
|
3561
|
+
const vn = rows.filter((r) => !v.filter || v.filter(r)).length;
|
|
3532
3562
|
return /* @__PURE__ */ jsxs("button", {
|
|
3533
3563
|
type: "button",
|
|
3534
3564
|
role: "tab",
|
|
@@ -3541,11 +3571,11 @@ function DataTable(p) {
|
|
|
3541
3571
|
children: [v.label, /* @__PURE__ */ jsxs("span", {
|
|
3542
3572
|
className: "ui-dt-view-n",
|
|
3543
3573
|
children: [
|
|
3544
|
-
format.number(
|
|
3574
|
+
format.number(vn),
|
|
3545
3575
|
" ",
|
|
3546
3576
|
/* @__PURE__ */ jsx("span", {
|
|
3547
3577
|
className: "ui-unit",
|
|
3548
|
-
children:
|
|
3578
|
+
children: unitFor("筆", vn)
|
|
3549
3579
|
})
|
|
3550
3580
|
]
|
|
3551
3581
|
})]
|
|
@@ -4501,7 +4531,7 @@ function Swatch({ type }) {
|
|
|
4501
4531
|
y1: 4,
|
|
4502
4532
|
x2: 28,
|
|
4503
4533
|
y2: 4,
|
|
4504
|
-
className: cx("ui-graph-edge", type === "inferred" && "is-inferred")
|
|
4534
|
+
className: cx("ui-graph-edge", type === "inferred" && "is-inferred", type === "declared" && "is-declared")
|
|
4505
4535
|
})
|
|
4506
4536
|
});
|
|
4507
4537
|
}
|
|
@@ -4646,7 +4676,7 @@ function wraps(text) {
|
|
|
4646
4676
|
for (const t of text.match(/`[^`]+`|[A-Za-z0-9_./:#@-]+|\s+|[\s\S]/gu) ?? []) {
|
|
4647
4677
|
const prev = atoms[atoms.length - 1];
|
|
4648
4678
|
const unit = /\d\s*$/.test(prev ?? "") && !/^[A-Za-z0-9_]/.test(t);
|
|
4649
|
-
if (prev != null && (unit || /^[)」』、,。:;!?)\]]/.test(t) || /[(「『([]$/.test(prev))) atoms[atoms.length - 1] = prev + t;
|
|
4679
|
+
if (prev != null && (unit || /^[)」』、,。:;!?)\],;!?]/.test(t) || /[(「『([]$/.test(prev))) atoms[atoms.length - 1] = prev + t;
|
|
4650
4680
|
else atoms.push(t);
|
|
4651
4681
|
}
|
|
4652
4682
|
const fill = (max) => {
|
|
@@ -4716,7 +4746,7 @@ const clean = (pts) => pts.filter((q, i) => {
|
|
|
4716
4746
|
});
|
|
4717
4747
|
/** Architecture as layers of boxes with arrows. Line width shows how often; inferred relations are dashed and labelled;
|
|
4718
4748
|
* shared items are listed under the diagram instead of drawn. Wider than its box: the boxes narrow (down to 120 px),
|
|
4719
|
-
* then the whole diagram scales down (to 0.75 at least); past that it scrolls sideways (PM). */
|
|
4749
|
+
* then the whole diagram scales down (to 0.75 at least); past that it scrolls sideways at full width (PM, WA). */
|
|
4720
4750
|
function LayerGraph(p) {
|
|
4721
4751
|
const [avail, setAvail] = React.useState(0);
|
|
4722
4752
|
const [fit, setFit] = React.useState(null);
|
|
@@ -4742,6 +4772,7 @@ function LayerGraph(p) {
|
|
|
4742
4772
|
const main = all.filter((n) => !n.shared);
|
|
4743
4773
|
const shared = all.filter((n) => n.shared);
|
|
4744
4774
|
const edges = p.edges.filter((e) => !sharedIds.has(e.from) && !sharedIds.has(e.to));
|
|
4775
|
+
const lab = (e) => !!(e.inferred || e.declared);
|
|
4745
4776
|
const byLayer = /* @__PURE__ */ new Map();
|
|
4746
4777
|
const EXTERNAL = Number.NEGATIVE_INFINITY;
|
|
4747
4778
|
for (const n of main) {
|
|
@@ -4872,12 +4903,13 @@ function LayerGraph(p) {
|
|
|
4872
4903
|
};
|
|
4873
4904
|
const midSentence = (t) => /^[A-Z][a-z]/.test(t) && !/^zh/i.test(format.locale()) ? t[0].toLowerCase() + t.slice(1) : t;
|
|
4874
4905
|
const sameLabel = /* @__PURE__ */ new Map();
|
|
4875
|
-
for (const e of edges) if (e
|
|
4906
|
+
for (const e of edges) if (lab(e) && e.label && pos[e.from] && pos[e.to]) sameLabel.set(e.label, (sameLabel.get(e.label) ?? 0) + 1);
|
|
4907
|
+
const kindWord = (e) => e.declared ? p.declaredLabel || tr("宣告") : p.inferredLabel || tr("推測");
|
|
4876
4908
|
const inferredText = (e) => e.label && (sameLabel.get(e.label) ?? 0) > 1 ? tr("來自 {from},{label}", {
|
|
4877
4909
|
from: nameOf(e.from),
|
|
4878
4910
|
label: midSentence(e.label)
|
|
4879
|
-
}) : e.label ||
|
|
4880
|
-
const markText = (e) => e
|
|
4911
|
+
}) : e.label || kindWord(e);
|
|
4912
|
+
const markText = (e) => lab(e) ? inferredText(e) : countText(e);
|
|
4881
4913
|
if (upsL.length) {
|
|
4882
4914
|
const left0 = Math.min(...main.map((n) => pos[n.id].x));
|
|
4883
4915
|
const shift = Math.max(0, PAD + (upsL.length - 1) * LANE_STEP + LANE - left0);
|
|
@@ -4905,7 +4937,7 @@ function LayerGraph(p) {
|
|
|
4905
4937
|
const laneCount = {};
|
|
4906
4938
|
{
|
|
4907
4939
|
const into = {};
|
|
4908
|
-
for (const e of edges) if (ins[e.to]?.includes(e) && (e
|
|
4940
|
+
for (const e of edges) if (ins[e.to]?.includes(e) && (lab(e) || related(e))) (into[e.to] ??= []).push(e);
|
|
4909
4941
|
for (const id in into) {
|
|
4910
4942
|
if (into[id].length < 2) continue;
|
|
4911
4943
|
laneGroups[id] = into[id].sort((a, b) => txOf(b) - txOf(a));
|
|
@@ -5172,7 +5204,7 @@ function LayerGraph(p) {
|
|
|
5172
5204
|
y0 - 3,
|
|
5173
5205
|
y0 + 3
|
|
5174
5206
|
]);
|
|
5175
|
-
if (e
|
|
5207
|
+
if (lab(e) || r) {
|
|
5176
5208
|
const text = markText(e);
|
|
5177
5209
|
marks.push({
|
|
5178
5210
|
idx,
|
|
@@ -5209,7 +5241,7 @@ function LayerGraph(p) {
|
|
|
5209
5241
|
f.y - 3,
|
|
5210
5242
|
f.y + 3
|
|
5211
5243
|
]);
|
|
5212
|
-
if (e
|
|
5244
|
+
if (lab(e) || r) {
|
|
5213
5245
|
const text = markText(e);
|
|
5214
5246
|
marks.push({
|
|
5215
5247
|
idx,
|
|
@@ -5259,7 +5291,7 @@ function LayerGraph(p) {
|
|
|
5259
5291
|
ty
|
|
5260
5292
|
]);
|
|
5261
5293
|
}
|
|
5262
|
-
const w = (e
|
|
5294
|
+
const w = (lab(e) ? 1.5 : 1.5 + 5.5 * ((e.count || 0) / maxCount)) + (picked ? 1.5 : 0) + (hovered ? 2 : 0);
|
|
5263
5295
|
const cpts = clean(pts);
|
|
5264
5296
|
ptsOf[idx] = cpts;
|
|
5265
5297
|
for (let k = 1; k < cpts.length; k++) {
|
|
@@ -5277,7 +5309,7 @@ function LayerGraph(p) {
|
|
|
5277
5309
|
}
|
|
5278
5310
|
const d = route(cpts, 10);
|
|
5279
5311
|
paths.push(/* @__PURE__ */ jsx("path", {
|
|
5280
|
-
className: cx("ui-lg-edge", e.inferred && "is-inferred", r && "is-related", dim && "is-dim", hovered && "is-hover"),
|
|
5312
|
+
className: cx("ui-lg-edge", e.declared ? "is-declared" : e.inferred && "is-inferred", r && "is-related", dim && "is-dim", hovered && "is-hover"),
|
|
5281
5313
|
d,
|
|
5282
5314
|
strokeWidth: w
|
|
5283
5315
|
}, "p" + idx));
|
|
@@ -5318,7 +5350,7 @@ function LayerGraph(p) {
|
|
|
5318
5350
|
className: cx("ui-lg-arrow", r && "is-related", dim && "is-dim"),
|
|
5319
5351
|
d: arrow
|
|
5320
5352
|
}, "a" + idx));
|
|
5321
|
-
if (!up && !isFlat(e) && (e
|
|
5353
|
+
if (!up && !isFlat(e) && (lab(e) || r)) {
|
|
5322
5354
|
const text = markText(e);
|
|
5323
5355
|
marks.push({
|
|
5324
5356
|
idx,
|
|
@@ -5344,9 +5376,20 @@ function LayerGraph(p) {
|
|
|
5344
5376
|
]);
|
|
5345
5377
|
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);
|
|
5346
5378
|
const cross = (q, x0, lw, y0, y1) => x0 < q[1] - 1 && q[0] + 1 < x0 + lw && y0 < q[3] - 1 && q[2] + 1 < y1;
|
|
5347
|
-
const
|
|
5379
|
+
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 alongLine = (m, own = false) => {
|
|
5348
5381
|
const pts = ptsOf[m.idx] ?? [];
|
|
5349
|
-
const
|
|
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
|
+
};
|
|
5392
|
+
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);
|
|
5350
5393
|
for (const lines of wraps(m.text)) {
|
|
5351
5394
|
const lw = Math.ceil(Math.max(...lines.map(labelWidth)));
|
|
5352
5395
|
const lh = lines.length * 16;
|
|
@@ -5380,9 +5423,9 @@ function LayerGraph(p) {
|
|
|
5380
5423
|
}
|
|
5381
5424
|
return null;
|
|
5382
5425
|
};
|
|
5383
|
-
const labelEl = (m, x0, top, lines = [m.text]) => /* @__PURE__ */ jsx("span", {
|
|
5426
|
+
const labelEl = (m, x0, top, lines = [m.text], over = false) => /* @__PURE__ */ jsx("span", {
|
|
5384
5427
|
"aria-hidden": pickEdge ? true : void 0,
|
|
5385
|
-
className: cx("ui-lg-label", 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"),
|
|
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"),
|
|
5386
5429
|
style: {
|
|
5387
5430
|
left: x0,
|
|
5388
5431
|
top
|
|
@@ -5395,7 +5438,8 @@ function LayerGraph(p) {
|
|
|
5395
5438
|
onPointerLeave: pickEdge ? () => setHover(null) : void 0,
|
|
5396
5439
|
children: lines.map((t, i) => /* @__PURE__ */ jsxs(React.Fragment, { children: [i ? /* @__PURE__ */ jsx("br", {}) : null, labelParts(t)] }, i))
|
|
5397
5440
|
}, "l" + m.idx);
|
|
5398
|
-
|
|
5441
|
+
const later = [];
|
|
5442
|
+
const place = (m, last) => {
|
|
5399
5443
|
const w = Math.ceil(labelWidth(m.text));
|
|
5400
5444
|
if (m.flat) {
|
|
5401
5445
|
let spot = alongLine(m);
|
|
@@ -5426,6 +5470,23 @@ function LayerGraph(p) {
|
|
|
5426
5470
|
return;
|
|
5427
5471
|
}
|
|
5428
5472
|
if (m.up) {
|
|
5473
|
+
const p0 = ptsOf[m.idx]?.[0];
|
|
5474
|
+
const near = p0 ? alongLine({
|
|
5475
|
+
...m,
|
|
5476
|
+
tx: p0[0],
|
|
5477
|
+
ty: p0[1]
|
|
5478
|
+
}, true) : null;
|
|
5479
|
+
if (near) {
|
|
5480
|
+
placed.push([
|
|
5481
|
+
near.x0,
|
|
5482
|
+
near.x0 + near.lw,
|
|
5483
|
+
near.top - near.lh / 2 - 4,
|
|
5484
|
+
near.top + near.lh / 2 + 4,
|
|
5485
|
+
6
|
|
5486
|
+
]);
|
|
5487
|
+
labels.push(labelEl(m, near.x0, near.top, near.lines));
|
|
5488
|
+
return;
|
|
5489
|
+
}
|
|
5429
5490
|
const x0Of = (lw) => Math.max(PAD / 2, Math.min(W - PAD / 2 - lw, m.left ? m.tx - lw : m.tx));
|
|
5430
5491
|
const start0 = Math.max(10, Math.min(H - 10, m.ty));
|
|
5431
5492
|
const find = (x0, lw, lh, withLines) => {
|
|
@@ -5534,6 +5595,11 @@ function LayerGraph(p) {
|
|
|
5534
5595
|
if (spot) break;
|
|
5535
5596
|
}
|
|
5536
5597
|
if (!spot) spot = alongLine(m);
|
|
5598
|
+
if (!spot && !last) {
|
|
5599
|
+
later.push(m);
|
|
5600
|
+
return;
|
|
5601
|
+
}
|
|
5602
|
+
const over = !spot;
|
|
5537
5603
|
if (!spot) {
|
|
5538
5604
|
if (g >= 0) need.add(g);
|
|
5539
5605
|
covered++;
|
|
@@ -5577,14 +5643,16 @@ function LayerGraph(p) {
|
|
|
5577
5643
|
placed.push([
|
|
5578
5644
|
spot.x0,
|
|
5579
5645
|
spot.x0 + spot.lw,
|
|
5580
|
-
spot.top - spot.lh / 2 -
|
|
5581
|
-
spot.top + spot.lh / 2 +
|
|
5646
|
+
spot.top - spot.lh / 2 - 4,
|
|
5647
|
+
spot.top + spot.lh / 2 + 4,
|
|
5582
5648
|
6
|
|
5583
5649
|
]);
|
|
5584
5650
|
wide = Math.max(wide, spot.x0 + spot.lw + PAD / 2 + 4);
|
|
5585
5651
|
least = Math.min(least, spot.x0 - PAD / 2 - 4);
|
|
5586
|
-
labels.push(labelEl(m, spot.x0, spot.top, spot.lines));
|
|
5587
|
-
}
|
|
5652
|
+
labels.push(labelEl(m, spot.x0, spot.top, spot.lines, over));
|
|
5653
|
+
};
|
|
5654
|
+
marks.sort((m, n) => Number(!!m.up) - Number(!!n.up) || m.ty - n.ty || m.tx - n.tx).forEach((m) => place(m, false));
|
|
5655
|
+
later.forEach((m) => place(m, true));
|
|
5588
5656
|
return {
|
|
5589
5657
|
paths,
|
|
5590
5658
|
labels,
|
|
@@ -5700,10 +5768,10 @@ function LayerGraph(p) {
|
|
|
5700
5768
|
})]
|
|
5701
5769
|
}, s.id);
|
|
5702
5770
|
});
|
|
5703
|
-
const edgeText = (e) => e
|
|
5771
|
+
const edgeText = (e) => lab(e) ? e.label ? tr("{label}({inferred})", {
|
|
5704
5772
|
label: e.label,
|
|
5705
|
-
inferred:
|
|
5706
|
-
}) :
|
|
5773
|
+
inferred: kindWord(e)
|
|
5774
|
+
}) : kindWord(e) : countText(e);
|
|
5707
5775
|
const listItem = (key, on, dim, onClick, head, rest) => /* @__PURE__ */ jsxs("li", {
|
|
5708
5776
|
className: cx("ui-lg-li", dim && "is-dim"),
|
|
5709
5777
|
children: [onClick ? /* @__PURE__ */ jsx("button", {
|
|
@@ -5763,7 +5831,7 @@ function LayerGraph(p) {
|
|
|
5763
5831
|
})]
|
|
5764
5832
|
});
|
|
5765
5833
|
const showList = p.listView !== false && view === "list";
|
|
5766
|
-
const toggleShown = p.labelToggle !== false && !showList && p.edges.some((e) => e
|
|
5834
|
+
const toggleShown = p.labelToggle !== false && !showList && p.edges.some((e) => lab(e));
|
|
5767
5835
|
React.useLayoutEffect(() => {
|
|
5768
5836
|
const el = scrollRef.current;
|
|
5769
5837
|
if (!el) return;
|
|
@@ -5788,11 +5856,22 @@ function LayerGraph(p) {
|
|
|
5788
5856
|
});
|
|
5789
5857
|
return;
|
|
5790
5858
|
}
|
|
5791
|
-
if (fitted.
|
|
5792
|
-
const s = avail / W;
|
|
5793
|
-
if (s
|
|
5859
|
+
if (fitted.full) return;
|
|
5860
|
+
const s = Math.floor(avail / W * 1e3) / 1e3;
|
|
5861
|
+
if (W > avail + .5 && s < .75) {
|
|
5862
|
+
setFit({
|
|
5863
|
+
...fitted,
|
|
5864
|
+
nw: p.nodeWidth || 200,
|
|
5865
|
+
col: 40,
|
|
5866
|
+
scale: 1,
|
|
5867
|
+
full: true
|
|
5868
|
+
});
|
|
5869
|
+
return;
|
|
5870
|
+
}
|
|
5871
|
+
const want = W <= avail + .5 ? 1 : s;
|
|
5872
|
+
if (want !== fitted.scale) setFit({
|
|
5794
5873
|
...fitted,
|
|
5795
|
-
scale:
|
|
5874
|
+
scale: want
|
|
5796
5875
|
});
|
|
5797
5876
|
}, [
|
|
5798
5877
|
avail,
|
|
@@ -5906,14 +5985,22 @@ function LayerGraph(p) {
|
|
|
5906
5985
|
children: sharedBoxes
|
|
5907
5986
|
})]
|
|
5908
5987
|
}) : null,
|
|
5909
|
-
showList || p.legend === false || !p.legendItems && !edges.some((e) => pos[e.from] && pos[e.to]) ? null : /* @__PURE__ */ jsx(GraphLegend, { items: p.legendItems || [
|
|
5910
|
-
|
|
5911
|
-
|
|
5912
|
-
|
|
5913
|
-
|
|
5914
|
-
|
|
5915
|
-
|
|
5916
|
-
|
|
5988
|
+
showList || p.legend === false || !p.legendItems && !edges.some((e) => pos[e.from] && pos[e.to]) ? null : /* @__PURE__ */ jsx(GraphLegend, { items: p.legendItems || [
|
|
5989
|
+
...edges.some((e) => !lab(e) && pos[e.from] && pos[e.to]) ? [{
|
|
5990
|
+
type: "weight",
|
|
5991
|
+
label: "次數越多線越粗"
|
|
5992
|
+
}] : [],
|
|
5993
|
+
...edges.some((e) => e.inferred && !e.declared && pos[e.from] && pos[e.to]) ? [{
|
|
5994
|
+
type: "inferred",
|
|
5995
|
+
label: p.inferredLabel || "推測的關係",
|
|
5996
|
+
text: p.inferredText
|
|
5997
|
+
}] : [],
|
|
5998
|
+
...edges.some((e) => e.declared && pos[e.from] && pos[e.to]) ? [{
|
|
5999
|
+
type: "declared",
|
|
6000
|
+
label: p.declaredLegend || "專案宣告的關係",
|
|
6001
|
+
text: p.declaredText
|
|
6002
|
+
}] : []
|
|
6003
|
+
] })
|
|
5917
6004
|
]
|
|
5918
6005
|
});
|
|
5919
6006
|
}
|