@cloudflare/component-button 5.0.0 → 5.2.0
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 +13 -0
- package/dist/Button.d.ts +64 -66
- package/dist/ButtonGroup.d.ts +5 -4
- package/dist/TextButton.d.ts +64 -63
- package/dist/UnstyledButton.d.ts +65 -63
- package/es/Button.js +82 -90
- package/es/UnstyledButton.js +23 -9
- package/lib/Button.js +84 -91
- package/lib/UnstyledButton.js +13 -3
- package/package.json +1 -1
package/dist/UnstyledButton.d.ts
CHANGED
|
@@ -1,29 +1,58 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
declare const UnstyledButton: import("react").ComponentType<{
|
|
3
|
+
is?: string | undefined;
|
|
4
|
+
name?: string | undefined;
|
|
5
|
+
disabled?: boolean | undefined;
|
|
6
|
+
color?: (string & (string | [string | undefined, string | undefined] | [string | undefined, string | undefined, string | undefined])) | undefined;
|
|
3
7
|
form?: string | undefined;
|
|
4
8
|
slot?: string | undefined;
|
|
5
9
|
style?: import("react").CSSProperties | undefined;
|
|
6
10
|
title?: string | undefined;
|
|
7
11
|
children?: import("react").ReactNode;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
onDragEnd?: import("react").DragEventHandler<HTMLButtonElement> | undefined;
|
|
12
|
+
value?: string | number | readonly string[] | undefined;
|
|
13
|
+
defaultChecked?: boolean | undefined;
|
|
14
|
+
defaultValue?: string | number | readonly string[] | undefined;
|
|
15
|
+
suppressContentEditableWarning?: boolean | undefined;
|
|
16
|
+
suppressHydrationWarning?: boolean | undefined;
|
|
17
|
+
dangerouslySetInnerHTML?: {
|
|
18
|
+
__html: string;
|
|
19
|
+
} | undefined;
|
|
20
|
+
accessKey?: string | undefined;
|
|
18
21
|
className?: string | undefined;
|
|
19
|
-
|
|
22
|
+
contentEditable?: (boolean | "true" | "false") | "inherit" | undefined;
|
|
23
|
+
contextMenu?: string | undefined;
|
|
24
|
+
dir?: string | undefined;
|
|
25
|
+
draggable?: (boolean | "true" | "false") | undefined;
|
|
26
|
+
id?: string | undefined;
|
|
20
27
|
lang?: string | undefined;
|
|
21
|
-
|
|
22
|
-
|
|
28
|
+
placeholder?: string | undefined;
|
|
29
|
+
spellCheck?: (boolean | "true" | "false") | undefined;
|
|
23
30
|
tabIndex?: number | undefined;
|
|
31
|
+
inputMode?: "search" | "text" | "none" | "tel" | "url" | "email" | "numeric" | "decimal" | undefined;
|
|
32
|
+
radioGroup?: string | undefined;
|
|
33
|
+
role?: string | undefined;
|
|
34
|
+
about?: string | undefined;
|
|
35
|
+
datatype?: string | undefined;
|
|
36
|
+
inlist?: any;
|
|
37
|
+
prefix?: string | undefined;
|
|
38
|
+
property?: string | undefined;
|
|
39
|
+
resource?: string | undefined;
|
|
40
|
+
typeof?: string | undefined;
|
|
41
|
+
vocab?: string | undefined;
|
|
42
|
+
autoCapitalize?: string | undefined;
|
|
43
|
+
autoCorrect?: string | undefined;
|
|
44
|
+
autoSave?: string | undefined;
|
|
45
|
+
itemProp?: string | undefined;
|
|
46
|
+
itemScope?: boolean | undefined;
|
|
47
|
+
itemType?: string | undefined;
|
|
48
|
+
itemID?: string | undefined;
|
|
49
|
+
itemRef?: string | undefined;
|
|
50
|
+
results?: number | undefined;
|
|
51
|
+
security?: string | undefined;
|
|
52
|
+
unselectable?: "on" | "off" | undefined;
|
|
24
53
|
'aria-activedescendant'?: string | undefined;
|
|
25
54
|
'aria-atomic'?: boolean | "true" | "false" | undefined;
|
|
26
|
-
'aria-autocomplete'?: "
|
|
55
|
+
'aria-autocomplete'?: "inline" | "none" | "list" | "both" | undefined;
|
|
27
56
|
'aria-busy'?: boolean | "true" | "false" | undefined;
|
|
28
57
|
'aria-checked'?: boolean | "true" | "false" | "mixed" | undefined;
|
|
29
58
|
'aria-colcount'?: number | undefined;
|
|
@@ -39,7 +68,7 @@ declare const UnstyledButton: import("react").ComponentType<{
|
|
|
39
68
|
'aria-expanded'?: boolean | "true" | "false" | undefined;
|
|
40
69
|
'aria-flowto'?: string | undefined;
|
|
41
70
|
'aria-grabbed'?: boolean | "true" | "false" | undefined;
|
|
42
|
-
'aria-haspopup'?: boolean | "
|
|
71
|
+
'aria-haspopup'?: boolean | "menu" | "dialog" | "true" | "false" | "grid" | "listbox" | "tree" | undefined;
|
|
43
72
|
'aria-hidden'?: boolean | "true" | "false" | undefined;
|
|
44
73
|
'aria-invalid'?: boolean | "true" | "false" | "grammar" | "spelling" | undefined;
|
|
45
74
|
'aria-keyshortcuts'?: string | undefined;
|
|
@@ -69,9 +98,16 @@ declare const UnstyledButton: import("react").ComponentType<{
|
|
|
69
98
|
'aria-valuemin'?: number | undefined;
|
|
70
99
|
'aria-valuenow'?: number | undefined;
|
|
71
100
|
'aria-valuetext'?: string | undefined;
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
101
|
+
type?: "button" | "reset" | "submit" | undefined;
|
|
102
|
+
autoFocus?: boolean | undefined;
|
|
103
|
+
formAction?: string | undefined;
|
|
104
|
+
formEncType?: string | undefined;
|
|
105
|
+
formMethod?: string | undefined;
|
|
106
|
+
formNoValidate?: boolean | undefined;
|
|
107
|
+
formTarget?: string | undefined;
|
|
108
|
+
key?: import("react").Key | null | undefined;
|
|
109
|
+
hidden?: boolean | undefined;
|
|
110
|
+
translate?: "yes" | "no" | undefined;
|
|
75
111
|
onCopy?: import("react").ClipboardEventHandler<HTMLButtonElement> | undefined;
|
|
76
112
|
onCopyCapture?: import("react").ClipboardEventHandler<HTMLButtonElement> | undefined;
|
|
77
113
|
onCut?: import("react").ClipboardEventHandler<HTMLButtonElement> | undefined;
|
|
@@ -156,12 +192,15 @@ declare const UnstyledButton: import("react").ComponentType<{
|
|
|
156
192
|
onWaitingCapture?: import("react").ReactEventHandler<HTMLButtonElement> | undefined;
|
|
157
193
|
onAuxClick?: import("react").MouseEventHandler<HTMLButtonElement> | undefined;
|
|
158
194
|
onAuxClickCapture?: import("react").MouseEventHandler<HTMLButtonElement> | undefined;
|
|
195
|
+
onClick?: import("react").MouseEventHandler<HTMLButtonElement> | undefined;
|
|
159
196
|
onClickCapture?: import("react").MouseEventHandler<HTMLButtonElement> | undefined;
|
|
160
197
|
onContextMenu?: import("react").MouseEventHandler<HTMLButtonElement> | undefined;
|
|
161
198
|
onContextMenuCapture?: import("react").MouseEventHandler<HTMLButtonElement> | undefined;
|
|
162
199
|
onDoubleClick?: import("react").MouseEventHandler<HTMLButtonElement> | undefined;
|
|
163
200
|
onDoubleClickCapture?: import("react").MouseEventHandler<HTMLButtonElement> | undefined;
|
|
201
|
+
onDrag?: import("react").DragEventHandler<HTMLButtonElement> | undefined;
|
|
164
202
|
onDragCapture?: import("react").DragEventHandler<HTMLButtonElement> | undefined;
|
|
203
|
+
onDragEnd?: import("react").DragEventHandler<HTMLButtonElement> | undefined;
|
|
165
204
|
onDragEndCapture?: import("react").DragEventHandler<HTMLButtonElement> | undefined;
|
|
166
205
|
onDragEnter?: import("react").DragEventHandler<HTMLButtonElement> | undefined;
|
|
167
206
|
onDragEnterCapture?: import("react").DragEventHandler<HTMLButtonElement> | undefined;
|
|
@@ -171,11 +210,14 @@ declare const UnstyledButton: import("react").ComponentType<{
|
|
|
171
210
|
onDragLeaveCapture?: import("react").DragEventHandler<HTMLButtonElement> | undefined;
|
|
172
211
|
onDragOver?: import("react").DragEventHandler<HTMLButtonElement> | undefined;
|
|
173
212
|
onDragOverCapture?: import("react").DragEventHandler<HTMLButtonElement> | undefined;
|
|
213
|
+
onDragStart?: import("react").DragEventHandler<HTMLButtonElement> | undefined;
|
|
174
214
|
onDragStartCapture?: import("react").DragEventHandler<HTMLButtonElement> | undefined;
|
|
175
215
|
onDrop?: import("react").DragEventHandler<HTMLButtonElement> | undefined;
|
|
176
216
|
onDropCapture?: import("react").DragEventHandler<HTMLButtonElement> | undefined;
|
|
177
217
|
onMouseDown?: import("react").MouseEventHandler<HTMLButtonElement> | undefined;
|
|
178
218
|
onMouseDownCapture?: import("react").MouseEventHandler<HTMLButtonElement> | undefined;
|
|
219
|
+
onMouseEnter?: import("react").MouseEventHandler<HTMLButtonElement> | undefined;
|
|
220
|
+
onMouseLeave?: import("react").MouseEventHandler<HTMLButtonElement> | undefined;
|
|
179
221
|
onMouseMove?: import("react").MouseEventHandler<HTMLButtonElement> | undefined;
|
|
180
222
|
onMouseMoveCapture?: import("react").MouseEventHandler<HTMLButtonElement> | undefined;
|
|
181
223
|
onMouseOut?: import("react").MouseEventHandler<HTMLButtonElement> | undefined;
|
|
@@ -226,48 +268,7 @@ declare const UnstyledButton: import("react").ComponentType<{
|
|
|
226
268
|
onAnimationIterationCapture?: import("react").AnimationEventHandler<HTMLButtonElement> | undefined;
|
|
227
269
|
onTransitionEnd?: import("react").TransitionEventHandler<HTMLButtonElement> | undefined;
|
|
228
270
|
onTransitionEndCapture?: import("react").TransitionEventHandler<HTMLButtonElement> | undefined;
|
|
229
|
-
|
|
230
|
-
is?: string | undefined;
|
|
231
|
-
disabled?: boolean | undefined;
|
|
232
|
-
value?: string | number | readonly string[] | undefined;
|
|
233
|
-
defaultChecked?: boolean | undefined;
|
|
234
|
-
defaultValue?: string | number | readonly string[] | undefined;
|
|
235
|
-
suppressContentEditableWarning?: boolean | undefined;
|
|
236
|
-
suppressHydrationWarning?: boolean | undefined;
|
|
237
|
-
accessKey?: string | undefined;
|
|
238
|
-
contentEditable?: "inherit" | (boolean | "true" | "false") | undefined;
|
|
239
|
-
contextMenu?: string | undefined;
|
|
240
|
-
placeholder?: string | undefined;
|
|
241
|
-
spellCheck?: (boolean | "true" | "false") | undefined;
|
|
242
|
-
inputMode?: "search" | "text" | "none" | "tel" | "url" | "email" | "numeric" | "decimal" | undefined;
|
|
243
|
-
radioGroup?: string | undefined;
|
|
244
|
-
about?: string | undefined;
|
|
245
|
-
datatype?: string | undefined;
|
|
246
|
-
inlist?: any;
|
|
247
|
-
prefix?: string | undefined;
|
|
248
|
-
property?: string | undefined;
|
|
249
|
-
resource?: string | undefined;
|
|
250
|
-
typeof?: string | undefined;
|
|
251
|
-
vocab?: string | undefined;
|
|
252
|
-
autoCapitalize?: string | undefined;
|
|
253
|
-
autoCorrect?: string | undefined;
|
|
254
|
-
autoSave?: string | undefined;
|
|
255
|
-
itemProp?: string | undefined;
|
|
256
|
-
itemScope?: boolean | undefined;
|
|
257
|
-
itemType?: string | undefined;
|
|
258
|
-
itemID?: string | undefined;
|
|
259
|
-
itemRef?: string | undefined;
|
|
260
|
-
results?: number | undefined;
|
|
261
|
-
security?: string | undefined;
|
|
262
|
-
unselectable?: "on" | "off" | undefined;
|
|
263
|
-
autoFocus?: boolean | undefined;
|
|
264
|
-
formAction?: string | undefined;
|
|
265
|
-
formEncType?: string | undefined;
|
|
266
|
-
formMethod?: string | undefined;
|
|
267
|
-
formNoValidate?: boolean | undefined;
|
|
268
|
-
formTarget?: string | undefined;
|
|
269
|
-
hidden?: boolean | undefined;
|
|
270
|
-
translate?: "no" | "yes" | undefined;
|
|
271
|
+
borderColor?: string | [string | undefined, string | undefined] | [string | undefined, string | undefined, string | undefined] | undefined;
|
|
271
272
|
p?: import("csstype").PaddingProperty<string | number> | [import("csstype").PaddingProperty<string | number> | undefined, import("csstype").PaddingProperty<string | number> | undefined] | [import("csstype").PaddingProperty<string | number> | undefined, import("csstype").PaddingProperty<string | number> | undefined, import("csstype").PaddingProperty<string | number> | undefined] | undefined;
|
|
272
273
|
height?: import("csstype").HeightProperty<string | number> | [import("csstype").HeightProperty<string | number> | undefined, import("csstype").HeightProperty<string | number> | undefined] | [import("csstype").HeightProperty<string | number> | undefined, import("csstype").HeightProperty<string | number> | undefined, import("csstype").HeightProperty<string | number> | undefined] | undefined;
|
|
273
274
|
width?: import("csstype").WidthProperty<string | number> | [import("csstype").WidthProperty<string | number> | undefined, import("csstype").WidthProperty<string | number> | undefined] | [import("csstype").WidthProperty<string | number> | undefined, import("csstype").WidthProperty<string | number> | undefined, import("csstype").WidthProperty<string | number> | undefined] | undefined;
|
|
@@ -276,7 +277,6 @@ declare const UnstyledButton: import("react").ComponentType<{
|
|
|
276
277
|
fontSize?: import("csstype").FontSizeProperty<string | number> | [import("csstype").FontSizeProperty<string | number> | undefined, import("csstype").FontSizeProperty<string | number> | undefined] | [import("csstype").FontSizeProperty<string | number> | undefined, import("csstype").FontSizeProperty<string | number> | undefined, import("csstype").FontSizeProperty<string | number> | undefined] | undefined;
|
|
277
278
|
fontWeight?: import("csstype").FontWeightProperty | [import("csstype").FontWeightProperty | undefined, import("csstype").FontWeightProperty | undefined] | [import("csstype").FontWeightProperty | undefined, import("csstype").FontWeightProperty | undefined, import("csstype").FontWeightProperty | undefined] | undefined;
|
|
278
279
|
textDecoration?: string | [string | undefined, string | undefined] | [string | undefined, string | undefined, string | undefined] | undefined;
|
|
279
|
-
borderColor?: string | [string | undefined, string | undefined] | [string | undefined, string | undefined, string | undefined] | undefined;
|
|
280
280
|
margin?: import("csstype").MarginProperty<string | number> | [import("csstype").MarginProperty<string | number> | undefined, import("csstype").MarginProperty<string | number> | undefined] | [import("csstype").MarginProperty<string | number> | undefined, import("csstype").MarginProperty<string | number> | undefined, import("csstype").MarginProperty<string | number> | undefined] | undefined;
|
|
281
281
|
marginLeft?: import("csstype").MarginLeftProperty<string | number> | [import("csstype").MarginLeftProperty<string | number> | undefined, import("csstype").MarginLeftProperty<string | number> | undefined] | [import("csstype").MarginLeftProperty<string | number> | undefined, import("csstype").MarginLeftProperty<string | number> | undefined, import("csstype").MarginLeftProperty<string | number> | undefined] | undefined;
|
|
282
282
|
marginRight?: import("csstype").MarginRightProperty<string | number> | [import("csstype").MarginRightProperty<string | number> | undefined, import("csstype").MarginRightProperty<string | number> | undefined] | [import("csstype").MarginRightProperty<string | number> | undefined, import("csstype").MarginRightProperty<string | number> | undefined, import("csstype").MarginRightProperty<string | number> | undefined] | undefined;
|
|
@@ -335,12 +335,14 @@ declare const UnstyledButton: import("react").ComponentType<{
|
|
|
335
335
|
flexDirection?: import("csstype").FlexDirectionProperty | [import("csstype").FlexDirectionProperty | undefined, import("csstype").FlexDirectionProperty | undefined] | [import("csstype").FlexDirectionProperty | undefined, import("csstype").FlexDirectionProperty | undefined, import("csstype").FlexDirectionProperty | undefined] | undefined;
|
|
336
336
|
flexBasis?: import("csstype").FlexBasisProperty<string | number> | [import("csstype").FlexBasisProperty<string | number> | undefined, import("csstype").FlexBasisProperty<string | number> | undefined] | [import("csstype").FlexBasisProperty<string | number> | undefined, import("csstype").FlexBasisProperty<string | number> | undefined, import("csstype").FlexBasisProperty<string | number> | undefined] | undefined;
|
|
337
337
|
flexGrow?: import("csstype").GlobalsNumber | [import("csstype").GlobalsNumber | undefined, import("csstype").GlobalsNumber | undefined] | [import("csstype").GlobalsNumber | undefined, import("csstype").GlobalsNumber | undefined, import("csstype").GlobalsNumber | undefined] | undefined;
|
|
338
|
+
gridTemplateColumns?: import("csstype").GridTemplateColumnsProperty<string | number> | [import("csstype").GridTemplateColumnsProperty<string | number> | undefined, import("csstype").GridTemplateColumnsProperty<string | number> | undefined] | [import("csstype").GridTemplateColumnsProperty<string | number> | undefined, import("csstype").GridTemplateColumnsProperty<string | number> | undefined, import("csstype").GridTemplateColumnsProperty<string | number> | undefined] | undefined;
|
|
339
|
+
focus?: boolean | undefined;
|
|
338
340
|
innerRef?: import("react").Ref<HTMLButtonElement> | undefined;
|
|
339
341
|
gridColumnSpan?: number | number[] | "end" | "all" | undefined;
|
|
340
342
|
gridColumnPad?: number | number[] | undefined;
|
|
341
343
|
gridRowSpan?: number | number[] | undefined;
|
|
342
344
|
gridRowPad?: number | number[] | undefined;
|
|
343
|
-
gridAlign?: ("
|
|
344
|
-
gridJustify?: ("
|
|
345
|
+
gridAlign?: ("start" | "end" | "center" | "stretch") | undefined;
|
|
346
|
+
gridJustify?: ("start" | "end" | "center" | "stretch") | undefined;
|
|
345
347
|
}>;
|
|
346
348
|
export default UnstyledButton;
|
package/es/Button.js
CHANGED
|
@@ -11,19 +11,24 @@ import PropTypes from 'prop-types';
|
|
|
11
11
|
import { isDarkMode } from '@cloudflare/style-const';
|
|
12
12
|
import { ariaAttributes, createStyledComponent } from '@cloudflare/style-container';
|
|
13
13
|
import { Icon } from '@cloudflare/component-icon';
|
|
14
|
+
var borderRadius = '4px';
|
|
15
|
+
|
|
16
|
+
var standardColors = (theme, state) => {
|
|
17
|
+
var _theme$colors$button$, _theme$colors$button$2, _theme$colors$button$3, _theme$colors$button$4, _theme$colors$button$5, _theme$colors$button$6;
|
|
14
18
|
|
|
15
|
-
var standardColors = theme => {
|
|
16
19
|
var color = theme.colors.gray[9];
|
|
17
20
|
return {
|
|
18
21
|
default: isDarkMode() ? color : theme.colors.gray[1],
|
|
19
|
-
primary: color,
|
|
20
22
|
success: color,
|
|
21
23
|
warning: color,
|
|
22
|
-
danger: color,
|
|
23
24
|
inverted: {
|
|
24
|
-
danger: theme.colors.
|
|
25
|
-
primary: theme.colors.
|
|
26
|
-
}
|
|
25
|
+
danger: (_theme$colors$button$ = theme.colors.button.danger[state]) === null || _theme$colors$button$ === void 0 ? void 0 : _theme$colors$button$[state === 'active' ? 'text' : 'background'],
|
|
26
|
+
primary: (_theme$colors$button$2 = theme.colors.button.primary[state]) === null || _theme$colors$button$2 === void 0 ? void 0 : _theme$colors$button$2[state === 'active' ? 'text' : 'background']
|
|
27
|
+
},
|
|
28
|
+
primary: ((_theme$colors$button$3 = theme.colors.button.primary[state]) === null || _theme$colors$button$3 === void 0 ? void 0 : _theme$colors$button$3.text) || color,
|
|
29
|
+
danger: ((_theme$colors$button$4 = theme.colors.button.danger[state]) === null || _theme$colors$button$4 === void 0 ? void 0 : _theme$colors$button$4.text) || color,
|
|
30
|
+
plain: ((_theme$colors$button$5 = theme.colors.button.plain[state]) === null || _theme$colors$button$5 === void 0 ? void 0 : _theme$colors$button$5.text) || color,
|
|
31
|
+
plainMono: ((_theme$colors$button$6 = theme.colors.button.plainMono[state]) === null || _theme$colors$button$6 === void 0 ? void 0 : _theme$colors$button$6.text) || color
|
|
27
32
|
};
|
|
28
33
|
};
|
|
29
34
|
|
|
@@ -35,95 +40,73 @@ var buttonColors = theme => {
|
|
|
35
40
|
normal: {
|
|
36
41
|
backgroundColor: {
|
|
37
42
|
default: isDarkMode() ? theme.colors.gray[standardIndex] : theme.colors.gray[8],
|
|
38
|
-
primary: theme.colors.
|
|
43
|
+
primary: theme.colors.button.primary.normal.background,
|
|
39
44
|
success: theme.colors.green[standardIndex],
|
|
40
45
|
warning: theme.colors.orange[standardIndex],
|
|
41
|
-
danger: theme.colors.
|
|
46
|
+
danger: theme.colors.button.danger.normal.background,
|
|
42
47
|
inverted: {
|
|
43
48
|
danger: 'transparent',
|
|
44
49
|
primary: 'transparent'
|
|
45
|
-
}
|
|
50
|
+
},
|
|
51
|
+
plain: theme.colors.button.plain.normal.background,
|
|
52
|
+
plainMono: theme.colors.button.plainMono.normal.background
|
|
46
53
|
},
|
|
47
|
-
color: standardColors(theme)
|
|
54
|
+
color: standardColors(theme, 'normal')
|
|
48
55
|
},
|
|
49
56
|
// Hover
|
|
50
57
|
hover: {
|
|
51
58
|
backgroundColor: {
|
|
52
59
|
default: theme.colors.gray[isDarkMode() ? 2 : 7],
|
|
53
|
-
primary: theme.colors.
|
|
60
|
+
primary: theme.colors.button.primary.hover.background,
|
|
54
61
|
success: theme.colors.green[hoverIndex],
|
|
55
62
|
warning: theme.colors.orange[hoverIndex],
|
|
56
|
-
danger: theme.colors.
|
|
57
|
-
inverted: {
|
|
58
|
-
danger: theme.colors.red[hoverIndex],
|
|
59
|
-
primary: theme.colors.blue[hoverIndex]
|
|
60
|
-
}
|
|
61
|
-
},
|
|
62
|
-
color: _objectSpread(_objectSpread({}, standardColors(theme)), {}, {
|
|
63
|
+
danger: theme.colors.button.danger.hover.background,
|
|
63
64
|
inverted: {
|
|
64
65
|
danger: theme.colors.white,
|
|
65
66
|
primary: theme.colors.white
|
|
66
|
-
}
|
|
67
|
-
|
|
67
|
+
},
|
|
68
|
+
plain: theme.colors.button.plain.hover.background,
|
|
69
|
+
plainMono: theme.colors.button.plainMono.hover.background
|
|
70
|
+
},
|
|
71
|
+
color: standardColors(theme, 'hover')
|
|
68
72
|
},
|
|
69
73
|
// Active
|
|
70
74
|
active: {
|
|
71
75
|
backgroundColor: {
|
|
72
|
-
default: theme.colors.gray[isDarkMode() ? 3 :
|
|
73
|
-
primary: theme.colors.
|
|
76
|
+
default: theme.colors.gray[isDarkMode() ? 3 : 6],
|
|
77
|
+
primary: theme.colors.button.primary.active.background,
|
|
74
78
|
success: theme.colors.green[standardIndex],
|
|
75
79
|
warning: theme.colors.orange[standardIndex],
|
|
76
|
-
danger: theme.colors.
|
|
80
|
+
danger: theme.colors.button.danger.active.background,
|
|
77
81
|
inverted: {
|
|
78
|
-
danger: theme.colors.red[
|
|
79
|
-
primary: theme.colors.blue[
|
|
80
|
-
}
|
|
82
|
+
danger: theme.colors.red[hoverIndex],
|
|
83
|
+
primary: theme.colors.blue[hoverIndex]
|
|
84
|
+
},
|
|
85
|
+
plain: theme.colors.button.plain.active.background,
|
|
86
|
+
plainMono: theme.colors.button.plainMono.active.background
|
|
81
87
|
},
|
|
82
|
-
color:
|
|
83
|
-
inverted: {
|
|
84
|
-
danger: theme.colors.gray[9],
|
|
85
|
-
primary: theme.colors.gray[9]
|
|
86
|
-
}
|
|
87
|
-
})
|
|
88
|
+
color: standardColors(theme, 'active')
|
|
88
89
|
},
|
|
89
90
|
// Focus
|
|
90
91
|
focus: {
|
|
91
92
|
backgroundColor: {
|
|
92
93
|
default: theme.colors.gray[isDarkMode() ? 3 : 8],
|
|
93
|
-
primary: theme.colors.
|
|
94
|
+
primary: theme.colors.button.primary.focus.background,
|
|
94
95
|
success: theme.colors.green[standardIndex],
|
|
95
96
|
warning: theme.colors.orange[standardIndex],
|
|
96
|
-
danger: theme.colors.
|
|
97
|
+
danger: theme.colors.button.danger.focus.background,
|
|
97
98
|
inverted: {
|
|
98
99
|
danger: 'transparent',
|
|
99
100
|
primary: 'transparent'
|
|
100
|
-
}
|
|
101
|
+
},
|
|
102
|
+
plain: theme.colors.button.plain.focus.background,
|
|
103
|
+
plainMono: theme.colors.button.plainMono.focus.background
|
|
101
104
|
},
|
|
102
|
-
color: standardColors(theme)
|
|
105
|
+
color: standardColors(theme, 'focus')
|
|
103
106
|
}
|
|
104
107
|
};
|
|
105
108
|
};
|
|
106
109
|
|
|
107
|
-
var getFocusOutlineColor = (theme, type, inverted) => {
|
|
108
|
-
var _invertedOutlines$typ;
|
|
109
|
-
|
|
110
|
-
var standardIndex = isDarkMode() ? 3 : 4;
|
|
111
|
-
var FOCUS_OFFSET_INDEX = 2;
|
|
112
|
-
var focusIndex = standardIndex - FOCUS_OFFSET_INDEX;
|
|
113
|
-
var outlines = {
|
|
114
|
-
default: isDarkMode() ? theme.colors.gray[focusIndex] : theme.colors.gray[8 - FOCUS_OFFSET_INDEX],
|
|
115
|
-
primary: theme.colors.blue[focusIndex],
|
|
116
|
-
success: theme.colors.green[focusIndex],
|
|
117
|
-
warning: theme.colors.orange[focusIndex],
|
|
118
|
-
danger: theme.colors.red[focusIndex]
|
|
119
|
-
};
|
|
120
|
-
var invertedOutlines = {
|
|
121
|
-
danger: theme.colors.red[focusIndex],
|
|
122
|
-
primary: theme.colors.blue[focusIndex]
|
|
123
|
-
};
|
|
124
|
-
return inverted ? (_invertedOutlines$typ = invertedOutlines[type]) !== null && _invertedOutlines$typ !== void 0 ? _invertedOutlines$typ : outlines[type] : outlines[type];
|
|
125
|
-
};
|
|
126
|
-
|
|
127
110
|
var colorAccessor = (property, _ref) => {
|
|
128
111
|
var {
|
|
129
112
|
inverted = false,
|
|
@@ -140,13 +123,18 @@ var interactionStyleAccessor = (interactionState, props) => {
|
|
|
140
123
|
} = props;
|
|
141
124
|
var isInteractive = !(loading || disabled);
|
|
142
125
|
var stateStyles = buttonColors(theme)[interactionState];
|
|
126
|
+
var color = colorAccessor(stateStyles.color, props);
|
|
127
|
+
var backgroundColor = colorAccessor(stateStyles.backgroundColor, props);
|
|
143
128
|
return isInteractive ? {
|
|
144
|
-
backgroundColor
|
|
145
|
-
color
|
|
129
|
+
backgroundColor,
|
|
130
|
+
color,
|
|
131
|
+
boxShadow: props.inverted ? "inset 0px 0px 0px 1px ".concat(interactionState === 'active' ? backgroundColor : color) : undefined
|
|
146
132
|
} : undefined;
|
|
147
133
|
};
|
|
148
134
|
|
|
149
135
|
export var buttonStyles = props => {
|
|
136
|
+
var _styles$buttonState, _styles$buttonState2;
|
|
137
|
+
|
|
150
138
|
var {
|
|
151
139
|
theme,
|
|
152
140
|
loading = false,
|
|
@@ -158,28 +146,33 @@ export var buttonStyles = props => {
|
|
|
158
146
|
space = 2,
|
|
159
147
|
type = 'default',
|
|
160
148
|
stretch,
|
|
161
|
-
noWrapText
|
|
149
|
+
noWrapText,
|
|
150
|
+
buttonState
|
|
162
151
|
} = props;
|
|
163
|
-
var
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
152
|
+
var styles = {
|
|
153
|
+
normal: buttonColors(theme).normal,
|
|
154
|
+
hover: interactionStyleAccessor('hover', props),
|
|
155
|
+
active: interactionStyleAccessor('active', props),
|
|
156
|
+
focus: interactionStyleAccessor('focus', props)
|
|
157
|
+
};
|
|
158
|
+
var color = buttonState && styles[buttonState] ? (_styles$buttonState = styles[buttonState]) === null || _styles$buttonState === void 0 ? void 0 : _styles$buttonState.color : colorAccessor(styles.normal.color, props);
|
|
159
|
+
var backgroundColor = buttonState && styles[buttonState] ? (_styles$buttonState2 = styles[buttonState]) === null || _styles$buttonState2 === void 0 ? void 0 : _styles$buttonState2.backgroundColor : colorAccessor(styles.normal.backgroundColor, props);
|
|
160
|
+
return _objectSpread(_objectSpread(_objectSpread({}, buttonState ? {} : {
|
|
161
|
+
'&:focus': styles.focus,
|
|
162
|
+
'&:hover': styles.hover,
|
|
163
|
+
'&:active': styles.active,
|
|
164
|
+
'&:focus:active': styles.active
|
|
165
|
+
}), {}, {
|
|
171
166
|
'&:focus-visible': {
|
|
172
167
|
outlineOffset: 3,
|
|
173
168
|
outlineStyle: 'auto',
|
|
174
|
-
outlineColor:
|
|
169
|
+
outlineColor: type === 'danger' ? theme.colors.red[isDarkMode() ? 3 : 4] : theme.colors.focus
|
|
175
170
|
},
|
|
176
|
-
'&:focus-within:hover': focusStyles,
|
|
177
|
-
'&:active:hover': activeStyles,
|
|
178
171
|
'&[title]': {
|
|
179
172
|
pointerEvents: disabled ? 'auto' : 'none'
|
|
180
173
|
},
|
|
181
|
-
backgroundColor
|
|
182
|
-
color: loading ? 'transparent' :
|
|
174
|
+
backgroundColor,
|
|
175
|
+
color: loading ? 'transparent' : color,
|
|
183
176
|
cursor: disabled || loading ? 'default' : 'pointer',
|
|
184
177
|
display: 'inline-flex',
|
|
185
178
|
flexGrow: stretch ? 1 : undefined,
|
|
@@ -189,22 +182,17 @@ export var buttonStyles = props => {
|
|
|
189
182
|
fontSize: 2,
|
|
190
183
|
fontWeight: 400,
|
|
191
184
|
lineHeight: 1.2,
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
borderColor: inverted ? colorAccessor(normalStyles.color, props) : 'currentColor',
|
|
201
|
-
borderTopRightRadius: (group === 'first' || group === 'inbetween') && !spaced ? 0 : theme.radii[2],
|
|
202
|
-
borderTopLeftRadius: (group === 'last' || group === 'inbetween') && !spaced ? 0 : theme.radii[2],
|
|
203
|
-
borderBottomLeftRadius: (group === 'last' || group === 'inbetween') && !spaced ? 0 : theme.radii[2],
|
|
204
|
-
borderBottomRightRadius: (group === 'first' || group === 'inbetween') && !spaced ? 0 : theme.radii[2],
|
|
185
|
+
border: 'none'
|
|
186
|
+
}, inverted ? {
|
|
187
|
+
boxShadow: "inset 0px 0px 0px 1px ".concat(buttonState === 'active' ? backgroundColor : color)
|
|
188
|
+
} : {}), {}, {
|
|
189
|
+
borderTopRightRadius: (group === 'first' || group === 'inbetween') && !spaced ? 0 : borderRadius,
|
|
190
|
+
borderTopLeftRadius: (group === 'last' || group === 'inbetween') && !spaced ? 0 : borderRadius,
|
|
191
|
+
borderBottomLeftRadius: (group === 'last' || group === 'inbetween') && !spaced ? 0 : borderRadius,
|
|
192
|
+
borderBottomRightRadius: (group === 'first' || group === 'inbetween') && !spaced ? 0 : borderRadius,
|
|
205
193
|
'&::before': loading ? {
|
|
206
194
|
content: '"•••"',
|
|
207
|
-
color
|
|
195
|
+
color,
|
|
208
196
|
display: 'flex',
|
|
209
197
|
alignItems: 'center',
|
|
210
198
|
justifyContent: 'center',
|
|
@@ -232,7 +220,7 @@ export var buttonStyles = props => {
|
|
|
232
220
|
pointerEvents: disabled ? 'none' : 'auto',
|
|
233
221
|
position: 'relative',
|
|
234
222
|
textAlign: 'center',
|
|
235
|
-
transitionProperty:
|
|
223
|
+
transitionProperty: 'all',
|
|
236
224
|
transitionDuration: '200ms',
|
|
237
225
|
transitionTimingFunction: 'ease',
|
|
238
226
|
userSelect: 'none',
|
|
@@ -240,10 +228,11 @@ export var buttonStyles = props => {
|
|
|
240
228
|
float: 'none',
|
|
241
229
|
whiteSpace: noWrapText ? 'nowrap' : 'normal',
|
|
242
230
|
width: direction === 'column' ? '100%' : 'auto'
|
|
243
|
-
};
|
|
231
|
+
});
|
|
244
232
|
};
|
|
245
233
|
var Button = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
246
234
|
var {
|
|
235
|
+
id,
|
|
247
236
|
submit = false,
|
|
248
237
|
className,
|
|
249
238
|
disabled,
|
|
@@ -263,6 +252,7 @@ var Button = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
263
252
|
[propName]: props[propName]
|
|
264
253
|
}), {});
|
|
265
254
|
return /*#__PURE__*/React.createElement("button", _extends({}, ariaAndDataProps, {
|
|
255
|
+
id: id,
|
|
266
256
|
type: submit ? 'submit' : 'button',
|
|
267
257
|
"data-testid": testId,
|
|
268
258
|
disabled: disabled || loading,
|
|
@@ -285,6 +275,7 @@ var Button = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
285
275
|
}));
|
|
286
276
|
});
|
|
287
277
|
Button.propTypes = {
|
|
278
|
+
id: PropTypes.string,
|
|
288
279
|
onClick: PropTypes.func,
|
|
289
280
|
submit: PropTypes.bool,
|
|
290
281
|
spaced: PropTypes.bool,
|
|
@@ -292,7 +283,7 @@ Button.propTypes = {
|
|
|
292
283
|
direction: PropTypes.oneOf(['column', 'row']),
|
|
293
284
|
className: PropTypes.string,
|
|
294
285
|
group: PropTypes.oneOf(['first', 'inbetween', 'last']),
|
|
295
|
-
type: PropTypes.oneOf(['default', 'primary', 'success', 'warning', 'danger']),
|
|
286
|
+
type: PropTypes.oneOf(['default', 'primary', 'success', 'warning', 'danger', 'plain', 'plainMono']),
|
|
296
287
|
testId: PropTypes.string,
|
|
297
288
|
disabled: PropTypes.bool,
|
|
298
289
|
loading: PropTypes.bool,
|
|
@@ -304,7 +295,8 @@ Button.propTypes = {
|
|
|
304
295
|
tabIndex: PropTypes.number,
|
|
305
296
|
ariaLabel: PropTypes.string,
|
|
306
297
|
stretch: PropTypes.bool,
|
|
307
|
-
noWrapText: PropTypes.bool
|
|
298
|
+
noWrapText: PropTypes.bool,
|
|
299
|
+
buttonState: PropTypes.oneOf(['hover', 'active', 'focus'])
|
|
308
300
|
};
|
|
309
301
|
Button.displayName = 'Button';
|
|
310
302
|
export default createStyledComponent(buttonStyles, Button);
|
package/es/UnstyledButton.js
CHANGED
|
@@ -1,11 +1,25 @@
|
|
|
1
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
2
|
+
|
|
3
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
|
+
|
|
5
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
|
+
|
|
1
7
|
import { createStyledComponent } from '@cloudflare/style-container';
|
|
2
|
-
var UnstyledButton = createStyledComponent(
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
var UnstyledButton = createStyledComponent(_ref => {
|
|
9
|
+
var {
|
|
10
|
+
theme,
|
|
11
|
+
focus,
|
|
12
|
+
disabled
|
|
13
|
+
} = _ref;
|
|
14
|
+
return _objectSpread({
|
|
15
|
+
background: 'none',
|
|
16
|
+
color: 'inherit',
|
|
17
|
+
border: 'none',
|
|
18
|
+
padding: 0,
|
|
19
|
+
opacity: disabled ? 0.5 : undefined,
|
|
20
|
+
font: 'inherit',
|
|
21
|
+
cursor: 'pointer',
|
|
22
|
+
outline: 'inherit'
|
|
23
|
+
}, focus ? theme.mixins.focus() : {});
|
|
24
|
+
}, 'button');
|
|
11
25
|
export default UnstyledButton;
|