Skip to content

refactor(form-fields): extract shared CVA primitives to _shared/form-field-cva.ts #268

@Gabo-Dev

Description

@Gabo-Dev

Context

The Autocomplete spec (closes #12, §3) mandates reusing CVA variants directly from \select/types.ts. The implementation follows the spec correctly, but this design decision creates structural coupling between two independent components.

Problem

\�utocomplete/types.ts\ imports and re-exports 14 CVA definitions directly from \select/types.ts. As a result:

  • A bug in any shared CVA affects both components simultaneously.
  • Visual findings scoped to Autocomplete cannot be fixed within its own 6 files.
  • Future divergence between Select and Autocomplete requires breaking the import chain.

This was identified during the visual review of Autocomplete, which surfaced 4 MAJOR findings that require changes to \select/types.ts\ — outside the component's own scope:

  1. \selectTrigger\ uses \ease-[ease], an invalid CSS easing function.
  2. \selectIndicator\ uses \duration-300, exceeding the 250ms max for interactive elements.
  3. \selectClearButton\ applies an input-level focus ring opacity (0.15) instead of button-level (0.35/0.40).
  4. \�ordered\ variant hover has only one visual signal (background) — border-color is not elevated.

Proposed solution

Extract shared CVA to a neutral module that neither component owns:

\
src/components/atoms/
_shared/
form-field-cva.ts ← shared CVA (selectTrigger, selectItem, selectPopover, etc.)
select/
types.ts ← imports from _shared + Select-specific CVA
autocomplete/
types.ts ← imports from _shared + Autocomplete-specific CVA
\\

This removes the dependency between the two components while keeping a single source of truth for the shared visual primitives.

Acceptance criteria

  • _shared/form-field-cva.ts\ created with all currently shared CVA
  • \select/types.ts\ updated to import from _shared\
  • \�utocomplete/types.ts\ updated to import from _shared\
  • The 4 MAJOR findings listed above are fixed in _shared/form-field-cva.ts\
  • No visual regression in Select or Autocomplete stories

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    Todo

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions