@seanyeh77/ui 0.8.0 → 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 +401 -77
- 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";
|
|
@@ -1286,13 +1313,22 @@ function useReturnFocus(open) {
|
|
|
1286
1313
|
if (!open && wasOpen.current) {
|
|
1287
1314
|
const back = opener.current;
|
|
1288
1315
|
opener.current = null;
|
|
1289
|
-
const
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1316
|
+
const held = document.activeElement;
|
|
1317
|
+
const until = performance.now() + 2e3;
|
|
1318
|
+
let frame = 0;
|
|
1319
|
+
const look = () => {
|
|
1320
|
+
if (lost()) {
|
|
1321
|
+
if (back?.isConnected) back.focus();
|
|
1322
|
+
else focusMain();
|
|
1323
|
+
return;
|
|
1324
|
+
}
|
|
1325
|
+
const at = document.activeElement;
|
|
1326
|
+
if (!(at === held || !!at?.closest("[data-ending-style]")) || performance.now() > until) return;
|
|
1327
|
+
frame = requestAnimationFrame(look);
|
|
1328
|
+
};
|
|
1329
|
+
frame = requestAnimationFrame(look);
|
|
1294
1330
|
wasOpen.current = open;
|
|
1295
|
-
return () =>
|
|
1331
|
+
return () => cancelAnimationFrame(frame);
|
|
1296
1332
|
}
|
|
1297
1333
|
wasOpen.current = open;
|
|
1298
1334
|
}, [open]);
|
|
@@ -1316,13 +1352,24 @@ function useFocusRescue(ref, fallback) {
|
|
|
1316
1352
|
last = e.target;
|
|
1317
1353
|
index = Array.from(box.querySelectorAll(FOCUSABLE)).indexOf(last);
|
|
1318
1354
|
};
|
|
1319
|
-
const
|
|
1320
|
-
if (!last || last.isConnected && !last.matches(":disabled") || !lost()) return;
|
|
1355
|
+
const rescue = () => {
|
|
1321
1356
|
const now = list();
|
|
1322
1357
|
const next = fb.current?.() ?? now[Math.min(index, now.length - 1)] ?? null;
|
|
1323
1358
|
last = null;
|
|
1324
1359
|
if (next) next.focus();
|
|
1325
1360
|
else focusMain();
|
|
1361
|
+
};
|
|
1362
|
+
let frame = 0;
|
|
1363
|
+
const mo = new MutationObserver(() => {
|
|
1364
|
+
if (!last || last.isConnected && !last.matches(":disabled")) return;
|
|
1365
|
+
if (lost()) return rescue();
|
|
1366
|
+
const dead = last;
|
|
1367
|
+
cancelAnimationFrame(frame);
|
|
1368
|
+
frame = requestAnimationFrame(() => {
|
|
1369
|
+
frame = requestAnimationFrame(() => {
|
|
1370
|
+
if (last === dead && (lost() || document.activeElement === dead)) rescue();
|
|
1371
|
+
});
|
|
1372
|
+
});
|
|
1326
1373
|
});
|
|
1327
1374
|
box.addEventListener("focusin", onIn);
|
|
1328
1375
|
mo.observe(box, {
|
|
@@ -1334,6 +1381,7 @@ function useFocusRescue(ref, fallback) {
|
|
|
1334
1381
|
return () => {
|
|
1335
1382
|
box.removeEventListener("focusin", onIn);
|
|
1336
1383
|
mo.disconnect();
|
|
1384
|
+
cancelAnimationFrame(frame);
|
|
1337
1385
|
};
|
|
1338
1386
|
}, [ref]);
|
|
1339
1387
|
}
|
|
@@ -2449,6 +2497,7 @@ function Tabs({ items, value, onChange, label, unit, className }) {
|
|
|
2449
2497
|
className: cx("ui-tab", i === idx && "is-selected"),
|
|
2450
2498
|
onClick: () => go(i),
|
|
2451
2499
|
onKeyDown: (e) => {
|
|
2500
|
+
if (browserKey(e)) return;
|
|
2452
2501
|
const to = e.key === "ArrowRight" ? (i + 1) % items.length : e.key === "ArrowLeft" ? (i - 1 + items.length) % items.length : -1;
|
|
2453
2502
|
if (to < 0) return;
|
|
2454
2503
|
e.preventDefault();
|
|
@@ -2821,12 +2870,14 @@ function FilterButton({ filters, values, activeCount, count, onChange, onClear }
|
|
|
2821
2870
|
})]
|
|
2822
2871
|
});
|
|
2823
2872
|
}
|
|
2824
|
-
/** Long text in a cell. Phone cards: at most 2 lines with 「顯示全部」. Desktop: one line;
|
|
2825
|
-
*
|
|
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. */
|
|
2826
2876
|
function LongText({ children }) {
|
|
2827
2877
|
const box = React.useRef(null);
|
|
2828
2878
|
const ref = React.useRef(null);
|
|
2829
2879
|
const narrow = useNarrow();
|
|
2880
|
+
const touch = useMedia(TOUCH_ONLY);
|
|
2830
2881
|
const [open, setOpen] = React.useState(false);
|
|
2831
2882
|
const [over, setOver] = React.useState(false);
|
|
2832
2883
|
const [cut, setCut] = React.useState("");
|
|
@@ -2836,7 +2887,7 @@ function LongText({ children }) {
|
|
|
2836
2887
|
if (!el || !outer || open) return;
|
|
2837
2888
|
const check = () => {
|
|
2838
2889
|
setOver(el.scrollHeight > el.clientHeight + 1);
|
|
2839
|
-
setCut(!narrow && outer.scrollWidth > outer.clientWidth + 1 ? outer.textContent ?? "" : "");
|
|
2890
|
+
setCut(!narrow && !touch && outer.scrollWidth > outer.clientWidth + 1 ? outer.textContent ?? "" : "");
|
|
2840
2891
|
};
|
|
2841
2892
|
check();
|
|
2842
2893
|
const ro = new ResizeObserver(check);
|
|
@@ -2845,7 +2896,8 @@ function LongText({ children }) {
|
|
|
2845
2896
|
}, [
|
|
2846
2897
|
open,
|
|
2847
2898
|
children,
|
|
2848
|
-
narrow
|
|
2899
|
+
narrow,
|
|
2900
|
+
touch
|
|
2849
2901
|
]);
|
|
2850
2902
|
const body = /* @__PURE__ */ jsxs("span", {
|
|
2851
2903
|
ref: box,
|
|
@@ -2929,6 +2981,9 @@ function DataTable(p) {
|
|
|
2929
2981
|
const [values, setValues] = React.useState(() => fromUrl().values);
|
|
2930
2982
|
const [view, setView] = React.useState(p.views?.[0]?.id ?? null);
|
|
2931
2983
|
const [toggled, setToggled] = React.useState({});
|
|
2984
|
+
const [opened, setOpened] = React.useState({});
|
|
2985
|
+
const narrow = useNarrow();
|
|
2986
|
+
const uid = React.useId();
|
|
2932
2987
|
const [sel, setSel] = React.useState({});
|
|
2933
2988
|
const [sumVal, setSumVal] = React.useState("all");
|
|
2934
2989
|
const [resetKey, setResetKey] = React.useState(p.resetKey);
|
|
@@ -2945,6 +3000,7 @@ function DataTable(p) {
|
|
|
2945
3000
|
dir: "desc"
|
|
2946
3001
|
});
|
|
2947
3002
|
setToggled({});
|
|
3003
|
+
setOpened({});
|
|
2948
3004
|
}
|
|
2949
3005
|
const valuesKey = JSON.stringify(values);
|
|
2950
3006
|
React.useEffect(() => {
|
|
@@ -3137,17 +3193,21 @@ function DataTable(p) {
|
|
|
3137
3193
|
const m = c.mobile || (!hasTitle && ci === 0 ? "title" : null);
|
|
3138
3194
|
return m ? "is-m-" + m : null;
|
|
3139
3195
|
};
|
|
3196
|
+
const longCols = shownCols.filter((c) => c.long);
|
|
3197
|
+
const expander = longCols.length > 0 && !narrow;
|
|
3198
|
+
const EXP = 40;
|
|
3140
3199
|
const template = [
|
|
3200
|
+
expander ? "40px" : null,
|
|
3141
3201
|
selectable ? "46px" : null,
|
|
3142
3202
|
...shownCols.map((c) => c.width ? `minmax(${c.width}px, ${c.grow || 1}fr)` : c.numeric ? "minmax(96px, .8fr)" : "minmax(120px, 1fr)"),
|
|
3143
3203
|
hasAct ? actW + "px" : null
|
|
3144
3204
|
].filter(Boolean).join(" ");
|
|
3145
|
-
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);
|
|
3146
3206
|
const gridStyle = {
|
|
3147
3207
|
gridTemplateColumns: template,
|
|
3148
3208
|
minWidth: minW
|
|
3149
3209
|
};
|
|
3150
|
-
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;
|
|
3151
3211
|
const cellClass = (c, ci, ...more) => cx("ui-dt-cell", isNum(c) && "is-num", ci === 0 && sticky && "is-sticky", ...more);
|
|
3152
3212
|
const head = selectable && selIds.length && p.bulkActions ? /* @__PURE__ */ jsxs("div", {
|
|
3153
3213
|
className: "ui-dt-row ui-dt-head ui-dt-bulk",
|
|
@@ -3187,6 +3247,11 @@ function DataTable(p) {
|
|
|
3187
3247
|
role: "row",
|
|
3188
3248
|
style: gridStyle,
|
|
3189
3249
|
children: [
|
|
3250
|
+
expander ? /* @__PURE__ */ jsx("div", {
|
|
3251
|
+
className: "ui-dt-cell ui-dt-exp",
|
|
3252
|
+
role: "columnheader",
|
|
3253
|
+
"aria-label": tr("詳細")
|
|
3254
|
+
}) : null,
|
|
3190
3255
|
selectable ? /* @__PURE__ */ jsx("div", {
|
|
3191
3256
|
className: "ui-dt-cell ui-dt-sel",
|
|
3192
3257
|
role: "columnheader",
|
|
@@ -3223,7 +3288,7 @@ function DataTable(p) {
|
|
|
3223
3288
|
]
|
|
3224
3289
|
});
|
|
3225
3290
|
const mark = searching ? q : "";
|
|
3226
|
-
const
|
|
3291
|
+
const cellInner = (r, c) => {
|
|
3227
3292
|
const raw = get(r, c.key);
|
|
3228
3293
|
let v;
|
|
3229
3294
|
if (c.render) v = c.render(r);
|
|
@@ -3239,8 +3304,9 @@ function DataTable(p) {
|
|
|
3239
3304
|
})
|
|
3240
3305
|
] });
|
|
3241
3306
|
else v = markMatch(cellText(c, raw), mark);
|
|
3242
|
-
return
|
|
3307
|
+
return v;
|
|
3243
3308
|
};
|
|
3309
|
+
const cell = (r, c) => c.long ? /* @__PURE__ */ jsx(LongText, { children: cellInner(r, c) }) : cellInner(r, c);
|
|
3244
3310
|
const total = (c, ci) => {
|
|
3245
3311
|
const how = p.totals?.[c.key];
|
|
3246
3312
|
const rowsAll = list.map((x) => x.r);
|
|
@@ -3342,12 +3408,18 @@ function DataTable(p) {
|
|
|
3342
3408
|
setPage(0);
|
|
3343
3409
|
}
|
|
3344
3410
|
}) : null,
|
|
3345
|
-
/* @__PURE__ */
|
|
3411
|
+
/* @__PURE__ */ jsxs("span", {
|
|
3346
3412
|
className: "ui-dt-result",
|
|
3347
|
-
children:
|
|
3348
|
-
|
|
3349
|
-
|
|
3350
|
-
|
|
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
|
+
})]
|
|
3351
3423
|
}),
|
|
3352
3424
|
p.columnMenu !== false && cols.length > 2 ? /* @__PURE__ */ jsx(ColumnMenu, {
|
|
3353
3425
|
cols,
|
|
@@ -3378,7 +3450,10 @@ function DataTable(p) {
|
|
|
3378
3450
|
children: vis.length ? vis.map((x, i) => {
|
|
3379
3451
|
const id = visIds[i];
|
|
3380
3452
|
const on = !!sel[id];
|
|
3381
|
-
|
|
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", {
|
|
3382
3457
|
"data-rid": id,
|
|
3383
3458
|
ref: (el) => {
|
|
3384
3459
|
rowEls.current[id] = el;
|
|
@@ -3387,6 +3462,25 @@ function DataTable(p) {
|
|
|
3387
3462
|
className: cx("ui-dt-row", i % 2 && "is-even", on && "is-selected", selectable && "has-sel"),
|
|
3388
3463
|
style: gridStyle,
|
|
3389
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,
|
|
3390
3484
|
selectable ? /* @__PURE__ */ jsx("div", {
|
|
3391
3485
|
className: "ui-dt-cell ui-dt-sel",
|
|
3392
3486
|
role: "cell",
|
|
@@ -3409,7 +3503,27 @@ function DataTable(p) {
|
|
|
3409
3503
|
children: p.rowActions?.(x.r)
|
|
3410
3504
|
}) : null
|
|
3411
3505
|
]
|
|
3412
|
-
},
|
|
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);
|
|
3413
3527
|
}) : /* @__PURE__ */ jsxs("div", {
|
|
3414
3528
|
className: "ui-dt-empty",
|
|
3415
3529
|
children: [p.emptyText || tr("沒有符合的資料"), q || activeN ? /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(Button, {
|
|
@@ -3423,6 +3537,10 @@ function DataTable(p) {
|
|
|
3423
3537
|
role: "row",
|
|
3424
3538
|
style: gridStyle,
|
|
3425
3539
|
children: [
|
|
3540
|
+
expander ? /* @__PURE__ */ jsx("div", {
|
|
3541
|
+
className: "ui-dt-cell",
|
|
3542
|
+
role: "cell"
|
|
3543
|
+
}) : null,
|
|
3426
3544
|
selectable ? /* @__PURE__ */ jsx("div", {
|
|
3427
3545
|
className: "ui-dt-cell",
|
|
3428
3546
|
role: "cell"
|
|
@@ -3658,6 +3776,128 @@ function DetailList({ items, className }) {
|
|
|
3658
3776
|
}, i))
|
|
3659
3777
|
});
|
|
3660
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
|
+
}
|
|
3661
3901
|
// src/components/EmptyState/EmptyState.tsx
|
|
3662
3902
|
/** What a list or page shows when it has nothing yet: what is missing and the first step. */
|
|
3663
3903
|
function EmptyState({ title, description, steps = [], current = 0, action }) {
|
|
@@ -4235,14 +4475,16 @@ function LayerGraph(p) {
|
|
|
4235
4475
|
const all = p.nodes;
|
|
4236
4476
|
const sel = p.selected ?? null;
|
|
4237
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} 個函式」.");
|
|
4238
|
-
|
|
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;
|
|
4239
4480
|
const sharedIds = new Set(all.filter((n) => n.shared).map((n) => n.id));
|
|
4240
4481
|
const main = all.filter((n) => !n.shared);
|
|
4241
4482
|
const shared = all.filter((n) => n.shared);
|
|
4242
4483
|
const edges = p.edges.filter((e) => !sharedIds.has(e.from) && !sharedIds.has(e.to));
|
|
4243
4484
|
const byLayer = /* @__PURE__ */ new Map();
|
|
4485
|
+
const EXTERNAL = Number.NEGATIVE_INFINITY;
|
|
4244
4486
|
for (const n of main) {
|
|
4245
|
-
const l = n.layer || 0;
|
|
4487
|
+
const l = n.external ? EXTERNAL : n.layer || 0;
|
|
4246
4488
|
byLayer.set(l, [...byLayer.get(l) ?? [], n]);
|
|
4247
4489
|
}
|
|
4248
4490
|
const layers = [...byLayer.keys()].sort((a, b) => a - b);
|
|
@@ -4318,8 +4560,9 @@ function LayerGraph(p) {
|
|
|
4318
4560
|
onScroll();
|
|
4319
4561
|
};
|
|
4320
4562
|
const selEdge = pickEdge && edges.find((e) => edgeId(e) === p.selectedEdge) || null;
|
|
4563
|
+
const nodeIdsAll = new Set(all.map((n) => n.id));
|
|
4321
4564
|
const uses = {};
|
|
4322
|
-
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);
|
|
4323
4566
|
const selShared = !selEdge && sel != null && sharedIds.has(sel) ? sel : null;
|
|
4324
4567
|
const related = (e) => selEdge ? e === selEdge : !!sel && !selShared && (e.from === sel || e.to === sel);
|
|
4325
4568
|
const focus = !!sel || !!selEdge;
|
|
@@ -4355,6 +4598,7 @@ function LayerGraph(p) {
|
|
|
4355
4598
|
const paths = [];
|
|
4356
4599
|
const labels = [];
|
|
4357
4600
|
const need = /* @__PURE__ */ new Set();
|
|
4601
|
+
const crowd = /* @__PURE__ */ new Set();
|
|
4358
4602
|
const marks = [];
|
|
4359
4603
|
const runs = [];
|
|
4360
4604
|
const segs = [];
|
|
@@ -4618,9 +4862,11 @@ function LayerGraph(p) {
|
|
|
4618
4862
|
const g = Math.max(0, Math.min(layers.length - 2, layers.findIndex((_, k) => k < layers.length - 1 && m.ty < rowTop(k + 1))));
|
|
4619
4863
|
need.add(g);
|
|
4620
4864
|
const x0 = x0Of(w);
|
|
4865
|
+
const top = find(x0, w, 16, false);
|
|
4866
|
+
if (top == null) crowd.add(g);
|
|
4621
4867
|
spot = {
|
|
4622
4868
|
x0,
|
|
4623
|
-
top:
|
|
4869
|
+
top: top ?? start0,
|
|
4624
4870
|
lw: w,
|
|
4625
4871
|
lh: 16,
|
|
4626
4872
|
lines: [m.text]
|
|
@@ -4637,6 +4883,7 @@ function LayerGraph(p) {
|
|
|
4637
4883
|
return;
|
|
4638
4884
|
}
|
|
4639
4885
|
const g = layerIndex[m.e.to] - 1;
|
|
4886
|
+
const gapTop = g >= 0 ? rowTop(g) + NH : 0;
|
|
4640
4887
|
const sideOf = (lw) => {
|
|
4641
4888
|
let left = m.left;
|
|
4642
4889
|
if (left && m.tx - 8 - lw < 0) left = false;
|
|
@@ -4658,7 +4905,7 @@ function LayerGraph(p) {
|
|
|
4658
4905
|
if (x0 < 0 || x0 + lw > W) continue;
|
|
4659
4906
|
for (let k = 0; k < 8 && !spot; k++) {
|
|
4660
4907
|
const top = m.ty - 8 - lh / 2 - k * 18;
|
|
4661
|
-
if (top - lh / 2 < 2) break;
|
|
4908
|
+
if (top - lh / 2 < Math.max(2, gapTop + 2)) break;
|
|
4662
4909
|
if (clear(x0, lw, top - lh / 2, top + lh / 2)) spot = {
|
|
4663
4910
|
x0,
|
|
4664
4911
|
top,
|
|
@@ -4673,16 +4920,42 @@ function LayerGraph(p) {
|
|
|
4673
4920
|
}
|
|
4674
4921
|
if (!spot) {
|
|
4675
4922
|
if (g >= 0) need.add(g);
|
|
4676
|
-
const
|
|
4677
|
-
|
|
4678
|
-
|
|
4679
|
-
|
|
4680
|
-
|
|
4681
|
-
|
|
4682
|
-
|
|
4683
|
-
|
|
4684
|
-
|
|
4685
|
-
|
|
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
|
+
}
|
|
4686
4959
|
}
|
|
4687
4960
|
placed.push([
|
|
4688
4961
|
spot.x0,
|
|
@@ -4697,7 +4970,8 @@ function LayerGraph(p) {
|
|
|
4697
4970
|
paths,
|
|
4698
4971
|
labels,
|
|
4699
4972
|
hitPaths,
|
|
4700
|
-
need
|
|
4973
|
+
need,
|
|
4974
|
+
crowd
|
|
4701
4975
|
};
|
|
4702
4976
|
};
|
|
4703
4977
|
placeRows();
|
|
@@ -4713,9 +4987,16 @@ function LayerGraph(p) {
|
|
|
4713
4987
|
for (const g of stuck) gaps[g] = GAP;
|
|
4714
4988
|
placeRows();
|
|
4715
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
|
+
}
|
|
4716
4996
|
}
|
|
4717
4997
|
const { paths, labels, hitPaths } = drawn;
|
|
4718
4998
|
const sizeText = p.sizeLabel ?? tr("{n} 個項目");
|
|
4999
|
+
const externalText = p.externalLabel ?? tr("repo 外");
|
|
4719
5000
|
const useText = p.useLabel ?? tr("使用 {n} 次");
|
|
4720
5001
|
const nodes = main.map((n) => {
|
|
4721
5002
|
const q = pos[n.id];
|
|
@@ -4724,7 +5005,7 @@ function LayerGraph(p) {
|
|
|
4724
5005
|
const used = selShared ? uses[selShared]?.[n.id] : void 0;
|
|
4725
5006
|
return /* @__PURE__ */ jsxs("button", {
|
|
4726
5007
|
type: "button",
|
|
4727
|
-
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"),
|
|
4728
5009
|
style: {
|
|
4729
5010
|
left: q.x,
|
|
4730
5011
|
top: q.y,
|
|
@@ -4733,26 +5014,33 @@ function LayerGraph(p) {
|
|
|
4733
5014
|
},
|
|
4734
5015
|
"aria-pressed": p.onSelect ? on : void 0,
|
|
4735
5016
|
onClick: p.onSelect ? () => pick(n.id, on) : void 0,
|
|
4736
|
-
children: [
|
|
4737
|
-
|
|
4738
|
-
|
|
4739
|
-
|
|
4740
|
-
|
|
4741
|
-
|
|
4742
|
-
|
|
4743
|
-
|
|
4744
|
-
|
|
4745
|
-
|
|
4746
|
-
|
|
4747
|
-
|
|
4748
|
-
className: "ui-lg-
|
|
4749
|
-
|
|
4750
|
-
|
|
4751
|
-
|
|
4752
|
-
className: "ui-lg-
|
|
4753
|
-
children:
|
|
4754
|
-
|
|
4755
|
-
|
|
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
|
+
]
|
|
4756
5044
|
}, n.id);
|
|
4757
5045
|
});
|
|
4758
5046
|
const sharedMeta = p.sharedMeta ?? tr("{a} 個項目使用,共 {b} 次");
|
|
@@ -4760,7 +5048,7 @@ function LayerGraph(p) {
|
|
|
4760
5048
|
const by = uses[s.id] ?? {};
|
|
4761
5049
|
const total = Object.values(by).reduce((a, b) => a + b, 0);
|
|
4762
5050
|
const on = s.id === sel;
|
|
4763
|
-
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));
|
|
4764
5052
|
return /* @__PURE__ */ jsxs("button", {
|
|
4765
5053
|
type: "button",
|
|
4766
5054
|
className: cx("ui-lg-node", "ui-lg-chip", on && "is-selected", dim && "is-dim"),
|
|
@@ -4803,7 +5091,10 @@ function LayerGraph(p) {
|
|
|
4803
5091
|
return listItem(n.id, n.id === sel, !near(n.id), p.onSelect ? () => pick(n.id, n.id === sel) : void 0, /* @__PURE__ */ jsx("span", {
|
|
4804
5092
|
className: "ui-lg-code",
|
|
4805
5093
|
children: n.name || n.id
|
|
4806
|
-
}),
|
|
5094
|
+
}), n.external && !n.shared ? /* @__PURE__ */ jsxs("span", {
|
|
5095
|
+
className: "ui-lg-limeta",
|
|
5096
|
+
children: [",", externalText]
|
|
5097
|
+
}) : size != null ? /* @__PURE__ */ jsxs("span", {
|
|
4807
5098
|
className: "ui-lg-limeta",
|
|
4808
5099
|
children: [",", monoNums(sizeText.replace("{n}", ""), [size])]
|
|
4809
5100
|
}) : null);
|
|
@@ -5535,6 +5826,7 @@ function RadioGroup({ label, value, onChange, options, disabled, className }) {
|
|
|
5535
5826
|
className: cx("ui-radio", on && "is-on"),
|
|
5536
5827
|
onClick: () => onChange?.(o.value),
|
|
5537
5828
|
onKeyDown: (e) => {
|
|
5829
|
+
if (browserKey(e)) return;
|
|
5538
5830
|
if (e.key === "ArrowDown" || e.key === "ArrowRight") {
|
|
5539
5831
|
e.preventDefault();
|
|
5540
5832
|
move(i, 1);
|
|
@@ -5903,9 +6195,15 @@ function TextArea({ label, hint, value, onChange, maxLength = 200, className, id
|
|
|
5903
6195
|
children: [/* @__PURE__ */ jsx("span", {
|
|
5904
6196
|
className: "ui-field-hint",
|
|
5905
6197
|
children: hint || ""
|
|
5906
|
-
}), /* @__PURE__ */
|
|
6198
|
+
}), /* @__PURE__ */ jsxs("span", {
|
|
5907
6199
|
className: "ui-count",
|
|
5908
|
-
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
|
+
})]
|
|
5909
6207
|
})]
|
|
5910
6208
|
})
|
|
5911
6209
|
]
|
|
@@ -6069,6 +6367,26 @@ function Tour({ open, steps, onClose, skippable = true, step: controlled, onStep
|
|
|
6069
6367
|
};
|
|
6070
6368
|
const end = (why) => onClose?.(why);
|
|
6071
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]);
|
|
6072
6390
|
const target = step?.target;
|
|
6073
6391
|
const pad = step?.padding ?? 6;
|
|
6074
6392
|
const hasStep = !!step;
|
|
@@ -6122,6 +6440,7 @@ function Tour({ open, steps, onClose, skippable = true, step: controlled, onStep
|
|
|
6122
6440
|
]);
|
|
6123
6441
|
const observer = React.useRef(null);
|
|
6124
6442
|
const card = React.useCallback((el) => {
|
|
6443
|
+
cardEl.current = el;
|
|
6125
6444
|
observer.current?.disconnect();
|
|
6126
6445
|
observer.current = null;
|
|
6127
6446
|
if (!el) return;
|
|
@@ -6171,6 +6490,7 @@ function Tour({ open, steps, onClose, skippable = true, step: controlled, onStep
|
|
|
6171
6490
|
className: "ui-tour-card",
|
|
6172
6491
|
"data-placement": place.mode,
|
|
6173
6492
|
initialFocus: next,
|
|
6493
|
+
onKeyDown: onTab,
|
|
6174
6494
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
6175
6495
|
className: "ui-tour-body",
|
|
6176
6496
|
children: [
|
|
@@ -6483,7 +6803,7 @@ function TreeList(p) {
|
|
|
6483
6803
|
setFocusId(rows[j].n.id);
|
|
6484
6804
|
};
|
|
6485
6805
|
const onKey = (e) => {
|
|
6486
|
-
if (e.target.getAttribute("role") !== "treeitem" || !rows.length) return;
|
|
6806
|
+
if (e.target.getAttribute("role") !== "treeitem" || !rows.length || browserKey(e)) return;
|
|
6487
6807
|
const r = rows[cur];
|
|
6488
6808
|
const k = e.key;
|
|
6489
6809
|
if (!([
|
|
@@ -6510,8 +6830,10 @@ function TreeList(p) {
|
|
|
6510
6830
|
break;
|
|
6511
6831
|
}
|
|
6512
6832
|
} else if (k === "Enter") {
|
|
6513
|
-
if (plain)
|
|
6514
|
-
|
|
6833
|
+
if (plain) {
|
|
6834
|
+
p.onSelect?.(r.n);
|
|
6835
|
+
if (r.isF) toggle(r.n);
|
|
6836
|
+
} else if (r.isF) toggle(r.n);
|
|
6515
6837
|
else openFile(r.n);
|
|
6516
6838
|
} else checkToggle(r.n);
|
|
6517
6839
|
};
|
|
@@ -6535,8 +6857,9 @@ function TreeList(p) {
|
|
|
6535
6857
|
const meta = n.meta ?? (n.path ? format.path(n.path) : "");
|
|
6536
6858
|
return /* @__PURE__ */ jsxs("div", {
|
|
6537
6859
|
...itemProps(r, idx),
|
|
6538
|
-
"aria-label": [
|
|
6860
|
+
"aria-label": n.ariaLabel ?? [
|
|
6539
6861
|
n.name,
|
|
6862
|
+
...(n.tags ?? []).map(nodeText),
|
|
6540
6863
|
n.meta,
|
|
6541
6864
|
n.path
|
|
6542
6865
|
].filter(Boolean).join(","),
|
|
@@ -6544,8 +6867,8 @@ function TreeList(p) {
|
|
|
6544
6867
|
className: cx("ui-tree-row", "is-plain", on && "is-current", n.muted && "is-muted", r.fresh && "ui-tree-in"),
|
|
6545
6868
|
onClick: () => {
|
|
6546
6869
|
setFocusId(n.id);
|
|
6547
|
-
|
|
6548
|
-
|
|
6870
|
+
p.onSelect?.(n);
|
|
6871
|
+
if (isF) toggle(n);
|
|
6549
6872
|
},
|
|
6550
6873
|
children: [
|
|
6551
6874
|
/* @__PURE__ */ jsx(Guides, { guides: r.guides }),
|
|
@@ -6653,6 +6976,7 @@ function TreeList(p) {
|
|
|
6653
6976
|
const bits = (isF ? [fl.length ? tr("{n} 個檔案", { n: fl.length }) : "", dateTxt] : [dateTxt, sizeTxt]).filter(Boolean);
|
|
6654
6977
|
return /* @__PURE__ */ jsxs("div", {
|
|
6655
6978
|
...itemProps(r, idx),
|
|
6979
|
+
"aria-label": n.ariaLabel,
|
|
6656
6980
|
"aria-selected": selectable ? ck === true : void 0,
|
|
6657
6981
|
className: cx("ui-tree-row", isF && "is-folder", ck === true && "is-selected", r.fresh && "ui-tree-in"),
|
|
6658
6982
|
onClick: () => {
|
|
@@ -6859,6 +7183,6 @@ function TreeList(p) {
|
|
|
6859
7183
|
})]
|
|
6860
7184
|
});
|
|
6861
7185
|
}
|
|
6862
|
-
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 };
|
|
6863
7187
|
|
|
6864
7188
|
//# sourceMappingURL=index.js.map
|