@primer/components 31.2.0-rc.b718ff50 → 31.2.0-rc.decfca99
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 +13 -1
- package/dist/browser.esm.js +620 -618
- package/dist/browser.esm.js.map +1 -1
- package/dist/browser.umd.js +188 -186
- package/dist/browser.umd.js.map +1 -1
- package/docs/content/ActionList2.mdx +360 -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.jsx +301 -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 +244 -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 +70 -0
- package/lib/ActionList2/Selection.jsx +36 -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.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/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.js +2 -2
- 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__/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 +7 -0
- package/lib/drafts.js +20 -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.js +161 -636
- package/lib/polyfills/eventListenerSignal.js +37 -45
- package/lib/stories/ActionList2.stories.js +908 -0
- package/lib/stories/TextInput.stories.js +144 -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/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 +210 -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 +52 -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.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/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/_TextInputWrapper.js +2 -2
- package/lib-esm/__tests__/ActionList2.test.d.ts +1 -0
- package/lib-esm/__tests__/ActionList2.test.js +41 -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 +7 -0
- package/lib-esm/drafts.js +8 -0
- package/lib-esm/stories/ActionList2.stories.js +796 -0
- package/lib-esm/stories/TextInput.stories.js +117 -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/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 +40 -0
- package/src/ActionList2/Visuals.tsx +76 -0
- package/src/ActionList2/index.ts +39 -0
- package/src/StateLabel.tsx +14 -2
- package/src/_TextInputWrapper.tsx +7 -0
- package/src/__tests__/ActionList2.test.tsx +47 -0
- package/src/__tests__/__snapshots__/ActionList2.test.tsx.snap +14 -0
- package/src/__tests__/__snapshots__/Autocomplete.test.tsx.snap +1 -0
- 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__/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 +9 -0
- package/src/stories/ActionList2.stories.tsx +1291 -0
- package/src/stories/TextInput.stories.tsx +113 -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
package/lib/Dropdown.jsx
ADDED
@@ -0,0 +1,134 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
const react_1 = __importDefault(require("react"));
|
7
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
8
|
+
const Button_1 = __importDefault(require("./Button"));
|
9
|
+
const constants_1 = require("./constants");
|
10
|
+
const Details_1 = __importDefault(require("./Details"));
|
11
|
+
const DropdownStyles_1 = __importDefault(require("./DropdownStyles"));
|
12
|
+
const useDetails_1 = __importDefault(require("./hooks/useDetails"));
|
13
|
+
const sx_1 = __importDefault(require("./sx"));
|
14
|
+
const StyledDetails = styled_components_1.default(Details_1.default) `
|
15
|
+
position: relative;
|
16
|
+
display: inline-block;
|
17
|
+
`;
|
18
|
+
const Dropdown = ({ children, className, ...rest }) => {
|
19
|
+
const { getDetailsProps } = useDetails_1.default({ closeOnOutsideClick: true });
|
20
|
+
return (<StyledDetails className={className} {...getDetailsProps()} {...rest}>
|
21
|
+
{children}
|
22
|
+
</StyledDetails>);
|
23
|
+
};
|
24
|
+
const DropdownButton = ({ children, ...rest }) => {
|
25
|
+
return (<Button_1.default as="summary" aria-haspopup="true" {...rest}>
|
26
|
+
{children}
|
27
|
+
<DropdownCaret />
|
28
|
+
</Button_1.default>);
|
29
|
+
};
|
30
|
+
const DropdownCaret = styled_components_1.default.div `
|
31
|
+
border: 4px solid transparent;
|
32
|
+
margin-left: 12px;
|
33
|
+
border-top-color: currentcolor;
|
34
|
+
border-bottom-width: 0;
|
35
|
+
content: '';
|
36
|
+
display: inline-block;
|
37
|
+
height: 0;
|
38
|
+
vertical-align: middle;
|
39
|
+
width: 0;
|
40
|
+
${constants_1.COMMON};
|
41
|
+
${sx_1.default};
|
42
|
+
`;
|
43
|
+
const DropdownMenu = styled_components_1.default.ul `
|
44
|
+
background-clip: padding-box;
|
45
|
+
background-color: ${constants_1.get('colors.canvas.overlay')};
|
46
|
+
border: 1px solid ${constants_1.get('colors.border.default')};
|
47
|
+
border-radius: ${constants_1.get('radii.2')};
|
48
|
+
box-shadow: ${constants_1.get('shadows.shadow.large')};
|
49
|
+
left: 0;
|
50
|
+
list-style: none;
|
51
|
+
margin-top: 2px;
|
52
|
+
padding: 5px 0 5px 0 !important; //TODO: fix this override on our markdown styles
|
53
|
+
position: absolute;
|
54
|
+
top: 100%;
|
55
|
+
width: 160px;
|
56
|
+
z-index: 100;
|
57
|
+
|
58
|
+
&::before {
|
59
|
+
position: absolute;
|
60
|
+
display: inline-block;
|
61
|
+
content: '';
|
62
|
+
}
|
63
|
+
|
64
|
+
&::after {
|
65
|
+
position: absolute;
|
66
|
+
display: inline-block;
|
67
|
+
content: '';
|
68
|
+
}
|
69
|
+
|
70
|
+
&::before {
|
71
|
+
border: 8px solid transparent;
|
72
|
+
border-bottom-color: ${constants_1.get('colors.canvas.overlay')};
|
73
|
+
}
|
74
|
+
|
75
|
+
&::after {
|
76
|
+
border: 7px solid transparent;
|
77
|
+
border-bottom-color: ${constants_1.get('colors.canvas.overlay')};
|
78
|
+
}
|
79
|
+
|
80
|
+
// stylelint-disable-next-line selector-max-type
|
81
|
+
> ul {
|
82
|
+
list-style: none;
|
83
|
+
}
|
84
|
+
${props => (props.direction ? DropdownStyles_1.default(props.theme, props.direction) : '')};
|
85
|
+
${constants_1.COMMON};
|
86
|
+
${sx_1.default};
|
87
|
+
`;
|
88
|
+
const DropdownItem = styled_components_1.default.li `
|
89
|
+
display: block;
|
90
|
+
padding: ${constants_1.get('space.1')} 10px ${constants_1.get('space.1')} 15px;
|
91
|
+
overflow: hidden;
|
92
|
+
color: ${constants_1.get('colors.fg.default')};
|
93
|
+
text-overflow: ellipsis;
|
94
|
+
white-space: nowrap;
|
95
|
+
a {
|
96
|
+
color: ${constants_1.get('colors.fg.default')};
|
97
|
+
text-decoration: none;
|
98
|
+
display: block;
|
99
|
+
overflow: hidden;
|
100
|
+
color: ${constants_1.get('colors.fg.default')};
|
101
|
+
text-overflow: ellipsis;
|
102
|
+
white-space: nowrap;
|
103
|
+
}
|
104
|
+
|
105
|
+
&:focus,
|
106
|
+
a:focus {
|
107
|
+
color: ${constants_1.get('colors.fg.onEmphasis')};
|
108
|
+
text-decoration: none;
|
109
|
+
background-color: ${constants_1.get('colors.accent.emphasis')};
|
110
|
+
}
|
111
|
+
|
112
|
+
&:hover,
|
113
|
+
&:hover a {
|
114
|
+
color: ${constants_1.get('colors.fg.onEmphasis')};
|
115
|
+
text-decoration: none;
|
116
|
+
background-color: ${constants_1.get('colors.accent.emphasis')};
|
117
|
+
outline: none;
|
118
|
+
}
|
119
|
+
${constants_1.COMMON};
|
120
|
+
${sx_1.default};
|
121
|
+
`;
|
122
|
+
DropdownMenu.defaultProps = { direction: 'sw' };
|
123
|
+
DropdownMenu.displayName = 'Dropdown.Menu';
|
124
|
+
DropdownItem.displayName = 'Dropdown.Item';
|
125
|
+
DropdownButton.defaultProps = Button_1.default.defaultProps;
|
126
|
+
DropdownButton.displayName = 'Dropdown.Button';
|
127
|
+
DropdownCaret.displayName = 'Dropdown.Caret';
|
128
|
+
Dropdown.defaultProps = Details_1.default.defaultProps;
|
129
|
+
exports.default = Object.assign(Dropdown, {
|
130
|
+
Caret: DropdownCaret,
|
131
|
+
Menu: DropdownMenu,
|
132
|
+
Item: DropdownItem,
|
133
|
+
Button: DropdownButton
|
134
|
+
});
|
@@ -37,6 +37,28 @@ export declare const DropdownButton: React.ForwardRefExoticComponent<Pick<React.
|
|
37
37
|
slot?: string | undefined;
|
38
38
|
style?: React.CSSProperties | undefined;
|
39
39
|
title?: string | undefined;
|
40
|
+
bg?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
41
|
+
m?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
42
|
+
mt?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
43
|
+
mr?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
44
|
+
mb?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
45
|
+
ml?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
46
|
+
mx?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
47
|
+
marginX?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
48
|
+
my?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
49
|
+
marginY?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
50
|
+
pt?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
51
|
+
pr?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
52
|
+
pb?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
53
|
+
pl?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
54
|
+
px?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
55
|
+
paddingX?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
56
|
+
py?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
57
|
+
paddingY?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
58
|
+
size?: import("styled-system").ResponsiveValue<import("csstype").Property.Height<import("styled-system").TLengthStyledSystem>, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
59
|
+
sx?: import("../sx").BetterSystemStyleObject | undefined;
|
60
|
+
variant?: "small" | "medium" | "large" | undefined;
|
61
|
+
role?: React.AriaRole | undefined;
|
40
62
|
type?: "button" | "reset" | "submit" | undefined;
|
41
63
|
name?: string | undefined;
|
42
64
|
key?: React.Key | null | undefined;
|
@@ -46,17 +68,16 @@ export declare const DropdownButton: React.ForwardRefExoticComponent<Pick<React.
|
|
46
68
|
suppressHydrationWarning?: boolean | undefined;
|
47
69
|
accessKey?: string | undefined;
|
48
70
|
className?: string | undefined;
|
49
|
-
contentEditable?: "inherit" | (boolean | "
|
71
|
+
contentEditable?: "inherit" | (boolean | "false" | "true") | undefined;
|
50
72
|
contextMenu?: string | undefined;
|
51
73
|
dir?: string | undefined;
|
52
|
-
draggable?: (boolean | "
|
74
|
+
draggable?: (boolean | "false" | "true") | undefined;
|
53
75
|
id?: string | undefined;
|
54
76
|
lang?: string | undefined;
|
55
77
|
placeholder?: string | undefined;
|
56
|
-
spellCheck?: (boolean | "
|
78
|
+
spellCheck?: (boolean | "false" | "true") | undefined;
|
57
79
|
tabIndex?: number | undefined;
|
58
80
|
radioGroup?: string | undefined;
|
59
|
-
role?: React.AriaRole | undefined;
|
60
81
|
about?: string | undefined;
|
61
82
|
datatype?: string | undefined;
|
62
83
|
inlist?: any;
|
@@ -79,47 +100,47 @@ export declare const DropdownButton: React.ForwardRefExoticComponent<Pick<React.
|
|
79
100
|
inputMode?: "search" | "none" | "text" | "tel" | "url" | "email" | "numeric" | "decimal" | undefined;
|
80
101
|
is?: string | undefined;
|
81
102
|
'aria-activedescendant'?: string | undefined;
|
82
|
-
'aria-atomic'?: boolean | "
|
83
|
-
'aria-autocomplete'?: "none" | "
|
84
|
-
'aria-busy'?: boolean | "
|
85
|
-
'aria-checked'?: boolean | "
|
103
|
+
'aria-atomic'?: boolean | "false" | "true" | undefined;
|
104
|
+
'aria-autocomplete'?: "none" | "both" | "inline" | "list" | undefined;
|
105
|
+
'aria-busy'?: boolean | "false" | "true" | undefined;
|
106
|
+
'aria-checked'?: boolean | "mixed" | "false" | "true" | undefined;
|
86
107
|
'aria-colcount'?: number | undefined;
|
87
108
|
'aria-colindex'?: number | undefined;
|
88
109
|
'aria-colspan'?: number | undefined;
|
89
110
|
'aria-controls'?: string | undefined;
|
90
|
-
'aria-current'?: boolean | "time" | "
|
111
|
+
'aria-current'?: boolean | "time" | "page" | "false" | "true" | "step" | "location" | "date" | undefined;
|
91
112
|
'aria-describedby'?: string | undefined;
|
92
113
|
'aria-details'?: string | undefined;
|
93
|
-
'aria-disabled'?: boolean | "
|
94
|
-
'aria-dropeffect'?: "link" | "none" | "copy" | "
|
114
|
+
'aria-disabled'?: boolean | "false" | "true" | undefined;
|
115
|
+
'aria-dropeffect'?: "link" | "none" | "copy" | "move" | "execute" | "popup" | undefined;
|
95
116
|
'aria-errormessage'?: string | undefined;
|
96
|
-
'aria-expanded'?: boolean | "
|
117
|
+
'aria-expanded'?: boolean | "false" | "true" | undefined;
|
97
118
|
'aria-flowto'?: string | undefined;
|
98
|
-
'aria-grabbed'?: boolean | "
|
99
|
-
'aria-haspopup'?: boolean | "grid" | "dialog" | "menu" | "listbox" | "
|
100
|
-
'aria-hidden'?: boolean | "
|
101
|
-
'aria-invalid'?: boolean | "
|
119
|
+
'aria-grabbed'?: boolean | "false" | "true" | undefined;
|
120
|
+
'aria-haspopup'?: boolean | "grid" | "dialog" | "menu" | "listbox" | "false" | "true" | "tree" | undefined;
|
121
|
+
'aria-hidden'?: boolean | "false" | "true" | undefined;
|
122
|
+
'aria-invalid'?: boolean | "false" | "true" | "grammar" | "spelling" | undefined;
|
102
123
|
'aria-keyshortcuts'?: string | undefined;
|
103
124
|
'aria-label'?: string | undefined;
|
104
125
|
'aria-labelledby'?: string | undefined;
|
105
126
|
'aria-level'?: number | undefined;
|
106
127
|
'aria-live'?: "off" | "assertive" | "polite" | undefined;
|
107
|
-
'aria-modal'?: boolean | "
|
108
|
-
'aria-multiline'?: boolean | "
|
109
|
-
'aria-multiselectable'?: boolean | "
|
128
|
+
'aria-modal'?: boolean | "false" | "true" | undefined;
|
129
|
+
'aria-multiline'?: boolean | "false" | "true" | undefined;
|
130
|
+
'aria-multiselectable'?: boolean | "false" | "true" | undefined;
|
110
131
|
'aria-orientation'?: "horizontal" | "vertical" | undefined;
|
111
132
|
'aria-owns'?: string | undefined;
|
112
133
|
'aria-placeholder'?: string | undefined;
|
113
134
|
'aria-posinset'?: number | undefined;
|
114
|
-
'aria-pressed'?: boolean | "
|
115
|
-
'aria-readonly'?: boolean | "
|
135
|
+
'aria-pressed'?: boolean | "mixed" | "false" | "true" | undefined;
|
136
|
+
'aria-readonly'?: boolean | "false" | "true" | undefined;
|
116
137
|
'aria-relevant'?: "all" | "text" | "additions" | "additions removals" | "additions text" | "removals" | "removals additions" | "removals text" | "text additions" | "text removals" | undefined;
|
117
|
-
'aria-required'?: boolean | "
|
138
|
+
'aria-required'?: boolean | "false" | "true" | undefined;
|
118
139
|
'aria-roledescription'?: string | undefined;
|
119
140
|
'aria-rowcount'?: number | undefined;
|
120
141
|
'aria-rowindex'?: number | undefined;
|
121
142
|
'aria-rowspan'?: number | undefined;
|
122
|
-
'aria-selected'?: boolean | "
|
143
|
+
'aria-selected'?: boolean | "false" | "true" | undefined;
|
123
144
|
'aria-setsize'?: number | undefined;
|
124
145
|
'aria-sort'?: "none" | "ascending" | "descending" | "other" | undefined;
|
125
146
|
'aria-valuemax'?: number | undefined;
|
@@ -289,35 +310,14 @@ export declare const DropdownButton: React.ForwardRefExoticComponent<Pick<React.
|
|
289
310
|
onAnimationIterationCapture?: React.AnimationEventHandler<HTMLButtonElement> | undefined;
|
290
311
|
onTransitionEnd?: React.TransitionEventHandler<HTMLButtonElement> | undefined;
|
291
312
|
onTransitionEndCapture?: React.TransitionEventHandler<HTMLButtonElement> | undefined;
|
292
|
-
bg?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
293
|
-
m?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
294
|
-
mt?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
295
|
-
mr?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
296
|
-
mb?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
297
|
-
ml?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
298
|
-
mx?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
299
|
-
marginX?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
300
|
-
my?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
301
|
-
marginY?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
302
|
-
pt?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
303
|
-
pr?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
304
|
-
pb?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
305
|
-
pl?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
306
|
-
px?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
307
|
-
paddingX?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
308
|
-
py?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
309
|
-
paddingY?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
310
|
-
size?: import("styled-system").ResponsiveValue<import("csstype").Property.Height<import("styled-system").TLengthStyledSystem>, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
311
|
-
sx?: import("../sx").BetterSystemStyleObject | undefined;
|
312
313
|
as?: string | React.ComponentClass<any, any> | React.FunctionComponent<any> | undefined;
|
313
|
-
autoFocus?: boolean | undefined;
|
314
314
|
disabled?: boolean | undefined;
|
315
|
+
autoFocus?: boolean | undefined;
|
315
316
|
formAction?: string | undefined;
|
316
317
|
formEncType?: string | undefined;
|
317
318
|
formMethod?: string | undefined;
|
318
319
|
formNoValidate?: boolean | undefined;
|
319
320
|
formTarget?: string | undefined;
|
320
|
-
variant?: "small" | "medium" | "large" | undefined;
|
321
321
|
} & {
|
322
322
|
theme?: any;
|
323
|
-
}>, "backgroundColor" | "color" | "display" | "fontSize" | "height" | "marginBottom" | "marginLeft" | "marginRight" | "marginTop" | "maxHeight" | "maxWidth" | "minHeight" | "minWidth" | "opacity" | "overflowX" | "overflowY" | "paddingBottom" | "paddingLeft" | "paddingRight" | "paddingTop" | "translate" | "verticalAlign" | "width" | "margin" | "overflow" | "padding" | "hidden" | "children" | "theme" | "value" | "form" | "p" | "slot" | "style" | "title" | "type" | "name" | "key" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "id" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "radioGroup" | "
|
323
|
+
}>, "backgroundColor" | "color" | "display" | "fontSize" | "height" | "marginBottom" | "marginLeft" | "marginRight" | "marginTop" | "maxHeight" | "maxWidth" | "minHeight" | "minWidth" | "opacity" | "overflowX" | "overflowY" | "paddingBottom" | "paddingLeft" | "paddingRight" | "paddingTop" | "translate" | "verticalAlign" | "width" | "margin" | "overflow" | "padding" | "hidden" | "children" | "theme" | "value" | "form" | "p" | "slot" | "style" | "title" | "bg" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "marginX" | "my" | "marginY" | "pt" | "pr" | "pb" | "pl" | "px" | "paddingX" | "py" | "paddingY" | "size" | "sx" | "variant" | "role" | "type" | "name" | "key" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "id" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "radioGroup" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "as" | "disabled" | "autoFocus" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget"> & React.RefAttributes<HTMLElement>>;
|
@@ -0,0 +1,14 @@
|
|
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.DropdownButton = void 0;
|
7
|
+
const react_1 = __importDefault(require("react"));
|
8
|
+
const octicons_react_1 = require("@primer/octicons-react");
|
9
|
+
const Button_1 = __importDefault(require("../Button/Button"));
|
10
|
+
const StyledOcticon_1 = __importDefault(require("../StyledOcticon"));
|
11
|
+
exports.DropdownButton = react_1.default.forwardRef(({ children, ...props }, ref) => (<Button_1.default ref={ref} type="button" {...props}>
|
12
|
+
{children}
|
13
|
+
<StyledOcticon_1.default icon={octicons_react_1.TriangleDownIcon} ml={1}/>
|
14
|
+
</Button_1.default>));
|
@@ -0,0 +1,70 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
5
|
+
}) : (function(o, m, k, k2) {
|
6
|
+
if (k2 === undefined) k2 = k;
|
7
|
+
o[k2] = m[k];
|
8
|
+
}));
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
11
|
+
}) : function(o, v) {
|
12
|
+
o["default"] = v;
|
13
|
+
});
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
15
|
+
if (mod && mod.__esModule) return mod;
|
16
|
+
var result = {};
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
18
|
+
__setModuleDefault(result, mod);
|
19
|
+
return result;
|
20
|
+
};
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
22
|
+
exports.DropdownMenu = void 0;
|
23
|
+
const react_1 = __importStar(require("react"));
|
24
|
+
const List_1 = require("../ActionList/List");
|
25
|
+
const DropdownButton_1 = require("./DropdownButton");
|
26
|
+
const AnchoredOverlay_1 = require("../AnchoredOverlay");
|
27
|
+
const useProvidedRefOrCreate_1 = require("../hooks/useProvidedRefOrCreate");
|
28
|
+
const useProvidedStateOrCreate_1 = require("../hooks/useProvidedStateOrCreate");
|
29
|
+
/**
|
30
|
+
* A `DropdownMenu` provides an anchor (button by default) that will open a floating menu of selectable items. The menu can be
|
31
|
+
* opened and navigated using keyboard or mouse. When an item is selected, the menu will close and the `onChange` callback will be called.
|
32
|
+
* If the default anchor button is used, the anchor contents will be updated with the selection.
|
33
|
+
*/
|
34
|
+
function DropdownMenu({ renderAnchor = (props) => <DropdownButton_1.DropdownButton {...props}/>, anchorRef: externalAnchorRef, placeholder, selectedItem, onChange, overlayProps, items, open, onOpenChange, ...listProps }) {
|
35
|
+
const [combinedOpenState, setCombinedOpenState] = useProvidedStateOrCreate_1.useProvidedStateOrCreate(open, onOpenChange, false);
|
36
|
+
const onOpen = react_1.useCallback(() => setCombinedOpenState(true), [setCombinedOpenState]);
|
37
|
+
const onClose = react_1.useCallback(() => setCombinedOpenState(false), [setCombinedOpenState]);
|
38
|
+
const anchorRef = useProvidedRefOrCreate_1.useProvidedRefOrCreate(externalAnchorRef);
|
39
|
+
const renderMenuAnchor = react_1.useMemo(() => {
|
40
|
+
if (renderAnchor === null) {
|
41
|
+
return null;
|
42
|
+
}
|
43
|
+
return (props) => renderAnchor({
|
44
|
+
...props,
|
45
|
+
children: selectedItem?.text ?? placeholder
|
46
|
+
});
|
47
|
+
}, [placeholder, renderAnchor, selectedItem?.text]);
|
48
|
+
const itemsToRender = react_1.useMemo(() => {
|
49
|
+
return items.map(item => {
|
50
|
+
return {
|
51
|
+
...item,
|
52
|
+
role: 'option',
|
53
|
+
selected: item === selectedItem,
|
54
|
+
onAction: (itemFromAction, event) => {
|
55
|
+
item.onAction?.(itemFromAction, event);
|
56
|
+
if (event.defaultPrevented) {
|
57
|
+
return;
|
58
|
+
}
|
59
|
+
onClose();
|
60
|
+
onChange?.(item === selectedItem ? undefined : item);
|
61
|
+
}
|
62
|
+
};
|
63
|
+
});
|
64
|
+
}, [items, onChange, onClose, selectedItem]);
|
65
|
+
return (<AnchoredOverlay_1.AnchoredOverlay renderAnchor={renderMenuAnchor} anchorRef={anchorRef} open={combinedOpenState} onOpen={onOpen} onClose={onClose} overlayProps={overlayProps}>
|
66
|
+
<List_1.List {...listProps} role="listbox" items={itemsToRender}/>
|
67
|
+
</AnchoredOverlay_1.AnchoredOverlay>);
|
68
|
+
}
|
69
|
+
exports.DropdownMenu = DropdownMenu;
|
70
|
+
DropdownMenu.displayName = 'DropdownMenu';
|
@@ -1,21 +1,7 @@
|
|
1
1
|
"use strict";
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
});
|
6
|
-
|
7
|
-
|
8
|
-
get: function () {
|
9
|
-
return _DropdownMenu.DropdownMenu;
|
10
|
-
}
|
11
|
-
});
|
12
|
-
Object.defineProperty(exports, "DropdownButton", {
|
13
|
-
enumerable: true,
|
14
|
-
get: function () {
|
15
|
-
return _DropdownButton.DropdownButton;
|
16
|
-
}
|
17
|
-
});
|
18
|
-
|
19
|
-
var _DropdownMenu = require("./DropdownMenu");
|
20
|
-
|
21
|
-
var _DropdownButton = require("./DropdownButton");
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.DropdownButton = exports.DropdownMenu = void 0;
|
4
|
+
var DropdownMenu_1 = require("./DropdownMenu");
|
5
|
+
Object.defineProperty(exports, "DropdownMenu", { enumerable: true, get: function () { return DropdownMenu_1.DropdownMenu; } });
|
6
|
+
var DropdownButton_1 = require("./DropdownButton");
|
7
|
+
Object.defineProperty(exports, "DropdownButton", { enumerable: true, get: function () { return DropdownButton_1.DropdownButton; } });
|
package/lib/DropdownStyles.js
CHANGED
@@ -1,15 +1,9 @@
|
|
1
1
|
"use strict";
|
2
|
-
|
3
|
-
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports.default = void 0;
|
7
|
-
|
8
|
-
var _constants = require("./constants");
|
9
|
-
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
const constants_1 = require("./constants");
|
10
4
|
const getDirectionStyles = (theme, direction) => {
|
11
|
-
|
12
|
-
|
5
|
+
const map = {
|
6
|
+
w: `
|
13
7
|
top: 0;
|
14
8
|
right: 100%;
|
15
9
|
left: auto;
|
@@ -22,7 +16,7 @@ const getDirectionStyles = (theme, direction) => {
|
|
22
16
|
right: -16px;
|
23
17
|
left: auto;
|
24
18
|
border-color: transparent;
|
25
|
-
border-left-color: ${
|
19
|
+
border-left-color: ${constants_1.get('colors.border.default')(theme)};
|
26
20
|
}
|
27
21
|
|
28
22
|
&::after {
|
@@ -30,10 +24,10 @@ const getDirectionStyles = (theme, direction) => {
|
|
30
24
|
right: -14px;
|
31
25
|
left: auto;
|
32
26
|
border-color: transparent;
|
33
|
-
border-left-color: ${
|
27
|
+
border-left-color: ${constants_1.get('colors.border.default')(theme)};
|
34
28
|
}
|
35
29
|
`,
|
36
|
-
|
30
|
+
e: `
|
37
31
|
top: 0;
|
38
32
|
left: 100%;
|
39
33
|
width: auto;
|
@@ -44,17 +38,17 @@ const getDirectionStyles = (theme, direction) => {
|
|
44
38
|
top: 10px;
|
45
39
|
left: -16px;
|
46
40
|
border-color: transparent;
|
47
|
-
border-right-color: ${
|
41
|
+
border-right-color: ${constants_1.get('colors.border.default')(theme)};
|
48
42
|
}
|
49
43
|
|
50
44
|
&::after {
|
51
45
|
top: 11px;
|
52
46
|
left: -14px;
|
53
47
|
border-color: transparent;
|
54
|
-
border-right-color: ${
|
48
|
+
border-right-color: ${constants_1.get('colors.border.default')(theme)};
|
55
49
|
}
|
56
50
|
`,
|
57
|
-
|
51
|
+
ne: `
|
58
52
|
top: auto;
|
59
53
|
bottom: 100%;
|
60
54
|
left: 0;
|
@@ -69,7 +63,7 @@ const getDirectionStyles = (theme, direction) => {
|
|
69
63
|
&::before {
|
70
64
|
bottom: -8px;
|
71
65
|
left: 9px;
|
72
|
-
border-top: 8px solid ${
|
66
|
+
border-top: 8px solid ${constants_1.get('colors.border.default')(theme)};
|
73
67
|
border-bottom: 0;
|
74
68
|
border-left: 8px solid transparent;
|
75
69
|
}
|
@@ -77,13 +71,13 @@ const getDirectionStyles = (theme, direction) => {
|
|
77
71
|
&::after {
|
78
72
|
bottom: -7px;
|
79
73
|
left: 10px;
|
80
|
-
border-top: 7px solid ${
|
74
|
+
border-top: 7px solid ${constants_1.get('colors.border.default')(theme)};
|
81
75
|
border-right: 7px solid transparent;
|
82
76
|
border-bottom: 0;
|
83
77
|
border-left: 7px solid transparent;
|
84
78
|
}
|
85
79
|
`,
|
86
|
-
|
80
|
+
s: `
|
87
81
|
right: 50%;
|
88
82
|
left: auto;
|
89
83
|
transform: translateX(50%);
|
@@ -100,7 +94,7 @@ const getDirectionStyles = (theme, direction) => {
|
|
100
94
|
transform: translateX(50%);
|
101
95
|
}
|
102
96
|
`,
|
103
|
-
|
97
|
+
sw: `
|
104
98
|
right: 0;
|
105
99
|
left: auto;
|
106
100
|
|
@@ -116,7 +110,7 @@ const getDirectionStyles = (theme, direction) => {
|
|
116
110
|
left: auto;
|
117
111
|
}
|
118
112
|
`,
|
119
|
-
|
113
|
+
se: `
|
120
114
|
&::before {
|
121
115
|
top: -16px;
|
122
116
|
left: 9px;
|
@@ -127,9 +121,7 @@ const getDirectionStyles = (theme, direction) => {
|
|
127
121
|
left: 10px;
|
128
122
|
}
|
129
123
|
`
|
130
|
-
|
131
|
-
|
124
|
+
};
|
125
|
+
return map[direction];
|
132
126
|
};
|
133
|
-
|
134
|
-
var _default = getDirectionStyles;
|
135
|
-
exports.default = _default;
|
127
|
+
exports.default = getDirectionStyles;
|