@primer/components 0.0.0-202111231117 → 0.0.0-202111245715

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 (175) hide show
  1. package/CHANGELOG.md +9 -3
  2. package/dist/browser.esm.js +586 -604
  3. package/dist/browser.esm.js.map +1 -1
  4. package/dist/browser.umd.js +204 -222
  5. package/dist/browser.umd.js.map +1 -1
  6. package/lib/Autocomplete/AutocompleteMenu.js +13 -6
  7. package/lib/Avatar.d.ts +1 -2
  8. package/lib/Avatar.js +1 -1
  9. package/lib/BranchName.d.ts +1 -2
  10. package/lib/BranchName.js +1 -1
  11. package/lib/Checkbox.d.ts +1 -1
  12. package/lib/Details.d.ts +1 -2
  13. package/lib/Details.js +1 -3
  14. package/lib/Dropdown.d.ts +2 -66
  15. package/lib/Heading.d.ts +1 -2
  16. package/lib/Heading.js +1 -6
  17. package/lib/NewButton/button-base.d.ts +6 -0
  18. package/lib/NewButton/button-base.js +69 -0
  19. package/lib/NewButton/button-link.d.ts +26 -0
  20. package/lib/{ChoiceFieldset/ChoiceFieldLabel.js → NewButton/button-link.js} +14 -18
  21. package/lib/NewButton/button.d.ts +2 -11
  22. package/lib/NewButton/button.js +6 -283
  23. package/lib/NewButton/icon-button.d.ts +4 -0
  24. package/lib/NewButton/icon-button.js +57 -0
  25. package/lib/NewButton/index.d.ts +6 -11
  26. package/lib/NewButton/index.js +18 -0
  27. package/lib/NewButton/styles.d.ts +202 -0
  28. package/lib/NewButton/styles.js +248 -0
  29. package/lib/NewButton/types.d.ts +28 -8
  30. package/lib/NewButton/types.js +19 -1
  31. package/lib/ProgressBar.d.ts +16 -11
  32. package/lib/ProgressBar.js +6 -10
  33. package/lib/Spinner.d.ts +1 -2
  34. package/lib/Spinner.js +1 -3
  35. package/lib/index.d.ts +0 -4
  36. package/lib/index.js +0 -38
  37. package/lib-esm/Autocomplete/AutocompleteMenu.js +13 -3
  38. package/lib-esm/Avatar.d.ts +1 -2
  39. package/lib-esm/Avatar.js +2 -2
  40. package/lib-esm/BranchName.d.ts +1 -2
  41. package/lib-esm/BranchName.js +2 -2
  42. package/lib-esm/Checkbox.d.ts +1 -1
  43. package/lib-esm/Details.d.ts +1 -2
  44. package/lib-esm/Details.js +1 -2
  45. package/lib-esm/Dropdown.d.ts +2 -66
  46. package/lib-esm/Heading.d.ts +1 -2
  47. package/lib-esm/Heading.js +2 -6
  48. package/lib-esm/NewButton/button-base.d.ts +6 -0
  49. package/lib-esm/NewButton/button-base.js +47 -0
  50. package/lib-esm/NewButton/button-link.d.ts +26 -0
  51. package/lib-esm/NewButton/button-link.js +15 -0
  52. package/lib-esm/NewButton/button.d.ts +2 -11
  53. package/lib-esm/NewButton/button.js +4 -275
  54. package/lib-esm/NewButton/icon-button.d.ts +4 -0
  55. package/lib-esm/NewButton/icon-button.js +35 -0
  56. package/lib-esm/NewButton/index.d.ts +6 -11
  57. package/lib-esm/NewButton/index.js +4 -1
  58. package/lib-esm/NewButton/styles.d.ts +202 -0
  59. package/lib-esm/NewButton/styles.js +229 -0
  60. package/lib-esm/NewButton/types.d.ts +28 -8
  61. package/lib-esm/NewButton/types.js +6 -1
  62. package/lib-esm/ProgressBar.d.ts +16 -11
  63. package/lib-esm/ProgressBar.js +7 -11
  64. package/lib-esm/Spinner.d.ts +1 -2
  65. package/lib-esm/Spinner.js +1 -2
  66. package/lib-esm/index.d.ts +0 -4
  67. package/lib-esm/index.js +0 -4
  68. package/package.json +2 -2
  69. package/lib/CheckboxInputField.d.ts +0 -11
  70. package/lib/CheckboxInputField.js +0 -73
  71. package/lib/ChoiceFieldset/ChoiceFieldCaption.d.ts +0 -3
  72. package/lib/ChoiceFieldset/ChoiceFieldCaption.js +0 -35
  73. package/lib/ChoiceFieldset/ChoiceFieldLabel.d.ts +0 -3
  74. package/lib/ChoiceFieldset/ChoiceFieldset.d.ts +0 -65
  75. package/lib/ChoiceFieldset/ChoiceFieldset.js +0 -95
  76. package/lib/ChoiceFieldset/ChoiceFieldsetDescription.d.ts +0 -3
  77. package/lib/ChoiceFieldset/ChoiceFieldsetDescription.js +0 -29
  78. package/lib/ChoiceFieldset/ChoiceFieldsetLegend.d.ts +0 -9
  79. package/lib/ChoiceFieldset/ChoiceFieldsetLegend.js +0 -44
  80. package/lib/ChoiceFieldset/ChoiceFieldsetList.d.ts +0 -9
  81. package/lib/ChoiceFieldset/ChoiceFieldsetList.js +0 -80
  82. package/lib/ChoiceFieldset/ChoiceFieldsetListContext.d.ts +0 -19
  83. package/lib/ChoiceFieldset/ChoiceFieldsetListContext.js +0 -15
  84. package/lib/ChoiceFieldset/ChoiceFieldsetListItem.d.ts +0 -25
  85. package/lib/ChoiceFieldset/ChoiceFieldsetListItem.js +0 -75
  86. package/lib/ChoiceFieldset/ChoiceFieldsetValidation.d.ts +0 -6
  87. package/lib/ChoiceFieldset/ChoiceFieldsetValidation.js +0 -17
  88. package/lib/ChoiceFieldset/index.d.ts +0 -3
  89. package/lib/ChoiceFieldset/index.js +0 -23
  90. package/lib/RadioInputField.d.ts +0 -9
  91. package/lib/RadioInputField.js +0 -82
  92. package/lib/TextInputField.d.ts +0 -581
  93. package/lib/TextInputField.js +0 -66
  94. package/lib/_InputCaption.d.ts +0 -13
  95. package/lib/_InputCaption.js +0 -27
  96. package/lib/_InputField/InputField.d.ts +0 -39
  97. package/lib/_InputField/InputField.js +0 -90
  98. package/lib/_InputField/InputFieldCaption.d.ts +0 -3
  99. package/lib/_InputField/InputFieldCaption.js +0 -30
  100. package/lib/_InputField/InputFieldLabel.d.ts +0 -9
  101. package/lib/_InputField/InputFieldLabel.js +0 -34
  102. package/lib/_InputField/InputFieldValidation.d.ts +0 -6
  103. package/lib/_InputField/InputFieldValidation.js +0 -17
  104. package/lib/_InputField/ToggleInputField.d.ts +0 -13
  105. package/lib/_InputField/ToggleInputField.js +0 -71
  106. package/lib/_InputField/ToggleInputLeadingVisual.d.ts +0 -3
  107. package/lib/_InputField/ToggleInputLeadingVisual.js +0 -22
  108. package/lib/_InputField/ValidationAnimationContainer.d.ts +0 -6
  109. package/lib/_InputField/ValidationAnimationContainer.js +0 -48
  110. package/lib/_InputField/index.d.ts +0 -1
  111. package/lib/_InputField/index.js +0 -15
  112. package/lib/_InputField/slots.d.ts +0 -13
  113. package/lib/_InputField/slots.js +0 -17
  114. package/lib/_InputLabel.d.ts +0 -8
  115. package/lib/_InputLabel.js +0 -44
  116. package/lib/_InputValidation.d.ts +0 -8
  117. package/lib/_InputValidation.js +0 -56
  118. package/lib/_VisuallyHidden.d.ts +0 -6
  119. package/lib/_VisuallyHidden.js +0 -39
  120. package/lib/utils/types/FormValidationStatus.d.ts +0 -1
  121. package/lib/utils/types/FormValidationStatus.js +0 -1
  122. package/lib-esm/CheckboxInputField.d.ts +0 -11
  123. package/lib-esm/CheckboxInputField.js +0 -56
  124. package/lib-esm/ChoiceFieldset/ChoiceFieldCaption.d.ts +0 -3
  125. package/lib-esm/ChoiceFieldset/ChoiceFieldCaption.js +0 -20
  126. package/lib-esm/ChoiceFieldset/ChoiceFieldLabel.d.ts +0 -3
  127. package/lib-esm/ChoiceFieldset/ChoiceFieldLabel.js +0 -20
  128. package/lib-esm/ChoiceFieldset/ChoiceFieldset.d.ts +0 -65
  129. package/lib-esm/ChoiceFieldset/ChoiceFieldset.js +0 -72
  130. package/lib-esm/ChoiceFieldset/ChoiceFieldsetDescription.d.ts +0 -3
  131. package/lib-esm/ChoiceFieldset/ChoiceFieldsetDescription.js +0 -17
  132. package/lib-esm/ChoiceFieldset/ChoiceFieldsetLegend.d.ts +0 -9
  133. package/lib-esm/ChoiceFieldset/ChoiceFieldsetLegend.js +0 -31
  134. package/lib-esm/ChoiceFieldset/ChoiceFieldsetList.d.ts +0 -9
  135. package/lib-esm/ChoiceFieldset/ChoiceFieldsetList.js +0 -63
  136. package/lib-esm/ChoiceFieldset/ChoiceFieldsetListContext.d.ts +0 -19
  137. package/lib-esm/ChoiceFieldset/ChoiceFieldsetListContext.js +0 -5
  138. package/lib-esm/ChoiceFieldset/ChoiceFieldsetListItem.d.ts +0 -25
  139. package/lib-esm/ChoiceFieldset/ChoiceFieldsetListItem.js +0 -51
  140. package/lib-esm/ChoiceFieldset/ChoiceFieldsetValidation.d.ts +0 -6
  141. package/lib-esm/ChoiceFieldset/ChoiceFieldsetValidation.js +0 -7
  142. package/lib-esm/ChoiceFieldset/index.d.ts +0 -3
  143. package/lib-esm/ChoiceFieldset/index.js +0 -2
  144. package/lib-esm/RadioInputField.d.ts +0 -9
  145. package/lib-esm/RadioInputField.js +0 -65
  146. package/lib-esm/TextInputField.d.ts +0 -581
  147. package/lib-esm/TextInputField.js +0 -50
  148. package/lib-esm/_InputCaption.d.ts +0 -13
  149. package/lib-esm/_InputCaption.js +0 -16
  150. package/lib-esm/_InputField/InputField.d.ts +0 -39
  151. package/lib-esm/_InputField/InputField.js +0 -70
  152. package/lib-esm/_InputField/InputFieldCaption.d.ts +0 -3
  153. package/lib-esm/_InputField/InputFieldCaption.js +0 -18
  154. package/lib-esm/_InputField/InputFieldLabel.d.ts +0 -9
  155. package/lib-esm/_InputField/InputFieldLabel.js +0 -22
  156. package/lib-esm/_InputField/InputFieldValidation.d.ts +0 -6
  157. package/lib-esm/_InputField/InputFieldValidation.js +0 -7
  158. package/lib-esm/_InputField/ToggleInputField.d.ts +0 -13
  159. package/lib-esm/_InputField/ToggleInputField.js +0 -54
  160. package/lib-esm/_InputField/ToggleInputLeadingVisual.d.ts +0 -3
  161. package/lib-esm/_InputField/ToggleInputLeadingVisual.js +0 -11
  162. package/lib-esm/_InputField/ValidationAnimationContainer.d.ts +0 -6
  163. package/lib-esm/_InputField/ValidationAnimationContainer.js +0 -33
  164. package/lib-esm/_InputField/index.d.ts +0 -1
  165. package/lib-esm/_InputField/index.js +0 -1
  166. package/lib-esm/_InputField/slots.d.ts +0 -13
  167. package/lib-esm/_InputField/slots.js +0 -5
  168. package/lib-esm/_InputLabel.d.ts +0 -8
  169. package/lib-esm/_InputLabel.js +0 -32
  170. package/lib-esm/_InputValidation.d.ts +0 -8
  171. package/lib-esm/_InputValidation.js +0 -43
  172. package/lib-esm/_VisuallyHidden.d.ts +0 -6
  173. package/lib-esm/_VisuallyHidden.js +0 -26
  174. package/lib-esm/utils/types/FormValidationStatus.d.ts +0 -1
  175. package/lib-esm/utils/types/FormValidationStatus.js +0 -1
@@ -7,13 +7,7 @@ exports.Button = void 0;
7
7
 
8
8
  var _react = _interopRequireWildcard(require("react"));
9
9
 
10
- var _Box = _interopRequireDefault(require("../Box"));
11
-
12
- var _styledComponents = _interopRequireDefault(require("styled-components"));
13
-
14
- var _sx = _interopRequireWildcard(require("../sx"));
15
-
16
- var _ThemeProvider = require("../ThemeProvider");
10
+ var _buttonBase = _interopRequireDefault(require("./button-base"));
17
11
 
18
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
13
 
@@ -23,286 +17,15 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
23
17
 
24
18
  function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
25
19
 
26
- const TEXT_ROW_HEIGHT = '20px'; // custom value off the scale
27
-
28
- const getVariantStyles = (variant = 'default', theme) => {
29
- const style = {
30
- default: {
31
- color: 'btn.text',
32
- backgroundColor: 'btn.bg',
33
- boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.shadow}, ${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.insetShadow}`,
34
- '&:hover:not([disabled])': {
35
- backgroundColor: 'btn.hoverBg'
36
- },
37
- // focus must come before :active so that the active box shadow overrides
38
- '&:focus:not([disabled])': {
39
- boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.focusShadow}`
40
- },
41
- '&:active:not([disabled])': {
42
- backgroundColor: 'btn.selectedBg',
43
- boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.shadowActive}`
44
- },
45
- '&:disabled': {
46
- color: 'primer.fg.disabled',
47
- backgroundColor: 'btn.disabledBg'
48
- }
49
- },
50
- primary: {
51
- color: 'btn.primary.text',
52
- backgroundColor: 'btn.primary.bg',
53
- borderColor: 'border.subtle',
54
- boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.primary.shadow}`,
55
- '&:hover:not([disabled])': {
56
- color: 'btn.primary.hoverText',
57
- backgroundColor: 'btn.primary.hoverBg'
58
- },
59
- // focus must come before :active so that the active box shadow overrides
60
- '&:focus:not([disabled])': {
61
- boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.primary.focusShadow}`
62
- },
63
- '&:active:not([disabled])': {
64
- backgroundColor: 'btn.primary.selectedBg',
65
- boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.primary.selectedShadow}`
66
- },
67
- '&:disabled': {
68
- color: 'btn.primary.disabledText',
69
- backgroundColor: 'btn.primary.disabledBg'
70
- },
71
- '[data-component="ButtonCounter"]': {
72
- backgroundColor: 'btn.primary.counterBg',
73
- color: 'btn.primary.text'
74
- }
75
- },
76
- danger: {
77
- color: 'btn.danger.text',
78
- backgroundColor: 'btn.bg',
79
- boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.shadow}`,
80
- '&:hover:not([disabled])': {
81
- color: 'btn.danger.hoverText',
82
- backgroundColor: 'btn.danger.hoverBg',
83
- borderColor: 'btn.danger.hoverBorder',
84
- boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.danger.hoverShadow}`,
85
- '[data-component="ButtonCounter"]': {
86
- backgroundColor: 'btn.danger.hoverCounterBg',
87
- color: 'btn.danger.hoverText'
88
- }
89
- },
90
- // focus must come before :active so that the active box shadow overrides
91
- '&:focus:not([disabled])': {
92
- borderColor: 'btn.danger.focusBorder',
93
- boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.danger.focusShadow}`
94
- },
95
- '&:active:not([disabled])': {
96
- color: 'btn.danger.selectedText',
97
- backgroundColor: 'btn.danger.selectedBg',
98
- boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.danger.selectedShadow}`,
99
- borderColor: 'btn.danger.selectedBorder'
100
- },
101
- '&:disabled': {
102
- color: 'btn.danger.disabledText',
103
- backgroundColor: 'btn.danger.disabledBg',
104
- borderColor: 'btn.danger.disabledBorder',
105
- '[data-component="ButtonCounter"]': {
106
- backgroundColor: 'btn.danger.disabledCounterBg'
107
- }
108
- },
109
- '[data-component="ButtonCounter"]': {
110
- color: 'btn.danger.text',
111
- backgroundColor: 'btn.danger.counterBg'
112
- }
113
- },
114
- invisible: {
115
- color: 'accent.fg',
116
- backgroundColor: 'transparent',
117
- border: '0',
118
- boxShadow: 'none',
119
- '&:hover:not([disabled])': {
120
- backgroundColor: 'btn.hoverBg'
121
- },
122
- // focus must come before :active so that the active box shadow overrides
123
- '&:focus:not([disabled])': {
124
- boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.focusShadow}`
125
- },
126
- '&:active:not([disabled])': {
127
- backgroundColor: 'btn.selectedBg'
128
- },
129
- '&:disabled': {
130
- color: 'primer.fg.disabled'
131
- }
132
- },
133
- outline: {
134
- color: 'btn.outline.text',
135
- boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.shadow}`,
136
- '&:hover': {
137
- color: 'btn.outline.hoverText',
138
- backgroundColor: 'btn.outline.hoverBg',
139
- borderColor: 'outline.hoverBorder',
140
- boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.outline.hoverShadow}`,
141
- '[data-component="ButtonCounter"]': {
142
- backgroundColor: 'btn.outline.hoverCounterBg',
143
- color: 'btn.outline.hoverText'
144
- }
145
- },
146
- // focus must come before :active so that the active box shadow overrides
147
- '&:focus': {
148
- borderColor: 'btn.outline.focusBorder',
149
- boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.outline.focusShadow}`
150
- },
151
- '&:active:not([disabled])': {
152
- color: 'btn.outline.selectedText',
153
- backgroundColor: 'btn.outline.selectedBg',
154
- boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.outline.selectedShadow}`,
155
- borderColor: 'btn.outline.selectedBorder'
156
- },
157
- '&:disabled': {
158
- color: 'btn.outline.disabledText',
159
- backgroundColor: 'btn.outline.disabledBg',
160
- borderColor: 'btn.border',
161
- '[data-component="ButtonCounter"]': {
162
- backgroundColor: 'btn.outline.disabledCounterBg'
163
- }
164
- },
165
- '[data-component="ButtonCounter"]': {
166
- backgroundColor: 'btn.outline.counterBg',
167
- color: 'btn.outline.text'
168
- }
169
- }
170
- };
171
- return style[variant];
172
- };
173
-
174
- const getSizeStyles = (size = 'medium', variant = 'default', iconOnly) => {
175
- let paddingY, paddingX, fontSize;
176
-
177
- switch (size) {
178
- case 'small':
179
- paddingY = 3;
180
- paddingX = 12;
181
- fontSize = 0;
182
- break;
183
-
184
- case 'large':
185
- paddingY = 9;
186
- paddingX = 20;
187
- fontSize = 2;
188
- break;
189
-
190
- case 'medium':
191
- default:
192
- paddingY = 5;
193
- paddingX = 16;
194
- fontSize = 1;
195
- }
196
-
197
- if (iconOnly) {
198
- paddingX = paddingY + 2;
199
- }
200
-
201
- if (variant === 'invisible') {
202
- paddingY = paddingY + 1;
203
- }
204
-
205
- return {
206
- paddingY: `${paddingY}px`,
207
- paddingX: `${paddingX}px`,
208
- fontSize,
209
- '[data-component="ButtonCounter"]': {
210
- fontSize
211
- }
212
- };
213
- };
214
-
215
- const ButtonBase = _styledComponents.default.button.withConfig({
216
- displayName: "button__ButtonBase",
217
- componentId: "sc-15k5iqk-0"
218
- })(_sx.default);
219
-
220
20
  const Button = /*#__PURE__*/(0, _react.forwardRef)(({
221
21
  children,
222
- sx: sxProp = {},
223
22
  ...props
224
23
  }, forwardedRef) => {
225
- const {
226
- icon: Icon,
227
- leadingIcon: LeadingIcon,
228
- trailingIcon: TrailingIcon,
229
- variant = 'default',
230
- size = 'medium'
231
- } = props;
232
- const iconOnly = !!Icon;
233
- const {
234
- theme
235
- } = (0, _ThemeProvider.useTheme)();
236
- const styles = {
237
- borderRadius: '2',
238
- border: '1px solid',
239
- borderColor: theme === null || theme === void 0 ? void 0 : theme.colors.btn.border,
240
- display: 'grid',
241
- gridTemplateAreas: '"leadingIcon text trailingIcon"',
242
- fontWeight: 'bold',
243
- lineHeight: TEXT_ROW_HEIGHT,
244
- whiteSpace: 'nowrap',
245
- verticalAlign: 'middle',
246
- cursor: 'pointer',
247
- appearance: 'none',
248
- userSelect: 'none',
249
- textDecoration: 'none',
250
- textAlign: 'center',
251
- '& > :not(:last-child)': {
252
- mr: '2'
253
- },
254
- '&:focus': {
255
- outline: 'none'
256
- },
257
- '&:disabled': {
258
- cursor: 'default'
259
- },
260
- '&:disabled svg': {
261
- opacity: '0.6'
262
- },
263
- '[data-component="leadingIcon"]': {
264
- gridArea: 'leadingIcon'
265
- },
266
- '[data-component="text"]': {
267
- gridArea: 'text'
268
- },
269
- '[data-component="trailingIcon"]': {
270
- gridArea: 'trailingIcon'
271
- }
272
- };
273
- const iconWrapStyles = {
274
- display: 'inline-block'
275
- };
276
-
277
- const sxStyles = _sx.merge.all([styles, getSizeStyles(size, variant, iconOnly), getVariantStyles(variant, theme), sxProp]);
278
-
279
- return /*#__PURE__*/_react.default.createElement(ButtonBase, _extends({
280
- sx: sxStyles,
24
+ return /*#__PURE__*/_react.default.createElement(_buttonBase.default, _extends({
281
25
  ref: forwardedRef
282
- }, props), LeadingIcon && /*#__PURE__*/_react.default.createElement(_Box.default, {
283
- as: "span",
284
- "data-component": "leadingIcon",
285
- sx: iconWrapStyles,
286
- "aria-hidden": !iconOnly
287
- }, /*#__PURE__*/_react.default.createElement(LeadingIcon, null)), /*#__PURE__*/_react.default.createElement("span", {
288
- "data-component": "text",
289
- hidden: Icon ? true : false
290
- }, children), Icon && /*#__PURE__*/_react.default.createElement(_Box.default, {
291
- "data-component": "icon-only",
292
- as: "span",
293
- sx: {
294
- display: 'inline-block'
295
- },
296
- "aria-hidden": !iconOnly
297
- }, /*#__PURE__*/_react.default.createElement(Icon, null)), TrailingIcon && /*#__PURE__*/_react.default.createElement(_Box.default, {
298
- as: "span",
299
- "data-component": "trailingIcon",
300
- sx: { ...iconWrapStyles,
301
- ml: 2
302
- },
303
- "aria-hidden": !iconOnly
304
- }, /*#__PURE__*/_react.default.createElement(TrailingIcon, null)));
26
+ }, props, {
27
+ as: "button"
28
+ }), children);
305
29
  });
306
30
  exports.Button = Button;
307
- Button.displayName = 'Button';
308
- Object.assign(Button, {});
31
+ Button.displayName = 'Button';
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import { IconButtonProps } from './types';
3
+ declare const IconButton: React.ForwardRefExoticComponent<Pick<IconButtonProps, string | number | symbol> & React.RefAttributes<HTMLButtonElement>>;
4
+ export default IconButton;
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _react = _interopRequireWildcard(require("react"));
9
+
10
+ var _sx = require("../sx");
11
+
12
+ var _ThemeProvider = require("../ThemeProvider");
13
+
14
+ var _Box = _interopRequireDefault(require("../Box"));
15
+
16
+ var _types = require("./types");
17
+
18
+ var _styles = require("./styles");
19
+
20
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
+
22
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
23
+
24
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
25
+
26
+ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
27
+
28
+ const IconButton = /*#__PURE__*/(0, _react.forwardRef)((props, forwardedRef) => {
29
+ const {
30
+ variant = 'default',
31
+ size = 'medium',
32
+ sx: sxProp = {},
33
+ icon: Icon,
34
+ iconLabel
35
+ } = props;
36
+ const {
37
+ theme
38
+ } = (0, _ThemeProvider.useTheme)();
39
+ const styles = { ...(0, _styles.getBaseStyles)(theme)
40
+ };
41
+
42
+ const sxStyles = _sx.merge.all([styles, (0, _styles.getSizeStyles)(size, variant, true), (0, _styles.getVariantStyles)(variant, theme), sxProp]);
43
+
44
+ return /*#__PURE__*/_react.default.createElement(_types.StyledButton, _extends({
45
+ sx: sxStyles,
46
+ ref: forwardedRef
47
+ }, props), /*#__PURE__*/_react.default.createElement("span", {
48
+ hidden: true
49
+ }, iconLabel), /*#__PURE__*/_react.default.createElement(_Box.default, {
50
+ as: "span",
51
+ sx: {
52
+ display: 'inline-block'
53
+ }
54
+ }, /*#__PURE__*/_react.default.createElement(Icon, null)));
55
+ });
56
+ var _default = IconButton;
57
+ exports.default = _default;
@@ -1,14 +1,9 @@
1
1
  /// <reference types="react" />
2
- import { ButtonProps } from './types';
3
- export type { ButtonProps as NewButtonProps };
4
- export declare const NewButton: import("react").ForwardRefExoticComponent<{
5
- variant?: import("./types").VariantType | undefined;
6
- size?: import("./types").Size | undefined;
7
- icon?: import("react").FunctionComponent<import("@primer/octicons-react/dist/icons").IconProps> | undefined;
8
- leadingIcon?: import("react").FunctionComponent<import("@primer/octicons-react/dist/icons").IconProps> | undefined;
9
- trailingIcon?: import("react").FunctionComponent<import("@primer/octicons-react/dist/icons").IconProps> | undefined;
10
- disabled?: boolean | undefined;
11
- children: import("react").ReactNode;
12
- } & import("../sx").SxProp & import("react").HTMLAttributes<HTMLButtonElement> & import("react").RefAttributes<HTMLButtonElement>> & {
2
+ import IconButton from './icon-button';
3
+ import ButtonLink from './button-link';
4
+ import { ButtonProps, IconButtonProps } from './types';
5
+ export type { ButtonProps as NewButtonProps, IconButtonProps };
6
+ export declare const NewButton: import("react").ForwardRefExoticComponent<Pick<ButtonProps, string | number | symbol> & import("react").RefAttributes<HTMLButtonElement>> & {
13
7
  Counter: ({ children, sx: sxProp, ...props }: import("./button-counter").CounterProps) => JSX.Element;
14
8
  };
9
+ export { IconButton, ButtonLink };
@@ -3,12 +3,30 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ Object.defineProperty(exports, "IconButton", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _iconButton.default;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "ButtonLink", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _buttonLink.default;
16
+ }
17
+ });
6
18
  exports.NewButton = void 0;
7
19
 
8
20
  var _button = require("./button");
9
21
 
10
22
  var _buttonCounter = require("./button-counter");
11
23
 
24
+ var _iconButton = _interopRequireDefault(require("./icon-button"));
25
+
26
+ var _buttonLink = _interopRequireDefault(require("./button-link"));
27
+
28
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
29
+
12
30
  const NewButton = Object.assign(_button.Button, {
13
31
  Counter: _buttonCounter.Counter
14
32
  });
@@ -0,0 +1,202 @@
1
+ import { VariantType } from './types';
2
+ import { Theme } from '../ThemeProvider';
3
+ export declare const TEXT_ROW_HEIGHT = "20px";
4
+ export declare const getVariantStyles: (variant?: VariantType, theme?: Theme | undefined) => {
5
+ color: string;
6
+ backgroundColor: string;
7
+ boxShadow: string;
8
+ '&:hover:not([disabled])': {
9
+ backgroundColor: string;
10
+ };
11
+ '&:focus:not([disabled])': {
12
+ boxShadow: string;
13
+ };
14
+ '&:active:not([disabled])': {
15
+ backgroundColor: string;
16
+ boxShadow: string;
17
+ };
18
+ '&:disabled': {
19
+ color: string;
20
+ backgroundColor: string;
21
+ };
22
+ } | {
23
+ color: string;
24
+ backgroundColor: string;
25
+ borderColor: string;
26
+ boxShadow: string;
27
+ '&:hover:not([disabled])': {
28
+ color: string;
29
+ backgroundColor: string;
30
+ };
31
+ '&:focus:not([disabled])': {
32
+ boxShadow: string;
33
+ };
34
+ '&:active:not([disabled])': {
35
+ backgroundColor: string;
36
+ boxShadow: string;
37
+ };
38
+ '&:disabled': {
39
+ color: string;
40
+ backgroundColor: string;
41
+ };
42
+ '[data-component="ButtonCounter"]': {
43
+ backgroundColor: string;
44
+ color: string;
45
+ };
46
+ } | {
47
+ color: string;
48
+ backgroundColor: string;
49
+ boxShadow: string;
50
+ '&:hover:not([disabled])': {
51
+ color: string;
52
+ backgroundColor: string;
53
+ borderColor: string;
54
+ boxShadow: string;
55
+ '[data-component="ButtonCounter"]': {
56
+ backgroundColor: string;
57
+ color: string;
58
+ };
59
+ };
60
+ '&:focus:not([disabled])': {
61
+ borderColor: string;
62
+ boxShadow: string;
63
+ };
64
+ '&:active:not([disabled])': {
65
+ color: string;
66
+ backgroundColor: string;
67
+ boxShadow: string;
68
+ borderColor: string;
69
+ };
70
+ '&:disabled': {
71
+ color: string;
72
+ backgroundColor: string;
73
+ borderColor: string;
74
+ '[data-component="ButtonCounter"]': {
75
+ backgroundColor: string;
76
+ };
77
+ };
78
+ '[data-component="ButtonCounter"]': {
79
+ color: string;
80
+ backgroundColor: string;
81
+ };
82
+ } | {
83
+ color: string;
84
+ backgroundColor: string;
85
+ border: string;
86
+ boxShadow: string;
87
+ '&:hover:not([disabled])': {
88
+ backgroundColor: string;
89
+ };
90
+ '&:focus:not([disabled])': {
91
+ boxShadow: string;
92
+ };
93
+ '&:active:not([disabled])': {
94
+ backgroundColor: string;
95
+ };
96
+ '&:disabled': {
97
+ color: string;
98
+ };
99
+ } | {
100
+ color: string;
101
+ boxShadow: string;
102
+ '&:hover': {
103
+ color: string;
104
+ backgroundColor: string;
105
+ borderColor: string;
106
+ boxShadow: string;
107
+ '[data-component="ButtonCounter"]': {
108
+ backgroundColor: string;
109
+ color: string;
110
+ };
111
+ };
112
+ '&:focus': {
113
+ borderColor: string;
114
+ boxShadow: string;
115
+ };
116
+ '&:active:not([disabled])': {
117
+ color: string;
118
+ backgroundColor: string;
119
+ boxShadow: string;
120
+ borderColor: string;
121
+ };
122
+ '&:disabled': {
123
+ color: string;
124
+ backgroundColor: string;
125
+ borderColor: string;
126
+ '[data-component="ButtonCounter"]': {
127
+ backgroundColor: string;
128
+ };
129
+ };
130
+ '[data-component="ButtonCounter"]': {
131
+ backgroundColor: string;
132
+ color: string;
133
+ };
134
+ };
135
+ export declare const getSizeStyles: (size: string | undefined, variant: VariantType | undefined, iconOnly: boolean) => {
136
+ paddingY: string;
137
+ paddingX: string;
138
+ fontSize: number;
139
+ '[data-component="ButtonCounter"]': {
140
+ fontSize: number;
141
+ };
142
+ };
143
+ export declare const getBaseStyles: (theme?: Theme | undefined) => {
144
+ borderRadius: string;
145
+ border: string;
146
+ borderColor: any;
147
+ fontWeight: string;
148
+ lineHeight: string;
149
+ whiteSpace: string;
150
+ verticalAlign: string;
151
+ cursor: string;
152
+ appearance: string;
153
+ userSelect: string;
154
+ textDecoration: string;
155
+ textAlign: string;
156
+ '&:focus': {
157
+ outline: string;
158
+ };
159
+ '&:disabled': {
160
+ cursor: string;
161
+ };
162
+ '&:disabled svg': {
163
+ opacity: string;
164
+ };
165
+ };
166
+ export declare const getButtonStyles: (theme?: Theme | undefined) => {
167
+ display: string;
168
+ gridTemplateAreas: string;
169
+ '& > :not(:last-child)': {
170
+ mr: string;
171
+ };
172
+ '[data-component="leadingIcon"]': {
173
+ gridArea: string;
174
+ };
175
+ '[data-component="text"]': {
176
+ gridArea: string;
177
+ };
178
+ '[data-component="trailingIcon"]': {
179
+ gridArea: string;
180
+ };
181
+ borderRadius: string;
182
+ border: string;
183
+ borderColor: any;
184
+ fontWeight: string;
185
+ lineHeight: string;
186
+ whiteSpace: string;
187
+ verticalAlign: string;
188
+ cursor: string;
189
+ appearance: string;
190
+ userSelect: string;
191
+ textDecoration: string;
192
+ textAlign: string;
193
+ '&:focus': {
194
+ outline: string;
195
+ };
196
+ '&:disabled': {
197
+ cursor: string;
198
+ };
199
+ '&:disabled svg': {
200
+ opacity: string;
201
+ };
202
+ };