@primer/components 31.2.0-rc.c7f73427 → 31.2.1-rc.18690e3f
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/ci.yml +5 -2
- package/.github/workflows/release.yml +1 -0
- package/.github/workflows/release_canary.yml +1 -0
- package/CHANGELOG.md +16 -0
- package/dist/browser.esm.js +656 -645
- package/dist/browser.esm.js.map +1 -1
- package/dist/browser.umd.js +211 -200
- package/dist/browser.umd.js.map +1 -1
- package/docs/content/ActionList2.mdx +358 -0
- package/docs/content/StateLabel.md +5 -4
- package/docs/content/getting-started.md +1 -1
- package/docs/src/@primer/gatsby-theme-doctocat/live-code-scope.js +17 -0
- 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 +28 -19
- 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.d.ts +12 -0
- package/lib/ActionList2/Description.js +53 -0
- package/lib/ActionList2/Description.jsx +30 -0
- package/lib/ActionList2/Divider.d.ts +5 -0
- package/lib/ActionList2/Divider.js +35 -0
- package/lib/ActionList2/Divider.jsx +22 -0
- package/lib/ActionList2/Group.d.ts +11 -0
- package/lib/ActionList2/Group.js +57 -0
- 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.d.ts +63 -0
- package/lib/ActionList2/Item.js +243 -0
- package/lib/ActionList2/Item.jsx +174 -0
- package/lib/ActionList2/LinkItem.d.ts +17 -0
- package/lib/ActionList2/LinkItem.js +57 -0
- package/lib/ActionList2/LinkItem.jsx +28 -0
- package/lib/ActionList2/List.d.ts +26 -0
- package/lib/ActionList2/List.js +59 -0
- package/lib/ActionList2/List.jsx +41 -0
- package/lib/ActionList2/Selection.d.ts +5 -0
- package/lib/ActionList2/Selection.js +84 -0
- package/lib/ActionList2/Selection.jsx +50 -0
- package/lib/ActionList2/Visuals.d.ts +9 -0
- package/lib/ActionList2/Visuals.js +90 -0
- package/lib/ActionList2/Visuals.jsx +48 -0
- package/lib/ActionList2/index.d.ts +36 -0
- package/lib/ActionList2/index.js +29 -0
- 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 +28 -28
- package/lib/Autocomplete/Autocomplete.jsx +100 -0
- package/lib/Autocomplete/AutocompleteContext.jsx +5 -0
- package/lib/Autocomplete/AutocompleteInput.d.ts +28 -28
- 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.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.jsx +20 -0
- package/lib/Breadcrumbs.jsx +74 -0
- package/lib/Button/Button.d.ts +25 -25
- package/lib/Button/Button.jsx +60 -0
- package/lib/Button/ButtonBase.jsx +36 -0
- package/lib/Button/ButtonClose.d.ts +45 -45
- package/lib/Button/ButtonClose.jsx +55 -0
- package/lib/Button/ButtonDanger.d.ts +25 -25
- package/lib/Button/ButtonDanger.jsx +63 -0
- package/lib/Button/ButtonGroup.jsx +55 -0
- package/lib/Button/ButtonInvisible.d.ts +25 -25
- package/lib/Button/ButtonInvisible.jsx +52 -0
- package/lib/Button/ButtonOutline.d.ts +25 -25
- package/lib/Button/ButtonOutline.jsx +63 -0
- package/lib/Button/ButtonPrimary.d.ts +25 -25
- package/lib/Button/ButtonPrimary.jsx +62 -0
- package/lib/Button/ButtonStyles.jsx +37 -0
- package/lib/Button/ButtonTableList.jsx +49 -0
- package/lib/Button/index.js +21 -70
- package/lib/Caret.jsx +93 -0
- package/lib/CircleBadge.jsx +43 -0
- package/lib/CircleOcticon.d.ts +42 -42
- package/lib/CircleOcticon.jsx +21 -0
- package/lib/CounterLabel.jsx +44 -0
- package/lib/Details.jsx +21 -0
- package/lib/Dialog/ConfirmationDialog.jsx +146 -0
- package/lib/Dialog/Dialog.js +1 -0
- package/lib/Dialog/Dialog.jsx +273 -0
- package/lib/Dialog.d.ts +45 -45
- package/lib/Dialog.jsx +131 -0
- package/lib/Dropdown.d.ts +176 -176
- package/lib/Dropdown.jsx +134 -0
- package/lib/DropdownMenu/DropdownButton.d.ts +46 -46
- 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/FilterList.d.ts +42 -42
- package/lib/FilterList.jsx +63 -0
- package/lib/FilteredActionList/FilteredActionList.jsx +100 -0
- package/lib/FilteredActionList/index.js +4 -12
- package/lib/FilteredSearch.jsx +29 -0
- package/lib/Flash.jsx +70 -0
- package/lib/Flex.jsx +15 -0
- package/lib/FormGroup.jsx +25 -0
- package/lib/Grid.jsx +15 -0
- package/lib/Header.jsx +90 -0
- package/lib/Heading.jsx +21 -0
- package/lib/Label.jsx +84 -0
- package/lib/LabelGroup.jsx +19 -0
- package/lib/Link.jsx +38 -0
- package/lib/NewButton/button-counter.d.ts +6 -0
- package/lib/NewButton/button-counter.js +31 -0
- package/lib/NewButton/button-counter.jsx +14 -0
- package/lib/NewButton/button.d.ts +13 -0
- package/lib/NewButton/button.js +316 -0
- package/lib/NewButton/button.jsx +278 -0
- package/lib/NewButton/index.d.ts +14 -0
- package/lib/NewButton/index.js +8 -0
- package/lib/NewButton/types.d.ts +32 -0
- package/lib/NewButton/types.js +2 -0
- package/lib/Overlay.jsx +156 -0
- package/lib/Pagehead.jsx +18 -0
- 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.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.jsx +39 -0
- package/lib/SelectMenu/SelectMenu.d.ts +246 -246
- package/lib/SelectMenu/SelectMenu.jsx +114 -0
- package/lib/SelectMenu/SelectMenuContext.jsx +5 -0
- package/lib/SelectMenu/SelectMenuDivider.jsx +43 -0
- package/lib/SelectMenu/SelectMenuFilter.jsx +59 -0
- package/lib/SelectMenu/SelectMenuFooter.jsx +46 -0
- package/lib/SelectMenu/SelectMenuHeader.jsx +44 -0
- package/lib/SelectMenu/SelectMenuItem.d.ts +1 -1
- package/lib/SelectMenu/SelectMenuItem.jsx +143 -0
- package/lib/SelectMenu/SelectMenuList.jsx +60 -0
- package/lib/SelectMenu/SelectMenuLoadingAnimation.jsx +21 -0
- package/lib/SelectMenu/SelectMenuModal.d.ts +1 -1
- package/lib/SelectMenu/SelectMenuModal.jsx +119 -0
- package/lib/SelectMenu/SelectMenuTab.jsx +93 -0
- package/lib/SelectMenu/SelectMenuTabPanel.jsx +43 -0
- 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.jsx +177 -0
- package/lib/Spinner.jsx +35 -0
- package/lib/StateLabel.d.ts +1 -1
- package/lib/StateLabel.js +6 -1
- package/lib/StateLabel.jsx +94 -0
- package/lib/StyledOcticon.jsx +20 -0
- package/lib/SubNav.jsx +104 -0
- package/lib/TabNav.jsx +60 -0
- package/lib/Text.jsx +14 -0
- package/lib/TextInput.jsx +23 -0
- package/lib/TextInputWithTokens.d.ts +28 -28
- package/lib/TextInputWithTokens.jsx +218 -0
- package/lib/ThemeProvider.jsx +130 -0
- package/lib/Timeline.d.ts +43 -43
- 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.jsx +246 -0
- package/lib/Truncate.jsx +27 -0
- package/lib/UnderlineNav.jsx +90 -0
- package/lib/_TextInputWrapper.jsx +120 -0
- package/lib/_UnstyledTextInput.jsx +22 -0
- package/lib/__tests__/ActionList.test.jsx +49 -0
- package/lib/__tests__/ActionList.types.test.jsx +45 -0
- package/lib/__tests__/ActionList2.test.d.ts +1 -0
- package/lib/__tests__/ActionList2.test.js +53 -0
- package/lib/__tests__/ActionList2.test.jsx +46 -0
- package/lib/__tests__/ActionMenu.test.jsx +124 -0
- package/lib/__tests__/AnchoredOverlay.test.jsx +121 -0
- package/lib/__tests__/Autocomplete.test.jsx +299 -0
- package/lib/__tests__/Avatar.test.jsx +42 -0
- package/lib/__tests__/AvatarStack.test.jsx +43 -0
- package/lib/__tests__/BorderBox.test.jsx +36 -0
- package/lib/__tests__/Box.test.jsx +41 -0
- package/lib/__tests__/BranchName.test.jsx +27 -0
- package/lib/__tests__/Breadcrumbs.test.jsx +28 -0
- package/lib/__tests__/BreadcrumbsItem.test.jsx +31 -0
- package/lib/__tests__/Button.test.jsx +100 -0
- package/lib/__tests__/Caret.test.jsx +37 -0
- package/lib/__tests__/CircleBadge.test.jsx +55 -0
- package/lib/__tests__/CircleOcticon.test.jsx +45 -0
- package/lib/__tests__/ConfirmationDialog.test.jsx +119 -0
- package/lib/__tests__/CounterLabel.test.jsx +36 -0
- package/lib/__tests__/Details.test.jsx +85 -0
- package/lib/__tests__/Dialog.test.jsx +139 -0
- package/lib/__tests__/Dropdown.test.jsx +49 -0
- package/lib/__tests__/DropdownMenu.test.jsx +119 -0
- package/lib/__tests__/FilterList.test.jsx +27 -0
- package/lib/__tests__/FilterListItem.test.jsx +31 -0
- package/lib/__tests__/FilteredSearch.test.jsx +27 -0
- package/lib/__tests__/Flash.test.jsx +36 -0
- package/lib/__tests__/Flex.test.jsx +51 -0
- package/lib/__tests__/FormGroup.test.jsx +36 -0
- package/lib/__tests__/Grid.test.jsx +69 -0
- package/lib/__tests__/Header.test.jsx +45 -0
- package/lib/__tests__/Heading.test.jsx +71 -0
- package/lib/__tests__/KeyPaths.types.test.js +5 -8
- package/lib/__tests__/Label.test.jsx +33 -0
- package/lib/__tests__/LabelGroup.test.jsx +29 -0
- package/lib/__tests__/Link.test.jsx +43 -0
- package/lib/__tests__/Merge.types.test.js +13 -19
- package/lib/__tests__/NewButton.test.d.ts +1 -0
- package/lib/__tests__/NewButton.test.js +95 -0
- package/lib/__tests__/NewButton.test.jsx +61 -0
- package/lib/__tests__/Overlay.test.jsx +105 -0
- package/lib/__tests__/Pagehead.test.jsx +25 -0
- package/lib/__tests__/Pagination/Pagination.test.jsx +32 -0
- package/lib/__tests__/Pagination/PaginationModel.test.jsx +118 -0
- package/lib/__tests__/PointerBox.test.jsx +33 -0
- package/lib/__tests__/Popover.test.jsx +58 -0
- package/lib/__tests__/Portal.test.jsx +102 -0
- package/lib/__tests__/Position.test.jsx +96 -0
- package/lib/__tests__/ProgressBar.test.jsx +38 -0
- package/lib/__tests__/SelectMenu.test.jsx +120 -0
- package/lib/__tests__/SelectPanel.test.jsx +48 -0
- package/lib/__tests__/SideNav.test.jsx +55 -0
- package/lib/__tests__/Spinner.test.jsx +41 -0
- package/lib/__tests__/StateLabel.test.jsx +46 -0
- package/lib/__tests__/StyledOcticon.test.jsx +28 -0
- package/lib/__tests__/SubNav.test.jsx +47 -0
- package/lib/__tests__/SubNavLink.test.jsx +31 -0
- package/lib/__tests__/TabNav.test.jsx +32 -0
- package/lib/__tests__/Text.test.jsx +71 -0
- package/lib/__tests__/TextInput.test.jsx +45 -0
- package/lib/__tests__/TextInputWithTokens.test.jsx +302 -0
- package/lib/__tests__/ThemeProvider.test.jsx +314 -0
- package/lib/__tests__/Timeline.test.jsx +51 -0
- package/lib/__tests__/Token.test.jsx +93 -0
- package/lib/__tests__/Tooltip.test.jsx +46 -0
- package/lib/__tests__/Truncate.test.jsx +41 -0
- package/lib/__tests__/UnderlineNav.test.jsx +53 -0
- package/lib/__tests__/UnderlineNavLink.test.jsx +31 -0
- package/lib/__tests__/behaviors/anchoredPosition.test.js +229 -376
- package/lib/__tests__/behaviors/focusTrap.test.jsx +184 -0
- package/lib/__tests__/behaviors/focusZone.test.jsx +406 -0
- package/lib/__tests__/behaviors/iterateFocusableElements.test.jsx +58 -0
- package/lib/__tests__/behaviors/scrollIntoViewingArea.test.js +145 -216
- package/lib/__tests__/filterObject.test.js +48 -27
- package/lib/__tests__/hooks/useAnchoredPosition.test.jsx +29 -0
- package/lib/__tests__/hooks/useOnEscapePress.test.jsx +19 -0
- package/lib/__tests__/hooks/useOnOutsideClick.test.jsx +63 -0
- package/lib/__tests__/hooks/useOpenAndCloseFocus.test.jsx +61 -0
- package/lib/__tests__/hooks/useProvidedStateOrCreate.test.jsx +56 -0
- package/lib/__tests__/theme.test.js +33 -34
- package/lib/__tests__/themeGet.test.js +12 -23
- package/lib/__tests__/useSafeTimeout.test.jsx +36 -0
- package/lib/__tests__/utils/createSlots.test.d.ts +1 -0
- package/lib/__tests__/utils/createSlots.test.js +75 -0
- package/lib/__tests__/utils/createSlots.test.jsx +57 -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 +8 -0
- package/lib/drafts.js +21 -0
- 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 -0
- package/lib/index.js +163 -636
- package/lib/polyfills/eventListenerSignal.js +37 -45
- package/lib/stories/ActionList2.stories.js +908 -0
- package/lib/stories/NewButton.stories.js +230 -0
- package/lib/sx.d.ts +2 -0
- package/lib/sx.js +10 -14
- package/lib/theme-preval.js +65 -2945
- package/lib/theme.js +3 -12
- package/lib/utils/create-slots.d.ts +17 -0
- package/lib/utils/create-slots.js +105 -0
- 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 +14 -1
- 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.d.ts +1 -0
- package/lib/utils/use-force-update.js +13 -0
- package/lib/utils/useIsomorphicLayoutEffect.js +8 -11
- package/lib/utils/userAgent.js +8 -12
- package/lib-esm/ActionList/Item.js +28 -19
- package/lib-esm/ActionList2/Description.d.ts +12 -0
- package/lib-esm/ActionList2/Description.js +37 -0
- package/lib-esm/ActionList2/Divider.d.ts +5 -0
- package/lib-esm/ActionList2/Divider.js +23 -0
- package/lib-esm/ActionList2/Group.d.ts +11 -0
- package/lib-esm/ActionList2/Group.js +40 -0
- package/lib-esm/ActionList2/Header.d.ts +26 -0
- package/lib-esm/ActionList2/Header.js +44 -0
- package/lib-esm/ActionList2/Item.d.ts +63 -0
- package/lib-esm/ActionList2/Item.js +209 -0
- package/lib-esm/ActionList2/LinkItem.d.ts +17 -0
- package/lib-esm/ActionList2/LinkItem.js +43 -0
- package/lib-esm/ActionList2/List.d.ts +26 -0
- package/lib-esm/ActionList2/List.js +37 -0
- package/lib-esm/ActionList2/Selection.d.ts +5 -0
- package/lib-esm/ActionList2/Selection.js +66 -0
- package/lib-esm/ActionList2/Visuals.d.ts +9 -0
- package/lib-esm/ActionList2/Visuals.js +68 -0
- package/lib-esm/ActionList2/index.d.ts +36 -0
- package/lib-esm/ActionList2/index.js +33 -0
- package/lib-esm/Autocomplete/Autocomplete.d.ts +28 -28
- package/lib-esm/Autocomplete/AutocompleteInput.d.ts +28 -28
- package/lib-esm/Button/Button.d.ts +25 -25
- package/lib-esm/Button/ButtonClose.d.ts +45 -45
- package/lib-esm/Button/ButtonDanger.d.ts +25 -25
- package/lib-esm/Button/ButtonInvisible.d.ts +25 -25
- package/lib-esm/Button/ButtonOutline.d.ts +25 -25
- package/lib-esm/Button/ButtonPrimary.d.ts +25 -25
- package/lib-esm/CircleOcticon.d.ts +42 -42
- package/lib-esm/Dialog/Dialog.js +1 -0
- package/lib-esm/Dialog.d.ts +45 -45
- package/lib-esm/Dropdown.d.ts +176 -176
- package/lib-esm/DropdownMenu/DropdownButton.d.ts +46 -46
- package/lib-esm/FilterList.d.ts +42 -42
- package/lib-esm/NewButton/button-counter.d.ts +6 -0
- package/lib-esm/NewButton/button-counter.js +18 -0
- package/lib-esm/NewButton/button.d.ts +13 -0
- package/lib-esm/NewButton/button.js +298 -0
- package/lib-esm/NewButton/index.d.ts +14 -0
- package/lib-esm/NewButton/index.js +5 -0
- package/lib-esm/NewButton/types.d.ts +32 -0
- package/lib-esm/NewButton/types.js +1 -0
- package/lib-esm/Position.d.ts +4 -4
- package/lib-esm/SelectMenu/SelectMenu.d.ts +246 -246
- package/lib-esm/SelectMenu/SelectMenuItem.d.ts +1 -1
- package/lib-esm/SelectMenu/SelectMenuModal.d.ts +1 -1
- package/lib-esm/StateLabel.d.ts +1 -1
- package/lib-esm/StateLabel.js +7 -2
- package/lib-esm/TextInputWithTokens.d.ts +28 -28
- package/lib-esm/Timeline.d.ts +43 -43
- 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/__tests__/ActionList2.test.d.ts +1 -0
- package/lib-esm/__tests__/ActionList2.test.js +41 -0
- package/lib-esm/__tests__/NewButton.test.d.ts +1 -0
- package/lib-esm/__tests__/NewButton.test.js +84 -0
- package/lib-esm/__tests__/utils/createSlots.test.d.ts +1 -0
- package/lib-esm/__tests__/utils/createSlots.test.js +67 -0
- package/lib-esm/drafts.d.ts +8 -0
- package/lib-esm/drafts.js +9 -0
- package/lib-esm/index.d.ts +2 -0
- package/lib-esm/index.js +1 -0
- package/lib-esm/stories/ActionList2.stories.js +796 -0
- package/lib-esm/stories/NewButton.stories.js +178 -0
- package/lib-esm/sx.d.ts +2 -0
- package/lib-esm/sx.js +3 -1
- package/lib-esm/theme-preval.js +81 -2
- package/lib-esm/utils/create-slots.d.ts +17 -0
- package/lib-esm/utils/create-slots.js +84 -0
- package/lib-esm/utils/testing.d.ts +14 -1
- package/lib-esm/utils/use-force-update.d.ts +1 -0
- package/lib-esm/utils/use-force-update.js +6 -0
- package/package-lock.json +153 -14
- package/package.json +7 -4
- package/script/build +1 -1
- package/src/ActionList/Item.tsx +32 -19
- package/src/ActionList2/Description.tsx +49 -0
- package/src/ActionList2/Divider.tsx +24 -0
- package/src/ActionList2/Group.tsx +34 -0
- package/src/ActionList2/Header.tsx +58 -0
- package/src/ActionList2/Item.tsx +245 -0
- package/src/ActionList2/LinkItem.tsx +49 -0
- package/src/ActionList2/List.tsx +55 -0
- package/src/ActionList2/Selection.tsx +60 -0
- package/src/ActionList2/Visuals.tsx +76 -0
- package/src/ActionList2/index.ts +39 -0
- package/src/Dialog/Dialog.tsx +1 -0
- package/src/NewButton/button-counter.tsx +15 -0
- package/src/NewButton/button.tsx +279 -0
- package/src/NewButton/index.ts +10 -0
- package/src/NewButton/types.ts +36 -0
- package/src/StateLabel.tsx +14 -2
- package/src/__tests__/ActionList2.test.tsx +47 -0
- package/src/__tests__/NewButton.test.tsx +70 -0
- package/src/__tests__/__snapshots__/ActionList2.test.tsx.snap +14 -0
- package/src/__tests__/__snapshots__/Autocomplete.test.tsx.snap +722 -255
- package/src/__tests__/__snapshots__/CircleBadge.test.tsx.snap +1 -0
- package/src/__tests__/__snapshots__/CircleOcticon.test.tsx.snap +1 -0
- package/src/__tests__/__snapshots__/Dialog.test.tsx.snap +1 -0
- package/src/__tests__/__snapshots__/DropdownMenu.test.tsx.snap +1 -0
- package/src/__tests__/__snapshots__/NewButton.test.tsx.snap +300 -0
- package/src/__tests__/__snapshots__/SelectMenu.test.tsx.snap +4 -0
- package/src/__tests__/__snapshots__/SelectPanel.test.tsx.snap +1 -0
- package/src/__tests__/__snapshots__/StateLabel.test.tsx.snap +13 -6
- package/src/__tests__/__snapshots__/StyledOcticon.test.tsx.snap +1 -0
- package/src/__tests__/__snapshots__/TextInputWithTokens.test.tsx.snap +66 -0
- package/src/__tests__/__snapshots__/Token.test.tsx.snap +17 -0
- package/src/__tests__/utils/__snapshots__/createSlots.test.tsx.snap +55 -0
- package/src/__tests__/utils/createSlots.test.tsx +74 -0
- package/src/drafts.ts +10 -0
- package/src/index.ts +2 -0
- package/src/stories/ActionList2.stories.tsx +1291 -0
- package/src/stories/NewButton.stories.tsx +201 -0
- package/src/sx.ts +3 -0
- package/src/theme-preval.js +1 -0
- package/src/utils/create-slots.tsx +96 -0
- package/src/utils/use-force-update.ts +7 -0
- package/stats.html +1 -1
- package/tsconfig.base.json +20 -0
- package/tsconfig.build.json +2 -2
- package/tsconfig.json +4 -17
@@ -0,0 +1,358 @@
|
|
1
|
+
---
|
2
|
+
title: ActionList
|
3
|
+
status: Alpha
|
4
|
+
source: https://github.com/primer/react/tree/main/src/ActionList2
|
5
|
+
storybook: '/react/storybook?path=/story/composite-components-actionlist2'
|
6
|
+
description: An ActionList is a list of items which can be activated or selected. ActionList is the base component for many of our menu-type components, including DropdownMenu and ActionMenu.
|
7
|
+
---
|
8
|
+
|
9
|
+
import {BorderBox, Avatar} from '@primer/components'
|
10
|
+
import {ActionList} from '@primer/components/drafts'
|
11
|
+
import {Props} from '../src/props'
|
12
|
+
|
13
|
+
import {ImageContainer} from '@primer/gatsby-theme-doctocat'
|
14
|
+
import {LinkIcon, AlertIcon, ArrowRightIcon} from '@primer/octicons-react'
|
15
|
+
|
16
|
+
<br />
|
17
|
+
|
18
|
+
<BorderBox sx={{padding: 6}}>
|
19
|
+
<ActionList sx={{width: 320}}>
|
20
|
+
<ActionList.Item>
|
21
|
+
<ActionList.LeadingVisual>
|
22
|
+
<LinkIcon />
|
23
|
+
</ActionList.LeadingVisual>
|
24
|
+
github.com/primer
|
25
|
+
<ActionList.Description variant="block">
|
26
|
+
A React implementation of GitHub's Primer Design System
|
27
|
+
</ActionList.Description>
|
28
|
+
</ActionList.Item>
|
29
|
+
<ActionList.Item>
|
30
|
+
<ActionList.LeadingVisual>
|
31
|
+
<Avatar src="https://github.com/mona.png" />
|
32
|
+
</ActionList.LeadingVisual>
|
33
|
+
mona
|
34
|
+
<ActionList.Description>Monalisa Octocat</ActionList.Description>
|
35
|
+
</ActionList.Item>
|
36
|
+
<ActionList.Item variant="danger">
|
37
|
+
<ActionList.LeadingVisual>
|
38
|
+
<AlertIcon />
|
39
|
+
</ActionList.LeadingVisual>
|
40
|
+
4 vulnerabilities
|
41
|
+
<ActionList.TrailingVisual>
|
42
|
+
<ArrowRightIcon />
|
43
|
+
</ActionList.TrailingVisual>
|
44
|
+
</ActionList.Item>
|
45
|
+
</ActionList>
|
46
|
+
</BorderBox>
|
47
|
+
|
48
|
+
<br />
|
49
|
+
|
50
|
+
```js
|
51
|
+
import {ActionList} from '@primer/components/drafts'
|
52
|
+
```
|
53
|
+
|
54
|
+
<br />
|
55
|
+
|
56
|
+
## Examples
|
57
|
+
|
58
|
+
### Minimal example
|
59
|
+
|
60
|
+
```javascript live noinline
|
61
|
+
// import {ActionList} from '@primer/components/drafts'
|
62
|
+
const {ActionList} = drafts // ignore docs silliness; import like that ↑
|
63
|
+
|
64
|
+
render(
|
65
|
+
<ActionList>
|
66
|
+
<ActionList.Item>New file</ActionList.Item>
|
67
|
+
<ActionList.Item>Copy link</ActionList.Item>
|
68
|
+
<ActionList.Item>Edit file</ActionList.Item>
|
69
|
+
<ActionList.Divider />
|
70
|
+
<ActionList.Item variant="danger">Delete file</ActionList.Item>
|
71
|
+
</ActionList>
|
72
|
+
)
|
73
|
+
```
|
74
|
+
|
75
|
+
<br />
|
76
|
+
|
77
|
+
### With leading visual
|
78
|
+
|
79
|
+
Leading visuals are optional and appear at the start of an item. They can be octicons, avatars, and other custom visuals that fit a small area.
|
80
|
+
|
81
|
+
<!-- prettier-ignore -->
|
82
|
+
```javascript live noinline
|
83
|
+
// import {ActionList} from '@primer/components/drafts'
|
84
|
+
const {ActionList} = drafts // ignore docs silliness; import like that ↑
|
85
|
+
|
86
|
+
render(
|
87
|
+
<ActionList>
|
88
|
+
<ActionList.Item>
|
89
|
+
<ActionList.LeadingVisual><LinkIcon /></ActionList.LeadingVisual>
|
90
|
+
github.com/primer
|
91
|
+
</ActionList.Item>
|
92
|
+
<ActionList.Item variant="danger">
|
93
|
+
<ActionList.LeadingVisual><AlertIcon /></ActionList.LeadingVisual>
|
94
|
+
4 vulnerabilities
|
95
|
+
</ActionList.Item>
|
96
|
+
<ActionList.Item>
|
97
|
+
<ActionList.LeadingVisual><Avatar src="https://github.com/mona.png" /></ActionList.LeadingVisual>
|
98
|
+
mona
|
99
|
+
</ActionList.Item>
|
100
|
+
</ActionList>
|
101
|
+
)
|
102
|
+
```
|
103
|
+
|
104
|
+
<br />
|
105
|
+
|
106
|
+
### With trailing visual
|
107
|
+
|
108
|
+
Trailing visual and trailing text can display auxiliary information. They're placed at the right of the item, and can denote status, keyboard shortcuts, or be used to set expectations about what the action does.
|
109
|
+
|
110
|
+
```javascript live noinline
|
111
|
+
// import {ActionList} from '@primer/components/drafts'
|
112
|
+
const {ActionList} = drafts // ignore docs silliness; import like that ↑
|
113
|
+
|
114
|
+
render(
|
115
|
+
<ActionList>
|
116
|
+
<ActionList.Item>
|
117
|
+
New file
|
118
|
+
<ActionList.TrailingVisual>⌘ + N</ActionList.TrailingVisual>
|
119
|
+
</ActionList.Item>
|
120
|
+
<ActionList.Item>
|
121
|
+
Copy link
|
122
|
+
<ActionList.TrailingVisual>⌘ + C</ActionList.TrailingVisual>
|
123
|
+
</ActionList.Item>
|
124
|
+
<ActionList.Item>
|
125
|
+
Edit file
|
126
|
+
<ActionList.TrailingVisual>⌘ + E</ActionList.TrailingVisual>
|
127
|
+
</ActionList.Item>
|
128
|
+
<ActionList.Item variant="danger">
|
129
|
+
Delete file
|
130
|
+
<ActionList.TrailingVisual>⌫</ActionList.TrailingVisual>
|
131
|
+
</ActionList.Item>
|
132
|
+
</ActionList>
|
133
|
+
)
|
134
|
+
```
|
135
|
+
|
136
|
+
<br />
|
137
|
+
|
138
|
+
### With description and dividers
|
139
|
+
|
140
|
+
Item dividers allow users to parse heavier amounts of information. They're placed between items and are useful in complex lists, particularly when descriptions or multi-line text is present.
|
141
|
+
|
142
|
+
```javascript live noinline
|
143
|
+
// import {ActionList} from '@primer/components/drafts'
|
144
|
+
const {ActionList} = drafts // ignore docs silliness; import like that ↑
|
145
|
+
|
146
|
+
render(
|
147
|
+
<ActionList showDividers>
|
148
|
+
<ActionList.Item>
|
149
|
+
<ActionList.LeadingVisual>
|
150
|
+
<Avatar src="https://github.com/mona.png" />
|
151
|
+
</ActionList.LeadingVisual>
|
152
|
+
mona
|
153
|
+
<ActionList.Description>Monalisa Octocat</ActionList.Description>
|
154
|
+
</ActionList.Item>
|
155
|
+
<ActionList.Item>
|
156
|
+
<ActionList.LeadingVisual>
|
157
|
+
<Avatar src="https://github.com/hubot.png" />
|
158
|
+
</ActionList.LeadingVisual>
|
159
|
+
hubot
|
160
|
+
<ActionList.Description>Hubot</ActionList.Description>
|
161
|
+
</ActionList.Item>
|
162
|
+
<ActionList.Item>
|
163
|
+
<ActionList.LeadingVisual>
|
164
|
+
<Avatar src="https://github.com/primer-css.png" />
|
165
|
+
</ActionList.LeadingVisual>
|
166
|
+
primer-css
|
167
|
+
<ActionList.Description>GitHub Design Systems Bot</ActionList.Description>
|
168
|
+
</ActionList.Item>
|
169
|
+
</ActionList>
|
170
|
+
)
|
171
|
+
```
|
172
|
+
|
173
|
+
### With links
|
174
|
+
|
175
|
+
When you want to add links to the List instead of actions, use `ActionList.LinkItem`
|
176
|
+
|
177
|
+
<!-- prettier-ignore -->
|
178
|
+
```javascript live noinline
|
179
|
+
// import {ActionList} from '@primer/components/drafts'
|
180
|
+
const {ActionList} = drafts // ignore docs silliness; import like that ↑
|
181
|
+
|
182
|
+
render(
|
183
|
+
<ActionList>
|
184
|
+
<ActionList.LinkItem href="https://github.com/primer">
|
185
|
+
<ActionList.LeadingVisual>
|
186
|
+
<LinkIcon />
|
187
|
+
</ActionList.LeadingVisual>
|
188
|
+
github/primer
|
189
|
+
</ActionList.LinkItem>
|
190
|
+
<ActionList.LinkItem as={ReactRouterLink} to="/">
|
191
|
+
<ActionList.LeadingVisual>
|
192
|
+
<LawIcon />
|
193
|
+
</ActionList.LeadingVisual>
|
194
|
+
MIT License
|
195
|
+
</ActionList.LinkItem>
|
196
|
+
<ActionList.LinkItem
|
197
|
+
href="https://github.com/primer/react/stargazers"
|
198
|
+
target="_blank"
|
199
|
+
rel="noopener noreferrer"
|
200
|
+
>
|
201
|
+
<ActionList.LeadingVisual>
|
202
|
+
<StarIcon />
|
203
|
+
</ActionList.LeadingVisual>
|
204
|
+
1.4k stars
|
205
|
+
</ActionList.LinkItem>
|
206
|
+
</ActionList>
|
207
|
+
)
|
208
|
+
```
|
209
|
+
|
210
|
+
<br />
|
211
|
+
|
212
|
+
### With groups
|
213
|
+
|
214
|
+
```javascript live noinline
|
215
|
+
// import {ActionList} from '@primer/components/drafts'
|
216
|
+
const {ActionList} = drafts // ignore docs silliness; import like that ↑
|
217
|
+
|
218
|
+
const SelectFields = () => {
|
219
|
+
const [options, setOptions] = React.useState([
|
220
|
+
{text: 'Status', selected: true},
|
221
|
+
{text: 'Stage', selected: true},
|
222
|
+
{text: 'Assignee', selected: true},
|
223
|
+
{text: 'Team', selected: true},
|
224
|
+
{text: 'Estimate', selected: false},
|
225
|
+
{text: 'Due Date', selected: false}
|
226
|
+
])
|
227
|
+
|
228
|
+
const visibleOptions = options.filter(option => option.selected)
|
229
|
+
const hiddenOptions = options.filter(option => !option.selected)
|
230
|
+
|
231
|
+
const toggle = text => {
|
232
|
+
setOptions(
|
233
|
+
options.map(option => {
|
234
|
+
if (option.text === text) option.selected = !option.selected
|
235
|
+
return option
|
236
|
+
})
|
237
|
+
)
|
238
|
+
}
|
239
|
+
|
240
|
+
return (
|
241
|
+
<ActionList selectionVariant="multiple">
|
242
|
+
<ActionList.Group title="Visible fields (can be reordered)">
|
243
|
+
{visibleOptions.map(option => (
|
244
|
+
<ActionList.Item key={option.text} selected={true} onSelect={() => toggle(option.text)}>
|
245
|
+
{option.text}
|
246
|
+
</ActionList.Item>
|
247
|
+
))}
|
248
|
+
</ActionList.Group>
|
249
|
+
<ActionList.Group
|
250
|
+
title="Hidden fields"
|
251
|
+
selectionVariant={
|
252
|
+
/** selectionVariant override on Group: disable selection if there are no options */
|
253
|
+
hiddenOptions.length ? 'multiple' : false
|
254
|
+
}
|
255
|
+
>
|
256
|
+
{hiddenOptions.map((option, index) => (
|
257
|
+
<ActionList.Item key={option.text} selected={false} onSelect={() => toggle(option.text)}>
|
258
|
+
{option.text}
|
259
|
+
</ActionList.Item>
|
260
|
+
))}
|
261
|
+
{hiddenOptions.length === 0 && <ActionList.Item disabled>No hidden fields</ActionList.Item>}
|
262
|
+
</ActionList.Group>
|
263
|
+
</ActionList>
|
264
|
+
)
|
265
|
+
}
|
266
|
+
|
267
|
+
render(<SelectFields />)
|
268
|
+
```
|
269
|
+
|
270
|
+
<br />
|
271
|
+
|
272
|
+
## Props / API reference
|
273
|
+
|
274
|
+
### ActionList
|
275
|
+
|
276
|
+
| Name | Type | Default | Description |
|
277
|
+
| :--------------- | :------------------------------------------------------------------------------------------------ | :-----: | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
278
|
+
| children\* | `ActionList.Item[]` or ActionList.LinkItem[] or `ActionList.Group[]` | - | Required. |
|
279
|
+
| variant | `'inset'` or `'full'` | 'inset' | Optional. Usage is discretionary, `inset` children are offset (vertically and horizontally) from `List`’s edges, `full` children are flush (vertically and horizontally) with `List` edges |
|
280
|
+
| selectionVariant | `'single'` or `'multiple'` | - | Optional. Whether multiple Items or a single Item can be selected. |
|
281
|
+
| showDivider | boolean | false | Optional. Display a divider above each `Item` in this `List` when it does not follow a `Header` or `Divider`. |
|
282
|
+
| sx | sxProp | - | Optional. See guide to [Overriding styles](/overriding-styles) |
|
283
|
+
| role | [AriaRole](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Techniques#roles) | - | Optional. The ARIA role describing the function of `List` component. `listbox` or `menu` are a common values. |
|
284
|
+
|
285
|
+
<br />
|
286
|
+
|
287
|
+
### ActionList.Item
|
288
|
+
|
289
|
+
| Name | Type | Default | Description |
|
290
|
+
| :--------- | :------------------------------------------------------------------------------------------------------------ | :---------: | :----------------------------------------------------------------------------------------------- |
|
291
|
+
| children\* | one of [`React.ReactNode`, `ActionList.LeadingVisual`, `ActionList.Description`, `ActionList.TrailingVisual`] | - | Required. |
|
292
|
+
| variant | `'default'` or `'danger'` | `'default'` | Optional. variant="danger" creates a destructive action `Item`. |
|
293
|
+
| onSelect | Function | - | Optional. Callback that will trigger both on click selection and keyboard selection. |
|
294
|
+
| selected | boolean | false | Optional. For `Item`s which can be selected, whether the `Item` is currently selected. |
|
295
|
+
| disabled | boolean | false | Optional. Items that are disabled can not be clicked, selected, or navigated through. |
|
296
|
+
| role | [AriaRole](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Techniques#roles) | - | Optional. The ARIA role describing the function of `Item` component. `option` is a common value. |
|
297
|
+
| sx | sxProp | - | Optional. See guide to [Overriding styles](/overriding-styles) |
|
298
|
+
|
299
|
+
<br />
|
300
|
+
|
301
|
+
### ActionList.LinkItem
|
302
|
+
|
303
|
+
| Name | Type | Default | Description |
|
304
|
+
| :-------------------------------------------------- | :------------------------------------------------------------------------------------------------------------ | :-----: | :------------------------------------------------------------- |
|
305
|
+
| children\* | one of [`React.ReactNode`, `ActionList.LeadingVisual`, `ActionList.Description`, `ActionList.TrailingVisual`] | - | Required. |
|
306
|
+
| sx | sxProp | - | Optional. See guide to [Overriding styles](/overriding-styles) |
|
307
|
+
| + AnchorHTMLAttributes like href, target, rel, etc. | | | |
|
308
|
+
|
309
|
+
<br />
|
310
|
+
|
311
|
+
### ActionList.LeadingVisual
|
312
|
+
|
313
|
+
| Name | Type | Default | Description |
|
314
|
+
| :--------- | :------------------ | :-----: | :------------------------------------------------------------- |
|
315
|
+
| children\* | `React.ReactNode` - | - | Required. Icon (or similar) positioned before `Item` text. |
|
316
|
+
| sx | sxProp | - | Optional. See guide to [Overriding styles](/overriding-styles) |
|
317
|
+
|
318
|
+
### ActionList.TrailingVisual
|
319
|
+
|
320
|
+
| Name | Type | Default | Description |
|
321
|
+
| :--------- | :------------------ | :-----: | :------------------------------------------------------------- |
|
322
|
+
| children\* | `React.ReactNode` - | - | Required. Visual positioned after `Item` text. |
|
323
|
+
| sx | sxProp | - | Optional. See guide to [Overriding styles](/overriding-styles) |
|
324
|
+
|
325
|
+
<br />
|
326
|
+
|
327
|
+
### ActionList.Description
|
328
|
+
|
329
|
+
| Name | Type | Default | Description |
|
330
|
+
| :--------- | :---------------------- | :--------: | :-------------------------------------------------------------------------------------------------------------------------------- |
|
331
|
+
| children\* | `React.ReactNode` - | - | Required. Visual positioned after `Item` text. |
|
332
|
+
| variant | `'inline'` or `'block'` | `'inline'` | Optional. `"inline"` secondary text is positioned beside primary text. `"block"` secondary text is positioned below primary text. |
|
333
|
+
| sx | sxProp | - | Optional. See guide to [Overriding styles](/overriding-styles) |
|
334
|
+
|
335
|
+
<br />
|
336
|
+
|
337
|
+
### ActionList.Group
|
338
|
+
|
339
|
+
| Name | Type | Default | Description |
|
340
|
+
| :--------------- | :------------------------------------------- | :--------: | :--------------------------------------------------------------------------------------------------------------------------------------- |
|
341
|
+
| children\* | `ActionList.Item[] or ActionList.LinkItem[]` | - | Required. |
|
342
|
+
| title | string | - | Optional. Primary text which names a `Group` |
|
343
|
+
| auxiliaryText | string | - | Optional. Secondary text which provides additional information about a `Group`. |
|
344
|
+
| variant | `'filled'` or `'subtle'` | `'subtle'` | Optional. `"filled"` - Superimposed on a background, offset from nearby content, `"subtle"` - Relatively less offset from nearby content |
|
345
|
+
| selectionVariant | `'single'` or `'multiple'` or `false` | - | Optional. Set `selectionVariant` at the group level |
|
346
|
+
|
347
|
+
<br />
|
348
|
+
|
349
|
+
## Further reading
|
350
|
+
|
351
|
+
- [Interface guidelines: Action List](https://primer.style/design/components/action-list)
|
352
|
+
|
353
|
+
<br />
|
354
|
+
|
355
|
+
## Related components
|
356
|
+
|
357
|
+
- [ActionMenu](/ActionMenu)
|
358
|
+
- [SelectPanel](/SelectPanel)
|
@@ -14,6 +14,7 @@ Use StateLabel components to show the status of an issue or pull request.
|
|
14
14
|
<StateLabel status="pullClosed">Closed</StateLabel>
|
15
15
|
<StateLabel status="pullMerged">Merged</StateLabel>
|
16
16
|
<StateLabel status="draft">Draft</StateLabel>
|
17
|
+
<StateLabel status="issueDraft">Draft</StateLabel>
|
17
18
|
</>
|
18
19
|
```
|
19
20
|
|
@@ -29,7 +30,7 @@ StateLabel components get `COMMON` system props. Read our [System Props](/system
|
|
29
30
|
|
30
31
|
## Component props
|
31
32
|
|
32
|
-
| Name | Type | Default | Description
|
33
|
-
| :------ | :----- | :------: |
|
34
|
-
| variant | String | 'normal' | a value of `small` or `normal` results in a smaller or larger version of the StateLabel.
|
35
|
-
| status | String | | Can be one of `issueOpened`, `issueClosed`, `pullOpened`, `pullClosed`, `pullMerged`, or `
|
33
|
+
| Name | Type | Default | Description |
|
34
|
+
| :------ | :----- | :------: | :------------------------------------------------------------------------------------------------------------- |
|
35
|
+
| variant | String | 'normal' | a value of `small` or `normal` results in a smaller or larger version of the StateLabel. |
|
36
|
+
| status | String | | Can be one of `issueOpened`, `issueClosed`, `pullOpened`, `pullClosed`, `pullMerged`, `draft` or `issueDraft`. |
|
@@ -105,7 +105,7 @@ If you're rendering React components both server- and client-side, we suggest fo
|
|
105
105
|
|
106
106
|
## TypeScript
|
107
107
|
|
108
|
-
Primer React includes TypeScript support and ships with its own typings. You will
|
108
|
+
Primer React includes TypeScript support and ships with its own typings. You will still need to install type definitions for the peer dependencies if you import those in your own application code.
|
109
109
|
|
110
110
|
Once installed, you can import components and their prop type interfaces from the `@primer/components` package:
|
111
111
|
|
@@ -1,4 +1,6 @@
|
|
1
|
+
import React from 'react'
|
1
2
|
import * as primerComponents from '@primer/components'
|
3
|
+
import * as drafts from '@primer/components/drafts'
|
2
4
|
import * as doctocatComponents from '@primer/gatsby-theme-doctocat'
|
3
5
|
import {
|
4
6
|
CheckIcon,
|
@@ -18,6 +20,10 @@ import {
|
|
18
20
|
GearIcon,
|
19
21
|
TypographyIcon,
|
20
22
|
VersionsIcon,
|
23
|
+
LinkIcon,
|
24
|
+
LawIcon,
|
25
|
+
StarIcon,
|
26
|
+
AlertIcon,
|
21
27
|
ArrowRightIcon
|
22
28
|
} from '@primer/octicons-react'
|
23
29
|
import State from '../../../components/State'
|
@@ -26,9 +32,16 @@ import {AnchoredOverlay} from '../../../../src/AnchoredOverlay'
|
|
26
32
|
import {ConfirmationDialog, useConfirm} from '../../../../src/Dialog/ConfirmationDialog'
|
27
33
|
import {SelectPanel} from '../../../../src/SelectPanel/SelectPanel'
|
28
34
|
|
35
|
+
const ReactRouterLink = ({to, ...props}) => {
|
36
|
+
// eslint-disable-next-line jsx-a11y/anchor-has-content
|
37
|
+
return <a href={to} {...props} />
|
38
|
+
}
|
39
|
+
|
29
40
|
export default {
|
30
41
|
...doctocatComponents,
|
31
42
|
...primerComponents,
|
43
|
+
drafts,
|
44
|
+
ReactRouterLink,
|
32
45
|
State,
|
33
46
|
CheckIcon,
|
34
47
|
SearchIcon,
|
@@ -47,6 +60,10 @@ export default {
|
|
47
60
|
GearIcon,
|
48
61
|
TypographyIcon,
|
49
62
|
VersionsIcon,
|
63
|
+
LinkIcon,
|
64
|
+
LawIcon,
|
65
|
+
StarIcon,
|
66
|
+
AlertIcon,
|
50
67
|
ArrowRightIcon,
|
51
68
|
Dialog2,
|
52
69
|
ConfirmationDialog,
|
@@ -0,0 +1,29 @@
|
|
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;
|
@@ -0,0 +1,23 @@
|
|
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;
|
@@ -0,0 +1,66 @@
|
|
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.js
CHANGED
@@ -142,7 +142,7 @@ exports.TextContainer = TextContainer;
|
|
142
142
|
const BaseVisualContainer = _styledComponents.default.div.withConfig({
|
143
143
|
displayName: "Item__BaseVisualContainer",
|
144
144
|
componentId: "jqpvy8-4"
|
145
|
-
})(["height:20px;width:", ";margin-right:", ";"], (0, _constants.get)('space.3'), (0, _constants.get)('space.2'));
|
145
|
+
})(["height:20px;width:", ";margin-right:", ";display:flex;justify-content:center;align-items:center;"], (0, _constants.get)('space.3'), (0, _constants.get)('space.2'));
|
146
146
|
|
147
147
|
const ColoredVisualContainer = (0, _styledComponents.default)(BaseVisualContainer).withConfig({
|
148
148
|
displayName: "Item__ColoredVisualContainer",
|
@@ -168,10 +168,16 @@ const DescriptionContainer = _styledComponents.default.span.withConfig({
|
|
168
168
|
componentId: "jqpvy8-8"
|
169
169
|
})(["color:", ";font-size:", ";line-height:16px;margin-left:var(--description-container-margin-left);min-width:0;flex-grow:1;flex-basis:var(--description-container-flex-basis);"], (0, _constants.get)('colors.fg.muted'), (0, _constants.get)('fontSizes.0'));
|
170
170
|
|
171
|
-
const
|
172
|
-
displayName: "
|
171
|
+
const MultiSelectIcon = _styledComponents.default.svg.withConfig({
|
172
|
+
displayName: "Item__MultiSelectIcon",
|
173
173
|
componentId: "jqpvy8-9"
|
174
|
-
})(["
|
174
|
+
})(["rect{fill:", ";stroke:", ";}path{fill:", ";boxshadow:", ";opacity:", ";}"], ({
|
175
|
+
selected
|
176
|
+
}) => selected ? (0, _constants.get)('colors.accent.fg') : (0, _constants.get)('colors.canvas.default'), ({
|
177
|
+
selected
|
178
|
+
}) => selected ? (0, _constants.get)('colors.accent.fg') : (0, _constants.get)('colors.border.default'), (0, _constants.get)('colors.fg.onEmphasis'), (0, _constants.get)('shadow.small'), ({
|
179
|
+
selected
|
180
|
+
}) => selected ? 1 : 0);
|
175
181
|
/**
|
176
182
|
* An actionable or selectable `Item` with an optional icon and description.
|
177
183
|
*/
|
@@ -207,12 +213,6 @@ const Item = /*#__PURE__*/_react.default.forwardRef((itemProps, ref) => {
|
|
207
213
|
}
|
208
214
|
|
209
215
|
onKeyPress === null || onKeyPress === void 0 ? void 0 : onKeyPress(event);
|
210
|
-
const isCheckbox = event.target instanceof HTMLInputElement && event.target.type === 'checkbox';
|
211
|
-
|
212
|
-
if (isCheckbox && event.key === ' ') {
|
213
|
-
// space key on a checkbox will also trigger a click event. Ignore the space key so we don't get double events
|
214
|
-
return;
|
215
|
-
}
|
216
216
|
|
217
217
|
if (!event.defaultPrevented && [' ', 'Enter'].includes(event.key)) {
|
218
218
|
onAction === null || onAction === void 0 ? void 0 : onAction(itemProps, event);
|
@@ -250,15 +250,24 @@ const Item = /*#__PURE__*/_react.default.forwardRef((itemProps, ref) => {
|
|
250
250
|
onClick: clickHandler,
|
251
251
|
hoverBackground: disabled ? 'inherit' : hoverBackground,
|
252
252
|
focusBackground: disabled ? 'inherit' : focusBackground
|
253
|
-
}), !!selected === selected && /*#__PURE__*/_react.default.createElement(BaseVisualContainer, null, selectionVariant === 'multiple' ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
"
|
259
|
-
|
260
|
-
|
261
|
-
|
253
|
+
}), !!selected === selected && /*#__PURE__*/_react.default.createElement(BaseVisualContainer, null, selectionVariant === 'multiple' ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(MultiSelectIcon, {
|
254
|
+
selected: selected,
|
255
|
+
width: "16",
|
256
|
+
height: "16",
|
257
|
+
viewBox: "0 0 16 16",
|
258
|
+
xmlns: "http://www.w3.org/2000/svg",
|
259
|
+
"aria-hidden": "true"
|
260
|
+
}, /*#__PURE__*/_react.default.createElement("rect", {
|
261
|
+
x: "2",
|
262
|
+
y: "2",
|
263
|
+
width: "12",
|
264
|
+
height: "12",
|
265
|
+
rx: "4"
|
266
|
+
}), /*#__PURE__*/_react.default.createElement("path", {
|
267
|
+
fillRule: "evenodd",
|
268
|
+
strokeWidth: "0",
|
269
|
+
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"
|
270
|
+
}))) : selected && /*#__PURE__*/_react.default.createElement(_octiconsReact.CheckIcon, {
|
262
271
|
fill: theme === null || theme === void 0 ? void 0 : theme.colors.fg.default
|
263
272
|
})), LeadingVisual && /*#__PURE__*/_react.default.createElement(LeadingVisualContainer, {
|
264
273
|
variant: variant,
|