@krelborn/stylesui 0.0.0-stage → 0.8.1
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/LICENSE +74 -0
- package/README.md +129 -2
- package/dist/accessibility/RequiredAccessibleName.d.ts +26 -0
- package/dist/accessibility/idSegment.d.ts +7 -0
- package/dist/accessibility/idSegment.js +6 -0
- package/dist/accessibility/index.d.ts +2 -0
- package/dist/collections/index.d.ts +4 -0
- package/dist/collections/targetIndexForKey.d.ts +45 -0
- package/dist/collections/targetIndexForKey.js +17 -0
- package/dist/collections/typeAhead.d.ts +43 -0
- package/dist/collections/typeAhead.js +19 -0
- package/dist/components/Alert/Alert.css +1 -0
- package/dist/components/Alert/Alert.d.ts +47 -0
- package/dist/components/Alert/Alert.js +28 -0
- package/dist/components/Alert/Alert.module.js +9 -0
- package/dist/components/Alert/AlertIcon.d.ts +14 -0
- package/dist/components/Alert/AlertIcon.js +43 -0
- package/dist/components/Alert/index.d.ts +2 -0
- package/dist/components/Avatar/Avatar.css +1 -0
- package/dist/components/Avatar/Avatar.d.ts +33 -0
- package/dist/components/Avatar/Avatar.js +27 -0
- package/dist/components/Avatar/Avatar.module.js +7 -0
- package/dist/components/Avatar/index.d.ts +2 -0
- package/dist/components/Avatar/initialsOf.d.ts +9 -0
- package/dist/components/Avatar/initialsOf.js +10 -0
- package/dist/components/AvatarGroup/AvatarGroup.css +1 -0
- package/dist/components/AvatarGroup/AvatarGroup.d.ts +30 -0
- package/dist/components/AvatarGroup/AvatarGroup.js +34 -0
- package/dist/components/AvatarGroup/AvatarGroup.module.js +7 -0
- package/dist/components/AvatarGroup/index.d.ts +2 -0
- package/dist/components/Badge/Badge.css +1 -0
- package/dist/components/Badge/Badge.d.ts +36 -0
- package/dist/components/Badge/Badge.js +16 -0
- package/dist/components/Badge/Badge.module.js +4 -0
- package/dist/components/Badge/index.d.ts +2 -0
- package/dist/components/Box/Box.css +1 -0
- package/dist/components/Box/Box.d.ts +31 -0
- package/dist/components/Box/Box.js +18 -0
- package/dist/components/Box/Box.module.js +4 -0
- package/dist/components/Box/index.d.ts +2 -0
- package/dist/components/Button/Button.css +1 -0
- package/dist/components/Button/Button.d.ts +42 -0
- package/dist/components/Button/Button.js +29 -0
- package/dist/components/Button/Button.module.js +7 -0
- package/dist/components/Button/index.d.ts +2 -0
- package/dist/components/Card/Card.css +1 -0
- package/dist/components/Card/Card.d.ts +24 -0
- package/dist/components/Card/Card.js +15 -0
- package/dist/components/Card/Card.module.js +4 -0
- package/dist/components/Card/index.d.ts +2 -0
- package/dist/components/Center/Center.css +1 -0
- package/dist/components/Center/Center.d.ts +34 -0
- package/dist/components/Center/Center.js +20 -0
- package/dist/components/Center/Center.module.js +4 -0
- package/dist/components/Center/index.d.ts +2 -0
- package/dist/components/Checkbox/Checkbox.d.ts +23 -0
- package/dist/components/Checkbox/Checkbox.js +13 -0
- package/dist/components/Checkbox/index.d.ts +2 -0
- package/dist/components/ChoiceControl/ChoiceControl.css +1 -0
- package/dist/components/ChoiceControl/ChoiceControl.d.ts +21 -0
- package/dist/components/ChoiceControl/ChoiceControl.js +40 -0
- package/dist/components/ChoiceControl/ChoiceControl.module.js +9 -0
- package/dist/components/ChoiceControl/index.d.ts +1 -0
- package/dist/components/Cluster/Cluster.d.ts +29 -0
- package/dist/components/Cluster/Cluster.js +14 -0
- package/dist/components/Cluster/index.d.ts +2 -0
- package/dist/components/Code/Code.css +1 -0
- package/dist/components/Code/Code.d.ts +13 -0
- package/dist/components/Code/Code.js +20 -0
- package/dist/components/Code/Code.module.js +4 -0
- package/dist/components/Code/index.d.ts +2 -0
- package/dist/components/Counter/Counter.css +1 -0
- package/dist/components/Counter/Counter.d.ts +39 -0
- package/dist/components/Counter/Counter.js +19 -0
- package/dist/components/Counter/Counter.module.js +4 -0
- package/dist/components/Counter/index.d.ts +2 -0
- package/dist/components/Cover/Cover.css +1 -0
- package/dist/components/Cover/Cover.d.ts +40 -0
- package/dist/components/Cover/Cover.js +30 -0
- package/dist/components/Cover/Cover.module.js +7 -0
- package/dist/components/Cover/index.d.ts +2 -0
- package/dist/components/Divider/Divider.css +1 -0
- package/dist/components/Divider/Divider.d.ts +25 -0
- package/dist/components/Divider/Divider.js +16 -0
- package/dist/components/Divider/Divider.module.js +4 -0
- package/dist/components/Divider/index.d.ts +2 -0
- package/dist/components/Field/Field.css +1 -0
- package/dist/components/Field/Field.d.ts +49 -0
- package/dist/components/Field/Field.js +48 -0
- package/dist/components/Field/Field.module.js +9 -0
- package/dist/components/Field/index.d.ts +2 -0
- package/dist/components/Fieldset/Fieldset.css +1 -0
- package/dist/components/Fieldset/Fieldset.d.ts +35 -0
- package/dist/components/Fieldset/Fieldset.js +65 -0
- package/dist/components/Fieldset/Fieldset.module.js +9 -0
- package/dist/components/Fieldset/index.d.ts +2 -0
- package/dist/components/Frame/Frame.css +1 -0
- package/dist/components/Frame/Frame.d.ts +23 -0
- package/dist/components/Frame/Frame.js +17 -0
- package/dist/components/Frame/Frame.module.js +4 -0
- package/dist/components/Frame/index.d.ts +2 -0
- package/dist/components/Grid/Grid.css +1 -0
- package/dist/components/Grid/Grid.d.ts +25 -0
- package/dist/components/Grid/Grid.js +23 -0
- package/dist/components/Grid/Grid.module.js +4 -0
- package/dist/components/Grid/index.d.ts +2 -0
- package/dist/components/Heading/Heading.css +1 -0
- package/dist/components/Heading/Heading.d.ts +39 -0
- package/dist/components/Heading/Heading.js +24 -0
- package/dist/components/Heading/Heading.module.js +4 -0
- package/dist/components/Heading/index.d.ts +2 -0
- package/dist/components/HorizontalFlow/HorizontalFlow.css +1 -0
- package/dist/components/HorizontalFlow/HorizontalFlow.d.ts +30 -0
- package/dist/components/HorizontalFlow/HorizontalFlow.js +31 -0
- package/dist/components/HorizontalFlow/HorizontalFlow.module.js +4 -0
- package/dist/components/HorizontalFlow/index.d.ts +2 -0
- package/dist/components/Icon/AddIcon.d.ts +11 -0
- package/dist/components/Icon/AddIcon.js +22 -0
- package/dist/components/Icon/ChevronDownIcon.d.ts +11 -0
- package/dist/components/Icon/ChevronDownIcon.js +19 -0
- package/dist/components/Icon/CloseIcon.d.ts +12 -0
- package/dist/components/Icon/CloseIcon.js +22 -0
- package/dist/components/Icon/ColorModeIcon.d.ts +12 -0
- package/dist/components/Icon/ColorModeIcon.js +37 -0
- package/dist/components/Icon/DeleteIcon.d.ts +11 -0
- package/dist/components/Icon/DeleteIcon.js +37 -0
- package/dist/components/Icon/Icon.css +1 -0
- package/dist/components/Icon/Icon.d.ts +40 -0
- package/dist/components/Icon/Icon.js +28 -0
- package/dist/components/Icon/Icon.module.js +7 -0
- package/dist/components/Icon/InfoIcon.d.ts +11 -0
- package/dist/components/Icon/InfoIcon.js +31 -0
- package/dist/components/Icon/MoreHorizontalIcon.d.ts +11 -0
- package/dist/components/Icon/MoreHorizontalIcon.js +35 -0
- package/dist/components/Icon/MoreVerticalIcon.d.ts +11 -0
- package/dist/components/Icon/MoreVerticalIcon.js +35 -0
- package/dist/components/Icon/PaletteIcon.d.ts +12 -0
- package/dist/components/Icon/PaletteIcon.js +49 -0
- package/dist/components/Icon/RefreshIcon.d.ts +13 -0
- package/dist/components/Icon/RefreshIcon.js +33 -0
- package/dist/components/Icon/RemoveIcon.d.ts +11 -0
- package/dist/components/Icon/RemoveIcon.js +19 -0
- package/dist/components/Icon/SendIcon.d.ts +11 -0
- package/dist/components/Icon/SendIcon.js +23 -0
- package/dist/components/Icon/index.d.ts +13 -0
- package/dist/components/IconButton/IconButton.css +1 -0
- package/dist/components/IconButton/IconButton.d.ts +45 -0
- package/dist/components/IconButton/IconButton.js +41 -0
- package/dist/components/IconButton/IconButton.module.js +8 -0
- package/dist/components/IconButton/index.d.ts +2 -0
- package/dist/components/Kbd/Kbd.css +1 -0
- package/dist/components/Kbd/Kbd.d.ts +13 -0
- package/dist/components/Kbd/Kbd.js +20 -0
- package/dist/components/Kbd/Kbd.module.js +4 -0
- package/dist/components/Kbd/index.d.ts +2 -0
- package/dist/components/Link/Link.css +1 -0
- package/dist/components/Link/Link.d.ts +52 -0
- package/dist/components/Link/Link.js +27 -0
- package/dist/components/Link/Link.module.js +4 -0
- package/dist/components/Link/index.d.ts +2 -0
- package/dist/components/Listbox/Listbox.css +1 -0
- package/dist/components/Listbox/Listbox.d.ts +46 -0
- package/dist/components/Listbox/Listbox.js +56 -0
- package/dist/components/Listbox/Listbox.module.js +7 -0
- package/dist/components/Listbox/ListboxContext.d.ts +38 -0
- package/dist/components/Listbox/ListboxContext.js +5 -0
- package/dist/components/Listbox/ListboxOption.d.ts +31 -0
- package/dist/components/Listbox/ListboxOption.js +43 -0
- package/dist/components/Listbox/index.d.ts +4 -0
- package/dist/components/Listbox/optionId.d.ts +8 -0
- package/dist/components/Listbox/optionId.js +7 -0
- package/dist/components/Listbox/renderedOptions.d.ts +30 -0
- package/dist/components/Listbox/renderedOptions.js +15 -0
- package/dist/components/Listbox/useListbox.d.ts +54 -0
- package/dist/components/Listbox/useListbox.js +104 -0
- package/dist/components/Listbox/useListboxContext.d.ts +9 -0
- package/dist/components/Listbox/useListboxContext.js +11 -0
- package/dist/components/NavList/NavList.css +1 -0
- package/dist/components/NavList/NavList.d.ts +20 -0
- package/dist/components/NavList/NavList.js +28 -0
- package/dist/components/NavList/NavList.module.js +12 -0
- package/dist/components/NavList/NavListGroup.d.ts +25 -0
- package/dist/components/NavList/NavListGroup.js +40 -0
- package/dist/components/NavList/NavListItem.d.ts +53 -0
- package/dist/components/NavList/NavListItem.js +57 -0
- package/dist/components/NavList/index.d.ts +6 -0
- package/dist/components/Overlay/Overlay.css +1 -0
- package/dist/components/Overlay/Overlay.d.ts +33 -0
- package/dist/components/Overlay/Overlay.js +36 -0
- package/dist/components/Overlay/Overlay.module.js +4 -0
- package/dist/components/Overlay/index.d.ts +1 -0
- package/dist/components/PageLayout/PageLayout.css +1 -0
- package/dist/components/PageLayout/PageLayout.d.ts +26 -0
- package/dist/components/PageLayout/PageLayout.js +18 -0
- package/dist/components/PageLayout/PageLayout.module.js +4 -0
- package/dist/components/PageLayout/index.d.ts +2 -0
- package/dist/components/Popover/Popover.css +1 -0
- package/dist/components/Popover/Popover.d.ts +52 -0
- package/dist/components/Popover/Popover.js +21 -0
- package/dist/components/Popover/Popover.module.js +4 -0
- package/dist/components/Popover/index.d.ts +4 -0
- package/dist/components/Popover/usePopover.d.ts +96 -0
- package/dist/components/Popover/usePopover.js +66 -0
- package/dist/components/Prose/Prose.css +1 -0
- package/dist/components/Prose/Prose.d.ts +50 -0
- package/dist/components/Prose/Prose.js +16 -0
- package/dist/components/Prose/Prose.module.js +4 -0
- package/dist/components/Prose/index.d.ts +2 -0
- package/dist/components/Radio/Radio.d.ts +29 -0
- package/dist/components/Radio/Radio.js +24 -0
- package/dist/components/Radio/index.d.ts +2 -0
- package/dist/components/RadioGroup/RadioGroup.css +1 -0
- package/dist/components/RadioGroup/RadioGroup.d.ts +58 -0
- package/dist/components/RadioGroup/RadioGroup.js +37 -0
- package/dist/components/RadioGroup/RadioGroup.module.js +4 -0
- package/dist/components/RadioGroup/index.d.ts +2 -0
- package/dist/components/RequiredIndicator/RequiredIndicator.css +1 -0
- package/dist/components/RequiredIndicator/RequiredIndicator.d.ts +6 -0
- package/dist/components/RequiredIndicator/RequiredIndicator.js +16 -0
- package/dist/components/RequiredIndicator/RequiredIndicator.module.js +4 -0
- package/dist/components/RequiredIndicator/index.d.ts +1 -0
- package/dist/components/Row/Row.d.ts +29 -0
- package/dist/components/Row/Row.js +14 -0
- package/dist/components/Row/index.d.ts +2 -0
- package/dist/components/SegmentedControl/Segment.d.ts +24 -0
- package/dist/components/SegmentedControl/Segment.js +42 -0
- package/dist/components/SegmentedControl/SegmentedControl.css +1 -0
- package/dist/components/SegmentedControl/SegmentedControl.d.ts +25 -0
- package/dist/components/SegmentedControl/SegmentedControl.js +20 -0
- package/dist/components/SegmentedControl/SegmentedControl.module.js +10 -0
- package/dist/components/SegmentedControl/index.d.ts +4 -0
- package/dist/components/Select/Select.d.ts +27 -0
- package/dist/components/Select/Select.js +12 -0
- package/dist/components/Select/index.d.ts +2 -0
- package/dist/components/Sidebar/Sidebar.css +1 -0
- package/dist/components/Sidebar/Sidebar.d.ts +42 -0
- package/dist/components/Sidebar/Sidebar.js +24 -0
- package/dist/components/Sidebar/Sidebar.module.js +4 -0
- package/dist/components/Sidebar/index.d.ts +2 -0
- package/dist/components/SkipLink/SkipLink.css +1 -0
- package/dist/components/SkipLink/SkipLink.d.ts +20 -0
- package/dist/components/SkipLink/SkipLink.js +21 -0
- package/dist/components/SkipLink/SkipLink.module.js +4 -0
- package/dist/components/SkipLink/index.d.ts +2 -0
- package/dist/components/Spinner/Spinner.css +1 -0
- package/dist/components/Spinner/Spinner.d.ts +13 -0
- package/dist/components/Spinner/Spinner.js +33 -0
- package/dist/components/Spinner/Spinner.module.js +8 -0
- package/dist/components/Spinner/index.d.ts +1 -0
- package/dist/components/Stack/Stack.css +1 -0
- package/dist/components/Stack/Stack.d.ts +25 -0
- package/dist/components/Stack/Stack.js +21 -0
- package/dist/components/Stack/Stack.module.js +4 -0
- package/dist/components/Stack/index.d.ts +2 -0
- package/dist/components/StatusDot/StatusDot.css +1 -0
- package/dist/components/StatusDot/StatusDot.d.ts +57 -0
- package/dist/components/StatusDot/StatusDot.js +21 -0
- package/dist/components/StatusDot/StatusDot.module.js +4 -0
- package/dist/components/StatusDot/index.d.ts +2 -0
- package/dist/components/Switch/Switch.d.ts +24 -0
- package/dist/components/Switch/Switch.js +13 -0
- package/dist/components/Switch/index.d.ts +2 -0
- package/dist/components/Switcher/Switcher.css +1 -0
- package/dist/components/Switcher/Switcher.d.ts +27 -0
- package/dist/components/Switcher/Switcher.js +23 -0
- package/dist/components/Switcher/Switcher.module.js +4 -0
- package/dist/components/Switcher/index.d.ts +2 -0
- package/dist/components/Tabs/Tab.d.ts +26 -0
- package/dist/components/Tabs/Tab.js +61 -0
- package/dist/components/Tabs/TabList.d.ts +16 -0
- package/dist/components/Tabs/TabList.js +23 -0
- package/dist/components/Tabs/TabPanel.d.ts +24 -0
- package/dist/components/Tabs/TabPanel.js +22 -0
- package/dist/components/Tabs/Tabs.css +1 -0
- package/dist/components/Tabs/Tabs.d.ts +81 -0
- package/dist/components/Tabs/Tabs.js +31 -0
- package/dist/components/Tabs/Tabs.module.js +9 -0
- package/dist/components/Tabs/TabsContext.d.ts +39 -0
- package/dist/components/Tabs/TabsContext.js +5 -0
- package/dist/components/Tabs/index.d.ts +8 -0
- package/dist/components/Tabs/tabIds.d.ts +16 -0
- package/dist/components/Tabs/tabIds.js +10 -0
- package/dist/components/Tabs/useTabsContext.d.ts +9 -0
- package/dist/components/Tabs/useTabsContext.js +11 -0
- package/dist/components/Text/Text.css +1 -0
- package/dist/components/Text/Text.d.ts +40 -0
- package/dist/components/Text/Text.js +17 -0
- package/dist/components/Text/Text.module.js +4 -0
- package/dist/components/Text/index.d.ts +2 -0
- package/dist/components/TextControl/TextControl.css +1 -0
- package/dist/components/TextControl/TextControl.d.ts +22 -0
- package/dist/components/TextControl/TextControl.js +23 -0
- package/dist/components/TextControl/TextControl.module.js +4 -0
- package/dist/components/TextControl/index.d.ts +1 -0
- package/dist/components/TextInput/TextInput.d.ts +31 -0
- package/dist/components/TextInput/TextInput.js +13 -0
- package/dist/components/TextInput/index.d.ts +2 -0
- package/dist/components/Textarea/Textarea.d.ts +24 -0
- package/dist/components/Textarea/Textarea.js +12 -0
- package/dist/components/Textarea/index.d.ts +2 -0
- package/dist/components/Theme/Theme.d.ts +46 -0
- package/dist/components/Theme/Theme.js +18 -0
- package/dist/components/Theme/index.d.ts +2 -0
- package/dist/components/Tooltip/Tooltip.css +1 -0
- package/dist/components/Tooltip/Tooltip.d.ts +49 -0
- package/dist/components/Tooltip/Tooltip.js +22 -0
- package/dist/components/Tooltip/Tooltip.module.js +4 -0
- package/dist/components/Tooltip/index.d.ts +4 -0
- package/dist/components/Tooltip/tooltipCoordinator.d.ts +14 -0
- package/dist/components/Tooltip/tooltipCoordinator.js +17 -0
- package/dist/components/Tooltip/useTooltip.d.ts +119 -0
- package/dist/components/Tooltip/useTooltip.js +74 -0
- package/dist/components/VisuallyHidden/VisuallyHidden.css +1 -0
- package/dist/components/VisuallyHidden/VisuallyHidden.d.ts +14 -0
- package/dist/components/VisuallyHidden/VisuallyHidden.js +20 -0
- package/dist/components/VisuallyHidden/VisuallyHidden.module.js +4 -0
- package/dist/components/VisuallyHidden/index.d.ts +2 -0
- package/dist/errors/MissingContextError.d.ts +11 -0
- package/dist/errors/MissingContextError.js +9 -0
- package/dist/errors/PopoverRefusedError.d.ts +12 -0
- package/dist/errors/PopoverRefusedError.js +9 -0
- package/dist/errors/index.d.ts +2 -0
- package/dist/forms/ControlSize.d.ts +4 -0
- package/dist/forms/FieldContext.d.ts +29 -0
- package/dist/forms/FieldContext.js +5 -0
- package/dist/forms/RadioGroupContext.d.ts +34 -0
- package/dist/forms/RadioGroupContext.js +5 -0
- package/dist/forms/hasContent.d.ts +10 -0
- package/dist/forms/hasContent.js +7 -0
- package/dist/forms/index.d.ts +8 -0
- package/dist/forms/useFieldControl.d.ts +36 -0
- package/dist/forms/useFieldControl.js +29 -0
- package/dist/forms/useRadioGroupItem.d.ts +50 -0
- package/dist/forms/useRadioGroupItem.js +27 -0
- package/dist/index.d.ts +95 -0
- package/dist/index.js +67 -0
- package/dist/layout/Space.d.ts +4 -0
- package/dist/layout/alignment.d.ts +8 -0
- package/dist/layout/index.d.ts +5 -0
- package/dist/layout/listRole.d.ts +11 -0
- package/dist/layout/listRole.js +6 -0
- package/dist/layout/spaceValue.d.ts +8 -0
- package/dist/layout/spaceValue.js +6 -0
- package/dist/layout/withCustomProperties.d.ts +9 -0
- package/dist/layout/withCustomProperties.js +9 -0
- package/dist/overlays/OverlayDelay.d.ts +13 -0
- package/dist/overlays/OverlayPlacement.d.ts +6 -0
- package/dist/overlays/anchorNameFor.d.ts +7 -0
- package/dist/overlays/anchorNameFor.js +6 -0
- package/dist/overlays/index.d.ts +6 -0
- package/dist/overlays/mergeProps.d.ts +13 -0
- package/dist/overlays/mergeProps.js +30 -0
- package/dist/overlays/syncPopover.d.ts +11 -0
- package/dist/overlays/syncPopover.js +25 -0
- package/dist/overlays/useOverlay.d.ts +71 -0
- package/dist/overlays/useOverlay.js +56 -0
- package/dist/styles.css +1 -0
- package/fonts/playful.css +3 -0
- package/package.json +103 -3
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { FieldContext as e } from "./FieldContext.js";
|
|
2
|
+
import { useContext as t } from "react";
|
|
3
|
+
import { c as n } from "react/compiler-runtime";
|
|
4
|
+
//#region src/forms/useFieldControl.ts
|
|
5
|
+
function r(r) {
|
|
6
|
+
let i = n(15), { "aria-describedby": a, "aria-invalid": o, disabled: s, id: c, required: l } = r, u = t(e);
|
|
7
|
+
if (u === null) {
|
|
8
|
+
let e;
|
|
9
|
+
return i[0] !== a || i[1] !== s || i[2] !== c || i[3] !== o || i[4] !== l ? (e = {
|
|
10
|
+
"aria-describedby": a,
|
|
11
|
+
"aria-invalid": o,
|
|
12
|
+
disabled: s,
|
|
13
|
+
id: c,
|
|
14
|
+
required: l
|
|
15
|
+
}, i[0] = a, i[1] = s, i[2] = c, i[3] = o, i[4] = l, i[5] = e) : e = i[5], e;
|
|
16
|
+
}
|
|
17
|
+
let d;
|
|
18
|
+
i[6] !== u.describedBy || i[7] !== a ? (d = [u.describedBy, a].filter(Boolean), i[6] = u.describedBy, i[7] = a, i[8] = d) : d = i[8];
|
|
19
|
+
let f = d.join(" "), p = f === "" ? void 0 : f, m = o ?? (u.invalid || void 0), h = s ?? (u.disabled || void 0), g = l ?? (u.required || void 0), _;
|
|
20
|
+
return i[9] !== u.controlId || i[10] !== p || i[11] !== m || i[12] !== h || i[13] !== g ? (_ = {
|
|
21
|
+
"aria-describedby": p,
|
|
22
|
+
"aria-invalid": m,
|
|
23
|
+
disabled: h,
|
|
24
|
+
id: u.controlId,
|
|
25
|
+
required: g
|
|
26
|
+
}, i[9] = u.controlId, i[10] = p, i[11] = m, i[12] = h, i[13] = g, i[14] = _) : _ = i[14], _;
|
|
27
|
+
}
|
|
28
|
+
//#endregion
|
|
29
|
+
export { r as useFieldControl };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { ChangeEventHandler } from "react";
|
|
2
|
+
interface RadioGroupItemOptions {
|
|
3
|
+
/**
|
|
4
|
+
* The radio's own change handler
|
|
5
|
+
*/
|
|
6
|
+
onChange: ChangeEventHandler<HTMLInputElement> | undefined;
|
|
7
|
+
/**
|
|
8
|
+
* The value the radio stands for
|
|
9
|
+
*/
|
|
10
|
+
value: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* The props a radio takes from the `RadioGroup` around it
|
|
14
|
+
*/
|
|
15
|
+
export interface RadioGroupItemProps {
|
|
16
|
+
/**
|
|
17
|
+
* Whether the radio is selected, when the group is controlled
|
|
18
|
+
*/
|
|
19
|
+
checked?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Present when the group shows an error, so the radio can draw it
|
|
22
|
+
*/
|
|
23
|
+
"data-invalid"?: "";
|
|
24
|
+
/**
|
|
25
|
+
* Whether the radio starts selected, when the group is uncontrolled
|
|
26
|
+
*/
|
|
27
|
+
defaultChecked?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* The group's shared name
|
|
30
|
+
*/
|
|
31
|
+
name?: string;
|
|
32
|
+
/**
|
|
33
|
+
* The radio's own handler, followed inside a group by reporting the radio's value to the group
|
|
34
|
+
*/
|
|
35
|
+
onChange: ChangeEventHandler<HTMLInputElement> | undefined;
|
|
36
|
+
/**
|
|
37
|
+
* Whether the group needs an answer
|
|
38
|
+
*/
|
|
39
|
+
required?: boolean;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Connects a radio to the `RadioGroup` around it
|
|
43
|
+
*
|
|
44
|
+
* @param options the radio's own `onChange` and its `value`
|
|
45
|
+
* @returns the props to spread on the radio input after its own. Outside a group, only the radio's `onChange`. Inside
|
|
46
|
+
* one: the selection from the group's `value` or `defaultValue`, the group's `name` and `required`, `data-invalid`
|
|
47
|
+
* while the group has an error, and an `onChange` that runs the radio's own and then reports its value to the group.
|
|
48
|
+
*/
|
|
49
|
+
export declare function useRadioGroupItem({ onChange, value }: RadioGroupItemOptions): RadioGroupItemProps;
|
|
50
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { RadioGroupContext as e } from "./RadioGroupContext.js";
|
|
2
|
+
import { useContext as t } from "react";
|
|
3
|
+
import { c as n } from "react/compiler-runtime";
|
|
4
|
+
//#region src/forms/useRadioGroupItem.ts
|
|
5
|
+
function r(r) {
|
|
6
|
+
let i = n(16), { onChange: a, value: o } = r, s = t(e);
|
|
7
|
+
if (s === null) {
|
|
8
|
+
let e;
|
|
9
|
+
return i[0] === a ? e = i[1] : (e = { onChange: a }, i[0] = a, i[1] = e), e;
|
|
10
|
+
}
|
|
11
|
+
let c;
|
|
12
|
+
i[2] !== s.defaultValue || i[3] !== s.value || i[4] !== o ? (c = {}, s.value === void 0 ? s.defaultValue !== void 0 && (c.defaultChecked = s.defaultValue === o) : c.checked = s.value === o, i[2] = s.defaultValue, i[3] = s.value, i[4] = o, i[5] = c) : c = i[5];
|
|
13
|
+
let l = s.invalid ? "" : void 0, u;
|
|
14
|
+
i[6] !== s || i[7] !== a || i[8] !== o ? (u = (e) => {
|
|
15
|
+
a?.(e), s.onValueChange?.(o);
|
|
16
|
+
}, i[6] = s, i[7] = a, i[8] = o, i[9] = u) : u = i[9];
|
|
17
|
+
let d;
|
|
18
|
+
return i[10] !== s.name || i[11] !== s.required || i[12] !== c || i[13] !== l || i[14] !== u ? (d = {
|
|
19
|
+
...c,
|
|
20
|
+
"data-invalid": l,
|
|
21
|
+
name: s.name,
|
|
22
|
+
onChange: u,
|
|
23
|
+
required: s.required
|
|
24
|
+
}, i[10] = s.name, i[11] = s.required, i[12] = c, i[13] = l, i[14] = u, i[15] = d) : d = i[15], d;
|
|
25
|
+
}
|
|
26
|
+
//#endregion
|
|
27
|
+
export { r as useRadioGroupItem };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
export { Alert } from "./components/Alert";
|
|
2
|
+
export type { AlertProps, AlertTone } from "./components/Alert";
|
|
3
|
+
export { Avatar } from "./components/Avatar";
|
|
4
|
+
export type { AvatarProps, AvatarSize } from "./components/Avatar";
|
|
5
|
+
export { AvatarGroup } from "./components/AvatarGroup";
|
|
6
|
+
export type { AvatarGroupProps } from "./components/AvatarGroup";
|
|
7
|
+
export { Badge } from "./components/Badge";
|
|
8
|
+
export type { BadgeElement, BadgeProps, BadgeTone, BadgeVariant } from "./components/Badge";
|
|
9
|
+
export { Box } from "./components/Box";
|
|
10
|
+
export type { BoxElement, BoxProps, PolymorphicProps } from "./components/Box";
|
|
11
|
+
export { Button } from "./components/Button";
|
|
12
|
+
export type { ButtonProps, ButtonSize, ButtonVariant } from "./components/Button";
|
|
13
|
+
export { Card } from "./components/Card";
|
|
14
|
+
export type { CardPadding, CardProps } from "./components/Card";
|
|
15
|
+
export { Center } from "./components/Center";
|
|
16
|
+
export type { CenterProps, CenterWidth } from "./components/Center";
|
|
17
|
+
export { Checkbox } from "./components/Checkbox";
|
|
18
|
+
export type { CheckboxProps } from "./components/Checkbox";
|
|
19
|
+
export { Cluster } from "./components/Cluster";
|
|
20
|
+
export type { ClusterProps } from "./components/Cluster";
|
|
21
|
+
export { Code } from "./components/Code";
|
|
22
|
+
export type { CodeProps } from "./components/Code";
|
|
23
|
+
export { Counter } from "./components/Counter";
|
|
24
|
+
export type { CounterProps } from "./components/Counter";
|
|
25
|
+
export { Cover } from "./components/Cover";
|
|
26
|
+
export type { CoverProps } from "./components/Cover";
|
|
27
|
+
export { Divider } from "./components/Divider";
|
|
28
|
+
export type { DividerOrientation, DividerProps } from "./components/Divider";
|
|
29
|
+
export { Field } from "./components/Field";
|
|
30
|
+
export type { FieldElement, FieldProps } from "./components/Field";
|
|
31
|
+
export { Fieldset } from "./components/Fieldset";
|
|
32
|
+
export type { FieldsetProps } from "./components/Fieldset";
|
|
33
|
+
export { Frame } from "./components/Frame";
|
|
34
|
+
export type { FrameProps } from "./components/Frame";
|
|
35
|
+
export { Grid } from "./components/Grid";
|
|
36
|
+
export type { GridProps } from "./components/Grid";
|
|
37
|
+
export { Heading } from "./components/Heading";
|
|
38
|
+
export type { HeadingLevel, HeadingProps, HeadingSize } from "./components/Heading";
|
|
39
|
+
export { AddIcon, ChevronDownIcon, CloseIcon, ColorModeIcon, DeleteIcon, InfoIcon, MoreHorizontalIcon, MoreVerticalIcon, PaletteIcon, RefreshIcon, RemoveIcon, SendIcon, } from "./components/Icon";
|
|
40
|
+
export type { IconProps } from "./components/Icon";
|
|
41
|
+
export { IconButton } from "./components/IconButton";
|
|
42
|
+
export type { IconButtonProps } from "./components/IconButton";
|
|
43
|
+
export { Kbd } from "./components/Kbd";
|
|
44
|
+
export type { KbdProps } from "./components/Kbd";
|
|
45
|
+
export { Link } from "./components/Link";
|
|
46
|
+
export type { LinkElement, LinkProps, LinkTone, LinkUnderline } from "./components/Link";
|
|
47
|
+
export { Listbox, ListboxOption } from "./components/Listbox";
|
|
48
|
+
export type { ListboxOptionProps, ListboxProps } from "./components/Listbox";
|
|
49
|
+
export { NavList, NavListGroup, NavListItem } from "./components/NavList";
|
|
50
|
+
export type { NavListGroupProps, NavListItemElement, NavListItemProps, NavListProps } from "./components/NavList";
|
|
51
|
+
export { PageLayout } from "./components/PageLayout";
|
|
52
|
+
export type { PageLayoutProps } from "./components/PageLayout";
|
|
53
|
+
export { Popover, usePopover } from "./components/Popover";
|
|
54
|
+
export type { PopoverProps, UsePopoverOptions, UsePopoverResult } from "./components/Popover";
|
|
55
|
+
export { Prose } from "./components/Prose";
|
|
56
|
+
export type { ProseCodeOverflow, ProseProps, ProseSize } from "./components/Prose";
|
|
57
|
+
export { Radio } from "./components/Radio";
|
|
58
|
+
export type { RadioProps } from "./components/Radio";
|
|
59
|
+
export { RadioGroup } from "./components/RadioGroup";
|
|
60
|
+
export type { RadioGroupOrientation, RadioGroupProps } from "./components/RadioGroup";
|
|
61
|
+
export { Row } from "./components/Row";
|
|
62
|
+
export type { RowProps } from "./components/Row";
|
|
63
|
+
export { Segment, SegmentedControl } from "./components/SegmentedControl";
|
|
64
|
+
export type { SegmentedControlProps, SegmentProps } from "./components/SegmentedControl";
|
|
65
|
+
export { Select } from "./components/Select";
|
|
66
|
+
export type { SelectProps } from "./components/Select";
|
|
67
|
+
export { Sidebar } from "./components/Sidebar";
|
|
68
|
+
export type { SidebarProps } from "./components/Sidebar";
|
|
69
|
+
export { SkipLink } from "./components/SkipLink";
|
|
70
|
+
export type { SkipLinkProps } from "./components/SkipLink";
|
|
71
|
+
export { Stack } from "./components/Stack";
|
|
72
|
+
export type { StackProps } from "./components/Stack";
|
|
73
|
+
export { StatusDot } from "./components/StatusDot";
|
|
74
|
+
export type { StatusDotProps, StatusDotSize, StatusDotVariant } from "./components/StatusDot";
|
|
75
|
+
export { Switch } from "./components/Switch";
|
|
76
|
+
export type { SwitchProps } from "./components/Switch";
|
|
77
|
+
export { Switcher } from "./components/Switcher";
|
|
78
|
+
export type { SwitcherProps } from "./components/Switcher";
|
|
79
|
+
export { Tab, TabList, TabPanel, Tabs } from "./components/Tabs";
|
|
80
|
+
export type { TabListProps, TabPanelProps, TabProps, TabsActivation, TabsOrientation, TabsProps, TabsVariant, } from "./components/Tabs";
|
|
81
|
+
export { Text } from "./components/Text";
|
|
82
|
+
export type { TextProps, TextSize, TextTone, TextWeight } from "./components/Text";
|
|
83
|
+
export { Textarea } from "./components/Textarea";
|
|
84
|
+
export type { TextareaProps } from "./components/Textarea";
|
|
85
|
+
export { TextInput } from "./components/TextInput";
|
|
86
|
+
export type { TextInputProps, TextInputType } from "./components/TextInput";
|
|
87
|
+
export { Theme } from "./components/Theme";
|
|
88
|
+
export type { PaletteName, ThemeMode, ThemeName, ThemeProps } from "./components/Theme";
|
|
89
|
+
export { Tooltip, useTooltip } from "./components/Tooltip";
|
|
90
|
+
export type { TooltipProps, TooltipRelationship, UseTooltipOptions, UseTooltipResult } from "./components/Tooltip";
|
|
91
|
+
export { VisuallyHidden } from "./components/VisuallyHidden";
|
|
92
|
+
export type { VisuallyHiddenProps } from "./components/VisuallyHidden";
|
|
93
|
+
export type { ControlSize } from "./forms";
|
|
94
|
+
export type { Alignment, Justification, Space } from "./layout";
|
|
95
|
+
export type { OverlayDelay, OverlayPlacement } from "./overlays";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { Box as e } from "./components/Box/Box.js";
|
|
2
|
+
import { Alert as t } from "./components/Alert/Alert.js";
|
|
3
|
+
import { Avatar as n } from "./components/Avatar/Avatar.js";
|
|
4
|
+
import { VisuallyHidden as r } from "./components/VisuallyHidden/VisuallyHidden.js";
|
|
5
|
+
import { AvatarGroup as i } from "./components/AvatarGroup/AvatarGroup.js";
|
|
6
|
+
import { Badge as a } from "./components/Badge/Badge.js";
|
|
7
|
+
import { Button as o } from "./components/Button/Button.js";
|
|
8
|
+
import { Card as s } from "./components/Card/Card.js";
|
|
9
|
+
import { Center as c } from "./components/Center/Center.js";
|
|
10
|
+
import { Checkbox as l } from "./components/Checkbox/Checkbox.js";
|
|
11
|
+
import { Cluster as u } from "./components/Cluster/Cluster.js";
|
|
12
|
+
import { Code as d } from "./components/Code/Code.js";
|
|
13
|
+
import { Counter as f } from "./components/Counter/Counter.js";
|
|
14
|
+
import { Cover as p } from "./components/Cover/Cover.js";
|
|
15
|
+
import { Divider as m } from "./components/Divider/Divider.js";
|
|
16
|
+
import { Field as h } from "./components/Field/Field.js";
|
|
17
|
+
import { Fieldset as g } from "./components/Fieldset/Fieldset.js";
|
|
18
|
+
import { Frame as _ } from "./components/Frame/Frame.js";
|
|
19
|
+
import { Grid as v } from "./components/Grid/Grid.js";
|
|
20
|
+
import { Heading as y } from "./components/Heading/Heading.js";
|
|
21
|
+
import { AddIcon as b } from "./components/Icon/AddIcon.js";
|
|
22
|
+
import { ChevronDownIcon as x } from "./components/Icon/ChevronDownIcon.js";
|
|
23
|
+
import { CloseIcon as S } from "./components/Icon/CloseIcon.js";
|
|
24
|
+
import { ColorModeIcon as C } from "./components/Icon/ColorModeIcon.js";
|
|
25
|
+
import { DeleteIcon as w } from "./components/Icon/DeleteIcon.js";
|
|
26
|
+
import { InfoIcon as T } from "./components/Icon/InfoIcon.js";
|
|
27
|
+
import { MoreHorizontalIcon as E } from "./components/Icon/MoreHorizontalIcon.js";
|
|
28
|
+
import { MoreVerticalIcon as D } from "./components/Icon/MoreVerticalIcon.js";
|
|
29
|
+
import { PaletteIcon as O } from "./components/Icon/PaletteIcon.js";
|
|
30
|
+
import { RefreshIcon as k } from "./components/Icon/RefreshIcon.js";
|
|
31
|
+
import { RemoveIcon as A } from "./components/Icon/RemoveIcon.js";
|
|
32
|
+
import { SendIcon as j } from "./components/Icon/SendIcon.js";
|
|
33
|
+
import { Kbd as M } from "./components/Kbd/Kbd.js";
|
|
34
|
+
import { Tooltip as N } from "./components/Tooltip/Tooltip.js";
|
|
35
|
+
import { useTooltip as P } from "./components/Tooltip/useTooltip.js";
|
|
36
|
+
import { IconButton as F } from "./components/IconButton/IconButton.js";
|
|
37
|
+
import { Link as I } from "./components/Link/Link.js";
|
|
38
|
+
import { Listbox as L } from "./components/Listbox/Listbox.js";
|
|
39
|
+
import { ListboxOption as R } from "./components/Listbox/ListboxOption.js";
|
|
40
|
+
import { NavList as z } from "./components/NavList/NavList.js";
|
|
41
|
+
import { NavListGroup as B } from "./components/NavList/NavListGroup.js";
|
|
42
|
+
import { NavListItem as V } from "./components/NavList/NavListItem.js";
|
|
43
|
+
import { PageLayout as H } from "./components/PageLayout/PageLayout.js";
|
|
44
|
+
import { Popover as U } from "./components/Popover/Popover.js";
|
|
45
|
+
import { usePopover as W } from "./components/Popover/usePopover.js";
|
|
46
|
+
import { Prose as G } from "./components/Prose/Prose.js";
|
|
47
|
+
import { Radio as K } from "./components/Radio/Radio.js";
|
|
48
|
+
import { RadioGroup as q } from "./components/RadioGroup/RadioGroup.js";
|
|
49
|
+
import { Row as J } from "./components/Row/Row.js";
|
|
50
|
+
import { Segment as Y } from "./components/SegmentedControl/Segment.js";
|
|
51
|
+
import { SegmentedControl as X } from "./components/SegmentedControl/SegmentedControl.js";
|
|
52
|
+
import { Select as Z } from "./components/Select/Select.js";
|
|
53
|
+
import { Sidebar as Q } from "./components/Sidebar/Sidebar.js";
|
|
54
|
+
import { SkipLink as $ } from "./components/SkipLink/SkipLink.js";
|
|
55
|
+
import { Stack as ee } from "./components/Stack/Stack.js";
|
|
56
|
+
import { StatusDot as te } from "./components/StatusDot/StatusDot.js";
|
|
57
|
+
import { Switch as ne } from "./components/Switch/Switch.js";
|
|
58
|
+
import { Switcher as re } from "./components/Switcher/Switcher.js";
|
|
59
|
+
import { Tab as ie } from "./components/Tabs/Tab.js";
|
|
60
|
+
import { TabList as ae } from "./components/Tabs/TabList.js";
|
|
61
|
+
import { TabPanel as oe } from "./components/Tabs/TabPanel.js";
|
|
62
|
+
import { Tabs as se } from "./components/Tabs/Tabs.js";
|
|
63
|
+
import { Text as ce } from "./components/Text/Text.js";
|
|
64
|
+
import { Textarea as le } from "./components/Textarea/Textarea.js";
|
|
65
|
+
import { TextInput as ue } from "./components/TextInput/TextInput.js";
|
|
66
|
+
import { Theme as de } from "./components/Theme/Theme.js";
|
|
67
|
+
export { b as AddIcon, t as Alert, n as Avatar, i as AvatarGroup, a as Badge, e as Box, o as Button, s as Card, c as Center, l as Checkbox, x as ChevronDownIcon, S as CloseIcon, u as Cluster, d as Code, C as ColorModeIcon, f as Counter, p as Cover, w as DeleteIcon, m as Divider, h as Field, g as Fieldset, _ as Frame, v as Grid, y as Heading, F as IconButton, T as InfoIcon, M as Kbd, I as Link, L as Listbox, R as ListboxOption, E as MoreHorizontalIcon, D as MoreVerticalIcon, z as NavList, B as NavListGroup, V as NavListItem, H as PageLayout, O as PaletteIcon, U as Popover, G as Prose, K as Radio, q as RadioGroup, k as RefreshIcon, A as RemoveIcon, J as Row, Y as Segment, X as SegmentedControl, Z as Select, j as SendIcon, Q as Sidebar, $ as SkipLink, ee as Stack, te as StatusDot, ne as Switch, re as Switcher, ie as Tab, ae as TabList, oe as TabPanel, se as Tabs, ce as Text, ue as TextInput, le as Textarea, de as Theme, N as Tooltip, r as VisuallyHidden, W as usePopover, P as useTooltip };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Placement of children on a container's cross axis
|
|
3
|
+
*/
|
|
4
|
+
export type Alignment = "start" | "center" | "end" | "stretch" | "baseline";
|
|
5
|
+
/**
|
|
6
|
+
* Distribution of children along a container's main axis
|
|
7
|
+
*/
|
|
8
|
+
export type Justification = "start" | "center" | "end" | "between";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { AriaRole } from "react";
|
|
2
|
+
import type { BoxElement } from "../components/Box";
|
|
3
|
+
/**
|
|
4
|
+
* Picks the role for a container that removes list markers, which makes WebKit stop exposing
|
|
5
|
+
* `ul` and `ol` as lists
|
|
6
|
+
*
|
|
7
|
+
* @param element the element the container renders
|
|
8
|
+
* @param role the role the consumer passed, if any
|
|
9
|
+
* @returns `list` for a `ul` or `ol` without a role, otherwise the given role
|
|
10
|
+
*/
|
|
11
|
+
export declare function listRole(element: BoxElement, role: AriaRole | undefined): AriaRole | undefined;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Space } from "./Space";
|
|
2
|
+
/**
|
|
3
|
+
* Resolves a spacing step to a CSS value
|
|
4
|
+
*
|
|
5
|
+
* @param space the spacing step
|
|
6
|
+
* @returns `0px` (a length, so it stays valid inside `calc()`), or the matching `--sui-space-*` token with the default theme's value as fallback
|
|
7
|
+
*/
|
|
8
|
+
export declare function spaceValue(space: Space): string;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { CSSProperties } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Merges a component's custom properties with the consumer's style
|
|
4
|
+
*
|
|
5
|
+
* @param customProperties the component's custom properties; undefined values are not rendered
|
|
6
|
+
* @param style the consumer's style, whose declarations win on conflict
|
|
7
|
+
* @returns the merged style
|
|
8
|
+
*/
|
|
9
|
+
export declare function withCustomProperties(customProperties: Record<`--${string}`, string | undefined>, style: CSSProperties | undefined): CSSProperties;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Delays before an overlay shows and hides, in milliseconds
|
|
3
|
+
*/
|
|
4
|
+
export interface OverlayDelay {
|
|
5
|
+
/**
|
|
6
|
+
* Time between the pointer leaving the trigger and overlay, and the overlay hiding
|
|
7
|
+
*/
|
|
8
|
+
hide?: number;
|
|
9
|
+
/**
|
|
10
|
+
* Time between the pointer entering the trigger and the overlay showing
|
|
11
|
+
*/
|
|
12
|
+
show?: number;
|
|
13
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Side of the trigger an overlay opens on. `top` and `bottom` centre it on the trigger, and `top-start`, `top-end`,
|
|
3
|
+
* `bottom-start` and `bottom-end` line its start or end edge up with the trigger's instead, so it grows away from that
|
|
4
|
+
* edge. `start` and `end` follow the writing direction.
|
|
5
|
+
*/
|
|
6
|
+
export type OverlayPlacement = "bottom" | "bottom-end" | "bottom-start" | "end" | "start" | "top" | "top-end" | "top-start";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Builds the `anchor-name` that ties an overlay to its trigger
|
|
3
|
+
*
|
|
4
|
+
* @param id the overlay's generated id
|
|
5
|
+
* @returns a dashed ident unique to the id, with the punctuation React's ids contain removed
|
|
6
|
+
*/
|
|
7
|
+
export declare function anchorNameFor(id: string): string;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { anchorNameFor } from "./anchorNameFor";
|
|
2
|
+
export { mergeProps } from "./mergeProps";
|
|
3
|
+
export type { OverlayDelay } from "./OverlayDelay";
|
|
4
|
+
export type { OverlayPlacement } from "./OverlayPlacement";
|
|
5
|
+
export { syncPopover } from "./syncPopover";
|
|
6
|
+
export { useOverlay } from "./useOverlay";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Combines a consumer's own props with the props an overlay hook sets on the same element
|
|
3
|
+
*
|
|
4
|
+
* @param own the consumer's props, if any
|
|
5
|
+
* @param hook the props the hook sets
|
|
6
|
+
* @returns the consumer's props with the hook's added. Where both set a prop, both functions run, the consumer's
|
|
7
|
+
* first; `aria-describedby` and `aria-labelledby` list the hook's ids before the consumer's; `style` objects merge,
|
|
8
|
+
* the hook's properties winning except `anchorName`, which lists the hook's name before the consumer's when the
|
|
9
|
+
* consumer's is a list of dashed idents, so one trigger can anchor two overlays, and otherwise takes the hook's name,
|
|
10
|
+
* in place of a keyword such as `none` or `inherit`; and any other prop takes the hook's value. A hook value of
|
|
11
|
+
* `undefined` keeps the consumer's.
|
|
12
|
+
*/
|
|
13
|
+
export declare function mergeProps<Own extends object, Hook extends object>(own: (Own & Partial<Hook>) | undefined, hook: Hook): Omit<Own, keyof Hook> & Hook;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
//#region src/overlays/mergeProps.ts
|
|
2
|
+
var e = /* @__PURE__ */ new Set(["aria-describedby", "aria-labelledby"]), t = /^--[-\w\u{80}-\u{10FFFF}]+$/u;
|
|
3
|
+
function n(e, t) {
|
|
4
|
+
let n = { ...e };
|
|
5
|
+
for (let [e, i] of Object.entries(t)) n[e] = r(e, n[e], i);
|
|
6
|
+
return n;
|
|
7
|
+
}
|
|
8
|
+
function r(t, n, r) {
|
|
9
|
+
return n === void 0 ? r : r === void 0 ? n : o(n) && o(r) ? (e) => {
|
|
10
|
+
n(e), r(e);
|
|
11
|
+
} : e.has(t) ? `${String(r)} ${String(n)}` : t === "style" && s(n) && s(r) ? i(n, r) : r;
|
|
12
|
+
}
|
|
13
|
+
function i(e, t) {
|
|
14
|
+
let n = {
|
|
15
|
+
...e,
|
|
16
|
+
...t
|
|
17
|
+
};
|
|
18
|
+
return t.anchorName !== void 0 && a(e.anchorName) && (n.anchorName = `${t.anchorName}, ${e.anchorName}`), n;
|
|
19
|
+
}
|
|
20
|
+
function a(e) {
|
|
21
|
+
return e !== void 0 && e.split(",").every((e) => t.test(e.trim()));
|
|
22
|
+
}
|
|
23
|
+
function o(e) {
|
|
24
|
+
return typeof e == "function";
|
|
25
|
+
}
|
|
26
|
+
function s(e) {
|
|
27
|
+
return typeof e == "object" && !!e;
|
|
28
|
+
}
|
|
29
|
+
//#endregion
|
|
30
|
+
export { n as mergeProps };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shows or hides a popover to match `open`, leaving it alone when it already matches. The browser refuses while it
|
|
3
|
+
* shows or hides another popover, so a refusal is tried again on the next task, unless the popover has left the
|
|
4
|
+
* document by then. A second refusal is thrown from the timer as a `PopoverRefusedError`, where it is reported without
|
|
5
|
+
* unmounting the app; any other error is thrown at once.
|
|
6
|
+
*
|
|
7
|
+
* @param popover the popover element
|
|
8
|
+
* @param open whether it should be shown
|
|
9
|
+
* @returns a function that cancels the retry, for an effect's cleanup
|
|
10
|
+
*/
|
|
11
|
+
export declare function syncPopover(popover: HTMLElement, open: boolean): () => void;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { PopoverRefusedError as e } from "../errors/PopoverRefusedError.js";
|
|
2
|
+
//#region src/overlays/syncPopover.ts
|
|
3
|
+
function t(t, r) {
|
|
4
|
+
if (n(t, r) === null) return () => {};
|
|
5
|
+
let i = setTimeout(() => {
|
|
6
|
+
if (!t.isConnected) return;
|
|
7
|
+
let i = n(t, r);
|
|
8
|
+
if (i !== null) throw new e(t, r, i);
|
|
9
|
+
}, 0);
|
|
10
|
+
return () => {
|
|
11
|
+
clearTimeout(i);
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
function n(e, t) {
|
|
15
|
+
let n = e.matches(":popover-open");
|
|
16
|
+
try {
|
|
17
|
+
t && !n ? e.showPopover() : !t && n && e.hidePopover();
|
|
18
|
+
} catch (e) {
|
|
19
|
+
if (e instanceof DOMException && e.name === "InvalidStateError") return e;
|
|
20
|
+
throw e;
|
|
21
|
+
}
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
export { t as syncPopover };
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { OverlayDelay } from "./OverlayDelay";
|
|
2
|
+
interface UseOverlayOptions {
|
|
3
|
+
/**
|
|
4
|
+
* Whether the overlay starts open when uncontrolled
|
|
5
|
+
*/
|
|
6
|
+
defaultOpen: boolean;
|
|
7
|
+
/**
|
|
8
|
+
* Show and hide delays, in milliseconds
|
|
9
|
+
*/
|
|
10
|
+
delay: Required<OverlayDelay>;
|
|
11
|
+
/**
|
|
12
|
+
* Called with the requested open state whenever the overlay asks to open or close
|
|
13
|
+
*/
|
|
14
|
+
onOpenChange?: (open: boolean) => void;
|
|
15
|
+
/**
|
|
16
|
+
* Controls whether the overlay is open
|
|
17
|
+
*/
|
|
18
|
+
open?: boolean;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* An overlay's identity and open state, and the requests that change it. Each request cancels any pending one.
|
|
22
|
+
*/
|
|
23
|
+
interface OverlayState {
|
|
24
|
+
/**
|
|
25
|
+
* `anchor-name` that ties the overlay's position to its trigger
|
|
26
|
+
*/
|
|
27
|
+
anchorName: string;
|
|
28
|
+
/**
|
|
29
|
+
* Cancels a pending delayed show or hide
|
|
30
|
+
*/
|
|
31
|
+
cancelDelay: () => void;
|
|
32
|
+
/**
|
|
33
|
+
* Hides the overlay at once
|
|
34
|
+
*/
|
|
35
|
+
hide: () => void;
|
|
36
|
+
/**
|
|
37
|
+
* Hides the overlay after the hide delay, unless another request comes first
|
|
38
|
+
*/
|
|
39
|
+
hideAfterDelay: () => void;
|
|
40
|
+
/**
|
|
41
|
+
* The overlay element's `id`
|
|
42
|
+
*/
|
|
43
|
+
id: string;
|
|
44
|
+
/**
|
|
45
|
+
* Whether the overlay is open
|
|
46
|
+
*/
|
|
47
|
+
open: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Shows the overlay at once
|
|
50
|
+
*/
|
|
51
|
+
show: () => void;
|
|
52
|
+
/**
|
|
53
|
+
* Shows the overlay after the show delay, unless another request comes first
|
|
54
|
+
*/
|
|
55
|
+
showAfterDelay: () => void;
|
|
56
|
+
/**
|
|
57
|
+
* Shows the overlay once the current task has finished, unless another request comes first
|
|
58
|
+
*/
|
|
59
|
+
showAfterTask: () => void;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Holds an overlay's open state, controlled or uncontrolled, and hides an open overlay on Escape. An Escape that
|
|
63
|
+
* hides the overlay has its default action prevented, so a dialog around the trigger stays open. Escape is left alone
|
|
64
|
+
* while it ends a text composition, and when the overlay cannot close because it is controlled with no `onOpenChange`.
|
|
65
|
+
*
|
|
66
|
+
* @param options the initial or controlled open state, the delays and the change callback
|
|
67
|
+
* @returns the overlay's id, the `anchor-name` that ties it to its trigger, whether it is open, and the requests that
|
|
68
|
+
* change it
|
|
69
|
+
*/
|
|
70
|
+
export declare function useOverlay({ defaultOpen, delay, onOpenChange, open: controlledOpen, }: UseOverlayOptions): OverlayState;
|
|
71
|
+
export {};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { anchorNameFor as e } from "./anchorNameFor.js";
|
|
2
|
+
import { useEffect as t, useEffectEvent as n, useId as r, useRef as i, useState as a } from "react";
|
|
3
|
+
//#region src/overlays/useOverlay.ts
|
|
4
|
+
function o({ defaultOpen: o, delay: s, onOpenChange: c, open: l }) {
|
|
5
|
+
let u = r(), [d, f] = a(o), p = i(void 0), m = l ?? d;
|
|
6
|
+
function h() {
|
|
7
|
+
clearTimeout(p.current), p.current = void 0;
|
|
8
|
+
}
|
|
9
|
+
function g(e) {
|
|
10
|
+
l === void 0 && f(e), c?.(e);
|
|
11
|
+
}
|
|
12
|
+
function _(e, t) {
|
|
13
|
+
if (h(), e !== m) {
|
|
14
|
+
if (t <= 0) {
|
|
15
|
+
g(e);
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
v(e, t);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function v(e, t) {
|
|
22
|
+
p.current = setTimeout(() => {
|
|
23
|
+
p.current = void 0, g(e);
|
|
24
|
+
}, t);
|
|
25
|
+
}
|
|
26
|
+
function y() {
|
|
27
|
+
h(), m || v(!0, 0);
|
|
28
|
+
}
|
|
29
|
+
let b = n((e) => {
|
|
30
|
+
let t = l === void 0 || c !== void 0;
|
|
31
|
+
e.key === "Escape" && !e.isComposing && t && (e.preventDefault(), _(!1, 0));
|
|
32
|
+
});
|
|
33
|
+
return t(() => {
|
|
34
|
+
if (!m) return;
|
|
35
|
+
function e(e) {
|
|
36
|
+
b(e);
|
|
37
|
+
}
|
|
38
|
+
return document.addEventListener("keydown", e), () => {
|
|
39
|
+
document.removeEventListener("keydown", e);
|
|
40
|
+
};
|
|
41
|
+
}, [m]), t(() => () => {
|
|
42
|
+
clearTimeout(p.current);
|
|
43
|
+
}, []), {
|
|
44
|
+
anchorName: e(u),
|
|
45
|
+
cancelDelay: h,
|
|
46
|
+
hide: () => _(!1, 0),
|
|
47
|
+
hideAfterDelay: () => _(!1, s.hide),
|
|
48
|
+
id: u,
|
|
49
|
+
open: m,
|
|
50
|
+
show: () => _(!0, 0),
|
|
51
|
+
showAfterDelay: () => _(!0, s.show),
|
|
52
|
+
showAfterTask: y
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
//#endregion
|
|
56
|
+
export { o as useOverlay };
|