@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.
- package/CHANGELOG.md +1 -7
- package/dist/browser.esm.js +148 -166
- package/dist/browser.esm.js.map +1 -1
- package/dist/browser.umd.js +156 -174
- package/dist/browser.umd.js.map +1 -1
- package/lib/ActionList2/Divider.d.ts +2 -3
- package/lib/ActionList2/Divider.js +5 -10
- package/lib/ActionList2/Item.js +5 -21
- package/lib/ActionList2/List.js +1 -11
- package/lib/ActionList2/Selection.js +0 -11
- package/lib/ActionList2/index.d.ts +2 -1
- package/lib/Autocomplete/Autocomplete.d.ts +2 -10
- package/lib/Autocomplete/AutocompleteInput.d.ts +2 -10
- package/lib/Checkbox.d.ts +1 -1
- package/lib/NewButton/button-base.d.ts +6 -0
- package/lib/NewButton/button-base.js +69 -0
- package/lib/NewButton/button-link.d.ts +26 -0
- package/lib/NewButton/button-link.js +31 -0
- package/lib/NewButton/button.d.ts +2 -11
- package/lib/NewButton/button.js +6 -283
- package/lib/NewButton/icon-button.d.ts +4 -0
- package/lib/NewButton/icon-button.js +57 -0
- package/lib/NewButton/index.d.ts +6 -11
- package/lib/NewButton/index.js +18 -0
- package/lib/NewButton/styles.d.ts +202 -0
- package/lib/NewButton/styles.js +248 -0
- package/lib/NewButton/types.d.ts +28 -8
- package/lib/NewButton/types.js +19 -1
- package/lib/SelectMenu/SelectMenu.d.ts +2 -10
- package/lib/TextInput.d.ts +1 -8
- package/lib/TextInput.js +5 -16
- package/lib/TextInputWithTokens.d.ts +2 -10
- package/lib/_TextInputWrapper.d.ts +0 -3
- package/lib/_TextInputWrapper.js +7 -18
- package/lib/drafts.d.ts +0 -1
- package/lib/drafts.js +0 -13
- package/lib-esm/ActionList2/Divider.d.ts +2 -3
- package/lib-esm/ActionList2/Divider.js +5 -8
- package/lib-esm/ActionList2/Item.js +5 -19
- package/lib-esm/ActionList2/List.js +1 -9
- package/lib-esm/ActionList2/Selection.js +0 -9
- package/lib-esm/ActionList2/index.d.ts +2 -1
- package/lib-esm/Autocomplete/Autocomplete.d.ts +2 -10
- package/lib-esm/Autocomplete/AutocompleteInput.d.ts +2 -10
- package/lib-esm/Checkbox.d.ts +1 -1
- package/lib-esm/NewButton/button-base.d.ts +6 -0
- package/lib-esm/NewButton/button-base.js +47 -0
- package/lib-esm/NewButton/button-link.d.ts +26 -0
- package/lib-esm/NewButton/button-link.js +15 -0
- package/lib-esm/NewButton/button.d.ts +2 -11
- package/lib-esm/NewButton/button.js +4 -275
- package/lib-esm/NewButton/icon-button.d.ts +4 -0
- package/lib-esm/NewButton/icon-button.js +35 -0
- package/lib-esm/NewButton/index.d.ts +6 -11
- package/lib-esm/NewButton/index.js +4 -1
- package/lib-esm/NewButton/styles.d.ts +202 -0
- package/lib-esm/NewButton/styles.js +229 -0
- package/lib-esm/NewButton/types.d.ts +28 -8
- package/lib-esm/NewButton/types.js +6 -1
- package/lib-esm/SelectMenu/SelectMenu.d.ts +2 -10
- package/lib-esm/TextInput.d.ts +1 -8
- package/lib-esm/TextInput.js +5 -16
- package/lib-esm/TextInputWithTokens.d.ts +2 -10
- package/lib-esm/_TextInputWrapper.d.ts +0 -3
- package/lib-esm/_TextInputWrapper.js +7 -18
- package/lib-esm/drafts.d.ts +0 -1
- package/lib-esm/drafts.js +1 -2
- package/package.json +1 -1
- package/lib/ActionList2/MenuContext.d.ts +0 -10
- package/lib/ActionList2/MenuContext.js +0 -15
- package/lib/ActionMenu2.d.ts +0 -310
- package/lib/ActionMenu2.js +0 -91
- package/lib-esm/ActionList2/MenuContext.d.ts +0 -10
- package/lib-esm/ActionList2/MenuContext.js +0 -3
- package/lib-esm/ActionMenu2.d.ts +0 -310
- package/lib-esm/ActionMenu2.js +0 -67
@@ -0,0 +1,248 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.getButtonStyles = exports.getBaseStyles = exports.getSizeStyles = exports.getVariantStyles = exports.TEXT_ROW_HEIGHT = void 0;
|
7
|
+
const TEXT_ROW_HEIGHT = '20px'; // custom value off the scale
|
8
|
+
|
9
|
+
exports.TEXT_ROW_HEIGHT = TEXT_ROW_HEIGHT;
|
10
|
+
|
11
|
+
const getVariantStyles = (variant = 'default', theme) => {
|
12
|
+
const style = {
|
13
|
+
default: {
|
14
|
+
color: 'btn.text',
|
15
|
+
backgroundColor: 'btn.bg',
|
16
|
+
boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.shadow}, ${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.insetShadow}`,
|
17
|
+
'&:hover:not([disabled])': {
|
18
|
+
backgroundColor: 'btn.hoverBg'
|
19
|
+
},
|
20
|
+
// focus must come before :active so that the active box shadow overrides
|
21
|
+
'&:focus:not([disabled])': {
|
22
|
+
boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.focusShadow}`
|
23
|
+
},
|
24
|
+
'&:active:not([disabled])': {
|
25
|
+
backgroundColor: 'btn.selectedBg',
|
26
|
+
boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.shadowActive}`
|
27
|
+
},
|
28
|
+
'&:disabled': {
|
29
|
+
color: 'primer.fg.disabled',
|
30
|
+
backgroundColor: 'btn.disabledBg'
|
31
|
+
}
|
32
|
+
},
|
33
|
+
primary: {
|
34
|
+
color: 'btn.primary.text',
|
35
|
+
backgroundColor: 'btn.primary.bg',
|
36
|
+
borderColor: 'border.subtle',
|
37
|
+
boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.primary.shadow}`,
|
38
|
+
'&:hover:not([disabled])': {
|
39
|
+
color: 'btn.primary.hoverText',
|
40
|
+
backgroundColor: 'btn.primary.hoverBg'
|
41
|
+
},
|
42
|
+
// focus must come before :active so that the active box shadow overrides
|
43
|
+
'&:focus:not([disabled])': {
|
44
|
+
boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.primary.focusShadow}`
|
45
|
+
},
|
46
|
+
'&:active:not([disabled])': {
|
47
|
+
backgroundColor: 'btn.primary.selectedBg',
|
48
|
+
boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.primary.selectedShadow}`
|
49
|
+
},
|
50
|
+
'&:disabled': {
|
51
|
+
color: 'btn.primary.disabledText',
|
52
|
+
backgroundColor: 'btn.primary.disabledBg'
|
53
|
+
},
|
54
|
+
'[data-component="ButtonCounter"]': {
|
55
|
+
backgroundColor: 'btn.primary.counterBg',
|
56
|
+
color: 'btn.primary.text'
|
57
|
+
}
|
58
|
+
},
|
59
|
+
danger: {
|
60
|
+
color: 'btn.danger.text',
|
61
|
+
backgroundColor: 'btn.bg',
|
62
|
+
boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.shadow}`,
|
63
|
+
'&:hover:not([disabled])': {
|
64
|
+
color: 'btn.danger.hoverText',
|
65
|
+
backgroundColor: 'btn.danger.hoverBg',
|
66
|
+
borderColor: 'btn.danger.hoverBorder',
|
67
|
+
boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.danger.hoverShadow}`,
|
68
|
+
'[data-component="ButtonCounter"]': {
|
69
|
+
backgroundColor: 'btn.danger.hoverCounterBg',
|
70
|
+
color: 'btn.danger.hoverText'
|
71
|
+
}
|
72
|
+
},
|
73
|
+
// focus must come before :active so that the active box shadow overrides
|
74
|
+
'&:focus:not([disabled])': {
|
75
|
+
borderColor: 'btn.danger.focusBorder',
|
76
|
+
boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.danger.focusShadow}`
|
77
|
+
},
|
78
|
+
'&:active:not([disabled])': {
|
79
|
+
color: 'btn.danger.selectedText',
|
80
|
+
backgroundColor: 'btn.danger.selectedBg',
|
81
|
+
boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.danger.selectedShadow}`,
|
82
|
+
borderColor: 'btn.danger.selectedBorder'
|
83
|
+
},
|
84
|
+
'&:disabled': {
|
85
|
+
color: 'btn.danger.disabledText',
|
86
|
+
backgroundColor: 'btn.danger.disabledBg',
|
87
|
+
borderColor: 'btn.danger.disabledBorder',
|
88
|
+
'[data-component="ButtonCounter"]': {
|
89
|
+
backgroundColor: 'btn.danger.disabledCounterBg'
|
90
|
+
}
|
91
|
+
},
|
92
|
+
'[data-component="ButtonCounter"]': {
|
93
|
+
color: 'btn.danger.text',
|
94
|
+
backgroundColor: 'btn.danger.counterBg'
|
95
|
+
}
|
96
|
+
},
|
97
|
+
invisible: {
|
98
|
+
color: 'accent.fg',
|
99
|
+
backgroundColor: 'transparent',
|
100
|
+
border: '0',
|
101
|
+
boxShadow: 'none',
|
102
|
+
'&:hover:not([disabled])': {
|
103
|
+
backgroundColor: 'btn.hoverBg'
|
104
|
+
},
|
105
|
+
// focus must come before :active so that the active box shadow overrides
|
106
|
+
'&:focus:not([disabled])': {
|
107
|
+
boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.focusShadow}`
|
108
|
+
},
|
109
|
+
'&:active:not([disabled])': {
|
110
|
+
backgroundColor: 'btn.selectedBg'
|
111
|
+
},
|
112
|
+
'&:disabled': {
|
113
|
+
color: 'primer.fg.disabled'
|
114
|
+
}
|
115
|
+
},
|
116
|
+
outline: {
|
117
|
+
color: 'btn.outline.text',
|
118
|
+
boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.shadow}`,
|
119
|
+
'&:hover': {
|
120
|
+
color: 'btn.outline.hoverText',
|
121
|
+
backgroundColor: 'btn.outline.hoverBg',
|
122
|
+
borderColor: 'outline.hoverBorder',
|
123
|
+
boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.outline.hoverShadow}`,
|
124
|
+
'[data-component="ButtonCounter"]': {
|
125
|
+
backgroundColor: 'btn.outline.hoverCounterBg',
|
126
|
+
color: 'btn.outline.hoverText'
|
127
|
+
}
|
128
|
+
},
|
129
|
+
// focus must come before :active so that the active box shadow overrides
|
130
|
+
'&:focus': {
|
131
|
+
borderColor: 'btn.outline.focusBorder',
|
132
|
+
boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.outline.focusShadow}`
|
133
|
+
},
|
134
|
+
'&:active:not([disabled])': {
|
135
|
+
color: 'btn.outline.selectedText',
|
136
|
+
backgroundColor: 'btn.outline.selectedBg',
|
137
|
+
boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.outline.selectedShadow}`,
|
138
|
+
borderColor: 'btn.outline.selectedBorder'
|
139
|
+
},
|
140
|
+
'&:disabled': {
|
141
|
+
color: 'btn.outline.disabledText',
|
142
|
+
backgroundColor: 'btn.outline.disabledBg',
|
143
|
+
borderColor: 'btn.border',
|
144
|
+
'[data-component="ButtonCounter"]': {
|
145
|
+
backgroundColor: 'btn.outline.disabledCounterBg'
|
146
|
+
}
|
147
|
+
},
|
148
|
+
'[data-component="ButtonCounter"]': {
|
149
|
+
backgroundColor: 'btn.outline.counterBg',
|
150
|
+
color: 'btn.outline.text'
|
151
|
+
}
|
152
|
+
}
|
153
|
+
};
|
154
|
+
return style[variant];
|
155
|
+
};
|
156
|
+
|
157
|
+
exports.getVariantStyles = getVariantStyles;
|
158
|
+
|
159
|
+
const getSizeStyles = (size = 'medium', variant = 'default', iconOnly) => {
|
160
|
+
let paddingY, paddingX, fontSize;
|
161
|
+
|
162
|
+
switch (size) {
|
163
|
+
case 'small':
|
164
|
+
paddingY = 3;
|
165
|
+
paddingX = 12;
|
166
|
+
fontSize = 0;
|
167
|
+
break;
|
168
|
+
|
169
|
+
case 'large':
|
170
|
+
paddingY = 9;
|
171
|
+
paddingX = 20;
|
172
|
+
fontSize = 2;
|
173
|
+
break;
|
174
|
+
|
175
|
+
case 'medium':
|
176
|
+
default:
|
177
|
+
paddingY = 5;
|
178
|
+
paddingX = 16;
|
179
|
+
fontSize = 1;
|
180
|
+
}
|
181
|
+
|
182
|
+
if (iconOnly) {
|
183
|
+
paddingX = paddingY + 2;
|
184
|
+
}
|
185
|
+
|
186
|
+
if (variant === 'invisible') {
|
187
|
+
paddingY = paddingY + 1;
|
188
|
+
}
|
189
|
+
|
190
|
+
return {
|
191
|
+
paddingY: `${paddingY}px`,
|
192
|
+
paddingX: `${paddingX}px`,
|
193
|
+
fontSize,
|
194
|
+
'[data-component="ButtonCounter"]': {
|
195
|
+
fontSize
|
196
|
+
}
|
197
|
+
};
|
198
|
+
};
|
199
|
+
|
200
|
+
exports.getSizeStyles = getSizeStyles;
|
201
|
+
|
202
|
+
const getBaseStyles = theme => ({
|
203
|
+
borderRadius: '2',
|
204
|
+
border: '1px solid',
|
205
|
+
borderColor: theme === null || theme === void 0 ? void 0 : theme.colors.btn.border,
|
206
|
+
fontWeight: 'bold',
|
207
|
+
lineHeight: TEXT_ROW_HEIGHT,
|
208
|
+
whiteSpace: 'nowrap',
|
209
|
+
verticalAlign: 'middle',
|
210
|
+
cursor: 'pointer',
|
211
|
+
appearance: 'none',
|
212
|
+
userSelect: 'none',
|
213
|
+
textDecoration: 'none',
|
214
|
+
textAlign: 'center',
|
215
|
+
'&:focus': {
|
216
|
+
outline: 'none'
|
217
|
+
},
|
218
|
+
'&:disabled': {
|
219
|
+
cursor: 'default'
|
220
|
+
},
|
221
|
+
'&:disabled svg': {
|
222
|
+
opacity: '0.6'
|
223
|
+
}
|
224
|
+
});
|
225
|
+
|
226
|
+
exports.getBaseStyles = getBaseStyles;
|
227
|
+
|
228
|
+
const getButtonStyles = theme => {
|
229
|
+
const styles = { ...getBaseStyles(theme),
|
230
|
+
display: 'grid',
|
231
|
+
gridTemplateAreas: '"leadingIcon text trailingIcon"',
|
232
|
+
'& > :not(:last-child)': {
|
233
|
+
mr: '2'
|
234
|
+
},
|
235
|
+
'[data-component="leadingIcon"]': {
|
236
|
+
gridArea: 'leadingIcon'
|
237
|
+
},
|
238
|
+
'[data-component="text"]': {
|
239
|
+
gridArea: 'text'
|
240
|
+
},
|
241
|
+
'[data-component="trailingIcon"]': {
|
242
|
+
gridArea: 'trailingIcon'
|
243
|
+
}
|
244
|
+
};
|
245
|
+
return styles;
|
246
|
+
};
|
247
|
+
|
248
|
+
exports.getButtonStyles = getButtonStyles;
|
package/lib/NewButton/types.d.ts
CHANGED
@@ -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
|
-
|
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
|
-
*
|
18
|
+
* Items that are disabled can not be clicked, selected, or navigated through.
|
17
19
|
*/
|
18
|
-
|
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
|
-
*
|
35
|
+
* This is to be used if it is an icon-only button. Will make text visually hidden
|
29
36
|
*/
|
30
|
-
|
31
|
-
|
32
|
-
} &
|
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 {};
|
package/lib/NewButton/types.js
CHANGED
@@ -1 +1,19 @@
|
|
1
|
-
"use strict";
|
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;
|
@@ -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" | "
|
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" | "
|
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;
|
package/lib/TextInput.d.ts
CHANGED
@@ -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
|
-
|
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>;
|
package/lib/TextInput.js
CHANGED
@@ -20,21 +20,16 @@ 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,
|
25
23
|
block,
|
26
24
|
className,
|
27
25
|
contrast,
|
28
26
|
disabled,
|
29
|
-
validationStatus,
|
30
27
|
sx: sxProp,
|
31
|
-
|
32
|
-
// start deprecated props
|
28
|
+
theme,
|
33
29
|
width: widthProp,
|
34
30
|
minWidth: minWidthProp,
|
35
31
|
maxWidth: maxWidthProp,
|
36
32
|
variant: variantProp,
|
37
|
-
// end deprecated props
|
38
33
|
...inputProps
|
39
34
|
}, ref) => {
|
40
35
|
// this class is necessary to style FilterSearch, plz no touchy!
|
@@ -42,27 +37,21 @@ const TextInput = /*#__PURE__*/_react.default.forwardRef(({
|
|
42
37
|
return /*#__PURE__*/_react.default.createElement(_TextInputWrapper.default, {
|
43
38
|
block: block,
|
44
39
|
className: wrapperClasses,
|
45
|
-
validationStatus: validationStatus,
|
46
40
|
contrast: contrast,
|
47
41
|
disabled: disabled,
|
42
|
+
hasIcon: !!IconComponent,
|
48
43
|
sx: sxProp,
|
49
|
-
|
44
|
+
theme: theme,
|
50
45
|
width: widthProp,
|
51
46
|
minWidth: minWidthProp,
|
52
47
|
maxWidth: maxWidthProp,
|
53
48
|
variant: variantProp
|
54
49
|
}, IconComponent && /*#__PURE__*/_react.default.createElement(IconComponent, {
|
55
50
|
className: "TextInput-icon"
|
56
|
-
}),
|
57
|
-
"data-component": "leadingVisual"
|
58
|
-
}, typeof LeadingVisual === 'function' ? /*#__PURE__*/_react.default.createElement(LeadingVisual, null) : LeadingVisual), /*#__PURE__*/_react.default.createElement(_UnstyledTextInput.default, _extends({
|
51
|
+
}), /*#__PURE__*/_react.default.createElement(_UnstyledTextInput.default, _extends({
|
59
52
|
ref: ref,
|
60
53
|
disabled: disabled
|
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));
|
54
|
+
}, inputProps)));
|
66
55
|
});
|
67
56
|
|
68
57
|
TextInput.defaultProps = {
|
@@ -44,17 +44,11 @@ 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" | "
|
47
|
+
}, string | number | symbol>, "maxWidth" | "minWidth" | "width" | "theme" | "block" | "icon" | "variant" | "sx" | "className" | "disabled" | "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;
|
58
52
|
} & Pick<{
|
59
53
|
color?: string | undefined;
|
60
54
|
maxWidth?: import("styled-system").ResponsiveValue<import("csstype").Property.MaxWidth<import("styled-system").TLengthStyledSystem>, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
@@ -67,7 +61,6 @@ declare const TextInputWithTokens: React.ForwardRefExoticComponent<Pick<{
|
|
67
61
|
slot?: string | undefined;
|
68
62
|
style?: React.CSSProperties | undefined;
|
69
63
|
title?: string | undefined;
|
70
|
-
size?: "small" | "large" | undefined;
|
71
64
|
block?: boolean | undefined;
|
72
65
|
variant?: "small" | "large" | undefined;
|
73
66
|
role?: React.AriaRole | undefined;
|
@@ -325,10 +318,9 @@ declare const TextInputWithTokens: React.ForwardRefExoticComponent<Pick<{
|
|
325
318
|
disabled?: boolean | undefined;
|
326
319
|
hasIcon?: boolean | undefined;
|
327
320
|
contrast?: boolean | undefined;
|
328
|
-
validationStatus?: "error" | "warning" | undefined;
|
329
321
|
} & {
|
330
322
|
theme?: any;
|
331
|
-
}, "maxWidth" | "minWidth" | "width" | "
|
323
|
+
}, "maxWidth" | "minWidth" | "width" | "theme" | "block" | "variant" | "sx" | "disabled" | "contrast">, string | number | symbol> & React.RefAttributes<HTMLInputElement> & {
|
332
324
|
selectedTokenIndex: number | undefined;
|
333
325
|
setSelectedTokenIndex: React.Dispatch<React.SetStateAction<number | undefined>>;
|
334
326
|
}, string | number | symbol> & React.RefAttributes<HTMLInputElement>>;
|
@@ -5,9 +5,6 @@ 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 */
|
10
8
|
variant?: "small" | "large" | undefined;
|
11
|
-
size?: "small" | "large" | undefined;
|
12
9
|
} & 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>;
|
13
10
|
export default TextInputWrapper;
|
package/lib/_TextInputWrapper.js
CHANGED
@@ -19,24 +19,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
19
19
|
|
20
20
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
21
21
|
|
22
|
-
const sizeDeprecatedVariants = (0, _styledSystem.variant)({
|
23
|
-
variants: {
|
24
|
-
small: {
|
25
|
-
minHeight: '28px',
|
26
|
-
px: 2,
|
27
|
-
py: '3px',
|
28
|
-
fontSize: 0,
|
29
|
-
lineHeight: '20px'
|
30
|
-
},
|
31
|
-
large: {
|
32
|
-
px: 2,
|
33
|
-
py: '10px',
|
34
|
-
fontSize: 3
|
35
|
-
}
|
36
|
-
}
|
37
|
-
});
|
38
22
|
const sizeVariants = (0, _styledSystem.variant)({
|
39
|
-
prop: 'size',
|
40
23
|
variants: {
|
41
24
|
small: {
|
42
25
|
minHeight: '28px',
|
@@ -56,7 +39,13 @@ const sizeVariants = (0, _styledSystem.variant)({
|
|
56
39
|
const TextInputWrapper = _styledComponents.default.span.withConfig({
|
57
40
|
displayName: "_TextInputWrapper__TextInputWrapper",
|
58
41
|
componentId: "sc-5vfcis-0"
|
59
|
-
})(["
|
42
|
+
})(["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:", ";}", " ", " ", " ", " ", ";"], (0, _constants.get)('fontSizes.1'), (0, _constants.get)('colors.fg.default'), (0, _constants.get)('colors.border.default'), (0, _constants.get)('radii.2'), (0, _constants.get)('shadows.primer.shadow.inset'), props => {
|
43
|
+
if (props.hasIcon) {
|
44
|
+
return (0, _styledComponents.css)(["padding:0;"]);
|
45
|
+
} else {
|
46
|
+
return (0, _styledComponents.css)(["padding:6px 12px;"]);
|
47
|
+
}
|
48
|
+
}, (0, _constants.get)('colors.fg.muted'), (0, _constants.get)('space.2'), (0, _constants.get)('colors.accent.emphasis'), (0, _constants.get)('shadows.primer.shadow.focus'), props => props.contrast && (0, _styledComponents.css)(["background-color:", ";"], (0, _constants.get)('colors.canvas.inset')), props => props.disabled && (0, _styledComponents.css)(["color:", ";background-color:", ";border-color:", ";"], (0, _constants.get)('colors.primer.fg.disabled'), (0, _constants.get)('colors.input.disabledBg'), (0, _constants.get)('colors.border.default')), props => props.block && (0, _styledComponents.css)(["display:block;width:100%;"]), props => props.block && props.hasIcon && (0, _styledComponents.css)(["display:flex;"]), (0, _constants.get)('breakpoints.1'), (0, _constants.get)('fontSizes.1'), _styledSystem.width, _styledSystem.minWidth, _styledSystem.maxWidth, sizeVariants, _sx.default);
|
60
49
|
|
61
50
|
var _default = TextInputWrapper;
|
62
51
|
exports.default = _default;
|
package/lib/drafts.d.ts
CHANGED
package/lib/drafts.js
CHANGED
@@ -28,17 +28,4 @@ Object.keys(_NewButton).forEach(function (key) {
|
|
28
28
|
return _NewButton[key];
|
29
29
|
}
|
30
30
|
});
|
31
|
-
});
|
32
|
-
|
33
|
-
var _ActionMenu = require("./ActionMenu2");
|
34
|
-
|
35
|
-
Object.keys(_ActionMenu).forEach(function (key) {
|
36
|
-
if (key === "default" || key === "__esModule") return;
|
37
|
-
if (key in exports && exports[key] === _ActionMenu[key]) return;
|
38
|
-
Object.defineProperty(exports, key, {
|
39
|
-
enumerable: true,
|
40
|
-
get: function () {
|
41
|
-
return _ActionMenu[key];
|
42
|
-
}
|
43
|
-
});
|
44
31
|
});
|
@@ -1,6 +1,5 @@
|
|
1
|
-
|
2
|
-
import { SxProp } from '../sx';
|
1
|
+
/// <reference types="react" />
|
3
2
|
/**
|
4
3
|
* Visually separates `Item`s or `Group`s in an `ActionList`.
|
5
4
|
*/
|
6
|
-
export declare
|
5
|
+
export declare function Divider(): JSX.Element;
|
@@ -1,26 +1,23 @@
|
|
1
1
|
import React from 'react';
|
2
2
|
import Box from '../Box';
|
3
3
|
import { get } from '../constants';
|
4
|
-
|
4
|
+
|
5
5
|
/**
|
6
6
|
* Visually separates `Item`s or `Group`s in an `ActionList`.
|
7
7
|
*/
|
8
|
-
|
9
|
-
export const Divider = ({
|
10
|
-
sx = {}
|
11
|
-
}) => {
|
8
|
+
export function Divider() {
|
12
9
|
return /*#__PURE__*/React.createElement(Box, {
|
13
10
|
as: "li",
|
14
11
|
role: "separator",
|
15
|
-
sx:
|
12
|
+
sx: {
|
16
13
|
height: 1,
|
17
14
|
backgroundColor: 'actionListItem.inlineDivider',
|
18
15
|
marginTop: theme => `calc(${get('space.2')(theme)} - 1px)`,
|
19
16
|
marginBottom: 2,
|
20
17
|
listStyle: 'none' // hide the ::marker inserted by browser's stylesheet
|
21
18
|
|
22
|
-
},
|
19
|
+
},
|
23
20
|
"data-component": "ActionList.Divider"
|
24
21
|
});
|
25
|
-
}
|
22
|
+
}
|
26
23
|
Divider.displayName = "Divider";
|