@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,101 @@
|
|
|
1
|
+
.group {
|
|
2
|
+
position: relative;
|
|
3
|
+
display: grid;
|
|
4
|
+
width: 100%;
|
|
5
|
+
height: 100%;
|
|
6
|
+
min-width: 0;
|
|
7
|
+
min-height: 0;
|
|
8
|
+
grid-template-columns: minmax(0, var(--panel-first)) 8px minmax(
|
|
9
|
+
0,
|
|
10
|
+
var(--panel-second)
|
|
11
|
+
);
|
|
12
|
+
grid-template-rows: minmax(0, 1fr);
|
|
13
|
+
overflow: hidden;
|
|
14
|
+
transition:
|
|
15
|
+
grid-template-columns var(--motion-panel) var(--ease),
|
|
16
|
+
grid-template-rows var(--motion-panel) var(--ease);
|
|
17
|
+
}
|
|
18
|
+
.group[data-direction="vertical"] {
|
|
19
|
+
grid-template-columns: minmax(0, 1fr);
|
|
20
|
+
grid-template-rows: minmax(0, var(--panel-first)) 8px minmax(
|
|
21
|
+
0,
|
|
22
|
+
var(--panel-second)
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
.group[data-resizing="true"] {
|
|
26
|
+
transition: none;
|
|
27
|
+
}
|
|
28
|
+
.pane {
|
|
29
|
+
min-width: 0;
|
|
30
|
+
min-height: 0;
|
|
31
|
+
overflow: auto;
|
|
32
|
+
overscroll-behavior: contain;
|
|
33
|
+
}
|
|
34
|
+
.pane[data-collapsed="true"] {
|
|
35
|
+
visibility: hidden;
|
|
36
|
+
}
|
|
37
|
+
.handle {
|
|
38
|
+
position: relative;
|
|
39
|
+
cursor: col-resize;
|
|
40
|
+
touch-action: none;
|
|
41
|
+
outline: none;
|
|
42
|
+
}
|
|
43
|
+
.handle:focus-visible {
|
|
44
|
+
outline: none;
|
|
45
|
+
}
|
|
46
|
+
.handle::before {
|
|
47
|
+
content: "";
|
|
48
|
+
position: absolute;
|
|
49
|
+
top: 0;
|
|
50
|
+
bottom: 0;
|
|
51
|
+
left: calc(50% - 0.5px);
|
|
52
|
+
width: var(--separator-width);
|
|
53
|
+
background: var(--separator-color);
|
|
54
|
+
transition: background var(--motion-hover);
|
|
55
|
+
}
|
|
56
|
+
.handle::after {
|
|
57
|
+
content: "";
|
|
58
|
+
position: absolute;
|
|
59
|
+
top: 50%;
|
|
60
|
+
left: 50%;
|
|
61
|
+
transform: translate(-50%, -50%);
|
|
62
|
+
width: 3px;
|
|
63
|
+
height: 28px;
|
|
64
|
+
border-radius: 3px;
|
|
65
|
+
background: var(--muted);
|
|
66
|
+
opacity: 0;
|
|
67
|
+
transition: opacity var(--motion-hover);
|
|
68
|
+
}
|
|
69
|
+
.handle:hover:not([aria-disabled="true"])::after,
|
|
70
|
+
.handle:focus-visible::after,
|
|
71
|
+
.group[data-resizing="true"] > .handle::after {
|
|
72
|
+
opacity: 1;
|
|
73
|
+
}
|
|
74
|
+
.handle:focus-visible::before,
|
|
75
|
+
.group[data-resizing="true"] > .handle::before {
|
|
76
|
+
background: var(--accent);
|
|
77
|
+
}
|
|
78
|
+
.handle[aria-disabled="true"] {
|
|
79
|
+
cursor: default;
|
|
80
|
+
}
|
|
81
|
+
.group[data-direction="vertical"] > .handle {
|
|
82
|
+
cursor: row-resize;
|
|
83
|
+
}
|
|
84
|
+
.group[data-direction="vertical"] > .handle[aria-disabled="true"] {
|
|
85
|
+
cursor: default;
|
|
86
|
+
}
|
|
87
|
+
.group[data-direction="vertical"] > .handle::before {
|
|
88
|
+
left: 0;
|
|
89
|
+
right: 0;
|
|
90
|
+
top: calc(50% - 0.5px);
|
|
91
|
+
bottom: auto;
|
|
92
|
+
height: var(--separator-width);
|
|
93
|
+
width: auto;
|
|
94
|
+
}
|
|
95
|
+
.group[data-direction="vertical"] > .handle::after {
|
|
96
|
+
width: 28px;
|
|
97
|
+
height: 3px;
|
|
98
|
+
}
|
|
99
|
+
.help {
|
|
100
|
+
composes: visuallyHidden from "./Accessibility.module.css";
|
|
101
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type InputHTMLAttributes } from "react";
|
|
2
|
+
export declare function SearchField({ value, onChange, label, placeholder, className, clearable, loading, onSearch, onKeyDown, ...props }: Omit<InputHTMLAttributes<HTMLInputElement>, "value" | "onChange" | "onSearch"> & {
|
|
3
|
+
value: string;
|
|
4
|
+
onChange(value: string): void;
|
|
5
|
+
label?: string;
|
|
6
|
+
placeholder?: string;
|
|
7
|
+
className?: string;
|
|
8
|
+
clearable?: boolean;
|
|
9
|
+
loading?: boolean;
|
|
10
|
+
onSearch?(value: string): void;
|
|
11
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useRef } from "react";
|
|
3
|
+
import { Spinner } from "./Spinner.js";
|
|
4
|
+
import { Search, X } from "lucide-react";
|
|
5
|
+
import s from "./SearchField.module.css";
|
|
6
|
+
function SearchField({
|
|
7
|
+
value,
|
|
8
|
+
onChange,
|
|
9
|
+
label = "\u641C\u7D22",
|
|
10
|
+
placeholder = "\u641C\u7D22\u2026",
|
|
11
|
+
className = "",
|
|
12
|
+
clearable = true,
|
|
13
|
+
loading = false,
|
|
14
|
+
onSearch,
|
|
15
|
+
onKeyDown,
|
|
16
|
+
...props
|
|
17
|
+
}) {
|
|
18
|
+
const input = useRef(null);
|
|
19
|
+
return /* @__PURE__ */ jsxs(
|
|
20
|
+
"div",
|
|
21
|
+
{
|
|
22
|
+
"data-disabled": props.disabled,
|
|
23
|
+
"aria-busy": loading || void 0,
|
|
24
|
+
className: `${s.search} ${className}`,
|
|
25
|
+
children: [
|
|
26
|
+
loading ? /* @__PURE__ */ jsx(Spinner, { size: 16, decorative: true }) : /* @__PURE__ */ jsx(Search, {}),
|
|
27
|
+
/* @__PURE__ */ jsx(
|
|
28
|
+
"input",
|
|
29
|
+
{
|
|
30
|
+
...props,
|
|
31
|
+
ref: input,
|
|
32
|
+
type: "search",
|
|
33
|
+
"aria-label": label,
|
|
34
|
+
placeholder,
|
|
35
|
+
value,
|
|
36
|
+
onChange: (e) => onChange(e.target.value),
|
|
37
|
+
onKeyDown: (e) => {
|
|
38
|
+
onKeyDown?.(e);
|
|
39
|
+
if (e.defaultPrevented) return;
|
|
40
|
+
if (e.key === "Enter") onSearch?.(value);
|
|
41
|
+
if (e.key === "Escape" && value && clearable && !props.readOnly) {
|
|
42
|
+
e.stopPropagation();
|
|
43
|
+
onChange("");
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
),
|
|
48
|
+
value && clearable && !props.disabled && !props.readOnly && /* @__PURE__ */ jsx(
|
|
49
|
+
"button",
|
|
50
|
+
{
|
|
51
|
+
type: "button",
|
|
52
|
+
"aria-label": `\u6E05\u9664${label}`,
|
|
53
|
+
onClick: () => {
|
|
54
|
+
onChange("");
|
|
55
|
+
input.current?.focus();
|
|
56
|
+
},
|
|
57
|
+
children: /* @__PURE__ */ jsx(X, {})
|
|
58
|
+
}
|
|
59
|
+
)
|
|
60
|
+
]
|
|
61
|
+
}
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
export {
|
|
65
|
+
SearchField
|
|
66
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
.search {
|
|
2
|
+
composes: surface from "./Control.module.css";
|
|
3
|
+
display: flex;
|
|
4
|
+
align-items: center;
|
|
5
|
+
min-width: 0;
|
|
6
|
+
gap: 8px;
|
|
7
|
+
padding: 0 10px;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.search > svg {
|
|
11
|
+
color: var(--muted);
|
|
12
|
+
width: 15px;
|
|
13
|
+
height: 15px;
|
|
14
|
+
}
|
|
15
|
+
.search input {
|
|
16
|
+
width: 100%;
|
|
17
|
+
min-width: 0;
|
|
18
|
+
background: transparent;
|
|
19
|
+
border: 0;
|
|
20
|
+
outline: 0;
|
|
21
|
+
font-size: inherit;
|
|
22
|
+
}
|
|
23
|
+
.search input::-webkit-search-cancel-button {
|
|
24
|
+
display: none;
|
|
25
|
+
}
|
|
26
|
+
.search button {
|
|
27
|
+
border: 0;
|
|
28
|
+
background: transparent;
|
|
29
|
+
color: var(--muted);
|
|
30
|
+
padding: 1px;
|
|
31
|
+
display: grid;
|
|
32
|
+
place-items: center;
|
|
33
|
+
}
|
|
34
|
+
.search button svg {
|
|
35
|
+
width: 13px;
|
|
36
|
+
height: 13px;
|
|
37
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import s from "./Section.module.css";
|
|
3
|
+
function Section({
|
|
4
|
+
title,
|
|
5
|
+
children,
|
|
6
|
+
aside
|
|
7
|
+
}) {
|
|
8
|
+
return /* @__PURE__ */ jsxs("section", { className: s.section, children: [
|
|
9
|
+
/* @__PURE__ */ jsxs("header", { children: [
|
|
10
|
+
/* @__PURE__ */ jsx("h2", { children: title }),
|
|
11
|
+
aside
|
|
12
|
+
] }),
|
|
13
|
+
children
|
|
14
|
+
] });
|
|
15
|
+
}
|
|
16
|
+
export {
|
|
17
|
+
Section
|
|
18
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
export declare function Segmented<T extends string>({ value, onChange, options, label, }: {
|
|
3
|
+
value: T;
|
|
4
|
+
onChange(value: T): void;
|
|
5
|
+
options: {
|
|
6
|
+
value: T;
|
|
7
|
+
label: ReactNode;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
}[];
|
|
10
|
+
label: string;
|
|
11
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useLayoutEffect, useRef } from "react";
|
|
3
|
+
import s from "./Segmented.module.css";
|
|
4
|
+
function Segmented({
|
|
5
|
+
value,
|
|
6
|
+
onChange,
|
|
7
|
+
options,
|
|
8
|
+
label
|
|
9
|
+
}) {
|
|
10
|
+
const root = useRef(null), buttons = useRef(/* @__PURE__ */ new Map());
|
|
11
|
+
useLayoutEffect(() => {
|
|
12
|
+
const group = root.current;
|
|
13
|
+
const measure = () => {
|
|
14
|
+
const selected = buttons.current.get(value);
|
|
15
|
+
group.style.setProperty("--segment-opacity", selected ? "1" : "0");
|
|
16
|
+
if (!selected) return;
|
|
17
|
+
if (selected.offsetLeft < group.scrollLeft)
|
|
18
|
+
group.scrollLeft = selected.offsetLeft;
|
|
19
|
+
else if (selected.offsetLeft + selected.offsetWidth > group.scrollLeft + group.clientWidth)
|
|
20
|
+
group.scrollLeft = selected.offsetLeft + selected.offsetWidth - group.clientWidth;
|
|
21
|
+
group.style.setProperty("--segment-x", selected.offsetLeft + "px");
|
|
22
|
+
group.style.setProperty("--segment-y", selected.offsetTop + "px");
|
|
23
|
+
group.style.setProperty("--segment-width", selected.offsetWidth + "px");
|
|
24
|
+
group.style.setProperty("--segment-height", selected.offsetHeight + "px");
|
|
25
|
+
if (!group.dataset.ready) {
|
|
26
|
+
group.getBoundingClientRect();
|
|
27
|
+
group.dataset.ready = "true";
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
measure();
|
|
31
|
+
const observer = new ResizeObserver(measure);
|
|
32
|
+
observer.observe(group);
|
|
33
|
+
buttons.current.forEach((button) => observer.observe(button));
|
|
34
|
+
return () => observer.disconnect();
|
|
35
|
+
}, [value, options]);
|
|
36
|
+
const keyboard = (event, current) => {
|
|
37
|
+
const enabled = options.filter((option) => !option.disabled);
|
|
38
|
+
const index = enabled.findIndex(
|
|
39
|
+
(option) => option.value === options[current].value
|
|
40
|
+
);
|
|
41
|
+
let target = index;
|
|
42
|
+
if (event.key === "ArrowRight" || event.key === "ArrowDown")
|
|
43
|
+
target = (index + 1) % enabled.length;
|
|
44
|
+
else if (event.key === "ArrowLeft" || event.key === "ArrowUp")
|
|
45
|
+
target = (index - 1 + enabled.length) % enabled.length;
|
|
46
|
+
else if (event.key === "Home") target = 0;
|
|
47
|
+
else if (event.key === "End") target = enabled.length - 1;
|
|
48
|
+
else return;
|
|
49
|
+
if (!enabled.length) return;
|
|
50
|
+
event.preventDefault();
|
|
51
|
+
onChange(enabled[target].value);
|
|
52
|
+
buttons.current.get(enabled[target].value)?.focus();
|
|
53
|
+
};
|
|
54
|
+
return /* @__PURE__ */ jsxs("div", { ref: root, className: s.segmented, role: "group", "aria-label": label, children: [
|
|
55
|
+
/* @__PURE__ */ jsx("span", { className: s.indicator, "aria-hidden": "true", "data-segment-indicator": true }),
|
|
56
|
+
options.map((option, index) => /* @__PURE__ */ jsx(
|
|
57
|
+
"button",
|
|
58
|
+
{
|
|
59
|
+
type: "button",
|
|
60
|
+
ref: (node) => {
|
|
61
|
+
if (node) buttons.current.set(option.value, node);
|
|
62
|
+
else buttons.current.delete(option.value);
|
|
63
|
+
},
|
|
64
|
+
"aria-pressed": value === option.value,
|
|
65
|
+
disabled: option.disabled,
|
|
66
|
+
tabIndex: (options.some((item) => item.value === value && !item.disabled) ? value === option.value : option === options.find((item) => !item.disabled)) ? 0 : -1,
|
|
67
|
+
onKeyDown: (event) => keyboard(event, index),
|
|
68
|
+
onClick: () => onChange(option.value),
|
|
69
|
+
children: option.label
|
|
70
|
+
},
|
|
71
|
+
option.value
|
|
72
|
+
))
|
|
73
|
+
] });
|
|
74
|
+
}
|
|
75
|
+
export {
|
|
76
|
+
Segmented
|
|
77
|
+
};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
.segmented {
|
|
2
|
+
position: relative;
|
|
3
|
+
isolation: isolate;
|
|
4
|
+
display: inline-flex;
|
|
5
|
+
width: max-content;
|
|
6
|
+
align-self: flex-start;
|
|
7
|
+
gap: 3px;
|
|
8
|
+
padding: 3px;
|
|
9
|
+
background: var(--soft);
|
|
10
|
+
border: 1px solid var(--line);
|
|
11
|
+
border-radius: calc(var(--radius) - 2px);
|
|
12
|
+
}
|
|
13
|
+
.indicator {
|
|
14
|
+
opacity: var(--segment-opacity, 0);
|
|
15
|
+
position: absolute;
|
|
16
|
+
left: 0;
|
|
17
|
+
top: 0;
|
|
18
|
+
width: var(--segment-width, 0px);
|
|
19
|
+
height: var(--segment-height, 0px);
|
|
20
|
+
transform: translate(var(--segment-x, 0px), var(--segment-y, 0px));
|
|
21
|
+
border-radius: calc(var(--radius) - 5px);
|
|
22
|
+
background: var(--surface);
|
|
23
|
+
box-shadow: 0 1px 3px #0000000d;
|
|
24
|
+
pointer-events: none;
|
|
25
|
+
z-index: 0;
|
|
26
|
+
}
|
|
27
|
+
.segmented[data-ready="true"] .indicator {
|
|
28
|
+
transition:
|
|
29
|
+
transform var(--motion-segment) var(--ease),
|
|
30
|
+
width var(--motion-segment) var(--ease),
|
|
31
|
+
height var(--motion-segment) var(--ease);
|
|
32
|
+
}
|
|
33
|
+
.segmented button {
|
|
34
|
+
position: relative;
|
|
35
|
+
z-index: 1;
|
|
36
|
+
display: flex;
|
|
37
|
+
align-items: center;
|
|
38
|
+
justify-content: center;
|
|
39
|
+
gap: 6px;
|
|
40
|
+
min-height: 26px;
|
|
41
|
+
border: 0;
|
|
42
|
+
padding: 4px 12px;
|
|
43
|
+
border-radius: calc(var(--radius) - 5px);
|
|
44
|
+
background: transparent;
|
|
45
|
+
color: var(--muted);
|
|
46
|
+
font-size: 12px;
|
|
47
|
+
transition:
|
|
48
|
+
color var(--motion-hover) var(--ease),
|
|
49
|
+
scale var(--motion-press) var(--ease);
|
|
50
|
+
}
|
|
51
|
+
.segmented button[aria-pressed="true"] {
|
|
52
|
+
color: var(--fg);
|
|
53
|
+
}
|
|
54
|
+
.segmented button:active:not(:disabled) {
|
|
55
|
+
scale: 0.97;
|
|
56
|
+
}
|
|
57
|
+
.segmented {
|
|
58
|
+
max-width: 100%;
|
|
59
|
+
overflow: auto;
|
|
60
|
+
border-radius: var(--segment-radius);
|
|
61
|
+
background: var(--segment-background);
|
|
62
|
+
}
|
|
63
|
+
.segmented button {
|
|
64
|
+
min-height: var(--segment-height-min);
|
|
65
|
+
font-size: var(--field-font-size);
|
|
66
|
+
white-space: nowrap;
|
|
67
|
+
cursor: pointer;
|
|
68
|
+
}
|
|
69
|
+
.segmented button[aria-pressed="true"] {
|
|
70
|
+
color: var(--segment-selected-color);
|
|
71
|
+
}
|
|
72
|
+
.segmented button:disabled {
|
|
73
|
+
opacity: 0.45;
|
|
74
|
+
cursor: not-allowed;
|
|
75
|
+
}
|
|
76
|
+
.segmented button svg {
|
|
77
|
+
width: 16px;
|
|
78
|
+
height: 16px;
|
|
79
|
+
}
|
|
80
|
+
.segmented button:focus-visible {
|
|
81
|
+
outline-offset: -2px;
|
|
82
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type FieldOptions } from "./field";
|
|
2
|
+
import type { SelectOption } from "./types";
|
|
3
|
+
export declare function Select({ value, onChange, options, label, disabled, id: controlId, name, required, readOnly, error, hint, placeholder, emptyText, ...aria }: FieldOptions & {
|
|
4
|
+
value: string;
|
|
5
|
+
onChange(value: string): void;
|
|
6
|
+
options: SelectOption[];
|
|
7
|
+
label: string;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
placeholder?: string;
|
|
10
|
+
emptyText?: string;
|
|
11
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { fieldTriggerProps, useFieldControl } from "./field.js";
|
|
3
|
+
import { MenuItem } from "./MenuItem.js";
|
|
4
|
+
import { useEffect, useId, useRef, useState } from "react";
|
|
5
|
+
import { usePopover } from "./usePopover.js";
|
|
6
|
+
import { SelectTrigger } from "./SelectTrigger.js";
|
|
7
|
+
import { Popover } from "./Popover.js";
|
|
8
|
+
import s from "./Select.module.css";
|
|
9
|
+
function Select({
|
|
10
|
+
value,
|
|
11
|
+
onChange,
|
|
12
|
+
options,
|
|
13
|
+
label,
|
|
14
|
+
disabled,
|
|
15
|
+
id: controlId,
|
|
16
|
+
name,
|
|
17
|
+
required,
|
|
18
|
+
readOnly,
|
|
19
|
+
error,
|
|
20
|
+
hint,
|
|
21
|
+
placeholder = "\u8BF7\u9009\u62E9",
|
|
22
|
+
emptyText = "\u6CA1\u6709\u53EF\u7528\u9009\u9879",
|
|
23
|
+
...aria
|
|
24
|
+
}) {
|
|
25
|
+
const field = useFieldControl({
|
|
26
|
+
id: controlId,
|
|
27
|
+
name,
|
|
28
|
+
label,
|
|
29
|
+
disabled,
|
|
30
|
+
required,
|
|
31
|
+
readOnly,
|
|
32
|
+
error,
|
|
33
|
+
hint,
|
|
34
|
+
...aria
|
|
35
|
+
});
|
|
36
|
+
const pop = usePopover(field.disabled || field.readOnly), ref = pop.anchor, open = pop.open, [active, setActive] = useState(0), id = useId();
|
|
37
|
+
const reserveIcon = options.some((option) => !!option.icon);
|
|
38
|
+
const selected = options.findIndex((v) => v.value === value);
|
|
39
|
+
const show = () => {
|
|
40
|
+
setActive(
|
|
41
|
+
selected >= 0 && !options[selected]?.disabled ? selected : options.findIndex((option) => !option.disabled)
|
|
42
|
+
);
|
|
43
|
+
pop.show();
|
|
44
|
+
};
|
|
45
|
+
const choose = (index) => {
|
|
46
|
+
if (!field.disabled && !field.readOnly && options[index] && !options[index].disabled) {
|
|
47
|
+
onChange(options[index].value);
|
|
48
|
+
pop.closeAndFocus();
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
const move = (delta) => {
|
|
52
|
+
for (let offset = 1; offset <= options.length; offset++) {
|
|
53
|
+
const next = (active + delta * offset + options.length * 2) % options.length;
|
|
54
|
+
if (!options[next].disabled) {
|
|
55
|
+
setActive(next);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
const typeahead = useRef(""), typeTimer = useRef(void 0);
|
|
61
|
+
useEffect(() => () => clearTimeout(typeTimer.current), []);
|
|
62
|
+
useEffect(() => {
|
|
63
|
+
if (open)
|
|
64
|
+
document.getElementById(`${id}-${active}`)?.scrollIntoView({ block: "nearest" });
|
|
65
|
+
}, [open, active, id]);
|
|
66
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
67
|
+
/* @__PURE__ */ jsx(
|
|
68
|
+
SelectTrigger,
|
|
69
|
+
{
|
|
70
|
+
...fieldTriggerProps(field),
|
|
71
|
+
icon: options[selected]?.icon,
|
|
72
|
+
expanded: open,
|
|
73
|
+
ref,
|
|
74
|
+
"aria-controls": id,
|
|
75
|
+
"aria-haspopup": "listbox",
|
|
76
|
+
"aria-activedescendant": open && active >= 0 ? `${id}-${active}` : void 0,
|
|
77
|
+
onClick: () => {
|
|
78
|
+
if (!field.readOnly) open ? pop.close() : show();
|
|
79
|
+
},
|
|
80
|
+
onKeyDown: (event) => {
|
|
81
|
+
if (field.readOnly) return;
|
|
82
|
+
if (event.key === "Tab") {
|
|
83
|
+
pop.close();
|
|
84
|
+
} else if (["ArrowDown", "ArrowUp", "Home", "End", "Enter", " "].includes(
|
|
85
|
+
event.key
|
|
86
|
+
)) {
|
|
87
|
+
event.preventDefault();
|
|
88
|
+
if (!open) {
|
|
89
|
+
show();
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
if (event.key === "ArrowDown") move(1);
|
|
93
|
+
else if (event.key === "ArrowUp") move(-1);
|
|
94
|
+
else if (event.key === "Home")
|
|
95
|
+
setActive(options.findIndex((v) => !v.disabled));
|
|
96
|
+
else if (event.key === "End")
|
|
97
|
+
setActive(options.findLastIndex((v) => !v.disabled));
|
|
98
|
+
else choose(active);
|
|
99
|
+
} else if (event.key.length === 1 && !event.ctrlKey && !event.metaKey) {
|
|
100
|
+
typeahead.current += event.key.toLowerCase();
|
|
101
|
+
clearTimeout(typeTimer.current);
|
|
102
|
+
typeTimer.current = setTimeout(() => {
|
|
103
|
+
typeahead.current = "";
|
|
104
|
+
}, 500);
|
|
105
|
+
const index = options.findIndex(
|
|
106
|
+
(option) => !option.disabled && option.label.toLowerCase().startsWith(typeahead.current)
|
|
107
|
+
);
|
|
108
|
+
if (index >= 0) {
|
|
109
|
+
setActive(index);
|
|
110
|
+
pop.show();
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
children: /* @__PURE__ */ jsx("span", { children: options[selected]?.label || placeholder })
|
|
115
|
+
}
|
|
116
|
+
),
|
|
117
|
+
field.name && /* @__PURE__ */ jsx(
|
|
118
|
+
"input",
|
|
119
|
+
{
|
|
120
|
+
type: "hidden",
|
|
121
|
+
name: field.name,
|
|
122
|
+
value,
|
|
123
|
+
disabled: field.disabled
|
|
124
|
+
}
|
|
125
|
+
),
|
|
126
|
+
/* @__PURE__ */ jsxs(
|
|
127
|
+
Popover,
|
|
128
|
+
{
|
|
129
|
+
id,
|
|
130
|
+
open,
|
|
131
|
+
onClose: pop.close,
|
|
132
|
+
anchor: ref,
|
|
133
|
+
width: Math.max(
|
|
134
|
+
options.some((option) => option.description || option.shortcut) ? 280 : 200,
|
|
135
|
+
ref.current?.offsetWidth || 0
|
|
136
|
+
),
|
|
137
|
+
label,
|
|
138
|
+
role: "listbox",
|
|
139
|
+
children: [
|
|
140
|
+
!options.length && /* @__PURE__ */ jsx("p", { className: s.empty, children: emptyText }),
|
|
141
|
+
options.map((option, index) => /* @__PURE__ */ jsx(
|
|
142
|
+
MenuItem,
|
|
143
|
+
{
|
|
144
|
+
as: "div",
|
|
145
|
+
label: option.label,
|
|
146
|
+
description: option.description,
|
|
147
|
+
icon: option.icon,
|
|
148
|
+
reserveIcon,
|
|
149
|
+
shortcut: option.shortcut,
|
|
150
|
+
selected: value === option.value,
|
|
151
|
+
active: active === index,
|
|
152
|
+
disabled: option.disabled,
|
|
153
|
+
selection: "check",
|
|
154
|
+
id: `${id}-${index}`,
|
|
155
|
+
role: "option",
|
|
156
|
+
"aria-selected": value === option.value,
|
|
157
|
+
"aria-disabled": option.disabled || void 0,
|
|
158
|
+
onPointerMove: () => !option.disabled && setActive(index),
|
|
159
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
160
|
+
onClick: () => choose(index)
|
|
161
|
+
},
|
|
162
|
+
option.value
|
|
163
|
+
))
|
|
164
|
+
]
|
|
165
|
+
}
|
|
166
|
+
)
|
|
167
|
+
] });
|
|
168
|
+
}
|
|
169
|
+
export {
|
|
170
|
+
Select
|
|
171
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
.select {
|
|
2
|
+
composes: surface from "./Control.module.css";
|
|
3
|
+
min-width: min(168px, 100%);
|
|
4
|
+
width: var(--select-width);
|
|
5
|
+
max-width: 100%;
|
|
6
|
+
padding: 5px 10px;
|
|
7
|
+
display: inline-flex;
|
|
8
|
+
align-items: center;
|
|
9
|
+
justify-content: space-between;
|
|
10
|
+
gap: 18px;
|
|
11
|
+
text-align: left;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.select svg {
|
|
15
|
+
color: var(--muted);
|
|
16
|
+
}
|
|
17
|
+
.empty {
|
|
18
|
+
padding: 14px 10px;
|
|
19
|
+
color: var(--muted);
|
|
20
|
+
font-size: 12px;
|
|
21
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { MenuItemContent } from "./MenuItemContent.js";
|
|
3
|
+
import s from "./SelectOptionContent.module.css";
|
|
4
|
+
function SelectOptionContent({
|
|
5
|
+
option,
|
|
6
|
+
reserveIcon = false
|
|
7
|
+
}) {
|
|
8
|
+
return /* @__PURE__ */ jsx("span", { className: s.content, children: /* @__PURE__ */ jsx(
|
|
9
|
+
MenuItemContent,
|
|
10
|
+
{
|
|
11
|
+
label: option.label,
|
|
12
|
+
description: option.description,
|
|
13
|
+
icon: option.icon,
|
|
14
|
+
reserveIcon
|
|
15
|
+
}
|
|
16
|
+
) });
|
|
17
|
+
}
|
|
18
|
+
export {
|
|
19
|
+
SelectOptionContent
|
|
20
|
+
};
|