create-huenei-template 0.2.13 → 0.2.15
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/config/templates.js +7 -0
- package/dist/templates/cursor/.cursor/agents/config-drift-analyzer.md +152 -0
- package/dist/templates/cursor/.cursor/commands/actualizar-reglas.md +580 -0
- package/dist/templates/frontend/react-ssr/.cursor/agents/accessibility-reviewer.md +22 -0
- package/dist/templates/frontend/react-ssr/.cursor/agents/nextjs-code-reviewer.md +24 -0
- package/dist/templates/frontend/react-ssr/.cursor/agents/react-test-expert.md +32 -0
- package/dist/templates/frontend/react-ssr/.cursor/agents/security-auditor.md +25 -0
- package/dist/templates/frontend/react-ssr/.cursor/commands/new-component.md +97 -0
- package/dist/templates/frontend/react-ssr/.cursor/commands/new-page.md +95 -0
- package/dist/templates/frontend/react-ssr/.cursor/commands/new-prisma-model.md +66 -0
- package/dist/templates/frontend/react-ssr/.cursor/commands/new-server-action.md +89 -0
- package/dist/templates/frontend/react-ssr/.cursor/hooks/auto-format.ts +64 -0
- package/dist/templates/frontend/react-ssr/.cursor/hooks/auto-test-on-stop.ts +94 -0
- package/dist/templates/frontend/react-ssr/.cursor/hooks/block-dangerous-commands.ts +120 -0
- package/dist/templates/frontend/react-ssr/.cursor/hooks/ensure-tests-exist.ts +209 -0
- package/dist/templates/frontend/react-ssr/.cursor/hooks/protect-sensitive-files.ts +101 -0
- package/dist/templates/frontend/react-ssr/.cursor/hooks/session-context.ts +93 -0
- package/dist/templates/frontend/react-ssr/.cursor/hooks/tsconfig.json +10 -0
- package/dist/templates/frontend/react-ssr/.cursor/hooks.json +41 -0
- package/dist/templates/frontend/react-ssr/.cursor/rules/auth-patterns.mdc +48 -0
- package/dist/templates/frontend/react-ssr/.cursor/rules/code-quality.mdc +39 -0
- package/dist/templates/frontend/react-ssr/.cursor/rules/naming-conventions.mdc +32 -0
- package/dist/templates/frontend/react-ssr/.cursor/rules/nextjs-architecture.mdc +51 -0
- package/dist/templates/frontend/react-ssr/.cursor/rules/prisma-standards.mdc +53 -0
- package/dist/templates/frontend/react-ssr/.cursor/rules/react-conventions.mdc +52 -0
- package/dist/templates/frontend/react-ssr/.cursor/rules/testing-conventions.mdc +53 -0
- package/dist/templates/frontend/react-ssr/.cursor/rules/ui-stack.mdc +47 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/authjs-skills/SKILL.md +1149 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/daisyui-5/SKILL.md +189 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/daisyui-5/daisyUI5.skill +0 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/daisyui-5/references/creating-components.md +412 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/daisyui-5/references/data-display.md +341 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/daisyui-5/references/feedback.md +240 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/daisyui-5/references/input.md +283 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/daisyui-5/references/layout.md +275 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/daisyui-5/references/navigation.md +338 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/daisyui-5/scripts/daisy-meta.ts +220 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/daisyui-5/scripts/generate-daisy-safelist.ts +152 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/docker-expert/SKILL.md +413 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/nextjs-app-router-patterns/SKILL.md +537 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-cli/SKILL.md +243 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/db-execute.md +75 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/db-pull.md +185 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/db-push.md +148 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/db-seed.md +191 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/debug.md +46 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/dev.md +157 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/format.md +48 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/generate.md +147 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/init.md +118 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/migrate-deploy.md +127 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/migrate-dev.md +143 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/migrate-diff.md +89 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/migrate-reset.md +72 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/migrate-resolve.md +57 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/migrate-status.md +65 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/studio.md +122 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/validate.md +53 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-client-api/SKILL.md +216 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-client-api/references/client-methods.md +221 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-client-api/references/constructor.md +185 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-client-api/references/filters.md +256 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-client-api/references/model-queries.md +281 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-client-api/references/query-options.md +276 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-client-api/references/raw-queries.md +194 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-client-api/references/relations.md +308 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-client-api/references/transactions.md +184 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/AGENTS.md +97 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/README.md +138 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/SKILL.md +116 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/assets/templates/_template.md +26 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/_sections.md +46 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/adv-devtools-performance.md +69 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/adv-formprovider-memo.md +78 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/adv-testing-wrapper.md +63 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/array-complete-default-objects.md +66 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/array-separate-crud-operations.md +76 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/array-unique-fieldarray-per-name.md +58 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/array-use-field-id-as-key.md +54 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/array-virtualization-formprovider.md +64 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/ctrl-avoid-double-registration.md +46 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/ctrl-controller-field-props.md +56 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/ctrl-local-state-combination.md +69 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/ctrl-single-usecontroller-per-component.md +62 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/ctrl-usecontroller-isolation.md +64 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formcfg-async-default-values.md +69 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formcfg-default-values.md +57 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formcfg-revalidate-mode.md +48 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formcfg-should-unregister.md +62 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formcfg-useeffect-dependency.md +54 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formcfg-validation-mode.md +51 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formstate-avoid-isvalid-with-onsubmit.md +58 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formstate-destructure-formstate.md +48 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formstate-getfieldstate-for-single-field.md +49 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formstate-subscribe-to-specific-fields.md +54 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formstate-useformstate-isolation.md +62 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/integ-mui-controller-pattern.md +59 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/integ-shadcn-form-import.md +64 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/integ-shadcn-select-wiring.md +64 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/integ-value-transform.md +59 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/sub-avoid-watch-in-render.md +48 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/sub-deep-subscription.md +62 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/sub-useformcontext-sparingly.md +58 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/sub-usewatch-default-value.md +50 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/sub-usewatch-over-watch.md +58 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/sub-usewatch-with-getvalues.md +54 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/sub-watch-specific-fields.md +54 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/valid-delay-error.md +52 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/valid-dynamic-schema-factory.md +57 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/valid-error-message-strategy.md +65 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/valid-inline-vs-resolver.md +63 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/valid-native-validation.md +60 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/valid-resolver-caching.md +58 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/recharts/SKILL.md +713 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/recharts/references/api_reference.md +1121 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/recharts/references/best_practices.md +782 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/recharts/references/examples.md +940 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/SKILL.md +114 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/cache-gc-time.md +93 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/cache-invalidation.md +116 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/cache-placeholder-vs-initial.md +156 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/cache-stale-time.md +80 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/err-error-boundaries.md +150 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/inf-page-params.md +132 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/mut-invalidate-queries.md +118 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/mut-mutation-state.md +169 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/mut-optimistic-updates.md +137 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/network-mode.md +179 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/parallel-use-queries.md +152 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/perf-select-transform.md +144 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/persist-queries.md +194 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/pf-intent-prefetch.md +143 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/qk-array-structure.md +50 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/qk-factory-pattern.md +102 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/qk-hierarchical-organization.md +76 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/qk-include-dependencies.md +62 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/qk-serializable.md +93 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/query-cancellation.md +171 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/ssr-dehydration.md +158 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-table/SKILL.md +582 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/zod-4/SKILL.md +216 -0
- package/dist/templates/frontend/react-ssr/.dockerignore +14 -0
- package/dist/templates/frontend/react-ssr/.env.example +9 -0
- package/dist/templates/frontend/react-ssr/.husky/pre-commit +1 -0
- package/dist/templates/frontend/react-ssr/Dockerfile +41 -0
- package/dist/templates/frontend/react-ssr/README.md +121 -0
- package/dist/templates/frontend/react-ssr/components.json +22 -0
- package/dist/templates/frontend/react-ssr/docker-compose.yml +21 -0
- package/dist/templates/frontend/react-ssr/eslint.config.mjs +26 -0
- package/dist/templates/frontend/react-ssr/next.config.ts +7 -0
- package/dist/templates/frontend/react-ssr/package.json +86 -0
- package/dist/templates/frontend/react-ssr/postcss.config.mjs +5 -0
- package/dist/templates/frontend/react-ssr/prisma/schema.prisma +75 -0
- package/dist/templates/frontend/react-ssr/prisma/seed.ts +109 -0
- package/dist/templates/frontend/react-ssr/prisma.config.ts +17 -0
- package/dist/templates/frontend/react-ssr/skills-lock.json +65 -0
- package/dist/templates/frontend/react-ssr/src/__tests__/components/ui/badge.test.tsx +26 -0
- package/dist/templates/frontend/react-ssr/src/__tests__/components/ui/button.test.tsx +38 -0
- package/dist/templates/frontend/react-ssr/src/__tests__/components/ui/card.test.tsx +39 -0
- package/dist/templates/frontend/react-ssr/src/__tests__/components/ui/input.test.tsx +32 -0
- package/dist/templates/frontend/react-ssr/src/__tests__/hooks/useLocalStorage.test.ts +53 -0
- package/dist/templates/frontend/react-ssr/src/__tests__/lib/queryClient.test.ts +19 -0
- package/dist/templates/frontend/react-ssr/src/__tests__/lib/utils.test.ts +24 -0
- package/dist/templates/frontend/react-ssr/src/actions/auth.ts +91 -0
- package/dist/templates/frontend/react-ssr/src/actions/contacto.ts +46 -0
- package/dist/templates/frontend/react-ssr/src/actions/proyectos.ts +159 -0
- package/dist/templates/frontend/react-ssr/src/app/(authenticated)/dashboard/dashboard-client.tsx +321 -0
- package/dist/templates/frontend/react-ssr/src/app/(authenticated)/dashboard/page.tsx +48 -0
- package/dist/templates/frontend/react-ssr/src/app/(authenticated)/layout.tsx +34 -0
- package/dist/templates/frontend/react-ssr/src/app/(authenticated)/perfil/page.tsx +85 -0
- package/dist/templates/frontend/react-ssr/src/app/(authenticated)/proyectos-crud/page.tsx +23 -0
- package/dist/templates/frontend/react-ssr/src/app/(authenticated)/proyectos-crud/proyectos-crud-client.tsx +472 -0
- package/dist/templates/frontend/react-ssr/src/app/(authenticated)/ui-components/page.tsx +358 -0
- package/dist/templates/frontend/react-ssr/src/app/api/auth/[...nextauth]/route.ts +3 -0
- package/dist/templates/frontend/react-ssr/src/app/auth/iniciar-sesion/page.tsx +148 -0
- package/dist/templates/frontend/react-ssr/src/app/auth/recuperar-password/page.tsx +100 -0
- package/dist/templates/frontend/react-ssr/src/app/auth/registro/page.tsx +154 -0
- package/dist/templates/frontend/react-ssr/src/app/contacto/contacto-form.tsx +189 -0
- package/dist/templates/frontend/react-ssr/src/app/contacto/page.tsx +11 -0
- package/dist/templates/frontend/react-ssr/src/app/globals.css +99 -0
- package/dist/templates/frontend/react-ssr/src/app/layout.tsx +22 -0
- package/dist/templates/frontend/react-ssr/src/app/loading.tsx +7 -0
- package/dist/templates/frontend/react-ssr/src/app/not-found.tsx +14 -0
- package/dist/templates/frontend/react-ssr/src/app/page.tsx +331 -0
- package/dist/templates/frontend/react-ssr/src/app/proyectos/page.tsx +178 -0
- package/dist/templates/frontend/react-ssr/src/auth.ts +64 -0
- package/dist/templates/frontend/react-ssr/src/components/layout/navbar.tsx +68 -0
- package/dist/templates/frontend/react-ssr/src/components/layout/sidebar.tsx +109 -0
- package/dist/templates/frontend/react-ssr/src/components/layout/sign-out-button.tsx +16 -0
- package/dist/templates/frontend/react-ssr/src/components/providers.tsx +33 -0
- package/dist/templates/frontend/react-ssr/src/components/ui/avatar.tsx +53 -0
- package/dist/templates/frontend/react-ssr/src/components/ui/badge.tsx +42 -0
- package/dist/templates/frontend/react-ssr/src/components/ui/breadcrumb.tsx +114 -0
- package/dist/templates/frontend/react-ssr/src/components/ui/button.tsx +58 -0
- package/dist/templates/frontend/react-ssr/src/components/ui/card.tsx +95 -0
- package/dist/templates/frontend/react-ssr/src/components/ui/dialog.tsx +136 -0
- package/dist/templates/frontend/react-ssr/src/components/ui/form.tsx +168 -0
- package/dist/templates/frontend/react-ssr/src/components/ui/input.tsx +22 -0
- package/dist/templates/frontend/react-ssr/src/components/ui/label.tsx +26 -0
- package/dist/templates/frontend/react-ssr/src/components/ui/password-input.tsx +43 -0
- package/dist/templates/frontend/react-ssr/src/components/ui/separator.tsx +30 -0
- package/dist/templates/frontend/react-ssr/src/components/ui/table.tsx +240 -0
- package/dist/templates/frontend/react-ssr/src/components/ui/tabs.tsx +76 -0
- package/dist/templates/frontend/react-ssr/src/components/ui/textarea.tsx +21 -0
- package/dist/templates/frontend/react-ssr/src/data/dashboard.ts +179 -0
- package/dist/templates/frontend/react-ssr/src/hooks/useLocalStorage.ts +38 -0
- package/dist/templates/frontend/react-ssr/src/lib/prisma.ts +24 -0
- package/dist/templates/frontend/react-ssr/src/lib/queryClient.ts +25 -0
- package/dist/templates/frontend/react-ssr/src/lib/utils.ts +6 -0
- package/dist/templates/frontend/react-ssr/src/proxy.ts +31 -0
- package/dist/templates/frontend/react-ssr/src/test/mocks/next-navigation.ts +16 -0
- package/dist/templates/frontend/react-ssr/src/test/setup.ts +1 -0
- package/dist/templates/frontend/react-ssr/src/test/utils.tsx +30 -0
- package/dist/templates/frontend/react-ssr/src/types/index.ts +36 -0
- package/dist/templates/frontend/react-ssr/tsconfig.json +41 -0
- package/dist/templates/frontend/react-ssr/vitest.config.ts +41 -0
- package/package.json +1 -1
- package/templates/cursor/.cursor/agents/config-drift-analyzer.md +152 -0
- package/templates/cursor/.cursor/commands/actualizar-reglas.md +580 -0
- package/templates/frontend/react-ssr/.cursor/agents/accessibility-reviewer.md +22 -0
- package/templates/frontend/react-ssr/.cursor/agents/nextjs-code-reviewer.md +24 -0
- package/templates/frontend/react-ssr/.cursor/agents/react-test-expert.md +32 -0
- package/templates/frontend/react-ssr/.cursor/agents/security-auditor.md +25 -0
- package/templates/frontend/react-ssr/.cursor/commands/new-component.md +97 -0
- package/templates/frontend/react-ssr/.cursor/commands/new-page.md +95 -0
- package/templates/frontend/react-ssr/.cursor/commands/new-prisma-model.md +66 -0
- package/templates/frontend/react-ssr/.cursor/commands/new-server-action.md +89 -0
- package/templates/frontend/react-ssr/.cursor/hooks/auto-format.ts +64 -0
- package/templates/frontend/react-ssr/.cursor/hooks/auto-test-on-stop.ts +94 -0
- package/templates/frontend/react-ssr/.cursor/hooks/block-dangerous-commands.ts +120 -0
- package/templates/frontend/react-ssr/.cursor/hooks/ensure-tests-exist.ts +209 -0
- package/templates/frontend/react-ssr/.cursor/hooks/protect-sensitive-files.ts +101 -0
- package/templates/frontend/react-ssr/.cursor/hooks/session-context.ts +93 -0
- package/templates/frontend/react-ssr/.cursor/hooks/tsconfig.json +10 -0
- package/templates/frontend/react-ssr/.cursor/hooks.json +41 -0
- package/templates/frontend/react-ssr/.cursor/rules/auth-patterns.mdc +48 -0
- package/templates/frontend/react-ssr/.cursor/rules/code-quality.mdc +39 -0
- package/templates/frontend/react-ssr/.cursor/rules/naming-conventions.mdc +32 -0
- package/templates/frontend/react-ssr/.cursor/rules/nextjs-architecture.mdc +51 -0
- package/templates/frontend/react-ssr/.cursor/rules/prisma-standards.mdc +53 -0
- package/templates/frontend/react-ssr/.cursor/rules/react-conventions.mdc +52 -0
- package/templates/frontend/react-ssr/.cursor/rules/testing-conventions.mdc +53 -0
- package/templates/frontend/react-ssr/.cursor/rules/ui-stack.mdc +47 -0
- package/templates/frontend/react-ssr/.cursor/skills/authjs-skills/SKILL.md +1149 -0
- package/templates/frontend/react-ssr/.cursor/skills/daisyui-5/SKILL.md +189 -0
- package/templates/frontend/react-ssr/.cursor/skills/daisyui-5/daisyUI5.skill +0 -0
- package/templates/frontend/react-ssr/.cursor/skills/daisyui-5/references/creating-components.md +412 -0
- package/templates/frontend/react-ssr/.cursor/skills/daisyui-5/references/data-display.md +341 -0
- package/templates/frontend/react-ssr/.cursor/skills/daisyui-5/references/feedback.md +240 -0
- package/templates/frontend/react-ssr/.cursor/skills/daisyui-5/references/input.md +283 -0
- package/templates/frontend/react-ssr/.cursor/skills/daisyui-5/references/layout.md +275 -0
- package/templates/frontend/react-ssr/.cursor/skills/daisyui-5/references/navigation.md +338 -0
- package/templates/frontend/react-ssr/.cursor/skills/daisyui-5/scripts/daisy-meta.ts +220 -0
- package/templates/frontend/react-ssr/.cursor/skills/daisyui-5/scripts/generate-daisy-safelist.ts +152 -0
- package/templates/frontend/react-ssr/.cursor/skills/docker-expert/SKILL.md +413 -0
- package/templates/frontend/react-ssr/.cursor/skills/nextjs-app-router-patterns/SKILL.md +537 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-cli/SKILL.md +243 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/db-execute.md +75 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/db-pull.md +185 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/db-push.md +148 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/db-seed.md +191 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/debug.md +46 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/dev.md +157 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/format.md +48 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/generate.md +147 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/init.md +118 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/migrate-deploy.md +127 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/migrate-dev.md +143 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/migrate-diff.md +89 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/migrate-reset.md +72 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/migrate-resolve.md +57 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/migrate-status.md +65 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/studio.md +122 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/validate.md +53 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-client-api/SKILL.md +216 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-client-api/references/client-methods.md +221 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-client-api/references/constructor.md +185 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-client-api/references/filters.md +256 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-client-api/references/model-queries.md +281 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-client-api/references/query-options.md +276 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-client-api/references/raw-queries.md +194 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-client-api/references/relations.md +308 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-client-api/references/transactions.md +184 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/AGENTS.md +97 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/README.md +138 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/SKILL.md +116 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/assets/templates/_template.md +26 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/_sections.md +46 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/adv-devtools-performance.md +69 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/adv-formprovider-memo.md +78 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/adv-testing-wrapper.md +63 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/array-complete-default-objects.md +66 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/array-separate-crud-operations.md +76 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/array-unique-fieldarray-per-name.md +58 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/array-use-field-id-as-key.md +54 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/array-virtualization-formprovider.md +64 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/ctrl-avoid-double-registration.md +46 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/ctrl-controller-field-props.md +56 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/ctrl-local-state-combination.md +69 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/ctrl-single-usecontroller-per-component.md +62 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/ctrl-usecontroller-isolation.md +64 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formcfg-async-default-values.md +69 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formcfg-default-values.md +57 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formcfg-revalidate-mode.md +48 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formcfg-should-unregister.md +62 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formcfg-useeffect-dependency.md +54 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formcfg-validation-mode.md +51 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formstate-avoid-isvalid-with-onsubmit.md +58 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formstate-destructure-formstate.md +48 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formstate-getfieldstate-for-single-field.md +49 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formstate-subscribe-to-specific-fields.md +54 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formstate-useformstate-isolation.md +62 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/integ-mui-controller-pattern.md +59 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/integ-shadcn-form-import.md +64 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/integ-shadcn-select-wiring.md +64 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/integ-value-transform.md +59 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/sub-avoid-watch-in-render.md +48 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/sub-deep-subscription.md +62 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/sub-useformcontext-sparingly.md +58 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/sub-usewatch-default-value.md +50 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/sub-usewatch-over-watch.md +58 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/sub-usewatch-with-getvalues.md +54 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/sub-watch-specific-fields.md +54 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/valid-delay-error.md +52 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/valid-dynamic-schema-factory.md +57 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/valid-error-message-strategy.md +65 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/valid-inline-vs-resolver.md +63 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/valid-native-validation.md +60 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/valid-resolver-caching.md +58 -0
- package/templates/frontend/react-ssr/.cursor/skills/recharts/SKILL.md +713 -0
- package/templates/frontend/react-ssr/.cursor/skills/recharts/references/api_reference.md +1121 -0
- package/templates/frontend/react-ssr/.cursor/skills/recharts/references/best_practices.md +782 -0
- package/templates/frontend/react-ssr/.cursor/skills/recharts/references/examples.md +940 -0
- package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/SKILL.md +114 -0
- package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/cache-gc-time.md +93 -0
- package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/cache-invalidation.md +116 -0
- package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/cache-placeholder-vs-initial.md +156 -0
- package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/cache-stale-time.md +80 -0
- package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/err-error-boundaries.md +150 -0
- package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/inf-page-params.md +132 -0
- package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/mut-invalidate-queries.md +118 -0
- package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/mut-mutation-state.md +169 -0
- package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/mut-optimistic-updates.md +137 -0
- package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/network-mode.md +179 -0
- package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/parallel-use-queries.md +152 -0
- package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/perf-select-transform.md +144 -0
- package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/persist-queries.md +194 -0
- package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/pf-intent-prefetch.md +143 -0
- package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/qk-array-structure.md +50 -0
- package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/qk-factory-pattern.md +102 -0
- package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/qk-hierarchical-organization.md +76 -0
- package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/qk-include-dependencies.md +62 -0
- package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/qk-serializable.md +93 -0
- package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/query-cancellation.md +171 -0
- package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/ssr-dehydration.md +158 -0
- package/templates/frontend/react-ssr/.cursor/skills/tanstack-table/SKILL.md +582 -0
- package/templates/frontend/react-ssr/.cursor/skills/zod-4/SKILL.md +216 -0
- package/templates/frontend/react-ssr/.dockerignore +14 -0
- package/templates/frontend/react-ssr/.env.example +9 -0
- package/templates/frontend/react-ssr/.husky/pre-commit +1 -0
- package/templates/frontend/react-ssr/Dockerfile +41 -0
- package/templates/frontend/react-ssr/README.md +121 -0
- package/templates/frontend/react-ssr/components.json +22 -0
- package/templates/frontend/react-ssr/docker-compose.yml +21 -0
- package/templates/frontend/react-ssr/eslint.config.mjs +26 -0
- package/templates/frontend/react-ssr/next.config.ts +7 -0
- package/templates/frontend/react-ssr/package.json +86 -0
- package/templates/frontend/react-ssr/postcss.config.mjs +5 -0
- package/templates/frontend/react-ssr/prisma/schema.prisma +75 -0
- package/templates/frontend/react-ssr/prisma/seed.ts +109 -0
- package/templates/frontend/react-ssr/prisma.config.ts +17 -0
- package/templates/frontend/react-ssr/skills-lock.json +65 -0
- package/templates/frontend/react-ssr/src/__tests__/components/ui/badge.test.tsx +26 -0
- package/templates/frontend/react-ssr/src/__tests__/components/ui/button.test.tsx +38 -0
- package/templates/frontend/react-ssr/src/__tests__/components/ui/card.test.tsx +39 -0
- package/templates/frontend/react-ssr/src/__tests__/components/ui/input.test.tsx +32 -0
- package/templates/frontend/react-ssr/src/__tests__/hooks/useLocalStorage.test.ts +53 -0
- package/templates/frontend/react-ssr/src/__tests__/lib/queryClient.test.ts +19 -0
- package/templates/frontend/react-ssr/src/__tests__/lib/utils.test.ts +24 -0
- package/templates/frontend/react-ssr/src/actions/auth.ts +91 -0
- package/templates/frontend/react-ssr/src/actions/contacto.ts +46 -0
- package/templates/frontend/react-ssr/src/actions/proyectos.ts +159 -0
- package/templates/frontend/react-ssr/src/app/(authenticated)/dashboard/dashboard-client.tsx +321 -0
- package/templates/frontend/react-ssr/src/app/(authenticated)/dashboard/page.tsx +48 -0
- package/templates/frontend/react-ssr/src/app/(authenticated)/layout.tsx +34 -0
- package/templates/frontend/react-ssr/src/app/(authenticated)/perfil/page.tsx +85 -0
- package/templates/frontend/react-ssr/src/app/(authenticated)/proyectos-crud/page.tsx +23 -0
- package/templates/frontend/react-ssr/src/app/(authenticated)/proyectos-crud/proyectos-crud-client.tsx +472 -0
- package/templates/frontend/react-ssr/src/app/(authenticated)/ui-components/page.tsx +358 -0
- package/templates/frontend/react-ssr/src/app/api/auth/[...nextauth]/route.ts +3 -0
- package/templates/frontend/react-ssr/src/app/auth/iniciar-sesion/page.tsx +148 -0
- package/templates/frontend/react-ssr/src/app/auth/recuperar-password/page.tsx +100 -0
- package/templates/frontend/react-ssr/src/app/auth/registro/page.tsx +154 -0
- package/templates/frontend/react-ssr/src/app/contacto/contacto-form.tsx +189 -0
- package/templates/frontend/react-ssr/src/app/contacto/page.tsx +11 -0
- package/templates/frontend/react-ssr/src/app/globals.css +99 -0
- package/templates/frontend/react-ssr/src/app/layout.tsx +22 -0
- package/templates/frontend/react-ssr/src/app/loading.tsx +7 -0
- package/templates/frontend/react-ssr/src/app/not-found.tsx +14 -0
- package/templates/frontend/react-ssr/src/app/page.tsx +331 -0
- package/templates/frontend/react-ssr/src/app/proyectos/page.tsx +178 -0
- package/templates/frontend/react-ssr/src/auth.ts +64 -0
- package/templates/frontend/react-ssr/src/components/layout/navbar.tsx +68 -0
- package/templates/frontend/react-ssr/src/components/layout/sidebar.tsx +109 -0
- package/templates/frontend/react-ssr/src/components/layout/sign-out-button.tsx +16 -0
- package/templates/frontend/react-ssr/src/components/providers.tsx +33 -0
- package/templates/frontend/react-ssr/src/components/ui/avatar.tsx +53 -0
- package/templates/frontend/react-ssr/src/components/ui/badge.tsx +42 -0
- package/templates/frontend/react-ssr/src/components/ui/breadcrumb.tsx +114 -0
- package/templates/frontend/react-ssr/src/components/ui/button.tsx +58 -0
- package/templates/frontend/react-ssr/src/components/ui/card.tsx +95 -0
- package/templates/frontend/react-ssr/src/components/ui/dialog.tsx +136 -0
- package/templates/frontend/react-ssr/src/components/ui/form.tsx +168 -0
- package/templates/frontend/react-ssr/src/components/ui/input.tsx +22 -0
- package/templates/frontend/react-ssr/src/components/ui/label.tsx +26 -0
- package/templates/frontend/react-ssr/src/components/ui/password-input.tsx +43 -0
- package/templates/frontend/react-ssr/src/components/ui/separator.tsx +30 -0
- package/templates/frontend/react-ssr/src/components/ui/table.tsx +240 -0
- package/templates/frontend/react-ssr/src/components/ui/tabs.tsx +76 -0
- package/templates/frontend/react-ssr/src/components/ui/textarea.tsx +21 -0
- package/templates/frontend/react-ssr/src/data/dashboard.ts +179 -0
- package/templates/frontend/react-ssr/src/hooks/useLocalStorage.ts +38 -0
- package/templates/frontend/react-ssr/src/lib/prisma.ts +24 -0
- package/templates/frontend/react-ssr/src/lib/queryClient.ts +25 -0
- package/templates/frontend/react-ssr/src/lib/utils.ts +6 -0
- package/templates/frontend/react-ssr/src/proxy.ts +31 -0
- package/templates/frontend/react-ssr/src/test/mocks/next-navigation.ts +16 -0
- package/templates/frontend/react-ssr/src/test/setup.ts +1 -0
- package/templates/frontend/react-ssr/src/test/utils.tsx +30 -0
- package/templates/frontend/react-ssr/src/types/index.ts +36 -0
- package/templates/frontend/react-ssr/tsconfig.json +41 -0
- package/templates/frontend/react-ssr/vitest.config.ts +41 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Enable shouldUnregister for Dynamic Form Memory Efficiency
|
|
3
|
+
impact: HIGH
|
|
4
|
+
impactDescription: reduces memory usage for forms with frequently mounted/unmounted fields
|
|
5
|
+
tags: formcfg, should-unregister, dynamic-forms, memory
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Enable shouldUnregister for Dynamic Form Memory Efficiency
|
|
9
|
+
|
|
10
|
+
By default, unmounted fields retain their values and validation state. For forms with frequently added/removed fields, enable `shouldUnregister` to automatically clean up unmounted fields.
|
|
11
|
+
|
|
12
|
+
**Incorrect (unmounted fields persist in memory):**
|
|
13
|
+
|
|
14
|
+
```typescript
|
|
15
|
+
const { register, handleSubmit } = useForm({
|
|
16
|
+
shouldUnregister: false, // Default: unmounted fields stay in form state
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
function MultiStepForm() {
|
|
20
|
+
const [step, setStep] = useState(1)
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<form onSubmit={handleSubmit(onSubmit)}>
|
|
24
|
+
{step === 1 && (
|
|
25
|
+
<input {...register('personalInfo.name')} />
|
|
26
|
+
)}
|
|
27
|
+
{step === 2 && (
|
|
28
|
+
<input {...register('companyInfo.company')} /> {/* Step 1 fields still in memory */}
|
|
29
|
+
)}
|
|
30
|
+
</form>
|
|
31
|
+
)
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
**Correct (unmounted fields cleaned up automatically):**
|
|
36
|
+
|
|
37
|
+
```typescript
|
|
38
|
+
const { register, handleSubmit } = useForm({
|
|
39
|
+
shouldUnregister: true, // Unmounted fields removed from form state
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
function MultiStepForm() {
|
|
43
|
+
const [step, setStep] = useState(1)
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<form onSubmit={handleSubmit(onSubmit)}>
|
|
47
|
+
{step === 1 && (
|
|
48
|
+
<input {...register('personalInfo.name')} />
|
|
49
|
+
)}
|
|
50
|
+
{step === 2 && (
|
|
51
|
+
<input {...register('companyInfo.company')} /> {/* Step 1 fields cleaned up */}
|
|
52
|
+
)}
|
|
53
|
+
</form>
|
|
54
|
+
)
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
**When NOT to use:**
|
|
59
|
+
- Multi-step wizards where you need to preserve values across steps
|
|
60
|
+
- Conditional fields that should retain values when hidden
|
|
61
|
+
|
|
62
|
+
Reference: [useForm - shouldUnregister](https://react-hook-form.com/docs/useform)
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Avoid useForm Return Object in useEffect Dependencies
|
|
3
|
+
impact: CRITICAL
|
|
4
|
+
impactDescription: prevents infinite render loops
|
|
5
|
+
tags: formcfg, useEffect, dependencies, infinite-loop
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Avoid useForm Return Object in useEffect Dependencies
|
|
9
|
+
|
|
10
|
+
Adding the entire useForm return object to a useEffect dependency array causes infinite loops. Destructure only the specific methods you need.
|
|
11
|
+
|
|
12
|
+
**Incorrect (entire form object causes infinite loop):**
|
|
13
|
+
|
|
14
|
+
```typescript
|
|
15
|
+
function ContactForm({ defaultEmail }: { defaultEmail: string }) {
|
|
16
|
+
const form = useForm({
|
|
17
|
+
defaultValues: { email: '' },
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
form.reset({ email: defaultEmail })
|
|
22
|
+
}, [form, defaultEmail]) // form reference changes on every render = infinite loop
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<form onSubmit={form.handleSubmit(onSubmit)}>
|
|
26
|
+
<input {...form.register('email')} />
|
|
27
|
+
</form>
|
|
28
|
+
)
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
**Correct (destructure specific stable methods):**
|
|
33
|
+
|
|
34
|
+
```typescript
|
|
35
|
+
function ContactForm({ defaultEmail }: { defaultEmail: string }) {
|
|
36
|
+
const { register, handleSubmit, reset } = useForm({
|
|
37
|
+
defaultValues: { email: '' },
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
useEffect(() => {
|
|
41
|
+
reset({ email: defaultEmail })
|
|
42
|
+
}, [reset, defaultEmail]) // reset is stable, no infinite loop
|
|
43
|
+
|
|
44
|
+
return (
|
|
45
|
+
<form onSubmit={handleSubmit(onSubmit)}>
|
|
46
|
+
<input {...register('email')} />
|
|
47
|
+
</form>
|
|
48
|
+
)
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
**Note:** In a future major release, useForm return will be memoized. Until then, always destructure.
|
|
53
|
+
|
|
54
|
+
Reference: [useForm](https://react-hook-form.com/docs/useform)
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Use onSubmit Mode for Optimal Performance
|
|
3
|
+
impact: CRITICAL
|
|
4
|
+
impactDescription: prevents re-renders on every keystroke
|
|
5
|
+
tags: formcfg, validation-mode, re-renders, useForm
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Use onSubmit Mode for Optimal Performance
|
|
9
|
+
|
|
10
|
+
The `mode` option in useForm determines when validation runs. Using `onChange` mode triggers validation on every keystroke, causing significant re-renders. Default to `onSubmit` unless real-time feedback is essential.
|
|
11
|
+
|
|
12
|
+
**Incorrect (validates on every keystroke):**
|
|
13
|
+
|
|
14
|
+
```typescript
|
|
15
|
+
const { register, handleSubmit, formState: { errors } } = useForm({
|
|
16
|
+
mode: 'onChange', // Triggers validation + re-render on EVERY input change
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
function RegistrationForm() {
|
|
20
|
+
return (
|
|
21
|
+
<form onSubmit={handleSubmit(onSubmit)}>
|
|
22
|
+
<input {...register('email', { required: true, pattern: /^\S+@\S+$/i })} />
|
|
23
|
+
{errors.email && <span>{errors.email.message}</span>}
|
|
24
|
+
</form>
|
|
25
|
+
)
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
**Correct (validates only on submit):**
|
|
30
|
+
|
|
31
|
+
```typescript
|
|
32
|
+
const { register, handleSubmit, formState: { errors } } = useForm({
|
|
33
|
+
mode: 'onSubmit', // Default: validates only when form is submitted
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
function RegistrationForm() {
|
|
37
|
+
return (
|
|
38
|
+
<form onSubmit={handleSubmit(onSubmit)}>
|
|
39
|
+
<input {...register('email', { required: true, pattern: /^\S+@\S+$/i })} />
|
|
40
|
+
{errors.email && <span>{errors.email.message}</span>}
|
|
41
|
+
</form>
|
|
42
|
+
)
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
**When to use other modes:**
|
|
47
|
+
- `onBlur`: Validate when user leaves a field (good balance of UX and performance)
|
|
48
|
+
- `onTouched`: Like `onBlur` but only after first interaction
|
|
49
|
+
- `onChange`: Only when real-time validation feedback is critical (use sparingly)
|
|
50
|
+
|
|
51
|
+
Reference: [useForm - mode](https://react-hook-form.com/docs/useform)
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Avoid isValid with onSubmit Mode for Button State
|
|
3
|
+
impact: MEDIUM
|
|
4
|
+
impactDescription: prevents validation on every render for button disabled state
|
|
5
|
+
tags: formstate, isValid, onSubmit, validation-mode
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Avoid isValid with onSubmit Mode for Button State
|
|
9
|
+
|
|
10
|
+
When using `mode: 'onSubmit'`, accessing `isValid` forces validation on every render to determine the current validity state. This defeats the purpose of deferred validation.
|
|
11
|
+
|
|
12
|
+
**Incorrect (isValid triggers validation despite onSubmit mode):**
|
|
13
|
+
|
|
14
|
+
```typescript
|
|
15
|
+
function RegistrationForm() {
|
|
16
|
+
const { register, handleSubmit, formState: { isValid } } = useForm({
|
|
17
|
+
mode: 'onSubmit', // Expects validation only on submit
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<form onSubmit={handleSubmit(onSubmit)}>
|
|
22
|
+
<input {...register('email', { required: true })} />
|
|
23
|
+
<input {...register('password', { required: true })} />
|
|
24
|
+
<button disabled={!isValid}>Register</button> {/* Forces validation on every render */}
|
|
25
|
+
</form>
|
|
26
|
+
)
|
|
27
|
+
}
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
**Correct (use isSubmitting or allow submit attempt):**
|
|
31
|
+
|
|
32
|
+
```typescript
|
|
33
|
+
function RegistrationForm() {
|
|
34
|
+
const { register, handleSubmit, formState: { isSubmitting } } = useForm({
|
|
35
|
+
mode: 'onSubmit',
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<form onSubmit={handleSubmit(onSubmit)}>
|
|
40
|
+
<input {...register('email', { required: true })} />
|
|
41
|
+
<input {...register('password', { required: true })} />
|
|
42
|
+
<button disabled={isSubmitting}>
|
|
43
|
+
{isSubmitting ? 'Registering...' : 'Register'}
|
|
44
|
+
</button>
|
|
45
|
+
</form>
|
|
46
|
+
)
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
**Alternative (use onChange mode if real-time validation needed):**
|
|
51
|
+
|
|
52
|
+
```typescript
|
|
53
|
+
const { formState: { isValid } } = useForm({
|
|
54
|
+
mode: 'onChange', // Explicit: validation runs on every change
|
|
55
|
+
})
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Reference: [useForm - mode](https://react-hook-form.com/docs/useform)
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Destructure formState Properties Before Render
|
|
3
|
+
impact: MEDIUM
|
|
4
|
+
impactDescription: enables Proxy subscription optimization
|
|
5
|
+
tags: formstate, formState, destructure, proxy, subscription
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Destructure formState Properties Before Render
|
|
9
|
+
|
|
10
|
+
formState is wrapped in a Proxy that tracks which properties you access. Destructure the specific properties you need before render to enable the subscription optimization. Assigning the entire object disables it.
|
|
11
|
+
|
|
12
|
+
**Incorrect (entire object assignment disables Proxy):**
|
|
13
|
+
|
|
14
|
+
```typescript
|
|
15
|
+
function SubmitButton() {
|
|
16
|
+
const { handleSubmit, formState } = useForm()
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<button
|
|
20
|
+
disabled={!formState.isValid} // Proxy optimization disabled
|
|
21
|
+
onClick={handleSubmit(onSubmit)}
|
|
22
|
+
>
|
|
23
|
+
{formState.isSubmitting ? 'Saving...' : 'Save'}
|
|
24
|
+
</button>
|
|
25
|
+
)
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
**Correct (destructure enables selective subscription):**
|
|
30
|
+
|
|
31
|
+
```typescript
|
|
32
|
+
function SubmitButton() {
|
|
33
|
+
const { handleSubmit, formState: { isValid, isSubmitting } } = useForm()
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<button
|
|
37
|
+
disabled={!isValid} // Only subscribes to isValid changes
|
|
38
|
+
onClick={handleSubmit(onSubmit)}
|
|
39
|
+
>
|
|
40
|
+
{isSubmitting ? 'Saving...' : 'Save'}
|
|
41
|
+
</button>
|
|
42
|
+
)
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
**Note:** This also applies to useFormState hook - always destructure the properties you need.
|
|
47
|
+
|
|
48
|
+
Reference: [useFormState](https://react-hook-form.com/docs/useformstate)
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Use getFieldState for Single Field State Access
|
|
3
|
+
impact: MEDIUM
|
|
4
|
+
impactDescription: avoids subscription overhead for one-time state reads
|
|
5
|
+
tags: formstate, getFieldState, single-field, no-subscription
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Use getFieldState for Single Field State Access
|
|
9
|
+
|
|
10
|
+
When you need to check a single field's state (dirty, touched, error) without subscribing to updates, use `getFieldState()`. It returns current state without creating a subscription.
|
|
11
|
+
|
|
12
|
+
**Incorrect (useFormState creates subscription for one-time check):**
|
|
13
|
+
|
|
14
|
+
```typescript
|
|
15
|
+
function FieldHelpText({ control, name }: { control: Control; name: string }) {
|
|
16
|
+
const { touchedFields } = useFormState({ control }) // Subscribes to all touched changes
|
|
17
|
+
|
|
18
|
+
const wasTouched = touchedFields[name]
|
|
19
|
+
|
|
20
|
+
return wasTouched ? null : <span>Please fill out this field</span>
|
|
21
|
+
}
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
**Correct (getFieldState for non-reactive read):**
|
|
25
|
+
|
|
26
|
+
```typescript
|
|
27
|
+
function FieldHelpText({ formState, name }: { formState: FormState; name: string }) {
|
|
28
|
+
const { isTouched } = getFieldState(name, formState) // No subscription created
|
|
29
|
+
|
|
30
|
+
return isTouched ? null : <span>Please fill out this field</span>
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function MyForm() {
|
|
34
|
+
const { register, formState } = useForm()
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<form>
|
|
38
|
+
<input {...register('email')} />
|
|
39
|
+
<FieldHelpText formState={formState} name="email" />
|
|
40
|
+
</form>
|
|
41
|
+
)
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
**When to use each:**
|
|
46
|
+
- `useFormState`: Need to react to state changes (display updates)
|
|
47
|
+
- `getFieldState`: Need current state at a point in time (conditional logic)
|
|
48
|
+
|
|
49
|
+
Reference: [useForm - getFieldState](https://react-hook-form.com/docs/useform/getfieldstate)
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Subscribe to Specific Field Names in useFormState
|
|
3
|
+
impact: MEDIUM
|
|
4
|
+
impactDescription: reduces re-renders to only relevant field changes
|
|
5
|
+
tags: formstate, useFormState, name, specific-fields
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Subscribe to Specific Field Names in useFormState
|
|
9
|
+
|
|
10
|
+
useFormState accepts a `name` option to subscribe only to specific field state changes. Without it, the component re-renders on any field's state change.
|
|
11
|
+
|
|
12
|
+
**Incorrect (subscribes to all field state changes):**
|
|
13
|
+
|
|
14
|
+
```typescript
|
|
15
|
+
function PasswordStrengthIndicator({ control }: { control: Control }) {
|
|
16
|
+
const { errors, dirtyFields } = useFormState({ control }) // All fields
|
|
17
|
+
|
|
18
|
+
const passwordError = errors.password
|
|
19
|
+
const isPasswordDirty = dirtyFields.password
|
|
20
|
+
|
|
21
|
+
return isPasswordDirty && !passwordError ? (
|
|
22
|
+
<span>Password looks good!</span>
|
|
23
|
+
) : null
|
|
24
|
+
}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
**Correct (subscribes only to password field):**
|
|
28
|
+
|
|
29
|
+
```typescript
|
|
30
|
+
function PasswordStrengthIndicator({ control }: { control: Control }) {
|
|
31
|
+
const { errors, dirtyFields } = useFormState({
|
|
32
|
+
control,
|
|
33
|
+
name: 'password', // Only re-renders on password state changes
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
const passwordError = errors.password
|
|
37
|
+
const isPasswordDirty = dirtyFields.password
|
|
38
|
+
|
|
39
|
+
return isPasswordDirty && !passwordError ? (
|
|
40
|
+
<span>Password looks good!</span>
|
|
41
|
+
) : null
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
**Multiple fields:**
|
|
46
|
+
|
|
47
|
+
```typescript
|
|
48
|
+
const { errors } = useFormState({
|
|
49
|
+
control,
|
|
50
|
+
name: ['email', 'password'], // Subscribe to multiple specific fields
|
|
51
|
+
})
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Reference: [useFormState](https://react-hook-form.com/docs/useformstate)
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Use useFormState for Isolated State Subscriptions
|
|
3
|
+
impact: MEDIUM
|
|
4
|
+
impactDescription: prevents parent re-renders from state access in children
|
|
5
|
+
tags: formstate, useFormState, isolation, re-renders
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Use useFormState for Isolated State Subscriptions
|
|
9
|
+
|
|
10
|
+
useFormState allows subscribing to form state in child components without causing parent re-renders. Each useFormState instance is isolated and doesn't affect other subscribers.
|
|
11
|
+
|
|
12
|
+
**Incorrect (formState at root re-renders entire form):**
|
|
13
|
+
|
|
14
|
+
```typescript
|
|
15
|
+
function ContactForm() {
|
|
16
|
+
const { register, handleSubmit, formState: { errors, isDirty } } = useForm()
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<form onSubmit={handleSubmit(onSubmit)}>
|
|
20
|
+
<input {...register('email', { required: true })} />
|
|
21
|
+
{errors.email && <span>Email required</span>} {/* Re-renders all on any state change */}
|
|
22
|
+
<input {...register('message')} />
|
|
23
|
+
<SaveIndicator isDirty={isDirty} /> {/* Prop drilling */}
|
|
24
|
+
</form>
|
|
25
|
+
)
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
**Correct (useFormState isolates subscriptions):**
|
|
30
|
+
|
|
31
|
+
```typescript
|
|
32
|
+
function ContactForm() {
|
|
33
|
+
const { register, handleSubmit, control } = useForm()
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<form onSubmit={handleSubmit(onSubmit)}>
|
|
37
|
+
<EmailField register={register} control={control} />
|
|
38
|
+
<input {...register('message')} />
|
|
39
|
+
<SaveIndicator control={control} /> {/* Isolated subscription */}
|
|
40
|
+
</form>
|
|
41
|
+
)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function EmailField({ register, control }: EmailFieldProps) {
|
|
45
|
+
const { errors } = useFormState({ control, name: 'email' })
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<div>
|
|
49
|
+
<input {...register('email', { required: true })} />
|
|
50
|
+
{errors.email && <span>Email required</span>}
|
|
51
|
+
</div>
|
|
52
|
+
)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function SaveIndicator({ control }: { control: Control }) {
|
|
56
|
+
const { isDirty } = useFormState({ control })
|
|
57
|
+
|
|
58
|
+
return isDirty ? <span>Unsaved changes</span> : null
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Reference: [useFormState](https://react-hook-form.com/docs/useformstate)
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Use Controller for Material-UI Components
|
|
3
|
+
impact: MEDIUM
|
|
4
|
+
impactDescription: maintains controlled component behavior with proper event handling
|
|
5
|
+
tags: integ, mui, material-ui, Controller
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Use Controller for Material-UI Components
|
|
9
|
+
|
|
10
|
+
Material-UI components are controlled by design. Use Controller to wrap them, handling the onChange event object correctly (MUI passes the event, not the value directly).
|
|
11
|
+
|
|
12
|
+
**Incorrect (register doesn't work with MUI controlled components):**
|
|
13
|
+
|
|
14
|
+
```typescript
|
|
15
|
+
import { TextField } from '@mui/material'
|
|
16
|
+
|
|
17
|
+
function MuiForm() {
|
|
18
|
+
const { register, handleSubmit } = useForm()
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<form onSubmit={handleSubmit(onSubmit)}>
|
|
22
|
+
<TextField
|
|
23
|
+
{...register('email')} // MUI TextField is controlled, register won't work
|
|
24
|
+
label="Email"
|
|
25
|
+
/>
|
|
26
|
+
</form>
|
|
27
|
+
)
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
**Correct (Controller handles MUI's event-based onChange):**
|
|
32
|
+
|
|
33
|
+
```typescript
|
|
34
|
+
import { TextField } from '@mui/material'
|
|
35
|
+
import { Controller } from 'react-hook-form'
|
|
36
|
+
|
|
37
|
+
function MuiForm() {
|
|
38
|
+
const { control, handleSubmit } = useForm()
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<form onSubmit={handleSubmit(onSubmit)}>
|
|
42
|
+
<Controller
|
|
43
|
+
name="email"
|
|
44
|
+
control={control}
|
|
45
|
+
render={({ field, fieldState }) => (
|
|
46
|
+
<TextField
|
|
47
|
+
{...field} // MUI TextField accepts onChange with event
|
|
48
|
+
label="Email"
|
|
49
|
+
error={!!fieldState.error}
|
|
50
|
+
helperText={fieldState.error?.message}
|
|
51
|
+
/>
|
|
52
|
+
)}
|
|
53
|
+
/>
|
|
54
|
+
</form>
|
|
55
|
+
)
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Reference: [React Hook Form - UI Libraries](https://react-hook-form.com/get-started#IntegratingwithUIlibraries)
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Verify shadcn Form Component Import Source
|
|
3
|
+
impact: MEDIUM
|
|
4
|
+
impactDescription: prevents silent component mismatch bugs
|
|
5
|
+
tags: integ, shadcn, imports, Form-component
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Verify shadcn Form Component Import Source
|
|
9
|
+
|
|
10
|
+
React Hook Form exports its own `<Form>` component. When using shadcn/ui, ensure you import the shadcn Form wrapper, not RHF's Form. Auto-imports often get this wrong.
|
|
11
|
+
|
|
12
|
+
**Incorrect (imports RHF Form instead of shadcn):**
|
|
13
|
+
|
|
14
|
+
```typescript
|
|
15
|
+
import { useForm, Form } from 'react-hook-form' // Wrong Form!
|
|
16
|
+
import { FormField, FormItem, FormLabel } from '@/components/ui/form'
|
|
17
|
+
|
|
18
|
+
function LoginForm() {
|
|
19
|
+
const form = useForm()
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<Form {...form}> {/* RHF Form doesn't work with shadcn FormField */}
|
|
23
|
+
<FormField
|
|
24
|
+
control={form.control}
|
|
25
|
+
name="email"
|
|
26
|
+
render={({ field }) => (
|
|
27
|
+
<FormItem>
|
|
28
|
+
<FormLabel>Email</FormLabel>
|
|
29
|
+
<Input {...field} />
|
|
30
|
+
</FormItem>
|
|
31
|
+
)}
|
|
32
|
+
/>
|
|
33
|
+
</Form>
|
|
34
|
+
)
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
**Correct (separate imports for each library):**
|
|
39
|
+
|
|
40
|
+
```typescript
|
|
41
|
+
import { useForm } from 'react-hook-form'
|
|
42
|
+
import { Form, FormField, FormItem, FormLabel } from '@/components/ui/form'
|
|
43
|
+
|
|
44
|
+
function LoginForm() {
|
|
45
|
+
const form = useForm()
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<Form {...form}> {/* shadcn Form wraps FormProvider correctly */}
|
|
49
|
+
<FormField
|
|
50
|
+
control={form.control}
|
|
51
|
+
name="email"
|
|
52
|
+
render={({ field }) => (
|
|
53
|
+
<FormItem>
|
|
54
|
+
<FormLabel>Email</FormLabel>
|
|
55
|
+
<Input {...field} />
|
|
56
|
+
</FormItem>
|
|
57
|
+
)}
|
|
58
|
+
/>
|
|
59
|
+
</Form>
|
|
60
|
+
)
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Reference: [shadcn Form](https://ui.shadcn.com/docs/components/form)
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Wire shadcn Select with onValueChange Instead of Spread
|
|
3
|
+
impact: MEDIUM
|
|
4
|
+
impactDescription: prevents 100% of silent select binding failures with Radix-based components
|
|
5
|
+
tags: integ, shadcn, select, radix
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Wire shadcn Select with onValueChange Instead of Spread
|
|
9
|
+
|
|
10
|
+
shadcn's Select (built on Radix) uses `onValueChange` instead of `onChange`. Spreading field props directly doesn't work. Manually wire the value change handler.
|
|
11
|
+
|
|
12
|
+
**Incorrect (spread doesn't work with Radix Select):**
|
|
13
|
+
|
|
14
|
+
```typescript
|
|
15
|
+
function CountrySelect({ control }: { control: Control }) {
|
|
16
|
+
return (
|
|
17
|
+
<FormField
|
|
18
|
+
control={control}
|
|
19
|
+
name="country"
|
|
20
|
+
render={({ field }) => (
|
|
21
|
+
<Select {...field}> {/* field.onChange expects event, Radix passes value */}
|
|
22
|
+
<SelectTrigger>
|
|
23
|
+
<SelectValue placeholder="Select country" />
|
|
24
|
+
</SelectTrigger>
|
|
25
|
+
<SelectContent>
|
|
26
|
+
<SelectItem value="us">United States</SelectItem>
|
|
27
|
+
<SelectItem value="uk">United Kingdom</SelectItem>
|
|
28
|
+
</SelectContent>
|
|
29
|
+
</Select>
|
|
30
|
+
)}
|
|
31
|
+
/>
|
|
32
|
+
)
|
|
33
|
+
}
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
**Correct (wire props individually):**
|
|
37
|
+
|
|
38
|
+
```typescript
|
|
39
|
+
function CountrySelect({ control }: { control: Control }) {
|
|
40
|
+
return (
|
|
41
|
+
<FormField
|
|
42
|
+
control={control}
|
|
43
|
+
name="country"
|
|
44
|
+
render={({ field }) => (
|
|
45
|
+
<Select
|
|
46
|
+
value={field.value}
|
|
47
|
+
onValueChange={field.onChange} // Radix passes value directly
|
|
48
|
+
onOpenChange={() => field.onBlur()} // Trigger blur on close
|
|
49
|
+
>
|
|
50
|
+
<SelectTrigger>
|
|
51
|
+
<SelectValue placeholder="Select country" />
|
|
52
|
+
</SelectTrigger>
|
|
53
|
+
<SelectContent>
|
|
54
|
+
<SelectItem value="us">United States</SelectItem>
|
|
55
|
+
<SelectItem value="uk">United Kingdom</SelectItem>
|
|
56
|
+
</SelectContent>
|
|
57
|
+
</Select>
|
|
58
|
+
)}
|
|
59
|
+
/>
|
|
60
|
+
)
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Reference: [shadcn Select](https://ui.shadcn.com/docs/components/select)
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Transform Values at Controller Level for Type Coercion
|
|
3
|
+
impact: MEDIUM
|
|
4
|
+
impactDescription: prevents type coercion bugs in 100% of numeric/date form fields
|
|
5
|
+
tags: integ, transform, value-coercion, Controller
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Transform Values at Controller Level for Type Coercion
|
|
9
|
+
|
|
10
|
+
Native inputs return strings. When your form needs numbers, dates, or other types, transform values in the Controller render function rather than relying solely on `valueAsNumber` or `valueAsDate`.
|
|
11
|
+
|
|
12
|
+
**Incorrect (valueAsNumber has edge cases):**
|
|
13
|
+
|
|
14
|
+
```typescript
|
|
15
|
+
function QuantityInput() {
|
|
16
|
+
const { register } = useForm()
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<input
|
|
20
|
+
{...register('quantity', { valueAsNumber: true })} // Returns NaN for empty string
|
|
21
|
+
type="number"
|
|
22
|
+
/>
|
|
23
|
+
)
|
|
24
|
+
}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
**Correct (explicit transformation in Controller):**
|
|
28
|
+
|
|
29
|
+
```typescript
|
|
30
|
+
function QuantityInput({ control }: { control: Control }) {
|
|
31
|
+
return (
|
|
32
|
+
<Controller
|
|
33
|
+
name="quantity"
|
|
34
|
+
control={control}
|
|
35
|
+
render={({ field }) => (
|
|
36
|
+
<input
|
|
37
|
+
type="number"
|
|
38
|
+
value={field.value ?? ''}
|
|
39
|
+
onChange={(e) => {
|
|
40
|
+
const value = e.target.value
|
|
41
|
+
field.onChange(value === '' ? null : parseInt(value, 10))
|
|
42
|
+
}}
|
|
43
|
+
onBlur={field.onBlur}
|
|
44
|
+
/>
|
|
45
|
+
)}
|
|
46
|
+
/>
|
|
47
|
+
)
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
**Alternative (Zod transform at schema level):**
|
|
52
|
+
|
|
53
|
+
```typescript
|
|
54
|
+
const schema = z.object({
|
|
55
|
+
quantity: z.string().transform((val) => (val === '' ? null : parseInt(val, 10))),
|
|
56
|
+
})
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Reference: [React Hook Form - Advanced Usage](https://react-hook-form.com/advanced-usage)
|