@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,309 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useId, useMemo, useRef, useState } from "react";
|
|
3
|
+
import { ChevronDown, Minus } 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 TreeSelect(props) {
|
|
18
|
+
const {
|
|
19
|
+
options,
|
|
20
|
+
label,
|
|
21
|
+
searchable = true,
|
|
22
|
+
clearable = true,
|
|
23
|
+
placeholder = "\u8BF7\u9009\u62E9",
|
|
24
|
+
loadChildren,
|
|
25
|
+
defaultExpanded = []
|
|
26
|
+
} = props;
|
|
27
|
+
const field = useFieldControl(props), pop = usePopover(field.disabled || field.readOnly), id = useId(), list = useRef(null), [query, setQuery] = useState(""), [expanded, setExpanded] = useState(new Set(defaultExpanded)), [focused, setFocused] = useState("");
|
|
28
|
+
const data = useHierarchy(options, loadChildren), selected = props.multiple ? props.value : props.value ? [props.value] : [];
|
|
29
|
+
const rows = useMemo(() => {
|
|
30
|
+
const matches = query.trim() ? new Set(
|
|
31
|
+
[...data.entries.values()].filter((entry) => hierarchyMatches(entry, query)).flatMap((entry) => entry.path.map((node) => node.value))
|
|
32
|
+
) : null;
|
|
33
|
+
return [...data.entries.values()].filter(
|
|
34
|
+
(entry) => (!matches || matches.has(entry.node.value)) && (query.trim() || entry.path.slice(0, -1).every((node) => expanded.has(node.value)))
|
|
35
|
+
);
|
|
36
|
+
}, [data.entries, query, expanded]);
|
|
37
|
+
const close = pop.closeAndFocus;
|
|
38
|
+
const show = () => {
|
|
39
|
+
if (field.disabled || field.readOnly) return;
|
|
40
|
+
if (pop.open) {
|
|
41
|
+
pop.close();
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
setQuery("");
|
|
45
|
+
setExpanded(
|
|
46
|
+
(old) => /* @__PURE__ */ new Set([
|
|
47
|
+
...old,
|
|
48
|
+
...selected.flatMap(
|
|
49
|
+
(value) => data.entries.get(value)?.path.slice(0, -1).map((n) => n.value) || []
|
|
50
|
+
)
|
|
51
|
+
])
|
|
52
|
+
);
|
|
53
|
+
pop.show();
|
|
54
|
+
};
|
|
55
|
+
const focus = (value) => {
|
|
56
|
+
setFocused(value);
|
|
57
|
+
list.current?.querySelectorAll('[role="treeitem"]').forEach((n) => {
|
|
58
|
+
if (n.dataset.value === value) n.focus({ preventScroll: true });
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
const toggleExpand = (entry) => {
|
|
62
|
+
if (entry.disabled || !entry.branch) return;
|
|
63
|
+
setExpanded((old) => {
|
|
64
|
+
const next = new Set(old);
|
|
65
|
+
next.has(entry.node.value) ? next.delete(entry.node.value) : next.add(entry.node.value);
|
|
66
|
+
return next;
|
|
67
|
+
});
|
|
68
|
+
if (!expanded.has(entry.node.value)) void data.load(entry.node);
|
|
69
|
+
};
|
|
70
|
+
const selectedSet = new Set(selected);
|
|
71
|
+
const leafMap = useMemo(() => {
|
|
72
|
+
const map = /* @__PURE__ */ new Map();
|
|
73
|
+
for (const entry of data.entries.values())
|
|
74
|
+
if (!entry.disabled && !entry.branch && entry.node.selectable !== false)
|
|
75
|
+
for (const node of entry.path) {
|
|
76
|
+
const values = map.get(node.value) || [];
|
|
77
|
+
values.push(entry.node.value);
|
|
78
|
+
map.set(node.value, values);
|
|
79
|
+
}
|
|
80
|
+
return map;
|
|
81
|
+
}, [data.entries]);
|
|
82
|
+
const selection = (entry) => {
|
|
83
|
+
if (!props.multiple) return selectedSet.has(entry.node.value);
|
|
84
|
+
if (entry.disabled) return selectedSet.has(entry.node.value);
|
|
85
|
+
if (props.checkStrictly) return selectedSet.has(entry.node.value);
|
|
86
|
+
const leaves = leafMap.get(entry.node.value) || [], count = leaves.filter((value) => selectedSet.has(value)).length;
|
|
87
|
+
return count && count < leaves.length ? "mixed" : !!leaves.length && count === leaves.length;
|
|
88
|
+
};
|
|
89
|
+
const choose = (entry) => {
|
|
90
|
+
if (field.disabled || field.readOnly || entry.disabled) return;
|
|
91
|
+
if (entry.node.selectable === false || props.multiple && !props.checkStrictly && entry.branch && data.children(entry.node) === void 0) {
|
|
92
|
+
toggleExpand(entry);
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
if (!props.multiple) {
|
|
96
|
+
props.onChange(entry.node.value);
|
|
97
|
+
close();
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
const targets = props.checkStrictly ? [entry.node.value] : leafMap.get(entry.node.value) || [];
|
|
101
|
+
if (!targets.length) return;
|
|
102
|
+
const remove = targets.every((value) => selectedSet.has(value));
|
|
103
|
+
props.onChange(
|
|
104
|
+
remove ? selected.filter((value) => !targets.includes(value)) : [.../* @__PURE__ */ new Set([...selected, ...targets])]
|
|
105
|
+
);
|
|
106
|
+
};
|
|
107
|
+
const first = rows.find((entry) => !entry.disabled)?.node.value;
|
|
108
|
+
const active = rows.some(
|
|
109
|
+
(entry) => entry.node.value === focused && !entry.disabled
|
|
110
|
+
) ? focused : first;
|
|
111
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
112
|
+
/* @__PURE__ */ jsx(
|
|
113
|
+
SelectTrigger,
|
|
114
|
+
{
|
|
115
|
+
...fieldTriggerProps(field),
|
|
116
|
+
ref: pop.anchor,
|
|
117
|
+
expanded: pop.open,
|
|
118
|
+
className: s.trigger,
|
|
119
|
+
"aria-haspopup": "dialog",
|
|
120
|
+
"aria-controls": id,
|
|
121
|
+
onClick: show,
|
|
122
|
+
onKeyDown: (event) => {
|
|
123
|
+
if (event.key === "ArrowDown" && !pop.open) {
|
|
124
|
+
event.preventDefault();
|
|
125
|
+
show();
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
children: selected.length ? props.multiple ? `\u5DF2\u9009\u62E9 ${selected.length} \u9879` : data.entries.get(selected[0])?.path.map((n) => n.label).join(" / ") || selected[0] : placeholder
|
|
129
|
+
}
|
|
130
|
+
),
|
|
131
|
+
field.name && (props.multiple ? selected.map((value) => /* @__PURE__ */ jsx(
|
|
132
|
+
"input",
|
|
133
|
+
{
|
|
134
|
+
type: "hidden",
|
|
135
|
+
name: field.name,
|
|
136
|
+
value,
|
|
137
|
+
disabled: field.disabled
|
|
138
|
+
},
|
|
139
|
+
value
|
|
140
|
+
)) : /* @__PURE__ */ jsx(
|
|
141
|
+
"input",
|
|
142
|
+
{
|
|
143
|
+
type: "hidden",
|
|
144
|
+
name: field.name,
|
|
145
|
+
value: props.value,
|
|
146
|
+
disabled: field.disabled
|
|
147
|
+
}
|
|
148
|
+
)),
|
|
149
|
+
/* @__PURE__ */ jsxs(
|
|
150
|
+
Popover,
|
|
151
|
+
{
|
|
152
|
+
anchor: pop.anchor,
|
|
153
|
+
open: pop.open,
|
|
154
|
+
onClose: pop.close,
|
|
155
|
+
label,
|
|
156
|
+
id,
|
|
157
|
+
width: 340,
|
|
158
|
+
children: [
|
|
159
|
+
searchable && /* @__PURE__ */ jsx("div", { className: s.search, children: /* @__PURE__ */ jsx(
|
|
160
|
+
SearchField,
|
|
161
|
+
{
|
|
162
|
+
label: `\u641C\u7D22${label}`,
|
|
163
|
+
placeholder: "\u641C\u7D22\u540D\u79F0\u6216\u8DEF\u5F84",
|
|
164
|
+
value: query,
|
|
165
|
+
onChange: setQuery,
|
|
166
|
+
onKeyDown: (event) => {
|
|
167
|
+
if (event.key === "ArrowDown") {
|
|
168
|
+
event.preventDefault();
|
|
169
|
+
if (first) focus(first);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
) }),
|
|
174
|
+
/* @__PURE__ */ jsxs(
|
|
175
|
+
"div",
|
|
176
|
+
{
|
|
177
|
+
ref: list,
|
|
178
|
+
role: "tree",
|
|
179
|
+
"aria-label": `${label}\u9009\u9879`,
|
|
180
|
+
"aria-multiselectable": props.multiple || void 0,
|
|
181
|
+
className: s.tree,
|
|
182
|
+
onKeyDown: (event) => {
|
|
183
|
+
if (event.target instanceof HTMLButtonElement) return;
|
|
184
|
+
const available = rows.filter((entry2) => !entry2.disabled), current = available.findIndex(
|
|
185
|
+
(entry2) => entry2.node.value === focused
|
|
186
|
+
), entry = available[current];
|
|
187
|
+
let next;
|
|
188
|
+
if (event.key === "ArrowDown")
|
|
189
|
+
next = available[Math.min(available.length - 1, current + 1)];
|
|
190
|
+
else if (event.key === "ArrowUp")
|
|
191
|
+
next = available[Math.max(0, current - 1)];
|
|
192
|
+
else if (event.key === "Home") next = available[0];
|
|
193
|
+
else if (event.key === "End") next = available.at(-1);
|
|
194
|
+
else if (entry && event.key === "ArrowRight") {
|
|
195
|
+
if (entry.branch && !expanded.has(entry.node.value))
|
|
196
|
+
toggleExpand(entry);
|
|
197
|
+
else
|
|
198
|
+
next = available.find(
|
|
199
|
+
(item) => item.parent === entry.node.value
|
|
200
|
+
);
|
|
201
|
+
} else if (entry && event.key === "ArrowLeft") {
|
|
202
|
+
if (expanded.has(entry.node.value)) toggleExpand(entry);
|
|
203
|
+
else
|
|
204
|
+
next = available.find(
|
|
205
|
+
(item) => item.node.value === entry.parent
|
|
206
|
+
);
|
|
207
|
+
} else if (entry && (event.key === "Enter" || event.key === " "))
|
|
208
|
+
choose(entry);
|
|
209
|
+
else return;
|
|
210
|
+
event.preventDefault();
|
|
211
|
+
event.stopPropagation();
|
|
212
|
+
if (next) focus(next.node.value);
|
|
213
|
+
},
|
|
214
|
+
children: [
|
|
215
|
+
!rows.length && /* @__PURE__ */ jsx("div", { role: "status", className: s.empty, children: "\u6CA1\u6709\u5339\u914D\u9009\u9879" }),
|
|
216
|
+
rows.map((entry) => {
|
|
217
|
+
const state = selection(entry), isExpanded = !!query.trim() || expanded.has(entry.node.value), error = data.error(entry.node);
|
|
218
|
+
return /* @__PURE__ */ jsxs("div", { children: [
|
|
219
|
+
/* @__PURE__ */ jsx(
|
|
220
|
+
MenuItem,
|
|
221
|
+
{
|
|
222
|
+
as: "div",
|
|
223
|
+
role: "treeitem",
|
|
224
|
+
"aria-label": entry.node.label,
|
|
225
|
+
"aria-level": entry.path.length,
|
|
226
|
+
"aria-expanded": entry.branch ? isExpanded : void 0,
|
|
227
|
+
"aria-checked": props.multiple ? state : void 0,
|
|
228
|
+
"aria-selected": !props.multiple && !!state,
|
|
229
|
+
"aria-disabled": entry.disabled || void 0,
|
|
230
|
+
tabIndex: entry.node.value === active ? 0 : -1,
|
|
231
|
+
"data-value": entry.node.value,
|
|
232
|
+
className: `${s.row} ${s.treeRow}`,
|
|
233
|
+
style: { "--level": entry.path.length - 1 },
|
|
234
|
+
label: entry.node.label,
|
|
235
|
+
description: query.trim() ? entry.path.slice(0, -1).map((n) => n.label).join(" / ") : void 0,
|
|
236
|
+
icon: entry.node.icon,
|
|
237
|
+
selected: state === true,
|
|
238
|
+
selection: props.multiple ? "checkbox" : "check",
|
|
239
|
+
disabled: entry.disabled,
|
|
240
|
+
trailing: state === "mixed" ? /* @__PURE__ */ jsx("span", { className: s.mixed, children: /* @__PURE__ */ jsx(Minus, {}) }) : void 0,
|
|
241
|
+
onFocus: () => setFocused(entry.node.value),
|
|
242
|
+
onClick: () => {
|
|
243
|
+
if (entry.disabled) return;
|
|
244
|
+
focus(entry.node.value);
|
|
245
|
+
choose(entry);
|
|
246
|
+
},
|
|
247
|
+
prefix: entry.branch ? /* @__PURE__ */ jsx(
|
|
248
|
+
"button",
|
|
249
|
+
{
|
|
250
|
+
type: "button",
|
|
251
|
+
tabIndex: -1,
|
|
252
|
+
className: s.expander,
|
|
253
|
+
"data-expanded": isExpanded,
|
|
254
|
+
"aria-label": `${isExpanded ? "\u6298\u53E0" : "\u5C55\u5F00"} ${entry.node.label}`,
|
|
255
|
+
disabled: entry.disabled || data.loading.has(entry.node.value),
|
|
256
|
+
onClick: (event) => {
|
|
257
|
+
event.stopPropagation();
|
|
258
|
+
focus(entry.node.value);
|
|
259
|
+
toggleExpand(entry);
|
|
260
|
+
},
|
|
261
|
+
children: data.loading.has(entry.node.value) ? /* @__PURE__ */ jsx(Spinner, { size: 12, decorative: true }) : /* @__PURE__ */ jsx(ChevronDown, {})
|
|
262
|
+
}
|
|
263
|
+
) : /* @__PURE__ */ jsx("span", { className: s.spacer })
|
|
264
|
+
}
|
|
265
|
+
),
|
|
266
|
+
isExpanded && error && /* @__PURE__ */ jsxs("div", { role: "alert", className: s.error, children: [
|
|
267
|
+
/* @__PURE__ */ jsx("span", { children: error }),
|
|
268
|
+
/* @__PURE__ */ jsx(
|
|
269
|
+
Button,
|
|
270
|
+
{
|
|
271
|
+
size: "small",
|
|
272
|
+
variant: "ghost",
|
|
273
|
+
onClick: () => void data.load(entry.node),
|
|
274
|
+
children: "\u91CD\u8BD5"
|
|
275
|
+
}
|
|
276
|
+
)
|
|
277
|
+
] })
|
|
278
|
+
] }, entry.node.value);
|
|
279
|
+
})
|
|
280
|
+
]
|
|
281
|
+
}
|
|
282
|
+
),
|
|
283
|
+
/* @__PURE__ */ jsxs("div", { className: s.footer, children: [
|
|
284
|
+
/* @__PURE__ */ jsx("span", { children: props.multiple ? `${selected.length} \u9879\u5DF2\u9009` : "" }),
|
|
285
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
286
|
+
clearable && /* @__PURE__ */ jsx(
|
|
287
|
+
Button,
|
|
288
|
+
{
|
|
289
|
+
size: "small",
|
|
290
|
+
variant: "ghost",
|
|
291
|
+
disabled: !selected.length,
|
|
292
|
+
onClick: () => {
|
|
293
|
+
if (props.multiple) props.onChange([]);
|
|
294
|
+
else props.onChange("");
|
|
295
|
+
},
|
|
296
|
+
children: "\u6E05\u7A7A"
|
|
297
|
+
}
|
|
298
|
+
),
|
|
299
|
+
props.multiple && /* @__PURE__ */ jsx(Button, { size: "small", onClick: close, children: "\u5B8C\u6210" })
|
|
300
|
+
] })
|
|
301
|
+
] })
|
|
302
|
+
]
|
|
303
|
+
}
|
|
304
|
+
)
|
|
305
|
+
] });
|
|
306
|
+
}
|
|
307
|
+
export {
|
|
308
|
+
TreeSelect
|
|
309
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
export type UIConfig = {
|
|
3
|
+
toastPosition: "top-left" | "top-center" | "top-right" | "bottom-left" | "bottom-center" | "bottom-right";
|
|
4
|
+
tooltipPlacement: "top" | "bottom" | "left" | "right";
|
|
5
|
+
requiredIndicator: "asterisk" | "text" | "none";
|
|
6
|
+
};
|
|
7
|
+
export declare function UIProvider({ children, ...config }: Partial<UIConfig> & {
|
|
8
|
+
children: ReactNode;
|
|
9
|
+
}): import("react").JSX.Element;
|
|
10
|
+
export declare const useUIConfig: () => UIConfig;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useContext } from "react";
|
|
3
|
+
const defaults = {
|
|
4
|
+
toastPosition: "bottom-right",
|
|
5
|
+
tooltipPlacement: "top",
|
|
6
|
+
requiredIndicator: "none"
|
|
7
|
+
};
|
|
8
|
+
const Context = createContext(defaults);
|
|
9
|
+
function UIProvider({
|
|
10
|
+
children,
|
|
11
|
+
...config
|
|
12
|
+
}) {
|
|
13
|
+
const parent = useContext(Context);
|
|
14
|
+
return /* @__PURE__ */ jsx(Context, { value: { ...parent, ...config }, children });
|
|
15
|
+
}
|
|
16
|
+
const useUIConfig = () => useContext(Context);
|
|
17
|
+
export {
|
|
18
|
+
UIProvider,
|
|
19
|
+
useUIConfig
|
|
20
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
import { type FieldOptions } from "./field";
|
|
3
|
+
import { type FileConstraints, type FileRejection, type FileSelectionResult } from "./fileSelection";
|
|
4
|
+
import type { UploadFile, UploadRequest, UploadResult } from "./uploadTypes";
|
|
5
|
+
export type UploadProps = Omit<FieldOptions, "name"> & Omit<FileConstraints, "selectedCount"> & {
|
|
6
|
+
label: string;
|
|
7
|
+
value?: UploadFile[];
|
|
8
|
+
defaultValue?: UploadFile[];
|
|
9
|
+
onChange?(files: UploadFile[]): void;
|
|
10
|
+
request?: UploadRequest;
|
|
11
|
+
autoUpload?: boolean;
|
|
12
|
+
concurrency?: number;
|
|
13
|
+
draggable?: boolean;
|
|
14
|
+
showThumbnails?: boolean;
|
|
15
|
+
description?: ReactNode;
|
|
16
|
+
onReject?(rejections: FileRejection[]): void;
|
|
17
|
+
onValidation?(result: FileSelectionResult): void;
|
|
18
|
+
onSuccess?(file: UploadFile, result: UploadResult | void): void;
|
|
19
|
+
onError?(file: UploadFile, error: unknown): void;
|
|
20
|
+
onPreview?(file: UploadFile, source?: string): void;
|
|
21
|
+
};
|
|
22
|
+
export declare function Upload({ label, value, defaultValue, onChange, request, autoUpload, concurrency, draggable, showThumbnails, description, onReject, onValidation, onSuccess, onError, onPreview, accept, maxSize, maxFiles, multiple, ...options }: UploadProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useRef, useState } from "react";
|
|
3
|
+
import { FilePicker } from "./FilePicker.js";
|
|
4
|
+
import { FileDropZone } from "./FileDropZone.js";
|
|
5
|
+
import { FileSelectionFeedback } from "./FileSelectionFeedback.js";
|
|
6
|
+
import { UploadList } from "./UploadList.js";
|
|
7
|
+
import { Button } from "./Button.js";
|
|
8
|
+
import { Dialog } from "./Dialog.js";
|
|
9
|
+
import { useFieldControl } from "./field.js";
|
|
10
|
+
import { useUploadQueue } from "./useUploadQueue.js";
|
|
11
|
+
import {
|
|
12
|
+
validateFiles
|
|
13
|
+
} from "./fileSelection.js";
|
|
14
|
+
import s from "./Upload.module.css";
|
|
15
|
+
function Upload({
|
|
16
|
+
label,
|
|
17
|
+
value,
|
|
18
|
+
defaultValue,
|
|
19
|
+
onChange,
|
|
20
|
+
request,
|
|
21
|
+
autoUpload = true,
|
|
22
|
+
concurrency = 3,
|
|
23
|
+
draggable = true,
|
|
24
|
+
showThumbnails = true,
|
|
25
|
+
description,
|
|
26
|
+
onReject,
|
|
27
|
+
onValidation,
|
|
28
|
+
onSuccess,
|
|
29
|
+
onError,
|
|
30
|
+
onPreview,
|
|
31
|
+
accept,
|
|
32
|
+
maxSize,
|
|
33
|
+
maxFiles,
|
|
34
|
+
multiple,
|
|
35
|
+
...options
|
|
36
|
+
}) {
|
|
37
|
+
const field = useFieldControl({ ...options, label }), blocked = field.disabled || field.readOnly, queue = useUploadQueue({
|
|
38
|
+
value,
|
|
39
|
+
defaultValue,
|
|
40
|
+
onChange,
|
|
41
|
+
request,
|
|
42
|
+
autoUpload,
|
|
43
|
+
concurrency,
|
|
44
|
+
disabled: blocked,
|
|
45
|
+
onSuccess,
|
|
46
|
+
onError
|
|
47
|
+
}), [rejected, setRejected] = useState([]), [preview, setPreview] = useState(), root = useRef(null);
|
|
48
|
+
const receive = (result) => {
|
|
49
|
+
if (blocked) return;
|
|
50
|
+
const checked = validateFiles(result.accepted, {
|
|
51
|
+
accept,
|
|
52
|
+
maxSize,
|
|
53
|
+
maxFiles,
|
|
54
|
+
multiple,
|
|
55
|
+
selectedCount: queue.current.current.length
|
|
56
|
+
}), combined = {
|
|
57
|
+
accepted: checked.accepted,
|
|
58
|
+
rejected: [...result.rejected, ...checked.rejected]
|
|
59
|
+
};
|
|
60
|
+
setRejected(combined.rejected);
|
|
61
|
+
onValidation?.(combined);
|
|
62
|
+
if (combined.rejected.length) onReject?.(combined.rejected);
|
|
63
|
+
if (checked.accepted.length) queue.add(checked.accepted);
|
|
64
|
+
};
|
|
65
|
+
const constraints = {
|
|
66
|
+
accept,
|
|
67
|
+
maxSize,
|
|
68
|
+
maxFiles,
|
|
69
|
+
multiple,
|
|
70
|
+
selectedCount: queue.files.length
|
|
71
|
+
}, picker = /* @__PURE__ */ jsx(
|
|
72
|
+
FilePicker,
|
|
73
|
+
{
|
|
74
|
+
...constraints,
|
|
75
|
+
label: `\u9009\u62E9${label}`,
|
|
76
|
+
disabled: blocked,
|
|
77
|
+
showErrors: false,
|
|
78
|
+
onFiles: () => {
|
|
79
|
+
},
|
|
80
|
+
onValidation: receive
|
|
81
|
+
}
|
|
82
|
+
);
|
|
83
|
+
useEffect(() => {
|
|
84
|
+
if (!queue.files.length) setRejected((old) => old.length ? [] : old);
|
|
85
|
+
if (preview && !queue.files.some((file) => file.id === preview.id))
|
|
86
|
+
setPreview(void 0);
|
|
87
|
+
}, [queue.files, preview]);
|
|
88
|
+
return /* @__PURE__ */ jsxs(
|
|
89
|
+
"div",
|
|
90
|
+
{
|
|
91
|
+
id: field.id,
|
|
92
|
+
role: "group",
|
|
93
|
+
"aria-label": label,
|
|
94
|
+
"aria-invalid": field.invalid,
|
|
95
|
+
"aria-describedby": field.descriptionId,
|
|
96
|
+
className: s.upload,
|
|
97
|
+
ref: root,
|
|
98
|
+
tabIndex: -1,
|
|
99
|
+
onFocus: (event) => {
|
|
100
|
+
if (event.target === root.current)
|
|
101
|
+
root.current.querySelector("button:not(:disabled)")?.focus();
|
|
102
|
+
},
|
|
103
|
+
children: [
|
|
104
|
+
draggable ? /* @__PURE__ */ jsx(
|
|
105
|
+
FileDropZone,
|
|
106
|
+
{
|
|
107
|
+
...constraints,
|
|
108
|
+
label: `${label}\u62D6\u62FD\u533A\u57DF`,
|
|
109
|
+
title: "\u6DFB\u52A0\u5230\u4E0A\u4F20\u5217\u8868",
|
|
110
|
+
disabled: blocked,
|
|
111
|
+
onFiles: () => {
|
|
112
|
+
},
|
|
113
|
+
onValidation: receive,
|
|
114
|
+
showErrors: false,
|
|
115
|
+
children: /* @__PURE__ */ jsxs("div", { className: s.drop, children: [
|
|
116
|
+
picker,
|
|
117
|
+
description && /* @__PURE__ */ jsx("div", { className: s.description, children: description })
|
|
118
|
+
] })
|
|
119
|
+
}
|
|
120
|
+
) : /* @__PURE__ */ jsxs("div", { className: s.row, children: [
|
|
121
|
+
picker,
|
|
122
|
+
description && /* @__PURE__ */ jsx("div", { className: s.description, children: description })
|
|
123
|
+
] }),
|
|
124
|
+
/* @__PURE__ */ jsx(FileSelectionFeedback, { rejections: rejected }),
|
|
125
|
+
!autoUpload && request && queue.files.some((file) => file.status === "ready") && /* @__PURE__ */ jsx("div", { className: s.row, children: /* @__PURE__ */ jsx(
|
|
126
|
+
Button,
|
|
127
|
+
{
|
|
128
|
+
size: "small",
|
|
129
|
+
disabled: blocked,
|
|
130
|
+
onClick: () => queue.files.filter((file) => file.status === "ready").forEach((file) => queue.start(file.id)),
|
|
131
|
+
children: "\u5F00\u59CB\u5168\u90E8\u4E0A\u4F20"
|
|
132
|
+
}
|
|
133
|
+
) }),
|
|
134
|
+
/* @__PURE__ */ jsx(
|
|
135
|
+
UploadList,
|
|
136
|
+
{
|
|
137
|
+
files: queue.files,
|
|
138
|
+
label: `${label}\u5217\u8868`,
|
|
139
|
+
disabled: blocked,
|
|
140
|
+
showThumbnails,
|
|
141
|
+
onStart: request ? queue.start : void 0,
|
|
142
|
+
onCancel: queue.cancel,
|
|
143
|
+
onRetry: request ? queue.retry : void 0,
|
|
144
|
+
onRemove: queue.remove,
|
|
145
|
+
onPreview: onPreview || ((file, source) => {
|
|
146
|
+
if (source) setPreview({ id: file.id, name: file.name, source });
|
|
147
|
+
})
|
|
148
|
+
}
|
|
149
|
+
),
|
|
150
|
+
/* @__PURE__ */ jsx(
|
|
151
|
+
Dialog,
|
|
152
|
+
{
|
|
153
|
+
open: !!preview,
|
|
154
|
+
onClose: () => setPreview(void 0),
|
|
155
|
+
title: preview?.name || "\u6587\u4EF6\u9884\u89C8",
|
|
156
|
+
children: preview && /* @__PURE__ */ jsx("img", { className: s.preview, src: preview.source, alt: preview.name })
|
|
157
|
+
}
|
|
158
|
+
)
|
|
159
|
+
]
|
|
160
|
+
}
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
export {
|
|
164
|
+
Upload
|
|
165
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
.upload {
|
|
2
|
+
min-width: 0;
|
|
3
|
+
outline: none;
|
|
4
|
+
}
|
|
5
|
+
.drop {
|
|
6
|
+
border: 1px dashed color-mix(in srgb, var(--fg) 20%, var(--surface));
|
|
7
|
+
border-radius: var(--radius);
|
|
8
|
+
background: var(--canvas);
|
|
9
|
+
min-height: 132px;
|
|
10
|
+
display: flex;
|
|
11
|
+
flex-direction: column;
|
|
12
|
+
align-items: center;
|
|
13
|
+
justify-content: center;
|
|
14
|
+
gap: 10px;
|
|
15
|
+
padding: 20px;
|
|
16
|
+
}
|
|
17
|
+
.description {
|
|
18
|
+
color: var(--muted);
|
|
19
|
+
font-size: 12px;
|
|
20
|
+
line-height: 20px;
|
|
21
|
+
overflow-wrap: anywhere;
|
|
22
|
+
}
|
|
23
|
+
.row {
|
|
24
|
+
display: flex;
|
|
25
|
+
align-items: center;
|
|
26
|
+
gap: 12px;
|
|
27
|
+
flex-wrap: wrap;
|
|
28
|
+
margin: 8px 0;
|
|
29
|
+
}
|
|
30
|
+
.preview {
|
|
31
|
+
display: block;
|
|
32
|
+
max-width: 100%;
|
|
33
|
+
max-height: 65vh;
|
|
34
|
+
object-fit: contain;
|
|
35
|
+
margin: auto;
|
|
36
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import { type UploadItemActions } from "./UploadListItem";
|
|
3
|
+
import type { UploadFile } from "./uploadTypes";
|
|
4
|
+
export type UploadListProps = UploadItemActions & {
|
|
5
|
+
files: UploadFile[];
|
|
6
|
+
label?: string;
|
|
7
|
+
emptyText?: ReactNode;
|
|
8
|
+
};
|
|
9
|
+
export declare function UploadList({ files, label, emptyText, ...actions }: UploadListProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { UploadListItem } from "./UploadListItem.js";
|
|
3
|
+
import s from "./UploadList.module.css";
|
|
4
|
+
function UploadList({
|
|
5
|
+
files,
|
|
6
|
+
label = "\u4E0A\u4F20\u6587\u4EF6\u5217\u8868",
|
|
7
|
+
emptyText = "\u5C1A\u672A\u6DFB\u52A0\u6587\u4EF6",
|
|
8
|
+
...actions
|
|
9
|
+
}) {
|
|
10
|
+
return /* @__PURE__ */ jsx("div", { className: s.root, children: files.length ? /* @__PURE__ */ jsx("ul", { className: s.list, "aria-label": label, children: files.map((file) => /* @__PURE__ */ jsx(UploadListItem, { file, ...actions }, file.id)) }) : /* @__PURE__ */ jsx("div", { role: "status", className: s.empty, children: emptyText }) });
|
|
11
|
+
}
|
|
12
|
+
export {
|
|
13
|
+
UploadList
|
|
14
|
+
};
|