feat(record-form): hand slot RecordFields their wiring as bind (PUI-125) #137

Open
pienter wants to merge 9 commits from feature/PUI-125-recordform-hands-slot-fields-their-wiring into main
Owner

RecordFields placed in RecordForm's slots now get their wiring from RecordForm, so pages stop repeating it and useRecordForm clears issues for fields in those slots too.

Every CMS and CRM form puts its fields in #fields/#aside, and each RecordFields repeated v-model, :issues, :busy and @field-change (14 places). Those field changes never reached RecordForm, so useRecordForm's bind.onFieldChange never ran for them.

Review guide

  • Library:
    • RecordForm.vue: #fields and #aside receive a bind slot prop, used as <template #fields="{ bind }"><RecordFields v-bind="bind" :fields="group" /></template>. A field change goes out through RecordForm's field-change, once per edit. Its slots are declared with defineSlots, and forwarding of before-field/field:* is split into a static template plus a typed loop, since defineSlots requires it.
    • record-form/types.ts: new exported RecordFieldsBinding<T>.
  • Examples:
    • Settings, Blog and Page forms spread the slot bind; only PageForm's block fields override busy/readonly.
    • On those pages the composable's bind is renamed formBind, because vue/no-template-shadow rejects two binds.
    • The CRM forms move their clearIssue to one @field-change on RecordForm, with the same clearing.
  • Tests:
    • New tests/record-form.test.ts: slot edits, busy/readonly precedence, useRecordForm clearing, default-slot forwarding.
    • tests/dom.ts is the shared DOM harness, moved out of repeater.test.ts.
    • The list-row slot test stays in repeater.test.ts and checks a row edit isn't forwarded twice.
  • Docs: AUDIT (including why provide/inject was rejected), README, docs/cms/forms-and-validation.md, CHANGELOG, and the RecordForm and PageAside stories.

Proof

  • The new tests fail against the old RecordForm.vue. Test files run separately: record-form 3, repeater 28, record-form-composable 19, reveal-field 32, read-only 21, access-forms 32 and the other form files all pass.
  • bun run typecheck, lint and format pass.
  • examples/vue type-check: only the known SettingsForm.vue error that #136 fixes.
  • Not checked in a browser or Storybook.

Choices made: composable bind renamed formBind on pages (not the slot prop); field-change forwarded with all arguments, ready for PUI-126; the default slot gets no bind; bind leaves out baseline/errors/submit (RecordFields doesn't take them).

Closes PUI-125

RecordFields placed in RecordForm's slots now get their wiring from RecordForm, so pages stop repeating it and `useRecordForm` clears issues for fields in those slots too. Every CMS and CRM form puts its fields in `#fields`/`#aside`, and each RecordFields repeated `v-model`, `:issues`, `:busy` and `@field-change` (14 places). Those field changes never reached RecordForm, so `useRecordForm`'s `bind.onFieldChange` never ran for them. **Review guide** - **Library:** - `RecordForm.vue`: `#fields` and `#aside` receive a `bind` slot prop, used as `<template #fields="{ bind }"><RecordFields v-bind="bind" :fields="group" /></template>`. A field change goes out through RecordForm's `field-change`, once per edit. Its slots are declared with `defineSlots`, and forwarding of `before-field`/`field:*` is split into a static template plus a typed loop, since `defineSlots` requires it. - `record-form/types.ts`: new exported `RecordFieldsBinding<T>`. - **Examples:** - Settings, Blog and Page forms spread the slot `bind`; only PageForm's block fields override busy/readonly. - On those pages the composable's `bind` is renamed `formBind`, because `vue/no-template-shadow` rejects two `bind`s. - The CRM forms move their `clearIssue` to one `@field-change` on RecordForm, with the same clearing. - **Tests:** - New `tests/record-form.test.ts`: slot edits, busy/readonly precedence, `useRecordForm` clearing, default-slot forwarding. - `tests/dom.ts` is the shared DOM harness, moved out of repeater.test.ts. - The list-row slot test stays in repeater.test.ts and checks a row edit isn't forwarded twice. - **Docs:** AUDIT (including why provide/inject was rejected), README, `docs/cms/forms-and-validation.md`, CHANGELOG, and the RecordForm and PageAside stories. **Proof** - The new tests fail against the old RecordForm.vue. Test files run separately: record-form 3, repeater 28, record-form-composable 19, reveal-field 32, read-only 21, access-forms 32 and the other form files all pass. - `bun run typecheck`, lint and format pass. - `examples/vue` type-check: only the known `SettingsForm.vue` error that #136 fixes. - Not checked in a browser or Storybook. **Choices made:** composable `bind` renamed `formBind` on pages (not the slot prop); `field-change` forwarded with all arguments, ready for PUI-126; the `default` slot gets no `bind`; `bind` leaves out baseline/errors/submit (RecordFields doesn't take them). Closes PUI-125
RecordFields in RecordForm's `#fields` and `#aside` slots repeated the
model, issues, busy and field-change wiring on every page, and their
field changes never reached RecordForm, so `useRecordForm`'s clearing
missed them. Both slots now receive a `bind` slot prop to spread on
RecordFields; its field changes go out through RecordForm's
`field-change`. RecordForm declares its slots, and `RecordFieldsBinding`
is exported.

Refs PUI-125
Refs PUI-125
Refs PUI-125
Moves the RecordForm slot tests out of repeater.test.ts and shares the
DOM harness in tests/dom.ts.

Refs PUI-125
docs: wire PageAside story slots through bind; explain formBind once
All checks were successful
ci / lint (pull_request) Successful in 27s
ci / typecheck (pull_request) Successful in 25s
ci / format (pull_request) Successful in 31s
ci / rust (pull_request) Successful in 4m49s
ci / release (pull_request) Has been skipped
4397e4b3c6
Refs PUI-125
Merge remote-tracking branch 'origin/main' into feature/PUI-125-recordform-hands-slot-fields-their-wiring
All checks were successful
ci / typecheck (pull_request) Successful in 24s
ci / lint (pull_request) Successful in 27s
ci / format (pull_request) Successful in 30s
ci / rust (pull_request) Successful in 3m34s
ci / release (pull_request) Has been skipped
bfffcefed5
# Conflicts:
#	examples/vue/src/views/crm/ContactForm.vue
#	packages/ui/CHANGELOG.md
#	packages/ui/README.md
Author
Owner

Ready to merge, after #136. CI green; base current with main (6802ee5, merged in at bfffcef). Conflicts resolved: ContactForm now keeps PanelGroup (#135) and spreads the slot bind; README; CHANGELOG (the entry moved to a fresh ## Unreleased, since 0.44.0 had been released). Review panel: changes and quality seats, nothing material; nits fixed in d152796 and 4397e4b (default-slot forwarding test, RecordForm tests in their own file, PageAside story, docs). Remaining nits: field:* slot scope is hand-copied in RecordForm's defineSlots (RecordFields declares no slots); bind is rebuilt on every recompute. Not checked in a browser.

Ready to merge, after #136. CI green; base current with main (6802ee5, merged in at bfffcef). Conflicts resolved: ContactForm now keeps PanelGroup (#135) and spreads the slot `bind`; README; CHANGELOG (the entry moved to a fresh `## Unreleased`, since 0.44.0 had been released). Review panel: changes and quality seats, nothing material; nits fixed in d152796 and 4397e4b (default-slot forwarding test, RecordForm tests in their own file, PageAside story, docs). Remaining nits: `field:*` slot scope is hand-copied in RecordForm's `defineSlots` (RecordFields declares no slots); `bind` is rebuilt on every recompute. Not checked in a browser.
Merge remote-tracking branch 'origin/main' into feature/PUI-125-recordform-hands-slot-fields-their-wiring
Some checks failed
ci / typecheck (pull_request) Successful in 27s
ci / lint (pull_request) Successful in 32s
ci / format (pull_request) Has been cancelled
ci / rust (pull_request) Has been cancelled
ci / release (pull_request) Has been cancelled
580b730075
# Conflicts:
#	packages/ui/CHANGELOG.md
bun update
Some checks failed
ci / typecheck (pull_request) Successful in 24s
ci / lint (pull_request) Successful in 28s
ci / format (pull_request) Successful in 35s
ci / rust (pull_request) Has been cancelled
ci / release (pull_request) Has been cancelled
ab66f96c22
Merge remote-tracking branch 'origin/main' into feature/PUI-125-recordform-hands-slot-fields-their-wiring
All checks were successful
ci / typecheck (pull_request) Successful in 27s
ci / lint (pull_request) Successful in 29s
ci / format (pull_request) Successful in 27s
ci / rust (pull_request) Successful in 1m52s
ci / release (pull_request) Has been skipped
38634970fd
# Conflicts:
#	packages/ui/CHANGELOG.md
All checks were successful
ci / typecheck (pull_request) Successful in 27s
Required
Details
ci / lint (pull_request) Successful in 29s
Required
Details
ci / format (pull_request) Successful in 27s
Required
Details
ci / rust (pull_request) Successful in 1m52s
Required
Details
ci / release (pull_request) Has been skipped
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'feature/PUI-125-recordform-hands-slot-fields-their-wiring:feature/PUI-125-recordform-hands-slot-fields-their-wiring'
git switch 'feature/PUI-125-recordform-hands-slot-fields-their-wiring'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
pienter/ui!137
No description provided.