@seanyeh77/ui 0.49.0 → 0.50.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 +18 -18
- package/dist/components/CodeView/CodeView.js +6 -5
- package/dist/components/CodeView/CodeView.js.map +1 -1
- package/dist/components/ConsoleLayout/ConsoleLayout.d.ts +11 -5
- package/dist/components/ConsoleLayout/ConsoleLayout.js +73 -10
- package/dist/components/ConsoleLayout/ConsoleLayout.js.map +1 -1
- package/dist/components/DataTable/DataTable.js +2 -2
- package/dist/components/DataTable/DataTable.js.map +1 -1
- package/dist/components/EmptyState/EmptyState.js +2 -2
- package/dist/components/EmptyState/EmptyState.js.map +1 -1
- package/dist/components/FloorPlan/FloorPlan.js +27 -19
- package/dist/components/FloorPlan/FloorPlan.js.map +1 -1
- package/dist/components/Markdown/Markdown.js +3 -3
- package/dist/components/Markdown/Markdown.js.map +1 -1
- package/dist/components/SideNav/SideNav.js +2 -2
- package/dist/components/SideNav/SideNav.js.map +1 -1
- package/dist/components/SplitPane/SplitPane.js +2 -2
- package/dist/components/SplitPane/SplitPane.js.map +1 -1
- package/dist/css/ConsoleLayout.css +43 -5
- package/dist/css/FloorPlan.css +3 -0
- package/dist/css/KpiCard.css +5 -4
- package/dist/internal/chart.js +2 -2
- package/dist/internal/chart.js.map +1 -1
- package/dist/internal/util.js +8 -1
- package/dist/internal/util.js.map +1 -1
- package/dist/styles.css +51 -9
- package/docs/ConsoleLayout.md +23 -7
- package/docs/agents.md +5 -5
- package/docs/monitoring.md +2 -1
- package/package.json +2 -2
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { InlineCode } from "../InlineCode/InlineCode.js";
|
|
3
3
|
import { announce } from "../../announce.js";
|
|
4
4
|
import { tr } from "../../i18n.js";
|
|
5
|
-
import { copyText, cx, monoNums, useNarrow } from "../../internal/util.js";
|
|
5
|
+
import { copyText, cssZoom, cx, monoNums, useNarrow } from "../../internal/util.js";
|
|
6
6
|
import { devWarn } from "../../internal/dev.js";
|
|
7
7
|
import { CHECK } from "../../icons/Icon.js";
|
|
8
8
|
import { IconButton } from "../IconButton/IconButton.js";
|
|
@@ -170,11 +170,12 @@ function scroller(el) {
|
|
|
170
170
|
* line goes to the top. Nothing moves when they are already in view. */
|
|
171
171
|
function showRange(first, last, pre) {
|
|
172
172
|
const box = scroller(pre);
|
|
173
|
+
const z = cssZoom(box ?? pre);
|
|
173
174
|
const view = box ? (() => {
|
|
174
|
-
const top = box.getBoundingClientRect().top + box.clientTop;
|
|
175
|
+
const top = box.getBoundingClientRect().top + box.clientTop * z;
|
|
175
176
|
return {
|
|
176
177
|
top,
|
|
177
|
-
bottom: top + box.clientHeight
|
|
178
|
+
bottom: top + box.clientHeight * z
|
|
178
179
|
};
|
|
179
180
|
})() : {
|
|
180
181
|
top: 0,
|
|
@@ -186,7 +187,7 @@ function showRange(first, last, pre) {
|
|
|
186
187
|
if (bottom - top > view.bottom - view.top) by = top - view.top;
|
|
187
188
|
else if (top < view.top) by = top - view.top;
|
|
188
189
|
else if (bottom > view.bottom) by = bottom - view.bottom;
|
|
189
|
-
by = Math.round(by);
|
|
190
|
+
by = Math.round(by / z);
|
|
190
191
|
if (!by) return;
|
|
191
192
|
if (box) box.scrollTop += by;
|
|
192
193
|
else window.scrollBy(0, by);
|
|
@@ -353,7 +354,7 @@ function CodeView({ code, start = 1, target, context = 2, file, fileHref, onFile
|
|
|
353
354
|
React.useEffect(() => {
|
|
354
355
|
const b = body.current;
|
|
355
356
|
const el = b?.querySelector(".is-target");
|
|
356
|
-
if (b && el && b.scrollHeight > b.clientHeight && !selectedIn(b)) b.scrollTop += el.getBoundingClientRect().top - b.getBoundingClientRect().top - b.clientHeight / 2 + el.offsetHeight / 2;
|
|
357
|
+
if (b && el && b.scrollHeight > b.clientHeight && !selectedIn(b)) b.scrollTop += (el.getBoundingClientRect().top - b.getBoundingClientRect().top) / cssZoom(b) - b.clientHeight / 2 + el.offsetHeight / 2;
|
|
357
358
|
}, [ta, code]);
|
|
358
359
|
const [pFrom, pTo] = peek == null ? [NaN, NaN] : typeof peek === "number" ? [peek, peek] : [Math.min(peek.from, peek.to), Math.max(peek.from, peek.to)];
|
|
359
360
|
React.useEffect(() => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CodeView.js","names":["phCopy","phKeyboard","builtIn"],"sources":["../../../src/components/CodeView/CodeView.tsx"],"sourcesContent":["import * as React from 'react';\nimport { PreviewCard } from '@base-ui/react/preview-card';\nimport { InlineCode, type OnRef, type RefHref } from '../InlineCode/InlineCode';\nimport { announce } from '../../announce';\nimport { tr } from '../../i18n';\nimport { copyText, cx, monoNums, useNarrow } from '../../internal/util';\nimport { devWarn } from '../../internal/dev';\nimport { CHECK } from '../../icons/Icon';\nimport { IconButton } from '../IconButton/IconButton';\nimport { FloatingPanel } from '../../internal/FloatingPanel';\nimport { findTerms, termPattern, withTerms, type TermDef, type TermHit, type TermsMark } from '../../internal/terms';\nimport { LANGUAGE_NAMES, languageOf, tokenize as builtIn, type Tokenizer } from './tokens';\nimport { includeIcons } from '../../icons/store';\nimport phCopy from '../../icons/ph/copy';\nimport phKeyboard from '../../icons/ph/keyboard';\n\nincludeIcons(phCopy, phKeyboard);\n\n/** A line's indentation, said after its number: a screen reader drops leading spaces, and in Python or YAML\n * the indentation is the structure (which `if` a line belongs to). Tabs and spaces are said apart. */\nfunction indentText(line: string): string {\n const lead = /^[ \\t]*/.exec(line)?.[0] ?? '';\n if (!lead || lead.length === line.length) return '';\n const tabs = lead.split('\\t').length - 1;\n const spaces = lead.length - tabs;\n return (\n tr(',') +\n (tabs && spaces ? tr('縮排 {a} 個 tab、{b} 格', { a: tabs, b: spaces }) : tabs ? tr('縮排 {n} 個 tab', { n: tabs }) : tr('縮排 {n} 格', { n: spaces }))\n );\n}\n\n/** A name in the code that is a link, e.g. a call to a function defined elsewhere. */\nexport interface CodeLink {\n /** Line number, counted from `start` like `target`. */\n line: number;\n /** The name exactly as it is in the code, e.g. `runtime.deploy`: the whole dotted name, never only its last part. */\n text: string;\n /** Column where `text` starts, from 1, in characters (Unicode code points). Without it, the first whole `text` on the\n * line. Convert byte or UTF-16 offsets before passing them. */\n col?: number;\n /** Where the link goes. Ctrl or ⌘ + click (or Enter) follows it when there is no `onLink`; Shift + click and the\n * middle button open it in a new tab or window. */\n href?: string;\n /** Read by screen readers instead of the name, and the native tooltip when there is no `preview`, e.g.\n * 「runtime.deploy,定義在 harness/runtime.py:591」. */\n label?: string;\n}\n\nexport interface CodeViewProps<L extends CodeLink = CodeLink> {\n /** The source text. */\n code: string;\n /** Number of the first line. Default 1. */\n start?: number;\n /** A line or [from, to] to mark. On phones only these lines and `context` lines either side show at first. */\n target?: number | [number, number];\n /** Lines shown either side of the target on phones. Default 2. */\n context?: number;\n /** Path in the header; its extension picks the language. */\n file?: string;\n /** Makes the file name in the header a link. */\n fileHref?: string;\n /** Called when the file name in the header is pressed (a link in an app without URLs). */\n onFile?: (e: React.MouseEvent<HTMLElement>) => void;\n /** Header text when there is no file. */\n title?: string;\n /** 'c' | 'js' | 'py' | 'sh' | 'plain', or any language your tokenizer knows. Default: from the file extension. */\n language?: string;\n /** The language, as plain muted text at the right of the header (C is 「C 語言」); false hides it. */\n languageLabel?: string | false;\n /** false: no syntax colors. */\n highlight?: boolean;\n /** Replaces the built-in highlighter, e.g. one built on Shiki that returns the same token classes. */\n tokenizer?: Tokenizer;\n /** Paths in comments and strings (docs/design/ring.md, src/app.c:86) become links: the link of a path, or undefined\n * for none. Same as CodeText's refHref. */\n refHref?: RefHref;\n /** A plain click on a path in the code (the default navigation is prevented); with refHref, Ctrl, ⌘ or Shift still\n * opens the link. */\n onRef?: OnRef;\n /** Names in the code that are links. Dotted underline; Ctrl or ⌘ + click opens one (a plain click only selects\n * text; on touch screens a tap opens it). With links the code is one Tab stop: ↑ ↓ move by line, ← → between\n * links, Enter opens, Esc goes back to the line. A link that does not match the code is left out, with a\n * warning in development. */\n links?: readonly L[];\n /** Opening a link (Ctrl or ⌘ + click, a tap, or Enter), with the same object you passed in `links`. The default\n * navigation is prevented. */\n onLink?: (link: L, e: React.MouseEvent<HTMLElement> | React.KeyboardEvent<HTMLElement>) => void;\n /** A small card under a link after the pointer or the keyboard focus rests on it for 500 ms, e.g. the name, where it\n * is defined and the first line of its doc comment. */\n preview?: (link: L) => React.ReactNode;\n /** Words in comments and strings that get an explanation: a dashed underline, and the card after the pointer rests\n * on the word for 500 ms, or on Enter. Whole words, case-sensitive; names in the code are never marked, and a name\n * link or a path wins at the same spot. ← → stop on them as on links. */\n terms?: readonly TermDef[];\n /** 'first' (default): each word only where it first appears in the file. 'all': everywhere. */\n termsMark?: TermsMark;\n /** Scrolls inside the box and keeps the target in view, e.g. '420px'. */\n maxHeight?: string;\n /** Where sections start, e.g. each function: [ and ] jump to the previous and next one (CB), and the section's\n * name is read out with its line. Lines count from start, like target. */\n sections?: { line: number; label: string }[];\n /** false: no line numbers, for short snippets nobody refers to by line (Markdown code blocks). Screen readers still\n * hear 「第 n 行」. Default true. */\n lineNumbers?: boolean;\n /** true (default): the header row (file or title, language, buttons). 'float': no row; the language and the\n * buttons float at the top right while the pointer is over the code or focus is in it (always on touch screens),\n * for a page that already shows the file, such as a breadcrumb above. false: nothing. `file` still picks the\n * language either way. */\n header?: boolean | 'float';\n /** A small copy icon at the right of the header: copies the whole code and turns into a check for 2 s. Shows the\n * header even without file or title. Default false. */\n copy?: boolean;\n /** Called after copying, with the text. */\n onCopy?: (text: string) => void;\n /** Copying failed (the browser does not allow the clipboard): say so, for example in a Toast. */\n onCopyError?: () => void;\n /** The reader clicked a line, or moved to one with ↑ ↓ (also Home, End, PageUp, PageDown, [ ]): `how` says which.\n * Dragging to select text is not a move and does not call it. Given this, ↑ ↓ move by line even without links. */\n onLine?: (line: number, how: 'click' | 'key') => void;\n /** Marks a line, or a range of lines (`{ from, to }`, both included), for a moment, apart from `target` (both can\n * show), e.g. while the pointer rests on an item that points at it. Scrolled with the least movement so the whole\n * range is in view; a range taller than the view puts its first line at the top. Focus and selected text stay.\n * null or undefined: none. */\n peek?: number | { from: number; to: number } | null;\n /** Extra class on the root element. */\n className?: string;\n /** focusTarget() moves keyboard and screen-reader focus to the target line. */\n ref?: React.Ref<CodeViewHandle>;\n}\n\nexport interface CodeViewHandle {\n /** Focuses the first target line (scrolled into view); nothing happens without a target, or while the reader has\n * text selected in the code (the selection stays). */\n focusTarget: () => void;\n}\n\n// Where a long line may wrap: after these, never inside them. Multi-character operators stay whole.\nconst OPS = /(->|::|==|!=|<=|>=|&&|\\|\\||\\+\\+|--|<<|>>|=>|\\+=|-=|\\*=|\\/=)/;\nconst AFTER = /([,.([{;])/;\n\n/** A piece of code with soft break points after commas, dots and opening brackets, and operators kept together. */\n// A path in a comment or a string: folders and a file with an extension (docs/design/ring.md), or a file and line\n// (app.c:86, src/app.c:86-90). A bare word with a dot (printf.h, v1.2) is not one.\nconst PATH_IN_CODE = /(?<![\\w./-])((?:\\.{1,2}\\/)?(?:[\\w.-]+\\/)+[\\w.-]+\\.[A-Za-z0-9]+(?::\\d+(?:-\\d+)?)?|[\\w.-]+\\.[A-Za-z0-9]+:\\d+(?:-\\d+)?)(?![\\w/])/g;\n\n/** The paths in a comment or string as links (refHref, onRef); the rest stays text. */\nfunction withPaths(text: string, refHref: RefHref | undefined, onRef: OnRef | undefined, tab?: number): React.ReactNode {\n const out: React.ReactNode[] = [];\n let at = 0;\n for (const m of text.matchAll(PATH_IN_CODE)) {\n const v = m[1];\n const href = refHref ? refHref(v) || undefined : undefined;\n if (refHref ? !href : !onRef) continue;\n if (m.index > at) out.push(breakable(text.slice(at, m.index)));\n const click = onRef\n ? (e: React.MouseEvent<HTMLElement>) => {\n if (href && (e.metaKey || e.ctrlKey || e.shiftKey || e.button === 1)) return;\n e.preventDefault();\n onRef(v, e);\n }\n : undefined;\n // A link when it has an address; else a button, so the keyboard reaches it too.\n out.push(\n href ? (\n <a key={m.index} className=\"ui-cv-ref\" href={href} onClick={click} tabIndex={tab}>\n {v}\n </a>\n ) : (\n <button key={m.index} type=\"button\" className=\"ui-cv-ref\" onClick={click} tabIndex={tab}>\n {v}\n </button>\n ),\n );\n at = m.index + v.length;\n }\n if (!out.length) return breakable(text);\n if (at < text.length) out.push(breakable(text.slice(at)));\n return out;\n}\n\nfunction breakable(text: string): React.ReactNode {\n if (!OPS.test(text) && !AFTER.test(text)) return text;\n const out: React.ReactNode[] = [];\n text.split(OPS).forEach((part, i) => {\n if (!part) return;\n if (i % 2) {\n out.push(\n <span key={i} className=\"ui-cv-op\">\n {part}\n </span>,\n <wbr key={i + 'w'} />,\n );\n return;\n }\n part.split(AFTER).forEach((bit, k) => {\n if (!bit) return;\n out.push(bit);\n if (k % 2) out.push(<wbr key={i + '.' + k} />);\n });\n });\n return out;\n}\n\ninterface Hit {\n from: number;\n to: number;\n /** Index in links. */\n i: number;\n}\n\nconst NAME_CHAR = /[\\p{L}\\p{N}_$]/u;\n\n/** UTF-16 index of a 1-based column counted in code points; -1 past the end. */\nfunction colIndex(s: string, col: number): number {\n let i = 0;\n for (let c = 1; c < col; c++) {\n if (i >= s.length) return -1;\n i += (s.codePointAt(i) ?? 0) > 0xffff ? 2 : 1;\n }\n return i;\n}\n\n/** The first whole `text` on the line: not inside a longer name, and not the tail of a dotted one (x.runtime.deploy). */\nfunction findName(s: string, text: string): number {\n for (let i = s.indexOf(text); i >= 0; i = s.indexOf(text, i + 1)) {\n const before = s[i - 1] ?? '';\n const after = s[i + text.length] ?? '';\n if (!NAME_CHAR.test(before) && before !== '.' && !NAME_CHAR.test(after)) return i;\n }\n return -1;\n}\n\n/** Each line's links, sorted, without overlaps; what does not match is left out with a development warning. */\nfunction matchLinks(lines: string[], start: number, links: readonly CodeLink[] | undefined): Map<number, Hit[]> {\n const out = new Map<number, Hit[]>();\n links?.forEach((l, i) => {\n const s = lines[l.line - start];\n if (s == null) {\n devWarn(true, 'CodeView', `line ${l.line} is not in the code, so the link \"${l.text}\" was not added. Count line from start (${start}), as target does.`);\n return;\n }\n let from = -1;\n if (l.col != null) {\n const at = colIndex(s, l.col);\n if (at >= 0 && s.startsWith(l.text, at)) from = at;\n else\n devWarn(\n true,\n 'CodeView',\n `line ${l.line} column ${l.col} is not \"${l.text}\", so the link was not added. Count col from 1 in characters; convert byte or UTF-16 offsets first.`,\n );\n } else {\n from = findName(s, l.text);\n devWarn(\n from < 0,\n 'CodeView',\n `line ${l.line} has no whole \"${l.text}\", so the link was not added. Make text match the code exactly (the whole dotted name), or pass col.`,\n );\n }\n if (from < 0) return;\n const hit = { from, to: from + l.text.length, i };\n const list = out.get(l.line) ?? [];\n if (list.some((h) => h.from < hit.to && hit.from < h.to)) {\n devWarn(\n true,\n 'CodeView',\n `\"${l.text}\" on line ${l.line} overlaps another link, so it was not added. For a name that appears twice on a line, pass col for the second one.`,\n );\n return;\n }\n list.push(hit);\n out.set(l.line, list);\n });\n for (const list of out.values()) list.sort((a, b) => a.from - b.from);\n return out;\n}\n\n/** True when the reader has text selected inside el. */\nfunction selectedIn(el: Element | null): boolean {\n const sel = typeof window === 'undefined' ? null : window.getSelection();\n if (!el || !sel || sel.isCollapsed || !sel.rangeCount) return false;\n const r = sel.getRangeAt(0);\n return el.contains(r.startContainer) || el.contains(r.endContainer);\n}\n\n/** The selected code as plain text, one line per line; null when the selection is not in pre. */\nfunction selectedCode(pre: HTMLElement): string | null {\n const sel = window.getSelection();\n if (!sel || sel.isCollapsed || !sel.rangeCount) return null;\n const r = sel.getRangeAt(0);\n if (!pre.contains(r.commonAncestorContainer)) return null;\n const frag = r.cloneContents();\n frag.querySelectorAll('.ui-cv-num, .ui-visually-hidden').forEach((x) => x.remove());\n const rows = [...frag.querySelectorAll('[role=\"listitem\"]')];\n return rows.length ? rows.map((x) => x.textContent ?? '').join('\\n') : (frag.textContent ?? '');\n}\n\n/** The nearest box that scrolls el's content: el itself, a parent with overflow auto or scroll, or the page (null). */\nfunction scroller(el: HTMLElement): HTMLElement | null {\n for (let n: HTMLElement | null = el; n && n !== document.body && n !== document.documentElement; n = n.parentElement) {\n const o = getComputedStyle(n).overflowY;\n if ((o === 'auto' || o === 'scroll' || o === 'overlay') && n.scrollHeight > n.clientHeight) return n;\n }\n return null;\n}\n\n/** Scrolls the lines first…last into view with the least movement; when they are taller than the view, the first\n * line goes to the top. Nothing moves when they are already in view. */\nfunction showRange(first: HTMLElement, last: HTMLElement, pre: HTMLElement) {\n const box = scroller(pre);\n const view = box\n ? (() => {\n const r = box.getBoundingClientRect();\n const top = r.top + box.clientTop;\n return { top, bottom: top + box.clientHeight };\n })()\n : { top: 0, bottom: window.innerHeight };\n const top = first.getBoundingClientRect().top;\n const bottom = last.getBoundingClientRect().bottom;\n let by = 0;\n if (bottom - top > view.bottom - view.top) by = top - view.top;\n else if (top < view.top) by = top - view.top;\n else if (bottom > view.bottom) by = bottom - view.bottom;\n by = Math.round(by);\n if (!by) return;\n if (box) box.scrollTop += by;\n else window.scrollBy(0, by);\n}\n\n/** Each line's words from `terms`: only in comments and strings, never where a name link or a path is. With 'first',\n * each word once per file, at its first place. */\nfunction matchTerms(\n toks: readonly (readonly (readonly [string, string])[])[],\n start: number,\n links: Map<number, Hit[]>,\n terms: readonly TermDef[] | undefined,\n mark: TermsMark,\n): Map<number, TermHit[]> {\n const out = new Map<number, TermHit[]>();\n const re = termPattern(terms);\n if (!re || !terms) return out;\n const seen = new Set<string>();\n toks.forEach((line, i) => {\n const n = start + i;\n const taken = links.get(n) ?? [];\n let at = 0;\n for (const [cls, text] of line) {\n if (cls === 'is-comment' || cls === 'is-string') {\n const paths = [...text.matchAll(PATH_IN_CODE)].map((m) => ({ from: at + m.index, to: at + m.index + m[0].length }));\n const free = (from: number, to: number) => ![...taken, ...paths].some((h) => h.from < to && from < h.to);\n // Words that overlap a link or a path are skipped before they count as seen.\n const found = findTerms(text, terms, re, 'all', new Set())\n .map((w) => ({ ...w, from: w.from + at, to: w.to + at }))\n .filter((w) => free(w.from, w.to))\n .filter((w) => {\n if (mark === 'all') return true;\n const t = terms[w.i].term;\n if (seen.has(t)) return false;\n seen.add(t);\n return true;\n });\n if (found.length) out.set(n, [...(out.get(n) ?? []), ...found]);\n }\n at += text.length;\n }\n });\n return out;\n}\n\n/** What the keys do: a small panel opened from the keyboard button or with ?; nothing on screen until asked. */\nfunction KeysPanel(p: {\n open: boolean;\n onOpenChange: (open: boolean) => void;\n trigger: React.ReactElement;\n keys: { k: string; label: string; what: string }[];\n}) {\n return (\n <FloatingPanel\n open={p.open}\n onOpenChange={p.onOpenChange}\n trigger={p.trigger}\n side=\"bottom\"\n align=\"end\"\n className=\"ui-popover ui-cv-keys\"\n aria-label={tr('鍵盤操作')}\n >\n <dl className=\"ui-cv-keylist\">\n {p.keys.map((k) => (\n <div key={k.k}>\n <dt>\n <kbd>{k.label}</kbd>\n </dt>\n <dd>{k.what}</dd>\n </div>\n ))}\n <div>\n <dt>\n <kbd>?</kbd>\n </dt>\n <dd>{tr('顯示或關閉這份說明')}</dd>\n </div>\n </dl>\n </FloatingPanel>\n );\n}\n\n/** Source with line numbers and an optional target line: soft accent background, long lines wrap, light syntax colors. */\nexport function CodeView<L extends CodeLink = CodeLink>({\n code,\n start = 1,\n target,\n context = 2,\n file,\n fileHref,\n onFile,\n title,\n language,\n languageLabel,\n highlight = true,\n tokenizer = builtIn,\n refHref,\n onRef,\n links,\n onLink,\n preview,\n terms,\n termsMark = 'first',\n maxHeight,\n sections,\n copy,\n header = true,\n lineNumbers = true,\n onCopy,\n onCopyError,\n onLine,\n peek,\n className,\n ref,\n}: CodeViewProps<L>) {\n const lines = React.useMemo(\n () =>\n String(code || '')\n .replace(/\\n$/, '')\n .split('\\n'),\n [code],\n );\n const lang = language || languageOf(file);\n const toks = React.useMemo(() => (highlight ? tokenizer(lines, lang) : lines.map((l) => [['', l] as const])), [lines, lang, highlight, tokenizer]);\n const hits = React.useMemo(() => matchLinks(lines, start, links), [lines, start, links]);\n const termHits = React.useMemo(() => matchTerms(toks, start, hits, terms, termsMark), [toks, start, hits, terms, termsMark]);\n const nav = hits.size > 0 || termHits.size > 0;\n const [armed, setArmed] = React.useState(false);\n const inside = React.useRef(false);\n // Ctrl or ⌘ held while the pointer is over the code: the names turn into clickable links (A2).\n React.useEffect(() => {\n if (!nav) return;\n const key = (e: KeyboardEvent) => {\n if (e.key === 'Control' || e.key === 'Meta') setArmed(e.type === 'keydown' && inside.current);\n };\n const off = () => setArmed(false);\n window.addEventListener('keydown', key);\n window.addEventListener('keyup', key);\n window.addEventListener('blur', off);\n return () => {\n window.removeEventListener('keydown', key);\n window.removeEventListener('keyup', key);\n window.removeEventListener('blur', off);\n };\n }, [nav]);\n const [pv, setPv] = React.useState<{ i: number; el: HTMLElement } | null>(null);\n const pvId = React.useId();\n const showTimer = React.useRef<ReturnType<typeof setTimeout>>(undefined);\n const hideTimer = React.useRef<ReturnType<typeof setTimeout>>(undefined);\n React.useEffect(\n () => () => {\n clearTimeout(showTimer.current);\n clearTimeout(hideTimer.current);\n },\n [],\n );\n const pvSoon = (el: HTMLElement) => {\n if (!preview) return;\n clearTimeout(hideTimer.current);\n clearTimeout(showTimer.current);\n if (pv?.el === el) return;\n showTimer.current = setTimeout(() => setPv({ i: Number(el.dataset.link), el }), 500);\n };\n const pvLater = () => {\n clearTimeout(showTimer.current);\n clearTimeout(hideTimer.current);\n hideTimer.current = setTimeout(() => setPv(null), 200);\n };\n const pvKeep = () => clearTimeout(hideTimer.current);\n const linkEl = (t: EventTarget | null) => (t instanceof Element ? t.closest<HTMLElement>('.ui-cv-name') : null);\n const open = (el: HTMLElement, e: React.MouseEvent<HTMLElement> | React.KeyboardEvent<HTMLElement>) => {\n const link = links?.[Number(el.dataset.link)];\n if (!link) return;\n clearTimeout(showTimer.current);\n setPv(null);\n if (onLink) onLink(link, e);\n else if (link.href) window.location.assign(link.href);\n };\n const onLinkClick = (e: React.MouseEvent<HTMLPreElement>) => {\n const el = linkEl(e.target);\n if (!el) return;\n const href = links?.[Number(el.dataset.link)]?.href;\n if (e.shiftKey && href) return; // the browser opens it in a new window\n e.preventDefault();\n const type = (e.nativeEvent as PointerEvent).pointerType;\n // Enter (detail 0), a tap, or Ctrl / ⌘ + click opens; a plain click only selects text.\n if (e.detail === 0 || type === 'touch' || type === 'pen' || e.ctrlKey || e.metaKey) open(el, e);\n };\n const [ta, tb] = target == null ? [null, null] : Array.isArray(target) ? target : [target, target];\n const narrow = useNarrow();\n const [all, setAll] = React.useState(false);\n const [shownFor, setShownFor] = React.useState({ code, ta, tb });\n if (shownFor.code !== code || shownFor.ta !== ta || shownFor.tb !== tb) {\n setShownFor({ code, ta, tb });\n setAll(false);\n }\n const canWindow = ta != null && tb != null && lines.length > tb - ta + 1 + context * 2;\n const windowed = narrow && canWindow && !all;\n const from = windowed ? Math.max(0, ta - start - context) : 0;\n const to = windowed ? Math.min(lines.length, tb - start + context + 1) : lines.length;\n const body = React.useRef<HTMLPreElement>(null);\n React.useImperativeHandle(ref, () => ({\n focusTarget: () => {\n if (selectedIn(body.current)) return;\n body.current?.querySelector<HTMLElement>('.is-target')?.focus();\n },\n }));\n React.useEffect(() => {\n const b = body.current;\n const el = b?.querySelector<HTMLElement>('.is-target');\n // Text the reader selected stays where it is: no scrolling under it.\n if (b && el && b.scrollHeight > b.clientHeight && !selectedIn(b))\n b.scrollTop += el.getBoundingClientRect().top - b.getBoundingClientRect().top - b.clientHeight / 2 + el.offsetHeight / 2;\n }, [ta, code]);\n const [pFrom, pTo] = peek == null ? [NaN, NaN] : typeof peek === 'number' ? [peek, peek] : [Math.min(peek.from, peek.to), Math.max(peek.from, peek.to)];\n React.useEffect(() => {\n if (Number.isNaN(pFrom)) return;\n const pre = body.current;\n if (!pre) return;\n // The lines on the page in the range (on phones only the rows around the target are drawn).\n const rows = [...pre.querySelectorAll<HTMLElement>('[data-n]')].filter((el) => {\n const n = Number(el.dataset.n);\n return n >= pFrom && n <= pTo;\n });\n if (rows.length) showRange(rows[0], rows[rows.length - 1], pre);\n }, [pFrom, pTo]);\n const digits = String(start + lines.length - 1).length;\n const prose = (cls: string, text: string, inLink: boolean) =>\n !inLink && (refHref || onRef) && (cls === 'is-comment' || cls === 'is-string') ? withPaths(text, refHref, onRef, nav ? -1 : undefined) : breakable(text);\n // at: where the piece starts in its line; the words of `terms` inside it become inline Terms.\n const piece = (cls: string, text: string, key: string, inLink: boolean, at = 0, words?: TermHit[]) => {\n const mine = !inLink && terms && words ? words.filter((w) => w.from >= at && w.to <= at + text.length) : [];\n let k = 0;\n const kids =\n mine.length && terms\n ? withTerms(\n text,\n mine.map((w) => ({ ...w, from: w.from - at, to: w.to - at })),\n terms,\n () => key + 't' + k++,\n (t) => prose(cls, t, false),\n { className: 'ui-cv-term', tabIndex: -1, openOnFocus: false },\n )\n : prose(cls, text, inLink);\n return cls ? (\n <span key={key} className={cls}>\n {kids}\n </span>\n ) : (\n <React.Fragment key={key}>{kids}</React.Fragment>\n );\n };\n const nameLink = (hit: Hit, kids: React.ReactNode[]) => {\n const link = links?.[hit.i];\n if (!link) return null;\n return (\n <a\n key={'n' + hit.i}\n className=\"ui-cv-name\"\n href={link.href}\n role={link.href ? undefined : 'link'}\n tabIndex={-1}\n draggable={false}\n data-link={hit.i}\n aria-label={link.label}\n aria-describedby={pv?.i === hit.i ? pvId : undefined}\n title={preview ? undefined : link.label}\n >\n {kids}\n </a>\n );\n };\n // A line's tokens, cut where links start and end; the pieces inside a link go into its <a>.\n const lineContent = (line: readonly (readonly [string, string])[], lineHits: Hit[] | undefined, words: TermHit[] | undefined) => {\n if (!lineHits) {\n let at = 0;\n return line.map(([cls, text], j) => {\n const el = piece(cls, text, String(j), false, at, words);\n at += text.length;\n return el;\n });\n }\n const out: React.ReactNode[] = [];\n let group: React.ReactNode[] = [];\n let open: Hit | null = null;\n const flush = () => {\n if (open) out.push(nameLink(open, group));\n open = null;\n group = [];\n };\n let pos = 0;\n let h = 0;\n line.forEach(([cls, text], j) => {\n let k = 0;\n while (k < text.length) {\n const at = pos + k;\n while (h < lineHits.length && lineHits[h].to <= at) h++;\n const next = lineHits[h];\n const hit = next && next.from <= at ? next : null;\n const end = Math.min(pos + text.length, hit ? hit.to : next ? next.from : Infinity);\n const key = j + '.' + k;\n if (hit) {\n if (open !== hit) {\n flush();\n open = hit;\n }\n group.push(piece(cls, text.slice(k, end - pos), key, true));\n } else {\n flush();\n out.push(piece(cls, text.slice(k, end - pos), key, false, at, words));\n }\n k = end - pos;\n }\n pos += text.length;\n });\n flush();\n return out;\n };\n const rows: React.ReactNode[] = [];\n for (let i = from; i < to; i++) {\n const n = start + i;\n const on = ta != null && tb != null && n >= ta && n <= tb;\n rows.push(\n // One list item per line, so a screen reader moves line by line; 「第 62 行」 is said, not shown or copied.\n <div\n key={i}\n role=\"listitem\"\n className={cx('ui-cv-line', on && 'is-target', n >= pFrom && n <= pTo && 'is-peek')}\n data-n={n}\n aria-current={on && n === ta ? 'location' : undefined}\n tabIndex={on && n === ta ? -1 : undefined}\n >\n {lineNumbers ? (\n // VA: 12 px before the number, 16 px between it and the code.\n <span className=\"ui-cv-num\" style={{ width: `calc(${digits}ch + 28px)` }} aria-hidden=\"true\">\n {n}\n </span>\n ) : null}\n <span className=\"ui-cv-text\">\n <span className=\"ui-visually-hidden ui-cv-sr\">{tr('第 {n} 行', { n }) + indentText(lines[i]) + tr(':')}</span>\n {lineContent(toks[i], hits.get(n), termHits.get(n))}\n </span>\n </div>,\n );\n }\n // CA: Home, End, PageUp, PageDown move the focus by line inside the code; CB: [ and ] by section. The focused line\n // is read out (第 62 行 and its text); a section adds its name.\n const keys = [\n ...(nav\n ? [\n { k: 'ArrowUp ArrowDown', label: '↑↓', what: tr('上一行/下一行') },\n {\n k: 'ArrowLeft ArrowRight',\n label: '←→',\n what: tr(!termHits.size ? '上一個/下一個連結' : hits.size ? '上一個/下一個連結或名詞' : '上一個/下一個名詞'),\n },\n { k: 'Enter', label: 'Enter', what: tr('開啟') },\n { k: 'Escape', label: 'Esc', what: tr('回到這一行') },\n ]\n : []),\n { k: 'Home', label: 'Home', what: tr('第一行') },\n { k: 'End', label: 'End', what: tr('最後一行') },\n { k: 'PageUp', label: 'PgUp', what: tr('上 20 行') },\n { k: 'PageDown', label: 'PgDn', what: tr('下 20 行') },\n ...(sections?.length\n ? [\n { k: '[', label: '[', what: tr('上一段') },\n { k: ']', label: ']', what: tr('下一段') },\n ]\n : []),\n ];\n const onMove = (e: React.KeyboardEvent<HTMLPreElement>) => {\n if (e.altKey || e.ctrlKey || e.metaKey) return;\n // ? shows what the keys do; nothing about them is on screen until asked.\n if (e.key === '?') {\n e.preventDefault();\n byKey.current = true;\n setKeysOpen((o) => !o);\n return;\n }\n const pre = e.currentTarget;\n const items = [...pre.querySelectorAll<HTMLElement>('[role=\"listitem\"]')];\n if (!items.length) return;\n const nOf = (el: HTMLElement) => Number(el.dataset.n);\n const act = document.activeElement instanceof HTMLElement ? document.activeElement : null;\n const curLine = act && act !== pre ? act.closest<HTMLElement>('[role=\"listitem\"]') : null;\n const at = curLine ? items.indexOf(curLine) : -1;\n const now = at < 0 ? -1 : at;\n const focusLine = (el: HTMLElement | undefined) => {\n if (!el) return;\n el.tabIndex = -1;\n el.focus();\n onLine?.(nOf(el), 'key');\n };\n if (onLine && !nav && (e.key === 'ArrowUp' || e.key === 'ArrowDown')) {\n e.preventDefault();\n if (now < 0) focusLine(items.find((el) => el.classList.contains('is-target')) ?? items[0]);\n else focusLine(items[Math.max(0, Math.min(items.length - 1, now + (e.key === 'ArrowDown' ? 1 : -1)))]);\n return;\n }\n if (nav) {\n const stops = [...pre.querySelectorAll<HTMLElement>('.ui-cv-name, .ui-cv-ref, .ui-cv-term')];\n const onStop = act ? stops.indexOf(act) : -1;\n if (e.key === 'Escape') {\n // An open explanation closes by itself; focus stays on the word.\n if (act?.classList.contains('ui-cv-term') && act.getAttribute('aria-expanded') === 'true') return;\n if (pv) setPv(null);\n else if (onStop >= 0) focusLine(curLine ?? undefined);\n else if (curLine) pre.focus();\n else return;\n e.preventDefault();\n return;\n }\n if (e.key === 'Enter' && act && onStop >= 0 && act.classList.contains('ui-cv-name') && !act.hasAttribute('href')) {\n e.preventDefault();\n open(act, e);\n return;\n }\n if (e.key === 'ArrowUp' || e.key === 'ArrowDown') {\n e.preventDefault();\n if (now < 0) focusLine(items.find((el) => el.classList.contains('is-target')) ?? items[0]);\n else focusLine(items[Math.max(0, Math.min(items.length - 1, now + (e.key === 'ArrowDown' ? 1 : -1)))]);\n return;\n }\n if (e.key === 'ArrowLeft' || e.key === 'ArrowRight') {\n e.preventDefault();\n const fwd = e.key === 'ArrowRight';\n let to: HTMLElement | undefined;\n if (onStop >= 0) to = stops[onStop + (fwd ? 1 : -1)];\n else {\n const n = curLine ? nOf(curLine) : (ta ?? nOf(items[0]));\n const lineOf = (el: HTMLElement) => Number(el.closest<HTMLElement>('[role=\"listitem\"]')?.dataset.n);\n to = fwd ? stops.find((el) => lineOf(el) >= n) : stops.filter((el) => lineOf(el) <= n).pop();\n }\n to?.focus();\n return;\n }\n }\n let to = -1;\n let said = '';\n if (e.key === 'Home') to = 0;\n else if (e.key === 'End') to = items.length - 1;\n else if (e.key === 'PageDown') to = Math.min(items.length - 1, Math.max(0, now) + 20);\n else if (e.key === 'PageUp') to = Math.max(0, now - 20);\n else if ((e.key === '[' || e.key === ']') && sections?.length) {\n const cur = now < 0 ? (e.key === ']' ? -Infinity : Infinity) : nOf(items[now]);\n const sorted = [...sections].sort((a, b) => a.line - b.line);\n const s = e.key === ']' ? sorted.find((x) => x.line > cur) : [...sorted].reverse().find((x) => x.line < cur);\n if (s) {\n to = items.findIndex((el) => nOf(el) >= s.line);\n said = s.label;\n }\n } else return;\n e.preventDefault();\n const el = items[to];\n if (!el) return;\n el.tabIndex = -1;\n el.focus();\n onLine?.(nOf(el), 'key');\n if (said) announce(tr('{name},第 {n} 行', { name: said, n: nOf(el) }));\n };\n // A click on a line (not a drag that selected text, not a link, a path or a word that opens something).\n const onLineClick = (e: React.MouseEvent<HTMLPreElement>) => {\n if (!onLine) return;\n const t = e.target instanceof Element ? e.target : null;\n if (!t) return;\n const type = (e.nativeEvent as PointerEvent).pointerType;\n // A name opened (Ctrl / ⌘ + click, a tap, Enter) or a path or word pressed is not a move; a plain click on a name is.\n if (t.closest('.ui-cv-name') && (e.detail === 0 || type === 'touch' || type === 'pen' || e.ctrlKey || e.metaKey)) return;\n if (t.closest('a:not(.ui-cv-name), button:not(.ui-cv-name)')) return;\n if (selectedIn(e.currentTarget)) return;\n const row = t.closest<HTMLElement>('[role=\"listitem\"]');\n if (row) onLine(Number(row.dataset.n), 'click');\n };\n // Copying lines gives the code only: no line numbers, no text for screen readers, wrapped lines joined.\n const onCopyText = (e: React.ClipboardEvent<HTMLPreElement>) => {\n const text = selectedCode(e.currentTarget);\n if (text == null) return;\n e.preventDefault();\n e.clipboardData.setData('text/plain', text);\n };\n const [copied, setCopied] = React.useState(false);\n const [keysOpen, setKeysOpen] = React.useState(false);\n // Opened with ? from the code: closing puts focus back in the code.\n const byKey = React.useRef(false);\n const copyTimer = React.useRef<ReturnType<typeof setTimeout>>(undefined);\n React.useEffect(() => () => clearTimeout(copyTimer.current), []);\n const doCopy = () => {\n copyText(code).then(\n () => {\n setCopied(true);\n announce(tr('已複製'));\n clearTimeout(copyTimer.current);\n copyTimer.current = setTimeout(() => setCopied(false), 2000);\n onCopy?.(code);\n },\n () => onCopyError?.(),\n );\n };\n const langText =\n languageLabel !== false && lang !== 'plain' ? (\n // Plain text, not a control: the screen reader hears 「程式語言:C 語言」.\n <span className=\"ui-cv-lang\">\n <span className=\"ui-visually-hidden\">{tr('程式語言') + tr(':')}</span>\n {tr(languageLabel || LANGUAGE_NAMES[lang] || lang)}\n </span>\n ) : null;\n const copyBtn = copy ? (\n <IconButton\n className={cx('ui-cv-copy', copied && 'is-copied')}\n variant={header === 'float' ? 'quiet' : undefined}\n label={copied ? tr('已複製') : tr('複製程式碼')}\n icon={copied ? CHECK : 'copy'}\n onClick={doCopy}\n />\n ) : null;\n const onKeysChange = (o: boolean) => {\n setKeysOpen(o);\n if (!o && byKey.current) {\n byKey.current = false;\n requestAnimationFrame(() => body.current?.focus());\n }\n };\n const keysPanel = (trigger: React.ReactElement) => <KeysPanel open={keysOpen} onOpenChange={onKeysChange} trigger={trigger} keys={keys} />;\n const keysBtn = keysPanel(<IconButton variant=\"quiet\" icon=\"keyboard\" label={tr('鍵盤操作')} onClick={() => (byKey.current = false)} />);\n const head =\n header === 'float' ? (\n <div className=\"ui-cv-tools\">\n {langText}\n {copyBtn}\n {keysBtn}\n </div>\n ) : header === false ? (\n // No header: ? still opens the list, placed at the code's top right.\n keysPanel(<span className=\"ui-cv-keyanchor\" aria-hidden=\"true\" />)\n ) : file || title || copy ? (\n <div className=\"ui-cv-head\">\n {file ? (\n fileHref || onFile ? (\n <InlineCode href={fileHref} onClick={onFile} className=\"ui-cv-file\">\n {file}\n </InlineCode>\n ) : (\n <span className=\"ui-cv-file\">{file}</span>\n )\n ) : title ? (\n <span className=\"ui-cv-title\">{title}</span>\n ) : null}\n {langText}\n {copyBtn}\n {keysBtn}\n </div>\n ) : (\n keysPanel(<span className=\"ui-cv-keyanchor\" aria-hidden=\"true\" />)\n );\n return (\n <div\n className={cx('ui-cv', !lineNumbers && 'no-nums', header === 'float' && 'is-float', className)}\n // A region (a landmark) only when it has a name of its own; a nameless block (a fence in Markdown) is a group named by\n // its language, so a document with many code blocks does not get many 「原始碼」 landmarks.\n role={file || title ? 'region' : 'group'}\n aria-label={\n file || title || (lang !== 'plain' ? tr('{lang} 程式碼', { lang: tr((languageLabel || undefined) ?? LANGUAGE_NAMES[lang] ?? lang) }) : tr('原始碼'))\n }\n >\n {head}\n <pre\n ref={body}\n style={maxHeight ? { maxHeight } : undefined}\n tabIndex={0}\n aria-label={tr('程式碼')}\n aria-keyshortcuts={[...keys.map((k) => k.k), '?'].join(' ')}\n onKeyDown={onMove}\n onCopy={onCopyText}\n onClick={nav ? undefined : onLineClick}\n {...(nav\n ? {\n onClick: (e: React.MouseEvent<HTMLPreElement>) => {\n onLinkClick(e);\n onLineClick(e);\n },\n onPointerEnter: () => (inside.current = true),\n onPointerLeave: () => {\n inside.current = false;\n setArmed(false);\n },\n onPointerMove: (e: React.PointerEvent) => {\n const held = e.ctrlKey || e.metaKey;\n if (held !== armed) setArmed(held);\n },\n onPointerOver: (e: React.PointerEvent) => {\n const el = linkEl(e.target);\n if (el && e.pointerType === 'mouse') pvSoon(el);\n },\n onPointerOut: (e: React.PointerEvent) => {\n const el = linkEl(e.target);\n if (el && !el.contains(e.relatedTarget as Node | null)) pvLater();\n },\n onFocus: (e: React.FocusEvent) => {\n const el = linkEl(e.target);\n if (el && el.matches(':focus-visible')) pvSoon(el);\n },\n onBlur: (e: React.FocusEvent) => {\n if (linkEl(e.target)) pvLater();\n },\n }\n : null)}\n className={cx('ui-cv-body', armed && 'is-armed')}\n >\n <code role=\"list\">{rows}</code>\n </pre>\n {preview && pv && links?.[pv.i] ? (\n <PreviewCard.Root open onOpenChange={(o) => (o ? undefined : setPv(null))}>\n <PreviewCard.Portal>\n <PreviewCard.Positioner anchor={pv.el} side=\"bottom\" align=\"start\" sideOffset={6} className=\"ui-float\">\n <PreviewCard.Popup id={pvId} className=\"ui-popover ui-cv-preview\" onPointerEnter={pvKeep} onPointerLeave={pvLater}>\n {preview(links[pv.i])}\n </PreviewCard.Popup>\n </PreviewCard.Positioner>\n </PreviewCard.Portal>\n </PreviewCard.Root>\n ) : null}\n {narrow && canWindow ? (\n <button type=\"button\" className=\"ui-link-btn ui-cv-more\" onClick={() => setAll(!all)}>\n <span>{all ? tr('只顯示第 {n} 行前後', { n: ta }) : monoNums(tr('顯示全部 {n} 行', { n: '\\u0001' }), [lines.length])}</span>\n </button>\n ) : null}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAgBA,aAAaA,cAAQC,gBAAU;;;AAI/B,SAAS,WAAW,MAAsB;CACxC,MAAM,OAAO,UAAU,KAAK,IAAI,CAAC,GAAG,MAAM;CAC1C,IAAI,CAAC,QAAQ,KAAK,WAAW,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AAM,KAAK,OAAO,EAAE,MAAM;MAC1B,IAAI,MAAM,GAAG,QAAQ,gBAAgB,GAAG,OAAO,EAAE;KACnD;KACA,SAAS,MAAwB;MAC/B,IAAI,OAAO,EAAE,MAAM,GAAG,QAAQ;KAChC;IACF,IACA;IACJ,WAAW,GAAG,cAAc,SAAS,UAAU;IAE/C,UAAA,oBAAC,QAAD;KAAM,MAAK;KAAQ,UAAA;IAAW,CAAA;GAC3B,CAAA;GACJ,WAAW,MAAM,QAAQ,GAAG,KAC3B,oBAAC,YAAY,MAAb;IAAkB,MAAA;IAAK,eAAe,MAAO,IAAI,KAAA,IAAY,MAAM,IAAI;IACrE,UAAA,oBAAC,YAAY,QAAb,EAAA,UACE,oBAAC,YAAY,YAAb;KAAwB,QAAQ,GAAG;KAAI,MAAK;KAAS,OAAM;KAAQ,YAAY;KAAG,WAAU;KAC1F,UAAA,oBAAC,YAAY,OAAb;MAAmB,IAAI;MAAM,WAAU;MAA2B,gBAAgB;MAAQ,gBAAgB;MACvG,UAAA,QAAQ,MAAM,GAAG,EAAE;KACH,CAAA;IACG,CAAA,EACN,CAAA;GACJ,CAAA,IAChB;GACH,UAAU,YACT,oBAAC,UAAD;IAAQ,MAAK;IAAS,WAAU;IAAyB,eAAe,OAAO,CAAC,GAAG;IACjF,UAAA,oBAAC,QAAD,EAAA,UAAO,MAAM,GAAG,gBAAgB,EAAE,GAAG,GAAG,CAAC,IAAI,SAAS,GAAG,cAAc,EAAE,GAAG,IAAS,CAAC,GAAG,CAAC,MAAM,MAAM,CAAC,EAAQ,CAAA;GACzG,CAAA,IACN;EACD;;AAET"}
|
|
1
|
+
{"version":3,"file":"CodeView.js","names":["phCopy","phKeyboard","builtIn"],"sources":["../../../src/components/CodeView/CodeView.tsx"],"sourcesContent":["import * as React from 'react';\nimport { PreviewCard } from '@base-ui/react/preview-card';\nimport { InlineCode, type OnRef, type RefHref } from '../InlineCode/InlineCode';\nimport { announce } from '../../announce';\nimport { tr } from '../../i18n';\nimport { copyText, cssZoom, cx, monoNums, useNarrow } from '../../internal/util';\nimport { devWarn } from '../../internal/dev';\nimport { CHECK } from '../../icons/Icon';\nimport { IconButton } from '../IconButton/IconButton';\nimport { FloatingPanel } from '../../internal/FloatingPanel';\nimport { findTerms, termPattern, withTerms, type TermDef, type TermHit, type TermsMark } from '../../internal/terms';\nimport { LANGUAGE_NAMES, languageOf, tokenize as builtIn, type Tokenizer } from './tokens';\nimport { includeIcons } from '../../icons/store';\nimport phCopy from '../../icons/ph/copy';\nimport phKeyboard from '../../icons/ph/keyboard';\n\nincludeIcons(phCopy, phKeyboard);\n\n/** A line's indentation, said after its number: a screen reader drops leading spaces, and in Python or YAML\n * the indentation is the structure (which `if` a line belongs to). Tabs and spaces are said apart. */\nfunction indentText(line: string): string {\n const lead = /^[ \\t]*/.exec(line)?.[0] ?? '';\n if (!lead || lead.length === line.length) return '';\n const tabs = lead.split('\\t').length - 1;\n const spaces = lead.length - tabs;\n return (\n tr(',') +\n (tabs && spaces ? tr('縮排 {a} 個 tab、{b} 格', { a: tabs, b: spaces }) : tabs ? tr('縮排 {n} 個 tab', { n: tabs }) : tr('縮排 {n} 格', { n: spaces }))\n );\n}\n\n/** A name in the code that is a link, e.g. a call to a function defined elsewhere. */\nexport interface CodeLink {\n /** Line number, counted from `start` like `target`. */\n line: number;\n /** The name exactly as it is in the code, e.g. `runtime.deploy`: the whole dotted name, never only its last part. */\n text: string;\n /** Column where `text` starts, from 1, in characters (Unicode code points). Without it, the first whole `text` on the\n * line. Convert byte or UTF-16 offsets before passing them. */\n col?: number;\n /** Where the link goes. Ctrl or ⌘ + click (or Enter) follows it when there is no `onLink`; Shift + click and the\n * middle button open it in a new tab or window. */\n href?: string;\n /** Read by screen readers instead of the name, and the native tooltip when there is no `preview`, e.g.\n * 「runtime.deploy,定義在 harness/runtime.py:591」. */\n label?: string;\n}\n\nexport interface CodeViewProps<L extends CodeLink = CodeLink> {\n /** The source text. */\n code: string;\n /** Number of the first line. Default 1. */\n start?: number;\n /** A line or [from, to] to mark. On phones only these lines and `context` lines either side show at first. */\n target?: number | [number, number];\n /** Lines shown either side of the target on phones. Default 2. */\n context?: number;\n /** Path in the header; its extension picks the language. */\n file?: string;\n /** Makes the file name in the header a link. */\n fileHref?: string;\n /** Called when the file name in the header is pressed (a link in an app without URLs). */\n onFile?: (e: React.MouseEvent<HTMLElement>) => void;\n /** Header text when there is no file. */\n title?: string;\n /** 'c' | 'js' | 'py' | 'sh' | 'plain', or any language your tokenizer knows. Default: from the file extension. */\n language?: string;\n /** The language, as plain muted text at the right of the header (C is 「C 語言」); false hides it. */\n languageLabel?: string | false;\n /** false: no syntax colors. */\n highlight?: boolean;\n /** Replaces the built-in highlighter, e.g. one built on Shiki that returns the same token classes. */\n tokenizer?: Tokenizer;\n /** Paths in comments and strings (docs/design/ring.md, src/app.c:86) become links: the link of a path, or undefined\n * for none. Same as CodeText's refHref. */\n refHref?: RefHref;\n /** A plain click on a path in the code (the default navigation is prevented); with refHref, Ctrl, ⌘ or Shift still\n * opens the link. */\n onRef?: OnRef;\n /** Names in the code that are links. Dotted underline; Ctrl or ⌘ + click opens one (a plain click only selects\n * text; on touch screens a tap opens it). With links the code is one Tab stop: ↑ ↓ move by line, ← → between\n * links, Enter opens, Esc goes back to the line. A link that does not match the code is left out, with a\n * warning in development. */\n links?: readonly L[];\n /** Opening a link (Ctrl or ⌘ + click, a tap, or Enter), with the same object you passed in `links`. The default\n * navigation is prevented. */\n onLink?: (link: L, e: React.MouseEvent<HTMLElement> | React.KeyboardEvent<HTMLElement>) => void;\n /** A small card under a link after the pointer or the keyboard focus rests on it for 500 ms, e.g. the name, where it\n * is defined and the first line of its doc comment. */\n preview?: (link: L) => React.ReactNode;\n /** Words in comments and strings that get an explanation: a dashed underline, and the card after the pointer rests\n * on the word for 500 ms, or on Enter. Whole words, case-sensitive; names in the code are never marked, and a name\n * link or a path wins at the same spot. ← → stop on them as on links. */\n terms?: readonly TermDef[];\n /** 'first' (default): each word only where it first appears in the file. 'all': everywhere. */\n termsMark?: TermsMark;\n /** Scrolls inside the box and keeps the target in view, e.g. '420px'. */\n maxHeight?: string;\n /** Where sections start, e.g. each function: [ and ] jump to the previous and next one (CB), and the section's\n * name is read out with its line. Lines count from start, like target. */\n sections?: { line: number; label: string }[];\n /** false: no line numbers, for short snippets nobody refers to by line (Markdown code blocks). Screen readers still\n * hear 「第 n 行」. Default true. */\n lineNumbers?: boolean;\n /** true (default): the header row (file or title, language, buttons). 'float': no row; the language and the\n * buttons float at the top right while the pointer is over the code or focus is in it (always on touch screens),\n * for a page that already shows the file, such as a breadcrumb above. false: nothing. `file` still picks the\n * language either way. */\n header?: boolean | 'float';\n /** A small copy icon at the right of the header: copies the whole code and turns into a check for 2 s. Shows the\n * header even without file or title. Default false. */\n copy?: boolean;\n /** Called after copying, with the text. */\n onCopy?: (text: string) => void;\n /** Copying failed (the browser does not allow the clipboard): say so, for example in a Toast. */\n onCopyError?: () => void;\n /** The reader clicked a line, or moved to one with ↑ ↓ (also Home, End, PageUp, PageDown, [ ]): `how` says which.\n * Dragging to select text is not a move and does not call it. Given this, ↑ ↓ move by line even without links. */\n onLine?: (line: number, how: 'click' | 'key') => void;\n /** Marks a line, or a range of lines (`{ from, to }`, both included), for a moment, apart from `target` (both can\n * show), e.g. while the pointer rests on an item that points at it. Scrolled with the least movement so the whole\n * range is in view; a range taller than the view puts its first line at the top. Focus and selected text stay.\n * null or undefined: none. */\n peek?: number | { from: number; to: number } | null;\n /** Extra class on the root element. */\n className?: string;\n /** focusTarget() moves keyboard and screen-reader focus to the target line. */\n ref?: React.Ref<CodeViewHandle>;\n}\n\nexport interface CodeViewHandle {\n /** Focuses the first target line (scrolled into view); nothing happens without a target, or while the reader has\n * text selected in the code (the selection stays). */\n focusTarget: () => void;\n}\n\n// Where a long line may wrap: after these, never inside them. Multi-character operators stay whole.\nconst OPS = /(->|::|==|!=|<=|>=|&&|\\|\\||\\+\\+|--|<<|>>|=>|\\+=|-=|\\*=|\\/=)/;\nconst AFTER = /([,.([{;])/;\n\n/** A piece of code with soft break points after commas, dots and opening brackets, and operators kept together. */\n// A path in a comment or a string: folders and a file with an extension (docs/design/ring.md), or a file and line\n// (app.c:86, src/app.c:86-90). A bare word with a dot (printf.h, v1.2) is not one.\nconst PATH_IN_CODE = /(?<![\\w./-])((?:\\.{1,2}\\/)?(?:[\\w.-]+\\/)+[\\w.-]+\\.[A-Za-z0-9]+(?::\\d+(?:-\\d+)?)?|[\\w.-]+\\.[A-Za-z0-9]+:\\d+(?:-\\d+)?)(?![\\w/])/g;\n\n/** The paths in a comment or string as links (refHref, onRef); the rest stays text. */\nfunction withPaths(text: string, refHref: RefHref | undefined, onRef: OnRef | undefined, tab?: number): React.ReactNode {\n const out: React.ReactNode[] = [];\n let at = 0;\n for (const m of text.matchAll(PATH_IN_CODE)) {\n const v = m[1];\n const href = refHref ? refHref(v) || undefined : undefined;\n if (refHref ? !href : !onRef) continue;\n if (m.index > at) out.push(breakable(text.slice(at, m.index)));\n const click = onRef\n ? (e: React.MouseEvent<HTMLElement>) => {\n if (href && (e.metaKey || e.ctrlKey || e.shiftKey || e.button === 1)) return;\n e.preventDefault();\n onRef(v, e);\n }\n : undefined;\n // A link when it has an address; else a button, so the keyboard reaches it too.\n out.push(\n href ? (\n <a key={m.index} className=\"ui-cv-ref\" href={href} onClick={click} tabIndex={tab}>\n {v}\n </a>\n ) : (\n <button key={m.index} type=\"button\" className=\"ui-cv-ref\" onClick={click} tabIndex={tab}>\n {v}\n </button>\n ),\n );\n at = m.index + v.length;\n }\n if (!out.length) return breakable(text);\n if (at < text.length) out.push(breakable(text.slice(at)));\n return out;\n}\n\nfunction breakable(text: string): React.ReactNode {\n if (!OPS.test(text) && !AFTER.test(text)) return text;\n const out: React.ReactNode[] = [];\n text.split(OPS).forEach((part, i) => {\n if (!part) return;\n if (i % 2) {\n out.push(\n <span key={i} className=\"ui-cv-op\">\n {part}\n </span>,\n <wbr key={i + 'w'} />,\n );\n return;\n }\n part.split(AFTER).forEach((bit, k) => {\n if (!bit) return;\n out.push(bit);\n if (k % 2) out.push(<wbr key={i + '.' + k} />);\n });\n });\n return out;\n}\n\ninterface Hit {\n from: number;\n to: number;\n /** Index in links. */\n i: number;\n}\n\nconst NAME_CHAR = /[\\p{L}\\p{N}_$]/u;\n\n/** UTF-16 index of a 1-based column counted in code points; -1 past the end. */\nfunction colIndex(s: string, col: number): number {\n let i = 0;\n for (let c = 1; c < col; c++) {\n if (i >= s.length) return -1;\n i += (s.codePointAt(i) ?? 0) > 0xffff ? 2 : 1;\n }\n return i;\n}\n\n/** The first whole `text` on the line: not inside a longer name, and not the tail of a dotted one (x.runtime.deploy). */\nfunction findName(s: string, text: string): number {\n for (let i = s.indexOf(text); i >= 0; i = s.indexOf(text, i + 1)) {\n const before = s[i - 1] ?? '';\n const after = s[i + text.length] ?? '';\n if (!NAME_CHAR.test(before) && before !== '.' && !NAME_CHAR.test(after)) return i;\n }\n return -1;\n}\n\n/** Each line's links, sorted, without overlaps; what does not match is left out with a development warning. */\nfunction matchLinks(lines: string[], start: number, links: readonly CodeLink[] | undefined): Map<number, Hit[]> {\n const out = new Map<number, Hit[]>();\n links?.forEach((l, i) => {\n const s = lines[l.line - start];\n if (s == null) {\n devWarn(true, 'CodeView', `line ${l.line} is not in the code, so the link \"${l.text}\" was not added. Count line from start (${start}), as target does.`);\n return;\n }\n let from = -1;\n if (l.col != null) {\n const at = colIndex(s, l.col);\n if (at >= 0 && s.startsWith(l.text, at)) from = at;\n else\n devWarn(\n true,\n 'CodeView',\n `line ${l.line} column ${l.col} is not \"${l.text}\", so the link was not added. Count col from 1 in characters; convert byte or UTF-16 offsets first.`,\n );\n } else {\n from = findName(s, l.text);\n devWarn(\n from < 0,\n 'CodeView',\n `line ${l.line} has no whole \"${l.text}\", so the link was not added. Make text match the code exactly (the whole dotted name), or pass col.`,\n );\n }\n if (from < 0) return;\n const hit = { from, to: from + l.text.length, i };\n const list = out.get(l.line) ?? [];\n if (list.some((h) => h.from < hit.to && hit.from < h.to)) {\n devWarn(\n true,\n 'CodeView',\n `\"${l.text}\" on line ${l.line} overlaps another link, so it was not added. For a name that appears twice on a line, pass col for the second one.`,\n );\n return;\n }\n list.push(hit);\n out.set(l.line, list);\n });\n for (const list of out.values()) list.sort((a, b) => a.from - b.from);\n return out;\n}\n\n/** True when the reader has text selected inside el. */\nfunction selectedIn(el: Element | null): boolean {\n const sel = typeof window === 'undefined' ? null : window.getSelection();\n if (!el || !sel || sel.isCollapsed || !sel.rangeCount) return false;\n const r = sel.getRangeAt(0);\n return el.contains(r.startContainer) || el.contains(r.endContainer);\n}\n\n/** The selected code as plain text, one line per line; null when the selection is not in pre. */\nfunction selectedCode(pre: HTMLElement): string | null {\n const sel = window.getSelection();\n if (!sel || sel.isCollapsed || !sel.rangeCount) return null;\n const r = sel.getRangeAt(0);\n if (!pre.contains(r.commonAncestorContainer)) return null;\n const frag = r.cloneContents();\n frag.querySelectorAll('.ui-cv-num, .ui-visually-hidden').forEach((x) => x.remove());\n const rows = [...frag.querySelectorAll('[role=\"listitem\"]')];\n return rows.length ? rows.map((x) => x.textContent ?? '').join('\\n') : (frag.textContent ?? '');\n}\n\n/** The nearest box that scrolls el's content: el itself, a parent with overflow auto or scroll, or the page (null). */\nfunction scroller(el: HTMLElement): HTMLElement | null {\n for (let n: HTMLElement | null = el; n && n !== document.body && n !== document.documentElement; n = n.parentElement) {\n const o = getComputedStyle(n).overflowY;\n if ((o === 'auto' || o === 'scroll' || o === 'overlay') && n.scrollHeight > n.clientHeight) return n;\n }\n return null;\n}\n\n/** Scrolls the lines first…last into view with the least movement; when they are taller than the view, the first\n * line goes to the top. Nothing moves when they are already in view. */\nfunction showRange(first: HTMLElement, last: HTMLElement, pre: HTMLElement) {\n const box = scroller(pre);\n // Rects are in screen px; clientTop, clientHeight and scrollTop in CSS px (they differ under CSS zoom).\n const z = cssZoom(box ?? pre);\n const view = box\n ? (() => {\n const r = box.getBoundingClientRect();\n const top = r.top + box.clientTop * z;\n return { top, bottom: top + box.clientHeight * z };\n })()\n : { top: 0, bottom: window.innerHeight };\n const top = first.getBoundingClientRect().top;\n const bottom = last.getBoundingClientRect().bottom;\n let by = 0;\n if (bottom - top > view.bottom - view.top) by = top - view.top;\n else if (top < view.top) by = top - view.top;\n else if (bottom > view.bottom) by = bottom - view.bottom;\n by = Math.round(by / z);\n if (!by) return;\n if (box) box.scrollTop += by;\n else window.scrollBy(0, by);\n}\n\n/** Each line's words from `terms`: only in comments and strings, never where a name link or a path is. With 'first',\n * each word once per file, at its first place. */\nfunction matchTerms(\n toks: readonly (readonly (readonly [string, string])[])[],\n start: number,\n links: Map<number, Hit[]>,\n terms: readonly TermDef[] | undefined,\n mark: TermsMark,\n): Map<number, TermHit[]> {\n const out = new Map<number, TermHit[]>();\n const re = termPattern(terms);\n if (!re || !terms) return out;\n const seen = new Set<string>();\n toks.forEach((line, i) => {\n const n = start + i;\n const taken = links.get(n) ?? [];\n let at = 0;\n for (const [cls, text] of line) {\n if (cls === 'is-comment' || cls === 'is-string') {\n const paths = [...text.matchAll(PATH_IN_CODE)].map((m) => ({ from: at + m.index, to: at + m.index + m[0].length }));\n const free = (from: number, to: number) => ![...taken, ...paths].some((h) => h.from < to && from < h.to);\n // Words that overlap a link or a path are skipped before they count as seen.\n const found = findTerms(text, terms, re, 'all', new Set())\n .map((w) => ({ ...w, from: w.from + at, to: w.to + at }))\n .filter((w) => free(w.from, w.to))\n .filter((w) => {\n if (mark === 'all') return true;\n const t = terms[w.i].term;\n if (seen.has(t)) return false;\n seen.add(t);\n return true;\n });\n if (found.length) out.set(n, [...(out.get(n) ?? []), ...found]);\n }\n at += text.length;\n }\n });\n return out;\n}\n\n/** What the keys do: a small panel opened from the keyboard button or with ?; nothing on screen until asked. */\nfunction KeysPanel(p: {\n open: boolean;\n onOpenChange: (open: boolean) => void;\n trigger: React.ReactElement;\n keys: { k: string; label: string; what: string }[];\n}) {\n return (\n <FloatingPanel\n open={p.open}\n onOpenChange={p.onOpenChange}\n trigger={p.trigger}\n side=\"bottom\"\n align=\"end\"\n className=\"ui-popover ui-cv-keys\"\n aria-label={tr('鍵盤操作')}\n >\n <dl className=\"ui-cv-keylist\">\n {p.keys.map((k) => (\n <div key={k.k}>\n <dt>\n <kbd>{k.label}</kbd>\n </dt>\n <dd>{k.what}</dd>\n </div>\n ))}\n <div>\n <dt>\n <kbd>?</kbd>\n </dt>\n <dd>{tr('顯示或關閉這份說明')}</dd>\n </div>\n </dl>\n </FloatingPanel>\n );\n}\n\n/** Source with line numbers and an optional target line: soft accent background, long lines wrap, light syntax colors. */\nexport function CodeView<L extends CodeLink = CodeLink>({\n code,\n start = 1,\n target,\n context = 2,\n file,\n fileHref,\n onFile,\n title,\n language,\n languageLabel,\n highlight = true,\n tokenizer = builtIn,\n refHref,\n onRef,\n links,\n onLink,\n preview,\n terms,\n termsMark = 'first',\n maxHeight,\n sections,\n copy,\n header = true,\n lineNumbers = true,\n onCopy,\n onCopyError,\n onLine,\n peek,\n className,\n ref,\n}: CodeViewProps<L>) {\n const lines = React.useMemo(\n () =>\n String(code || '')\n .replace(/\\n$/, '')\n .split('\\n'),\n [code],\n );\n const lang = language || languageOf(file);\n const toks = React.useMemo(() => (highlight ? tokenizer(lines, lang) : lines.map((l) => [['', l] as const])), [lines, lang, highlight, tokenizer]);\n const hits = React.useMemo(() => matchLinks(lines, start, links), [lines, start, links]);\n const termHits = React.useMemo(() => matchTerms(toks, start, hits, terms, termsMark), [toks, start, hits, terms, termsMark]);\n const nav = hits.size > 0 || termHits.size > 0;\n const [armed, setArmed] = React.useState(false);\n const inside = React.useRef(false);\n // Ctrl or ⌘ held while the pointer is over the code: the names turn into clickable links (A2).\n React.useEffect(() => {\n if (!nav) return;\n const key = (e: KeyboardEvent) => {\n if (e.key === 'Control' || e.key === 'Meta') setArmed(e.type === 'keydown' && inside.current);\n };\n const off = () => setArmed(false);\n window.addEventListener('keydown', key);\n window.addEventListener('keyup', key);\n window.addEventListener('blur', off);\n return () => {\n window.removeEventListener('keydown', key);\n window.removeEventListener('keyup', key);\n window.removeEventListener('blur', off);\n };\n }, [nav]);\n const [pv, setPv] = React.useState<{ i: number; el: HTMLElement } | null>(null);\n const pvId = React.useId();\n const showTimer = React.useRef<ReturnType<typeof setTimeout>>(undefined);\n const hideTimer = React.useRef<ReturnType<typeof setTimeout>>(undefined);\n React.useEffect(\n () => () => {\n clearTimeout(showTimer.current);\n clearTimeout(hideTimer.current);\n },\n [],\n );\n const pvSoon = (el: HTMLElement) => {\n if (!preview) return;\n clearTimeout(hideTimer.current);\n clearTimeout(showTimer.current);\n if (pv?.el === el) return;\n showTimer.current = setTimeout(() => setPv({ i: Number(el.dataset.link), el }), 500);\n };\n const pvLater = () => {\n clearTimeout(showTimer.current);\n clearTimeout(hideTimer.current);\n hideTimer.current = setTimeout(() => setPv(null), 200);\n };\n const pvKeep = () => clearTimeout(hideTimer.current);\n const linkEl = (t: EventTarget | null) => (t instanceof Element ? t.closest<HTMLElement>('.ui-cv-name') : null);\n const open = (el: HTMLElement, e: React.MouseEvent<HTMLElement> | React.KeyboardEvent<HTMLElement>) => {\n const link = links?.[Number(el.dataset.link)];\n if (!link) return;\n clearTimeout(showTimer.current);\n setPv(null);\n if (onLink) onLink(link, e);\n else if (link.href) window.location.assign(link.href);\n };\n const onLinkClick = (e: React.MouseEvent<HTMLPreElement>) => {\n const el = linkEl(e.target);\n if (!el) return;\n const href = links?.[Number(el.dataset.link)]?.href;\n if (e.shiftKey && href) return; // the browser opens it in a new window\n e.preventDefault();\n const type = (e.nativeEvent as PointerEvent).pointerType;\n // Enter (detail 0), a tap, or Ctrl / ⌘ + click opens; a plain click only selects text.\n if (e.detail === 0 || type === 'touch' || type === 'pen' || e.ctrlKey || e.metaKey) open(el, e);\n };\n const [ta, tb] = target == null ? [null, null] : Array.isArray(target) ? target : [target, target];\n const narrow = useNarrow();\n const [all, setAll] = React.useState(false);\n const [shownFor, setShownFor] = React.useState({ code, ta, tb });\n if (shownFor.code !== code || shownFor.ta !== ta || shownFor.tb !== tb) {\n setShownFor({ code, ta, tb });\n setAll(false);\n }\n const canWindow = ta != null && tb != null && lines.length > tb - ta + 1 + context * 2;\n const windowed = narrow && canWindow && !all;\n const from = windowed ? Math.max(0, ta - start - context) : 0;\n const to = windowed ? Math.min(lines.length, tb - start + context + 1) : lines.length;\n const body = React.useRef<HTMLPreElement>(null);\n React.useImperativeHandle(ref, () => ({\n focusTarget: () => {\n if (selectedIn(body.current)) return;\n body.current?.querySelector<HTMLElement>('.is-target')?.focus();\n },\n }));\n React.useEffect(() => {\n const b = body.current;\n const el = b?.querySelector<HTMLElement>('.is-target');\n // Text the reader selected stays where it is: no scrolling under it.\n if (b && el && b.scrollHeight > b.clientHeight && !selectedIn(b))\n b.scrollTop += (el.getBoundingClientRect().top - b.getBoundingClientRect().top) / cssZoom(b) - b.clientHeight / 2 + el.offsetHeight / 2;\n }, [ta, code]);\n const [pFrom, pTo] = peek == null ? [NaN, NaN] : typeof peek === 'number' ? [peek, peek] : [Math.min(peek.from, peek.to), Math.max(peek.from, peek.to)];\n React.useEffect(() => {\n if (Number.isNaN(pFrom)) return;\n const pre = body.current;\n if (!pre) return;\n // The lines on the page in the range (on phones only the rows around the target are drawn).\n const rows = [...pre.querySelectorAll<HTMLElement>('[data-n]')].filter((el) => {\n const n = Number(el.dataset.n);\n return n >= pFrom && n <= pTo;\n });\n if (rows.length) showRange(rows[0], rows[rows.length - 1], pre);\n }, [pFrom, pTo]);\n const digits = String(start + lines.length - 1).length;\n const prose = (cls: string, text: string, inLink: boolean) =>\n !inLink && (refHref || onRef) && (cls === 'is-comment' || cls === 'is-string') ? withPaths(text, refHref, onRef, nav ? -1 : undefined) : breakable(text);\n // at: where the piece starts in its line; the words of `terms` inside it become inline Terms.\n const piece = (cls: string, text: string, key: string, inLink: boolean, at = 0, words?: TermHit[]) => {\n const mine = !inLink && terms && words ? words.filter((w) => w.from >= at && w.to <= at + text.length) : [];\n let k = 0;\n const kids =\n mine.length && terms\n ? withTerms(\n text,\n mine.map((w) => ({ ...w, from: w.from - at, to: w.to - at })),\n terms,\n () => key + 't' + k++,\n (t) => prose(cls, t, false),\n { className: 'ui-cv-term', tabIndex: -1, openOnFocus: false },\n )\n : prose(cls, text, inLink);\n return cls ? (\n <span key={key} className={cls}>\n {kids}\n </span>\n ) : (\n <React.Fragment key={key}>{kids}</React.Fragment>\n );\n };\n const nameLink = (hit: Hit, kids: React.ReactNode[]) => {\n const link = links?.[hit.i];\n if (!link) return null;\n return (\n <a\n key={'n' + hit.i}\n className=\"ui-cv-name\"\n href={link.href}\n role={link.href ? undefined : 'link'}\n tabIndex={-1}\n draggable={false}\n data-link={hit.i}\n aria-label={link.label}\n aria-describedby={pv?.i === hit.i ? pvId : undefined}\n title={preview ? undefined : link.label}\n >\n {kids}\n </a>\n );\n };\n // A line's tokens, cut where links start and end; the pieces inside a link go into its <a>.\n const lineContent = (line: readonly (readonly [string, string])[], lineHits: Hit[] | undefined, words: TermHit[] | undefined) => {\n if (!lineHits) {\n let at = 0;\n return line.map(([cls, text], j) => {\n const el = piece(cls, text, String(j), false, at, words);\n at += text.length;\n return el;\n });\n }\n const out: React.ReactNode[] = [];\n let group: React.ReactNode[] = [];\n let open: Hit | null = null;\n const flush = () => {\n if (open) out.push(nameLink(open, group));\n open = null;\n group = [];\n };\n let pos = 0;\n let h = 0;\n line.forEach(([cls, text], j) => {\n let k = 0;\n while (k < text.length) {\n const at = pos + k;\n while (h < lineHits.length && lineHits[h].to <= at) h++;\n const next = lineHits[h];\n const hit = next && next.from <= at ? next : null;\n const end = Math.min(pos + text.length, hit ? hit.to : next ? next.from : Infinity);\n const key = j + '.' + k;\n if (hit) {\n if (open !== hit) {\n flush();\n open = hit;\n }\n group.push(piece(cls, text.slice(k, end - pos), key, true));\n } else {\n flush();\n out.push(piece(cls, text.slice(k, end - pos), key, false, at, words));\n }\n k = end - pos;\n }\n pos += text.length;\n });\n flush();\n return out;\n };\n const rows: React.ReactNode[] = [];\n for (let i = from; i < to; i++) {\n const n = start + i;\n const on = ta != null && tb != null && n >= ta && n <= tb;\n rows.push(\n // One list item per line, so a screen reader moves line by line; 「第 62 行」 is said, not shown or copied.\n <div\n key={i}\n role=\"listitem\"\n className={cx('ui-cv-line', on && 'is-target', n >= pFrom && n <= pTo && 'is-peek')}\n data-n={n}\n aria-current={on && n === ta ? 'location' : undefined}\n tabIndex={on && n === ta ? -1 : undefined}\n >\n {lineNumbers ? (\n // VA: 12 px before the number, 16 px between it and the code.\n <span className=\"ui-cv-num\" style={{ width: `calc(${digits}ch + 28px)` }} aria-hidden=\"true\">\n {n}\n </span>\n ) : null}\n <span className=\"ui-cv-text\">\n <span className=\"ui-visually-hidden ui-cv-sr\">{tr('第 {n} 行', { n }) + indentText(lines[i]) + tr(':')}</span>\n {lineContent(toks[i], hits.get(n), termHits.get(n))}\n </span>\n </div>,\n );\n }\n // CA: Home, End, PageUp, PageDown move the focus by line inside the code; CB: [ and ] by section. The focused line\n // is read out (第 62 行 and its text); a section adds its name.\n const keys = [\n ...(nav\n ? [\n { k: 'ArrowUp ArrowDown', label: '↑↓', what: tr('上一行/下一行') },\n {\n k: 'ArrowLeft ArrowRight',\n label: '←→',\n what: tr(!termHits.size ? '上一個/下一個連結' : hits.size ? '上一個/下一個連結或名詞' : '上一個/下一個名詞'),\n },\n { k: 'Enter', label: 'Enter', what: tr('開啟') },\n { k: 'Escape', label: 'Esc', what: tr('回到這一行') },\n ]\n : []),\n { k: 'Home', label: 'Home', what: tr('第一行') },\n { k: 'End', label: 'End', what: tr('最後一行') },\n { k: 'PageUp', label: 'PgUp', what: tr('上 20 行') },\n { k: 'PageDown', label: 'PgDn', what: tr('下 20 行') },\n ...(sections?.length\n ? [\n { k: '[', label: '[', what: tr('上一段') },\n { k: ']', label: ']', what: tr('下一段') },\n ]\n : []),\n ];\n const onMove = (e: React.KeyboardEvent<HTMLPreElement>) => {\n if (e.altKey || e.ctrlKey || e.metaKey) return;\n // ? shows what the keys do; nothing about them is on screen until asked.\n if (e.key === '?') {\n e.preventDefault();\n byKey.current = true;\n setKeysOpen((o) => !o);\n return;\n }\n const pre = e.currentTarget;\n const items = [...pre.querySelectorAll<HTMLElement>('[role=\"listitem\"]')];\n if (!items.length) return;\n const nOf = (el: HTMLElement) => Number(el.dataset.n);\n const act = document.activeElement instanceof HTMLElement ? document.activeElement : null;\n const curLine = act && act !== pre ? act.closest<HTMLElement>('[role=\"listitem\"]') : null;\n const at = curLine ? items.indexOf(curLine) : -1;\n const now = at < 0 ? -1 : at;\n const focusLine = (el: HTMLElement | undefined) => {\n if (!el) return;\n el.tabIndex = -1;\n el.focus();\n onLine?.(nOf(el), 'key');\n };\n if (onLine && !nav && (e.key === 'ArrowUp' || e.key === 'ArrowDown')) {\n e.preventDefault();\n if (now < 0) focusLine(items.find((el) => el.classList.contains('is-target')) ?? items[0]);\n else focusLine(items[Math.max(0, Math.min(items.length - 1, now + (e.key === 'ArrowDown' ? 1 : -1)))]);\n return;\n }\n if (nav) {\n const stops = [...pre.querySelectorAll<HTMLElement>('.ui-cv-name, .ui-cv-ref, .ui-cv-term')];\n const onStop = act ? stops.indexOf(act) : -1;\n if (e.key === 'Escape') {\n // An open explanation closes by itself; focus stays on the word.\n if (act?.classList.contains('ui-cv-term') && act.getAttribute('aria-expanded') === 'true') return;\n if (pv) setPv(null);\n else if (onStop >= 0) focusLine(curLine ?? undefined);\n else if (curLine) pre.focus();\n else return;\n e.preventDefault();\n return;\n }\n if (e.key === 'Enter' && act && onStop >= 0 && act.classList.contains('ui-cv-name') && !act.hasAttribute('href')) {\n e.preventDefault();\n open(act, e);\n return;\n }\n if (e.key === 'ArrowUp' || e.key === 'ArrowDown') {\n e.preventDefault();\n if (now < 0) focusLine(items.find((el) => el.classList.contains('is-target')) ?? items[0]);\n else focusLine(items[Math.max(0, Math.min(items.length - 1, now + (e.key === 'ArrowDown' ? 1 : -1)))]);\n return;\n }\n if (e.key === 'ArrowLeft' || e.key === 'ArrowRight') {\n e.preventDefault();\n const fwd = e.key === 'ArrowRight';\n let to: HTMLElement | undefined;\n if (onStop >= 0) to = stops[onStop + (fwd ? 1 : -1)];\n else {\n const n = curLine ? nOf(curLine) : (ta ?? nOf(items[0]));\n const lineOf = (el: HTMLElement) => Number(el.closest<HTMLElement>('[role=\"listitem\"]')?.dataset.n);\n to = fwd ? stops.find((el) => lineOf(el) >= n) : stops.filter((el) => lineOf(el) <= n).pop();\n }\n to?.focus();\n return;\n }\n }\n let to = -1;\n let said = '';\n if (e.key === 'Home') to = 0;\n else if (e.key === 'End') to = items.length - 1;\n else if (e.key === 'PageDown') to = Math.min(items.length - 1, Math.max(0, now) + 20);\n else if (e.key === 'PageUp') to = Math.max(0, now - 20);\n else if ((e.key === '[' || e.key === ']') && sections?.length) {\n const cur = now < 0 ? (e.key === ']' ? -Infinity : Infinity) : nOf(items[now]);\n const sorted = [...sections].sort((a, b) => a.line - b.line);\n const s = e.key === ']' ? sorted.find((x) => x.line > cur) : [...sorted].reverse().find((x) => x.line < cur);\n if (s) {\n to = items.findIndex((el) => nOf(el) >= s.line);\n said = s.label;\n }\n } else return;\n e.preventDefault();\n const el = items[to];\n if (!el) return;\n el.tabIndex = -1;\n el.focus();\n onLine?.(nOf(el), 'key');\n if (said) announce(tr('{name},第 {n} 行', { name: said, n: nOf(el) }));\n };\n // A click on a line (not a drag that selected text, not a link, a path or a word that opens something).\n const onLineClick = (e: React.MouseEvent<HTMLPreElement>) => {\n if (!onLine) return;\n const t = e.target instanceof Element ? e.target : null;\n if (!t) return;\n const type = (e.nativeEvent as PointerEvent).pointerType;\n // A name opened (Ctrl / ⌘ + click, a tap, Enter) or a path or word pressed is not a move; a plain click on a name is.\n if (t.closest('.ui-cv-name') && (e.detail === 0 || type === 'touch' || type === 'pen' || e.ctrlKey || e.metaKey)) return;\n if (t.closest('a:not(.ui-cv-name), button:not(.ui-cv-name)')) return;\n if (selectedIn(e.currentTarget)) return;\n const row = t.closest<HTMLElement>('[role=\"listitem\"]');\n if (row) onLine(Number(row.dataset.n), 'click');\n };\n // Copying lines gives the code only: no line numbers, no text for screen readers, wrapped lines joined.\n const onCopyText = (e: React.ClipboardEvent<HTMLPreElement>) => {\n const text = selectedCode(e.currentTarget);\n if (text == null) return;\n e.preventDefault();\n e.clipboardData.setData('text/plain', text);\n };\n const [copied, setCopied] = React.useState(false);\n const [keysOpen, setKeysOpen] = React.useState(false);\n // Opened with ? from the code: closing puts focus back in the code.\n const byKey = React.useRef(false);\n const copyTimer = React.useRef<ReturnType<typeof setTimeout>>(undefined);\n React.useEffect(() => () => clearTimeout(copyTimer.current), []);\n const doCopy = () => {\n copyText(code).then(\n () => {\n setCopied(true);\n announce(tr('已複製'));\n clearTimeout(copyTimer.current);\n copyTimer.current = setTimeout(() => setCopied(false), 2000);\n onCopy?.(code);\n },\n () => onCopyError?.(),\n );\n };\n const langText =\n languageLabel !== false && lang !== 'plain' ? (\n // Plain text, not a control: the screen reader hears 「程式語言:C 語言」.\n <span className=\"ui-cv-lang\">\n <span className=\"ui-visually-hidden\">{tr('程式語言') + tr(':')}</span>\n {tr(languageLabel || LANGUAGE_NAMES[lang] || lang)}\n </span>\n ) : null;\n const copyBtn = copy ? (\n <IconButton\n className={cx('ui-cv-copy', copied && 'is-copied')}\n variant={header === 'float' ? 'quiet' : undefined}\n label={copied ? tr('已複製') : tr('複製程式碼')}\n icon={copied ? CHECK : 'copy'}\n onClick={doCopy}\n />\n ) : null;\n const onKeysChange = (o: boolean) => {\n setKeysOpen(o);\n if (!o && byKey.current) {\n byKey.current = false;\n requestAnimationFrame(() => body.current?.focus());\n }\n };\n const keysPanel = (trigger: React.ReactElement) => <KeysPanel open={keysOpen} onOpenChange={onKeysChange} trigger={trigger} keys={keys} />;\n const keysBtn = keysPanel(<IconButton variant=\"quiet\" icon=\"keyboard\" label={tr('鍵盤操作')} onClick={() => (byKey.current = false)} />);\n const head =\n header === 'float' ? (\n <div className=\"ui-cv-tools\">\n {langText}\n {copyBtn}\n {keysBtn}\n </div>\n ) : header === false ? (\n // No header: ? still opens the list, placed at the code's top right.\n keysPanel(<span className=\"ui-cv-keyanchor\" aria-hidden=\"true\" />)\n ) : file || title || copy ? (\n <div className=\"ui-cv-head\">\n {file ? (\n fileHref || onFile ? (\n <InlineCode href={fileHref} onClick={onFile} className=\"ui-cv-file\">\n {file}\n </InlineCode>\n ) : (\n <span className=\"ui-cv-file\">{file}</span>\n )\n ) : title ? (\n <span className=\"ui-cv-title\">{title}</span>\n ) : null}\n {langText}\n {copyBtn}\n {keysBtn}\n </div>\n ) : (\n keysPanel(<span className=\"ui-cv-keyanchor\" aria-hidden=\"true\" />)\n );\n return (\n <div\n className={cx('ui-cv', !lineNumbers && 'no-nums', header === 'float' && 'is-float', className)}\n // A region (a landmark) only when it has a name of its own; a nameless block (a fence in Markdown) is a group named by\n // its language, so a document with many code blocks does not get many 「原始碼」 landmarks.\n role={file || title ? 'region' : 'group'}\n aria-label={\n file || title || (lang !== 'plain' ? tr('{lang} 程式碼', { lang: tr((languageLabel || undefined) ?? LANGUAGE_NAMES[lang] ?? lang) }) : tr('原始碼'))\n }\n >\n {head}\n <pre\n ref={body}\n style={maxHeight ? { maxHeight } : undefined}\n tabIndex={0}\n aria-label={tr('程式碼')}\n aria-keyshortcuts={[...keys.map((k) => k.k), '?'].join(' ')}\n onKeyDown={onMove}\n onCopy={onCopyText}\n onClick={nav ? undefined : onLineClick}\n {...(nav\n ? {\n onClick: (e: React.MouseEvent<HTMLPreElement>) => {\n onLinkClick(e);\n onLineClick(e);\n },\n onPointerEnter: () => (inside.current = true),\n onPointerLeave: () => {\n inside.current = false;\n setArmed(false);\n },\n onPointerMove: (e: React.PointerEvent) => {\n const held = e.ctrlKey || e.metaKey;\n if (held !== armed) setArmed(held);\n },\n onPointerOver: (e: React.PointerEvent) => {\n const el = linkEl(e.target);\n if (el && e.pointerType === 'mouse') pvSoon(el);\n },\n onPointerOut: (e: React.PointerEvent) => {\n const el = linkEl(e.target);\n if (el && !el.contains(e.relatedTarget as Node | null)) pvLater();\n },\n onFocus: (e: React.FocusEvent) => {\n const el = linkEl(e.target);\n if (el && el.matches(':focus-visible')) pvSoon(el);\n },\n onBlur: (e: React.FocusEvent) => {\n if (linkEl(e.target)) pvLater();\n },\n }\n : null)}\n className={cx('ui-cv-body', armed && 'is-armed')}\n >\n <code role=\"list\">{rows}</code>\n </pre>\n {preview && pv && links?.[pv.i] ? (\n <PreviewCard.Root open onOpenChange={(o) => (o ? undefined : setPv(null))}>\n <PreviewCard.Portal>\n <PreviewCard.Positioner anchor={pv.el} side=\"bottom\" align=\"start\" sideOffset={6} className=\"ui-float\">\n <PreviewCard.Popup id={pvId} className=\"ui-popover ui-cv-preview\" onPointerEnter={pvKeep} onPointerLeave={pvLater}>\n {preview(links[pv.i])}\n </PreviewCard.Popup>\n </PreviewCard.Positioner>\n </PreviewCard.Portal>\n </PreviewCard.Root>\n ) : null}\n {narrow && canWindow ? (\n <button type=\"button\" className=\"ui-link-btn ui-cv-more\" onClick={() => setAll(!all)}>\n <span>{all ? tr('只顯示第 {n} 行前後', { n: ta }) : monoNums(tr('顯示全部 {n} 行', { n: '\\u0001' }), [lines.length])}</span>\n </button>\n ) : null}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAgBA,aAAaA,cAAQC,gBAAU;;;AAI/B,SAAS,WAAW,MAAsB;CACxC,MAAM,OAAO,UAAU,KAAK,IAAI,CAAC,GAAG,MAAM;CAC1C,IAAI,CAAC,QAAQ,KAAK,WAAW,KAAK,QAAQ,OAAO;CACjD,MAAM,OAAO,KAAK,MAAM,GAAI,CAAC,CAAC,SAAS;CACvC,MAAM,SAAS,KAAK,SAAS;CAC7B,OACE,GAAG,GAAG,KACL,QAAQ,SAAS,GAAG,sBAAsB;EAAE,GAAG;EAAM,GAAG;CAAO,CAAC,IAAI,OAAO,GAAG,gBAAgB,EAAE,GAAG,KAAK,CAAC,IAAI,GAAG,YAAY,EAAE,GAAG,OAAO,CAAC;AAE9I;AA4GA,MAA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D;KAAM,MAAK;KAAQ,UAAA;IAAW,CAAA;GAC3B,CAAA;GACJ,WAAW,MAAM,QAAQ,GAAG,KAC3B,oBAAC,YAAY,MAAb;IAAkB,MAAA;IAAK,eAAe,MAAO,IAAI,KAAA,IAAY,MAAM,IAAI;IACrE,UAAA,oBAAC,YAAY,QAAb,EAAA,UACE,oBAAC,YAAY,YAAb;KAAwB,QAAQ,GAAG;KAAI,MAAK;KAAS,OAAM;KAAQ,YAAY;KAAG,WAAU;KAC1F,UAAA,oBAAC,YAAY,OAAb;MAAmB,IAAI;MAAM,WAAU;MAA2B,gBAAgB;MAAQ,gBAAgB;MACvG,UAAA,QAAQ,MAAM,GAAG,EAAE;KACH,CAAA;IACG,CAAA,EACN,CAAA;GACJ,CAAA,IAChB;GACH,UAAU,YACT,oBAAC,UAAD;IAAQ,MAAK;IAAS,WAAU;IAAyB,eAAe,OAAO,CAAC,GAAG;IACjF,UAAA,oBAAC,QAAD,EAAA,UAAO,MAAM,GAAG,gBAAgB,EAAE,GAAG,GAAG,CAAC,IAAI,SAAS,GAAG,cAAc,EAAE,GAAG,IAAS,CAAC,GAAG,CAAC,MAAM,MAAM,CAAC,EAAQ,CAAA;GACzG,CAAA,IACN;EACD;;AAET"}
|
|
@@ -3,9 +3,9 @@ import * as React from "react";
|
|
|
3
3
|
export interface ConsoleExtra {
|
|
4
4
|
/** Stable key for the card. */
|
|
5
5
|
id: string;
|
|
6
|
-
/**
|
|
7
|
-
* px,
|
|
8
|
-
minHeight
|
|
6
|
+
/** Optional: also needs the layout's logical height (the screen height divided by the zoom) to be at least this
|
|
7
|
+
* many px. Without it, the card shows whenever it fits under the side cards at its own height. */
|
|
8
|
+
minHeight?: number;
|
|
9
9
|
/** The card: usually a Card. */
|
|
10
10
|
node: React.ReactNode;
|
|
11
11
|
}
|
|
@@ -32,12 +32,18 @@ export interface ConsoleLayoutProps {
|
|
|
32
32
|
/** The bottom row under the main view, as tall as its content: e.g. a LineChart in a Card. The main view takes the
|
|
33
33
|
* height that is left. */
|
|
34
34
|
bottom?: React.ReactNode;
|
|
35
|
-
/** Cards added at the end of the side panel
|
|
35
|
+
/** Cards added at the end of the side panel when they fit there at their own height, in order (the first that does
|
|
36
|
+
* not fit and every one after it stay out): `[{ id, node }]`. Stacked, all of them show. */
|
|
36
37
|
extras?: ConsoleExtra[];
|
|
38
|
+
/** Below this width of the layout (px) everything is one scrolling column (stacked). Default 1100: narrower, the main
|
|
39
|
+
* view beside the side panel would be under 700 px wide. */
|
|
40
|
+
stackedBelow?: number;
|
|
41
|
+
/** 'auto' (default): stacked below `stackedBelow`. 'console': never stacked. 'stacked': always stacked. */
|
|
42
|
+
mode?: 'auto' | 'console' | 'stacked';
|
|
37
43
|
/** Extra class on the root element. */
|
|
38
44
|
className?: string;
|
|
39
45
|
}
|
|
40
46
|
/** A full-screen monitoring layout: a top bar (title, tags, then status, KPIs, clock and full screen on the right),
|
|
41
47
|
* the main view with a side panel beside it and a bottom row under it, filling the screen without scrolling. From
|
|
42
48
|
* 1440 × 900 up everything zooms with the screen (at most 1.5×). Phones (under 600 px) get one scrolling column. */
|
|
43
|
-
export declare function ConsoleLayout({ title, tags, status, kpis, clock, fullscreen, main, side, bottom, extras, className }: ConsoleLayoutProps): React.JSX.Element;
|
|
49
|
+
export declare function ConsoleLayout({ title, tags, status, kpis, clock, fullscreen, main, side, bottom, extras, stackedBelow, mode, className }: ConsoleLayoutProps): React.JSX.Element;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { IconButton } from "../IconButton/IconButton.js";
|
|
3
|
+
import { devWarn } from "../../internal/dev.js";
|
|
3
4
|
import { cx } from "../../internal/util.js";
|
|
4
5
|
import { tr } from "../../i18n.js";
|
|
5
6
|
import { includeIcons } from "../../icons/store.js";
|
|
@@ -13,6 +14,7 @@ includeIcons(corners_in_default, corners_out_default);
|
|
|
13
14
|
const BASE_W = 1440;
|
|
14
15
|
const BASE_H = 900;
|
|
15
16
|
const MAX_ZOOM = 1.5;
|
|
17
|
+
const STACKED_BELOW = 1100;
|
|
16
18
|
const PHONE = 600;
|
|
17
19
|
const noSubscribe = () => () => {};
|
|
18
20
|
const fullscreenEnabled = () => typeof document !== "undefined" && document.fullscreenEnabled === true;
|
|
@@ -24,8 +26,9 @@ function consoleZoom(w, h) {
|
|
|
24
26
|
/** A full-screen monitoring layout: a top bar (title, tags, then status, KPIs, clock and full screen on the right),
|
|
25
27
|
* the main view with a side panel beside it and a bottom row under it, filling the screen without scrolling. From
|
|
26
28
|
* 1440 × 900 up everything zooms with the screen (at most 1.5×). Phones (under 600 px) get one scrolling column. */
|
|
27
|
-
function ConsoleLayout({ title, tags, status, kpis, clock, fullscreen = true, main, side, bottom, extras, className }) {
|
|
29
|
+
function ConsoleLayout({ title, tags, status, kpis, clock, fullscreen = true, main, side, bottom, extras, stackedBelow = STACKED_BELOW, mode = "auto", className }) {
|
|
28
30
|
const ref = React.useRef(null);
|
|
31
|
+
const sideRef = React.useRef(null);
|
|
29
32
|
const [size, setSize] = React.useState(null);
|
|
30
33
|
const [full, setFull] = React.useState(false);
|
|
31
34
|
const canFull = React.useSyncExternalStore(noSubscribe, fullscreenEnabled, serverFalse);
|
|
@@ -53,11 +56,14 @@ function ConsoleLayout({ title, tags, status, kpis, clock, fullscreen = true, ma
|
|
|
53
56
|
if (document.fullscreenElement) document.exitFullscreen().catch(() => void 0);
|
|
54
57
|
else el.requestFullscreen().catch(() => void 0);
|
|
55
58
|
};
|
|
59
|
+
const stacked = mode === "stacked" || mode === "auto" && size != null && size.w < stackedBelow;
|
|
56
60
|
const phone = size != null && size.w < PHONE;
|
|
57
|
-
const
|
|
61
|
+
const zoomH = size ? Math.min(size.h, typeof window !== "undefined" && window.innerHeight || size.h) : 0;
|
|
62
|
+
const zoom = size && !stacked ? consoleZoom(size.w, zoomH) : 1;
|
|
58
63
|
const logicalH = size ? size.h / zoom : 0;
|
|
59
|
-
const
|
|
60
|
-
const
|
|
64
|
+
const allowed = (extras ?? []).filter((x) => stacked || x.minHeight == null || logicalH >= x.minHeight);
|
|
65
|
+
const fit = useExtrasFit(sideRef, stacked ? -1 : allowed.length, `${allowed.map((x) => x.id).join("|")}|${size?.w}|${size?.h}|${zoom}`);
|
|
66
|
+
const frameStyle = size && !stacked && zoom !== 1 ? {
|
|
61
67
|
zoom,
|
|
62
68
|
width: size.w / zoom,
|
|
63
69
|
height: size.h / zoom
|
|
@@ -95,7 +101,7 @@ function ConsoleLayout({ title, tags, status, kpis, clock, fullscreen = true, ma
|
|
|
95
101
|
});
|
|
96
102
|
return /* @__PURE__ */ jsx("div", {
|
|
97
103
|
ref,
|
|
98
|
-
className: cx("ui-console",
|
|
104
|
+
className: cx("ui-console", stacked && "is-stacked", className),
|
|
99
105
|
children: /* @__PURE__ */ jsxs("div", {
|
|
100
106
|
className: "ui-console-frame",
|
|
101
107
|
style: frameStyle,
|
|
@@ -106,24 +112,81 @@ function ConsoleLayout({ title, tags, status, kpis, clock, fullscreen = true, ma
|
|
|
106
112
|
children: [/* @__PURE__ */ jsx("div", {
|
|
107
113
|
className: "ui-console-main",
|
|
108
114
|
children: main
|
|
109
|
-
}),
|
|
110
|
-
side,
|
|
115
|
+
}), stacked ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
116
|
+
side != null ? /* @__PURE__ */ jsx("div", {
|
|
117
|
+
className: "ui-console-cards",
|
|
118
|
+
children: side
|
|
119
|
+
}) : null,
|
|
111
120
|
bottom,
|
|
112
|
-
|
|
121
|
+
allowed.length ? /* @__PURE__ */ jsx("div", {
|
|
122
|
+
className: "ui-console-cards",
|
|
123
|
+
children: allowed.map((x) => /* @__PURE__ */ jsx(React.Fragment, { children: x.node }, x.id))
|
|
124
|
+
}) : null
|
|
113
125
|
] }) : bottom != null ? /* @__PURE__ */ jsx("div", {
|
|
114
126
|
className: "ui-console-bottom",
|
|
115
127
|
children: bottom
|
|
116
128
|
}) : null]
|
|
117
129
|
}),
|
|
118
|
-
|
|
130
|
+
stacked ? null : /* @__PURE__ */ jsxs("aside", {
|
|
131
|
+
ref: sideRef,
|
|
119
132
|
className: "ui-console-side",
|
|
120
133
|
"aria-label": tr("側欄"),
|
|
121
|
-
children: [side,
|
|
134
|
+
children: [side, allowed.map((x, i) => {
|
|
135
|
+
const out = i >= fit;
|
|
136
|
+
return /* @__PURE__ */ jsx("div", {
|
|
137
|
+
className: cx("ui-console-extra", out && "is-out"),
|
|
138
|
+
"data-extra": "",
|
|
139
|
+
"aria-hidden": out || void 0,
|
|
140
|
+
inert: out || void 0,
|
|
141
|
+
children: x.node
|
|
142
|
+
}, x.id);
|
|
143
|
+
})]
|
|
122
144
|
})
|
|
123
145
|
]
|
|
124
146
|
})
|
|
125
147
|
});
|
|
126
148
|
}
|
|
149
|
+
/** How many extras fit in the side panel under its other cards, each at its own height, in order. n is how many there
|
|
150
|
+
* are (-1: none are measured, stacked). Measured again when the panel or any card changes size. */
|
|
151
|
+
function useExtrasFit(sideRef, n, key) {
|
|
152
|
+
const [fit, setFit] = React.useState(0);
|
|
153
|
+
React.useLayoutEffect(() => {
|
|
154
|
+
const side = sideRef.current;
|
|
155
|
+
if (!side || n <= 0) return setFit(0);
|
|
156
|
+
const measure = () => {
|
|
157
|
+
const cs = getComputedStyle(side);
|
|
158
|
+
const gap = parseFloat(cs.rowGap) || 0;
|
|
159
|
+
const room = side.clientHeight - (parseFloat(cs.paddingTop) || 0) - (parseFloat(cs.paddingBottom) || 0);
|
|
160
|
+
const kids = [...side.children];
|
|
161
|
+
const cards = kids.filter((k) => !k.hasAttribute("data-extra"));
|
|
162
|
+
const extraEls = kids.filter((k) => k.hasAttribute("data-extra"));
|
|
163
|
+
devWarn(cards.some((k) => k.scrollHeight > k.clientHeight + 1 && !/auto|scroll/.test(getComputedStyle(k).overflowY)), "ConsoleLayout", "a side card is shorter than its content, so the content is cut. Keep side cards at their own height: do not give them flex: 1 or min-height: 0; the side panel scrolls when they do not fit.");
|
|
164
|
+
let used = cards.reduce((t, k, i) => t + k.offsetHeight + (i ? gap : 0), 0);
|
|
165
|
+
let count = 0;
|
|
166
|
+
for (const ex of extraEls) {
|
|
167
|
+
const need = (ex.classList.contains("is-out") ? ex.firstElementChild?.offsetHeight ?? 0 : ex.offsetHeight) + (used > 0 ? gap : 0);
|
|
168
|
+
if (used + need > room + .5) break;
|
|
169
|
+
used += need;
|
|
170
|
+
count++;
|
|
171
|
+
}
|
|
172
|
+
setFit((f) => f === count ? f : count);
|
|
173
|
+
};
|
|
174
|
+
measure();
|
|
175
|
+
if (typeof ResizeObserver !== "function") return;
|
|
176
|
+
const ro = new ResizeObserver(measure);
|
|
177
|
+
ro.observe(side);
|
|
178
|
+
for (const k of side.children) {
|
|
179
|
+
ro.observe(k);
|
|
180
|
+
if (k.firstElementChild) ro.observe(k.firstElementChild);
|
|
181
|
+
}
|
|
182
|
+
return () => ro.disconnect();
|
|
183
|
+
}, [
|
|
184
|
+
sideRef,
|
|
185
|
+
n,
|
|
186
|
+
key
|
|
187
|
+
]);
|
|
188
|
+
return n < 0 ? 0 : fit;
|
|
189
|
+
}
|
|
127
190
|
export { ConsoleLayout, consoleZoom };
|
|
128
191
|
|
|
129
192
|
//# sourceMappingURL=ConsoleLayout.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConsoleLayout.js","names":["phCornersIn","phCornersOut"],"sources":["../../../src/components/ConsoleLayout/ConsoleLayout.tsx"],"sourcesContent":["import * as React from 'react';\nimport { IconButton } from '../IconButton/IconButton';\nimport { cx } from '../../internal/util';\nimport { tr } from '../../i18n';\nimport { includeIcons } from '../../icons/store';\nimport phCornersIn from '../../icons/ph/corners-in';\nimport phCornersOut from '../../icons/ph/corners-out';\n\nincludeIcons(phCornersIn, phCornersOut);\n\n/** A card that shows only when the screen is tall enough. */\nexport interface ConsoleExtra {\n /** Stable key for the card. */\n id: string;\n /** The card shows when the layout's logical height (the screen height divided by the zoom) is at least this many\n * px, e.g. 1040. */\n minHeight: number;\n /** The card: usually a Card. */\n node: React.ReactNode;\n}\n\nexport interface ConsoleLayoutProps {\n /** The product or screen name, the page's only heading: 「設施監控」. */\n title: string;\n /** Right after the title: a Tag 「示範資料」 with the info icon. Same size and color as the text around it. */\n tags?: React.ReactNode;\n /** Right side, before the KPIs: one short state in plain words, 「AI 最佳化中」. Shown in body size and ink color;\n * pass plain text, not a Badge. */\n status?: React.ReactNode;\n /** Right side: `<KpiCard size=\"compact\" />` side by side. In the top bar they lose their card look and sit between\n * 1 px lines. */\n kpis?: React.ReactNode;\n /** Right side, after the KPIs: the time and whether it is live, 「16:24 即時」. */\n clock?: React.ReactNode;\n /** A 「全螢幕」 button at the right end (Fullscreen API). Default true; hidden where the browser has no full screen. */\n fullscreen?: boolean;\n /** The main view, left of the side panel; it fills its cell (pass one Card, e.g. with a ZoneMap). */\n main: React.ReactNode;\n /** The side panel, 400 px (360 px under 1280 px): cards from top to bottom (TimeControl, EventTimeline). When they\n * do not fit, the side panel scrolls on its own; the page never does. */\n side?: React.ReactNode;\n /** The bottom row under the main view, as tall as its content: e.g. a LineChart in a Card. The main view takes the\n * height that is left. */\n bottom?: React.ReactNode;\n /** Cards added at the end of the side panel on tall screens: `[{ id, minHeight: 1040, node }]`. */\n extras?: ConsoleExtra[];\n /** Extra class on the root element. */\n className?: string;\n}\n\n/** Design size: at this size and up the layout zooms in. */\nconst BASE_W = 1440;\nconst BASE_H = 900;\nconst MAX_ZOOM = 1.5;\nconst PHONE = 600;\n\nconst noSubscribe = () => () => {};\nconst fullscreenEnabled = () => typeof document !== 'undefined' && document.fullscreenEnabled === true;\nconst serverFalse = () => false;\n\n/** Zoom for a screen of w × h px: 1 up to 1440 × 900, then grows with the screen, at most 1.5. */\nexport function consoleZoom(w: number, h: number): number {\n return Math.max(1, Math.min(MAX_ZOOM, Math.min(w / BASE_W, h / BASE_H)));\n}\n\n/** A full-screen monitoring layout: a top bar (title, tags, then status, KPIs, clock and full screen on the right),\n * the main view with a side panel beside it and a bottom row under it, filling the screen without scrolling. From\n * 1440 × 900 up everything zooms with the screen (at most 1.5×). Phones (under 600 px) get one scrolling column. */\nexport function ConsoleLayout({ title, tags, status, kpis, clock, fullscreen = true, main, side, bottom, extras, className }: ConsoleLayoutProps) {\n const ref = React.useRef<HTMLDivElement>(null);\n const [size, setSize] = React.useState<{ w: number; h: number } | null>(null);\n const [full, setFull] = React.useState(false);\n // false on the server and the first browser render, so the markup matches; then whether full screen is allowed.\n const canFull = React.useSyncExternalStore(noSubscribe, fullscreenEnabled, serverFalse);\n\n React.useLayoutEffect(() => {\n const el = ref.current;\n if (!el) return;\n const measure = () => setSize({ w: el.clientWidth, h: el.clientHeight });\n measure();\n if (typeof ResizeObserver === 'undefined') return;\n const ro = new ResizeObserver(measure);\n ro.observe(el);\n return () => ro.disconnect();\n }, []);\n\n React.useEffect(() => {\n const f = () => setFull(document.fullscreenElement != null && document.fullscreenElement === ref.current);\n document.addEventListener('fullscreenchange', f);\n return () => document.removeEventListener('fullscreenchange', f);\n }, []);\n\n const toggleFull = () => {\n const el = ref.current;\n if (!el) return;\n if (document.fullscreenElement) void document.exitFullscreen().catch(() => undefined);\n else void el.requestFullscreen().catch(() => undefined);\n };\n\n const phone = size != null && size.w < PHONE;\n const zoom = size && !phone ? consoleZoom(size.w, size.h) : 1;\n const logicalH = size ? size.h / zoom : 0;\n const shown = (extras ?? []).filter((x) => phone || logicalH >= x.minHeight);\n const frameStyle: React.CSSProperties | undefined =\n size && !phone && zoom !== 1 ? ({ zoom, width: size.w / zoom, height: size.h / zoom } as React.CSSProperties) : undefined;\n\n const top = (\n <header className=\"ui-console-top\">\n <div className=\"ui-console-start\">\n <h1 className=\"ui-console-title\">{title}</h1>\n {tags}\n </div>\n <div className=\"ui-console-end\">\n {status != null ? <span className=\"ui-console-status\">{status}</span> : null}\n {kpis != null ? <div className=\"ui-console-kpis\">{kpis}</div> : null}\n {clock != null ? <span className=\"ui-console-clock\">{clock}</span> : null}\n {fullscreen && canFull && !phone ? (\n <IconButton label={full ? tr('離開全螢幕') : tr('全螢幕')} icon={full ? 'corners-in' : 'corners-out'} onClick={toggleFull} />\n ) : null}\n </div>\n </header>\n );\n\n return (\n <div ref={ref} className={cx('ui-console', phone && 'is-stacked', className)}>\n <div className=\"ui-console-frame\" style={frameStyle}>\n {top}\n {/* The main landmark draws no box (display: contents): the main view and the bottom row stay grid cells, and\n on phones the whole column after the top bar is in it. */}\n <main className=\"ui-console-content\">\n <div className=\"ui-console-main\">{main}</div>\n {phone ? (\n <>\n {side}\n {bottom}\n {shown.map((x) => (\n <React.Fragment key={x.id}>{x.node}</React.Fragment>\n ))}\n </>\n ) : bottom != null ? (\n <div className=\"ui-console-bottom\">{bottom}</div>\n ) : null}\n </main>\n {phone ? null : (\n <aside className=\"ui-console-side\" aria-label={tr('側欄')}>\n {side}\n {shown.map((x) => (\n <React.Fragment key={x.id}>{x.node}</React.Fragment>\n ))}\n </aside>\n )}\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;AAQA,aAAaA,oBAAaC,mBAAY;;AA2CtC,MAAM,SAAS;AACf,MAAM,SAAS;AACf,MAAM,WAAW;AACjB,MAAM,QAAQ;AAEd,MAAM,0BAA0B,CAAC;AACjC,MAAM,0BAA0B,OAAO,aAAa,eAAe,SAAS,sBAAsB;AAClG,MAAM,oBAAoB;;AAG1B,SAAgB,YAAY,GAAW,GAAmB;CACxD,OAAO,KAAK,IAAI,GAAG,KAAK,IAAI,UAAU,KAAK,IAAI,IAAI,QAAQ,IAAI,MAAM,CAAC,CAAC;AACzE;;;;AAKA,SAAgB,cAAc,EAAE,OAAO,MAAM,QAAQ,MAAM,OAAO,aAAa,MAAM,MAAM,MAAM,QAAQ,QAAQ,aAAiC;CAChJ,MAAM,MAAM,MAAM,OAAuB,IAAI;CAC7C,MAAM,CAAC,MAAM,WAAW,MAAM,SAA0C,IAAI;CAC5E,MAAM,CAAC,MAAM,WAAW,MAAM,SAAS,KAAK;CAE5C,MAAM,UAAU,MAAM,qBAAqB,aAAa,mBAAmB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sx"],"sourcesContent":["import * as React from 'react';\nimport { IconButton } from '../IconButton/IconButton';\nimport { devWarn } from '../../internal/dev';\nimport { cx } from '../../internal/util';\nimport { tr } from '../../i18n';\nimport { includeIcons } from '../../icons/store';\nimport phCornersIn from '../../icons/ph/corners-in';\nimport phCornersOut from '../../icons/ph/corners-out';\n\nincludeIcons(phCornersIn, phCornersOut);\n\n/** A card that shows only when the screen is tall enough. */\nexport interface ConsoleExtra {\n /** Stable key for the card. */\n id: string;\n /** Optional: also needs the layout's logical height (the screen height divided by the zoom) to be at least this\n * many px. Without it, the card shows whenever it fits under the side cards at its own height. */\n minHeight?: number;\n /** The card: usually a Card. */\n node: React.ReactNode;\n}\n\nexport interface ConsoleLayoutProps {\n /** The product or screen name, the page's only heading: 「設施監控」. */\n title: string;\n /** Right after the title: a Tag 「示範資料」 with the info icon. Same size and color as the text around it. */\n tags?: React.ReactNode;\n /** Right side, before the KPIs: one short state in plain words, 「AI 最佳化中」. Shown in body size and ink color;\n * pass plain text, not a Badge. */\n status?: React.ReactNode;\n /** Right side: `<KpiCard size=\"compact\" />` side by side. In the top bar they lose their card look and sit between\n * 1 px lines. */\n kpis?: React.ReactNode;\n /** Right side, after the KPIs: the time and whether it is live, 「16:24 即時」. */\n clock?: React.ReactNode;\n /** A 「全螢幕」 button at the right end (Fullscreen API). Default true; hidden where the browser has no full screen. */\n fullscreen?: boolean;\n /** The main view, left of the side panel; it fills its cell (pass one Card, e.g. with a ZoneMap). */\n main: React.ReactNode;\n /** The side panel, 400 px (360 px under 1280 px): cards from top to bottom (TimeControl, EventTimeline). When they\n * do not fit, the side panel scrolls on its own; the page never does. */\n side?: React.ReactNode;\n /** The bottom row under the main view, as tall as its content: e.g. a LineChart in a Card. The main view takes the\n * height that is left. */\n bottom?: React.ReactNode;\n /** Cards added at the end of the side panel when they fit there at their own height, in order (the first that does\n * not fit and every one after it stay out): `[{ id, node }]`. Stacked, all of them show. */\n extras?: ConsoleExtra[];\n /** Below this width of the layout (px) everything is one scrolling column (stacked). Default 1100: narrower, the main\n * view beside the side panel would be under 700 px wide. */\n stackedBelow?: number;\n /** 'auto' (default): stacked below `stackedBelow`. 'console': never stacked. 'stacked': always stacked. */\n mode?: 'auto' | 'console' | 'stacked';\n /** Extra class on the root element. */\n className?: string;\n}\n\n/** Design size: at this size and up the layout zooms in. */\nconst BASE_W = 1440;\nconst BASE_H = 900;\nconst MAX_ZOOM = 1.5;\nconst STACKED_BELOW = 1100;\nconst PHONE = 600;\n\nconst noSubscribe = () => () => {};\nconst fullscreenEnabled = () => typeof document !== 'undefined' && document.fullscreenEnabled === true;\nconst serverFalse = () => false;\n\n/** Zoom for a screen of w × h px: 1 up to 1440 × 900, then grows with the screen, at most 1.5. */\nexport function consoleZoom(w: number, h: number): number {\n return Math.max(1, Math.min(MAX_ZOOM, Math.min(w / BASE_W, h / BASE_H)));\n}\n\n/** A full-screen monitoring layout: a top bar (title, tags, then status, KPIs, clock and full screen on the right),\n * the main view with a side panel beside it and a bottom row under it, filling the screen without scrolling. From\n * 1440 × 900 up everything zooms with the screen (at most 1.5×). Phones (under 600 px) get one scrolling column. */\nexport function ConsoleLayout({\n title,\n tags,\n status,\n kpis,\n clock,\n fullscreen = true,\n main,\n side,\n bottom,\n extras,\n stackedBelow = STACKED_BELOW,\n mode = 'auto',\n className,\n}: ConsoleLayoutProps) {\n const ref = React.useRef<HTMLDivElement>(null);\n const sideRef = React.useRef<HTMLElement>(null);\n const [size, setSize] = React.useState<{ w: number; h: number } | null>(null);\n const [full, setFull] = React.useState(false);\n // false on the server and the first browser render, so the markup matches; then whether full screen is allowed.\n const canFull = React.useSyncExternalStore(noSubscribe, fullscreenEnabled, serverFalse);\n\n React.useLayoutEffect(() => {\n const el = ref.current;\n if (!el) return;\n const measure = () => setSize({ w: el.clientWidth, h: el.clientHeight });\n measure();\n if (typeof ResizeObserver === 'undefined') return;\n const ro = new ResizeObserver(measure);\n ro.observe(el);\n return () => ro.disconnect();\n }, []);\n\n React.useEffect(() => {\n const f = () => setFull(document.fullscreenElement != null && document.fullscreenElement === ref.current);\n document.addEventListener('fullscreenchange', f);\n return () => document.removeEventListener('fullscreenchange', f);\n }, []);\n\n const toggleFull = () => {\n const el = ref.current;\n if (!el) return;\n if (document.fullscreenElement) void document.exitFullscreen().catch(() => undefined);\n else void el.requestFullscreen().catch(() => undefined);\n };\n\n const stacked = mode === 'stacked' || (mode === 'auto' && size != null && size.w < stackedBelow);\n const phone = size != null && size.w < PHONE;\n // Stacked, the column scrolls and never zooms.\n // The zoom takes at most the window's height: a layout an app lets grow with its content would otherwise zoom in on\n // its own height.\n const zoomH = size ? Math.min(size.h, (typeof window !== 'undefined' && window.innerHeight) || size.h) : 0;\n const zoom = size && !stacked ? consoleZoom(size.w, zoomH) : 1;\n const logicalH = size ? size.h / zoom : 0;\n const allowed = (extras ?? []).filter((x) => stacked || x.minHeight == null || logicalH >= x.minHeight);\n const fit = useExtrasFit(sideRef, stacked ? -1 : allowed.length, `${allowed.map((x) => x.id).join('|')}|${size?.w}|${size?.h}|${zoom}`);\n const frameStyle: React.CSSProperties | undefined =\n size && !stacked && zoom !== 1 ? ({ zoom, width: size.w / zoom, height: size.h / zoom } as React.CSSProperties) : undefined;\n\n const top = (\n <header className=\"ui-console-top\">\n <div className=\"ui-console-start\">\n <h1 className=\"ui-console-title\">{title}</h1>\n {tags}\n </div>\n <div className=\"ui-console-end\">\n {status != null ? <span className=\"ui-console-status\">{status}</span> : null}\n {kpis != null ? <div className=\"ui-console-kpis\">{kpis}</div> : null}\n {clock != null ? <span className=\"ui-console-clock\">{clock}</span> : null}\n {fullscreen && canFull && !phone ? (\n <IconButton label={full ? tr('離開全螢幕') : tr('全螢幕')} icon={full ? 'corners-in' : 'corners-out'} onClick={toggleFull} />\n ) : null}\n </div>\n </header>\n );\n\n return (\n <div ref={ref} className={cx('ui-console', stacked && 'is-stacked', className)}>\n <div className=\"ui-console-frame\" style={frameStyle}>\n {top}\n {/* The main landmark draws no box (display: contents): the main view and the bottom row stay grid cells, and\n stacked, the whole column after the top bar is in it. */}\n <main className=\"ui-console-content\">\n <div className=\"ui-console-main\">{main}</div>\n {stacked ? (\n <>\n {side != null ? <div className=\"ui-console-cards\">{side}</div> : null}\n {bottom}\n {allowed.length ? (\n <div className=\"ui-console-cards\">\n {allowed.map((x) => (\n <React.Fragment key={x.id}>{x.node}</React.Fragment>\n ))}\n </div>\n ) : null}\n </>\n ) : bottom != null ? (\n <div className=\"ui-console-bottom\">{bottom}</div>\n ) : null}\n </main>\n {stacked ? null : (\n <aside ref={sideRef} className=\"ui-console-side\" aria-label={tr('側欄')}>\n {side}\n {/* Each extra in a wrapper that is measured; one that does not fit is laid out out of sight, at no height,\n so it is measured again when the panel grows. */}\n {allowed.map((x, i) => {\n const out = i >= fit;\n return (\n <div key={x.id} className={cx('ui-console-extra', out && 'is-out')} data-extra=\"\" aria-hidden={out || undefined} inert={out || undefined}>\n {x.node}\n </div>\n );\n })}\n </aside>\n )}\n </div>\n </div>\n );\n}\n\n/** How many extras fit in the side panel under its other cards, each at its own height, in order. n is how many there\n * are (-1: none are measured, stacked). Measured again when the panel or any card changes size. */\nfunction useExtrasFit(sideRef: React.RefObject<HTMLElement | null>, n: number, key: string): number {\n const [fit, setFit] = React.useState(0);\n React.useLayoutEffect(() => {\n const side = sideRef.current;\n if (!side || n <= 0) return setFit(0);\n const measure = () => {\n const cs = getComputedStyle(side);\n const gap = parseFloat(cs.rowGap) || 0;\n const room = side.clientHeight - (parseFloat(cs.paddingTop) || 0) - (parseFloat(cs.paddingBottom) || 0);\n const kids = [...side.children] as HTMLElement[];\n const cards = kids.filter((k) => !k.hasAttribute('data-extra'));\n const extraEls = kids.filter((k) => k.hasAttribute('data-extra'));\n devWarn(\n cards.some((k) => k.scrollHeight > k.clientHeight + 1 && !/auto|scroll/.test(getComputedStyle(k).overflowY)),\n 'ConsoleLayout',\n 'a side card is shorter than its content, so the content is cut. Keep side cards at their own height: do not give them flex: 1 or min-height: 0; the side panel scrolls when they do not fit.',\n );\n let used = cards.reduce((t, k, i) => t + k.offsetHeight + (i ? gap : 0), 0);\n let count = 0;\n for (const ex of extraEls) {\n // An extra out of sight has no height of its own: its card's height counts.\n const h = ex.classList.contains('is-out') ? ((ex.firstElementChild as HTMLElement | null)?.offsetHeight ?? 0) : ex.offsetHeight;\n const need = h + (used > 0 ? gap : 0);\n if (used + need > room + 0.5) break;\n used += need;\n count++;\n }\n setFit((f) => (f === count ? f : count));\n };\n measure();\n if (typeof ResizeObserver !== 'function') return;\n const ro = new ResizeObserver(measure);\n ro.observe(side);\n for (const k of side.children) {\n ro.observe(k);\n if (k.firstElementChild) ro.observe(k.firstElementChild);\n }\n return () => ro.disconnect();\n }, [sideRef, n, key]);\n return n < 0 ? 0 : fit;\n}\n"],"mappings":";;;;;;;;;;;AASA,aAAaA,oBAAaC,mBAAY;;AAiDtC,MAAM,SAAS;AACf,MAAM,SAAS;AACf,MAAM,WAAW;AACjB,MAAM,gBAAgB;AACtB,MAAM,QAAQ;AAEd,MAAM,0BAA0B,CAAC;AACjC,MAAM,0BAA0B,OAAO,aAAa,eAAe,SAAS,sBAAsB;AAClG,MAAM,oBAAoB;;AAG1B,SAAgB,YAAY,GAAW,GAAmB;CACxD,OAAO,KAAK,IAAI,GAAG,KAAK,IAAI,UAAU,KAAK,IAAI,IAAI,QAAQ,IAAI,MAAM,CAAC,CAAC;AACzE;;;;AAKA,SAAgB,cAAc,EAC5B,OACA,MACA,QACA,MACA,OACA,aAAa,MACb,MACA,MACA,QACA,QACA,eAAe,eACf,OAAO,QACP,aACqB;CACrB,MAAM,MAAM,MAAM,OAAuB,IAAI;CAC7C,MAAM,UAAU,MAAM,OAAoB,IAAI;CAC9C,MAAM,CAAC,MAAM,WAAW,MAAM,SAA0C,IAAI;CAC5E,MAAM,CAAC,MAAM,WAAW,MAAM,SAAS,KAAK;CAE5C,MAAM,UAAU,MAAM,qBAAqB,aAAa,mBAAmB,WAAW;CAEtF,MAAM,sBAAsB;EAC1B,MA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AAM,IAAI,EAAE,gBAAgB,IAAI,MAAM,IAAI,CAAC;GAC1E,IAAI,QAAQ;GACZ,KAAK,MAAM,MAAM,UAAU;IAGzB,MAAM,QADI,GAAG,UAAU,SAAS,QAAQ,IAAM,GAAG,mBAA0C,gBAAgB,IAAK,GAAG,iBACjG,OAAO,IAAI,MAAM;IACnC,IAAI,OAAO,OAAO,OAAO,IAAK;IAC9B,QAAQ;IACR;GACF;GACA,QAAQ,MAAO,MAAM,QAAQ,IAAI,KAAM;EACzC;EACA,QAAQ;EACR,IAAI,OAAO,mBAAmB,YAAY;EAC1C,MAAM,KAAK,IAAI,eAAe,OAAO;EACrC,GAAG,QAAQ,IAAI;EACf,KAAK,MAAM,KAAK,KAAK,UAAU;GAC7B,GAAG,QAAQ,CAAC;GACZ,IAAI,EAAE,mBAAmB,GAAG,QAAQ,EAAE,iBAAiB;EACzD;EACA,aAAa,GAAG,WAAW;CAC7B,GAAG;EAAC;EAAS;EAAG;CAAG,CAAC;CACpB,OAAO,IAAI,IAAI,IAAI;AACrB"}
|
|
@@ -5,7 +5,7 @@ import { Tabs } from "../Tabs/Tabs.js";
|
|
|
5
5
|
import { format } from "../../format.js";
|
|
6
6
|
import { tr, unitFor } from "../../i18n.js";
|
|
7
7
|
import { Icon } from "../../icons/Icon.js";
|
|
8
|
-
import { TOUCH_ONLY, copyText, cx, idPart, monoNums, reduced, resizeObserver, seenOnly, useMedia, useNarrow } from "../../internal/util.js";
|
|
8
|
+
import { TOUCH_ONLY, copyText, cssZoom, cx, idPart, monoNums, reduced, resizeObserver, seenOnly, useMedia, useNarrow } from "../../internal/util.js";
|
|
9
9
|
import { Tooltip } from "../Tooltip/Tooltip.js";
|
|
10
10
|
import { Skeleton } from "../Skeleton/Skeleton.js";
|
|
11
11
|
import { RelativeTime } from "../RelativeTime/RelativeTime.js";
|
|
@@ -77,7 +77,7 @@ function contentWidth(el) {
|
|
|
77
77
|
right = Math.max(right, r.right);
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
|
-
return right > left ? right - left : 0;
|
|
80
|
+
return right > left ? (right - left) / cssZoom(el) : 0;
|
|
81
81
|
}
|
|
82
82
|
const shortcutTables = /* @__PURE__ */ new Set();
|
|
83
83
|
const shortcutListeners = /* @__PURE__ */ new Set();
|