@krelborn/stylesui 0.0.0-stage → 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/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 +5 -0
- package/dist/accessibility/index.d.ts +2 -0
- package/dist/collections/index.d.ts +7 -0
- package/dist/collections/optionId.d.ts +8 -0
- package/dist/collections/optionId.js +6 -0
- package/dist/collections/renderedOptions.d.ts +37 -0
- package/dist/collections/renderedOptions.js +17 -0
- package/dist/collections/targetIndexForKey.d.ts +45 -0
- package/dist/collections/targetIndexForKey.js +16 -0
- package/dist/collections/typeAhead.d.ts +43 -0
- package/dist/collections/typeAhead.js +18 -0
- 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.css +1 -0
- package/dist/components/Alert/Alert.d.ts +47 -0
- package/dist/components/Alert/Alert.js +27 -0
- package/dist/components/Alert/Alert.module.js +8 -0
- package/dist/components/Alert/AlertIcon.d.ts +14 -0
- package/dist/components/Alert/AlertIcon.js +42 -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 +26 -0
- package/dist/components/Avatar/Avatar.module.js +6 -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 +9 -0
- package/dist/components/AvatarGroup/AvatarGroup.css +1 -0
- package/dist/components/AvatarGroup/AvatarGroup.d.ts +30 -0
- package/dist/components/AvatarGroup/AvatarGroup.js +33 -0
- package/dist/components/AvatarGroup/AvatarGroup.module.js +6 -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 +15 -0
- package/dist/components/Badge/Badge.module.js +3 -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 +17 -0
- package/dist/components/Box/Box.module.js +3 -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 +24 -0
- package/dist/components/Button/Button.module.js +6 -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 +14 -0
- package/dist/components/Card/Card.module.js +3 -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 +19 -0
- package/dist/components/Center/Center.module.js +3 -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 +12 -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 +39 -0
- package/dist/components/ChoiceControl/ChoiceControl.module.js +8 -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 +13 -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 +19 -0
- package/dist/components/Code/Code.module.js +3 -0
- package/dist/components/Code/index.d.ts +2 -0
- 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.css +1 -0
- package/dist/components/Counter/Counter.d.ts +39 -0
- package/dist/components/Counter/Counter.js +18 -0
- package/dist/components/Counter/Counter.module.js +3 -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 +29 -0
- package/dist/components/Cover/Cover.module.js +6 -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 +15 -0
- package/dist/components/Divider/Divider.module.js +3 -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 +49 -0
- package/dist/components/Field/Field.module.js +8 -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 +64 -0
- package/dist/components/Fieldset/Fieldset.module.js +8 -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 +16 -0
- package/dist/components/Frame/Frame.module.js +3 -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 +22 -0
- package/dist/components/Grid/Grid.module.js +3 -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 +23 -0
- package/dist/components/Heading/Heading.module.js +3 -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 +30 -0
- package/dist/components/HorizontalFlow/HorizontalFlow.module.js +3 -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 +21 -0
- package/dist/components/Icon/CheckIcon.d.ts +11 -0
- package/dist/components/Icon/CheckIcon.js +18 -0
- package/dist/components/Icon/ChevronDownIcon.d.ts +11 -0
- package/dist/components/Icon/ChevronDownIcon.js +18 -0
- package/dist/components/Icon/ChevronRightIcon.d.ts +11 -0
- package/dist/components/Icon/ChevronRightIcon.js +19 -0
- package/dist/components/Icon/CloseIcon.d.ts +12 -0
- package/dist/components/Icon/CloseIcon.js +21 -0
- package/dist/components/Icon/ColorModeIcon.d.ts +12 -0
- package/dist/components/Icon/ColorModeIcon.js +36 -0
- package/dist/components/Icon/DeleteIcon.d.ts +11 -0
- package/dist/components/Icon/DeleteIcon.js +36 -0
- package/dist/components/Icon/Icon.css +1 -0
- package/dist/components/Icon/Icon.d.ts +40 -0
- package/dist/components/Icon/Icon.js +27 -0
- package/dist/components/Icon/Icon.module.js +6 -0
- package/dist/components/Icon/InfoIcon.d.ts +11 -0
- package/dist/components/Icon/InfoIcon.js +30 -0
- package/dist/components/Icon/MenuIcon.d.ts +12 -0
- package/dist/components/Icon/MenuIcon.js +28 -0
- package/dist/components/Icon/MoreHorizontalIcon.d.ts +11 -0
- package/dist/components/Icon/MoreHorizontalIcon.js +34 -0
- package/dist/components/Icon/MoreVerticalIcon.d.ts +11 -0
- package/dist/components/Icon/MoreVerticalIcon.js +34 -0
- package/dist/components/Icon/PaletteIcon.d.ts +12 -0
- package/dist/components/Icon/PaletteIcon.js +48 -0
- package/dist/components/Icon/RefreshIcon.d.ts +13 -0
- package/dist/components/Icon/RefreshIcon.js +32 -0
- package/dist/components/Icon/RemoveIcon.d.ts +11 -0
- package/dist/components/Icon/RemoveIcon.js +18 -0
- package/dist/components/Icon/SendIcon.d.ts +11 -0
- package/dist/components/Icon/SendIcon.js +22 -0
- package/dist/components/Icon/index.d.ts +16 -0
- package/dist/components/IconButton/IconButton.css +1 -0
- package/dist/components/IconButton/IconButton.d.ts +45 -0
- package/dist/components/IconButton/IconButton.js +40 -0
- package/dist/components/IconButton/IconButton.module.js +7 -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 +19 -0
- package/dist/components/Kbd/Kbd.module.js +3 -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 +26 -0
- package/dist/components/Link/Link.module.js +3 -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 +55 -0
- package/dist/components/Listbox/Listbox.module.js +6 -0
- package/dist/components/Listbox/ListboxContext.d.ts +38 -0
- package/dist/components/Listbox/ListboxContext.js +4 -0
- package/dist/components/Listbox/ListboxOption.d.ts +31 -0
- package/dist/components/Listbox/ListboxOption.js +42 -0
- package/dist/components/Listbox/index.d.ts +4 -0
- package/dist/components/Listbox/useListbox.d.ts +54 -0
- package/dist/components/Listbox/useListbox.js +103 -0
- package/dist/components/Listbox/useListboxContext.d.ts +9 -0
- package/dist/components/Listbox/useListboxContext.js +10 -0
- 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.css +1 -0
- package/dist/components/NavList/NavList.d.ts +20 -0
- package/dist/components/NavList/NavList.js +27 -0
- package/dist/components/NavList/NavList.module.js +11 -0
- package/dist/components/NavList/NavListGroup.d.ts +25 -0
- package/dist/components/NavList/NavListGroup.js +39 -0
- package/dist/components/NavList/NavListItem.d.ts +49 -0
- package/dist/components/NavList/NavListItem.js +56 -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 +35 -0
- package/dist/components/Overlay/Overlay.module.js +3 -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 +17 -0
- package/dist/components/PageLayout/PageLayout.module.js +3 -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 +20 -0
- package/dist/components/Popover/Popover.module.js +3 -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 +71 -0
- package/dist/components/Prose/Prose.css +1 -0
- package/dist/components/Prose/Prose.d.ts +50 -0
- package/dist/components/Prose/Prose.js +15 -0
- package/dist/components/Prose/Prose.module.js +3 -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 +23 -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 +36 -0
- package/dist/components/RadioGroup/RadioGroup.module.js +3 -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 +15 -0
- package/dist/components/RequiredIndicator/RequiredIndicator.module.js +3 -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 +13 -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 +41 -0
- package/dist/components/SegmentedControl/SegmentedControl.css +1 -0
- package/dist/components/SegmentedControl/SegmentedControl.d.ts +25 -0
- package/dist/components/SegmentedControl/SegmentedControl.js +19 -0
- package/dist/components/SegmentedControl/SegmentedControl.module.js +9 -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 +11 -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 +23 -0
- package/dist/components/Sidebar/Sidebar.module.js +3 -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 +20 -0
- package/dist/components/SkipLink/SkipLink.module.js +3 -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 +32 -0
- package/dist/components/Spinner/Spinner.module.js +7 -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 +20 -0
- package/dist/components/Stack/Stack.module.js +3 -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 +20 -0
- package/dist/components/StatusDot/StatusDot.module.js +3 -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 +12 -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 +22 -0
- package/dist/components/Switcher/Switcher.module.js +3 -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 +60 -0
- package/dist/components/Tabs/TabList.d.ts +16 -0
- package/dist/components/Tabs/TabList.js +22 -0
- package/dist/components/Tabs/TabPanel.d.ts +24 -0
- package/dist/components/Tabs/TabPanel.js +21 -0
- package/dist/components/Tabs/Tabs.css +1 -0
- package/dist/components/Tabs/Tabs.d.ts +81 -0
- package/dist/components/Tabs/Tabs.js +30 -0
- package/dist/components/Tabs/Tabs.module.js +8 -0
- package/dist/components/Tabs/TabsContext.d.ts +39 -0
- package/dist/components/Tabs/TabsContext.js +4 -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 +9 -0
- package/dist/components/Tabs/useTabsContext.d.ts +9 -0
- package/dist/components/Tabs/useTabsContext.js +10 -0
- package/dist/components/Text/Text.css +1 -0
- package/dist/components/Text/Text.d.ts +40 -0
- package/dist/components/Text/Text.js +16 -0
- package/dist/components/Text/Text.module.js +3 -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 +27 -0
- package/dist/components/TextControl/TextControl.module.js +3 -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 +12 -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 +11 -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 +17 -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 +21 -0
- package/dist/components/Tooltip/Tooltip.module.js +3 -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 +16 -0
- package/dist/components/Tooltip/useTooltip.d.ts +119 -0
- package/dist/components/Tooltip/useTooltip.js +73 -0
- package/dist/components/VisuallyHidden/VisuallyHidden.css +1 -0
- package/dist/components/VisuallyHidden/VisuallyHidden.d.ts +14 -0
- package/dist/components/VisuallyHidden/VisuallyHidden.js +19 -0
- package/dist/components/VisuallyHidden/VisuallyHidden.module.js +3 -0
- package/dist/components/VisuallyHidden/index.d.ts +2 -0
- package/dist/errors/MissingContextError.d.ts +11 -0
- package/dist/errors/MissingContextError.js +8 -0
- package/dist/errors/PopoverRefusedError.d.ts +12 -0
- package/dist/errors/PopoverRefusedError.js +8 -0
- package/dist/errors/index.d.ts +2 -0
- package/dist/forms/ControlSize.d.ts +4 -0
- package/dist/forms/FieldContext.d.ts +34 -0
- package/dist/forms/FieldContext.js +4 -0
- package/dist/forms/RadioGroupContext.d.ts +34 -0
- package/dist/forms/RadioGroupContext.js +4 -0
- package/dist/forms/hasContent.d.ts +10 -0
- package/dist/forms/hasContent.js +6 -0
- package/dist/forms/index.d.ts +8 -0
- package/dist/forms/useFieldControl.d.ts +36 -0
- package/dist/forms/useFieldControl.js +28 -0
- package/dist/forms/useRadioGroupItem.d.ts +50 -0
- package/dist/forms/useRadioGroupItem.js +26 -0
- package/dist/index.d.ts +107 -0
- package/dist/index.js +92 -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 +5 -0
- package/dist/layout/spaceValue.d.ts +8 -0
- package/dist/layout/spaceValue.js +5 -0
- package/dist/layout/withCustomProperties.d.ts +9 -0
- package/dist/layout/withCustomProperties.js +8 -0
- 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/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 +5 -0
- package/dist/overlays/index.d.ts +6 -0
- package/dist/overlays/mergeProps.d.ts +13 -0
- package/dist/overlays/mergeProps.js +29 -0
- package/dist/overlays/syncPopover.d.ts +11 -0
- package/dist/overlays/syncPopover.js +24 -0
- package/dist/overlays/useOverlay.d.ts +71 -0
- package/dist/overlays/useOverlay.js +49 -0
- package/dist/styles.css +1 -0
- package/fonts/playful.css +3 -0
- package/package.json +103 -3
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { optionId as e } from "../../collections/optionId.js";
|
|
2
|
+
import { Box as t } from "../Box/Box.js";
|
|
3
|
+
import n from "./Listbox.module.js";
|
|
4
|
+
import { useListboxContext as r } from "./useListboxContext.js";
|
|
5
|
+
import { clsx as i } from "clsx";
|
|
6
|
+
import { useEffectEvent as a, useLayoutEffect as o } from "react";
|
|
7
|
+
import { jsx as s } from "react/jsx-runtime";
|
|
8
|
+
// src/components/Listbox/ListboxOption.tsx
|
|
9
|
+
function c({ className: c, disabled: l = !1, onClick: u, onDoubleClick: d, textValue: f, value: p, ...m }) {
|
|
10
|
+
let h = r("ListboxOption"), { setActiveValue: g } = h, _ = h.activeValue === p, v = h.selectedValue === p, y = a(h.claim);
|
|
11
|
+
o(() => {
|
|
12
|
+
if (_) return () => {
|
|
13
|
+
g((e) => e === p ? null : e);
|
|
14
|
+
};
|
|
15
|
+
}, [
|
|
16
|
+
_,
|
|
17
|
+
g,
|
|
18
|
+
p
|
|
19
|
+
]), o(() => {
|
|
20
|
+
v && y(p);
|
|
21
|
+
}, [v, p]);
|
|
22
|
+
function b(e) {
|
|
23
|
+
u?.(e), e.defaultPrevented || h.choose(e.currentTarget, p, l);
|
|
24
|
+
}
|
|
25
|
+
function x(e) {
|
|
26
|
+
d?.(e), !e.defaultPrevented && !l && h.act(p);
|
|
27
|
+
}
|
|
28
|
+
return /* @__PURE__ */ s(t, {
|
|
29
|
+
...m,
|
|
30
|
+
className: i(n.option, c),
|
|
31
|
+
id: e(h.baseId, p),
|
|
32
|
+
onClick: b,
|
|
33
|
+
onDoubleClick: x,
|
|
34
|
+
role: "option",
|
|
35
|
+
"aria-disabled": l ? !0 : void 0,
|
|
36
|
+
"aria-selected": v,
|
|
37
|
+
"data-active": _ ? "" : void 0,
|
|
38
|
+
"data-text-value": f,
|
|
39
|
+
"data-value": p
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
export { c as ListboxOption };
|
|
@@ -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,103 @@
|
|
|
1
|
+
import { extendTypeAheadQuery as e, isTypeAheadQueryLive as t, typeAheadTarget as n } from "../../collections/typeAhead.js";
|
|
2
|
+
import { renderedOptions as r } from "../../collections/renderedOptions.js";
|
|
3
|
+
import { targetIndexForKey as i } from "../../collections/targetIndexForKey.js";
|
|
4
|
+
import { useId as a, useRef as o, useState as s } from "react";
|
|
5
|
+
// 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 = r(t), i = n.findIndex((t) => t.value === e);
|
|
26
|
+
i !== -1 && E(n, i);
|
|
27
|
+
}
|
|
28
|
+
function k(e) {
|
|
29
|
+
if (e.target !== e.currentTarget) return;
|
|
30
|
+
v.current = e.currentTarget;
|
|
31
|
+
let t = r(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 = r(e.currentTarget), n = u(t, S, w), i = Date.now();
|
|
51
|
+
(P(e, t[n]) || F(e.key, t[n], i) || I(e.key, t, n) || L(e.key, t, n, i)) && 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, n, r) {
|
|
57
|
+
return e !== " " || t(g.current, r) ? !1 : (n !== void 0 && !n.disabled && T(n.value), !0);
|
|
58
|
+
}
|
|
59
|
+
function I(e, t, n) {
|
|
60
|
+
let r = (n === -1 ? d(e, t.length, y.current) : null) ?? i({
|
|
61
|
+
count: t.length,
|
|
62
|
+
currentIndex: n,
|
|
63
|
+
key: e,
|
|
64
|
+
orientation: "vertical",
|
|
65
|
+
wraps: !1
|
|
66
|
+
});
|
|
67
|
+
return r !== null && (D(t, r), !0);
|
|
68
|
+
}
|
|
69
|
+
function L(t, r, i, a) {
|
|
70
|
+
if (Array.from(t).length !== 1) return !1;
|
|
71
|
+
g.current = e(g.current, t, a);
|
|
72
|
+
let o = r.map((e) => e.textValue), s = n(o, i, g.current.text);
|
|
73
|
+
return s !== null && D(r, 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
|
+
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,10 @@
|
|
|
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
|
+
// 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
|
+
export { r as useListboxContext };
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { JSX, ToggleEventHandler } from "react";
|
|
2
|
+
import type { OverlayPlacement } from "../../overlays";
|
|
3
|
+
import type { BoxProps } from "../Box";
|
|
4
|
+
/**
|
|
5
|
+
* How tightly a menu's rows are spaced: `default` for menus from buttons, `compact` for menubars and dense tools
|
|
6
|
+
*/
|
|
7
|
+
export type MenuDensity = "compact" | "default";
|
|
8
|
+
/**
|
|
9
|
+
* Props `getMenuProps` from `useMenu` returns, which every `Menu` takes
|
|
10
|
+
*/
|
|
11
|
+
export interface MenuOverlayProps {
|
|
12
|
+
/**
|
|
13
|
+
* `anchor-name` of the trigger the menu is positioned against. From `getMenuProps`.
|
|
14
|
+
*/
|
|
15
|
+
anchorName: string;
|
|
16
|
+
/**
|
|
17
|
+
* Closes every open menu, as choosing an item does. From `getMenuProps`.
|
|
18
|
+
*/
|
|
19
|
+
close: () => void;
|
|
20
|
+
/**
|
|
21
|
+
* The menu's id, which the trigger's `popoverTarget` and `aria-controls` point at. From `getMenuProps`.
|
|
22
|
+
*/
|
|
23
|
+
id: string;
|
|
24
|
+
/**
|
|
25
|
+
* Cancels an opening the parent of a controlled menu has not asked for. From `getMenuProps`.
|
|
26
|
+
*/
|
|
27
|
+
onBeforeToggle: ToggleEventHandler<HTMLElement>;
|
|
28
|
+
/**
|
|
29
|
+
* Keeps the hook's state in step with the browser and moves focus in as the menu opens. From `getMenuProps`.
|
|
30
|
+
*/
|
|
31
|
+
onToggle: ToggleEventHandler<HTMLElement>;
|
|
32
|
+
/**
|
|
33
|
+
* Whether the menu is shown. From `getMenuProps`.
|
|
34
|
+
*/
|
|
35
|
+
open: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Side of the trigger the menu opens on. From `getMenuProps`.
|
|
38
|
+
*/
|
|
39
|
+
placement: OverlayPlacement;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Props for `Menu`: the props `getMenuProps` returns plus every `div` prop except those the menu pattern sets
|
|
43
|
+
*/
|
|
44
|
+
export interface MenuProps extends MenuOverlayProps, Omit<BoxProps<"div">, "aria-activedescendant" | "aria-orientation" | "as" | "popover" | "ref" | "role" | "tabIndex" | keyof MenuOverlayProps> {
|
|
45
|
+
/**
|
|
46
|
+
* How tightly the rows are spaced, which the menu's submenus share. Rows are at least 44px tall on a touch screen,
|
|
47
|
+
* whatever the density. Defaults to `default`.
|
|
48
|
+
*/
|
|
49
|
+
density?: MenuDensity;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* A menu of commands that opens from a button, such as the actions on a row or the options of a view. `useMenu`
|
|
53
|
+
* connects the two: spread `getTriggerProps()` on a `Button` or `IconButton` and `getMenuProps()` on the menu, inside
|
|
54
|
+
* the same `Theme`. Opened from the keyboard, focus moves to the first item; opened with a pointer, to the menu itself.
|
|
55
|
+
* Choosing an item runs its `onClick` and closes the menu, and Escape or a click outside closes it too. Focus then goes
|
|
56
|
+
* back to the trigger, unless a click outside put it elsewhere.
|
|
57
|
+
*
|
|
58
|
+
* The menu is named by its trigger. An `IconButton` takes its name from its tooltip, which the menu cannot reach, so
|
|
59
|
+
* give the menu the same name with `getMenuProps({ "aria-label": … })`.
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* const menu = useMenu();
|
|
63
|
+
*
|
|
64
|
+
* <Button {...menu.getTriggerProps()} variant="secondary">Actions</Button>
|
|
65
|
+
* <Menu {...menu.getMenuProps()}>
|
|
66
|
+
* <MenuItem onClick={edit}>Edit</MenuItem>
|
|
67
|
+
* <MenuItem onClick={duplicate}>Duplicate</MenuItem>
|
|
68
|
+
* </Menu>
|
|
69
|
+
*/
|
|
70
|
+
export declare function Menu({ className, close, density, onKeyDown, onPointerMove, onPointerOut, onToggle, ...rest }: MenuProps): JSX.Element;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { extendTypeAheadQuery as e, isTypeAheadQueryLive as t, typeAheadTarget as n } from "../../collections/typeAhead.js";
|
|
2
|
+
import { targetIndexForKey as r } from "../../collections/targetIndexForKey.js";
|
|
3
|
+
import { focusItem as i } from "../../menus/focusItem.js";
|
|
4
|
+
import { hasModifier as a } from "../../menus/hasModifier.js";
|
|
5
|
+
import { itemText as o } from "../../menus/itemText.js";
|
|
6
|
+
import { renderedItems as s } from "../../menus/renderedItems.js";
|
|
7
|
+
import c from "../MenuSurface/MenuSurface.module.js";
|
|
8
|
+
import { Overlay as l } from "../Overlay/Overlay.js";
|
|
9
|
+
import { MenuContext as u } from "./MenuContext.js";
|
|
10
|
+
import { useMenuPointer as d } from "./useMenuPointer.js";
|
|
11
|
+
import { clsx as f } from "clsx";
|
|
12
|
+
import { useRef as p } from "react";
|
|
13
|
+
import { jsx as m } from "react/jsx-runtime";
|
|
14
|
+
// src/components/Menu/Menu.tsx
|
|
15
|
+
function h({ className: h, close: g, density: _ = "default", onKeyDown: v, onPointerMove: y, onPointerOut: b, onToggle: x, ...S }) {
|
|
16
|
+
let C = p(null), w = p(!1), T = d();
|
|
17
|
+
function E() {
|
|
18
|
+
w.current || g();
|
|
19
|
+
}
|
|
20
|
+
function D(e) {
|
|
21
|
+
y?.(e), T.handlePointerMove(e);
|
|
22
|
+
}
|
|
23
|
+
function O(e) {
|
|
24
|
+
b?.(e), T.handlePointerOut(e);
|
|
25
|
+
}
|
|
26
|
+
function k(e) {
|
|
27
|
+
x(e), e.newState === "closed" && e.target === e.currentTarget && (C.current = null);
|
|
28
|
+
}
|
|
29
|
+
function A(e) {
|
|
30
|
+
v?.(e);
|
|
31
|
+
let t = e.currentTarget, n = e.target.closest("[role=\"menu\"]") !== t;
|
|
32
|
+
if (e.defaultPrevented || a(e) || n) return;
|
|
33
|
+
let r = s(t), i = r.indexOf(e.target), o = i === -1 ? void 0 : r[i];
|
|
34
|
+
(j(e.key, r, i) || M(e, o)) && e.preventDefault();
|
|
35
|
+
}
|
|
36
|
+
function j(e, t, n) {
|
|
37
|
+
let a = r({
|
|
38
|
+
count: t.length,
|
|
39
|
+
currentIndex: n,
|
|
40
|
+
key: e,
|
|
41
|
+
orientation: "vertical",
|
|
42
|
+
wraps: !0
|
|
43
|
+
}) ?? N(e, t, n);
|
|
44
|
+
return a != null && i(t[a]), a !== void 0;
|
|
45
|
+
}
|
|
46
|
+
function M(e, t) {
|
|
47
|
+
let n = t?.getAttribute("role") !== "menuitem";
|
|
48
|
+
return e.key !== " " || t === void 0 || !n && t instanceof HTMLButtonElement ? !1 : (e.repeat || (w.current = n, t.click(), w.current = !1), !0);
|
|
49
|
+
}
|
|
50
|
+
function N(r, i, a) {
|
|
51
|
+
let s = Date.now();
|
|
52
|
+
if (!(Array.from(r).length !== 1 || r === " " && !t(C.current, s))) return C.current = e(C.current, r, s), n(i.map(o), a, C.current.text);
|
|
53
|
+
}
|
|
54
|
+
return /* @__PURE__ */ m(u.Provider, {
|
|
55
|
+
value: {
|
|
56
|
+
closeAfterChoosing: E,
|
|
57
|
+
closeAll: g,
|
|
58
|
+
density: _,
|
|
59
|
+
startPointerGrace: T.startPointerGrace
|
|
60
|
+
},
|
|
61
|
+
children: /* @__PURE__ */ m(l, {
|
|
62
|
+
...S,
|
|
63
|
+
as: "div",
|
|
64
|
+
className: f(c.menu, h),
|
|
65
|
+
onKeyDown: A,
|
|
66
|
+
onPointerMove: D,
|
|
67
|
+
onPointerOut: O,
|
|
68
|
+
onToggle: k,
|
|
69
|
+
popover: "auto",
|
|
70
|
+
role: "menu",
|
|
71
|
+
tabIndex: 0,
|
|
72
|
+
"data-density": _
|
|
73
|
+
})
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
export { h as Menu };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Point } from "../../menus";
|
|
2
|
+
import type { MenuDensity } from "./Menu";
|
|
3
|
+
/**
|
|
4
|
+
* State a `Menu` shares with its items
|
|
5
|
+
*/
|
|
6
|
+
export interface MenuContextValue {
|
|
7
|
+
/**
|
|
8
|
+
* Closes every open menu once an item has been chosen, unless Space chose a checkbox or radio item, which leaves
|
|
9
|
+
* them open
|
|
10
|
+
*/
|
|
11
|
+
closeAfterChoosing: () => void;
|
|
12
|
+
/**
|
|
13
|
+
* Closes every open menu, from the top menu down
|
|
14
|
+
*/
|
|
15
|
+
closeAll: () => void;
|
|
16
|
+
/**
|
|
17
|
+
* How tightly the menu's rows are spaced, which its submenus share
|
|
18
|
+
*/
|
|
19
|
+
density: MenuDensity;
|
|
20
|
+
/**
|
|
21
|
+
* Lets the pointer cross the menu's other items on its way into an open submenu, from the point where it left the
|
|
22
|
+
* submenu's item
|
|
23
|
+
*/
|
|
24
|
+
startPointerGrace: (exit: Point, submenu: HTMLElement) => void;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Carries a `Menu`'s state to its items; null outside a `Menu`
|
|
28
|
+
*/
|
|
29
|
+
export declare const MenuContext: import("react").Context<MenuContextValue | null>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { JSX, ReactNode } from "react";
|
|
2
|
+
import type { BoxProps } from "../Box";
|
|
3
|
+
/**
|
|
4
|
+
* Props for `MenuGroup`: its label plus every `div` prop except the role the menu pattern sets
|
|
5
|
+
*/
|
|
6
|
+
export interface MenuGroupProps extends Omit<BoxProps<"div">, "as" | "role"> {
|
|
7
|
+
/**
|
|
8
|
+
* A heading shown above the group's items, which names the group
|
|
9
|
+
*/
|
|
10
|
+
label?: ReactNode;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Groups related items in a `Menu`, under a label that names them when it has one. The arrow keys and type-ahead move
|
|
14
|
+
* across groups as though the items were in one list. Put a `MenuSeparator` between groups to rule them apart.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* <MenuGroup label="Sort by">
|
|
18
|
+
* <MenuItem onClick={sortByName}>Name</MenuItem>
|
|
19
|
+
* <MenuItem onClick={sortBySize}>Size</MenuItem>
|
|
20
|
+
* </MenuGroup>
|
|
21
|
+
*/
|
|
22
|
+
export declare function MenuGroup({ children, className, label, "aria-labelledby": labelledBy, ...rest }: MenuGroupProps): JSX.Element;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { hasContent as e } from "../../forms/hasContent.js";
|
|
2
|
+
import { Box as t } from "../Box/Box.js";
|
|
3
|
+
import n from "../MenuSurface/MenuSurface.module.js";
|
|
4
|
+
import { useMenuContext as r } from "./useMenuContext.js";
|
|
5
|
+
import { clsx as i } from "clsx";
|
|
6
|
+
import { useId as a } from "react";
|
|
7
|
+
import { c as o } from "react/compiler-runtime";
|
|
8
|
+
import { jsx as s, jsxs as c } from "react/jsx-runtime";
|
|
9
|
+
// src/components/Menu/MenuGroup.tsx
|
|
10
|
+
function l(l) {
|
|
11
|
+
let u = o(20), d, f, p, m, h;
|
|
12
|
+
u[0] === l ? (d = u[1], f = u[2], p = u[3], m = u[4], h = u[5]) : ({children: d, className: f, label: p, "aria-labelledby": m, ...h} = l, u[0] = l, u[1] = d, u[2] = f, u[3] = p, u[4] = m, u[5] = h), r("MenuGroup");
|
|
13
|
+
let g = a(), _;
|
|
14
|
+
u[6] === p ? _ = u[7] : (_ = e(p), u[6] = p, u[7] = _);
|
|
15
|
+
let v = _, y;
|
|
16
|
+
u[8] === f ? y = u[9] : (y = i(n.group, f), u[8] = f, u[9] = y);
|
|
17
|
+
let b = v ? g : m, x;
|
|
18
|
+
u[10] !== v || u[11] !== p || u[12] !== g ? (x = v && /* @__PURE__ */ s(t, {
|
|
19
|
+
className: n.groupLabel,
|
|
20
|
+
id: g,
|
|
21
|
+
children: p
|
|
22
|
+
}), u[10] = v, u[11] = p, u[12] = g, u[13] = x) : x = u[13];
|
|
23
|
+
let S;
|
|
24
|
+
return u[14] !== d || u[15] !== h || u[16] !== y || u[17] !== b || u[18] !== x ? (S = /* @__PURE__ */ c(t, {
|
|
25
|
+
...h,
|
|
26
|
+
className: y,
|
|
27
|
+
role: "group",
|
|
28
|
+
"aria-labelledby": b,
|
|
29
|
+
children: [x, d]
|
|
30
|
+
}), u[14] = d, u[15] = h, u[16] = y, u[17] = b, u[18] = x, u[19] = S) : S = u[19], S;
|
|
31
|
+
}
|
|
32
|
+
export { l as MenuGroup };
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import type { JSX, ReactNode } from "react";
|
|
2
|
+
import type { LinkOrButtonElement, LinkOrButtonProps } from "../../links";
|
|
3
|
+
/**
|
|
4
|
+
* What a `MenuItem` can render: a button for an action, a link, or a component that renders an anchor, such as a
|
|
5
|
+
* router's link
|
|
6
|
+
*/
|
|
7
|
+
export type MenuItemElement = LinkOrButtonElement;
|
|
8
|
+
interface MenuItemOwnProps {
|
|
9
|
+
/**
|
|
10
|
+
* Not accepted: the label names the item
|
|
11
|
+
*/
|
|
12
|
+
"aria-label"?: never;
|
|
13
|
+
/**
|
|
14
|
+
* Not accepted: the label names the item
|
|
15
|
+
*/
|
|
16
|
+
"aria-labelledby"?: never;
|
|
17
|
+
/**
|
|
18
|
+
* The label, which names the item
|
|
19
|
+
*/
|
|
20
|
+
children: ReactNode;
|
|
21
|
+
/**
|
|
22
|
+
* A line of muted text below the label, which describes the item
|
|
23
|
+
*/
|
|
24
|
+
description?: ReactNode;
|
|
25
|
+
/**
|
|
26
|
+
* Whether the item cannot be chosen. It stays reachable with the arrow keys, so its label is read, but clicks, Enter
|
|
27
|
+
* and Space do nothing: your `onClick` does not run and a link is not followed, nor opened by a middle click. A link
|
|
28
|
+
* given as `a` also loses its `href`, so its context menu cannot open it. Defaults to `false`.
|
|
29
|
+
*/
|
|
30
|
+
disabled?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* An icon before the label, hidden from assistive technology. Once any item in the menu has one, every label lines
|
|
33
|
+
* up after the icons.
|
|
34
|
+
*/
|
|
35
|
+
icon?: ReactNode;
|
|
36
|
+
/**
|
|
37
|
+
* A keyboard shortcut shown after the label, such as "⌘D". It is hidden from assistive technology: announce it with
|
|
38
|
+
* `aria-keyshortcuts`. The menu does not bind it.
|
|
39
|
+
*/
|
|
40
|
+
shortcut?: string;
|
|
41
|
+
/**
|
|
42
|
+
* `danger` for an item that destroys something, which also needs to say so in its label
|
|
43
|
+
*/
|
|
44
|
+
tone?: "danger";
|
|
45
|
+
}
|
|
46
|
+
interface MenuItemElementOwnProps<E extends MenuItemElement> {
|
|
47
|
+
/**
|
|
48
|
+
* What to render: `button`, `a`, or a component that renders an anchor. Defaults to `button`.
|
|
49
|
+
*/
|
|
50
|
+
as?: E;
|
|
51
|
+
/**
|
|
52
|
+
* Class names merged with the item's base class
|
|
53
|
+
*/
|
|
54
|
+
className?: string;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Props for `MenuItem`: its own props plus every other prop of the button, link or component given in `as`, except
|
|
58
|
+
* those the menu pattern sets. When `as` may be either a link or a button, only props both accept are allowed.
|
|
59
|
+
*/
|
|
60
|
+
export type MenuItemProps<E extends MenuItemElement = "button"> = E extends MenuItemElement ? MenuItemPropsFor<E> : never;
|
|
61
|
+
type MenuItemPropsFor<E extends MenuItemElement> = MenuItemOwnProps & MenuItemElementOwnProps<E> & LinkOrButtonProps<E, "aria-disabled" | "dangerouslySetInnerHTML" | "disabled" | "role" | "tabIndex" | "type" | keyof MenuItemElementOwnProps<E> | keyof MenuItemOwnProps>;
|
|
62
|
+
/**
|
|
63
|
+
* One command in a `Menu`: a button by default, or a link with `as="a"` or a router's link component. Choosing it,
|
|
64
|
+
* with a click, Enter or Space, runs your `onClick`, or follows the link, and then closes every open menu, returning
|
|
65
|
+
* focus to the trigger; calling `preventDefault()` in a button's `onClick` keeps the menus open. A component given in
|
|
66
|
+
* `as` must pass the props it is given on to its anchor, or the item is neither styled nor reachable.
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* <MenuItem icon={<AddIcon />} onClick={duplicate} shortcut="⌘D" aria-keyshortcuts="Meta+D">
|
|
70
|
+
* Duplicate
|
|
71
|
+
* </MenuItem>
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* <MenuItem as="a" href="/settings">Settings</MenuItem>
|
|
75
|
+
*/
|
|
76
|
+
export declare function MenuItem<E extends MenuItemElement = "button">({ as, children, className, description, disabled, icon, shortcut, tone, ...rest }: MenuItemProps<E>): JSX.Element;
|
|
77
|
+
export {};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { Box as e } from "../Box/Box.js";
|
|
2
|
+
import t from "../MenuSurface/MenuSurface.module.js";
|
|
3
|
+
import { useMenuContext as n } from "./useMenuContext.js";
|
|
4
|
+
import { useMenuItemContent as r } from "./useMenuItemContent.js";
|
|
5
|
+
import { clsx as i } from "clsx";
|
|
6
|
+
import { jsx as a } from "react/jsx-runtime";
|
|
7
|
+
// src/components/Menu/MenuItem.tsx
|
|
8
|
+
function o({ as: e, children: a, className: o, description: c, disabled: l = !1, icon: u, shortcut: d, tone: f, ...p }) {
|
|
9
|
+
let m = n("MenuItem"), { "aria-describedby": h, href: g, onAuxClick: _, onClick: v, ...y } = p, b = r({
|
|
10
|
+
describedBy: h,
|
|
11
|
+
description: c,
|
|
12
|
+
label: a,
|
|
13
|
+
leading: u,
|
|
14
|
+
trailing: d
|
|
15
|
+
});
|
|
16
|
+
function x(e) {
|
|
17
|
+
l ? e.preventDefault() : (_?.(e), e.button === 1 && !e.defaultPrevented && e.currentTarget instanceof HTMLAnchorElement && m.closeAfterChoosing());
|
|
18
|
+
}
|
|
19
|
+
function S(e) {
|
|
20
|
+
l ? e.preventDefault() : (v?.(e), (!e.defaultPrevented || e.currentTarget instanceof HTMLAnchorElement) && m.closeAfterChoosing());
|
|
21
|
+
}
|
|
22
|
+
let C = g === void 0 || l && e === "a" ? {} : { href: g };
|
|
23
|
+
return s(e, {
|
|
24
|
+
...y,
|
|
25
|
+
...C,
|
|
26
|
+
"aria-describedby": b.describedBy,
|
|
27
|
+
"aria-disabled": l ? !0 : void 0,
|
|
28
|
+
"aria-labelledby": b.labelId,
|
|
29
|
+
children: b.content,
|
|
30
|
+
className: i(t.item, o),
|
|
31
|
+
"data-leading": b.hasLeading ? !0 : void 0,
|
|
32
|
+
"data-tone": f,
|
|
33
|
+
onAuxClick: x,
|
|
34
|
+
onClick: S,
|
|
35
|
+
role: "menuitem",
|
|
36
|
+
tabIndex: -1
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
function s(t, { children: n, ...r }) {
|
|
40
|
+
return t === void 0 || t === "button" ? /* @__PURE__ */ a(e, {
|
|
41
|
+
...r,
|
|
42
|
+
as: "button",
|
|
43
|
+
type: "button",
|
|
44
|
+
children: n
|
|
45
|
+
}) : t === "a" ? /* @__PURE__ */ a(e, {
|
|
46
|
+
...r,
|
|
47
|
+
as: "a",
|
|
48
|
+
children: n
|
|
49
|
+
}) : /* @__PURE__ */ a(t, {
|
|
50
|
+
...r,
|
|
51
|
+
children: n
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
export { o as MenuItem };
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { JSX, ReactNode } from "react";
|
|
2
|
+
import type { BoxProps } from "../Box";
|
|
3
|
+
/**
|
|
4
|
+
* Props for `MenuItemCheckbox`: its own props plus every native button prop except those the menu pattern sets and the
|
|
5
|
+
* name its label gives it
|
|
6
|
+
*/
|
|
7
|
+
export interface MenuItemCheckboxProps extends Omit<BoxProps<"button">, "aria-checked" | "aria-disabled" | "aria-label" | "aria-labelledby" | "as" | "children" | "dangerouslySetInnerHTML" | "defaultChecked" | "disabled" | "role" | "tabIndex" | "type"> {
|
|
8
|
+
/**
|
|
9
|
+
* Not accepted: the label names the item
|
|
10
|
+
*/
|
|
11
|
+
"aria-label"?: never;
|
|
12
|
+
/**
|
|
13
|
+
* Not accepted: the label names the item
|
|
14
|
+
*/
|
|
15
|
+
"aria-labelledby"?: never;
|
|
16
|
+
/**
|
|
17
|
+
* Controls whether the item is checked. Without it, the item holds its own state, starting from `defaultChecked`.
|
|
18
|
+
*/
|
|
19
|
+
checked?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* The label, which names the item
|
|
22
|
+
*/
|
|
23
|
+
children: ReactNode;
|
|
24
|
+
/**
|
|
25
|
+
* Whether an uncontrolled item starts checked. Defaults to `false`.
|
|
26
|
+
*/
|
|
27
|
+
defaultChecked?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* A line of muted text below the label, which describes the item
|
|
30
|
+
*/
|
|
31
|
+
description?: ReactNode;
|
|
32
|
+
/**
|
|
33
|
+
* Whether the item cannot be toggled. It stays reachable with the arrow keys, so its label and state are read, but
|
|
34
|
+
* clicks, Enter and Space do nothing. Defaults to `false`.
|
|
35
|
+
*/
|
|
36
|
+
disabled?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Not accepted: the check takes the icon's place
|
|
39
|
+
*/
|
|
40
|
+
icon?: never;
|
|
41
|
+
/**
|
|
42
|
+
* Called with the new state when the user toggles the item
|
|
43
|
+
*/
|
|
44
|
+
onCheckedChange?: (checked: boolean) => void;
|
|
45
|
+
/**
|
|
46
|
+
* A keyboard shortcut shown after the label, such as "⇧⌘H". It is hidden from assistive technology: announce it with
|
|
47
|
+
* `aria-keyshortcuts`. The menu does not bind it.
|
|
48
|
+
*/
|
|
49
|
+
shortcut?: string;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* An option in a `Menu` that is on or off, shown by a check before its label. A click or Enter toggles it and closes
|
|
53
|
+
* every open menu; Space toggles it and leaves them open, so several can be set at once. Your `onClick` runs first, and
|
|
54
|
+
* calling `preventDefault()` in it keeps the menus open.
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* <MenuItemCheckbox checked={showArchived} onCheckedChange={setShowArchived}>
|
|
58
|
+
* Show archived
|
|
59
|
+
* </MenuItemCheckbox>
|
|
60
|
+
*/
|
|
61
|
+
export declare function MenuItemCheckbox({ checked, children, className, defaultChecked, description, disabled, onCheckedChange, onClick, shortcut, "aria-describedby": describedBy, ...rest }: MenuItemCheckboxProps): JSX.Element;
|