@seanyeh77/ui 0.14.0 → 0.16.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.
@@ -67,6 +67,18 @@ const I18N = {
67
67
  "說明 {name}": "Explain {name}",
68
68
  程式碼: "Code",
69
69
  "第 {n} 行": "Line {n}",
70
+ "第 {n} 層": "Level {n}",
71
+ 第一行: "First line",
72
+ 最後一行: "Last line",
73
+ "上 20 行": "20 lines up",
74
+ "下 20 行": "20 lines down",
75
+ 上一段: "Previous section",
76
+ 下一段: "Next section",
77
+ "{name},第 {n} 行": "{name}, line {n}",
78
+ "顯示 {n} 筆,另有 {m} 筆,請輸入更長的字": "Showing {n}, {m} more: type more to narrow it down",
79
+ "縮排 {n} 格": "indented {n} spaces",
80
+ "縮排 {n} 個 tab": "indented {n} tabs",
81
+ "縮排 {a} 個 tab、{b} 格": "indented {a} tabs and {b} spaces",
70
82
  向右捲動: "Scroll right",
71
83
  筆: "rows",
72
84
  "1 筆": "1 row",
@@ -476,4 +488,4 @@ const sameDay = (a, b) => !!a && !!b && a.getFullYear() === b.getFullYear() && a
476
488
  const dayAdd = (d, n) => new Date(d.getFullYear(), d.getMonth(), d.getDate() + n);
477
489
  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 };
478
490
 
479
- //# sourceMappingURL=format-entry-DgBikvR_.js.map
491
+ //# sourceMappingURL=format-entry-C9LWyR-H.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format-entry-C9LWyR-H.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}, {what}',\n '{label}({inferred})': '{label} ({inferred})',\n 調整面板寬度: 'Resize the panel',\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 '原本:': '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);\n"],"mappings":";AAUA,MAAa,OAAkB;CAC7B,QAAQ;CACR,UAAU;CACV,UAAU,EACR,IAAI;EACF,aAAa;EACb,qBAAqB;EACrB,YAAY;EACZ,KAAK;EACL,KAAK;EACL,eAAe;EACf,KAAK;EACL,KAAK;EACL,MAAM;EACN,IAAI;EACJ,IAAI;EACJ,IAAI;EACJ,IAAI;EACJ,QAAQ;EACR,WAAW;EACX,IAAI;EACJ,IAAI;EACJ,MAAM;EACN,MAAM;EACN,wBAAwB;EACxB,MAAM;EACN,KAAK;EACL,QAAQ;EACR,IAAI;EACJ,OAAO;EACP,YAAY;EACZ,IAAI;EACJ,KAAK;EACL,SAAS;EACT,UAAU;EACV,WAAW;EACX,IAAI;EACJ,IAAI;EACJ,OAAO;EACP,IAAI;EACJ,aAAa;EACb,YAAY;EACZ,eAAe;EACf,eAAe;EACf,kBAAkB;EAClB,WAAW;EACX,0BAA0B;EAC1B,MAAM;EACN,IAAI;EACJ,MAAM;EACN,QAAQ;EACR,IAAI;EACJ,MAAM;EACN,MAAM;EACN,QAAQ;EACR,MAAM;EACN,GAAG;EACH,IAAI;EACJ,IAAI;EACJ,IAAI;EACJ,KAAK;EACL,KAAK;EACL,gBAAgB;EAChB,YAAY;EACZ,cAAc;EACd,mBAAmB;EACnB,aAAa;EACb,KAAK;EACL,WAAW;EACX,WAAW;EACX,KAAK;EACL,MAAM;EACN,UAAU;EACV,UAAU;EACV,KAAK;EACL,KAAK;EACL,kBAAkB;EAClB,6BAA6B;EAC7B,YAAY;EACZ,gBAAgB;EAChB,sBAAsB;EACtB,MAAM;EACN,GAAG;EACH,OAAO;EAEP,KAAK;EACL,KAAK;EACL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B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAGA,MAAa,WAAW,MAAwC,IAAI,GAAG,EAAE,YAAY,EAAE,GAAG,KAAK,EAAE,SAAS,IAAI,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-DgBikvR_.js";
1
+ export { c as addMessages, i as format, l as setLocale, u as t } from "./format-entry-C9LWyR-H.js";
package/dist/index.d.ts CHANGED
@@ -220,12 +220,14 @@ interface AppShellProps {
220
220
  actions?: React.ReactNode;
221
221
  /** The page: Cards and sections, 32 px apart. */
222
222
  children: React.ReactNode;
223
+ /** Labels under the phone tab bar's icons (MobileTabBar labels). Default true. */
224
+ tabLabels?: boolean;
223
225
  className?: string;
224
226
  }
225
227
  /** The dashboard frame: sidebar (240 px, 72 px collapsed) above 1024 px, a drawer from the top bar's menu button from
226
228
  * 600 to 1024 px, and bottom tabs on phones.
227
229
  * The top bar hides while scrolling down and returns when scrolling up. */
228
- export declare function AppShell({ nav, value, onNavigate, brand, title, breadcrumb, onSearch, actions, children, className }: AppShellProps): React.JSX.Element;
230
+ export declare function AppShell({ nav, value, onNavigate, brand, title, breadcrumb, onSearch, actions, children, tabLabels, className }: AppShellProps): React.JSX.Element;
229
231
  interface GridProps {
230
232
  /** Columns from 1280 px. Under 600 px there is one column; in between, at most 2. Default 3. */
231
233
  columns?: 1 | 2 | 3 | 4 | 6;
@@ -460,6 +462,12 @@ interface CodeViewProps {
460
462
  onRef?: OnRef;
461
463
  /** Scrolls inside the box and keeps the target in view, e.g. '420px'. */
462
464
  maxHeight?: string;
465
+ /** Where sections start, e.g. each function: [ and ] jump to the previous and next one (CB), and the section's
466
+ * name is read out with its line. Lines count from start, like target. */
467
+ sections?: {
468
+ line: number;
469
+ label: string;
470
+ }[];
463
471
  className?: string;
464
472
  /** focusTarget() moves keyboard and screen-reader focus to the target line. */
465
473
  ref?: React.Ref<CodeViewHandle>;
@@ -469,7 +477,7 @@ interface CodeViewHandle {
469
477
  focusTarget: () => void;
470
478
  }
471
479
  /** Source with line numbers and an optional target line: soft accent background, long lines wrap, light syntax colors. */
472
- export declare function CodeView({ code, start, target, context, file, fileHref, onFile, title, language, languageLabel, highlight, tokenizer, refHref, onRef, maxHeight, className, ref }: CodeViewProps): React.JSX.Element;
480
+ export declare function CodeView({ code, start, target, context, file, fileHref, onFile, title, language, languageLabel, highlight, tokenizer, refHref, onRef, maxHeight, sections, className, ref }: CodeViewProps): React.JSX.Element;
473
481
  interface PaletteItem {
474
482
  id?: string | number;
475
483
  label: string;
@@ -507,6 +515,9 @@ interface CommandPaletteProps<T extends PaletteItem = PaletteItem> {
507
515
  onQueryChange?: (query: string) => void;
508
516
  /** Shows 「搜尋中」 when there are no items yet. */
509
517
  loading?: boolean;
518
+ /** How many matched before you cut the list down to items (RA): the line under the results then says how many
519
+ * more there are, e.g. 「顯示 30 筆,另有 17 筆,請輸入更長的字」. Without it the line says 「共 30 筆」. */
520
+ total?: number;
510
521
  /** Most results shown. Default 50. */
511
522
  limit?: number;
512
523
  /** Ctrl K / ⌘K toggles it. Default true. */
@@ -1080,10 +1091,13 @@ interface MobileTabBarProps {
1080
1091
  onChange?: (id: string) => void;
1081
1092
  /** Default 「主要導覽」. */
1082
1093
  label?: string;
1094
+ /** Default true: an 11 px label under each icon (MA). false: icons only, each named by its aria-label, as in
1095
+ * photo apps, for a bar whose icons people already know. */
1096
+ labels?: boolean;
1083
1097
  className?: string;
1084
1098
  }
1085
1099
  /** Bottom navigation on phones, in place of the sidebar. The pill slides like a droplet; the selected icon is filled. */
1086
- export declare function MobileTabBar({ items, value, onChange, label, className }: MobileTabBarProps): React.JSX.Element;
1100
+ export declare function MobileTabBar({ items, value, onChange, label, labels, className }: MobileTabBarProps): React.JSX.Element;
1087
1101
  interface MultiSelectOption {
1088
1102
  value: string;
1089
1103
  label: 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-DgBikvR_.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-C9LWyR-H.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";
@@ -769,12 +769,12 @@ function TopBar({ title, breadcrumb, onSearch, searchLabel, children, onMenu, cl
769
769
  }
770
770
  // src/components/MobileTabBar/MobileTabBar.tsx
771
771
  /** Bottom navigation on phones, in place of the sidebar. The pill slides like a droplet; the selected icon is filled. */
772
- function MobileTabBar({ items, value, onChange, label, className }) {
772
+ function MobileTabBar({ items, value, onChange, label, labels = true, className }) {
773
773
  const idx = Math.max(0, items.findIndex((t) => t.id === value));
774
774
  const [forward, setForward] = React.useState(true);
775
775
  const w = 100 / Math.max(1, items.length);
776
776
  return /* @__PURE__ */ jsxs("nav", {
777
- className: cx("ui-tabbar", className),
777
+ className: cx("ui-tabbar", labels && "has-labels", className),
778
778
  "aria-label": label || tr("主要導覽"),
779
779
  children: [/* @__PURE__ */ jsx("span", {
780
780
  className: "ui-tabbar-pill",
@@ -784,20 +784,23 @@ function MobileTabBar({ items, value, onChange, label, className }) {
784
784
  right: `calc(${100 - idx * w - w / 2}% - 28px)`,
785
785
  transition: dropTransition("left", "right", forward)
786
786
  }
787
- }), items.map((t, i) => /* @__PURE__ */ jsx("button", {
787
+ }), items.map((t, i) => /* @__PURE__ */ jsxs("button", {
788
788
  type: "button",
789
789
  className: cx("ui-tabbar-item", i === idx && "is-selected"),
790
- "aria-label": t.label,
790
+ "aria-label": labels ? void 0 : t.label,
791
791
  "aria-current": i === idx ? "page" : void 0,
792
792
  onClick: () => {
793
793
  if (i !== idx) setForward(i > idx);
794
794
  onChange?.(t.id);
795
795
  },
796
- children: /* @__PURE__ */ jsx(IconOf, {
796
+ children: [/* @__PURE__ */ jsx(IconOf, {
797
797
  icon: t.icon,
798
798
  size: 22,
799
799
  filled: i === idx
800
- })
800
+ }), labels ? /* @__PURE__ */ jsx("span", {
801
+ className: "ui-tabbar-label",
802
+ children: t.label
803
+ }) : null]
801
804
  }, t.id))]
802
805
  });
803
806
  }
@@ -1014,7 +1017,7 @@ const MORE = "\0more";
1014
1017
  /** The dashboard frame: sidebar (240 px, 72 px collapsed) above 1024 px, a drawer from the top bar's menu button from
1015
1018
  * 600 to 1024 px, and bottom tabs on phones.
1016
1019
  * The top bar hides while scrolling down and returns when scrolling up. */
1017
- function AppShell({ nav, value, onNavigate, brand, title, breadcrumb, onSearch, actions, children, className }) {
1020
+ function AppShell({ nav, value, onNavigate, brand, title, breadcrumb, onSearch, actions, children, tabLabels, className }) {
1018
1021
  const phone = useNarrow();
1019
1022
  const tablet = useMedia("(min-width: 600px) and (max-width: 1024px)");
1020
1023
  const [userCollapsed, setUserCollapsed] = React.useState(() => store(COLLAPSE_KEY) === "1");
@@ -1104,7 +1107,8 @@ function AppShell({ nav, value, onNavigate, brand, title, breadcrumb, onSearch,
1104
1107
  phone && tabs.length ? /* @__PURE__ */ jsx(MobileTabBar, {
1105
1108
  items: tabs,
1106
1109
  value: tabValue,
1107
- onChange: onTab
1110
+ onChange: onTab,
1111
+ labels: tabLabels
1108
1112
  }) : null,
1109
1113
  phone || tablet ? /* @__PURE__ */ jsx(Drawer, {
1110
1114
  open: moreOpen,
@@ -1195,6 +1199,17 @@ function contrast(a, b) {
1195
1199
  const y = lum(b);
1196
1200
  return (Math.max(x, y) + .05) / (Math.min(x, y) + .05);
1197
1201
  }
1202
+ /** The accent's text color (accent-text): the accent itself when it reads on both bg and surface (4.5:1); else, in
1203
+ * light, the accent mixed with black 4 % at a time, in dark with white 5 % at a time, until it reads on both. Only
1204
+ * text changes: fills, bars, rings and dots keep the accent. */
1205
+ function accentText(hex, dark, bg, surface) {
1206
+ const reads = (c) => contrast(c, bg) >= 4.5 && contrast(c, surface) >= 4.5;
1207
+ const toward = dark ? "#ffffff" : "#000000";
1208
+ const step = dark ? .05 : .04;
1209
+ let text = hex;
1210
+ for (let k = 1; k * step <= 1 && !reads(text); k++) text = mixHex(hex, toward, k * step);
1211
+ return text;
1212
+ }
1198
1213
  /** Derives every accent token from one color (自訂強調色的換算 in docs/guidelines.md).
1199
1214
  * Returns false for anything but #rrggbb. quiet: apply without storing. */
1200
1215
  function setAccent(hex, quiet = false) {
@@ -1205,8 +1220,7 @@ function setAccent(hex, quiet = false) {
1205
1220
  const cs = getComputedStyle(root);
1206
1221
  const surface = (cs.getPropertyValue("--surface") || (dark ? "#393530" : "#ffffff")).trim();
1207
1222
  const bg = (cs.getPropertyValue("--bg") || (dark ? "#2f2a25" : "#fcfbfb")).trim();
1208
- let text = hex;
1209
- if (dark) for (let t = 0; t <= 1 && contrast(text, surface) < 4.5; t += .05) text = mixHex(hex, "#ffffff", t);
1223
+ const text = accentText(hex, dark, bg.startsWith("#") ? bg : dark ? "#2f2a25" : "#fcfbfb", surface.startsWith("#") ? surface : dark ? "#393530" : "#ffffff");
1210
1224
  const ink = "#171512";
1211
1225
  const vars = {
1212
1226
  "--accent": hex,
@@ -2120,6 +2134,18 @@ const tokenize = (lines, lang) => {
2120
2134
  });
2121
2135
  };
2122
2136
  // src/components/CodeView/CodeView.tsx
2137
+ /** A line's indentation, said after its number: a screen reader drops leading spaces, and in Python or YAML
2138
+ * the indentation is the structure (which `if` a line belongs to). Tabs and spaces are said apart. */
2139
+ function indentText(line) {
2140
+ const lead = /^[ \t]*/.exec(line)?.[0] ?? "";
2141
+ if (!lead || lead.length === line.length) return "";
2142
+ const tabs = lead.split(" ").length - 1;
2143
+ const spaces = lead.length - tabs;
2144
+ return tr(",") + (tabs && spaces ? tr("縮排 {a} 個 tab、{b} 格", {
2145
+ a: tabs,
2146
+ b: spaces
2147
+ }) : tabs ? tr("縮排 {n} 個 tab", { n: tabs }) : tr("縮排 {n} 格", { n: spaces }));
2148
+ }
2123
2149
  const OPS = /(->|::|==|!=|<=|>=|&&|\|\||\+\+|--|<<|>>|=>|\+=|-=|\*=|\/=)/;
2124
2150
  const AFTER = /([,.([{;])/;
2125
2151
  /** A piece of code with soft break points after commas, dots and opening brackets, and operators kept together. */
@@ -2176,7 +2202,7 @@ function breakable(text) {
2176
2202
  return out;
2177
2203
  }
2178
2204
  /** Source with line numbers and an optional target line: soft accent background, long lines wrap, light syntax colors. */
2179
- function CodeView({ code, start = 1, target, context = 2, file, fileHref, onFile, title, language, languageLabel, highlight = true, tokenizer = tokenize, refHref, onRef, maxHeight, className, ref }) {
2205
+ function CodeView({ code, start = 1, target, context = 2, file, fileHref, onFile, title, language, languageLabel, highlight = true, tokenizer = tokenize, refHref, onRef, maxHeight, sections, className, ref }) {
2180
2206
  const lines = React.useMemo(() => String(code || "").replace(/\n$/, "").split("\n"), [code]);
2181
2207
  const lang = language || languageOf(file);
2182
2208
  const toks = React.useMemo(() => highlight ? tokenizer(lines, lang) : lines.map((l) => [["", l]]), [
@@ -2220,6 +2246,7 @@ function CodeView({ code, start = 1, target, context = 2, file, fileHref, onFile
2220
2246
  rows.push(/* @__PURE__ */ jsxs("div", {
2221
2247
  role: "listitem",
2222
2248
  className: cx("ui-cv-line", on && "is-target"),
2249
+ "data-n": n,
2223
2250
  "aria-current": on && n === ta ? "location" : void 0,
2224
2251
  tabIndex: on && n === ta ? -1 : void 0,
2225
2252
  children: [/* @__PURE__ */ jsx("span", {
@@ -2231,7 +2258,7 @@ function CodeView({ code, start = 1, target, context = 2, file, fileHref, onFile
2231
2258
  className: "ui-cv-text",
2232
2259
  children: [/* @__PURE__ */ jsx("span", {
2233
2260
  className: "ui-visually-hidden ui-cv-sr",
2234
- children: tr("第 {n} 行", { n }) + tr(":")
2261
+ children: tr("第 {n} 行", { n }) + indentText(lines[i]) + tr(":")
2235
2262
  }), toks[i].map(([cls, text], j) => cls ? /* @__PURE__ */ jsx("span", {
2236
2263
  className: cls,
2237
2264
  children: (refHref || onRef) && (cls === "is-comment" || cls === "is-string") ? withPaths(text, refHref, onRef) : breakable(text)
@@ -2239,6 +2266,69 @@ function CodeView({ code, start = 1, target, context = 2, file, fileHref, onFile
2239
2266
  })]
2240
2267
  }, i));
2241
2268
  }
2269
+ const keys = [
2270
+ {
2271
+ k: "Home",
2272
+ label: "Home",
2273
+ what: tr("第一行")
2274
+ },
2275
+ {
2276
+ k: "End",
2277
+ label: "End",
2278
+ what: tr("最後一行")
2279
+ },
2280
+ {
2281
+ k: "PageUp",
2282
+ label: "PgUp",
2283
+ what: tr("上 20 行")
2284
+ },
2285
+ {
2286
+ k: "PageDown",
2287
+ label: "PgDn",
2288
+ what: tr("下 20 行")
2289
+ },
2290
+ ...sections?.length ? [{
2291
+ k: "[",
2292
+ label: "[",
2293
+ what: tr("上一段")
2294
+ }, {
2295
+ k: "]",
2296
+ label: "]",
2297
+ what: tr("下一段")
2298
+ }] : []
2299
+ ];
2300
+ const onMove = (e) => {
2301
+ if (e.altKey || e.ctrlKey || e.metaKey) return;
2302
+ const items = [...e.currentTarget.querySelectorAll("[role=\"listitem\"]")];
2303
+ if (!items.length) return;
2304
+ const nOf = (el) => Number(el.dataset.n);
2305
+ const at = items.indexOf(document.activeElement instanceof HTMLElement ? document.activeElement : items[0]);
2306
+ const now = at < 0 ? -1 : at;
2307
+ let to = -1;
2308
+ let said = "";
2309
+ if (e.key === "Home") to = 0;
2310
+ else if (e.key === "End") to = items.length - 1;
2311
+ else if (e.key === "PageDown") to = Math.min(items.length - 1, Math.max(0, now) + 20);
2312
+ else if (e.key === "PageUp") to = Math.max(0, now - 20);
2313
+ else if ((e.key === "[" || e.key === "]") && sections?.length) {
2314
+ const cur = now < 0 ? e.key === "]" ? -Infinity : Infinity : nOf(items[now]);
2315
+ const sorted = [...sections].sort((a, b) => a.line - b.line);
2316
+ const s = e.key === "]" ? sorted.find((x) => x.line > cur) : [...sorted].reverse().find((x) => x.line < cur);
2317
+ if (s) {
2318
+ to = items.findIndex((el) => nOf(el) >= s.line);
2319
+ said = s.label;
2320
+ }
2321
+ } else return;
2322
+ e.preventDefault();
2323
+ const el = items[to];
2324
+ if (!el) return;
2325
+ el.tabIndex = -1;
2326
+ el.focus();
2327
+ if (said) announce(tr("{name},第 {n} 行", {
2328
+ name: said,
2329
+ n: nOf(el)
2330
+ }));
2331
+ };
2242
2332
  const head = file || title ? /* @__PURE__ */ jsxs("div", {
2243
2333
  className: "ui-cv-head",
2244
2334
  children: [file ? fileHref || onFile ? /* @__PURE__ */ jsx(InlineCode, {
@@ -2272,11 +2362,18 @@ function CodeView({ code, start = 1, target, context = 2, file, fileHref, onFile
2272
2362
  style: maxHeight ? { maxHeight } : void 0,
2273
2363
  tabIndex: 0,
2274
2364
  "aria-label": tr("程式碼"),
2365
+ "aria-keyshortcuts": keys.map((k) => k.k).join(" "),
2366
+ onKeyDown: onMove,
2275
2367
  children: /* @__PURE__ */ jsx("code", {
2276
2368
  role: "list",
2277
2369
  children: rows
2278
2370
  })
2279
2371
  }),
2372
+ /* @__PURE__ */ jsx("div", {
2373
+ className: "ui-cv-keys",
2374
+ "aria-hidden": "true",
2375
+ children: keys.map((k) => /* @__PURE__ */ jsxs("span", { children: [/* @__PURE__ */ jsx("kbd", { children: k.label }), k.what] }, k.k))
2376
+ }),
2280
2377
  narrow && canWindow ? /* @__PURE__ */ jsx("button", {
2281
2378
  type: "button",
2282
2379
  className: "ui-link-btn ui-cv-more",
@@ -2306,7 +2403,7 @@ function score(it, q) {
2306
2403
  }
2307
2404
  /** One search for everything, opened with Ctrl K (⌘K). A panel in the middle of the screen; results sorted by relevance. */
2308
2405
  function CommandPalette(props) {
2309
- const { open, onOpenChange, items, onSelect, placeholder, recent, recentLabel, emptyText, noResultsText, kinds, filter = true, onQueryChange, loading, limit = 50, hotkey = true, defaultQuery = "", label } = props;
2406
+ const { open, onOpenChange, items, onSelect, placeholder, recent, recentLabel, emptyText, noResultsText, kinds, filter = true, onQueryChange, loading, total, limit = 50, hotkey = true, defaultQuery = "", label } = props;
2310
2407
  const [q, setQ] = React.useState(defaultQuery);
2311
2408
  const [active, setActive] = React.useState(0);
2312
2409
  useReturnFocus(open);
@@ -2391,7 +2488,12 @@ function CommandPalette(props) {
2391
2488
  };
2392
2489
  const none = (t) => typeof noResultsText === "function" ? noResultsText(t) : (noResultsText ?? tr("找不到符合「{q}」的結果")).replace("{q}", t);
2393
2490
  const empty = query ? none(q.trim()) : emptyText || tr("輸入名稱開始搜尋");
2394
- const said = !open ? "" : !query ? "" : loading ? tr("搜尋中") : shown.length ? tr("找到 {n} 筆結果", { n: shown.length }) : empty;
2491
+ const more = total != null && total > shown.length ? total - shown.length : 0;
2492
+ const count = more ? tr("顯示 {n} 筆,另有 {m} 筆,請輸入更長的字", {
2493
+ n: shown.length,
2494
+ m: more
2495
+ }) : tr("共 {n} 筆", { n: shown.length });
2496
+ const said = !open ? "" : !query ? "" : loading ? tr("搜尋中") : shown.length ? more ? count : tr("找到 {n} 筆結果", { n: shown.length }) : empty;
2395
2497
  React.useEffect(() => {
2396
2498
  if (!said) return;
2397
2499
  const t = setTimeout(() => announce(said), 400);
@@ -2484,6 +2586,15 @@ function CommandPalette(props) {
2484
2586
  className: "ui-pal-empty",
2485
2587
  children: loading ? tr("搜尋中") : empty
2486
2588
  }),
2589
+ loading && shown.length ? /* @__PURE__ */ jsx("p", {
2590
+ className: "ui-pal-loading",
2591
+ children: tr("搜尋中")
2592
+ }) : null,
2593
+ query && !loading && shown.length ? /* @__PURE__ */ jsx("p", {
2594
+ className: "ui-pal-count",
2595
+ "aria-hidden": "true",
2596
+ children: count
2597
+ }) : null,
2487
2598
  /* @__PURE__ */ jsxs("div", {
2488
2599
  className: "ui-pal-keys",
2489
2600
  "aria-hidden": "true",
@@ -7847,8 +7958,27 @@ function TreeList(p) {
7847
7958
  want.current = rows[j].n.id;
7848
7959
  setFocusId(rows[j].n.id);
7849
7960
  };
7961
+ const treeEl = React.useRef(null);
7962
+ React.useLayoutEffect(() => {
7963
+ for (const el of treeEl.current?.querySelectorAll("[role=\"treeitem\"] :is(a[href], button, input, select, textarea, [tabindex])") ?? []) if (el.tabIndex >= 0 && el.getAttribute("role") !== "treeitem") el.tabIndex = -1;
7964
+ });
7965
+ const inner = (row) => [...row.querySelectorAll("a[href], button, input, select, textarea, [tabindex]")].filter((el) => el.closest("[role=\"treeitem\"]") === row && el.getAttribute("role") !== "treeitem" && !el.closest("[aria-hidden=\"true\"]") && !el.matches(":disabled"));
7850
7966
  const onKey = (e) => {
7851
- if (e.target.getAttribute("role") !== "treeitem" || !rows.length || browserKey(e)) return;
7967
+ if (!rows.length || browserKey(e)) return;
7968
+ const t = e.target;
7969
+ const row = t.closest("[role=\"treeitem\"]");
7970
+ if (row && row !== t) {
7971
+ const list = inner(row);
7972
+ const i = list.indexOf(t);
7973
+ if (e.key === "ArrowRight" && i < list.length - 1) list[i + 1].focus();
7974
+ else if (e.key === "ArrowLeft" && i > 0) list[i - 1].focus();
7975
+ else if (e.key === "ArrowLeft" || e.key === "Escape") row.focus();
7976
+ else if (e.key === "ArrowDown" || e.key === "ArrowUp") go(cur + (e.key === "ArrowDown" ? 1 : -1));
7977
+ else return;
7978
+ e.preventDefault();
7979
+ return;
7980
+ }
7981
+ if (t.getAttribute("role") !== "treeitem") return;
7852
7982
  const r = rows[cur];
7853
7983
  const k = e.key;
7854
7984
  if (!([
@@ -7866,7 +7996,9 @@ function TreeList(p) {
7866
7996
  else if (k === "Home") go(0);
7867
7997
  else if (k === "End") go(rows.length - 1);
7868
7998
  else if (k === "ArrowRight") {
7999
+ const list = inner(t);
7869
8000
  if (r.isF && !r.open) toggle(r.n);
8001
+ else if (list.length) list[0].focus();
7870
8002
  else if (r.isF) go(cur + 1);
7871
8003
  } else if (k === "ArrowLeft") {
7872
8004
  if (r.isF && r.open) toggle(r.n);
@@ -7947,6 +8079,7 @@ function TreeList(p) {
7947
8079
  r.depth > 3 ? /* @__PURE__ */ jsx("span", {
7948
8080
  className: "ui-tree-depth",
7949
8081
  "aria-hidden": "true",
8082
+ title: tr("第 {n} 層", { n: r.depth + 1 }),
7950
8083
  children: "L" + (r.depth + 1)
7951
8084
  }) : null,
7952
8085
  /* @__PURE__ */ jsx("span", {
@@ -8220,6 +8353,7 @@ function TreeList(p) {
8220
8353
  "aria-label": p.label || (typeof p.title === "string" ? p.title : void 0),
8221
8354
  "aria-multiselectable": selectable || void 0,
8222
8355
  className: "ui-tree-list",
8356
+ ref: treeEl,
8223
8357
  onKeyDown: onKey,
8224
8358
  children: nest(0, 0)[0]
8225
8359
  }) : /* @__PURE__ */ jsx("p", {