@seanyeh77/ui 0.47.1 → 0.48.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 +11 -13
- package/dist/components/DataTable/DataTable.js +13 -6
- package/dist/components/DataTable/DataTable.js.map +1 -1
- package/dist/components/FileUpload/useFilePicker.d.ts +17 -0
- package/dist/components/FileUpload/useFilePicker.js +53 -0
- package/dist/components/FileUpload/useFilePicker.js.map +1 -0
- package/dist/components/Workbench/Workbench.d.ts +2 -3
- package/dist/components/Workbench/Workbench.js +35 -19
- package/dist/components/Workbench/Workbench.js.map +1 -1
- package/dist/css/DataTable.css +27 -0
- package/dist/css/Workbench.css +10 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/internal/scrollHint.js +2 -1
- package/dist/internal/scrollHint.js.map +1 -1
- package/dist/styles.css +37 -0
- package/docs/DataTable.md +1 -1
- package/docs/FileUpload.md +14 -1
- package/docs/Term.md +2 -2
- package/docs/Workbench.md +2 -1
- package/docs/agents.md +5 -5
- package/package.json +2 -2
package/dist/styles.css
CHANGED
|
@@ -4188,6 +4188,14 @@ div.ui-toast[role='status'] {
|
|
|
4188
4188
|
font-weight: 600;
|
|
4189
4189
|
white-space: nowrap;
|
|
4190
4190
|
}
|
|
4191
|
+
/* The bulk bar's count with, on phones, the select-all checkbox before it (the header row with its checkbox is hidden
|
|
4192
|
+
there): the checkbox in the rows' checkbox column, the count where the rows' titles start. */
|
|
4193
|
+
.ui-dt-bulk-lead {
|
|
4194
|
+
display: flex;
|
|
4195
|
+
align-items: center;
|
|
4196
|
+
gap: var(--space-2);
|
|
4197
|
+
min-width: 0;
|
|
4198
|
+
}
|
|
4191
4199
|
.ui-dt-bulk-actions {
|
|
4192
4200
|
margin-left: auto;
|
|
4193
4201
|
display: flex;
|
|
@@ -4371,6 +4379,10 @@ div.ui-toast[role='status'] {
|
|
|
4371
4379
|
width: auto;
|
|
4372
4380
|
min-width: 0;
|
|
4373
4381
|
}
|
|
4382
|
+
/* Cards never scroll sideways: no fade on the right (useScrollHint also ignores a box that does not scroll). */
|
|
4383
|
+
.ui-dt-scroller::after {
|
|
4384
|
+
display: none;
|
|
4385
|
+
}
|
|
4374
4386
|
/* In a Card the cards' box is the Card itself: no second shadow, a line between the toolbar and the first row. */
|
|
4375
4387
|
.ui-card .ui-dt-scroll {
|
|
4376
4388
|
box-shadow: none;
|
|
@@ -4473,12 +4485,27 @@ div.ui-toast[role='status'] {
|
|
|
4473
4485
|
grid-row: 1;
|
|
4474
4486
|
margin: 0 var(--space-2) 0 0;
|
|
4475
4487
|
}
|
|
4488
|
+
/* The checkbox and the status sit on the title's first line, centred on it: a box one line tall (1lh, the title's
|
|
4489
|
+
line height) at the top of the row, the checkbox or Badge centred in it. As inline boxes they sat on the
|
|
4490
|
+
baseline, and the title's second line (secondary) centred the row around both lines, so they stood 4 to 8 px
|
|
4491
|
+
above the title. */
|
|
4492
|
+
.ui-dt-body .ui-dt-cell:is(.ui-dt-sel, .is-m-status) {
|
|
4493
|
+
display: flex;
|
|
4494
|
+
align-items: center;
|
|
4495
|
+
align-self: start;
|
|
4496
|
+
height: 1lh;
|
|
4497
|
+
}
|
|
4476
4498
|
.ui-dt-body .ui-dt-cell.is-m-title {
|
|
4477
4499
|
grid-column: 2;
|
|
4478
4500
|
grid-row: 1;
|
|
4501
|
+
align-self: start;
|
|
4479
4502
|
margin-top: 0;
|
|
4480
4503
|
font-weight: 600;
|
|
4481
4504
|
}
|
|
4505
|
+
/* The row's padding is the card's: the title (and its secondary line) starts at the top, level with the checkbox. */
|
|
4506
|
+
.ui-dt-body .ui-dt-cell.is-m-title > .ui-dt-stack {
|
|
4507
|
+
padding-block: 0;
|
|
4508
|
+
}
|
|
4482
4509
|
/* A title made of a name and tags in a row: the tags go to the next line instead of squeezing the name. */
|
|
4483
4510
|
.ui-dt-body .ui-dt-cell.is-m-title > :is(span, div):only-child {
|
|
4484
4511
|
flex-wrap: wrap;
|
|
@@ -9030,6 +9057,16 @@ button.ui-md-link.is-row {
|
|
|
9030
9057
|
margin-top: -4px;
|
|
9031
9058
|
cursor: row-resize;
|
|
9032
9059
|
}
|
|
9060
|
+
/* The bottom panel's border: a 24 px hit area (WCAG 2.5.8), the 8 px handle plus 16 px above it over the bottom of the
|
|
9061
|
+
main view, so it never covers the panel's tab row below. */
|
|
9062
|
+
.ui-wb-panel > .ui-wb-split.is-h::before {
|
|
9063
|
+
content: '';
|
|
9064
|
+
position: absolute;
|
|
9065
|
+
left: 0;
|
|
9066
|
+
right: 0;
|
|
9067
|
+
bottom: 0;
|
|
9068
|
+
height: 24px;
|
|
9069
|
+
}
|
|
9033
9070
|
.ui-wb-split-line {
|
|
9034
9071
|
position: absolute;
|
|
9035
9072
|
background: transparent;
|
package/docs/DataTable.md
CHANGED
|
@@ -51,7 +51,7 @@ const columns: DataTableColumn<Import>[] = [
|
|
|
51
51
|
- 搜尋:預設搜尋所有欄位,按「/」移到搜尋框;`search.keys` 限定欄位,`render` 的欄位給 `searchText`;`search: false` 拿掉搜尋框。筆數:有 `summary` 時「全部 24」已經是筆數,工具列只在搜尋或篩選後顯示「10 / 24 筆」;沒有 `summary` 時一頁內的表格顯示「24 筆」,有頁碼時由下方的「第 1–10 筆,共 24 筆」說。螢幕閱讀器一律念得到筆數。每一處筆數的單位是 `unit`(預設 `summary.unit`,再沒有是「筆」)。
|
|
52
52
|
- `toolbar={false}`:沒有工具列,給 3 到 5 列、不需要搜尋和篩選的小表格;點欄位標題仍可排序。
|
|
53
53
|
- 排序:點欄位標題,Shift+點加成下一層;`defaultSort`、`maxSort`,`sortValue` 給排序用的值,`sortable: false` 不能排序。
|
|
54
|
-
- `selectable` 加 `bulkActions={(ids, clear) => …}`:勾選後表格上方出現「已選 n
|
|
54
|
+
- `selectable` 加 `bulkActions={(ids, clear) => …}`:勾選後表格上方出現「已選 n 筆」和批次按鈕;看不到的列自動取消勾選;手機卡片沒有表頭,「全選」放在這一列的最前面,和列的勾選框同一欄。
|
|
55
55
|
- `rowHref={(row) => url}`:整列是連結(中鍵、Ctrl+點開新分頁);SPA 另給 `onRowOpen` 推路由。第一欄的 `render` 裡不再放連結。
|
|
56
56
|
- `totals={{ amount: 'sum', rate: 'avg' }}`:合計列,有金額或數量要加總時才開(看情況)。`stickyFirst`:欄位多、常橫向捲動時固定第一欄(看情況)。`views`:幾組固定的看法(「我負責的」)時才開(看情況)。
|
|
57
57
|
- 欄位:`hidden: true` 一開始不顯示(「⋯」的「欄位」可以打開);`width` 只是最小寬度;`grow` 改變分剩下寬度的份數;`long: true` 的長文字截斷並可展開;`fullText` 給縮短的格子完整文字;`currency`、`decimals` 調整格式。
|
package/docs/FileUpload.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
## 用法
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
檔案上傳:一行拖放區,下方列出檔案與進度,上傳本身由頁面實作;只從按鈕或選單項目打開檔案選擇時改用 `useFilePicker`。
|
|
6
6
|
|
|
7
7
|
```tsx
|
|
8
8
|
<FileUpload
|
|
@@ -17,6 +17,19 @@
|
|
|
17
17
|
- 用 `onAdd` 收到檔案,自己上傳,再更新 `files` 裡的 `progress`、`status`(`uploading`、`done`、`danger`)。失敗時把原因和修正方式寫在 `error`。
|
|
18
18
|
- 限制(類型、大小)寫在拖放區右邊(`limitText`)。
|
|
19
19
|
- 失敗時給 `error`:一句原因加修正方式,旁邊有「重試」。
|
|
20
|
+
- 從按鈕或選單項目打開檔案選擇(「開啟檔案」,沒有拖放區)用 `useFilePicker`,不自己放 `<input type="file">`:
|
|
21
|
+
|
|
22
|
+
```tsx
|
|
23
|
+
const picker = useFilePicker({ accept: '.json', onPick: (files) => load(files[0]) });
|
|
24
|
+
<Button onClick={picker.open}>開啟檔案</Button>
|
|
25
|
+
<Menu label="更多操作" items={[{ label: '開啟檔案', icon: 'folder-open', onSelect: picker.open }]} />
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## `useFilePicker`
|
|
29
|
+
|
|
30
|
+
- 回傳 `{ open }`;選項 `accept`、`multiple`、`onPick(files)`(取消時不呼叫)。
|
|
31
|
+
- `open()` 要直接在點擊的處理函式裡呼叫(Button 的 `onClick`、Menu 項目的 `onSelect`):瀏覽器只在使用者操作當下打開檔案選擇,先 `await` 再呼叫會被擋下。
|
|
32
|
+
- hook 自己管一個隱藏的 `<input type="file">`:第一次 `open()` 時放進 `document.body`,元件卸載時移除;伺服器渲染時不碰 document。選完會清空,同一個檔案可以再選一次。
|
|
20
33
|
|
|
21
34
|
## 細節
|
|
22
35
|
|
package/docs/Term.md
CHANGED
|
@@ -16,12 +16,12 @@
|
|
|
16
16
|
- 預設在詞的後面加一個小問號,點一下打開;句子裡讀起來不想被打斷時用 `variant="inline"`(灰色虛線)。
|
|
17
17
|
- 關係的說明可以加證據那一行程式碼(`code`)和一個動作(`action`,例如「看這一行」)。
|
|
18
18
|
- 同一份程式碼或文件反覆出現的詞,用 CodeView 或 Markdown 的 `terms` 自動標,不必一個一個包。
|
|
19
|
+
- 觸控範圍:`variant="inline"` 一律當作句子裡的詞,和句子裡的連結一樣不擴大到 48 px(WCAG 2.2 行內例外),`ui check` 也不算它;預設樣式在句子裡(旁邊有文字)時同樣不擴大,單獨出現時(Tag 裡、圖例)自動擴大到 48 px。
|
|
19
20
|
|
|
20
21
|
## 細節
|
|
21
22
|
|
|
22
23
|
- 記號:詞的後面加一個小問號,滑過或打開時問號變強調色。文字本身維持周圍的字體和顏色,所以可以放在句子裡,也可以放在 `UI.Tag` 裡。
|
|
23
24
|
- 點一次打開,再點一次關閉;右上角也有 ×,按 Esc 或點外面也會關閉。
|
|
24
|
-
- 觸控範圍:放在句子裡時不擴大(WCAG 2.2 行內例外);單獨出現時(Tag 裡、圖例)自動擴大到 48 px,不用另外處理。
|
|
25
25
|
- 寬度 600 px 以上:詞的下方浮起小卡,寬 340 px。小卡留在詞所在的區塊裡(最近的卡片、SplitPane 的一邊或主要內容區),往左右移動或變窄來放進去,不蓋到旁邊的面板;區塊比 240 px 窄時才以整個視窗為範圍。小於 600 px:從畫面下方打開,字比較大,按鈕至少 48 px。
|
|
26
26
|
- 說明裡的檔案和行號可以用 `refHref`、`onRef`、`isRef` 變成連結(同 CodeText)。
|
|
27
27
|
- 內容:標題(預設是詞本身)、一兩句說明(`text`,反引號變行內程式碼);關係的說明可以加證據那一行程式碼(`code`)和一個動作(`action`,例如「看這一行」)。
|
|
@@ -55,7 +55,7 @@ h(
|
|
|
55
55
|
- 外觀:文字顏色不變;虛線是 `--line-strong`,離字 4 px;滑過、打開或鍵盤停在上面時,虛線變強調色。游標是說明游標(help)。
|
|
56
56
|
- 滑鼠停在詞上 500 ms 才打開,只是經過不會打開;點一下立刻打開。指標移進小卡時小卡不關閉,離開 150 ms 後關閉。
|
|
57
57
|
- 鍵盤:Tab 到詞上不會打開(一路 Tab 過去不會把每張小卡都念一遍);按 Enter 打開,Esc 關閉,焦點留在詞上;打開後再按 Tab 進入小卡的動作。要 Tab 到就打開時加 `openOnFocus`。
|
|
58
|
-
- 觸控(寬度小於 600 px):點一下從畫面下方打開,和一般 Term
|
|
58
|
+
- 觸控(寬度小於 600 px):點一下從畫面下方打開,和一般 Term 相同。
|
|
59
59
|
- 螢幕閱讀器念「cookie,有說明」;小卡打開時以 `aria-describedby` 連到詞上。
|
|
60
60
|
- 小卡和一般 Term 相同(標題、說明、程式碼、動作)。
|
|
61
61
|
|
package/docs/Workbench.md
CHANGED
|
@@ -27,6 +27,7 @@ import { Workbench, useWorkbench, TreeList, IconButton, SearchField } from '@sea
|
|
|
27
27
|
```
|
|
28
28
|
|
|
29
29
|
- 外層要給高度(例如 `height: 100vh`);Workbench 填滿它。給 `storageKey` 才會記住版面。
|
|
30
|
+
- `views` 和 `defaultLayout` 可以每次繪製都是新的陣列(`render` 讀最新的 state):版面只看 view 的 `id` 和 `defaultLayout` 的內容,不必 `useMemo`。
|
|
30
31
|
- `brand` 的名稱是整頁的 `h1`,主畫面和它上方的列在 `main` 裡(名稱是 `label`,預設「編輯器」):頁面不再另放 `h1` 或 `main`。
|
|
31
32
|
- `mainBar`(36 px 的列)只放 `IconButton variant="quiet"` 或 `SegmentedControl iconOnly`;不放 40 px 的一般按鈕、輸入框、Select 或 Tabs。
|
|
32
33
|
- 主畫面裡的 CodeView 用 `header="float"`:檔名已經在麵包屑上。
|
|
@@ -109,7 +110,7 @@ React.useEffect(() => {
|
|
|
109
110
|
## 讀取目前的版面
|
|
110
111
|
|
|
111
112
|
- `useWorkbench().layout`:目前的 `WorkbenchLayout`(`side`、`panel` 兩邊各有哪些分頁,`active.side`、`active.panel` 目前的分頁,`open` 開或關,`size` 大小)。Workbench 裡面的元件會跟著重新繪製。
|
|
112
|
-
- `onLayoutChange(layout)
|
|
113
|
+
- `onLayoutChange(layout)`:第一次繪製時和之後每次改變(換分頁、移動分頁、開關區塊、改大小)都會呼叫;內容沒變時不呼叫,所以可以直接 `onLayoutChange={setLayout}` 存進頁面的 state。
|
|
113
114
|
- `ref` 的 `getLayout()`:呼叫當下的版面。
|
|
114
115
|
|
|
115
116
|
把下方面板目前的分頁寫進網址:
|
package/docs/agents.md
CHANGED
|
@@ -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.
|
|
69
|
-
<link rel="stylesheet" href="https://seanyeh77.github.io/ui-design-system/dist/0.
|
|
70
|
-
<link rel="stylesheet" href="https://seanyeh77.github.io/ui-design-system/dist/0.
|
|
68
|
+
<link rel="stylesheet" href="https://seanyeh77.github.io/ui-design-system/dist/0.48.0/fonts.css">
|
|
69
|
+
<link rel="stylesheet" href="https://seanyeh77.github.io/ui-design-system/dist/0.48.0/tokens.css">
|
|
70
|
+
<link rel="stylesheet" href="https://seanyeh77.github.io/ui-design-system/dist/0.48.0/styles.css">
|
|
71
71
|
<div id="root"></div>
|
|
72
|
-
<script src="https://seanyeh77.github.io/ui-design-system/dist/0.
|
|
72
|
+
<script src="https://seanyeh77.github.io/ui-design-system/dist/0.48.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.
|
|
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.48.0/dist/bundle.js`, `…/dist/styles.css`; the fonts at `https://cdn.jsdelivr.net/npm/@seanyeh77/tokens@0.48.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@seanyeh77/ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.48.0",
|
|
4
4
|
"description": "SeanYeh's design system: typed React components on Base UI, styled with design tokens.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Hsiu-An Yeh",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
60
|
"@base-ui/react": "^1.9.0",
|
|
61
|
-
"@seanyeh77/tokens": "^0.
|
|
61
|
+
"@seanyeh77/tokens": "^0.48.0"
|
|
62
62
|
},
|
|
63
63
|
"scripts": {
|
|
64
64
|
"build": "node scripts/theme-defaults.ts && tsdown && node scripts/postbuild.ts",
|