Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion packages/angular/src/lib/auth/forms/sign-in-auth-form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,13 @@ import {
></fui-form-input>
</fieldset>
<fieldset>
<fui-form-input name="password" tanstack-app-field [tanstackField]="form" label="{{ passwordLabel() }}">
<fui-form-input
name="password"
tanstack-app-field
[tanstackField]="form"
label="{{ passwordLabel() }}"
type="password"
>
@if (forgotPassword) {
<button fui-form-action (click)="forgotPassword.emit()">
{{ forgotPasswordLabel() }}
Expand Down
8 changes: 7 additions & 1 deletion packages/angular/src/lib/auth/forms/sign-up-auth-form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,13 @@ import {
<fui-form-input name="email" tanstack-app-field [tanstackField]="form" label="{{ emailLabel() }}" />
</fieldset>
<fieldset>
<fui-form-input name="password" tanstack-app-field [tanstackField]="form" label="{{ passwordLabel() }}" />
<fui-form-input
name="password"
tanstack-app-field
[tanstackField]="form"
label="{{ passwordLabel() }}"
type="password"
/>
</fieldset>
<fui-policies />
<fieldset>
Expand Down
2 changes: 2 additions & 0 deletions packages/angular/src/lib/components/form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export class FormMetadataComponent {
<span>{{ label() }}</span>
<input
[attr.aria-invalid]="field.api.state.meta.isTouched && field.api.state.meta.errors.length > 0"
[type]="type()"
[id]="field.api.name"
[name]="field.api.name"
[value]="field.api.state.value"
Expand All @@ -47,6 +48,7 @@ export class FormMetadataComponent {
export class FormInputComponent {
field = injectField<string>();
label = input.required<string>();
type = input<string>("text");
}

@Component({
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/auth/forms/sign-in-auth-form.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ describe("<SignInAuthForm />", () => {

// Make sure we have an email and password input
expect(screen.getByRole("textbox", { name: /email/i })).toBeInTheDocument();
expect(screen.getByRole("textbox", { name: /password/i })).toBeInTheDocument();
expect(screen.getByLabelText(/password/i)).toBeInTheDocument();

// Ensure the "Sign In" button is present and is a submit button
const signInButton = screen.getByRole("button", { name: "signIn" });
Expand Down
6 changes: 3 additions & 3 deletions packages/react/src/auth/forms/sign-up-auth-form.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ describe("<SignUpAuthForm />", () => {

// Make sure we have an email and password input with translated labels
expect(screen.getByRole("textbox", { name: /emailAddress/ })).toBeInTheDocument();
expect(screen.getByRole("textbox", { name: /password/ })).toBeInTheDocument();
expect(screen.getByLabelText(/password/)).toBeInTheDocument();

// Ensure the "Create Account" button is present and is a submit button
const createAccountButton = screen.getByRole("button", { name: "createAccount" });
Expand Down Expand Up @@ -365,7 +365,7 @@ describe("<SignUpAuthForm />", () => {

// Make sure we have all three inputs with translated labels
expect(screen.getByRole("textbox", { name: /emailAddress/ })).toBeInTheDocument();
expect(screen.getByRole("textbox", { name: /password/ })).toBeInTheDocument();
expect(screen.getByLabelText(/password/)).toBeInTheDocument();
expect(screen.getByRole("textbox", { name: /displayName/ })).toBeInTheDocument();

// Ensure the "Create Account" button is present and is a submit button
Expand Down Expand Up @@ -397,7 +397,7 @@ describe("<SignUpAuthForm />", () => {
expect(form.length).toBe(1);

expect(screen.getByRole("textbox", { name: /email/ })).toBeInTheDocument();
expect(screen.getByRole("textbox", { name: /password/ })).toBeInTheDocument();
expect(screen.getByLabelText(/password/)).toBeInTheDocument();
expect(screen.queryByRole("textbox", { name: /displayName/ })).not.toBeInTheDocument();
});

Expand Down
14 changes: 10 additions & 4 deletions packages/react/src/components/form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,21 @@ function FieldMetadata({ className, ...props }: ComponentProps<"div"> & { field:
);
}

function Input(props: PropsWithChildren<ComponentProps<"input"> & { label: string; before?: ReactNode }>) {
function Input({
children,
before,
label,
...props
}: PropsWithChildren<ComponentProps<"input"> & { label: string; before?: ReactNode }>) {
const field = useFieldContext<string>();

return (
<label htmlFor={field.name}>
<span>{props.label}</span>
<span>{label}</span>
<div data-input-group>
{props.before}
{before}
<input
{...props}
aria-invalid={field.state.meta.isTouched && field.state.meta.errors.length > 0}
id={field.name}
name={field.name}
Expand All @@ -40,7 +46,7 @@ function Input(props: PropsWithChildren<ComponentProps<"input"> & { label: strin
}}
/>
</div>
{props.children ? <>{props.children}</> : null}
{children ? <>{children}</> : null}
<FieldMetadata field={field} />
</label>
);
Expand Down