@mirohq/design-system-button 2.1.2-button.0 → 2.1.2-changelog-1.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/dist/main.js +316 -268
- package/dist/main.js.map +1 -1
- package/dist/module.js +317 -269
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +53 -451
- package/package.json +5 -7
package/dist/module.js
CHANGED
|
@@ -1,289 +1,297 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { useRef } from 'react';
|
|
2
|
+
import { useButton } from '@react-aria/button';
|
|
3
|
+
import { mergeProps } from '@react-aria/utils';
|
|
2
4
|
import { Spinner } from '@mirohq/design-system-spinner';
|
|
5
|
+
import { useLink } from '@react-aria/link';
|
|
6
|
+
import { useFocusRing } from '@react-aria/focus';
|
|
3
7
|
import { Primitive } from '@mirohq/design-system-primitive';
|
|
4
8
|
import { styled } from '@mirohq/design-system-stitches';
|
|
5
|
-
import {
|
|
9
|
+
import { focus } from '@mirohq/design-system-styles';
|
|
6
10
|
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
ref: forwardRef,
|
|
11
|
-
"aria-hidden": true,
|
|
12
|
-
asChild: true
|
|
13
|
-
}, children));
|
|
14
|
-
|
|
15
|
-
const activeSelector = "&:active, &[data-pressed]";
|
|
16
|
-
const disabledSelector = '&[disabled], &[aria-disabled="true"]';
|
|
17
|
-
const iconSlotSelector = `& ${StyledIconSlot}`;
|
|
18
|
-
const solidDisabled = {
|
|
19
|
-
[disabledSelector]: {
|
|
20
|
-
backgroundColor: "$background-neutrals-disabled",
|
|
21
|
-
color: "$text-neutrals-disabled",
|
|
22
|
-
[iconSlotSelector]: {
|
|
23
|
-
color: "$icon-neutrals-disabled"
|
|
24
|
-
}
|
|
11
|
+
const focusFilled = {
|
|
12
|
+
"&[data-focused]": {
|
|
13
|
+
boxShadow: `inset 0 0 0 1px white, ${focus.defaults["&:focus-visible"].boxShadow}`
|
|
25
14
|
}
|
|
26
15
|
};
|
|
27
|
-
const
|
|
28
|
-
[
|
|
29
|
-
|
|
30
|
-
borderColor: "
|
|
31
|
-
color: "$text-neutrals-disabled",
|
|
32
|
-
[iconSlotSelector]: {
|
|
33
|
-
color: "$icon-neutrals-disabled"
|
|
34
|
-
}
|
|
16
|
+
const focusOutline = {
|
|
17
|
+
"&[data-focused]": {
|
|
18
|
+
...focus.defaults,
|
|
19
|
+
borderColor: "transparent"
|
|
35
20
|
}
|
|
36
21
|
};
|
|
37
|
-
const
|
|
38
|
-
[
|
|
39
|
-
color: "$text-neutrals-disabled",
|
|
40
|
-
backgroundColor: "$transparent",
|
|
41
|
-
[iconSlotSelector]: {
|
|
42
|
-
color: "$icon-neutrals-disabled"
|
|
43
|
-
}
|
|
44
|
-
}
|
|
22
|
+
const focusDefault = {
|
|
23
|
+
"&[data-focused]": focus.defaults
|
|
45
24
|
};
|
|
46
|
-
const
|
|
47
|
-
const StyledButton = styled(
|
|
48
|
-
|
|
25
|
+
const pressedSelector = "&:active, &[data-pressed]";
|
|
26
|
+
const StyledButton = styled(Primitive.button, {
|
|
27
|
+
boxSizing: "border-box",
|
|
28
|
+
display: "inline-block",
|
|
29
|
+
outline: "none",
|
|
49
30
|
whiteSpace: "nowrap",
|
|
50
31
|
textOverflow: "ellipsis",
|
|
51
32
|
textAlign: "center",
|
|
33
|
+
verticalAlign: "middle",
|
|
34
|
+
userSelect: "none",
|
|
35
|
+
fontFamily: "inherit",
|
|
36
|
+
fontStyle: "normal",
|
|
37
|
+
fontStretch: "normal",
|
|
38
|
+
letterSpacing: "normal",
|
|
39
|
+
fontWeight: "normal",
|
|
52
40
|
position: "relative",
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
"&[
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
},
|
|
61
|
-
[`& ${StyledIconSlot}:first-child`]: {
|
|
62
|
-
marginLeft: -LABEL_OFFSET,
|
|
63
|
-
marginRight: `calc($50 + ${LABEL_OFFSET}px)`
|
|
64
|
-
},
|
|
65
|
-
[`& ${StyledIconSlot}:last-child`]: {
|
|
66
|
-
marginRight: -LABEL_OFFSET,
|
|
67
|
-
marginLeft: `calc($50 + ${LABEL_OFFSET}px)`
|
|
41
|
+
cursor: "pointer",
|
|
42
|
+
border: "none",
|
|
43
|
+
textDecoration: "none",
|
|
44
|
+
backgroundColor: "transparent",
|
|
45
|
+
"&[disabled]": {
|
|
46
|
+
pointerEvents: "none",
|
|
47
|
+
opacity: 0.4
|
|
68
48
|
},
|
|
69
49
|
variants: {
|
|
70
50
|
variant: {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
51
|
+
primary: {},
|
|
52
|
+
secondary: {},
|
|
53
|
+
danger: {}
|
|
54
|
+
},
|
|
55
|
+
appearance: {
|
|
56
|
+
filled: {},
|
|
57
|
+
outlined: {},
|
|
58
|
+
flat: {}
|
|
59
|
+
},
|
|
60
|
+
size: {
|
|
61
|
+
large: {
|
|
62
|
+
padding: "14px 32px 18px 32px",
|
|
63
|
+
fontSize: "20px",
|
|
64
|
+
lineHeight: "28px",
|
|
65
|
+
height: "60px"
|
|
84
66
|
},
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
color: "$icon-primary"
|
|
91
|
-
},
|
|
92
|
-
"&:hover": {
|
|
93
|
-
backgroundColor: "$background-primary-subtle-hover",
|
|
94
|
-
borderColor: "$border-primary-hover",
|
|
95
|
-
color: "$text-primary-hover",
|
|
96
|
-
[iconSlotSelector]: {
|
|
97
|
-
color: "$icon-primary-hover"
|
|
98
|
-
}
|
|
99
|
-
},
|
|
100
|
-
[activeSelector]: {
|
|
101
|
-
backgroundColor: "$background-primary-subtle-active",
|
|
102
|
-
borderColor: "$border-primary-active",
|
|
103
|
-
color: "$text-primary-active",
|
|
104
|
-
[iconSlotSelector]: {
|
|
105
|
-
color: "$icon-primary-active"
|
|
106
|
-
}
|
|
107
|
-
},
|
|
108
|
-
...outlineDisabled
|
|
67
|
+
medium: {
|
|
68
|
+
padding: "11px 24px 13px 24px",
|
|
69
|
+
fontSize: "16px",
|
|
70
|
+
lineHeight: "24px",
|
|
71
|
+
height: "48px"
|
|
109
72
|
},
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
"
|
|
114
|
-
|
|
115
|
-
color: "$text-primary-hover",
|
|
116
|
-
[iconSlotSelector]: {
|
|
117
|
-
color: "$icon-primary-hover"
|
|
118
|
-
}
|
|
119
|
-
},
|
|
120
|
-
[activeSelector]: {
|
|
121
|
-
backgroundColor: "$background-primary-subtle-active",
|
|
122
|
-
color: "$text-primary-active",
|
|
123
|
-
[iconSlotSelector]: {
|
|
124
|
-
color: "$icon-primary-active"
|
|
125
|
-
}
|
|
126
|
-
},
|
|
127
|
-
...ghostDisabled
|
|
73
|
+
small: {
|
|
74
|
+
padding: "7px 16px 9px 16px",
|
|
75
|
+
fontSize: "14px",
|
|
76
|
+
lineHeight: "20px",
|
|
77
|
+
height: "36px"
|
|
128
78
|
},
|
|
129
|
-
"
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
},
|
|
135
|
-
"&:hover": {
|
|
136
|
-
backgroundColor: "$background-neutrals-subtle-hover"
|
|
137
|
-
},
|
|
138
|
-
[activeSelector]: {
|
|
139
|
-
backgroundColor: "$background-neutrals-subtle-active"
|
|
140
|
-
},
|
|
141
|
-
...solidDisabled
|
|
79
|
+
"x-small": {
|
|
80
|
+
padding: "5px 12px 7px",
|
|
81
|
+
fontSize: "14px",
|
|
82
|
+
lineHeight: "20px",
|
|
83
|
+
height: "32px"
|
|
142
84
|
},
|
|
143
|
-
"
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
85
|
+
"xx-small": {
|
|
86
|
+
padding: "3px 12px",
|
|
87
|
+
fontSize: "12px",
|
|
88
|
+
lineHeight: "18px",
|
|
89
|
+
height: "24px"
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
rounded: {
|
|
93
|
+
true: {
|
|
94
|
+
borderRadius: "$half"
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
loading: {
|
|
98
|
+
true: {
|
|
99
|
+
"&[disabled]": {
|
|
100
|
+
cursor: "default",
|
|
101
|
+
opacity: 1,
|
|
102
|
+
pointerEvents: "none",
|
|
103
|
+
"& > span": {
|
|
104
|
+
visibility: "hidden"
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
fluid: {
|
|
110
|
+
true: {
|
|
111
|
+
width: "100%",
|
|
112
|
+
display: "block"
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
compoundVariants: [
|
|
117
|
+
{
|
|
118
|
+
size: "small",
|
|
119
|
+
rounded: true,
|
|
120
|
+
css: {
|
|
121
|
+
padding: "10px 16px",
|
|
122
|
+
height: "40px"
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
size: "large",
|
|
127
|
+
rounded: false,
|
|
128
|
+
css: {
|
|
129
|
+
borderRadius: "$50"
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
size: "medium",
|
|
134
|
+
rounded: false,
|
|
135
|
+
css: {
|
|
136
|
+
borderRadius: "$50"
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
size: "small",
|
|
141
|
+
rounded: false,
|
|
142
|
+
css: {
|
|
143
|
+
borderRadius: "$50"
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
size: "x-small",
|
|
148
|
+
rounded: false,
|
|
149
|
+
css: {
|
|
150
|
+
borderRadius: "$50"
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
size: "xx-small",
|
|
155
|
+
rounded: false,
|
|
156
|
+
css: {
|
|
157
|
+
borderRadius: "$25"
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
variant: "primary",
|
|
162
|
+
appearance: "filled",
|
|
163
|
+
css: {
|
|
164
|
+
color: "$white",
|
|
165
|
+
backgroundColor: "$blue-600",
|
|
166
|
+
...focusFilled,
|
|
150
167
|
"&:hover": {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
},
|
|
154
|
-
[activeSelector]: {
|
|
155
|
-
backgroundColor: "$background-neutrals-subtle-active",
|
|
156
|
-
borderColor: "$border-neutrals-active"
|
|
157
|
-
},
|
|
158
|
-
...outlineDisabled
|
|
159
|
-
},
|
|
160
|
-
"ghost-subtle": {
|
|
161
|
-
backgroundColor: "transparent",
|
|
162
|
-
color: "$text-neutrals",
|
|
163
|
-
[iconSlotSelector]: {
|
|
164
|
-
color: "$icon-neutrals"
|
|
168
|
+
color: "$white",
|
|
169
|
+
backgroundColor: "$blue-700"
|
|
165
170
|
},
|
|
171
|
+
[pressedSelector]: {
|
|
172
|
+
backgroundColor: "$blue-900"
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
variant: "primary",
|
|
178
|
+
appearance: "outlined",
|
|
179
|
+
css: {
|
|
180
|
+
color: "rgba(66, 98, 255, 1)",
|
|
181
|
+
border: "1px solid rgba(66, 98, 255, 1)",
|
|
182
|
+
...focusOutline,
|
|
166
183
|
"&:hover": {
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
[activeSelector]: {
|
|
170
|
-
backgroundColor: "$background-neutrals-subtle-active"
|
|
171
|
-
},
|
|
172
|
-
...ghostDisabled
|
|
173
|
-
},
|
|
174
|
-
"solid-danger": {
|
|
175
|
-
backgroundColor: "$background-danger-prominent",
|
|
176
|
-
color: "$text-danger-inverted",
|
|
177
|
-
[iconSlotSelector]: {
|
|
178
|
-
color: "$icon-danger-inverted"
|
|
184
|
+
color: "rgba(66, 98, 255, 1)",
|
|
185
|
+
backgroundColor: "rgba(244, 246, 255, 1)"
|
|
179
186
|
},
|
|
187
|
+
[pressedSelector]: {
|
|
188
|
+
backgroundColor: "rgba(240, 242, 255, 1)"
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
variant: "primary",
|
|
194
|
+
appearance: "flat",
|
|
195
|
+
css: {
|
|
196
|
+
color: "rgba(66, 98, 255, 1)",
|
|
197
|
+
...focusDefault,
|
|
180
198
|
"&:hover": {
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
[activeSelector]: {
|
|
184
|
-
backgroundColor: "$background-danger-prominent-active"
|
|
185
|
-
},
|
|
186
|
-
...solidDisabled
|
|
187
|
-
},
|
|
188
|
-
"outline-danger": {
|
|
189
|
-
backgroundColor: "$background-neutrals",
|
|
190
|
-
borderColor: "$border-danger",
|
|
191
|
-
color: "$text-danger",
|
|
192
|
-
[iconSlotSelector]: {
|
|
193
|
-
color: "$icon-danger"
|
|
199
|
+
color: "rgba(69, 91, 237, 1)",
|
|
200
|
+
backgroundColor: "rgba(245, 245, 247, 1)"
|
|
194
201
|
},
|
|
202
|
+
[pressedSelector]: {
|
|
203
|
+
color: "rgba(61, 81, 212, 1)"
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
variant: "secondary",
|
|
209
|
+
appearance: "filled",
|
|
210
|
+
css: {
|
|
211
|
+
color: "rgba(5, 0, 56, 1)",
|
|
212
|
+
backgroundColor: "rgba(245, 245, 247, 1)",
|
|
213
|
+
...focusFilled,
|
|
195
214
|
"&:hover": {
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
[iconSlotSelector]: {
|
|
199
|
-
color: "$icon-danger-hover"
|
|
200
|
-
}
|
|
201
|
-
},
|
|
202
|
-
[activeSelector]: {
|
|
203
|
-
backgroundColor: "$background-danger-hover",
|
|
204
|
-
color: "$text-danger-active",
|
|
205
|
-
[iconSlotSelector]: {
|
|
206
|
-
color: "$icon-danger-active"
|
|
207
|
-
}
|
|
208
|
-
},
|
|
209
|
-
...outlineDisabled
|
|
210
|
-
},
|
|
211
|
-
"ghost-danger": {
|
|
212
|
-
backgroundColor: "transparent",
|
|
213
|
-
color: "$text-danger",
|
|
214
|
-
[iconSlotSelector]: {
|
|
215
|
-
color: "$icon-danger"
|
|
215
|
+
color: "rgba(5, 0, 56, 1)",
|
|
216
|
+
backgroundColor: "rgba(240, 240, 243, 1)"
|
|
216
217
|
},
|
|
218
|
+
[pressedSelector]: {
|
|
219
|
+
backgroundColor: "rgba(235, 235, 239, 1)"
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
variant: "secondary",
|
|
225
|
+
appearance: "outlined",
|
|
226
|
+
css: {
|
|
227
|
+
color: "rgba(5, 0, 56, 1)",
|
|
228
|
+
border: "1px solid rgba(205, 204, 215, 1)",
|
|
229
|
+
...focusOutline,
|
|
217
230
|
"&:hover": {
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
[iconSlotSelector]: {
|
|
221
|
-
color: "$icon-danger-hover"
|
|
222
|
-
}
|
|
223
|
-
},
|
|
224
|
-
[activeSelector]: {
|
|
225
|
-
backgroundColor: "$background-danger-hover",
|
|
226
|
-
color: "$text-danger-active",
|
|
227
|
-
[iconSlotSelector]: {
|
|
228
|
-
color: "$icon-danger-active"
|
|
229
|
-
}
|
|
231
|
+
color: "rgba(5, 0, 56, 1)",
|
|
232
|
+
backgroundColor: "rgba(245, 245, 247, 1)"
|
|
230
233
|
},
|
|
231
|
-
|
|
234
|
+
[pressedSelector]: {
|
|
235
|
+
backgroundColor: "rgba(235, 235, 239, 1)"
|
|
236
|
+
}
|
|
232
237
|
}
|
|
233
238
|
},
|
|
234
|
-
|
|
235
|
-
"
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
},
|
|
244
|
-
large: {
|
|
245
|
-
height: sizes.large,
|
|
246
|
-
fontSize: "$200",
|
|
247
|
-
paddingX: `calc($150 + ${LABEL_OFFSET}px)`,
|
|
248
|
-
[iconSlotSelector]: {
|
|
249
|
-
width: "$icon-300",
|
|
250
|
-
height: "$icon-300"
|
|
251
|
-
}
|
|
252
|
-
},
|
|
253
|
-
medium: {
|
|
254
|
-
height: sizes.medium,
|
|
255
|
-
fontSize: "$175",
|
|
256
|
-
paddingX: `calc($100 + ${LABEL_OFFSET}px)`,
|
|
257
|
-
[iconSlotSelector]: {
|
|
258
|
-
width: "$icon-200",
|
|
259
|
-
height: "$icon-200"
|
|
239
|
+
{
|
|
240
|
+
variant: "secondary",
|
|
241
|
+
appearance: "flat",
|
|
242
|
+
css: {
|
|
243
|
+
color: "rgba(5, 0, 56, 1)",
|
|
244
|
+
...focusDefault,
|
|
245
|
+
"&:hover": {
|
|
246
|
+
color: "rgba(5, 0, 56, 1)",
|
|
247
|
+
backgroundColor: "rgba(245, 245, 247, 1)"
|
|
260
248
|
}
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
249
|
+
}
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
variant: "danger",
|
|
253
|
+
appearance: "filled",
|
|
254
|
+
css: {
|
|
255
|
+
color: "$white",
|
|
256
|
+
backgroundColor: "rgba(217, 41, 41, 1)",
|
|
257
|
+
...focusFilled,
|
|
258
|
+
"&:hover": {
|
|
259
|
+
backgroundColor: "rgba(199, 20, 20, 1)"
|
|
260
|
+
},
|
|
261
|
+
[pressedSelector]: {
|
|
262
|
+
backgroundColor: "rgba(184, 13, 13, 1)"
|
|
269
263
|
}
|
|
270
264
|
}
|
|
271
265
|
},
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
266
|
+
{
|
|
267
|
+
variant: "danger",
|
|
268
|
+
appearance: "outlined",
|
|
269
|
+
css: {
|
|
270
|
+
color: "rgba(217, 41, 41, 1)",
|
|
271
|
+
border: "1px solid rgba(217, 41, 41, 1)",
|
|
272
|
+
...focusOutline,
|
|
273
|
+
"&:hover": {
|
|
274
|
+
color: "rgba(217, 41, 41, 1)",
|
|
275
|
+
backgroundColor: "rgba(254, 247, 247, 1)"
|
|
276
|
+
},
|
|
277
|
+
[pressedSelector]: {
|
|
278
|
+
backgroundColor: "rgba(253, 242, 242, 1)"
|
|
279
|
+
}
|
|
275
280
|
}
|
|
276
281
|
},
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
282
|
+
{
|
|
283
|
+
variant: "danger",
|
|
284
|
+
appearance: "flat",
|
|
285
|
+
css: {
|
|
286
|
+
color: "rgba(217, 41, 41, 1)",
|
|
287
|
+
...focusDefault,
|
|
288
|
+
"&:hover": {
|
|
289
|
+
color: "rgba(217, 41, 41, 1)",
|
|
290
|
+
backgroundColor: "rgba(245, 245, 247, 1)"
|
|
291
|
+
}
|
|
281
292
|
}
|
|
282
293
|
}
|
|
283
|
-
|
|
284
|
-
});
|
|
285
|
-
const StyledHiddenContent = styled(Primitive.span, {
|
|
286
|
-
visibility: "hidden"
|
|
294
|
+
]
|
|
287
295
|
});
|
|
288
296
|
const StyledSpinnerBox = styled(Primitive.div, {
|
|
289
297
|
display: "flex",
|
|
@@ -299,44 +307,84 @@ const StyledSpinnerBox = styled(Primitive.div, {
|
|
|
299
307
|
|
|
300
308
|
const Button = React.forwardRef(
|
|
301
309
|
({
|
|
302
|
-
variant = "
|
|
303
|
-
|
|
310
|
+
variant = "primary",
|
|
311
|
+
appearance = "filled",
|
|
312
|
+
size = "medium",
|
|
304
313
|
loading = false,
|
|
305
314
|
rounded = false,
|
|
306
315
|
fluid = false,
|
|
307
|
-
|
|
316
|
+
disabled = false,
|
|
317
|
+
href,
|
|
318
|
+
target,
|
|
319
|
+
rel,
|
|
308
320
|
children,
|
|
321
|
+
onPress,
|
|
322
|
+
onClick,
|
|
323
|
+
asChild,
|
|
309
324
|
...restProps
|
|
310
325
|
}, forwardRef) => {
|
|
311
|
-
let spinnerSize
|
|
312
|
-
if (typeof size === "string"
|
|
313
|
-
spinnerSize = "small";
|
|
326
|
+
let spinnerSize;
|
|
327
|
+
if (typeof size === "string") {
|
|
328
|
+
spinnerSize = ["x-small", "xx-small"].includes(size) ? "small" : "medium";
|
|
329
|
+
} else {
|
|
330
|
+
spinnerSize = "medium";
|
|
314
331
|
}
|
|
315
|
-
const
|
|
316
|
-
const
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
332
|
+
const _loading = loading === "true" || loading === true;
|
|
333
|
+
const shouldBeDisabled = disabled || _loading;
|
|
334
|
+
const asLink = href != null;
|
|
335
|
+
const ref = useRef(null);
|
|
336
|
+
const refWithFallback = forwardRef != null ? forwardRef : ref;
|
|
337
|
+
const { buttonProps, isPressed } = useButton(
|
|
338
|
+
{
|
|
339
|
+
isDisabled: shouldBeDisabled,
|
|
340
|
+
href,
|
|
341
|
+
onPress: onPress != null ? onPress : onClick,
|
|
342
|
+
allowFocusWhenDisabled: false,
|
|
343
|
+
...restProps
|
|
344
|
+
},
|
|
345
|
+
refWithFallback
|
|
346
|
+
);
|
|
347
|
+
const { linkProps } = useLink(
|
|
348
|
+
{
|
|
349
|
+
isDisabled: disabled,
|
|
350
|
+
onPress: onPress != null ? onPress : onClick,
|
|
351
|
+
...restProps
|
|
352
|
+
},
|
|
353
|
+
refWithFallback
|
|
324
354
|
);
|
|
325
|
-
const Content =
|
|
355
|
+
const Content = /* @__PURE__ */ React.createElement(React.Fragment, null, _loading && /* @__PURE__ */ React.createElement(StyledSpinnerBox, null, /* @__PURE__ */ React.createElement(Spinner, {
|
|
326
356
|
size: spinnerSize
|
|
327
|
-
})), /* @__PURE__ */ React.createElement(
|
|
357
|
+
})), /* @__PURE__ */ React.createElement("span", null, children));
|
|
358
|
+
const tabIndexProp = shouldBeDisabled && {
|
|
359
|
+
tabIndex: -1
|
|
360
|
+
};
|
|
361
|
+
const { isFocusVisible, focusProps } = useFocusRing();
|
|
362
|
+
const elementProps = mergeProps(
|
|
363
|
+
restProps,
|
|
364
|
+
asLink ? linkProps : buttonProps,
|
|
365
|
+
focusProps
|
|
366
|
+
);
|
|
328
367
|
return /* @__PURE__ */ React.createElement(StyledButton, {
|
|
329
|
-
...
|
|
368
|
+
...elementProps,
|
|
330
369
|
variant,
|
|
370
|
+
appearance,
|
|
371
|
+
size,
|
|
372
|
+
loading,
|
|
331
373
|
rounded,
|
|
332
374
|
fluid,
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
375
|
+
disabled: shouldBeDisabled,
|
|
376
|
+
asChild: asLink || asChild,
|
|
377
|
+
...tabIndexProp,
|
|
378
|
+
"data-pressed": isPressed ? "" : void 0,
|
|
379
|
+
"data-focused": isFocusVisible ? "" : void 0,
|
|
380
|
+
ref: refWithFallback
|
|
381
|
+
}, asLink ? /* @__PURE__ */ React.createElement("a", {
|
|
382
|
+
href,
|
|
383
|
+
target,
|
|
384
|
+
rel: target === "_blank" ? `noopener noreferrer ${rel}` : rel
|
|
385
|
+
}, Content) : Content);
|
|
337
386
|
}
|
|
338
387
|
);
|
|
339
|
-
Button.IconSlot = IconSlot;
|
|
340
388
|
|
|
341
389
|
export { Button };
|
|
342
390
|
//# sourceMappingURL=module.js.map
|