Skip to content

feat(components): accessible Field primitive + server-error mapping (#75) - #112

Merged
joelpeace48-cell merged 1 commit into
FinesseStudioLab:mainfrom
leojay-net:feat/form-primitives-75
Aug 30, 2026
Merged

joelpeace48-cell merged 1 commit into
FinesseStudioLab:mainfrom
leojay-net:feat/form-primitives-75

Conversation

@leojay-net

Copy link
Copy Markdown
Contributor

Description

First slice of the shared form primitives (issue #75). No new deps.

  • components/forms/field.tsx — accessible Field wrapper: labelled via htmlFor, with a fieldAria(id, {hasHint, hasError}) helper that returns the exact aria-describedby (hint + error ids) and aria-invalid a control should spread onto itself, so every form associates them identically. Error renders with role="alert".
  • lib/forms/server-errors.ts — mapServerErrors(body, knownFields) maps a backend error body (zod-style errors: [{path, message}] list or a flat fieldErrors map) onto known fields; unmatched messages go to a single formLevel fallback rather than being dropped or rendered as orphans.
  • tests/unit/forms.test.tsx — a11y association assertions + server-error mapping cases (7 tests).

Follow-up (same issue)

Input / Select / Textarea / FileUpload primitives, the full lifecycle state (pristine → submitting → error/success, double-submit lock), input preservation on failure, and client validation sharing the backend zod schemas (blocked on the shared schema package).

Testing

npm test (7 new tests pass), next lint clean locally.

Closes #75

…inesseStudioLab#75)

First slice of the shared form primitives:
- components/forms/field.tsx: labelled Field wrapper with fieldAria() helper
  that wires aria-describedby (hint + error) and aria-invalid onto the
  control, so every form associates them identically.
- lib/forms/server-errors.ts: mapServerErrors() maps backend validation
  errors (zod errors[] list or flat fieldErrors map) onto known fields,
  routing unmatched messages to a single form-level fallback rather than
  dropping them.

Input, Select, Textarea, FileUpload and the shared-zod-schema validation
build on these (the schema sharing depends on the shared schema package).

Refs FinesseStudioLab#75
@joelpeace48-cell
joelpeace48-cell merged commit d57c51f into FinesseStudioLab:main Aug 30, 2026
4 checks passed
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.

components: form primitives with shared validation schemas

2 participants