@react-spectrum/textfield 3.10.7 → 3.11.1

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/import.mjs CHANGED
@@ -1,7 +1,10 @@
1
+ "use client";
2
+
1
3
  import "./main.css";
2
4
  import {useLayoutEffect as $evhxb$useLayoutEffect, chain as $evhxb$chain, mergeProps as $evhxb$mergeProps} from "@react-aria/utils";
3
5
  import $evhxb$react, {useRef as $evhxb$useRef, useCallback as $evhxb$useCallback, useImperativeHandle as $evhxb$useImperativeHandle, cloneElement as $evhxb$cloneElement, forwardRef as $evhxb$forwardRef} from "react";
4
6
  import {useControlledState as $evhxb$useControlledState} from "@react-stately/utils";
7
+ import {useFormProps as $evhxb$useFormProps} from "@react-spectrum/form";
5
8
  import {useProviderProps as $evhxb$useProviderProps} from "@react-spectrum/provider";
6
9
  import {useTextField as $evhxb$useTextField} from "@react-aria/textfield";
7
10
  import $evhxb$spectrumiconsuiAlertMedium from "@spectrum-icons/ui/AlertMedium";
@@ -11,9 +14,11 @@ import {Field as $evhxb$Field} from "@react-spectrum/label";
11
14
  import {useFocusRing as $evhxb$useFocusRing} from "@react-aria/focus";
12
15
  import {useHover as $evhxb$useHover} from "@react-aria/interactions";
13
16
 
17
+
14
18
  function $parcel$interopDefault(a) {
15
19
  return a && a.__esModule ? a.default : a;
16
20
  }
21
+
17
22
  function $parcel$export(e, n, v, s) {
18
23
  Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
19
24
  }
@@ -129,7 +134,7 @@ $c14528ddc146317f$export$9fcb3d6af94a9d12 = `YO3Nla_spectrum-Textfield-wrapper--
129
134
 
130
135
 
131
136
  function $599adb75312e6492$var$TextFieldBase(props, ref) {
132
- let { validationState: validationState, icon: icon, isQuiet: isQuiet = false, isDisabled: isDisabled, multiLine: multiLine, autoFocus: autoFocus, inputClassName: inputClassName, wrapperChildren: wrapperChildren, labelProps: labelProps, inputProps: inputProps, descriptionProps: descriptionProps, errorMessageProps: errorMessageProps, inputRef: userInputRef, isLoading: isLoading, loadingIndicator: loadingIndicator, validationIconClassName: validationIconClassName, disableFocusRing: disableFocusRing } = props;
137
+ let { validationState: validationState = props.isInvalid ? "invalid" : null, icon: icon, isQuiet: isQuiet = false, isDisabled: isDisabled, multiLine: multiLine, autoFocus: autoFocus, inputClassName: inputClassName, wrapperChildren: wrapperChildren, labelProps: labelProps, inputProps: inputProps, descriptionProps: descriptionProps, errorMessageProps: errorMessageProps, inputRef: userInputRef, isLoading: isLoading, loadingIndicator: loadingIndicator, validationIconClassName: validationIconClassName, disableFocusRing: disableFocusRing } = props;
133
138
  let { hoverProps: hoverProps, isHovered: isHovered } = (0, $evhxb$useHover)({
134
139
  isDisabled: isDisabled
135
140
  });
@@ -199,11 +204,14 @@ const $599adb75312e6492$export$d22444a338b6e3c2 = /*#__PURE__*/ (0, $evhxb$forwa
199
204
 
200
205
 
201
206
 
207
+
202
208
  function $cc187bf91f8eea73$var$TextArea(props, ref) {
203
209
  props = (0, $evhxb$useProviderProps)(props);
210
+ props = (0, $evhxb$useFormProps)(props);
204
211
  let { isDisabled: isDisabled = false, isQuiet: isQuiet = false, isReadOnly: isReadOnly = false, isRequired: isRequired = false, onChange: onChange, ...otherProps } = props;
212
+ var _props_defaultValue;
205
213
  // not in stately because this is so we know when to re-measure, which is a spectrum design
206
- let [inputValue, setInputValue] = (0, $evhxb$useControlledState)(props.value, props.defaultValue, ()=>{});
214
+ let [inputValue, setInputValue] = (0, $evhxb$useControlledState)(props.value, (_props_defaultValue = props.defaultValue) !== null && _props_defaultValue !== void 0 ? _props_defaultValue : "", ()=>{});
207
215
  let inputRef = (0, $evhxb$useRef)(null);
208
216
  let onHeightChange = (0, $evhxb$useCallback)(()=>{
209
217
  // Quiet textareas always grow based on their text content.
@@ -237,7 +245,7 @@ function $cc187bf91f8eea73$var$TextArea(props, ref) {
237
245
  inputRef
238
246
  ]);
239
247
  if (props.placeholder) console.warn("Placeholders are deprecated due to accessibility issues. Please use help text instead. See the docs for details: https://react-spectrum.adobe.com/react-spectrum/TextArea.html#help-text");
240
- let { labelProps: labelProps, inputProps: inputProps, descriptionProps: descriptionProps, errorMessageProps: errorMessageProps } = (0, $evhxb$useTextField)({
248
+ let result = (0, $evhxb$useTextField)({
241
249
  ...props,
242
250
  onChange: (0, $evhxb$chain)(onChange, setInputValue),
243
251
  inputElementType: "textarea"
@@ -246,10 +254,7 @@ function $cc187bf91f8eea73$var$TextArea(props, ref) {
246
254
  ...otherProps,
247
255
  ref: ref,
248
256
  inputRef: inputRef,
249
- labelProps: labelProps,
250
- inputProps: inputProps,
251
- descriptionProps: descriptionProps,
252
- errorMessageProps: errorMessageProps,
257
+ ...result,
253
258
  multiLine: true,
254
259
  isDisabled: isDisabled,
255
260
  isQuiet: isQuiet,
@@ -278,17 +283,16 @@ function $cc187bf91f8eea73$var$TextArea(props, ref) {
278
283
 
279
284
 
280
285
 
286
+
281
287
  function $265457f9427aa380$var$TextField(props, ref) {
282
288
  props = (0, $evhxb$useProviderProps)(props);
289
+ props = (0, $evhxb$useFormProps)(props);
283
290
  let inputRef = (0, $evhxb$useRef)(null);
284
- let { labelProps: labelProps, inputProps: inputProps, descriptionProps: descriptionProps, errorMessageProps: errorMessageProps } = (0, $evhxb$useTextField)(props, inputRef);
291
+ let result = (0, $evhxb$useTextField)(props, inputRef);
285
292
  if (props.placeholder) console.warn("Placeholders are deprecated due to accessibility issues. Please use help text instead. See the docs for details: https://react-spectrum.adobe.com/react-spectrum/TextField.html#help-text");
286
293
  return /*#__PURE__*/ (0, $evhxb$react).createElement((0, $599adb75312e6492$export$d22444a338b6e3c2), {
287
294
  ...props,
288
- labelProps: labelProps,
289
- inputProps: inputProps,
290
- descriptionProps: descriptionProps,
291
- errorMessageProps: errorMessageProps,
295
+ ...result,
292
296
  ref: ref,
293
297
  inputRef: inputRef
294
298
  });