@react-aria/textfield 3.5.0 → 3.5.3

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,241 +1,206 @@
1
- var {
2
- useEffect,
3
- useRef
4
- } = require("react");
1
+ var $iITAC$reactariautils = require("@react-aria/utils");
2
+ var $iITAC$reactarialabel = require("@react-aria/label");
3
+ var $iITAC$reactariafocus = require("@react-aria/focus");
4
+ var $iITAC$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
- useFocusable
8
- } = require("@react-aria/focus");
12
+ Object.defineProperty(dest, key, {
13
+ enumerable: true,
14
+ get: function get() {
15
+ return source[key];
16
+ }
17
+ });
18
+ });
9
19
 
10
- var {
11
- useField
12
- } = require("@react-aria/label");
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 $9076f978e02df845$exports = {};
13
26
 
14
- var {
15
- filterDOMProps,
16
- mergeProps
17
- } = require("@react-aria/utils");
27
+ $parcel$export($9076f978e02df845$exports, "useTextField", () => $9076f978e02df845$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
- descriptionProps,
47
- errorMessageProps
48
- } = useField(props);
49
- let domProps = filterDOMProps(props, {
50
- labelable: true
51
- });
52
- const inputOnlyProps = {
53
- type,
54
- pattern: props.pattern
55
- };
56
- return {
57
- labelProps,
58
- inputProps: mergeProps(domProps, inputElementType === 'input' && inputOnlyProps, _babelRuntimeHelpersExtends({
59
- disabled: isDisabled,
60
- readOnly: isReadOnly,
61
- 'aria-required': isRequired || undefined,
62
- 'aria-invalid': validationState === 'invalid' || undefined,
63
- 'aria-errormessage': props['aria-errormessage'],
64
- 'aria-activedescendant': props['aria-activedescendant'],
65
- 'aria-autocomplete': props['aria-autocomplete'],
66
- 'aria-haspopup': props['aria-haspopup'],
67
- value: props.value,
68
- defaultValue: props.value ? undefined : props.defaultValue,
69
- onChange: e => _onChange(e.target.value),
70
- autoComplete: props.autoComplete,
71
- maxLength: props.maxLength,
72
- minLength: props.minLength,
73
- name: props.name,
74
- placeholder: props.placeholder,
75
- inputMode: props.inputMode,
76
- // Clipboard events
77
- onCopy: props.onCopy,
78
- onCut: props.onCut,
79
- onPaste: props.onPaste,
80
- // Composition events
81
- onCompositionEnd: props.onCompositionEnd,
82
- onCompositionStart: props.onCompositionStart,
83
- onCompositionUpdate: props.onCompositionUpdate,
84
- // Selection events
85
- onSelect: props.onSelect,
86
- // Input events
87
- onBeforeInput: props.onBeforeInput,
88
- onInput: props.onInput
89
- }, focusableProps, fieldProps)),
90
- descriptionProps,
91
- errorMessageProps
92
- };
31
+ function $9076f978e02df845$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 } = $iITAC$reactariafocus.useFocusable(props, ref);
35
+ let { labelProps: labelProps , fieldProps: fieldProps , descriptionProps: descriptionProps , errorMessageProps: errorMessageProps } = $iITAC$reactarialabel.useField(props);
36
+ let domProps = $iITAC$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: $iITAC$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
+ };
93
83
  }
94
84
 
95
- exports.useTextField = useTextField;
96
85
 
97
- function $e12a6959a5c62c5783c0140bc17c4eda$var$supportsNativeBeforeInputEvent() {
98
- return typeof window !== 'undefined' && window.InputEvent && // @ts-ignore
99
- typeof InputEvent.prototype.getTargetRanges === 'function';
100
- }
86
+ var $56b68c3dab9bf16c$exports = {};
101
87
 
102
- function useFormattedTextField(props, state, inputRef) {
103
- let stateRef = useRef(state);
104
- stateRef.current = state; // All browsers implement the 'beforeinput' event natively except Firefox
105
- // (currently behind a flag as of Firefox 84). React's polyfill does not
106
- // run in all cases that the native event fires, e.g. when deleting text.
107
- // Use the native event if available so that we can prevent invalid deletions.
108
- // We do not attempt to polyfill this in Firefox since it would be very complicated,
109
- // the benefit of doing so is fairly minor, and it's going to be natively supported soon.
110
-
111
- useEffect(() => {
112
- if (!$e12a6959a5c62c5783c0140bc17c4eda$var$supportsNativeBeforeInputEvent()) {
113
- return;
114
- }
88
+ $parcel$export($56b68c3dab9bf16c$exports, "useFormattedTextField", () => $56b68c3dab9bf16c$export$4f384c9210e583c3);
115
89
 
116
- let input = inputRef.current;
117
-
118
- let onBeforeInput = e => {
119
- let state = stateRef.current; // Compute the next value of the input if the event is allowed to proceed.
120
- // See https://www.w3.org/TR/input-events-2/#interface-InputEvent-Attributes for a full list of input types.
121
-
122
- let nextValue;
123
-
124
- switch (e.inputType) {
125
- case 'historyUndo':
126
- case 'historyRedo':
127
- // Explicitly allow undo/redo. e.data is null in this case, but there's no need to validate,
128
- // because presumably the input would have already been validated previously.
129
- return;
130
-
131
- case 'deleteContent':
132
- case 'deleteByCut':
133
- case 'deleteByDrag':
134
- nextValue = input.value.slice(0, input.selectionStart) + input.value.slice(input.selectionEnd);
135
- break;
136
-
137
- case 'deleteContentForward':
138
- // This is potentially incorrect, since the browser may actually delete more than a single UTF-16
139
- // character. In reality, a full Unicode grapheme cluster consisting of multiple UTF-16 characters
140
- // or code points may be deleted. However, in our currently supported locales, there are no such cases.
141
- // If we support additional locales in the future, this may need to change.
142
- 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);
143
- break;
144
-
145
- case 'deleteContentBackward':
146
- 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);
147
- break;
148
-
149
- case 'deleteSoftLineBackward':
150
- case 'deleteHardLineBackward':
151
- nextValue = input.value.slice(input.selectionStart);
152
- break;
153
-
154
- default:
155
- if (e.data != null) {
156
- nextValue = input.value.slice(0, input.selectionStart) + e.data + input.value.slice(input.selectionEnd);
157
- }
158
-
159
- break;
160
- } // If we did not compute a value, or the new value is invalid, prevent the event
161
- // so that the browser does not update the input text, move the selection, or add to
162
- // the undo/redo stack.
163
-
164
-
165
- if (nextValue == null || !state.validate(nextValue)) {
166
- e.preventDefault();
167
- }
168
- };
169
90
 
170
- input.addEventListener('beforeinput', onBeforeInput, false);
171
- return () => {
172
- input.removeEventListener('beforeinput', onBeforeInput, false);
173
- };
174
- }, [inputRef, stateRef]);
175
- let onBeforeInput = !$e12a6959a5c62c5783c0140bc17c4eda$var$supportsNativeBeforeInputEvent() ? e => {
176
- let nextValue = e.target.value.slice(0, e.target.selectionStart) + e.data + e.target.value.slice(e.target.selectionEnd);
177
91
 
178
- if (!state.validate(nextValue)) {
179
- e.preventDefault();
180
- }
181
- } : null;
182
- let {
183
- labelProps,
184
- inputProps: textFieldProps,
185
- descriptionProps,
186
- errorMessageProps
187
- } = useTextField(props, inputRef);
188
- let compositionStartState = useRef(null);
189
- return {
190
- inputProps: mergeProps(textFieldProps, {
191
- onBeforeInput,
192
-
193
- onCompositionStart() {
194
- // Chrome does not implement Input Events Level 2, which specifies the insertFromComposition
195
- // and deleteByComposition inputType values for the beforeinput event. These are meant to occur
196
- // at the end of a composition (e.g. Pinyin IME, Android auto correct, etc.), and crucially, are
197
- // cancelable. The insertCompositionText and deleteCompositionText input types are not cancelable,
198
- // nor would we want to cancel them because the input from the user is incomplete at that point.
199
- // In Safari, insertFromComposition/deleteFromComposition will fire, however, allowing us to cancel
200
- // the final composition result if it is invalid. As a fallback for Chrome and Firefox, which either
201
- // don't support Input Events Level 2, or beforeinput at all, we store the state of the input when
202
- // the compositionstart event fires, and undo the changes in compositionend (below) if it is invalid.
203
- // Unfortunately, this messes up the undo/redo stack, but until insertFromComposition/deleteByComposition
204
- // are implemented, there is no other way to prevent composed input.
205
- // See https://bugs.chromium.org/p/chromium/issues/detail?id=1022204
206
- let {
207
- value,
208
- selectionStart,
209
- selectionEnd
210
- } = inputRef.current;
211
- compositionStartState.current = {
212
- value,
213
- selectionStart,
214
- selectionEnd
92
+ function $56b68c3dab9bf16c$var$supportsNativeBeforeInputEvent() {
93
+ return typeof window !== 'undefined' && window.InputEvent && // @ts-ignore
94
+ typeof InputEvent.prototype.getTargetRanges === 'function';
95
+ }
96
+ function $56b68c3dab9bf16c$export$4f384c9210e583c3(props, state1, inputRef) {
97
+ let stateRef = $iITAC$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
+ $iITAC$react.useEffect(()=>{
106
+ if (!$56b68c3dab9bf16c$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();
215
146
  };
216
- },
217
-
218
- onCompositionEnd() {
219
- if (!state.validate(inputRef.current.value)) {
220
- // Restore the input value in the DOM immediately so we can synchronously update the selection position.
221
- // But also update the value in React state as well so it is correct for future updates.
222
- let {
223
- value,
224
- selectionStart,
225
- selectionEnd
226
- } = compositionStartState.current;
227
- inputRef.current.value = value;
228
- inputRef.current.setSelectionRange(selectionStart, selectionEnd);
229
- state.setInputValue(value);
230
- }
231
- }
232
-
233
- }),
234
- labelProps,
235
- descriptionProps,
236
- errorMessageProps
237
- };
147
+ input.addEventListener('beforeinput', onBeforeInput, false);
148
+ return ()=>{
149
+ input.removeEventListener('beforeinput', onBeforeInput, false);
150
+ };
151
+ }, [
152
+ inputRef,
153
+ stateRef
154
+ ]);
155
+ let onBeforeInput1 = !$56b68c3dab9bf16c$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 } = $9076f978e02df845$export$712718f7aec83d5(props, inputRef);
160
+ let compositionStartState = $iITAC$react.useRef(null);
161
+ return {
162
+ inputProps: $iITAC$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
+ };
238
199
  }
239
200
 
240
- exports.useFormattedTextField = useFormattedTextField;
201
+
202
+ $parcel$exportWildcard(module.exports, $9076f978e02df845$exports);
203
+ $parcel$exportWildcard(module.exports, $56b68c3dab9bf16c$exports);
204
+
205
+
241
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;;AC+FD;;;;;AAKO,SAASG,YAAT,CACLC,KADK,EAELC,GAFK,EAGa;AAClB,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,MAQkDR,KARtD;AASA,MAAI;AAACS,IAAAA;AAAD,MAAmBC,YAAY,CAACV,KAAD,EAAQC,GAAR,CAAnC;AACA,MAAI;AAACU,IAAAA,UAAD;AAAaC,IAAAA,UAAb;AAAyBC,IAAAA,gBAAzB;AAA2CC,IAAAA;AAA3C,MAAgEC,QAAQ,CAACf,KAAD,CAA5E;AACA,MAAIgB,QAAQ,GAAGC,cAAc,CAACjB,KAAD,EAAQ;AAACkB,IAAAA,SAAS,EAAE;AAAZ,GAAR,CAA7B;AAEA,QAAMC,cAAc,GAAG;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;AAA2DC,IAAAA;AAA3D,MAAgF,aAAad,KAAb,EAAoBoD,QAApB,CAApF;AAEA,MAAIiB,qBAAqB,GAAGf,MAAM,CAAC,IAAD,CAAlC;AACA,SAAO;AACLjC,IAAAA,UAAU,EAAEC,UAAU,CACpB8C,cADoB,EAEpB;AACEzB,MAAAA,aADF;;AAEEH,MAAAA,kBAAkB,GAAG;AACnB;AACA;AACA;AACA;AACA;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;AAiCLf,IAAAA,UAjCK;AAkCLE,IAAAA,gBAlCK;AAmCLC,IAAAA;AAnCK,GAAP;AAqCD","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 {\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":["$parcel$interopDefault","a","__esModule","default","useTextField","props","ref","inputElementType","isDisabled","isRequired","isReadOnly","validationState","type","onChange","focusableProps","useFocusable","labelProps","fieldProps","descriptionProps","errorMessageProps","useField","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,kCAAY,CAAC,KAAK,EAAE,GAAG;IAC9C,GAAG,CAAC,CAAC,aAAA,UAAU,eAAE,UAAU,qBAAE,gBAAgB,sBAAE,iBAAiB,EAAA,CAAC,GAAG,8BAAQ,CAAC,KAAK;IAClF,GAAG,CAAC,QAAQ,GAAG,oCAAc,CAAC,KAAK,EAAE,CAAC;QAAA,SAAS,EAAE,IAAI;IAAA,CAAC;IAEtD,KAAK,CAAC,cAAc,GAAG,CAAC;cACtB,IAAI;QACJ,OAAO,EAAE,KAAK,CAAC,OAAO;IACxB,CAAC;IAED,MAAM,CAAC,CAAC;oBACN,UAAU;QACV,UAAU,EAAE,gCAAU,CACpB,QAAQ,EACR,gBAAgB,KAAK,CAAO,UAAI,cAAc,EAC9C,CAAC;YACC,QAAQ,EAAE,UAAU;YACpB,QAAQ,EAAE,UAAU;YACpB,CAAe,gBAAE,UAAU,IAAI,SAAS;YACxC,CAAc,eAAE,eAAe,KAAK,CAAS,YAAI,SAAS;YAC1D,CAAmB,oBAAE,KAAK,CAAC,CAAmB;YAC9C,CAAuB,wBAAE,KAAK,CAAC,CAAuB;YACtD,CAAmB,oBAAE,KAAK,CAAC,CAAmB;YAC9C,CAAe,gBAAE,KAAK,CAAC,CAAe;YACtC,KAAK,E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E,cAAc,iBAAE,YAAY,EAAA,CAAC,GAAG,QAAQ,CAAC,OAAO;gBAC5D,qBAAqB,CAAC,OAAO,GAAG,CAAC;2BAAA,KAAK;oCAAE,cAAc;kCAAE,YAAY;gBAAA,CAAC;YACvE,CAAC;YACD,gBAAgB,IAAG,CAAC;gBAClB,EAAE,GAAG,MAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,GAAG,CAAC;oBAC5C,EAAwG,AAAxG,sGAAwG;oBACxG,EAAwF,AAAxF,sFAAwF;oBACxF,GAAG,CAAC,CAAC,QAAA,KAAK,mBAAE,cAAc,iBAAE,YAAY,EAAA,CAAC,GAAG,qBAAqB,CAAC,OAAO;oBACzE,QAAQ,CAAC,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"}
package/dist/module.js CHANGED
@@ -1,219 +1,189 @@
1
- import { useEffect, useRef } from "react";
2
- import { useFocusable } from "@react-aria/focus";
3
- import { useField } from "@react-aria/label";
4
- import { filterDOMProps, mergeProps } from "@react-aria/utils";
5
- import _babelRuntimeHelpersEsmExtends from "@babel/runtime/helpers/esm/extends";
1
+ import {filterDOMProps as $kOq5K$filterDOMProps, mergeProps as $kOq5K$mergeProps} from "@react-aria/utils";
2
+ import {useField as $kOq5K$useField} from "@react-aria/label";
3
+ import {useFocusable as $kOq5K$useFocusable} from "@react-aria/focus";
4
+ import {useRef as $kOq5K$useRef, useEffect as $kOq5K$useEffect} from "react";
6
5
 
7
- /**
8
- * Provides the behavior and accessibility implementation for a text field.
9
- * @param props - Props for the text field.
10
- * @param ref - Ref to the HTML input or textarea element.
11
- */
12
- export function useTextField(props, ref) {
13
- let {
14
- inputElementType = 'input',
15
- isDisabled = false,
16
- isRequired = false,
17
- isReadOnly = false,
18
- validationState,
19
- type = 'text',
20
- onChange: _onChange = () => {}
21
- } = props;
22
- let {
23
- focusableProps
24
- } = useFocusable(props, ref);
25
- let {
26
- labelProps,
27
- fieldProps,
28
- descriptionProps,
29
- errorMessageProps
30
- } = useField(props);
31
- let domProps = filterDOMProps(props, {
32
- labelable: true
33
- });
34
- const inputOnlyProps = {
35
- type,
36
- pattern: props.pattern
37
- };
38
- return {
39
- labelProps,
40
- inputProps: mergeProps(domProps, inputElementType === 'input' && inputOnlyProps, _babelRuntimeHelpersEsmExtends({
41
- disabled: isDisabled,
42
- readOnly: isReadOnly,
43
- 'aria-required': isRequired || undefined,
44
- 'aria-invalid': validationState === 'invalid' || undefined,
45
- 'aria-errormessage': props['aria-errormessage'],
46
- 'aria-activedescendant': props['aria-activedescendant'],
47
- 'aria-autocomplete': props['aria-autocomplete'],
48
- 'aria-haspopup': props['aria-haspopup'],
49
- value: props.value,
50
- defaultValue: props.value ? undefined : props.defaultValue,
51
- onChange: e => _onChange(e.target.value),
52
- autoComplete: props.autoComplete,
53
- maxLength: props.maxLength,
54
- minLength: props.minLength,
55
- name: props.name,
56
- placeholder: props.placeholder,
57
- inputMode: props.inputMode,
58
- // Clipboard events
59
- onCopy: props.onCopy,
60
- onCut: props.onCut,
61
- onPaste: props.onPaste,
62
- // Composition events
63
- onCompositionEnd: props.onCompositionEnd,
64
- onCompositionStart: props.onCompositionStart,
65
- onCompositionUpdate: props.onCompositionUpdate,
66
- // Selection events
67
- onSelect: props.onSelect,
68
- // Input events
69
- onBeforeInput: props.onBeforeInput,
70
- onInput: props.onInput
71
- }, focusableProps, fieldProps)),
72
- descriptionProps,
73
- errorMessageProps
74
- };
6
+ function $parcel$export(e, n, v, s) {
7
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
75
8
  }
9
+ var $2d73ec29415bd339$exports = {};
76
10
 
77
- function $c7e32867b2abc7e2d776d5c060056cb7$var$supportsNativeBeforeInputEvent() {
78
- return typeof window !== 'undefined' && window.InputEvent && // @ts-ignore
79
- typeof InputEvent.prototype.getTargetRanges === 'function';
80
- }
81
-
82
- export function useFormattedTextField(props, state, inputRef) {
83
- let stateRef = useRef(state);
84
- stateRef.current = state; // All browsers implement the 'beforeinput' event natively except Firefox
85
- // (currently behind a flag as of Firefox 84). React's polyfill does not
86
- // run in all cases that the native event fires, e.g. when deleting text.
87
- // Use the native event if available so that we can prevent invalid deletions.
88
- // We do not attempt to polyfill this in Firefox since it would be very complicated,
89
- // the benefit of doing so is fairly minor, and it's going to be natively supported soon.
90
-
91
- useEffect(() => {
92
- if (!$c7e32867b2abc7e2d776d5c060056cb7$var$supportsNativeBeforeInputEvent()) {
93
- return;
94
- }
95
-
96
- let input = inputRef.current;
97
-
98
- let onBeforeInput = e => {
99
- let state = stateRef.current; // Compute the next value of the input if the event is allowed to proceed.
100
- // See https://www.w3.org/TR/input-events-2/#interface-InputEvent-Attributes for a full list of input types.
11
+ $parcel$export($2d73ec29415bd339$exports, "useTextField", () => $2d73ec29415bd339$export$712718f7aec83d5);
101
12
 
102
- let nextValue;
103
13
 
104
- switch (e.inputType) {
105
- case 'historyUndo':
106
- case 'historyRedo':
107
- // Explicitly allow undo/redo. e.data is null in this case, but there's no need to validate,
108
- // because presumably the input would have already been validated previously.
109
- return;
110
14
 
111
- case 'deleteContent':
112
- case 'deleteByCut':
113
- case 'deleteByDrag':
114
- nextValue = input.value.slice(0, input.selectionStart) + input.value.slice(input.selectionEnd);
115
- break;
116
-
117
- case 'deleteContentForward':
118
- // This is potentially incorrect, since the browser may actually delete more than a single UTF-16
119
- // character. In reality, a full Unicode grapheme cluster consisting of multiple UTF-16 characters
120
- // or code points may be deleted. However, in our currently supported locales, there are no such cases.
121
- // If we support additional locales in the future, this may need to change.
122
- 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);
123
- break;
124
-
125
- case 'deleteContentBackward':
126
- 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);
127
- break;
15
+ function $2d73ec29415bd339$export$712718f7aec83d5(props, ref) {
16
+ let { inputElementType: inputElementType = 'input' , isDisabled: isDisabled = false , isRequired: isRequired = false , isReadOnly: isReadOnly = false , validationState: validationState , type: type = 'text' , onChange: onChange = ()=>{
17
+ } } = props;
18
+ let { focusableProps: focusableProps } = $kOq5K$useFocusable(props, ref);
19
+ let { labelProps: labelProps , fieldProps: fieldProps , descriptionProps: descriptionProps , errorMessageProps: errorMessageProps } = $kOq5K$useField(props);
20
+ let domProps = $kOq5K$filterDOMProps(props, {
21
+ labelable: true
22
+ });
23
+ const inputOnlyProps = {
24
+ type: type,
25
+ pattern: props.pattern
26
+ };
27
+ return {
28
+ labelProps: labelProps,
29
+ inputProps: $kOq5K$mergeProps(domProps, inputElementType === 'input' && inputOnlyProps, {
30
+ disabled: isDisabled,
31
+ readOnly: isReadOnly,
32
+ 'aria-required': isRequired || undefined,
33
+ 'aria-invalid': validationState === 'invalid' || undefined,
34
+ 'aria-errormessage': props['aria-errormessage'],
35
+ 'aria-activedescendant': props['aria-activedescendant'],
36
+ 'aria-autocomplete': props['aria-autocomplete'],
37
+ 'aria-haspopup': props['aria-haspopup'],
38
+ value: props.value,
39
+ defaultValue: props.value ? undefined : props.defaultValue,
40
+ onChange: (e)=>onChange(e.target.value)
41
+ ,
42
+ autoComplete: props.autoComplete,
43
+ maxLength: props.maxLength,
44
+ minLength: props.minLength,
45
+ name: props.name,
46
+ placeholder: props.placeholder,
47
+ inputMode: props.inputMode,
48
+ // Clipboard events
49
+ onCopy: props.onCopy,
50
+ onCut: props.onCut,
51
+ onPaste: props.onPaste,
52
+ // Composition events
53
+ onCompositionEnd: props.onCompositionEnd,
54
+ onCompositionStart: props.onCompositionStart,
55
+ onCompositionUpdate: props.onCompositionUpdate,
56
+ // Selection events
57
+ onSelect: props.onSelect,
58
+ // Input events
59
+ onBeforeInput: props.onBeforeInput,
60
+ onInput: props.onInput,
61
+ ...focusableProps,
62
+ ...fieldProps
63
+ }),
64
+ descriptionProps: descriptionProps,
65
+ errorMessageProps: errorMessageProps
66
+ };
67
+ }
128
68
 
129
- case 'deleteSoftLineBackward':
130
- case 'deleteHardLineBackward':
131
- nextValue = input.value.slice(input.selectionStart);
132
- break;
133
69
 
134
- default:
135
- if (e.data != null) {
136
- nextValue = input.value.slice(0, input.selectionStart) + e.data + input.value.slice(input.selectionEnd);
137
- }
70
+ var $d841c8010a73d545$exports = {};
138
71
 
139
- break;
140
- } // If we did not compute a value, or the new value is invalid, prevent the event
141
- // so that the browser does not update the input text, move the selection, or add to
142
- // the undo/redo stack.
72
+ $parcel$export($d841c8010a73d545$exports, "useFormattedTextField", () => $d841c8010a73d545$export$4f384c9210e583c3);
143
73
 
144
74
 
145
- if (nextValue == null || !state.validate(nextValue)) {
146
- e.preventDefault();
147
- }
148
- };
149
75
 
150
- input.addEventListener('beforeinput', onBeforeInput, false);
151
- return () => {
152
- input.removeEventListener('beforeinput', onBeforeInput, false);
76
+ function $d841c8010a73d545$var$supportsNativeBeforeInputEvent() {
77
+ return typeof window !== 'undefined' && window.InputEvent && // @ts-ignore
78
+ typeof InputEvent.prototype.getTargetRanges === 'function';
79
+ }
80
+ function $d841c8010a73d545$export$4f384c9210e583c3(props, state1, inputRef) {
81
+ let stateRef = $kOq5K$useRef(state1);
82
+ stateRef.current = state1;
83
+ // All browsers implement the 'beforeinput' event natively except Firefox
84
+ // (currently behind a flag as of Firefox 84). React's polyfill does not
85
+ // run in all cases that the native event fires, e.g. when deleting text.
86
+ // Use the native event if available so that we can prevent invalid deletions.
87
+ // We do not attempt to polyfill this in Firefox since it would be very complicated,
88
+ // the benefit of doing so is fairly minor, and it's going to be natively supported soon.
89
+ $kOq5K$useEffect(()=>{
90
+ if (!$d841c8010a73d545$var$supportsNativeBeforeInputEvent()) return;
91
+ let input = inputRef.current;
92
+ let onBeforeInput = (e)=>{
93
+ let state = stateRef.current;
94
+ // Compute the next value of the input if the event is allowed to proceed.
95
+ // See https://www.w3.org/TR/input-events-2/#interface-InputEvent-Attributes for a full list of input types.
96
+ let nextValue;
97
+ switch(e.inputType){
98
+ case 'historyUndo':
99
+ case 'historyRedo':
100
+ // Explicitly allow undo/redo. e.data is null in this case, but there's no need to validate,
101
+ // because presumably the input would have already been validated previously.
102
+ return;
103
+ case 'deleteContent':
104
+ case 'deleteByCut':
105
+ case 'deleteByDrag':
106
+ nextValue = input.value.slice(0, input.selectionStart) + input.value.slice(input.selectionEnd);
107
+ break;
108
+ case 'deleteContentForward':
109
+ // This is potentially incorrect, since the browser may actually delete more than a single UTF-16
110
+ // character. In reality, a full Unicode grapheme cluster consisting of multiple UTF-16 characters
111
+ // or code points may be deleted. However, in our currently supported locales, there are no such cases.
112
+ // If we support additional locales in the future, this may need to change.
113
+ 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);
114
+ break;
115
+ case 'deleteContentBackward':
116
+ 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);
117
+ break;
118
+ case 'deleteSoftLineBackward':
119
+ case 'deleteHardLineBackward':
120
+ nextValue = input.value.slice(input.selectionStart);
121
+ break;
122
+ default:
123
+ if (e.data != null) nextValue = input.value.slice(0, input.selectionStart) + e.data + input.value.slice(input.selectionEnd);
124
+ break;
125
+ }
126
+ // If we did not compute a value, or the new value is invalid, prevent the event
127
+ // so that the browser does not update the input text, move the selection, or add to
128
+ // the undo/redo stack.
129
+ if (nextValue == null || !state.validate(nextValue)) e.preventDefault();
130
+ };
131
+ input.addEventListener('beforeinput', onBeforeInput, false);
132
+ return ()=>{
133
+ input.removeEventListener('beforeinput', onBeforeInput, false);
134
+ };
135
+ }, [
136
+ inputRef,
137
+ stateRef
138
+ ]);
139
+ let onBeforeInput1 = !$d841c8010a73d545$var$supportsNativeBeforeInputEvent() ? (e)=>{
140
+ let nextValue = e.target.value.slice(0, e.target.selectionStart) + e.data + e.target.value.slice(e.target.selectionEnd);
141
+ if (!state1.validate(nextValue)) e.preventDefault();
142
+ } : null;
143
+ let { labelProps: labelProps , inputProps: textFieldProps , descriptionProps: descriptionProps , errorMessageProps: errorMessageProps } = $2d73ec29415bd339$export$712718f7aec83d5(props, inputRef);
144
+ let compositionStartState = $kOq5K$useRef(null);
145
+ return {
146
+ inputProps: $kOq5K$mergeProps(textFieldProps, {
147
+ onBeforeInput: onBeforeInput1,
148
+ onCompositionStart () {
149
+ // Chrome does not implement Input Events Level 2, which specifies the insertFromComposition
150
+ // and deleteByComposition inputType values for the beforeinput event. These are meant to occur
151
+ // at the end of a composition (e.g. Pinyin IME, Android auto correct, etc.), and crucially, are
152
+ // cancelable. The insertCompositionText and deleteCompositionText input types are not cancelable,
153
+ // nor would we want to cancel them because the input from the user is incomplete at that point.
154
+ // In Safari, insertFromComposition/deleteFromComposition will fire, however, allowing us to cancel
155
+ // the final composition result if it is invalid. As a fallback for Chrome and Firefox, which either
156
+ // don't support Input Events Level 2, or beforeinput at all, we store the state of the input when
157
+ // the compositionstart event fires, and undo the changes in compositionend (below) if it is invalid.
158
+ // Unfortunately, this messes up the undo/redo stack, but until insertFromComposition/deleteByComposition
159
+ // are implemented, there is no other way to prevent composed input.
160
+ // See https://bugs.chromium.org/p/chromium/issues/detail?id=1022204
161
+ let { value: value , selectionStart: selectionStart , selectionEnd: selectionEnd } = inputRef.current;
162
+ compositionStartState.current = {
163
+ value: value,
164
+ selectionStart: selectionStart,
165
+ selectionEnd: selectionEnd
166
+ };
167
+ },
168
+ onCompositionEnd () {
169
+ if (!state1.validate(inputRef.current.value)) {
170
+ // Restore the input value in the DOM immediately so we can synchronously update the selection position.
171
+ // But also update the value in React state as well so it is correct for future updates.
172
+ let { value: value , selectionStart: selectionStart , selectionEnd: selectionEnd } = compositionStartState.current;
173
+ inputRef.current.value = value;
174
+ inputRef.current.setSelectionRange(selectionStart, selectionEnd);
175
+ state1.setInputValue(value);
176
+ }
177
+ }
178
+ }),
179
+ labelProps: labelProps,
180
+ descriptionProps: descriptionProps,
181
+ errorMessageProps: errorMessageProps
153
182
  };
154
- }, [inputRef, stateRef]);
155
- let onBeforeInput = !$c7e32867b2abc7e2d776d5c060056cb7$var$supportsNativeBeforeInputEvent() ? e => {
156
- let nextValue = e.target.value.slice(0, e.target.selectionStart) + e.data + e.target.value.slice(e.target.selectionEnd);
183
+ }
157
184
 
158
- if (!state.validate(nextValue)) {
159
- e.preventDefault();
160
- }
161
- } : null;
162
- let {
163
- labelProps,
164
- inputProps: textFieldProps,
165
- descriptionProps,
166
- errorMessageProps
167
- } = useTextField(props, inputRef);
168
- let compositionStartState = useRef(null);
169
- return {
170
- inputProps: mergeProps(textFieldProps, {
171
- onBeforeInput,
172
185
 
173
- onCompositionStart() {
174
- // Chrome does not implement Input Events Level 2, which specifies the insertFromComposition
175
- // and deleteByComposition inputType values for the beforeinput event. These are meant to occur
176
- // at the end of a composition (e.g. Pinyin IME, Android auto correct, etc.), and crucially, are
177
- // cancelable. The insertCompositionText and deleteCompositionText input types are not cancelable,
178
- // nor would we want to cancel them because the input from the user is incomplete at that point.
179
- // In Safari, insertFromComposition/deleteFromComposition will fire, however, allowing us to cancel
180
- // the final composition result if it is invalid. As a fallback for Chrome and Firefox, which either
181
- // don't support Input Events Level 2, or beforeinput at all, we store the state of the input when
182
- // the compositionstart event fires, and undo the changes in compositionend (below) if it is invalid.
183
- // Unfortunately, this messes up the undo/redo stack, but until insertFromComposition/deleteByComposition
184
- // are implemented, there is no other way to prevent composed input.
185
- // See https://bugs.chromium.org/p/chromium/issues/detail?id=1022204
186
- let {
187
- value,
188
- selectionStart,
189
- selectionEnd
190
- } = inputRef.current;
191
- compositionStartState.current = {
192
- value,
193
- selectionStart,
194
- selectionEnd
195
- };
196
- },
197
186
 
198
- onCompositionEnd() {
199
- if (!state.validate(inputRef.current.value)) {
200
- // Restore the input value in the DOM immediately so we can synchronously update the selection position.
201
- // But also update the value in React state as well so it is correct for future updates.
202
- let {
203
- value,
204
- selectionStart,
205
- selectionEnd
206
- } = compositionStartState.current;
207
- inputRef.current.value = value;
208
- inputRef.current.setSelectionRange(selectionStart, selectionEnd);
209
- state.setInputValue(value);
210
- }
211
- }
212
187
 
213
- }),
214
- labelProps,
215
- descriptionProps,
216
- errorMessageProps
217
- };
218
- }
188
+ export {$2d73ec29415bd339$export$712718f7aec83d5 as useTextField, $d841c8010a73d545$export$4f384c9210e583c3 as useFormattedTextField};
219
189
  //# sourceMappingURL=module.js.map
@@ -1 +1 @@
1
- {"mappings":";;;;;;AAiGA;;;;;OAKO,SAASA,YAAT,CACLC,KADK,EAELC,GAFK,EAGa;AAClB,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,MAQkDR,KARtD;AASA,MAAI;AAACS,IAAAA;AAAD,MAAmBC,YAAY,CAACV,KAAD,EAAQC,GAAR,CAAnC;AACA,MAAI;AAACU,IAAAA,UAAD;AAAaC,IAAAA,UAAb;AAAyBC,IAAAA,gBAAzB;AAA2CC,IAAAA;AAA3C,MAAgEC,QAAQ,CAACf,KAAD,CAA5E;AACA,MAAIgB,QAAQ,GAAGC,cAAc,CAACjB,KAAD,EAAQ;AAACkB,IAAAA,SAAS,EAAE;AAAZ,GAAR,CAA7B;AAEA,QAAMC,cAAc,GAAG;AACrBZ,IAAAA,IADqB;AAErBa,IAAAA,OAAO,EAAEpB,KAAK,CAACoB;AAFM,GAAvB;AAKA,SAAO;AACLT,IAAAA,UADK;AAELU,IAAAA,UAAU,EAAEC,UAAU,CACpBN,QADoB,EAEpBd,gBAAgB,KAAK,OAArB,IAAgCiB,cAFZ;AAIlBI,MAAAA,QAAQ,EAAEpB,UAJQ;AAKlBqB,MAAAA,QAAQ,EAAEnB,UALQ;AAMlB,uBAAiBD,UAAU,IAAIqB,SANb;AAOlB,sBAAgBnB,eAAe,KAAK,SAApB,IAAiCmB,SAP/B;AAQlB,2BAAqBzB,KAAK,CAAC,mBAAD,CARR;AASlB,+BAAyB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d,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;AAiCLf,IAAAA,UAjCK;AAkCLE,IAAAA,gBAlCK;AAmCLC,IAAAA;AAnCK,GAAP;AAqCD","sources":["./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\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":["useTextField","props","ref","inputElementType","isDisabled","isRequired","isReadOnly","validationState","type","onChange","focusableProps","useFocusable","labelProps","fieldProps","descriptionProps","errorMessageProps","useField","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":"module.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,mBAAY,CAAC,KAAK,EAAE,GAAG;IAC9C,GAAG,CAAC,CAAC,aAAA,UAAU,eAAE,UAAU,qBAAE,gBAAgB,sBAAE,iBAAiB,EAAA,CAAC,GAAG,eAAQ,CAAC,KAAK;IAClF,GAAG,CAAC,QAAQ,GAAG,qBAAc,CAAC,KAAK,EAAE,CAAC;QAAA,SAAS,EAAE,IAAI;IAAA,CAAC;IAEtD,KAAK,CAAC,cAAc,GAAG,CAAC;cACtB,IAAI;QACJ,OAAO,EAAE,KAAK,CAAC,OAAO;IACxB,CAAC;IAED,MAAM,CAAC,CAAC;oBACN,UAAU;QACV,UAAU,EAAE,iBAAU,CACpB,QAAQ,EACR,gBAAgB,KAAK,CAAO,UAAI,cAAc,EAC9C,CAAC;YACC,QAAQ,EAAE,UAAU;YACpB,QAAQ,EAAE,UAAU;YACpB,CAAe,gBAA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AAmG,AAAnG,iGAAmG;gBACnG,EAAoG,AAApG,kGAAoG;gBACpG,EAAkG,AAAlG,gGAAkG;gBAClG,EAAqG,AAArG,mGAAqG;gBACrG,EAAyG,AAAzG,uGAAyG;gBACzG,EAAoE,AAApE,kEAAoE;gBACpE,EAAoE,AAApE,kEAAoE;gBACpE,GAAG,CAAC,CAAC,QAAA,KAAK,mBAAE,cAAc,iBAAE,YAAY,EAAA,CAAC,GAAG,QAAQ,CAAC,OAAO;gBAC5D,qBAAqB,CAAC,OAAO,GAAG,CAAC;2BAAA,KAAK;oCAAE,cAAc;kCAAE,YAAY;gBAAA,CAAC;YACvE,CAAC;YACD,gBAAgB,IAAG,CAAC;gBAClB,EAAE,GAAG,MAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,GAAG,CAAC;oBAC5C,EAAwG,AAAxG,sGAAwG;oBACxG,EAAwF,AAAxF,sFAAwF;oBACxF,GAAG,CAAC,CAAC,QAAA,KAAK,mBAAE,cAAc,iBAAE,YAAY,EAAA,CAAC,GAAG,qBAAqB,CAAC,OAAO;oBACzE,QAAQ,CAAC,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":"module.js.map"}
@@ -1 +1 @@
1
- {"mappings":"A;A;AAyBA;A;A;GAGG;AACH,6BAA6B;KAC1B,CAAC,IAAI,MAAM,uBAAuB,GAAG,uBAAuB,CAAC,CAAC,CAAC,SAAS,eAAe,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK;CAC7G,CAAC;AAEF;A;A;GAGG;AACH,+BAA+B;KAC5B,CAAC,IAAI,MAAM,QAAQ,GAAG,QAAQ,CAAC,CAAC,CAAC,SAAS,WAAW,MAAM,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK;CAChF,CAAC;AAEF,0BAA0B,OAAO,CAAC;AAElC;A;A;GAGG;AACH,kCAAkC,MAAM,IAAI,CAAC,qBAAqB,EAAE,OAAO,GAAG,UAAU,CAAC,CAAC;AAEzF;A;A;A;GAIG;AACJ,gCAAgC,IAAI,CAAC,qBAAqB,EAAE,0BAA0B,CAAC,CAAC;AAEvF;A;A;A;GAIG;AACJ,mCAAmC,IAAI,CAAC,uBAAuB,EAAE,0BAA0B,CAAC,CAAC;AAE7F;A;A;GAGG;AACH,yBAAyB,CAAC,SAAS,0BAA0B,IAAI,2BAA2B,CAAC,CAAC,CAAC,CAAC;AAEhG,+BAA+B,CAAC,SAAS,0BAA0B,CAAE,SAAQ,kBAAkB;IAC7F;A;A;A;A;OAKG;IACH,gBAAgB,CAAC,EAAE,CAAC,CAAA;CACrB;AAED;A;A;A;GAIG;AACH,wBAAwB,CAAC,SAAS,0BAA0B,IAAI,UAAU,wBAAwB,CAAC,CAAC,CAAC,CAAC,CAAC;AAEvG,+BAA+B,CAAC,SAAS,0BAA0B,GAAG,kBAAkB;IACtF,mCAAmC;IACnC,UAAU,EAAE,oBAAoB,CAAC,CAAC,CAAC;IACnC,gEAAgE;IAChE,UAAU,EAAE,oBAAoB,gBAAgB,CAAC,CAAC;IAClD,8DAA8D;IAC9D,gBAAgB,EAAE,eAAe,WAAW,CAAC,CAAC;IAC9C,gEAAgE;IAChE,iBAAiB,EAAE,eAAe,WAAW,CAAC,CAAA;CAC/C;AAED;A;A;A;GAIG;AACH,6BAA6B,CAAC,SAAS,0BAA0B,GAAG,kBAAkB,EACpF,KAAK,EAAE,qBAAqB,CAAC,CAAC,EAC9B,GAAG,EAAE,mBAAmB,CAAC,CAAC,GACzB,cAAc,CAAC,CAAC,CAkElB;AC1JD;IACE,QAAQ,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC;IACnC,aAAa,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAA;CACrC;AAUD,sCAAsC,KAAK,EAAE,kBAAkB,EAAE,KAAK,EAAE,uBAAuB,EAAE,QAAQ,EAAE,UAAU,gBAAgB,CAAC,GAAG,aAAa,CAkIrJ","sources":["./packages/@react-aria/textfield/src/packages/@react-aria/textfield/src/useTextField.ts","./packages/@react-aria/textfield/src/packages/@react-aria/textfield/src/useFormattedTextField.ts","./packages/@react-aria/textfield/src/packages/@react-aria/textfield/src/index.ts"],"sourcesContent":[null,null,null],"names":[],"version":3,"file":"types.d.ts.map"}
1
+ {"mappings":";;AAyBA;;;GAGG;AACH,6BAA6B;KAC1B,CAAC,IAAI,MAA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EAAE,qBAAqB,CAAC,CAAC,EAC9B,GAAG,EAAE,mBAAmB,CAAC,CAAC,GACzB,cAAc,CAAC,CAAC,CAkElB;AC1JD;IACE,QAAQ,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC;IACnC,aAAa,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAA;CACrC;AAUD,sCAAsC,KAAK,EAAE,kBAAkB,EAAE,KAAK,EAAE,uBAAuB,EAAE,QAAQ,EAAE,UAAU,gBAAgB,CAAC,GAAG,aAAa,CAkIrJ","sources":["packages/@react-aria/textfield/src/packages/@react-aria/textfield/src/useTextField.ts","packages/@react-aria/textfield/src/packages/@react-aria/textfield/src/useFormattedTextField.ts","packages/@react-aria/textfield/src/packages/@react-aria/textfield/src/index.ts","packages/@react-aria/textfield/src/index.ts"],"sourcesContent":[null,null,null,"/*\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"],"names":[],"version":3,"file":"types.d.ts.map"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-aria/textfield",
3
- "version": "3.5.0",
3
+ "version": "3.5.3",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/main.js",
@@ -18,11 +18,11 @@
18
18
  },
19
19
  "dependencies": {
20
20
  "@babel/runtime": "^7.6.2",
21
- "@react-aria/focus": "^3.5.0",
22
- "@react-aria/label": "^3.2.1",
23
- "@react-aria/utils": "^3.10.0",
24
- "@react-types/shared": "^3.10.0",
25
- "@react-types/textfield": "^3.3.0"
21
+ "@react-aria/focus": "^3.5.3",
22
+ "@react-aria/label": "^3.2.4",
23
+ "@react-aria/utils": "^3.11.3",
24
+ "@react-types/shared": "^3.11.2",
25
+ "@react-types/textfield": "^3.3.3"
26
26
  },
27
27
  "peerDependencies": {
28
28
  "react": "^16.8.0 || ^17.0.0-rc.1"
@@ -30,5 +30,5 @@
30
30
  "publishConfig": {
31
31
  "access": "public"
32
32
  },
33
- "gitHead": "896eabe5521a0349a675c4773ed7629addd4b8c4"
33
+ "gitHead": "ed8d8d984c2f7f2c31e8b18795b97858a95e4729"
34
34
  }