57 | {label ? (
58 |
59 |
60 | {label}
61 | {required ? (
62 | *
63 | ) : null}
64 |
65 | {error ? (
66 |
67 | {error}
68 |
69 | ) : null}
70 | {alt ?
{alt} : null}
71 |
72 | ) : null}
73 |
74 | {variant !== 'description-below' && descriptionElement}
75 |
76 | {childNodes.length === 1
77 | ? cloneElement(childNodes[0], {
78 | ...childNodes[0].props,
79 | id: inputId,
80 | invalid:
81 | (childNodes[0].type as any).name === Input.name
82 | ? invalid
83 | : undefined,
84 | required: childNodes[0].props.required || required,
85 | 'aria-invalid': invalid,
86 | 'aria-describedby': [error && errorId, description && descriptionId]
87 | .filter(Boolean)
88 | .join(' '),
89 | })
90 | : children}
91 |
92 | {variant === 'description-below' && descriptionElement}
93 |
94 | );
95 | }
96 |
97 | export default Field;
98 |
--------------------------------------------------------------------------------
/packages/nextjs-auth-ui/src/shared/input.tsx:
--------------------------------------------------------------------------------
1 | import cn from 'clsx';
2 |
3 | type InputProps = {
4 | invalid?: boolean;
5 | resize?: boolean;
6 | flat?: boolean;
7 | className?: string;
8 | status?: 'initial' | 'error' | 'success';
9 | type?: 'textarea' | string;
10 | 'aria-label'?: string;
11 | } & Record