@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,29 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { FormField } from "./FormField.js";
|
|
3
|
+
import { fieldInputProps, useFieldControl } from "./field.js";
|
|
4
|
+
import s from "./Input.module.css";
|
|
5
|
+
function Input({
|
|
6
|
+
label,
|
|
7
|
+
error,
|
|
8
|
+
hint,
|
|
9
|
+
leading,
|
|
10
|
+
...props
|
|
11
|
+
}) {
|
|
12
|
+
const field = useFieldControl({ ...props, label, error, hint });
|
|
13
|
+
const control = /* @__PURE__ */ jsx(
|
|
14
|
+
"input",
|
|
15
|
+
{
|
|
16
|
+
...props,
|
|
17
|
+
...fieldInputProps(field),
|
|
18
|
+
className: [s.input, props.className].filter(Boolean).join(" ")
|
|
19
|
+
}
|
|
20
|
+
);
|
|
21
|
+
const content = leading ? /* @__PURE__ */ jsxs("div", { className: s.withIcon, children: [
|
|
22
|
+
/* @__PURE__ */ jsx("span", { className: s.leading, children: leading }),
|
|
23
|
+
control
|
|
24
|
+
] }) : control;
|
|
25
|
+
return field.wrapped ? content : /* @__PURE__ */ jsx(FormField, { ...field, children: content });
|
|
26
|
+
}
|
|
27
|
+
export {
|
|
28
|
+
Input
|
|
29
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
.input {
|
|
2
|
+
composes: surface from "./Control.module.css";
|
|
3
|
+
width: 100%;
|
|
4
|
+
padding: 6px 10px;
|
|
5
|
+
}
|
|
6
|
+
.withIcon {
|
|
7
|
+
position: relative;
|
|
8
|
+
width: 100%;
|
|
9
|
+
min-width: 0;
|
|
10
|
+
}
|
|
11
|
+
.withIcon .input {
|
|
12
|
+
padding-left: 38px;
|
|
13
|
+
}
|
|
14
|
+
.leading {
|
|
15
|
+
position: absolute;
|
|
16
|
+
left: 12px;
|
|
17
|
+
top: 50%;
|
|
18
|
+
transform: translateY(-50%);
|
|
19
|
+
display: flex;
|
|
20
|
+
align-items: center;
|
|
21
|
+
color: var(--muted);
|
|
22
|
+
pointer-events: none;
|
|
23
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { LoadingState } from "./LoadingState.js";
|
|
3
|
+
import s from "./LoadingOverlay.module.css";
|
|
4
|
+
function LoadingOverlay({
|
|
5
|
+
active,
|
|
6
|
+
children,
|
|
7
|
+
label = "\u6B63\u5728\u5904\u7406"
|
|
8
|
+
}) {
|
|
9
|
+
return /* @__PURE__ */ jsxs("div", { className: s.host, "aria-busy": active, children: [
|
|
10
|
+
/* @__PURE__ */ jsx("div", { inert: active, children }),
|
|
11
|
+
/* @__PURE__ */ jsx("div", { className: s.overlay, "data-active": active, "aria-hidden": !active, children: /* @__PURE__ */ jsx(LoadingState, { label }) })
|
|
12
|
+
] });
|
|
13
|
+
}
|
|
14
|
+
export {
|
|
15
|
+
LoadingOverlay
|
|
16
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
.host {
|
|
2
|
+
position: relative;
|
|
3
|
+
border-radius: var(--radius);
|
|
4
|
+
overflow: hidden;
|
|
5
|
+
}
|
|
6
|
+
.overlay {
|
|
7
|
+
position: absolute;
|
|
8
|
+
inset: 0;
|
|
9
|
+
display: grid;
|
|
10
|
+
place-items: center;
|
|
11
|
+
background: color-mix(in srgb, var(--surface) 88%, transparent);
|
|
12
|
+
backdrop-filter: blur(2px);
|
|
13
|
+
visibility: hidden;
|
|
14
|
+
opacity: 0;
|
|
15
|
+
transition:
|
|
16
|
+
opacity var(--popup-enter),
|
|
17
|
+
visibility var(--popup-enter);
|
|
18
|
+
}
|
|
19
|
+
.overlay[data-active="true"] {
|
|
20
|
+
opacity: 1;
|
|
21
|
+
visibility: visible;
|
|
22
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Spinner } from "./Spinner.js";
|
|
3
|
+
import { SkeletonRows } from "./SkeletonRows.js";
|
|
4
|
+
import { Progress } from "./Progress.js";
|
|
5
|
+
import s from "./LoadingState.module.css";
|
|
6
|
+
function LoadingState({
|
|
7
|
+
variant = "spinner",
|
|
8
|
+
label = "\u6B63\u5728\u52A0\u8F7D",
|
|
9
|
+
progress
|
|
10
|
+
}) {
|
|
11
|
+
if (variant === "skeleton") return /* @__PURE__ */ jsx(SkeletonRows, { label });
|
|
12
|
+
return /* @__PURE__ */ jsxs("div", { className: s.loading, role: "status", "aria-label": label, children: [
|
|
13
|
+
variant === "progress" ? /* @__PURE__ */ jsx(Progress, { value: progress ?? 0, label }) : /* @__PURE__ */ jsx(
|
|
14
|
+
Spinner,
|
|
15
|
+
{
|
|
16
|
+
size: 24,
|
|
17
|
+
variant: variant === "dots" ? "dots" : "ring",
|
|
18
|
+
decorative: true
|
|
19
|
+
}
|
|
20
|
+
),
|
|
21
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
22
|
+
label,
|
|
23
|
+
variant === "progress" && progress !== void 0 ? " " + Math.round(progress) + "%" : ""
|
|
24
|
+
] })
|
|
25
|
+
] });
|
|
26
|
+
}
|
|
27
|
+
export {
|
|
28
|
+
LoadingState
|
|
29
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
.loading {
|
|
2
|
+
display: flex;
|
|
3
|
+
min-height: 160px;
|
|
4
|
+
align-items: center;
|
|
5
|
+
justify-content: center;
|
|
6
|
+
flex-direction: column;
|
|
7
|
+
gap: 14px;
|
|
8
|
+
padding: 22px;
|
|
9
|
+
color: var(--muted);
|
|
10
|
+
font-size: 12px;
|
|
11
|
+
}
|
|
12
|
+
.loading > div {
|
|
13
|
+
width: min(260px, 100%);
|
|
14
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
export declare function Menu({ label, items, }: {
|
|
3
|
+
label: string;
|
|
4
|
+
items: {
|
|
5
|
+
label: string;
|
|
6
|
+
icon?: ReactNode;
|
|
7
|
+
danger?: boolean;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
action: () => void;
|
|
10
|
+
}[];
|
|
11
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useId } from "react";
|
|
3
|
+
import { ChevronDown } from "lucide-react";
|
|
4
|
+
import { Button } from "./Button.js";
|
|
5
|
+
import { MenuItem } from "./MenuItem.js";
|
|
6
|
+
import { Popover } from "./Popover.js";
|
|
7
|
+
import { usePopover } from "./usePopover.js";
|
|
8
|
+
function Menu({
|
|
9
|
+
label,
|
|
10
|
+
items
|
|
11
|
+
}) {
|
|
12
|
+
const pop = usePopover(), id = useId();
|
|
13
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
14
|
+
/* @__PURE__ */ jsxs(
|
|
15
|
+
Button,
|
|
16
|
+
{
|
|
17
|
+
ref: pop.anchor,
|
|
18
|
+
"aria-haspopup": "menu",
|
|
19
|
+
"aria-expanded": pop.open,
|
|
20
|
+
"aria-controls": id,
|
|
21
|
+
onClick: pop.toggle,
|
|
22
|
+
onKeyDown: (event) => {
|
|
23
|
+
if (event.key === "ArrowDown" || event.key === "ArrowUp") {
|
|
24
|
+
event.preventDefault();
|
|
25
|
+
pop.show();
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
children: [
|
|
29
|
+
label,
|
|
30
|
+
/* @__PURE__ */ jsx(ChevronDown, { size: 14 })
|
|
31
|
+
]
|
|
32
|
+
}
|
|
33
|
+
),
|
|
34
|
+
/* @__PURE__ */ jsx(
|
|
35
|
+
Popover,
|
|
36
|
+
{
|
|
37
|
+
id,
|
|
38
|
+
label,
|
|
39
|
+
role: "menu",
|
|
40
|
+
open: pop.open,
|
|
41
|
+
anchor: pop.anchor,
|
|
42
|
+
onClose: pop.close,
|
|
43
|
+
onKeyDown: (event) => {
|
|
44
|
+
const buttons = Array.from(
|
|
45
|
+
event.currentTarget.querySelectorAll(
|
|
46
|
+
'[role="menuitem"]:not(:disabled)'
|
|
47
|
+
)
|
|
48
|
+
);
|
|
49
|
+
if (!buttons.length) return;
|
|
50
|
+
const current = buttons.indexOf(
|
|
51
|
+
document.activeElement
|
|
52
|
+
);
|
|
53
|
+
const next = event.key === "ArrowDown" ? (current + 1) % buttons.length : event.key === "ArrowUp" ? (current - 1 + buttons.length) % buttons.length : event.key === "Home" ? 0 : event.key === "End" ? buttons.length - 1 : -1;
|
|
54
|
+
if (next >= 0) {
|
|
55
|
+
event.preventDefault();
|
|
56
|
+
buttons[next].focus();
|
|
57
|
+
}
|
|
58
|
+
if (event.key === "Tab") pop.close();
|
|
59
|
+
},
|
|
60
|
+
children: items.map((item) => /* @__PURE__ */ jsx(
|
|
61
|
+
MenuItem,
|
|
62
|
+
{
|
|
63
|
+
role: "menuitem",
|
|
64
|
+
label: item.label,
|
|
65
|
+
icon: item.icon,
|
|
66
|
+
reserveIcon: items.some((entry) => !!entry.icon),
|
|
67
|
+
disabled: item.disabled,
|
|
68
|
+
tone: item.danger ? "danger" : "default",
|
|
69
|
+
onClick: () => {
|
|
70
|
+
pop.closeAndFocus();
|
|
71
|
+
item.action();
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
item.label
|
|
75
|
+
))
|
|
76
|
+
}
|
|
77
|
+
)
|
|
78
|
+
] });
|
|
79
|
+
}
|
|
80
|
+
export {
|
|
81
|
+
Menu
|
|
82
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type MenuItemContentProps } from "./MenuItemContent";
|
|
2
|
+
import type { HTMLAttributes, ReactNode } from "react";
|
|
3
|
+
export type MenuItemProps = Omit<HTMLAttributes<HTMLElement>, "children" | "prefix"> & MenuItemContentProps & {
|
|
4
|
+
as?: "button" | "div";
|
|
5
|
+
prefix?: ReactNode;
|
|
6
|
+
shortcut?: string;
|
|
7
|
+
trailing?: ReactNode;
|
|
8
|
+
selected?: boolean;
|
|
9
|
+
active?: boolean;
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
selection?: "check" | "checkbox" | "radio";
|
|
12
|
+
tone?: "default" | "danger";
|
|
13
|
+
};
|
|
14
|
+
export declare function MenuItem({ as, prefix, label, description, icon, reserveIcon, shortcut, trailing, selected, active, disabled, selection, tone, className, ...props }: MenuItemProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { MenuItemContent } from "./MenuItemContent.js";
|
|
3
|
+
import { Check } from "lucide-react";
|
|
4
|
+
import s from "./MenuItem.module.css";
|
|
5
|
+
function MenuItem({
|
|
6
|
+
as = "button",
|
|
7
|
+
prefix,
|
|
8
|
+
label,
|
|
9
|
+
description,
|
|
10
|
+
icon,
|
|
11
|
+
reserveIcon = false,
|
|
12
|
+
shortcut,
|
|
13
|
+
trailing,
|
|
14
|
+
selected = false,
|
|
15
|
+
active = false,
|
|
16
|
+
disabled = false,
|
|
17
|
+
selection,
|
|
18
|
+
tone,
|
|
19
|
+
className = "",
|
|
20
|
+
...props
|
|
21
|
+
}) {
|
|
22
|
+
const content = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
23
|
+
prefix,
|
|
24
|
+
/* @__PURE__ */ jsx(
|
|
25
|
+
MenuItemContent,
|
|
26
|
+
{
|
|
27
|
+
label,
|
|
28
|
+
description,
|
|
29
|
+
icon,
|
|
30
|
+
reserveIcon
|
|
31
|
+
}
|
|
32
|
+
),
|
|
33
|
+
shortcut && /* @__PURE__ */ jsx("kbd", { className: s.shortcut, children: shortcut }),
|
|
34
|
+
/* @__PURE__ */ jsx("span", { className: s.trailing, "data-menu-trailing": true, "aria-hidden": "true", children: trailing || (selection === "checkbox" ? /* @__PURE__ */ jsx("span", { className: s.checkbox, "data-checked": selected, children: selected && /* @__PURE__ */ jsx(Check, {}) }) : selection === "radio" ? /* @__PURE__ */ jsx("span", { className: s.radio, "data-checked": selected, children: /* @__PURE__ */ jsx("i", {}) }) : selection === "check" && selected ? /* @__PURE__ */ jsx(Check, { className: s.check }) : null) })
|
|
35
|
+
] });
|
|
36
|
+
const common = {
|
|
37
|
+
...props,
|
|
38
|
+
className: s.item + " " + className,
|
|
39
|
+
"data-menu-item": "",
|
|
40
|
+
"data-selected": selected,
|
|
41
|
+
"data-active": active,
|
|
42
|
+
"data-tone": tone,
|
|
43
|
+
"aria-disabled": disabled || void 0
|
|
44
|
+
};
|
|
45
|
+
return as === "div" ? /* @__PURE__ */ jsx("div", { ...common, children: content }) : /* @__PURE__ */ jsx("button", { type: "button", ...common, disabled, children: content });
|
|
46
|
+
}
|
|
47
|
+
export {
|
|
48
|
+
MenuItem
|
|
49
|
+
};
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
.item {
|
|
2
|
+
display: flex;
|
|
3
|
+
align-items: center;
|
|
4
|
+
gap: var(--menu-item-gap);
|
|
5
|
+
width: 100%;
|
|
6
|
+
min-width: 0;
|
|
7
|
+
min-height: var(--menu-item-height);
|
|
8
|
+
margin: 0;
|
|
9
|
+
padding: max(
|
|
10
|
+
4px,
|
|
11
|
+
calc((var(--menu-item-height) - var(--menu-item-line-height)) / 2)
|
|
12
|
+
)
|
|
13
|
+
var(--menu-item-padding-x);
|
|
14
|
+
border: 0;
|
|
15
|
+
border-radius: calc(var(--radius) - 4px);
|
|
16
|
+
background: transparent;
|
|
17
|
+
color: var(--fg);
|
|
18
|
+
text-align: left;
|
|
19
|
+
font-family: var(--ui-font);
|
|
20
|
+
font-size: var(--menu-item-font-size);
|
|
21
|
+
font-weight: 400;
|
|
22
|
+
line-height: var(--menu-item-line-height);
|
|
23
|
+
cursor: pointer;
|
|
24
|
+
outline: none;
|
|
25
|
+
transition:
|
|
26
|
+
background-color var(--motion-hover),
|
|
27
|
+
color var(--motion-hover);
|
|
28
|
+
}
|
|
29
|
+
.item + .item {
|
|
30
|
+
margin-top: var(--menu-item-spacing);
|
|
31
|
+
}
|
|
32
|
+
@media (pointer: coarse) {
|
|
33
|
+
.item {
|
|
34
|
+
min-height: 44px;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
.item[data-selected="true"] {
|
|
38
|
+
background: var(--selected);
|
|
39
|
+
}
|
|
40
|
+
.item:where(:not(:disabled):not([aria-disabled="true"])):is(
|
|
41
|
+
:hover,
|
|
42
|
+
:focus-visible,
|
|
43
|
+
[data-active="true"],
|
|
44
|
+
[aria-expanded="true"]
|
|
45
|
+
) {
|
|
46
|
+
background: var(--hover);
|
|
47
|
+
}
|
|
48
|
+
.item[data-selected="true"]:where(
|
|
49
|
+
:not(:disabled):not([aria-disabled="true"])
|
|
50
|
+
):is(:hover, :focus-visible, [data-active="true"]) {
|
|
51
|
+
background: color-mix(in srgb, var(--selected) 75%, var(--hover));
|
|
52
|
+
}
|
|
53
|
+
.item:where(:not(:disabled):not([aria-disabled="true"])):active {
|
|
54
|
+
background: var(--selected);
|
|
55
|
+
}
|
|
56
|
+
.item:disabled,
|
|
57
|
+
.item[aria-disabled="true"] {
|
|
58
|
+
opacity: var(--menu-disabled-opacity);
|
|
59
|
+
cursor: not-allowed;
|
|
60
|
+
}
|
|
61
|
+
.item[data-tone="danger"] {
|
|
62
|
+
color: var(--danger);
|
|
63
|
+
}
|
|
64
|
+
.leading,
|
|
65
|
+
.trailing {
|
|
66
|
+
display: grid;
|
|
67
|
+
place-items: center;
|
|
68
|
+
flex: 0 0 var(--menu-item-icon-size);
|
|
69
|
+
width: var(--menu-item-icon-size);
|
|
70
|
+
height: var(--menu-item-icon-size);
|
|
71
|
+
}
|
|
72
|
+
.leading {
|
|
73
|
+
color: inherit;
|
|
74
|
+
opacity: 0.8;
|
|
75
|
+
}
|
|
76
|
+
.leading svg,
|
|
77
|
+
.trailing > svg {
|
|
78
|
+
width: var(--menu-item-icon-size);
|
|
79
|
+
height: var(--menu-item-icon-size);
|
|
80
|
+
stroke-width: 1.65;
|
|
81
|
+
}
|
|
82
|
+
.copy {
|
|
83
|
+
flex: 1;
|
|
84
|
+
min-width: 0;
|
|
85
|
+
display: flex;
|
|
86
|
+
flex-direction: column;
|
|
87
|
+
gap: 2px;
|
|
88
|
+
}
|
|
89
|
+
.label {
|
|
90
|
+
min-width: 0;
|
|
91
|
+
overflow: hidden;
|
|
92
|
+
text-overflow: ellipsis;
|
|
93
|
+
white-space: nowrap;
|
|
94
|
+
}
|
|
95
|
+
.description {
|
|
96
|
+
white-space: nowrap;
|
|
97
|
+
overflow: hidden;
|
|
98
|
+
text-overflow: ellipsis;
|
|
99
|
+
font-size: 11px;
|
|
100
|
+
font-weight: 400;
|
|
101
|
+
line-height: 14px;
|
|
102
|
+
color: var(--muted);
|
|
103
|
+
}
|
|
104
|
+
.shortcut {
|
|
105
|
+
flex-shrink: 0;
|
|
106
|
+
margin-left: auto;
|
|
107
|
+
font-family: var(--ui-font);
|
|
108
|
+
font-size: var(--menu-shortcut-font-size);
|
|
109
|
+
font-weight: 400;
|
|
110
|
+
line-height: var(--menu-shortcut-line-height);
|
|
111
|
+
font-variant-numeric: tabular-nums;
|
|
112
|
+
color: var(--muted);
|
|
113
|
+
white-space: nowrap;
|
|
114
|
+
}
|
|
115
|
+
.check {
|
|
116
|
+
color: var(--accent);
|
|
117
|
+
}
|
|
118
|
+
.checkbox,
|
|
119
|
+
.radio {
|
|
120
|
+
display: grid;
|
|
121
|
+
place-items: center;
|
|
122
|
+
width: var(--menu-item-icon-size);
|
|
123
|
+
height: var(--menu-item-icon-size);
|
|
124
|
+
border: 1px solid color-mix(in srgb, var(--fg) 25%, var(--surface));
|
|
125
|
+
background: var(--field);
|
|
126
|
+
transition:
|
|
127
|
+
background var(--motion-hover),
|
|
128
|
+
border-color var(--motion-hover);
|
|
129
|
+
}
|
|
130
|
+
.checkbox {
|
|
131
|
+
border-radius: 4px;
|
|
132
|
+
}
|
|
133
|
+
.checkbox[data-checked="true"] {
|
|
134
|
+
background: var(--accent);
|
|
135
|
+
border-color: var(--accent);
|
|
136
|
+
color: var(--on-accent);
|
|
137
|
+
}
|
|
138
|
+
.checkbox svg {
|
|
139
|
+
width: 12px;
|
|
140
|
+
height: 12px;
|
|
141
|
+
stroke-width: 2;
|
|
142
|
+
}
|
|
143
|
+
.radio {
|
|
144
|
+
border-radius: 50%;
|
|
145
|
+
}
|
|
146
|
+
.radio i {
|
|
147
|
+
width: 6px;
|
|
148
|
+
height: 6px;
|
|
149
|
+
border-radius: 50%;
|
|
150
|
+
background: var(--accent);
|
|
151
|
+
transform: scale(0);
|
|
152
|
+
transition: transform var(--motion-press) var(--ease);
|
|
153
|
+
}
|
|
154
|
+
.radio[data-checked="true"] {
|
|
155
|
+
border-color: var(--accent);
|
|
156
|
+
}
|
|
157
|
+
.radio[data-checked="true"] i {
|
|
158
|
+
transform: scale(1);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
.item:focus-visible {
|
|
162
|
+
outline: none;
|
|
163
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
export type MenuItemContentProps = {
|
|
3
|
+
label: ReactNode;
|
|
4
|
+
description?: ReactNode;
|
|
5
|
+
icon?: ReactNode;
|
|
6
|
+
reserveIcon?: boolean;
|
|
7
|
+
};
|
|
8
|
+
export declare function MenuItemContent({ label, description, icon, reserveIcon, }: MenuItemContentProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import s from "./MenuItem.module.css";
|
|
3
|
+
function MenuItemContent({
|
|
4
|
+
label,
|
|
5
|
+
description,
|
|
6
|
+
icon,
|
|
7
|
+
reserveIcon = false
|
|
8
|
+
}) {
|
|
9
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
10
|
+
(icon || reserveIcon) && /* @__PURE__ */ jsx("span", { className: s.leading, "data-menu-icon": true, "aria-hidden": "true", children: icon }),
|
|
11
|
+
/* @__PURE__ */ jsxs("span", { className: s.copy, children: [
|
|
12
|
+
/* @__PURE__ */ jsx("span", { className: s.label, "data-menu-label": true, children: label }),
|
|
13
|
+
description && /* @__PURE__ */ jsx("span", { className: s.description, children: description })
|
|
14
|
+
] })
|
|
15
|
+
] });
|
|
16
|
+
}
|
|
17
|
+
export {
|
|
18
|
+
MenuItemContent
|
|
19
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type FieldOptions } from "./field";
|
|
2
|
+
import type { SelectOption } from "./types";
|
|
3
|
+
export declare function MultiSelect({ value, onChange, options, label, disabled, readOnly, required, name, id: controlId, error, hint, maxSelected, clearable, placeholder, ...aria }: FieldOptions & {
|
|
4
|
+
value: string[];
|
|
5
|
+
onChange(value: string[]): void;
|
|
6
|
+
options: SelectOption[];
|
|
7
|
+
label: string;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
maxSelected?: number;
|
|
10
|
+
clearable?: boolean;
|
|
11
|
+
placeholder?: string;
|
|
12
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { moveMenuFocus } from "./menuFocus.js";
|
|
3
|
+
import { fieldTriggerProps, useFieldControl } from "./field.js";
|
|
4
|
+
import { MenuItem } from "./MenuItem.js";
|
|
5
|
+
import { SelectTrigger } from "./SelectTrigger.js";
|
|
6
|
+
import { useEffect, useId, useRef, useState } from "react";
|
|
7
|
+
import { Search } from "lucide-react";
|
|
8
|
+
import { Popover } from "./Popover.js";
|
|
9
|
+
import { usePopover } from "./usePopover.js";
|
|
10
|
+
import { Button } from "./Button.js";
|
|
11
|
+
import s from "./MultiSelect.module.css";
|
|
12
|
+
function MultiSelect({
|
|
13
|
+
value,
|
|
14
|
+
onChange,
|
|
15
|
+
options,
|
|
16
|
+
label,
|
|
17
|
+
disabled,
|
|
18
|
+
readOnly,
|
|
19
|
+
required,
|
|
20
|
+
name,
|
|
21
|
+
id: controlId,
|
|
22
|
+
error,
|
|
23
|
+
hint,
|
|
24
|
+
maxSelected = Infinity,
|
|
25
|
+
clearable = true,
|
|
26
|
+
placeholder = "\u8BF7\u9009\u62E9",
|
|
27
|
+
...aria
|
|
28
|
+
}) {
|
|
29
|
+
const field = useFieldControl({
|
|
30
|
+
id: controlId,
|
|
31
|
+
name,
|
|
32
|
+
label,
|
|
33
|
+
disabled,
|
|
34
|
+
readOnly,
|
|
35
|
+
required,
|
|
36
|
+
error,
|
|
37
|
+
hint,
|
|
38
|
+
...aria
|
|
39
|
+
});
|
|
40
|
+
const pop = usePopover(field.disabled || field.readOnly), [query, setQuery] = useState(""), list = useRef(null), search = useRef(null), id = useId();
|
|
41
|
+
const reserveIcon = options.some((option) => !!option.icon);
|
|
42
|
+
const filtered = options.filter(
|
|
43
|
+
(item) => item.label.toLowerCase().includes(query.toLowerCase())
|
|
44
|
+
);
|
|
45
|
+
const toggle = (option) => {
|
|
46
|
+
if (!field.disabled && !field.readOnly && !option.disabled && (value.includes(option.value) || value.length < maxSelected))
|
|
47
|
+
onChange(
|
|
48
|
+
value.includes(option.value) ? value.filter((v) => v !== option.value) : [...value, option.value]
|
|
49
|
+
);
|
|
50
|
+
};
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
if (pop.open) {
|
|
53
|
+
setQuery("");
|
|
54
|
+
search.current?.focus();
|
|
55
|
+
}
|
|
56
|
+
}, [pop.open]);
|
|
57
|
+
const summary = value.length ? options.filter((item) => value.includes(item.value)).map((item) => item.label).slice(0, 2).join("\u3001") + (value.length > 2 ? ` +${value.length - 2}` : "") : placeholder;
|
|
58
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
59
|
+
/* @__PURE__ */ jsx(
|
|
60
|
+
SelectTrigger,
|
|
61
|
+
{
|
|
62
|
+
...fieldTriggerProps(field),
|
|
63
|
+
expanded: pop.open,
|
|
64
|
+
ref: pop.anchor,
|
|
65
|
+
className: s.multiTrigger,
|
|
66
|
+
"aria-haspopup": "dialog",
|
|
67
|
+
"aria-controls": id,
|
|
68
|
+
onClick: pop.toggle,
|
|
69
|
+
children: /* @__PURE__ */ jsx("span", { children: summary })
|
|
70
|
+
}
|
|
71
|
+
),
|
|
72
|
+
field.name && value.map((value2) => /* @__PURE__ */ jsx(
|
|
73
|
+
"input",
|
|
74
|
+
{
|
|
75
|
+
type: "hidden",
|
|
76
|
+
name: field.name,
|
|
77
|
+
value: value2,
|
|
78
|
+
disabled: field.disabled
|
|
79
|
+
},
|
|
80
|
+
value2
|
|
81
|
+
)),
|
|
82
|
+
/* @__PURE__ */ jsxs(
|
|
83
|
+
Popover,
|
|
84
|
+
{
|
|
85
|
+
id,
|
|
86
|
+
anchor: pop.anchor,
|
|
87
|
+
open: pop.open,
|
|
88
|
+
onClose: pop.close,
|
|
89
|
+
label,
|
|
90
|
+
width: 270,
|
|
91
|
+
onKeyDown: (event) => moveMenuFocus(event, list.current),
|
|
92
|
+
children: [
|
|
93
|
+
/* @__PURE__ */ jsxs("div", { className: s.multiSearch, children: [
|
|
94
|
+
/* @__PURE__ */ jsx(Search, {}),
|
|
95
|
+
/* @__PURE__ */ jsx(
|
|
96
|
+
"input",
|
|
97
|
+
{
|
|
98
|
+
ref: search,
|
|
99
|
+
"aria-label": `\u641C\u7D22${label}`,
|
|
100
|
+
placeholder: "\u641C\u7D22\u9009\u9879\u2026",
|
|
101
|
+
value: query,
|
|
102
|
+
onChange: (e) => setQuery(e.target.value)
|
|
103
|
+
}
|
|
104
|
+
)
|
|
105
|
+
] }),
|
|
106
|
+
/* @__PURE__ */ jsxs(
|
|
107
|
+
"div",
|
|
108
|
+
{
|
|
109
|
+
ref: list,
|
|
110
|
+
className: s.multiList,
|
|
111
|
+
role: "listbox",
|
|
112
|
+
"aria-label": label,
|
|
113
|
+
"aria-multiselectable": "true",
|
|
114
|
+
children: [
|
|
115
|
+
filtered.map((option) => /* @__PURE__ */ jsx(
|
|
116
|
+
MenuItem,
|
|
117
|
+
{
|
|
118
|
+
label: option.label,
|
|
119
|
+
description: option.description,
|
|
120
|
+
icon: option.icon,
|
|
121
|
+
reserveIcon,
|
|
122
|
+
shortcut: option.shortcut,
|
|
123
|
+
selected: value.includes(option.value),
|
|
124
|
+
selection: "checkbox",
|
|
125
|
+
role: "option",
|
|
126
|
+
"aria-selected": value.includes(option.value),
|
|
127
|
+
disabled: option.disabled || !value.includes(option.value) && value.length >= maxSelected,
|
|
128
|
+
onClick: () => toggle(option)
|
|
129
|
+
},
|
|
130
|
+
option.value
|
|
131
|
+
)),
|
|
132
|
+
!filtered.length && /* @__PURE__ */ jsx("p", { className: s.noResults, children: "\u6CA1\u6709\u5339\u914D\u7684\u9009\u9879" })
|
|
133
|
+
]
|
|
134
|
+
}
|
|
135
|
+
),
|
|
136
|
+
/* @__PURE__ */ jsxs("footer", { className: s.multiFooter, children: [
|
|
137
|
+
clearable && /* @__PURE__ */ jsx(
|
|
138
|
+
Button,
|
|
139
|
+
{
|
|
140
|
+
variant: "ghost",
|
|
141
|
+
size: "small",
|
|
142
|
+
disabled: !value.length,
|
|
143
|
+
onClick: () => onChange([]),
|
|
144
|
+
children: "\u6E05\u7A7A"
|
|
145
|
+
}
|
|
146
|
+
),
|
|
147
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
148
|
+
value.length,
|
|
149
|
+
Number.isFinite(maxSelected) ? " / " + maxSelected : "",
|
|
150
|
+
" \u9879"
|
|
151
|
+
] }),
|
|
152
|
+
/* @__PURE__ */ jsx(Button, { size: "small", onClick: pop.closeAndFocus, children: "\u5B8C\u6210" })
|
|
153
|
+
] })
|
|
154
|
+
]
|
|
155
|
+
}
|
|
156
|
+
)
|
|
157
|
+
] });
|
|
158
|
+
}
|
|
159
|
+
export {
|
|
160
|
+
MultiSelect
|
|
161
|
+
};
|