@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
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { JSX, ReactNode } from "react";
|
|
2
|
+
import type { ControlSize } from "../../forms";
|
|
3
|
+
import type { BoxProps } from "../Box";
|
|
4
|
+
import type { ComboboxPlacement } from "./ComboboxPopup";
|
|
5
|
+
interface ComboboxOwnProps {
|
|
6
|
+
/**
|
|
7
|
+
* The `ComboboxOption`s
|
|
8
|
+
*/
|
|
9
|
+
children?: ReactNode;
|
|
10
|
+
/**
|
|
11
|
+
* The option selected at first, which leaves the combobox uncontrolled. Defaults to none.
|
|
12
|
+
*/
|
|
13
|
+
defaultValue?: string | null;
|
|
14
|
+
/**
|
|
15
|
+
* Adds a hidden input that submits the selected value with a form under this name
|
|
16
|
+
*/
|
|
17
|
+
name?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Called with the value of the option the user commits
|
|
20
|
+
*/
|
|
21
|
+
onValueChange?: (value: string) => void;
|
|
22
|
+
/**
|
|
23
|
+
* Shown in the field while no option is selected
|
|
24
|
+
*/
|
|
25
|
+
placeholder?: ReactNode;
|
|
26
|
+
/**
|
|
27
|
+
* Where the list opens. It flips to the other side when there is no room. Defaults to `bottom-start`.
|
|
28
|
+
*/
|
|
29
|
+
placement?: ComboboxPlacement;
|
|
30
|
+
/**
|
|
31
|
+
* Height of the field, matching the `Button` sizes. Defaults to `md`.
|
|
32
|
+
*/
|
|
33
|
+
size?: ControlSize;
|
|
34
|
+
/**
|
|
35
|
+
* The selected option, or null for none, which makes the combobox controlled: update it from `onValueChange`
|
|
36
|
+
*/
|
|
37
|
+
value?: string | null;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Props for `Combobox`: its own props plus every `button` prop except those the combobox pattern sets
|
|
41
|
+
*/
|
|
42
|
+
export interface ComboboxProps extends ComboboxOwnProps, Omit<BoxProps<"button">, "aria-activedescendant" | "aria-autocomplete" | "aria-controls" | "aria-expanded" | "aria-haspopup" | "as" | "defaultValue" | "role" | "type" | "value" | keyof ComboboxOwnProps> {
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* A field that opens a list of options to choose one from, following the WAI-ARIA select-only combobox pattern, for
|
|
46
|
+
* options a native `Select` cannot show, such as people with avatars. The field shows the selected option. Down Arrow,
|
|
47
|
+
* Enter, Space or a click opens the list; the arrow keys, Home, End and type-ahead move through it; Enter, Space or a
|
|
48
|
+
* click chooses an option; Escape and Tab close it without choosing. Focus stays on the field. Inside a `Field` it takes
|
|
49
|
+
* its label, description, error, and required and disabled state from the field; outside one, give it an `aria-label`.
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* <Field label="Assignee">
|
|
53
|
+
* <Combobox onValueChange={setAssignee} placeholder="Unassigned" value={assignee}>
|
|
54
|
+
* <ComboboxOption leading={<Avatar name="Pat Lee" size="xs" />} value="pat">Pat Lee</ComboboxOption>
|
|
55
|
+
* </Combobox>
|
|
56
|
+
* </Field>
|
|
57
|
+
*/
|
|
58
|
+
export declare function Combobox({ children, className, defaultValue, name, onValueChange, placeholder, placement, size, value, ...rest }: ComboboxProps): JSX.Element;
|
|
59
|
+
export {};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { useFieldControl as e } from "../../forms/useFieldControl.js";
|
|
2
|
+
import { anchorNameFor as t } from "../../overlays/anchorNameFor.js";
|
|
3
|
+
import { mergeProps as n } from "../../overlays/mergeProps.js";
|
|
4
|
+
import { ChevronDownIcon as r } from "../Icon/ChevronDownIcon.js";
|
|
5
|
+
import { TextControl as i } from "../TextControl/TextControl.js";
|
|
6
|
+
import a from "./Combobox.module.js";
|
|
7
|
+
import { ComboboxFieldValue as o } from "./ComboboxFieldValue.js";
|
|
8
|
+
import { ComboboxPopup as s } from "./ComboboxPopup.js";
|
|
9
|
+
import { handleComboboxKey as c } from "./comboboxKeys.js";
|
|
10
|
+
import { useComboboxList as l } from "./useComboboxList.js";
|
|
11
|
+
import { useComboboxSelection as u } from "./useComboboxSelection.js";
|
|
12
|
+
import { clsx as d } from "clsx";
|
|
13
|
+
import { useState as f } from "react";
|
|
14
|
+
import { Fragment as p, jsx as m, jsxs as h } from "react/jsx-runtime";
|
|
15
|
+
// src/components/Combobox/Combobox.tsx
|
|
16
|
+
function g({ children: g, className: v, defaultValue: y = null, name: b, onValueChange: x, placeholder: S, placement: C = "bottom-start", size: w = "md", value: T, ...E }) {
|
|
17
|
+
let D = e(E), [O, k] = f(null), A = u({
|
|
18
|
+
defaultValue: y,
|
|
19
|
+
onValueChange: _(x),
|
|
20
|
+
value: T
|
|
21
|
+
}), j = l({
|
|
22
|
+
controlId: D.id,
|
|
23
|
+
filter: null,
|
|
24
|
+
query: "",
|
|
25
|
+
selection: A
|
|
26
|
+
}), M = { anchorName: t(j.listId) };
|
|
27
|
+
function N(e) {
|
|
28
|
+
!e.defaultPrevented && c(e, j) && e.preventDefault();
|
|
29
|
+
}
|
|
30
|
+
function P(e) {
|
|
31
|
+
e.key === " " && e.preventDefault();
|
|
32
|
+
}
|
|
33
|
+
function F(e) {
|
|
34
|
+
k(j.open);
|
|
35
|
+
}
|
|
36
|
+
function I(e) {
|
|
37
|
+
let t = e.detail > 0, n = t ? O ?? j.open : j.open;
|
|
38
|
+
k(null), e.defaultPrevented || (e.currentTarget.focus(), j.toggleList(n, t ? "pointer" : "keyboard"));
|
|
39
|
+
}
|
|
40
|
+
function L(e) {
|
|
41
|
+
j.close();
|
|
42
|
+
}
|
|
43
|
+
return /* @__PURE__ */ h(p, { children: [/* @__PURE__ */ h(i, {
|
|
44
|
+
...n(E, {
|
|
45
|
+
onBlur: L,
|
|
46
|
+
onClick: I,
|
|
47
|
+
onKeyDown: N,
|
|
48
|
+
onKeyUp: P,
|
|
49
|
+
onPointerDown: F,
|
|
50
|
+
style: M
|
|
51
|
+
}),
|
|
52
|
+
as: "button",
|
|
53
|
+
className: d(a.field, v),
|
|
54
|
+
id: j.controlId,
|
|
55
|
+
role: "combobox",
|
|
56
|
+
size: w,
|
|
57
|
+
type: "button",
|
|
58
|
+
"aria-activedescendant": j.activeDescendant,
|
|
59
|
+
"aria-controls": j.listId,
|
|
60
|
+
"aria-expanded": j.open,
|
|
61
|
+
"aria-haspopup": "listbox",
|
|
62
|
+
children: [/* @__PURE__ */ m(o, {
|
|
63
|
+
placeholder: S,
|
|
64
|
+
selected: j.selectedContent
|
|
65
|
+
}), /* @__PURE__ */ m(r, { className: a.chevron })]
|
|
66
|
+
}), /* @__PURE__ */ m(s, {
|
|
67
|
+
"aria-label": E["aria-label"],
|
|
68
|
+
"aria-labelledby": E["aria-labelledby"],
|
|
69
|
+
disabled: D.disabled,
|
|
70
|
+
form: E.form,
|
|
71
|
+
list: j,
|
|
72
|
+
name: b,
|
|
73
|
+
placement: C,
|
|
74
|
+
children: g
|
|
75
|
+
})] });
|
|
76
|
+
}
|
|
77
|
+
function _(e) {
|
|
78
|
+
return (t) => {
|
|
79
|
+
t !== null && e?.(t);
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
export { g as Combobox };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import './Combobox.css';// src/components/Combobox/Combobox.module.css
|
|
2
|
+
var e = "sui-field-BenH0", t = "sui-placeholder-NQX-b", n = "sui-fieldLabel-zBN6l", r = "sui-fieldLeading-4y-j7", i = "sui-chevron-NVqyn", a = "sui-inputFrame-mYx2Q", o = "sui-input--HTv1", s = "sui-popup-rsvuH", c = "sui-listbox-2wSrg", l = "sui-option-vhhn5", u = "sui-check-9yQbP", d = "sui-optionLeading-kXakJ", f = "sui-empty-Ahw5K", p = {
|
|
3
|
+
field: e,
|
|
4
|
+
placeholder: t,
|
|
5
|
+
fieldLabel: n,
|
|
6
|
+
fieldLeading: r,
|
|
7
|
+
chevron: i,
|
|
8
|
+
inputFrame: a,
|
|
9
|
+
input: o,
|
|
10
|
+
popup: s,
|
|
11
|
+
listbox: c,
|
|
12
|
+
option: l,
|
|
13
|
+
check: u,
|
|
14
|
+
optionLeading: d,
|
|
15
|
+
empty: f
|
|
16
|
+
};
|
|
17
|
+
export { u as check, i as chevron, p as default, f as empty, e as field, n as fieldLabel, r as fieldLeading, o as input, a as inputFrame, c as listbox, l as option, d as optionLeading, t as placeholder, s as popup };
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type { Dispatch, ReactNode, SetStateAction } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* What made an option active: a key, which shows the focus ring, or the pointer, which shows only the tint
|
|
4
|
+
*/
|
|
5
|
+
export type ActiveSource = "keyboard" | "pointer";
|
|
6
|
+
/**
|
|
7
|
+
* The option the keys act on, which `aria-activedescendant` names
|
|
8
|
+
*/
|
|
9
|
+
export interface ActiveOption {
|
|
10
|
+
/**
|
|
11
|
+
* What made it active
|
|
12
|
+
*/
|
|
13
|
+
source: ActiveSource;
|
|
14
|
+
/**
|
|
15
|
+
* Its value
|
|
16
|
+
*/
|
|
17
|
+
value: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* What the selected option shows in the field
|
|
21
|
+
*/
|
|
22
|
+
export interface SelectedContent {
|
|
23
|
+
/**
|
|
24
|
+
* The option's label
|
|
25
|
+
*/
|
|
26
|
+
label: ReactNode;
|
|
27
|
+
/**
|
|
28
|
+
* The option's leading content, such as an avatar
|
|
29
|
+
*/
|
|
30
|
+
leading: ReactNode;
|
|
31
|
+
/**
|
|
32
|
+
* The option's text, which an `Autocomplete`'s input shows
|
|
33
|
+
*/
|
|
34
|
+
text: string;
|
|
35
|
+
/**
|
|
36
|
+
* The option's value
|
|
37
|
+
*/
|
|
38
|
+
value: string;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Tests whether an option shows for the typed text
|
|
42
|
+
*/
|
|
43
|
+
export type ComboboxFilter = (textValue: string, inputValue: string) => boolean;
|
|
44
|
+
/**
|
|
45
|
+
* State a combobox shares with its options
|
|
46
|
+
*/
|
|
47
|
+
export interface ComboboxContextValue {
|
|
48
|
+
/**
|
|
49
|
+
* The option the keys act on, or null for none
|
|
50
|
+
*/
|
|
51
|
+
active: ActiveOption | null;
|
|
52
|
+
/**
|
|
53
|
+
* Makes an option active under the pointer
|
|
54
|
+
*/
|
|
55
|
+
activateFromPointer: (value: string) => void;
|
|
56
|
+
/**
|
|
57
|
+
* The generated id every option id starts with
|
|
58
|
+
*/
|
|
59
|
+
baseId: string;
|
|
60
|
+
/**
|
|
61
|
+
* Commits an option's value and closes the list
|
|
62
|
+
*/
|
|
63
|
+
commit: (value: string) => void;
|
|
64
|
+
/**
|
|
65
|
+
* Whether an option shows for the typed text, or null to show every option
|
|
66
|
+
*/
|
|
67
|
+
filter: ComboboxFilter | null;
|
|
68
|
+
/**
|
|
69
|
+
* The text the options are filtered by; empty shows every option
|
|
70
|
+
*/
|
|
71
|
+
query: string;
|
|
72
|
+
/**
|
|
73
|
+
* The selected option's value, or null for none
|
|
74
|
+
*/
|
|
75
|
+
selectedValue: string | null;
|
|
76
|
+
/**
|
|
77
|
+
* Sets the option the keys act on
|
|
78
|
+
*/
|
|
79
|
+
setActive: Dispatch<SetStateAction<ActiveOption | null>>;
|
|
80
|
+
/**
|
|
81
|
+
* Sets what the selected option shows in the field
|
|
82
|
+
*/
|
|
83
|
+
setSelectedContent: Dispatch<SetStateAction<SelectedContent | null>>;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Carries a `Combobox`'s or `Autocomplete`'s state to its options; null outside one
|
|
87
|
+
*/
|
|
88
|
+
export declare const ComboboxContext: import("react").Context<ComboboxContextValue | null>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { JSX, ReactNode } from "react";
|
|
2
|
+
import type { SelectedContent } from "./ComboboxContext";
|
|
3
|
+
interface ComboboxFieldValueProps {
|
|
4
|
+
/**
|
|
5
|
+
* Shown while no option is selected
|
|
6
|
+
*/
|
|
7
|
+
placeholder: ReactNode;
|
|
8
|
+
/**
|
|
9
|
+
* What the selected option shows, or null for none
|
|
10
|
+
*/
|
|
11
|
+
selected: SelectedContent | null;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* What a `Combobox`'s field shows: the selected option's leading content and label, or the placeholder
|
|
15
|
+
*/
|
|
16
|
+
export declare function ComboboxFieldValue({ placeholder, selected }: ComboboxFieldValueProps): JSX.Element;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { hasContent as e } from "../../forms/hasContent.js";
|
|
2
|
+
import { Box as t } from "../Box/Box.js";
|
|
3
|
+
import n from "./Combobox.module.js";
|
|
4
|
+
import { c as r } from "react/compiler-runtime";
|
|
5
|
+
import { Fragment as i, jsx as a, jsxs as o } from "react/jsx-runtime";
|
|
6
|
+
// src/components/Combobox/ComboboxFieldValue.tsx
|
|
7
|
+
function s(s) {
|
|
8
|
+
let c = r(9), { placeholder: l, selected: u } = s;
|
|
9
|
+
if (u === null) {
|
|
10
|
+
let e;
|
|
11
|
+
return c[0] === l ? e = c[1] : (e = /* @__PURE__ */ a(t, {
|
|
12
|
+
as: "span",
|
|
13
|
+
className: n.placeholder,
|
|
14
|
+
children: l
|
|
15
|
+
}), c[0] = l, c[1] = e), e;
|
|
16
|
+
}
|
|
17
|
+
let d;
|
|
18
|
+
c[2] === u.leading ? d = c[3] : (d = e(u.leading) && /* @__PURE__ */ a(t, {
|
|
19
|
+
as: "span",
|
|
20
|
+
className: n.fieldLeading,
|
|
21
|
+
"aria-hidden": !0,
|
|
22
|
+
children: u.leading
|
|
23
|
+
}), c[2] = u.leading, c[3] = d);
|
|
24
|
+
let f;
|
|
25
|
+
c[4] === u.label ? f = c[5] : (f = /* @__PURE__ */ a(t, {
|
|
26
|
+
as: "span",
|
|
27
|
+
className: n.fieldLabel,
|
|
28
|
+
children: u.label
|
|
29
|
+
}), c[4] = u.label, c[5] = f);
|
|
30
|
+
let p;
|
|
31
|
+
return c[6] !== d || c[7] !== f ? (p = /* @__PURE__ */ o(i, { children: [d, f] }), c[6] = d, c[7] = f, c[8] = p) : p = c[8], p;
|
|
32
|
+
}
|
|
33
|
+
export { s as ComboboxFieldValue };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { JSX, ReactNode } from "react";
|
|
2
|
+
import type { BoxProps } from "../Box";
|
|
3
|
+
/**
|
|
4
|
+
* Props for `ComboboxOption`: its own props plus every `div` prop except those the combobox pattern sets and the name
|
|
5
|
+
* its label gives it
|
|
6
|
+
*/
|
|
7
|
+
export interface ComboboxOptionProps extends Omit<BoxProps<"div">, "aria-disabled" | "aria-label" | "aria-labelledby" | "aria-selected" | "as" | "children" | "dangerouslySetInnerHTML" | "hidden" | "id" | "role" | "tabIndex"> {
|
|
8
|
+
/**
|
|
9
|
+
* Not accepted: the label names the option
|
|
10
|
+
*/
|
|
11
|
+
"aria-label"?: never;
|
|
12
|
+
/**
|
|
13
|
+
* Not accepted: the label names the option
|
|
14
|
+
*/
|
|
15
|
+
"aria-labelledby"?: never;
|
|
16
|
+
/**
|
|
17
|
+
* The label, which names the option
|
|
18
|
+
*/
|
|
19
|
+
children: ReactNode;
|
|
20
|
+
/**
|
|
21
|
+
* A line of muted text below the label, which describes the option
|
|
22
|
+
*/
|
|
23
|
+
description?: ReactNode;
|
|
24
|
+
/**
|
|
25
|
+
* Whether the option can be reached with the keys but not chosen. Defaults to `false`.
|
|
26
|
+
*/
|
|
27
|
+
disabled?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Content before the label, such as an `Avatar` or an icon, which a `Combobox` shows in its field too while the
|
|
30
|
+
* option is selected
|
|
31
|
+
*/
|
|
32
|
+
leading?: ReactNode;
|
|
33
|
+
/**
|
|
34
|
+
* The text filtering, type-ahead and an `Autocomplete`'s input use. Defaults to the label's text.
|
|
35
|
+
*/
|
|
36
|
+
textValue?: string;
|
|
37
|
+
/**
|
|
38
|
+
* The value this option stands for
|
|
39
|
+
*/
|
|
40
|
+
value: string;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* One option in a `Combobox` or `Autocomplete`. The selected option shows a check. To leave an option out, do not
|
|
44
|
+
* render it; an `Autocomplete` hides the options its filter rejects itself.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* <ComboboxOption description="Design" leading={<Avatar name="Pat Lee" size="xs" />} value="pat">
|
|
48
|
+
* Pat Lee
|
|
49
|
+
* </ComboboxOption>
|
|
50
|
+
*/
|
|
51
|
+
export declare function ComboboxOption({ "aria-describedby": describedBy, children, className, description, disabled, leading, onClick, onPointerMove, ref, textValue, value, ...rest }: ComboboxOptionProps): JSX.Element;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { optionId as e } from "../../collections/optionId.js";
|
|
2
|
+
import { hasContent as t } from "../../forms/hasContent.js";
|
|
3
|
+
import { Box as n } from "../Box/Box.js";
|
|
4
|
+
import r from "../MenuSurface/MenuSurface.module.js";
|
|
5
|
+
import i from "./Combobox.module.js";
|
|
6
|
+
import { ComboboxOptionContent as a } from "./ComboboxOptionContent.js";
|
|
7
|
+
import { useComboboxContext as o } from "./useComboboxContext.js";
|
|
8
|
+
import { useComboboxOption as s } from "./useComboboxOption.js";
|
|
9
|
+
import { clsx as c } from "clsx";
|
|
10
|
+
import { useId as l, useRef as u } from "react";
|
|
11
|
+
import { jsx as d } from "react/jsx-runtime";
|
|
12
|
+
// src/components/Combobox/ComboboxOption.tsx
|
|
13
|
+
function f({ "aria-describedby": f, children: h, className: g, description: _, disabled: v = !1, leading: y, onClick: b, onPointerMove: x, ref: S, textValue: C, value: w, ...T }) {
|
|
14
|
+
let E = o("ComboboxOption"), D = u(null), O = l(), k = l(), A = E.active?.value === w ? E.active.source : void 0, j = E.selectedValue === w, M = p(t(_) ? k : void 0, f);
|
|
15
|
+
s({
|
|
16
|
+
children: h,
|
|
17
|
+
leading: y,
|
|
18
|
+
optionRef: D,
|
|
19
|
+
selected: j,
|
|
20
|
+
textValue: C,
|
|
21
|
+
value: w
|
|
22
|
+
});
|
|
23
|
+
function N(e) {
|
|
24
|
+
D.current = e;
|
|
25
|
+
let t = m(S, e);
|
|
26
|
+
return () => {
|
|
27
|
+
D.current = null, t();
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function P(e) {
|
|
31
|
+
b?.(e), !e.defaultPrevented && !v && E.commit(w);
|
|
32
|
+
}
|
|
33
|
+
function F(e) {
|
|
34
|
+
x?.(e), e.pointerType !== "touch" && E.active?.value !== w && E.activateFromPointer(w);
|
|
35
|
+
}
|
|
36
|
+
return /* @__PURE__ */ d(n, {
|
|
37
|
+
...T,
|
|
38
|
+
className: c(r.item, i.option, g),
|
|
39
|
+
id: e(E.baseId, w),
|
|
40
|
+
onClick: P,
|
|
41
|
+
onPointerMove: F,
|
|
42
|
+
ref: N,
|
|
43
|
+
role: "option",
|
|
44
|
+
"aria-describedby": M,
|
|
45
|
+
"aria-disabled": v ? !0 : void 0,
|
|
46
|
+
"aria-labelledby": O,
|
|
47
|
+
"aria-selected": j,
|
|
48
|
+
"data-active": A,
|
|
49
|
+
"data-text-value": C,
|
|
50
|
+
"data-value": w,
|
|
51
|
+
children: /* @__PURE__ */ d(a, {
|
|
52
|
+
description: _,
|
|
53
|
+
descriptionId: k,
|
|
54
|
+
labelId: O,
|
|
55
|
+
leading: y,
|
|
56
|
+
selected: j,
|
|
57
|
+
children: h
|
|
58
|
+
})
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
function p(...e) {
|
|
62
|
+
let t = e.filter(Boolean).join(" ");
|
|
63
|
+
return t === "" ? void 0 : t;
|
|
64
|
+
}
|
|
65
|
+
function m(e, t) {
|
|
66
|
+
if (typeof e == "function") {
|
|
67
|
+
let n = e(t);
|
|
68
|
+
return typeof n == "function" ? n : () => e(null);
|
|
69
|
+
}
|
|
70
|
+
return e == null ? () => {} : (e.current = t, () => {
|
|
71
|
+
e.current = null;
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
export { f as ComboboxOption };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { JSX, ReactNode } from "react";
|
|
2
|
+
interface ComboboxOptionContentProps {
|
|
3
|
+
/**
|
|
4
|
+
* The label
|
|
5
|
+
*/
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
/**
|
|
8
|
+
* A line of muted text below the label
|
|
9
|
+
*/
|
|
10
|
+
description: ReactNode;
|
|
11
|
+
/**
|
|
12
|
+
* The id of the description, which describes the option
|
|
13
|
+
*/
|
|
14
|
+
descriptionId: string;
|
|
15
|
+
/**
|
|
16
|
+
* The id of the label, which names the option
|
|
17
|
+
*/
|
|
18
|
+
labelId: string;
|
|
19
|
+
/**
|
|
20
|
+
* Content before the label
|
|
21
|
+
*/
|
|
22
|
+
leading: ReactNode;
|
|
23
|
+
/**
|
|
24
|
+
* Whether the option is selected, which shows a check
|
|
25
|
+
*/
|
|
26
|
+
selected: boolean;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* A combobox option's row: the check of a selected option, then its leading content, label and description
|
|
30
|
+
*/
|
|
31
|
+
export declare function ComboboxOptionContent({ children, description, descriptionId, labelId, leading, selected, }: ComboboxOptionContentProps): JSX.Element;
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { hasContent as e } from "../../forms/hasContent.js";
|
|
2
|
+
import { Box as t } from "../Box/Box.js";
|
|
3
|
+
import { CheckIcon as n } from "../Icon/CheckIcon.js";
|
|
4
|
+
import r from "../MenuSurface/MenuSurface.module.js";
|
|
5
|
+
import i from "./Combobox.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/Combobox/ComboboxOptionContent.tsx
|
|
9
|
+
function l(l) {
|
|
10
|
+
let u = a(17), { children: d, description: f, descriptionId: p, labelId: m, leading: h, selected: g } = l, _;
|
|
11
|
+
u[0] === g ? _ = u[1] : (_ = g && /* @__PURE__ */ s(t, {
|
|
12
|
+
as: "span",
|
|
13
|
+
className: `${r.leading} ${i.check}`,
|
|
14
|
+
"aria-hidden": !0,
|
|
15
|
+
children: /* @__PURE__ */ s(n, {})
|
|
16
|
+
}), u[0] = g, u[1] = _);
|
|
17
|
+
let v;
|
|
18
|
+
u[2] === h ? v = u[3] : (v = e(h) && /* @__PURE__ */ s(t, {
|
|
19
|
+
as: "span",
|
|
20
|
+
className: i.optionLeading,
|
|
21
|
+
"aria-hidden": !0,
|
|
22
|
+
children: h
|
|
23
|
+
}), u[2] = h, u[3] = v);
|
|
24
|
+
let y;
|
|
25
|
+
u[4] !== d || u[5] !== m ? (y = /* @__PURE__ */ s(t, {
|
|
26
|
+
as: "span",
|
|
27
|
+
className: r.label,
|
|
28
|
+
id: m,
|
|
29
|
+
children: d
|
|
30
|
+
}), u[4] = d, u[5] = m, u[6] = y) : y = u[6];
|
|
31
|
+
let b;
|
|
32
|
+
u[7] !== f || u[8] !== p ? (b = e(f) && /* @__PURE__ */ s(t, {
|
|
33
|
+
as: "span",
|
|
34
|
+
className: r.description,
|
|
35
|
+
id: p,
|
|
36
|
+
children: f
|
|
37
|
+
}), u[7] = f, u[8] = p, u[9] = b) : b = u[9];
|
|
38
|
+
let x;
|
|
39
|
+
u[10] !== y || u[11] !== b ? (x = /* @__PURE__ */ c(t, {
|
|
40
|
+
as: "span",
|
|
41
|
+
className: r.text,
|
|
42
|
+
children: [y, b]
|
|
43
|
+
}), u[10] = y, u[11] = b, u[12] = x) : x = u[12];
|
|
44
|
+
let S;
|
|
45
|
+
return u[13] !== _ || u[14] !== v || u[15] !== x ? (S = /* @__PURE__ */ c(o, { children: [
|
|
46
|
+
_,
|
|
47
|
+
v,
|
|
48
|
+
x
|
|
49
|
+
] }), u[13] = _, u[14] = v, u[15] = x, u[16] = S) : S = u[16], S;
|
|
50
|
+
}
|
|
51
|
+
export { l as ComboboxOptionContent };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { JSX, ReactNode } from "react";
|
|
2
|
+
import type { ComboboxList } from "./useComboboxList";
|
|
3
|
+
/**
|
|
4
|
+
* Where a combobox's list opens, flipping to the other side when there is no room
|
|
5
|
+
*/
|
|
6
|
+
export type ComboboxPlacement = "bottom-start" | "top-start";
|
|
7
|
+
interface ComboboxPopupProps {
|
|
8
|
+
/**
|
|
9
|
+
* The control's `aria-label`, which names the list outside a `Field`
|
|
10
|
+
*/
|
|
11
|
+
"aria-label": string | undefined;
|
|
12
|
+
/**
|
|
13
|
+
* The control's `aria-labelledby`, which names the list outside a `Field`
|
|
14
|
+
*/
|
|
15
|
+
"aria-labelledby": string | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* The options
|
|
18
|
+
*/
|
|
19
|
+
children: ReactNode;
|
|
20
|
+
/**
|
|
21
|
+
* Whether the control is disabled, which leaves its value out of the form
|
|
22
|
+
*/
|
|
23
|
+
disabled: boolean | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* The line shown in place of the options while none shows; without one, an empty list shows nothing
|
|
26
|
+
*/
|
|
27
|
+
emptyMessage?: string;
|
|
28
|
+
/**
|
|
29
|
+
* The id of the form the value submits with, when not the one around the control
|
|
30
|
+
*/
|
|
31
|
+
form: string | undefined;
|
|
32
|
+
/**
|
|
33
|
+
* The list's state
|
|
34
|
+
*/
|
|
35
|
+
list: ComboboxList;
|
|
36
|
+
/**
|
|
37
|
+
* The name the selected value submits under with a form; without one, nothing is submitted
|
|
38
|
+
*/
|
|
39
|
+
name: string | undefined;
|
|
40
|
+
/**
|
|
41
|
+
* Where the list opens
|
|
42
|
+
*/
|
|
43
|
+
placement: ComboboxPlacement;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* A combobox's list, an overlay on the menu surface holding the `listbox` and its options named by the surrounding
|
|
47
|
+
* `Field`'s label or else as the control is, followed by the hidden input that submits the value when it has a name
|
|
48
|
+
*/
|
|
49
|
+
export declare function ComboboxPopup({ "aria-label": label, "aria-labelledby": labelledBy, children, disabled, emptyMessage, form, list, name, placement, }: ComboboxPopupProps): JSX.Element;
|
|
50
|
+
export {};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { FieldContext as e } from "../../forms/FieldContext.js";
|
|
2
|
+
import { anchorNameFor as t } from "../../overlays/anchorNameFor.js";
|
|
3
|
+
import { Box as n } from "../Box/Box.js";
|
|
4
|
+
import r from "../MenuSurface/MenuSurface.module.js";
|
|
5
|
+
import { Overlay as i } from "../Overlay/Overlay.js";
|
|
6
|
+
import a from "./Combobox.module.js";
|
|
7
|
+
import { ComboboxContext as o } from "./ComboboxContext.js";
|
|
8
|
+
import { useContext as s } from "react";
|
|
9
|
+
import { c } from "react/compiler-runtime";
|
|
10
|
+
import { jsx as l, jsxs as u } from "react/jsx-runtime";
|
|
11
|
+
// src/components/Combobox/ComboboxPopup.tsx
|
|
12
|
+
function d(d) {
|
|
13
|
+
let f = c(26), { "aria-label": p, "aria-labelledby": m, children: h, disabled: g, emptyMessage: _, form: v, list: y, name: b, placement: x } = d, { attachList: S, context: C, listId: w, open: T, selectedValue: E } = y, D = s(e)?.labelId, O;
|
|
14
|
+
f[0] === Symbol.for("react.memo_cache_sentinel") ? (O = function(e) {
|
|
15
|
+
e.preventDefault();
|
|
16
|
+
}, f[0] = O) : O = f[0];
|
|
17
|
+
let k = O, A;
|
|
18
|
+
f[1] === w ? A = f[2] : (A = t(w), f[1] = w, f[2] = A);
|
|
19
|
+
let j = D === void 0 ? p : void 0, M = D ?? m, N;
|
|
20
|
+
f[3] !== S || f[4] !== h || f[5] !== w || f[6] !== j || f[7] !== M ? (N = /* @__PURE__ */ l(n, {
|
|
21
|
+
className: a.listbox,
|
|
22
|
+
id: w,
|
|
23
|
+
ref: S,
|
|
24
|
+
role: "listbox",
|
|
25
|
+
"aria-label": j,
|
|
26
|
+
"aria-labelledby": M,
|
|
27
|
+
children: h
|
|
28
|
+
}), f[3] = S, f[4] = h, f[5] = w, f[6] = j, f[7] = M, f[8] = N) : N = f[8];
|
|
29
|
+
let P;
|
|
30
|
+
f[9] === _ ? P = f[10] : (P = _ !== void 0 && /* @__PURE__ */ l(n, {
|
|
31
|
+
className: a.empty,
|
|
32
|
+
children: _
|
|
33
|
+
}), f[9] = _, f[10] = P);
|
|
34
|
+
let F;
|
|
35
|
+
f[11] !== T || f[12] !== x || f[13] !== A || f[14] !== N || f[15] !== P ? (F = /* @__PURE__ */ u(i, {
|
|
36
|
+
anchorName: A,
|
|
37
|
+
as: "div",
|
|
38
|
+
className: `${r.menu} ${a.popup}`,
|
|
39
|
+
onMouseDown: k,
|
|
40
|
+
open: T,
|
|
41
|
+
placement: x,
|
|
42
|
+
popover: "manual",
|
|
43
|
+
children: [N, P]
|
|
44
|
+
}), f[11] = T, f[12] = x, f[13] = A, f[14] = N, f[15] = P, f[16] = F) : F = f[16];
|
|
45
|
+
let I;
|
|
46
|
+
f[17] !== g || f[18] !== v || f[19] !== b || f[20] !== E ? (I = b !== void 0 && /* @__PURE__ */ l("input", {
|
|
47
|
+
disabled: g,
|
|
48
|
+
form: v,
|
|
49
|
+
name: b,
|
|
50
|
+
type: "hidden",
|
|
51
|
+
value: E ?? ""
|
|
52
|
+
}), f[17] = g, f[18] = v, f[19] = b, f[20] = E, f[21] = I) : I = f[21];
|
|
53
|
+
let L;
|
|
54
|
+
return f[22] !== C || f[23] !== F || f[24] !== I ? (L = /* @__PURE__ */ u(o.Provider, {
|
|
55
|
+
value: C,
|
|
56
|
+
children: [F, I]
|
|
57
|
+
}), f[22] = C, f[23] = F, f[24] = I, f[25] = L) : L = f[25], L;
|
|
58
|
+
}
|
|
59
|
+
export { d as ComboboxPopup };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { KeyboardEvent } from "react";
|
|
2
|
+
import type { ComboboxList } from "./useComboboxList";
|
|
3
|
+
/**
|
|
4
|
+
* The input's text, which Enter and Escape read and Escape clears
|
|
5
|
+
*/
|
|
6
|
+
interface InputText {
|
|
7
|
+
/**
|
|
8
|
+
* Puts text in the input
|
|
9
|
+
*/
|
|
10
|
+
commit: (text: string) => void;
|
|
11
|
+
/**
|
|
12
|
+
* Whether the input holds text typed since the last choice
|
|
13
|
+
*/
|
|
14
|
+
editing: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* The text the input shows
|
|
17
|
+
*/
|
|
18
|
+
shown: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Acts on a key pressed in an `Autocomplete`'s input, leaving typing, the caret keys, keys that compose text in an input
|
|
22
|
+
* method, and Enter with no active option and no unchosen text, to the input
|
|
23
|
+
*
|
|
24
|
+
* @param event the key event
|
|
25
|
+
* @param list the autocomplete's list
|
|
26
|
+
* @param text the input's text: Enter does not submit text typed since the last choice, and Escape on the closed input
|
|
27
|
+
* clears it with the selection
|
|
28
|
+
* @returns whether the key was handled, so its default should be prevented
|
|
29
|
+
*/
|
|
30
|
+
export declare function handleAutocompleteKey(event: KeyboardEvent<HTMLElement>, list: ComboboxList, text: InputText): boolean;
|
|
31
|
+
export {};
|