@react-aria/textfield 3.3.1 → 3.5.2

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/main.js CHANGED
@@ -1,233 +1,206 @@
1
- var {
2
- useEffect,
3
- useRef
4
- } = require("react");
1
+ var $5GtoM$reactariautils = require("@react-aria/utils");
2
+ var $5GtoM$reactarialabel = require("@react-aria/label");
3
+ var $5GtoM$reactariafocus = require("@react-aria/focus");
4
+ var $5GtoM$react = require("react");
5
+
6
+ function $parcel$exportWildcard(dest, source) {
7
+ Object.keys(source).forEach(function(key) {
8
+ if (key === 'default' || key === '__esModule' || dest.hasOwnProperty(key)) {
9
+ return;
10
+ }
5
11
 
6
- var {
7
- useLabel
8
- } = require("@react-aria/label");
12
+ Object.defineProperty(dest, key, {
13
+ enumerable: true,
14
+ get: function get() {
15
+ return source[key];
16
+ }
17
+ });
18
+ });
9
19
 
10
- var {
11
- useFocusable
12
- } = require("@react-aria/focus");
20
+ return dest;
21
+ }
22
+ function $parcel$export(e, n, v, s) {
23
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
24
+ }
25
+ var $bebe07d66fab856a$exports = {};
13
26
 
14
- var {
15
- filterDOMProps,
16
- mergeProps
17
- } = require("@react-aria/utils");
27
+ $parcel$export($bebe07d66fab856a$exports, "useTextField", () => $bebe07d66fab856a$export$712718f7aec83d5);
18
28
 
19
- var _babelRuntimeHelpersExtends = $parcel$interopDefault(require("@babel/runtime/helpers/extends"));
20
29
 
21
- function $parcel$interopDefault(a) {
22
- return a && a.__esModule ? a.default : a;
23
- }
24
30
 
25
- /**
26
- * Provides the behavior and accessibility implementation for a text field.
27
- * @param props - Props for the text field.
28
- * @param ref - Ref to the HTML input or textarea element.
29
- */
30
- function useTextField(props, ref) {
31
- let {
32
- inputElementType = 'input',
33
- isDisabled = false,
34
- isRequired = false,
35
- isReadOnly = false,
36
- validationState,
37
- type = 'text',
38
- onChange: _onChange = () => {}
39
- } = props;
40
- let {
41
- focusableProps
42
- } = useFocusable(props, ref);
43
- let {
44
- labelProps,
45
- fieldProps
46
- } = useLabel(props);
47
- let domProps = filterDOMProps(props, {
48
- labelable: true
49
- });
50
- const inputOnlyProps = {
51
- type,
52
- pattern: props.pattern
53
- };
54
- return {
55
- labelProps,
56
- inputProps: mergeProps(domProps, inputElementType === 'input' && inputOnlyProps, _babelRuntimeHelpersExtends({
57
- disabled: isDisabled,
58
- readOnly: isReadOnly,
59
- 'aria-required': isRequired || undefined,
60
- 'aria-invalid': validationState === 'invalid' || undefined,
61
- 'aria-errormessage': props['aria-errormessage'],
62
- 'aria-activedescendant': props['aria-activedescendant'],
63
- 'aria-autocomplete': props['aria-autocomplete'],
64
- 'aria-haspopup': props['aria-haspopup'],
65
- value: props.value,
66
- defaultValue: props.value ? undefined : props.defaultValue,
67
- onChange: e => _onChange(e.target.value),
68
- autoComplete: props.autoComplete,
69
- maxLength: props.maxLength,
70
- minLength: props.minLength,
71
- name: props.name,
72
- placeholder: props.placeholder,
73
- inputMode: props.inputMode,
74
- // Clipboard events
75
- onCopy: props.onCopy,
76
- onCut: props.onCut,
77
- onPaste: props.onPaste,
78
- // Composition events
79
- onCompositionEnd: props.onCompositionEnd,
80
- onCompositionStart: props.onCompositionStart,
81
- onCompositionUpdate: props.onCompositionUpdate,
82
- // Selection events
83
- onSelect: props.onSelect,
84
- // Input events
85
- onBeforeInput: props.onBeforeInput,
86
- onInput: props.onInput
87
- }, focusableProps, fieldProps))
88
- };
31
+ function $bebe07d66fab856a$export$712718f7aec83d5(props, ref) {
32
+ let { inputElementType: inputElementType = 'input' , isDisabled: isDisabled = false , isRequired: isRequired = false , isReadOnly: isReadOnly = false , validationState: validationState , type: type = 'text' , onChange: onChange = ()=>{
33
+ } } = props;
34
+ let { focusableProps: focusableProps } = $5GtoM$reactariafocus.useFocusable(props, ref);
35
+ let { labelProps: labelProps , fieldProps: fieldProps , descriptionProps: descriptionProps , errorMessageProps: errorMessageProps } = $5GtoM$reactarialabel.useField(props);
36
+ let domProps = $5GtoM$reactariautils.filterDOMProps(props, {
37
+ labelable: true
38
+ });
39
+ const inputOnlyProps = {
40
+ type: type,
41
+ pattern: props.pattern
42
+ };
43
+ return {
44
+ labelProps: labelProps,
45
+ inputProps: $5GtoM$reactariautils.mergeProps(domProps, inputElementType === 'input' && inputOnlyProps, {
46
+ disabled: isDisabled,
47
+ readOnly: isReadOnly,
48
+ 'aria-required': isRequired || undefined,
49
+ 'aria-invalid': validationState === 'invalid' || undefined,
50
+ 'aria-errormessage': props['aria-errormessage'],
51
+ 'aria-activedescendant': props['aria-activedescendant'],
52
+ 'aria-autocomplete': props['aria-autocomplete'],
53
+ 'aria-haspopup': props['aria-haspopup'],
54
+ value: props.value,
55
+ defaultValue: props.value ? undefined : props.defaultValue,
56
+ onChange: (e)=>onChange(e.target.value)
57
+ ,
58
+ autoComplete: props.autoComplete,
59
+ maxLength: props.maxLength,
60
+ minLength: props.minLength,
61
+ name: props.name,
62
+ placeholder: props.placeholder,
63
+ inputMode: props.inputMode,
64
+ // Clipboard events
65
+ onCopy: props.onCopy,
66
+ onCut: props.onCut,
67
+ onPaste: props.onPaste,
68
+ // Composition events
69
+ onCompositionEnd: props.onCompositionEnd,
70
+ onCompositionStart: props.onCompositionStart,
71
+ onCompositionUpdate: props.onCompositionUpdate,
72
+ // Selection events
73
+ onSelect: props.onSelect,
74
+ // Input events
75
+ onBeforeInput: props.onBeforeInput,
76
+ onInput: props.onInput,
77
+ ...focusableProps,
78
+ ...fieldProps
79
+ }),
80
+ descriptionProps: descriptionProps,
81
+ errorMessageProps: errorMessageProps
82
+ };
89
83
  }
90
84
 
91
- exports.useTextField = useTextField;
92
85
 
93
- function $e12a6959a5c62c5783c0140bc17c4eda$var$supportsNativeBeforeInputEvent() {
94
- return typeof window !== 'undefined' && window.InputEvent && // @ts-ignore
95
- typeof InputEvent.prototype.getTargetRanges === 'function';
96
- }
86
+ var $264edc939d19dce3$exports = {};
97
87
 
98
- function useFormattedTextField(props, state, inputRef) {
99
- let stateRef = useRef(state);
100
- stateRef.current = state; // All browsers implement the 'beforeinput' event natively except Firefox
101
- // (currently behind a flag as of Firefox 84). React's polyfill does not
102
- // run in all cases that the native event fires, e.g. when deleting text.
103
- // Use the native event if available so that we can prevent invalid deletions.
104
- // We do not attempt to polyfill this in Firefox since it would be very complicated,
105
- // the benefit of doing so is fairly minor, and it's going to be natively supported soon.
106
-
107
- useEffect(() => {
108
- if (!$e12a6959a5c62c5783c0140bc17c4eda$var$supportsNativeBeforeInputEvent()) {
109
- return;
110
- }
88
+ $parcel$export($264edc939d19dce3$exports, "useFormattedTextField", () => $264edc939d19dce3$export$4f384c9210e583c3);
111
89
 
112
- let input = inputRef.current;
113
-
114
- let onBeforeInput = e => {
115
- let state = stateRef.current; // Compute the next value of the input if the event is allowed to proceed.
116
- // See https://www.w3.org/TR/input-events-2/#interface-InputEvent-Attributes for a full list of input types.
117
-
118
- let nextValue;
119
-
120
- switch (e.inputType) {
121
- case 'historyUndo':
122
- case 'historyRedo':
123
- // Explicitly allow undo/redo. e.data is null in this case, but there's no need to validate,
124
- // because presumably the input would have already been validated previously.
125
- return;
126
-
127
- case 'deleteContent':
128
- case 'deleteByCut':
129
- case 'deleteByDrag':
130
- nextValue = input.value.slice(0, input.selectionStart) + input.value.slice(input.selectionEnd);
131
- break;
132
-
133
- case 'deleteContentForward':
134
- // This is potentially incorrect, since the browser may actually delete more than a single UTF-16
135
- // character. In reality, a full Unicode grapheme cluster consisting of multiple UTF-16 characters
136
- // or code points may be deleted. However, in our currently supported locales, there are no such cases.
137
- // If we support additional locales in the future, this may need to change.
138
- nextValue = input.selectionEnd === input.selectionStart ? input.value.slice(0, input.selectionStart) + input.value.slice(input.selectionEnd + 1) : input.value.slice(0, input.selectionStart) + input.value.slice(input.selectionEnd);
139
- break;
140
-
141
- case 'deleteContentBackward':
142
- nextValue = input.selectionEnd === input.selectionStart ? input.value.slice(0, input.selectionStart - 1) + input.value.slice(input.selectionStart) : input.value.slice(0, input.selectionStart) + input.value.slice(input.selectionEnd);
143
- break;
144
-
145
- case 'deleteSoftLineBackward':
146
- case 'deleteHardLineBackward':
147
- nextValue = input.value.slice(input.selectionStart);
148
- break;
149
-
150
- default:
151
- if (e.data != null) {
152
- nextValue = input.value.slice(0, input.selectionStart) + e.data + input.value.slice(input.selectionEnd);
153
- }
154
-
155
- break;
156
- } // If we did not compute a value, or the new value is invalid, prevent the event
157
- // so that the browser does not update the input text, move the selection, or add to
158
- // the undo/redo stack.
159
-
160
-
161
- if (nextValue == null || !state.validate(nextValue)) {
162
- e.preventDefault();
163
- }
164
- };
165
90
 
166
- input.addEventListener('beforeinput', onBeforeInput, false);
167
- return () => {
168
- input.removeEventListener('beforeinput', onBeforeInput, false);
169
- };
170
- }, [inputRef, stateRef]);
171
- let onBeforeInput = !$e12a6959a5c62c5783c0140bc17c4eda$var$supportsNativeBeforeInputEvent() ? e => {
172
- let nextValue = e.target.value.slice(0, e.target.selectionStart) + e.data + e.target.value.slice(e.target.selectionEnd);
173
91
 
174
- if (!state.validate(nextValue)) {
175
- e.preventDefault();
176
- }
177
- } : null;
178
- let {
179
- labelProps,
180
- inputProps: textFieldProps
181
- } = useTextField(props, inputRef);
182
- let compositionStartState = useRef(null);
183
- return {
184
- inputProps: mergeProps(textFieldProps, {
185
- onBeforeInput,
186
-
187
- onCompositionStart() {
188
- // Chrome does not implement Input Events Level 2, which specifies the insertFromComposition
189
- // and deleteByComposition inputType values for the beforeinput event. These are meant to occur
190
- // at the end of a composition (e.g. Pinyin IME, Android auto correct, etc.), and crucially, are
191
- // cancelable. The insertCompositionText and deleteCompositionText input types are not cancelable,
192
- // nor would we want to cancel them because the input from the user is incomplete at that point.
193
- // In Safari, insertFromComposition/deleteFromComposition will fire, however, allowing us to cancel
194
- // the final composition result if it is invalid. As a fallback for Chrome and Firefox, which either
195
- // don't support Input Events Level 2, or beforeinput at all, we store the state of the input when
196
- // the compositionstart event fires, and undo the changes in compositionend (below) if it is invalid.
197
- // Unfortunately, this messes up the undo/redo stack, but until insertFromComposition/deleteByComposition
198
- // are implemented, there is no other way to prevent composed input.
199
- // See https://bugs.chromium.org/p/chromium/issues/detail?id=1022204
200
- let {
201
- value,
202
- selectionStart,
203
- selectionEnd
204
- } = inputRef.current;
205
- compositionStartState.current = {
206
- value,
207
- selectionStart,
208
- selectionEnd
92
+ function $264edc939d19dce3$var$supportsNativeBeforeInputEvent() {
93
+ return typeof window !== 'undefined' && window.InputEvent && // @ts-ignore
94
+ typeof InputEvent.prototype.getTargetRanges === 'function';
95
+ }
96
+ function $264edc939d19dce3$export$4f384c9210e583c3(props, state1, inputRef) {
97
+ let stateRef = $5GtoM$react.useRef(state1);
98
+ stateRef.current = state1;
99
+ // All browsers implement the 'beforeinput' event natively except Firefox
100
+ // (currently behind a flag as of Firefox 84). React's polyfill does not
101
+ // run in all cases that the native event fires, e.g. when deleting text.
102
+ // Use the native event if available so that we can prevent invalid deletions.
103
+ // We do not attempt to polyfill this in Firefox since it would be very complicated,
104
+ // the benefit of doing so is fairly minor, and it's going to be natively supported soon.
105
+ $5GtoM$react.useEffect(()=>{
106
+ if (!$264edc939d19dce3$var$supportsNativeBeforeInputEvent()) return;
107
+ let input = inputRef.current;
108
+ let onBeforeInput = (e)=>{
109
+ let state = stateRef.current;
110
+ // Compute the next value of the input if the event is allowed to proceed.
111
+ // See https://www.w3.org/TR/input-events-2/#interface-InputEvent-Attributes for a full list of input types.
112
+ let nextValue;
113
+ switch(e.inputType){
114
+ case 'historyUndo':
115
+ case 'historyRedo':
116
+ // Explicitly allow undo/redo. e.data is null in this case, but there's no need to validate,
117
+ // because presumably the input would have already been validated previously.
118
+ return;
119
+ case 'deleteContent':
120
+ case 'deleteByCut':
121
+ case 'deleteByDrag':
122
+ nextValue = input.value.slice(0, input.selectionStart) + input.value.slice(input.selectionEnd);
123
+ break;
124
+ case 'deleteContentForward':
125
+ // This is potentially incorrect, since the browser may actually delete more than a single UTF-16
126
+ // character. In reality, a full Unicode grapheme cluster consisting of multiple UTF-16 characters
127
+ // or code points may be deleted. However, in our currently supported locales, there are no such cases.
128
+ // If we support additional locales in the future, this may need to change.
129
+ nextValue = input.selectionEnd === input.selectionStart ? input.value.slice(0, input.selectionStart) + input.value.slice(input.selectionEnd + 1) : input.value.slice(0, input.selectionStart) + input.value.slice(input.selectionEnd);
130
+ break;
131
+ case 'deleteContentBackward':
132
+ nextValue = input.selectionEnd === input.selectionStart ? input.value.slice(0, input.selectionStart - 1) + input.value.slice(input.selectionStart) : input.value.slice(0, input.selectionStart) + input.value.slice(input.selectionEnd);
133
+ break;
134
+ case 'deleteSoftLineBackward':
135
+ case 'deleteHardLineBackward':
136
+ nextValue = input.value.slice(input.selectionStart);
137
+ break;
138
+ default:
139
+ if (e.data != null) nextValue = input.value.slice(0, input.selectionStart) + e.data + input.value.slice(input.selectionEnd);
140
+ break;
141
+ }
142
+ // If we did not compute a value, or the new value is invalid, prevent the event
143
+ // so that the browser does not update the input text, move the selection, or add to
144
+ // the undo/redo stack.
145
+ if (nextValue == null || !state.validate(nextValue)) e.preventDefault();
209
146
  };
210
- },
211
-
212
- onCompositionEnd() {
213
- if (!state.validate(inputRef.current.value)) {
214
- // Restore the input value in the DOM immediately so we can synchronously update the selection position.
215
- // But also update the value in React state as well so it is correct for future updates.
216
- let {
217
- value,
218
- selectionStart,
219
- selectionEnd
220
- } = compositionStartState.current;
221
- inputRef.current.value = value;
222
- inputRef.current.setSelectionRange(selectionStart, selectionEnd);
223
- state.setInputValue(value);
224
- }
225
- }
226
-
227
- }),
228
- labelProps
229
- };
147
+ input.addEventListener('beforeinput', onBeforeInput, false);
148
+ return ()=>{
149
+ input.removeEventListener('beforeinput', onBeforeInput, false);
150
+ };
151
+ }, [
152
+ inputRef,
153
+ stateRef
154
+ ]);
155
+ let onBeforeInput1 = !$264edc939d19dce3$var$supportsNativeBeforeInputEvent() ? (e)=>{
156
+ let nextValue = e.target.value.slice(0, e.target.selectionStart) + e.data + e.target.value.slice(e.target.selectionEnd);
157
+ if (!state1.validate(nextValue)) e.preventDefault();
158
+ } : null;
159
+ let { labelProps: labelProps , inputProps: textFieldProps , descriptionProps: descriptionProps , errorMessageProps: errorMessageProps } = $bebe07d66fab856a$export$712718f7aec83d5(props, inputRef);
160
+ let compositionStartState = $5GtoM$react.useRef(null);
161
+ return {
162
+ inputProps: $5GtoM$reactariautils.mergeProps(textFieldProps, {
163
+ onBeforeInput: onBeforeInput1,
164
+ onCompositionStart () {
165
+ // Chrome does not implement Input Events Level 2, which specifies the insertFromComposition
166
+ // and deleteByComposition inputType values for the beforeinput event. These are meant to occur
167
+ // at the end of a composition (e.g. Pinyin IME, Android auto correct, etc.), and crucially, are
168
+ // cancelable. The insertCompositionText and deleteCompositionText input types are not cancelable,
169
+ // nor would we want to cancel them because the input from the user is incomplete at that point.
170
+ // In Safari, insertFromComposition/deleteFromComposition will fire, however, allowing us to cancel
171
+ // the final composition result if it is invalid. As a fallback for Chrome and Firefox, which either
172
+ // don't support Input Events Level 2, or beforeinput at all, we store the state of the input when
173
+ // the compositionstart event fires, and undo the changes in compositionend (below) if it is invalid.
174
+ // Unfortunately, this messes up the undo/redo stack, but until insertFromComposition/deleteByComposition
175
+ // are implemented, there is no other way to prevent composed input.
176
+ // See https://bugs.chromium.org/p/chromium/issues/detail?id=1022204
177
+ let { value: value , selectionStart: selectionStart , selectionEnd: selectionEnd } = inputRef.current;
178
+ compositionStartState.current = {
179
+ value: value,
180
+ selectionStart: selectionStart,
181
+ selectionEnd: selectionEnd
182
+ };
183
+ },
184
+ onCompositionEnd () {
185
+ if (!state1.validate(inputRef.current.value)) {
186
+ // Restore the input value in the DOM immediately so we can synchronously update the selection position.
187
+ // But also update the value in React state as well so it is correct for future updates.
188
+ let { value: value , selectionStart: selectionStart , selectionEnd: selectionEnd } = compositionStartState.current;
189
+ inputRef.current.value = value;
190
+ inputRef.current.setSelectionRange(selectionStart, selectionEnd);
191
+ state1.setInputValue(value);
192
+ }
193
+ }
194
+ }),
195
+ labelProps: labelProps,
196
+ descriptionProps: descriptionProps,
197
+ errorMessageProps: errorMessageProps
198
+ };
230
199
  }
231
200
 
232
- exports.useFormattedTextField = useFormattedTextField;
201
+
202
+ $parcel$exportWildcard(module.exports, $bebe07d66fab856a$exports);
203
+ $parcel$exportWildcard(module.exports, $264edc939d19dce3$exports);
204
+
205
+
233
206
  //# sourceMappingURL=main.js.map
package/dist/main.js.map CHANGED
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,SAASA,sBAAT,CAAgCC,CAAhC,EAAmC;AACjC,SAAOA,CAAC,IAAIA,CAAC,CAACC,UAAP,GAAoBD,CAAC,CAACE,OAAtB,GAAgCF,CAAvC;AACD;;ACkCD;;;;;AAKO,SAASG,YAAT,CACLC,KADK,EAELC,GAFK,EAGU;AACf,MAAI;AACFC,IAAAA,gBAAgB,GAAG,OADjB;AAEFC,IAAAA,UAAU,GAAG,KAFX;AAGFC,IAAAA,UAAU,GAAG,KAHX;AAIFC,IAAAA,UAAU,GAAG,KAJX;AAKFC,IAAAA,eALE;AAMFC,IAAAA,IAAI,GAAG,MANL;AAOFC,IAAAA,QAAQ,EAARA,SAAQ,GAAG,MAAM,CAAE;AAPjB,MAQAR,KARJ;AASA,MAAI;AAACS,IAAAA;AAAD,MAAmBC,YAAY,CAACV,KAAD,EAAQC,GAAR,CAAnC;AACA,MAAI;AAACU,IAAAA,UAAD;AAAaC,IAAAA;AAAb,MAA2BC,QAAQ,CAACb,KAAD,CAAvC;AACA,MAAIc,QAAQ,GAAGC,cAAc,CAACf,KAAD,EAAQ;AAACgB,IAAAA,SAAS,EAAE;AAAZ,GAAR,CAA7B;AAEA,QAAMC,cAAc,GAAG;AACrBV,IAAAA,IADqB;AAErBW,IAAAA,OAAO,EAAElB,KAAK,CAACkB;AAFM,GAAvB;AAKA,SAAO;AACLP,IAAAA,UADK;AAELQ,IAAAA,UAAU,EAAEC,UAAU,CACpBN,QADoB,EAEpB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A;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,YAAI;AAACd,UAAAA,KAAD;AAAQmC,UAAAA,cAAR;AAAwBC,UAAAA;AAAxB,YAAwCV,QAAQ,CAACG,OAArD;AACAc,QAAAA,qBAAqB,CAACd,OAAtB,GAAgC;AAAC7B,UAAAA,KAAD;AAAQmC,UAAAA,cAAR;AAAwBC,UAAAA;AAAxB,SAAhC;AACD,OAjBH;;AAkBEvB,MAAAA,gBAAgB,GAAG;AACjB,YAAI,CAACY,KAAK,CAACa,QAAN,CAAeZ,QAAQ,CAACG,OAAT,CAAiB7B,KAAhC,CAAL,EAA6C;AAC3C;AACA;AACA,cAAI;AAACA,YAAAA,KAAD;AAAQmC,YAAAA,cAAR;AAAwBC,YAAAA;AAAxB,cAAwCO,qBAAqB,CAACd,OAAlE;AACAH,UAAAA,QAAQ,CAACG,OAAT,CAAiB7B,KAAjB,GAAyBA,KAAzB;AACA0B,UAAAA,QAAQ,CAACG,OAAT,CAAiBe,iBAAjB,CAAmCT,cAAnC,EAAmDC,YAAnD;AACAX,UAAAA,KAAK,CAACoB,aAAN,CAAoB7C,KAApB;AACD;AACF;;AA3BH,KAFoB,CADjB;AAiCLb,IAAAA;AAjCK,GAAP;AAmCD","sources":["./node_modules/@parcel/scope-hoisting/lib/helpers.js","./packages/@react-aria/textfield/src/useTextField.ts","./packages/@react-aria/textfield/src/useFormattedTextField.ts"],"sourcesContent":["function $parcel$interopDefault(a) {\n return a && a.__esModule ? a.default : a;\n}\n\nfunction $parcel$defineInteropFlag(a) {\n Object.defineProperty(a, '__esModule', {value: true});\n}\n\nfunction $parcel$exportWildcard(dest, source) {\n Object.keys(source).forEach(function(key) {\n if (key === 'default' || key === '__esModule') {\n return;\n }\n\n Object.defineProperty(dest, key, {\n enumerable: true,\n get: function get() {\n return source[key];\n },\n });\n });\n\n return dest;\n}\n\nfunction $parcel$missingModule(name) {\n var err = new Error(\"Cannot find module '\" + name + \"'\");\n err.code = 'MODULE_NOT_FOUND';\n throw err;\n}\n\nvar $parcel$global =\n typeof globalThis !== 'undefined'\n ? globalThis\n : typeof self !== 'undefined'\n ? self\n : typeof window !== 'undefined'\n ? window\n : typeof global !== 'undefined'\n ? global\n : {};\n","/*\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 {AriaTextFieldProps} from '@react-types/textfield';\nimport {ChangeEvent, InputHTMLAttributes, LabelHTMLAttributes, RefObject, TextareaHTMLAttributes} from 'react';\nimport {ElementType} from 'react';\nimport {filterDOMProps, mergeProps} from '@react-aria/utils';\nimport {useFocusable} from '@react-aria/focus';\nimport {useLabel} from '@react-aria/label';\n\nexport interface TextFieldAria {\n /** Props for the input element. */\n inputProps: InputHTMLAttributes<HTMLInputElement> | TextareaHTMLAttributes<HTMLTextAreaElement>,\n /** Props for the text field's visible label element (if any). */\n labelProps: LabelHTMLAttributes<HTMLLabelElement>\n}\n\ninterface AriaTextFieldOptions extends AriaTextFieldProps {\n /**\n * The HTML element used to render the input, e.g. 'input', or 'textarea'.\n * It determines whether certain HTML attributes will be included in `inputProps`.\n * For example, [`type`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-type).\n * @default 'input'\n */\n inputElementType?: ElementType\n}\n\n/**\n * Provides the behavior and accessibility implementation for a text field.\n * @param props - Props for the text field.\n * @param ref - Ref to the HTML input or textarea element.\n */\nexport function useTextField(\n props: AriaTextFieldOptions,\n ref: RefObject<HTMLInputElement | HTMLTextAreaElement>\n): TextFieldAria {\n let {\n inputElementType = 'input',\n isDisabled = false,\n isRequired = false,\n isReadOnly = false,\n validationState,\n type = 'text',\n onChange = () => {}\n } = props;\n let {focusableProps} = useFocusable(props, ref);\n let {labelProps, fieldProps} = useLabel(props);\n let domProps = filterDOMProps(props, {labelable: true});\n\n const inputOnlyProps = {\n type,\n pattern: props.pattern\n };\n\n return {\n labelProps,\n inputProps: mergeProps(\n domProps,\n inputElementType === 'input' && inputOnlyProps,\n {\n disabled: isDisabled,\n readOnly: isReadOnly,\n 'aria-required': isRequired || undefined,\n 'aria-invalid': validationState === 'invalid' || undefined,\n 'aria-errormessage': props['aria-errormessage'],\n 'aria-activedescendant': props['aria-activedescendant'],\n 'aria-autocomplete': props['aria-autocomplete'],\n 'aria-haspopup': props['aria-haspopup'],\n value: props.value,\n defaultValue: props.value ? undefined : props.defaultValue,\n onChange: (e: ChangeEvent<HTMLInputElement>) => onChange(e.target.value),\n autoComplete: props.autoComplete,\n maxLength: props.maxLength,\n minLength: props.minLength,\n name: props.name,\n placeholder: props.placeholder,\n inputMode: props.inputMode,\n\n // Clipboard events\n onCopy: props.onCopy,\n onCut: props.onCut,\n onPaste: props.onPaste,\n\n // Composition events\n onCompositionEnd: props.onCompositionEnd,\n onCompositionStart: props.onCompositionStart,\n onCompositionUpdate: props.onCompositionUpdate,\n\n // Selection events\n onSelect: props.onSelect,\n\n // Input events\n onBeforeInput: props.onBeforeInput,\n onInput: props.onInput,\n ...focusableProps,\n ...fieldProps\n }\n )\n };\n}\n","/*\n * Copyright 2021 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 {AriaTextFieldProps} from '@react-types/textfield';\nimport {mergeProps} from '@react-aria/utils';\nimport {RefObject, useEffect, useRef} from 'react';\nimport {TextFieldAria, useTextField} from './useTextField';\n\ninterface FormattedTextFieldState {\n validate: (val: string) => boolean,\n setInputValue: (val: string) => void\n}\n\n\nfunction supportsNativeBeforeInputEvent() {\n return typeof window !== 'undefined' &&\n window.InputEvent &&\n // @ts-ignore\n typeof InputEvent.prototype.getTargetRanges === 'function';\n}\n\nexport function useFormattedTextField(props: AriaTextFieldProps, state: FormattedTextFieldState, inputRef: RefObject<HTMLInputElement>): TextFieldAria {\n\n let stateRef = useRef(state);\n stateRef.current = state;\n\n // All browsers implement the 'beforeinput' event natively except Firefox\n // (currently behind a flag as of Firefox 84). React's polyfill does not\n // run in all cases that the native event fires, e.g. when deleting text.\n // Use the native event if available so that we can prevent invalid deletions.\n // We do not attempt to polyfill this in Firefox since it would be very complicated,\n // the benefit of doing so is fairly minor, and it's going to be natively supported soon.\n useEffect(() => {\n if (!supportsNativeBeforeInputEvent()) {\n return;\n }\n\n let input = inputRef.current;\n\n let onBeforeInput = (e: InputEvent) => {\n let state = stateRef.current;\n\n // Compute the next value of the input if the event is allowed to proceed.\n // See https://www.w3.org/TR/input-events-2/#interface-InputEvent-Attributes for a full list of input types.\n let nextValue: string;\n switch (e.inputType) {\n case 'historyUndo':\n case 'historyRedo':\n // Explicitly allow undo/redo. e.data is null in this case, but there's no need to validate,\n // because presumably the input would have already been validated previously.\n return;\n case 'deleteContent':\n case 'deleteByCut':\n case 'deleteByDrag':\n nextValue = input.value.slice(0, input.selectionStart) + input.value.slice(input.selectionEnd);\n break;\n case 'deleteContentForward':\n // This is potentially incorrect, since the browser may actually delete more than a single UTF-16\n // character. In reality, a full Unicode grapheme cluster consisting of multiple UTF-16 characters\n // or code points may be deleted. However, in our currently supported locales, there are no such cases.\n // If we support additional locales in the future, this may need to change.\n nextValue = input.selectionEnd === input.selectionStart\n ? input.value.slice(0, input.selectionStart) + input.value.slice(input.selectionEnd + 1)\n : input.value.slice(0, input.selectionStart) + input.value.slice(input.selectionEnd);\n break;\n case 'deleteContentBackward':\n nextValue = input.selectionEnd === input.selectionStart\n ? input.value.slice(0, input.selectionStart - 1) + input.value.slice(input.selectionStart)\n : input.value.slice(0, input.selectionStart) + input.value.slice(input.selectionEnd);\n break;\n case 'deleteSoftLineBackward':\n case 'deleteHardLineBackward':\n nextValue = input.value.slice(input.selectionStart);\n break;\n default:\n if (e.data != null) {\n nextValue =\n input.value.slice(0, input.selectionStart) +\n e.data +\n input.value.slice(input.selectionEnd);\n }\n break;\n }\n\n // If we did not compute a value, or the new value is invalid, prevent the event\n // so that the browser does not update the input text, move the selection, or add to\n // the undo/redo stack.\n if (nextValue == null || !state.validate(nextValue)) {\n e.preventDefault();\n }\n };\n\n input.addEventListener('beforeinput', onBeforeInput, false);\n return () => {\n input.removeEventListener('beforeinput', onBeforeInput, false);\n };\n }, [inputRef, stateRef]);\n\n let onBeforeInput = !supportsNativeBeforeInputEvent()\n ? e => {\n let nextValue =\n e.target.value.slice(0, e.target.selectionStart) +\n e.data +\n e.target.value.slice(e.target.selectionEnd);\n\n if (!state.validate(nextValue)) {\n e.preventDefault();\n }\n }\n : null;\n\n let {labelProps, inputProps: textFieldProps} = useTextField(props, inputRef);\n\n let compositionStartState = useRef(null);\n return {\n inputProps: mergeProps(\n textFieldProps,\n {\n onBeforeInput,\n onCompositionStart() {\n // Chrome does not implement Input Events Level 2, which specifies the insertFromComposition\n // and deleteByComposition inputType values for the beforeinput event. These are meant to occur\n // at the end of a composition (e.g. Pinyin IME, Android auto correct, etc.), and crucially, are\n // cancelable. The insertCompositionText and deleteCompositionText input types are not cancelable,\n // nor would we want to cancel them because the input from the user is incomplete at that point.\n // In Safari, insertFromComposition/deleteFromComposition will fire, however, allowing us to cancel\n // the final composition result if it is invalid. As a fallback for Chrome and Firefox, which either\n // don't support Input Events Level 2, or beforeinput at all, we store the state of the input when\n // the compositionstart event fires, and undo the changes in compositionend (below) if it is invalid.\n // Unfortunately, this messes up the undo/redo stack, but until insertFromComposition/deleteByComposition\n // are implemented, there is no other way to prevent composed input.\n // See https://bugs.chromium.org/p/chromium/issues/detail?id=1022204\n let {value, selectionStart, selectionEnd} = inputRef.current;\n compositionStartState.current = {value, selectionStart, selectionEnd};\n },\n onCompositionEnd() {\n if (!state.validate(inputRef.current.value)) {\n // Restore the input value in the DOM immediately so we can synchronously update the selection position.\n // But also update the value in React state as well so it is correct for future updates.\n let {value, selectionStart, selectionEnd} = compositionStartState.current;\n inputRef.current.value = value;\n inputRef.current.setSelectionRange(selectionStart, selectionEnd);\n state.setInputValue(value);\n }\n }\n }\n ),\n labelProps\n };\n}\n"],"names":["$parcel$interopDefault","a","__esModule","default","useTextField","props","ref","inputElementType","isDisabled","isRequired","isReadOnly","validationState","type","onChange","focusableProps","useFocusable","labelProps","fieldProps","useLabel","domProps","filterDOMProps","labelable","inputOnlyProps","pattern","inputProps","mergeProps","disabled","readOnly","undefined","value","defaultValue","e","target","autoComplete","maxLength","minLength","name","placeholder","inputMode","onCopy","onCut","onPaste","onCompositionEnd","onCompositionStart","onCompositionUpdate","onSelect","onBeforeInput","onInput","supportsNativeBeforeInputEvent","window","InputEvent","prototype","getTargetRanges","useFormattedTextField","state","inputRef","stateRef","useRef","current","useEffect","input","nextValue","inputType","slice","selectionStart","selectionEnd","data","validate","preventDefault","addEventListener","removeEventListener","textFieldProps","compositionStartState","setSelectionRange","setInputValue"],"version":3,"file":"main.js.map"}
1
+ {"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SCsGgB,wCAAY,CAC1B,KAA8B,EAC9B,GAA0B,EACR,CAAC;IACnB,GAAG,CAAC,CAAC,mBACH,gBAAgB,GAAG,CAAO,qBAC1B,UAAU,GAAG,KAAK,eAClB,UAAU,GAAG,KAAK,eAClB,UAAU,GAAG,KAAK,oBAClB,eAAe,SACf,IAAI,GAAG,CAAM,kBACb,QAAQ,OAAS,CAAC;IAAA,CAAC,EACrB,CAAC,GAAqD,KAAK;IAC3D,GAAG,CAAC,CAAC,iBAAA,cAAc,EAAA,CAAC,GAAG,kCA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AC,OAAO,CAAC,KAAK,GAAG,KAAK;oBAC9B,QAAQ,CAAC,OAAO,CAAC,iBAAiB,CAAC,cAAc,EAAE,YAAY;oBAC/D,MAAK,CAAC,aAAa,CAAC,KAAK;gBAC3B,CAAC;YACH,CAAC;QACH,CAAC;oBAEH,UAAU;0BACV,gBAAgB;2BAChB,iBAAiB;IACnB,CAAC;AACH,CAAC;;","sources":["packages/@react-aria/textfield/src/index.ts","packages/@react-aria/textfield/src/useTextField.ts","packages/@react-aria/textfield/src/useFormattedTextField.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\nexport * from './useTextField';\nexport * from './useFormattedTextField';\n","/*\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 {AriaTextFieldProps} from '@react-types/textfield';\nimport {\n ChangeEvent,\n DOMFactory,\n HTMLAttributes,\n LabelHTMLAttributes,\n ReactDOM,\n RefObject\n} from 'react';\nimport {filterDOMProps, mergeProps} from '@react-aria/utils';\nimport {useField} from '@react-aria/label';\nimport {useFocusable} from '@react-aria/focus';\n\n/**\n * A map of HTML element names and their interface types.\n * For example `'a'` -> `HTMLAnchorElement`.\n */\ntype IntrinsicHTMLElements = {\n [K in keyof IntrinsicHTMLAttributes]: IntrinsicHTMLAttributes[K] extends HTMLAttributes<infer T> ? T : never\n};\n\n/**\n * A map of HTML element names and their attribute interface types.\n * For example `'a'` -> `AnchorHTMLAttributes<HTMLAnchorElement>`.\n */\ntype IntrinsicHTMLAttributes = {\n [K in keyof ReactDOM]: ReactDOM[K] extends DOMFactory<infer T, any> ? T : never\n};\n\ntype DefaultElementType = 'input';\n\n/**\n * The intrinsic HTML element names that `useTextField` supports; e.g. `input`,\n * `textarea`.\n */\ntype TextFieldIntrinsicElements = keyof Pick<IntrinsicHTMLElements, 'input' | 'textarea'>;\n\n /**\n * The HTML element interfaces that `useTextField` supports based on what is\n * defined for `TextFieldIntrinsicElements`; e.g. `HTMLInputElement`,\n * `HTMLTextAreaElement`.\n */\ntype TextFieldHTMLElementType = Pick<IntrinsicHTMLElements, TextFieldIntrinsicElements>;\n\n /**\n * The HTML attributes interfaces that `useTextField` supports based on what\n * is defined for `TextFieldIntrinsicElements`; e.g. `InputHTMLAttributes`,\n * `TextareaHTMLAttributes`.\n */\ntype TextFieldHTMLAttributesType = Pick<IntrinsicHTMLAttributes, TextFieldIntrinsicElements>;\n\n/**\n * The type of `inputProps` returned by `useTextField`; e.g. `InputHTMLAttributes`,\n * `TextareaHTMLAttributes`.\n */\ntype TextFieldInputProps<T extends TextFieldIntrinsicElements> = TextFieldHTMLAttributesType[T];\n\ninterface AriaTextFieldOptions<T extends TextFieldIntrinsicElements> extends AriaTextFieldProps {\n /**\n * The HTML element used to render the input, e.g. 'input', or 'textarea'.\n * It determines whether certain HTML attributes will be included in `inputProps`.\n * For example, [`type`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-type).\n * @default 'input'\n */\n inputElementType?: T\n}\n\n/**\n * The type of `ref` object that can be passed to `useTextField` based on the given\n * intrinsic HTML element name; e.g.`RefObject<HTMLInputElement>`,\n * `RefObject<HTMLTextAreaElement>`.\n */\ntype TextFieldRefObject<T extends TextFieldIntrinsicElements> = RefObject<TextFieldHTMLElementType[T]>;\n\nexport interface TextFieldAria<T extends TextFieldIntrinsicElements = DefaultElementType> {\n /** Props for the input element. */\n inputProps: TextFieldInputProps<T>,\n /** Props for the text field's visible label element, if any. */\n labelProps: LabelHTMLAttributes<HTMLLabelElement>,\n /** Props for the text field's description element, if any. */\n descriptionProps: HTMLAttributes<HTMLElement>,\n /** Props for the text field's error message element, if any. */\n errorMessageProps: HTMLAttributes<HTMLElement>\n}\n\n/**\n * Provides the behavior and accessibility implementation for a text field.\n * @param props - Props for the text field.\n * @param ref - Ref to the HTML input or textarea element.\n */\nexport function useTextField<T extends TextFieldIntrinsicElements = DefaultElementType>(\n props: AriaTextFieldOptions<T>,\n ref: TextFieldRefObject<T>\n): TextFieldAria<T> {\n let {\n inputElementType = 'input',\n isDisabled = false,\n isRequired = false,\n isReadOnly = false,\n validationState,\n type = 'text',\n onChange = () => {}\n }: AriaTextFieldOptions<TextFieldIntrinsicElements> = props;\n let {focusableProps} = useFocusable(props, ref);\n let {labelProps, fieldProps, descriptionProps, errorMessageProps} = useField(props);\n let domProps = filterDOMProps(props, {labelable: true});\n\n const inputOnlyProps = {\n type,\n pattern: props.pattern\n };\n\n return {\n labelProps,\n inputProps: mergeProps(\n domProps,\n inputElementType === 'input' && inputOnlyProps,\n {\n disabled: isDisabled,\n readOnly: isReadOnly,\n 'aria-required': isRequired || undefined,\n 'aria-invalid': validationState === 'invalid' || undefined,\n 'aria-errormessage': props['aria-errormessage'],\n 'aria-activedescendant': props['aria-activedescendant'],\n 'aria-autocomplete': props['aria-autocomplete'],\n 'aria-haspopup': props['aria-haspopup'],\n value: props.value,\n defaultValue: props.value ? undefined : props.defaultValue,\n onChange: (e: ChangeEvent<HTMLInputElement>) => onChange(e.target.value),\n autoComplete: props.autoComplete,\n maxLength: props.maxLength,\n minLength: props.minLength,\n name: props.name,\n placeholder: props.placeholder,\n inputMode: props.inputMode,\n\n // Clipboard events\n onCopy: props.onCopy,\n onCut: props.onCut,\n onPaste: props.onPaste,\n\n // Composition events\n onCompositionEnd: props.onCompositionEnd,\n onCompositionStart: props.onCompositionStart,\n onCompositionUpdate: props.onCompositionUpdate,\n\n // Selection events\n onSelect: props.onSelect,\n\n // Input events\n onBeforeInput: props.onBeforeInput,\n onInput: props.onInput,\n ...focusableProps,\n ...fieldProps\n }\n ),\n descriptionProps,\n errorMessageProps\n };\n}\n","/*\n * Copyright 2021 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 {AriaTextFieldProps} from '@react-types/textfield';\nimport {mergeProps} from '@react-aria/utils';\nimport {RefObject, useEffect, useRef} from 'react';\nimport {TextFieldAria, useTextField} from './useTextField';\n\ninterface FormattedTextFieldState {\n validate: (val: string) => boolean,\n setInputValue: (val: string) => void\n}\n\n\nfunction supportsNativeBeforeInputEvent() {\n return typeof window !== 'undefined' &&\n window.InputEvent &&\n // @ts-ignore\n typeof InputEvent.prototype.getTargetRanges === 'function';\n}\n\nexport function useFormattedTextField(props: AriaTextFieldProps, state: FormattedTextFieldState, inputRef: RefObject<HTMLInputElement>): TextFieldAria {\n\n let stateRef = useRef(state);\n stateRef.current = state;\n\n // All browsers implement the 'beforeinput' event natively except Firefox\n // (currently behind a flag as of Firefox 84). React's polyfill does not\n // run in all cases that the native event fires, e.g. when deleting text.\n // Use the native event if available so that we can prevent invalid deletions.\n // We do not attempt to polyfill this in Firefox since it would be very complicated,\n // the benefit of doing so is fairly minor, and it's going to be natively supported soon.\n useEffect(() => {\n if (!supportsNativeBeforeInputEvent()) {\n return;\n }\n\n let input = inputRef.current;\n\n let onBeforeInput = (e: InputEvent) => {\n let state = stateRef.current;\n\n // Compute the next value of the input if the event is allowed to proceed.\n // See https://www.w3.org/TR/input-events-2/#interface-InputEvent-Attributes for a full list of input types.\n let nextValue: string;\n switch (e.inputType) {\n case 'historyUndo':\n case 'historyRedo':\n // Explicitly allow undo/redo. e.data is null in this case, but there's no need to validate,\n // because presumably the input would have already been validated previously.\n return;\n case 'deleteContent':\n case 'deleteByCut':\n case 'deleteByDrag':\n nextValue = input.value.slice(0, input.selectionStart) + input.value.slice(input.selectionEnd);\n break;\n case 'deleteContentForward':\n // This is potentially incorrect, since the browser may actually delete more than a single UTF-16\n // character. In reality, a full Unicode grapheme cluster consisting of multiple UTF-16 characters\n // or code points may be deleted. However, in our currently supported locales, there are no such cases.\n // If we support additional locales in the future, this may need to change.\n nextValue = input.selectionEnd === input.selectionStart\n ? input.value.slice(0, input.selectionStart) + input.value.slice(input.selectionEnd + 1)\n : input.value.slice(0, input.selectionStart) + input.value.slice(input.selectionEnd);\n break;\n case 'deleteContentBackward':\n nextValue = input.selectionEnd === input.selectionStart\n ? input.value.slice(0, input.selectionStart - 1) + input.value.slice(input.selectionStart)\n : input.value.slice(0, input.selectionStart) + input.value.slice(input.selectionEnd);\n break;\n case 'deleteSoftLineBackward':\n case 'deleteHardLineBackward':\n nextValue = input.value.slice(input.selectionStart);\n break;\n default:\n if (e.data != null) {\n nextValue =\n input.value.slice(0, input.selectionStart) +\n e.data +\n input.value.slice(input.selectionEnd);\n }\n break;\n }\n\n // If we did not compute a value, or the new value is invalid, prevent the event\n // so that the browser does not update the input text, move the selection, or add to\n // the undo/redo stack.\n if (nextValue == null || !state.validate(nextValue)) {\n e.preventDefault();\n }\n };\n\n input.addEventListener('beforeinput', onBeforeInput, false);\n return () => {\n input.removeEventListener('beforeinput', onBeforeInput, false);\n };\n }, [inputRef, stateRef]);\n\n let onBeforeInput = !supportsNativeBeforeInputEvent()\n ? e => {\n let nextValue =\n e.target.value.slice(0, e.target.selectionStart) +\n e.data +\n e.target.value.slice(e.target.selectionEnd);\n\n if (!state.validate(nextValue)) {\n e.preventDefault();\n }\n }\n : null;\n\n let {labelProps, inputProps: textFieldProps, descriptionProps, errorMessageProps} = useTextField(props, inputRef);\n\n let compositionStartState = useRef(null);\n return {\n inputProps: mergeProps(\n textFieldProps,\n {\n onBeforeInput,\n onCompositionStart() {\n // Chrome does not implement Input Events Level 2, which specifies the insertFromComposition\n // and deleteByComposition inputType values for the beforeinput event. These are meant to occur\n // at the end of a composition (e.g. Pinyin IME, Android auto correct, etc.), and crucially, are\n // cancelable. The insertCompositionText and deleteCompositionText input types are not cancelable,\n // nor would we want to cancel them because the input from the user is incomplete at that point.\n // In Safari, insertFromComposition/deleteFromComposition will fire, however, allowing us to cancel\n // the final composition result if it is invalid. As a fallback for Chrome and Firefox, which either\n // don't support Input Events Level 2, or beforeinput at all, we store the state of the input when\n // the compositionstart event fires, and undo the changes in compositionend (below) if it is invalid.\n // Unfortunately, this messes up the undo/redo stack, but until insertFromComposition/deleteByComposition\n // are implemented, there is no other way to prevent composed input.\n // See https://bugs.chromium.org/p/chromium/issues/detail?id=1022204\n let {value, selectionStart, selectionEnd} = inputRef.current;\n compositionStartState.current = {value, selectionStart, selectionEnd};\n },\n onCompositionEnd() {\n if (!state.validate(inputRef.current.value)) {\n // Restore the input value in the DOM immediately so we can synchronously update the selection position.\n // But also update the value in React state as well so it is correct for future updates.\n let {value, selectionStart, selectionEnd} = compositionStartState.current;\n inputRef.current.value = value;\n inputRef.current.setSelectionRange(selectionStart, selectionEnd);\n state.setInputValue(value);\n }\n }\n }\n ),\n labelProps,\n descriptionProps,\n errorMessageProps\n };\n}\n"],"names":[],"version":3,"file":"main.js.map"}