ToDo & Changelog
ToDo List#
- Release
4.0.0: bumpversioninpackage.json(still3.0.0) before tagging, the publish workflow requires the tag to match it
Changelog#
Dynamic-forms follows the semver standard.
4.0.0 (unreleased)#
- Breaking:
form.notify()rejects when a select's remote call fails, instead of logging the error and resolving.form.ready()rejects too when an initialisation remote call fails (#27). Changes triggered by the user still log the error to the console form.ready()rejects when initialisation fails (e.g.beforeInitthrows), instead of never settling (#28)- Breaking: every Field Hook receives the
NodeListof the elements with the field name, even when there is only one. Hooks on single elements readhtmlElement[0].valueinstead ofhtmlElement.value. Before, checkbox and radioio.get,io.setandbehavior.clearand selectbehavior.updateStatus,postProcessDataandsaveDataalways received theNodeList, while the other hooks received the element itself when only one had the field name - Breaking (TypeScript): public types reworked so configurations need no casts. The package now exports
FormConfiguration,FormHooks,UpdateRule,InitialisationRule,FieldConfiguration,FieldIoHooks,FieldFetchConfiguration,FieldHooks,SelectConfiguration,CheckboxConfiguration,UpdateDataand theDynamicFormtypeFormConfigurationrequires onlyid, andbehavioraccepts any subset of the Form HooksFieldConfigurationhas theselectandcheckboxkeys; the formerSelectConfiguration/CheckboxConfigurationinterfaces extending it are gone, and the names now belong to the formerSelectSelectConfiguration/CheckboxCheckboxConfiguration- Renamed
FormBehaviortoFormHooks,FieldBehaviorConfigurationtoFieldHooks,FieldIoConfigurationtoFieldIoHooks - The
datareceived by Field Hooks,makeUrl,makeBodyandexternalDataisUpdateData(Record<string, any>) instead ofobject, sodata.countryneeds no annotation - Form Hooks and
externalDatareceive astringSubject name, nevernull - Field Hooks receive
NodeListOf<FieldElement>(FieldElementisHTMLInputElement | HTMLSelectElement | HTMLTextAreaElement) instead ofHTMLElement | NodeList, sohtmlElement[0].valueneeds no narrowing or cast.FieldConfiguration<E, V>states the element and value types of a field (FieldConfiguration<HTMLSelectElement>,FieldConfiguration<HTMLInputElement, string[]>); the value staysanyby default select.postProcessDatareceives the response asanyand returnsSelectOption[]({ value: string | number, text: string }), whichselect.saveDatareceivesInitialisationRule.valueisunknowninstead ofany- The
behavior.afterUpdateField Hook returnsvoidinstead ofboolean: its result was never used - Exports
FieldElementandSelectOptiontoo
- Breaking:
fetch.fullFetchConfigis a function of the Update Data,(data) => RequestInit, instead of a static object, as the documentation already described (#31). Wrap an existing object asfullFetchConfig: () => ({ ... }) makeForm()no longer modifies the given configuration: defaults and discovered fields go into an internal copy. Form Hooks set toundefinedfall back to the default instead of throwing- Breaking:
makeForm()throws when the Update Rules form a cycle, including a field listing itself in its ownupdate, which used to be ignored (#38). A cycle used to clear the field the user had just changed - Breaking: a custom
behavior.beforeUpdateon a select no longer switches offselect.clearOnParentVoid: with an empty Subject's value the select is cleared and its update stops before the hook is called (#40). SetclearOnParentVoid: falseto handle an empty Subject's value in the hook - Breaking:
makeForm()throws when the configuration mentions a name which is not a field of the form: in an Update Rule (itsname,updateoradditionalData) or in an Initialisation Rule. These used to fail at the first update withUnknown element, or be silently ignored (#45). The error lists every unknown name, and every missingname; a Field Configuration for a missing field joins the list instead of throwingElement ... not found - Breaking:
makeForm()throws when a Form for that id already exists, instead of leaving the previous one listening to the fields with its old configuration (#47). The newform.destroy()removes the Form's listeners, unregisters it fromgetForm()and aborts its remote calls; a pendingnotify(),manualUpdate()orready()rejects withForm "id" was destroyed, as do later calls. Fields added aftermakeForm()are picked up by destroying the Form and creating it again - The
behavior.updateStatusField Hook receives a 4th parameter, theAbortSignalaborted when the Form is destroyed. Asignalreturned byfetch.fullFetchConfigis combined with it - Breaking: a failed remote call rejects
notify()andready()with aRemoteCallError, anErrorexported by the package with the url and status in its message and theResponseinerror.response, instead of rejecting with theResponseitself (#49). Readerror.response.statusinstead oferror.status - New
select.loadOptionsField Hook: it replaces only the remote call of a select, receiving the parameters ofupdateStatus, and its data goes throughpostProcessDataandsaveDataas usual (#50) - Initialisation no longer clears the initial value of a field reached by the Cascade Clear of another initialised field (#37)
- An update clears the Observers' Observers before updating the Observers, so the result no longer depends on the order of the names in
update form.notify()andform.ready()reject when clearing the Observers' Observers fails (e.g. abehavior.clearField Hook throws), instead of leaving an unhandled rejection- Clearing a checkbox unchecks it instead of checking it (#25)
- A select filled by a remote call gets an empty option when neither the html nor the data have one (#26). An option with value
0is not taken for the empty one
3.0.0#
- Webpack has been replaced with Vite
- Library import does not expose the
dynamicFormsmodule anymore butmakeformandgetFormfunctions directly
2.0.0#
- Library has been rewritten in typescript
FieldConfiguration.dropdownrenamed toFieldConfiguration.select- Better documentation
1.3.0#
- Added automatic field discovery: you don't need to specify fields with standard behavior anymore
1.2.0#
- Supported fields initialisation
- Added
form.ready()method to synchronise post-initialisation operations
1.0.1#
1.0.0#
- First release