@primer/components 31.2.1-rc.f73a0f8c → 32.0.1-rc.44e3df9b
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/.github/workflows/ci.yml +2 -5
- package/.github/workflows/release.yml +0 -1
- package/.github/workflows/release_canary.yml +0 -1
- package/CHANGELOG.md +74 -4
- package/dist/browser.esm.js +299 -361
- package/dist/browser.esm.js.map +1 -1
- package/dist/browser.umd.js +294 -356
- package/dist/browser.umd.js.map +1 -1
- package/docs/content/ActionList2.mdx +8 -7
- package/docs/content/Breadcrumbs.md +11 -16
- package/docs/content/Buttons.md +7 -17
- package/docs/content/CircleBadge.md +0 -10
- package/docs/content/CounterLabel.md +0 -10
- package/docs/content/Dialog.md +15 -18
- package/docs/content/Dialog2.mdx +1 -0
- package/docs/content/Dropdown.md +11 -18
- package/docs/content/FilterList.md +10 -17
- package/docs/content/FilteredSearch.md +4 -11
- package/docs/content/Flash.md +5 -14
- package/docs/content/FormGroup.md +9 -17
- package/docs/content/Header.md +14 -16
- package/docs/content/Label.md +32 -25
- package/docs/content/LabelGroup.md +4 -14
- package/docs/content/Link.md +8 -17
- package/docs/content/Overlay.mdx +1 -10
- package/docs/content/Pagehead.md +4 -13
- package/docs/content/Pagination.md +10 -19
- package/docs/content/Popover.md +11 -19
- package/docs/content/SelectMenu.md +50 -114
- package/docs/content/SideNav.md +15 -23
- package/docs/content/StateLabel.md +5 -14
- package/docs/content/StyledOcticon.md +7 -16
- package/docs/content/SubNav.md +19 -21
- package/docs/content/TabNav.md +10 -18
- package/docs/content/Timeline.md +34 -24
- package/docs/content/Tooltip.md +8 -17
- package/docs/content/Truncate.md +7 -16
- package/docs/content/UnderlineNav.md +13 -21
- package/docs/package-lock.json +269 -158
- package/docs/package.json +1 -1
- package/lib/ActionList/index.js +23 -12
- package/lib/ActionList2/Group.d.ts +28 -2
- package/lib/ActionList2/Group.js +55 -6
- package/lib/ActionList2/List.d.ts +1 -1
- package/lib/ActionList2/index.js +41 -23
- package/lib/AnchoredOverlay/index.js +12 -4
- package/lib/Autocomplete/Autocomplete.d.ts +3 -3
- package/lib/Autocomplete/AutocompleteInput.d.ts +3 -3
- package/lib/Autocomplete/index.js +14 -7
- package/lib/Breadcrumbs.d.ts +8 -7
- package/lib/Breadcrumbs.js +7 -12
- package/lib/Button/Button.d.ts +2 -3
- package/lib/Button/Button.js +2 -6
- package/lib/Button/ButtonBase.d.ts +5 -8
- package/lib/Button/ButtonBase.js +1 -5
- package/lib/Button/ButtonClose.d.ts +3 -46
- package/lib/Button/ButtonClose.js +1 -1
- package/lib/Button/ButtonDanger.d.ts +2 -3
- package/lib/Button/ButtonDanger.js +2 -6
- package/lib/Button/ButtonInvisible.d.ts +2 -3
- package/lib/Button/ButtonInvisible.js +2 -6
- package/lib/Button/ButtonOutline.d.ts +2 -3
- package/lib/Button/ButtonOutline.js +2 -6
- package/lib/Button/ButtonPrimary.d.ts +2 -3
- package/lib/Button/ButtonPrimary.js +2 -6
- package/lib/Button/ButtonTableList.d.ts +1 -2
- package/lib/Button/ButtonTableList.js +1 -1
- package/lib/Button/index.js +70 -21
- package/lib/CircleBadge.d.ts +4 -5
- package/lib/CircleBadge.js +1 -1
- package/lib/CircleOcticon.d.ts +1 -1
- package/lib/CounterLabel.d.ts +1 -2
- package/lib/CounterLabel.js +1 -1
- package/lib/Dialog/Dialog.d.ts +5 -9
- package/lib/Dialog/Dialog.js +17 -11
- package/lib/Dialog.d.ts +4 -5
- package/lib/Dialog.js +1 -1
- package/lib/Dropdown.d.ts +10 -99
- package/lib/Dropdown.js +3 -3
- package/lib/DropdownMenu/DropdownButton.d.ts +3 -47
- package/lib/DropdownMenu/DropdownButton.js +3 -1
- package/lib/DropdownMenu/index.js +20 -6
- package/lib/DropdownStyles.js +26 -18
- package/lib/FilterList.d.ts +264 -303
- package/lib/FilterList.js +2 -6
- package/lib/FilteredActionList/index.js +12 -4
- package/lib/FilteredSearch.d.ts +1 -2
- package/lib/FilteredSearch.js +1 -1
- package/lib/Flash.d.ts +1 -2
- package/lib/Flash.js +1 -1
- package/lib/FormGroup.d.ts +4 -5
- package/lib/FormGroup.js +2 -2
- package/lib/Header.d.ts +6 -7
- package/lib/Header.js +4 -4
- package/lib/Label.d.ts +1 -2
- package/lib/Label.js +2 -3
- package/lib/LabelGroup.d.ts +1 -2
- package/lib/LabelGroup.js +1 -1
- package/lib/Link.d.ts +1 -2
- package/lib/Link.js +1 -1
- package/lib/NewButton/button.js +34 -42
- package/lib/NewButton/index.js +12 -5
- package/lib/NewButton/types.js +1 -2
- package/lib/Overlay.d.ts +11 -10
- package/lib/Overlay.js +3 -4
- package/lib/Pagehead.d.ts +1 -2
- package/lib/Pagehead.js +1 -1
- package/lib/Pagination/Pagination.js +1 -1
- package/lib/Pagination/index.js +12 -6
- package/lib/Popover.d.ts +4 -5
- package/lib/Popover.js +4 -5
- package/lib/Portal/index.js +16 -5
- package/lib/Position.d.ts +4 -4
- package/lib/SelectMenu/SelectMenu.d.ts +21 -189
- package/lib/SelectMenu/SelectMenu.js +1 -3
- package/lib/SelectMenu/SelectMenuDivider.d.ts +1 -2
- package/lib/SelectMenu/SelectMenuDivider.js +1 -1
- package/lib/SelectMenu/SelectMenuFilter.js +1 -1
- package/lib/SelectMenu/SelectMenuFooter.d.ts +1 -2
- package/lib/SelectMenu/SelectMenuFooter.js +1 -1
- package/lib/SelectMenu/SelectMenuHeader.d.ts +1 -2
- package/lib/SelectMenu/SelectMenuHeader.js +1 -1
- package/lib/SelectMenu/SelectMenuItem.d.ts +2 -3
- package/lib/SelectMenu/SelectMenuItem.js +1 -1
- package/lib/SelectMenu/SelectMenuList.d.ts +1 -2
- package/lib/SelectMenu/SelectMenuList.js +1 -1
- package/lib/SelectMenu/SelectMenuLoadingAnimation.d.ts +2 -2
- package/lib/SelectMenu/SelectMenuLoadingAnimation.js +3 -1
- package/lib/SelectMenu/SelectMenuModal.d.ts +2 -3
- package/lib/SelectMenu/SelectMenuModal.js +1 -1
- package/lib/SelectMenu/SelectMenuTab.d.ts +1 -2
- package/lib/SelectMenu/SelectMenuTab.js +1 -1
- package/lib/SelectMenu/SelectMenuTabPanel.d.ts +1 -2
- package/lib/SelectMenu/SelectMenuTabPanel.js +1 -1
- package/lib/SelectMenu/SelectMenuTabs.d.ts +1 -2
- package/lib/SelectMenu/SelectMenuTabs.js +1 -1
- package/lib/SelectMenu/hooks/useKeyboardNav.js +96 -80
- package/lib/SelectMenu/index.js +14 -7
- package/lib/SelectPanel/index.js +12 -4
- package/lib/SideNav.d.ts +11 -8
- package/lib/SideNav.js +8 -15
- package/lib/StateLabel.d.ts +1 -2
- package/lib/StateLabel.js +6 -5
- package/lib/StyledOcticon.d.ts +1 -2
- package/lib/StyledOcticon.js +1 -3
- package/lib/SubNav.d.ts +5 -11
- package/lib/SubNav.js +7 -12
- package/lib/TabNav.d.ts +3 -4
- package/lib/TabNav.js +2 -2
- package/lib/TextInputWithTokens.d.ts +3 -3
- package/lib/Timeline.d.ts +19 -393
- package/lib/Timeline.js +16 -13
- package/lib/Token/Token.d.ts +1 -1
- package/lib/Token/index.js +30 -11
- package/lib/Tooltip.d.ts +1 -2
- package/lib/Tooltip.js +1 -1
- package/lib/Truncate.d.ts +1 -2
- package/lib/Truncate.js +1 -3
- package/lib/UnderlineNav.d.ts +2 -3
- package/lib/UnderlineNav.js +2 -2
- package/lib/__tests__/Breadcrumbs.test.js +4 -1
- package/lib/__tests__/Breadcrumbs.types.test.d.ts +3 -0
- package/lib/__tests__/Breadcrumbs.types.test.js +25 -0
- package/lib/__tests__/Button.test.js +6 -2
- package/lib/__tests__/CircleBadge.types.test.d.ts +3 -0
- package/lib/__tests__/CircleBadge.types.test.js +28 -0
- package/lib/__tests__/CounterLabel.types.test.d.ts +3 -0
- package/lib/__tests__/CounterLabel.types.test.js +28 -0
- package/lib/__tests__/Dialog.types.test.d.ts +3 -0
- package/lib/__tests__/Dialog.types.test.js +28 -0
- package/lib/__tests__/Dialog2.types.test.d.ts +3 -0
- package/lib/__tests__/Dialog2.types.test.js +31 -0
- package/lib/__tests__/Dropdown.types.test.d.ts +3 -0
- package/lib/__tests__/Dropdown.types.test.js +31 -0
- package/lib/__tests__/FilterList.types.test.d.ts +3 -0
- package/lib/__tests__/FilterList.types.test.js +27 -0
- package/lib/__tests__/FilteredSearch.types.test.d.ts +3 -0
- package/lib/__tests__/FilteredSearch.types.test.js +28 -0
- package/lib/__tests__/Flash.types.test.d.ts +3 -0
- package/lib/__tests__/Flash.types.test.js +28 -0
- package/lib/__tests__/FormGroup.types.test.d.ts +3 -0
- package/lib/__tests__/FormGroup.types.test.js +28 -0
- package/lib/__tests__/Header.types.test.d.ts +3 -0
- package/lib/__tests__/Header.types.test.js +29 -0
- package/lib/__tests__/KeyPaths.types.test.js +8 -5
- package/lib/__tests__/Label.types.test.d.ts +3 -0
- package/lib/__tests__/Label.types.test.js +28 -0
- package/lib/__tests__/LabelGroup.types.test.d.ts +3 -0
- package/lib/__tests__/LabelGroup.types.test.js +28 -0
- package/lib/__tests__/Link.test.js +11 -5
- package/lib/__tests__/Link.types.test.d.ts +3 -0
- package/lib/__tests__/Link.types.test.js +28 -0
- package/lib/__tests__/Merge.types.test.js +19 -13
- package/lib/__tests__/Overlay.types.test.d.ts +3 -0
- package/lib/__tests__/Overlay.types.test.js +35 -0
- package/lib/__tests__/Pagehead.types.test.d.ts +3 -0
- package/lib/__tests__/Pagehead.types.test.js +28 -0
- package/lib/__tests__/Pagination.types.test.d.ts +3 -0
- package/lib/__tests__/Pagination.types.test.js +33 -0
- package/lib/__tests__/Popover.types.test.d.ts +3 -0
- package/lib/__tests__/Popover.types.test.js +27 -0
- package/lib/__tests__/SelectMenu.types.test.d.ts +3 -0
- package/lib/__tests__/SelectMenu.types.test.js +47 -0
- package/lib/__tests__/SideNav.types.test.d.ts +3 -0
- package/lib/__tests__/SideNav.types.test.js +28 -0
- package/lib/__tests__/StateLabel.types.test.d.ts +3 -0
- package/lib/__tests__/StateLabel.types.test.js +28 -0
- package/lib/__tests__/StyledOcticon.types.test.d.ts +3 -0
- package/lib/__tests__/StyledOcticon.types.test.js +32 -0
- package/lib/__tests__/SubNav.types.test.d.ts +3 -0
- package/lib/__tests__/SubNav.types.test.js +27 -0
- package/lib/__tests__/TabNav.types.test.d.ts +3 -0
- package/lib/__tests__/TabNav.types.test.js +25 -0
- package/lib/__tests__/Timeline.types.test.d.ts +3 -0
- package/lib/__tests__/Timeline.types.test.js +31 -0
- package/lib/__tests__/Tooltip.types.test.d.ts +3 -0
- package/lib/__tests__/Tooltip.types.test.js +28 -0
- package/lib/__tests__/Truncate.types.test.d.ts +3 -0
- package/lib/__tests__/Truncate.types.test.js +31 -0
- package/lib/__tests__/UnderlineNav.types.test.d.ts +3 -0
- package/lib/__tests__/UnderlineNav.types.test.js +25 -0
- package/lib/__tests__/behaviors/anchoredPosition.test.js +376 -229
- package/lib/__tests__/behaviors/scrollIntoViewingArea.test.js +216 -145
- package/lib/__tests__/filterObject.test.js +27 -48
- package/lib/__tests__/theme.test.js +34 -33
- package/lib/__tests__/themeGet.test.js +23 -12
- package/lib/behaviors/anchoredPosition.js +234 -205
- package/lib/behaviors/focusTrap.js +157 -121
- package/lib/behaviors/focusZone.js +509 -434
- package/lib/behaviors/scrollIntoViewingArea.js +35 -18
- package/lib/constants.js +43 -39
- package/lib/drafts.js +30 -20
- package/lib/hooks/index.js +60 -16
- package/lib/hooks/useAnchoredPosition.js +40 -32
- package/lib/hooks/useCombinedRefs.js +36 -32
- package/lib/hooks/useDialog.js +96 -72
- package/lib/hooks/useFocusTrap.js +60 -43
- package/lib/hooks/useFocusZone.js +50 -54
- package/lib/hooks/useOnEscapePress.js +36 -25
- package/lib/hooks/useOpenAndCloseFocus.js +34 -22
- package/lib/hooks/useProvidedRefOrCreate.js +14 -10
- package/lib/hooks/useProvidedStateOrCreate.js +16 -13
- package/lib/hooks/useRenderForcingRef.js +17 -13
- package/lib/hooks/useResizeObserver.js +18 -15
- package/lib/hooks/useSafeTimeout.js +30 -22
- package/lib/hooks/useScrollFlash.js +23 -16
- package/lib/index.js +644 -163
- package/lib/polyfills/eventListenerSignal.js +45 -37
- package/lib/stories/ActionList2.stories.js +4 -3
- package/lib/stories/ActionMenu.stories.js +1 -3
- package/lib/stories/ConfirmationDialog.stories.js +16 -8
- package/lib/stories/Dialog.stories.js +6 -2
- package/lib/stories/useFocusTrap.stories.js +6 -2
- package/lib/stories/useFocusZone.stories.js +13 -5
- package/lib/sx.js +22 -10
- package/lib/theme-preval.js +3169 -64
- package/lib/theme.js +12 -3
- package/lib/utils/iterateFocusableElements.js +85 -63
- package/lib/utils/testing.d.ts +1 -1
- package/lib/utils/theme.js +47 -33
- package/lib/utils/types/AriaRole.js +1 -2
- package/lib/utils/types/ComponentProps.js +1 -2
- package/lib/utils/types/Flatten.js +1 -2
- package/lib/utils/types/KeyPaths.js +1 -2
- package/lib/utils/types/MandateProps.js +1 -16
- package/lib/utils/types/Merge.js +1 -2
- package/lib/utils/types/index.js +69 -16
- package/lib/utils/uniqueId.js +8 -5
- package/lib/utils/use-force-update.js +14 -8
- package/lib/utils/useIsomorphicLayoutEffect.js +11 -8
- package/lib/utils/userAgent.js +12 -8
- package/lib-esm/ActionList2/Group.d.ts +28 -2
- package/lib-esm/ActionList2/Group.js +52 -5
- package/lib-esm/ActionList2/List.d.ts +1 -1
- package/lib-esm/Autocomplete/Autocomplete.d.ts +3 -3
- package/lib-esm/Autocomplete/AutocompleteInput.d.ts +3 -3
- package/lib-esm/Breadcrumbs.d.ts +8 -7
- package/lib-esm/Breadcrumbs.js +8 -13
- package/lib-esm/Button/Button.d.ts +2 -3
- package/lib-esm/Button/Button.js +2 -2
- package/lib-esm/Button/ButtonBase.d.ts +5 -8
- package/lib-esm/Button/ButtonBase.js +1 -3
- package/lib-esm/Button/ButtonClose.d.ts +3 -46
- package/lib-esm/Button/ButtonClose.js +2 -2
- package/lib-esm/Button/ButtonDanger.d.ts +2 -3
- package/lib-esm/Button/ButtonDanger.js +2 -2
- package/lib-esm/Button/ButtonInvisible.d.ts +2 -3
- package/lib-esm/Button/ButtonInvisible.js +2 -2
- package/lib-esm/Button/ButtonOutline.d.ts +2 -3
- package/lib-esm/Button/ButtonOutline.js +2 -2
- package/lib-esm/Button/ButtonPrimary.d.ts +2 -3
- package/lib-esm/Button/ButtonPrimary.js +2 -2
- package/lib-esm/Button/ButtonTableList.d.ts +1 -2
- package/lib-esm/Button/ButtonTableList.js +2 -2
- package/lib-esm/CircleBadge.d.ts +4 -5
- package/lib-esm/CircleBadge.js +2 -2
- package/lib-esm/CircleOcticon.d.ts +1 -1
- package/lib-esm/CounterLabel.d.ts +1 -2
- package/lib-esm/CounterLabel.js +2 -2
- package/lib-esm/Dialog/Dialog.d.ts +5 -9
- package/lib-esm/Dialog/Dialog.js +12 -12
- package/lib-esm/Dialog.d.ts +4 -5
- package/lib-esm/Dialog.js +2 -2
- package/lib-esm/Dropdown.d.ts +10 -99
- package/lib-esm/Dropdown.js +4 -4
- package/lib-esm/DropdownMenu/DropdownButton.d.ts +3 -47
- package/lib-esm/DropdownMenu/DropdownButton.js +3 -1
- package/lib-esm/FilterList.d.ts +264 -303
- package/lib-esm/FilterList.js +3 -7
- package/lib-esm/FilteredSearch.d.ts +1 -2
- package/lib-esm/FilteredSearch.js +2 -2
- package/lib-esm/Flash.d.ts +1 -2
- package/lib-esm/Flash.js +2 -2
- package/lib-esm/FormGroup.d.ts +4 -5
- package/lib-esm/FormGroup.js +3 -3
- package/lib-esm/Header.d.ts +6 -7
- package/lib-esm/Header.js +5 -5
- package/lib-esm/Label.d.ts +1 -2
- package/lib-esm/Label.js +3 -4
- package/lib-esm/LabelGroup.d.ts +1 -2
- package/lib-esm/LabelGroup.js +2 -2
- package/lib-esm/Link.d.ts +1 -2
- package/lib-esm/Link.js +2 -2
- package/lib-esm/NewButton/button.js +31 -42
- package/lib-esm/Overlay.d.ts +11 -10
- package/lib-esm/Overlay.js +2 -3
- package/lib-esm/Pagehead.d.ts +1 -2
- package/lib-esm/Pagehead.js +2 -2
- package/lib-esm/Pagination/Pagination.js +2 -2
- package/lib-esm/Popover.d.ts +4 -5
- package/lib-esm/Popover.js +4 -5
- package/lib-esm/Position.d.ts +4 -4
- package/lib-esm/SelectMenu/SelectMenu.d.ts +21 -189
- package/lib-esm/SelectMenu/SelectMenu.js +1 -2
- package/lib-esm/SelectMenu/SelectMenuDivider.d.ts +1 -2
- package/lib-esm/SelectMenu/SelectMenuDivider.js +2 -2
- package/lib-esm/SelectMenu/SelectMenuFilter.js +2 -2
- package/lib-esm/SelectMenu/SelectMenuFooter.d.ts +1 -2
- package/lib-esm/SelectMenu/SelectMenuFooter.js +2 -2
- package/lib-esm/SelectMenu/SelectMenuHeader.d.ts +1 -2
- package/lib-esm/SelectMenu/SelectMenuHeader.js +2 -2
- package/lib-esm/SelectMenu/SelectMenuItem.d.ts +2 -3
- package/lib-esm/SelectMenu/SelectMenuItem.js +2 -2
- package/lib-esm/SelectMenu/SelectMenuList.d.ts +1 -2
- package/lib-esm/SelectMenu/SelectMenuList.js +2 -2
- package/lib-esm/SelectMenu/SelectMenuLoadingAnimation.d.ts +2 -2
- package/lib-esm/SelectMenu/SelectMenuLoadingAnimation.js +3 -2
- package/lib-esm/SelectMenu/SelectMenuModal.d.ts +2 -3
- package/lib-esm/SelectMenu/SelectMenuModal.js +2 -2
- package/lib-esm/SelectMenu/SelectMenuTab.d.ts +1 -2
- package/lib-esm/SelectMenu/SelectMenuTab.js +2 -2
- package/lib-esm/SelectMenu/SelectMenuTabPanel.d.ts +1 -2
- package/lib-esm/SelectMenu/SelectMenuTabPanel.js +2 -2
- package/lib-esm/SelectMenu/SelectMenuTabs.d.ts +1 -2
- package/lib-esm/SelectMenu/SelectMenuTabs.js +2 -2
- package/lib-esm/SideNav.d.ts +11 -8
- package/lib-esm/SideNav.js +8 -16
- package/lib-esm/StateLabel.d.ts +1 -2
- package/lib-esm/StateLabel.js +7 -6
- package/lib-esm/StyledOcticon.d.ts +1 -2
- package/lib-esm/StyledOcticon.js +1 -2
- package/lib-esm/SubNav.d.ts +5 -11
- package/lib-esm/SubNav.js +8 -13
- package/lib-esm/TabNav.d.ts +3 -4
- package/lib-esm/TabNav.js +3 -3
- package/lib-esm/TextInputWithTokens.d.ts +3 -3
- package/lib-esm/Timeline.d.ts +19 -393
- package/lib-esm/Timeline.js +12 -13
- package/lib-esm/Token/Token.d.ts +1 -1
- package/lib-esm/Tooltip.d.ts +1 -2
- package/lib-esm/Tooltip.js +2 -2
- package/lib-esm/Truncate.d.ts +1 -2
- package/lib-esm/Truncate.js +1 -2
- package/lib-esm/UnderlineNav.d.ts +2 -3
- package/lib-esm/UnderlineNav.js +3 -3
- package/lib-esm/__tests__/Breadcrumbs.test.js +4 -1
- package/lib-esm/__tests__/Breadcrumbs.types.test.d.ts +3 -0
- package/lib-esm/__tests__/Breadcrumbs.types.test.js +12 -0
- package/lib-esm/__tests__/Button.test.js +6 -2
- package/lib-esm/__tests__/CircleBadge.types.test.d.ts +3 -0
- package/lib-esm/__tests__/CircleBadge.types.test.js +13 -0
- package/lib-esm/__tests__/CounterLabel.types.test.d.ts +3 -0
- package/lib-esm/__tests__/CounterLabel.types.test.js +13 -0
- package/lib-esm/__tests__/Dialog.types.test.d.ts +3 -0
- package/lib-esm/__tests__/Dialog.types.test.js +13 -0
- package/lib-esm/__tests__/Dialog2.types.test.d.ts +3 -0
- package/lib-esm/__tests__/Dialog2.types.test.js +16 -0
- package/lib-esm/__tests__/Dropdown.types.test.d.ts +3 -0
- package/lib-esm/__tests__/Dropdown.types.test.js +17 -0
- package/lib-esm/__tests__/FilterList.types.test.d.ts +3 -0
- package/lib-esm/__tests__/FilterList.types.test.js +13 -0
- package/lib-esm/__tests__/FilteredSearch.types.test.d.ts +3 -0
- package/lib-esm/__tests__/FilteredSearch.types.test.js +13 -0
- package/lib-esm/__tests__/Flash.types.test.d.ts +3 -0
- package/lib-esm/__tests__/Flash.types.test.js +13 -0
- package/lib-esm/__tests__/FormGroup.types.test.d.ts +3 -0
- package/lib-esm/__tests__/FormGroup.types.test.js +13 -0
- package/lib-esm/__tests__/Header.types.test.d.ts +3 -0
- package/lib-esm/__tests__/Header.types.test.js +15 -0
- package/lib-esm/__tests__/Label.types.test.d.ts +3 -0
- package/lib-esm/__tests__/Label.types.test.js +13 -0
- package/lib-esm/__tests__/LabelGroup.types.test.d.ts +3 -0
- package/lib-esm/__tests__/LabelGroup.types.test.js +13 -0
- package/lib-esm/__tests__/Link.test.js +11 -5
- package/lib-esm/__tests__/Link.types.test.d.ts +3 -0
- package/lib-esm/__tests__/Link.types.test.js +13 -0
- package/lib-esm/__tests__/Overlay.types.test.d.ts +3 -0
- package/lib-esm/__tests__/Overlay.types.test.js +20 -0
- package/lib-esm/__tests__/Pagehead.types.test.d.ts +3 -0
- package/lib-esm/__tests__/Pagehead.types.test.js +13 -0
- package/lib-esm/__tests__/Pagination.types.test.d.ts +3 -0
- package/lib-esm/__tests__/Pagination.types.test.js +18 -0
- package/lib-esm/__tests__/Popover.types.test.d.ts +3 -0
- package/lib-esm/__tests__/Popover.types.test.js +13 -0
- package/lib-esm/__tests__/SelectMenu.types.test.d.ts +3 -0
- package/lib-esm/__tests__/SelectMenu.types.test.js +33 -0
- package/lib-esm/__tests__/SideNav.types.test.d.ts +3 -0
- package/lib-esm/__tests__/SideNav.types.test.js +13 -0
- package/lib-esm/__tests__/StateLabel.types.test.d.ts +3 -0
- package/lib-esm/__tests__/StateLabel.types.test.js +13 -0
- package/lib-esm/__tests__/StyledOcticon.types.test.d.ts +3 -0
- package/lib-esm/__tests__/StyledOcticon.types.test.js +16 -0
- package/lib-esm/__tests__/SubNav.types.test.d.ts +3 -0
- package/lib-esm/__tests__/SubNav.types.test.js +14 -0
- package/lib-esm/__tests__/TabNav.types.test.d.ts +3 -0
- package/lib-esm/__tests__/TabNav.types.test.js +12 -0
- package/lib-esm/__tests__/Timeline.types.test.d.ts +3 -0
- package/lib-esm/__tests__/Timeline.types.test.js +18 -0
- package/lib-esm/__tests__/Tooltip.types.test.d.ts +3 -0
- package/lib-esm/__tests__/Tooltip.types.test.js +13 -0
- package/lib-esm/__tests__/Truncate.types.test.d.ts +3 -0
- package/lib-esm/__tests__/Truncate.types.test.js +16 -0
- package/lib-esm/__tests__/UnderlineNav.types.test.d.ts +3 -0
- package/lib-esm/__tests__/UnderlineNav.types.test.js +12 -0
- package/lib-esm/stories/ActionList2.stories.js +4 -3
- package/lib-esm/stories/ActionMenu.stories.js +1 -3
- package/lib-esm/stories/ConfirmationDialog.stories.js +16 -8
- package/lib-esm/stories/Dialog.stories.js +6 -2
- package/lib-esm/stories/useFocusTrap.stories.js +6 -2
- package/lib-esm/stories/useFocusZone.stories.js +13 -5
- package/lib-esm/theme-preval.js +446 -0
- package/lib-esm/utils/testing.d.ts +1 -1
- package/package-lock.json +16 -16
- package/package.json +4 -5
- package/script/build +1 -1
- package/src/ActionList2/Group.tsx +76 -7
- package/src/ActionList2/List.tsx +1 -1
- package/src/Breadcrumbs.tsx +11 -11
- package/src/Button/Button.tsx +2 -3
- package/src/Button/ButtonBase.tsx +2 -6
- package/src/Button/ButtonClose.tsx +2 -6
- package/src/Button/ButtonDanger.tsx +2 -3
- package/src/Button/ButtonInvisible.tsx +2 -3
- package/src/Button/ButtonOutline.tsx +2 -3
- package/src/Button/ButtonPrimary.tsx +2 -3
- package/src/Button/ButtonTableList.tsx +2 -15
- package/src/CircleBadge.tsx +2 -4
- package/src/CounterLabel.tsx +2 -4
- package/src/Dialog/Dialog.tsx +22 -11
- package/src/Dialog.tsx +2 -6
- package/src/Dropdown.tsx +3 -7
- package/src/DropdownMenu/DropdownButton.tsx +1 -1
- package/src/FilterList.tsx +5 -11
- package/src/FilteredSearch.tsx +2 -3
- package/src/Flash.tsx +2 -4
- package/src/FormGroup.tsx +3 -6
- package/src/Header.tsx +4 -14
- package/src/Label.tsx +2 -5
- package/src/LabelGroup.tsx +2 -3
- package/src/Link.tsx +2 -6
- package/src/NewButton/button.tsx +82 -78
- package/src/Overlay.tsx +13 -11
- package/src/Pagehead.tsx +2 -3
- package/src/Pagination/Pagination.tsx +3 -5
- package/src/Popover.tsx +3 -14
- package/src/SelectMenu/SelectMenu.tsx +1 -3
- package/src/SelectMenu/SelectMenuDivider.tsx +2 -3
- package/src/SelectMenu/SelectMenuFilter.tsx +2 -3
- package/src/SelectMenu/SelectMenuFooter.tsx +2 -3
- package/src/SelectMenu/SelectMenuHeader.tsx +2 -4
- package/src/SelectMenu/SelectMenuItem.tsx +2 -3
- package/src/SelectMenu/SelectMenuList.tsx +2 -3
- package/src/SelectMenu/SelectMenuLoadingAnimation.tsx +4 -3
- package/src/SelectMenu/SelectMenuModal.tsx +2 -4
- package/src/SelectMenu/SelectMenuTab.tsx +2 -3
- package/src/SelectMenu/SelectMenuTabPanel.tsx +2 -3
- package/src/SelectMenu/SelectMenuTabs.tsx +2 -3
- package/src/SideNav.tsx +11 -13
- package/src/StateLabel.tsx +3 -5
- package/src/StyledOcticon.tsx +1 -3
- package/src/SubNav.tsx +8 -13
- package/src/TabNav.tsx +3 -7
- package/src/Timeline.tsx +11 -12
- package/src/Tooltip.tsx +3 -3
- package/src/Truncate.tsx +0 -5
- package/src/UnderlineNav.tsx +3 -6
- package/src/__tests__/Breadcrumbs.test.tsx +1 -1
- package/src/__tests__/Breadcrumbs.types.test.tsx +22 -0
- package/src/__tests__/Button.test.tsx +2 -2
- package/src/__tests__/CircleBadge.types.test.tsx +11 -0
- package/src/__tests__/CounterLabel.types.test.tsx +11 -0
- package/src/__tests__/Dialog.types.test.tsx +11 -0
- package/src/__tests__/Dialog2.types.test.tsx +11 -0
- package/src/__tests__/Dropdown.types.test.tsx +21 -0
- package/src/__tests__/FilterList.types.test.tsx +17 -0
- package/src/__tests__/FilteredSearch.types.test.tsx +11 -0
- package/src/__tests__/Flash.types.test.tsx +11 -0
- package/src/__tests__/FormGroup.types.test.tsx +11 -0
- package/src/__tests__/Header.types.test.tsx +19 -0
- package/src/__tests__/Label.types.test.tsx +11 -0
- package/src/__tests__/LabelGroup.types.test.tsx +11 -0
- package/src/__tests__/Link.test.tsx +5 -5
- package/src/__tests__/Link.types.test.tsx +11 -0
- package/src/__tests__/Overlay.types.test.tsx +18 -0
- package/src/__tests__/Pagehead.types.test.tsx +11 -0
- package/src/__tests__/Pagination.types.test.tsx +11 -0
- package/src/__tests__/Popover.types.test.tsx +17 -0
- package/src/__tests__/SelectMenu.types.test.tsx +37 -0
- package/src/__tests__/SideNav.types.test.tsx +11 -0
- package/src/__tests__/StateLabel.types.test.tsx +11 -0
- package/src/__tests__/StyledOcticon.types.test.tsx +12 -0
- package/src/__tests__/SubNav.types.test.tsx +25 -0
- package/src/__tests__/TabNav.types.test.tsx +22 -0
- package/src/__tests__/Timeline.types.test.tsx +31 -0
- package/src/__tests__/Tooltip.types.test.tsx +11 -0
- package/src/__tests__/Truncate.types.test.tsx +11 -0
- package/src/__tests__/UnderlineNav.types.test.tsx +22 -0
- package/src/__tests__/__snapshots__/Label.test.tsx.snap +3 -4
- package/src/__tests__/__snapshots__/Link.test.tsx.snap +1 -2
- package/src/__tests__/__snapshots__/NewButton.test.tsx.snap +5 -0
- package/src/stories/ActionList2.stories.tsx +3 -3
- package/src/stories/ActionMenu.stories.tsx +1 -4
- package/src/stories/ConfirmationDialog.stories.tsx +4 -4
- package/src/stories/Dialog.stories.tsx +2 -2
- package/src/stories/useFocusTrap.stories.tsx +2 -2
- package/src/stories/useFocusZone.stories.tsx +4 -4
- package/stats.html +1 -1
- package/tsconfig.build.json +2 -2
- package/tsconfig.json +17 -4
- package/lib/ActionList/Divider.jsx +0 -29
- package/lib/ActionList/Group.jsx +0 -23
- package/lib/ActionList/Header.jsx +0 -66
- package/lib/ActionList/Item.jsx +0 -288
- package/lib/ActionList/List.jsx +0 -138
- package/lib/ActionList2/Description.jsx +0 -29
- package/lib/ActionList2/Divider.jsx +0 -22
- package/lib/ActionList2/Group.jsx +0 -25
- package/lib/ActionList2/Header.jsx +0 -36
- package/lib/ActionList2/Item.jsx +0 -174
- package/lib/ActionList2/LinkItem.jsx +0 -28
- package/lib/ActionList2/List.jsx +0 -41
- package/lib/ActionList2/Selection.jsx +0 -50
- package/lib/ActionList2/Visuals.jsx +0 -48
- package/lib/ActionMenu.jsx +0 -73
- package/lib/AnchoredOverlay/AnchoredOverlay.jsx +0 -100
- package/lib/Autocomplete/Autocomplete.jsx +0 -100
- package/lib/Autocomplete/AutocompleteContext.jsx +0 -5
- package/lib/Autocomplete/AutocompleteInput.jsx +0 -113
- package/lib/Autocomplete/AutocompleteMenu.jsx +0 -190
- package/lib/Autocomplete/AutocompleteOverlay.jsx +0 -55
- package/lib/Avatar.jsx +0 -34
- package/lib/AvatarPair.jsx +0 -29
- package/lib/AvatarStack.jsx +0 -151
- package/lib/BaseStyles.jsx +0 -65
- package/lib/BorderBox.jsx +0 -18
- package/lib/Box.jsx +0 -10
- package/lib/BranchName.jsx +0 -20
- package/lib/Breadcrumbs.jsx +0 -74
- package/lib/Button/Button.jsx +0 -60
- package/lib/Button/ButtonBase.jsx +0 -36
- package/lib/Button/ButtonClose.jsx +0 -55
- package/lib/Button/ButtonDanger.jsx +0 -63
- package/lib/Button/ButtonGroup.jsx +0 -55
- package/lib/Button/ButtonInvisible.jsx +0 -52
- package/lib/Button/ButtonOutline.jsx +0 -63
- package/lib/Button/ButtonPrimary.jsx +0 -62
- package/lib/Button/ButtonStyles.jsx +0 -37
- package/lib/Button/ButtonTableList.jsx +0 -49
- package/lib/Caret.jsx +0 -93
- package/lib/CircleBadge.jsx +0 -43
- package/lib/CircleOcticon.jsx +0 -21
- package/lib/CounterLabel.jsx +0 -44
- package/lib/Details.jsx +0 -21
- package/lib/Dialog/ConfirmationDialog.jsx +0 -146
- package/lib/Dialog/Dialog.jsx +0 -273
- package/lib/Dialog.jsx +0 -131
- package/lib/Dropdown.jsx +0 -134
- package/lib/DropdownMenu/DropdownButton.jsx +0 -14
- package/lib/DropdownMenu/DropdownMenu.jsx +0 -70
- package/lib/FilterList.jsx +0 -63
- package/lib/FilteredActionList/FilteredActionList.jsx +0 -100
- package/lib/FilteredSearch.jsx +0 -29
- package/lib/Flash.jsx +0 -70
- package/lib/Flex.jsx +0 -15
- package/lib/FormGroup.jsx +0 -25
- package/lib/Grid.jsx +0 -15
- package/lib/Header.jsx +0 -90
- package/lib/Heading.jsx +0 -21
- package/lib/Label.jsx +0 -84
- package/lib/LabelGroup.jsx +0 -19
- package/lib/Link.jsx +0 -38
- package/lib/NewButton/button-counter.jsx +0 -14
- package/lib/NewButton/button.jsx +0 -278
- package/lib/Overlay.jsx +0 -156
- package/lib/Pagehead.jsx +0 -18
- package/lib/Pagination/Pagination.jsx +0 -163
- package/lib/Pagination/model.jsx +0 -174
- package/lib/PointerBox.jsx +0 -25
- package/lib/Popover.jsx +0 -210
- package/lib/Portal/Portal.jsx +0 -79
- package/lib/Position.jsx +0 -46
- package/lib/ProgressBar.jsx +0 -39
- package/lib/SelectMenu/SelectMenu.jsx +0 -114
- package/lib/SelectMenu/SelectMenuContext.jsx +0 -5
- package/lib/SelectMenu/SelectMenuDivider.jsx +0 -43
- package/lib/SelectMenu/SelectMenuFilter.jsx +0 -59
- package/lib/SelectMenu/SelectMenuFooter.jsx +0 -46
- package/lib/SelectMenu/SelectMenuHeader.jsx +0 -44
- package/lib/SelectMenu/SelectMenuItem.jsx +0 -143
- package/lib/SelectMenu/SelectMenuList.jsx +0 -60
- package/lib/SelectMenu/SelectMenuLoadingAnimation.jsx +0 -21
- package/lib/SelectMenu/SelectMenuModal.jsx +0 -119
- package/lib/SelectMenu/SelectMenuTab.jsx +0 -93
- package/lib/SelectMenu/SelectMenuTabPanel.jsx +0 -43
- package/lib/SelectMenu/SelectMenuTabs.jsx +0 -58
- package/lib/SelectPanel/SelectPanel.jsx +0 -105
- package/lib/SideNav.jsx +0 -177
- package/lib/Spinner.jsx +0 -35
- package/lib/StateLabel.jsx +0 -94
- package/lib/StyledOcticon.jsx +0 -20
- package/lib/SubNav.jsx +0 -104
- package/lib/TabNav.jsx +0 -60
- package/lib/Text.jsx +0 -14
- package/lib/TextInput.jsx +0 -23
- package/lib/TextInputWithTokens.jsx +0 -218
- package/lib/ThemeProvider.jsx +0 -130
- package/lib/Timeline.jsx +0 -124
- package/lib/Token/AvatarToken.jsx +0 -54
- package/lib/Token/IssueLabelToken.jsx +0 -125
- package/lib/Token/Token.jsx +0 -103
- package/lib/Token/TokenBase.jsx +0 -88
- package/lib/Token/_RemoveTokenButton.jsx +0 -108
- package/lib/Token/_TokenTextContainer.jsx +0 -49
- package/lib/Tooltip.jsx +0 -246
- package/lib/Truncate.jsx +0 -27
- package/lib/UnderlineNav.jsx +0 -90
- package/lib/_TextInputWrapper.jsx +0 -120
- package/lib/_UnstyledTextInput.jsx +0 -22
- package/lib/__tests__/ActionList.test.jsx +0 -49
- package/lib/__tests__/ActionList.types.test.jsx +0 -45
- package/lib/__tests__/ActionList2.test.jsx +0 -46
- package/lib/__tests__/ActionMenu.test.jsx +0 -124
- package/lib/__tests__/AnchoredOverlay.test.jsx +0 -121
- package/lib/__tests__/Autocomplete.test.jsx +0 -299
- package/lib/__tests__/Avatar.test.jsx +0 -42
- package/lib/__tests__/AvatarStack.test.jsx +0 -43
- package/lib/__tests__/BorderBox.test.jsx +0 -36
- package/lib/__tests__/Box.test.jsx +0 -41
- package/lib/__tests__/BranchName.test.jsx +0 -27
- package/lib/__tests__/Breadcrumbs.test.jsx +0 -28
- package/lib/__tests__/BreadcrumbsItem.test.jsx +0 -31
- package/lib/__tests__/Button.test.jsx +0 -100
- package/lib/__tests__/Caret.test.jsx +0 -37
- package/lib/__tests__/CircleBadge.test.jsx +0 -55
- package/lib/__tests__/CircleOcticon.test.jsx +0 -45
- package/lib/__tests__/ConfirmationDialog.test.jsx +0 -119
- package/lib/__tests__/CounterLabel.test.jsx +0 -36
- package/lib/__tests__/Details.test.jsx +0 -85
- package/lib/__tests__/Dialog.test.jsx +0 -139
- package/lib/__tests__/Dropdown.test.jsx +0 -49
- package/lib/__tests__/DropdownMenu.test.jsx +0 -119
- package/lib/__tests__/FilterList.test.jsx +0 -27
- package/lib/__tests__/FilterListItem.test.jsx +0 -31
- package/lib/__tests__/FilteredSearch.test.jsx +0 -27
- package/lib/__tests__/Flash.test.jsx +0 -36
- package/lib/__tests__/Flex.test.jsx +0 -51
- package/lib/__tests__/FormGroup.test.jsx +0 -36
- package/lib/__tests__/Grid.test.jsx +0 -69
- package/lib/__tests__/Header.test.jsx +0 -45
- package/lib/__tests__/Heading.test.jsx +0 -71
- package/lib/__tests__/Label.test.jsx +0 -33
- package/lib/__tests__/LabelGroup.test.jsx +0 -29
- package/lib/__tests__/Link.test.jsx +0 -43
- package/lib/__tests__/NewButton.test.jsx +0 -61
- package/lib/__tests__/Overlay.test.jsx +0 -105
- package/lib/__tests__/Pagehead.test.jsx +0 -25
- package/lib/__tests__/Pagination/Pagination.test.jsx +0 -32
- package/lib/__tests__/Pagination/PaginationModel.test.jsx +0 -118
- package/lib/__tests__/PointerBox.test.jsx +0 -33
- package/lib/__tests__/Popover.test.jsx +0 -58
- package/lib/__tests__/Portal.test.jsx +0 -102
- package/lib/__tests__/Position.test.jsx +0 -96
- package/lib/__tests__/ProgressBar.test.jsx +0 -38
- package/lib/__tests__/SelectMenu.test.jsx +0 -120
- package/lib/__tests__/SelectPanel.test.jsx +0 -48
- package/lib/__tests__/SideNav.test.jsx +0 -55
- package/lib/__tests__/Spinner.test.jsx +0 -41
- package/lib/__tests__/StateLabel.test.jsx +0 -46
- package/lib/__tests__/StyledOcticon.test.jsx +0 -28
- package/lib/__tests__/SubNav.test.jsx +0 -47
- package/lib/__tests__/SubNavLink.test.jsx +0 -31
- package/lib/__tests__/TabNav.test.jsx +0 -32
- package/lib/__tests__/Text.test.jsx +0 -71
- package/lib/__tests__/TextInput.test.jsx +0 -45
- package/lib/__tests__/TextInputWithTokens.test.jsx +0 -302
- package/lib/__tests__/ThemeProvider.test.jsx +0 -314
- package/lib/__tests__/Timeline.test.jsx +0 -51
- package/lib/__tests__/Token.test.jsx +0 -93
- package/lib/__tests__/Tooltip.test.jsx +0 -46
- package/lib/__tests__/Truncate.test.jsx +0 -41
- package/lib/__tests__/UnderlineNav.test.jsx +0 -53
- package/lib/__tests__/UnderlineNavLink.test.jsx +0 -31
- package/lib/__tests__/behaviors/focusTrap.test.jsx +0 -184
- package/lib/__tests__/behaviors/focusZone.test.jsx +0 -406
- package/lib/__tests__/behaviors/iterateFocusableElements.test.jsx +0 -58
- package/lib/__tests__/hooks/useAnchoredPosition.test.jsx +0 -29
- package/lib/__tests__/hooks/useOnEscapePress.test.jsx +0 -19
- package/lib/__tests__/hooks/useOnOutsideClick.test.jsx +0 -63
- package/lib/__tests__/hooks/useOpenAndCloseFocus.test.jsx +0 -61
- package/lib/__tests__/hooks/useProvidedStateOrCreate.test.jsx +0 -56
- package/lib/__tests__/useSafeTimeout.test.jsx +0 -36
- package/lib/__tests__/utils/createSlots.test.jsx +0 -57
- package/lib/hooks/useDetails.jsx +0 -39
- package/lib/hooks/useOnOutsideClick.jsx +0 -61
- package/lib/hooks/useOverlay.jsx +0 -15
- package/lib/utils/create-slots.jsx +0 -65
- package/lib/utils/deprecate.jsx +0 -59
- package/lib/utils/isNumeric.jsx +0 -7
- package/lib/utils/ssr.jsx +0 -6
- package/lib/utils/test-deprecations.jsx +0 -20
- package/lib/utils/test-helpers.jsx +0 -8
- package/lib/utils/test-matchers.jsx +0 -100
- package/lib/utils/testing.jsx +0 -206
- package/tsconfig.base.json +0 -20
@@ -1,56 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
-
if (k2 === undefined) k2 = k;
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
5
|
-
}) : (function(o, m, k, k2) {
|
6
|
-
if (k2 === undefined) k2 = k;
|
7
|
-
o[k2] = m[k];
|
8
|
-
}));
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
11
|
-
}) : function(o, v) {
|
12
|
-
o["default"] = v;
|
13
|
-
});
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
15
|
-
if (mod && mod.__esModule) return mod;
|
16
|
-
var result = {};
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
18
|
-
__setModuleDefault(result, mod);
|
19
|
-
return result;
|
20
|
-
};
|
21
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
22
|
-
const useProvidedStateOrCreate_1 = require("../../hooks/useProvidedStateOrCreate");
|
23
|
-
const react_1 = require("@testing-library/react");
|
24
|
-
const react_2 = __importStar(require("react"));
|
25
|
-
it('will use the provided state', () => {
|
26
|
-
const Component = () => {
|
27
|
-
const [state, setState] = react_2.useState('foo');
|
28
|
-
const [combinedState] = useProvidedStateOrCreate_1.useProvidedStateOrCreate(state, setState, 'bar');
|
29
|
-
return <div>{combinedState}</div>;
|
30
|
-
};
|
31
|
-
const doc = react_1.render(<Component />);
|
32
|
-
expect(doc.baseElement.textContent).toEqual('foo');
|
33
|
-
});
|
34
|
-
it('will set state correctly when provided a set state method', () => {
|
35
|
-
const Component = () => {
|
36
|
-
const [state, setState] = react_2.useState('foo');
|
37
|
-
const [combinedState, setCombinedState] = useProvidedStateOrCreate_1.useProvidedStateOrCreate(state, setState, 'bar');
|
38
|
-
if (combinedState !== 'baz')
|
39
|
-
setCombinedState('baz');
|
40
|
-
return <div>{combinedState}</div>;
|
41
|
-
};
|
42
|
-
const doc = react_1.render(<Component />);
|
43
|
-
expect(doc.baseElement.textContent).toEqual('baz');
|
44
|
-
});
|
45
|
-
it('if not provided a state, will use an internal state', () => {
|
46
|
-
const Component = () => {
|
47
|
-
const state = undefined;
|
48
|
-
const setState = undefined;
|
49
|
-
const [combinedState, setCombinedState] = useProvidedStateOrCreate_1.useProvidedStateOrCreate(state, setState, '');
|
50
|
-
if (combinedState !== 'bar')
|
51
|
-
setCombinedState('bar');
|
52
|
-
return <div>{combinedState}</div>;
|
53
|
-
};
|
54
|
-
const doc = react_1.render(<Component />);
|
55
|
-
expect(doc.baseElement.textContent).toEqual('bar');
|
56
|
-
});
|
@@ -1,36 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
-
};
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
const react_hooks_1 = require("@testing-library/react-hooks");
|
7
|
-
const useSafeTimeout_1 = __importDefault(require("../hooks/useSafeTimeout"));
|
8
|
-
afterEach(() => {
|
9
|
-
jest.useRealTimers();
|
10
|
-
});
|
11
|
-
test('should call callback after time', async () => {
|
12
|
-
const { result, waitFor } = react_hooks_1.renderHook(() => useSafeTimeout_1.default());
|
13
|
-
const mockFunction = jest.fn();
|
14
|
-
result.current.safeSetTimeout(mockFunction, 300);
|
15
|
-
await waitFor(() => expect(mockFunction).toHaveBeenCalled());
|
16
|
-
});
|
17
|
-
test('should clear timeouts when safeClearTimeout is called', () => {
|
18
|
-
jest.useFakeTimers();
|
19
|
-
jest.spyOn(global, 'clearTimeout');
|
20
|
-
const { result } = react_hooks_1.renderHook(() => useSafeTimeout_1.default());
|
21
|
-
const mockFunction = jest.fn();
|
22
|
-
const timeoutId = result.current.safeSetTimeout(mockFunction, 300);
|
23
|
-
result.current.safeClearTimeout(timeoutId);
|
24
|
-
expect(clearTimeout).toHaveBeenCalledTimes(1);
|
25
|
-
expect(clearTimeout).toHaveBeenLastCalledWith(timeoutId);
|
26
|
-
});
|
27
|
-
test('should clear timeouts when the component is unmounted', () => {
|
28
|
-
jest.useFakeTimers();
|
29
|
-
jest.spyOn(global, 'clearTimeout');
|
30
|
-
const { result, unmount } = react_hooks_1.renderHook(() => useSafeTimeout_1.default());
|
31
|
-
const mockFunction = jest.fn();
|
32
|
-
const timeoutId = result.current.safeSetTimeout(mockFunction, 300);
|
33
|
-
unmount();
|
34
|
-
expect(clearTimeout).toHaveBeenCalledTimes(1);
|
35
|
-
expect(clearTimeout).toHaveBeenLastCalledWith(timeoutId);
|
36
|
-
});
|
@@ -1,57 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
-
};
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
const react_1 = __importDefault(require("react"));
|
7
|
-
require("babel-polyfill");
|
8
|
-
const react_2 = require("@testing-library/react");
|
9
|
-
const create_slots_1 = __importDefault(require("../../utils/create-slots"));
|
10
|
-
// setup a component with slots
|
11
|
-
const { Slots, Slot } = create_slots_1.default(['One', 'Two', 'Three']);
|
12
|
-
const ComponentWithSlots = ({ salutation, children }) => {
|
13
|
-
return (<Slots context={{ salutation }}>
|
14
|
-
{slots => (<div>
|
15
|
-
{slots.One}
|
16
|
-
<span>
|
17
|
-
{children} {slots.Two} {slots.Three}
|
18
|
-
</span>
|
19
|
-
</div>)}
|
20
|
-
</Slots>);
|
21
|
-
};
|
22
|
-
const SlotItem1 = ({ children }) => <Slot name="One">{children}</Slot>;
|
23
|
-
const SlotItem2 = ({ children }) => <Slot name="Two">{children}</Slot>;
|
24
|
-
const SlotItem3 = ({ children }) => (<Slot name="Three">
|
25
|
-
{(context) => (<>
|
26
|
-
{context.salutation} {children}
|
27
|
-
</>)}
|
28
|
-
</Slot>);
|
29
|
-
describe('ComponentWithSlots', () => {
|
30
|
-
it('renders all slots', async () => {
|
31
|
-
const component = react_2.render(<ComponentWithSlots>
|
32
|
-
<SlotItem1>first</SlotItem1>
|
33
|
-
<SlotItem2>second</SlotItem2>
|
34
|
-
free form
|
35
|
-
</ComponentWithSlots>);
|
36
|
-
await react_2.waitFor(() => component.getByText('first'));
|
37
|
-
expect(component.container).toMatchSnapshot();
|
38
|
-
});
|
39
|
-
it('renders without any slots', async () => {
|
40
|
-
const component = react_2.render(<ComponentWithSlots>free form</ComponentWithSlots>);
|
41
|
-
expect(component.container).toMatchSnapshot();
|
42
|
-
});
|
43
|
-
it('renders with just one slot', async () => {
|
44
|
-
const component = react_2.render(<ComponentWithSlots>
|
45
|
-
<SlotItem1>first</SlotItem1>
|
46
|
-
free form
|
47
|
-
</ComponentWithSlots>);
|
48
|
-
expect(component.container).toMatchSnapshot();
|
49
|
-
});
|
50
|
-
it('renders with context passed to children', async () => {
|
51
|
-
const component = react_2.render(<ComponentWithSlots salutation="hi">
|
52
|
-
<SlotItem3>third</SlotItem3>
|
53
|
-
free form
|
54
|
-
</ComponentWithSlots>);
|
55
|
-
expect(component.container).toMatchSnapshot();
|
56
|
-
});
|
57
|
-
});
|
package/lib/hooks/useDetails.jsx
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
const react_1 = require("react");
|
4
|
-
function useDetails({ ref, closeOnOutsideClick, defaultOpen, onClickOutside }) {
|
5
|
-
const [open, setOpen] = react_1.useState(defaultOpen);
|
6
|
-
const backupRef = react_1.useRef(null);
|
7
|
-
const customRef = ref ?? backupRef;
|
8
|
-
const onClickOutsideInternal = react_1.useCallback((event) => {
|
9
|
-
const { current } = customRef;
|
10
|
-
const eventTarget = event.target;
|
11
|
-
const closest = eventTarget.closest('details');
|
12
|
-
if (closest !== current) {
|
13
|
-
onClickOutside && onClickOutside(event);
|
14
|
-
if (!event.defaultPrevented) {
|
15
|
-
setOpen(false);
|
16
|
-
}
|
17
|
-
}
|
18
|
-
}, [customRef, setOpen, onClickOutside]);
|
19
|
-
// handles the overlay behavior - closing the menu when clicking outside of it
|
20
|
-
react_1.useEffect(() => {
|
21
|
-
if (open && closeOnOutsideClick) {
|
22
|
-
document.addEventListener('click', onClickOutsideInternal);
|
23
|
-
return () => {
|
24
|
-
document.removeEventListener('click', onClickOutsideInternal);
|
25
|
-
};
|
26
|
-
}
|
27
|
-
}, [open, closeOnOutsideClick, onClickOutsideInternal]);
|
28
|
-
const handleToggle = (e) => {
|
29
|
-
if (!e.defaultPrevented) {
|
30
|
-
const eventTarget = e.target;
|
31
|
-
setOpen(eventTarget.open);
|
32
|
-
}
|
33
|
-
};
|
34
|
-
const getDetailsProps = () => {
|
35
|
-
return { onToggle: handleToggle, open, ref: customRef };
|
36
|
-
};
|
37
|
-
return { open, setOpen, getDetailsProps };
|
38
|
-
}
|
39
|
-
exports.default = useDetails;
|
@@ -1,61 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.useOnOutsideClick = void 0;
|
4
|
-
const react_1 = require("react");
|
5
|
-
// Because events are handled at the document level, we provide a mechanism for early return.
|
6
|
-
const stopPropagation = true;
|
7
|
-
/**
|
8
|
-
* Calls all handlers in reverse order
|
9
|
-
* @param event The MouseEvent generated by the click event.
|
10
|
-
*/
|
11
|
-
function handleClick(event) {
|
12
|
-
if (!event.defaultPrevented) {
|
13
|
-
for (const handler of Object.values(registry).reverse()) {
|
14
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
15
|
-
if (handler(event) === stopPropagation || event.defaultPrevented) {
|
16
|
-
break;
|
17
|
-
}
|
18
|
-
}
|
19
|
-
}
|
20
|
-
}
|
21
|
-
const registry = {};
|
22
|
-
function register(id, handler) {
|
23
|
-
registry[id] = handler;
|
24
|
-
}
|
25
|
-
function deregister(id) {
|
26
|
-
delete registry[id];
|
27
|
-
}
|
28
|
-
// For auto-incrementing unique identifiers for registered handlers.
|
29
|
-
let handlerId = 0;
|
30
|
-
const useOnOutsideClick = ({ containerRef, ignoreClickRefs, onClickOutside }) => {
|
31
|
-
const id = react_1.useMemo(() => handlerId++, []);
|
32
|
-
const handler = react_1.useCallback(event => {
|
33
|
-
// don't call click handler if the mouse event was triggered by an auxiliary button (right click/wheel button/etc)
|
34
|
-
if (event instanceof MouseEvent && event.button > 0) {
|
35
|
-
return stopPropagation;
|
36
|
-
}
|
37
|
-
// don't call handler if the click happened inside of the container
|
38
|
-
if (containerRef.current?.contains(event.target)) {
|
39
|
-
return stopPropagation;
|
40
|
-
}
|
41
|
-
// don't call handler if click happened on an ignored ref
|
42
|
-
if (ignoreClickRefs && ignoreClickRefs.some(({ current }) => current?.contains(event.target))) {
|
43
|
-
return stopPropagation;
|
44
|
-
}
|
45
|
-
onClickOutside(event);
|
46
|
-
}, [containerRef, ignoreClickRefs, onClickOutside]);
|
47
|
-
react_1.useEffect(() => {
|
48
|
-
if (Object.keys(registry).length === 0) {
|
49
|
-
// use capture to ensure we get all events
|
50
|
-
document.addEventListener('mousedown', handleClick, { capture: true });
|
51
|
-
}
|
52
|
-
register(id, handler);
|
53
|
-
return () => {
|
54
|
-
deregister(id);
|
55
|
-
if (Object.keys(registry).length === 0) {
|
56
|
-
document.removeEventListener('mousedown', handleClick, { capture: true });
|
57
|
-
}
|
58
|
-
};
|
59
|
-
}, [id, handler]);
|
60
|
-
};
|
61
|
-
exports.useOnOutsideClick = useOnOutsideClick;
|
package/lib/hooks/useOverlay.jsx
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.useOverlay = void 0;
|
4
|
-
const useOnOutsideClick_1 = require("./useOnOutsideClick");
|
5
|
-
const useOpenAndCloseFocus_1 = require("./useOpenAndCloseFocus");
|
6
|
-
const useOnEscapePress_1 = require("./useOnEscapePress");
|
7
|
-
const useProvidedRefOrCreate_1 = require("./useProvidedRefOrCreate");
|
8
|
-
const useOverlay = ({ overlayRef: _overlayRef, returnFocusRef, initialFocusRef, onEscape, ignoreClickRefs, onClickOutside, preventFocusOnOpen }) => {
|
9
|
-
const overlayRef = useProvidedRefOrCreate_1.useProvidedRefOrCreate(_overlayRef);
|
10
|
-
useOpenAndCloseFocus_1.useOpenAndCloseFocus({ containerRef: overlayRef, returnFocusRef, initialFocusRef, preventFocusOnOpen });
|
11
|
-
useOnOutsideClick_1.useOnOutsideClick({ containerRef: overlayRef, ignoreClickRefs, onClickOutside });
|
12
|
-
useOnEscapePress_1.useOnEscapePress(onEscape);
|
13
|
-
return { ref: overlayRef };
|
14
|
-
};
|
15
|
-
exports.useOverlay = useOverlay;
|
@@ -1,65 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
-
};
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
const react_1 = __importDefault(require("react"));
|
7
|
-
const use_force_update_1 = require("./use-force-update");
|
8
|
-
/** createSlots is a factory that can create a
|
9
|
-
* typesafe Slots + Slot pair to use in a component definition
|
10
|
-
* For example: ActionList.Item uses createSlots to get a Slots wrapper
|
11
|
-
* + Slot component that is used by LeadingVisual, Description
|
12
|
-
*/
|
13
|
-
const createSlots = (slotNames) => {
|
14
|
-
const SlotsContext = react_1.default.createContext({
|
15
|
-
registerSlot: () => null,
|
16
|
-
unregisterSlot: () => null,
|
17
|
-
context: {}
|
18
|
-
});
|
19
|
-
/** Slots uses a Double render strategy inspired by [reach-ui/descendants](https://github.com/reach/reach-ui/tree/develop/packages/descendants)
|
20
|
-
* Slot registers themself with the Slots parent.
|
21
|
-
* When all the children have mounted = registered themselves in slot,
|
22
|
-
* we re-render the parent component to render with slots
|
23
|
-
*/
|
24
|
-
const Slots = ({ context = {}, children }) => {
|
25
|
-
// initialise slots
|
26
|
-
const slotsDefinition = {};
|
27
|
-
slotNames.map(name => (slotsDefinition[name] = null));
|
28
|
-
const slotsRef = react_1.default.useRef(slotsDefinition);
|
29
|
-
const rerenderWithSlots = use_force_update_1.useForceUpdate();
|
30
|
-
const [isMounted, setIsMounted] = react_1.default.useState(false);
|
31
|
-
// fires after all the effects in children
|
32
|
-
react_1.default.useEffect(() => {
|
33
|
-
rerenderWithSlots();
|
34
|
-
setIsMounted(true);
|
35
|
-
}, [rerenderWithSlots]);
|
36
|
-
const registerSlot = react_1.default.useCallback((name, contents) => {
|
37
|
-
slotsRef.current[name] = contents;
|
38
|
-
// don't render until the component mounts = all slots are registered
|
39
|
-
if (isMounted)
|
40
|
-
rerenderWithSlots();
|
41
|
-
}, [isMounted, rerenderWithSlots]);
|
42
|
-
// Slot can be removed from the tree as well,
|
43
|
-
// we need to unregister them from the slot
|
44
|
-
const unregisterSlot = react_1.default.useCallback((name) => {
|
45
|
-
slotsRef.current[name] = null;
|
46
|
-
rerenderWithSlots();
|
47
|
-
}, [rerenderWithSlots]);
|
48
|
-
/**
|
49
|
-
* Slots uses a render prop API so abstract the
|
50
|
-
* implementation detail of using a context provider.
|
51
|
-
*/
|
52
|
-
const slots = slotsRef.current;
|
53
|
-
return (<SlotsContext.Provider value={{ registerSlot, unregisterSlot, context }}>{children(slots)}</SlotsContext.Provider>);
|
54
|
-
};
|
55
|
-
const Slot = ({ name, children }) => {
|
56
|
-
const { registerSlot, unregisterSlot, context } = react_1.default.useContext(SlotsContext);
|
57
|
-
react_1.default.useEffect(() => {
|
58
|
-
registerSlot(name, typeof children === 'function' ? children(context) : children);
|
59
|
-
return () => unregisterSlot(name);
|
60
|
-
}, [name, children, registerSlot, unregisterSlot, context]);
|
61
|
-
return null;
|
62
|
-
};
|
63
|
-
return { Slots, Slot };
|
64
|
-
};
|
65
|
-
exports.default = createSlots;
|
package/lib/utils/deprecate.jsx
DELETED
@@ -1,59 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.Deprecations = exports.useDeprecation = exports.deprecate = void 0;
|
4
|
-
const react_1 = require("react");
|
5
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
6
|
-
const noop = () => { };
|
7
|
-
// eslint-disable-next-line import/no-mutable-exports
|
8
|
-
let deprecate = noop;
|
9
|
-
exports.deprecate = deprecate;
|
10
|
-
if (__DEV__) {
|
11
|
-
exports.deprecate = deprecate = ({ name, message, version }) => {
|
12
|
-
Deprecations.deprecate({ name, message, version });
|
13
|
-
};
|
14
|
-
}
|
15
|
-
// eslint-disable-next-line import/no-mutable-exports
|
16
|
-
let useDeprecation = null;
|
17
|
-
exports.useDeprecation = useDeprecation;
|
18
|
-
if (__DEV__) {
|
19
|
-
exports.useDeprecation = useDeprecation = ({ name, message, version }) => {
|
20
|
-
const ref = react_1.useRef(false);
|
21
|
-
const logDeprecation = react_1.useCallback(() => {
|
22
|
-
if (!ref.current) {
|
23
|
-
ref.current = true;
|
24
|
-
deprecate({ name, message, version });
|
25
|
-
}
|
26
|
-
}, [name, message, version]);
|
27
|
-
return logDeprecation;
|
28
|
-
};
|
29
|
-
}
|
30
|
-
else {
|
31
|
-
exports.useDeprecation = useDeprecation = () => {
|
32
|
-
return noop;
|
33
|
-
};
|
34
|
-
}
|
35
|
-
class Deprecations {
|
36
|
-
constructor() {
|
37
|
-
this.deprecations = [];
|
38
|
-
}
|
39
|
-
static get() {
|
40
|
-
if (!Deprecations.instance) {
|
41
|
-
Deprecations.instance = new Deprecations();
|
42
|
-
}
|
43
|
-
return Deprecations.instance;
|
44
|
-
}
|
45
|
-
static deprecate({ name, message, version }) {
|
46
|
-
const msg = `WARNING! ${name} is deprecated and will be removed in version ${version}. ${message}`;
|
47
|
-
// eslint-disable-next-line no-console
|
48
|
-
console.warn(msg);
|
49
|
-
this.get().deprecations.push({ name, message, version });
|
50
|
-
}
|
51
|
-
static getDeprecations() {
|
52
|
-
return this.get().deprecations;
|
53
|
-
}
|
54
|
-
static clearDeprecations() {
|
55
|
-
this.get().deprecations.length = 0;
|
56
|
-
}
|
57
|
-
}
|
58
|
-
exports.Deprecations = Deprecations;
|
59
|
-
Deprecations.instance = null;
|
package/lib/utils/isNumeric.jsx
DELETED
package/lib/utils/ssr.jsx
DELETED
@@ -1,6 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.useSSRSafeId = exports.SSRProvider = void 0;
|
4
|
-
var ssr_1 = require("@react-aria/ssr");
|
5
|
-
Object.defineProperty(exports, "SSRProvider", { enumerable: true, get: function () { return ssr_1.SSRProvider; } });
|
6
|
-
Object.defineProperty(exports, "useSSRSafeId", { enumerable: true, get: function () { return ssr_1.useSSRSafeId; } });
|
@@ -1,20 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
-
};
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
const semver_1 = __importDefault(require("semver"));
|
7
|
-
const deprecate_1 = require("./deprecate");
|
8
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
9
|
-
const ourVersion = require('../../package.json').version;
|
10
|
-
beforeEach(() => {
|
11
|
-
deprecate_1.Deprecations.clearDeprecations();
|
12
|
-
});
|
13
|
-
afterEach(() => {
|
14
|
-
const deprecations = deprecate_1.Deprecations.getDeprecations();
|
15
|
-
for (const dep of deprecations) {
|
16
|
-
if (semver_1.default.gte(ourVersion, dep.version)) {
|
17
|
-
throw new Error(`Found a deprecation that should be removed in ${dep.version}`);
|
18
|
-
}
|
19
|
-
}
|
20
|
-
});
|
@@ -1,100 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
-
};
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
require("jest-styled-components");
|
7
|
-
const serializer_1 = require("jest-styled-components/serializer");
|
8
|
-
const react_1 = __importDefault(require("react"));
|
9
|
-
const testing_1 = require("./testing");
|
10
|
-
expect.addSnapshotSerializer(serializer_1.styleSheetSerializer);
|
11
|
-
const stringify = (d) => JSON.stringify(d, null, ' ');
|
12
|
-
expect.extend({
|
13
|
-
toMatchKeys(obj, values) {
|
14
|
-
return {
|
15
|
-
pass: Object.keys(values).every(key => this.equals(obj[key], values[key])),
|
16
|
-
message: () => `Expected ${stringify(obj)} to have matching keys: ${stringify(values)}`
|
17
|
-
};
|
18
|
-
},
|
19
|
-
toHaveClass(node, klass) {
|
20
|
-
const classes = testing_1.getClasses(node);
|
21
|
-
const pass = classes.includes(klass);
|
22
|
-
return {
|
23
|
-
pass,
|
24
|
-
message: () => `expected ${stringify(classes)} to include: ${stringify(klass)}`
|
25
|
-
};
|
26
|
-
},
|
27
|
-
toHaveClasses(node, klasses, only = false) {
|
28
|
-
const classes = testing_1.getClasses(node);
|
29
|
-
const pass = only
|
30
|
-
? this.equals(classes.sort(), klasses.sort())
|
31
|
-
: klasses.every((klass) => classes.includes(klass));
|
32
|
-
return {
|
33
|
-
pass,
|
34
|
-
message: () => `expected ${stringify(classes)} to include: ${stringify(klasses)}`
|
35
|
-
};
|
36
|
-
},
|
37
|
-
toImplementSxBehavior(element) {
|
38
|
-
const mediaKey = '@media (max-width:123px)';
|
39
|
-
const sxPropValue = {
|
40
|
-
[mediaKey]: {
|
41
|
-
color: 'red.5'
|
42
|
-
}
|
43
|
-
};
|
44
|
-
const elem = react_1.default.cloneElement(element, { sx: sxPropValue });
|
45
|
-
function checkStylesDeep(rendered) {
|
46
|
-
const className = rendered.props.className;
|
47
|
-
const styles = testing_1.getComputedStyles(className);
|
48
|
-
const mediaStyles = styles[mediaKey];
|
49
|
-
if (mediaStyles && mediaStyles.color) {
|
50
|
-
return true;
|
51
|
-
}
|
52
|
-
else if (rendered.children) {
|
53
|
-
return rendered.children.some((child) => checkStylesDeep(child));
|
54
|
-
}
|
55
|
-
else {
|
56
|
-
return false;
|
57
|
-
}
|
58
|
-
}
|
59
|
-
return {
|
60
|
-
pass: checkStylesDeep(testing_1.render(elem)),
|
61
|
-
message: () => 'sx prop values did not change styles of component nor of any sub-components'
|
62
|
-
};
|
63
|
-
},
|
64
|
-
toSetExports(mod, expectedExports) {
|
65
|
-
if (!Object.keys(expectedExports).includes('default')) {
|
66
|
-
return {
|
67
|
-
pass: false,
|
68
|
-
message: () => "You must specify the module's default export"
|
69
|
-
};
|
70
|
-
}
|
71
|
-
const seen = new Set();
|
72
|
-
for (const exp of Object.keys(expectedExports)) {
|
73
|
-
seen.add(exp);
|
74
|
-
if (mod[exp] !== expectedExports[exp]) {
|
75
|
-
if (!mod[exp] && !expectedExports[exp]) {
|
76
|
-
continue;
|
77
|
-
}
|
78
|
-
return {
|
79
|
-
pass: false,
|
80
|
-
message: () => `Module exported a different value from key '${exp}' than expected`
|
81
|
-
};
|
82
|
-
}
|
83
|
-
}
|
84
|
-
for (const exp of Object.keys(mod)) {
|
85
|
-
if (seen.has(exp)) {
|
86
|
-
continue;
|
87
|
-
}
|
88
|
-
if (mod[exp] !== expectedExports[exp]) {
|
89
|
-
return {
|
90
|
-
pass: false,
|
91
|
-
message: () => `Module exported an unexpected value from key '${exp}'`
|
92
|
-
};
|
93
|
-
}
|
94
|
-
}
|
95
|
-
return {
|
96
|
-
pass: true,
|
97
|
-
message: () => ''
|
98
|
-
};
|
99
|
-
}
|
100
|
-
});
|