@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
|
@@ -1,287 +1,16 @@
|
|
|
1
1
|
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
2
|
|
|
3
3
|
import React, { forwardRef } from 'react';
|
|
4
|
-
import
|
|
5
|
-
import styled from 'styled-components';
|
|
6
|
-
import sx, { merge } from '../sx';
|
|
7
|
-
import { useTheme } from '../ThemeProvider';
|
|
8
|
-
const TEXT_ROW_HEIGHT = '20px'; // custom value off the scale
|
|
9
|
-
|
|
10
|
-
const getVariantStyles = (variant = 'default', theme) => {
|
|
11
|
-
const style = {
|
|
12
|
-
default: {
|
|
13
|
-
color: 'btn.text',
|
|
14
|
-
backgroundColor: 'btn.bg',
|
|
15
|
-
boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.shadow}, ${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.insetShadow}`,
|
|
16
|
-
'&:hover:not([disabled])': {
|
|
17
|
-
backgroundColor: 'btn.hoverBg'
|
|
18
|
-
},
|
|
19
|
-
// focus must come before :active so that the active box shadow overrides
|
|
20
|
-
'&:focus:not([disabled])': {
|
|
21
|
-
boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.focusShadow}`
|
|
22
|
-
},
|
|
23
|
-
'&:active:not([disabled])': {
|
|
24
|
-
backgroundColor: 'btn.selectedBg',
|
|
25
|
-
boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.shadowActive}`
|
|
26
|
-
},
|
|
27
|
-
'&:disabled': {
|
|
28
|
-
color: 'primer.fg.disabled',
|
|
29
|
-
backgroundColor: 'btn.disabledBg'
|
|
30
|
-
}
|
|
31
|
-
},
|
|
32
|
-
primary: {
|
|
33
|
-
color: 'btn.primary.text',
|
|
34
|
-
backgroundColor: 'btn.primary.bg',
|
|
35
|
-
borderColor: 'border.subtle',
|
|
36
|
-
boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.primary.shadow}`,
|
|
37
|
-
'&:hover:not([disabled])': {
|
|
38
|
-
color: 'btn.primary.hoverText',
|
|
39
|
-
backgroundColor: 'btn.primary.hoverBg'
|
|
40
|
-
},
|
|
41
|
-
// focus must come before :active so that the active box shadow overrides
|
|
42
|
-
'&:focus:not([disabled])': {
|
|
43
|
-
boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.primary.focusShadow}`
|
|
44
|
-
},
|
|
45
|
-
'&:active:not([disabled])': {
|
|
46
|
-
backgroundColor: 'btn.primary.selectedBg',
|
|
47
|
-
boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.primary.selectedShadow}`
|
|
48
|
-
},
|
|
49
|
-
'&:disabled': {
|
|
50
|
-
color: 'btn.primary.disabledText',
|
|
51
|
-
backgroundColor: 'btn.primary.disabledBg'
|
|
52
|
-
},
|
|
53
|
-
'[data-component="ButtonCounter"]': {
|
|
54
|
-
backgroundColor: 'btn.primary.counterBg',
|
|
55
|
-
color: 'btn.primary.text'
|
|
56
|
-
}
|
|
57
|
-
},
|
|
58
|
-
danger: {
|
|
59
|
-
color: 'btn.danger.text',
|
|
60
|
-
backgroundColor: 'btn.bg',
|
|
61
|
-
boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.shadow}`,
|
|
62
|
-
'&:hover:not([disabled])': {
|
|
63
|
-
color: 'btn.danger.hoverText',
|
|
64
|
-
backgroundColor: 'btn.danger.hoverBg',
|
|
65
|
-
borderColor: 'btn.danger.hoverBorder',
|
|
66
|
-
boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.danger.hoverShadow}`,
|
|
67
|
-
'[data-component="ButtonCounter"]': {
|
|
68
|
-
backgroundColor: 'btn.danger.hoverCounterBg',
|
|
69
|
-
color: 'btn.danger.hoverText'
|
|
70
|
-
}
|
|
71
|
-
},
|
|
72
|
-
// focus must come before :active so that the active box shadow overrides
|
|
73
|
-
'&:focus:not([disabled])': {
|
|
74
|
-
borderColor: 'btn.danger.focusBorder',
|
|
75
|
-
boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.danger.focusShadow}`
|
|
76
|
-
},
|
|
77
|
-
'&:active:not([disabled])': {
|
|
78
|
-
color: 'btn.danger.selectedText',
|
|
79
|
-
backgroundColor: 'btn.danger.selectedBg',
|
|
80
|
-
boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.danger.selectedShadow}`,
|
|
81
|
-
borderColor: 'btn.danger.selectedBorder'
|
|
82
|
-
},
|
|
83
|
-
'&:disabled': {
|
|
84
|
-
color: 'btn.danger.disabledText',
|
|
85
|
-
backgroundColor: 'btn.danger.disabledBg',
|
|
86
|
-
borderColor: 'btn.danger.disabledBorder',
|
|
87
|
-
'[data-component="ButtonCounter"]': {
|
|
88
|
-
backgroundColor: 'btn.danger.disabledCounterBg'
|
|
89
|
-
}
|
|
90
|
-
},
|
|
91
|
-
'[data-component="ButtonCounter"]': {
|
|
92
|
-
color: 'btn.danger.text',
|
|
93
|
-
backgroundColor: 'btn.danger.counterBg'
|
|
94
|
-
}
|
|
95
|
-
},
|
|
96
|
-
invisible: {
|
|
97
|
-
color: 'accent.fg',
|
|
98
|
-
backgroundColor: 'transparent',
|
|
99
|
-
border: '0',
|
|
100
|
-
boxShadow: 'none',
|
|
101
|
-
'&:hover:not([disabled])': {
|
|
102
|
-
backgroundColor: 'btn.hoverBg'
|
|
103
|
-
},
|
|
104
|
-
// focus must come before :active so that the active box shadow overrides
|
|
105
|
-
'&:focus:not([disabled])': {
|
|
106
|
-
boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.focusShadow}`
|
|
107
|
-
},
|
|
108
|
-
'&:active:not([disabled])': {
|
|
109
|
-
backgroundColor: 'btn.selectedBg'
|
|
110
|
-
},
|
|
111
|
-
'&:disabled': {
|
|
112
|
-
color: 'primer.fg.disabled'
|
|
113
|
-
}
|
|
114
|
-
},
|
|
115
|
-
outline: {
|
|
116
|
-
color: 'btn.outline.text',
|
|
117
|
-
boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.shadow}`,
|
|
118
|
-
'&:hover': {
|
|
119
|
-
color: 'btn.outline.hoverText',
|
|
120
|
-
backgroundColor: 'btn.outline.hoverBg',
|
|
121
|
-
borderColor: 'outline.hoverBorder',
|
|
122
|
-
boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.outline.hoverShadow}`,
|
|
123
|
-
'[data-component="ButtonCounter"]': {
|
|
124
|
-
backgroundColor: 'btn.outline.hoverCounterBg',
|
|
125
|
-
color: 'btn.outline.hoverText'
|
|
126
|
-
}
|
|
127
|
-
},
|
|
128
|
-
// focus must come before :active so that the active box shadow overrides
|
|
129
|
-
'&:focus': {
|
|
130
|
-
borderColor: 'btn.outline.focusBorder',
|
|
131
|
-
boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.outline.focusShadow}`
|
|
132
|
-
},
|
|
133
|
-
'&:active:not([disabled])': {
|
|
134
|
-
color: 'btn.outline.selectedText',
|
|
135
|
-
backgroundColor: 'btn.outline.selectedBg',
|
|
136
|
-
boxShadow: `${theme === null || theme === void 0 ? void 0 : theme.shadows.btn.outline.selectedShadow}`,
|
|
137
|
-
borderColor: 'btn.outline.selectedBorder'
|
|
138
|
-
},
|
|
139
|
-
'&:disabled': {
|
|
140
|
-
color: 'btn.outline.disabledText',
|
|
141
|
-
backgroundColor: 'btn.outline.disabledBg',
|
|
142
|
-
borderColor: 'btn.border',
|
|
143
|
-
'[data-component="ButtonCounter"]': {
|
|
144
|
-
backgroundColor: 'btn.outline.disabledCounterBg'
|
|
145
|
-
}
|
|
146
|
-
},
|
|
147
|
-
'[data-component="ButtonCounter"]': {
|
|
148
|
-
backgroundColor: 'btn.outline.counterBg',
|
|
149
|
-
color: 'btn.outline.text'
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
};
|
|
153
|
-
return style[variant];
|
|
154
|
-
};
|
|
155
|
-
|
|
156
|
-
const getSizeStyles = (size = 'medium', variant = 'default', iconOnly) => {
|
|
157
|
-
let paddingY, paddingX, fontSize;
|
|
158
|
-
|
|
159
|
-
switch (size) {
|
|
160
|
-
case 'small':
|
|
161
|
-
paddingY = 3;
|
|
162
|
-
paddingX = 12;
|
|
163
|
-
fontSize = 0;
|
|
164
|
-
break;
|
|
165
|
-
|
|
166
|
-
case 'large':
|
|
167
|
-
paddingY = 9;
|
|
168
|
-
paddingX = 20;
|
|
169
|
-
fontSize = 2;
|
|
170
|
-
break;
|
|
171
|
-
|
|
172
|
-
case 'medium':
|
|
173
|
-
default:
|
|
174
|
-
paddingY = 5;
|
|
175
|
-
paddingX = 16;
|
|
176
|
-
fontSize = 1;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
if (iconOnly) {
|
|
180
|
-
paddingX = paddingY + 2;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
if (variant === 'invisible') {
|
|
184
|
-
paddingY = paddingY + 1;
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
return {
|
|
188
|
-
paddingY: `${paddingY}px`,
|
|
189
|
-
paddingX: `${paddingX}px`,
|
|
190
|
-
fontSize,
|
|
191
|
-
'[data-component="ButtonCounter"]': {
|
|
192
|
-
fontSize
|
|
193
|
-
}
|
|
194
|
-
};
|
|
195
|
-
};
|
|
196
|
-
|
|
197
|
-
const ButtonBase = styled.button.withConfig({
|
|
198
|
-
displayName: "button__ButtonBase",
|
|
199
|
-
componentId: "sc-18npz5p-0"
|
|
200
|
-
})(sx);
|
|
4
|
+
import ButtonBase from './button-base';
|
|
201
5
|
const Button = /*#__PURE__*/forwardRef(({
|
|
202
6
|
children,
|
|
203
|
-
sx: sxProp = {},
|
|
204
7
|
...props
|
|
205
8
|
}, forwardedRef) => {
|
|
206
|
-
const {
|
|
207
|
-
icon: Icon,
|
|
208
|
-
leadingIcon: LeadingIcon,
|
|
209
|
-
trailingIcon: TrailingIcon,
|
|
210
|
-
variant = 'default',
|
|
211
|
-
size = 'medium'
|
|
212
|
-
} = props;
|
|
213
|
-
const iconOnly = !!Icon;
|
|
214
|
-
const {
|
|
215
|
-
theme
|
|
216
|
-
} = useTheme();
|
|
217
|
-
const styles = {
|
|
218
|
-
borderRadius: '2',
|
|
219
|
-
border: '1px solid',
|
|
220
|
-
borderColor: theme === null || theme === void 0 ? void 0 : theme.colors.btn.border,
|
|
221
|
-
display: 'grid',
|
|
222
|
-
gridTemplateAreas: '"leadingIcon text trailingIcon"',
|
|
223
|
-
fontWeight: 'bold',
|
|
224
|
-
lineHeight: TEXT_ROW_HEIGHT,
|
|
225
|
-
whiteSpace: 'nowrap',
|
|
226
|
-
verticalAlign: 'middle',
|
|
227
|
-
cursor: 'pointer',
|
|
228
|
-
appearance: 'none',
|
|
229
|
-
userSelect: 'none',
|
|
230
|
-
textDecoration: 'none',
|
|
231
|
-
textAlign: 'center',
|
|
232
|
-
'& > :not(:last-child)': {
|
|
233
|
-
mr: '2'
|
|
234
|
-
},
|
|
235
|
-
'&:focus': {
|
|
236
|
-
outline: 'none'
|
|
237
|
-
},
|
|
238
|
-
'&:disabled': {
|
|
239
|
-
cursor: 'default'
|
|
240
|
-
},
|
|
241
|
-
'&:disabled svg': {
|
|
242
|
-
opacity: '0.6'
|
|
243
|
-
},
|
|
244
|
-
'[data-component="leadingIcon"]': {
|
|
245
|
-
gridArea: 'leadingIcon'
|
|
246
|
-
},
|
|
247
|
-
'[data-component="text"]': {
|
|
248
|
-
gridArea: 'text'
|
|
249
|
-
},
|
|
250
|
-
'[data-component="trailingIcon"]': {
|
|
251
|
-
gridArea: 'trailingIcon'
|
|
252
|
-
}
|
|
253
|
-
};
|
|
254
|
-
const iconWrapStyles = {
|
|
255
|
-
display: 'inline-block'
|
|
256
|
-
};
|
|
257
|
-
const sxStyles = merge.all([styles, getSizeStyles(size, variant, iconOnly), getVariantStyles(variant, theme), sxProp]);
|
|
258
9
|
return /*#__PURE__*/React.createElement(ButtonBase, _extends({
|
|
259
|
-
sx: sxStyles,
|
|
260
10
|
ref: forwardedRef
|
|
261
|
-
}, props
|
|
262
|
-
as: "
|
|
263
|
-
|
|
264
|
-
sx: iconWrapStyles,
|
|
265
|
-
"aria-hidden": !iconOnly
|
|
266
|
-
}, /*#__PURE__*/React.createElement(LeadingIcon, null)), /*#__PURE__*/React.createElement("span", {
|
|
267
|
-
"data-component": "text",
|
|
268
|
-
hidden: Icon ? true : false
|
|
269
|
-
}, children), Icon && /*#__PURE__*/React.createElement(Box, {
|
|
270
|
-
"data-component": "icon-only",
|
|
271
|
-
as: "span",
|
|
272
|
-
sx: {
|
|
273
|
-
display: 'inline-block'
|
|
274
|
-
},
|
|
275
|
-
"aria-hidden": !iconOnly
|
|
276
|
-
}, /*#__PURE__*/React.createElement(Icon, null)), TrailingIcon && /*#__PURE__*/React.createElement(Box, {
|
|
277
|
-
as: "span",
|
|
278
|
-
"data-component": "trailingIcon",
|
|
279
|
-
sx: { ...iconWrapStyles,
|
|
280
|
-
ml: 2
|
|
281
|
-
},
|
|
282
|
-
"aria-hidden": !iconOnly
|
|
283
|
-
}, /*#__PURE__*/React.createElement(TrailingIcon, null)));
|
|
11
|
+
}, props, {
|
|
12
|
+
as: "button"
|
|
13
|
+
}), children);
|
|
284
14
|
});
|
|
285
15
|
Button.displayName = 'Button';
|
|
286
|
-
Object.assign(Button, {});
|
|
287
16
|
export { Button };
|
|
@@ -0,0 +1,39 @@
|
|
|
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
|
+
import { useSSRSafeId } from '@react-aria/ssr';
|
|
10
|
+
const IconButton = /*#__PURE__*/forwardRef((props, forwardedRef) => {
|
|
11
|
+
const {
|
|
12
|
+
variant = 'default',
|
|
13
|
+
size = 'medium',
|
|
14
|
+
sx: sxProp = {},
|
|
15
|
+
icon: Icon,
|
|
16
|
+
iconLabel
|
|
17
|
+
} = props;
|
|
18
|
+
const iconLabelId = useSSRSafeId();
|
|
19
|
+
const {
|
|
20
|
+
theme
|
|
21
|
+
} = useTheme();
|
|
22
|
+
const styles = { ...getBaseStyles(theme)
|
|
23
|
+
};
|
|
24
|
+
const sxStyles = merge.all([styles, getSizeStyles(size, variant, true), getVariantStyles(variant, theme), sxProp]);
|
|
25
|
+
return /*#__PURE__*/React.createElement(StyledButton, _extends({
|
|
26
|
+
"aria-labelledby": iconLabelId,
|
|
27
|
+
sx: sxStyles,
|
|
28
|
+
ref: forwardedRef
|
|
29
|
+
}, props), /*#__PURE__*/React.createElement("span", {
|
|
30
|
+
id: iconLabelId,
|
|
31
|
+
hidden: true
|
|
32
|
+
}, iconLabel), /*#__PURE__*/React.createElement(Box, {
|
|
33
|
+
as: "span",
|
|
34
|
+
sx: {
|
|
35
|
+
display: 'inline-block'
|
|
36
|
+
}
|
|
37
|
+
}, /*#__PURE__*/React.createElement(Icon, null)));
|
|
38
|
+
});
|
|
39
|
+
export default IconButton;
|
|
@@ -1,14 +1,9 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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,204 @@
|
|
|
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:not([disabled])': {
|
|
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:not([disabled])': {
|
|
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
|
+
fontFamily: string;
|
|
148
|
+
fontWeight: string;
|
|
149
|
+
lineHeight: string;
|
|
150
|
+
whiteSpace: string;
|
|
151
|
+
verticalAlign: string;
|
|
152
|
+
cursor: string;
|
|
153
|
+
appearance: string;
|
|
154
|
+
userSelect: string;
|
|
155
|
+
textDecoration: string;
|
|
156
|
+
textAlign: string;
|
|
157
|
+
'&:focus': {
|
|
158
|
+
outline: string;
|
|
159
|
+
};
|
|
160
|
+
'&:disabled': {
|
|
161
|
+
cursor: string;
|
|
162
|
+
};
|
|
163
|
+
'&:disabled svg': {
|
|
164
|
+
opacity: string;
|
|
165
|
+
};
|
|
166
|
+
};
|
|
167
|
+
export declare const getButtonStyles: (theme?: Theme | undefined) => {
|
|
168
|
+
display: string;
|
|
169
|
+
gridTemplateAreas: string;
|
|
170
|
+
'& > :not(:last-child)': {
|
|
171
|
+
mr: string;
|
|
172
|
+
};
|
|
173
|
+
'[data-component="leadingIcon"]': {
|
|
174
|
+
gridArea: string;
|
|
175
|
+
};
|
|
176
|
+
'[data-component="text"]': {
|
|
177
|
+
gridArea: string;
|
|
178
|
+
};
|
|
179
|
+
'[data-component="trailingIcon"]': {
|
|
180
|
+
gridArea: string;
|
|
181
|
+
};
|
|
182
|
+
borderRadius: string;
|
|
183
|
+
border: string;
|
|
184
|
+
borderColor: any;
|
|
185
|
+
fontFamily: string;
|
|
186
|
+
fontWeight: string;
|
|
187
|
+
lineHeight: string;
|
|
188
|
+
whiteSpace: string;
|
|
189
|
+
verticalAlign: string;
|
|
190
|
+
cursor: string;
|
|
191
|
+
appearance: string;
|
|
192
|
+
userSelect: string;
|
|
193
|
+
textDecoration: string;
|
|
194
|
+
textAlign: string;
|
|
195
|
+
'&:focus': {
|
|
196
|
+
outline: string;
|
|
197
|
+
};
|
|
198
|
+
'&:disabled': {
|
|
199
|
+
cursor: string;
|
|
200
|
+
};
|
|
201
|
+
'&:disabled svg': {
|
|
202
|
+
opacity: string;
|
|
203
|
+
};
|
|
204
|
+
};
|