@krelborn/stylesui 0.8.1 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/accessibility/idSegment.js +1 -2
- package/dist/collections/index.d.ts +3 -0
- package/dist/collections/optionId.js +6 -0
- package/dist/{components/Listbox → collections}/renderedOptions.d.ts +7 -0
- package/dist/{components/Listbox → collections}/renderedOptions.js +6 -4
- package/dist/collections/targetIndexForKey.js +1 -2
- package/dist/collections/typeAhead.js +0 -1
- package/dist/components/Accordion/Accordion.css +1 -0
- package/dist/components/Accordion/Accordion.d.ts +90 -0
- package/dist/components/Accordion/Accordion.js +47 -0
- package/dist/components/Accordion/Accordion.module.js +19 -0
- package/dist/components/Accordion/AccordionContext.d.ts +40 -0
- package/dist/components/Accordion/AccordionContext.js +4 -0
- package/dist/components/Accordion/AccordionItem.d.ts +51 -0
- package/dist/components/Accordion/AccordionItem.js +69 -0
- package/dist/components/Accordion/AccordionToggleContent.d.ts +30 -0
- package/dist/components/Accordion/AccordionToggleContent.js +44 -0
- package/dist/components/Accordion/accordionIds.d.ts +24 -0
- package/dist/components/Accordion/accordionIds.js +12 -0
- package/dist/components/Accordion/index.d.ts +4 -0
- package/dist/components/Accordion/useAccordionContext.d.ts +9 -0
- package/dist/components/Accordion/useAccordionContext.js +10 -0
- package/dist/components/Accordion/useFindablePanel.d.ts +25 -0
- package/dist/components/Accordion/useFindablePanel.js +36 -0
- package/dist/components/Accordion/useFragmentTargetReveal.d.ts +27 -0
- package/dist/components/Accordion/useFragmentTargetReveal.js +36 -0
- package/dist/components/Accordion/useHasOpened.d.ts +7 -0
- package/dist/components/Accordion/useHasOpened.js +7 -0
- package/dist/components/Alert/Alert.js +1 -2
- package/dist/components/Alert/Alert.module.js +1 -2
- package/dist/components/Alert/AlertIcon.js +1 -2
- package/dist/components/Avatar/Avatar.js +1 -2
- package/dist/components/Avatar/Avatar.module.js +1 -2
- package/dist/components/Avatar/initialsOf.js +1 -2
- package/dist/components/AvatarGroup/AvatarGroup.js +1 -2
- package/dist/components/AvatarGroup/AvatarGroup.module.js +1 -2
- package/dist/components/Badge/Badge.js +1 -2
- package/dist/components/Badge/Badge.module.js +1 -2
- package/dist/components/Box/Box.js +1 -2
- package/dist/components/Box/Box.module.js +1 -2
- package/dist/components/Button/Button.js +2 -7
- package/dist/components/Button/Button.module.js +1 -2
- package/dist/components/Card/Card.js +1 -2
- package/dist/components/Card/Card.module.js +1 -2
- package/dist/components/Center/Center.js +6 -7
- package/dist/components/Center/Center.module.js +1 -2
- package/dist/components/Checkbox/Checkbox.js +1 -2
- package/dist/components/ChoiceControl/ChoiceControl.js +1 -2
- package/dist/components/ChoiceControl/ChoiceControl.module.js +1 -2
- package/dist/components/Cluster/Cluster.js +1 -2
- package/dist/components/Code/Code.js +1 -2
- package/dist/components/Code/Code.module.js +1 -2
- package/dist/components/Combobox/Autocomplete.d.ts +83 -0
- package/dist/components/Combobox/Autocomplete.js +102 -0
- package/dist/components/Combobox/Combobox.css +1 -0
- package/dist/components/Combobox/Combobox.d.ts +59 -0
- package/dist/components/Combobox/Combobox.js +82 -0
- package/dist/components/Combobox/Combobox.module.js +17 -0
- package/dist/components/Combobox/ComboboxContext.d.ts +88 -0
- package/dist/components/Combobox/ComboboxContext.js +4 -0
- package/dist/components/Combobox/ComboboxFieldValue.d.ts +17 -0
- package/dist/components/Combobox/ComboboxFieldValue.js +33 -0
- package/dist/components/Combobox/ComboboxOption.d.ts +51 -0
- package/dist/components/Combobox/ComboboxOption.js +74 -0
- package/dist/components/Combobox/ComboboxOptionContent.d.ts +32 -0
- package/dist/components/Combobox/ComboboxOptionContent.js +51 -0
- package/dist/components/Combobox/ComboboxPopup.d.ts +50 -0
- package/dist/components/Combobox/ComboboxPopup.js +59 -0
- package/dist/components/Combobox/autocompleteKeys.d.ts +31 -0
- package/dist/components/Combobox/autocompleteKeys.js +25 -0
- package/dist/components/Combobox/comboboxKeys.d.ts +10 -0
- package/dist/components/Combobox/comboboxKeys.js +22 -0
- package/dist/components/Combobox/containsText.d.ts +9 -0
- package/dist/components/Combobox/containsText.js +8 -0
- package/dist/components/Combobox/index.d.ts +6 -0
- package/dist/components/Combobox/isAltArrow.d.ts +9 -0
- package/dist/components/Combobox/isAltArrow.js +5 -0
- package/dist/components/Combobox/isOptionShown.d.ts +10 -0
- package/dist/components/Combobox/isOptionShown.js +5 -0
- package/dist/components/Combobox/useAutocompleteText.d.ts +56 -0
- package/dist/components/Combobox/useAutocompleteText.js +27 -0
- package/dist/components/Combobox/useComboboxContext.d.ts +9 -0
- package/dist/components/Combobox/useComboboxContext.js +10 -0
- package/dist/components/Combobox/useComboboxList.d.ts +129 -0
- package/dist/components/Combobox/useComboboxList.js +138 -0
- package/dist/components/Combobox/useComboboxOption.d.ts +35 -0
- package/dist/components/Combobox/useComboboxOption.js +46 -0
- package/dist/components/Combobox/useComboboxSelection.d.ts +45 -0
- package/dist/components/Combobox/useComboboxSelection.js +17 -0
- package/dist/components/Combobox/useResultsAnnouncement.d.ts +23 -0
- package/dist/components/Combobox/useResultsAnnouncement.js +24 -0
- package/dist/components/ContextMenu/index.d.ts +2 -0
- package/dist/components/ContextMenu/useContextMenu.d.ts +112 -0
- package/dist/components/ContextMenu/useContextMenu.js +202 -0
- package/dist/components/ContextMenu/watchLongPress.d.ts +35 -0
- package/dist/components/ContextMenu/watchLongPress.js +38 -0
- package/dist/components/Counter/Counter.js +5 -6
- package/dist/components/Counter/Counter.module.js +1 -2
- package/dist/components/Cover/Cover.js +8 -9
- package/dist/components/Cover/Cover.module.js +1 -2
- package/dist/components/Divider/Divider.js +1 -2
- package/dist/components/Divider/Divider.module.js +1 -2
- package/dist/components/Field/Field.js +11 -10
- package/dist/components/Field/Field.module.js +1 -2
- package/dist/components/Fieldset/Fieldset.js +1 -2
- package/dist/components/Fieldset/Fieldset.module.js +1 -2
- package/dist/components/Frame/Frame.js +5 -6
- package/dist/components/Frame/Frame.module.js +1 -2
- package/dist/components/Grid/Grid.js +9 -10
- package/dist/components/Grid/Grid.module.js +1 -2
- package/dist/components/Heading/Heading.js +1 -2
- package/dist/components/Heading/Heading.module.js +1 -2
- package/dist/components/HorizontalFlow/HorizontalFlow.js +6 -7
- package/dist/components/HorizontalFlow/HorizontalFlow.module.js +1 -2
- package/dist/components/Icon/AddIcon.js +1 -2
- package/dist/components/Icon/CheckIcon.d.ts +11 -0
- package/dist/components/Icon/CheckIcon.js +18 -0
- package/dist/components/Icon/ChevronDownIcon.js +1 -2
- package/dist/components/Icon/ChevronRightIcon.d.ts +11 -0
- package/dist/components/Icon/ChevronRightIcon.js +19 -0
- package/dist/components/Icon/CloseIcon.js +1 -2
- package/dist/components/Icon/ColorModeIcon.js +1 -2
- package/dist/components/Icon/DeleteIcon.js +1 -2
- package/dist/components/Icon/Icon.js +1 -2
- package/dist/components/Icon/Icon.module.js +1 -2
- package/dist/components/Icon/InfoIcon.js +1 -2
- package/dist/components/Icon/MenuIcon.d.ts +12 -0
- package/dist/components/Icon/MenuIcon.js +28 -0
- package/dist/components/Icon/MoreHorizontalIcon.js +1 -2
- package/dist/components/Icon/MoreVerticalIcon.js +1 -2
- package/dist/components/Icon/PaletteIcon.js +1 -2
- package/dist/components/Icon/RefreshIcon.js +1 -2
- package/dist/components/Icon/RemoveIcon.js +1 -2
- package/dist/components/Icon/SendIcon.js +1 -2
- package/dist/components/Icon/index.d.ts +3 -0
- package/dist/components/IconButton/IconButton.js +1 -2
- package/dist/components/IconButton/IconButton.module.js +1 -2
- package/dist/components/Kbd/Kbd.js +1 -2
- package/dist/components/Kbd/Kbd.module.js +1 -2
- package/dist/components/Link/Link.js +1 -2
- package/dist/components/Link/Link.module.js +1 -2
- package/dist/components/Listbox/Listbox.js +9 -10
- package/dist/components/Listbox/Listbox.module.js +1 -2
- package/dist/components/Listbox/ListboxContext.js +1 -2
- package/dist/components/Listbox/ListboxOption.js +7 -8
- package/dist/components/Listbox/useListbox.js +22 -23
- package/dist/components/Listbox/useListboxContext.js +1 -2
- package/dist/components/Menu/Menu.d.ts +70 -0
- package/dist/components/Menu/Menu.js +76 -0
- package/dist/components/Menu/MenuContext.d.ts +29 -0
- package/dist/components/Menu/MenuContext.js +4 -0
- package/dist/components/Menu/MenuGroup.d.ts +22 -0
- package/dist/components/Menu/MenuGroup.js +32 -0
- package/dist/components/Menu/MenuItem.d.ts +77 -0
- package/dist/components/Menu/MenuItem.js +54 -0
- package/dist/components/Menu/MenuItemCheckbox.d.ts +61 -0
- package/dist/components/Menu/MenuItemCheckbox.js +37 -0
- package/dist/components/Menu/MenuItemRadio.d.ts +47 -0
- package/dist/components/Menu/MenuItemRadio.js +39 -0
- package/dist/components/Menu/MenuRadioGroup.d.ts +34 -0
- package/dist/components/Menu/MenuRadioGroup.js +27 -0
- package/dist/components/Menu/MenuRadioGroupContext.d.ts +17 -0
- package/dist/components/Menu/MenuRadioGroupContext.js +4 -0
- package/dist/components/Menu/MenuSeparator.d.ts +16 -0
- package/dist/components/Menu/MenuSeparator.js +20 -0
- package/dist/components/Menu/Submenu.d.ts +36 -0
- package/dist/components/Menu/Submenu.js +122 -0
- package/dist/components/Menu/index.d.ts +18 -0
- package/dist/components/Menu/useMenu.d.ts +18 -0
- package/dist/components/Menu/useMenu.js +20 -0
- package/dist/components/Menu/useMenuButton.d.ts +124 -0
- package/dist/components/Menu/useMenuButton.js +92 -0
- package/dist/components/Menu/useMenuContext.d.ts +9 -0
- package/dist/components/Menu/useMenuContext.js +10 -0
- package/dist/components/Menu/useMenuItemContent.d.ts +55 -0
- package/dist/components/Menu/useMenuItemContent.js +66 -0
- package/dist/components/Menu/useMenuPointer.d.ts +27 -0
- package/dist/components/Menu/useMenuPointer.js +56 -0
- package/dist/components/Menu/useMenuRadioGroupContext.d.ts +9 -0
- package/dist/components/Menu/useMenuRadioGroupContext.js +10 -0
- package/dist/components/MenuSurface/MenuSurface.css +1 -0
- package/dist/components/MenuSurface/MenuSurface.module.js +16 -0
- package/dist/components/Menubar/Menubar.css +1 -0
- package/dist/components/Menubar/Menubar.d.ts +23 -0
- package/dist/components/Menubar/Menubar.js +67 -0
- package/dist/components/Menubar/Menubar.module.js +7 -0
- package/dist/components/Menubar/MenubarContext.d.ts +29 -0
- package/dist/components/Menubar/MenubarContext.js +4 -0
- package/dist/components/Menubar/MenubarMenu.d.ts +26 -0
- package/dist/components/Menubar/MenubarMenu.js +88 -0
- package/dist/components/Menubar/findOpenMenubarItem.d.ts +7 -0
- package/dist/components/Menubar/findOpenMenubarItem.js +6 -0
- package/dist/components/Menubar/index.d.ts +4 -0
- package/dist/components/Menubar/menubarItems.d.ts +7 -0
- package/dist/components/Menubar/menubarItems.js +5 -0
- package/dist/components/Menubar/useMenubarContext.d.ts +9 -0
- package/dist/components/Menubar/useMenubarContext.js +10 -0
- package/dist/components/NavBar/NavBar.css +1 -0
- package/dist/components/NavBar/NavBar.d.ts +53 -0
- package/dist/components/NavBar/NavBar.js +97 -0
- package/dist/components/NavBar/NavBar.module.js +22 -0
- package/dist/components/NavBar/NavBarContext.d.ts +21 -0
- package/dist/components/NavBar/NavBarContext.js +4 -0
- package/dist/components/NavBar/NavBarItem.d.ts +32 -0
- package/dist/components/NavBar/NavBarItem.js +18 -0
- package/dist/components/NavBar/NavBarMenu.d.ts +32 -0
- package/dist/components/NavBar/NavBarMenu.js +84 -0
- package/dist/components/NavBar/NavBarMenuGroup.d.ts +25 -0
- package/dist/components/NavBar/NavBarMenuGroup.js +40 -0
- package/dist/components/NavBar/NavBarMenuItem.d.ts +36 -0
- package/dist/components/NavBar/NavBarMenuItem.js +49 -0
- package/dist/components/NavBar/index.d.ts +10 -0
- package/dist/components/NavBar/isNavBarCollapsed.d.ts +8 -0
- package/dist/components/NavBar/isNavBarCollapsed.js +5 -0
- package/dist/components/NavBar/leavesPageInPlace.d.ts +12 -0
- package/dist/components/NavBar/leavesPageInPlace.js +29 -0
- package/dist/components/NavBar/renderNavBarLink.d.ts +12 -0
- package/dist/components/NavBar/renderNavBarLink.js +16 -0
- package/dist/components/NavBar/useLayoutSwitch.d.ts +26 -0
- package/dist/components/NavBar/useLayoutSwitch.js +25 -0
- package/dist/components/NavBar/useNavBarContext.d.ts +9 -0
- package/dist/components/NavBar/useNavBarContext.js +10 -0
- package/dist/components/NavList/NavList.js +1 -2
- package/dist/components/NavList/NavList.module.js +1 -2
- package/dist/components/NavList/NavListGroup.js +1 -2
- package/dist/components/NavList/NavListItem.d.ts +4 -8
- package/dist/components/NavList/NavListItem.js +1 -2
- package/dist/components/Overlay/Overlay.js +6 -7
- package/dist/components/Overlay/Overlay.module.js +1 -2
- package/dist/components/PageLayout/PageLayout.js +6 -7
- package/dist/components/PageLayout/PageLayout.module.js +1 -2
- package/dist/components/Popover/Popover.js +1 -2
- package/dist/components/Popover/Popover.module.js +1 -2
- package/dist/components/Popover/usePopover.js +44 -39
- package/dist/components/Prose/Prose.js +1 -2
- package/dist/components/Prose/Prose.module.js +1 -2
- package/dist/components/Radio/Radio.js +1 -2
- package/dist/components/RadioGroup/RadioGroup.js +5 -6
- package/dist/components/RadioGroup/RadioGroup.module.js +1 -2
- package/dist/components/RequiredIndicator/RequiredIndicator.js +1 -2
- package/dist/components/RequiredIndicator/RequiredIndicator.module.js +1 -2
- package/dist/components/Row/Row.js +1 -2
- package/dist/components/SegmentedControl/Segment.js +1 -2
- package/dist/components/SegmentedControl/SegmentedControl.js +1 -2
- package/dist/components/SegmentedControl/SegmentedControl.module.js +1 -2
- package/dist/components/Select/Select.js +1 -2
- package/dist/components/Sidebar/Sidebar.js +7 -8
- package/dist/components/Sidebar/Sidebar.module.js +1 -2
- package/dist/components/SkipLink/SkipLink.js +1 -2
- package/dist/components/SkipLink/SkipLink.module.js +1 -2
- package/dist/components/Spinner/Spinner.js +1 -2
- package/dist/components/Spinner/Spinner.module.js +1 -2
- package/dist/components/Stack/Stack.js +8 -9
- package/dist/components/Stack/Stack.module.js +1 -2
- package/dist/components/StatusDot/StatusDot.js +1 -2
- package/dist/components/StatusDot/StatusDot.module.js +1 -2
- package/dist/components/Switch/Switch.js +1 -2
- package/dist/components/Switcher/Switcher.js +9 -10
- package/dist/components/Switcher/Switcher.module.js +1 -2
- package/dist/components/Tabs/Tab.js +12 -13
- package/dist/components/Tabs/TabList.js +1 -2
- package/dist/components/Tabs/TabPanel.js +1 -2
- package/dist/components/Tabs/Tabs.js +1 -2
- package/dist/components/Tabs/Tabs.module.js +1 -2
- package/dist/components/Tabs/TabsContext.js +1 -2
- package/dist/components/Tabs/tabIds.js +1 -2
- package/dist/components/Tabs/useTabsContext.js +1 -2
- package/dist/components/Text/Text.js +1 -2
- package/dist/components/Text/Text.module.js +1 -2
- package/dist/components/TextControl/TextControl.d.ts +3 -3
- package/dist/components/TextControl/TextControl.js +14 -10
- package/dist/components/TextControl/TextControl.module.js +1 -2
- package/dist/components/TextInput/TextInput.js +1 -2
- package/dist/components/Textarea/Textarea.js +1 -2
- package/dist/components/Theme/Theme.js +1 -2
- package/dist/components/Tooltip/Tooltip.js +1 -2
- package/dist/components/Tooltip/Tooltip.module.js +1 -2
- package/dist/components/Tooltip/tooltipCoordinator.js +1 -2
- package/dist/components/Tooltip/useTooltip.js +1 -2
- package/dist/components/VisuallyHidden/VisuallyHidden.js +1 -2
- package/dist/components/VisuallyHidden/VisuallyHidden.module.js +1 -2
- package/dist/errors/MissingContextError.js +1 -2
- package/dist/errors/PopoverRefusedError.js +1 -2
- package/dist/forms/FieldContext.d.ts +5 -0
- package/dist/forms/FieldContext.js +1 -2
- package/dist/forms/RadioGroupContext.js +1 -2
- package/dist/forms/hasContent.js +1 -2
- package/dist/forms/useFieldControl.js +1 -2
- package/dist/forms/useRadioGroupItem.js +1 -2
- package/dist/index.d.ts +13 -1
- package/dist/index.js +90 -65
- package/dist/layout/listRole.js +1 -2
- package/dist/layout/spaceValue.js +1 -2
- package/dist/layout/withCustomProperties.js +1 -2
- package/dist/links/LinkOrButtonProps.d.ts +17 -0
- package/dist/links/index.d.ts +1 -0
- package/dist/menus/closeWhenFocusLeaves.d.ts +9 -0
- package/dist/menus/closeWhenFocusLeaves.js +11 -0
- package/dist/menus/focusItem.d.ts +6 -0
- package/dist/menus/focusItem.js +9 -0
- package/dist/menus/focusOnOpening.d.ts +11 -0
- package/dist/menus/focusOnOpening.js +11 -0
- package/dist/menus/hasModifier.d.ts +7 -0
- package/dist/menus/hasModifier.js +5 -0
- package/dist/menus/index.d.ts +11 -0
- package/dist/menus/itemText.d.ts +8 -0
- package/dist/menus/itemText.js +6 -0
- package/dist/menus/leaveMenuOnTab.d.ts +9 -0
- package/dist/menus/leaveMenuOnTab.js +6 -0
- package/dist/menus/pointerIntent.d.ts +36 -0
- package/dist/menus/pointerIntent.js +68 -0
- package/dist/menus/renderedItems.d.ts +8 -0
- package/dist/menus/renderedItems.js +4 -0
- package/dist/menus/watchRemovals.d.ts +8 -0
- package/dist/menus/watchRemovals.js +23 -0
- package/dist/overlays/anchorNameFor.js +1 -2
- package/dist/overlays/mergeProps.js +1 -2
- package/dist/overlays/syncPopover.js +1 -2
- package/dist/overlays/useOverlay.js +2 -9
- package/package.json +10 -10
- package/dist/components/Listbox/optionId.js +0 -7
- /package/dist/{components/Listbox → collections}/optionId.d.ts +0 -0
package/README.md
CHANGED
|
@@ -79,7 +79,7 @@ Playful's buttons lift on hover and press down when clicked. When the OS asks fo
|
|
|
79
79
|
|
|
80
80
|
Themes and palettes use CSS `light-dark()`, which needs Chrome 123, Safari 17.5 or Firefox 120.
|
|
81
81
|
|
|
82
|
-
`Tooltip` and `
|
|
82
|
+
`Tooltip`, `Popover`, the menus (`useMenu`, `useContextMenu` and `Menubar`), `Combobox` and `Autocomplete` use the Popover API and CSS anchor positioning, which need Chrome/Edge 129, Firefox 147 or Safari 26. `NavBar` anchors its wide layout's panels too, and collapses with a container style query, which needs Firefox 151; Firefox 147 to 150 show its wide layout at every width. With Vite, the CSS target below leaves their anchor positioning styles unchanged.
|
|
83
83
|
|
|
84
84
|
### Bundler CSS target
|
|
85
85
|
|
|
@@ -115,7 +115,7 @@ A Husky pre-commit hook runs lint-staged, which lints (`oxlint --fix`) and forma
|
|
|
115
115
|
|
|
116
116
|
Create `src/components/<Name>/` with `<Name>.tsx`, `<Name>.module.css`, `<Name>.test.tsx`, `<Name>.stories.tsx` and an `index.ts`, then export it from `src/index.ts`. Build on `Box` where possible. JSDoc on the component, its props and each story becomes the component's Docs page in Storybook.
|
|
117
117
|
|
|
118
|
-
Form components share code in `src/forms/`: the `ControlSize` type, the `FieldContext` and `RadioGroupContext` contexts (each in its own module), the `useFieldControl` hook that merges a `Field`'s state into a control's props, the `useRadioGroupItem` hook that gives `Radio` and `Segment` their `RadioGroup`'s name and selection, and `hasContent`. Only `ControlSize` is exported from the package. `TextControl` (behind `TextInput`, `Textarea` and `
|
|
118
|
+
Form components share code in `src/forms/`: the `ControlSize` type, the `FieldContext` and `RadioGroupContext` contexts (each in its own module), the `useFieldControl` hook that merges a `Field`'s state into a control's props, the `useRadioGroupItem` hook that gives `Radio` and `Segment` their `RadioGroup`'s name and selection, and `hasContent`. Only `ControlSize` is exported from the package. `TextControl` (behind `TextInput`, `Textarea`, `Select`, `Combobox` and `Autocomplete`), `ChoiceControl` (behind `Checkbox`, `Switch` and `Radio`) and `RequiredIndicator` are internal components: they are not exported from `src/index.ts` and have no stories or tests of their own, since the public components built on them cover them. `TextControl` and `ChoiceControl` own the one CSS module their wrappers share, so those wrappers have none.
|
|
119
119
|
|
|
120
120
|
Tree-shaking relies on the build preserving one output module per source module and on `"sideEffects": ["**/*.css"]` in `package.json`. Avoid top-level side effects in component modules.
|
|
121
121
|
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
export { optionId } from "./optionId";
|
|
2
|
+
export { optionTextValue, renderedOptions } from "./renderedOptions";
|
|
3
|
+
export type { RenderedOption } from "./renderedOptions";
|
|
1
4
|
export { targetIndexForKey } from "./targetIndexForKey";
|
|
2
5
|
export type { WritingDirection } from "./targetIndexForKey";
|
|
3
6
|
export { extendTypeAheadQuery, isTypeAheadQueryLive, typeAheadTarget } from "./typeAhead";
|
|
@@ -28,3 +28,10 @@ export interface RenderedOption {
|
|
|
28
28
|
* whether it is disabled
|
|
29
29
|
*/
|
|
30
30
|
export declare function renderedOptions(listbox: HTMLElement): RenderedOption[];
|
|
31
|
+
/**
|
|
32
|
+
* Reads the text an option is matched by, whether or not it is hidden
|
|
33
|
+
*
|
|
34
|
+
* @param option the option element
|
|
35
|
+
* @returns its `data-text-value`, else the text of the elements its `aria-labelledby` names, else its own text
|
|
36
|
+
*/
|
|
37
|
+
export declare function optionTextValue(option: HTMLElement): string;
|
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
// src/collections/renderedOptions.ts
|
|
2
2
|
function e(e) {
|
|
3
3
|
return Array.from(e.querySelectorAll("[role=\"option\"]")).filter((e) => e.closest("[hidden], [inert]") === null).map((e) => ({
|
|
4
4
|
disabled: e.getAttribute("aria-disabled") === "true",
|
|
5
5
|
element: e,
|
|
6
|
-
textValue:
|
|
6
|
+
textValue: t(e),
|
|
7
7
|
value: e.dataset.value ?? ""
|
|
8
8
|
}));
|
|
9
9
|
}
|
|
10
10
|
function t(e) {
|
|
11
|
+
return e.dataset.textValue ?? n(e) ?? e.textContent ?? "";
|
|
12
|
+
}
|
|
13
|
+
function n(e) {
|
|
11
14
|
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
15
|
return r.length === 0 ? void 0 : r.map((e) => e.textContent).join(" ");
|
|
13
16
|
}
|
|
14
|
-
|
|
15
|
-
export { e as renderedOptions };
|
|
17
|
+
export { t as optionTextValue, e as renderedOptions };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/collections/targetIndexForKey.ts
|
|
2
2
|
function e({ count: e, currentIndex: n, direction: r = "ltr", key: i, orientation: a, wraps: o }) {
|
|
3
3
|
let s = e - 1;
|
|
4
4
|
if (e === 0) return null;
|
|
@@ -13,5 +13,4 @@ function e({ count: e, currentIndex: n, direction: r = "ltr", key: i, orientatio
|
|
|
13
13
|
function t(e, t, n) {
|
|
14
14
|
return e === (t === "vertical" ? "ArrowDown" : n === "rtl" ? "ArrowLeft" : "ArrowRight") ? 1 : e === (t === "vertical" ? "ArrowUp" : n === "rtl" ? "ArrowRight" : "ArrowLeft") ? -1 : 0;
|
|
15
15
|
}
|
|
16
|
-
//#endregion
|
|
17
16
|
export { e as targetIndexForKey };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.sui-accordion-LVhhv{--sui-accordion-padding-y:var(--sui-space-2,.5rem);--sui-accordion-padding-x:var(--sui-space-2,.5rem);--sui-accordion-inset:var(--sui-space-1,.25rem);--sui-accordion-gap:var(--sui-space-2,.5rem);--sui-accordion-font-size:var(--sui-font-size-md,1rem);--sui-accordion-description-font-size:var(--sui-font-size-sm,.875rem);--sui-accordion-divider:var(--sui-color-border,#d1d5db);--sui-accordion-indicator-color:var(--sui-color-text-muted,#4b5563);--sui-accordion-radius:var(--sui-radius-md,4px);--_sui-accordion-indicator-space:calc(var(--sui-accordion-font-size) + var(--sui-accordion-gap));--_sui-accordion-actions-end:0px;color:var(--sui-color-text,#111827)}.sui-accordion-LVhhv:not([data-variant=flush]){--sui-accordion-padding-x:var(--sui-space-4,1rem);--sui-accordion-inset:0px;--sui-accordion-radius:0px;--_sui-accordion-indicator-space:0px;--_sui-accordion-actions-end:var(--sui-accordion-padding-x)}.sui-accordion-LVhhv:not([data-variant=flush])[data-size=sm]{--sui-accordion-padding-x:var(--sui-space-3,.75rem)}.sui-accordion-LVhhv:not([data-variant=flush])[data-size=lg]{--sui-accordion-padding-x:var(--sui-space-6,1.5rem)}.sui-accordion-LVhhv[data-variant=joined]{border:var(--sui-border-width,1px) solid var(--sui-accordion-divider);border-radius:var(--sui-radius-lg,8px);overflow:clip}.sui-accordion-LVhhv[data-size=sm]{--sui-accordion-padding-y:var(--sui-space-1,.25rem);--sui-accordion-font-size:var(--sui-font-size-sm,.875rem);--sui-accordion-description-font-size:var(--sui-font-size-xs,.75rem)}.sui-accordion-LVhhv[data-size=lg]{--sui-accordion-padding-y:var(--sui-space-3,.75rem);--sui-accordion-font-size:var(--sui-font-size-lg,1.125rem);--sui-accordion-description-font-size:var(--sui-font-size-md,1rem)}.sui-accordion-LVhhv[data-variant=separated]{gap:var(--sui-space-3,.75rem);flex-direction:column;display:flex}.sui-accordion-LVhhv[data-variant=separated]>.sui-item-7ryVk{--sui-accordion-radius:calc(var(--sui-radius-lg,8px) - var(--sui-border-width,1px));border:var(--sui-border-width,1px) solid var(--sui-color-border,#d1d5db);border-radius:var(--sui-radius-lg,8px);background-color:var(--sui-color-surface,#f3f4f6);box-shadow:var(--sui-shadow-sm,0 1px 3px #0000001f);transition:box-shadow var(--sui-motion-spring,.12s ease-out), translate var(--sui-motion-spring,.12s ease-out)}@media (hover:hover){.sui-accordion-LVhhv[data-variant=separated]>.sui-item-7ryVk:has(>.sui-header-WaTdJ .sui-toggle-cSQLb:hover:not([aria-disabled=true])){box-shadow:var(--sui-shadow-sm,0 1px 3px #0000001f), 0 calc(var(--sui-control-depth,0px) / 2) 0 var(--sui-color-shadow,transparent);translate:0 calc(var(--sui-control-depth,0px) / -2)}}.sui-accordion-LVhhv:is([data-variant=flush],[data-variant=joined])>.sui-item-7ryVk+.sui-item-7ryVk{border-block-start:var(--sui-border-width,1px) solid var(--sui-accordion-divider)}.sui-header-WaTdJ{align-items:center;gap:var(--sui-accordion-inset);padding:var(--sui-accordion-inset);display:flex}.sui-heading-6PDIo{min-inline-size:0;font:inherit;flex:1;margin:0}.sui-toggle-cSQLb{align-items:center;gap:var(--sui-accordion-gap);inline-size:100%;padding:var(--sui-accordion-padding-y) var(--sui-accordion-padding-x);border-radius:var(--sui-accordion-radius);color:inherit;font-family:var(--sui-font-body,system-ui, sans-serif);font-size:var(--sui-accordion-font-size);font-weight:var(--sui-font-weight-control,500);line-height:var(--sui-line-height-tight,1.25);text-align:start;cursor:pointer;background-color:#0000;border:0;transition:background-color .12s;display:flex}@media (hover:hover){.sui-toggle-cSQLb:hover:not([aria-disabled=true]){background-color:color-mix(in srgb, currentColor 8%, transparent)}}.sui-toggle-cSQLb:active:not([aria-disabled=true]){background-color:color-mix(in srgb, currentColor 16%, transparent)}.sui-toggle-cSQLb:focus-visible{outline:var(--sui-focus-ring-width,2px) solid var(--sui-color-focus-ring,#3b82f6);outline-offset:calc(-1 * var(--sui-focus-ring-width,2px))}.sui-toggle-cSQLb[aria-disabled=true]{color:color-mix(in srgb, var(--sui-color-text,#111827) 50%, transparent);cursor:not-allowed}.sui-toggle-cSQLb:not([data-variant=flush]){font-family:var(--sui-font-heading,system-ui, sans-serif)}.sui-indicator-5mEls{color:var(--sui-accordion-indicator-color);transition:background-color .12s ease, color .12s ease, rotate var(--sui-motion-spring,.12s ease-out)}.sui-toggle-cSQLb:not([data-variant=flush]) .sui-indicator-5mEls{order:1}.sui-toggle-cSQLb:not([data-variant=flush])[aria-expanded=true] .sui-chevron-i-HVZ{rotate:180deg}.sui-toggle-cSQLb[data-variant=separated] .sui-indicator-5mEls{box-sizing:content-box;padding:calc(.375em - var(--sui-border-width,1px));border:var(--sui-border-width,1px) solid var(--sui-color-control-border,transparent);border-radius:var(--sui-radius-full,9999px);background-color:var(--sui-color-secondary,#e5e7eb);color:var(--sui-color-on-secondary,#111827)}.sui-toggle-cSQLb[data-variant=separated][aria-expanded=true] .sui-indicator-5mEls{background-color:var(--sui-color-primary,#2563eb);color:var(--sui-color-on-primary,#fff)}.sui-toggle-cSQLb[aria-disabled=true] :is(.sui-indicator-5mEls,.sui-description-kokuI,.sui-trailing--LXlM){color:inherit}.sui-toggle-cSQLb[data-variant=separated][aria-disabled=true] .sui-indicator-5mEls{background-color:color-mix(in srgb, var(--sui-color-secondary,#e5e7eb) 50%, transparent)}.sui-toggle-cSQLb[data-variant=flush][aria-expanded=false] .sui-chevron-i-HVZ{rotate:-90deg}.sui-toggle-cSQLb[data-variant=flush][aria-expanded=false] .sui-chevron-i-HVZ:dir(rtl){rotate:90deg}.sui-plusMinus-j8bGi path:nth-child(2){transform-box:fill-box;transform-origin:50%;transition:rotate var(--sui-motion-spring,.12s ease-out)}.sui-toggle-cSQLb[aria-expanded=true] .sui-plusMinus-j8bGi path:nth-child(2){rotate:90deg}.sui-label-Ss7uW{flex:1;min-inline-size:0;display:grid}.sui-title--w5py{overflow-wrap:anywhere}.sui-description-kokuI,.sui-trailing--LXlM{color:var(--sui-color-text-muted,#4b5563);font-family:var(--sui-font-body,system-ui, sans-serif);font-size:var(--sui-accordion-description-font-size);font-weight:var(--sui-font-weight-regular,400)}.sui-trailing--LXlM{flex:none}.sui-actions-1vJf9{align-items:center;gap:var(--sui-accordion-inset);flex:none;padding-inline-end:var(--_sui-accordion-actions-end);display:flex}.sui-content-PEM9t{padding-block:0 var(--sui-space-3,.75rem);padding-inline:calc(var(--sui-accordion-inset) + var(--sui-accordion-padding-x) + var(--_sui-accordion-indicator-space)) calc(var(--sui-accordion-inset) + var(--sui-accordion-padding-x))}.sui-panel-Wx50w{interpolate-size:allow-keywords;transition:block-size .2s ease-out, content-visibility .2s ease-out allow-discrete;overflow:clip}.sui-panel-Wx50w[hidden]{block-size:0}@media (prefers-reduced-motion:reduce){.sui-indicator-5mEls{transition:background-color .12s,color .12s}.sui-plusMinus-j8bGi path:nth-child(2),.sui-panel-Wx50w,.sui-accordion-LVhhv[data-variant=separated]>.sui-item-7ryVk{transition:none}}@media (forced-colors:active){.sui-toggle-cSQLb[aria-disabled=true]{color:graytext}.sui-toggle-cSQLb[data-variant=separated] .sui-indicator-5mEls,.sui-toggle-cSQLb[data-variant=separated][aria-expanded=true] .sui-indicator-5mEls{color:buttontext;background-color:buttonface;border-color:buttontext}}@media print{.sui-panel-Wx50w[hidden=until-found]{content-visibility:visible;block-size:auto;transition:none}.sui-indicator-5mEls{display:none}}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import type { JSX, ReactNode } from "react";
|
|
2
|
+
import type { ControlSize } from "../../forms";
|
|
3
|
+
import type { BoxProps } from "../Box";
|
|
4
|
+
import type { HeadingLevel } from "../Heading";
|
|
5
|
+
/**
|
|
6
|
+
* Shape of the indicator that shows whether an item is open: a `chevron` that turns, or a `plusMinus` that turns from
|
|
7
|
+
* a plus into a minus
|
|
8
|
+
*/
|
|
9
|
+
export type AccordionIndicator = "chevron" | "plusMinus";
|
|
10
|
+
/**
|
|
11
|
+
* Accordion looks: `flush` rows split by dividers, for inspectors and sidebars; `joined` items in one bordered box;
|
|
12
|
+
* `separated` items each drawn as a card
|
|
13
|
+
*/
|
|
14
|
+
export type AccordionVariant = "flush" | "joined" | "separated";
|
|
15
|
+
interface AccordionOwnProps {
|
|
16
|
+
/**
|
|
17
|
+
* The `AccordionItem`s
|
|
18
|
+
*/
|
|
19
|
+
children?: ReactNode;
|
|
20
|
+
/**
|
|
21
|
+
* Whether opening an item closes the others, so at most one is open once the user opens one. Items that `value` or
|
|
22
|
+
* `defaultValue` opens are shown as given. Defaults to `false`.
|
|
23
|
+
*/
|
|
24
|
+
exclusive?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Level of every item's heading, which the page outline decides
|
|
27
|
+
*/
|
|
28
|
+
headingLevel: HeadingLevel;
|
|
29
|
+
/**
|
|
30
|
+
* Shape of the indicator that shows whether an item is open. Defaults to `chevron`.
|
|
31
|
+
*/
|
|
32
|
+
indicator?: AccordionIndicator;
|
|
33
|
+
/**
|
|
34
|
+
* Called with the values of the open items when the user opens or closes one
|
|
35
|
+
*/
|
|
36
|
+
onValueChange?: (value: string[]) => void;
|
|
37
|
+
/**
|
|
38
|
+
* Whether each open panel is a landmark region named by its title. Defaults to `true` for `joined` and `separated` and
|
|
39
|
+
* `false` for `flush`, whose many open sections would crowd the page's landmarks.
|
|
40
|
+
*/
|
|
41
|
+
regions?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Header size, matching the `Button` sizes. Defaults to `md`.
|
|
44
|
+
*/
|
|
45
|
+
size?: ControlSize;
|
|
46
|
+
/**
|
|
47
|
+
* Look of the accordion. Defaults to `flush`.
|
|
48
|
+
*/
|
|
49
|
+
variant?: AccordionVariant;
|
|
50
|
+
}
|
|
51
|
+
type AccordionOpenItems = {
|
|
52
|
+
/**
|
|
53
|
+
* Values of the items open at first. It leaves `Accordion` uncontrolled. Defaults to none.
|
|
54
|
+
*/
|
|
55
|
+
defaultValue?: string[];
|
|
56
|
+
/**
|
|
57
|
+
* Not accepted with `defaultValue`
|
|
58
|
+
*/
|
|
59
|
+
value?: never;
|
|
60
|
+
} | {
|
|
61
|
+
/**
|
|
62
|
+
* Not accepted with `value`
|
|
63
|
+
*/
|
|
64
|
+
defaultValue?: never;
|
|
65
|
+
/**
|
|
66
|
+
* Values of the open items, which makes `Accordion` controlled: update it from `onValueChange`
|
|
67
|
+
*/
|
|
68
|
+
value: string[];
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Props for `Accordion`: its own props, `value` or `defaultValue`, and every other `div` prop
|
|
72
|
+
*/
|
|
73
|
+
export type AccordionProps = AccordionOwnProps & AccordionOpenItems & Omit<BoxProps<"div">, "as" | "defaultValue" | keyof AccordionOwnProps>;
|
|
74
|
+
/**
|
|
75
|
+
* Sections of content that each open and close under a heading, following the WAI-ARIA accordion pattern. Give it an
|
|
76
|
+
* `AccordionItem` for each section. Any number of items can be open, or one with `exclusive`.
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* <Accordion defaultValue={["layout"]} headingLevel={3} size="sm">
|
|
80
|
+
* <AccordionItem title="Layout" value="layout">…</AccordionItem>
|
|
81
|
+
* <AccordionItem title="Fill" value="fill">…</AccordionItem>
|
|
82
|
+
* </Accordion>
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* <Accordion exclusive={true} headingLevel={2} indicator="plusMinus" size="lg" variant="separated">
|
|
86
|
+
* <AccordionItem title="Can I return a kit?" value="returns">…</AccordionItem>
|
|
87
|
+
* </Accordion>
|
|
88
|
+
*/
|
|
89
|
+
export declare function Accordion({ className, defaultValue, exclusive, headingLevel, indicator, onKeyDown, onValueChange, regions, size, value, variant, ...rest }: AccordionProps): JSX.Element;
|
|
90
|
+
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { targetIndexForKey as e } from "../../collections/targetIndexForKey.js";
|
|
2
|
+
import { Box as t } from "../Box/Box.js";
|
|
3
|
+
import n from "./Accordion.module.js";
|
|
4
|
+
import { AccordionContext as r } from "./AccordionContext.js";
|
|
5
|
+
import { clsx as i } from "clsx";
|
|
6
|
+
import { useId as a, useState as o } from "react";
|
|
7
|
+
import { jsx as s } from "react/jsx-runtime";
|
|
8
|
+
// src/components/Accordion/Accordion.tsx
|
|
9
|
+
function c({ className: c, defaultValue: l = [], exclusive: u = !1, headingLevel: d, indicator: f = "chevron", onKeyDown: p, onValueChange: m, regions: h, size: g = "md", value: _, variant: v = "flush", ...y }) {
|
|
10
|
+
let b = a(), [x, S] = o(l), C = _ ?? x;
|
|
11
|
+
function w(e) {
|
|
12
|
+
let t;
|
|
13
|
+
t = C.includes(e) ? C.filter((t) => t !== e) : u ? [e] : [...C, e], _ === void 0 && S(t), m?.(t);
|
|
14
|
+
}
|
|
15
|
+
function T(t) {
|
|
16
|
+
if (p?.(t), t.defaultPrevented || t.altKey || t.ctrlKey || t.metaKey || t.shiftKey) return;
|
|
17
|
+
let r = t.currentTarget, i = Array.from(r.querySelectorAll(`.${n.toggle}`)).filter((e) => e.closest(`.${n.accordion}`) === r && e.closest("[hidden], [inert]") === null), a = i.findIndex((e) => e === t.target);
|
|
18
|
+
if (a === -1) return;
|
|
19
|
+
let o = e({
|
|
20
|
+
count: i.length,
|
|
21
|
+
currentIndex: a,
|
|
22
|
+
key: t.key,
|
|
23
|
+
orientation: "vertical",
|
|
24
|
+
wraps: !1
|
|
25
|
+
});
|
|
26
|
+
o !== null && (t.preventDefault(), i[o].focus());
|
|
27
|
+
}
|
|
28
|
+
return /* @__PURE__ */ s(r.Provider, {
|
|
29
|
+
value: {
|
|
30
|
+
baseId: b,
|
|
31
|
+
headingLevel: d,
|
|
32
|
+
indicator: f,
|
|
33
|
+
openValues: C,
|
|
34
|
+
regions: h ?? v !== "flush",
|
|
35
|
+
toggle: w,
|
|
36
|
+
variant: v
|
|
37
|
+
},
|
|
38
|
+
children: /* @__PURE__ */ s(t, {
|
|
39
|
+
...y,
|
|
40
|
+
className: i(n.accordion, c),
|
|
41
|
+
onKeyDown: T,
|
|
42
|
+
"data-size": g,
|
|
43
|
+
"data-variant": v
|
|
44
|
+
})
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
export { c as Accordion };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import './Accordion.css';// src/components/Accordion/Accordion.module.css
|
|
2
|
+
var e = "sui-accordion-LVhhv", t = "sui-item-7ryVk", n = "sui-header-WaTdJ", r = "sui-toggle-cSQLb", i = "sui-heading-6PDIo", a = "sui-indicator-5mEls", o = "sui-chevron-i-HVZ", s = "sui-description-kokuI", c = "sui-trailing--LXlM", l = "sui-plusMinus-j8bGi", u = "sui-label-Ss7uW", d = "sui-title--w5py", f = "sui-actions-1vJf9", p = "sui-content-PEM9t", m = "sui-panel-Wx50w", h = {
|
|
3
|
+
accordion: e,
|
|
4
|
+
item: t,
|
|
5
|
+
header: n,
|
|
6
|
+
toggle: r,
|
|
7
|
+
heading: i,
|
|
8
|
+
indicator: a,
|
|
9
|
+
chevron: o,
|
|
10
|
+
description: s,
|
|
11
|
+
trailing: c,
|
|
12
|
+
plusMinus: l,
|
|
13
|
+
label: u,
|
|
14
|
+
title: d,
|
|
15
|
+
actions: f,
|
|
16
|
+
content: p,
|
|
17
|
+
panel: m
|
|
18
|
+
};
|
|
19
|
+
export { e as accordion, f as actions, o as chevron, p as content, h as default, s as description, n as header, i as heading, a as indicator, t as item, u as label, m as panel, l as plusMinus, d as title, r as toggle, c as trailing };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { HeadingLevel } from "../Heading";
|
|
2
|
+
import type { AccordionIndicator, AccordionVariant } from "./Accordion";
|
|
3
|
+
/**
|
|
4
|
+
* State an `Accordion` shares with its items
|
|
5
|
+
*/
|
|
6
|
+
export interface AccordionContextValue {
|
|
7
|
+
/**
|
|
8
|
+
* The generated id every toggle and panel id starts with
|
|
9
|
+
*/
|
|
10
|
+
baseId: string;
|
|
11
|
+
/**
|
|
12
|
+
* Level of every item's heading
|
|
13
|
+
*/
|
|
14
|
+
headingLevel: HeadingLevel;
|
|
15
|
+
/**
|
|
16
|
+
* Shape of every item's indicator
|
|
17
|
+
*/
|
|
18
|
+
indicator: AccordionIndicator;
|
|
19
|
+
/**
|
|
20
|
+
* Values of the open items
|
|
21
|
+
*/
|
|
22
|
+
openValues: readonly string[];
|
|
23
|
+
/**
|
|
24
|
+
* Whether each open panel is a region named by its title
|
|
25
|
+
*/
|
|
26
|
+
regions: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Opens the item with the given value if it is closed, or closes it if it is open, reporting the open items to
|
|
29
|
+
* `onValueChange`
|
|
30
|
+
*/
|
|
31
|
+
toggle: (value: string) => void;
|
|
32
|
+
/**
|
|
33
|
+
* Look of the accordion and its items
|
|
34
|
+
*/
|
|
35
|
+
variant: AccordionVariant;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Carries an `Accordion`'s state to its items; null outside an `Accordion`
|
|
39
|
+
*/
|
|
40
|
+
export declare const AccordionContext: import("react").Context<AccordionContextValue | null>;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { JSX, ReactNode } from "react";
|
|
2
|
+
import type { BoxProps } from "../Box";
|
|
3
|
+
/**
|
|
4
|
+
* Props for `AccordionItem`: its own props plus every `div` prop except `dangerouslySetInnerHTML` and `title`
|
|
5
|
+
*/
|
|
6
|
+
export interface AccordionItemProps extends Omit<BoxProps<"div">, "as" | "dangerouslySetInnerHTML" | "title"> {
|
|
7
|
+
/**
|
|
8
|
+
* Controls beside the toggle, such as an `IconButton` that adds an entry to the section. They sit outside the
|
|
9
|
+
* heading, so they are not part of its text or the toggle's name.
|
|
10
|
+
*/
|
|
11
|
+
actions?: ReactNode;
|
|
12
|
+
/**
|
|
13
|
+
* The panel's content
|
|
14
|
+
*/
|
|
15
|
+
children?: ReactNode;
|
|
16
|
+
/**
|
|
17
|
+
* Muted text under the title, inside the toggle, so it is read as part of the toggle's name
|
|
18
|
+
*/
|
|
19
|
+
description?: ReactNode;
|
|
20
|
+
/**
|
|
21
|
+
* Whether the item cannot be opened or closed. A disabled item stays reachable with the keyboard, so its title is
|
|
22
|
+
* read, and its closed panel is skipped by find-in-page. Defaults to `false`.
|
|
23
|
+
*/
|
|
24
|
+
disabled?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Whether the panel's content renders only once the item first opens, for content that is costly to render. It stays
|
|
27
|
+
* rendered after the item closes. Find-in-page and links cannot reach content that has never rendered. Defaults to
|
|
28
|
+
* `false`.
|
|
29
|
+
*/
|
|
30
|
+
lazy?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* The header's text, which names the toggle and, when the accordion has regions, the panel
|
|
33
|
+
*/
|
|
34
|
+
title: ReactNode;
|
|
35
|
+
/**
|
|
36
|
+
* Shown at the end of the toggle, such as a value or a `Counter`. A space separates it from the title, so it is read
|
|
37
|
+
* after it. Not for interactive content, which cannot sit inside the toggle: put controls in `actions`.
|
|
38
|
+
*/
|
|
39
|
+
trailing?: ReactNode;
|
|
40
|
+
/**
|
|
41
|
+
* Identifies the item in the `Accordion`'s `value`, `defaultValue` and `onValueChange`
|
|
42
|
+
*/
|
|
43
|
+
value: string;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* One section of an `Accordion`: a heading holding the toggle that opens and closes it, and the panel it shows
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* <AccordionItem title="Effects" trailing={<Counter count={2} />} value="effects">…</AccordionItem>
|
|
50
|
+
*/
|
|
51
|
+
export declare function AccordionItem({ actions, children, className, description, disabled, lazy, title, trailing, value, ...rest }: AccordionItemProps): JSX.Element;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { hasContent as e } from "../../forms/hasContent.js";
|
|
2
|
+
import { Box as t } from "../Box/Box.js";
|
|
3
|
+
import n from "./Accordion.module.js";
|
|
4
|
+
import { panelId as r, titleId as i, toggleId as a } from "./accordionIds.js";
|
|
5
|
+
import { AccordionToggleContent as o } from "./AccordionToggleContent.js";
|
|
6
|
+
import { useAccordionContext as s } from "./useAccordionContext.js";
|
|
7
|
+
import { useFindablePanel as c } from "./useFindablePanel.js";
|
|
8
|
+
import { useHasOpened as l } from "./useHasOpened.js";
|
|
9
|
+
import { clsx as u } from "clsx";
|
|
10
|
+
import { jsx as d, jsxs as f } from "react/jsx-runtime";
|
|
11
|
+
// src/components/Accordion/AccordionItem.tsx
|
|
12
|
+
function p({ actions: p, children: m, className: h, description: g, disabled: _ = !1, lazy: v = !1, title: y, trailing: b, value: x, ...S }) {
|
|
13
|
+
let C = s("AccordionItem"), w = C.openValues.includes(x), T = a(C.baseId, x), E = r(C.baseId, x), D = i(C.baseId, x), O = l(w), k = c({
|
|
14
|
+
disabled: _,
|
|
15
|
+
onMatch: () => C.toggle(x),
|
|
16
|
+
open: w
|
|
17
|
+
}), A = C.regions && w ? {
|
|
18
|
+
role: "region",
|
|
19
|
+
"aria-labelledby": D
|
|
20
|
+
} : {};
|
|
21
|
+
function j() {
|
|
22
|
+
_ || C.toggle(x);
|
|
23
|
+
}
|
|
24
|
+
return /* @__PURE__ */ f(t, {
|
|
25
|
+
...S,
|
|
26
|
+
className: u(n.item, h),
|
|
27
|
+
"data-disabled": _,
|
|
28
|
+
"data-open": w,
|
|
29
|
+
children: [/* @__PURE__ */ f(t, {
|
|
30
|
+
className: n.header,
|
|
31
|
+
children: [/* @__PURE__ */ d(t, {
|
|
32
|
+
as: `h${C.headingLevel}`,
|
|
33
|
+
className: n.heading,
|
|
34
|
+
children: /* @__PURE__ */ d(t, {
|
|
35
|
+
as: "button",
|
|
36
|
+
className: n.toggle,
|
|
37
|
+
id: T,
|
|
38
|
+
onClick: j,
|
|
39
|
+
type: "button",
|
|
40
|
+
"aria-controls": E,
|
|
41
|
+
"aria-disabled": _ ? !0 : void 0,
|
|
42
|
+
"aria-expanded": w,
|
|
43
|
+
"data-variant": C.variant,
|
|
44
|
+
children: /* @__PURE__ */ d(o, {
|
|
45
|
+
description: g,
|
|
46
|
+
indicator: C.indicator,
|
|
47
|
+
title: y,
|
|
48
|
+
titleId: D,
|
|
49
|
+
trailing: b
|
|
50
|
+
})
|
|
51
|
+
})
|
|
52
|
+
}), e(p) && /* @__PURE__ */ d(t, {
|
|
53
|
+
className: n.actions,
|
|
54
|
+
children: p
|
|
55
|
+
})]
|
|
56
|
+
}), /* @__PURE__ */ d(t, {
|
|
57
|
+
className: n.panel,
|
|
58
|
+
hidden: !w,
|
|
59
|
+
id: E,
|
|
60
|
+
ref: k,
|
|
61
|
+
...A,
|
|
62
|
+
children: /* @__PURE__ */ d(t, {
|
|
63
|
+
className: n.content,
|
|
64
|
+
children: !v || O ? m : null
|
|
65
|
+
})
|
|
66
|
+
})]
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
export { p as AccordionItem };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { JSX, ReactNode } from "react";
|
|
2
|
+
import type { AccordionIndicator } from "./Accordion";
|
|
3
|
+
interface AccordionToggleContentProps {
|
|
4
|
+
/**
|
|
5
|
+
* Muted text under the title
|
|
6
|
+
*/
|
|
7
|
+
description: ReactNode;
|
|
8
|
+
/**
|
|
9
|
+
* Shape of the indicator
|
|
10
|
+
*/
|
|
11
|
+
indicator: AccordionIndicator;
|
|
12
|
+
/**
|
|
13
|
+
* The header's text
|
|
14
|
+
*/
|
|
15
|
+
title: ReactNode;
|
|
16
|
+
/**
|
|
17
|
+
* Id of the element holding the title
|
|
18
|
+
*/
|
|
19
|
+
titleId: string;
|
|
20
|
+
/**
|
|
21
|
+
* Shown at the end of the toggle
|
|
22
|
+
*/
|
|
23
|
+
trailing: ReactNode;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* What an `AccordionItem`'s toggle shows: the indicator, which the stylesheet places for the look, then its title, and
|
|
27
|
+
* its description and trailing content, each after a space, so the toggle's name reads them in that order
|
|
28
|
+
*/
|
|
29
|
+
export declare function AccordionToggleContent({ description, indicator, title, titleId, trailing, }: AccordionToggleContentProps): JSX.Element;
|
|
30
|
+
export {};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { hasContent as e } from "../../forms/hasContent.js";
|
|
2
|
+
import { Box as t } from "../Box/Box.js";
|
|
3
|
+
import { AddIcon as n } from "../Icon/AddIcon.js";
|
|
4
|
+
import { ChevronDownIcon as r } from "../Icon/ChevronDownIcon.js";
|
|
5
|
+
import i from "./Accordion.module.js";
|
|
6
|
+
import { c as a } from "react/compiler-runtime";
|
|
7
|
+
import { Fragment as o, jsx as s, jsxs as c } from "react/jsx-runtime";
|
|
8
|
+
// src/components/Accordion/AccordionToggleContent.tsx
|
|
9
|
+
function l(l) {
|
|
10
|
+
let u = a(16), { description: d, indicator: f, title: p, titleId: m, trailing: h } = l, g;
|
|
11
|
+
u[0] === f ? g = u[1] : (g = f === "plusMinus" ? /* @__PURE__ */ s(n, { className: `${i.indicator} ${i.plusMinus}` }) : /* @__PURE__ */ s(r, { className: `${i.indicator} ${i.chevron}` }), u[0] = f, u[1] = g);
|
|
12
|
+
let _;
|
|
13
|
+
u[2] !== p || u[3] !== m ? (_ = /* @__PURE__ */ s(t, {
|
|
14
|
+
as: "span",
|
|
15
|
+
className: i.title,
|
|
16
|
+
id: m,
|
|
17
|
+
children: p
|
|
18
|
+
}), u[2] = p, u[3] = m, u[4] = _) : _ = u[4];
|
|
19
|
+
let v;
|
|
20
|
+
u[5] === d ? v = u[6] : (v = e(d) && /* @__PURE__ */ c(o, { children: [" ", /* @__PURE__ */ s(t, {
|
|
21
|
+
as: "span",
|
|
22
|
+
className: i.description,
|
|
23
|
+
children: d
|
|
24
|
+
})] }), u[5] = d, u[6] = v);
|
|
25
|
+
let y;
|
|
26
|
+
u[7] !== _ || u[8] !== v ? (y = /* @__PURE__ */ c(t, {
|
|
27
|
+
as: "span",
|
|
28
|
+
className: i.label,
|
|
29
|
+
children: [_, v]
|
|
30
|
+
}), u[7] = _, u[8] = v, u[9] = y) : y = u[9];
|
|
31
|
+
let b;
|
|
32
|
+
u[10] === h ? b = u[11] : (b = e(h) && /* @__PURE__ */ c(o, { children: [" ", /* @__PURE__ */ s(t, {
|
|
33
|
+
as: "span",
|
|
34
|
+
className: i.trailing,
|
|
35
|
+
children: h
|
|
36
|
+
})] }), u[10] = h, u[11] = b);
|
|
37
|
+
let x;
|
|
38
|
+
return u[12] !== g || u[13] !== y || u[14] !== b ? (x = /* @__PURE__ */ c(o, { children: [
|
|
39
|
+
g,
|
|
40
|
+
y,
|
|
41
|
+
b
|
|
42
|
+
] }), u[12] = g, u[13] = y, u[14] = b, u[15] = x) : x = u[15], x;
|
|
43
|
+
}
|
|
44
|
+
export { l as AccordionToggleContent };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Builds the id of an item's toggle
|
|
3
|
+
*
|
|
4
|
+
* @param baseId the `Accordion`'s generated id
|
|
5
|
+
* @param value the item's value
|
|
6
|
+
* @returns an id unique to the value within its `Accordion`, whatever characters the value holds
|
|
7
|
+
*/
|
|
8
|
+
export declare function toggleId(baseId: string, value: string): string;
|
|
9
|
+
/**
|
|
10
|
+
* Builds the id of an item's panel
|
|
11
|
+
*
|
|
12
|
+
* @param baseId the `Accordion`'s generated id
|
|
13
|
+
* @param value the item's value
|
|
14
|
+
* @returns an id unique to the value within its `Accordion`, whatever characters the value holds
|
|
15
|
+
*/
|
|
16
|
+
export declare function panelId(baseId: string, value: string): string;
|
|
17
|
+
/**
|
|
18
|
+
* Builds the id of an item's title, which names its panel when the panel is a region
|
|
19
|
+
*
|
|
20
|
+
* @param baseId the `Accordion`'s generated id
|
|
21
|
+
* @param value the item's value
|
|
22
|
+
* @returns an id unique to the value within its `Accordion`, whatever characters the value holds
|
|
23
|
+
*/
|
|
24
|
+
export declare function titleId(baseId: string, value: string): string;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { idSegment as e } from "../../accessibility/idSegment.js";
|
|
2
|
+
// src/components/Accordion/accordionIds.ts
|
|
3
|
+
function t(t, n) {
|
|
4
|
+
return `${t}-toggle-${e(n)}`;
|
|
5
|
+
}
|
|
6
|
+
function n(t, n) {
|
|
7
|
+
return `${t}-panel-${e(n)}`;
|
|
8
|
+
}
|
|
9
|
+
function r(t, n) {
|
|
10
|
+
return `${t}-title-${e(n)}`;
|
|
11
|
+
}
|
|
12
|
+
export { n as panelId, r as titleId, t as toggleId };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { AccordionContextValue } from "./AccordionContext";
|
|
2
|
+
/**
|
|
3
|
+
* Reads the state of the surrounding `Accordion`
|
|
4
|
+
*
|
|
5
|
+
* @param part the name of the part reading it, for the error message
|
|
6
|
+
* @returns the surrounding `Accordion`'s state
|
|
7
|
+
* @throws MissingContextError when the part is not inside an `Accordion`
|
|
8
|
+
*/
|
|
9
|
+
export declare function useAccordionContext(part: string): AccordionContextValue;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { MissingContextError as e } from "../../errors/MissingContextError.js";
|
|
2
|
+
import { AccordionContext as t } from "./AccordionContext.js";
|
|
3
|
+
import { useContext as n } from "react";
|
|
4
|
+
// src/components/Accordion/useAccordionContext.ts
|
|
5
|
+
function r(r) {
|
|
6
|
+
let i = n(t);
|
|
7
|
+
if (i === null) throw new e(r, "Accordion");
|
|
8
|
+
return i;
|
|
9
|
+
}
|
|
10
|
+
export { r as useAccordionContext };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { RefObject } from "react";
|
|
2
|
+
interface FindablePanelOptions {
|
|
3
|
+
/**
|
|
4
|
+
* Whether the item is disabled, so its closed panel is skipped by find-in-page
|
|
5
|
+
*/
|
|
6
|
+
disabled: boolean;
|
|
7
|
+
/**
|
|
8
|
+
* Called when find-in-page, a fragment link or the page's URL fragment as the panel mounts matches inside the closed
|
|
9
|
+
* panel
|
|
10
|
+
*/
|
|
11
|
+
onMatch: () => void;
|
|
12
|
+
/**
|
|
13
|
+
* Whether the item is open
|
|
14
|
+
*/
|
|
15
|
+
open: boolean;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Keeps a closed panel hidden until find-in-page or a fragment link matches inside it. Render the panel with `hidden`
|
|
19
|
+
* set to whether it is closed, and give it the returned ref.
|
|
20
|
+
*
|
|
21
|
+
* @param options the item's state and what to do on a match
|
|
22
|
+
* @returns the ref for the panel element
|
|
23
|
+
*/
|
|
24
|
+
export declare function useFindablePanel({ disabled, onMatch, open }: FindablePanelOptions): RefObject<HTMLDivElement | null>;
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { useFragmentTargetReveal as e } from "./useFragmentTargetReveal.js";
|
|
2
|
+
import { useLayoutEffect as t, useRef as n, useState as r } from "react";
|
|
3
|
+
import { c as i } from "react/compiler-runtime";
|
|
4
|
+
// src/components/Accordion/useFindablePanel.ts
|
|
5
|
+
function a(a) {
|
|
6
|
+
let s = i(15), { disabled: c, onMatch: l, open: u } = a, d = n(null), [f, p] = r(0), m = !u && !c, h;
|
|
7
|
+
s[0] !== c || s[1] !== u ? (h = () => {
|
|
8
|
+
u || d.current?.setAttribute("hidden", c ? "" : "until-found");
|
|
9
|
+
}, s[0] = c, s[1] = u, s[2] = h) : h = s[2];
|
|
10
|
+
let g;
|
|
11
|
+
s[3] !== c || s[4] !== u || s[5] !== f ? (g = [
|
|
12
|
+
c,
|
|
13
|
+
u,
|
|
14
|
+
f
|
|
15
|
+
], s[3] = c, s[4] = u, s[5] = f, s[6] = g) : g = s[6], t(h, g);
|
|
16
|
+
let _, v;
|
|
17
|
+
s[7] !== m || s[8] !== l ? (_ = () => {
|
|
18
|
+
let e = d.current;
|
|
19
|
+
if (e === null || !m) return;
|
|
20
|
+
let t = function(t) {
|
|
21
|
+
t.target === e && (p(o), l());
|
|
22
|
+
};
|
|
23
|
+
return e.addEventListener("beforematch", t), () => e.removeEventListener("beforematch", t);
|
|
24
|
+
}, v = [m, l], s[7] = m, s[8] = l, s[9] = _, s[10] = v) : (_ = s[9], v = s[10]), t(_, v);
|
|
25
|
+
let y;
|
|
26
|
+
return s[11] !== m || s[12] !== l || s[13] !== u ? (y = {
|
|
27
|
+
findable: m,
|
|
28
|
+
onMatch: l,
|
|
29
|
+
open: u,
|
|
30
|
+
panelRef: d
|
|
31
|
+
}, s[11] = m, s[12] = l, s[13] = u, s[14] = y) : y = s[14], e(y), d;
|
|
32
|
+
}
|
|
33
|
+
function o(e) {
|
|
34
|
+
return e + 1;
|
|
35
|
+
}
|
|
36
|
+
export { a as useFindablePanel };
|