Repository navigation
Document and type the form widget contract - #97
Conversation
* seven: Update README with the Plone Aurora Seven querystringWidget (#8017) [Seven] Add `renderEmptyState` to `Table` component (#8308) Recurrence widget (#7200)
Co-authored-by: Steve Piercy <web@stevepiercy.com>
|
@sneridagh https://www.dlr.de/de keeps timing out in the README linkcheck. |
stevepiercy
left a comment
There was a problem hiding this comment.
I still don't have a firm grasp of the differences between field, control, and widget. Adapter kind of makes sense to me as the glue between a control and a widget. Is there a diagram or external documentation that we can reuse? I need a picture or more code examples.
In my tiny dinosaur brain:
- A control is the HTML form control and its attributes, per https://developer.mozilla.org/en-US/docs/Learn_web_development/Extensions/Forms/Basic_native_form_controls.
- A field, I think in this context, is similar to a column in a relational database.
- A widget would be something such as a date range picker, a sequence of dependent selects, or allows callbacks from the client.
We should also add all these terms into a glossary.
| ## Design implications | ||
|
|
||
| The form generator should be basic. | ||
| It should resolve widgets, pass normalized field props, and connect changes back to form state. |
There was a problem hiding this comment.
| It should resolve widgets, pass normalized field props, and connect changes back to form state. | |
| It should resolve widgets, pass normalized field props, and connect changes back to the form state. |
| It should not contain special cases for checkbox selection state, date serialization, upload workflows, relation values, or vocabulary fetching. | ||
|
|
||
| Widgets should own those differences. |
There was a problem hiding this comment.
I think this sentence belongs better with the previous paragraph, forming a complete concept of what it means to keep the form generator basic.
Then the next paragraph explains why that's advantageous, and where the complicated pieces belong.
| It should not contain special cases for checkbox selection state, date serialization, upload workflows, relation values, or vocabulary fetching. | |
| Widgets should own those differences. | |
| It should not contain special cases for checkbox selection state, date serialization, upload workflows, relation values, or vocabulary fetching. | |
| Widgets should own those differences. | |
|
|
||
| (form-fields-controls-and-widgets-label)= | ||
|
|
||
| # Form fields, controls, and widgets |
There was a problem hiding this comment.
| # Form fields, controls, and widgets | |
| # Form fields, controls, widgets, and adapters |
| html_meta: | ||
| "description": "An explanation of fields, controls, widgets, and widget adapters in Seven forms" | ||
| "property=og:description": "An explanation of fields, controls, widgets, and widget adapters in Seven forms" | ||
| "property=og:title": "Form fields, controls, and widgets" |
There was a problem hiding this comment.
| "property=og:title": "Form fields, controls, and widgets" | |
| "property=og:title": "Form fields, controls, widgets, and adapters" |
| "description": "An explanation of fields, controls, widgets, and widget adapters in Seven forms" | ||
| "property=og:description": "An explanation of fields, controls, widgets, and widget adapters in Seven forms" | ||
| "property=og:title": "Form fields, controls, and widgets" | ||
| "keywords": "Seven, forms, fields, controls, widgets, @tanstack/form, @plone/cmsui" |
There was a problem hiding this comment.
| "keywords": "Seven, forms, fields, controls, widgets, @tanstack/form, @plone/cmsui" | |
| "keywords": "Aurora, forms, fields, controls, widgets, adapters, @tanstack/form, @plone/cmsui" |
| "description": "An explanation of fields, controls, widgets, and widget adapters in Seven forms" | ||
| "property=og:description": "An explanation of fields, controls, widgets, and widget adapters in Seven forms" |
There was a problem hiding this comment.
| "description": "An explanation of fields, controls, widgets, and widget adapters in Seven forms" | |
| "property=og:description": "An explanation of fields, controls, widgets, and widget adapters in Seven forms" | |
| "description": "An explanation of fields, controls, widgets, and widget adapters in Aurora forms" | |
| "property=og:description": "An explanation of fields, controls, widgets, and widget adapters in Aurora forms" |
|
|
||
| # Form fields, controls, and widgets | ||
|
|
||
| Seven forms are schema-driven. |
There was a problem hiding this comment.
| Seven forms are schema-driven. | |
| Aurora forms are schema-driven. |
| The form state system asks, "What is the value and validation state of this field?" | ||
| The widget registry asks, "Which widget should render this field?" | ||
|
|
||
| Seven can resolve a widget from several schema hints. |
There was a problem hiding this comment.
| Seven can resolve a widget from several schema hints. | |
| Aurora can resolve a widget from several schema hints. |
|
|
||
| ## Control | ||
|
|
||
| A control is a lower-level interactive component. |
There was a problem hiding this comment.
Lower-level than what? Field? Widget?
| import { BooleanWidget } from './BooleanWidget'; | ||
|
|
||
| const meta = { | ||
| title: 'CMS UI/Widgets/BooleanWidget', |
There was a problem hiding this comment.
| title: 'CMS UI/Widgets/BooleanWidget', | |
| title: 'CMSUI/Widgets/BooleanWidget', |
Wire the control panel action to PATCH @ControlPanels, port the BooleanWidget adapter from #97 so boolean fields show their label and value, and replace the react-aria toolbar buttons in the control panel routes, whose onPress never fires inside the toolbar's shadow root.
* origin/main: (190 commits) Make control panels saveable (#220) Public UI: render a single .content-area root (#230) (#234) Remove tsconfig test/spec/story excludes that never matched any file (#222) Add PloneClient.extend() and clientEndpoints utility for custom endpoints (#221) Store the default block width of every top-level block (#190) Releasing @plone/aurora 1.0.0-alpha.19 Release @plone/cmsui 1.0.0-alpha.12 Release @plone/agave 1.0.0-alpha.9 Release @plone/theming 1.0.0-alpha.9 Release @plone/layout 1.0.0-alpha.14 Release @plone/blocks 1.0.0-alpha.18 Release @plone/plate 1.0.0-alpha.25 Release @plone/registry 4.0.0-alpha.5 Release @plone/quanta 1.0.0-alpha.2 Content CSS Phase 11: theming guide for blocks and cleanup (#219) Rename the Plone blocks' classnames to the content contract (#218) Share the block spacing between the Public UI and the editor (#217) Content CSS Phase 8: structural blocks and content root to styles/content.css (#216) Remove the Plate media nodes from Aurora's presets (#215) Move the table styles to styles/content.css (#214) ... # Conflicts: # packages/cmsui/components/BooleanWidget/BooleanWidget.stories.tsx # packages/cmsui/components/BooleanWidget/BooleanWidget.test.tsx # packages/cmsui/components/BooleanWidget/BooleanWidget.tsx # packages/cmsui/news/+boolean-widget-adapter.bugfix
Address the review: add a diagram that follows one field from its schema to its control and back, a comparison with HTML form controls and database columns, worked adapter examples for a boolean and a date widget, and a glossary. Apply the suggested wording and title changes. Add the missing cmsui and docs news fragments.
|
@stevepiercy thanks for the review. I reworked the guide in 4ed03e8:
The rest of the contract work is tracked in #243. |
* origin/main: Fix the recurrence modal crash for events ending on days 1 to 9 (#255)
* origin/main: Validate schema-driven forms (#256) Move the recurrence modal off TanStack Form (#254) Move the forms onto the helpers form store (#253) Add a Jotai-native form layer to helpers (#252) Render every schema form through one field renderer (#251) Document and type the form widget contract (#97) Match utility dependencies exactly in the registry (#259) # Conflicts: # packages/cmsui/config/widgets.ts
…widget-context * origin/feat/widget-adapters: Restore files the pre-commit hook reformatted Validate schema-driven forms (#256) Move the recurrence modal off TanStack Form (#254) Move the forms onto the helpers form store (#253) Add a Jotai-native form layer to helpers (#252) Render every schema form through one field renderer (#251) Document and type the form widget contract (#97) Match utility dependencies exactly in the registry (#259)
…yped-widget-registry * origin/feat/widget-context: Restore files the pre-commit hook reformatted Validate schema-driven forms (#256) Move the recurrence modal off TanStack Form (#254) Move the forms onto the helpers form store (#253) Add a Jotai-native form layer to helpers (#252) Render every schema form through one field renderer (#251) Document and type the form widget contract (#97) Match utility dependencies exactly in the registry (#259)
… feat/missing-widgets * origin/feat/typed-widget-registry: Restore files the pre-commit hook reformatted Validate schema-driven forms (#256) Move the recurrence modal off TanStack Form (#254) Move the forms onto the helpers form store (#253) Add a Jotai-native form layer to helpers (#252) Render every schema form through one field renderer (#251) Document and type the form widget contract (#97) Match utility dependencies exactly in the registry (#259)
Step 1 of #243 (define and enforce the form widget contract).
FormWidgetProps<T>/FormWidget<T>types to@plone/types.valuecomes in asT | null(it can be empty) andonChangeemits a normalizedT.BooleanWidgetnow uses the shared type.Field.tsxwiresonBlurto TanStack Form (touched state and blur validation), convertserrortoerrors/errorMessage, and stops overwriting alabelpassed by the caller.The
BooleanWidgetadapter itself landed on main with #220. This PR now carries the contract types and docs. The remaining inconsistencies are tracked in #243, which has the plan for follow-up PRs.Originally transferred from plone/volto#8309, and supersedes plone/volto#8237 and plone/volto#8247.