@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,27 @@
|
|
|
1
|
+
.summary {
|
|
2
|
+
padding: 12px 14px;
|
|
3
|
+
border: 1px solid color-mix(in srgb, var(--danger) 30%, var(--surface));
|
|
4
|
+
border-radius: var(--radius);
|
|
5
|
+
background: color-mix(in srgb, var(--danger) 5%, var(--surface));
|
|
6
|
+
color: var(--danger);
|
|
7
|
+
font-size: 12px;
|
|
8
|
+
line-height: 1.6;
|
|
9
|
+
}
|
|
10
|
+
.summary strong {
|
|
11
|
+
font-weight: 550;
|
|
12
|
+
}
|
|
13
|
+
.summary ul {
|
|
14
|
+
margin: 5px 0 0;
|
|
15
|
+
padding-left: 18px;
|
|
16
|
+
}
|
|
17
|
+
.summary button {
|
|
18
|
+
border: 0;
|
|
19
|
+
background: transparent;
|
|
20
|
+
color: inherit;
|
|
21
|
+
text-align: left;
|
|
22
|
+
padding: 2px 0;
|
|
23
|
+
font-size: 12px;
|
|
24
|
+
}
|
|
25
|
+
.summary button:hover {
|
|
26
|
+
text-decoration: underline;
|
|
27
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
import type { FieldOptions } from "./field";
|
|
3
|
+
export declare function FormField({ children, pending, requiredIndicator, optional, onBlur, ...options }: FieldOptions & {
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
pending?: boolean;
|
|
6
|
+
requiredIndicator?: "asterisk" | "text" | "none";
|
|
7
|
+
optional?: boolean;
|
|
8
|
+
onBlur?(): void;
|
|
9
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useUIConfig } from "./UIProvider.js";
|
|
3
|
+
import { FieldMessages } from "./FieldMessages.js";
|
|
4
|
+
import { Spinner } from "./Spinner.js";
|
|
5
|
+
import { useRef } from "react";
|
|
6
|
+
import { FieldContext, useFieldControl } from "./field.js";
|
|
7
|
+
import { FieldLabel } from "./FieldLabel.js";
|
|
8
|
+
import s from "./FormField.module.css";
|
|
9
|
+
function FormField({
|
|
10
|
+
children,
|
|
11
|
+
pending = false,
|
|
12
|
+
requiredIndicator,
|
|
13
|
+
optional = false,
|
|
14
|
+
onBlur,
|
|
15
|
+
...options
|
|
16
|
+
}) {
|
|
17
|
+
const config = useUIConfig();
|
|
18
|
+
const field = useFieldControl(options), root = useRef(null);
|
|
19
|
+
return /* @__PURE__ */ jsx(FieldContext, { value: field, children: /* @__PURE__ */ jsxs(
|
|
20
|
+
"div",
|
|
21
|
+
{
|
|
22
|
+
ref: root,
|
|
23
|
+
className: s.field,
|
|
24
|
+
"data-invalid": !!field.error,
|
|
25
|
+
"data-disabled": field.disabled || void 0,
|
|
26
|
+
onBlur: (event) => {
|
|
27
|
+
const next = event.relatedTarget, node = root.current;
|
|
28
|
+
if (next && node.contains(next)) return;
|
|
29
|
+
const portals = [...node.querySelectorAll("[aria-controls]")].map(
|
|
30
|
+
(control) => document.getElementById(
|
|
31
|
+
control.getAttribute("aria-controls") || ""
|
|
32
|
+
)
|
|
33
|
+
);
|
|
34
|
+
if (next && portals.some((portal) => portal?.contains(next))) return;
|
|
35
|
+
onBlur?.();
|
|
36
|
+
},
|
|
37
|
+
children: [
|
|
38
|
+
/* @__PURE__ */ jsxs("div", { className: s.labelRow, children: [
|
|
39
|
+
/* @__PURE__ */ jsx(
|
|
40
|
+
FieldLabel,
|
|
41
|
+
{
|
|
42
|
+
label: field.label,
|
|
43
|
+
htmlFor: field.id,
|
|
44
|
+
required: field.required,
|
|
45
|
+
indicator: requiredIndicator ?? config.requiredIndicator,
|
|
46
|
+
optional
|
|
47
|
+
}
|
|
48
|
+
),
|
|
49
|
+
pending && /* @__PURE__ */ jsx(Spinner, { size: 13, label: "\u6B63\u5728\u6821\u9A8C" + field.label })
|
|
50
|
+
] }),
|
|
51
|
+
children,
|
|
52
|
+
/* @__PURE__ */ jsx(FieldMessages, { id: field.id, hint: field.hint, error: field.error })
|
|
53
|
+
]
|
|
54
|
+
}
|
|
55
|
+
) });
|
|
56
|
+
}
|
|
57
|
+
export {
|
|
58
|
+
FormField
|
|
59
|
+
};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
.field {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: column;
|
|
4
|
+
gap: 7px;
|
|
5
|
+
min-width: 0;
|
|
6
|
+
}
|
|
7
|
+
.label {
|
|
8
|
+
display: inline-flex;
|
|
9
|
+
align-items: baseline;
|
|
10
|
+
gap: 5px;
|
|
11
|
+
font-size: 12px;
|
|
12
|
+
color: var(--fg);
|
|
13
|
+
}
|
|
14
|
+
.required {
|
|
15
|
+
color: var(--danger);
|
|
16
|
+
font-size: 12px;
|
|
17
|
+
line-height: 1;
|
|
18
|
+
}
|
|
19
|
+
.optional {
|
|
20
|
+
color: var(--muted);
|
|
21
|
+
font-size: 11px;
|
|
22
|
+
}
|
|
23
|
+
.hint,
|
|
24
|
+
.error {
|
|
25
|
+
font-size: 11px;
|
|
26
|
+
line-height: 1.5;
|
|
27
|
+
margin: 0;
|
|
28
|
+
}
|
|
29
|
+
.hint {
|
|
30
|
+
color: var(--muted);
|
|
31
|
+
}
|
|
32
|
+
.error {
|
|
33
|
+
color: var(--danger);
|
|
34
|
+
}
|
|
35
|
+
.field[data-disabled="true"] > .labelRow > .label,
|
|
36
|
+
.field:has(
|
|
37
|
+
> input:disabled,
|
|
38
|
+
> textarea:disabled,
|
|
39
|
+
> button:disabled,
|
|
40
|
+
> div > input:disabled,
|
|
41
|
+
> label > input:disabled,
|
|
42
|
+
> fieldset:disabled
|
|
43
|
+
)
|
|
44
|
+
> .labelRow
|
|
45
|
+
> .label {
|
|
46
|
+
opacity: 0.55;
|
|
47
|
+
}
|
|
48
|
+
.group {
|
|
49
|
+
display: flex;
|
|
50
|
+
flex-direction: column;
|
|
51
|
+
gap: 12px;
|
|
52
|
+
min-width: 0;
|
|
53
|
+
border: 0;
|
|
54
|
+
padding: 0;
|
|
55
|
+
margin: 0;
|
|
56
|
+
}
|
|
57
|
+
.group > legend {
|
|
58
|
+
padding: 0;
|
|
59
|
+
margin-bottom: 10px;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.labelRow {
|
|
63
|
+
display: flex;
|
|
64
|
+
align-items: center;
|
|
65
|
+
justify-content: space-between;
|
|
66
|
+
gap: var(--field-gap);
|
|
67
|
+
}
|
|
68
|
+
.field {
|
|
69
|
+
width: 100%;
|
|
70
|
+
gap: 8px;
|
|
71
|
+
}
|
|
72
|
+
.field > .labelRow:empty {
|
|
73
|
+
display: none;
|
|
74
|
+
}
|
|
75
|
+
.field > [role="combobox"] {
|
|
76
|
+
width: var(--field-trigger-width);
|
|
77
|
+
max-width: 100%;
|
|
78
|
+
}
|
|
79
|
+
.label {
|
|
80
|
+
font-size: var(--field-label-size);
|
|
81
|
+
}
|
|
82
|
+
.hint,
|
|
83
|
+
.error {
|
|
84
|
+
font-size: var(--field-message-size);
|
|
85
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
export declare function FormGroup({ label, children, disabled, required, hint, error, }: {
|
|
3
|
+
label: string;
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
required?: boolean;
|
|
7
|
+
hint?: string;
|
|
8
|
+
error?: string;
|
|
9
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { FieldMessages } from "./FieldMessages.js";
|
|
3
|
+
import { useId } from "react";
|
|
4
|
+
import { FieldLabel } from "./FieldLabel.js";
|
|
5
|
+
import s from "./FormField.module.css";
|
|
6
|
+
function FormGroup({
|
|
7
|
+
label,
|
|
8
|
+
children,
|
|
9
|
+
disabled = false,
|
|
10
|
+
required = false,
|
|
11
|
+
hint,
|
|
12
|
+
error
|
|
13
|
+
}) {
|
|
14
|
+
const id = useId();
|
|
15
|
+
return /* @__PURE__ */ jsxs(
|
|
16
|
+
"fieldset",
|
|
17
|
+
{
|
|
18
|
+
className: s.group,
|
|
19
|
+
disabled,
|
|
20
|
+
"aria-invalid": !!error,
|
|
21
|
+
"aria-describedby": [hint ? id + "-hint" : "", error ? id + "-error" : ""].filter(Boolean).join(" ") || void 0,
|
|
22
|
+
children: [
|
|
23
|
+
/* @__PURE__ */ jsx("legend", { children: /* @__PURE__ */ jsx(FieldLabel, { as: "span", label, required }) }),
|
|
24
|
+
children,
|
|
25
|
+
/* @__PURE__ */ jsx(FieldMessages, { id, hint, error })
|
|
26
|
+
]
|
|
27
|
+
}
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
export {
|
|
31
|
+
FormGroup
|
|
32
|
+
};
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
.trigger {
|
|
2
|
+
width: 280px;
|
|
3
|
+
max-width: 100%;
|
|
4
|
+
min-width: 0;
|
|
5
|
+
}
|
|
6
|
+
.search {
|
|
7
|
+
margin: 3px 3px 8px;
|
|
8
|
+
}
|
|
9
|
+
.tree {
|
|
10
|
+
composes: stack from "./OptionList.module.css";
|
|
11
|
+
max-height: 292px;
|
|
12
|
+
overflow: auto;
|
|
13
|
+
padding: 2px;
|
|
14
|
+
}
|
|
15
|
+
.row {
|
|
16
|
+
padding-left: calc(var(--menu-item-padding-x) + var(--level, 0) * 18px);
|
|
17
|
+
}
|
|
18
|
+
.row:focus-visible {
|
|
19
|
+
outline: none;
|
|
20
|
+
box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent);
|
|
21
|
+
}
|
|
22
|
+
.expander,
|
|
23
|
+
.spacer {
|
|
24
|
+
display: inline-grid;
|
|
25
|
+
place-items: center;
|
|
26
|
+
flex: 0 0 18px;
|
|
27
|
+
width: 18px;
|
|
28
|
+
height: 20px;
|
|
29
|
+
}
|
|
30
|
+
.expander {
|
|
31
|
+
padding: 0;
|
|
32
|
+
border: 0;
|
|
33
|
+
border-radius: 4px;
|
|
34
|
+
background: transparent;
|
|
35
|
+
color: var(--muted);
|
|
36
|
+
}
|
|
37
|
+
.expander:hover {
|
|
38
|
+
background: var(--selected);
|
|
39
|
+
}
|
|
40
|
+
.expander svg {
|
|
41
|
+
width: 13px;
|
|
42
|
+
height: 13px;
|
|
43
|
+
transform: rotate(-90deg);
|
|
44
|
+
transition: transform var(--motion-chevron) var(--ease);
|
|
45
|
+
}
|
|
46
|
+
.expander[data-expanded="true"] svg {
|
|
47
|
+
transform: rotate(0deg);
|
|
48
|
+
}
|
|
49
|
+
.mixed {
|
|
50
|
+
display: grid;
|
|
51
|
+
place-items: center;
|
|
52
|
+
width: 16px;
|
|
53
|
+
height: 16px;
|
|
54
|
+
border: 1px solid var(--accent);
|
|
55
|
+
border-radius: 4px;
|
|
56
|
+
background: var(--accent);
|
|
57
|
+
color: var(--on-accent);
|
|
58
|
+
}
|
|
59
|
+
.mixed svg {
|
|
60
|
+
width: 12px;
|
|
61
|
+
height: 12px;
|
|
62
|
+
}
|
|
63
|
+
.empty,
|
|
64
|
+
.status {
|
|
65
|
+
padding: 16px 10px;
|
|
66
|
+
color: var(--muted);
|
|
67
|
+
font-size: 12px;
|
|
68
|
+
}
|
|
69
|
+
.error {
|
|
70
|
+
color: var(--danger);
|
|
71
|
+
padding: 6px 10px;
|
|
72
|
+
font-size: 12px;
|
|
73
|
+
display: flex;
|
|
74
|
+
gap: 8px;
|
|
75
|
+
align-items: center;
|
|
76
|
+
flex-wrap: wrap;
|
|
77
|
+
}
|
|
78
|
+
.error span {
|
|
79
|
+
min-width: 0;
|
|
80
|
+
overflow-wrap: anywhere;
|
|
81
|
+
}
|
|
82
|
+
.footer {
|
|
83
|
+
display: flex;
|
|
84
|
+
justify-content: space-between;
|
|
85
|
+
align-items: center;
|
|
86
|
+
gap: 12px;
|
|
87
|
+
padding: 8px 3px 1px;
|
|
88
|
+
margin-top: 6px;
|
|
89
|
+
border-top: var(--separator-width) var(--separator-style)
|
|
90
|
+
var(--separator-color);
|
|
91
|
+
font-size: 11px;
|
|
92
|
+
color: var(--muted);
|
|
93
|
+
}
|
|
94
|
+
.footerActions {
|
|
95
|
+
display: flex;
|
|
96
|
+
align-items: center;
|
|
97
|
+
gap: 8px;
|
|
98
|
+
}
|
|
99
|
+
.columns {
|
|
100
|
+
display: flex;
|
|
101
|
+
min-height: 240px;
|
|
102
|
+
max-height: 300px;
|
|
103
|
+
overflow: auto;
|
|
104
|
+
overscroll-behavior: contain;
|
|
105
|
+
}
|
|
106
|
+
.column {
|
|
107
|
+
composes: stack from "./OptionList.module.css";
|
|
108
|
+
flex: 1 0 170px;
|
|
109
|
+
min-width: 170px;
|
|
110
|
+
max-height: 292px;
|
|
111
|
+
overflow: auto;
|
|
112
|
+
padding: 2px 5px;
|
|
113
|
+
animation: columnIn 160ms var(--ease);
|
|
114
|
+
}
|
|
115
|
+
.column + .column {
|
|
116
|
+
border-left: var(--separator-width) var(--separator-style)
|
|
117
|
+
var(--separator-color);
|
|
118
|
+
}
|
|
119
|
+
.treeRow {
|
|
120
|
+
position: relative;
|
|
121
|
+
animation: rowIn 140ms var(--ease);
|
|
122
|
+
}
|
|
123
|
+
.categoryRow {
|
|
124
|
+
--tree-elbow-gap: 6px;
|
|
125
|
+
--tree-stem-inset: 12px;
|
|
126
|
+
min-height: 42px;
|
|
127
|
+
}
|
|
128
|
+
.categoryRow[data-branch="true"] [data-menu-label] {
|
|
129
|
+
font-weight: 600;
|
|
130
|
+
}
|
|
131
|
+
.categoryRow [data-menu-icon] {
|
|
132
|
+
width: 26px;
|
|
133
|
+
height: 26px;
|
|
134
|
+
flex-basis: 26px;
|
|
135
|
+
border-radius: 7px;
|
|
136
|
+
background: var(--field);
|
|
137
|
+
border: 1px solid var(--line);
|
|
138
|
+
color: var(--muted);
|
|
139
|
+
}
|
|
140
|
+
.categoryRow[data-branch="true"] [data-menu-icon] {
|
|
141
|
+
background: var(--selected);
|
|
142
|
+
color: var(--accent);
|
|
143
|
+
}
|
|
144
|
+
.categoryRow [data-menu-trailing] > span {
|
|
145
|
+
border-radius: 999px;
|
|
146
|
+
}
|
|
147
|
+
.categoryRow .mixed {
|
|
148
|
+
border-radius: 999px;
|
|
149
|
+
}
|
|
150
|
+
.treeRow[aria-disabled="true"] .expander {
|
|
151
|
+
pointer-events: none;
|
|
152
|
+
}
|
|
153
|
+
@keyframes rowIn {
|
|
154
|
+
from {
|
|
155
|
+
opacity: 0;
|
|
156
|
+
transform: translateY(-3px);
|
|
157
|
+
}
|
|
158
|
+
to {
|
|
159
|
+
opacity: 1;
|
|
160
|
+
transform: none;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
@keyframes columnIn {
|
|
164
|
+
from {
|
|
165
|
+
opacity: 0;
|
|
166
|
+
transform: translateX(6px);
|
|
167
|
+
}
|
|
168
|
+
to {
|
|
169
|
+
opacity: 1;
|
|
170
|
+
transform: none;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
@media (prefers-reduced-motion: reduce) {
|
|
174
|
+
.column,
|
|
175
|
+
.treeRow {
|
|
176
|
+
animation: none;
|
|
177
|
+
}
|
|
178
|
+
.expander svg {
|
|
179
|
+
transition: none;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ButtonHTMLAttributes } from "react";
|
|
2
|
+
export declare function IconButton({ label, loading, children, variant, size, ...props }: ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
3
|
+
label: string;
|
|
4
|
+
loading?: boolean;
|
|
5
|
+
variant?: "primary" | "secondary" | "ghost" | "danger";
|
|
6
|
+
size?: "small" | "normal";
|
|
7
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Spinner } from "./Spinner.js";
|
|
3
|
+
import { Tooltip } from "./Tooltip.js";
|
|
4
|
+
import s from "./IconButton.module.css";
|
|
5
|
+
function IconButton({
|
|
6
|
+
label,
|
|
7
|
+
loading,
|
|
8
|
+
children,
|
|
9
|
+
variant = "ghost",
|
|
10
|
+
size = "normal",
|
|
11
|
+
...props
|
|
12
|
+
}) {
|
|
13
|
+
return /* @__PURE__ */ jsx(Tooltip, { content: label, children: /* @__PURE__ */ jsx(
|
|
14
|
+
"button",
|
|
15
|
+
{
|
|
16
|
+
type: "button",
|
|
17
|
+
...props,
|
|
18
|
+
"aria-label": label,
|
|
19
|
+
"aria-busy": loading || void 0,
|
|
20
|
+
"data-variant": variant,
|
|
21
|
+
"data-size": size,
|
|
22
|
+
disabled: props.disabled || loading,
|
|
23
|
+
className: `${s.iconButton} ${props.className || ""}`,
|
|
24
|
+
children: /* @__PURE__ */ jsx("span", { className: s.icon, children: loading ? /* @__PURE__ */ jsx(Spinner, { decorative: true }) : children })
|
|
25
|
+
}
|
|
26
|
+
) });
|
|
27
|
+
}
|
|
28
|
+
export {
|
|
29
|
+
IconButton
|
|
30
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
.iconButton {
|
|
2
|
+
position: relative;
|
|
3
|
+
display: grid;
|
|
4
|
+
place-items: center;
|
|
5
|
+
width: 32px;
|
|
6
|
+
height: 32px;
|
|
7
|
+
padding: 0;
|
|
8
|
+
border: 0;
|
|
9
|
+
background: transparent;
|
|
10
|
+
border-radius: calc(var(--radius) - 3px);
|
|
11
|
+
color: var(--muted);
|
|
12
|
+
transition:
|
|
13
|
+
background var(--motion-hover),
|
|
14
|
+
color var(--motion-hover);
|
|
15
|
+
}
|
|
16
|
+
.iconButton:hover {
|
|
17
|
+
color: var(--fg);
|
|
18
|
+
background: var(--hover);
|
|
19
|
+
}
|
|
20
|
+
.icon {
|
|
21
|
+
display: contents;
|
|
22
|
+
}
|
|
23
|
+
.iconButton[data-size="small"] {
|
|
24
|
+
width: 30px;
|
|
25
|
+
height: 30px;
|
|
26
|
+
min-width: 30px;
|
|
27
|
+
}
|
|
28
|
+
.iconButton[data-variant="primary"] {
|
|
29
|
+
background: var(--accent-fill, var(--accent));
|
|
30
|
+
color: var(--on-accent-fill, var(--on-accent));
|
|
31
|
+
}
|
|
32
|
+
.iconButton[data-variant="primary"]:hover:not(:disabled) {
|
|
33
|
+
background: var(--accent-fill-hover, var(--accent));
|
|
34
|
+
}
|
|
35
|
+
.iconButton[data-variant="secondary"] {
|
|
36
|
+
border: 1px solid var(--border);
|
|
37
|
+
background: var(--surface);
|
|
38
|
+
}
|
|
39
|
+
.iconButton[data-variant="danger"] {
|
|
40
|
+
color: var(--danger);
|
|
41
|
+
background: var(--danger-soft);
|
|
42
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback, useMemo, useRef, useState } from "react";
|
|
3
|
+
import { Popover } from "./Popover.js";
|
|
4
|
+
import { SearchField } from "./SearchField.js";
|
|
5
|
+
import { CatalogIcon } from "./CatalogIcon.js";
|
|
6
|
+
import { Spinner } from "./Spinner.js";
|
|
7
|
+
import { Button } from "./Button.js";
|
|
8
|
+
import { SelectTrigger } from "./SelectTrigger.js";
|
|
9
|
+
import {
|
|
10
|
+
VirtualPickerList
|
|
11
|
+
} from "./VirtualPickerList.js";
|
|
12
|
+
import { useIconCatalog, iconCategories } from "./iconCatalog.js";
|
|
13
|
+
import s from "./Picker.module.css";
|
|
14
|
+
function IconPicker({
|
|
15
|
+
value,
|
|
16
|
+
onChange,
|
|
17
|
+
label = "\u56FE\u6807",
|
|
18
|
+
disabled = false
|
|
19
|
+
}) {
|
|
20
|
+
const anchor = useRef(null), [open, setOpen] = useState(false), [query, setQuery] = useState("");
|
|
21
|
+
const { items, error, retry } = useIconCatalog(open);
|
|
22
|
+
const groups = useMemo(() => {
|
|
23
|
+
if (!items) return [];
|
|
24
|
+
const indexed = items.map((icon) => ({
|
|
25
|
+
id: icon.name,
|
|
26
|
+
label: icon.name,
|
|
27
|
+
icon,
|
|
28
|
+
search: [
|
|
29
|
+
icon.name,
|
|
30
|
+
...icon.aliases,
|
|
31
|
+
...icon.categories.flatMap((c) => [c, iconCategories[c]])
|
|
32
|
+
].join(" ").toLowerCase()
|
|
33
|
+
}));
|
|
34
|
+
return Object.entries(iconCategories).map(
|
|
35
|
+
([id, label2]) => ({
|
|
36
|
+
id,
|
|
37
|
+
label: label2,
|
|
38
|
+
items: indexed.filter(
|
|
39
|
+
(entry) => id === "uncategorized" ? !entry.icon.categories.length : entry.icon.categories.includes(id)
|
|
40
|
+
)
|
|
41
|
+
})
|
|
42
|
+
).filter((group) => group.items.length);
|
|
43
|
+
}, [items]);
|
|
44
|
+
const choose = useCallback(
|
|
45
|
+
(item) => {
|
|
46
|
+
onChange(item.id);
|
|
47
|
+
setOpen(false);
|
|
48
|
+
anchor.current?.focus();
|
|
49
|
+
},
|
|
50
|
+
[onChange]
|
|
51
|
+
);
|
|
52
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
53
|
+
/* @__PURE__ */ jsx(
|
|
54
|
+
SelectTrigger,
|
|
55
|
+
{
|
|
56
|
+
ref: anchor,
|
|
57
|
+
expanded: open,
|
|
58
|
+
disabled,
|
|
59
|
+
"aria-label": label,
|
|
60
|
+
"aria-haspopup": "dialog",
|
|
61
|
+
onClick: () => setOpen((x) => !x),
|
|
62
|
+
onKeyDown: (e) => {
|
|
63
|
+
if (e.key === "ArrowDown" || e.key === "ArrowUp") {
|
|
64
|
+
e.preventDefault();
|
|
65
|
+
setOpen(true);
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
icon: /* @__PURE__ */ jsx(CatalogIcon, { name: value }),
|
|
69
|
+
children: /* @__PURE__ */ jsx("span", { children: value || "\u9009\u62E9\u56FE\u6807" })
|
|
70
|
+
}
|
|
71
|
+
),
|
|
72
|
+
/* @__PURE__ */ jsx(
|
|
73
|
+
Popover,
|
|
74
|
+
{
|
|
75
|
+
open,
|
|
76
|
+
onClose: () => setOpen(false),
|
|
77
|
+
anchor,
|
|
78
|
+
width: 470,
|
|
79
|
+
label: label + "\u9009\u62E9\u5668",
|
|
80
|
+
children: /* @__PURE__ */ jsxs("div", { className: s.panel, children: [
|
|
81
|
+
/* @__PURE__ */ jsx(
|
|
82
|
+
SearchField,
|
|
83
|
+
{
|
|
84
|
+
label: "\u641C\u7D22\u56FE\u6807",
|
|
85
|
+
placeholder: "\u540D\u79F0\u3001\u5206\u7C7B\uFF08\u4E2D/\u82F1\u6587\uFF09",
|
|
86
|
+
value: query,
|
|
87
|
+
onChange: setQuery
|
|
88
|
+
}
|
|
89
|
+
),
|
|
90
|
+
error ? /* @__PURE__ */ jsx(Button, { onClick: retry, children: "\u91CD\u65B0\u52A0\u8F7D" }) : !items ? /* @__PURE__ */ jsx("div", { className: s.loading, children: /* @__PURE__ */ jsx(Spinner, { label: "\u52A0\u8F7D\u56FE\u6807" }) }) : /* @__PURE__ */ jsx(
|
|
91
|
+
VirtualPickerList,
|
|
92
|
+
{
|
|
93
|
+
groups,
|
|
94
|
+
query,
|
|
95
|
+
value,
|
|
96
|
+
label: "\u56FE\u6807",
|
|
97
|
+
onChoose: choose
|
|
98
|
+
}
|
|
99
|
+
),
|
|
100
|
+
/* @__PURE__ */ jsx("div", { className: s.footer, children: /* @__PURE__ */ jsxs("span", { children: [
|
|
101
|
+
items?.length || 0,
|
|
102
|
+
" \u4E2A\u56FE\u6807"
|
|
103
|
+
] }) })
|
|
104
|
+
] })
|
|
105
|
+
}
|
|
106
|
+
)
|
|
107
|
+
] });
|
|
108
|
+
}
|
|
109
|
+
export {
|
|
110
|
+
IconPicker
|
|
111
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
export type IndicatorItem<T extends string = string> = {
|
|
3
|
+
value: T;
|
|
4
|
+
label: string;
|
|
5
|
+
icon?: ReactNode;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
};
|
|
8
|
+
export type IndicatorGroup<T extends string = string> = {
|
|
9
|
+
id: string;
|
|
10
|
+
label?: string;
|
|
11
|
+
items: IndicatorItem<T>[];
|
|
12
|
+
};
|
|
13
|
+
export declare function Indicator<T extends string>({ value, onChange, groups, label, }: {
|
|
14
|
+
value: T;
|
|
15
|
+
onChange(value: T): void;
|
|
16
|
+
groups: IndicatorGroup<T>[];
|
|
17
|
+
label?: string;
|
|
18
|
+
}): import("react").JSX.Element;
|