@seanyeh77/ui 0.8.1 → 0.9.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 +9 -9
- package/dist/bundle.js.map +1 -1
- package/dist/{format-entry-B2xJlA9l.js → format-entry-CbNdiURz.js} +33 -2
- package/dist/format-entry-CbNdiURz.js.map +1 -0
- package/dist/{format-entry-BKj7P9i6.d.ts → format-entry-Cvq4QsNK.d.ts} +8 -0
- package/dist/format.d.ts +1 -1
- package/dist/format.js +1 -1
- package/dist/index.d.ts +36 -4
- package/dist/index.js +372 -69
- package/dist/index.js.map +1 -1
- package/dist/styles.css +163 -0
- package/docs/AppShell.md +1 -1
- package/docs/DataTable.md +5 -2
- package/docs/Format.md +7 -0
- package/docs/LayerGraph.md +3 -2
- package/docs/RadioGroup.md +1 -1
- package/docs/SplitPane.md +38 -0
- package/docs/Tabs.md +1 -0
- package/docs/TextArea.md +1 -1
- package/docs/TopBar.md +1 -1
- package/docs/Tour.md +2 -1
- package/docs/TreeList.md +4 -4
- package/docs/guidelines.md +1 -1
- package/docs/layout.md +1 -0
- package/package.json +2 -2
- package/dist/format-entry-B2xJlA9l.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, 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-CbNdiURz.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";
|
|
@@ -266,7 +266,12 @@ function store(key, value) {
|
|
|
266
266
|
function reduced() {
|
|
267
267
|
return typeof window !== "undefined" && typeof window.matchMedia === "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
268
268
|
}
|
|
269
|
-
const
|
|
269
|
+
const nav = typeof navigator !== "undefined" ? navigator : void 0;
|
|
270
|
+
const IS_MAC = /mac|iphone|ipad/i.test(nav?.userAgentData?.platform || nav?.platform || nav?.userAgent || "");
|
|
271
|
+
/** A touch screen as the main input (phones, tablets): no keyboard to press a shortcut with, no hover. Phones and
|
|
272
|
+
* tablets report (pointer: coarse); (hover: none) alone is not used, since Chromium keeps it after touch emulation is
|
|
273
|
+
* turned off and a mouse would then lose its Tooltips. */
|
|
274
|
+
const TOUCH_ONLY = "(pointer: coarse)";
|
|
270
275
|
const SHORTCUT = IS_MAC ? "⌘K" : "Ctrl K";
|
|
271
276
|
/** Matches a media query and follows changes. */
|
|
272
277
|
function useMedia(query) {
|
|
@@ -310,6 +315,20 @@ function digits(text, numbers = /(\d[\d,.:/]*)/) {
|
|
|
310
315
|
children: t
|
|
311
316
|
}, i) : t);
|
|
312
317
|
}
|
|
318
|
+
/** Alt, Meta or Ctrl held: the key belongs to the browser or the system (Alt+← goes back a page), not to the widget. */
|
|
319
|
+
const browserKey = (e) => e.altKey || e.metaKey || e.ctrlKey;
|
|
320
|
+
/** The words in a React node, as a screen reader would read them: strings and numbers, through elements' children. */
|
|
321
|
+
function nodeText(node) {
|
|
322
|
+
if (node == null || typeof node === "boolean") return "";
|
|
323
|
+
if (typeof node === "string" || typeof node === "number") return String(node);
|
|
324
|
+
if (Array.isArray(node)) return node.map(nodeText).join("");
|
|
325
|
+
if (React.isValidElement(node)) {
|
|
326
|
+
const props = node.props;
|
|
327
|
+
if (typeof props["aria-label"] === "string") return props["aria-label"];
|
|
328
|
+
return nodeText(props.children) || (typeof props.label === "string" ? props.label : "");
|
|
329
|
+
}
|
|
330
|
+
return "";
|
|
331
|
+
}
|
|
313
332
|
// src/icons/Icon.tsx
|
|
314
333
|
const BY_MARKUP = /* @__PURE__ */ new Map();
|
|
315
334
|
for (const k of Object.keys(PH)) {
|
|
@@ -693,6 +712,7 @@ function IconButton({ label, icon, className, tooltip = true, ...native }) {
|
|
|
693
712
|
// src/components/TopBar/TopBar.tsx
|
|
694
713
|
/** The bar at the top of a dashboard page: title or breadcrumb on the left, search and tools on the right. */
|
|
695
714
|
function TopBar({ title, breadcrumb, onSearch, searchLabel, children, onMenu, className }) {
|
|
715
|
+
const touch = useMedia(TOUCH_ONLY);
|
|
696
716
|
return /* @__PURE__ */ jsxs("header", {
|
|
697
717
|
className: cx("ui-topbar", className),
|
|
698
718
|
children: [
|
|
@@ -721,13 +741,13 @@ function TopBar({ title, breadcrumb, onSearch, searchLabel, children, onMenu, cl
|
|
|
721
741
|
size: 16
|
|
722
742
|
}),
|
|
723
743
|
/* @__PURE__ */ jsx("span", { children: searchLabel || tr("搜尋") }),
|
|
724
|
-
/* @__PURE__ */ jsx("kbd", { children: SHORTCUT })
|
|
744
|
+
touch ? null : /* @__PURE__ */ jsx("kbd", { children: SHORTCUT })
|
|
725
745
|
]
|
|
726
746
|
}), /* @__PURE__ */ jsx(IconButton, {
|
|
727
747
|
className: "ui-search-icon",
|
|
728
748
|
"data-tour": "search",
|
|
729
749
|
icon: "magnifying-glass",
|
|
730
|
-
label: tr("搜尋({k})", { k: SHORTCUT }),
|
|
750
|
+
label: touch ? tr("搜尋") : tr("搜尋({k})", { k: SHORTCUT }),
|
|
731
751
|
onClick: onSearch
|
|
732
752
|
})] }) : null, children]
|
|
733
753
|
})
|
|
@@ -958,15 +978,22 @@ function Drawer({ open, onClose, title, actions, dirty, width, side = "right", c
|
|
|
958
978
|
});
|
|
959
979
|
}
|
|
960
980
|
// src/internal/focusMain.ts
|
|
981
|
+
let lastInput = "pointer";
|
|
982
|
+
if (typeof document !== "undefined") {
|
|
983
|
+
document.addEventListener("keydown", () => lastInput = "key", true);
|
|
984
|
+
document.addEventListener("pointerdown", () => lastInput = "pointer", true);
|
|
985
|
+
}
|
|
961
986
|
/** Moves keyboard and screen-reader focus to the page's content: its first heading inside main (or the top bar's title),
|
|
962
|
-
* else main itself. Call it after the app changes page, e.g. when a CommandPalette result opens another page.
|
|
987
|
+
* else main itself. Call it after the app changes page, e.g. when a CommandPalette result opens another page. The
|
|
988
|
+
* heading gets no focus ring: a 3 px accent bar on its left after a key press, nothing after a mouse or touch. */
|
|
963
989
|
function focusMain() {
|
|
964
990
|
if (typeof document === "undefined") return;
|
|
965
991
|
const main = document.querySelector("main");
|
|
966
992
|
const target = main?.querySelector("h1, h2") ?? document.querySelector(".ui-topbar-title") ?? main;
|
|
967
993
|
if (!target) return;
|
|
968
994
|
if (target.tabIndex < 0 && !target.hasAttribute("tabindex")) target.setAttribute("tabindex", "-1");
|
|
969
|
-
target.focus
|
|
995
|
+
target.setAttribute("data-ui-main-focus", lastInput);
|
|
996
|
+
target.focus({ preventScroll: false });
|
|
970
997
|
}
|
|
971
998
|
// src/components/AppShell/AppShell.tsx
|
|
972
999
|
const COLLAPSE_KEY = "ui-nav-collapsed";
|
|
@@ -2470,6 +2497,7 @@ function Tabs({ items, value, onChange, label, unit, className }) {
|
|
|
2470
2497
|
className: cx("ui-tab", i === idx && "is-selected"),
|
|
2471
2498
|
onClick: () => go(i),
|
|
2472
2499
|
onKeyDown: (e) => {
|
|
2500
|
+
if (browserKey(e)) return;
|
|
2473
2501
|
const to = e.key === "ArrowRight" ? (i + 1) % items.length : e.key === "ArrowLeft" ? (i - 1 + items.length) % items.length : -1;
|
|
2474
2502
|
if (to < 0) return;
|
|
2475
2503
|
e.preventDefault();
|
|
@@ -2842,12 +2870,14 @@ function FilterButton({ filters, values, activeCount, count, onChange, onClear }
|
|
|
2842
2870
|
})]
|
|
2843
2871
|
});
|
|
2844
2872
|
}
|
|
2845
|
-
/** Long text in a cell. Phone cards: at most 2 lines with 「顯示全部」. Desktop: one line;
|
|
2846
|
-
*
|
|
2873
|
+
/** Long text in a cell. Phone cards: at most 2 lines with 「顯示全部」. Desktop: one line; the row's caret shows it in
|
|
2874
|
+
* full below the row, and with a mouse, hover or focus on a cut-off cell shows it in a Tooltip. No Tooltip on a touch
|
|
2875
|
+
* screen: a tap would leave it over the next rows. */
|
|
2847
2876
|
function LongText({ children }) {
|
|
2848
2877
|
const box = React.useRef(null);
|
|
2849
2878
|
const ref = React.useRef(null);
|
|
2850
2879
|
const narrow = useNarrow();
|
|
2880
|
+
const touch = useMedia(TOUCH_ONLY);
|
|
2851
2881
|
const [open, setOpen] = React.useState(false);
|
|
2852
2882
|
const [over, setOver] = React.useState(false);
|
|
2853
2883
|
const [cut, setCut] = React.useState("");
|
|
@@ -2857,7 +2887,7 @@ function LongText({ children }) {
|
|
|
2857
2887
|
if (!el || !outer || open) return;
|
|
2858
2888
|
const check = () => {
|
|
2859
2889
|
setOver(el.scrollHeight > el.clientHeight + 1);
|
|
2860
|
-
setCut(!narrow && outer.scrollWidth > outer.clientWidth + 1 ? outer.textContent ?? "" : "");
|
|
2890
|
+
setCut(!narrow && !touch && outer.scrollWidth > outer.clientWidth + 1 ? outer.textContent ?? "" : "");
|
|
2861
2891
|
};
|
|
2862
2892
|
check();
|
|
2863
2893
|
const ro = new ResizeObserver(check);
|
|
@@ -2866,7 +2896,8 @@ function LongText({ children }) {
|
|
|
2866
2896
|
}, [
|
|
2867
2897
|
open,
|
|
2868
2898
|
children,
|
|
2869
|
-
narrow
|
|
2899
|
+
narrow,
|
|
2900
|
+
touch
|
|
2870
2901
|
]);
|
|
2871
2902
|
const body = /* @__PURE__ */ jsxs("span", {
|
|
2872
2903
|
ref: box,
|
|
@@ -2950,6 +2981,9 @@ function DataTable(p) {
|
|
|
2950
2981
|
const [values, setValues] = React.useState(() => fromUrl().values);
|
|
2951
2982
|
const [view, setView] = React.useState(p.views?.[0]?.id ?? null);
|
|
2952
2983
|
const [toggled, setToggled] = React.useState({});
|
|
2984
|
+
const [opened, setOpened] = React.useState({});
|
|
2985
|
+
const narrow = useNarrow();
|
|
2986
|
+
const uid = React.useId();
|
|
2953
2987
|
const [sel, setSel] = React.useState({});
|
|
2954
2988
|
const [sumVal, setSumVal] = React.useState("all");
|
|
2955
2989
|
const [resetKey, setResetKey] = React.useState(p.resetKey);
|
|
@@ -2966,6 +3000,7 @@ function DataTable(p) {
|
|
|
2966
3000
|
dir: "desc"
|
|
2967
3001
|
});
|
|
2968
3002
|
setToggled({});
|
|
3003
|
+
setOpened({});
|
|
2969
3004
|
}
|
|
2970
3005
|
const valuesKey = JSON.stringify(values);
|
|
2971
3006
|
React.useEffect(() => {
|
|
@@ -3158,17 +3193,21 @@ function DataTable(p) {
|
|
|
3158
3193
|
const m = c.mobile || (!hasTitle && ci === 0 ? "title" : null);
|
|
3159
3194
|
return m ? "is-m-" + m : null;
|
|
3160
3195
|
};
|
|
3196
|
+
const longCols = shownCols.filter((c) => c.long);
|
|
3197
|
+
const expander = longCols.length > 0 && !narrow;
|
|
3198
|
+
const EXP = 40;
|
|
3161
3199
|
const template = [
|
|
3200
|
+
expander ? "40px" : null,
|
|
3162
3201
|
selectable ? "46px" : null,
|
|
3163
3202
|
...shownCols.map((c) => c.width ? `minmax(${c.width}px, ${c.grow || 1}fr)` : c.numeric ? "minmax(96px, .8fr)" : "minmax(120px, 1fr)"),
|
|
3164
3203
|
hasAct ? actW + "px" : null
|
|
3165
3204
|
].filter(Boolean).join(" ");
|
|
3166
|
-
const minW = (selectable ? 46 : 0) + shownCols.reduce((a, c) => a + (c.width || (c.numeric ? 96 : 120)), 0) + (hasAct ? actW : 0);
|
|
3205
|
+
const minW = (expander ? EXP : 0) + (selectable ? 46 : 0) + shownCols.reduce((a, c) => a + (c.width || (c.numeric ? 96 : 120)), 0) + (hasAct ? actW : 0);
|
|
3167
3206
|
const gridStyle = {
|
|
3168
3207
|
gridTemplateColumns: template,
|
|
3169
3208
|
minWidth: minW
|
|
3170
3209
|
};
|
|
3171
|
-
const stickyStyle = (ci) => ci === 0 && sticky ? { left: selectable ? 46 : 0 } : void 0;
|
|
3210
|
+
const stickyStyle = (ci) => ci === 0 && sticky ? { left: (expander ? EXP : 0) + (selectable ? 46 : 0) } : void 0;
|
|
3172
3211
|
const cellClass = (c, ci, ...more) => cx("ui-dt-cell", isNum(c) && "is-num", ci === 0 && sticky && "is-sticky", ...more);
|
|
3173
3212
|
const head = selectable && selIds.length && p.bulkActions ? /* @__PURE__ */ jsxs("div", {
|
|
3174
3213
|
className: "ui-dt-row ui-dt-head ui-dt-bulk",
|
|
@@ -3208,6 +3247,11 @@ function DataTable(p) {
|
|
|
3208
3247
|
role: "row",
|
|
3209
3248
|
style: gridStyle,
|
|
3210
3249
|
children: [
|
|
3250
|
+
expander ? /* @__PURE__ */ jsx("div", {
|
|
3251
|
+
className: "ui-dt-cell ui-dt-exp",
|
|
3252
|
+
role: "columnheader",
|
|
3253
|
+
"aria-label": tr("詳細")
|
|
3254
|
+
}) : null,
|
|
3211
3255
|
selectable ? /* @__PURE__ */ jsx("div", {
|
|
3212
3256
|
className: "ui-dt-cell ui-dt-sel",
|
|
3213
3257
|
role: "columnheader",
|
|
@@ -3244,7 +3288,7 @@ function DataTable(p) {
|
|
|
3244
3288
|
]
|
|
3245
3289
|
});
|
|
3246
3290
|
const mark = searching ? q : "";
|
|
3247
|
-
const
|
|
3291
|
+
const cellInner = (r, c) => {
|
|
3248
3292
|
const raw = get(r, c.key);
|
|
3249
3293
|
let v;
|
|
3250
3294
|
if (c.render) v = c.render(r);
|
|
@@ -3260,8 +3304,9 @@ function DataTable(p) {
|
|
|
3260
3304
|
})
|
|
3261
3305
|
] });
|
|
3262
3306
|
else v = markMatch(cellText(c, raw), mark);
|
|
3263
|
-
return
|
|
3307
|
+
return v;
|
|
3264
3308
|
};
|
|
3309
|
+
const cell = (r, c) => c.long ? /* @__PURE__ */ jsx(LongText, { children: cellInner(r, c) }) : cellInner(r, c);
|
|
3265
3310
|
const total = (c, ci) => {
|
|
3266
3311
|
const how = p.totals?.[c.key];
|
|
3267
3312
|
const rowsAll = list.map((x) => x.r);
|
|
@@ -3363,12 +3408,18 @@ function DataTable(p) {
|
|
|
3363
3408
|
setPage(0);
|
|
3364
3409
|
}
|
|
3365
3410
|
}) : null,
|
|
3366
|
-
/* @__PURE__ */
|
|
3411
|
+
/* @__PURE__ */ jsxs("span", {
|
|
3367
3412
|
className: "ui-dt-result",
|
|
3368
|
-
children:
|
|
3369
|
-
|
|
3370
|
-
|
|
3371
|
-
|
|
3413
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
3414
|
+
"aria-hidden": "true",
|
|
3415
|
+
children: monoNums(tr("{n} / {total} 筆", {
|
|
3416
|
+
n: "",
|
|
3417
|
+
total: ""
|
|
3418
|
+
}), [format.number(list.length), format.number(baseCount)])
|
|
3419
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
3420
|
+
className: "ui-visually-hidden",
|
|
3421
|
+
children: format.fractionLabel(list.length, baseCount, tr("筆"))
|
|
3422
|
+
})]
|
|
3372
3423
|
}),
|
|
3373
3424
|
p.columnMenu !== false && cols.length > 2 ? /* @__PURE__ */ jsx(ColumnMenu, {
|
|
3374
3425
|
cols,
|
|
@@ -3399,7 +3450,10 @@ function DataTable(p) {
|
|
|
3399
3450
|
children: vis.length ? vis.map((x, i) => {
|
|
3400
3451
|
const id = visIds[i];
|
|
3401
3452
|
const on = !!sel[id];
|
|
3402
|
-
|
|
3453
|
+
const open = expander && !!opened[id];
|
|
3454
|
+
const detailId = `${uid}-d-${id}`;
|
|
3455
|
+
const rowName = shownCols[0] ? String(cellText(shownCols[0], get(x.r, shownCols[0].key)) ?? "") : "";
|
|
3456
|
+
return /* @__PURE__ */ jsxs(React.Fragment, { children: [/* @__PURE__ */ jsxs("div", {
|
|
3403
3457
|
"data-rid": id,
|
|
3404
3458
|
ref: (el) => {
|
|
3405
3459
|
rowEls.current[id] = el;
|
|
@@ -3408,6 +3462,25 @@ function DataTable(p) {
|
|
|
3408
3462
|
className: cx("ui-dt-row", i % 2 && "is-even", on && "is-selected", selectable && "has-sel"),
|
|
3409
3463
|
style: gridStyle,
|
|
3410
3464
|
children: [
|
|
3465
|
+
expander ? /* @__PURE__ */ jsx("div", {
|
|
3466
|
+
className: "ui-dt-cell ui-dt-exp",
|
|
3467
|
+
role: "cell",
|
|
3468
|
+
children: /* @__PURE__ */ jsx("button", {
|
|
3469
|
+
type: "button",
|
|
3470
|
+
className: cx("ui-dt-exp-btn", open && "is-open"),
|
|
3471
|
+
"aria-expanded": open,
|
|
3472
|
+
"aria-controls": open ? detailId : void 0,
|
|
3473
|
+
"aria-label": tr(open ? "收合 {name}" : "展開 {name}", { name: rowName }),
|
|
3474
|
+
onClick: () => setOpened({
|
|
3475
|
+
...opened,
|
|
3476
|
+
[id]: !open
|
|
3477
|
+
}),
|
|
3478
|
+
children: /* @__PURE__ */ jsx(Icon, {
|
|
3479
|
+
name: "caret-right",
|
|
3480
|
+
size: 16
|
|
3481
|
+
})
|
|
3482
|
+
})
|
|
3483
|
+
}) : null,
|
|
3411
3484
|
selectable ? /* @__PURE__ */ jsx("div", {
|
|
3412
3485
|
className: "ui-dt-cell ui-dt-sel",
|
|
3413
3486
|
role: "cell",
|
|
@@ -3430,7 +3503,27 @@ function DataTable(p) {
|
|
|
3430
3503
|
children: p.rowActions?.(x.r)
|
|
3431
3504
|
}) : null
|
|
3432
3505
|
]
|
|
3433
|
-
},
|
|
3506
|
+
}), open ? /* @__PURE__ */ jsx("div", {
|
|
3507
|
+
id: detailId,
|
|
3508
|
+
role: "row",
|
|
3509
|
+
className: cx("ui-dt-detail", i % 2 && "is-even"),
|
|
3510
|
+
style: { minWidth: minW },
|
|
3511
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
3512
|
+
role: "cell",
|
|
3513
|
+
className: "ui-dt-detail-cell",
|
|
3514
|
+
style: { paddingLeft: EXP + (selectable ? 46 : 0) + 12 },
|
|
3515
|
+
children: longCols.map((c) => /* @__PURE__ */ jsxs("div", {
|
|
3516
|
+
className: "ui-dt-detail-item",
|
|
3517
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
3518
|
+
className: "ui-dt-detail-label",
|
|
3519
|
+
children: c.label
|
|
3520
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
3521
|
+
className: "ui-dt-detail-text",
|
|
3522
|
+
children: cellInner(x.r, c)
|
|
3523
|
+
})]
|
|
3524
|
+
}, c.key))
|
|
3525
|
+
})
|
|
3526
|
+
}) : null] }, id);
|
|
3434
3527
|
}) : /* @__PURE__ */ jsxs("div", {
|
|
3435
3528
|
className: "ui-dt-empty",
|
|
3436
3529
|
children: [p.emptyText || tr("沒有符合的資料"), q || activeN ? /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(Button, {
|
|
@@ -3444,6 +3537,10 @@ function DataTable(p) {
|
|
|
3444
3537
|
role: "row",
|
|
3445
3538
|
style: gridStyle,
|
|
3446
3539
|
children: [
|
|
3540
|
+
expander ? /* @__PURE__ */ jsx("div", {
|
|
3541
|
+
className: "ui-dt-cell",
|
|
3542
|
+
role: "cell"
|
|
3543
|
+
}) : null,
|
|
3447
3544
|
selectable ? /* @__PURE__ */ jsx("div", {
|
|
3448
3545
|
className: "ui-dt-cell",
|
|
3449
3546
|
role: "cell"
|
|
@@ -3679,6 +3776,128 @@ function DetailList({ items, className }) {
|
|
|
3679
3776
|
}, i))
|
|
3680
3777
|
});
|
|
3681
3778
|
}
|
|
3779
|
+
// src/components/SplitPane/SplitPane.tsx
|
|
3780
|
+
/** Width of the divider between the two areas, in px; a 48 px hit area is drawn over it. */
|
|
3781
|
+
const HANDLE = 16;
|
|
3782
|
+
/** Narrower than this (px, the component's own width), the two areas stack and the divider goes away. */
|
|
3783
|
+
const STACK = 960;
|
|
3784
|
+
/** One arrow key press, in px. */
|
|
3785
|
+
const STEP = 16;
|
|
3786
|
+
const read = (key) => {
|
|
3787
|
+
if (!key) return null;
|
|
3788
|
+
try {
|
|
3789
|
+
const v = Number(window.localStorage.getItem("ui-split:" + key));
|
|
3790
|
+
return Number.isFinite(v) && v > 0 ? v : null;
|
|
3791
|
+
} catch {
|
|
3792
|
+
return null;
|
|
3793
|
+
}
|
|
3794
|
+
};
|
|
3795
|
+
const write = (key, v) => {
|
|
3796
|
+
if (!key) return;
|
|
3797
|
+
try {
|
|
3798
|
+
window.localStorage.setItem("ui-split:" + key, String(Math.round(v)));
|
|
3799
|
+
} catch {}
|
|
3800
|
+
};
|
|
3801
|
+
/** A main area and a side panel with a divider between them that can be dragged, moved with the arrow keys and reset
|
|
3802
|
+
* with a double-click. Under 960 px (its own width) the two stack, side panel below, without the divider. */
|
|
3803
|
+
function SplitPane({ a, b, defaultB = 420, minA = 360, minB = 280, storageKey, label, onResize, className }) {
|
|
3804
|
+
devWarn(defaultB < minB, "SplitPane", `defaultB (${defaultB} px) is under minB (${minB} px): the panel starts at ${minB} px. Raise defaultB or lower minB.`);
|
|
3805
|
+
const root = React.useRef(null);
|
|
3806
|
+
const [width, setWidth] = React.useState(0);
|
|
3807
|
+
const [side, setSide] = React.useState(() => (typeof window === "undefined" ? null : read(storageKey)) ?? defaultB);
|
|
3808
|
+
const [drag, setDrag] = React.useState(false);
|
|
3809
|
+
const dragging = React.useRef(false);
|
|
3810
|
+
const id = React.useId();
|
|
3811
|
+
React.useLayoutEffect(() => {
|
|
3812
|
+
const el = root.current;
|
|
3813
|
+
if (!el) return;
|
|
3814
|
+
const measure = () => setWidth(el.clientWidth);
|
|
3815
|
+
measure();
|
|
3816
|
+
const ro = new ResizeObserver(measure);
|
|
3817
|
+
ro.observe(el);
|
|
3818
|
+
return () => ro.disconnect();
|
|
3819
|
+
}, []);
|
|
3820
|
+
const stacked = width > 0 && width < STACK;
|
|
3821
|
+
const maxB = Math.max(minB, width - HANDLE - minA);
|
|
3822
|
+
const shown = Math.round(Math.min(maxB, Math.max(minB, side)));
|
|
3823
|
+
const valueA = Math.max(0, width - HANDLE - shown);
|
|
3824
|
+
const latest = React.useRef(shown);
|
|
3825
|
+
const set = (v, keep = true) => {
|
|
3826
|
+
const next = Math.round(Math.min(maxB, Math.max(minB, v)));
|
|
3827
|
+
latest.current = next;
|
|
3828
|
+
setSide(next);
|
|
3829
|
+
if (keep) write(storageKey, next);
|
|
3830
|
+
onResize?.(next);
|
|
3831
|
+
};
|
|
3832
|
+
const onKey = (e) => {
|
|
3833
|
+
if (browserKey(e)) return;
|
|
3834
|
+
const to = e.key === "ArrowLeft" ? shown + STEP : e.key === "ArrowRight" ? shown - STEP : e.key === "Home" ? maxB : e.key === "End" ? minB : e.key === "Enter" ? defaultB : null;
|
|
3835
|
+
if (to == null) return;
|
|
3836
|
+
e.preventDefault();
|
|
3837
|
+
set(to);
|
|
3838
|
+
};
|
|
3839
|
+
const onDown = (e) => {
|
|
3840
|
+
if (e.button !== 0) return;
|
|
3841
|
+
e.preventDefault();
|
|
3842
|
+
try {
|
|
3843
|
+
e.currentTarget.setPointerCapture(e.pointerId);
|
|
3844
|
+
} catch {}
|
|
3845
|
+
e.currentTarget.focus({ preventScroll: true });
|
|
3846
|
+
dragging.current = true;
|
|
3847
|
+
setDrag(true);
|
|
3848
|
+
};
|
|
3849
|
+
const onMove = (e) => {
|
|
3850
|
+
if (!dragging.current || !root.current) return;
|
|
3851
|
+
const r = root.current.getBoundingClientRect();
|
|
3852
|
+
set(r.right - e.clientX - HANDLE / 2, false);
|
|
3853
|
+
};
|
|
3854
|
+
const onUp = (e) => {
|
|
3855
|
+
if (!dragging.current) return;
|
|
3856
|
+
dragging.current = false;
|
|
3857
|
+
setDrag(false);
|
|
3858
|
+
try {
|
|
3859
|
+
if (e.currentTarget.hasPointerCapture(e.pointerId)) e.currentTarget.releasePointerCapture(e.pointerId);
|
|
3860
|
+
} catch {}
|
|
3861
|
+
if (root.current) write(storageKey, latest.current);
|
|
3862
|
+
};
|
|
3863
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
3864
|
+
ref: root,
|
|
3865
|
+
className: cx("ui-split", stacked && "is-stacked", drag && "is-dragging", className),
|
|
3866
|
+
style: stacked || !width ? void 0 : { gridTemplateColumns: `minmax(0, 1fr) ${HANDLE}px ${shown}px` },
|
|
3867
|
+
children: [
|
|
3868
|
+
/* @__PURE__ */ jsx("div", {
|
|
3869
|
+
className: "ui-split-a",
|
|
3870
|
+
children: a
|
|
3871
|
+
}),
|
|
3872
|
+
stacked ? null : /* @__PURE__ */ jsx("div", {
|
|
3873
|
+
role: "separator",
|
|
3874
|
+
tabIndex: 0,
|
|
3875
|
+
"aria-orientation": "vertical",
|
|
3876
|
+
"aria-label": label || tr("調整面板寬度"),
|
|
3877
|
+
"aria-controls": id,
|
|
3878
|
+
"aria-valuenow": valueA,
|
|
3879
|
+
"aria-valuemin": minA,
|
|
3880
|
+
"aria-valuemax": Math.max(minA, width - HANDLE - minB),
|
|
3881
|
+
"aria-valuetext": tr("主要區域 {a} px,面板 {b} px", {
|
|
3882
|
+
a: valueA,
|
|
3883
|
+
b: shown
|
|
3884
|
+
}),
|
|
3885
|
+
className: "ui-split-handle",
|
|
3886
|
+
onKeyDown: onKey,
|
|
3887
|
+
onPointerDown: onDown,
|
|
3888
|
+
onPointerMove: onMove,
|
|
3889
|
+
onPointerUp: onUp,
|
|
3890
|
+
onPointerCancel: onUp,
|
|
3891
|
+
onDoubleClick: () => set(defaultB)
|
|
3892
|
+
}),
|
|
3893
|
+
/* @__PURE__ */ jsx("div", {
|
|
3894
|
+
id,
|
|
3895
|
+
className: "ui-split-b",
|
|
3896
|
+
children: b
|
|
3897
|
+
})
|
|
3898
|
+
]
|
|
3899
|
+
});
|
|
3900
|
+
}
|
|
3682
3901
|
// src/components/EmptyState/EmptyState.tsx
|
|
3683
3902
|
/** What a list or page shows when it has nothing yet: what is missing and the first step. */
|
|
3684
3903
|
function EmptyState({ title, description, steps = [], current = 0, action }) {
|
|
@@ -4256,14 +4475,16 @@ function LayerGraph(p) {
|
|
|
4256
4475
|
const all = p.nodes;
|
|
4257
4476
|
const sel = p.selected ?? null;
|
|
4258
4477
|
devWarn(all.some((n) => n.fns != null), "LayerGraph", "fns is renamed size; pass size and, for the text under the bar, sizeLabel such as 「{n} 個函式」.");
|
|
4259
|
-
|
|
4478
|
+
devWarn(all.some((n) => n.external && n.shared), "LayerGraph", "a node is both external and shared; it is drawn as shared. Keep one of the two.");
|
|
4479
|
+
const sizeOf = (n) => n.external && !n.shared ? void 0 : n.size ?? n.fns;
|
|
4260
4480
|
const sharedIds = new Set(all.filter((n) => n.shared).map((n) => n.id));
|
|
4261
4481
|
const main = all.filter((n) => !n.shared);
|
|
4262
4482
|
const shared = all.filter((n) => n.shared);
|
|
4263
4483
|
const edges = p.edges.filter((e) => !sharedIds.has(e.from) && !sharedIds.has(e.to));
|
|
4264
4484
|
const byLayer = /* @__PURE__ */ new Map();
|
|
4485
|
+
const EXTERNAL = Number.NEGATIVE_INFINITY;
|
|
4265
4486
|
for (const n of main) {
|
|
4266
|
-
const l = n.layer || 0;
|
|
4487
|
+
const l = n.external ? EXTERNAL : n.layer || 0;
|
|
4267
4488
|
byLayer.set(l, [...byLayer.get(l) ?? [], n]);
|
|
4268
4489
|
}
|
|
4269
4490
|
const layers = [...byLayer.keys()].sort((a, b) => a - b);
|
|
@@ -4339,8 +4560,9 @@ function LayerGraph(p) {
|
|
|
4339
4560
|
onScroll();
|
|
4340
4561
|
};
|
|
4341
4562
|
const selEdge = pickEdge && edges.find((e) => edgeId(e) === p.selectedEdge) || null;
|
|
4563
|
+
const nodeIdsAll = new Set(all.map((n) => n.id));
|
|
4342
4564
|
const uses = {};
|
|
4343
|
-
for (const e of p.edges) if (sharedIds.has(e.to) &&
|
|
4565
|
+
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);
|
|
4344
4566
|
const selShared = !selEdge && sel != null && sharedIds.has(sel) ? sel : null;
|
|
4345
4567
|
const related = (e) => selEdge ? e === selEdge : !!sel && !selShared && (e.from === sel || e.to === sel);
|
|
4346
4568
|
const focus = !!sel || !!selEdge;
|
|
@@ -4376,6 +4598,7 @@ function LayerGraph(p) {
|
|
|
4376
4598
|
const paths = [];
|
|
4377
4599
|
const labels = [];
|
|
4378
4600
|
const need = /* @__PURE__ */ new Set();
|
|
4601
|
+
const crowd = /* @__PURE__ */ new Set();
|
|
4379
4602
|
const marks = [];
|
|
4380
4603
|
const runs = [];
|
|
4381
4604
|
const segs = [];
|
|
@@ -4639,9 +4862,11 @@ function LayerGraph(p) {
|
|
|
4639
4862
|
const g = Math.max(0, Math.min(layers.length - 2, layers.findIndex((_, k) => k < layers.length - 1 && m.ty < rowTop(k + 1))));
|
|
4640
4863
|
need.add(g);
|
|
4641
4864
|
const x0 = x0Of(w);
|
|
4865
|
+
const top = find(x0, w, 16, false);
|
|
4866
|
+
if (top == null) crowd.add(g);
|
|
4642
4867
|
spot = {
|
|
4643
4868
|
x0,
|
|
4644
|
-
top:
|
|
4869
|
+
top: top ?? start0,
|
|
4645
4870
|
lw: w,
|
|
4646
4871
|
lh: 16,
|
|
4647
4872
|
lines: [m.text]
|
|
@@ -4658,6 +4883,7 @@ function LayerGraph(p) {
|
|
|
4658
4883
|
return;
|
|
4659
4884
|
}
|
|
4660
4885
|
const g = layerIndex[m.e.to] - 1;
|
|
4886
|
+
const gapTop = g >= 0 ? rowTop(g) + NH : 0;
|
|
4661
4887
|
const sideOf = (lw) => {
|
|
4662
4888
|
let left = m.left;
|
|
4663
4889
|
if (left && m.tx - 8 - lw < 0) left = false;
|
|
@@ -4679,7 +4905,7 @@ function LayerGraph(p) {
|
|
|
4679
4905
|
if (x0 < 0 || x0 + lw > W) continue;
|
|
4680
4906
|
for (let k = 0; k < 8 && !spot; k++) {
|
|
4681
4907
|
const top = m.ty - 8 - lh / 2 - k * 18;
|
|
4682
|
-
if (top - lh / 2 < 2) break;
|
|
4908
|
+
if (top - lh / 2 < Math.max(2, gapTop + 2)) break;
|
|
4683
4909
|
if (clear(x0, lw, top - lh / 2, top + lh / 2)) spot = {
|
|
4684
4910
|
x0,
|
|
4685
4911
|
top,
|
|
@@ -4694,16 +4920,42 @@ function LayerGraph(p) {
|
|
|
4694
4920
|
}
|
|
4695
4921
|
if (!spot) {
|
|
4696
4922
|
if (g >= 0) need.add(g);
|
|
4697
|
-
const
|
|
4698
|
-
|
|
4699
|
-
|
|
4700
|
-
|
|
4701
|
-
|
|
4702
|
-
|
|
4703
|
-
|
|
4704
|
-
|
|
4705
|
-
|
|
4706
|
-
|
|
4923
|
+
const offBoxes = (x0, lw, y0, y1) => !hits(x0, x0 + lw, y0, y1) && !boxRects.some((q) => x0 < q[1] + 2 && q[0] < x0 + lw + 2 && y0 < q[3] + 2 && q[2] < y1 + 2);
|
|
4924
|
+
for (const lines of wraps(m.text)) {
|
|
4925
|
+
const lw = Math.ceil(Math.max(...lines.map(labelWidth)));
|
|
4926
|
+
const lh = lines.length * 16;
|
|
4927
|
+
const pref = sideOf(lw);
|
|
4928
|
+
for (const left of [pref, !pref]) {
|
|
4929
|
+
const x0 = at(left, lw);
|
|
4930
|
+
if (x0 < 0 || x0 + lw > W) continue;
|
|
4931
|
+
for (let k = 0; k < 8 && !spot; k++) {
|
|
4932
|
+
const top = m.ty - 8 - lh / 2 - k * 18;
|
|
4933
|
+
if (top - lh / 2 < Math.max(2, gapTop + 2)) break;
|
|
4934
|
+
if (offBoxes(x0, lw, top - lh / 2, top + lh / 2)) spot = {
|
|
4935
|
+
x0,
|
|
4936
|
+
top,
|
|
4937
|
+
lw,
|
|
4938
|
+
lh,
|
|
4939
|
+
lines
|
|
4940
|
+
};
|
|
4941
|
+
}
|
|
4942
|
+
if (spot) break;
|
|
4943
|
+
}
|
|
4944
|
+
if (spot) break;
|
|
4945
|
+
}
|
|
4946
|
+
if (!spot) {
|
|
4947
|
+
if (g >= 0) crowd.add(g);
|
|
4948
|
+
const x0 = at(sideOf(w), w);
|
|
4949
|
+
let top = m.ty - 16;
|
|
4950
|
+
for (let k = 0; k < 8 && hits(x0, x0 + w, top - 8, top + 8); k++) top -= 18;
|
|
4951
|
+
spot = {
|
|
4952
|
+
x0,
|
|
4953
|
+
top,
|
|
4954
|
+
lw: w,
|
|
4955
|
+
lh: 16,
|
|
4956
|
+
lines: [m.text]
|
|
4957
|
+
};
|
|
4958
|
+
}
|
|
4707
4959
|
}
|
|
4708
4960
|
placed.push([
|
|
4709
4961
|
spot.x0,
|
|
@@ -4718,7 +4970,8 @@ function LayerGraph(p) {
|
|
|
4718
4970
|
paths,
|
|
4719
4971
|
labels,
|
|
4720
4972
|
hitPaths,
|
|
4721
|
-
need
|
|
4973
|
+
need,
|
|
4974
|
+
crowd
|
|
4722
4975
|
};
|
|
4723
4976
|
};
|
|
4724
4977
|
placeRows();
|
|
@@ -4734,9 +4987,16 @@ function LayerGraph(p) {
|
|
|
4734
4987
|
for (const g of stuck) gaps[g] = GAP;
|
|
4735
4988
|
placeRows();
|
|
4736
4989
|
drawn = draw();
|
|
4990
|
+
const crowded = () => [...drawn.crowd].filter((g) => stuck.includes(g) && gaps[g] < 200);
|
|
4991
|
+
for (let k = 0; k < GROW_MAX / GROW && crowded().length; k++) {
|
|
4992
|
+
for (const g of crowded()) gaps[g] = Math.min(200, gaps[g] + GROW);
|
|
4993
|
+
placeRows();
|
|
4994
|
+
drawn = draw();
|
|
4995
|
+
}
|
|
4737
4996
|
}
|
|
4738
4997
|
const { paths, labels, hitPaths } = drawn;
|
|
4739
4998
|
const sizeText = p.sizeLabel ?? tr("{n} 個項目");
|
|
4999
|
+
const externalText = p.externalLabel ?? tr("repo 外");
|
|
4740
5000
|
const useText = p.useLabel ?? tr("使用 {n} 次");
|
|
4741
5001
|
const nodes = main.map((n) => {
|
|
4742
5002
|
const q = pos[n.id];
|
|
@@ -4745,7 +5005,7 @@ function LayerGraph(p) {
|
|
|
4745
5005
|
const used = selShared ? uses[selShared]?.[n.id] : void 0;
|
|
4746
5006
|
return /* @__PURE__ */ jsxs("button", {
|
|
4747
5007
|
type: "button",
|
|
4748
|
-
className: cx("ui-lg-node", on && "is-selected", !near(n.id) && "is-dim"),
|
|
5008
|
+
className: cx("ui-lg-node", n.external && "is-external", on && "is-selected", !near(n.id) && "is-dim"),
|
|
4749
5009
|
style: {
|
|
4750
5010
|
left: q.x,
|
|
4751
5011
|
top: q.y,
|
|
@@ -4754,26 +5014,33 @@ function LayerGraph(p) {
|
|
|
4754
5014
|
},
|
|
4755
5015
|
"aria-pressed": p.onSelect ? on : void 0,
|
|
4756
5016
|
onClick: p.onSelect ? () => pick(n.id, on) : void 0,
|
|
4757
|
-
children: [
|
|
4758
|
-
|
|
4759
|
-
|
|
4760
|
-
|
|
4761
|
-
|
|
4762
|
-
|
|
4763
|
-
|
|
4764
|
-
|
|
4765
|
-
|
|
4766
|
-
|
|
4767
|
-
|
|
4768
|
-
|
|
4769
|
-
className: "ui-lg-
|
|
4770
|
-
|
|
4771
|
-
|
|
4772
|
-
|
|
4773
|
-
className: "ui-lg-
|
|
4774
|
-
children:
|
|
4775
|
-
|
|
4776
|
-
|
|
5017
|
+
children: [
|
|
5018
|
+
/* @__PURE__ */ jsxs("span", {
|
|
5019
|
+
className: "ui-lg-head",
|
|
5020
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
5021
|
+
className: "ui-lg-name",
|
|
5022
|
+
children: n.name || n.id
|
|
5023
|
+
}), used ? /* @__PURE__ */ jsx("span", {
|
|
5024
|
+
className: "ui-lg-use",
|
|
5025
|
+
children: monoNums(useText.replace("{n}", ""), [used])
|
|
5026
|
+
}) : null]
|
|
5027
|
+
}),
|
|
5028
|
+
n.external ? /* @__PURE__ */ jsx("span", {
|
|
5029
|
+
className: "ui-lg-ext",
|
|
5030
|
+
children: externalText
|
|
5031
|
+
}) : null,
|
|
5032
|
+
size != null ? /* @__PURE__ */ jsxs("span", {
|
|
5033
|
+
className: "ui-lg-size",
|
|
5034
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
5035
|
+
className: "ui-lg-track",
|
|
5036
|
+
"aria-hidden": "true",
|
|
5037
|
+
children: /* @__PURE__ */ jsx("span", { style: { width: Math.round(size / maxSize * 100) + "%" } })
|
|
5038
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
5039
|
+
className: "ui-lg-count",
|
|
5040
|
+
children: monoNums(sizeText.replace("{n}", ""), [size])
|
|
5041
|
+
})]
|
|
5042
|
+
}) : null
|
|
5043
|
+
]
|
|
4777
5044
|
}, n.id);
|
|
4778
5045
|
});
|
|
4779
5046
|
const sharedMeta = p.sharedMeta ?? tr("{a} 個項目使用,共 {b} 次");
|
|
@@ -4781,7 +5048,7 @@ function LayerGraph(p) {
|
|
|
4781
5048
|
const by = uses[s.id] ?? {};
|
|
4782
5049
|
const total = Object.values(by).reduce((a, b) => a + b, 0);
|
|
4783
5050
|
const on = s.id === sel;
|
|
4784
|
-
const dim = !!selEdge || sel != null && !on && (selShared != null
|
|
5051
|
+
const dim = !!selEdge || sel != null && !on && (selShared != null ? !(s.id in (uses[selShared] ?? {})) && !(selShared in by) : !(sel in by));
|
|
4785
5052
|
return /* @__PURE__ */ jsxs("button", {
|
|
4786
5053
|
type: "button",
|
|
4787
5054
|
className: cx("ui-lg-node", "ui-lg-chip", on && "is-selected", dim && "is-dim"),
|
|
@@ -4824,7 +5091,10 @@ function LayerGraph(p) {
|
|
|
4824
5091
|
return listItem(n.id, n.id === sel, !near(n.id), p.onSelect ? () => pick(n.id, n.id === sel) : void 0, /* @__PURE__ */ jsx("span", {
|
|
4825
5092
|
className: "ui-lg-code",
|
|
4826
5093
|
children: n.name || n.id
|
|
4827
|
-
}),
|
|
5094
|
+
}), n.external && !n.shared ? /* @__PURE__ */ jsxs("span", {
|
|
5095
|
+
className: "ui-lg-limeta",
|
|
5096
|
+
children: [",", externalText]
|
|
5097
|
+
}) : size != null ? /* @__PURE__ */ jsxs("span", {
|
|
4828
5098
|
className: "ui-lg-limeta",
|
|
4829
5099
|
children: [",", monoNums(sizeText.replace("{n}", ""), [size])]
|
|
4830
5100
|
}) : null);
|
|
@@ -5556,6 +5826,7 @@ function RadioGroup({ label, value, onChange, options, disabled, className }) {
|
|
|
5556
5826
|
className: cx("ui-radio", on && "is-on"),
|
|
5557
5827
|
onClick: () => onChange?.(o.value),
|
|
5558
5828
|
onKeyDown: (e) => {
|
|
5829
|
+
if (browserKey(e)) return;
|
|
5559
5830
|
if (e.key === "ArrowDown" || e.key === "ArrowRight") {
|
|
5560
5831
|
e.preventDefault();
|
|
5561
5832
|
move(i, 1);
|
|
@@ -5924,9 +6195,15 @@ function TextArea({ label, hint, value, onChange, maxLength = 200, className, id
|
|
|
5924
6195
|
children: [/* @__PURE__ */ jsx("span", {
|
|
5925
6196
|
className: "ui-field-hint",
|
|
5926
6197
|
children: hint || ""
|
|
5927
|
-
}), /* @__PURE__ */
|
|
6198
|
+
}), /* @__PURE__ */ jsxs("span", {
|
|
5928
6199
|
className: "ui-count",
|
|
5929
|
-
children:
|
|
6200
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
6201
|
+
"aria-hidden": "true",
|
|
6202
|
+
children: format.fraction((value || "").length, maxLength)
|
|
6203
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
6204
|
+
className: "ui-visually-hidden",
|
|
6205
|
+
children: format.fractionLabel((value || "").length, maxLength, tr("字"))
|
|
6206
|
+
})]
|
|
5930
6207
|
})]
|
|
5931
6208
|
})
|
|
5932
6209
|
]
|
|
@@ -6090,6 +6367,26 @@ function Tour({ open, steps, onClose, skippable = true, step: controlled, onStep
|
|
|
6090
6367
|
};
|
|
6091
6368
|
const end = (why) => onClose?.(why);
|
|
6092
6369
|
useReturnFocus(open);
|
|
6370
|
+
const cardEl = React.useRef(null);
|
|
6371
|
+
const tabbables = () => Array.from(cardEl.current?.querySelectorAll("button:not(:disabled), a[href], input:not(:disabled), [tabindex]:not([tabindex=\"-1\"])") ?? []).filter((e) => e.getClientRects().length > 0);
|
|
6372
|
+
const onTab = (e) => {
|
|
6373
|
+
if (e.key !== "Tab" || e.altKey || e.ctrlKey || e.metaKey) return;
|
|
6374
|
+
const list = tabbables();
|
|
6375
|
+
if (!list.length) return;
|
|
6376
|
+
e.preventDefault();
|
|
6377
|
+
const at = list.indexOf(document.activeElement);
|
|
6378
|
+
list[at < 0 ? 0 : (at + (e.shiftKey ? -1 : 1) + list.length) % list.length].focus();
|
|
6379
|
+
};
|
|
6380
|
+
React.useEffect(() => {
|
|
6381
|
+
if (!open) return;
|
|
6382
|
+
const back = (e) => {
|
|
6383
|
+
const box = cardEl.current;
|
|
6384
|
+
if (!box || !(e.target instanceof Node) || box.contains(e.target)) return;
|
|
6385
|
+
(next.current ?? tabbables()[0])?.focus();
|
|
6386
|
+
};
|
|
6387
|
+
document.addEventListener("focusin", back);
|
|
6388
|
+
return () => document.removeEventListener("focusin", back);
|
|
6389
|
+
}, [open]);
|
|
6093
6390
|
const target = step?.target;
|
|
6094
6391
|
const pad = step?.padding ?? 6;
|
|
6095
6392
|
const hasStep = !!step;
|
|
@@ -6143,6 +6440,7 @@ function Tour({ open, steps, onClose, skippable = true, step: controlled, onStep
|
|
|
6143
6440
|
]);
|
|
6144
6441
|
const observer = React.useRef(null);
|
|
6145
6442
|
const card = React.useCallback((el) => {
|
|
6443
|
+
cardEl.current = el;
|
|
6146
6444
|
observer.current?.disconnect();
|
|
6147
6445
|
observer.current = null;
|
|
6148
6446
|
if (!el) return;
|
|
@@ -6192,6 +6490,7 @@ function Tour({ open, steps, onClose, skippable = true, step: controlled, onStep
|
|
|
6192
6490
|
className: "ui-tour-card",
|
|
6193
6491
|
"data-placement": place.mode,
|
|
6194
6492
|
initialFocus: next,
|
|
6493
|
+
onKeyDown: onTab,
|
|
6195
6494
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
6196
6495
|
className: "ui-tour-body",
|
|
6197
6496
|
children: [
|
|
@@ -6504,7 +6803,7 @@ function TreeList(p) {
|
|
|
6504
6803
|
setFocusId(rows[j].n.id);
|
|
6505
6804
|
};
|
|
6506
6805
|
const onKey = (e) => {
|
|
6507
|
-
if (e.target.getAttribute("role") !== "treeitem" || !rows.length) return;
|
|
6806
|
+
if (e.target.getAttribute("role") !== "treeitem" || !rows.length || browserKey(e)) return;
|
|
6508
6807
|
const r = rows[cur];
|
|
6509
6808
|
const k = e.key;
|
|
6510
6809
|
if (!([
|
|
@@ -6531,8 +6830,10 @@ function TreeList(p) {
|
|
|
6531
6830
|
break;
|
|
6532
6831
|
}
|
|
6533
6832
|
} else if (k === "Enter") {
|
|
6534
|
-
if (plain)
|
|
6535
|
-
|
|
6833
|
+
if (plain) {
|
|
6834
|
+
p.onSelect?.(r.n);
|
|
6835
|
+
if (r.isF) toggle(r.n);
|
|
6836
|
+
} else if (r.isF) toggle(r.n);
|
|
6536
6837
|
else openFile(r.n);
|
|
6537
6838
|
} else checkToggle(r.n);
|
|
6538
6839
|
};
|
|
@@ -6556,8 +6857,9 @@ function TreeList(p) {
|
|
|
6556
6857
|
const meta = n.meta ?? (n.path ? format.path(n.path) : "");
|
|
6557
6858
|
return /* @__PURE__ */ jsxs("div", {
|
|
6558
6859
|
...itemProps(r, idx),
|
|
6559
|
-
"aria-label": [
|
|
6860
|
+
"aria-label": n.ariaLabel ?? [
|
|
6560
6861
|
n.name,
|
|
6862
|
+
...(n.tags ?? []).map(nodeText),
|
|
6561
6863
|
n.meta,
|
|
6562
6864
|
n.path
|
|
6563
6865
|
].filter(Boolean).join(","),
|
|
@@ -6565,8 +6867,8 @@ function TreeList(p) {
|
|
|
6565
6867
|
className: cx("ui-tree-row", "is-plain", on && "is-current", n.muted && "is-muted", r.fresh && "ui-tree-in"),
|
|
6566
6868
|
onClick: () => {
|
|
6567
6869
|
setFocusId(n.id);
|
|
6568
|
-
|
|
6569
|
-
|
|
6870
|
+
p.onSelect?.(n);
|
|
6871
|
+
if (isF) toggle(n);
|
|
6570
6872
|
},
|
|
6571
6873
|
children: [
|
|
6572
6874
|
/* @__PURE__ */ jsx(Guides, { guides: r.guides }),
|
|
@@ -6674,6 +6976,7 @@ function TreeList(p) {
|
|
|
6674
6976
|
const bits = (isF ? [fl.length ? tr("{n} 個檔案", { n: fl.length }) : "", dateTxt] : [dateTxt, sizeTxt]).filter(Boolean);
|
|
6675
6977
|
return /* @__PURE__ */ jsxs("div", {
|
|
6676
6978
|
...itemProps(r, idx),
|
|
6979
|
+
"aria-label": n.ariaLabel,
|
|
6677
6980
|
"aria-selected": selectable ? ck === true : void 0,
|
|
6678
6981
|
className: cx("ui-tree-row", isF && "is-folder", ck === true && "is-selected", r.fresh && "ui-tree-in"),
|
|
6679
6982
|
onClick: () => {
|
|
@@ -6880,6 +7183,6 @@ function TreeList(p) {
|
|
|
6880
7183
|
})]
|
|
6881
7184
|
});
|
|
6882
7185
|
}
|
|
6883
|
-
export { AccentPicker, ActionBar, Alert, AppShell, Badge, BarChart, Breadcrumb, Button, Calendar, Card, Checkbox, CodeText, CodeView, CommandPalette, DangerZone, DataTable, DatePicker, DateRangePicker, DetailList, Dialog, Drawer, EmptyState, ErrorPage, FileUpload, FormGrid, GraphDefs, GraphLegend, Grid, Icon, IconButton, InlineCode, KpiCard, LayerGraph, LineChart, LoadingBar, LoginCard, MOTION, Menu, MobileTabBar, MultiSelect, NotificationBell, Page, Popover, ProgressBar, ProgressRing, ProjectSwitcher, RadioGroup, SearchField, Select, SettingsLayout, SettingsSection, SideNav, Skeleton, Suggestion, Switch, Tabs, Tag, Term, TextArea, TextField, ThemePicker, Toast, Tooltip, TopBar, Tour, TreeList, addMessages, announce, focusMain, format, icons, initTheme, isCodeRef, setAccent, setLocale, setTheme, tr as t, useTour };
|
|
7186
|
+
export { AccentPicker, ActionBar, Alert, AppShell, Badge, BarChart, Breadcrumb, Button, Calendar, Card, Checkbox, CodeText, CodeView, CommandPalette, DangerZone, DataTable, DatePicker, DateRangePicker, DetailList, Dialog, Drawer, EmptyState, ErrorPage, FileUpload, FormGrid, GraphDefs, GraphLegend, Grid, Icon, IconButton, InlineCode, KpiCard, LayerGraph, LineChart, LoadingBar, LoginCard, MOTION, Menu, MobileTabBar, MultiSelect, NotificationBell, Page, Popover, ProgressBar, ProgressRing, ProjectSwitcher, RadioGroup, SearchField, Select, SettingsLayout, SettingsSection, SideNav, Skeleton, SplitPane, Suggestion, Switch, Tabs, Tag, Term, TextArea, TextField, ThemePicker, Toast, Tooltip, TopBar, Tour, TreeList, addMessages, announce, focusMain, format, icons, initTheme, isCodeRef, setAccent, setLocale, setTheme, tr as t, useTour };
|
|
6884
7187
|
|
|
6885
7188
|
//# sourceMappingURL=index.js.map
|