@react-aria/spinbutton 3.6.4 → 3.6.6
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/ar-AE.mjs +1 -1
- package/dist/bg-BG.mjs +1 -1
- package/dist/cs-CZ.mjs +1 -1
- package/dist/da-DK.mjs +1 -1
- package/dist/de-DE.mjs +1 -1
- package/dist/el-GR.mjs +1 -1
- package/dist/en-US.mjs +1 -1
- package/dist/es-ES.mjs +1 -1
- package/dist/et-EE.mjs +1 -1
- package/dist/fi-FI.mjs +1 -1
- package/dist/fr-FR.mjs +1 -1
- package/dist/he-IL.mjs +1 -1
- package/dist/hr-HR.mjs +1 -1
- package/dist/hu-HU.mjs +1 -1
- package/dist/intlStrings.mjs +1 -1
- package/dist/it-IT.mjs +1 -1
- package/dist/ja-JP.mjs +1 -1
- package/dist/ko-KR.mjs +1 -1
- package/dist/lt-LT.mjs +1 -1
- package/dist/lv-LV.mjs +1 -1
- package/dist/nb-NO.mjs +1 -1
- package/dist/nl-NL.mjs +1 -1
- package/dist/pl-PL.mjs +1 -1
- package/dist/pt-BR.mjs +1 -1
- package/dist/pt-PT.mjs +1 -1
- package/dist/ro-RO.mjs +1 -1
- package/dist/ru-RU.mjs +1 -1
- package/dist/sk-SK.mjs +1 -1
- package/dist/sl-SI.mjs +1 -1
- package/dist/sr-SP.mjs +1 -1
- package/dist/sv-SE.mjs +1 -1
- package/dist/tr-TR.mjs +1 -1
- package/dist/uk-UA.mjs +1 -1
- package/dist/useSpinButton.main.js +23 -23
- package/dist/useSpinButton.main.js.map +1 -1
- package/dist/useSpinButton.mjs +24 -24
- package/dist/useSpinButton.module.js +23 -23
- package/dist/useSpinButton.module.js.map +1 -1
- package/dist/zh-CN.mjs +1 -1
- package/dist/zh-TW.mjs +1 -1
- package/package.json +9 -9
- package/src/useSpinButton.ts +1 -1
package/dist/ar-AE.mjs
CHANGED
package/dist/bg-BG.mjs
CHANGED
package/dist/cs-CZ.mjs
CHANGED
package/dist/da-DK.mjs
CHANGED
package/dist/de-DE.mjs
CHANGED
package/dist/el-GR.mjs
CHANGED
package/dist/en-US.mjs
CHANGED
package/dist/es-ES.mjs
CHANGED
package/dist/et-EE.mjs
CHANGED
package/dist/fi-FI.mjs
CHANGED
package/dist/fr-FR.mjs
CHANGED
package/dist/he-IL.mjs
CHANGED
package/dist/hr-HR.mjs
CHANGED
package/dist/hu-HU.mjs
CHANGED
package/dist/intlStrings.mjs
CHANGED
package/dist/it-IT.mjs
CHANGED
package/dist/ja-JP.mjs
CHANGED
package/dist/ko-KR.mjs
CHANGED
package/dist/lt-LT.mjs
CHANGED
package/dist/lv-LV.mjs
CHANGED
package/dist/nb-NO.mjs
CHANGED
package/dist/nl-NL.mjs
CHANGED
package/dist/pl-PL.mjs
CHANGED
package/dist/pt-BR.mjs
CHANGED
package/dist/pt-PT.mjs
CHANGED
package/dist/ro-RO.mjs
CHANGED
package/dist/ru-RU.mjs
CHANGED
package/dist/sk-SK.mjs
CHANGED
package/dist/sl-SI.mjs
CHANGED
package/dist/sr-SP.mjs
CHANGED
package/dist/sv-SE.mjs
CHANGED
package/dist/tr-TR.mjs
CHANGED
package/dist/uk-UA.mjs
CHANGED
|
@@ -30,9 +30,9 @@ $parcel$export(module.exports, "useSpinButton", () => $37bbd4c129023f61$export$e
|
|
|
30
30
|
|
|
31
31
|
|
|
32
32
|
function $37bbd4c129023f61$export$e908e06f4b8e3402(props) {
|
|
33
|
-
const _async = (0, $2pZbw$react.useRef)();
|
|
33
|
+
const _async = (0, $2pZbw$react.useRef)(undefined);
|
|
34
34
|
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;
|
|
35
|
-
const stringFormatter = (0, $2pZbw$reactariai18n.useLocalizedStringFormatter)((0, ($parcel$interopDefault($cb4b786159079747$exports))),
|
|
35
|
+
const stringFormatter = (0, $2pZbw$reactariai18n.useLocalizedStringFormatter)((0, ($parcel$interopDefault($cb4b786159079747$exports))), '@react-aria/spinbutton');
|
|
36
36
|
const clearAsync = ()=>clearTimeout(_async.current);
|
|
37
37
|
// eslint-disable-next-line arrow-body-style
|
|
38
38
|
(0, $2pZbw$react.useEffect)(()=>{
|
|
@@ -41,41 +41,41 @@ function $37bbd4c129023f61$export$e908e06f4b8e3402(props) {
|
|
|
41
41
|
let onKeyDown = (e)=>{
|
|
42
42
|
if (e.ctrlKey || e.metaKey || e.shiftKey || e.altKey || isReadOnly) return;
|
|
43
43
|
switch(e.key){
|
|
44
|
-
case
|
|
44
|
+
case 'PageUp':
|
|
45
45
|
if (onIncrementPage) {
|
|
46
46
|
e.preventDefault();
|
|
47
47
|
onIncrementPage === null || onIncrementPage === void 0 ? void 0 : onIncrementPage();
|
|
48
48
|
break;
|
|
49
49
|
}
|
|
50
50
|
// fallthrough!
|
|
51
|
-
case
|
|
52
|
-
case
|
|
51
|
+
case 'ArrowUp':
|
|
52
|
+
case 'Up':
|
|
53
53
|
if (onIncrement) {
|
|
54
54
|
e.preventDefault();
|
|
55
55
|
onIncrement === null || onIncrement === void 0 ? void 0 : onIncrement();
|
|
56
56
|
}
|
|
57
57
|
break;
|
|
58
|
-
case
|
|
58
|
+
case 'PageDown':
|
|
59
59
|
if (onDecrementPage) {
|
|
60
60
|
e.preventDefault();
|
|
61
61
|
onDecrementPage === null || onDecrementPage === void 0 ? void 0 : onDecrementPage();
|
|
62
62
|
break;
|
|
63
63
|
}
|
|
64
64
|
// fallthrough
|
|
65
|
-
case
|
|
66
|
-
case
|
|
65
|
+
case 'ArrowDown':
|
|
66
|
+
case 'Down':
|
|
67
67
|
if (onDecrement) {
|
|
68
68
|
e.preventDefault();
|
|
69
69
|
onDecrement === null || onDecrement === void 0 ? void 0 : onDecrement();
|
|
70
70
|
}
|
|
71
71
|
break;
|
|
72
|
-
case
|
|
72
|
+
case 'Home':
|
|
73
73
|
if (onDecrementToMin) {
|
|
74
74
|
e.preventDefault();
|
|
75
75
|
onDecrementToMin === null || onDecrementToMin === void 0 ? void 0 : onDecrementToMin();
|
|
76
76
|
}
|
|
77
77
|
break;
|
|
78
|
-
case
|
|
78
|
+
case 'End':
|
|
79
79
|
if (onIncrementToMax) {
|
|
80
80
|
e.preventDefault();
|
|
81
81
|
onIncrementToMax === null || onIncrementToMax === void 0 ? void 0 : onIncrementToMax();
|
|
@@ -94,11 +94,11 @@ function $37bbd4c129023f61$export$e908e06f4b8e3402(props) {
|
|
|
94
94
|
// This ensures that macOS VoiceOver announces it as "minus" even with other characters between the minus sign
|
|
95
95
|
// and the number (e.g. currency symbol). Otherwise it announces nothing because it assumes the character is a hyphen.
|
|
96
96
|
// In addition, replace the empty string with the word "Empty" so that iOS VoiceOver does not read "50%" for an empty field.
|
|
97
|
-
let ariaTextValue = textValue ===
|
|
97
|
+
let ariaTextValue = textValue === '' ? stringFormatter.format('Empty') : (textValue || `${value}`).replace('-', '\u2212');
|
|
98
98
|
(0, $2pZbw$react.useEffect)(()=>{
|
|
99
99
|
if (isFocused.current) {
|
|
100
|
-
(0, $2pZbw$reactarialiveannouncer.clearAnnouncer)(
|
|
101
|
-
(0, $2pZbw$reactarialiveannouncer.announce)(ariaTextValue,
|
|
100
|
+
(0, $2pZbw$reactarialiveannouncer.clearAnnouncer)('assertive');
|
|
101
|
+
(0, $2pZbw$reactarialiveannouncer.announce)(ariaTextValue, 'assertive');
|
|
102
102
|
}
|
|
103
103
|
}, [
|
|
104
104
|
ariaTextValue
|
|
@@ -125,14 +125,14 @@ function $37bbd4c129023f61$export$e908e06f4b8e3402(props) {
|
|
|
125
125
|
let { addGlobalListener: addGlobalListener, removeAllGlobalListeners: removeAllGlobalListeners } = (0, $2pZbw$reactariautils.useGlobalListeners)();
|
|
126
126
|
return {
|
|
127
127
|
spinButtonProps: {
|
|
128
|
-
role:
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
128
|
+
role: 'spinbutton',
|
|
129
|
+
'aria-valuenow': value !== undefined && !isNaN(value) ? value : undefined,
|
|
130
|
+
'aria-valuetext': ariaTextValue,
|
|
131
|
+
'aria-valuemin': minValue,
|
|
132
|
+
'aria-valuemax': maxValue,
|
|
133
|
+
'aria-disabled': isDisabled || undefined,
|
|
134
|
+
'aria-readonly': isReadOnly || undefined,
|
|
135
|
+
'aria-required': isRequired || undefined,
|
|
136
136
|
onKeyDown: onKeyDown,
|
|
137
137
|
onFocus: onFocus,
|
|
138
138
|
onBlur: onBlur
|
|
@@ -140,7 +140,7 @@ function $37bbd4c129023f61$export$e908e06f4b8e3402(props) {
|
|
|
140
140
|
incrementButtonProps: {
|
|
141
141
|
onPressStart: ()=>{
|
|
142
142
|
onIncrementPressStart(400);
|
|
143
|
-
addGlobalListener(window,
|
|
143
|
+
addGlobalListener(window, 'contextmenu', cancelContextMenu);
|
|
144
144
|
},
|
|
145
145
|
onPressEnd: ()=>{
|
|
146
146
|
clearAsync();
|
|
@@ -152,7 +152,7 @@ function $37bbd4c129023f61$export$e908e06f4b8e3402(props) {
|
|
|
152
152
|
decrementButtonProps: {
|
|
153
153
|
onPressStart: ()=>{
|
|
154
154
|
onDecrementPressStart(400);
|
|
155
|
-
addGlobalListener(window,
|
|
155
|
+
addGlobalListener(window, 'contextmenu', cancelContextMenu);
|
|
156
156
|
},
|
|
157
157
|
onPressEnd: ()=>{
|
|
158
158
|
clearAsync();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;AA4BM,SAAS,0CACd,KAAsB;IAEtB,MAAM,SAAS,CAAA,GAAA,mBAAK;
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;AA4BM,SAAS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ACZ,sBAAsB;gBACtB,kBAAkB,QAAQ,eAAe;YAC3C;YACA,YAAY;gBACV;gBACA;YACF;qBACA;oBACA;QACF;QACA,sBAAsB;YACpB,cAAc;gBACZ,sBAAsB;gBACtB,kBAAkB,QAAQ,eAAe;YAC3C;YACA,YAAY;gBACV;gBACA;YACF;qBACA;oBACA;QACF;IACF;AACF","sources":["packages/@react-aria/spinbutton/src/useSpinButton.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {announce, clearAnnouncer} from '@react-aria/live-announcer';\nimport {AriaButtonProps} from '@react-types/button';\nimport {DOMAttributes, InputBase, RangeInputBase, Validation, ValueBase} from '@react-types/shared';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport {useEffect, useRef} from 'react';\nimport {useEffectEvent, useGlobalListeners} from '@react-aria/utils';\nimport {useLocalizedStringFormatter} from '@react-aria/i18n';\n\n\nexport interface SpinButtonProps extends InputBase, Validation<number>, ValueBase<number>, RangeInputBase<number> {\n textValue?: string,\n onIncrement?: () => void,\n onIncrementPage?: () => void,\n onDecrement?: () => void,\n onDecrementPage?: () => void,\n onDecrementToMin?: () => void,\n onIncrementToMax?: () => void\n}\n\nexport interface SpinbuttonAria {\n spinButtonProps: DOMAttributes,\n incrementButtonProps: AriaButtonProps,\n decrementButtonProps: AriaButtonProps\n}\n\nexport function useSpinButton(\n props: SpinButtonProps\n): SpinbuttonAria {\n const _async = useRef<number>(undefined);\n let {\n value,\n textValue,\n minValue,\n maxValue,\n isDisabled,\n isReadOnly,\n isRequired,\n onIncrement,\n onIncrementPage,\n onDecrement,\n onDecrementPage,\n onDecrementToMin,\n onIncrementToMax\n } = props;\n const stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/spinbutton');\n\n const clearAsync = () => clearTimeout(_async.current);\n\n // eslint-disable-next-line arrow-body-style\n useEffect(() => {\n return () => clearAsync();\n }, []);\n\n let onKeyDown = (e) => {\n if (e.ctrlKey || e.metaKey || e.shiftKey || e.altKey || isReadOnly) {\n return;\n }\n\n switch (e.key) {\n case 'PageUp':\n if (onIncrementPage) {\n e.preventDefault();\n onIncrementPage?.();\n break;\n }\n // fallthrough!\n case 'ArrowUp':\n case 'Up':\n if (onIncrement) {\n e.preventDefault();\n onIncrement?.();\n }\n break;\n case 'PageDown':\n if (onDecrementPage) {\n e.preventDefault();\n onDecrementPage?.();\n break;\n }\n // fallthrough\n case 'ArrowDown':\n case 'Down':\n if (onDecrement) {\n e.preventDefault();\n onDecrement?.();\n }\n break;\n case 'Home':\n if (onDecrementToMin) {\n e.preventDefault();\n onDecrementToMin?.();\n }\n break;\n case 'End':\n if (onIncrementToMax) {\n e.preventDefault();\n onIncrementToMax?.();\n }\n break;\n }\n };\n\n let isFocused = useRef(false);\n let onFocus = () => {\n isFocused.current = true;\n };\n\n let onBlur = () => {\n isFocused.current = false;\n };\n\n // Replace Unicode hyphen-minus (U+002D) with minus sign (U+2212).\n // This ensures that macOS VoiceOver announces it as \"minus\" even with other characters between the minus sign\n // and the number (e.g. currency symbol). Otherwise it announces nothing because it assumes the character is a hyphen.\n // In addition, replace the empty string with the word \"Empty\" so that iOS VoiceOver does not read \"50%\" for an empty field.\n let ariaTextValue = textValue === '' ? stringFormatter.format('Empty') : (textValue || `${value}`).replace('-', '\\u2212');\n\n useEffect(() => {\n if (isFocused.current) {\n clearAnnouncer('assertive');\n announce(ariaTextValue, 'assertive');\n }\n }, [ariaTextValue]);\n\n const onIncrementPressStart = useEffectEvent(\n (initialStepDelay: number) => {\n clearAsync();\n onIncrement?.();\n // Start spinning after initial delay\n _async.current = window.setTimeout(\n () => {\n if ((maxValue === undefined || isNaN(maxValue)) || (value === undefined || isNaN(value)) || value < maxValue) {\n onIncrementPressStart(60);\n }\n },\n initialStepDelay\n );\n }\n );\n\n const onDecrementPressStart = useEffectEvent(\n (initialStepDelay: number) => {\n clearAsync();\n onDecrement?.();\n // Start spinning after initial delay\n _async.current = window.setTimeout(\n () => {\n if ((minValue === undefined || isNaN(minValue)) || (value === undefined || isNaN(value)) || value > minValue) {\n onDecrementPressStart(60);\n }\n },\n initialStepDelay\n );\n }\n );\n\n let cancelContextMenu = (e) => {\n e.preventDefault();\n };\n\n let {addGlobalListener, removeAllGlobalListeners} = useGlobalListeners();\n\n return {\n spinButtonProps: {\n role: 'spinbutton',\n 'aria-valuenow': value !== undefined && !isNaN(value) ? value : undefined,\n 'aria-valuetext': ariaTextValue,\n 'aria-valuemin': minValue,\n 'aria-valuemax': maxValue,\n 'aria-disabled': isDisabled || undefined,\n 'aria-readonly': isReadOnly || undefined,\n 'aria-required': isRequired || undefined,\n onKeyDown,\n onFocus,\n onBlur\n },\n incrementButtonProps: {\n onPressStart: () => {\n onIncrementPressStart(400);\n addGlobalListener(window, 'contextmenu', cancelContextMenu);\n },\n onPressEnd: () => {\n clearAsync();\n removeAllGlobalListeners();\n },\n onFocus,\n onBlur\n },\n decrementButtonProps: {\n onPressStart: () => {\n onDecrementPressStart(400);\n addGlobalListener(window, 'contextmenu', cancelContextMenu);\n },\n onPressEnd: () => {\n clearAsync();\n removeAllGlobalListeners();\n },\n onFocus,\n onBlur\n }\n };\n}\n"],"names":[],"version":3,"file":"useSpinButton.main.js.map"}
|
package/dist/useSpinButton.mjs
CHANGED
|
@@ -24,9 +24,9 @@ function $parcel$interopDefault(a) {
|
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
function $d2e8511e6f209edf$export$e908e06f4b8e3402(props) {
|
|
27
|
-
const _async = (0, $5rwhf$useRef)();
|
|
27
|
+
const _async = (0, $5rwhf$useRef)(undefined);
|
|
28
28
|
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;
|
|
29
|
-
const stringFormatter = (0, $5rwhf$useLocalizedStringFormatter)((0, ($parcel$interopDefault($5rwhf$intlStringsmodulejs))),
|
|
29
|
+
const stringFormatter = (0, $5rwhf$useLocalizedStringFormatter)((0, ($parcel$interopDefault($5rwhf$intlStringsmodulejs))), '@react-aria/spinbutton');
|
|
30
30
|
const clearAsync = ()=>clearTimeout(_async.current);
|
|
31
31
|
// eslint-disable-next-line arrow-body-style
|
|
32
32
|
(0, $5rwhf$useEffect)(()=>{
|
|
@@ -35,41 +35,41 @@ function $d2e8511e6f209edf$export$e908e06f4b8e3402(props) {
|
|
|
35
35
|
let onKeyDown = (e)=>{
|
|
36
36
|
if (e.ctrlKey || e.metaKey || e.shiftKey || e.altKey || isReadOnly) return;
|
|
37
37
|
switch(e.key){
|
|
38
|
-
case
|
|
38
|
+
case 'PageUp':
|
|
39
39
|
if (onIncrementPage) {
|
|
40
40
|
e.preventDefault();
|
|
41
41
|
onIncrementPage === null || onIncrementPage === void 0 ? void 0 : onIncrementPage();
|
|
42
42
|
break;
|
|
43
43
|
}
|
|
44
44
|
// fallthrough!
|
|
45
|
-
case
|
|
46
|
-
case
|
|
45
|
+
case 'ArrowUp':
|
|
46
|
+
case 'Up':
|
|
47
47
|
if (onIncrement) {
|
|
48
48
|
e.preventDefault();
|
|
49
49
|
onIncrement === null || onIncrement === void 0 ? void 0 : onIncrement();
|
|
50
50
|
}
|
|
51
51
|
break;
|
|
52
|
-
case
|
|
52
|
+
case 'PageDown':
|
|
53
53
|
if (onDecrementPage) {
|
|
54
54
|
e.preventDefault();
|
|
55
55
|
onDecrementPage === null || onDecrementPage === void 0 ? void 0 : onDecrementPage();
|
|
56
56
|
break;
|
|
57
57
|
}
|
|
58
58
|
// fallthrough
|
|
59
|
-
case
|
|
60
|
-
case
|
|
59
|
+
case 'ArrowDown':
|
|
60
|
+
case 'Down':
|
|
61
61
|
if (onDecrement) {
|
|
62
62
|
e.preventDefault();
|
|
63
63
|
onDecrement === null || onDecrement === void 0 ? void 0 : onDecrement();
|
|
64
64
|
}
|
|
65
65
|
break;
|
|
66
|
-
case
|
|
66
|
+
case 'Home':
|
|
67
67
|
if (onDecrementToMin) {
|
|
68
68
|
e.preventDefault();
|
|
69
69
|
onDecrementToMin === null || onDecrementToMin === void 0 ? void 0 : onDecrementToMin();
|
|
70
70
|
}
|
|
71
71
|
break;
|
|
72
|
-
case
|
|
72
|
+
case 'End':
|
|
73
73
|
if (onIncrementToMax) {
|
|
74
74
|
e.preventDefault();
|
|
75
75
|
onIncrementToMax === null || onIncrementToMax === void 0 ? void 0 : onIncrementToMax();
|
|
@@ -88,11 +88,11 @@ function $d2e8511e6f209edf$export$e908e06f4b8e3402(props) {
|
|
|
88
88
|
// This ensures that macOS VoiceOver announces it as "minus" even with other characters between the minus sign
|
|
89
89
|
// and the number (e.g. currency symbol). Otherwise it announces nothing because it assumes the character is a hyphen.
|
|
90
90
|
// In addition, replace the empty string with the word "Empty" so that iOS VoiceOver does not read "50%" for an empty field.
|
|
91
|
-
let ariaTextValue = textValue ===
|
|
91
|
+
let ariaTextValue = textValue === '' ? stringFormatter.format('Empty') : (textValue || `${value}`).replace('-', '\u2212');
|
|
92
92
|
(0, $5rwhf$useEffect)(()=>{
|
|
93
93
|
if (isFocused.current) {
|
|
94
|
-
(0, $5rwhf$clearAnnouncer)(
|
|
95
|
-
(0, $5rwhf$announce)(ariaTextValue,
|
|
94
|
+
(0, $5rwhf$clearAnnouncer)('assertive');
|
|
95
|
+
(0, $5rwhf$announce)(ariaTextValue, 'assertive');
|
|
96
96
|
}
|
|
97
97
|
}, [
|
|
98
98
|
ariaTextValue
|
|
@@ -119,14 +119,14 @@ function $d2e8511e6f209edf$export$e908e06f4b8e3402(props) {
|
|
|
119
119
|
let { addGlobalListener: addGlobalListener, removeAllGlobalListeners: removeAllGlobalListeners } = (0, $5rwhf$useGlobalListeners)();
|
|
120
120
|
return {
|
|
121
121
|
spinButtonProps: {
|
|
122
|
-
role:
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
122
|
+
role: 'spinbutton',
|
|
123
|
+
'aria-valuenow': value !== undefined && !isNaN(value) ? value : undefined,
|
|
124
|
+
'aria-valuetext': ariaTextValue,
|
|
125
|
+
'aria-valuemin': minValue,
|
|
126
|
+
'aria-valuemax': maxValue,
|
|
127
|
+
'aria-disabled': isDisabled || undefined,
|
|
128
|
+
'aria-readonly': isReadOnly || undefined,
|
|
129
|
+
'aria-required': isRequired || undefined,
|
|
130
130
|
onKeyDown: onKeyDown,
|
|
131
131
|
onFocus: onFocus,
|
|
132
132
|
onBlur: onBlur
|
|
@@ -134,7 +134,7 @@ function $d2e8511e6f209edf$export$e908e06f4b8e3402(props) {
|
|
|
134
134
|
incrementButtonProps: {
|
|
135
135
|
onPressStart: ()=>{
|
|
136
136
|
onIncrementPressStart(400);
|
|
137
|
-
addGlobalListener(window,
|
|
137
|
+
addGlobalListener(window, 'contextmenu', cancelContextMenu);
|
|
138
138
|
},
|
|
139
139
|
onPressEnd: ()=>{
|
|
140
140
|
clearAsync();
|
|
@@ -146,7 +146,7 @@ function $d2e8511e6f209edf$export$e908e06f4b8e3402(props) {
|
|
|
146
146
|
decrementButtonProps: {
|
|
147
147
|
onPressStart: ()=>{
|
|
148
148
|
onDecrementPressStart(400);
|
|
149
|
-
addGlobalListener(window,
|
|
149
|
+
addGlobalListener(window, 'contextmenu', cancelContextMenu);
|
|
150
150
|
},
|
|
151
151
|
onPressEnd: ()=>{
|
|
152
152
|
clearAsync();
|
|
@@ -160,4 +160,4 @@ function $d2e8511e6f209edf$export$e908e06f4b8e3402(props) {
|
|
|
160
160
|
|
|
161
161
|
|
|
162
162
|
export {$d2e8511e6f209edf$export$e908e06f4b8e3402 as useSpinButton};
|
|
163
|
-
//# sourceMappingURL=useSpinButton.
|
|
163
|
+
//# sourceMappingURL=useSpinButton.module.js.map
|
|
@@ -24,9 +24,9 @@ function $parcel$interopDefault(a) {
|
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
function $d2e8511e6f209edf$export$e908e06f4b8e3402(props) {
|
|
27
|
-
const _async = (0, $5rwhf$useRef)();
|
|
27
|
+
const _async = (0, $5rwhf$useRef)(undefined);
|
|
28
28
|
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;
|
|
29
|
-
const stringFormatter = (0, $5rwhf$useLocalizedStringFormatter)((0, ($parcel$interopDefault($5rwhf$intlStringsmodulejs))),
|
|
29
|
+
const stringFormatter = (0, $5rwhf$useLocalizedStringFormatter)((0, ($parcel$interopDefault($5rwhf$intlStringsmodulejs))), '@react-aria/spinbutton');
|
|
30
30
|
const clearAsync = ()=>clearTimeout(_async.current);
|
|
31
31
|
// eslint-disable-next-line arrow-body-style
|
|
32
32
|
(0, $5rwhf$useEffect)(()=>{
|
|
@@ -35,41 +35,41 @@ function $d2e8511e6f209edf$export$e908e06f4b8e3402(props) {
|
|
|
35
35
|
let onKeyDown = (e)=>{
|
|
36
36
|
if (e.ctrlKey || e.metaKey || e.shiftKey || e.altKey || isReadOnly) return;
|
|
37
37
|
switch(e.key){
|
|
38
|
-
case
|
|
38
|
+
case 'PageUp':
|
|
39
39
|
if (onIncrementPage) {
|
|
40
40
|
e.preventDefault();
|
|
41
41
|
onIncrementPage === null || onIncrementPage === void 0 ? void 0 : onIncrementPage();
|
|
42
42
|
break;
|
|
43
43
|
}
|
|
44
44
|
// fallthrough!
|
|
45
|
-
case
|
|
46
|
-
case
|
|
45
|
+
case 'ArrowUp':
|
|
46
|
+
case 'Up':
|
|
47
47
|
if (onIncrement) {
|
|
48
48
|
e.preventDefault();
|
|
49
49
|
onIncrement === null || onIncrement === void 0 ? void 0 : onIncrement();
|
|
50
50
|
}
|
|
51
51
|
break;
|
|
52
|
-
case
|
|
52
|
+
case 'PageDown':
|
|
53
53
|
if (onDecrementPage) {
|
|
54
54
|
e.preventDefault();
|
|
55
55
|
onDecrementPage === null || onDecrementPage === void 0 ? void 0 : onDecrementPage();
|
|
56
56
|
break;
|
|
57
57
|
}
|
|
58
58
|
// fallthrough
|
|
59
|
-
case
|
|
60
|
-
case
|
|
59
|
+
case 'ArrowDown':
|
|
60
|
+
case 'Down':
|
|
61
61
|
if (onDecrement) {
|
|
62
62
|
e.preventDefault();
|
|
63
63
|
onDecrement === null || onDecrement === void 0 ? void 0 : onDecrement();
|
|
64
64
|
}
|
|
65
65
|
break;
|
|
66
|
-
case
|
|
66
|
+
case 'Home':
|
|
67
67
|
if (onDecrementToMin) {
|
|
68
68
|
e.preventDefault();
|
|
69
69
|
onDecrementToMin === null || onDecrementToMin === void 0 ? void 0 : onDecrementToMin();
|
|
70
70
|
}
|
|
71
71
|
break;
|
|
72
|
-
case
|
|
72
|
+
case 'End':
|
|
73
73
|
if (onIncrementToMax) {
|
|
74
74
|
e.preventDefault();
|
|
75
75
|
onIncrementToMax === null || onIncrementToMax === void 0 ? void 0 : onIncrementToMax();
|
|
@@ -88,11 +88,11 @@ function $d2e8511e6f209edf$export$e908e06f4b8e3402(props) {
|
|
|
88
88
|
// This ensures that macOS VoiceOver announces it as "minus" even with other characters between the minus sign
|
|
89
89
|
// and the number (e.g. currency symbol). Otherwise it announces nothing because it assumes the character is a hyphen.
|
|
90
90
|
// In addition, replace the empty string with the word "Empty" so that iOS VoiceOver does not read "50%" for an empty field.
|
|
91
|
-
let ariaTextValue = textValue ===
|
|
91
|
+
let ariaTextValue = textValue === '' ? stringFormatter.format('Empty') : (textValue || `${value}`).replace('-', '\u2212');
|
|
92
92
|
(0, $5rwhf$useEffect)(()=>{
|
|
93
93
|
if (isFocused.current) {
|
|
94
|
-
(0, $5rwhf$clearAnnouncer)(
|
|
95
|
-
(0, $5rwhf$announce)(ariaTextValue,
|
|
94
|
+
(0, $5rwhf$clearAnnouncer)('assertive');
|
|
95
|
+
(0, $5rwhf$announce)(ariaTextValue, 'assertive');
|
|
96
96
|
}
|
|
97
97
|
}, [
|
|
98
98
|
ariaTextValue
|
|
@@ -119,14 +119,14 @@ function $d2e8511e6f209edf$export$e908e06f4b8e3402(props) {
|
|
|
119
119
|
let { addGlobalListener: addGlobalListener, removeAllGlobalListeners: removeAllGlobalListeners } = (0, $5rwhf$useGlobalListeners)();
|
|
120
120
|
return {
|
|
121
121
|
spinButtonProps: {
|
|
122
|
-
role:
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
122
|
+
role: 'spinbutton',
|
|
123
|
+
'aria-valuenow': value !== undefined && !isNaN(value) ? value : undefined,
|
|
124
|
+
'aria-valuetext': ariaTextValue,
|
|
125
|
+
'aria-valuemin': minValue,
|
|
126
|
+
'aria-valuemax': maxValue,
|
|
127
|
+
'aria-disabled': isDisabled || undefined,
|
|
128
|
+
'aria-readonly': isReadOnly || undefined,
|
|
129
|
+
'aria-required': isRequired || undefined,
|
|
130
130
|
onKeyDown: onKeyDown,
|
|
131
131
|
onFocus: onFocus,
|
|
132
132
|
onBlur: onBlur
|
|
@@ -134,7 +134,7 @@ function $d2e8511e6f209edf$export$e908e06f4b8e3402(props) {
|
|
|
134
134
|
incrementButtonProps: {
|
|
135
135
|
onPressStart: ()=>{
|
|
136
136
|
onIncrementPressStart(400);
|
|
137
|
-
addGlobalListener(window,
|
|
137
|
+
addGlobalListener(window, 'contextmenu', cancelContextMenu);
|
|
138
138
|
},
|
|
139
139
|
onPressEnd: ()=>{
|
|
140
140
|
clearAsync();
|
|
@@ -146,7 +146,7 @@ function $d2e8511e6f209edf$export$e908e06f4b8e3402(props) {
|
|
|
146
146
|
decrementButtonProps: {
|
|
147
147
|
onPressStart: ()=>{
|
|
148
148
|
onDecrementPressStart(400);
|
|
149
|
-
addGlobalListener(window,
|
|
149
|
+
addGlobalListener(window, 'contextmenu', cancelContextMenu);
|
|
150
150
|
},
|
|
151
151
|
onPressEnd: ()=>{
|
|
152
152
|
clearAsync();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;AA4BM,SAAS,0CACd,KAAsB;IAEtB,MAAM,SAAS,CAAA,GAAA,aAAK;
|
|
1
|
+
{"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;AA4BM,SAAS,0CACd,KAAsB;IAEtB,MAAM,SAAS,CAAA,GAAA,aAAK,EAAU;IAC9B,IAAI,SACF,KAAK,aACL,SAAS,YACT,QAAQ,YACR,QAAQ,cACR,UAAU,cACV,UAAU,cACV,UAAU,eACV,WAAW,mBACX,eAAe,eACf,WAAW,mBACX,eAAe,oBACf,gBAAgB,oBAChB,gBAAgB,EACjB,GAAG;IACJ,MAAM,kBAAkB,CAAA,GAAA,kCAA0B,EAAE,CAAA,GAAA,oDAAW,GAAG;IAElE,MAAM,aAAa,IAAM,aAAa,OAAO,OAAO;IAEpD,4CAA4C;IAC5C,CAAA,GAAA,gBAAQ,EAAE;QACR,OAAO,IAAM;IACf,GAAG,EAAE;IAEL,IAAI,YAAY,CAAC;QACf,IAAI,EAAE,OAAO,IAAI,EAAE,OAAO,IAAI,EAAE,QAAQ,IAAI,EAAE,MAAM,IAAI,YACtD;QAGF,OAAQ,EAAE,GAAG;YACX,KAAK;gBACH,IAAI,iBAAiB;oBACnB,EAAE,cAAc;oBAChB,4BAAA,sCAAA;oBACA;gBACF;YACF,eAAe;YACf,KAAK;YACL,KAAK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AAA;QACA,qCAAqC;QACrC,OAAO,OAAO,GAAG,OAAO,UAAU,CAChC;YACE,IAAI,AAAC,aAAa,aAAa,MAAM,aAAe,UAAU,aAAa,MAAM,UAAW,QAAQ,UAClG,sBAAsB;QAE1B,GACA;IAEJ;IAGF,IAAI,oBAAoB,CAAC;QACvB,EAAE,cAAc;IAClB;IAEA,IAAI,qBAAC,iBAAiB,4BAAE,wBAAwB,EAAC,GAAG,CAAA,GAAA,yBAAiB;IAErE,OAAO;QACL,iBAAiB;YACf,MAAM;YACN,iBAAiB,UAAU,aAAa,CAAC,MAAM,SAAS,QAAQ;YAChE,kBAAkB;YAClB,iBAAiB;YACjB,iBAAiB;YACjB,iBAAiB,cAAc;YAC/B,iBAAiB,cAAc;YAC/B,iBAAiB,cAAc;uBAC/B;qBACA;oBACA;QACF;QACA,sBAAsB;YACpB,cAAc;gBACZ,sBAAsB;gBACtB,kBAAkB,QAAQ,eAAe;YAC3C;YACA,YAAY;gBACV;gBACA;YACF;qBACA;oBACA;QACF;QACA,sBAAsB;YACpB,cAAc;gBACZ,sBAAsB;gBACtB,kBAAkB,QAAQ,eAAe;YAC3C;YACA,YAAY;gBACV;gBACA;YACF;qBACA;oBACA;QACF;IACF;AACF","sources":["packages/@react-aria/spinbutton/src/useSpinButton.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {announce, clearAnnouncer} from '@react-aria/live-announcer';\nimport {AriaButtonProps} from '@react-types/button';\nimport {DOMAttributes, InputBase, RangeInputBase, Validation, ValueBase} from '@react-types/shared';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport {useEffect, useRef} from 'react';\nimport {useEffectEvent, useGlobalListeners} from '@react-aria/utils';\nimport {useLocalizedStringFormatter} from '@react-aria/i18n';\n\n\nexport interface SpinButtonProps extends InputBase, Validation<number>, ValueBase<number>, RangeInputBase<number> {\n textValue?: string,\n onIncrement?: () => void,\n onIncrementPage?: () => void,\n onDecrement?: () => void,\n onDecrementPage?: () => void,\n onDecrementToMin?: () => void,\n onIncrementToMax?: () => void\n}\n\nexport interface SpinbuttonAria {\n spinButtonProps: DOMAttributes,\n incrementButtonProps: AriaButtonProps,\n decrementButtonProps: AriaButtonProps\n}\n\nexport function useSpinButton(\n props: SpinButtonProps\n): SpinbuttonAria {\n const _async = useRef<number>(undefined);\n let {\n value,\n textValue,\n minValue,\n maxValue,\n isDisabled,\n isReadOnly,\n isRequired,\n onIncrement,\n onIncrementPage,\n onDecrement,\n onDecrementPage,\n onDecrementToMin,\n onIncrementToMax\n } = props;\n const stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/spinbutton');\n\n const clearAsync = () => clearTimeout(_async.current);\n\n // eslint-disable-next-line arrow-body-style\n useEffect(() => {\n return () => clearAsync();\n }, []);\n\n let onKeyDown = (e) => {\n if (e.ctrlKey || e.metaKey || e.shiftKey || e.altKey || isReadOnly) {\n return;\n }\n\n switch (e.key) {\n case 'PageUp':\n if (onIncrementPage) {\n e.preventDefault();\n onIncrementPage?.();\n break;\n }\n // fallthrough!\n case 'ArrowUp':\n case 'Up':\n if (onIncrement) {\n e.preventDefault();\n onIncrement?.();\n }\n break;\n case 'PageDown':\n if (onDecrementPage) {\n e.preventDefault();\n onDecrementPage?.();\n break;\n }\n // fallthrough\n case 'ArrowDown':\n case 'Down':\n if (onDecrement) {\n e.preventDefault();\n onDecrement?.();\n }\n break;\n case 'Home':\n if (onDecrementToMin) {\n e.preventDefault();\n onDecrementToMin?.();\n }\n break;\n case 'End':\n if (onIncrementToMax) {\n e.preventDefault();\n onIncrementToMax?.();\n }\n break;\n }\n };\n\n let isFocused = useRef(false);\n let onFocus = () => {\n isFocused.current = true;\n };\n\n let onBlur = () => {\n isFocused.current = false;\n };\n\n // Replace Unicode hyphen-minus (U+002D) with minus sign (U+2212).\n // This ensures that macOS VoiceOver announces it as \"minus\" even with other characters between the minus sign\n // and the number (e.g. currency symbol). Otherwise it announces nothing because it assumes the character is a hyphen.\n // In addition, replace the empty string with the word \"Empty\" so that iOS VoiceOver does not read \"50%\" for an empty field.\n let ariaTextValue = textValue === '' ? stringFormatter.format('Empty') : (textValue || `${value}`).replace('-', '\\u2212');\n\n useEffect(() => {\n if (isFocused.current) {\n clearAnnouncer('assertive');\n announce(ariaTextValue, 'assertive');\n }\n }, [ariaTextValue]);\n\n const onIncrementPressStart = useEffectEvent(\n (initialStepDelay: number) => {\n clearAsync();\n onIncrement?.();\n // Start spinning after initial delay\n _async.current = window.setTimeout(\n () => {\n if ((maxValue === undefined || isNaN(maxValue)) || (value === undefined || isNaN(value)) || value < maxValue) {\n onIncrementPressStart(60);\n }\n },\n initialStepDelay\n );\n }\n );\n\n const onDecrementPressStart = useEffectEvent(\n (initialStepDelay: number) => {\n clearAsync();\n onDecrement?.();\n // Start spinning after initial delay\n _async.current = window.setTimeout(\n () => {\n if ((minValue === undefined || isNaN(minValue)) || (value === undefined || isNaN(value)) || value > minValue) {\n onDecrementPressStart(60);\n }\n },\n initialStepDelay\n );\n }\n );\n\n let cancelContextMenu = (e) => {\n e.preventDefault();\n };\n\n let {addGlobalListener, removeAllGlobalListeners} = useGlobalListeners();\n\n return {\n spinButtonProps: {\n role: 'spinbutton',\n 'aria-valuenow': value !== undefined && !isNaN(value) ? value : undefined,\n 'aria-valuetext': ariaTextValue,\n 'aria-valuemin': minValue,\n 'aria-valuemax': maxValue,\n 'aria-disabled': isDisabled || undefined,\n 'aria-readonly': isReadOnly || undefined,\n 'aria-required': isRequired || undefined,\n onKeyDown,\n onFocus,\n onBlur\n },\n incrementButtonProps: {\n onPressStart: () => {\n onIncrementPressStart(400);\n addGlobalListener(window, 'contextmenu', cancelContextMenu);\n },\n onPressEnd: () => {\n clearAsync();\n removeAllGlobalListeners();\n },\n onFocus,\n onBlur\n },\n decrementButtonProps: {\n onPressStart: () => {\n onDecrementPressStart(400);\n addGlobalListener(window, 'contextmenu', cancelContextMenu);\n },\n onPressEnd: () => {\n clearAsync();\n removeAllGlobalListeners();\n },\n onFocus,\n onBlur\n }\n };\n}\n"],"names":[],"version":3,"file":"useSpinButton.module.js.map"}
|
package/dist/zh-CN.mjs
CHANGED
package/dist/zh-TW.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-aria/spinbutton",
|
|
3
|
-
"version": "3.6.
|
|
3
|
+
"version": "3.6.6",
|
|
4
4
|
"description": "Spectrum UI components in React",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -22,19 +22,19 @@
|
|
|
22
22
|
"url": "https://github.com/adobe/react-spectrum"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@react-aria/i18n": "^3.
|
|
26
|
-
"@react-aria/live-announcer": "^3.3.
|
|
27
|
-
"@react-aria/utils": "^3.
|
|
28
|
-
"@react-types/button": "^3.9.
|
|
29
|
-
"@react-types/shared": "^3.
|
|
25
|
+
"@react-aria/i18n": "^3.12.0",
|
|
26
|
+
"@react-aria/live-announcer": "^3.3.4",
|
|
27
|
+
"@react-aria/utils": "^3.25.0",
|
|
28
|
+
"@react-types/button": "^3.9.5",
|
|
29
|
+
"@react-types/shared": "^3.24.0",
|
|
30
30
|
"@swc/helpers": "^0.5.0"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
|
-
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0",
|
|
34
|
-
"react-dom": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0"
|
|
33
|
+
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0",
|
|
34
|
+
"react-dom": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0"
|
|
35
35
|
},
|
|
36
36
|
"publishConfig": {
|
|
37
37
|
"access": "public"
|
|
38
38
|
},
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "86d80e3216bc32e75108831cf3a5a720bc849206"
|
|
40
40
|
}
|
package/src/useSpinButton.ts
CHANGED