@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,52 @@
|
|
|
1
|
+
import type { JSX, ToggleEventHandler } from "react";
|
|
2
|
+
import type { OverlayPlacement } from "../../overlays";
|
|
3
|
+
import type { BoxProps } from "../Box";
|
|
4
|
+
/**
|
|
5
|
+
* Props `getOverlayProps` from `usePopover` returns, which every `Popover` takes
|
|
6
|
+
*/
|
|
7
|
+
export interface PopoverOverlayProps {
|
|
8
|
+
/**
|
|
9
|
+
* `anchor-name` of the trigger the popover is positioned against. From `getOverlayProps`.
|
|
10
|
+
*/
|
|
11
|
+
anchorName: string;
|
|
12
|
+
/**
|
|
13
|
+
* The popover's id, which the trigger's `popoverTarget` and `aria-controls` point at. From `getOverlayProps`.
|
|
14
|
+
*/
|
|
15
|
+
id: string;
|
|
16
|
+
/**
|
|
17
|
+
* Cancels an opening the parent of a controlled popover has not asked for. From `getOverlayProps`.
|
|
18
|
+
*/
|
|
19
|
+
onBeforeToggle: ToggleEventHandler<HTMLElement>;
|
|
20
|
+
/**
|
|
21
|
+
* Keeps the hook's state in step with the browser. From `getOverlayProps`.
|
|
22
|
+
*/
|
|
23
|
+
onToggle: ToggleEventHandler<HTMLElement>;
|
|
24
|
+
/**
|
|
25
|
+
* Whether the popover is shown. From `getOverlayProps`.
|
|
26
|
+
*/
|
|
27
|
+
open: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Side of the trigger the popover opens on. From `getOverlayProps`.
|
|
30
|
+
*/
|
|
31
|
+
placement: OverlayPlacement;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Props for `Popover`: the props `getOverlayProps` returns plus every `div` prop except `popover` and `ref`
|
|
35
|
+
*/
|
|
36
|
+
export interface PopoverProps extends PopoverOverlayProps, Omit<BoxProps<"div">, "as" | "popover" | "ref" | keyof PopoverOverlayProps> {
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* A surface that opens beside a button and holds more content than a tooltip can, such as a short list or a few
|
|
40
|
+
* actions. `usePopover` connects the two: spread `getTriggerProps()` on a `Button` or `IconButton` and
|
|
41
|
+
* `getOverlayProps()` on the popover, inside the same `Theme`. It closes on Escape and on a click outside. Closing it
|
|
42
|
+
* with focus inside gives focus back to what had it before it opened, usually the button, or to the button when the
|
|
43
|
+
* browser leaves it on the page, and `usePopover`'s `initialFocus` moves focus in as it opens. It has no role of its
|
|
44
|
+
* own: give it `role="dialog"` and a name when it holds a form or asks for confirmation.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* const popover = usePopover({ placement: "top" });
|
|
48
|
+
*
|
|
49
|
+
* <Button {...popover.getTriggerProps()} variant="ghost">2 problems</Button>
|
|
50
|
+
* <Popover {...popover.getOverlayProps()}>…</Popover>
|
|
51
|
+
*/
|
|
52
|
+
export declare function Popover({ className, ...rest }: PopoverProps): JSX.Element;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Overlay as e } from "../Overlay/Overlay.js";
|
|
2
|
+
import t from "./Popover.module.js";
|
|
3
|
+
import { clsx as n } from "clsx";
|
|
4
|
+
import { c as r } from "react/compiler-runtime";
|
|
5
|
+
import { jsx as i } from "react/jsx-runtime";
|
|
6
|
+
//#region src/components/Popover/Popover.tsx
|
|
7
|
+
function a(a) {
|
|
8
|
+
let o = r(8), s, c;
|
|
9
|
+
o[0] === a ? (s = o[1], c = o[2]) : ({className: s, ...c} = a, o[0] = a, o[1] = s, o[2] = c);
|
|
10
|
+
let l;
|
|
11
|
+
o[3] === s ? l = o[4] : (l = n(t.popover, s), o[3] = s, o[4] = l);
|
|
12
|
+
let u;
|
|
13
|
+
return o[5] !== c || o[6] !== l ? (u = /* @__PURE__ */ i(e, {
|
|
14
|
+
...c,
|
|
15
|
+
as: "div",
|
|
16
|
+
className: l,
|
|
17
|
+
popover: "auto"
|
|
18
|
+
}), o[5] = c, o[6] = l, o[7] = u) : u = o[7], u;
|
|
19
|
+
}
|
|
20
|
+
//#endregion
|
|
21
|
+
export { a as Popover };
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import type { CSSProperties, RefObject } from "react";
|
|
2
|
+
import type { OverlayPlacement } from "../../overlays";
|
|
3
|
+
import type { PopoverOverlayProps } from "./Popover";
|
|
4
|
+
/**
|
|
5
|
+
* Options for `usePopover`
|
|
6
|
+
*/
|
|
7
|
+
export interface UsePopoverOptions {
|
|
8
|
+
/**
|
|
9
|
+
* Whether the popover starts open when uncontrolled. Defaults to `false`.
|
|
10
|
+
*/
|
|
11
|
+
defaultOpen?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Element to focus when the popover opens, such as the safe choice in a confirmation. Without one, focus stays where
|
|
14
|
+
* it is.
|
|
15
|
+
*/
|
|
16
|
+
initialFocus?: RefObject<HTMLElement | null>;
|
|
17
|
+
/**
|
|
18
|
+
* Called with the new open state when the popover opens or closes; when controlled, also with `true` when the user
|
|
19
|
+
* asks to open it
|
|
20
|
+
*/
|
|
21
|
+
onOpenChange?: (open: boolean) => void;
|
|
22
|
+
/**
|
|
23
|
+
* Controls whether the popover is open. The hook then cancels openings and reports them through `onOpenChange`; a
|
|
24
|
+
* close the browser makes is reported after it happens, and the popover shows again if `open` stays true. Only one
|
|
25
|
+
* popover can be open at a time, so two held open this way keep closing each other.
|
|
26
|
+
*/
|
|
27
|
+
open?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Side of the trigger the popover opens on. It flips to the opposite side when there is no room. Defaults to
|
|
30
|
+
* `bottom`.
|
|
31
|
+
*/
|
|
32
|
+
placement?: OverlayPlacement;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Props `getTriggerProps` sets on the trigger
|
|
36
|
+
*/
|
|
37
|
+
interface PopoverTriggerProps {
|
|
38
|
+
/**
|
|
39
|
+
* The popover's id
|
|
40
|
+
*/
|
|
41
|
+
"aria-controls": string;
|
|
42
|
+
/**
|
|
43
|
+
* Whether the popover is open
|
|
44
|
+
*/
|
|
45
|
+
"aria-expanded": boolean;
|
|
46
|
+
/**
|
|
47
|
+
* The popover's id, which makes the button open and close it without script
|
|
48
|
+
*/
|
|
49
|
+
popoverTarget: string;
|
|
50
|
+
/**
|
|
51
|
+
* Names the trigger as the popover's anchor
|
|
52
|
+
*/
|
|
53
|
+
style: CSSProperties;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Prop getters for a popover's trigger and the `Popover`, whether it is open, and a way to close it
|
|
57
|
+
*/
|
|
58
|
+
export interface UsePopoverResult {
|
|
59
|
+
/**
|
|
60
|
+
* Closes the popover: hides it when uncontrolled, and reports `false` through `onOpenChange` either way. Focus moves
|
|
61
|
+
* as when the browser closes it, and also to the trigger when it is lost to the page as the popover hides, as Safari
|
|
62
|
+
* loses it when a button is clicked. Focus the caller moves elsewhere stays there.
|
|
63
|
+
*/
|
|
64
|
+
close: () => void;
|
|
65
|
+
/**
|
|
66
|
+
* Returns the props to spread on the `Popover`, merged with any given
|
|
67
|
+
*/
|
|
68
|
+
getOverlayProps: <Props extends object>(props?: Props & Partial<PopoverOverlayProps>) => Omit<Props, keyof PopoverOverlayProps> & PopoverOverlayProps;
|
|
69
|
+
/**
|
|
70
|
+
* Returns the props to spread on the trigger, which must be a button, merged with any given: where both set a
|
|
71
|
+
* handler, both run, the given one first, and `style` objects merge
|
|
72
|
+
*/
|
|
73
|
+
getTriggerProps: <Props extends object>(props?: Props & Partial<PopoverTriggerProps>) => Omit<Props, keyof PopoverTriggerProps> & PopoverTriggerProps;
|
|
74
|
+
/**
|
|
75
|
+
* Whether the popover is open
|
|
76
|
+
*/
|
|
77
|
+
open: boolean;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Connects a `Popover` to the button that opens it. Clicking the button toggles the popover, and Escape or a click
|
|
81
|
+
* outside closes it, all handled by the browser. Opening another popover closes this one. When the popover closes with
|
|
82
|
+
* focus inside it, the browser returns focus to whatever had it before the popover opened, usually the button; where
|
|
83
|
+
* the browser leaves focus on the page or in the hidden popover, as Safari does, the hook moves it to the button. A
|
|
84
|
+
* click outside leaves focus where the click put it.
|
|
85
|
+
*
|
|
86
|
+
* @param options open state, the change callback, placement and the element to focus on opening
|
|
87
|
+
* @returns prop getters for the trigger and the `Popover`, whether it is open, and `close`
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* const popover = usePopover({ placement: "top" });
|
|
91
|
+
*
|
|
92
|
+
* <Button {...popover.getTriggerProps()} variant="ghost">2 problems</Button>
|
|
93
|
+
* <Popover {...popover.getOverlayProps()}>…</Popover>
|
|
94
|
+
*/
|
|
95
|
+
export declare function usePopover({ defaultOpen, initialFocus, onOpenChange, open: controlledOpen, placement, }?: UsePopoverOptions): UsePopoverResult;
|
|
96
|
+
export {};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { anchorNameFor as e } from "../../overlays/anchorNameFor.js";
|
|
2
|
+
import { mergeProps as t } from "../../overlays/mergeProps.js";
|
|
3
|
+
import { syncPopover as n } from "../../overlays/syncPopover.js";
|
|
4
|
+
import { useEffect as r, useId as i, useRef as a, useState as o } from "react";
|
|
5
|
+
//#region src/components/Popover/usePopover.ts
|
|
6
|
+
function s({ defaultOpen: s = !1, initialFocus: u, onOpenChange: d, open: f, placement: p = "bottom" } = {}) {
|
|
7
|
+
let m = i(), [h, g] = o(s), [_, v] = o(0), y = a(null), b = a(!1), x = a(!1), S = f !== void 0, C = f ?? h, w = e(m);
|
|
8
|
+
r(() => {
|
|
9
|
+
let e = y.current;
|
|
10
|
+
if (_ !== 0 && C && e !== null && e.isConnected) return n(e, !0);
|
|
11
|
+
}, [C, _]);
|
|
12
|
+
function T(e) {
|
|
13
|
+
S || g(e), d?.(e);
|
|
14
|
+
}
|
|
15
|
+
function E(e) {
|
|
16
|
+
if (e.newState === "closed") {
|
|
17
|
+
let t = e.currentTarget;
|
|
18
|
+
b.current = t.contains(t.ownerDocument.activeElement) || x.current && l(t.ownerDocument), x.current = !1;
|
|
19
|
+
}
|
|
20
|
+
S && !C && e.newState === "open" && (e.preventDefault(), d?.(!0));
|
|
21
|
+
}
|
|
22
|
+
function D(e) {
|
|
23
|
+
let t = e.newState === "open";
|
|
24
|
+
t ? u?.current?.focus() : b.current && (b.current = !1, c(e.currentTarget)), t !== C && (T(t), S && (y.current = e.currentTarget, v((e) => e + 1)));
|
|
25
|
+
}
|
|
26
|
+
function O() {
|
|
27
|
+
C && (x.current = !0, T(!1));
|
|
28
|
+
}
|
|
29
|
+
let k = {
|
|
30
|
+
anchorName: w,
|
|
31
|
+
id: m,
|
|
32
|
+
onBeforeToggle: E,
|
|
33
|
+
onToggle: D,
|
|
34
|
+
open: C,
|
|
35
|
+
placement: p
|
|
36
|
+
}, A = {
|
|
37
|
+
"aria-controls": m,
|
|
38
|
+
"aria-expanded": C,
|
|
39
|
+
popoverTarget: m,
|
|
40
|
+
style: { anchorName: w }
|
|
41
|
+
};
|
|
42
|
+
function j(e) {
|
|
43
|
+
return t(e, k);
|
|
44
|
+
}
|
|
45
|
+
function M(e) {
|
|
46
|
+
return t(e, A);
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
close: O,
|
|
50
|
+
getOverlayProps: j,
|
|
51
|
+
getTriggerProps: M,
|
|
52
|
+
open: C
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
function c(e) {
|
|
56
|
+
(l(e.ownerDocument) || e.contains(e.ownerDocument.activeElement)) && u(e)?.focus();
|
|
57
|
+
}
|
|
58
|
+
function l(e) {
|
|
59
|
+
return e.activeElement === null || e.activeElement === e.body;
|
|
60
|
+
}
|
|
61
|
+
function u(e) {
|
|
62
|
+
let t = e.ownerDocument.querySelectorAll("[popovertarget]");
|
|
63
|
+
return Array.from(t).find((t) => t.getAttribute("popovertarget") === e.id && !e.contains(t)) ?? null;
|
|
64
|
+
}
|
|
65
|
+
//#endregion
|
|
66
|
+
export { s as usePopover };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.sui-prose-Obc4t{--sui-prose-font-size:var(--sui-font-size-md,1rem);--sui-prose-flow:var(--sui-space-4,1rem);color:var(--sui-color-text,#111827);font-family:var(--sui-font-body,system-ui, sans-serif);font-size:var(--sui-prose-font-size);line-height:var(--sui-prose-line-height,var(--sui-line-height-normal,1.5));overflow-wrap:anywhere}.sui-prose-Obc4t[data-size=sm]{--sui-prose-font-size:var(--sui-font-size-sm,.875rem)}.sui-prose-Obc4t[data-size=lg]{--sui-prose-font-size:var(--sui-font-size-lg,1.125rem)}:where(.sui-prose-Obc4t) p,:where(.sui-prose-Obc4t) ul,:where(.sui-prose-Obc4t) ol,:where(.sui-prose-Obc4t) blockquote,:where(.sui-prose-Obc4t) pre,:where(.sui-prose-Obc4t) figure,:where(.sui-prose-Obc4t) table,:where(.sui-prose-Obc4t) hr{margin:var(--sui-prose-flow) 0 0}:where(.sui-prose-Obc4t) h1,:where(.sui-prose-Obc4t) h2,:where(.sui-prose-Obc4t) h3,:where(.sui-prose-Obc4t) h4,:where(.sui-prose-Obc4t) h5,:where(.sui-prose-Obc4t) h6{margin:calc(var(--sui-prose-flow) * 2) 0 0;font-family:var(--sui-font-heading,system-ui, sans-serif);font-weight:var(--sui-font-weight-bold,700);line-height:var(--sui-line-height-tight,1.25)}:where(.sui-prose-Obc4t) h1{font-size:var(--sui-font-size-3xl,1.875rem)}:where(.sui-prose-Obc4t) h2{font-size:var(--sui-font-size-2xl,1.5rem)}:where(.sui-prose-Obc4t) h3{font-size:var(--sui-font-size-xl,1.25rem)}:where(.sui-prose-Obc4t) h4{font-size:var(--sui-font-size-lg,1.125rem)}:where(.sui-prose-Obc4t) h5{font-size:var(--sui-font-size-md,1rem)}:where(.sui-prose-Obc4t) h6{font-size:var(--sui-font-size-sm,.875rem)}:where(.sui-prose-Obc4t) li{margin-block-start:calc(var(--sui-prose-flow) / 4)}:where(.sui-prose-Obc4t) figcaption{color:var(--sui-color-text-muted,#4b5563);margin-block-start:calc(var(--sui-prose-flow) / 2);font-size:.875em}:where(.sui-prose-Obc4t) p:where(:first-child),:where(.sui-prose-Obc4t) ul:where(:first-child),:where(.sui-prose-Obc4t) ol:where(:first-child),:where(.sui-prose-Obc4t) blockquote:where(:first-child),:where(.sui-prose-Obc4t) pre:where(:first-child),:where(.sui-prose-Obc4t) figure:where(:first-child),:where(.sui-prose-Obc4t) table:where(:first-child),:where(.sui-prose-Obc4t) hr:where(:first-child),:where(.sui-prose-Obc4t) h1:where(:first-child),:where(.sui-prose-Obc4t) h2:where(:first-child),:where(.sui-prose-Obc4t) h3:where(:first-child),:where(.sui-prose-Obc4t) h4:where(:first-child),:where(.sui-prose-Obc4t) h5:where(:first-child),:where(.sui-prose-Obc4t) h6:where(:first-child),:where(.sui-prose-Obc4t) li:where(:first-child),:where(.sui-prose-Obc4t) figcaption:where(:first-child){margin-block-start:0}:where(.sui-prose-Obc4t) a{color:var(--sui-link-color,var(--sui-color-primary,#2563eb));text-decoration-line:underline;text-decoration-thickness:var(--sui-border-width,1px);text-underline-offset:.2em}:where(.sui-prose-Obc4t) a:where(:hover){text-decoration-thickness:calc(var(--sui-border-width,1px) * 2)}:where(.sui-prose-Obc4t) a:where(:focus-visible){outline:var(--sui-focus-ring-width,2px) solid var(--sui-color-focus-ring,#3b82f6);outline-offset:2px}:where(.sui-prose-Obc4t) ul,:where(.sui-prose-Obc4t) ol{padding-inline-start:var(--sui-space-6,1.5rem)}:where(.sui-prose-Obc4t) ul:where(:not([type])),:where(.sui-prose-Obc4t) ol:where(:not([type])){list-style-type:revert}:where(.sui-prose-Obc4t) blockquote{border-inline-start:calc(var(--sui-border-width,1px) * 3) solid var(--sui-color-border,#d1d5db);color:var(--sui-color-text-muted,#4b5563);padding-inline-start:var(--sui-space-4,1rem)}:where(.sui-prose-Obc4t) hr{border:0;border-block-start:var(--sui-border-width,1px) solid var(--sui-color-border,#d1d5db)}:where(.sui-prose-Obc4t) code{padding:0 var(--sui-space-1,.25rem);border-radius:var(--sui-radius-sm,2px);background-color:var(--sui-color-sunken,#f3f4f6);font-family:var(--sui-font-mono,ui-monospace, SFMono-Regular, Menlo, monospace);font-size:.875em}:where(.sui-prose-Obc4t) kbd{padding:0 var(--sui-space-1,.25rem);border:var(--sui-border-width,1px) solid var(--sui-color-border,#d1d5db);border-block-end-width:calc(var(--sui-border-width,1px) * 2);border-radius:var(--sui-radius-sm,2px);background-color:var(--sui-color-sunken,#f3f4f6);color:var(--sui-color-text,#111827);font-family:var(--sui-font-mono,ui-monospace, SFMono-Regular, Menlo, monospace);white-space:nowrap;font-size:.875em}:where(.sui-prose-Obc4t) pre{padding:var(--sui-space-4,1rem);border-radius:var(--sui-radius-md,4px);background-color:var(--sui-color-sunken,#f3f4f6);font-family:var(--sui-font-mono,ui-monospace, SFMono-Regular, Menlo, monospace);font-size:.875em;line-height:var(--sui-line-height-normal,1.5);overflow-wrap:anywhere;white-space:pre-wrap}:where(.sui-prose-Obc4t[data-code-overflow=scroll]) pre{white-space:pre;overflow-x:auto}:where(.sui-prose-Obc4t) pre code{font-size:inherit;background-color:#0000;border-radius:0;padding:0}:where(.sui-prose-Obc4t) img{block-size:auto;max-inline-size:100%}:where(.sui-prose-Obc4t) table{border-collapse:collapse;overflow-wrap:break-word;inline-size:max-content;max-inline-size:100%;display:block;overflow:auto}:where(.sui-prose-Obc4t) pre:where(:focus-visible),:where(.sui-prose-Obc4t) table:where(:focus-visible){outline:var(--sui-focus-ring-width,2px) solid var(--sui-color-focus-ring,#3b82f6);outline-offset:2px}:where(.sui-prose-Obc4t) th,:where(.sui-prose-Obc4t) td{padding:var(--sui-space-2,.5rem) var(--sui-space-3,.75rem);border:var(--sui-border-width,1px) solid var(--sui-color-border,#d1d5db)}:where(.sui-prose-Obc4t) th{background-color:var(--sui-color-sunken,#f3f4f6);font-weight:var(--sui-font-weight-bold,700)}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { JSX } from "react";
|
|
2
|
+
import type { BoxElement, BoxProps } from "../Box";
|
|
3
|
+
/**
|
|
4
|
+
* Body text sizes of prose, mapped to the `--sui-font-size-*` tokens
|
|
5
|
+
*/
|
|
6
|
+
export type ProseSize = "sm" | "md" | "lg";
|
|
7
|
+
/**
|
|
8
|
+
* What a code block in prose does with a line wider than the column
|
|
9
|
+
*/
|
|
10
|
+
export type ProseCodeOverflow = "wrap" | "scroll";
|
|
11
|
+
interface ProseOwnProps {
|
|
12
|
+
/**
|
|
13
|
+
* What a code block does with a line wider than the column: `wrap` breaks it onto the next line,
|
|
14
|
+
* and `scroll` keeps it whole and scrolls the block sideways, so wrapping cannot break indentation
|
|
15
|
+
* or a diagram drawn in text. Defaults to `wrap`.
|
|
16
|
+
*/
|
|
17
|
+
codeOverflow?: ProseCodeOverflow;
|
|
18
|
+
/**
|
|
19
|
+
* Body text size. Defaults to `md`.
|
|
20
|
+
*/
|
|
21
|
+
size?: ProseSize;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Props for `Prose`: its own props plus every prop supported by the element given in `as`
|
|
25
|
+
*/
|
|
26
|
+
export type ProseProps<E extends BoxElement = "div"> = ProseOwnProps & Omit<BoxProps<E>, keyof ProseOwnProps>;
|
|
27
|
+
/**
|
|
28
|
+
* Styles the raw HTML inside it: headings, paragraphs, links, lists, quotes, code, images, figures
|
|
29
|
+
* and tables. It is for content that cannot be written one component per element, such as rendered
|
|
30
|
+
* markdown or CMS output.
|
|
31
|
+
*
|
|
32
|
+
* A StylesUI component inside prose keeps its own styles. Two things are still styled as prose: a
|
|
33
|
+
* raw element inside that component, and, for the properties it does not set itself, a component
|
|
34
|
+
* rendered through `as` as an element prose styles, such as `<Text as="code">`.
|
|
35
|
+
*
|
|
36
|
+
* A table wider than the column scrolls sideways inside its own box, as does a code block when
|
|
37
|
+
* `codeOverflow` is `scroll`; give each one that scrolls `tabIndex={0}` so a keyboard can scroll it.
|
|
38
|
+
* Set `--sui-prose-line-height` on the prose or an ancestor to space out long lines of text. Code
|
|
39
|
+
* keeps `--sui-line-height-normal`.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* <Prose as="article" size="lg">
|
|
43
|
+
* <h2>Release notes</h2>
|
|
44
|
+
* <p>
|
|
45
|
+
* Read the <a href="#changelog">changelog</a> before you upgrade.
|
|
46
|
+
* </p>
|
|
47
|
+
* </Prose>
|
|
48
|
+
*/
|
|
49
|
+
export declare function Prose<E extends BoxElement = "div">({ as, className, codeOverflow, size, ...rest }: ProseProps<E>): JSX.Element;
|
|
50
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Box as e } from "../Box/Box.js";
|
|
2
|
+
import t from "./Prose.module.js";
|
|
3
|
+
import { clsx as n } from "clsx";
|
|
4
|
+
import { jsx as r } from "react/jsx-runtime";
|
|
5
|
+
//#region src/components/Prose/Prose.tsx
|
|
6
|
+
function i({ as: i, className: a, codeOverflow: o = "wrap", size: s = "md", ...c }) {
|
|
7
|
+
return /* @__PURE__ */ r(e, {
|
|
8
|
+
...c,
|
|
9
|
+
as: i,
|
|
10
|
+
className: n(t.prose, a),
|
|
11
|
+
"data-code-overflow": o,
|
|
12
|
+
"data-size": s
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
export { i as Prose };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { JSX, ReactNode } from "react";
|
|
2
|
+
import type { BoxProps } from "../Box";
|
|
3
|
+
/**
|
|
4
|
+
* Props for `Radio`: its own props plus every native input prop. `className` and `style` go to the wrapping
|
|
5
|
+
* label; `ref` and every other prop go to the input.
|
|
6
|
+
*/
|
|
7
|
+
export interface RadioProps extends Omit<BoxProps<"input">, "as" | "children" | "dangerouslySetInnerHTML" | "type" | "value"> {
|
|
8
|
+
/**
|
|
9
|
+
* Label shown beside the button, which names the radio. Without it, give the radio an accessible name, for
|
|
10
|
+
* example with `aria-label`. It is inline content, as a `label` holds: a child laid out as a block drops below the
|
|
11
|
+
* button, so put a description after the radio, padded by `var(--sui-space-6)`.
|
|
12
|
+
*/
|
|
13
|
+
children?: ReactNode;
|
|
14
|
+
/**
|
|
15
|
+
* The value this radio stands for: what a form submits when it is selected, and what a `RadioGroup` reports
|
|
16
|
+
* and matches against its own value
|
|
17
|
+
*/
|
|
18
|
+
value: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Themed native radio button inside the label that names it. On its own it is a plain native radio: radios
|
|
22
|
+
* that share a `name` allow one selection. Inside a `RadioGroup` it takes its `name` and `required` state from
|
|
23
|
+
* the group, its selection from the group's `value` or `defaultValue`, and reports its `value` to the group's
|
|
24
|
+
* `onValueChange` after its own `onChange`.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* <Radio name="plan" value="monthly">Pay monthly</Radio>
|
|
28
|
+
*/
|
|
29
|
+
export declare function Radio({ children, onChange, value, ...rest }: RadioProps): JSX.Element;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { useRadioGroupItem as e } from "../../forms/useRadioGroupItem.js";
|
|
2
|
+
import { ChoiceControl as t } from "../ChoiceControl/ChoiceControl.js";
|
|
3
|
+
import { c as n } from "react/compiler-runtime";
|
|
4
|
+
import { jsx as r } from "react/jsx-runtime";
|
|
5
|
+
//#region src/components/Radio/Radio.tsx
|
|
6
|
+
function i(i) {
|
|
7
|
+
let a = n(13), o, s, c, l;
|
|
8
|
+
a[0] === i ? (o = a[1], s = a[2], c = a[3], l = a[4]) : ({children: o, onChange: s, value: l, ...c} = i, a[0] = i, a[1] = o, a[2] = s, a[3] = c, a[4] = l);
|
|
9
|
+
let u;
|
|
10
|
+
a[5] !== s || a[6] !== l ? (u = {
|
|
11
|
+
onChange: s,
|
|
12
|
+
value: l
|
|
13
|
+
}, a[5] = s, a[6] = l, a[7] = u) : u = a[7];
|
|
14
|
+
let d = e(u), f;
|
|
15
|
+
return a[8] !== o || a[9] !== d || a[10] !== c || a[11] !== l ? (f = /* @__PURE__ */ r(t, {
|
|
16
|
+
...c,
|
|
17
|
+
...d,
|
|
18
|
+
kind: "radio",
|
|
19
|
+
value: l,
|
|
20
|
+
children: o
|
|
21
|
+
}), a[8] = o, a[9] = d, a[10] = c, a[11] = l, a[12] = f) : f = a[12], f;
|
|
22
|
+
}
|
|
23
|
+
//#endregion
|
|
24
|
+
export { i as Radio };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.sui-radioGroup-pO2pz{--sui-radio-group-gap:var(--sui-space-2,.5rem);gap:var(--sui-radio-group-gap);display:flex}.sui-radioGroup-pO2pz[data-orientation=vertical]{flex-direction:column}.sui-radioGroup-pO2pz[data-orientation=horizontal]{gap:var(--sui-radio-group-gap) var(--sui-space-4,1rem);flex-flow:wrap}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { JSX } from "react";
|
|
2
|
+
import type { FieldsetProps } from "../Fieldset";
|
|
3
|
+
/**
|
|
4
|
+
* Direction a group lays its radios out: `vertical` in a column, `horizontal` in a row that wraps
|
|
5
|
+
*/
|
|
6
|
+
export type RadioGroupOrientation = "horizontal" | "vertical";
|
|
7
|
+
/**
|
|
8
|
+
* Props for `RadioGroup`: its own props plus every native fieldset prop
|
|
9
|
+
*/
|
|
10
|
+
export interface RadioGroupProps extends Omit<FieldsetProps, "aria-invalid" | "aria-required" | "defaultValue" | "name" | "role"> {
|
|
11
|
+
/**
|
|
12
|
+
* Not accepted: an `error` marks the group invalid
|
|
13
|
+
*/
|
|
14
|
+
"aria-invalid"?: never;
|
|
15
|
+
/**
|
|
16
|
+
* Not accepted: `required` marks the group required
|
|
17
|
+
*/
|
|
18
|
+
"aria-required"?: never;
|
|
19
|
+
/**
|
|
20
|
+
* The value selected at first. It leaves the group uncontrolled, so the radios keep the user's choices.
|
|
21
|
+
*/
|
|
22
|
+
defaultValue?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Name every radio submits its value under. Defaults to a generated name that is unique to the group.
|
|
25
|
+
*/
|
|
26
|
+
name?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Called with the value of the radio the user selects, after that radio's own `onChange`
|
|
29
|
+
*/
|
|
30
|
+
onValueChange?: (value: string) => void;
|
|
31
|
+
/**
|
|
32
|
+
* How the radios are laid out. Defaults to `vertical`.
|
|
33
|
+
*/
|
|
34
|
+
orientation?: RadioGroupOrientation;
|
|
35
|
+
/**
|
|
36
|
+
* Whether one radio must be selected. It marks the group and every radio required and adds an asterisk
|
|
37
|
+
* to the label. Defaults to `false`.
|
|
38
|
+
*/
|
|
39
|
+
required?: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* The selected value, which makes the group controlled: the selection follows it, so update it from
|
|
42
|
+
* `onValueChange`. Give a value that matches no radio to select none.
|
|
43
|
+
*/
|
|
44
|
+
value?: string;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Groups `Radio` components under a label so they share a name and one selection. The label names the group,
|
|
48
|
+
* `description` and `error` are linked to it, and an `error` marks the group and its radios invalid. The
|
|
49
|
+
* native `disabled` prop disables every radio. The group holds no state of its own: it is uncontrolled with
|
|
50
|
+
* `defaultValue` and controlled with `value`.
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* <RadioGroup defaultValue="monthly" label="Billing" onValueChange={setBilling}>
|
|
54
|
+
* <Radio value="monthly">Pay monthly</Radio>
|
|
55
|
+
* <Radio value="yearly">Pay yearly</Radio>
|
|
56
|
+
* </RadioGroup>
|
|
57
|
+
*/
|
|
58
|
+
export declare function RadioGroup({ children, defaultValue, error, label, name, onValueChange, orientation, required, value, ...rest }: RadioGroupProps): JSX.Element;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { hasContent as e } from "../../forms/hasContent.js";
|
|
2
|
+
import { RadioGroupContext as t } from "../../forms/RadioGroupContext.js";
|
|
3
|
+
import { Box as n } from "../Box/Box.js";
|
|
4
|
+
import { RequiredIndicator as r } from "../RequiredIndicator/RequiredIndicator.js";
|
|
5
|
+
import { Fieldset as i } from "../Fieldset/Fieldset.js";
|
|
6
|
+
import a from "./RadioGroup.module.js";
|
|
7
|
+
import { useId as o } from "react";
|
|
8
|
+
import { Fragment as s, jsx as c, jsxs as l } from "react/jsx-runtime";
|
|
9
|
+
//#region src/components/RadioGroup/RadioGroup.tsx
|
|
10
|
+
function u({ children: u, defaultValue: d, error: f, label: p, name: m, onValueChange: h, orientation: g = "vertical", required: _ = !1, value: v, ...y }) {
|
|
11
|
+
let b = o(), x = e(f);
|
|
12
|
+
return /* @__PURE__ */ c(t.Provider, {
|
|
13
|
+
value: {
|
|
14
|
+
defaultValue: d,
|
|
15
|
+
invalid: x,
|
|
16
|
+
name: m ?? b,
|
|
17
|
+
onValueChange: h,
|
|
18
|
+
required: _,
|
|
19
|
+
value: v
|
|
20
|
+
},
|
|
21
|
+
children: /* @__PURE__ */ c(i, {
|
|
22
|
+
...y,
|
|
23
|
+
error: f,
|
|
24
|
+
label: _ ? /* @__PURE__ */ l(s, { children: [p, /* @__PURE__ */ c(r, {})] }) : p,
|
|
25
|
+
role: "radiogroup",
|
|
26
|
+
"aria-invalid": x ? !0 : void 0,
|
|
27
|
+
"aria-required": _ ? !0 : void 0,
|
|
28
|
+
children: /* @__PURE__ */ c(n, {
|
|
29
|
+
className: a.radioGroup,
|
|
30
|
+
"data-orientation": g,
|
|
31
|
+
children: u
|
|
32
|
+
})
|
|
33
|
+
})
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
//#endregion
|
|
37
|
+
export { u as RadioGroup };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.sui-requiredIndicator-11-gH{color:var(--sui-color-danger-text,#b91c1c);margin-inline-start:var(--sui-space-1,.25rem)}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Box as e } from "../Box/Box.js";
|
|
2
|
+
import t from "./RequiredIndicator.module.js";
|
|
3
|
+
import { c as n } from "react/compiler-runtime";
|
|
4
|
+
import { jsx as r } from "react/jsx-runtime";
|
|
5
|
+
//#region src/components/RequiredIndicator/RequiredIndicator.tsx
|
|
6
|
+
function i() {
|
|
7
|
+
let i = n(1), a;
|
|
8
|
+
return i[0] === Symbol.for("react.memo_cache_sentinel") ? (a = /* @__PURE__ */ r(e, {
|
|
9
|
+
as: "span",
|
|
10
|
+
className: t.requiredIndicator,
|
|
11
|
+
"aria-hidden": "true",
|
|
12
|
+
children: "*"
|
|
13
|
+
}), i[0] = a) : a = i[0], a;
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
export { i as RequiredIndicator };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { RequiredIndicator } from "./RequiredIndicator";
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { JSX } from "react";
|
|
2
|
+
import type { Alignment, Justification, Space } from "../../layout";
|
|
3
|
+
import type { BoxElement, BoxProps } from "../Box";
|
|
4
|
+
interface RowOwnProps {
|
|
5
|
+
/**
|
|
6
|
+
* Cross-axis placement of children. Defaults to `center`.
|
|
7
|
+
*/
|
|
8
|
+
align?: Alignment;
|
|
9
|
+
/**
|
|
10
|
+
* Space between children. Defaults to `2`.
|
|
11
|
+
*/
|
|
12
|
+
gap?: Space;
|
|
13
|
+
/**
|
|
14
|
+
* Main-axis distribution of children. Defaults to `start`.
|
|
15
|
+
*/
|
|
16
|
+
justify?: Justification;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Props for `Row`: its own props plus every prop supported by the element given in `as`
|
|
20
|
+
*/
|
|
21
|
+
export type RowProps<E extends BoxElement = "div"> = RowOwnProps & Omit<BoxProps<E>, keyof RowOwnProps>;
|
|
22
|
+
/**
|
|
23
|
+
* Horizontal flow that keeps its children on one line. Use `Cluster` when they should wrap.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* <Row as="header" justify="between">...</Row>
|
|
27
|
+
*/
|
|
28
|
+
export declare function Row<E extends BoxElement = "div">({ align, gap, justify, ...rest }: RowProps<E>): JSX.Element;
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { HorizontalFlow as e } from "../HorizontalFlow/HorizontalFlow.js";
|
|
2
|
+
import { jsx as t } from "react/jsx-runtime";
|
|
3
|
+
//#region src/components/Row/Row.tsx
|
|
4
|
+
function n({ align: n = "center", gap: r = 2, justify: i = "start", ...a }) {
|
|
5
|
+
return /* @__PURE__ */ t(e, {
|
|
6
|
+
...a,
|
|
7
|
+
align: n,
|
|
8
|
+
gap: r,
|
|
9
|
+
justify: i,
|
|
10
|
+
wrap: !1
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
export { n as Row };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { JSX, ReactNode } from "react";
|
|
2
|
+
import type { BoxProps } from "../Box";
|
|
3
|
+
/**
|
|
4
|
+
* Props for `Segment`: its own props plus every native input prop. `className` and `style` go to the label; `ref`
|
|
5
|
+
* and every other prop go to the input.
|
|
6
|
+
*/
|
|
7
|
+
export interface SegmentProps extends Omit<BoxProps<"input">, "as" | "children" | "dangerouslySetInnerHTML" | "type" | "value"> {
|
|
8
|
+
/**
|
|
9
|
+
* The segment's label, which names it. Without it, give the segment an accessible name, for example with
|
|
10
|
+
* `aria-label`.
|
|
11
|
+
*/
|
|
12
|
+
children?: ReactNode;
|
|
13
|
+
/**
|
|
14
|
+
* The value this segment stands for, which the `SegmentedControl` reports and a form submits
|
|
15
|
+
*/
|
|
16
|
+
value: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* One choice in a `SegmentedControl`: a native radio drawn as a joined button
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* <Segment value="dark">Dark</Segment>
|
|
23
|
+
*/
|
|
24
|
+
export declare function Segment({ children, className, onChange, style, value, ...rest }: SegmentProps): JSX.Element;
|