@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Markdown.js","names":["phCaretRight"],"sources":["../../../src/components/Markdown/Markdown.tsx"],"sourcesContent":["import * as React from 'react';\nimport { Alert, type AlertTone } from '../Alert/Alert';\nimport { Icon } from '../../icons/Icon';\nimport { ColResize, TableDialog, ZoomButton } from '../../internal/tableTools';\nimport { cx, resizeObserver } from '../../internal/util';\nimport { devWarn } from '../../internal/dev';\nimport { CodeView } from '../CodeView/CodeView';\nimport { languageOf } from '../CodeView/tokens';\nimport { InlineCode, type OnRef, type RefHref } from '../InlineCode/InlineCode';\nimport { AiMark } from '../AiMark/AiMark';\nimport { findTerms, termNode, termPattern, withTerms, type TermDef, type TermsMark } from '../../internal/terms';\nimport { includeIcons } from '../../icons/store';\nimport phCaretRight from '../../icons/ph/caret-right';\n\nincludeIcons(phCaretRight);\n\n/* A small Markdown reader for project documents and code comments. It builds React elements only: no HTML from the\n source is ever run. HTML tags are dropped and their text kept (MX). */\n\ntype Block =\n | { t: 'h'; level: number; text: string }\n | { t: 'p'; text: string }\n | { t: 'code'; lang: string; code: string }\n | { t: 'quote'; blocks: Block[] }\n | { t: 'list'; ordered: boolean; start: number; items: Block[][] }\n | { t: 'table'; head: string[]; align: ('left' | 'right' | 'center' | null)[]; rows: string[][] }\n | { t: 'hr' }\n | { t: 'details'; summary: string; blocks: Block[] }\n | { t: 'alert'; tone: AlertTone; blocks: Block[] };\n\n// DA: <details> and <summary> are the only HTML let through, without attributes; they make a closed block.\nconst DETAILS_OPEN = /^\\s*<details\\b[^>]*>/i;\nconst DETAILS_TAG = /<(\\/?)details\\b[^>]*>/gi;\nconst SUMMARY = /<summary\\b[^>]*>([\\s\\S]*?)<\\/summary>/i;\n// NB: GitHub's alerts, > [!NOTE] and the like, shown as the system's Alert.\nconst ALERT = /^\\s*\\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\\]\\s*$/i;\nconst ALERT_TONE: Record<string, AlertTone> = { NOTE: 'info', TIP: 'success', IMPORTANT: 'info', WARNING: 'warning', CAUTION: 'danger' };\n\nconst FENCE = /^ {0,3}(`{3,}|~{3,})\\s*([\\w+#.-]*)/;\nconst HEADING = /^ {0,3}(#{1,6})(?:\\s+(.*?))?\\s*#*\\s*$/;\nconst HR = /^ {0,3}([-*_])(?:\\s*\\1){2,}\\s*$/;\nconst ITEM = /^( {0,3})([-*+]|\\d{1,9}[.)])(\\s+|$)(.*)$/;\nconst QUOTE = /^ {0,3}> ?(.*)$/;\nconst TABLE_SEP = /^\\s*\\|?\\s*:?-{1,}:?\\s*(\\|\\s*:?-{1,}:?\\s*)*\\|?\\s*$/;\n\nfunction cells(line: string): string[] {\n let s = line.trim();\n if (s.startsWith('|')) s = s.slice(1);\n if (s.endsWith('|') && !s.endsWith('\\\\|')) s = s.slice(0, -1);\n const out: string[] = [];\n let cur = '';\n let code = false;\n for (let i = 0; i < s.length; i++) {\n const c = s[i];\n if (c === '\\\\' && s[i + 1] === '|') {\n cur += '|';\n i++;\n } else if (c === '`') {\n code = !code;\n cur += c;\n } else if (c === '|' && !code) {\n out.push(cur.trim());\n cur = '';\n } else cur += c;\n }\n out.push(cur.trim());\n return out;\n}\n\nconst blank = (l: string) => !l.trim();\nconst startsBlock = (l: string) => FENCE.test(l) || HEADING.test(l) || HR.test(l) || QUOTE.test(l) || ITEM.test(l);\n\nfunction parse(lines: string[]): Block[] {\n const out: Block[] = [];\n let i = 0;\n while (i < lines.length) {\n const line = lines[i];\n if (blank(line)) {\n i++;\n continue;\n }\n if (DETAILS_OPEN.test(line)) {\n // The matching </details>, counting nested ones; what follows it on the line goes on as more Markdown.\n const rest = lines.slice(i).join('\\n');\n DETAILS_TAG.lastIndex = 0;\n let depth = 0;\n let open = -1;\n let close = rest.length;\n let after = rest.length;\n for (let m = DETAILS_TAG.exec(rest); m; m = DETAILS_TAG.exec(rest)) {\n if (!m[1]) {\n if (depth++ === 0) open = m.index + m[0].length;\n } else if (--depth === 0) {\n close = m.index;\n after = m.index + m[0].length;\n break;\n }\n }\n let inner = rest.slice(open, close);\n const sum = SUMMARY.exec(inner);\n if (sum) inner = inner.slice(0, sum.index) + inner.slice(sum.index + sum[0].length);\n out.push({ t: 'details', summary: (sum?.[1] ?? '').trim(), blocks: parse(inner.split('\\n')) });\n return out.concat(parse(rest.slice(after).split('\\n')));\n }\n const fence = FENCE.exec(line);\n if (fence) {\n const mark = fence[1];\n const body: string[] = [];\n i++;\n while (i < lines.length && !lines[i].trim().startsWith(mark)) body.push(lines[i++]);\n i++;\n out.push({ t: 'code', lang: fence[2].toLowerCase(), code: body.join('\\n') });\n continue;\n }\n const h = HEADING.exec(line);\n if (h) {\n out.push({ t: 'h', level: h[1].length, text: h[2] ?? '' });\n i++;\n continue;\n }\n if (HR.test(line)) {\n out.push({ t: 'hr' });\n i++;\n continue;\n }\n if (QUOTE.test(line)) {\n const body: string[] = [];\n while (i < lines.length && !blank(lines[i]) && (QUOTE.test(lines[i]) || !startsBlock(lines[i]))) {\n body.push(QUOTE.exec(lines[i])?.[1] ?? lines[i]);\n i++;\n }\n const alert = body.length > 0 ? ALERT.exec(body[0]) : null;\n if (alert) out.push({ t: 'alert', tone: ALERT_TONE[alert[1].toUpperCase()], blocks: parse(body.slice(1)) });\n else out.push({ t: 'quote', blocks: parse(body) });\n continue;\n }\n const item = ITEM.exec(line);\n if (item) {\n const ordered = /\\d/.test(item[2]);\n const start = ordered ? parseInt(item[2], 10) : 1;\n const items: Block[][] = [];\n while (i < lines.length) {\n const m = ITEM.exec(lines[i]);\n if (!m || /\\d/.test(m[2]) !== ordered) break;\n const indent = m[1].length + m[2].length + Math.max(1, Math.min(m[3].length, 4));\n const body = [m[4]];\n i++;\n // The item's own lines: indented continuation (nested lists too), and lazy text right after it.\n while (i < lines.length) {\n const l = lines[i];\n if (blank(l)) {\n const next = lines[i + 1];\n if (next !== undefined && /^\\s+/.test(next) && next.search(/\\S/) >= indent) {\n body.push('');\n i++;\n continue;\n }\n break;\n }\n const lead = l.search(/\\S/);\n if (lead >= indent || (lead >= 2 && ITEM.test(l.trimStart()))) body.push(l.slice(Math.min(lead, indent)));\n else if (!startsBlock(l) && !ITEM.test(l)) body.push(l);\n else break;\n i++;\n }\n items.push(parse(body));\n if (i < lines.length && blank(lines[i])) {\n const next = lines[i + 1];\n if (next !== undefined && ITEM.test(next) && /\\d/.test(ITEM.exec(next)?.[2] ?? '') === ordered) {\n i++;\n continue;\n }\n break;\n }\n }\n out.push({ t: 'list', ordered, start, items });\n continue;\n }\n if (line.includes('|') && i + 1 < lines.length && TABLE_SEP.test(lines[i + 1]) && lines[i + 1].includes('-')) {\n const head = cells(line);\n const align = cells(lines[i + 1]).map((c) =>\n c.startsWith(':') && c.endsWith(':') ? 'center' : c.endsWith(':') ? 'right' : c.startsWith(':') ? 'left' : null,\n );\n const rows: string[][] = [];\n i += 2;\n while (i < lines.length && !blank(lines[i]) && lines[i].includes('|')) rows.push(cells(lines[i++]));\n out.push({ t: 'table', head, align, rows });\n continue;\n }\n // A paragraph: lines until a blank line or another block.\n const body = [line];\n i++;\n while (i < lines.length && !blank(lines[i]) && !startsBlock(lines[i])) body.push(lines[i++]);\n out.push({ t: 'p', text: body.join('\\n') });\n }\n return out;\n}\n\n/** Only http, https, mailto and relative addresses are kept; anything else (javascript:, data:) is not a link. */\nexport function safeHref(href: string): string | undefined {\n const h = href.trim();\n if (!h) return undefined;\n const scheme = /^([a-z][a-z0-9+.-]*):/i.exec(h);\n if (!scheme) return h;\n return ['http', 'https', 'mailto'].includes(scheme[1].toLowerCase()) ? h : undefined;\n}\n\n// A path in inline code: folders and a file with an extension, or a file and line (src/app.c:86, docs/a.md).\nconst PATH = /^(?:\\.{1,2}\\/)?(?:[\\w.-]+\\/)*[\\w.-]+\\.[A-Za-z0-9]+(?::\\d+(?:-\\d+)?)?$/;\nconst isPath = (s: string) => PATH.test(s) && (s.includes('/') || /:\\d/.test(s));\n\n// Never links, even when listed in schemes.\nconst BLOCKED = ['javascript', 'data', 'vbscript'];\n\ninterface Ctx {\n /** Extra schemes (fn, file) handed to linkHref and onLink as they are. */\n schemes?: string[];\n /** The next key: counted from 0 on every render, so the same source gives the same keys. */\n k: () => string;\n linkHref?: (href: string) => string | undefined | null;\n onLink?: (href: string, e: React.MouseEvent<HTMLElement>) => void;\n refHref?: RefHref;\n onRef?: OnRef;\n terms?: readonly TermDef[];\n termsMark: TermsMark;\n /** All the words in one pattern; null without terms. */\n termRe: RegExp | null;\n /** Words already marked in this block (paragraph, list item, table cell). Absent: no words here (headings, link\n * text, a details summary). */\n seen?: Set<string>;\n}\n\n/** A new block: its own count of marked words. */\nconst block = (c: Ctx): Ctx => ({ ...c, seen: new Set() });\n/** No words marked inside (headings, link text, a summary button). */\nconst noTerms = (c: Ctx): Ctx => ({ ...c, seen: undefined });\n\nconst CJK = /[\\p{Script=Han}\\p{Script=Hiragana}\\p{Script=Katakana}\\u3000-\\u303f\\uff00-\\uffef]/u;\n\n/** Inline Markdown: code spans, links, autolinks, bold, italic, hard breaks; HTML tags dropped, their text kept. */\nfunction inline(src: string, c: Ctx): React.ReactNode[] {\n let aiMark: string | null = null;\n const out: React.ReactNode[] = [];\n let text = '';\n const flush = () => {\n if (text && c.termRe && c.terms && c.seen) out.push(...withTerms(text, findTerms(text, c.terms, c.termRe, c.termsMark, c.seen), c.terms, c.k));\n else if (text) out.push(text);\n text = '';\n };\n let i = 0;\n while (i < src.length) {\n const ch = src[i];\n if (ch === '\\\\' && i + 1 < src.length && /[\\\\`*_{}[\\]()#+\\-.!|<>~]/.test(src[i + 1])) {\n text += src[i + 1];\n i += 2;\n continue;\n }\n if (ch === '\\\\' && src[i + 1] === '\\n') {\n flush();\n out.push(<br key={c.k()} />);\n i += 2;\n continue;\n }\n if (ch === '\\n') {\n // Two spaces before a line break make a break; otherwise it is a space.\n if (/ {2,}$/.test(text)) {\n text = text.replace(/ +$/, '');\n flush();\n out.push(<br key={c.k()} />);\n } else {\n // Lines joined: a space between words, none next to Chinese text or full-width punctuation.\n text = text.replace(/ +$/, '');\n const before = text.at(-1) ?? (typeof out.at(-1) === 'string' ? String(out.at(-1)).at(-1) : '');\n const after = src.slice(i + 1).trimStart()[0] ?? '';\n if (!CJK.test(before ?? '') && !CJK.test(after)) text += ' ';\n while (src[i + 1] === ' ') i++;\n }\n i++;\n continue;\n }\n if (ch === '`') {\n const run = /^`+/.exec(src.slice(i))?.[0] ?? '`';\n const end = src.indexOf(run, i + run.length);\n if (end > 0) {\n flush();\n let v = src.slice(i + run.length, end).replace(/\\n/g, ' ');\n if (/^ .* $/.test(v)) v = v.slice(1, -1);\n out.push(code(v, c));\n i = end + run.length;\n continue;\n }\n }\n if (ch === '<') {\n const auto = /^<((?:https?:|mailto:)[^\\s<>]+)>/i.exec(src.slice(i));\n if (auto) {\n flush();\n out.push(link(auto[1], [auto[1].replace(/^mailto:/i, '')], c));\n i += auto[0].length;\n continue;\n }\n const tag = /^<!--[\\s\\S]*?-->|^<\\/?[A-Za-z][\\w-]*(?:\\s[^<>]*)?\\/?>/.exec(src.slice(i));\n if (tag) {\n // MX: an HTML tag (or comment) is dropped; the text between tags stays.\n i += tag[0].length;\n continue;\n }\n }\n if (ch === '!' && src[i + 1] === '[') {\n // An image shows its alt text; nothing is loaded.\n const m = /^!\\[([^\\]]*)\\]\\([^)]*\\)/.exec(src.slice(i));\n if (m) {\n text += m[1];\n i += m[0].length;\n continue;\n }\n }\n if (ch === '[') {\n const m = matchLink(src, i);\n if (m) {\n // [AI](ai:) marks a paragraph, list item or cell written by AI: an AiMark at its end, wherever it is written.\n // Other words in the brackets, such as [推測](ai:), are shown in the same style.\n if (m.href.trim().toLowerCase() === 'ai:') {\n const words = m.text.trim();\n aiMark = words && words !== 'AI' ? words : '';\n i = m.end;\n if (src[i] === ' ') i++;\n continue;\n }\n flush();\n // [cookie](term:cookie) marks a word explicitly with its entry in terms.\n const termId = /^term:(.*)$/i.exec(m.href.trim())?.[1];\n if (termId !== undefined) {\n let id = termId;\n try {\n id = decodeURIComponent(termId);\n } catch {\n /* kept as written */\n }\n const t = c.terms?.find((x) => x.term === id);\n devWarn(\n !t,\n 'Markdown',\n `[${m.text}](term:${termId}) has no entry with term \"${id}\" in terms, so only the text shows. Add it to terms, or change the word after term:.`,\n );\n c.seen?.add(id);\n out.push(t ? termNode(t, c.k(), inline(m.text, noTerms(c))) : <React.Fragment key={c.k()}>{inline(m.text, noTerms(c))}</React.Fragment>);\n i = m.end;\n continue;\n }\n // A link whose text is one code span ([`_sync_as`](fn:…)) is a name: accent monospace, no chip.\n const name = /^\\s*`([^`]+)`\\s*$/.exec(m.text)?.[1];\n out.push(link(m.href, inline(m.text, noTerms(c)), c, name));\n i = m.end;\n continue;\n }\n }\n if (ch === '*' || ch === '_') {\n const run = src[i + 1] === ch ? ch + ch : ch;\n // _ inside a word (snake_case) is not emphasis.\n const prev = src[i - 1];\n const intraword = ch === '_' && prev !== undefined && /\\w/.test(prev);\n const next = src[i + run.length];\n if (!intraword && next && !/\\s/.test(next)) {\n const end = findClose(src, i + run.length, run);\n if (end > 0) {\n flush();\n const inner = inline(src.slice(i + run.length, end), c);\n out.push(run.length === 2 ? <strong key={c.k()}>{inner}</strong> : <em key={c.k()}>{inner}</em>);\n i = end + run.length;\n continue;\n }\n }\n }\n text += ch;\n i++;\n }\n flush();\n if (aiMark != null) {\n // A trailing space before the mark is dropped; the mark keeps its own 8 px.\n const last = out[out.length - 1];\n if (typeof last === 'string') out[out.length - 1] = last.replace(/\\s+$/, '');\n out.push(<AiMark key={c.k()} text={aiMark || undefined} />);\n }\n return out;\n\n function code(v: string, ctx: Ctx): React.ReactNode {\n const onRef = ctx.onRef;\n if (isPath(v)) {\n // A file and line that points somewhere is a location: gray, one step smaller.\n const href = ctx.refHref?.(v) || undefined;\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 if (href)\n return (\n <InlineCode key={ctx.k()} look=\"location\" href={href} onClick={click}>\n {v}\n </InlineCode>\n );\n if (click)\n return (\n <InlineCode key={ctx.k()} look=\"location\" onClick={click}>\n {v}\n </InlineCode>\n );\n }\n return <InlineCode key={ctx.k()}>{v}</InlineCode>;\n }\n}\n\nfunction matchLink(src: string, i: number): { text: string; href: string; end: number } | null {\n let depth = 0;\n let j = i;\n for (; j < src.length; j++) {\n if (src[j] === '\\\\') {\n j++;\n continue;\n }\n if (src[j] === '[') depth++;\n else if (src[j] === ']' && --depth === 0) break;\n }\n if (j >= src.length || src[j + 1] !== '(') return null;\n // The address may hold balanced parentheses (javascript:alert(1), wiki/Foo_(bar)); an optional \"title\" follows.\n let at = j + 2;\n while (src[at] === ' ') at++;\n let depth2 = 0;\n let href = '';\n for (; at < src.length; at++) {\n const ch = src[at];\n if (/\\s/.test(ch)) break;\n if (ch === '(') depth2++;\n else if (ch === ')') {\n if (depth2 === 0) break;\n depth2--;\n }\n href += ch;\n }\n const rest = /^(?:\\s+(?:\"[^\"]*\"|'[^']*'))?\\s*\\)/.exec(src.slice(at));\n if (!rest) return null;\n return { text: src.slice(i + 1, j), href: href.replace(/^<(.*)>$/, '$1'), end: at + rest[0].length };\n}\n\nfunction findClose(src: string, from: number, run: string): number {\n let j = from;\n while ((j = src.indexOf(run, j)) > 0) {\n const before = src[j - 1];\n const after = src[j + run.length];\n if (before && !/\\s/.test(before) && !(run[0] === '_' && after && /\\w/.test(after)) && !(run.length === 1 && after === run)) return j;\n j += run.length;\n }\n return -1;\n}\n\nfunction link(raw: string, children: React.ReactNode, c: Ctx, name?: string): React.ReactNode {\n // A scheme listed in schemes (fn:, file:) is up to linkHref and onLink: no address of its own.\n const scheme = /^([a-z][a-z0-9+.-]*):/i.exec(raw.trim())?.[1].toLowerCase();\n const own = !!scheme && !BLOCKED.includes(scheme) && !!c.schemes?.some((x) => x.toLowerCase() === scheme);\n const safe = own ? raw.trim() : safeHref(raw);\n if (safe === undefined) return <React.Fragment key={c.k()}>{children}</React.Fragment>;\n const href = c.linkHref ? c.linkHref(safe) || undefined : own ? undefined : safe;\n if (!href && !c.onLink) return <React.Fragment key={c.k()}>{children}</React.Fragment>;\n const outside = !!href && /^https?:/i.test(href);\n const onLink = c.onLink;\n const click = onLink\n ? (e: React.MouseEvent<HTMLElement>) => {\n if (href && (e.metaKey || e.ctrlKey || e.shiftKey || e.button === 1)) return;\n e.preventDefault();\n onLink(safe, e);\n }\n : undefined;\n if (name !== undefined && !(outside && !c.onLink)) {\n if (href)\n return (\n <InlineCode key={c.k()} look=\"name\" href={href} onClick={click}>\n {name}\n </InlineCode>\n );\n if (click)\n return (\n <InlineCode key={c.k()} look=\"name\" onClick={click}>\n {name}\n </InlineCode>\n );\n }\n if (!href)\n return (\n <button key={c.k()} type=\"button\" className=\"ui-md-link\" onClick={click}>\n {children}\n </button>\n );\n return (\n <a key={c.k()} className=\"ui-md-link\" href={href} onClick={click} {...(outside && !c.onLink ? { target: '_blank', rel: 'noopener noreferrer' } : {})}>\n {children}\n </a>\n );\n}\n\n/** A list item whose whole content is one link (a reference list: 「RFC 1812: IPv4 router …」): that link, made a row\n * that fills the item, or null. Links inside a sentence stay inline. */\nfunction rowLink(nodes: React.ReactNode[]): React.ReactElement | null {\n const parts = nodes.filter((n) => !(typeof n === 'string' && !n.trim()));\n if (parts.length !== 1) return null;\n const only = parts[0];\n if (!React.isValidElement<{ className?: string }>(only) || (only.type !== 'a' && only.type !== 'button') || only.props.className !== 'ui-md-link')\n return null;\n return React.cloneElement(only, { className: 'ui-md-link is-row' });\n}\n\n// A fence's language name as CodeView knows it: ```python is py, ```bash is sh; file extensions work too (```ts).\nconst FENCE_LANG: Record<string, string> = {\n python: 'py',\n javascript: 'js',\n typescript: 'js',\n jsx: 'js',\n tsx: 'js',\n bash: 'sh',\n shell: 'sh',\n zsh: 'sh',\n console: 'sh',\n 'c++': 'c',\n};\nconst fenceLang = (l: string) => FENCE_LANG[l] ?? (languageOf('x.' + l) !== 'plain' ? languageOf('x.' + l) : l || 'plain');\n\n// A number cell's figures and its unit: [all, number, space, unit].\nconst NUM_UNIT = /^([-+]?(?:NT\\$\\s?)?[\\d,]+(?:\\.\\d+)?)(\\s?)(%|[A-Za-z]{1,3}|\\p{Script=Han}{1,2})$/u;\nconst NUM = /^[-+]?(?:NT\\$\\s?)?[\\d,]+(?:\\.\\d+)?\\s?(?:%|[A-Za-z]{1,3}|\\p{Script=Han}{1,2})?$/u;\n\nexport interface MarkdownProps {\n /** The Markdown text. */\n children: string;\n /** Only inline syntax (code, links, bold, italic), no paragraphs: for a one-line summary such as a README's first\n * sentence. Line breaks become spaces. */\n inline?: boolean;\n /** small: 13 px, for notes. Default: the same 16 px as the text around it. */\n size?: 'body' | 'small';\n /** The heading level `#` becomes. Default 4: # is an h4 (20 px), ## an h5, ### and deeper h6 (both 16 px bold). */\n topLevel?: 1 | 2 | 3 | 4 | 5 | 6;\n /** Link schemes of your own, such as ['fn', 'file']: [_sync_as](fn:harness/controller.py:VirtualRouter._sync_as)\n * goes to linkHref and onLink as written, which decide what it opens. javascript:, data: and vbscript: never link. */\n schemes?: string[];\n /** The address of a link (after the http, https, mailto or relative check); return undefined for no link. */\n linkHref?: (href: string) => string | undefined | null;\n /** A plain click on a link (the default navigation is prevented; Ctrl, ⌘ or Shift still open linkHref). */\n onLink?: (href: string, e: React.MouseEvent<HTMLElement>) => void;\n /** Inline code that is a path (harness/routing.py:108, docs/a.md) and paths in code blocks: their link. Same as\n * CodeView's refHref. */\n refHref?: RefHref;\n /** A plain click on such a path. Same as CodeView's onRef. */\n onRef?: OnRef;\n /** Words that get an explanation (Term variant=\"inline\"): matched whole and case-sensitive in plain text, not in\n * inline code, link text or headings; fenced code blocks match them in comments and strings. `[cookie](term:cookie)`\n * marks one explicitly, wherever it is. */\n terms?: readonly TermDef[];\n /** 'first' (default): each word only where it first appears in a paragraph, list item or table cell. 'all': everywhere. */\n termsMark?: TermsMark;\n /** Extra class on the root element. */\n className?: string;\n}\n\n/** Markdown from project documents and code comments, in the system's own type, code and table styles. Never runs HTML:\n * tags are dropped and their text kept; links only to http, https, mailto and relative addresses. */\nexport function Markdown(p: MarkdownProps) {\n // Keys count from 0 on every render, so the same source gives the same keys and nothing remounts.\n let n = 0;\n const termsMark = p.termsMark ?? 'first';\n const termRe = React.useMemo(() => termPattern(p.terms), [p.terms]);\n const c: Ctx = {\n k: () => 'm' + n++,\n schemes: p.schemes,\n linkHref: p.linkHref,\n onLink: p.onLink,\n refHref: p.refHref,\n onRef: p.onRef,\n terms: p.terms,\n termsMark,\n termRe,\n };\n const src = String(p.children ?? '').replace(/\\r\\n?/g, '\\n');\n const cls = cx('ui-md', p.size === 'small' && 'is-small', p.className);\n if (p.inline) return <span className={cx(cls, 'is-inline')}>{inline(src.trim().replace(/\\n\\s*\\n/g, '\\n'), block(c))}</span>;\n const top = p.topLevel ?? 4;\n const render = (blocks: Block[]): React.ReactNode[] =>\n blocks.map((b) => {\n switch (b.t) {\n case 'h': {\n const H = `h${Math.min(6, top + b.level - 1)}` as 'h4';\n return (\n <H key={c.k()} className=\"ui-md-h\">\n {inline(b.text, noTerms(c))}\n </H>\n );\n }\n case 'p':\n return <p key={c.k()}>{inline(b.text, block(c))}</p>;\n case 'hr':\n return <hr key={c.k()} />;\n case 'details':\n return (\n <MdDetails key={c.k()} summary={inline(b.summary, noTerms(c))}>\n {render(b.blocks)}\n </MdDetails>\n );\n case 'alert':\n return (\n <Alert key={c.k()} tone={b.tone} className=\"ui-md-alert\">\n {render(b.blocks)}\n </Alert>\n );\n case 'quote':\n return <blockquote key={c.k()}>{render(b.blocks)}</blockquote>;\n case 'list': {\n const items = b.items.map((it) => {\n const key = c.k();\n if (!(it.length === 1 && it[0].t === 'p')) return <li key={key}>{render(it)}</li>;\n const nodes = inline(it[0].text, block(c));\n const row = rowLink(nodes);\n return row ? (\n <li key={key} className=\"ui-md-rowitem\">\n {row}\n </li>\n ) : (\n <li key={key}>{nodes}</li>\n );\n });\n return b.ordered ? (\n <ol key={c.k()} start={b.start === 1 ? undefined : b.start}>\n {items}\n </ol>\n ) : (\n <ul key={c.k()}>{items}</ul>\n );\n }\n case 'code':\n return (\n <CodeView\n key={c.k()}\n className=\"ui-md-code\"\n code={b.code}\n language={fenceLang(b.lang)}\n languageLabel={b.lang ? undefined : false}\n copy\n lineNumbers={false}\n refHref={p.refHref}\n onRef={p.onRef}\n terms={p.terms}\n termsMark={termsMark}\n />\n );\n case 'table': {\n // Numbers right-aligned: a column whose cells are all numbers, unless the source sets its alignment.\n const n = b.head.length;\n const numeric = b.head.map((_, j) => b.rows.length > 0 && b.rows.every((r) => !r[j] || NUM.test(r[j])));\n const align = (j: number): React.CSSProperties | undefined => {\n const a = b.align[j] ?? (numeric[j] ? 'right' : null);\n return a ? { textAlign: a } : undefined;\n };\n return (\n <MdTable\n key={c.k()}\n label={b.head.map(plain).join('、')}\n heads={b.head.map((h) => inline(h, noTerms(c)))}\n headText={b.head.map(plain)}\n rows={b.rows.map((r) =>\n Array.from({ length: n }, (_, j) => {\n // A number column: the figures in Geist Mono (td.is-num), the unit (「46 分」「3.5 GB」) in the text font.\n const u = numeric[j] ? NUM_UNIT.exec(r[j] ?? '') : null;\n return u ? (\n <>\n {inline(u[1], block(c))}\n {u[2]}\n <span className=\"ui-unit\">{u[3]}</span>\n </>\n ) : (\n inline(r[j] ?? '', block(c))\n );\n }),\n )}\n numeric={numeric}\n align={align}\n />\n );\n }\n }\n });\n return <div className={cls}>{render(parse(src.split('\\n')))}</div>;\n}\n\n/** A header cell as plain text, for the label above each value when a narrow table turns into cards. */\nconst plain = (md: string) =>\n md\n .replace(/\\[([^\\]]*)\\]\\([^)]*\\)/g, '$1')\n .replace(/[`*_]/g, '')\n .trim();\n\n/** DA: a <details> block: a button with the summary, closed at first. The closed content stays in the page\n * (hidden=\"until-found\"), so the browser's find opens it, as in Section. */\nfunction MdDetails({ summary, children }: { summary: React.ReactNode; children: React.ReactNode }) {\n const [open, setOpen] = React.useState(false);\n const id = React.useId();\n const body = React.useRef<HTMLDivElement>(null);\n React.useLayoutEffect(() => {\n const el = body.current;\n if (!el) return;\n if (open) {\n el.removeAttribute('hidden');\n return;\n }\n el.setAttribute('hidden', 'until-found');\n const found = () => setOpen(true);\n el.addEventListener('beforematch', found);\n return () => el.removeEventListener('beforematch', found);\n }, [open]);\n return (\n <div className={cx('ui-md-details', open && 'is-open')}>\n <button type=\"button\" className=\"ui-md-summary\" aria-expanded={open} aria-controls={id} onClick={() => setOpen(!open)}>\n <Icon name=\"caret-right\" size={16} className=\"ui-md-caret\" />\n <span>{summary}</span>\n </button>\n <div id={id} ref={body} className=\"ui-md-details-body\">\n {children}\n </div>\n </div>\n );\n}\n\n/** A Markdown table: column borders in the header drag; the corner button shows the whole table in a wide dialog.\n * Under 480 px every row is a card instead, without either. The border, the dialog and the copy icon are the same as\n * DataTable's (internal/tableTools). */\nfunction MdTable(p: {\n label: string;\n heads: React.ReactNode[];\n headText: string[];\n rows: React.ReactNode[][];\n numeric: boolean[];\n align: (j: number) => React.CSSProperties | undefined;\n}) {\n const [widths, setWidths] = React.useState<number[] | null>(null);\n const [big, setBig] = React.useState(false);\n const [dragging, setDragging] = React.useState(false);\n const table = React.useRef<HTMLTableElement>(null);\n // Rounded up: a fixed column a fraction of a pixel narrower than it was drawn would wrap its longest word.\n const measure = () => [...(table.current?.querySelectorAll<HTMLElement>('thead th') ?? [])].map((th) => Math.ceil(th.getBoundingClientRect().width));\n // The drawn widths, kept for the borders' aria-valuenow (refs are not read while rendering).\n const [measured, setMeasured] = React.useState<number[]>([]);\n React.useLayoutEffect(() => {\n const el = table.current;\n if (!el) return;\n const update = () => {\n const m = [...el.querySelectorAll<HTMLElement>('thead th')].map((th) => Math.ceil(th.getBoundingClientRect().width));\n setMeasured((old) => (old.length === m.length && old.every((v, i) => v === m[i]) ? old : m));\n };\n update();\n const ro = resizeObserver(update);\n ro?.observe(el);\n return () => ro?.disconnect();\n }, []);\n const body = (resize: boolean) => (\n <table\n ref={resize ? table : undefined}\n className=\"ui-md-table\"\n style={resize && widths ? { width: widths.reduce((a, b) => a + b, 0), tableLayout: 'fixed', minWidth: 0 } : undefined}\n >\n {resize && widths ? (\n <colgroup>\n {widths.map((w, j) => (\n <col key={j} style={{ width: w }} />\n ))}\n </colgroup>\n ) : null}\n <thead>\n <tr>\n {p.heads.map((h, j) => (\n <th key={j} style={p.align(j)}>\n {h}\n {resize ? (\n <ColResize\n name={p.headText[j]}\n width={widths?.[j] ?? measured[j] ?? 0}\n start={() => (widths ?? measure())[j]}\n onWidth={(w) => {\n const next = (widths ?? measure()).slice();\n next[j] = w;\n setWidths(next);\n }}\n onReset={() => setWidths(null)}\n onDragging={setDragging}\n />\n ) : null}\n </th>\n ))}\n </tr>\n </thead>\n <tbody>\n {p.rows.map((r, ri) => (\n <tr key={ri}>\n {r.map((cell, j) => (\n <td key={j} className={p.numeric[j] ? 'is-num' : undefined} style={p.align(j)} data-label={p.headText[j]}>\n {cell}\n </td>\n ))}\n </tr>\n ))}\n </tbody>\n </table>\n );\n return (\n <div className={cx('ui-md-tablebox', dragging && 'is-resizing')}>\n <div className=\"ui-md-table-tools\">\n <ZoomButton onClick={() => setBig(true)} />\n </div>\n <div className=\"ui-md-table-wrap\" tabIndex={0} role=\"region\" aria-label={p.label}>\n {body(true)}\n </div>\n <TableDialog open={big} onClose={() => setBig(false)}>\n <div className=\"ui-md ui-md-table-wrap\" tabIndex={0} role=\"region\" aria-label={p.label}>\n {body(false)}\n </div>\n </TableDialog>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAcA,aAAaA,mBAAY;AAiBzB,MAAM,eAAe;AACrB,MAAM,cAAc;AACpB,MAAM,UAAU;AAEhB,MAAM,QAAQ;AACd,MAAM,aAAwC;CAAE,MAAM;CAAQ,KAAK;CAAW,WAAW;CAAQ,SAAS;CAAW,SAAS;AAAS;AAEvI,MAAM,QAAQ;AACd,MAAM,UAAU;AAChB,MAAM,KAAK;AACX,MAAM,OAAO;AACb,MAAM,QAAQ;AACd,MAAM,YAAY;AAElB,SAAS,MAAM,MAAwB;CACrC,IAAI,IAAI,KAAK,KAAK;CAClB,IAAI,EAAE,WAAW,GAAG,GAAG,IAAI,EAAE,MAAM,CAAC;CACpC,IAAI,EAAE,SAAS,GAAG,KAAK,CAAC,EAAE,SAAS,KAAK,GAAG,IAAI,EAAE,MAAM,GAAG,EAAE;CAC5D,MAAM,MAA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ACL,EACC,CAAA,EACC,CAAA;GACP,oBAAC,SAAD,EAAA,UACG,EAAE,KAAK,KAAK,GAAG,OACd,oBAAC,MAAD,EAAA,UACG,EAAE,KAAK,MAAM,MACZ,oBAAC,MAAD;IAAY,WAAW,EAAE,QAAQ,KAAK,WAAW,KAAA;IAAW,OAAO,EAAE,MAAM,CAAC;IAAG,cAAY,EAAE,SAAS;IACnG,UAAA;GACC,GAFK,CAEL,CACL,EACC,GANK,EAML,CACL,EACI,CAAA;EACF;;CAET,OACE,qBAAC,OAAD;EAAK,WAAW,GAAG,kBAAkB,YAAY,aAAa;EAA9D,UAAA;GACE,oBAAC,OAAD;IAAK,WAAU;IACb,UAAA,oBAAC,YAAD,EAAY,eAAe,OAAO,IAAI,EAAI,CAAA;GACvC,CAAA;GACL,oBAAC,OAAD;IAAK,WAAU;IAAmB,UAAU;IAAG,MAAK;IAAS,cAAY,EAAE;IACxE,UAAA,KAAK,IAAI;GACP,CAAA;GACL,oBAAC,aAAD;IAAa,MAAM;IAAK,eAAe,OAAO,KAAK;IACjD,UAAA,oBAAC,OAAD;KAAK,WAAU;KAAyB,UAAU;KAAG,MAAK;KAAS,cAAY,EAAE;KAC9E,UAAA,KAAK,KAAK;IACR,CAAA;GACM,CAAA;EACV;;AAET"}
|
|
1
|
+
{"version":3,"file":"Markdown.js","names":["phCaretRight"],"sources":["../../../src/components/Markdown/Markdown.tsx"],"sourcesContent":["import * as React from 'react';\nimport { Alert, type AlertTone } from '../Alert/Alert';\nimport { Icon } from '../../icons/Icon';\nimport { ColResize, TableDialog, ZoomButton } from '../../internal/tableTools';\nimport { cssZoom, cx, resizeObserver } from '../../internal/util';\nimport { devWarn } from '../../internal/dev';\nimport { CodeView } from '../CodeView/CodeView';\nimport { languageOf } from '../CodeView/tokens';\nimport { InlineCode, type OnRef, type RefHref } from '../InlineCode/InlineCode';\nimport { AiMark } from '../AiMark/AiMark';\nimport { findTerms, termNode, termPattern, withTerms, type TermDef, type TermsMark } from '../../internal/terms';\nimport { includeIcons } from '../../icons/store';\nimport phCaretRight from '../../icons/ph/caret-right';\n\nincludeIcons(phCaretRight);\n\n/* A small Markdown reader for project documents and code comments. It builds React elements only: no HTML from the\n source is ever run. HTML tags are dropped and their text kept (MX). */\n\ntype Block =\n | { t: 'h'; level: number; text: string }\n | { t: 'p'; text: string }\n | { t: 'code'; lang: string; code: string }\n | { t: 'quote'; blocks: Block[] }\n | { t: 'list'; ordered: boolean; start: number; items: Block[][] }\n | { t: 'table'; head: string[]; align: ('left' | 'right' | 'center' | null)[]; rows: string[][] }\n | { t: 'hr' }\n | { t: 'details'; summary: string; blocks: Block[] }\n | { t: 'alert'; tone: AlertTone; blocks: Block[] };\n\n// DA: <details> and <summary> are the only HTML let through, without attributes; they make a closed block.\nconst DETAILS_OPEN = /^\\s*<details\\b[^>]*>/i;\nconst DETAILS_TAG = /<(\\/?)details\\b[^>]*>/gi;\nconst SUMMARY = /<summary\\b[^>]*>([\\s\\S]*?)<\\/summary>/i;\n// NB: GitHub's alerts, > [!NOTE] and the like, shown as the system's Alert.\nconst ALERT = /^\\s*\\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\\]\\s*$/i;\nconst ALERT_TONE: Record<string, AlertTone> = { NOTE: 'info', TIP: 'success', IMPORTANT: 'info', WARNING: 'warning', CAUTION: 'danger' };\n\nconst FENCE = /^ {0,3}(`{3,}|~{3,})\\s*([\\w+#.-]*)/;\nconst HEADING = /^ {0,3}(#{1,6})(?:\\s+(.*?))?\\s*#*\\s*$/;\nconst HR = /^ {0,3}([-*_])(?:\\s*\\1){2,}\\s*$/;\nconst ITEM = /^( {0,3})([-*+]|\\d{1,9}[.)])(\\s+|$)(.*)$/;\nconst QUOTE = /^ {0,3}> ?(.*)$/;\nconst TABLE_SEP = /^\\s*\\|?\\s*:?-{1,}:?\\s*(\\|\\s*:?-{1,}:?\\s*)*\\|?\\s*$/;\n\nfunction cells(line: string): string[] {\n let s = line.trim();\n if (s.startsWith('|')) s = s.slice(1);\n if (s.endsWith('|') && !s.endsWith('\\\\|')) s = s.slice(0, -1);\n const out: string[] = [];\n let cur = '';\n let code = false;\n for (let i = 0; i < s.length; i++) {\n const c = s[i];\n if (c === '\\\\' && s[i + 1] === '|') {\n cur += '|';\n i++;\n } else if (c === '`') {\n code = !code;\n cur += c;\n } else if (c === '|' && !code) {\n out.push(cur.trim());\n cur = '';\n } else cur += c;\n }\n out.push(cur.trim());\n return out;\n}\n\nconst blank = (l: string) => !l.trim();\nconst startsBlock = (l: string) => FENCE.test(l) || HEADING.test(l) || HR.test(l) || QUOTE.test(l) || ITEM.test(l);\n\nfunction parse(lines: string[]): Block[] {\n const out: Block[] = [];\n let i = 0;\n while (i < lines.length) {\n const line = lines[i];\n if (blank(line)) {\n i++;\n continue;\n }\n if (DETAILS_OPEN.test(line)) {\n // The matching </details>, counting nested ones; what follows it on the line goes on as more Markdown.\n const rest = lines.slice(i).join('\\n');\n DETAILS_TAG.lastIndex = 0;\n let depth = 0;\n let open = -1;\n let close = rest.length;\n let after = rest.length;\n for (let m = DETAILS_TAG.exec(rest); m; m = DETAILS_TAG.exec(rest)) {\n if (!m[1]) {\n if (depth++ === 0) open = m.index + m[0].length;\n } else if (--depth === 0) {\n close = m.index;\n after = m.index + m[0].length;\n break;\n }\n }\n let inner = rest.slice(open, close);\n const sum = SUMMARY.exec(inner);\n if (sum) inner = inner.slice(0, sum.index) + inner.slice(sum.index + sum[0].length);\n out.push({ t: 'details', summary: (sum?.[1] ?? '').trim(), blocks: parse(inner.split('\\n')) });\n return out.concat(parse(rest.slice(after).split('\\n')));\n }\n const fence = FENCE.exec(line);\n if (fence) {\n const mark = fence[1];\n const body: string[] = [];\n i++;\n while (i < lines.length && !lines[i].trim().startsWith(mark)) body.push(lines[i++]);\n i++;\n out.push({ t: 'code', lang: fence[2].toLowerCase(), code: body.join('\\n') });\n continue;\n }\n const h = HEADING.exec(line);\n if (h) {\n out.push({ t: 'h', level: h[1].length, text: h[2] ?? '' });\n i++;\n continue;\n }\n if (HR.test(line)) {\n out.push({ t: 'hr' });\n i++;\n continue;\n }\n if (QUOTE.test(line)) {\n const body: string[] = [];\n while (i < lines.length && !blank(lines[i]) && (QUOTE.test(lines[i]) || !startsBlock(lines[i]))) {\n body.push(QUOTE.exec(lines[i])?.[1] ?? lines[i]);\n i++;\n }\n const alert = body.length > 0 ? ALERT.exec(body[0]) : null;\n if (alert) out.push({ t: 'alert', tone: ALERT_TONE[alert[1].toUpperCase()], blocks: parse(body.slice(1)) });\n else out.push({ t: 'quote', blocks: parse(body) });\n continue;\n }\n const item = ITEM.exec(line);\n if (item) {\n const ordered = /\\d/.test(item[2]);\n const start = ordered ? parseInt(item[2], 10) : 1;\n const items: Block[][] = [];\n while (i < lines.length) {\n const m = ITEM.exec(lines[i]);\n if (!m || /\\d/.test(m[2]) !== ordered) break;\n const indent = m[1].length + m[2].length + Math.max(1, Math.min(m[3].length, 4));\n const body = [m[4]];\n i++;\n // The item's own lines: indented continuation (nested lists too), and lazy text right after it.\n while (i < lines.length) {\n const l = lines[i];\n if (blank(l)) {\n const next = lines[i + 1];\n if (next !== undefined && /^\\s+/.test(next) && next.search(/\\S/) >= indent) {\n body.push('');\n i++;\n continue;\n }\n break;\n }\n const lead = l.search(/\\S/);\n if (lead >= indent || (lead >= 2 && ITEM.test(l.trimStart()))) body.push(l.slice(Math.min(lead, indent)));\n else if (!startsBlock(l) && !ITEM.test(l)) body.push(l);\n else break;\n i++;\n }\n items.push(parse(body));\n if (i < lines.length && blank(lines[i])) {\n const next = lines[i + 1];\n if (next !== undefined && ITEM.test(next) && /\\d/.test(ITEM.exec(next)?.[2] ?? '') === ordered) {\n i++;\n continue;\n }\n break;\n }\n }\n out.push({ t: 'list', ordered, start, items });\n continue;\n }\n if (line.includes('|') && i + 1 < lines.length && TABLE_SEP.test(lines[i + 1]) && lines[i + 1].includes('-')) {\n const head = cells(line);\n const align = cells(lines[i + 1]).map((c) =>\n c.startsWith(':') && c.endsWith(':') ? 'center' : c.endsWith(':') ? 'right' : c.startsWith(':') ? 'left' : null,\n );\n const rows: string[][] = [];\n i += 2;\n while (i < lines.length && !blank(lines[i]) && lines[i].includes('|')) rows.push(cells(lines[i++]));\n out.push({ t: 'table', head, align, rows });\n continue;\n }\n // A paragraph: lines until a blank line or another block.\n const body = [line];\n i++;\n while (i < lines.length && !blank(lines[i]) && !startsBlock(lines[i])) body.push(lines[i++]);\n out.push({ t: 'p', text: body.join('\\n') });\n }\n return out;\n}\n\n/** Only http, https, mailto and relative addresses are kept; anything else (javascript:, data:) is not a link. */\nexport function safeHref(href: string): string | undefined {\n const h = href.trim();\n if (!h) return undefined;\n const scheme = /^([a-z][a-z0-9+.-]*):/i.exec(h);\n if (!scheme) return h;\n return ['http', 'https', 'mailto'].includes(scheme[1].toLowerCase()) ? h : undefined;\n}\n\n// A path in inline code: folders and a file with an extension, or a file and line (src/app.c:86, docs/a.md).\nconst PATH = /^(?:\\.{1,2}\\/)?(?:[\\w.-]+\\/)*[\\w.-]+\\.[A-Za-z0-9]+(?::\\d+(?:-\\d+)?)?$/;\nconst isPath = (s: string) => PATH.test(s) && (s.includes('/') || /:\\d/.test(s));\n\n// Never links, even when listed in schemes.\nconst BLOCKED = ['javascript', 'data', 'vbscript'];\n\ninterface Ctx {\n /** Extra schemes (fn, file) handed to linkHref and onLink as they are. */\n schemes?: string[];\n /** The next key: counted from 0 on every render, so the same source gives the same keys. */\n k: () => string;\n linkHref?: (href: string) => string | undefined | null;\n onLink?: (href: string, e: React.MouseEvent<HTMLElement>) => void;\n refHref?: RefHref;\n onRef?: OnRef;\n terms?: readonly TermDef[];\n termsMark: TermsMark;\n /** All the words in one pattern; null without terms. */\n termRe: RegExp | null;\n /** Words already marked in this block (paragraph, list item, table cell). Absent: no words here (headings, link\n * text, a details summary). */\n seen?: Set<string>;\n}\n\n/** A new block: its own count of marked words. */\nconst block = (c: Ctx): Ctx => ({ ...c, seen: new Set() });\n/** No words marked inside (headings, link text, a summary button). */\nconst noTerms = (c: Ctx): Ctx => ({ ...c, seen: undefined });\n\nconst CJK = /[\\p{Script=Han}\\p{Script=Hiragana}\\p{Script=Katakana}\\u3000-\\u303f\\uff00-\\uffef]/u;\n\n/** Inline Markdown: code spans, links, autolinks, bold, italic, hard breaks; HTML tags dropped, their text kept. */\nfunction inline(src: string, c: Ctx): React.ReactNode[] {\n let aiMark: string | null = null;\n const out: React.ReactNode[] = [];\n let text = '';\n const flush = () => {\n if (text && c.termRe && c.terms && c.seen) out.push(...withTerms(text, findTerms(text, c.terms, c.termRe, c.termsMark, c.seen), c.terms, c.k));\n else if (text) out.push(text);\n text = '';\n };\n let i = 0;\n while (i < src.length) {\n const ch = src[i];\n if (ch === '\\\\' && i + 1 < src.length && /[\\\\`*_{}[\\]()#+\\-.!|<>~]/.test(src[i + 1])) {\n text += src[i + 1];\n i += 2;\n continue;\n }\n if (ch === '\\\\' && src[i + 1] === '\\n') {\n flush();\n out.push(<br key={c.k()} />);\n i += 2;\n continue;\n }\n if (ch === '\\n') {\n // Two spaces before a line break make a break; otherwise it is a space.\n if (/ {2,}$/.test(text)) {\n text = text.replace(/ +$/, '');\n flush();\n out.push(<br key={c.k()} />);\n } else {\n // Lines joined: a space between words, none next to Chinese text or full-width punctuation.\n text = text.replace(/ +$/, '');\n const before = text.at(-1) ?? (typeof out.at(-1) === 'string' ? String(out.at(-1)).at(-1) : '');\n const after = src.slice(i + 1).trimStart()[0] ?? '';\n if (!CJK.test(before ?? '') && !CJK.test(after)) text += ' ';\n while (src[i + 1] === ' ') i++;\n }\n i++;\n continue;\n }\n if (ch === '`') {\n const run = /^`+/.exec(src.slice(i))?.[0] ?? '`';\n const end = src.indexOf(run, i + run.length);\n if (end > 0) {\n flush();\n let v = src.slice(i + run.length, end).replace(/\\n/g, ' ');\n if (/^ .* $/.test(v)) v = v.slice(1, -1);\n out.push(code(v, c));\n i = end + run.length;\n continue;\n }\n }\n if (ch === '<') {\n const auto = /^<((?:https?:|mailto:)[^\\s<>]+)>/i.exec(src.slice(i));\n if (auto) {\n flush();\n out.push(link(auto[1], [auto[1].replace(/^mailto:/i, '')], c));\n i += auto[0].length;\n continue;\n }\n const tag = /^<!--[\\s\\S]*?-->|^<\\/?[A-Za-z][\\w-]*(?:\\s[^<>]*)?\\/?>/.exec(src.slice(i));\n if (tag) {\n // MX: an HTML tag (or comment) is dropped; the text between tags stays.\n i += tag[0].length;\n continue;\n }\n }\n if (ch === '!' && src[i + 1] === '[') {\n // An image shows its alt text; nothing is loaded.\n const m = /^!\\[([^\\]]*)\\]\\([^)]*\\)/.exec(src.slice(i));\n if (m) {\n text += m[1];\n i += m[0].length;\n continue;\n }\n }\n if (ch === '[') {\n const m = matchLink(src, i);\n if (m) {\n // [AI](ai:) marks a paragraph, list item or cell written by AI: an AiMark at its end, wherever it is written.\n // Other words in the brackets, such as [推測](ai:), are shown in the same style.\n if (m.href.trim().toLowerCase() === 'ai:') {\n const words = m.text.trim();\n aiMark = words && words !== 'AI' ? words : '';\n i = m.end;\n if (src[i] === ' ') i++;\n continue;\n }\n flush();\n // [cookie](term:cookie) marks a word explicitly with its entry in terms.\n const termId = /^term:(.*)$/i.exec(m.href.trim())?.[1];\n if (termId !== undefined) {\n let id = termId;\n try {\n id = decodeURIComponent(termId);\n } catch {\n /* kept as written */\n }\n const t = c.terms?.find((x) => x.term === id);\n devWarn(\n !t,\n 'Markdown',\n `[${m.text}](term:${termId}) has no entry with term \"${id}\" in terms, so only the text shows. Add it to terms, or change the word after term:.`,\n );\n c.seen?.add(id);\n out.push(t ? termNode(t, c.k(), inline(m.text, noTerms(c))) : <React.Fragment key={c.k()}>{inline(m.text, noTerms(c))}</React.Fragment>);\n i = m.end;\n continue;\n }\n // A link whose text is one code span ([`_sync_as`](fn:…)) is a name: accent monospace, no chip.\n const name = /^\\s*`([^`]+)`\\s*$/.exec(m.text)?.[1];\n out.push(link(m.href, inline(m.text, noTerms(c)), c, name));\n i = m.end;\n continue;\n }\n }\n if (ch === '*' || ch === '_') {\n const run = src[i + 1] === ch ? ch + ch : ch;\n // _ inside a word (snake_case) is not emphasis.\n const prev = src[i - 1];\n const intraword = ch === '_' && prev !== undefined && /\\w/.test(prev);\n const next = src[i + run.length];\n if (!intraword && next && !/\\s/.test(next)) {\n const end = findClose(src, i + run.length, run);\n if (end > 0) {\n flush();\n const inner = inline(src.slice(i + run.length, end), c);\n out.push(run.length === 2 ? <strong key={c.k()}>{inner}</strong> : <em key={c.k()}>{inner}</em>);\n i = end + run.length;\n continue;\n }\n }\n }\n text += ch;\n i++;\n }\n flush();\n if (aiMark != null) {\n // A trailing space before the mark is dropped; the mark keeps its own 8 px.\n const last = out[out.length - 1];\n if (typeof last === 'string') out[out.length - 1] = last.replace(/\\s+$/, '');\n out.push(<AiMark key={c.k()} text={aiMark || undefined} />);\n }\n return out;\n\n function code(v: string, ctx: Ctx): React.ReactNode {\n const onRef = ctx.onRef;\n if (isPath(v)) {\n // A file and line that points somewhere is a location: gray, one step smaller.\n const href = ctx.refHref?.(v) || undefined;\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 if (href)\n return (\n <InlineCode key={ctx.k()} look=\"location\" href={href} onClick={click}>\n {v}\n </InlineCode>\n );\n if (click)\n return (\n <InlineCode key={ctx.k()} look=\"location\" onClick={click}>\n {v}\n </InlineCode>\n );\n }\n return <InlineCode key={ctx.k()}>{v}</InlineCode>;\n }\n}\n\nfunction matchLink(src: string, i: number): { text: string; href: string; end: number } | null {\n let depth = 0;\n let j = i;\n for (; j < src.length; j++) {\n if (src[j] === '\\\\') {\n j++;\n continue;\n }\n if (src[j] === '[') depth++;\n else if (src[j] === ']' && --depth === 0) break;\n }\n if (j >= src.length || src[j + 1] !== '(') return null;\n // The address may hold balanced parentheses (javascript:alert(1), wiki/Foo_(bar)); an optional \"title\" follows.\n let at = j + 2;\n while (src[at] === ' ') at++;\n let depth2 = 0;\n let href = '';\n for (; at < src.length; at++) {\n const ch = src[at];\n if (/\\s/.test(ch)) break;\n if (ch === '(') depth2++;\n else if (ch === ')') {\n if (depth2 === 0) break;\n depth2--;\n }\n href += ch;\n }\n const rest = /^(?:\\s+(?:\"[^\"]*\"|'[^']*'))?\\s*\\)/.exec(src.slice(at));\n if (!rest) return null;\n return { text: src.slice(i + 1, j), href: href.replace(/^<(.*)>$/, '$1'), end: at + rest[0].length };\n}\n\nfunction findClose(src: string, from: number, run: string): number {\n let j = from;\n while ((j = src.indexOf(run, j)) > 0) {\n const before = src[j - 1];\n const after = src[j + run.length];\n if (before && !/\\s/.test(before) && !(run[0] === '_' && after && /\\w/.test(after)) && !(run.length === 1 && after === run)) return j;\n j += run.length;\n }\n return -1;\n}\n\nfunction link(raw: string, children: React.ReactNode, c: Ctx, name?: string): React.ReactNode {\n // A scheme listed in schemes (fn:, file:) is up to linkHref and onLink: no address of its own.\n const scheme = /^([a-z][a-z0-9+.-]*):/i.exec(raw.trim())?.[1].toLowerCase();\n const own = !!scheme && !BLOCKED.includes(scheme) && !!c.schemes?.some((x) => x.toLowerCase() === scheme);\n const safe = own ? raw.trim() : safeHref(raw);\n if (safe === undefined) return <React.Fragment key={c.k()}>{children}</React.Fragment>;\n const href = c.linkHref ? c.linkHref(safe) || undefined : own ? undefined : safe;\n if (!href && !c.onLink) return <React.Fragment key={c.k()}>{children}</React.Fragment>;\n const outside = !!href && /^https?:/i.test(href);\n const onLink = c.onLink;\n const click = onLink\n ? (e: React.MouseEvent<HTMLElement>) => {\n if (href && (e.metaKey || e.ctrlKey || e.shiftKey || e.button === 1)) return;\n e.preventDefault();\n onLink(safe, e);\n }\n : undefined;\n if (name !== undefined && !(outside && !c.onLink)) {\n if (href)\n return (\n <InlineCode key={c.k()} look=\"name\" href={href} onClick={click}>\n {name}\n </InlineCode>\n );\n if (click)\n return (\n <InlineCode key={c.k()} look=\"name\" onClick={click}>\n {name}\n </InlineCode>\n );\n }\n if (!href)\n return (\n <button key={c.k()} type=\"button\" className=\"ui-md-link\" onClick={click}>\n {children}\n </button>\n );\n return (\n <a key={c.k()} className=\"ui-md-link\" href={href} onClick={click} {...(outside && !c.onLink ? { target: '_blank', rel: 'noopener noreferrer' } : {})}>\n {children}\n </a>\n );\n}\n\n/** A list item whose whole content is one link (a reference list: 「RFC 1812: IPv4 router …」): that link, made a row\n * that fills the item, or null. Links inside a sentence stay inline. */\nfunction rowLink(nodes: React.ReactNode[]): React.ReactElement | null {\n const parts = nodes.filter((n) => !(typeof n === 'string' && !n.trim()));\n if (parts.length !== 1) return null;\n const only = parts[0];\n if (!React.isValidElement<{ className?: string }>(only) || (only.type !== 'a' && only.type !== 'button') || only.props.className !== 'ui-md-link')\n return null;\n return React.cloneElement(only, { className: 'ui-md-link is-row' });\n}\n\n// A fence's language name as CodeView knows it: ```python is py, ```bash is sh; file extensions work too (```ts).\nconst FENCE_LANG: Record<string, string> = {\n python: 'py',\n javascript: 'js',\n typescript: 'js',\n jsx: 'js',\n tsx: 'js',\n bash: 'sh',\n shell: 'sh',\n zsh: 'sh',\n console: 'sh',\n 'c++': 'c',\n};\nconst fenceLang = (l: string) => FENCE_LANG[l] ?? (languageOf('x.' + l) !== 'plain' ? languageOf('x.' + l) : l || 'plain');\n\n// A number cell's figures and its unit: [all, number, space, unit].\nconst NUM_UNIT = /^([-+]?(?:NT\\$\\s?)?[\\d,]+(?:\\.\\d+)?)(\\s?)(%|[A-Za-z]{1,3}|\\p{Script=Han}{1,2})$/u;\nconst NUM = /^[-+]?(?:NT\\$\\s?)?[\\d,]+(?:\\.\\d+)?\\s?(?:%|[A-Za-z]{1,3}|\\p{Script=Han}{1,2})?$/u;\n\nexport interface MarkdownProps {\n /** The Markdown text. */\n children: string;\n /** Only inline syntax (code, links, bold, italic), no paragraphs: for a one-line summary such as a README's first\n * sentence. Line breaks become spaces. */\n inline?: boolean;\n /** small: 13 px, for notes. Default: the same 16 px as the text around it. */\n size?: 'body' | 'small';\n /** The heading level `#` becomes. Default 4: # is an h4 (20 px), ## an h5, ### and deeper h6 (both 16 px bold). */\n topLevel?: 1 | 2 | 3 | 4 | 5 | 6;\n /** Link schemes of your own, such as ['fn', 'file']: [_sync_as](fn:harness/controller.py:VirtualRouter._sync_as)\n * goes to linkHref and onLink as written, which decide what it opens. javascript:, data: and vbscript: never link. */\n schemes?: string[];\n /** The address of a link (after the http, https, mailto or relative check); return undefined for no link. */\n linkHref?: (href: string) => string | undefined | null;\n /** A plain click on a link (the default navigation is prevented; Ctrl, ⌘ or Shift still open linkHref). */\n onLink?: (href: string, e: React.MouseEvent<HTMLElement>) => void;\n /** Inline code that is a path (harness/routing.py:108, docs/a.md) and paths in code blocks: their link. Same as\n * CodeView's refHref. */\n refHref?: RefHref;\n /** A plain click on such a path. Same as CodeView's onRef. */\n onRef?: OnRef;\n /** Words that get an explanation (Term variant=\"inline\"): matched whole and case-sensitive in plain text, not in\n * inline code, link text or headings; fenced code blocks match them in comments and strings. `[cookie](term:cookie)`\n * marks one explicitly, wherever it is. */\n terms?: readonly TermDef[];\n /** 'first' (default): each word only where it first appears in a paragraph, list item or table cell. 'all': everywhere. */\n termsMark?: TermsMark;\n /** Extra class on the root element. */\n className?: string;\n}\n\n/** Markdown from project documents and code comments, in the system's own type, code and table styles. Never runs HTML:\n * tags are dropped and their text kept; links only to http, https, mailto and relative addresses. */\nexport function Markdown(p: MarkdownProps) {\n // Keys count from 0 on every render, so the same source gives the same keys and nothing remounts.\n let n = 0;\n const termsMark = p.termsMark ?? 'first';\n const termRe = React.useMemo(() => termPattern(p.terms), [p.terms]);\n const c: Ctx = {\n k: () => 'm' + n++,\n schemes: p.schemes,\n linkHref: p.linkHref,\n onLink: p.onLink,\n refHref: p.refHref,\n onRef: p.onRef,\n terms: p.terms,\n termsMark,\n termRe,\n };\n const src = String(p.children ?? '').replace(/\\r\\n?/g, '\\n');\n const cls = cx('ui-md', p.size === 'small' && 'is-small', p.className);\n if (p.inline) return <span className={cx(cls, 'is-inline')}>{inline(src.trim().replace(/\\n\\s*\\n/g, '\\n'), block(c))}</span>;\n const top = p.topLevel ?? 4;\n const render = (blocks: Block[]): React.ReactNode[] =>\n blocks.map((b) => {\n switch (b.t) {\n case 'h': {\n const H = `h${Math.min(6, top + b.level - 1)}` as 'h4';\n return (\n <H key={c.k()} className=\"ui-md-h\">\n {inline(b.text, noTerms(c))}\n </H>\n );\n }\n case 'p':\n return <p key={c.k()}>{inline(b.text, block(c))}</p>;\n case 'hr':\n return <hr key={c.k()} />;\n case 'details':\n return (\n <MdDetails key={c.k()} summary={inline(b.summary, noTerms(c))}>\n {render(b.blocks)}\n </MdDetails>\n );\n case 'alert':\n return (\n <Alert key={c.k()} tone={b.tone} className=\"ui-md-alert\">\n {render(b.blocks)}\n </Alert>\n );\n case 'quote':\n return <blockquote key={c.k()}>{render(b.blocks)}</blockquote>;\n case 'list': {\n const items = b.items.map((it) => {\n const key = c.k();\n if (!(it.length === 1 && it[0].t === 'p')) return <li key={key}>{render(it)}</li>;\n const nodes = inline(it[0].text, block(c));\n const row = rowLink(nodes);\n return row ? (\n <li key={key} className=\"ui-md-rowitem\">\n {row}\n </li>\n ) : (\n <li key={key}>{nodes}</li>\n );\n });\n return b.ordered ? (\n <ol key={c.k()} start={b.start === 1 ? undefined : b.start}>\n {items}\n </ol>\n ) : (\n <ul key={c.k()}>{items}</ul>\n );\n }\n case 'code':\n return (\n <CodeView\n key={c.k()}\n className=\"ui-md-code\"\n code={b.code}\n language={fenceLang(b.lang)}\n languageLabel={b.lang ? undefined : false}\n copy\n lineNumbers={false}\n refHref={p.refHref}\n onRef={p.onRef}\n terms={p.terms}\n termsMark={termsMark}\n />\n );\n case 'table': {\n // Numbers right-aligned: a column whose cells are all numbers, unless the source sets its alignment.\n const n = b.head.length;\n const numeric = b.head.map((_, j) => b.rows.length > 0 && b.rows.every((r) => !r[j] || NUM.test(r[j])));\n const align = (j: number): React.CSSProperties | undefined => {\n const a = b.align[j] ?? (numeric[j] ? 'right' : null);\n return a ? { textAlign: a } : undefined;\n };\n return (\n <MdTable\n key={c.k()}\n label={b.head.map(plain).join('、')}\n heads={b.head.map((h) => inline(h, noTerms(c)))}\n headText={b.head.map(plain)}\n rows={b.rows.map((r) =>\n Array.from({ length: n }, (_, j) => {\n // A number column: the figures in Geist Mono (td.is-num), the unit (「46 分」「3.5 GB」) in the text font.\n const u = numeric[j] ? NUM_UNIT.exec(r[j] ?? '') : null;\n return u ? (\n <>\n {inline(u[1], block(c))}\n {u[2]}\n <span className=\"ui-unit\">{u[3]}</span>\n </>\n ) : (\n inline(r[j] ?? '', block(c))\n );\n }),\n )}\n numeric={numeric}\n align={align}\n />\n );\n }\n }\n });\n return <div className={cls}>{render(parse(src.split('\\n')))}</div>;\n}\n\n/** A header cell as plain text, for the label above each value when a narrow table turns into cards. */\nconst plain = (md: string) =>\n md\n .replace(/\\[([^\\]]*)\\]\\([^)]*\\)/g, '$1')\n .replace(/[`*_]/g, '')\n .trim();\n\n/** DA: a <details> block: a button with the summary, closed at first. The closed content stays in the page\n * (hidden=\"until-found\"), so the browser's find opens it, as in Section. */\nfunction MdDetails({ summary, children }: { summary: React.ReactNode; children: React.ReactNode }) {\n const [open, setOpen] = React.useState(false);\n const id = React.useId();\n const body = React.useRef<HTMLDivElement>(null);\n React.useLayoutEffect(() => {\n const el = body.current;\n if (!el) return;\n if (open) {\n el.removeAttribute('hidden');\n return;\n }\n el.setAttribute('hidden', 'until-found');\n const found = () => setOpen(true);\n el.addEventListener('beforematch', found);\n return () => el.removeEventListener('beforematch', found);\n }, [open]);\n return (\n <div className={cx('ui-md-details', open && 'is-open')}>\n <button type=\"button\" className=\"ui-md-summary\" aria-expanded={open} aria-controls={id} onClick={() => setOpen(!open)}>\n <Icon name=\"caret-right\" size={16} className=\"ui-md-caret\" />\n <span>{summary}</span>\n </button>\n <div id={id} ref={body} className=\"ui-md-details-body\">\n {children}\n </div>\n </div>\n );\n}\n\n/** A Markdown table: column borders in the header drag; the corner button shows the whole table in a wide dialog.\n * Under 480 px every row is a card instead, without either. The border, the dialog and the copy icon are the same as\n * DataTable's (internal/tableTools). */\nfunction MdTable(p: {\n label: string;\n heads: React.ReactNode[];\n headText: string[];\n rows: React.ReactNode[][];\n numeric: boolean[];\n align: (j: number) => React.CSSProperties | undefined;\n}) {\n const [widths, setWidths] = React.useState<number[] | null>(null);\n const [big, setBig] = React.useState(false);\n const [dragging, setDragging] = React.useState(false);\n const table = React.useRef<HTMLTableElement>(null);\n // Rounded up: a fixed column a fraction of a pixel narrower than it was drawn would wrap its longest word.\n const measure = () =>\n [...(table.current?.querySelectorAll<HTMLElement>('thead th') ?? [])].map((th) => Math.ceil(th.getBoundingClientRect().width / cssZoom(th)));\n // The drawn widths, kept for the borders' aria-valuenow (refs are not read while rendering).\n const [measured, setMeasured] = React.useState<number[]>([]);\n React.useLayoutEffect(() => {\n const el = table.current;\n if (!el) return;\n const update = () => {\n const m = [...el.querySelectorAll<HTMLElement>('thead th')].map((th) => Math.ceil(th.getBoundingClientRect().width / cssZoom(th)));\n setMeasured((old) => (old.length === m.length && old.every((v, i) => v === m[i]) ? old : m));\n };\n update();\n const ro = resizeObserver(update);\n ro?.observe(el);\n return () => ro?.disconnect();\n }, []);\n const body = (resize: boolean) => (\n <table\n ref={resize ? table : undefined}\n className=\"ui-md-table\"\n style={resize && widths ? { width: widths.reduce((a, b) => a + b, 0), tableLayout: 'fixed', minWidth: 0 } : undefined}\n >\n {resize && widths ? (\n <colgroup>\n {widths.map((w, j) => (\n <col key={j} style={{ width: w }} />\n ))}\n </colgroup>\n ) : null}\n <thead>\n <tr>\n {p.heads.map((h, j) => (\n <th key={j} style={p.align(j)}>\n {h}\n {resize ? (\n <ColResize\n name={p.headText[j]}\n width={widths?.[j] ?? measured[j] ?? 0}\n start={() => (widths ?? measure())[j]}\n onWidth={(w) => {\n const next = (widths ?? measure()).slice();\n next[j] = w;\n setWidths(next);\n }}\n onReset={() => setWidths(null)}\n onDragging={setDragging}\n />\n ) : null}\n </th>\n ))}\n </tr>\n </thead>\n <tbody>\n {p.rows.map((r, ri) => (\n <tr key={ri}>\n {r.map((cell, j) => (\n <td key={j} className={p.numeric[j] ? 'is-num' : undefined} style={p.align(j)} data-label={p.headText[j]}>\n {cell}\n </td>\n ))}\n </tr>\n ))}\n </tbody>\n </table>\n );\n return (\n <div className={cx('ui-md-tablebox', dragging && 'is-resizing')}>\n <div className=\"ui-md-table-tools\">\n <ZoomButton onClick={() => setBig(true)} />\n </div>\n <div className=\"ui-md-table-wrap\" tabIndex={0} role=\"region\" aria-label={p.label}>\n {body(true)}\n </div>\n <TableDialog open={big} onClose={() => setBig(false)}>\n <div className=\"ui-md ui-md-table-wrap\" tabIndex={0} role=\"region\" aria-label={p.label}>\n {body(false)}\n </div>\n </TableDialog>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAcA,aAAaA,mBAAY;AAiBzB,MAAM,eAAe;AACrB,MAAM,cAAc;AACpB,MAAM,UAAU;AAEhB,MAAM,QAAQ;AACd,MAAM,aAAwC;CAAE,MAAM;CAAQ,KAAK;CAAW,WAAW;CAAQ,SAAS;CAAW,SAAS;AAAS;AAEvI,MAAM,QAAQ;AACd,MAAM,UAAU;AAChB,MAAM,KAAK;AACX,MAAM,OAAO;AACb,MAAM,QAAQ;AACd,MAAM,YAAY;AAElB,SAAS,MAAM,MAAwB;CACrC,IAAI,IAAI,KAAK,KAAK;CAClB,IAAI,EAAE,WAAW,GAAG,GAAG,IAAI,EAAE,MAAM,CAAC;CACpC,IAAI,EAAE,SAAS,GAAG,KAAK,CAAC,EAAE,SAAS,KAAK,GAAG,IAAI,EAAE,MAAM,GAAG,EAAE;CAC5D,MAAM,MAAgB,CAAC;CACvB,IAAI,MAAM;CACV,IAAI,OAAO;CACX,KAAK,IAAI,IAAI,GAAG,IAAI,EAAE,QAAQ,KAAK;EACjC,MAAM,IAAI,EAAE;EACZ,IAAI,MAAM,QAAQ,EAAE,IAAI,OAAO,KAAK;GAClC,OAAO;GAC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Y,WAAW,EAAE,QAAQ,KAAK,WAAW,KAAA;IAAW,OAAO,EAAE,MAAM,CAAC;IAAG,cAAY,EAAE,SAAS;IACnG,UAAA;GACC,GAFK,CAEL,CACL,EACC,GANK,EAML,CACL,EACI,CAAA;EACF;;CAET,OACE,qBAAC,OAAD;EAAK,WAAW,GAAG,kBAAkB,YAAY,aAAa;EAA9D,UAAA;GACE,oBAAC,OAAD;IAAK,WAAU;IACb,UAAA,oBAAC,YAAD,EAAY,eAAe,OAAO,IAAI,EAAI,CAAA;GACvC,CAAA;GACL,oBAAC,OAAD;IAAK,WAAU;IAAmB,UAAU;IAAG,MAAK;IAAS,cAAY,EAAE;IACxE,UAAA,KAAK,IAAI;GACP,CAAA;GACL,oBAAC,aAAD;IAAa,MAAM;IAAK,eAAe,OAAO,KAAK;IACjD,UAAA,oBAAC,OAAD;KAAK,WAAU;KAAyB,UAAU;KAAG,MAAK;KAAS,cAAY,EAAE;KAC9E,UAAA,KAAK,KAAK;IACR,CAAA;GACM,CAAA;EACV;;AAET"}
|
|
@@ -3,7 +3,7 @@ import { tr } from "../../i18n.js";
|
|
|
3
3
|
import { Icon, IconOf } from "../../icons/Icon.js";
|
|
4
4
|
import { dropTransition, useMoving } from "../../motion.js";
|
|
5
5
|
import { announce } from "../../announce.js";
|
|
6
|
-
import { cx } from "../../internal/util.js";
|
|
6
|
+
import { cssZoom, cx } from "../../internal/util.js";
|
|
7
7
|
import { devWarn } from "../../internal/dev.js";
|
|
8
8
|
import { Tooltip } from "../Tooltip/Tooltip.js";
|
|
9
9
|
import { includeIcons } from "../../icons/store.js";
|
|
@@ -89,7 +89,7 @@ function SideNav({ sections, value, onChange, collapsed = false, onCollapsedChan
|
|
|
89
89
|
}
|
|
90
90
|
const box = wrap.current;
|
|
91
91
|
if (!el || !box) return;
|
|
92
|
-
const y = el.getBoundingClientRect().top - box.getBoundingClientRect().top;
|
|
92
|
+
const y = (el.getBoundingClientRect().top - box.getBoundingClientRect().top) / cssZoom(box);
|
|
93
93
|
const top = Math.round(y) + 8;
|
|
94
94
|
const bottom = Math.round(box.clientHeight - y - el.offsetHeight) + 8;
|
|
95
95
|
const prev = last.current;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SideNav.js","names":["phCaretRight","phPushPin","phSidebarSimple"],"sources":["../../../src/components/SideNav/SideNav.tsx"],"sourcesContent":["import * as React from 'react';\nimport { tr } from '../../i18n';\nimport { Icon, IconOf, type IconSource } from '../../icons/Icon';\nimport { dropTransition, useMoving } from '../../motion';\nimport { announce } from '../../announce';\nimport { cx } from '../../internal/util';\nimport { devWarn } from '../../internal/dev';\nimport { Tooltip } from '../Tooltip/Tooltip';\nimport { includeIcons } from '../../icons/store';\nimport phCaretRight from '../../icons/ph/caret-right';\nimport phPushPin from '../../icons/ph/push-pin';\nimport phSidebarSimple from '../../icons/ph/sidebar-simple';\n\nincludeIcons(phCaretRight, phPushPin, phSidebarSimple);\n\nexport interface NavItem {\n id: string;\n label: string;\n /** Top-level items have an icon; the selected one is filled. */\n icon?: IconSource;\n /** Second level, shown under the item; it opens and closes. */\n children?: NavItem[];\n}\n\nexport interface NavSection {\n items: NavItem[];\n}\n\n/** The product at the top of the sidebar. */\nexport interface NavBrand {\n /** Logo or colour block, at most 24 px: stays where it is, collapsed and open. Default: the first character of\n * `name` in an accent square. */\n mark?: React.ReactNode;\n /** The product name: shown beside the mark when the sidebar is open, the link's name when collapsed. */\n name: string;\n /** Usually the home page. */\n href?: string;\n onClick?: (e: React.MouseEvent<HTMLElement>) => void;\n}\n\nconst isBrand = (b: unknown): b is NavBrand =>\n !!b && typeof b === 'object' && !React.isValidElement(b) && !Array.isArray(b) && typeof (b as NavBrand).name === 'string';\n\nfunction NavBrandRow({ brand, collapsed }: { brand: React.ReactNode | NavBrand; collapsed: boolean }) {\n const spec: NavBrand | null = isBrand(brand) ? brand : typeof brand === 'string' ? { name: brand } : null;\n devWarn(\n !spec && collapsed,\n 'SideNav',\n 'brand is an element, so the collapsed sidebar cannot tell which part is the logo and hides all of it. Pass brand={{ mark, name, href }}: collapsed shows mark, expanded adds the name.',\n );\n if (!spec) return <div className=\"ui-nav-brand\">{collapsed ? null : (brand as React.ReactNode)}</div>;\n const inner = (\n <>\n <span className=\"ui-nav-mark\" aria-hidden=\"true\">\n {spec.mark ?? <span className=\"ui-nav-monogram\">{Array.from(spec.name)[0]}</span>}\n </span>\n <span className=\"ui-nav-brand-name\">{spec.name}</span>\n </>\n );\n // Collapsed, the name is invisible but the link keeps it as its label.\n const label = collapsed ? spec.name : undefined;\n return (\n <div className=\"ui-nav-brand has-mark\">\n {spec.href ? (\n <a className=\"ui-nav-brand-link\" href={spec.href} onClick={spec.onClick} aria-label={label}>\n {inner}\n </a>\n ) : spec.onClick ? (\n <button type=\"button\" className=\"ui-nav-brand-link\" onClick={spec.onClick} aria-label={label}>\n {inner}\n </button>\n ) : (\n <span className=\"ui-nav-brand-link\" aria-label={label} role={label ? 'img' : undefined}>\n {inner}\n </span>\n )}\n </div>\n );\n}\n\nexport interface SideNavProps {\n /** Groups separated by a divider. */\n sections: NavSection[];\n /** Id of the current page. */\n value: string;\n /** Called with the id of the item the person picks. */\n onChange?: (id: string) => void;\n /** 72 px with icons only, labels as tooltips. */\n collapsed?: boolean;\n /** Adds the collapse button at the bottom left; called with the state it asks for. */\n onCollapsedChange?: (collapsed: boolean) => void;\n /** Whether the sidebar is pinned: the pin button is filled and says 「取消釘選」. */\n pinned?: boolean;\n /** Adds the pin button at the bottom left (AppShell): pinned, the sidebar stays; not pinned, it hides to icons.\n * Called with the state it asks for. */\n onPinnedChange?: (pinned: boolean) => void;\n /** @deprecated Use `onCollapsedChange`. */\n onToggle?: () => void;\n /** @deprecated Use `onPinnedChange`. */\n onPin?: () => void;\n /** The product at the top. Prefer { mark, name, href }: collapsed (72 px) it shows only the mark, still a link\n * named by `name`; open, the mark with the name fading in beside it. Text alone gets its first character in an\n * accent square as the mark. Any other element is hidden while collapsed. */\n brand?: React.ReactNode | NavBrand;\n /** Default 「主要導覽」. */\n label?: string;\n /** Extra class on the root element. */\n className?: string;\n}\n\n/** The 240 px dashboard sidebar (72 px collapsed). The selection bar moves like a droplet. */\nexport function SideNav({\n sections,\n value,\n onChange,\n collapsed = false,\n onCollapsedChange,\n pinned = false,\n onPinnedChange,\n onToggle,\n onPin,\n brand,\n label,\n className,\n}: SideNavProps) {\n devWarn(onToggle && !onCollapsedChange, 'SideNav', '`onToggle` is deprecated. Pass onCollapsedChange={(collapsed) => …}: it gets the state to set.');\n devWarn(onPin && !onPinnedChange, 'SideNav', '`onPin` is deprecated. Pass onPinnedChange={(pinned) => …}: it gets the state to set.');\n const toggle = onCollapsedChange ? () => onCollapsedChange(!collapsed) : onToggle;\n const pin = onPinnedChange ? () => onPinnedChange(!pinned) : onPin;\n const refs = React.useRef<Record<string, HTMLButtonElement | null>>({});\n const wrap = React.useRef<HTMLDivElement>(null);\n const [bar, setBar] = React.useState({ top: 0, bottom: 0, show: false, down: true });\n const last = React.useRef<{ top: number; bottom: number } | null>(null);\n const [moving, bump] = useMoving();\n // A page change is announced (not the first page): screen readers hear where they are now.\n const firstValue = React.useRef<string | undefined>(value);\n React.useEffect(() => {\n if (value === firstValue.current) return;\n firstValue.current = undefined;\n const all = sections.flatMap((sec) => sec.items.flatMap((it) => [it, ...(it.children ?? [])]));\n const it = all.find((x) => x.id === value);\n if (it) announce(it.label);\n // eslint-disable-next-line react-hooks/exhaustive-deps -- only when the page changes\n }, [value]);\n const [closed, setClosed] = React.useState<Record<string, boolean>>({});\n const closedKey = Object.keys(closed)\n .filter((k) => closed[k])\n .join();\n React.useLayoutEffect(() => {\n let el = refs.current[value];\n if (!el) {\n const parent = sections.flatMap((s) => s.items).find((it) => it.children?.some((c) => c.id === value));\n el = parent ? refs.current[parent.id] : null;\n }\n const box = wrap.current;\n if (!el || !box) return;\n const y = el.getBoundingClientRect().top - box.getBoundingClientRect().top;\n const top = Math.round(y) + 8;\n const bottom = Math.round(box.clientHeight - y - el.offsetHeight) + 8;\n const prev = last.current;\n if (prev && prev.top === top && prev.bottom === bottom) return;\n if (prev && prev.top !== top) bump();\n last.current = { top, bottom };\n setBar({ top, bottom, show: true, down: !prev || top >= prev.top });\n }, [value, collapsed, closedKey, sections, bump]);\n\n const row = (it: NavItem, sub: boolean): React.ReactNode[] => {\n const kids = it.children ?? [];\n const hasKids = kids.length > 0 && !collapsed;\n const isOpen = !closed[it.id];\n const selected = value === it.id || ((!hasKids || !isOpen) && kids.some((c) => c.id === value));\n const out: React.ReactNode[] = [\n <div key={it.id} className=\"ui-nav-row\">\n <button\n type=\"button\"\n ref={(n) => {\n refs.current[it.id] = n;\n }}\n className={cx('ui-nav-item', sub && 'is-sub', selected && 'is-selected')}\n aria-current={selected ? 'page' : undefined}\n aria-expanded={hasKids ? isOpen : undefined}\n aria-label={collapsed ? it.label : undefined}\n // Collapsed, a parent opens its first page; the page switches between its siblings itself.\n onClick={() => (hasKids ? setClosed({ ...closed, [it.id]: isOpen }) : onChange?.(kids[0]?.id ?? it.id))}\n >\n {it.icon && !sub ? <IconOf icon={it.icon} size={22} filled={selected} className=\"ui-nav-icon\" /> : null}\n {collapsed ? null : <span className=\"ui-nav-label\">{it.label}</span>}\n {hasKids ? <Icon name=\"caret-right\" size={16} className={cx('ui-nav-chev', isOpen && 'is-open')} /> : null}\n </button>\n {collapsed ? (\n <span className=\"ui-nav-tip\" role=\"tooltip\">\n {it.label}\n </span>\n ) : null}\n </div>,\n ];\n if (hasKids && isOpen) for (const c of kids) out.push(...row(c, true));\n return out;\n };\n\n const toggleLabel = collapsed ? tr('展開側邊欄') : tr('收合側邊欄');\n return (\n <aside className={cx('ui-sidenav', collapsed && 'is-collapsed', className)}>\n {brand ? <NavBrandRow brand={brand} collapsed={collapsed} /> : null}\n <nav className=\"ui-nav-list\" aria-label={label || tr('主要導覽')}>\n <div ref={wrap} className=\"ui-nav-inner\">\n {bar.show ? (\n <span\n className=\"ui-nav-bar\"\n aria-hidden=\"true\"\n style={{ top: bar.top, bottom: bar.bottom, transform: moving ? 'scaleX(.7)' : 'none', transition: dropTransition('top', 'bottom', bar.down) }}\n />\n ) : null}\n {sections.map((sec, i) => (\n <React.Fragment key={i}>\n {i > 0 ? <div className=\"ui-nav-divider\" role=\"separator\" /> : null}\n {sec.items.flatMap((it) => row(it, false))}\n </React.Fragment>\n ))}\n </div>\n </nav>\n {toggle || pin ? (\n <div className=\"ui-nav-foot\">\n {pin ? (\n <Tooltip label={pinned ? tr('取消釘選') : tr('釘選側邊欄')} side=\"right\" describe={false}>\n <button\n type=\"button\"\n className={cx('ui-nav-collapse', 'ui-nav-pin', pinned && 'is-on')}\n aria-pressed={pinned}\n aria-label={pinned ? tr('取消釘選') : tr('釘選側邊欄')}\n onClick={pin}\n >\n <Icon name=\"push-pin\" size={22} filled={pinned} />\n </button>\n </Tooltip>\n ) : null}\n {toggle ? (\n <Tooltip label={toggleLabel} side=\"right\" describe={false}>\n <button type=\"button\" className=\"ui-nav-collapse\" aria-label={toggleLabel} onClick={toggle}>\n <Icon name=\"sidebar-simple\" size={22} />\n </button>\n </Tooltip>\n ) : null}\n </div>\n ) : null}\n </aside>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;AAaA,aAAaA,qBAAcC,kBAAWC,sBAAe;AA2BrD,MAAM,WAAW,MACf,CAAC,CAAC,KAAK,OAAO,MAAM,YAAY,CAAC,MAAM,eAAe,CAAC,KAAK,CAAC,MAAM,QAAQ,CAAC,KAAK,OAAQ,EAAe,SAAS;AAEnH,SAAS,YAAY,EAAE,OAAO,aAAwE;CACpG,MAAM,OAAwB,QAAQ,KAAK,IAAI,QAAQ,OAAO,UAAU,WAAW,EAAE,MAAM,MAAM,IAAI;CACrG,QACE,CAAC,QAAQ,WACT,WACA,wLACF;CACA,IAAI,CAAC,MAAM,OAAO,oBAAC,OAAD;EAAK,WAAU;EAAgB,UAAA,YAAY,OAAQ;CAA+B,CAAA;CACpG,MAAM,QACJ,qBAAA,UAAA,EAAA,UAAA,CACE,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;KAAQ,UAAU;KAClD,UAAA,oBAAC,UAAD;MAAQ,MAAK;MAAS,WAAU;MAAkB,cAAY;MAAa,SAAS;MAClF,UAAA,oBAAC,MAAD;OAAM,MAAK;OAAiB,MAAM;MAAK,CAAA;KACjC,CAAA;IACD,CAAA,IACP,IACD;GACH,CAAA,IAAA;EACC;;AAEX"}
|
|
1
|
+
{"version":3,"file":"SideNav.js","names":["phCaretRight","phPushPin","phSidebarSimple"],"sources":["../../../src/components/SideNav/SideNav.tsx"],"sourcesContent":["import * as React from 'react';\nimport { tr } from '../../i18n';\nimport { Icon, IconOf, type IconSource } from '../../icons/Icon';\nimport { dropTransition, useMoving } from '../../motion';\nimport { announce } from '../../announce';\nimport { cssZoom, cx } from '../../internal/util';\nimport { devWarn } from '../../internal/dev';\nimport { Tooltip } from '../Tooltip/Tooltip';\nimport { includeIcons } from '../../icons/store';\nimport phCaretRight from '../../icons/ph/caret-right';\nimport phPushPin from '../../icons/ph/push-pin';\nimport phSidebarSimple from '../../icons/ph/sidebar-simple';\n\nincludeIcons(phCaretRight, phPushPin, phSidebarSimple);\n\nexport interface NavItem {\n id: string;\n label: string;\n /** Top-level items have an icon; the selected one is filled. */\n icon?: IconSource;\n /** Second level, shown under the item; it opens and closes. */\n children?: NavItem[];\n}\n\nexport interface NavSection {\n items: NavItem[];\n}\n\n/** The product at the top of the sidebar. */\nexport interface NavBrand {\n /** Logo or colour block, at most 24 px: stays where it is, collapsed and open. Default: the first character of\n * `name` in an accent square. */\n mark?: React.ReactNode;\n /** The product name: shown beside the mark when the sidebar is open, the link's name when collapsed. */\n name: string;\n /** Usually the home page. */\n href?: string;\n onClick?: (e: React.MouseEvent<HTMLElement>) => void;\n}\n\nconst isBrand = (b: unknown): b is NavBrand =>\n !!b && typeof b === 'object' && !React.isValidElement(b) && !Array.isArray(b) && typeof (b as NavBrand).name === 'string';\n\nfunction NavBrandRow({ brand, collapsed }: { brand: React.ReactNode | NavBrand; collapsed: boolean }) {\n const spec: NavBrand | null = isBrand(brand) ? brand : typeof brand === 'string' ? { name: brand } : null;\n devWarn(\n !spec && collapsed,\n 'SideNav',\n 'brand is an element, so the collapsed sidebar cannot tell which part is the logo and hides all of it. Pass brand={{ mark, name, href }}: collapsed shows mark, expanded adds the name.',\n );\n if (!spec) return <div className=\"ui-nav-brand\">{collapsed ? null : (brand as React.ReactNode)}</div>;\n const inner = (\n <>\n <span className=\"ui-nav-mark\" aria-hidden=\"true\">\n {spec.mark ?? <span className=\"ui-nav-monogram\">{Array.from(spec.name)[0]}</span>}\n </span>\n <span className=\"ui-nav-brand-name\">{spec.name}</span>\n </>\n );\n // Collapsed, the name is invisible but the link keeps it as its label.\n const label = collapsed ? spec.name : undefined;\n return (\n <div className=\"ui-nav-brand has-mark\">\n {spec.href ? (\n <a className=\"ui-nav-brand-link\" href={spec.href} onClick={spec.onClick} aria-label={label}>\n {inner}\n </a>\n ) : spec.onClick ? (\n <button type=\"button\" className=\"ui-nav-brand-link\" onClick={spec.onClick} aria-label={label}>\n {inner}\n </button>\n ) : (\n <span className=\"ui-nav-brand-link\" aria-label={label} role={label ? 'img' : undefined}>\n {inner}\n </span>\n )}\n </div>\n );\n}\n\nexport interface SideNavProps {\n /** Groups separated by a divider. */\n sections: NavSection[];\n /** Id of the current page. */\n value: string;\n /** Called with the id of the item the person picks. */\n onChange?: (id: string) => void;\n /** 72 px with icons only, labels as tooltips. */\n collapsed?: boolean;\n /** Adds the collapse button at the bottom left; called with the state it asks for. */\n onCollapsedChange?: (collapsed: boolean) => void;\n /** Whether the sidebar is pinned: the pin button is filled and says 「取消釘選」. */\n pinned?: boolean;\n /** Adds the pin button at the bottom left (AppShell): pinned, the sidebar stays; not pinned, it hides to icons.\n * Called with the state it asks for. */\n onPinnedChange?: (pinned: boolean) => void;\n /** @deprecated Use `onCollapsedChange`. */\n onToggle?: () => void;\n /** @deprecated Use `onPinnedChange`. */\n onPin?: () => void;\n /** The product at the top. Prefer { mark, name, href }: collapsed (72 px) it shows only the mark, still a link\n * named by `name`; open, the mark with the name fading in beside it. Text alone gets its first character in an\n * accent square as the mark. Any other element is hidden while collapsed. */\n brand?: React.ReactNode | NavBrand;\n /** Default 「主要導覽」. */\n label?: string;\n /** Extra class on the root element. */\n className?: string;\n}\n\n/** The 240 px dashboard sidebar (72 px collapsed). The selection bar moves like a droplet. */\nexport function SideNav({\n sections,\n value,\n onChange,\n collapsed = false,\n onCollapsedChange,\n pinned = false,\n onPinnedChange,\n onToggle,\n onPin,\n brand,\n label,\n className,\n}: SideNavProps) {\n devWarn(onToggle && !onCollapsedChange, 'SideNav', '`onToggle` is deprecated. Pass onCollapsedChange={(collapsed) => …}: it gets the state to set.');\n devWarn(onPin && !onPinnedChange, 'SideNav', '`onPin` is deprecated. Pass onPinnedChange={(pinned) => …}: it gets the state to set.');\n const toggle = onCollapsedChange ? () => onCollapsedChange(!collapsed) : onToggle;\n const pin = onPinnedChange ? () => onPinnedChange(!pinned) : onPin;\n const refs = React.useRef<Record<string, HTMLButtonElement | null>>({});\n const wrap = React.useRef<HTMLDivElement>(null);\n const [bar, setBar] = React.useState({ top: 0, bottom: 0, show: false, down: true });\n const last = React.useRef<{ top: number; bottom: number } | null>(null);\n const [moving, bump] = useMoving();\n // A page change is announced (not the first page): screen readers hear where they are now.\n const firstValue = React.useRef<string | undefined>(value);\n React.useEffect(() => {\n if (value === firstValue.current) return;\n firstValue.current = undefined;\n const all = sections.flatMap((sec) => sec.items.flatMap((it) => [it, ...(it.children ?? [])]));\n const it = all.find((x) => x.id === value);\n if (it) announce(it.label);\n // eslint-disable-next-line react-hooks/exhaustive-deps -- only when the page changes\n }, [value]);\n const [closed, setClosed] = React.useState<Record<string, boolean>>({});\n const closedKey = Object.keys(closed)\n .filter((k) => closed[k])\n .join();\n React.useLayoutEffect(() => {\n let el = refs.current[value];\n if (!el) {\n const parent = sections.flatMap((s) => s.items).find((it) => it.children?.some((c) => c.id === value));\n el = parent ? refs.current[parent.id] : null;\n }\n const box = wrap.current;\n if (!el || !box) return;\n const y = (el.getBoundingClientRect().top - box.getBoundingClientRect().top) / cssZoom(box);\n const top = Math.round(y) + 8;\n const bottom = Math.round(box.clientHeight - y - el.offsetHeight) + 8;\n const prev = last.current;\n if (prev && prev.top === top && prev.bottom === bottom) return;\n if (prev && prev.top !== top) bump();\n last.current = { top, bottom };\n setBar({ top, bottom, show: true, down: !prev || top >= prev.top });\n }, [value, collapsed, closedKey, sections, bump]);\n\n const row = (it: NavItem, sub: boolean): React.ReactNode[] => {\n const kids = it.children ?? [];\n const hasKids = kids.length > 0 && !collapsed;\n const isOpen = !closed[it.id];\n const selected = value === it.id || ((!hasKids || !isOpen) && kids.some((c) => c.id === value));\n const out: React.ReactNode[] = [\n <div key={it.id} className=\"ui-nav-row\">\n <button\n type=\"button\"\n ref={(n) => {\n refs.current[it.id] = n;\n }}\n className={cx('ui-nav-item', sub && 'is-sub', selected && 'is-selected')}\n aria-current={selected ? 'page' : undefined}\n aria-expanded={hasKids ? isOpen : undefined}\n aria-label={collapsed ? it.label : undefined}\n // Collapsed, a parent opens its first page; the page switches between its siblings itself.\n onClick={() => (hasKids ? setClosed({ ...closed, [it.id]: isOpen }) : onChange?.(kids[0]?.id ?? it.id))}\n >\n {it.icon && !sub ? <IconOf icon={it.icon} size={22} filled={selected} className=\"ui-nav-icon\" /> : null}\n {collapsed ? null : <span className=\"ui-nav-label\">{it.label}</span>}\n {hasKids ? <Icon name=\"caret-right\" size={16} className={cx('ui-nav-chev', isOpen && 'is-open')} /> : null}\n </button>\n {collapsed ? (\n <span className=\"ui-nav-tip\" role=\"tooltip\">\n {it.label}\n </span>\n ) : null}\n </div>,\n ];\n if (hasKids && isOpen) for (const c of kids) out.push(...row(c, true));\n return out;\n };\n\n const toggleLabel = collapsed ? tr('展開側邊欄') : tr('收合側邊欄');\n return (\n <aside className={cx('ui-sidenav', collapsed && 'is-collapsed', className)}>\n {brand ? <NavBrandRow brand={brand} collapsed={collapsed} /> : null}\n <nav className=\"ui-nav-list\" aria-label={label || tr('主要導覽')}>\n <div ref={wrap} className=\"ui-nav-inner\">\n {bar.show ? (\n <span\n className=\"ui-nav-bar\"\n aria-hidden=\"true\"\n style={{ top: bar.top, bottom: bar.bottom, transform: moving ? 'scaleX(.7)' : 'none', transition: dropTransition('top', 'bottom', bar.down) }}\n />\n ) : null}\n {sections.map((sec, i) => (\n <React.Fragment key={i}>\n {i > 0 ? <div className=\"ui-nav-divider\" role=\"separator\" /> : null}\n {sec.items.flatMap((it) => row(it, false))}\n </React.Fragment>\n ))}\n </div>\n </nav>\n {toggle || pin ? (\n <div className=\"ui-nav-foot\">\n {pin ? (\n <Tooltip label={pinned ? tr('取消釘選') : tr('釘選側邊欄')} side=\"right\" describe={false}>\n <button\n type=\"button\"\n className={cx('ui-nav-collapse', 'ui-nav-pin', pinned && 'is-on')}\n aria-pressed={pinned}\n aria-label={pinned ? tr('取消釘選') : tr('釘選側邊欄')}\n onClick={pin}\n >\n <Icon name=\"push-pin\" size={22} filled={pinned} />\n </button>\n </Tooltip>\n ) : null}\n {toggle ? (\n <Tooltip label={toggleLabel} side=\"right\" describe={false}>\n <button type=\"button\" className=\"ui-nav-collapse\" aria-label={toggleLabel} onClick={toggle}>\n <Icon name=\"sidebar-simple\" size={22} />\n </button>\n </Tooltip>\n ) : null}\n </div>\n ) : null}\n </aside>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;AAaA,aAAaA,qBAAcC,kBAAWC,sBAAe;AA2BrD,MAAM,WAAW,MACf,CAAC,CAAC,KAAK,OAAO,MAAM,YAAY,CAAC,MAAM,eAAe,CAAC,KAAK,CAAC,MAAM,QAAQ,CAAC,KAAK,OAAQ,EAAe,SAAS;AAEnH,SAAS,YAAY,EAAE,OAAO,aAAwE;CACpG,MAAM,OAAwB,QAAQ,KAAK,IAAI,QAAQ,OAAO,UAAU,WAAW,EAAE,MAAM,MAAM,IAAI;CACrG,QACE,CAAC,QAAQ,WACT,WACA,wLACF;CACA,IAAI,CAAC,MAAM,OAAO,oBA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MAAD;OAAM,MAAK;OAAW,MAAM;OAAI,QAAQ;MAAS,CAAA;KAC3C,CAAA;IACD,CAAA,IACP,MACH,SACC,oBAAC,SAAD;KAAS,OAAO;KAAa,MAAK;KAAQ,UAAU;KAClD,UAAA,oBAAC,UAAD;MAAQ,MAAK;MAAS,WAAU;MAAkB,cAAY;MAAa,SAAS;MAClF,UAAA,oBAAC,MAAD;OAAM,MAAK;OAAiB,MAAM;MAAK,CAAA;KACjC,CAAA;IACD,CAAA,IACP,IACD;GACH,CAAA,IAAA;EACC;;AAEX"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { tr } from "../../i18n.js";
|
|
3
|
-
import { browserKey, cx, resizeObserver } from "../../internal/util.js";
|
|
3
|
+
import { browserKey, cssZoom, cx, resizeObserver } from "../../internal/util.js";
|
|
4
4
|
import { devWarn } from "../../internal/dev.js";
|
|
5
5
|
import { announce } from "../../announce.js";
|
|
6
6
|
import { nextPreset } from "../../internal/clickSteps.js";
|
|
@@ -85,7 +85,7 @@ function SplitPane({ a, b, defaultB = 420, minA = 360, minB = 280, storageKey, l
|
|
|
85
85
|
if (!d.moved && Math.abs(e.clientX - d.x) < 4) return;
|
|
86
86
|
d.moved = true;
|
|
87
87
|
const r = root.current.getBoundingClientRect();
|
|
88
|
-
set(r.right - e.clientX - HANDLE / 2, false);
|
|
88
|
+
set((r.right - e.clientX) / cssZoom(root.current) - HANDLE / 2, false);
|
|
89
89
|
};
|
|
90
90
|
const presets = [
|
|
91
91
|
minB,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SplitPane.js","names":[],"sources":["../../../src/components/SplitPane/SplitPane.tsx"],"sourcesContent":["import * as React from 'react';\nimport { tr } from '../../i18n';\nimport { browserKey, cx, resizeObserver } from '../../internal/util';\nimport { devWarn } from '../../internal/dev';\nimport { announce } from '../../announce';\nimport { DRAG_MIN, nextPreset } from '../../internal/clickSteps';\n\nexport interface SplitPaneProps {\n /** The main area, on the left. */\n a: React.ReactNode;\n /** The side panel, on the right; its width is what the divider changes. */\n b: React.ReactNode;\n /** px. The side panel's width at first and after a double-click on the divider. Default 420. */\n defaultB?: number;\n /** px. The main area never gets narrower than this. Default 360. */\n minA?: number;\n /** px. The side panel never gets narrower than this. Default 280. */\n minB?: number;\n /** Remembers the side panel's width in localStorage under this name. Without it the width lasts until the page reloads. */\n storageKey?: string;\n /** Names the divider for screen readers. Default 「調整面板寬度」. */\n label?: string;\n /** After every change, with the side panel's new width in px. */\n onResize?: (b: number) => void;\n /** Extra class on the root element. */\n className?: string;\n}\n\n/** Width of the divider between the two areas, in px; a 48 px hit area is drawn over it. */\nconst HANDLE = 16;\n/** Narrower than this (px, the component's own width), the two areas stack and the divider goes away. */\nconst STACK = 960;\n/** One arrow key press, in px. */\nconst STEP = 16;\n\nconst read = (key: string | undefined): number | null => {\n if (!key) return null;\n try {\n const v = Number(window.localStorage.getItem('ui-split:' + key));\n return Number.isFinite(v) && v > 0 ? v : null;\n } catch {\n return null;\n }\n};\nconst write = (key: string | undefined, v: number) => {\n if (!key) return;\n try {\n window.localStorage.setItem('ui-split:' + key, String(Math.round(v)));\n } catch {\n // Storage blocked or full: the width still changes, it is just not remembered.\n }\n};\n\n/** A main area and a side panel with a divider between them that can be dragged, moved with the arrow keys, stepped\n * through preset widths with a click (narrowest, default, 1.5 times the default) and reset with a double-click or Enter. Under 960 px (its own width) the two stack, side panel below, without the divider. */\nexport function SplitPane({ a, b, defaultB = 420, minA = 360, minB = 280, storageKey, label, onResize, className }: SplitPaneProps) {\n devWarn(defaultB < minB, 'SplitPane', `defaultB (${defaultB} px) is under minB (${minB} px): the panel starts at ${minB} px. Raise defaultB or lower minB.`);\n const root = React.useRef<HTMLDivElement>(null);\n const [width, setWidth] = React.useState(0);\n // The stored width, read on the first render in the browser. The grid columns are set only once the component has\n // measured itself, so the server's render and the first one in the browser match.\n const [side, setSide] = React.useState(() => (typeof window === 'undefined' ? null : read(storageKey)) ?? defaultB);\n const [drag, setDrag] = React.useState(false);\n // Read by the move and up handlers: a move can come before the render that follows the press. `moved` turns a press\n // into a drag once the pointer has gone DRAG_MIN px; released before that it was a click.\n const dragging = React.useRef<{ x: number; moved: boolean } | null>(null);\n const id = React.useId();\n React.useLayoutEffect(() => {\n const el = root.current;\n if (!el) return;\n const measure = () => setWidth(el.clientWidth);\n measure();\n const ro = resizeObserver(measure);\n ro?.observe(el);\n return () => ro?.disconnect();\n }, []);\n const stacked = width > 0 && width < STACK;\n // The side panel's width as it can be now: both areas keep their minimum.\n const maxB = Math.max(minB, width - HANDLE - minA);\n const shown = Math.round(Math.min(maxB, Math.max(minB, side)));\n const valueA = Math.max(0, width - HANDLE - shown);\n // The width after the last move, for the release that stores it (the render with it may not have happened yet).\n const latest = React.useRef(shown);\n const set = (v: number, keep = true) => {\n const next = Math.round(Math.min(maxB, Math.max(minB, v)));\n latest.current = next;\n setSide(next);\n if (keep) write(storageKey, next);\n onResize?.(next);\n };\n const onKey = (e: React.KeyboardEvent) => {\n if (browserKey(e)) return;\n // The value is the main area's width: ← makes it narrower (the panel wider), Home makes it as narrow as it goes.\n const to =\n e.key === 'ArrowLeft'\n ? shown + STEP\n : e.key === 'ArrowRight'\n ? shown - STEP\n : e.key === 'Home'\n ? maxB\n : e.key === 'End'\n ? minB\n : e.key === 'Enter'\n ? defaultB\n : null;\n if (to == null) return;\n e.preventDefault();\n set(to);\n };\n const onDown = (e: React.PointerEvent<HTMLDivElement>) => {\n if (e.button !== 0) return;\n e.preventDefault();\n // Keeps getting the moves when the pointer leaves the divider (a fast drag).\n try {\n e.currentTarget.setPointerCapture?.(e.pointerId);\n } catch {\n // No such pointer (a synthetic event): moves still come while over the divider.\n }\n e.currentTarget.focus({ preventScroll: true });\n dragging.current = { x: e.clientX, moved: false };\n setDrag(true);\n };\n const onMove = (e: React.PointerEvent<HTMLDivElement>) => {\n const d = dragging.current;\n if (!d || !root.current) return;\n if (!d.moved && Math.abs(e.clientX - d.x) < DRAG_MIN) return;\n d.moved = true;\n const r = root.current.getBoundingClientRect();\n set(r.right - e.clientX - HANDLE / 2, false);\n };\n // A click without dragging (WCAG 2.5.7): the next preset width of the panel, announced.\n const presets = [minB, defaultB, defaultB * 1.5];\n const onUp = (e: React.PointerEvent<HTMLDivElement>, cancel = false) => {\n const d = dragging.current;\n if (!d) return;\n dragging.current = null;\n setDrag(false);\n if (!d.moved && !cancel) {\n const next = Math.round(Math.min(maxB, Math.max(minB, nextPreset(shown, presets))));\n set(next);\n announce(tr('面板 {n} px', { n: next }));\n }\n try {\n if (e.currentTarget.hasPointerCapture?.(e.pointerId)) e.currentTarget.releasePointerCapture(e.pointerId);\n } catch {\n // Already released.\n }\n if (root.current) write(storageKey, latest.current);\n };\n return (\n <div\n ref={root}\n className={cx('ui-split', stacked && 'is-stacked', drag && 'is-dragging', className)}\n style={stacked || !width ? undefined : { gridTemplateColumns: `minmax(0, 1fr) ${HANDLE}px ${shown}px` }}\n >\n <div className=\"ui-split-a\">{a}</div>\n {stacked ? null : (\n <div\n role=\"separator\"\n tabIndex={0}\n aria-orientation=\"vertical\"\n aria-label={label || tr('調整面板寬度')}\n aria-controls={id}\n aria-valuenow={valueA}\n aria-valuemin={minA}\n aria-valuemax={Math.max(minA, width - HANDLE - minB)}\n aria-valuetext={tr('主要區域 {a} px,面板 {b} px', { a: valueA, b: shown })}\n aria-description={tr('拖曳或按 ← → 調整;按一下切換預設寬度,按兩下或 Enter 還原')}\n className=\"ui-split-handle\"\n onKeyDown={onKey}\n onPointerDown={onDown}\n onPointerMove={onMove}\n onPointerUp={onUp}\n onPointerCancel={(e) => onUp(e, true)}\n onDoubleClick={() => set(defaultB)}\n >\n {/* GB: a small handle in the middle of the line, so the divider reads as something to drag. */}\n <span className=\"ui-split-grip\" aria-hidden=\"true\">\n <i />\n <i />\n <i />\n </span>\n </div>\n )}\n <div id={id} className=\"ui-split-b\">\n {b}\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;AA6BA,MA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AAY;KAA5C,UAAA;MACE,oBAAC,KAAD,CAAI,CAAA;MACJ,oBAAC,KAAD,CAAI,CAAA;MACJ,oBAAC,KAAD,CAAI,CAAA;KACA;;GACH,CAAA;GAEP,oBAAC,OAAD;IAAS;IAAI,WAAU;IACpB,UAAA;GACE,CAAA;EACF;;AAET"}
|
|
1
|
+
{"version":3,"file":"SplitPane.js","names":[],"sources":["../../../src/components/SplitPane/SplitPane.tsx"],"sourcesContent":["import * as React from 'react';\nimport { tr } from '../../i18n';\nimport { browserKey, cssZoom, cx, resizeObserver } from '../../internal/util';\nimport { devWarn } from '../../internal/dev';\nimport { announce } from '../../announce';\nimport { DRAG_MIN, nextPreset } from '../../internal/clickSteps';\n\nexport interface SplitPaneProps {\n /** The main area, on the left. */\n a: React.ReactNode;\n /** The side panel, on the right; its width is what the divider changes. */\n b: React.ReactNode;\n /** px. The side panel's width at first and after a double-click on the divider. Default 420. */\n defaultB?: number;\n /** px. The main area never gets narrower than this. Default 360. */\n minA?: number;\n /** px. The side panel never gets narrower than this. Default 280. */\n minB?: number;\n /** Remembers the side panel's width in localStorage under this name. Without it the width lasts until the page reloads. */\n storageKey?: string;\n /** Names the divider for screen readers. Default 「調整面板寬度」. */\n label?: string;\n /** After every change, with the side panel's new width in px. */\n onResize?: (b: number) => void;\n /** Extra class on the root element. */\n className?: string;\n}\n\n/** Width of the divider between the two areas, in px; a 48 px hit area is drawn over it. */\nconst HANDLE = 16;\n/** Narrower than this (px, the component's own width), the two areas stack and the divider goes away. */\nconst STACK = 960;\n/** One arrow key press, in px. */\nconst STEP = 16;\n\nconst read = (key: string | undefined): number | null => {\n if (!key) return null;\n try {\n const v = Number(window.localStorage.getItem('ui-split:' + key));\n return Number.isFinite(v) && v > 0 ? v : null;\n } catch {\n return null;\n }\n};\nconst write = (key: string | undefined, v: number) => {\n if (!key) return;\n try {\n window.localStorage.setItem('ui-split:' + key, String(Math.round(v)));\n } catch {\n // Storage blocked or full: the width still changes, it is just not remembered.\n }\n};\n\n/** A main area and a side panel with a divider between them that can be dragged, moved with the arrow keys, stepped\n * through preset widths with a click (narrowest, default, 1.5 times the default) and reset with a double-click or Enter. Under 960 px (its own width) the two stack, side panel below, without the divider. */\nexport function SplitPane({ a, b, defaultB = 420, minA = 360, minB = 280, storageKey, label, onResize, className }: SplitPaneProps) {\n devWarn(defaultB < minB, 'SplitPane', `defaultB (${defaultB} px) is under minB (${minB} px): the panel starts at ${minB} px. Raise defaultB or lower minB.`);\n const root = React.useRef<HTMLDivElement>(null);\n const [width, setWidth] = React.useState(0);\n // The stored width, read on the first render in the browser. The grid columns are set only once the component has\n // measured itself, so the server's render and the first one in the browser match.\n const [side, setSide] = React.useState(() => (typeof window === 'undefined' ? null : read(storageKey)) ?? defaultB);\n const [drag, setDrag] = React.useState(false);\n // Read by the move and up handlers: a move can come before the render that follows the press. `moved` turns a press\n // into a drag once the pointer has gone DRAG_MIN px; released before that it was a click.\n const dragging = React.useRef<{ x: number; moved: boolean } | null>(null);\n const id = React.useId();\n React.useLayoutEffect(() => {\n const el = root.current;\n if (!el) return;\n const measure = () => setWidth(el.clientWidth);\n measure();\n const ro = resizeObserver(measure);\n ro?.observe(el);\n return () => ro?.disconnect();\n }, []);\n const stacked = width > 0 && width < STACK;\n // The side panel's width as it can be now: both areas keep their minimum.\n const maxB = Math.max(minB, width - HANDLE - minA);\n const shown = Math.round(Math.min(maxB, Math.max(minB, side)));\n const valueA = Math.max(0, width - HANDLE - shown);\n // The width after the last move, for the release that stores it (the render with it may not have happened yet).\n const latest = React.useRef(shown);\n const set = (v: number, keep = true) => {\n const next = Math.round(Math.min(maxB, Math.max(minB, v)));\n latest.current = next;\n setSide(next);\n if (keep) write(storageKey, next);\n onResize?.(next);\n };\n const onKey = (e: React.KeyboardEvent) => {\n if (browserKey(e)) return;\n // The value is the main area's width: ← makes it narrower (the panel wider), Home makes it as narrow as it goes.\n const to =\n e.key === 'ArrowLeft'\n ? shown + STEP\n : e.key === 'ArrowRight'\n ? shown - STEP\n : e.key === 'Home'\n ? maxB\n : e.key === 'End'\n ? minB\n : e.key === 'Enter'\n ? defaultB\n : null;\n if (to == null) return;\n e.preventDefault();\n set(to);\n };\n const onDown = (e: React.PointerEvent<HTMLDivElement>) => {\n if (e.button !== 0) return;\n e.preventDefault();\n // Keeps getting the moves when the pointer leaves the divider (a fast drag).\n try {\n e.currentTarget.setPointerCapture?.(e.pointerId);\n } catch {\n // No such pointer (a synthetic event): moves still come while over the divider.\n }\n e.currentTarget.focus({ preventScroll: true });\n dragging.current = { x: e.clientX, moved: false };\n setDrag(true);\n };\n const onMove = (e: React.PointerEvent<HTMLDivElement>) => {\n const d = dragging.current;\n if (!d || !root.current) return;\n if (!d.moved && Math.abs(e.clientX - d.x) < DRAG_MIN) return;\n d.moved = true;\n const r = root.current.getBoundingClientRect();\n set((r.right - e.clientX) / cssZoom(root.current) - HANDLE / 2, false);\n };\n // A click without dragging (WCAG 2.5.7): the next preset width of the panel, announced.\n const presets = [minB, defaultB, defaultB * 1.5];\n const onUp = (e: React.PointerEvent<HTMLDivElement>, cancel = false) => {\n const d = dragging.current;\n if (!d) return;\n dragging.current = null;\n setDrag(false);\n if (!d.moved && !cancel) {\n const next = Math.round(Math.min(maxB, Math.max(minB, nextPreset(shown, presets))));\n set(next);\n announce(tr('面板 {n} px', { n: next }));\n }\n try {\n if (e.currentTarget.hasPointerCapture?.(e.pointerId)) e.currentTarget.releasePointerCapture(e.pointerId);\n } catch {\n // Already released.\n }\n if (root.current) write(storageKey, latest.current);\n };\n return (\n <div\n ref={root}\n className={cx('ui-split', stacked && 'is-stacked', drag && 'is-dragging', className)}\n style={stacked || !width ? undefined : { gridTemplateColumns: `minmax(0, 1fr) ${HANDLE}px ${shown}px` }}\n >\n <div className=\"ui-split-a\">{a}</div>\n {stacked ? null : (\n <div\n role=\"separator\"\n tabIndex={0}\n aria-orientation=\"vertical\"\n aria-label={label || tr('調整面板寬度')}\n aria-controls={id}\n aria-valuenow={valueA}\n aria-valuemin={minA}\n aria-valuemax={Math.max(minA, width - HANDLE - minB)}\n aria-valuetext={tr('主要區域 {a} px,面板 {b} px', { a: valueA, b: shown })}\n aria-description={tr('拖曳或按 ← → 調整;按一下切換預設寬度,按兩下或 Enter 還原')}\n className=\"ui-split-handle\"\n onKeyDown={onKey}\n onPointerDown={onDown}\n onPointerMove={onMove}\n onPointerUp={onUp}\n onPointerCancel={(e) => onUp(e, true)}\n onDoubleClick={() => set(defaultB)}\n >\n {/* GB: a small handle in the middle of the line, so the divider reads as something to drag. */}\n <span className=\"ui-split-grip\" aria-hidden=\"true\">\n <i />\n <i />\n <i />\n </span>\n </div>\n )}\n <div id={id} className=\"ui-split-b\">\n {b}\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;AA6BA,MAAM,SAAS;;AAEf,MAAM,QAAQ;;AAEd,MAAM,OAAO;AAEb,MAAM,QAAQ,QAA2C;CACvD,IAAI,CAAC,KAAK,OAAO;CACjB,IAAI;EACF,MAAM,IAAI,OAAO,OAAO,aAAa,QAAQ,cAAc,GAAG,CAAC;EAC/D,OAAO,OAAO,SAAS,CAAC,KAAK,IAAI,IAAI,IAAI;CAC3C,QAAQ;EACN,OAAO;CACT;AACF;AACA,MAAM,SAAS,KAAyB,MAAc;CACpD,IAAI,CAAC,KAAK;CACV,IAAI;EACF,OAAO,aAAa,QAAQ,cAAc,KAAK,OAAO,KAAK,MAAM,CAAC,CAAC,CAAC;CACtE,QAAQ,CAER;AACF;;;AAIA,SAAgB,UAAU,EAAE,GAAG,GAAG,WAAW,KAAK,OAAO,KAAK,OAAO,KAAK,YAAY,OAAO,UAAU,aAA6B;CAClI,QAAQ,WAAW,MAAM,aAAa,aAAa,SAAS,sBAAsB,KAAK,4BAA4B,KAAK,mCAAmC;CAC3J,MAAM,OAAO,MAAM,OAAuB,IAAI;CAC9C,MAAM,CAAC,OAAO,YAAY,MAAM,SAAS,CAAC;CAG1C,MAAM,CAAC,MAAM,WAAW,MAAM,gBAAgB,OAAO,WAAW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GAKE,oBAAC,OAAD;IAAK,WAAU;IAAc,UAAA;GAAO,CAAA;GACnC,UAAU,OACT,oBAAC,OAAD;IACE,MAAK;IACL,UAAU;IACV,oBAAiB;IACjB,cAAY,SAAS,GAAG,QAAQ;IAChC,iBAAe;IACf,iBAAe;IACf,iBAAe;IACf,iBAAe,KAAK,IAAI,MAAM,QAAQ,SAAS,IAAI;IACnD,kBAAgB,GAAG,yBAAyB;KAAE,GAAG;KAAQ,GAAG;IAAM,CAAC;IACnE,oBAAkB,GAAG,qCAAqC;IAC1D,WAAU;IACV,WAAW;IACX,eAAe;IACf,eAAe;IACf,aAAa;IACb,kBAAkB,MAAM,KAAK,GAAG,IAAI;IACpC,qBAAqB,IAAI,QAAQ;IAGjC,UAAA,qBAAC,QAAD;KAAM,WAAU;KAAgB,eAAY;KAA5C,UAAA;MACE,oBAAC,KAAD,CAAI,CAAA;MACJ,oBAAC,KAAD,CAAI,CAAA;MACJ,oBAAC,KAAD,CAAI,CAAA;KACA;;GACH,CAAA;GAEP,oBAAC,OAAD;IAAS;IAAI,WAAU;IACpB,UAAA;GACE,CAAA;EACF;;AAET"}
|
|
@@ -29,6 +29,9 @@
|
|
|
29
29
|
.ui-console-top {
|
|
30
30
|
grid-column: 1 / -1;
|
|
31
31
|
display: flex;
|
|
32
|
+
/* Never wider than the layout: what does not fit goes to a second line (the main view gives up the height). */
|
|
33
|
+
flex-wrap: wrap;
|
|
34
|
+
row-gap: var(--space-2);
|
|
32
35
|
align-items: center;
|
|
33
36
|
justify-content: space-between;
|
|
34
37
|
gap: var(--space-4);
|
|
@@ -47,6 +50,11 @@
|
|
|
47
50
|
gap: var(--space-3);
|
|
48
51
|
min-width: 0;
|
|
49
52
|
}
|
|
53
|
+
.ui-console-end {
|
|
54
|
+
flex-wrap: wrap;
|
|
55
|
+
justify-content: flex-end;
|
|
56
|
+
margin-left: auto;
|
|
57
|
+
}
|
|
50
58
|
.ui-console-title {
|
|
51
59
|
margin: 0;
|
|
52
60
|
font-size: inherit;
|
|
@@ -60,7 +68,9 @@
|
|
|
60
68
|
}
|
|
61
69
|
.ui-console-kpis {
|
|
62
70
|
display: flex;
|
|
71
|
+
flex-wrap: wrap;
|
|
63
72
|
align-items: stretch;
|
|
73
|
+
max-width: 100%;
|
|
64
74
|
}
|
|
65
75
|
.ui-console-content {
|
|
66
76
|
display: contents;
|
|
@@ -74,6 +84,9 @@
|
|
|
74
84
|
flex-direction: column;
|
|
75
85
|
}
|
|
76
86
|
.ui-console-main > * {
|
|
87
|
+
/* Scroll containers are positioned, so visually hidden text inside them is clipped with them instead of making the
|
|
88
|
+
page scroll. */
|
|
89
|
+
position: relative;
|
|
77
90
|
flex: 1 1 auto;
|
|
78
91
|
min-height: 0;
|
|
79
92
|
overflow: auto;
|
|
@@ -82,6 +95,7 @@
|
|
|
82
95
|
flex-direction: column;
|
|
83
96
|
}
|
|
84
97
|
.ui-console-side {
|
|
98
|
+
position: relative;
|
|
85
99
|
grid-column: 2;
|
|
86
100
|
grid-row: 2 / 4;
|
|
87
101
|
min-height: 0;
|
|
@@ -94,9 +108,22 @@
|
|
|
94
108
|
padding: 12px;
|
|
95
109
|
}
|
|
96
110
|
.ui-console-side > * {
|
|
111
|
+
/* Side cards keep their own height; the panel scrolls when they do not fit. */
|
|
97
112
|
flex: none;
|
|
98
113
|
}
|
|
114
|
+
/* An extra card that does not fit: laid out at the panel's width, out of sight and at no height, so it is measured
|
|
115
|
+
again when the panel grows. */
|
|
116
|
+
.ui-console-extra.is-out {
|
|
117
|
+
position: absolute;
|
|
118
|
+
top: 0;
|
|
119
|
+
left: 12px;
|
|
120
|
+
right: 12px;
|
|
121
|
+
height: 0;
|
|
122
|
+
overflow: hidden;
|
|
123
|
+
visibility: hidden;
|
|
124
|
+
}
|
|
99
125
|
.ui-console-bottom {
|
|
126
|
+
position: relative;
|
|
100
127
|
grid-column: 1;
|
|
101
128
|
grid-row: 3;
|
|
102
129
|
min-width: 0;
|
|
@@ -104,7 +131,9 @@
|
|
|
104
131
|
display: flex;
|
|
105
132
|
flex-direction: column;
|
|
106
133
|
}
|
|
107
|
-
/*
|
|
134
|
+
/* Stacked (narrower than stackedBelow, 1100 px by default): one scrolling column. The top bar keeps the title, status,
|
|
135
|
+
clock and full screen on its first line and puts every KPI on the next ones; the main view; the side cards side by
|
|
136
|
+
side where there is room; the bottom row; the extra cards the same way as the side cards. */
|
|
108
137
|
.ui-console.is-stacked {
|
|
109
138
|
height: auto;
|
|
110
139
|
min-height: 100dvh;
|
|
@@ -116,19 +145,28 @@
|
|
|
116
145
|
height: auto;
|
|
117
146
|
}
|
|
118
147
|
.ui-console.is-stacked .ui-console-top {
|
|
119
|
-
flex-wrap: wrap;
|
|
120
148
|
padding: var(--space-3) var(--space-4);
|
|
121
149
|
}
|
|
150
|
+
.ui-console.is-stacked .ui-console-start {
|
|
151
|
+
margin-right: auto;
|
|
152
|
+
}
|
|
122
153
|
.ui-console.is-stacked .ui-console-end {
|
|
123
|
-
|
|
124
|
-
row-gap: var(--space-2);
|
|
154
|
+
display: contents;
|
|
125
155
|
}
|
|
126
156
|
.ui-console.is-stacked .ui-console-kpis {
|
|
127
157
|
order: 1;
|
|
158
|
+
display: grid;
|
|
159
|
+
grid-template-columns: repeat(auto-fill, minmax(min(190px, 100%), 1fr));
|
|
160
|
+
gap: var(--space-2) var(--space-4);
|
|
128
161
|
width: 100%;
|
|
129
|
-
overflow-x: auto;
|
|
130
162
|
}
|
|
131
163
|
.ui-console.is-stacked .ui-console-main {
|
|
132
164
|
min-height: 320px;
|
|
133
165
|
}
|
|
166
|
+
.ui-console-cards {
|
|
167
|
+
display: grid;
|
|
168
|
+
grid-template-columns: repeat(auto-fill, minmax(min(340px, 100%), 1fr));
|
|
169
|
+
align-items: start;
|
|
170
|
+
gap: 12px;
|
|
171
|
+
}
|
|
134
172
|
}
|
package/dist/css/FloorPlan.css
CHANGED
|
@@ -6,6 +6,9 @@
|
|
|
6
6
|
attention border, the forecast stripes, the selection outline (ink, 2 px, 4 px outside) and the label type follow
|
|
7
7
|
ZoneMap. */
|
|
8
8
|
.ui-floorplan {
|
|
9
|
+
/* The containing block of the visually hidden hint: without it the hint escapes a scrolling card and makes the page
|
|
10
|
+
scroll. */
|
|
11
|
+
position: relative;
|
|
9
12
|
display: flex;
|
|
10
13
|
flex-direction: column;
|
|
11
14
|
gap: var(--space-3);
|
package/dist/css/KpiCard.css
CHANGED
|
@@ -114,6 +114,7 @@
|
|
|
114
114
|
as its content. */
|
|
115
115
|
.ui-console-kpis > .ui-kpi {
|
|
116
116
|
flex: 1 1 0;
|
|
117
|
+
/* At least as wide as its content; the row wraps (the top bar's next line) when they do not all fit. */
|
|
117
118
|
min-width: max-content;
|
|
118
119
|
padding: 6px var(--space-4);
|
|
119
120
|
border-radius: 0;
|
|
@@ -124,11 +125,11 @@
|
|
|
124
125
|
.ui-console-kpis > .ui-kpi:last-child {
|
|
125
126
|
border-right: 1px solid var(--line);
|
|
126
127
|
}
|
|
127
|
-
|
|
128
|
+
/* Stacked, the KPIs are a grid under the title line: no lines between them, each starting at its column's edge. */
|
|
129
|
+
.ui-console.is-stacked .ui-console-kpis > .ui-kpi {
|
|
130
|
+
min-width: 0;
|
|
131
|
+
padding: 0;
|
|
128
132
|
border-left: 0;
|
|
129
|
-
padding-left: 0;
|
|
130
|
-
}
|
|
131
|
-
.ui-console.is-stacked .ui-console-kpis > .ui-kpi:last-child {
|
|
132
133
|
border-right: 0;
|
|
133
134
|
}
|
|
134
135
|
}
|
package/dist/internal/chart.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { format } from "../format.js";
|
|
3
|
-
import { reduced, useMedia } from "./util.js";
|
|
3
|
+
import { cssZoom, reduced, useMedia } from "./util.js";
|
|
4
4
|
import * as React from "react";
|
|
5
5
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
6
|
// src/internal/chart.tsx
|
|
@@ -150,7 +150,7 @@ function useAxisWidth(ref, labels, scaleKey = "") {
|
|
|
150
150
|
const read = () => {
|
|
151
151
|
let m = 0;
|
|
152
152
|
for (const el of root.querySelectorAll(".ui-chart-tick")) m = Math.max(m, el.getBoundingClientRect().width);
|
|
153
|
-
setW(m > 0 ? Math.ceil(m) : guess);
|
|
153
|
+
setW(m > 0 ? Math.ceil(m / cssZoom(root)) : guess);
|
|
154
154
|
};
|
|
155
155
|
read();
|
|
156
156
|
if (!root.querySelector(".ui-chart-tick") || typeof ResizeObserver !== "function") return;
|