@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
@@ -1,16 +1,287 @@
1
1
  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); }
2
2
 
3
3
  import React, { forwardRef } from 'react';
4
- import ButtonBase from './button-base';
4
+ import Box from '../Box';
5
+ import styled from 'styled-components';
6
+ import sx, { merge } from '../sx';
7
+ import { useTheme } from '../ThemeProvider';
8
+ const TEXT_ROW_HEIGHT = '20px'; // custom value off the scale
9
+
10
+ const getVariantStyles = (variant = 'default', theme) => {
11
+ const style = {
12
+ default: {
13
+ color: 'btn.text',
14
+ backgroundColor: 'btn.bg',
15
+ boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.shadow}, ${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.insetShadow}`,
16
+ '&:hover:not([disabled])': {
17
+ backgroundColor: 'btn.hoverBg'
18
+ },
19
+ // focus must come before :active so that the active box shadow overrides
20
+ '&:focus:not([disabled])': {
21
+ boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.focusShadow}`
22
+ },
23
+ '&:active:not([disabled])': {
24
+ backgroundColor: 'btn.selectedBg',
25
+ boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.shadowActive}`
26
+ },
27
+ '&:disabled': {
28
+ color: 'primer.fg.disabled',
29
+ backgroundColor: 'btn.disabledBg'
30
+ }
31
+ },
32
+ primary: {
33
+ color: 'btn.primary.text',
34
+ backgroundColor: 'btn.primary.bg',
35
+ borderColor: 'border.subtle',
36
+ boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.primary.shadow}`,
37
+ '&:hover:not([disabled])': {
38
+ color: 'btn.primary.hoverText',
39
+ backgroundColor: 'btn.primary.hoverBg'
40
+ },
41
+ // focus must come before :active so that the active box shadow overrides
42
+ '&:focus:not([disabled])': {
43
+ boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.primary.focusShadow}`
44
+ },
45
+ '&:active:not([disabled])': {
46
+ backgroundColor: 'btn.primary.selectedBg',
47
+ boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.primary.selectedShadow}`
48
+ },
49
+ '&:disabled': {
50
+ color: 'btn.primary.disabledText',
51
+ backgroundColor: 'btn.primary.disabledBg'
52
+ },
53
+ '[data-component="ButtonCounter"]': {
54
+ backgroundColor: 'btn.primary.counterBg',
55
+ color: 'btn.primary.text'
56
+ }
57
+ },
58
+ danger: {
59
+ color: 'btn.danger.text',
60
+ backgroundColor: 'btn.bg',
61
+ boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.shadow}`,
62
+ '&:hover:not([disabled])': {
63
+ color: 'btn.danger.hoverText',
64
+ backgroundColor: 'btn.danger.hoverBg',
65
+ borderColor: 'btn.danger.hoverBorder',
66
+ boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.danger.hoverShadow}`,
67
+ '[data-component="ButtonCounter"]': {
68
+ backgroundColor: 'btn.danger.hoverCounterBg',
69
+ color: 'btn.danger.hoverText'
70
+ }
71
+ },
72
+ // focus must come before :active so that the active box shadow overrides
73
+ '&:focus:not([disabled])': {
74
+ borderColor: 'btn.danger.focusBorder',
75
+ boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.danger.focusShadow}`
76
+ },
77
+ '&:active:not([disabled])': {
78
+ color: 'btn.danger.selectedText',
79
+ backgroundColor: 'btn.danger.selectedBg',
80
+ boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.danger.selectedShadow}`,
81
+ borderColor: 'btn.danger.selectedBorder'
82
+ },
83
+ '&:disabled': {
84
+ color: 'btn.danger.disabledText',
85
+ backgroundColor: 'btn.danger.disabledBg',
86
+ borderColor: 'btn.danger.disabledBorder',
87
+ '[data-component="ButtonCounter"]': {
88
+ backgroundColor: 'btn.danger.disabledCounterBg'
89
+ }
90
+ },
91
+ '[data-component="ButtonCounter"]': {
92
+ color: 'btn.danger.text',
93
+ backgroundColor: 'btn.danger.counterBg'
94
+ }
95
+ },
96
+ invisible: {
97
+ color: 'accent.fg',
98
+ backgroundColor: 'transparent',
99
+ border: '0',
100
+ boxShadow: 'none',
101
+ '&:hover:not([disabled])': {
102
+ backgroundColor: 'btn.hoverBg'
103
+ },
104
+ // focus must come before :active so that the active box shadow overrides
105
+ '&:focus:not([disabled])': {
106
+ boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.focusShadow}`
107
+ },
108
+ '&:active:not([disabled])': {
109
+ backgroundColor: 'btn.selectedBg'
110
+ },
111
+ '&:disabled': {
112
+ color: 'primer.fg.disabled'
113
+ }
114
+ },
115
+ outline: {
116
+ color: 'btn.outline.text',
117
+ boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.shadow}`,
118
+ '&:hover': {
119
+ color: 'btn.outline.hoverText',
120
+ backgroundColor: 'btn.outline.hoverBg',
121
+ borderColor: 'outline.hoverBorder',
122
+ boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.outline.hoverShadow}`,
123
+ '[data-component="ButtonCounter"]': {
124
+ backgroundColor: 'btn.outline.hoverCounterBg',
125
+ color: 'btn.outline.hoverText'
126
+ }
127
+ },
128
+ // focus must come before :active so that the active box shadow overrides
129
+ '&:focus': {
130
+ borderColor: 'btn.outline.focusBorder',
131
+ boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.outline.focusShadow}`
132
+ },
133
+ '&:active:not([disabled])': {
134
+ color: 'btn.outline.selectedText',
135
+ backgroundColor: 'btn.outline.selectedBg',
136
+ boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.outline.selectedShadow}`,
137
+ borderColor: 'btn.outline.selectedBorder'
138
+ },
139
+ '&:disabled': {
140
+ color: 'btn.outline.disabledText',
141
+ backgroundColor: 'btn.outline.disabledBg',
142
+ borderColor: 'btn.border',
143
+ '[data-component="ButtonCounter"]': {
144
+ backgroundColor: 'btn.outline.disabledCounterBg'
145
+ }
146
+ },
147
+ '[data-component="ButtonCounter"]': {
148
+ backgroundColor: 'btn.outline.counterBg',
149
+ color: 'btn.outline.text'
150
+ }
151
+ }
152
+ };
153
+ return style[variant];
154
+ };
155
+
156
+ const getSizeStyles = (size = 'medium', variant = 'default', iconOnly) => {
157
+ let paddingY, paddingX, fontSize;
158
+
159
+ switch (size) {
160
+ case 'small':
161
+ paddingY = 3;
162
+ paddingX = 12;
163
+ fontSize = 0;
164
+ break;
165
+
166
+ case 'large':
167
+ paddingY = 9;
168
+ paddingX = 20;
169
+ fontSize = 2;
170
+ break;
171
+
172
+ case 'medium':
173
+ default:
174
+ paddingY = 5;
175
+ paddingX = 16;
176
+ fontSize = 1;
177
+ }
178
+
179
+ if (iconOnly) {
180
+ paddingX = paddingY + 2;
181
+ }
182
+
183
+ if (variant === 'invisible') {
184
+ paddingY = paddingY + 1;
185
+ }
186
+
187
+ return {
188
+ paddingY: `${paddingY}px`,
189
+ paddingX: `${paddingX}px`,
190
+ fontSize,
191
+ '[data-component="ButtonCounter"]': {
192
+ fontSize
193
+ }
194
+ };
195
+ };
196
+
197
+ const ButtonBase = styled.button.withConfig({
198
+ displayName: "button__ButtonBase",
199
+ componentId: "sc-15k5iqk-0"
200
+ })(sx);
5
201
  const Button = /*#__PURE__*/forwardRef(({
6
202
  children,
203
+ sx: sxProp = {},
7
204
  ...props
8
205
  }, forwardedRef) => {
206
+ const {
207
+ icon: Icon,
208
+ leadingIcon: LeadingIcon,
209
+ trailingIcon: TrailingIcon,
210
+ variant = 'default',
211
+ size = 'medium'
212
+ } = props;
213
+ const iconOnly = !!Icon;
214
+ const {
215
+ theme
216
+ } = useTheme();
217
+ const styles = {
218
+ borderRadius: '2',
219
+ border: '1px solid',
220
+ borderColor: theme === null || theme === void 0 ? void 0 : theme.colors.btn.border,
221
+ display: 'grid',
222
+ gridTemplateAreas: '"leadingIcon text trailingIcon"',
223
+ fontWeight: 'bold',
224
+ lineHeight: TEXT_ROW_HEIGHT,
225
+ whiteSpace: 'nowrap',
226
+ verticalAlign: 'middle',
227
+ cursor: 'pointer',
228
+ appearance: 'none',
229
+ userSelect: 'none',
230
+ textDecoration: 'none',
231
+ textAlign: 'center',
232
+ '& > :not(:last-child)': {
233
+ mr: '2'
234
+ },
235
+ '&:focus': {
236
+ outline: 'none'
237
+ },
238
+ '&:disabled': {
239
+ cursor: 'default'
240
+ },
241
+ '&:disabled svg': {
242
+ opacity: '0.6'
243
+ },
244
+ '[data-component="leadingIcon"]': {
245
+ gridArea: 'leadingIcon'
246
+ },
247
+ '[data-component="text"]': {
248
+ gridArea: 'text'
249
+ },
250
+ '[data-component="trailingIcon"]': {
251
+ gridArea: 'trailingIcon'
252
+ }
253
+ };
254
+ const iconWrapStyles = {
255
+ display: 'inline-block'
256
+ };
257
+ const sxStyles = merge.all([styles, getSizeStyles(size, variant, iconOnly), getVariantStyles(variant, theme), sxProp]);
9
258
  return /*#__PURE__*/React.createElement(ButtonBase, _extends({
259
+ sx: sxStyles,
10
260
  ref: forwardedRef
11
- }, props, {
12
- as: "button"
13
- }), children);
261
+ }, props), LeadingIcon && /*#__PURE__*/React.createElement(Box, {
262
+ as: "span",
263
+ "data-component": "leadingIcon",
264
+ sx: iconWrapStyles,
265
+ "aria-hidden": !iconOnly
266
+ }, /*#__PURE__*/React.createElement(LeadingIcon, null)), /*#__PURE__*/React.createElement("span", {
267
+ "data-component": "text",
268
+ hidden: Icon ? true : false
269
+ }, children), Icon && /*#__PURE__*/React.createElement(Box, {
270
+ "data-component": "icon-only",
271
+ as: "span",
272
+ sx: {
273
+ display: 'inline-block'
274
+ },
275
+ "aria-hidden": !iconOnly
276
+ }, /*#__PURE__*/React.createElement(Icon, null)), TrailingIcon && /*#__PURE__*/React.createElement(Box, {
277
+ as: "span",
278
+ "data-component": "trailingIcon",
279
+ sx: { ...iconWrapStyles,
280
+ ml: 2
281
+ },
282
+ "aria-hidden": !iconOnly
283
+ }, /*#__PURE__*/React.createElement(TrailingIcon, null)));
14
284
  });
15
285
  Button.displayName = 'Button';
286
+ Object.assign(Button, {});
16
287
  export { 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 };
@@ -1,8 +1,5 @@
1
1
  import { Button } from './button';
2
2
  import { Counter } from './button-counter';
3
- import IconButton from './icon-button';
4
- import ButtonLink from './button-link';
5
3
  export const NewButton = Object.assign(Button, {
6
4
  Counter
7
- });
8
- export { IconButton, ButtonLink };
5
+ });
@@ -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,6 +1 @@
1
- import styled from 'styled-components';
2
- import sx from '../sx';
3
- export const StyledButton = styled.button.withConfig({
4
- displayName: "types__StyledButton",
5
- componentId: "sc-1sm8kx1-0"
6
- })(sx);
1
+ export {};
@@ -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>;
@@ -7,16 +7,21 @@ import TextInputWrapper from './_TextInputWrapper';
7
7
  // using forwardRef is important so that other components (ex. SelectMenu) can autofocus the input
8
8
  const TextInput = /*#__PURE__*/React.forwardRef(({
9
9
  icon: IconComponent,
10
+ leadingVisual: LeadingVisual,
11
+ trailingVisual: TrailingVisual,
10
12
  block,
11
13
  className,
12
14
  contrast,
13
15
  disabled,
16
+ validationStatus,
14
17
  sx: sxProp,
15
- theme,
18
+ size: sizeProp,
19
+ // start deprecated props
16
20
  width: widthProp,
17
21
  minWidth: minWidthProp,
18
22
  maxWidth: maxWidthProp,
19
23
  variant: variantProp,
24
+ // end deprecated props
20
25
  ...inputProps
21
26
  }, ref) => {
22
27
  // this class is necessary to style FilterSearch, plz no touchy!
@@ -24,21 +29,27 @@ const TextInput = /*#__PURE__*/React.forwardRef(({
24
29
  return /*#__PURE__*/React.createElement(TextInputWrapper, {
25
30
  block: block,
26
31
  className: wrapperClasses,
32
+ validationStatus: validationStatus,
27
33
  contrast: contrast,
28
34
  disabled: disabled,
29
- hasIcon: !!IconComponent,
30
35
  sx: sxProp,
31
- theme: theme,
36
+ size: sizeProp,
32
37
  width: widthProp,
33
38
  minWidth: minWidthProp,
34
39
  maxWidth: maxWidthProp,
35
40
  variant: variantProp
36
41
  }, IconComponent && /*#__PURE__*/React.createElement(IconComponent, {
37
42
  className: "TextInput-icon"
38
- }), /*#__PURE__*/React.createElement(UnstyledTextInput, _extends({
43
+ }), LeadingVisual && /*#__PURE__*/React.createElement("span", {
44
+ "data-component": "leadingVisual"
45
+ }, typeof LeadingVisual === 'function' ? /*#__PURE__*/React.createElement(LeadingVisual, null) : LeadingVisual), /*#__PURE__*/React.createElement(UnstyledTextInput, _extends({
39
46
  ref: ref,
40
47
  disabled: disabled
41
- }, inputProps)));
48
+ }, inputProps, {
49
+ "data-component": "input"
50
+ })), TrailingVisual && /*#__PURE__*/React.createElement("span", {
51
+ "data-component": "leadingVisual"
52
+ }, typeof TrailingVisual === 'function' ? /*#__PURE__*/React.createElement(TrailingVisual, null) : TrailingVisual));
42
53
  });
43
54
  TextInput.defaultProps = {
44
55
  type: 'text'
@@ -44,11 +44,17 @@ declare const TextInputWithTokens: React.ForwardRefExoticComponent<Pick<{
44
44
  } & {
45
45
  as?: string | React.ComponentType<any> | undefined;
46
46
  forwardedAs?: string | React.ComponentType<any> | undefined;
47
- }, string | number | symbol>, "maxWidth" | "minWidth" | "width" | "theme" | "block" | "icon" | "variant" | "sx" | "className" | "disabled" | "contrast"> & {
47
+ }, string | number | symbol>, "maxWidth" | "minWidth" | "width" | "size" | "block" | "icon" | "variant" | "sx" | "className" | "disabled" | "leadingVisual" | "trailingVisual" | "contrast"> & {
48
48
  className?: string | undefined;
49
49
  icon?: React.ComponentType<{
50
50
  className?: string | undefined;
51
51
  }> | undefined;
52
+ leadingVisual?: string | React.ComponentType<{
53
+ className?: string | undefined;
54
+ }> | undefined;
55
+ trailingVisual?: string | React.ComponentType<{
56
+ className?: string | undefined;
57
+ }> | undefined;
52
58
  } & Pick<{
53
59
  color?: string | undefined;
54
60
  maxWidth?: import("styled-system").ResponsiveValue<import("csstype").Property.MaxWidth<import("styled-system").TLengthStyledSystem>, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
@@ -61,6 +67,7 @@ declare const TextInputWithTokens: React.ForwardRefExoticComponent<Pick<{
61
67
  slot?: string | undefined;
62
68
  style?: React.CSSProperties | undefined;
63
69
  title?: string | undefined;
70
+ size?: "small" | "large" | undefined;
64
71
  block?: boolean | undefined;
65
72
  variant?: "small" | "large" | undefined;
66
73
  role?: React.AriaRole | undefined;
@@ -318,9 +325,10 @@ declare const TextInputWithTokens: React.ForwardRefExoticComponent<Pick<{
318
325
  disabled?: boolean | undefined;
319
326
  hasIcon?: boolean | undefined;
320
327
  contrast?: boolean | undefined;
328
+ validationStatus?: "error" | "warning" | undefined;
321
329
  } & {
322
330
  theme?: any;
323
- }, "maxWidth" | "minWidth" | "width" | "theme" | "block" | "variant" | "sx" | "disabled" | "contrast">, string | number | symbol> & React.RefAttributes<HTMLInputElement> & {
331
+ }, "maxWidth" | "minWidth" | "width" | "size" | "block" | "variant" | "sx" | "disabled" | "contrast">, string | number | symbol> & React.RefAttributes<HTMLInputElement> & {
324
332
  selectedTokenIndex: number | undefined;
325
333
  setSelectedTokenIndex: React.Dispatch<React.SetStateAction<number | undefined>>;
326
334
  }, string | number | symbol> & React.RefAttributes<HTMLInputElement>>;
@@ -5,6 +5,9 @@ declare const TextInputWrapper: import("styled-components").StyledComponent<"spa
5
5
  hasIcon?: boolean | undefined;
6
6
  block?: boolean | undefined;
7
7
  contrast?: boolean | undefined;
8
+ validationStatus?: "error" | "warning" | undefined;
9
+ /** @deprecated Use `size` prop instead */
8
10
  variant?: "small" | "large" | undefined;
11
+ size?: "small" | "large" | undefined;
9
12
  } & WidthProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, import("csstype").Property.Width<import("styled-system").TLengthStyledSystem>> & MinWidthProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, import("csstype").Property.MinWidth<import("styled-system").TLengthStyledSystem>> & MaxWidthProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, import("csstype").Property.MaxWidth<import("styled-system").TLengthStyledSystem>> & SxProp, never>;
10
13
  export default TextInputWrapper;
@@ -2,7 +2,24 @@ import styled, { css } from 'styled-components';
2
2
  import { maxWidth, minWidth, variant, width } from 'styled-system';
3
3
  import { get } from './constants';
4
4
  import sx from './sx';
5
+ const sizeDeprecatedVariants = variant({
6
+ variants: {
7
+ small: {
8
+ minHeight: '28px',
9
+ px: 2,
10
+ py: '3px',
11
+ fontSize: 0,
12
+ lineHeight: '20px'
13
+ },
14
+ large: {
15
+ px: 2,
16
+ py: '10px',
17
+ fontSize: 3
18
+ }
19
+ }
20
+ });
5
21
  const sizeVariants = variant({
22
+ prop: 'size',
6
23
  variants: {
7
24
  small: {
8
25
  minHeight: '28px',
@@ -21,11 +38,5 @@ const sizeVariants = variant({
21
38
  const TextInputWrapper = styled.span.withConfig({
22
39
  displayName: "_TextInputWrapper__TextInputWrapper",
23
40
  componentId: "sc-5vfcis-0"
24
- })(["display:inline-flex;align-items:stretch;min-height:34px;font-size:", ";line-height:20px;color:", ";vertical-align:middle;background-repeat:no-repeat;background-position:right 8px center;border:1px solid ", ";border-radius:", ";outline:none;box-shadow:", ";cursor:text;", " .TextInput-icon{align-self:center;color:", ";margin:0 ", ";flex-shrink:0;}&:focus-within{border-color:", ";box-shadow:", ";}", " ", " ", " ", " @media (min-width:", "){font-size:", ";}", " ", " ", " ", " ", ";"], get('fontSizes.1'), get('colors.fg.default'), get('colors.border.default'), get('radii.2'), get('shadows.primer.shadow.inset'), props => {
25
- if (props.hasIcon) {
26
- return css(["padding:0;"]);
27
- } else {
28
- return css(["padding:6px 12px;"]);
29
- }
30
- }, get('colors.fg.muted'), get('space.2'), get('colors.accent.emphasis'), get('shadows.primer.shadow.focus'), props => props.contrast && css(["background-color:", ";"], get('colors.canvas.inset')), props => props.disabled && css(["color:", ";background-color:", ";border-color:", ";"], get('colors.primer.fg.disabled'), get('colors.input.disabledBg'), get('colors.border.default')), props => props.block && css(["display:block;width:100%;"]), props => props.block && props.hasIcon && css(["display:flex;"]), get('breakpoints.1'), get('fontSizes.1'), width, minWidth, maxWidth, sizeVariants, sx);
41
+ })(["width:max-content;min-height:34px;font-size:", ";line-height:20px;color:", ";vertical-align:middle;background-color:", ";background-repeat:no-repeat;background-position:right 8px center;border:1px solid ", ";border-radius:", ";outline:none;box-shadow:", ";cursor:text;padding:6px 12px;display:grid;grid-template-columns:auto 1fr auto;justify-items:end;& >:not(:last-child){margin-right:", ";}[data-component=' leadingVisual ']{align-self:center;color:", ";}[data-component=' trailingVisual ']{align-self:center;color:", ";}.TextInput-icon{align-self:center;color:", ";margin:0 ", ";flex-shrink:0;}&:focus-within{border-color:", ";box-shadow:", ";}", " ", " ", " ", " ", " @media (min-width:", "){font-size:", ";}", " ", " ", " ", " ", " ", ";"], get('fontSizes.1'), get('colors.fg.default'), get('colors.canvas.default'), get('colors.border.default'), get('radii.2'), get('shadows.primer.shadow.inset'), get('space.2'), get('colors.fg.muted'), get('colors.fg.muted'), get('colors.fg.muted'), get('space.2'), get('colors.accent.emphasis'), get('shadows.primer.shadow.focus'), props => props.contrast && css(["background-color:", ";"], get('colors.canvas.inset')), props => props.disabled && css(["color:", ";background-color:", ";border-color:", ";"], get('colors.primer.fg.disabled'), get('colors.input.disabledBg'), get('colors.border.default')), props => props.validationStatus === 'error' && css(["border-color:", ";&:focus-within{border-color:", ";box-shadow:", ";}"], get('colors.danger.emphasis'), get('colors.danger.emphasis'), get('shadows.btn.danger.focusShadow')), props => props.validationStatus === 'warning' && css(["border-color:", ";&:focus-within{border-color:", ";box-shadow:0 0 0 3px ", ";}"], get('colors.attention.emphasis'), get('colors.attention.emphasis'), get('colors.attention.muted')), props => props.block && css(["width:100%;"]), get('breakpoints.1'), get('fontSizes.1'), width, minWidth, maxWidth, sizeDeprecatedVariants, sizeVariants, sx);
31
42
  export default TextInputWrapper;
@@ -6,3 +6,4 @@
6
6
  */
7
7
  export * from './ActionList2';
8
8
  export * from './NewButton';
9
+ export * from './ActionMenu2';
package/lib-esm/drafts.js CHANGED
@@ -6,4 +6,5 @@
6
6
  */
7
7
  // Components
8
8
  export * from './ActionList2';
9
- export * from './NewButton';
9
+ export * from './NewButton';
10
+ export * from './ActionMenu2';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@primer/components",
3
- "version": "0.0.0-202111245715",
3
+ "version": "0.0.0-20211124581",
4
4
  "description": "Primer react components",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib-esm/index.js",
@@ -1,6 +0,0 @@
1
- import { ComponentPropsWithRef } from 'react';
2
- import { ForwardRefComponent as PolymorphicForwardRefComponent } from '@radix-ui/react-polymorphic';
3
- import { ButtonProps } from './types';
4
- declare const ButtonBase: PolymorphicForwardRefComponent<"a" | "button", ButtonProps>;
5
- export declare type ButtonBaseProps = ComponentPropsWithRef<typeof ButtonBase>;
6
- export default ButtonBase;