@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,106 @@
|
|
|
1
|
+
.calendar {
|
|
2
|
+
width: 100%;
|
|
3
|
+
min-width: 0;
|
|
4
|
+
padding: 4px;
|
|
5
|
+
}
|
|
6
|
+
.calendar header {
|
|
7
|
+
display: flex;
|
|
8
|
+
align-items: center;
|
|
9
|
+
justify-content: space-between;
|
|
10
|
+
height: 36px;
|
|
11
|
+
margin-bottom: 6px;
|
|
12
|
+
}
|
|
13
|
+
.heading {
|
|
14
|
+
display: flex;
|
|
15
|
+
gap: 2px;
|
|
16
|
+
align-items: center;
|
|
17
|
+
font-size: 12px;
|
|
18
|
+
font-weight: 500;
|
|
19
|
+
}
|
|
20
|
+
.heading button {
|
|
21
|
+
background: transparent;
|
|
22
|
+
border: 0;
|
|
23
|
+
border-radius: 5px;
|
|
24
|
+
padding: 4px 6px;
|
|
25
|
+
font-size: 12px;
|
|
26
|
+
}
|
|
27
|
+
.heading button:hover {
|
|
28
|
+
background: var(--hover);
|
|
29
|
+
}
|
|
30
|
+
.area {
|
|
31
|
+
height: 252px;
|
|
32
|
+
}
|
|
33
|
+
.week {
|
|
34
|
+
display: grid;
|
|
35
|
+
grid-template-columns: repeat(7, 1fr);
|
|
36
|
+
height: 30px;
|
|
37
|
+
align-items: center;
|
|
38
|
+
text-align: center;
|
|
39
|
+
color: var(--muted);
|
|
40
|
+
font-size: 11px;
|
|
41
|
+
}
|
|
42
|
+
.days {
|
|
43
|
+
display: grid;
|
|
44
|
+
grid-template-columns: repeat(7, minmax(0, 1fr));
|
|
45
|
+
grid-template-rows: repeat(6, 34px);
|
|
46
|
+
gap: 3px;
|
|
47
|
+
}
|
|
48
|
+
.days button,
|
|
49
|
+
.choices button {
|
|
50
|
+
border: 0;
|
|
51
|
+
border-radius: 6px;
|
|
52
|
+
background: transparent;
|
|
53
|
+
font-size: 12px;
|
|
54
|
+
}
|
|
55
|
+
.days button:hover:not(:disabled),
|
|
56
|
+
.choices button:hover:not(:disabled) {
|
|
57
|
+
background: var(--hover);
|
|
58
|
+
}
|
|
59
|
+
.days button[data-outside="true"] {
|
|
60
|
+
color: var(--muted);
|
|
61
|
+
opacity: 0.5;
|
|
62
|
+
}
|
|
63
|
+
.days button[aria-current="date"] {
|
|
64
|
+
box-shadow: inset 0 0 0 1px var(--line);
|
|
65
|
+
}
|
|
66
|
+
.days button[aria-pressed="true"],
|
|
67
|
+
.choices button[aria-pressed="true"] {
|
|
68
|
+
background: var(--accent);
|
|
69
|
+
color: var(--on-accent);
|
|
70
|
+
opacity: 1;
|
|
71
|
+
}
|
|
72
|
+
.days button:focus-visible,
|
|
73
|
+
.choices button:focus-visible {
|
|
74
|
+
outline-offset: -2px;
|
|
75
|
+
}
|
|
76
|
+
.choices {
|
|
77
|
+
display: grid;
|
|
78
|
+
grid-template-columns: repeat(3, minmax(0, 1fr));
|
|
79
|
+
grid-template-rows: repeat(4, 1fr);
|
|
80
|
+
gap: 8px;
|
|
81
|
+
height: 100%;
|
|
82
|
+
padding: 8px 0;
|
|
83
|
+
}
|
|
84
|
+
.days button[data-in-range="true"] {
|
|
85
|
+
background: color-mix(in srgb, var(--accent) 10%, var(--surface));
|
|
86
|
+
color: var(--fg);
|
|
87
|
+
opacity: 1;
|
|
88
|
+
}
|
|
89
|
+
.days button[data-preview="true"][data-in-range="true"] {
|
|
90
|
+
background: color-mix(in srgb, var(--accent) 7%, var(--surface));
|
|
91
|
+
}
|
|
92
|
+
.days button:disabled,
|
|
93
|
+
.choices button:disabled {
|
|
94
|
+
color: var(--disabled);
|
|
95
|
+
opacity: 0.42;
|
|
96
|
+
cursor: not-allowed;
|
|
97
|
+
}
|
|
98
|
+
.days button:disabled[aria-pressed="true"] {
|
|
99
|
+
background: var(--soft);
|
|
100
|
+
}
|
|
101
|
+
.days button,
|
|
102
|
+
.choices button {
|
|
103
|
+
transition:
|
|
104
|
+
background var(--motion-hover),
|
|
105
|
+
color var(--motion-hover);
|
|
106
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import s from "./Card.module.css";
|
|
3
|
+
function Card({
|
|
4
|
+
title,
|
|
5
|
+
action,
|
|
6
|
+
children,
|
|
7
|
+
className = ""
|
|
8
|
+
}) {
|
|
9
|
+
return /* @__PURE__ */ jsxs("section", { className: s.card + " " + className, children: [
|
|
10
|
+
(title || action) && /* @__PURE__ */ jsxs("header", { className: s.header, children: [
|
|
11
|
+
/* @__PURE__ */ jsx("h2", { children: title }),
|
|
12
|
+
action
|
|
13
|
+
] }),
|
|
14
|
+
/* @__PURE__ */ jsx("div", { className: s.body, "data-card-body": true, children })
|
|
15
|
+
] });
|
|
16
|
+
}
|
|
17
|
+
export {
|
|
18
|
+
Card
|
|
19
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
.card {
|
|
2
|
+
background: var(--surface);
|
|
3
|
+
border: 1px solid var(--line);
|
|
4
|
+
border-radius: var(--card-radius);
|
|
5
|
+
min-width: 0;
|
|
6
|
+
box-shadow: var(--card-shadow, none);
|
|
7
|
+
}
|
|
8
|
+
.header {
|
|
9
|
+
display: flex;
|
|
10
|
+
align-items: center;
|
|
11
|
+
justify-content: space-between;
|
|
12
|
+
gap: 12px;
|
|
13
|
+
padding: 20px 24px 0;
|
|
14
|
+
}
|
|
15
|
+
.body {
|
|
16
|
+
padding: var(--card-space);
|
|
17
|
+
}
|
|
18
|
+
.header + .body {
|
|
19
|
+
padding-top: 20px;
|
|
20
|
+
}
|
|
21
|
+
@media (max-width: 600px) {
|
|
22
|
+
.header {
|
|
23
|
+
padding: 18px 18px 0;
|
|
24
|
+
}
|
|
25
|
+
.body {
|
|
26
|
+
padding: 18px;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type FieldOptions } from "./field";
|
|
2
|
+
import { type HierarchyLoader, type HierarchyOption } from "./hierarchy";
|
|
3
|
+
export type CascaderProps = FieldOptions & {
|
|
4
|
+
options: HierarchyOption[];
|
|
5
|
+
value: string[];
|
|
6
|
+
onChange(path: string[]): void;
|
|
7
|
+
label: string;
|
|
8
|
+
searchable?: boolean;
|
|
9
|
+
clearable?: boolean;
|
|
10
|
+
changeOnSelect?: boolean;
|
|
11
|
+
placeholder?: string;
|
|
12
|
+
loadChildren?: HierarchyLoader;
|
|
13
|
+
};
|
|
14
|
+
export declare function Cascader({ options, value, onChange, label, searchable, clearable, changeOnSelect, placeholder, loadChildren, ...fieldOptions }: CascaderProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useId, useLayoutEffect, useRef, useState } from "react";
|
|
3
|
+
import { ChevronRight } from "lucide-react";
|
|
4
|
+
import { SelectTrigger } from "./SelectTrigger.js";
|
|
5
|
+
import { Popover } from "./Popover.js";
|
|
6
|
+
import { MenuItem } from "./MenuItem.js";
|
|
7
|
+
import { SearchField } from "./SearchField.js";
|
|
8
|
+
import { Spinner } from "./Spinner.js";
|
|
9
|
+
import { Button } from "./Button.js";
|
|
10
|
+
import { usePopover } from "./usePopover.js";
|
|
11
|
+
import { fieldTriggerProps, useFieldControl } from "./field.js";
|
|
12
|
+
import { useHierarchy } from "./useHierarchy.js";
|
|
13
|
+
import {
|
|
14
|
+
hierarchyMatches
|
|
15
|
+
} from "./hierarchy.js";
|
|
16
|
+
import s from "./HierarchyPicker.module.css";
|
|
17
|
+
function Cascader({
|
|
18
|
+
options,
|
|
19
|
+
value,
|
|
20
|
+
onChange,
|
|
21
|
+
label,
|
|
22
|
+
searchable = true,
|
|
23
|
+
clearable = true,
|
|
24
|
+
changeOnSelect = false,
|
|
25
|
+
placeholder = "\u8BF7\u9009\u62E9\u8DEF\u5F84",
|
|
26
|
+
loadChildren,
|
|
27
|
+
...fieldOptions
|
|
28
|
+
}) {
|
|
29
|
+
const field = useFieldControl({ ...fieldOptions, label }), pop = usePopover(field.disabled || field.readOnly), id = useId(), root = useRef(null), pending = useRef(null), [path, setPath] = useState([]), [query, setQuery] = useState(""), [focused, setFocused] = useState({});
|
|
30
|
+
const data = useHierarchy(options, loadChildren);
|
|
31
|
+
const columns = [
|
|
32
|
+
{ nodes: options }
|
|
33
|
+
];
|
|
34
|
+
let parent;
|
|
35
|
+
for (const key of path) {
|
|
36
|
+
const entry = data.entries.get(key);
|
|
37
|
+
if (!entry || entry.parent !== parent) break;
|
|
38
|
+
const children = data.children(entry.node);
|
|
39
|
+
if (entry.branch)
|
|
40
|
+
columns.push({ nodes: children || [], parent: entry.node });
|
|
41
|
+
parent = key;
|
|
42
|
+
}
|
|
43
|
+
const matches = query.trim() ? [...data.entries.values()].filter(
|
|
44
|
+
(entry) => !entry.disabled && entry.node.selectable !== false && (!entry.branch || changeOnSelect) && hierarchyMatches(entry, query)
|
|
45
|
+
) : [];
|
|
46
|
+
const focus = (column, key) => {
|
|
47
|
+
const node = root.current?.querySelector(
|
|
48
|
+
`[data-column="${column}"]`
|
|
49
|
+
);
|
|
50
|
+
const target = key ? [
|
|
51
|
+
...node?.querySelectorAll('[role="option"]') || []
|
|
52
|
+
].find((n) => n.dataset.value === key) : node?.querySelector('[role="option"]:not(:disabled)');
|
|
53
|
+
target?.focus({ preventScroll: true });
|
|
54
|
+
target?.scrollIntoView({ block: "nearest", inline: "nearest" });
|
|
55
|
+
};
|
|
56
|
+
useLayoutEffect(() => {
|
|
57
|
+
if (pop.open && pending.current !== null) {
|
|
58
|
+
const index = pending.current;
|
|
59
|
+
if (columns[index]?.nodes.length) {
|
|
60
|
+
pending.current = null;
|
|
61
|
+
focus(index);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}, [path, data.entries, pop.open]);
|
|
65
|
+
const close = () => {
|
|
66
|
+
pending.current = null;
|
|
67
|
+
pop.closeAndFocus();
|
|
68
|
+
};
|
|
69
|
+
const show = () => {
|
|
70
|
+
if (field.disabled || field.readOnly) return;
|
|
71
|
+
if (pop.open) {
|
|
72
|
+
pop.close();
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
setFocused({});
|
|
76
|
+
setPath([...value]);
|
|
77
|
+
setQuery("");
|
|
78
|
+
pending.current = null;
|
|
79
|
+
pop.show();
|
|
80
|
+
};
|
|
81
|
+
const choose = (entry, keyboard = false) => {
|
|
82
|
+
if (entry.disabled || field.disabled || field.readOnly) return;
|
|
83
|
+
pending.current = null;
|
|
84
|
+
const next = entry.path.map((node) => node.value);
|
|
85
|
+
setPath(next);
|
|
86
|
+
if (entry.branch) {
|
|
87
|
+
if (changeOnSelect && entry.node.selectable !== false) onChange(next);
|
|
88
|
+
if (keyboard) pending.current = entry.path.length;
|
|
89
|
+
void data.load(entry.node);
|
|
90
|
+
} else if (entry.node.selectable !== false) {
|
|
91
|
+
onChange(next);
|
|
92
|
+
close();
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
const stops = columns.map(({ nodes }, level) => {
|
|
96
|
+
const enabled = nodes.filter((node) => {
|
|
97
|
+
const entry = data.entries.get(node.value);
|
|
98
|
+
return entry && !entry.disabled && (entry.branch || node.selectable !== false);
|
|
99
|
+
});
|
|
100
|
+
return [focused[level], path[level], enabled[0]?.value].find(
|
|
101
|
+
(value2) => enabled.some((node) => node.value === value2)
|
|
102
|
+
);
|
|
103
|
+
});
|
|
104
|
+
const remember = (level, value2) => setFocused(
|
|
105
|
+
(old) => old[level] === value2 ? old : { ...old, [level]: value2 }
|
|
106
|
+
);
|
|
107
|
+
const summary = value.map((key) => data.entries.get(key)?.node.label || key).join(" / ");
|
|
108
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
109
|
+
/* @__PURE__ */ jsx(
|
|
110
|
+
SelectTrigger,
|
|
111
|
+
{
|
|
112
|
+
...fieldTriggerProps(field),
|
|
113
|
+
ref: pop.anchor,
|
|
114
|
+
expanded: pop.open,
|
|
115
|
+
className: s.trigger,
|
|
116
|
+
"aria-haspopup": "dialog",
|
|
117
|
+
"aria-controls": id,
|
|
118
|
+
onClick: show,
|
|
119
|
+
onKeyDown: (event) => {
|
|
120
|
+
if (event.key === "ArrowDown" && !pop.open) {
|
|
121
|
+
event.preventDefault();
|
|
122
|
+
show();
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
children: summary || placeholder
|
|
126
|
+
}
|
|
127
|
+
),
|
|
128
|
+
field.name && value.map((key, index) => /* @__PURE__ */ jsx(
|
|
129
|
+
"input",
|
|
130
|
+
{
|
|
131
|
+
type: "hidden",
|
|
132
|
+
name: field.name,
|
|
133
|
+
value: key,
|
|
134
|
+
disabled: field.disabled
|
|
135
|
+
},
|
|
136
|
+
index
|
|
137
|
+
)),
|
|
138
|
+
/* @__PURE__ */ jsxs(
|
|
139
|
+
Popover,
|
|
140
|
+
{
|
|
141
|
+
anchor: pop.anchor,
|
|
142
|
+
open: pop.open,
|
|
143
|
+
onClose: pop.close,
|
|
144
|
+
label,
|
|
145
|
+
id,
|
|
146
|
+
width: 580,
|
|
147
|
+
children: [
|
|
148
|
+
searchable && /* @__PURE__ */ jsx("div", { className: s.search, children: /* @__PURE__ */ jsx(
|
|
149
|
+
SearchField,
|
|
150
|
+
{
|
|
151
|
+
label: `\u641C\u7D22${label}`,
|
|
152
|
+
placeholder: "\u641C\u7D22\u540D\u79F0\u6216\u5B8C\u6574\u8DEF\u5F84",
|
|
153
|
+
value: query,
|
|
154
|
+
onChange: setQuery,
|
|
155
|
+
onKeyDown: (event) => {
|
|
156
|
+
if (event.key === "ArrowDown") {
|
|
157
|
+
event.preventDefault();
|
|
158
|
+
if (query.trim())
|
|
159
|
+
root.current?.querySelector(
|
|
160
|
+
'[role="option"]:not(:disabled)'
|
|
161
|
+
)?.focus();
|
|
162
|
+
else focus(0);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
) }),
|
|
167
|
+
/* @__PURE__ */ jsx(
|
|
168
|
+
"div",
|
|
169
|
+
{
|
|
170
|
+
ref: root,
|
|
171
|
+
className: s.columns,
|
|
172
|
+
onKeyDown: (event) => {
|
|
173
|
+
const target = event.target;
|
|
174
|
+
if (target.getAttribute("role") !== "option") return;
|
|
175
|
+
const column = target.closest("[data-column]"), nodes = [
|
|
176
|
+
...column?.querySelectorAll(
|
|
177
|
+
'[role="option"]:not(:disabled)'
|
|
178
|
+
) || []
|
|
179
|
+
], index = nodes.indexOf(target), level = Number(column?.dataset.column), entry = data.entries.get(target.dataset.value || "");
|
|
180
|
+
let next;
|
|
181
|
+
if (event.key === "ArrowDown")
|
|
182
|
+
next = nodes[(index + 1) % nodes.length];
|
|
183
|
+
else if (event.key === "ArrowUp")
|
|
184
|
+
next = nodes[(index - 1 + nodes.length) % nodes.length];
|
|
185
|
+
else if (event.key === "Home") next = nodes[0];
|
|
186
|
+
else if (event.key === "End") next = nodes.at(-1);
|
|
187
|
+
else if (!query.trim() && event.key === "ArrowRight" && entry?.branch)
|
|
188
|
+
choose(entry, true);
|
|
189
|
+
else if (!query.trim() && event.key === "ArrowLeft" && level > 0) {
|
|
190
|
+
pending.current = null;
|
|
191
|
+
focus(level - 1, path[level - 1]);
|
|
192
|
+
} else return;
|
|
193
|
+
event.preventDefault();
|
|
194
|
+
event.stopPropagation();
|
|
195
|
+
next?.focus();
|
|
196
|
+
},
|
|
197
|
+
children: query.trim() ? /* @__PURE__ */ jsx(
|
|
198
|
+
"div",
|
|
199
|
+
{
|
|
200
|
+
role: "listbox",
|
|
201
|
+
"aria-label": `${label}\u641C\u7D22\u7ED3\u679C`,
|
|
202
|
+
"data-column": "0",
|
|
203
|
+
className: s.column,
|
|
204
|
+
children: matches.length ? matches.map((entry) => /* @__PURE__ */ jsx(
|
|
205
|
+
MenuItem,
|
|
206
|
+
{
|
|
207
|
+
role: "option",
|
|
208
|
+
"data-value": entry.node.value,
|
|
209
|
+
label: entry.path.map((n) => n.label).join(" / "),
|
|
210
|
+
tabIndex: entry.node.value === (matches.some((item) => item.node.value === focused[0]) ? focused[0] : matches[0]?.node.value) ? 0 : -1,
|
|
211
|
+
onFocus: () => remember(0, entry.node.value),
|
|
212
|
+
icon: entry.node.icon,
|
|
213
|
+
"aria-selected": entry.node.value === value.at(-1),
|
|
214
|
+
selected: entry.node.value === value.at(-1),
|
|
215
|
+
selection: "check",
|
|
216
|
+
onClick: () => choose(entry)
|
|
217
|
+
},
|
|
218
|
+
entry.node.value
|
|
219
|
+
)) : /* @__PURE__ */ jsx("div", { role: "status", className: s.empty, children: "\u6CA1\u6709\u5339\u914D\u9009\u9879" })
|
|
220
|
+
},
|
|
221
|
+
"search"
|
|
222
|
+
) : columns.map(({ nodes, parent: parent2 }, level) => /* @__PURE__ */ jsxs(
|
|
223
|
+
"div",
|
|
224
|
+
{
|
|
225
|
+
role: "listbox",
|
|
226
|
+
"aria-label": `${label}\u7B2C ${level + 1} \u7EA7`,
|
|
227
|
+
"data-column": level,
|
|
228
|
+
"aria-busy": !!parent2 && data.loading.has(parent2.value),
|
|
229
|
+
className: s.column,
|
|
230
|
+
children: [
|
|
231
|
+
nodes.map((node) => {
|
|
232
|
+
const entry = data.entries.get(node.value);
|
|
233
|
+
if (!entry) return null;
|
|
234
|
+
return /* @__PURE__ */ jsx(
|
|
235
|
+
MenuItem,
|
|
236
|
+
{
|
|
237
|
+
role: "option",
|
|
238
|
+
"data-value": node.value,
|
|
239
|
+
label: node.label,
|
|
240
|
+
icon: node.icon,
|
|
241
|
+
disabled: entry.disabled || !entry.branch && node.selectable === false,
|
|
242
|
+
"aria-selected": path[level] === node.value,
|
|
243
|
+
selected: path[level] === node.value,
|
|
244
|
+
trailing: data.loading.has(node.value) ? /* @__PURE__ */ jsx(Spinner, { size: 14, decorative: true }) : entry.branch ? /* @__PURE__ */ jsx(ChevronRight, {}) : void 0,
|
|
245
|
+
selection: entry.branch ? void 0 : "check",
|
|
246
|
+
tabIndex: node.value === stops[level] ? 0 : -1,
|
|
247
|
+
onFocus: () => remember(level, node.value),
|
|
248
|
+
onClick: () => choose(entry)
|
|
249
|
+
},
|
|
250
|
+
node.value
|
|
251
|
+
);
|
|
252
|
+
}),
|
|
253
|
+
parent2 && data.loading.has(parent2.value) && /* @__PURE__ */ jsx("div", { role: "status", className: s.status, children: "\u6B63\u5728\u52A0\u8F7D\u2026" }),
|
|
254
|
+
parent2 && data.error(parent2) && /* @__PURE__ */ jsxs("div", { role: "alert", className: s.error, children: [
|
|
255
|
+
/* @__PURE__ */ jsx("span", { children: data.error(parent2) }),
|
|
256
|
+
/* @__PURE__ */ jsx(
|
|
257
|
+
Button,
|
|
258
|
+
{
|
|
259
|
+
size: "small",
|
|
260
|
+
variant: "ghost",
|
|
261
|
+
onClick: () => void data.load(parent2),
|
|
262
|
+
children: "\u91CD\u8BD5"
|
|
263
|
+
}
|
|
264
|
+
)
|
|
265
|
+
] }),
|
|
266
|
+
!nodes.length && (!parent2 || !data.loading.has(parent2.value) && !data.error(parent2)) && /* @__PURE__ */ jsx("div", { role: "status", className: s.empty, children: "\u6CA1\u6709\u53EF\u7528\u9009\u9879" })
|
|
267
|
+
]
|
|
268
|
+
},
|
|
269
|
+
parent2?.value || "root"
|
|
270
|
+
))
|
|
271
|
+
}
|
|
272
|
+
),
|
|
273
|
+
clearable && /* @__PURE__ */ jsxs("div", { className: s.footer, children: [
|
|
274
|
+
/* @__PURE__ */ jsx("span", {}),
|
|
275
|
+
/* @__PURE__ */ jsx(
|
|
276
|
+
Button,
|
|
277
|
+
{
|
|
278
|
+
size: "small",
|
|
279
|
+
variant: "ghost",
|
|
280
|
+
disabled: !value.length,
|
|
281
|
+
onClick: () => {
|
|
282
|
+
onChange([]);
|
|
283
|
+
setPath([]);
|
|
284
|
+
},
|
|
285
|
+
children: "\u6E05\u7A7A"
|
|
286
|
+
}
|
|
287
|
+
)
|
|
288
|
+
] })
|
|
289
|
+
]
|
|
290
|
+
}
|
|
291
|
+
)
|
|
292
|
+
] });
|
|
293
|
+
}
|
|
294
|
+
export {
|
|
295
|
+
Cascader
|
|
296
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Icon, Shapes } from "lucide-react";
|
|
3
|
+
import { useIconCatalog } from "./iconCatalog.js";
|
|
4
|
+
function CatalogIcon({ name }) {
|
|
5
|
+
const { items } = useIconCatalog();
|
|
6
|
+
const icon = items?.find((x) => x.name === name || x.aliases.includes(name));
|
|
7
|
+
return icon ? /* @__PURE__ */ jsx(Icon, { icon }) : /* @__PURE__ */ jsx(Shapes, {});
|
|
8
|
+
}
|
|
9
|
+
export {
|
|
10
|
+
CatalogIcon
|
|
11
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export type CharacterGroup = {
|
|
2
|
+
name: string;
|
|
3
|
+
items: [string, string, string?][];
|
|
4
|
+
};
|
|
5
|
+
export declare function CharacterPicker({ value, onChange, label, groups, disabled, loading, error, onRetry, emoji, }: {
|
|
6
|
+
value: string;
|
|
7
|
+
onChange(value: string): void;
|
|
8
|
+
label: string;
|
|
9
|
+
groups: CharacterGroup[];
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
loading?: boolean;
|
|
12
|
+
error?: boolean;
|
|
13
|
+
onRetry?(): void;
|
|
14
|
+
emoji?: boolean;
|
|
15
|
+
}): import("react").JSX.Element;
|