@seanyeh77/ui 0.25.0 → 0.27.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 +14 -14
- package/dist/bundle.js.map +1 -1
- package/dist/{format-entry-CwOAT4YT.js → format-entry-BXwnh9f-.js} +5 -1
- package/dist/format-entry-BXwnh9f-.js.map +1 -0
- package/dist/format.js +1 -1
- package/dist/index.d.ts +63 -10
- package/dist/index.js +257 -50
- package/dist/index.js.map +1 -1
- package/dist/styles.css +198 -0
- package/docs/AiMark.md +20 -0
- package/docs/AppShell.md +5 -1
- package/docs/IconButton.md +18 -0
- package/docs/InlineCode.md +23 -1
- package/docs/Markdown.md +23 -0
- package/docs/SideNav.md +1 -0
- package/docs/Tour.md +1 -0
- package/docs/guidelines.md +5 -2
- package/docs/layout.md +2 -2
- package/package.json +2 -2
- package/dist/format-entry-CwOAT4YT.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";
|
|
@@ -107,7 +107,8 @@ const PH = {
|
|
|
107
107
|
command: "<path d=\"M180,144H160V112h20a36,36,0,1,0-36-36V96H112V76a36,36,0,1,0-36,36H96v32H76a36,36,0,1,0,36,36V160h32v20a36,36,0,1,0,36-36ZM160,76a20,20,0,1,1,20,20H160ZM56,76a20,20,0,0,1,40,0V96H76A20,20,0,0,1,56,76ZM96,180a20,20,0,1,1-20-20H96Zm16-68h32v32H112Zm68,88a20,20,0,0,1-20-20V160h20a20,20,0,0,1,0,40Z\"/>",
|
|
108
108
|
tag: "<path d=\"M243.31,136,144,36.69A15.86,15.86,0,0,0,132.69,32H40a8,8,0,0,0-8,8v92.69A15.86,15.86,0,0,0,36.69,144L136,243.31a16,16,0,0,0,22.63,0l84.68-84.68a16,16,0,0,0,0-22.63Zm-96,96L48,132.69V48h84.69L232,147.31ZM96,84A12,12,0,1,1,84,72,12,12,0,0,1,96,84Z\"/>",
|
|
109
109
|
"sort-ascending": "<path d=\"M128,128a8,8,0,0,1-8,8H48a8,8,0,0,1,0-16h72A8,8,0,0,1,128,128ZM48,72H184a8,8,0,0,0,0-16H48a8,8,0,0,0,0,16Zm56,112H48a8,8,0,0,0,0,16h56a8,8,0,0,0,0-16Zm125.66-21.66a8,8,0,0,0-11.32,0L192,188.69V112a8,8,0,0,0-16,0v76.69l-26.34-26.35a8,8,0,0,0-11.32,11.32l40,40a8,8,0,0,0,11.32,0l40-40A8,8,0,0,0,229.66,162.34Z\"/>",
|
|
110
|
-
"dots-six-vertical": "<path d=\"M104,60A12,12,0,1,1,92,48,12,12,0,0,1,104,60Zm60,12a12,12,0,1,0-12-12A12,12,0,0,0,164,72ZM92,116a12,12,0,1,0,12,12A12,12,0,0,0,92,116Zm72,0a12,12,0,1,0,12,12A12,12,0,0,0,164,116ZM92,184a12,12,0,1,0,12,12A12,12,0,0,0,92,184Zm72,0a12,12,0,1,0,12,12A12,12,0,0,0,164,184Z\"/>"
|
|
110
|
+
"dots-six-vertical": "<path d=\"M104,60A12,12,0,1,1,92,48,12,12,0,0,1,104,60Zm60,12a12,12,0,1,0-12-12A12,12,0,0,0,164,72ZM92,116a12,12,0,1,0,12,12A12,12,0,0,0,92,116Zm72,0a12,12,0,1,0,12,12A12,12,0,0,0,164,116ZM92,184a12,12,0,1,0,12,12A12,12,0,0,0,92,184Zm72,0a12,12,0,1,0,12,12A12,12,0,0,0,164,184Z\"/>",
|
|
111
|
+
"push-pin": "<path d=\"M235.32,81.37,174.63,20.69a16,16,0,0,0-22.63,0L98.37,74.49c-10.66-3.34-35-7.37-60.4,13.14a16,16,0,0,0-1.29,23.78L85,159.71,42.34,202.34a8,8,0,0,0,11.32,11.32L96.29,171l48.29,48.29A16,16,0,0,0,155.9,224c.38,0,.75,0,1.13,0a15.93,15.93,0,0,0,11.64-6.33c19.64-26.1,17.75-47.32,13.19-60L235.33,104A16,16,0,0,0,235.32,81.37ZM224,92.69h0l-57.27,57.46a8,8,0,0,0-1.49,9.22c9.46,18.93-1.8,38.59-9.34,48.62L48,100.08c12.08-9.74,23.64-12.31,32.48-12.31A40.13,40.13,0,0,1,96.81,91a8,8,0,0,0,9.25-1.51L163.32,32,224,92.68Z\"/>"
|
|
111
112
|
};
|
|
112
113
|
const PH_FILL = {
|
|
113
114
|
archive: "<path d=\"M224,48H32A16,16,0,0,0,16,64V88a16,16,0,0,0,16,16v88a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V104a16,16,0,0,0,16-16V64A16,16,0,0,0,224,48Zm-72,96H104a8,8,0,0,1,0-16h48a8,8,0,0,1,0,16Zm72-56H32V64H224V88Z\"/>",
|
|
@@ -205,7 +206,8 @@ const PH_FILL = {
|
|
|
205
206
|
command: "<path d=\"M116,116h24v24H116ZM86,72a14,14,0,0,0,0,28h14V86A14,14,0,0,0,86,72Zm98,14a14,14,0,0,0-28,0v14h14A14,14,0,0,0,184,86ZM72,170a14,14,0,0,0,28,0V156H86A14,14,0,0,0,72,170ZM224,48V208a16,16,0,0,1-16,16H48a16,16,0,0,1-16-16V48A16,16,0,0,1,48,32H208A16,16,0,0,1,224,48Zm-68,92V116h14a30,30,0,1,0-30-30v14H116V86a30,30,0,1,0-30,30h14v24H86a30,30,0,1,0,30,30V156h24v14a30,30,0,1,0,30-30Zm0,30a14,14,0,1,0,14-14H156Z\"/>",
|
|
206
207
|
tag: "<path d=\"M243.31,136,144,36.69A15.86,15.86,0,0,0,132.69,32H40a8,8,0,0,0-8,8v92.69A15.86,15.86,0,0,0,36.69,144L136,243.31a16,16,0,0,0,22.63,0l84.68-84.68a16,16,0,0,0,0-22.63ZM84,96A12,12,0,1,1,96,84,12,12,0,0,1,84,96Z\"/>",
|
|
207
208
|
"sort-ascending": "<path d=\"M208,32H48A16,16,0,0,0,32,48V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V48A16,16,0,0,0,208,32ZM72,72h96a8,8,0,0,1,0,16H72a8,8,0,0,1,0-16Zm40,112H72a8,8,0,0,1,0-16h40a8,8,0,0,1,0,16Zm8-48H72a8,8,0,0,1,0-16h48a8,8,0,0,1,0,16Zm77.66,29.66-24,24a8,8,0,0,1-11.32,0l-24-24a8,8,0,0,1,11.32-11.32L160,164.69V120a8,8,0,0,1,16,0v44.69l10.34-10.35a8,8,0,0,1,11.32,11.32Z\"/>",
|
|
208
|
-
"dots-six-vertical": "<path d=\"M192,16H64A16,16,0,0,0,48,32V224a16,16,0,0,0,16,16H192a16,16,0,0,0,16-16V32A16,16,0,0,0,192,16ZM100,200a12,12,0,1,1,12-12A12,12,0,0,1,100,200Zm0-60a12,12,0,1,1,12-12A12,12,0,0,1,100,140Zm0-60a12,12,0,1,1,12-12A12,12,0,0,1,100,80Zm56,120a12,12,0,1,1,12-12A12,12,0,0,1,156,200Zm0-60a12,12,0,1,1,12-12A12,12,0,0,1,156,140Zm0-60a12,12,0,1,1,12-12A12,12,0,0,1,156,80Z\"/>"
|
|
209
|
+
"dots-six-vertical": "<path d=\"M192,16H64A16,16,0,0,0,48,32V224a16,16,0,0,0,16,16H192a16,16,0,0,0,16-16V32A16,16,0,0,0,192,16ZM100,200a12,12,0,1,1,12-12A12,12,0,0,1,100,200Zm0-60a12,12,0,1,1,12-12A12,12,0,0,1,100,140Zm0-60a12,12,0,1,1,12-12A12,12,0,0,1,100,80Zm56,120a12,12,0,1,1,12-12A12,12,0,0,1,156,200Zm0-60a12,12,0,1,1,12-12A12,12,0,0,1,156,140Zm0-60a12,12,0,1,1,12-12A12,12,0,0,1,156,80Z\"/>",
|
|
210
|
+
"push-pin": "<path d=\"M235.33,104l-53.47,53.65c4.56,12.67,6.45,33.89-13.19,60A15.93,15.93,0,0,1,157,224c-.38,0-.75,0-1.13,0a16,16,0,0,1-11.32-4.69L96.29,171,53.66,213.66a8,8,0,0,1-11.32-11.32L85,159.71l-48.3-48.3A16,16,0,0,1,38,87.63c25.42-20.51,49.75-16.48,60.4-13.14L152,20.7a16,16,0,0,1,22.63,0l60.69,60.68A16,16,0,0,1,235.33,104Z\"/>"
|
|
209
211
|
};
|
|
210
212
|
/** Lucide names that map to a Phosphor icon. */
|
|
211
213
|
const PH_ALIAS = {
|
|
@@ -491,7 +493,7 @@ function announce(text) {
|
|
|
491
493
|
}
|
|
492
494
|
// src/components/SideNav/SideNav.tsx
|
|
493
495
|
/** The 240 px dashboard sidebar (72 px collapsed). The selection bar moves like a droplet. */
|
|
494
|
-
function SideNav({ sections, value, onChange, collapsed = false, onToggle, brand, label, className }) {
|
|
496
|
+
function SideNav({ sections, value, onChange, collapsed = false, onToggle, onPin, pinned = false, brand, label, className }) {
|
|
495
497
|
const refs = React.useRef({});
|
|
496
498
|
const wrap = React.useRef(null);
|
|
497
499
|
const [bar, setBar] = React.useState({
|
|
@@ -617,16 +619,31 @@ function SideNav({ sections, value, onChange, collapsed = false, onToggle, brand
|
|
|
617
619
|
}) : null, sec.items.flatMap((it) => row(it, false))] }, i))]
|
|
618
620
|
})
|
|
619
621
|
}),
|
|
620
|
-
onToggle ? /* @__PURE__ */
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
622
|
+
onToggle || onPin ? /* @__PURE__ */ jsxs("div", {
|
|
623
|
+
className: "ui-nav-foot",
|
|
624
|
+
children: [onPin ? /* @__PURE__ */ jsx("button", {
|
|
625
|
+
type: "button",
|
|
626
|
+
className: cx("ui-nav-collapse", "ui-nav-pin", pinned && "is-on"),
|
|
627
|
+
"aria-pressed": pinned,
|
|
628
|
+
"aria-label": pinned ? tr("取消釘選") : tr("釘選側邊欄"),
|
|
629
|
+
title: pinned ? tr("取消釘選") : tr("釘選側邊欄"),
|
|
630
|
+
onClick: onPin,
|
|
631
|
+
children: /* @__PURE__ */ jsx(Icon, {
|
|
632
|
+
name: "push-pin",
|
|
633
|
+
size: 20,
|
|
634
|
+
filled: pinned
|
|
635
|
+
})
|
|
636
|
+
}) : null, onToggle ? /* @__PURE__ */ jsx("button", {
|
|
637
|
+
type: "button",
|
|
638
|
+
className: "ui-nav-collapse",
|
|
639
|
+
"aria-label": toggleLabel,
|
|
640
|
+
title: toggleLabel,
|
|
641
|
+
onClick: onToggle,
|
|
642
|
+
children: /* @__PURE__ */ jsx(Icon, {
|
|
643
|
+
name: "sidebar-simple",
|
|
644
|
+
size: 20
|
|
645
|
+
})
|
|
646
|
+
}) : null]
|
|
630
647
|
}) : null
|
|
631
648
|
]
|
|
632
649
|
});
|
|
@@ -717,22 +734,58 @@ function Tooltip({ label, side = "top", describe = true, wrap = false, disabled
|
|
|
717
734
|
}
|
|
718
735
|
// src/components/IconButton/IconButton.tsx
|
|
719
736
|
/** A square icon-only button with a tooltip. */
|
|
720
|
-
function IconButton({ label, icon, className, tooltip = true, filled, ...native }) {
|
|
721
|
-
const
|
|
737
|
+
function IconButton({ label, icon, className, tooltip = true, filled, hint, ...native }) {
|
|
738
|
+
const id = React.useId();
|
|
739
|
+
const btn = /* @__PURE__ */ jsxs("button", {
|
|
722
740
|
type: "button",
|
|
723
741
|
...native,
|
|
724
|
-
className: cx("ui-iconbtn", className),
|
|
742
|
+
className: cx("ui-iconbtn", hint && "has-hint", className),
|
|
725
743
|
"aria-label": label,
|
|
726
|
-
|
|
744
|
+
"aria-describedby": hint ? id : native["aria-describedby"],
|
|
745
|
+
children: [/* @__PURE__ */ jsx(IconOf, {
|
|
727
746
|
icon,
|
|
728
747
|
filled
|
|
729
|
-
})
|
|
748
|
+
}), hint && /* @__PURE__ */ jsx("span", {
|
|
749
|
+
className: "ui-iconbtn-dot",
|
|
750
|
+
"aria-hidden": "true"
|
|
751
|
+
})]
|
|
730
752
|
});
|
|
731
|
-
|
|
753
|
+
const button = tooltip ? /* @__PURE__ */ jsx(Tooltip, {
|
|
732
754
|
label,
|
|
733
755
|
describe: false,
|
|
734
756
|
children: btn
|
|
735
757
|
}) : btn;
|
|
758
|
+
if (!hint) return button;
|
|
759
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
760
|
+
className: "ui-iconbtn-hintbox",
|
|
761
|
+
children: [button, /* @__PURE__ */ jsxs("span", {
|
|
762
|
+
className: "ui-hint",
|
|
763
|
+
id,
|
|
764
|
+
role: "status",
|
|
765
|
+
children: [
|
|
766
|
+
/* @__PURE__ */ jsx("span", {
|
|
767
|
+
className: "ui-hint-text",
|
|
768
|
+
children: hint.text
|
|
769
|
+
}),
|
|
770
|
+
/* @__PURE__ */ jsx("button", {
|
|
771
|
+
type: "button",
|
|
772
|
+
className: "ui-hint-go",
|
|
773
|
+
onClick: hint.onAction,
|
|
774
|
+
children: hint.action ?? tr("開始")
|
|
775
|
+
}),
|
|
776
|
+
/* @__PURE__ */ jsx("button", {
|
|
777
|
+
type: "button",
|
|
778
|
+
className: "ui-hint-x",
|
|
779
|
+
"aria-label": tr("關閉提示"),
|
|
780
|
+
onClick: hint.onDismiss,
|
|
781
|
+
children: /* @__PURE__ */ jsx(Icon, {
|
|
782
|
+
name: "x",
|
|
783
|
+
size: 16
|
|
784
|
+
})
|
|
785
|
+
})
|
|
786
|
+
]
|
|
787
|
+
})]
|
|
788
|
+
});
|
|
736
789
|
}
|
|
737
790
|
// src/components/TopBar/TopBar.tsx
|
|
738
791
|
/** The bar at the top of a dashboard page: title or breadcrumb on the left, search and tools on the right. */
|
|
@@ -1025,15 +1078,43 @@ function focusMain() {
|
|
|
1025
1078
|
}
|
|
1026
1079
|
// src/components/AppShell/AppShell.tsx
|
|
1027
1080
|
const COLLAPSE_KEY = "ui-nav-collapsed";
|
|
1081
|
+
const PIN_KEY = "ui-nav-pinned";
|
|
1082
|
+
/** Pointer on the strip this long before it opens (passing over it on the way to the browser's edge does not). */
|
|
1083
|
+
const OPEN_DELAY = 100;
|
|
1084
|
+
/** Pointer away this long before it hides again (a slip off the edge does not). */
|
|
1085
|
+
const CLOSE_DELAY = 300;
|
|
1028
1086
|
const MORE = "\0more";
|
|
1029
1087
|
/** The dashboard frame: sidebar (240 px, 72 px collapsed) above 1024 px, a drawer from the top bar's menu button from
|
|
1030
1088
|
* 600 to 1024 px, and bottom tabs on phones.
|
|
1031
1089
|
* The top bar hides while scrolling down and returns when scrolling up. */
|
|
1032
|
-
function AppShell({ nav, value, onNavigate, brand, title, breadcrumb, onSearch, actions, children, tabLabels, className }) {
|
|
1090
|
+
function AppShell({ nav, value, onNavigate, brand, title, breadcrumb, onSearch, actions, children, tabLabels, defaultPinned = false, className }) {
|
|
1033
1091
|
const phone = useNarrow();
|
|
1034
1092
|
const tablet = useMedia("(min-width: 600px) and (max-width: 1024px)");
|
|
1035
1093
|
const [userCollapsed, setUserCollapsed] = React.useState(() => store(COLLAPSE_KEY) === "1");
|
|
1036
|
-
const
|
|
1094
|
+
const [pinned, setPinned] = React.useState(() => {
|
|
1095
|
+
const v = store(PIN_KEY);
|
|
1096
|
+
if (v != null) return v === "1";
|
|
1097
|
+
return store(COLLAPSE_KEY) != null || defaultPinned;
|
|
1098
|
+
});
|
|
1099
|
+
const [open, setOpen] = React.useState(false);
|
|
1100
|
+
const openTimer = React.useRef(void 0);
|
|
1101
|
+
const closeTimer = React.useRef(void 0);
|
|
1102
|
+
const later = (show) => {
|
|
1103
|
+
clearTimeout(openTimer.current);
|
|
1104
|
+
clearTimeout(closeTimer.current);
|
|
1105
|
+
if (show) openTimer.current = setTimeout(() => setOpen(true), OPEN_DELAY);
|
|
1106
|
+
else closeTimer.current = setTimeout(() => setOpen(false), CLOSE_DELAY);
|
|
1107
|
+
};
|
|
1108
|
+
React.useEffect(() => () => {
|
|
1109
|
+
clearTimeout(openTimer.current);
|
|
1110
|
+
clearTimeout(closeTimer.current);
|
|
1111
|
+
}, []);
|
|
1112
|
+
const collapsed = pinned ? userCollapsed : !open;
|
|
1113
|
+
const togglePin = () => {
|
|
1114
|
+
store(PIN_KEY, pinned ? "0" : "1");
|
|
1115
|
+
setPinned(!pinned);
|
|
1116
|
+
setOpen(false);
|
|
1117
|
+
};
|
|
1037
1118
|
const top = nav.flatMap((s) => s.items);
|
|
1038
1119
|
const parentOf = (id) => top.find((it) => it.children?.some((c) => c.id === id));
|
|
1039
1120
|
const withIcon = top.filter((it) => !!it.icon);
|
|
@@ -1088,16 +1169,48 @@ function AppShell({ nav, value, onNavigate, brand, title, breadcrumb, onSearch,
|
|
|
1088
1169
|
},
|
|
1089
1170
|
children: tr("跳到主要內容")
|
|
1090
1171
|
}),
|
|
1091
|
-
phone || tablet ? null : /* @__PURE__ */ jsx(SideNav, {
|
|
1172
|
+
phone || tablet ? null : pinned ? /* @__PURE__ */ jsx(SideNav, {
|
|
1092
1173
|
sections: nav,
|
|
1093
1174
|
value,
|
|
1094
1175
|
onChange: onNavigate,
|
|
1095
1176
|
brand,
|
|
1096
1177
|
collapsed,
|
|
1178
|
+
pinned: true,
|
|
1179
|
+
onPin: togglePin,
|
|
1097
1180
|
onToggle: () => {
|
|
1098
1181
|
store(COLLAPSE_KEY, userCollapsed ? "0" : "1");
|
|
1099
1182
|
setUserCollapsed(!userCollapsed);
|
|
1100
1183
|
}
|
|
1184
|
+
}) : /* @__PURE__ */ jsx("div", {
|
|
1185
|
+
className: cx("ui-shell-rail", open && "is-open"),
|
|
1186
|
+
onPointerEnter: (e) => e.pointerType === "mouse" && later(true),
|
|
1187
|
+
onPointerLeave: (e) => e.pointerType === "mouse" && later(false),
|
|
1188
|
+
onFocus: (e) => {
|
|
1189
|
+
if (!e.target.matches(":focus-visible")) return;
|
|
1190
|
+
clearTimeout(closeTimer.current);
|
|
1191
|
+
setOpen(true);
|
|
1192
|
+
},
|
|
1193
|
+
onBlur: (e) => {
|
|
1194
|
+
if (!e.currentTarget.contains(e.relatedTarget)) setOpen(false);
|
|
1195
|
+
},
|
|
1196
|
+
onKeyDown: (e) => {
|
|
1197
|
+
if (e.key === "Escape" && open) {
|
|
1198
|
+
e.stopPropagation();
|
|
1199
|
+
setOpen(false);
|
|
1200
|
+
}
|
|
1201
|
+
},
|
|
1202
|
+
children: /* @__PURE__ */ jsx(SideNav, {
|
|
1203
|
+
sections: nav,
|
|
1204
|
+
value,
|
|
1205
|
+
onChange: (id) => {
|
|
1206
|
+
clearTimeout(openTimer.current);
|
|
1207
|
+
setOpen(false);
|
|
1208
|
+
onNavigate(id);
|
|
1209
|
+
},
|
|
1210
|
+
brand,
|
|
1211
|
+
collapsed,
|
|
1212
|
+
onPin: togglePin
|
|
1213
|
+
})
|
|
1101
1214
|
}),
|
|
1102
1215
|
/* @__PURE__ */ jsxs("div", {
|
|
1103
1216
|
className: "ui-shell-body",
|
|
@@ -1190,6 +1303,22 @@ const hexRgb = (x) => [
|
|
|
1190
1303
|
3,
|
|
1191
1304
|
5
|
|
1192
1305
|
].map((i) => parseInt(x.slice(i, i + 2), 16));
|
|
1306
|
+
/** A CSS color as #rrggbb: #rgb, #rgba, #rrggbb, #rrggbbaa (alpha dropped), rgb() and rgba() with commas or spaces.
|
|
1307
|
+
* null for anything else (a name, a var(), an empty value). Bundlers shorten #ffffff to #fff in tokens.css, so the
|
|
1308
|
+
* short form must read the same. */
|
|
1309
|
+
function toHex(c) {
|
|
1310
|
+
const v = c.trim().toLowerCase();
|
|
1311
|
+
const short = /^#([0-9a-f])([0-9a-f])([0-9a-f])[0-9a-f]?$/.exec(v);
|
|
1312
|
+
if (short) return "#" + short[1] + short[1] + short[2] + short[2] + short[3] + short[3];
|
|
1313
|
+
const long = /^#([0-9a-f]{6})(?:[0-9a-f]{2})?$/.exec(v);
|
|
1314
|
+
if (long) return "#" + long[1];
|
|
1315
|
+
const fn = /^rgba?\(\s*([\d.]+)[\s,]+([\d.]+)[\s,]+([\d.]+)(?:\s*[,/]\s*[\d.]+%?)?\s*\)$/.exec(v);
|
|
1316
|
+
if (fn) {
|
|
1317
|
+
const n = fn.slice(1, 4).map(Number);
|
|
1318
|
+
if (n.every((x) => x >= 0 && x <= 255)) return "#" + n.map((x) => Math.round(x).toString(16).padStart(2, "0")).join("");
|
|
1319
|
+
}
|
|
1320
|
+
return null;
|
|
1321
|
+
}
|
|
1193
1322
|
function mixHex(a, b, t) {
|
|
1194
1323
|
const p = hexRgb(a);
|
|
1195
1324
|
const q = hexRgb(b);
|
|
@@ -1215,7 +1344,10 @@ function contrast(a, b) {
|
|
|
1215
1344
|
* light, the accent mixed with black 4 % at a time, in dark with white 5 % at a time, until it reads on both. Only
|
|
1216
1345
|
* text changes: fills, bars, rings and dots keep the accent. */
|
|
1217
1346
|
function accentText(hex, dark, bg, surface) {
|
|
1218
|
-
const
|
|
1347
|
+
const b = toHex(bg);
|
|
1348
|
+
const s = toHex(surface);
|
|
1349
|
+
if (!b || !s) return hex;
|
|
1350
|
+
const reads = (c) => contrast(c, b) >= 4.5 && contrast(c, s) >= 4.5;
|
|
1219
1351
|
const toward = dark ? "#ffffff" : "#000000";
|
|
1220
1352
|
const step = dark ? .05 : .04;
|
|
1221
1353
|
let text = hex;
|
|
@@ -1230,15 +1362,15 @@ function setAccent(hex, quiet = false) {
|
|
|
1230
1362
|
const root = document.documentElement;
|
|
1231
1363
|
const dark = root.getAttribute("data-theme") === "dark";
|
|
1232
1364
|
const cs = getComputedStyle(root);
|
|
1233
|
-
const surface = (cs.getPropertyValue("--surface")
|
|
1234
|
-
const bg = (cs.getPropertyValue("--bg")
|
|
1235
|
-
const text = accentText(hex, dark, bg
|
|
1365
|
+
const surface = toHex(cs.getPropertyValue("--surface")) ?? (dark ? "#393530" : "#ffffff");
|
|
1366
|
+
const bg = toHex(cs.getPropertyValue("--bg")) ?? (dark ? "#2f2a25" : "#fcfbfb");
|
|
1367
|
+
const text = accentText(hex, dark, bg, surface);
|
|
1236
1368
|
const ink = "#171512";
|
|
1237
1369
|
const vars = {
|
|
1238
1370
|
"--accent": hex,
|
|
1239
1371
|
"--accent-hover": mixHex(hex, "#000000", .12),
|
|
1240
1372
|
"--accent-press": mixHex(hex, "#000000", .22),
|
|
1241
|
-
"--accent-soft": dark ? mixHex(bg
|
|
1373
|
+
"--accent-soft": dark ? mixHex(bg, hex, .22) : mixHex("#ffffff", hex, .12),
|
|
1242
1374
|
"--accent-text": text,
|
|
1243
1375
|
"--on-accent": contrast("#ffffff", hex) >= contrast(ink, hex) ? "#ffffff" : ink,
|
|
1244
1376
|
"--focus-ring": `rgba(${hexRgb(hex).join(", ")}, 0.3)`
|
|
@@ -2026,14 +2158,16 @@ function Checkbox({ checked, onChange, label, disabled, className, ...aria }) {
|
|
|
2026
2158
|
});
|
|
2027
2159
|
}
|
|
2028
2160
|
// src/components/InlineCode/InlineCode.tsx
|
|
2029
|
-
/** Code inside a sentence: monospace on a light gray chip. A span that points somewhere is a link
|
|
2030
|
-
|
|
2161
|
+
/** Code inside a sentence: monospace on a light gray chip. A span that points somewhere is a link; `look` turns a
|
|
2162
|
+
* link into a name or a location. */
|
|
2163
|
+
function InlineCode({ children, href, onClick, className, look = "chip" }) {
|
|
2031
2164
|
const [inline, setInline] = React.useState(false);
|
|
2032
2165
|
const link = React.useCallback((el) => {
|
|
2033
2166
|
const par = el?.parentNode;
|
|
2034
2167
|
setInline(!!par && Array.from(par.childNodes).some((n) => n.nodeType === 3 && !!n.textContent?.trim()));
|
|
2035
2168
|
}, []);
|
|
2036
|
-
const
|
|
2169
|
+
const isLink = !!(href || onClick);
|
|
2170
|
+
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);
|
|
2037
2171
|
if (href) return /* @__PURE__ */ jsx("a", {
|
|
2038
2172
|
ref: link,
|
|
2039
2173
|
className: cls,
|
|
@@ -2067,15 +2201,23 @@ function CodeText({ text, refHref, onRef, isRef = isCodeRef, as: Tag = "span", c
|
|
|
2067
2201
|
const v = t.slice(1, -1);
|
|
2068
2202
|
const href = refHref && isRef(v) ? refHref(v) || void 0 : void 0;
|
|
2069
2203
|
if (!(isRef(v) && (refHref ? !!href : !!onRef))) return /* @__PURE__ */ jsx(InlineCode, { children: v }, i);
|
|
2070
|
-
|
|
2204
|
+
const click = onRef ? (e) => {
|
|
2205
|
+
if (href && (e.metaKey || e.ctrlKey || e.shiftKey || e.button === 1)) return;
|
|
2206
|
+
e.preventDefault();
|
|
2207
|
+
onRef(v, e);
|
|
2208
|
+
} : void 0;
|
|
2209
|
+
if (href) return /* @__PURE__ */ jsx(InlineCode, {
|
|
2210
|
+
look: "location",
|
|
2071
2211
|
href,
|
|
2072
|
-
onClick:
|
|
2073
|
-
if (href && (e.metaKey || e.ctrlKey || e.shiftKey || e.button === 1)) return;
|
|
2074
|
-
e.preventDefault();
|
|
2075
|
-
onRef(v, e);
|
|
2076
|
-
} : void 0,
|
|
2212
|
+
onClick: click,
|
|
2077
2213
|
children: v
|
|
2078
2214
|
}, i);
|
|
2215
|
+
if (click) return /* @__PURE__ */ jsx(InlineCode, {
|
|
2216
|
+
look: "location",
|
|
2217
|
+
onClick: click,
|
|
2218
|
+
children: v
|
|
2219
|
+
}, i);
|
|
2220
|
+
return /* @__PURE__ */ jsx(InlineCode, { children: v }, i);
|
|
2079
2221
|
})
|
|
2080
2222
|
});
|
|
2081
2223
|
}
|
|
@@ -5504,6 +5646,19 @@ function GraphLegend({ items = LEGEND_DEFAULT, className }) {
|
|
|
5504
5646
|
}, i))
|
|
5505
5647
|
});
|
|
5506
5648
|
}
|
|
5649
|
+
// src/components/AiMark/AiMark.tsx
|
|
5650
|
+
/** 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;
|
|
5651
|
+
* screen readers say 「AI 說明:」 instead of the letters. */
|
|
5652
|
+
function AiMark({ label, className }) {
|
|
5653
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("span", {
|
|
5654
|
+
className: cx("ui-aimark", className),
|
|
5655
|
+
"aria-hidden": "true",
|
|
5656
|
+
children: "AI"
|
|
5657
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
5658
|
+
className: "ui-visually-hidden",
|
|
5659
|
+
children: (label ?? tr("AI 說明")) + tr(":")
|
|
5660
|
+
})] });
|
|
5661
|
+
}
|
|
5507
5662
|
// src/components/Markdown/Markdown.tsx
|
|
5508
5663
|
const DETAILS_OPEN = /^\s*<details\b[^>]*>/i;
|
|
5509
5664
|
const DETAILS_TAG = /<(\/?)details\b[^>]*>/gi;
|
|
@@ -5791,8 +5946,17 @@ function inline(src, c) {
|
|
|
5791
5946
|
if (ch === "[") {
|
|
5792
5947
|
const m = matchLink(src, i);
|
|
5793
5948
|
if (m) {
|
|
5949
|
+
if (m.href.trim().toLowerCase() === "ai:") {
|
|
5950
|
+
devWarn(out.length || text.trim(), "Markdown", "[AI](ai:) 在句子中間。把它移到段落、清單項目或表格格子的開頭。");
|
|
5951
|
+
flush();
|
|
5952
|
+
out.push(/* @__PURE__ */ jsx(AiMark, {}, c.k()));
|
|
5953
|
+
i = m.end;
|
|
5954
|
+
if (src[i] === " ") i++;
|
|
5955
|
+
continue;
|
|
5956
|
+
}
|
|
5794
5957
|
flush();
|
|
5795
|
-
|
|
5958
|
+
const name = /^\s*`([^`]+)`\s*$/.exec(m.text)?.[1];
|
|
5959
|
+
out.push(link(m.href, inline(m.text, c), c, name));
|
|
5796
5960
|
i = m.end;
|
|
5797
5961
|
continue;
|
|
5798
5962
|
}
|
|
@@ -5822,13 +5986,20 @@ function inline(src, c) {
|
|
|
5822
5986
|
const onRef = ctx.onRef;
|
|
5823
5987
|
if (isPath(v)) {
|
|
5824
5988
|
const href = ctx.refHref?.(v) || void 0;
|
|
5825
|
-
|
|
5989
|
+
const click = onRef ? (e) => {
|
|
5990
|
+
if (href && (e.metaKey || e.ctrlKey || e.shiftKey || e.button === 1)) return;
|
|
5991
|
+
e.preventDefault();
|
|
5992
|
+
onRef(v, e);
|
|
5993
|
+
} : void 0;
|
|
5994
|
+
if (href) return /* @__PURE__ */ jsx(InlineCode, {
|
|
5995
|
+
look: "location",
|
|
5826
5996
|
href,
|
|
5827
|
-
onClick:
|
|
5828
|
-
|
|
5829
|
-
|
|
5830
|
-
|
|
5831
|
-
|
|
5997
|
+
onClick: click,
|
|
5998
|
+
children: v
|
|
5999
|
+
}, ctx.k());
|
|
6000
|
+
if (click) return /* @__PURE__ */ jsx(InlineCode, {
|
|
6001
|
+
look: "location",
|
|
6002
|
+
onClick: click,
|
|
5832
6003
|
children: v
|
|
5833
6004
|
}, ctx.k());
|
|
5834
6005
|
}
|
|
@@ -5879,7 +6050,7 @@ function findClose(src, from, run) {
|
|
|
5879
6050
|
}
|
|
5880
6051
|
return -1;
|
|
5881
6052
|
}
|
|
5882
|
-
function link(raw, children, c) {
|
|
6053
|
+
function link(raw, children, c, name) {
|
|
5883
6054
|
const scheme = /^([a-z][a-z0-9+.-]*):/i.exec(raw.trim())?.[1].toLowerCase();
|
|
5884
6055
|
const own = !!scheme && !BLOCKED.includes(scheme) && !!c.schemes?.some((x) => x.toLowerCase() === scheme);
|
|
5885
6056
|
const safe = own ? raw.trim() : safeHref(raw);
|
|
@@ -5893,6 +6064,19 @@ function link(raw, children, c) {
|
|
|
5893
6064
|
e.preventDefault();
|
|
5894
6065
|
onLink(safe, e);
|
|
5895
6066
|
} : void 0;
|
|
6067
|
+
if (name !== void 0 && !(outside && !c.onLink)) {
|
|
6068
|
+
if (href) return /* @__PURE__ */ jsx(InlineCode, {
|
|
6069
|
+
look: "name",
|
|
6070
|
+
href,
|
|
6071
|
+
onClick: click,
|
|
6072
|
+
children: name
|
|
6073
|
+
}, c.k());
|
|
6074
|
+
if (click) return /* @__PURE__ */ jsx(InlineCode, {
|
|
6075
|
+
look: "name",
|
|
6076
|
+
onClick: click,
|
|
6077
|
+
children: name
|
|
6078
|
+
}, c.k());
|
|
6079
|
+
}
|
|
5896
6080
|
if (!href) return /* @__PURE__ */ jsx("button", {
|
|
5897
6081
|
type: "button",
|
|
5898
6082
|
className: "ui-md-link",
|
|
@@ -9118,17 +9302,40 @@ function ThemePicker({ value, onChange, label, className }) {
|
|
|
9118
9302
|
}
|
|
9119
9303
|
// src/components/Tour/Tour.tsx
|
|
9120
9304
|
const TOUR_KEY = "ui-tour:";
|
|
9121
|
-
/** Opens the tour once per browser: { open, start, close, seen }. Pass close to Tour's onClose; start() shows
|
|
9305
|
+
/** Opens the tour once per browser: { open, start, close, seen, hint }. Pass close to Tour's onClose; start() shows
|
|
9306
|
+
* it again. hint(text) gives IconButton's `hint` for the button that starts the tour: a page that uses it shows the dot
|
|
9307
|
+
* and the bubble instead of opening the tour by itself. 「開始」 starts the tour; × and finishing it hide the hint for
|
|
9308
|
+
* good (the same record as seen). */
|
|
9122
9309
|
function useTour(key) {
|
|
9123
|
-
const [
|
|
9310
|
+
const [seen, setSeen] = React.useState(() => !!store(TOUR_KEY + key));
|
|
9311
|
+
const [open, setOpen] = React.useState(false);
|
|
9312
|
+
const hinted = React.useRef(false);
|
|
9313
|
+
React.useLayoutEffect(() => {
|
|
9314
|
+
if (!store(TOUR_KEY + key) && !hinted.current) setOpen(true);
|
|
9315
|
+
}, [key]);
|
|
9316
|
+
const remember = () => {
|
|
9317
|
+
store(TOUR_KEY + key, "1");
|
|
9318
|
+
setSeen(true);
|
|
9319
|
+
};
|
|
9124
9320
|
return {
|
|
9125
9321
|
open,
|
|
9126
9322
|
start: () => setOpen(true),
|
|
9127
9323
|
close: () => {
|
|
9128
|
-
|
|
9324
|
+
remember();
|
|
9129
9325
|
setOpen(false);
|
|
9130
9326
|
},
|
|
9131
|
-
seen
|
|
9327
|
+
seen,
|
|
9328
|
+
/** IconButton's `hint` for the button that starts this tour, or undefined once seen or while the tour is open. */
|
|
9329
|
+
hint: (text, action) => {
|
|
9330
|
+
hinted.current = true;
|
|
9331
|
+
if (seen || open) return void 0;
|
|
9332
|
+
return {
|
|
9333
|
+
text,
|
|
9334
|
+
action,
|
|
9335
|
+
onAction: () => setOpen(true),
|
|
9336
|
+
onDismiss: remember
|
|
9337
|
+
};
|
|
9338
|
+
}
|
|
9132
9339
|
};
|
|
9133
9340
|
}
|
|
9134
9341
|
function findTarget(t) {
|
|
@@ -10179,6 +10386,6 @@ function TreeList(p) {
|
|
|
10179
10386
|
})]
|
|
10180
10387
|
});
|
|
10181
10388
|
}
|
|
10182
|
-
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 };
|
|
10389
|
+
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 };
|
|
10183
10390
|
|
|
10184
10391
|
//# sourceMappingURL=index.js.map
|