Skip to content
Open Cloud

Migrate to 0.22 ​

0.22 is the last breaking release before 1.0. The definition format stays 1.5: definitions and submissions do not change.

bash
npm i @formhaus/core@^0.22 @formhaus/react@^0.22
npm i @formhaus/core@^0.22 @formhaus/vue@^0.22

Changes ​

Core ​

Old (0.21)New (0.22)Action
validateDefinitionRemovedUse checkDefinition(input).map((issue) => issue.message)
FormAnalyticsEventRemovedUse FormEvent
SubmitFnAfterSubmitFnRename the type
ValidationRuleRemovedUse MessageKey. getDefaultMessage() takes a MessageKey
parseDefinition(input, options)parseDefinition(input)Drop the second argument
validateFieldValue(field, value, values, validators, messages)validateFieldValue(field, value, values, { validators, messages })Pass an options object
validateFields(nodes, values, validators, messages)validateFields(nodes, values, { validators, messages })Pass an options object
validateStep(step, values, validators, messages)validateStep(step, values, { validators, messages })Pass an options object
form_submit_failed fired only after form_submittedIt also fires with reason: 'validation' when Submit fails client validation. A thrown error adds its numeric statusCount only reason: 'rejected' and 'error' if a report needs the old numbers

Issue codes ​

Old (0.21)New (0.22)Action
invalid-range for min above max or minLength above maxLengthmin-greater-than-maxRename in code that matches issue codes
invalid-range for defaultItems above maxLengthdefault-items-greater-than-maxRename
invalid-range warning for a group over its item limitgroup-item-limitRename
invalid-range for columns outside 1 to 4invalid-columnsRename
empty-label, and missing-property for a label at the path of its objectmissing-label at the path of the label, such as /fields/0/labelRename, and match the new path
i18n-unbound-sloti18n-key-without-textRename

Cloud client ​

Old (0.21)New (0.22)Action
fetchForm(options, signal, after)fetchForm({ ...options, signal, version })Pass an options object
fetchDefinitionRemovedUse (await fetchForm(options)).definition
createSubmitter(options) returned submit(values, skippedSteps, challengeToken)submit(values, { skippedSteps, challengeToken })Pass an options object
createChallengeFrame(challenge, formId, host, timeout, quiet)createChallengeFrame({ challenge, formId, host, timeout, quiet })Pass an options object
sessionDraftStore(maxAge, storage)sessionDraftStore({ maxAge, storage })Pass an options object
new CloudError(status, code, errors, version, cause)new CloudError({ status, code, errors, version, cause })Pass an options object
ts
const form = await fetchForm({ id: 'FORM_ID', signal });
const submit = createSubmitter({ id: 'FORM_ID', version: form.version, renderToken: form.renderToken });
const check = form.challenge && createChallengeFrame({ challenge: form.challenge, formId: 'FORM_ID', host: () => box });
await submit(values, { skippedSteps: [], challengeToken: await check?.token() });

React ​

Old (0.21)New (0.22)Action
onAnalyticsEventRemovedUse onFormEvent
onPrev in FormActionsPropsonBackRename in a custom actions component
ItemComponent in GroupComponentPropsitemComponentRename in a custom group component
useLocalizedForm(definition, source, deps)useLocalizedForm(definition, source, { key }). A new translate function does not rebuild the form. The definition, lang, prefix, the overlay or key doReplace deps with { key }, such as { key: t } with react-i18next
tsx
function Group({ items, itemComponent: Item }: GroupComponentProps) {
  return items.map((item) => <Item key={item.id} {...item} />);
}

const form = useLocalizedForm(
  definition,
  { translate: (key, params, defaultValue) => t(key, { ...params, defaultValue }), lang: i18n.language },
  { key: t },
);

Vue ​

Old (0.21)New (0.22)Action
submitHandlerRemovedUse @submit
@analytics-eventRemovedUse @form-event
FormFieldPropsFieldComponentPropsRename the type
formFieldProps, formFieldEmitsfieldComponentProps, fieldComponentEmitsRename the imports
prev emit of a custom actions componentbackEmit back
vue
<script setup lang="ts">
import { fieldComponentEmits, fieldComponentProps } from '@formhaus/vue';
const props = defineProps(fieldComponentProps);
const emit = defineEmits(fieldComponentEmits);
</script>

React and Vue ​

Old (0.21)New (0.22)Action
errorSummary was off by defaultThe error summary shows by defaultPass errorSummary={false} or :error-summary="false" to hide it
draftStore was off by default in FormhausFormFormhausForm keeps a draft in sessionStorage without password, file and hidden valuesPass draftStore={false} to turn drafts off, or draftExclude with the keys of sensitive fields. See Drafts
After a failed Continue or Submit, focus moved to the first invalid fieldWith two or more errors, focus moves to the error summary. With one error, or with errorSummary off, focus moves to the invalid fieldUpdate tests that expect the first field to have focus

Vue FormhausForm ​

Old (0.21)New (0.22)Action
FormhausForm removed a group item with answers without askingIt asks first, like FormRendererPass :confirm-remove="false" to remove without asking

Styles ​

The private custom properties of style.css start with --fhi-. Only the variables listed in Optional baseline styles are public.

Old (0.21)New (0.22)Action
--fh-auto-*, such as --fh-auto-input-padding--fhi-auto-*Set the public variable instead, such as --fh-input-padding
--fh-x, --fh-check, --fh-plus, --fh-zoom, --fh-star, --fh-star-fill, --fh-mask--fhi-x, --fhi-check, --fhi-plus, --fhi-zoom, --fhi-star, --fhi-star-fill, --fhi-maskRename in CSS that reads the icons
--fh-columns, --fh-matrix-columns, --fh-matrix-label, --fh-matrix-row, --fh-scale-points--fhi-columns, --fhi-matrix-columns, --fhi-matrix-label, --fhi-matrix-row, --fhi-scale-pointsRename in custom components that set them

Native ports ​

The conformance files in packages/core/fixtures/conformance use the new issue codes. scenarios/lifecycle.json, scenarios/recall-identifiers.json and scenarios/skip-steps.json expect form_submit_failed with reason: 'validation' before field_error. scenarios/go-to-step.json covers the new goToStep().