@react-spectrum/textfield 3.0.0-nightly.2519 → 3.0.0-nightly.2534
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 +116 -77
- package/dist/main.js +116 -77
- package/dist/main.js.map +1 -1
- package/dist/module.js +116 -77
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +2 -2
- package/dist/types.d.ts.map +1 -1
- package/package.json +16 -15
- package/src/TextArea.tsx +5 -6
- package/src/TextField.tsx +4 -5
- package/src/TextFieldBase.tsx +3 -3
package/src/TextField.tsx
CHANGED
@@ -13,14 +13,16 @@
|
|
13
13
|
import React, {forwardRef, Ref, useRef} from 'react';
|
14
14
|
import {SpectrumTextFieldProps, TextFieldRef} from '@react-types/textfield';
|
15
15
|
import {TextFieldBase} from './TextFieldBase';
|
16
|
+
import {useFormProps} from '@react-spectrum/form';
|
16
17
|
import {useProviderProps} from '@react-spectrum/provider';
|
17
18
|
import {useTextField} from '@react-aria/textfield';
|
18
19
|
|
19
20
|
function TextField(props: SpectrumTextFieldProps, ref: Ref<TextFieldRef>) {
|
20
21
|
props = useProviderProps(props);
|
22
|
+
props = useFormProps(props);
|
21
23
|
|
22
24
|
let inputRef = useRef<HTMLInputElement>(null);
|
23
|
-
let
|
25
|
+
let result = useTextField(props, inputRef);
|
24
26
|
|
25
27
|
if (props.placeholder) {
|
26
28
|
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');
|
@@ -29,10 +31,7 @@ function TextField(props: SpectrumTextFieldProps, ref: Ref<TextFieldRef>) {
|
|
29
31
|
return (
|
30
32
|
<TextFieldBase
|
31
33
|
{...props}
|
32
|
-
|
33
|
-
inputProps={inputProps}
|
34
|
-
descriptionProps={descriptionProps}
|
35
|
-
errorMessageProps={errorMessageProps}
|
34
|
+
{...result}
|
36
35
|
ref={ref}
|
37
36
|
inputRef={inputRef} />
|
38
37
|
);
|
package/src/TextFieldBase.tsx
CHANGED
@@ -15,14 +15,14 @@ import CheckmarkMedium from '@spectrum-icons/ui/CheckmarkMedium';
|
|
15
15
|
import {classNames, createFocusableRef} from '@react-spectrum/utils';
|
16
16
|
import {Field} from '@react-spectrum/label';
|
17
17
|
import {mergeProps} from '@react-aria/utils';
|
18
|
-
import {PressEvents} from '@react-types/shared';
|
18
|
+
import {PressEvents, ValidationResult} from '@react-types/shared';
|
19
19
|
import React, {cloneElement, forwardRef, HTMLAttributes, InputHTMLAttributes, LabelHTMLAttributes, ReactElement, Ref, RefObject, TextareaHTMLAttributes, useImperativeHandle, useRef} from 'react';
|
20
20
|
import {SpectrumTextFieldProps, TextFieldRef} from '@react-types/textfield';
|
21
21
|
import styles from '@adobe/spectrum-css-temp/components/textfield/vars.css';
|
22
22
|
import {useFocusRing} from '@react-aria/focus';
|
23
23
|
import {useHover} from '@react-aria/interactions';
|
24
24
|
|
25
|
-
interface TextFieldBaseProps extends Omit<SpectrumTextFieldProps, 'onChange'>, PressEvents {
|
25
|
+
interface TextFieldBaseProps extends Omit<SpectrumTextFieldProps, 'onChange' | 'validate'>, PressEvents, Partial<ValidationResult> {
|
26
26
|
wrapperChildren?: ReactElement | ReactElement[],
|
27
27
|
inputClassName?: string,
|
28
28
|
validationIconClassName?: string,
|
@@ -39,7 +39,7 @@ interface TextFieldBaseProps extends Omit<SpectrumTextFieldProps, 'onChange'>, P
|
|
39
39
|
|
40
40
|
function TextFieldBase(props: TextFieldBaseProps, ref: Ref<TextFieldRef>) {
|
41
41
|
let {
|
42
|
-
validationState,
|
42
|
+
validationState = props.isInvalid ? 'invalid' : null,
|
43
43
|
icon,
|
44
44
|
isQuiet = false,
|
45
45
|
isDisabled,
|