@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/Header.jsx DELETED
@@ -1,83 +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 Header = styled_components_1.default.div `
29
- z-index: 32;
30
- display: flex;
31
- padding: ${constants_1.get('space.3')};
32
- font-size: ${constants_1.get('fontSizes.1')};
33
- line-height: ${constants_1.get('lineHeights.default')};
34
- color: ${constants_1.get('colors.header.text')};
35
- background-color: ${constants_1.get('colors.header.bg')};
36
- align-items: center;
37
- flex-wrap: nowrap;
38
-
39
- ${sx_1.default};
40
- `;
41
- const HeaderItem = styled_components_1.default.div `
42
- display: flex;
43
- margin-right: ${constants_1.get('space.3')};
44
- align-self: stretch;
45
- align-items: center;
46
- flex-wrap: nowrap;
47
-
48
- ${({ full }) => full &&
49
- styled_components_1.css `
50
- flex: auto;
51
- `};
52
-
53
- ${sx_1.default};
54
- `;
55
- HeaderItem.displayName = 'Header.Item';
56
- const HeaderLink = styled_components_1.default.a.attrs(({ to }) => {
57
- const isReactRouter = typeof to === 'string';
58
- if (isReactRouter) {
59
- // according to their docs, NavLink supports aria-current:
60
- // https://reacttraining.com/react-router/web/api/NavLink/aria-current-string
61
- return { 'aria-current': 'page' };
62
- }
63
- else {
64
- return {};
65
- }
66
- }) `
67
- font-weight: ${constants_1.get('fontWeights.bold')};
68
- color: ${constants_1.get('colors.header.logo')};
69
- white-space: nowrap;
70
- cursor: pointer;
71
- text-decoration: none;
72
- display: flex;
73
- align-items: center;
74
-
75
- &:hover,
76
- &:focus {
77
- color: ${constants_1.get('colors.header.text')};
78
- }
79
-
80
- ${sx_1.default};
81
- `;
82
- HeaderLink.displayName = 'Header.Link';
83
- exports.default = Object.assign(Header, { Link: HeaderLink, Item: HeaderItem });
package/lib/Heading.jsx DELETED
@@ -1,21 +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 theme_1 = __importDefault(require("./theme"));
10
- const Heading = styled_components_1.default.h2 `
11
- font-weight: ${constants_1.get('fontWeights.bold')};
12
- font-size: ${constants_1.get('fontSizes.5')};
13
- margin: 0;
14
- ${constants_1.TYPOGRAPHY};
15
- ${constants_1.COMMON};
16
- ${sx_1.default};
17
- `;
18
- Heading.defaultProps = {
19
- theme: theme_1.default
20
- };
21
- exports.default = Heading;
package/lib/Label.jsx DELETED
@@ -1,82 +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 styled_system_1 = require("styled-system");
27
- const constants_1 = require("./constants");
28
- const sx_1 = __importDefault(require("./sx"));
29
- const outlineStyles = styled_components_1.css `
30
- margin-top: -1px; // offsets the 1px border
31
- margin-bottom: -1px; // offsets the 1px border
32
- color: ${constants_1.get('colors.fg.muted')};
33
- border: ${constants_1.get('borderWidths.1')} solid ${constants_1.get('colors.border.default')};
34
- box-shadow: none;
35
- ${styled_system_1.borderColor};
36
- background-color: transparent;
37
- `;
38
- const sizeVariant = styled_system_1.variant({
39
- variants: {
40
- small: {
41
- fontSize: 0,
42
- lineHeight: '16px',
43
- padding: '0px 8px'
44
- },
45
- medium: {
46
- fontSize: 0,
47
- lineHeight: '20px',
48
- padding: '0 8px'
49
- },
50
- large: {
51
- fontSize: 0,
52
- lineHeight: '24px',
53
- padding: '0 12px'
54
- },
55
- // corresponds to StateLabel fontSize/lineHeight/padding
56
- xl: {
57
- fontSize: 1,
58
- lineHeight: '16px',
59
- padding: '8px 12px'
60
- }
61
- }
62
- });
63
- const Label = styled_components_1.default.span `
64
- display: inline-block;
65
- font-weight: ${constants_1.get('fontWeights.semibold')};
66
- color: ${constants_1.get('colors.fg.onEmphasis')};
67
- border-radius: ${constants_1.get('radii.3')};
68
- background-color: ${constants_1.get('colors.neutral.emphasis')};
69
-
70
- &:hover {
71
- text-decoration: none;
72
- }
73
-
74
- ${sizeVariant}
75
- ${props => (props.dropshadow ? 'box-shadow: inset 0 -1px 0 rgba(27, 31, 35, 0.12)' : '')}
76
- ${props => (props.outline ? outlineStyles : '')} // must be last to override other values
77
- ${sx_1.default}
78
- `;
79
- Label.defaultProps = {
80
- variant: 'medium'
81
- };
82
- exports.default = Label;
@@ -1,18 +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 LabelGroup = styled_components_1.default.span `
10
- & * {
11
- margin-right: ${constants_1.get('space.1')};
12
- }
13
- & *:last-child {
14
- margin-right: 0;
15
- }
16
- ${sx_1.default};
17
- `;
18
- exports.default = LabelGroup;
package/lib/Link.jsx DELETED
@@ -1,36 +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 hoverColor = styled_system_1.system({
11
- hoverColor: {
12
- property: 'color',
13
- scale: 'colors'
14
- }
15
- });
16
- const Link = styled_components_1.default.a `
17
- color: ${props => (props.muted ? constants_1.get('colors.fg.muted')(props) : constants_1.get('colors.accent.fg')(props))};
18
- text-decoration: ${props => (props.underline ? 'underline' : 'none')};
19
- &:hover {
20
- text-decoration: ${props => (props.muted ? 'none' : 'underline')};
21
- ${props => (props.hoverColor ? hoverColor : props.muted ? `color: ${constants_1.get('colors.accent.fg')(props)}` : '')};
22
- }
23
- &:is(button) {
24
- display: inline-block;
25
- padding: 0;
26
- font-size: inherit;
27
- white-space: nowrap;
28
- cursor: pointer;
29
- user-select: none;
30
- background-color: transparent;
31
- border: 0;
32
- appearance: none;
33
- }
34
- ${sx_1.default};
35
- `;
36
- exports.default = Link;
@@ -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.Counter = void 0;
7
- const react_1 = __importDefault(require("react"));
8
- const CounterLabel_1 = __importDefault(require("../CounterLabel"));
9
- const Counter = ({ children, sx: sxProp = {}, ...props }) => {
10
- return (<CounterLabel_1.default data-component="ButtonCounter" sx={{ ml: 2, ...sxProp }} {...props}>
11
- {children}
12
- </CounterLabel_1.default>);
13
- };
14
- exports.Counter = Counter;
@@ -1,279 +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.Button = void 0;
26
- const react_1 = __importStar(require("react"));
27
- const Box_1 = __importDefault(require("../Box"));
28
- const styled_components_1 = __importDefault(require("styled-components"));
29
- const sx_1 = __importStar(require("../sx"));
30
- const ThemeProvider_1 = require("../ThemeProvider");
31
- const TEXT_ROW_HEIGHT = '20px'; // custom value off the scale
32
- const getVariantStyles = (variant = 'default', theme) => {
33
- const style = {
34
- default: {
35
- color: 'btn.text',
36
- backgroundColor: 'btn.bg',
37
- boxShadow: `${theme?.shadows.btn.shadow}, ${theme?.shadows.btn.insetShadow}`,
38
- '&:hover:not([disabled])': {
39
- backgroundColor: 'btn.hoverBg'
40
- },
41
- // focus must come before :active so that the active box shadow overrides
42
- '&:focus:not([disabled])': {
43
- boxShadow: `${theme?.shadows.btn.focusShadow}`
44
- },
45
- '&:active:not([disabled])': {
46
- backgroundColor: 'btn.selectedBg',
47
- boxShadow: `${theme?.shadows.btn.shadowActive}`
48
- },
49
- '&:disabled': {
50
- color: 'primer.fg.disabled',
51
- backgroundColor: 'btn.disabledBg'
52
- }
53
- },
54
- primary: {
55
- color: 'btn.primary.text',
56
- backgroundColor: 'btn.primary.bg',
57
- borderColor: 'border.subtle',
58
- boxShadow: `${theme?.shadows.btn.primary.shadow}`,
59
- '&:hover:not([disabled])': {
60
- color: 'btn.primary.hoverText',
61
- backgroundColor: 'btn.primary.hoverBg'
62
- },
63
- // focus must come before :active so that the active box shadow overrides
64
- '&:focus:not([disabled])': {
65
- boxShadow: `${theme?.shadows.btn.primary.focusShadow}`
66
- },
67
- '&:active:not([disabled])': {
68
- backgroundColor: 'btn.primary.selectedBg',
69
- boxShadow: `${theme?.shadows.btn.primary.selectedShadow}`
70
- },
71
- '&:disabled': {
72
- color: 'btn.primary.disabledText',
73
- backgroundColor: 'btn.primary.disabledBg'
74
- },
75
- '[data-component="ButtonCounter"]': {
76
- backgroundColor: 'btn.primary.counterBg',
77
- color: 'btn.primary.text'
78
- }
79
- },
80
- danger: {
81
- color: 'btn.danger.text',
82
- backgroundColor: 'btn.bg',
83
- boxShadow: `${theme?.shadows.btn.shadow}`,
84
- '&:hover:not([disabled])': {
85
- color: 'btn.danger.hoverText',
86
- backgroundColor: 'btn.danger.hoverBg',
87
- borderColor: 'btn.danger.hoverBorder',
88
- boxShadow: `${theme?.shadows.btn.danger.hoverShadow}`,
89
- '[data-component="ButtonCounter"]': {
90
- backgroundColor: 'btn.danger.hoverCounterBg',
91
- color: 'btn.danger.hoverText'
92
- }
93
- },
94
- // focus must come before :active so that the active box shadow overrides
95
- '&:focus:not([disabled])': {
96
- borderColor: 'btn.danger.focusBorder',
97
- boxShadow: `${theme?.shadows.btn.danger.focusShadow}`
98
- },
99
- '&:active:not([disabled])': {
100
- color: 'btn.danger.selectedText',
101
- backgroundColor: 'btn.danger.selectedBg',
102
- boxShadow: `${theme?.shadows.btn.danger.selectedShadow}`,
103
- borderColor: 'btn.danger.selectedBorder'
104
- },
105
- '&:disabled': {
106
- color: 'btn.danger.disabledText',
107
- backgroundColor: 'btn.danger.disabledBg',
108
- borderColor: 'btn.danger.disabledBorder',
109
- '[data-component="ButtonCounter"]': {
110
- backgroundColor: 'btn.danger.disabledCounterBg'
111
- }
112
- },
113
- '[data-component="ButtonCounter"]': {
114
- color: 'btn.danger.text',
115
- backgroundColor: 'btn.danger.counterBg'
116
- }
117
- },
118
- invisible: {
119
- color: 'accent.fg',
120
- backgroundColor: 'transparent',
121
- border: '0',
122
- boxShadow: 'none',
123
- '&:hover:not([disabled])': {
124
- backgroundColor: 'btn.hoverBg'
125
- },
126
- // focus must come before :active so that the active box shadow overrides
127
- '&:focus:not([disabled])': {
128
- boxShadow: `${theme?.shadows.btn.focusShadow}`
129
- },
130
- '&:active:not([disabled])': {
131
- backgroundColor: 'btn.selectedBg'
132
- },
133
- '&:disabled': {
134
- color: 'primer.fg.disabled'
135
- }
136
- },
137
- outline: {
138
- color: 'btn.outline.text',
139
- boxShadow: `${theme?.shadows.btn.shadow}`,
140
- '&:hover': {
141
- color: 'btn.outline.hoverText',
142
- backgroundColor: 'btn.outline.hoverBg',
143
- borderColor: 'outline.hoverBorder',
144
- boxShadow: `${theme?.shadows.btn.outline.hoverShadow}`,
145
- '[data-component="ButtonCounter"]': {
146
- backgroundColor: 'btn.outline.hoverCounterBg',
147
- color: 'btn.outline.hoverText'
148
- }
149
- },
150
- // focus must come before :active so that the active box shadow overrides
151
- '&:focus': {
152
- borderColor: 'btn.outline.focusBorder',
153
- boxShadow: `${theme?.shadows.btn.outline.focusShadow}`
154
- },
155
- '&:active:not([disabled])': {
156
- color: 'btn.outline.selectedText',
157
- backgroundColor: 'btn.outline.selectedBg',
158
- boxShadow: `${theme?.shadows.btn.outline.selectedShadow}`,
159
- borderColor: 'btn.outline.selectedBorder'
160
- },
161
- '&:disabled': {
162
- color: 'btn.outline.disabledText',
163
- backgroundColor: 'btn.outline.disabledBg',
164
- borderColor: 'btn.border',
165
- '[data-component="ButtonCounter"]': {
166
- backgroundColor: 'btn.outline.disabledCounterBg'
167
- }
168
- },
169
- '[data-component="ButtonCounter"]': {
170
- backgroundColor: 'btn.outline.counterBg',
171
- color: 'btn.outline.text'
172
- }
173
- }
174
- };
175
- return style[variant];
176
- };
177
- const getSizeStyles = (size = 'medium', variant = 'default', iconOnly) => {
178
- let paddingY, paddingX, fontSize;
179
- switch (size) {
180
- case 'small':
181
- paddingY = 3;
182
- paddingX = 12;
183
- fontSize = 0;
184
- break;
185
- case 'large':
186
- paddingY = 9;
187
- paddingX = 20;
188
- fontSize = 2;
189
- break;
190
- case 'medium':
191
- default:
192
- paddingY = 5;
193
- paddingX = 16;
194
- fontSize = 1;
195
- }
196
- if (iconOnly) {
197
- paddingX = paddingY + 2;
198
- }
199
- if (variant === 'invisible') {
200
- paddingY = paddingY + 1;
201
- }
202
- return {
203
- paddingY: `${paddingY}px`,
204
- paddingX: `${paddingX}px`,
205
- fontSize,
206
- '[data-component="ButtonCounter"]': {
207
- fontSize
208
- }
209
- };
210
- };
211
- const ButtonBase = styled_components_1.default.button(sx_1.default);
212
- const Button = react_1.forwardRef(({ children, sx: sxProp = {}, ...props }, forwardedRef) => {
213
- const { icon: Icon, leadingIcon: LeadingIcon, trailingIcon: TrailingIcon, variant = 'default', size = 'medium' } = props;
214
- const iconOnly = !!Icon;
215
- const { theme } = ThemeProvider_1.useTheme();
216
- const styles = {
217
- borderRadius: '2',
218
- border: '1px solid',
219
- borderColor: theme?.colors.btn.border,
220
- display: 'grid',
221
- gridTemplateAreas: '"leadingIcon text trailingIcon"',
222
- fontWeight: 'bold',
223
- lineHeight: TEXT_ROW_HEIGHT,
224
- whiteSpace: 'nowrap',
225
- verticalAlign: 'middle',
226
- cursor: 'pointer',
227
- appearance: 'none',
228
- userSelect: 'none',
229
- textDecoration: 'none',
230
- textAlign: 'center',
231
- '& > :not(:last-child)': {
232
- mr: '2'
233
- },
234
- '&:focus': {
235
- outline: 'none'
236
- },
237
- '&:disabled': {
238
- cursor: 'default'
239
- },
240
- '&:disabled svg': {
241
- opacity: '0.6'
242
- },
243
- '[data-component="leadingIcon"]': {
244
- gridArea: 'leadingIcon'
245
- },
246
- '[data-component="text"]': {
247
- gridArea: 'text'
248
- },
249
- '[data-component="trailingIcon"]': {
250
- gridArea: 'trailingIcon'
251
- }
252
- };
253
- const iconWrapStyles = {
254
- display: 'inline-block'
255
- };
256
- const sxStyles = sx_1.merge.all([
257
- styles,
258
- getSizeStyles(size, variant, iconOnly),
259
- getVariantStyles(variant, theme),
260
- sxProp
261
- ]);
262
- return (<ButtonBase sx={sxStyles} ref={forwardedRef} {...props}>
263
- {LeadingIcon && (<Box_1.default as="span" data-component="leadingIcon" sx={iconWrapStyles} aria-hidden={!iconOnly}>
264
- <LeadingIcon />
265
- </Box_1.default>)}
266
- <span data-component="text" hidden={Icon ? true : false}>
267
- {children}
268
- </span>
269
- {Icon && (<Box_1.default data-component="icon-only" as="span" sx={{ display: 'inline-block' }} aria-hidden={!iconOnly}>
270
- <Icon />
271
- </Box_1.default>)}
272
- {TrailingIcon && (<Box_1.default as="span" data-component="trailingIcon" sx={{ ...iconWrapStyles, ml: 2 }} aria-hidden={!iconOnly}>
273
- <TrailingIcon />
274
- </Box_1.default>)}
275
- </ButtonBase>);
276
- });
277
- exports.Button = Button;
278
- Button.displayName = 'Button';
279
- Object.assign(Button, {});