@primer/react 34.0.0 → 34.0.1
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/dist/browser.esm.js +2 -2
- package/dist/browser.esm.js.map +1 -1
- package/dist/browser.umd.js +2 -2
- package/dist/browser.umd.js.map +1 -1
- package/lib/ActionList/Item.js +3 -3
- package/lib/ActionList/List.js +2 -2
- package/lib/ActionList2/Selection.js +0 -1
- package/lib/ActionMenu2.d.ts +0 -2
- package/lib/ActionMenu2.js +1 -3
- package/lib/AnchoredOverlay/AnchoredOverlay.d.ts +1 -1
- package/lib/Autocomplete/Autocomplete.d.ts +12 -3
- package/lib/Autocomplete/AutocompleteInput.d.ts +12 -3
- package/lib/Autocomplete/AutocompleteMenu.js +10 -5
- package/lib/Dialog/ConfirmationDialog.js +2 -2
- package/lib/Dialog/Dialog.js +2 -2
- package/lib/FilteredActionList/FilteredActionList.js +10 -3
- package/lib/NewButton/button-base.d.ts +6 -0
- package/lib/NewButton/button-base.js +69 -0
- package/lib/NewButton/button-link.d.ts +27 -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 +62 -0
- package/lib/NewButton/index.d.ts +6 -11
- package/lib/NewButton/index.js +18 -0
- package/lib/NewButton/styles.d.ts +204 -0
- package/lib/NewButton/styles.js +249 -0
- package/lib/NewButton/types.d.ts +28 -8
- package/lib/NewButton/types.js +19 -1
- package/lib/Overlay.d.ts +1 -1
- package/lib/SelectMenu/SelectMenu.d.ts +12 -3
- package/lib/TextInput.d.ts +8 -1
- package/lib/TextInput.js +19 -6
- package/lib/TextInputWithTokens.d.ts +12 -3
- package/lib/TextInputWithTokens.js +14 -11
- package/lib/_TextInputWrapper.d.ts +6 -1
- package/lib/_TextInputWrapper.js +21 -8
- package/lib/hooks/useAnchoredPosition.d.ts +1 -1
- package/lib/hooks/useAnchoredPosition.js +2 -2
- package/lib/hooks/useFocusTrap.js +2 -2
- package/lib/hooks/useFocusZone.d.ts +3 -1
- package/lib/hooks/useFocusZone.js +8 -2
- package/lib/hooks/useOpenAndCloseFocus.js +2 -2
- package/lib-esm/ActionList/Item.js +1 -1
- package/lib-esm/ActionList/List.js +1 -1
- package/lib-esm/ActionList2/Selection.js +0 -1
- package/lib-esm/ActionMenu2.d.ts +0 -2
- package/lib-esm/ActionMenu2.js +1 -1
- package/lib-esm/AnchoredOverlay/AnchoredOverlay.d.ts +1 -1
- package/lib-esm/Autocomplete/Autocomplete.d.ts +12 -3
- package/lib-esm/Autocomplete/AutocompleteInput.d.ts +12 -3
- package/lib-esm/Autocomplete/AutocompleteMenu.js +9 -4
- package/lib-esm/Dialog/ConfirmationDialog.js +1 -1
- package/lib-esm/Dialog/Dialog.js +1 -1
- package/lib-esm/FilteredActionList/FilteredActionList.js +9 -3
- 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 +27 -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 +39 -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 +204 -0
- package/lib-esm/NewButton/styles.js +230 -0
- package/lib-esm/NewButton/types.d.ts +28 -8
- package/lib-esm/NewButton/types.js +6 -1
- package/lib-esm/Overlay.d.ts +1 -1
- package/lib-esm/SelectMenu/SelectMenu.d.ts +12 -3
- package/lib-esm/TextInput.d.ts +8 -1
- package/lib-esm/TextInput.js +19 -6
- package/lib-esm/TextInputWithTokens.d.ts +12 -3
- package/lib-esm/TextInputWithTokens.js +12 -9
- package/lib-esm/_TextInputWrapper.d.ts +6 -1
- package/lib-esm/_TextInputWrapper.js +19 -7
- package/lib-esm/hooks/useAnchoredPosition.d.ts +1 -1
- package/lib-esm/hooks/useAnchoredPosition.js +1 -1
- package/lib-esm/hooks/useFocusTrap.js +1 -1
- package/lib-esm/hooks/useFocusZone.d.ts +3 -1
- package/lib-esm/hooks/useFocusZone.js +2 -1
- package/lib-esm/hooks/useOpenAndCloseFocus.js +1 -1
- package/package.json +6 -10
- package/lib/behaviors/anchoredPosition.d.ts +0 -89
- package/lib/behaviors/anchoredPosition.js +0 -316
- package/lib/behaviors/focusTrap.d.ts +0 -12
- package/lib/behaviors/focusTrap.js +0 -179
- package/lib/behaviors/focusZone.d.ts +0 -137
- package/lib/behaviors/focusZone.js +0 -578
- package/lib/behaviors/scrollIntoViewingArea.d.ts +0 -1
- package/lib/behaviors/scrollIntoViewingArea.js +0 -39
- package/lib/utils/iterateFocusableElements.d.ts +0 -42
- package/lib/utils/iterateFocusableElements.js +0 -113
- package/lib/utils/uniqueId.d.ts +0 -1
- package/lib/utils/uniqueId.js +0 -12
- package/lib/utils/userAgent.d.ts +0 -1
- package/lib/utils/userAgent.js +0 -15
- package/lib-esm/behaviors/anchoredPosition.d.ts +0 -89
- package/lib-esm/behaviors/anchoredPosition.js +0 -309
- package/lib-esm/behaviors/focusTrap.d.ts +0 -12
- package/lib-esm/behaviors/focusTrap.js +0 -170
- package/lib-esm/behaviors/focusZone.d.ts +0 -137
- package/lib-esm/behaviors/focusZone.js +0 -560
- package/lib-esm/behaviors/scrollIntoViewingArea.d.ts +0 -1
- package/lib-esm/behaviors/scrollIntoViewingArea.js +0 -30
- package/lib-esm/utils/iterateFocusableElements.d.ts +0 -42
- package/lib-esm/utils/iterateFocusableElements.js +0 -102
- package/lib-esm/utils/uniqueId.d.ts +0 -1
- package/lib-esm/utils/uniqueId.js +0 -5
- package/lib-esm/utils/userAgent.d.ts +0 -1
- package/lib-esm/utils/userAgent.js +0 -8
|
@@ -0,0 +1,249 @@
|
|
|
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:not([disabled])': {
|
|
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:not([disabled])': {
|
|
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
|
+
fontFamily: 'inherit',
|
|
207
|
+
fontWeight: 'bold',
|
|
208
|
+
lineHeight: TEXT_ROW_HEIGHT,
|
|
209
|
+
whiteSpace: 'nowrap',
|
|
210
|
+
verticalAlign: 'middle',
|
|
211
|
+
cursor: 'pointer',
|
|
212
|
+
appearance: 'none',
|
|
213
|
+
userSelect: 'none',
|
|
214
|
+
textDecoration: 'none',
|
|
215
|
+
textAlign: 'center',
|
|
216
|
+
'&:focus': {
|
|
217
|
+
outline: 'none'
|
|
218
|
+
},
|
|
219
|
+
'&:disabled': {
|
|
220
|
+
cursor: 'default'
|
|
221
|
+
},
|
|
222
|
+
'&:disabled svg': {
|
|
223
|
+
opacity: '0.6'
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
exports.getBaseStyles = getBaseStyles;
|
|
228
|
+
|
|
229
|
+
const getButtonStyles = theme => {
|
|
230
|
+
const styles = { ...getBaseStyles(theme),
|
|
231
|
+
display: 'grid',
|
|
232
|
+
gridTemplateAreas: '"leadingIcon text trailingIcon"',
|
|
233
|
+
'& > :not(:last-child)': {
|
|
234
|
+
mr: '2'
|
|
235
|
+
},
|
|
236
|
+
'[data-component="leadingIcon"]': {
|
|
237
|
+
gridArea: 'leadingIcon'
|
|
238
|
+
},
|
|
239
|
+
'[data-component="text"]': {
|
|
240
|
+
gridArea: 'text'
|
|
241
|
+
},
|
|
242
|
+
'[data-component="trailingIcon"]': {
|
|
243
|
+
gridArea: 'trailingIcon'
|
|
244
|
+
}
|
|
245
|
+
};
|
|
246
|
+
return styles;
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
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-15vtwkc-0"
|
|
17
|
+
})(_sx.default);
|
|
18
|
+
|
|
19
|
+
exports.StyledButton = StyledButton;
|
package/lib/Overlay.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import React, { ComponentPropsWithRef } from 'react';
|
|
|
2
2
|
import { AriaRole, Merge } from './utils/types';
|
|
3
3
|
import { TouchOrMouseEvent } from './hooks';
|
|
4
4
|
import { SxProp } from './sx';
|
|
5
|
-
import { AnchorSide } from '
|
|
5
|
+
import type { AnchorSide } from '@primer/behaviors';
|
|
6
6
|
import { ForwardRefComponent as PolymorphicForwardRefComponent } from '@radix-ui/react-polymorphic';
|
|
7
7
|
declare type StyledOverlayProps = {
|
|
8
8
|
width?: keyof typeof widthMap;
|
|
@@ -40,11 +40,17 @@ declare const _default: React.ForwardRefExoticComponent<Pick<SelectMenuInternalP
|
|
|
40
40
|
} & {
|
|
41
41
|
as?: string | React.ComponentType<any> | undefined;
|
|
42
42
|
forwardedAs?: string | React.ComponentType<any> | undefined;
|
|
43
|
-
}, string | number | symbol>, "maxWidth" | "minWidth" | "width" | "
|
|
43
|
+
}, string | number | symbol>, "maxWidth" | "minWidth" | "width" | "size" | "block" | "icon" | "variant" | "sx" | "className" | "disabled" | "leadingVisual" | "trailingVisual" | "contrast"> & {
|
|
44
44
|
className?: string | undefined;
|
|
45
45
|
icon?: React.ComponentType<{
|
|
46
46
|
className?: string | undefined;
|
|
47
47
|
}> | undefined;
|
|
48
|
+
leadingVisual?: string | React.ComponentType<{
|
|
49
|
+
className?: string | undefined;
|
|
50
|
+
}> | undefined;
|
|
51
|
+
trailingVisual?: string | React.ComponentType<{
|
|
52
|
+
className?: string | undefined;
|
|
53
|
+
}> | undefined;
|
|
48
54
|
} & Pick<{
|
|
49
55
|
color?: string | undefined;
|
|
50
56
|
property?: string | undefined;
|
|
@@ -58,6 +64,7 @@ declare const _default: React.ForwardRefExoticComponent<Pick<SelectMenuInternalP
|
|
|
58
64
|
slot?: string | undefined;
|
|
59
65
|
style?: React.CSSProperties | undefined;
|
|
60
66
|
title?: string | undefined;
|
|
67
|
+
size?: "small" | "large" | undefined;
|
|
61
68
|
block?: boolean | undefined;
|
|
62
69
|
variant?: "small" | "large" | undefined;
|
|
63
70
|
role?: React.AriaRole | undefined;
|
|
@@ -312,11 +319,13 @@ declare const _default: React.ForwardRefExoticComponent<Pick<SelectMenuInternalP
|
|
|
312
319
|
onTransitionEndCapture?: React.TransitionEventHandler<HTMLSpanElement> | undefined;
|
|
313
320
|
css?: import("@emotion/core").InterpolationWithTheme<any>;
|
|
314
321
|
disabled?: boolean | undefined;
|
|
315
|
-
|
|
322
|
+
validationStatus?: "error" | "warning" | undefined;
|
|
323
|
+
hasLeadingVisual?: boolean | undefined;
|
|
324
|
+
hasTrailingVisual?: boolean | undefined;
|
|
316
325
|
contrast?: boolean | undefined;
|
|
317
326
|
} & {
|
|
318
327
|
theme?: any;
|
|
319
|
-
}, "maxWidth" | "minWidth" | "width" | "
|
|
328
|
+
}, "maxWidth" | "minWidth" | "width" | "size" | "block" | "variant" | "sx" | "disabled" | "contrast">, string | number | symbol> & React.RefAttributes<HTMLInputElement>, string | number | symbol> & React.RefAttributes<HTMLInputElement>>;
|
|
320
329
|
Footer: import("styled-components").StyledComponent<"footer", any, SxProp, never>;
|
|
321
330
|
Item: React.ForwardRefExoticComponent<Pick<{
|
|
322
331
|
as?: React.ElementType<any> | undefined;
|
package/lib/TextInput.d.ts
CHANGED
|
@@ -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
|
-
|
|
11
|
+
leadingVisual?: string | React.ComponentType<{
|
|
12
|
+
className?: string;
|
|
13
|
+
}>;
|
|
14
|
+
trailingVisual?: string | React.ComponentType<{
|
|
15
|
+
className?: string;
|
|
16
|
+
}>;
|
|
17
|
+
} & Pick<ComponentProps<typeof TextInputWrapper>, 'block' | 'contrast' | 'disabled' | 'sx' | 'width' | 'maxWidth' | 'minWidth' | 'variant' | 'size'>;
|
|
11
18
|
declare type TextInputInternalProps = Merge<React.ComponentPropsWithoutRef<typeof UnstyledTextInput>, NonPassthroughProps>;
|
|
12
19
|
declare const TextInput: React.ForwardRefExoticComponent<Pick<TextInputInternalProps, string | number | symbol> & React.RefAttributes<HTMLInputElement>>;
|
|
13
20
|
export declare type TextInputProps = ComponentProps<typeof TextInput>;
|
package/lib/TextInput.js
CHANGED
|
@@ -20,16 +20,21 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
|
|
|
20
20
|
// using forwardRef is important so that other components (ex. SelectMenu) can autofocus the input
|
|
21
21
|
const TextInput = /*#__PURE__*/_react.default.forwardRef(({
|
|
22
22
|
icon: IconComponent,
|
|
23
|
+
leadingVisual: LeadingVisual,
|
|
24
|
+
trailingVisual: TrailingVisual,
|
|
23
25
|
block,
|
|
24
26
|
className,
|
|
25
27
|
contrast,
|
|
26
28
|
disabled,
|
|
29
|
+
validationStatus,
|
|
27
30
|
sx: sxProp,
|
|
28
|
-
|
|
31
|
+
size: sizeProp,
|
|
32
|
+
// start deprecated props
|
|
29
33
|
width: widthProp,
|
|
30
34
|
minWidth: minWidthProp,
|
|
31
35
|
maxWidth: maxWidthProp,
|
|
32
36
|
variant: variantProp,
|
|
37
|
+
// end deprecated props
|
|
33
38
|
...inputProps
|
|
34
39
|
}, ref) => {
|
|
35
40
|
// this class is necessary to style FilterSearch, plz no touchy!
|
|
@@ -37,21 +42,29 @@ const TextInput = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
37
42
|
return /*#__PURE__*/_react.default.createElement(_TextInputWrapper.default, {
|
|
38
43
|
block: block,
|
|
39
44
|
className: wrapperClasses,
|
|
45
|
+
validationStatus: validationStatus,
|
|
40
46
|
contrast: contrast,
|
|
41
47
|
disabled: disabled,
|
|
42
|
-
hasIcon: !!IconComponent,
|
|
43
48
|
sx: sxProp,
|
|
44
|
-
|
|
49
|
+
size: sizeProp,
|
|
45
50
|
width: widthProp,
|
|
46
51
|
minWidth: minWidthProp,
|
|
47
52
|
maxWidth: maxWidthProp,
|
|
48
|
-
variant: variantProp
|
|
53
|
+
variant: variantProp,
|
|
54
|
+
hasLeadingVisual: Boolean(LeadingVisual),
|
|
55
|
+
hasTrailingVisual: Boolean(TrailingVisual)
|
|
49
56
|
}, IconComponent && /*#__PURE__*/_react.default.createElement(IconComponent, {
|
|
50
57
|
className: "TextInput-icon"
|
|
51
|
-
}), /*#__PURE__*/_react.default.createElement(
|
|
58
|
+
}), LeadingVisual && /*#__PURE__*/_react.default.createElement("span", {
|
|
59
|
+
className: "TextInput-icon"
|
|
60
|
+
}, typeof LeadingVisual === 'function' ? /*#__PURE__*/_react.default.createElement(LeadingVisual, null) : LeadingVisual), /*#__PURE__*/_react.default.createElement(_UnstyledTextInput.default, _extends({
|
|
52
61
|
ref: ref,
|
|
53
62
|
disabled: disabled
|
|
54
|
-
}, inputProps
|
|
63
|
+
}, inputProps, {
|
|
64
|
+
"data-component": "input"
|
|
65
|
+
})), TrailingVisual && /*#__PURE__*/_react.default.createElement("span", {
|
|
66
|
+
className: "TextInput-icon"
|
|
67
|
+
}, typeof TrailingVisual === 'function' ? /*#__PURE__*/_react.default.createElement(TrailingVisual, null) : TrailingVisual));
|
|
55
68
|
});
|
|
56
69
|
|
|
57
70
|
TextInput.defaultProps = {
|
|
@@ -45,11 +45,17 @@ declare const TextInputWithTokens: React.ForwardRefExoticComponent<Pick<{
|
|
|
45
45
|
} & {
|
|
46
46
|
as?: string | React.ComponentType<any> | undefined;
|
|
47
47
|
forwardedAs?: string | React.ComponentType<any> | undefined;
|
|
48
|
-
}, string | number | symbol>, "maxWidth" | "minWidth" | "width" | "
|
|
48
|
+
}, string | number | symbol>, "maxWidth" | "minWidth" | "width" | "size" | "block" | "icon" | "variant" | "sx" | "className" | "disabled" | "leadingVisual" | "trailingVisual" | "contrast"> & {
|
|
49
49
|
className?: string | undefined;
|
|
50
50
|
icon?: React.ComponentType<{
|
|
51
51
|
className?: string | undefined;
|
|
52
52
|
}> | undefined;
|
|
53
|
+
leadingVisual?: string | React.ComponentType<{
|
|
54
|
+
className?: string | undefined;
|
|
55
|
+
}> | undefined;
|
|
56
|
+
trailingVisual?: string | React.ComponentType<{
|
|
57
|
+
className?: string | undefined;
|
|
58
|
+
}> | undefined;
|
|
53
59
|
} & Pick<{
|
|
54
60
|
color?: string | undefined;
|
|
55
61
|
property?: string | undefined;
|
|
@@ -63,6 +69,7 @@ declare const TextInputWithTokens: React.ForwardRefExoticComponent<Pick<{
|
|
|
63
69
|
slot?: string | undefined;
|
|
64
70
|
style?: React.CSSProperties | undefined;
|
|
65
71
|
title?: string | undefined;
|
|
72
|
+
size?: "small" | "large" | undefined;
|
|
66
73
|
block?: boolean | undefined;
|
|
67
74
|
variant?: "small" | "large" | undefined;
|
|
68
75
|
role?: React.AriaRole | undefined;
|
|
@@ -317,11 +324,13 @@ declare const TextInputWithTokens: React.ForwardRefExoticComponent<Pick<{
|
|
|
317
324
|
onTransitionEndCapture?: React.TransitionEventHandler<HTMLSpanElement> | undefined;
|
|
318
325
|
css?: import("@emotion/core").InterpolationWithTheme<any>;
|
|
319
326
|
disabled?: boolean | undefined;
|
|
320
|
-
|
|
327
|
+
validationStatus?: "error" | "warning" | undefined;
|
|
328
|
+
hasLeadingVisual?: boolean | undefined;
|
|
329
|
+
hasTrailingVisual?: boolean | undefined;
|
|
321
330
|
contrast?: boolean | undefined;
|
|
322
331
|
} & {
|
|
323
332
|
theme?: any;
|
|
324
|
-
}, "maxWidth" | "minWidth" | "width" | "
|
|
333
|
+
}, "maxWidth" | "minWidth" | "width" | "size" | "block" | "variant" | "sx" | "disabled" | "contrast">, string | number | symbol> & React.RefAttributes<HTMLInputElement> & {
|
|
325
334
|
selectedTokenIndex: number | undefined;
|
|
326
335
|
setSelectedTokenIndex: React.Dispatch<React.SetStateAction<number | undefined>>;
|
|
327
336
|
}, string | number | symbol> & React.RefAttributes<HTMLInputElement>>;
|
|
@@ -9,7 +9,7 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
9
9
|
|
|
10
10
|
var _props = require("@styled-system/props");
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _behaviors = require("@primer/behaviors");
|
|
13
13
|
|
|
14
14
|
var _useCombinedRefs = require("./hooks/useCombinedRefs");
|
|
15
15
|
|
|
@@ -21,13 +21,13 @@ var _hooks = require("./hooks");
|
|
|
21
21
|
|
|
22
22
|
var _UnstyledTextInput = _interopRequireDefault(require("./_UnstyledTextInput"));
|
|
23
23
|
|
|
24
|
-
var _TextInputWrapper =
|
|
24
|
+
var _TextInputWrapper = _interopRequireWildcard(require("./_TextInputWrapper"));
|
|
25
25
|
|
|
26
26
|
var _Box = _interopRequireDefault(require("./Box"));
|
|
27
27
|
|
|
28
28
|
var _Text = _interopRequireDefault(require("./Text"));
|
|
29
29
|
|
|
30
|
-
var
|
|
30
|
+
var _utils = require("@primer/behaviors/utils");
|
|
31
31
|
|
|
32
32
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
33
33
|
|
|
@@ -81,7 +81,7 @@ function TextInputWithTokensInnerComponent({
|
|
|
81
81
|
containerRef
|
|
82
82
|
} = (0, _useFocusZone.useFocusZone)({
|
|
83
83
|
focusOutBehavior: 'wrap',
|
|
84
|
-
bindKeys:
|
|
84
|
+
bindKeys: _behaviors.FocusKeys.ArrowHorizontal | _behaviors.FocusKeys.HomeAndEnd,
|
|
85
85
|
focusableElementFilter: element => {
|
|
86
86
|
return !element.getAttributeNames().includes('aria-hidden');
|
|
87
87
|
},
|
|
@@ -119,7 +119,7 @@ function TextInputWithTokensInnerComponent({
|
|
|
119
119
|
const nextElementToFocus = (_containerRef$current2 = containerRef.current) === null || _containerRef$current2 === void 0 ? void 0 : _containerRef$current2.children[selectedTokenIndex || 0]; // when removing the first token by keying "Backspace" or "Delete",
|
|
120
120
|
// `nextFocusableElement` is the div that wraps the input
|
|
121
121
|
|
|
122
|
-
const firstFocusable = nextElementToFocus && (0,
|
|
122
|
+
const firstFocusable = nextElementToFocus && (0, _utils.isFocusable)(nextElementToFocus) ? nextElementToFocus : Array.from(((_containerRef$current3 = containerRef.current) === null || _containerRef$current3 === void 0 ? void 0 : _containerRef$current3.children) || []).find(el => (0, _utils.isFocusable)(el));
|
|
123
123
|
|
|
124
124
|
if (firstFocusable) {
|
|
125
125
|
firstFocusable.focus();
|
|
@@ -229,14 +229,17 @@ function TextInputWithTokensInnerComponent({
|
|
|
229
229
|
className: className,
|
|
230
230
|
contrast: contrast,
|
|
231
231
|
disabled: disabled,
|
|
232
|
-
|
|
232
|
+
hasLeadingVisual: Boolean(IconComponent),
|
|
233
233
|
theme: theme,
|
|
234
234
|
width: widthProp,
|
|
235
235
|
minWidth: minWidthProp,
|
|
236
236
|
maxWidth: maxWidthProp,
|
|
237
237
|
variant: variantProp,
|
|
238
238
|
onClick: focusInput,
|
|
239
|
-
sx: {
|
|
239
|
+
sx: {
|
|
240
|
+
paddingLeft: _TextInputWrapper.textInputHorizPadding,
|
|
241
|
+
py: `calc(${_TextInputWrapper.textInputHorizPadding} / 2)`,
|
|
242
|
+
...(block ? {
|
|
240
243
|
display: 'flex',
|
|
241
244
|
width: '100%'
|
|
242
245
|
} : {}),
|
|
@@ -264,14 +267,14 @@ function TextInputWithTokensInnerComponent({
|
|
|
264
267
|
marginBottom: '0.25rem'
|
|
265
268
|
}
|
|
266
269
|
}
|
|
267
|
-
}, /*#__PURE__*/_react.default.createElement(
|
|
270
|
+
}, IconComponent && /*#__PURE__*/_react.default.createElement(IconComponent, {
|
|
271
|
+
className: "TextInput-icon"
|
|
272
|
+
}), /*#__PURE__*/_react.default.createElement(_Box.default, {
|
|
268
273
|
sx: {
|
|
269
274
|
order: 1,
|
|
270
275
|
flexGrow: 1
|
|
271
276
|
}
|
|
272
|
-
},
|
|
273
|
-
className: "TextInput-icon"
|
|
274
|
-
}), /*#__PURE__*/_react.default.createElement(_UnstyledTextInput.default, _extends({
|
|
277
|
+
}, /*#__PURE__*/_react.default.createElement(_UnstyledTextInput.default, _extends({
|
|
275
278
|
ref: combinedInputRef,
|
|
276
279
|
disabled: disabled,
|
|
277
280
|
onFocus: handleInputFocus,
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import { MaxWidthProps, MinWidthProps, WidthProps } from 'styled-system';
|
|
2
2
|
import { SxProp } from './sx';
|
|
3
|
+
export declare const textInputHorizPadding = "12px";
|
|
3
4
|
declare const TextInputWrapper: import("styled-components").StyledComponent<"span", any, {
|
|
4
5
|
disabled?: boolean | undefined;
|
|
5
|
-
|
|
6
|
+
hasLeadingVisual?: boolean | undefined;
|
|
7
|
+
hasTrailingVisual?: boolean | undefined;
|
|
6
8
|
block?: boolean | undefined;
|
|
7
9
|
contrast?: boolean | undefined;
|
|
10
|
+
validationStatus?: "error" | "warning" | undefined;
|
|
11
|
+
/** @deprecated Use `size` prop instead */
|
|
8
12
|
variant?: "small" | "large" | undefined;
|
|
13
|
+
size?: "small" | "large" | undefined;
|
|
9
14
|
} & 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
15
|
export default TextInputWrapper;
|