Skip to content

refactor(admin-frontend): fields.types.ts só com blocos genéricos - #216

Closed
evertonschuster wants to merge 1 commit into
mainfrom
refactor/fields-types-generic
Closed

evertonschuster wants to merge 1 commit into
mainfrom
refactor/fields-types-generic

Conversation

@evertonschuster

@evertonschuster evertonschuster commented Nov 11, 2026 •

Copy link
Copy Markdown
Owner

O quê

Refatoração sem mudança de comportamento em apps/admin-frontend/src/shared/form/fields/.

fields.types.ts misturava blocos genéricos com props de cada campo, por isso importava componentes concretos de shared/ui (Input, Textarea, InputGroupInput, ColorSwatchPickerOption). Agora ele guarda só os blocos genéricos e importa de @/shared/ui apenas form-field (FormFieldControlProps, usado por ControlledFieldProps).

Onde ficou cada tipo

Tipo Arquivo
BaseFieldProps, RegisterOwnedProps, FormFieldOwnedProps, WithOptionalLabel, FieldLabelPlacement, ControlledFieldProps, FieldErrorProps fields.types.ts (exportados para os componentes)
TextFieldProps, TextareaFieldProps components/text-fields.tsx
MaskedFieldProps components/masked-field.tsx
DateFieldProps components/date-field.tsx
CpfFieldProps components/cpf-field.tsx (base vem de masked-field)
PhoneFieldProps, EmailFieldProps components/phone-field.tsx, components/email-field.tsx (base vem de text-fields)
BirthDateFieldProps components/birth-date-field.tsx (base vem de date-field)
ColorFieldProps components/color-field.tsx
SelectFieldOption, SelectFieldProps components/select-field.tsx
SearchFieldProps components/search-field.tsx

As definições foram movidas sem alteração. O barril index.tsx continua exportando os mesmos 14 nomes de tipo, então nada em features/ muda. Fora de shared/form/fields, nenhum arquivo foi tocado. Dentro, só select-field.test.tsx trocou a origem de SelectFieldOption.

Fora do escopo

O SearchSelectField do #207 (claude/multi-select-component-d9018b) ainda não está na main, então SearchSelectFieldProps e SearchSelectOwnedProps não foram mexidos aqui. Quando um dos dois PRs entrar, o outro precisa levar esses tipos para components/search-select-field.tsx, seguindo a mesma regra.

Validação

Em apps/admin-frontend:

  • npm run format:check: ok
  • npm run lint: 0 erros e as mesmas 6 warnings de react-refresh da main (shared/ui/badge, button, toast e src/test/renderRoutes.tsx). Nenhuma em shared/form/fields.
  • npm run build: ok (tsc + vite build)
  • npm run test:coverage -- --exclude ".claude/**": 100 arquivos e 1092 testes passando, limiares de cobertura atendidos

Não há verificação no navegador porque a mudança é só de tipos e não muda nada na tela.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Refactor
    • Form field configuration types are now provided alongside their corresponding fields, with shared types available through the common form interface. Existing field behavior is unchanged, including optional labels and date bounds.
    • No changes to the admin interface’s appearance or end-user form interactions are included in this update.

As props de cada campo passam a morar no arquivo do componente que as usa
(TextFieldProps em text-fields, ColorFieldProps em color-field etc.); os
derivados importam a base do arquivo do campo base. fields.types.ts fica com
BaseFieldProps, RegisterOwnedProps, FormFieldOwnedProps, WithOptionalLabel,
FieldLabelPlacement, ControlledFieldProps e FieldErrorProps, e de shared/ui
importa só form-field. O barril exporta os mesmos nomes de tipo.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Field-specific prop types now live in their owning component modules instead of fields.types.ts. Shared field prop utilities are exported for reuse, and the field barrel exports each prop type from its component module.

Changes: Field prop type ownership

Layer / File(s) Summary
Export shared field prop utilities
apps/admin-frontend/src/shared/form/fields/fields.types.ts
Shared field prop utilities become exported. Field-specific prop declarations are removed from this file.
Define field prop types in component modules
apps/admin-frontend/src/shared/form/fields/components/*, apps/admin-frontend/src/shared/form/fields/index.tsx
Field-specific prop types are declared in their owning component modules. SelectFieldOption values use the value type at the selected form path. The barrel exports the types from those modules, and the select-field test imports SelectFieldOption from select-field.tsx.

Estimated code review effort: 3 (Moderate) | ~15 minutes

Change: Refactor

Possibly related PRs

  • evertonschuster/Agenza#192: Changes field contracts that this PR relocates, including MaskedFieldProps, CpfFieldProps, and date-field value types.
  • evertonschuster/Agenza#207: Adds SearchSelectFieldProps to fields.types.ts and the field barrel; the summary identifies its later move to the owning component module as out of scope for this PR.
Merge Risk: Minimal · up to 24f53

This refactor only relocates TypeScript types in the admin frontend and does not change runtime behavior. No actionable merge risk was identified.

Pre-merge checks: Passed 5

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly summarizes the main change: refactoring fields.types.ts to retain only generic field types while moving field-specific types to component files.
Docstring Coverage Passed No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 13 files.

Finishing Touches

Generate docstrings

  • Commit to this branch
  • Create a new PR
Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Some tools did not complete. Review the errors below.

ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

apps/admin-frontend/src/shared/form/fields/components/birth-date-field.tsx

typescript-eslint does not support TS 7.0.
Please see https://devblogs.microsoft.com/typescript/announcing-typescript-7-0/#running-side-by-side-with-typescript-6.0 to run typescript-eslint using the TS 6 API.
See also typescript-eslint/typescript-eslint#10940 for tracking typescript-eslint's support for TS >=7.1

Oops! Something went wrong! :(

ESLint: 10.14.0

Error: typescript-eslint does not support TS 7.0.
at Object. (/.eslint-tmp/node_modules/typescript-eslint/dist/index.js:52:11)
at Module._compile (node:internal/modules/cjs/loader:1929:14)
at Object..js (node:internal/modules/cjs/loader:2060:10)
at Module.load (node:internal/modules/cjs/loader:1651:32)
at Module._load (node:internal/modules/cjs/loader:1443:12)
at wrapModuleLoad (node:internal/modules/cjs/loader:261:19)
at loadCJSModuleWithModuleLoad (node:internal/modules/esm/translators:372:15)
at ModuleWrap. (node:internal/modules/esm/translators:244:9)
at ModuleJob.run (node:internal/modules/esm/module_job:561:25)
at async node:internal/modules/esm/loader:647:26

apps/admin-frontend/src/shared/form/fields/components/color-field.tsx

ESLint skipped: the matched ESLint configuration already failed (config-incompatibility).

apps/admin-frontend/src/shared/form/fields/components/cpf-field.tsx

ESLint skipped: the matched ESLint configuration already failed (config-incompatibility).

  • 10 others

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 033066c2-19b5-4dc7-8794-797ad1384c42
Commits

Reviewing files that changed from the base of the PR and between 0210f9b and 24f535b.

Files selected for processing: 13

  • apps/admin-frontend/src/shared/form/fields/components/birth-date-field.tsx
  • apps/admin-frontend/src/shared/form/fields/components/color-field.tsx
  • apps/admin-frontend/src/shared/form/fields/components/cpf-field.tsx
  • apps/admin-frontend/src/shared/form/fields/components/date-field.tsx
  • apps/admin-frontend/src/shared/form/fields/components/email-field.tsx
  • apps/admin-frontend/src/shared/form/fields/components/masked-field.tsx
  • apps/admin-frontend/src/shared/form/fields/components/phone-field.tsx
  • apps/admin-frontend/src/shared/form/fields/components/search-field.tsx
  • apps/admin-frontend/src/shared/form/fields/components/select-field.test.tsx
  • apps/admin-frontend/src/shared/form/fields/components/select-field.tsx
  • apps/admin-frontend/src/shared/form/fields/components/text-fields.tsx
  • apps/admin-frontend/src/shared/form/fields/fields.types.ts
  • apps/admin-frontend/src/shared/form/fields/index.tsx

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant