@robert-stackflow/oneui 0.0.0-stage → 0.1.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 +45 -2
- package/assets/LUCIDE-LICENSE.txt +43 -0
- package/assets/character-metadata.json +1 -0
- package/assets/emoji.json +1 -0
- package/assets/icon-catalog.json +1 -0
- package/assets/symbols.json +1 -0
- package/components/Accessibility.module.css +8 -0
- package/components/Accordion.d.ts +7 -0
- package/components/Accordion.js +41 -0
- package/components/Accordion.module.css +38 -0
- package/components/Alert.d.ts +9 -0
- package/components/Alert.js +42 -0
- package/components/Alert.module.css +56 -0
- package/components/AppShell.d.ts +30 -0
- package/components/AppShell.js +152 -0
- package/components/AppShell.module.css +239 -0
- package/components/AppearanceSettings.d.ts +7 -0
- package/components/AppearanceSettings.js +201 -0
- package/components/AppearanceSettings.module.css +32 -0
- package/components/Avatar.d.ts +14 -0
- package/components/Avatar.js +69 -0
- package/components/Avatar.module.css +70 -0
- package/components/AvatarGroup.d.ts +15 -0
- package/components/AvatarGroup.js +115 -0
- package/components/AvatarGroup.module.css +54 -0
- package/components/Badge.d.ts +5 -0
- package/components/Badge.js +11 -0
- package/components/Badge.module.css +30 -0
- package/components/BlockedTab.d.ts +4 -0
- package/components/BlockedTab.js +10 -0
- package/components/Breadcrumb.d.ts +16 -0
- package/components/Breadcrumb.js +157 -0
- package/components/Breadcrumb.module.css +97 -0
- package/components/Button.d.ts +6 -0
- package/components/Button.js +29 -0
- package/components/Button.module.css +79 -0
- package/components/Calendar.d.ts +10 -0
- package/components/Calendar.js +260 -0
- package/components/Calendar.module.css +106 -0
- package/components/Card.d.ts +7 -0
- package/components/Card.js +19 -0
- package/components/Card.module.css +28 -0
- package/components/Cascader.d.ts +14 -0
- package/components/Cascader.js +296 -0
- package/components/CatalogIcon.d.ts +3 -0
- package/components/CatalogIcon.js +11 -0
- package/components/CharacterPicker.d.ts +15 -0
- package/components/CharacterPicker.js +200 -0
- package/components/Checkbox.d.ts +12 -0
- package/components/Checkbox.js +82 -0
- package/components/Checkbox.module.css +95 -0
- package/components/ColorField.d.ts +6 -0
- package/components/ColorField.js +61 -0
- package/components/ColorField.module.css +15 -0
- package/components/ColorPicker.d.ts +5 -0
- package/components/ColorPicker.js +188 -0
- package/components/ColorPicker.module.css +90 -0
- package/components/Combobox.d.ts +11 -0
- package/components/Combobox.js +252 -0
- package/components/Combobox.module.css +26 -0
- package/components/CommandPalette.d.ts +25 -0
- package/components/CommandPalette.js +269 -0
- package/components/CommandPalette.module.css +49 -0
- package/components/ContextMenu.d.ts +9 -0
- package/components/ContextMenu.js +363 -0
- package/components/ContextMenu.module.css +42 -0
- package/components/ContextMenuPanel.d.ts +22 -0
- package/components/ContextMenuPanel.js +155 -0
- package/components/ContributionCalendar.d.ts +18 -0
- package/components/ContributionCalendar.js +201 -0
- package/components/ContributionCalendar.module.css +114 -0
- package/components/ContributionCell.d.ts +11 -0
- package/components/ContributionCell.js +41 -0
- package/components/Control.module.css +73 -0
- package/components/DataTable.d.ts +49 -0
- package/components/DataTable.js +220 -0
- package/components/DataTable.module.css +112 -0
- package/components/DatePicker.d.ts +15 -0
- package/components/DatePicker.js +186 -0
- package/components/DatePicker.module.css +85 -0
- package/components/DateRangePicker.d.ts +9 -0
- package/components/DateRangePicker.js +168 -0
- package/components/Descriptions.d.ts +21 -0
- package/components/Descriptions.js +162 -0
- package/components/Descriptions.module.css +117 -0
- package/components/Dialog.d.ts +9 -0
- package/components/Dialog.js +112 -0
- package/components/Dialog.module.css +71 -0
- package/components/DisclosureChevron.d.ts +3 -0
- package/components/DisclosureChevron.js +17 -0
- package/components/DisclosureChevron.module.css +17 -0
- package/components/Divider.d.ts +5 -0
- package/components/Divider.js +24 -0
- package/components/Divider.module.css +19 -0
- package/components/Drawer.d.ts +18 -0
- package/components/Drawer.js +145 -0
- package/components/Drawer.module.css +109 -0
- package/components/EmojiPicker.d.ts +6 -0
- package/components/EmojiPicker.js +19 -0
- package/components/EmptyState.d.ts +8 -0
- package/components/EmptyState.js +20 -0
- package/components/EmptyState.module.css +30 -0
- package/components/FieldLabel.d.ts +8 -0
- package/components/FieldLabel.js +20 -0
- package/components/FieldMessages.d.ts +5 -0
- package/components/FieldMessages.js +15 -0
- package/components/FileDropOverlay.d.ts +5 -0
- package/components/FileDropOverlay.js +26 -0
- package/components/FileDropOverlay.module.css +55 -0
- package/components/FileDropZone.d.ts +15 -0
- package/components/FileDropZone.js +113 -0
- package/components/FileDropZone.module.css +6 -0
- package/components/FilePicker.d.ts +10 -0
- package/components/FilePicker.js +59 -0
- package/components/FileSelectionFeedback.d.ts +5 -0
- package/components/FileSelectionFeedback.js +23 -0
- package/components/FileSelectionFeedback.module.css +14 -0
- package/components/FileTree.d.ts +13 -0
- package/components/FileTree.js +125 -0
- package/components/FileTree.module.css +66 -0
- package/components/Form.d.ts +7 -0
- package/components/Form.js +26 -0
- package/components/Form.module.css +7 -0
- package/components/FormErrorSummary.d.ts +6 -0
- package/components/FormErrorSummary.js +27 -0
- package/components/FormErrorSummary.module.css +27 -0
- package/components/FormField.d.ts +9 -0
- package/components/FormField.js +59 -0
- package/components/FormField.module.css +85 -0
- package/components/FormGroup.d.ts +9 -0
- package/components/FormGroup.js +32 -0
- package/components/HierarchyPicker.module.css +146 -0
- package/components/IconButton.d.ts +7 -0
- package/components/IconButton.js +30 -0
- package/components/IconButton.module.css +39 -0
- package/components/IconPicker.d.ts +6 -0
- package/components/IconPicker.js +111 -0
- package/components/Indicator.d.ts +18 -0
- package/components/Indicator.js +97 -0
- package/components/Indicator.module.css +83 -0
- package/components/Input.d.ts +7 -0
- package/components/Input.js +29 -0
- package/components/Input.module.css +23 -0
- package/components/LoadingOverlay.d.ts +6 -0
- package/components/LoadingOverlay.js +16 -0
- package/components/LoadingOverlay.module.css +22 -0
- package/components/LoadingState.d.ts +5 -0
- package/components/LoadingState.js +29 -0
- package/components/LoadingState.module.css +14 -0
- package/components/Menu.d.ts +11 -0
- package/components/Menu.js +82 -0
- package/components/MenuItem.d.ts +14 -0
- package/components/MenuItem.js +49 -0
- package/components/MenuItem.module.css +163 -0
- package/components/MenuItemContent.d.ts +8 -0
- package/components/MenuItemContent.js +19 -0
- package/components/MultiSelect.d.ts +12 -0
- package/components/MultiSelect.js +161 -0
- package/components/MultiSelect.module.css +61 -0
- package/components/NumberInput.d.ts +12 -0
- package/components/NumberInput.js +113 -0
- package/components/NumberInput.module.css +33 -0
- package/components/Page.d.ts +7 -0
- package/components/Page.js +22 -0
- package/components/Page.module.css +44 -0
- package/components/Pagination.d.ts +11 -0
- package/components/Pagination.js +160 -0
- package/components/Pagination.module.css +70 -0
- package/components/PasswordField.d.ts +9 -0
- package/components/PasswordField.js +101 -0
- package/components/PasswordField.module.css +64 -0
- package/components/Picker.module.css +52 -0
- package/components/PinInput.d.ts +13 -0
- package/components/PinInput.js +172 -0
- package/components/PinInput.module.css +72 -0
- package/components/Placeholder.d.ts +31 -0
- package/components/Placeholder.js +36 -0
- package/components/Popconfirm.d.ts +17 -0
- package/components/Popconfirm.js +159 -0
- package/components/Popconfirm.module.css +49 -0
- package/components/Popover.d.ts +13 -0
- package/components/Popover.js +150 -0
- package/components/Popover.module.css +16 -0
- package/components/Progress.d.ts +5 -0
- package/components/Progress.js +31 -0
- package/components/Progress.module.css +33 -0
- package/components/RadioGroup.d.ts +15 -0
- package/components/RadioGroup.js +73 -0
- package/components/RadioGroup.module.css +87 -0
- package/components/RangeSlider.d.ts +22 -0
- package/components/RangeSlider.js +278 -0
- package/components/RangeSlider.module.css +141 -0
- package/components/ResizablePanel.d.ts +21 -0
- package/components/ResizablePanel.js +219 -0
- package/components/ResizablePanel.module.css +101 -0
- package/components/SearchField.d.ts +11 -0
- package/components/SearchField.js +66 -0
- package/components/SearchField.module.css +37 -0
- package/components/Section.d.ts +6 -0
- package/components/Section.js +18 -0
- package/components/Section.module.css +14 -0
- package/components/Segmented.d.ts +11 -0
- package/components/Segmented.js +77 -0
- package/components/Segmented.module.css +82 -0
- package/components/Select.d.ts +11 -0
- package/components/Select.js +171 -0
- package/components/Select.module.css +21 -0
- package/components/SelectOptionContent.d.ts +5 -0
- package/components/SelectOptionContent.js +20 -0
- package/components/SelectOptionContent.module.css +7 -0
- package/components/SelectTrigger.d.ts +5 -0
- package/components/SelectTrigger.js +32 -0
- package/components/SelectTrigger.module.css +24 -0
- package/components/SettingRow.d.ts +7 -0
- package/components/SettingRow.js +19 -0
- package/components/SettingRow.module.css +44 -0
- package/components/SettingsLayout.d.ts +9 -0
- package/components/SettingsLayout.js +45 -0
- package/components/SettingsLayout.module.css +48 -0
- package/components/ShortcutInput.d.ts +8 -0
- package/components/ShortcutInput.js +131 -0
- package/components/ShortcutInput.module.css +39 -0
- package/components/Skeleton.d.ts +5 -0
- package/components/Skeleton.js +19 -0
- package/components/Skeleton.module.css +27 -0
- package/components/SkeletonRows.d.ts +4 -0
- package/components/SkeletonRows.js +19 -0
- package/components/SkeletonRows.module.css +19 -0
- package/components/SkinTonePicker.d.ts +4 -0
- package/components/SkinTonePicker.js +43 -0
- package/components/SkinTonePicker.module.css +50 -0
- package/components/Slider.d.ts +10 -0
- package/components/Slider.js +40 -0
- package/components/Slider.module.css +19 -0
- package/components/Spinner.d.ts +6 -0
- package/components/Spinner.js +31 -0
- package/components/Spinner.module.css +57 -0
- package/components/SplitButton.d.ts +17 -0
- package/components/SplitButton.js +102 -0
- package/components/SplitButton.module.css +56 -0
- package/components/Statistic.d.ts +22 -0
- package/components/Statistic.js +102 -0
- package/components/Statistic.module.css +55 -0
- package/components/Steps.d.ts +19 -0
- package/components/Steps.js +102 -0
- package/components/Steps.module.css +176 -0
- package/components/Switch.d.ts +6 -0
- package/components/Switch.js +25 -0
- package/components/Switch.module.css +56 -0
- package/components/SymbolPicker.d.ts +6 -0
- package/components/SymbolPicker.js +18 -0
- package/components/Tab.module.css +145 -0
- package/components/TabList.d.ts +11 -0
- package/components/TabList.js +51 -0
- package/components/Table.d.ts +12 -0
- package/components/Table.js +20 -0
- package/components/Table.module.css +48 -0
- package/components/TableColumnFilter.d.ts +6 -0
- package/components/TableColumnFilter.js +76 -0
- package/components/TableColumnVisibility.d.ts +11 -0
- package/components/TableColumnVisibility.js +76 -0
- package/components/Tabs.d.ts +13 -0
- package/components/Tabs.js +49 -0
- package/components/Tabs.module.css +3 -0
- package/components/TagInput.d.ts +11 -0
- package/components/TagInput.js +154 -0
- package/components/TagInput.module.css +64 -0
- package/components/Textarea.d.ts +6 -0
- package/components/Textarea.js +24 -0
- package/components/Textarea.module.css +9 -0
- package/components/ThemePicker.d.ts +6 -0
- package/components/ThemePicker.js +78 -0
- package/components/ThemePicker.module.css +178 -0
- package/components/ThemeProvider.d.ts +11 -0
- package/components/ThemeProvider.js +80 -0
- package/components/ThemeStylePicker.d.ts +5 -0
- package/components/ThemeStylePicker.js +22 -0
- package/components/TimeColumns.d.ts +6 -0
- package/components/TimeColumns.js +55 -0
- package/components/TimeColumns.module.css +47 -0
- package/components/Timeline.d.ts +26 -0
- package/components/Timeline.js +131 -0
- package/components/Timeline.module.css +202 -0
- package/components/Toast.d.ts +6 -0
- package/components/Toast.js +181 -0
- package/components/Toast.module.css +175 -0
- package/components/ToastProvider.d.ts +35 -0
- package/components/ToastProvider.js +47 -0
- package/components/Tooltip.d.ts +10 -0
- package/components/Tooltip.js +169 -0
- package/components/Tooltip.module.css +53 -0
- package/components/TreeSelect.d.ts +23 -0
- package/components/TreeSelect.js +309 -0
- package/components/UIProvider.d.ts +10 -0
- package/components/UIProvider.js +20 -0
- package/components/UnderlinedTab.d.ts +2 -0
- package/components/UnderlinedTab.js +8 -0
- package/components/Upload.d.ts +22 -0
- package/components/Upload.js +165 -0
- package/components/Upload.module.css +36 -0
- package/components/UploadList.d.ts +9 -0
- package/components/UploadList.js +14 -0
- package/components/UploadList.module.css +130 -0
- package/components/UploadListItem.d.ts +13 -0
- package/components/UploadListItem.js +122 -0
- package/components/VirtualPickerList.d.ts +25 -0
- package/components/VirtualPickerList.js +269 -0
- package/components/VirtualPickerList.module.css +89 -0
- package/components/appearance.d.ts +19 -0
- package/components/appearance.js +60 -0
- package/components/characterCatalog.d.ts +9 -0
- package/components/characterCatalog.js +55 -0
- package/components/color.d.ts +7 -0
- package/components/color.js +18 -0
- package/components/contribution.d.ts +57 -0
- package/components/contribution.js +86 -0
- package/components/dateConstraints.d.ts +13 -0
- package/components/dateConstraints.js +44 -0
- package/components/field.d.ts +58 -0
- package/components/field.js +57 -0
- package/components/fileSelection.d.ts +21 -0
- package/components/fileSelection.js +43 -0
- package/components/hierarchy.d.ts +22 -0
- package/components/hierarchy.js +33 -0
- package/components/iconCatalog.d.ts +13 -0
- package/components/iconCatalog.js +80 -0
- package/components/index.d.ts +150 -0
- package/components/index.js +219 -0
- package/components/menuFocus.d.ts +7 -0
- package/components/menuFocus.js +21 -0
- package/components/menuPointer.d.ts +6 -0
- package/components/menuPointer.js +13 -0
- package/components/menuTypes.d.ts +24 -0
- package/components/menuTypes.js +0 -0
- package/components/motion.d.ts +9 -0
- package/components/motion.js +82 -0
- package/components/rangeMath.d.ts +12 -0
- package/components/rangeMath.js +30 -0
- package/components/surfacePortal.d.ts +13 -0
- package/components/surfacePortal.js +22 -0
- package/components/tooltipState.d.ts +5 -0
- package/components/tooltipState.js +48 -0
- package/components/types.d.ts +9 -0
- package/components/types.js +0 -0
- package/components/uploadTypes.d.ts +21 -0
- package/components/uploadTypes.js +0 -0
- package/components/useFormState.d.ts +51 -0
- package/components/useFormState.js +218 -0
- package/components/useHierarchy.d.ts +8 -0
- package/components/useHierarchy.js +80 -0
- package/components/useMenuLayers.d.ts +17 -0
- package/components/useMenuLayers.js +23 -0
- package/components/useModalScrollLock.d.ts +1 -0
- package/components/useModalScrollLock.js +18 -0
- package/components/usePopover.d.ts +8 -0
- package/components/usePopover.js +22 -0
- package/components/useTabIndicator.d.ts +12 -0
- package/components/useTabIndicator.js +63 -0
- package/components/useUploadQueue.d.ts +20 -0
- package/components/useUploadQueue.js +175 -0
- package/package.json +783 -3
- package/styles/base.css +189 -0
- package/styles/blue.css +254 -0
- package/styles/desktop.css +2 -0
- package/styles/minimal.css +337 -0
- package/styles/themes.css +2 -0
- package/styles/web.css +2 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
.field {
|
|
2
|
+
display: grid;
|
|
3
|
+
gap: 12px;
|
|
4
|
+
}
|
|
5
|
+
.field label {
|
|
6
|
+
display: flex;
|
|
7
|
+
justify-content: space-between;
|
|
8
|
+
font-size: 12px;
|
|
9
|
+
}
|
|
10
|
+
.field label span {
|
|
11
|
+
color: var(--muted);
|
|
12
|
+
font-variant-numeric: tabular-nums;
|
|
13
|
+
}
|
|
14
|
+
.field input {
|
|
15
|
+
width: 100%;
|
|
16
|
+
margin: 6px 0;
|
|
17
|
+
accent-color: var(--accent);
|
|
18
|
+
cursor: pointer;
|
|
19
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import s from "./Spinner.module.css";
|
|
3
|
+
function Spinner({
|
|
4
|
+
size = 18,
|
|
5
|
+
variant = "ring",
|
|
6
|
+
label = "\u6B63\u5728\u52A0\u8F7D",
|
|
7
|
+
decorative = false
|
|
8
|
+
}) {
|
|
9
|
+
return /* @__PURE__ */ jsx(
|
|
10
|
+
"span",
|
|
11
|
+
{
|
|
12
|
+
className: s.spinner,
|
|
13
|
+
"data-variant": variant,
|
|
14
|
+
role: decorative ? void 0 : "status",
|
|
15
|
+
"aria-label": decorative ? void 0 : label,
|
|
16
|
+
"aria-hidden": decorative || void 0,
|
|
17
|
+
style: { "--spinner-size": size + "px" },
|
|
18
|
+
children: variant === "dots" ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
19
|
+
/* @__PURE__ */ jsx("i", {}),
|
|
20
|
+
/* @__PURE__ */ jsx("i", {}),
|
|
21
|
+
/* @__PURE__ */ jsx("i", {})
|
|
22
|
+
] }) : /* @__PURE__ */ jsxs("svg", { viewBox: "0 0 24 24", children: [
|
|
23
|
+
/* @__PURE__ */ jsx("circle", { cx: "12", cy: "12", r: "9" }),
|
|
24
|
+
/* @__PURE__ */ jsx("path", { d: "M12 3a9 9 0 0 1 9 9" })
|
|
25
|
+
] })
|
|
26
|
+
}
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
export {
|
|
30
|
+
Spinner
|
|
31
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
.spinner {
|
|
2
|
+
display: inline-flex;
|
|
3
|
+
align-items: center;
|
|
4
|
+
justify-content: center;
|
|
5
|
+
flex-shrink: 0;
|
|
6
|
+
vertical-align: middle;
|
|
7
|
+
width: var(--spinner-size);
|
|
8
|
+
height: var(--spinner-size);
|
|
9
|
+
}
|
|
10
|
+
.spinner svg {
|
|
11
|
+
width: 100%;
|
|
12
|
+
height: 100%;
|
|
13
|
+
fill: none;
|
|
14
|
+
stroke: currentColor;
|
|
15
|
+
stroke-width: 2;
|
|
16
|
+
animation: turn 800ms linear infinite;
|
|
17
|
+
}
|
|
18
|
+
.spinner circle {
|
|
19
|
+
opacity: 0.18;
|
|
20
|
+
}
|
|
21
|
+
.spinner path {
|
|
22
|
+
stroke-linecap: round;
|
|
23
|
+
}
|
|
24
|
+
.spinner[data-variant="dots"] {
|
|
25
|
+
gap: 3px;
|
|
26
|
+
width: calc(var(--spinner-size) * 1.8);
|
|
27
|
+
}
|
|
28
|
+
.spinner i {
|
|
29
|
+
width: 5px;
|
|
30
|
+
height: 5px;
|
|
31
|
+
border-radius: 50%;
|
|
32
|
+
background: currentColor;
|
|
33
|
+
animation: pulse 1000ms ease-in-out infinite;
|
|
34
|
+
}
|
|
35
|
+
.spinner i:nth-child(2) {
|
|
36
|
+
animation-delay: 120ms;
|
|
37
|
+
}
|
|
38
|
+
.spinner i:nth-child(3) {
|
|
39
|
+
animation-delay: 240ms;
|
|
40
|
+
}
|
|
41
|
+
@keyframes turn {
|
|
42
|
+
to {
|
|
43
|
+
transform: rotate(360deg);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
@keyframes pulse {
|
|
47
|
+
0%,
|
|
48
|
+
80%,
|
|
49
|
+
100% {
|
|
50
|
+
opacity: 0.3;
|
|
51
|
+
transform: translateY(0);
|
|
52
|
+
}
|
|
53
|
+
40% {
|
|
54
|
+
opacity: 1;
|
|
55
|
+
transform: translateY(-3px);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
export type SplitButtonItem = {
|
|
3
|
+
label: string;
|
|
4
|
+
icon?: ReactNode;
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
shortcut?: string;
|
|
7
|
+
description?: string;
|
|
8
|
+
onSelect(): void;
|
|
9
|
+
};
|
|
10
|
+
export declare function SplitButton({ children, onClick, items, menuLabel, variant, disabled, }: {
|
|
11
|
+
children: ReactNode;
|
|
12
|
+
onClick(): void;
|
|
13
|
+
items: SplitButtonItem[];
|
|
14
|
+
menuLabel: string;
|
|
15
|
+
variant?: "primary" | "secondary";
|
|
16
|
+
disabled?: boolean;
|
|
17
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { MenuItem } from "./MenuItem.js";
|
|
3
|
+
import { useId, useRef, useState } from "react";
|
|
4
|
+
import { Popover } from "./Popover.js";
|
|
5
|
+
import { DisclosureChevron } from "./DisclosureChevron.js";
|
|
6
|
+
import s from "./SplitButton.module.css";
|
|
7
|
+
function SplitButton({
|
|
8
|
+
children,
|
|
9
|
+
onClick,
|
|
10
|
+
items,
|
|
11
|
+
menuLabel,
|
|
12
|
+
variant = "secondary",
|
|
13
|
+
disabled = false
|
|
14
|
+
}) {
|
|
15
|
+
const [open, setOpen] = useState(false), anchor = useRef(null), root = useRef(null), id = useId();
|
|
16
|
+
const reserveIcon = items.some((item) => !!item.icon);
|
|
17
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
18
|
+
/* @__PURE__ */ jsxs("div", { className: s.split, "data-variant": variant, "data-disabled": disabled, children: [
|
|
19
|
+
/* @__PURE__ */ jsx(
|
|
20
|
+
"button",
|
|
21
|
+
{
|
|
22
|
+
type: "button",
|
|
23
|
+
disabled,
|
|
24
|
+
onClick: () => {
|
|
25
|
+
setOpen(false);
|
|
26
|
+
onClick();
|
|
27
|
+
},
|
|
28
|
+
children
|
|
29
|
+
}
|
|
30
|
+
),
|
|
31
|
+
/* @__PURE__ */ jsx(
|
|
32
|
+
"button",
|
|
33
|
+
{
|
|
34
|
+
ref: anchor,
|
|
35
|
+
type: "button",
|
|
36
|
+
className: s.arrow,
|
|
37
|
+
disabled,
|
|
38
|
+
"aria-label": menuLabel,
|
|
39
|
+
"aria-haspopup": "menu",
|
|
40
|
+
"aria-controls": id,
|
|
41
|
+
"aria-expanded": open,
|
|
42
|
+
onClick: () => setOpen((v) => !v),
|
|
43
|
+
onKeyDown: (e) => {
|
|
44
|
+
if (e.key === "ArrowDown") {
|
|
45
|
+
e.preventDefault();
|
|
46
|
+
setOpen(true);
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
children: /* @__PURE__ */ jsx(DisclosureChevron, { expanded: open })
|
|
50
|
+
}
|
|
51
|
+
)
|
|
52
|
+
] }),
|
|
53
|
+
/* @__PURE__ */ jsx(
|
|
54
|
+
Popover,
|
|
55
|
+
{
|
|
56
|
+
anchor,
|
|
57
|
+
open: open && !disabled,
|
|
58
|
+
onClose: () => setOpen(false),
|
|
59
|
+
id,
|
|
60
|
+
role: "menu",
|
|
61
|
+
label: menuLabel,
|
|
62
|
+
width: 235,
|
|
63
|
+
onKeyDown: (e) => {
|
|
64
|
+
const buttons = Array.from(
|
|
65
|
+
root.current?.querySelectorAll(
|
|
66
|
+
"button:not(:disabled)"
|
|
67
|
+
) || []
|
|
68
|
+
);
|
|
69
|
+
if (!buttons.length) return;
|
|
70
|
+
const index = buttons.indexOf(
|
|
71
|
+
document.activeElement
|
|
72
|
+
);
|
|
73
|
+
if (["ArrowUp", "ArrowDown", "Home", "End"].includes(e.key)) {
|
|
74
|
+
e.preventDefault();
|
|
75
|
+
buttons[e.key === "Home" ? 0 : e.key === "End" ? buttons.length - 1 : (index + (e.key === "ArrowDown" ? 1 : buttons.length - 1)) % buttons.length].focus();
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
children: /* @__PURE__ */ jsx("div", { ref: root, className: s.menu, children: items.map((item, index) => /* @__PURE__ */ jsx(
|
|
79
|
+
MenuItem,
|
|
80
|
+
{
|
|
81
|
+
label: item.label,
|
|
82
|
+
description: item.description,
|
|
83
|
+
icon: item.icon,
|
|
84
|
+
reserveIcon,
|
|
85
|
+
shortcut: item.shortcut,
|
|
86
|
+
role: "menuitem",
|
|
87
|
+
disabled: item.disabled,
|
|
88
|
+
onClick: () => {
|
|
89
|
+
setOpen(false);
|
|
90
|
+
anchor.current?.focus();
|
|
91
|
+
item.onSelect();
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
index
|
|
95
|
+
)) })
|
|
96
|
+
}
|
|
97
|
+
)
|
|
98
|
+
] });
|
|
99
|
+
}
|
|
100
|
+
export {
|
|
101
|
+
SplitButton
|
|
102
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
.split {
|
|
2
|
+
display: inline-flex;
|
|
3
|
+
flex-shrink: 0;
|
|
4
|
+
border: 1px solid var(--line);
|
|
5
|
+
border-radius: var(--radius);
|
|
6
|
+
overflow: hidden;
|
|
7
|
+
background: var(--surface);
|
|
8
|
+
}
|
|
9
|
+
.split > button {
|
|
10
|
+
display: flex;
|
|
11
|
+
align-items: center;
|
|
12
|
+
justify-content: center;
|
|
13
|
+
gap: 7px;
|
|
14
|
+
min-height: var(--control-height);
|
|
15
|
+
padding: 6px 13px;
|
|
16
|
+
border: 0;
|
|
17
|
+
border-radius: 0;
|
|
18
|
+
background: transparent;
|
|
19
|
+
box-shadow: none;
|
|
20
|
+
font-size: 12px;
|
|
21
|
+
transition: background var(--motion-hover);
|
|
22
|
+
}
|
|
23
|
+
.split > .arrow {
|
|
24
|
+
width: 30px;
|
|
25
|
+
min-width: 30px;
|
|
26
|
+
padding: 0;
|
|
27
|
+
border-left: var(--separator-width) var(--separator-style)
|
|
28
|
+
var(--separator-color);
|
|
29
|
+
}
|
|
30
|
+
.split > button:hover:not(:disabled),
|
|
31
|
+
.split > button[aria-expanded="true"] {
|
|
32
|
+
background: var(--hover);
|
|
33
|
+
}
|
|
34
|
+
.split > button:active:not(:disabled) > svg {
|
|
35
|
+
scale: 0.94;
|
|
36
|
+
}
|
|
37
|
+
.split > button:focus-visible {
|
|
38
|
+
outline-offset: -3px;
|
|
39
|
+
}
|
|
40
|
+
.split[data-variant="primary"] {
|
|
41
|
+
background: var(--accent);
|
|
42
|
+
border-color: var(--accent);
|
|
43
|
+
}
|
|
44
|
+
.split[data-variant="primary"] > button {
|
|
45
|
+
color: var(--on-accent);
|
|
46
|
+
}
|
|
47
|
+
.split[data-variant="primary"] > .arrow {
|
|
48
|
+
border-left-color: color-mix(in srgb, var(--on-accent) 24%, transparent);
|
|
49
|
+
}
|
|
50
|
+
.split[data-variant="primary"] > button:hover:not(:disabled),
|
|
51
|
+
.split[data-variant="primary"] > button[aria-expanded="true"] {
|
|
52
|
+
background: color-mix(in srgb, var(--on-accent) 14%, transparent);
|
|
53
|
+
}
|
|
54
|
+
.menu {
|
|
55
|
+
display: block;
|
|
56
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
export type StatisticProps = {
|
|
3
|
+
title: ReactNode;
|
|
4
|
+
label?: string;
|
|
5
|
+
value: number | string | null | undefined;
|
|
6
|
+
precision?: number;
|
|
7
|
+
locale?: string;
|
|
8
|
+
grouping?: boolean;
|
|
9
|
+
prefix?: ReactNode;
|
|
10
|
+
suffix?: ReactNode;
|
|
11
|
+
formatter?(value: number | string): ReactNode;
|
|
12
|
+
valueLabel?: string;
|
|
13
|
+
loading?: boolean;
|
|
14
|
+
animate?: boolean;
|
|
15
|
+
emptyText?: ReactNode;
|
|
16
|
+
trend?: {
|
|
17
|
+
direction: "up" | "down" | "flat";
|
|
18
|
+
value: ReactNode;
|
|
19
|
+
tone?: "success" | "danger" | "neutral";
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
export declare function Statistic({ title, label, value, precision, locale, grouping, prefix, suffix, formatter, valueLabel, loading, animate, emptyText, trend, }: StatisticProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useMemo, useRef, useState } from "react";
|
|
3
|
+
import { ArrowDownRight, ArrowUpRight, Minus } from "lucide-react";
|
|
4
|
+
import { Skeleton } from "./Skeleton.js";
|
|
5
|
+
import s from "./Statistic.module.css";
|
|
6
|
+
function Statistic({
|
|
7
|
+
title,
|
|
8
|
+
label,
|
|
9
|
+
value,
|
|
10
|
+
precision = 0,
|
|
11
|
+
locale = "zh-CN",
|
|
12
|
+
grouping = true,
|
|
13
|
+
prefix,
|
|
14
|
+
suffix,
|
|
15
|
+
formatter,
|
|
16
|
+
valueLabel,
|
|
17
|
+
loading = false,
|
|
18
|
+
animate = true,
|
|
19
|
+
emptyText = "\u2014",
|
|
20
|
+
trend
|
|
21
|
+
}) {
|
|
22
|
+
const valid = typeof value === "number" && Number.isFinite(value), target = valid ? value : 0, [display, setDisplay] = useState(target), current = useRef(target);
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
if (!valid) return;
|
|
25
|
+
const media = matchMedia("(prefers-reduced-motion: reduce)"), start = current.current, startTime = performance.now();
|
|
26
|
+
let frame = 0;
|
|
27
|
+
const finish = () => {
|
|
28
|
+
cancelAnimationFrame(frame);
|
|
29
|
+
current.current = target;
|
|
30
|
+
setDisplay(target);
|
|
31
|
+
};
|
|
32
|
+
const change = () => {
|
|
33
|
+
if (media.matches) finish();
|
|
34
|
+
};
|
|
35
|
+
if (!animate || loading || media.matches || start === target) finish();
|
|
36
|
+
else {
|
|
37
|
+
const tick = (now) => {
|
|
38
|
+
const progress = Math.min(1, (now - startTime) / 320), next = start + (target - start) * (1 - Math.pow(1 - progress, 3));
|
|
39
|
+
current.current = next;
|
|
40
|
+
setDisplay(next);
|
|
41
|
+
if (progress < 1) frame = requestAnimationFrame(tick);
|
|
42
|
+
};
|
|
43
|
+
frame = requestAnimationFrame(tick);
|
|
44
|
+
}
|
|
45
|
+
media.addEventListener("change", change);
|
|
46
|
+
return () => {
|
|
47
|
+
cancelAnimationFrame(frame);
|
|
48
|
+
media.removeEventListener("change", change);
|
|
49
|
+
};
|
|
50
|
+
}, [target, valid, animate, loading]);
|
|
51
|
+
const digits = Number.isFinite(precision) ? Math.min(20, Math.max(0, Math.trunc(precision))) : 0;
|
|
52
|
+
const numberFormat = useMemo(() => {
|
|
53
|
+
const options = {
|
|
54
|
+
minimumFractionDigits: digits,
|
|
55
|
+
maximumFractionDigits: digits,
|
|
56
|
+
useGrouping: grouping
|
|
57
|
+
};
|
|
58
|
+
try {
|
|
59
|
+
return new Intl.NumberFormat(locale, options);
|
|
60
|
+
} catch {
|
|
61
|
+
return new Intl.NumberFormat("zh-CN", options);
|
|
62
|
+
}
|
|
63
|
+
}, [locale, digits, grouping]);
|
|
64
|
+
const format = (n) => numberFormat.format(n);
|
|
65
|
+
const empty = value == null || value === "" || typeof value === "number" && !valid;
|
|
66
|
+
const formatted = empty ? emptyText : formatter ? formatter(valid ? display : value) : valid ? format(display) : value;
|
|
67
|
+
const accessible = valueLabel || (empty ? "\u65E0\u6570\u636E" : `${typeof prefix === "string" || typeof prefix === "number" ? prefix : ""}${valid ? format(target) : value}${typeof suffix === "string" || typeof suffix === "number" ? suffix : ""}`);
|
|
68
|
+
return /* @__PURE__ */ jsxs(
|
|
69
|
+
"div",
|
|
70
|
+
{
|
|
71
|
+
className: s.statistic,
|
|
72
|
+
role: "group",
|
|
73
|
+
"aria-label": label || (typeof title === "string" ? title : "\u7EDF\u8BA1"),
|
|
74
|
+
"aria-busy": loading || void 0,
|
|
75
|
+
children: [
|
|
76
|
+
/* @__PURE__ */ jsx("div", { className: s.title, children: title }),
|
|
77
|
+
/* @__PURE__ */ jsx("div", { className: s.number, "aria-hidden": "true", children: loading ? /* @__PURE__ */ jsx(Skeleton, { width: 140, height: 28 }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
78
|
+
prefix != null && /* @__PURE__ */ jsx("span", { className: s.affix, children: prefix }),
|
|
79
|
+
/* @__PURE__ */ jsx("span", { children: formatted }),
|
|
80
|
+
suffix != null && /* @__PURE__ */ jsx("span", { className: s.affix, children: suffix })
|
|
81
|
+
] }) }),
|
|
82
|
+
/* @__PURE__ */ jsx("output", { className: s.sr, "aria-live": "polite", children: loading ? "\u6B63\u5728\u52A0\u8F7D" : accessible }),
|
|
83
|
+
trend && /* @__PURE__ */ jsxs(
|
|
84
|
+
"div",
|
|
85
|
+
{
|
|
86
|
+
className: s.trend,
|
|
87
|
+
"data-tone": trend.tone || "neutral",
|
|
88
|
+
"aria-hidden": loading || void 0,
|
|
89
|
+
style: { visibility: loading ? "hidden" : void 0 },
|
|
90
|
+
children: [
|
|
91
|
+
trend.direction === "up" ? /* @__PURE__ */ jsx(ArrowUpRight, { "aria-hidden": "true" }) : trend.direction === "down" ? /* @__PURE__ */ jsx(ArrowDownRight, { "aria-hidden": "true" }) : /* @__PURE__ */ jsx(Minus, { "aria-hidden": "true" }),
|
|
92
|
+
/* @__PURE__ */ jsx("span", { children: trend.value })
|
|
93
|
+
]
|
|
94
|
+
}
|
|
95
|
+
)
|
|
96
|
+
]
|
|
97
|
+
}
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
export {
|
|
101
|
+
Statistic
|
|
102
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
.statistic {
|
|
2
|
+
min-width: 0;
|
|
3
|
+
}
|
|
4
|
+
.title {
|
|
5
|
+
color: var(--muted);
|
|
6
|
+
font-size: 12px;
|
|
7
|
+
line-height: 20px;
|
|
8
|
+
}
|
|
9
|
+
.number {
|
|
10
|
+
display: flex;
|
|
11
|
+
align-items: baseline;
|
|
12
|
+
gap: 6px;
|
|
13
|
+
min-height: 42px;
|
|
14
|
+
margin-top: 6px;
|
|
15
|
+
font-size: 30px;
|
|
16
|
+
font-weight: 600;
|
|
17
|
+
line-height: 1.35;
|
|
18
|
+
font-variant-numeric: tabular-nums;
|
|
19
|
+
}
|
|
20
|
+
.number > span {
|
|
21
|
+
min-width: 0;
|
|
22
|
+
overflow-wrap: anywhere;
|
|
23
|
+
}
|
|
24
|
+
.affix {
|
|
25
|
+
font-size: 14px;
|
|
26
|
+
font-weight: 400;
|
|
27
|
+
color: var(--muted);
|
|
28
|
+
}
|
|
29
|
+
.affix svg {
|
|
30
|
+
width: 18px;
|
|
31
|
+
height: 18px;
|
|
32
|
+
}
|
|
33
|
+
.trend {
|
|
34
|
+
display: flex;
|
|
35
|
+
align-items: center;
|
|
36
|
+
gap: 4px;
|
|
37
|
+
margin-top: 6px;
|
|
38
|
+
font-size: 11px;
|
|
39
|
+
color: var(--muted);
|
|
40
|
+
line-height: 18px;
|
|
41
|
+
}
|
|
42
|
+
.trend svg {
|
|
43
|
+
width: 14px;
|
|
44
|
+
height: 14px;
|
|
45
|
+
flex-shrink: 0;
|
|
46
|
+
}
|
|
47
|
+
.trend[data-tone="success"] {
|
|
48
|
+
color: var(--success);
|
|
49
|
+
}
|
|
50
|
+
.trend[data-tone="danger"] {
|
|
51
|
+
color: var(--danger);
|
|
52
|
+
}
|
|
53
|
+
.sr {
|
|
54
|
+
composes: visuallyHidden from "./Accessibility.module.css";
|
|
55
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
export type StepStatus = "waiting" | "current" | "complete" | "error" | "loading";
|
|
3
|
+
export type StepItem = {
|
|
4
|
+
value: string;
|
|
5
|
+
label: string;
|
|
6
|
+
description?: string;
|
|
7
|
+
icon?: ReactNode;
|
|
8
|
+
status?: StepStatus;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
};
|
|
11
|
+
export type StepsProps = {
|
|
12
|
+
items: StepItem[];
|
|
13
|
+
value?: string;
|
|
14
|
+
onChange?(value: string): void;
|
|
15
|
+
orientation?: "horizontal" | "vertical";
|
|
16
|
+
label?: string;
|
|
17
|
+
className?: string;
|
|
18
|
+
};
|
|
19
|
+
export declare function Steps({ items, value, onChange, orientation, label, className, }: StepsProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useId, useState } from "react";
|
|
3
|
+
import { Check, CircleAlert } from "lucide-react";
|
|
4
|
+
import { Spinner } from "./Spinner.js";
|
|
5
|
+
import s from "./Steps.module.css";
|
|
6
|
+
const statusNames = {
|
|
7
|
+
waiting: "\u672A\u5F00\u59CB",
|
|
8
|
+
current: "\u5F53\u524D\u6B65\u9AA4",
|
|
9
|
+
complete: "\u5DF2\u5B8C\u6210",
|
|
10
|
+
error: "\u53D1\u751F\u9519\u8BEF",
|
|
11
|
+
loading: "\u8FDB\u884C\u4E2D"
|
|
12
|
+
};
|
|
13
|
+
function Steps({
|
|
14
|
+
items,
|
|
15
|
+
value,
|
|
16
|
+
onChange,
|
|
17
|
+
orientation = "horizontal",
|
|
18
|
+
label = "\u6B65\u9AA4",
|
|
19
|
+
className = ""
|
|
20
|
+
}) {
|
|
21
|
+
const current = items.findIndex((item) => item.value === value), id = useId();
|
|
22
|
+
const [focused, setFocused] = useState(null);
|
|
23
|
+
useEffect(() => setFocused(null), [value]);
|
|
24
|
+
const enabled = items.filter((item) => !item.disabled);
|
|
25
|
+
const tabStop = enabled.find((item) => item.value === focused)?.value ?? enabled.find((item) => item.value === value)?.value ?? enabled[0]?.value;
|
|
26
|
+
return /* @__PURE__ */ jsx(
|
|
27
|
+
"ol",
|
|
28
|
+
{
|
|
29
|
+
className: `${s.steps} ${className}`,
|
|
30
|
+
"aria-label": label,
|
|
31
|
+
"data-orientation": orientation,
|
|
32
|
+
onKeyDown: (event) => {
|
|
33
|
+
if (!onChange || !enabled.length) return;
|
|
34
|
+
const active = enabled.findIndex(
|
|
35
|
+
(item) => item.value === event.target.closest(
|
|
36
|
+
"[data-step-value]"
|
|
37
|
+
)?.dataset.stepValue
|
|
38
|
+
);
|
|
39
|
+
if (active < 0) return;
|
|
40
|
+
const previous = orientation === "horizontal" ? "ArrowLeft" : "ArrowUp", next = orientation === "horizontal" ? "ArrowRight" : "ArrowDown";
|
|
41
|
+
const index = event.key === "Home" ? 0 : event.key === "End" ? enabled.length - 1 : event.key === previous ? (active - 1 + enabled.length) % enabled.length : event.key === next ? (active + 1) % enabled.length : -1;
|
|
42
|
+
if (index < 0) return;
|
|
43
|
+
event.preventDefault();
|
|
44
|
+
setFocused(enabled[index].value);
|
|
45
|
+
[
|
|
46
|
+
...event.currentTarget.querySelectorAll(
|
|
47
|
+
"[data-step-value]"
|
|
48
|
+
)
|
|
49
|
+
].find((node) => node.dataset.stepValue === enabled[index].value)?.focus();
|
|
50
|
+
},
|
|
51
|
+
children: items.map((item, index) => {
|
|
52
|
+
const status = item.status ?? (current < 0 || index > current ? "waiting" : index < current ? "complete" : "current");
|
|
53
|
+
const descriptionId = `${id}-${index}`;
|
|
54
|
+
const content = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
55
|
+
/* @__PURE__ */ jsx("span", { className: s.marker, "aria-hidden": "true", children: /* @__PURE__ */ jsx("span", { className: s.mark, children: status === "loading" ? /* @__PURE__ */ jsx(Spinner, { decorative: true }) : status === "complete" ? /* @__PURE__ */ jsx(Check, {}) : status === "error" ? /* @__PURE__ */ jsx(CircleAlert, {}) : item.icon || index + 1 }, status) }),
|
|
56
|
+
/* @__PURE__ */ jsxs("span", { className: s.copy, children: [
|
|
57
|
+
/* @__PURE__ */ jsx("span", { className: s.label, children: item.label }),
|
|
58
|
+
item.description && /* @__PURE__ */ jsx("span", { id: descriptionId, className: s.description, children: item.description })
|
|
59
|
+
] })
|
|
60
|
+
] });
|
|
61
|
+
return /* @__PURE__ */ jsx(
|
|
62
|
+
"li",
|
|
63
|
+
{
|
|
64
|
+
className: s.item,
|
|
65
|
+
"data-status": status,
|
|
66
|
+
"data-disabled": item.disabled || void 0,
|
|
67
|
+
children: onChange ? /* @__PURE__ */ jsx(
|
|
68
|
+
"button",
|
|
69
|
+
{
|
|
70
|
+
type: "button",
|
|
71
|
+
className: s.control,
|
|
72
|
+
"data-step-value": item.value,
|
|
73
|
+
disabled: item.disabled,
|
|
74
|
+
tabIndex: item.value === tabStop ? 0 : -1,
|
|
75
|
+
"aria-current": index === current ? "step" : void 0,
|
|
76
|
+
"aria-label": `${item.label}\uFF0C${statusNames[status]}`,
|
|
77
|
+
"aria-describedby": item.description ? descriptionId : void 0,
|
|
78
|
+
onFocus: () => setFocused(item.value),
|
|
79
|
+
onClick: () => onChange(item.value),
|
|
80
|
+
children: content
|
|
81
|
+
}
|
|
82
|
+
) : /* @__PURE__ */ jsxs(
|
|
83
|
+
"div",
|
|
84
|
+
{
|
|
85
|
+
className: s.control,
|
|
86
|
+
"aria-current": index === current ? "step" : void 0,
|
|
87
|
+
children: [
|
|
88
|
+
content,
|
|
89
|
+
/* @__PURE__ */ jsx("span", { className: s.srOnly, children: statusNames[status] })
|
|
90
|
+
]
|
|
91
|
+
}
|
|
92
|
+
)
|
|
93
|
+
},
|
|
94
|
+
item.value
|
|
95
|
+
);
|
|
96
|
+
})
|
|
97
|
+
}
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
export {
|
|
101
|
+
Steps
|
|
102
|
+
};
|