Skip to content

U06: Form primitives: Field, Input, Textarea, Select, Switch, Checkbox - #804

Merged
LinuxDevil merged 1 commit into
mainfrom
fb-u06-form-primitives
Oct 30, 2026
Merged

LinuxDevil merged 1 commit into
mainfrom
fb-u06-form-primitives

Conversation

@LinuxDevil

Copy link
Copy Markdown
Owner

What changed

New form primitives in apps/agent-forge/src/ui/:

  • Field.tsx — Field wrapper (label / hint / error / required / inline) that publishes FieldIds through FieldContext; useFieldIds() exposes them to controls. div.field[.field-inline][.field-invalid] with label.field-label, p.hint and p.hint.field-error.
  • controls.tsx — Input, Textarea (prose, autoGrow), Select (data-driven options, disabled placeholder first option), Switch (button[role=switch], stateLabel On/Off overline, size="sm" 26×14 track) and Checkbox (styled box with tick/indeterminate drawn in CSS, whole row a <label>). All but Switch are forwardRef and spread native props. Inside a Field, controls default id to the Field id, join hintId/errorId into aria-describedby, take aria-invalid from the Field error and aria-required from required; explicit props win.
  • form.css — .field-label, .field-inline, .input-sm/.select-sm (28px), [aria-invalid] danger border + ring, .textarea-prose/.textarea-autogrow, .switch-wrap/.switch-sm/.switch:disabled, .checkbox* styles. Tokens only, reduced-motion honoured.
  • __tests__/controls.test.tsx — 9 tests covering the Field a11y wiring, explicit-prop overrides, placeholder/options/sm select, prose/autoGrow textarea, switch toggle/disabled/stateLabel/sm, indeterminate + label-click checkbox and the inline-Field switch naming.

base.css and existing screens (Inspector, SettingsPanel) are untouched per the ticket's scope.

The four *Props interfaces carry fallow-ignore-next-line unused-type suppressions: they are the public contract adopted by the form screens in the follow-up tickets.

How it was tested

  • npm test --workspace apps/agent-forge -- --run — 79 files / 858 tests passed (9 new)
  • npm run typecheck --workspace apps/agent-forge — clean
  • npm run typecheck:server --workspace apps/agent-forge — clean
  • npm run test:server --workspace apps/agent-forge — 24 files / 337 tests passed
  • npm run lint --workspace apps/agent-forge — 0 errors (30 pre-existing warnings elsewhere)
  • root npx tsc --noEmit — clean
  • root npm run lint — clean
  • root npm run test:coverage — 438 files / 6718 tests passed (first run needed npm run build -w create-lousho-agent in the fresh worktree; green after)
  • npm run fallow — pass (0 dead-code issues; the pre-existing .ev-switch/.pg-switch CSS clone from earlier PRs is reported but non-gating)

Acceptance criteria

  • A control inside <Field label hint error required> is labelled, described by hint+error, aria-invalid, aria-required.
  • Switch is a button[role=switch] with aria-checked, toggles on click/Enter/Space, and does nothing when disabled.
  • Checkbox supports checked, indeterminate and disabled; the tick is drawn with tokens only.
  • controlSize="sm" gives 28px controls; default stays 32px.
  • No raw colours in form.css.

Generated with Devin

…witch, Checkbox

React wrappers around the existing .field/.input/.select/.textarea/.switch
classes so screens stop hand-wiring ids, aria-describedby, aria-invalid and
switch semantics; plus a styled Checkbox and a 28px (sm) control size.

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@LinuxDevil
LinuxDevil merged commit c5c11aa into main Oct 30, 2026
2 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.

1 participant