@react-aria/spinbutton 3.2.1 → 3.3.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.
Files changed (2) hide show
  1. package/dist/import.mjs +424 -0
  2. package/package.json +12 -7
@@ -0,0 +1,424 @@
1
+ import {announce as $glIEW$announce} from "@react-aria/live-announcer";
2
+ import {useRef as $glIEW$useRef, useEffect as $glIEW$useEffect, useCallback as $glIEW$useCallback} from "react";
3
+ import {useGlobalListeners as $glIEW$useGlobalListeners} from "@react-aria/utils";
4
+ import {useLocalizedStringFormatter as $glIEW$useLocalizedStringFormatter} from "@react-aria/i18n";
5
+
6
+ function $parcel$interopDefault(a) {
7
+ return a && a.__esModule ? a.default : a;
8
+ }
9
+ /*
10
+ * Copyright 2020 Adobe. All rights reserved.
11
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
12
+ * you may not use this file except in compliance with the License. You may obtain a copy
13
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
14
+ *
15
+ * Unless required by applicable law or agreed to in writing, software distributed under
16
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
17
+ * OF ANY KIND, either express or implied. See the License for the specific language
18
+ * governing permissions and limitations under the License.
19
+ */ /*
20
+ * Copyright 2020 Adobe. All rights reserved.
21
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
22
+ * you may not use this file except in compliance with the License. You may obtain a copy
23
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
24
+ *
25
+ * Unless required by applicable law or agreed to in writing, software distributed under
26
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
27
+ * OF ANY KIND, either express or implied. See the License for the specific language
28
+ * governing permissions and limitations under the License.
29
+ */
30
+ var $c6208a7792e31a37$exports = {};
31
+ var $ed6aae4e5f766f1e$exports = {};
32
+ $ed6aae4e5f766f1e$exports = {
33
+ "Empty": `فارغ`
34
+ };
35
+
36
+
37
+ var $38854e2b175151fa$exports = {};
38
+ $38854e2b175151fa$exports = {
39
+ "Empty": `Изпразни`
40
+ };
41
+
42
+
43
+ var $15b25ab20f3945b2$exports = {};
44
+ $15b25ab20f3945b2$exports = {
45
+ "Empty": `Prázdné`
46
+ };
47
+
48
+
49
+ var $692a4298b6b649a2$exports = {};
50
+ $692a4298b6b649a2$exports = {
51
+ "Empty": `Tom`
52
+ };
53
+
54
+
55
+ var $1c6e1539193f1243$exports = {};
56
+ $1c6e1539193f1243$exports = {
57
+ "Empty": `Leer`
58
+ };
59
+
60
+
61
+ var $1e8678632c464b6d$exports = {};
62
+ $1e8678632c464b6d$exports = {
63
+ "Empty": `Άδειο`
64
+ };
65
+
66
+
67
+ var $4adc85d9bf5b9eed$exports = {};
68
+ $4adc85d9bf5b9eed$exports = {
69
+ "Empty": `Empty`
70
+ };
71
+
72
+
73
+ var $41c4b2bb61dafbca$exports = {};
74
+ $41c4b2bb61dafbca$exports = {
75
+ "Empty": `Vacío`
76
+ };
77
+
78
+
79
+ var $405f8b24f5dd2a60$exports = {};
80
+ $405f8b24f5dd2a60$exports = {
81
+ "Empty": `Tühjenda`
82
+ };
83
+
84
+
85
+ var $7efe3ed02b9b9dd4$exports = {};
86
+ $7efe3ed02b9b9dd4$exports = {
87
+ "Empty": `Tyhjä`
88
+ };
89
+
90
+
91
+ var $99fc4c101d92daf3$exports = {};
92
+ $99fc4c101d92daf3$exports = {
93
+ "Empty": `Vide`
94
+ };
95
+
96
+
97
+ var $f9e155e6e8cacaa2$exports = {};
98
+ $f9e155e6e8cacaa2$exports = {
99
+ "Empty": `ריק`
100
+ };
101
+
102
+
103
+ var $c31b5e8e9a249fd5$exports = {};
104
+ $c31b5e8e9a249fd5$exports = {
105
+ "Empty": `Prazno`
106
+ };
107
+
108
+
109
+ var $9c5435bc17499bd9$exports = {};
110
+ $9c5435bc17499bd9$exports = {
111
+ "Empty": `Üres`
112
+ };
113
+
114
+
115
+ var $6d1fc8e84d8165e1$exports = {};
116
+ $6d1fc8e84d8165e1$exports = {
117
+ "Empty": `Vuoto`
118
+ };
119
+
120
+
121
+ var $46ea6b3641b83e71$exports = {};
122
+ $46ea6b3641b83e71$exports = {
123
+ "Empty": `空`
124
+ };
125
+
126
+
127
+ var $0e3cc9a288289dc5$exports = {};
128
+ $0e3cc9a288289dc5$exports = {
129
+ "Empty": `비어 있음`
130
+ };
131
+
132
+
133
+ var $4ff2bb25c0089ffb$exports = {};
134
+ $4ff2bb25c0089ffb$exports = {
135
+ "Empty": `Tuščias`
136
+ };
137
+
138
+
139
+ var $6cf33cd4c010a2fb$exports = {};
140
+ $6cf33cd4c010a2fb$exports = {
141
+ "Empty": `Tukšs`
142
+ };
143
+
144
+
145
+ var $5a9f8486f8b8837e$exports = {};
146
+ $5a9f8486f8b8837e$exports = {
147
+ "Empty": `Tom`
148
+ };
149
+
150
+
151
+ var $583f94d807f6ecea$exports = {};
152
+ $583f94d807f6ecea$exports = {
153
+ "Empty": `Leeg`
154
+ };
155
+
156
+
157
+ var $cc4dcfeea2b4050d$exports = {};
158
+ $cc4dcfeea2b4050d$exports = {
159
+ "Empty": `Pusty`
160
+ };
161
+
162
+
163
+ var $68ac2954d56e12b4$exports = {};
164
+ $68ac2954d56e12b4$exports = {
165
+ "Empty": `Vazio`
166
+ };
167
+
168
+
169
+ var $fdb0616f309780b0$exports = {};
170
+ $fdb0616f309780b0$exports = {
171
+ "Empty": `Vazio`
172
+ };
173
+
174
+
175
+ var $fe1eccf4ee1d6f52$exports = {};
176
+ $fe1eccf4ee1d6f52$exports = {
177
+ "Empty": `Gol`
178
+ };
179
+
180
+
181
+ var $a38b6c4e18725976$exports = {};
182
+ $a38b6c4e18725976$exports = {
183
+ "Empty": `Не заполнено`
184
+ };
185
+
186
+
187
+ var $6c14ae2b766b652c$exports = {};
188
+ $6c14ae2b766b652c$exports = {
189
+ "Empty": `Prázdne`
190
+ };
191
+
192
+
193
+ var $8f1c9692e16dc5eb$exports = {};
194
+ $8f1c9692e16dc5eb$exports = {
195
+ "Empty": `Prazen`
196
+ };
197
+
198
+
199
+ var $d2aa7abea627cafa$exports = {};
200
+ $d2aa7abea627cafa$exports = {
201
+ "Empty": `Prazno`
202
+ };
203
+
204
+
205
+ var $676b82e4b56408e6$exports = {};
206
+ $676b82e4b56408e6$exports = {
207
+ "Empty": `Tomt`
208
+ };
209
+
210
+
211
+ var $14c9042552d7ce08$exports = {};
212
+ $14c9042552d7ce08$exports = {
213
+ "Empty": `Boş`
214
+ };
215
+
216
+
217
+ var $393254ebcb66c9f5$exports = {};
218
+ $393254ebcb66c9f5$exports = {
219
+ "Empty": `Пусто`
220
+ };
221
+
222
+
223
+ var $d49d621f310cf6ce$exports = {};
224
+ $d49d621f310cf6ce$exports = {
225
+ "Empty": `空`
226
+ };
227
+
228
+
229
+ var $94b60c866ca5dfe6$exports = {};
230
+ $94b60c866ca5dfe6$exports = {
231
+ "Empty": `空白`
232
+ };
233
+
234
+
235
+ $c6208a7792e31a37$exports = {
236
+ "ar-AE": $ed6aae4e5f766f1e$exports,
237
+ "bg-BG": $38854e2b175151fa$exports,
238
+ "cs-CZ": $15b25ab20f3945b2$exports,
239
+ "da-DK": $692a4298b6b649a2$exports,
240
+ "de-DE": $1c6e1539193f1243$exports,
241
+ "el-GR": $1e8678632c464b6d$exports,
242
+ "en-US": $4adc85d9bf5b9eed$exports,
243
+ "es-ES": $41c4b2bb61dafbca$exports,
244
+ "et-EE": $405f8b24f5dd2a60$exports,
245
+ "fi-FI": $7efe3ed02b9b9dd4$exports,
246
+ "fr-FR": $99fc4c101d92daf3$exports,
247
+ "he-IL": $f9e155e6e8cacaa2$exports,
248
+ "hr-HR": $c31b5e8e9a249fd5$exports,
249
+ "hu-HU": $9c5435bc17499bd9$exports,
250
+ "it-IT": $6d1fc8e84d8165e1$exports,
251
+ "ja-JP": $46ea6b3641b83e71$exports,
252
+ "ko-KR": $0e3cc9a288289dc5$exports,
253
+ "lt-LT": $4ff2bb25c0089ffb$exports,
254
+ "lv-LV": $6cf33cd4c010a2fb$exports,
255
+ "nb-NO": $5a9f8486f8b8837e$exports,
256
+ "nl-NL": $583f94d807f6ecea$exports,
257
+ "pl-PL": $cc4dcfeea2b4050d$exports,
258
+ "pt-BR": $68ac2954d56e12b4$exports,
259
+ "pt-PT": $fdb0616f309780b0$exports,
260
+ "ro-RO": $fe1eccf4ee1d6f52$exports,
261
+ "ru-RU": $a38b6c4e18725976$exports,
262
+ "sk-SK": $6c14ae2b766b652c$exports,
263
+ "sl-SI": $8f1c9692e16dc5eb$exports,
264
+ "sr-SP": $d2aa7abea627cafa$exports,
265
+ "sv-SE": $676b82e4b56408e6$exports,
266
+ "tr-TR": $14c9042552d7ce08$exports,
267
+ "uk-UA": $393254ebcb66c9f5$exports,
268
+ "zh-CN": $d49d621f310cf6ce$exports,
269
+ "zh-TW": $94b60c866ca5dfe6$exports
270
+ };
271
+
272
+
273
+
274
+
275
+
276
+ function $d2e8511e6f209edf$export$e908e06f4b8e3402(props) {
277
+ const _async = (0, $glIEW$useRef)();
278
+ let { value: value , textValue: textValue , minValue: minValue , maxValue: maxValue , isDisabled: isDisabled , isReadOnly: isReadOnly , isRequired: isRequired , onIncrement: onIncrement , onIncrementPage: onIncrementPage , onDecrement: onDecrement , onDecrementPage: onDecrementPage , onDecrementToMin: onDecrementToMin , onIncrementToMax: onIncrementToMax } = props;
279
+ const stringFormatter = (0, $glIEW$useLocalizedStringFormatter)((0, (/*@__PURE__*/$parcel$interopDefault($c6208a7792e31a37$exports))));
280
+ const propsRef = (0, $glIEW$useRef)(props);
281
+ propsRef.current = props;
282
+ const clearAsync = ()=>clearTimeout(_async.current);
283
+ // eslint-disable-next-line arrow-body-style
284
+ (0, $glIEW$useEffect)(()=>{
285
+ return ()=>clearAsync();
286
+ }, []);
287
+ let onKeyDown = (e)=>{
288
+ if (e.ctrlKey || e.metaKey || e.shiftKey || e.altKey || isReadOnly) return;
289
+ switch(e.key){
290
+ case "PageUp":
291
+ if (onIncrementPage) {
292
+ e.preventDefault();
293
+ onIncrementPage();
294
+ break;
295
+ }
296
+ // fallthrough!
297
+ case "ArrowUp":
298
+ case "Up":
299
+ if (onIncrement) {
300
+ e.preventDefault();
301
+ onIncrement();
302
+ }
303
+ break;
304
+ case "PageDown":
305
+ if (onDecrementPage) {
306
+ e.preventDefault();
307
+ onDecrementPage();
308
+ break;
309
+ }
310
+ // fallthrough
311
+ case "ArrowDown":
312
+ case "Down":
313
+ if (onDecrement) {
314
+ e.preventDefault();
315
+ onDecrement();
316
+ }
317
+ break;
318
+ case "Home":
319
+ if (onDecrementToMin) {
320
+ e.preventDefault();
321
+ onDecrementToMin();
322
+ }
323
+ break;
324
+ case "End":
325
+ if (onIncrementToMax) {
326
+ e.preventDefault();
327
+ onIncrementToMax();
328
+ }
329
+ break;
330
+ }
331
+ };
332
+ let isFocused = (0, $glIEW$useRef)(false);
333
+ let onFocus = ()=>{
334
+ isFocused.current = true;
335
+ };
336
+ let onBlur = ()=>{
337
+ isFocused.current = false;
338
+ };
339
+ // Replace Unicode hyphen-minus (U+002D) with minus sign (U+2212).
340
+ // This ensures that macOS VoiceOver announces it as "minus" even with other characters between the minus sign
341
+ // and the number (e.g. currency symbol). Otherwise it announces nothing because it assumes the character is a hyphen.
342
+ // In addition, replace the empty string with the word "Empty" so that iOS VoiceOver does not read "50%" for an empty field.
343
+ textValue = textValue === "" ? stringFormatter.format("Empty") : (textValue || `${value}`).replace("-", "−");
344
+ (0, $glIEW$useEffect)(()=>{
345
+ if (isFocused.current) (0, $glIEW$announce)(textValue, "assertive");
346
+ }, [
347
+ textValue
348
+ ]);
349
+ const onIncrementPressStart = (0, $glIEW$useCallback)((initialStepDelay)=>{
350
+ clearAsync();
351
+ propsRef.current.onIncrement();
352
+ // Start spinning after initial delay
353
+ _async.current = window.setTimeout(()=>{
354
+ if (isNaN(maxValue) || isNaN(value) || value < maxValue) onIncrementPressStart(60);
355
+ }, initialStepDelay);
356
+ }, // eslint-disable-next-line react-hooks/exhaustive-deps
357
+ [
358
+ onIncrement,
359
+ maxValue,
360
+ value
361
+ ]);
362
+ const onDecrementPressStart = (0, $glIEW$useCallback)((initialStepDelay)=>{
363
+ clearAsync();
364
+ propsRef.current.onDecrement();
365
+ // Start spinning after initial delay
366
+ _async.current = window.setTimeout(()=>{
367
+ if (isNaN(minValue) || isNaN(value) || value > minValue) onDecrementPressStart(60);
368
+ }, initialStepDelay);
369
+ }, // eslint-disable-next-line react-hooks/exhaustive-deps
370
+ [
371
+ onDecrement,
372
+ minValue,
373
+ value
374
+ ]);
375
+ let cancelContextMenu = (e)=>{
376
+ e.preventDefault();
377
+ };
378
+ let { addGlobalListener: addGlobalListener , removeAllGlobalListeners: removeAllGlobalListeners } = (0, $glIEW$useGlobalListeners)();
379
+ return {
380
+ spinButtonProps: {
381
+ role: "spinbutton",
382
+ "aria-valuenow": !isNaN(value) ? value : null,
383
+ "aria-valuetext": textValue,
384
+ "aria-valuemin": minValue,
385
+ "aria-valuemax": maxValue,
386
+ "aria-disabled": isDisabled || null,
387
+ "aria-readonly": isReadOnly || null,
388
+ "aria-required": isRequired || null,
389
+ onKeyDown: onKeyDown,
390
+ onFocus: onFocus,
391
+ onBlur: onBlur
392
+ },
393
+ incrementButtonProps: {
394
+ onPressStart: ()=>{
395
+ onIncrementPressStart(400);
396
+ addGlobalListener(window, "contextmenu", cancelContextMenu);
397
+ },
398
+ onPressEnd: ()=>{
399
+ clearAsync();
400
+ removeAllGlobalListeners();
401
+ },
402
+ onFocus: onFocus,
403
+ onBlur: onBlur
404
+ },
405
+ decrementButtonProps: {
406
+ onPressStart: ()=>{
407
+ onDecrementPressStart(400);
408
+ addGlobalListener(window, "contextmenu", cancelContextMenu);
409
+ },
410
+ onPressEnd: ()=>{
411
+ clearAsync();
412
+ removeAllGlobalListeners();
413
+ },
414
+ onFocus: onFocus,
415
+ onBlur: onBlur
416
+ }
417
+ };
418
+ }
419
+
420
+
421
+
422
+
423
+ export {$d2e8511e6f209edf$export$e908e06f4b8e3402 as useSpinButton};
424
+ //# sourceMappingURL=module.js.map
package/package.json CHANGED
@@ -1,10 +1,15 @@
1
1
  {
2
2
  "name": "@react-aria/spinbutton",
3
- "version": "3.2.1",
3
+ "version": "3.3.0",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/main.js",
7
7
  "module": "dist/module.js",
8
+ "exports": {
9
+ "types": "./dist/types.d.ts",
10
+ "import": "./dist/import.mjs",
11
+ "require": "./dist/main.js"
12
+ },
8
13
  "types": "dist/types.d.ts",
9
14
  "source": "src/index.ts",
10
15
  "files": [
@@ -17,11 +22,11 @@
17
22
  "url": "https://github.com/adobe/react-spectrum"
18
23
  },
19
24
  "dependencies": {
20
- "@react-aria/i18n": "^3.6.3",
21
- "@react-aria/live-announcer": "^3.1.2",
22
- "@react-aria/utils": "^3.14.2",
23
- "@react-types/button": "^3.7.0",
24
- "@react-types/shared": "^3.16.0",
25
+ "@react-aria/i18n": "^3.7.0",
26
+ "@react-aria/live-announcer": "^3.2.0",
27
+ "@react-aria/utils": "^3.15.0",
28
+ "@react-types/button": "^3.7.1",
29
+ "@react-types/shared": "^3.17.0",
25
30
  "@swc/helpers": "^0.4.14"
26
31
  },
27
32
  "peerDependencies": {
@@ -31,5 +36,5 @@
31
36
  "publishConfig": {
32
37
  "access": "public"
33
38
  },
34
- "gitHead": "5480d76bd815e239366f92852c76b6831ad2a4fd"
39
+ "gitHead": "a0efee84aa178cb1a202951dfd6d8de02b292307"
35
40
  }