@primer/components 0.0.0-20211124581 → 0.0.0-202111255030

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 +1 -7
  2. package/dist/browser.esm.js +148 -166
  3. package/dist/browser.esm.js.map +1 -1
  4. package/dist/browser.umd.js +156 -174
  5. package/dist/browser.umd.js.map +1 -1
  6. package/lib/ActionList2/Divider.d.ts +2 -3
  7. package/lib/ActionList2/Divider.js +5 -10
  8. package/lib/ActionList2/Item.js +5 -21
  9. package/lib/ActionList2/List.js +1 -11
  10. package/lib/ActionList2/Selection.js +0 -11
  11. package/lib/ActionList2/index.d.ts +2 -1
  12. package/lib/Autocomplete/Autocomplete.d.ts +2 -10
  13. package/lib/Autocomplete/AutocompleteInput.d.ts +2 -10
  14. package/lib/Checkbox.d.ts +1 -1
  15. package/lib/NewButton/button-base.d.ts +6 -0
  16. package/lib/NewButton/button-base.js +69 -0
  17. package/lib/NewButton/button-link.d.ts +26 -0
  18. package/lib/NewButton/button-link.js +31 -0
  19. package/lib/NewButton/button.d.ts +2 -11
  20. package/lib/NewButton/button.js +6 -283
  21. package/lib/NewButton/icon-button.d.ts +4 -0
  22. package/lib/NewButton/icon-button.js +57 -0
  23. package/lib/NewButton/index.d.ts +6 -11
  24. package/lib/NewButton/index.js +18 -0
  25. package/lib/NewButton/styles.d.ts +202 -0
  26. package/lib/NewButton/styles.js +248 -0
  27. package/lib/NewButton/types.d.ts +28 -8
  28. package/lib/NewButton/types.js +19 -1
  29. package/lib/SelectMenu/SelectMenu.d.ts +2 -10
  30. package/lib/TextInput.d.ts +1 -8
  31. package/lib/TextInput.js +5 -16
  32. package/lib/TextInputWithTokens.d.ts +2 -10
  33. package/lib/_TextInputWrapper.d.ts +0 -3
  34. package/lib/_TextInputWrapper.js +7 -18
  35. package/lib/drafts.d.ts +0 -1
  36. package/lib/drafts.js +0 -13
  37. package/lib-esm/ActionList2/Divider.d.ts +2 -3
  38. package/lib-esm/ActionList2/Divider.js +5 -8
  39. package/lib-esm/ActionList2/Item.js +5 -19
  40. package/lib-esm/ActionList2/List.js +1 -9
  41. package/lib-esm/ActionList2/Selection.js +0 -9
  42. package/lib-esm/ActionList2/index.d.ts +2 -1
  43. package/lib-esm/Autocomplete/Autocomplete.d.ts +2 -10
  44. package/lib-esm/Autocomplete/AutocompleteInput.d.ts +2 -10
  45. package/lib-esm/Checkbox.d.ts +1 -1
  46. package/lib-esm/NewButton/button-base.d.ts +6 -0
  47. package/lib-esm/NewButton/button-base.js +47 -0
  48. package/lib-esm/NewButton/button-link.d.ts +26 -0
  49. package/lib-esm/NewButton/button-link.js +15 -0
  50. package/lib-esm/NewButton/button.d.ts +2 -11
  51. package/lib-esm/NewButton/button.js +4 -275
  52. package/lib-esm/NewButton/icon-button.d.ts +4 -0
  53. package/lib-esm/NewButton/icon-button.js +35 -0
  54. package/lib-esm/NewButton/index.d.ts +6 -11
  55. package/lib-esm/NewButton/index.js +4 -1
  56. package/lib-esm/NewButton/styles.d.ts +202 -0
  57. package/lib-esm/NewButton/styles.js +229 -0
  58. package/lib-esm/NewButton/types.d.ts +28 -8
  59. package/lib-esm/NewButton/types.js +6 -1
  60. package/lib-esm/SelectMenu/SelectMenu.d.ts +2 -10
  61. package/lib-esm/TextInput.d.ts +1 -8
  62. package/lib-esm/TextInput.js +5 -16
  63. package/lib-esm/TextInputWithTokens.d.ts +2 -10
  64. package/lib-esm/_TextInputWrapper.d.ts +0 -3
  65. package/lib-esm/_TextInputWrapper.js +7 -18
  66. package/lib-esm/drafts.d.ts +0 -1
  67. package/lib-esm/drafts.js +1 -2
  68. package/package.json +1 -1
  69. package/lib/ActionList2/MenuContext.d.ts +0 -10
  70. package/lib/ActionList2/MenuContext.js +0 -15
  71. package/lib/ActionMenu2.d.ts +0 -310
  72. package/lib/ActionMenu2.js +0 -91
  73. package/lib-esm/ActionList2/MenuContext.d.ts +0 -10
  74. package/lib-esm/ActionList2/MenuContext.js +0 -3
  75. package/lib-esm/ActionMenu2.d.ts +0 -310
  76. package/lib-esm/ActionMenu2.js +0 -67
@@ -0,0 +1,35 @@
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
+
3
+ import React, { forwardRef } from 'react';
4
+ import { merge } from '../sx';
5
+ import { useTheme } from '../ThemeProvider';
6
+ import Box from '../Box';
7
+ import { StyledButton } from './types';
8
+ import { getBaseStyles, getSizeStyles, getVariantStyles } from './styles';
9
+ const IconButton = /*#__PURE__*/forwardRef((props, forwardedRef) => {
10
+ const {
11
+ variant = 'default',
12
+ size = 'medium',
13
+ sx: sxProp = {},
14
+ icon: Icon,
15
+ iconLabel
16
+ } = props;
17
+ const {
18
+ theme
19
+ } = useTheme();
20
+ const styles = { ...getBaseStyles(theme)
21
+ };
22
+ const sxStyles = merge.all([styles, getSizeStyles(size, variant, true), getVariantStyles(variant, theme), sxProp]);
23
+ return /*#__PURE__*/React.createElement(StyledButton, _extends({
24
+ sx: sxStyles,
25
+ ref: forwardedRef
26
+ }, props), /*#__PURE__*/React.createElement("span", {
27
+ hidden: true
28
+ }, iconLabel), /*#__PURE__*/React.createElement(Box, {
29
+ as: "span",
30
+ sx: {
31
+ display: 'inline-block'
32
+ }
33
+ }, /*#__PURE__*/React.createElement(Icon, null)));
34
+ });
35
+ export default IconButton;
@@ -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 };
@@ -1,5 +1,8 @@
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';
3
5
  export const NewButton = Object.assign(Button, {
4
6
  Counter
5
- });
7
+ });
8
+ export { IconButton, ButtonLink };
@@ -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
+ };
@@ -0,0 +1,229 @@
1
+ export const TEXT_ROW_HEIGHT = '20px'; // custom value off the scale
2
+
3
+ export const getVariantStyles = (variant = 'default', theme) => {
4
+ const style = {
5
+ default: {
6
+ color: 'btn.text',
7
+ backgroundColor: 'btn.bg',
8
+ boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.shadow}, ${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.insetShadow}`,
9
+ '&:hover:not([disabled])': {
10
+ backgroundColor: 'btn.hoverBg'
11
+ },
12
+ // focus must come before :active so that the active box shadow overrides
13
+ '&:focus:not([disabled])': {
14
+ boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.focusShadow}`
15
+ },
16
+ '&:active:not([disabled])': {
17
+ backgroundColor: 'btn.selectedBg',
18
+ boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.shadowActive}`
19
+ },
20
+ '&:disabled': {
21
+ color: 'primer.fg.disabled',
22
+ backgroundColor: 'btn.disabledBg'
23
+ }
24
+ },
25
+ primary: {
26
+ color: 'btn.primary.text',
27
+ backgroundColor: 'btn.primary.bg',
28
+ borderColor: 'border.subtle',
29
+ boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.primary.shadow}`,
30
+ '&:hover:not([disabled])': {
31
+ color: 'btn.primary.hoverText',
32
+ backgroundColor: 'btn.primary.hoverBg'
33
+ },
34
+ // focus must come before :active so that the active box shadow overrides
35
+ '&:focus:not([disabled])': {
36
+ boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.primary.focusShadow}`
37
+ },
38
+ '&:active:not([disabled])': {
39
+ backgroundColor: 'btn.primary.selectedBg',
40
+ boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.primary.selectedShadow}`
41
+ },
42
+ '&:disabled': {
43
+ color: 'btn.primary.disabledText',
44
+ backgroundColor: 'btn.primary.disabledBg'
45
+ },
46
+ '[data-component="ButtonCounter"]': {
47
+ backgroundColor: 'btn.primary.counterBg',
48
+ color: 'btn.primary.text'
49
+ }
50
+ },
51
+ danger: {
52
+ color: 'btn.danger.text',
53
+ backgroundColor: 'btn.bg',
54
+ boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.shadow}`,
55
+ '&:hover:not([disabled])': {
56
+ color: 'btn.danger.hoverText',
57
+ backgroundColor: 'btn.danger.hoverBg',
58
+ borderColor: 'btn.danger.hoverBorder',
59
+ boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.danger.hoverShadow}`,
60
+ '[data-component="ButtonCounter"]': {
61
+ backgroundColor: 'btn.danger.hoverCounterBg',
62
+ color: 'btn.danger.hoverText'
63
+ }
64
+ },
65
+ // focus must come before :active so that the active box shadow overrides
66
+ '&:focus:not([disabled])': {
67
+ borderColor: 'btn.danger.focusBorder',
68
+ boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.danger.focusShadow}`
69
+ },
70
+ '&:active:not([disabled])': {
71
+ color: 'btn.danger.selectedText',
72
+ backgroundColor: 'btn.danger.selectedBg',
73
+ boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.danger.selectedShadow}`,
74
+ borderColor: 'btn.danger.selectedBorder'
75
+ },
76
+ '&:disabled': {
77
+ color: 'btn.danger.disabledText',
78
+ backgroundColor: 'btn.danger.disabledBg',
79
+ borderColor: 'btn.danger.disabledBorder',
80
+ '[data-component="ButtonCounter"]': {
81
+ backgroundColor: 'btn.danger.disabledCounterBg'
82
+ }
83
+ },
84
+ '[data-component="ButtonCounter"]': {
85
+ color: 'btn.danger.text',
86
+ backgroundColor: 'btn.danger.counterBg'
87
+ }
88
+ },
89
+ invisible: {
90
+ color: 'accent.fg',
91
+ backgroundColor: 'transparent',
92
+ border: '0',
93
+ boxShadow: 'none',
94
+ '&:hover:not([disabled])': {
95
+ backgroundColor: 'btn.hoverBg'
96
+ },
97
+ // focus must come before :active so that the active box shadow overrides
98
+ '&:focus:not([disabled])': {
99
+ boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.focusShadow}`
100
+ },
101
+ '&:active:not([disabled])': {
102
+ backgroundColor: 'btn.selectedBg'
103
+ },
104
+ '&:disabled': {
105
+ color: 'primer.fg.disabled'
106
+ }
107
+ },
108
+ outline: {
109
+ color: 'btn.outline.text',
110
+ boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.shadow}`,
111
+ '&:hover': {
112
+ color: 'btn.outline.hoverText',
113
+ backgroundColor: 'btn.outline.hoverBg',
114
+ borderColor: 'outline.hoverBorder',
115
+ boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.outline.hoverShadow}`,
116
+ '[data-component="ButtonCounter"]': {
117
+ backgroundColor: 'btn.outline.hoverCounterBg',
118
+ color: 'btn.outline.hoverText'
119
+ }
120
+ },
121
+ // focus must come before :active so that the active box shadow overrides
122
+ '&:focus': {
123
+ borderColor: 'btn.outline.focusBorder',
124
+ boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.outline.focusShadow}`
125
+ },
126
+ '&:active:not([disabled])': {
127
+ color: 'btn.outline.selectedText',
128
+ backgroundColor: 'btn.outline.selectedBg',
129
+ boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.outline.selectedShadow}`,
130
+ borderColor: 'btn.outline.selectedBorder'
131
+ },
132
+ '&:disabled': {
133
+ color: 'btn.outline.disabledText',
134
+ backgroundColor: 'btn.outline.disabledBg',
135
+ borderColor: 'btn.border',
136
+ '[data-component="ButtonCounter"]': {
137
+ backgroundColor: 'btn.outline.disabledCounterBg'
138
+ }
139
+ },
140
+ '[data-component="ButtonCounter"]': {
141
+ backgroundColor: 'btn.outline.counterBg',
142
+ color: 'btn.outline.text'
143
+ }
144
+ }
145
+ };
146
+ return style[variant];
147
+ };
148
+ export const getSizeStyles = (size = 'medium', variant = 'default', iconOnly) => {
149
+ let paddingY, paddingX, fontSize;
150
+
151
+ switch (size) {
152
+ case 'small':
153
+ paddingY = 3;
154
+ paddingX = 12;
155
+ fontSize = 0;
156
+ break;
157
+
158
+ case 'large':
159
+ paddingY = 9;
160
+ paddingX = 20;
161
+ fontSize = 2;
162
+ break;
163
+
164
+ case 'medium':
165
+ default:
166
+ paddingY = 5;
167
+ paddingX = 16;
168
+ fontSize = 1;
169
+ }
170
+
171
+ if (iconOnly) {
172
+ paddingX = paddingY + 2;
173
+ }
174
+
175
+ if (variant === 'invisible') {
176
+ paddingY = paddingY + 1;
177
+ }
178
+
179
+ return {
180
+ paddingY: `${paddingY}px`,
181
+ paddingX: `${paddingX}px`,
182
+ fontSize,
183
+ '[data-component="ButtonCounter"]': {
184
+ fontSize
185
+ }
186
+ };
187
+ };
188
+ export const getBaseStyles = theme => ({
189
+ borderRadius: '2',
190
+ border: '1px solid',
191
+ borderColor: theme === null || theme === void 0 ? void 0 : theme.colors.btn.border,
192
+ fontWeight: 'bold',
193
+ lineHeight: TEXT_ROW_HEIGHT,
194
+ whiteSpace: 'nowrap',
195
+ verticalAlign: 'middle',
196
+ cursor: 'pointer',
197
+ appearance: 'none',
198
+ userSelect: 'none',
199
+ textDecoration: 'none',
200
+ textAlign: 'center',
201
+ '&:focus': {
202
+ outline: 'none'
203
+ },
204
+ '&:disabled': {
205
+ cursor: 'default'
206
+ },
207
+ '&:disabled svg': {
208
+ opacity: '0.6'
209
+ }
210
+ });
211
+ export const getButtonStyles = theme => {
212
+ const styles = { ...getBaseStyles(theme),
213
+ display: 'grid',
214
+ gridTemplateAreas: '"leadingIcon text trailingIcon"',
215
+ '& > :not(:last-child)': {
216
+ mr: '2'
217
+ },
218
+ '[data-component="leadingIcon"]': {
219
+ gridArea: 'leadingIcon'
220
+ },
221
+ '[data-component="text"]': {
222
+ gridArea: 'text'
223
+ },
224
+ '[data-component="trailingIcon"]': {
225
+ gridArea: 'trailingIcon'
226
+ }
227
+ };
228
+ return styles;
229
+ };
@@ -1,9 +1,11 @@
1
- import React, { HTMLAttributes } from 'react';
1
+ import React, { HTMLAttributes, ComponentPropsWithRef } 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>;
4
5
  export declare type VariantType = 'default' | 'primary' | 'invisible' | 'danger' | 'outline';
5
6
  export declare type Size = 'small' | 'medium' | 'large';
6
- export declare type ButtonProps = {
7
+ declare type StyledButtonProps = ComponentPropsWithRef<typeof StyledButton>;
8
+ export declare type ButtonBaseProps = {
7
9
  /**
8
10
  * Determine's the styles on a button one of 'default' | 'primary' | 'invisible' | 'danger'
9
11
  */
@@ -13,9 +15,11 @@ export declare type ButtonProps = {
13
15
  */
14
16
  size?: Size;
15
17
  /**
16
- * This is to be used if it is an icon-only button. Will make text visually hidden
18
+ * Items that are disabled can not be clicked, selected, or navigated through.
17
19
  */
18
- icon?: React.FunctionComponent<IconProps>;
20
+ disabled?: boolean;
21
+ } & SxProp & HTMLAttributes<HTMLButtonElement> & StyledButtonProps;
22
+ export declare type ButtonProps = {
19
23
  /**
20
24
  * The leading icon comes before button content
21
25
  */
@@ -24,9 +28,25 @@ export declare type ButtonProps = {
24
28
  * The trailing icon comes after button content
25
29
  */
26
30
  trailingIcon?: React.FunctionComponent<IconProps>;
31
+ children: React.ReactNode;
32
+ } & ButtonBaseProps;
33
+ export declare type IconButtonProps = {
27
34
  /**
28
- * Items that are disabled can not be clicked, selected, or navigated through.
35
+ * This is to be used if it is an icon-only button. Will make text visually hidden
29
36
  */
30
- disabled?: boolean;
31
- children: React.ReactNode;
32
- } & SxProp & HTMLAttributes<HTMLButtonElement>;
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 {};
@@ -1 +1,6 @@
1
- export {};
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);
@@ -39,17 +39,11 @@ 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" | "size" | "block" | "icon" | "variant" | "sx" | "className" | "disabled" | "leadingVisual" | "trailingVisual" | "contrast"> & {
42
+ }, string | number | symbol>, "maxWidth" | "minWidth" | "width" | "theme" | "block" | "icon" | "variant" | "sx" | "className" | "disabled" | "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;
53
47
  } & Pick<{
54
48
  color?: string | undefined;
55
49
  maxWidth?: import("styled-system").ResponsiveValue<import("csstype").Property.MaxWidth<import("styled-system").TLengthStyledSystem>, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
@@ -62,7 +56,6 @@ declare const _default: React.ForwardRefExoticComponent<Pick<SelectMenuInternalP
62
56
  slot?: string | undefined;
63
57
  style?: React.CSSProperties | undefined;
64
58
  title?: string | undefined;
65
- size?: "small" | "large" | undefined;
66
59
  block?: boolean | undefined;
67
60
  variant?: "small" | "large" | undefined;
68
61
  role?: React.AriaRole | undefined;
@@ -320,10 +313,9 @@ declare const _default: React.ForwardRefExoticComponent<Pick<SelectMenuInternalP
320
313
  disabled?: boolean | undefined;
321
314
  hasIcon?: boolean | undefined;
322
315
  contrast?: boolean | undefined;
323
- validationStatus?: "error" | "warning" | undefined;
324
316
  } & {
325
317
  theme?: any;
326
- }, "maxWidth" | "minWidth" | "width" | "size" | "block" | "variant" | "sx" | "disabled" | "contrast">, string | number | symbol> & React.RefAttributes<HTMLInputElement>, string | number | symbol> & React.RefAttributes<HTMLInputElement>>;
318
+ }, "maxWidth" | "minWidth" | "width" | "theme" | "block" | "variant" | "sx" | "disabled" | "contrast">, string | number | symbol> & React.RefAttributes<HTMLInputElement>, string | number | symbol> & React.RefAttributes<HTMLInputElement>>;
327
319
  Footer: import("styled-components").StyledComponent<"footer", any, SxProp, never>;
328
320
  Item: React.ForwardRefExoticComponent<Pick<{
329
321
  as?: React.ElementType<any> | undefined;
@@ -4,17 +4,10 @@ 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 */
8
7
  icon?: React.ComponentType<{
9
8
  className?: string;
10
9
  }>;
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'>;
10
+ } & Pick<ComponentProps<typeof TextInputWrapper>, 'block' | 'contrast' | 'disabled' | 'sx' | 'theme' | 'width' | 'maxWidth' | 'minWidth' | 'variant'>;
18
11
  declare type TextInputInternalProps = Merge<React.ComponentPropsWithoutRef<typeof UnstyledTextInput>, NonPassthroughProps>;
19
12
  declare const TextInput: React.ForwardRefExoticComponent<Pick<TextInputInternalProps, string | number | symbol> & React.RefAttributes<HTMLInputElement>>;
20
13
  export declare type TextInputProps = ComponentProps<typeof TextInput>;
@@ -7,21 +7,16 @@ 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,
12
10
  block,
13
11
  className,
14
12
  contrast,
15
13
  disabled,
16
- validationStatus,
17
14
  sx: sxProp,
18
- size: sizeProp,
19
- // start deprecated props
15
+ theme,
20
16
  width: widthProp,
21
17
  minWidth: minWidthProp,
22
18
  maxWidth: maxWidthProp,
23
19
  variant: variantProp,
24
- // end deprecated props
25
20
  ...inputProps
26
21
  }, ref) => {
27
22
  // this class is necessary to style FilterSearch, plz no touchy!
@@ -29,27 +24,21 @@ const TextInput = /*#__PURE__*/React.forwardRef(({
29
24
  return /*#__PURE__*/React.createElement(TextInputWrapper, {
30
25
  block: block,
31
26
  className: wrapperClasses,
32
- validationStatus: validationStatus,
33
27
  contrast: contrast,
34
28
  disabled: disabled,
29
+ hasIcon: !!IconComponent,
35
30
  sx: sxProp,
36
- size: sizeProp,
31
+ theme: theme,
37
32
  width: widthProp,
38
33
  minWidth: minWidthProp,
39
34
  maxWidth: maxWidthProp,
40
35
  variant: variantProp
41
36
  }, IconComponent && /*#__PURE__*/React.createElement(IconComponent, {
42
37
  className: "TextInput-icon"
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({
38
+ }), /*#__PURE__*/React.createElement(UnstyledTextInput, _extends({
46
39
  ref: ref,
47
40
  disabled: disabled
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));
41
+ }, inputProps)));
53
42
  });
54
43
  TextInput.defaultProps = {
55
44
  type: 'text'