@primer/components 0.0.0-20211030175556 → 0.0.0-20211030182910

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 (272) hide show
  1. package/CHANGELOG.md +34 -2
  2. package/dist/browser.esm.js +186 -183
  3. package/dist/browser.esm.js.map +1 -1
  4. package/dist/browser.umd.js +190 -187
  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/Avatar.d.ts +1 -2
  17. package/lib/Avatar.js +1 -1
  18. package/lib/BranchName.d.ts +1 -2
  19. package/lib/BranchName.js +1 -1
  20. package/lib/Button/Button.d.ts +1 -0
  21. package/lib/Button/ButtonClose.d.ts +2 -1
  22. package/lib/Button/ButtonDanger.d.ts +1 -0
  23. package/lib/Button/ButtonInvisible.d.ts +1 -0
  24. package/lib/Button/ButtonOutline.d.ts +1 -0
  25. package/lib/Button/ButtonPrimary.d.ts +1 -0
  26. package/lib/Button/index.js +70 -21
  27. package/lib/Checkbox.d.ts +29 -0
  28. package/lib/Checkbox.js +64 -0
  29. package/lib/CircleOcticon.d.ts +1 -0
  30. package/lib/Details.d.ts +1 -2
  31. package/lib/Details.js +1 -3
  32. package/lib/Dialog.d.ts +3 -2
  33. package/lib/Dropdown.d.ts +6 -66
  34. package/lib/DropdownMenu/DropdownButton.d.ts +2 -1
  35. package/lib/DropdownMenu/index.js +20 -6
  36. package/lib/DropdownStyles.js +26 -18
  37. package/lib/FilterList.d.ts +1 -0
  38. package/lib/FilteredActionList/index.js +12 -4
  39. package/lib/Heading.d.ts +1 -2
  40. package/lib/Heading.js +1 -6
  41. package/lib/NewButton/index.js +12 -5
  42. package/lib/NewButton/types.js +1 -2
  43. package/lib/Overlay.d.ts +5 -3
  44. package/lib/Pagination/index.js +12 -6
  45. package/lib/Portal/index.js +16 -5
  46. package/lib/Position.d.ts +4 -4
  47. package/lib/ProgressBar.d.ts +16 -11
  48. package/lib/ProgressBar.js +6 -10
  49. package/lib/SelectMenu/SelectMenu.d.ts +10 -4
  50. package/lib/SelectMenu/SelectMenuItem.d.ts +1 -1
  51. package/lib/SelectMenu/SelectMenuModal.d.ts +1 -1
  52. package/lib/SelectMenu/hooks/useKeyboardNav.js +96 -80
  53. package/lib/SelectMenu/index.js +14 -7
  54. package/lib/SelectPanel/index.js +12 -4
  55. package/lib/Spinner.d.ts +1 -2
  56. package/lib/Spinner.js +1 -3
  57. package/lib/TextInputWithTokens.d.ts +1 -0
  58. package/lib/Token/AvatarToken.d.ts +1 -1
  59. package/lib/Token/IssueLabelToken.d.ts +1 -1
  60. package/lib/Token/Token.d.ts +1 -1
  61. package/lib/Token/index.js +30 -11
  62. package/lib/behaviors/anchoredPosition.js +234 -205
  63. package/lib/behaviors/focusTrap.js +157 -121
  64. package/lib/behaviors/focusZone.js +509 -434
  65. package/lib/behaviors/scrollIntoViewingArea.js +35 -18
  66. package/lib/constants.js +43 -39
  67. package/lib/drafts.js +30 -20
  68. package/lib/hooks/index.js +60 -16
  69. package/lib/hooks/useAnchoredPosition.js +40 -32
  70. package/lib/hooks/useCombinedRefs.js +36 -32
  71. package/lib/hooks/useDialog.js +96 -72
  72. package/lib/hooks/useFocusTrap.js +60 -43
  73. package/lib/hooks/useFocusZone.js +50 -54
  74. package/lib/hooks/useOnEscapePress.js +36 -25
  75. package/lib/hooks/useOpenAndCloseFocus.js +34 -22
  76. package/lib/hooks/useProvidedRefOrCreate.js +14 -10
  77. package/lib/hooks/useProvidedStateOrCreate.js +16 -13
  78. package/lib/hooks/useRenderForcingRef.js +17 -13
  79. package/lib/hooks/useResizeObserver.js +18 -15
  80. package/lib/hooks/useSafeTimeout.js +30 -22
  81. package/lib/hooks/useScrollFlash.js +23 -16
  82. package/lib/index.d.ts +2 -0
  83. package/lib/index.js +652 -163
  84. package/lib/polyfills/eventListenerSignal.js +45 -37
  85. package/lib/sx.js +22 -10
  86. package/lib/theme-preval.js +3169 -64
  87. package/lib/theme.js +12 -3
  88. package/lib/utils/iterateFocusableElements.js +85 -63
  89. package/lib/utils/testing.d.ts +2 -1
  90. package/lib/utils/testing.js +29 -0
  91. package/lib/utils/theme.js +47 -33
  92. package/lib/utils/types/AriaRole.js +1 -2
  93. package/lib/utils/types/ComponentProps.js +1 -2
  94. package/lib/utils/types/Flatten.js +1 -2
  95. package/lib/utils/types/KeyPaths.js +1 -2
  96. package/lib/utils/types/MandateProps.js +1 -16
  97. package/lib/utils/types/Merge.js +1 -2
  98. package/lib/utils/types/index.js +69 -16
  99. package/lib/utils/uniqueId.js +8 -5
  100. package/lib/utils/use-force-update.js +14 -8
  101. package/lib/utils/useIsomorphicLayoutEffect.js +11 -8
  102. package/lib/utils/userAgent.js +12 -8
  103. package/lib-esm/ActionList/Item.js +3 -3
  104. package/lib-esm/ActionList2/Item.js +3 -1
  105. package/lib-esm/ActionList2/List.js +1 -2
  106. package/lib-esm/ActionList2/Selection.js +3 -1
  107. package/lib-esm/Autocomplete/Autocomplete.d.ts +1 -0
  108. package/lib-esm/Autocomplete/AutocompleteInput.d.ts +1 -0
  109. package/lib-esm/Avatar.d.ts +1 -2
  110. package/lib-esm/Avatar.js +2 -2
  111. package/lib-esm/BranchName.d.ts +1 -2
  112. package/lib-esm/BranchName.js +2 -2
  113. package/lib-esm/Button/Button.d.ts +1 -0
  114. package/lib-esm/Button/ButtonClose.d.ts +2 -1
  115. package/lib-esm/Button/ButtonDanger.d.ts +1 -0
  116. package/lib-esm/Button/ButtonInvisible.d.ts +1 -0
  117. package/lib-esm/Button/ButtonOutline.d.ts +1 -0
  118. package/lib-esm/Button/ButtonPrimary.d.ts +1 -0
  119. package/lib-esm/Checkbox.d.ts +29 -0
  120. package/lib-esm/Checkbox.js +44 -0
  121. package/lib-esm/CircleOcticon.d.ts +1 -0
  122. package/lib-esm/Details.d.ts +1 -2
  123. package/lib-esm/Details.js +1 -2
  124. package/lib-esm/Dialog.d.ts +3 -2
  125. package/lib-esm/Dropdown.d.ts +6 -66
  126. package/lib-esm/DropdownMenu/DropdownButton.d.ts +2 -1
  127. package/lib-esm/FilterList.d.ts +1 -0
  128. package/lib-esm/Heading.d.ts +1 -2
  129. package/lib-esm/Heading.js +2 -6
  130. package/lib-esm/Overlay.d.ts +5 -3
  131. package/lib-esm/Position.d.ts +4 -4
  132. package/lib-esm/ProgressBar.d.ts +16 -11
  133. package/lib-esm/ProgressBar.js +7 -11
  134. package/lib-esm/SelectMenu/SelectMenu.d.ts +10 -4
  135. package/lib-esm/SelectMenu/SelectMenuItem.d.ts +1 -1
  136. package/lib-esm/SelectMenu/SelectMenuModal.d.ts +1 -1
  137. package/lib-esm/Spinner.d.ts +1 -2
  138. package/lib-esm/Spinner.js +1 -2
  139. package/lib-esm/TextInputWithTokens.d.ts +1 -0
  140. package/lib-esm/Token/AvatarToken.d.ts +1 -1
  141. package/lib-esm/Token/IssueLabelToken.d.ts +1 -1
  142. package/lib-esm/Token/Token.d.ts +1 -1
  143. package/lib-esm/index.d.ts +2 -0
  144. package/lib-esm/index.js +1 -0
  145. package/lib-esm/theme-preval.js +446 -0
  146. package/lib-esm/utils/testing.d.ts +2 -1
  147. package/lib-esm/utils/testing.js +24 -0
  148. package/package.json +4 -5
  149. package/lib/ActionList/Divider.jsx +0 -29
  150. package/lib/ActionList/Group.jsx +0 -23
  151. package/lib/ActionList/Header.jsx +0 -66
  152. package/lib/ActionList/Item.jsx +0 -288
  153. package/lib/ActionList/List.jsx +0 -138
  154. package/lib/ActionList2/Description.jsx +0 -29
  155. package/lib/ActionList2/Divider.jsx +0 -22
  156. package/lib/ActionList2/Group.jsx +0 -54
  157. package/lib/ActionList2/Header.d.ts +0 -26
  158. package/lib/ActionList2/Header.js +0 -55
  159. package/lib/ActionList2/Header.jsx +0 -36
  160. package/lib/ActionList2/Item.jsx +0 -174
  161. package/lib/ActionList2/LinkItem.jsx +0 -28
  162. package/lib/ActionList2/List.jsx +0 -41
  163. package/lib/ActionList2/Selection.jsx +0 -50
  164. package/lib/ActionList2/Visuals.jsx +0 -48
  165. package/lib/ActionMenu.jsx +0 -73
  166. package/lib/AnchoredOverlay/AnchoredOverlay.jsx +0 -100
  167. package/lib/Autocomplete/Autocomplete.jsx +0 -100
  168. package/lib/Autocomplete/AutocompleteContext.jsx +0 -5
  169. package/lib/Autocomplete/AutocompleteInput.jsx +0 -113
  170. package/lib/Autocomplete/AutocompleteMenu.jsx +0 -190
  171. package/lib/Autocomplete/AutocompleteOverlay.jsx +0 -55
  172. package/lib/Avatar.jsx +0 -34
  173. package/lib/AvatarPair.jsx +0 -29
  174. package/lib/AvatarStack.jsx +0 -151
  175. package/lib/BaseStyles.jsx +0 -65
  176. package/lib/BorderBox.jsx +0 -18
  177. package/lib/Box.jsx +0 -10
  178. package/lib/BranchName.jsx +0 -20
  179. package/lib/Breadcrumbs.jsx +0 -71
  180. package/lib/Button/Button.jsx +0 -40
  181. package/lib/Button/ButtonBase.jsx +0 -33
  182. package/lib/Button/ButtonClose.jsx +0 -53
  183. package/lib/Button/ButtonDanger.jsx +0 -43
  184. package/lib/Button/ButtonGroup.jsx +0 -55
  185. package/lib/Button/ButtonInvisible.jsx +0 -32
  186. package/lib/Button/ButtonOutline.jsx +0 -43
  187. package/lib/Button/ButtonPrimary.jsx +0 -42
  188. package/lib/Button/ButtonStyles.jsx +0 -37
  189. package/lib/Button/ButtonTableList.jsx +0 -46
  190. package/lib/Caret.jsx +0 -93
  191. package/lib/CircleBadge.jsx +0 -42
  192. package/lib/CircleOcticon.jsx +0 -21
  193. package/lib/CounterLabel.jsx +0 -43
  194. package/lib/Details.jsx +0 -21
  195. package/lib/Dialog/ConfirmationDialog.jsx +0 -146
  196. package/lib/Dialog/Dialog.jsx +0 -279
  197. package/lib/Dialog.jsx +0 -129
  198. package/lib/Dropdown.jsx +0 -131
  199. package/lib/DropdownMenu/DropdownButton.jsx +0 -14
  200. package/lib/DropdownMenu/DropdownMenu.jsx +0 -70
  201. package/lib/FilterList.jsx +0 -59
  202. package/lib/FilteredActionList/FilteredActionList.jsx +0 -100
  203. package/lib/FilteredSearch.jsx +0 -28
  204. package/lib/Flash.jsx +0 -69
  205. package/lib/Flex.jsx +0 -15
  206. package/lib/FormGroup.jsx +0 -22
  207. package/lib/Grid.jsx +0 -15
  208. package/lib/Header.jsx +0 -83
  209. package/lib/Heading.jsx +0 -21
  210. package/lib/Label.jsx +0 -82
  211. package/lib/LabelGroup.jsx +0 -18
  212. package/lib/Link.jsx +0 -36
  213. package/lib/NewButton/button-counter.jsx +0 -14
  214. package/lib/NewButton/button.jsx +0 -279
  215. package/lib/Overlay.jsx +0 -154
  216. package/lib/Pagehead.jsx +0 -17
  217. package/lib/Pagination/Pagination.jsx +0 -161
  218. package/lib/Pagination/model.jsx +0 -174
  219. package/lib/PointerBox.jsx +0 -25
  220. package/lib/Popover.jsx +0 -202
  221. package/lib/Portal/Portal.jsx +0 -79
  222. package/lib/Position.jsx +0 -46
  223. package/lib/ProgressBar.jsx +0 -39
  224. package/lib/SelectMenu/SelectMenu.jsx +0 -112
  225. package/lib/SelectMenu/SelectMenuContext.jsx +0 -5
  226. package/lib/SelectMenu/SelectMenuDivider.jsx +0 -42
  227. package/lib/SelectMenu/SelectMenuFilter.jsx +0 -58
  228. package/lib/SelectMenu/SelectMenuFooter.jsx +0 -45
  229. package/lib/SelectMenu/SelectMenuHeader.jsx +0 -42
  230. package/lib/SelectMenu/SelectMenuItem.jsx +0 -142
  231. package/lib/SelectMenu/SelectMenuList.jsx +0 -59
  232. package/lib/SelectMenu/SelectMenuLoadingAnimation.jsx +0 -22
  233. package/lib/SelectMenu/SelectMenuModal.jsx +0 -118
  234. package/lib/SelectMenu/SelectMenuTab.jsx +0 -92
  235. package/lib/SelectMenu/SelectMenuTabPanel.jsx +0 -42
  236. package/lib/SelectMenu/SelectMenuTabs.jsx +0 -57
  237. package/lib/SelectPanel/SelectPanel.jsx +0 -105
  238. package/lib/SideNav.jsx +0 -173
  239. package/lib/Spinner.jsx +0 -35
  240. package/lib/StateLabel.jsx +0 -93
  241. package/lib/StyledOcticon.jsx +0 -18
  242. package/lib/SubNav.jsx +0 -101
  243. package/lib/TabNav.jsx +0 -58
  244. package/lib/Text.jsx +0 -14
  245. package/lib/TextInput.jsx +0 -23
  246. package/lib/TextInputWithTokens.jsx +0 -218
  247. package/lib/ThemeProvider.jsx +0 -130
  248. package/lib/Timeline.jsx +0 -123
  249. package/lib/Token/AvatarToken.jsx +0 -54
  250. package/lib/Token/IssueLabelToken.jsx +0 -125
  251. package/lib/Token/Token.jsx +0 -103
  252. package/lib/Token/TokenBase.jsx +0 -88
  253. package/lib/Token/_RemoveTokenButton.jsx +0 -108
  254. package/lib/Token/_TokenTextContainer.jsx +0 -49
  255. package/lib/Tooltip.jsx +0 -246
  256. package/lib/Truncate.jsx +0 -24
  257. package/lib/UnderlineNav.jsx +0 -88
  258. package/lib/_TextInputWrapper.jsx +0 -120
  259. package/lib/_UnstyledTextInput.jsx +0 -22
  260. package/lib/hooks/useDetails.jsx +0 -39
  261. package/lib/hooks/useOnOutsideClick.jsx +0 -61
  262. package/lib/hooks/useOverlay.jsx +0 -15
  263. package/lib/utils/create-slots.jsx +0 -65
  264. package/lib/utils/deprecate.jsx +0 -59
  265. package/lib/utils/isNumeric.jsx +0 -7
  266. package/lib/utils/ssr.jsx +0 -6
  267. package/lib/utils/test-deprecations.jsx +0 -20
  268. package/lib/utils/test-helpers.jsx +0 -8
  269. package/lib/utils/test-matchers.jsx +0 -100
  270. package/lib/utils/testing.jsx +0 -206
  271. package/lib-esm/ActionList2/Header.d.ts +0 -26
  272. package/lib-esm/ActionList2/Header.js +0 -44
@@ -1,39 +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 styled_system_1 = require("styled-system");
9
- const constants_1 = require("./constants");
10
- const sx_1 = __importDefault(require("./sx"));
11
- const Bar = styled_components_1.default.span `
12
- width: ${props => (props.progress ? `${props.progress}%` : 0)};
13
- ${constants_1.COMMON}
14
- `;
15
- const sizeMap = {
16
- small: '5px',
17
- large: '10px',
18
- default: '8px'
19
- };
20
- const ProgressContainer = styled_components_1.default.span `
21
- display: ${props => (props.inline ? 'inline-flex' : 'flex')};
22
- overflow: hidden;
23
- background-color: ${constants_1.get('colors.border.default')};
24
- border-radius: ${constants_1.get('radii.1')};
25
- height: ${props => sizeMap[props.barSize || 'default']};
26
- ${constants_1.COMMON}
27
- ${styled_system_1.width}
28
- ${sx_1.default};
29
- `;
30
- function ProgressBar({ progress, bg, theme, ...rest }) {
31
- return (<ProgressContainer theme={theme} {...rest}>
32
- <Bar progress={progress} bg={bg} theme={theme}/>
33
- </ProgressContainer>);
34
- }
35
- ProgressBar.defaultProps = {
36
- bg: 'success.emphasis',
37
- barSize: 'default'
38
- };
39
- exports.default = ProgressBar;
@@ -1,112 +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 sx_1 = __importDefault(require("../sx"));
28
- const useKeyboardNav_1 = __importDefault(require("./hooks/useKeyboardNav"));
29
- const SelectMenuContext_1 = require("./SelectMenuContext");
30
- const SelectMenuDivider_1 = __importDefault(require("./SelectMenuDivider"));
31
- const SelectMenuFilter_1 = __importDefault(require("./SelectMenuFilter"));
32
- const SelectMenuFooter_1 = __importDefault(require("./SelectMenuFooter"));
33
- const SelectMenuHeader_1 = __importDefault(require("./SelectMenuHeader"));
34
- const SelectMenuItem_1 = __importDefault(require("./SelectMenuItem"));
35
- const SelectMenuList_1 = __importDefault(require("./SelectMenuList"));
36
- const SelectMenuLoadingAnimation_1 = __importDefault(require("./SelectMenuLoadingAnimation"));
37
- const SelectMenuModal_1 = __importDefault(require("./SelectMenuModal"));
38
- const SelectMenuTab_1 = __importDefault(require("./SelectMenuTab"));
39
- const SelectMenuTabPanel_1 = __importDefault(require("./SelectMenuTabPanel"));
40
- const SelectMenuTabs_1 = __importDefault(require("./SelectMenuTabs"));
41
- const wrapperStyles = `
42
- // Remove marker added by the display: list-item browser default
43
- > summary {
44
- list-style: none;
45
- }
46
- // Remove marker added by details polyfill
47
- > summary::before {
48
- display: none;
49
- }
50
- // Remove marker added by Chrome
51
- > summary::-webkit-details-marker {
52
- display: none;
53
- }
54
- `;
55
- const StyledSelectMenu = styled_components_1.default.details `
56
- ${wrapperStyles}
57
- ${sx_1.default};
58
- `;
59
- // 'as' is spread out because we don't want users to be able to change the tag.
60
- const SelectMenu = react_1.default.forwardRef(({ children, initialTab = '', as: _ignoredAs, ...rest }, forwardedRef) => {
61
- const backupRef = react_1.useRef(null);
62
- const ref = forwardedRef ?? backupRef;
63
- const [selectedTab, setSelectedTab] = react_1.useState(initialTab);
64
- const [open, setOpen] = react_1.useState(false);
65
- const menuProviderValues = {
66
- selectedTab,
67
- setSelectedTab,
68
- setOpen,
69
- open,
70
- initialTab
71
- };
72
- const onClickOutside = react_1.useCallback(event => {
73
- if ('current' in ref && ref.current && !ref.current.contains(event.target)) {
74
- if (!event.defaultPrevented) {
75
- setOpen(false);
76
- }
77
- }
78
- }, [ref, setOpen]);
79
- // handles the overlay behavior - closing the menu when clicking outside of it
80
- react_1.useEffect(() => {
81
- if (open) {
82
- document.addEventListener('click', onClickOutside);
83
- return () => {
84
- document.removeEventListener('click', onClickOutside);
85
- };
86
- }
87
- }, [open, onClickOutside]);
88
- function toggle(event) {
89
- setOpen(event.target.open);
90
- }
91
- useKeyboardNav_1.default(ref, open, setOpen);
92
- return (<SelectMenuContext_1.MenuContext.Provider value={menuProviderValues}>
93
- <StyledSelectMenu ref={ref} {...rest} open={open} onToggle={toggle}>
94
- {children}
95
- </StyledSelectMenu>
96
- </SelectMenuContext_1.MenuContext.Provider>);
97
- });
98
- SelectMenu.displayName = 'SelectMenu';
99
- exports.default = Object.assign(SelectMenu, {
100
- MenuContext: SelectMenuContext_1.MenuContext,
101
- List: SelectMenuList_1.default,
102
- Divider: SelectMenuDivider_1.default,
103
- Filter: SelectMenuFilter_1.default,
104
- Footer: SelectMenuFooter_1.default,
105
- Item: SelectMenuItem_1.default,
106
- Modal: SelectMenuModal_1.default,
107
- Tabs: SelectMenuTabs_1.default,
108
- Tab: SelectMenuTab_1.default,
109
- TabPanel: SelectMenuTabPanel_1.default,
110
- Header: SelectMenuHeader_1.default,
111
- LoadingAnimation: SelectMenuLoadingAnimation_1.default
112
- });
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MenuContext = void 0;
4
- const react_1 = require("react");
5
- exports.MenuContext = react_1.createContext({});
@@ -1,42 +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 styled_components_1 = __importStar(require("styled-components"));
26
- const constants_1 = require("../constants");
27
- const sx_1 = __importDefault(require("../sx"));
28
- const dividerStyles = styled_components_1.css `
29
- padding: ${constants_1.get('space.1')} ${constants_1.get('space.3')};
30
- margin: 0;
31
- font-size: ${constants_1.get('fontSizes.0')};
32
- font-weight: ${constants_1.get('fontWeights.bold')};
33
- color: ${constants_1.get('colors.fg.muted')};
34
- background-color: ${constants_1.get('colors.canvas.subtle')};
35
- border-bottom: ${constants_1.get('borderWidths.1')} solid ${constants_1.get('colors.border.muted')};
36
- `;
37
- const SelectMenuDivider = styled_components_1.default.div `
38
- ${dividerStyles}
39
- ${sx_1.default};
40
- `;
41
- SelectMenuDivider.displayName = 'SelectMenu.Divider';
42
- exports.default = SelectMenuDivider;
@@ -1,58 +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 constants_1 = require("../constants");
28
- const sx_1 = __importDefault(require("../sx"));
29
- const TextInput_1 = __importDefault(require("../TextInput"));
30
- const SelectMenuContext_1 = require("./SelectMenuContext");
31
- const StyledForm = styled_components_1.default.form `
32
- padding: ${constants_1.get('space.3')};
33
- margin: 0;
34
- border-bottom: ${constants_1.get('borderWidths.1')} solid ${constants_1.get('colors.border.muted')};
35
- background-color: ${constants_1.get('colors.canvas.overlay')};
36
-
37
- @media (min-width: ${constants_1.get('breakpoints.0')}) {
38
- padding: ${constants_1.get('space.2')};
39
- }
40
-
41
- ${sx_1.default};
42
- `;
43
- const SelectMenuFilter = react_1.forwardRef(({ theme, value, sx: sxProp, ...rest }, forwardedRef) => {
44
- const inputRef = react_1.useRef(null);
45
- const ref = forwardedRef ?? inputRef;
46
- const { open } = react_1.useContext(SelectMenuContext_1.MenuContext);
47
- // puts focus on the filter input when the menu is opened
48
- react_1.useEffect(() => {
49
- if (open) {
50
- inputRef.current?.focus();
51
- }
52
- }, [open]);
53
- return (<StyledForm theme={theme} sx={sxProp}>
54
- <TextInput_1.default theme={theme} ref={ref} width="100%" block value={value} contrast {...rest}/>
55
- </StyledForm>);
56
- });
57
- SelectMenuFilter.displayName = 'SelectMenu.Filter';
58
- exports.default = SelectMenuFilter;
@@ -1,45 +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 styled_components_1 = __importStar(require("styled-components"));
26
- const constants_1 = require("../constants");
27
- const sx_1 = __importDefault(require("../sx"));
28
- const footerStyles = styled_components_1.css `
29
- margin-top: -1px;
30
- padding: ${constants_1.get('space.2')} ${constants_1.get('space.3')};
31
- font-size: ${constants_1.get('fontSizes.0')};
32
- color: ${constants_1.get('colors.fg.muted')};
33
- text-align: center;
34
- border-top: ${constants_1.get('borderWidths.1')} solid ${constants_1.get('colors.border.muted')};
35
-
36
- @media (min-width: ${constants_1.get('breakpoints.0')}) {
37
- padding: ${constants_1.get('space.1')} ${constants_1.get('space.2')};
38
- }
39
- `;
40
- const SelectMenuFooter = styled_components_1.default.footer `
41
- ${footerStyles}
42
- ${sx_1.default};
43
- `;
44
- SelectMenuFooter.displayName = 'SelectMenu.Footer';
45
- exports.default = SelectMenuFooter;
@@ -1,42 +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
- // SelectMenu.Header is intentionally not exported, it's an internal component used in
11
- // SelectMenu.Modal
12
- const SelectMenuTitle = styled_components_1.default.h3 `
13
- color: ${constants_1.get('colors.fg.default')};
14
- flex: auto;
15
- font-size: ${constants_1.get('fontSizes.1')};
16
- font-weight: ${constants_1.get('fontWeights.bold')};
17
- margin: 0;
18
-
19
- @media (min-width: ${constants_1.get('breakpoints.0')}) {
20
- font-size: inherit;
21
- }
22
- `;
23
- const StyledHeader = styled_components_1.default.header `
24
- display: flex;
25
- flex: none; // fixes header from getting squeezed in Safari iOS
26
- padding: ${constants_1.get('space.3')};
27
- border-bottom: ${constants_1.get('borderWidths')} solid ${constants_1.get('colors.border.muted')};
28
-
29
- @media (min-width: ${constants_1.get('breakpoints.0')}) {
30
- padding-top: ${constants_1.get('space.2')};
31
- padding-bottom: ${constants_1.get('space.2')};
32
- }
33
-
34
- ${sx_1.default};
35
- `;
36
- const SelectMenuHeader = ({ children, theme, ...rest }) => {
37
- return (<StyledHeader theme={theme} {...rest}>
38
- <SelectMenuTitle theme={theme}>{children}</SelectMenuTitle>
39
- </StyledHeader>);
40
- };
41
- SelectMenuHeader.displayName = 'SelectMenu.Header';
42
- exports.default = SelectMenuHeader;
@@ -1,142 +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.listItemStyles = void 0;
26
- const octicons_react_1 = require("@primer/octicons-react");
27
- const react_1 = __importStar(require("react"));
28
- const styled_components_1 = __importStar(require("styled-components"));
29
- const constants_1 = require("../constants");
30
- const StyledOcticon_1 = __importDefault(require("../StyledOcticon"));
31
- const sx_1 = __importDefault(require("../sx"));
32
- const SelectMenuContext_1 = require("./SelectMenuContext");
33
- exports.listItemStyles = styled_components_1.css `
34
- display: flex;
35
- align-items: center;
36
- padding: ${constants_1.get('space.3')};
37
- overflow: hidden;
38
- text-align: left;
39
- cursor: pointer;
40
- background-color: ${constants_1.get('colors.canvas.overlay')};
41
- border: 0;
42
- border-bottom: ${constants_1.get('borderWidths.1')} solid ${constants_1.get('colors.border.muted')};
43
- color: ${constants_1.get('colors.fg.muted')};
44
- text-decoration: none;
45
- font-size: ${constants_1.get('fontSizes.0')};
46
- font-family: inherit; // needed if user uses a "button" tag
47
- width: 100%;
48
-
49
- &:hover {
50
- text-decoration: none;
51
- }
52
- &:focus {
53
- outline: none;
54
- }
55
-
56
- &[hidden] {
57
- display: none !important;
58
- }
59
-
60
- @media (min-width: ${constants_1.get('breakpoints.0')}) {
61
- padding-top: ${constants_1.get('space.2')};
62
- padding-bottom: ${constants_1.get('space.2')};
63
- }
64
-
65
- .SelectMenu-icon {
66
- width: ${constants_1.get('space.3')};
67
- margin-right: ${constants_1.get('space.2')};
68
- flex-shrink: 0;
69
- }
70
-
71
- .SelectMenu-selected-icon {
72
- visibility: hidden;
73
- transition: transform 0.12s cubic-bezier(0.5, 0.1, 1, 0.5), visibility 0s 0.12s linear;
74
- transform: scale(0);
75
- }
76
-
77
- // selected items
78
- &[aria-checked='true'] {
79
- font-weight: 500;
80
- color: ${constants_1.get('colors.fg.default')};
81
-
82
- .SelectMenu-selected-icon {
83
- visibility: visible;
84
- transition: transform 0.12s cubic-bezier(0, 0, 0.2, 1), visibility 0s linear;
85
- transform: scale(1);
86
- }
87
- }
88
-
89
- // can hover states
90
- @media (hover: hover) {
91
- &:hover,
92
- &:active,
93
- &:focus {
94
- background-color: ${constants_1.get('colors.neutral.subtle')};
95
- }
96
- }
97
-
98
- // Can not hover states
99
- //
100
- // For touch input
101
-
102
- @media (hover: none) {
103
- // Android
104
- &:focus,
105
- &:active {
106
- background-color: ${constants_1.get('colors.canvas.subtle')};
107
- }
108
-
109
- // iOS Safari
110
- // :active would work if ontouchstart is added to the button
111
- // Instead this tweaks the "native" highlight color
112
- -webkit-tap-highlight-color: ${constants_1.get('colors.selectMenu.tapHighlight')};
113
- }
114
- `;
115
- const StyledItem = styled_components_1.default.a.attrs(() => ({
116
- role: 'menuitemcheckbox'
117
- })) `
118
- ${exports.listItemStyles}
119
- ${sx_1.default};
120
- `;
121
- const SelectMenuItem = react_1.forwardRef(({ children, selected, theme, onClick, ...rest }, forwardedRef) => {
122
- const menuContext = react_1.useContext(SelectMenuContext_1.MenuContext);
123
- const backupRef = react_1.useRef(null);
124
- const itemRef = forwardedRef ?? backupRef;
125
- // close the menu when an item is clicked
126
- // this can be overriden if the user provides a `onClick` prop and prevents default in it
127
- const handleClick = (e) => {
128
- onClick && onClick(e);
129
- if (!e.defaultPrevented) {
130
- menuContext.setOpen?.(false);
131
- }
132
- };
133
- return (<StyledItem ref={itemRef} {...rest} theme={theme} onClick={handleClick} aria-checked={selected}>
134
- <StyledOcticon_1.default theme={theme} className="SelectMenu-icon SelectMenu-selected-icon" icon={octicons_react_1.CheckIcon}/>
135
- {children}
136
- </StyledItem>);
137
- });
138
- SelectMenuItem.defaultProps = {
139
- selected: false
140
- };
141
- SelectMenuItem.displayName = 'SelectMenu.Item';
142
- exports.default = SelectMenuItem;
@@ -1,59 +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 styled_components_1 = __importStar(require("styled-components"));
26
- const constants_1 = require("../constants");
27
- const sx_1 = __importDefault(require("../sx"));
28
- const listStyles = styled_components_1.css `
29
- position: relative;
30
- padding: 0;
31
- margin: 0;
32
- flex: auto;
33
- overflow-x: hidden;
34
- overflow-y: auto;
35
- background-color: ${constants_1.get('colors.canvas.overlay')};
36
- -webkit-overflow-scrolling: touch; // Adds momentum + bouncy scrolling
37
-
38
- @media (hover: hover) {
39
- .SelectMenuTab:focus {
40
- background-color: ${constants_1.get('colors.selectMenu.tapFocusBg')};
41
- }
42
-
43
- .SelectMenuTab:not([aria-checked='true']):hover {
44
- color: ${constants_1.get('colors.fg.default')};
45
- background-color: ${constants_1.get('colors.canvas.subtle')};
46
- }
47
-
48
- .SelectMenuTab:not([aria-checked='true']):active {
49
- color: ${constants_1.get('colors.fg.default')};
50
- background-color: ${constants_1.get('colors.canvas.subtle')};
51
- }
52
- }
53
- `;
54
- const SelectMenuList = styled_components_1.default.div `
55
- ${listStyles}
56
- ${sx_1.default};
57
- `;
58
- SelectMenuList.displayName = 'SelectMenu.List';
59
- exports.default = SelectMenuList;
@@ -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 react_1 = __importDefault(require("react"));
7
- const styled_components_1 = __importDefault(require("styled-components"));
8
- const constants_1 = require("../constants");
9
- const Spinner_1 = __importDefault(require("../Spinner"));
10
- const sx_1 = __importDefault(require("../sx"));
11
- const Animation = styled_components_1.default.div `
12
- padding: ${constants_1.get('space.6')} ${constants_1.get('space.4')};
13
- text-align: center;
14
- background-color: ${constants_1.get('colors.canvas.overlay')};
15
- ${sx_1.default}
16
- `;
17
- const SelectMenuLoadingAnimation = (props) => {
18
- return (<Animation {...props}>
19
- <Spinner_1.default />
20
- </Animation>);
21
- };
22
- exports.default = SelectMenuLoadingAnimation;