@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.
- package/dist/bundle.js +19 -19
- package/dist/components/Alert/Alert.d.ts +2 -1
- package/dist/components/Alert/Alert.js +15 -17
- package/dist/components/Alert/Alert.js.map +1 -1
- package/dist/components/AppShell/AppShell.d.ts +3 -3
- package/dist/components/AppShell/AppShell.js +9 -10
- package/dist/components/AppShell/AppShell.js.map +1 -1
- package/dist/components/Badge/Badge.d.ts +4 -4
- package/dist/components/Badge/Badge.js +7 -1
- package/dist/components/Badge/Badge.js.map +1 -1
- package/dist/components/Breadcrumb/Breadcrumb.js +1 -0
- package/dist/components/Breadcrumb/Breadcrumb.js.map +1 -1
- package/dist/components/Calendar/Calendar.js +6 -2
- package/dist/components/Calendar/Calendar.js.map +1 -1
- package/dist/components/ConsoleLayout/ConsoleLayout.js +15 -12
- package/dist/components/ConsoleLayout/ConsoleLayout.js.map +1 -1
- package/dist/components/DataTable/DataTable.d.ts +8 -0
- package/dist/components/DataTable/DataTable.js +188 -34
- package/dist/components/DataTable/DataTable.js.map +1 -1
- package/dist/components/DataTable/filters.js +10 -4
- package/dist/components/DataTable/filters.js.map +1 -1
- package/dist/components/DatePicker/DatePicker.js +1 -0
- package/dist/components/DatePicker/DatePicker.js.map +1 -1
- package/dist/components/DateRangePicker/DateRangePicker.js +1 -0
- package/dist/components/DateRangePicker/DateRangePicker.js.map +1 -1
- package/dist/components/DetailList/DetailList.d.ts +8 -1
- package/dist/components/DetailList/DetailList.js +16 -2
- package/dist/components/DetailList/DetailList.js.map +1 -1
- package/dist/components/EmptyState/EmptyState.js +19 -1
- package/dist/components/EmptyState/EmptyState.js.map +1 -1
- package/dist/components/EventTimeline/EventTimeline.js +6 -3
- package/dist/components/EventTimeline/EventTimeline.js.map +1 -1
- package/dist/components/FileUpload/FileUpload.js +2 -2
- package/dist/components/FileUpload/FileUpload.js.map +1 -1
- package/dist/components/Grid/Grid.d.ts +5 -2
- package/dist/components/Grid/Grid.js +4 -3
- package/dist/components/Grid/Grid.js.map +1 -1
- package/dist/components/InlineCode/InlineCode.js +7 -6
- package/dist/components/InlineCode/InlineCode.js.map +1 -1
- package/dist/components/KpiCard/KpiCard.d.ts +6 -4
- package/dist/components/KpiCard/KpiCard.js +6 -12
- package/dist/components/KpiCard/KpiCard.js.map +1 -1
- package/dist/components/LayerGraph/LayerGraph.js +47 -13
- package/dist/components/LayerGraph/LayerGraph.js.map +1 -1
- package/dist/components/MultiSelect/MultiSelect.js +73 -45
- package/dist/components/MultiSelect/MultiSelect.js.map +1 -1
- package/dist/components/NotificationBell/NotificationBell.d.ts +6 -3
- package/dist/components/NotificationBell/NotificationBell.js +14 -3
- package/dist/components/NotificationBell/NotificationBell.js.map +1 -1
- package/dist/components/PageHeader/PageHeader.d.ts +3 -2
- package/dist/components/PageHeader/PageHeader.js +10 -1
- package/dist/components/PageHeader/PageHeader.js.map +1 -1
- package/dist/components/RelativeTime/RelativeTime.js +4 -3
- package/dist/components/RelativeTime/RelativeTime.js.map +1 -1
- package/dist/components/Select/Select.js +1 -1
- package/dist/components/Select/Select.js.map +1 -1
- package/dist/components/SettingsLayout/SettingsLayout.d.ts +6 -4
- package/dist/components/SettingsLayout/SettingsLayout.js +38 -11
- package/dist/components/SettingsLayout/SettingsLayout.js.map +1 -1
- package/dist/components/SideNav/SideNav.d.ts +10 -5
- package/dist/components/SideNav/SideNav.js +10 -6
- package/dist/components/SideNav/SideNav.js.map +1 -1
- package/dist/components/SplitPane/SplitPane.d.ts +2 -2
- package/dist/components/SplitPane/SplitPane.js +29 -9
- package/dist/components/SplitPane/SplitPane.js.map +1 -1
- package/dist/components/TextField/TextField.d.ts +8 -2
- package/dist/components/TextField/TextField.js +59 -13
- package/dist/components/TextField/TextField.js.map +1 -1
- package/dist/components/TopBar/TopBar.d.ts +2 -2
- package/dist/components/TopBar/TopBar.js.map +1 -1
- package/dist/components/Workbench/Workbench.d.ts +8 -5
- package/dist/components/Workbench/Workbench.js +184 -157
- package/dist/components/Workbench/Workbench.js.map +1 -1
- package/dist/components/ZoneMap/ZoneMap.js +4 -4
- package/dist/components/ZoneMap/ZoneMap.js.map +1 -1
- package/dist/components/useFormErrors/useFormErrors.d.ts +5 -2
- package/dist/components/useFormErrors/useFormErrors.js +10 -4
- package/dist/components/useFormErrors/useFormErrors.js.map +1 -1
- package/dist/css/AccentPicker.css +19 -0
- package/dist/css/Alert.css +30 -7
- package/dist/css/AppShell.css +12 -0
- package/dist/css/Calendar.css +7 -0
- package/dist/css/ConsoleLayout.css +3 -0
- package/dist/css/DataTable.css +70 -8
- package/dist/css/DetailList.css +11 -0
- package/dist/css/EmptyState.css +8 -0
- package/dist/css/EventTimeline.css +11 -4
- package/dist/css/Grid.css +15 -0
- package/dist/css/KpiCard.css +1 -0
- package/dist/css/LayerGraph.css +1 -1
- package/dist/css/LoadingBar.css +4 -1
- package/dist/css/LoginCard.css +1 -1
- package/dist/css/MobileTabBar.css +6 -4
- package/dist/css/MultiSelect.css +23 -3
- package/dist/css/Select.css +9 -0
- package/dist/css/SettingsLayout.css +29 -14
- package/dist/css/Tabs.css +36 -17
- package/dist/css/Toast.css +7 -0
- package/dist/css/TopBar.css +6 -3
- package/dist/css/Workbench.css +10 -5
- package/dist/css/base.css +90 -3
- package/dist/css/end.css +5 -2
- package/dist/fonts-latin.css +2 -0
- package/dist/fonts-tc.css +2 -0
- package/dist/format.d.ts +4 -3
- package/dist/format.js +13 -12
- package/dist/format.js.map +1 -1
- package/dist/i18n.js +17 -6
- package/dist/i18n.js.map +1 -1
- package/dist/icons/Icon.d.ts +2 -1
- package/dist/icons/Icon.js +4 -3
- package/dist/icons/Icon.js.map +1 -1
- package/dist/icons/all.js +23 -1
- package/dist/icons/all.js.map +1 -1
- package/dist/icons/names.d.ts +22 -0
- package/dist/icons/names.js +11 -0
- package/dist/icons/names.js.map +1 -1
- package/dist/icons/ph/credit-card.d.ts +10 -0
- package/dist/icons/ph/credit-card.js +11 -0
- package/dist/icons/ph/credit-card.js.map +1 -0
- package/dist/icons/ph/map-pin.d.ts +10 -0
- package/dist/icons/ph/map-pin.js +11 -0
- package/dist/icons/ph/map-pin.js.map +1 -0
- package/dist/icons/ph/package.d.ts +10 -0
- package/dist/icons/ph/package.js +11 -0
- package/dist/icons/ph/package.js.map +1 -0
- package/dist/icons/ph/pause.d.ts +10 -0
- package/dist/icons/ph/pause.js +11 -0
- package/dist/icons/ph/pause.js.map +1 -0
- package/dist/icons/ph/phone.d.ts +10 -0
- package/dist/icons/ph/phone.js +11 -0
- package/dist/icons/ph/phone.js.map +1 -0
- package/dist/icons/ph/play.d.ts +10 -0
- package/dist/icons/ph/play.js +11 -0
- package/dist/icons/ph/play.js.map +1 -0
- package/dist/icons/ph/prohibit.d.ts +10 -0
- package/dist/icons/ph/prohibit.js +11 -0
- package/dist/icons/ph/prohibit.js.map +1 -0
- package/dist/icons/ph/receipt.d.ts +10 -0
- package/dist/icons/ph/receipt.js +11 -0
- package/dist/icons/ph/receipt.js.map +1 -0
- package/dist/icons/ph/shopping-cart.d.ts +10 -0
- package/dist/icons/ph/shopping-cart.js +11 -0
- package/dist/icons/ph/shopping-cart.js.map +1 -0
- package/dist/icons/ph/storefront.d.ts +10 -0
- package/dist/icons/ph/storefront.js +11 -0
- package/dist/icons/ph/storefront.js.map +1 -0
- package/dist/icons/ph/truck.d.ts +10 -0
- package/dist/icons/ph/truck.js +11 -0
- package/dist/icons/ph/truck.js.map +1 -0
- package/dist/icons/store.d.ts +3 -1
- package/dist/icons/store.js +17 -12
- package/dist/icons/store.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/internal/FloatingPanel.js +5 -2
- package/dist/internal/FloatingPanel.js.map +1 -1
- package/dist/internal/clickSteps.js +11 -0
- package/dist/internal/clickSteps.js.map +1 -0
- package/dist/internal/util.js +7 -1
- package/dist/internal/util.js.map +1 -1
- package/dist/styles.css +499 -162
- package/dist/theme.d.ts +7 -0
- package/dist/theme.js +39 -15
- package/dist/theme.js.map +1 -1
- package/docs/Alert.md +1 -1
- package/docs/AppShell.md +4 -4
- package/docs/Badge.md +2 -1
- package/docs/BarChart.md +1 -1
- package/docs/Checkbox.md +2 -2
- package/docs/CodeView.md +12 -22
- package/docs/ConsoleLayout.md +1 -0
- package/docs/DataTable.md +16 -11
- package/docs/DatePicker.md +1 -1
- package/docs/DateRangePicker.md +1 -0
- package/docs/DetailList.md +12 -1
- package/docs/Drawer.md +1 -1
- package/docs/EmptyState.md +1 -0
- package/docs/EventTimeline.md +1 -1
- package/docs/Format.md +2 -1
- package/docs/Graph.md +1 -0
- package/docs/Grid.md +9 -0
- package/docs/KpiCard.md +5 -4
- package/docs/LoadingBar.md +1 -1
- package/docs/LoginCard.md +1 -1
- package/docs/Markdown.md +4 -37
- package/docs/MobileTabBar.md +1 -1
- package/docs/MultiSelect.md +3 -2
- package/docs/NotificationBell.md +2 -2
- package/docs/PageHeader.md +2 -1
- package/docs/RadioGroup.md +1 -1
- package/docs/RelativeTime.md +2 -2
- package/docs/SettingsLayout.md +5 -4
- package/docs/SideNav.md +2 -1
- package/docs/Skeleton.md +2 -2
- package/docs/SplitPane.md +3 -9
- package/docs/Tabs.md +14 -11
- package/docs/Tag.md +4 -3
- package/docs/TextField.md +2 -0
- package/docs/Toast.md +1 -1
- package/docs/TopBar.md +2 -2
- package/docs/Workbench.md +9 -6
- package/docs/agents.md +13 -13
- package/docs/data.md +2 -1
- package/docs/guidelines.md +4 -4
- package/docs/icons.md +2 -2
- package/docs/layout.md +3 -3
- package/docs/theme.md +6 -3
- package/docs/useFormErrors.md +2 -1
- package/package.json +4 -2
|
@@ -3,7 +3,7 @@ import * as React from "react";
|
|
|
3
3
|
export interface TopBarProps {
|
|
4
4
|
/** The page title, shown once: either here or as the page's own heading. */
|
|
5
5
|
title?: string;
|
|
6
|
-
/** Right after the title, e.g. a Tag 「示範資料」 with the info icon:
|
|
6
|
+
/** Right after the title, e.g. a Tag 「示範資料」 with the info icon: drawn small and muted (12 px, ink-muted). */
|
|
7
7
|
tags?: React.ReactNode;
|
|
8
8
|
/** @deprecated A breadcrumb goes at the top of the content: put `<Breadcrumb items={…} />` first in the page. */
|
|
9
9
|
breadcrumb?: BreadcrumbItem[];
|
|
@@ -13,7 +13,7 @@ export interface TopBarProps {
|
|
|
13
13
|
searchLabel?: string;
|
|
14
14
|
/** Right side: NotificationBell, ProjectSwitcher, the account menu. */
|
|
15
15
|
children?: React.ReactNode;
|
|
16
|
-
/** A menu button at the left that opens the navigation (AppShell from 600 to
|
|
16
|
+
/** A menu button at the left that opens the navigation (AppShell from 600 to 1024 px). */
|
|
17
17
|
onMenu?: () => void;
|
|
18
18
|
/** Extra class on the root element. */
|
|
19
19
|
className?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TopBar.js","names":["phListBullets","phMagnifyingGlass"],"sources":["../../../src/components/TopBar/TopBar.tsx"],"sourcesContent":["import type * as React from 'react';\nimport { tr } from '../../i18n';\nimport { Icon } from '../../icons/Icon';\nimport { IS_MAC, SHORTCUT, TOUCH_ONLY, cx, useMedia } from '../../internal/util';\nimport { devWarn } from '../../internal/dev';\nimport { Breadcrumb, type BreadcrumbItem } from '../Breadcrumb/Breadcrumb';\nimport { IconButton } from '../IconButton/IconButton';\nimport { includeIcons } from '../../icons/store';\nimport phListBullets from '../../icons/ph/list-bullets';\nimport phMagnifyingGlass from '../../icons/ph/magnifying-glass';\n\nincludeIcons(phListBullets, phMagnifyingGlass);\n\nexport interface TopBarProps {\n /** The page title, shown once: either here or as the page's own heading. */\n title?: string;\n /** Right after the title, e.g. a Tag 「示範資料」 with the info icon:
|
|
1
|
+
{"version":3,"file":"TopBar.js","names":["phListBullets","phMagnifyingGlass"],"sources":["../../../src/components/TopBar/TopBar.tsx"],"sourcesContent":["import type * as React from 'react';\nimport { tr } from '../../i18n';\nimport { Icon } from '../../icons/Icon';\nimport { IS_MAC, SHORTCUT, TOUCH_ONLY, cx, useMedia } from '../../internal/util';\nimport { devWarn } from '../../internal/dev';\nimport { Breadcrumb, type BreadcrumbItem } from '../Breadcrumb/Breadcrumb';\nimport { IconButton } from '../IconButton/IconButton';\nimport { includeIcons } from '../../icons/store';\nimport phListBullets from '../../icons/ph/list-bullets';\nimport phMagnifyingGlass from '../../icons/ph/magnifying-glass';\n\nincludeIcons(phListBullets, phMagnifyingGlass);\n\nexport interface TopBarProps {\n /** The page title, shown once: either here or as the page's own heading. */\n title?: string;\n /** Right after the title, e.g. a Tag 「示範資料」 with the info icon: drawn small and muted (12 px, ink-muted). */\n tags?: React.ReactNode;\n /** @deprecated A breadcrumb goes at the top of the content: put `<Breadcrumb items={…} />` first in the page. */\n breadcrumb?: BreadcrumbItem[];\n /** Opens search (CommandPalette). false hides the search entry. */\n onSearch?: (() => void) | false;\n /** Default 「搜尋」. */\n searchLabel?: string;\n /** Right side: NotificationBell, ProjectSwitcher, the account menu. */\n children?: React.ReactNode;\n /** A menu button at the left that opens the navigation (AppShell from 600 to 1024 px). */\n onMenu?: () => void;\n /** Extra class on the root element. */\n className?: string;\n}\n\n/** The bar at the top of a dashboard page: title or breadcrumb on the left, search and tools on the right. */\nexport function TopBar({ title, tags, breadcrumb, onSearch, searchLabel, children, onMenu, className }: TopBarProps) {\n const touch = useMedia(TOUCH_ONLY);\n devWarn(\n breadcrumb,\n 'TopBar',\n '`breadcrumb` is deprecated: a breadcrumb in the top bar repeats the page title. Put <Breadcrumb items={…} /> first in the page content instead.',\n );\n return (\n <header className={cx('ui-topbar', className)}>\n {onMenu ? <IconButton className=\"ui-topbar-menu\" icon=\"list-bullets\" label={tr('開啟導覽')} onClick={onMenu} /> : null}\n {title ? <h1 className=\"ui-topbar-title\">{title}</h1> : null}\n {tags ? <div className=\"ui-topbar-tags\">{tags}</div> : null}\n {breadcrumb ? <Breadcrumb items={breadcrumb} /> : null}\n <div className=\"ui-topbar-end\">\n {onSearch !== false ? (\n <>\n <button type=\"button\" className=\"ui-search\" data-tour=\"search\" onClick={onSearch} aria-keyshortcuts={IS_MAC ? 'Meta+K' : 'Control+K'}>\n <Icon name=\"magnifying-glass\" size={16} />\n <span>{searchLabel || tr('搜尋')}</span>\n {/* No keyboard on a touch screen: no shortcut to show. */}\n {touch ? null : <kbd>{SHORTCUT}</kbd>}\n </button>\n <IconButton\n className=\"ui-search-icon\"\n data-tour=\"search\"\n icon=\"magnifying-glass\"\n label={touch ? tr('搜尋') : tr('搜尋({k})', { k: SHORTCUT })}\n onClick={onSearch}\n />\n </>\n ) : null}\n {children}\n </div>\n </header>\n );\n}\n"],"mappings":";;;;;;;;;;;;AAWA,aAAaA,sBAAeC,wBAAiB;;AAsB7C,SAAgB,OAAO,EAAE,OAAO,MAAM,YAAY,UAAU,aAAa,UAAU,QAAQ,aAA0B;CACnH,MAAM,QAAQ,SAAS,UAAU;CACjC,QACE,YACA,UACA,iJACF;CACA,OACE,qBAAC,UAAD;EAAQ,WAAW,GAAG,aAAa,SAAS;EAA5C,UAAA;GACG,SAAS,oBAAC,YAAD;IAAY,WAAU;IAAiB,MAAK;IAAe,OAAO,GAAG,MAAM;IAAG,SAAS;GAAS,CAAA,IAAI;GAC7G,QAAQ,oBAAC,MAAD;IAAI,WAAU;IAAmB,UAAA;GAAU,CAAA,IAAI;GACvD,OAAO,oBAAC,OAAD;IAAK,WAAU;IAAkB,UAAA;GAAU,CAAA,IAAI;GACtD,aAAa,oBAAC,YAAD,EAAY,OAAO,WAAa,CAAA,IAAI;GAClD,qBAAC,OAAD;IAAK,WAAU;IAAf,UAAA,CACG,aAAa,QACZ,qBAAA,UAAA,EAAA,UAAA,CACE,qBAAC,UAAD;KAAQ,MAAK;KAAS,WAAU;KAAY,aAAU;KAAS,SAAS;KAAU,qBAAmB,SAAS,WAAW;KAAzH,UAAA;MACE,oBAAC,MAAD;OAAM,MAAK;OAAmB,MAAM;MAAK,CAAA;MACzC,oBAAC,QAAD,EAAA,UAAO,eAAe,GAAG,IAAI,EAAQ,CAAA;MAEpC,QAAQ,OAAO,oBAAC,OAAD,EAAA,UAAM,SAAc,CAAA;KAC9B;IACR,CAAA,GAAA,oBAAC,YAAD;KACE,WAAU;KACV,aAAU;KACV,MAAK;KACL,OAAO,QAAQ,GAAG,IAAI,IAAI,GAAG,WAAW,EAAE,GAAG,SAAS,CAAC;KACvD,SAAS;IACV,CAAA,CACD,EAAA,CAAA,IACA,MACH,QACE;;EACC;;AAEZ"}
|
|
@@ -11,7 +11,7 @@ export interface WorkbenchView {
|
|
|
11
11
|
/** Something worth a look (new problems): a dot on the tab, and on the region's top-bar button while it is closed. */
|
|
12
12
|
attention?: boolean;
|
|
13
13
|
}
|
|
14
|
-
/** Where each view sits and what is open; kept in localStorage under 「ui-workbench:」 +
|
|
14
|
+
/** Where each view sits and what is open; kept in localStorage under 「ui-workbench:」 + storageKey. */
|
|
15
15
|
export interface WorkbenchLayout {
|
|
16
16
|
side: string[];
|
|
17
17
|
panel: string[];
|
|
@@ -23,9 +23,12 @@ export interface WorkbenchLayout {
|
|
|
23
23
|
size: Record<WorkbenchRegion, number>;
|
|
24
24
|
}
|
|
25
25
|
export interface WorkbenchProps {
|
|
26
|
-
/**
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
/** Remembers the layout in localStorage under 「ui-workbench:」 + this name, one per page such as 'app'. Without it
|
|
27
|
+
* the layout lasts until the page reloads. */
|
|
28
|
+
storageKey?: string;
|
|
29
|
+
/** @deprecated Use `storageKey` (same stored data). */
|
|
30
|
+
id?: string;
|
|
31
|
+
/** Product at the top left, the page's h1. The name is hidden on phones (still read as the heading); the mark stays. */
|
|
29
32
|
brand?: {
|
|
30
33
|
mark?: React.ReactNode;
|
|
31
34
|
name: string;
|
|
@@ -63,7 +66,7 @@ export interface WorkbenchProps {
|
|
|
63
66
|
};
|
|
64
67
|
/** The main view: a diagram, a document or code. */
|
|
65
68
|
children?: React.ReactNode;
|
|
66
|
-
/** Accessible name of the
|
|
69
|
+
/** Accessible name of the main landmark (the main view and the bar above it). Default 「編輯器」. */
|
|
67
70
|
label?: string;
|
|
68
71
|
/** Extra class on the root element. */
|
|
69
72
|
className?: string;
|
|
@@ -6,6 +6,8 @@ import { Icon } from "../../icons/Icon.js";
|
|
|
6
6
|
import { IS_MAC, cx, resizeObserver } from "../../internal/util.js";
|
|
7
7
|
import { readStored, useStored } from "../../internal/stored.js";
|
|
8
8
|
import { devWarn } from "../../internal/dev.js";
|
|
9
|
+
import { announce } from "../../announce.js";
|
|
10
|
+
import { nextPreset } from "../../internal/clickSteps.js";
|
|
9
11
|
import { tr } from "../../i18n.js";
|
|
10
12
|
import { dropTransition } from "../../motion.js";
|
|
11
13
|
import { includeIcons } from "../../icons/store.js";
|
|
@@ -99,11 +101,17 @@ function restore(raw, def) {
|
|
|
99
101
|
}
|
|
100
102
|
const clamp = (v, lo, hi) => Math.max(lo, Math.min(hi, Math.round(v)));
|
|
101
103
|
const inField = (t) => t instanceof HTMLElement && (t.isContentEditable || /^(INPUT|TEXTAREA|SELECT)$/.test(t.tagName));
|
|
102
|
-
/** A draggable border between two regions: role="separator", arrows 16 px, Shift 64 px, Home/End, double-click resets.
|
|
104
|
+
/** A draggable border between two regions: role="separator", arrows 16 px, Shift 64 px, Home/End, double-click resets.
|
|
105
|
+
* A click without dragging (WCAG 2.5.7) steps through the narrowest size, the default and 1.5 times the default. */
|
|
103
106
|
function Splitter(p) {
|
|
104
107
|
const start = React.useRef(null);
|
|
105
108
|
const [on, setOn] = React.useState(false);
|
|
106
109
|
const pos = (e) => p.vertical ? e.clientX : e.clientY;
|
|
110
|
+
const end = () => {
|
|
111
|
+
start.current = null;
|
|
112
|
+
setOn(false);
|
|
113
|
+
p.onDrag(false);
|
|
114
|
+
};
|
|
107
115
|
return /* @__PURE__ */ jsx("div", {
|
|
108
116
|
className: cx("ui-wb-split", p.vertical ? "is-v" : "is-h", on && "is-on"),
|
|
109
117
|
role: "separator",
|
|
@@ -112,31 +120,42 @@ function Splitter(p) {
|
|
|
112
120
|
"aria-valuenow": p.value,
|
|
113
121
|
"aria-valuemin": p.min,
|
|
114
122
|
"aria-valuemax": p.max,
|
|
123
|
+
"aria-description": tr("拖曳或按方向鍵調整;按一下切換預設大小,按兩下還原"),
|
|
115
124
|
tabIndex: 0,
|
|
116
125
|
style: p.style,
|
|
117
126
|
onPointerDown: (e) => {
|
|
127
|
+
if (e.button !== 0) return;
|
|
118
128
|
e.currentTarget.setPointerCapture?.(e.pointerId);
|
|
119
129
|
start.current = {
|
|
120
130
|
at: pos(e),
|
|
121
|
-
v: p.value
|
|
131
|
+
v: p.value,
|
|
132
|
+
moved: false
|
|
122
133
|
};
|
|
123
134
|
setOn(true);
|
|
124
135
|
p.onDrag(true);
|
|
125
136
|
},
|
|
126
137
|
onPointerMove: (e) => {
|
|
127
138
|
const s = start.current;
|
|
128
|
-
if (s
|
|
139
|
+
if (!s || !s.moved && Math.abs(pos(e) - s.at) < 4) return;
|
|
140
|
+
s.moved = true;
|
|
141
|
+
p.onChange(clamp(s.v + (pos(e) - s.at) * p.grow, p.min, p.max));
|
|
129
142
|
},
|
|
130
143
|
onPointerUp: () => {
|
|
131
|
-
start.current
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
p.
|
|
144
|
+
const clicked = start.current && !start.current.moved;
|
|
145
|
+
end();
|
|
146
|
+
if (!clicked) return;
|
|
147
|
+
const v = clamp(nextPreset(p.value, [
|
|
148
|
+
p.min,
|
|
149
|
+
p.def,
|
|
150
|
+
p.def * 1.5
|
|
151
|
+
]), p.min, p.max);
|
|
152
|
+
p.onChange(v);
|
|
153
|
+
announce(tr("{label} {n} px", {
|
|
154
|
+
label: p.label,
|
|
155
|
+
n: v
|
|
156
|
+
}));
|
|
139
157
|
},
|
|
158
|
+
onPointerCancel: end,
|
|
140
159
|
onDoubleClick: p.onReset,
|
|
141
160
|
onKeyDown: (e) => {
|
|
142
161
|
const step = e.shiftKey ? 64 : STEP;
|
|
@@ -458,11 +477,16 @@ function Pane({ view, onSwipe }) {
|
|
|
458
477
|
function Workbench({ ref, ...p }) {
|
|
459
478
|
const views = React.useMemo(() => p.views ?? [], [p.views]);
|
|
460
479
|
const byId = React.useMemo(() => Object.fromEntries(views.map((v) => [v.id, v])), [views]);
|
|
461
|
-
|
|
480
|
+
devWarn(p.id !== void 0 && p.storageKey === void 0, "Workbench", "`id` is deprecated. Pass storageKey instead: the same name keeps the stored layout.");
|
|
481
|
+
const name = p.storageKey ?? p.id;
|
|
482
|
+
const key = name ? "ui-workbench:" + name : void 0;
|
|
462
483
|
const def = React.useMemo(() => defaults(views, p.defaultLayout), [views, p.defaultLayout]);
|
|
463
484
|
const parseLayout = React.useCallback((raw) => restore(raw, def), [def]);
|
|
464
|
-
const [
|
|
485
|
+
const [stored, saveLay] = useStored(key, parseLayout, def);
|
|
486
|
+
const [mem, setMem] = React.useState(null);
|
|
487
|
+
const lay = key ? stored : mem ?? def;
|
|
465
488
|
const setLay = React.useCallback((u) => {
|
|
489
|
+
if (!key) return setMem((m) => typeof u === "function" ? u(m ?? def) : u);
|
|
466
490
|
const raw = readStored(key);
|
|
467
491
|
const cur = raw ? restore(raw, def) : def;
|
|
468
492
|
saveLay(typeof u === "function" ? u(cur) : u);
|
|
@@ -527,7 +551,8 @@ function Workbench({ ref, ...p }) {
|
|
|
527
551
|
const sideW = phone ? w : Math.min(clamp(lay.size.side, LIM.side[0], LIM.side[1]), w - 48);
|
|
528
552
|
const panelH = clamp(lay.size.panel, LIM.panel[0], panelMax);
|
|
529
553
|
const sheetMax = Math.round(bodyH * .75);
|
|
530
|
-
const
|
|
554
|
+
const sheetDefault = clamp(bodyH * .45, 120, Math.max(120, sheetMax));
|
|
555
|
+
const sheetSize = clamp(sheetH ?? sheetDefault, 120, Math.max(120, sheetMax));
|
|
531
556
|
const exOpen = exOverlay ? ov.explorer : lay.open.explorer;
|
|
532
557
|
const sideHas = lay.side.length > 0;
|
|
533
558
|
const panelHas = lay.panel.length > 0;
|
|
@@ -852,20 +877,22 @@ function Workbench({ ref, ...p }) {
|
|
|
852
877
|
children: /* @__PURE__ */ jsxs("div", {
|
|
853
878
|
ref: root,
|
|
854
879
|
className: cx("ui-wb", phone && "is-phone", sizing && "is-sizing", p.className),
|
|
855
|
-
role: "group",
|
|
856
|
-
"aria-label": p.label ?? tr("編輯器"),
|
|
857
880
|
children: [/* @__PURE__ */ jsxs("header", {
|
|
858
881
|
className: "ui-wb-top",
|
|
859
882
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
860
883
|
className: "ui-wb-top-l",
|
|
861
|
-
children: [toggleBtn("explorer", exOpen, false), brand ?
|
|
862
|
-
className: "ui-wb-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
884
|
+
children: [toggleBtn("explorer", exOpen, false), brand ? /* @__PURE__ */ jsx("h1", {
|
|
885
|
+
className: "ui-wb-title",
|
|
886
|
+
children: brand.href ? /* @__PURE__ */ jsx("a", {
|
|
887
|
+
className: "ui-wb-brand",
|
|
888
|
+
href: brand.href,
|
|
889
|
+
"aria-label": phone ? brand.name : void 0,
|
|
890
|
+
children: brandInner
|
|
891
|
+
}) : /* @__PURE__ */ jsx("span", {
|
|
892
|
+
className: "ui-wb-brand",
|
|
893
|
+
"aria-label": phone ? brand.name : void 0,
|
|
894
|
+
children: brandInner
|
|
895
|
+
})
|
|
869
896
|
}) : null]
|
|
870
897
|
}), /* @__PURE__ */ jsxs("div", {
|
|
871
898
|
className: "ui-wb-top-r",
|
|
@@ -882,160 +909,159 @@ function Workbench({ ref, ...p }) {
|
|
|
882
909
|
}), /* @__PURE__ */ jsxs("div", {
|
|
883
910
|
className: "ui-wb-body",
|
|
884
911
|
children: [
|
|
885
|
-
|
|
886
|
-
className: "ui-wb-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
912
|
+
/* @__PURE__ */ jsxs("main", {
|
|
913
|
+
className: "ui-wb-mainwrap",
|
|
914
|
+
"aria-label": p.label ?? tr("編輯器"),
|
|
915
|
+
children: [hasBar ? /* @__PURE__ */ jsxs("div", {
|
|
916
|
+
className: "ui-wb-mainbar",
|
|
917
|
+
style: {
|
|
918
|
+
left: mainL,
|
|
919
|
+
right: mainR
|
|
920
|
+
},
|
|
921
|
+
children: [p.crumbs?.length ? /* @__PURE__ */ jsx(Breadcrumb, {
|
|
922
|
+
className: "ui-wb-crumbs",
|
|
923
|
+
items: p.crumbs
|
|
924
|
+
}) : /* @__PURE__ */ jsx("span", { className: "ui-wb-mainbar-fill" }), p.mainBar ? /* @__PURE__ */ jsx("div", {
|
|
925
|
+
className: "ui-wb-mainbar-btns",
|
|
926
|
+
children: p.mainBar
|
|
927
|
+
}) : null]
|
|
928
|
+
}) : null, /* @__PURE__ */ jsx("div", {
|
|
929
|
+
className: "ui-wb-main",
|
|
930
|
+
style: {
|
|
931
|
+
left: mainL,
|
|
932
|
+
right: mainR,
|
|
933
|
+
bottom: mainB,
|
|
934
|
+
top: hasBar ? BAR : 0
|
|
935
|
+
},
|
|
936
|
+
children: p.children
|
|
937
|
+
})]
|
|
938
|
+
}),
|
|
939
|
+
p.explorer || p.explorerHead || p.explorerFoot || filter ? /* @__PURE__ */ jsxs(Fragment, { children: [exOverlay ? /* @__PURE__ */ jsx("button", {
|
|
940
|
+
type: "button",
|
|
941
|
+
tabIndex: -1,
|
|
942
|
+
className: cx("ui-wb-scrim", exOpen && "is-open"),
|
|
943
|
+
"aria-label": tr("關閉{region}", { region: regionName.explorer }),
|
|
944
|
+
onClick: () => setOv((o) => ({
|
|
945
|
+
...o,
|
|
946
|
+
explorer: false
|
|
947
|
+
}))
|
|
948
|
+
}) : null, /* @__PURE__ */ jsxs("aside", {
|
|
949
|
+
className: cx("ui-wb-ex", exOverlay ? "is-drawer" : "is-docked", exOpen ? "is-open" : "is-shut"),
|
|
950
|
+
style: { width: exW },
|
|
951
|
+
"aria-label": regionName.explorer,
|
|
952
|
+
inert: !exOpen,
|
|
953
|
+
children: [
|
|
954
|
+
filter ? /* @__PURE__ */ jsx("div", {
|
|
955
|
+
className: "ui-wb-exfilter",
|
|
956
|
+
children: /* @__PURE__ */ jsx(SearchField, {
|
|
957
|
+
value: filter.value,
|
|
958
|
+
onChange: filter.onChange,
|
|
959
|
+
label: filter.label ?? tr("篩選"),
|
|
960
|
+
placeholder: filter.label ?? tr("篩選")
|
|
961
|
+
})
|
|
962
|
+
}) : null,
|
|
963
|
+
p.explorerHead ? /* @__PURE__ */ jsx("div", {
|
|
964
|
+
className: "ui-wb-exhead",
|
|
965
|
+
children: p.explorerHead
|
|
966
|
+
}) : null,
|
|
967
|
+
/* @__PURE__ */ jsx("div", {
|
|
968
|
+
className: "ui-wb-exbody",
|
|
969
|
+
children: p.explorer
|
|
970
|
+
}),
|
|
971
|
+
p.explorerFoot ? /* @__PURE__ */ jsx("div", {
|
|
972
|
+
className: "ui-wb-exfoot",
|
|
973
|
+
children: p.explorerFoot
|
|
974
|
+
}) : null,
|
|
975
|
+
exDocked ? /* @__PURE__ */ jsx(Splitter, {
|
|
976
|
+
label: tr("{region}寬度", { region: regionName.explorer }),
|
|
977
|
+
vertical: true,
|
|
978
|
+
grow: 1,
|
|
979
|
+
value: exW,
|
|
980
|
+
min: LIM.explorer[0],
|
|
981
|
+
max: LIM.explorer[1],
|
|
982
|
+
def: def.size.explorer,
|
|
983
|
+
onChange: (v) => update((l) => ({
|
|
984
|
+
...l,
|
|
985
|
+
size: {
|
|
986
|
+
...l.size,
|
|
987
|
+
explorer: v
|
|
988
|
+
}
|
|
989
|
+
})),
|
|
990
|
+
onReset: () => update((l) => ({
|
|
991
|
+
...l,
|
|
992
|
+
size: {
|
|
993
|
+
...l.size,
|
|
994
|
+
explorer: def.size.explorer
|
|
995
|
+
}
|
|
996
|
+
})),
|
|
997
|
+
onDrag: setSizing,
|
|
998
|
+
style: { left: exW }
|
|
999
|
+
}) : null
|
|
1000
|
+
]
|
|
1001
|
+
})] }) : null,
|
|
1002
|
+
!phone && panelHas ? /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs("section", {
|
|
1003
|
+
className: cx("ui-wb-panel", panelOpen ? "is-open" : "is-shut", drag?.over?.region === "panel" && "is-dropping"),
|
|
901
1004
|
style: {
|
|
902
1005
|
left: mainL,
|
|
903
1006
|
right: mainR,
|
|
904
|
-
|
|
905
|
-
top: hasBar ? BAR : 0
|
|
1007
|
+
height: panelH
|
|
906
1008
|
},
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
}))
|
|
919
|
-
}) : null,
|
|
920
|
-
/* @__PURE__ */ jsxs("aside", {
|
|
921
|
-
className: cx("ui-wb-ex", exOverlay ? "is-drawer" : "is-docked", exOpen ? "is-open" : "is-shut"),
|
|
922
|
-
style: { width: exW },
|
|
923
|
-
"aria-label": regionName.explorer,
|
|
924
|
-
inert: !exOpen,
|
|
925
|
-
children: [
|
|
926
|
-
filter ? /* @__PURE__ */ jsx("div", {
|
|
927
|
-
className: "ui-wb-exfilter",
|
|
928
|
-
children: /* @__PURE__ */ jsx(SearchField, {
|
|
929
|
-
value: filter.value,
|
|
930
|
-
onChange: filter.onChange,
|
|
931
|
-
label: filter.label ?? tr("篩選"),
|
|
932
|
-
placeholder: filter.label ?? tr("篩選")
|
|
933
|
-
})
|
|
934
|
-
}) : null,
|
|
935
|
-
p.explorerHead ? /* @__PURE__ */ jsx("div", {
|
|
936
|
-
className: "ui-wb-exhead",
|
|
937
|
-
children: p.explorerHead
|
|
938
|
-
}) : null,
|
|
939
|
-
/* @__PURE__ */ jsx("div", {
|
|
940
|
-
className: "ui-wb-exbody",
|
|
941
|
-
children: p.explorer
|
|
942
|
-
}),
|
|
943
|
-
p.explorerFoot ? /* @__PURE__ */ jsx("div", {
|
|
944
|
-
className: "ui-wb-exfoot",
|
|
945
|
-
children: p.explorerFoot
|
|
946
|
-
}) : null
|
|
947
|
-
]
|
|
948
|
-
}),
|
|
949
|
-
exDocked ? /* @__PURE__ */ jsx(Splitter, {
|
|
950
|
-
label: tr("{region}寬度", { region: regionName.explorer }),
|
|
951
|
-
vertical: true,
|
|
952
|
-
grow: 1,
|
|
953
|
-
value: exW,
|
|
954
|
-
min: LIM.explorer[0],
|
|
955
|
-
max: LIM.explorer[1],
|
|
1009
|
+
"aria-label": regionName.panel,
|
|
1010
|
+
inert: !panelOpen,
|
|
1011
|
+
...regionDrop("panel"),
|
|
1012
|
+
children: [regionBox("panel"), panelOpen ? /* @__PURE__ */ jsx(Splitter, {
|
|
1013
|
+
label: tr("{region}高度", { region: regionName.panel }),
|
|
1014
|
+
vertical: false,
|
|
1015
|
+
grow: -1,
|
|
1016
|
+
value: panelH,
|
|
1017
|
+
min: LIM.panel[0],
|
|
1018
|
+
max: panelMax,
|
|
1019
|
+
def: def.size.panel,
|
|
956
1020
|
onChange: (v) => update((l) => ({
|
|
957
1021
|
...l,
|
|
958
1022
|
size: {
|
|
959
1023
|
...l.size,
|
|
960
|
-
|
|
1024
|
+
panel: v
|
|
961
1025
|
}
|
|
962
1026
|
})),
|
|
963
1027
|
onReset: () => update((l) => ({
|
|
964
1028
|
...l,
|
|
965
1029
|
size: {
|
|
966
1030
|
...l.size,
|
|
967
|
-
|
|
1031
|
+
panel: def.size.panel
|
|
968
1032
|
}
|
|
969
1033
|
})),
|
|
970
1034
|
onDrag: setSizing,
|
|
971
|
-
style: {
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
className: cx("ui-wb-panel", panelOpen ? "is-open" : "is-shut", drag?.over?.region === "panel" && "is-dropping"),
|
|
976
|
-
style: {
|
|
977
|
-
left: mainL,
|
|
978
|
-
right: mainR,
|
|
979
|
-
height: panelH
|
|
980
|
-
},
|
|
981
|
-
"aria-label": regionName.panel,
|
|
982
|
-
inert: !panelOpen,
|
|
983
|
-
...regionDrop("panel"),
|
|
984
|
-
children: regionBox("panel")
|
|
985
|
-
}), panelOpen ? /* @__PURE__ */ jsx(Splitter, {
|
|
986
|
-
label: tr("{region}高度", { region: regionName.panel }),
|
|
987
|
-
vertical: false,
|
|
988
|
-
grow: -1,
|
|
989
|
-
value: panelH,
|
|
990
|
-
min: LIM.panel[0],
|
|
991
|
-
max: panelMax,
|
|
992
|
-
onChange: (v) => update((l) => ({
|
|
993
|
-
...l,
|
|
994
|
-
size: {
|
|
995
|
-
...l.size,
|
|
996
|
-
panel: v
|
|
1035
|
+
style: {
|
|
1036
|
+
left: 0,
|
|
1037
|
+
right: 0,
|
|
1038
|
+
top: -1
|
|
997
1039
|
}
|
|
998
|
-
})
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
}
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
tabIndex: -1,
|
|
1017
|
-
className: cx("ui-wb-scrim", sideOpen && "is-open"),
|
|
1018
|
-
"aria-label": tr("關閉{region}", { region: regionName.side }),
|
|
1019
|
-
onClick: () => setOv((o) => ({
|
|
1020
|
-
...o,
|
|
1021
|
-
side: false
|
|
1022
|
-
}))
|
|
1023
|
-
}) : null,
|
|
1024
|
-
/* @__PURE__ */ jsx("aside", {
|
|
1025
|
-
className: cx("ui-wb-side", sideOverlay ? "is-drawer" : "is-docked", sideOpen ? "is-open" : "is-shut", drag?.over?.region === "side" && "is-dropping"),
|
|
1026
|
-
style: { width: sideW },
|
|
1027
|
-
"aria-label": regionName.side,
|
|
1028
|
-
inert: !sideOpen,
|
|
1029
|
-
...regionDrop("side"),
|
|
1030
|
-
children: regionBox("side")
|
|
1031
|
-
}),
|
|
1032
|
-
sideDocked ? /* @__PURE__ */ jsx(Splitter, {
|
|
1040
|
+
}) : null]
|
|
1041
|
+
}) }) : null,
|
|
1042
|
+
!phone && sideHas ? /* @__PURE__ */ jsxs(Fragment, { children: [sideOverlay ? /* @__PURE__ */ jsx("button", {
|
|
1043
|
+
type: "button",
|
|
1044
|
+
tabIndex: -1,
|
|
1045
|
+
className: cx("ui-wb-scrim", sideOpen && "is-open"),
|
|
1046
|
+
"aria-label": tr("關閉{region}", { region: regionName.side }),
|
|
1047
|
+
onClick: () => setOv((o) => ({
|
|
1048
|
+
...o,
|
|
1049
|
+
side: false
|
|
1050
|
+
}))
|
|
1051
|
+
}) : null, /* @__PURE__ */ jsxs("aside", {
|
|
1052
|
+
className: cx("ui-wb-side", sideOverlay ? "is-drawer" : "is-docked", sideOpen ? "is-open" : "is-shut", drag?.over?.region === "side" && "is-dropping"),
|
|
1053
|
+
style: { width: sideW },
|
|
1054
|
+
"aria-label": regionName.side,
|
|
1055
|
+
inert: !sideOpen,
|
|
1056
|
+
...regionDrop("side"),
|
|
1057
|
+
children: [regionBox("side"), sideDocked ? /* @__PURE__ */ jsx(Splitter, {
|
|
1033
1058
|
label: tr("{region}寬度", { region: regionName.side }),
|
|
1034
1059
|
vertical: true,
|
|
1035
1060
|
grow: -1,
|
|
1036
1061
|
value: sideW,
|
|
1037
1062
|
min: LIM.side[0],
|
|
1038
1063
|
max: LIM.side[1],
|
|
1064
|
+
def: def.size.side,
|
|
1039
1065
|
onChange: (v) => update((l) => ({
|
|
1040
1066
|
...l,
|
|
1041
1067
|
size: {
|
|
@@ -1051,9 +1077,9 @@ function Workbench({ ref, ...p }) {
|
|
|
1051
1077
|
}
|
|
1052
1078
|
})),
|
|
1053
1079
|
onDrag: setSizing,
|
|
1054
|
-
style: {
|
|
1055
|
-
}) : null
|
|
1056
|
-
] }) : null,
|
|
1080
|
+
style: { left: -1 }
|
|
1081
|
+
}) : null]
|
|
1082
|
+
})] }) : null,
|
|
1057
1083
|
showDropSide ? /* @__PURE__ */ jsx("div", {
|
|
1058
1084
|
className: cx("ui-wb-dropzone is-side", drag?.over?.region === "side" && "is-over"),
|
|
1059
1085
|
style: { bottom: (panelOpen ? panelH : 0) + 8 },
|
|
@@ -1082,6 +1108,7 @@ function Workbench({ ref, ...p }) {
|
|
|
1082
1108
|
value: sheetSize,
|
|
1083
1109
|
min: 120,
|
|
1084
1110
|
max: Math.max(120, sheetMax),
|
|
1111
|
+
def: sheetDefault,
|
|
1085
1112
|
onChange: setSheetH,
|
|
1086
1113
|
onReset: () => setSheetH(null),
|
|
1087
1114
|
onDrag: setSizing,
|