@seanyeh77/ui 0.47.2 → 0.48.1

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/index.d.ts CHANGED
@@ -27,6 +27,7 @@ import { EmptyState, EmptyStateProps } from "./components/EmptyState/EmptyState.
27
27
  import { DataTableColumn, DataTableFilter, DataTableView, FilterOption, FilterValue, RangeValue, Row, RowKey, Total } from "./components/DataTable/types.js";
28
28
  import { ErrorPage, ErrorPageProps } from "./components/ErrorPage/ErrorPage.js";
29
29
  import { FileUpload, FileUploadProps, UploadFile } from "./components/FileUpload/FileUpload.js";
30
+ import { FilePicker, FilePickerOptions, useFilePicker } from "./components/FileUpload/useFilePicker.js";
30
31
  import { FormGrid, FormGridProps } from "./components/FormGrid/FormGrid.js";
31
32
  import { GraphDefs, GraphLegend, GraphLegendItem, GraphLegendProps } from "./components/Graph/Graph.js";
32
33
  import { IconButton, IconButtonHint, IconButtonProps } from "./components/IconButton/IconButton.js";
@@ -92,4 +93,4 @@ import { MOTION } from "./motion.js";
92
93
  import { ThemeSetting, divergeToken, heatToken, initTheme, pickedAccent, resetAccent, setAccent, setTheme, storedAccent, storedTheme, textOn, themePreset, themeScript } from "./theme.js";
93
94
  import { announce } from "./announce.js";
94
95
  import { Workbench, WorkbenchApi, WorkbenchHandle, WorkbenchLayout, WorkbenchProps, WorkbenchRegion, WorkbenchView, useWorkbench } from "./components/Workbench/Workbench.js";
95
- export { AccentPicker, type AccentPickerProps, ActionBar, type ActionBarAction, type ActionBarProps, AiMark, type AiMarkProps, Alert, type AlertProps, type AlertTone, AppShell, type AppShellProps, Badge, type BadgePreset, type BadgeProps, type BadgeStatus, type BadgeTone, BarChart, type BarChartProps, type BarDatum, Breadcrumb, type BreadcrumbItem, type BreadcrumbProps, Button, type ButtonProps, Calendar, type CalendarProps, Card, type CardProps, Checkbox, type CheckboxProps, type CodeLanguage, type CodeLink, CodeText, type CodeTextProps, CodeView, type CodeViewHandle, type CodeViewProps, CommandPalette, type CommandPaletteProps, type ConsoleExtra, ConsoleLayout, type ConsoleLayoutProps, type CountUnit, type CustomIcon, type DangerConfirm, DangerZone, type DangerZoneProps, DataTable, type DataTableColumn, type DataTableFilter, type DataTableProps, type DataTableView, DatePicker, type DatePickerProps, type DateRange, DateRangePicker, type DateRangePickerProps, type DayState, type Decimals, DetailList, type DetailListItem, type DetailListProps, Dialog, type DialogProps, Drawer, type DrawerProps, EmptyState, type EmptyStateProps, ErrorPage, type ErrorPageProps, type EventKind, EventTimeline, type EventTimelineProps, type FieldProps, FileUpload, type FileUploadProps, type FilterOption, type FilterValue, type FormErrors, FormGrid, type FormGridProps, GraphDefs, GraphLegend, type GraphLegendItem, type GraphLegendProps, Grid, type GridProps, type GridRatio, Icon, IconButton, type IconButtonHint, type IconButtonProps, type IconName, type IconProps, type IconSource, InlineCode, type InlineCodeProps, KpiCard, type KpiCardProps, LayerGraph, type LayerGraphEdge, type LayerGraphNode, type LayerGraphProps, type LineBand, LineChart, type LineChartProps, type LineSeries, type LineThreshold, Link, type LinkProps, LoadingBar, type LoadingBarProps, LocaleProvider, type LocaleProviderProps, LoginCard, type LoginCardProps, MOTION, Markdown, type MarkdownProps, Menu, type MenuItem, type MenuProps, Meter, type MeterProps, type MobileTab, MobileTabBar, type MobileTabBarProps, MultiSelect, type MultiSelectOption, type MultiSelectProps, type NavBrand, type NavItem, type NavSection, NotificationBell, type NotificationBellProps, type NotificationItem, type OnRef, type OpenChangeReason, type OpenStateProps, Page, PageHeader, type PageHeaderAction, type PageHeaderProps, type PageProps, type PaletteItem, type PaletteKind, Popover, type PopoverProps, ProgressBar, type ProgressBarProps, ProgressRing, type ProgressRingProps, type ProjectOption, type ProjectStatus, ProjectSwitcher, type ProjectSwitcherProps, RadioGroup, type RadioGroupProps, type RadioOption, type RangeValue, type RefHref, RelativeTime, type RelativeTimeProps, type Row, type RowKey, SearchField, type SearchFieldProps, Section, SectionGroup, type SectionGroupProps, SectionGroupToggle, type SectionGroupToggleProps, type SectionProps, SegmentedControl, type SegmentedControlProps, type SegmentedItem, type SegmentedOption, Select, type SelectOption, type SelectProps, type SettingsCategory, SettingsLayout, type SettingsLayoutProps, SettingsRow, type SettingsRowProps, SettingsSection, type SettingsSectionProps, SideNav, type SideNavProps, Skeleton, type SkeletonProps, SplitPane, type SplitPaneProps, StatusBand, type StatusBandProps, StatusLegend, type StatusSegment, Suggestion, type SuggestionProps, Switch, type SwitchProps, TOAST_DURATION, type TabItem, Tabs, type TabsProps, Tag, type TagProps, Term, type TermDef, type TermProps, type TermsMark, TextArea, type TextAreaProps, TextField, type TextFieldProps, ThemePicker, type ThemePickerProps, type ThemePreset, type ThemeSetting, TimeControl, type TimeControlProps, type TimelineEvent, type TimelineKind, Toast, type ToastAction, type ToastOptions, type ToastProps, type ToastTone, Toaster, type ToasterProps, type Token, type TokenClass, type Tokenizer, Tooltip, type TooltipProps, TopBar, type TopBarProps, type Total, Tour, type TourProps, type TourStep, TreeList, type TreeListProps, type TreeMark, type TreeNode, type UploadFile, type UseFormErrors, Workbench, type WorkbenchApi, type WorkbenchHandle, type WorkbenchLayout, type WorkbenchProps, type WorkbenchRegion, type WorkbenchView, type Zone, ZoneMap, type ZoneMapProps, addMessages, announce, consoleZoom, divergeToken, focusMain, format, heatToken, icons, initTheme, isCodeRef, pickedAccent, preloadIcons, resetAccent, safeHref, setAccent, setLocale, setTheme, storedAccent, storedTheme, subscribeLocale, tr as t, textOn, themePreset, themeScript, toast, useFormErrors, useLocale, useToast, useTour, useWorkbench };
96
+ export { AccentPicker, type AccentPickerProps, ActionBar, type ActionBarAction, type ActionBarProps, AiMark, type AiMarkProps, Alert, type AlertProps, type AlertTone, AppShell, type AppShellProps, Badge, type BadgePreset, type BadgeProps, type BadgeStatus, type BadgeTone, BarChart, type BarChartProps, type BarDatum, Breadcrumb, type BreadcrumbItem, type BreadcrumbProps, Button, type ButtonProps, Calendar, type CalendarProps, Card, type CardProps, Checkbox, type CheckboxProps, type CodeLanguage, type CodeLink, CodeText, type CodeTextProps, CodeView, type CodeViewHandle, type CodeViewProps, CommandPalette, type CommandPaletteProps, type ConsoleExtra, ConsoleLayout, type ConsoleLayoutProps, type CountUnit, type CustomIcon, type DangerConfirm, DangerZone, type DangerZoneProps, DataTable, type DataTableColumn, type DataTableFilter, type DataTableProps, type DataTableView, DatePicker, type DatePickerProps, type DateRange, DateRangePicker, type DateRangePickerProps, type DayState, type Decimals, DetailList, type DetailListItem, type DetailListProps, Dialog, type DialogProps, Drawer, type DrawerProps, EmptyState, type EmptyStateProps, ErrorPage, type ErrorPageProps, type EventKind, EventTimeline, type EventTimelineProps, type FieldProps, type FilePicker, type FilePickerOptions, FileUpload, type FileUploadProps, type FilterOption, type FilterValue, type FormErrors, FormGrid, type FormGridProps, GraphDefs, GraphLegend, type GraphLegendItem, type GraphLegendProps, Grid, type GridProps, type GridRatio, Icon, IconButton, type IconButtonHint, type IconButtonProps, type IconName, type IconProps, type IconSource, InlineCode, type InlineCodeProps, KpiCard, type KpiCardProps, LayerGraph, type LayerGraphEdge, type LayerGraphNode, type LayerGraphProps, type LineBand, LineChart, type LineChartProps, type LineSeries, type LineThreshold, Link, type LinkProps, LoadingBar, type LoadingBarProps, LocaleProvider, type LocaleProviderProps, LoginCard, type LoginCardProps, MOTION, Markdown, type MarkdownProps, Menu, type MenuItem, type MenuProps, Meter, type MeterProps, type MobileTab, MobileTabBar, type MobileTabBarProps, MultiSelect, type MultiSelectOption, type MultiSelectProps, type NavBrand, type NavItem, type NavSection, NotificationBell, type NotificationBellProps, type NotificationItem, type OnRef, type OpenChangeReason, type OpenStateProps, Page, PageHeader, type PageHeaderAction, type PageHeaderProps, type PageProps, type PaletteItem, type PaletteKind, Popover, type PopoverProps, ProgressBar, type ProgressBarProps, ProgressRing, type ProgressRingProps, type ProjectOption, type ProjectStatus, ProjectSwitcher, type ProjectSwitcherProps, RadioGroup, type RadioGroupProps, type RadioOption, type RangeValue, type RefHref, RelativeTime, type RelativeTimeProps, type Row, type RowKey, SearchField, type SearchFieldProps, Section, SectionGroup, type SectionGroupProps, SectionGroupToggle, type SectionGroupToggleProps, type SectionProps, SegmentedControl, type SegmentedControlProps, type SegmentedItem, type SegmentedOption, Select, type SelectOption, type SelectProps, type SettingsCategory, SettingsLayout, type SettingsLayoutProps, SettingsRow, type SettingsRowProps, SettingsSection, type SettingsSectionProps, SideNav, type SideNavProps, Skeleton, type SkeletonProps, SplitPane, type SplitPaneProps, StatusBand, type StatusBandProps, StatusLegend, type StatusSegment, Suggestion, type SuggestionProps, Switch, type SwitchProps, TOAST_DURATION, type TabItem, Tabs, type TabsProps, Tag, type TagProps, Term, type TermDef, type TermProps, type TermsMark, TextArea, type TextAreaProps, TextField, type TextFieldProps, ThemePicker, type ThemePickerProps, type ThemePreset, type ThemeSetting, TimeControl, type TimeControlProps, type TimelineEvent, type TimelineKind, Toast, type ToastAction, type ToastOptions, type ToastProps, type ToastTone, Toaster, type ToasterProps, type Token, type TokenClass, type Tokenizer, Tooltip, type TooltipProps, TopBar, type TopBarProps, type Total, Tour, type TourProps, type TourStep, TreeList, type TreeListProps, type TreeMark, type TreeNode, type UploadFile, type UseFormErrors, Workbench, type WorkbenchApi, type WorkbenchHandle, type WorkbenchLayout, type WorkbenchProps, type WorkbenchRegion, type WorkbenchView, type Zone, ZoneMap, type ZoneMapProps, addMessages, announce, consoleZoom, divergeToken, focusMain, format, heatToken, icons, initTheme, isCodeRef, pickedAccent, preloadIcons, resetAccent, safeHref, setAccent, setLocale, setTheme, storedAccent, storedTheme, subscribeLocale, tr as t, textOn, themePreset, themeScript, toast, useFilePicker, useFormErrors, useLocale, useToast, useTour, useWorkbench };
package/dist/index.js CHANGED
@@ -26,6 +26,7 @@ import { EmptyState } from "./components/EmptyState/EmptyState.js";
26
26
  import { ErrorPage } from "./components/ErrorPage/ErrorPage.js";
27
27
  import { format } from "./format.js";
28
28
  import { FileUpload } from "./components/FileUpload/FileUpload.js";
29
+ import { useFilePicker } from "./components/FileUpload/useFilePicker.js";
29
30
  import { FormGrid } from "./components/FormGrid/FormGrid.js";
30
31
  import { GraphDefs, GraphLegend } from "./components/Graph/Graph.js";
31
32
  import { IconButton } from "./components/IconButton/IconButton.js";
@@ -86,4 +87,4 @@ import { MOTION } from "./motion.js";
86
87
  import { divergeToken, heatToken, initTheme, pickedAccent, resetAccent, setAccent, setTheme, storedAccent, storedTheme, textOn, themePreset, themeScript } from "./theme.js";
87
88
  import { announce } from "./announce.js";
88
89
  import { Workbench, useWorkbench } from "./components/Workbench/Workbench.js";
89
- export { AccentPicker, ActionBar, AiMark, Alert, AppShell, Badge, BarChart, Breadcrumb, Button, Calendar, Card, Checkbox, CodeText, CodeView, CommandPalette, ConsoleLayout, DangerZone, DataTable, DatePicker, DateRangePicker, DetailList, Dialog, Drawer, EmptyState, ErrorPage, EventTimeline, FileUpload, FormGrid, GraphDefs, GraphLegend, Grid, Icon, IconButton, InlineCode, KpiCard, LayerGraph, LineChart, Link, LoadingBar, LocaleProvider, LoginCard, MOTION, Markdown, Menu, Meter, MobileTabBar, MultiSelect, NotificationBell, Page, PageHeader, Popover, ProgressBar, ProgressRing, ProjectSwitcher, RadioGroup, RelativeTime, SearchField, Section, SectionGroup, SectionGroupToggle, SegmentedControl, Select, SettingsLayout, SettingsRow, SettingsSection, SideNav, Skeleton, SplitPane, StatusBand, StatusLegend, Suggestion, Switch, TOAST_DURATION, Tabs, Tag, Term, TextArea, TextField, ThemePicker, TimeControl, Toast, Toaster, Tooltip, TopBar, Tour, TreeList, Workbench, ZoneMap, addMessages, announce, consoleZoom, divergeToken, focusMain, format, heatToken, icons, initTheme, isCodeRef, pickedAccent, preloadIcons, resetAccent, safeHref, setAccent, setLocale, setTheme, storedAccent, storedTheme, subscribeLocale, tr as t, textOn, themePreset, themeScript, toast, useFormErrors, useLocale, useToast, useTour, useWorkbench };
90
+ export { AccentPicker, ActionBar, AiMark, Alert, AppShell, Badge, BarChart, Breadcrumb, Button, Calendar, Card, Checkbox, CodeText, CodeView, CommandPalette, ConsoleLayout, DangerZone, DataTable, DatePicker, DateRangePicker, DetailList, Dialog, Drawer, EmptyState, ErrorPage, EventTimeline, FileUpload, FormGrid, GraphDefs, GraphLegend, Grid, Icon, IconButton, InlineCode, KpiCard, LayerGraph, LineChart, Link, LoadingBar, LocaleProvider, LoginCard, MOTION, Markdown, Menu, Meter, MobileTabBar, MultiSelect, NotificationBell, Page, PageHeader, Popover, ProgressBar, ProgressRing, ProjectSwitcher, RadioGroup, RelativeTime, SearchField, Section, SectionGroup, SectionGroupToggle, SegmentedControl, Select, SettingsLayout, SettingsRow, SettingsSection, SideNav, Skeleton, SplitPane, StatusBand, StatusLegend, Suggestion, Switch, TOAST_DURATION, Tabs, Tag, Term, TextArea, TextField, ThemePicker, TimeControl, Toast, Toaster, Tooltip, TopBar, Tour, TreeList, Workbench, ZoneMap, addMessages, announce, consoleZoom, divergeToken, focusMain, format, heatToken, icons, initTheme, isCodeRef, pickedAccent, preloadIcons, resetAccent, safeHref, setAccent, setLocale, setTheme, storedAccent, storedTheme, subscribeLocale, tr as t, textOn, themePreset, themeScript, toast, useFilePicker, useFormErrors, useLocale, useToast, useTour, useWorkbench };
package/dist/styles.css CHANGED
@@ -9038,7 +9038,7 @@ button.ui-md-link.is-row {
9038
9038
  padding: var(--space-2) var(--space-3);
9039
9039
  border-top: 1px solid var(--line);
9040
9040
  }
9041
- /* Splitters: 8 px to grab, a 1 px line; a 2 px accent line on hover (after 150 ms), while dragging and on focus. */
9041
+ /* Splitters: 8 px to grab (24 px on desktop, below), a 1 px line; a 2 px accent line on hover (after 150 ms), while dragging and on focus. */
9042
9042
  .ui-wb-split {
9043
9043
  position: absolute;
9044
9044
  z-index: var(--z-float);
@@ -9057,6 +9057,32 @@ button.ui-md-link.is-row {
9057
9057
  margin-top: -4px;
9058
9058
  cursor: row-resize;
9059
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. The side borders do the same towards the main view, between
9062
+ its bar and the bottom panel (--ui-wb-reach-top and --ui-wb-reach-bottom, set by Workbench), so they never cover the
9063
+ explorer's or the right panel's rows, the bar's buttons or the panel's tabs. */
9064
+ .ui-wb-ex > .ui-wb-split.is-v::before,
9065
+ .ui-wb-side > .ui-wb-split.is-v::before {
9066
+ content: '';
9067
+ position: absolute;
9068
+ top: var(--ui-wb-reach-top, 0);
9069
+ bottom: var(--ui-wb-reach-bottom, 0);
9070
+ width: 24px;
9071
+ }
9072
+ .ui-wb-ex > .ui-wb-split.is-v::before {
9073
+ left: 0;
9074
+ }
9075
+ .ui-wb-side > .ui-wb-split.is-v::before {
9076
+ right: 0;
9077
+ }
9078
+ .ui-wb-panel > .ui-wb-split.is-h::before {
9079
+ content: '';
9080
+ position: absolute;
9081
+ left: 0;
9082
+ right: 0;
9083
+ bottom: 0;
9084
+ height: 24px;
9085
+ }
9060
9086
  .ui-wb-split-line {
9061
9087
  position: absolute;
9062
9088
  background: transparent;
@@ -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 相同。行內不擴大觸控範圍(WCAG 2.2 行內例外)。
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
  把下方面板目前的分頁寫進網址:
@@ -132,3 +133,16 @@ React.useEffect(() => {
132
133
  `open` 是寬螢幕記下的開關。窄螢幕上疊在主畫面上的區塊、手機的合併面板是否打開不在 `layout` 裡;手機上在合併面板換分頁時,`active` 會跟著更新。
133
134
 
134
135
  外觀、鍵盤與無障礙的完整規格在 repo 的 `docs/maintaining/Workbench.md`。
136
+
137
+ ## 區塊名稱的翻譯
138
+
139
+ 區塊名稱只能用 `addMessages` 改,每個區塊兩種寫法,都不加冠詞(句子自己有 the):
140
+
141
+ - 原 key(`檔案總管`、`右側欄`、`下方面板`):單獨出現或在句首,例如 `Side bar`、`Side bar width`。
142
+ - `句中::` 加原 key:在句子中間,例如 `Hide the side bar`。普通名詞小寫,專有名詞(`Explorer`)照樣大寫。
143
+
144
+ ```ts
145
+ addMessages('en', { 右側欄: 'Outline', '句中::右側欄': 'outline' });
146
+ ```
147
+
148
+ 只給原 key 時句中也用它。
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.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">
68
+ <link rel="stylesheet" href="https://seanyeh77.github.io/ui-design-system/dist/0.48.1/fonts.css">
69
+ <link rel="stylesheet" href="https://seanyeh77.github.io/ui-design-system/dist/0.48.1/tokens.css">
70
+ <link rel="stylesheet" href="https://seanyeh77.github.io/ui-design-system/dist/0.48.1/styles.css">
71
71
  <div id="root"></div>
72
- <script src="https://seanyeh77.github.io/ui-design-system/dist/0.47.2/bundle.js"></script>
72
+ <script src="https://seanyeh77.github.io/ui-design-system/dist/0.48.1/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.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.
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.1/dist/bundle.js`, `…/dist/styles.css`; the fonts at `https://cdn.jsdelivr.net/npm/@seanyeh77/tokens@0.48.1/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.2",
3
+ "version": "0.48.1",
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.2"
61
+ "@seanyeh77/tokens": "^0.48.1"
62
62
  },
63
63
  "scripts": {
64
64
  "build": "node scripts/theme-defaults.ts && tsdown && node scripts/postbuild.ts",