@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,156 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { FieldContext } from "./field.js";
|
|
3
|
+
import {
|
|
4
|
+
useLayoutEffect,
|
|
5
|
+
useRef,
|
|
6
|
+
useEffect
|
|
7
|
+
} from "react";
|
|
8
|
+
import { createPortal } from "react-dom";
|
|
9
|
+
import { menuSurfaceMotion, cancelMotion } from "./motion.js";
|
|
10
|
+
import s from "./Popover.module.css";
|
|
11
|
+
import { useSurfacePortal } from "./surfacePortal.js";
|
|
12
|
+
function Popover({
|
|
13
|
+
open: requestedOpen,
|
|
14
|
+
onClose,
|
|
15
|
+
anchor,
|
|
16
|
+
children,
|
|
17
|
+
width = 230,
|
|
18
|
+
label,
|
|
19
|
+
role = "dialog",
|
|
20
|
+
id,
|
|
21
|
+
onKeyDown,
|
|
22
|
+
descriptionId,
|
|
23
|
+
autoFocus = true,
|
|
24
|
+
matchAnchorWidth = false,
|
|
25
|
+
className = ""
|
|
26
|
+
}) {
|
|
27
|
+
const owner = useSurfacePortal(), portalHost = owner?.host || document.body, open = requestedOpen && owner?.active !== false;
|
|
28
|
+
const ref = useRef(null), close = useRef(onClose);
|
|
29
|
+
close.current = onClose;
|
|
30
|
+
const opened = useRef(open);
|
|
31
|
+
opened.current = open;
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
if (requestedOpen && owner?.active === false) close.current();
|
|
34
|
+
}, [requestedOpen, owner?.active]);
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
const node = ref.current;
|
|
37
|
+
return () => cancelMotion(node);
|
|
38
|
+
}, [portalHost]);
|
|
39
|
+
useLayoutEffect(() => {
|
|
40
|
+
const surface = ref.current, trigger = anchor.current;
|
|
41
|
+
if (!open) {
|
|
42
|
+
if (!surface.matches(":popover-open")) return;
|
|
43
|
+
surface.inert = true;
|
|
44
|
+
surface.setAttribute("aria-hidden", "true");
|
|
45
|
+
void menuSurfaceMotion(
|
|
46
|
+
surface,
|
|
47
|
+
"exit",
|
|
48
|
+
surface.dataset.side === "top" ? "top" : "bottom"
|
|
49
|
+
).then((done) => {
|
|
50
|
+
if (done && !opened.current && surface.matches(":popover-open"))
|
|
51
|
+
surface.hidePopover();
|
|
52
|
+
});
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
if (!trigger) return;
|
|
56
|
+
surface.inert = false;
|
|
57
|
+
surface.removeAttribute("aria-hidden");
|
|
58
|
+
const position = () => {
|
|
59
|
+
if (!trigger.isConnected) {
|
|
60
|
+
close.current();
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
const viewport = window.visualViewport;
|
|
64
|
+
const viewportTop = viewport?.offsetTop ?? 0;
|
|
65
|
+
const viewportLeft = viewport?.offsetLeft ?? 0;
|
|
66
|
+
const viewportWidth = viewport?.width ?? innerWidth;
|
|
67
|
+
const viewportBottom = viewportTop + (viewport?.height ?? innerHeight);
|
|
68
|
+
const rect = trigger.getBoundingClientRect(), available = Math.max(0, viewportBottom - viewportTop - 24);
|
|
69
|
+
surface.style.maxHeight = available + "px";
|
|
70
|
+
const actualWidth = Math.min(
|
|
71
|
+
matchAnchorWidth ? rect.width : width,
|
|
72
|
+
Math.max(0, viewportWidth - 24)
|
|
73
|
+
);
|
|
74
|
+
surface.style.width = actualWidth + "px";
|
|
75
|
+
const height = Math.min(surface.scrollHeight + 2, available);
|
|
76
|
+
surface.style.left = Math.max(
|
|
77
|
+
viewportLeft + 12,
|
|
78
|
+
Math.min(rect.left, viewportLeft + viewportWidth - actualWidth - 12)
|
|
79
|
+
) + "px";
|
|
80
|
+
const below = viewportBottom - rect.bottom - 10;
|
|
81
|
+
surface.dataset.side = below >= height || rect.top - viewportTop < height ? "bottom" : "top";
|
|
82
|
+
const top = surface.dataset.side === "bottom" ? rect.bottom + 6 : rect.top - height - 6;
|
|
83
|
+
surface.style.top = Math.max(
|
|
84
|
+
viewportTop + 12,
|
|
85
|
+
Math.min(top, viewportBottom - height - 12)
|
|
86
|
+
) + "px";
|
|
87
|
+
};
|
|
88
|
+
if (!surface.matches(":popover-open")) surface.showPopover();
|
|
89
|
+
position();
|
|
90
|
+
void menuSurfaceMotion(
|
|
91
|
+
surface,
|
|
92
|
+
"enter",
|
|
93
|
+
surface.dataset.side === "top" ? "top" : "bottom"
|
|
94
|
+
);
|
|
95
|
+
if (autoFocus && role !== "listbox")
|
|
96
|
+
(surface.querySelector("[data-autofocus]") || surface.querySelector(
|
|
97
|
+
'input:not([disabled]),button:not([disabled]),[tabindex="0"]'
|
|
98
|
+
))?.focus({ preventScroll: true });
|
|
99
|
+
const observer = new ResizeObserver(position);
|
|
100
|
+
observer.observe(surface);
|
|
101
|
+
observer.observe(trigger);
|
|
102
|
+
const pointer = (event) => {
|
|
103
|
+
if (!surface.contains(event.target) && !trigger.contains(event.target))
|
|
104
|
+
close.current();
|
|
105
|
+
};
|
|
106
|
+
const focus = (event) => {
|
|
107
|
+
if (!surface.contains(event.target) && !trigger.contains(event.target))
|
|
108
|
+
close.current();
|
|
109
|
+
};
|
|
110
|
+
const key = (event) => {
|
|
111
|
+
if (event.key === "Escape") {
|
|
112
|
+
event.preventDefault();
|
|
113
|
+
event.stopPropagation();
|
|
114
|
+
close.current();
|
|
115
|
+
trigger.focus();
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
document.addEventListener("pointerdown", pointer, true);
|
|
119
|
+
document.addEventListener("keydown", key, true);
|
|
120
|
+
document.addEventListener("focusin", focus, true);
|
|
121
|
+
window.addEventListener("resize", position);
|
|
122
|
+
window.addEventListener("scroll", position, true);
|
|
123
|
+
window.visualViewport?.addEventListener("resize", position);
|
|
124
|
+
window.visualViewport?.addEventListener("scroll", position);
|
|
125
|
+
return () => {
|
|
126
|
+
observer.disconnect();
|
|
127
|
+
document.removeEventListener("pointerdown", pointer, true);
|
|
128
|
+
document.removeEventListener("keydown", key, true);
|
|
129
|
+
document.removeEventListener("focusin", focus, true);
|
|
130
|
+
window.removeEventListener("resize", position);
|
|
131
|
+
window.removeEventListener("scroll", position, true);
|
|
132
|
+
window.visualViewport?.removeEventListener("resize", position);
|
|
133
|
+
window.visualViewport?.removeEventListener("scroll", position);
|
|
134
|
+
};
|
|
135
|
+
}, [open, anchor, width, role, portalHost, autoFocus, matchAnchorWidth]);
|
|
136
|
+
return createPortal(
|
|
137
|
+
/* @__PURE__ */ jsx(
|
|
138
|
+
"div",
|
|
139
|
+
{
|
|
140
|
+
ref,
|
|
141
|
+
id,
|
|
142
|
+
popover: "manual",
|
|
143
|
+
role,
|
|
144
|
+
"aria-label": label,
|
|
145
|
+
"aria-describedby": descriptionId,
|
|
146
|
+
onKeyDown,
|
|
147
|
+
className: s.popover + " " + className,
|
|
148
|
+
children: /* @__PURE__ */ jsx(FieldContext, { value: null, children })
|
|
149
|
+
}
|
|
150
|
+
),
|
|
151
|
+
portalHost
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
export {
|
|
155
|
+
Popover
|
|
156
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
.popover {
|
|
2
|
+
position: fixed;
|
|
3
|
+
inset: auto;
|
|
4
|
+
margin: 0;
|
|
5
|
+
padding: 5px;
|
|
6
|
+
color: var(--fg);
|
|
7
|
+
background: var(--popup-background);
|
|
8
|
+
border: 1px solid var(--popup-border);
|
|
9
|
+
border-radius: var(--popup-radius);
|
|
10
|
+
box-shadow: var(--popup-shadow);
|
|
11
|
+
overflow-y: auto;
|
|
12
|
+
overscroll-behavior: contain;
|
|
13
|
+
}
|
|
14
|
+
.popover[inert] {
|
|
15
|
+
pointer-events: none;
|
|
16
|
+
}
|
|
17
|
+
.popover:not(:popover-open) {
|
|
18
|
+
display: none;
|
|
19
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import s from "./Progress.module.css";
|
|
3
|
+
function Progress({
|
|
4
|
+
value,
|
|
5
|
+
label,
|
|
6
|
+
tone = "default"
|
|
7
|
+
}) {
|
|
8
|
+
const amount = value === void 0 ? void 0 : Math.max(0, Math.min(100, Number.isFinite(value) ? value : 0));
|
|
9
|
+
return /* @__PURE__ */ jsx(
|
|
10
|
+
"div",
|
|
11
|
+
{
|
|
12
|
+
className: s.progress,
|
|
13
|
+
"data-indeterminate": amount === void 0,
|
|
14
|
+
"data-tone": tone,
|
|
15
|
+
role: "progressbar",
|
|
16
|
+
"aria-label": label,
|
|
17
|
+
"aria-valuenow": amount,
|
|
18
|
+
"aria-valuemin": 0,
|
|
19
|
+
"aria-valuemax": 100,
|
|
20
|
+
children: /* @__PURE__ */ jsx(
|
|
21
|
+
"span",
|
|
22
|
+
{
|
|
23
|
+
style: amount === void 0 ? void 0 : { width: amount + "%" }
|
|
24
|
+
}
|
|
25
|
+
)
|
|
26
|
+
}
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
export {
|
|
30
|
+
Progress
|
|
31
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
.progress {
|
|
2
|
+
height: 5px;
|
|
3
|
+
width: 100%;
|
|
4
|
+
background: var(--line);
|
|
5
|
+
border-radius: 10px;
|
|
6
|
+
overflow: hidden;
|
|
7
|
+
}
|
|
8
|
+
.progress span {
|
|
9
|
+
display: block;
|
|
10
|
+
height: 100%;
|
|
11
|
+
background: var(--accent);
|
|
12
|
+
border-radius: inherit;
|
|
13
|
+
transition: width var(--motion-panel) var(--ease);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.progress[data-indeterminate="true"] > span {
|
|
17
|
+
width: 35%;
|
|
18
|
+
animation: progress-travel 1.25s ease-in-out infinite;
|
|
19
|
+
}
|
|
20
|
+
.progress[data-tone="success"] > span {
|
|
21
|
+
background: var(--success);
|
|
22
|
+
}
|
|
23
|
+
.progress[data-tone="error"] > span {
|
|
24
|
+
background: var(--danger);
|
|
25
|
+
}
|
|
26
|
+
@keyframes progress-travel {
|
|
27
|
+
from {
|
|
28
|
+
transform: translateX(-100%);
|
|
29
|
+
}
|
|
30
|
+
to {
|
|
31
|
+
transform: translateX(290%);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type FieldOptions } from "./field";
|
|
2
|
+
export declare function RadioGroup({ label, value, onChange, options, disabled, required, name: providedName, orientation, ...optionsProps }: FieldOptions & {
|
|
3
|
+
label: string;
|
|
4
|
+
disabled?: boolean;
|
|
5
|
+
required?: boolean;
|
|
6
|
+
name?: string;
|
|
7
|
+
orientation?: "horizontal" | "vertical";
|
|
8
|
+
value: string;
|
|
9
|
+
onChange(value: string): void;
|
|
10
|
+
options: {
|
|
11
|
+
value: string;
|
|
12
|
+
label: string;
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
}[];
|
|
15
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { FieldLabel } from "./FieldLabel.js";
|
|
3
|
+
import { useFieldControl } from "./field.js";
|
|
4
|
+
import { useId } from "react";
|
|
5
|
+
import s from "./RadioGroup.module.css";
|
|
6
|
+
function RadioGroup({
|
|
7
|
+
label,
|
|
8
|
+
value,
|
|
9
|
+
onChange,
|
|
10
|
+
options,
|
|
11
|
+
disabled,
|
|
12
|
+
required,
|
|
13
|
+
name: providedName,
|
|
14
|
+
orientation = "horizontal",
|
|
15
|
+
...optionsProps
|
|
16
|
+
}) {
|
|
17
|
+
const generated = useId(), field = useFieldControl({
|
|
18
|
+
...optionsProps,
|
|
19
|
+
label,
|
|
20
|
+
name: providedName,
|
|
21
|
+
disabled,
|
|
22
|
+
required
|
|
23
|
+
}), name = field.name || generated;
|
|
24
|
+
return /* @__PURE__ */ jsxs(
|
|
25
|
+
"fieldset",
|
|
26
|
+
{
|
|
27
|
+
className: s.group,
|
|
28
|
+
disabled: field.disabled,
|
|
29
|
+
id: field.id,
|
|
30
|
+
"aria-invalid": field.invalid,
|
|
31
|
+
"aria-describedby": field.descriptionId,
|
|
32
|
+
"data-orientation": orientation,
|
|
33
|
+
children: [
|
|
34
|
+
/* @__PURE__ */ jsx("legend", { children: /* @__PURE__ */ jsx(
|
|
35
|
+
FieldLabel,
|
|
36
|
+
{
|
|
37
|
+
as: "span",
|
|
38
|
+
label,
|
|
39
|
+
required: !field.wrapped && field.required
|
|
40
|
+
}
|
|
41
|
+
) }),
|
|
42
|
+
options.map((option) => /* @__PURE__ */ jsxs(
|
|
43
|
+
"label",
|
|
44
|
+
{
|
|
45
|
+
"data-disabled": field.disabled || option.disabled,
|
|
46
|
+
children: [
|
|
47
|
+
/* @__PURE__ */ jsx(
|
|
48
|
+
"input",
|
|
49
|
+
{
|
|
50
|
+
type: "radio",
|
|
51
|
+
value: option.value,
|
|
52
|
+
name,
|
|
53
|
+
required: field.required,
|
|
54
|
+
checked: value === option.value,
|
|
55
|
+
disabled: field.disabled || option.disabled,
|
|
56
|
+
onChange: () => {
|
|
57
|
+
if (!field.readOnly) onChange(option.value);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
),
|
|
61
|
+
/* @__PURE__ */ jsx("span", { className: s.mark, "aria-hidden": "true" }),
|
|
62
|
+
/* @__PURE__ */ jsx("span", { children: option.label })
|
|
63
|
+
]
|
|
64
|
+
},
|
|
65
|
+
option.value
|
|
66
|
+
))
|
|
67
|
+
]
|
|
68
|
+
}
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
export {
|
|
72
|
+
RadioGroup
|
|
73
|
+
};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
.group {
|
|
2
|
+
border: 0;
|
|
3
|
+
margin: 0;
|
|
4
|
+
padding: 0;
|
|
5
|
+
display: flex;
|
|
6
|
+
gap: 20px;
|
|
7
|
+
}
|
|
8
|
+
.group legend {
|
|
9
|
+
padding: 0;
|
|
10
|
+
margin-bottom: 10px;
|
|
11
|
+
font-size: 12px;
|
|
12
|
+
}
|
|
13
|
+
.group label {
|
|
14
|
+
position: relative;
|
|
15
|
+
display: inline-flex;
|
|
16
|
+
align-items: center;
|
|
17
|
+
gap: 8px;
|
|
18
|
+
cursor: pointer;
|
|
19
|
+
user-select: none;
|
|
20
|
+
}
|
|
21
|
+
.group input[type="radio"] {
|
|
22
|
+
position: absolute;
|
|
23
|
+
left: 0;
|
|
24
|
+
margin: 0;
|
|
25
|
+
width: 18px;
|
|
26
|
+
height: 18px;
|
|
27
|
+
opacity: 0;
|
|
28
|
+
}
|
|
29
|
+
.mark {
|
|
30
|
+
display: grid;
|
|
31
|
+
place-items: center;
|
|
32
|
+
flex-shrink: 0;
|
|
33
|
+
width: 18px;
|
|
34
|
+
height: 18px;
|
|
35
|
+
border: 1px solid color-mix(in srgb, var(--fg) 25%, var(--surface));
|
|
36
|
+
border-radius: 50%;
|
|
37
|
+
background: var(--field);
|
|
38
|
+
pointer-events: none;
|
|
39
|
+
transition:
|
|
40
|
+
border-color var(--motion-hover),
|
|
41
|
+
box-shadow var(--motion-hover),
|
|
42
|
+
transform var(--motion-press);
|
|
43
|
+
}
|
|
44
|
+
.mark::after {
|
|
45
|
+
content: "";
|
|
46
|
+
width: 8px;
|
|
47
|
+
height: 8px;
|
|
48
|
+
border-radius: 50%;
|
|
49
|
+
background: var(--accent-fill, var(--accent));
|
|
50
|
+
transform: scale(0.25);
|
|
51
|
+
opacity: 0;
|
|
52
|
+
transition:
|
|
53
|
+
transform var(--motion-panel) var(--ease),
|
|
54
|
+
opacity var(--motion-hover);
|
|
55
|
+
}
|
|
56
|
+
.group input:checked + .mark {
|
|
57
|
+
border-color: var(--accent-fill, var(--accent));
|
|
58
|
+
}
|
|
59
|
+
.group input:checked + .mark::after {
|
|
60
|
+
transform: scale(1);
|
|
61
|
+
opacity: 1;
|
|
62
|
+
}
|
|
63
|
+
.group label:hover input:not(:disabled) + .mark {
|
|
64
|
+
border-color: var(--muted);
|
|
65
|
+
}
|
|
66
|
+
.group label:active input:not(:disabled) + .mark {
|
|
67
|
+
transform: scale(0.92);
|
|
68
|
+
}
|
|
69
|
+
.group input:focus-visible + .mark {
|
|
70
|
+
box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent);
|
|
71
|
+
border-color: var(--accent);
|
|
72
|
+
}
|
|
73
|
+
.group label[data-disabled="true"] {
|
|
74
|
+
cursor: not-allowed;
|
|
75
|
+
}
|
|
76
|
+
.group input:disabled ~ span {
|
|
77
|
+
opacity: 0.4;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.group[data-orientation="vertical"] {
|
|
81
|
+
flex-direction: column;
|
|
82
|
+
align-items: flex-start;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.group[aria-invalid="true"] .mark {
|
|
86
|
+
border-color: var(--danger);
|
|
87
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
import { type FieldOptions } from "./field";
|
|
3
|
+
import { type RangeValue } from "./rangeMath";
|
|
4
|
+
export type RangeSliderProps = FieldOptions & {
|
|
5
|
+
label: string;
|
|
6
|
+
value: RangeValue;
|
|
7
|
+
onChange(value: RangeValue): void;
|
|
8
|
+
onChangeEnd?(value: RangeValue): void;
|
|
9
|
+
min?: number;
|
|
10
|
+
max?: number;
|
|
11
|
+
step?: number;
|
|
12
|
+
minDistance?: number;
|
|
13
|
+
lowerLabel?: string;
|
|
14
|
+
upperLabel?: string;
|
|
15
|
+
formatValue?(value: number): string;
|
|
16
|
+
marks?: (number | {
|
|
17
|
+
value: number;
|
|
18
|
+
label?: ReactNode;
|
|
19
|
+
})[];
|
|
20
|
+
tooltip?: boolean;
|
|
21
|
+
};
|
|
22
|
+
export declare function RangeSlider({ label, value, onChange, onChangeEnd, min, max, step, minDistance, lowerLabel, upperLabel, formatValue, marks, tooltip, ...options }: RangeSliderProps): import("react").JSX.Element;
|