@primer/components 0.0.0-202111245715 → 0.0.0-20211124581

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 (76) hide show
  1. package/CHANGELOG.md +7 -1
  2. package/dist/browser.esm.js +166 -148
  3. package/dist/browser.esm.js.map +1 -1
  4. package/dist/browser.umd.js +174 -156
  5. package/dist/browser.umd.js.map +1 -1
  6. package/lib/ActionList2/Divider.d.ts +3 -2
  7. package/lib/ActionList2/Divider.js +10 -5
  8. package/lib/ActionList2/Item.js +21 -5
  9. package/lib/ActionList2/List.js +11 -1
  10. package/lib/ActionList2/MenuContext.d.ts +10 -0
  11. package/lib/ActionList2/MenuContext.js +15 -0
  12. package/lib/ActionList2/Selection.js +11 -0
  13. package/lib/ActionList2/index.d.ts +1 -2
  14. package/lib/ActionMenu2.d.ts +310 -0
  15. package/lib/ActionMenu2.js +91 -0
  16. package/lib/Autocomplete/Autocomplete.d.ts +10 -2
  17. package/lib/Autocomplete/AutocompleteInput.d.ts +10 -2
  18. package/lib/Checkbox.d.ts +1 -1
  19. package/lib/NewButton/button.d.ts +11 -2
  20. package/lib/NewButton/button.js +283 -6
  21. package/lib/NewButton/index.d.ts +11 -6
  22. package/lib/NewButton/index.js +0 -18
  23. package/lib/NewButton/types.d.ts +8 -28
  24. package/lib/NewButton/types.js +1 -19
  25. package/lib/SelectMenu/SelectMenu.d.ts +10 -2
  26. package/lib/TextInput.d.ts +8 -1
  27. package/lib/TextInput.js +16 -5
  28. package/lib/TextInputWithTokens.d.ts +10 -2
  29. package/lib/_TextInputWrapper.d.ts +3 -0
  30. package/lib/_TextInputWrapper.js +18 -7
  31. package/lib/drafts.d.ts +1 -0
  32. package/lib/drafts.js +13 -0
  33. package/lib-esm/ActionList2/Divider.d.ts +3 -2
  34. package/lib-esm/ActionList2/Divider.js +8 -5
  35. package/lib-esm/ActionList2/Item.js +19 -5
  36. package/lib-esm/ActionList2/List.js +9 -1
  37. package/lib-esm/ActionList2/MenuContext.d.ts +10 -0
  38. package/lib-esm/ActionList2/MenuContext.js +3 -0
  39. package/lib-esm/ActionList2/Selection.js +9 -0
  40. package/lib-esm/ActionList2/index.d.ts +1 -2
  41. package/lib-esm/ActionMenu2.d.ts +310 -0
  42. package/lib-esm/ActionMenu2.js +67 -0
  43. package/lib-esm/Autocomplete/Autocomplete.d.ts +10 -2
  44. package/lib-esm/Autocomplete/AutocompleteInput.d.ts +10 -2
  45. package/lib-esm/Checkbox.d.ts +1 -1
  46. package/lib-esm/NewButton/button.d.ts +11 -2
  47. package/lib-esm/NewButton/button.js +275 -4
  48. package/lib-esm/NewButton/index.d.ts +11 -6
  49. package/lib-esm/NewButton/index.js +1 -4
  50. package/lib-esm/NewButton/types.d.ts +8 -28
  51. package/lib-esm/NewButton/types.js +1 -6
  52. package/lib-esm/SelectMenu/SelectMenu.d.ts +10 -2
  53. package/lib-esm/TextInput.d.ts +8 -1
  54. package/lib-esm/TextInput.js +16 -5
  55. package/lib-esm/TextInputWithTokens.d.ts +10 -2
  56. package/lib-esm/_TextInputWrapper.d.ts +3 -0
  57. package/lib-esm/_TextInputWrapper.js +18 -7
  58. package/lib-esm/drafts.d.ts +1 -0
  59. package/lib-esm/drafts.js +2 -1
  60. package/package.json +1 -1
  61. package/lib/NewButton/button-base.d.ts +0 -6
  62. package/lib/NewButton/button-base.js +0 -69
  63. package/lib/NewButton/button-link.d.ts +0 -26
  64. package/lib/NewButton/button-link.js +0 -31
  65. package/lib/NewButton/icon-button.d.ts +0 -4
  66. package/lib/NewButton/icon-button.js +0 -57
  67. package/lib/NewButton/styles.d.ts +0 -202
  68. package/lib/NewButton/styles.js +0 -248
  69. package/lib-esm/NewButton/button-base.d.ts +0 -6
  70. package/lib-esm/NewButton/button-base.js +0 -47
  71. package/lib-esm/NewButton/button-link.d.ts +0 -26
  72. package/lib-esm/NewButton/button-link.js +0 -15
  73. package/lib-esm/NewButton/icon-button.d.ts +0 -4
  74. package/lib-esm/NewButton/icon-button.js +0 -35
  75. package/lib-esm/NewButton/styles.d.ts +0 -202
  76. package/lib-esm/NewButton/styles.js +0 -229
@@ -20,11 +20,17 @@ declare const _default: React.FC<{
20
20
  } & {
21
21
  as?: string | React.ComponentType<any> | undefined;
22
22
  forwardedAs?: string | React.ComponentType<any> | undefined;
23
- }, string | number | symbol>, "maxWidth" | "minWidth" | "width" | "theme" | "block" | "icon" | "variant" | "sx" | "className" | "disabled" | "contrast"> & {
23
+ }, string | number | symbol>, "maxWidth" | "minWidth" | "width" | "size" | "block" | "icon" | "variant" | "sx" | "className" | "disabled" | "leadingVisual" | "trailingVisual" | "contrast"> & {
24
24
  className?: string | undefined;
25
25
  icon?: React.ComponentType<{
26
26
  className?: string | undefined;
27
27
  }> | undefined;
28
+ leadingVisual?: string | React.ComponentType<{
29
+ className?: string | undefined;
30
+ }> | undefined;
31
+ trailingVisual?: string | React.ComponentType<{
32
+ className?: string | undefined;
33
+ }> | undefined;
28
34
  } & Pick<{
29
35
  color?: string | undefined;
30
36
  maxWidth?: import("styled-system").ResponsiveValue<import("csstype").Property.MaxWidth<import("styled-system").TLengthStyledSystem>, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
@@ -37,6 +43,7 @@ declare const _default: React.FC<{
37
43
  slot?: string | undefined;
38
44
  style?: React.CSSProperties | undefined;
39
45
  title?: string | undefined;
46
+ size?: "small" | "large" | undefined;
40
47
  block?: boolean | undefined;
41
48
  variant?: "small" | "large" | undefined;
42
49
  role?: React.AriaRole | undefined;
@@ -294,9 +301,10 @@ declare const _default: React.FC<{
294
301
  disabled?: boolean | undefined;
295
302
  hasIcon?: boolean | undefined;
296
303
  contrast?: boolean | undefined;
304
+ validationStatus?: "error" | "warning" | undefined;
297
305
  } & {
298
306
  theme?: any;
299
- }, "maxWidth" | "minWidth" | "width" | "theme" | "block" | "variant" | "sx" | "disabled" | "contrast">, string | number | symbol> & React.RefAttributes<HTMLInputElement>>, {
307
+ }, "maxWidth" | "minWidth" | "width" | "size" | "block" | "variant" | "sx" | "disabled" | "contrast">, string | number | symbol> & React.RefAttributes<HTMLInputElement>>, {
300
308
  as?: React.ComponentType<any> | undefined;
301
309
  }>;
302
310
  Menu: typeof AutocompleteMenu;
@@ -12,11 +12,17 @@ declare const AutocompleteInput: PolymorphicForwardRefComponent<React.ForwardRef
12
12
  } & {
13
13
  as?: string | React.ComponentType<any> | undefined;
14
14
  forwardedAs?: string | React.ComponentType<any> | undefined;
15
- }, string | number | symbol>, "maxWidth" | "minWidth" | "width" | "theme" | "block" | "icon" | "variant" | "sx" | "className" | "disabled" | "contrast"> & {
15
+ }, string | number | symbol>, "maxWidth" | "minWidth" | "width" | "size" | "block" | "icon" | "variant" | "sx" | "className" | "disabled" | "leadingVisual" | "trailingVisual" | "contrast"> & {
16
16
  className?: string | undefined;
17
17
  icon?: React.ComponentType<{
18
18
  className?: string | undefined;
19
19
  }> | undefined;
20
+ leadingVisual?: string | React.ComponentType<{
21
+ className?: string | undefined;
22
+ }> | undefined;
23
+ trailingVisual?: string | React.ComponentType<{
24
+ className?: string | undefined;
25
+ }> | undefined;
20
26
  } & Pick<{
21
27
  color?: string | undefined;
22
28
  maxWidth?: import("styled-system").ResponsiveValue<import("csstype").Property.MaxWidth<import("styled-system").TLengthStyledSystem>, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
@@ -29,6 +35,7 @@ declare const AutocompleteInput: PolymorphicForwardRefComponent<React.ForwardRef
29
35
  slot?: string | undefined;
30
36
  style?: React.CSSProperties | undefined;
31
37
  title?: string | undefined;
38
+ size?: "small" | "large" | undefined;
32
39
  block?: boolean | undefined;
33
40
  variant?: "small" | "large" | undefined;
34
41
  role?: React.AriaRole | undefined;
@@ -286,8 +293,9 @@ declare const AutocompleteInput: PolymorphicForwardRefComponent<React.ForwardRef
286
293
  disabled?: boolean | undefined;
287
294
  hasIcon?: boolean | undefined;
288
295
  contrast?: boolean | undefined;
296
+ validationStatus?: "error" | "warning" | undefined;
289
297
  } & {
290
298
  theme?: any;
291
- }, "maxWidth" | "minWidth" | "width" | "theme" | "block" | "variant" | "sx" | "disabled" | "contrast">, string | number | symbol> & React.RefAttributes<HTMLInputElement>>, InternalAutocompleteInputProps>;
299
+ }, "maxWidth" | "minWidth" | "width" | "size" | "block" | "variant" | "sx" | "disabled" | "contrast">, string | number | symbol> & React.RefAttributes<HTMLInputElement>>, InternalAutocompleteInputProps>;
292
300
  export declare type AutocompleteInputProps = ComponentProps<typeof AutocompleteInput>;
293
301
  export default AutocompleteInput;
package/lib/Checkbox.d.ts CHANGED
@@ -25,5 +25,5 @@ export declare type CheckboxProps = {
25
25
  /**
26
26
  * An accessible, native checkbox component
27
27
  */
28
- declare const Checkbox: React.ForwardRefExoticComponent<Pick<CheckboxProps, "sx" | keyof React.InputHTMLAttributes<HTMLInputElement> | "indeterminate" | "validationStatus"> & React.RefAttributes<HTMLInputElement>>;
28
+ declare const Checkbox: React.ForwardRefExoticComponent<Pick<CheckboxProps, "sx" | keyof React.InputHTMLAttributes<HTMLInputElement> | "validationStatus" | "indeterminate"> & React.RefAttributes<HTMLInputElement>>;
29
29
  export default Checkbox;
@@ -1,4 +1,13 @@
1
1
  import React from 'react';
2
- import { ButtonProps } from './types';
3
- declare const Button: React.ForwardRefExoticComponent<Pick<ButtonProps, string | number | symbol> & React.RefAttributes<HTMLButtonElement>>;
2
+ import { SxProp } from '../sx';
3
+ import { VariantType } from './types';
4
+ declare const Button: React.ForwardRefExoticComponent<{
5
+ variant?: VariantType | undefined;
6
+ size?: import("./types").Size | undefined;
7
+ icon?: React.FunctionComponent<import("@primer/octicons-react/dist/icons").IconProps> | undefined;
8
+ leadingIcon?: React.FunctionComponent<import("@primer/octicons-react/dist/icons").IconProps> | undefined;
9
+ trailingIcon?: React.FunctionComponent<import("@primer/octicons-react/dist/icons").IconProps> | undefined;
10
+ disabled?: boolean | undefined;
11
+ children: React.ReactNode;
12
+ } & SxProp & React.HTMLAttributes<HTMLButtonElement> & React.RefAttributes<HTMLButtonElement>>;
4
13
  export { Button };
@@ -7,7 +7,13 @@ exports.Button = void 0;
7
7
 
8
8
  var _react = _interopRequireWildcard(require("react"));
9
9
 
10
- var _buttonBase = _interopRequireDefault(require("./button-base"));
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");
11
17
 
12
18
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
19
 
@@ -17,15 +23,286 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
17
23
 
18
24
  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); }
19
25
 
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
+
20
220
  const Button = /*#__PURE__*/(0, _react.forwardRef)(({
21
221
  children,
222
+ sx: sxProp = {},
22
223
  ...props
23
224
  }, forwardedRef) => {
24
- return /*#__PURE__*/_react.default.createElement(_buttonBase.default, _extends({
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,
25
281
  ref: forwardedRef
26
- }, props, {
27
- as: "button"
28
- }), children);
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)));
29
305
  });
30
306
  exports.Button = Button;
31
- Button.displayName = 'Button';
307
+ Button.displayName = 'Button';
308
+ Object.assign(Button, {});
@@ -1,9 +1,14 @@
1
1
  /// <reference types="react" />
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>> & {
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>> & {
7
13
  Counter: ({ children, sx: sxProp, ...props }: import("./button-counter").CounterProps) => JSX.Element;
8
14
  };
9
- export { IconButton, ButtonLink };
@@ -3,30 +3,12 @@
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
- });
18
6
  exports.NewButton = void 0;
19
7
 
20
8
  var _button = require("./button");
21
9
 
22
10
  var _buttonCounter = require("./button-counter");
23
11
 
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
-
30
12
  const NewButton = Object.assign(_button.Button, {
31
13
  Counter: _buttonCounter.Counter
32
14
  });
@@ -1,11 +1,9 @@
1
- import React, { HTMLAttributes, ComponentPropsWithRef } from 'react';
1
+ import React, { HTMLAttributes } from 'react';
2
2
  import { IconProps } from '@primer/octicons-react';
3
3
  import { SxProp } from '../sx';
4
- export declare const StyledButton: import("styled-components").StyledComponent<"button", any, SxProp, never>;
5
4
  export declare type VariantType = 'default' | 'primary' | 'invisible' | 'danger' | 'outline';
6
5
  export declare type Size = 'small' | 'medium' | 'large';
7
- declare type StyledButtonProps = ComponentPropsWithRef<typeof StyledButton>;
8
- export declare type ButtonBaseProps = {
6
+ export declare type ButtonProps = {
9
7
  /**
10
8
  * Determine's the styles on a button one of 'default' | 'primary' | 'invisible' | 'danger'
11
9
  */
@@ -15,11 +13,9 @@ export declare type ButtonBaseProps = {
15
13
  */
16
14
  size?: Size;
17
15
  /**
18
- * Items that are disabled can not be clicked, selected, or navigated through.
16
+ * This is to be used if it is an icon-only button. Will make text visually hidden
19
17
  */
20
- disabled?: boolean;
21
- } & SxProp & HTMLAttributes<HTMLButtonElement> & StyledButtonProps;
22
- export declare type ButtonProps = {
18
+ icon?: React.FunctionComponent<IconProps>;
23
19
  /**
24
20
  * The leading icon comes before button content
25
21
  */
@@ -28,25 +24,9 @@ export declare type ButtonProps = {
28
24
  * The trailing icon comes after button content
29
25
  */
30
26
  trailingIcon?: React.FunctionComponent<IconProps>;
31
- children: React.ReactNode;
32
- } & ButtonBaseProps;
33
- export declare type IconButtonProps = {
34
27
  /**
35
- * This is to be used if it is an icon-only button. Will make text visually hidden
28
+ * Items that are disabled can not be clicked, selected, or navigated through.
36
29
  */
37
- icon: React.FunctionComponent<IconProps>;
38
- iconLabel: string;
39
- } & ButtonBaseProps;
40
- export declare type LinkButtonProps = {
41
- underline?: boolean;
42
- download?: string;
43
- href?: string;
44
- hrefLang?: string;
45
- media?: string;
46
- ping?: string;
47
- rel?: string;
48
- target?: string;
49
- type?: string;
50
- referrerPolicy?: React.AnchorHTMLAttributes<HTMLAnchorElement>['referrerPolicy'];
51
- };
52
- export {};
30
+ disabled?: boolean;
31
+ children: React.ReactNode;
32
+ } & SxProp & HTMLAttributes<HTMLButtonElement>;
@@ -1,19 +1 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.StyledButton = void 0;
7
-
8
- var _styledComponents = _interopRequireDefault(require("styled-components"));
9
-
10
- var _sx = _interopRequireDefault(require("../sx"));
11
-
12
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
-
14
- const StyledButton = _styledComponents.default.button.withConfig({
15
- displayName: "types__StyledButton",
16
- componentId: "sc-1sm8kx1-0"
17
- })(_sx.default);
18
-
19
- exports.StyledButton = StyledButton;
1
+ "use strict";
@@ -39,11 +39,17 @@ declare const _default: React.ForwardRefExoticComponent<Pick<SelectMenuInternalP
39
39
  } & {
40
40
  as?: string | React.ComponentType<any> | undefined;
41
41
  forwardedAs?: string | React.ComponentType<any> | undefined;
42
- }, string | number | symbol>, "maxWidth" | "minWidth" | "width" | "theme" | "block" | "icon" | "variant" | "sx" | "className" | "disabled" | "contrast"> & {
42
+ }, string | number | symbol>, "maxWidth" | "minWidth" | "width" | "size" | "block" | "icon" | "variant" | "sx" | "className" | "disabled" | "leadingVisual" | "trailingVisual" | "contrast"> & {
43
43
  className?: string | undefined;
44
44
  icon?: React.ComponentType<{
45
45
  className?: string | undefined;
46
46
  }> | undefined;
47
+ leadingVisual?: string | React.ComponentType<{
48
+ className?: string | undefined;
49
+ }> | undefined;
50
+ trailingVisual?: string | React.ComponentType<{
51
+ className?: string | undefined;
52
+ }> | undefined;
47
53
  } & Pick<{
48
54
  color?: string | undefined;
49
55
  maxWidth?: import("styled-system").ResponsiveValue<import("csstype").Property.MaxWidth<import("styled-system").TLengthStyledSystem>, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
@@ -56,6 +62,7 @@ declare const _default: React.ForwardRefExoticComponent<Pick<SelectMenuInternalP
56
62
  slot?: string | undefined;
57
63
  style?: React.CSSProperties | undefined;
58
64
  title?: string | undefined;
65
+ size?: "small" | "large" | undefined;
59
66
  block?: boolean | undefined;
60
67
  variant?: "small" | "large" | undefined;
61
68
  role?: React.AriaRole | undefined;
@@ -313,9 +320,10 @@ declare const _default: React.ForwardRefExoticComponent<Pick<SelectMenuInternalP
313
320
  disabled?: boolean | undefined;
314
321
  hasIcon?: boolean | undefined;
315
322
  contrast?: boolean | undefined;
323
+ validationStatus?: "error" | "warning" | undefined;
316
324
  } & {
317
325
  theme?: any;
318
- }, "maxWidth" | "minWidth" | "width" | "theme" | "block" | "variant" | "sx" | "disabled" | "contrast">, string | number | symbol> & React.RefAttributes<HTMLInputElement>, string | number | symbol> & React.RefAttributes<HTMLInputElement>>;
326
+ }, "maxWidth" | "minWidth" | "width" | "size" | "block" | "variant" | "sx" | "disabled" | "contrast">, string | number | symbol> & React.RefAttributes<HTMLInputElement>, string | number | symbol> & React.RefAttributes<HTMLInputElement>>;
319
327
  Footer: import("styled-components").StyledComponent<"footer", any, SxProp, never>;
320
328
  Item: React.ForwardRefExoticComponent<Pick<{
321
329
  as?: React.ElementType<any> | undefined;
@@ -4,10 +4,17 @@ import UnstyledTextInput from './_UnstyledTextInput';
4
4
  import TextInputWrapper from './_TextInputWrapper';
5
5
  declare type NonPassthroughProps = {
6
6
  className?: string;
7
+ /** @deprecated Use `leadingVisual` or `trailingVisual` prop instead */
7
8
  icon?: React.ComponentType<{
8
9
  className?: string;
9
10
  }>;
10
- } & Pick<ComponentProps<typeof TextInputWrapper>, 'block' | 'contrast' | 'disabled' | 'sx' | 'theme' | 'width' | 'maxWidth' | 'minWidth' | 'variant'>;
11
+ leadingVisual?: string | React.ComponentType<{
12
+ className?: string;
13
+ }>;
14
+ trailingVisual?: string | React.ComponentType<{
15
+ className?: string;
16
+ }>;
17
+ } & Pick<ComponentProps<typeof TextInputWrapper>, 'block' | 'contrast' | 'disabled' | 'sx' | 'width' | 'maxWidth' | 'minWidth' | 'variant' | 'size'>;
11
18
  declare type TextInputInternalProps = Merge<React.ComponentPropsWithoutRef<typeof UnstyledTextInput>, NonPassthroughProps>;
12
19
  declare const TextInput: React.ForwardRefExoticComponent<Pick<TextInputInternalProps, string | number | symbol> & React.RefAttributes<HTMLInputElement>>;
13
20
  export declare type TextInputProps = ComponentProps<typeof TextInput>;
package/lib/TextInput.js CHANGED
@@ -20,16 +20,21 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
20
20
  // using forwardRef is important so that other components (ex. SelectMenu) can autofocus the input
21
21
  const TextInput = /*#__PURE__*/_react.default.forwardRef(({
22
22
  icon: IconComponent,
23
+ leadingVisual: LeadingVisual,
24
+ trailingVisual: TrailingVisual,
23
25
  block,
24
26
  className,
25
27
  contrast,
26
28
  disabled,
29
+ validationStatus,
27
30
  sx: sxProp,
28
- theme,
31
+ size: sizeProp,
32
+ // start deprecated props
29
33
  width: widthProp,
30
34
  minWidth: minWidthProp,
31
35
  maxWidth: maxWidthProp,
32
36
  variant: variantProp,
37
+ // end deprecated props
33
38
  ...inputProps
34
39
  }, ref) => {
35
40
  // this class is necessary to style FilterSearch, plz no touchy!
@@ -37,21 +42,27 @@ const TextInput = /*#__PURE__*/_react.default.forwardRef(({
37
42
  return /*#__PURE__*/_react.default.createElement(_TextInputWrapper.default, {
38
43
  block: block,
39
44
  className: wrapperClasses,
45
+ validationStatus: validationStatus,
40
46
  contrast: contrast,
41
47
  disabled: disabled,
42
- hasIcon: !!IconComponent,
43
48
  sx: sxProp,
44
- theme: theme,
49
+ size: sizeProp,
45
50
  width: widthProp,
46
51
  minWidth: minWidthProp,
47
52
  maxWidth: maxWidthProp,
48
53
  variant: variantProp
49
54
  }, IconComponent && /*#__PURE__*/_react.default.createElement(IconComponent, {
50
55
  className: "TextInput-icon"
51
- }), /*#__PURE__*/_react.default.createElement(_UnstyledTextInput.default, _extends({
56
+ }), LeadingVisual && /*#__PURE__*/_react.default.createElement("span", {
57
+ "data-component": "leadingVisual"
58
+ }, typeof LeadingVisual === 'function' ? /*#__PURE__*/_react.default.createElement(LeadingVisual, null) : LeadingVisual), /*#__PURE__*/_react.default.createElement(_UnstyledTextInput.default, _extends({
52
59
  ref: ref,
53
60
  disabled: disabled
54
- }, inputProps)));
61
+ }, inputProps, {
62
+ "data-component": "input"
63
+ })), TrailingVisual && /*#__PURE__*/_react.default.createElement("span", {
64
+ "data-component": "leadingVisual"
65
+ }, typeof TrailingVisual === 'function' ? /*#__PURE__*/_react.default.createElement(TrailingVisual, null) : TrailingVisual));
55
66
  });
56
67
 
57
68
  TextInput.defaultProps = {