@primer/components 0.0.0-202110303104 → 0.0.0-2021103082237
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 +90 -4
- package/dist/browser.esm.js +738 -779
- package/dist/browser.esm.js.map +1 -1
- package/dist/browser.umd.js +736 -777
- package/dist/browser.umd.js.map +1 -1
- package/lib/ActionList/Item.js +27 -52
- 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/List.js +1 -2
- package/lib/ActionList2/index.js +41 -23
- package/lib/AnchoredOverlay/index.js +12 -4
- package/lib/Autocomplete/Autocomplete.d.ts +11 -3
- package/lib/Autocomplete/AutocompleteInput.d.ts +11 -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/Checkbox.d.ts +29 -0
- package/lib/Checkbox.js +64 -0
- 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 +14 -11
- 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 +29 -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/TextInput.d.ts +8 -1
- package/lib/TextInput.js +17 -5
- package/lib/TextInputWithTokens.d.ts +11 -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/_TextInputWrapper.d.ts +3 -0
- package/lib/_TextInputWrapper.js +18 -7
- 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.d.ts +2 -2
- package/lib/index.js +652 -165
- package/lib/polyfills/eventListenerSignal.js +45 -37
- 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 +28 -61
- package/lib/utils/testing.js +29 -0
- 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/ActionList/Item.js +28 -53
- 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/ActionList2/List.js +1 -2
- package/lib-esm/Autocomplete/Autocomplete.d.ts +11 -3
- package/lib-esm/Autocomplete/AutocompleteInput.d.ts +11 -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/Checkbox.d.ts +29 -0
- package/lib-esm/Checkbox.js +44 -0
- 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 +14 -11
- 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 +29 -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/TextInput.d.ts +8 -1
- package/lib-esm/TextInput.js +17 -5
- package/lib-esm/TextInputWithTokens.d.ts +11 -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/_TextInputWrapper.d.ts +3 -0
- package/lib-esm/_TextInputWrapper.js +18 -7
- package/lib-esm/index.d.ts +2 -2
- package/lib-esm/index.js +1 -1
- package/lib-esm/theme-preval.js +512 -366
- package/lib-esm/utils/testing.d.ts +28 -61
- package/lib-esm/utils/testing.js +24 -0
- package/package.json +5 -6
- 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 -311
- 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/EmojiPicker/EmojiPicker.d.ts +0 -15
- package/lib/EmojiPicker/EmojiPicker.js +0 -205
- package/lib/EmojiPicker/EmojiPicker.jsx +0 -125
- package/lib/EmojiPicker/EmojiPickerAnchor.d.ts +0 -0
- package/lib/EmojiPicker/EmojiPickerAnchor.js +0 -1
- package/lib/EmojiPicker/EmojiPickerAnchor.jsx +0 -1
- package/lib/EmojiPicker/EmojiPickerPanel.d.ts +0 -3
- package/lib/EmojiPicker/EmojiPickerPanel.js +0 -18
- package/lib/EmojiPicker/EmojiPickerPanel.jsx +0 -10
- package/lib/EmojiPicker/data.d.ts +0 -9
- package/lib/EmojiPicker/data.js +0 -7254
- package/lib/EmojiPicker/index.d.ts +0 -2
- package/lib/EmojiPicker/index.js +0 -8
- 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/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/lib-esm/EmojiPicker/EmojiPicker.d.ts +0 -15
- package/lib-esm/EmojiPicker/EmojiPicker.js +0 -184
- package/lib-esm/EmojiPicker/EmojiPickerAnchor.d.ts +0 -0
- package/lib-esm/EmojiPicker/EmojiPickerAnchor.js +0 -0
- package/lib-esm/EmojiPicker/EmojiPickerPanel.d.ts +0 -3
- package/lib-esm/EmojiPicker/EmojiPickerPanel.js +0 -8
- package/lib-esm/EmojiPicker/data.d.ts +0 -9
- package/lib-esm/EmojiPicker/data.js +0 -5434
- package/lib-esm/EmojiPicker/index.d.ts +0 -2
- package/lib-esm/EmojiPicker/index.js +0 -1
@@ -53,7 +53,7 @@ export declare function render(component: React.ReactElement, theme?: {
|
|
53
53
|
xlarge: string;
|
54
54
|
};
|
55
55
|
space: string[];
|
56
|
-
colorSchemes: Record<"light" | "light_colorblind" | "dark" | "dark_dimmed" | "dark_high_contrast" | "dark_colorblind", Record<"colors" | "shadows", Partial<{
|
56
|
+
colorSchemes: Record<"light" | "light_high_contrast" | "light_colorblind" | "dark" | "dark_dimmed" | "dark_high_contrast" | "dark_colorblind", Record<"colors" | "shadows", Partial<{
|
57
57
|
canvasDefaultTransparent: string;
|
58
58
|
marketingIcon: {
|
59
59
|
primary: string;
|
@@ -88,6 +88,17 @@ export declare function render(component: React.ReactElement, theme?: {
|
|
88
88
|
additionBg: string;
|
89
89
|
};
|
90
90
|
searchKeyword: {
|
91
|
+
/**
|
92
|
+
* Render the component (a React.createElement() or JSX expression)
|
93
|
+
* into its intermediate object representation with 'type',
|
94
|
+
* 'props', and 'children' keys
|
95
|
+
*
|
96
|
+
* The returned object can be matched with expect().toEqual(), e.g.
|
97
|
+
*
|
98
|
+
* ```js
|
99
|
+
* expect(render(<Foo />)).toEqual(render(<div foo='bar' />))
|
100
|
+
* ```
|
101
|
+
*/
|
91
102
|
hl: string;
|
92
103
|
};
|
93
104
|
prettylights: {
|
@@ -108,6 +119,15 @@ export declare function render(component: React.ReactElement, theme?: {
|
|
108
119
|
stringRegexp: string;
|
109
120
|
markupList: string;
|
110
121
|
markupHeading: string;
|
122
|
+
/**
|
123
|
+
* Get the HTML class names rendered by the component instance
|
124
|
+
* as an array.
|
125
|
+
*
|
126
|
+
* ```js
|
127
|
+
* expect(renderClasses(<div className='a b' />))
|
128
|
+
* .toEqual(['a', 'b'])
|
129
|
+
* ```
|
130
|
+
*/
|
111
131
|
markupItalic: string;
|
112
132
|
markupBold: string;
|
113
133
|
markupDeletedText: string;
|
@@ -231,67 +251,13 @@ export declare function render(component: React.ReactElement, theme?: {
|
|
231
251
|
gradientOut: string;
|
232
252
|
};
|
233
253
|
mktg: {
|
234
|
-
success: string;
|
235
|
-
info: string;
|
236
|
-
bgShadeGradient: {
|
237
|
-
top: string;
|
238
|
-
bottom: string;
|
239
|
-
};
|
240
254
|
btn: {
|
241
|
-
bg:
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
bottom: string;
|
248
|
-
};
|
249
|
-
text: string;
|
250
|
-
primary: {
|
251
|
-
bg: {
|
252
|
-
top: string;
|
253
|
-
bottom: string;
|
254
|
-
};
|
255
|
-
bgOverlay: {
|
256
|
-
top: string;
|
257
|
-
bottom: string;
|
258
|
-
};
|
259
|
-
text: string;
|
260
|
-
};
|
261
|
-
enterprise: {
|
262
|
-
bg: {
|
263
|
-
top: string;
|
264
|
-
bottom: string;
|
265
|
-
};
|
266
|
-
bgOverlay: {
|
267
|
-
top: string;
|
268
|
-
bottom: string;
|
269
|
-
};
|
270
|
-
text: string;
|
271
|
-
};
|
272
|
-
outline: {
|
273
|
-
text: string;
|
274
|
-
border: string;
|
275
|
-
hover: {
|
276
|
-
text: string;
|
277
|
-
border: string;
|
278
|
-
};
|
279
|
-
focus: {
|
280
|
-
border: string;
|
281
|
-
borderInset: string;
|
282
|
-
};
|
283
|
-
};
|
284
|
-
dark: {
|
285
|
-
text: string;
|
286
|
-
border: string;
|
287
|
-
hover: {
|
288
|
-
text: string;
|
289
|
-
border: string;
|
290
|
-
};
|
291
|
-
focus: {
|
292
|
-
border: string;
|
293
|
-
borderInset: string;
|
294
|
-
};
|
255
|
+
bg: string;
|
256
|
+
shadow: {
|
257
|
+
outline: string;
|
258
|
+
focus: string;
|
259
|
+
hover: string;
|
260
|
+
hoverMuted: string;
|
295
261
|
};
|
296
262
|
};
|
297
263
|
};
|
@@ -595,4 +561,5 @@ interface BehavesAsComponent {
|
|
595
561
|
}
|
596
562
|
export declare function behavesAsComponent({ Component, toRender, options }: BehavesAsComponent): void;
|
597
563
|
export declare function checkExports(path: string, exports: Record<any, any>): void;
|
564
|
+
export declare function checkStoriesForAxeViolations(name: string): void;
|
598
565
|
export {};
|
package/lib-esm/utils/testing.js
CHANGED
@@ -3,6 +3,8 @@ import { promisify } from 'util';
|
|
3
3
|
import renderer from 'react-test-renderer';
|
4
4
|
import enzyme from 'enzyme';
|
5
5
|
import Adapter from '@wojtekmaj/enzyme-adapter-react-17';
|
6
|
+
import { cleanup, render as HTMLRender } from '@testing-library/react';
|
7
|
+
import { axe, toHaveNoViolations } from 'jest-axe';
|
6
8
|
import { ThemeProvider } from '..';
|
7
9
|
import { default as defaultTheme } from '../theme';
|
8
10
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
@@ -219,4 +221,26 @@ export function checkExports(path, exports) {
|
|
219
221
|
|
220
222
|
expect(mod).toSetExports(exports);
|
221
223
|
});
|
224
|
+
}
|
225
|
+
expect.extend(toHaveNoViolations);
|
226
|
+
export function checkStoriesForAxeViolations(name) {
|
227
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
228
|
+
const stories = require(`../stories/${name}.stories`); // eslint-disable-next-line @typescript-eslint/no-unused-vars -- _meta
|
229
|
+
|
230
|
+
|
231
|
+
const {
|
232
|
+
default: _meta,
|
233
|
+
...Stories
|
234
|
+
} = stories;
|
235
|
+
Object.values(Stories).map(Story => {
|
236
|
+
if (typeof Story !== 'function') return;
|
237
|
+
it(`story {Story.storyName} should have no axe violations`, async () => {
|
238
|
+
const {
|
239
|
+
container
|
240
|
+
} = HTMLRender( /*#__PURE__*/React.createElement(Story, null));
|
241
|
+
const results = await axe(container);
|
242
|
+
expect(results).toHaveNoViolations();
|
243
|
+
cleanup();
|
244
|
+
});
|
245
|
+
});
|
222
246
|
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@primer/components",
|
3
|
-
"version": "0.0.0-
|
3
|
+
"version": "0.0.0-2021103082237",
|
4
4
|
"description": "Primer react components",
|
5
5
|
"main": "lib/index.js",
|
6
6
|
"module": "lib-esm/index.js",
|
@@ -20,8 +20,7 @@
|
|
20
20
|
"test": "jest",
|
21
21
|
"test:update": "npm run test -- --updateSnapshot",
|
22
22
|
"release": "npm run build && changeset publish",
|
23
|
-
"size": "size-limit"
|
24
|
-
"typecheck": "npx tsc --project tsconfig.json"
|
23
|
+
"size": "size-limit"
|
25
24
|
},
|
26
25
|
"repository": "primer/react",
|
27
26
|
"keywords": [
|
@@ -45,7 +44,7 @@
|
|
45
44
|
"license": "MIT",
|
46
45
|
"dependencies": {
|
47
46
|
"@primer/octicons-react": "^16.1.0",
|
48
|
-
"@primer/primitives": "
|
47
|
+
"@primer/primitives": "7.1.1",
|
49
48
|
"@radix-ui/react-polymorphic": "0.0.14",
|
50
49
|
"@react-aria/ssr": "3.1.0",
|
51
50
|
"@styled-system/css": "5.1.5",
|
@@ -88,7 +87,7 @@
|
|
88
87
|
"@testing-library/user-event": "13.1.9",
|
89
88
|
"@types/chroma-js": "2.1.3",
|
90
89
|
"@types/enzyme": "3.10.9",
|
91
|
-
"@types/jest": "
|
90
|
+
"@types/jest": "27.0.2",
|
92
91
|
"@types/jest-axe": "3.5.3",
|
93
92
|
"@types/lodash.isempty": "4.4.6",
|
94
93
|
"@types/lodash.isobject": "3.0.6",
|
@@ -114,7 +113,7 @@
|
|
114
113
|
"eslint-plugin-jsx-a11y": "6.4.1",
|
115
114
|
"eslint-plugin-mdx": "1.15.1",
|
116
115
|
"eslint-plugin-prettier": "3.4.0",
|
117
|
-
"eslint-plugin-primer-react": "0.
|
116
|
+
"eslint-plugin-primer-react": "0.7.0",
|
118
117
|
"eslint-plugin-react": "7.24.0",
|
119
118
|
"eslint-plugin-react-hooks": "4.2.0",
|
120
119
|
"jest": "27.0.4",
|
@@ -1,29 +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
|
-
exports.Divider = exports.StyledDivider = void 0;
|
7
|
-
const react_1 = __importDefault(require("react"));
|
8
|
-
const styled_components_1 = __importDefault(require("styled-components"));
|
9
|
-
const constants_1 = require("../constants");
|
10
|
-
exports.StyledDivider = styled_components_1.default.div `
|
11
|
-
height: 1px;
|
12
|
-
background: ${constants_1.get('colors.border.muted')};
|
13
|
-
margin-top: calc(${constants_1.get('space.2')} - 1px);
|
14
|
-
margin-bottom: ${constants_1.get('space.2')};
|
15
|
-
`;
|
16
|
-
/**
|
17
|
-
* Visually separates `Item`s or `Group`s in an `ActionList`.
|
18
|
-
*/
|
19
|
-
function Divider() {
|
20
|
-
return <exports.StyledDivider />;
|
21
|
-
}
|
22
|
-
exports.Divider = Divider;
|
23
|
-
/**
|
24
|
-
* `Divider` fulfills the `ItemPropsWithCustomRenderer` contract,
|
25
|
-
* so it can be used inline in an `ActionList`’s `items` prop.
|
26
|
-
* In other words, `items={[ActionList.Divider]}` is supported as a concise
|
27
|
-
* alternative to `items={[{renderItem: () => <ActionList.Divider />}]}`.
|
28
|
-
*/
|
29
|
-
Divider.renderItem = Divider;
|
package/lib/ActionList/Group.jsx
DELETED
@@ -1,23 +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
|
-
exports.Group = void 0;
|
7
|
-
const react_1 = __importDefault(require("react"));
|
8
|
-
const styled_components_1 = __importDefault(require("styled-components"));
|
9
|
-
const sx_1 = __importDefault(require("../sx"));
|
10
|
-
const Header_1 = require("./Header");
|
11
|
-
const StyledGroup = styled_components_1.default.div `
|
12
|
-
${sx_1.default}
|
13
|
-
`;
|
14
|
-
/**
|
15
|
-
* Collects related `Items` in an `ActionList`.
|
16
|
-
*/
|
17
|
-
function Group({ header, items, ...props }) {
|
18
|
-
return (<StyledGroup {...props}>
|
19
|
-
{header && <Header_1.Header {...header}/>}
|
20
|
-
{items}
|
21
|
-
</StyledGroup>);
|
22
|
-
}
|
23
|
-
exports.Group = Group;
|
@@ -1,66 +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
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
22
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
23
|
-
};
|
24
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
25
|
-
exports.Header = exports.StyledHeader = void 0;
|
26
|
-
const react_1 = __importDefault(require("react"));
|
27
|
-
const styled_components_1 = __importStar(require("styled-components"));
|
28
|
-
const constants_1 = require("../constants");
|
29
|
-
const sx_1 = __importDefault(require("../sx"));
|
30
|
-
exports.StyledHeader = styled_components_1.default.div `
|
31
|
-
{
|
32
|
-
/* 6px vertical padding + 20px line height = 32px total height
|
33
|
-
*
|
34
|
-
* TODO: When rem-based spacing on a 4px scale lands, replace
|
35
|
-
* hardcoded '6px' with 'calc((${constants_1.get('space.s32')} - ${constants_1.get('space.20')}) / 2)'.
|
36
|
-
*/
|
37
|
-
}
|
38
|
-
padding: 6px ${constants_1.get('space.3')};
|
39
|
-
font-size: ${constants_1.get('fontSizes.0')};
|
40
|
-
font-weight: ${constants_1.get('fontWeights.bold')};
|
41
|
-
color: ${constants_1.get('colors.fg.muted')};
|
42
|
-
|
43
|
-
${({ variant }) => variant === 'filled' &&
|
44
|
-
styled_components_1.css `
|
45
|
-
background: ${constants_1.get('colors.canvas.subtle')};
|
46
|
-
margin: ${constants_1.get('space.2')} 0;
|
47
|
-
border-top: 1px solid ${constants_1.get('colors.neutral.muted')};
|
48
|
-
border-bottom: 1px solid ${constants_1.get('colors.neutral.muted')};
|
49
|
-
|
50
|
-
&:first-child {
|
51
|
-
margin-top: 0;
|
52
|
-
}
|
53
|
-
`}
|
54
|
-
|
55
|
-
${sx_1.default}
|
56
|
-
`;
|
57
|
-
/**
|
58
|
-
* Displays the name and description of a `Group`.
|
59
|
-
*/
|
60
|
-
function Header({ variant = 'subtle', title, auxiliaryText, children: _children, ...props }) {
|
61
|
-
return (<exports.StyledHeader role="heading" variant={variant} {...props}>
|
62
|
-
{title}
|
63
|
-
{auxiliaryText && <span>{auxiliaryText}</span>}
|
64
|
-
</exports.StyledHeader>);
|
65
|
-
}
|
66
|
-
exports.Header = Header;
|
package/lib/ActionList/Item.jsx
DELETED
@@ -1,311 +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
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
22
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
23
|
-
};
|
24
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
25
|
-
exports.Item = exports.TextContainer = void 0;
|
26
|
-
const octicons_react_1 = require("@primer/octicons-react");
|
27
|
-
const react_1 = __importStar(require("react"));
|
28
|
-
const constants_1 = require("../constants");
|
29
|
-
const sx_1 = __importDefault(require("../sx"));
|
30
|
-
const Truncate_1 = __importDefault(require("../Truncate"));
|
31
|
-
const styled_components_1 = __importDefault(require("styled-components"));
|
32
|
-
const Header_1 = require("./Header");
|
33
|
-
const Divider_1 = require("./Divider");
|
34
|
-
const ThemeProvider_1 = require("../ThemeProvider");
|
35
|
-
const focusZone_1 = require("../behaviors/focusZone");
|
36
|
-
const ssr_1 = require("@react-aria/ssr");
|
37
|
-
/**
|
38
|
-
* These colors are not yet in our default theme. Need to remove this once they are added.
|
39
|
-
*/
|
40
|
-
const customItemThemes = {
|
41
|
-
default: {
|
42
|
-
hover: {
|
43
|
-
light: 'rgba(46, 77, 108, 0.06)',
|
44
|
-
dark: 'rgba(201, 206, 212, 0.12)',
|
45
|
-
dark_dimmed: 'rgba(201, 206, 212, 0.12)'
|
46
|
-
},
|
47
|
-
focus: {
|
48
|
-
light: 'rgba(54, 77, 100, 0.16)',
|
49
|
-
dark: 'rgba(201, 206, 212, 0.24)',
|
50
|
-
dark_dimmed: 'rgba(201, 206, 212, 0.24)'
|
51
|
-
}
|
52
|
-
},
|
53
|
-
danger: {
|
54
|
-
hover: {
|
55
|
-
light: 'rgba(234, 74, 90, 0.08)',
|
56
|
-
dark: 'rgba(248, 81, 73, 0.16)',
|
57
|
-
dark_dimmed: 'rgba(248, 81, 73, 0.16)'
|
58
|
-
},
|
59
|
-
focus: {
|
60
|
-
light: 'rgba(234, 74, 90, 0.14)',
|
61
|
-
dark: 'rgba(248, 81, 73, 0.24)',
|
62
|
-
dark_dimmed: 'rgba(248, 81, 73, 0.24)'
|
63
|
-
}
|
64
|
-
}
|
65
|
-
};
|
66
|
-
const getItemVariant = (variant = 'default', disabled) => {
|
67
|
-
if (disabled) {
|
68
|
-
return {
|
69
|
-
color: constants_1.get('colors.primer.fg.disabled'),
|
70
|
-
iconColor: constants_1.get('colors.primer.fg.disabled'),
|
71
|
-
annotationColor: constants_1.get('colors.primer.fg.disabled'),
|
72
|
-
hoverCursor: 'default'
|
73
|
-
};
|
74
|
-
}
|
75
|
-
switch (variant) {
|
76
|
-
case 'danger':
|
77
|
-
return {
|
78
|
-
color: constants_1.get('colors.danger.fg'),
|
79
|
-
iconColor: constants_1.get('colors.danger.fg'),
|
80
|
-
annotationColor: constants_1.get('colors.fg.muted'),
|
81
|
-
hoverCursor: 'pointer'
|
82
|
-
};
|
83
|
-
default:
|
84
|
-
return {
|
85
|
-
color: constants_1.get('colors.fg.default'),
|
86
|
-
iconColor: constants_1.get('colors.fg.muted'),
|
87
|
-
annotationColor: constants_1.get('colors.fg.muted'),
|
88
|
-
hoverCursor: 'pointer'
|
89
|
-
};
|
90
|
-
}
|
91
|
-
};
|
92
|
-
const DividedContent = styled_components_1.default.div `
|
93
|
-
display: flex;
|
94
|
-
min-width: 0;
|
95
|
-
|
96
|
-
/* Required for dividers */
|
97
|
-
position: relative;
|
98
|
-
flex-grow: 1;
|
99
|
-
`;
|
100
|
-
const MainContent = styled_components_1.default.div `
|
101
|
-
align-items: baseline;
|
102
|
-
display: flex;
|
103
|
-
min-width: 0;
|
104
|
-
flex-direction: var(--main-content-flex-direction);
|
105
|
-
flex-grow: 1;
|
106
|
-
`;
|
107
|
-
const StyledItem = styled_components_1.default.div `
|
108
|
-
/* 6px vertical padding + 20px line height = 32px total height
|
109
|
-
*
|
110
|
-
* TODO: When rem-based spacing on a 4px scale lands, replace
|
111
|
-
* hardcoded '6px' with 'calc((${constants_1.get('space.s32')} - ${constants_1.get('space.20')}) / 2)'.
|
112
|
-
*/
|
113
|
-
padding: 6px ${constants_1.get('space.2')};
|
114
|
-
display: flex;
|
115
|
-
border-radius: ${constants_1.get('radii.2')};
|
116
|
-
color: ${({ variant, item }) => getItemVariant(variant, item?.disabled).color};
|
117
|
-
// 2 frames on a 60hz monitor
|
118
|
-
transition: background 33.333ms linear;
|
119
|
-
text-decoration: none;
|
120
|
-
|
121
|
-
@media (hover: hover) and (pointer: fine) {
|
122
|
-
:hover {
|
123
|
-
// allow override in case another item in the list is active/focused
|
124
|
-
background: var(--item-hover-bg-override, ${({ hoverBackground }) => hoverBackground});
|
125
|
-
cursor: ${({ variant, item }) => getItemVariant(variant, item?.disabled).hoverCursor};
|
126
|
-
}
|
127
|
-
}
|
128
|
-
|
129
|
-
// Item dividers
|
130
|
-
:not(:first-of-type):not(${Divider_1.StyledDivider} + &):not(${Header_1.StyledHeader} + &) {
|
131
|
-
margin-top: ${({ showDivider }) => (showDivider ? `1px` : '0')};
|
132
|
-
|
133
|
-
${DividedContent}::before {
|
134
|
-
content: ' ';
|
135
|
-
display: block;
|
136
|
-
position: absolute;
|
137
|
-
width: 100%;
|
138
|
-
top: -7px;
|
139
|
-
// NB: This 'get' won’t execute if it’s moved into the arrow function below.
|
140
|
-
border: 0 solid ${constants_1.get('colors.border.muted')};
|
141
|
-
border-top-width: ${({ showDivider }) => (showDivider ? `1px` : '0')};
|
142
|
-
}
|
143
|
-
}
|
144
|
-
|
145
|
-
// Item dividers should not be visible:
|
146
|
-
// - above Hovered
|
147
|
-
&:hover ${DividedContent}::before,
|
148
|
-
// - below Hovered
|
149
|
-
// '*' instead of '&' because '&' maps to separate class names depending on 'variant'
|
150
|
-
:hover + * ${DividedContent}::before {
|
151
|
-
// allow override in case another item in the list is active/focused
|
152
|
-
border-color: var(--item-hover-divider-border-color-override, transparent) !important;
|
153
|
-
}
|
154
|
-
|
155
|
-
// - above Focused
|
156
|
-
&:focus ${DividedContent}::before,
|
157
|
-
// - below Focused
|
158
|
-
// '*' instead of '&' because '&' maps to separate class names depending on 'variant'
|
159
|
-
:focus + * ${DividedContent}::before,
|
160
|
-
// - above Active Descendent
|
161
|
-
&[${focusZone_1.isActiveDescendantAttribute}] ${DividedContent}::before,
|
162
|
-
// - below Active Descendent
|
163
|
-
[${focusZone_1.isActiveDescendantAttribute}] + & ${DividedContent}::before {
|
164
|
-
// '!important' because all the ':not's above give higher specificity
|
165
|
-
border-color: transparent !important;
|
166
|
-
}
|
167
|
-
|
168
|
-
// Active Descendant
|
169
|
-
&[${focusZone_1.isActiveDescendantAttribute}='${focusZone_1.activeDescendantActivatedDirectly}'] {
|
170
|
-
background: ${({ focusBackground }) => focusBackground};
|
171
|
-
}
|
172
|
-
&[${focusZone_1.isActiveDescendantAttribute}='${focusZone_1.activeDescendantActivatedIndirectly}'] {
|
173
|
-
background: ${({ hoverBackground }) => hoverBackground};
|
174
|
-
}
|
175
|
-
|
176
|
-
&:focus {
|
177
|
-
background: ${({ focusBackground }) => focusBackground};
|
178
|
-
outline: none;
|
179
|
-
}
|
180
|
-
|
181
|
-
&:active {
|
182
|
-
background: ${({ focusBackground }) => focusBackground};
|
183
|
-
}
|
184
|
-
|
185
|
-
${sx_1.default}
|
186
|
-
`;
|
187
|
-
exports.TextContainer = styled_components_1.default.span ``;
|
188
|
-
const BaseVisualContainer = styled_components_1.default.div `
|
189
|
-
// Match visual height to adjacent text line height.
|
190
|
-
// TODO: When rem-based spacing on a 4px scale lands, replace
|
191
|
-
// hardcoded '20px' with '${constants_1.get('space.s20')}'.
|
192
|
-
height: 20px;
|
193
|
-
width: ${constants_1.get('space.3')};
|
194
|
-
margin-right: ${constants_1.get('space.2')};
|
195
|
-
display: flex;
|
196
|
-
justify-content: center;
|
197
|
-
align-items: center;
|
198
|
-
`;
|
199
|
-
const ColoredVisualContainer = styled_components_1.default(BaseVisualContainer) `
|
200
|
-
svg {
|
201
|
-
fill: ${({ variant, disabled }) => getItemVariant(variant, disabled).iconColor};
|
202
|
-
font-size: ${constants_1.get('fontSizes.0')};
|
203
|
-
}
|
204
|
-
`;
|
205
|
-
const LeadingVisualContainer = styled_components_1.default(ColoredVisualContainer) `
|
206
|
-
flex-shrink: 0;
|
207
|
-
display: flex;
|
208
|
-
flex-direction: column;
|
209
|
-
justify-content: center;
|
210
|
-
`;
|
211
|
-
const TrailingContent = styled_components_1.default(ColoredVisualContainer) `
|
212
|
-
color: ${({ variant, disabled }) => getItemVariant(variant, disabled).annotationColor}};
|
213
|
-
margin-left: ${constants_1.get('space.2')};
|
214
|
-
margin-right: 0;
|
215
|
-
width: auto;
|
216
|
-
div:nth-child(2) {
|
217
|
-
margin-left: ${constants_1.get('space.2')};
|
218
|
-
}
|
219
|
-
`;
|
220
|
-
const DescriptionContainer = styled_components_1.default.span `
|
221
|
-
color: ${constants_1.get('colors.fg.muted')};
|
222
|
-
font-size: ${constants_1.get('fontSizes.0')};
|
223
|
-
// TODO: When rem-based spacing on a 4px scale lands, replace
|
224
|
-
// hardcoded '16px' with '${constants_1.get('lh-12')}'.
|
225
|
-
line-height: 16px;
|
226
|
-
margin-left: var(--description-container-margin-left);
|
227
|
-
min-width: 0;
|
228
|
-
flex-grow: 1;
|
229
|
-
flex-basis: var(--description-container-flex-basis);
|
230
|
-
`;
|
231
|
-
const MultiSelectIcon = styled_components_1.default.svg `
|
232
|
-
rect {
|
233
|
-
fill: ${({ selected }) => (selected ? constants_1.get('colors.accent.fg') : constants_1.get('colors.canvas.default'))};
|
234
|
-
stroke: ${({ selected }) => (selected ? constants_1.get('colors.accent.fg') : constants_1.get('colors.border.default'))};
|
235
|
-
}
|
236
|
-
path {
|
237
|
-
fill: ${constants_1.get('colors.fg.onEmphasis')};
|
238
|
-
boxshadow: ${constants_1.get('shadow.small')};
|
239
|
-
opacity: ${({ selected }) => (selected ? 1 : 0)};
|
240
|
-
}
|
241
|
-
`;
|
242
|
-
/**
|
243
|
-
* An actionable or selectable `Item` with an optional icon and description.
|
244
|
-
*/
|
245
|
-
exports.Item = react_1.default.forwardRef((itemProps, ref) => {
|
246
|
-
const { as: Component, text, description, descriptionVariant = 'inline', selected, selectionVariant, leadingVisual: LeadingVisual, trailingIcon: TrailingIcon, trailingVisual: TrailingVisual, trailingText, variant = 'default', showDivider, disabled, onAction, onKeyPress, children, onClick, id, ...props } = itemProps;
|
247
|
-
const labelId = ssr_1.useSSRSafeId();
|
248
|
-
const descriptionId = ssr_1.useSSRSafeId();
|
249
|
-
const keyPressHandler = react_1.useCallback(event => {
|
250
|
-
if (disabled) {
|
251
|
-
return;
|
252
|
-
}
|
253
|
-
onKeyPress?.(event);
|
254
|
-
if (!event.defaultPrevented && [' ', 'Enter'].includes(event.key)) {
|
255
|
-
onAction?.(itemProps, event);
|
256
|
-
}
|
257
|
-
}, [onAction, disabled, itemProps, onKeyPress]);
|
258
|
-
const clickHandler = react_1.useCallback(event => {
|
259
|
-
if (disabled) {
|
260
|
-
return;
|
261
|
-
}
|
262
|
-
onClick?.(event);
|
263
|
-
if (!event.defaultPrevented) {
|
264
|
-
onAction?.(itemProps, event);
|
265
|
-
}
|
266
|
-
}, [onAction, disabled, itemProps, onClick]);
|
267
|
-
const customItemTheme = customItemThemes[variant];
|
268
|
-
const hoverBackground = ThemeProvider_1.useColorSchemeVar(customItemTheme.hover, 'inherit');
|
269
|
-
const focusBackground = ThemeProvider_1.useColorSchemeVar(customItemTheme.focus, 'inherit');
|
270
|
-
const { theme } = ThemeProvider_1.useTheme();
|
271
|
-
return (<StyledItem ref={ref} as={Component} tabIndex={disabled ? undefined : -1} variant={variant} showDivider={showDivider} aria-selected={selected} aria-labelledby={text ? labelId : undefined} aria-describedby={description ? descriptionId : undefined} {...props} data-id={id} onKeyPress={keyPressHandler} onClick={clickHandler} hoverBackground={disabled ? 'inherit' : hoverBackground} focusBackground={disabled ? 'inherit' : focusBackground}>
|
272
|
-
{!!selected === selected && (<BaseVisualContainer>
|
273
|
-
{selectionVariant === 'multiple' ? (<>
|
274
|
-
{/**
|
275
|
-
* we use a svg instead of an input because there should not
|
276
|
-
* be an interactive element inside an option
|
277
|
-
* svg copied from primer/css
|
278
|
-
*/}
|
279
|
-
<MultiSelectIcon selected={selected} width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
|
280
|
-
<rect x="2" y="2" width="12" height="12" rx="4"></rect>
|
281
|
-
<path fillRule="evenodd" strokeWidth="0" d="M4.03231 8.69862C3.84775 8.20646 4.49385 7.77554 4.95539 7.77554C5.41693 7.77554 6.80154 9.85246 6.80154 9.85246C6.80154 9.85246 10.2631 4.314 10.4938 4.08323C10.7246 3.85246 11.8785 4.08323 11.4169 5.00631C11.0081 5.82388 7.26308 11.4678 7.26308 11.4678C7.26308 11.4678 6.80154 12.1602 6.34 11.4678C5.87846 10.7755 4.21687 9.19077 4.03231 8.69862Z"/>
|
282
|
-
</MultiSelectIcon>
|
283
|
-
</>) : (selected && <octicons_react_1.CheckIcon fill={theme?.colors.fg.default}/>)}
|
284
|
-
</BaseVisualContainer>)}
|
285
|
-
{LeadingVisual && (<LeadingVisualContainer variant={variant} disabled={disabled}>
|
286
|
-
<LeadingVisual />
|
287
|
-
</LeadingVisualContainer>)}
|
288
|
-
<DividedContent>
|
289
|
-
<MainContent style={{ '--main-content-flex-direction': descriptionVariant === 'inline' ? 'row' : 'column' }}>
|
290
|
-
{children}
|
291
|
-
{text ? <exports.TextContainer id={labelId}>{text}</exports.TextContainer> : null}
|
292
|
-
{description ? (<DescriptionContainer id={descriptionId} style={{
|
293
|
-
'--description-container-margin-left': descriptionVariant === 'inline' ? constants_1.get('space.2')(theme) : 0,
|
294
|
-
'--description-container-flex-basis': descriptionVariant === 'inline' ? 0 : 'auto'
|
295
|
-
}}>
|
296
|
-
{descriptionVariant === 'block' ? (description) : (<Truncate_1.default title={description} inline={true} maxWidth="100%">
|
297
|
-
{description}
|
298
|
-
</Truncate_1.default>)}
|
299
|
-
</DescriptionContainer>) : null}
|
300
|
-
</MainContent>
|
301
|
-
{/* backward compatibility: prefer TrailingVisual but fallback to TrailingIcon */}
|
302
|
-
{TrailingVisual ? (<TrailingContent variant={variant} disabled={disabled}>
|
303
|
-
{typeof TrailingVisual === 'function' ? <TrailingVisual /> : TrailingVisual}
|
304
|
-
</TrailingContent>) : TrailingIcon || trailingText ? (<TrailingContent variant={variant} disabled={disabled}>
|
305
|
-
{trailingText}
|
306
|
-
{TrailingIcon && <TrailingIcon />}
|
307
|
-
</TrailingContent>) : null}
|
308
|
-
</DividedContent>
|
309
|
-
</StyledItem>);
|
310
|
-
});
|
311
|
-
exports.Item.displayName = 'ActionList.Item';
|