@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,181 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import {
|
|
3
|
+
useEffect,
|
|
4
|
+
useLayoutEffect,
|
|
5
|
+
useRef,
|
|
6
|
+
useState
|
|
7
|
+
} from "react";
|
|
8
|
+
import { createPortal } from "react-dom";
|
|
9
|
+
import {
|
|
10
|
+
X,
|
|
11
|
+
CheckCircle2,
|
|
12
|
+
Info,
|
|
13
|
+
TriangleAlert,
|
|
14
|
+
CircleX,
|
|
15
|
+
LoaderCircle
|
|
16
|
+
} from "lucide-react";
|
|
17
|
+
import { surfaceMotion, cancelMotion } from "./motion.js";
|
|
18
|
+
import s from "./Toast.module.css";
|
|
19
|
+
const icons = {
|
|
20
|
+
neutral: Info,
|
|
21
|
+
success: CheckCircle2,
|
|
22
|
+
info: Info,
|
|
23
|
+
warning: TriangleAlert,
|
|
24
|
+
error: CircleX
|
|
25
|
+
};
|
|
26
|
+
function Toast({
|
|
27
|
+
toast,
|
|
28
|
+
position,
|
|
29
|
+
onDismiss
|
|
30
|
+
}) {
|
|
31
|
+
const ref = useRef(null), current = useRef(toast), timer = useRef(void 0), pendingId = useRef(null);
|
|
32
|
+
const [pending, setPending] = useState(false), [error, setError] = useState("");
|
|
33
|
+
current.current = toast;
|
|
34
|
+
const dismiss = () => {
|
|
35
|
+
clearTimeout(timer.current);
|
|
36
|
+
const message = current.current, node = ref.current;
|
|
37
|
+
if (!message) return;
|
|
38
|
+
void surfaceMotion(
|
|
39
|
+
node,
|
|
40
|
+
"exit",
|
|
41
|
+
position.startsWith("top") ? "0 -4px" : "0 4px"
|
|
42
|
+
).then((done) => {
|
|
43
|
+
if (done && current.current?.id === message.id) {
|
|
44
|
+
if (node.matches(":popover-open")) node.hidePopover();
|
|
45
|
+
onDismiss(message.id);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
const arm = () => {
|
|
50
|
+
clearTimeout(timer.current);
|
|
51
|
+
const message = current.current, node = ref.current;
|
|
52
|
+
if (message && !message.closing && !message.options?.persistent && pendingId.current !== message.id && !node?.matches(":hover") && !node?.contains(document.activeElement))
|
|
53
|
+
timer.current = setTimeout(
|
|
54
|
+
dismiss,
|
|
55
|
+
Math.max(0, message.options?.duration ?? 5e3)
|
|
56
|
+
);
|
|
57
|
+
};
|
|
58
|
+
useLayoutEffect(() => {
|
|
59
|
+
const node = ref.current;
|
|
60
|
+
setPending(false);
|
|
61
|
+
setError("");
|
|
62
|
+
pendingId.current = null;
|
|
63
|
+
if (!toast) {
|
|
64
|
+
if (node.matches(":popover-open")) node.hidePopover();
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
if (toast.closing) {
|
|
68
|
+
dismiss();
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
const already = node.matches(":popover-open");
|
|
72
|
+
if (!already) node.showPopover();
|
|
73
|
+
void surfaceMotion(
|
|
74
|
+
node,
|
|
75
|
+
already ? "update" : "enter",
|
|
76
|
+
position.startsWith("top") ? "0 -4px" : "0 4px"
|
|
77
|
+
);
|
|
78
|
+
arm();
|
|
79
|
+
return () => clearTimeout(timer.current);
|
|
80
|
+
}, [toast, position]);
|
|
81
|
+
useEffect(() => {
|
|
82
|
+
const node = ref.current;
|
|
83
|
+
return () => {
|
|
84
|
+
clearTimeout(timer.current);
|
|
85
|
+
cancelMotion(node);
|
|
86
|
+
};
|
|
87
|
+
}, []);
|
|
88
|
+
const execute = async () => {
|
|
89
|
+
const message = current.current, action2 = message?.options?.action;
|
|
90
|
+
if (!message || !action2 || pendingId.current === message.id) return;
|
|
91
|
+
clearTimeout(timer.current);
|
|
92
|
+
pendingId.current = message.id;
|
|
93
|
+
setPending(true);
|
|
94
|
+
setError("");
|
|
95
|
+
try {
|
|
96
|
+
await action2.onClick();
|
|
97
|
+
if (current.current?.id === message.id && action2.closeOnClick !== false)
|
|
98
|
+
dismiss();
|
|
99
|
+
} catch {
|
|
100
|
+
if (current.current?.id === message.id) setError("\u64CD\u4F5C\u672A\u5B8C\u6210\uFF0C\u8BF7\u91CD\u8BD5");
|
|
101
|
+
} finally {
|
|
102
|
+
if (current.current?.id === message.id) {
|
|
103
|
+
pendingId.current = null;
|
|
104
|
+
setPending(false);
|
|
105
|
+
arm();
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
const options = toast?.options || {}, tone = options.tone || "neutral", Icon = icons[tone], action = options.action;
|
|
110
|
+
const icon = options.icon === false ? null : options.icon === true || options.icon === void 0 ? tone !== "neutral" || options.icon === true ? /* @__PURE__ */ jsx(Icon, {}) : null : options.icon;
|
|
111
|
+
const style = {
|
|
112
|
+
"--toast-icon-color": options.iconColor,
|
|
113
|
+
"--toast-text-color": options.textColor
|
|
114
|
+
};
|
|
115
|
+
return createPortal(
|
|
116
|
+
/* @__PURE__ */ jsxs(
|
|
117
|
+
"div",
|
|
118
|
+
{
|
|
119
|
+
ref,
|
|
120
|
+
popover: "manual",
|
|
121
|
+
className: s.toast,
|
|
122
|
+
"data-position": position,
|
|
123
|
+
"data-tone": tone,
|
|
124
|
+
"data-variant": options.variant || "solid",
|
|
125
|
+
role: "status",
|
|
126
|
+
"aria-live": "polite",
|
|
127
|
+
"aria-atomic": "true",
|
|
128
|
+
style,
|
|
129
|
+
onPointerEnter: () => clearTimeout(timer.current),
|
|
130
|
+
onPointerLeave: arm,
|
|
131
|
+
onFocus: () => clearTimeout(timer.current),
|
|
132
|
+
onBlur: (e) => {
|
|
133
|
+
if (!e.currentTarget.contains(e.relatedTarget)) queueMicrotask(arm);
|
|
134
|
+
},
|
|
135
|
+
onKeyDown: (e) => {
|
|
136
|
+
if (e.key === "Escape") {
|
|
137
|
+
e.stopPropagation();
|
|
138
|
+
dismiss();
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
children: [
|
|
142
|
+
icon && /* @__PURE__ */ jsx("span", { className: s.icon, "aria-hidden": "true", "data-toast-icon": true, children: icon }),
|
|
143
|
+
/* @__PURE__ */ jsxs("div", { className: s.copy, "data-toast-copy": true, children: [
|
|
144
|
+
options.title && /* @__PURE__ */ jsx("strong", { children: options.title }),
|
|
145
|
+
/* @__PURE__ */ jsx("span", { children: toast?.message }),
|
|
146
|
+
error && /* @__PURE__ */ jsx("small", { role: "alert", children: error })
|
|
147
|
+
] }),
|
|
148
|
+
action && /* @__PURE__ */ jsxs(
|
|
149
|
+
"button",
|
|
150
|
+
{
|
|
151
|
+
className: s.action,
|
|
152
|
+
type: "button",
|
|
153
|
+
"aria-label": action.label,
|
|
154
|
+
disabled: pending,
|
|
155
|
+
"data-icon-only": action.display === "icon",
|
|
156
|
+
onClick: () => void execute(),
|
|
157
|
+
children: [
|
|
158
|
+
pending ? /* @__PURE__ */ jsx(LoaderCircle, { className: s.spin }) : action.display !== "text" && action.icon,
|
|
159
|
+
action.display !== "icon" && /* @__PURE__ */ jsx("span", { children: action.label })
|
|
160
|
+
]
|
|
161
|
+
}
|
|
162
|
+
),
|
|
163
|
+
options.closable !== false && /* @__PURE__ */ jsx(
|
|
164
|
+
"button",
|
|
165
|
+
{
|
|
166
|
+
className: s.close,
|
|
167
|
+
type: "button",
|
|
168
|
+
"aria-label": "\u5173\u95ED\u63D0\u793A",
|
|
169
|
+
onClick: dismiss,
|
|
170
|
+
children: /* @__PURE__ */ jsx(X, {})
|
|
171
|
+
}
|
|
172
|
+
)
|
|
173
|
+
]
|
|
174
|
+
}
|
|
175
|
+
),
|
|
176
|
+
document.body
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
export {
|
|
180
|
+
Toast
|
|
181
|
+
};
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
.toast {
|
|
2
|
+
position: fixed;
|
|
3
|
+
inset: auto;
|
|
4
|
+
margin: 0;
|
|
5
|
+
padding: 10px 14px;
|
|
6
|
+
border: 0;
|
|
7
|
+
border-radius: 10px;
|
|
8
|
+
background: #303030;
|
|
9
|
+
color: var(--toast-text-color, #fff);
|
|
10
|
+
box-shadow:
|
|
11
|
+
0 8px 28px #0000001c,
|
|
12
|
+
0 2px 6px #0000000d;
|
|
13
|
+
max-width: min(460px, calc(100vw - 40px));
|
|
14
|
+
max-height: min(160px, calc(100vh - 40px));
|
|
15
|
+
overflow: auto;
|
|
16
|
+
font-size: 13px;
|
|
17
|
+
line-height: 20px;
|
|
18
|
+
scrollbar-width: thin;
|
|
19
|
+
--tone: #c4c4c4;
|
|
20
|
+
--soft-tone: #555;
|
|
21
|
+
}
|
|
22
|
+
.toast:popover-open {
|
|
23
|
+
display: flex;
|
|
24
|
+
align-items: center;
|
|
25
|
+
gap: 11px;
|
|
26
|
+
}
|
|
27
|
+
.copy {
|
|
28
|
+
min-width: 0;
|
|
29
|
+
display: grid;
|
|
30
|
+
gap: 2px;
|
|
31
|
+
white-space: pre-wrap;
|
|
32
|
+
overflow-wrap: anywhere;
|
|
33
|
+
}
|
|
34
|
+
.copy strong {
|
|
35
|
+
font-size: 12px;
|
|
36
|
+
font-weight: 600;
|
|
37
|
+
}
|
|
38
|
+
.copy small {
|
|
39
|
+
color: inherit;
|
|
40
|
+
opacity: 0.8;
|
|
41
|
+
font-size: 11px;
|
|
42
|
+
}
|
|
43
|
+
.icon {
|
|
44
|
+
display: grid;
|
|
45
|
+
place-items: center;
|
|
46
|
+
flex-shrink: 0;
|
|
47
|
+
align-self: center;
|
|
48
|
+
width: 20px;
|
|
49
|
+
height: 20px;
|
|
50
|
+
color: var(--toast-icon-color, var(--tone));
|
|
51
|
+
}
|
|
52
|
+
.icon svg {
|
|
53
|
+
display: block;
|
|
54
|
+
width: 18px;
|
|
55
|
+
height: 18px;
|
|
56
|
+
}
|
|
57
|
+
.toast button {
|
|
58
|
+
display: inline-flex;
|
|
59
|
+
align-items: center;
|
|
60
|
+
justify-content: center;
|
|
61
|
+
gap: 5px;
|
|
62
|
+
flex-shrink: 0;
|
|
63
|
+
border: 0;
|
|
64
|
+
border-radius: 5px;
|
|
65
|
+
color: inherit;
|
|
66
|
+
font-size: 12px;
|
|
67
|
+
line-height: 20px;
|
|
68
|
+
min-height: 26px;
|
|
69
|
+
transition:
|
|
70
|
+
background-color var(--motion-hover),
|
|
71
|
+
opacity var(--motion-hover);
|
|
72
|
+
}
|
|
73
|
+
.action {
|
|
74
|
+
min-height: 26px;
|
|
75
|
+
padding: 3px 8px;
|
|
76
|
+
background: #ffffff18;
|
|
77
|
+
white-space: nowrap;
|
|
78
|
+
}
|
|
79
|
+
.action:hover:not(:disabled) {
|
|
80
|
+
background: #ffffff2a;
|
|
81
|
+
}
|
|
82
|
+
.action[data-icon-only="true"] {
|
|
83
|
+
width: 26px;
|
|
84
|
+
padding: 4px;
|
|
85
|
+
}
|
|
86
|
+
.action svg {
|
|
87
|
+
width: 15px;
|
|
88
|
+
height: 15px;
|
|
89
|
+
}
|
|
90
|
+
.close {
|
|
91
|
+
width: 26px;
|
|
92
|
+
height: 26px;
|
|
93
|
+
padding: 3px;
|
|
94
|
+
background: transparent;
|
|
95
|
+
opacity: 0.65;
|
|
96
|
+
}
|
|
97
|
+
.close:hover {
|
|
98
|
+
opacity: 1;
|
|
99
|
+
background: #ffffff20;
|
|
100
|
+
}
|
|
101
|
+
.close svg {
|
|
102
|
+
width: 14px;
|
|
103
|
+
height: 14px;
|
|
104
|
+
}
|
|
105
|
+
.toast button:focus-visible {
|
|
106
|
+
outline: 1px solid currentColor;
|
|
107
|
+
outline-offset: 2px;
|
|
108
|
+
}
|
|
109
|
+
.toast[data-tone="success"] {
|
|
110
|
+
--tone: #91d5a4;
|
|
111
|
+
--soft-tone: #257243;
|
|
112
|
+
}
|
|
113
|
+
.toast[data-tone="info"] {
|
|
114
|
+
--tone: #8ec5ff;
|
|
115
|
+
--soft-tone: #2566a6;
|
|
116
|
+
}
|
|
117
|
+
.toast[data-tone="warning"] {
|
|
118
|
+
--tone: #f0c474;
|
|
119
|
+
--soft-tone: #926313;
|
|
120
|
+
}
|
|
121
|
+
.toast[data-tone="error"] {
|
|
122
|
+
--tone: #f4a3a3;
|
|
123
|
+
--soft-tone: #b13d3d;
|
|
124
|
+
}
|
|
125
|
+
.toast[data-variant="soft"] {
|
|
126
|
+
background: color-mix(in srgb, var(--soft-tone) 8%, var(--surface));
|
|
127
|
+
color: var(--toast-text-color, var(--fg));
|
|
128
|
+
box-shadow: var(--shadow);
|
|
129
|
+
border: 1px solid color-mix(in srgb, var(--soft-tone) 18%, var(--surface));
|
|
130
|
+
}
|
|
131
|
+
.toast[data-variant="soft"] .icon {
|
|
132
|
+
color: var(--toast-icon-color, var(--soft-tone));
|
|
133
|
+
}
|
|
134
|
+
.toast[data-variant="soft"] .action {
|
|
135
|
+
background: color-mix(in srgb, var(--soft-tone) 10%, transparent);
|
|
136
|
+
}
|
|
137
|
+
.toast[data-variant="soft"] button:hover:not(:disabled) {
|
|
138
|
+
background: color-mix(in srgb, var(--soft-tone) 18%, transparent);
|
|
139
|
+
}
|
|
140
|
+
.toast[data-position^="top"] {
|
|
141
|
+
top: 20px;
|
|
142
|
+
}
|
|
143
|
+
.toast[data-position^="bottom"] {
|
|
144
|
+
bottom: 20px;
|
|
145
|
+
}
|
|
146
|
+
.toast[data-position$="left"] {
|
|
147
|
+
left: 20px;
|
|
148
|
+
}
|
|
149
|
+
.toast[data-position$="right"] {
|
|
150
|
+
right: 20px;
|
|
151
|
+
}
|
|
152
|
+
.toast[data-position$="center"] {
|
|
153
|
+
left: 50%;
|
|
154
|
+
transform: translateX(-50%);
|
|
155
|
+
}
|
|
156
|
+
:global([data-theme="dark"]) .toast {
|
|
157
|
+
box-shadow:
|
|
158
|
+
0 8px 28px #0000003d,
|
|
159
|
+
0 2px 6px #00000024;
|
|
160
|
+
}
|
|
161
|
+
:global([data-theme="dark"]) .toast[data-variant="solid"] {
|
|
162
|
+
background: #333;
|
|
163
|
+
color: var(--toast-text-color, #f4f4f4);
|
|
164
|
+
}
|
|
165
|
+
:global([data-theme="dark"]) .toast[data-variant="soft"] {
|
|
166
|
+
--soft-tone: var(--tone);
|
|
167
|
+
}
|
|
168
|
+
.spin {
|
|
169
|
+
animation: spin 1s linear infinite;
|
|
170
|
+
}
|
|
171
|
+
@keyframes spin {
|
|
172
|
+
to {
|
|
173
|
+
transform: rotate(360deg);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
export type ToastPosition = "top-left" | "top-center" | "top-right" | "bottom-left" | "bottom-center" | "bottom-right";
|
|
3
|
+
export type ToastTone = "neutral" | "success" | "info" | "warning" | "error";
|
|
4
|
+
export type ToastAction = {
|
|
5
|
+
label: string;
|
|
6
|
+
icon?: ReactNode;
|
|
7
|
+
display?: "text" | "icon" | "both";
|
|
8
|
+
onClick(): void | Promise<void>;
|
|
9
|
+
closeOnClick?: boolean;
|
|
10
|
+
};
|
|
11
|
+
export type ToastOptions = {
|
|
12
|
+
duration?: number;
|
|
13
|
+
persistent?: boolean;
|
|
14
|
+
closable?: boolean;
|
|
15
|
+
title?: string;
|
|
16
|
+
tone?: ToastTone;
|
|
17
|
+
variant?: "solid" | "soft";
|
|
18
|
+
icon?: boolean | ReactNode;
|
|
19
|
+
iconColor?: string;
|
|
20
|
+
textColor?: string;
|
|
21
|
+
action?: ToastAction;
|
|
22
|
+
position?: ToastPosition;
|
|
23
|
+
};
|
|
24
|
+
export type ToastMessage = {
|
|
25
|
+
message: string;
|
|
26
|
+
id: number;
|
|
27
|
+
options?: ToastOptions;
|
|
28
|
+
closing?: boolean;
|
|
29
|
+
};
|
|
30
|
+
type Notify = (message: string, options?: ToastOptions | ToastTone) => () => void;
|
|
31
|
+
export declare function ToastProvider({ children }: {
|
|
32
|
+
children: ReactNode;
|
|
33
|
+
}): import("react").JSX.Element;
|
|
34
|
+
export declare const useToast: () => Notify;
|
|
35
|
+
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import {
|
|
3
|
+
createContext,
|
|
4
|
+
useCallback,
|
|
5
|
+
useContext,
|
|
6
|
+
useRef,
|
|
7
|
+
useState
|
|
8
|
+
} from "react";
|
|
9
|
+
import { useUIConfig } from "./UIProvider.js";
|
|
10
|
+
import { Toast } from "./Toast.js";
|
|
11
|
+
const Context = createContext(() => () => {
|
|
12
|
+
});
|
|
13
|
+
function ToastProvider({ children }) {
|
|
14
|
+
const config = useUIConfig();
|
|
15
|
+
const [toast, setToast] = useState(null), counter = useRef(0);
|
|
16
|
+
const notify = useCallback((message, options) => {
|
|
17
|
+
const id = ++counter.current;
|
|
18
|
+
setToast({
|
|
19
|
+
message,
|
|
20
|
+
id,
|
|
21
|
+
options: typeof options === "string" ? { tone: options } : options
|
|
22
|
+
});
|
|
23
|
+
return () => setToast(
|
|
24
|
+
(current) => current?.id === id ? { ...current, closing: true } : current
|
|
25
|
+
);
|
|
26
|
+
}, []);
|
|
27
|
+
const clear = useCallback(
|
|
28
|
+
(id) => setToast((current) => current?.id === id ? null : current),
|
|
29
|
+
[]
|
|
30
|
+
);
|
|
31
|
+
return /* @__PURE__ */ jsxs(Context, { value: notify, children: [
|
|
32
|
+
children,
|
|
33
|
+
/* @__PURE__ */ jsx(
|
|
34
|
+
Toast,
|
|
35
|
+
{
|
|
36
|
+
toast,
|
|
37
|
+
position: toast?.options?.position || config.toastPosition,
|
|
38
|
+
onDismiss: clear
|
|
39
|
+
}
|
|
40
|
+
)
|
|
41
|
+
] });
|
|
42
|
+
}
|
|
43
|
+
const useToast = () => useContext(Context);
|
|
44
|
+
export {
|
|
45
|
+
ToastProvider,
|
|
46
|
+
useToast
|
|
47
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type ReactElement } from "react";
|
|
2
|
+
type Side = "top" | "bottom" | "left" | "right";
|
|
3
|
+
export declare function Tooltip({ content, placement, children, }: {
|
|
4
|
+
content: string;
|
|
5
|
+
placement?: Side;
|
|
6
|
+
children: ReactElement<{
|
|
7
|
+
"aria-describedby"?: string;
|
|
8
|
+
}>;
|
|
9
|
+
}): import("react").JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import {
|
|
3
|
+
cloneElement,
|
|
4
|
+
useCallback,
|
|
5
|
+
useEffect,
|
|
6
|
+
useId,
|
|
7
|
+
useLayoutEffect,
|
|
8
|
+
useRef,
|
|
9
|
+
useState
|
|
10
|
+
} from "react";
|
|
11
|
+
import { useUIConfig } from "./UIProvider.js";
|
|
12
|
+
import { createPortal } from "react-dom";
|
|
13
|
+
import { surfaceMotion, cancelMotion } from "./motion.js";
|
|
14
|
+
import {
|
|
15
|
+
claimTooltip,
|
|
16
|
+
releaseTooltip,
|
|
17
|
+
retainTooltipEvents,
|
|
18
|
+
keyboardTooltip,
|
|
19
|
+
tooltipDelay
|
|
20
|
+
} from "./tooltipState.js";
|
|
21
|
+
import s from "./Tooltip.module.css";
|
|
22
|
+
import { useSurfacePortal } from "./surfacePortal.js";
|
|
23
|
+
function Tooltip({
|
|
24
|
+
content,
|
|
25
|
+
placement,
|
|
26
|
+
children
|
|
27
|
+
}) {
|
|
28
|
+
const config = useUIConfig();
|
|
29
|
+
const preferred = placement || config.tooltipPlacement, id = useId();
|
|
30
|
+
const anchor = useRef(null), popup = useRef(null), timer = useRef(void 0);
|
|
31
|
+
const owner = useSurfacePortal(), portalHost = owner?.host || document.body;
|
|
32
|
+
const [requestedOpen, setOpen] = useState(false), opened = useRef(false), visible = useRef(false);
|
|
33
|
+
const open = requestedOpen && owner?.active !== false;
|
|
34
|
+
const hide = useCallback((immediate = false) => {
|
|
35
|
+
clearTimeout(timer.current);
|
|
36
|
+
opened.current = false;
|
|
37
|
+
setOpen(false);
|
|
38
|
+
releaseTooltip(hide, visible.current);
|
|
39
|
+
visible.current = false;
|
|
40
|
+
if (immediate && popup.current) {
|
|
41
|
+
cancelMotion(popup.current);
|
|
42
|
+
if (popup.current.matches(":popover-open")) popup.current.hidePopover();
|
|
43
|
+
}
|
|
44
|
+
}, []);
|
|
45
|
+
const schedule = () => {
|
|
46
|
+
if (owner?.active === false) return;
|
|
47
|
+
clearTimeout(timer.current);
|
|
48
|
+
claimTooltip(hide);
|
|
49
|
+
timer.current = setTimeout(() => {
|
|
50
|
+
opened.current = true;
|
|
51
|
+
setOpen(true);
|
|
52
|
+
}, tooltipDelay());
|
|
53
|
+
};
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
const release = retainTooltipEvents(), node = popup.current;
|
|
56
|
+
return () => {
|
|
57
|
+
clearTimeout(timer.current);
|
|
58
|
+
releaseTooltip(hide, visible.current);
|
|
59
|
+
cancelMotion(node);
|
|
60
|
+
release();
|
|
61
|
+
};
|
|
62
|
+
}, [hide, portalHost]);
|
|
63
|
+
useLayoutEffect(() => {
|
|
64
|
+
if (owner?.active === false) hide(true);
|
|
65
|
+
}, [owner?.active, hide]);
|
|
66
|
+
useLayoutEffect(() => {
|
|
67
|
+
const node = popup.current;
|
|
68
|
+
if (!open) {
|
|
69
|
+
if (node.matches(":popover-open"))
|
|
70
|
+
void surfaceMotion(node, "exit", node.dataset.offset).then((done) => {
|
|
71
|
+
if (done && !opened.current && node.matches(":popover-open"))
|
|
72
|
+
node.hidePopover();
|
|
73
|
+
});
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
if (!node.matches(":popover-open")) node.showPopover();
|
|
77
|
+
visible.current = true;
|
|
78
|
+
const a = anchor.current.getBoundingClientRect(), w = node.offsetWidth, h = node.offsetHeight, gap = 10;
|
|
79
|
+
const spaces = {
|
|
80
|
+
top: a.top,
|
|
81
|
+
bottom: innerHeight - a.bottom,
|
|
82
|
+
left: a.left,
|
|
83
|
+
right: innerWidth - a.right
|
|
84
|
+
};
|
|
85
|
+
const opposite = {
|
|
86
|
+
top: "bottom",
|
|
87
|
+
bottom: "top",
|
|
88
|
+
left: "right",
|
|
89
|
+
right: "left"
|
|
90
|
+
};
|
|
91
|
+
const sides = Object.keys(spaces);
|
|
92
|
+
const order = [
|
|
93
|
+
preferred,
|
|
94
|
+
opposite[preferred],
|
|
95
|
+
...sides.sort((x2, y2) => spaces[y2] - spaces[x2])
|
|
96
|
+
];
|
|
97
|
+
const actual = order.find(
|
|
98
|
+
(v) => spaces[v] >= (v === "top" || v === "bottom" ? h : w) + gap + 8
|
|
99
|
+
) || order[2];
|
|
100
|
+
let x = a.left + a.width / 2 - w / 2, y = a.top - h - gap;
|
|
101
|
+
if (actual === "bottom") y = a.bottom + gap;
|
|
102
|
+
if (actual === "left" || actual === "right") {
|
|
103
|
+
x = actual === "left" ? a.left - w - gap : a.right + gap;
|
|
104
|
+
y = a.top + a.height / 2 - h / 2;
|
|
105
|
+
}
|
|
106
|
+
x = Math.max(8, Math.min(x, innerWidth - w - 8));
|
|
107
|
+
y = Math.max(8, Math.min(y, innerHeight - h - 8));
|
|
108
|
+
const vertical = actual === "top" || actual === "bottom", extent = vertical ? w : h, margin = Math.min(17, extent / 2);
|
|
109
|
+
node.style.left = x + "px";
|
|
110
|
+
node.style.top = y + "px";
|
|
111
|
+
node.style.setProperty(
|
|
112
|
+
"--arrow",
|
|
113
|
+
Math.max(
|
|
114
|
+
margin,
|
|
115
|
+
Math.min(
|
|
116
|
+
extent - margin,
|
|
117
|
+
vertical ? a.left + a.width / 2 - x : a.top + a.height / 2 - y
|
|
118
|
+
)
|
|
119
|
+
) + "px"
|
|
120
|
+
);
|
|
121
|
+
node.dataset.side = actual;
|
|
122
|
+
node.dataset.offset = {
|
|
123
|
+
top: "0 3px",
|
|
124
|
+
bottom: "0 -3px",
|
|
125
|
+
left: "3px 0",
|
|
126
|
+
right: "-3px 0"
|
|
127
|
+
}[actual];
|
|
128
|
+
void surfaceMotion(node, "enter", node.dataset.offset);
|
|
129
|
+
}, [open, preferred, portalHost]);
|
|
130
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
131
|
+
/* @__PURE__ */ jsx(
|
|
132
|
+
"span",
|
|
133
|
+
{
|
|
134
|
+
ref: anchor,
|
|
135
|
+
className: s.anchor,
|
|
136
|
+
onPointerEnter: (e) => {
|
|
137
|
+
if (e.pointerType !== "touch" && !e.buttons) schedule();
|
|
138
|
+
},
|
|
139
|
+
onPointerLeave: () => hide(),
|
|
140
|
+
onPointerDown: () => hide(),
|
|
141
|
+
onFocus: (e) => {
|
|
142
|
+
if (keyboardTooltip() && e.target.matches(":focus-visible"))
|
|
143
|
+
schedule();
|
|
144
|
+
},
|
|
145
|
+
onBlur: () => hide(),
|
|
146
|
+
children: cloneElement(children, {
|
|
147
|
+
"aria-describedby": [children.props["aria-describedby"], open ? id : void 0].filter(Boolean).join(" ") || void 0
|
|
148
|
+
})
|
|
149
|
+
}
|
|
150
|
+
),
|
|
151
|
+
createPortal(
|
|
152
|
+
/* @__PURE__ */ jsx(
|
|
153
|
+
"div",
|
|
154
|
+
{
|
|
155
|
+
ref: popup,
|
|
156
|
+
id,
|
|
157
|
+
role: "tooltip",
|
|
158
|
+
popover: "manual",
|
|
159
|
+
className: s.tooltip,
|
|
160
|
+
children: content
|
|
161
|
+
}
|
|
162
|
+
),
|
|
163
|
+
portalHost
|
|
164
|
+
)
|
|
165
|
+
] });
|
|
166
|
+
}
|
|
167
|
+
export {
|
|
168
|
+
Tooltip
|
|
169
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
.anchor {
|
|
2
|
+
display: inline-flex;
|
|
3
|
+
align-items: center;
|
|
4
|
+
}
|
|
5
|
+
.tooltip {
|
|
6
|
+
position: fixed;
|
|
7
|
+
inset: auto;
|
|
8
|
+
margin: 0;
|
|
9
|
+
max-width: min(320px, calc(100vw - 16px));
|
|
10
|
+
padding: 6px 9px;
|
|
11
|
+
border-radius: 10px;
|
|
12
|
+
background: #303030;
|
|
13
|
+
color: #fff;
|
|
14
|
+
border: 1px solid #303030;
|
|
15
|
+
box-shadow: 0 3px 12px rgb(0 0 0 / 0.14);
|
|
16
|
+
font: 400 11px/16px var(--ui-font);
|
|
17
|
+
overflow: visible;
|
|
18
|
+
pointer-events: none;
|
|
19
|
+
}
|
|
20
|
+
:global([data-theme="dark"]) .tooltip {
|
|
21
|
+
box-shadow: 0 3px 12px rgb(0 0 0 / 0.22);
|
|
22
|
+
}
|
|
23
|
+
.tooltip::before {
|
|
24
|
+
content: "";
|
|
25
|
+
position: absolute;
|
|
26
|
+
background: inherit;
|
|
27
|
+
width: 14px;
|
|
28
|
+
height: 8px;
|
|
29
|
+
}
|
|
30
|
+
.tooltip[data-side="top"]::before {
|
|
31
|
+
bottom: -7px;
|
|
32
|
+
left: calc(var(--arrow) - 7px);
|
|
33
|
+
clip-path: polygon(0 0, 100% 0, 50% 100%);
|
|
34
|
+
}
|
|
35
|
+
.tooltip[data-side="bottom"]::before {
|
|
36
|
+
top: -7px;
|
|
37
|
+
left: calc(var(--arrow) - 7px);
|
|
38
|
+
clip-path: polygon(50% 0, 100% 100%, 0 100%);
|
|
39
|
+
}
|
|
40
|
+
.tooltip[data-side="left"]::before {
|
|
41
|
+
right: -7px;
|
|
42
|
+
top: calc(var(--arrow) - 7px);
|
|
43
|
+
width: 8px;
|
|
44
|
+
height: 14px;
|
|
45
|
+
clip-path: polygon(100% 50%, 0 0, 0 100%);
|
|
46
|
+
}
|
|
47
|
+
.tooltip[data-side="right"]::before {
|
|
48
|
+
left: -7px;
|
|
49
|
+
top: calc(var(--arrow) - 7px);
|
|
50
|
+
width: 8px;
|
|
51
|
+
height: 14px;
|
|
52
|
+
clip-path: polygon(0 50%, 100% 0, 100% 100%);
|
|
53
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type FieldOptions } from "./field";
|
|
2
|
+
import { type HierarchyLoader, type HierarchyOption } from "./hierarchy";
|
|
3
|
+
type Base = FieldOptions & {
|
|
4
|
+
options: HierarchyOption[];
|
|
5
|
+
label: string;
|
|
6
|
+
searchable?: boolean;
|
|
7
|
+
clearable?: boolean;
|
|
8
|
+
placeholder?: string;
|
|
9
|
+
loadChildren?: HierarchyLoader;
|
|
10
|
+
defaultExpanded?: string[];
|
|
11
|
+
};
|
|
12
|
+
export type TreeSelectProps = Base & ({
|
|
13
|
+
multiple?: false;
|
|
14
|
+
value: string;
|
|
15
|
+
onChange(value: string): void;
|
|
16
|
+
} | {
|
|
17
|
+
multiple: true;
|
|
18
|
+
value: string[];
|
|
19
|
+
onChange(value: string[]): void;
|
|
20
|
+
checkStrictly?: boolean;
|
|
21
|
+
});
|
|
22
|
+
export declare function TreeSelect(props: TreeSelectProps): import("react").JSX.Element;
|
|
23
|
+
export {};
|