@react-spectrum/button 3.15.0 → 3.16.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/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, isAppleDevice as $d7FTw$isAppleDevice, isFirefox as $d7FTw$isFirefox, 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";
@@ -47,205 +47,205 @@ function $parcel$export(e, n, v, s) {
47
47
  var $94fed84ca44dbd5b$exports = {};
48
48
  var $3d5058299051dde5$exports = {};
49
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}...`
50
+ "pending": `\u{642}\u{64A}\u{62F} \u{627}\u{644}\u{627}\u{646}\u{62A}\u{638}\u{627}\u{631}`
51
51
  };
52
52
 
53
53
 
54
54
  var $b09fec806b7b8f22$exports = {};
55
55
  $b09fec806b7b8f22$exports = {
56
- "loading": `\u{417}\u{430}\u{440}\u{435}\u{436}\u{434}\u{430}\u{43D}\u{435}...`
56
+ "pending": `\u{43D}\u{435}\u{434}\u{43E}\u{432}\u{44A}\u{440}\u{448}\u{435}\u{43D}\u{43E}`
57
57
  };
58
58
 
59
59
 
60
60
  var $ca0549dfb1669363$exports = {};
61
61
  $ca0549dfb1669363$exports = {
62
- "loading": `Na\u{10D}\xedt\xe1n\xed...`
62
+ "pending": `\u{10D}ek\xe1 na vy\u{159}\xedzen\xed`
63
63
  };
64
64
 
65
65
 
66
66
  var $98f2907c0694c5b6$exports = {};
67
67
  $98f2907c0694c5b6$exports = {
68
- "loading": `Indl\xe6ser ...`
68
+ "pending": `afventende`
69
69
  };
70
70
 
71
71
 
72
72
  var $9d6fce77106482c8$exports = {};
73
73
  $9d6fce77106482c8$exports = {
74
- "loading": `Wird geladen \u{2026}`
74
+ "pending": `Ausstehend`
75
75
  };
76
76
 
77
77
 
78
78
  var $db5c63cb8d95d7a4$exports = {};
79
79
  $db5c63cb8d95d7a4$exports = {
80
- "loading": `\u{3A6}\u{3CC}\u{3C1}\u{3C4}\u{3C9}\u{3C3}\u{3B7}\u{2026}`
80
+ "pending": `\u{3C3}\u{3B5} \u{3B5}\u{3BA}\u{3BA}\u{3C1}\u{3B5}\u{3BC}\u{3CC}\u{3C4}\u{3B7}\u{3C4}\u{3B1}`
81
81
  };
82
82
 
83
83
 
84
84
  var $94e4262f3b79d866$exports = {};
85
85
  $94e4262f3b79d866$exports = {
86
- "loading": `Loading\u{2026}`
86
+ "pending": `pending`
87
87
  };
88
88
 
89
89
 
90
90
  var $16cf2bb6affc1ca9$exports = {};
91
91
  $16cf2bb6affc1ca9$exports = {
92
- "loading": `Cargando\u{2026}`
92
+ "pending": `pendiente`
93
93
  };
94
94
 
95
95
 
96
96
  var $d2a4cd1ccd3b9660$exports = {};
97
97
  $d2a4cd1ccd3b9660$exports = {
98
- "loading": `Laadimine...`
98
+ "pending": `ootel`
99
99
  };
100
100
 
101
101
 
102
102
  var $0aa3ceafb597db1b$exports = {};
103
103
  $0aa3ceafb597db1b$exports = {
104
- "loading": `Ladataan\u{2026}`
104
+ "pending": `odottaa`
105
105
  };
106
106
 
107
107
 
108
108
  var $5779b104f19b7b1a$exports = {};
109
109
  $5779b104f19b7b1a$exports = {
110
- "loading": `Chargement en cours\u{2026}`
110
+ "pending": `En attente`
111
111
  };
112
112
 
113
113
 
114
114
  var $33aba885fd306c4d$exports = {};
115
115
  $33aba885fd306c4d$exports = {
116
- "loading": `\u{5D8}\u{5D5}\u{5E2}\u{5DF}...`
116
+ "pending": `\u{5DE}\u{5DE}\u{5EA}\u{5D9}\u{5DF} \u{5DC}`
117
117
  };
118
118
 
119
119
 
120
120
  var $30a099a3f19b59af$exports = {};
121
121
  $30a099a3f19b59af$exports = {
122
- "loading": `U\u{10D}itavam...`
122
+ "pending": `u tijeku`
123
123
  };
124
124
 
125
125
 
126
126
  var $f257504b02c6b23f$exports = {};
127
127
  $f257504b02c6b23f$exports = {
128
- "loading": `Bet\xf6lt\xe9s folyamatban\u{2026}`
128
+ "pending": `f\xfcgg\u{151}ben lev\u{151}`
129
129
  };
130
130
 
131
131
 
132
132
  var $b6e12833733478ab$exports = {};
133
133
  $b6e12833733478ab$exports = {
134
- "loading": `Caricamento...`
134
+ "pending": `in sospeso`
135
135
  };
136
136
 
137
137
 
138
138
  var $e69fac8c5f9d6043$exports = {};
139
139
  $e69fac8c5f9d6043$exports = {
140
- "loading": `\u{8AAD}\u{307F}\u{8FBC}\u{307F}\u{4E2D}...`
140
+ "pending": `\u{4FDD}\u{7559}`
141
141
  };
142
142
 
143
143
 
144
144
  var $a9b740b7d23548d0$exports = {};
145
145
  $a9b740b7d23548d0$exports = {
146
- "loading": `\u{B85C}\u{B4DC} \u{C911}\u{2026}`
146
+ "pending": `\u{BCF4}\u{B958} \u{C911}`
147
147
  };
148
148
 
149
149
 
150
150
  var $4d8ca888adc67de0$exports = {};
151
151
  $4d8ca888adc67de0$exports = {
152
- "loading": `\u{12E}keliama\u{2026}`
152
+ "pending": `laukiama`
153
153
  };
154
154
 
155
155
 
156
156
  var $5d3a845adaaa328a$exports = {};
157
157
  $5d3a845adaaa328a$exports = {
158
- "loading": `Notiek iel\u{101}de\u{2026}`
158
+ "pending": `gaida`
159
159
  };
160
160
 
161
161
 
162
162
  var $20112446b2d06d6e$exports = {};
163
163
  $20112446b2d06d6e$exports = {
164
- "loading": `Laster inn ...`
164
+ "pending": `avventer`
165
165
  };
166
166
 
167
167
 
168
168
  var $168501f8ff8ad607$exports = {};
169
169
  $168501f8ff8ad607$exports = {
170
- "loading": `Laden...`
170
+ "pending": `in behandeling`
171
171
  };
172
172
 
173
173
 
174
174
  var $7d885e2935e9ed01$exports = {};
175
175
  $7d885e2935e9ed01$exports = {
176
- "loading": `Wczytywanie...`
176
+ "pending": `oczekuj\u{105}ce`
177
177
  };
178
178
 
179
179
 
180
180
  var $ece77a10c9739c65$exports = {};
181
181
  $ece77a10c9739c65$exports = {
182
- "loading": `Carregando...`
182
+ "pending": `pendente`
183
183
  };
184
184
 
185
185
 
186
186
  var $8dbae7e3487e6fc7$exports = {};
187
187
  $8dbae7e3487e6fc7$exports = {
188
- "loading": `A carregar...`
188
+ "pending": `pendente`
189
189
  };
190
190
 
191
191
 
192
192
  var $4ab371254445a3f4$exports = {};
193
193
  $4ab371254445a3f4$exports = {
194
- "loading": `Se \xeencarc\u{103}...`
194
+ "pending": `\xeen a\u{219}teptare`
195
195
  };
196
196
 
197
197
 
198
198
  var $c5ac7ec630c67dba$exports = {};
199
199
  $c5ac7ec630c67dba$exports = {
200
- "loading": `\u{417}\u{430}\u{433}\u{440}\u{443}\u{437}\u{43A}\u{430}...`
200
+ "pending": `\u{432} \u{43E}\u{436}\u{438}\u{434}\u{430}\u{43D}\u{438}\u{438}`
201
201
  };
202
202
 
203
203
 
204
204
  var $846eaea7e21f7fbf$exports = {};
205
205
  $846eaea7e21f7fbf$exports = {
206
- "loading": `Na\u{10D}\xedtava sa...`
206
+ "pending": `\u{10D}akaj\xface`
207
207
  };
208
208
 
209
209
 
210
210
  var $dde062d6acd4e43a$exports = {};
211
211
  $dde062d6acd4e43a$exports = {
212
- "loading": `Nalaganje ...`
212
+ "pending": `v teku`
213
213
  };
214
214
 
215
215
 
216
216
  var $579b7ae9c5494112$exports = {};
217
217
  $579b7ae9c5494112$exports = {
218
- "loading": `U\u{10D}itavam...`
218
+ "pending": `nere\u{161}eno`
219
219
  };
220
220
 
221
221
 
222
222
  var $3b62c0bcc6cf3c98$exports = {};
223
223
  $3b62c0bcc6cf3c98$exports = {
224
- "loading": `L\xe4ser in...`
224
+ "pending": `v\xe4ntande`
225
225
  };
226
226
 
227
227
 
228
228
  var $31f966e58b99834b$exports = {};
229
229
  $31f966e58b99834b$exports = {
230
- "loading": `Y\xfckleniyor...`
230
+ "pending": `beklemede`
231
231
  };
232
232
 
233
233
 
234
234
  var $a3d99ea5d46a3d12$exports = {};
235
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}`
236
+ "pending": `\u{432} \u{43E}\u{447}\u{456}\u{43A}\u{443}\u{432}\u{430}\u{43D}\u{43D}\u{456}`
237
237
  };
238
238
 
239
239
 
240
240
  var $6e4b63af77288b7a$exports = {};
241
241
  $6e4b63af77288b7a$exports = {
242
- "loading": `\u{6B63}\u{5728}\u{52A0}\u{8F7D}...`
242
+ "pending": `\u{5F85}\u{5904}\u{7406}`
243
243
  };
244
244
 
245
245
 
246
246
  var $be993a68bccef72a$exports = {};
247
247
  $be993a68bccef72a$exports = {
248
- "loading": `\u{8F09}\u{5165}\u{4E2D}\u{2026}`
248
+ "pending": `\u{5F85}\u{8655}\u{7406}`
249
249
  };
250
250
 
251
251
 
@@ -426,6 +426,7 @@ function $b865a6f0049e2d66$var$disablePendingProps(props) {
426
426
  return props;
427
427
  }
428
428
  function $b865a6f0049e2d66$var$Button(props, ref) {
429
+ var _buttonProps_arialabelledby;
429
430
  props = (0, $d7FTw$useProviderProps)(props);
430
431
  props = (0, $d7FTw$useSlotProps)(props, "button");
431
432
  props = $b865a6f0049e2d66$var$disablePendingProps(props);
@@ -435,11 +436,23 @@ function $b865a6f0049e2d66$var$Button(props, ref) {
435
436
  let { hoverProps: hoverProps, isHovered: isHovered } = (0, $d7FTw$useHover)({
436
437
  isDisabled: isDisabled
437
438
  });
438
- let stringFormatter = (0, $d7FTw$useLocalizedStringFormatter)((0, (/*@__PURE__*/$parcel$interopDefault($94fed84ca44dbd5b$exports))));
439
+ let [isFocused, onFocusChange] = (0, $d7FTw$useState)(false);
440
+ let { focusProps: focusProps } = (0, $d7FTw$useFocus)({
441
+ onFocusChange: onFocusChange,
442
+ isDisabled: isDisabled
443
+ });
444
+ let stringFormatter = (0, $d7FTw$useLocalizedStringFormatter)((0, (/*@__PURE__*/$parcel$interopDefault($94fed84ca44dbd5b$exports))), "@react-spectrum/button");
439
445
  let { styleProps: styleProps } = (0, $d7FTw$useStyleProps)(otherProps);
440
446
  let hasLabel = (0, $d7FTw$useHasChild)(`.${(0, (/*@__PURE__*/$parcel$interopDefault($086e93d2352a4536$exports)))["spectrum-Button-label"]}`, domRef);
441
447
  let hasIcon = (0, $d7FTw$useHasChild)(`.${(0, (/*@__PURE__*/$parcel$interopDefault($086e93d2352a4536$exports)))["spectrum-Icon"]}`, domRef);
448
+ // an aria label will block children and their labels from being read, this is undesirable for pending state
449
+ let hasAriaLabel = !!buttonProps["aria-label"] || !!buttonProps["aria-labelledby"];
442
450
  let [isProgressVisible, setIsProgressVisible] = (0, $d7FTw$useState)(false);
451
+ let backupButtonId = (0, $d7FTw$useId)();
452
+ let buttonId = buttonProps.id || backupButtonId;
453
+ let iconId = (0, $d7FTw$useId)();
454
+ let textId = (0, $d7FTw$useId)();
455
+ let spinnerId = (0, $d7FTw$useId)();
443
456
  (0, $d7FTw$useEffect)(()=>{
444
457
  let timeout;
445
458
  if (isPending) // Start timer when isPending is set to true.
@@ -460,18 +473,25 @@ function $b865a6f0049e2d66$var$Button(props, ref) {
460
473
  variant = "primary";
461
474
  staticColor = "white";
462
475
  }
476
+ const isPendingAriaLiveLabel = `${hasAriaLabel ? buttonProps["aria-label"] : ""} ${stringFormatter.format("pending")}`.trim();
477
+ var _buttonProps_arialabelledby_replace;
478
+ const isPendingAriaLiveLabelledby = hasAriaLabel ? (_buttonProps_arialabelledby_replace = (_buttonProps_arialabelledby = buttonProps["aria-labelledby"]) === null || _buttonProps_arialabelledby === void 0 ? void 0 : _buttonProps_arialabelledby.replace(buttonId, spinnerId)) !== null && _buttonProps_arialabelledby_replace !== void 0 ? _buttonProps_arialabelledby_replace : spinnerId : `${hasIcon ? iconId : ""} ${hasLabel ? textId : ""} ${spinnerId}`.trim();
479
+ let ariaLive = "polite";
480
+ if ((0, $d7FTw$isAppleDevice)() && (!hasAriaLabel || (0, $d7FTw$isFirefox)())) ariaLive = "off";
463
481
  return /*#__PURE__*/ (0, $d7FTw$react).createElement((0, $d7FTw$FocusRing), {
464
482
  focusRingClass: (0, $d7FTw$classNames)((0, (/*@__PURE__*/$parcel$interopDefault($086e93d2352a4536$exports))), "focus-ring"),
465
483
  autoFocus: autoFocus
466
484
  }, /*#__PURE__*/ (0, $d7FTw$react).createElement(Element, {
467
485
  ...styleProps,
468
- ...(0, $d7FTw$mergeProps)(buttonProps, hoverProps),
486
+ ...(0, $d7FTw$mergeProps)(buttonProps, hoverProps, focusProps),
487
+ id: buttonId,
469
488
  ref: domRef,
470
489
  "data-variant": variant,
471
490
  "data-style": style,
472
491
  "data-static-color": staticColor || undefined,
473
- "aria-disabled": isPending || undefined,
474
- "aria-live": isPending ? "polite" : undefined,
492
+ "aria-disabled": isPending ? "true" : undefined,
493
+ "aria-label": isPending ? isPendingAriaLiveLabel : buttonProps["aria-label"],
494
+ "aria-labelledby": isPending ? isPendingAriaLiveLabelledby : buttonProps["aria-labelledby"],
475
495
  className: (0, $d7FTw$classNames)((0, (/*@__PURE__*/$parcel$interopDefault($086e93d2352a4536$exports))), "spectrum-Button", {
476
496
  "spectrum-Button--iconOnly": hasIcon && !hasLabel,
477
497
  "is-disabled": isDisabled || isProgressVisible,
@@ -482,20 +502,36 @@ function $b865a6f0049e2d66$var$Button(props, ref) {
482
502
  }, /*#__PURE__*/ (0, $d7FTw$react).createElement((0, $d7FTw$SlotProvider), {
483
503
  slots: {
484
504
  icon: {
505
+ id: iconId,
485
506
  size: "S",
486
507
  UNSAFE_className: (0, $d7FTw$classNames)((0, (/*@__PURE__*/$parcel$interopDefault($086e93d2352a4536$exports))), "spectrum-Icon")
487
508
  },
488
509
  text: {
510
+ id: textId,
489
511
  UNSAFE_className: (0, $d7FTw$classNames)((0, (/*@__PURE__*/$parcel$interopDefault($086e93d2352a4536$exports))), "spectrum-Button-label")
490
512
  }
491
513
  }
492
- }, isProgressVisible && /*#__PURE__*/ (0, $d7FTw$react).createElement((0, $d7FTw$ProgressCircle), {
493
- "aria-label": stringFormatter.format("loading"),
514
+ }, typeof children === "string" ? /*#__PURE__*/ (0, $d7FTw$react).createElement((0, $d7FTw$Text), null, children) : children, isPending && /*#__PURE__*/ (0, $d7FTw$react).createElement("div", {
515
+ "aria-hidden": "true",
516
+ style: {
517
+ visibility: isProgressVisible ? "visible" : "hidden"
518
+ },
519
+ className: (0, $d7FTw$classNames)((0, (/*@__PURE__*/$parcel$interopDefault($086e93d2352a4536$exports))), "spectrum-Button-circleLoader")
520
+ }, /*#__PURE__*/ (0, $d7FTw$react).createElement((0, $d7FTw$ProgressCircle), {
521
+ "aria-label": isPendingAriaLiveLabel,
494
522
  isIndeterminate: true,
495
523
  size: "S",
496
- UNSAFE_className: (0, $d7FTw$classNames)((0, (/*@__PURE__*/$parcel$interopDefault($086e93d2352a4536$exports))), "spectrum-Button-circleLoader"),
497
524
  staticColor: staticColor
498
- }), typeof children === "string" ? /*#__PURE__*/ (0, $d7FTw$react).createElement((0, $d7FTw$Text), null, children) : children)));
525
+ })), isPending && /*#__PURE__*/ (0, $d7FTw$react).createElement((0, $d7FTw$react).Fragment, null, /*#__PURE__*/ (0, $d7FTw$react).createElement("div", {
526
+ "aria-live": isFocused ? ariaLive : "off"
527
+ }, isProgressVisible && /*#__PURE__*/ (0, $d7FTw$react).createElement("div", {
528
+ role: "img",
529
+ "aria-labelledby": isPendingAriaLiveLabelledby
530
+ })), /*#__PURE__*/ (0, $d7FTw$react).createElement("div", {
531
+ id: spinnerId,
532
+ role: "img",
533
+ "aria-label": isPendingAriaLiveLabel
534
+ })))));
499
535
  }
500
536
  /**
501
537
  * Buttons allow users to perform an action or to navigate to another page.