@seanyeh77/ui 0.18.0 → 0.20.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.
@@ -90,6 +90,8 @@ const I18N = {
90
90
  到: "to",
91
91
  "{label}({inferred})": "{label} ({inferred})",
92
92
  調整面板寬度: "Resize the panel",
93
+ 調整架構圖高度: "Resize the diagram height",
94
+ "{n} px": "{n} px",
93
95
  "主要區域 {a} px,面板 {b} px": "Main area {a} px, panel {b} px",
94
96
  "repo 外": "outside the repo",
95
97
  詳細: "Details",
@@ -490,4 +492,4 @@ const sameDay = (a, b) => !!a && !!b && a.getFullYear() === b.getFullYear() && a
490
492
  const dayAdd = (d, n) => new Date(d.getFullYear(), d.getMonth(), d.getDate() + n);
491
493
  export { parseDate as a, addMessages as c, unitFor as d, format as i, setLocale as l, fileSize as n, sameDay as o, fmtDate as r, I18N as s, dayAdd as t, tr as u };
492
494
 
493
- //# sourceMappingURL=format-entry-madGv9m_.js.map
495
+ //# sourceMappingURL=format-entry-CfCwMZuE.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format-entry-CfCwMZuE.js","names":[],"sources":["../src/i18n.ts","../src/format.ts"],"sourcesContent":["/* ---------- i18n and formats ----------\n Every built-in string is the zh-TW text passed through tr(); other languages come from UI.addMessages().\n Dates and numbers go through UI.format, which uses Intl for the current locale. The zh-TW rules are the\n ones the design system chose; other locales use their own conventions from Intl. */\ninterface I18nState {\n locale: string;\n currency: string;\n messages: Record<string, Record<string, string>>;\n}\n\nexport const I18N: I18nState = {\n locale: 'zh-TW',\n currency: 'TWD',\n messages: {\n en: {\n 'Email 或帳號': 'Email or username',\n '{label}:{a} 到 {b}': '{label}: {a} to {b}',\n '{n} 個百分點': '{n} pts',\n 上一頁: 'Previous page',\n 上個月: 'Previous month',\n '上傳失敗,請再試一次。': 'Upload failed. Try again.',\n 下一頁: 'Next page',\n 下個月: 'Next month',\n 主要導覽: 'Main navigation',\n 主題: 'Theme',\n 今天: 'Today',\n 全選: 'Select all',\n 全部: 'All',\n 全部標為已讀: 'Mark all as read',\n '共 {n} 筆': '{n} items',\n 分頁: 'Pagination',\n 刪除: 'Delete',\n 危險操作: 'Danger zone',\n 取消選取: 'Clear selection',\n '可以直接輸入,例如 2026/11/14': 'Type a date, e.g. 2026/11/14',\n 回上一頁: 'Go back',\n 回首頁: 'Go home',\n '完成 ✓': 'Done ✓',\n 密碼: 'Password',\n 展開側邊欄: 'Expand sidebar',\n '已選 {n} 筆': '{n} selected',\n 帳號: 'Username',\n 強調色: 'Accent color',\n '忘記密碼?': 'Forgot password?',\n 找不到符合的選項: 'No matching options',\n '拖放檔案,或 ': 'Drop files here, or ',\n 搜尋: 'Search',\n 操作: 'Actions',\n 收合側邊欄: 'Collapse sidebar',\n 放棄: 'Discard',\n '放棄未儲存的變更?': 'Discard unsaved changes?',\n '{label}?': '{label}?',\n '{name} 上傳進度': 'Upload progress of {name}',\n 左右方向鍵查看每一項的數值: 'Use ← and → to read each value',\n 左右方向鍵查看每一個時間點的數值: 'Use ← and → to read each point',\n '新增「{q}」': 'Add “{q}”',\n '日期格式不正確,請寫成 2026/11/14': 'Invalid date. Use 2026/11/14.',\n 更多操作: 'More actions',\n 更多: 'More',\n 左右滑動: 'Scroll sideways',\n 跳到主要內容: 'Skip to main content',\n 說明: 'Explain',\n 開啟導覽: 'Open navigation',\n 顯示方式: 'View',\n 顯示線上文字: 'Show line labels',\n 線上文字: 'Line labels',\n 圖: 'Diagram',\n 清單: 'List',\n 項目: 'Items',\n 關係: 'Relations',\n 已展開: 'Expanded',\n 已收合: 'Collapsed',\n '已展開,{n} 個子項目': 'Expanded, {n} items',\n '顯示 {n} 筆': 'Showing {n} rows',\n '找到 {n} 筆結果': '{n} results',\n '第 {a} 步,共 {b} 步': 'Step {a} of {b}',\n '說明 {name}': 'Explain {name}',\n 程式碼: 'Code',\n '第 {n} 行': 'Line {n}',\n '第 {n} 層': 'Level {n}',\n 第一行: 'First line',\n 最後一行: 'Last line',\n '上 20 行': '20 lines up',\n '下 20 行': '20 lines down',\n 上一段: 'Previous section',\n 下一段: 'Next section',\n '{name},第 {n} 行': '{name}, line {n}',\n '顯示 {n} 筆,另有 {m} 筆,請輸入更長的字': 'Showing {n}, {m} more: type more to narrow it down',\n '縮排 {n} 格': 'indented {n} spaces',\n '縮排 {n} 個 tab': 'indented {n} tabs',\n '縮排 {a} 個 tab、{b} 格': 'indented {a} tabs and {b} spaces',\n 向右捲動: 'Scroll right',\n 筆: 'rows',\n '1 筆': '1 row',\n // Separators: full-width in Chinese, ASCII and a space in English.\n ',': ', ',\n ':': ': ',\n '。': '. ',\n '來自 {from},{label}': 'From {from}, {label}',\n '{from} 到 {to},{what}': '{from} to {to}, {what}',\n 到: 'to',\n '{label}({inferred})': '{label} ({inferred})',\n 調整面板寬度: 'Resize the panel',\n 調整架構圖高度: 'Resize the diagram height',\n '{n} px': '{n} px',\n '主要區域 {a} px,面板 {b} px': 'Main area {a} px, panel {b} px',\n 'repo 外': 'outside the repo',\n 詳細: 'Details',\n '展開 {name}': 'Expand {name}',\n '收合 {name}': 'Collapse {name}',\n 字: 'characters',\n 'C 語言': 'C',\n 程式語言: 'Language',\n 全部頁面: 'All pages',\n '最近 30 天': 'Last 30 days',\n '最近 7 天': 'Last 7 days',\n 期間: 'Period',\n 未讀: 'Unread',\n 本月: 'This month',\n 沒有符合的資料: 'No matching data',\n 沒有通知: 'No notifications',\n 清除: 'Clear',\n 清除搜尋: 'Clear search',\n 登入: 'Sign in',\n 發生錯誤: 'Something went wrong',\n '移除 {name}': 'Remove {name}',\n '第 {a}–{b} 筆,共 {n} 筆': '{a}–{b} of {n}',\n 繼續編輯: 'Keep editing',\n '自訂強調色(色碼)': 'Custom accent color (hex)',\n '色碼格式不正確,例如 #2457d6': 'Invalid hex, e.g. #2457d6',\n 設定分類: 'Settings sections',\n 請輸入密碼: 'Enter your password',\n 請輸入帳號: 'Enter your username',\n 請選擇: 'Select',\n 路徑: 'Breadcrumb',\n 較上週: 'vs last week',\n 載入中: 'Loading',\n '輸入 # 加 6 碼': 'Enter # and 6 digits',\n 通知: 'Notifications',\n '通知,{n} 則未讀': 'Notifications, {n} unread',\n '選取第 {n} 筆': 'Select row {n}',\n 選擇日期: 'Choose date',\n 選擇期間: 'Choose period',\n 選擇檔案: 'choose files',\n 重試: 'Retry',\n 開啟日曆: 'Open calendar',\n 關閉: 'Close',\n '關閉後,剛才的修改不會保留。': 'If you close now, your changes will be lost.',\n 關閉提示: 'Dismiss',\n 隱藏密碼: 'Hide password',\n 顯示密碼: 'Show password',\n '(今天)': ' (today)',\n 伺服器暫時無法回應: 'The server is not responding',\n 找不到這個頁面: 'Page not found',\n 沒有權限查看這個頁面: 'You do not have access to this page',\n '網址可能打錯了,或這個頁面已經移除。': 'The address may be wrong, or the page has been removed.',\n '這個問題已經記錄下來,請稍後重新整理再試。': 'The problem has been logged. Refresh the page later.',\n '請向管理員申請權限,或切換成有權限的帳號。': 'Ask an admin for access, or switch to an account that has it.',\n 自動: 'Auto',\n 淺色: 'Light',\n 深色: 'Dark',\n 藍: 'Blue',\n 靛: 'Indigo',\n 紫: 'Purple',\n 桃紅: 'Pink',\n 紅: 'Red',\n 橘: 'Orange',\n 綠: 'Green',\n 青: 'Teal',\n 草稿: 'Draft',\n 進行中: 'In progress',\n 審核中: 'In review',\n 完成: 'Done',\n 失敗: 'Failed',\n 檢視: 'Views',\n '{n} / {total} 筆': '{n} / {total}',\n '{n} / {total} {unit}': '{n} / {total} {unit}',\n '{n} / {total}': '{n} / {total}',\n '{total} {unit}中的 {n} {unit}': '{n} of {total} {unit}',\n '{total} 中的 {n}': '{n} of {total}',\n 欄位: 'Columns',\n 顯示的欄位: 'Visible columns',\n 清除篩選: 'Clear filters',\n 清除全部: 'Clear all',\n 篩選: 'Filter',\n 最低: 'Min',\n 最高: 'Max',\n '合計 {n} 筆': 'Total: {n}',\n 平均: 'Avg',\n '選取 {name}': 'Select {name}',\n '{n} 個新': '{n} new',\n '{n} 個檔案': '{n} files',\n '下載 {name}': 'Download {name}',\n '已選 {n} 個檔案': '{n} files selected',\n '共 {size}': '{size} total',\n 清除選取: 'Clear selection',\n 下載: 'Download',\n 全部展開: 'Expand all',\n 全部收合: 'Collapse all',\n 這裡還沒有檔案: 'No files here yet',\n 顯示全部: 'Show all',\n 收合: 'Show less',\n 依狀態篩選: 'Filter by status',\n 展開: 'Expand',\n 沒有項目: 'Nothing here',\n 即時: 'Live',\n 已過期: 'Stale',\n 離線: 'Offline',\n 切換專案: 'Switch project',\n '切換專案,目前是 {name}': 'Switch project, now {name}',\n 推測: 'Inferred',\n '{n} 個項目': '{n} items',\n '1 個項目': '1 item',\n '{a} 個項目使用,共 {b} 次': 'Used {b} times by {a} items',\n 共用項目: 'Shared',\n 次數越多線越粗: 'Thicker lines mean more often',\n 架構圖: 'Architecture',\n '{n} 次': '{n} calls',\n '1 次': '1 call',\n 原始碼: 'Source',\n '顯示全部 {n} 行': 'Show all {n} lines',\n '只顯示第 {n} 行前後': 'Show only around line {n}',\n '無法載入 {name} 的子項目': 'Could not load the children of {name}',\n '找不到符合「{q}」的結果': 'No results for “{q}”',\n 輸入名稱開始搜尋: 'Type a name to search',\n 搜尋中: 'Searching',\n 搜尋結果: 'Search results',\n 最近開啟: 'Recently opened',\n 選擇: 'Select',\n 打開: 'Open',\n 取消: 'Cancel',\n 略過: 'Skip',\n 上一步: 'Back',\n 下一步: 'Next',\n 建議修正: 'Suggested fix',\n 複製修正: 'Copy fix',\n 已複製: 'Copied',\n 複製程式碼: 'Copy code',\n '原本:': 'Before: ',\n '改成:': 'After: ',\n 關閉說明: 'Close explanation',\n '(說明)': ' (explain)',\n '搜尋({k})': 'Search ({k})',\n 確定的關係: 'Confirmed',\n 推測的關係: 'Inferred',\n 專案宣告的關係: 'Declared by the project',\n 宣告: 'Declared',\n 外部項目: 'External',\n },\n },\n};\n\nfunction msgsFor(loc: string): Record<string, string> | null {\n return I18N.messages[loc] || I18N.messages[loc.split('-')[0]] || null;\n}\n\n/** Translates a built-in zh-TW string into the current locale; {name} placeholders take vars. */\nexport function tr(key: string, vars?: Record<string, string | number>): string {\n // zh-TW (and zh-Hant) is the source text; other Chinese locales (zh-CN) use the messages an app adds for them.\n const m = isZhTW() ? null : msgsFor(I18N.locale);\n const out = m?.[key] ?? key;\n return vars ? out.replace(/\\{(\\w+)\\}/g, (a, k: string) => (vars[k] !== undefined ? String(vars[k]) : a)) : out;\n}\n\n/** A count's unit: a function gets the count (for plurals, 「1 row」「2 rows」); a string goes through tr(), and for 1\n * the message 「1 <unit>」 is used when the locale has one (「1 筆」 → 「1 row」), without the number. */\nexport type CountUnit = string | ((n: number) => string);\nexport function unitFor(unit: CountUnit | undefined, n: number): string {\n if (!unit) return '';\n if (typeof unit === 'function') return unit(n);\n if (n === 1) {\n const one = tr('1 ' + unit);\n if (one !== '1 ' + unit) return one.replace(/^1\\s*/, '');\n }\n return tr(unit);\n}\n\n/** Switches the interface language and, optionally, the currency used by format.money. */\nexport function setLocale(locale: string, opts?: { currency?: string }): void {\n I18N.locale = locale || 'zh-TW';\n if (opts?.currency) I18N.currency = opts.currency;\n if (typeof document !== 'undefined') document.documentElement.setAttribute('lang', I18N.locale);\n}\n\n/** Adds or overrides translations for a locale. Keys are the zh-TW strings. */\nexport function addMessages(locale: string, dict: Record<string, string>): void {\n I18N.messages[locale] = { ...I18N.messages[locale], ...dict };\n}\n\nexport const isZhTW = (): boolean => /^zh-(TW|Hant)/i.test(I18N.locale);\n","import { I18N, isZhTW, tr } from './i18n';\n\n/* Dates and numbers for the current locale (setLocale). zh-TW follows the design system's rules\n (2026/11/04(三), 24-hour clock, NT$ 1,280, 萬 and 億 in KPI cards); other locales use Intl's conventions. */\n\nexport type Decimals = number | 'money' | 'percent' | 'size' | 'count';\n\nconst DECIMALS = { money: 0, percent: 1, size: 1, count: 0 } as const;\n\nconst pad2 = (n: number): string => String(n).padStart(2, '0');\n\nfunction locale(): string {\n return I18N.locale;\n}\n\n/** zh-TW: 2026/11/04(三). Other locales: their short date with weekday. */\nfunction date(d: Date | null | undefined, o: { weekday?: boolean; long?: boolean } = {}): string {\n if (!d) return '';\n const wd = o.weekday !== false;\n if (o.long) return new Intl.DateTimeFormat(I18N.locale, { year: 'numeric', month: 'long', day: 'numeric', weekday: wd ? 'long' : undefined }).format(d);\n if (isZhTW()) return fmtDate(d) + (wd ? `(${new Intl.DateTimeFormat('zh-TW', { weekday: 'narrow' }).format(d)})` : '');\n return new Intl.DateTimeFormat(I18N.locale, { year: 'numeric', month: '2-digit', day: '2-digit', weekday: wd ? 'short' : undefined }).format(d);\n}\n\n/** zh-TW: 24-hour 15:57. Other locales: their own clock. */\nfunction time(d: Date | null | undefined): string {\n if (!d) return '';\n return new Intl.DateTimeFormat(\n I18N.locale,\n isZhTW() ? { hour: '2-digit', minute: '2-digit', hourCycle: 'h23' } : { hour: 'numeric', minute: '2-digit' },\n ).format(d);\n}\n\nfunction dateTime(d: Date | null | undefined, o?: { weekday?: boolean }): string {\n return d ? `${date(d, o)} ${time(d)}` : '';\n}\n\n/** Within 7 days: 「2 小時前」、「昨天」. Older: full date and time. Pass now to test. */\nfunction relative(d: Date | null | undefined, now: Date = new Date()): string {\n if (!d) return '';\n const s = (now.getTime() - d.getTime()) / 1000;\n if (s < 0 || s >= 604800) return dateTime(d);\n const rt = new Intl.RelativeTimeFormat(I18N.locale, { numeric: 'auto' });\n if (s < 60) return rt.format(0, 'second');\n if (s < 3600) return rt.format(-Math.floor(s / 60), 'minute');\n if (s < 86400) return rt.format(-Math.floor(s / 3600), 'hour');\n return rt.format(-Math.floor(s / 86400), 'day');\n}\n\nfunction month(d: Date): string {\n return new Intl.DateTimeFormat(I18N.locale, { year: 'numeric', month: 'long' }).format(d);\n}\n\n/** Week starts on Sunday for zh-TW; other locales use Intl's week info when the browser has it. */\nfunction firstDay(): number {\n if (isZhTW()) return 0;\n try {\n const l = new Intl.Locale(I18N.locale) as Intl.Locale & { getWeekInfo?: () => { firstDay: number }; weekInfo?: { firstDay: number } };\n const w = l.getWeekInfo ? l.getWeekInfo() : l.weekInfo;\n if (w?.firstDay) return w.firstDay % 7;\n } catch {\n /* older browsers have no week info */\n }\n return 0;\n}\n\n/** Narrow weekday names, starting from firstDay(). */\nfunction weekdays(): string[] {\n const fd = firstDay();\n const f = new Intl.DateTimeFormat(I18N.locale, { weekday: 'narrow' });\n // 2026/11/01 is a Sunday.\n return Array.from({ length: 7 }, (_, i) => f.format(new Date(2026, 10, 1 + ((fd + i) % 7))));\n}\n\n/** Decimals by unit: money 0, percent 1, size 1, count 0; pass a number to force it. */\nfunction number(v: number, dec?: Decimals): string {\n const dd = typeof dec === 'number' ? dec : dec ? DECIMALS[dec] : 0;\n return new Intl.NumberFormat(I18N.locale, { minimumFractionDigits: dd, maximumFractionDigits: dd }).format(v);\n}\n\nfunction percent(v: number, dec = 1): string {\n return new Intl.NumberFormat(I18N.locale, { style: 'percent', minimumFractionDigits: dec, maximumFractionDigits: dec }).format(v / 100);\n}\n\n/** Only KPI cards abbreviate: 1,284 萬 in zh-TW (萬、億), 12.8M in English.\n * like: format v with the unit and decimals that `like` gets, so a counting KPI keeps its width. */\nfunction compact(v: number, like?: number): string {\n const ref = like ?? v;\n if (Math.abs(ref) < 1e4) return number(v);\n if (/^zh/i.test(I18N.locale)) {\n const a = Math.abs(ref);\n const [unit, div, maxDec] = a >= 1e8 ? (['億', 1e8, 2] as const) : (['萬', 1e4, 1] as const);\n const finalStr = new Intl.NumberFormat(I18N.locale, { maximumFractionDigits: maxDec }).format(a / div);\n const sign = v < 0 ? '-' : '';\n if (like === undefined) return `${sign}${finalStr} ${unit}`;\n const digits = (finalStr.split('.')[1] || '').length;\n return `${sign}${new Intl.NumberFormat(I18N.locale, { minimumFractionDigits: digits, maximumFractionDigits: digits }).format(Math.abs(v) / div)} ${unit}`;\n }\n const nf = new Intl.NumberFormat(I18N.locale, { notation: 'compact', maximumFractionDigits: 1 });\n if (like === undefined) return nf.format(v);\n const parts = nf.formatToParts(ref);\n let num = '';\n let dec = '';\n for (const pt of parts) {\n if (pt.type === 'integer') num += pt.value;\n if (pt.type === 'fraction') {\n num += '.' + pt.value;\n dec = pt.value;\n }\n }\n const mant = parseFloat(num) || 1;\n const scale = 10 ** Math.round(Math.log10(Math.abs(ref) / mant));\n const inner = new Intl.NumberFormat(I18N.locale, { minimumFractionDigits: dec.length, maximumFractionDigits: dec.length }).format(Math.abs(v) / scale);\n let done = false;\n const body = parts\n .map((pt) => {\n if (pt.type === 'integer' || pt.type === 'group' || pt.type === 'decimal' || pt.type === 'fraction') {\n if (done) return '';\n done = true;\n return inner;\n }\n return pt.value;\n })\n .join('');\n return (v < 0 && ref >= 0 ? '-' : '') + body;\n}\n\n/** zh-TW with TWD: NT$ 1,280, negatives -NT$ 1,280. Other locales and currencies: Intl's own symbol and order. */\nfunction money(v: number, o: { currency?: string; compact?: boolean; like?: number } = {}): string {\n const cur = o.currency || I18N.currency;\n const body = o.compact ? compact(Math.abs(v), o.like !== undefined ? Math.abs(o.like) : undefined) : number(Math.abs(v), 'money');\n if (isZhTW() && cur === 'TWD') return `${v < 0 ? '-' : ''}NT$ ${body}`;\n if (o.compact) return `${v < 0 ? '-' : ''}${body} ${cur}`;\n return new Intl.NumberFormat(I18N.locale, {\n style: 'currency',\n currency: cur,\n currencyDisplay: 'narrowSymbol',\n minimumFractionDigits: 0,\n maximumFractionDigits: cur === 'TWD' || cur === 'JPY' ? 0 : 2,\n }).format(v);\n}\n\n/** Bytes to 「186 KB」「54.9 MB」「1.2 GB」. */\nexport function fileSize(b: number | null | undefined): string {\n if (b == null || Number.isNaN(b)) return '';\n // An empty file is 0 KB; anything else at least 1 KB.\n if (b < 1048576) return number(b === 0 ? 0 : Math.max(1, Math.round(b / 1024))) + ' KB';\n if (b < 1073741824) return number(b / 1048576, 1) + ' MB';\n return number(b / 1073741824, 1) + ' GB';\n}\n\n/** Shortens a path: keeps the first segment and the last two, 「src/…/hooks/ops.c:58」. */\nfunction path(p: string | null | undefined, o: { head?: number; tail?: number } = {}): string {\n const head = o.head ?? 1;\n const tail = o.tail ?? 2;\n const parts = String(p ?? '').split('/');\n return parts.length > head + tail ? `${parts.slice(0, head).join('/')}/…/${parts.slice(-tail).join('/')}` : String(p ?? '');\n}\n\n/** A part of a whole, as shown: 「1 / 1 個」「6 / 6 筆」, or 「1 / 5」 without a unit. Give screen readers\n * `fractionLabel` with it: they read the slash as 「斜線」. */\nfunction fraction(n: number, total: number, unit?: string): string {\n return tr(unit ? '{n} / {total} {unit}' : '{n} / {total}', { n: number(n), total: number(total), unit: unit ?? '' });\n}\n\n/** The same fraction as read aloud: 「1 個中的 1 個」「6 筆中的 6 筆」, or 「5 中的 1」 without a unit (English:\n * 「1 of 1」). For `aria-label`, or for visually hidden text beside the shown fraction. */\nfunction fractionLabel(n: number, total: number, unit?: string): string {\n return tr(unit ? '{total} {unit}中的 {n} {unit}' : '{total} 中的 {n}', { n: number(n), total: number(total), unit: unit ?? '' });\n}\n\n/** Every date, number, amount, size and path shown in the UI goes through these. */\nexport const format = {\n locale,\n date,\n time,\n dateTime,\n relative,\n month,\n weekdays,\n firstDay,\n number,\n percent,\n compact,\n money,\n fileSize,\n path,\n fraction,\n fractionLabel,\n};\n\n/* Calendar helpers (local dates, no time). */\nexport const fmtDate = (d: Date | null | undefined): string => (d ? `${d.getFullYear()}/${pad2(d.getMonth() + 1)}/${pad2(d.getDate())}` : '');\n\nexport function parseDate(s: string | null | undefined): Date | null {\n const m = /^(\\d{4})\\/(\\d{1,2})\\/(\\d{1,2})$/.exec(s || '');\n if (!m) return null;\n const d = new Date(+m[1], +m[2] - 1, +m[3]);\n return d.getMonth() === +m[2] - 1 ? d : null;\n}\n\nexport const sameDay = (a: Date | null | undefined, b: Date | null | undefined): boolean =>\n !!a && !!b && a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth() && a.getDate() === b.getDate();\n\nexport const dayAdd = (d: Date, n: number): Date => new Date(d.getFullYear(), d.getMonth(), d.getDate() + n);\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AI,CAAC,EAAE,GAAG,KAAK,EAAE,QAAQ,CAAC,MAAM;AAE1I,SAAgB,UAAU,GAA2C;CACnE,MAAM,IAAI,kCAAkC,KAAK,KAAK,EAAE;CACxD,IAAI,CAAC,GAAG,OAAO;CACf,MAAM,IAAI,IAAI,KAAK,CAAC,EAAE,IAAI,CAAC,EAAE,KAAK,GAAG,CAAC,EAAE,EAAE;CAC1C,OAAO,EAAE,SAAS,MAAM,CAAC,EAAE,KAAK,IAAI,IAAI;AAC1C;AAEA,MAAa,WAAW,GAA4B,MAClD,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,YAAY,MAAM,EAAE,YAAY,KAAK,EAAE,SAAS,MAAM,EAAE,SAAS,KAAK,EAAE,QAAQ,MAAM,EAAE,QAAQ;AAElH,MAAa,UAAU,GAAS,MAAoB,IAAI,KAAK,EAAE,YAAY,GAAG,EAAE,SAAS,GAAG,EAAE,QAAQ,IAAI,CAAC"}
package/dist/format.js CHANGED
@@ -1 +1 @@
1
- export { c as addMessages, i as format, l as setLocale, u as t } from "./format-entry-madGv9m_.js";
1
+ export { c as addMessages, i as format, l as setLocale, u as t } from "./format-entry-CfCwMZuE.js";
package/dist/index.d.ts CHANGED
@@ -901,7 +901,10 @@ interface MarkdownProps {
901
901
  /** small: 13 px, for notes. Default: the same 16 px as the text around it. */
902
902
  size?: 'body' | 'small';
903
903
  /** The heading level `#` becomes. Default 4: # is an h4 (20 px), ## an h5, ### and deeper h6 (both 16 px bold). */
904
- topLevel?: 3 | 4 | 5 | 6;
904
+ topLevel?: 1 | 2 | 3 | 4 | 5 | 6;
905
+ /** Link schemes of your own, such as ['fn', 'file']: [_sync_as](fn:harness/controller.py:VirtualRouter._sync_as)
906
+ * goes to linkHref and onLink as written, which decide what it opens. javascript:, data: and vbscript: never link. */
907
+ schemes?: string[];
905
908
  /** The address of a link (after the http, https, mailto or relative check); return undefined for no link. */
906
909
  linkHref?: (href: string) => string | undefined | null;
907
910
  /** A plain click on a link (the default navigation is prevented; Ctrl, ⌘ or Shift still open linkHref). */
@@ -935,6 +938,9 @@ interface SectionProps {
935
938
  lazy?: boolean;
936
939
  /** Remembers open or closed in localStorage under this key. If storage fails it works the same, without remembering. */
937
940
  storageKey?: string;
941
+ /** Controls right of the summary, such as a copy IconButton. Outside the title button: clicking them does not open
942
+ * or close the section. */
943
+ actions?: React.ReactNode;
938
944
  /** Heading level of the title. Default 3. The size stays 20 px whatever the level. */
939
945
  level?: 2 | 3 | 4 | 5 | 6;
940
946
  children?: React.ReactNode;
@@ -1070,6 +1076,15 @@ interface LayerGraphProps {
1070
1076
  /** The 「圖/清單」 switch above the diagram; the list shows every box and line as text, also for screen readers.
1071
1077
  * false hides the switch. */
1072
1078
  listView?: boolean;
1079
+ /** HC: a handle under the diagram to drag its height, like SplitPane's divider. Down: the layers move apart (the gaps
1080
+ * between them grow), so lines and their labels have more room. Up past the drawn height: the diagram scrolls up and
1081
+ * down inside a shorter frame. ↑↓ 16 px, Enter or a double-click goes back. Default false. */
1082
+ resizable?: boolean;
1083
+ /** Remembers the dragged height in localStorage under this name (ui-lg-height:<name>). */
1084
+ heightKey?: string;
1085
+ /** Controls of the page on the same row as 「圖/清單」, at its left, such as the page's own 「依元件/依檔案」 Tabs,
1086
+ * so two switches do not sit on two rows. */
1087
+ toolbar?: React.ReactNode;
1073
1088
  /** Headings of the list: { nodes, edges }. Default 「項目」 and 「關係」. */
1074
1089
  listLabels?: {
1075
1090
  nodes?: string;
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import { a as parseDate, c as addMessages, d as unitFor, i as format, l as setLocale, n as fileSize, o as sameDay, r as fmtDate, s as I18N, t as dayAdd, u as tr } from "./format-entry-madGv9m_.js";
2
+ import { a as parseDate, c as addMessages, d as unitFor, i as format, l as setLocale, n as fileSize, o as sameDay, r as fmtDate, s as I18N, t as dayAdd, u as tr } from "./format-entry-CfCwMZuE.js";
3
3
  import * as React from "react";
4
4
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
5
5
  import { Tooltip as Tooltip$1 } from "@base-ui/react/tooltip";
@@ -4687,6 +4687,17 @@ function GraphLegend({ items = LEGEND_DEFAULT, className }) {
4687
4687
  });
4688
4688
  }
4689
4689
  // src/components/Markdown/Markdown.tsx
4690
+ const DETAILS_OPEN = /^\s*<details\b[^>]*>/i;
4691
+ const DETAILS_TAG = /<(\/?)details\b[^>]*>/gi;
4692
+ const SUMMARY = /<summary\b[^>]*>([\s\S]*?)<\/summary>/i;
4693
+ const ALERT = /^\s*\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\]\s*$/i;
4694
+ const ALERT_TONE = {
4695
+ NOTE: "info",
4696
+ TIP: "success",
4697
+ IMPORTANT: "info",
4698
+ WARNING: "warning",
4699
+ CAUTION: "danger"
4700
+ };
4690
4701
  const FENCE = /^ {0,3}(`{3,}|~{3,})\s*([\w+#.-]*)/;
4691
4702
  const HEADING = /^ {0,3}(#{1,6})(?:\s+(.*?))?\s*#*\s*$/;
4692
4703
  const HR = /^ {0,3}([-*_])(?:\s*\1){2,}\s*$/;
@@ -4727,6 +4738,30 @@ function parse(lines) {
4727
4738
  i++;
4728
4739
  continue;
4729
4740
  }
4741
+ if (DETAILS_OPEN.test(line)) {
4742
+ const rest = lines.slice(i).join("\n");
4743
+ DETAILS_TAG.lastIndex = 0;
4744
+ let depth = 0;
4745
+ let open = -1;
4746
+ let close = rest.length;
4747
+ let after = rest.length;
4748
+ for (let m = DETAILS_TAG.exec(rest); m; m = DETAILS_TAG.exec(rest)) if (!m[1]) {
4749
+ if (depth++ === 0) open = m.index + m[0].length;
4750
+ } else if (--depth === 0) {
4751
+ close = m.index;
4752
+ after = m.index + m[0].length;
4753
+ break;
4754
+ }
4755
+ let inner = rest.slice(open, close);
4756
+ const sum = SUMMARY.exec(inner);
4757
+ if (sum) inner = inner.slice(0, sum.index) + inner.slice(sum.index + sum[0].length);
4758
+ out.push({
4759
+ t: "details",
4760
+ summary: (sum?.[1] ?? "").trim(),
4761
+ blocks: parse(inner.split("\n"))
4762
+ });
4763
+ return out.concat(parse(rest.slice(after).split("\n")));
4764
+ }
4730
4765
  const fence = FENCE.exec(line);
4731
4766
  if (fence) {
4732
4767
  const mark = fence[1];
@@ -4762,7 +4797,13 @@ function parse(lines) {
4762
4797
  body.push(QUOTE.exec(lines[i])?.[1] ?? lines[i]);
4763
4798
  i++;
4764
4799
  }
4765
- out.push({
4800
+ const alert = body.length > 0 ? ALERT.exec(body[0]) : null;
4801
+ if (alert) out.push({
4802
+ t: "alert",
4803
+ tone: ALERT_TONE[alert[1].toUpperCase()],
4804
+ blocks: parse(body.slice(1))
4805
+ });
4806
+ else out.push({
4766
4807
  t: "quote",
4767
4808
  blocks: parse(body)
4768
4809
  });
@@ -4852,6 +4893,11 @@ function safeHref(href) {
4852
4893
  }
4853
4894
  const PATH = /^(?:\.{1,2}\/)?(?:[\w.-]+\/)*[\w.-]+\.[A-Za-z0-9]+(?::\d+(?:-\d+)?)?$/;
4854
4895
  const isPath = (s) => PATH.test(s) && (s.includes("/") || /:\d/.test(s));
4896
+ const BLOCKED = [
4897
+ "javascript",
4898
+ "data",
4899
+ "vbscript"
4900
+ ];
4855
4901
  const CJK = /[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\u3000-\u303f\uff00-\uffef]/u;
4856
4902
  /** Inline Markdown: code spans, links, autolinks, bold, italic, hard breaks; HTML tags dropped, their text kept. */
4857
4903
  function inline(src, c) {
@@ -5016,9 +5062,11 @@ function findClose(src, from, run) {
5016
5062
  return -1;
5017
5063
  }
5018
5064
  function link(raw, children, c) {
5019
- const safe = safeHref(raw);
5065
+ const scheme = /^([a-z][a-z0-9+.-]*):/i.exec(raw.trim())?.[1].toLowerCase();
5066
+ const own = !!scheme && !BLOCKED.includes(scheme) && !!c.schemes?.some((x) => x.toLowerCase() === scheme);
5067
+ const safe = own ? raw.trim() : safeHref(raw);
5020
5068
  if (safe === void 0) return /* @__PURE__ */ jsx(React.Fragment, { children }, c.k());
5021
- const href = c.linkHref ? c.linkHref(safe) || void 0 : safe;
5069
+ const href = c.linkHref ? c.linkHref(safe) || void 0 : own ? void 0 : safe;
5022
5070
  if (!href && !c.onLink) return /* @__PURE__ */ jsx(React.Fragment, { children }, c.k());
5023
5071
  const outside = !!href && /^https?:/i.test(href);
5024
5072
  const onLink = c.onLink;
@@ -5064,6 +5112,7 @@ function Markdown(p) {
5064
5112
  let n = 0;
5065
5113
  const c = {
5066
5114
  k: () => "m" + n++,
5115
+ schemes: p.schemes,
5067
5116
  linkHref: p.linkHref,
5068
5117
  onLink: p.onLink,
5069
5118
  refHref: p.refHref,
@@ -5087,6 +5136,15 @@ function Markdown(p) {
5087
5136
  }
5088
5137
  case "p": return /* @__PURE__ */ jsx("p", { children: inline(b.text, c) }, c.k());
5089
5138
  case "hr": return /* @__PURE__ */ jsx("hr", {}, c.k());
5139
+ case "details": return /* @__PURE__ */ jsx(MdDetails, {
5140
+ summary: inline(b.summary, c),
5141
+ children: render(b.blocks)
5142
+ }, c.k());
5143
+ case "alert": return /* @__PURE__ */ jsx(Alert, {
5144
+ tone: b.tone,
5145
+ className: "ui-md-alert",
5146
+ children: render(b.blocks)
5147
+ }, c.k());
5090
5148
  case "quote": return /* @__PURE__ */ jsx("blockquote", { children: render(b.blocks) }, c.k());
5091
5149
  case "list": {
5092
5150
  const items = b.items.map((it) => /* @__PURE__ */ jsx("li", { children: it.length === 1 && it[0].t === "p" ? inline(it[0].text, c) : render(it) }, c.k()));
@@ -5125,6 +5183,7 @@ function Markdown(p) {
5125
5183
  }, j)) }) }), /* @__PURE__ */ jsx("tbody", { children: b.rows.map((r, ri) => /* @__PURE__ */ jsx("tr", { children: Array.from({ length: n }, (_, j) => /* @__PURE__ */ jsx("td", {
5126
5184
  className: numeric[j] ? "is-num" : void 0,
5127
5185
  style: align(j),
5186
+ "data-label": plain(b.head[j] ?? ""),
5128
5187
  children: inline(r[j] ?? "", c)
5129
5188
  }, j)) }, ri)) })]
5130
5189
  })
@@ -5137,6 +5196,47 @@ function Markdown(p) {
5137
5196
  children: render(parse(src.split("\n")))
5138
5197
  });
5139
5198
  }
5199
+ /** A header cell as plain text, for the label above each value when a narrow table turns into cards. */
5200
+ const plain = (md) => md.replace(/\[([^\]]*)\]\([^)]*\)/g, "$1").replace(/[`*_]/g, "").trim();
5201
+ /** DA: a <details> block: a button with the summary, closed at first. The closed content stays in the page
5202
+ * (hidden="until-found"), so the browser's find opens it, as in Section. */
5203
+ function MdDetails({ summary, children }) {
5204
+ const [open, setOpen] = React.useState(false);
5205
+ const id = React.useId();
5206
+ const body = React.useRef(null);
5207
+ React.useLayoutEffect(() => {
5208
+ const el = body.current;
5209
+ if (!el) return;
5210
+ if (open) {
5211
+ el.removeAttribute("hidden");
5212
+ return;
5213
+ }
5214
+ el.setAttribute("hidden", "until-found");
5215
+ const found = () => setOpen(true);
5216
+ el.addEventListener("beforematch", found);
5217
+ return () => el.removeEventListener("beforematch", found);
5218
+ }, [open]);
5219
+ return /* @__PURE__ */ jsxs("div", {
5220
+ className: cx("ui-md-details", open && "is-open"),
5221
+ children: [/* @__PURE__ */ jsxs("button", {
5222
+ type: "button",
5223
+ className: "ui-md-summary",
5224
+ "aria-expanded": open,
5225
+ "aria-controls": id,
5226
+ onClick: () => setOpen(!open),
5227
+ children: [/* @__PURE__ */ jsx(Icon, {
5228
+ name: "caret-right",
5229
+ size: 16,
5230
+ className: "ui-md-caret"
5231
+ }), /* @__PURE__ */ jsx("span", { children: summary })]
5232
+ }), /* @__PURE__ */ jsx("div", {
5233
+ id,
5234
+ ref: body,
5235
+ className: "ui-md-details-body",
5236
+ children
5237
+ })]
5238
+ });
5239
+ }
5140
5240
  // src/components/Section/Section.tsx
5141
5241
  const Group = React.createContext(null);
5142
5242
  const MOVE_MS = 260;
@@ -5245,31 +5345,37 @@ function Section(p) {
5245
5345
  return /* @__PURE__ */ jsxs("section", {
5246
5346
  id: p.id,
5247
5347
  className: cx("ui-sec", open && "is-open", p.className),
5248
- children: [/* @__PURE__ */ jsx(H, {
5249
- ref: head,
5250
- className: "ui-sec-h",
5251
- children: /* @__PURE__ */ jsxs("button", {
5252
- type: "button",
5253
- className: "ui-sec-btn",
5254
- "aria-expanded": open,
5255
- "aria-controls": body,
5256
- onClick: () => set(!open),
5257
- children: [
5258
- /* @__PURE__ */ jsx(Icon, {
5259
- name: "caret-right",
5260
- size: 18,
5261
- className: "ui-sec-caret"
5262
- }),
5263
- /* @__PURE__ */ jsx("span", {
5264
- className: "ui-sec-title",
5265
- children: p.title
5266
- }),
5267
- p.summary != null && p.summary !== false ? /* @__PURE__ */ jsx("span", {
5268
- className: "ui-sec-sum",
5269
- children: p.summary
5270
- }) : null
5271
- ]
5272
- })
5348
+ children: [/* @__PURE__ */ jsxs("div", {
5349
+ className: "ui-sec-row",
5350
+ children: [/* @__PURE__ */ jsx(H, {
5351
+ ref: head,
5352
+ className: "ui-sec-h",
5353
+ children: /* @__PURE__ */ jsxs("button", {
5354
+ type: "button",
5355
+ className: "ui-sec-btn",
5356
+ "aria-expanded": open,
5357
+ "aria-controls": body,
5358
+ onClick: () => set(!open),
5359
+ children: [
5360
+ /* @__PURE__ */ jsx(Icon, {
5361
+ name: "caret-right",
5362
+ size: 18,
5363
+ className: "ui-sec-caret"
5364
+ }),
5365
+ /* @__PURE__ */ jsx("span", {
5366
+ className: "ui-sec-title",
5367
+ children: p.title
5368
+ }),
5369
+ p.summary != null && p.summary !== false ? /* @__PURE__ */ jsx("span", {
5370
+ className: "ui-sec-sum",
5371
+ children: p.summary
5372
+ }) : null
5373
+ ]
5374
+ })
5375
+ }), p.actions ? /* @__PURE__ */ jsx("div", {
5376
+ className: "ui-sec-actions",
5377
+ children: p.actions
5378
+ }) : null]
5273
5379
  }), /* @__PURE__ */ jsx("div", {
5274
5380
  id: body,
5275
5381
  className: "ui-sec-body",
@@ -5495,6 +5601,66 @@ function textWidth(text, size, code) {
5495
5601
  return c.measureText(text).width;
5496
5602
  }
5497
5603
  const TAG_KEEP = 8;
5604
+ const MIN_FRAME = 160;
5605
+ const MAX_EXTRA = 200;
5606
+ /** HC: the bar under the diagram: drag it, ↑↓ 16 px, Enter or a double-click back to the drawn height. */
5607
+ function HeightHandle(p) {
5608
+ const [dragging, setDragging] = React.useState(false);
5609
+ const from = React.useRef(null);
5610
+ return /* @__PURE__ */ jsx("div", {
5611
+ className: cx("ui-lg-resize", dragging && "is-dragging"),
5612
+ role: "separator",
5613
+ "aria-orientation": "horizontal",
5614
+ "aria-label": tr("調整架構圖高度"),
5615
+ "aria-valuenow": p.value,
5616
+ "aria-valuemin": p.min,
5617
+ "aria-valuemax": p.max,
5618
+ "aria-valuetext": tr("{n} px", { n: p.value }),
5619
+ tabIndex: 0,
5620
+ onPointerDown: (e) => {
5621
+ if (e.button !== 0) return;
5622
+ e.preventDefault();
5623
+ e.currentTarget.setPointerCapture(e.pointerId);
5624
+ from.current = {
5625
+ y: e.clientY,
5626
+ d: p.start()
5627
+ };
5628
+ setDragging(true);
5629
+ },
5630
+ onPointerMove: (e) => {
5631
+ if (!from.current) return;
5632
+ p.onDrag(from.current.d + e.clientY - from.current.y);
5633
+ },
5634
+ onPointerUp: () => {
5635
+ from.current = null;
5636
+ setDragging(false);
5637
+ },
5638
+ onPointerCancel: () => {
5639
+ from.current = null;
5640
+ setDragging(false);
5641
+ },
5642
+ onDoubleClick: p.onReset,
5643
+ onKeyDown: (e) => {
5644
+ if (e.altKey || e.metaKey || e.ctrlKey) return;
5645
+ if (e.key === "ArrowUp" || e.key === "ArrowDown") {
5646
+ e.preventDefault();
5647
+ p.onKey(e.key === "ArrowUp" ? -16 : 16);
5648
+ } else if (e.key === "Enter") {
5649
+ e.preventDefault();
5650
+ p.onReset();
5651
+ }
5652
+ },
5653
+ children: /* @__PURE__ */ jsxs("span", {
5654
+ className: "ui-lg-resize-grip",
5655
+ "aria-hidden": "true",
5656
+ children: [
5657
+ /* @__PURE__ */ jsx("i", {}),
5658
+ /* @__PURE__ */ jsx("i", {}),
5659
+ /* @__PURE__ */ jsx("i", {})
5660
+ ]
5661
+ })
5662
+ });
5663
+ }
5498
5664
  function labelWidth(text) {
5499
5665
  const parts = text.split(SPLIT).filter(Boolean);
5500
5666
  if (measure === void 0) measure = document.createElement("canvas").getContext("2d");
@@ -5598,6 +5764,22 @@ function LayerGraph(p) {
5598
5764
  const fitted = fit && fit.at === avail ? fit : null;
5599
5765
  const NW = fitted?.nw ?? (p.nodeWidth || 200);
5600
5766
  const GAP = 56;
5767
+ const [dh, setDhState] = React.useState(() => {
5768
+ if (!p.resizable || !p.heightKey) return 0;
5769
+ try {
5770
+ const v = Number(localStorage.getItem("ui-lg-height:" + p.heightKey));
5771
+ return Number.isFinite(v) ? v : 0;
5772
+ } catch {
5773
+ return 0;
5774
+ }
5775
+ });
5776
+ const setDh = React.useCallback((v) => {
5777
+ setDhState(v);
5778
+ if (!p.heightKey) return;
5779
+ try {
5780
+ localStorage.setItem("ui-lg-height:" + p.heightKey, String(Math.round(v)));
5781
+ } catch {}
5782
+ }, [p.heightKey]);
5601
5783
  const spreadKey = avail + "#" + p.nodes.map((n) => n.id).join("|") + "#" + p.edges.map((e) => e.from + ">" + e.to + ":" + (e.label ?? "")).join("|");
5602
5784
  const [spreadAt, setSpread] = React.useState({
5603
5785
  key: "",
@@ -5633,7 +5815,9 @@ function LayerGraph(p) {
5633
5815
  const layers = [...byLayer.keys()].sort((a, b) => a - b);
5634
5816
  const cols = Math.max(1, ...layers.map((l) => byLayer.get(l)?.length ?? 0));
5635
5817
  let W = 32 + cols * NW + (cols - 1) * COL;
5636
- const gaps = layers.map(() => GAP);
5818
+ const between = Math.max(0, layers.length - 1);
5819
+ const extra = p.resizable && dh > 0 && between ? Math.min(MAX_EXTRA, dh / scale / between) : 0;
5820
+ const gaps = layers.map((_, k) => GAP + (k < between ? extra : 0));
5637
5821
  let H = 0;
5638
5822
  const pos = {};
5639
5823
  const layerIndex = {};
@@ -6852,48 +7036,60 @@ function LayerGraph(p) {
6852
7036
  spread,
6853
7037
  spreadKey
6854
7038
  ]);
7039
+ const drawnH = H * scale;
7040
+ const naturalH = drawnH - Math.max(0, dh);
7041
+ const frameH = p.resizable && dh < 0 ? Math.max(Math.min(MIN_FRAME, naturalH), naturalH + dh) : null;
7042
+ const dragTo = (v) => Math.max(Math.min(MIN_FRAME, naturalH) - naturalH, Math.min(v, between ? MAX_EXTRA * between * scale : 0));
6855
7043
  return /* @__PURE__ */ jsxs("div", {
6856
7044
  className: cx("ui-graph ui-lg", p.className),
6857
7045
  children: [
6858
- p.listView === false && !toggleShown ? null : /* @__PURE__ */ jsxs("div", {
7046
+ p.listView === false && !toggleShown && !p.toolbar ? null : /* @__PURE__ */ jsxs("div", {
6859
7047
  className: "ui-lg-bar",
6860
- children: [toggleShown && p.labelToggle === "icon" ? /* @__PURE__ */ jsx(IconButton, {
6861
- className: "ui-lg-labels-btn",
6862
- icon: "tag",
6863
- filled: labelsOn,
6864
- label: tr("顯示線上文字"),
6865
- "aria-pressed": labelsOn,
6866
- onClick: switchLabels
6867
- }) : toggleShown ? /* @__PURE__ */ jsxs("label", {
6868
- className: "ui-lg-labels-switch",
6869
- children: [/* @__PURE__ */ jsx(Switch, {
6870
- checked: labelsOn,
6871
- onChange: switchLabels,
6872
- label: tr("線上文字")
6873
- }), /* @__PURE__ */ jsx("span", {
6874
- "aria-hidden": "true",
6875
- children: tr("線上文字")
6876
- })]
6877
- }) : null, p.listView === false ? null : /* @__PURE__ */ jsx(Tabs, {
6878
- label: tr("顯示方式"),
6879
- value: view,
6880
- onChange: setView,
6881
- items: [{
6882
- id: "graph",
6883
- label: tr("圖")
6884
- }, {
6885
- id: "list",
6886
- label: tr("清單")
6887
- }]
6888
- })]
7048
+ children: [
7049
+ p.toolbar ? /* @__PURE__ */ jsx("div", {
7050
+ className: "ui-lg-toolbar",
7051
+ children: p.toolbar
7052
+ }) : null,
7053
+ toggleShown && p.labelToggle === "icon" ? /* @__PURE__ */ jsx(IconButton, {
7054
+ className: "ui-lg-labels-btn",
7055
+ icon: "tag",
7056
+ filled: labelsOn,
7057
+ label: tr("顯示線上文字"),
7058
+ "aria-pressed": labelsOn,
7059
+ onClick: switchLabels
7060
+ }) : toggleShown ? /* @__PURE__ */ jsxs("label", {
7061
+ className: "ui-lg-labels-switch",
7062
+ children: [/* @__PURE__ */ jsx(Switch, {
7063
+ checked: labelsOn,
7064
+ onChange: switchLabels,
7065
+ label: tr("線上文字")
7066
+ }), /* @__PURE__ */ jsx("span", {
7067
+ "aria-hidden": "true",
7068
+ children: tr("線上文字")
7069
+ })]
7070
+ }) : null,
7071
+ p.listView === false ? null : /* @__PURE__ */ jsx(Tabs, {
7072
+ label: tr("顯示方式"),
7073
+ value: view,
7074
+ onChange: setView,
7075
+ items: [{
7076
+ id: "graph",
7077
+ label: tr("圖")
7078
+ }, {
7079
+ id: "list",
7080
+ label: tr("清單")
7081
+ }]
7082
+ })
7083
+ ]
6889
7084
  }),
6890
7085
  showList ? list : null,
6891
7086
  /* @__PURE__ */ jsx("div", {
6892
7087
  className: cx("ui-lg-scroller", scrollMore && "has-more", showList && "is-hidden"),
6893
7088
  children: /* @__PURE__ */ jsx("div", {
6894
- className: "ui-lg-scroll",
7089
+ className: cx("ui-lg-scroll", frameH != null && "is-framed"),
6895
7090
  ref: scrollRef,
6896
7091
  onScroll: onScrollKeep,
7092
+ style: frameH != null ? { height: frameH } : void 0,
6897
7093
  children: /* @__PURE__ */ jsxs("div", {
6898
7094
  className: "ui-lg-canvas",
6899
7095
  style: scale === 1 ? {
@@ -6941,6 +7137,15 @@ function LayerGraph(p) {
6941
7137
  })
6942
7138
  })
6943
7139
  }),
7140
+ p.resizable && !showList ? /* @__PURE__ */ jsx(HeightHandle, {
7141
+ value: Math.round(drawnH + Math.min(0, dh)),
7142
+ min: Math.round(Math.min(MIN_FRAME, drawnH)),
7143
+ max: Math.round(drawnH - Math.max(0, dh) + MAX_EXTRA * between * scale),
7144
+ onDrag: (d) => setDh(dragTo(d)),
7145
+ onKey: (step) => setDh(dragTo(dh + step)),
7146
+ onReset: () => setDh(0),
7147
+ start: () => dh
7148
+ }) : null,
6944
7149
  showList ? null : /* @__PURE__ */ jsx(ScrollHint, {
6945
7150
  show: overflows,
6946
7151
  done: scrolled