@robert-stackflow/oneui 0.0.0-stage → 0.2.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/CHANGELOG.md +18 -0
- package/README.md +72 -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 +13 -0
- package/components/Button.js +52 -0
- package/components/Button.module.css +88 -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 +8 -0
- package/components/Card.js +29 -0
- package/components/Card.module.css +47 -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 +13 -0
- package/components/Combobox.js +338 -0
- package/components/Combobox.module.css +24 -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 +86 -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 +14 -0
- package/components/Dialog.js +125 -0
- package/components/Dialog.module.css +88 -0
- package/components/DialogVariants.d.ts +27 -0
- package/components/DialogVariants.js +161 -0
- package/components/DialogVariants.module.css +29 -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 +181 -0
- package/components/IconButton.d.ts +7 -0
- package/components/IconButton.js +30 -0
- package/components/IconButton.module.css +42 -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 +8 -0
- package/components/Input.js +37 -0
- package/components/Input.module.css +40 -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 +7 -0
- package/components/LoadingState.js +40 -0
- package/components/LoadingState.module.css +17 -0
- package/components/Menu.d.ts +11 -0
- package/components/Menu.js +82 -0
- package/components/MenuItem.d.ts +15 -0
- package/components/MenuItem.js +51 -0
- package/components/MenuItem.module.css +172 -0
- package/components/MenuItemContent.d.ts +8 -0
- package/components/MenuItemContent.js +19 -0
- package/components/MultiSelect.d.ts +13 -0
- package/components/MultiSelect.js +225 -0
- package/components/MultiSelect.module.css +99 -0
- package/components/NumberInput.d.ts +12 -0
- package/components/NumberInput.js +114 -0
- package/components/NumberInput.module.css +33 -0
- package/components/OptionList.module.css +12 -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 +102 -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 +173 -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 +16 -0
- package/components/Popover.js +156 -0
- package/components/Popover.module.css +19 -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 +67 -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 +172 -0
- package/components/Select.module.css +24 -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/SelectionTag.d.ts +8 -0
- package/components/SelectionTag.js +39 -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 +11 -0
- package/components/SettingsLayout.js +61 -0
- package/components/SettingsLayout.module.css +68 -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 +59 -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 +16 -0
- package/components/Table.js +30 -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 +142 -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 +94 -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/TreeGuides.d.ts +9 -0
- package/components/TreeGuides.js +39 -0
- package/components/TreeGuides.module.css +45 -0
- package/components/TreeSelect.d.ts +26 -0
- package/components/TreeSelect.js +337 -0
- package/components/TreeTable.d.ts +15 -0
- package/components/TreeTable.js +151 -0
- package/components/TreeTable.module.css +53 -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 +93 -0
- package/components/appearance.d.ts +20 -0
- package/components/appearance.js +69 -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 +23 -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 +152 -0
- package/components/index.js +225 -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 +810 -3
- package/styles/base.css +206 -0
- package/styles/blue.css +268 -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,168 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useId, useState } from "react";
|
|
3
|
+
import { CalendarDays, ArrowRight } from "lucide-react";
|
|
4
|
+
import { Calendar } from "./Calendar.js";
|
|
5
|
+
import { Popover } from "./Popover.js";
|
|
6
|
+
import { usePopover } from "./usePopover.js";
|
|
7
|
+
import { Button } from "./Button.js";
|
|
8
|
+
import { fieldTriggerProps, useFieldControl } from "./field.js";
|
|
9
|
+
import {
|
|
10
|
+
boundedDate,
|
|
11
|
+
isRangeAllowed
|
|
12
|
+
} from "./dateConstraints.js";
|
|
13
|
+
import s from "./DatePicker.module.css";
|
|
14
|
+
function DateRangePicker({
|
|
15
|
+
value,
|
|
16
|
+
onChange,
|
|
17
|
+
label,
|
|
18
|
+
clearable = true,
|
|
19
|
+
minDate,
|
|
20
|
+
maxDate,
|
|
21
|
+
disabledDate,
|
|
22
|
+
...options
|
|
23
|
+
}) {
|
|
24
|
+
const field = useFieldControl({ ...options, label }), pop = usePopover(field.disabled || field.readOnly), id = useId(), [draft, setDraft] = useState([...value]), [preview, setPreview] = useState(""), [error, setError] = useState("");
|
|
25
|
+
const constraints = { minDate, maxDate, disabledDate }, complete = !!draft[0] && !!draft[1] && isRangeAllowed(draft, constraints);
|
|
26
|
+
const close = pop.closeAndFocus;
|
|
27
|
+
const show = () => {
|
|
28
|
+
if (field.disabled || field.readOnly) return;
|
|
29
|
+
if (pop.open) {
|
|
30
|
+
pop.close();
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
setDraft([...value]);
|
|
34
|
+
setPreview("");
|
|
35
|
+
setError("");
|
|
36
|
+
pop.show();
|
|
37
|
+
};
|
|
38
|
+
const select = (next) => {
|
|
39
|
+
setError("");
|
|
40
|
+
setPreview("");
|
|
41
|
+
if (!draft[0] || draft[1]) {
|
|
42
|
+
setDraft([next, ""]);
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const range = next < draft[0] ? [next, draft[0]] : [draft[0], next];
|
|
46
|
+
if (!isRangeAllowed(range, constraints)) {
|
|
47
|
+
setError("\u8303\u56F4\u5305\u542B\u4E0D\u53EF\u9009\u65E5\u671F\uFF0C\u8BF7\u91CD\u65B0\u9009\u62E9\u3002");
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
setDraft(range);
|
|
51
|
+
};
|
|
52
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
53
|
+
/* @__PURE__ */ jsxs(
|
|
54
|
+
"button",
|
|
55
|
+
{
|
|
56
|
+
...fieldTriggerProps(field),
|
|
57
|
+
ref: pop.anchor,
|
|
58
|
+
type: "button",
|
|
59
|
+
role: "combobox",
|
|
60
|
+
className: s.trigger,
|
|
61
|
+
"aria-expanded": pop.open,
|
|
62
|
+
"aria-haspopup": "dialog",
|
|
63
|
+
"aria-controls": id,
|
|
64
|
+
onClick: show,
|
|
65
|
+
onKeyDown: (event) => {
|
|
66
|
+
if (event.key === "ArrowDown" && !pop.open) {
|
|
67
|
+
event.preventDefault();
|
|
68
|
+
show();
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
children: [
|
|
72
|
+
/* @__PURE__ */ jsx("span", { children: value[0] || value[1] ? `${value[0] || "\u5F00\u59CB\u65E5\u671F"} \u2014 ${value[1] || "\u7ED3\u675F\u65E5\u671F"}` : "\u8BF7\u9009\u62E9\u65E5\u671F\u8303\u56F4" }),
|
|
73
|
+
/* @__PURE__ */ jsx(CalendarDays, {})
|
|
74
|
+
]
|
|
75
|
+
}
|
|
76
|
+
),
|
|
77
|
+
field.name && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
78
|
+
/* @__PURE__ */ jsx(
|
|
79
|
+
"input",
|
|
80
|
+
{
|
|
81
|
+
type: "hidden",
|
|
82
|
+
name: `${field.name}.start`,
|
|
83
|
+
value: value[0],
|
|
84
|
+
disabled: field.disabled
|
|
85
|
+
}
|
|
86
|
+
),
|
|
87
|
+
/* @__PURE__ */ jsx(
|
|
88
|
+
"input",
|
|
89
|
+
{
|
|
90
|
+
type: "hidden",
|
|
91
|
+
name: `${field.name}.end`,
|
|
92
|
+
value: value[1],
|
|
93
|
+
disabled: field.disabled
|
|
94
|
+
}
|
|
95
|
+
)
|
|
96
|
+
] }),
|
|
97
|
+
/* @__PURE__ */ jsxs(
|
|
98
|
+
Popover,
|
|
99
|
+
{
|
|
100
|
+
anchor: pop.anchor,
|
|
101
|
+
open: pop.open,
|
|
102
|
+
onClose: pop.close,
|
|
103
|
+
label,
|
|
104
|
+
id,
|
|
105
|
+
width: 320,
|
|
106
|
+
children: [
|
|
107
|
+
/* @__PURE__ */ jsxs("div", { className: s.rangeSummary, children: [
|
|
108
|
+
/* @__PURE__ */ jsx("span", { children: draft[0] || "\u5F00\u59CB\u65E5\u671F" }),
|
|
109
|
+
/* @__PURE__ */ jsx(ArrowRight, {}),
|
|
110
|
+
/* @__PURE__ */ jsx("span", { children: draft[1] || "\u7ED3\u675F\u65E5\u671F" })
|
|
111
|
+
] }),
|
|
112
|
+
/* @__PURE__ */ jsx(
|
|
113
|
+
Calendar,
|
|
114
|
+
{
|
|
115
|
+
...constraints,
|
|
116
|
+
value: draft[1] || draft[0] || boundedDate("", constraints),
|
|
117
|
+
range: draft,
|
|
118
|
+
preview,
|
|
119
|
+
onChange: select,
|
|
120
|
+
onHover: (next) => {
|
|
121
|
+
if (!draft[0] || draft[1]) return;
|
|
122
|
+
const range = next < draft[0] ? [next, draft[0]] : [draft[0], next];
|
|
123
|
+
setPreview(next && isRangeAllowed(range, constraints) ? next : "");
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
pop.open ? "open" : "closed"
|
|
127
|
+
),
|
|
128
|
+
/* @__PURE__ */ jsx("div", { className: s.rangeError, role: error ? "alert" : void 0, children: error }),
|
|
129
|
+
/* @__PURE__ */ jsxs("footer", { className: s.footer, children: [
|
|
130
|
+
clearable ? /* @__PURE__ */ jsx(
|
|
131
|
+
"button",
|
|
132
|
+
{
|
|
133
|
+
type: "button",
|
|
134
|
+
disabled: !draft[0] && !draft[1],
|
|
135
|
+
onClick: () => {
|
|
136
|
+
onChange(["", ""]);
|
|
137
|
+
close();
|
|
138
|
+
},
|
|
139
|
+
children: "\u6E05\u7A7A"
|
|
140
|
+
}
|
|
141
|
+
) : /* @__PURE__ */ jsx("span", {}),
|
|
142
|
+
/* @__PURE__ */ jsxs("div", { className: s.rangeActions, children: [
|
|
143
|
+
/* @__PURE__ */ jsx(Button, { size: "small", variant: "ghost", onClick: close, children: "\u53D6\u6D88" }),
|
|
144
|
+
/* @__PURE__ */ jsx(
|
|
145
|
+
Button,
|
|
146
|
+
{
|
|
147
|
+
size: "small",
|
|
148
|
+
variant: "primary",
|
|
149
|
+
disabled: !complete,
|
|
150
|
+
onClick: () => {
|
|
151
|
+
if (complete) {
|
|
152
|
+
onChange([...draft]);
|
|
153
|
+
close();
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
children: "\u786E\u5B9A\u8303\u56F4"
|
|
157
|
+
}
|
|
158
|
+
)
|
|
159
|
+
] })
|
|
160
|
+
] })
|
|
161
|
+
]
|
|
162
|
+
}
|
|
163
|
+
)
|
|
164
|
+
] });
|
|
165
|
+
}
|
|
166
|
+
export {
|
|
167
|
+
DateRangePicker
|
|
168
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
export type DescriptionItem = {
|
|
3
|
+
key: string;
|
|
4
|
+
label: ReactNode;
|
|
5
|
+
children?: ReactNode;
|
|
6
|
+
span?: number;
|
|
7
|
+
copyable?: boolean | string;
|
|
8
|
+
selectable?: boolean;
|
|
9
|
+
};
|
|
10
|
+
export type DescriptionsProps = {
|
|
11
|
+
items: DescriptionItem[];
|
|
12
|
+
label?: string;
|
|
13
|
+
title?: ReactNode;
|
|
14
|
+
columns?: 1 | 2 | 3 | 4;
|
|
15
|
+
layout?: "horizontal" | "vertical";
|
|
16
|
+
bordered?: boolean;
|
|
17
|
+
size?: "default" | "small";
|
|
18
|
+
loading?: boolean;
|
|
19
|
+
emptyText?: ReactNode;
|
|
20
|
+
};
|
|
21
|
+
export declare function Descriptions({ items, label, title, columns, layout, bordered, size, loading, emptyText, }: DescriptionsProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import {
|
|
3
|
+
Fragment,
|
|
4
|
+
useEffect,
|
|
5
|
+
useRef,
|
|
6
|
+
useState
|
|
7
|
+
} from "react";
|
|
8
|
+
import { Check, Copy } from "lucide-react";
|
|
9
|
+
import { IconButton } from "./IconButton.js";
|
|
10
|
+
import { Skeleton } from "./Skeleton.js";
|
|
11
|
+
import s from "./Descriptions.module.css";
|
|
12
|
+
function Descriptions({
|
|
13
|
+
items,
|
|
14
|
+
label = "\u8BE6\u60C5",
|
|
15
|
+
title,
|
|
16
|
+
columns = 2,
|
|
17
|
+
layout = "horizontal",
|
|
18
|
+
bordered = false,
|
|
19
|
+
size = "default",
|
|
20
|
+
loading = false,
|
|
21
|
+
emptyText = "\u2014"
|
|
22
|
+
}) {
|
|
23
|
+
const [copied, setCopied] = useState(""), [error, setError] = useState(""), timer = useRef(null), alive = useRef(true), request = useRef(0);
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
alive.current = true;
|
|
26
|
+
return () => {
|
|
27
|
+
alive.current = false;
|
|
28
|
+
request.current++;
|
|
29
|
+
if (timer.current) clearTimeout(timer.current);
|
|
30
|
+
};
|
|
31
|
+
}, []);
|
|
32
|
+
const copy = async (key, text) => {
|
|
33
|
+
const revision = ++request.current;
|
|
34
|
+
setCopied("");
|
|
35
|
+
setError("");
|
|
36
|
+
if (timer.current) clearTimeout(timer.current);
|
|
37
|
+
try {
|
|
38
|
+
await navigator.clipboard.writeText(text);
|
|
39
|
+
if (!alive.current || revision !== request.current) return;
|
|
40
|
+
setError("");
|
|
41
|
+
setCopied(key);
|
|
42
|
+
if (timer.current) clearTimeout(timer.current);
|
|
43
|
+
timer.current = setTimeout(() => setCopied(""), 1800);
|
|
44
|
+
} catch {
|
|
45
|
+
if (alive.current && revision === request.current) setError(key);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
const columnCount = Math.min(4, Math.max(1, Math.trunc(columns) || 1));
|
|
49
|
+
const spanOf = (item) => Math.min(columnCount, Math.max(1, Math.floor(item.span || 1)));
|
|
50
|
+
let occupied = 0;
|
|
51
|
+
const gaps = items.map((item) => {
|
|
52
|
+
const span = spanOf(item);
|
|
53
|
+
const gap = span > columnCount - occupied ? columnCount - occupied : 0;
|
|
54
|
+
occupied = (gap ? span : occupied + span) % columnCount;
|
|
55
|
+
return gap;
|
|
56
|
+
});
|
|
57
|
+
return /* @__PURE__ */ jsxs("section", { "aria-label": label, className: s.root, children: [
|
|
58
|
+
title && /* @__PURE__ */ jsx("div", { className: s.title, children: title }),
|
|
59
|
+
/* @__PURE__ */ jsxs(
|
|
60
|
+
"dl",
|
|
61
|
+
{
|
|
62
|
+
className: s.list,
|
|
63
|
+
"data-bordered": bordered,
|
|
64
|
+
"data-layout": layout,
|
|
65
|
+
"data-size": size,
|
|
66
|
+
"aria-busy": loading || void 0,
|
|
67
|
+
style: { "--description-columns": columnCount },
|
|
68
|
+
children: [
|
|
69
|
+
items.map((item, index) => {
|
|
70
|
+
const text = typeof item.copyable === "string" ? item.copyable : item.copyable && (typeof item.children === "string" || typeof item.children === "number") ? String(item.children) : void 0;
|
|
71
|
+
const span = spanOf(item);
|
|
72
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
73
|
+
bordered && gaps[index] > 0 && /* @__PURE__ */ jsx(
|
|
74
|
+
"div",
|
|
75
|
+
{
|
|
76
|
+
"aria-hidden": "true",
|
|
77
|
+
className: s.filler,
|
|
78
|
+
style: { gridColumn: `span ${gaps[index]}` }
|
|
79
|
+
}
|
|
80
|
+
),
|
|
81
|
+
/* @__PURE__ */ jsxs(
|
|
82
|
+
"div",
|
|
83
|
+
{
|
|
84
|
+
className: s.item,
|
|
85
|
+
style: { gridColumn: `span ${span}` },
|
|
86
|
+
children: [
|
|
87
|
+
/* @__PURE__ */ jsx("dt", { children: item.label }),
|
|
88
|
+
/* @__PURE__ */ jsxs("dd", { children: [
|
|
89
|
+
/* @__PURE__ */ jsxs(
|
|
90
|
+
"div",
|
|
91
|
+
{
|
|
92
|
+
className: s.value,
|
|
93
|
+
"data-selectable": item.selectable || void 0,
|
|
94
|
+
children: [
|
|
95
|
+
/* @__PURE__ */ jsx(
|
|
96
|
+
"div",
|
|
97
|
+
{
|
|
98
|
+
"data-loading": loading,
|
|
99
|
+
"aria-hidden": loading || void 0,
|
|
100
|
+
inert: loading,
|
|
101
|
+
className: s.valueContent,
|
|
102
|
+
children: item.children == null || item.children === "" ? emptyText : typeof item.children === "boolean" ? item.children ? "\u662F" : "\u5426" : item.children
|
|
103
|
+
}
|
|
104
|
+
),
|
|
105
|
+
loading && /* @__PURE__ */ jsx("span", { className: s.loading, children: /* @__PURE__ */ jsx(Skeleton, { width: "75%", height: 14 }) })
|
|
106
|
+
]
|
|
107
|
+
}
|
|
108
|
+
),
|
|
109
|
+
text !== void 0 && /* @__PURE__ */ jsx(
|
|
110
|
+
"span",
|
|
111
|
+
{
|
|
112
|
+
"data-loading": loading,
|
|
113
|
+
"aria-hidden": loading || void 0,
|
|
114
|
+
inert: loading,
|
|
115
|
+
className: s.copyTool,
|
|
116
|
+
children: /* @__PURE__ */ jsx(
|
|
117
|
+
IconButton,
|
|
118
|
+
{
|
|
119
|
+
className: s.copyButton,
|
|
120
|
+
disabled: loading,
|
|
121
|
+
label: `${copied === item.key ? "\u5DF2\u590D\u5236" : "\u590D\u5236"} ${typeof item.label === "string" ? item.label : item.key}`,
|
|
122
|
+
onClick: () => void copy(item.key, text),
|
|
123
|
+
children: copied === item.key ? /* @__PURE__ */ jsx(Check, {}) : /* @__PURE__ */ jsx(Copy, {})
|
|
124
|
+
}
|
|
125
|
+
)
|
|
126
|
+
}
|
|
127
|
+
),
|
|
128
|
+
error === item.key && /* @__PURE__ */ jsx(
|
|
129
|
+
"span",
|
|
130
|
+
{
|
|
131
|
+
role: "alert",
|
|
132
|
+
"aria-hidden": loading || void 0,
|
|
133
|
+
"data-loading": loading,
|
|
134
|
+
className: s.error,
|
|
135
|
+
children: "\u590D\u5236\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5\u3002"
|
|
136
|
+
}
|
|
137
|
+
)
|
|
138
|
+
] })
|
|
139
|
+
]
|
|
140
|
+
},
|
|
141
|
+
item.key
|
|
142
|
+
)
|
|
143
|
+
] }, item.key);
|
|
144
|
+
}),
|
|
145
|
+
bordered && occupied > 0 && /* @__PURE__ */ jsx(
|
|
146
|
+
"div",
|
|
147
|
+
{
|
|
148
|
+
"aria-hidden": "true",
|
|
149
|
+
className: s.filler,
|
|
150
|
+
style: { gridColumn: `span ${columnCount - occupied}` }
|
|
151
|
+
}
|
|
152
|
+
)
|
|
153
|
+
]
|
|
154
|
+
}
|
|
155
|
+
),
|
|
156
|
+
!items.length && /* @__PURE__ */ jsx("div", { className: s.empty, children: emptyText }),
|
|
157
|
+
/* @__PURE__ */ jsx("span", { className: s.sr, role: "status", children: loading ? "\u6B63\u5728\u52A0\u8F7D\u8BE6\u60C5" : copied ? "\u5DF2\u590D\u5236" : "" })
|
|
158
|
+
] });
|
|
159
|
+
}
|
|
160
|
+
export {
|
|
161
|
+
Descriptions
|
|
162
|
+
};
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
.root {
|
|
2
|
+
min-width: 0;
|
|
3
|
+
container-type: inline-size;
|
|
4
|
+
}
|
|
5
|
+
.title {
|
|
6
|
+
margin-bottom: 16px;
|
|
7
|
+
font-size: 14px;
|
|
8
|
+
font-weight: 600;
|
|
9
|
+
}
|
|
10
|
+
.list {
|
|
11
|
+
display: grid;
|
|
12
|
+
grid-template-columns: repeat(var(--description-columns), minmax(0, 1fr));
|
|
13
|
+
gap: 18px 24px;
|
|
14
|
+
margin: 0;
|
|
15
|
+
}
|
|
16
|
+
.item {
|
|
17
|
+
display: grid;
|
|
18
|
+
grid-template-columns: minmax(70px, 100px) minmax(0, 1fr);
|
|
19
|
+
gap: 12px;
|
|
20
|
+
min-width: 0;
|
|
21
|
+
font-size: 12px;
|
|
22
|
+
line-height: 22px;
|
|
23
|
+
}
|
|
24
|
+
.item dt {
|
|
25
|
+
min-height: 24px;
|
|
26
|
+
color: var(--muted);
|
|
27
|
+
overflow-wrap: anywhere;
|
|
28
|
+
}
|
|
29
|
+
.item dd {
|
|
30
|
+
min-height: 24px;
|
|
31
|
+
display: flex;
|
|
32
|
+
flex-wrap: wrap;
|
|
33
|
+
align-items: flex-start;
|
|
34
|
+
gap: 6px;
|
|
35
|
+
min-width: 0;
|
|
36
|
+
margin: 0;
|
|
37
|
+
}
|
|
38
|
+
.value {
|
|
39
|
+
position: relative;
|
|
40
|
+
flex: 1;
|
|
41
|
+
min-width: 0;
|
|
42
|
+
overflow-wrap: anywhere;
|
|
43
|
+
}
|
|
44
|
+
.item .copyButton {
|
|
45
|
+
width: 24px;
|
|
46
|
+
height: 24px;
|
|
47
|
+
flex: 0 0 24px;
|
|
48
|
+
}
|
|
49
|
+
.item .copyButton svg {
|
|
50
|
+
width: 13px;
|
|
51
|
+
height: 13px;
|
|
52
|
+
}
|
|
53
|
+
.list[data-layout="vertical"] .item {
|
|
54
|
+
grid-template-columns: minmax(0, 1fr);
|
|
55
|
+
gap: 4px;
|
|
56
|
+
}
|
|
57
|
+
.list[data-bordered="true"] {
|
|
58
|
+
border: 1px solid var(--line);
|
|
59
|
+
border-radius: var(--radius);
|
|
60
|
+
overflow: hidden;
|
|
61
|
+
gap: var(--separator-width);
|
|
62
|
+
background: var(--separator-color);
|
|
63
|
+
}
|
|
64
|
+
.list[data-bordered="true"] .item {
|
|
65
|
+
padding: 16px;
|
|
66
|
+
background: var(--surface);
|
|
67
|
+
}
|
|
68
|
+
.list[data-bordered="true"][data-size="small"] .item {
|
|
69
|
+
padding: 10px 12px;
|
|
70
|
+
}
|
|
71
|
+
.list[data-size="small"] {
|
|
72
|
+
gap: 12px 16px;
|
|
73
|
+
}
|
|
74
|
+
.list[data-bordered="true"][data-size="small"] {
|
|
75
|
+
gap: var(--separator-width);
|
|
76
|
+
}
|
|
77
|
+
.error {
|
|
78
|
+
color: var(--danger);
|
|
79
|
+
font-size: 11px;
|
|
80
|
+
flex-basis: 100%;
|
|
81
|
+
}
|
|
82
|
+
.valueContent[data-loading="true"],
|
|
83
|
+
.copyTool[data-loading="true"],
|
|
84
|
+
.error[data-loading="true"] {
|
|
85
|
+
visibility: hidden;
|
|
86
|
+
}
|
|
87
|
+
.copyTool {
|
|
88
|
+
display: inline-flex;
|
|
89
|
+
}
|
|
90
|
+
.loading {
|
|
91
|
+
position: absolute;
|
|
92
|
+
inset: 0;
|
|
93
|
+
display: flex;
|
|
94
|
+
align-items: center;
|
|
95
|
+
}
|
|
96
|
+
.filler {
|
|
97
|
+
background: var(--surface);
|
|
98
|
+
}
|
|
99
|
+
.empty {
|
|
100
|
+
padding: 20px;
|
|
101
|
+
color: var(--muted);
|
|
102
|
+
font-size: 12px;
|
|
103
|
+
}
|
|
104
|
+
.sr {
|
|
105
|
+
composes: visuallyHidden from "./Accessibility.module.css";
|
|
106
|
+
}
|
|
107
|
+
@container (max-width: 640px) {
|
|
108
|
+
.list {
|
|
109
|
+
grid-template-columns: minmax(0, 1fr);
|
|
110
|
+
}
|
|
111
|
+
.item {
|
|
112
|
+
grid-column: span 1 !important;
|
|
113
|
+
}
|
|
114
|
+
.filler {
|
|
115
|
+
display: none;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
export declare function Dialog({ open: requestedOpen, onClose, title, children, footer, wide, size, role, descriptionId, busy, variant, }: {
|
|
3
|
+
open: boolean;
|
|
4
|
+
onClose(): void;
|
|
5
|
+
title: string;
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
footer?: ReactNode;
|
|
8
|
+
wide?: boolean;
|
|
9
|
+
size?: "small" | "medium" | "large";
|
|
10
|
+
role?: "dialog" | "alertdialog";
|
|
11
|
+
descriptionId?: string;
|
|
12
|
+
busy?: boolean;
|
|
13
|
+
variant?: "default" | "message" | "confirm" | "form";
|
|
14
|
+
}): import("react").ReactPortal;
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import {
|
|
3
|
+
useId,
|
|
4
|
+
useEffect,
|
|
5
|
+
useLayoutEffect,
|
|
6
|
+
useRef,
|
|
7
|
+
useState
|
|
8
|
+
} from "react";
|
|
9
|
+
import { createPortal } from "react-dom";
|
|
10
|
+
import { X } from "lucide-react";
|
|
11
|
+
import { IconButton } from "./IconButton.js";
|
|
12
|
+
import { surfaceMotion, cancelMotion } from "./motion.js";
|
|
13
|
+
import s from "./Dialog.module.css";
|
|
14
|
+
import { FieldContext } from "./field.js";
|
|
15
|
+
import { useModalScrollLock } from "./useModalScrollLock.js";
|
|
16
|
+
import {
|
|
17
|
+
SurfacePortalContext,
|
|
18
|
+
useSurfaceHost,
|
|
19
|
+
useSurfacePortal
|
|
20
|
+
} from "./surfacePortal.js";
|
|
21
|
+
function Dialog({
|
|
22
|
+
open: requestedOpen,
|
|
23
|
+
onClose,
|
|
24
|
+
title,
|
|
25
|
+
children,
|
|
26
|
+
footer,
|
|
27
|
+
wide = false,
|
|
28
|
+
size = "medium",
|
|
29
|
+
role = "dialog",
|
|
30
|
+
descriptionId,
|
|
31
|
+
busy = false,
|
|
32
|
+
variant = "default"
|
|
33
|
+
}) {
|
|
34
|
+
const owner = useSurfacePortal(), open = requestedOpen && owner?.active !== false;
|
|
35
|
+
const { ref, host, setRef } = useSurfaceHost();
|
|
36
|
+
const titleId = useId();
|
|
37
|
+
const previousFocus = useRef(null);
|
|
38
|
+
const [closing, setClosing] = useState(false);
|
|
39
|
+
useModalScrollLock(open || closing);
|
|
40
|
+
const opened = useRef(open);
|
|
41
|
+
opened.current = open;
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
if (requestedOpen && owner?.active === false) onClose();
|
|
44
|
+
}, [requestedOpen, owner?.active, onClose]);
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
const node = ref.current;
|
|
47
|
+
return () => cancelMotion(node);
|
|
48
|
+
}, []);
|
|
49
|
+
useLayoutEffect(() => {
|
|
50
|
+
const element = ref.current;
|
|
51
|
+
if (open) {
|
|
52
|
+
element.inert = false;
|
|
53
|
+
setClosing(false);
|
|
54
|
+
if (!element.open) {
|
|
55
|
+
previousFocus.current = document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
|
56
|
+
element.showModal();
|
|
57
|
+
element.querySelector(
|
|
58
|
+
"[data-dialog-initial-focus]:not(:disabled)"
|
|
59
|
+
)?.focus({ preventScroll: true });
|
|
60
|
+
if (!element.querySelector("[data-dialog-initial-focus]:not(:disabled)"))
|
|
61
|
+
element.querySelector(
|
|
62
|
+
'input:not([disabled]):not([readonly]):not([type="hidden"]):not([type="file"]):not([type="checkbox"]):not([type="radio"]),textarea:not([disabled]),[role="combobox"]'
|
|
63
|
+
)?.focus({ preventScroll: true });
|
|
64
|
+
}
|
|
65
|
+
void surfaceMotion(element, "enter", "0 4px");
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
if (!element.open) return;
|
|
69
|
+
setClosing(true);
|
|
70
|
+
element.inert = true;
|
|
71
|
+
void surfaceMotion(element, "exit", "0 4px").then((done) => {
|
|
72
|
+
if (!done || opened.current) return;
|
|
73
|
+
element.close();
|
|
74
|
+
const modal = [
|
|
75
|
+
...document.querySelectorAll("dialog:modal")
|
|
76
|
+
].at(-1);
|
|
77
|
+
if (previousFocus.current?.isConnected && (!modal || modal.contains(previousFocus.current)))
|
|
78
|
+
previousFocus.current.focus({ preventScroll: true });
|
|
79
|
+
setClosing(false);
|
|
80
|
+
});
|
|
81
|
+
}, [open]);
|
|
82
|
+
const backdropDown = useRef(false);
|
|
83
|
+
const outside = (event) => {
|
|
84
|
+
const rect = event.currentTarget.getBoundingClientRect();
|
|
85
|
+
return event.target === event.currentTarget && (event.clientX < rect.left || event.clientX > rect.right || event.clientY < rect.top || event.clientY > rect.bottom);
|
|
86
|
+
};
|
|
87
|
+
return createPortal(
|
|
88
|
+
/* @__PURE__ */ jsx(SurfacePortalContext, { value: { host, active: open }, children: /* @__PURE__ */ jsx(FieldContext, { value: null, children: /* @__PURE__ */ jsxs(
|
|
89
|
+
"dialog",
|
|
90
|
+
{
|
|
91
|
+
ref: setRef,
|
|
92
|
+
"aria-labelledby": titleId,
|
|
93
|
+
"aria-describedby": descriptionId,
|
|
94
|
+
"aria-busy": busy || void 0,
|
|
95
|
+
role,
|
|
96
|
+
"data-variant": variant,
|
|
97
|
+
className: `${s.dialog} ${wide || size === "large" ? s.wide : ""} ${size === "small" ? s.small : ""} ${closing ? s.closing : ""}`,
|
|
98
|
+
onCancel: (e) => {
|
|
99
|
+
e.preventDefault();
|
|
100
|
+
e.stopPropagation();
|
|
101
|
+
if (!busy) onClose();
|
|
102
|
+
},
|
|
103
|
+
onMouseDown: (e) => {
|
|
104
|
+
backdropDown.current = outside(e);
|
|
105
|
+
},
|
|
106
|
+
onClick: (e) => {
|
|
107
|
+
if (!busy && backdropDown.current && outside(e)) onClose();
|
|
108
|
+
backdropDown.current = false;
|
|
109
|
+
},
|
|
110
|
+
children: [
|
|
111
|
+
/* @__PURE__ */ jsxs("header", { className: s.dialogHeader, children: [
|
|
112
|
+
/* @__PURE__ */ jsx("h2", { id: titleId, children: title }),
|
|
113
|
+
/* @__PURE__ */ jsx(IconButton, { label: "\u5173\u95ED\u5F39\u7A97", onClick: onClose, disabled: busy, children: /* @__PURE__ */ jsx(X, {}) })
|
|
114
|
+
] }),
|
|
115
|
+
/* @__PURE__ */ jsx("div", { className: s.dialogBody, children }),
|
|
116
|
+
footer && /* @__PURE__ */ jsx("footer", { className: s.dialogFooter, children: footer })
|
|
117
|
+
]
|
|
118
|
+
}
|
|
119
|
+
) }) }),
|
|
120
|
+
document.body
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
export {
|
|
124
|
+
Dialog
|
|
125
|
+
};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
.dialog {
|
|
2
|
+
width: min(var(--dialog-width), calc(100vw - 32px));
|
|
3
|
+
max-height: calc(100dvh - var(--dialog-inset));
|
|
4
|
+
padding: 0;
|
|
5
|
+
color: var(--fg);
|
|
6
|
+
background: var(--surface);
|
|
7
|
+
border: 1px solid var(--line);
|
|
8
|
+
border-radius: calc(var(--radius) + 3px);
|
|
9
|
+
box-shadow: var(--shadow-dialog);
|
|
10
|
+
overflow: auto;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.dialog::backdrop {
|
|
14
|
+
background: var(--overlay);
|
|
15
|
+
backdrop-filter: blur(3px);
|
|
16
|
+
animation: fade-in var(--popup-enter);
|
|
17
|
+
}
|
|
18
|
+
.dialogHeader {
|
|
19
|
+
border-bottom: var(--dialog-header-border);
|
|
20
|
+
display: flex;
|
|
21
|
+
align-items: center;
|
|
22
|
+
justify-content: space-between;
|
|
23
|
+
padding: var(--dialog-header-padding);
|
|
24
|
+
}
|
|
25
|
+
.dialogBody {
|
|
26
|
+
padding: var(--dialog-body-padding);
|
|
27
|
+
}
|
|
28
|
+
.dialogBody > p {
|
|
29
|
+
color: var(--muted);
|
|
30
|
+
font-size: 12px;
|
|
31
|
+
line-height: 1.8;
|
|
32
|
+
}
|
|
33
|
+
.dialogFooter {
|
|
34
|
+
flex-wrap: wrap;
|
|
35
|
+
display: flex;
|
|
36
|
+
justify-content: flex-end;
|
|
37
|
+
gap: 8px;
|
|
38
|
+
padding: 14px 22px;
|
|
39
|
+
border-top: var(--separator-width) var(--separator-style)
|
|
40
|
+
var(--separator-color);
|
|
41
|
+
background: var(--canvas);
|
|
42
|
+
}
|
|
43
|
+
.wide {
|
|
44
|
+
width: min(var(--dialog-wide-width), calc(100vw - 32px));
|
|
45
|
+
}
|
|
46
|
+
.small {
|
|
47
|
+
width: min(420px, calc(100vw - 32px));
|
|
48
|
+
}
|
|
49
|
+
.dialog[data-variant="message"] .dialogHeader {
|
|
50
|
+
border: 0;
|
|
51
|
+
padding-bottom: 12px;
|
|
52
|
+
}
|
|
53
|
+
.dialog[data-variant="message"] .dialogBody {
|
|
54
|
+
padding-top: 0;
|
|
55
|
+
padding-bottom: 24px;
|
|
56
|
+
}
|
|
57
|
+
.dialog[data-variant="message"] .dialogFooter {
|
|
58
|
+
border: 0;
|
|
59
|
+
background: transparent;
|
|
60
|
+
padding-top: 0;
|
|
61
|
+
padding-bottom: 18px;
|
|
62
|
+
}
|
|
63
|
+
.closing {
|
|
64
|
+
pointer-events: none;
|
|
65
|
+
}
|
|
66
|
+
.dialog.closing::backdrop {
|
|
67
|
+
background: transparent;
|
|
68
|
+
backdrop-filter: blur(0);
|
|
69
|
+
transition:
|
|
70
|
+
background var(--popup-exit),
|
|
71
|
+
backdrop-filter var(--popup-exit);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.dialogHeader h2 {
|
|
75
|
+
font-size: var(--dialog-title-size);
|
|
76
|
+
}
|
|
77
|
+
@media (max-width: 600px) {
|
|
78
|
+
.dialog {
|
|
79
|
+
max-height: calc(100dvh - 24px);
|
|
80
|
+
}
|
|
81
|
+
.dialogBody {
|
|
82
|
+
padding: 18px;
|
|
83
|
+
}
|
|
84
|
+
.dialogHeader,
|
|
85
|
+
.dialogFooter {
|
|
86
|
+
padding: 14px 18px;
|
|
87
|
+
}
|
|
88
|
+
}
|