@primer/components 0.0.0-20211030175556 → 0.0.0-20211030175634

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.
Files changed (248) hide show
  1. package/CHANGELOG.md +24 -2
  2. package/dist/browser.esm.js +144 -137
  3. package/dist/browser.esm.js.map +1 -1
  4. package/dist/browser.umd.js +128 -121
  5. package/dist/browser.umd.js.map +1 -1
  6. package/lib/ActionList/Item.js +3 -3
  7. package/lib/ActionList/index.js +23 -12
  8. package/lib/ActionList2/Item.js +3 -1
  9. package/lib/ActionList2/List.js +1 -2
  10. package/lib/ActionList2/Selection.js +3 -1
  11. package/lib/ActionList2/index.js +41 -23
  12. package/lib/AnchoredOverlay/index.js +12 -4
  13. package/lib/Autocomplete/Autocomplete.d.ts +1 -0
  14. package/lib/Autocomplete/AutocompleteInput.d.ts +1 -0
  15. package/lib/Autocomplete/index.js +14 -7
  16. package/lib/Button/Button.d.ts +1 -0
  17. package/lib/Button/ButtonClose.d.ts +2 -1
  18. package/lib/Button/ButtonDanger.d.ts +1 -0
  19. package/lib/Button/ButtonInvisible.d.ts +1 -0
  20. package/lib/Button/ButtonOutline.d.ts +1 -0
  21. package/lib/Button/ButtonPrimary.d.ts +1 -0
  22. package/lib/Button/index.js +70 -21
  23. package/lib/Checkbox.d.ts +29 -0
  24. package/lib/Checkbox.js +64 -0
  25. package/lib/CircleOcticon.d.ts +1 -0
  26. package/lib/Dialog.d.ts +3 -2
  27. package/lib/Dropdown.d.ts +4 -0
  28. package/lib/DropdownMenu/DropdownButton.d.ts +2 -1
  29. package/lib/DropdownMenu/index.js +20 -6
  30. package/lib/DropdownStyles.js +26 -18
  31. package/lib/FilterList.d.ts +1 -0
  32. package/lib/FilteredActionList/index.js +12 -4
  33. package/lib/NewButton/index.js +12 -5
  34. package/lib/NewButton/types.js +1 -2
  35. package/lib/Overlay.d.ts +5 -3
  36. package/lib/Pagination/index.js +12 -6
  37. package/lib/Portal/index.js +16 -5
  38. package/lib/Position.d.ts +4 -4
  39. package/lib/SelectMenu/SelectMenu.d.ts +10 -4
  40. package/lib/SelectMenu/SelectMenuItem.d.ts +1 -1
  41. package/lib/SelectMenu/SelectMenuModal.d.ts +1 -1
  42. package/lib/SelectMenu/hooks/useKeyboardNav.js +96 -80
  43. package/lib/SelectMenu/index.js +14 -7
  44. package/lib/SelectPanel/index.js +12 -4
  45. package/lib/TextInputWithTokens.d.ts +1 -0
  46. package/lib/Token/AvatarToken.d.ts +1 -1
  47. package/lib/Token/IssueLabelToken.d.ts +1 -1
  48. package/lib/Token/Token.d.ts +1 -1
  49. package/lib/Token/index.js +30 -11
  50. package/lib/behaviors/anchoredPosition.js +234 -205
  51. package/lib/behaviors/focusTrap.js +157 -121
  52. package/lib/behaviors/focusZone.js +509 -434
  53. package/lib/behaviors/scrollIntoViewingArea.js +35 -18
  54. package/lib/constants.js +43 -39
  55. package/lib/drafts.js +30 -20
  56. package/lib/hooks/index.js +60 -16
  57. package/lib/hooks/useAnchoredPosition.js +40 -32
  58. package/lib/hooks/useCombinedRefs.js +36 -32
  59. package/lib/hooks/useDialog.js +96 -72
  60. package/lib/hooks/useFocusTrap.js +60 -43
  61. package/lib/hooks/useFocusZone.js +50 -54
  62. package/lib/hooks/useOnEscapePress.js +36 -25
  63. package/lib/hooks/useOpenAndCloseFocus.js +34 -22
  64. package/lib/hooks/useProvidedRefOrCreate.js +14 -10
  65. package/lib/hooks/useProvidedStateOrCreate.js +16 -13
  66. package/lib/hooks/useRenderForcingRef.js +17 -13
  67. package/lib/hooks/useResizeObserver.js +18 -15
  68. package/lib/hooks/useSafeTimeout.js +30 -22
  69. package/lib/hooks/useScrollFlash.js +23 -16
  70. package/lib/index.d.ts +2 -0
  71. package/lib/index.js +652 -163
  72. package/lib/polyfills/eventListenerSignal.js +45 -37
  73. package/lib/sx.js +22 -10
  74. package/lib/theme-preval.js +3169 -64
  75. package/lib/theme.js +12 -3
  76. package/lib/utils/iterateFocusableElements.js +85 -63
  77. package/lib/utils/testing.d.ts +2 -1
  78. package/lib/utils/testing.js +29 -0
  79. package/lib/utils/theme.js +47 -33
  80. package/lib/utils/types/AriaRole.js +1 -2
  81. package/lib/utils/types/ComponentProps.js +1 -2
  82. package/lib/utils/types/Flatten.js +1 -2
  83. package/lib/utils/types/KeyPaths.js +1 -2
  84. package/lib/utils/types/MandateProps.js +1 -16
  85. package/lib/utils/types/Merge.js +1 -2
  86. package/lib/utils/types/index.js +69 -16
  87. package/lib/utils/uniqueId.js +8 -5
  88. package/lib/utils/use-force-update.js +14 -8
  89. package/lib/utils/useIsomorphicLayoutEffect.js +11 -8
  90. package/lib/utils/userAgent.js +12 -8
  91. package/lib-esm/ActionList/Item.js +3 -3
  92. package/lib-esm/ActionList2/Item.js +3 -1
  93. package/lib-esm/ActionList2/List.js +1 -2
  94. package/lib-esm/ActionList2/Selection.js +3 -1
  95. package/lib-esm/Autocomplete/Autocomplete.d.ts +1 -0
  96. package/lib-esm/Autocomplete/AutocompleteInput.d.ts +1 -0
  97. package/lib-esm/Button/Button.d.ts +1 -0
  98. package/lib-esm/Button/ButtonClose.d.ts +2 -1
  99. package/lib-esm/Button/ButtonDanger.d.ts +1 -0
  100. package/lib-esm/Button/ButtonInvisible.d.ts +1 -0
  101. package/lib-esm/Button/ButtonOutline.d.ts +1 -0
  102. package/lib-esm/Button/ButtonPrimary.d.ts +1 -0
  103. package/lib-esm/Checkbox.d.ts +29 -0
  104. package/lib-esm/Checkbox.js +44 -0
  105. package/lib-esm/CircleOcticon.d.ts +1 -0
  106. package/lib-esm/Dialog.d.ts +3 -2
  107. package/lib-esm/Dropdown.d.ts +4 -0
  108. package/lib-esm/DropdownMenu/DropdownButton.d.ts +2 -1
  109. package/lib-esm/FilterList.d.ts +1 -0
  110. package/lib-esm/Overlay.d.ts +5 -3
  111. package/lib-esm/Position.d.ts +4 -4
  112. package/lib-esm/SelectMenu/SelectMenu.d.ts +10 -4
  113. package/lib-esm/SelectMenu/SelectMenuItem.d.ts +1 -1
  114. package/lib-esm/SelectMenu/SelectMenuModal.d.ts +1 -1
  115. package/lib-esm/TextInputWithTokens.d.ts +1 -0
  116. package/lib-esm/Token/AvatarToken.d.ts +1 -1
  117. package/lib-esm/Token/IssueLabelToken.d.ts +1 -1
  118. package/lib-esm/Token/Token.d.ts +1 -1
  119. package/lib-esm/index.d.ts +2 -0
  120. package/lib-esm/index.js +1 -0
  121. package/lib-esm/theme-preval.js +446 -0
  122. package/lib-esm/utils/testing.d.ts +2 -1
  123. package/lib-esm/utils/testing.js +24 -0
  124. package/package.json +4 -5
  125. package/lib/ActionList/Divider.jsx +0 -29
  126. package/lib/ActionList/Group.jsx +0 -23
  127. package/lib/ActionList/Header.jsx +0 -66
  128. package/lib/ActionList/Item.jsx +0 -288
  129. package/lib/ActionList/List.jsx +0 -138
  130. package/lib/ActionList2/Description.jsx +0 -29
  131. package/lib/ActionList2/Divider.jsx +0 -22
  132. package/lib/ActionList2/Group.jsx +0 -54
  133. package/lib/ActionList2/Header.d.ts +0 -26
  134. package/lib/ActionList2/Header.js +0 -55
  135. package/lib/ActionList2/Header.jsx +0 -36
  136. package/lib/ActionList2/Item.jsx +0 -174
  137. package/lib/ActionList2/LinkItem.jsx +0 -28
  138. package/lib/ActionList2/List.jsx +0 -41
  139. package/lib/ActionList2/Selection.jsx +0 -50
  140. package/lib/ActionList2/Visuals.jsx +0 -48
  141. package/lib/ActionMenu.jsx +0 -73
  142. package/lib/AnchoredOverlay/AnchoredOverlay.jsx +0 -100
  143. package/lib/Autocomplete/Autocomplete.jsx +0 -100
  144. package/lib/Autocomplete/AutocompleteContext.jsx +0 -5
  145. package/lib/Autocomplete/AutocompleteInput.jsx +0 -113
  146. package/lib/Autocomplete/AutocompleteMenu.jsx +0 -190
  147. package/lib/Autocomplete/AutocompleteOverlay.jsx +0 -55
  148. package/lib/Avatar.jsx +0 -34
  149. package/lib/AvatarPair.jsx +0 -29
  150. package/lib/AvatarStack.jsx +0 -151
  151. package/lib/BaseStyles.jsx +0 -65
  152. package/lib/BorderBox.jsx +0 -18
  153. package/lib/Box.jsx +0 -10
  154. package/lib/BranchName.jsx +0 -20
  155. package/lib/Breadcrumbs.jsx +0 -71
  156. package/lib/Button/Button.jsx +0 -40
  157. package/lib/Button/ButtonBase.jsx +0 -33
  158. package/lib/Button/ButtonClose.jsx +0 -53
  159. package/lib/Button/ButtonDanger.jsx +0 -43
  160. package/lib/Button/ButtonGroup.jsx +0 -55
  161. package/lib/Button/ButtonInvisible.jsx +0 -32
  162. package/lib/Button/ButtonOutline.jsx +0 -43
  163. package/lib/Button/ButtonPrimary.jsx +0 -42
  164. package/lib/Button/ButtonStyles.jsx +0 -37
  165. package/lib/Button/ButtonTableList.jsx +0 -46
  166. package/lib/Caret.jsx +0 -93
  167. package/lib/CircleBadge.jsx +0 -42
  168. package/lib/CircleOcticon.jsx +0 -21
  169. package/lib/CounterLabel.jsx +0 -43
  170. package/lib/Details.jsx +0 -21
  171. package/lib/Dialog/ConfirmationDialog.jsx +0 -146
  172. package/lib/Dialog/Dialog.jsx +0 -279
  173. package/lib/Dialog.jsx +0 -129
  174. package/lib/Dropdown.jsx +0 -131
  175. package/lib/DropdownMenu/DropdownButton.jsx +0 -14
  176. package/lib/DropdownMenu/DropdownMenu.jsx +0 -70
  177. package/lib/FilterList.jsx +0 -59
  178. package/lib/FilteredActionList/FilteredActionList.jsx +0 -100
  179. package/lib/FilteredSearch.jsx +0 -28
  180. package/lib/Flash.jsx +0 -69
  181. package/lib/Flex.jsx +0 -15
  182. package/lib/FormGroup.jsx +0 -22
  183. package/lib/Grid.jsx +0 -15
  184. package/lib/Header.jsx +0 -83
  185. package/lib/Heading.jsx +0 -21
  186. package/lib/Label.jsx +0 -82
  187. package/lib/LabelGroup.jsx +0 -18
  188. package/lib/Link.jsx +0 -36
  189. package/lib/NewButton/button-counter.jsx +0 -14
  190. package/lib/NewButton/button.jsx +0 -279
  191. package/lib/Overlay.jsx +0 -154
  192. package/lib/Pagehead.jsx +0 -17
  193. package/lib/Pagination/Pagination.jsx +0 -161
  194. package/lib/Pagination/model.jsx +0 -174
  195. package/lib/PointerBox.jsx +0 -25
  196. package/lib/Popover.jsx +0 -202
  197. package/lib/Portal/Portal.jsx +0 -79
  198. package/lib/Position.jsx +0 -46
  199. package/lib/ProgressBar.jsx +0 -39
  200. package/lib/SelectMenu/SelectMenu.jsx +0 -112
  201. package/lib/SelectMenu/SelectMenuContext.jsx +0 -5
  202. package/lib/SelectMenu/SelectMenuDivider.jsx +0 -42
  203. package/lib/SelectMenu/SelectMenuFilter.jsx +0 -58
  204. package/lib/SelectMenu/SelectMenuFooter.jsx +0 -45
  205. package/lib/SelectMenu/SelectMenuHeader.jsx +0 -42
  206. package/lib/SelectMenu/SelectMenuItem.jsx +0 -142
  207. package/lib/SelectMenu/SelectMenuList.jsx +0 -59
  208. package/lib/SelectMenu/SelectMenuLoadingAnimation.jsx +0 -22
  209. package/lib/SelectMenu/SelectMenuModal.jsx +0 -118
  210. package/lib/SelectMenu/SelectMenuTab.jsx +0 -92
  211. package/lib/SelectMenu/SelectMenuTabPanel.jsx +0 -42
  212. package/lib/SelectMenu/SelectMenuTabs.jsx +0 -57
  213. package/lib/SelectPanel/SelectPanel.jsx +0 -105
  214. package/lib/SideNav.jsx +0 -173
  215. package/lib/Spinner.jsx +0 -35
  216. package/lib/StateLabel.jsx +0 -93
  217. package/lib/StyledOcticon.jsx +0 -18
  218. package/lib/SubNav.jsx +0 -101
  219. package/lib/TabNav.jsx +0 -58
  220. package/lib/Text.jsx +0 -14
  221. package/lib/TextInput.jsx +0 -23
  222. package/lib/TextInputWithTokens.jsx +0 -218
  223. package/lib/ThemeProvider.jsx +0 -130
  224. package/lib/Timeline.jsx +0 -123
  225. package/lib/Token/AvatarToken.jsx +0 -54
  226. package/lib/Token/IssueLabelToken.jsx +0 -125
  227. package/lib/Token/Token.jsx +0 -103
  228. package/lib/Token/TokenBase.jsx +0 -88
  229. package/lib/Token/_RemoveTokenButton.jsx +0 -108
  230. package/lib/Token/_TokenTextContainer.jsx +0 -49
  231. package/lib/Tooltip.jsx +0 -246
  232. package/lib/Truncate.jsx +0 -24
  233. package/lib/UnderlineNav.jsx +0 -88
  234. package/lib/_TextInputWrapper.jsx +0 -120
  235. package/lib/_UnstyledTextInput.jsx +0 -22
  236. package/lib/hooks/useDetails.jsx +0 -39
  237. package/lib/hooks/useOnOutsideClick.jsx +0 -61
  238. package/lib/hooks/useOverlay.jsx +0 -15
  239. package/lib/utils/create-slots.jsx +0 -65
  240. package/lib/utils/deprecate.jsx +0 -59
  241. package/lib/utils/isNumeric.jsx +0 -7
  242. package/lib/utils/ssr.jsx +0 -6
  243. package/lib/utils/test-deprecations.jsx +0 -20
  244. package/lib/utils/test-helpers.jsx +0 -8
  245. package/lib/utils/test-matchers.jsx +0 -100
  246. package/lib/utils/testing.jsx +0 -206
  247. package/lib-esm/ActionList2/Header.d.ts +0 -26
  248. package/lib-esm/ActionList2/Header.js +0 -44
package/lib/Dialog.jsx DELETED
@@ -1,129 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
- Object.defineProperty(o, "default", { enumerable: true, value: v });
11
- }) : function(o, v) {
12
- o["default"] = v;
13
- });
14
- var __importStar = (this && this.__importStar) || function (mod) {
15
- if (mod && mod.__esModule) return mod;
16
- var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
- __setModuleDefault(result, mod);
19
- return result;
20
- };
21
- var __importDefault = (this && this.__importDefault) || function (mod) {
22
- return (mod && mod.__esModule) ? mod : { "default": mod };
23
- };
24
- Object.defineProperty(exports, "__esModule", { value: true });
25
- const react_1 = __importStar(require("react"));
26
- const styled_components_1 = __importDefault(require("styled-components"));
27
- const ButtonClose_1 = __importDefault(require("./Button/ButtonClose"));
28
- const constants_1 = require("./constants");
29
- const Box_1 = __importDefault(require("./Box"));
30
- const useDialog_1 = __importDefault(require("./hooks/useDialog"));
31
- const sx_1 = __importDefault(require("./sx"));
32
- const Text_1 = __importDefault(require("./Text"));
33
- const useCombinedRefs_1 = require("./hooks/useCombinedRefs");
34
- const noop = () => null;
35
- const DialogBase = styled_components_1.default.div `
36
- box-shadow: ${constants_1.get('shadows.shadow.large')};
37
- border-radius: ${constants_1.get('radii.2')};
38
- position: fixed;
39
- top: 0;
40
- left: 50%;
41
- transform: translateX(-50%);
42
- max-height: 80vh;
43
- z-index: 999;
44
- margin: 10vh auto;
45
- background-color: ${constants_1.get('colors.canvas.default')};
46
- width: ${props => (props.narrow ? '320px' : props.wide ? '640px' : '440px')};
47
- outline: none;
48
-
49
- @media screen and (max-width: 750px) {
50
- width: 100vw;
51
- margin: 0;
52
- border-radius: 0;
53
- height: 100vh;
54
- }
55
-
56
- ${sx_1.default};
57
- `;
58
- const DialogHeaderBase = styled_components_1.default(Box_1.default) `
59
- border-radius: ${constants_1.get('radii.2')} ${constants_1.get('radii.2')} 0px 0px;
60
- border-bottom: 1px solid ${constants_1.get('colors.border.default')};
61
- display: flex;
62
-
63
- @media screen and (max-width: 750px) {
64
- border-radius: 0px;
65
- }
66
-
67
- ${sx_1.default};
68
- `;
69
- function DialogHeader({ theme, children, backgroundColor = 'gray.1', ...rest }) {
70
- if (react_1.default.Children.toArray(children).every(ch => typeof ch === 'string')) {
71
- children = (<Text_1.default theme={theme} color="fg.default" fontSize={1} fontWeight="bold" fontFamily="sans-serif">
72
- {children}
73
- </Text_1.default>);
74
- }
75
- return (<DialogHeaderBase theme={theme} p={3} backgroundColor={backgroundColor} {...rest}>
76
- {children}
77
- </DialogHeaderBase>);
78
- }
79
- const Overlay = styled_components_1.default.span `
80
- &:before {
81
- position: fixed;
82
- top: 0;
83
- right: 0;
84
- bottom: 0;
85
- left: 0;
86
- display: block;
87
- cursor: default;
88
- content: ' ';
89
- background: transparent;
90
- z-index: 99;
91
- background: ${constants_1.get('colors.primer.canvas.backdrop')};
92
- }
93
- `;
94
- const Dialog = react_1.forwardRef(({ children, onDismiss = noop, isOpen, initialFocusRef, returnFocusRef, ...props }, forwardedRef) => {
95
- const overlayRef = react_1.useRef(null);
96
- const modalRef = useCombinedRefs_1.useCombinedRefs(forwardedRef);
97
- const closeButtonRef = react_1.useRef(null);
98
- const onCloseClick = () => {
99
- onDismiss();
100
- if (returnFocusRef && returnFocusRef.current) {
101
- returnFocusRef.current.focus();
102
- }
103
- };
104
- const { getDialogProps } = useDialog_1.default({
105
- modalRef,
106
- onDismiss: onCloseClick,
107
- isOpen,
108
- initialFocusRef,
109
- closeButtonRef,
110
- returnFocusRef,
111
- overlayRef
112
- });
113
- return isOpen ? (<>
114
- <Overlay ref={overlayRef}/>
115
- <DialogBase tabIndex={-1} ref={modalRef} role="dialog" aria-modal="true" {...props} {...getDialogProps()}>
116
- <ButtonClose_1.default ref={closeButtonRef} onClick={onCloseClick} sx={{ position: 'absolute', top: '16px', right: '16px' }}/>
117
- {children}
118
- </DialogBase>
119
- </>) : null;
120
- });
121
- DialogHeader.defaultProps = {
122
- backgroundColor: 'canvas.subtle'
123
- };
124
- DialogHeader.propTypes = {
125
- ...Box_1.default.propTypes
126
- };
127
- DialogHeader.displayName = 'Dialog.Header';
128
- Dialog.displayName = 'Dialog';
129
- exports.default = Object.assign(Dialog, { Header: DialogHeader });
package/lib/Dropdown.jsx DELETED
@@ -1,131 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const react_1 = __importDefault(require("react"));
7
- const 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
- ${sx_1.default};
41
- `;
42
- const DropdownMenu = styled_components_1.default.ul `
43
- background-clip: padding-box;
44
- background-color: ${constants_1.get('colors.canvas.overlay')};
45
- border: 1px solid ${constants_1.get('colors.border.default')};
46
- border-radius: ${constants_1.get('radii.2')};
47
- box-shadow: ${constants_1.get('shadows.shadow.large')};
48
- left: 0;
49
- list-style: none;
50
- margin-top: 2px;
51
- padding: 5px 0 5px 0 !important; //TODO: fix this override on our markdown styles
52
- position: absolute;
53
- top: 100%;
54
- width: 160px;
55
- z-index: 100;
56
-
57
- &::before {
58
- position: absolute;
59
- display: inline-block;
60
- content: '';
61
- }
62
-
63
- &::after {
64
- position: absolute;
65
- display: inline-block;
66
- content: '';
67
- }
68
-
69
- &::before {
70
- border: 8px solid transparent;
71
- border-bottom-color: ${constants_1.get('colors.canvas.overlay')};
72
- }
73
-
74
- &::after {
75
- border: 7px solid transparent;
76
- border-bottom-color: ${constants_1.get('colors.canvas.overlay')};
77
- }
78
-
79
- // stylelint-disable-next-line selector-max-type
80
- > ul {
81
- list-style: none;
82
- }
83
- ${props => (props.direction ? DropdownStyles_1.default(props.theme, props.direction) : '')};
84
- ${sx_1.default};
85
- `;
86
- const DropdownItem = styled_components_1.default.li `
87
- display: block;
88
- padding: ${constants_1.get('space.1')} 10px ${constants_1.get('space.1')} 15px;
89
- overflow: hidden;
90
- color: ${constants_1.get('colors.fg.default')};
91
- text-overflow: ellipsis;
92
- white-space: nowrap;
93
- a {
94
- color: ${constants_1.get('colors.fg.default')};
95
- text-decoration: none;
96
- display: block;
97
- overflow: hidden;
98
- color: ${constants_1.get('colors.fg.default')};
99
- text-overflow: ellipsis;
100
- white-space: nowrap;
101
- }
102
-
103
- &:focus,
104
- a:focus {
105
- color: ${constants_1.get('colors.fg.onEmphasis')};
106
- text-decoration: none;
107
- background-color: ${constants_1.get('colors.accent.emphasis')};
108
- }
109
-
110
- &:hover,
111
- &:hover a {
112
- color: ${constants_1.get('colors.fg.onEmphasis')};
113
- text-decoration: none;
114
- background-color: ${constants_1.get('colors.accent.emphasis')};
115
- outline: none;
116
- }
117
- ${sx_1.default};
118
- `;
119
- DropdownMenu.defaultProps = { direction: 'sw' };
120
- DropdownMenu.displayName = 'Dropdown.Menu';
121
- DropdownItem.displayName = 'Dropdown.Item';
122
- DropdownButton.defaultProps = Button_1.default.defaultProps;
123
- DropdownButton.displayName = 'Dropdown.Button';
124
- DropdownCaret.displayName = 'Dropdown.Caret';
125
- Dropdown.defaultProps = Details_1.default.defaultProps;
126
- exports.default = Object.assign(Dropdown, {
127
- Caret: DropdownCaret,
128
- Menu: DropdownMenu,
129
- Item: DropdownItem,
130
- Button: DropdownButton
131
- });
@@ -1,14 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.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} sx={{ ml: 1 }}/>
14
- </Button_1.default>));
@@ -1,70 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
- Object.defineProperty(o, "default", { enumerable: true, value: v });
11
- }) : function(o, v) {
12
- o["default"] = v;
13
- });
14
- var __importStar = (this && this.__importStar) || function (mod) {
15
- if (mod && mod.__esModule) return mod;
16
- var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
- __setModuleDefault(result, mod);
19
- return result;
20
- };
21
- Object.defineProperty(exports, "__esModule", { value: true });
22
- 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,59 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const react_1 = __importDefault(require("react"));
7
- const styled_components_1 = __importDefault(require("styled-components"));
8
- const constants_1 = require("./constants");
9
- const sx_1 = __importDefault(require("./sx"));
10
- const FilterListBase = styled_components_1.default.ul `
11
- list-style-type: none;
12
- margin: 0;
13
- padding: 0;
14
- ${sx_1.default};
15
- `;
16
- const FilterList = ({ children, ...rest }) => {
17
- const items = react_1.default.Children.map(children, child => {
18
- return <li>{child}</li>;
19
- });
20
- return <FilterListBase {...rest}>{items}</FilterListBase>;
21
- };
22
- const FilterListItemBase = styled_components_1.default.a `
23
- position: relative;
24
- display: block;
25
- padding: ${props => (props.small ? `${constants_1.get('space.1')(props)} 10px` : `${constants_1.get('space.2')(props)} 11px`)};
26
- margin: ${props => (props.small ? '0 0 2px' : '0 0 5px 0')};
27
- overflow: hidden;
28
- font-size: ${constants_1.get('fontSizes.1')};
29
- color: ${props => (props.selected ? constants_1.get('colors.fg.onEmphasis') : constants_1.get('colors.fg.muted'))};
30
- background-color: ${props => (props.selected ? constants_1.get('colors.accent.emphasis') : '')}!important;
31
- text-decoration: none;
32
- text-overflow: ellipsis;
33
- white-space: nowrap;
34
- cursor: pointer;
35
- border-radius: ${constants_1.get('radii.1')};
36
- &:hover {
37
- text-decoration: none;
38
- background-color: ${constants_1.get('colors.canvas.subtle')};
39
- }
40
- &:active {
41
- color: ${constants_1.get('colors.fg.onEmphasis')};
42
- background-color: ${constants_1.get('colors.accent.emphasis')};
43
- }
44
- .count {
45
- float: right;
46
- font-weight: ${constants_1.get('fontWeights.bold')};
47
- }
48
- ${sx_1.default};
49
- `;
50
- function FilterListItem({ children, count, ...rest }) {
51
- return (<FilterListItemBase {...rest}>
52
- {count && (<span title="results" className="count">
53
- {count}
54
- </span>)}
55
- {children}
56
- </FilterListItemBase>);
57
- }
58
- FilterListItem.displayName = 'FilterList.Item';
59
- exports.default = Object.assign(FilterList, { Item: FilterListItem });
@@ -1,100 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
- Object.defineProperty(o, "default", { enumerable: true, value: v });
11
- }) : function(o, v) {
12
- o["default"] = v;
13
- });
14
- var __importStar = (this && this.__importStar) || function (mod) {
15
- if (mod && mod.__esModule) return mod;
16
- var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
- __setModuleDefault(result, mod);
19
- return result;
20
- };
21
- var __importDefault = (this && this.__importDefault) || function (mod) {
22
- return (mod && mod.__esModule) ? mod : { "default": mod };
23
- };
24
- Object.defineProperty(exports, "__esModule", { value: true });
25
- exports.FilteredActionList = void 0;
26
- const react_1 = __importStar(require("react"));
27
- const ssr_1 = require("@react-aria/ssr");
28
- const TextInput_1 = __importDefault(require("../TextInput"));
29
- const Box_1 = __importDefault(require("../Box"));
30
- const ActionList_1 = require("../ActionList");
31
- const Spinner_1 = __importDefault(require("../Spinner"));
32
- const useFocusZone_1 = require("../hooks/useFocusZone");
33
- const useProvidedStateOrCreate_1 = require("../hooks/useProvidedStateOrCreate");
34
- const styled_components_1 = __importDefault(require("styled-components"));
35
- const constants_1 = require("../constants");
36
- const useProvidedRefOrCreate_1 = require("../hooks/useProvidedRefOrCreate");
37
- const useScrollFlash_1 = __importDefault(require("../hooks/useScrollFlash"));
38
- const scrollIntoViewingArea_1 = require("../behaviors/scrollIntoViewingArea");
39
- const StyledHeader = styled_components_1.default.div `
40
- box-shadow: 0 1px 0 ${constants_1.get('colors.border.default')};
41
- z-index: 1;
42
- `;
43
- function FilteredActionList({ loading = false, placeholderText, filterValue: externalFilterValue, onFilterChange, items, textInputProps, inputRef: providedInputRef, sx, ...listProps }) {
44
- const [filterValue, setInternalFilterValue] = useProvidedStateOrCreate_1.useProvidedStateOrCreate(externalFilterValue, undefined, '');
45
- const onInputChange = react_1.useCallback((e) => {
46
- const value = e.target.value;
47
- onFilterChange(value, e);
48
- setInternalFilterValue(value);
49
- }, [onFilterChange, setInternalFilterValue]);
50
- const scrollContainerRef = react_1.useRef(null);
51
- const listContainerRef = react_1.useRef(null);
52
- const inputRef = useProvidedRefOrCreate_1.useProvidedRefOrCreate(providedInputRef);
53
- const activeDescendantRef = react_1.useRef();
54
- const listId = ssr_1.useSSRSafeId();
55
- const onInputKeyPress = react_1.useCallback(event => {
56
- if (event.key === 'Enter' && activeDescendantRef.current) {
57
- event.preventDefault();
58
- event.nativeEvent.stopImmediatePropagation();
59
- // Forward Enter key press to active descendant so that item gets activated
60
- const activeDescendantEvent = new KeyboardEvent(event.type, event.nativeEvent);
61
- activeDescendantRef.current.dispatchEvent(activeDescendantEvent);
62
- }
63
- }, [activeDescendantRef]);
64
- useFocusZone_1.useFocusZone({
65
- containerRef: listContainerRef,
66
- focusOutBehavior: 'wrap',
67
- focusableElementFilter: element => {
68
- return !(element instanceof HTMLInputElement);
69
- },
70
- activeDescendantFocus: inputRef,
71
- onActiveDescendantChanged: (current, previous, directlyActivated) => {
72
- activeDescendantRef.current = current;
73
- if (current && scrollContainerRef.current && directlyActivated) {
74
- scrollIntoViewingArea_1.scrollIntoViewingArea(current, scrollContainerRef.current);
75
- }
76
- }
77
- }, [
78
- // List ref isn't set while loading. Need to re-bind focus zone when it changes
79
- loading
80
- ]);
81
- react_1.useEffect(() => {
82
- // if items changed, we want to instantly move active descendant into view
83
- if (activeDescendantRef.current && scrollContainerRef.current) {
84
- scrollIntoViewingArea_1.scrollIntoViewingArea(activeDescendantRef.current, scrollContainerRef.current, 'vertical', undefined, undefined, 'auto');
85
- }
86
- }, [items]);
87
- useScrollFlash_1.default(scrollContainerRef);
88
- return (<Box_1.default display="flex" flexDirection="column" overflow="hidden" sx={sx}>
89
- <StyledHeader>
90
- <TextInput_1.default ref={inputRef} block width="auto" color="fg.default" value={filterValue} onChange={onInputChange} onKeyPress={onInputKeyPress} placeholder={placeholderText} aria-label={placeholderText} aria-controls={listId} {...textInputProps}/>
91
- </StyledHeader>
92
- <Box_1.default ref={scrollContainerRef} overflow="auto">
93
- {loading ? (<Box_1.default width="100%" display="flex" flexDirection="row" justifyContent="center" pt={6} pb={7}>
94
- <Spinner_1.default />
95
- </Box_1.default>) : (<ActionList_1.ActionList ref={listContainerRef} items={items} {...listProps} role="listbox" id={listId}/>)}
96
- </Box_1.default>
97
- </Box_1.default>);
98
- }
99
- exports.FilteredActionList = FilteredActionList;
100
- FilteredActionList.displayName = 'FilteredActionList';
@@ -1,28 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const styled_components_1 = __importDefault(require("styled-components"));
7
- const constants_1 = require("./constants");
8
- const sx_1 = __importDefault(require("./sx"));
9
- const FilteredSearch = styled_components_1.default.div `
10
- display: flex;
11
- align-items: stretch;
12
-
13
- summary {
14
- border-radius: 0;
15
- border-top-left-radius: ${constants_1.get('radii.2')};
16
- border-bottom-left-radius: ${constants_1.get('radii.2')};
17
- border-right: 0;
18
- }
19
- .TextInput-wrapper {
20
- border-radius: 0;
21
- border-top-right-radius: ${constants_1.get('radii.2')};
22
- border-bottom-right-radius: ${constants_1.get('radii.2')};
23
- z-index: 1; // Allows the focus outline to show on top of the dropdown.
24
- }
25
-
26
- ${sx_1.default}
27
- `;
28
- exports.default = FilteredSearch;
package/lib/Flash.jsx DELETED
@@ -1,69 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const styled_components_1 = __importDefault(require("styled-components"));
7
- const styled_system_1 = require("styled-system");
8
- const constants_1 = require("./constants");
9
- const sx_1 = __importDefault(require("./sx"));
10
- const variants = styled_system_1.variant({
11
- variants: {
12
- default: {
13
- color: 'fg.default',
14
- backgroundColor: 'accent.subtle',
15
- borderColor: 'accent.muted',
16
- svg: {
17
- color: 'accent.fg'
18
- }
19
- },
20
- success: {
21
- color: 'fg.default',
22
- backgroundColor: 'success.subtle',
23
- borderColor: 'success.muted',
24
- svg: {
25
- color: 'success.fg'
26
- }
27
- },
28
- danger: {
29
- color: 'fg.default',
30
- backgroundColor: 'danger.subtle',
31
- borderColor: 'danger.muted',
32
- svg: {
33
- color: 'danger.fg'
34
- }
35
- },
36
- warning: {
37
- color: 'fg.default',
38
- backgroundColor: 'attention.subtle',
39
- borderColor: 'attention.muted',
40
- svg: {
41
- color: 'attention.fg'
42
- }
43
- }
44
- }
45
- });
46
- const Flash = styled_components_1.default.div `
47
- position: relative;
48
- color: ${constants_1.get('colors.fg.default')};
49
- padding: ${constants_1.get('space.3')};
50
- border-style: solid;
51
- border-width: ${props => (props.full ? '1px 0px' : '1px')};
52
- border-radius: ${props => (props.full ? '0' : constants_1.get('radii.2'))};
53
- margin-top: ${props => (props.full ? '-1px' : '0')};
54
-
55
- p:last-child {
56
- margin-bottom: 0;
57
- }
58
-
59
- svg {
60
- margin-right: ${constants_1.get('space.2')};
61
- }
62
-
63
- ${variants};
64
- ${sx_1.default};
65
- `;
66
- Flash.defaultProps = {
67
- variant: 'default'
68
- };
69
- exports.default = Flash;
package/lib/Flex.jsx DELETED
@@ -1,15 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const styled_components_1 = __importDefault(require("styled-components"));
7
- const Box_1 = __importDefault(require("./Box"));
8
- /**
9
- * @deprecated Use the Box component instead (i.e. <Flex> → <Box display="flex">)
10
- */
11
- const Flex = styled_components_1.default(Box_1.default) ``;
12
- Flex.defaultProps = {
13
- display: 'flex'
14
- };
15
- exports.default = Flex;
package/lib/FormGroup.jsx DELETED
@@ -1,22 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const styled_components_1 = __importDefault(require("styled-components"));
7
- const constants_1 = require("./constants");
8
- const sx_1 = __importDefault(require("./sx"));
9
- const FormGroup = styled_components_1.default.div `
10
- margin: ${constants_1.get('space.3')} 0;
11
- font-weight: ${constants_1.get('fontWeights.normal')};
12
- ${sx_1.default};
13
- `;
14
- const FormGroupLabel = styled_components_1.default.label `
15
- display: block;
16
- margin: 0 0 ${constants_1.get('space.2')};
17
- font-size: ${constants_1.get('fontSizes.1')};
18
- font-weight: ${constants_1.get('fontWeights.bold')};
19
- ${sx_1.default};
20
- `;
21
- FormGroupLabel.displayName = 'FormGroup.Label';
22
- exports.default = Object.assign(FormGroup, { Label: FormGroupLabel });
package/lib/Grid.jsx DELETED
@@ -1,15 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const styled_components_1 = __importDefault(require("styled-components"));
7
- const Box_1 = __importDefault(require("./Box"));
8
- /**
9
- * @deprecated Use the Box component instead (i.e. <Grid> → <Box display="grid">)
10
- */
11
- const Grid = styled_components_1.default(Box_1.default) ``;
12
- Grid.defaultProps = {
13
- display: 'grid'
14
- };
15
- exports.default = Grid;