@seanyeh77/ui 0.26.0 → 0.28.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 -19
- package/dist/bundle.js.map +1 -1
- package/dist/{format-entry-Dvpr6YK0.js → format-entry-BXwnh9f-.js} +3 -1
- package/dist/format-entry-BXwnh9f-.js.map +1 -0
- package/dist/format.js +1 -1
- package/dist/index.d.ts +71 -11
- package/dist/index.js +226 -54
- package/dist/index.js.map +1 -1
- package/dist/styles.css +225 -0
- package/docs/AiMark.md +20 -0
- package/docs/AppShell.md +17 -1
- package/docs/IconButton.md +18 -0
- package/docs/InlineCode.md +23 -1
- package/docs/Markdown.md +23 -0
- package/docs/SideNav.md +17 -1
- package/docs/Tour.md +1 -0
- package/docs/guidelines.md +5 -1
- package/package.json +2 -2
- package/dist/format-entry-Dvpr6YK0.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { a as parseDate, c as addMessages, d as unitFor, i as format, l as setLocale, n as fileSize, o as sameDay, r as fmtDate, s as I18N, t as dayAdd, u as tr } from "./format-entry-
|
|
2
|
+
import { a as parseDate, c as addMessages, d as unitFor, i as format, l as setLocale, n as fileSize, o as sameDay, r as fmtDate, s as I18N, t as dayAdd, u as tr } from "./format-entry-BXwnh9f-.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";
|
|
@@ -491,7 +491,66 @@ function announce(text) {
|
|
|
491
491
|
el.textContent = text;
|
|
492
492
|
}, 60);
|
|
493
493
|
}
|
|
494
|
+
// src/internal/dev.ts
|
|
495
|
+
const DEV = typeof __UI_DEV__ === "boolean" ? __UI_DEV__ : (() => {
|
|
496
|
+
try {
|
|
497
|
+
return process.env.NODE_ENV !== "production";
|
|
498
|
+
} catch {
|
|
499
|
+
return false;
|
|
500
|
+
}
|
|
501
|
+
})();
|
|
502
|
+
const seen = /* @__PURE__ */ new Set();
|
|
503
|
+
/** Logs once per message when cond is true. */
|
|
504
|
+
function devWarn(cond, component, message) {
|
|
505
|
+
if (!DEV || !cond) return;
|
|
506
|
+
const text = `[@seanyeh77/ui] ${component}: ${message}`;
|
|
507
|
+
if (seen.has(text)) return;
|
|
508
|
+
seen.add(text);
|
|
509
|
+
console.warn(text);
|
|
510
|
+
}
|
|
494
511
|
// src/components/SideNav/SideNav.tsx
|
|
512
|
+
const isBrand = (b) => !!b && typeof b === "object" && !React.isValidElement(b) && !Array.isArray(b) && typeof b.name === "string";
|
|
513
|
+
function NavBrandRow({ brand, collapsed }) {
|
|
514
|
+
const spec = isBrand(brand) ? brand : typeof brand === "string" ? { name: brand } : null;
|
|
515
|
+
devWarn(!spec && collapsed, "SideNav", "brand 是一個元素,收合時讀不出哪部分是 logo,只能整塊藏起來。改傳 brand={{ mark, name, href }}:收合時顯示 mark,展開時加上名稱。");
|
|
516
|
+
if (!spec) return /* @__PURE__ */ jsx("div", {
|
|
517
|
+
className: "ui-nav-brand",
|
|
518
|
+
children: collapsed ? null : brand
|
|
519
|
+
});
|
|
520
|
+
const inner = /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("span", {
|
|
521
|
+
className: "ui-nav-mark",
|
|
522
|
+
"aria-hidden": "true",
|
|
523
|
+
children: spec.mark ?? /* @__PURE__ */ jsx("span", {
|
|
524
|
+
className: "ui-nav-monogram",
|
|
525
|
+
children: Array.from(spec.name)[0]
|
|
526
|
+
})
|
|
527
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
528
|
+
className: "ui-nav-brand-name",
|
|
529
|
+
children: spec.name
|
|
530
|
+
})] });
|
|
531
|
+
const label = collapsed ? spec.name : void 0;
|
|
532
|
+
return /* @__PURE__ */ jsx("div", {
|
|
533
|
+
className: "ui-nav-brand has-mark",
|
|
534
|
+
children: spec.href ? /* @__PURE__ */ jsx("a", {
|
|
535
|
+
className: "ui-nav-brand-link",
|
|
536
|
+
href: spec.href,
|
|
537
|
+
onClick: spec.onClick,
|
|
538
|
+
"aria-label": label,
|
|
539
|
+
children: inner
|
|
540
|
+
}) : spec.onClick ? /* @__PURE__ */ jsx("button", {
|
|
541
|
+
type: "button",
|
|
542
|
+
className: "ui-nav-brand-link",
|
|
543
|
+
onClick: spec.onClick,
|
|
544
|
+
"aria-label": label,
|
|
545
|
+
children: inner
|
|
546
|
+
}) : /* @__PURE__ */ jsx("span", {
|
|
547
|
+
className: "ui-nav-brand-link",
|
|
548
|
+
"aria-label": label,
|
|
549
|
+
role: label ? "img" : void 0,
|
|
550
|
+
children: inner
|
|
551
|
+
})
|
|
552
|
+
});
|
|
553
|
+
}
|
|
495
554
|
/** The 240 px dashboard sidebar (72 px collapsed). The selection bar moves like a droplet. */
|
|
496
555
|
function SideNav({ sections, value, onChange, collapsed = false, onToggle, onPin, pinned = false, brand, label, className }) {
|
|
497
556
|
const refs = React.useRef({});
|
|
@@ -594,9 +653,9 @@ function SideNav({ sections, value, onChange, collapsed = false, onToggle, onPin
|
|
|
594
653
|
return /* @__PURE__ */ jsxs("aside", {
|
|
595
654
|
className: cx("ui-sidenav", collapsed && "is-collapsed", className),
|
|
596
655
|
children: [
|
|
597
|
-
brand ? /* @__PURE__ */ jsx(
|
|
598
|
-
|
|
599
|
-
|
|
656
|
+
brand ? /* @__PURE__ */ jsx(NavBrandRow, {
|
|
657
|
+
brand,
|
|
658
|
+
collapsed
|
|
600
659
|
}) : null,
|
|
601
660
|
/* @__PURE__ */ jsx("nav", {
|
|
602
661
|
className: "ui-nav-list",
|
|
@@ -734,22 +793,58 @@ function Tooltip({ label, side = "top", describe = true, wrap = false, disabled
|
|
|
734
793
|
}
|
|
735
794
|
// src/components/IconButton/IconButton.tsx
|
|
736
795
|
/** A square icon-only button with a tooltip. */
|
|
737
|
-
function IconButton({ label, icon, className, tooltip = true, filled, ...native }) {
|
|
738
|
-
const
|
|
796
|
+
function IconButton({ label, icon, className, tooltip = true, filled, hint, ...native }) {
|
|
797
|
+
const id = React.useId();
|
|
798
|
+
const btn = /* @__PURE__ */ jsxs("button", {
|
|
739
799
|
type: "button",
|
|
740
800
|
...native,
|
|
741
|
-
className: cx("ui-iconbtn", className),
|
|
801
|
+
className: cx("ui-iconbtn", hint && "has-hint", className),
|
|
742
802
|
"aria-label": label,
|
|
743
|
-
|
|
803
|
+
"aria-describedby": hint ? id : native["aria-describedby"],
|
|
804
|
+
children: [/* @__PURE__ */ jsx(IconOf, {
|
|
744
805
|
icon,
|
|
745
806
|
filled
|
|
746
|
-
})
|
|
807
|
+
}), hint && /* @__PURE__ */ jsx("span", {
|
|
808
|
+
className: "ui-iconbtn-dot",
|
|
809
|
+
"aria-hidden": "true"
|
|
810
|
+
})]
|
|
747
811
|
});
|
|
748
|
-
|
|
812
|
+
const button = tooltip ? /* @__PURE__ */ jsx(Tooltip, {
|
|
749
813
|
label,
|
|
750
814
|
describe: false,
|
|
751
815
|
children: btn
|
|
752
816
|
}) : btn;
|
|
817
|
+
if (!hint) return button;
|
|
818
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
819
|
+
className: "ui-iconbtn-hintbox",
|
|
820
|
+
children: [button, /* @__PURE__ */ jsxs("span", {
|
|
821
|
+
className: "ui-hint",
|
|
822
|
+
id,
|
|
823
|
+
role: "status",
|
|
824
|
+
children: [
|
|
825
|
+
/* @__PURE__ */ jsx("span", {
|
|
826
|
+
className: "ui-hint-text",
|
|
827
|
+
children: hint.text
|
|
828
|
+
}),
|
|
829
|
+
/* @__PURE__ */ jsx("button", {
|
|
830
|
+
type: "button",
|
|
831
|
+
className: "ui-hint-go",
|
|
832
|
+
onClick: hint.onAction,
|
|
833
|
+
children: hint.action ?? tr("開始")
|
|
834
|
+
}),
|
|
835
|
+
/* @__PURE__ */ jsx("button", {
|
|
836
|
+
type: "button",
|
|
837
|
+
className: "ui-hint-x",
|
|
838
|
+
"aria-label": tr("關閉提示"),
|
|
839
|
+
onClick: hint.onDismiss,
|
|
840
|
+
children: /* @__PURE__ */ jsx(Icon, {
|
|
841
|
+
name: "x",
|
|
842
|
+
size: 16
|
|
843
|
+
})
|
|
844
|
+
})
|
|
845
|
+
]
|
|
846
|
+
})]
|
|
847
|
+
});
|
|
753
848
|
}
|
|
754
849
|
// src/components/TopBar/TopBar.tsx
|
|
755
850
|
/** The bar at the top of a dashboard page: title or breadcrumb on the left, search and tools on the right. */
|
|
@@ -833,23 +928,6 @@ function MobileTabBar({ items, value, onChange, label, labels = true, className
|
|
|
833
928
|
}, t.id))]
|
|
834
929
|
});
|
|
835
930
|
}
|
|
836
|
-
// src/internal/dev.ts
|
|
837
|
-
const DEV = typeof __UI_DEV__ === "boolean" ? __UI_DEV__ : (() => {
|
|
838
|
-
try {
|
|
839
|
-
return process.env.NODE_ENV !== "production";
|
|
840
|
-
} catch {
|
|
841
|
-
return false;
|
|
842
|
-
}
|
|
843
|
-
})();
|
|
844
|
-
const seen = /* @__PURE__ */ new Set();
|
|
845
|
-
/** Logs once per message when cond is true. */
|
|
846
|
-
function devWarn(cond, component, message) {
|
|
847
|
-
if (!DEV || !cond) return;
|
|
848
|
-
const text = `[@seanyeh77/ui] ${component}: ${message}`;
|
|
849
|
-
if (seen.has(text)) return;
|
|
850
|
-
seen.add(text);
|
|
851
|
-
console.warn(text);
|
|
852
|
-
}
|
|
853
931
|
// src/components/Button/Button.tsx
|
|
854
932
|
/** Buttons. Labels are verbs; one primary per section; danger actions are always confirmed. */
|
|
855
933
|
function Button(props) {
|
|
@@ -1267,6 +1345,22 @@ const hexRgb = (x) => [
|
|
|
1267
1345
|
3,
|
|
1268
1346
|
5
|
|
1269
1347
|
].map((i) => parseInt(x.slice(i, i + 2), 16));
|
|
1348
|
+
/** A CSS color as #rrggbb: #rgb, #rgba, #rrggbb, #rrggbbaa (alpha dropped), rgb() and rgba() with commas or spaces.
|
|
1349
|
+
* null for anything else (a name, a var(), an empty value). Bundlers shorten #ffffff to #fff in tokens.css, so the
|
|
1350
|
+
* short form must read the same. */
|
|
1351
|
+
function toHex(c) {
|
|
1352
|
+
const v = c.trim().toLowerCase();
|
|
1353
|
+
const short = /^#([0-9a-f])([0-9a-f])([0-9a-f])[0-9a-f]?$/.exec(v);
|
|
1354
|
+
if (short) return "#" + short[1] + short[1] + short[2] + short[2] + short[3] + short[3];
|
|
1355
|
+
const long = /^#([0-9a-f]{6})(?:[0-9a-f]{2})?$/.exec(v);
|
|
1356
|
+
if (long) return "#" + long[1];
|
|
1357
|
+
const fn = /^rgba?\(\s*([\d.]+)[\s,]+([\d.]+)[\s,]+([\d.]+)(?:\s*[,/]\s*[\d.]+%?)?\s*\)$/.exec(v);
|
|
1358
|
+
if (fn) {
|
|
1359
|
+
const n = fn.slice(1, 4).map(Number);
|
|
1360
|
+
if (n.every((x) => x >= 0 && x <= 255)) return "#" + n.map((x) => Math.round(x).toString(16).padStart(2, "0")).join("");
|
|
1361
|
+
}
|
|
1362
|
+
return null;
|
|
1363
|
+
}
|
|
1270
1364
|
function mixHex(a, b, t) {
|
|
1271
1365
|
const p = hexRgb(a);
|
|
1272
1366
|
const q = hexRgb(b);
|
|
@@ -1292,7 +1386,10 @@ function contrast(a, b) {
|
|
|
1292
1386
|
* light, the accent mixed with black 4 % at a time, in dark with white 5 % at a time, until it reads on both. Only
|
|
1293
1387
|
* text changes: fills, bars, rings and dots keep the accent. */
|
|
1294
1388
|
function accentText(hex, dark, bg, surface) {
|
|
1295
|
-
const
|
|
1389
|
+
const b = toHex(bg);
|
|
1390
|
+
const s = toHex(surface);
|
|
1391
|
+
if (!b || !s) return hex;
|
|
1392
|
+
const reads = (c) => contrast(c, b) >= 4.5 && contrast(c, s) >= 4.5;
|
|
1296
1393
|
const toward = dark ? "#ffffff" : "#000000";
|
|
1297
1394
|
const step = dark ? .05 : .04;
|
|
1298
1395
|
let text = hex;
|
|
@@ -1307,15 +1404,15 @@ function setAccent(hex, quiet = false) {
|
|
|
1307
1404
|
const root = document.documentElement;
|
|
1308
1405
|
const dark = root.getAttribute("data-theme") === "dark";
|
|
1309
1406
|
const cs = getComputedStyle(root);
|
|
1310
|
-
const surface = (cs.getPropertyValue("--surface")
|
|
1311
|
-
const bg = (cs.getPropertyValue("--bg")
|
|
1312
|
-
const text = accentText(hex, dark, bg
|
|
1407
|
+
const surface = toHex(cs.getPropertyValue("--surface")) ?? (dark ? "#393530" : "#ffffff");
|
|
1408
|
+
const bg = toHex(cs.getPropertyValue("--bg")) ?? (dark ? "#2f2a25" : "#fcfbfb");
|
|
1409
|
+
const text = accentText(hex, dark, bg, surface);
|
|
1313
1410
|
const ink = "#171512";
|
|
1314
1411
|
const vars = {
|
|
1315
1412
|
"--accent": hex,
|
|
1316
1413
|
"--accent-hover": mixHex(hex, "#000000", .12),
|
|
1317
1414
|
"--accent-press": mixHex(hex, "#000000", .22),
|
|
1318
|
-
"--accent-soft": dark ? mixHex(bg
|
|
1415
|
+
"--accent-soft": dark ? mixHex(bg, hex, .22) : mixHex("#ffffff", hex, .12),
|
|
1319
1416
|
"--accent-text": text,
|
|
1320
1417
|
"--on-accent": contrast("#ffffff", hex) >= contrast(ink, hex) ? "#ffffff" : ink,
|
|
1321
1418
|
"--focus-ring": `rgba(${hexRgb(hex).join(", ")}, 0.3)`
|
|
@@ -2103,14 +2200,16 @@ function Checkbox({ checked, onChange, label, disabled, className, ...aria }) {
|
|
|
2103
2200
|
});
|
|
2104
2201
|
}
|
|
2105
2202
|
// src/components/InlineCode/InlineCode.tsx
|
|
2106
|
-
/** Code inside a sentence: monospace on a light gray chip. A span that points somewhere is a link
|
|
2107
|
-
|
|
2203
|
+
/** Code inside a sentence: monospace on a light gray chip. A span that points somewhere is a link; `look` turns a
|
|
2204
|
+
* link into a name or a location. */
|
|
2205
|
+
function InlineCode({ children, href, onClick, className, look = "chip" }) {
|
|
2108
2206
|
const [inline, setInline] = React.useState(false);
|
|
2109
2207
|
const link = React.useCallback((el) => {
|
|
2110
2208
|
const par = el?.parentNode;
|
|
2111
2209
|
setInline(!!par && Array.from(par.childNodes).some((n) => n.nodeType === 3 && !!n.textContent?.trim()));
|
|
2112
2210
|
}, []);
|
|
2113
|
-
const
|
|
2211
|
+
const isLink = !!(href || onClick);
|
|
2212
|
+
const cls = cx("ui-code", isLink && "is-link", isLink && inline && "is-inline", isLink && look !== "chip" && `is-${look}`, typeof children === "string" && children.length <= 24 && "is-short", className);
|
|
2114
2213
|
if (href) return /* @__PURE__ */ jsx("a", {
|
|
2115
2214
|
ref: link,
|
|
2116
2215
|
className: cls,
|
|
@@ -2144,15 +2243,23 @@ function CodeText({ text, refHref, onRef, isRef = isCodeRef, as: Tag = "span", c
|
|
|
2144
2243
|
const v = t.slice(1, -1);
|
|
2145
2244
|
const href = refHref && isRef(v) ? refHref(v) || void 0 : void 0;
|
|
2146
2245
|
if (!(isRef(v) && (refHref ? !!href : !!onRef))) return /* @__PURE__ */ jsx(InlineCode, { children: v }, i);
|
|
2147
|
-
|
|
2246
|
+
const click = onRef ? (e) => {
|
|
2247
|
+
if (href && (e.metaKey || e.ctrlKey || e.shiftKey || e.button === 1)) return;
|
|
2248
|
+
e.preventDefault();
|
|
2249
|
+
onRef(v, e);
|
|
2250
|
+
} : void 0;
|
|
2251
|
+
if (href) return /* @__PURE__ */ jsx(InlineCode, {
|
|
2252
|
+
look: "location",
|
|
2148
2253
|
href,
|
|
2149
|
-
onClick:
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2254
|
+
onClick: click,
|
|
2255
|
+
children: v
|
|
2256
|
+
}, i);
|
|
2257
|
+
if (click) return /* @__PURE__ */ jsx(InlineCode, {
|
|
2258
|
+
look: "location",
|
|
2259
|
+
onClick: click,
|
|
2154
2260
|
children: v
|
|
2155
2261
|
}, i);
|
|
2262
|
+
return /* @__PURE__ */ jsx(InlineCode, { children: v }, i);
|
|
2156
2263
|
})
|
|
2157
2264
|
});
|
|
2158
2265
|
}
|
|
@@ -5581,6 +5688,19 @@ function GraphLegend({ items = LEGEND_DEFAULT, className }) {
|
|
|
5581
5688
|
}, i))
|
|
5582
5689
|
});
|
|
5583
5690
|
}
|
|
5691
|
+
// src/components/AiMark/AiMark.tsx
|
|
5692
|
+
/** A small 「AI」 at the start of a paragraph, list item or table cell written by AI. Not a link and not a Tab stop;
|
|
5693
|
+
* screen readers say 「AI 說明:」 instead of the letters. */
|
|
5694
|
+
function AiMark({ label, className }) {
|
|
5695
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("span", {
|
|
5696
|
+
className: cx("ui-aimark", className),
|
|
5697
|
+
"aria-hidden": "true",
|
|
5698
|
+
children: "AI"
|
|
5699
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
5700
|
+
className: "ui-visually-hidden",
|
|
5701
|
+
children: (label ?? tr("AI 說明")) + tr(":")
|
|
5702
|
+
})] });
|
|
5703
|
+
}
|
|
5584
5704
|
// src/components/Markdown/Markdown.tsx
|
|
5585
5705
|
const DETAILS_OPEN = /^\s*<details\b[^>]*>/i;
|
|
5586
5706
|
const DETAILS_TAG = /<(\/?)details\b[^>]*>/gi;
|
|
@@ -5868,8 +5988,17 @@ function inline(src, c) {
|
|
|
5868
5988
|
if (ch === "[") {
|
|
5869
5989
|
const m = matchLink(src, i);
|
|
5870
5990
|
if (m) {
|
|
5991
|
+
if (m.href.trim().toLowerCase() === "ai:") {
|
|
5992
|
+
devWarn(out.length || text.trim(), "Markdown", "[AI](ai:) 在句子中間。把它移到段落、清單項目或表格格子的開頭。");
|
|
5993
|
+
flush();
|
|
5994
|
+
out.push(/* @__PURE__ */ jsx(AiMark, {}, c.k()));
|
|
5995
|
+
i = m.end;
|
|
5996
|
+
if (src[i] === " ") i++;
|
|
5997
|
+
continue;
|
|
5998
|
+
}
|
|
5871
5999
|
flush();
|
|
5872
|
-
|
|
6000
|
+
const name = /^\s*`([^`]+)`\s*$/.exec(m.text)?.[1];
|
|
6001
|
+
out.push(link(m.href, inline(m.text, c), c, name));
|
|
5873
6002
|
i = m.end;
|
|
5874
6003
|
continue;
|
|
5875
6004
|
}
|
|
@@ -5899,13 +6028,20 @@ function inline(src, c) {
|
|
|
5899
6028
|
const onRef = ctx.onRef;
|
|
5900
6029
|
if (isPath(v)) {
|
|
5901
6030
|
const href = ctx.refHref?.(v) || void 0;
|
|
5902
|
-
|
|
6031
|
+
const click = onRef ? (e) => {
|
|
6032
|
+
if (href && (e.metaKey || e.ctrlKey || e.shiftKey || e.button === 1)) return;
|
|
6033
|
+
e.preventDefault();
|
|
6034
|
+
onRef(v, e);
|
|
6035
|
+
} : void 0;
|
|
6036
|
+
if (href) return /* @__PURE__ */ jsx(InlineCode, {
|
|
6037
|
+
look: "location",
|
|
5903
6038
|
href,
|
|
5904
|
-
onClick:
|
|
5905
|
-
|
|
5906
|
-
|
|
5907
|
-
|
|
5908
|
-
|
|
6039
|
+
onClick: click,
|
|
6040
|
+
children: v
|
|
6041
|
+
}, ctx.k());
|
|
6042
|
+
if (click) return /* @__PURE__ */ jsx(InlineCode, {
|
|
6043
|
+
look: "location",
|
|
6044
|
+
onClick: click,
|
|
5909
6045
|
children: v
|
|
5910
6046
|
}, ctx.k());
|
|
5911
6047
|
}
|
|
@@ -5956,7 +6092,7 @@ function findClose(src, from, run) {
|
|
|
5956
6092
|
}
|
|
5957
6093
|
return -1;
|
|
5958
6094
|
}
|
|
5959
|
-
function link(raw, children, c) {
|
|
6095
|
+
function link(raw, children, c, name) {
|
|
5960
6096
|
const scheme = /^([a-z][a-z0-9+.-]*):/i.exec(raw.trim())?.[1].toLowerCase();
|
|
5961
6097
|
const own = !!scheme && !BLOCKED.includes(scheme) && !!c.schemes?.some((x) => x.toLowerCase() === scheme);
|
|
5962
6098
|
const safe = own ? raw.trim() : safeHref(raw);
|
|
@@ -5970,6 +6106,19 @@ function link(raw, children, c) {
|
|
|
5970
6106
|
e.preventDefault();
|
|
5971
6107
|
onLink(safe, e);
|
|
5972
6108
|
} : void 0;
|
|
6109
|
+
if (name !== void 0 && !(outside && !c.onLink)) {
|
|
6110
|
+
if (href) return /* @__PURE__ */ jsx(InlineCode, {
|
|
6111
|
+
look: "name",
|
|
6112
|
+
href,
|
|
6113
|
+
onClick: click,
|
|
6114
|
+
children: name
|
|
6115
|
+
}, c.k());
|
|
6116
|
+
if (click) return /* @__PURE__ */ jsx(InlineCode, {
|
|
6117
|
+
look: "name",
|
|
6118
|
+
onClick: click,
|
|
6119
|
+
children: name
|
|
6120
|
+
}, c.k());
|
|
6121
|
+
}
|
|
5973
6122
|
if (!href) return /* @__PURE__ */ jsx("button", {
|
|
5974
6123
|
type: "button",
|
|
5975
6124
|
className: "ui-md-link",
|
|
@@ -9195,17 +9344,40 @@ function ThemePicker({ value, onChange, label, className }) {
|
|
|
9195
9344
|
}
|
|
9196
9345
|
// src/components/Tour/Tour.tsx
|
|
9197
9346
|
const TOUR_KEY = "ui-tour:";
|
|
9198
|
-
/** Opens the tour once per browser: { open, start, close, seen }. Pass close to Tour's onClose; start() shows
|
|
9347
|
+
/** Opens the tour once per browser: { open, start, close, seen, hint }. Pass close to Tour's onClose; start() shows
|
|
9348
|
+
* it again. hint(text) gives IconButton's `hint` for the button that starts the tour: a page that uses it shows the dot
|
|
9349
|
+
* and the bubble instead of opening the tour by itself. 「開始」 starts the tour; × and finishing it hide the hint for
|
|
9350
|
+
* good (the same record as seen). */
|
|
9199
9351
|
function useTour(key) {
|
|
9200
|
-
const [
|
|
9352
|
+
const [seen, setSeen] = React.useState(() => !!store(TOUR_KEY + key));
|
|
9353
|
+
const [open, setOpen] = React.useState(false);
|
|
9354
|
+
const hinted = React.useRef(false);
|
|
9355
|
+
React.useLayoutEffect(() => {
|
|
9356
|
+
if (!store(TOUR_KEY + key) && !hinted.current) setOpen(true);
|
|
9357
|
+
}, [key]);
|
|
9358
|
+
const remember = () => {
|
|
9359
|
+
store(TOUR_KEY + key, "1");
|
|
9360
|
+
setSeen(true);
|
|
9361
|
+
};
|
|
9201
9362
|
return {
|
|
9202
9363
|
open,
|
|
9203
9364
|
start: () => setOpen(true),
|
|
9204
9365
|
close: () => {
|
|
9205
|
-
|
|
9366
|
+
remember();
|
|
9206
9367
|
setOpen(false);
|
|
9207
9368
|
},
|
|
9208
|
-
seen
|
|
9369
|
+
seen,
|
|
9370
|
+
/** IconButton's `hint` for the button that starts this tour, or undefined once seen or while the tour is open. */
|
|
9371
|
+
hint: (text, action) => {
|
|
9372
|
+
hinted.current = true;
|
|
9373
|
+
if (seen || open) return void 0;
|
|
9374
|
+
return {
|
|
9375
|
+
text,
|
|
9376
|
+
action,
|
|
9377
|
+
onAction: () => setOpen(true),
|
|
9378
|
+
onDismiss: remember
|
|
9379
|
+
};
|
|
9380
|
+
}
|
|
9209
9381
|
};
|
|
9210
9382
|
}
|
|
9211
9383
|
function findTarget(t) {
|
|
@@ -10256,6 +10428,6 @@ function TreeList(p) {
|
|
|
10256
10428
|
})]
|
|
10257
10429
|
});
|
|
10258
10430
|
}
|
|
10259
|
-
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, 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, addMessages, announce, focusMain, format, icons, initTheme, isCodeRef, safeHref, setAccent, setLocale, setTheme, tr as t, useTour };
|
|
10431
|
+
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, addMessages, announce, focusMain, format, icons, initTheme, isCodeRef, safeHref, setAccent, setLocale, setTheme, tr as t, useTour };
|
|
10260
10432
|
|
|
10261
10433
|
//# sourceMappingURL=index.js.map
|