@seanyeh77/ui 0.32.0 → 0.34.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 +19 -18
- package/dist/bundle.js.map +1 -1
- package/dist/{format-entry-B9oxzJvw.js → format-entry-CubJQqC9.js} +3 -1
- package/dist/{format-entry-B9oxzJvw.js.map → format-entry-CubJQqC9.js.map} +1 -1
- package/dist/format.js +1 -1
- package/dist/index.d.ts +39 -8
- package/dist/index.js +229 -43
- package/dist/index.js.map +1 -1
- package/dist/styles.css +97 -21
- package/docs/AiMark.md +7 -7
- package/docs/CodeView.md +23 -0
- package/docs/IconButton.md +2 -3
- package/docs/Markdown.md +5 -8
- package/docs/SegmentedControl.md +28 -0
- package/docs/TreeList.md +1 -2
- package/docs/Workbench.md +4 -0
- package/docs/guidelines.md +3 -3
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { a as parseDate, c as addMessages, d as unitFor, i as format, l as setLocale, n as fileSize, o as sameDay, r as fmtDate, s as I18N, t as dayAdd, u as tr } from "./format-entry-
|
|
2
|
+
import { a as parseDate, c as addMessages, d as unitFor, i as format, l as setLocale, n as fileSize, o as sameDay, r as fmtDate, s as I18N, t as dayAdd, u as tr } from "./format-entry-CubJQqC9.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";
|
|
@@ -819,35 +819,74 @@ function IconButton({ label, icon, className, tooltip = true, filled, hint, vari
|
|
|
819
819
|
if (!hint) return button;
|
|
820
820
|
return /* @__PURE__ */ jsxs("span", {
|
|
821
821
|
className: "ui-iconbtn-hintbox",
|
|
822
|
-
children: [button, /* @__PURE__ */
|
|
823
|
-
className: "ui-hint",
|
|
822
|
+
children: [button, /* @__PURE__ */ jsx(HintBubble, {
|
|
824
823
|
id,
|
|
825
|
-
|
|
826
|
-
children: [
|
|
827
|
-
/* @__PURE__ */ jsx("span", {
|
|
828
|
-
className: "ui-hint-text",
|
|
829
|
-
children: hint.text
|
|
830
|
-
}),
|
|
831
|
-
/* @__PURE__ */ jsx("button", {
|
|
832
|
-
type: "button",
|
|
833
|
-
className: "ui-hint-go",
|
|
834
|
-
onClick: hint.onAction,
|
|
835
|
-
children: hint.action ?? tr("開始")
|
|
836
|
-
}),
|
|
837
|
-
/* @__PURE__ */ jsx("button", {
|
|
838
|
-
type: "button",
|
|
839
|
-
className: "ui-hint-x",
|
|
840
|
-
"aria-label": tr("關閉提示"),
|
|
841
|
-
onClick: hint.onDismiss,
|
|
842
|
-
children: /* @__PURE__ */ jsx(Icon, {
|
|
843
|
-
name: "x",
|
|
844
|
-
size: 16
|
|
845
|
-
})
|
|
846
|
-
})
|
|
847
|
-
]
|
|
824
|
+
hint
|
|
848
825
|
})]
|
|
849
826
|
});
|
|
850
827
|
}
|
|
828
|
+
/** The bubble sits left of the button, in its row (H3), narrowing (the text wraps) to the room there. With less than
|
|
829
|
+
* 180 px on the left it goes below the button, right-aligned with it but kept 16 px inside the screen, its arrow
|
|
830
|
+
* still on the button. */
|
|
831
|
+
function HintBubble({ id, hint }) {
|
|
832
|
+
const ref = React.useRef(null);
|
|
833
|
+
const [place, setPlace] = React.useState(null);
|
|
834
|
+
React.useLayoutEffect(() => {
|
|
835
|
+
const el = ref.current;
|
|
836
|
+
if (!el) return;
|
|
837
|
+
const check = () => {
|
|
838
|
+
const box = el.parentElement?.getBoundingClientRect();
|
|
839
|
+
if (!box) return;
|
|
840
|
+
const room = Math.floor(box.left - 12 - 8);
|
|
841
|
+
if (room >= 180) return setPlace({ room });
|
|
842
|
+
const w = Math.min(320, window.innerWidth - 32);
|
|
843
|
+
const want = box.left + box.width - w;
|
|
844
|
+
const at = Math.max(16, Math.min(want, window.innerWidth - 16 - w));
|
|
845
|
+
setPlace({
|
|
846
|
+
room,
|
|
847
|
+
left: Math.round(at - box.left),
|
|
848
|
+
arrow: Math.round(box.left + box.width / 2 - at - 6)
|
|
849
|
+
});
|
|
850
|
+
};
|
|
851
|
+
check();
|
|
852
|
+
window.addEventListener("resize", check);
|
|
853
|
+
return () => window.removeEventListener("resize", check);
|
|
854
|
+
}, []);
|
|
855
|
+
const below = place != null && place.room < 180;
|
|
856
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
857
|
+
ref,
|
|
858
|
+
className: cx("ui-hint", below && "is-below"),
|
|
859
|
+
id,
|
|
860
|
+
role: "status",
|
|
861
|
+
style: place == null ? void 0 : below ? {
|
|
862
|
+
left: place.left,
|
|
863
|
+
right: "auto",
|
|
864
|
+
"--hint-arrow": place.arrow + "px"
|
|
865
|
+
} : { maxWidth: Math.min(320, place.room) },
|
|
866
|
+
children: [
|
|
867
|
+
/* @__PURE__ */ jsx("span", {
|
|
868
|
+
className: "ui-hint-text",
|
|
869
|
+
children: hint.text
|
|
870
|
+
}),
|
|
871
|
+
/* @__PURE__ */ jsx("button", {
|
|
872
|
+
type: "button",
|
|
873
|
+
className: "ui-hint-go",
|
|
874
|
+
onClick: hint.onAction,
|
|
875
|
+
children: hint.action ?? tr("開始")
|
|
876
|
+
}),
|
|
877
|
+
/* @__PURE__ */ jsx("button", {
|
|
878
|
+
type: "button",
|
|
879
|
+
className: "ui-hint-x",
|
|
880
|
+
"aria-label": tr("關閉提示"),
|
|
881
|
+
onClick: hint.onDismiss,
|
|
882
|
+
children: /* @__PURE__ */ jsx(Icon, {
|
|
883
|
+
name: "x",
|
|
884
|
+
size: 16
|
|
885
|
+
})
|
|
886
|
+
})
|
|
887
|
+
]
|
|
888
|
+
});
|
|
889
|
+
}
|
|
851
890
|
// src/components/TopBar/TopBar.tsx
|
|
852
891
|
/** The bar at the top of a dashboard page: title or breadcrumb on the left, search and tools on the right. */
|
|
853
892
|
function TopBar({ title, breadcrumb, onSearch, searchLabel, children, onMenu, className }) {
|
|
@@ -2671,6 +2710,33 @@ function matchLinks(lines, start, links) {
|
|
|
2671
2710
|
for (const list of out.values()) list.sort((a, b) => a.from - b.from);
|
|
2672
2711
|
return out;
|
|
2673
2712
|
}
|
|
2713
|
+
/** True when the reader has text selected inside el. */
|
|
2714
|
+
function selectedIn(el) {
|
|
2715
|
+
const sel = typeof window === "undefined" ? null : window.getSelection();
|
|
2716
|
+
if (!el || !sel || sel.isCollapsed || !sel.rangeCount) return false;
|
|
2717
|
+
const r = sel.getRangeAt(0);
|
|
2718
|
+
return el.contains(r.startContainer) || el.contains(r.endContainer);
|
|
2719
|
+
}
|
|
2720
|
+
/** The selected code as plain text, one line per line; null when the selection is not in pre. */
|
|
2721
|
+
function selectedCode(pre) {
|
|
2722
|
+
const sel = window.getSelection();
|
|
2723
|
+
if (!sel || sel.isCollapsed || !sel.rangeCount) return null;
|
|
2724
|
+
const r = sel.getRangeAt(0);
|
|
2725
|
+
if (!pre.contains(r.commonAncestorContainer)) return null;
|
|
2726
|
+
const frag = r.cloneContents();
|
|
2727
|
+
frag.querySelectorAll(".ui-cv-num, .ui-visually-hidden").forEach((x) => x.remove());
|
|
2728
|
+
const rows = [...frag.querySelectorAll("[role=\"listitem\"]")];
|
|
2729
|
+
return rows.length ? rows.map((x) => x.textContent ?? "").join("\n") : frag.textContent ?? "";
|
|
2730
|
+
}
|
|
2731
|
+
/** Scrolls el into view inside box (or the page) only when it is not already fully visible. */
|
|
2732
|
+
function inView(el, box) {
|
|
2733
|
+
const r = el.getBoundingClientRect();
|
|
2734
|
+
const b = box && box.scrollHeight > box.clientHeight ? box.getBoundingClientRect() : {
|
|
2735
|
+
top: 0,
|
|
2736
|
+
bottom: window.innerHeight
|
|
2737
|
+
};
|
|
2738
|
+
if (r.top < b.top || r.bottom > b.bottom) el.scrollIntoView({ block: "nearest" });
|
|
2739
|
+
}
|
|
2674
2740
|
/** Each line's words from `terms`: only in comments and strings, never where a name link or a path is. With 'first',
|
|
2675
2741
|
* each word once per file, at its first place. */
|
|
2676
2742
|
function matchTerms(toks, start, links, terms, mark) {
|
|
@@ -2724,7 +2790,7 @@ function KeysPanel(p) {
|
|
|
2724
2790
|
});
|
|
2725
2791
|
}
|
|
2726
2792
|
/** Source with line numbers and an optional target line: soft accent background, long lines wrap, light syntax colors. */
|
|
2727
|
-
function CodeView({ code, start = 1, target, context = 2, file, fileHref, onFile, title, language, languageLabel, highlight = true, tokenizer = tokenize, refHref, onRef, links, onLink, preview, terms, termsMark = "first", maxHeight, sections, copy, header = true, lineNumbers = true, onCopy, onCopyError, className, ref }) {
|
|
2793
|
+
function CodeView({ code, start = 1, target, context = 2, file, fileHref, onFile, title, language, languageLabel, highlight = true, tokenizer = tokenize, refHref, onRef, links, onLink, preview, terms, termsMark = "first", maxHeight, sections, copy, header = true, lineNumbers = true, onCopy, onCopyError, onLine, peek, className, ref }) {
|
|
2728
2794
|
const lines = React.useMemo(() => String(code || "").replace(/\n$/, "").split("\n"), [code]);
|
|
2729
2795
|
const lang = language || languageOf(file);
|
|
2730
2796
|
const toks = React.useMemo(() => highlight ? tokenizer(lines, lang) : lines.map((l) => [["", l]]), [
|
|
@@ -2826,12 +2892,20 @@ function CodeView({ code, start = 1, target, context = 2, file, fileHref, onFile
|
|
|
2826
2892
|
const from = windowed ? Math.max(0, ta - start - context) : 0;
|
|
2827
2893
|
const to = windowed ? Math.min(lines.length, tb - start + context + 1) : lines.length;
|
|
2828
2894
|
const body = React.useRef(null);
|
|
2829
|
-
React.useImperativeHandle(ref, () => ({ focusTarget: () =>
|
|
2895
|
+
React.useImperativeHandle(ref, () => ({ focusTarget: () => {
|
|
2896
|
+
if (selectedIn(body.current)) return;
|
|
2897
|
+
body.current?.querySelector(".is-target")?.focus();
|
|
2898
|
+
} }));
|
|
2830
2899
|
React.useEffect(() => {
|
|
2831
2900
|
const b = body.current;
|
|
2832
2901
|
const el = b?.querySelector(".is-target");
|
|
2833
|
-
if (b && el && b.scrollHeight > b.clientHeight) b.scrollTop += el.getBoundingClientRect().top - b.getBoundingClientRect().top - b.clientHeight / 2 + el.offsetHeight / 2;
|
|
2902
|
+
if (b && el && b.scrollHeight > b.clientHeight && !selectedIn(b)) b.scrollTop += el.getBoundingClientRect().top - b.getBoundingClientRect().top - b.clientHeight / 2 + el.offsetHeight / 2;
|
|
2834
2903
|
}, [ta, code]);
|
|
2904
|
+
React.useEffect(() => {
|
|
2905
|
+
if (peek == null) return;
|
|
2906
|
+
const el = body.current?.querySelector(`[data-n="${peek}"]`);
|
|
2907
|
+
if (el) inView(el, body.current);
|
|
2908
|
+
}, [peek]);
|
|
2835
2909
|
const digits = String(start + lines.length - 1).length;
|
|
2836
2910
|
const prose = (cls, text, inLink) => !inLink && (refHref || onRef) && (cls === "is-comment" || cls === "is-string") ? withPaths(text, refHref, onRef, nav ? -1 : void 0) : breakable(text);
|
|
2837
2911
|
const piece = (cls, text, key, inLink, at = 0, words) => {
|
|
@@ -2918,7 +2992,7 @@ function CodeView({ code, start = 1, target, context = 2, file, fileHref, onFile
|
|
|
2918
2992
|
const on = ta != null && tb != null && n >= ta && n <= tb;
|
|
2919
2993
|
rows.push(/* @__PURE__ */ jsxs("div", {
|
|
2920
2994
|
role: "listitem",
|
|
2921
|
-
className: cx("ui-cv-line", on && "is-target"),
|
|
2995
|
+
className: cx("ui-cv-line", on && "is-target", peek === n && "is-peek"),
|
|
2922
2996
|
"data-n": n,
|
|
2923
2997
|
"aria-current": on && n === ta ? "location" : void 0,
|
|
2924
2998
|
tabIndex: on && n === ta ? -1 : void 0,
|
|
@@ -3009,7 +3083,14 @@ function CodeView({ code, start = 1, target, context = 2, file, fileHref, onFile
|
|
|
3009
3083
|
if (!el) return;
|
|
3010
3084
|
el.tabIndex = -1;
|
|
3011
3085
|
el.focus();
|
|
3086
|
+
onLine?.(nOf(el), "key");
|
|
3012
3087
|
};
|
|
3088
|
+
if (onLine && !nav && (e.key === "ArrowUp" || e.key === "ArrowDown")) {
|
|
3089
|
+
e.preventDefault();
|
|
3090
|
+
if (now < 0) focusLine(items.find((el) => el.classList.contains("is-target")) ?? items[0]);
|
|
3091
|
+
else focusLine(items[Math.max(0, Math.min(items.length - 1, now + (e.key === "ArrowDown" ? 1 : -1)))]);
|
|
3092
|
+
return;
|
|
3093
|
+
}
|
|
3013
3094
|
if (nav) {
|
|
3014
3095
|
const stops = [...pre.querySelectorAll(".ui-cv-name, .ui-cv-ref, .ui-cv-term")];
|
|
3015
3096
|
const onStop = act ? stops.indexOf(act) : -1;
|
|
@@ -3067,11 +3148,29 @@ function CodeView({ code, start = 1, target, context = 2, file, fileHref, onFile
|
|
|
3067
3148
|
if (!el) return;
|
|
3068
3149
|
el.tabIndex = -1;
|
|
3069
3150
|
el.focus();
|
|
3151
|
+
onLine?.(nOf(el), "key");
|
|
3070
3152
|
if (said) announce(tr("{name},第 {n} 行", {
|
|
3071
3153
|
name: said,
|
|
3072
3154
|
n: nOf(el)
|
|
3073
3155
|
}));
|
|
3074
3156
|
};
|
|
3157
|
+
const onLineClick = (e) => {
|
|
3158
|
+
if (!onLine) return;
|
|
3159
|
+
const t = e.target instanceof Element ? e.target : null;
|
|
3160
|
+
if (!t) return;
|
|
3161
|
+
const type = e.nativeEvent.pointerType;
|
|
3162
|
+
if (t.closest(".ui-cv-name") && (e.detail === 0 || type === "touch" || type === "pen" || e.ctrlKey || e.metaKey)) return;
|
|
3163
|
+
if (t.closest("a:not(.ui-cv-name), button:not(.ui-cv-name)")) return;
|
|
3164
|
+
if (selectedIn(e.currentTarget)) return;
|
|
3165
|
+
const row = t.closest("[role=\"listitem\"]");
|
|
3166
|
+
if (row) onLine(Number(row.dataset.n), "click");
|
|
3167
|
+
};
|
|
3168
|
+
const onCopyText = (e) => {
|
|
3169
|
+
const text = selectedCode(e.currentTarget);
|
|
3170
|
+
if (text == null) return;
|
|
3171
|
+
e.preventDefault();
|
|
3172
|
+
e.clipboardData.setData("text/plain", text);
|
|
3173
|
+
};
|
|
3075
3174
|
const [copied, setCopied] = React.useState(false);
|
|
3076
3175
|
const [keysOpen, setKeysOpen] = React.useState(false);
|
|
3077
3176
|
const byKey = React.useRef(false);
|
|
@@ -3165,8 +3264,13 @@ function CodeView({ code, start = 1, target, context = 2, file, fileHref, onFile
|
|
|
3165
3264
|
"aria-label": tr("程式碼"),
|
|
3166
3265
|
"aria-keyshortcuts": [...keys.map((k) => k.k), "?"].join(" "),
|
|
3167
3266
|
onKeyDown: onMove,
|
|
3267
|
+
onCopy: onCopyText,
|
|
3268
|
+
onClick: nav ? void 0 : onLineClick,
|
|
3168
3269
|
...nav ? {
|
|
3169
|
-
onClick:
|
|
3270
|
+
onClick: (e) => {
|
|
3271
|
+
onLinkClick(e);
|
|
3272
|
+
onLineClick(e);
|
|
3273
|
+
},
|
|
3170
3274
|
onPointerEnter: () => inside.current = true,
|
|
3171
3275
|
onPointerLeave: () => {
|
|
3172
3276
|
inside.current = false;
|
|
@@ -5901,16 +6005,17 @@ function GraphLegend({ items = LEGEND_DEFAULT, className }) {
|
|
|
5901
6005
|
});
|
|
5902
6006
|
}
|
|
5903
6007
|
// src/components/AiMark/AiMark.tsx
|
|
5904
|
-
/** A small 「AI
|
|
5905
|
-
* screen readers
|
|
5906
|
-
function AiMark({ label, className }) {
|
|
6008
|
+
/** A small gray 「AI 撰寫」 at the end of a sentence, paragraph, list item or cell written by AI. Not a link and not a
|
|
6009
|
+
* Tab stop; screen readers hear it in parentheses after the sentence. */
|
|
6010
|
+
function AiMark({ text, label, className }) {
|
|
6011
|
+
const words = text ?? tr("AI 撰寫");
|
|
5907
6012
|
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("span", {
|
|
5908
6013
|
className: cx("ui-aimark", className),
|
|
5909
6014
|
"aria-hidden": "true",
|
|
5910
|
-
children:
|
|
6015
|
+
children: words
|
|
5911
6016
|
}), /* @__PURE__ */ jsx("span", {
|
|
5912
6017
|
className: "ui-visually-hidden",
|
|
5913
|
-
children:
|
|
6018
|
+
children: label ?? tr("({v})", { v: words })
|
|
5914
6019
|
})] });
|
|
5915
6020
|
}
|
|
5916
6021
|
// src/components/Markdown/Markdown.tsx
|
|
@@ -6138,6 +6243,7 @@ const noTerms = (c) => ({
|
|
|
6138
6243
|
const CJK = /[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\u3000-\u303f\uff00-\uffef]/u;
|
|
6139
6244
|
/** Inline Markdown: code spans, links, autolinks, bold, italic, hard breaks; HTML tags dropped, their text kept. */
|
|
6140
6245
|
function inline(src, c) {
|
|
6246
|
+
let aiMark = null;
|
|
6141
6247
|
const out = [];
|
|
6142
6248
|
let text = "";
|
|
6143
6249
|
const flush = () => {
|
|
@@ -6212,9 +6318,8 @@ function inline(src, c) {
|
|
|
6212
6318
|
const m = matchLink(src, i);
|
|
6213
6319
|
if (m) {
|
|
6214
6320
|
if (m.href.trim().toLowerCase() === "ai:") {
|
|
6215
|
-
|
|
6216
|
-
|
|
6217
|
-
out.push(/* @__PURE__ */ jsx(AiMark, {}, c.k()));
|
|
6321
|
+
const words = m.text.trim();
|
|
6322
|
+
aiMark = words && words !== "AI" ? words : "";
|
|
6218
6323
|
i = m.end;
|
|
6219
6324
|
if (src[i] === " ") i++;
|
|
6220
6325
|
continue;
|
|
@@ -6259,6 +6364,11 @@ function inline(src, c) {
|
|
|
6259
6364
|
i++;
|
|
6260
6365
|
}
|
|
6261
6366
|
flush();
|
|
6367
|
+
if (aiMark != null) {
|
|
6368
|
+
const last = out[out.length - 1];
|
|
6369
|
+
if (typeof last === "string") out[out.length - 1] = last.replace(/\s+$/, "");
|
|
6370
|
+
out.push(/* @__PURE__ */ jsx(AiMark, { text: aiMark || void 0 }, c.k()));
|
|
6371
|
+
}
|
|
6262
6372
|
return out;
|
|
6263
6373
|
function code(v, ctx) {
|
|
6264
6374
|
const onRef = ctx.onRef;
|
|
@@ -9482,6 +9592,81 @@ function Suggestion({ title, before, after, copyText: copyValue, copyLabel, onCo
|
|
|
9482
9592
|
]
|
|
9483
9593
|
});
|
|
9484
9594
|
}
|
|
9595
|
+
// src/components/SegmentedControl/SegmentedControl.tsx
|
|
9596
|
+
/** A small switch between two or three ways of showing the same thing (預覽/原始碼), 28 px tall to sit in a toolbar
|
|
9597
|
+
* or Workbench's mainBar. The selected part is a raised white pill that slides; ← → move and pick. For views of
|
|
9598
|
+
* different content use Tabs. */
|
|
9599
|
+
function SegmentedControl({ items, value, onChange, label, iconOnly = false, className }) {
|
|
9600
|
+
devWarn(iconOnly && items.some((t) => !t.icon), "SegmentedControl", "iconOnly 需要每一項都有 icon;沒有圖示的那一項只剩空白。補上 icon,或拿掉 iconOnly 改顯示文字。");
|
|
9601
|
+
const refs = React.useRef([]);
|
|
9602
|
+
const idx = Math.max(0, items.findIndex((t) => t.id === value));
|
|
9603
|
+
const [box, setBox] = React.useState(null);
|
|
9604
|
+
const [forward, setForward] = React.useState(true);
|
|
9605
|
+
React.useLayoutEffect(() => {
|
|
9606
|
+
const el = refs.current[idx];
|
|
9607
|
+
if (!el) return;
|
|
9608
|
+
const measure = () => setBox({
|
|
9609
|
+
left: el.offsetLeft,
|
|
9610
|
+
width: el.offsetWidth
|
|
9611
|
+
});
|
|
9612
|
+
measure();
|
|
9613
|
+
const ro = new ResizeObserver(measure);
|
|
9614
|
+
ro.observe(el);
|
|
9615
|
+
return () => ro.disconnect();
|
|
9616
|
+
}, [idx, items.length]);
|
|
9617
|
+
const go = (i) => {
|
|
9618
|
+
if (i === idx || !items[i]) return;
|
|
9619
|
+
setForward(i > idx);
|
|
9620
|
+
onChange?.(items[i].id);
|
|
9621
|
+
};
|
|
9622
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
9623
|
+
className: cx("ui-seg", iconOnly && "is-icons", className),
|
|
9624
|
+
role: "radiogroup",
|
|
9625
|
+
"aria-label": label,
|
|
9626
|
+
children: [box ? /* @__PURE__ */ jsx("span", {
|
|
9627
|
+
className: "ui-seg-ind",
|
|
9628
|
+
"aria-hidden": "true",
|
|
9629
|
+
style: {
|
|
9630
|
+
left: box.left,
|
|
9631
|
+
width: box.width,
|
|
9632
|
+
transition: dropTransition("left", "width", forward)
|
|
9633
|
+
}
|
|
9634
|
+
}) : null, items.map((t, i) => {
|
|
9635
|
+
const btn = /* @__PURE__ */ jsxs("button", {
|
|
9636
|
+
ref: (n) => {
|
|
9637
|
+
refs.current[i] = n;
|
|
9638
|
+
},
|
|
9639
|
+
type: "button",
|
|
9640
|
+
role: "radio",
|
|
9641
|
+
"aria-checked": i === idx,
|
|
9642
|
+
"aria-label": iconOnly ? t.label : void 0,
|
|
9643
|
+
tabIndex: i === idx ? 0 : -1,
|
|
9644
|
+
className: cx("ui-seg-item", i === idx && "is-selected"),
|
|
9645
|
+
onClick: () => go(i),
|
|
9646
|
+
onKeyDown: (e) => {
|
|
9647
|
+
if (browserKey(e)) return;
|
|
9648
|
+
const n = items.length;
|
|
9649
|
+
const to = e.key === "ArrowRight" || e.key === "ArrowDown" ? (i + 1) % n : e.key === "ArrowLeft" || e.key === "ArrowUp" ? (i - 1 + n) % n : -1;
|
|
9650
|
+
if (to < 0) return;
|
|
9651
|
+
e.preventDefault();
|
|
9652
|
+
refs.current[to]?.focus();
|
|
9653
|
+
go(to);
|
|
9654
|
+
},
|
|
9655
|
+
children: [t.icon ? /* @__PURE__ */ jsx(IconOf, {
|
|
9656
|
+
icon: t.icon,
|
|
9657
|
+
size: 16,
|
|
9658
|
+
filled: iconOnly && i === idx
|
|
9659
|
+
}) : null, iconOnly ? null : /* @__PURE__ */ jsx("span", { children: t.label })]
|
|
9660
|
+
}, t.id);
|
|
9661
|
+
return iconOnly ? /* @__PURE__ */ jsx(Tooltip, {
|
|
9662
|
+
label: t.label,
|
|
9663
|
+
describe: false,
|
|
9664
|
+
side: "bottom",
|
|
9665
|
+
children: btn
|
|
9666
|
+
}, t.id) : btn;
|
|
9667
|
+
})]
|
|
9668
|
+
});
|
|
9669
|
+
}
|
|
9485
9670
|
// src/components/Tag/Tag.tsx
|
|
9486
9671
|
/** What kind of thing an item is (「外部」「範本」): small gray text. Status uses Badge instead. */
|
|
9487
9672
|
function Tag({ children, className }) {
|
|
@@ -10319,8 +10504,9 @@ function TreeList(p) {
|
|
|
10319
10504
|
}
|
|
10320
10505
|
} else if (k === "Enter") {
|
|
10321
10506
|
if (plain) {
|
|
10507
|
+
const again = p.selectedId != null && p.selectedId === r.n.id;
|
|
10322
10508
|
p.onSelect?.(r.n);
|
|
10323
|
-
if (r.isF) toggle(r.n);
|
|
10509
|
+
if (r.isF && !again) toggle(r.n);
|
|
10324
10510
|
} else if (r.isF) toggle(r.n);
|
|
10325
10511
|
else openFile(r.n);
|
|
10326
10512
|
} else checkToggle(r.n);
|
|
@@ -10355,9 +10541,9 @@ function TreeList(p) {
|
|
|
10355
10541
|
"aria-selected": p.onSelect ? on : void 0,
|
|
10356
10542
|
className: cx("ui-tree-row", "is-plain", on && "is-current", n.muted && "is-muted", r.fresh && "ui-tree-in"),
|
|
10357
10543
|
onClick: () => {
|
|
10358
|
-
setFocusId(n.id);
|
|
10544
|
+
if (focusId !== n.id) setFocusId(n.id);
|
|
10359
10545
|
p.onSelect?.(n);
|
|
10360
|
-
if (isF) toggle(n);
|
|
10546
|
+
if (isF && !on) toggle(n);
|
|
10361
10547
|
},
|
|
10362
10548
|
children: [
|
|
10363
10549
|
/* @__PURE__ */ jsx(Guides, { guides: r.guides }),
|
|
@@ -11801,6 +11987,6 @@ function Workbench({ ref, ...p }) {
|
|
|
11801
11987
|
})
|
|
11802
11988
|
});
|
|
11803
11989
|
}
|
|
11804
|
-
export { AccentPicker, ActionBar, AiMark, 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, Markdown, Menu, MobileTabBar, MultiSelect, NotificationBell, Page, Popover, ProgressBar, ProgressRing, ProjectSwitcher, RadioGroup, SearchField, Section, SectionGroup, SectionGroupToggle, Select, SettingsLayout, SettingsSection, SideNav, Skeleton, SplitPane, Suggestion, Switch, Tabs, Tag, Term, TextArea, TextField, ThemePicker, Toast, Tooltip, TopBar, Tour, TreeList, Workbench, addMessages, announce, focusMain, format, icons, initTheme, isCodeRef, safeHref, setAccent, setLocale, setTheme, tr as t, useTour, useWorkbench };
|
|
11990
|
+
export { AccentPicker, ActionBar, AiMark, 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, Markdown, Menu, MobileTabBar, MultiSelect, NotificationBell, Page, Popover, ProgressBar, ProgressRing, ProjectSwitcher, RadioGroup, SearchField, Section, SectionGroup, SectionGroupToggle, SegmentedControl, Select, SettingsLayout, SettingsSection, SideNav, Skeleton, SplitPane, Suggestion, Switch, Tabs, Tag, Term, TextArea, TextField, ThemePicker, Toast, Tooltip, TopBar, Tour, TreeList, Workbench, addMessages, announce, focusMain, format, icons, initTheme, isCodeRef, safeHref, setAccent, setLocale, setTheme, tr as t, useTour, useWorkbench };
|
|
11805
11991
|
|
|
11806
11992
|
//# sourceMappingURL=index.js.map
|