@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,122 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
import {
|
|
4
|
+
CheckCircle,
|
|
5
|
+
CircleAlert,
|
|
6
|
+
File,
|
|
7
|
+
Play,
|
|
8
|
+
RotateCcw,
|
|
9
|
+
Square,
|
|
10
|
+
X
|
|
11
|
+
} from "lucide-react";
|
|
12
|
+
import { IconButton } from "./IconButton.js";
|
|
13
|
+
import { Progress } from "./Progress.js";
|
|
14
|
+
import { formatFileSize } from "./fileSelection.js";
|
|
15
|
+
import s from "./UploadList.module.css";
|
|
16
|
+
const statuses = {
|
|
17
|
+
ready: "\u7B49\u5F85\u4E0A\u4F20",
|
|
18
|
+
uploading: "\u6B63\u5728\u4E0A\u4F20",
|
|
19
|
+
success: "\u4E0A\u4F20\u5B8C\u6210",
|
|
20
|
+
error: "\u4E0A\u4F20\u5931\u8D25",
|
|
21
|
+
canceled: "\u5DF2\u53D6\u6D88"
|
|
22
|
+
};
|
|
23
|
+
function UploadListItem({
|
|
24
|
+
file,
|
|
25
|
+
disabled = false,
|
|
26
|
+
showThumbnails = true,
|
|
27
|
+
onStart,
|
|
28
|
+
onRetry,
|
|
29
|
+
onCancel,
|
|
30
|
+
onRemove,
|
|
31
|
+
onPreview
|
|
32
|
+
}) {
|
|
33
|
+
const [localUrl, setLocalUrl] = useState(), [failed, setFailed] = useState(false), image = !!file.type?.startsWith("image/");
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
if (!showThumbnails || !image || !file.file) {
|
|
36
|
+
setLocalUrl(void 0);
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const url = URL.createObjectURL(file.file);
|
|
40
|
+
setLocalUrl(url);
|
|
41
|
+
return () => URL.revokeObjectURL(url);
|
|
42
|
+
}, [file.file, image, showThumbnails]);
|
|
43
|
+
const source = showThumbnails && image ? localUrl || file.url : void 0;
|
|
44
|
+
useEffect(() => setFailed(false), [source]);
|
|
45
|
+
const thumbnail = source && !failed ? /* @__PURE__ */ jsx("img", { src: source, alt: "", onError: () => setFailed(true) }) : /* @__PURE__ */ jsx(File, { "aria-hidden": "true" });
|
|
46
|
+
return /* @__PURE__ */ jsxs("li", { className: s.item, "data-status": file.status, "aria-label": file.name, children: [
|
|
47
|
+
onPreview && source && !failed ? /* @__PURE__ */ jsx(
|
|
48
|
+
"button",
|
|
49
|
+
{
|
|
50
|
+
type: "button",
|
|
51
|
+
className: s.thumbnail,
|
|
52
|
+
"aria-label": `\u9884\u89C8 ${file.name}`,
|
|
53
|
+
onClick: () => onPreview(file, source),
|
|
54
|
+
children: thumbnail
|
|
55
|
+
}
|
|
56
|
+
) : /* @__PURE__ */ jsx("span", { className: s.thumbnail, "aria-hidden": "true", children: thumbnail }),
|
|
57
|
+
/* @__PURE__ */ jsxs("div", { className: s.body, children: [
|
|
58
|
+
/* @__PURE__ */ jsx("div", { className: s.name, "data-selectable": "true", children: file.name }),
|
|
59
|
+
/* @__PURE__ */ jsxs("div", { className: s.meta, children: [
|
|
60
|
+
/* @__PURE__ */ jsx("span", { children: formatFileSize(file.size) }),
|
|
61
|
+
/* @__PURE__ */ jsxs(
|
|
62
|
+
"span",
|
|
63
|
+
{
|
|
64
|
+
role: file.status === "error" ? "alert" : "status",
|
|
65
|
+
className: s.status,
|
|
66
|
+
children: [
|
|
67
|
+
file.status === "success" ? /* @__PURE__ */ jsx(CheckCircle, { "aria-hidden": "true" }) : file.status === "error" ? /* @__PURE__ */ jsx(CircleAlert, { "aria-hidden": "true" }) : null,
|
|
68
|
+
statuses[file.status]
|
|
69
|
+
]
|
|
70
|
+
}
|
|
71
|
+
),
|
|
72
|
+
file.status === "uploading" && /* @__PURE__ */ jsxs("span", { "aria-hidden": "true", children: [
|
|
73
|
+
Math.round(Math.min(100, Math.max(0, file.progress || 0))),
|
|
74
|
+
"%"
|
|
75
|
+
] })
|
|
76
|
+
] }),
|
|
77
|
+
file.status === "uploading" && /* @__PURE__ */ jsx(Progress, { value: file.progress, label: `${file.name}\u4E0A\u4F20\u8FDB\u5EA6` }),
|
|
78
|
+
file.status === "error" && file.error && /* @__PURE__ */ jsx("div", { className: s.error, children: file.error })
|
|
79
|
+
] }),
|
|
80
|
+
/* @__PURE__ */ jsxs("div", { className: s.actions, children: [
|
|
81
|
+
file.status === "ready" && onStart && /* @__PURE__ */ jsx(
|
|
82
|
+
IconButton,
|
|
83
|
+
{
|
|
84
|
+
label: `\u5F00\u59CB\u4E0A\u4F20 ${file.name}`,
|
|
85
|
+
disabled: disabled || !file.file,
|
|
86
|
+
onClick: () => onStart(file.id),
|
|
87
|
+
children: /* @__PURE__ */ jsx(Play, {})
|
|
88
|
+
}
|
|
89
|
+
),
|
|
90
|
+
file.status === "uploading" && onCancel && /* @__PURE__ */ jsx(
|
|
91
|
+
IconButton,
|
|
92
|
+
{
|
|
93
|
+
label: `\u53D6\u6D88\u4E0A\u4F20 ${file.name}`,
|
|
94
|
+
disabled,
|
|
95
|
+
onClick: () => onCancel(file.id),
|
|
96
|
+
children: /* @__PURE__ */ jsx(Square, {})
|
|
97
|
+
}
|
|
98
|
+
),
|
|
99
|
+
(file.status === "error" || file.status === "canceled") && onRetry && /* @__PURE__ */ jsx(
|
|
100
|
+
IconButton,
|
|
101
|
+
{
|
|
102
|
+
label: `\u91CD\u8BD5\u4E0A\u4F20 ${file.name}`,
|
|
103
|
+
disabled: disabled || !file.file,
|
|
104
|
+
onClick: () => onRetry(file.id),
|
|
105
|
+
children: /* @__PURE__ */ jsx(RotateCcw, {})
|
|
106
|
+
}
|
|
107
|
+
),
|
|
108
|
+
onRemove && /* @__PURE__ */ jsx(
|
|
109
|
+
IconButton,
|
|
110
|
+
{
|
|
111
|
+
label: `\u79FB\u9664\u6587\u4EF6 ${file.name}`,
|
|
112
|
+
disabled,
|
|
113
|
+
onClick: () => onRemove(file.id),
|
|
114
|
+
children: /* @__PURE__ */ jsx(X, {})
|
|
115
|
+
}
|
|
116
|
+
)
|
|
117
|
+
] })
|
|
118
|
+
] });
|
|
119
|
+
}
|
|
120
|
+
export {
|
|
121
|
+
UploadListItem
|
|
122
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type LucideIconData } from "lucide-react";
|
|
2
|
+
export type PickerCatalogItem = {
|
|
3
|
+
id: string;
|
|
4
|
+
label: string;
|
|
5
|
+
search: string;
|
|
6
|
+
glyph?: string;
|
|
7
|
+
icon?: LucideIconData;
|
|
8
|
+
variants?: {
|
|
9
|
+
glyph: string;
|
|
10
|
+
label: string;
|
|
11
|
+
}[];
|
|
12
|
+
};
|
|
13
|
+
export type PickerCatalogGroup = {
|
|
14
|
+
id: string;
|
|
15
|
+
label: string;
|
|
16
|
+
items: PickerCatalogItem[];
|
|
17
|
+
};
|
|
18
|
+
export declare function VirtualPickerList({ groups, query, value, label, onChoose, onVariants, }: {
|
|
19
|
+
groups: PickerCatalogGroup[];
|
|
20
|
+
query: string;
|
|
21
|
+
value: string;
|
|
22
|
+
label: string;
|
|
23
|
+
onChoose(item: PickerCatalogItem): void;
|
|
24
|
+
onVariants?(item: PickerCatalogItem): void;
|
|
25
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import {
|
|
3
|
+
useCallback,
|
|
4
|
+
memo,
|
|
5
|
+
useDeferredValue,
|
|
6
|
+
useEffect,
|
|
7
|
+
useLayoutEffect,
|
|
8
|
+
useMemo,
|
|
9
|
+
useRef,
|
|
10
|
+
useState
|
|
11
|
+
} from "react";
|
|
12
|
+
import { Icon } from "lucide-react";
|
|
13
|
+
import { BlockedTab } from "./BlockedTab.js";
|
|
14
|
+
import { reducedMotion } from "./motion.js";
|
|
15
|
+
import s from "./VirtualPickerList.module.css";
|
|
16
|
+
const Cell = memo(function Cell2({
|
|
17
|
+
item,
|
|
18
|
+
selected,
|
|
19
|
+
onChoose,
|
|
20
|
+
onVariants,
|
|
21
|
+
index
|
|
22
|
+
}) {
|
|
23
|
+
return /* @__PURE__ */ jsxs(
|
|
24
|
+
"button",
|
|
25
|
+
{
|
|
26
|
+
type: "button",
|
|
27
|
+
className: s.cell,
|
|
28
|
+
"data-picker-index": index,
|
|
29
|
+
"data-character": item.glyph,
|
|
30
|
+
"aria-label": item.label,
|
|
31
|
+
title: item.label,
|
|
32
|
+
"aria-pressed": selected,
|
|
33
|
+
onClick: () => onChoose(item),
|
|
34
|
+
onContextMenu: (e) => {
|
|
35
|
+
if (item.variants && item.variants.length > 1 && onVariants) {
|
|
36
|
+
e.preventDefault();
|
|
37
|
+
onVariants(item);
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
onKeyDown: (e) => {
|
|
41
|
+
if ((e.key === "ContextMenu" || e.shiftKey && e.key === "F10") && onVariants && item.variants && item.variants.length > 1) {
|
|
42
|
+
e.preventDefault();
|
|
43
|
+
onVariants(item);
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
children: [
|
|
47
|
+
item.icon ? /* @__PURE__ */ jsx(Icon, { icon: item.icon }) : item.glyph,
|
|
48
|
+
item.variants && item.variants.length > 1 && /* @__PURE__ */ jsx("span", { className: s.variantMark, "aria-hidden": "true" })
|
|
49
|
+
]
|
|
50
|
+
}
|
|
51
|
+
);
|
|
52
|
+
});
|
|
53
|
+
function VirtualPickerList({
|
|
54
|
+
groups,
|
|
55
|
+
query,
|
|
56
|
+
value,
|
|
57
|
+
label,
|
|
58
|
+
onChoose,
|
|
59
|
+
onVariants
|
|
60
|
+
}) {
|
|
61
|
+
const deferred = useDeferredValue(query), viewport = useRef(null), pendingFocus = useRef(void 0), locked = useRef(false), frame = useRef(void 0), [columns, setColumns] = useState(6), [position, setPosition] = useState({ top: 0, height: 300 }), [active, setActive] = useState(groups[0]?.id || "");
|
|
62
|
+
const filtered = useMemo(() => {
|
|
63
|
+
const terms = deferred.trim().toLowerCase().split(/\s+/).filter(Boolean);
|
|
64
|
+
return groups.map((g) => ({
|
|
65
|
+
...g,
|
|
66
|
+
items: terms.length ? g.items.filter(
|
|
67
|
+
(i) => terms.every((term) => i.search.includes(term))
|
|
68
|
+
) : g.items
|
|
69
|
+
})).filter((g) => g.items.length);
|
|
70
|
+
}, [groups, deferred]);
|
|
71
|
+
const layout = useMemo(() => {
|
|
72
|
+
const rows = [], offsets = /* @__PURE__ */ new Map(), items = [];
|
|
73
|
+
let top = 0;
|
|
74
|
+
for (const group of filtered) {
|
|
75
|
+
offsets.set(group.id, top);
|
|
76
|
+
rows.push({ top, group: group.id, label: group.label });
|
|
77
|
+
top += 30;
|
|
78
|
+
for (let i = 0; i < group.items.length; i += columns) {
|
|
79
|
+
const slice = group.items.slice(i, i + columns).map((item) => {
|
|
80
|
+
const index = items.length;
|
|
81
|
+
items.push({ item, top });
|
|
82
|
+
return { item, index };
|
|
83
|
+
});
|
|
84
|
+
rows.push({ top, group: group.id, items: slice });
|
|
85
|
+
top += 42;
|
|
86
|
+
}
|
|
87
|
+
top += 12;
|
|
88
|
+
}
|
|
89
|
+
return { rows, offsets, items, height: top };
|
|
90
|
+
}, [filtered, columns]);
|
|
91
|
+
const current = useRef(layout);
|
|
92
|
+
current.current = layout;
|
|
93
|
+
const sync = () => {
|
|
94
|
+
const node = viewport.current;
|
|
95
|
+
if (!node) return;
|
|
96
|
+
setPosition({ top: node.scrollTop, height: node.clientHeight });
|
|
97
|
+
if (!locked.current) {
|
|
98
|
+
const offsets = [...current.current.offsets];
|
|
99
|
+
const group = node.scrollTop + node.clientHeight >= node.scrollHeight - 2 ? offsets.at(-1)?.[0] : offsets.filter(([, top]) => top <= node.scrollTop + 32).at(-1)?.[0] || offsets[0]?.[0];
|
|
100
|
+
if (group) setActive(group);
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
useLayoutEffect(() => {
|
|
104
|
+
const node = viewport.current;
|
|
105
|
+
const measure = () => {
|
|
106
|
+
setColumns(Math.max(2, Math.floor((node.clientWidth + 4) / 42)));
|
|
107
|
+
sync();
|
|
108
|
+
};
|
|
109
|
+
measure();
|
|
110
|
+
const observer = new ResizeObserver(measure);
|
|
111
|
+
observer.observe(node);
|
|
112
|
+
const end = () => {
|
|
113
|
+
locked.current = false;
|
|
114
|
+
sync();
|
|
115
|
+
};
|
|
116
|
+
node.addEventListener("scrollend", end);
|
|
117
|
+
return () => {
|
|
118
|
+
observer.disconnect();
|
|
119
|
+
node.removeEventListener("scrollend", end);
|
|
120
|
+
if (frame.current) cancelAnimationFrame(frame.current);
|
|
121
|
+
};
|
|
122
|
+
}, []);
|
|
123
|
+
useEffect(() => {
|
|
124
|
+
locked.current = false;
|
|
125
|
+
viewport.current?.scrollTo({ top: 0, behavior: "instant" });
|
|
126
|
+
setActive(filtered[0]?.id || "");
|
|
127
|
+
setPosition((p) => ({ ...p, top: 0 }));
|
|
128
|
+
}, [deferred]);
|
|
129
|
+
useLayoutEffect(() => {
|
|
130
|
+
if (pendingFocus.current === void 0) return;
|
|
131
|
+
const cell = viewport.current?.querySelector(
|
|
132
|
+
'[data-picker-index="' + pendingFocus.current + '"]'
|
|
133
|
+
);
|
|
134
|
+
if (cell) {
|
|
135
|
+
cell.focus({ preventScroll: true });
|
|
136
|
+
pendingFocus.current = void 0;
|
|
137
|
+
}
|
|
138
|
+
}, [position, layout]);
|
|
139
|
+
useLayoutEffect(() => {
|
|
140
|
+
sync();
|
|
141
|
+
}, [layout]);
|
|
142
|
+
const options = useMemo(
|
|
143
|
+
() => filtered.map((g) => ({ value: g.id, label: g.label })),
|
|
144
|
+
[filtered]
|
|
145
|
+
);
|
|
146
|
+
const jump = useCallback(
|
|
147
|
+
(id) => {
|
|
148
|
+
setActive(id);
|
|
149
|
+
locked.current = true;
|
|
150
|
+
viewport.current?.scrollTo({
|
|
151
|
+
top: layout.offsets.get(id) || 0,
|
|
152
|
+
behavior: reducedMotion() ? "instant" : "smooth"
|
|
153
|
+
});
|
|
154
|
+
if (reducedMotion()) {
|
|
155
|
+
locked.current = false;
|
|
156
|
+
sync();
|
|
157
|
+
}
|
|
158
|
+
},
|
|
159
|
+
[layout]
|
|
160
|
+
);
|
|
161
|
+
const visible = layout.rows.filter(
|
|
162
|
+
(row) => row.top + 42 >= position.top - 84 && row.top <= position.top + position.height + 84
|
|
163
|
+
);
|
|
164
|
+
return /* @__PURE__ */ jsxs(
|
|
165
|
+
"div",
|
|
166
|
+
{
|
|
167
|
+
className: s.body,
|
|
168
|
+
"data-virtual-picker": true,
|
|
169
|
+
"aria-busy": query !== deferred || void 0,
|
|
170
|
+
children: [
|
|
171
|
+
/* @__PURE__ */ jsx(
|
|
172
|
+
BlockedTab,
|
|
173
|
+
{
|
|
174
|
+
orientation: "vertical",
|
|
175
|
+
label: label + "\u5206\u7C7B",
|
|
176
|
+
value: active,
|
|
177
|
+
onChange: jump,
|
|
178
|
+
options
|
|
179
|
+
}
|
|
180
|
+
),
|
|
181
|
+
/* @__PURE__ */ jsxs(
|
|
182
|
+
"div",
|
|
183
|
+
{
|
|
184
|
+
ref: viewport,
|
|
185
|
+
className: s.viewport,
|
|
186
|
+
role: "region",
|
|
187
|
+
"aria-label": label + "\u8FDE\u7EED\u5217\u8868",
|
|
188
|
+
tabIndex: -1,
|
|
189
|
+
onScroll: () => {
|
|
190
|
+
if (frame.current) return;
|
|
191
|
+
frame.current = requestAnimationFrame(() => {
|
|
192
|
+
frame.current = void 0;
|
|
193
|
+
sync();
|
|
194
|
+
});
|
|
195
|
+
},
|
|
196
|
+
onWheel: () => {
|
|
197
|
+
locked.current = false;
|
|
198
|
+
},
|
|
199
|
+
onPointerDown: () => {
|
|
200
|
+
locked.current = false;
|
|
201
|
+
},
|
|
202
|
+
onKeyDown: (event) => {
|
|
203
|
+
const index = Number(
|
|
204
|
+
event.target.closest("[data-picker-index]")?.getAttribute("data-picker-index")
|
|
205
|
+
);
|
|
206
|
+
if (!Number.isFinite(index)) return;
|
|
207
|
+
const delta = {
|
|
208
|
+
ArrowRight: 1,
|
|
209
|
+
ArrowLeft: -1,
|
|
210
|
+
ArrowDown: columns,
|
|
211
|
+
ArrowUp: -columns
|
|
212
|
+
}[event.key];
|
|
213
|
+
const next = event.key === "Home" ? 0 : event.key === "End" ? layout.items.length - 1 : delta === void 0 ? void 0 : Math.max(
|
|
214
|
+
0,
|
|
215
|
+
Math.min(layout.items.length - 1, index + delta)
|
|
216
|
+
);
|
|
217
|
+
if (next === void 0 || !layout.items[next]) return;
|
|
218
|
+
event.preventDefault();
|
|
219
|
+
locked.current = false;
|
|
220
|
+
pendingFocus.current = next;
|
|
221
|
+
const node = viewport.current, top = layout.items[next].top;
|
|
222
|
+
if (top < node.scrollTop + 30 || top + 42 > node.scrollTop + node.clientHeight)
|
|
223
|
+
node.scrollTo({ top: Math.max(0, top - 30), behavior: "instant" });
|
|
224
|
+
sync();
|
|
225
|
+
},
|
|
226
|
+
children: [
|
|
227
|
+
/* @__PURE__ */ jsx("div", { className: s.spacer, style: { height: layout.height }, children: visible.map(
|
|
228
|
+
(row) => row.items ? /* @__PURE__ */ jsx(
|
|
229
|
+
"div",
|
|
230
|
+
{
|
|
231
|
+
className: s.row,
|
|
232
|
+
style: {
|
|
233
|
+
top: row.top,
|
|
234
|
+
gridTemplateColumns: "repeat(" + columns + ",minmax(0,1fr))"
|
|
235
|
+
},
|
|
236
|
+
children: row.items.map(({ item, index }) => /* @__PURE__ */ jsx(
|
|
237
|
+
Cell,
|
|
238
|
+
{
|
|
239
|
+
item,
|
|
240
|
+
index,
|
|
241
|
+
selected: value === item.id || value === item.glyph,
|
|
242
|
+
onChoose,
|
|
243
|
+
onVariants
|
|
244
|
+
},
|
|
245
|
+
item.id
|
|
246
|
+
))
|
|
247
|
+
},
|
|
248
|
+
row.group + "-" + row.top
|
|
249
|
+
) : /* @__PURE__ */ jsx(
|
|
250
|
+
"div",
|
|
251
|
+
{
|
|
252
|
+
className: s.heading,
|
|
253
|
+
style: { top: row.top },
|
|
254
|
+
children: row.label
|
|
255
|
+
},
|
|
256
|
+
row.group
|
|
257
|
+
)
|
|
258
|
+
) }),
|
|
259
|
+
!filtered.length && /* @__PURE__ */ jsx("p", { className: s.empty, children: "\u6CA1\u6709\u5339\u914D\u7ED3\u679C" })
|
|
260
|
+
]
|
|
261
|
+
}
|
|
262
|
+
)
|
|
263
|
+
]
|
|
264
|
+
}
|
|
265
|
+
);
|
|
266
|
+
}
|
|
267
|
+
export {
|
|
268
|
+
VirtualPickerList
|
|
269
|
+
};
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
.body {
|
|
2
|
+
--blocked-background: transparent;
|
|
3
|
+
--blocked-border: 0;
|
|
4
|
+
--blocked-selected: var(--selected);
|
|
5
|
+
--blocked-shadow: none;
|
|
6
|
+
display: flex;
|
|
7
|
+
gap: 12px;
|
|
8
|
+
min-height: 0;
|
|
9
|
+
height: 320px;
|
|
10
|
+
}
|
|
11
|
+
.viewport {
|
|
12
|
+
position: relative;
|
|
13
|
+
flex: 1;
|
|
14
|
+
min-width: 0;
|
|
15
|
+
overflow: auto;
|
|
16
|
+
overscroll-behavior: contain;
|
|
17
|
+
scrollbar-gutter: stable;
|
|
18
|
+
contain: layout paint;
|
|
19
|
+
overflow-anchor: none;
|
|
20
|
+
}
|
|
21
|
+
.spacer {
|
|
22
|
+
position: relative;
|
|
23
|
+
width: 100%;
|
|
24
|
+
}
|
|
25
|
+
.row {
|
|
26
|
+
position: absolute;
|
|
27
|
+
left: 0;
|
|
28
|
+
right: 0;
|
|
29
|
+
display: grid;
|
|
30
|
+
gap: 4px;
|
|
31
|
+
height: 42px;
|
|
32
|
+
padding-bottom: 4px;
|
|
33
|
+
}
|
|
34
|
+
.heading {
|
|
35
|
+
position: absolute;
|
|
36
|
+
left: 0;
|
|
37
|
+
right: 0;
|
|
38
|
+
height: 30px;
|
|
39
|
+
display: flex;
|
|
40
|
+
align-items: center;
|
|
41
|
+
padding: 0 5px;
|
|
42
|
+
color: var(--muted);
|
|
43
|
+
font-size: 11px;
|
|
44
|
+
font-weight: 500;
|
|
45
|
+
}
|
|
46
|
+
.cell {
|
|
47
|
+
position: relative;
|
|
48
|
+
display: grid;
|
|
49
|
+
place-items: center;
|
|
50
|
+
height: 38px;
|
|
51
|
+
min-width: 0;
|
|
52
|
+
padding: 0;
|
|
53
|
+
border: 1px solid transparent;
|
|
54
|
+
border-radius: 7px;
|
|
55
|
+
background: transparent;
|
|
56
|
+
font-size: 23px;
|
|
57
|
+
line-height: 1;
|
|
58
|
+
font-family: "Segoe UI Emoji", "Segoe UI Symbol", var(--ui-font);
|
|
59
|
+
}
|
|
60
|
+
.cell svg {
|
|
61
|
+
width: 19px;
|
|
62
|
+
height: 19px;
|
|
63
|
+
}
|
|
64
|
+
.cell:hover {
|
|
65
|
+
background: var(--hover);
|
|
66
|
+
}
|
|
67
|
+
.cell[aria-pressed="true"] {
|
|
68
|
+
background: var(--selected);
|
|
69
|
+
border-color: var(--accent);
|
|
70
|
+
}
|
|
71
|
+
.cell:focus-visible {
|
|
72
|
+
outline-offset: -2px;
|
|
73
|
+
}
|
|
74
|
+
.variantMark {
|
|
75
|
+
position: absolute;
|
|
76
|
+
bottom: 3px;
|
|
77
|
+
right: 3px;
|
|
78
|
+
width: 3px;
|
|
79
|
+
height: 3px;
|
|
80
|
+
border-radius: 50%;
|
|
81
|
+
background: var(--muted);
|
|
82
|
+
opacity: 0.55;
|
|
83
|
+
}
|
|
84
|
+
.empty {
|
|
85
|
+
padding: 32px 8px;
|
|
86
|
+
color: var(--muted);
|
|
87
|
+
text-align: center;
|
|
88
|
+
}
|
|
89
|
+
@media (max-height: 650px) {
|
|
90
|
+
.body {
|
|
91
|
+
height: 240px;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { UITheme, ColorMode } from "./ThemeProvider";
|
|
2
|
+
import type { UIConfig } from "./UIProvider";
|
|
3
|
+
export interface AppearancePreferences {
|
|
4
|
+
paletteVersion?: 2;
|
|
5
|
+
designTheme: UITheme;
|
|
6
|
+
mode: ColorMode;
|
|
7
|
+
accent: string;
|
|
8
|
+
lightBackground: string;
|
|
9
|
+
darkBackground: string;
|
|
10
|
+
lightForeground: string;
|
|
11
|
+
darkForeground: string;
|
|
12
|
+
font: string;
|
|
13
|
+
density: "comfortable" | "compact";
|
|
14
|
+
radius: number;
|
|
15
|
+
motion: boolean;
|
|
16
|
+
toastPosition: UIConfig["toastPosition"];
|
|
17
|
+
tooltipPlacement: UIConfig["tooltipPlacement"];
|
|
18
|
+
}
|
|
19
|
+
export declare function appearanceDefaults(designTheme?: UITheme): AppearancePreferences;
|
|
20
|
+
export declare function normalizeAppearance(input: unknown, fallback?: UITheme): AppearancePreferences;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
function appearanceDefaults(designTheme = "minimal") {
|
|
2
|
+
const blue = designTheme === "blue";
|
|
3
|
+
return {
|
|
4
|
+
paletteVersion: 2,
|
|
5
|
+
designTheme,
|
|
6
|
+
mode: "system",
|
|
7
|
+
accent: blue ? "#5067b8" : "#303030",
|
|
8
|
+
lightBackground: "#ffffff",
|
|
9
|
+
darkBackground: blue ? "#19212f" : "#1e1e1f",
|
|
10
|
+
lightForeground: blue ? "#25324a" : "#202020",
|
|
11
|
+
darkForeground: blue ? "#e1e8f4" : "#f4f4f5",
|
|
12
|
+
font: "system",
|
|
13
|
+
density: "comfortable",
|
|
14
|
+
radius: blue ? 9 : 10,
|
|
15
|
+
motion: true,
|
|
16
|
+
toastPosition: "bottom-center",
|
|
17
|
+
tooltipPlacement: "top"
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
function normalizeAppearance(input, fallback = "minimal") {
|
|
21
|
+
const x = input && typeof input === "object" ? input : {};
|
|
22
|
+
const d = appearanceDefaults(
|
|
23
|
+
x.designTheme === "minimal" || x.designTheme === "blue" ? x.designTheme : fallback
|
|
24
|
+
);
|
|
25
|
+
const legacyBlue = d.designTheme === "blue" && x.paletteVersion !== 2 ? {
|
|
26
|
+
accent: "#5269b6",
|
|
27
|
+
darkBackground: "#19212e",
|
|
28
|
+
lightForeground: "#263149",
|
|
29
|
+
darkForeground: "#e0e7f2"
|
|
30
|
+
} : {};
|
|
31
|
+
if (["light", "dark", "system"].includes(String(x.mode)))
|
|
32
|
+
d.mode = x.mode;
|
|
33
|
+
for (const key of [
|
|
34
|
+
"accent",
|
|
35
|
+
"lightBackground",
|
|
36
|
+
"darkBackground",
|
|
37
|
+
"lightForeground",
|
|
38
|
+
"darkForeground"
|
|
39
|
+
])
|
|
40
|
+
if (typeof x[key] === "string" && /^#[\da-f]{6}$/i.test(x[key])) {
|
|
41
|
+
if (x[key].toLowerCase() !== legacyBlue[key])
|
|
42
|
+
d[key] = x[key];
|
|
43
|
+
}
|
|
44
|
+
if (["system", "Segoe UI", "Microsoft YaHei UI", "sans-serif"].includes(
|
|
45
|
+
String(x.font)
|
|
46
|
+
))
|
|
47
|
+
d.font = x.font;
|
|
48
|
+
if (x.density === "comfortable" || x.density === "compact")
|
|
49
|
+
d.density = x.density;
|
|
50
|
+
if (typeof x.radius === "number" && Number.isFinite(x.radius))
|
|
51
|
+
d.radius = Math.min(20, Math.max(0, x.radius));
|
|
52
|
+
if (typeof x.motion === "boolean") d.motion = x.motion;
|
|
53
|
+
if ([
|
|
54
|
+
"top-left",
|
|
55
|
+
"top-center",
|
|
56
|
+
"top-right",
|
|
57
|
+
"bottom-left",
|
|
58
|
+
"bottom-center",
|
|
59
|
+
"bottom-right"
|
|
60
|
+
].includes(String(x.toastPosition)))
|
|
61
|
+
d.toastPosition = x.toastPosition;
|
|
62
|
+
if (["top", "bottom", "left", "right"].includes(String(x.tooltipPlacement)))
|
|
63
|
+
d.tooltipPlacement = x.tooltipPlacement;
|
|
64
|
+
return d;
|
|
65
|
+
}
|
|
66
|
+
export {
|
|
67
|
+
appearanceDefaults,
|
|
68
|
+
normalizeAppearance
|
|
69
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
const emojiUrl = new URL("../assets/emoji.json", import.meta.url).href;
|
|
3
|
+
const symbolsUrl = new URL("../assets/symbols.json", import.meta.url).href;
|
|
4
|
+
import metadata from "../assets/character-metadata.json";
|
|
5
|
+
const cache = {}, pending = {};
|
|
6
|
+
const labels = metadata.groups, aliases = metadata.aliases;
|
|
7
|
+
function load(kind) {
|
|
8
|
+
return pending[kind] ||= fetch(kind === "emoji" ? emojiUrl : symbolsUrl).then((r) => {
|
|
9
|
+
if (!r.ok) throw Error("\u5B57\u7B26\u52A0\u8F7D\u5931\u8D25");
|
|
10
|
+
return r.json();
|
|
11
|
+
}).then((rows) => {
|
|
12
|
+
const groups = /* @__PURE__ */ new Map();
|
|
13
|
+
for (const [glyph, title, group, detail] of rows) {
|
|
14
|
+
if (!glyph.trim()) continue;
|
|
15
|
+
let item = groups.get(group);
|
|
16
|
+
if (!item) {
|
|
17
|
+
item = { name: labels[group]?.[0] || group, items: [] };
|
|
18
|
+
groups.set(group, item);
|
|
19
|
+
}
|
|
20
|
+
item.items.push([
|
|
21
|
+
glyph,
|
|
22
|
+
title,
|
|
23
|
+
[group, detail || "", aliases[glyph] || ""].join(" ")
|
|
24
|
+
]);
|
|
25
|
+
}
|
|
26
|
+
return cache[kind] = [...groups.values()];
|
|
27
|
+
}).catch((e) => {
|
|
28
|
+
delete pending[kind];
|
|
29
|
+
throw e;
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
function useCharacterCatalog(kind) {
|
|
33
|
+
const [groups, setGroups] = useState(cache[kind]), [error, setError] = useState(false), [revision, setRevision] = useState(0);
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
let active = true;
|
|
36
|
+
setError(false);
|
|
37
|
+
load(kind).then((data) => {
|
|
38
|
+
if (active) setGroups(data);
|
|
39
|
+
}).catch(() => {
|
|
40
|
+
if (active) setError(true);
|
|
41
|
+
});
|
|
42
|
+
return () => {
|
|
43
|
+
active = false;
|
|
44
|
+
};
|
|
45
|
+
}, [kind, revision]);
|
|
46
|
+
return {
|
|
47
|
+
groups: groups || [],
|
|
48
|
+
loading: !groups && !error,
|
|
49
|
+
error,
|
|
50
|
+
retry: () => setRevision((n) => n + 1)
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
export {
|
|
54
|
+
useCharacterCatalog
|
|
55
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
function toHSV(hex) {
|
|
2
|
+
const [r, g, b] = [1, 3, 5].map(
|
|
3
|
+
(i) => parseInt(hex.slice(i, i + 2), 16) / 255
|
|
4
|
+
), max = Math.max(r, g, b), min = Math.min(r, g, b), d = max - min;
|
|
5
|
+
let h = !d ? 0 : max === r ? (g - b) / d % 6 : max === g ? (b - r) / d + 2 : (r - g) / d + 4;
|
|
6
|
+
return { h: (h * 60 + 360) % 360, s: max ? d / max : 0, v: max };
|
|
7
|
+
}
|
|
8
|
+
function toHex({ h, s, v }) {
|
|
9
|
+
const f = (n) => {
|
|
10
|
+
const k = (n + h / 60) % 6;
|
|
11
|
+
return Math.round((v - v * s * Math.max(0, Math.min(k, 4 - k, 1))) * 255).toString(16).padStart(2, "0");
|
|
12
|
+
};
|
|
13
|
+
return "#" + f(5) + f(3) + f(1);
|
|
14
|
+
}
|
|
15
|
+
export {
|
|
16
|
+
toHSV,
|
|
17
|
+
toHex
|
|
18
|
+
};
|