@primer/components 0.0.0-20219835928 → 0.0.0-2022530195733
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 -1
- 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/MandateProps.d.ts +0 -3
- package/lib/utils/types/MandateProps.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 -5
- package/lib/utils/types/index.js +0 -70
- 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 -1
- 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/MandateProps.d.ts +0 -3
- package/lib-esm/utils/types/MandateProps.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 -5
- package/lib-esm/utils/types/index.js +0 -5
- package/lib-esm/utils/uniqueId.d.ts +0 -1
- package/lib-esm/utils/userAgent.d.ts +0 -1
@@ -0,0 +1,50 @@
|
|
1
|
+
/* adapted from: https://github.com/github/github/blob/a959c0d15c29b98c49b881f520c5947fe24eecb9/app/assets/modules/github/behaviors/button-outline.ts */
|
2
|
+
import { useEffect } from 'react';
|
3
|
+
|
4
|
+
const useMouseIntent = () => {
|
5
|
+
useEffect(() => {
|
6
|
+
let lastActiveElement = null;
|
7
|
+
let currentInputIsMouse = false;
|
8
|
+
|
9
|
+
function setClass() {
|
10
|
+
lastActiveElement = document.activeElement;
|
11
|
+
|
12
|
+
if (document.body) {
|
13
|
+
document.body.classList.toggle('intent-mouse', currentInputIsMouse);
|
14
|
+
}
|
15
|
+
}
|
16
|
+
|
17
|
+
function onKeyDown() {
|
18
|
+
currentInputIsMouse = false;
|
19
|
+
}
|
20
|
+
|
21
|
+
function onMouseDown() {
|
22
|
+
currentInputIsMouse = true;
|
23
|
+
if (lastActiveElement === document.activeElement) setClass();
|
24
|
+
} // Use mousedown event to make sure outline is remove for holding and dragging
|
25
|
+
|
26
|
+
|
27
|
+
document.addEventListener('mousedown', onMouseDown, {
|
28
|
+
capture: true
|
29
|
+
});
|
30
|
+
document.addEventListener('keydown', onKeyDown, {
|
31
|
+
capture: true
|
32
|
+
});
|
33
|
+
document.addEventListener('focusin', setClass, {
|
34
|
+
capture: true
|
35
|
+
});
|
36
|
+
return () => {
|
37
|
+
document.removeEventListener('keydown', onKeyDown, {
|
38
|
+
capture: true
|
39
|
+
});
|
40
|
+
document.removeEventListener('focusin', setClass, {
|
41
|
+
capture: true
|
42
|
+
});
|
43
|
+
document.removeEventListener('mousedown', onMouseDown, {
|
44
|
+
capture: true
|
45
|
+
});
|
46
|
+
};
|
47
|
+
}, []);
|
48
|
+
};
|
49
|
+
|
50
|
+
export default useMouseIntent;
|
@@ -1,59 +1,16 @@
|
|
1
1
|
import { useEffect, useCallback } from 'react';
|
2
|
-
const
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
function handleEscape(event) {
|
9
|
-
if (event.key === 'Escape' && !event.defaultPrevented) {
|
10
|
-
for (let i = handlers.length - 1; i >= 0; --i) {
|
11
|
-
handlers[i](event); // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
12
|
-
|
13
|
-
if (event.defaultPrevented) {
|
14
|
-
break;
|
15
|
-
}
|
2
|
+
export const useOnEscapePress = ({
|
3
|
+
onEscape
|
4
|
+
}) => {
|
5
|
+
const handleEscape = useCallback(e => {
|
6
|
+
if (e.key === 'Escape' && !e.defaultPrevented) {
|
7
|
+
onEscape(e);
|
16
8
|
}
|
17
|
-
}
|
18
|
-
}
|
19
|
-
/**
|
20
|
-
* Sets up a `keydown` listener on `window.document`. If
|
21
|
-
* 1) The pressed key is "Escape", and
|
22
|
-
* 2) The event has not had `.preventDefault()` called
|
23
|
-
* The given callback will be executed.
|
24
|
-
*
|
25
|
-
* Note: If multiple `useOnEscapePress` hooks are active simultaneously, the
|
26
|
-
* callbacks will occur in reverse order. In other words, if a parent component
|
27
|
-
* and a child component both call `useOnEscapePress`, when the user presses
|
28
|
-
* Escape, the child component's callback will execute, followed by the parent's
|
29
|
-
* callback. Each callback has the chance to call `.preventDefault()` on the
|
30
|
-
* event to prevent further callbacks.
|
31
|
-
*
|
32
|
-
* @param callback {(e: KeyboardEvent) => void} The callback that gets executed
|
33
|
-
* when the Escape key is pressed. The KeyboardEvent generated by the Escape
|
34
|
-
* keypress is passed as the only argument.
|
35
|
-
*
|
36
|
-
* @param callbackDependencies {React.DependencyList} The dependencies of the given
|
37
|
-
* `onEscape` callback for memoization. Omit this param if the callback is already
|
38
|
-
* memoized. See `React.useCallback` for more info on memoization.
|
39
|
-
*/
|
40
|
-
|
41
|
-
|
42
|
-
export const useOnEscapePress = (onEscape, callbackDependencies = [onEscape]) => {
|
43
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
44
|
-
const escapeCallback = useCallback(onEscape, callbackDependencies);
|
9
|
+
}, [onEscape]);
|
45
10
|
useEffect(() => {
|
46
|
-
|
47
|
-
document.addEventListener('keydown', handleEscape);
|
48
|
-
}
|
49
|
-
|
50
|
-
handlers.push(escapeCallback);
|
11
|
+
document.addEventListener('keydown', handleEscape);
|
51
12
|
return () => {
|
52
|
-
|
53
|
-
|
54
|
-
if (handlers.length === 0) {
|
55
|
-
document.removeEventListener('keydown', handleEscape);
|
56
|
-
}
|
13
|
+
document.removeEventListener('keydown', handleEscape);
|
57
14
|
};
|
58
|
-
}, [
|
15
|
+
}, [handleEscape]);
|
59
16
|
};
|
@@ -1,79 +1,54 @@
|
|
1
|
-
import { useEffect, useCallback
|
2
|
-
|
3
|
-
const
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
1
|
+
import { useEffect, useCallback } from 'react';
|
2
|
+
|
3
|
+
const shouldCallClickHandler = ({
|
4
|
+
ignoreClickRefs,
|
5
|
+
containerRef,
|
6
|
+
e
|
7
|
+
}) => {
|
8
|
+
var _containerRef$current;
|
9
|
+
|
10
|
+
let shouldCallHandler = true; // don't call click handler if the mouse event was triggered by an auxiliary button (right click/wheel button/etc)
|
11
|
+
|
12
|
+
if (e instanceof MouseEvent && e.button > 0) {
|
13
|
+
shouldCallHandler = false;
|
14
|
+
} // don't call handler if the click happened inside of the container
|
15
|
+
|
16
|
+
|
17
|
+
if ((_containerRef$current = containerRef.current) !== null && _containerRef$current !== void 0 && _containerRef$current.contains(e.target)) {
|
18
|
+
shouldCallHandler = false; // don't call handler if click happened on an ignored ref
|
19
|
+
} else if (ignoreClickRefs) {
|
20
|
+
for (const ignoreRef of ignoreClickRefs) {
|
21
|
+
var _ignoreRef$current;
|
22
|
+
|
23
|
+
if (ignoreRef && (_ignoreRef$current = ignoreRef.current) !== null && _ignoreRef$current !== void 0 && _ignoreRef$current.contains(e.target)) {
|
24
|
+
shouldCallHandler = false; // if we encounter one, break early, we don't need to go through the rest
|
8
25
|
|
9
|
-
function handleClick(event) {
|
10
|
-
if (!event.defaultPrevented) {
|
11
|
-
for (const handler of Object.values(registry).reverse()) {
|
12
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
13
|
-
if (handler(event) === stopPropagation || event.defaultPrevented) {
|
14
26
|
break;
|
15
27
|
}
|
16
28
|
}
|
17
29
|
}
|
18
|
-
}
|
19
|
-
|
20
|
-
const registry = {};
|
21
|
-
|
22
|
-
function register(id, handler) {
|
23
|
-
registry[id] = handler;
|
24
|
-
}
|
25
30
|
|
26
|
-
|
27
|
-
|
28
|
-
} // For auto-incrementing unique identifiers for registered handlers.
|
31
|
+
return shouldCallHandler;
|
32
|
+
};
|
29
33
|
|
30
|
-
|
31
|
-
let handlerId = 0;
|
32
34
|
export const useOnOutsideClick = ({
|
33
35
|
containerRef,
|
34
36
|
ignoreClickRefs,
|
35
37
|
onClickOutside
|
36
38
|
}) => {
|
37
|
-
const
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
} // don't call handler if the click happened inside of the container
|
45
|
-
|
46
|
-
|
47
|
-
if ((_containerRef$current = containerRef.current) !== null && _containerRef$current !== void 0 && _containerRef$current.contains(event.target)) {
|
48
|
-
return stopPropagation;
|
49
|
-
} // don't call handler if click happened on an ignored ref
|
50
|
-
|
51
|
-
|
52
|
-
if (ignoreClickRefs && ignoreClickRefs.some(({
|
53
|
-
current
|
54
|
-
}) => current === null || current === void 0 ? void 0 : current.contains(event.target))) {
|
55
|
-
return stopPropagation;
|
39
|
+
const onOutsideClickInternal = useCallback(e => {
|
40
|
+
if (shouldCallClickHandler({
|
41
|
+
ignoreClickRefs,
|
42
|
+
containerRef,
|
43
|
+
e
|
44
|
+
})) {
|
45
|
+
onClickOutside(e);
|
56
46
|
}
|
57
|
-
|
58
|
-
onClickOutside(event);
|
59
|
-
}, [containerRef, ignoreClickRefs, onClickOutside]);
|
47
|
+
}, [onClickOutside, containerRef, ignoreClickRefs]);
|
60
48
|
useEffect(() => {
|
61
|
-
|
62
|
-
// use capture to ensure we get all events
|
63
|
-
document.addEventListener('mousedown', handleClick, {
|
64
|
-
capture: true
|
65
|
-
});
|
66
|
-
}
|
67
|
-
|
68
|
-
register(id, handler);
|
49
|
+
document.addEventListener('click', onOutsideClickInternal);
|
69
50
|
return () => {
|
70
|
-
|
71
|
-
|
72
|
-
if (Object.keys(registry).length === 0) {
|
73
|
-
document.removeEventListener('mousedown', handleClick, {
|
74
|
-
capture: true
|
75
|
-
});
|
76
|
-
}
|
51
|
+
document.removeEventListener('click', onOutsideClickInternal);
|
77
52
|
};
|
78
|
-
}, [
|
53
|
+
}, [onOutsideClickInternal]);
|
79
54
|
};
|
@@ -3,19 +3,14 @@ import { iterateFocusableElements } from '../utils/iterateFocusableElements';
|
|
3
3
|
export function useOpenAndCloseFocus({
|
4
4
|
initialFocusRef,
|
5
5
|
returnFocusRef,
|
6
|
-
containerRef
|
7
|
-
preventFocusOnOpen
|
6
|
+
containerRef
|
8
7
|
}) {
|
9
8
|
useEffect(() => {
|
10
|
-
if (preventFocusOnOpen) {
|
11
|
-
return;
|
12
|
-
}
|
13
|
-
|
14
9
|
const returnRef = returnFocusRef.current;
|
15
10
|
|
16
11
|
if (initialFocusRef && initialFocusRef.current) {
|
17
12
|
initialFocusRef.current.focus();
|
18
|
-
} else if (containerRef.current) {
|
13
|
+
} else if (containerRef && containerRef.current) {
|
19
14
|
const firstItem = iterateFocusableElements(containerRef.current).next().value;
|
20
15
|
firstItem === null || firstItem === void 0 ? void 0 : firstItem.focus();
|
21
16
|
}
|
@@ -23,5 +18,5 @@ export function useOpenAndCloseFocus({
|
|
23
18
|
return function () {
|
24
19
|
returnRef === null || returnRef === void 0 ? void 0 : returnRef.focus();
|
25
20
|
};
|
26
|
-
}, [initialFocusRef, returnFocusRef, containerRef
|
21
|
+
}, [initialFocusRef, returnFocusRef, containerRef]);
|
27
22
|
}
|
@@ -1,30 +1,39 @@
|
|
1
1
|
import { useOnOutsideClick } from './useOnOutsideClick';
|
2
2
|
import { useOpenAndCloseFocus } from './useOpenAndCloseFocus';
|
3
3
|
import { useOnEscapePress } from './useOnEscapePress';
|
4
|
-
import {
|
4
|
+
import { useAnchoredPosition } from './useAnchoredPosition';
|
5
|
+
import { useRef } from 'react';
|
5
6
|
export const useOverlay = ({
|
6
|
-
|
7
|
+
anchorRef,
|
8
|
+
positionSettings = {},
|
9
|
+
positionDeps,
|
7
10
|
returnFocusRef,
|
8
11
|
initialFocusRef,
|
9
12
|
onEscape,
|
10
13
|
ignoreClickRefs,
|
11
|
-
onClickOutside
|
12
|
-
preventFocusOnOpen
|
14
|
+
onClickOutside
|
13
15
|
}) => {
|
14
|
-
const overlayRef =
|
16
|
+
const overlayRef = useRef(null);
|
17
|
+
positionSettings.anchorElementRef = anchorRef;
|
18
|
+
positionSettings.floatingElementRef = overlayRef;
|
15
19
|
useOpenAndCloseFocus({
|
16
20
|
containerRef: overlayRef,
|
17
21
|
returnFocusRef,
|
18
|
-
initialFocusRef
|
19
|
-
preventFocusOnOpen
|
22
|
+
initialFocusRef
|
20
23
|
});
|
21
24
|
useOnOutsideClick({
|
22
25
|
containerRef: overlayRef,
|
23
26
|
ignoreClickRefs,
|
24
27
|
onClickOutside
|
25
28
|
});
|
26
|
-
useOnEscapePress(
|
29
|
+
useOnEscapePress({
|
30
|
+
onEscape
|
31
|
+
});
|
32
|
+
const {
|
33
|
+
position
|
34
|
+
} = useAnchoredPosition(positionSettings, positionDeps);
|
27
35
|
return {
|
28
|
-
ref: overlayRef
|
36
|
+
ref: overlayRef,
|
37
|
+
position
|
29
38
|
};
|
30
39
|
};
|
package/lib-esm/index.js
CHANGED
@@ -1,30 +1,27 @@
|
|
1
1
|
export { default as theme } from './theme';
|
2
2
|
export { get as themeGet } from './constants';
|
3
3
|
export { default as BaseStyles } from './BaseStyles';
|
4
|
-
export { default as ThemeProvider, useTheme, useColorSchemeVar } from './ThemeProvider';
|
5
|
-
|
4
|
+
export { default as ThemeProvider, useTheme, useColorSchemeVar } from './ThemeProvider'; // Layout
|
5
|
+
|
6
6
|
export { default as BorderBox } from './BorderBox';
|
7
7
|
export { default as Box } from './Box';
|
8
8
|
export { default as Flex } from './Flex';
|
9
9
|
export { default as Grid } from './Grid';
|
10
|
-
export { default as Position, Absolute, Fixed, Relative, Sticky } from './Position';
|
11
|
-
|
10
|
+
export { default as Position, Absolute, Fixed, Relative, Sticky } from './Position'; // Hooks
|
11
|
+
|
12
12
|
export { default as useDetails } from './hooks/useDetails';
|
13
|
+
export { default as useMouseIntent } from './hooks/useMouseIntent';
|
13
14
|
export { default as useSafeTimeout } from './hooks/useSafeTimeout';
|
14
15
|
export { useOnOutsideClick } from './hooks/useOnOutsideClick';
|
15
16
|
export { useOpenAndCloseFocus } from './hooks/useOpenAndCloseFocus';
|
16
17
|
export { useOnEscapePress } from './hooks/useOnEscapePress';
|
17
|
-
export { useOverlay } from './hooks/useOverlay';
|
18
|
-
export { useConfirm } from './Dialog/ConfirmationDialog'; // Components
|
18
|
+
export { useOverlay } from './hooks/useOverlay'; // Components
|
19
19
|
|
20
|
-
export { ActionList } from './ActionList';
|
21
|
-
export { ActionMenu } from './ActionMenu';
|
22
|
-
export { default as Autocomplete } from './Autocomplete';
|
23
20
|
export { default as Avatar } from './Avatar';
|
24
21
|
export { default as AvatarPair } from './AvatarPair';
|
25
22
|
export { default as AvatarStack } from './AvatarStack';
|
26
23
|
export { default as BranchName } from './BranchName';
|
27
|
-
export { default as
|
24
|
+
export { default as Breadcrumb } from './Breadcrumb';
|
28
25
|
export { default as Button, ButtonDanger, ButtonOutline, ButtonPrimary, ButtonInvisible, ButtonTableList, ButtonClose, ButtonGroup } from './Button';
|
29
26
|
export { default as Caret } from './Caret';
|
30
27
|
export { default as CircleBadge } from './CircleBadge';
|
@@ -32,11 +29,7 @@ export { default as CircleOcticon } from './CircleOcticon';
|
|
32
29
|
export { default as CounterLabel } from './CounterLabel';
|
33
30
|
export { default as Details } from './Details';
|
34
31
|
export { default as Dialog } from './Dialog';
|
35
|
-
export { ConfirmationDialog } from './Dialog/ConfirmationDialog';
|
36
32
|
export { default as Dropdown } from './Dropdown';
|
37
|
-
export { DropdownButton, DropdownMenu } from './DropdownMenu'; // not exporting new DropdownMenu types yet due to conflict with Dropdown types above
|
38
|
-
// export type {DropdownButtonProps, DropdownMenuProps} from './DropdownMenu'
|
39
|
-
|
40
33
|
export { default as FilteredSearch } from './FilteredSearch';
|
41
34
|
export { default as FilterList } from './FilterList';
|
42
35
|
export { default as Flash } from './Flash';
|
@@ -50,23 +43,18 @@ export { default as Overlay } from './Overlay';
|
|
50
43
|
export { default as Pagehead } from './Pagehead';
|
51
44
|
export { default as Pagination } from './Pagination';
|
52
45
|
export { default as PointerBox } from './PointerBox';
|
53
|
-
export { default as Popover } from './Popover';
|
54
|
-
|
55
|
-
// export type {PortalProps} from './Portal'
|
46
|
+
export { default as Popover } from './Popover'; // export {default as Portal, PortalProps, registerPortalRoot} from './Portal'
|
47
|
+
|
56
48
|
export { default as ProgressBar } from './ProgressBar';
|
57
49
|
export { default as SelectMenu } from './SelectMenu';
|
58
50
|
export { default as SideNav } from './SideNav';
|
59
|
-
export { default as Spinner } from './Spinner';
|
60
51
|
export { default as StateLabel } from './StateLabel';
|
61
52
|
export { default as StyledOcticon } from './StyledOcticon';
|
62
53
|
export { default as SubNav } from './SubNav';
|
63
54
|
export { default as TabNav } from './TabNav';
|
64
55
|
export { default as TextInput } from './TextInput';
|
65
|
-
export { default as TextInputWithTokens } from './TextInputWithTokens';
|
66
56
|
export { default as Text } from './Text';
|
67
57
|
export { default as Timeline } from './Timeline';
|
68
|
-
export { default as Token, IssueLabelToken, ProfileToken } from './Token';
|
69
58
|
export { default as Tooltip } from './Tooltip';
|
70
59
|
export { default as Truncate } from './Truncate';
|
71
|
-
export { default as UnderlineNav } from './UnderlineNav';
|
72
|
-
export { SSRProvider, useSSRSafeId } from './utils/ssr';
|
60
|
+
export { default as UnderlineNav } from './UnderlineNav';
|
@@ -15,10 +15,9 @@ function noop() {}
|
|
15
15
|
try {
|
16
16
|
const options = Object.create({}, {
|
17
17
|
signal: {
|
18
|
-
get() {
|
18
|
+
get: function () {
|
19
19
|
signalSupported = true;
|
20
20
|
}
|
21
|
-
|
22
21
|
}
|
23
22
|
});
|
24
23
|
window.addEventListener('test', noop, options);
|
@@ -32,10 +31,6 @@ function featureSupported() {
|
|
32
31
|
}
|
33
32
|
|
34
33
|
function monkeyPatch() {
|
35
|
-
if (typeof window === 'undefined') {
|
36
|
-
return;
|
37
|
-
}
|
38
|
-
|
39
34
|
const originalAddEventListener = EventTarget.prototype.addEventListener;
|
40
35
|
|
41
36
|
EventTarget.prototype.addEventListener = function (name, originalCallback, optionsOrCapture) {
|
@@ -0,0 +1,79 @@
|
|
1
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
2
|
+
|
3
|
+
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
4
|
+
import React from 'react';
|
5
|
+
import { BaseStyles, Button, ButtonClose, ButtonDanger, ButtonGroup, ButtonInvisible, ButtonOutline, ButtonPrimary, ButtonTableList, ThemeProvider } from '..';
|
6
|
+
export default {
|
7
|
+
title: 'Composite components/Button',
|
8
|
+
decorators: [Story => {
|
9
|
+
return /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(BaseStyles, null, /*#__PURE__*/React.createElement(Story, null)));
|
10
|
+
}],
|
11
|
+
argTypes: {
|
12
|
+
as: {
|
13
|
+
table: {
|
14
|
+
disable: true
|
15
|
+
}
|
16
|
+
},
|
17
|
+
theme: {
|
18
|
+
table: {
|
19
|
+
disable: true
|
20
|
+
}
|
21
|
+
},
|
22
|
+
sx: {
|
23
|
+
table: {
|
24
|
+
disable: true
|
25
|
+
}
|
26
|
+
},
|
27
|
+
variant: {
|
28
|
+
control: {
|
29
|
+
type: 'radio',
|
30
|
+
options: ['small', 'medium', 'large']
|
31
|
+
}
|
32
|
+
}
|
33
|
+
}
|
34
|
+
};
|
35
|
+
export const defaultButton = args => /*#__PURE__*/React.createElement(Button, args, "Default Button");
|
36
|
+
defaultButton.displayName = "defaultButton";
|
37
|
+
export const dangerButton = args => /*#__PURE__*/React.createElement(ButtonDanger, args, "Danger Button");
|
38
|
+
dangerButton.displayName = "dangerButton";
|
39
|
+
export const outlineButton = args => /*#__PURE__*/React.createElement(ButtonOutline, args, "Outline Button");
|
40
|
+
outlineButton.displayName = "outlineButton";
|
41
|
+
export const primaryButton = args => /*#__PURE__*/React.createElement(ButtonPrimary, args, "Primary Button");
|
42
|
+
primaryButton.displayName = "primaryButton";
|
43
|
+
export const invisibleButton = args => /*#__PURE__*/React.createElement(ButtonInvisible, args, "Invisible Button");
|
44
|
+
invisibleButton.displayName = "invisibleButton";
|
45
|
+
export const closeButton = args => /*#__PURE__*/React.createElement(ButtonClose, _extends({}, args, {
|
46
|
+
onClick: () => alert('button clicked.')
|
47
|
+
}));
|
48
|
+
closeButton.displayName = "closeButton";
|
49
|
+
export const buttonGroup = args => /*#__PURE__*/React.createElement(ButtonGroup, {
|
50
|
+
display: "block",
|
51
|
+
my: 2
|
52
|
+
}, /*#__PURE__*/React.createElement(Button, args, "Button 1"), /*#__PURE__*/React.createElement(Button, args, "Button 2"), /*#__PURE__*/React.createElement(Button, args, "Button 3"));
|
53
|
+
buttonGroup.displayName = "buttonGroup";
|
54
|
+
export const buttonTableList = args => /*#__PURE__*/React.createElement(ButtonTableList, args, "Button Table List");
|
55
|
+
buttonTableList.displayName = "buttonTableList";
|
56
|
+
defaultButton.args = {
|
57
|
+
variant: 'medium'
|
58
|
+
};
|
59
|
+
dangerButton.args = {
|
60
|
+
variant: 'medium'
|
61
|
+
};
|
62
|
+
outlineButton.args = {
|
63
|
+
variant: 'medium'
|
64
|
+
};
|
65
|
+
primaryButton.args = {
|
66
|
+
variant: 'medium'
|
67
|
+
};
|
68
|
+
invisibleButton.args = {
|
69
|
+
variant: 'medium'
|
70
|
+
};
|
71
|
+
closeButton.args = {
|
72
|
+
variant: 'medium'
|
73
|
+
};
|
74
|
+
buttonGroup.args = {
|
75
|
+
variant: 'medium'
|
76
|
+
};
|
77
|
+
buttonTableList.args = {
|
78
|
+
variant: 'medium'
|
79
|
+
};
|
@@ -0,0 +1,80 @@
|
|
1
|
+
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
2
|
+
import React, { useState, useRef } from 'react';
|
3
|
+
import styled, { ThemeProvider } from 'styled-components';
|
4
|
+
import { BaseStyles, Overlay, Button, Text, ButtonDanger, theme, Position, Flex } from '..';
|
5
|
+
export default {
|
6
|
+
title: 'Internal components/Overlay',
|
7
|
+
component: Overlay,
|
8
|
+
decorators: [Story => {
|
9
|
+
return /*#__PURE__*/React.createElement(ThemeProvider, {
|
10
|
+
theme: theme
|
11
|
+
}, /*#__PURE__*/React.createElement(BaseStyles, null, /*#__PURE__*/React.createElement(Story, null)));
|
12
|
+
}]
|
13
|
+
};
|
14
|
+
const DummyItem = styled.button.withConfig({
|
15
|
+
displayName: "Overlaystories__DummyItem",
|
16
|
+
componentId: "sc-92ppmu-0"
|
17
|
+
})(["border-radius:6px;font-weight:400;padding:6px 8px;font-weight:400;text-align:left;margin:0;font-size:14px;background:none;border:none;&:hover{background:#f0f3f5;}&:focus{background:red;}"]);
|
18
|
+
export const DropdownOverlay = () => {
|
19
|
+
const [isOpen, setIsOpen] = useState(false);
|
20
|
+
const buttonRef = useRef(null);
|
21
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Button, {
|
22
|
+
ref: buttonRef,
|
23
|
+
sx: {
|
24
|
+
position: 'relative'
|
25
|
+
},
|
26
|
+
onClick: () => setIsOpen(!isOpen)
|
27
|
+
}, "open overlay"), isOpen && /*#__PURE__*/React.createElement(Overlay, {
|
28
|
+
anchorRef: buttonRef,
|
29
|
+
returnFocusRef: buttonRef,
|
30
|
+
height: "auto",
|
31
|
+
width: "sm",
|
32
|
+
ignoreClickRefs: [buttonRef],
|
33
|
+
onEscape: () => setIsOpen(false),
|
34
|
+
onClickOutside: () => setIsOpen(false)
|
35
|
+
}, /*#__PURE__*/React.createElement(Flex, {
|
36
|
+
flexDirection: "column",
|
37
|
+
p: 2
|
38
|
+
}, /*#__PURE__*/React.createElement(DummyItem, null, "Copy link"), /*#__PURE__*/React.createElement(DummyItem, null, "Quote reply"), /*#__PURE__*/React.createElement(DummyItem, null, "Reference in new issue"), /*#__PURE__*/React.createElement(DummyItem, null, "Edit"), /*#__PURE__*/React.createElement(DummyItem, null, "Delete"))));
|
39
|
+
};
|
40
|
+
export const DialogOverlay = () => {
|
41
|
+
const [isOpen, setIsOpen] = useState(false);
|
42
|
+
const buttonRef = useRef(null);
|
43
|
+
const confirmButtonRef = useRef(null);
|
44
|
+
const anchorRef = useRef(null);
|
45
|
+
|
46
|
+
const closeOverlay = () => setIsOpen(false);
|
47
|
+
|
48
|
+
return /*#__PURE__*/React.createElement(Position, {
|
49
|
+
position: "absolute",
|
50
|
+
top: 0,
|
51
|
+
left: 0,
|
52
|
+
bottom: 0,
|
53
|
+
right: 0,
|
54
|
+
ref: anchorRef
|
55
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
56
|
+
ref: buttonRef,
|
57
|
+
onClick: () => setIsOpen(!isOpen)
|
58
|
+
}, "open overlay"), isOpen && /*#__PURE__*/React.createElement(Overlay, {
|
59
|
+
positionSettings: {
|
60
|
+
side: 'inside-center',
|
61
|
+
align: 'center'
|
62
|
+
},
|
63
|
+
anchorRef: anchorRef,
|
64
|
+
initialFocusRef: confirmButtonRef,
|
65
|
+
returnFocusRef: buttonRef,
|
66
|
+
ignoreClickRefs: [buttonRef],
|
67
|
+
onEscape: closeOverlay,
|
68
|
+
onClickOutside: closeOverlay,
|
69
|
+
width: "sm"
|
70
|
+
}, /*#__PURE__*/React.createElement(Flex, {
|
71
|
+
flexDirection: "column",
|
72
|
+
p: 2
|
73
|
+
}, /*#__PURE__*/React.createElement(Text, null, "Are you sure?"), /*#__PURE__*/React.createElement(ButtonDanger, {
|
74
|
+
onClick: closeOverlay
|
75
|
+
}, "Cancel"), /*#__PURE__*/React.createElement(Button, {
|
76
|
+
onClick: closeOverlay,
|
77
|
+
ref: confirmButtonRef
|
78
|
+
}, "Confirm"))));
|
79
|
+
};
|
80
|
+
DialogOverlay.displayName = "DialogOverlay";
|
@@ -0,0 +1,72 @@
|
|
1
|
+
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
2
|
+
import React from 'react';
|
3
|
+
import { BaseStyles, Box, ThemeProvider } from '..';
|
4
|
+
import Portal, { registerPortalRoot } from '../Portal';
|
5
|
+
export default {
|
6
|
+
title: 'Generic behaviors/Portal',
|
7
|
+
component: Portal,
|
8
|
+
decorators: [Story => {
|
9
|
+
// Since portal roots are registered globally, we need this line so that each storybook
|
10
|
+
// story works in isolation.
|
11
|
+
registerPortalRoot(undefined);
|
12
|
+
return /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(BaseStyles, null, /*#__PURE__*/React.createElement(Story, null)));
|
13
|
+
}]
|
14
|
+
};
|
15
|
+
export const defaultPortal = () => /*#__PURE__*/React.createElement(React.Fragment, null, "Root position", /*#__PURE__*/React.createElement(Box, {
|
16
|
+
bg: "red.2",
|
17
|
+
p: 3
|
18
|
+
}, "Outer container", /*#__PURE__*/React.createElement(Box, {
|
19
|
+
bg: "green.2",
|
20
|
+
p: 3
|
21
|
+
}, "Inner container", /*#__PURE__*/React.createElement(Portal, null, "Portaled content rendered at ", /*#__PURE__*/React.createElement("code", null, "<BaseStyles>"), " root."))));
|
22
|
+
export const customPortalRootById = () => /*#__PURE__*/React.createElement(React.Fragment, null, "Root position", /*#__PURE__*/React.createElement(Box, {
|
23
|
+
bg: "red.2",
|
24
|
+
p: 3,
|
25
|
+
id: "__primerPortalRoot__"
|
26
|
+
}, "Outer container", /*#__PURE__*/React.createElement(Box, {
|
27
|
+
bg: "green.2",
|
28
|
+
p: 3
|
29
|
+
}, "Inner container", /*#__PURE__*/React.createElement(Portal, null, "Portaled content rendered at the outer container."))));
|
30
|
+
export const CustomPortalRootByRegistration = () => {
|
31
|
+
const outerContainerRef = React.useRef(null);
|
32
|
+
const [mounted, setMounted] = React.useState(false);
|
33
|
+
React.useEffect(() => {
|
34
|
+
if (outerContainerRef.current instanceof HTMLElement) {
|
35
|
+
registerPortalRoot(outerContainerRef.current);
|
36
|
+
setMounted(true);
|
37
|
+
}
|
38
|
+
}, []);
|
39
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, "Root position", /*#__PURE__*/React.createElement(Box, {
|
40
|
+
bg: "red.2",
|
41
|
+
p: 3,
|
42
|
+
ref: outerContainerRef
|
43
|
+
}, mounted && /*#__PURE__*/React.createElement(React.Fragment, null, "Outer container", /*#__PURE__*/React.createElement(Box, {
|
44
|
+
bg: "green.2",
|
45
|
+
p: 3
|
46
|
+
}, "Inner container", /*#__PURE__*/React.createElement(Portal, null, "Portaled content rendered at the outer container.")))));
|
47
|
+
};
|
48
|
+
export const MultiplePortalRoots = () => {
|
49
|
+
const outerContainerRef = React.useRef(null);
|
50
|
+
const innerContainerRef = React.useRef(null);
|
51
|
+
const [mounted, setMounted] = React.useState(false);
|
52
|
+
React.useEffect(() => {
|
53
|
+
if (outerContainerRef.current instanceof HTMLElement && innerContainerRef.current instanceof HTMLElement) {
|
54
|
+
registerPortalRoot(outerContainerRef.current, 'outer');
|
55
|
+
registerPortalRoot(innerContainerRef.current, 'inner');
|
56
|
+
setMounted(true);
|
57
|
+
}
|
58
|
+
}, [outerContainerRef]);
|
59
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, "Root position", /*#__PURE__*/React.createElement(Box, {
|
60
|
+
bg: "red.2",
|
61
|
+
p: 3,
|
62
|
+
ref: outerContainerRef
|
63
|
+
}, "Outer container", /*#__PURE__*/React.createElement(Box, {
|
64
|
+
bg: "green.2",
|
65
|
+
p: 3,
|
66
|
+
ref: innerContainerRef
|
67
|
+
}, mounted && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Portal, {
|
68
|
+
containerName: "outer"
|
69
|
+
}, "Portaled content rendered at the outer container."), /*#__PURE__*/React.createElement(Portal, {
|
70
|
+
containerName: "inner"
|
71
|
+
}, "Portaled content rendered at the end of the inner container."), /*#__PURE__*/React.createElement(Portal, null, "Portaled content rendered at ", /*#__PURE__*/React.createElement("code", null, "<BaseStyles>"), " root.")), "Inner container")));
|
72
|
+
};
|