@seanyeh77/ui 0.45.0 → 0.47.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.
Files changed (210) hide show
  1. package/dist/bundle.js +19 -19
  2. package/dist/components/Alert/Alert.d.ts +2 -1
  3. package/dist/components/Alert/Alert.js +15 -17
  4. package/dist/components/Alert/Alert.js.map +1 -1
  5. package/dist/components/AppShell/AppShell.d.ts +3 -3
  6. package/dist/components/AppShell/AppShell.js +9 -10
  7. package/dist/components/AppShell/AppShell.js.map +1 -1
  8. package/dist/components/Badge/Badge.d.ts +4 -4
  9. package/dist/components/Badge/Badge.js +7 -1
  10. package/dist/components/Badge/Badge.js.map +1 -1
  11. package/dist/components/Breadcrumb/Breadcrumb.js +1 -0
  12. package/dist/components/Breadcrumb/Breadcrumb.js.map +1 -1
  13. package/dist/components/Calendar/Calendar.js +6 -2
  14. package/dist/components/Calendar/Calendar.js.map +1 -1
  15. package/dist/components/ConsoleLayout/ConsoleLayout.js +15 -12
  16. package/dist/components/ConsoleLayout/ConsoleLayout.js.map +1 -1
  17. package/dist/components/DataTable/DataTable.d.ts +8 -0
  18. package/dist/components/DataTable/DataTable.js +188 -34
  19. package/dist/components/DataTable/DataTable.js.map +1 -1
  20. package/dist/components/DataTable/filters.js +10 -4
  21. package/dist/components/DataTable/filters.js.map +1 -1
  22. package/dist/components/DatePicker/DatePicker.js +1 -0
  23. package/dist/components/DatePicker/DatePicker.js.map +1 -1
  24. package/dist/components/DateRangePicker/DateRangePicker.js +1 -0
  25. package/dist/components/DateRangePicker/DateRangePicker.js.map +1 -1
  26. package/dist/components/DetailList/DetailList.d.ts +8 -1
  27. package/dist/components/DetailList/DetailList.js +16 -2
  28. package/dist/components/DetailList/DetailList.js.map +1 -1
  29. package/dist/components/EmptyState/EmptyState.js +19 -1
  30. package/dist/components/EmptyState/EmptyState.js.map +1 -1
  31. package/dist/components/EventTimeline/EventTimeline.js +6 -3
  32. package/dist/components/EventTimeline/EventTimeline.js.map +1 -1
  33. package/dist/components/FileUpload/FileUpload.js +2 -2
  34. package/dist/components/FileUpload/FileUpload.js.map +1 -1
  35. package/dist/components/Grid/Grid.d.ts +5 -2
  36. package/dist/components/Grid/Grid.js +4 -3
  37. package/dist/components/Grid/Grid.js.map +1 -1
  38. package/dist/components/InlineCode/InlineCode.js +7 -6
  39. package/dist/components/InlineCode/InlineCode.js.map +1 -1
  40. package/dist/components/KpiCard/KpiCard.d.ts +6 -4
  41. package/dist/components/KpiCard/KpiCard.js +6 -12
  42. package/dist/components/KpiCard/KpiCard.js.map +1 -1
  43. package/dist/components/LayerGraph/LayerGraph.js +47 -13
  44. package/dist/components/LayerGraph/LayerGraph.js.map +1 -1
  45. package/dist/components/MultiSelect/MultiSelect.js +73 -45
  46. package/dist/components/MultiSelect/MultiSelect.js.map +1 -1
  47. package/dist/components/NotificationBell/NotificationBell.d.ts +6 -3
  48. package/dist/components/NotificationBell/NotificationBell.js +14 -3
  49. package/dist/components/NotificationBell/NotificationBell.js.map +1 -1
  50. package/dist/components/PageHeader/PageHeader.d.ts +3 -2
  51. package/dist/components/PageHeader/PageHeader.js +10 -1
  52. package/dist/components/PageHeader/PageHeader.js.map +1 -1
  53. package/dist/components/RelativeTime/RelativeTime.js +4 -3
  54. package/dist/components/RelativeTime/RelativeTime.js.map +1 -1
  55. package/dist/components/Select/Select.js +1 -1
  56. package/dist/components/Select/Select.js.map +1 -1
  57. package/dist/components/SettingsLayout/SettingsLayout.d.ts +6 -4
  58. package/dist/components/SettingsLayout/SettingsLayout.js +38 -11
  59. package/dist/components/SettingsLayout/SettingsLayout.js.map +1 -1
  60. package/dist/components/SideNav/SideNav.d.ts +10 -5
  61. package/dist/components/SideNav/SideNav.js +10 -6
  62. package/dist/components/SideNav/SideNav.js.map +1 -1
  63. package/dist/components/SplitPane/SplitPane.d.ts +2 -2
  64. package/dist/components/SplitPane/SplitPane.js +29 -9
  65. package/dist/components/SplitPane/SplitPane.js.map +1 -1
  66. package/dist/components/TextField/TextField.d.ts +8 -2
  67. package/dist/components/TextField/TextField.js +59 -13
  68. package/dist/components/TextField/TextField.js.map +1 -1
  69. package/dist/components/TopBar/TopBar.d.ts +2 -2
  70. package/dist/components/TopBar/TopBar.js.map +1 -1
  71. package/dist/components/Workbench/Workbench.d.ts +8 -5
  72. package/dist/components/Workbench/Workbench.js +184 -157
  73. package/dist/components/Workbench/Workbench.js.map +1 -1
  74. package/dist/components/ZoneMap/ZoneMap.js +4 -4
  75. package/dist/components/ZoneMap/ZoneMap.js.map +1 -1
  76. package/dist/components/useFormErrors/useFormErrors.d.ts +5 -2
  77. package/dist/components/useFormErrors/useFormErrors.js +10 -4
  78. package/dist/components/useFormErrors/useFormErrors.js.map +1 -1
  79. package/dist/css/AccentPicker.css +19 -0
  80. package/dist/css/Alert.css +30 -7
  81. package/dist/css/AppShell.css +12 -0
  82. package/dist/css/Calendar.css +7 -0
  83. package/dist/css/ConsoleLayout.css +3 -0
  84. package/dist/css/DataTable.css +70 -8
  85. package/dist/css/DetailList.css +11 -0
  86. package/dist/css/EmptyState.css +8 -0
  87. package/dist/css/EventTimeline.css +11 -4
  88. package/dist/css/Grid.css +15 -0
  89. package/dist/css/KpiCard.css +1 -0
  90. package/dist/css/LayerGraph.css +1 -1
  91. package/dist/css/LoadingBar.css +4 -1
  92. package/dist/css/LoginCard.css +1 -1
  93. package/dist/css/MobileTabBar.css +6 -4
  94. package/dist/css/MultiSelect.css +23 -3
  95. package/dist/css/Select.css +9 -0
  96. package/dist/css/SettingsLayout.css +29 -14
  97. package/dist/css/Tabs.css +36 -17
  98. package/dist/css/Toast.css +7 -0
  99. package/dist/css/TopBar.css +6 -3
  100. package/dist/css/Workbench.css +10 -5
  101. package/dist/css/base.css +90 -3
  102. package/dist/css/end.css +5 -2
  103. package/dist/fonts-latin.css +2 -0
  104. package/dist/fonts-tc.css +2 -0
  105. package/dist/format.d.ts +4 -3
  106. package/dist/format.js +13 -12
  107. package/dist/format.js.map +1 -1
  108. package/dist/i18n.js +17 -6
  109. package/dist/i18n.js.map +1 -1
  110. package/dist/icons/Icon.d.ts +2 -1
  111. package/dist/icons/Icon.js +4 -3
  112. package/dist/icons/Icon.js.map +1 -1
  113. package/dist/icons/all.js +23 -1
  114. package/dist/icons/all.js.map +1 -1
  115. package/dist/icons/names.d.ts +22 -0
  116. package/dist/icons/names.js +11 -0
  117. package/dist/icons/names.js.map +1 -1
  118. package/dist/icons/ph/credit-card.d.ts +10 -0
  119. package/dist/icons/ph/credit-card.js +11 -0
  120. package/dist/icons/ph/credit-card.js.map +1 -0
  121. package/dist/icons/ph/map-pin.d.ts +10 -0
  122. package/dist/icons/ph/map-pin.js +11 -0
  123. package/dist/icons/ph/map-pin.js.map +1 -0
  124. package/dist/icons/ph/package.d.ts +10 -0
  125. package/dist/icons/ph/package.js +11 -0
  126. package/dist/icons/ph/package.js.map +1 -0
  127. package/dist/icons/ph/pause.d.ts +10 -0
  128. package/dist/icons/ph/pause.js +11 -0
  129. package/dist/icons/ph/pause.js.map +1 -0
  130. package/dist/icons/ph/phone.d.ts +10 -0
  131. package/dist/icons/ph/phone.js +11 -0
  132. package/dist/icons/ph/phone.js.map +1 -0
  133. package/dist/icons/ph/play.d.ts +10 -0
  134. package/dist/icons/ph/play.js +11 -0
  135. package/dist/icons/ph/play.js.map +1 -0
  136. package/dist/icons/ph/prohibit.d.ts +10 -0
  137. package/dist/icons/ph/prohibit.js +11 -0
  138. package/dist/icons/ph/prohibit.js.map +1 -0
  139. package/dist/icons/ph/receipt.d.ts +10 -0
  140. package/dist/icons/ph/receipt.js +11 -0
  141. package/dist/icons/ph/receipt.js.map +1 -0
  142. package/dist/icons/ph/shopping-cart.d.ts +10 -0
  143. package/dist/icons/ph/shopping-cart.js +11 -0
  144. package/dist/icons/ph/shopping-cart.js.map +1 -0
  145. package/dist/icons/ph/storefront.d.ts +10 -0
  146. package/dist/icons/ph/storefront.js +11 -0
  147. package/dist/icons/ph/storefront.js.map +1 -0
  148. package/dist/icons/ph/truck.d.ts +10 -0
  149. package/dist/icons/ph/truck.js +11 -0
  150. package/dist/icons/ph/truck.js.map +1 -0
  151. package/dist/icons/store.d.ts +3 -1
  152. package/dist/icons/store.js +17 -12
  153. package/dist/icons/store.js.map +1 -1
  154. package/dist/index.d.ts +2 -2
  155. package/dist/index.js +2 -2
  156. package/dist/internal/FloatingPanel.js +5 -2
  157. package/dist/internal/FloatingPanel.js.map +1 -1
  158. package/dist/internal/clickSteps.js +11 -0
  159. package/dist/internal/clickSteps.js.map +1 -0
  160. package/dist/internal/util.js +7 -1
  161. package/dist/internal/util.js.map +1 -1
  162. package/dist/styles.css +499 -162
  163. package/dist/theme.d.ts +7 -0
  164. package/dist/theme.js +39 -15
  165. package/dist/theme.js.map +1 -1
  166. package/docs/Alert.md +1 -1
  167. package/docs/AppShell.md +4 -4
  168. package/docs/Badge.md +2 -1
  169. package/docs/BarChart.md +1 -1
  170. package/docs/Checkbox.md +2 -2
  171. package/docs/CodeView.md +12 -22
  172. package/docs/ConsoleLayout.md +1 -0
  173. package/docs/DataTable.md +16 -11
  174. package/docs/DatePicker.md +1 -1
  175. package/docs/DateRangePicker.md +1 -0
  176. package/docs/DetailList.md +12 -1
  177. package/docs/Drawer.md +1 -1
  178. package/docs/EmptyState.md +1 -0
  179. package/docs/EventTimeline.md +1 -1
  180. package/docs/Format.md +2 -1
  181. package/docs/Graph.md +1 -0
  182. package/docs/Grid.md +9 -0
  183. package/docs/KpiCard.md +5 -4
  184. package/docs/LoadingBar.md +1 -1
  185. package/docs/LoginCard.md +1 -1
  186. package/docs/Markdown.md +4 -37
  187. package/docs/MobileTabBar.md +1 -1
  188. package/docs/MultiSelect.md +3 -2
  189. package/docs/NotificationBell.md +2 -2
  190. package/docs/PageHeader.md +2 -1
  191. package/docs/RadioGroup.md +1 -1
  192. package/docs/RelativeTime.md +2 -2
  193. package/docs/SettingsLayout.md +5 -4
  194. package/docs/SideNav.md +2 -1
  195. package/docs/Skeleton.md +2 -2
  196. package/docs/SplitPane.md +3 -9
  197. package/docs/Tabs.md +14 -11
  198. package/docs/Tag.md +4 -3
  199. package/docs/TextField.md +2 -0
  200. package/docs/Toast.md +1 -1
  201. package/docs/TopBar.md +2 -2
  202. package/docs/Workbench.md +9 -6
  203. package/docs/agents.md +13 -13
  204. package/docs/data.md +2 -1
  205. package/docs/guidelines.md +4 -4
  206. package/docs/icons.md +2 -2
  207. package/docs/layout.md +3 -3
  208. package/docs/theme.md +6 -3
  209. package/docs/useFormErrors.md +2 -1
  210. package/package.json +4 -2
@@ -10,4 +10,4 @@
10
10
 
11
11
  - 高度 8 px,和進度條相同的軌道。
12
12
  - 一段強調色流過去:前端先衝、後端跟上,所以中間會拉長,和導覽的水滴動畫一致。
13
- - 減少動態效果時改成靜止的半透明條。
13
+ - 減少動態效果時改成靜止、跨滿軌道的強調色斜紋(和軌道至少 3:1),看起來是「處理中」,不像完成了某個比例。
package/docs/LoginCard.md CHANGED
@@ -22,7 +22,7 @@
22
22
 
23
23
  ## 細節
24
24
 
25
- - 整頁是 `<main>`,最小高度 100dvh,卡片上下左右置中;深色主題下卡片(`surface`)比頁面(`bg`)亮,層次和淺色一致。
25
+ - 整頁是 `<main>`,最小高度 100dvh,卡片上下左右置中;卡片和其他卡片一樣只用陰影、沒有外框;深色主題下卡片(`surface`)比頁面(`bg`)亮,層次和淺色一致。
26
26
  - 密碼欄右邊有眼睛按鈕「顯示密碼」,名稱不變,只用 `aria-pressed` 表示是否已顯示。
27
27
  - `loading` 時登入按鈕轉圈、按了不送出,焦點留在按鈕上。
28
28
  - 按 Enter 也會送出。
package/docs/Markdown.md CHANGED
@@ -49,13 +49,7 @@ h(
49
49
  - 沒有給 `linkHref` 時連結照原網址;外部網址在新分頁開啟。
50
50
  - 自訂 scheme:`schemes={['fn']}` 之後,`[_sync_as](fn:harness/controller.py:VirtualRouter._sync_as)` 原樣交給 `linkHref` 與 `onLink`;`linkHref` 沒有回傳網址、也沒有 `onLink` 時只顯示文字。
51
51
 
52
- ### 名稱與位置的外觀
53
-
54
- 原文不用改,Markdown 自動判斷:
55
-
56
- - 連結的文字只有一段行內程式碼(``[`VirtualRouter._sync_as`](fn:…)``)時是「名稱」:強調文字色的等寬字,沒有底色,滑過或焦點時才有底線(`InlineCode look="name"`)。
57
- - 行內程式碼被 `refHref` 或 `onRef` 認成路徑、而且有目標時是「位置」:灰色、13 px,滑過或焦點時變強調文字色加底線(`InlineCode look="location"`)。
58
- - 其他連結(`[說明](fn:docs)`、一般網址)照舊;沒有目標的行內程式碼維持灰底。外部網址在新分頁開啟的連結(沒有 `onLink`)也照舊。
52
+ 連結文字只有一段行內程式碼時顯示成「名稱」,被 `refHref`/`onRef` 認成路徑的行內程式碼顯示成「位置」,原文不用改。
59
53
 
60
54
  ## 名詞說明(terms)
61
55
 
@@ -77,7 +71,7 @@ h(UI.Markdown, {
77
71
 
78
72
  ## AI 標記
79
73
 
80
- AI 寫的段落、清單項目或表格格子寫 `[AI](ai:)`(開頭或結尾都可以),在那一段的最後畫成灰色小字「AI 撰寫」(`UI.AiMark`):13 px、`ink-muted`,和前面的文字隔 8 px。`[推測](ai:)` 用同樣的樣子顯示「推測」。
74
+ AI 寫的段落、清單項目或表格格子寫 `[AI](ai:)`(開頭或結尾都可以),在那一段的最後畫成灰色小字「AI 撰寫」(`UI.AiMark`)。`[推測](ai:)` 用同樣的樣子顯示「推測」。
81
75
 
82
76
  ```md
83
77
  這個函式在每次路由表變動時重新建立連線,所以第 540 行的呼叫次數會隨鄰居數增加。[AI](ai:)
@@ -87,6 +81,7 @@ AI 寫的段落、清單項目或表格格子寫 `[AI](ai:)`(開頭或結尾
87
81
  ```
88
82
 
89
83
  - 不是連結,Tab 不會停在上面;螢幕閱讀器在句子後面念「(AI 撰寫)」。
84
+
90
85
  ## inline
91
86
 
92
87
  只渲染行內語法、不產生段落,給一行摘要用,例如 README 的第一句:
@@ -112,7 +107,6 @@ CodeView 不內建預覽:由使用的地方放一個 `SegmentedControl`(「
112
107
  | Section 裡(Section 標題是 h3) | `#` | 4 | `#` 是 h4 |
113
108
  | Section 裡,原文從 `###` 開始寫 | `###` | 2 | `###` 是 h4 |
114
109
 
115
- - 大小跟著層級:h4 20 px,h5、h6 16 px 粗體。在 Section 裡,h4 改成 16 px 粗體,不比 Section 的 20 px 標題大。
116
110
 
117
111
  ## 範例:用 Markdown 顯示一份結構化報告
118
112
 
@@ -154,33 +148,6 @@ h(
154
148
 
155
149
  畫面就是這份文字;「複製成 Markdown」直接複製 `report`,貼到 GitHub 或 Notion 時表格、收合區塊、提示框都還在。
156
150
 
157
- ## 範例:Section 裡放 Markdown
158
-
159
- ```js
160
- h(
161
- UI.SectionGroup,
162
- null,
163
- h(
164
- UI.Section,
165
- {
166
- id: 'external',
167
- title: '外部指令',
168
- summary: '29 個指令、4 個 namespace、3 個沒有逾時',
169
- defaultOpen: true,
170
- actions: h(UI.IconButton, {
171
- icon: 'copy',
172
- label: '複製這一段',
173
- onClick: function () {
174
- navigator.clipboard.writeText(report);
175
- },
176
- }),
177
- },
178
- h(UI.Markdown, { topLevel: 2, schemes: ['fn'], linkHref: linkHref, refHref: refHref }, report),
179
- ),
180
- );
181
- ```
182
-
183
- - `report` 從 `###` 開始寫,所以 `topLevel: 2`,`###` 成為 h4,在 Section 的 h3 標題底下。
184
- - 「複製這一段」放在 Section 的 `actions`,點它不會開合段落。
151
+ 放在 Section 裡時,`report` 從 `###` 開始寫就給 `topLevel: 2`(`###` 成為 h4,在 Section 的 h3 標題底下);「複製這一段」放在 Section 的 `actions`,點它不會開合段落。
185
152
 
186
153
  外觀、鍵盤與無障礙的完整規格在 repo 的 `docs/maintaining/Markdown.md`。
@@ -22,4 +22,4 @@
22
22
  ## 細節
23
23
 
24
24
  - 選中:圖示後方一塊 `accent-soft` 圓角矩形(`radius-md`),圖示變 `accent-text`。
25
- - 切換動畫:水滴膠囊,和 Tabs 相同的拉伸方式(前端 120 ms、後端 440 ms)。
25
+ - 切換動畫:水滴膠囊,和 Tabs 相同的拉伸方式(前端 120 ms、後端 440 ms)。選中的膠囊 28 px 高,上下置中在圖示上,和下方文字之間留空。
@@ -10,11 +10,12 @@
10
10
 
11
11
  - 能不能新增依情況決定:名稱、標籤這類使用者可以自由增加的才開 `creatable`;選項固定、使用者不該自己加的(例如狀態、權限)不要開。
12
12
  - 框內顯示前 2 個標籤,其餘寫成「+n」(滑過可看全部,螢幕閱讀器念「另外 n 個:…」加上名稱);`maxChips` 可以改數量。
13
- - 和其他欄位一樣有 `hint`、`required`、`disabled`、`name`;`label` 必填。
13
+ - 和其他欄位一樣 40 px 高(手機 48 px),有 `hint`、`required`、`disabled`、`name`;`label` 必填。
14
+ - 移除:每個標籤的 ×、Backspace 移除最後一個,選了 2 個以上時框的右端有「清除」移除全部(Tab 可以移到,Enter 清除);移除後念出「已移除 …」或「已清除…」。Esc 只關閉選單,選單沒開時交給外層(關閉 Drawer 或 Dialog),不會清掉已選的值。
14
15
  - 有錯誤時給 `error`:紅框、框內右側的警告圖示,下方寫錯誤,出現時念一次。
15
16
 
16
17
  ## 細節
17
18
 
18
19
  - 輸入文字篩選選單;選單裡每個選項前面有勾選框。
19
20
  - `creatable` 時,輸入清單裡沒有的名字會出現「新增「…」」,也可以按 Enter;不能新增時顯示「找不到符合的選項」。
20
- - Backspace 移除最後一個標籤,Esc 關閉選單。
21
+ - 選單打開時 Esc 關閉選單;選單沒開、框裡有輸入的字時 Esc 清掉輸入的字。
@@ -5,12 +5,12 @@
5
5
  頂部列的通知鈴鐺與通知中心,放在 AppShell 或 TopBar 的右側。
6
6
 
7
7
  ```tsx
8
- <AppShell actions={<NotificationBell items={notifications} onOpen={open} onReadAll={readAll} />} …>
8
+ <AppShell actions={<NotificationBell items={notifications} onSelect={go} onReadAll={readAll} />} …>
9
9
  ```
10
10
 
11
11
  - 鈴鐺上有紅色數字角標(`danger`),超過 99 顯示 99+;沒有未讀時不顯示。
12
12
  - 通知依時間分組(`group`,例如「今天」、「更早」),由新到舊。
13
- - 點一則通知交給 `onOpen` 處理(通常是標成已讀並前往)。
13
+ - 點一則通知交給 `onSelect(item)` 處理(通常是標成已讀並前往),面板隨即關閉。面板的開關照慣例是 `open`、`defaultOpen`、`onOpenChange`;舊的 `onOpen` 仍可用(等於 `onSelect`),開發時 console 提醒改名。
14
14
 
15
15
  ## 細節
16
16
 
@@ -11,7 +11,7 @@
11
11
  <PageHeader
12
12
  title="訂單 #1024"
13
13
  status={<Badge status="doing">出貨中</Badge>}
14
- meta="建立於 2026/11/04(三)· 負責人 王小明"
14
+ meta={['建立於 2026/11/04(三)', '負責人 王小明']}
15
15
  primary={{ label: '出貨', onClick: ship }}
16
16
  actions={[{ label: '編輯', icon: 'pencil-simple', onClick: edit }]}
17
17
  more={[{ label: '刪除', icon: 'trash', danger: true, confirm: { title: '刪除訂單 #1024?' }, onSelect: remove }]}
@@ -25,6 +25,7 @@
25
25
  - 操作:`primary` 最多一個實心按鈕;`actions` 是外框按鈕,最多 3 個;其他和危險操作放 `more`(「⋯」選單,危險項目會先確認)。
26
26
  - 手機(小於 600 px):只有 `primary` 保持按鈕,`actions` 收進「⋯」。
27
27
  - `status` 放 Badge,和 `meta` 在標題下同一行、同一個字級。
28
+ - `meta` 給陣列時以「 · 」連起來,全形「)」後面不加空格(「(三)· 負責人」);給字串時也照這個規則調整,日期的「)」和時間之間不留空格(「(三)13:00」)。
28
29
 
29
30
  ## 細節
30
31
 
@@ -19,7 +19,7 @@
19
19
  - `label` 或 `aria-label` 一定要有一個(型別檢查);`label` 顯示在選項上方並當作群組名稱。
20
20
  - 受控用 `value` 加 `onChange(value, event)`;非受控用 `defaultValue`。給 `name` 時選中的值隨表單送出。
21
21
  - 選中時外圈變 `accent`,中間出現 10 px 圓點(彈出動畫)。
22
- - 整列可點,高度 40 px。
22
+ - 圓圈加文字可點,寬度只到文字結束,焦點外框也只包住它們;高度 40 px。
23
23
 
24
24
  ## 細節
25
25
 
@@ -10,9 +10,9 @@
10
10
  ```
11
11
 
12
12
  - 輸出 `<time datetime="…">`,`datetime` 是完整的時間(ISO 8601),螢幕閱讀器和複製都拿得到精確時間。
13
- - 規則和 `format.relative` 一樣:1 小時內寫分鐘;同一天寫小時;跨過午夜以日曆天計算,昨天任何時間都是「昨天」;7 個日曆天以上或未來的時間寫完整日期時間。
13
+ - 規則和 `format.relative` 一樣:1 小時內寫分鐘;同一天寫小時;跨過午夜以日曆天計算,昨天任何時間都是「昨天」;7 個日曆天以上或超過 60 s 以後的時間寫完整日期時間,60 s 以內的未來時間寫「現在」。
14
14
  - 需要完整日期時間的提示時,自己包 `Tooltip`,內容用 `format.dateTime(d)`。
15
- - 伺服器先渲染時,瀏覽器接手後會依自己的時鐘重新顯示一次,不會出現 hydration 警告。
15
+ - 伺服器渲染(SSR)時先輸出完整日期時間(不受伺服器時鐘影響),瀏覽器接手後立刻換成依自己時鐘算的相對時間,不會出現 hydration 警告,也不會停在伺服器算的字。
16
16
 
17
17
  ## Props
18
18
 
@@ -24,15 +24,16 @@
24
24
  ```
25
25
 
26
26
  - 每個分類的內容用 `SettingsSection` 分成卡片;SettingsSection 本身就是卡片,不再包 Card。
27
- - 開關用 `SettingsRow`:左邊名稱和一句說明,右邊 Switch,整列是 `<label>`,點文字也會切換。Switch 的 `label` 和 SettingsRow 的 `label` 寫同一句。
28
- - 什麼時候儲存:開關和選單改了就存;文字欄位離開欄位(blur)且驗證通過才存,不是每打一個字就存。存好後呼叫 `toast('已儲存', { id: 'saved' })`,連續修改時同一則重新計時;AppShell 裡不用另外放 `<Toaster />`;不用 `toast` prop(deprecated)。
27
+ - 開關用 `SettingsRow`:左邊名稱和一句說明,右邊 Switch,整列是 `<label>`,點文字也會切換。Switch 的 `label` 和 SettingsRow 的 `label` 寫同一句。SettingsRow 裡不放按鈕(點整列都會按到它);整個區塊的操作(「還原預設」)給 SettingsSection 的 `actions`,用 `quiet` 按鈕,在標題列右端。
28
+ - 什麼時候儲存:開關和選單改了就存;文字欄位離開欄位(blur)且驗證通過才存,不是每打一個字就存:用 `useFormErrors`,`onBlur={() => form.onBlur('name') && save()}`(`onBlur` 回傳欄位是否正確)。存好後呼叫 `toast('已儲存', { id: 'saved' })`,連續修改時同一則重新計時;AppShell 裡不用另外放 `<Toaster />`;不用 `toast` prop(deprecated)。
29
29
  - 刪除帳號這類操作放在最後一個分類的最下方,用 `DangerZone`,按下後先跳確認對話框。
30
30
  - 主題與強調色放在「外觀」分類(ThemePicker、AccentPicker)。
31
+ - 網址:選中的分類寫進 hash(`#settings-notifications`),重新整理或分享連結時打開同一個分類。用 hash 當路由的 SPA(網址是 `#/settings`)會自動不寫;其他情況要關掉給 `urlSync={false}`,由外部控制時給 `value` 和 `onChange`。
31
32
 
32
33
  ## 細節
33
34
 
34
- - 分類清單 180 px,選中的分類有左側強調色指示條;手機寬度時改成上方橫向分類,內容的卡片撐滿寬度。
35
+ - 分類清單 180 px,選中的分類有左側強調色指示條;手機寬度時改成上方的 `Tabs`(和其他分頁同一個樣式,放不下時左右捲動),內容的卡片撐滿寬度。
35
36
  - 內容最寬 760 px(欄位不會拉到 1000 px 寬),卡片之間 32 px(`space-8`)。
36
- - 選中的分類寫進網址的 hash(`#notifications`),重新整理或分享連結時打開同一個分類;`urlSync={false}` 關掉。給了 `value`(由外部控制)時不改網址。
37
+ - hash 也讀沒有前綴的寫法(`#notifications`)。給了 `value`(由外部控制)時不改網址。
37
38
  - 換分類時螢幕閱讀器念出分類名稱(`announce`)。
38
39
  - SettingsSection 標題 17 px(`text-title`),和 Card 標題相同。
package/docs/SideNav.md CHANGED
@@ -16,6 +16,7 @@ Dashboard 類頁面的左側導覽,可以收合。AppShell 已經內建(側
16
16
  - 品牌傳 `{ mark, name, href }`;只有文字時用第一個字放在強調色方塊裡當 logo。
17
17
  - 選中:左側 3 px 強調色指示條,用水滴方式移動到新項目。
18
18
  - 有子項目的父項目:收合時點了直接進第一個子頁面,頁面內再切換其他子頁面(例如用 Tabs)。
19
+ - 收合和釘選照受控慣例:`collapsed` 加 `onCollapsedChange(collapsed)`(給了才有收合按鈕),`pinned` 加 `onPinnedChange(pinned)`(給了才有圖釘按鈕)。舊的 `onToggle`、`onPin` 仍可用,開發時 console 提醒改名。
19
20
 
20
21
  ## 細節
21
22
 
@@ -25,7 +26,7 @@ Dashboard 類頁面的左側導覽,可以收合。AppShell 已經內建(側
25
26
  - 選中:左側 3 px 強調色指示條,用水滴方式移動到新項目;文字變粗、圖示變 `accent-text`。
26
27
  - 子選單:點父項目展開,子項目縮排;收起時選中的子項目會標在父項目上。收合時,有子項目的父項目點了直接進第一個子頁面,頁面內再切換其他子頁面(例如用 Tabs)。
27
28
  - 收合按鈕在左下角,只有圖示、沒有文字。收合後只剩圖示,滑過顯示名稱提示。
28
- - 圖釘按鈕(`onPin`、`pinned`):也在左下角、收合按鈕左邊,240 px 時兩個並排,72 px 時上下排。沒有釘選時是線條圖示「釘選側邊欄」,釘選時是實心強調色「取消釘選」(`aria-pressed`)。AppShell 用它切換自動展開與釘選;單獨使用 SideNav 時通常不需要。
29
+ - 圖釘按鈕(`pinned`、`onPinnedChange`):也在左下角、收合按鈕左邊,240 px 時兩個並排,72 px 時上下排。沒有釘選時是線條圖示「釘選側邊欄」,釘選時是實心強調色「取消釘選」(`aria-pressed`)。AppShell 用它切換自動展開與釘選;單獨使用 SideNav 時通常不需要。
29
30
  - 圖釘和收合按鈕滑過或 focus 時,右側出現 Tooltip 寫出動作名稱;Focus 時有 2 px `focus` 外框。
30
31
  - `label` 是導覽的 `aria-label`,預設「主要導覽」。
31
32
 
package/docs/Skeleton.md CHANGED
@@ -2,10 +2,10 @@
2
2
 
3
3
  ## 用法
4
4
 
5
- 資料載入中時顯示的骨架,用 `line` 色的條(在 `surface` 上約 1.33:1,淺色和深色都看得見)。不知道要多久的整頁工作用 LoadingBar。
5
+ 資料載入中時顯示的骨架,用 `line` 色的條(在 `surface` 上約 1.33:1,淺色和深色都看得見)。表格不用它,給 DataTable `loading`;不知道要多久的整頁工作用 LoadingBar。
6
6
 
7
7
  ```tsx
8
- {loading ? <Skeleton height={48} /> : <DataTable … />}
8
+ {chart ? <LineChart … /> : <Skeleton height={240} />}
9
9
  ```
10
10
 
11
11
  - 開始載入就立即顯示(延遲 0 ms)。
package/docs/SplitPane.md CHANGED
@@ -5,14 +5,7 @@
5
5
  主要區域和側邊面板並排,中間的分隔線可以拖拉,調整面板寬度。用在需要看長內容的面板,例如程式碼、詳細資料。
6
6
 
7
7
  ```tsx
8
- <SplitPane
9
- a={<Card title="架構">…</Card>}
10
- b={<CodeView file="src/server/shm.c" code={code} />}
11
- defaultB={420}
12
- minA={360}
13
- minB={280}
14
- storageKey="code-panel"
15
- />
8
+ <SplitPane a={<Card title="架構">…</Card>} b={<CodeView file="src/server/shm.c" code={code} />} defaultB={420} minA={360} minB={280} storageKey="code-panel" />
16
9
  ```
17
10
 
18
11
  - `a` 是主要區域(左),`b` 是側邊面板(右);`defaultB`(px,預設 420)是面板一開始的寬度。
@@ -29,7 +22,8 @@
29
22
  ## 操作
30
23
 
31
24
  - 滑鼠或觸控:按住分隔線左右拖拉。拖拉時游標是左右箭頭,頁面上的文字不會被選到。
32
- - 雙擊分隔線:回到 `defaultB`。
25
+ - 不拖曳也能調整(單一指標,WCAG 2.5.7):點一下分隔線,面板依序變成最窄(`minB`)、預設(`defaultB`)、預設的 1.5 倍,再回到最窄;每次念出新的寬度。移動不到 4 px 算點一下。
26
+ - 雙擊分隔線:回到 `defaultB`。操作方式寫在分隔線的 `aria-description`。
33
27
  - 鍵盤:Tab 移到分隔線,← → 每次 16 px(← 讓面板變寬),Home 讓面板最寬(主要區域剩最小寬度),End 讓面板最窄,Enter 回到 `defaultB`。按住 Alt、⌘ 或 Ctrl 時不處理。
34
28
  - 每次改變後呼叫 `onResize(寬度)`。
35
29
 
package/docs/Tabs.md CHANGED
@@ -2,32 +2,35 @@
2
2
 
3
3
  ## 用法
4
4
 
5
- 分頁:同一頁裡切換內容不同的幾個檢視。同一份內容的兩三種顯示方式(預覽/原始碼)用 SegmentedControl;結果清單的狀態摘要用 DataTable 的 `summary`。
5
+ 分頁:同一頁裡切換內容不同的幾個檢視。同一份內容的兩三種顯示方式(圖/清單、預覽/原始碼)用 SegmentedControl;帶筆數的篩選摘要(全部/錯誤/要確認)一律用 DataTable 的 `summary`,不用 Tabs。
6
6
 
7
7
  ```tsx
8
8
  <Tabs
9
- label="部署紀錄"
10
- unit="筆"
9
+ label="專案"
11
10
  value={tab}
12
11
  onChange={setTab}
13
12
  items={[
14
- { id: 'all', label: '全部', count: 26 },
15
- { id: 'failed', label: '失敗', count: 3 },
13
+ { id: 'overview', label: '總覽' },
14
+ { id: 'files', label: '檔案', count: 12, unit: '個' },
15
+ { id: 'comments', label: '留言', count: 6, unit: '則' },
16
16
  ]}
17
17
  />
18
18
  ```
19
19
 
20
- - 有 `count` 時後面一定帶單位:`unit` 給整排,某一項不同時在那一項給 `unit`。單位寫出來只是雜訊時(整排都是同一個單位的狀態摘要),加 `hideUnit`:畫面上只寫數字,螢幕閱讀器仍念單位。有 `count` 沒有單位時,開發模式會在主控台提醒。
20
+ - 有 `count` 時後面一定帶單位:`unit` 給整排,某一項不同時在那一項給 `unit`。有 `count` 沒有單位時,開發模式會在主控台提醒。
21
+ - 基準線一律跨滿容器的寬度;下面的內容從基準線下 `space-4`(16 px)開始。
22
+ - 外觀和 SegmentedControl 刻意不同:分頁是文字加底線(換內容),分段控制是灰底上的白塊(換顯示方式);不要用 CSS 把其中一個改成另一個的樣子。
21
23
  - 分頁的字一律不換行;整排比外框寬時改成左右捲動。
22
24
  - 內容切換:新內容的卡片依序浮起(外層加 `ui-rise-in`,並在切換時換 `key` 重新掛載)。
23
25
 
24
26
  ## 細節
25
27
 
26
- - `count` 顯示在名稱右邊:一般字體的等寬數字、14 px、次要文字色、一般字重,選中時也一樣,讓名稱是主角。`hideUnit`:畫面上只寫數字,單位只給螢幕閱讀器和切換時的朗讀,給整排同一個單位的狀態摘要用(DataTable 的 `summary` 用這個,畫面上是「全部 6 · 錯誤 4 · 要確認 2」,念成「全部 6 筆」)。`unit` 也可以傳函式,拿到數字後回傳單位,給有單複數的語言用:`unit: (n) => (n === 1 ? 'item' : 'items')`;傳字串時,數字是 1 而且語言有「1 <單位>」的翻譯(例如 `addMessages('en', { '1 項': '1 item' })`),就用那個。
27
- - 手機上當作摘要使用時,各項平均分配寬度,不換行。
28
- - 左右捲動時選中的底塊跟著捲,分頁不會互相重疊。還有分頁的那一側邊緣淡出(40 px),看得出可以往那邊捲;選中的分頁自動捲進畫面。
29
- - 整排高 40 px(分頁 32 px 加上下各 4 px,和 DataTable 的摘要分段相同),和工具列上的按鈕、搜尋框一樣高。
30
- - `surface-sub` 灰底軌道,選中的是浮起的 `surface` 白塊,加 1 px `line-strong` 框(白對灰只有約 1.1:1,框讓選中處達到 3:1),圓角 `radius-md` 10 px。
28
+ - `count` 顯示在名稱右邊:一般字體的等寬數字、14 px、次要文字色、一般字重,選中時也一樣,讓名稱是主角。`hideUnit`:畫面上只寫數字,單位只給螢幕閱讀器和切換時的朗讀;DataTable 的 `summary` 用這個(畫面上是「全部 6 · 錯誤 4 · 要確認 2」,念成「全部 6 筆」)。`unit` 也可以傳函式,拿到數字後回傳單位,給有單複數的語言用:`unit: (n) => (n === 1 ? 'item' : 'items')`;傳字串時,數字是 1 而且語言有「1 <單位>」的翻譯(例如 `addMessages('en', { '1 項': '1 item' })`),就用那個。
29
+ - DataTable 的 `summary` 在手機上各項平均分配寬度,不換行。
30
+ - 左右捲動時選中的底線跟著捲,分頁不會互相重疊。還有分頁的那一側邊緣淡出(40 px),看得出可以往那邊捲;選中的分頁自動捲進畫面。
31
+ - 整排高 40 px(手機 48 px,觸控目標),和工具列上的按鈕、搜尋框一樣高;沒有底色,下緣一條 1 px `line` 基準線。強制色彩模式(Windows 高對比)下,底線是 `Highlight`、基準線是 `CanvasText` 的框線。
32
+ - 選中的分頁:字變 `ink`、粗體,下方 2 px `accent-text` 底線(任何強調色都至少 3:1),換分頁時底線用水滴動畫滑過去;其他分頁 `ink-muted`,滑過時變 `ink`。
33
+ - DataTable 的 `summary` 例外:保留分段控制的樣子(`surface-sub` 灰底軌道、選中的 `surface` 白塊加 1 px `line-strong` 框),這是使用者為狀態摘要選的外觀。
31
34
  - 切換動畫:水滴。靠近目標的一端先移動(120 ms),另一端慢 2.2 倍才跟上(440 ms),移動中略為變細,到位後恢復;全程是同一塊,邊緣清晰。
32
35
 
33
36
  ## 無障礙
package/docs/Tag.md CHANGED
@@ -10,15 +10,16 @@
10
10
  <Tag icon="info">示範資料</Tag>
11
11
  ```
12
12
 
13
- - 只有小字:12 px、粗體、`ink-muted`,沒有框也沒有底色;一律灰色,不用顏色區分類別。
13
+ - 沒有 `icon`:12 px、半粗、`ink-muted` 的小字,沒有框也沒有底色;一律灰色,不用顏色區分類別。
14
+ - 有 `icon`:字級和顏色跟著旁邊的文字(見下方「數字的來源」),只有 AppShell/TopBar 的 `tags` 例外:頂部列一律畫成 12 px `ink-muted` 小字,不會看起來像標題的一部分。
14
15
  - 標籤只標例外:大部分項目都一樣的屬性不標。名詞需要說明時在 Tag 裡包 `Term`。
15
16
  - 加 `icon` 時用來說明數字的來源(見下方);`variant` 已停用。
16
17
 
17
18
  ## 數字的來源
18
19
 
19
- 加 `icon` 後是圖示加文字,沒有底色;字級跟著旁邊的文字(放在品牌旁就和品牌一樣大),半粗。沒有 `tone` 時顏色和旁邊的文字相同。
20
+ 加 `icon` 後是圖示加文字,沒有底色,半粗;字級跟著旁邊的文字(放在 KPI 數值旁就和數值的單位一起),沒有 `tone` 時顏色和旁邊的文字相同。放在 AppShell/TopBar 的 `tags` 時一律 12 px、`ink-muted`(有 `tone` 時用 tone 的顏色);ConsoleLayout 頂列的 `tags` 和標題同字級、同顏色(使用者確認的監控畫面規則)。
20
21
 
21
22
  - 預測、非實測的值:`icon="trend-up" tone="info"`「預測」,`accent-text` 色。放在預測值旁邊,或疊了斜線紋理(class `ui-forecast`)的區塊裡。
22
- - 整頁都是示範值:`icon="info"`「示範資料」。放在頁面標題旁:AppShell 或 ConsoleLayout 的 `tags`(頂列標題旁),一頁一個。
23
+ - 整頁都是示範值:`icon="info"`「示範資料」。放在頁面標題旁:AppShell 或 ConsoleLayout 的 `tags`(頂列標題旁),一頁一個。不要放進 `title` 字串,也不要自己加大或換色。
23
24
  - `tone` 其他值(`success`、`warning`、`danger`)只給這類來源標示用;分類一律灰色。
24
25
 
package/docs/TextField.md CHANGED
@@ -13,6 +13,7 @@
13
13
  - 自己給的 `aria-describedby`、`aria-invalid` 會保留,和提示或錯誤合在一起。
14
14
  - 錯誤:`error` 給一句原因加修正方式(「Email 格式不正確,例如 name@example.com」)。離開欄位(blur)或送出表單時才設定,不在每次按鍵時設定;改正後立刻清掉。欄位多時用 `useFormErrors` 處理這些時機。
15
15
  - 必填:`required` 會在標籤後加紅色星號(`danger`)。
16
+ - 金額、數量和網址的固定部分寫在框裡,不寫進標籤或 placeholder:`prefix="NT$"`(框的開頭)、`suffix="元"` 或 `".example.com"`(框的結尾)、`unit="GB"`(緊接在輸入的字後面)。三者都是灰字,螢幕閱讀器跟著說明念。
16
17
 
17
18
  ## 細節
18
19
 
@@ -20,3 +21,4 @@
20
21
  - focus:2 px `focus` 實線外框(間隔 2 px),和其他控制項相同;邊框不變色。
21
22
  - 錯誤時邊框變 `danger`,欄位內右側出現警示圖示,訊息用 `danger-text`。輸入框帶 `aria-invalid` 與 `aria-describedby`;錯誤訊息只在有錯誤時才放進頁面,是 `role="alert"` 的新節點,出現時念一次;同一句錯誤重新渲染不再念,換成另一句時念新的一句。說明(`hint`)是另一個節點,不會被念出。
22
23
  - 停用:`surface-sub` 灰底、`ink-muted` 灰字、無邊框。
24
+ - 有 `prefix`、`suffix` 或 `unit` 時外框畫在外層,字和輸入框在同一個框裡(間距 8 px);focus 外框圍住整個框。`unit` 跟著輸入的字移動,沒有字時接在 placeholder 後面。
package/docs/Toast.md CHANGED
@@ -15,7 +15,7 @@ toast('儲存失敗:網路中斷,請稍後再試', { tone: 'danger' });
15
15
 
16
16
  - 頁面不自己管 toast 的 state 和計時器:`toast()` 負責顯示、排隊、計時和念出。AppShell 自動放一個 Toaster;頁面自己放了 `<Toaster />` 時改用頁面的,同一則訊息不會出現兩次。
17
17
  - 時間:一般訊息 3 s 後消失;有動作(例如「復原」)的訊息停留 10 s,滑鼠移到訊息上或焦點在訊息裡時暫停計時(WCAG 2.2.1)。
18
- - 「復原」加 `undo: true`:訊息顯示時按 Ctrl Z(Mac 是 ⌘Z)也會執行,按鈕上寫出這個按鍵;焦點在輸入框裡時 Ctrl Z 仍是輸入框的復原。
18
+ - 「復原」加 `undo: true`:訊息顯示時按 Ctrl Z(Mac 是 ⌘Z)也會執行,按鈕上寫出這個按鍵(觸控螢幕不寫,按鍵仍在 `aria-keyshortcuts`);焦點在輸入框裡時 Ctrl Z 仍是輸入框的復原。
19
19
  - 文字寫發生了什麼,用過去式:「已刪除 3 筆」。
20
20
  - `tone`:預設 `success`(打勾);`neutral`、`info`、`warning`、`danger`。`danger` 立即念出(`role="alert"`),用在操作失敗;失敗的原因和修正方式寫進訊息。
21
21
  - 同一件事連續發生(每次輸入都存檔)時給相同的 `id`:只留一則,重新計時。
package/docs/TopBar.md CHANGED
@@ -13,7 +13,7 @@ Dashboard 類頁面的頂部列,高 64 px(`header-height`)。AppShell 已
13
13
 
14
14
  - 左側頁面標題(`title`,20 px、字重 700)。
15
15
  - `breadcrumb` prop 已停用:麵包屑是內容最上方的 `<Breadcrumb>`。
16
- - `tags`:標題旁的標記,字級和標題相同,例如 `<Tag icon="info">示範資料</Tag>`。
16
+ - `tags`:標題旁的標記,畫成 12 px `ink-muted` 小字(不像標題的一部分),例如 `<Tag icon="info">示範資料</Tag>`。
17
17
  - 帳號:用 `<Menu icon="user" label="帳號" items={…} />`(無框圖示按鈕,打開帳號選單),不要自己畫空白的圓形頭像。
18
18
  - `onSearch` 通常接到 CommandPalette;右側其他元素放 `children`。
19
19
 
@@ -23,4 +23,4 @@ Dashboard 類頁面的頂部列,高 64 px(`header-height`)。AppShell 已
23
23
  - 空間不夠時,右側的專案切換器先拿掉狀態文字、再截斷名稱,標題最多保留頂部列 45 % 的寬度才用「…」。
24
24
  - 寬度小於 600 px 時,搜尋框換成搜尋圖示(觸控區 48 px)。兩者都呼叫 `onSearch`,也都有 `data-tour="search"`,Tour 可以直接用 `target: 'search'`。
25
25
  - 頁首行為依版面規則:往下捲時隱藏,往上捲時出現。
26
- - `onMenu`:左邊加一個「開啟導覽」選單按鈕(AppShell 在 600 到 1023 px 用來打開導覽抽屜)。
26
+ - `onMenu`:左邊加一個「開啟導覽」選單按鈕(AppShell 在 600 到 1024 px 用來打開導覽抽屜)。
package/docs/Workbench.md CHANGED
@@ -8,7 +8,7 @@
8
8
  import { Workbench, useWorkbench, TreeList, IconButton, SearchField } from '@seanyeh77/ui';
9
9
 
10
10
  <Workbench
11
- id="app"
11
+ storageKey="app"
12
12
  brand={{ mark: <Logo />, name: 'app', href: '#overview' }}
13
13
  crumbs={[{ label: 'harness' }, { label: 'controller.py' }]}
14
14
  mainBar={<IconButton variant="quiet" icon="arrow-square-out" label="用 VS Code 開啟" onClick={openInEditor} />}
@@ -23,10 +23,11 @@ import { Workbench, useWorkbench, TreeList, IconButton, SearchField } from '@sea
23
23
  defaultLayout={{ side: ['outline'], panel: ['problems'] }}
24
24
  >
25
25
  <CodeView code={code} file={file} header="float" copy />
26
- </Workbench>
26
+ </Workbench>;
27
27
  ```
28
28
 
29
- - 外層要給高度(例如 `height: 100vh`);Workbench 填滿它。
29
+ - 外層要給高度(例如 `height: 100vh`);Workbench 填滿它。給 `storageKey` 才會記住版面。
30
+ - `brand` 的名稱是整頁的 `h1`,主畫面和它上方的列在 `main` 裡(名稱是 `label`,預設「編輯器」):頁面不再另放 `h1` 或 `main`。
30
31
  - `mainBar`(36 px 的列)只放 `IconButton variant="quiet"` 或 `SegmentedControl iconOnly`;不放 40 px 的一般按鈕、輸入框、Select 或 Tabs。
31
32
  - 主畫面裡的 CodeView 用 `header="float"`:檔名已經在麵包屑上。
32
33
  - 檔案總管的樹用 `TreeList kind="plain" density="compact" bare`;選了東西之後呼叫 `useWorkbench().explorerPicked()`。
@@ -50,7 +51,7 @@ import { Workbench, useWorkbench, TreeList, IconButton, SearchField } from '@sea
50
51
 
51
52
  ## 記住版面
52
53
 
53
- - 每個分頁在哪一邊、各邊開著哪個分頁、各區塊開或關、大小,存在 `localStorage` 的 `ui-workbench:` 加 `id`。新增的 view 照 `defaultLayout` 放;拿掉的 view 自動忽略。
54
+ - 給 `storageKey` 時,每個分頁在哪一邊、各邊開著哪個分頁、各區塊開或關、大小,存在 `localStorage` 的 `ui-workbench:` 加 `storageKey`;沒給時只記到重新整理為止。舊的 `id` 仍可用(存的資料相同),開發時 console 提醒改名。新增的 view 照 `defaultLayout` 放;拿掉的 view 自動忽略。
54
55
  - 「還原預設版面」:在 Workbench 裡面用 `useWorkbench().resetLayout()`,按鈕放在哪由頁面決定(例如 `actions` 或說明選單)。
55
56
 
56
57
  ```tsx
@@ -100,7 +101,9 @@ React.useEffect(() => {
100
101
  return () => window.removeEventListener('popstate', open);
101
102
  }, []);
102
103
 
103
- <Workbench ref={wb} id="app" views={views}>…</Workbench>
104
+ <Workbench ref={wb} storageKey="app" views={views}>
105
+ …
106
+ </Workbench>;
104
107
  ```
105
108
 
106
109
  ## 讀取目前的版面
@@ -114,7 +117,7 @@ React.useEffect(() => {
114
117
  ```tsx
115
118
  <Workbench
116
119
  ref={wb}
117
- id="app"
120
+ storageKey="app"
118
121
  views={views}
119
122
  onLayoutChange={(l) => {
120
123
  const url = new URL(location.href);
package/docs/agents.md CHANGED
@@ -9,8 +9,7 @@ SeanYeh's design system: typed React 19 components, design tokens, page template
9
9
  | `@seanyeh77/ui` | The components, `styles.css`, `bundle.js` for pages without a build step, and the docs under `docs/` (this file is `docs/agents.md`) |
10
10
  | `@seanyeh77/tokens` | `tokens.css`, the fonts, a Tailwind v4 theme (`tailwind.css`), typed token names with `cssVar()` |
11
11
  | `@seanyeh77/eslint-plugin-ui` | Lint rules for the core rules |
12
- | `@seanyeh77/ui-cli` | `ui check`, `ui shots`, `ui docs`, `ui list`. Run it as `npx @seanyeh77/ui-cli …`: plain `npx ui` is an unrelated package. |
13
- | Registry `…/r/<name>.json` | Page templates: `dashboard`, `list-detail`, `settings`, `login` |
12
+ | `@seanyeh77/ui-cli` | `ui check`, `ui shots`, `ui docs`, `ui list`, `ui add`. Run it as `npx @seanyeh77/ui-cli …`: plain `npx ui` is an unrelated package. |
14
13
 
15
14
  ## Building a page
16
15
 
@@ -18,17 +17,17 @@ Use it for any web page or tool UI unless the user asks for a different look. Sp
18
17
 
19
18
  Read this, and nothing more:
20
19
 
21
- 1. `docs/guidelines.md`, the core rules every page needs (about 9 KB). Read it once, whole: the rules agents most often get wrong (list pages, buttons, status, numbers, empty and loading states) are there.
20
+ 1. `docs/guidelines.md`, the core rules every page needs (about 9 KB). Read it once, whole.
22
21
  2. The 用法 block of each component you use: `npx @seanyeh77/ui-cli docs DataTable`. Add `--full` only for a detail the block does not cover. `ui list` lists every component by group; `ui docs icons` prints the icon names. The same files are in `node_modules/@seanyeh77/ui/docs/` and on the docs site under `/md/`.
23
22
  3. A topic file only when the page has that topic: `layout`, `forms`, `data`, `monitoring`, `code`, `theme`, `motion` (`ui docs layout`).
24
23
 
25
24
  Then:
26
25
 
27
- - Start from a page template when one fits: `npx shadcn@latest add https://seanyeh77.github.io/ui-design-system/r/dashboard.json` (also `list-detail`, `settings`, `login`). It needs a `components.json` (`npx shadcn@latest init`); without shadcn, write the JSON's `files[].content` yourself.
26
+ - Start from a page template when one fits (`dashboard`, `list-detail`, `settings`, `login`): `npx @seanyeh77/ui-cli add dashboard [dir]` writes it with no network (default `src/components/blocks/dashboard/`). The same templates are a shadcn registry: `npx shadcn@latest add https://seanyeh77.github.io/ui-design-system/r/dashboard.json` (needs a `components.json`).
28
27
  - Your own CSS uses tokens only: `var(--surface)` in CSS, `cssVar('ink-muted')` from `@seanyeh77/tokens` in style props, `bg-surface text-ink-muted` with the Tailwind theme.
29
- - TypeScript enforces most rules (icon names, `confirm` on danger actions, DataTable column keys): fix type errors instead of casting them away. In development the components warn in the console with the cause and the fix.
28
+ - TypeScript enforces most rules: fix type errors instead of casting them away. In development the components warn in the console with the cause and the fix.
30
29
  - Items marked 看情況 ("situational") are not fixed rules: choose per context and say which way you chose.
31
- - Before you finish: `npx @seanyeh77/ui-cli check <file or URL>`. It opens the page at 390 px and 1280 px, light and dark, opens its tabs, SettingsLayout categories and toolbar menus, and fails on what the rules forbid (console errors, overflow, small or crowded targets, a card in a card, native controls, wrapped labels, cut-off text, page CSS that overrides components, axe-core WCAG 2.2 AA); each problem says what to fix. `--open <selector>` also checks a dialog or drawer; `--no-axe` and `--no-interact` skip those parts. Add `--shots shots/` and check the screenshots against the last section of `guidelines.md`.
30
+ - Before you finish: `npx @seanyeh77/ui-cli check <file or URL>`. It opens the page at 390 px and 1280 px, light and dark, opens its tabs and menus, and fails on what the rules forbid and on axe-core WCAG 2.2 AA; each problem says what to fix. `--open <selector>` also checks a dialog or drawer. Add `--shots shots/` and check the screenshots against the last section of `guidelines.md`.
32
31
 
33
32
  ## Projects with a build step (Vite, Next.js and similar)
34
33
 
@@ -53,8 +52,9 @@ import ui from '@seanyeh77/eslint-plugin-ui';
53
52
  export default [ui.configs.recommended];
54
53
  ```
55
54
 
56
- - ES modules only: TypeScript needs `moduleResolution` `bundler`, `node16` or `nodenext` (Vite and Next.js templates use `bundler`). React 19 is required. The module starts with `'use client'`; server code that only formats dates, numbers or text imports `@seanyeh77/ui/format`.
57
- - The system's CSS is in the cascade layer `ui`: your unlayered CSS always wins, with no `!important`. So delete the template's starter CSS (Vite's `index.css`, `App.css`) and put any reset in `@layer base { … }`. With Tailwind v4, start the main CSS with `@layer theme, base, ui, components, utilities;` (details in `theme.md`).
55
+ - `fonts.css` is about 500 KB of CSS (Noto Sans TC lists the characters of its 432 files). To keep it out of the CSS that blocks the first render, import `@seanyeh77/ui/fonts-latin.css` (Inter, Geist Mono; about 18 KB) instead and load the Chinese faces after the page with `import('@seanyeh77/ui/fonts-tc.css')` (a separate CSS file). Vite inlines font files under 4 KB; keep them as files with `build: { assetsInlineLimit: (f) => (f.endsWith('.woff2') ? false : undefined) }` in `vite.config`.
56
+ - ES modules only: TypeScript needs `moduleResolution` `bundler`, `node16` or `nodenext` (Vite and Next.js templates use `bundler`). React 19 is required. The module starts with `'use client'`; server code that only formats dates, numbers or text imports `@seanyeh77/ui/format`. Server-rendered pages put `themeScript` in an inline `<script>` in `<head>` so the stored theme and accent apply before the first paint (`theme.md`).
57
+ - The system's CSS is in the cascade layer `ui`: your unlayered CSS always wins. So delete the template's starter CSS (Vite's `index.css`, `App.css`) and put any reset in `@layer base { … }`. With Tailwind v4, start the main CSS with `@layer theme, base, ui, components, utilities;` (details in `theme.md`).
58
58
  - The ESLint plugin depends only on ESLint and works with TypeScript 7. Templates that ship oxlint instead need `eslint` and an `eslint.config.js`, as above.
59
59
  - pnpm may refuse a version published less than a day ago: `pnpm add @seanyeh77/ui@<version> --config.minimum-release-age=0`.
60
60
 
@@ -65,11 +65,11 @@ export default [ui.configs.recommended];
65
65
  ```html
66
66
  <meta charset="utf-8">
67
67
  <meta name="viewport" content="width=device-width, initial-scale=1">
68
- <link rel="stylesheet" href="https://seanyeh77.github.io/ui-design-system/dist/0.45.0/fonts.css">
69
- <link rel="stylesheet" href="https://seanyeh77.github.io/ui-design-system/dist/0.45.0/tokens.css">
70
- <link rel="stylesheet" href="https://seanyeh77.github.io/ui-design-system/dist/0.45.0/styles.css">
68
+ <link rel="stylesheet" href="https://seanyeh77.github.io/ui-design-system/dist/0.47.0/fonts.css">
69
+ <link rel="stylesheet" href="https://seanyeh77.github.io/ui-design-system/dist/0.47.0/tokens.css">
70
+ <link rel="stylesheet" href="https://seanyeh77.github.io/ui-design-system/dist/0.47.0/styles.css">
71
71
  <div id="root"></div>
72
- <script src="https://seanyeh77.github.io/ui-design-system/dist/0.45.0/bundle.js"></script>
72
+ <script src="https://seanyeh77.github.io/ui-design-system/dist/0.47.0/bundle.js"></script>
73
73
  <script>
74
74
  const h = React.createElement;
75
75
  UI.initTheme();
@@ -77,6 +77,6 @@ export default [ui.configs.recommended];
77
77
  </script>
78
78
  ```
79
79
 
80
- Pin a version as above: `/dist/<version>/` never changes; `/dist/` always serves the latest release. jsDelivr has the same files (`https://cdn.jsdelivr.net/npm/@seanyeh77/ui@0.45.0/dist/bundle.js`, `…/dist/styles.css`; the fonts at `https://cdn.jsdelivr.net/npm/@seanyeh77/tokens@0.45.0/fonts.css`). Without a bundler, `@seanyeh77/ui/dist/fonts.css` cannot resolve its import: load the tokens package's `fonts.css` or the pinned site URL.
80
+ Pin a version as above: `/dist/<version>/` never changes; `/dist/` always serves the latest release. jsDelivr has the same files (`https://cdn.jsdelivr.net/npm/@seanyeh77/ui@0.47.0/dist/bundle.js`, `…/dist/styles.css`; the fonts at `https://cdn.jsdelivr.net/npm/@seanyeh77/tokens@0.47.0/fonts.css`). Without a bundler, `@seanyeh77/ui/dist/fonts.css` cannot resolve its import: load the tokens package's `fonts.css` or the pinned site URL.
81
81
 
82
82
  Scope: web UI, and the tokens of SeanYeh's Slidev decks (`initTheme({ preset: 'teaching' })`, see `theme.md`). Slide layout, Notion documents and teaching diagrams follow the separate `teaching-materials-style` skill.
package/docs/data.md CHANGED
@@ -21,7 +21,7 @@
21
21
 
22
22
  ## 表格與結果清單
23
23
 
24
- - 表格裡的數字不縮寫;時間長度用 `format: 'duration'`,日期用 `date`、`dateTime`、`relative`。
24
+ - 表格裡的數字不縮寫。金額、時間長度、日期的欄位格式(`format`)寫在 DataTable 的用法(`ui docs DataTable`)。
25
25
  - 結果清單(檢查結果、審核清單):上方用 DataTable 的 `summary` 當摘要(全部加各狀態,附筆數),點了就篩選。要處理的狀態(失敗)緊接在「全部」後面。排序看情況,預設照資料的順序。
26
26
  - 摘要已經寫出各狀態的筆數,就不用 KPI 卡片重複;KPI 只放表格看不出來的數字(總時數、成功率、趨勢)。
27
27
  - 合計列、固定第一欄、常用檢視、同一欄位多選:看情況,依資料決定要不要開。
@@ -32,5 +32,6 @@
32
32
 
33
33
  - 圖表配色依序 `chart-1` 藍、`chart-2` 青、`chart-3` 橘、`chart-4` 暖灰;只有一組資料時用 `chart-1`;`chart-4` 給「其他」這類次要的一類。類別超過 3 時,圖例一定有文字。
34
34
  - 大數字的軸和數值用 `format="compact"`(「50 萬」);KpiCard 自己縮寫。
35
+ - KpiCard 變化的好壞方向(`direction`,越低越好的指標)和比較期間(`compareLabel`)寫在 KpiCard 的用法(`ui docs KpiCard`)。
35
36
  - 熱度色階 `heat-1`…`heat-7` 與差值的發散色階只用在資料的填色,上面的字用 `textOn(fill)`;狀態不只靠顏色,數值一定寫出來(見 DataColors)。
36
37
  - 預測、非實測的數值:填色上疊斜線(`ui-forecast`),旁邊加 `Tag icon="trend-up" tone="info"`「預測」。
@@ -29,7 +29,7 @@
29
29
  ## 控制項
30
30
 
31
31
  - 不用原生 `<select>`、`<table>`、`<input>`、`<textarea>`、`<button>`、`<a>`、勾選框:用 Select、DataTable、TextField、TextArea、Button、Link、Checkbox。
32
- - 按鈕層級:`primary` 實心,每個區塊最多一個;`secondary` 外框;`quiet` 無框,給次要操作與工具列;`danger` 實心紅色,按下後先確認(給 `confirm`)。只有圖示的按鈕用 `IconButton`,一定有 `label`。
32
+ - 按鈕的層級(`primary`、`secondary`、`quiet`、`danger`)和危險動作的確認寫在 Button 的用法(`ui docs Button`)。只有圖示的按鈕用 `IconButton`,一定有 `label`。
33
33
  - 按鈕與輸入框 40 px,寬度小於 600 px 時輸入框 48 px;觸控點擊範圍至少 48 × 48 px,句子裡的連結和名詞說明例外。
34
34
  - 鍵盤焦點一律是 2 px `focus` 外框;錯誤是紅框加圖示加原因;停用灰底灰字。
35
35
  - 浮層:要使用者決定用 Dialog,編輯一筆資料用 Drawer,按鈕旁的少量設定用 Popover,更多操作用 Menu,短提示用 Tooltip。開關一律是 `open`、`defaultOpen`、`onOpenChange`。
@@ -40,7 +40,7 @@
40
40
  - Dashboard 類用 `AppShell`;監控畫面用 `ConsoleLayout`;程式碼工具用 `Workbench`;展示類(產品介紹、說明網站)只用頂部導覽,見 [layout.md](layout.md)。
41
41
  - 內容滿版,`Page` 上下排區塊,`Grid` 排卡片:等寬 `columns={3}`,不等寬給比例 `columns={[2, 1]}`(主要內容加側欄)。每個區塊一張 `Card`。
42
42
  - 頁面標題只出現一次:清單頁、Dashboard、設定頁寫在頂部列(AppShell `title`);詳細頁是那筆資料的名稱,寫在 `PageHeader`,AppShell 不給 `title`。麵包屑放在內容最上方(`Breadcrumb`),不放頂部列。
43
- - 斷點:手機小於 600 px、平板 600 到 959 px、桌面 960 px 以上(大螢幕 1280 px 以上)。AppShell 的導覽另以 1024 px 為界:600 到 1023 px 改成導覽抽屜,1024 px 以上有側邊欄,小於 600 px 改成底部分頁列。手機上長文字靠左。
43
+ - 斷點:手機小於 600 px、平板 600 到 959 px、桌面 960 px 以上(大螢幕 1280 px 以上)。AppShell 的導覽另以 1024 px 為界:600 到 1024 px(含 1024 px)改成導覽抽屜,大於 1024 px 有側邊欄,小於 600 px 改成底部分頁列。手機上長文字靠左。
44
44
 
45
45
  ## 常見頁面
46
46
 
@@ -53,9 +53,9 @@
53
53
  ## 狀態與回饋
54
54
 
55
55
  - 狀態(進度、結果、連線)用 `Badge`,圓點加文字,只有要處理的狀態醒目:已啟用 `tone="success"`、已停用和已取消 `status="closed"`、在線 `online`、離線 `offline`。「這是什麼」的分類用 `Tag`,一律灰色。
56
- - 載入:立即顯示和內容同大小的 `Skeleton`(表格、KPI、圖表各一塊),不用轉圈。載入失敗:在那個區塊的位置放 `Alert tone="danger"`,寫原因,動作「重試」。
56
+ - 載入:立即顯示和內容同大小的 `Skeleton`(KPI、圖表各一塊;表格給 DataTable `loading`,工具列和表頭留著),不用轉圈。載入失敗:在那個區塊的位置放 `Alert tone="danger"`,寫原因,動作「重試」。
57
57
  - 空清單:還沒有任何資料時,Card 裡放 `EmptyState`(下一步怎麼開始,「新增」放在它的 `action`)取代 DataTable;搜尋或篩選後沒有結果時,DataTable 自己顯示一句 `emptyText`,工具列留著。
58
- - 操作完成:`toast('已儲存')`(AppShell 已放好 Toaster;沒有 AppShell 時在 app 最外層放一個 `<Toaster />`)。一般訊息 3 s 後消失;能復原時附「復原」,停留 10 s,滑鼠或焦點在訊息上時暫停,按 Ctrl Z(Mac ⌘Z)也能復原。要一直顯示的提示用 Alert。
58
+ - 操作完成:`toast('已儲存')`;能復原時附「復原」。顯示時間、復原和放 Toaster 的位置寫在 Toast 的用法(`ui docs Toast`)。要一直顯示的提示用 Alert。
59
59
 
60
60
  ## 格式
61
61
 
package/docs/icons.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # 圖示名稱
2
2
 
3
- Icon 的 `name` 和元件的 `icon` 接受的 102 個內建 Phosphor 名稱(`filled` 換實心版;其他圖示傳 24 px 的 path):
3
+ Icon 的 `name` 和元件的 `icon` 接受的 113 個內建 Phosphor 名稱(`filled` 換實心版;其他圖示傳 24 px 的 path):
4
4
 
5
- archive arrow-down arrow-left arrow-right arrow-square-out arrow-u-up-left arrow-u-up-right arrow-up arrows-clockwise arrows-in-line-vertical arrows-left-right arrows-out-line-vertical bell brackets-curly calendar-blank caret-down caret-left caret-right caret-up chart-bar chart-line chart-pie chat-centered check check-circle check-square circle-notch clock cloud columns command copy corners-in corners-out cpu database dots-six-vertical dots-three dots-three-vertical download-simple envelope-simple eye eye-slash file file-code file-text floppy-disk folder folder-open function funnel gauge gear globe hard-drives hash heart house image info key keyboard layout link list list-bullets lock magnifying-glass minus monitor moon paper-plane-tilt pencil-simple plus printer pulse push-pin question share-network shield sidebar-simple sign-in sign-out sliders-horizontal sort-ascending sparkle square squares-four stack star sun tag terminal-window trash trend-up upload-simple user users warning warning-circle x x-circle
5
+ archive arrow-down arrow-left arrow-right arrow-square-out arrow-u-up-left arrow-u-up-right arrow-up arrows-clockwise arrows-in-line-vertical arrows-left-right arrows-out-line-vertical bell brackets-curly calendar-blank caret-down caret-left caret-right caret-up chart-bar chart-line chart-pie chat-centered check check-circle check-square circle-notch clock cloud columns command copy corners-in corners-out cpu credit-card database dots-six-vertical dots-three dots-three-vertical download-simple envelope-simple eye eye-slash file file-code file-text floppy-disk folder folder-open function funnel gauge gear globe hard-drives hash heart house image info key keyboard layout link list list-bullets lock magnifying-glass map-pin minus monitor moon package paper-plane-tilt pause pencil-simple phone play plus printer prohibit pulse push-pin question receipt share-network shield shopping-cart sidebar-simple sign-in sign-out sliders-horizontal sort-ascending sparkle square squares-four stack star storefront sun tag terminal-window trash trend-up truck upload-simple user users warning warning-circle x x-circle
6
6
 
7
7
  也接受這 40 個 Lucide 名稱(對應到上面的圖示):
8
8
 
package/docs/layout.md CHANGED
@@ -30,7 +30,7 @@
30
30
  | 桌面 | 960 到 1279 | `bp-desktop` |
31
31
  | 大螢幕 | 1280 以上 | `bp-wide` |
32
32
 
33
- - 導覽的邊界是 1024 px,只管導覽:AppShell 在 600 到 1023 px 沒有側邊欄,頂部列左邊的選單按鈕打開導覽抽屜;1024 px 以上有側邊欄。頁面排版(`Grid`、`SplitPane`)照上表的斷點。
33
+ - 導覽的邊界是 1024 px,只管導覽:AppShell 在 600 到 1024 px(含 1024 px)沒有側邊欄,頂部列左邊的選單按鈕打開導覽抽屜;大於 1024 px 有側邊欄。頁面排版(`Grid`、`SplitPane`)照上表的斷點。
34
34
  - 表單欄位:`FormGrid` 自己寬 640 px 以上雙欄,以下單欄(container query)。
35
35
 
36
36
  ## 導覽
@@ -39,7 +39,7 @@
39
39
 
40
40
  - 側邊欄(`SideNav`,AppShell 內建):選中用左側指示條(水滴方式移動);項目高 40 px;組與組之間分隔線;收合後滑過顯示名稱提示。品牌用 `brand={{ mark, name, href }}`。
41
41
  - 頂部列(`TopBar`):左邊頁面標題,右邊填色搜尋框(附 Ctrl K 提示,Mac 上寫 ⌘K);手機上搜尋框換成搜尋圖示。
42
- - 同一頁裡切換內容不同的檢視:分頁(`Tabs`),內容依序浮起;分頁上的數字帶單位。同一份內容的兩三種顯示方式:分段控制(`SegmentedControl`)。
42
+ - 同一頁裡切換內容不同的檢視:分頁(`Tabs`),內容依序浮起;分頁上的數字帶單位。同一份內容的兩三種顯示方式:分段控制(`SegmentedControl`)。兩者外觀不同:分頁是文字加底線,分段控制是灰底上的白塊。
43
43
  - 手機底部分頁列(`MobileTabBar`,AppShell 內建):放不下的頁面放在最後一格「更多」。
44
44
  - 專案狀態:頂部列右邊放 `ProjectSwitcher`。通知:頂部列的 `NotificationBell`。主題與強調色放在設定頁的「外觀」,不放在頂部列。
45
45
 
@@ -49,4 +49,4 @@
49
49
  - 第一次使用的導覽:`Tour` 加 `useTour(key)` 記住看過了沒有。可以略過,看完或略過後不再自動出現;頁面上要有「重看導覽」。有「導覽」按鈕的頁面不自動打開,改在按鈕上提示(`IconButton` 的 `hint`);不用「第一次使用」橫幅。
50
50
  - 讀者可能看不懂的名詞和關係標籤:`Term`;句子裡用 `variant="inline"`。
51
51
  - 發現寫錯的地方:`Suggestion`,舊的和新的上下兩行,可以複製修正。
52
- - 整頁元件:錯誤頁 `ErrorPage`、登入頁 `LoginCard`、設定頁 `SettingsLayout`(改完自動儲存,危險操作放最下方的 `DangerZone`)。
52
+ - 整頁元件:錯誤頁 `ErrorPage`、登入頁 `LoginCard`、設定頁 `SettingsLayout`(改完自動儲存,危險操作放最下方的 `DangerZone`;分類寫進網址 hash,`urlSync` 見 `ui docs SettingsLayout`)。