@seanyeh77/ui 0.41.0 → 0.42.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/README.md +32 -0
- package/dist/announce.d.ts +3 -0
- package/dist/announce.js +35 -0
- package/dist/announce.js.map +1 -0
- package/dist/bundle.js +1 -1
- package/dist/bundle.js.map +1 -1
- package/dist/components/AccentPicker/AccentPicker.d.ts +12 -0
- package/dist/components/AccentPicker/AccentPicker.js +96 -0
- package/dist/components/AccentPicker/AccentPicker.js.map +1 -0
- package/dist/components/ActionBar/ActionBar.d.ts +27 -0
- package/dist/components/ActionBar/ActionBar.js +62 -0
- package/dist/components/ActionBar/ActionBar.js.map +1 -0
- package/dist/components/AiMark/AiMark.d.ts +10 -0
- package/dist/components/AiMark/AiMark.js +21 -0
- package/dist/components/AiMark/AiMark.js.map +1 -0
- package/dist/components/Alert/Alert.d.ts +17 -0
- package/dist/components/Alert/Alert.js +56 -0
- package/dist/components/Alert/Alert.js.map +1 -0
- package/dist/components/AppShell/AppShell.d.ts +36 -0
- package/dist/components/AppShell/AppShell.js +195 -0
- package/dist/components/AppShell/AppShell.js.map +1 -0
- package/dist/components/Badge/Badge.d.ts +12 -0
- package/dist/components/Badge/Badge.js +58 -0
- package/dist/components/Badge/Badge.js.map +1 -0
- package/dist/components/BarChart/BarChart.d.ts +19 -0
- package/dist/components/BarChart/BarChart.js +78 -0
- package/dist/components/BarChart/BarChart.js.map +1 -0
- package/dist/components/Breadcrumb/Breadcrumb.d.ts +11 -0
- package/dist/components/Breadcrumb/Breadcrumb.js +29 -0
- package/dist/components/Breadcrumb/Breadcrumb.js.map +1 -0
- package/dist/components/Button/Button.d.ts +39 -0
- package/dist/components/Button/Button.js +54 -0
- package/dist/components/Button/Button.js.map +1 -0
- package/dist/components/Calendar/Calendar.d.ts +18 -0
- package/dist/components/Calendar/Calendar.js +125 -0
- package/dist/components/Calendar/Calendar.js.map +1 -0
- package/dist/components/Card/Card.d.ts +14 -0
- package/dist/components/Card/Card.js +33 -0
- package/dist/components/Card/Card.js.map +1 -0
- package/dist/components/Checkbox/Checkbox.d.ts +14 -0
- package/dist/components/Checkbox/Checkbox.js +27 -0
- package/dist/components/Checkbox/Checkbox.js.map +1 -0
- package/dist/components/CodeView/CodeView.d.ts +111 -0
- package/dist/components/CodeView/CodeView.js +790 -0
- package/dist/components/CodeView/CodeView.js.map +1 -0
- package/dist/components/CodeView/tokens.d.ts +5 -0
- package/dist/components/CodeView/tokens.js +70 -0
- package/dist/components/CodeView/tokens.js.map +1 -0
- package/dist/components/CommandPalette/CommandPalette.d.ts +52 -0
- package/dist/components/CommandPalette/CommandPalette.js +242 -0
- package/dist/components/CommandPalette/CommandPalette.js.map +1 -0
- package/dist/components/ConsoleLayout/ConsoleLayout.d.ts +44 -0
- package/dist/components/ConsoleLayout/ConsoleLayout.js +119 -0
- package/dist/components/ConsoleLayout/ConsoleLayout.js.map +1 -0
- package/dist/components/DangerZone/DangerZone.d.ts +16 -0
- package/dist/components/DangerZone/DangerZone.js +28 -0
- package/dist/components/DangerZone/DangerZone.js.map +1 -0
- package/dist/components/DataTable/DataTable.d.ts +99 -0
- package/dist/components/DataTable/DataTable.js +1267 -0
- package/dist/components/DataTable/DataTable.js.map +1 -0
- package/dist/components/DataTable/SortButton.js +222 -0
- package/dist/components/DataTable/SortButton.js.map +1 -0
- package/dist/components/DataTable/filters.js +147 -0
- package/dist/components/DataTable/filters.js.map +1 -0
- package/dist/components/DataTable/parts.js +373 -0
- package/dist/components/DataTable/parts.js.map +1 -0
- package/dist/components/DataTable/types.d.ts +85 -0
- package/dist/components/DatePicker/DatePicker.d.ts +15 -0
- package/dist/components/DatePicker/DatePicker.js +104 -0
- package/dist/components/DatePicker/DatePicker.js.map +1 -0
- package/dist/components/DateRangePicker/DateRangePicker.d.ts +11 -0
- package/dist/components/DateRangePicker/DateRangePicker.js +88 -0
- package/dist/components/DateRangePicker/DateRangePicker.js.map +1 -0
- package/dist/components/DetailList/DetailList.d.ts +17 -0
- package/dist/components/DetailList/DetailList.js +18 -0
- package/dist/components/DetailList/DetailList.js.map +1 -0
- package/dist/components/Dialog/Dialog.d.ts +30 -0
- package/dist/components/Dialog/Dialog.js +87 -0
- package/dist/components/Dialog/Dialog.js.map +1 -0
- package/dist/components/Drawer/Drawer.d.ts +20 -0
- package/dist/components/Drawer/Drawer.js +64 -0
- package/dist/components/Drawer/Drawer.js.map +1 -0
- package/dist/components/EmptyState/EmptyState.d.ts +15 -0
- package/dist/components/EmptyState/EmptyState.js +34 -0
- package/dist/components/EmptyState/EmptyState.js.map +1 -0
- package/dist/components/ErrorPage/ErrorPage.d.ts +14 -0
- package/dist/components/ErrorPage/ErrorPage.js +47 -0
- package/dist/components/ErrorPage/ErrorPage.js.map +1 -0
- package/dist/components/EventTimeline/EventTimeline.d.ts +19 -0
- package/dist/components/EventTimeline/EventTimeline.js +63 -0
- package/dist/components/EventTimeline/EventTimeline.js.map +1 -0
- package/dist/components/FileUpload/FileUpload.d.ts +27 -0
- package/dist/components/FileUpload/FileUpload.js +121 -0
- package/dist/components/FileUpload/FileUpload.js.map +1 -0
- package/dist/components/FormGrid/FormGrid.d.ts +7 -0
- package/dist/components/FormGrid/FormGrid.js +14 -0
- package/dist/components/FormGrid/FormGrid.js.map +1 -0
- package/dist/components/Graph/Graph.d.ts +18 -0
- package/dist/components/Graph/Graph.js +97 -0
- package/dist/components/Graph/Graph.js.map +1 -0
- package/dist/components/Grid/Grid.d.ts +16 -0
- package/dist/components/Grid/Grid.js +21 -0
- package/dist/components/Grid/Grid.js.map +1 -0
- package/dist/components/IconButton/IconButton.d.ts +32 -0
- package/dist/components/IconButton/IconButton.js +104 -0
- package/dist/components/IconButton/IconButton.js.map +1 -0
- package/dist/components/InlineCode/InlineCode.d.ts +46 -0
- package/dist/components/InlineCode/InlineCode.js +71 -0
- package/dist/components/InlineCode/InlineCode.js.map +1 -0
- package/dist/components/KpiCard/KpiCard.d.ts +38 -0
- package/dist/components/KpiCard/KpiCard.js +116 -0
- package/dist/components/KpiCard/KpiCard.js.map +1 -0
- package/dist/components/LayerGraph/LayerGraph.d.ts +117 -0
- package/dist/components/LayerGraph/LayerGraph.js +1644 -0
- package/dist/components/LayerGraph/LayerGraph.js.map +1 -0
- package/dist/components/LineChart/LineChart.d.ts +73 -0
- package/dist/components/LineChart/LineChart.js +337 -0
- package/dist/components/LineChart/LineChart.js.map +1 -0
- package/dist/components/LoadingBar/LoadingBar.d.ts +7 -0
- package/dist/components/LoadingBar/LoadingBar.js +18 -0
- package/dist/components/LoadingBar/LoadingBar.js.map +1 -0
- package/dist/components/LoginCard/LoginCard.d.ts +23 -0
- package/dist/components/LoginCard/LoginCard.js +113 -0
- package/dist/components/LoginCard/LoginCard.js.map +1 -0
- package/dist/components/Markdown/Markdown.d.ts +38 -0
- package/dist/components/Markdown/Markdown.js +716 -0
- package/dist/components/Markdown/Markdown.js.map +1 -0
- package/dist/components/Menu/Menu.d.ts +33 -0
- package/dist/components/Menu/Menu.js +75 -0
- package/dist/components/Menu/Menu.js.map +1 -0
- package/dist/components/Meter/Meter.d.ts +20 -0
- package/dist/components/Meter/Meter.js +120 -0
- package/dist/components/Meter/Meter.js.map +1 -0
- package/dist/components/MobileTabBar/MobileTabBar.d.ts +21 -0
- package/dist/components/MobileTabBar/MobileTabBar.js +47 -0
- package/dist/components/MobileTabBar/MobileTabBar.js.map +1 -0
- package/dist/components/MultiSelect/MultiSelect.d.ts +25 -0
- package/dist/components/MultiSelect/MultiSelect.js +116 -0
- package/dist/components/MultiSelect/MultiSelect.js.map +1 -0
- package/dist/components/NotificationBell/NotificationBell.d.ts +20 -0
- package/dist/components/NotificationBell/NotificationBell.js +92 -0
- package/dist/components/NotificationBell/NotificationBell.js.map +1 -0
- package/dist/components/Popover/Popover.d.ts +20 -0
- package/dist/components/Popover/Popover.js +48 -0
- package/dist/components/Popover/Popover.js.map +1 -0
- package/dist/components/ProgressBar/ProgressBar.d.ts +10 -0
- package/dist/components/ProgressBar/ProgressBar.js +38 -0
- package/dist/components/ProgressBar/ProgressBar.js.map +1 -0
- package/dist/components/ProgressRing/ProgressRing.d.ts +11 -0
- package/dist/components/ProgressRing/ProgressRing.js +53 -0
- package/dist/components/ProgressRing/ProgressRing.js.map +1 -0
- package/dist/components/ProjectSwitcher/ProjectSwitcher.d.ts +25 -0
- package/dist/components/ProjectSwitcher/ProjectSwitcher.js +97 -0
- package/dist/components/ProjectSwitcher/ProjectSwitcher.js.map +1 -0
- package/dist/components/RadioGroup/RadioGroup.d.ts +18 -0
- package/dist/components/RadioGroup/RadioGroup.js +63 -0
- package/dist/components/RadioGroup/RadioGroup.js.map +1 -0
- package/dist/components/SearchField/SearchField.d.ts +9 -0
- package/dist/components/SearchField/SearchField.js +46 -0
- package/dist/components/SearchField/SearchField.js.map +1 -0
- package/dist/components/Section/Section.d.ts +50 -0
- package/dist/components/Section/Section.js +220 -0
- package/dist/components/Section/Section.js.map +1 -0
- package/dist/components/SegmentedControl/SegmentedControl.d.ts +23 -0
- package/dist/components/SegmentedControl/SegmentedControl.js +86 -0
- package/dist/components/SegmentedControl/SegmentedControl.js.map +1 -0
- package/dist/components/Select/Select.d.ts +31 -0
- package/dist/components/Select/Select.js +138 -0
- package/dist/components/Select/Select.js.map +1 -0
- package/dist/components/SettingsLayout/SettingsLayout.d.ts +27 -0
- package/dist/components/SettingsLayout/SettingsLayout.js +69 -0
- package/dist/components/SettingsLayout/SettingsLayout.js.map +1 -0
- package/dist/components/SideNav/SideNav.d.ts +48 -0
- package/dist/components/SideNav/SideNav.js +220 -0
- package/dist/components/SideNav/SideNav.js.map +1 -0
- package/dist/components/Skeleton/Skeleton.d.ts +8 -0
- package/dist/components/Skeleton/Skeleton.js +17 -0
- package/dist/components/Skeleton/Skeleton.js.map +1 -0
- package/dist/components/SplitPane/SplitPane.d.ts +23 -0
- package/dist/components/SplitPane/SplitPane.js +140 -0
- package/dist/components/SplitPane/SplitPane.js.map +1 -0
- package/dist/components/StatusBand/StatusBand.d.ts +31 -0
- package/dist/components/StatusBand/StatusBand.js +43 -0
- package/dist/components/StatusBand/StatusBand.js.map +1 -0
- package/dist/components/Suggestion/Suggestion.d.ts +22 -0
- package/dist/components/Suggestion/Suggestion.js +72 -0
- package/dist/components/Suggestion/Suggestion.js.map +1 -0
- package/dist/components/Switch/Switch.d.ts +11 -0
- package/dist/components/Switch/Switch.js +56 -0
- package/dist/components/Switch/Switch.js.map +1 -0
- package/dist/components/Tabs/Tabs.d.ts +23 -0
- package/dist/components/Tabs/Tabs.js +117 -0
- package/dist/components/Tabs/Tabs.js.map +1 -0
- package/dist/components/Tag/Tag.d.ts +13 -0
- package/dist/components/Tag/Tag.js +22 -0
- package/dist/components/Tag/Tag.js.map +1 -0
- package/dist/components/Term/Term.d.ts +34 -0
- package/dist/components/Term/Term.js +138 -0
- package/dist/components/Term/Term.js.map +1 -0
- package/dist/components/TextArea/TextArea.d.ts +15 -0
- package/dist/components/TextArea/TextArea.js +75 -0
- package/dist/components/TextArea/TextArea.js.map +1 -0
- package/dist/components/TextField/TextField.d.ts +15 -0
- package/dist/components/TextField/TextField.js +43 -0
- package/dist/components/TextField/TextField.js.map +1 -0
- package/dist/components/ThemePicker/ThemePicker.d.ts +13 -0
- package/dist/components/ThemePicker/ThemePicker.js +66 -0
- package/dist/components/ThemePicker/ThemePicker.js.map +1 -0
- package/dist/components/TimeControl/TimeControl.d.ts +19 -0
- package/dist/components/TimeControl/TimeControl.js +47 -0
- package/dist/components/TimeControl/TimeControl.js.map +1 -0
- package/dist/components/Toast/Toast.d.ts +10 -0
- package/dist/components/Toast/Toast.js +27 -0
- package/dist/components/Toast/Toast.js.map +1 -0
- package/dist/components/Tooltip/Tooltip.d.ts +17 -0
- package/dist/components/Tooltip/Tooltip.js +69 -0
- package/dist/components/Tooltip/Tooltip.js.map +1 -0
- package/dist/components/TopBar/TopBar.d.ts +18 -0
- package/dist/components/TopBar/TopBar.js +55 -0
- package/dist/components/TopBar/TopBar.js.map +1 -0
- package/dist/components/Tour/Tour.d.ts +44 -0
- package/dist/components/Tour/Tour.js +440 -0
- package/dist/components/Tour/Tour.js.map +1 -0
- package/dist/components/TreeList/TreeList.d.ts +90 -0
- package/dist/components/TreeList/TreeList.js +588 -0
- package/dist/components/TreeList/TreeList.js.map +1 -0
- package/dist/components/TreeList/helpers.d.ts +2 -0
- package/dist/components/TreeList/helpers.js +104 -0
- package/dist/components/TreeList/helpers.js.map +1 -0
- package/dist/components/Workbench/Workbench.d.ts +100 -0
- package/dist/components/Workbench/Workbench.js +1137 -0
- package/dist/components/Workbench/Workbench.js.map +1 -0
- package/dist/components/ZoneMap/ZoneMap.d.ts +49 -0
- package/dist/components/ZoneMap/ZoneMap.js +89 -0
- package/dist/components/ZoneMap/ZoneMap.js.map +1 -0
- package/dist/css/AccentPicker.css +49 -0
- package/dist/css/ActionBar.css +36 -0
- package/dist/css/AiMark.css +14 -0
- package/dist/css/Alert.css +80 -0
- package/dist/css/AppShell.css +81 -0
- package/dist/css/Badge.css +68 -0
- package/dist/css/BarChart.css +66 -0
- package/dist/css/Breadcrumb.css +33 -0
- package/dist/css/Button.css +190 -0
- package/dist/css/Calendar.css +96 -0
- package/dist/css/Card.css +70 -0
- package/dist/css/Checkbox.css +38 -0
- package/dist/css/CodeView.css +302 -0
- package/dist/css/CommandPalette.css +232 -0
- package/dist/css/ConsoleLayout.css +131 -0
- package/dist/css/DangerZone.css +32 -0
- package/dist/css/DataTable.css +1195 -0
- package/dist/css/DatePicker.css +38 -0
- package/dist/css/DateRangePicker.css +70 -0
- package/dist/css/DetailList.css +69 -0
- package/dist/css/Dialog.css +3 -0
- package/dist/css/Drawer.css +90 -0
- package/dist/css/EmptyState.css +61 -0
- package/dist/css/ErrorPage.css +40 -0
- package/dist/css/EventTimeline.css +43 -0
- package/dist/css/FileUpload.css +92 -0
- package/dist/css/FormGrid.css +17 -0
- package/dist/css/Graph.css +99 -0
- package/dist/css/Grid.css +48 -0
- package/dist/css/IconButton.css +149 -0
- package/dist/css/InlineCode.css +92 -0
- package/dist/css/KpiCard.css +121 -0
- package/dist/css/LayerGraph.css +575 -0
- package/dist/css/LineChart.css +3 -0
- package/dist/css/LoadingBar.css +45 -0
- package/dist/css/LoginCard.css +65 -0
- package/dist/css/Markdown.css +266 -0
- package/dist/css/Menu.css +88 -0
- package/dist/css/Meter.css +110 -0
- package/dist/css/MobileTabBar.css +63 -0
- package/dist/css/MultiSelect.css +78 -0
- package/dist/css/NotificationBell.css +129 -0
- package/dist/css/Popover.css +57 -0
- package/dist/css/ProgressBar.css +42 -0
- package/dist/css/ProgressRing.css +19 -0
- package/dist/css/ProjectSwitcher.css +153 -0
- package/dist/css/RadioGroup.css +52 -0
- package/dist/css/SearchField.css +79 -0
- package/dist/css/Section.css +115 -0
- package/dist/css/SegmentedControl.css +67 -0
- package/dist/css/Select.css +136 -0
- package/dist/css/SettingsLayout.css +110 -0
- package/dist/css/SideNav.css +281 -0
- package/dist/css/Skeleton.css +19 -0
- package/dist/css/SplitPane.css +108 -0
- package/dist/css/StatusBand.css +23 -0
- package/dist/css/Suggestion.css +82 -0
- package/dist/css/Switch.css +46 -0
- package/dist/css/Tabs.css +91 -0
- package/dist/css/Tag.css +36 -0
- package/dist/css/Term.css +160 -0
- package/dist/css/TextArea.css +22 -0
- package/dist/css/TextField.css +2 -0
- package/dist/css/ThemePicker.css +70 -0
- package/dist/css/TimeControl.css +33 -0
- package/dist/css/Toast.css +47 -0
- package/dist/css/Tooltip.css +58 -0
- package/dist/css/TopBar.css +86 -0
- package/dist/css/Tour.css +90 -0
- package/dist/css/TreeList.css +532 -0
- package/dist/css/Workbench.css +652 -0
- package/dist/css/ZoneMap.css +203 -0
- package/dist/css/base.css +556 -0
- package/dist/css/end.css +273 -0
- package/dist/format-entry.d.ts +3 -0
- package/dist/format-entry.js +3 -0
- package/dist/format.d.ts +68 -2
- package/dist/format.js +237 -1
- package/dist/format.js.map +1 -0
- package/dist/i18n.d.ts +11 -0
- package/dist/{format-entry-CyChe8bk.js → i18n.js} +2 -235
- package/dist/i18n.js.map +1 -0
- package/dist/icons/Icon.d.ts +23 -0
- package/dist/icons/Icon.js +90 -0
- package/dist/icons/Icon.js.map +1 -0
- package/dist/icons/data.d.ts +150 -0
- package/dist/icons/data.js +256 -0
- package/dist/icons/data.js.map +1 -0
- package/dist/index.d.ts +84 -2293
- package/dist/index.js +79 -13348
- package/dist/internal/Field.js +71 -0
- package/dist/internal/Field.js.map +1 -0
- package/dist/internal/FloatingPanel.js +41 -0
- package/dist/internal/FloatingPanel.js.map +1 -0
- package/dist/internal/chart.js +131 -0
- package/dist/internal/chart.js.map +1 -0
- package/dist/internal/dev.js +21 -0
- package/dist/internal/dev.js.map +1 -0
- package/dist/internal/focus.js +94 -0
- package/dist/internal/focus.js.map +1 -0
- package/dist/internal/focusMain.d.ts +4 -0
- package/dist/internal/focusMain.js +22 -0
- package/dist/internal/focusMain.js.map +1 -0
- package/dist/internal/scrollHint.js +75 -0
- package/dist/internal/scrollHint.js.map +1 -0
- package/dist/internal/tableTools.js +109 -0
- package/dist/internal/tableTools.js.map +1 -0
- package/dist/internal/terms.d.ts +18 -0
- package/dist/internal/terms.js +64 -0
- package/dist/internal/terms.js.map +1 -0
- package/dist/internal/util.js +107 -0
- package/dist/internal/util.js.map +1 -0
- package/dist/motion.d.ts +5 -0
- package/dist/motion.js +29 -0
- package/dist/motion.js.map +1 -0
- package/dist/styles.css +4280 -4265
- package/dist/theme.d.ts +20 -0
- package/dist/theme.js +210 -0
- package/dist/theme.js.map +1 -0
- package/dist/tokens.css +4 -0
- package/docs/guidelines.md +1 -0
- package/docs/theme.md +49 -0
- package/package.json +5 -4
- package/dist/format-entry-CgMBtkni.d.ts +0 -79
- package/dist/format-entry-CyChe8bk.js.map +0 -1
- package/dist/index.js.map +0 -1
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { IconButton } from "../IconButton/IconButton.js";
|
|
3
|
+
import { cx } from "../../internal/util.js";
|
|
4
|
+
import { tr } from "../../i18n.js";
|
|
5
|
+
import * as React from "react";
|
|
6
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
// src/components/ConsoleLayout/ConsoleLayout.tsx
|
|
8
|
+
/** Design size: at this size and up the layout zooms in. */
|
|
9
|
+
const BASE_W = 1440;
|
|
10
|
+
const BASE_H = 900;
|
|
11
|
+
const MAX_ZOOM = 1.5;
|
|
12
|
+
const PHONE = 600;
|
|
13
|
+
/** Zoom for a screen of w × h px: 1 up to 1440 × 900, then grows with the screen, at most 1.5. */
|
|
14
|
+
function consoleZoom(w, h) {
|
|
15
|
+
return Math.max(1, Math.min(MAX_ZOOM, Math.min(w / BASE_W, h / BASE_H)));
|
|
16
|
+
}
|
|
17
|
+
/** A full-screen monitoring layout: a top bar (title, tags, then status, KPIs, clock and full screen on the right),
|
|
18
|
+
* the main view with a side panel beside it and a bottom row under it, filling the screen without scrolling. From
|
|
19
|
+
* 1440 × 900 up everything zooms with the screen (at most 1.5×). Phones (under 600 px) get one scrolling column. */
|
|
20
|
+
function ConsoleLayout({ title, tags, status, kpis, clock, fullscreen = true, main, side, bottom, extras, className }) {
|
|
21
|
+
const ref = React.useRef(null);
|
|
22
|
+
const [size, setSize] = React.useState(null);
|
|
23
|
+
const [full, setFull] = React.useState(false);
|
|
24
|
+
const canFull = typeof document !== "undefined" && document.fullscreenEnabled === true;
|
|
25
|
+
React.useLayoutEffect(() => {
|
|
26
|
+
const el = ref.current;
|
|
27
|
+
if (!el) return;
|
|
28
|
+
const measure = () => setSize({
|
|
29
|
+
w: el.clientWidth,
|
|
30
|
+
h: el.clientHeight
|
|
31
|
+
});
|
|
32
|
+
measure();
|
|
33
|
+
if (typeof ResizeObserver === "undefined") return;
|
|
34
|
+
const ro = new ResizeObserver(measure);
|
|
35
|
+
ro.observe(el);
|
|
36
|
+
return () => ro.disconnect();
|
|
37
|
+
}, []);
|
|
38
|
+
React.useEffect(() => {
|
|
39
|
+
const f = () => setFull(document.fullscreenElement != null && document.fullscreenElement === ref.current);
|
|
40
|
+
document.addEventListener("fullscreenchange", f);
|
|
41
|
+
return () => document.removeEventListener("fullscreenchange", f);
|
|
42
|
+
}, []);
|
|
43
|
+
const toggleFull = () => {
|
|
44
|
+
const el = ref.current;
|
|
45
|
+
if (!el) return;
|
|
46
|
+
if (document.fullscreenElement) document.exitFullscreen().catch(() => void 0);
|
|
47
|
+
else el.requestFullscreen().catch(() => void 0);
|
|
48
|
+
};
|
|
49
|
+
const phone = size != null && size.w < PHONE;
|
|
50
|
+
const zoom = size && !phone ? consoleZoom(size.w, size.h) : 1;
|
|
51
|
+
const logicalH = size ? size.h / zoom : 0;
|
|
52
|
+
const shown = (extras ?? []).filter((x) => phone || logicalH >= x.minHeight);
|
|
53
|
+
const frameStyle = size && !phone && zoom !== 1 ? {
|
|
54
|
+
zoom,
|
|
55
|
+
width: size.w / zoom,
|
|
56
|
+
height: size.h / zoom
|
|
57
|
+
} : void 0;
|
|
58
|
+
const top = /* @__PURE__ */ jsxs("header", {
|
|
59
|
+
className: "ui-console-top",
|
|
60
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
61
|
+
className: "ui-console-start",
|
|
62
|
+
children: [/* @__PURE__ */ jsx("h1", {
|
|
63
|
+
className: "ui-console-title",
|
|
64
|
+
children: title
|
|
65
|
+
}), tags]
|
|
66
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
67
|
+
className: "ui-console-end",
|
|
68
|
+
children: [
|
|
69
|
+
status != null ? /* @__PURE__ */ jsx("span", {
|
|
70
|
+
className: "ui-console-status",
|
|
71
|
+
children: status
|
|
72
|
+
}) : null,
|
|
73
|
+
kpis != null ? /* @__PURE__ */ jsx("div", {
|
|
74
|
+
className: "ui-console-kpis",
|
|
75
|
+
children: kpis
|
|
76
|
+
}) : null,
|
|
77
|
+
clock != null ? /* @__PURE__ */ jsx("span", {
|
|
78
|
+
className: "ui-console-clock",
|
|
79
|
+
children: clock
|
|
80
|
+
}) : null,
|
|
81
|
+
fullscreen && canFull && !phone ? /* @__PURE__ */ jsx(IconButton, {
|
|
82
|
+
label: full ? tr("離開全螢幕") : tr("全螢幕"),
|
|
83
|
+
icon: full ? "corners-in" : "corners-out",
|
|
84
|
+
onClick: toggleFull
|
|
85
|
+
}) : null
|
|
86
|
+
]
|
|
87
|
+
})]
|
|
88
|
+
});
|
|
89
|
+
return /* @__PURE__ */ jsx("div", {
|
|
90
|
+
ref,
|
|
91
|
+
className: cx("ui-console", phone && "is-stacked", className),
|
|
92
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
93
|
+
className: "ui-console-frame",
|
|
94
|
+
style: frameStyle,
|
|
95
|
+
children: [
|
|
96
|
+
top,
|
|
97
|
+
/* @__PURE__ */ jsx("main", {
|
|
98
|
+
className: "ui-console-main",
|
|
99
|
+
children: main
|
|
100
|
+
}),
|
|
101
|
+
phone ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
102
|
+
side,
|
|
103
|
+
bottom,
|
|
104
|
+
shown.map((x) => /* @__PURE__ */ jsx(React.Fragment, { children: x.node }, x.id))
|
|
105
|
+
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("aside", {
|
|
106
|
+
className: "ui-console-side",
|
|
107
|
+
"aria-label": tr("側欄"),
|
|
108
|
+
children: [side, shown.map((x) => /* @__PURE__ */ jsx(React.Fragment, { children: x.node }, x.id))]
|
|
109
|
+
}), bottom != null ? /* @__PURE__ */ jsx("div", {
|
|
110
|
+
className: "ui-console-bottom",
|
|
111
|
+
children: bottom
|
|
112
|
+
}) : null] })
|
|
113
|
+
]
|
|
114
|
+
})
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
export { ConsoleLayout, consoleZoom };
|
|
118
|
+
|
|
119
|
+
//# sourceMappingURL=ConsoleLayout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConsoleLayout.js","names":[],"sources":["../../../src/components/ConsoleLayout/ConsoleLayout.tsx"],"sourcesContent":["import * as React from 'react';\nimport { IconButton } from '../IconButton/IconButton';\nimport { cx } from '../../internal/util';\nimport { tr } from '../../i18n';\n\n/** A card that shows only when the screen is tall enough. */\nexport interface ConsoleExtra {\n /** Stable key for the card. */\n id: string;\n /** The card shows when the layout's logical height (the screen height divided by the zoom) is at least this many\n * px, e.g. 1040. */\n minHeight: number;\n /** The card: usually a Card. */\n node: React.ReactNode;\n}\n\nexport interface ConsoleLayoutProps {\n /** The product or screen name, the page's only heading: 「設施監控」. */\n title: string;\n /** Right after the title: `<Tag variant=\"demo\">示範資料</Tag>`. Same size and color as the text around it. */\n tags?: React.ReactNode;\n /** Right side, before the KPIs: one short state in plain words, 「AI 最佳化中」. Shown in body size and ink color;\n * pass plain text, not a Badge. */\n status?: React.ReactNode;\n /** Right side: `<KpiCard size=\"compact\" />` side by side. In the top bar they lose their card look and sit between\n * 1 px lines. */\n kpis?: React.ReactNode;\n /** Right side, after the KPIs: the time and whether it is live, 「16:24 即時」. */\n clock?: React.ReactNode;\n /** A 「全螢幕」 button at the right end (Fullscreen API). Default true; hidden where the browser has no full screen. */\n fullscreen?: boolean;\n /** The main view, left of the side panel; it fills its cell (pass one Card, e.g. with a ZoneMap). */\n main: React.ReactNode;\n /** The side panel, 400 px (360 px under 1280 px): cards from top to bottom (TimeControl, EventTimeline). When they\n * do not fit, the side panel scrolls on its own; the page never does. */\n side?: React.ReactNode;\n /** The bottom row under the main view, as tall as its content: e.g. a LineChart in a Card. The main view takes the\n * height that is left. */\n bottom?: React.ReactNode;\n /** Cards added at the end of the side panel on tall screens: `[{ id, minHeight: 1040, node }]`. */\n extras?: ConsoleExtra[];\n className?: string;\n}\n\n/** Design size: at this size and up the layout zooms in. */\nconst BASE_W = 1440;\nconst BASE_H = 900;\nconst MAX_ZOOM = 1.5;\nconst PHONE = 600;\n\n/** Zoom for a screen of w × h px: 1 up to 1440 × 900, then grows with the screen, at most 1.5. */\nexport function consoleZoom(w: number, h: number): number {\n return Math.max(1, Math.min(MAX_ZOOM, Math.min(w / BASE_W, h / BASE_H)));\n}\n\n/** A full-screen monitoring layout: a top bar (title, tags, then status, KPIs, clock and full screen on the right),\n * the main view with a side panel beside it and a bottom row under it, filling the screen without scrolling. From\n * 1440 × 900 up everything zooms with the screen (at most 1.5×). Phones (under 600 px) get one scrolling column. */\nexport function ConsoleLayout({ title, tags, status, kpis, clock, fullscreen = true, main, side, bottom, extras, className }: ConsoleLayoutProps) {\n const ref = React.useRef<HTMLDivElement>(null);\n const [size, setSize] = React.useState<{ w: number; h: number } | null>(null);\n const [full, setFull] = React.useState(false);\n const canFull = typeof document !== 'undefined' && document.fullscreenEnabled === true;\n\n React.useLayoutEffect(() => {\n const el = ref.current;\n if (!el) return;\n const measure = () => setSize({ w: el.clientWidth, h: el.clientHeight });\n measure();\n if (typeof ResizeObserver === 'undefined') return;\n const ro = new ResizeObserver(measure);\n ro.observe(el);\n return () => ro.disconnect();\n }, []);\n\n React.useEffect(() => {\n const f = () => setFull(document.fullscreenElement != null && document.fullscreenElement === ref.current);\n document.addEventListener('fullscreenchange', f);\n return () => document.removeEventListener('fullscreenchange', f);\n }, []);\n\n const toggleFull = () => {\n const el = ref.current;\n if (!el) return;\n if (document.fullscreenElement) void document.exitFullscreen().catch(() => undefined);\n else void el.requestFullscreen().catch(() => undefined);\n };\n\n const phone = size != null && size.w < PHONE;\n const zoom = size && !phone ? consoleZoom(size.w, size.h) : 1;\n const logicalH = size ? size.h / zoom : 0;\n const shown = (extras ?? []).filter((x) => phone || logicalH >= x.minHeight);\n const frameStyle: React.CSSProperties | undefined =\n size && !phone && zoom !== 1 ? ({ zoom, width: size.w / zoom, height: size.h / zoom } as React.CSSProperties) : undefined;\n\n const top = (\n <header className=\"ui-console-top\">\n <div className=\"ui-console-start\">\n <h1 className=\"ui-console-title\">{title}</h1>\n {tags}\n </div>\n <div className=\"ui-console-end\">\n {status != null ? <span className=\"ui-console-status\">{status}</span> : null}\n {kpis != null ? <div className=\"ui-console-kpis\">{kpis}</div> : null}\n {clock != null ? <span className=\"ui-console-clock\">{clock}</span> : null}\n {fullscreen && canFull && !phone ? (\n <IconButton label={full ? tr('離開全螢幕') : tr('全螢幕')} icon={full ? 'corners-in' : 'corners-out'} onClick={toggleFull} />\n ) : null}\n </div>\n </header>\n );\n\n return (\n <div ref={ref} className={cx('ui-console', phone && 'is-stacked', className)}>\n <div className=\"ui-console-frame\" style={frameStyle}>\n {top}\n <main className=\"ui-console-main\">{main}</main>\n {phone ? (\n <>\n {side}\n {bottom}\n {shown.map((x) => (\n <React.Fragment key={x.id}>{x.node}</React.Fragment>\n ))}\n </>\n ) : (\n <>\n <aside className=\"ui-console-side\" aria-label={tr('側欄')}>\n {side}\n {shown.map((x) => (\n <React.Fragment key={x.id}>{x.node}</React.Fragment>\n ))}\n </aside>\n {bottom != null ? <div className=\"ui-console-bottom\">{bottom}</div> : null}\n </>\n )}\n </div>\n </div>\n );\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { DangerConfirm } from "../Button/Button.js";
|
|
2
|
+
export interface DangerZoneProps {
|
|
3
|
+
/** Default 「危險操作」. */
|
|
4
|
+
title?: string;
|
|
5
|
+
/** What the action destroys. */
|
|
6
|
+
description: string;
|
|
7
|
+
/** Default 「刪除」. */
|
|
8
|
+
actionLabel?: string;
|
|
9
|
+
/** Runs after the person confirms. */
|
|
10
|
+
onAction: () => void;
|
|
11
|
+
/** The confirm dialog: name the object in the title. */
|
|
12
|
+
confirm: DangerConfirm;
|
|
13
|
+
className?: string;
|
|
14
|
+
}
|
|
15
|
+
/** A red-bordered block at the bottom of a settings page for delete-type actions; the button asks to confirm. */
|
|
16
|
+
export declare function DangerZone({ title, description, actionLabel, onAction, confirm, className }: DangerZoneProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { tr } from "../../i18n.js";
|
|
3
|
+
import { cx } from "../../internal/util.js";
|
|
4
|
+
import { Button } from "../Button/Button.js";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
// src/components/DangerZone/DangerZone.tsx
|
|
7
|
+
/** A red-bordered block at the bottom of a settings page for delete-type actions; the button asks to confirm. */
|
|
8
|
+
function DangerZone({ title, description, actionLabel, onAction, confirm, className }) {
|
|
9
|
+
const label = actionLabel || tr("刪除");
|
|
10
|
+
return /* @__PURE__ */ jsxs("section", {
|
|
11
|
+
className: cx("ui-danger", className),
|
|
12
|
+
children: [/* @__PURE__ */ jsx("h2", {
|
|
13
|
+
className: "ui-danger-title",
|
|
14
|
+
children: title || tr("危險操作")
|
|
15
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
16
|
+
className: "ui-danger-row",
|
|
17
|
+
children: [/* @__PURE__ */ jsx("p", { children: description }), /* @__PURE__ */ jsx(Button, {
|
|
18
|
+
variant: "danger",
|
|
19
|
+
confirm: confirm ?? { title: tr("{label}?", { label }) },
|
|
20
|
+
onClick: onAction,
|
|
21
|
+
children: label
|
|
22
|
+
})]
|
|
23
|
+
})]
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
export { DangerZone };
|
|
27
|
+
|
|
28
|
+
//# sourceMappingURL=DangerZone.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DangerZone.js","names":[],"sources":["../../../src/components/DangerZone/DangerZone.tsx"],"sourcesContent":["import { tr } from '../../i18n';\nimport { cx } from '../../internal/util';\nimport { Button, type DangerConfirm } from '../Button/Button';\n\nexport interface DangerZoneProps {\n /** Default 「危險操作」. */\n title?: string;\n /** What the action destroys. */\n description: string;\n /** Default 「刪除」. */\n actionLabel?: string;\n /** Runs after the person confirms. */\n onAction: () => void;\n /** The confirm dialog: name the object in the title. */\n confirm: DangerConfirm;\n className?: string;\n}\n\n/** A red-bordered block at the bottom of a settings page for delete-type actions; the button asks to confirm. */\nexport function DangerZone({ title, description, actionLabel, onAction, confirm, className }: DangerZoneProps) {\n const label = actionLabel || tr('刪除');\n return (\n <section className={cx('ui-danger', className)}>\n <h2 className=\"ui-danger-title\">{title || tr('危險操作')}</h2>\n <div className=\"ui-danger-row\">\n <p>{description}</p>\n {/* Without a build step nothing enforces confirm: ask anyway. */}\n <Button variant=\"danger\" confirm={confirm ?? { title: tr('{label}?', { label }) }} onClick={onAction}>\n {label}\n </Button>\n </div>\n </section>\n );\n}\n"],"mappings":";;;;;;;AAmBA,SAAgB,WAAW,EAAE,OAAO,aAAa,aAAa,UAAU,SAAS,aAA8B;CAC7G,MAAM,QAAQ,eAAe,GAAG,IAAI;CACpC,OACE,qBAAC,WAAD;EAAS,WAAW,GAAG,aAAa,SAAS;EAA7C,UAAA,CACE,oBAAC,MAAD;GAAI,WAAU;GAAmB,UAAA,SAAS,GAAG,MAAM;EAAM,CAAA,GACzD,qBAAC,OAAD;GAAK,WAAU;GAAf,UAAA,CACE,oBAAC,KAAD,EAAA,UAAI,YAAe,CAAA,GAEnB,oBAAC,QAAD;IAAQ,SAAQ;IAAS,SAAS,WAAW,EAAE,OAAO,GAAG,YAAY,EAAE,MAAM,CAAC,EAAE;IAAG,SAAS;IACzF,UAAA;GACK,CAAA,CACL;EACE,CAAA,CAAA;;AAEb"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { CountUnit } from "../../i18n.js";
|
|
2
|
+
import { DataTableColumn, DataTableFilter, DataTableView, FilterOption, FilterValue, RangeValue, Row, RowKey, Total } from "./types.js";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
export interface DataTableProps<R extends Row = Record<string, unknown>> {
|
|
5
|
+
columns: DataTableColumn<R>[];
|
|
6
|
+
/** Give each row an `id` so selection and animations follow the row, not its position. */
|
|
7
|
+
rows: R[];
|
|
8
|
+
/** Title above the table, also its accessible name. */
|
|
9
|
+
caption?: string;
|
|
10
|
+
/** Segmented summary above the table: 「全部」 plus one tab per status with its count; picking one filters the rows.
|
|
11
|
+
* `unit` follows every count; default 「筆」. A function gets the count, for plurals in other languages. */
|
|
12
|
+
summary?: {
|
|
13
|
+
key: RowKey<R>;
|
|
14
|
+
items: {
|
|
15
|
+
value: string;
|
|
16
|
+
label: string;
|
|
17
|
+
}[];
|
|
18
|
+
label?: string;
|
|
19
|
+
unit?: CountUnit;
|
|
20
|
+
};
|
|
21
|
+
/** aria-label when there is no caption. */
|
|
22
|
+
label?: string;
|
|
23
|
+
/** Rows per page. Default 10. */
|
|
24
|
+
pageSize?: number;
|
|
25
|
+
/** Change it when the rows become a different data set: search, filters, sort, page, selection and summary reset. */
|
|
26
|
+
resetKey?: string | number;
|
|
27
|
+
/** Checkboxes appear when a row is hovered, and on every row once any row is selected. */
|
|
28
|
+
selectable?: boolean;
|
|
29
|
+
/** Buttons for the bar that replaces the header while rows are selected. */
|
|
30
|
+
bulkActions?: (ids: string[], clear: () => void) => React.ReactNode;
|
|
31
|
+
/** IconButtons at the row's right end, shown when the row is hovered. */
|
|
32
|
+
rowActions?: (row: R) => React.ReactNode;
|
|
33
|
+
/** px. Default 88. */
|
|
34
|
+
actionsWidth?: number;
|
|
35
|
+
/** Search box (default on; false hides it). Searches every column unless keys is given. */
|
|
36
|
+
search?: false | {
|
|
37
|
+
placeholder?: string;
|
|
38
|
+
keys?: RowKey<R>[];
|
|
39
|
+
};
|
|
40
|
+
/** Filters in the 「篩選」 popover. */
|
|
41
|
+
filters?: DataTableFilter<R>[];
|
|
42
|
+
/** @deprecated use filters. */
|
|
43
|
+
filter?: {
|
|
44
|
+
key: RowKey<R>;
|
|
45
|
+
label?: string;
|
|
46
|
+
options: FilterOption[];
|
|
47
|
+
};
|
|
48
|
+
/** 「/」 focuses this table's search field when focus is not in a text field (no Ctrl, Alt or ⌘). Only the first
|
|
49
|
+
* table on the page with a search field takes it; it shows a small 「/」 in the empty field on desktop. Default true. */
|
|
50
|
+
searchShortcut?: boolean;
|
|
51
|
+
/** Each row's page: the first cell's text becomes a link to it, and a click anywhere else on the row (not on its own
|
|
52
|
+
* links, buttons or checkbox, nor a click that ends a text selection) opens it. Like a link, Ctrl, ⌘ or Shift + click
|
|
53
|
+
* and a middle click open it in a new tab. */
|
|
54
|
+
rowHref?: (row: R) => string;
|
|
55
|
+
/** With rowHref: called instead of following the link on a plain click (on the row or its first cell's link), so an
|
|
56
|
+
* app router can push the route. Ctrl, ⌘, Shift and middle clicks still open the href in a new tab. */
|
|
57
|
+
onRowOpen?: (row: R, event: React.MouseEvent) => void;
|
|
58
|
+
/** Write search and filters into the URL. Default true. */
|
|
59
|
+
urlSync?: boolean;
|
|
60
|
+
/** Prefix of the URL parameters when a page has several tables. */
|
|
61
|
+
urlKey?: string;
|
|
62
|
+
/** The sort before anyone changes it, first level first, e.g. [{ key: 'prog' }, { key: 'dt', dir: 'desc' }]. A level
|
|
63
|
+
* without dir starts like a click on its heading: numbers from the largest, text from A. Default: the rows' order. */
|
|
64
|
+
defaultSort?: readonly {
|
|
65
|
+
key: RowKey<R>;
|
|
66
|
+
dir?: 'asc' | 'desc';
|
|
67
|
+
}[];
|
|
68
|
+
/** How many columns can sort at once (the 「排序」 panel, Shift + click on a heading). Default: no limit, every sortable
|
|
69
|
+
* column. */
|
|
70
|
+
maxSort?: number;
|
|
71
|
+
/** Saved views shown as tabs above the table. */
|
|
72
|
+
views?: DataTableView<R>[];
|
|
73
|
+
/** Totals row: 'sum', 'avg' or a function per column key. */
|
|
74
|
+
totals?: Partial<Record<string, Total<R>>>;
|
|
75
|
+
/** Keep the first column visible while scrolling sideways. */
|
|
76
|
+
stickyFirst?: boolean;
|
|
77
|
+
/** 「欄位」 in the 「⋯」 menu, to hide columns. Default true. */
|
|
78
|
+
columnMenu?: boolean;
|
|
79
|
+
/** Remembers the column widths readers drag (the borders in the header) and the columns they hide or show, in
|
|
80
|
+
* localStorage under this name (ui-dt-width:<widthKey>, ui-dt-cols:<widthKey>). Without it they go back to the
|
|
81
|
+
* defaults when the page reloads. resetKey does not clear them: they are the reader's own; 「欄位」 → 「還原預設」 does. */
|
|
82
|
+
widthKey?: string;
|
|
83
|
+
/** 「放大表格」 in the 「⋯」 menu: the whole table, with its search, filters, sort and pages, in a dialog up to
|
|
84
|
+
* 1200 px wide. A click on a link inside closes the dialog. Not on phones. Default true. */
|
|
85
|
+
zoom?: boolean;
|
|
86
|
+
/** 「複製成 Markdown」 in the 「⋯」 menu: every row the search and filters keep (all pages), in the shown columns and
|
|
87
|
+
* order; each cell is the column's fullText, else its searchText, else its value. Default true. */
|
|
88
|
+
copy?: boolean;
|
|
89
|
+
/** Your own text for 「複製成 Markdown」, from the same rows (all pages, sorted). */
|
|
90
|
+
copyText?: (rows: R[]) => string;
|
|
91
|
+
/** Copying failed (the browser does not allow the clipboard): say so, for example in a Toast. */
|
|
92
|
+
onCopyError?: () => void;
|
|
93
|
+
/** Default 「沒有符合的資料」. */
|
|
94
|
+
emptyText?: string;
|
|
95
|
+
className?: string;
|
|
96
|
+
}
|
|
97
|
+
/** The table for records: sort, search, filters, page numbers, selection with a bulk bar, row actions; cards on phones. */
|
|
98
|
+
export declare function DataTable<R extends Row = Record<string, unknown>>(p: DataTableProps<R>): React.JSX.Element;
|
|
99
|
+
export type { DataTableColumn, DataTableFilter, DataTableView, FilterOption, FilterValue, RangeValue, Row, RowKey, Total };
|