@primer/components 0.0.0-20211124581 → 0.0.0-2021113174023
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 +4 -110
- package/dist/browser.esm.js +783 -738
- package/dist/browser.esm.js.map +1 -1
- package/dist/browser.umd.js +781 -736
- package/dist/browser.umd.js.map +1 -1
- package/lib/ActionList/Divider.jsx +29 -0
- package/lib/ActionList/Group.jsx +23 -0
- package/lib/ActionList/Header.jsx +66 -0
- package/lib/ActionList/Item.js +55 -30
- package/lib/ActionList/Item.jsx +311 -0
- package/lib/ActionList/List.jsx +138 -0
- package/lib/ActionList/index.js +12 -23
- package/lib/ActionList2/Description.jsx +29 -0
- package/lib/ActionList2/Divider.d.ts +2 -3
- package/lib/ActionList2/Divider.js +5 -10
- package/lib/ActionList2/Divider.jsx +22 -0
- package/lib/ActionList2/Group.d.ts +2 -28
- package/lib/ActionList2/Group.js +6 -55
- package/lib/ActionList2/Group.jsx +25 -0
- package/lib/ActionList2/Header.d.ts +26 -0
- package/lib/ActionList2/Header.js +55 -0
- package/lib/ActionList2/Header.jsx +36 -0
- package/lib/ActionList2/Item.js +6 -24
- package/lib/ActionList2/Item.jsx +174 -0
- package/lib/ActionList2/LinkItem.jsx +28 -0
- package/lib/ActionList2/List.d.ts +1 -1
- package/lib/ActionList2/List.js +1 -10
- package/lib/ActionList2/List.jsx +41 -0
- package/lib/ActionList2/Selection.js +1 -14
- package/lib/ActionList2/Selection.jsx +50 -0
- package/lib/ActionList2/Visuals.jsx +48 -0
- package/lib/ActionList2/index.d.ts +2 -1
- package/lib/ActionList2/index.js +23 -41
- package/lib/ActionMenu.jsx +73 -0
- package/lib/AnchoredOverlay/AnchoredOverlay.jsx +100 -0
- package/lib/AnchoredOverlay/index.js +4 -12
- package/lib/Autocomplete/Autocomplete.d.ts +3 -12
- package/lib/Autocomplete/Autocomplete.jsx +100 -0
- package/lib/Autocomplete/AutocompleteContext.jsx +5 -0
- package/lib/Autocomplete/AutocompleteInput.d.ts +3 -12
- package/lib/Autocomplete/AutocompleteInput.jsx +113 -0
- package/lib/Autocomplete/AutocompleteMenu.jsx +190 -0
- package/lib/Autocomplete/AutocompleteOverlay.jsx +55 -0
- package/lib/Autocomplete/index.js +7 -14
- package/lib/Avatar.d.ts +2 -1
- package/lib/Avatar.js +1 -1
- package/lib/Avatar.jsx +34 -0
- package/lib/AvatarPair.jsx +29 -0
- package/lib/AvatarStack.jsx +151 -0
- package/lib/BaseStyles.jsx +65 -0
- package/lib/BorderBox.jsx +18 -0
- package/lib/Box.jsx +10 -0
- package/lib/BranchName.d.ts +2 -1
- package/lib/BranchName.js +1 -1
- package/lib/BranchName.jsx +20 -0
- package/lib/Breadcrumbs.d.ts +7 -8
- package/lib/Breadcrumbs.js +12 -7
- package/lib/Breadcrumbs.jsx +74 -0
- package/lib/Button/Button.d.ts +3 -3
- package/lib/Button/Button.js +6 -2
- package/lib/Button/Button.jsx +60 -0
- package/lib/Button/ButtonBase.d.ts +8 -5
- package/lib/Button/ButtonBase.js +5 -1
- package/lib/Button/ButtonBase.jsx +36 -0
- package/lib/Button/ButtonClose.d.ts +46 -4
- package/lib/Button/ButtonClose.js +1 -1
- package/lib/Button/ButtonClose.jsx +55 -0
- package/lib/Button/ButtonDanger.d.ts +3 -3
- package/lib/Button/ButtonDanger.js +6 -2
- package/lib/Button/ButtonDanger.jsx +63 -0
- package/lib/Button/ButtonGroup.jsx +55 -0
- package/lib/Button/ButtonInvisible.d.ts +3 -3
- package/lib/Button/ButtonInvisible.js +6 -2
- package/lib/Button/ButtonInvisible.jsx +52 -0
- package/lib/Button/ButtonOutline.d.ts +3 -3
- package/lib/Button/ButtonOutline.js +6 -2
- package/lib/Button/ButtonOutline.jsx +63 -0
- package/lib/Button/ButtonPrimary.d.ts +3 -3
- package/lib/Button/ButtonPrimary.js +6 -2
- package/lib/Button/ButtonPrimary.jsx +62 -0
- package/lib/Button/ButtonStyles.jsx +37 -0
- package/lib/Button/ButtonTableList.d.ts +2 -1
- package/lib/Button/ButtonTableList.js +1 -1
- package/lib/Button/ButtonTableList.jsx +49 -0
- package/lib/Button/index.js +21 -70
- package/lib/Caret.jsx +93 -0
- package/lib/CircleBadge.d.ts +5 -4
- package/lib/CircleBadge.js +1 -1
- package/lib/CircleBadge.jsx +43 -0
- package/lib/CircleOcticon.d.ts +1 -2
- package/lib/CircleOcticon.jsx +21 -0
- package/lib/CounterLabel.d.ts +2 -1
- package/lib/CounterLabel.js +1 -1
- package/lib/CounterLabel.jsx +44 -0
- package/lib/Details.d.ts +2 -1
- package/lib/Details.js +3 -1
- package/lib/Details.jsx +21 -0
- package/lib/Dialog/ConfirmationDialog.jsx +146 -0
- package/lib/Dialog/Dialog.d.ts +9 -5
- package/lib/Dialog/Dialog.js +11 -17
- package/lib/Dialog/Dialog.jsx +273 -0
- package/lib/Dialog.d.ts +5 -5
- package/lib/Dialog.js +1 -1
- package/lib/Dialog.jsx +131 -0
- package/lib/Dropdown.d.ts +165 -16
- package/lib/Dropdown.js +3 -3
- package/lib/Dropdown.jsx +134 -0
- package/lib/DropdownMenu/DropdownButton.d.ts +47 -4
- package/lib/DropdownMenu/DropdownButton.js +1 -3
- package/lib/DropdownMenu/DropdownButton.jsx +14 -0
- package/lib/DropdownMenu/DropdownMenu.jsx +70 -0
- package/lib/DropdownMenu/index.js +6 -20
- package/lib/DropdownStyles.js +18 -26
- package/lib/EmojiPicker/EmojiPicker.d.ts +17 -0
- package/lib/EmojiPicker/EmojiPicker.js +202 -0
- package/lib/EmojiPicker/EmojiPicker.jsx +132 -0
- package/lib/EmojiPicker/EmojiPickerAnchor.d.ts +0 -0
- package/lib/EmojiPicker/EmojiPickerAnchor.js +1 -0
- package/lib/EmojiPicker/EmojiPickerAnchor.jsx +1 -0
- package/lib/EmojiPicker/EmojiPickerPanel.d.ts +3 -0
- package/lib/EmojiPicker/EmojiPickerPanel.js +18 -0
- package/lib/EmojiPicker/EmojiPickerPanel.jsx +10 -0
- package/lib/EmojiPicker/data.d.ts +9 -0
- package/lib/EmojiPicker/data.js +7254 -0
- package/lib/EmojiPicker/index.d.ts +2 -0
- package/lib/EmojiPicker/index.js +8 -0
- package/lib/FilterList.d.ts +303 -265
- package/lib/FilterList.js +6 -2
- package/lib/FilterList.jsx +63 -0
- package/lib/FilteredActionList/FilteredActionList.jsx +100 -0
- package/lib/FilteredActionList/index.js +4 -12
- package/lib/FilteredSearch.d.ts +2 -1
- package/lib/FilteredSearch.js +1 -1
- package/lib/FilteredSearch.jsx +29 -0
- package/lib/Flash.d.ts +2 -1
- package/lib/Flash.js +1 -1
- package/lib/Flash.jsx +70 -0
- package/lib/Flex.jsx +15 -0
- package/lib/FormGroup.d.ts +5 -4
- package/lib/FormGroup.js +2 -2
- package/lib/FormGroup.jsx +25 -0
- package/lib/Grid.jsx +15 -0
- package/lib/Header.d.ts +7 -6
- package/lib/Header.js +4 -4
- package/lib/Header.jsx +90 -0
- package/lib/Heading.d.ts +2 -1
- package/lib/Heading.js +6 -1
- package/lib/Heading.jsx +21 -0
- package/lib/Label.d.ts +2 -1
- package/lib/Label.js +3 -2
- package/lib/Label.jsx +84 -0
- package/lib/LabelGroup.d.ts +2 -1
- package/lib/LabelGroup.js +1 -1
- package/lib/LabelGroup.jsx +19 -0
- package/lib/Link.d.ts +2 -1
- package/lib/Link.js +1 -1
- package/lib/Link.jsx +38 -0
- package/lib/NewButton/button-counter.jsx +14 -0
- package/lib/NewButton/button.js +42 -34
- package/lib/NewButton/button.jsx +278 -0
- package/lib/NewButton/index.js +5 -12
- package/lib/NewButton/types.js +2 -1
- package/lib/Overlay.d.ts +11 -14
- package/lib/Overlay.js +4 -3
- package/lib/Overlay.jsx +156 -0
- package/lib/Pagehead.d.ts +2 -1
- package/lib/Pagehead.js +1 -1
- package/lib/Pagehead.jsx +18 -0
- package/lib/Pagination/Pagination.js +1 -1
- package/lib/Pagination/Pagination.jsx +163 -0
- package/lib/Pagination/index.js +6 -12
- package/lib/Pagination/model.jsx +174 -0
- package/lib/PointerBox.jsx +25 -0
- package/lib/Popover.d.ts +5 -4
- package/lib/Popover.js +5 -4
- package/lib/Popover.jsx +210 -0
- package/lib/Portal/Portal.jsx +79 -0
- package/lib/Portal/index.js +5 -16
- package/lib/Position.d.ts +4 -4
- package/lib/Position.jsx +46 -0
- package/lib/ProgressBar.d.ts +11 -16
- package/lib/ProgressBar.js +10 -6
- package/lib/ProgressBar.jsx +39 -0
- package/lib/SelectMenu/SelectMenu.d.ts +189 -35
- package/lib/SelectMenu/SelectMenu.js +3 -1
- package/lib/SelectMenu/SelectMenu.jsx +114 -0
- package/lib/SelectMenu/SelectMenuContext.jsx +5 -0
- package/lib/SelectMenu/SelectMenuDivider.d.ts +2 -1
- package/lib/SelectMenu/SelectMenuDivider.js +1 -1
- package/lib/SelectMenu/SelectMenuDivider.jsx +43 -0
- package/lib/SelectMenu/SelectMenuFilter.js +1 -1
- package/lib/SelectMenu/SelectMenuFilter.jsx +59 -0
- package/lib/SelectMenu/SelectMenuFooter.d.ts +2 -1
- package/lib/SelectMenu/SelectMenuFooter.js +1 -1
- package/lib/SelectMenu/SelectMenuFooter.jsx +46 -0
- package/lib/SelectMenu/SelectMenuHeader.d.ts +2 -1
- package/lib/SelectMenu/SelectMenuHeader.js +1 -1
- package/lib/SelectMenu/SelectMenuHeader.jsx +44 -0
- package/lib/SelectMenu/SelectMenuItem.d.ts +3 -2
- package/lib/SelectMenu/SelectMenuItem.js +1 -1
- package/lib/SelectMenu/SelectMenuItem.jsx +143 -0
- package/lib/SelectMenu/SelectMenuList.d.ts +2 -1
- package/lib/SelectMenu/SelectMenuList.js +1 -1
- package/lib/SelectMenu/SelectMenuList.jsx +60 -0
- package/lib/SelectMenu/SelectMenuLoadingAnimation.d.ts +2 -2
- package/lib/SelectMenu/SelectMenuLoadingAnimation.js +1 -3
- package/lib/SelectMenu/SelectMenuLoadingAnimation.jsx +21 -0
- package/lib/SelectMenu/SelectMenuModal.d.ts +3 -2
- package/lib/SelectMenu/SelectMenuModal.js +1 -1
- package/lib/SelectMenu/SelectMenuModal.jsx +119 -0
- package/lib/SelectMenu/SelectMenuTab.d.ts +2 -1
- package/lib/SelectMenu/SelectMenuTab.js +1 -1
- package/lib/SelectMenu/SelectMenuTab.jsx +93 -0
- package/lib/SelectMenu/SelectMenuTabPanel.d.ts +2 -1
- package/lib/SelectMenu/SelectMenuTabPanel.js +1 -1
- package/lib/SelectMenu/SelectMenuTabPanel.jsx +43 -0
- package/lib/SelectMenu/SelectMenuTabs.d.ts +2 -1
- package/lib/SelectMenu/SelectMenuTabs.js +1 -1
- package/lib/SelectMenu/SelectMenuTabs.jsx +58 -0
- package/lib/SelectMenu/hooks/useKeyboardNav.js +80 -96
- package/lib/SelectMenu/index.js +7 -14
- package/lib/SelectPanel/SelectPanel.jsx +105 -0
- package/lib/SelectPanel/index.js +4 -12
- package/lib/SideNav.d.ts +8 -11
- package/lib/SideNav.js +15 -8
- package/lib/SideNav.jsx +177 -0
- package/lib/Spinner.d.ts +2 -1
- package/lib/Spinner.js +3 -1
- package/lib/Spinner.jsx +35 -0
- package/lib/StateLabel.d.ts +2 -1
- package/lib/StateLabel.js +5 -6
- package/lib/StateLabel.jsx +94 -0
- package/lib/StyledOcticon.d.ts +2 -1
- package/lib/StyledOcticon.js +3 -1
- package/lib/StyledOcticon.jsx +20 -0
- package/lib/SubNav.d.ts +11 -5
- package/lib/SubNav.js +12 -7
- package/lib/SubNav.jsx +104 -0
- package/lib/TabNav.d.ts +4 -3
- package/lib/TabNav.js +2 -2
- package/lib/TabNav.jsx +60 -0
- package/lib/Text.jsx +14 -0
- package/lib/TextInput.d.ts +1 -8
- package/lib/TextInput.js +5 -16
- package/lib/TextInput.jsx +23 -0
- package/lib/TextInputWithTokens.d.ts +3 -12
- package/lib/TextInputWithTokens.jsx +218 -0
- package/lib/ThemeProvider.jsx +130 -0
- package/lib/Timeline.d.ts +393 -19
- package/lib/Timeline.js +13 -16
- package/lib/Timeline.jsx +124 -0
- package/lib/Token/AvatarToken.d.ts +1 -1
- package/lib/Token/AvatarToken.jsx +54 -0
- package/lib/Token/IssueLabelToken.d.ts +1 -1
- package/lib/Token/IssueLabelToken.jsx +125 -0
- package/lib/Token/Token.d.ts +1 -1
- package/lib/Token/Token.jsx +103 -0
- package/lib/Token/TokenBase.jsx +88 -0
- package/lib/Token/_RemoveTokenButton.jsx +108 -0
- package/lib/Token/_TokenTextContainer.jsx +49 -0
- package/lib/Token/index.js +11 -30
- package/lib/Tooltip.d.ts +2 -1
- package/lib/Tooltip.js +1 -1
- package/lib/Tooltip.jsx +246 -0
- package/lib/Truncate.d.ts +2 -1
- package/lib/Truncate.js +3 -1
- package/lib/Truncate.jsx +27 -0
- package/lib/UnderlineNav.d.ts +3 -2
- package/lib/UnderlineNav.js +2 -2
- package/lib/UnderlineNav.jsx +90 -0
- package/lib/_TextInputWrapper.d.ts +0 -3
- package/lib/_TextInputWrapper.js +7 -18
- package/lib/_TextInputWrapper.jsx +120 -0
- package/lib/_UnstyledTextInput.jsx +22 -0
- package/lib/behaviors/anchoredPosition.js +205 -234
- package/lib/behaviors/focusTrap.js +121 -157
- package/lib/behaviors/focusZone.js +434 -509
- package/lib/behaviors/scrollIntoViewingArea.js +18 -35
- package/lib/constants.js +39 -43
- package/lib/drafts.d.ts +0 -1
- package/lib/drafts.js +20 -43
- package/lib/hooks/index.js +16 -60
- package/lib/hooks/useAnchoredPosition.js +32 -40
- package/lib/hooks/useCombinedRefs.js +32 -36
- package/lib/hooks/useDetails.jsx +39 -0
- package/lib/hooks/useDialog.js +72 -96
- package/lib/hooks/useFocusTrap.js +43 -60
- package/lib/hooks/useFocusZone.js +54 -50
- package/lib/hooks/useOnEscapePress.js +25 -36
- package/lib/hooks/useOnOutsideClick.jsx +61 -0
- package/lib/hooks/useOpenAndCloseFocus.js +22 -34
- package/lib/hooks/useOverlay.jsx +15 -0
- package/lib/hooks/useProvidedRefOrCreate.js +10 -14
- package/lib/hooks/useProvidedStateOrCreate.js +13 -16
- package/lib/hooks/useRenderForcingRef.js +13 -17
- package/lib/hooks/useResizeObserver.js +15 -18
- package/lib/hooks/useSafeTimeout.js +22 -30
- package/lib/hooks/useScrollFlash.js +16 -23
- package/lib/index.d.ts +2 -2
- package/lib/index.js +165 -652
- package/lib/polyfills/eventListenerSignal.js +37 -45
- package/lib/sx.js +10 -22
- package/lib/theme-preval.js +64 -3169
- package/lib/theme.js +3 -12
- package/lib/utils/create-slots.jsx +65 -0
- package/lib/utils/deprecate.jsx +59 -0
- package/lib/utils/isNumeric.jsx +7 -0
- package/lib/utils/iterateFocusableElements.js +63 -85
- package/lib/utils/ssr.jsx +6 -0
- package/lib/utils/test-deprecations.jsx +20 -0
- package/lib/utils/test-helpers.jsx +8 -0
- package/lib/utils/test-matchers.jsx +100 -0
- package/lib/utils/testing.d.ts +61 -8
- package/lib/utils/testing.js +0 -29
- package/lib/utils/testing.jsx +206 -0
- package/lib/utils/theme.js +33 -47
- package/lib/utils/types/AriaRole.js +2 -1
- package/lib/utils/types/ComponentProps.js +2 -1
- package/lib/utils/types/Flatten.js +2 -1
- package/lib/utils/types/KeyPaths.js +2 -1
- package/lib/utils/types/MandateProps.js +16 -1
- package/lib/utils/types/Merge.js +2 -1
- package/lib/utils/types/index.js +16 -69
- package/lib/utils/uniqueId.js +5 -8
- package/lib/utils/use-force-update.js +8 -14
- package/lib/utils/useIsomorphicLayoutEffect.js +8 -11
- package/lib/utils/userAgent.js +8 -12
- package/lib-esm/ActionList/Item.js +56 -31
- package/lib-esm/ActionList2/Divider.d.ts +2 -3
- package/lib-esm/ActionList2/Divider.js +5 -8
- package/lib-esm/ActionList2/Group.d.ts +2 -28
- package/lib-esm/ActionList2/Group.js +5 -52
- package/lib-esm/ActionList2/Header.d.ts +26 -0
- package/lib-esm/ActionList2/Header.js +44 -0
- package/lib-esm/ActionList2/Item.js +6 -22
- package/lib-esm/ActionList2/List.d.ts +1 -1
- package/lib-esm/ActionList2/List.js +1 -8
- package/lib-esm/ActionList2/Selection.js +1 -12
- package/lib-esm/ActionList2/index.d.ts +2 -1
- package/lib-esm/Autocomplete/Autocomplete.d.ts +3 -12
- package/lib-esm/Autocomplete/AutocompleteInput.d.ts +3 -12
- package/lib-esm/Avatar.d.ts +2 -1
- package/lib-esm/Avatar.js +2 -2
- package/lib-esm/BranchName.d.ts +2 -1
- package/lib-esm/BranchName.js +2 -2
- package/lib-esm/Breadcrumbs.d.ts +7 -8
- package/lib-esm/Breadcrumbs.js +13 -8
- package/lib-esm/Button/Button.d.ts +3 -3
- package/lib-esm/Button/Button.js +2 -2
- package/lib-esm/Button/ButtonBase.d.ts +8 -5
- package/lib-esm/Button/ButtonBase.js +3 -1
- package/lib-esm/Button/ButtonClose.d.ts +46 -4
- package/lib-esm/Button/ButtonClose.js +2 -2
- package/lib-esm/Button/ButtonDanger.d.ts +3 -3
- package/lib-esm/Button/ButtonDanger.js +2 -2
- package/lib-esm/Button/ButtonInvisible.d.ts +3 -3
- package/lib-esm/Button/ButtonInvisible.js +2 -2
- package/lib-esm/Button/ButtonOutline.d.ts +3 -3
- package/lib-esm/Button/ButtonOutline.js +2 -2
- package/lib-esm/Button/ButtonPrimary.d.ts +3 -3
- package/lib-esm/Button/ButtonPrimary.js +2 -2
- package/lib-esm/Button/ButtonTableList.d.ts +2 -1
- package/lib-esm/Button/ButtonTableList.js +2 -2
- package/lib-esm/CircleBadge.d.ts +5 -4
- package/lib-esm/CircleBadge.js +2 -2
- package/lib-esm/CircleOcticon.d.ts +1 -2
- package/lib-esm/CounterLabel.d.ts +2 -1
- package/lib-esm/CounterLabel.js +2 -2
- package/lib-esm/Details.d.ts +2 -1
- package/lib-esm/Details.js +2 -1
- package/lib-esm/Dialog/Dialog.d.ts +9 -5
- package/lib-esm/Dialog/Dialog.js +12 -12
- package/lib-esm/Dialog.d.ts +5 -5
- package/lib-esm/Dialog.js +2 -2
- package/lib-esm/Dropdown.d.ts +165 -16
- package/lib-esm/Dropdown.js +4 -4
- package/lib-esm/DropdownMenu/DropdownButton.d.ts +47 -4
- package/lib-esm/DropdownMenu/DropdownButton.js +1 -3
- package/lib-esm/EmojiPicker/EmojiPicker.d.ts +17 -0
- package/lib-esm/EmojiPicker/EmojiPicker.js +181 -0
- package/lib-esm/EmojiPicker/EmojiPickerAnchor.d.ts +0 -0
- package/lib-esm/EmojiPicker/EmojiPickerAnchor.js +0 -0
- package/lib-esm/EmojiPicker/EmojiPickerPanel.d.ts +3 -0
- package/lib-esm/EmojiPicker/EmojiPickerPanel.js +8 -0
- package/lib-esm/EmojiPicker/data.d.ts +9 -0
- package/lib-esm/EmojiPicker/data.js +5434 -0
- package/lib-esm/EmojiPicker/index.d.ts +2 -0
- package/lib-esm/EmojiPicker/index.js +1 -0
- package/lib-esm/FilterList.d.ts +303 -265
- package/lib-esm/FilterList.js +7 -3
- package/lib-esm/FilteredSearch.d.ts +2 -1
- package/lib-esm/FilteredSearch.js +2 -2
- package/lib-esm/Flash.d.ts +2 -1
- package/lib-esm/Flash.js +2 -2
- package/lib-esm/FormGroup.d.ts +5 -4
- package/lib-esm/FormGroup.js +3 -3
- package/lib-esm/Header.d.ts +7 -6
- package/lib-esm/Header.js +5 -5
- package/lib-esm/Heading.d.ts +2 -1
- package/lib-esm/Heading.js +6 -2
- package/lib-esm/Label.d.ts +2 -1
- package/lib-esm/Label.js +4 -3
- package/lib-esm/LabelGroup.d.ts +2 -1
- package/lib-esm/LabelGroup.js +2 -2
- package/lib-esm/Link.d.ts +2 -1
- package/lib-esm/Link.js +2 -2
- package/lib-esm/NewButton/button.js +42 -31
- package/lib-esm/Overlay.d.ts +11 -14
- package/lib-esm/Overlay.js +3 -2
- package/lib-esm/Pagehead.d.ts +2 -1
- package/lib-esm/Pagehead.js +2 -2
- package/lib-esm/Pagination/Pagination.js +2 -2
- package/lib-esm/Popover.d.ts +5 -4
- package/lib-esm/Popover.js +5 -4
- package/lib-esm/Position.d.ts +4 -4
- package/lib-esm/ProgressBar.d.ts +11 -16
- package/lib-esm/ProgressBar.js +11 -7
- package/lib-esm/SelectMenu/SelectMenu.d.ts +189 -35
- package/lib-esm/SelectMenu/SelectMenu.js +2 -1
- package/lib-esm/SelectMenu/SelectMenuDivider.d.ts +2 -1
- package/lib-esm/SelectMenu/SelectMenuDivider.js +2 -2
- package/lib-esm/SelectMenu/SelectMenuFilter.js +2 -2
- package/lib-esm/SelectMenu/SelectMenuFooter.d.ts +2 -1
- package/lib-esm/SelectMenu/SelectMenuFooter.js +2 -2
- package/lib-esm/SelectMenu/SelectMenuHeader.d.ts +2 -1
- package/lib-esm/SelectMenu/SelectMenuHeader.js +2 -2
- package/lib-esm/SelectMenu/SelectMenuItem.d.ts +3 -2
- package/lib-esm/SelectMenu/SelectMenuItem.js +2 -2
- package/lib-esm/SelectMenu/SelectMenuList.d.ts +2 -1
- package/lib-esm/SelectMenu/SelectMenuList.js +2 -2
- package/lib-esm/SelectMenu/SelectMenuLoadingAnimation.d.ts +2 -2
- package/lib-esm/SelectMenu/SelectMenuLoadingAnimation.js +2 -3
- package/lib-esm/SelectMenu/SelectMenuModal.d.ts +3 -2
- package/lib-esm/SelectMenu/SelectMenuModal.js +2 -2
- package/lib-esm/SelectMenu/SelectMenuTab.d.ts +2 -1
- package/lib-esm/SelectMenu/SelectMenuTab.js +2 -2
- package/lib-esm/SelectMenu/SelectMenuTabPanel.d.ts +2 -1
- package/lib-esm/SelectMenu/SelectMenuTabPanel.js +2 -2
- package/lib-esm/SelectMenu/SelectMenuTabs.d.ts +2 -1
- package/lib-esm/SelectMenu/SelectMenuTabs.js +2 -2
- package/lib-esm/SideNav.d.ts +8 -11
- package/lib-esm/SideNav.js +16 -8
- package/lib-esm/Spinner.d.ts +2 -1
- package/lib-esm/Spinner.js +2 -1
- package/lib-esm/StateLabel.d.ts +2 -1
- package/lib-esm/StateLabel.js +6 -7
- package/lib-esm/StyledOcticon.d.ts +2 -1
- package/lib-esm/StyledOcticon.js +2 -1
- package/lib-esm/SubNav.d.ts +11 -5
- package/lib-esm/SubNav.js +13 -8
- package/lib-esm/TabNav.d.ts +4 -3
- package/lib-esm/TabNav.js +3 -3
- package/lib-esm/TextInput.d.ts +1 -8
- package/lib-esm/TextInput.js +5 -16
- package/lib-esm/TextInputWithTokens.d.ts +3 -12
- package/lib-esm/Timeline.d.ts +393 -19
- package/lib-esm/Timeline.js +13 -12
- package/lib-esm/Token/AvatarToken.d.ts +1 -1
- package/lib-esm/Token/IssueLabelToken.d.ts +1 -1
- package/lib-esm/Token/Token.d.ts +1 -1
- package/lib-esm/Tooltip.d.ts +2 -1
- package/lib-esm/Tooltip.js +2 -2
- package/lib-esm/Truncate.d.ts +2 -1
- package/lib-esm/Truncate.js +2 -1
- package/lib-esm/UnderlineNav.d.ts +3 -2
- package/lib-esm/UnderlineNav.js +3 -3
- package/lib-esm/_TextInputWrapper.d.ts +0 -3
- package/lib-esm/_TextInputWrapper.js +7 -18
- package/lib-esm/drafts.d.ts +0 -1
- package/lib-esm/drafts.js +1 -2
- package/lib-esm/index.d.ts +2 -2
- package/lib-esm/index.js +1 -1
- package/lib-esm/theme-preval.js +366 -512
- package/lib-esm/utils/testing.d.ts +61 -8
- package/lib-esm/utils/testing.js +0 -24
- package/package.json +6 -5
- package/lib/ActionList2/MenuContext.d.ts +0 -10
- package/lib/ActionList2/MenuContext.js +0 -15
- package/lib/ActionMenu2.d.ts +0 -310
- package/lib/ActionMenu2.js +0 -91
- package/lib/Checkbox.d.ts +0 -29
- package/lib/Checkbox.js +0 -64
- package/lib-esm/ActionList2/MenuContext.d.ts +0 -10
- package/lib-esm/ActionList2/MenuContext.js +0 -3
- package/lib-esm/ActionMenu2.d.ts +0 -310
- package/lib-esm/ActionMenu2.js +0 -67
- package/lib-esm/Checkbox.d.ts +0 -29
- package/lib-esm/Checkbox.js +0 -44
@@ -0,0 +1,174 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.buildComponentData = exports.buildPaginationModel = void 0;
|
4
|
+
function buildPaginationModel(pageCount, currentPage, showPages, marginPageCount, surroundingPageCount) {
|
5
|
+
const pages = [];
|
6
|
+
if (showPages) {
|
7
|
+
const pageNums = [];
|
8
|
+
const addPage = (n) => {
|
9
|
+
if (n >= 1 && n <= pageCount) {
|
10
|
+
pageNums.push(n);
|
11
|
+
}
|
12
|
+
};
|
13
|
+
// Start by defining the window of pages to show around the current page.
|
14
|
+
// If the window goes off either edge, shift it until it fits.
|
15
|
+
let extentLeft = currentPage - surroundingPageCount;
|
16
|
+
let extentRight = currentPage + surroundingPageCount;
|
17
|
+
if (extentLeft < 1 && extentRight > pageCount) {
|
18
|
+
// Our window is larger than the entire range,
|
19
|
+
// so simply display every page.
|
20
|
+
extentLeft = 1;
|
21
|
+
extentRight = pageCount;
|
22
|
+
}
|
23
|
+
else if (extentLeft < 1) {
|
24
|
+
while (extentLeft < 1) {
|
25
|
+
extentLeft++;
|
26
|
+
extentRight++;
|
27
|
+
}
|
28
|
+
}
|
29
|
+
else if (extentRight > pageCount) {
|
30
|
+
while (extentRight > pageCount) {
|
31
|
+
extentLeft--;
|
32
|
+
extentRight--;
|
33
|
+
}
|
34
|
+
}
|
35
|
+
// Next, include the pages in the margins.
|
36
|
+
// If a margin page is already covered in the window,
|
37
|
+
// extend the window to the other direction.
|
38
|
+
for (let i = 1; i <= marginPageCount; i++) {
|
39
|
+
const leftPage = i;
|
40
|
+
const rightPage = pageCount - (i - 1);
|
41
|
+
if (leftPage >= extentLeft) {
|
42
|
+
extentRight++;
|
43
|
+
}
|
44
|
+
else {
|
45
|
+
addPage(leftPage);
|
46
|
+
}
|
47
|
+
if (rightPage <= extentRight) {
|
48
|
+
extentLeft--;
|
49
|
+
}
|
50
|
+
else {
|
51
|
+
addPage(rightPage);
|
52
|
+
}
|
53
|
+
}
|
54
|
+
for (let i = extentLeft; i <= extentRight; i++) {
|
55
|
+
addPage(i);
|
56
|
+
}
|
57
|
+
const sorted = pageNums
|
58
|
+
.slice()
|
59
|
+
.sort((a, b) => a - b)
|
60
|
+
.filter((item, idx, ary) => !idx || item !== ary[idx - 1]);
|
61
|
+
for (let idx = 0; idx < sorted.length; idx++) {
|
62
|
+
const num = sorted[idx];
|
63
|
+
const selected = num === currentPage;
|
64
|
+
if (idx === 0) {
|
65
|
+
if (num !== 1) {
|
66
|
+
// If the first page isn't page one,
|
67
|
+
// we need to add a break
|
68
|
+
pages.push({
|
69
|
+
type: 'BREAK',
|
70
|
+
num: 1
|
71
|
+
});
|
72
|
+
}
|
73
|
+
pages.push({
|
74
|
+
type: 'NUM',
|
75
|
+
num,
|
76
|
+
selected
|
77
|
+
});
|
78
|
+
}
|
79
|
+
else {
|
80
|
+
const last = sorted[idx - 1];
|
81
|
+
const delta = num - last;
|
82
|
+
if (delta === 1) {
|
83
|
+
pages.push({
|
84
|
+
type: 'NUM',
|
85
|
+
num,
|
86
|
+
selected
|
87
|
+
});
|
88
|
+
}
|
89
|
+
else {
|
90
|
+
// We skipped some, so add a break
|
91
|
+
pages.push({
|
92
|
+
type: 'BREAK',
|
93
|
+
num: num - 1
|
94
|
+
});
|
95
|
+
pages.push({
|
96
|
+
type: 'NUM',
|
97
|
+
num,
|
98
|
+
selected
|
99
|
+
});
|
100
|
+
}
|
101
|
+
}
|
102
|
+
}
|
103
|
+
const lastPage = pages[pages.length - 1];
|
104
|
+
if (lastPage.type === 'NUM' && lastPage.num !== pageCount) {
|
105
|
+
// The last page we rendered wasn't the actual last page,
|
106
|
+
// so we need an additional break
|
107
|
+
pages.push({
|
108
|
+
type: 'BREAK',
|
109
|
+
num: pageCount
|
110
|
+
});
|
111
|
+
}
|
112
|
+
}
|
113
|
+
const prev = { type: 'PREV', num: currentPage - 1, disabled: currentPage === 1 };
|
114
|
+
const next = { type: 'NEXT', num: currentPage + 1, disabled: currentPage === pageCount };
|
115
|
+
return [prev, ...pages, next];
|
116
|
+
}
|
117
|
+
exports.buildPaginationModel = buildPaginationModel;
|
118
|
+
function buildComponentData(page, hrefBuilder, onClick) {
|
119
|
+
const props = {};
|
120
|
+
let content = '';
|
121
|
+
let key = '';
|
122
|
+
switch (page.type) {
|
123
|
+
case 'PREV': {
|
124
|
+
key = 'page-prev';
|
125
|
+
content = 'Previous';
|
126
|
+
if (page.disabled) {
|
127
|
+
Object.assign(props, { as: 'span', 'aria-disabled': 'true' });
|
128
|
+
}
|
129
|
+
else {
|
130
|
+
Object.assign(props, {
|
131
|
+
rel: 'prev',
|
132
|
+
href: hrefBuilder(page.num),
|
133
|
+
'aria-label': 'Previous Page',
|
134
|
+
onClick
|
135
|
+
});
|
136
|
+
}
|
137
|
+
break;
|
138
|
+
}
|
139
|
+
case 'NEXT': {
|
140
|
+
key = 'page-next';
|
141
|
+
content = 'Next';
|
142
|
+
if (page.disabled) {
|
143
|
+
Object.assign(props, { as: 'span', 'aria-disabled': 'true' });
|
144
|
+
}
|
145
|
+
else {
|
146
|
+
Object.assign(props, {
|
147
|
+
rel: 'next',
|
148
|
+
href: hrefBuilder(page.num),
|
149
|
+
'aria-label': 'Next Page',
|
150
|
+
onClick
|
151
|
+
});
|
152
|
+
}
|
153
|
+
break;
|
154
|
+
}
|
155
|
+
case 'NUM': {
|
156
|
+
key = `page-${page.num}`;
|
157
|
+
content = String(page.num);
|
158
|
+
if (page.selected) {
|
159
|
+
Object.assign(props, { as: 'em', 'aria-current': 'page' });
|
160
|
+
}
|
161
|
+
else {
|
162
|
+
Object.assign(props, { href: hrefBuilder(page.num), 'aria-label': `Page ${page.num}`, onClick });
|
163
|
+
}
|
164
|
+
break;
|
165
|
+
}
|
166
|
+
case 'BREAK': {
|
167
|
+
key = `page-${page.num}-break`;
|
168
|
+
content = '…';
|
169
|
+
Object.assign(props, { as: 'span', 'aria-disabled': true });
|
170
|
+
}
|
171
|
+
}
|
172
|
+
return { props, key, content };
|
173
|
+
}
|
174
|
+
exports.buildComponentData = buildComponentData;
|
@@ -0,0 +1,25 @@
|
|
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 BorderBox_1 = __importDefault(require("./BorderBox"));
|
8
|
+
const Caret_1 = __importDefault(require("./Caret"));
|
9
|
+
function PointerBox(props) {
|
10
|
+
// don't destructure these, just grab them
|
11
|
+
const { bg, border, borderColor, theme } = props;
|
12
|
+
const { caret, children, ...boxProps } = props;
|
13
|
+
const caretProps = {
|
14
|
+
bg,
|
15
|
+
borderColor,
|
16
|
+
borderWidth: border,
|
17
|
+
location: caret,
|
18
|
+
theme
|
19
|
+
};
|
20
|
+
return (<BorderBox_1.default sx={{ position: 'relative' }} {...boxProps}>
|
21
|
+
{children}
|
22
|
+
<Caret_1.default {...caretProps}/>
|
23
|
+
</BorderBox_1.default>);
|
24
|
+
}
|
25
|
+
exports.default = PointerBox;
|
package/lib/Popover.d.ts
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
/// <reference types="hoist-non-react-statics" />
|
2
|
+
import { SystemCommonProps, SystemLayoutProps, SystemPositionProps } from './constants';
|
2
3
|
import { SxProp } from './sx';
|
3
4
|
import { ComponentProps } from './utils/types';
|
4
5
|
declare type CaretPosition = 'top' | 'bottom' | 'left' | 'right' | 'bottom-left' | 'bottom-right' | 'top-left' | 'top-right' | 'left-bottom' | 'left-top' | 'right-bottom' | 'right-top';
|
@@ -6,15 +7,15 @@ declare const Popover: import("styled-components").StyledComponent<"div", any, {
|
|
6
7
|
caret?: CaretPosition | undefined;
|
7
8
|
relative?: boolean | undefined;
|
8
9
|
open?: boolean | undefined;
|
9
|
-
} & SxProp, never>;
|
10
|
-
declare const PopoverContent: import("styled-components").StyledComponent<"div", any, SxProp, never>;
|
10
|
+
} & SystemCommonProps & SystemLayoutProps & SystemPositionProps & SxProp, never>;
|
11
|
+
declare const PopoverContent: import("styled-components").StyledComponent<"div", any, import("styled-system").SpaceProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, string | number | symbol> & import("styled-system").ColorProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, string | number | symbol> & import("styled-system").TypographyProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & import("styled-system").LayoutProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & import("styled-system").FlexboxProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & import("styled-system").GridProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & import("styled-system").BackgroundProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, import("csstype").Property.Background<import("styled-system").TLengthStyledSystem>> & import("styled-system").BorderProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, import("csstype").Property.Border<import("styled-system").TLengthStyledSystem>> & import("styled-system").PositionProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & import("styled-system").ShadowProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & SxProp, never>;
|
11
12
|
export declare type PopoverProps = ComponentProps<typeof Popover>;
|
12
13
|
export declare type PopoverContentProps = ComponentProps<typeof PopoverContent>;
|
13
14
|
declare const _default: string & import("styled-components").StyledComponentBase<"div", any, {
|
14
15
|
caret?: CaretPosition | undefined;
|
15
16
|
relative?: boolean | undefined;
|
16
17
|
open?: boolean | undefined;
|
17
|
-
} & SxProp, never> & import("hoist-non-react-statics").NonReactStatics<never, {}> & {
|
18
|
-
Content: import("styled-components").StyledComponent<"div", any, SxProp, never>;
|
18
|
+
} & SystemCommonProps & SystemLayoutProps & SystemPositionProps & SxProp, never> & import("hoist-non-react-statics").NonReactStatics<never, {}> & {
|
19
|
+
Content: import("styled-components").StyledComponent<"div", any, import("styled-system").SpaceProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, string | number | symbol> & import("styled-system").ColorProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, string | number | symbol> & import("styled-system").TypographyProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & import("styled-system").LayoutProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & import("styled-system").FlexboxProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & import("styled-system").GridProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & import("styled-system").BackgroundProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, import("csstype").Property.Background<import("styled-system").TLengthStyledSystem>> & import("styled-system").BorderProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, import("csstype").Property.Border<import("styled-system").TLengthStyledSystem>> & import("styled-system").PositionProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & import("styled-system").ShadowProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & SxProp, never>;
|
19
20
|
};
|
20
21
|
export default _default;
|
package/lib/Popover.js
CHANGED
@@ -9,6 +9,8 @@ var _classnames = _interopRequireDefault(require("classnames"));
|
|
9
9
|
|
10
10
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
11
11
|
|
12
|
+
var _Box = _interopRequireDefault(require("./Box"));
|
13
|
+
|
12
14
|
var _constants = require("./constants");
|
13
15
|
|
14
16
|
var _sx = _interopRequireDefault(require("./sx"));
|
@@ -25,13 +27,12 @@ const Popover = _styledComponents.default.div.attrs(({
|
|
25
27
|
}).withConfig({
|
26
28
|
displayName: "Popover",
|
27
29
|
componentId: "sc-1nxygy2-0"
|
28
|
-
})(["position:", ";z-index:100;display:", ";", ";"], props => props.relative ? 'relative' : 'absolute', props => props.open ? 'block' : 'none', _sx.default);
|
30
|
+
})(["position:", ";z-index:100;display:", ";", ";", ";", ";", ";"], props => props.relative ? 'relative' : 'absolute', props => props.open ? 'block' : 'none', _constants.COMMON, _constants.LAYOUT, _constants.POSITION, _sx.default);
|
29
31
|
|
30
|
-
const PopoverContent = _styledComponents.default.
|
32
|
+
const PopoverContent = (0, _styledComponents.default)(_Box.default).withConfig({
|
31
33
|
displayName: "Popover__PopoverContent",
|
32
34
|
componentId: "sc-1nxygy2-1"
|
33
|
-
})(["border:1px solid ", ";border-radius:", ";position:relative;width:232px;margin-right:auto;margin-left:auto;padding:", ";background-color:", ";&::before,&::after{position:absolute;left:50%;display:inline-block;content:'';}&::before{top:-", ";margin-left:-9px;border:", " solid transparent;border-bottom-color:", ";}&::after{top:-14px;margin-left:-", ";border:7px solid transparent;border-bottom-color:", ";}", ".caret-pos--bottom &,", ".caret-pos--bottom-right &,", ".caret-pos--bottom-left &{&::before,&::after{top:auto;border-bottom-color:transparent;}&::before{bottom:-", ";border-top-color:", ";}&::after{bottom:-14px;border-top-color:", ";}}", ".caret-pos--top-right &,", ".caret-pos--bottom-right &{right:-9px;margin-right:0;&::before,&::after{left:auto;margin-left:0;}&::before{right:20px;}&::after{right:21px;}}", ".caret-pos--top-left &,", ".caret-pos--bottom-left &{left:-9px;margin-left:0;&::before,&::after{left:", ";margin-left:0;}&::after{left:calc(", " + 1px);}}", ".caret-pos--right &,", ".caret-pos--right-top &,", ".caret-pos--right-bottom &,", ".caret-pos--left &,", ".caret-pos--left-top &,", ".caret-pos--left-bottom &{&::before,&::after{top:50%;left:auto;margin-left:0;border-bottom-color:transparent;}&::before{margin-top:calc((", " + 1px) * -1);}&::after{margin-top:-", ";}}", ".caret-pos--right &,", ".caret-pos--right-top &,", ".caret-pos--right-bottom &{&::before{right:-", ";border-left-color:", ";}&::after{right:-14px;border-left-color:", ";}}", ".caret-pos--left &,", ".caret-pos--left-top &,", ".caret-pos--left-bottom &{&::before{left:-", ";border-right-color:", ";}&::after{left:-14px;border-right-color:", ";}}", ".caret-pos--right-top &,", ".caret-pos--left-top &{&::before,&::after{top:", ";}}", ".caret-pos--right-bottom &,", ".caret-pos--left-bottom &{&::before,&::after{top:auto;}&::before{bottom:", ";}&::after{bottom:calc(", " + 1px);}}", ";"], (0, _constants.get)('colors.border.default'), (0, _constants.get)('radii.2'), (0, _constants.get)('space.4'), (0, _constants.get)('colors.canvas.overlay'), (0, _constants.get)('space.3'), (0, _constants.get)('space.2'), (0, _constants.get)('colors.border.default'), (0, _constants.get)('space.2'), (0, _constants.get)('colors.canvas.overlay'), Popover, Popover, Popover, (0, _constants.get)('space.3'), (0, _constants.get)('colors.border.default'), (0, _constants.get)('colors.canvas.overlay'), Popover, Popover, Popover, Popover, (0, _constants.get)('space.4'), (0, _constants.get)('space.4'), Popover, Popover, Popover, Popover, Popover, Popover, (0, _constants.get)('space.2'), (0, _constants.get)('space.2'), Popover, Popover, Popover, (0, _constants.get)('space.3'), (0, _constants.get)('colors.border.default'), (0, _constants.get)('colors.canvas.overlay'), Popover, Popover, Popover, (0, _constants.get)('space.3'), (0, _constants.get)('colors.border.default'), (0, _constants.get)('colors.canvas.overlay'), Popover, Popover, (0, _constants.get)('space.4'), Popover, Popover, (0, _constants.get)('space.3'), (0, _constants.get)('space.3'), _sx.default);
|
34
|
-
|
35
|
+
})(["border:1px solid ", ";border-radius:", ";position:relative;width:232px;margin-right:auto;margin-left:auto;padding:", ";background-color:", ";", ";", ";&::before,&::after{position:absolute;left:50%;display:inline-block;content:'';}&::before{top:-", ";margin-left:-9px;border:", " solid transparent;border-bottom-color:", ";}&::after{top:-14px;margin-left:-", ";border:7px solid transparent;border-bottom-color:", ";}", ".caret-pos--bottom &,", ".caret-pos--bottom-right &,", ".caret-pos--bottom-left &{&::before,&::after{top:auto;border-bottom-color:transparent;}&::before{bottom:-", ";border-top-color:", ";}&::after{bottom:-14px;border-top-color:", ";}}", ".caret-pos--top-right &,", ".caret-pos--bottom-right &{right:-9px;margin-right:0;&::before,&::after{left:auto;margin-left:0;}&::before{right:20px;}&::after{right:21px;}}", ".caret-pos--top-left &,", ".caret-pos--bottom-left &{left:-9px;margin-left:0;&::before,&::after{left:", ";margin-left:0;}&::after{left:calc(", " + 1px);}}", ".caret-pos--right &,", ".caret-pos--right-top &,", ".caret-pos--right-bottom &,", ".caret-pos--left &,", ".caret-pos--left-top &,", ".caret-pos--left-bottom &{&::before,&::after{top:50%;left:auto;margin-left:0;border-bottom-color:transparent;}&::before{margin-top:calc((", " + 1px) * -1);}&::after{margin-top:-", ";}}", ".caret-pos--right &,", ".caret-pos--right-top &,", ".caret-pos--right-bottom &{&::before{right:-", ";border-left-color:", ";}&::after{right:-14px;border-left-color:", ";}}", ".caret-pos--left &,", ".caret-pos--left-top &,", ".caret-pos--left-bottom &{&::before{left:-", ";border-right-color:", ";}&::after{left:-14px;border-right-color:", ";}}", ".caret-pos--right-top &,", ".caret-pos--left-top &{&::before,&::after{top:", ";}}", ".caret-pos--right-bottom &,", ".caret-pos--left-bottom &{&::before,&::after{top:auto;}&::before{bottom:", ";}&::after{bottom:calc(", " + 1px);}}", ";"], (0, _constants.get)('colors.border.default'), (0, _constants.get)('radii.2'), (0, _constants.get)('space.4'), (0, _constants.get)('colors.canvas.overlay'), _constants.COMMON, _constants.LAYOUT, (0, _constants.get)('space.3'), (0, _constants.get)('space.2'), (0, _constants.get)('colors.border.default'), (0, _constants.get)('space.2'), (0, _constants.get)('colors.canvas.overlay'), Popover, Popover, Popover, (0, _constants.get)('space.3'), (0, _constants.get)('colors.border.default'), (0, _constants.get)('colors.canvas.overlay'), Popover, Popover, Popover, Popover, (0, _constants.get)('space.4'), (0, _constants.get)('space.4'), Popover, Popover, Popover, Popover, Popover, Popover, (0, _constants.get)('space.2'), (0, _constants.get)('space.2'), Popover, Popover, Popover, (0, _constants.get)('space.3'), (0, _constants.get)('colors.border.default'), (0, _constants.get)('colors.canvas.overlay'), Popover, Popover, Popover, (0, _constants.get)('space.3'), (0, _constants.get)('colors.border.default'), (0, _constants.get)('colors.canvas.overlay'), Popover, Popover, (0, _constants.get)('space.4'), Popover, Popover, (0, _constants.get)('space.3'), (0, _constants.get)('space.3'), _sx.default);
|
35
36
|
Popover.defaultProps = {
|
36
37
|
caret: 'top'
|
37
38
|
};
|
package/lib/Popover.jsx
ADDED
@@ -0,0 +1,210 @@
|
|
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 classnames_1 = __importDefault(require("classnames"));
|
7
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
8
|
+
const Box_1 = __importDefault(require("./Box"));
|
9
|
+
const constants_1 = require("./constants");
|
10
|
+
const sx_1 = __importDefault(require("./sx"));
|
11
|
+
const Popover = styled_components_1.default.div.attrs(({ className, caret }) => {
|
12
|
+
return {
|
13
|
+
className: classnames_1.default(className, `caret-pos--${caret}`)
|
14
|
+
};
|
15
|
+
}) `
|
16
|
+
position: ${props => (props.relative ? 'relative' : 'absolute')};
|
17
|
+
z-index: 100;
|
18
|
+
display: ${props => (props.open ? 'block' : 'none')};
|
19
|
+
|
20
|
+
${constants_1.COMMON};
|
21
|
+
${constants_1.LAYOUT};
|
22
|
+
${constants_1.POSITION};
|
23
|
+
${sx_1.default};
|
24
|
+
`;
|
25
|
+
const PopoverContent = styled_components_1.default(Box_1.default) `
|
26
|
+
border: 1px solid ${constants_1.get('colors.border.default')};
|
27
|
+
border-radius: ${constants_1.get('radii.2')};
|
28
|
+
position: relative;
|
29
|
+
width: 232px;
|
30
|
+
margin-right: auto;
|
31
|
+
margin-left: auto;
|
32
|
+
padding: ${constants_1.get('space.4')};
|
33
|
+
background-color: ${constants_1.get('colors.canvas.overlay')};
|
34
|
+
|
35
|
+
${constants_1.COMMON};
|
36
|
+
${constants_1.LAYOUT};
|
37
|
+
|
38
|
+
// Carets
|
39
|
+
&::before,
|
40
|
+
&::after {
|
41
|
+
position: absolute;
|
42
|
+
left: 50%;
|
43
|
+
display: inline-block;
|
44
|
+
content: '';
|
45
|
+
}
|
46
|
+
|
47
|
+
&::before {
|
48
|
+
top: -${constants_1.get('space.3')};
|
49
|
+
margin-left: -9px;
|
50
|
+
border: ${constants_1.get('space.2')} solid transparent; // TODO: solid?
|
51
|
+
border-bottom-color: ${constants_1.get('colors.border.default')};
|
52
|
+
}
|
53
|
+
|
54
|
+
&::after {
|
55
|
+
top: -14px;
|
56
|
+
margin-left: -${constants_1.get('space.2')};
|
57
|
+
border: 7px solid transparent; // todo: solid
|
58
|
+
border-bottom-color: ${constants_1.get('colors.canvas.overlay')};
|
59
|
+
}
|
60
|
+
|
61
|
+
// Bottom-oriented carets
|
62
|
+
${Popover}.caret-pos--bottom & ,
|
63
|
+
${Popover}.caret-pos--bottom-right & ,
|
64
|
+
${Popover}.caret-pos--bottom-left & {
|
65
|
+
&::before,
|
66
|
+
&::after {
|
67
|
+
top: auto;
|
68
|
+
border-bottom-color: transparent;
|
69
|
+
}
|
70
|
+
|
71
|
+
&::before {
|
72
|
+
bottom: -${constants_1.get('space.3')};
|
73
|
+
border-top-color: ${constants_1.get('colors.border.default')};
|
74
|
+
}
|
75
|
+
|
76
|
+
&::after {
|
77
|
+
bottom: -14px;
|
78
|
+
// stylelint-disable-next-line primer/borders
|
79
|
+
border-top-color: ${constants_1.get('colors.canvas.overlay')};
|
80
|
+
}
|
81
|
+
}
|
82
|
+
|
83
|
+
// Top & Bottom: Right-oriented carets
|
84
|
+
${Popover}.caret-pos--top-right & ,
|
85
|
+
${Popover}.caret-pos--bottom-right & {
|
86
|
+
right: -9px;
|
87
|
+
margin-right: 0;
|
88
|
+
|
89
|
+
&::before,
|
90
|
+
&::after {
|
91
|
+
left: auto;
|
92
|
+
margin-left: 0;
|
93
|
+
}
|
94
|
+
|
95
|
+
&::before {
|
96
|
+
right: 20px;
|
97
|
+
}
|
98
|
+
|
99
|
+
&::after {
|
100
|
+
right: 21px;
|
101
|
+
}
|
102
|
+
}
|
103
|
+
|
104
|
+
// Top & Bottom: Left-oriented carets
|
105
|
+
${Popover}.caret-pos--top-left & ,
|
106
|
+
${Popover}.caret-pos--bottom-left & {
|
107
|
+
left: -9px;
|
108
|
+
margin-left: 0;
|
109
|
+
|
110
|
+
&::before,
|
111
|
+
&::after {
|
112
|
+
left: ${constants_1.get('space.4')};
|
113
|
+
margin-left: 0;
|
114
|
+
}
|
115
|
+
|
116
|
+
&::after {
|
117
|
+
left: calc(${constants_1.get('space.4')} + 1px);
|
118
|
+
}
|
119
|
+
}
|
120
|
+
|
121
|
+
// Right- & Left-oriented carets
|
122
|
+
${Popover}.caret-pos--right & ,
|
123
|
+
${Popover}.caret-pos--right-top & ,
|
124
|
+
${Popover}.caret-pos--right-bottom & ,
|
125
|
+
${Popover}.caret-pos--left & ,
|
126
|
+
${Popover}.caret-pos--left-top & ,
|
127
|
+
${Popover}.caret-pos--left-bottom & {
|
128
|
+
&::before,
|
129
|
+
&::after {
|
130
|
+
top: 50%;
|
131
|
+
left: auto;
|
132
|
+
margin-left: 0;
|
133
|
+
border-bottom-color: transparent;
|
134
|
+
}
|
135
|
+
|
136
|
+
&::before {
|
137
|
+
// stylelint-disable-next-line primer/spacing
|
138
|
+
margin-top: calc((${constants_1.get('space.2')} + 1px) * -1);
|
139
|
+
}
|
140
|
+
|
141
|
+
&::after {
|
142
|
+
margin-top: -${constants_1.get('space.2')};
|
143
|
+
}
|
144
|
+
}
|
145
|
+
|
146
|
+
// Right-oriented carets
|
147
|
+
${Popover}.caret-pos--right & ,
|
148
|
+
${Popover}.caret-pos--right-top & ,
|
149
|
+
${Popover}.caret-pos--right-bottom & {
|
150
|
+
&::before {
|
151
|
+
right: -${constants_1.get('space.3')};
|
152
|
+
border-left-color: ${constants_1.get('colors.border.default')};
|
153
|
+
}
|
154
|
+
|
155
|
+
&::after {
|
156
|
+
right: -14px;
|
157
|
+
// stylelint-disable-next-line primer/borders
|
158
|
+
border-left-color: ${constants_1.get('colors.canvas.overlay')};
|
159
|
+
}
|
160
|
+
}
|
161
|
+
|
162
|
+
// Left-oriented carets
|
163
|
+
${Popover}.caret-pos--left & ,
|
164
|
+
${Popover}.caret-pos--left-top & ,
|
165
|
+
${Popover}.caret-pos--left-bottom & {
|
166
|
+
&::before {
|
167
|
+
left: -${constants_1.get('space.3')};
|
168
|
+
border-right-color: ${constants_1.get('colors.border.default')};
|
169
|
+
}
|
170
|
+
|
171
|
+
&::after {
|
172
|
+
left: -14px;
|
173
|
+
// stylelint-disable-next-line primer/borders
|
174
|
+
border-right-color: ${constants_1.get('colors.canvas.overlay')};
|
175
|
+
}
|
176
|
+
}
|
177
|
+
|
178
|
+
// Right & Left: Top-oriented carets
|
179
|
+
${Popover}.caret-pos--right-top & ,
|
180
|
+
${Popover}.caret-pos--left-top & {
|
181
|
+
&::before,
|
182
|
+
&::after {
|
183
|
+
top: ${constants_1.get('space.4')};
|
184
|
+
}
|
185
|
+
}
|
186
|
+
|
187
|
+
// Right & Left: Bottom-oriented carets
|
188
|
+
${Popover}.caret-pos--right-bottom & ,
|
189
|
+
${Popover}.caret-pos--left-bottom & {
|
190
|
+
&::before,
|
191
|
+
&::after {
|
192
|
+
top: auto;
|
193
|
+
}
|
194
|
+
|
195
|
+
&::before {
|
196
|
+
bottom: ${constants_1.get('space.3')};
|
197
|
+
}
|
198
|
+
|
199
|
+
&::after {
|
200
|
+
bottom: calc(${constants_1.get('space.3')} + 1px);
|
201
|
+
}
|
202
|
+
}
|
203
|
+
|
204
|
+
${sx_1.default};
|
205
|
+
`;
|
206
|
+
Popover.defaultProps = {
|
207
|
+
caret: 'top'
|
208
|
+
};
|
209
|
+
PopoverContent.displayName = 'Popover.Content';
|
210
|
+
exports.default = Object.assign(Popover, { Content: PopoverContent });
|
@@ -0,0 +1,79 @@
|
|
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
|
+
exports.Portal = exports.registerPortalRoot = void 0;
|
7
|
+
const react_1 = __importDefault(require("react"));
|
8
|
+
const react_dom_1 = require("react-dom");
|
9
|
+
const useIsomorphicLayoutEffect_1 = __importDefault(require("../utils/useIsomorphicLayoutEffect"));
|
10
|
+
const PRIMER_PORTAL_ROOT_ID = '__primerPortalRoot__';
|
11
|
+
const DEFAULT_PORTAL_CONTAINER_NAME = '__default__';
|
12
|
+
const portalRootRegistry = {};
|
13
|
+
/**
|
14
|
+
* Register a container to serve as a portal root.
|
15
|
+
* @param root The element that will be the root for portals created in this container
|
16
|
+
* @param name The name of the container, to be used with the `containerName` prop on the Portal Component.
|
17
|
+
* If name is not specified, registers the default portal root.
|
18
|
+
*/
|
19
|
+
function registerPortalRoot(root, name = DEFAULT_PORTAL_CONTAINER_NAME) {
|
20
|
+
portalRootRegistry[name] = root;
|
21
|
+
}
|
22
|
+
exports.registerPortalRoot = registerPortalRoot;
|
23
|
+
// Ensures that a default portal root exists and is registered. If a DOM element exists
|
24
|
+
// with id __primerPortalRoot__, allow that element to serve as the default portal root.
|
25
|
+
// Otherwise, create that element and attach it to the end of document.body.
|
26
|
+
function ensureDefaultPortal() {
|
27
|
+
const existingDefaultPortalContainer = portalRootRegistry[DEFAULT_PORTAL_CONTAINER_NAME];
|
28
|
+
if (!existingDefaultPortalContainer || !document.body.contains(existingDefaultPortalContainer)) {
|
29
|
+
let defaultPortalContainer = document.getElementById(PRIMER_PORTAL_ROOT_ID);
|
30
|
+
if (!(defaultPortalContainer instanceof Element)) {
|
31
|
+
defaultPortalContainer = document.createElement('div');
|
32
|
+
defaultPortalContainer.setAttribute('id', PRIMER_PORTAL_ROOT_ID);
|
33
|
+
defaultPortalContainer.style.position = 'absolute';
|
34
|
+
defaultPortalContainer.style.top = '0';
|
35
|
+
defaultPortalContainer.style.left = '0';
|
36
|
+
const suitablePortalRoot = document.querySelector('[data-portal-root]');
|
37
|
+
if (suitablePortalRoot) {
|
38
|
+
suitablePortalRoot.appendChild(defaultPortalContainer);
|
39
|
+
}
|
40
|
+
else {
|
41
|
+
document.body.appendChild(defaultPortalContainer);
|
42
|
+
}
|
43
|
+
}
|
44
|
+
registerPortalRoot(defaultPortalContainer);
|
45
|
+
}
|
46
|
+
}
|
47
|
+
/**
|
48
|
+
* Creates a React Portal, placing all children in a separate physical DOM root node.
|
49
|
+
* @see https://reactjs.org/docs/portals.html
|
50
|
+
*/
|
51
|
+
const Portal = ({ children, onMount, containerName: _containerName }) => {
|
52
|
+
const hostElement = document.createElement('div');
|
53
|
+
// Portaled content should get their own stacking context so they don't interfere
|
54
|
+
// with each other in unexpected ways. One should never find themselves tempted
|
55
|
+
// to change the zIndex to a value other than "1".
|
56
|
+
hostElement.style.position = 'relative';
|
57
|
+
hostElement.style.zIndex = '1';
|
58
|
+
const elementRef = react_1.default.useRef(hostElement);
|
59
|
+
useIsomorphicLayoutEffect_1.default(() => {
|
60
|
+
let containerName = _containerName;
|
61
|
+
if (containerName === undefined) {
|
62
|
+
containerName = DEFAULT_PORTAL_CONTAINER_NAME;
|
63
|
+
ensureDefaultPortal();
|
64
|
+
}
|
65
|
+
const parentElement = portalRootRegistry[containerName];
|
66
|
+
if (!parentElement) {
|
67
|
+
throw new Error(`Portal container '${_containerName}' is not yet registered. Container must be registered with registerPortal before use.`);
|
68
|
+
}
|
69
|
+
const element = elementRef.current;
|
70
|
+
parentElement.appendChild(element);
|
71
|
+
onMount?.();
|
72
|
+
return () => {
|
73
|
+
parentElement.removeChild(element);
|
74
|
+
};
|
75
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
76
|
+
}, [elementRef]);
|
77
|
+
return react_dom_1.createPortal(children, elementRef.current);
|
78
|
+
};
|
79
|
+
exports.Portal = Portal;
|
package/lib/Portal/index.js
CHANGED
@@ -1,17 +1,6 @@
|
|
1
1
|
"use strict";
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
});
|
6
|
-
|
7
|
-
enumerable: true,
|
8
|
-
get: function () {
|
9
|
-
return _Portal.registerPortalRoot;
|
10
|
-
}
|
11
|
-
});
|
12
|
-
exports.default = void 0;
|
13
|
-
|
14
|
-
var _Portal = require("./Portal");
|
15
|
-
|
16
|
-
var _default = _Portal.Portal;
|
17
|
-
exports.default = _default;
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.registerPortalRoot = void 0;
|
4
|
+
const Portal_1 = require("./Portal");
|
5
|
+
Object.defineProperty(exports, "registerPortalRoot", { enumerable: true, get: function () { return Portal_1.registerPortalRoot; } });
|
6
|
+
exports.default = Portal_1.Portal;
|