@seanyeh77/ui 0.11.0 → 0.12.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 +9 -9
- package/dist/bundle.js.map +1 -1
- package/dist/{format-entry-Cvq4QsNK.d.ts → format-entry-BJI8MU2K.d.ts} +4 -1
- package/dist/{format-entry-CkHGBG0X.js → format-entry-jAIdVjUz.js} +14 -2
- package/dist/format-entry-jAIdVjUz.js.map +1 -0
- package/dist/format.d.ts +2 -2
- package/dist/format.js +1 -1
- package/dist/index.d.ts +25 -11
- package/dist/index.js +73 -42
- package/dist/index.js.map +1 -1
- package/dist/styles.css +26 -2
- package/docs/CommandPalette.md +1 -1
- package/docs/DataTable.md +1 -1
- package/docs/Graph.md +1 -1
- package/docs/LayerGraph.md +4 -3
- package/docs/Tabs.md +2 -1
- package/docs/guidelines.md +2 -2
- package/package.json +2 -2
- package/dist/format-entry-CkHGBG0X.js.map +0 -1
|
@@ -63,10 +63,13 @@ declare const format: {
|
|
|
63
63
|
};
|
|
64
64
|
/** Translates a built-in zh-TW string into the current locale; {name} placeholders take vars. */
|
|
65
65
|
declare function tr(key: string, vars?: Record<string, string | number>): string;
|
|
66
|
+
/** A count's unit: a function gets the count (for plurals, 「1 row」「2 rows」); a string goes through tr(), and for 1
|
|
67
|
+
* the message 「1 <unit>」 is used when the locale has one (「1 筆」 → 「1 row」), without the number. */
|
|
68
|
+
type CountUnit = string | ((n: number) => string);
|
|
66
69
|
/** Switches the interface language and, optionally, the currency used by format.money. */
|
|
67
70
|
declare function setLocale(locale: string, opts?: {
|
|
68
71
|
currency?: string;
|
|
69
72
|
}): void;
|
|
70
73
|
/** Adds or overrides translations for a locale. Keys are the zh-TW strings. */
|
|
71
74
|
declare function addMessages(locale: string, dict: Record<string, string>): void;
|
|
72
|
-
export {
|
|
75
|
+
export { Decimals as a, tr as i, addMessages as n, format as o, setLocale as r, CountUnit as t };
|
|
@@ -68,6 +68,7 @@ const I18N = {
|
|
|
68
68
|
"第 {n} 行": "Line {n}",
|
|
69
69
|
向右捲動: "Scroll right",
|
|
70
70
|
筆: "rows",
|
|
71
|
+
"1 筆": "1 row",
|
|
71
72
|
",": ", ",
|
|
72
73
|
":": ": ",
|
|
73
74
|
"。": ". ",
|
|
@@ -214,6 +215,8 @@ const I18N = {
|
|
|
214
215
|
"搜尋({k})": "Search ({k})",
|
|
215
216
|
確定的關係: "Confirmed",
|
|
216
217
|
推測的關係: "Inferred",
|
|
218
|
+
專案宣告的關係: "Declared by the project",
|
|
219
|
+
宣告: "Declared",
|
|
217
220
|
外部項目: "External"
|
|
218
221
|
} }
|
|
219
222
|
};
|
|
@@ -225,6 +228,15 @@ function tr(key, vars) {
|
|
|
225
228
|
const out = (isZhTW() ? null : msgsFor(I18N.locale))?.[key] ?? key;
|
|
226
229
|
return vars ? out.replace(/\{(\w+)\}/g, (a, k) => vars[k] !== void 0 ? String(vars[k]) : a) : out;
|
|
227
230
|
}
|
|
231
|
+
function unitFor(unit, n) {
|
|
232
|
+
if (!unit) return "";
|
|
233
|
+
if (typeof unit === "function") return unit(n);
|
|
234
|
+
if (n === 1) {
|
|
235
|
+
const one = tr("1 " + unit);
|
|
236
|
+
if (one !== "1 " + unit) return one.replace(/^1\s*/, "");
|
|
237
|
+
}
|
|
238
|
+
return tr(unit);
|
|
239
|
+
}
|
|
228
240
|
/** Switches the interface language and, optionally, the currency used by format.money. */
|
|
229
241
|
function setLocale(locale, opts) {
|
|
230
242
|
I18N.locale = locale || "zh-TW";
|
|
@@ -461,6 +473,6 @@ function parseDate(s) {
|
|
|
461
473
|
}
|
|
462
474
|
const sameDay = (a, b) => !!a && !!b && a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth() && a.getDate() === b.getDate();
|
|
463
475
|
const dayAdd = (d, n) => new Date(d.getFullYear(), d.getMonth(), d.getDate() + n);
|
|
464
|
-
export { parseDate as a, addMessages as c, format as i, setLocale as l, fileSize as n, sameDay as o, fmtDate as r, I18N as s, dayAdd as t, tr as u };
|
|
476
|
+
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 };
|
|
465
477
|
|
|
466
|
-
//# sourceMappingURL=format-entry-
|
|
478
|
+
//# sourceMappingURL=format-entry-jAIdVjUz.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format-entry-jAIdVjUz.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 圖: '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 向右捲動: '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,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,MAAM;EACN,GAAG;EACH,OAAO;EAEP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AAGA,MAAa,SAAS;CACpB;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.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
export { type Decimals, addMessages, format, setLocale, tr as t };
|
|
1
|
+
import { a as Decimals, i as tr, n as addMessages, o as format, r as setLocale, t as CountUnit } from "./format-entry-BJI8MU2K.js";
|
|
2
|
+
export { type CountUnit, type Decimals, addMessages, format, setLocale, tr as t };
|
package/dist/format.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { c as addMessages, i as format, l as setLocale, u as t } from "./format-entry-
|
|
1
|
+
export { c as addMessages, i as format, l as setLocale, u as t } from "./format-entry-jAIdVjUz.js";
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as
|
|
1
|
+
import { a as Decimals, i as tr, n as addMessages, o as format, r as setLocale, t as CountUnit } from "./format-entry-BJI8MU2K.js";
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
declare const PH: {
|
|
4
4
|
readonly archive: '<path d="M224,48H32A16,16,0,0,0,16,64V88a16,16,0,0,0,16,16v88a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V104a16,16,0,0,0,16-16V64A16,16,0,0,0,224,48ZM208,192H48V104H208ZM224,88H32V64H224V88ZM96,136a8,8,0,0,1,8-8h48a8,8,0,0,1,0,16H104A8,8,0,0,1,96,136Z"/>';
|
|
@@ -497,6 +497,9 @@ interface CommandPaletteProps<T extends PaletteItem = PaletteItem> {
|
|
|
497
497
|
recentLabel?: string;
|
|
498
498
|
/** Shown with nothing typed and no recent items. Default 「輸入名稱開始搜尋」. */
|
|
499
499
|
emptyText?: string;
|
|
500
|
+
/** Shown and read out when the typed text finds nothing, e.g. what else to try. `{q}` is the typed text; a function
|
|
501
|
+
* gets it. Default 「找不到符合「{q}」的結果」. Not an item, so it is never counted as a result. */
|
|
502
|
+
noResultsText?: string | ((query: string) => string);
|
|
500
503
|
/** Icon for each of your own kinds: { 函式: 'brackets-curly' }. */
|
|
501
504
|
kinds?: Record<string, IconSource>;
|
|
502
505
|
/** false: items are already filtered (server search with onQueryChange). */
|
|
@@ -611,7 +614,7 @@ interface DataTableProps<R extends Row = Record<string, unknown>> {
|
|
|
611
614
|
/** Title above the table, also its accessible name. */
|
|
612
615
|
caption?: string;
|
|
613
616
|
/** Segmented summary above the table: 「全部」 plus one tab per status with its count; picking one filters the rows.
|
|
614
|
-
* `unit` follows every count; default 「筆」. */
|
|
617
|
+
* `unit` follows every count; default 「筆」. A function gets the count, for plurals in other languages. */
|
|
615
618
|
summary?: {
|
|
616
619
|
key: RowKey<R>;
|
|
617
620
|
items: {
|
|
@@ -619,7 +622,7 @@ interface DataTableProps<R extends Row = Record<string, unknown>> {
|
|
|
619
622
|
label: string;
|
|
620
623
|
}[];
|
|
621
624
|
label?: string;
|
|
622
|
-
unit?:
|
|
625
|
+
unit?: CountUnit;
|
|
623
626
|
};
|
|
624
627
|
/** aria-label when there is no caption. */
|
|
625
628
|
label?: string;
|
|
@@ -830,8 +833,9 @@ export declare function FormGrid({ children, className }: FormGridProps): React.
|
|
|
830
833
|
/** <defs> with the arrowheads #ui-arrow and #ui-arrow-accent; put it first inside your diagram's <svg>. */
|
|
831
834
|
export declare function GraphDefs(): import("react").JSX.Element;
|
|
832
835
|
interface GraphLegendItem {
|
|
833
|
-
/** edge: a confirmed line; inferred: a dashed line;
|
|
834
|
-
|
|
836
|
+
/** edge: a confirmed line; inferred: a dashed line; declared: long-short dashes (declared by the project); external: a
|
|
837
|
+
* dashed box; node: a plain box; weight: thin and thick lines. */
|
|
838
|
+
type: 'edge' | 'inferred' | 'declared' | 'external' | 'node' | 'weight';
|
|
835
839
|
/** Your own words for it: 「呼叫」「推測的呼叫」「外部函式」. */
|
|
836
840
|
label: string;
|
|
837
841
|
/** Adds a Term with this explanation. */
|
|
@@ -908,6 +912,9 @@ interface LayerGraphEdge {
|
|
|
908
912
|
count?: number;
|
|
909
913
|
/** Inferred by a rule rather than known: dashed and labelled. */
|
|
910
914
|
inferred?: boolean;
|
|
915
|
+
/** Declared by the project, e.g. in a config file, rather than seen by a compiler: long-short dashes and labelled
|
|
916
|
+
* like an inferred edge, but with a basis. Wins over `inferred`. */
|
|
917
|
+
declared?: boolean;
|
|
911
918
|
/** Label of an inferred edge; `backticks` and numbers are in Geist Mono. */
|
|
912
919
|
label?: string;
|
|
913
920
|
/** Names the edge for selectedEdge and onSelectEdge. Default `${from}->${to}`. */
|
|
@@ -950,6 +957,12 @@ interface LayerGraphProps {
|
|
|
950
957
|
inferredLabel?: string;
|
|
951
958
|
/** Explains inferred edges in the legend (a Term). */
|
|
952
959
|
inferredText?: string;
|
|
960
|
+
/** The word for declared edges, after a label in the list. Default 「宣告」. */
|
|
961
|
+
declaredLabel?: string;
|
|
962
|
+
/** The legend entry for declared edges. Default 「專案宣告的關係」. */
|
|
963
|
+
declaredLegend?: string;
|
|
964
|
+
/** Explains declared edges in the legend (a Term), e.g. which file declares them. */
|
|
965
|
+
declaredText?: string;
|
|
953
966
|
/** false hides the legend. By default it lists only the kinds of line the diagram has. */
|
|
954
967
|
legend?: boolean;
|
|
955
968
|
legendItems?: GraphLegendItem[];
|
|
@@ -970,7 +983,7 @@ interface LayerGraphProps {
|
|
|
970
983
|
}
|
|
971
984
|
/** Architecture as layers of boxes with arrows. Line width shows how often; inferred relations are dashed and labelled;
|
|
972
985
|
* shared items are listed under the diagram instead of drawn. Wider than its box: the boxes narrow (down to 120 px),
|
|
973
|
-
* then the whole diagram scales down (to 0.75 at least); past that it scrolls sideways (PM). */
|
|
986
|
+
* then the whole diagram scales down (to 0.75 at least); past that it scrolls sideways at full width (PM, WA). */
|
|
974
987
|
export declare function LayerGraph(p: LayerGraphProps): React.JSX.Element;
|
|
975
988
|
interface LineSeries {
|
|
976
989
|
name: string;
|
|
@@ -1293,8 +1306,8 @@ interface TabItem<V extends string = string> {
|
|
|
1293
1306
|
label: string;
|
|
1294
1307
|
/** A count after the label, e.g. how many rows a view has. */
|
|
1295
1308
|
count?: number;
|
|
1296
|
-
/** Unit after this tab's count, e.g.
|
|
1297
|
-
unit?:
|
|
1309
|
+
/** Unit after this tab's count, e.g. 「筆」, or a function of the count for plurals. Default: the list's unit. */
|
|
1310
|
+
unit?: CountUnit;
|
|
1298
1311
|
}
|
|
1299
1312
|
interface TabsProps<V extends string = string> {
|
|
1300
1313
|
items: TabItem<V>[];
|
|
@@ -1302,8 +1315,9 @@ interface TabsProps<V extends string = string> {
|
|
|
1302
1315
|
onChange?: (id: V) => void;
|
|
1303
1316
|
/** aria-label of the tab list. */
|
|
1304
1317
|
label?: string;
|
|
1305
|
-
/** Unit after every count, e.g. 「筆」 or 「個」: a number carries its unit.
|
|
1306
|
-
|
|
1318
|
+
/** Unit after every count, e.g. 「筆」 or 「個」: a number carries its unit. A function gets the count, for plurals:
|
|
1319
|
+
* `(n) => (n === 1 ? 'item' : 'items')`. */
|
|
1320
|
+
unit?: CountUnit;
|
|
1307
1321
|
className?: string;
|
|
1308
1322
|
}
|
|
1309
1323
|
/** Views of the same content. The underline moves like a droplet; arrow keys move between tabs. */
|
|
@@ -1539,4 +1553,4 @@ export declare const MOTION: {
|
|
|
1539
1553
|
/** Says text to screen readers through the page's polite live region, without moving focus: 「顯示 6 筆」.
|
|
1540
1554
|
* A second call before the first is read replaces it. */
|
|
1541
1555
|
export declare function announce(text: string): void;
|
|
1542
|
-
export { type AccentPickerProps, type ActionBarAction, type ActionBarProps, type AlertProps, type AlertTone, type AppShellProps, type BadgeProps, type BadgeStatus, type BarChartProps, type BarDatum, type BreadcrumbItem, type BreadcrumbProps, type ButtonProps, type CalendarProps, type CardProps, type CheckboxProps, type CodeLanguage, type CodeTextProps, type CodeViewHandle, type CodeViewProps, type CommandPaletteProps, type CustomIcon, type DangerConfirm, type DangerZoneProps, type DataTableColumn, type DataTableFilter, type DataTableProps, type DataTableView, type DatePickerProps, type DateRange, type DateRangePickerProps, type DayState, type Decimals, type DetailListItem, type DetailListProps, type DialogProps, type DrawerProps, type EmptyStateProps, type ErrorPageProps, type FileUploadProps, type FilterOption, type FilterValue, type FormGridProps, type GraphLegendItem, type GraphLegendProps, type GridProps, type IconButtonProps, type IconName, type IconProps, type IconSource, type InlineCodeProps, type KpiCardProps, type LayerGraphEdge, type LayerGraphNode, type LayerGraphProps, type LineChartProps, type LineSeries, type LoadingBarProps, type LoginCardProps, type MenuItem, type MenuProps, type MobileTab, type MobileTabBarProps, type MultiSelectOption, type MultiSelectProps, type NavItem, type NavSection, type NotificationBellProps, type NotificationItem, type OnRef, type PageProps, type PaletteItem, type PopoverProps, type ProgressBarProps, type ProgressRingProps, type ProjectOption, type ProjectStatus, type ProjectSwitcherProps, type RadioGroupProps, type RadioOption, type RangeValue, type RefHref, type Row, type RowKey, type SearchFieldProps, type SelectOption, type SelectProps, type SettingsCategory, type SettingsLayoutProps, type SettingsSectionProps, type SideNavProps, type SkeletonProps, type SplitPaneProps, type SuggestionProps, type SwitchProps, type TabItem, type TabsProps, type TagProps, type TermProps, type TextAreaProps, type TextFieldProps, type ThemePickerProps, type ThemeSetting, type ToastProps, type Token, type TokenClass, type Tokenizer, type TooltipProps, type TopBarProps, type Total, type TourProps, type TourStep, type TreeListProps, type TreeNode, type UploadFile, addMessages, format, setLocale, tr as t };
|
|
1556
|
+
export { type AccentPickerProps, type ActionBarAction, type ActionBarProps, type AlertProps, type AlertTone, type AppShellProps, type BadgeProps, type BadgeStatus, type BarChartProps, type BarDatum, type BreadcrumbItem, type BreadcrumbProps, type ButtonProps, type CalendarProps, type CardProps, type CheckboxProps, type CodeLanguage, type CodeTextProps, type CodeViewHandle, type CodeViewProps, type CommandPaletteProps, type CountUnit, type CustomIcon, type DangerConfirm, type DangerZoneProps, type DataTableColumn, type DataTableFilter, type DataTableProps, type DataTableView, type DatePickerProps, type DateRange, type DateRangePickerProps, type DayState, type Decimals, type DetailListItem, type DetailListProps, type DialogProps, type DrawerProps, type EmptyStateProps, type ErrorPageProps, type FileUploadProps, type FilterOption, type FilterValue, type FormGridProps, type GraphLegendItem, type GraphLegendProps, type GridProps, type IconButtonProps, type IconName, type IconProps, type IconSource, type InlineCodeProps, type KpiCardProps, type LayerGraphEdge, type LayerGraphNode, type LayerGraphProps, type LineChartProps, type LineSeries, type LoadingBarProps, type LoginCardProps, type MenuItem, type MenuProps, type MobileTab, type MobileTabBarProps, type MultiSelectOption, type MultiSelectProps, type NavItem, type NavSection, type NotificationBellProps, type NotificationItem, type OnRef, type PageProps, type PaletteItem, type PopoverProps, type ProgressBarProps, type ProgressRingProps, type ProjectOption, type ProjectStatus, type ProjectSwitcherProps, type RadioGroupProps, type RadioOption, type RangeValue, type RefHref, type Row, type RowKey, type SearchFieldProps, type SelectOption, type SelectProps, type SettingsCategory, type SettingsLayoutProps, type SettingsSectionProps, type SideNavProps, type SkeletonProps, type SplitPaneProps, type SuggestionProps, type SwitchProps, type TabItem, type TabsProps, type TagProps, type TermProps, type TextAreaProps, type TextFieldProps, type ThemePickerProps, type ThemeSetting, type ToastProps, type Token, type TokenClass, type Tokenizer, type TooltipProps, type TopBarProps, type Total, type TourProps, type TourStep, type TreeListProps, type TreeNode, type UploadFile, addMessages, format, setLocale, tr as t };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { a as parseDate, c as addMessages, 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-
|
|
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-jAIdVjUz.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";
|
|
@@ -2306,7 +2306,7 @@ function score(it, q) {
|
|
|
2306
2306
|
}
|
|
2307
2307
|
/** One search for everything, opened with Ctrl K (⌘K). A panel in the middle of the screen; results sorted by relevance. */
|
|
2308
2308
|
function CommandPalette(props) {
|
|
2309
|
-
const { open, onOpenChange, items, onSelect, placeholder, recent, recentLabel, emptyText, kinds, filter = true, onQueryChange, loading, limit = 50, hotkey = true, defaultQuery = "", label } = props;
|
|
2309
|
+
const { open, onOpenChange, items, onSelect, placeholder, recent, recentLabel, emptyText, noResultsText, kinds, filter = true, onQueryChange, loading, limit = 50, hotkey = true, defaultQuery = "", label } = props;
|
|
2310
2310
|
const [q, setQ] = React.useState(defaultQuery);
|
|
2311
2311
|
const [active, setActive] = React.useState(0);
|
|
2312
2312
|
useReturnFocus(open);
|
|
@@ -2389,7 +2389,8 @@ function CommandPalette(props) {
|
|
|
2389
2389
|
] }) : t
|
|
2390
2390
|
});
|
|
2391
2391
|
};
|
|
2392
|
-
const
|
|
2392
|
+
const none = (t) => typeof noResultsText === "function" ? noResultsText(t) : (noResultsText ?? tr("找不到符合「{q}」的結果")).replace("{q}", t);
|
|
2393
|
+
const empty = query ? none(q.trim()) : emptyText || tr("輸入名稱開始搜尋");
|
|
2393
2394
|
const said = !open ? "" : !query ? "" : loading ? tr("搜尋中") : shown.length ? tr("找到 {n} 筆結果", { n: shown.length }) : empty;
|
|
2394
2395
|
React.useEffect(() => {
|
|
2395
2396
|
if (!said) return;
|
|
@@ -2578,7 +2579,7 @@ function Tabs({ items, value, onChange, label, unit, className }) {
|
|
|
2578
2579
|
setForward(i > idx);
|
|
2579
2580
|
bump();
|
|
2580
2581
|
onChange?.(items[i].id);
|
|
2581
|
-
announce(items[i].label + (items[i].count != null ? " " + format.number(items[i].count ?? 0) + (items[i].unit || unit ? " " +
|
|
2582
|
+
announce(items[i].label + (items[i].count != null ? " " + format.number(items[i].count ?? 0) + (items[i].unit || unit ? " " + unitFor(items[i].unit || unit, items[i].count ?? 0) : "") : ""));
|
|
2582
2583
|
};
|
|
2583
2584
|
return /* @__PURE__ */ jsxs("div", {
|
|
2584
2585
|
ref: track,
|
|
@@ -2619,7 +2620,7 @@ function Tabs({ items, value, onChange, label, unit, className }) {
|
|
|
2619
2620
|
className: "ui-tab-count",
|
|
2620
2621
|
children: [format.number(t.count), t.unit || unit ? /* @__PURE__ */ jsxs(Fragment, { children: [" ", /* @__PURE__ */ jsx("span", {
|
|
2621
2622
|
className: "ui-unit",
|
|
2622
|
-
children:
|
|
2623
|
+
children: unitFor(t.unit || unit, t.count)
|
|
2623
2624
|
})] }) : null]
|
|
2624
2625
|
}) : null
|
|
2625
2626
|
]
|
|
@@ -3529,6 +3530,7 @@ function DataTable(p) {
|
|
|
3529
3530
|
"aria-label": tr("檢視"),
|
|
3530
3531
|
children: p.views.map((v) => {
|
|
3531
3532
|
const on = v.id === view;
|
|
3533
|
+
const vn = rows.filter((r) => !v.filter || v.filter(r)).length;
|
|
3532
3534
|
return /* @__PURE__ */ jsxs("button", {
|
|
3533
3535
|
type: "button",
|
|
3534
3536
|
role: "tab",
|
|
@@ -3541,11 +3543,11 @@ function DataTable(p) {
|
|
|
3541
3543
|
children: [v.label, /* @__PURE__ */ jsxs("span", {
|
|
3542
3544
|
className: "ui-dt-view-n",
|
|
3543
3545
|
children: [
|
|
3544
|
-
format.number(
|
|
3546
|
+
format.number(vn),
|
|
3545
3547
|
" ",
|
|
3546
3548
|
/* @__PURE__ */ jsx("span", {
|
|
3547
3549
|
className: "ui-unit",
|
|
3548
|
-
children:
|
|
3550
|
+
children: unitFor("筆", vn)
|
|
3549
3551
|
})
|
|
3550
3552
|
]
|
|
3551
3553
|
})]
|
|
@@ -4501,7 +4503,7 @@ function Swatch({ type }) {
|
|
|
4501
4503
|
y1: 4,
|
|
4502
4504
|
x2: 28,
|
|
4503
4505
|
y2: 4,
|
|
4504
|
-
className: cx("ui-graph-edge", type === "inferred" && "is-inferred")
|
|
4506
|
+
className: cx("ui-graph-edge", type === "inferred" && "is-inferred", type === "declared" && "is-declared")
|
|
4505
4507
|
})
|
|
4506
4508
|
});
|
|
4507
4509
|
}
|
|
@@ -4646,7 +4648,7 @@ function wraps(text) {
|
|
|
4646
4648
|
for (const t of text.match(/`[^`]+`|[A-Za-z0-9_./:#@-]+|\s+|[\s\S]/gu) ?? []) {
|
|
4647
4649
|
const prev = atoms[atoms.length - 1];
|
|
4648
4650
|
const unit = /\d\s*$/.test(prev ?? "") && !/^[A-Za-z0-9_]/.test(t);
|
|
4649
|
-
if (prev != null && (unit || /^[)」』、,。:;!?)\]]/.test(t) || /[(「『([]$/.test(prev))) atoms[atoms.length - 1] = prev + t;
|
|
4651
|
+
if (prev != null && (unit || /^[)」』、,。:;!?)\],;!?]/.test(t) || /[(「『([]$/.test(prev))) atoms[atoms.length - 1] = prev + t;
|
|
4650
4652
|
else atoms.push(t);
|
|
4651
4653
|
}
|
|
4652
4654
|
const fill = (max) => {
|
|
@@ -4716,7 +4718,7 @@ const clean = (pts) => pts.filter((q, i) => {
|
|
|
4716
4718
|
});
|
|
4717
4719
|
/** Architecture as layers of boxes with arrows. Line width shows how often; inferred relations are dashed and labelled;
|
|
4718
4720
|
* shared items are listed under the diagram instead of drawn. Wider than its box: the boxes narrow (down to 120 px),
|
|
4719
|
-
* then the whole diagram scales down (to 0.75 at least); past that it scrolls sideways (PM). */
|
|
4721
|
+
* then the whole diagram scales down (to 0.75 at least); past that it scrolls sideways at full width (PM, WA). */
|
|
4720
4722
|
function LayerGraph(p) {
|
|
4721
4723
|
const [avail, setAvail] = React.useState(0);
|
|
4722
4724
|
const [fit, setFit] = React.useState(null);
|
|
@@ -4742,6 +4744,7 @@ function LayerGraph(p) {
|
|
|
4742
4744
|
const main = all.filter((n) => !n.shared);
|
|
4743
4745
|
const shared = all.filter((n) => n.shared);
|
|
4744
4746
|
const edges = p.edges.filter((e) => !sharedIds.has(e.from) && !sharedIds.has(e.to));
|
|
4747
|
+
const lab = (e) => !!(e.inferred || e.declared);
|
|
4745
4748
|
const byLayer = /* @__PURE__ */ new Map();
|
|
4746
4749
|
const EXTERNAL = Number.NEGATIVE_INFINITY;
|
|
4747
4750
|
for (const n of main) {
|
|
@@ -4872,12 +4875,13 @@ function LayerGraph(p) {
|
|
|
4872
4875
|
};
|
|
4873
4876
|
const midSentence = (t) => /^[A-Z][a-z]/.test(t) && !/^zh/i.test(format.locale()) ? t[0].toLowerCase() + t.slice(1) : t;
|
|
4874
4877
|
const sameLabel = /* @__PURE__ */ new Map();
|
|
4875
|
-
for (const e of edges) if (e
|
|
4878
|
+
for (const e of edges) if (lab(e) && e.label && pos[e.from] && pos[e.to]) sameLabel.set(e.label, (sameLabel.get(e.label) ?? 0) + 1);
|
|
4879
|
+
const kindWord = (e) => e.declared ? p.declaredLabel || tr("宣告") : p.inferredLabel || tr("推測");
|
|
4876
4880
|
const inferredText = (e) => e.label && (sameLabel.get(e.label) ?? 0) > 1 ? tr("來自 {from},{label}", {
|
|
4877
4881
|
from: nameOf(e.from),
|
|
4878
4882
|
label: midSentence(e.label)
|
|
4879
|
-
}) : e.label ||
|
|
4880
|
-
const markText = (e) => e
|
|
4883
|
+
}) : e.label || kindWord(e);
|
|
4884
|
+
const markText = (e) => lab(e) ? inferredText(e) : countText(e);
|
|
4881
4885
|
if (upsL.length) {
|
|
4882
4886
|
const left0 = Math.min(...main.map((n) => pos[n.id].x));
|
|
4883
4887
|
const shift = Math.max(0, PAD + (upsL.length - 1) * LANE_STEP + LANE - left0);
|
|
@@ -4905,7 +4909,7 @@ function LayerGraph(p) {
|
|
|
4905
4909
|
const laneCount = {};
|
|
4906
4910
|
{
|
|
4907
4911
|
const into = {};
|
|
4908
|
-
for (const e of edges) if (ins[e.to]?.includes(e) && (e
|
|
4912
|
+
for (const e of edges) if (ins[e.to]?.includes(e) && (lab(e) || related(e))) (into[e.to] ??= []).push(e);
|
|
4909
4913
|
for (const id in into) {
|
|
4910
4914
|
if (into[id].length < 2) continue;
|
|
4911
4915
|
laneGroups[id] = into[id].sort((a, b) => txOf(b) - txOf(a));
|
|
@@ -5172,7 +5176,7 @@ function LayerGraph(p) {
|
|
|
5172
5176
|
y0 - 3,
|
|
5173
5177
|
y0 + 3
|
|
5174
5178
|
]);
|
|
5175
|
-
if (e
|
|
5179
|
+
if (lab(e) || r) {
|
|
5176
5180
|
const text = markText(e);
|
|
5177
5181
|
marks.push({
|
|
5178
5182
|
idx,
|
|
@@ -5209,7 +5213,7 @@ function LayerGraph(p) {
|
|
|
5209
5213
|
f.y - 3,
|
|
5210
5214
|
f.y + 3
|
|
5211
5215
|
]);
|
|
5212
|
-
if (e
|
|
5216
|
+
if (lab(e) || r) {
|
|
5213
5217
|
const text = markText(e);
|
|
5214
5218
|
marks.push({
|
|
5215
5219
|
idx,
|
|
@@ -5259,7 +5263,7 @@ function LayerGraph(p) {
|
|
|
5259
5263
|
ty
|
|
5260
5264
|
]);
|
|
5261
5265
|
}
|
|
5262
|
-
const w = (e
|
|
5266
|
+
const w = (lab(e) ? 1.5 : 1.5 + 5.5 * ((e.count || 0) / maxCount)) + (picked ? 1.5 : 0) + (hovered ? 2 : 0);
|
|
5263
5267
|
const cpts = clean(pts);
|
|
5264
5268
|
ptsOf[idx] = cpts;
|
|
5265
5269
|
for (let k = 1; k < cpts.length; k++) {
|
|
@@ -5277,7 +5281,7 @@ function LayerGraph(p) {
|
|
|
5277
5281
|
}
|
|
5278
5282
|
const d = route(cpts, 10);
|
|
5279
5283
|
paths.push(/* @__PURE__ */ jsx("path", {
|
|
5280
|
-
className: cx("ui-lg-edge", e.inferred && "is-inferred", r && "is-related", dim && "is-dim", hovered && "is-hover"),
|
|
5284
|
+
className: cx("ui-lg-edge", e.declared ? "is-declared" : e.inferred && "is-inferred", r && "is-related", dim && "is-dim", hovered && "is-hover"),
|
|
5281
5285
|
d,
|
|
5282
5286
|
strokeWidth: w
|
|
5283
5287
|
}, "p" + idx));
|
|
@@ -5318,7 +5322,7 @@ function LayerGraph(p) {
|
|
|
5318
5322
|
className: cx("ui-lg-arrow", r && "is-related", dim && "is-dim"),
|
|
5319
5323
|
d: arrow
|
|
5320
5324
|
}, "a" + idx));
|
|
5321
|
-
if (!up && !isFlat(e) && (e
|
|
5325
|
+
if (!up && !isFlat(e) && (lab(e) || r)) {
|
|
5322
5326
|
const text = markText(e);
|
|
5323
5327
|
marks.push({
|
|
5324
5328
|
idx,
|
|
@@ -5380,9 +5384,9 @@ function LayerGraph(p) {
|
|
|
5380
5384
|
}
|
|
5381
5385
|
return null;
|
|
5382
5386
|
};
|
|
5383
|
-
const labelEl = (m, x0, top, lines = [m.text]) => /* @__PURE__ */ jsx("span", {
|
|
5387
|
+
const labelEl = (m, x0, top, lines = [m.text], over = false) => /* @__PURE__ */ jsx("span", {
|
|
5384
5388
|
"aria-hidden": pickEdge ? true : void 0,
|
|
5385
|
-
className: cx("ui-lg-label", pickEdge && "is-clickable", pickEdge && hover === edgeId(m.e) && "is-hover", m.r && "is-related", m.dim && "is-dim", peek && !m.r && hover !== edgeId(m.e) && m.e !== selEdge && "is-quiet"),
|
|
5389
|
+
className: cx("ui-lg-label", over && "is-over", pickEdge && "is-clickable", pickEdge && hover === edgeId(m.e) && "is-hover", m.r && "is-related", m.dim && "is-dim", peek && !m.r && hover !== edgeId(m.e) && m.e !== selEdge && "is-quiet"),
|
|
5386
5390
|
style: {
|
|
5387
5391
|
left: x0,
|
|
5388
5392
|
top
|
|
@@ -5395,7 +5399,8 @@ function LayerGraph(p) {
|
|
|
5395
5399
|
onPointerLeave: pickEdge ? () => setHover(null) : void 0,
|
|
5396
5400
|
children: lines.map((t, i) => /* @__PURE__ */ jsxs(React.Fragment, { children: [i ? /* @__PURE__ */ jsx("br", {}) : null, labelParts(t)] }, i))
|
|
5397
5401
|
}, "l" + m.idx);
|
|
5398
|
-
|
|
5402
|
+
const later = [];
|
|
5403
|
+
const place = (m, last) => {
|
|
5399
5404
|
const w = Math.ceil(labelWidth(m.text));
|
|
5400
5405
|
if (m.flat) {
|
|
5401
5406
|
let spot = alongLine(m);
|
|
@@ -5534,6 +5539,11 @@ function LayerGraph(p) {
|
|
|
5534
5539
|
if (spot) break;
|
|
5535
5540
|
}
|
|
5536
5541
|
if (!spot) spot = alongLine(m);
|
|
5542
|
+
if (!spot && !last) {
|
|
5543
|
+
later.push(m);
|
|
5544
|
+
return;
|
|
5545
|
+
}
|
|
5546
|
+
const over = !spot;
|
|
5537
5547
|
if (!spot) {
|
|
5538
5548
|
if (g >= 0) need.add(g);
|
|
5539
5549
|
covered++;
|
|
@@ -5577,14 +5587,16 @@ function LayerGraph(p) {
|
|
|
5577
5587
|
placed.push([
|
|
5578
5588
|
spot.x0,
|
|
5579
5589
|
spot.x0 + spot.lw,
|
|
5580
|
-
spot.top - spot.lh / 2 -
|
|
5581
|
-
spot.top + spot.lh / 2 +
|
|
5590
|
+
spot.top - spot.lh / 2 - 4,
|
|
5591
|
+
spot.top + spot.lh / 2 + 4,
|
|
5582
5592
|
6
|
|
5583
5593
|
]);
|
|
5584
5594
|
wide = Math.max(wide, spot.x0 + spot.lw + PAD / 2 + 4);
|
|
5585
5595
|
least = Math.min(least, spot.x0 - PAD / 2 - 4);
|
|
5586
|
-
labels.push(labelEl(m, spot.x0, spot.top, spot.lines));
|
|
5587
|
-
}
|
|
5596
|
+
labels.push(labelEl(m, spot.x0, spot.top, spot.lines, over));
|
|
5597
|
+
};
|
|
5598
|
+
marks.sort((m, n) => Number(!!m.up) - Number(!!n.up) || m.ty - n.ty || m.tx - n.tx).forEach((m) => place(m, false));
|
|
5599
|
+
later.forEach((m) => place(m, true));
|
|
5588
5600
|
return {
|
|
5589
5601
|
paths,
|
|
5590
5602
|
labels,
|
|
@@ -5700,10 +5712,10 @@ function LayerGraph(p) {
|
|
|
5700
5712
|
})]
|
|
5701
5713
|
}, s.id);
|
|
5702
5714
|
});
|
|
5703
|
-
const edgeText = (e) => e
|
|
5715
|
+
const edgeText = (e) => lab(e) ? e.label ? tr("{label}({inferred})", {
|
|
5704
5716
|
label: e.label,
|
|
5705
|
-
inferred:
|
|
5706
|
-
}) :
|
|
5717
|
+
inferred: kindWord(e)
|
|
5718
|
+
}) : kindWord(e) : countText(e);
|
|
5707
5719
|
const listItem = (key, on, dim, onClick, head, rest) => /* @__PURE__ */ jsxs("li", {
|
|
5708
5720
|
className: cx("ui-lg-li", dim && "is-dim"),
|
|
5709
5721
|
children: [onClick ? /* @__PURE__ */ jsx("button", {
|
|
@@ -5763,7 +5775,7 @@ function LayerGraph(p) {
|
|
|
5763
5775
|
})]
|
|
5764
5776
|
});
|
|
5765
5777
|
const showList = p.listView !== false && view === "list";
|
|
5766
|
-
const toggleShown = p.labelToggle !== false && !showList && p.edges.some((e) => e
|
|
5778
|
+
const toggleShown = p.labelToggle !== false && !showList && p.edges.some((e) => lab(e));
|
|
5767
5779
|
React.useLayoutEffect(() => {
|
|
5768
5780
|
const el = scrollRef.current;
|
|
5769
5781
|
if (!el) return;
|
|
@@ -5788,11 +5800,22 @@ function LayerGraph(p) {
|
|
|
5788
5800
|
});
|
|
5789
5801
|
return;
|
|
5790
5802
|
}
|
|
5791
|
-
if (fitted.
|
|
5792
|
-
const s = avail / W;
|
|
5793
|
-
if (s
|
|
5803
|
+
if (fitted.full) return;
|
|
5804
|
+
const s = Math.floor(avail / W * 1e3) / 1e3;
|
|
5805
|
+
if (W > avail + .5 && s < .75) {
|
|
5806
|
+
setFit({
|
|
5807
|
+
...fitted,
|
|
5808
|
+
nw: p.nodeWidth || 200,
|
|
5809
|
+
col: 40,
|
|
5810
|
+
scale: 1,
|
|
5811
|
+
full: true
|
|
5812
|
+
});
|
|
5813
|
+
return;
|
|
5814
|
+
}
|
|
5815
|
+
const want = W <= avail + .5 ? 1 : s;
|
|
5816
|
+
if (want !== fitted.scale) setFit({
|
|
5794
5817
|
...fitted,
|
|
5795
|
-
scale:
|
|
5818
|
+
scale: want
|
|
5796
5819
|
});
|
|
5797
5820
|
}, [
|
|
5798
5821
|
avail,
|
|
@@ -5906,14 +5929,22 @@ function LayerGraph(p) {
|
|
|
5906
5929
|
children: sharedBoxes
|
|
5907
5930
|
})]
|
|
5908
5931
|
}) : null,
|
|
5909
|
-
showList || p.legend === false || !p.legendItems && !edges.some((e) => pos[e.from] && pos[e.to]) ? null : /* @__PURE__ */ jsx(GraphLegend, { items: p.legendItems || [
|
|
5910
|
-
|
|
5911
|
-
|
|
5912
|
-
|
|
5913
|
-
|
|
5914
|
-
|
|
5915
|
-
|
|
5916
|
-
|
|
5932
|
+
showList || p.legend === false || !p.legendItems && !edges.some((e) => pos[e.from] && pos[e.to]) ? null : /* @__PURE__ */ jsx(GraphLegend, { items: p.legendItems || [
|
|
5933
|
+
...edges.some((e) => !lab(e) && pos[e.from] && pos[e.to]) ? [{
|
|
5934
|
+
type: "weight",
|
|
5935
|
+
label: "次數越多線越粗"
|
|
5936
|
+
}] : [],
|
|
5937
|
+
...edges.some((e) => e.inferred && !e.declared && pos[e.from] && pos[e.to]) ? [{
|
|
5938
|
+
type: "inferred",
|
|
5939
|
+
label: p.inferredLabel || "推測的關係",
|
|
5940
|
+
text: p.inferredText
|
|
5941
|
+
}] : [],
|
|
5942
|
+
...edges.some((e) => e.declared && pos[e.from] && pos[e.to]) ? [{
|
|
5943
|
+
type: "declared",
|
|
5944
|
+
label: p.declaredLegend || "專案宣告的關係",
|
|
5945
|
+
text: p.declaredText
|
|
5946
|
+
}] : []
|
|
5947
|
+
] })
|
|
5917
5948
|
]
|
|
5918
5949
|
});
|
|
5919
5950
|
}
|