|
1 |
| -import { forwardRef } from 'react'; |
2 |
| - |
3 | 1 | import { InputError } from './input-error';
|
4 | 2 | import { InputHelp } from './input-help';
|
5 | 3 |
|
@@ -30,23 +28,21 @@ export interface InputFieldProps {
|
30 | 28 | type?: 'email' | 'number' | 'password' | 'search' | 'tel' | 'text' | 'url';
|
31 | 29 | }
|
32 | 30 |
|
33 |
| -const InputField = forwardRef<HTMLInputElement, InputFieldProps>((props, ref) => { |
34 |
| - const { |
35 |
| - ariaDescribedby, |
36 |
| - errorMessage, |
37 |
| - className, |
38 |
| - defaultValue, |
39 |
| - helpMessagePrimary, |
40 |
| - helpMessagePrimaryClassName, |
41 |
| - helpMessageSecondary, |
42 |
| - helpMessageSecondaryClassName, |
43 |
| - id, |
44 |
| - label, |
45 |
| - required, |
46 |
| - type = 'text', |
47 |
| - ...restInputProps |
48 |
| - } = props; |
49 |
| - |
| 31 | +export function InputField({ |
| 32 | + ariaDescribedby, |
| 33 | + errorMessage, |
| 34 | + className, |
| 35 | + defaultValue, |
| 36 | + helpMessagePrimary, |
| 37 | + helpMessagePrimaryClassName, |
| 38 | + helpMessageSecondary, |
| 39 | + helpMessageSecondaryClassName, |
| 40 | + id, |
| 41 | + label, |
| 42 | + required, |
| 43 | + type = 'text', |
| 44 | + ...restInputProps |
| 45 | +}: InputFieldProps) { |
50 | 46 | const inputErrorId = `input-${id}-error`;
|
51 | 47 | const inputHelpMessagePrimaryId = `input-${id}-help-primary`;
|
52 | 48 | const inputHelpMessageSecondaryId = `input-${id}-help-secondary`;
|
@@ -81,7 +77,6 @@ const InputField = forwardRef<HTMLInputElement, InputFieldProps>((props, ref) =>
|
81 | 77 | </InputHelp>
|
82 | 78 | )}
|
83 | 79 | <input
|
84 |
| - ref={ref} |
85 | 80 | aria-describedby={getAriaDescribedby()}
|
86 | 81 | aria-errormessage={errorMessage ? inputErrorId : undefined}
|
87 | 82 | aria-invalid={!!errorMessage}
|
@@ -112,8 +107,4 @@ const InputField = forwardRef<HTMLInputElement, InputFieldProps>((props, ref) =>
|
112 | 107 | )}
|
113 | 108 | </div>
|
114 | 109 | );
|
115 |
| -}); |
116 |
| - |
117 |
| -InputField.displayName = 'InputField'; |
118 |
| - |
119 |
| -export { InputField }; |
| 110 | +} |
0 commit comments