@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,200 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback, useMemo, useRef, useState } from "react";
|
|
3
|
+
import { ArrowLeft } from "lucide-react";
|
|
4
|
+
import { Popover } from "./Popover.js";
|
|
5
|
+
import { SearchField } from "./SearchField.js";
|
|
6
|
+
import { SelectTrigger } from "./SelectTrigger.js";
|
|
7
|
+
import { Spinner } from "./Spinner.js";
|
|
8
|
+
import { Button } from "./Button.js";
|
|
9
|
+
import { SkinTonePicker } from "./SkinTonePicker.js";
|
|
10
|
+
import {
|
|
11
|
+
VirtualPickerList
|
|
12
|
+
} from "./VirtualPickerList.js";
|
|
13
|
+
import s from "./Picker.module.css";
|
|
14
|
+
function CharacterPicker({
|
|
15
|
+
value,
|
|
16
|
+
onChange,
|
|
17
|
+
label,
|
|
18
|
+
groups,
|
|
19
|
+
disabled,
|
|
20
|
+
loading,
|
|
21
|
+
error,
|
|
22
|
+
onRetry,
|
|
23
|
+
emoji = false
|
|
24
|
+
}) {
|
|
25
|
+
const anchor = useRef(null), [open, setOpen] = useState(false), [query, setQuery] = useState(""), [tone, setTone] = useState(0), [variants, setVariants] = useState();
|
|
26
|
+
const indexed = useMemo(
|
|
27
|
+
() => groups.map((group) => {
|
|
28
|
+
const families = /* @__PURE__ */ new Map();
|
|
29
|
+
for (const [glyph, title, detail = ""] of group.items) {
|
|
30
|
+
const id = emoji ? glyph.replace(/[\u{1F3FB}-\u{1F3FF}\uFE0F]/gu, "") : glyph;
|
|
31
|
+
let item = families.get(id);
|
|
32
|
+
if (!item) {
|
|
33
|
+
item = {
|
|
34
|
+
id,
|
|
35
|
+
label: title,
|
|
36
|
+
glyph,
|
|
37
|
+
search: "",
|
|
38
|
+
variants: emoji ? [] : void 0
|
|
39
|
+
};
|
|
40
|
+
families.set(id, item);
|
|
41
|
+
}
|
|
42
|
+
if (emoji) {
|
|
43
|
+
item.variants.push({ glyph, label: title });
|
|
44
|
+
if (!/[\u{1F3FB}-\u{1F3FF}]/u.test(glyph)) {
|
|
45
|
+
item.glyph = glyph;
|
|
46
|
+
item.label = title;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
item.search += " " + [glyph, title, group.name, detail].join(" ").toLowerCase();
|
|
50
|
+
}
|
|
51
|
+
return {
|
|
52
|
+
id: group.name,
|
|
53
|
+
label: group.name,
|
|
54
|
+
items: [...families.values()]
|
|
55
|
+
};
|
|
56
|
+
}),
|
|
57
|
+
[groups, emoji]
|
|
58
|
+
);
|
|
59
|
+
const catalog = useMemo(
|
|
60
|
+
() => !emoji || !tone ? indexed : indexed.map((group) => ({
|
|
61
|
+
...group,
|
|
62
|
+
items: group.items.map((item) => {
|
|
63
|
+
const variant = item.variants?.find((v) => {
|
|
64
|
+
const tones = [...v.glyph].filter(
|
|
65
|
+
(c) => /[\u{1F3FB}-\u{1F3FF}]/u.test(c)
|
|
66
|
+
);
|
|
67
|
+
return tones.length && tones.every((c) => c.codePointAt(0) === 127994 + tone);
|
|
68
|
+
});
|
|
69
|
+
return variant ? { ...item, glyph: variant.glyph, label: variant.label } : item;
|
|
70
|
+
})
|
|
71
|
+
})),
|
|
72
|
+
[indexed, tone, emoji]
|
|
73
|
+
);
|
|
74
|
+
const current = useMemo(
|
|
75
|
+
() => groups.flatMap((g) => g.items).find((i) => i[0] === value),
|
|
76
|
+
[groups, value]
|
|
77
|
+
), count = useMemo(
|
|
78
|
+
() => groups.reduce((n, g) => n + g.items.length, 0),
|
|
79
|
+
[groups]
|
|
80
|
+
);
|
|
81
|
+
const choose = useCallback(
|
|
82
|
+
(item) => {
|
|
83
|
+
onChange(item.glyph || item.id);
|
|
84
|
+
setOpen(false);
|
|
85
|
+
setVariants(void 0);
|
|
86
|
+
anchor.current?.focus();
|
|
87
|
+
},
|
|
88
|
+
[onChange]
|
|
89
|
+
);
|
|
90
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
91
|
+
/* @__PURE__ */ jsx(
|
|
92
|
+
SelectTrigger,
|
|
93
|
+
{
|
|
94
|
+
ref: anchor,
|
|
95
|
+
expanded: open,
|
|
96
|
+
disabled,
|
|
97
|
+
"aria-label": label,
|
|
98
|
+
"aria-haspopup": "dialog",
|
|
99
|
+
onClick: () => {
|
|
100
|
+
setOpen((v) => !v);
|
|
101
|
+
setVariants(void 0);
|
|
102
|
+
},
|
|
103
|
+
onKeyDown: (e) => {
|
|
104
|
+
if (e.key === "ArrowDown" || e.key === "ArrowUp") {
|
|
105
|
+
e.preventDefault();
|
|
106
|
+
setOpen(true);
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
icon: /* @__PURE__ */ jsx("span", { className: s.preview, children: value }),
|
|
110
|
+
children: /* @__PURE__ */ jsx("span", { children: current?.[1] || label })
|
|
111
|
+
}
|
|
112
|
+
),
|
|
113
|
+
/* @__PURE__ */ jsx(
|
|
114
|
+
Popover,
|
|
115
|
+
{
|
|
116
|
+
open,
|
|
117
|
+
onClose: () => {
|
|
118
|
+
setOpen(false);
|
|
119
|
+
setVariants(void 0);
|
|
120
|
+
},
|
|
121
|
+
anchor,
|
|
122
|
+
width: 470,
|
|
123
|
+
label: label + "\u9009\u62E9\u5668",
|
|
124
|
+
children: /* @__PURE__ */ jsxs("div", { className: s.panel, children: [
|
|
125
|
+
/* @__PURE__ */ jsx(
|
|
126
|
+
SearchField,
|
|
127
|
+
{
|
|
128
|
+
label: "\u641C\u7D22" + label,
|
|
129
|
+
value: query,
|
|
130
|
+
onChange: (v) => {
|
|
131
|
+
setQuery(v);
|
|
132
|
+
setVariants(void 0);
|
|
133
|
+
},
|
|
134
|
+
placeholder: "\u641C\u7D22\u540D\u79F0\u3001\u5206\u7C7B\u6216\u5B57\u7B26"
|
|
135
|
+
}
|
|
136
|
+
),
|
|
137
|
+
emoji && /* @__PURE__ */ jsx(SkinTonePicker, { value: tone, onChange: setTone }),
|
|
138
|
+
loading ? /* @__PURE__ */ jsx("div", { className: s.loading, children: /* @__PURE__ */ jsx(Spinner, { label: "\u52A0\u8F7D\u5B57\u7B26" }) }) : error ? /* @__PURE__ */ jsx(Button, { onClick: onRetry, children: "\u91CD\u65B0\u52A0\u8F7D" }) : variants ? /* @__PURE__ */ jsxs("div", { className: s.variantPanel, children: [
|
|
139
|
+
/* @__PURE__ */ jsxs(
|
|
140
|
+
Button,
|
|
141
|
+
{
|
|
142
|
+
variant: "ghost",
|
|
143
|
+
size: "small",
|
|
144
|
+
onClick: () => setVariants(void 0),
|
|
145
|
+
children: [
|
|
146
|
+
/* @__PURE__ */ jsx(ArrowLeft, {}),
|
|
147
|
+
"\u8FD4\u56DE"
|
|
148
|
+
]
|
|
149
|
+
}
|
|
150
|
+
),
|
|
151
|
+
/* @__PURE__ */ jsx(
|
|
152
|
+
"div",
|
|
153
|
+
{
|
|
154
|
+
className: s.variantGrid,
|
|
155
|
+
role: "group",
|
|
156
|
+
"aria-label": "Emoji \u53D8\u4F53",
|
|
157
|
+
children: variants.variants?.map((item) => /* @__PURE__ */ jsx(
|
|
158
|
+
"button",
|
|
159
|
+
{
|
|
160
|
+
type: "button",
|
|
161
|
+
"data-character": item.glyph,
|
|
162
|
+
className: s.cell,
|
|
163
|
+
"aria-label": item.label,
|
|
164
|
+
title: item.label,
|
|
165
|
+
onClick: () => choose({
|
|
166
|
+
id: item.glyph,
|
|
167
|
+
label: item.label,
|
|
168
|
+
glyph: item.glyph,
|
|
169
|
+
search: ""
|
|
170
|
+
}),
|
|
171
|
+
children: item.glyph
|
|
172
|
+
},
|
|
173
|
+
item.glyph
|
|
174
|
+
))
|
|
175
|
+
}
|
|
176
|
+
)
|
|
177
|
+
] }) : /* @__PURE__ */ jsx(
|
|
178
|
+
VirtualPickerList,
|
|
179
|
+
{
|
|
180
|
+
groups: catalog,
|
|
181
|
+
query,
|
|
182
|
+
value,
|
|
183
|
+
label,
|
|
184
|
+
onChoose: choose,
|
|
185
|
+
onVariants: emoji ? setVariants : void 0
|
|
186
|
+
}
|
|
187
|
+
),
|
|
188
|
+
/* @__PURE__ */ jsx("div", { className: s.footer, children: /* @__PURE__ */ jsxs("span", { children: [
|
|
189
|
+
count,
|
|
190
|
+
" \u4E2A",
|
|
191
|
+
emoji ? "Emoji" : "\u7B26\u53F7"
|
|
192
|
+
] }) })
|
|
193
|
+
] })
|
|
194
|
+
}
|
|
195
|
+
)
|
|
196
|
+
] });
|
|
197
|
+
}
|
|
198
|
+
export {
|
|
199
|
+
CharacterPicker
|
|
200
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type FieldOptions } from "./field";
|
|
2
|
+
export declare function Checkbox({ label, checked, onChange, disabled, indeterminate, name, value, required, readOnly, id, error, hint, }: FieldOptions & {
|
|
3
|
+
label: string;
|
|
4
|
+
checked: boolean;
|
|
5
|
+
onChange(value: boolean): void;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
name?: string;
|
|
8
|
+
value?: string;
|
|
9
|
+
required?: boolean;
|
|
10
|
+
readOnly?: boolean;
|
|
11
|
+
indeterminate?: boolean;
|
|
12
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { FieldLabel } from "./FieldLabel.js";
|
|
3
|
+
import { useFieldControl } from "./field.js";
|
|
4
|
+
import { useEffect, useRef } from "react";
|
|
5
|
+
import s from "./Checkbox.module.css";
|
|
6
|
+
function Checkbox({
|
|
7
|
+
label,
|
|
8
|
+
checked,
|
|
9
|
+
onChange,
|
|
10
|
+
disabled,
|
|
11
|
+
indeterminate = false,
|
|
12
|
+
name,
|
|
13
|
+
value,
|
|
14
|
+
required,
|
|
15
|
+
readOnly,
|
|
16
|
+
id,
|
|
17
|
+
error,
|
|
18
|
+
hint
|
|
19
|
+
}) {
|
|
20
|
+
const field = useFieldControl({
|
|
21
|
+
id,
|
|
22
|
+
name,
|
|
23
|
+
label,
|
|
24
|
+
disabled,
|
|
25
|
+
required,
|
|
26
|
+
readOnly,
|
|
27
|
+
error,
|
|
28
|
+
hint
|
|
29
|
+
});
|
|
30
|
+
const ref = useRef(null);
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
if (ref.current) ref.current.indeterminate = indeterminate;
|
|
33
|
+
}, [indeterminate]);
|
|
34
|
+
return /* @__PURE__ */ jsxs(
|
|
35
|
+
"label",
|
|
36
|
+
{
|
|
37
|
+
className: s.checkbox,
|
|
38
|
+
"data-disabled": field.disabled,
|
|
39
|
+
"data-indeterminate": indeterminate,
|
|
40
|
+
children: [
|
|
41
|
+
/* @__PURE__ */ jsx(
|
|
42
|
+
"input",
|
|
43
|
+
{
|
|
44
|
+
id: field.id,
|
|
45
|
+
"aria-invalid": field.invalid,
|
|
46
|
+
"aria-describedby": field.descriptionId,
|
|
47
|
+
ref,
|
|
48
|
+
"aria-checked": indeterminate ? "mixed" : checked,
|
|
49
|
+
type: "checkbox",
|
|
50
|
+
name: field.name,
|
|
51
|
+
value,
|
|
52
|
+
required: field.required,
|
|
53
|
+
"aria-readonly": field.readOnly || void 0,
|
|
54
|
+
checked,
|
|
55
|
+
onChange: (e) => {
|
|
56
|
+
if (!field.readOnly) onChange(e.target.checked);
|
|
57
|
+
},
|
|
58
|
+
disabled: field.disabled
|
|
59
|
+
}
|
|
60
|
+
),
|
|
61
|
+
/* @__PURE__ */ jsx("span", { className: s.checkMark, "aria-hidden": "true", children: /* @__PURE__ */ jsx("svg", { viewBox: "0 0 16 16", children: /* @__PURE__ */ jsx(
|
|
62
|
+
"path",
|
|
63
|
+
{
|
|
64
|
+
d: indeterminate ? "M4 8h8" : "m3.5 8 3 3 6-6",
|
|
65
|
+
pathLength: "1"
|
|
66
|
+
}
|
|
67
|
+
) }) }),
|
|
68
|
+
/* @__PURE__ */ jsx(
|
|
69
|
+
FieldLabel,
|
|
70
|
+
{
|
|
71
|
+
as: "span",
|
|
72
|
+
label,
|
|
73
|
+
required: !field.wrapped && field.required
|
|
74
|
+
}
|
|
75
|
+
)
|
|
76
|
+
]
|
|
77
|
+
}
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
export {
|
|
81
|
+
Checkbox
|
|
82
|
+
};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
.checkbox {
|
|
2
|
+
display: inline-flex;
|
|
3
|
+
align-items: center;
|
|
4
|
+
gap: 9px;
|
|
5
|
+
cursor: pointer;
|
|
6
|
+
position: relative;
|
|
7
|
+
user-select: none;
|
|
8
|
+
}
|
|
9
|
+
.checkbox input[type="checkbox"] {
|
|
10
|
+
position: absolute;
|
|
11
|
+
left: 0;
|
|
12
|
+
width: 18px;
|
|
13
|
+
height: 18px;
|
|
14
|
+
margin: 0;
|
|
15
|
+
opacity: 0;
|
|
16
|
+
}
|
|
17
|
+
.checkMark {
|
|
18
|
+
width: 18px;
|
|
19
|
+
height: 18px;
|
|
20
|
+
flex-shrink: 0;
|
|
21
|
+
border: 1px solid color-mix(in srgb, var(--fg) 25%, var(--surface));
|
|
22
|
+
border-radius: 5px;
|
|
23
|
+
background: var(--field);
|
|
24
|
+
display: grid;
|
|
25
|
+
place-items: center;
|
|
26
|
+
pointer-events: none;
|
|
27
|
+
transition:
|
|
28
|
+
background-color var(--motion-hover),
|
|
29
|
+
border-color var(--motion-hover),
|
|
30
|
+
box-shadow var(--motion-hover),
|
|
31
|
+
transform var(--motion-press);
|
|
32
|
+
}
|
|
33
|
+
.checkMark svg {
|
|
34
|
+
width: 16px;
|
|
35
|
+
height: 16px;
|
|
36
|
+
fill: none;
|
|
37
|
+
stroke: currentColor;
|
|
38
|
+
stroke-width: 1.8;
|
|
39
|
+
stroke-linecap: round;
|
|
40
|
+
stroke-linejoin: round;
|
|
41
|
+
}
|
|
42
|
+
.checkMark path {
|
|
43
|
+
stroke-dasharray: 1;
|
|
44
|
+
stroke-dashoffset: 1;
|
|
45
|
+
opacity: 0;
|
|
46
|
+
transition:
|
|
47
|
+
stroke-dashoffset var(--motion-panel) var(--ease),
|
|
48
|
+
opacity var(--motion-hover);
|
|
49
|
+
}
|
|
50
|
+
.checkbox:hover input:not(:disabled) + .checkMark {
|
|
51
|
+
border-color: var(--muted);
|
|
52
|
+
}
|
|
53
|
+
.checkbox:active input:not(:disabled) + .checkMark {
|
|
54
|
+
transform: scale(0.92);
|
|
55
|
+
}
|
|
56
|
+
.checkbox input:checked + .checkMark {
|
|
57
|
+
background: var(--accent-fill, var(--accent));
|
|
58
|
+
color: var(--on-accent-fill, var(--on-accent));
|
|
59
|
+
border-color: var(--accent-fill, var(--accent));
|
|
60
|
+
}
|
|
61
|
+
.checkbox input:checked + .checkMark path {
|
|
62
|
+
stroke-dashoffset: 0;
|
|
63
|
+
opacity: 1;
|
|
64
|
+
}
|
|
65
|
+
.checkbox input:focus-visible + .checkMark {
|
|
66
|
+
box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent);
|
|
67
|
+
border-color: var(--accent);
|
|
68
|
+
}
|
|
69
|
+
.checkbox[data-disabled="true"] {
|
|
70
|
+
cursor: not-allowed;
|
|
71
|
+
}
|
|
72
|
+
.checkbox input:disabled ~ span {
|
|
73
|
+
opacity: 0.4;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.checkbox[data-indeterminate="true"] .checkMark {
|
|
77
|
+
background: var(--accent);
|
|
78
|
+
border-color: var(--accent);
|
|
79
|
+
color: var(--on-accent);
|
|
80
|
+
}
|
|
81
|
+
.checkbox[data-indeterminate="true"] .checkMark svg {
|
|
82
|
+
opacity: 1;
|
|
83
|
+
transform: scale(1);
|
|
84
|
+
}
|
|
85
|
+
.checkbox[data-indeterminate="true"] .checkMark path {
|
|
86
|
+
stroke-dashoffset: 0;
|
|
87
|
+
opacity: 1;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.checkbox input[aria-invalid="true"] + .checkMark {
|
|
91
|
+
border-color: var(--danger);
|
|
92
|
+
}
|
|
93
|
+
.checkbox input[aria-invalid="true"]:focus-visible + .checkMark {
|
|
94
|
+
box-shadow: 0 0 0 2px color-mix(in srgb, var(--danger) 12%, transparent);
|
|
95
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { fieldTriggerProps, useFieldControl } from "./field.js";
|
|
3
|
+
import { useId } from "react";
|
|
4
|
+
import { Popover } from "./Popover.js";
|
|
5
|
+
import { usePopover } from "./usePopover.js";
|
|
6
|
+
import { ColorPicker } from "./ColorPicker.js";
|
|
7
|
+
import s from "./ColorField.module.css";
|
|
8
|
+
function ColorField({
|
|
9
|
+
value,
|
|
10
|
+
onChange,
|
|
11
|
+
label,
|
|
12
|
+
...options
|
|
13
|
+
}) {
|
|
14
|
+
const field = useFieldControl({ ...options, label });
|
|
15
|
+
const pop = usePopover(field.disabled || field.readOnly), id = useId();
|
|
16
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
17
|
+
/* @__PURE__ */ jsxs(
|
|
18
|
+
"button",
|
|
19
|
+
{
|
|
20
|
+
...fieldTriggerProps(field),
|
|
21
|
+
role: "combobox",
|
|
22
|
+
ref: pop.anchor,
|
|
23
|
+
type: "button",
|
|
24
|
+
className: s.trigger,
|
|
25
|
+
"aria-label": "\u9009\u62E9\u989C\u8272 \xB7 " + label,
|
|
26
|
+
"aria-haspopup": "dialog",
|
|
27
|
+
"aria-controls": id,
|
|
28
|
+
"aria-expanded": pop.open,
|
|
29
|
+
onClick: pop.toggle,
|
|
30
|
+
children: [
|
|
31
|
+
/* @__PURE__ */ jsx("i", { style: { background: value }, "aria-hidden": "true" }),
|
|
32
|
+
/* @__PURE__ */ jsx("span", { children: value.toUpperCase() })
|
|
33
|
+
]
|
|
34
|
+
}
|
|
35
|
+
),
|
|
36
|
+
field.name && /* @__PURE__ */ jsx(
|
|
37
|
+
"input",
|
|
38
|
+
{
|
|
39
|
+
type: "hidden",
|
|
40
|
+
name: field.name,
|
|
41
|
+
value,
|
|
42
|
+
disabled: field.disabled
|
|
43
|
+
}
|
|
44
|
+
),
|
|
45
|
+
/* @__PURE__ */ jsx(
|
|
46
|
+
Popover,
|
|
47
|
+
{
|
|
48
|
+
open: pop.open,
|
|
49
|
+
onClose: pop.close,
|
|
50
|
+
anchor: pop.anchor,
|
|
51
|
+
width: 280,
|
|
52
|
+
label: label + " \u989C\u8272\u9009\u62E9\u5668",
|
|
53
|
+
id,
|
|
54
|
+
children: /* @__PURE__ */ jsx(ColorPicker, { value, onChange, label })
|
|
55
|
+
}
|
|
56
|
+
)
|
|
57
|
+
] });
|
|
58
|
+
}
|
|
59
|
+
export {
|
|
60
|
+
ColorField
|
|
61
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
.trigger {
|
|
2
|
+
composes: surface from "./Control.module.css";
|
|
3
|
+
display: inline-flex;
|
|
4
|
+
align-items: center;
|
|
5
|
+
gap: 8px;
|
|
6
|
+
padding: 5px 9px;
|
|
7
|
+
min-width: 118px;
|
|
8
|
+
font-variant-numeric: tabular-nums;
|
|
9
|
+
}
|
|
10
|
+
.trigger i {
|
|
11
|
+
width: 16px;
|
|
12
|
+
height: 16px;
|
|
13
|
+
border-radius: 5px;
|
|
14
|
+
border: 1px solid #80808040;
|
|
15
|
+
}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useRef, useState } from "react";
|
|
3
|
+
import { Input } from "./Input.js";
|
|
4
|
+
import { NumberInput } from "./NumberInput.js";
|
|
5
|
+
import { toHSV, toHex } from "./color.js";
|
|
6
|
+
import s from "./ColorPicker.module.css";
|
|
7
|
+
const presets = [
|
|
8
|
+
"#ffffff",
|
|
9
|
+
"#202020",
|
|
10
|
+
"#808080",
|
|
11
|
+
"#e5484d",
|
|
12
|
+
"#e79230",
|
|
13
|
+
"#f5d90a",
|
|
14
|
+
"#46a758",
|
|
15
|
+
"#12a594",
|
|
16
|
+
"#0090ff",
|
|
17
|
+
"#6e56cf",
|
|
18
|
+
"#ab4aba",
|
|
19
|
+
"#e93d82",
|
|
20
|
+
"#4479d8",
|
|
21
|
+
"#6d61bd",
|
|
22
|
+
"#41886c",
|
|
23
|
+
"#b67838"
|
|
24
|
+
];
|
|
25
|
+
function ColorPicker({
|
|
26
|
+
value,
|
|
27
|
+
onChange,
|
|
28
|
+
label
|
|
29
|
+
}) {
|
|
30
|
+
const [hsv, setHSV] = useState(() => toHSV(value)), [draft, setDraft] = useState(value.toUpperCase()), [invalid, setInvalid] = useState(false);
|
|
31
|
+
const last = useRef(value), pointer = useRef(void 0);
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
setDraft(value.toUpperCase());
|
|
34
|
+
setInvalid(false);
|
|
35
|
+
if (value !== last.current) setHSV(toHSV(value));
|
|
36
|
+
last.current = value;
|
|
37
|
+
}, [value]);
|
|
38
|
+
const apply = (next) => {
|
|
39
|
+
setHSV(next);
|
|
40
|
+
const hex = toHex(next);
|
|
41
|
+
last.current = hex;
|
|
42
|
+
setDraft(hex.toUpperCase());
|
|
43
|
+
setInvalid(false);
|
|
44
|
+
onChange(hex);
|
|
45
|
+
};
|
|
46
|
+
const pick = (event) => {
|
|
47
|
+
const box = event.currentTarget.getBoundingClientRect();
|
|
48
|
+
apply({
|
|
49
|
+
...hsv,
|
|
50
|
+
s: Math.max(0, Math.min(1, (event.clientX - box.left) / box.width)),
|
|
51
|
+
v: 1 - Math.max(0, Math.min(1, (event.clientY - box.top) / box.height))
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
const commit = () => {
|
|
55
|
+
const hex = draft.startsWith("#") ? draft : "#" + draft;
|
|
56
|
+
if (/^#[\da-f]{6}$/i.test(hex)) apply(toHSV(hex));
|
|
57
|
+
else setInvalid(true);
|
|
58
|
+
};
|
|
59
|
+
const channels = [1, 3, 5].map((i) => parseInt(value.slice(i, i + 2), 16));
|
|
60
|
+
return /* @__PURE__ */ jsxs("div", { className: s.panel, children: [
|
|
61
|
+
/* @__PURE__ */ jsx(
|
|
62
|
+
"div",
|
|
63
|
+
{
|
|
64
|
+
className: s.plane,
|
|
65
|
+
tabIndex: 0,
|
|
66
|
+
role: "slider",
|
|
67
|
+
"data-autofocus": true,
|
|
68
|
+
"aria-label": label + " \u8272\u5F69",
|
|
69
|
+
"aria-valuemin": 0,
|
|
70
|
+
"aria-valuemax": 100,
|
|
71
|
+
"aria-valuenow": Math.round(hsv.s * 100),
|
|
72
|
+
"aria-valuetext": value,
|
|
73
|
+
style: { backgroundColor: toHex({ h: hsv.h, s: 1, v: 1 }) },
|
|
74
|
+
onPointerDown: (e) => {
|
|
75
|
+
if (e.button !== 0) return;
|
|
76
|
+
e.preventDefault();
|
|
77
|
+
e.currentTarget.focus();
|
|
78
|
+
pointer.current = e.pointerId;
|
|
79
|
+
e.currentTarget.setPointerCapture(e.pointerId);
|
|
80
|
+
pick(e);
|
|
81
|
+
},
|
|
82
|
+
onPointerMove: (e) => {
|
|
83
|
+
if (pointer.current === e.pointerId) pick(e);
|
|
84
|
+
},
|
|
85
|
+
onPointerUp: (e) => {
|
|
86
|
+
if (e.currentTarget.hasPointerCapture(e.pointerId))
|
|
87
|
+
e.currentTarget.releasePointerCapture(e.pointerId);
|
|
88
|
+
pointer.current = void 0;
|
|
89
|
+
},
|
|
90
|
+
onPointerCancel: () => {
|
|
91
|
+
pointer.current = void 0;
|
|
92
|
+
},
|
|
93
|
+
onKeyDown: (e) => {
|
|
94
|
+
if (!e.key.startsWith("Arrow")) return;
|
|
95
|
+
e.preventDefault();
|
|
96
|
+
const step = e.shiftKey ? 0.1 : 0.02;
|
|
97
|
+
apply({
|
|
98
|
+
...hsv,
|
|
99
|
+
s: Math.max(
|
|
100
|
+
0,
|
|
101
|
+
Math.min(
|
|
102
|
+
1,
|
|
103
|
+
hsv.s + (e.key === "ArrowRight" ? step : e.key === "ArrowLeft" ? -step : 0)
|
|
104
|
+
)
|
|
105
|
+
),
|
|
106
|
+
v: Math.max(
|
|
107
|
+
0,
|
|
108
|
+
Math.min(
|
|
109
|
+
1,
|
|
110
|
+
hsv.v + (e.key === "ArrowUp" ? step : e.key === "ArrowDown" ? -step : 0)
|
|
111
|
+
)
|
|
112
|
+
)
|
|
113
|
+
});
|
|
114
|
+
},
|
|
115
|
+
children: /* @__PURE__ */ jsx(
|
|
116
|
+
"span",
|
|
117
|
+
{
|
|
118
|
+
className: s.marker,
|
|
119
|
+
style: { left: hsv.s * 100 + "%", top: (1 - hsv.v) * 100 + "%" }
|
|
120
|
+
}
|
|
121
|
+
)
|
|
122
|
+
}
|
|
123
|
+
),
|
|
124
|
+
/* @__PURE__ */ jsx(
|
|
125
|
+
"input",
|
|
126
|
+
{
|
|
127
|
+
className: s.hue,
|
|
128
|
+
type: "range",
|
|
129
|
+
min: 0,
|
|
130
|
+
max: 359,
|
|
131
|
+
value: hsv.h,
|
|
132
|
+
"aria-label": label + " \u8272\u8C03",
|
|
133
|
+
onChange: (e) => apply({ ...hsv, h: Number(e.target.value) })
|
|
134
|
+
}
|
|
135
|
+
),
|
|
136
|
+
/* @__PURE__ */ jsx("div", { className: s.presets, children: presets.map((color) => /* @__PURE__ */ jsx(
|
|
137
|
+
"button",
|
|
138
|
+
{
|
|
139
|
+
type: "button",
|
|
140
|
+
"aria-label": "\u9884\u8BBE\u8272 " + color,
|
|
141
|
+
"aria-pressed": value.toLowerCase() === color,
|
|
142
|
+
style: { background: color },
|
|
143
|
+
onClick: () => apply(toHSV(color))
|
|
144
|
+
},
|
|
145
|
+
color
|
|
146
|
+
)) }),
|
|
147
|
+
/* @__PURE__ */ jsx(
|
|
148
|
+
Input,
|
|
149
|
+
{
|
|
150
|
+
label: "HEX",
|
|
151
|
+
"aria-label": label + " HEX",
|
|
152
|
+
value: draft,
|
|
153
|
+
maxLength: 7,
|
|
154
|
+
spellCheck: false,
|
|
155
|
+
error: invalid ? "\u4F7F\u7528 #RRGGBB \u683C\u5F0F" : void 0,
|
|
156
|
+
onChange: (e) => setDraft(e.target.value),
|
|
157
|
+
onBlur: commit,
|
|
158
|
+
onKeyDown: (e) => {
|
|
159
|
+
if (e.key === "Enter") commit();
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
),
|
|
163
|
+
/* @__PURE__ */ jsx("div", { className: s.rgb, children: ["R", "G", "B"].map((channel, index) => /* @__PURE__ */ jsxs("label", { children: [
|
|
164
|
+
/* @__PURE__ */ jsx("span", { children: channel }),
|
|
165
|
+
/* @__PURE__ */ jsx(
|
|
166
|
+
NumberInput,
|
|
167
|
+
{
|
|
168
|
+
label: label + " RGB " + channel,
|
|
169
|
+
min: 0,
|
|
170
|
+
max: 255,
|
|
171
|
+
value: channels[index],
|
|
172
|
+
onChange: (next) => {
|
|
173
|
+
const values = [...channels];
|
|
174
|
+
values[index] = next;
|
|
175
|
+
apply(
|
|
176
|
+
toHSV(
|
|
177
|
+
"#" + values.map((v) => v.toString(16).padStart(2, "0")).join("")
|
|
178
|
+
)
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
)
|
|
183
|
+
] }, channel)) })
|
|
184
|
+
] });
|
|
185
|
+
}
|
|
186
|
+
export {
|
|
187
|
+
ColorPicker
|
|
188
|
+
};
|