@astryxdesign/core 0.1.2 → 0.1.3
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/CHANGELOG.md +165 -0
- package/README.md +12 -12
- package/dist/Avatar/Avatar.d.ts.map +1 -1
- package/dist/Avatar/Avatar.js +11 -5
- package/dist/Breadcrumbs/BreadcrumbItem.d.ts +1 -1
- package/dist/Breadcrumbs/BreadcrumbItem.d.ts.map +1 -1
- package/dist/Breadcrumbs/BreadcrumbItem.js +24 -5
- package/dist/Button/Button.d.ts.map +1 -1
- package/dist/Button/Button.js +2 -4
- package/dist/ButtonGroup/ButtonGroup.d.ts.map +1 -1
- package/dist/ButtonGroup/ButtonGroup.js +0 -1
- package/dist/Calendar/Calendar.d.ts +5 -4
- package/dist/Calendar/Calendar.d.ts.map +1 -1
- package/dist/Calendar/Calendar.js +82 -43
- package/dist/Calendar/hooks/index.d.ts +0 -2
- package/dist/Calendar/hooks/index.d.ts.map +1 -1
- package/dist/Calendar/hooks/index.js +1 -2
- package/dist/Calendar/index.d.ts +3 -3
- package/dist/Calendar/index.d.ts.map +1 -1
- package/dist/Calendar/index.js +1 -1
- package/dist/Calendar/styles.d.ts +3 -9
- package/dist/Calendar/styles.d.ts.map +1 -1
- package/dist/Calendar/styles.js +3 -11
- package/dist/Carousel/Carousel.d.ts.map +1 -1
- package/dist/Carousel/Carousel.js +17 -3
- package/dist/Center/Center.d.ts +11 -1
- package/dist/Center/Center.d.ts.map +1 -1
- package/dist/Center/Center.js +9 -3
- package/dist/Chat/ChatComposerInput.d.ts.map +1 -1
- package/dist/Chat/ChatComposerInput.js +0 -1
- package/dist/Chat/ChatMessageList.d.ts +14 -1
- package/dist/Chat/ChatMessageList.d.ts.map +1 -1
- package/dist/Chat/ChatMessageList.js +2 -0
- package/dist/Chat/useTriggerMenu.d.ts +8 -1
- package/dist/Chat/useTriggerMenu.d.ts.map +1 -1
- package/dist/Chat/useTriggerMenu.js +15 -3
- package/dist/CheckboxInput/CheckboxInput.d.ts +23 -2
- package/dist/CheckboxInput/CheckboxInput.d.ts.map +1 -1
- package/dist/CheckboxInput/CheckboxInput.js +51 -9
- package/dist/CheckboxList/CheckboxList.d.ts +13 -1
- package/dist/CheckboxList/CheckboxList.d.ts.map +1 -1
- package/dist/CheckboxList/CheckboxList.js +39 -9
- package/dist/CheckboxList/CheckboxListContext.d.ts +7 -0
- package/dist/CheckboxList/CheckboxListContext.d.ts.map +1 -1
- package/dist/CheckboxList/CheckboxListItem.d.ts.map +1 -1
- package/dist/CheckboxList/CheckboxListItem.js +0 -1
- package/dist/Citation/Citation.d.ts.map +1 -1
- package/dist/Citation/Citation.js +9 -5
- package/dist/CodeBlock/CodeBlock.d.ts.map +1 -1
- package/dist/CodeBlock/CodeBlock.js +51 -37
- package/dist/CommandPalette/CommandPalette.d.ts.map +1 -1
- package/dist/CommandPalette/CommandPalette.js +5 -5
- package/dist/ContextMenu/ContextMenu.d.ts +4 -5
- package/dist/ContextMenu/ContextMenu.d.ts.map +1 -1
- package/dist/ContextMenu/ContextMenu.js +93 -11
- package/dist/DateInput/DateInput.d.ts +23 -1
- package/dist/DateInput/DateInput.d.ts.map +1 -1
- package/dist/DateInput/DateInput.js +167 -99
- package/dist/DateRangeInput/DateRangeInput.d.ts +23 -1
- package/dist/DateRangeInput/DateRangeInput.d.ts.map +1 -1
- package/dist/DateRangeInput/DateRangeInput.js +42 -9
- package/dist/DateTimeInput/DateTimeInput.d.ts +35 -2
- package/dist/DateTimeInput/DateTimeInput.d.ts.map +1 -1
- package/dist/DateTimeInput/DateTimeInput.js +78 -15
- package/dist/Dialog/Dialog.d.ts.map +1 -1
- package/dist/Dialog/Dialog.js +12 -0
- package/dist/DropdownMenu/DropdownMenu.d.ts +1 -8
- package/dist/DropdownMenu/DropdownMenu.d.ts.map +1 -1
- package/dist/DropdownMenu/DropdownMenu.js +42 -14
- package/dist/Field/Field.d.ts +19 -2
- package/dist/Field/Field.d.ts.map +1 -1
- package/dist/Field/Field.js +4 -0
- package/dist/Field/FieldLabel.d.ts +21 -2
- package/dist/Field/FieldLabel.d.ts.map +1 -1
- package/dist/Field/FieldLabel.js +41 -26
- package/dist/FileInput/FileInput.d.ts +22 -1
- package/dist/FileInput/FileInput.d.ts.map +1 -1
- package/dist/FileInput/FileInput.js +56 -10
- package/dist/Grid/Grid.d.ts +11 -1
- package/dist/Grid/Grid.d.ts.map +1 -1
- package/dist/Grid/Grid.js +32 -6
- package/dist/InputGroup/InputGroup.d.ts +4 -3
- package/dist/InputGroup/InputGroup.d.ts.map +1 -1
- package/dist/InputGroup/InputGroup.js +16 -6
- package/dist/InputGroup/InputGroupContext.d.ts +4 -0
- package/dist/InputGroup/InputGroupContext.d.ts.map +1 -1
- package/dist/InputGroup/InputGroupContext.js +2 -2
- package/dist/InputGroup/groupStyles.d.ts +1 -1
- package/dist/InputGroup/groupStyles.d.ts.map +1 -1
- package/dist/InputGroup/groupStyles.js +3 -3
- package/dist/InputGroup/index.d.ts +1 -0
- package/dist/InputGroup/index.d.ts.map +1 -1
- package/dist/Kbd/Kbd.d.ts.map +1 -1
- package/dist/Kbd/Kbd.js +33 -1
- package/dist/Layer/layerAnimations.stylex.d.ts +4 -0
- package/dist/Layer/layerAnimations.stylex.d.ts.map +1 -1
- package/dist/Layer/layerAnimations.stylex.js +8 -4
- package/dist/Layer/useLayer.d.ts +10 -0
- package/dist/Layer/useLayer.d.ts.map +1 -1
- package/dist/Layer/useLayer.js +64 -9
- package/dist/Layout/Layout.d.ts +4 -11
- package/dist/Layout/Layout.d.ts.map +1 -1
- package/dist/Layout/Layout.js +10 -11
- package/dist/Layout/LayoutFooter.d.ts +2 -2
- package/dist/Layout/LayoutFooter.d.ts.map +1 -1
- package/dist/Layout/LayoutHeader.d.ts +2 -2
- package/dist/Layout/LayoutHeader.d.ts.map +1 -1
- package/dist/Layout/LayoutPanel.d.ts +2 -2
- package/dist/Layout/LayoutPanel.d.ts.map +1 -1
- package/dist/Layout/padding.stylex.d.ts +51 -0
- package/dist/Layout/padding.stylex.d.ts.map +1 -1
- package/dist/Layout/padding.stylex.js +63 -0
- package/dist/Lightbox/Lightbox.d.ts.map +1 -1
- package/dist/Lightbox/Lightbox.js +4 -2
- package/dist/Link/Link.d.ts +16 -1
- package/dist/Link/Link.d.ts.map +1 -1
- package/dist/Link/Link.js +18 -7
- package/dist/Markdown/Markdown.d.ts.map +1 -1
- package/dist/Markdown/Markdown.js +7 -0
- package/dist/MoreMenu/MoreMenu.d.ts +1 -7
- package/dist/MoreMenu/MoreMenu.d.ts.map +1 -1
- package/dist/MoreMenu/MoreMenu.js +0 -2
- package/dist/MultiSelector/MultiSelector.d.ts +27 -2
- package/dist/MultiSelector/MultiSelector.d.ts.map +1 -1
- package/dist/MultiSelector/MultiSelector.js +141 -42
- package/dist/MultiSelector/hooks.d.ts +12 -1
- package/dist/MultiSelector/hooks.d.ts.map +1 -1
- package/dist/MultiSelector/hooks.js +14 -1
- package/dist/NavMenu/NavHeadingMenu.d.ts.map +1 -1
- package/dist/NavMenu/NavHeadingMenu.js +34 -3
- package/dist/NumberInput/NumberInput.d.ts +23 -2
- package/dist/NumberInput/NumberInput.d.ts.map +1 -1
- package/dist/NumberInput/NumberInput.js +62 -12
- package/dist/Pagination/Pagination.d.ts +1 -1
- package/dist/Pagination/Pagination.d.ts.map +1 -1
- package/dist/Pagination/Pagination.js +15 -1
- package/dist/Popover/Popover.d.ts +18 -2
- package/dist/Popover/Popover.d.ts.map +1 -1
- package/dist/Popover/Popover.js +5 -2
- package/dist/Popover/usePopover.d.ts +38 -3
- package/dist/Popover/usePopover.d.ts.map +1 -1
- package/dist/Popover/usePopover.js +24 -9
- package/dist/PowerSearch/PowerSearch.d.ts +11 -1
- package/dist/PowerSearch/PowerSearch.d.ts.map +1 -1
- package/dist/PowerSearch/PowerSearch.js +6 -1
- package/dist/ProgressBar/ProgressBar.d.ts.map +1 -1
- package/dist/ProgressBar/ProgressBar.js +3 -5
- package/dist/RadioList/RadioList.d.ts +20 -2
- package/dist/RadioList/RadioList.d.ts.map +1 -1
- package/dist/RadioList/RadioList.js +105 -9
- package/dist/RadioList/RadioListItem.d.ts.map +1 -1
- package/dist/RadioList/RadioListItem.js +13 -2
- package/dist/SegmentedControl/SegmentedControl.d.ts +13 -2
- package/dist/SegmentedControl/SegmentedControl.d.ts.map +1 -1
- package/dist/SegmentedControl/SegmentedControl.js +78 -44
- package/dist/SegmentedControl/SegmentedControlContext.d.ts +7 -0
- package/dist/SegmentedControl/SegmentedControlContext.d.ts.map +1 -1
- package/dist/SegmentedControl/SegmentedControlItem.d.ts.map +1 -1
- package/dist/SegmentedControl/SegmentedControlItem.js +13 -2
- package/dist/Selector/Selector.d.ts +24 -1
- package/dist/Selector/Selector.d.ts.map +1 -1
- package/dist/Selector/Selector.js +122 -43
- package/dist/Selector/hooks.d.ts +8 -1
- package/dist/Selector/hooks.d.ts.map +1 -1
- package/dist/Selector/hooks.js +14 -1
- package/dist/SideNav/SideNavHeading.d.ts.map +1 -1
- package/dist/SideNav/SideNavHeading.js +2 -0
- package/dist/SideNav/SideNavItem.d.ts.map +1 -1
- package/dist/SideNav/SideNavItem.js +1 -1
- package/dist/Skeleton/Skeleton.d.ts.map +1 -1
- package/dist/Skeleton/Skeleton.js +8 -2
- package/dist/Slider/Slider.d.ts +21 -0
- package/dist/Slider/Slider.d.ts.map +1 -1
- package/dist/Slider/Slider.js +36 -9
- package/dist/Spinner/Spinner.d.ts.map +1 -1
- package/dist/Spinner/Spinner.js +1 -1
- package/dist/Stack/Stack.d.ts +38 -23
- package/dist/Stack/Stack.d.ts.map +1 -1
- package/dist/Stack/Stack.js +25 -1
- package/dist/Stack/StackItem.d.ts +12 -23
- package/dist/Stack/StackItem.d.ts.map +1 -1
- package/dist/Stack/StackItem.js +8 -1
- package/dist/Switch/Switch.d.ts +23 -2
- package/dist/Switch/Switch.d.ts.map +1 -1
- package/dist/Switch/Switch.js +41 -11
- package/dist/TabList/Tab.d.ts.map +1 -1
- package/dist/TabList/Tab.js +6 -0
- package/dist/TabList/TabList.d.ts +16 -4
- package/dist/TabList/TabList.d.ts.map +1 -1
- package/dist/TabList/TabList.js +87 -10
- package/dist/TabList/TabListContext.d.ts +5 -0
- package/dist/TabList/TabListContext.d.ts.map +1 -1
- package/dist/TabList/TabListContext.js +5 -0
- package/dist/TabList/TabMenu.d.ts.map +1 -1
- package/dist/TabList/TabMenu.js +6 -1
- package/dist/Table/BaseTable.d.ts.map +1 -1
- package/dist/Table/BaseTable.js +11 -8
- package/dist/Table/Table.d.ts.map +1 -1
- package/dist/Table/Table.js +10 -1
- package/dist/Table/TableCell.d.ts +8 -1
- package/dist/Table/TableCell.d.ts.map +1 -1
- package/dist/Table/TableCell.js +10 -10
- package/dist/Table/TableHeaderCell.d.ts +8 -1
- package/dist/Table/TableHeaderCell.d.ts.map +1 -1
- package/dist/Table/TableHeaderCell.js +16 -16
- package/dist/Table/index.d.ts +2 -1
- package/dist/Table/index.d.ts.map +1 -1
- package/dist/Table/index.js +2 -2
- package/dist/Table/plugins/pagination/paginateData.d.ts +2 -1
- package/dist/Table/plugins/pagination/paginateData.d.ts.map +1 -1
- package/dist/Table/plugins/pagination/paginateData.js +8 -3
- package/dist/Table/plugins/pagination/useTablePagination.d.ts.map +1 -1
- package/dist/Table/plugins/pagination/useTablePagination.js +6 -1
- package/dist/Table/plugins/sortable/useTableSortable.d.ts.map +1 -1
- package/dist/Table/plugins/sortable/useTableSortable.js +59 -3
- package/dist/Table/tableContextMenu.d.ts +33 -0
- package/dist/Table/tableContextMenu.d.ts.map +1 -0
- package/dist/Table/tableContextMenu.js +133 -0
- package/dist/Table/types.d.ts +66 -0
- package/dist/Table/types.d.ts.map +1 -1
- package/dist/TextArea/TextArea.d.ts +22 -1
- package/dist/TextArea/TextArea.d.ts.map +1 -1
- package/dist/TextArea/TextArea.js +41 -9
- package/dist/TextInput/TextInput.d.ts +23 -2
- package/dist/TextInput/TextInput.d.ts.map +1 -1
- package/dist/TextInput/TextInput.js +55 -10
- package/dist/TimeInput/TimeInput.d.ts +23 -1
- package/dist/TimeInput/TimeInput.d.ts.map +1 -1
- package/dist/TimeInput/TimeInput.js +147 -76
- package/dist/Toast/Toast.d.ts.map +1 -1
- package/dist/Toast/Toast.js +14 -0
- package/dist/Toast/ToastViewport.d.ts.map +1 -1
- package/dist/Toast/ToastViewport.js +131 -3
- package/dist/Tokenizer/Tokenizer.d.ts +12 -1
- package/dist/Tokenizer/Tokenizer.d.ts.map +1 -1
- package/dist/Tokenizer/Tokenizer.js +26 -4
- package/dist/Toolbar/Toolbar.d.ts +3 -3
- package/dist/Toolbar/Toolbar.d.ts.map +1 -1
- package/dist/Toolbar/Toolbar.js +51 -7
- package/dist/Tooltip/useTooltip.d.ts.map +1 -1
- package/dist/Tooltip/useTooltip.js +56 -9
- package/dist/TopNav/TopNavHeading.d.ts +7 -1
- package/dist/TopNav/TopNavHeading.d.ts.map +1 -1
- package/dist/TopNav/TopNavHeading.js +8 -0
- package/dist/TreeList/TreeList.d.ts +1 -1
- package/dist/TreeList/TreeList.d.ts.map +1 -1
- package/dist/TreeList/TreeList.js +72 -2
- package/dist/TreeList/TreeListItem.d.ts +11 -1
- package/dist/TreeList/TreeListItem.d.ts.map +1 -1
- package/dist/TreeList/TreeListItem.js +51 -12
- package/dist/TreeList/treeListItem.markers.stylex.d.ts +16 -0
- package/dist/TreeList/treeListItem.markers.stylex.d.ts.map +1 -0
- package/dist/TreeList/treeListItem.markers.stylex.js +22 -0
- package/dist/Typeahead/BaseTypeahead.d.ts +13 -0
- package/dist/Typeahead/BaseTypeahead.d.ts.map +1 -1
- package/dist/Typeahead/BaseTypeahead.js +69 -6
- package/dist/Typeahead/Typeahead.d.ts +26 -3
- package/dist/Typeahead/Typeahead.d.ts.map +1 -1
- package/dist/Typeahead/Typeahead.js +65 -29
- package/dist/VisuallyHidden/VisuallyHidden.d.ts +61 -0
- package/dist/VisuallyHidden/VisuallyHidden.d.ts.map +1 -0
- package/dist/VisuallyHidden/VisuallyHidden.js +65 -0
- package/dist/VisuallyHidden/index.d.ts +11 -0
- package/dist/VisuallyHidden/index.d.ts.map +1 -0
- package/dist/VisuallyHidden/index.js +13 -0
- package/dist/astryx.css +18 -0
- package/dist/astryx.umd.js +55 -55
- package/dist/astryx.umd.js.map +4 -4
- package/dist/hooks/focusableSelector.d.ts +22 -0
- package/dist/hooks/focusableSelector.d.ts.map +1 -0
- package/dist/hooks/focusableSelector.js +24 -0
- package/dist/hooks/index.d.ts +12 -2
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +7 -2
- package/dist/hooks/useAnnounce.d.ts +40 -0
- package/dist/hooks/useAnnounce.d.ts.map +1 -0
- package/dist/hooks/useAnnounce.js +142 -0
- package/dist/hooks/useClickableContainer.d.ts +16 -1
- package/dist/hooks/useClickableContainer.d.ts.map +1 -1
- package/dist/hooks/useClickableContainer.js +16 -4
- package/dist/hooks/useEntryAnimation.d.ts.map +1 -1
- package/dist/hooks/useEntryAnimation.js +4 -4
- package/dist/hooks/useFocusTrap.d.ts +18 -0
- package/dist/hooks/useFocusTrap.d.ts.map +1 -1
- package/dist/hooks/useFocusTrap.js +87 -3
- package/dist/hooks/useGridFocus.d.ts +88 -1
- package/dist/hooks/useGridFocus.d.ts.map +1 -1
- package/dist/hooks/useGridFocus.js +261 -62
- package/dist/hooks/useKeyboardHint.d.ts +82 -0
- package/dist/hooks/useKeyboardHint.d.ts.map +1 -0
- package/dist/hooks/useKeyboardHint.js +220 -0
- package/dist/hooks/useListFocus.d.ts +78 -7
- package/dist/hooks/useListFocus.d.ts.map +1 -1
- package/dist/hooks/useListFocus.js +305 -52
- package/dist/hooks/useLongPress.d.ts +21 -0
- package/dist/hooks/useLongPress.d.ts.map +1 -0
- package/dist/hooks/useLongPress.js +89 -0
- package/dist/hooks/useTreeFocus.d.ts +157 -0
- package/dist/hooks/useTreeFocus.d.ts.map +1 -0
- package/dist/hooks/useTreeFocus.js +337 -0
- package/dist/hooks/useTypeahead.d.ts +63 -0
- package/dist/hooks/useTypeahead.d.ts.map +1 -0
- package/dist/hooks/useTypeahead.js +117 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/utils/dateTypes.d.ts +12 -0
- package/dist/utils/dateTypes.d.ts.map +1 -1
- package/dist/utils/dateTypes.js +41 -1
- package/dist/utils/index.d.ts +4 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +3 -1
- package/dist/utils/inputAria.d.ts +29 -0
- package/dist/utils/inputAria.d.ts.map +1 -0
- package/dist/utils/inputAria.js +30 -0
- package/dist/utils/timeParser.d.ts.map +1 -1
- package/dist/utils/timeParser.js +5 -2
- package/docs.mjs +2 -2
- package/package.json +12 -8
- package/src/Avatar/Avatar.test.tsx +37 -0
- package/src/Avatar/Avatar.tsx +10 -5
- package/src/Breadcrumbs/BreadcrumbItem.tsx +25 -7
- package/src/Breadcrumbs/Breadcrumbs.test.tsx +31 -10
- package/src/Button/Button.tsx +3 -16
- package/src/ButtonGroup/ButtonGroup.test.tsx +9 -9
- package/src/ButtonGroup/ButtonGroup.tsx +0 -1
- package/src/Calendar/Calendar.doc.mjs +4 -4
- package/src/Calendar/Calendar.test.tsx +168 -30
- package/src/Calendar/Calendar.tsx +121 -66
- package/src/Calendar/hooks/index.ts +0 -6
- package/src/Calendar/index.ts +1 -3
- package/src/Calendar/styles.ts +4 -9
- package/src/Carousel/Carousel.doc.mjs +7 -1
- package/src/Carousel/Carousel.test.tsx +20 -0
- package/src/Carousel/Carousel.tsx +16 -1
- package/src/Center/Center.doc.mjs +12 -2
- package/src/Center/Center.tsx +28 -3
- package/src/Chat/ChatComposerInput.test.tsx +26 -7
- package/src/Chat/ChatComposerInput.tsx +0 -1
- package/src/Chat/ChatDictationButton.doc.mjs +1 -1
- package/src/Chat/ChatMessageList.doc.mjs +8 -0
- package/src/Chat/ChatMessageList.test.tsx +18 -0
- package/src/Chat/ChatMessageList.tsx +16 -0
- package/src/Chat/useTriggerMenu.tsx +22 -4
- package/src/CheckboxInput/CheckboxInput.doc.mjs +10 -0
- package/src/CheckboxInput/CheckboxInput.test.tsx +172 -27
- package/src/CheckboxInput/CheckboxInput.tsx +78 -6
- package/src/CheckboxList/CheckboxList.doc.mjs +9 -0
- package/src/CheckboxList/CheckboxList.test.tsx +192 -26
- package/src/CheckboxList/CheckboxList.tsx +56 -3
- package/src/CheckboxList/CheckboxListContext.tsx +7 -0
- package/src/CheckboxList/CheckboxListItem.tsx +0 -3
- package/src/Citation/Citation.doc.mjs +10 -0
- package/src/Citation/Citation.test.tsx +121 -0
- package/src/Citation/Citation.tsx +15 -3
- package/src/CodeBlock/CodeBlock.test.tsx +115 -0
- package/src/CodeBlock/CodeBlock.tsx +63 -33
- package/src/CommandPalette/CommandPalette.test.tsx +47 -1
- package/src/CommandPalette/CommandPalette.tsx +9 -21
- package/src/ContextMenu/ContextMenu.doc.mjs +4 -4
- package/src/ContextMenu/ContextMenu.test.tsx +155 -1
- package/src/ContextMenu/ContextMenu.tsx +113 -16
- package/src/DateInput/DateInput.doc.mjs +286 -56
- package/src/DateInput/DateInput.test.tsx +248 -2
- package/src/DateInput/DateInput.tsx +196 -100
- package/src/DateRangeInput/DateRangeInput.doc.mjs +251 -46
- package/src/DateRangeInput/DateRangeInput.test.tsx +182 -20
- package/src/DateRangeInput/DateRangeInput.tsx +63 -5
- package/src/DateTimeInput/DateTimeInput.doc.mjs +368 -67
- package/src/DateTimeInput/DateTimeInput.test.tsx +279 -11
- package/src/DateTimeInput/DateTimeInput.tsx +125 -17
- package/src/Dialog/Dialog.doc.mjs +2 -2
- package/src/Dialog/Dialog.tsx +12 -0
- package/src/DropdownMenu/DropdownMenu.doc.mjs +1 -8
- package/src/DropdownMenu/DropdownMenu.test.tsx +56 -42
- package/src/DropdownMenu/DropdownMenu.tsx +52 -18
- package/src/Field/Field.doc.mjs +59 -18
- package/src/Field/Field.test.tsx +32 -0
- package/src/Field/Field.tsx +23 -5
- package/src/Field/FieldLabel.tsx +55 -17
- package/src/FileInput/FileInput.doc.mjs +17 -0
- package/src/FileInput/FileInput.test.tsx +283 -49
- package/src/FileInput/FileInput.tsx +76 -4
- package/src/Grid/Grid.doc.mjs +17 -4
- package/src/Grid/Grid.test.tsx +43 -30
- package/src/Grid/Grid.tsx +38 -3
- package/src/Icon/Icon.doc.mjs +3 -3
- package/src/InputGroup/InputGroup.doc.mjs +111 -23
- package/src/InputGroup/InputGroup.test.tsx +257 -60
- package/src/InputGroup/InputGroup.tsx +23 -5
- package/src/InputGroup/InputGroupContext.ts +9 -4
- package/src/InputGroup/groupStyles.ts +7 -1
- package/src/InputGroup/index.ts +1 -0
- package/src/Kbd/Kbd.test.tsx +22 -4
- package/src/Kbd/Kbd.tsx +35 -3
- package/src/Layer/layerAnimations.stylex.ts +20 -4
- package/src/Layer/useLayer.doc.mjs +5 -0
- package/src/Layer/useLayer.test.tsx +111 -0
- package/src/Layer/useLayer.tsx +90 -9
- package/src/Layout/Layout.tsx +8 -16
- package/src/Layout/LayoutFooter.doc.mjs +4 -4
- package/src/Layout/LayoutFooter.tsx +3 -3
- package/src/Layout/LayoutHeader.doc.mjs +4 -4
- package/src/Layout/LayoutHeader.tsx +3 -3
- package/src/Layout/LayoutPanel.tsx +3 -3
- package/src/Layout/padding.stylex.ts +52 -0
- package/src/Lightbox/Lightbox.doc.mjs +9 -0
- package/src/Lightbox/Lightbox.test.tsx +53 -5
- package/src/Lightbox/Lightbox.tsx +9 -4
- package/src/Link/Link.doc.mjs +14 -0
- package/src/Link/Link.test.tsx +50 -0
- package/src/Link/Link.tsx +39 -4
- package/src/Markdown/Markdown.test.tsx +11 -0
- package/src/Markdown/Markdown.tsx +7 -0
- package/src/MetadataList/MetadataListItem.doc.mjs +4 -0
- package/src/MoreMenu/MoreMenu.doc.mjs +2 -17
- package/src/MoreMenu/MoreMenu.tsx +0 -9
- package/src/MultiSelector/MultiSelector.doc.mjs +30 -0
- package/src/MultiSelector/MultiSelector.test.tsx +375 -8
- package/src/MultiSelector/MultiSelector.tsx +194 -48
- package/src/MultiSelector/hooks.ts +27 -0
- package/src/NavMenu/NavHeadingMenu.test.tsx +77 -1
- package/src/NavMenu/NavHeadingMenu.tsx +50 -3
- package/src/NumberInput/NumberInput.doc.mjs +17 -0
- package/src/NumberInput/NumberInput.test.tsx +242 -40
- package/src/NumberInput/NumberInput.tsx +89 -11
- package/src/Pagination/Pagination.doc.mjs +3 -3
- package/src/Pagination/Pagination.test.tsx +117 -5
- package/src/Pagination/Pagination.tsx +21 -1
- package/src/Popover/Popover.doc.mjs +26 -0
- package/src/Popover/Popover.test.tsx +121 -0
- package/src/Popover/Popover.tsx +23 -2
- package/src/Popover/usePopover.doc.mjs +9 -3
- package/src/Popover/usePopover.tsx +70 -12
- package/src/PowerSearch/PowerSearch.doc.mjs +15 -0
- package/src/PowerSearch/PowerSearch.test.tsx +97 -1
- package/src/PowerSearch/PowerSearch.tsx +16 -3
- package/src/ProgressBar/ProgressBar.test.tsx +34 -26
- package/src/ProgressBar/ProgressBar.tsx +3 -4
- package/src/RadioList/RadioList.doc.mjs +9 -0
- package/src/RadioList/RadioList.test.tsx +252 -16
- package/src/RadioList/RadioList.tsx +166 -10
- package/src/RadioList/RadioListItem.tsx +14 -2
- package/src/SegmentedControl/SegmentedControl.doc.mjs +9 -0
- package/src/SegmentedControl/SegmentedControl.test.tsx +214 -42
- package/src/SegmentedControl/SegmentedControl.tsx +102 -54
- package/src/SegmentedControl/SegmentedControlContext.ts +7 -0
- package/src/SegmentedControl/SegmentedControlItem.tsx +14 -1
- package/src/SelectableCard/SelectableCard.doc.mjs +1 -1
- package/src/Selector/Selector.doc.mjs +26 -0
- package/src/Selector/Selector.test.tsx +387 -15
- package/src/Selector/Selector.tsx +175 -67
- package/src/Selector/hooks.ts +23 -0
- package/src/SideNav/SideNav.test.tsx +48 -0
- package/src/SideNav/SideNavHeading.tsx +8 -2
- package/src/SideNav/SideNavItem.tsx +2 -4
- package/src/Skeleton/Skeleton.test.tsx +25 -0
- package/src/Skeleton/Skeleton.tsx +11 -1
- package/src/Slider/Slider.doc.mjs +15 -0
- package/src/Slider/Slider.test.tsx +155 -2
- package/src/Slider/Slider.tsx +53 -5
- package/src/Spinner/Spinner.tsx +7 -1
- package/src/Stack/Stack.doc.mjs +77 -0
- package/src/Stack/Stack.test.tsx +55 -5
- package/src/Stack/Stack.tsx +73 -24
- package/src/Stack/StackItem.test.tsx +23 -0
- package/src/Stack/StackItem.tsx +20 -23
- package/src/Switch/Switch.doc.mjs +15 -0
- package/src/Switch/Switch.test.tsx +162 -27
- package/src/Switch/Switch.tsx +61 -21
- package/src/TabList/Tab.tsx +6 -0
- package/src/TabList/TabList.doc.mjs +6 -0
- package/src/TabList/TabList.test.tsx +251 -0
- package/src/TabList/TabList.tsx +103 -12
- package/src/TabList/TabListContext.ts +7 -3
- package/src/TabList/TabMenu.tsx +6 -3
- package/src/Table/BaseTable.tsx +21 -17
- package/src/Table/Table.doc.mjs +2 -0
- package/src/Table/Table.test.tsx +10 -0
- package/src/Table/Table.tsx +8 -0
- package/src/Table/TableCell.tsx +25 -23
- package/src/Table/TableHeaderCell.tsx +28 -29
- package/src/Table/index.ts +3 -2
- package/src/Table/plugins/pagination/paginateData.ts +10 -3
- package/src/Table/plugins/pagination/useTablePagination.test.tsx +16 -0
- package/src/Table/plugins/pagination/useTablePagination.tsx +8 -1
- package/src/Table/plugins/sortable/useTableSortable.test.tsx +91 -2
- package/src/Table/plugins/sortable/useTableSortable.tsx +53 -1
- package/src/Table/tableContextMenu.test.tsx +157 -0
- package/src/Table/tableContextMenu.tsx +142 -0
- package/src/Table/types.ts +74 -0
- package/src/Table/useTableColumnResize.doc.mjs +3 -3
- package/src/Table/useTableStickyColumns.doc.mjs +2 -2
- package/src/Text/Text.doc.mjs +18 -18
- package/src/TextArea/TextArea.doc.mjs +17 -0
- package/src/TextArea/TextArea.test.tsx +167 -35
- package/src/TextArea/TextArea.tsx +62 -15
- package/src/TextInput/TextInput.doc.mjs +17 -0
- package/src/TextInput/TextInput.test.tsx +168 -34
- package/src/TextInput/TextInput.tsx +77 -9
- package/src/Thumbnail/Thumbnail.doc.mjs +4 -4
- package/src/TimeInput/TimeInput.doc.mjs +340 -60
- package/src/TimeInput/TimeInput.test.tsx +255 -7
- package/src/TimeInput/TimeInput.tsx +176 -70
- package/src/Timestamp/Timestamp.doc.mjs +19 -19
- package/src/Toast/Toast.tsx +14 -0
- package/src/Toast/ToastViewport.test.tsx +214 -0
- package/src/Toast/ToastViewport.tsx +167 -21
- package/src/Tokenizer/Tokenizer.doc.mjs +29 -14
- package/src/Tokenizer/Tokenizer.test.tsx +105 -1
- package/src/Tokenizer/Tokenizer.tsx +37 -1
- package/src/Toolbar/Toolbar.test.tsx +109 -6
- package/src/Toolbar/Toolbar.tsx +59 -5
- package/src/Tooltip/Tooltip.test.tsx +68 -0
- package/src/Tooltip/useTooltip.tsx +55 -8
- package/src/TopNav/TopNav.test.tsx +50 -0
- package/src/TopNav/TopNavHeading.tsx +17 -1
- package/src/TreeList/TreeList.test.tsx +295 -6
- package/src/TreeList/TreeList.tsx +73 -1
- package/src/TreeList/TreeListItem.tsx +51 -5
- package/src/TreeList/treeListItem.markers.stylex.ts +20 -0
- package/src/Typeahead/BaseTypeahead.tsx +93 -9
- package/src/Typeahead/Typeahead.doc.mjs +141 -30
- package/src/Typeahead/Typeahead.test.tsx +331 -1
- package/src/Typeahead/Typeahead.tsx +105 -33
- package/src/VisuallyHidden/VisuallyHidden.doc.mjs +80 -0
- package/src/VisuallyHidden/VisuallyHidden.test.tsx +76 -0
- package/src/VisuallyHidden/VisuallyHidden.tsx +113 -0
- package/src/VisuallyHidden/index.ts +15 -0
- package/src/docs-script.test.mjs +50 -0
- package/src/hooks/focusableSelector.ts +25 -0
- package/src/hooks/index.ts +28 -2
- package/src/hooks/useAnnounce.test.tsx +101 -0
- package/src/hooks/useAnnounce.ts +168 -0
- package/src/hooks/useClickableContainer.ts +16 -4
- package/src/hooks/useEntryAnimation.ts +16 -4
- package/src/hooks/useFocusTrap.test.tsx +132 -0
- package/src/hooks/useFocusTrap.ts +98 -4
- package/src/hooks/useGridFocus.doc.mjs +40 -2
- package/src/hooks/useGridFocus.test.tsx +132 -0
- package/src/hooks/useGridFocus.ts +343 -67
- package/src/hooks/useKeyboardHint.doc.mjs +101 -0
- package/src/hooks/useKeyboardHint.test.tsx +70 -0
- package/src/hooks/useKeyboardHint.tsx +332 -0
- package/src/hooks/useListFocus.doc.mjs +50 -10
- package/src/hooks/useListFocus.test.tsx +375 -0
- package/src/hooks/useListFocus.ts +395 -57
- package/src/hooks/useLongPress.test.tsx +134 -0
- package/src/hooks/useLongPress.ts +119 -0
- package/src/hooks/useTreeFocus.doc.mjs +140 -0
- package/src/hooks/useTreeFocus.test.tsx +214 -0
- package/src/hooks/useTreeFocus.ts +559 -0
- package/src/hooks/useTypeahead.test.tsx +109 -0
- package/src/hooks/useTypeahead.ts +183 -0
- package/src/index.ts +1 -0
- package/src/theme/derivedVarRegistry.test.ts +10 -5
- package/src/utils/dateTypes.test.ts +40 -0
- package/src/utils/dateTypes.ts +40 -0
- package/src/utils/index.ts +9 -0
- package/src/utils/inputAria.test.ts +39 -0
- package/src/utils/inputAria.ts +58 -0
- package/src/utils/timeParser.test.ts +10 -0
- package/src/utils/timeParser.ts +5 -2
- package/dist/Calendar/hooks/useCalendarRovingTabindex.d.ts +0 -57
- package/dist/Calendar/hooks/useCalendarRovingTabindex.d.ts.map +0 -1
- package/dist/Calendar/hooks/useCalendarRovingTabindex.js +0 -96
- package/src/Calendar/hooks/useCalendarRovingTabindex.ts +0 -118
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file focusableSelector.ts
|
|
3
|
+
* @input None (a plain CSS selector string constant)
|
|
4
|
+
* @output Exports FOCUSABLE_SELECTOR
|
|
5
|
+
* @position Internal utility; the canonical CSS selector for focusable
|
|
6
|
+
* elements, shared by focus-management hooks (e.g. useFocusTrap) so the
|
|
7
|
+
* selector isn't duplicated across components/hooks. Not exported from the
|
|
8
|
+
* public barrel — internal implementation detail.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Canonical CSS selector for commonly focusable elements. Includes the
|
|
12
|
+
* tabbable natives (button/link/input/select/textarea/[tabindex]) plus
|
|
13
|
+
* editable and media elements the browser also puts in the tab order —
|
|
14
|
+
* contenteditable, media with controls, iframe, and an open <details>'s
|
|
15
|
+
* <summary> — which a naive selector misses, letting Tab escape a trap whose
|
|
16
|
+
* only interactive content is (e.g.) a contenteditable composer (infra-8).
|
|
17
|
+
*
|
|
18
|
+
* This is the canonical focusable selector; prefer importing it here over
|
|
19
|
+
* re-declaring the string so behavior stays consistent across hooks.
|
|
20
|
+
*/
|
|
21
|
+
export declare const FOCUSABLE_SELECTOR = "button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex=\"-1\"]):not([disabled]), [contenteditable]:not([contenteditable=\"false\"]), audio[controls], video[controls], iframe, details > summary:first-child";
|
|
22
|
+
//# sourceMappingURL=focusableSelector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"focusableSelector.d.ts","sourceRoot":"","sources":["../../src/hooks/focusableSelector.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AAEH;;;;;;;;;;GAUG;AACH,eAAO,MAAM,kBAAkB,4RACwP,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file focusableSelector.ts
|
|
5
|
+
* @input None (a plain CSS selector string constant)
|
|
6
|
+
* @output Exports FOCUSABLE_SELECTOR
|
|
7
|
+
* @position Internal utility; the canonical CSS selector for focusable
|
|
8
|
+
* elements, shared by focus-management hooks (e.g. useFocusTrap) so the
|
|
9
|
+
* selector isn't duplicated across components/hooks. Not exported from the
|
|
10
|
+
* public barrel — internal implementation detail.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Canonical CSS selector for commonly focusable elements. Includes the
|
|
15
|
+
* tabbable natives (button/link/input/select/textarea/[tabindex]) plus
|
|
16
|
+
* editable and media elements the browser also puts in the tab order —
|
|
17
|
+
* contenteditable, media with controls, iframe, and an open <details>'s
|
|
18
|
+
* <summary> — which a naive selector misses, letting Tab escape a trap whose
|
|
19
|
+
* only interactive content is (e.g.) a contenteditable composer (infra-8).
|
|
20
|
+
*
|
|
21
|
+
* This is the canonical focusable selector; prefer importing it here over
|
|
22
|
+
* re-declaring the string so behavior stays consistent across hooks.
|
|
23
|
+
*/
|
|
24
|
+
export const FOCUSABLE_SELECTOR = 'button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"]):not([disabled]), [contenteditable]:not([contenteditable="false"]), audio[controls], video[controls], iframe, details > summary:first-child';
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -8,10 +8,18 @@
|
|
|
8
8
|
*/
|
|
9
9
|
export { useFocusTrap } from './useFocusTrap';
|
|
10
10
|
export type { UseFocusTrapOptions, UseFocusTrapReturn } from './useFocusTrap';
|
|
11
|
+
export { useAnnounce } from './useAnnounce';
|
|
12
|
+
export type { AnnounceFn, AnnouncePoliteness } from './useAnnounce';
|
|
11
13
|
export { useGridFocus } from './useGridFocus';
|
|
12
14
|
export type { UseGridFocusOptions, UseGridFocusReturn } from './useGridFocus';
|
|
13
15
|
export { useListFocus } from './useListFocus';
|
|
14
|
-
export type { UseListFocusOptions, UseListFocusReturn } from './useListFocus';
|
|
16
|
+
export type { UseListFocusOptions, UseListFocusReturn, ListFocusOrientation, } from './useListFocus';
|
|
17
|
+
export { useTreeFocus } from './useTreeFocus';
|
|
18
|
+
export type { UseTreeFocusOptions, UseTreeFocusReturn } from './useTreeFocus';
|
|
19
|
+
export { useTypeahead } from './useTypeahead';
|
|
20
|
+
export { useKeyboardHint } from './useKeyboardHint';
|
|
21
|
+
export type { UseKeyboardHintOptions, UseKeyboardHintReturn, KeyboardHintOrientation, } from './useKeyboardHint';
|
|
22
|
+
export type { UseTypeaheadOptions, UseTypeaheadReturn } from './useTypeahead';
|
|
15
23
|
export { useMediaQuery } from './useMediaQuery';
|
|
16
24
|
export { useOverflow } from './useOverflow';
|
|
17
25
|
export type { UseOverflowOptions, UseOverflowReturn } from './useOverflow';
|
|
@@ -24,10 +32,12 @@ export { useStreamingText } from './useStreamingText';
|
|
|
24
32
|
export type { StreamingTextSpeed, UseStreamingTextOptions, } from './useStreamingText';
|
|
25
33
|
export { useImageMode } from './useImageMode';
|
|
26
34
|
export type { ImageSampleRegion, UseImageModeOptions } from './useImageMode';
|
|
27
|
-
export { useClickableContainer } from './useClickableContainer';
|
|
35
|
+
export { useClickableContainer, INTERACTIVE_SELECTORS, } from './useClickableContainer';
|
|
28
36
|
export type { UseClickableContainerOptions, ClickableContainerResult, } from './useClickableContainer';
|
|
29
37
|
export { useInputContainer } from './useInputContainer';
|
|
30
38
|
export type { UseInputContainerOptions } from './useInputContainer';
|
|
31
39
|
export { useInteractiveRole } from './useInteractiveRole';
|
|
32
40
|
export type { InteractiveRole, UseInteractiveRoleOptions, } from './useInteractiveRole';
|
|
41
|
+
export { useLongPress } from './useLongPress';
|
|
42
|
+
export type { UseLongPressOptions, UseLongPressHandlers } from './useLongPress';
|
|
33
43
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAIA;;;;;;;GAOG;AAEH,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAC5C,YAAY,EAAC,mBAAmB,EAAE,kBAAkB,EAAC,MAAM,gBAAgB,CAAC;AAE5E,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAC5C,YAAY,EAAC,mBAAmB,EAAE,kBAAkB,EAAC,MAAM,gBAAgB,CAAC;AAE5E,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAC5C,YAAY,EAAC,mBAAmB,EAAE,kBAAkB,EAAC,MAAM,gBAAgB,CAAC;AAE5E,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAC;AAE9C,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;AAC1C,YAAY,EAAC,kBAAkB,EAAE,iBAAiB,EAAC,MAAM,eAAe,CAAC;AAEzE,OAAO,EAAC,iBAAiB,EAAC,MAAM,qBAAqB,CAAC;AACtD,YAAY,EAAC,mBAAmB,EAAC,MAAM,qBAAqB,CAAC;AAE7D,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAC;AAE9C,OAAO,EAAC,iBAAiB,EAAC,MAAM,qBAAqB,CAAC;AACtD,YAAY,EAAC,oBAAoB,EAAC,MAAM,qBAAqB,CAAC;AAE9D,OAAO,EAAC,gBAAgB,EAAC,MAAM,oBAAoB,CAAC;AACpD,YAAY,EACV,kBAAkB,EAClB,uBAAuB,GACxB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAC5C,YAAY,EAAC,iBAAiB,EAAE,mBAAmB,EAAC,MAAM,gBAAgB,CAAC;AAE3E,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAIA;;;;;;;GAOG;AAEH,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAC5C,YAAY,EAAC,mBAAmB,EAAE,kBAAkB,EAAC,MAAM,gBAAgB,CAAC;AAE5E,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;AAC1C,YAAY,EAAC,UAAU,EAAE,kBAAkB,EAAC,MAAM,eAAe,CAAC;AAElE,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAC5C,YAAY,EAAC,mBAAmB,EAAE,kBAAkB,EAAC,MAAM,gBAAgB,CAAC;AAE5E,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAC5C,YAAY,EACV,mBAAmB,EACnB,kBAAkB,EAClB,oBAAoB,GACrB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAC5C,YAAY,EAAC,mBAAmB,EAAE,kBAAkB,EAAC,MAAM,gBAAgB,CAAC;AAE5E,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAE5C,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAC;AAClD,YAAY,EACV,sBAAsB,EACtB,qBAAqB,EACrB,uBAAuB,GACxB,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EAAC,mBAAmB,EAAE,kBAAkB,EAAC,MAAM,gBAAgB,CAAC;AAE5E,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAC;AAE9C,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;AAC1C,YAAY,EAAC,kBAAkB,EAAE,iBAAiB,EAAC,MAAM,eAAe,CAAC;AAEzE,OAAO,EAAC,iBAAiB,EAAC,MAAM,qBAAqB,CAAC;AACtD,YAAY,EAAC,mBAAmB,EAAC,MAAM,qBAAqB,CAAC;AAE7D,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAC;AAE9C,OAAO,EAAC,iBAAiB,EAAC,MAAM,qBAAqB,CAAC;AACtD,YAAY,EAAC,oBAAoB,EAAC,MAAM,qBAAqB,CAAC;AAE9D,OAAO,EAAC,gBAAgB,EAAC,MAAM,oBAAoB,CAAC;AACpD,YAAY,EACV,kBAAkB,EAClB,uBAAuB,GACxB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAC5C,YAAY,EAAC,iBAAiB,EAAE,mBAAmB,EAAC,MAAM,gBAAgB,CAAC;AAE3E,OAAO,EACL,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,yBAAyB,CAAC;AACjC,YAAY,EACV,4BAA4B,EAC5B,wBAAwB,GACzB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAC,iBAAiB,EAAC,MAAM,qBAAqB,CAAC;AACtD,YAAY,EAAC,wBAAwB,EAAC,MAAM,qBAAqB,CAAC;AAElE,OAAO,EAAC,kBAAkB,EAAC,MAAM,sBAAsB,CAAC;AACxD,YAAY,EACV,eAAe,EACf,yBAAyB,GAC1B,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAC5C,YAAY,EAAC,mBAAmB,EAAE,oBAAoB,EAAC,MAAM,gBAAgB,CAAC"}
|
package/dist/hooks/index.js
CHANGED
|
@@ -11,8 +11,12 @@
|
|
|
11
11
|
* SYNC: When modified, update this header
|
|
12
12
|
*/
|
|
13
13
|
export { useFocusTrap } from "./useFocusTrap.js";
|
|
14
|
+
export { useAnnounce } from "./useAnnounce.js";
|
|
14
15
|
export { useGridFocus } from "./useGridFocus.js";
|
|
15
16
|
export { useListFocus } from "./useListFocus.js";
|
|
17
|
+
export { useTreeFocus } from "./useTreeFocus.js";
|
|
18
|
+
export { useTypeahead } from "./useTypeahead.js";
|
|
19
|
+
export { useKeyboardHint } from "./useKeyboardHint.js";
|
|
16
20
|
export { useMediaQuery } from "./useMediaQuery.js";
|
|
17
21
|
export { useOverflow } from "./useOverflow.js";
|
|
18
22
|
export { useScrollOverflow } from "./useScrollOverflow.js";
|
|
@@ -20,6 +24,7 @@ export { useScrollLock } from "./useScrollLock.js";
|
|
|
20
24
|
export { useEntryAnimation } from "./useEntryAnimation.js";
|
|
21
25
|
export { useStreamingText } from "./useStreamingText.js";
|
|
22
26
|
export { useImageMode } from "./useImageMode.js";
|
|
23
|
-
export { useClickableContainer } from "./useClickableContainer.js";
|
|
27
|
+
export { useClickableContainer, INTERACTIVE_SELECTORS } from "./useClickableContainer.js";
|
|
24
28
|
export { useInputContainer } from "./useInputContainer.js";
|
|
25
|
-
export { useInteractiveRole } from "./useInteractiveRole.js";
|
|
29
|
+
export { useInteractiveRole } from "./useInteractiveRole.js";
|
|
30
|
+
export { useLongPress } from "./useLongPress.js";
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Announcement urgency:
|
|
3
|
+
* - `'polite'` (default): announced when the screen reader is idle. Use for
|
|
4
|
+
* status updates, result counts, "no results", non-urgent confirmations.
|
|
5
|
+
* - `'assertive'`: interrupts the current announcement. Reserve for errors and
|
|
6
|
+
* time-sensitive alerts.
|
|
7
|
+
*/
|
|
8
|
+
export type AnnouncePoliteness = 'polite' | 'assertive';
|
|
9
|
+
/**
|
|
10
|
+
* Imperative screen-reader announcement function.
|
|
11
|
+
*/
|
|
12
|
+
export type AnnounceFn = (message: string, politeness?: AnnouncePoliteness) => void;
|
|
13
|
+
/**
|
|
14
|
+
* Returns an imperative `announce(message, politeness?)` function that speaks a
|
|
15
|
+
* message through a persistently-mounted, visually-hidden live region.
|
|
16
|
+
*
|
|
17
|
+
* The polite and assertive regions are created once on first use and kept
|
|
18
|
+
* mounted, so announcements are reliable even for messages that appear
|
|
19
|
+
* immediately (unlike a live region rendered together with its content).
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```
|
|
23
|
+
* function Search() {
|
|
24
|
+
* const announce = useAnnounce();
|
|
25
|
+
* const onResults = (n: number) => {
|
|
26
|
+
* announce(n === 0 ? 'No results found' : `${n} results`);
|
|
27
|
+
* };
|
|
28
|
+
* // ...
|
|
29
|
+
* }
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export declare function useAnnounce(): AnnounceFn;
|
|
33
|
+
/**
|
|
34
|
+
* Test-only helper: removes the singleton live regions and resets state so
|
|
35
|
+
* each test starts clean. Not part of the public runtime API.
|
|
36
|
+
*
|
|
37
|
+
* @internal
|
|
38
|
+
*/
|
|
39
|
+
export declare function __resetLiveRegionsForTest(): void;
|
|
40
|
+
//# sourceMappingURL=useAnnounce.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAnnounce.d.ts","sourceRoot":"","sources":["../../src/hooks/useAnnounce.ts"],"names":[],"mappings":"AAiBA;;;;;;GAMG;AACH,MAAM,MAAM,kBAAkB,GAAG,QAAQ,GAAG,WAAW,CAAC;AAExD;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,CACvB,OAAO,EAAE,MAAM,EACf,UAAU,CAAC,EAAE,kBAAkB,KAC5B,IAAI,CAAC;AAyFV;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,WAAW,IAAI,UAAU,CAaxC;AAED;;;;;GAKG;AACH,wBAAgB,yBAAyB,IAAI,IAAI,CAMhD"}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
'use client';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @file useAnnounce.ts
|
|
7
|
+
* @input Uses React useCallback; DOM APIs for a singleton live-region pair
|
|
8
|
+
* @output Exports useAnnounce hook and AnnouncePoliteness type
|
|
9
|
+
* @position Core a11y hook; provides imperative screen-reader announcements
|
|
10
|
+
* via persistently-mounted polite/assertive live regions
|
|
11
|
+
*
|
|
12
|
+
* SYNC: When modified, update:
|
|
13
|
+
* - /packages/core/src/hooks/index.ts
|
|
14
|
+
*/
|
|
15
|
+
import { useCallback } from 'react';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Announcement urgency:
|
|
19
|
+
* - `'polite'` (default): announced when the screen reader is idle. Use for
|
|
20
|
+
* status updates, result counts, "no results", non-urgent confirmations.
|
|
21
|
+
* - `'assertive'`: interrupts the current announcement. Reserve for errors and
|
|
22
|
+
* time-sensitive alerts.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Imperative screen-reader announcement function.
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
const CONTAINER_ATTR = 'data-astryx-live-region';
|
|
30
|
+
|
|
31
|
+
// Visually-hidden clip block (matches the VisuallyHidden primitive). Applied
|
|
32
|
+
// inline so the regions work without any stylesheet being present.
|
|
33
|
+
const VISUALLY_HIDDEN_CSS = 'position:absolute;width:1px;height:1px;margin:-1px;padding:0;' + 'overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0;' + 'inset-block-start:0;inset-inline-start:0;pointer-events:none;' + 'user-select:none;';
|
|
34
|
+
// Singleton: the live regions are created ONCE and stay mounted for the
|
|
35
|
+
// lifetime of the document. This is the crux of reliable announcements — many
|
|
36
|
+
// screen readers will not announce content injected into a live region that is
|
|
37
|
+
// created together with its content ("born with content"). By mounting empty
|
|
38
|
+
// regions up front and only mutating their text later, updates are announced.
|
|
39
|
+
let regions = null;
|
|
40
|
+
function createRegion(politeness) {
|
|
41
|
+
const el = document.createElement('div');
|
|
42
|
+
el.setAttribute(CONTAINER_ATTR, politeness);
|
|
43
|
+
el.setAttribute('aria-live', politeness);
|
|
44
|
+
el.setAttribute('aria-atomic', 'true');
|
|
45
|
+
el.setAttribute('role', politeness === 'assertive' ? 'alert' : 'status');
|
|
46
|
+
el.style.cssText = VISUALLY_HIDDEN_CSS;
|
|
47
|
+
document.body.appendChild(el);
|
|
48
|
+
return el;
|
|
49
|
+
}
|
|
50
|
+
function getRegions() {
|
|
51
|
+
if (typeof document === 'undefined') {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
if (regions) {
|
|
55
|
+
// Re-attach if a region was removed from the DOM (e.g. by a test cleanup).
|
|
56
|
+
if (!regions.polite.isConnected) {
|
|
57
|
+
document.body.appendChild(regions.polite);
|
|
58
|
+
}
|
|
59
|
+
if (!regions.assertive.isConnected) {
|
|
60
|
+
document.body.appendChild(regions.assertive);
|
|
61
|
+
}
|
|
62
|
+
return regions;
|
|
63
|
+
}
|
|
64
|
+
regions = {
|
|
65
|
+
polite: createRegion('polite'),
|
|
66
|
+
assertive: createRegion('assertive')
|
|
67
|
+
};
|
|
68
|
+
return regions;
|
|
69
|
+
}
|
|
70
|
+
function announceMessage(message, politeness) {
|
|
71
|
+
const r = getRegions();
|
|
72
|
+
if (!r) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
const target = politeness === 'assertive' ? r.assertive : r.polite;
|
|
76
|
+
// Clearing first guarantees the mutation is observed even when the new
|
|
77
|
+
// message equals the current text — some AT deduplicate identical content.
|
|
78
|
+
target.textContent = '';
|
|
79
|
+
// A microtask/rAF-free re-set in the next frame is more reliable across AT
|
|
80
|
+
// than an immediate re-set, which can be coalesced with the clear.
|
|
81
|
+
requestAnimationFrame(() => {
|
|
82
|
+
target.textContent = message;
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Clear any pending announcement from a region without announcing anything new.
|
|
88
|
+
* Used when the triggering context goes away (e.g. a search query is cleared),
|
|
89
|
+
* so stale status text does not linger in the accessibility tree.
|
|
90
|
+
*/
|
|
91
|
+
function clearRegion(politeness) {
|
|
92
|
+
if (!regions) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
const target = politeness === 'assertive' ? regions.assertive : regions.polite;
|
|
96
|
+
target.textContent = '';
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Returns an imperative `announce(message, politeness?)` function that speaks a
|
|
101
|
+
* message through a persistently-mounted, visually-hidden live region.
|
|
102
|
+
*
|
|
103
|
+
* The polite and assertive regions are created once on first use and kept
|
|
104
|
+
* mounted, so announcements are reliable even for messages that appear
|
|
105
|
+
* immediately (unlike a live region rendered together with its content).
|
|
106
|
+
*
|
|
107
|
+
* @example
|
|
108
|
+
* ```
|
|
109
|
+
* function Search() {
|
|
110
|
+
* const announce = useAnnounce();
|
|
111
|
+
* const onResults = (n: number) => {
|
|
112
|
+
* announce(n === 0 ? 'No results found' : `${n} results`);
|
|
113
|
+
* };
|
|
114
|
+
* // ...
|
|
115
|
+
* }
|
|
116
|
+
* ```
|
|
117
|
+
*/
|
|
118
|
+
export function useAnnounce() {
|
|
119
|
+
return useCallback((message, politeness = 'polite') => {
|
|
120
|
+
if (!message) {
|
|
121
|
+
// An empty message clears any lingering status from the region rather
|
|
122
|
+
// than announcing nothing — useful when the triggering context ends.
|
|
123
|
+
clearRegion(politeness);
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
announceMessage(message, politeness);
|
|
127
|
+
}, []);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Test-only helper: removes the singleton live regions and resets state so
|
|
132
|
+
* each test starts clean. Not part of the public runtime API.
|
|
133
|
+
*
|
|
134
|
+
* @internal
|
|
135
|
+
*/
|
|
136
|
+
export function __resetLiveRegionsForTest() {
|
|
137
|
+
if (regions) {
|
|
138
|
+
regions.polite.remove();
|
|
139
|
+
regions.assertive.remove();
|
|
140
|
+
regions = null;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
@@ -1,13 +1,28 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @file useClickableContainer.ts
|
|
3
3
|
* @input Container ref, interactive element ref, click/href handlers
|
|
4
|
-
* @output onClick and onMouseUp handlers for the container
|
|
4
|
+
* @output onClick and onMouseUp handlers for the container; INTERACTIVE_SELECTORS list
|
|
5
5
|
* @position Core hook for clickable containers that safely handle nested interactive elements
|
|
6
6
|
*
|
|
7
7
|
* Solves the "nested interactive elements" problem: when a card is clickable
|
|
8
8
|
* but contains buttons/links, clicking those should NOT trigger the card's action.
|
|
9
|
+
*
|
|
10
|
+
* SYNC: When modified, update:
|
|
11
|
+
* - /packages/core/src/hooks/index.ts (export)
|
|
9
12
|
*/
|
|
10
13
|
import { type RefObject, type MouseEvent } from 'react';
|
|
14
|
+
/**
|
|
15
|
+
* Canonical list of interactive element selectors — native controls plus
|
|
16
|
+
* role-based interactive elements. Clicks on these (or their descendants)
|
|
17
|
+
* should NOT bubble to a clickable container's click handler.
|
|
18
|
+
*
|
|
19
|
+
* Exported so other focus/interaction utilities can share one comprehensive
|
|
20
|
+
* definition of "interactive target" rather than hand-rolling divergent lists.
|
|
21
|
+
* Note: this list is about "don't bubble clicks", not focus-eligibility —
|
|
22
|
+
* consumers that need focusable elements must additionally exclude
|
|
23
|
+
* unfocusable/disabled targets (e.g. `[tabindex="-1"]`, `:disabled`).
|
|
24
|
+
*/
|
|
25
|
+
export declare const INTERACTIVE_SELECTORS: string;
|
|
11
26
|
export interface UseClickableContainerOptions {
|
|
12
27
|
/** Ref to the outer container element */
|
|
13
28
|
containerRef: RefObject<HTMLElement | null>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useClickableContainer.d.ts","sourceRoot":"","sources":["../../src/hooks/useClickableContainer.ts"],"names":[],"mappings":"AAIA
|
|
1
|
+
{"version":3,"file":"useClickableContainer.d.ts","sourceRoot":"","sources":["../../src/hooks/useClickableContainer.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAyB,KAAK,SAAS,EAAE,KAAK,UAAU,EAAC,MAAM,OAAO,CAAC;AAE9E;;;;;;;;;;GAUG;AACH,eAAO,MAAM,qBAAqB,QAmBvB,CAAC;AAmCZ,MAAM,WAAW,4BAA4B;IAC3C,yCAAyC;IACzC,YAAY,EAAE,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;IAC5C,mEAAmE;IACnE,cAAc,CAAC,EAAE,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;IAC/C,oBAAoB;IACpB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,CAAC,WAAW,CAAC,KAAK,IAAI,CAAC;IACnD,uEAAuE;IACvE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,kBAAkB;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,wCAAwC;IACxC,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,wBAAwB;IACvC,OAAO,EAAE,CAAC,KAAK,EAAE,UAAU,CAAC,WAAW,CAAC,KAAK,IAAI,CAAC;IAClD,SAAS,EAAE,CAAC,KAAK,EAAE,UAAU,CAAC,WAAW,CAAC,KAAK,IAAI,CAAC;CACrD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,qBAAqB,CAAC,EACpC,YAAY,EACZ,cAAc,EACd,OAAO,EAAE,WAAW,EACpB,IAAI,EACJ,MAAM,EACN,QAAgB,GACjB,EAAE,4BAA4B,GAAG,wBAAwB,CA6GzD"}
|
|
@@ -5,17 +5,29 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* @file useClickableContainer.ts
|
|
7
7
|
* @input Container ref, interactive element ref, click/href handlers
|
|
8
|
-
* @output onClick and onMouseUp handlers for the container
|
|
8
|
+
* @output onClick and onMouseUp handlers for the container; INTERACTIVE_SELECTORS list
|
|
9
9
|
* @position Core hook for clickable containers that safely handle nested interactive elements
|
|
10
10
|
*
|
|
11
11
|
* Solves the "nested interactive elements" problem: when a card is clickable
|
|
12
12
|
* but contains buttons/links, clicking those should NOT trigger the card's action.
|
|
13
|
+
*
|
|
14
|
+
* SYNC: When modified, update:
|
|
15
|
+
* - /packages/core/src/hooks/index.ts (export)
|
|
13
16
|
*/
|
|
14
17
|
import { useCallback, useEffect } from 'react';
|
|
15
18
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
+
/**
|
|
20
|
+
* Canonical list of interactive element selectors — native controls plus
|
|
21
|
+
* role-based interactive elements. Clicks on these (or their descendants)
|
|
22
|
+
* should NOT bubble to a clickable container's click handler.
|
|
23
|
+
*
|
|
24
|
+
* Exported so other focus/interaction utilities can share one comprehensive
|
|
25
|
+
* definition of "interactive target" rather than hand-rolling divergent lists.
|
|
26
|
+
* Note: this list is about "don't bubble clicks", not focus-eligibility —
|
|
27
|
+
* consumers that need focusable elements must additionally exclude
|
|
28
|
+
* unfocusable/disabled targets (e.g. `[tabindex="-1"]`, `:disabled`).
|
|
29
|
+
*/
|
|
30
|
+
export const INTERACTIVE_SELECTORS = ['button', 'a', 'input', 'select', 'textarea', '[role="button"]', '[role="link"]', '[role="checkbox"]', '[role="radio"]', '[role="switch"]', '[role="tab"]', '[role="menuitem"]', '[role="option"]', '[role="combobox"]', '[role="listbox"]', '[role="slider"]', '[role="spinbutton"]', '[data-pressable-container]'].join(',');
|
|
19
31
|
const NON_INTERACTIVE_SELECTORS = '[aria-readonly="true"]';
|
|
20
32
|
|
|
21
33
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useEntryAnimation.d.ts","sourceRoot":"","sources":["../../src/hooks/useEntryAnimation.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"useEntryAnimation.d.ts","sourceRoot":"","sources":["../../src/hooks/useEntryAnimation.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,kBAAkB,CAAC;AAoFnD,MAAM,MAAM,oBAAoB,GAC5B,WAAW,GACX,SAAS,GACT,QAAQ,GACR,SAAS,CAAC;AAEd;;;;;;;;;;;GAWG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,GAAE,oBAAkC,GACzC,YAAY,GAAG,IAAI,CAGrB"}
|
|
@@ -38,28 +38,28 @@ const fadeIn = "x18re5ia-B";
|
|
|
38
38
|
const scaleIn = "x1k48ry3-B";
|
|
39
39
|
const styles = {
|
|
40
40
|
slideDown: {
|
|
41
|
-
kKVMdj: "x1srr2gu",
|
|
41
|
+
kKVMdj: "x1srr2gu x1aquc0h",
|
|
42
42
|
k44tkh: "x9uej1z",
|
|
43
43
|
kyAemX: "x128ha8g",
|
|
44
44
|
kWV6AL: "xskzprw",
|
|
45
45
|
$$css: true
|
|
46
46
|
},
|
|
47
47
|
slideUp: {
|
|
48
|
-
kKVMdj: "x1dvww92",
|
|
48
|
+
kKVMdj: "x1dvww92 x1aquc0h",
|
|
49
49
|
k44tkh: "x9uej1z",
|
|
50
50
|
kyAemX: "x128ha8g",
|
|
51
51
|
kWV6AL: "xskzprw",
|
|
52
52
|
$$css: true
|
|
53
53
|
},
|
|
54
54
|
fadeIn: {
|
|
55
|
-
kKVMdj: "xqcmdr3",
|
|
55
|
+
kKVMdj: "xqcmdr3 x1aquc0h",
|
|
56
56
|
k44tkh: "x9uej1z",
|
|
57
57
|
kyAemX: "x128ha8g",
|
|
58
58
|
kWV6AL: "xskzprw",
|
|
59
59
|
$$css: true
|
|
60
60
|
},
|
|
61
61
|
scaleIn: {
|
|
62
|
-
kKVMdj: "x97zbip",
|
|
62
|
+
kKVMdj: "x97zbip x1aquc0h",
|
|
63
63
|
k44tkh: "x9uej1z",
|
|
64
64
|
kyAemX: "x128ha8g",
|
|
65
65
|
kWV6AL: "xskzprw",
|
|
@@ -1,3 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether any focus-trap Escape handler is currently active (i.e. a popover
|
|
3
|
+
* layer is open). Other overlay primitives that manage their own Escape (e.g.
|
|
4
|
+
* Dialog) can consult this to defer to a popover layered on top of them,
|
|
5
|
+
* giving topmost-only dismissal until a full layer stack exists.
|
|
6
|
+
*/
|
|
7
|
+
export declare function hasActiveFocusTrapEscape(): boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Whether an Escape keydown should be ignored because it is cancelling an
|
|
10
|
+
* in-progress IME composition. CJK/IME users press Escape to cancel
|
|
11
|
+
* composition; that must not close the surrounding overlay. `keyCode === 229`
|
|
12
|
+
* covers browsers that fire keydown before `isComposing` is set. Exported so
|
|
13
|
+
* other overlays (Dialog, Drawer, CommandPalette) share one definition.
|
|
14
|
+
*/
|
|
15
|
+
export declare function isImeKeyEvent(event: {
|
|
16
|
+
isComposing?: boolean;
|
|
17
|
+
keyCode?: number;
|
|
18
|
+
}): boolean;
|
|
1
19
|
/**
|
|
2
20
|
* Configuration for focus trap behavior
|
|
3
21
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFocusTrap.d.ts","sourceRoot":"","sources":["../../src/hooks/useFocusTrap.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useFocusTrap.d.ts","sourceRoot":"","sources":["../../src/hooks/useFocusTrap.ts"],"names":[],"mappings":"AA+CA;;;;;GAKG;AACH,wBAAgB,wBAAwB,IAAI,OAAO,CAElD;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE;IACnC,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,GAAG,OAAO,CAEV;AA0ED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC;;OAEG;IACH,QAAQ,EAAE,OAAO,CAAC;IAElB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB,CAAC,CAAC,SAAS,WAAW,GAAG,WAAW;IACrE;;OAEG;IACH,YAAY,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;IAExC;;OAEG;IACH,UAAU,EAAE,MAAM,IAAI,CAAC;CACxB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS,WAAW,GAAG,WAAW,EAC9D,OAAO,EAAE,mBAAmB,GAC3B,kBAAkB,CAAC,CAAC,CAAC,CAoJvB"}
|
|
@@ -15,17 +15,80 @@
|
|
|
15
15
|
* - /packages/core/src/hooks/index.ts
|
|
16
16
|
*/
|
|
17
17
|
import { useCallback, useEffect, useRef } from 'react';
|
|
18
|
+
import { FOCUSABLE_SELECTOR } from "./focusableSelector.js";
|
|
18
19
|
|
|
19
20
|
/**
|
|
20
|
-
*
|
|
21
|
+
* Module-level stack of active focus-trap Escape handlers.
|
|
22
|
+
*
|
|
23
|
+
* Every active `useFocusTrap` used to attach its own document-level `keydown`
|
|
24
|
+
* listener with no coordination, so a single Escape press closed *every* open
|
|
25
|
+
* layer at once (e.g. a popover nested inside a Dialog closed both). Tracking
|
|
26
|
+
* traps in a shared stack lets only the most recently activated (top-most)
|
|
27
|
+
* trap respond to Escape.
|
|
28
|
+
*/
|
|
29
|
+
const escapeStack = [];
|
|
30
|
+
function pushEscapeHandler(handler) {
|
|
31
|
+
escapeStack.push(handler);
|
|
32
|
+
}
|
|
33
|
+
function removeEscapeHandler(handler) {
|
|
34
|
+
const index = escapeStack.lastIndexOf(handler);
|
|
35
|
+
if (index !== -1) {
|
|
36
|
+
escapeStack.splice(index, 1);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
function isTopEscapeHandler(handler) {
|
|
40
|
+
return escapeStack[escapeStack.length - 1] === handler;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Whether any focus-trap Escape handler is currently active (i.e. a popover
|
|
45
|
+
* layer is open). Other overlay primitives that manage their own Escape (e.g.
|
|
46
|
+
* Dialog) can consult this to defer to a popover layered on top of them,
|
|
47
|
+
* giving topmost-only dismissal until a full layer stack exists.
|
|
21
48
|
*/
|
|
22
|
-
|
|
49
|
+
export function hasActiveFocusTrapEscape() {
|
|
50
|
+
return escapeStack.length > 0;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Whether an Escape keydown should be ignored because it is cancelling an
|
|
55
|
+
* in-progress IME composition. CJK/IME users press Escape to cancel
|
|
56
|
+
* composition; that must not close the surrounding overlay. `keyCode === 229`
|
|
57
|
+
* covers browsers that fire keydown before `isComposing` is set. Exported so
|
|
58
|
+
* other overlays (Dialog, Drawer, CommandPalette) share one definition.
|
|
59
|
+
*/
|
|
60
|
+
export function isImeKeyEvent(event) {
|
|
61
|
+
return event.isComposing === true || event.keyCode === 229;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Whether an element is currently perceivable/focusable — excludes ones hidden
|
|
66
|
+
* via `display:none`/`visibility:hidden` or inside an `inert`/`hidden` subtree,
|
|
67
|
+
* which the browser skips for Tab.
|
|
68
|
+
*/
|
|
69
|
+
function isVisiblyFocusable(el) {
|
|
70
|
+
if (el.hasAttribute('inert') || el.closest('[inert]')) {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
if (el.hidden || el.closest('[hidden]')) {
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
// offsetParent is null for display:none (and fixed elements); pair with a
|
|
77
|
+
// visibility check via getComputedStyle when available.
|
|
78
|
+
if (typeof window !== 'undefined' && window.getComputedStyle) {
|
|
79
|
+
const style = window.getComputedStyle(el);
|
|
80
|
+
if (style.visibility === 'hidden' || style.display === 'none') {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return true;
|
|
85
|
+
}
|
|
23
86
|
|
|
24
87
|
/**
|
|
25
88
|
* Get all focusable elements within a container.
|
|
26
89
|
*/
|
|
27
90
|
function getFocusableElements(container) {
|
|
28
|
-
return Array.from(container.querySelectorAll(FOCUSABLE_SELECTOR));
|
|
91
|
+
return Array.from(container.querySelectorAll(FOCUSABLE_SELECTOR)).filter(isVisiblyFocusable);
|
|
29
92
|
}
|
|
30
93
|
|
|
31
94
|
/**
|
|
@@ -171,13 +234,31 @@ export function useFocusTrap(options) {
|
|
|
171
234
|
if (!isActive) {
|
|
172
235
|
return;
|
|
173
236
|
}
|
|
237
|
+
|
|
238
|
+
// Register this trap on the shared Escape stack so only the top-most
|
|
239
|
+
// active trap responds to Escape. A stable identity per active period is
|
|
240
|
+
// enough — we push on activate and remove on cleanup.
|
|
241
|
+
const escapeHandler = () => {
|
|
242
|
+
onEscape?.();
|
|
243
|
+
};
|
|
244
|
+
if (onEscape) {
|
|
245
|
+
pushEscapeHandler(escapeHandler);
|
|
246
|
+
}
|
|
174
247
|
const handleKeyDown = event => {
|
|
175
248
|
const container = containerRef.current;
|
|
176
249
|
if (!container) {
|
|
177
250
|
return;
|
|
178
251
|
}
|
|
179
252
|
if (event.key === 'Escape' && onEscape) {
|
|
253
|
+
// Ignore Escape that is cancelling an IME composition, already handled
|
|
254
|
+
// by a nested handler, or not targeting the top-most trap.
|
|
255
|
+
if (event.defaultPrevented || isImeKeyEvent(event) || !isTopEscapeHandler(escapeHandler)) {
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
// Mark handled and stop propagation so an outer layer (e.g. a Dialog
|
|
259
|
+
// hosting this popover) does not also dismiss on the same press.
|
|
180
260
|
event.preventDefault();
|
|
261
|
+
event.stopPropagation();
|
|
181
262
|
onEscape();
|
|
182
263
|
return;
|
|
183
264
|
}
|
|
@@ -208,6 +289,9 @@ export function useFocusTrap(options) {
|
|
|
208
289
|
document.addEventListener('keydown', handleKeyDown);
|
|
209
290
|
return () => {
|
|
210
291
|
document.removeEventListener('keydown', handleKeyDown);
|
|
292
|
+
if (onEscape) {
|
|
293
|
+
removeEscapeHandler(escapeHandler);
|
|
294
|
+
}
|
|
211
295
|
};
|
|
212
296
|
}, [isActive, onEscape]);
|
|
213
297
|
return {
|