@primer/components 0.0.0-2021983515 → 0.0.0-2022530194733
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 +105 -492
- package/README.md +16 -16
- package/codemods/lib/modifyProps.js +7 -9
- package/codemods/lib/prettify.js +1 -1
- package/codemods/lib/replaceImportSource.js +5 -5
- package/dist/browser.esm.js +889 -1279
- package/dist/browser.esm.js.map +1 -1
- package/dist/browser.umd.js +839 -1234
- package/dist/browser.umd.js.map +1 -1
- package/index.d.ts +940 -0
- package/lib/AvatarPair.js +5 -6
- package/lib/AvatarStack.js +10 -10
- package/lib/BaseStyles.js +19 -18
- package/lib/BorderBox.js +5 -4
- package/lib/Box.js +2 -2
- package/lib/BranchName.js +1 -1
- package/lib/{Breadcrumbs.js → Breadcrumb.js} +23 -33
- package/lib/Button/Button.js +3 -3
- package/lib/Button/ButtonClose.js +4 -4
- package/lib/Button/ButtonDanger.js +2 -2
- package/lib/Button/ButtonInvisible.js +3 -3
- package/lib/Button/ButtonOutline.js +2 -2
- package/lib/Button/ButtonPrimary.js +2 -2
- package/lib/Button/ButtonTableList.js +1 -1
- package/lib/CircleBadge.js +1 -1
- package/lib/CircleOcticon.js +7 -9
- package/lib/CounterLabel.js +2 -2
- package/lib/Dialog.js +14 -13
- package/lib/Dropdown.js +2 -2
- package/lib/DropdownStyles.js +6 -6
- package/lib/FilterList.js +1 -1
- package/lib/Flash.js +1 -1
- package/lib/Flex.js +0 -3
- package/lib/Grid.js +3 -4
- package/lib/Header.js +2 -3
- package/lib/Label.js +4 -4
- package/lib/Link.js +12 -1
- package/lib/Overlay.js +36 -126
- package/lib/Pagehead.js +1 -1
- package/lib/Pagination/Pagination.js +2 -3
- package/lib/Popover.js +3 -3
- package/lib/Portal/Portal.js +12 -20
- package/lib/Position.js +27 -46
- package/lib/ProgressBar.js +1 -1
- package/lib/SelectMenu/SelectMenu.js +4 -4
- package/lib/SelectMenu/SelectMenuContext.js +1 -1
- package/lib/SelectMenu/SelectMenuDivider.js +3 -3
- package/lib/SelectMenu/SelectMenuFilter.js +6 -6
- package/lib/SelectMenu/SelectMenuFooter.js +3 -3
- package/lib/SelectMenu/SelectMenuHeader.js +2 -2
- package/lib/SelectMenu/SelectMenuItem.js +4 -4
- package/lib/SelectMenu/SelectMenuList.js +3 -3
- package/lib/SelectMenu/SelectMenuLoadingAnimation.js +15 -4
- package/lib/SelectMenu/SelectMenuModal.js +7 -7
- package/lib/SelectMenu/SelectMenuTab.js +3 -3
- package/lib/SelectMenu/SelectMenuTabPanel.js +3 -3
- package/lib/SelectMenu/SelectMenuTabs.js +2 -2
- package/lib/SelectMenu/hooks/useKeyboardNav.js +0 -2
- package/lib/SideNav.js +12 -20
- package/lib/StateLabel.js +4 -4
- package/lib/SubNav.js +3 -5
- package/lib/TabNav.js +3 -3
- package/lib/TextInput.js +59 -22
- package/lib/ThemeProvider.js +15 -32
- package/lib/Timeline.js +29 -24
- package/lib/Tooltip.js +1 -2
- package/lib/UnderlineNav.js +2 -2
- package/lib/behaviors/anchoredPosition.js +9 -17
- package/lib/behaviors/focusTrap.js +14 -32
- package/lib/behaviors/focusZone.js +148 -218
- package/lib/constants.js +2 -3
- package/lib/hooks/index.js +1 -9
- package/lib/hooks/useAnchoredPosition.js +4 -11
- package/lib/hooks/useDialog.js +1 -1
- package/lib/hooks/useFocusTrap.js +8 -26
- package/lib/hooks/useFocusZone.js +7 -7
- package/lib/hooks/useMouseIntent.js +58 -0
- package/lib/hooks/useOnEscapePress.js +10 -53
- package/lib/hooks/useOnOutsideClick.js +35 -62
- package/lib/hooks/useOpenAndCloseFocus.js +3 -8
- package/lib/hooks/useOverlay.js +19 -9
- package/lib/hooks/useSafeTimeout.js +0 -1
- package/lib/index.js +12 -112
- package/lib/polyfills/eventListenerSignal.js +1 -6
- package/lib/stories/Button.stories.js +114 -0
- package/lib/stories/Overlay.stories.js +102 -0
- package/lib/stories/Portal.stories.js +108 -0
- package/lib/stories/ThemeProvider.stories.js +95 -0
- package/lib/stories/useAnchoredPosition.stories.js +349 -0
- package/lib/stories/useFocusTrap.stories.js +278 -0
- package/lib/stories/useFocusZone.stories.js +490 -0
- package/lib/theme-preval.js +2057 -5148
- package/lib/utils/deprecate.js +2 -3
- package/lib/utils/isNumeric.js +0 -1
- package/lib/utils/iterateFocusableElements.js +1 -1
- package/lib/utils/test-deprecations.js +0 -1
- package/lib/utils/test-matchers.js +12 -3
- package/lib/utils/testing.js +4 -4
- package/lib/utils/theme.js +1 -1
- package/lib/utils/{types/AriaRole.js → types.js} +0 -0
- package/lib/utils/uniqueId.js +0 -1
- package/lib-esm/AvatarPair.js +5 -6
- package/lib-esm/AvatarStack.js +11 -11
- package/lib-esm/BaseStyles.js +16 -16
- package/lib-esm/BorderBox.js +3 -5
- package/lib-esm/Box.js +2 -2
- package/lib-esm/BranchName.js +1 -1
- package/lib-esm/{Breadcrumbs.js → Breadcrumb.js} +22 -32
- package/lib-esm/Button/Button.js +1 -1
- package/lib-esm/Button/ButtonClose.js +2 -2
- package/lib-esm/Button/ButtonInvisible.js +1 -1
- package/lib-esm/Button/ButtonTableList.js +1 -1
- package/lib-esm/CircleBadge.js +1 -1
- package/lib-esm/CircleOcticon.js +6 -9
- package/lib-esm/CounterLabel.js +2 -2
- package/lib-esm/Dialog.js +12 -10
- package/lib-esm/Dropdown.js +2 -2
- package/lib-esm/DropdownStyles.js +6 -6
- package/lib-esm/FilterList.js +1 -1
- package/lib-esm/Flash.js +1 -1
- package/lib-esm/Flex.js +0 -4
- package/lib-esm/Grid.js +2 -5
- package/lib-esm/Header.js +0 -1
- package/lib-esm/Label.js +2 -2
- package/lib-esm/Link.js +12 -1
- package/lib-esm/Overlay.js +38 -119
- package/lib-esm/Pagehead.js +1 -1
- package/lib-esm/Pagination/Pagination.js +2 -3
- package/lib-esm/Popover.js +3 -3
- package/lib-esm/Portal/Portal.js +12 -19
- package/lib-esm/Portal/index.js +1 -1
- package/lib-esm/Position.js +20 -45
- package/lib-esm/ProgressBar.js +1 -1
- package/lib-esm/SelectMenu/SelectMenu.js +3 -3
- package/lib-esm/SelectMenu/SelectMenuContext.js +1 -1
- package/lib-esm/SelectMenu/SelectMenuDivider.js +1 -1
- package/lib-esm/SelectMenu/SelectMenuFilter.js +4 -4
- package/lib-esm/SelectMenu/SelectMenuFooter.js +1 -1
- package/lib-esm/SelectMenu/SelectMenuHeader.js +2 -2
- package/lib-esm/SelectMenu/SelectMenuItem.js +2 -2
- package/lib-esm/SelectMenu/SelectMenuList.js +1 -1
- package/lib-esm/SelectMenu/SelectMenuLoadingAnimation.js +10 -5
- package/lib-esm/SelectMenu/SelectMenuModal.js +5 -5
- package/lib-esm/SelectMenu/SelectMenuTab.js +1 -1
- package/lib-esm/SelectMenu/SelectMenuTabPanel.js +1 -1
- package/lib-esm/SelectMenu/hooks/useKeyboardNav.js +0 -2
- package/lib-esm/SideNav.js +7 -16
- package/lib-esm/StateLabel.js +4 -4
- package/lib-esm/SubNav.js +4 -7
- package/lib-esm/TabNav.js +4 -5
- package/lib-esm/TextInput.js +49 -22
- package/lib-esm/ThemeProvider.js +16 -31
- package/lib-esm/Timeline.js +24 -19
- package/lib-esm/Tooltip.js +1 -2
- package/lib-esm/UnderlineNav.js +3 -4
- package/lib-esm/behaviors/anchoredPosition.js +9 -17
- package/lib-esm/behaviors/focusTrap.js +14 -32
- package/lib-esm/behaviors/focusZone.js +148 -213
- package/lib-esm/constants.js +1 -2
- package/lib-esm/hooks/index.js +1 -2
- package/lib-esm/hooks/useAnchoredPosition.js +5 -10
- package/lib-esm/hooks/useDialog.js +1 -1
- package/lib-esm/hooks/useFocusTrap.js +8 -25
- package/lib-esm/hooks/useFocusZone.js +5 -5
- package/lib-esm/hooks/useMouseIntent.js +50 -0
- package/lib-esm/hooks/useOnEscapePress.js +10 -53
- package/lib-esm/hooks/useOnOutsideClick.js +37 -62
- package/lib-esm/hooks/useOpenAndCloseFocus.js +3 -8
- package/lib-esm/hooks/useOverlay.js +18 -9
- package/lib-esm/hooks/useSafeTimeout.js +0 -1
- package/lib-esm/index.js +10 -22
- package/lib-esm/polyfills/eventListenerSignal.js +1 -6
- package/lib-esm/stories/Button.stories.js +79 -0
- package/lib-esm/stories/Overlay.stories.js +80 -0
- package/lib-esm/stories/Portal.stories.js +72 -0
- package/lib-esm/stories/ThemeProvider.stories.js +76 -0
- package/lib-esm/stories/useAnchoredPosition.stories.js +311 -0
- package/lib-esm/stories/useFocusTrap.stories.js +234 -0
- package/lib-esm/stories/useFocusZone.stories.js +445 -0
- package/lib-esm/theme-preval.js +2057 -5148
- package/lib-esm/utils/deprecate.js +2 -3
- package/lib-esm/utils/isNumeric.js +0 -1
- package/lib-esm/utils/iterateFocusableElements.js +1 -1
- package/lib-esm/utils/test-deprecations.js +1 -1
- package/lib-esm/utils/test-matchers.js +11 -3
- package/lib-esm/utils/testing.js +6 -6
- package/lib-esm/utils/theme.js +1 -1
- package/lib-esm/utils/{test-helpers.d.ts → types.js} +0 -0
- package/lib-esm/utils/uniqueId.js +0 -1
- package/package.json +95 -103
- package/codemods/__tests__/deprecateUtilityComponents.js +0 -200
- package/codemods/__tests__/removeSystemProps.js +0 -225
- package/codemods/deprecateUtilityComponents.js +0 -111
- package/codemods/removeSystemProps.js +0 -312
- package/lib/ActionList/Divider.d.ts +0 -9
- package/lib/ActionList/Divider.js +0 -40
- package/lib/ActionList/Group.d.ts +0 -28
- package/lib/ActionList/Group.js +0 -35
- package/lib/ActionList/Header.d.ts +0 -29
- package/lib/ActionList/Header.js +0 -51
- package/lib/ActionList/Item.d.ts +0 -92
- package/lib/ActionList/Item.js +0 -288
- package/lib/ActionList/List.d.ts +0 -88
- package/lib/ActionList/List.js +0 -199
- package/lib/ActionList/index.d.ts +0 -17
- package/lib/ActionList/index.js +0 -29
- package/lib/ActionMenu.d.ts +0 -40
- package/lib/ActionMenu.js +0 -103
- package/lib/AnchoredOverlay/AnchoredOverlay.d.ts +0 -62
- package/lib/AnchoredOverlay/AnchoredOverlay.js +0 -124
- package/lib/AnchoredOverlay/index.d.ts +0 -2
- package/lib/AnchoredOverlay/index.js +0 -13
- package/lib/Autocomplete/Autocomplete.d.ts +0 -40
- package/lib/Autocomplete/Autocomplete.js +0 -68
- package/lib/Autocomplete/AutocompleteContext.d.ts +0 -17
- package/lib/Autocomplete/AutocompleteContext.js +0 -11
- package/lib/Autocomplete/AutocompleteInput.d.ts +0 -9
- package/lib/Autocomplete/AutocompleteInput.js +0 -150
- package/lib/Autocomplete/AutocompleteMenu.d.ts +0 -71
- package/lib/Autocomplete/AutocompleteMenu.js +0 -223
- package/lib/Autocomplete/AutocompleteOverlay.d.ts +0 -17
- package/lib/Autocomplete/AutocompleteOverlay.js +0 -69
- package/lib/Autocomplete/index.d.ts +0 -2
- package/lib/Autocomplete/index.js +0 -15
- package/lib/Avatar.d.ts +0 -15
- package/lib/AvatarPair.d.ts +0 -8
- package/lib/AvatarStack.d.ts +0 -8
- package/lib/BaseStyles.d.ts +0 -14
- package/lib/BorderBox.d.ts +0 -7
- package/lib/Box.d.ts +0 -6
- package/lib/BranchName.d.ts +0 -6
- package/lib/Breadcrumbs.d.ts +0 -40
- package/lib/Button/Button.d.ts +0 -284
- package/lib/Button/ButtonBase.d.ts +0 -12
- package/lib/Button/ButtonClose.d.ts +0 -321
- package/lib/Button/ButtonDanger.d.ts +0 -284
- package/lib/Button/ButtonGroup.d.ts +0 -4
- package/lib/Button/ButtonInvisible.d.ts +0 -284
- package/lib/Button/ButtonOutline.d.ts +0 -284
- package/lib/Button/ButtonPrimary.d.ts +0 -284
- package/lib/Button/ButtonStyles.d.ts +0 -2
- package/lib/Button/ButtonTableList.d.ts +0 -6
- package/lib/Button/index.d.ts +0 -16
- package/lib/Caret.d.ts +0 -21
- package/lib/CircleBadge.d.ts +0 -25
- package/lib/CircleOcticon.d.ts +0 -391
- package/lib/CounterLabel.d.ts +0 -8
- package/lib/Details.d.ts +0 -6
- package/lib/Dialog/ConfirmationDialog.d.ts +0 -44
- package/lib/Dialog/ConfirmationDialog.js +0 -191
- package/lib/Dialog/Dialog.d.ts +0 -167
- package/lib/Dialog/Dialog.js +0 -304
- package/lib/Dialog.d.ts +0 -406
- package/lib/Dropdown.d.ts +0 -1262
- package/lib/DropdownMenu/DropdownButton.d.ts +0 -323
- package/lib/DropdownMenu/DropdownButton.js +0 -31
- package/lib/DropdownMenu/DropdownMenu.d.ts +0 -43
- package/lib/DropdownMenu/DropdownMenu.js +0 -94
- package/lib/DropdownMenu/index.d.ts +0 -4
- package/lib/DropdownMenu/index.js +0 -21
- package/lib/DropdownStyles.d.ts +0 -3
- package/lib/FilterList.d.ts +0 -321
- package/lib/FilteredActionList/FilteredActionList.d.ts +0 -16
- package/lib/FilteredActionList/FilteredActionList.js +0 -137
- package/lib/FilteredActionList/index.d.ts +0 -2
- package/lib/FilteredActionList/index.js +0 -13
- package/lib/FilteredSearch.d.ts +0 -6
- package/lib/Flash.d.ts +0 -9
- package/lib/Flex.d.ts +0 -7
- package/lib/FormGroup.d.ts +0 -12
- package/lib/Grid.d.ts +0 -7
- package/lib/Header.d.ts +0 -24
- package/lib/Heading.d.ts +0 -6
- package/lib/Label.d.ts +0 -11
- package/lib/LabelGroup.d.ts +0 -6
- package/lib/Link.d.ts +0 -10
- package/lib/Overlay.d.ts +0 -63
- package/lib/Pagehead.d.ts +0 -6
- package/lib/Pagination/Pagination.d.ts +0 -24
- package/lib/Pagination/index.d.ts +0 -3
- package/lib/Pagination/model.d.ts +0 -26
- package/lib/PointerBox.d.ts +0 -11
- package/lib/Popover.d.ts +0 -21
- package/lib/Portal/Portal.d.ts +0 -25
- package/lib/Portal/index.d.ts +0 -4
- package/lib/Position.d.ts +0 -34
- package/lib/ProgressBar.d.ts +0 -21
- package/lib/SelectMenu/SelectMenu.d.ts +0 -1832
- package/lib/SelectMenu/SelectMenuContext.d.ts +0 -8
- package/lib/SelectMenu/SelectMenuDivider.d.ts +0 -6
- package/lib/SelectMenu/SelectMenuFilter.d.ts +0 -9
- package/lib/SelectMenu/SelectMenuFooter.d.ts +0 -6
- package/lib/SelectMenu/SelectMenuHeader.d.ts +0 -11
- package/lib/SelectMenu/SelectMenuItem.d.ts +0 -15
- package/lib/SelectMenu/SelectMenuList.d.ts +0 -6
- package/lib/SelectMenu/SelectMenuLoadingAnimation.d.ts +0 -7
- package/lib/SelectMenu/SelectMenuModal.d.ts +0 -15
- package/lib/SelectMenu/SelectMenuTab.d.ts +0 -14
- package/lib/SelectMenu/SelectMenuTabPanel.d.ts +0 -13
- package/lib/SelectMenu/SelectMenuTabs.d.ts +0 -11
- package/lib/SelectMenu/hooks/useKeyboardNav.d.ts +0 -2
- package/lib/SelectMenu/index.d.ts +0 -2
- package/lib/SelectPanel/SelectPanel.d.ts +0 -25
- package/lib/SelectPanel/SelectPanel.js +0 -147
- package/lib/SelectPanel/index.d.ts +0 -2
- package/lib/SelectPanel/index.js +0 -13
- package/lib/SideNav.d.ts +0 -31
- package/lib/Spinner.d.ts +0 -17
- package/lib/Spinner.js +0 -60
- package/lib/StateLabel.d.ts +0 -16
- package/lib/StyledOcticon.d.ts +0 -12
- package/lib/SubNav.d.ts +0 -32
- package/lib/TabNav.d.ts +0 -20
- package/lib/Text.d.ts +0 -6
- package/lib/TextInput.d.ts +0 -14
- package/lib/TextInputWithTokens.d.ts +0 -323
- package/lib/TextInputWithTokens.js +0 -244
- package/lib/ThemeProvider.d.ts +0 -26
- package/lib/Timeline.d.ts +0 -407
- package/lib/Token/IssueLabelToken.d.ts +0 -14
- package/lib/Token/IssueLabelToken.js +0 -144
- package/lib/Token/ProfileToken.d.ts +0 -7
- package/lib/Token/ProfileToken.js +0 -53
- package/lib/Token/Token.d.ts +0 -15
- package/lib/Token/Token.js +0 -94
- package/lib/Token/TokenBase.d.ts +0 -17
- package/lib/Token/TokenBase.js +0 -108
- package/lib/Token/_RemoveTokenButton.d.ts +0 -12
- package/lib/Token/_RemoveTokenButton.js +0 -77
- package/lib/Token/_TokenTextContainer.d.ts +0 -3
- package/lib/Token/_TokenTextContainer.js +0 -28
- package/lib/Token/index.d.ts +0 -3
- package/lib/Token/index.js +0 -31
- package/lib/Tooltip.d.ts +0 -18
- package/lib/Truncate.d.ts +0 -11
- package/lib/UnderlineNav.d.ts +0 -25
- package/lib/_TextInputWrapper.d.ts +0 -10
- package/lib/_TextInputWrapper.js +0 -51
- package/lib/_UnstyledTextInput.d.ts +0 -2
- package/lib/_UnstyledTextInput.js +0 -20
- package/lib/behaviors/anchoredPosition.d.ts +0 -89
- package/lib/behaviors/focusTrap.d.ts +0 -12
- package/lib/behaviors/focusZone.d.ts +0 -137
- package/lib/constants.d.ts +0 -20
- package/lib/hooks/index.d.ts +0 -11
- package/lib/hooks/useAnchoredPosition.d.ts +0 -20
- package/lib/hooks/useCombinedRefs.d.ts +0 -10
- package/lib/hooks/useCombinedRefs.js +0 -49
- package/lib/hooks/useDetails.d.ts +0 -17
- package/lib/hooks/useDialog.d.ts +0 -16
- package/lib/hooks/useFocusTrap.d.ts +0 -32
- package/lib/hooks/useFocusZone.d.ts +0 -23
- package/lib/hooks/useOnEscapePress.d.ts +0 -23
- package/lib/hooks/useOnOutsideClick.d.ts +0 -8
- package/lib/hooks/useOpenAndCloseFocus.d.ts +0 -8
- package/lib/hooks/useOverlay.d.ts +0 -15
- package/lib/hooks/useProvidedRefOrCreate.d.ts +0 -10
- package/lib/hooks/useProvidedStateOrCreate.d.ts +0 -10
- package/lib/hooks/useProvidedStateOrCreate.js +0 -27
- package/lib/hooks/useRenderForcingRef.d.ts +0 -8
- package/lib/hooks/useRenderForcingRef.js +0 -25
- package/lib/hooks/useResizeObserver.d.ts +0 -1
- package/lib/hooks/useResizeObserver.js +0 -20
- package/lib/hooks/useSafeTimeout.d.ts +0 -12
- package/lib/hooks/useScrollFlash.d.ts +0 -6
- package/lib/hooks/useScrollFlash.js +0 -29
- package/lib/index.d.ts +0 -114
- package/lib/polyfills/eventListenerSignal.d.ts +0 -6
- package/lib/sx.d.ts +0 -6
- package/lib/theme-preval.d.ts +0 -49
- package/lib/theme.d.ts +0 -2
- package/lib/utils/deprecate.d.ts +0 -18
- package/lib/utils/isNumeric.d.ts +0 -1
- package/lib/utils/iterateFocusableElements.d.ts +0 -42
- package/lib/utils/scrollIntoViewingArea.d.ts +0 -1
- package/lib/utils/scrollIntoViewingArea.js +0 -39
- package/lib/utils/ssr.d.ts +0 -1
- package/lib/utils/ssr.js +0 -19
- package/lib/utils/test-deprecations.d.ts +0 -1
- package/lib/utils/test-helpers.d.ts +0 -0
- package/lib/utils/test-helpers.js +0 -9
- package/lib/utils/test-matchers.d.ts +0 -1
- package/lib/utils/testing.d.ts +0 -1028
- package/lib/utils/theme.d.ts +0 -9
- package/lib/utils/types/AriaRole.d.ts +0 -4
- package/lib/utils/types/ComponentProps.d.ts +0 -9
- package/lib/utils/types/ComponentProps.js +0 -1
- package/lib/utils/types/Flatten.d.ts +0 -4
- package/lib/utils/types/Flatten.js +0 -1
- package/lib/utils/types/Merge.d.ts +0 -19
- package/lib/utils/types/Merge.js +0 -1
- package/lib/utils/types/index.d.ts +0 -4
- package/lib/utils/types/index.js +0 -57
- package/lib/utils/uniqueId.d.ts +0 -1
- package/lib/utils/userAgent.d.ts +0 -1
- package/lib-esm/ActionList/Divider.d.ts +0 -9
- package/lib-esm/ActionList/Divider.js +0 -23
- package/lib-esm/ActionList/Group.d.ts +0 -28
- package/lib-esm/ActionList/Group.js +0 -24
- package/lib-esm/ActionList/Header.d.ts +0 -29
- package/lib-esm/ActionList/Header.js +0 -33
- package/lib-esm/ActionList/Item.d.ts +0 -92
- package/lib-esm/ActionList/Item.js +0 -253
- package/lib-esm/ActionList/List.d.ts +0 -88
- package/lib-esm/ActionList/List.js +0 -181
- package/lib-esm/ActionList/index.d.ts +0 -17
- package/lib-esm/ActionList/index.js +0 -18
- package/lib-esm/ActionMenu.d.ts +0 -40
- package/lib-esm/ActionMenu.js +0 -82
- package/lib-esm/AnchoredOverlay/AnchoredOverlay.d.ts +0 -62
- package/lib-esm/AnchoredOverlay/AnchoredOverlay.js +0 -104
- package/lib-esm/AnchoredOverlay/index.d.ts +0 -2
- package/lib-esm/AnchoredOverlay/index.js +0 -1
- package/lib-esm/Autocomplete/Autocomplete.d.ts +0 -40
- package/lib-esm/Autocomplete/Autocomplete.js +0 -47
- package/lib-esm/Autocomplete/AutocompleteContext.d.ts +0 -17
- package/lib-esm/Autocomplete/AutocompleteContext.js +0 -2
- package/lib-esm/Autocomplete/AutocompleteInput.d.ts +0 -9
- package/lib-esm/Autocomplete/AutocompleteInput.js +0 -131
- package/lib-esm/Autocomplete/AutocompleteMenu.d.ts +0 -71
- package/lib-esm/Autocomplete/AutocompleteMenu.js +0 -204
- package/lib-esm/Autocomplete/AutocompleteOverlay.d.ts +0 -17
- package/lib-esm/Autocomplete/AutocompleteOverlay.js +0 -51
- package/lib-esm/Autocomplete/index.d.ts +0 -2
- package/lib-esm/Autocomplete/index.js +0 -1
- package/lib-esm/Avatar.d.ts +0 -15
- package/lib-esm/AvatarPair.d.ts +0 -8
- package/lib-esm/AvatarStack.d.ts +0 -8
- package/lib-esm/BaseStyles.d.ts +0 -14
- package/lib-esm/BorderBox.d.ts +0 -7
- package/lib-esm/Box.d.ts +0 -6
- package/lib-esm/BranchName.d.ts +0 -6
- package/lib-esm/Breadcrumbs.d.ts +0 -40
- package/lib-esm/Button/Button.d.ts +0 -284
- package/lib-esm/Button/ButtonBase.d.ts +0 -12
- package/lib-esm/Button/ButtonClose.d.ts +0 -321
- package/lib-esm/Button/ButtonDanger.d.ts +0 -284
- package/lib-esm/Button/ButtonGroup.d.ts +0 -4
- package/lib-esm/Button/ButtonInvisible.d.ts +0 -284
- package/lib-esm/Button/ButtonOutline.d.ts +0 -284
- package/lib-esm/Button/ButtonPrimary.d.ts +0 -284
- package/lib-esm/Button/ButtonStyles.d.ts +0 -2
- package/lib-esm/Button/ButtonTableList.d.ts +0 -6
- package/lib-esm/Button/index.d.ts +0 -16
- package/lib-esm/Caret.d.ts +0 -21
- package/lib-esm/CircleBadge.d.ts +0 -25
- package/lib-esm/CircleOcticon.d.ts +0 -391
- package/lib-esm/CounterLabel.d.ts +0 -8
- package/lib-esm/Details.d.ts +0 -6
- package/lib-esm/Dialog/ConfirmationDialog.d.ts +0 -44
- package/lib-esm/Dialog/ConfirmationDialog.js +0 -169
- package/lib-esm/Dialog/Dialog.d.ts +0 -167
- package/lib-esm/Dialog/Dialog.js +0 -274
- package/lib-esm/Dialog.d.ts +0 -406
- package/lib-esm/Dropdown.d.ts +0 -1262
- package/lib-esm/DropdownMenu/DropdownButton.d.ts +0 -323
- package/lib-esm/DropdownMenu/DropdownButton.js +0 -16
- package/lib-esm/DropdownMenu/DropdownMenu.d.ts +0 -43
- package/lib-esm/DropdownMenu/DropdownMenu.js +0 -77
- package/lib-esm/DropdownMenu/index.d.ts +0 -4
- package/lib-esm/DropdownMenu/index.js +0 -2
- package/lib-esm/DropdownStyles.d.ts +0 -3
- package/lib-esm/FilterList.d.ts +0 -321
- package/lib-esm/FilteredActionList/FilteredActionList.d.ts +0 -16
- package/lib-esm/FilteredActionList/FilteredActionList.js +0 -109
- package/lib-esm/FilteredActionList/index.d.ts +0 -2
- package/lib-esm/FilteredActionList/index.js +0 -1
- package/lib-esm/FilteredSearch.d.ts +0 -6
- package/lib-esm/Flash.d.ts +0 -9
- package/lib-esm/Flex.d.ts +0 -7
- package/lib-esm/FormGroup.d.ts +0 -12
- package/lib-esm/Grid.d.ts +0 -7
- package/lib-esm/Header.d.ts +0 -24
- package/lib-esm/Heading.d.ts +0 -6
- package/lib-esm/Label.d.ts +0 -11
- package/lib-esm/LabelGroup.d.ts +0 -6
- package/lib-esm/Link.d.ts +0 -10
- package/lib-esm/Overlay.d.ts +0 -63
- package/lib-esm/Pagehead.d.ts +0 -6
- package/lib-esm/Pagination/Pagination.d.ts +0 -24
- package/lib-esm/Pagination/index.d.ts +0 -3
- package/lib-esm/Pagination/model.d.ts +0 -26
- package/lib-esm/PointerBox.d.ts +0 -11
- package/lib-esm/Popover.d.ts +0 -21
- package/lib-esm/Portal/Portal.d.ts +0 -25
- package/lib-esm/Portal/index.d.ts +0 -4
- package/lib-esm/Position.d.ts +0 -34
- package/lib-esm/ProgressBar.d.ts +0 -21
- package/lib-esm/SelectMenu/SelectMenu.d.ts +0 -1832
- package/lib-esm/SelectMenu/SelectMenuContext.d.ts +0 -8
- package/lib-esm/SelectMenu/SelectMenuDivider.d.ts +0 -6
- package/lib-esm/SelectMenu/SelectMenuFilter.d.ts +0 -9
- package/lib-esm/SelectMenu/SelectMenuFooter.d.ts +0 -6
- package/lib-esm/SelectMenu/SelectMenuHeader.d.ts +0 -11
- package/lib-esm/SelectMenu/SelectMenuItem.d.ts +0 -15
- package/lib-esm/SelectMenu/SelectMenuList.d.ts +0 -6
- package/lib-esm/SelectMenu/SelectMenuLoadingAnimation.d.ts +0 -7
- package/lib-esm/SelectMenu/SelectMenuModal.d.ts +0 -15
- package/lib-esm/SelectMenu/SelectMenuTab.d.ts +0 -14
- package/lib-esm/SelectMenu/SelectMenuTabPanel.d.ts +0 -13
- package/lib-esm/SelectMenu/SelectMenuTabs.d.ts +0 -11
- package/lib-esm/SelectMenu/hooks/useKeyboardNav.d.ts +0 -2
- package/lib-esm/SelectMenu/index.d.ts +0 -2
- package/lib-esm/SelectPanel/SelectPanel.d.ts +0 -25
- package/lib-esm/SelectPanel/SelectPanel.js +0 -127
- package/lib-esm/SelectPanel/index.d.ts +0 -2
- package/lib-esm/SelectPanel/index.js +0 -1
- package/lib-esm/SideNav.d.ts +0 -31
- package/lib-esm/Spinner.d.ts +0 -17
- package/lib-esm/Spinner.js +0 -46
- package/lib-esm/StateLabel.d.ts +0 -16
- package/lib-esm/StyledOcticon.d.ts +0 -12
- package/lib-esm/SubNav.d.ts +0 -32
- package/lib-esm/TabNav.d.ts +0 -20
- package/lib-esm/Text.d.ts +0 -6
- package/lib-esm/TextInput.d.ts +0 -14
- package/lib-esm/TextInputWithTokens.d.ts +0 -323
- package/lib-esm/TextInputWithTokens.js +0 -219
- package/lib-esm/ThemeProvider.d.ts +0 -26
- package/lib-esm/Timeline.d.ts +0 -407
- package/lib-esm/Token/IssueLabelToken.d.ts +0 -14
- package/lib-esm/Token/IssueLabelToken.js +0 -124
- package/lib-esm/Token/ProfileToken.d.ts +0 -7
- package/lib-esm/Token/ProfileToken.js +0 -33
- package/lib-esm/Token/Token.d.ts +0 -15
- package/lib-esm/Token/Token.js +0 -73
- package/lib-esm/Token/TokenBase.d.ts +0 -17
- package/lib-esm/Token/TokenBase.js +0 -87
- package/lib-esm/Token/_RemoveTokenButton.d.ts +0 -12
- package/lib-esm/Token/_RemoveTokenButton.js +0 -60
- package/lib-esm/Token/_TokenTextContainer.d.ts +0 -3
- package/lib-esm/Token/_TokenTextContainer.js +0 -15
- package/lib-esm/Token/index.d.ts +0 -3
- package/lib-esm/Token/index.js +0 -3
- package/lib-esm/Tooltip.d.ts +0 -18
- package/lib-esm/Truncate.d.ts +0 -11
- package/lib-esm/UnderlineNav.d.ts +0 -25
- package/lib-esm/_TextInputWrapper.d.ts +0 -10
- package/lib-esm/_TextInputWrapper.js +0 -31
- package/lib-esm/_UnstyledTextInput.d.ts +0 -2
- package/lib-esm/_UnstyledTextInput.js +0 -7
- package/lib-esm/behaviors/anchoredPosition.d.ts +0 -89
- package/lib-esm/behaviors/focusTrap.d.ts +0 -12
- package/lib-esm/behaviors/focusZone.d.ts +0 -137
- package/lib-esm/constants.d.ts +0 -20
- package/lib-esm/hooks/index.d.ts +0 -11
- package/lib-esm/hooks/useAnchoredPosition.d.ts +0 -20
- package/lib-esm/hooks/useCombinedRefs.d.ts +0 -10
- package/lib-esm/hooks/useCombinedRefs.js +0 -36
- package/lib-esm/hooks/useDetails.d.ts +0 -17
- package/lib-esm/hooks/useDialog.d.ts +0 -16
- package/lib-esm/hooks/useFocusTrap.d.ts +0 -32
- package/lib-esm/hooks/useFocusZone.d.ts +0 -23
- package/lib-esm/hooks/useOnEscapePress.d.ts +0 -23
- package/lib-esm/hooks/useOnOutsideClick.d.ts +0 -8
- package/lib-esm/hooks/useOpenAndCloseFocus.d.ts +0 -8
- package/lib-esm/hooks/useOverlay.d.ts +0 -15
- package/lib-esm/hooks/useProvidedRefOrCreate.d.ts +0 -10
- package/lib-esm/hooks/useProvidedStateOrCreate.d.ts +0 -10
- package/lib-esm/hooks/useProvidedStateOrCreate.js +0 -20
- package/lib-esm/hooks/useRenderForcingRef.d.ts +0 -8
- package/lib-esm/hooks/useRenderForcingRef.js +0 -18
- package/lib-esm/hooks/useResizeObserver.d.ts +0 -1
- package/lib-esm/hooks/useResizeObserver.js +0 -10
- package/lib-esm/hooks/useSafeTimeout.d.ts +0 -12
- package/lib-esm/hooks/useScrollFlash.d.ts +0 -6
- package/lib-esm/hooks/useScrollFlash.js +0 -22
- package/lib-esm/index.d.ts +0 -114
- package/lib-esm/polyfills/eventListenerSignal.d.ts +0 -6
- package/lib-esm/sx.d.ts +0 -6
- package/lib-esm/theme-preval.d.ts +0 -49
- package/lib-esm/theme.d.ts +0 -2
- package/lib-esm/utils/deprecate.d.ts +0 -18
- package/lib-esm/utils/isNumeric.d.ts +0 -1
- package/lib-esm/utils/iterateFocusableElements.d.ts +0 -42
- package/lib-esm/utils/scrollIntoViewingArea.d.ts +0 -1
- package/lib-esm/utils/scrollIntoViewingArea.js +0 -30
- package/lib-esm/utils/ssr.d.ts +0 -1
- package/lib-esm/utils/ssr.js +0 -1
- package/lib-esm/utils/test-deprecations.d.ts +0 -1
- package/lib-esm/utils/test-helpers.js +0 -7
- package/lib-esm/utils/test-matchers.d.ts +0 -1
- package/lib-esm/utils/testing.d.ts +0 -1028
- package/lib-esm/utils/theme.d.ts +0 -9
- package/lib-esm/utils/types/AriaRole.d.ts +0 -4
- package/lib-esm/utils/types/AriaRole.js +0 -1
- package/lib-esm/utils/types/ComponentProps.d.ts +0 -9
- package/lib-esm/utils/types/ComponentProps.js +0 -1
- package/lib-esm/utils/types/Flatten.d.ts +0 -4
- package/lib-esm/utils/types/Flatten.js +0 -1
- package/lib-esm/utils/types/Merge.d.ts +0 -19
- package/lib-esm/utils/types/Merge.js +0 -1
- package/lib-esm/utils/types/index.d.ts +0 -4
- package/lib-esm/utils/types/index.js +0 -4
- package/lib-esm/utils/uniqueId.d.ts +0 -1
- package/lib-esm/utils/userAgent.d.ts +0 -1
@@ -1,89 +0,0 @@
|
|
1
|
-
export declare type AnchorAlignment = 'start' | 'center' | 'end';
|
2
|
-
export declare type AnchorSide = 'inside-top' | 'inside-bottom' | 'inside-left' | 'inside-right' | 'inside-center' | 'outside-top' | 'outside-bottom' | 'outside-left' | 'outside-right';
|
3
|
-
/**
|
4
|
-
* Settings that customize how a floating element is positioned
|
5
|
-
* with respect to an anchor element.
|
6
|
-
*/
|
7
|
-
export interface PositionSettings {
|
8
|
-
/**
|
9
|
-
* Sets the side of the anchor element that the floating element should be
|
10
|
-
* pinned to. This side is given by a string starting with either "inside" or
|
11
|
-
* "outside", followed by a hyphen, followed by either "top", "right", "bottom",
|
12
|
-
* or "left". Additionally, "inside-center" is an allowed value.
|
13
|
-
*
|
14
|
-
* The first part of this string, "inside" or "outside", determines whether the
|
15
|
-
* floating element should be attempted to be placed "inside" the anchor element
|
16
|
-
* or "outside" of it. Using "inside" is useful for making it appear that the
|
17
|
-
* anchor _contains_ the floating element, and it can be used for implementing a
|
18
|
-
* dialog that is centered on the screen. The "outside" value is more common and
|
19
|
-
* can be used for tooltips, popovers, menus, etc.
|
20
|
-
*
|
21
|
-
* The second part of this string determines the _edge_ on the anchor element that
|
22
|
-
* the floating element will be anchored to. If side is "inside-center", then
|
23
|
-
* the floating element will be centered in the X-direction (while align is used
|
24
|
-
* to position it in the Y-direction).
|
25
|
-
* Note: "outside-center" is _not_ a valid value for this property.
|
26
|
-
*/
|
27
|
-
side: AnchorSide;
|
28
|
-
/**
|
29
|
-
* Determines how the floating element should align with the anchor element. If
|
30
|
-
* set to "start", the floating element's first edge (top or left) will align
|
31
|
-
* with the anchor element's first edge. If set to "center", the floating
|
32
|
-
* element will be centered along the axis of the anchor edge. If set to "end",
|
33
|
-
* the floating element's last edge will align with the anchor element's last edge.
|
34
|
-
*/
|
35
|
-
align: AnchorAlignment;
|
36
|
-
/**
|
37
|
-
* The number of pixels between the anchor edge and the floating element.
|
38
|
-
*
|
39
|
-
* Positive values move the floating element farther from the anchor element
|
40
|
-
* (for outside positioning) or further inside the anchor element (for inside
|
41
|
-
* positioning). Negative values have the opposite effect.
|
42
|
-
*/
|
43
|
-
anchorOffset: number;
|
44
|
-
/**
|
45
|
-
* An additional offset, in pixels, to move the floating element from
|
46
|
-
* the aligning edge.
|
47
|
-
*
|
48
|
-
* Positive values move the floating element in the direction of center-
|
49
|
-
* alignment. Negative values move the floating element away from center-
|
50
|
-
* alignment. When align is "center", positive offsets move the floating
|
51
|
-
* element right (top or bottom anchor side) or down (left or right
|
52
|
-
* anchor side).
|
53
|
-
*/
|
54
|
-
alignmentOffset: number;
|
55
|
-
/**
|
56
|
-
* If false, when the above settings result in rendering the floating element
|
57
|
-
* wholly or partially outside of the bounds of the containing element, attempt
|
58
|
-
* to adjust the settings to prevent this. Only applies to "outside" positioning.
|
59
|
-
*
|
60
|
-
* First, attempt to flip to the opposite edge of the anchor if the floating
|
61
|
-
* element is getting clipped in that direction. If flipping results in a
|
62
|
-
* similar clipping, try moving to the adjacent sides.
|
63
|
-
*
|
64
|
-
* Once we find a side that does not clip the overlay in its own dimension,
|
65
|
-
* check the rest of the sides to see if we need to adjust the alignment offset
|
66
|
-
* to fit in other dimensions.
|
67
|
-
*
|
68
|
-
* If we try all four sides and get clipped each time, settle for overflowing
|
69
|
-
* and use the "bottom" side, since the ability to scroll is most likely in
|
70
|
-
* this direction.
|
71
|
-
*/
|
72
|
-
allowOutOfBounds: boolean;
|
73
|
-
}
|
74
|
-
export interface AnchorPosition {
|
75
|
-
top: number;
|
76
|
-
left: number;
|
77
|
-
anchorSide: AnchorSide;
|
78
|
-
}
|
79
|
-
/**
|
80
|
-
* Given a floating element and an anchor element, return coordinates for the top-left
|
81
|
-
* of the floating element in order to absolutely position it such that it appears
|
82
|
-
* near the anchor element.
|
83
|
-
*
|
84
|
-
* @param floatingElement Element intended to be positioned near or within an anchor
|
85
|
-
* @param anchorElement The element to serve as the position anchor
|
86
|
-
* @param settings Settings to determine the rules for positioning the floating element
|
87
|
-
* @returns {top: number, left: number} coordinates for the floating element
|
88
|
-
*/
|
89
|
-
export declare function getAnchoredPosition(floatingElement: Element, anchorElement: Element | DOMRect, settings?: Partial<PositionSettings>): AnchorPosition;
|
@@ -1,12 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Traps focus within the given container.
|
3
|
-
* @param container The container in which to trap focus
|
4
|
-
* @returns AbortController - call `.abort()` to disable the focus trap
|
5
|
-
*/
|
6
|
-
export declare function focusTrap(container: HTMLElement, initialFocus?: HTMLElement): AbortController;
|
7
|
-
/**
|
8
|
-
* Traps focus within the given container.
|
9
|
-
* @param container The container in which to trap focus
|
10
|
-
* @param abortSignal An AbortSignal to control the focus trap.
|
11
|
-
*/
|
12
|
-
export declare function focusTrap(container: HTMLElement, initialFocus: HTMLElement | undefined, abortSignal: AbortSignal): void;
|
@@ -1,137 +0,0 @@
|
|
1
|
-
export declare type Direction = 'previous' | 'next' | 'start' | 'end';
|
2
|
-
export declare type FocusMovementKeys = 'ArrowLeft' | 'ArrowDown' | 'ArrowUp' | 'ArrowRight' | 'h' | 'j' | 'k' | 'l' | 'a' | 's' | 'w' | 'd' | 'Tab' | 'Home' | 'End' | 'PageUp' | 'PageDown';
|
3
|
-
export declare enum FocusKeys {
|
4
|
-
ArrowHorizontal = 1,
|
5
|
-
ArrowVertical = 2,
|
6
|
-
JK = 4,
|
7
|
-
HL = 8,
|
8
|
-
HomeAndEnd = 16,
|
9
|
-
PageUpDown = 256,
|
10
|
-
WS = 32,
|
11
|
-
AD = 64,
|
12
|
-
Tab = 128,
|
13
|
-
ArrowAll = 3,
|
14
|
-
HJKL = 12,
|
15
|
-
WASD = 96,
|
16
|
-
All = 511
|
17
|
-
}
|
18
|
-
/**
|
19
|
-
* Options that control the behavior of the arrow focus behavior.
|
20
|
-
*/
|
21
|
-
export interface FocusZoneSettings {
|
22
|
-
/**
|
23
|
-
* Choose the behavior applied in cases where focus is currently at either the first or
|
24
|
-
* last element of the container.
|
25
|
-
*
|
26
|
-
* "stop" - do nothing and keep focus where it was
|
27
|
-
* "wrap" - wrap focus around to the first element from the last, or the last element from the first
|
28
|
-
*
|
29
|
-
* Default: "stop"
|
30
|
-
*/
|
31
|
-
focusOutBehavior?: 'stop' | 'wrap';
|
32
|
-
/**
|
33
|
-
* If set, this will be called to get the next focusable element. If this function
|
34
|
-
* returns null, we will try to determine the next direction ourselves. Use the
|
35
|
-
* `bindKeys` option to customize which keys are listened to.
|
36
|
-
*
|
37
|
-
* The function can accept a Direction, indicating the direction focus should move,
|
38
|
-
* the HTMLElement that was previously focused, and lastly the `KeyboardEvent` object
|
39
|
-
* created by the original `"keydown"` event.
|
40
|
-
*/
|
41
|
-
getNextFocusable?: (direction: Direction, from: Element | undefined, event: KeyboardEvent) => HTMLElement | undefined;
|
42
|
-
/**
|
43
|
-
* Called to decide if a focusable element is allowed to participate in the arrow
|
44
|
-
* key focus behavior.
|
45
|
-
*
|
46
|
-
* By default, all focusable elements within the given container will participate
|
47
|
-
* in the arrow key focus behavior. If you need to withhold some elements from
|
48
|
-
* participation, implement this callback to return false for those elements.
|
49
|
-
*/
|
50
|
-
focusableElementFilter?: (element: HTMLElement) => boolean;
|
51
|
-
/**
|
52
|
-
* Bit flags that identify keys that will be bound to. Each available key either
|
53
|
-
* moves focus to the "next" element or the "previous" element, so it is best
|
54
|
-
* to only bind the keys that make sense to move focus in your UI. Use the `FocusKeys`
|
55
|
-
* object to discover supported keys.
|
56
|
-
*
|
57
|
-
* Use the bitwise "OR" operator (`|`) to combine key types. For example,
|
58
|
-
* `FocusKeys.WASD | FocusKeys.HJKL` represents all of W, A, S, D, H, J, K, and L.
|
59
|
-
*
|
60
|
-
* A note on FocusKeys.PageUpDown: This behavior does not support paging, so by default
|
61
|
-
* using these keys will result in the same behavior as Home and End. To override this
|
62
|
-
* behavior, implement `getNextFocusable`.
|
63
|
-
*
|
64
|
-
* The default for this setting is `FocusKeys.ArrowVertical | FocusKeys.HomeAndEnd`, unless
|
65
|
-
* `getNextFocusable` is provided, in which case `FocusKeys.ArrowAll | FocusKeys.HomeAndEnd`
|
66
|
-
* is used as the default.
|
67
|
-
*/
|
68
|
-
bindKeys?: FocusKeys;
|
69
|
-
/**
|
70
|
-
* If provided, this signal can be used to disable the behavior and remove any
|
71
|
-
* event listeners.
|
72
|
-
*/
|
73
|
-
abortSignal?: AbortSignal;
|
74
|
-
/**
|
75
|
-
* If `activeDescendantControl` is supplied, do not move focus or alter `tabindex` on
|
76
|
-
* any element. Instead, manage `aria-activedescendant` according to the ARIA best
|
77
|
-
* practices guidelines.
|
78
|
-
* @see https://www.w3.org/TR/wai-aria-practices-1.1/#kbd_focus_activedescendant
|
79
|
-
*
|
80
|
-
* The given `activeDescendantControl` will be given an `aria-controls` attribute that
|
81
|
-
* references the ID of the `container`. Additionally, it will be given an
|
82
|
-
* `aria-activedescendant` attribute that references the ID of the currently-active
|
83
|
-
* descendant.
|
84
|
-
*
|
85
|
-
* This element will retain DOM focus as arrow keys are pressed.
|
86
|
-
*/
|
87
|
-
activeDescendantControl?: HTMLElement;
|
88
|
-
/**
|
89
|
-
* Called each time the active descendant changes. Note that either of the parameters
|
90
|
-
* may be undefined, e.g. when an element in the container first becomes active, or
|
91
|
-
* when the controlling element becomes unfocused.
|
92
|
-
*/
|
93
|
-
onActiveDescendantChanged?: (newActiveDescendant: HTMLElement | undefined, previousActiveDescendant: HTMLElement | undefined, directlyActivated: boolean) => void;
|
94
|
-
/**
|
95
|
-
* This option allows customization of the behavior that determines which of the
|
96
|
-
* focusable elements should be focused when focus enters the container via the Tab key.
|
97
|
-
*
|
98
|
-
* When set to "first", whenever focus enters the container via Tab, we will focus the
|
99
|
-
* first focusable element. When set to "previous", the most recently focused element
|
100
|
-
* will be focused (fallback to first if there was no previous).
|
101
|
-
*
|
102
|
-
* The "closest" strategy works like "first", except either the first or the last element
|
103
|
-
* of the container will be focused, depending on the direction from which focus comes.
|
104
|
-
*
|
105
|
-
* If a function is provided, this function should return the HTMLElement intended
|
106
|
-
* to receive focus. This is useful if you want to focus the currently "selected"
|
107
|
-
* item or element.
|
108
|
-
*
|
109
|
-
* Default: "previous"
|
110
|
-
*
|
111
|
-
* For more information, @see https://www.w3.org/TR/wai-aria-practices-1.1/#kbd_general_within
|
112
|
-
*/
|
113
|
-
focusInStrategy?: 'first' | 'closest' | 'previous' | ((previousFocusedElement: Element) => HTMLElement | undefined);
|
114
|
-
}
|
115
|
-
export declare const isActiveDescendantAttribute = "data-is-active-descendant";
|
116
|
-
/**
|
117
|
-
* A value of activated-directly for data-is-active-descendant indicates the descendant was activated
|
118
|
-
* by a manual user interaction with intent to move active descendant. This usually translates to the
|
119
|
-
* user pressing one of the bound keys (up/down arrow, etc) to move through the focus zone. This is
|
120
|
-
* intended to be roughly equivalent to the :focus-visible pseudo-class
|
121
|
-
**/
|
122
|
-
export declare const activeDescendantActivatedDirectly = "activated-directly";
|
123
|
-
/**
|
124
|
-
* A value of activated-indirectly for data-is-active-descendant indicates the descendant was activated
|
125
|
-
* implicitly, and not by a direct key press. This includes focus zone being created from scratch, focusable
|
126
|
-
* elements being added/removed, and mouseover events. This is intended to be roughly equivalent
|
127
|
-
* to :focus:not(:focus-visible)
|
128
|
-
**/
|
129
|
-
export declare const activeDescendantActivatedIndirectly = "activated-indirectly";
|
130
|
-
export declare const hasActiveDescendantAttribute = "data-has-active-descendant";
|
131
|
-
/**
|
132
|
-
* Sets up the arrow key focus behavior for all focusable elements in the given `container`.
|
133
|
-
* @param container
|
134
|
-
* @param settings
|
135
|
-
* @returns
|
136
|
-
*/
|
137
|
-
export declare function focusZone(container: HTMLElement, settings?: FocusZoneSettings): AbortController;
|
package/lib-esm/constants.d.ts
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
import * as styledSystem from 'styled-system';
|
2
|
-
export declare const get: (key: string) => (props: any) => any;
|
3
|
-
export declare const COMMON: styledSystem.styleFn;
|
4
|
-
export interface SystemCommonProps extends styledSystem.ColorProps, styledSystem.SpaceProps, styledSystem.DisplayProps {
|
5
|
-
}
|
6
|
-
export declare const TYPOGRAPHY: styledSystem.styleFn;
|
7
|
-
export interface SystemTypographyProps extends styledSystem.TypographyProps {
|
8
|
-
whiteSpace?: 'normal' | 'nowrap' | 'pre' | 'pre-wrap' | 'pre-line';
|
9
|
-
}
|
10
|
-
export declare const BORDER: styledSystem.styleFn;
|
11
|
-
export interface SystemBorderProps extends styledSystem.BorderProps, styledSystem.ShadowProps {
|
12
|
-
}
|
13
|
-
export declare const LAYOUT: styledSystem.styleFn;
|
14
|
-
export declare type SystemLayoutProps = styledSystem.LayoutProps;
|
15
|
-
export declare const POSITION: styledSystem.styleFn;
|
16
|
-
export declare type SystemPositionProps = styledSystem.PositionProps;
|
17
|
-
export declare const FLEX: styledSystem.styleFn;
|
18
|
-
export declare type SystemFlexProps = styledSystem.FlexboxProps;
|
19
|
-
export declare const GRID: styledSystem.styleFn;
|
20
|
-
export declare type SystemGridProps = styledSystem.GridProps;
|
package/lib-esm/hooks/index.d.ts
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
export { useOnOutsideClick } from './useOnOutsideClick';
|
2
|
-
export type { UseOnOutsideClickSettings, TouchOrMouseEvent } from './useOnOutsideClick';
|
3
|
-
export { useProvidedRefOrCreate } from './useProvidedRefOrCreate';
|
4
|
-
export { useOnEscapePress } from './useOnEscapePress';
|
5
|
-
export { useOpenAndCloseFocus } from './useOpenAndCloseFocus';
|
6
|
-
export type { UseOpenAndCloseFocusSettings } from './useOpenAndCloseFocus';
|
7
|
-
export type { AnchoredPositionHookSettings } from './useAnchoredPosition';
|
8
|
-
export { useAnchoredPosition } from './useAnchoredPosition';
|
9
|
-
export { useOverlay } from './useOverlay';
|
10
|
-
export type { UseOverlaySettings } from './useOverlay';
|
11
|
-
export { useRenderForcingRef } from './useRenderForcingRef';
|
@@ -1,20 +0,0 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
import { PositionSettings, AnchorPosition } from '../behaviors/anchoredPosition';
|
3
|
-
export interface AnchoredPositionHookSettings extends Partial<PositionSettings> {
|
4
|
-
floatingElementRef?: React.RefObject<Element>;
|
5
|
-
anchorElementRef?: React.RefObject<Element>;
|
6
|
-
}
|
7
|
-
/**
|
8
|
-
* Calculates the top and left values for an absolutely-positioned floating element
|
9
|
-
* to be anchored to some anchor element. Returns refs for the floating element
|
10
|
-
* and the anchor element, along with the position.
|
11
|
-
* @param settings Settings for calculating the anchored position.
|
12
|
-
* @param dependencies Dependencies to determine when to re-calculate the position.
|
13
|
-
* @returns An object of {top: number, left: number} to absolutely-position the
|
14
|
-
* floating element.
|
15
|
-
*/
|
16
|
-
export declare function useAnchoredPosition(settings?: AnchoredPositionHookSettings, dependencies?: React.DependencyList): {
|
17
|
-
floatingElementRef: React.RefObject<Element>;
|
18
|
-
anchorElementRef: React.RefObject<Element>;
|
19
|
-
position: AnchorPosition | undefined;
|
20
|
-
};
|
@@ -1,10 +0,0 @@
|
|
1
|
-
import React, { ForwardedRef } from 'react';
|
2
|
-
/**
|
3
|
-
* Creates a ref by combining multiple constituent refs. The ref returned by this hook
|
4
|
-
* should be passed as the ref for the element that needs to be shared. This is
|
5
|
-
* particularly useful when you are using `React.forwardRef` in your component but you
|
6
|
-
* also want to be able to access the local element. This is a small anti-pattern,
|
7
|
-
* though, as it breaks encapsulation.
|
8
|
-
* @param refs
|
9
|
-
*/
|
10
|
-
export declare function useCombinedRefs<T>(...refs: (ForwardedRef<T> | null | undefined)[]): React.MutableRefObject<T | null>;
|
@@ -1,36 +0,0 @@
|
|
1
|
-
import React, { useRef } from 'react';
|
2
|
-
/**
|
3
|
-
* Creates a ref by combining multiple constituent refs. The ref returned by this hook
|
4
|
-
* should be passed as the ref for the element that needs to be shared. This is
|
5
|
-
* particularly useful when you are using `React.forwardRef` in your component but you
|
6
|
-
* also want to be able to access the local element. This is a small anti-pattern,
|
7
|
-
* though, as it breaks encapsulation.
|
8
|
-
* @param refs
|
9
|
-
*/
|
10
|
-
|
11
|
-
export function useCombinedRefs(...refs) {
|
12
|
-
const combinedRef = useRef(null);
|
13
|
-
React.useLayoutEffect(() => {
|
14
|
-
function setRefs(current = null) {
|
15
|
-
for (const ref of refs) {
|
16
|
-
if (!ref) {
|
17
|
-
return;
|
18
|
-
}
|
19
|
-
|
20
|
-
if (typeof ref === 'function') {
|
21
|
-
ref(current);
|
22
|
-
} else {
|
23
|
-
ref.current = current;
|
24
|
-
}
|
25
|
-
}
|
26
|
-
}
|
27
|
-
|
28
|
-
setRefs(combinedRef.current);
|
29
|
-
return () => {
|
30
|
-
// ensure the refs get updated on unmount
|
31
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
32
|
-
setRefs(combinedRef.current);
|
33
|
-
}; // eslint-disable-next-line react-hooks/exhaustive-deps
|
34
|
-
}, [...refs, combinedRef.current]);
|
35
|
-
return combinedRef;
|
36
|
-
}
|
@@ -1,17 +0,0 @@
|
|
1
|
-
/// <reference types="react" />
|
2
|
-
declare type UseDetailsParameters = {
|
3
|
-
ref?: React.RefObject<HTMLElement>;
|
4
|
-
closeOnOutsideClick?: boolean;
|
5
|
-
defaultOpen?: boolean;
|
6
|
-
onClickOutside?: (event: MouseEvent) => void;
|
7
|
-
};
|
8
|
-
declare function useDetails({ ref, closeOnOutsideClick, defaultOpen, onClickOutside }: UseDetailsParameters): {
|
9
|
-
open: boolean | undefined;
|
10
|
-
setOpen: import("react").Dispatch<import("react").SetStateAction<boolean | undefined>>;
|
11
|
-
getDetailsProps: () => {
|
12
|
-
onToggle: (e: React.SyntheticEvent<HTMLElement, Event>) => void;
|
13
|
-
open: boolean | undefined;
|
14
|
-
ref: import("react").RefObject<HTMLElement>;
|
15
|
-
};
|
16
|
-
};
|
17
|
-
export default useDetails;
|
@@ -1,16 +0,0 @@
|
|
1
|
-
/// <reference types="react" />
|
2
|
-
declare type UseDialogParameters = {
|
3
|
-
modalRef: React.RefObject<HTMLElement>;
|
4
|
-
overlayRef: React.RefObject<HTMLElement>;
|
5
|
-
isOpen?: boolean;
|
6
|
-
onDismiss?: () => void;
|
7
|
-
initialFocusRef?: React.RefObject<HTMLElement>;
|
8
|
-
closeButtonRef?: React.RefObject<HTMLElement>;
|
9
|
-
returnFocusRef?: React.RefObject<HTMLElement>;
|
10
|
-
};
|
11
|
-
declare function useDialog({ modalRef, overlayRef, isOpen, onDismiss, initialFocusRef, closeButtonRef }: UseDialogParameters): {
|
12
|
-
getDialogProps: () => {
|
13
|
-
onKeyDown: (event: any) => void;
|
14
|
-
};
|
15
|
-
};
|
16
|
-
export default useDialog;
|
@@ -1,32 +0,0 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
export interface FocusTrapHookSettings {
|
3
|
-
/**
|
4
|
-
* Ref that will be used for the trapping container. If not provided, one will
|
5
|
-
* be created by this hook and returned.
|
6
|
-
*/
|
7
|
-
containerRef?: React.RefObject<HTMLElement>;
|
8
|
-
/**
|
9
|
-
* Ref for the element that should receive focus when the focus trap is first enabled. If
|
10
|
-
* not provided, one will be created by this hook and returned. Its use is optional.
|
11
|
-
*/
|
12
|
-
initialFocusRef?: React.RefObject<HTMLElement>;
|
13
|
-
/**
|
14
|
-
* Set to true to disable the focus trap and clean up listeners. Can be re-enabled at
|
15
|
-
* any time.
|
16
|
-
*/
|
17
|
-
disabled?: boolean;
|
18
|
-
/**
|
19
|
-
* If true, when this focus trap is cleaned up, restore focus to the element that had
|
20
|
-
* focus immediately before the focus trap was enabled. (Default: false)
|
21
|
-
*/
|
22
|
-
restoreFocusOnCleanUp?: boolean;
|
23
|
-
}
|
24
|
-
/**
|
25
|
-
* Hook used to trap focus inside a container. Returns a ref that can be added to the container
|
26
|
-
* that should trap focus.
|
27
|
-
* @param settings {FocusTrapHookSettings}
|
28
|
-
*/
|
29
|
-
export declare function useFocusTrap(settings?: FocusTrapHookSettings, dependencies?: React.DependencyList): {
|
30
|
-
containerRef: React.RefObject<HTMLElement>;
|
31
|
-
initialFocusRef: React.RefObject<HTMLElement>;
|
32
|
-
};
|
@@ -1,23 +0,0 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
import { FocusZoneSettings } from '../behaviors/focusZone';
|
3
|
-
export interface FocusZoneHookSettings extends Omit<FocusZoneSettings, 'activeDescendantControl'> {
|
4
|
-
/**
|
5
|
-
* Optional ref for the container that holds all elements participating in arrow key focus.
|
6
|
-
* If one is not passed, we will create one for you and return it from the hook.
|
7
|
-
*/
|
8
|
-
containerRef?: React.RefObject<HTMLElement>;
|
9
|
-
/**
|
10
|
-
* If using the "active descendant" focus pattern, pass `true` or a ref to the controlling
|
11
|
-
* element. If a ref object is not passed, we will create one for you.
|
12
|
-
*/
|
13
|
-
activeDescendantFocus?: boolean | React.RefObject<HTMLElement>;
|
14
|
-
/**
|
15
|
-
* Set to true to disable the focus zone and clean up listeners. Can be re-enabled at
|
16
|
-
* any time.
|
17
|
-
*/
|
18
|
-
disabled?: boolean;
|
19
|
-
}
|
20
|
-
export declare function useFocusZone(settings?: FocusZoneHookSettings, dependencies?: React.DependencyList): {
|
21
|
-
containerRef: React.RefObject<HTMLElement>;
|
22
|
-
activeDescendantControlRef: React.RefObject<HTMLElement>;
|
23
|
-
};
|
@@ -1,23 +0,0 @@
|
|
1
|
-
/// <reference types="react" />
|
2
|
-
/**
|
3
|
-
* Sets up a `keydown` listener on `window.document`. If
|
4
|
-
* 1) The pressed key is "Escape", and
|
5
|
-
* 2) The event has not had `.preventDefault()` called
|
6
|
-
* The given callback will be executed.
|
7
|
-
*
|
8
|
-
* Note: If multiple `useOnEscapePress` hooks are active simultaneously, the
|
9
|
-
* callbacks will occur in reverse order. In other words, if a parent component
|
10
|
-
* and a child component both call `useOnEscapePress`, when the user presses
|
11
|
-
* Escape, the child component's callback will execute, followed by the parent's
|
12
|
-
* callback. Each callback has the chance to call `.preventDefault()` on the
|
13
|
-
* event to prevent further callbacks.
|
14
|
-
*
|
15
|
-
* @param callback {(e: KeyboardEvent) => void} The callback that gets executed
|
16
|
-
* when the Escape key is pressed. The KeyboardEvent generated by the Escape
|
17
|
-
* keypress is passed as the only argument.
|
18
|
-
*
|
19
|
-
* @param callbackDependencies {React.DependencyList} The dependencies of the given
|
20
|
-
* `onEscape` callback for memoization. Omit this param if the callback is already
|
21
|
-
* memoized. See `React.useCallback` for more info on memoization.
|
22
|
-
*/
|
23
|
-
export declare const useOnEscapePress: (onEscape: (e: KeyboardEvent) => void, callbackDependencies?: import("react").DependencyList) => void;
|
@@ -1,8 +0,0 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
export declare type TouchOrMouseEvent = MouseEvent | TouchEvent;
|
3
|
-
export declare type UseOnOutsideClickSettings = {
|
4
|
-
containerRef: React.RefObject<HTMLDivElement>;
|
5
|
-
ignoreClickRefs?: React.RefObject<HTMLElement>[];
|
6
|
-
onClickOutside: (e: TouchOrMouseEvent) => void;
|
7
|
-
};
|
8
|
-
export declare const useOnOutsideClick: ({ containerRef, ignoreClickRefs, onClickOutside }: UseOnOutsideClickSettings) => void;
|
@@ -1,8 +0,0 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
export declare type UseOpenAndCloseFocusSettings = {
|
3
|
-
initialFocusRef?: React.RefObject<HTMLElement>;
|
4
|
-
containerRef: React.RefObject<HTMLElement>;
|
5
|
-
returnFocusRef: React.RefObject<HTMLElement>;
|
6
|
-
preventFocusOnOpen?: boolean;
|
7
|
-
};
|
8
|
-
export declare function useOpenAndCloseFocus({ initialFocusRef, returnFocusRef, containerRef, preventFocusOnOpen }: UseOpenAndCloseFocusSettings): void;
|
@@ -1,15 +0,0 @@
|
|
1
|
-
/// <reference types="react" />
|
2
|
-
import { TouchOrMouseEvent } from './useOnOutsideClick';
|
3
|
-
export declare type UseOverlaySettings = {
|
4
|
-
ignoreClickRefs?: React.RefObject<HTMLElement>[];
|
5
|
-
initialFocusRef?: React.RefObject<HTMLElement>;
|
6
|
-
returnFocusRef: React.RefObject<HTMLElement>;
|
7
|
-
onEscape: (e: KeyboardEvent) => void;
|
8
|
-
onClickOutside: (e: TouchOrMouseEvent) => void;
|
9
|
-
overlayRef?: React.RefObject<HTMLDivElement>;
|
10
|
-
preventFocusOnOpen?: boolean;
|
11
|
-
};
|
12
|
-
export declare type OverlayReturnProps = {
|
13
|
-
ref: React.RefObject<HTMLDivElement>;
|
14
|
-
};
|
15
|
-
export declare const useOverlay: ({ overlayRef: _overlayRef, returnFocusRef, initialFocusRef, onEscape, ignoreClickRefs, onClickOutside, preventFocusOnOpen }: UseOverlaySettings) => OverlayReturnProps;
|
@@ -1,10 +0,0 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
/**
|
3
|
-
* There are some situations where we only want to create a new ref if one is not provided to a component
|
4
|
-
* or hook as a prop. However, due to the `rules-of-hooks`, we cannot conditionally make a call to `React.useRef`
|
5
|
-
* only in the situations where the ref is not provided as a prop.
|
6
|
-
* This hook aims to encapsulate that logic, so the consumer doesn't need to be concerned with violating `rules-of-hooks`.
|
7
|
-
* @param providedRef The ref to use - if undefined, will use the ref from a call to React.useRef
|
8
|
-
* @type TRef The type of the RefObject which should be created.
|
9
|
-
*/
|
10
|
-
export declare function useProvidedRefOrCreate<TRef>(providedRef?: React.RefObject<TRef>): React.RefObject<TRef>;
|
@@ -1,10 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* There are some situations where we want to give users the option to control state externally with their own state handlers
|
3
|
-
* or default to using internal state handlers. Because of the 'rules-of-hooks', we cannot conditionally make a call to `React.useState`
|
4
|
-
* only in the situations where the state is not provided as a prop.
|
5
|
-
* This hook aims to encapsulate that logic, so the consumer doesn't need to be concerned with violating `rules-of-hooks`.
|
6
|
-
* @param externalState The state to use - if undefined, will use the state from a call to React.useState
|
7
|
-
* @param setExternalState The setState to use - if undefined, will use the setState from a call to React.useState
|
8
|
-
* @param defaultState The defaultState to use, if using internal state.
|
9
|
-
*/
|
10
|
-
export declare function useProvidedStateOrCreate<T>(externalState: T | undefined, setExternalState: ((s: T) => void) | undefined, defaultState: T): readonly [T, (s: T) => void];
|
@@ -1,20 +0,0 @@
|
|
1
|
-
import { useCallback, useState } from 'react';
|
2
|
-
/**
|
3
|
-
* There are some situations where we want to give users the option to control state externally with their own state handlers
|
4
|
-
* or default to using internal state handlers. Because of the 'rules-of-hooks', we cannot conditionally make a call to `React.useState`
|
5
|
-
* only in the situations where the state is not provided as a prop.
|
6
|
-
* This hook aims to encapsulate that logic, so the consumer doesn't need to be concerned with violating `rules-of-hooks`.
|
7
|
-
* @param externalState The state to use - if undefined, will use the state from a call to React.useState
|
8
|
-
* @param setExternalState The setState to use - if undefined, will use the setState from a call to React.useState
|
9
|
-
* @param defaultState The defaultState to use, if using internal state.
|
10
|
-
*/
|
11
|
-
|
12
|
-
export function useProvidedStateOrCreate(externalState, setExternalState, defaultState) {
|
13
|
-
const [internalState, setInternalState] = useState(defaultState);
|
14
|
-
const state = externalState !== null && externalState !== void 0 ? externalState : internalState;
|
15
|
-
const setState = useCallback(s => {
|
16
|
-
setInternalState(s);
|
17
|
-
if (setExternalState) setExternalState(s);
|
18
|
-
}, [setExternalState]);
|
19
|
-
return [state, setState];
|
20
|
-
}
|
@@ -1,8 +0,0 @@
|
|
1
|
-
import { RefObject } from 'react';
|
2
|
-
/**
|
3
|
-
* There are certain situations where a ref might be set after the current render cycle for a
|
4
|
-
* component has finished. e.g. a forward ref from a conditionally rendered child component.
|
5
|
-
* In these situations, we need to force a re-render, which is done here by the useState hook.
|
6
|
-
* @type TRef The type of the RefObject which should be created.
|
7
|
-
*/
|
8
|
-
export declare function useRenderForcingRef<TRef>(): readonly [RefObject<TRef>, (newRef: TRef | null) => void];
|
@@ -1,18 +0,0 @@
|
|
1
|
-
import { useCallback, useRef, useState } from 'react';
|
2
|
-
/**
|
3
|
-
* There are certain situations where a ref might be set after the current render cycle for a
|
4
|
-
* component has finished. e.g. a forward ref from a conditionally rendered child component.
|
5
|
-
* In these situations, we need to force a re-render, which is done here by the useState hook.
|
6
|
-
* @type TRef The type of the RefObject which should be created.
|
7
|
-
*/
|
8
|
-
|
9
|
-
export function useRenderForcingRef() {
|
10
|
-
const [refCurrent, setRefCurrent] = useState(null);
|
11
|
-
const ref = useRef(null);
|
12
|
-
ref.current = refCurrent;
|
13
|
-
const setRef = useCallback(newRef => {
|
14
|
-
ref.current = newRef;
|
15
|
-
setRefCurrent(newRef);
|
16
|
-
}, [ref]);
|
17
|
-
return [ref, setRef];
|
18
|
-
}
|
@@ -1 +0,0 @@
|
|
1
|
-
export declare function useResizeObserver(callback: () => void): void;
|
@@ -1,10 +0,0 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
export function useResizeObserver(callback) {
|
3
|
-
React.useLayoutEffect(() => {
|
4
|
-
const observer = new window.ResizeObserver(() => callback());
|
5
|
-
observer.observe(document.documentElement);
|
6
|
-
return () => {
|
7
|
-
observer.disconnect();
|
8
|
-
};
|
9
|
-
}, [callback]);
|
10
|
-
}
|
@@ -1,12 +0,0 @@
|
|
1
|
-
declare type SetTimeout = (handler: TimerHandler, timeout?: number, ...args: unknown[]) => number;
|
2
|
-
declare type ClearTimeout = (id: number) => void;
|
3
|
-
/**
|
4
|
-
* Safely call `setTimeout` and `clearTimeout` within a component.
|
5
|
-
*
|
6
|
-
* This hook ensures that all timeouts are cleared when the component unmounts.
|
7
|
-
*/
|
8
|
-
export default function useSafeTimeout(): {
|
9
|
-
safeSetTimeout: SetTimeout;
|
10
|
-
safeClearTimeout: ClearTimeout;
|
11
|
-
};
|
12
|
-
export {};
|
@@ -1,6 +0,0 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
/**
|
3
|
-
* This hook will flash the scrollbars for a ref of a container that has scrollable overflow
|
4
|
-
* @param scrollContainerRef The ref of the scrollable content
|
5
|
-
*/
|
6
|
-
export default function useScrollFlash(scrollContainerRef: React.RefObject<HTMLElement>): void;
|
@@ -1,22 +0,0 @@
|
|
1
|
-
import { useEffect } from 'react';
|
2
|
-
/**
|
3
|
-
* This hook will flash the scrollbars for a ref of a container that has scrollable overflow
|
4
|
-
* @param scrollContainerRef The ref of the scrollable content
|
5
|
-
*/
|
6
|
-
|
7
|
-
export default function useScrollFlash(scrollContainerRef) {
|
8
|
-
// https://adxlv.computer/projects/flash-scrollers/
|
9
|
-
useEffect(() => {
|
10
|
-
const scrollContainer = scrollContainerRef.current;
|
11
|
-
|
12
|
-
if (!scrollContainer) {
|
13
|
-
return;
|
14
|
-
}
|
15
|
-
|
16
|
-
const currentScroll = scrollContainer.scrollTop;
|
17
|
-
const maxScroll = scrollContainer.scrollHeight;
|
18
|
-
const altScroll = currentScroll < Math.min(1, maxScroll) ? currentScroll + 1 : currentScroll - 1;
|
19
|
-
scrollContainer.scrollTop = altScroll;
|
20
|
-
scrollContainer.scrollTop = currentScroll;
|
21
|
-
}, [scrollContainerRef]);
|
22
|
-
}
|