@mortenbrudvik/waveui 0.4.0 → 0.7.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 +1221 -173
- package/dist/_virtual/_rolldown/runtime.cjs +1 -0
- package/dist/components/button/Button.cjs +2 -0
- package/dist/components/button/Button.cjs.map +1 -0
- package/dist/components/button/Button.mjs +50 -0
- package/dist/components/button/Button.mjs.map +1 -0
- package/dist/components/button/Button.semantics.cjs +2 -0
- package/dist/components/button/Button.semantics.cjs.map +1 -0
- package/dist/components/button/Button.semantics.mjs +61 -0
- package/dist/components/button/Button.semantics.mjs.map +1 -0
- package/dist/components/button/Button.slots.cjs +2 -0
- package/dist/components/button/Button.slots.cjs.map +1 -0
- package/dist/components/button/Button.slots.mjs +47 -0
- package/dist/components/button/Button.slots.mjs.map +1 -0
- package/dist/components/button/CompoundButton.cjs +2 -0
- package/dist/components/button/CompoundButton.cjs.map +1 -0
- package/dist/components/button/CompoundButton.mjs +53 -0
- package/dist/components/button/CompoundButton.mjs.map +1 -0
- package/dist/components/button/Link.cjs +2 -0
- package/dist/components/button/Link.cjs.map +1 -0
- package/dist/components/button/Link.mjs +37 -0
- package/dist/components/button/Link.mjs.map +1 -0
- package/dist/components/button/MenuButton.cjs +2 -0
- package/dist/components/button/MenuButton.cjs.map +1 -0
- package/dist/components/button/MenuButton.mjs +45 -0
- package/dist/components/button/MenuButton.mjs.map +1 -0
- package/dist/components/button/SplitButton.cjs +2 -0
- package/dist/components/button/SplitButton.cjs.map +1 -0
- package/dist/components/button/SplitButton.mjs +66 -0
- package/dist/components/button/SplitButton.mjs.map +1 -0
- package/dist/components/button/ToggleButton.cjs +2 -0
- package/dist/components/button/ToggleButton.cjs.map +1 -0
- package/dist/components/button/ToggleButton.mjs +65 -0
- package/dist/components/button/ToggleButton.mjs.map +1 -0
- package/dist/components/button/Toolbar.cjs +2 -0
- package/dist/components/button/Toolbar.cjs.map +1 -0
- package/dist/components/button/Toolbar.context.cjs +2 -0
- package/dist/components/button/Toolbar.context.cjs.map +1 -0
- package/dist/components/button/Toolbar.context.mjs +31 -0
- package/dist/components/button/Toolbar.context.mjs.map +1 -0
- package/dist/components/button/Toolbar.mjs +63 -0
- package/dist/components/button/Toolbar.mjs.map +1 -0
- package/dist/components/button/Toolbar.parts.cjs +2 -0
- package/dist/components/button/Toolbar.parts.cjs.map +1 -0
- package/dist/components/button/Toolbar.parts.mjs +131 -0
- package/dist/components/button/Toolbar.parts.mjs.map +1 -0
- package/dist/components/button/buttonStyles.cjs +2 -0
- package/dist/components/button/buttonStyles.cjs.map +1 -0
- package/dist/components/button/buttonStyles.mjs +39 -0
- package/dist/components/button/buttonStyles.mjs.map +1 -0
- package/dist/components/data-display/Avatar.cjs +2 -0
- package/dist/components/data-display/Avatar.cjs.map +1 -0
- package/dist/components/data-display/Avatar.mjs +157 -0
- package/dist/components/data-display/Avatar.mjs.map +1 -0
- package/dist/components/data-display/AvatarGroup.cjs +2 -0
- package/dist/components/data-display/AvatarGroup.cjs.map +1 -0
- package/dist/components/data-display/AvatarGroup.mjs +134 -0
- package/dist/components/data-display/AvatarGroup.mjs.map +1 -0
- package/dist/components/data-display/Badge.cjs +2 -0
- package/dist/components/data-display/Badge.cjs.map +1 -0
- package/dist/components/data-display/Badge.colors.cjs +2 -0
- package/dist/components/data-display/Badge.colors.cjs.map +1 -0
- package/dist/components/data-display/Badge.colors.mjs +58 -0
- package/dist/components/data-display/Badge.colors.mjs.map +1 -0
- package/dist/components/data-display/Badge.mjs +32 -0
- package/dist/components/data-display/Badge.mjs.map +1 -0
- package/dist/components/data-display/CounterBadge.cjs +2 -0
- package/dist/components/data-display/CounterBadge.cjs.map +1 -0
- package/dist/components/data-display/CounterBadge.mjs +28 -0
- package/dist/components/data-display/CounterBadge.mjs.map +1 -0
- package/dist/components/data-display/Divider.cjs +2 -0
- package/dist/components/data-display/Divider.cjs.map +1 -0
- package/dist/components/data-display/Divider.mjs +52 -0
- package/dist/components/data-display/Divider.mjs.map +1 -0
- package/dist/components/data-display/Image.cjs +2 -0
- package/dist/components/data-display/Image.cjs.map +1 -0
- package/dist/components/data-display/Image.mjs +32 -0
- package/dist/components/data-display/Image.mjs.map +1 -0
- package/dist/components/data-display/InfoLabel.cjs +2 -0
- package/dist/components/data-display/InfoLabel.cjs.map +1 -0
- package/dist/components/data-display/InfoLabel.mjs +104 -0
- package/dist/components/data-display/InfoLabel.mjs.map +1 -0
- package/dist/components/data-display/List.cjs +2 -0
- package/dist/components/data-display/List.cjs.map +1 -0
- package/dist/components/data-display/List.mjs +381 -0
- package/dist/components/data-display/List.mjs.map +1 -0
- package/dist/components/data-display/List.registry.cjs +2 -0
- package/dist/components/data-display/List.registry.cjs.map +1 -0
- package/dist/components/data-display/List.registry.mjs +101 -0
- package/dist/components/data-display/List.registry.mjs.map +1 -0
- package/dist/components/data-display/Persona.cjs +2 -0
- package/dist/components/data-display/Persona.cjs.map +1 -0
- package/dist/components/data-display/Persona.mjs +48 -0
- package/dist/components/data-display/Persona.mjs.map +1 -0
- package/dist/components/data-display/PresenceBadge.cjs +2 -0
- package/dist/components/data-display/PresenceBadge.cjs.map +1 -0
- package/dist/components/data-display/PresenceBadge.mjs +71 -0
- package/dist/components/data-display/PresenceBadge.mjs.map +1 -0
- package/dist/components/data-display/Tag.cjs +2 -0
- package/dist/components/data-display/Tag.cjs.map +1 -0
- package/dist/components/data-display/Tag.mjs +147 -0
- package/dist/components/data-display/Tag.mjs.map +1 -0
- package/dist/components/feedback/MessageBar.cjs +2 -0
- package/dist/components/feedback/MessageBar.cjs.map +1 -0
- package/dist/components/feedback/MessageBar.mjs +144 -0
- package/dist/components/feedback/MessageBar.mjs.map +1 -0
- package/dist/components/feedback/MessageBar.status.cjs +2 -0
- package/dist/components/feedback/MessageBar.status.cjs.map +1 -0
- package/dist/components/feedback/MessageBar.status.mjs +45 -0
- package/dist/components/feedback/MessageBar.status.mjs.map +1 -0
- package/dist/components/feedback/ProgressBar.cjs +2 -0
- package/dist/components/feedback/ProgressBar.cjs.map +1 -0
- package/dist/components/feedback/ProgressBar.mjs +72 -0
- package/dist/components/feedback/ProgressBar.mjs.map +1 -0
- package/dist/components/feedback/Skeleton.cjs +2 -0
- package/dist/components/feedback/Skeleton.cjs.map +1 -0
- package/dist/components/feedback/Skeleton.mjs +47 -0
- package/dist/components/feedback/Skeleton.mjs.map +1 -0
- package/dist/components/feedback/Spinner.cjs +2 -0
- package/dist/components/feedback/Spinner.cjs.map +1 -0
- package/dist/components/feedback/Spinner.mjs +60 -0
- package/dist/components/feedback/Spinner.mjs.map +1 -0
- package/dist/components/feedback/Toast.cjs +2 -0
- package/dist/components/feedback/Toast.cjs.map +1 -0
- package/dist/components/feedback/Toast.mjs +347 -0
- package/dist/components/feedback/Toast.mjs.map +1 -0
- package/dist/components/input/Checkbox.cjs +2 -0
- package/dist/components/input/Checkbox.cjs.map +1 -0
- package/dist/components/input/Checkbox.mjs +96 -0
- package/dist/components/input/Checkbox.mjs.map +1 -0
- package/dist/components/input/ColorPicker.cjs +6 -0
- package/dist/components/input/ColorPicker.cjs.map +1 -0
- package/dist/components/input/ColorPicker.mjs +236 -0
- package/dist/components/input/ColorPicker.mjs.map +1 -0
- package/dist/components/input/Combobox.cjs +2 -0
- package/dist/components/input/Combobox.cjs.map +1 -0
- package/dist/components/input/Combobox.expand.cjs +2 -0
- package/dist/components/input/Combobox.expand.cjs.map +1 -0
- package/dist/components/input/Combobox.expand.mjs +38 -0
- package/dist/components/input/Combobox.expand.mjs.map +1 -0
- package/dist/components/input/Combobox.mjs +187 -0
- package/dist/components/input/Combobox.mjs.map +1 -0
- package/dist/components/input/DatePicker.cjs +2 -0
- package/dist/components/input/DatePicker.cjs.map +1 -0
- package/dist/components/input/DatePicker.mjs +340 -0
- package/dist/components/input/DatePicker.mjs.map +1 -0
- package/dist/components/input/Dropdown.cjs +2 -0
- package/dist/components/input/Dropdown.cjs.map +1 -0
- package/dist/components/input/Dropdown.mjs +128 -0
- package/dist/components/input/Dropdown.mjs.map +1 -0
- package/dist/components/input/Field.cjs +2 -0
- package/dist/components/input/Field.cjs.map +1 -0
- package/dist/components/input/Field.mjs +200 -0
- package/dist/components/input/Field.mjs.map +1 -0
- package/dist/components/input/Input.cjs +2 -0
- package/dist/components/input/Input.cjs.map +1 -0
- package/dist/components/input/Input.mjs +81 -0
- package/dist/components/input/Input.mjs.map +1 -0
- package/dist/components/input/Label.cjs +2 -0
- package/dist/components/input/Label.cjs.map +1 -0
- package/dist/components/input/Label.mjs +28 -0
- package/dist/components/input/Label.mjs.map +1 -0
- package/dist/components/input/Option.cjs +2 -0
- package/dist/components/input/Option.cjs.map +1 -0
- package/dist/components/input/Option.mjs +169 -0
- package/dist/components/input/Option.mjs.map +1 -0
- package/dist/components/input/RadioGroup.cjs +2 -0
- package/dist/components/input/RadioGroup.cjs.map +1 -0
- package/dist/components/input/RadioGroup.mjs +139 -0
- package/dist/components/input/RadioGroup.mjs.map +1 -0
- package/dist/components/input/Rating.cjs +2 -0
- package/dist/components/input/Rating.cjs.map +1 -0
- package/dist/components/input/Rating.mjs +196 -0
- package/dist/components/input/Rating.mjs.map +1 -0
- package/dist/components/input/SearchBox.cjs +2 -0
- package/dist/components/input/SearchBox.cjs.map +1 -0
- package/dist/components/input/SearchBox.mjs +205 -0
- package/dist/components/input/SearchBox.mjs.map +1 -0
- package/dist/components/input/Select.cjs +2 -0
- package/dist/components/input/Select.cjs.map +1 -0
- package/dist/components/input/Select.mjs +33 -0
- package/dist/components/input/Select.mjs.map +1 -0
- package/dist/components/input/Slider.cjs +2 -0
- package/dist/components/input/Slider.cjs.map +1 -0
- package/dist/components/input/Slider.mjs +79 -0
- package/dist/components/input/Slider.mjs.map +1 -0
- package/dist/components/input/SpinButton.cjs +2 -0
- package/dist/components/input/SpinButton.cjs.map +1 -0
- package/dist/components/input/SpinButton.mjs +157 -0
- package/dist/components/input/SpinButton.mjs.map +1 -0
- package/dist/components/input/SwatchPicker.cjs +2 -0
- package/dist/components/input/SwatchPicker.cjs.map +1 -0
- package/dist/components/input/SwatchPicker.mjs +113 -0
- package/dist/components/input/SwatchPicker.mjs.map +1 -0
- package/dist/components/input/Switch.cjs +2 -0
- package/dist/components/input/Switch.cjs.map +1 -0
- package/dist/components/input/Switch.mjs +92 -0
- package/dist/components/input/Switch.mjs.map +1 -0
- package/dist/components/input/TagPicker.cjs +2 -0
- package/dist/components/input/TagPicker.cjs.map +1 -0
- package/dist/components/input/TagPicker.mjs +249 -0
- package/dist/components/input/TagPicker.mjs.map +1 -0
- package/dist/components/input/Textarea.cjs +2 -0
- package/dist/components/input/Textarea.cjs.map +1 -0
- package/dist/components/input/Textarea.mjs +32 -0
- package/dist/components/input/Textarea.mjs.map +1 -0
- package/dist/components/input/TimePicker.cjs +2 -0
- package/dist/components/input/TimePicker.cjs.map +1 -0
- package/dist/components/input/TimePicker.mjs +292 -0
- package/dist/components/input/TimePicker.mjs.map +1 -0
- package/dist/components/input/colorUtils.cjs +2 -0
- package/dist/components/input/colorUtils.cjs.map +1 -0
- package/dist/components/input/colorUtils.mjs +96 -0
- package/dist/components/input/colorUtils.mjs.map +1 -0
- package/dist/components/input/dateUtils.cjs +2 -0
- package/dist/components/input/dateUtils.cjs.map +1 -0
- package/dist/components/input/dateUtils.mjs +250 -0
- package/dist/components/input/dateUtils.mjs.map +1 -0
- package/dist/components/input/pickerStyles.cjs +2 -0
- package/dist/components/input/pickerStyles.cjs.map +1 -0
- package/dist/components/input/pickerStyles.mjs +10 -0
- package/dist/components/input/pickerStyles.mjs.map +1 -0
- package/dist/components/internal/HiddenInput.cjs +2 -0
- package/dist/components/internal/HiddenInput.cjs.map +1 -0
- package/dist/components/internal/HiddenInput.mjs +88 -0
- package/dist/components/internal/HiddenInput.mjs.map +1 -0
- package/dist/components/layout/Accordion.cjs +2 -0
- package/dist/components/layout/Accordion.cjs.map +1 -0
- package/dist/components/layout/Accordion.mjs +236 -0
- package/dist/components/layout/Accordion.mjs.map +1 -0
- package/dist/components/layout/Card.cjs +2 -0
- package/dist/components/layout/Card.cjs.map +1 -0
- package/dist/components/layout/Card.mjs +121 -0
- package/dist/components/layout/Card.mjs.map +1 -0
- package/dist/components/layout/Carousel.cjs +2 -0
- package/dist/components/layout/Carousel.cjs.map +1 -0
- package/dist/components/layout/Carousel.mjs +205 -0
- package/dist/components/layout/Carousel.mjs.map +1 -0
- package/dist/components/layout/Flex.cjs +2 -0
- package/dist/components/layout/Flex.cjs.map +1 -0
- package/dist/components/layout/Flex.mjs +54 -0
- package/dist/components/layout/Flex.mjs.map +1 -0
- package/dist/components/layout/Grid.cjs +2 -0
- package/dist/components/layout/Grid.cjs.map +1 -0
- package/dist/components/layout/Grid.mjs +62 -0
- package/dist/components/layout/Grid.mjs.map +1 -0
- package/dist/components/layout/Overflow.cjs +2 -0
- package/dist/components/layout/Overflow.cjs.map +1 -0
- package/dist/components/layout/Overflow.mjs +269 -0
- package/dist/components/layout/Overflow.mjs.map +1 -0
- package/dist/components/layout/Stack.cjs +2 -0
- package/dist/components/layout/Stack.cjs.map +1 -0
- package/dist/components/layout/Stack.mjs +39 -0
- package/dist/components/layout/Stack.mjs.map +1 -0
- package/dist/components/layout/TabList.cjs +2 -0
- package/dist/components/layout/TabList.cjs.map +1 -0
- package/dist/components/layout/TabList.mjs +238 -0
- package/dist/components/layout/TabList.mjs.map +1 -0
- package/dist/components/layout/Tree.cjs +2 -0
- package/dist/components/layout/Tree.cjs.map +1 -0
- package/dist/components/layout/Tree.mjs +220 -0
- package/dist/components/layout/Tree.mjs.map +1 -0
- package/dist/components/layout/disclosureIds.cjs +2 -0
- package/dist/components/layout/disclosureIds.cjs.map +1 -0
- package/dist/components/layout/disclosureIds.mjs +12 -0
- package/dist/components/layout/disclosureIds.mjs.map +1 -0
- package/dist/components/motion/Presence.cjs +2 -0
- package/dist/components/motion/Presence.cjs.map +1 -0
- package/dist/components/motion/Presence.mjs +35 -0
- package/dist/components/motion/Presence.mjs.map +1 -0
- package/dist/components/navigation/Breadcrumb.cjs +2 -0
- package/dist/components/navigation/Breadcrumb.cjs.map +1 -0
- package/dist/components/navigation/Breadcrumb.mjs +144 -0
- package/dist/components/navigation/Breadcrumb.mjs.map +1 -0
- package/dist/components/navigation/Menu.cjs +2 -0
- package/dist/components/navigation/Menu.cjs.map +1 -0
- package/dist/components/navigation/Menu.context.cjs +2 -0
- package/dist/components/navigation/Menu.context.cjs.map +1 -0
- package/dist/components/navigation/Menu.context.mjs +82 -0
- package/dist/components/navigation/Menu.context.mjs.map +1 -0
- package/dist/components/navigation/Menu.group.cjs +2 -0
- package/dist/components/navigation/Menu.group.cjs.map +1 -0
- package/dist/components/navigation/Menu.group.mjs +58 -0
- package/dist/components/navigation/Menu.group.mjs.map +1 -0
- package/dist/components/navigation/Menu.items.cjs +2 -0
- package/dist/components/navigation/Menu.items.cjs.map +1 -0
- package/dist/components/navigation/Menu.items.mjs +127 -0
- package/dist/components/navigation/Menu.items.mjs.map +1 -0
- package/dist/components/navigation/Menu.link.cjs +2 -0
- package/dist/components/navigation/Menu.link.cjs.map +1 -0
- package/dist/components/navigation/Menu.link.mjs +41 -0
- package/dist/components/navigation/Menu.link.mjs.map +1 -0
- package/dist/components/navigation/Menu.mjs +27 -0
- package/dist/components/navigation/Menu.mjs.map +1 -0
- package/dist/components/navigation/Menu.popover.cjs +2 -0
- package/dist/components/navigation/Menu.popover.cjs.map +1 -0
- package/dist/components/navigation/Menu.popover.mjs +231 -0
- package/dist/components/navigation/Menu.popover.mjs.map +1 -0
- package/dist/components/navigation/Menu.root.cjs +2 -0
- package/dist/components/navigation/Menu.root.cjs.map +1 -0
- package/dist/components/navigation/Menu.root.mjs +308 -0
- package/dist/components/navigation/Menu.root.mjs.map +1 -0
- package/dist/components/navigation/Menu.selectable.cjs +2 -0
- package/dist/components/navigation/Menu.selectable.cjs.map +1 -0
- package/dist/components/navigation/Menu.selectable.mjs +89 -0
- package/dist/components/navigation/Menu.selectable.mjs.map +1 -0
- package/dist/components/navigation/Menu.shared.cjs +2 -0
- package/dist/components/navigation/Menu.shared.cjs.map +1 -0
- package/dist/components/navigation/Menu.shared.mjs +23 -0
- package/dist/components/navigation/Menu.shared.mjs.map +1 -0
- package/dist/components/navigation/Menu.splitGroup.cjs +2 -0
- package/dist/components/navigation/Menu.splitGroup.cjs.map +1 -0
- package/dist/components/navigation/Menu.splitGroup.mjs +51 -0
- package/dist/components/navigation/Menu.splitGroup.mjs.map +1 -0
- package/dist/components/navigation/Menu.trigger.cjs +2 -0
- package/dist/components/navigation/Menu.trigger.cjs.map +1 -0
- package/dist/components/navigation/Menu.trigger.mjs +79 -0
- package/dist/components/navigation/Menu.trigger.mjs.map +1 -0
- package/dist/components/navigation/Nav.cjs +2 -0
- package/dist/components/navigation/Nav.cjs.map +1 -0
- package/dist/components/navigation/Nav.mjs +276 -0
- package/dist/components/navigation/Nav.mjs.map +1 -0
- package/dist/components/navigation/Pagination.cjs +2 -0
- package/dist/components/navigation/Pagination.cjs.map +1 -0
- package/dist/components/navigation/Pagination.mjs +110 -0
- package/dist/components/navigation/Pagination.mjs.map +1 -0
- package/dist/components/navigation/Stepper.cjs +2 -0
- package/dist/components/navigation/Stepper.cjs.map +1 -0
- package/dist/components/navigation/Stepper.mjs +204 -0
- package/dist/components/navigation/Stepper.mjs.map +1 -0
- package/dist/components/overlays/Dialog.cjs +2 -0
- package/dist/components/overlays/Dialog.cjs.map +1 -0
- package/dist/components/overlays/Dialog.mjs +180 -0
- package/dist/components/overlays/Dialog.mjs.map +1 -0
- package/dist/components/overlays/Dialog.shared.cjs +2 -0
- package/dist/components/overlays/Dialog.shared.cjs.map +1 -0
- package/dist/components/overlays/Dialog.shared.mjs +227 -0
- package/dist/components/overlays/Dialog.shared.mjs.map +1 -0
- package/dist/components/overlays/Drawer.cjs +2 -0
- package/dist/components/overlays/Drawer.cjs.map +1 -0
- package/dist/components/overlays/Drawer.mjs +192 -0
- package/dist/components/overlays/Drawer.mjs.map +1 -0
- package/dist/components/overlays/Popover.cjs +2 -0
- package/dist/components/overlays/Popover.cjs.map +1 -0
- package/dist/components/overlays/Popover.mjs +365 -0
- package/dist/components/overlays/Popover.mjs.map +1 -0
- package/dist/components/overlays/Popover.shared.cjs +2 -0
- package/dist/components/overlays/Popover.shared.cjs.map +1 -0
- package/dist/components/overlays/Popover.shared.mjs +182 -0
- package/dist/components/overlays/Popover.shared.mjs.map +1 -0
- package/dist/components/overlays/TeachingPopover.cjs +2 -0
- package/dist/components/overlays/TeachingPopover.cjs.map +1 -0
- package/dist/components/overlays/TeachingPopover.mjs +181 -0
- package/dist/components/overlays/TeachingPopover.mjs.map +1 -0
- package/dist/components/overlays/Tooltip.cjs +2 -0
- package/dist/components/overlays/Tooltip.cjs.map +1 -0
- package/dist/components/overlays/Tooltip.mjs +160 -0
- package/dist/components/overlays/Tooltip.mjs.map +1 -0
- package/dist/components/portal/Portal.cjs +2 -0
- package/dist/components/portal/Portal.cjs.map +1 -0
- package/dist/components/portal/Portal.mjs +45 -0
- package/dist/components/portal/Portal.mjs.map +1 -0
- package/dist/components/provider/WaveProvider.cjs +2 -0
- package/dist/components/provider/WaveProvider.cjs.map +1 -0
- package/dist/components/provider/WaveProvider.mjs +51 -0
- package/dist/components/provider/WaveProvider.mjs.map +1 -0
- package/dist/components/table/DataGrid.cjs +2 -0
- package/dist/components/table/DataGrid.cjs.map +1 -0
- package/dist/components/table/DataGrid.mjs +489 -0
- package/dist/components/table/DataGrid.mjs.map +1 -0
- package/dist/components/table/Table.cjs +2 -0
- package/dist/components/table/Table.cjs.map +1 -0
- package/dist/components/table/Table.mjs +99 -0
- package/dist/components/table/Table.mjs.map +1 -0
- package/dist/components/table/useGridNavigation.cjs +2 -0
- package/dist/components/table/useGridNavigation.cjs.map +1 -0
- package/dist/components/table/useGridNavigation.mjs +336 -0
- package/dist/components/table/useGridNavigation.mjs.map +1 -0
- package/dist/components/typography/Text.cjs +2 -0
- package/dist/components/typography/Text.cjs.map +1 -0
- package/dist/components/typography/Text.mjs +38 -0
- package/dist/components/typography/Text.mjs.map +1 -0
- package/dist/hooks/useAnnounce.cjs +2 -0
- package/dist/hooks/useAnnounce.cjs.map +1 -0
- package/dist/hooks/useAnnounce.mjs +88 -0
- package/dist/hooks/useAnnounce.mjs.map +1 -0
- package/dist/hooks/useCheckedValues.cjs +2 -0
- package/dist/hooks/useCheckedValues.cjs.map +1 -0
- package/dist/hooks/useCheckedValues.mjs +102 -0
- package/dist/hooks/useCheckedValues.mjs.map +1 -0
- package/dist/hooks/useContextMenuAnchor.cjs +2 -0
- package/dist/hooks/useContextMenuAnchor.cjs.map +1 -0
- package/dist/hooks/useContextMenuAnchor.mjs +132 -0
- package/dist/hooks/useContextMenuAnchor.mjs.map +1 -0
- package/dist/hooks/useControllable.cjs +2 -0
- package/dist/hooks/useControllable.cjs.map +1 -0
- package/dist/hooks/useControllable.mjs +37 -0
- package/dist/hooks/useControllable.mjs.map +1 -0
- package/dist/hooks/useDirection.cjs +2 -0
- package/dist/hooks/useDirection.cjs.map +1 -0
- package/dist/hooks/useDirection.mjs +57 -0
- package/dist/hooks/useDirection.mjs.map +1 -0
- package/dist/hooks/useDismiss.cjs +2 -0
- package/dist/hooks/useDismiss.cjs.map +1 -0
- package/dist/hooks/useDismiss.mjs +57 -0
- package/dist/hooks/useDismiss.mjs.map +1 -0
- package/dist/hooks/useEventCallback.cjs +2 -0
- package/dist/hooks/useEventCallback.cjs.map +1 -0
- package/dist/hooks/useEventCallback.mjs +16 -0
- package/dist/hooks/useEventCallback.mjs.map +1 -0
- package/dist/hooks/useFieldControl.cjs +2 -0
- package/dist/hooks/useFieldControl.cjs.map +1 -0
- package/dist/hooks/useFieldControl.mjs +62 -0
- package/dist/hooks/useFieldControl.mjs.map +1 -0
- package/dist/hooks/useFocusTrap.cjs +2 -0
- package/dist/hooks/useFocusTrap.cjs.map +1 -0
- package/dist/hooks/useFocusTrap.mjs +266 -0
- package/dist/hooks/useFocusTrap.mjs.map +1 -0
- package/dist/hooks/useFormReset.cjs +2 -0
- package/dist/hooks/useFormReset.cjs.map +1 -0
- package/dist/hooks/useFormReset.mjs +33 -0
- package/dist/hooks/useFormReset.mjs.map +1 -0
- package/dist/hooks/useHoverIntent.cjs +2 -0
- package/dist/hooks/useHoverIntent.cjs.map +1 -0
- package/dist/hooks/useHoverIntent.mjs +201 -0
- package/dist/hooks/useHoverIntent.mjs.map +1 -0
- package/dist/hooks/useId.cjs +2 -0
- package/dist/hooks/useId.cjs.map +1 -0
- package/dist/hooks/useId.mjs +11 -0
- package/dist/hooks/useId.mjs.map +1 -0
- package/dist/hooks/useIsClient.cjs +2 -0
- package/dist/hooks/useIsClient.cjs.map +1 -0
- package/dist/hooks/useIsClient.mjs +19 -0
- package/dist/hooks/useIsClient.mjs.map +1 -0
- package/dist/hooks/useListbox.cjs +2 -0
- package/dist/hooks/useListbox.cjs.map +1 -0
- package/dist/hooks/useListbox.mjs +492 -0
- package/dist/hooks/useListbox.mjs.map +1 -0
- package/dist/hooks/useMergedRefs.cjs +2 -0
- package/dist/hooks/useMergedRefs.cjs.map +1 -0
- package/dist/hooks/useMergedRefs.mjs +57 -0
- package/dist/hooks/useMergedRefs.mjs.map +1 -0
- package/dist/hooks/useModalIsolation.cjs +2 -0
- package/dist/hooks/useModalIsolation.cjs.map +1 -0
- package/dist/hooks/useModalIsolation.mjs +87 -0
- package/dist/hooks/useModalIsolation.mjs.map +1 -0
- package/dist/hooks/useModalLayer.cjs +2 -0
- package/dist/hooks/useModalLayer.cjs.map +1 -0
- package/dist/hooks/useModalLayer.mjs +30 -0
- package/dist/hooks/useModalLayer.mjs.map +1 -0
- package/dist/hooks/usePopupPosition.cjs +2 -0
- package/dist/hooks/usePopupPosition.cjs.map +1 -0
- package/dist/hooks/usePopupPosition.mjs +117 -0
- package/dist/hooks/usePopupPosition.mjs.map +1 -0
- package/dist/hooks/usePrefersReducedMotion.cjs +2 -0
- package/dist/hooks/usePrefersReducedMotion.cjs.map +1 -0
- package/dist/hooks/usePrefersReducedMotion.mjs +24 -0
- package/dist/hooks/usePrefersReducedMotion.mjs.map +1 -0
- package/dist/hooks/usePresence.cjs +2 -0
- package/dist/hooks/usePresence.cjs.map +1 -0
- package/dist/hooks/usePresence.mjs +136 -0
- package/dist/hooks/usePresence.mjs.map +1 -0
- package/dist/hooks/usePreserveFocus.cjs +2 -0
- package/dist/hooks/usePreserveFocus.cjs.map +1 -0
- package/dist/hooks/usePreserveFocus.mjs +50 -0
- package/dist/hooks/usePreserveFocus.mjs.map +1 -0
- package/dist/hooks/useRestoreFocus.cjs +2 -0
- package/dist/hooks/useRestoreFocus.cjs.map +1 -0
- package/dist/hooks/useRestoreFocus.mjs +271 -0
- package/dist/hooks/useRestoreFocus.mjs.map +1 -0
- package/dist/hooks/useRovingTabIndex.cjs +2 -0
- package/dist/hooks/useRovingTabIndex.cjs.map +1 -0
- package/dist/hooks/useRovingTabIndex.mjs +389 -0
- package/dist/hooks/useRovingTabIndex.mjs.map +1 -0
- package/dist/hooks/useScrollLock.cjs +2 -0
- package/dist/hooks/useScrollLock.cjs.map +1 -0
- package/dist/hooks/useScrollLock.mjs +71 -0
- package/dist/hooks/useScrollLock.mjs.map +1 -0
- package/dist/hooks/useTriggerElement.cjs +2 -0
- package/dist/hooks/useTriggerElement.cjs.map +1 -0
- package/dist/hooks/useTriggerElement.mjs +126 -0
- package/dist/hooks/useTriggerElement.mjs.map +1 -0
- package/dist/hooks/useTypeahead.cjs +2 -0
- package/dist/hooks/useTypeahead.cjs.map +1 -0
- package/dist/hooks/useTypeahead.mjs +38 -0
- package/dist/hooks/useTypeahead.mjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +9099 -0
- package/dist/index.d.ts +7688 -1027
- package/dist/index.mjs +91 -5695
- package/dist/lib/aria.cjs +2 -0
- package/dist/lib/aria.cjs.map +1 -0
- package/dist/lib/aria.mjs +29 -0
- package/dist/lib/aria.mjs.map +1 -0
- package/dist/lib/children.cjs +2 -0
- package/dist/lib/children.cjs.map +1 -0
- package/dist/lib/children.mjs +37 -0
- package/dist/lib/children.mjs.map +1 -0
- package/dist/lib/cn.cjs +2 -0
- package/dist/lib/cn.cjs.map +1 -0
- package/dist/lib/cn.mjs +64 -0
- package/dist/lib/cn.mjs.map +1 -0
- package/dist/lib/composeEventHandlers.cjs +2 -0
- package/dist/lib/composeEventHandlers.cjs.map +1 -0
- package/dist/lib/composeEventHandlers.mjs +11 -0
- package/dist/lib/composeEventHandlers.mjs.map +1 -0
- package/dist/lib/dev.cjs +2 -0
- package/dist/lib/dev.cjs.map +1 -0
- package/dist/lib/dev.mjs +42 -0
- package/dist/lib/dev.mjs.map +1 -0
- package/dist/lib/direction.cjs +2 -0
- package/dist/lib/direction.cjs.map +1 -0
- package/dist/lib/direction.mjs +35 -0
- package/dist/lib/direction.mjs.map +1 -0
- package/dist/lib/events.cjs +2 -0
- package/dist/lib/events.cjs.map +1 -0
- package/dist/lib/events.mjs +31 -0
- package/dist/lib/events.mjs.map +1 -0
- package/dist/lib/focus.cjs +2 -0
- package/dist/lib/focus.cjs.map +1 -0
- package/dist/lib/focus.mjs +119 -0
- package/dist/lib/focus.mjs.map +1 -0
- package/dist/lib/globalRegistry.cjs +2 -0
- package/dist/lib/globalRegistry.cjs.map +1 -0
- package/dist/lib/globalRegistry.mjs +13 -0
- package/dist/lib/globalRegistry.mjs.map +1 -0
- package/dist/lib/icons.cjs +2 -0
- package/dist/lib/icons.cjs.map +1 -0
- package/dist/lib/icons.mjs +254 -0
- package/dist/lib/icons.mjs.map +1 -0
- package/dist/lib/labelInName.cjs +2 -0
- package/dist/lib/labelInName.cjs.map +1 -0
- package/dist/lib/labelInName.mjs +54 -0
- package/dist/lib/labelInName.mjs.map +1 -0
- package/dist/lib/layers.cjs +2 -0
- package/dist/lib/layers.cjs.map +1 -0
- package/dist/lib/layers.mjs +224 -0
- package/dist/lib/layers.mjs.map +1 -0
- package/dist/lib/mergeProps.cjs +2 -0
- package/dist/lib/mergeProps.cjs.map +1 -0
- package/dist/lib/mergeProps.mjs +21 -0
- package/dist/lib/mergeProps.mjs.map +1 -0
- package/dist/lib/mergeRefs.cjs +2 -0
- package/dist/lib/mergeRefs.cjs.map +1 -0
- package/dist/lib/mergeRefs.mjs +29 -0
- package/dist/lib/mergeRefs.mjs.map +1 -0
- package/dist/lib/renderTrigger.cjs +2 -0
- package/dist/lib/renderTrigger.cjs.map +1 -0
- package/dist/lib/renderTrigger.mjs +29 -0
- package/dist/lib/renderTrigger.mjs.map +1 -0
- package/dist/lib/slot.cjs +2 -0
- package/dist/lib/slot.cjs.map +1 -0
- package/dist/lib/slot.mjs +122 -0
- package/dist/lib/slot.mjs.map +1 -0
- package/dist/lib/styles.cjs +2 -0
- package/dist/lib/styles.cjs.map +1 -0
- package/dist/lib/styles.mjs +16 -0
- package/dist/lib/styles.mjs.map +1 -0
- package/dist/lib/theme.cjs +2 -0
- package/dist/lib/theme.cjs.map +1 -0
- package/dist/lib/theme.mjs +16 -0
- package/dist/lib/theme.mjs.map +1 -0
- package/dist/preflight.css +2 -0
- package/dist/styles.css +2 -0
- package/package.json +149 -100
- package/src/styles/animations.css +7 -39
- package/src/styles/base.css +103 -0
- package/src/styles/globals.css +10 -22
- package/src/styles/legacy-tokens.css +184 -0
- package/src/styles/preflight.css +7 -0
- package/src/styles/styles.css +32 -0
- package/src/styles/tailwind.css +17 -0
- package/src/styles/tokens.css +561 -221
- package/src/styles/variants.css +29 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTriggerElement.cjs","names":["FOCUSABLE_SELECTOR","isHiddenInput","isFocusable","getFirstTabbable","React","STATE_ARIA","unwrapFragment","isCloneableElement","useMergedRefs","useEventCallback","mergeProps","renderTrigger","require_runtime","require_dev","require_useEventCallback","require_focus","require_useMergedRefs","require_mergeProps","require_renderTrigger","react","GENERIC_ROLES","isNonGenericRole","role","first","isInTabOrder","tabIndex","NATIVE_CONTROL_SELECTOR","isWidgetElement","el","getTriggerTarget","widget","candidate","getTriggerFocusTarget","trigger","target","useTriggerFocusRef","createTriggerFocusRef","triggerRef","isElementNode","value","withoutStateAria","rest","props","key","pickStateAria","values","moveStateAria","previous","useTriggerElement","options","wrapperFallback","setWrapperFallback","isRenderProp","children","content","singleElement","cloneable","asChild","cloneTarget","allProps","triggerProps","ourRef","ourProps","omitStateAria","childRef","attachedRef","detectAttach","node","mergedRef","componentName","autoWrapper","wrapper","wrapperIsTrigger","movedAria","span","spread","name","ourId","resolvedId","reportId","onResolvedId","_theirRef","theirProps","_ourRef","ourRest","merged","wrapperProps","renderProps"],"sources":["../../src/hooks/useTriggerElement.tsx"],"sourcesContent":["import * as React from 'react';\nimport { mergeProps } from '../lib/mergeProps';\nimport {\n isCloneableElement,\n renderTrigger,\n STATE_ARIA,\n unwrapFragment,\n type TriggerChildren,\n} from '../lib/renderTrigger';\nimport { warnOnce } from '../lib/dev';\nimport { FOCUSABLE_SELECTOR, getFirstTabbable, isFocusable, isHiddenInput } from '../lib/focus';\nimport { useMergedRefs } from './useMergedRefs';\nimport { useEventCallback } from './useEventCallback';\n\n/**\n * Options of {@link useTriggerElement}. (`triggerProps.ref`, the hook's second argument, may be an\n * inline callback: it is re-attached after each commit; a stable ref is attached once.)\n */\nexport interface UseTriggerElementOptions {\n /** Public name used in development warnings, e.g. `'Dialog.Trigger'`. */\n componentName: string;\n /**\n * `false` renders the 0.4 wrapper `<span>` around the children instead of cloning; the state\n * ARIA moves onto the element inside it, as for the automatic fallback. @default true\n */\n asChild?: boolean;\n /**\n * Called (from an effect) with the id the trigger element ends up with: the child's own `id` when\n * it has one, otherwise `triggerProps.id`. Roots store it for `aria-labelledby`.\n */\n onResolvedId?: (id: string) => void;\n /**\n * Context-menu mode (`openOnContext`): the trigger is a region, not a menu button, so its\n * element carries no `aria-haspopup`, `aria-expanded` or `aria-controls`. A cloned child and a\n * wrapper span do not receive them from `triggerProps` (the state-ARIA move of the wrapper span\n * is skipped too). A render-prop child still receives every trigger prop; when its element\n * carries them after a commit, they are removed from it and a development warning is logged\n * once (`<componentName>:context-state-aria`).\n * @default false\n */\n omitStateAria?: boolean;\n}\n\ntype UnknownProps = Record<string, unknown>;\n\n/** Roles that make an element no widget of its own. */\nconst GENERIC_ROLES: ReadonlySet<string> = new Set(['generic', 'none', 'presentation']);\n\n/** Whether a `role` value (attribute or prop) names a role other than a generic one. */\nfunction isNonGenericRole(role: unknown): boolean {\n if (typeof role !== 'string') return false;\n const first = role.trim().split(/\\s+/)[0];\n return first !== '' && !GENERIC_ROLES.has(first);\n}\n\n/** Whether a `tabIndex` prop puts its element in the tab order. */\nfunction isInTabOrder(tabIndex: unknown): boolean {\n if (typeof tabIndex === 'number') return tabIndex >= 0;\n return typeof tabIndex === 'string' && tabIndex.trim() !== '' && Number(tabIndex) >= 0;\n}\n\n/** Native controls, whose own role can carry the state ARIA. */\nconst NATIVE_CONTROL_SELECTOR = 'a[href], button, input, select, summary, textarea';\n\n/**\n * Whether `el` can carry the state ARIA: its `role` names a role other than a generic one, or it\n * has none and is a native control. A `<span>` or `<div>` without a role is generic, whatever its\n * `tabIndex` (axe `aria-allowed-attr`).\n */\nfunction isWidgetElement(el: Element): boolean {\n const role = el.getAttribute('role');\n if (role !== null && role.trim() !== '') return isNonGenericRole(role);\n return el.matches(NATIVE_CONTROL_SELECTOR);\n}\n\n/**\n * The element that acts as the trigger rendered as `el` (a cloned child, or the wrapper `<span>`\n * of `asChild={false}`, of text children and of the automatic fallback): `el` itself when it is a\n * widget (a native control, or an element given a role other than a generic one) in the tab order\n * by markup (`tabIndex >= 0`: a button, a span given `role=\"button\"` and `tabIndex={0}`); else the\n * first element inside it in the tab order by markup; else `el` when it is a widget out of the tab\n * order (a span given only `role=\"button\"`, a `<button tabIndex={-1}>`); else `null`. `tabIndex`\n * alone never makes a generic element the trigger: it cannot carry the state ARIA. The trigger's\n * state ARIA belongs on it, and focus returns to it ({@link getTriggerFocusTarget}). Read from the\n * markup, not `getFirstTabbable`: that skips an `inert` subtree, and the page around a trigger is\n * inert while its modal dialog is open. Internal (not exported from the package entry).\n */\nexport function getTriggerTarget(el: HTMLElement): HTMLElement | null {\n const widget = isWidgetElement(el);\n if (widget && el.tabIndex >= 0) return el;\n for (const candidate of el.querySelectorAll<HTMLElement>(FOCUSABLE_SELECTOR)) {\n if (!isHiddenInput(candidate) && candidate.tabIndex >= 0) return candidate;\n }\n return widget ? el : null;\n}\n\n/**\n * The element that takes focus for the trigger rendered as `trigger`: the one rule of every focus\n * return of Menu, Popover, Dialog and Drawer (Escape, outside press, item activation, Tab and\n * Shift+Tab, the Close part). It is the {@link getTriggerTarget} element, which carries the state\n * ARIA, when that can take focus now (a `<button tabIndex={-1}>` child; the button inside a\n * `tabIndex={-1}` wrapper span, or inside a span given only a `role`); else the first tabbable\n * element inside `trigger` (a wrapper span whose first control is disabled or hidden, with another\n * one after it); else `trigger` itself when it can take focus (a span holding only text, given a\n * `tabIndex` but no widget role); else `null`. Internal (not exported from the package entry).\n */\nexport function getTriggerFocusTarget(trigger: HTMLElement | null): HTMLElement | null {\n if (!trigger) return null;\n const target = getTriggerTarget(trigger);\n if (target && isFocusable(target)) return target;\n return getFirstTabbable(trigger) ?? (isFocusable(trigger) ? trigger : null);\n}\n\n/**\n * A read-only ref for `useRestoreFocus`'s `triggerRef` and `useDismiss`'s `anchorRef` (Menu,\n * Popover; the anchor is where a surface opened from the popup restores focus once its opener is\n * gone): resolved when it is read, to {@link getTriggerFocusTarget} of the element in\n * `triggerRef`, or to that element itself when nothing in it can take focus (the restore then goes\n * to the element next to where it is, as for any opener that cannot take focus). Stable while\n * `triggerRef` is.\n */\nexport function useTriggerFocusRef(\n triggerRef: React.RefObject<HTMLElement | null>,\n): React.RefObject<HTMLElement | null> {\n return React.useMemo(() => createTriggerFocusRef(triggerRef), [triggerRef]);\n}\n\nfunction createTriggerFocusRef(\n triggerRef: React.RefObject<HTMLElement | null>,\n): React.RefObject<HTMLElement | null> {\n return {\n get current() {\n const trigger = triggerRef.current;\n return trigger && (getTriggerFocusTarget(trigger) ?? trigger);\n },\n };\n}\n\nfunction isElementNode(value: unknown): value is Element {\n return typeof value === 'object' && value !== null && (value as Node).nodeType === 1;\n}\n\ntype StateAriaValues = Partial<Record<(typeof STATE_ARIA)[number], unknown>>;\n\n/** `props` without the state ARIA keys (context-menu mode). */\nfunction withoutStateAria(props: UnknownProps): UnknownProps {\n const rest = { ...props };\n for (const key of STATE_ARIA) delete rest[key];\n return rest;\n}\n\n/** The state ARIA keys present in `props` (a key given as `undefined` removes the attribute). */\nfunction pickStateAria(props: UnknownProps): StateAriaValues {\n const values: StateAriaValues = {};\n for (const key of STATE_ARIA) {\n if (key in props) values[key] = props[key];\n }\n return values;\n}\n\n/** Writes `values` onto `target` and returns a cleanup that restores its own attributes. */\nfunction moveStateAria(target: Element, values: StateAriaValues): () => void {\n const previous = Object.keys(values).map((key) => [key, target.getAttribute(key)] as const);\n for (const [key, value] of Object.entries(values)) {\n if (value === undefined || value === null) target.removeAttribute(key);\n else target.setAttribute(key, String(value));\n }\n return () => {\n for (const [key, value] of previous) {\n if (value === null) target.removeAttribute(key);\n else target.setAttribute(key, value);\n }\n };\n}\n\n/**\n * Renders a trigger (`Dialog.Trigger`, `Drawer.Trigger`, `Popover.Trigger`, `Menu.Trigger`,\n * `.Close`): puts `triggerProps` on the consumer's element.\n *\n * - **Single element child** (default): cloned with the trigger props merged in (`mergeProps`):\n * handlers composed (the child's run first; `preventDefault()` skips the trigger's), classes and\n * styles merged, the child's own `id` kept, and live `aria-expanded` / `aria-controls` /\n * `aria-haspopup` always winning over the child's values. The trigger ref and the child's own ref\n * are merged with {@link useMergedRefs}, so a ref that keeps its identity is attached once and\n * the element is not detached and re-attached on every render (stable positioning anchor and\n * focus-restore target). A Fragment around a single element (`<><Button /></>`) is unwrapped and\n * its element cloned.\n * - **`triggerProps.ref`** does not have to be stable: an inline callback or a fresh `mergeRefs(…)`\n * result is detached and re-attached after each commit (as React does for an inline ref), and a\n * state-setting ref (`ref: setAnchor`) never loops. Pass a stable ref (an object ref, a\n * `useCallback` or a state setter) so floating-ui's reference and restore targets are set once.\n * - **Render-prop child**: called with `triggerProps` (all of them, whatever `asChild` says).\n * - **`asChild={false}`**: the 0.4 wrapper `<span>` carrying the trigger props except the state\n * ARIA, which moves as in the automatic fallback below (so a button inside is announced as\n * opening the popup).\n * - **Text, a Fragment of several elements, several children**: a wrapper `<span>` (with a\n * development warning from `renderTrigger`) carrying the trigger props except the state ARIA,\n * which moves as in the automatic fallback below.\n * - **A wrapper span the consumer made the trigger** (a `role` such as `\"button\"` and\n * `tabIndex={0}` passed to the trigger, e.g. `<Menu.Trigger asChild={false} role=\"button\"\n * tabIndex={0}>Actions</Menu.Trigger>`): the span keeps the state ARIA, as the element that\n * takes focus and is announced ({@link getTriggerTarget}). A span given only such a role gets\n * it too (after mount) when nothing inside it is in the tab order; `tabIndex` alone leaves the\n * span generic, so the state ARIA moves as below.\n * - **Automatic fallback**: when the cloned child has not attached its ref by the end of the mount\n * layout effect (a custom component that neither forwards `ref` nor spreads props), the hook\n * switches once to the wrapper span — whose click handler catches the bubbling click, so the\n * trigger keeps working — and warns in development. The span keeps the other trigger props (`id`,\n * handlers, ref), but the state ARIA (`aria-haspopup`, `aria-expanded`, `aria-controls`), which\n * a generic span cannot carry, moves after each commit onto the first element inside it in the\n * tab order (the child's own values restored when it stops being that element), or is dropped\n * when there is none. A component that forwards `ref` but drops `onClick` cannot be detected.\n * - **Context-menu mode** (`omitStateAria`): a cloned child and a wrapper span get no\n * `aria-haspopup`, `aria-expanded` or `aria-controls` (nothing moves inside the span either); a\n * render-prop child receives them with the other props, and the ones it spreads are removed from\n * its element after each commit, with a one-time development warning.\n *\n * @param children The trigger's children.\n * @param triggerProps Props for the trigger element (`id`, state ARIA, handlers, `ref`; the ref may\n * change between renders, a stable one is attached once).\n * @param options See {@link UseTriggerElementOptions}.\n */\nexport function useTriggerElement<P>(\n children: TriggerChildren<P> | React.ReactNode,\n triggerProps: P,\n options: UseTriggerElementOptions,\n): React.ReactNode {\n const { componentName, asChild = true, onResolvedId, omitStateAria = false } = options;\n const [wrapperFallback, setWrapperFallback] = React.useState(false);\n\n const isRenderProp = typeof children === 'function';\n // A Fragment around one element is that element (children of a conditional expression).\n const content = isRenderProp ? null : unwrapFragment(children as React.ReactNode);\n const singleElement = isCloneableElement(content);\n const cloneable = asChild && !wrapperFallback && singleElement;\n const cloneTarget = cloneable ? (content as React.ReactElement<UnknownProps>) : null;\n const allProps = triggerProps as UnknownProps;\n const ourRef = allProps.ref as React.Ref<Element> | undefined;\n // The props this hook puts on an element itself (a render-prop child receives `triggerProps`).\n const ourProps = omitStateAria ? withoutStateAria(allProps) : allProps;\n // The cloned child's own `ref` prop is read to merge it (React 19 keeps `ref` in props).\n const childRef = cloneTarget\n ? (cloneTarget.props.ref as React.Ref<Element> | undefined)\n : undefined;\n\n const attachedRef = React.useRef<Element | null>(null);\n const detectAttach = React.useCallback((node: Element | null) => {\n attachedRef.current = isElementNode(node) ? node : null;\n }, []);\n const mergedRef = useMergedRefs<Element>(ourRef, childRef, detectAttach);\n\n React.useLayoutEffect(() => {\n if (!cloneable || attachedRef.current) return;\n warnOnce(\n `trigger-ref:${componentName}`,\n `${componentName}: its child did not attach the trigger ref (a component that neither forwards \\`ref\\` nor spreads its props). It is rendered inside a <span> wrapper instead; forward \\`ref\\` and spread props onto the element, or pass asChild={false}.`,\n );\n // C-HOOKS site 2: the child never attached its ref after mount; switch to the wrapper span once.\n setWrapperFallback(true);\n }, [cloneable, componentName]);\n\n // A wrapper span: the explicit one of `asChild={false}`, the automatic fallback of a single\n // element child, or children that cannot be cloned (text, several elements). The trigger is the\n // element inside, so the state ARIA, which a generic span cannot carry, goes to the first element\n // it rendered in the tab order — unless the consumer made the span itself the trigger (a widget\n // `role` and `tabIndex={0}`, see getTriggerTarget): then the span keeps it from the first render.\n // A span given only such a role gets it after mount when nothing inside it is in the tab order.\n const autoWrapper = asChild && wrapperFallback && singleElement;\n const wrapper = !isRenderProp && !cloneable;\n const wrapperIsTrigger =\n wrapper && isNonGenericRole(ourProps.role) && isInTabOrder(ourProps.tabIndex);\n const movedAria = wrapper && !wrapperIsTrigger && !omitStateAria ? pickStateAria(ourProps) : null;\n // No deps: runs after every commit of the trigger (which re-renders on every state change), so\n // the attributes follow the live state and the child's current first tabbable element. A new\n // target rendered by the child without a trigger commit is picked up at the next one.\n React.useLayoutEffect(() => {\n const span = attachedRef.current;\n if (!movedAria || !span) return undefined;\n const target = getTriggerTarget(span as HTMLElement);\n return target ? moveStateAria(target, movedAria) : undefined;\n });\n\n // Context-menu mode: the state ARIA a render-prop child spread onto its element is removed after\n // each commit (React writes it again only when a value changes). No deps: every commit.\n React.useLayoutEffect(() => {\n const el = attachedRef.current;\n if (!omitStateAria || !isRenderProp || !el) return;\n const spread = STATE_ARIA.filter((name) => el.hasAttribute(name));\n if (spread.length === 0) return;\n for (const name of spread) el.removeAttribute(name);\n warnOnce(\n `${componentName}:context-state-aria`,\n `${componentName}: the trigger element is a context-menu region (openOnContext), which is not a menu button: do not spread aria-haspopup, aria-expanded and aria-controls onto it.`,\n );\n });\n\n const ourId = typeof ourProps.id === 'string' ? ourProps.id : undefined;\n const childId =\n cloneTarget && typeof cloneTarget.props.id === 'string' ? cloneTarget.props.id : undefined;\n const resolvedId = childId ?? ourId;\n const reportId = useEventCallback(onResolvedId);\n React.useEffect(() => {\n if (resolvedId) reportId(resolvedId);\n }, [resolvedId, reportId]);\n\n if (cloneTarget) {\n const { ref: _theirRef, ...theirProps } = cloneTarget.props;\n const { ref: _ourRef, ...ourRest } = ourProps;\n const merged = mergeProps(ourRest, theirProps, { oursWin: STATE_ARIA });\n return React.cloneElement(cloneTarget, { ...merged, ref: mergedRef });\n }\n\n if (wrapper) {\n const { ref: _ourRef, ...ourRest } = ourProps;\n const wrapperProps: UnknownProps = { ...ourRest, ref: mergedRef };\n if (!wrapperIsTrigger || omitStateAria) for (const key of STATE_ARIA) delete wrapperProps[key];\n // The explicit 0.4 span renders the children as given. Otherwise `asChild` lets renderTrigger\n // warn about children it cannot clone; the automatic fallback (a single element, never cloned\n // again) warned above.\n return asChild\n ? renderTrigger(content, wrapperProps, { componentName, asChild: !autoWrapper })\n : renderTrigger(children, wrapperProps, { componentName, asChild: false });\n }\n\n // A render-prop child. In context-menu mode its element is found through the merged ref, so the\n // state ARIA it spreads can be removed.\n const renderProps = omitStateAria ? ({ ...allProps, ref: mergedRef } as P) : triggerProps;\n return renderTrigger(children, renderProps, { componentName, asChild: false });\n}\n"],"mappings":"kTA8CA,IAAMoB,EAAqC,IAAI,IAAI,CAAC,UAAW,OAAQ,cAAc,CAAC,EAGtF,SAASC,EAAiB,EAAwB,CAChD,GAAI,OAAOC,GAAS,SAAU,MAAO,GACrC,IAAMC,EAAQD,EAAK,KAAK,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,GACvC,OAAOC,IAAU,IAAM,CAACH,EAAc,IAAIG,CAAK,CACjD,CAGA,SAASC,EAAa,EAA4B,CAEhD,OADI,OAAOC,GAAa,SAAiBA,GAAY,EAC9C,OAAOA,GAAa,UAAYA,EAAS,KAAK,IAAM,IAAM,OAAOA,CAAQ,GAAK,CACvF,CAGA,IAAMC,EAA0B,oDAOhC,SAASC,EAAgB,EAAsB,CAC7C,IAAML,EAAOM,EAAG,aAAa,MAAM,EAEnC,OADIN,IAAS,MAAQA,EAAK,KAAK,IAAM,GAAWD,EAAiBC,CAAI,EAC9DM,EAAG,QAAQF,CAAuB,CAC3C,CAcA,SAAgBG,EAAiB,EAAqC,CACpE,IAAMC,EAASH,EAAgBC,CAAE,EACjC,GAAIE,GAAUF,EAAG,UAAY,EAAG,OAAOA,EACvC,IAAK,IAAMG,KAAaH,EAAG,iBAA8B5B,EAAAA,kBAAkB,EACzE,GAAI,CAACC,EAAAA,cAAc8B,CAAS,GAAKA,EAAU,UAAY,EAAG,OAAOA,EAEnE,OAAOD,EAASF,EAAK,IACvB,CAYA,SAAgBI,EAAsB,EAAiD,CACrF,GAAI,CAACC,EAAS,OAAO,KACrB,IAAMC,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IAAMC,EAAcxB,EAAiB,CAAE,GAAGJ,EAAU,IAAKS,CAAU,EAAUR,EAC7E,OAAOjD,EAAAA,cAAc0C,EAAUkC,EAAa,CAAE,gBAAe,QAAS,EAAM,CAAC,CAC/E"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { warnOnce as e } from "../lib/dev.mjs";
|
|
3
|
+
import { useEventCallback as t } from "./useEventCallback.mjs";
|
|
4
|
+
import { FOCUSABLE_SELECTOR as n, getFirstTabbable as r, isFocusable as i, isHiddenInput as a } from "../lib/focus.mjs";
|
|
5
|
+
import { useMergedRefs as o } from "./useMergedRefs.mjs";
|
|
6
|
+
import { mergeProps as s } from "../lib/mergeProps.mjs";
|
|
7
|
+
import { STATE_ARIA as c, isCloneableElement as l, renderTrigger as u, unwrapFragment as d } from "../lib/renderTrigger.mjs";
|
|
8
|
+
import * as f from "react";
|
|
9
|
+
//#region src/hooks/useTriggerElement.tsx
|
|
10
|
+
var p = /* @__PURE__ */ new Set([
|
|
11
|
+
"generic",
|
|
12
|
+
"none",
|
|
13
|
+
"presentation"
|
|
14
|
+
]);
|
|
15
|
+
function m(e) {
|
|
16
|
+
if (typeof e != "string") return !1;
|
|
17
|
+
let t = e.trim().split(/\s+/)[0];
|
|
18
|
+
return t !== "" && !p.has(t);
|
|
19
|
+
}
|
|
20
|
+
function h(e) {
|
|
21
|
+
return typeof e == "number" ? e >= 0 : typeof e == "string" && e.trim() !== "" && Number(e) >= 0;
|
|
22
|
+
}
|
|
23
|
+
var g = "a[href], button, input, select, summary, textarea";
|
|
24
|
+
function _(e) {
|
|
25
|
+
let t = e.getAttribute("role");
|
|
26
|
+
return t !== null && t.trim() !== "" ? m(t) : e.matches(g);
|
|
27
|
+
}
|
|
28
|
+
function v(e) {
|
|
29
|
+
let t = _(e);
|
|
30
|
+
if (t && e.tabIndex >= 0) return e;
|
|
31
|
+
for (let t of e.querySelectorAll(n)) if (!a(t) && t.tabIndex >= 0) return t;
|
|
32
|
+
return t ? e : null;
|
|
33
|
+
}
|
|
34
|
+
function y(e) {
|
|
35
|
+
if (!e) return null;
|
|
36
|
+
let t = v(e);
|
|
37
|
+
return t && i(t) ? t : r(e) ?? (i(e) ? e : null);
|
|
38
|
+
}
|
|
39
|
+
function b(e) {
|
|
40
|
+
return f.useMemo(() => x(e), [e]);
|
|
41
|
+
}
|
|
42
|
+
function x(e) {
|
|
43
|
+
return { get current() {
|
|
44
|
+
let t = e.current;
|
|
45
|
+
return t && (y(t) ?? t);
|
|
46
|
+
} };
|
|
47
|
+
}
|
|
48
|
+
function S(e) {
|
|
49
|
+
return typeof e == "object" && !!e && e.nodeType === 1;
|
|
50
|
+
}
|
|
51
|
+
function C(e) {
|
|
52
|
+
let t = { ...e };
|
|
53
|
+
for (let e of c) delete t[e];
|
|
54
|
+
return t;
|
|
55
|
+
}
|
|
56
|
+
function w(e) {
|
|
57
|
+
let t = {};
|
|
58
|
+
for (let n of c) n in e && (t[n] = e[n]);
|
|
59
|
+
return t;
|
|
60
|
+
}
|
|
61
|
+
function T(e, t) {
|
|
62
|
+
let n = Object.keys(t).map((t) => [t, e.getAttribute(t)]);
|
|
63
|
+
for (let [n, r] of Object.entries(t)) r == null ? e.removeAttribute(n) : e.setAttribute(n, String(r));
|
|
64
|
+
return () => {
|
|
65
|
+
for (let [t, r] of n) r === null ? e.removeAttribute(t) : e.setAttribute(t, r);
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
function E(n, r, i) {
|
|
69
|
+
let { componentName: a, asChild: p = !0, onResolvedId: g, omitStateAria: _ = !1 } = i, [y, b] = f.useState(!1), x = typeof n == "function", E = x ? null : d(n), D = l(E), O = p && !y && D, k = O ? E : null, A = r, j = A.ref, M = _ ? C(A) : A, N = k ? k.props.ref : void 0, P = f.useRef(null), F = f.useCallback((e) => {
|
|
70
|
+
P.current = S(e) ? e : null;
|
|
71
|
+
}, []), I = o(j, N, F);
|
|
72
|
+
f.useLayoutEffect(() => {
|
|
73
|
+
O && !P.current && (e(`trigger-ref:${a}`, `${a}: its child did not attach the trigger ref (a component that neither forwards \`ref\` nor spreads its props). It is rendered inside a <span> wrapper instead; forward \`ref\` and spread props onto the element, or pass asChild={false}.`), b(!0));
|
|
74
|
+
}, [O, a]);
|
|
75
|
+
let L = p && y && D, R = !x && !O, z = R && m(M.role) && h(M.tabIndex), B = R && !z && !_ ? w(M) : null;
|
|
76
|
+
f.useLayoutEffect(() => {
|
|
77
|
+
let e = P.current;
|
|
78
|
+
if (!B || !e) return;
|
|
79
|
+
let t = v(e);
|
|
80
|
+
return t ? T(t, B) : void 0;
|
|
81
|
+
}), f.useLayoutEffect(() => {
|
|
82
|
+
let t = P.current;
|
|
83
|
+
if (!_ || !x || !t) return;
|
|
84
|
+
let n = c.filter((e) => t.hasAttribute(e));
|
|
85
|
+
if (n.length !== 0) {
|
|
86
|
+
for (let e of n) t.removeAttribute(e);
|
|
87
|
+
e(`${a}:context-state-aria`, `${a}: the trigger element is a context-menu region (openOnContext), which is not a menu button: do not spread aria-haspopup, aria-expanded and aria-controls onto it.`);
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
let V = typeof M.id == "string" ? M.id : void 0, H = (k && typeof k.props.id == "string" ? k.props.id : void 0) ?? V, U = t(g);
|
|
91
|
+
if (f.useEffect(() => {
|
|
92
|
+
H && U(H);
|
|
93
|
+
}, [H, U]), k) {
|
|
94
|
+
let { ref: e, ...t } = k.props, { ref: n, ...r } = M, i = s(r, t, { oursWin: c });
|
|
95
|
+
return f.cloneElement(k, {
|
|
96
|
+
...i,
|
|
97
|
+
ref: I
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
if (R) {
|
|
101
|
+
let { ref: e, ...t } = M, r = {
|
|
102
|
+
...t,
|
|
103
|
+
ref: I
|
|
104
|
+
};
|
|
105
|
+
if (!z || _) for (let e of c) delete r[e];
|
|
106
|
+
return p ? u(E, r, {
|
|
107
|
+
componentName: a,
|
|
108
|
+
asChild: !L
|
|
109
|
+
}) : u(n, r, {
|
|
110
|
+
componentName: a,
|
|
111
|
+
asChild: !1
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
let W = _ ? {
|
|
115
|
+
...A,
|
|
116
|
+
ref: I
|
|
117
|
+
} : r;
|
|
118
|
+
return u(n, W, {
|
|
119
|
+
componentName: a,
|
|
120
|
+
asChild: !1
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
//#endregion
|
|
124
|
+
export { y as getTriggerFocusTarget, v as getTriggerTarget, E as useTriggerElement, b as useTriggerFocusRef };
|
|
125
|
+
|
|
126
|
+
//# sourceMappingURL=useTriggerElement.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTriggerElement.mjs","names":["React","GENERIC_ROLES","isNonGenericRole","role","first","isInTabOrder","tabIndex","NATIVE_CONTROL_SELECTOR","isWidgetElement","el","getTriggerTarget","widget","candidate","FOCUSABLE_SELECTOR","isHiddenInput","getTriggerFocusTarget","trigger","target","isFocusable","getFirstTabbable","useTriggerFocusRef","createTriggerFocusRef","triggerRef","isElementNode","value","withoutStateAria","rest","props","key","STATE_ARIA","pickStateAria","values","moveStateAria","previous","useTriggerElement","options","wrapperFallback","setWrapperFallback","isRenderProp","children","content","unwrapFragment","singleElement","isCloneableElement","cloneable","asChild","cloneTarget","allProps","triggerProps","ourRef","ourProps","omitStateAria","childRef","attachedRef","detectAttach","node","mergedRef","useMergedRefs","warnOnce","componentName","autoWrapper","wrapper","wrapperIsTrigger","movedAria","span","spread","name","ourId","resolvedId","reportId","useEventCallback","onResolvedId","_theirRef","theirProps","_ourRef","ourRest","merged","mergeProps","wrapperProps","renderTrigger","renderProps"],"sources":["../../src/hooks/useTriggerElement.tsx"],"sourcesContent":["import * as React from 'react';\nimport { mergeProps } from '../lib/mergeProps';\nimport {\n isCloneableElement,\n renderTrigger,\n STATE_ARIA,\n unwrapFragment,\n type TriggerChildren,\n} from '../lib/renderTrigger';\nimport { warnOnce } from '../lib/dev';\nimport { FOCUSABLE_SELECTOR, getFirstTabbable, isFocusable, isHiddenInput } from '../lib/focus';\nimport { useMergedRefs } from './useMergedRefs';\nimport { useEventCallback } from './useEventCallback';\n\n/**\n * Options of {@link useTriggerElement}. (`triggerProps.ref`, the hook's second argument, may be an\n * inline callback: it is re-attached after each commit; a stable ref is attached once.)\n */\nexport interface UseTriggerElementOptions {\n /** Public name used in development warnings, e.g. `'Dialog.Trigger'`. */\n componentName: string;\n /**\n * `false` renders the 0.4 wrapper `<span>` around the children instead of cloning; the state\n * ARIA moves onto the element inside it, as for the automatic fallback. @default true\n */\n asChild?: boolean;\n /**\n * Called (from an effect) with the id the trigger element ends up with: the child's own `id` when\n * it has one, otherwise `triggerProps.id`. Roots store it for `aria-labelledby`.\n */\n onResolvedId?: (id: string) => void;\n /**\n * Context-menu mode (`openOnContext`): the trigger is a region, not a menu button, so its\n * element carries no `aria-haspopup`, `aria-expanded` or `aria-controls`. A cloned child and a\n * wrapper span do not receive them from `triggerProps` (the state-ARIA move of the wrapper span\n * is skipped too). A render-prop child still receives every trigger prop; when its element\n * carries them after a commit, they are removed from it and a development warning is logged\n * once (`<componentName>:context-state-aria`).\n * @default false\n */\n omitStateAria?: boolean;\n}\n\ntype UnknownProps = Record<string, unknown>;\n\n/** Roles that make an element no widget of its own. */\nconst GENERIC_ROLES: ReadonlySet<string> = new Set(['generic', 'none', 'presentation']);\n\n/** Whether a `role` value (attribute or prop) names a role other than a generic one. */\nfunction isNonGenericRole(role: unknown): boolean {\n if (typeof role !== 'string') return false;\n const first = role.trim().split(/\\s+/)[0];\n return first !== '' && !GENERIC_ROLES.has(first);\n}\n\n/** Whether a `tabIndex` prop puts its element in the tab order. */\nfunction isInTabOrder(tabIndex: unknown): boolean {\n if (typeof tabIndex === 'number') return tabIndex >= 0;\n return typeof tabIndex === 'string' && tabIndex.trim() !== '' && Number(tabIndex) >= 0;\n}\n\n/** Native controls, whose own role can carry the state ARIA. */\nconst NATIVE_CONTROL_SELECTOR = 'a[href], button, input, select, summary, textarea';\n\n/**\n * Whether `el` can carry the state ARIA: its `role` names a role other than a generic one, or it\n * has none and is a native control. A `<span>` or `<div>` without a role is generic, whatever its\n * `tabIndex` (axe `aria-allowed-attr`).\n */\nfunction isWidgetElement(el: Element): boolean {\n const role = el.getAttribute('role');\n if (role !== null && role.trim() !== '') return isNonGenericRole(role);\n return el.matches(NATIVE_CONTROL_SELECTOR);\n}\n\n/**\n * The element that acts as the trigger rendered as `el` (a cloned child, or the wrapper `<span>`\n * of `asChild={false}`, of text children and of the automatic fallback): `el` itself when it is a\n * widget (a native control, or an element given a role other than a generic one) in the tab order\n * by markup (`tabIndex >= 0`: a button, a span given `role=\"button\"` and `tabIndex={0}`); else the\n * first element inside it in the tab order by markup; else `el` when it is a widget out of the tab\n * order (a span given only `role=\"button\"`, a `<button tabIndex={-1}>`); else `null`. `tabIndex`\n * alone never makes a generic element the trigger: it cannot carry the state ARIA. The trigger's\n * state ARIA belongs on it, and focus returns to it ({@link getTriggerFocusTarget}). Read from the\n * markup, not `getFirstTabbable`: that skips an `inert` subtree, and the page around a trigger is\n * inert while its modal dialog is open. Internal (not exported from the package entry).\n */\nexport function getTriggerTarget(el: HTMLElement): HTMLElement | null {\n const widget = isWidgetElement(el);\n if (widget && el.tabIndex >= 0) return el;\n for (const candidate of el.querySelectorAll<HTMLElement>(FOCUSABLE_SELECTOR)) {\n if (!isHiddenInput(candidate) && candidate.tabIndex >= 0) return candidate;\n }\n return widget ? el : null;\n}\n\n/**\n * The element that takes focus for the trigger rendered as `trigger`: the one rule of every focus\n * return of Menu, Popover, Dialog and Drawer (Escape, outside press, item activation, Tab and\n * Shift+Tab, the Close part). It is the {@link getTriggerTarget} element, which carries the state\n * ARIA, when that can take focus now (a `<button tabIndex={-1}>` child; the button inside a\n * `tabIndex={-1}` wrapper span, or inside a span given only a `role`); else the first tabbable\n * element inside `trigger` (a wrapper span whose first control is disabled or hidden, with another\n * one after it); else `trigger` itself when it can take focus (a span holding only text, given a\n * `tabIndex` but no widget role); else `null`. Internal (not exported from the package entry).\n */\nexport function getTriggerFocusTarget(trigger: HTMLElement | null): HTMLElement | null {\n if (!trigger) return null;\n const target = getTriggerTarget(trigger);\n if (target && isFocusable(target)) return target;\n return getFirstTabbable(trigger) ?? (isFocusable(trigger) ? trigger : null);\n}\n\n/**\n * A read-only ref for `useRestoreFocus`'s `triggerRef` and `useDismiss`'s `anchorRef` (Menu,\n * Popover; the anchor is where a surface opened from the popup restores focus once its opener is\n * gone): resolved when it is read, to {@link getTriggerFocusTarget} of the element in\n * `triggerRef`, or to that element itself when nothing in it can take focus (the restore then goes\n * to the element next to where it is, as for any opener that cannot take focus). Stable while\n * `triggerRef` is.\n */\nexport function useTriggerFocusRef(\n triggerRef: React.RefObject<HTMLElement | null>,\n): React.RefObject<HTMLElement | null> {\n return React.useMemo(() => createTriggerFocusRef(triggerRef), [triggerRef]);\n}\n\nfunction createTriggerFocusRef(\n triggerRef: React.RefObject<HTMLElement | null>,\n): React.RefObject<HTMLElement | null> {\n return {\n get current() {\n const trigger = triggerRef.current;\n return trigger && (getTriggerFocusTarget(trigger) ?? trigger);\n },\n };\n}\n\nfunction isElementNode(value: unknown): value is Element {\n return typeof value === 'object' && value !== null && (value as Node).nodeType === 1;\n}\n\ntype StateAriaValues = Partial<Record<(typeof STATE_ARIA)[number], unknown>>;\n\n/** `props` without the state ARIA keys (context-menu mode). */\nfunction withoutStateAria(props: UnknownProps): UnknownProps {\n const rest = { ...props };\n for (const key of STATE_ARIA) delete rest[key];\n return rest;\n}\n\n/** The state ARIA keys present in `props` (a key given as `undefined` removes the attribute). */\nfunction pickStateAria(props: UnknownProps): StateAriaValues {\n const values: StateAriaValues = {};\n for (const key of STATE_ARIA) {\n if (key in props) values[key] = props[key];\n }\n return values;\n}\n\n/** Writes `values` onto `target` and returns a cleanup that restores its own attributes. */\nfunction moveStateAria(target: Element, values: StateAriaValues): () => void {\n const previous = Object.keys(values).map((key) => [key, target.getAttribute(key)] as const);\n for (const [key, value] of Object.entries(values)) {\n if (value === undefined || value === null) target.removeAttribute(key);\n else target.setAttribute(key, String(value));\n }\n return () => {\n for (const [key, value] of previous) {\n if (value === null) target.removeAttribute(key);\n else target.setAttribute(key, value);\n }\n };\n}\n\n/**\n * Renders a trigger (`Dialog.Trigger`, `Drawer.Trigger`, `Popover.Trigger`, `Menu.Trigger`,\n * `.Close`): puts `triggerProps` on the consumer's element.\n *\n * - **Single element child** (default): cloned with the trigger props merged in (`mergeProps`):\n * handlers composed (the child's run first; `preventDefault()` skips the trigger's), classes and\n * styles merged, the child's own `id` kept, and live `aria-expanded` / `aria-controls` /\n * `aria-haspopup` always winning over the child's values. The trigger ref and the child's own ref\n * are merged with {@link useMergedRefs}, so a ref that keeps its identity is attached once and\n * the element is not detached and re-attached on every render (stable positioning anchor and\n * focus-restore target). A Fragment around a single element (`<><Button /></>`) is unwrapped and\n * its element cloned.\n * - **`triggerProps.ref`** does not have to be stable: an inline callback or a fresh `mergeRefs(…)`\n * result is detached and re-attached after each commit (as React does for an inline ref), and a\n * state-setting ref (`ref: setAnchor`) never loops. Pass a stable ref (an object ref, a\n * `useCallback` or a state setter) so floating-ui's reference and restore targets are set once.\n * - **Render-prop child**: called with `triggerProps` (all of them, whatever `asChild` says).\n * - **`asChild={false}`**: the 0.4 wrapper `<span>` carrying the trigger props except the state\n * ARIA, which moves as in the automatic fallback below (so a button inside is announced as\n * opening the popup).\n * - **Text, a Fragment of several elements, several children**: a wrapper `<span>` (with a\n * development warning from `renderTrigger`) carrying the trigger props except the state ARIA,\n * which moves as in the automatic fallback below.\n * - **A wrapper span the consumer made the trigger** (a `role` such as `\"button\"` and\n * `tabIndex={0}` passed to the trigger, e.g. `<Menu.Trigger asChild={false} role=\"button\"\n * tabIndex={0}>Actions</Menu.Trigger>`): the span keeps the state ARIA, as the element that\n * takes focus and is announced ({@link getTriggerTarget}). A span given only such a role gets\n * it too (after mount) when nothing inside it is in the tab order; `tabIndex` alone leaves the\n * span generic, so the state ARIA moves as below.\n * - **Automatic fallback**: when the cloned child has not attached its ref by the end of the mount\n * layout effect (a custom component that neither forwards `ref` nor spreads props), the hook\n * switches once to the wrapper span — whose click handler catches the bubbling click, so the\n * trigger keeps working — and warns in development. The span keeps the other trigger props (`id`,\n * handlers, ref), but the state ARIA (`aria-haspopup`, `aria-expanded`, `aria-controls`), which\n * a generic span cannot carry, moves after each commit onto the first element inside it in the\n * tab order (the child's own values restored when it stops being that element), or is dropped\n * when there is none. A component that forwards `ref` but drops `onClick` cannot be detected.\n * - **Context-menu mode** (`omitStateAria`): a cloned child and a wrapper span get no\n * `aria-haspopup`, `aria-expanded` or `aria-controls` (nothing moves inside the span either); a\n * render-prop child receives them with the other props, and the ones it spreads are removed from\n * its element after each commit, with a one-time development warning.\n *\n * @param children The trigger's children.\n * @param triggerProps Props for the trigger element (`id`, state ARIA, handlers, `ref`; the ref may\n * change between renders, a stable one is attached once).\n * @param options See {@link UseTriggerElementOptions}.\n */\nexport function useTriggerElement<P>(\n children: TriggerChildren<P> | React.ReactNode,\n triggerProps: P,\n options: UseTriggerElementOptions,\n): React.ReactNode {\n const { componentName, asChild = true, onResolvedId, omitStateAria = false } = options;\n const [wrapperFallback, setWrapperFallback] = React.useState(false);\n\n const isRenderProp = typeof children === 'function';\n // A Fragment around one element is that element (children of a conditional expression).\n const content = isRenderProp ? null : unwrapFragment(children as React.ReactNode);\n const singleElement = isCloneableElement(content);\n const cloneable = asChild && !wrapperFallback && singleElement;\n const cloneTarget = cloneable ? (content as React.ReactElement<UnknownProps>) : null;\n const allProps = triggerProps as UnknownProps;\n const ourRef = allProps.ref as React.Ref<Element> | undefined;\n // The props this hook puts on an element itself (a render-prop child receives `triggerProps`).\n const ourProps = omitStateAria ? withoutStateAria(allProps) : allProps;\n // The cloned child's own `ref` prop is read to merge it (React 19 keeps `ref` in props).\n const childRef = cloneTarget\n ? (cloneTarget.props.ref as React.Ref<Element> | undefined)\n : undefined;\n\n const attachedRef = React.useRef<Element | null>(null);\n const detectAttach = React.useCallback((node: Element | null) => {\n attachedRef.current = isElementNode(node) ? node : null;\n }, []);\n const mergedRef = useMergedRefs<Element>(ourRef, childRef, detectAttach);\n\n React.useLayoutEffect(() => {\n if (!cloneable || attachedRef.current) return;\n warnOnce(\n `trigger-ref:${componentName}`,\n `${componentName}: its child did not attach the trigger ref (a component that neither forwards \\`ref\\` nor spreads its props). It is rendered inside a <span> wrapper instead; forward \\`ref\\` and spread props onto the element, or pass asChild={false}.`,\n );\n // C-HOOKS site 2: the child never attached its ref after mount; switch to the wrapper span once.\n setWrapperFallback(true);\n }, [cloneable, componentName]);\n\n // A wrapper span: the explicit one of `asChild={false}`, the automatic fallback of a single\n // element child, or children that cannot be cloned (text, several elements). The trigger is the\n // element inside, so the state ARIA, which a generic span cannot carry, goes to the first element\n // it rendered in the tab order — unless the consumer made the span itself the trigger (a widget\n // `role` and `tabIndex={0}`, see getTriggerTarget): then the span keeps it from the first render.\n // A span given only such a role gets it after mount when nothing inside it is in the tab order.\n const autoWrapper = asChild && wrapperFallback && singleElement;\n const wrapper = !isRenderProp && !cloneable;\n const wrapperIsTrigger =\n wrapper && isNonGenericRole(ourProps.role) && isInTabOrder(ourProps.tabIndex);\n const movedAria = wrapper && !wrapperIsTrigger && !omitStateAria ? pickStateAria(ourProps) : null;\n // No deps: runs after every commit of the trigger (which re-renders on every state change), so\n // the attributes follow the live state and the child's current first tabbable element. A new\n // target rendered by the child without a trigger commit is picked up at the next one.\n React.useLayoutEffect(() => {\n const span = attachedRef.current;\n if (!movedAria || !span) return undefined;\n const target = getTriggerTarget(span as HTMLElement);\n return target ? moveStateAria(target, movedAria) : undefined;\n });\n\n // Context-menu mode: the state ARIA a render-prop child spread onto its element is removed after\n // each commit (React writes it again only when a value changes). No deps: every commit.\n React.useLayoutEffect(() => {\n const el = attachedRef.current;\n if (!omitStateAria || !isRenderProp || !el) return;\n const spread = STATE_ARIA.filter((name) => el.hasAttribute(name));\n if (spread.length === 0) return;\n for (const name of spread) el.removeAttribute(name);\n warnOnce(\n `${componentName}:context-state-aria`,\n `${componentName}: the trigger element is a context-menu region (openOnContext), which is not a menu button: do not spread aria-haspopup, aria-expanded and aria-controls onto it.`,\n );\n });\n\n const ourId = typeof ourProps.id === 'string' ? ourProps.id : undefined;\n const childId =\n cloneTarget && typeof cloneTarget.props.id === 'string' ? cloneTarget.props.id : undefined;\n const resolvedId = childId ?? ourId;\n const reportId = useEventCallback(onResolvedId);\n React.useEffect(() => {\n if (resolvedId) reportId(resolvedId);\n }, [resolvedId, reportId]);\n\n if (cloneTarget) {\n const { ref: _theirRef, ...theirProps } = cloneTarget.props;\n const { ref: _ourRef, ...ourRest } = ourProps;\n const merged = mergeProps(ourRest, theirProps, { oursWin: STATE_ARIA });\n return React.cloneElement(cloneTarget, { ...merged, ref: mergedRef });\n }\n\n if (wrapper) {\n const { ref: _ourRef, ...ourRest } = ourProps;\n const wrapperProps: UnknownProps = { ...ourRest, ref: mergedRef };\n if (!wrapperIsTrigger || omitStateAria) for (const key of STATE_ARIA) delete wrapperProps[key];\n // The explicit 0.4 span renders the children as given. Otherwise `asChild` lets renderTrigger\n // warn about children it cannot clone; the automatic fallback (a single element, never cloned\n // again) warned above.\n return asChild\n ? renderTrigger(content, wrapperProps, { componentName, asChild: !autoWrapper })\n : renderTrigger(children, wrapperProps, { componentName, asChild: false });\n }\n\n // A render-prop child. In context-menu mode its element is found through the merged ref, so the\n // state ARIA it spreads can be removed.\n const renderProps = omitStateAria ? ({ ...allProps, ref: mergedRef } as P) : triggerProps;\n return renderTrigger(children, renderProps, { componentName, asChild: false });\n}\n"],"mappings":";;;;;;;;;AA8CA,IAAMC,oBAAqC,IAAI,IAAI;CAAC;CAAW;CAAQ;AAAc,CAAC;AAGtF,SAASC,EAAiB,GAAwB;CAChD,IAAI,OAAOC,KAAS,UAAU,OAAO;CACrC,IAAMC,IAAQD,EAAK,KAAK,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC;CACvC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;EACf,IAAM,EAAE,KAAK0B,GAAW,GAAGC,MAAe3B,EAAY,OAChD,EAAE,KAAK4B,GAAS,GAAGC,MAAYzB,GAC/B0B,IAASC,EAAWF,GAASF,GAAY,EAAE,SAAS5C,EAAW,CAAC;EACtE,OAAO7B,EAAM,aAAa8C,GAAa;GAAE,GAAG8B;GAAQ,KAAKpB;EAAU,CAAC;CACtE;CAEA,IAAIK,GAAS;EACX,IAAM,EAAE,KAAKa,GAAS,GAAGC,MAAYzB,GAC/B4B,IAA6B;GAAE,GAAGH;GAAS,KAAKnB;EAAU;EAChE,IAAI,CAACM,KAAoBX,GAAe,KAAK,IAAMvB,KAAOC,GAAY,OAAOiD,EAAalD;EAI1F,OAAOiB,IACHkC,EAAcvC,GAASsC,GAAc;GAAE;GAAe,SAAS,CAAClB;EAAY,CAAC,IAC7EmB,EAAcxC,GAAUuC,GAAc;GAAE;GAAe,SAAS;EAAM,CAAC;CAC7E;CAIA,IAAME,IAAc7B,IAAiB;EAAE,GAAGJ;EAAU,KAAKS;CAAU,IAAUR;CAC7E,OAAO+B,EAAcxC,GAAUyC,GAAa;EAAE;EAAe,SAAS;CAAM,CAAC;AAC/E"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";const e=require("./useEventCallback.cjs");let t=require("react");function n(e){return e.ctrlKey&&e.altKey&&e.key.length===1&&e.key!==` `}function r(e,t){return e.key.length!==1||e.metaKey||(e.ctrlKey||e.altKey)&&!n(e)?!1:e.key!==` `||t}function i(n){let{timeout:i=500}=n,a=e.useEventCallback(n.getItems),o=e.useEventCallback(n.onMatch),s=(0,t.useRef)(``),c=(0,t.useRef)(null),l=(0,t.useRef)(i);return(0,t.useEffect)(()=>{l.current=i},[i]),(0,t.useEffect)(()=>()=>{c.current!==null&&clearTimeout(c.current),c.current=null},[]),{onTypeahead:(0,t.useCallback)((e,t)=>{let n=s.current.length>0;if(!r(e,n))return!1;let i=s.current+e.key.toLowerCase();s.current=i,c.current!==null&&clearTimeout(c.current),c.current=setTimeout(()=>{s.current=``,c.current=null},l.current);let u=a().filter(e=>!e.disabled);if(u.length===0)return n;let d=i.length>1&&Array.from(i).every(e=>e===i[0])?i[0]:i,f=u.findIndex(e=>e.value===t),p=Math.max(f,0),m=[...u.slice(p),...u.slice(0,p)];d.length===1&&f!==-1&&(m=m.filter(e=>e.value!==t));let h=m.filter(e=>e.text.trim().toLowerCase().startsWith(d)).map(e=>e.value);return h.length===0?n:(o(h[0],h),!0)},[a,o]),isSearching:(0,t.useCallback)(()=>s.current.length>0,[])}}exports.isAltGraphCharacter=n,exports.useTypeahead=i;
|
|
2
|
+
//# sourceMappingURL=useTypeahead.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTypeahead.cjs","names":["useEventCallback","useRef","useCallback","require_useEventCallback","react","isAltGraphCharacter","event","isTypeaheadKey","searching","useTypeahead","options","getItems","onMatch","bufferRef","timerRef","timeoutRef","timeout","search","items","item","prefix","c","currentIndex","currentValue","start","candidates","matches"],"sources":["../../src/hooks/useTypeahead.ts"],"sourcesContent":["import { useCallback, useEffect, useRef } from 'react';\nimport type * as React from 'react';\nimport { useEventCallback } from './useEventCallback';\n\n/** An item that typeahead can move to. */\nexport interface TypeaheadItem {\n value: string;\n /** Text matched against the typed characters (case-insensitive prefix match). */\n text: string;\n /** Disabled items are skipped. */\n disabled?: boolean;\n}\n\n/** Options of {@link useTypeahead}. */\nexport interface UseTypeaheadOptions {\n /** Returns the items in navigation order, read at key time. */\n getItems: () => TypeaheadItem[];\n /**\n * Called with the value of the matched item, and with every item that matches the typed\n * characters in search order (`value` first), for a caller that passes over an item it cannot\n * move to.\n */\n onMatch: (value: string, matches: readonly string[]) => void;\n /** Milliseconds after the last key press before the typed prefix resets. @default 500 */\n timeout?: number;\n}\n\n/** Result of {@link useTypeahead}. */\nexport interface UseTypeaheadResult {\n /**\n * Handles a key press. Returns `true` when the key was consumed as typeahead: it matched an\n * item, or it continued a search (see `isSearching`), even when nothing matches, a Space\n * included. The caller should `preventDefault()`. Returns `false` for a key that is not\n * typeahead, and for the first character of a search when it matches nothing (so a closed\n * listbox can still open on it); that character still starts the search.\n *\n * @param event The keydown event (DOM or React).\n * @param currentValue The value of the focused or active item, or `null`.\n */\n onTypeahead: (event: KeyboardEvent | React.KeyboardEvent, currentValue: string | null) => boolean;\n /**\n * Whether a search is in progress: a printable key was typed less than `timeout` ms ago,\n * whether or not it matched. A Space typed now continues the search.\n */\n isSearching: () => boolean;\n}\n\n/**\n * A character typed with AltGr, which Windows reports as Ctrl+Alt (Polish `ł`, Romanian `ș`): text\n * input for typeahead, not a shortcut. Ctrl+Alt with a named key (Ctrl+Alt+ArrowDown) or with\n * Space (AltGr types no plain space) is a shortcut. Internal (not exported from the package entry).\n */\nexport function isAltGraphCharacter(event: KeyboardEvent | React.KeyboardEvent): boolean {\n return event.ctrlKey && event.altKey && event.key.length === 1 && event.key !== ' ';\n}\n\nfunction isTypeaheadKey(event: KeyboardEvent | React.KeyboardEvent, searching: boolean): boolean {\n if (event.key.length !== 1 || event.metaKey) return false;\n // Ctrl or Alt is a shortcut, except a character typed with AltGr.\n if ((event.ctrlKey || event.altKey) && !isAltGraphCharacter(event)) return false;\n // Space activates the focused item unless a search is in progress.\n return event.key !== ' ' || searching;\n}\n\n/**\n * Typeahead for lists, menus and trees (APG): printable characters typed within `timeout` build a\n * prefix; the next enabled item whose text starts with it (wrapping around from the current item)\n * is matched. Repeating one character cycles through the items that start with it. Characters\n * typed with AltGr (Ctrl+Alt on Windows) count; Ctrl, Alt or Meta shortcuts do not.\n *\n * @example\n * const { onTypeahead } = useTypeahead({ getItems, onMatch: focusValue });\n * const onKeyDown = (e) => { if (onTypeahead(e, focusedValue)) e.preventDefault(); };\n */\nexport function useTypeahead(options: UseTypeaheadOptions): UseTypeaheadResult {\n const { timeout = 500 } = options;\n const getItems = useEventCallback(options.getItems);\n const onMatch = useEventCallback(options.onMatch);\n const bufferRef = useRef('');\n const timerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n const timeoutRef = useRef(timeout);\n\n useEffect(() => {\n timeoutRef.current = timeout;\n }, [timeout]);\n\n useEffect(\n () => () => {\n if (timerRef.current !== null) clearTimeout(timerRef.current);\n timerRef.current = null;\n },\n [],\n );\n\n const onTypeahead = useCallback(\n (event: KeyboardEvent | React.KeyboardEvent, currentValue: string | null): boolean => {\n const searching = bufferRef.current.length > 0;\n if (!isTypeaheadKey(event, searching)) return false;\n\n const search = bufferRef.current + event.key.toLowerCase();\n bufferRef.current = search;\n if (timerRef.current !== null) clearTimeout(timerRef.current);\n timerRef.current = setTimeout(() => {\n bufferRef.current = '';\n timerRef.current = null;\n }, timeoutRef.current);\n\n const items = getItems().filter((item) => !item.disabled);\n // A search already in progress consumed this key even when nothing matches, so the caller\n // must not activate or commit. The first unmatched character still returns false.\n if (items.length === 0) return searching;\n\n const repeated = search.length > 1 && Array.from(search).every((c) => c === search[0]);\n const prefix = repeated ? search[0] : search;\n const currentIndex = items.findIndex((item) => item.value === currentValue);\n const start = Math.max(currentIndex, 0);\n let candidates = [...items.slice(start), ...items.slice(0, start)];\n // A single character moves on from the current item; a longer prefix may keep it.\n if (prefix.length === 1 && currentIndex !== -1) {\n candidates = candidates.filter((item) => item.value !== currentValue);\n }\n const matches = candidates\n .filter((item) => item.text.trim().toLowerCase().startsWith(prefix))\n .map((item) => item.value);\n if (matches.length === 0) return searching;\n onMatch(matches[0], matches);\n return true;\n },\n [getItems, onMatch],\n );\n\n const isSearching = useCallback(() => bufferRef.current.length > 0, []);\n\n return { onTypeahead, isSearching };\n}\n"],"mappings":"8EAoDA,SAAgBK,EAAoB,EAAqD,CACvF,OAAOC,EAAM,SAAWA,EAAM,QAAUA,EAAM,IAAI,SAAW,GAAKA,EAAM,MAAQ,GAClF,CAEA,SAASC,EAAe,EAA4C,EAA6B,CAK/F,OAJID,EAAM,IAAI,SAAW,GAAKA,EAAM,UAE/BA,EAAM,SAAWA,EAAM,SAAW,CAACD,EAAoBC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,EAAc,CAAC,EAClCG,EAAa,CAAC,GAAGP,EAAM,MAAMM,CAAK,EAAG,GAAGN,EAAM,MAAM,EAAGM,CAAK,CAAC,EAE7DJ,EAAO,SAAW,GAAKE,IAAiB,KAC1C,EAAaG,EAAW,OAAQ,GAASN,EAAK,QAAUI,CAAY,GAEtE,IAAMG,EAAUD,EACb,OAAQ,GAASN,EAAK,KAAK,KAAK,CAAC,CAAC,YAAY,CAAC,CAAC,WAAWC,CAAM,CAAC,CAAC,CACnE,IAAK,GAASD,EAAK,KAAK,EAG3B,OAFIO,EAAQ,SAAW,EAAUlB,GACjCI,EAAQc,EAAQ,GAAIA,CAAO,EACpB,GACT,EACA,CAACf,EAAUC,CAAO,CAKX,EAAa,aAAA,EAFFV,EAAAA,YAAAA,KAAkBW,EAAU,QAAQ,OAAS,EAAG,CAAC,CAE/C,CAAY,CACpC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useEventCallback as e } from "./useEventCallback.mjs";
|
|
3
|
+
import { useCallback as t, useEffect as n, useRef as r } from "react";
|
|
4
|
+
//#region src/hooks/useTypeahead.ts
|
|
5
|
+
function i(e) {
|
|
6
|
+
return e.ctrlKey && e.altKey && e.key.length === 1 && e.key !== " ";
|
|
7
|
+
}
|
|
8
|
+
function a(e, t) {
|
|
9
|
+
return e.key.length !== 1 || e.metaKey || (e.ctrlKey || e.altKey) && !i(e) ? !1 : e.key !== " " || t;
|
|
10
|
+
}
|
|
11
|
+
function o(i) {
|
|
12
|
+
let { timeout: o = 500 } = i, s = e(i.getItems), c = e(i.onMatch), l = r(""), u = r(null), d = r(o);
|
|
13
|
+
return n(() => {
|
|
14
|
+
d.current = o;
|
|
15
|
+
}, [o]), n(() => () => {
|
|
16
|
+
u.current !== null && clearTimeout(u.current), u.current = null;
|
|
17
|
+
}, []), {
|
|
18
|
+
onTypeahead: t((e, t) => {
|
|
19
|
+
let n = l.current.length > 0;
|
|
20
|
+
if (!a(e, n)) return !1;
|
|
21
|
+
let r = l.current + e.key.toLowerCase();
|
|
22
|
+
l.current = r, u.current !== null && clearTimeout(u.current), u.current = setTimeout(() => {
|
|
23
|
+
l.current = "", u.current = null;
|
|
24
|
+
}, d.current);
|
|
25
|
+
let i = s().filter((e) => !e.disabled);
|
|
26
|
+
if (i.length === 0) return n;
|
|
27
|
+
let o = r.length > 1 && Array.from(r).every((e) => e === r[0]) ? r[0] : r, f = i.findIndex((e) => e.value === t), p = Math.max(f, 0), m = [...i.slice(p), ...i.slice(0, p)];
|
|
28
|
+
o.length === 1 && f !== -1 && (m = m.filter((e) => e.value !== t));
|
|
29
|
+
let h = m.filter((e) => e.text.trim().toLowerCase().startsWith(o)).map((e) => e.value);
|
|
30
|
+
return h.length === 0 ? n : (c(h[0], h), !0);
|
|
31
|
+
}, [s, c]),
|
|
32
|
+
isSearching: t(() => l.current.length > 0, [])
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
//#endregion
|
|
36
|
+
export { i as isAltGraphCharacter, o as useTypeahead };
|
|
37
|
+
|
|
38
|
+
//# sourceMappingURL=useTypeahead.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTypeahead.mjs","names":["isAltGraphCharacter","event","isTypeaheadKey","searching","useTypeahead","options","getItems","useEventCallback","onMatch","bufferRef","useRef","timerRef","timeoutRef","timeout","useEffect","useCallback","search","items","item","prefix","c","currentIndex","currentValue","start","candidates","matches"],"sources":["../../src/hooks/useTypeahead.ts"],"sourcesContent":["import { useCallback, useEffect, useRef } from 'react';\nimport type * as React from 'react';\nimport { useEventCallback } from './useEventCallback';\n\n/** An item that typeahead can move to. */\nexport interface TypeaheadItem {\n value: string;\n /** Text matched against the typed characters (case-insensitive prefix match). */\n text: string;\n /** Disabled items are skipped. */\n disabled?: boolean;\n}\n\n/** Options of {@link useTypeahead}. */\nexport interface UseTypeaheadOptions {\n /** Returns the items in navigation order, read at key time. */\n getItems: () => TypeaheadItem[];\n /**\n * Called with the value of the matched item, and with every item that matches the typed\n * characters in search order (`value` first), for a caller that passes over an item it cannot\n * move to.\n */\n onMatch: (value: string, matches: readonly string[]) => void;\n /** Milliseconds after the last key press before the typed prefix resets. @default 500 */\n timeout?: number;\n}\n\n/** Result of {@link useTypeahead}. */\nexport interface UseTypeaheadResult {\n /**\n * Handles a key press. Returns `true` when the key was consumed as typeahead: it matched an\n * item, or it continued a search (see `isSearching`), even when nothing matches, a Space\n * included. The caller should `preventDefault()`. Returns `false` for a key that is not\n * typeahead, and for the first character of a search when it matches nothing (so a closed\n * listbox can still open on it); that character still starts the search.\n *\n * @param event The keydown event (DOM or React).\n * @param currentValue The value of the focused or active item, or `null`.\n */\n onTypeahead: (event: KeyboardEvent | React.KeyboardEvent, currentValue: string | null) => boolean;\n /**\n * Whether a search is in progress: a printable key was typed less than `timeout` ms ago,\n * whether or not it matched. A Space typed now continues the search.\n */\n isSearching: () => boolean;\n}\n\n/**\n * A character typed with AltGr, which Windows reports as Ctrl+Alt (Polish `ł`, Romanian `ș`): text\n * input for typeahead, not a shortcut. Ctrl+Alt with a named key (Ctrl+Alt+ArrowDown) or with\n * Space (AltGr types no plain space) is a shortcut. Internal (not exported from the package entry).\n */\nexport function isAltGraphCharacter(event: KeyboardEvent | React.KeyboardEvent): boolean {\n return event.ctrlKey && event.altKey && event.key.length === 1 && event.key !== ' ';\n}\n\nfunction isTypeaheadKey(event: KeyboardEvent | React.KeyboardEvent, searching: boolean): boolean {\n if (event.key.length !== 1 || event.metaKey) return false;\n // Ctrl or Alt is a shortcut, except a character typed with AltGr.\n if ((event.ctrlKey || event.altKey) && !isAltGraphCharacter(event)) return false;\n // Space activates the focused item unless a search is in progress.\n return event.key !== ' ' || searching;\n}\n\n/**\n * Typeahead for lists, menus and trees (APG): printable characters typed within `timeout` build a\n * prefix; the next enabled item whose text starts with it (wrapping around from the current item)\n * is matched. Repeating one character cycles through the items that start with it. Characters\n * typed with AltGr (Ctrl+Alt on Windows) count; Ctrl, Alt or Meta shortcuts do not.\n *\n * @example\n * const { onTypeahead } = useTypeahead({ getItems, onMatch: focusValue });\n * const onKeyDown = (e) => { if (onTypeahead(e, focusedValue)) e.preventDefault(); };\n */\nexport function useTypeahead(options: UseTypeaheadOptions): UseTypeaheadResult {\n const { timeout = 500 } = options;\n const getItems = useEventCallback(options.getItems);\n const onMatch = useEventCallback(options.onMatch);\n const bufferRef = useRef('');\n const timerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n const timeoutRef = useRef(timeout);\n\n useEffect(() => {\n timeoutRef.current = timeout;\n }, [timeout]);\n\n useEffect(\n () => () => {\n if (timerRef.current !== null) clearTimeout(timerRef.current);\n timerRef.current = null;\n },\n [],\n );\n\n const onTypeahead = useCallback(\n (event: KeyboardEvent | React.KeyboardEvent, currentValue: string | null): boolean => {\n const searching = bufferRef.current.length > 0;\n if (!isTypeaheadKey(event, searching)) return false;\n\n const search = bufferRef.current + event.key.toLowerCase();\n bufferRef.current = search;\n if (timerRef.current !== null) clearTimeout(timerRef.current);\n timerRef.current = setTimeout(() => {\n bufferRef.current = '';\n timerRef.current = null;\n }, timeoutRef.current);\n\n const items = getItems().filter((item) => !item.disabled);\n // A search already in progress consumed this key even when nothing matches, so the caller\n // must not activate or commit. The first unmatched character still returns false.\n if (items.length === 0) return searching;\n\n const repeated = search.length > 1 && Array.from(search).every((c) => c === search[0]);\n const prefix = repeated ? search[0] : search;\n const currentIndex = items.findIndex((item) => item.value === currentValue);\n const start = Math.max(currentIndex, 0);\n let candidates = [...items.slice(start), ...items.slice(0, start)];\n // A single character moves on from the current item; a longer prefix may keep it.\n if (prefix.length === 1 && currentIndex !== -1) {\n candidates = candidates.filter((item) => item.value !== currentValue);\n }\n const matches = candidates\n .filter((item) => item.text.trim().toLowerCase().startsWith(prefix))\n .map((item) => item.value);\n if (matches.length === 0) return searching;\n onMatch(matches[0], matches);\n return true;\n },\n [getItems, onMatch],\n );\n\n const isSearching = useCallback(() => bufferRef.current.length > 0, []);\n\n return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