diff --git a/id.saladeaula.digital/client/app/components/ui/form.tsx b/id.saladeaula.digital/client/app/components/ui/form.tsx new file mode 100644 index 0000000..524b986 --- /dev/null +++ b/id.saladeaula.digital/client/app/components/ui/form.tsx @@ -0,0 +1,167 @@ +"use client" + +import * as React from "react" +import * as LabelPrimitive from "@radix-ui/react-label" +import { Slot } from "@radix-ui/react-slot" +import { + Controller, + FormProvider, + useFormContext, + useFormState, + type ControllerProps, + type FieldPath, + type FieldValues, +} from "react-hook-form" + +import { cn } from "@/lib/utils" +import { Label } from "@/components/ui/label" + +const Form = FormProvider + +type FormFieldContextValue< + TFieldValues extends FieldValues = FieldValues, + TName extends FieldPath = FieldPath, +> = { + name: TName +} + +const FormFieldContext = React.createContext( + {} as FormFieldContextValue +) + +const FormField = < + TFieldValues extends FieldValues = FieldValues, + TName extends FieldPath = FieldPath, +>({ + ...props +}: ControllerProps) => { + return ( + + + + ) +} + +const useFormField = () => { + const fieldContext = React.useContext(FormFieldContext) + const itemContext = React.useContext(FormItemContext) + const { getFieldState } = useFormContext() + const formState = useFormState({ name: fieldContext.name }) + const fieldState = getFieldState(fieldContext.name, formState) + + if (!fieldContext) { + throw new Error("useFormField should be used within ") + } + + const { id } = itemContext + + return { + id, + name: fieldContext.name, + formItemId: `${id}-form-item`, + formDescriptionId: `${id}-form-item-description`, + formMessageId: `${id}-form-item-message`, + ...fieldState, + } +} + +type FormItemContextValue = { + id: string +} + +const FormItemContext = React.createContext( + {} as FormItemContextValue +) + +function FormItem({ className, ...props }: React.ComponentProps<"div">) { + const id = React.useId() + + return ( + +
+ + ) +} + +function FormLabel({ + className, + ...props +}: React.ComponentProps) { + const { error, formItemId } = useFormField() + + return ( +
-
-
-
-

- Faça login -

-

- Não tem uma conta?{' '} - - Cadastre-se - - . -

-
- -
- - -
- -
-
- - - Esqueceu sua senha? - + + +
+
+

+ Faça login +

+

+ Não tem uma conta?{' '} + + Cadastre-se + + . +

- ( + + Email ou CPF + + + + + + )} /> -
- setShow((x) => !x)} - tabIndex={-1} - /> - -
-
+ ( + + + + + +
+ setShow((x) => !x)} + tabIndex={-1} + /> + +
+ +
+ )} + /> - -
- + +
+ +

Ao fazer login, você concorda com nossa{' '} diff --git a/id.saladeaula.digital/client/package-lock.json b/id.saladeaula.digital/client/package-lock.json index 35826aa..c8dfd50 100644 --- a/id.saladeaula.digital/client/package-lock.json +++ b/id.saladeaula.digital/client/package-lock.json @@ -1,14 +1,14 @@ { - "name": "client", + "name": "id-saladeaula-digital", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "client", + "name": "id-saladeaula-digital", "hasInstallScript": true, "dependencies": { "@brazilian-utils/brazilian-utils": "^1.0.0-rc.12", - "@hookform/resolvers": "^5.2.1", + "@hookform/resolvers": "^5.2.2", "@radix-ui/react-checkbox": "^1.3.3", "@radix-ui/react-label": "^2.1.7", "@radix-ui/react-slot": "^1.2.3", @@ -22,7 +22,7 @@ "react-hook-form": "^7.62.0", "react-router": "^7.7.1", "tailwind-merge": "^3.3.1", - "zod": "^4.0.17" + "zod": "^4.1.8" }, "devDependencies": { "@cloudflare/vite-plugin": "^1.0.12", @@ -1168,9 +1168,9 @@ } }, "node_modules/@hookform/resolvers": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/@hookform/resolvers/-/resolvers-5.2.1.tgz", - "integrity": "sha512-u0+6X58gkjMcxur1wRWokA7XsiiBJ6aK17aPZxhkoYiK5J+HcTx0Vhu9ovXe6H+dVpO6cjrn2FkJTryXEMlryQ==", + "version": "5.2.2", + "resolved": "https://registry.npmjs.org/@hookform/resolvers/-/resolvers-5.2.2.tgz", + "integrity": "sha512-A/IxlMLShx3KjV/HeTcTfaMxdwy690+L/ZADoeaTltLx+CVuzkeVIPuybK3jrRfw7YZnmdKsVVHAlEPIAEUNlA==", "license": "MIT", "dependencies": { "@standard-schema/utils": "^0.3.0" @@ -5800,9 +5800,9 @@ "license": "MIT" }, "node_modules/zod": { - "version": "4.0.17", - "resolved": "https://registry.npmjs.org/zod/-/zod-4.0.17.tgz", - "integrity": "sha512-1PHjlYRevNxxdy2JZ8JcNAw7rX8V9P1AKkP+x/xZfxB0K5FYfuV+Ug6P/6NVSR2jHQ+FzDDoDHS04nYUsOIyLQ==", + "version": "4.1.8", + "resolved": "https://registry.npmjs.org/zod/-/zod-4.1.8.tgz", + "integrity": "sha512-5R1P+WwQqmmMIEACyzSvo4JXHY5WiAFHRMg+zBZKgKS+Q1viRa0C1hmUKtHltoIFKtIdki3pRxkmpP74jnNYHQ==", "license": "MIT", "funding": { "url": "https://github.com/sponsors/colinhacks" diff --git a/id.saladeaula.digital/client/package.json b/id.saladeaula.digital/client/package.json index 53723ea..bcc4253 100644 --- a/id.saladeaula.digital/client/package.json +++ b/id.saladeaula.digital/client/package.json @@ -13,7 +13,7 @@ }, "dependencies": { "@brazilian-utils/brazilian-utils": "^1.0.0-rc.12", - "@hookform/resolvers": "^5.2.1", + "@hookform/resolvers": "^5.2.2", "@radix-ui/react-checkbox": "^1.3.3", "@radix-ui/react-label": "^2.1.7", "@radix-ui/react-slot": "^1.2.3", @@ -27,7 +27,7 @@ "react-hook-form": "^7.62.0", "react-router": "^7.7.1", "tailwind-merge": "^3.3.1", - "zod": "^4.0.17" + "zod": "^4.1.8" }, "devDependencies": { "@cloudflare/vite-plugin": "^1.0.12",