@react-spectrum/button 3.0.0-nightly.2597 → 3.0.0-nightly.2602
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/import.mjs +44 -244
- package/dist/main.css +1 -1
- package/dist/main.js +42 -242
- package/dist/main.js.map +1 -1
- package/dist/module.js +44 -244
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +16 -16
- package/src/Button.tsx +40 -11
package/dist/import.mjs
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
import "./main.css";
|
2
2
|
import {useSlotProps as $d7FTw$useSlotProps, useFocusableRef as $d7FTw$useFocusableRef, useStyleProps as $d7FTw$useStyleProps, useHasChild as $d7FTw$useHasChild, classNames as $d7FTw$classNames, SlotProvider as $d7FTw$SlotProvider} from "@react-spectrum/utils";
|
3
3
|
import {FocusRing as $d7FTw$FocusRing} from "@react-aria/focus";
|
4
|
-
import {mergeProps as $d7FTw$mergeProps} from "@react-aria/utils";
|
4
|
+
import {useId as $d7FTw$useId, mergeProps as $d7FTw$mergeProps} from "@react-aria/utils";
|
5
5
|
import {ProgressCircle as $d7FTw$ProgressCircle} from "@react-spectrum/progress";
|
6
6
|
import $d7FTw$react, {useState as $d7FTw$useState, useEffect as $d7FTw$useEffect} from "react";
|
7
7
|
import {Text as $d7FTw$Text} from "@react-spectrum/text";
|
8
8
|
import {useButton as $d7FTw$useButton, useToggleButton as $d7FTw$useToggleButton} from "@react-aria/button";
|
9
|
-
import {useHover as $d7FTw$useHover} from "@react-aria/interactions";
|
9
|
+
import {useHover as $d7FTw$useHover, useFocus as $d7FTw$useFocus} from "@react-aria/interactions";
|
10
10
|
import {useLocalizedStringFormatter as $d7FTw$useLocalizedStringFormatter} from "@react-aria/i18n";
|
11
11
|
import {useProviderProps as $d7FTw$useProviderProps} from "@react-spectrum/provider";
|
12
12
|
import $d7FTw$spectrumiconsuiCornerTriangle from "@spectrum-icons/ui/CornerTriangle";
|
@@ -44,246 +44,15 @@ function $parcel$export(e, n, v, s) {
|
|
44
44
|
* governing permissions and limitations under the License.
|
45
45
|
*/
|
46
46
|
|
47
|
-
var $
|
48
|
-
var $3d5058299051dde5$exports = {};
|
49
|
-
$3d5058299051dde5$exports = {
|
50
|
-
"loading": `\u{62C}\u{627}\u{631}\u{64D} \u{627}\u{644}\u{62A}\u{62D}\u{645}\u{64A}\u{644}...`
|
51
|
-
};
|
52
|
-
|
53
|
-
|
54
|
-
var $b09fec806b7b8f22$exports = {};
|
55
|
-
$b09fec806b7b8f22$exports = {
|
56
|
-
"loading": `\u{417}\u{430}\u{440}\u{435}\u{436}\u{434}\u{430}\u{43D}\u{435}...`
|
57
|
-
};
|
58
|
-
|
59
|
-
|
60
|
-
var $ca0549dfb1669363$exports = {};
|
61
|
-
$ca0549dfb1669363$exports = {
|
62
|
-
"loading": `Na\u{10D}\xedt\xe1n\xed...`
|
63
|
-
};
|
64
|
-
|
65
|
-
|
66
|
-
var $98f2907c0694c5b6$exports = {};
|
67
|
-
$98f2907c0694c5b6$exports = {
|
68
|
-
"loading": `Indl\xe6ser ...`
|
69
|
-
};
|
70
|
-
|
71
|
-
|
72
|
-
var $9d6fce77106482c8$exports = {};
|
73
|
-
$9d6fce77106482c8$exports = {
|
74
|
-
"loading": `Wird geladen \u{2026}`
|
75
|
-
};
|
76
|
-
|
77
|
-
|
78
|
-
var $db5c63cb8d95d7a4$exports = {};
|
79
|
-
$db5c63cb8d95d7a4$exports = {
|
80
|
-
"loading": `\u{3A6}\u{3CC}\u{3C1}\u{3C4}\u{3C9}\u{3C3}\u{3B7}\u{2026}`
|
81
|
-
};
|
82
|
-
|
83
|
-
|
47
|
+
var $8cc8e92eff102fe0$exports = {};
|
84
48
|
var $94e4262f3b79d866$exports = {};
|
85
49
|
$94e4262f3b79d866$exports = {
|
86
|
-
"
|
87
|
-
};
|
88
|
-
|
89
|
-
|
90
|
-
var $16cf2bb6affc1ca9$exports = {};
|
91
|
-
$16cf2bb6affc1ca9$exports = {
|
92
|
-
"loading": `Cargando\u{2026}`
|
93
|
-
};
|
94
|
-
|
95
|
-
|
96
|
-
var $d2a4cd1ccd3b9660$exports = {};
|
97
|
-
$d2a4cd1ccd3b9660$exports = {
|
98
|
-
"loading": `Laadimine...`
|
99
|
-
};
|
100
|
-
|
101
|
-
|
102
|
-
var $0aa3ceafb597db1b$exports = {};
|
103
|
-
$0aa3ceafb597db1b$exports = {
|
104
|
-
"loading": `Ladataan\u{2026}`
|
105
|
-
};
|
106
|
-
|
107
|
-
|
108
|
-
var $5779b104f19b7b1a$exports = {};
|
109
|
-
$5779b104f19b7b1a$exports = {
|
110
|
-
"loading": `Chargement en cours\u{2026}`
|
111
|
-
};
|
112
|
-
|
113
|
-
|
114
|
-
var $33aba885fd306c4d$exports = {};
|
115
|
-
$33aba885fd306c4d$exports = {
|
116
|
-
"loading": `\u{5D8}\u{5D5}\u{5E2}\u{5DF}...`
|
117
|
-
};
|
118
|
-
|
119
|
-
|
120
|
-
var $30a099a3f19b59af$exports = {};
|
121
|
-
$30a099a3f19b59af$exports = {
|
122
|
-
"loading": `U\u{10D}itavam...`
|
123
|
-
};
|
124
|
-
|
125
|
-
|
126
|
-
var $f257504b02c6b23f$exports = {};
|
127
|
-
$f257504b02c6b23f$exports = {
|
128
|
-
"loading": `Bet\xf6lt\xe9s folyamatban\u{2026}`
|
129
|
-
};
|
130
|
-
|
131
|
-
|
132
|
-
var $b6e12833733478ab$exports = {};
|
133
|
-
$b6e12833733478ab$exports = {
|
134
|
-
"loading": `Caricamento...`
|
135
|
-
};
|
136
|
-
|
137
|
-
|
138
|
-
var $e69fac8c5f9d6043$exports = {};
|
139
|
-
$e69fac8c5f9d6043$exports = {
|
140
|
-
"loading": `\u{8AAD}\u{307F}\u{8FBC}\u{307F}\u{4E2D}...`
|
141
|
-
};
|
142
|
-
|
143
|
-
|
144
|
-
var $a9b740b7d23548d0$exports = {};
|
145
|
-
$a9b740b7d23548d0$exports = {
|
146
|
-
"loading": `\u{B85C}\u{B4DC} \u{C911}\u{2026}`
|
147
|
-
};
|
148
|
-
|
149
|
-
|
150
|
-
var $4d8ca888adc67de0$exports = {};
|
151
|
-
$4d8ca888adc67de0$exports = {
|
152
|
-
"loading": `\u{12E}keliama\u{2026}`
|
50
|
+
"pending": `pending`
|
153
51
|
};
|
154
52
|
|
155
53
|
|
156
|
-
|
157
|
-
$
|
158
|
-
"loading": `Notiek iel\u{101}de\u{2026}`
|
159
|
-
};
|
160
|
-
|
161
|
-
|
162
|
-
var $20112446b2d06d6e$exports = {};
|
163
|
-
$20112446b2d06d6e$exports = {
|
164
|
-
"loading": `Laster inn ...`
|
165
|
-
};
|
166
|
-
|
167
|
-
|
168
|
-
var $168501f8ff8ad607$exports = {};
|
169
|
-
$168501f8ff8ad607$exports = {
|
170
|
-
"loading": `Laden...`
|
171
|
-
};
|
172
|
-
|
173
|
-
|
174
|
-
var $7d885e2935e9ed01$exports = {};
|
175
|
-
$7d885e2935e9ed01$exports = {
|
176
|
-
"loading": `Wczytywanie...`
|
177
|
-
};
|
178
|
-
|
179
|
-
|
180
|
-
var $ece77a10c9739c65$exports = {};
|
181
|
-
$ece77a10c9739c65$exports = {
|
182
|
-
"loading": `Carregando...`
|
183
|
-
};
|
184
|
-
|
185
|
-
|
186
|
-
var $8dbae7e3487e6fc7$exports = {};
|
187
|
-
$8dbae7e3487e6fc7$exports = {
|
188
|
-
"loading": `A carregar...`
|
189
|
-
};
|
190
|
-
|
191
|
-
|
192
|
-
var $4ab371254445a3f4$exports = {};
|
193
|
-
$4ab371254445a3f4$exports = {
|
194
|
-
"loading": `Se \xeencarc\u{103}...`
|
195
|
-
};
|
196
|
-
|
197
|
-
|
198
|
-
var $c5ac7ec630c67dba$exports = {};
|
199
|
-
$c5ac7ec630c67dba$exports = {
|
200
|
-
"loading": `\u{417}\u{430}\u{433}\u{440}\u{443}\u{437}\u{43A}\u{430}...`
|
201
|
-
};
|
202
|
-
|
203
|
-
|
204
|
-
var $846eaea7e21f7fbf$exports = {};
|
205
|
-
$846eaea7e21f7fbf$exports = {
|
206
|
-
"loading": `Na\u{10D}\xedtava sa...`
|
207
|
-
};
|
208
|
-
|
209
|
-
|
210
|
-
var $dde062d6acd4e43a$exports = {};
|
211
|
-
$dde062d6acd4e43a$exports = {
|
212
|
-
"loading": `Nalaganje ...`
|
213
|
-
};
|
214
|
-
|
215
|
-
|
216
|
-
var $579b7ae9c5494112$exports = {};
|
217
|
-
$579b7ae9c5494112$exports = {
|
218
|
-
"loading": `U\u{10D}itavam...`
|
219
|
-
};
|
220
|
-
|
221
|
-
|
222
|
-
var $3b62c0bcc6cf3c98$exports = {};
|
223
|
-
$3b62c0bcc6cf3c98$exports = {
|
224
|
-
"loading": `L\xe4ser in...`
|
225
|
-
};
|
226
|
-
|
227
|
-
|
228
|
-
var $31f966e58b99834b$exports = {};
|
229
|
-
$31f966e58b99834b$exports = {
|
230
|
-
"loading": `Y\xfckleniyor...`
|
231
|
-
};
|
232
|
-
|
233
|
-
|
234
|
-
var $a3d99ea5d46a3d12$exports = {};
|
235
|
-
$a3d99ea5d46a3d12$exports = {
|
236
|
-
"loading": `\u{417}\u{430}\u{432}\u{430}\u{43D}\u{442}\u{430}\u{436}\u{435}\u{43D}\u{43D}\u{44F}\u{2026}`
|
237
|
-
};
|
238
|
-
|
239
|
-
|
240
|
-
var $6e4b63af77288b7a$exports = {};
|
241
|
-
$6e4b63af77288b7a$exports = {
|
242
|
-
"loading": `\u{6B63}\u{5728}\u{52A0}\u{8F7D}...`
|
243
|
-
};
|
244
|
-
|
245
|
-
|
246
|
-
var $be993a68bccef72a$exports = {};
|
247
|
-
$be993a68bccef72a$exports = {
|
248
|
-
"loading": `\u{8F09}\u{5165}\u{4E2D}\u{2026}`
|
249
|
-
};
|
250
|
-
|
251
|
-
|
252
|
-
$94fed84ca44dbd5b$exports = {
|
253
|
-
"ar-AE": $3d5058299051dde5$exports,
|
254
|
-
"bg-BG": $b09fec806b7b8f22$exports,
|
255
|
-
"cs-CZ": $ca0549dfb1669363$exports,
|
256
|
-
"da-DK": $98f2907c0694c5b6$exports,
|
257
|
-
"de-DE": $9d6fce77106482c8$exports,
|
258
|
-
"el-GR": $db5c63cb8d95d7a4$exports,
|
259
|
-
"en-US": $94e4262f3b79d866$exports,
|
260
|
-
"es-ES": $16cf2bb6affc1ca9$exports,
|
261
|
-
"et-EE": $d2a4cd1ccd3b9660$exports,
|
262
|
-
"fi-FI": $0aa3ceafb597db1b$exports,
|
263
|
-
"fr-FR": $5779b104f19b7b1a$exports,
|
264
|
-
"he-IL": $33aba885fd306c4d$exports,
|
265
|
-
"hr-HR": $30a099a3f19b59af$exports,
|
266
|
-
"hu-HU": $f257504b02c6b23f$exports,
|
267
|
-
"it-IT": $b6e12833733478ab$exports,
|
268
|
-
"ja-JP": $e69fac8c5f9d6043$exports,
|
269
|
-
"ko-KR": $a9b740b7d23548d0$exports,
|
270
|
-
"lt-LT": $4d8ca888adc67de0$exports,
|
271
|
-
"lv-LV": $5d3a845adaaa328a$exports,
|
272
|
-
"nb-NO": $20112446b2d06d6e$exports,
|
273
|
-
"nl-NL": $168501f8ff8ad607$exports,
|
274
|
-
"pl-PL": $7d885e2935e9ed01$exports,
|
275
|
-
"pt-BR": $ece77a10c9739c65$exports,
|
276
|
-
"pt-PT": $8dbae7e3487e6fc7$exports,
|
277
|
-
"ro-RO": $4ab371254445a3f4$exports,
|
278
|
-
"ru-RU": $c5ac7ec630c67dba$exports,
|
279
|
-
"sk-SK": $846eaea7e21f7fbf$exports,
|
280
|
-
"sl-SI": $dde062d6acd4e43a$exports,
|
281
|
-
"sr-SP": $579b7ae9c5494112$exports,
|
282
|
-
"sv-SE": $3b62c0bcc6cf3c98$exports,
|
283
|
-
"tr-TR": $31f966e58b99834b$exports,
|
284
|
-
"uk-UA": $a3d99ea5d46a3d12$exports,
|
285
|
-
"zh-CN": $6e4b63af77288b7a$exports,
|
286
|
-
"zh-TW": $be993a68bccef72a$exports
|
54
|
+
$8cc8e92eff102fe0$exports = {
|
55
|
+
"en-US": $94e4262f3b79d866$exports
|
287
56
|
};
|
288
57
|
|
289
58
|
|
@@ -426,6 +195,7 @@ function $b865a6f0049e2d66$var$disablePendingProps(props) {
|
|
426
195
|
return props;
|
427
196
|
}
|
428
197
|
function $b865a6f0049e2d66$var$Button(props, ref) {
|
198
|
+
var _buttonProps_arialabelledby;
|
429
199
|
props = (0, $d7FTw$useProviderProps)(props);
|
430
200
|
props = (0, $d7FTw$useSlotProps)(props, "button");
|
431
201
|
props = $b865a6f0049e2d66$var$disablePendingProps(props);
|
@@ -435,11 +205,24 @@ function $b865a6f0049e2d66$var$Button(props, ref) {
|
|
435
205
|
let { hoverProps: hoverProps, isHovered: isHovered } = (0, $d7FTw$useHover)({
|
436
206
|
isDisabled: isDisabled
|
437
207
|
});
|
438
|
-
let
|
208
|
+
let [isFocused, onFocusChange] = (0, $d7FTw$useState)(false);
|
209
|
+
let { focusProps: focusProps } = (0, $d7FTw$useFocus)({
|
210
|
+
onFocusChange: onFocusChange,
|
211
|
+
isDisabled: isDisabled
|
212
|
+
});
|
213
|
+
let stringFormatter = (0, $d7FTw$useLocalizedStringFormatter)((0, (/*@__PURE__*/$parcel$interopDefault($8cc8e92eff102fe0$exports))));
|
439
214
|
let { styleProps: styleProps } = (0, $d7FTw$useStyleProps)(otherProps);
|
440
215
|
let hasLabel = (0, $d7FTw$useHasChild)(`.${(0, (/*@__PURE__*/$parcel$interopDefault($086e93d2352a4536$exports)))["spectrum-Button-label"]}`, domRef);
|
441
216
|
let hasIcon = (0, $d7FTw$useHasChild)(`.${(0, (/*@__PURE__*/$parcel$interopDefault($086e93d2352a4536$exports)))["spectrum-Icon"]}`, domRef);
|
217
|
+
// an aria label will block children and their labels from being read, this is undesirable for pending state
|
218
|
+
let hasAriaLabel = !!buttonProps["aria-label"] || !!buttonProps["aria-labelledby"];
|
442
219
|
let [isProgressVisible, setIsProgressVisible] = (0, $d7FTw$useState)(false);
|
220
|
+
let backupButtonId = (0, $d7FTw$useId)();
|
221
|
+
let buttonId = buttonProps.id || backupButtonId;
|
222
|
+
let spinnerId = (0, $d7FTw$useId)();
|
223
|
+
let textId = (0, $d7FTw$useId)();
|
224
|
+
let iconId = (0, $d7FTw$useId)();
|
225
|
+
let auxLabelId = (0, $d7FTw$useId)();
|
443
226
|
(0, $d7FTw$useEffect)(()=>{
|
444
227
|
let timeout;
|
445
228
|
if (isPending) // Start timer when isPending is set to true.
|
@@ -465,13 +248,16 @@ function $b865a6f0049e2d66$var$Button(props, ref) {
|
|
465
248
|
autoFocus: autoFocus
|
466
249
|
}, /*#__PURE__*/ (0, $d7FTw$react).createElement(Element, {
|
467
250
|
...styleProps,
|
468
|
-
...(0, $d7FTw$mergeProps)(buttonProps, hoverProps),
|
251
|
+
...(0, $d7FTw$mergeProps)(buttonProps, hoverProps, focusProps),
|
252
|
+
id: buttonId,
|
469
253
|
ref: domRef,
|
470
254
|
"data-variant": variant,
|
471
255
|
"data-style": style,
|
472
256
|
"data-static-color": staticColor || undefined,
|
473
|
-
"aria-disabled": isPending
|
474
|
-
"aria-
|
257
|
+
"aria-disabled": isPending ? "true" : undefined,
|
258
|
+
"aria-label": isPending ? undefined : buttonProps["aria-label"],
|
259
|
+
"aria-labelledby": isPending ? undefined : buttonProps["aria-labelledby"],
|
260
|
+
"aria-live": isPending && isFocused ? "polite" : undefined,
|
475
261
|
className: (0, $d7FTw$classNames)((0, (/*@__PURE__*/$parcel$interopDefault($086e93d2352a4536$exports))), "spectrum-Button", {
|
476
262
|
"spectrum-Button--iconOnly": hasIcon && !hasLabel,
|
477
263
|
"is-disabled": isDisabled || isProgressVisible,
|
@@ -482,20 +268,34 @@ function $b865a6f0049e2d66$var$Button(props, ref) {
|
|
482
268
|
}, /*#__PURE__*/ (0, $d7FTw$react).createElement((0, $d7FTw$SlotProvider), {
|
483
269
|
slots: {
|
484
270
|
icon: {
|
271
|
+
id: iconId,
|
485
272
|
size: "S",
|
486
273
|
UNSAFE_className: (0, $d7FTw$classNames)((0, (/*@__PURE__*/$parcel$interopDefault($086e93d2352a4536$exports))), "spectrum-Icon")
|
487
274
|
},
|
488
275
|
text: {
|
276
|
+
id: textId,
|
489
277
|
UNSAFE_className: (0, $d7FTw$classNames)((0, (/*@__PURE__*/$parcel$interopDefault($086e93d2352a4536$exports))), "spectrum-Button-label")
|
490
278
|
}
|
491
279
|
}
|
492
|
-
},
|
493
|
-
"aria-
|
280
|
+
}, typeof children === "string" ? /*#__PURE__*/ (0, $d7FTw$react).createElement((0, $d7FTw$Text), null, children) : children, isPending && /*#__PURE__*/ (0, $d7FTw$react).createElement((0, $d7FTw$ProgressCircle), {
|
281
|
+
"aria-hidden": "true",
|
494
282
|
isIndeterminate: true,
|
495
283
|
size: "S",
|
496
284
|
UNSAFE_className: (0, $d7FTw$classNames)((0, (/*@__PURE__*/$parcel$interopDefault($086e93d2352a4536$exports))), "spectrum-Button-circleLoader"),
|
285
|
+
UNSAFE_style: {
|
286
|
+
visibility: isProgressVisible ? "visible" : "hidden"
|
287
|
+
},
|
497
288
|
staticColor: staticColor
|
498
|
-
}),
|
289
|
+
}), isPending && hasAriaLabel && /*#__PURE__*/ (0, $d7FTw$react).createElement("div", {
|
290
|
+
"aria-hidden": "true",
|
291
|
+
id: auxLabelId,
|
292
|
+
"aria-label": buttonProps["aria-label"],
|
293
|
+
"aria-labelledby": (_buttonProps_arialabelledby = buttonProps["aria-labelledby"]) === null || _buttonProps_arialabelledby === void 0 ? void 0 : _buttonProps_arialabelledby.replace(buttonId, auxLabelId)
|
294
|
+
}), isPending && /*#__PURE__*/ (0, $d7FTw$react).createElement("div", {
|
295
|
+
id: spinnerId,
|
296
|
+
"aria-label": stringFormatter.format("pending"),
|
297
|
+
"aria-labelledby": `${hasAriaLabel ? "" : iconId} ${hasAriaLabel ? auxLabelId : textId} ${spinnerId}`
|
298
|
+
}))));
|
499
299
|
}
|
500
300
|
/**
|
501
301
|
* Buttons allow users to perform an action or to navigate to another page.
|