@seanyeh77/ui 0.47.1 → 0.47.2
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 +2 -2
- package/dist/components/DataTable/DataTable.js +13 -6
- package/dist/components/DataTable/DataTable.js.map +1 -1
- package/dist/css/DataTable.css +27 -0
- package/dist/internal/scrollHint.js +2 -1
- package/dist/internal/scrollHint.js.map +1 -1
- package/dist/styles.css +27 -0
- package/docs/DataTable.md +1 -1
- package/docs/agents.md +5 -5
- package/package.json +2 -2
package/dist/css/DataTable.css
CHANGED
|
@@ -717,6 +717,14 @@
|
|
|
717
717
|
font-weight: 600;
|
|
718
718
|
white-space: nowrap;
|
|
719
719
|
}
|
|
720
|
+
/* The bulk bar's count with, on phones, the select-all checkbox before it (the header row with its checkbox is hidden
|
|
721
|
+
there): the checkbox in the rows' checkbox column, the count where the rows' titles start. */
|
|
722
|
+
.ui-dt-bulk-lead {
|
|
723
|
+
display: flex;
|
|
724
|
+
align-items: center;
|
|
725
|
+
gap: var(--space-2);
|
|
726
|
+
min-width: 0;
|
|
727
|
+
}
|
|
720
728
|
.ui-dt-bulk-actions {
|
|
721
729
|
margin-left: auto;
|
|
722
730
|
display: flex;
|
|
@@ -900,6 +908,10 @@
|
|
|
900
908
|
width: auto;
|
|
901
909
|
min-width: 0;
|
|
902
910
|
}
|
|
911
|
+
/* Cards never scroll sideways: no fade on the right (useScrollHint also ignores a box that does not scroll). */
|
|
912
|
+
.ui-dt-scroller::after {
|
|
913
|
+
display: none;
|
|
914
|
+
}
|
|
903
915
|
/* In a Card the cards' box is the Card itself: no second shadow, a line between the toolbar and the first row. */
|
|
904
916
|
.ui-card .ui-dt-scroll {
|
|
905
917
|
box-shadow: none;
|
|
@@ -1002,12 +1014,27 @@
|
|
|
1002
1014
|
grid-row: 1;
|
|
1003
1015
|
margin: 0 var(--space-2) 0 0;
|
|
1004
1016
|
}
|
|
1017
|
+
/* The checkbox and the status sit on the title's first line, centred on it: a box one line tall (1lh, the title's
|
|
1018
|
+
line height) at the top of the row, the checkbox or Badge centred in it. As inline boxes they sat on the
|
|
1019
|
+
baseline, and the title's second line (secondary) centred the row around both lines, so they stood 4 to 8 px
|
|
1020
|
+
above the title. */
|
|
1021
|
+
.ui-dt-body .ui-dt-cell:is(.ui-dt-sel, .is-m-status) {
|
|
1022
|
+
display: flex;
|
|
1023
|
+
align-items: center;
|
|
1024
|
+
align-self: start;
|
|
1025
|
+
height: 1lh;
|
|
1026
|
+
}
|
|
1005
1027
|
.ui-dt-body .ui-dt-cell.is-m-title {
|
|
1006
1028
|
grid-column: 2;
|
|
1007
1029
|
grid-row: 1;
|
|
1030
|
+
align-self: start;
|
|
1008
1031
|
margin-top: 0;
|
|
1009
1032
|
font-weight: 600;
|
|
1010
1033
|
}
|
|
1034
|
+
/* The row's padding is the card's: the title (and its secondary line) starts at the top, level with the checkbox. */
|
|
1035
|
+
.ui-dt-body .ui-dt-cell.is-m-title > .ui-dt-stack {
|
|
1036
|
+
padding-block: 0;
|
|
1037
|
+
}
|
|
1011
1038
|
/* A title made of a name and tags in a row: the tags go to the next line instead of squeezing the name. */
|
|
1012
1039
|
.ui-dt-body .ui-dt-cell.is-m-title > :is(span, div):only-child {
|
|
1013
1040
|
flex-wrap: wrap;
|
|
@@ -18,7 +18,8 @@ function useScrollHint() {
|
|
|
18
18
|
const measure = React.useCallback(() => {
|
|
19
19
|
const el = ref.current;
|
|
20
20
|
if (!el) return;
|
|
21
|
-
const
|
|
21
|
+
const ox = getComputedStyle(el).overflowX;
|
|
22
|
+
const wide = ox !== "visible" && ox !== "clip" && el.scrollWidth > el.clientWidth + 1;
|
|
22
23
|
setOverflows(wide);
|
|
23
24
|
setMore(wide && el.scrollLeft + el.clientWidth < el.scrollWidth - 1);
|
|
24
25
|
}, []);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scrollHint.js","names":["phArrowRight"],"sources":["../../src/internal/scrollHint.tsx"],"sourcesContent":["import * as React from 'react';\nimport { Icon } from '../icons/Icon';\nimport { tr } from '../i18n';\nimport { cx, useMedia, resizeObserver } from './util';\nimport { includeIcons } from '../icons/store';\nimport phArrowRight from '../icons/ph/arrow-right';\n\nincludeIcons(phArrowRight);\n\n/** A box that may be wider than its container: whether it overflows, whether more is to the right, and whether the\n * person has scrolled yet. Used by LayerGraph and DataTable for the right-edge fade and the 「左右滑動」 hint. */\nexport function useScrollHint<E extends HTMLElement = HTMLDivElement>() {\n const ref = React.useRef<E>(null);\n const [more, setMore] = React.useState(false);\n const [scrolled, setScrolled] = React.useState(false);\n const [overflows, setOverflows] = React.useState(false);\n const measure = React.useCallback(() => {\n const el = ref.current;\n if (!el) return;\n const wide = el.scrollWidth > el.clientWidth + 1;\n setOverflows(wide);\n setMore(wide && el.scrollLeft + el.clientWidth < el.scrollWidth - 1);\n }, []);\n React.useLayoutEffect(() => {\n const el = ref.current;\n if (!el) return;\n measure();\n const ro = resizeObserver(measure);\n ro?.observe(el);\n if (el.firstElementChild) ro?.observe(el.firstElementChild);\n // Content that changes without resizing the box (a column hidden, rows replaced, text measured again) and web\n // fonts that load late change the scroll width too: measured again after each.\n let raf = 0;\n const later = () => {\n cancelAnimationFrame(raf);\n raf = requestAnimationFrame(measure);\n };\n const mo = new MutationObserver(later);\n mo.observe(el, { childList: true, subtree: true, characterData: true });\n document.fonts?.ready.then(later).catch(() => {});\n return () => {\n ro?.disconnect();\n mo.disconnect();\n cancelAnimationFrame(raf);\n };\n }, [measure]);\n const onScroll = React.useCallback(() => {\n const el = ref.current;\n // Only a sideways scroll counts: a table also scrolls down.\n if (el && el.scrollLeft > 0) setScrolled(true);\n measure();\n }, [measure]);\n return { ref, more, overflows, scrolled, onScroll, measure };\n}\n\n/** 「→ 左右滑動」 (touch) or 「→ 向右捲動」 (mouse, trackpad) under the box, right-aligned. Hidden after the first sideways\n * scroll but keeps its line, so nothing below jumps. */\nexport function ScrollHint({ show, done }: { show: boolean; done: boolean }) {\n const touch = useMedia('(pointer: coarse)');\n return show ? (\n <span className={cx('ui-scroll-hint', done && 'is-done')} aria-hidden=\"true\">\n <Icon name=\"arrow-right\" size={14} />\n {touch ? tr('左右滑動') : tr('向右捲動')}\n </span>\n ) : null;\n}\n"],"mappings":";;;;;;;;;AAOA,aAAaA,mBAAY;;;AAIzB,SAAgB,gBAAwD;CACtE,MAAM,MAAM,MAAM,OAAU,IAAI;CAChC,MAAM,CAAC,MAAM,WAAW,MAAM,SAAS,KAAK;CAC5C,MAAM,CAAC,UAAU,eAAe,MAAM,SAAS,KAAK;CACpD,MAAM,CAAC,WAAW,gBAAgB,MAAM,SAAS,KAAK;CACtD,MAAM,UAAU,MAAM,kBAAkB;EACtC,MAAM,KAAK,IAAI;EACf,IAAI,CAAC,IAAI;
|
|
1
|
+
{"version":3,"file":"scrollHint.js","names":["phArrowRight"],"sources":["../../src/internal/scrollHint.tsx"],"sourcesContent":["import * as React from 'react';\nimport { Icon } from '../icons/Icon';\nimport { tr } from '../i18n';\nimport { cx, useMedia, resizeObserver } from './util';\nimport { includeIcons } from '../icons/store';\nimport phArrowRight from '../icons/ph/arrow-right';\n\nincludeIcons(phArrowRight);\n\n/** A box that may be wider than its container: whether it overflows, whether more is to the right, and whether the\n * person has scrolled yet. Used by LayerGraph and DataTable for the right-edge fade and the 「左右滑動」 hint. */\nexport function useScrollHint<E extends HTMLElement = HTMLDivElement>() {\n const ref = React.useRef<E>(null);\n const [more, setMore] = React.useState(false);\n const [scrolled, setScrolled] = React.useState(false);\n const [overflows, setOverflows] = React.useState(false);\n const measure = React.useCallback(() => {\n const el = ref.current;\n if (!el) return;\n // Only a box that scrolls sideways can have more to the right: with overflow visible (DataTable's phone cards)\n // scrollWidth still counts content past the edge, which drew a fade and 「左右滑動」 where nothing scrolls.\n const ox = getComputedStyle(el).overflowX;\n const wide = ox !== 'visible' && ox !== 'clip' && el.scrollWidth > el.clientWidth + 1;\n setOverflows(wide);\n setMore(wide && el.scrollLeft + el.clientWidth < el.scrollWidth - 1);\n }, []);\n React.useLayoutEffect(() => {\n const el = ref.current;\n if (!el) return;\n measure();\n const ro = resizeObserver(measure);\n ro?.observe(el);\n if (el.firstElementChild) ro?.observe(el.firstElementChild);\n // Content that changes without resizing the box (a column hidden, rows replaced, text measured again) and web\n // fonts that load late change the scroll width too: measured again after each.\n let raf = 0;\n const later = () => {\n cancelAnimationFrame(raf);\n raf = requestAnimationFrame(measure);\n };\n const mo = new MutationObserver(later);\n mo.observe(el, { childList: true, subtree: true, characterData: true });\n document.fonts?.ready.then(later).catch(() => {});\n return () => {\n ro?.disconnect();\n mo.disconnect();\n cancelAnimationFrame(raf);\n };\n }, [measure]);\n const onScroll = React.useCallback(() => {\n const el = ref.current;\n // Only a sideways scroll counts: a table also scrolls down.\n if (el && el.scrollLeft > 0) setScrolled(true);\n measure();\n }, [measure]);\n return { ref, more, overflows, scrolled, onScroll, measure };\n}\n\n/** 「→ 左右滑動」 (touch) or 「→ 向右捲動」 (mouse, trackpad) under the box, right-aligned. Hidden after the first sideways\n * scroll but keeps its line, so nothing below jumps. */\nexport function ScrollHint({ show, done }: { show: boolean; done: boolean }) {\n const touch = useMedia('(pointer: coarse)');\n return show ? (\n <span className={cx('ui-scroll-hint', done && 'is-done')} aria-hidden=\"true\">\n <Icon name=\"arrow-right\" size={14} />\n {touch ? tr('左右滑動') : tr('向右捲動')}\n </span>\n ) : null;\n}\n"],"mappings":";;;;;;;;;AAOA,aAAaA,mBAAY;;;AAIzB,SAAgB,gBAAwD;CACtE,MAAM,MAAM,MAAM,OAAU,IAAI;CAChC,MAAM,CAAC,MAAM,WAAW,MAAM,SAAS,KAAK;CAC5C,MAAM,CAAC,UAAU,eAAe,MAAM,SAAS,KAAK;CACpD,MAAM,CAAC,WAAW,gBAAgB,MAAM,SAAS,KAAK;CACtD,MAAM,UAAU,MAAM,kBAAkB;EACtC,MAAM,KAAK,IAAI;EACf,IAAI,CAAC,IAAI;EAGT,MAAM,KAAK,iBAAiB,EAAE,C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N"}
|
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;
|
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/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.47.
|
|
69
|
-
<link rel="stylesheet" href="https://seanyeh77.github.io/ui-design-system/dist/0.47.
|
|
70
|
-
<link rel="stylesheet" href="https://seanyeh77.github.io/ui-design-system/dist/0.47.
|
|
68
|
+
<link rel="stylesheet" href="https://seanyeh77.github.io/ui-design-system/dist/0.47.2/fonts.css">
|
|
69
|
+
<link rel="stylesheet" href="https://seanyeh77.github.io/ui-design-system/dist/0.47.2/tokens.css">
|
|
70
|
+
<link rel="stylesheet" href="https://seanyeh77.github.io/ui-design-system/dist/0.47.2/styles.css">
|
|
71
71
|
<div id="root"></div>
|
|
72
|
-
<script src="https://seanyeh77.github.io/ui-design-system/dist/0.47.
|
|
72
|
+
<script src="https://seanyeh77.github.io/ui-design-system/dist/0.47.2/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.47.
|
|
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.2/dist/bundle.js`, `…/dist/styles.css`; the fonts at `https://cdn.jsdelivr.net/npm/@seanyeh77/tokens@0.47.2/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.47.
|
|
3
|
+
"version": "0.47.2",
|
|
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.47.
|
|
61
|
+
"@seanyeh77/tokens": "^0.47.2"
|
|
62
62
|
},
|
|
63
63
|
"scripts": {
|
|
64
64
|
"build": "node scripts/theme-defaults.ts && tsdown && node scripts/postbuild.ts",
|