@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 CHANGED
@@ -5,4 +5,4 @@ $ed6aae4e5f766f1e$exports = {
5
5
 
6
6
 
7
7
  export {$ed6aae4e5f766f1e$exports as default};
8
- //# sourceMappingURL=ar-AE.mjs.map
8
+ //# sourceMappingURL=ar-AE.module.js.map
package/dist/bg-BG.mjs CHANGED
@@ -5,4 +5,4 @@ $38854e2b175151fa$exports = {
5
5
 
6
6
 
7
7
  export {$38854e2b175151fa$exports as default};
8
- //# sourceMappingURL=bg-BG.mjs.map
8
+ //# sourceMappingURL=bg-BG.module.js.map
package/dist/cs-CZ.mjs CHANGED
@@ -5,4 +5,4 @@ $15b25ab20f3945b2$exports = {
5
5
 
6
6
 
7
7
  export {$15b25ab20f3945b2$exports as default};
8
- //# sourceMappingURL=cs-CZ.mjs.map
8
+ //# sourceMappingURL=cs-CZ.module.js.map
package/dist/da-DK.mjs CHANGED
@@ -5,4 +5,4 @@ $692a4298b6b649a2$exports = {
5
5
 
6
6
 
7
7
  export {$692a4298b6b649a2$exports as default};
8
- //# sourceMappingURL=da-DK.mjs.map
8
+ //# sourceMappingURL=da-DK.module.js.map
package/dist/de-DE.mjs CHANGED
@@ -5,4 +5,4 @@ $1c6e1539193f1243$exports = {
5
5
 
6
6
 
7
7
  export {$1c6e1539193f1243$exports as default};
8
- //# sourceMappingURL=de-DE.mjs.map
8
+ //# sourceMappingURL=de-DE.module.js.map
package/dist/el-GR.mjs CHANGED
@@ -5,4 +5,4 @@ $1e8678632c464b6d$exports = {
5
5
 
6
6
 
7
7
  export {$1e8678632c464b6d$exports as default};
8
- //# sourceMappingURL=el-GR.mjs.map
8
+ //# sourceMappingURL=el-GR.module.js.map
package/dist/en-US.mjs CHANGED
@@ -5,4 +5,4 @@ $4adc85d9bf5b9eed$exports = {
5
5
 
6
6
 
7
7
  export {$4adc85d9bf5b9eed$exports as default};
8
- //# sourceMappingURL=en-US.mjs.map
8
+ //# sourceMappingURL=en-US.module.js.map
package/dist/es-ES.mjs CHANGED
@@ -5,4 +5,4 @@ $41c4b2bb61dafbca$exports = {
5
5
 
6
6
 
7
7
  export {$41c4b2bb61dafbca$exports as default};
8
- //# sourceMappingURL=es-ES.mjs.map
8
+ //# sourceMappingURL=es-ES.module.js.map
package/dist/et-EE.mjs CHANGED
@@ -5,4 +5,4 @@ $405f8b24f5dd2a60$exports = {
5
5
 
6
6
 
7
7
  export {$405f8b24f5dd2a60$exports as default};
8
- //# sourceMappingURL=et-EE.mjs.map
8
+ //# sourceMappingURL=et-EE.module.js.map
package/dist/fi-FI.mjs CHANGED
@@ -5,4 +5,4 @@ $7efe3ed02b9b9dd4$exports = {
5
5
 
6
6
 
7
7
  export {$7efe3ed02b9b9dd4$exports as default};
8
- //# sourceMappingURL=fi-FI.mjs.map
8
+ //# sourceMappingURL=fi-FI.module.js.map
package/dist/fr-FR.mjs CHANGED
@@ -5,4 +5,4 @@ $99fc4c101d92daf3$exports = {
5
5
 
6
6
 
7
7
  export {$99fc4c101d92daf3$exports as default};
8
- //# sourceMappingURL=fr-FR.mjs.map
8
+ //# sourceMappingURL=fr-FR.module.js.map
package/dist/he-IL.mjs CHANGED
@@ -5,4 +5,4 @@ $f9e155e6e8cacaa2$exports = {
5
5
 
6
6
 
7
7
  export {$f9e155e6e8cacaa2$exports as default};
8
- //# sourceMappingURL=he-IL.mjs.map
8
+ //# sourceMappingURL=he-IL.module.js.map
package/dist/hr-HR.mjs CHANGED
@@ -5,4 +5,4 @@ $c31b5e8e9a249fd5$exports = {
5
5
 
6
6
 
7
7
  export {$c31b5e8e9a249fd5$exports as default};
8
- //# sourceMappingURL=hr-HR.mjs.map
8
+ //# sourceMappingURL=hr-HR.module.js.map
package/dist/hu-HU.mjs CHANGED
@@ -5,4 +5,4 @@ $9c5435bc17499bd9$exports = {
5
5
 
6
6
 
7
7
  export {$9c5435bc17499bd9$exports as default};
8
- //# sourceMappingURL=hu-HU.mjs.map
8
+ //# sourceMappingURL=hu-HU.module.js.map
@@ -107,4 +107,4 @@ $a99895ee3dc79e61$exports = {
107
107
 
108
108
 
109
109
  export {$a99895ee3dc79e61$exports as default};
110
- //# sourceMappingURL=intlStrings.mjs.map
110
+ //# sourceMappingURL=intlStrings.module.js.map
package/dist/it-IT.mjs CHANGED
@@ -5,4 +5,4 @@ $6d1fc8e84d8165e1$exports = {
5
5
 
6
6
 
7
7
  export {$6d1fc8e84d8165e1$exports as default};
8
- //# sourceMappingURL=it-IT.mjs.map
8
+ //# sourceMappingURL=it-IT.module.js.map
package/dist/ja-JP.mjs CHANGED
@@ -5,4 +5,4 @@ $46ea6b3641b83e71$exports = {
5
5
 
6
6
 
7
7
  export {$46ea6b3641b83e71$exports as default};
8
- //# sourceMappingURL=ja-JP.mjs.map
8
+ //# sourceMappingURL=ja-JP.module.js.map
package/dist/ko-KR.mjs CHANGED
@@ -5,4 +5,4 @@ $0e3cc9a288289dc5$exports = {
5
5
 
6
6
 
7
7
  export {$0e3cc9a288289dc5$exports as default};
8
- //# sourceMappingURL=ko-KR.mjs.map
8
+ //# sourceMappingURL=ko-KR.module.js.map
package/dist/lt-LT.mjs CHANGED
@@ -5,4 +5,4 @@ $4ff2bb25c0089ffb$exports = {
5
5
 
6
6
 
7
7
  export {$4ff2bb25c0089ffb$exports as default};
8
- //# sourceMappingURL=lt-LT.mjs.map
8
+ //# sourceMappingURL=lt-LT.module.js.map
package/dist/lv-LV.mjs CHANGED
@@ -5,4 +5,4 @@ $6cf33cd4c010a2fb$exports = {
5
5
 
6
6
 
7
7
  export {$6cf33cd4c010a2fb$exports as default};
8
- //# sourceMappingURL=lv-LV.mjs.map
8
+ //# sourceMappingURL=lv-LV.module.js.map
package/dist/nb-NO.mjs CHANGED
@@ -5,4 +5,4 @@ $5a9f8486f8b8837e$exports = {
5
5
 
6
6
 
7
7
  export {$5a9f8486f8b8837e$exports as default};
8
- //# sourceMappingURL=nb-NO.mjs.map
8
+ //# sourceMappingURL=nb-NO.module.js.map
package/dist/nl-NL.mjs CHANGED
@@ -5,4 +5,4 @@ $583f94d807f6ecea$exports = {
5
5
 
6
6
 
7
7
  export {$583f94d807f6ecea$exports as default};
8
- //# sourceMappingURL=nl-NL.mjs.map
8
+ //# sourceMappingURL=nl-NL.module.js.map
package/dist/pl-PL.mjs CHANGED
@@ -5,4 +5,4 @@ $cc4dcfeea2b4050d$exports = {
5
5
 
6
6
 
7
7
  export {$cc4dcfeea2b4050d$exports as default};
8
- //# sourceMappingURL=pl-PL.mjs.map
8
+ //# sourceMappingURL=pl-PL.module.js.map
package/dist/pt-BR.mjs CHANGED
@@ -5,4 +5,4 @@ $68ac2954d56e12b4$exports = {
5
5
 
6
6
 
7
7
  export {$68ac2954d56e12b4$exports as default};
8
- //# sourceMappingURL=pt-BR.mjs.map
8
+ //# sourceMappingURL=pt-BR.module.js.map
package/dist/pt-PT.mjs CHANGED
@@ -5,4 +5,4 @@ $fdb0616f309780b0$exports = {
5
5
 
6
6
 
7
7
  export {$fdb0616f309780b0$exports as default};
8
- //# sourceMappingURL=pt-PT.mjs.map
8
+ //# sourceMappingURL=pt-PT.module.js.map
package/dist/ro-RO.mjs CHANGED
@@ -5,4 +5,4 @@ $fe1eccf4ee1d6f52$exports = {
5
5
 
6
6
 
7
7
  export {$fe1eccf4ee1d6f52$exports as default};
8
- //# sourceMappingURL=ro-RO.mjs.map
8
+ //# sourceMappingURL=ro-RO.module.js.map
package/dist/ru-RU.mjs CHANGED
@@ -5,4 +5,4 @@ $a38b6c4e18725976$exports = {
5
5
 
6
6
 
7
7
  export {$a38b6c4e18725976$exports as default};
8
- //# sourceMappingURL=ru-RU.mjs.map
8
+ //# sourceMappingURL=ru-RU.module.js.map
package/dist/sk-SK.mjs CHANGED
@@ -5,4 +5,4 @@ $6c14ae2b766b652c$exports = {
5
5
 
6
6
 
7
7
  export {$6c14ae2b766b652c$exports as default};
8
- //# sourceMappingURL=sk-SK.mjs.map
8
+ //# sourceMappingURL=sk-SK.module.js.map
package/dist/sl-SI.mjs CHANGED
@@ -5,4 +5,4 @@ $8f1c9692e16dc5eb$exports = {
5
5
 
6
6
 
7
7
  export {$8f1c9692e16dc5eb$exports as default};
8
- //# sourceMappingURL=sl-SI.mjs.map
8
+ //# sourceMappingURL=sl-SI.module.js.map
package/dist/sr-SP.mjs CHANGED
@@ -5,4 +5,4 @@ $d2aa7abea627cafa$exports = {
5
5
 
6
6
 
7
7
  export {$d2aa7abea627cafa$exports as default};
8
- //# sourceMappingURL=sr-SP.mjs.map
8
+ //# sourceMappingURL=sr-SP.module.js.map
package/dist/sv-SE.mjs CHANGED
@@ -5,4 +5,4 @@ $676b82e4b56408e6$exports = {
5
5
 
6
6
 
7
7
  export {$676b82e4b56408e6$exports as default};
8
- //# sourceMappingURL=sv-SE.mjs.map
8
+ //# sourceMappingURL=sv-SE.module.js.map
package/dist/tr-TR.mjs CHANGED
@@ -5,4 +5,4 @@ $14c9042552d7ce08$exports = {
5
5
 
6
6
 
7
7
  export {$14c9042552d7ce08$exports as default};
8
- //# sourceMappingURL=tr-TR.mjs.map
8
+ //# sourceMappingURL=tr-TR.module.js.map
package/dist/uk-UA.mjs CHANGED
@@ -5,4 +5,4 @@ $393254ebcb66c9f5$exports = {
5
5
 
6
6
 
7
7
  export {$393254ebcb66c9f5$exports as default};
8
- //# sourceMappingURL=uk-UA.mjs.map
8
+ //# sourceMappingURL=uk-UA.module.js.map
@@ -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))), "@react-aria/spinbutton");
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 "PageUp":
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 "ArrowUp":
52
- case "Up":
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 "PageDown":
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 "ArrowDown":
66
- case "Down":
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 "Home":
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 "End":
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 === "" ? stringFormatter.format("Empty") : (textValue || `${value}`).replace("-", "\u2212");
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)("assertive");
101
- (0, $2pZbw$reactarialiveannouncer.announce)(ariaTextValue, "assertive");
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: "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,
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, "contextmenu", cancelContextMenu);
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, "contextmenu", cancelContextMenu);
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;IACpB,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,gDAA0B,EAAE,CAAA,GAAA,mDAAW,GAAG;IAElE,MAAM,aAAa,IAAM,aAAa,OAAO,OAAO;IAEpD,4CAA4C;IAC5C,CAAA,GAAA,sBAAQ,EAAE;QACR,OAAO,IAAM;IACf,GAAG,E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CAAC;QACC;QACA,wBAAA,kCAAA;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,MAAM,wBAAwB,CAAA,GAAA,oCAAa,EACzC,CAAC;QACC;QACA,wBAAA,kCAAA;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,wCAAiB;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>();\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"}
1
+ {"mappings":";;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;AA4BM,SAAS,0CACd,KAAsB;IAEtB,MAAM,SAAS,CAAA,GAAA,mBAAK,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,gDAA0B,EAAE,CAAA,GAAA,mDAAW,GAAG;IAElE,MAAM,aAAa,IAAM,aAAa,OAAO,OAAO;IAEpD,4CAA4C;IAC5C,CAAA,GAAA,sBAAQ,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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ClG,sBAAsB;QAE1B,GACA;IAEJ;IAGF,MAAM,wBAAwB,CAAA,GAAA,oCAAa,EACzC,CAAC;QACC;QACA,wBAAA,kCAAA;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,wCAAiB;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.main.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))), "@react-aria/spinbutton");
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 "PageUp":
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 "ArrowUp":
46
- case "Up":
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 "PageDown":
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 "ArrowDown":
60
- case "Down":
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 "Home":
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 "End":
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 === "" ? stringFormatter.format("Empty") : (textValue || `${value}`).replace("-", "\u2212");
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)("assertive");
95
- (0, $5rwhf$announce)(ariaTextValue, "assertive");
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: "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,
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, "contextmenu", cancelContextMenu);
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, "contextmenu", cancelContextMenu);
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.mjs.map
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))), "@react-aria/spinbutton");
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 "PageUp":
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 "ArrowUp":
46
- case "Up":
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 "PageDown":
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 "ArrowDown":
60
- case "Down":
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 "Home":
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 "End":
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 === "" ? stringFormatter.format("Empty") : (textValue || `${value}`).replace("-", "\u2212");
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)("assertive");
95
- (0, $5rwhf$announce)(ariaTextValue, "assertive");
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: "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,
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, "contextmenu", cancelContextMenu);
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, "contextmenu", cancelContextMenu);
149
+ addGlobalListener(window, 'contextmenu', cancelContextMenu);
150
150
  },
151
151
  onPressEnd: ()=>{
152
152
  clearAsync();
@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AAiB,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>();\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"}
1
+ {"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;AA4BM,SAAS,0CACd,KAAsB;IAEtB,MAAM,SAAS,CAAA,GAAA,aAAK,EAAU;IAC9B,IAAI,SACF,KAAK,aACL,SAAS,YACT,QAAQ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;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
@@ -5,4 +5,4 @@ $d49d621f310cf6ce$exports = {
5
5
 
6
6
 
7
7
  export {$d49d621f310cf6ce$exports as default};
8
- //# sourceMappingURL=zh-CN.mjs.map
8
+ //# sourceMappingURL=zh-CN.module.js.map
package/dist/zh-TW.mjs CHANGED
@@ -5,4 +5,4 @@ $94b60c866ca5dfe6$exports = {
5
5
 
6
6
 
7
7
  export {$94b60c866ca5dfe6$exports as default};
8
- //# sourceMappingURL=zh-TW.mjs.map
8
+ //# sourceMappingURL=zh-TW.module.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-aria/spinbutton",
3
- "version": "3.6.4",
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.11.0",
26
- "@react-aria/live-announcer": "^3.3.3",
27
- "@react-aria/utils": "^3.24.0",
28
- "@react-types/button": "^3.9.3",
29
- "@react-types/shared": "^3.23.0",
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": "f645f29edc1322153fd60af4640cbcab1d992dbd"
39
+ "gitHead": "86d80e3216bc32e75108831cf3a5a720bc849206"
40
40
  }
@@ -39,7 +39,7 @@ export interface SpinbuttonAria {
39
39
  export function useSpinButton(
40
40
  props: SpinButtonProps
41
41
  ): SpinbuttonAria {
42
- const _async = useRef<number>();
42
+ const _async = useRef<number>(undefined);
43
43
  let {
44
44
  value,
45
45
  textValue,