formWithLocalStorage = (keyName, inputMap, defaults = {}, options = {}) => {
fromState(keyName, inputMap, defaults);
const { mode = 'oninput', ...formOptions } = options;
const form = Inputs.form(inputMap, formOptions);
form[mode] = function () {
const result = {};
for (const [key, elt] of Object.entries(inputMap)) {
result[key] = elt.value;
}
localStorage.setItem(keyName, JSON.stringify(result));
};
return form;
}