@seanyeh77/ui 0.48.2 → 0.48.3
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 +20 -20
- package/dist/components/InlineCode/InlineCode.js +41 -9
- package/dist/components/InlineCode/InlineCode.js.map +1 -1
- package/dist/components/LayerGraph/LayerGraph.js +19 -6
- package/dist/components/LayerGraph/LayerGraph.js.map +1 -1
- package/dist/css/DataTable.css +1 -1
- package/dist/css/InlineCode.css +23 -0
- package/dist/internal/util.js +19 -1
- package/dist/internal/util.js.map +1 -1
- package/dist/styles.css +76 -54
- package/docs/InlineCode.md +1 -1
- package/docs/agents.md +5 -5
- package/package.json +2 -2
package/dist/css/DataTable.css
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
@layer theme, base, ui, components, utilities;
|
|
2
2
|
@layer ui.tokens, ui.components;
|
|
3
|
+
@import './Tooltip.css';
|
|
3
4
|
@import './InlineCode.css';
|
|
4
5
|
@import './Button.css';
|
|
5
6
|
@import './Dialog.css';
|
|
@@ -8,7 +9,6 @@
|
|
|
8
9
|
@import './Checkbox.css';
|
|
9
10
|
@import './RadioGroup.css';
|
|
10
11
|
@import './SearchField.css';
|
|
11
|
-
@import './Tooltip.css';
|
|
12
12
|
@import './IconButton.css';
|
|
13
13
|
@import './Menu.css';
|
|
14
14
|
@import './Popover.css';
|
package/dist/css/InlineCode.css
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
@layer theme, base, ui, components, utilities;
|
|
2
2
|
@layer ui.tokens, ui.components;
|
|
3
|
+
@import './Tooltip.css';
|
|
3
4
|
@layer ui.components {
|
|
4
5
|
/* Inline code */
|
|
5
6
|
.ui-code {
|
|
@@ -61,6 +62,28 @@
|
|
|
61
62
|
font-size: var(--text-small);
|
|
62
63
|
white-space: nowrap;
|
|
63
64
|
}
|
|
65
|
+
/* A location in a phone card (DataTable under 600 px) is no wider than the card's value column: the folders are cut
|
|
66
|
+
with 「…」 first and the file name and line stay (codemap/…/tshelper.ts:42); a file name wider than the column is
|
|
67
|
+
cut at its end. InlineCode shows the whole path in a Tooltip while it is cut. Desktop tables and text keep the
|
|
68
|
+
plain inline link. */
|
|
69
|
+
@media (max-width: 599px) {
|
|
70
|
+
.ui-dt-body .ui-code.is-link.is-location {
|
|
71
|
+
display: inline-flex;
|
|
72
|
+
max-width: 100%;
|
|
73
|
+
}
|
|
74
|
+
.ui-dt-body .ui-code.is-link.is-location > .ui-code-dir {
|
|
75
|
+
flex: 0 1 auto;
|
|
76
|
+
min-width: 1ch;
|
|
77
|
+
overflow: hidden;
|
|
78
|
+
text-overflow: ellipsis;
|
|
79
|
+
}
|
|
80
|
+
.ui-dt-body .ui-code.is-link.is-location > .ui-code-file {
|
|
81
|
+
flex: 0 0 auto;
|
|
82
|
+
max-width: 100%;
|
|
83
|
+
overflow: hidden;
|
|
84
|
+
text-overflow: ellipsis;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
64
87
|
/* In a table cell a location is often a target on its own, beside the row's other links: its box is about 17 px of
|
|
65
88
|
13 px text. Vertical padding on an inline box grows the box it is clicked by to at least 24 px (WCAG 2.5.8) and
|
|
66
89
|
moves neither the line nor the row; there is no background, so nothing shows. Desktop rows only: in a phone card
|
package/dist/internal/util.js
CHANGED
|
@@ -55,6 +55,24 @@ const serverFalse = () => false;
|
|
|
55
55
|
function resizeObserver(cb) {
|
|
56
56
|
return typeof ResizeObserver === "function" ? new ResizeObserver(cb) : null;
|
|
57
57
|
}
|
|
58
|
+
let fontLoads = 0;
|
|
59
|
+
const fontListeners = /* @__PURE__ */ new Set();
|
|
60
|
+
if (typeof document !== "undefined" && typeof document.fonts?.addEventListener === "function") document.fonts.addEventListener("loadingdone", () => {
|
|
61
|
+
fontLoads++;
|
|
62
|
+
for (const f of fontListeners) f();
|
|
63
|
+
});
|
|
64
|
+
const subFonts = (f) => {
|
|
65
|
+
fontListeners.add(f);
|
|
66
|
+
return () => fontListeners.delete(f);
|
|
67
|
+
};
|
|
68
|
+
const getFonts = () => fontLoads;
|
|
69
|
+
const serverZero = () => 0;
|
|
70
|
+
/** A number that goes up each time web fonts finish loading (document.fonts `loadingdone`). Layout worked out from text
|
|
71
|
+
* measured on a canvas depends on it, so it is worked out again with the loaded fonts instead of keeping the fallback
|
|
72
|
+
* font's widths. 0 on the server and while hydrating. */
|
|
73
|
+
function useFontLoads() {
|
|
74
|
+
return React.useSyncExternalStore(subFonts, getFonts, serverZero);
|
|
75
|
+
}
|
|
58
76
|
/** True under 600 px, the same width where cards stack. */
|
|
59
77
|
function useNarrow() {
|
|
60
78
|
return useMedia("(max-width: 599px)");
|
|
@@ -103,6 +121,6 @@ function nodeText(node) {
|
|
|
103
121
|
function keepUnits(text) {
|
|
104
122
|
return text.replace(/(\d) (?=°|%|‰|[A-Za-zµΩ]{1,4}(?![A-Za-z])|[\u3400-\u9fff])/g, "$1\xA0").replace(/((?:^|[^\w$])(?:[A-Z]{2}\$|[$€£¥₩])) (?=[-−]?\d)/g, "$1\xA0");
|
|
105
123
|
}
|
|
106
|
-
export { IS_MAC, SHORTCUT, TOUCH_ONLY, browserKey, copyText, cx, digits, idPart, keepUnits, monoNums, nodeText, reduced, resizeObserver, seenOnly, useMedia, useNarrow };
|
|
124
|
+
export { IS_MAC, SHORTCUT, TOUCH_ONLY, browserKey, copyText, cx, digits, idPart, keepUnits, monoNums, nodeText, reduced, resizeObserver, seenOnly, useFontLoads, useMedia, useNarrow };
|
|
107
125
|
|
|
108
126
|
//# sourceMappingURL=util.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.js","names":[],"sources":["../../src/internal/util.tsx"],"sourcesContent":["import * as React from 'react';\n\n/** A value (a row or node id, a file path) as part of an element id: no spaces, so aria-owns, aria-controls and\n * aria-labelledby, which split their value at spaces, still find it. */\nexport const idPart = (s: string): string => encodeURIComponent(s);\n\n/** Joins the truthy class names. */\nexport function cx(...names: unknown[]): string {\n return names.filter(Boolean).join(' ');\n}\n\n// Text that is only seen: drawn by CSS (::before), so it is neither in the page's text (copy, innerText, text-reading\n// tools) nor read aloud. The readable version goes beside it, visually hidden. Numbers keep Geist Mono.\nexport function seenOnly(text: string, nums: string[]): React.ReactNode[] {\n return splitMarks(text).map(([t, k], i) => <span key={i} className={cx('ui-seen', k >= 0 && 'ui-num')} data-text={k >= 0 ? nums[k] : t} />);\n}\n\n// A translated sentence cut at its number marks (\\u0001, \\u0002, \\u0003): [text, -1] or [mark, its index].\nfunction splitMarks(text: string): [string, number][] {\n return (\n text\n // eslint-disable-next-line no-control-regex -- the marks are control characters on purpose\n .split(/(\\u0001|\\u0002|\\u0003)/)\n .filter(Boolean)\n .map((t) => [t, ['\\u0001', '\\u0002', '\\u0003'].indexOf(t)])\n );\n}\n\n// Puts the numbers of a translated sentence in Geist Mono and leaves the words in the text font.\n// The sentence marks each number with \\u0001, \\u0002 or \\u0003 in the order of nums.\nexport function monoNums(text: string, nums: React.ReactNode[]): React.ReactNode[] {\n return splitMarks(text).map(([t, k], i) =>\n k >= 0 ? (\n <span key={i} className=\"ui-num\">\n {nums[k]}\n </span>\n ) : (\n t\n ),\n );\n}\n\n/** localStorage get (no value) or set; null when storage is blocked. */\nexport function store(key: string, value?: string): string | null {\n try {\n if (value === undefined) return localStorage.getItem(key);\n localStorage.setItem(key, value);\n } catch {\n /* storage blocked (private mode, sandboxed frame) */\n }\n return null;\n}\n\nexport function reduced(): boolean {\n return typeof window !== 'undefined' && typeof window.matchMedia === 'function' && window.matchMedia('(prefers-reduced-motion: reduce)').matches;\n}\n\nconst nav = typeof navigator !== 'undefined' ? (navigator as Navigator & { userAgentData?: { platform?: string } }) : undefined;\nexport const IS_MAC = /mac|iphone|ipad/i.test(nav?.userAgentData?.platform || nav?.platform || nav?.userAgent || '');\n/** A touch screen as the main input (phones, tablets): no keyboard to press a shortcut with, no hover. Phones and\n * tablets report (pointer: coarse); (hover: none) alone is not used, since Chromium keeps it after touch emulation is\n * turned off and a mouse would then lose its Tooltips. */\nexport const TOUCH_ONLY = '(pointer: coarse)';\nexport const SHORTCUT = IS_MAC ? '⌘K' : 'Ctrl K';\n\n/** Matches a media query and follows changes. false on the server and in the first browser render while hydrating,\n * so the markup matches; then the real match. */\nexport function useMedia(query: string): boolean {\n const sub = React.useCallback(\n (f: () => void) => {\n if (typeof window === 'undefined' || typeof window.matchMedia !== 'function') return () => {};\n const m = window.matchMedia(query);\n m.addEventListener('change', f);\n return () => m.removeEventListener('change', f);\n },\n [query],\n );\n const get = React.useCallback(() => typeof window !== 'undefined' && typeof window.matchMedia === 'function' && window.matchMedia(query).matches, [query]);\n return React.useSyncExternalStore(sub, get, serverFalse);\n}\nconst serverFalse = () => false;\n\n/** A ResizeObserver, or null where there is none (jsdom, old browsers): the first measure then stays. */\nexport function resizeObserver(cb: ResizeObserverCallback): ResizeObserver | null {\n return typeof ResizeObserver === 'function' ? new ResizeObserver(cb) : null;\n}\n\n/** True under 600 px, the same width where cards stack. */\nexport function useNarrow(): boolean {\n return useMedia('(max-width: 599px)');\n}\n\nexport async function copyText(text: string): Promise<void> {\n if (navigator.clipboard?.writeText) {\n try {\n return await navigator.clipboard.writeText(text);\n } catch {\n /* fall back below (insecure context, denied permission) */\n }\n }\n const t = document.createElement('textarea');\n t.value = text;\n t.setAttribute('readonly', '');\n t.style.position = 'fixed';\n t.style.opacity = '0';\n document.body.appendChild(t);\n t.select();\n try {\n if (!document.execCommand('copy')) throw new Error('copy failed');\n } finally {\n document.body.removeChild(t);\n }\n}\n\n/** Text with every number in Geist Mono and the words in the text font, for labels that mix both (「第 1 週」). */\nexport function digits(text: string, numbers = /(\\d[\\d,.:/]*)/): React.ReactNode[] {\n return text.split(numbers).map((t, i) =>\n i % 2 ? (\n <span key={i} className=\"ui-num\">\n {t}\n </span>\n ) : (\n t\n ),\n );\n}\n\n/** Alt, Meta or Ctrl held: the key belongs to the browser or the system (Alt+← goes back a page), not to the widget. */\nexport const browserKey = (e: { altKey: boolean; metaKey: boolean; ctrlKey: boolean }): boolean => e.altKey || e.metaKey || e.ctrlKey;\n\n/** The words in a React node, as a screen reader would read them: strings and numbers, through elements' children. */\nexport function nodeText(node: React.ReactNode): string {\n if (node == null || typeof node === 'boolean') return '';\n if (typeof node === 'string' || typeof node === 'number') return String(node);\n if (Array.isArray(node)) return node.map(nodeText).join('');\n if (React.isValidElement(node)) {\n const props = node.props as { 'aria-label'?: string; label?: unknown; children?: React.ReactNode };\n if (typeof props['aria-label'] === 'string') return props['aria-label'];\n return nodeText(props.children) || (typeof props.label === 'string' ? props.label : '');\n }\n return '';\n}\n\n/** A number and its unit never break apart: the space between them becomes a no-break space (U+00A0), so\n * 「100 MB」「29 °C」「3 筆」 do not wrap as 「100 / MB」 on a phone, nor a currency before the number (「NT$ 1,280」).\n * Leaves every other space alone. */\nexport function keepUnits(text: string): string {\n return text\n .replace(/(\\d) (?=°|%|‰|[A-Za-zµΩ]{1,4}(?![A-Za-z])|[\\u3400-\\u9fff])/g, '$1\\u00a0')\n .replace(/((?:^|[^\\w$])(?:[A-Z]{2}\\$|[$€£¥₩])) (?=[-−]?\\d)/g, '$1\\u00a0');\n}\n"],"mappings":";;;;;;AAIA,MAAa,UAAU,MAAsB,mBAAmB,CAAC;;AAGjE,SAAgB,GAAG,GAAG,OAA0B;CAC9C,OAAO,MAAM,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG;AACvC;AAIA,SAAgB,SAAS,MAAc,MAAmC;CACxE,OAAO,WAAW,IAAI,CAAC,CAAC,KAAK,CAAC,GAAG,IAAI,MAAM,oBAAC,QAAD;EAAc,WAAW,GAAG,WAAW,KAAK,KAAK,QAAQ;EAAG,aAAW,KAAK,IAAI,KAAK,KAAK;CAAI,GAAnF,CAAmF,CAAC;AAC5I;AAGA,SAAS,WAAW,MAAkC;CACpD,OACE,KAEG,MAAM,wBAAwB,CAAC,CAC/B,OAAO,OAAO,CAAC,CACf,KAAK,MAAM,CAAC,GAAG;EAAC;EAAU;EAAU;CAAQ,CAA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(a row or node id, a file path) as part of an element id: no spaces, so aria-owns, aria-controls and\n * aria-labelledby, which split their value at spaces, still find it. */\nexport const idPart = (s: string): string => encodeURIComponent(s);\n\n/** Joins the truthy class names. */\nexport function cx(...names: unknown[]): string {\n return names.filter(Boolean).join(' ');\n}\n\n// Text that is only seen: drawn by CSS (::before), so it is neither in the page's text (copy, innerText, text-reading\n// tools) nor read aloud. The readable version goes beside it, visually hidden. Numbers keep Geist Mono.\nexport function seenOnly(text: string, nums: string[]): React.ReactNode[] {\n return splitMarks(text).map(([t, k], i) => <span key={i} className={cx('ui-seen', k >= 0 && 'ui-num')} data-text={k >= 0 ? nums[k] : t} />);\n}\n\n// A translated sentence cut at its number marks (\\u0001, \\u0002, \\u0003): [text, -1] or [mark, its index].\nfunction splitMarks(text: string): [string, number][] {\n return (\n text\n // eslint-disable-next-line no-control-regex -- the marks are control characters on purpose\n .split(/(\\u0001|\\u0002|\\u0003)/)\n .filter(Boolean)\n .map((t) => [t, ['\\u0001', '\\u0002', '\\u0003'].indexOf(t)])\n );\n}\n\n// Puts the numbers of a translated sentence in Geist Mono and leaves the words in the text font.\n// The sentence marks each number with \\u0001, \\u0002 or \\u0003 in the order of nums.\nexport function monoNums(text: string, nums: React.ReactNode[]): React.ReactNode[] {\n return splitMarks(text).map(([t, k], i) =>\n k >= 0 ? (\n <span key={i} className=\"ui-num\">\n {nums[k]}\n </span>\n ) : (\n t\n ),\n );\n}\n\n/** localStorage get (no value) or set; null when storage is blocked. */\nexport function store(key: string, value?: string): string | null {\n try {\n if (value === undefined) return localStorage.getItem(key);\n localStorage.setItem(key, value);\n } catch {\n /* storage blocked (private mode, sandboxed frame) */\n }\n return null;\n}\n\nexport function reduced(): boolean {\n return typeof window !== 'undefined' && typeof window.matchMedia === 'function' && window.matchMedia('(prefers-reduced-motion: reduce)').matches;\n}\n\nconst nav = typeof navigator !== 'undefined' ? (navigator as Navigator & { userAgentData?: { platform?: string } }) : undefined;\nexport const IS_MAC = /mac|iphone|ipad/i.test(nav?.userAgentData?.platform || nav?.platform || nav?.userAgent || '');\n/** A touch screen as the main input (phones, tablets): no keyboard to press a shortcut with, no hover. Phones and\n * tablets report (pointer: coarse); (hover: none) alone is not used, since Chromium keeps it after touch emulation is\n * turned off and a mouse would then lose its Tooltips. */\nexport const TOUCH_ONLY = '(pointer: coarse)';\nexport const SHORTCUT = IS_MAC ? '⌘K' : 'Ctrl K';\n\n/** Matches a media query and follows changes. false on the server and in the first browser render while hydrating,\n * so the markup matches; then the real match. */\nexport function useMedia(query: string): boolean {\n const sub = React.useCallback(\n (f: () => void) => {\n if (typeof window === 'undefined' || typeof window.matchMedia !== 'function') return () => {};\n const m = window.matchMedia(query);\n m.addEventListener('change', f);\n return () => m.removeEventListener('change', f);\n },\n [query],\n );\n const get = React.useCallback(() => typeof window !== 'undefined' && typeof window.matchMedia === 'function' && window.matchMedia(query).matches, [query]);\n return React.useSyncExternalStore(sub, get, serverFalse);\n}\nconst serverFalse = () => false;\n\n/** A ResizeObserver, or null where there is none (jsdom, old browsers): the first measure then stays. */\nexport function resizeObserver(cb: ResizeObserverCallback): ResizeObserver | null {\n return typeof ResizeObserver === 'function' ? new ResizeObserver(cb) : null;\n}\n\n// Web fonts that finished loading since this module ran: text measured on a canvas before then used the fallback font.\nlet fontLoads = 0;\nconst fontListeners = new Set<() => void>();\nif (typeof document !== 'undefined' && typeof document.fonts?.addEventListener === 'function') {\n document.fonts.addEventListener('loadingdone', () => {\n fontLoads++;\n for (const f of fontListeners) f();\n });\n}\nconst subFonts = (f: () => void) => {\n fontListeners.add(f);\n return () => fontListeners.delete(f);\n};\nconst getFonts = () => fontLoads;\nconst serverZero = () => 0;\n\n/** A number that goes up each time web fonts finish loading (document.fonts `loadingdone`). Layout worked out from text\n * measured on a canvas depends on it, so it is worked out again with the loaded fonts instead of keeping the fallback\n * font's widths. 0 on the server and while hydrating. */\nexport function useFontLoads(): number {\n return React.useSyncExternalStore(subFonts, getFonts, serverZero);\n}\n\n/** True under 600 px, the same width where cards stack. */\nexport function useNarrow(): boolean {\n return useMedia('(max-width: 599px)');\n}\n\nexport async function copyText(text: string): Promise<void> {\n if (navigator.clipboard?.writeText) {\n try {\n return await navigator.clipboard.writeText(text);\n } catch {\n /* fall back below (insecure context, denied permission) */\n }\n }\n const t = document.createElement('textarea');\n t.value = text;\n t.setAttribute('readonly', '');\n t.style.position = 'fixed';\n t.style.opacity = '0';\n document.body.appendChild(t);\n t.select();\n try {\n if (!document.execCommand('copy')) throw new Error('copy failed');\n } finally {\n document.body.removeChild(t);\n }\n}\n\n/** Text with every number in Geist Mono and the words in the text font, for labels that mix both (「第 1 週」). */\nexport function digits(text: string, numbers = /(\\d[\\d,.:/]*)/): React.ReactNode[] {\n return text.split(numbers).map((t, i) =>\n i % 2 ? (\n <span key={i} className=\"ui-num\">\n {t}\n </span>\n ) : (\n t\n ),\n );\n}\n\n/** Alt, Meta or Ctrl held: the key belongs to the browser or the system (Alt+← goes back a page), not to the widget. */\nexport const browserKey = (e: { altKey: boolean; metaKey: boolean; ctrlKey: boolean }): boolean => e.altKey || e.metaKey || e.ctrlKey;\n\n/** The words in a React node, as a screen reader would read them: strings and numbers, through elements' children. */\nexport function nodeText(node: React.ReactNode): string {\n if (node == null || typeof node === 'boolean') return '';\n if (typeof node === 'string' || typeof node === 'number') return String(node);\n if (Array.isArray(node)) return node.map(nodeText).join('');\n if (React.isValidElement(node)) {\n const props = node.props as { 'aria-label'?: string; label?: unknown; children?: React.ReactNode };\n if (typeof props['aria-label'] === 'string') return props['aria-label'];\n return nodeText(props.children) || (typeof props.label === 'string' ? props.label : '');\n }\n return '';\n}\n\n/** A number and its unit never break apart: the space between them becomes a no-break space (U+00A0), so\n * 「100 MB」「29 °C」「3 筆」 do not wrap as 「100 / MB」 on a phone, nor a currency before the number (「NT$ 1,280」).\n * Leaves every other space alone. */\nexport function keepUnits(text: string): string {\n return text\n .replace(/(\\d) (?=°|%|‰|[A-Za-zµΩ]{1,4}(?![A-Za-z])|[\\u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C;CAC3B,EAAE,OAAO;CACT,IAAI;EACF,IAAI,CAAC,SAAS,YAAY,MAAM,GAAG,MAAM,IAAI,MAAM,aAAa;CAClE,UAAU;EACR,SAAS,KAAK,YAAY,CAAC;CAC7B;AACF;;AAGA,SAAgB,OAAO,MAAc,UAAU,iBAAoC;CACjF,OAAO,KAAK,MAAM,OAAO,CAAC,CAAC,KAAK,GAAG,MACjC,IAAI,IACF,oBAAC,QAAD;EAAc,WAAU;EACrB,UAAA;CACG,GAFK,CAEL,IAEN,CAEJ;AACF;;AAGA,MAAa,cAAc,MAAwE,EAAE,UAAU,EAAE,WAAW,EAAE;;AAG9H,SAAgB,SAAS,MAA+B;CACtD,IAAI,QAAQ,QAAQ,OAAO,SAAS,WAAW,OAAO;CACtD,IAAI,OAAO,SAAS,YAAY,OAAO,SAAS,UAAU,OAAO,OAAO,IAAI;CAC5E,IAAI,MAAM,QAAQ,IAAI,GAAG,OAAO,KAAK,IAAI,QAAQ,CAAC,CAAC,KAAK,EAAE;CAC1D,IAAI,MAAM,eAAe,IAAI,GAAG;EAC9B,MAAM,QAAQ,KAAK;EACnB,IAAI,OAAO,MAAM,kBAAkB,UAAU,OAAO,MAAM;EAC1D,OAAO,SAAS,MAAM,QAAQ,MAAM,OAAO,MAAM,UAAU,WAAW,MAAM,QAAQ;CACtF;CACA,OAAO;AACT;;;;AAKA,SAAgB,UAAU,MAAsB;CAC9C,OAAO,KACJ,QAAQ,+DAA+D,QAAU,CAAC,CAClF,QAAQ,qDAAqD,QAAU;AAC5E"}
|
package/dist/styles.css
CHANGED
|
@@ -705,6 +705,60 @@ label:has(> .ui-switch) {
|
|
|
705
705
|
margin-left: 2px;
|
|
706
706
|
vertical-align: -2px;
|
|
707
707
|
}
|
|
708
|
+
.ui-tooltip {
|
|
709
|
+
padding: 6px 10px;
|
|
710
|
+
border-radius: var(--radius-chip);
|
|
711
|
+
background: var(--ink);
|
|
712
|
+
color: var(--bg);
|
|
713
|
+
font-size: var(--text-small);
|
|
714
|
+
font-weight: 600;
|
|
715
|
+
line-height: 1.4;
|
|
716
|
+
white-space: nowrap;
|
|
717
|
+
pointer-events: none;
|
|
718
|
+
animation: ui-pop-scale var(--dur-tooltip) var(--ease-spring) both;
|
|
719
|
+
}
|
|
720
|
+
.ui-tooltip {
|
|
721
|
+
transform-origin: var(--transform-origin);
|
|
722
|
+
}
|
|
723
|
+
/* Closing: no animation left to wait for, so the popup leaves at once (an entrance still running kept it on screen). */
|
|
724
|
+
.ui-tooltip[data-ending-style] {
|
|
725
|
+
animation: none;
|
|
726
|
+
}
|
|
727
|
+
.ui-tooltip.is-wrap {
|
|
728
|
+
max-width: min(360px, calc(100vw - 2 * var(--space-3)));
|
|
729
|
+
font-weight: 400;
|
|
730
|
+
line-height: 20px;
|
|
731
|
+
white-space: normal;
|
|
732
|
+
}
|
|
733
|
+
.ui-tooltip-arrow {
|
|
734
|
+
position: absolute;
|
|
735
|
+
width: 8px;
|
|
736
|
+
height: 8px;
|
|
737
|
+
background: inherit;
|
|
738
|
+
transform: rotate(45deg);
|
|
739
|
+
}
|
|
740
|
+
.ui-tooltip[data-side='top'] .ui-tooltip-arrow {
|
|
741
|
+
bottom: -4px;
|
|
742
|
+
}
|
|
743
|
+
.ui-tooltip[data-side='bottom'] .ui-tooltip-arrow {
|
|
744
|
+
top: -4px;
|
|
745
|
+
}
|
|
746
|
+
.ui-tooltip[data-side='right'] .ui-tooltip-arrow {
|
|
747
|
+
left: -4px;
|
|
748
|
+
}
|
|
749
|
+
.ui-tooltip[data-side='left'] .ui-tooltip-arrow {
|
|
750
|
+
right: -4px;
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
@media (prefers-reduced-motion: reduce) {
|
|
754
|
+
.ui-tooltip {
|
|
755
|
+
animation: ui-pop-fade var(--dur-hover) ease both;
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
.ui-tooltip-positioner {
|
|
759
|
+
z-index: var(--z-tooltip);
|
|
760
|
+
pointer-events: none;
|
|
761
|
+
}
|
|
708
762
|
/* Inline code */
|
|
709
763
|
.ui-code {
|
|
710
764
|
font-family: var(--font-mono);
|
|
@@ -765,6 +819,28 @@ label:has(> .ui-switch) {
|
|
|
765
819
|
font-size: var(--text-small);
|
|
766
820
|
white-space: nowrap;
|
|
767
821
|
}
|
|
822
|
+
/* A location in a phone card (DataTable under 600 px) is no wider than the card's value column: the folders are cut
|
|
823
|
+
with 「…」 first and the file name and line stay (codemap/…/tshelper.ts:42); a file name wider than the column is
|
|
824
|
+
cut at its end. InlineCode shows the whole path in a Tooltip while it is cut. Desktop tables and text keep the
|
|
825
|
+
plain inline link. */
|
|
826
|
+
@media (max-width: 599px) {
|
|
827
|
+
.ui-dt-body .ui-code.is-link.is-location {
|
|
828
|
+
display: inline-flex;
|
|
829
|
+
max-width: 100%;
|
|
830
|
+
}
|
|
831
|
+
.ui-dt-body .ui-code.is-link.is-location > .ui-code-dir {
|
|
832
|
+
flex: 0 1 auto;
|
|
833
|
+
min-width: 1ch;
|
|
834
|
+
overflow: hidden;
|
|
835
|
+
text-overflow: ellipsis;
|
|
836
|
+
}
|
|
837
|
+
.ui-dt-body .ui-code.is-link.is-location > .ui-code-file {
|
|
838
|
+
flex: 0 0 auto;
|
|
839
|
+
max-width: 100%;
|
|
840
|
+
overflow: hidden;
|
|
841
|
+
text-overflow: ellipsis;
|
|
842
|
+
}
|
|
843
|
+
}
|
|
768
844
|
/* In a table cell a location is often a target on its own, beside the row's other links: its box is about 17 px of
|
|
769
845
|
13 px text. Vertical padding on an inline box grows the box it is clicked by to at least 24 px (WCAG 2.5.8) and
|
|
770
846
|
moves neither the line nor the row; there is no background, so nothing shows. Desktop rows only: in a phone card
|
|
@@ -2175,60 +2251,6 @@ div.ui-toast[role='status'] {
|
|
|
2175
2251
|
font-weight: 700;
|
|
2176
2252
|
fill: var(--ink);
|
|
2177
2253
|
}
|
|
2178
|
-
.ui-tooltip {
|
|
2179
|
-
padding: 6px 10px;
|
|
2180
|
-
border-radius: var(--radius-chip);
|
|
2181
|
-
background: var(--ink);
|
|
2182
|
-
color: var(--bg);
|
|
2183
|
-
font-size: var(--text-small);
|
|
2184
|
-
font-weight: 600;
|
|
2185
|
-
line-height: 1.4;
|
|
2186
|
-
white-space: nowrap;
|
|
2187
|
-
pointer-events: none;
|
|
2188
|
-
animation: ui-pop-scale var(--dur-tooltip) var(--ease-spring) both;
|
|
2189
|
-
}
|
|
2190
|
-
.ui-tooltip {
|
|
2191
|
-
transform-origin: var(--transform-origin);
|
|
2192
|
-
}
|
|
2193
|
-
/* Closing: no animation left to wait for, so the popup leaves at once (an entrance still running kept it on screen). */
|
|
2194
|
-
.ui-tooltip[data-ending-style] {
|
|
2195
|
-
animation: none;
|
|
2196
|
-
}
|
|
2197
|
-
.ui-tooltip.is-wrap {
|
|
2198
|
-
max-width: min(360px, calc(100vw - 2 * var(--space-3)));
|
|
2199
|
-
font-weight: 400;
|
|
2200
|
-
line-height: 20px;
|
|
2201
|
-
white-space: normal;
|
|
2202
|
-
}
|
|
2203
|
-
.ui-tooltip-arrow {
|
|
2204
|
-
position: absolute;
|
|
2205
|
-
width: 8px;
|
|
2206
|
-
height: 8px;
|
|
2207
|
-
background: inherit;
|
|
2208
|
-
transform: rotate(45deg);
|
|
2209
|
-
}
|
|
2210
|
-
.ui-tooltip[data-side='top'] .ui-tooltip-arrow {
|
|
2211
|
-
bottom: -4px;
|
|
2212
|
-
}
|
|
2213
|
-
.ui-tooltip[data-side='bottom'] .ui-tooltip-arrow {
|
|
2214
|
-
top: -4px;
|
|
2215
|
-
}
|
|
2216
|
-
.ui-tooltip[data-side='right'] .ui-tooltip-arrow {
|
|
2217
|
-
left: -4px;
|
|
2218
|
-
}
|
|
2219
|
-
.ui-tooltip[data-side='left'] .ui-tooltip-arrow {
|
|
2220
|
-
right: -4px;
|
|
2221
|
-
}
|
|
2222
|
-
|
|
2223
|
-
@media (prefers-reduced-motion: reduce) {
|
|
2224
|
-
.ui-tooltip {
|
|
2225
|
-
animation: ui-pop-fade var(--dur-hover) ease both;
|
|
2226
|
-
}
|
|
2227
|
-
}
|
|
2228
|
-
.ui-tooltip-positioner {
|
|
2229
|
-
z-index: var(--z-tooltip);
|
|
2230
|
-
pointer-events: none;
|
|
2231
|
-
}
|
|
2232
2254
|
.ui-iconbtn {
|
|
2233
2255
|
display: inline-flex;
|
|
2234
2256
|
align-items: center;
|
package/docs/InlineCode.md
CHANGED
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
一段說明裡常常同時出現程式的名稱和它所在的檔案,例如「`VirtualRouter._sync_as` `harness/controller.py:540` 呼叫 …」。這兩種連結用 `look` 換成不同外觀,不再是兩個一樣的灰底底線塊:
|
|
29
29
|
|
|
30
30
|
- `look="name"`:函式、類別、變數,點了跳到定義。強調文字色(`accent-text`)的 Geist Mono,周圍文字的 0.875 倍,沒有底色也沒有底線;滑過或鍵盤焦點時出現 1 px 底線(離文字 3 px),焦點另有和其他控制項一樣的 2 px `focus` 外框。
|
|
31
|
-
- `look="location"`:檔案和行號。灰色(`ink-muted`)、13 px
|
|
31
|
+
- `look="location"`:檔案和行號。灰色(`ink-muted`)、13 px(次要文字的大小,比內文小一號),不斷行;滑過或焦點時變強調文字色加底線。空間不夠時(DataTable 的手機卡片,值的那一欄比路徑窄)不超出,改用「…」截斷:先截資料夾,留下檔名和行號(`codemap/…/tshelper.ts:42`),檔名本身也放不下時截在檔名尾端;截斷時滑過、點一下或鍵盤焦點會用 Tooltip 顯示完整路徑,點擊照樣前往連結,螢幕閱讀器念的名稱仍是完整路徑。桌面的表格和句子裡維持原樣。
|
|
32
32
|
- 兩種都一定要給 `href` 或 `onClick`,沒有的話 TypeScript 不會編譯:不指向任何地方的文字維持灰底(預設的 `look="chip"`)。
|
|
33
33
|
- 深色模式下在表格的灰色列(`surface-sub`)上,文字色混入 25% 的 `ink`,對比維持 4.5:1 以上。
|
|
34
34
|
|
package/docs/agents.md
CHANGED
|
@@ -65,11 +65,11 @@ export default [ui.configs.recommended];
|
|
|
65
65
|
```html
|
|
66
66
|
<meta charset="utf-8">
|
|
67
67
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
68
|
-
<link rel="stylesheet" href="https://seanyeh77.github.io/ui-design-system/dist/0.48.
|
|
69
|
-
<link rel="stylesheet" href="https://seanyeh77.github.io/ui-design-system/dist/0.48.
|
|
70
|
-
<link rel="stylesheet" href="https://seanyeh77.github.io/ui-design-system/dist/0.48.
|
|
68
|
+
<link rel="stylesheet" href="https://seanyeh77.github.io/ui-design-system/dist/0.48.3/fonts.css">
|
|
69
|
+
<link rel="stylesheet" href="https://seanyeh77.github.io/ui-design-system/dist/0.48.3/tokens.css">
|
|
70
|
+
<link rel="stylesheet" href="https://seanyeh77.github.io/ui-design-system/dist/0.48.3/styles.css">
|
|
71
71
|
<div id="root"></div>
|
|
72
|
-
<script src="https://seanyeh77.github.io/ui-design-system/dist/0.48.
|
|
72
|
+
<script src="https://seanyeh77.github.io/ui-design-system/dist/0.48.3/bundle.js"></script>
|
|
73
73
|
<script>
|
|
74
74
|
const h = React.createElement;
|
|
75
75
|
UI.initTheme();
|
|
@@ -77,6 +77,6 @@ export default [ui.configs.recommended];
|
|
|
77
77
|
</script>
|
|
78
78
|
```
|
|
79
79
|
|
|
80
|
-
Pin a version as above: `/dist/<version>/` never changes; `/dist/` always serves the latest release. jsDelivr has the same files (`https://cdn.jsdelivr.net/npm/@seanyeh77/ui@0.48.
|
|
80
|
+
Pin a version as above: `/dist/<version>/` never changes; `/dist/` always serves the latest release. jsDelivr has the same files (`https://cdn.jsdelivr.net/npm/@seanyeh77/ui@0.48.3/dist/bundle.js`, `…/dist/styles.css`; the fonts at `https://cdn.jsdelivr.net/npm/@seanyeh77/tokens@0.48.3/fonts.css`). Without a bundler, `@seanyeh77/ui/dist/fonts.css` cannot resolve its import: load the tokens package's `fonts.css` or the pinned site URL.
|
|
81
81
|
|
|
82
82
|
Scope: web UI, and the tokens of SeanYeh's Slidev decks (`initTheme({ preset: 'teaching' })`, see `theme.md`). Slide layout, Notion documents and teaching diagrams follow the separate `teaching-materials-style` skill.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@seanyeh77/ui",
|
|
3
|
-
"version": "0.48.
|
|
3
|
+
"version": "0.48.3",
|
|
4
4
|
"description": "SeanYeh's design system: typed React components on Base UI, styled with design tokens.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Hsiu-An Yeh",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
60
|
"@base-ui/react": "^1.9.0",
|
|
61
|
-
"@seanyeh77/tokens": "^0.48.
|
|
61
|
+
"@seanyeh77/tokens": "^0.48.3"
|
|
62
62
|
},
|
|
63
63
|
"scripts": {
|
|
64
64
|
"build": "node scripts/theme-defaults.ts && tsdown && node scripts/postbuild.ts",
|