@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,58 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { tr } from "../../i18n.js";
|
|
3
|
+
import { cx } from "../../internal/util.js";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
// src/components/Badge/Badge.tsx
|
|
6
|
+
const STATUS = {
|
|
7
|
+
draft: {
|
|
8
|
+
label: "草稿",
|
|
9
|
+
fill: ""
|
|
10
|
+
},
|
|
11
|
+
doing: {
|
|
12
|
+
label: "進行中",
|
|
13
|
+
fill: "M12 4a8 8 0 0 1 0 16z"
|
|
14
|
+
},
|
|
15
|
+
review: {
|
|
16
|
+
label: "審核中",
|
|
17
|
+
fill: "M12 4a8 8 0 0 1 8 8h-8z"
|
|
18
|
+
},
|
|
19
|
+
done: {
|
|
20
|
+
label: "完成",
|
|
21
|
+
fill: "M12 4a8 8 0 1 1 0 16a8 8 0 1 1 0-16z"
|
|
22
|
+
},
|
|
23
|
+
fail: {
|
|
24
|
+
label: "失敗",
|
|
25
|
+
fill: "M12 4a8 8 0 1 1 0 16a8 8 0 1 1 0-16z"
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
/** Status of an item. The mark's shape carries the status too, so it never depends on color alone. */
|
|
29
|
+
function Badge({ status, variant = "chip", children, className }) {
|
|
30
|
+
const st = STATUS[status] ? status : "draft";
|
|
31
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
32
|
+
className: cx("ui-badge", "ui-badge-" + st, variant === "dot" && "is-dot", className),
|
|
33
|
+
children: [/* @__PURE__ */ jsxs("svg", {
|
|
34
|
+
className: "ui-badge-mark",
|
|
35
|
+
width: 15,
|
|
36
|
+
height: 15,
|
|
37
|
+
viewBox: "0 0 24 24",
|
|
38
|
+
"aria-hidden": "true",
|
|
39
|
+
children: [/* @__PURE__ */ jsx("circle", {
|
|
40
|
+
cx: 12,
|
|
41
|
+
cy: 12,
|
|
42
|
+
r: 8,
|
|
43
|
+
fill: "none",
|
|
44
|
+
stroke: "currentColor",
|
|
45
|
+
strokeWidth: 2.5
|
|
46
|
+
}), STATUS[st].fill ? /* @__PURE__ */ jsx("path", {
|
|
47
|
+
d: STATUS[st].fill,
|
|
48
|
+
fill: "currentColor"
|
|
49
|
+
}) : null]
|
|
50
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
51
|
+
className: "ui-badge-text",
|
|
52
|
+
children: children || tr(STATUS[st].label)
|
|
53
|
+
})]
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
export { Badge };
|
|
57
|
+
|
|
58
|
+
//# sourceMappingURL=Badge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Badge.js","names":[],"sources":["../../../src/components/Badge/Badge.tsx"],"sourcesContent":["import type * as React from 'react';\nimport { tr } from '../../i18n';\nimport { cx } from '../../internal/util';\n\nexport type BadgeStatus = 'draft' | 'doing' | 'review' | 'done' | 'fail';\n\nconst STATUS: Record<BadgeStatus, { label: string; fill: string }> = {\n draft: { label: '草稿', fill: '' },\n doing: { label: '進行中', fill: 'M12 4a8 8 0 0 1 0 16z' },\n review: { label: '審核中', fill: 'M12 4a8 8 0 0 1 8 8h-8z' },\n done: { label: '完成', fill: 'M12 4a8 8 0 1 1 0 16a8 8 0 1 1 0-16z' },\n fail: { label: '失敗', fill: 'M12 4a8 8 0 1 1 0 16a8 8 0 1 1 0-16z' },\n};\n\nexport interface BadgeProps {\n status: BadgeStatus;\n /** 'dot' on cards: a mark and colored text, no chip. Default 'chip'. */\n variant?: 'chip' | 'dot';\n /** Default: the status name (草稿, 進行中, 審核中, 完成, 失敗). */\n children?: React.ReactNode;\n className?: string;\n}\n\n/** Status of an item. The mark's shape carries the status too, so it never depends on color alone. */\nexport function Badge({ status, variant = 'chip', children, className }: BadgeProps) {\n const st = STATUS[status] ? status : 'draft';\n return (\n <span className={cx('ui-badge', 'ui-badge-' + st, variant === 'dot' && 'is-dot', className)}>\n <svg className=\"ui-badge-mark\" width={15} height={15} viewBox=\"0 0 24 24\" aria-hidden=\"true\">\n <circle cx={12} cy={12} r={8} fill=\"none\" stroke=\"currentColor\" strokeWidth={2.5} />\n {STATUS[st].fill ? <path d={STATUS[st].fill} fill=\"currentColor\" /> : null}\n </svg>\n <span className=\"ui-badge-text\">{children || tr(STATUS[st].label)}</span>\n </span>\n );\n}\n"],"mappings":";;;;;AAMA,MAAM,SAA+D;CACnE,OAAO;EAAE,OAAO;EAAM,MAAM;CAAG;CAC/B,OAAO;EAAE,OAAO;EAAO,MAAM;CAAwB;CACrD,QAAQ;EAAE,OAAO;EAAO,MAAM;CAA0B;CACxD,MAAM;EAAE,OAAO;EAAM,MAAM;CAAuC;CAClE,MAAM;EAAE,OAAO;EAAM,MAAM;CAAuC;AACpE;;AAYA,SAAgB,MAAM,EAAE,QAAQ,UAAU,QAAQ,UAAU,aAAyB;CACnF,MAAM,KAAK,OAAO,UAAU,SAAS;CACrC,OACE,qBAAC,QAAD;EAAM,WAAW,GAAG,YAAY,cAAc,IAAI,YAAY,SAAS,UAAU,SAAS;EAA1F,UAAA,CACE,qBAAC,OAAD;GAAK,WAAU;GAAgB,OAAO;GAAI,QAAQ;GAAI,SAAQ;GAAY,eAAY;GAAtF,UAAA,CACE,oBAAC,UAAD;IAAQ,IAAI;IAAI,IAAI;IAAI,GAAG;IAAG,MAAK;IAAO,QAAO;IAAe,aAAa;GAAM,CAAA,GAClF,OAAO,GAAG,CAAC,OAAO,oBAAC,QAAD;IAAM,GAAG,OAAO,GAAG,CAAC;IAAM,MAAK;GAAgB,CAAA,IAAI,IACnE;EACL,CAAA,GAAA,oBAAC,QAAD;GAAM,WAAU;GAAiB,UAAA,YAAY,GAAG,OAAO,GAAG,CAAC,KAAK;EAAQ,CAAA,CACpE;;AAEV"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
export interface BarDatum {
|
|
3
|
+
label: string;
|
|
4
|
+
/** Shorter x-axis label when the full one would crowd. */
|
|
5
|
+
short?: string;
|
|
6
|
+
value: number;
|
|
7
|
+
}
|
|
8
|
+
export interface BarChartProps {
|
|
9
|
+
data: BarDatum[];
|
|
10
|
+
/** Describes the chart for screen readers. */
|
|
11
|
+
label: string;
|
|
12
|
+
unit?: string;
|
|
13
|
+
/** Decimals of the values in the tooltip. Default 0. */
|
|
14
|
+
decimals?: number;
|
|
15
|
+
max?: number;
|
|
16
|
+
className?: string;
|
|
17
|
+
}
|
|
18
|
+
/** Compares a few categories: rounded bars that grow in, a tooltip on hover. */
|
|
19
|
+
export declare function BarChart({ data, label, unit, decimals, max, className }: BarChartProps): React.JSX.Element;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { ChartTip, TICKS, chartKey, niceMax, tickDecimals } from "../../internal/chart.js";
|
|
3
|
+
import { cx, digits } from "../../internal/util.js";
|
|
4
|
+
import { format } from "../../format.js";
|
|
5
|
+
import { tr } from "../../i18n.js";
|
|
6
|
+
import { announce } from "../../announce.js";
|
|
7
|
+
import * as React from "react";
|
|
8
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
// src/components/BarChart/BarChart.tsx
|
|
10
|
+
/** Compares a few categories: rounded bars that grow in, a tooltip on hover. */
|
|
11
|
+
function BarChart({ data, label, unit, decimals, max, className }) {
|
|
12
|
+
const [hi, setHi] = React.useState(-1);
|
|
13
|
+
const top = max || niceMax(Math.max(1, ...data.map((d) => d.value)));
|
|
14
|
+
const suffix = unit ? " " + unit : "";
|
|
15
|
+
const show = (i) => {
|
|
16
|
+
setHi(i);
|
|
17
|
+
announce(data[i].label + tr(":") + format.number(data[i].value, decimals) + suffix);
|
|
18
|
+
};
|
|
19
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
20
|
+
className: cx("ui-chart", className),
|
|
21
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
22
|
+
className: "ui-bars",
|
|
23
|
+
role: "img",
|
|
24
|
+
"aria-label": label,
|
|
25
|
+
"aria-description": tr("左右方向鍵查看每一項的數值"),
|
|
26
|
+
tabIndex: data.length ? 0 : void 0,
|
|
27
|
+
onMouseLeave: () => setHi(-1),
|
|
28
|
+
onFocus: () => hi < 0 && data.length && show(0),
|
|
29
|
+
onBlur: () => setHi(-1),
|
|
30
|
+
onKeyDown: (e) => {
|
|
31
|
+
const to = chartKey(e, hi, data.length);
|
|
32
|
+
if (to != null) show(to);
|
|
33
|
+
},
|
|
34
|
+
children: [TICKS.map((f, i) => /* @__PURE__ */ jsx("div", {
|
|
35
|
+
className: cx("ui-bars-grid", !i && "is-axis"),
|
|
36
|
+
style: { bottom: f * 100 + "%" },
|
|
37
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
38
|
+
className: "ui-chart-tick",
|
|
39
|
+
children: format.number(f * top, tickDecimals(top))
|
|
40
|
+
})
|
|
41
|
+
}, "g" + i)), /* @__PURE__ */ jsx("div", {
|
|
42
|
+
className: "ui-bars-row",
|
|
43
|
+
children: data.map((d, i) => {
|
|
44
|
+
const ht = d.value / top * 100 + "%";
|
|
45
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
46
|
+
className: "ui-bar-slot",
|
|
47
|
+
onMouseEnter: () => setHi(i),
|
|
48
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
49
|
+
className: "ui-bar",
|
|
50
|
+
style: {
|
|
51
|
+
height: ht,
|
|
52
|
+
animationDelay: i * 40 + "ms",
|
|
53
|
+
opacity: hi >= 0 && hi !== i ? .55 : 1
|
|
54
|
+
}
|
|
55
|
+
}), hi === i ? /* @__PURE__ */ jsx(ChartTip, {
|
|
56
|
+
style: {
|
|
57
|
+
bottom: `calc(${ht} + 8px)`,
|
|
58
|
+
left: "50%",
|
|
59
|
+
transform: "translateX(-50%)",
|
|
60
|
+
whiteSpace: "nowrap"
|
|
61
|
+
},
|
|
62
|
+
rows: [{
|
|
63
|
+
name: d.label,
|
|
64
|
+
value: format.number(d.value, decimals) + suffix
|
|
65
|
+
}]
|
|
66
|
+
}) : null]
|
|
67
|
+
}, i);
|
|
68
|
+
})
|
|
69
|
+
})]
|
|
70
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
71
|
+
className: "ui-bars-labels",
|
|
72
|
+
children: data.map((d, i) => /* @__PURE__ */ jsx("span", { children: digits(d.short || d.label) }, i))
|
|
73
|
+
})]
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
export { BarChart };
|
|
77
|
+
|
|
78
|
+
//# sourceMappingURL=BarChart.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BarChart.js","names":[],"sources":["../../../src/components/BarChart/BarChart.tsx"],"sourcesContent":["import * as React from 'react';\nimport { ChartTip, TICKS, chartKey, tickDecimals, niceMax } from '../../internal/chart';\nimport { cx, digits } from '../../internal/util';\nimport { format } from '../../format';\nimport { tr } from '../../i18n';\nimport { announce } from '../../announce';\n\nexport interface BarDatum {\n label: string;\n /** Shorter x-axis label when the full one would crowd. */\n short?: string;\n value: number;\n}\n\nexport interface BarChartProps {\n data: BarDatum[];\n /** Describes the chart for screen readers. */\n label: string;\n unit?: string;\n /** Decimals of the values in the tooltip. Default 0. */\n decimals?: number;\n max?: number;\n className?: string;\n}\n\n/** Compares a few categories: rounded bars that grow in, a tooltip on hover. */\nexport function BarChart({ data, label, unit, decimals, max, className }: BarChartProps) {\n const [hi, setHi] = React.useState(-1);\n const top = max || niceMax(Math.max(1, ...data.map((d) => d.value)));\n const suffix = unit ? ' ' + unit : '';\n const show = (i: number) => {\n setHi(i);\n announce(data[i].label + tr(':') + format.number(data[i].value, decimals) + suffix);\n };\n return (\n <div className={cx('ui-chart', className)}>\n <div\n className=\"ui-bars\"\n role=\"img\"\n aria-label={label}\n aria-description={tr('左右方向鍵查看每一項的數值')}\n tabIndex={data.length ? 0 : undefined}\n onMouseLeave={() => setHi(-1)}\n // The keyboard sees the values too: ← → move between bars, each read aloud as it shows.\n onFocus={() => hi < 0 && data.length && show(0)}\n onBlur={() => setHi(-1)}\n onKeyDown={(e) => {\n const to = chartKey(e, hi, data.length);\n if (to != null) show(to);\n }}\n >\n {TICKS.map((f, i) => (\n <div key={'g' + i} className={cx('ui-bars-grid', !i && 'is-axis')} style={{ bottom: f * 100 + '%' }}>\n <span className=\"ui-chart-tick\">{format.number(f * top, tickDecimals(top))}</span>\n </div>\n ))}\n <div className=\"ui-bars-row\">\n {data.map((d, i) => {\n const ht = (d.value / top) * 100 + '%';\n return (\n <div key={i} className=\"ui-bar-slot\" onMouseEnter={() => setHi(i)}>\n <div className=\"ui-bar\" style={{ height: ht, animationDelay: i * 40 + 'ms', opacity: hi >= 0 && hi !== i ? 0.55 : 1 }} />\n {hi === i ? (\n <ChartTip\n style={{ bottom: `calc(${ht} + 8px)`, left: '50%', transform: 'translateX(-50%)', whiteSpace: 'nowrap' }}\n rows={[{ name: d.label, value: format.number(d.value, decimals) + suffix }]}\n />\n ) : null}\n </div>\n );\n })}\n </div>\n </div>\n <div className=\"ui-bars-labels\">\n {data.map((d, i) => (\n <span key={i}>{digits(d.short || d.label)}</span>\n ))}\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;AA0BA,SAAgB,SAAS,EAAE,MAAM,OAAO,MAAM,UAAU,KAAK,aAA4B;CACvF,MAAM,CAAC,IAAI,SAAS,MAAM,SAAS,EAAE;CACrC,MAAM,MAAM,OAAO,QAAQ,KAAK,IAAI,GAAG,GAAG,KAAK,KAAK,MAAM,EAAE,KAAK,CAAC,CAAC;CACnE,MAAM,SAAS,OAAO,MAAM,OAAO;CACnC,MAAM,QAAQ,MAAc;EAC1B,MAAM,CAAC;EACP,SAAS,KAAK,EAAE,CAAC,QAAQ,GAAG,GAAG,IAAI,OAAO,OAAO,KAAK,EAAE,CAAC,OAAO,QAAQ,IAAI,MAAM;CACpF;CACA,OACE,qBAAC,OAAD;EAAK,WAAW,GAAG,YAAY,SAAS;EAAxC,UAAA,CACE,qBAAC,OAAD;GACE,WAAU;GACV,MAAK;GACL,cAAY;GACZ,oBAAkB,GAAG,eAAe;GACpC,UAAU,KAAK,SAAS,IAAI,KAAA;GAC5B,oBAAoB,MAAM,EAAE;GAE5B,eAAe,KAAK,KAAK,KAAK,UAAU,KAAK,CAAC;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|
+
export interface BreadcrumbItem {
|
|
2
|
+
label: string;
|
|
3
|
+
href?: string;
|
|
4
|
+
}
|
|
5
|
+
export interface BreadcrumbProps {
|
|
6
|
+
/** From the top level down; the last one is the current page. */
|
|
7
|
+
items: BreadcrumbItem[];
|
|
8
|
+
className?: string;
|
|
9
|
+
}
|
|
10
|
+
/** Where the page sits: links to each level, the current page last and not a link. */
|
|
11
|
+
export declare function Breadcrumb({ items, className }: BreadcrumbProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { tr } from "../../i18n.js";
|
|
3
|
+
import { cx } from "../../internal/util.js";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
// src/components/Breadcrumb/Breadcrumb.tsx
|
|
6
|
+
/** Where the page sits: links to each level, the current page last and not a link. */
|
|
7
|
+
function Breadcrumb({ items, className }) {
|
|
8
|
+
return /* @__PURE__ */ jsx("nav", {
|
|
9
|
+
className: cx("ui-crumb", className),
|
|
10
|
+
"aria-label": tr("路徑"),
|
|
11
|
+
children: /* @__PURE__ */ jsx("ol", { children: items.map((it, i) => {
|
|
12
|
+
const last = i === items.length - 1;
|
|
13
|
+
return /* @__PURE__ */ jsxs("li", { children: [last ? /* @__PURE__ */ jsx("span", {
|
|
14
|
+
"aria-current": "page",
|
|
15
|
+
children: it.label
|
|
16
|
+
}) : it.href ? /* @__PURE__ */ jsx("a", {
|
|
17
|
+
href: it.href,
|
|
18
|
+
children: it.label
|
|
19
|
+
}) : /* @__PURE__ */ jsx("span", { children: it.label }), last ? null : /* @__PURE__ */ jsx("span", {
|
|
20
|
+
className: "ui-crumb-sep",
|
|
21
|
+
"aria-hidden": "true",
|
|
22
|
+
children: "›"
|
|
23
|
+
})] }, i);
|
|
24
|
+
}) })
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
export { Breadcrumb };
|
|
28
|
+
|
|
29
|
+
//# sourceMappingURL=Breadcrumb.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Breadcrumb.js","names":[],"sources":["../../../src/components/Breadcrumb/Breadcrumb.tsx"],"sourcesContent":["import { tr } from '../../i18n';\nimport { cx } from '../../internal/util';\n\nexport interface BreadcrumbItem {\n label: string;\n href?: string;\n}\n\nexport interface BreadcrumbProps {\n /** From the top level down; the last one is the current page. */\n items: BreadcrumbItem[];\n className?: string;\n}\n\n/** Where the page sits: links to each level, the current page last and not a link. */\nexport function Breadcrumb({ items, className }: BreadcrumbProps) {\n return (\n <nav className={cx('ui-crumb', className)} aria-label={tr('路徑')}>\n <ol>\n {items.map((it, i) => {\n const last = i === items.length - 1;\n return (\n <li key={i}>\n {last ? <span aria-current=\"page\">{it.label}</span> : it.href ? <a href={it.href}>{it.label}</a> : <span>{it.label}</span>}\n {last ? null : (\n <span className=\"ui-crumb-sep\" aria-hidden=\"true\">\n ›\n </span>\n )}\n </li>\n );\n })}\n </ol>\n </nav>\n );\n}\n"],"mappings":";;;;;;AAeA,SAAgB,WAAW,EAAE,OAAO,aAA8B;CAChE,OACE,oBAAC,OAAD;EAAK,WAAW,GAAG,YAAY,SAAS;EAAG,cAAY,GAAG,IAAI;EAC5D,UAAA,oBAAC,MAAD,EAAA,UACG,MAAM,KAAK,IAAI,MAAM;GACpB,MAAM,OAAO,MAAM,MAAM,SAAS;GAClC,OACE,qBAAC,MAAD,EAAA,UAAA,CACG,OAAO,oBAAC,QAAD;IAAM,gBAAa;IAAQ,UAAA,GAAG;GAAY,CAAA,IAAI,GAAG,OAAO,oBAAC,KAAD;IAAG,MAAM,GAAG;IAAO,UAAA,GAAG;GAAS,CAAA,IAAI,oBAAC,QAAD,EAAA,UAAO,GAAG,MAAY,CAAA,GACxH,OAAO,OACN,oBAAC,QAAD;IAAM,WAAU;IAAe,eAAY;IAAO,UAAA;GAE5C,CAAA,CAEN,EAAA,GAPK,CAOL;EAER,CAAC,EACC,CAAA;CACD,CAAA;AAET"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { IconSource } from "../../icons/Icon.js";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
interface ButtonBase extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'children'> {
|
|
4
|
+
/** A verb: 儲存, 刪除, 匯出. No 「確定」or 「好」. */
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
/** Shows a spinner and disables the button; pair it with a progressive label such as 儲存中. */
|
|
7
|
+
loading?: boolean;
|
|
8
|
+
/** Leading icon: a built-in name such as 'plus', or custom path data. */
|
|
9
|
+
icon?: IconSource;
|
|
10
|
+
ref?: React.Ref<HTMLButtonElement>;
|
|
11
|
+
}
|
|
12
|
+
/** What the confirm dialog of a danger button says. */
|
|
13
|
+
export interface DangerConfirm {
|
|
14
|
+
/** Names the object: 「刪除 api-gateway?」. */
|
|
15
|
+
title: string;
|
|
16
|
+
/** What is lost and whether it can be undone. */
|
|
17
|
+
body?: React.ReactNode;
|
|
18
|
+
/** The danger button's label in the dialog. Default: the button's own label. */
|
|
19
|
+
confirmLabel?: string;
|
|
20
|
+
}
|
|
21
|
+
export type ButtonProps = (ButtonBase & {
|
|
22
|
+
/** primary: the one main action of a section (solid). secondary (default): everything else (outline). quiet:
|
|
23
|
+
* low-emphasis and toolbar actions, text only with no border, a gray background on hover. */
|
|
24
|
+
variant?: 'primary' | 'secondary' | 'quiet';
|
|
25
|
+
}) | (ButtonBase & {
|
|
26
|
+
/** Destructive. Must be confirmed: pass `confirm`, or `confirmed` when this button is itself inside the confirm Dialog. */
|
|
27
|
+
variant: 'danger';
|
|
28
|
+
/** Opens a Dialog first; onClick runs only after the person confirms. */
|
|
29
|
+
confirm: DangerConfirm;
|
|
30
|
+
confirmed?: never;
|
|
31
|
+
}) | (ButtonBase & {
|
|
32
|
+
variant: 'danger';
|
|
33
|
+
/** This button is the confirming button of a Dialog (or DangerZone), so it runs at once. */
|
|
34
|
+
confirmed: true;
|
|
35
|
+
confirm?: never;
|
|
36
|
+
});
|
|
37
|
+
/** Buttons. Labels are verbs; one primary per section; danger actions are always confirmed. */
|
|
38
|
+
export declare function Button(props: ButtonProps): React.JSX.Element;
|
|
39
|
+
export {};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { IconOf, Spinner } from "../../icons/Icon.js";
|
|
3
|
+
import { cx } from "../../internal/util.js";
|
|
4
|
+
import { devWarn } from "../../internal/dev.js";
|
|
5
|
+
import { tr } from "../../i18n.js";
|
|
6
|
+
import { Dialog } from "../Dialog/Dialog.js";
|
|
7
|
+
import * as React from "react";
|
|
8
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
// src/components/Button/Button.tsx
|
|
10
|
+
/** Buttons. Labels are verbs; one primary per section; danger actions are always confirmed. */
|
|
11
|
+
function Button(props) {
|
|
12
|
+
const { variant = "secondary", loading, icon, className, children, disabled, onClick, ...other } = props;
|
|
13
|
+
const { confirm, confirmed, ...native } = other;
|
|
14
|
+
const [asking, setAsking] = React.useState(false);
|
|
15
|
+
devWarn(variant === "danger" && !confirm && !confirmed, "Button", "a danger button needs confirm={{ title }} (or confirmed when it is the button inside the confirm Dialog).");
|
|
16
|
+
const ownEvent = React.useRef(null);
|
|
17
|
+
const button = /* @__PURE__ */ jsxs("button", {
|
|
18
|
+
type: "button",
|
|
19
|
+
...native,
|
|
20
|
+
className: cx("ui-btn", "ui-btn-" + variant, loading && "is-loading", className),
|
|
21
|
+
disabled: disabled || loading,
|
|
22
|
+
"aria-busy": loading || void 0,
|
|
23
|
+
onClick: (e) => {
|
|
24
|
+
if (confirm) {
|
|
25
|
+
e.preventDefault();
|
|
26
|
+
ownEvent.current = {
|
|
27
|
+
event: e,
|
|
28
|
+
button: e.currentTarget
|
|
29
|
+
};
|
|
30
|
+
setAsking(true);
|
|
31
|
+
} else onClick?.(e);
|
|
32
|
+
},
|
|
33
|
+
children: [loading ? /* @__PURE__ */ jsx(Spinner, {}) : icon ? /* @__PURE__ */ jsx(IconOf, { icon }) : null, children]
|
|
34
|
+
});
|
|
35
|
+
if (!confirm) return button;
|
|
36
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [button, /* @__PURE__ */ jsx(Dialog, {
|
|
37
|
+
open: asking,
|
|
38
|
+
onClose: () => setAsking(false),
|
|
39
|
+
title: confirm.title,
|
|
40
|
+
tone: "danger",
|
|
41
|
+
confirmLabel: confirm.confirmLabel ?? (typeof children === "string" ? children : tr("刪除")),
|
|
42
|
+
onConfirm: () => {
|
|
43
|
+
setAsking(false);
|
|
44
|
+
const own = ownEvent.current;
|
|
45
|
+
if (!own) return;
|
|
46
|
+
onClick?.(own.event);
|
|
47
|
+
if (own.button.type === "submit") own.button.form?.requestSubmit(own.button);
|
|
48
|
+
},
|
|
49
|
+
children: confirm.body
|
|
50
|
+
})] });
|
|
51
|
+
}
|
|
52
|
+
export { Button };
|
|
53
|
+
|
|
54
|
+
//# sourceMappingURL=Button.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Button.js","names":[],"sources":["../../../src/components/Button/Button.tsx"],"sourcesContent":["import * as React from 'react';\nimport { IconOf, Spinner, type IconSource } from '../../icons/Icon';\nimport { cx } from '../../internal/util';\nimport { devWarn } from '../../internal/dev';\nimport { tr } from '../../i18n';\nimport { Dialog } from '../Dialog/Dialog';\n\ninterface ButtonBase extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'children'> {\n /** A verb: 儲存, 刪除, 匯出. No 「確定」or 「好」. */\n children: React.ReactNode;\n /** Shows a spinner and disables the button; pair it with a progressive label such as 儲存中. */\n loading?: boolean;\n /** Leading icon: a built-in name such as 'plus', or custom path data. */\n icon?: IconSource;\n ref?: React.Ref<HTMLButtonElement>;\n}\n\n/** What the confirm dialog of a danger button says. */\nexport interface DangerConfirm {\n /** Names the object: 「刪除 api-gateway?」. */\n title: string;\n /** What is lost and whether it can be undone. */\n body?: React.ReactNode;\n /** The danger button's label in the dialog. Default: the button's own label. */\n confirmLabel?: string;\n}\n\nexport type ButtonProps =\n | (ButtonBase & {\n /** primary: the one main action of a section (solid). secondary (default): everything else (outline). quiet:\n * low-emphasis and toolbar actions, text only with no border, a gray background on hover. */\n variant?: 'primary' | 'secondary' | 'quiet';\n })\n | (ButtonBase & {\n /** Destructive. Must be confirmed: pass `confirm`, or `confirmed` when this button is itself inside the confirm Dialog. */\n variant: 'danger';\n /** Opens a Dialog first; onClick runs only after the person confirms. */\n confirm: DangerConfirm;\n confirmed?: never;\n })\n | (ButtonBase & {\n variant: 'danger';\n /** This button is the confirming button of a Dialog (or DangerZone), so it runs at once. */\n confirmed: true;\n confirm?: never;\n });\n\n/** Buttons. Labels are verbs; one primary per section; danger actions are always confirmed. */\nexport function Button(props: ButtonProps) {\n const { variant = 'secondary', loading, icon, className, children, disabled, onClick, ...other } = props;\n const { confirm, confirmed, ...native } = other as typeof other & { confirm?: DangerConfirm; confirmed?: boolean };\n const [asking, setAsking] = React.useState(false);\n devWarn(\n variant === 'danger' && !confirm && !confirmed,\n 'Button',\n 'a danger button needs confirm={{ title }} (or confirmed when it is the button inside the confirm Dialog).',\n );\n const ownEvent = React.useRef<{ event: React.MouseEvent<HTMLButtonElement>; button: HTMLButtonElement } | null>(null);\n const button = (\n <button\n type=\"button\"\n {...native}\n className={cx('ui-btn', 'ui-btn-' + variant, loading && 'is-loading', className)}\n disabled={disabled || loading}\n aria-busy={loading || undefined}\n onClick={(e) => {\n if (confirm) {\n // A submit button must not submit before the person confirms.\n e.preventDefault();\n ownEvent.current = { event: e, button: e.currentTarget };\n setAsking(true);\n } else onClick?.(e);\n }}\n >\n {loading ? <Spinner /> : icon ? <IconOf icon={icon} /> : null}\n {children}\n </button>\n );\n if (!confirm) return button;\n return (\n <>\n {button}\n <Dialog\n open={asking}\n onClose={() => setAsking(false)}\n title={confirm.title}\n tone=\"danger\"\n confirmLabel={confirm.confirmLabel ?? (typeof children === 'string' ? children : tr('刪除'))}\n onConfirm={() => {\n setAsking(false);\n const own = ownEvent.current;\n if (!own) return;\n onClick?.(own.event);\n if (own.button.type === 'submit') own.button.form?.requestSubmit(own.button);\n }}\n >\n {confirm.body}\n </Dialog>\n </>\n );\n}\n"],"mappings":";;;;;;;;;;AAgDA,SAAgB,OAAO,OAAoB;CACzC,MAAM,EAAE,UAAU,aAAa,SAAS,MAAM,WAAW,UAAU,UAAU,SAAS,GAAG,UAAU;CACnG,MAAM,EAAE,SAAS,WAAW,GAAG,WAAW;CAC1C,MAAM,CAAC,QAAQ,aAAa,MAAM,SAAS,KAAK;CAChD,QACE,YAAY,YAAY,CAAC,WAAW,CAAC,WACrC,UACA,2GACF;CACA,MAAM,WAAW,MAAM,OAAyF,IAAI;CACpH,MAAM,SACJ,qBAAC,UAAD;EACE,MAAK;EACL,GAAI;EACJ,WAAW,GAAG,UAAU,YAAY,SAAS,WAAW,cAAc,SAAS;EAC/E,UAAU,YAAY;EACtB,aAAW,WAAW,KAAA;EACtB,UAAU,MAAM;GACd,IAAI,SAAS;IAEX,EAAE,eAAe;IACjB,SAAS,UAAU;KAAE,OAAO;KAAG,QAAQ,EAAE;IAAc;IACvD,UAAU,IAAI;GAChB,OAAO,UAAU,CAAC;EACpB;EAbF,UAAA,CAeG,UAAU,oBAAC,SAAD,CAAU,CAAA,IAAI,OAAO,oBAAC,QAAD,EAAc,KAAO,CAAA,IAAI,MACxD,QACK;;CAEV,IAAI,CAAC,SAAS,OAAO;CACrB,OACE,qBAAA,UAAA,EAAA,UAAA,CACG,QACD,oBAAC,QAAD;EACE,MAAM;EACN,eAAe,UAAU,KAAK;EAC9B,OAAO,QAAQ;EACf,MAAK;EACL,cAAc,QAAQ,iBAAiB,OAAO,aAAa,WAAW,WAAW,GAAG,IAAI;EACxF,iBAAiB;GACf,UAAU,KAAK;GACf,MAAM,MAAM,SAAS;GACrB,IAAI,CAAC,KAAK;GACV,UAAU,IAAI,KAAK;GACnB,IAAI,IAAI,OAAO,SAAS,UAAU,IAAI,OAAO,MAAM,cAAc,IAAI,MAAM;EAC7E;EAEC,UAAA,QAAQ;CACH,CAAA,CACR,EAAA,CAAA;AAEN"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
export interface DayState {
|
|
3
|
+
selected?: boolean;
|
|
4
|
+
inRange?: boolean;
|
|
5
|
+
start?: boolean;
|
|
6
|
+
end?: boolean;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface CalendarProps {
|
|
10
|
+
/** The month shown first. Default: this month. */
|
|
11
|
+
focus?: Date | null;
|
|
12
|
+
onPick?: (d: Date) => void;
|
|
13
|
+
onHover?: (d: Date | null) => void;
|
|
14
|
+
/** How each day looks: selected, inside a range, disabled. */
|
|
15
|
+
dayState?: (d: Date) => DayState | undefined;
|
|
16
|
+
}
|
|
17
|
+
/** A month grid: selected days are rounded squares, today has a dot under the number. */
|
|
18
|
+
export declare function Calendar({ focus, onPick, onHover, dayState }: CalendarProps): React.JSX.Element;
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { dayAdd, format, sameDay } from "../../format.js";
|
|
3
|
+
import { tr } from "../../i18n.js";
|
|
4
|
+
import { Icon } from "../../icons/Icon.js";
|
|
5
|
+
import { browserKey, cx } from "../../internal/util.js";
|
|
6
|
+
import * as React from "react";
|
|
7
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
// src/components/Calendar/Calendar.tsx
|
|
9
|
+
/** A month grid: selected days are rounded squares, today has a dot under the number. */
|
|
10
|
+
function Calendar({ focus, onPick, onHover, dayState }) {
|
|
11
|
+
const [month, setMonth] = React.useState(() => {
|
|
12
|
+
const b = focus || /* @__PURE__ */ new Date();
|
|
13
|
+
return new Date(b.getFullYear(), b.getMonth(), 1);
|
|
14
|
+
});
|
|
15
|
+
const today = /* @__PURE__ */ new Date();
|
|
16
|
+
const y = month.getFullYear();
|
|
17
|
+
const m = month.getMonth();
|
|
18
|
+
const [active, setActive] = React.useState(() => focus || today);
|
|
19
|
+
const cur = active.getFullYear() === y && active.getMonth() === m ? active : new Date(y, m, Math.min(active.getDate(), new Date(y, m + 1, 0).getDate()));
|
|
20
|
+
const grid = React.useRef(null);
|
|
21
|
+
const moveTo = React.useRef(false);
|
|
22
|
+
React.useEffect(() => {
|
|
23
|
+
if (!moveTo.current) return;
|
|
24
|
+
moveTo.current = false;
|
|
25
|
+
grid.current?.querySelector(".ui-cal-day[tabindex=\"0\"]")?.focus();
|
|
26
|
+
});
|
|
27
|
+
const go = (d) => {
|
|
28
|
+
const step = d < cur ? -1 : 1;
|
|
29
|
+
for (let k = 0; k < 31 && dayState?.(d)?.disabled; k++) d = dayAdd(d, step);
|
|
30
|
+
setActive(d);
|
|
31
|
+
if (d.getMonth() !== m || d.getFullYear() !== y) setMonth(new Date(d.getFullYear(), d.getMonth(), 1));
|
|
32
|
+
moveTo.current = true;
|
|
33
|
+
onHover?.(d);
|
|
34
|
+
};
|
|
35
|
+
const onKey = (e) => {
|
|
36
|
+
if (browserKey(e)) return;
|
|
37
|
+
const wd = (cur.getDay() - format.firstDay() + 7) % 7;
|
|
38
|
+
const sameDayIn = (dm) => {
|
|
39
|
+
const last = new Date(cur.getFullYear(), cur.getMonth() + dm + 1, 0).getDate();
|
|
40
|
+
return new Date(cur.getFullYear(), cur.getMonth() + dm, Math.min(cur.getDate(), last));
|
|
41
|
+
};
|
|
42
|
+
const to = {
|
|
43
|
+
ArrowLeft: () => dayAdd(cur, -1),
|
|
44
|
+
ArrowRight: () => dayAdd(cur, 1),
|
|
45
|
+
ArrowUp: () => dayAdd(cur, -7),
|
|
46
|
+
ArrowDown: () => dayAdd(cur, 7),
|
|
47
|
+
Home: () => dayAdd(cur, -wd),
|
|
48
|
+
End: () => dayAdd(cur, 6 - wd),
|
|
49
|
+
PageUp: () => sameDayIn(-1),
|
|
50
|
+
PageDown: () => sameDayIn(1)
|
|
51
|
+
};
|
|
52
|
+
if (!to[e.key]) return;
|
|
53
|
+
e.preventDefault();
|
|
54
|
+
go(to[e.key]());
|
|
55
|
+
};
|
|
56
|
+
const start = (new Date(y, m, 1).getDay() - format.firstDay() + 7) % 7;
|
|
57
|
+
const days = new Date(y, m + 1, 0).getDate();
|
|
58
|
+
const cells = [...Array(start).fill(null), ...Array.from({ length: days }, (_, i) => new Date(y, m, i + 1))];
|
|
59
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
60
|
+
className: "ui-cal",
|
|
61
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
62
|
+
className: "ui-cal-head",
|
|
63
|
+
children: [
|
|
64
|
+
/* @__PURE__ */ jsx("button", {
|
|
65
|
+
type: "button",
|
|
66
|
+
className: "ui-cal-nav",
|
|
67
|
+
"aria-label": tr("上個月"),
|
|
68
|
+
onClick: () => setMonth(new Date(y, m - 1, 1)),
|
|
69
|
+
children: /* @__PURE__ */ jsx(Icon, {
|
|
70
|
+
name: "caret-left",
|
|
71
|
+
size: 16
|
|
72
|
+
})
|
|
73
|
+
}),
|
|
74
|
+
/* @__PURE__ */ jsx("span", {
|
|
75
|
+
className: "ui-cal-title",
|
|
76
|
+
"aria-live": "polite",
|
|
77
|
+
children: format.month(month)
|
|
78
|
+
}),
|
|
79
|
+
/* @__PURE__ */ jsx("button", {
|
|
80
|
+
type: "button",
|
|
81
|
+
className: "ui-cal-nav",
|
|
82
|
+
"aria-label": tr("下個月"),
|
|
83
|
+
onClick: () => setMonth(new Date(y, m + 1, 1)),
|
|
84
|
+
children: /* @__PURE__ */ jsx(Icon, {
|
|
85
|
+
name: "caret-right",
|
|
86
|
+
size: 16
|
|
87
|
+
})
|
|
88
|
+
})
|
|
89
|
+
]
|
|
90
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
91
|
+
ref: grid,
|
|
92
|
+
className: "ui-cal-grid",
|
|
93
|
+
role: "group",
|
|
94
|
+
"aria-label": format.month(month),
|
|
95
|
+
onKeyDown: onKey,
|
|
96
|
+
children: [format.weekdays().map((w, i) => /* @__PURE__ */ jsx("span", {
|
|
97
|
+
className: "ui-cal-wk",
|
|
98
|
+
"aria-hidden": "true",
|
|
99
|
+
children: w
|
|
100
|
+
}, "w" + i)), cells.map((c, i) => {
|
|
101
|
+
if (!c) return /* @__PURE__ */ jsx("span", {}, "e" + i);
|
|
102
|
+
const st = dayState?.(c) ?? {};
|
|
103
|
+
const isToday = sameDay(c, today);
|
|
104
|
+
return /* @__PURE__ */ jsx("button", {
|
|
105
|
+
type: "button",
|
|
106
|
+
disabled: st.disabled,
|
|
107
|
+
className: cx("ui-cal-day", st.selected && "is-sel", st.inRange && "is-range", st.start && "is-start", st.end && "is-end", isToday && "is-today"),
|
|
108
|
+
"aria-pressed": !!st.selected,
|
|
109
|
+
"aria-label": format.date(c, {
|
|
110
|
+
weekday: false,
|
|
111
|
+
long: true
|
|
112
|
+
}) + (isToday ? tr("(今天)") : ""),
|
|
113
|
+
tabIndex: sameDay(c, cur) ? 0 : -1,
|
|
114
|
+
onFocus: () => !sameDay(c, cur) && setActive(c),
|
|
115
|
+
onClick: () => onPick?.(c),
|
|
116
|
+
onMouseEnter: onHover ? () => onHover(c) : void 0,
|
|
117
|
+
children: c.getDate()
|
|
118
|
+
}, i);
|
|
119
|
+
})]
|
|
120
|
+
})]
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
export { Calendar };
|
|
124
|
+
|
|
125
|
+
//# sourceMappingURL=Calendar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Calendar.js","names":[],"sources":["../../../src/components/Calendar/Calendar.tsx"],"sourcesContent":["import * as React from 'react';\nimport { dayAdd, format, sameDay } from '../../format';\nimport { tr } from '../../i18n';\nimport { Icon } from '../../icons/Icon';\nimport { browserKey, cx } from '../../internal/util';\n\nexport interface DayState {\n selected?: boolean;\n inRange?: boolean;\n start?: boolean;\n end?: boolean;\n disabled?: boolean;\n}\n\nexport interface CalendarProps {\n /** The month shown first. Default: this month. */\n focus?: Date | null;\n onPick?: (d: Date) => void;\n onHover?: (d: Date | null) => void;\n /** How each day looks: selected, inside a range, disabled. */\n dayState?: (d: Date) => DayState | undefined;\n}\n\n/** A month grid: selected days are rounded squares, today has a dot under the number. */\nexport function Calendar({ focus, onPick, onHover, dayState }: CalendarProps) {\n const [month, setMonth] = React.useState(() => {\n const b = focus || new Date();\n return new Date(b.getFullYear(), b.getMonth(), 1);\n });\n const today = new Date();\n const y = month.getFullYear();\n const m = month.getMonth();\n // The day the keyboard is on: the only day in the Tab order (the focused, else the selected, else today, else the\n // 1st), always in the month shown.\n const [active, setActive] = React.useState<Date>(() => focus || today);\n const cur = active.getFullYear() === y && active.getMonth() === m ? active : new Date(y, m, Math.min(active.getDate(), new Date(y, m + 1, 0).getDate()));\n const grid = React.useRef<HTMLDivElement>(null);\n const moveTo = React.useRef(false);\n React.useEffect(() => {\n if (!moveTo.current) return;\n moveTo.current = false;\n grid.current?.querySelector<HTMLButtonElement>('.ui-cal-day[tabindex=\"0\"]')?.focus();\n });\n const go = (d: Date) => {\n // Disabled days are passed over in the same direction, up to a month.\n const step = d < cur ? -1 : 1;\n for (let k = 0; k < 31 && dayState?.(d)?.disabled; k++) d = dayAdd(d, step);\n setActive(d);\n if (d.getMonth() !== m || d.getFullYear() !== y) setMonth(new Date(d.getFullYear(), d.getMonth(), 1));\n moveTo.current = true;\n onHover?.(d);\n };\n const onKey = (e: React.KeyboardEvent) => {\n if (browserKey(e)) return;\n const wd = (cur.getDay() - format.firstDay() + 7) % 7;\n const sameDayIn = (dm: number) => {\n const last = new Date(cur.getFullYear(), cur.getMonth() + dm + 1, 0).getDate();\n return new Date(cur.getFullYear(), cur.getMonth() + dm, Math.min(cur.getDate(), last));\n };\n const to: Record<string, () => Date> = {\n ArrowLeft: () => dayAdd(cur, -1),\n ArrowRight: () => dayAdd(cur, 1),\n ArrowUp: () => dayAdd(cur, -7),\n ArrowDown: () => dayAdd(cur, 7),\n Home: () => dayAdd(cur, -wd),\n End: () => dayAdd(cur, 6 - wd),\n PageUp: () => sameDayIn(-1),\n PageDown: () => sameDayIn(1),\n };\n if (!to[e.key]) return;\n e.preventDefault();\n go(to[e.key]());\n };\n const start = (new Date(y, m, 1).getDay() - format.firstDay() + 7) % 7;\n const days = new Date(y, m + 1, 0).getDate();\n const cells: (Date | null)[] = [...Array<null>(start).fill(null), ...Array.from({ length: days }, (_, i) => new Date(y, m, i + 1))];\n return (\n <div className=\"ui-cal\">\n <div className=\"ui-cal-head\">\n <button type=\"button\" className=\"ui-cal-nav\" aria-label={tr('上個月')} onClick={() => setMonth(new Date(y, m - 1, 1))}>\n <Icon name=\"caret-left\" size={16} />\n </button>\n <span className=\"ui-cal-title\" aria-live=\"polite\">\n {format.month(month)}\n </span>\n <button type=\"button\" className=\"ui-cal-nav\" aria-label={tr('下個月')} onClick={() => setMonth(new Date(y, m + 1, 1))}>\n <Icon name=\"caret-right\" size={16} />\n </button>\n </div>\n <div ref={grid} className=\"ui-cal-grid\" role=\"group\" aria-label={format.month(month)} onKeyDown={onKey}>\n {format.weekdays().map((w, i) => (\n <span key={'w' + i} className=\"ui-cal-wk\" aria-hidden=\"true\">\n {w}\n </span>\n ))}\n {cells.map((c, i) => {\n if (!c) return <span key={'e' + i} />;\n const st = dayState?.(c) ?? {};\n const isToday = sameDay(c, today);\n return (\n <button\n key={i}\n type=\"button\"\n disabled={st.disabled}\n className={cx('ui-cal-day', st.selected && 'is-sel', st.inRange && 'is-range', st.start && 'is-start', st.end && 'is-end', isToday && 'is-today')}\n aria-pressed={!!st.selected}\n aria-label={format.date(c, { weekday: false, long: true }) + (isToday ? tr('(今天)') : '')}\n tabIndex={sameDay(c, cur) ? 0 : -1}\n onFocus={() => !sameDay(c, cur) && setActive(c)}\n onClick={() => onPick?.(c)}\n onMouseEnter={onHover ? () => onHover(c) : undefined}\n >\n {c.getDate()}\n </button>\n );\n })}\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;AAwBA,SAAgB,SAAS,EAAE,OAAO,QAAQ,SAAS,YA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AA,CAAA;;AAET"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
export interface CardProps extends Omit<React.HTMLAttributes<HTMLElement>, 'title'> {
|
|
3
|
+
/** Heading at the top left. */
|
|
4
|
+
title?: React.ReactNode;
|
|
5
|
+
/** Buttons at the top right. */
|
|
6
|
+
actions?: React.ReactNode;
|
|
7
|
+
/** false: no inner padding, for a table or a tree that fills the card. */
|
|
8
|
+
padding?: boolean;
|
|
9
|
+
/** Element to render. Default 'section'. */
|
|
10
|
+
as?: 'section' | 'div' | 'article' | 'aside' | 'form';
|
|
11
|
+
children?: React.ReactNode;
|
|
12
|
+
}
|
|
13
|
+
/** The one container with a shadow. Never put a Card inside a Card: split the content into sections with headings instead. */
|
|
14
|
+
export declare function Card({ as: Tag, title, actions, padding, className, children, ...native }: CardProps): React.JSX.Element;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cx } from "../../internal/util.js";
|
|
3
|
+
import { devWarn } from "../../internal/dev.js";
|
|
4
|
+
import * as React from "react";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
// src/components/Card/Card.tsx
|
|
7
|
+
/** True inside a Card: card-styled components drop their own shadow there. */
|
|
8
|
+
const InCard = React.createContext(false);
|
|
9
|
+
/** The one container with a shadow. Never put a Card inside a Card: split the content into sections with headings instead. */
|
|
10
|
+
function Card({ as: Tag = "section", title, actions, padding = true, className, children, ...native }) {
|
|
11
|
+
const nested = React.useContext(InCard);
|
|
12
|
+
devWarn(nested, "Card", "a Card inside a Card gives two shadows. Use one Card and separate its parts with headings or a divider.");
|
|
13
|
+
return /* @__PURE__ */ jsx(InCard.Provider, {
|
|
14
|
+
value: true,
|
|
15
|
+
children: /* @__PURE__ */ jsxs(Tag, {
|
|
16
|
+
...native,
|
|
17
|
+
className: cx("ui-card", !padding && "is-flush", className),
|
|
18
|
+
children: [title || actions ? /* @__PURE__ */ jsxs("div", {
|
|
19
|
+
className: "ui-card-head",
|
|
20
|
+
children: [title ? /* @__PURE__ */ jsx("h2", {
|
|
21
|
+
className: "ui-card-title",
|
|
22
|
+
children: title
|
|
23
|
+
}) : null, actions ? /* @__PURE__ */ jsx("div", {
|
|
24
|
+
className: "ui-card-actions",
|
|
25
|
+
children: actions
|
|
26
|
+
}) : null]
|
|
27
|
+
}) : null, children]
|
|
28
|
+
})
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
export { Card };
|
|
32
|
+
|
|
33
|
+
//# sourceMappingURL=Card.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Card.js","names":[],"sources":["../../../src/components/Card/Card.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cx } from '../../internal/util';\nimport { devWarn } from '../../internal/dev';\n\n/** True inside a Card: card-styled components drop their own shadow there. */\nconst InCard = React.createContext(false);\n\nexport interface CardProps extends Omit<React.HTMLAttributes<HTMLElement>, 'title'> {\n /** Heading at the top left. */\n title?: React.ReactNode;\n /** Buttons at the top right. */\n actions?: React.ReactNode;\n /** false: no inner padding, for a table or a tree that fills the card. */\n padding?: boolean;\n /** Element to render. Default 'section'. */\n as?: 'section' | 'div' | 'article' | 'aside' | 'form';\n children?: React.ReactNode;\n}\n\n/** The one container with a shadow. Never put a Card inside a Card: split the content into sections with headings instead. */\nexport function Card({ as: Tag = 'section', title, actions, padding = true, className, children, ...native }: CardProps) {\n const nested = React.useContext(InCard);\n devWarn(nested, 'Card', 'a Card inside a Card gives two shadows. Use one Card and separate its parts with headings or a divider.');\n return (\n <InCard.Provider value>\n <Tag {...native} className={cx('ui-card', !padding && 'is-flush', className)}>\n {title || actions ? (\n <div className=\"ui-card-head\">\n {title ? <h2 className=\"ui-card-title\">{title}</h2> : null}\n {actions ? <div className=\"ui-card-actions\">{actions}</div> : null}\n </div>\n ) : null}\n {children}\n </Tag>\n </InCard.Provider>\n );\n}\n"],"mappings":";;;;;;;AAKA,MAAM,SAAS,MAAM,cAAc,KAAK;;AAexC,SAAgB,KAAK,EAAE,IAAI,MAAM,WAAW,OAAO,SAAS,UAAU,MAAM,WAAW,UAAU,GAAG,UAAqB;CACvH,MAAM,SAAS,MAAM,WAAW,MAAM;CACtC,QAAQ,QAAQ,QAAQ,yGAAyG;CACjI,OACE,oBAAC,OAAO,UAAR;EAAiB,OAAA;EACf,UAAA,qBAAC,KAAD;GAAK,GAAI;GAAQ,WAAW,GAAG,WAAW,CAAC,WAAW,YAAY,SAAS;GAA3E,UAAA,CACG,SAAS,UACR,qBAAC,OAAD;IAAK,WAAU;IAAf,UAAA,CACG,QAAQ,oBAAC,MAAD;KAAI,WAAU;KAAiB,UAAA;IAAU,CAAA,IAAI,MACrD,UAAU,oBAAC,OAAD;KAAK,WAAU;KAAmB,UAAA;IAAa,CAAA,IAAI,IAC3D;GACH,CAAA,IAAA,MACH,QACE;;CACU,CAAA;AAErB"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
export interface CheckboxProps {
|
|
3
|
+
/** 'mixed': some of a group are checked (shows a dash). */
|
|
4
|
+
checked?: boolean | 'mixed';
|
|
5
|
+
/** Receives the new state; from 'mixed' it goes to true. */
|
|
6
|
+
onChange?: (checked: boolean) => void;
|
|
7
|
+
/** Text to the right of the box. Without it, pass aria-label. */
|
|
8
|
+
label?: React.ReactNode;
|
|
9
|
+
'aria-label'?: string;
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
className?: string;
|
|
12
|
+
}
|
|
13
|
+
/** A check box with a drawn check mark. The whole row is the touch target. */
|
|
14
|
+
export declare function Checkbox({ checked, onChange, label, disabled, className, ...aria }: CheckboxProps): React.JSX.Element;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cx } from "../../internal/util.js";
|
|
3
|
+
import { CheckMark } from "../../internal/Field.js";
|
|
4
|
+
import "react";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
// src/components/Checkbox/Checkbox.tsx
|
|
7
|
+
/** A check box with a drawn check mark. The whole row is the touch target. */
|
|
8
|
+
function Checkbox({ checked, onChange, label, disabled, className, ...aria }) {
|
|
9
|
+
const v = checked === "mixed" ? "mixed" : !!checked;
|
|
10
|
+
return /* @__PURE__ */ jsxs("button", {
|
|
11
|
+
type: "button",
|
|
12
|
+
role: "checkbox",
|
|
13
|
+
"aria-checked": v,
|
|
14
|
+
"aria-label": aria["aria-label"],
|
|
15
|
+
disabled,
|
|
16
|
+
className: cx("ui-check", v && "is-on", className),
|
|
17
|
+
onClick: () => onChange?.(v !== true),
|
|
18
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
19
|
+
className: "ui-check-box",
|
|
20
|
+
"aria-hidden": "true",
|
|
21
|
+
children: /* @__PURE__ */ jsx(CheckMark, { v })
|
|
22
|
+
}), label ? /* @__PURE__ */ jsx("span", { children: label }) : null]
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
export { Checkbox };
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=Checkbox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Checkbox.js","names":[],"sources":["../../../src/components/Checkbox/Checkbox.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cx } from '../../internal/util';\nimport { CheckMark } from '../../internal/Field';\n\nexport interface CheckboxProps {\n /** 'mixed': some of a group are checked (shows a dash). */\n checked?: boolean | 'mixed';\n /** Receives the new state; from 'mixed' it goes to true. */\n onChange?: (checked: boolean) => void;\n /** Text to the right of the box. Without it, pass aria-label. */\n label?: React.ReactNode;\n 'aria-label'?: string;\n disabled?: boolean;\n className?: string;\n}\n\n/** A check box with a drawn check mark. The whole row is the touch target. */\nexport function Checkbox({ checked, onChange, label, disabled, className, ...aria }: CheckboxProps) {\n const v = checked === 'mixed' ? 'mixed' : !!checked;\n return (\n <button\n type=\"button\"\n role=\"checkbox\"\n aria-checked={v}\n aria-label={aria['aria-label']}\n disabled={disabled}\n className={cx('ui-check', v && 'is-on', className)}\n onClick={() => onChange?.(v !== true)}\n >\n <span className=\"ui-check-box\" aria-hidden=\"true\">\n <CheckMark v={v} />\n </span>\n {label ? <span>{label}</span> : null}\n </button>\n );\n}\n"],"mappings":";;;;;;;AAiBA,SAAgB,SAAS,EAAE,SAAS,UAAU,OAAO,UAAU,WAAW,GAAG,QAAuB;CAClG,MAAM,IAAI,YAAY,UAAU,UAAU,CAAC,CAAC;CAC5C,OACE,qBAAC,UAAD;EACE,MAAK;EACL,MAAK;EACL,gBAAc;EACd,cAAY,KAAK;EACP;EACV,WAAW,GAAG,YAAY,KAAK,SAAS,SAAS;EACjD,eAAe,WAAW,MAAM,IAAI;EAPtC,UAAA,CASE,oBAAC,QAAD;GAAM,WAAU;GAAe,eAAY;GACzC,UAAA,oBAAC,WAAD,EAAc,EAAI,CAAA;EACd,CAAA,GACL,QAAQ,oBAAC,QAAD,EAAA,UAAO,MAAY,CAAA,IAAI,IAC1B;;AAEZ"}
|