useForm function

Module @runic-artifex/react in @runic-artifex/react 0.23.0

function useForm(fields: FormFields<FormFieldHandle>, options?: UseFormOptions): FormHandle;

One dirty, pending and valid state over the useField handles of a component, and a submit that writes every field before its command (createFormController in @runic-artifex/views):

const title = useField(editor, EditorFields.title, { commit: "pause" });
const body = useField(editor, EditorFields.body, { commit: "pause" });
const form = useForm({ title, body }, { dirty: editor.state?.isDirty });
<button disabled={!form.valid || form.submitting} onClick={() => form.submit(() => editor.client!.save())}>Save</button>