@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,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An option as a listbox renders it
|
|
3
|
+
*/
|
|
4
|
+
export interface RenderedOption {
|
|
5
|
+
/**
|
|
6
|
+
* Whether the option can be reached but not selected
|
|
7
|
+
*/
|
|
8
|
+
disabled: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* The option element
|
|
11
|
+
*/
|
|
12
|
+
element: HTMLElement;
|
|
13
|
+
/**
|
|
14
|
+
* The text type-ahead matches: the option's `textValue`, else the text of the elements its `aria-labelledby` names,
|
|
15
|
+
* else its own text
|
|
16
|
+
*/
|
|
17
|
+
textValue: string;
|
|
18
|
+
/**
|
|
19
|
+
* The option's value
|
|
20
|
+
*/
|
|
21
|
+
value: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Reads the options a listbox renders
|
|
25
|
+
*
|
|
26
|
+
* @param listbox the listbox element
|
|
27
|
+
* @returns each option that is not hidden or inert, in document order, with its value, its type-ahead text and
|
|
28
|
+
* whether it is disabled
|
|
29
|
+
*/
|
|
30
|
+
export declare function renderedOptions(listbox: HTMLElement): RenderedOption[];
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//#region src/components/Listbox/renderedOptions.ts
|
|
2
|
+
function e(e) {
|
|
3
|
+
return Array.from(e.querySelectorAll("[role=\"option\"]")).filter((e) => e.closest("[hidden], [inert]") === null).map((e) => ({
|
|
4
|
+
disabled: e.getAttribute("aria-disabled") === "true",
|
|
5
|
+
element: e,
|
|
6
|
+
textValue: e.dataset.textValue ?? t(e) ?? e.textContent ?? "",
|
|
7
|
+
value: e.dataset.value ?? ""
|
|
8
|
+
}));
|
|
9
|
+
}
|
|
10
|
+
function t(e) {
|
|
11
|
+
let t = e.getRootNode(), n = t instanceof ShadowRoot ? t : e.ownerDocument, r = (e.getAttribute("aria-labelledby") ?? "").split(/\s+/).map((e) => n.getElementById(e)).filter((e) => e !== null);
|
|
12
|
+
return r.length === 0 ? void 0 : r.map((e) => e.textContent).join(" ");
|
|
13
|
+
}
|
|
14
|
+
//#endregion
|
|
15
|
+
export { e as renderedOptions };
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { FocusEvent, KeyboardEvent } from "react";
|
|
2
|
+
import type { ListboxContextValue } from "./ListboxContext";
|
|
3
|
+
interface UseListboxOptions {
|
|
4
|
+
/**
|
|
5
|
+
* The value selected at first when uncontrolled
|
|
6
|
+
*/
|
|
7
|
+
defaultValue: string | null;
|
|
8
|
+
/**
|
|
9
|
+
* Called with an option's value when Enter or a double-click acts on it
|
|
10
|
+
*/
|
|
11
|
+
onAction: ((value: string) => void) | undefined;
|
|
12
|
+
/**
|
|
13
|
+
* Called with the value of the option the user selects
|
|
14
|
+
*/
|
|
15
|
+
onValueChange: ((value: string) => void) | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* The selected value when controlled, or undefined when uncontrolled
|
|
18
|
+
*/
|
|
19
|
+
value: string | null | undefined;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* A listbox's state for its options, and the handlers for the listbox element
|
|
23
|
+
*/
|
|
24
|
+
export interface ListboxState extends ListboxContextValue {
|
|
25
|
+
/**
|
|
26
|
+
* Notes that focus has left, and forgets a press, so the next focus scrolls
|
|
27
|
+
*/
|
|
28
|
+
handleBlur: () => void;
|
|
29
|
+
/**
|
|
30
|
+
* Makes the selected option, or the first, active as focus enters, and scrolls it into view unless a press or a
|
|
31
|
+
* click caused the focus
|
|
32
|
+
*/
|
|
33
|
+
handleFocus: (event: FocusEvent<HTMLDivElement>) => void;
|
|
34
|
+
/**
|
|
35
|
+
* Handles the arrow keys, Home, End, Space, Enter and type-ahead
|
|
36
|
+
*/
|
|
37
|
+
handleKeyDown: (event: KeyboardEvent<HTMLDivElement>) => void;
|
|
38
|
+
/**
|
|
39
|
+
* Forgets a press the browser cancelled, so the next focus scrolls
|
|
40
|
+
*/
|
|
41
|
+
handlePointerCancel: () => void;
|
|
42
|
+
/**
|
|
43
|
+
* Notes that a press has started, so the focus it causes does not scroll
|
|
44
|
+
*/
|
|
45
|
+
handlePointerDown: () => void;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Holds a listbox's selection, controlled or uncontrolled, and its active option, and handles its keyboard
|
|
49
|
+
*
|
|
50
|
+
* @param options the selection props and callbacks
|
|
51
|
+
* @returns the state options read and the listbox element's handlers
|
|
52
|
+
*/
|
|
53
|
+
export declare function useListbox({ defaultValue, onAction, onValueChange, value }: UseListboxOptions): ListboxState;
|
|
54
|
+
export {};
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { targetIndexForKey as e } from "../../collections/targetIndexForKey.js";
|
|
2
|
+
import { extendTypeAheadQuery as t, isTypeAheadQueryLive as n, typeAheadTarget as r } from "../../collections/typeAhead.js";
|
|
3
|
+
import { renderedOptions as i } from "./renderedOptions.js";
|
|
4
|
+
import { useId as a, useRef as o, useState as s } from "react";
|
|
5
|
+
//#region src/components/Listbox/useListbox.ts
|
|
6
|
+
var c = {
|
|
7
|
+
block: "nearest",
|
|
8
|
+
container: "nearest"
|
|
9
|
+
};
|
|
10
|
+
function l({ defaultValue: l, onAction: f, onValueChange: p, value: m }) {
|
|
11
|
+
let h = a(), g = o(null), _ = o(!1), v = o(null), y = o(null), [b, x] = s(l), [S, C] = s(null), w = m === void 0 ? b : m;
|
|
12
|
+
function T(e) {
|
|
13
|
+
e !== w && (m === void 0 && x(e), p?.(e));
|
|
14
|
+
}
|
|
15
|
+
function E(e, t) {
|
|
16
|
+
C(e[t].value), y.current = t;
|
|
17
|
+
}
|
|
18
|
+
function D(e, t) {
|
|
19
|
+
let n = e[t];
|
|
20
|
+
E(e, t), n.element.scrollIntoView(c), n.disabled || T(n.value);
|
|
21
|
+
}
|
|
22
|
+
function O(e) {
|
|
23
|
+
let t = v.current;
|
|
24
|
+
if (t === null) return;
|
|
25
|
+
let n = i(t), r = n.findIndex((t) => t.value === e);
|
|
26
|
+
r !== -1 && E(n, r);
|
|
27
|
+
}
|
|
28
|
+
function k(e) {
|
|
29
|
+
if (e.target !== e.currentTarget) return;
|
|
30
|
+
v.current = e.currentTarget;
|
|
31
|
+
let t = i(e.currentTarget);
|
|
32
|
+
if (t.length === 0) {
|
|
33
|
+
C(null), y.current = null;
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
let n = Math.max(t.findIndex((e) => e.value === w), 0);
|
|
37
|
+
E(t, n), _.current || t[n].element.scrollIntoView(c);
|
|
38
|
+
}
|
|
39
|
+
function A() {
|
|
40
|
+
v.current = null, M();
|
|
41
|
+
}
|
|
42
|
+
function j() {
|
|
43
|
+
_.current = !0;
|
|
44
|
+
}
|
|
45
|
+
function M() {
|
|
46
|
+
_.current = !1;
|
|
47
|
+
}
|
|
48
|
+
function N(e) {
|
|
49
|
+
if (e.altKey || e.ctrlKey || e.metaKey) return;
|
|
50
|
+
let t = i(e.currentTarget), n = u(t, S, w), r = Date.now();
|
|
51
|
+
(P(e, t[n]) || F(e.key, t[n], r) || I(e.key, t, n) || L(e.key, t, n, r)) && e.preventDefault();
|
|
52
|
+
}
|
|
53
|
+
function P(e, t) {
|
|
54
|
+
return e.key === "Enter" && (!e.repeat && t !== void 0 && !t.disabled && f?.(t.value), !0);
|
|
55
|
+
}
|
|
56
|
+
function F(e, t, r) {
|
|
57
|
+
return e !== " " || n(g.current, r) ? !1 : (t !== void 0 && !t.disabled && T(t.value), !0);
|
|
58
|
+
}
|
|
59
|
+
function I(t, n, r) {
|
|
60
|
+
let i = (r === -1 ? d(t, n.length, y.current) : null) ?? e({
|
|
61
|
+
count: n.length,
|
|
62
|
+
currentIndex: r,
|
|
63
|
+
key: t,
|
|
64
|
+
orientation: "vertical",
|
|
65
|
+
wraps: !1
|
|
66
|
+
});
|
|
67
|
+
return i !== null && (D(n, i), !0);
|
|
68
|
+
}
|
|
69
|
+
function L(e, n, i, a) {
|
|
70
|
+
if (Array.from(e).length !== 1) return !1;
|
|
71
|
+
g.current = t(g.current, e, a);
|
|
72
|
+
let o = n.map((e) => e.textValue), s = r(o, i, g.current.text);
|
|
73
|
+
return s !== null && D(n, s), !0;
|
|
74
|
+
}
|
|
75
|
+
function R(e) {
|
|
76
|
+
f?.(e);
|
|
77
|
+
}
|
|
78
|
+
function z(e, t, n) {
|
|
79
|
+
_.current = !0, e.closest("[role=\"listbox\"]")?.focus(), _.current = !1, O(t), n || T(t);
|
|
80
|
+
}
|
|
81
|
+
return {
|
|
82
|
+
act: R,
|
|
83
|
+
activeValue: S,
|
|
84
|
+
baseId: h,
|
|
85
|
+
choose: z,
|
|
86
|
+
claim: O,
|
|
87
|
+
handleBlur: A,
|
|
88
|
+
handleFocus: k,
|
|
89
|
+
handleKeyDown: N,
|
|
90
|
+
handlePointerCancel: M,
|
|
91
|
+
handlePointerDown: j,
|
|
92
|
+
selectedValue: w,
|
|
93
|
+
setActiveValue: C
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
function u(e, t, n) {
|
|
97
|
+
let r = e.findIndex((e) => e.value === t);
|
|
98
|
+
return r === -1 ? e.findIndex((e) => e.value === n) : r;
|
|
99
|
+
}
|
|
100
|
+
function d(e, t, n) {
|
|
101
|
+
return n === null || t === 0 ? null : e === "ArrowDown" ? Math.min(n, t - 1) : e === "ArrowUp" ? Math.min(Math.max(n - 1, 0), t - 1) : null;
|
|
102
|
+
}
|
|
103
|
+
//#endregion
|
|
104
|
+
export { l as useListbox };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ListboxContextValue } from "./ListboxContext";
|
|
2
|
+
/**
|
|
3
|
+
* Reads the state of the surrounding `Listbox`
|
|
4
|
+
*
|
|
5
|
+
* @param part the name of the part reading it, for the error message
|
|
6
|
+
* @returns the surrounding `Listbox`'s state
|
|
7
|
+
* @throws MissingContextError when the part is not inside a `Listbox`
|
|
8
|
+
*/
|
|
9
|
+
export declare function useListboxContext(part: string): ListboxContextValue;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { MissingContextError as e } from "../../errors/MissingContextError.js";
|
|
2
|
+
import { ListboxContext as t } from "./ListboxContext.js";
|
|
3
|
+
import { useContext as n } from "react";
|
|
4
|
+
//#region src/components/Listbox/useListboxContext.ts
|
|
5
|
+
function r(r) {
|
|
6
|
+
let i = n(t);
|
|
7
|
+
if (i === null) throw new e(r, "Listbox");
|
|
8
|
+
return i;
|
|
9
|
+
}
|
|
10
|
+
//#endregion
|
|
11
|
+
export { r as useListboxContext };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.sui-navList-MII8M{font-family:var(--sui-font-body,system-ui, sans-serif);line-height:var(--sui-line-height-tight,1.25)}.sui-list-oNLze{gap:var(--sui-space-1,.25rem);flex-direction:column;margin:0;padding:0;list-style:none;display:flex}.sui-navList-MII8M>.sui-list-oNLze{padding:var(--sui-space-2,.5rem)}.sui-group-18cks+.sui-group-18cks{margin-block-start:var(--sui-space-3,.75rem)}.sui-groupTitle-Ftg7C{padding:var(--sui-space-1,.25rem) var(--sui-space-2,.5rem)}.sui-item-2Rc1V{box-sizing:border-box;align-items:center;gap:var(--sui-space-2,.5rem);min-block-size:1.75rem;inline-size:100%;padding:var(--sui-space-1,.25rem) var(--sui-space-2,.5rem);border-radius:var(--sui-radius-md,4px);color:var(--sui-color-text,#111827);font:inherit;text-align:start;cursor:pointer;scroll-margin-block:var(--sui-space-2,.5rem);background-color:#0000;border:0;text-decoration:none;transition:background-color .12s,color .12s;display:flex;position:relative}.sui-item-2Rc1V:hover{background-color:var(--sui-color-secondary-subtle,#f3f4f6)}.sui-item-2Rc1V[aria-current]:not([aria-current=false]){background-color:var(--sui-color-primary-subtle,#edf5ff);color:var(--sui-color-primary,#2563eb);font-weight:var(--sui-font-weight-bold,700)}.sui-item-2Rc1V:before{inset-block:var(--sui-space-1,.25rem);inline-size:calc(var(--sui-border-width,1px) * 2);border-radius:var(--sui-radius-full,9999px);background-color:var(--sui-color-primary,#2563eb);content:"";transition:transform .12s ease-out;position:absolute;inset-inline-start:0;transform:scaleY(0)}.sui-item-2Rc1V[aria-current]:not([aria-current=false]):before{transition:transform var(--sui-motion-spring,.12s ease-out);transform:scaleY(1)}.sui-item-2Rc1V:focus-visible{outline:var(--sui-focus-ring-width,2px) solid var(--sui-color-focus-ring,#3b82f6);outline-offset:2px}.sui-label-WQWVq{overflow-wrap:anywhere;flex:1;min-inline-size:0}.sui-trailing-g7A1F{flex:none}.sui-trailing-g7A1F:empty{display:none}@media (prefers-reduced-motion:reduce){.sui-item-2Rc1V:before,.sui-item-2Rc1V[aria-current]:not([aria-current=false]):before{transition:none}}@media (forced-colors:active){.sui-item-2Rc1V[aria-current]:not([aria-current=false]):before{forced-color-adjust:none;background-color:highlight}}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { JSX } from "react";
|
|
2
|
+
import type { RequiredAccessibleName } from "../../accessibility";
|
|
3
|
+
import type { BoxProps } from "../Box";
|
|
4
|
+
/**
|
|
5
|
+
* Props for `NavList`: a required `aria-label` or `aria-labelledby` and every other `nav` prop except
|
|
6
|
+
* `dangerouslySetInnerHTML`
|
|
7
|
+
*/
|
|
8
|
+
export type NavListProps = RequiredAccessibleName & Omit<BoxProps<"nav">, "aria-label" | "aria-labelledby" | "as" | "dangerouslySetInnerHTML">;
|
|
9
|
+
/**
|
|
10
|
+
* A navigation landmark holding a list of `NavListItem`s, optionally in `NavListGroup`s, such as an app's sidebar.
|
|
11
|
+
* Name it with `aria-label` or `aria-labelledby`.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* <NavList aria-label="Lists">
|
|
15
|
+
* <NavListGroup headingLevel={2} title="For review">
|
|
16
|
+
* <NavListItem href="/needs-you" aria-current="page">Needs you</NavListItem>
|
|
17
|
+
* </NavListGroup>
|
|
18
|
+
* </NavList>
|
|
19
|
+
*/
|
|
20
|
+
export declare function NavList({ children, className, ...rest }: NavListProps): JSX.Element;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Box as e } from "../Box/Box.js";
|
|
2
|
+
import t from "./NavList.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/NavList/NavList.tsx
|
|
7
|
+
function a(a) {
|
|
8
|
+
let o = r(12), s, c, l;
|
|
9
|
+
o[0] === a ? (s = o[1], c = o[2], l = o[3]) : ({children: s, className: c, ...l} = a, o[0] = a, o[1] = s, o[2] = c, o[3] = l);
|
|
10
|
+
let u;
|
|
11
|
+
o[4] === c ? u = o[5] : (u = n(t.navList, c), o[4] = c, o[5] = u);
|
|
12
|
+
let d;
|
|
13
|
+
o[6] === s ? d = o[7] : (d = /* @__PURE__ */ i(e, {
|
|
14
|
+
as: "ul",
|
|
15
|
+
className: t.list,
|
|
16
|
+
role: "list",
|
|
17
|
+
children: s
|
|
18
|
+
}), o[6] = s, o[7] = d);
|
|
19
|
+
let f;
|
|
20
|
+
return o[8] !== l || o[9] !== u || o[10] !== d ? (f = /* @__PURE__ */ i(e, {
|
|
21
|
+
...l,
|
|
22
|
+
as: "nav",
|
|
23
|
+
className: u,
|
|
24
|
+
children: d
|
|
25
|
+
}), o[8] = l, o[9] = u, o[10] = d, o[11] = f) : f = o[11], f;
|
|
26
|
+
}
|
|
27
|
+
//#endregion
|
|
28
|
+
export { a as NavList };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import './NavList.css';//#region src/components/NavList/NavList.module.css
|
|
2
|
+
var e = "sui-navList-MII8M", t = "sui-list-oNLze", n = "sui-group-18cks", r = "sui-groupTitle-Ftg7C", i = "sui-item-2Rc1V", a = "sui-label-WQWVq", o = "sui-trailing-g7A1F", s = {
|
|
3
|
+
navList: e,
|
|
4
|
+
list: t,
|
|
5
|
+
group: n,
|
|
6
|
+
groupTitle: r,
|
|
7
|
+
item: i,
|
|
8
|
+
label: a,
|
|
9
|
+
trailing: o
|
|
10
|
+
};
|
|
11
|
+
//#endregion
|
|
12
|
+
export { s as default, n as group, r as groupTitle, i as item, a as label, t as list, e as navList, o as trailing };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { JSX, ReactNode } from "react";
|
|
2
|
+
import type { BoxProps } from "../Box";
|
|
3
|
+
import type { HeadingLevel } from "../Heading";
|
|
4
|
+
/**
|
|
5
|
+
* Props for `NavListGroup`: its own props plus every `li` prop except `dangerouslySetInnerHTML` and `title`
|
|
6
|
+
*/
|
|
7
|
+
export interface NavListGroupProps extends Omit<BoxProps<"li">, "as" | "dangerouslySetInnerHTML" | "title"> {
|
|
8
|
+
/**
|
|
9
|
+
* The group's heading level, which the page outline decides: in a sidebar beside the page's `h1`, usually 2
|
|
10
|
+
*/
|
|
11
|
+
headingLevel: HeadingLevel;
|
|
12
|
+
/**
|
|
13
|
+
* The group's heading, which also names its list
|
|
14
|
+
*/
|
|
15
|
+
title: ReactNode;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* A titled group of `NavListItem`s inside a `NavList`
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* <NavListGroup headingLevel={2} title="For review">
|
|
22
|
+
* <NavListItem href="/needs-you">Needs you</NavListItem>
|
|
23
|
+
* </NavListGroup>
|
|
24
|
+
*/
|
|
25
|
+
export declare function NavListGroup({ children, className, headingLevel, title, ...rest }: NavListGroupProps): JSX.Element;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Box as e } from "../Box/Box.js";
|
|
2
|
+
import { Heading as t } from "../Heading/Heading.js";
|
|
3
|
+
import n from "./NavList.module.js";
|
|
4
|
+
import { clsx as r } from "clsx";
|
|
5
|
+
import { useId as i } from "react";
|
|
6
|
+
import { c as a } from "react/compiler-runtime";
|
|
7
|
+
import { jsx as o, jsxs as s } from "react/jsx-runtime";
|
|
8
|
+
//#region src/components/NavList/NavListGroup.tsx
|
|
9
|
+
function c(c) {
|
|
10
|
+
let l = a(20), u, d, f, p, m;
|
|
11
|
+
l[0] === c ? (u = l[1], d = l[2], f = l[3], p = l[4], m = l[5]) : ({children: u, className: d, headingLevel: f, title: m, ...p} = c, l[0] = c, l[1] = u, l[2] = d, l[3] = f, l[4] = p, l[5] = m);
|
|
12
|
+
let h = i(), g;
|
|
13
|
+
l[6] === d ? g = l[7] : (g = r(n.group, d), l[6] = d, l[7] = g);
|
|
14
|
+
let _;
|
|
15
|
+
l[8] !== h || l[9] !== f || l[10] !== m ? (_ = /* @__PURE__ */ o(t, {
|
|
16
|
+
className: n.groupTitle,
|
|
17
|
+
id: h,
|
|
18
|
+
level: f,
|
|
19
|
+
size: "xs",
|
|
20
|
+
tone: "muted",
|
|
21
|
+
children: m
|
|
22
|
+
}), l[8] = h, l[9] = f, l[10] = m, l[11] = _) : _ = l[11];
|
|
23
|
+
let v;
|
|
24
|
+
l[12] !== u || l[13] !== h ? (v = /* @__PURE__ */ o(e, {
|
|
25
|
+
as: "ul",
|
|
26
|
+
className: n.list,
|
|
27
|
+
role: "list",
|
|
28
|
+
"aria-labelledby": h,
|
|
29
|
+
children: u
|
|
30
|
+
}), l[12] = u, l[13] = h, l[14] = v) : v = l[14];
|
|
31
|
+
let y;
|
|
32
|
+
return l[15] !== p || l[16] !== g || l[17] !== _ || l[18] !== v ? (y = /* @__PURE__ */ s(e, {
|
|
33
|
+
...p,
|
|
34
|
+
as: "li",
|
|
35
|
+
className: g,
|
|
36
|
+
children: [_, v]
|
|
37
|
+
}), l[15] = p, l[16] = g, l[17] = _, l[18] = v, l[19] = y) : y = l[19], y;
|
|
38
|
+
}
|
|
39
|
+
//#endregion
|
|
40
|
+
export { c as NavListGroup };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { ComponentPropsWithRef, JSX, JSXElementConstructor, ReactNode } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* What a `NavListItem` can render: a link, a button for switching views, or a component that renders an anchor, such
|
|
4
|
+
* as a router's link
|
|
5
|
+
*/
|
|
6
|
+
export type NavListItemElement = "a" | "button" | JSXElementConstructor<never>;
|
|
7
|
+
interface NavListItemOwnProps {
|
|
8
|
+
/**
|
|
9
|
+
* The label. It is never a render function, even when the component given in `as` takes one, because the item
|
|
10
|
+
* renders it inside a `span`.
|
|
11
|
+
*/
|
|
12
|
+
children?: ReactNode;
|
|
13
|
+
/**
|
|
14
|
+
* Shown after the label, such as a `Counter`. A space separates it from the label, so it is read after it.
|
|
15
|
+
*/
|
|
16
|
+
trailing?: ReactNode;
|
|
17
|
+
}
|
|
18
|
+
interface NavListItemElementOwnProps<E extends NavListItemElement> {
|
|
19
|
+
/**
|
|
20
|
+
* What to render: `a`, `button`, or a component that renders an anchor. Defaults to `a`.
|
|
21
|
+
*/
|
|
22
|
+
as?: E;
|
|
23
|
+
/**
|
|
24
|
+
* Class names merged with the item's base class
|
|
25
|
+
*/
|
|
26
|
+
className?: string;
|
|
27
|
+
}
|
|
28
|
+
type PropsOnlyOn<Element extends "a" | "button", Other extends "a" | "button"> = {
|
|
29
|
+
[Name in Exclude<keyof ComponentPropsWithRef<Element>, keyof ComponentPropsWithRef<Other>>]?: never;
|
|
30
|
+
};
|
|
31
|
+
type NavListItemElementProps<E extends NavListItemElement> = E extends JSXElementConstructor<infer Props> ? Props : E extends "button" ? ComponentPropsWithRef<"button"> & PropsOnlyOn<"a", "button"> : ComponentPropsWithRef<"a"> & PropsOnlyOn<"button", "a">;
|
|
32
|
+
type OmitFromEach<Props, Name extends PropertyKey> = Props extends unknown ? Omit<Props, Name> : never;
|
|
33
|
+
/**
|
|
34
|
+
* Props for `NavListItem`: `children` and `trailing` plus every other prop of the link, button or component given in
|
|
35
|
+
* `as`, except `dangerouslySetInnerHTML`. When `as` may be either a link or a button, only props both accept are
|
|
36
|
+
* allowed.
|
|
37
|
+
*/
|
|
38
|
+
export type NavListItemProps<E extends NavListItemElement = "a"> = E extends NavListItemElement ? NavListItemPropsFor<E> : never;
|
|
39
|
+
type NavListItemPropsFor<E extends NavListItemElement> = NavListItemOwnProps & NavListItemElementOwnProps<E> & OmitFromEach<NavListItemElementProps<E>, "dangerouslySetInnerHTML" | keyof NavListItemOwnProps | keyof NavListItemElementOwnProps<E>>;
|
|
40
|
+
/**
|
|
41
|
+
* One item in a `NavList`. Every prop but `children` and `trailing` goes to the link, button or component given in
|
|
42
|
+
* `as`, not the list item around it. A component given in `as` must pass the `className` it is given on to its anchor,
|
|
43
|
+
* or the item is unstyled. Mark the current item with `aria-current` (`"page"` for a link, `"true"` for a view
|
|
44
|
+
* switched by a button).
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* <NavListItem href="/needs-you" trailing={<Counter count={3} />} aria-current="page">Needs you</NavListItem>
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* <NavListItem as="button" onClick={() => setView("mine")} aria-current={view === "mine"}>Mine</NavListItem>
|
|
51
|
+
*/
|
|
52
|
+
export declare function NavListItem<E extends NavListItemElement = "a">({ as, children, className, trailing, ...rest }: NavListItemProps<E>): JSX.Element;
|
|
53
|
+
export {};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { hasContent as e } from "../../forms/hasContent.js";
|
|
2
|
+
import { Box as t } from "../Box/Box.js";
|
|
3
|
+
import n from "./NavList.module.js";
|
|
4
|
+
import { clsx as r } from "clsx";
|
|
5
|
+
import { c as i } from "react/compiler-runtime";
|
|
6
|
+
import { Fragment as a, jsx as o, jsxs as s } from "react/jsx-runtime";
|
|
7
|
+
//#region src/components/NavList/NavListItem.tsx
|
|
8
|
+
function c(c) {
|
|
9
|
+
let u = i(15), d, f, p;
|
|
10
|
+
if (u[0] !== c) {
|
|
11
|
+
let { as: i, children: m, className: h, trailing: g, ..._ } = c, v = r(n.item, h), y;
|
|
12
|
+
u[4] === m ? y = u[5] : (y = /* @__PURE__ */ o(t, {
|
|
13
|
+
as: "span",
|
|
14
|
+
className: n.label,
|
|
15
|
+
children: m
|
|
16
|
+
}), u[4] = m, u[5] = y);
|
|
17
|
+
let b;
|
|
18
|
+
u[6] === g ? b = u[7] : (b = e(g) && /* @__PURE__ */ s(a, { children: [" ", /* @__PURE__ */ o(t, {
|
|
19
|
+
as: "span",
|
|
20
|
+
className: n.trailing,
|
|
21
|
+
children: g
|
|
22
|
+
})] }), u[6] = g, u[7] = b);
|
|
23
|
+
let x;
|
|
24
|
+
u[8] !== y || u[9] !== b ? (x = /* @__PURE__ */ s(a, { children: [y, b] }), u[8] = y, u[9] = b, u[10] = x) : x = u[10];
|
|
25
|
+
let S = x;
|
|
26
|
+
d = t, f = "li", p = l(i, v, S, _), u[0] = c, u[1] = d, u[2] = f, u[3] = p;
|
|
27
|
+
} else d = u[1], f = u[2], p = u[3];
|
|
28
|
+
let m;
|
|
29
|
+
return u[11] !== d || u[12] !== f || u[13] !== p ? (m = /* @__PURE__ */ o(d, {
|
|
30
|
+
as: f,
|
|
31
|
+
children: p
|
|
32
|
+
}), u[11] = d, u[12] = f, u[13] = p, u[14] = m) : m = u[14], m;
|
|
33
|
+
}
|
|
34
|
+
function l(e, n, r, i) {
|
|
35
|
+
if (e === "button") {
|
|
36
|
+
let { type: e = "button", ...a } = i;
|
|
37
|
+
return /* @__PURE__ */ o(t, {
|
|
38
|
+
...a,
|
|
39
|
+
as: "button",
|
|
40
|
+
className: n,
|
|
41
|
+
type: e,
|
|
42
|
+
children: r
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
return e === void 0 || e === "a" ? /* @__PURE__ */ o(t, {
|
|
46
|
+
...i,
|
|
47
|
+
as: "a",
|
|
48
|
+
className: n,
|
|
49
|
+
children: r
|
|
50
|
+
}) : /* @__PURE__ */ o(e, {
|
|
51
|
+
...i,
|
|
52
|
+
className: n,
|
|
53
|
+
children: r
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
//#endregion
|
|
57
|
+
export { c as NavListItem };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { NavList } from "./NavList";
|
|
2
|
+
export type { NavListProps } from "./NavList";
|
|
3
|
+
export { NavListGroup } from "./NavListGroup";
|
|
4
|
+
export type { NavListGroupProps } from "./NavListGroup";
|
|
5
|
+
export { NavListItem } from "./NavListItem";
|
|
6
|
+
export type { NavListItemElement, NavListItemProps } from "./NavListItem";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
:where(.sui-overlay-EkbfA){margin:var(--sui-space-2,.5rem);color:inherit;background:0 0;border:0;padding:0;inset:auto;overflow:visible}.sui-overlay-EkbfA[data-placement=top]{justify-self:anchor-center;position-area:top;position-try-fallbacks:flip-block}.sui-overlay-EkbfA[data-placement=bottom]{justify-self:anchor-center;position-area:bottom;position-try-fallbacks:flip-block}.sui-overlay-EkbfA[data-placement=start]{align-self:anchor-center;position-area:self-inline-start;position-try-fallbacks:flip-inline}.sui-overlay-EkbfA[data-placement=end]{align-self:anchor-center;position-area:self-inline-end;position-try-fallbacks:flip-inline}.sui-overlay-EkbfA[data-placement$=-start]{margin-inline-start:0}.sui-overlay-EkbfA[data-placement$=-end]{margin-inline-end:0}.sui-overlay-EkbfA:is([data-placement$=-start],[data-placement$=-end]){position-try-fallbacks:flip-block, flip-inline, flip-block flip-inline}.sui-overlay-EkbfA[data-placement=top-start]{position-area:self-block-start span-self-inline-end}.sui-overlay-EkbfA[data-placement=top-end]{position-area:self-block-start span-self-inline-start}.sui-overlay-EkbfA[data-placement=bottom-start]{position-area:self-block-end span-self-inline-end}.sui-overlay-EkbfA[data-placement=bottom-end]{position-area:self-block-end span-self-inline-start}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { JSX } from "react";
|
|
2
|
+
import type { OverlayPlacement } from "../../overlays";
|
|
3
|
+
import type { BoxProps } from "../Box";
|
|
4
|
+
interface OverlayOwnProps {
|
|
5
|
+
/**
|
|
6
|
+
* `anchor-name` of the trigger the overlay is positioned against
|
|
7
|
+
*/
|
|
8
|
+
anchorName: string;
|
|
9
|
+
/**
|
|
10
|
+
* Element to render: a `span` for text-only content that may sit inside a paragraph, or a `div`
|
|
11
|
+
*/
|
|
12
|
+
as: "div" | "span";
|
|
13
|
+
/**
|
|
14
|
+
* Whether the overlay is shown
|
|
15
|
+
*/
|
|
16
|
+
open: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Side of the trigger the overlay opens on. It flips to the opposite side when there is no room.
|
|
19
|
+
*/
|
|
20
|
+
placement: OverlayPlacement;
|
|
21
|
+
/**
|
|
22
|
+
* How the overlay closes: `auto` also closes on Escape, on a click outside and when another `auto` overlay opens;
|
|
23
|
+
* `manual` only when `open` turns false
|
|
24
|
+
*/
|
|
25
|
+
popover: "auto" | "manual";
|
|
26
|
+
}
|
|
27
|
+
type OverlayProps = OverlayOwnProps & Omit<BoxProps<"span">, "as" | "popover" | "ref" | keyof OverlayOwnProps>;
|
|
28
|
+
/**
|
|
29
|
+
* Floating surface shared by the overlay components. It shows in the top layer beside its trigger but stays in place
|
|
30
|
+
* in the DOM, so it inherits the theme and mode around it.
|
|
31
|
+
*/
|
|
32
|
+
export declare function Overlay({ anchorName, as, className, open, placement, popover, style, ...rest }: OverlayProps): JSX.Element;
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Box as e } from "../Box/Box.js";
|
|
2
|
+
import { syncPopover as t } from "../../overlays/syncPopover.js";
|
|
3
|
+
import n from "./Overlay.module.js";
|
|
4
|
+
import { clsx as r } from "clsx";
|
|
5
|
+
import { useEffect as i, useRef as a } from "react";
|
|
6
|
+
import { c as o } from "react/compiler-runtime";
|
|
7
|
+
import { jsx as s } from "react/jsx-runtime";
|
|
8
|
+
//#region src/components/Overlay/Overlay.tsx
|
|
9
|
+
function c(c) {
|
|
10
|
+
let l = o(24), u, d, f, p, m, h, g, _;
|
|
11
|
+
l[0] === c ? (u = l[1], d = l[2], f = l[3], p = l[4], m = l[5], h = l[6], g = l[7], _ = l[8]) : ({anchorName: u, as: d, className: f, open: p, placement: m, popover: h, style: _, ...g} = c, l[0] = c, l[1] = u, l[2] = d, l[3] = f, l[4] = p, l[5] = m, l[6] = h, l[7] = g, l[8] = _);
|
|
12
|
+
let v = a(null), y, b;
|
|
13
|
+
l[9] === p ? (y = l[10], b = l[11]) : (y = () => {
|
|
14
|
+
let e = v.current;
|
|
15
|
+
if (e !== null && "showPopover" in e) return t(e, p);
|
|
16
|
+
}, b = [p], l[9] = p, l[10] = y, l[11] = b), i(y, b);
|
|
17
|
+
let x = d, S;
|
|
18
|
+
l[12] === f ? S = l[13] : (S = r(n.overlay, f), l[12] = f, l[13] = S);
|
|
19
|
+
let C;
|
|
20
|
+
l[14] !== u || l[15] !== _ ? (C = {
|
|
21
|
+
..._,
|
|
22
|
+
positionAnchor: u
|
|
23
|
+
}, l[14] = u, l[15] = _, l[16] = C) : C = l[16];
|
|
24
|
+
let w;
|
|
25
|
+
return l[17] !== m || l[18] !== h || l[19] !== g || l[20] !== x || l[21] !== S || l[22] !== C ? (w = /* @__PURE__ */ s(e, {
|
|
26
|
+
...g,
|
|
27
|
+
as: x,
|
|
28
|
+
className: S,
|
|
29
|
+
popover: h,
|
|
30
|
+
ref: v,
|
|
31
|
+
style: C,
|
|
32
|
+
"data-placement": m
|
|
33
|
+
}), l[17] = m, l[18] = h, l[19] = g, l[20] = x, l[21] = S, l[22] = C, l[23] = w) : w = l[23], w;
|
|
34
|
+
}
|
|
35
|
+
//#endregion
|
|
36
|
+
export { c as Overlay };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Overlay } from "./Overlay";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.sui-pageLayout-5SkLH{gap:var(--sui-page-layout-gap);flex-direction:column;min-block-size:100dvh;display:flex}.sui-pageLayout-5SkLH>main{flex-grow:1}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { JSX } from "react";
|
|
2
|
+
import type { Space } from "../../layout";
|
|
3
|
+
import type { BoxElement, BoxProps } from "../Box";
|
|
4
|
+
interface PageLayoutOwnProps {
|
|
5
|
+
/**
|
|
6
|
+
* Space between the page regions. Defaults to `0`.
|
|
7
|
+
*/
|
|
8
|
+
gap?: Space;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Props for `PageLayout`: its own props plus every prop supported by the element given in `as`
|
|
12
|
+
*/
|
|
13
|
+
export type PageLayoutProps<E extends BoxElement = "div"> = PageLayoutOwnProps & Omit<BoxProps<E>, keyof PageLayoutOwnProps>;
|
|
14
|
+
/**
|
|
15
|
+
* Full-height page shell that keeps the footer at the bottom of short pages. Pass the page
|
|
16
|
+
* regions as direct children; a direct `main` child grows to fill the free space.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* <PageLayout>
|
|
20
|
+
* <header>...</header>
|
|
21
|
+
* <main>...</main>
|
|
22
|
+
* <footer>...</footer>
|
|
23
|
+
* </PageLayout>
|
|
24
|
+
*/
|
|
25
|
+
export declare function PageLayout<E extends BoxElement = "div">({ as, className, gap, ...rest }: PageLayoutProps<E>): JSX.Element;
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Box as e } from "../Box/Box.js";
|
|
2
|
+
import { spaceValue as t } from "../../layout/spaceValue.js";
|
|
3
|
+
import { withCustomProperties as n } from "../../layout/withCustomProperties.js";
|
|
4
|
+
import r from "./PageLayout.module.js";
|
|
5
|
+
import { clsx as i } from "clsx";
|
|
6
|
+
import { jsx as a } from "react/jsx-runtime";
|
|
7
|
+
//#region src/components/PageLayout/PageLayout.tsx
|
|
8
|
+
function o({ as: o, className: s, gap: c = 0, ...l }) {
|
|
9
|
+
let { style: u, ...d } = l;
|
|
10
|
+
return /* @__PURE__ */ a(e, {
|
|
11
|
+
...d,
|
|
12
|
+
as: o,
|
|
13
|
+
className: i(r.pageLayout, s),
|
|
14
|
+
style: n({ "--sui-page-layout-gap": t(c) }, u)
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
18
|
+
export { o as PageLayout };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.sui-popover-E9K9X{max-inline-size:var(--sui-popover-max-width,20rem);padding:var(--sui-space-3,.75rem);border:var(--sui-border-width,1px) solid var(--sui-color-border,#d1d5db);border-radius:var(--sui-radius-lg,8px);background-color:var(--sui-color-overlay,#fff);box-shadow:var(--sui-shadow-sm,0 1px 3px #0000001f);color:var(--sui-color-text,#111827);font-family:var(--sui-font-body,system-ui, sans-serif);font-size:var(--sui-font-size-sm,.875rem);line-height:var(--sui-line-height-normal,1.5);transition:opacity .12s ease-out, translate var(--sui-motion-spring,.12s ease-out)}@starting-style{.sui-popover-E9K9X{opacity:0}.sui-popover-E9K9X[data-placement^=top]{translate:0 var(--sui-popover-offset,4px)}.sui-popover-E9K9X[data-placement^=bottom]{translate:0 calc(var(--sui-popover-offset,4px) * -1)}.sui-popover-E9K9X[data-placement=start]{translate:var(--sui-popover-offset,4px) 0}.sui-popover-E9K9X[data-placement=end],.sui-popover-E9K9X[data-placement=start]:dir(rtl){translate:calc(var(--sui-popover-offset,4px) * -1) 0}.sui-popover-E9K9X[data-placement=end]:dir(rtl){translate:var(--sui-popover-offset,4px) 0}}@media (prefers-reduced-motion:reduce){.sui-popover-E9K9X{transition:opacity .12s ease-out}}
|