@defra/forms-model 3.0.313 → 3.0.315

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/dist/module/components/component-types.js +6 -0
  2. package/dist/module/components/component-types.js.map +1 -1
  3. package/dist/module/components/helpers.js +17 -6
  4. package/dist/module/components/helpers.js.map +1 -1
  5. package/dist/module/components/index.js +1 -1
  6. package/dist/module/components/index.js.map +1 -1
  7. package/dist/module/form/form-definition/types.js.map +1 -1
  8. package/dist/module/pages/helpers.js +12 -5
  9. package/dist/module/pages/helpers.js.map +1 -1
  10. package/dist/module/pages/index.js +1 -1
  11. package/dist/module/pages/index.js.map +1 -1
  12. package/dist/module/pages/page-types.js +2 -9
  13. package/dist/module/pages/page-types.js.map +1 -1
  14. package/dist/types/components/component-types.d.ts.map +1 -1
  15. package/dist/types/components/helpers.d.ts +10 -3
  16. package/dist/types/components/helpers.d.ts.map +1 -1
  17. package/dist/types/components/index.d.ts +1 -1
  18. package/dist/types/components/index.d.ts.map +1 -1
  19. package/dist/types/form/form-definition/types.d.ts +11 -4
  20. package/dist/types/form/form-definition/types.d.ts.map +1 -1
  21. package/dist/types/pages/helpers.d.ts +11 -5
  22. package/dist/types/pages/helpers.d.ts.map +1 -1
  23. package/dist/types/pages/index.d.ts +1 -1
  24. package/dist/types/pages/index.d.ts.map +1 -1
  25. package/dist/types/pages/page-types.d.ts.map +1 -1
  26. package/package.json +1 -1
  27. package/src/components/component-types.ts +7 -0
  28. package/src/components/helpers.ts +24 -7
  29. package/src/components/index.ts +1 -0
  30. package/src/form/form-definition/types.ts +17 -4
  31. package/src/pages/helpers.ts +26 -7
  32. package/src/pages/index.ts +1 -0
  33. package/src/pages/page-types.ts +2 -10
@@ -87,6 +87,12 @@ export const ComponentTypes = Object.freeze([{
87
87
  type: ComponentType.EmailAddressField,
88
88
  hint: 'For example, ‘name@example.com’',
89
89
  options: {}
90
+ }, {
91
+ name: 'FileUploadField',
92
+ title: 'File upload field',
93
+ type: ComponentType.FileUploadField,
94
+ options: {},
95
+ schema: {}
90
96
  }, {
91
97
  name: 'Html',
92
98
  title: 'Html',
@@ -1 +1 @@
1
- {"version":3,"file":"component-types.js","names":["ComponentType","ComponentTypes","Object","freeze","name","title","type","TextField","hint","options","schema","MultilineTextField","YesNoField","DatePartsField","MonthYearField","SelectField","list","AutocompleteField","RadiosField","CheckboxesField","NumberField","UkAddressField","TelephoneNumberField","EmailAddressField","Html","content","InsetText","Details","List"],"sources":["../../../src/components/component-types.ts"],"sourcesContent":["import { ComponentType } from '~/src/components/enums.js'\nimport { type ComponentDef } from '~/src/components/types.js'\n\n/**\n * Defaults for creating new components\n */\nexport const ComponentTypes: readonly ComponentDef[] = Object.freeze([\n {\n name: 'TextField',\n title: 'Text field',\n type: ComponentType.TextField,\n hint: '',\n options: {},\n schema: {}\n },\n {\n name: 'MultilineTextField',\n title: 'Multiline text field',\n type: ComponentType.MultilineTextField,\n hint: '',\n options: {},\n schema: {}\n },\n {\n name: 'YesNoField',\n title: 'Yes/No field',\n type: ComponentType.YesNoField,\n hint: '',\n options: {}\n },\n {\n name: 'DatePartsField',\n title: 'Date field',\n type: ComponentType.DatePartsField,\n hint: '',\n options: {}\n },\n {\n name: 'MonthYearField',\n title: 'Month & year field',\n type: ComponentType.MonthYearField,\n hint: '',\n options: {}\n },\n {\n name: 'SelectField',\n title: 'Select field',\n type: ComponentType.SelectField,\n hint: '',\n list: '',\n options: {}\n },\n {\n name: 'AutocompleteField',\n title: 'Autocomplete field',\n type: ComponentType.AutocompleteField,\n hint: '',\n list: '',\n options: {}\n },\n {\n name: 'RadiosField',\n title: 'Radios field',\n type: ComponentType.RadiosField,\n hint: '',\n list: '',\n options: {}\n },\n {\n name: 'CheckboxesField',\n title: 'Checkboxes field',\n type: ComponentType.CheckboxesField,\n hint: '',\n list: '',\n options: {}\n },\n {\n name: 'NumberField',\n title: 'Number field',\n type: ComponentType.NumberField,\n hint: '',\n options: {},\n schema: {}\n },\n {\n name: 'UkAddressField',\n title: 'UK address field',\n type: ComponentType.UkAddressField,\n hint: '',\n options: {}\n },\n {\n name: 'TelephoneNumberField',\n title: 'Telephone number field',\n type: ComponentType.TelephoneNumberField,\n hint: '',\n options: {}\n },\n {\n name: 'EmailAddressField',\n title: 'Email address field',\n type: ComponentType.EmailAddressField,\n hint: 'For example, ‘name@example.com’',\n options: {}\n },\n {\n name: 'Html',\n title: 'Html',\n type: ComponentType.Html,\n content: '',\n options: {}\n },\n {\n name: 'InsetText',\n title: 'Inset text',\n type: ComponentType.InsetText,\n content: ''\n },\n {\n name: 'Details',\n title: 'Details',\n type: ComponentType.Details,\n content: '',\n options: {}\n },\n {\n name: 'List',\n title: 'List',\n type: ComponentType.List,\n list: '',\n options: {}\n }\n])\n"],"mappings":"AAAA,SAASA,aAAa;AAGtB;AACA;AACA;AACA,OAAO,MAAMC,cAAuC,GAAGC,MAAM,CAACC,MAAM,CAAC,CACnE;EACEC,IAAI,EAAE,WAAW;EACjBC,KAAK,EAAE,YAAY;EACnBC,IAAI,EAAEN,aAAa,CAACO,SAAS;EAC7BC,IAAI,EAAE,EAAE;EACRC,OAAO,EAAE,CAAC,CAAC;EACXC,MAAM,EAAE,CAAC;AACX,CAAC,EACD;EACEN,IAAI,EAAE,oBAAoB;EAC1BC,KAAK,EAAE,sBAAsB;EAC7BC,IAAI,EAAEN,aAAa,CAACW,kBAAkB;EACtCH,IAAI,EAAE,EAAE;EACRC,OAAO,EAAE,CAAC,CAAC;EACXC,MAAM,EAAE,CAAC;AACX,CAAC,EACD;EACEN,IAAI,EAAE,YAAY;EAClBC,KAAK,EAAE,cAAc;EACrBC,IAAI,EAAEN,aAAa,CAACY,UAAU;EAC9BJ,IAAI,EAAE,EAAE;EACRC,OAAO,EAAE,CAAC;AACZ,CAAC,EACD;EACEL,IAAI,EAAE,gBAAgB;EACtBC,KAAK,EAAE,YAAY;EACnBC,IAAI,EAAEN,aAAa,CAACa,cAAc;EAClCL,IA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;EAClCb,IAAI,EAAE,EAAE;EACRC,OAAO,EAAE,CAAC;AACZ,CAAC,EACD;EACEL,IAAI,EAAE,sBAAsB;EAC5BC,KAAK,EAAE,wBAAwB;EAC/BC,IAAI,EAAEN,aAAa,CAACsB,oBAAoB;EACxCd,IAAI,EAAE,EAAE;EACRC,OAAO,EAAE,CAAC;AACZ,CAAC,EACD;EACEL,IAAI,EAAE,mBAAmB;EACzBC,KAAK,EAAE,qBAAqB;EAC5BC,IAAI,EAAEN,aAAa,CAACuB,iBAAiB;EACrCf,IAAI,EAAE,iCAAiC;EACvCC,OAAO,EAAE,CAAC;AACZ,CAAC,EACD;EACEL,IAAI,EAAE,MAAM;EACZC,KAAK,EAAE,MAAM;EACbC,IAAI,EAAEN,aAAa,CAACwB,IAAI;EACxBC,OAAO,EAAE,EAAE;EACXhB,OAAO,EAAE,CAAC;AACZ,CAAC,EACD;EACEL,IAAI,EAAE,WAAW;EACjBC,KAAK,EAAE,YAAY;EACnBC,IAAI,EAAEN,aAAa,CAAC0B,SAAS;EAC7BD,OAAO,EAAE;AACX,CAAC,EACD;EACErB,IAAI,EAAE,SAAS;EACfC,KAAK,EAAE,SAAS;EAChBC,IAAI,EAAEN,aAAa,CAAC2B,OAAO;EAC3BF,OAAO,EAAE,EAAE;EACXhB,OAAO,EAAE,CAAC;AACZ,CAAC,EACD;EACEL,IAAI,EAAE,MAAM;EACZC,KAAK,EAAE,MAAM;EACbC,IAAI,EAAEN,aAAa,CAAC4B,IAAI;EACxBZ,IAAI,EAAE,EAAE;EACRP,OAAO,EAAE,CAAC;AACZ,CAAC,CACF,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"component-types.js","names":["ComponentType","ComponentTypes","Object","freeze","name","title","type","TextField","hint","options","schema","MultilineTextField","YesNoField","DatePartsField","MonthYearField","SelectField","list","AutocompleteField","RadiosField","CheckboxesField","NumberField","UkAddressField","TelephoneNumberField","EmailAddressField","FileUploadField","Html","content","InsetText","Details","List"],"sources":["../../../src/components/component-types.ts"],"sourcesContent":["import { ComponentType } from '~/src/components/enums.js'\nimport { type ComponentDef } from '~/src/components/types.js'\n\n/**\n * Defaults for creating new components\n */\nexport const ComponentTypes: readonly ComponentDef[] = Object.freeze([\n {\n name: 'TextField',\n title: 'Text field',\n type: ComponentType.TextField,\n hint: '',\n options: {},\n schema: {}\n },\n {\n name: 'MultilineTextField',\n title: 'Multiline text field',\n type: ComponentType.MultilineTextField,\n hint: '',\n options: {},\n schema: {}\n },\n {\n name: 'YesNoField',\n title: 'Yes/No field',\n type: ComponentType.YesNoField,\n hint: '',\n options: {}\n },\n {\n name: 'DatePartsField',\n title: 'Date field',\n type: ComponentType.DatePartsField,\n hint: '',\n options: {}\n },\n {\n name: 'MonthYearField',\n title: 'Month & year field',\n type: ComponentType.MonthYearField,\n hint: '',\n options: {}\n },\n {\n name: 'SelectField',\n title: 'Select field',\n type: ComponentType.SelectField,\n hint: '',\n list: '',\n options: {}\n },\n {\n name: 'AutocompleteField',\n title: 'Autocomplete field',\n type: ComponentType.AutocompleteField,\n hint: '',\n list: '',\n options: {}\n },\n {\n name: 'RadiosField',\n title: 'Radios field',\n type: ComponentType.RadiosField,\n hint: '',\n list: '',\n options: {}\n },\n {\n name: 'CheckboxesField',\n title: 'Checkboxes field',\n type: ComponentType.CheckboxesField,\n hint: '',\n list: '',\n options: {}\n },\n {\n name: 'NumberField',\n title: 'Number field',\n type: ComponentType.NumberField,\n hint: '',\n options: {},\n schema: {}\n },\n {\n name: 'UkAddressField',\n title: 'UK address field',\n type: ComponentType.UkAddressField,\n hint: '',\n options: {}\n },\n {\n name: 'TelephoneNumberField',\n title: 'Telephone number field',\n type: ComponentType.TelephoneNumberField,\n hint: '',\n options: {}\n },\n {\n name: 'EmailAddressField',\n title: 'Email address field',\n type: ComponentType.EmailAddressField,\n hint: 'For example, ‘name@example.com’',\n options: {}\n },\n {\n name: 'FileUploadField',\n title: 'File upload field',\n type: ComponentType.FileUploadField,\n options: {},\n schema: {}\n },\n {\n name: 'Html',\n title: 'Html',\n type: ComponentType.Html,\n content: '',\n options: {}\n },\n {\n name: 'InsetText',\n title: 'Inset text',\n type: ComponentType.InsetText,\n content: ''\n },\n {\n name: 'Details',\n title: 'Details',\n type: ComponentType.Details,\n content: '',\n options: {}\n },\n {\n name: 'List',\n title: 'List',\n type: ComponentType.List,\n list: '',\n options: {}\n }\n])\n"],"mappings":"AAAA,SAASA,aAAa;AAGtB;AACA;AACA;AACA,OAAO,MAAMC,cAAuC,GAAGC,MAAM,CAACC,MAAM,CAAC,CACnE;EACEC,IAAI,EAAE,WAAW;EACjBC,KAAK,EAAE,YAAY;EACnBC,IAAI,EAAEN,aAAa,CAACO,SAAS;EAC7BC,IAAI,EAAE,EAAE;EACRC,OAAO,EAAE,CAAC,CAAC;EACXC,MAAM,EAAE,CAAC;AACX,CAAC,EACD;EACEN,IAAI,EAAE,oBAAoB;EAC1BC,KAAK,EAAE,sBAAsB;EAC7BC,IAAI,EAAEN,aAAa,CAACW,kBAAkB;EACtCH,IAAI,EAAE,EAAE;EACRC,OAAO,EAAE,CAAC,CAAC;EACXC,MAAM,EAAE,CAAC;AACX,CAAC,EACD;EACEN,IAAI,EAAE,YAAY;EAClBC,KAAK,EAAE,cAAc;EACrBC,IAAI,EAAEN,aAAa,CAACY,UAAU;EAC9BJ,IAAI,EAAE,EAAE;EACRC,OAAO,EAAE,CAAC;AACZ,CAAC,EACD;EACEL,IAAI,EAAE,gBAAgB;EACtBC,KAAK,EAAE,YAAY;EACnBC,IAAI,EAAEN,aAAa,CAACa,cAAc;EAClCL,IAAI,EAAE,EAAE;EACRC,OAAO,EAAE,CAAC;AACZ,CAAC,EACD;EACEL,IAAI,EAAE,gBAAgB;EACtBC,KAAK,EAAE,oBAAoB;EAC3BC,IAAI,EAAEN,aAAa,CAACc,cAAc;EAClCN,IAAI,EAAE,EAAE;EACRC,OAAO,EAAE,CAAC;AACZ,CAAC,EACD;EACEL,IAAI,EAAE,aAAa;EACnBC,KAAK,EAAE,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ACzBC,KAAK,EAAE,qBAAqB;EAC5BC,IAAI,EAAEN,aAAa,CAACuB,iBAAiB;EACrCf,IAAI,EAAE,iCAAiC;EACvCC,OAAO,EAAE,CAAC;AACZ,CAAC,EACD;EACEL,IAAI,EAAE,iBAAiB;EACvBC,KAAK,EAAE,mBAAmB;EAC1BC,IAAI,EAAEN,aAAa,CAACwB,eAAe;EACnCf,OAAO,EAAE,CAAC,CAAC;EACXC,MAAM,EAAE,CAAC;AACX,CAAC,EACD;EACEN,IAAI,EAAE,MAAM;EACZC,KAAK,EAAE,MAAM;EACbC,IAAI,EAAEN,aAAa,CAACyB,IAAI;EACxBC,OAAO,EAAE,EAAE;EACXjB,OAAO,EAAE,CAAC;AACZ,CAAC,EACD;EACEL,IAAI,EAAE,WAAW;EACjBC,KAAK,EAAE,YAAY;EACnBC,IAAI,EAAEN,aAAa,CAAC2B,SAAS;EAC7BD,OAAO,EAAE;AACX,CAAC,EACD;EACEtB,IAAI,EAAE,SAAS;EACfC,KAAK,EAAE,SAAS;EAChBC,IAAI,EAAEN,aAAa,CAAC4B,OAAO;EAC3BF,OAAO,EAAE,EAAE;EACXjB,OAAO,EAAE,CAAC;AACZ,CAAC,EACD;EACEL,IAAI,EAAE,MAAM;EACZC,KAAK,EAAE,MAAM;EACbC,IAAI,EAAEN,aAAa,CAAC6B,IAAI;EACxBb,IAAI,EAAE,EAAE;EACRP,OAAO,EAAE,CAAC;AACZ,CAAC,CACF,CAAC","ignoreList":[]}
@@ -4,12 +4,13 @@ import { ComponentType } from "./enums.js";
4
4
  * Return component defaults by type
5
5
  */
6
6
  export function getComponentDefaults(component) {
7
- if (!component?.type) {
8
- return;
9
- }
10
- return structuredClone(ComponentTypes.find(({
7
+ const defaults = ComponentTypes.find(({
11
8
  type
12
- }) => type === component.type));
9
+ }) => type === component?.type);
10
+ if (!defaults) {
11
+ throw new Error(`Defaults not found for component type '${component?.type}'`);
12
+ }
13
+ return structuredClone(defaults);
13
14
  }
14
15
 
15
16
  /**
@@ -44,6 +45,7 @@ export function isContentType(type) {
44
45
 
45
46
  /**
46
47
  * Filter known components with form fields
48
+ * (includes input fields and selection fields)
47
49
  */
48
50
  export function hasFormField(component) {
49
51
  return isFormType(component?.type);
@@ -64,7 +66,16 @@ export function isListType(type) {
64
66
  }
65
67
 
66
68
  /**
67
- * Filter known components with selection fields
69
+ * Filter known form components with input fields
70
+ * (excludes content and selection fields)
71
+ */
72
+ export function hasInputField(component) {
73
+ return hasFormField(component) && !hasSelectionFields(component);
74
+ }
75
+
76
+ /**
77
+ * Filter known form components with selection fields
78
+ * (excludes content and input fields)
68
79
  */
69
80
  export function hasSelectionFields(component) {
70
81
  const allowedTypes = [ComponentType.AutocompleteField, ComponentType.CheckboxesField, ComponentType.RadiosField, ComponentType.SelectField, ComponentType.YesNoField];
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.js","names":["ComponentTypes","ComponentType","getComponentDefaults","component","type","structuredClone","find","hasConditionSupport","isConditionalType","allowedTypes","AutocompleteField","RadiosField","CheckboxesField","DatePartsField","EmailAddressField","MultilineTextField","TelephoneNumberField","NumberField","SelectField","TextField","YesNoField","Html","Details","includes","hasContent","isContentType","hasContentField","deniedTypes","List","InsetText","hasFormField","isFormType","hasListField","isListType","hasSelectionFields","hasTitle","hasHint"],"sources":["../../../src/components/helpers.ts"],"sourcesContent":["import { ComponentTypes } from '~/src/components/component-types.js'\nimport { ComponentType } from '~/src/components/enums.js'\nimport {\n type ComponentDef,\n type ConditionalComponentsDef,\n type ConditionalComponentType,\n type ContentComponentsDef,\n type FormComponentsDef,\n type HtmlComponent,\n type InsetTextComponent,\n type ListComponent,\n type ListComponentsDef,\n type SelectionComponentsDef\n} from '~/src/components/types.js'\n\n/**\n * Return component defaults by type\n */\nexport function getComponentDefaults(component?: Partial<ComponentDef>) {\n if (!component?.type) {\n return\n }\n\n return structuredClone(\n ComponentTypes.find(({ type }) => type === component.type)\n )\n}\n\n/**\n * Filter known components with support for conditions\n */\nexport function hasConditionSupport(\n component?: Partial<ComponentDef>\n): component is ConditionalComponentsDef {\n return isConditionalType(component?.type)\n}\n\nexport function isConditionalType(\n type?: ComponentType\n): type is ConditionalComponentType {\n const allowedTypes = [\n ComponentType.AutocompleteField,\n ComponentType.RadiosField,\n ComponentType.CheckboxesField,\n ComponentType.DatePartsField,\n ComponentType.EmailAddressField,\n ComponentType.MultilineTextField,\n ComponentType.TelephoneNumberField,\n ComponentType.NumberField,\n ComponentType.SelectField,\n ComponentType.TextField,\n ComponentType.YesNoField,\n ComponentType.Html,\n ComponentType.Details\n ]\n\n return !!type && allowedTypes.includes(type)\n}\n\n/**\n * Filter known components with content (textarea or list)\n */\nexport function hasContent(\n component?: Partial<ComponentDef>\n): component is ContentComponentsDef {\n return isContentType(component?.type)\n}\n\n/**\n * Filter known components with content textarea\n */\nexport function hasContentField(\n component?: Partial<ComponentDef>\n): component is Exclude<ContentComponentsDef, ListComponent> {\n const deniedTypes = [ComponentType.List]\n return hasContent(component) && !deniedTypes.includes(component.type)\n}\n\nexport function isContentType(\n type?: ComponentType\n): type is ContentComponentsDef['type'] {\n const allowedTypes = [\n ComponentType.Details,\n ComponentType.Html,\n ComponentType.InsetText,\n ComponentType.List\n ]\n\n return !!type && allowedTypes.includes(type)\n}\n\n/**\n * Filter known components with form fields\n */\nexport function hasFormField(\n component?: Partial<ComponentDef>\n): component is FormComponentsDef {\n return isFormType(component?.type)\n}\n\nexport function isFormType(\n type?: ComponentType\n): type is FormComponentsDef['type'] {\n return !!type && !isContentType(type)\n}\n\n/**\n * Filter known components with lists\n */\nexport function hasListField(\n component?: Partial<ComponentDef>\n): component is ListComponentsDef {\n return isListType(component?.type)\n}\n\nexport function isListType(\n type?: ComponentType\n): type is ListComponentsDef['type'] {\n const allowedTypes = [\n ComponentType.AutocompleteField,\n ComponentType.List,\n ComponentType.RadiosField,\n ComponentType.SelectField,\n ComponentType.CheckboxesField\n ]\n\n return !!type && allowedTypes.includes(type)\n}\n\n/**\n * Filter known components with selection fields\n */\nexport function hasSelectionFields(\n component?: Partial<ComponentDef>\n): component is SelectionComponentsDef {\n const allowedTypes = [\n ComponentType.AutocompleteField,\n ComponentType.CheckboxesField,\n ComponentType.RadiosField,\n ComponentType.SelectField,\n ComponentType.YesNoField\n ]\n\n return !!component?.type && allowedTypes.includes(component.type)\n}\n\n/**\n * Filter known components with titles\n */\nexport function hasTitle(\n component?: Partial<ComponentDef>\n): component is Exclude<ComponentDef, InsetTextComponent | HtmlComponent> {\n const deniedTypes = [ComponentType.InsetText, ComponentType.Html]\n return !!component?.type && !deniedTypes.includes(component.type)\n}\n\n/**\n * Filter known components with hint text\n */\nexport function hasHint(\n component?: Partial<ComponentDef>\n): component is FormComponentsDef | ListComponent {\n return isFormType(component?.type) || component?.type === ComponentType.List\n}\n"],"mappings":"AAAA,SAASA,cAAc;AACvB,SAASC,aAAa;AActB;AACA;AACA;AACA,OAAO,SAASC,oBAAoBA,CAACC,SAAiC,EAAE;EACtE,IAAI,CAACA,SAAS,EAAEC,IAAI,EAAE;IACpB;EACF;EAEA,OAAOC,eAAe,CACpBL,cAAc,CAACM,IAAI,CAAC,CAAC;IAAEF;EAAK,CAAC,KAAKA,IAAI,KAAKD,SAAS,CAACC,IAAI,CAC3D,CAAC;AACH;;AAEA;AACA;AACA;AACA,OAAO,SAASG,mBAAmBA,CACjCJ,SAAiC,EACM;EACvC,OAAOK,iBAAiB,CAACL,SAAS,EAAEC,IAAI,CAAC;AAC3C;AAEA,OAAO,SAASI,iBAAiBA,CAC/BJ,IAAoB,EACc;EAClC,MAAMK,YAAY,GAAG,CACnBR,aAAa,CAACS,iBAAiB,EAC/BT,aAAa,CAACU,WAAW,EACzBV,aAAa,CAACW,eAAe,EAC7BX,aAAa,CAACY,cAAc,EAC5BZ,aAAa,CAACa,iBAAiB,EAC/Bb,aAAa,CAACc,kBAAkB,EAChCd,aAAa,CAACe,oBAAoB,EAClCf,aAAa,CAACgB,WAAW,EACzBhB,aAAa,CAACiB,WAAW,EACzBjB,a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7B,IAAoB,EACe;EACnC,MAAMK,YAAY,GAAG,CACnBR,aAAa,CAACS,iBAAiB,EAC/BT,aAAa,CAAC2B,IAAI,EAClB3B,aAAa,CAACU,WAAW,EACzBV,aAAa,CAACiB,WAAW,EACzBjB,aAAa,CAACW,eAAe,CAC9B;EAED,OAAO,CAAC,CAACR,IAAI,IAAIK,YAAY,CAACc,QAAQ,CAACnB,IAAI,CAAC;AAC9C;;AAEA;AACA;AACA;AACA,OAAO,SAAS8B,kBAAkBA,CAChC/B,SAAiC,EACI;EACrC,MAAMM,YAAY,GAAG,CACnBR,aAAa,CAACS,iBAAiB,EAC/BT,aAAa,CAACW,eAAe,EAC7BX,aAAa,CAACU,WAAW,EACzBV,aAAa,CAACiB,WAAW,EACzBjB,aAAa,CAACmB,UAAU,CACzB;EAED,OAAO,CAAC,CAACjB,SAAS,EAAEC,IAAI,IAAIK,YAAY,CAACc,QAAQ,CAACpB,SAAS,CAACC,IAAI,CAAC;AACnE;;AAEA;AACA;AACA;AACA,OAAO,SAAS+B,QAAQA,CACtBhC,SAAiC,EACuC;EACxE,MAAMwB,WAAW,GAAG,CAAC1B,aAAa,CAAC4B,SAAS,EAAE5B,aAAa,CAACoB,IAAI,CAAC;EACjE,OAAO,CAAC,CAAClB,SAAS,EAAEC,IAAI,IAAI,CAACuB,WAAW,CAACJ,QAAQ,CAACpB,SAAS,CAACC,IAAI,CAAC;AACnE;;AAEA;AACA;AACA;AACA,OAAO,SAASgC,OAAOA,CACrBjC,SAAiC,EACe;EAChD,OAAO4B,UAAU,CAAC5B,SAAS,EAAEC,IAAI,CAAC,IAAID,SAAS,EAAEC,IAAI,KAAKH,aAAa,CAAC2B,IAAI;AAC9E","ignoreList":[]}
1
+ {"version":3,"file":"helpers.js","names":["ComponentTypes","ComponentType","getComponentDefaults","component","defaults","find","type","Error","structuredClone","hasConditionSupport","isConditionalType","allowedTypes","AutocompleteField","RadiosField","CheckboxesField","DatePartsField","EmailAddressField","MultilineTextField","TelephoneNumberField","NumberField","SelectField","TextField","YesNoField","Html","Details","includes","hasContent","isContentType","hasContentField","deniedTypes","List","InsetText","hasFormField","isFormType","hasListField","isListType","hasInputField","hasSelectionFields","hasTitle","hasHint"],"sources":["../../../src/components/helpers.ts"],"sourcesContent":["import { ComponentTypes } from '~/src/components/component-types.js'\nimport { ComponentType } from '~/src/components/enums.js'\nimport {\n type ComponentDef,\n type ConditionalComponentsDef,\n type ConditionalComponentType,\n type ContentComponentsDef,\n type FormComponentsDef,\n type HtmlComponent,\n type InputFieldsComponentsDef,\n type InsetTextComponent,\n type ListComponent,\n type ListComponentsDef,\n type SelectionComponentsDef\n} from '~/src/components/types.js'\n\n/**\n * Return component defaults by type\n */\nexport function getComponentDefaults<FieldType extends ComponentDef>(\n component?: Pick<FieldType, 'type'>\n) {\n const defaults = ComponentTypes.find(({ type }) => type === component?.type)\n\n if (!defaults) {\n throw new Error(\n `Defaults not found for component type '${component?.type}'`\n )\n }\n\n return structuredClone(defaults) as FieldType\n}\n\n/**\n * Filter known components with support for conditions\n */\nexport function hasConditionSupport(\n component?: Partial<ComponentDef>\n): component is ConditionalComponentsDef {\n return isConditionalType(component?.type)\n}\n\nexport function isConditionalType(\n type?: ComponentType\n): type is ConditionalComponentType {\n const allowedTypes = [\n ComponentType.AutocompleteField,\n ComponentType.RadiosField,\n ComponentType.CheckboxesField,\n ComponentType.DatePartsField,\n ComponentType.EmailAddressField,\n ComponentType.MultilineTextField,\n ComponentType.TelephoneNumberField,\n ComponentType.NumberField,\n ComponentType.SelectField,\n ComponentType.TextField,\n ComponentType.YesNoField,\n ComponentType.Html,\n ComponentType.Details\n ]\n\n return !!type && allowedTypes.includes(type)\n}\n\n/**\n * Filter known components with content (textarea or list)\n */\nexport function hasContent(\n component?: Partial<ComponentDef>\n): component is ContentComponentsDef {\n return isContentType(component?.type)\n}\n\n/**\n * Filter known components with content textarea\n */\nexport function hasContentField(\n component?: Partial<ComponentDef>\n): component is Exclude<ContentComponentsDef, ListComponent> {\n const deniedTypes = [ComponentType.List]\n return hasContent(component) && !deniedTypes.includes(component.type)\n}\n\nexport function isContentType(\n type?: ComponentType\n): type is ContentComponentsDef['type'] {\n const allowedTypes = [\n ComponentType.Details,\n ComponentType.Html,\n ComponentType.InsetText,\n ComponentType.List\n ]\n\n return !!type && allowedTypes.includes(type)\n}\n\n/**\n * Filter known components with form fields\n * (includes input fields and selection fields)\n */\nexport function hasFormField(\n component?: Partial<ComponentDef>\n): component is FormComponentsDef {\n return isFormType(component?.type)\n}\n\nexport function isFormType(\n type?: ComponentType\n): type is FormComponentsDef['type'] {\n return !!type && !isContentType(type)\n}\n\n/**\n * Filter known components with lists\n */\nexport function hasListField(\n component?: Partial<ComponentDef>\n): component is ListComponentsDef {\n return isListType(component?.type)\n}\n\nexport function isListType(\n type?: ComponentType\n): type is ListComponentsDef['type'] {\n const allowedTypes = [\n ComponentType.AutocompleteField,\n ComponentType.List,\n ComponentType.RadiosField,\n ComponentType.SelectField,\n ComponentType.CheckboxesField\n ]\n\n return !!type && allowedTypes.includes(type)\n}\n\n/**\n * Filter known form components with input fields\n * (excludes content and selection fields)\n */\nexport function hasInputField(\n component?: Partial<ComponentDef>\n): component is InputFieldsComponentsDef {\n return hasFormField(component) && !hasSelectionFields(component)\n}\n\n/**\n * Filter known form components with selection fields\n * (excludes content and input fields)\n */\nexport function hasSelectionFields(\n component?: Partial<ComponentDef>\n): component is SelectionComponentsDef {\n const allowedTypes = [\n ComponentType.AutocompleteField,\n ComponentType.CheckboxesField,\n ComponentType.RadiosField,\n ComponentType.SelectField,\n ComponentType.YesNoField\n ]\n\n return !!component?.type && allowedTypes.includes(component.type)\n}\n\n/**\n * Filter known components with titles\n */\nexport function hasTitle(\n component?: Partial<ComponentDef>\n): component is Exclude<ComponentDef, InsetTextComponent | HtmlComponent> {\n const deniedTypes = [ComponentType.InsetText, ComponentType.Html]\n return !!component?.type && !deniedTypes.includes(component.type)\n}\n\n/**\n * Filter known components with hint text\n */\nexport function hasHint(\n component?: Partial<ComponentDef>\n): component is FormComponentsDef | ListComponent {\n return isFormType(component?.type) || component?.type === ComponentType.List\n}\n"],"mappings":"AAAA,SAASA,cAAc;AACvB,SAASC,aAAa;AAetB;AACA;AACA;AACA,OAAO,SAASC,oBAAoBA,CAClCC,SAAmC,EACnC;EACA,MAAMC,QAAQ,GAAGJ,cAAc,CAACK,IAAI,CAAC,CAAC;IAAEC;EAAK,CAAC,KAAKA,IAAI,KAAKH,SAAS,EAAEG,IAAI,CAAC;EAE5E,IAAI,CAACF,QAAQ,EAAE;IACb,MAAM,IAAIG,KAAK,CACb,0CAA0CJ,SAAS,EAAEG,IAAI,GAC3D,CAAC;EACH;EAEA,OAAOE,eAAe,CAACJ,QAAQ,CAAC;AAClC;;AAEA;AACA;AACA;AACA,OAAO,SAASK,mBAAmBA,CACjCN,SAAiC,EACM;EACvC,OAAOO,iBAAiB,CAACP,SAAS,EAAEG,IAAI,CAAC;AAC3C;AAEA,OAAO,SAASI,iBAAiBA,CAC/BJ,IAAoB,EACc;EAClC,MAAMK,YAAY,GAAG,CACnBV,aAAa,CAACW,iBAAiB,EAC/BX,aAAa,CAACY,WAAW,EACzBZ,aAAa,CAACa,eAAe,EAC7Bb,aAAa,CAACc,cAAc,EAC5Bd,aAAa,CAACe,iBAAiB,EAC/Bf,aAAa,CAACgB,kBAAkB,EAChChB,aAAa,CAACiB,oBAAoB,EAClCjB,aAAa,CAACkB,WAAW,EACzBlB,aAAa,CAACmB,WAAW,EACzBnB,aAAa,CAACoB,SAAS,EACvBpB,aAAa,CAACqB,UAAU,EACxBrB,aAAa,CAACsB,IAAI,EAClBtB,aAAa,CAACuB,OAAO,CACtB;EAED,OAAO,CAAC,CAAClB,IAAI,IAAIK,YAAY,CAACc,QAAQ,CAACnB,IAAI,CAAC;AAC9C;;AAEA;AACA;AACA;AACA,OAAO,SAASoB,UAAUA,CACxBvB,SAAiC,EACE;EACnC,OAAOwB,aAAa,CAACxB,SAAS,EAAEG,IAAI,CAAC;AACv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8B,aAAaA,CAC3BjC,SAAiC,EACM;EACvC,OAAO6B,YAAY,CAAC7B,SAAS,CAAC,IAAI,CAACkC,kBAAkB,CAAClC,SAAS,CAAC;AAClE;;AAEA;AACA;AACA;AACA;AACA,OAAO,SAASkC,kBAAkBA,CAChClC,SAAiC,EACI;EACrC,MAAMQ,YAAY,GAAG,CACnBV,aAAa,CAACW,iBAAiB,EAC/BX,aAAa,CAACa,eAAe,EAC7Bb,aAAa,CAACY,WAAW,EACzBZ,aAAa,CAACmB,WAAW,EACzBnB,aAAa,CAACqB,UAAU,CACzB;EAED,OAAO,CAAC,CAACnB,SAAS,EAAEG,IAAI,IAAIK,YAAY,CAACc,QAAQ,CAACtB,SAAS,CAACG,IAAI,CAAC;AACnE;;AAEA;AACA;AACA;AACA,OAAO,SAASgC,QAAQA,CACtBnC,SAAiC,EACuC;EACxE,MAAM0B,WAAW,GAAG,CAAC5B,aAAa,CAAC8B,SAAS,EAAE9B,aAAa,CAACsB,IAAI,CAAC;EACjE,OAAO,CAAC,CAACpB,SAAS,EAAEG,IAAI,IAAI,CAACuB,WAAW,CAACJ,QAAQ,CAACtB,SAAS,CAACG,IAAI,CAAC;AACnE;;AAEA;AACA;AACA;AACA,OAAO,SAASiC,OAAOA,CACrBpC,SAAiC,EACe;EAChD,OAAO8B,UAAU,CAAC9B,SAAS,EAAEG,IAAI,CAAC,IAAIH,SAAS,EAAEG,IAAI,KAAKL,aAAa,CAAC6B,IAAI;AAC9E","ignoreList":[]}
@@ -1,4 +1,4 @@
1
1
  export { ComponentTypes } from "./component-types.js";
2
- export { getComponentDefaults, hasConditionSupport, hasContent, hasContentField, hasFormField, hasHint, hasListField, hasSelectionFields, hasTitle, isConditionalType, isContentType, isFormType, isListType } from "./helpers.js";
2
+ export { getComponentDefaults, hasConditionSupport, hasContent, hasContentField, hasFormField, hasHint, hasListField, hasInputField, hasSelectionFields, hasTitle, isConditionalType, isContentType, isFormType, isListType } from "./helpers.js";
3
3
  export { ComponentType } from "./enums.js";
4
4
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["ComponentTypes","getComponentDefaults","hasConditionSupport","hasContent","hasContentField","hasFormField","hasHint","hasListField","hasSelectionFields","hasTitle","isConditionalType","isContentType","isFormType","isListType","ComponentType"],"sources":["../../../src/components/index.ts"],"sourcesContent":["export { ComponentTypes } from '~/src/components/component-types.js'\nexport {\n getComponentDefaults,\n hasConditionSupport,\n hasContent,\n hasContentField,\n hasFormField,\n hasHint,\n hasListField,\n hasSelectionFields,\n hasTitle,\n isConditionalType,\n isContentType,\n isFormType,\n isListType\n} from '~/src/components/helpers.js'\n\nexport { ComponentType } from '~/src/components/enums.js'\n"],"mappings":"AAAA,SAASA,cAAc;AACvB,SACEC,oBAAoB,EACpBC,mBAAmB,EACnBC,UAAU,EACVC,eAAe,EACfC,YAAY,EACZC,OAAO,EACPC,YAAY,EACZC,kBAAkB,EAClBC,QAAQ,EACRC,iBAAiB,EACjBC,aAAa,EACbC,UAAU,EACVC,UAAU;AAGZ,SAASC,aAAa","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["ComponentTypes","getComponentDefaults","hasConditionSupport","hasContent","hasContentField","hasFormField","hasHint","hasListField","hasInputField","hasSelectionFields","hasTitle","isConditionalType","isContentType","isFormType","isListType","ComponentType"],"sources":["../../../src/components/index.ts"],"sourcesContent":["export { ComponentTypes } from '~/src/components/component-types.js'\nexport {\n getComponentDefaults,\n hasConditionSupport,\n hasContent,\n hasContentField,\n hasFormField,\n hasHint,\n hasListField,\n hasInputField,\n hasSelectionFields,\n hasTitle,\n isConditionalType,\n isContentType,\n isFormType,\n isListType\n} from '~/src/components/helpers.js'\n\nexport { ComponentType } from '~/src/components/enums.js'\n"],"mappings":"AAAA,SAASA,cAAc;AACvB,SACEC,oBAAoB,EACpBC,mBAAmB,EACnBC,UAAU,EACVC,eAAe,EACfC,YAAY,EACZC,OAAO,EACPC,YAAY,EACZC,aAAa,EACbC,kBAAkB,EAClBC,QAAQ,EACRC,iBAAiB,EACjBC,aAAa,EACbC,UAAU,EACVC,UAAU;AAGZ,SAASC,aAAa","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":[],"sources":["../../../../src/form/form-definition/types.ts"],"sourcesContent":["import { type ComponentDef } from '~/src/components/types.js'\nimport { type ConditionsModelData } from '~/src/conditions/types.js'\nimport { formDefinitionSchema } from '~/src/form/form-definition/index.js'\nimport { type ControllerPath, type ControllerType } from '~/src/pages/enums.js'\n\nexport interface Link {\n path: string\n condition?: string\n redirect?: string\n}\n\nexport interface PageBase {\n title: string\n path: string\n}\n\nexport interface PageStart extends PageBase {\n controller: ControllerType.Start | ControllerType.Home\n section?: string | undefined\n next: Link[]\n components: ComponentDef[]\n}\n\nexport interface PageQuestion extends PageBase {\n controller?: ControllerType.Page | ControllerType.FileUpload\n section?: string | undefined\n next: Link[]\n components: ComponentDef[]\n}\n\nexport interface PageSummary extends PageBase {\n path: ControllerPath.Summary\n controller: ControllerType.Summary\n section?: undefined\n}\n\nexport interface PageStatus extends PageBase {\n path: ControllerPath.Status\n controller: ControllerType.Status\n section?: undefined\n}\n\nexport type Page = PageStart | PageQuestion | PageSummary | PageStatus\n\nexport type RequiredField<\n Type extends Partial<object>,\n KeyType extends keyof Type\n> = Omit<Type, KeyType> &\n Required<{\n [Key in KeyType]: Type[Key]\n }>\n\nexport interface Section {\n name: string\n title: string\n hideTitle?: boolean\n}\n\nexport interface Item {\n text: string\n value: string | number | boolean\n description?: string\n conditional?: { components: ComponentDef[] }\n condition?: string\n}\n\nexport interface List {\n name: string\n title: string\n type: ListTypeContent\n items: Item[]\n}\n\nexport type ListTypeOption = 'bulleted' | 'numbered'\nexport type ListTypeContent = 'string' | 'number' | 'boolean'\n\nexport interface Feedback {\n feedbackForm?: boolean\n url?: string\n emailAddress?: string\n}\n\nexport interface PhaseBanner {\n phase?: 'alpha' | 'beta'\n feedbackUrl?: string\n}\n\nexport interface ConditionWrapper {\n name: string\n displayName: string\n value: ConditionsModelData\n}\n\n/**\n * Interface for `formDefinitionSchema` Joi schema\n * @see {@link formDefinitionSchema}\n */\nexport interface FormDefinition {\n pages: Page[]\n conditions: ConditionWrapper[]\n lists: List[]\n sections: Section[]\n startPage?: string\n name?: string\n feedback?: Feedback\n phaseBanner?: PhaseBanner\n skipSummary?: boolean\n declaration?: string\n metadata?: Record<string, unknown>\n outputEmail?: string\n}\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"file":"types.js","names":[],"sources":["../../../../src/form/form-definition/types.ts"],"sourcesContent":["import { type ComponentDef } from '~/src/components/types.js'\nimport { type ConditionsModelData } from '~/src/conditions/types.js'\nimport { formDefinitionSchema } from '~/src/form/form-definition/index.js'\nimport { type ControllerPath, type ControllerType } from '~/src/pages/enums.js'\n\nexport interface Link {\n path: string\n condition?: string\n redirect?: string\n}\n\nexport interface PageBase {\n title: string\n path: string\n}\n\nexport interface PageStart extends PageBase {\n path: ControllerPath.Start | string\n controller: ControllerType.Start | ControllerType.Home\n section?: string | undefined\n next: Link[]\n components: ComponentDef[]\n}\n\nexport interface PageQuestion extends PageBase {\n controller?: ControllerType.Page\n section?: string | undefined\n next: Link[]\n components: ComponentDef[]\n}\n\nexport interface PageFileUpload extends PageBase {\n controller?: ControllerType.FileUpload\n section?: string | undefined\n next: Link[]\n components: ComponentDef[]\n}\n\nexport interface PageSummary extends PageBase {\n path: ControllerPath.Summary | string\n controller: ControllerType.Summary\n section?: undefined\n}\n\nexport interface PageStatus extends PageBase {\n path: ControllerPath.Status | string\n controller: ControllerType.Status\n section?: undefined\n}\n\nexport type Page =\n | PageStart\n | PageQuestion\n | PageFileUpload\n | PageSummary\n | PageStatus\n\nexport type RequiredField<\n Type extends Partial<object>,\n KeyType extends keyof Type\n> = Omit<Type, KeyType> &\n Required<{\n [Key in KeyType]: Type[Key]\n }>\n\nexport interface Section {\n name: string\n title: string\n hideTitle?: boolean\n}\n\nexport interface Item {\n text: string\n value: string | number | boolean\n description?: string\n conditional?: { components: ComponentDef[] }\n condition?: string\n}\n\nexport interface List {\n name: string\n title: string\n type: ListTypeContent\n items: Item[]\n}\n\nexport type ListTypeOption = 'bulleted' | 'numbered'\nexport type ListTypeContent = 'string' | 'number' | 'boolean'\n\nexport interface Feedback {\n feedbackForm?: boolean\n url?: string\n emailAddress?: string\n}\n\nexport interface PhaseBanner {\n phase?: 'alpha' | 'beta'\n feedbackUrl?: string\n}\n\nexport interface ConditionWrapper {\n name: string\n displayName: string\n value: ConditionsModelData\n}\n\n/**\n * Interface for `formDefinitionSchema` Joi schema\n * @see {@link formDefinitionSchema}\n */\nexport interface FormDefinition {\n pages: Page[]\n conditions: ConditionWrapper[]\n lists: List[]\n sections: Section[]\n startPage?: string\n name?: string\n feedback?: Feedback\n phaseBanner?: PhaseBanner\n skipSummary?: boolean\n declaration?: string\n metadata?: Record<string, unknown>\n outputEmail?: string\n}\n"],"mappings":"","ignoreList":[]}
@@ -6,10 +6,10 @@ import { PageTypes } from "./page-types.js";
6
6
  * Return component defaults by type
7
7
  */
8
8
  export function getPageDefaults(page) {
9
- const controller = controllerNameFromPath(page.controller);
9
+ const controller = controllerNameFromPath(page.controller ?? ControllerType.Page);
10
10
  const defaults = PageTypes.find(pageType => pageType.controller === controller);
11
11
  if (!defaults) {
12
- throw new Error(`Defaults not found for ${page.controller}`);
12
+ throw new Error(`Defaults not found for page type '${page.controller}'`);
13
13
  }
14
14
  return structuredClone(defaults);
15
15
  }
@@ -21,6 +21,13 @@ export function hasComponents(page) {
21
21
  return isLinkablePage(page) && Array.isArray(page.components);
22
22
  }
23
23
 
24
+ /**
25
+ * Check page has form components
26
+ */
27
+ export function hasFormComponents(page) {
28
+ return isLinkablePage(page) && Array.isArray(page.components);
29
+ }
30
+
24
31
  /**
25
32
  * Check page has sections
26
33
  */
@@ -50,7 +57,7 @@ export function isLinkablePage(page) {
50
57
  return false;
51
58
  }
52
59
  const controller = controllerNameFromPath(page.controller);
53
- return controller === ControllerType.Start || controller === ControllerType.Page || controller === ControllerType.FileUpload;
60
+ return !controller || controller === ControllerType.Start || controller === ControllerType.Page || controller === ControllerType.FileUpload;
54
61
  }
55
62
 
56
63
  /**
@@ -58,7 +65,7 @@ export function isLinkablePage(page) {
58
65
  */
59
66
  export function isQuestionPage(page) {
60
67
  const controller = controllerNameFromPath(page?.controller);
61
- return controller === ControllerType.Page || controller === ControllerType.FileUpload;
68
+ return !controller || controller === ControllerType.Page || controller === ControllerType.FileUpload;
62
69
  }
63
70
 
64
71
  /**
@@ -72,6 +79,6 @@ export function controllerNameFromPath(nameOrPath) {
72
79
  const options = ControllerTypes.find(({
73
80
  path
74
81
  }) => path === nameOrPath);
75
- return options?.name ?? ControllerType.Page;
82
+ return options?.name;
76
83
  }
77
84
  //# sourceMappingURL=helpers.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.js","names":["ControllerNames","ControllerTypes","ControllerType","PageTypes","getPageDefaults","page","controller","controllerNameFromPath","defaults","find","pageType","Error","structuredClone","hasComponents","isLinkablePage","Array","isArray","components","hasSection","section","hasNext","isControllerName","nameOrPath","includes","Start","Page","FileUpload","isQuestionPage","options","path","name"],"sources":["../../../src/pages/helpers.ts"],"sourcesContent":["import { type ComponentDef } from '~/src/components/types.js'\nimport {\n type Link,\n type Page,\n type PageQuestion,\n type PageStart,\n type RequiredField\n} from '~/src/form/form-definition/types.js'\nimport {\n ControllerNames,\n ControllerTypes\n} from '~/src/pages/controller-types.js'\nimport { ControllerType } from '~/src/pages/enums.js'\nimport { PageTypes } from '~/src/pages/page-types.js'\n\n/**\n * Return component defaults by type\n */\nexport function getPageDefaults(page: Pick<Page, 'controller'>) {\n const controller = controllerNameFromPath(page.controller)\n\n const defaults = PageTypes.find(\n (pageType) => pageType.controller === controller\n )\n\n if (!defaults) {\n throw new Error(`Defaults not found for ${page.controller}`)\n }\n\n return structuredClone(defaults)\n}\n\n/**\n * Check page has components\n */\nexport function hasComponents(\n page?: Partial<Page>\n): page is Extract<Page, { components: ComponentDef[] }> {\n return isLinkablePage(page) && Array.isArray(page.components)\n}\n\n/**\n * Check page has sections\n */\nexport function hasSection(\n page?: Partial<Page>\n): page is RequiredField<PageStart | PageQuestion, 'section'> {\n return isLinkablePage(page) && typeof page.section === 'string'\n}\n\n/**\n * Check page has next link\n */\nexport function hasNext(page?: Partial<Page>) {\n return isLinkablePage(page)\n}\n\n/**\n * Check for known page controller names\n */\nexport function isControllerName(\n nameOrPath?: ControllerType | string\n): nameOrPath is ControllerType {\n return !!nameOrPath && ControllerNames.includes(nameOrPath)\n}\n\n/**\n * Check page is linkable\n */\nexport function isLinkablePage(\n page?: Partial<Page>\n): page is Extract<Page, { next: Link[] }> {\n if (!page || !('next' in page)) {\n return false\n }\n\n const controller = controllerNameFromPath(page.controller)\n\n return (\n controller === ControllerType.Start ||\n controller === ControllerType.Page ||\n controller === ControllerType.FileUpload\n )\n}\n\n/**\n * Check page supports questions\n */\nexport function isQuestionPage(page?: Partial<Page>): page is PageQuestion {\n const controller = controllerNameFromPath(page?.controller)\n\n return (\n controller === ControllerType.Page ||\n controller === ControllerType.FileUpload\n )\n}\n\n/**\n * Check and optionally replace legacy path with controller name\n * @param {string} [nameOrPath] - Controller name or legacy controller path\n */\nexport function controllerNameFromPath(nameOrPath?: ControllerType | string) {\n if (isControllerName(nameOrPath)) {\n return nameOrPath\n }\n\n const options = ControllerTypes.find(({ path }) => path === nameOrPath)\n return options?.name ?? ControllerType.Page\n}\n"],"mappings":"AAQA,SACEA,eAAe,EACfC,eAAe;AAEjB,SAASC,cAAc;AACvB,SAASC,SAAS;;AAElB;AACA;AACA;AACA,OAAO,SAASC,eAAeA,CAACC,IAA8B,EAAE;EAC9D,MAAMC,UAAU,GAAGC,sBAAsB,CAACF,IAAI,CAACC,UAAU,CAAC;EAE1D,MAAME,QAAQ,GAAGL,SAAS,CAACM,IAAI,CAC5BC,QAAQ,IAAKA,QAAQ,CAACJ,UAAU,KAAKA,UACxC,CAAC;EAED,IAAI,CAACE,QAAQ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AClCnB,UAAU,KAAKJ,cAAc,CAACwB,UAAU;AAE5C;;AAEA;AACA;AACA;AACA;AACA,OAAO,SAASnB,sBAAsBA,CAACe,UAAoC,EAAE;EAC3E,IAAID,gBAAgB,CAACC,UAAU,CAAC,EAAE;IAChC,OAAOA,UAAU;EACnB;EAEA,MAAMM,OAAO,GAAG3B,eAAe,CAACQ,IAAI,CAAC,CAAC;IAAEoB;EAAK,CAAC,KAAKA,IAAI,KAAKP,UAAU,CAAC;EACvE,OAAOM,OAAO,EAAEE,IAAI,IAAI5B,cAAc,CAACuB,IAAI;AAC7C","ignoreList":[]}
1
+ {"version":3,"file":"helpers.js","names":["ControllerNames","ControllerTypes","ControllerType","PageTypes","getPageDefaults","page","controller","controllerNameFromPath","Page","defaults","find","pageType","Error","structuredClone","hasComponents","isLinkablePage","Array","isArray","components","hasFormComponents","hasSection","section","hasNext","isControllerName","nameOrPath","includes","Start","FileUpload","isQuestionPage","options","path","name"],"sources":["../../../src/pages/helpers.ts"],"sourcesContent":["import { type ComponentDef } from '~/src/components/types.js'\nimport {\n type Link,\n type Page,\n type PageFileUpload,\n type PageQuestion,\n type PageStart,\n type RequiredField\n} from '~/src/form/form-definition/types.js'\nimport {\n ControllerNames,\n ControllerTypes\n} from '~/src/pages/controller-types.js'\nimport { ControllerType } from '~/src/pages/enums.js'\nimport { PageTypes } from '~/src/pages/page-types.js'\n\n/**\n * Return component defaults by type\n */\nexport function getPageDefaults<PageType extends Page>(\n page: Pick<PageType, 'controller'>\n) {\n const controller = controllerNameFromPath(\n page.controller ?? ControllerType.Page\n )\n\n const defaults = PageTypes.find(\n (pageType) => pageType.controller === controller\n )\n\n if (!defaults) {\n throw new Error(`Defaults not found for page type '${page.controller}'`)\n }\n\n return structuredClone(defaults) as PageType\n}\n\n/**\n * Check page has components\n */\nexport function hasComponents(\n page?: Partial<Page>\n): page is Extract<Page, { components: ComponentDef[] }> {\n return isLinkablePage(page) && Array.isArray(page.components)\n}\n\n/**\n * Check page has form components\n */\nexport function hasFormComponents(\n page?: Partial<Page>\n): page is Extract<Page, { components: ComponentDef[] }> {\n return isLinkablePage(page) && Array.isArray(page.components)\n}\n\n/**\n * Check page has sections\n */\nexport function hasSection(\n page: Partial<Page>\n): page is\n | RequiredField<PageStart, 'section'>\n | RequiredField<PageQuestion, 'section'>\n | RequiredField<PageFileUpload, 'section'> {\n return isLinkablePage(page) && typeof page.section === 'string'\n}\n\n/**\n * Check page has next link\n */\nexport function hasNext(page?: Partial<Page>) {\n return isLinkablePage(page)\n}\n\n/**\n * Check for known page controller names\n */\nexport function isControllerName(\n nameOrPath?: ControllerType | string\n): nameOrPath is ControllerType {\n return !!nameOrPath && ControllerNames.includes(nameOrPath)\n}\n\n/**\n * Check page is linkable\n */\nexport function isLinkablePage(\n page?: Partial<Page>\n): page is Extract<Page, { next: Link[] }> {\n if (!page || !('next' in page)) {\n return false\n }\n\n const controller = controllerNameFromPath(page.controller)\n\n return (\n !controller ||\n controller === ControllerType.Start ||\n controller === ControllerType.Page ||\n controller === ControllerType.FileUpload\n )\n}\n\n/**\n * Check page supports questions\n */\nexport function isQuestionPage(page?: Partial<Page>): page is PageQuestion {\n const controller = controllerNameFromPath(page?.controller)\n\n return (\n !controller ||\n controller === ControllerType.Page ||\n controller === ControllerType.FileUpload\n )\n}\n\n/**\n * Check and optionally replace legacy path with controller name\n * @param {string} [nameOrPath] - Controller name or legacy controller path\n */\nexport function controllerNameFromPath(nameOrPath?: ControllerType | string) {\n if (isControllerName(nameOrPath)) {\n return nameOrPath\n }\n\n const options = ControllerTypes.find(({ path }) => path === nameOrPath)\n return options?.name\n}\n"],"mappings":"AASA,SACEA,eAAe,EACfC,eAAe;AAEjB,SAASC,cAAc;AACvB,SAASC,SAAS;;AAElB;AACA;AACA;AACA,OAAO,SAASC,eAAeA,CAC7BC,IAAkC,EAClC;EACA,MAAMC,UAAU,GAAGC,sBAAsB,CACvCF,IAAI,CAACC,UAAU,IAAIJ,cAAc,CAACM,IACpC,CAAC;E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ACA,UAAU,IACXA,UAAU,KAAKJ,cAAc,CAACwB,KAAK,IACnCpB,UAAU,KAAKJ,cAAc,CAACM,IAAI,IAClCF,UAAU,KAAKJ,cAAc,CAACyB,UAAU;AAE5C;;AAEA;AACA;AACA;AACA,OAAO,SAASC,cAAcA,CAACvB,IAAoB,EAAwB;EACzE,MAAMC,UAAU,GAAGC,sBAAsB,CAACF,IAAI,EAAEC,UAAU,CAAC;EAE3D,OACE,CAACA,UAAU,IACXA,UAAU,KAAKJ,cAAc,CAACM,IAAI,IAClCF,UAAU,KAAKJ,cAAc,CAACyB,UAAU;AAE5C;;AAEA;AACA;AACA;AACA;AACA,OAAO,SAASpB,sBAAsBA,CAACiB,UAAoC,EAAE;EAC3E,IAAID,gBAAgB,CAACC,UAAU,CAAC,EAAE;IAChC,OAAOA,UAAU;EACnB;EAEA,MAAMK,OAAO,GAAG5B,eAAe,CAACS,IAAI,CAAC,CAAC;IAAEoB;EAAK,CAAC,KAAKA,IAAI,KAAKN,UAAU,CAAC;EACvE,OAAOK,OAAO,EAAEE,IAAI;AACtB","ignoreList":[]}
@@ -1,5 +1,5 @@
1
1
  export { ControllerNames, ControllerTypes } from "./controller-types.js";
2
2
  export { PageTypes } from "./page-types.js";
3
- export { controllerNameFromPath, getPageDefaults, hasComponents, hasSection, hasNext, isControllerName, isLinkablePage, isQuestionPage } from "./helpers.js";
3
+ export { controllerNameFromPath, getPageDefaults, hasComponents, hasFormComponents, hasSection, hasNext, isControllerName, isLinkablePage, isQuestionPage } from "./helpers.js";
4
4
  export { ControllerPath, ControllerType } from "./enums.js";
5
5
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["ControllerNames","ControllerTypes","PageTypes","controllerNameFromPath","getPageDefaults","hasComponents","hasSection","hasNext","isControllerName","isLinkablePage","isQuestionPage","ControllerPath","ControllerType"],"sources":["../../../src/pages/index.ts"],"sourcesContent":["export {\n ControllerNames,\n ControllerTypes\n} from '~/src/pages/controller-types.js'\n\nexport { PageTypes } from '~/src/pages/page-types.js'\n\nexport {\n controllerNameFromPath,\n getPageDefaults,\n hasComponents,\n hasSection,\n hasNext,\n isControllerName,\n isLinkablePage,\n isQuestionPage\n} from '~/src/pages/helpers.js'\n\nexport { ControllerPath, ControllerType } from '~/src/pages/enums.js'\n"],"mappings":"AAAA,SACEA,eAAe,EACfC,eAAe;AAGjB,SAASC,SAAS;AAElB,SACEC,sBAAsB,EACtBC,eAAe,EACfC,aAAa,EACbC,UAAU,EACVC,OAAO,EACPC,gBAAgB,EAChBC,cAAc,EACdC,cAAc;AAGhB,SAASC,cAAc,EAAEC,cAAc","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["ControllerNames","ControllerTypes","PageTypes","controllerNameFromPath","getPageDefaults","hasComponents","hasFormComponents","hasSection","hasNext","isControllerName","isLinkablePage","isQuestionPage","ControllerPath","ControllerType"],"sources":["../../../src/pages/index.ts"],"sourcesContent":["export {\n ControllerNames,\n ControllerTypes\n} from '~/src/pages/controller-types.js'\n\nexport { PageTypes } from '~/src/pages/page-types.js'\n\nexport {\n controllerNameFromPath,\n getPageDefaults,\n hasComponents,\n hasFormComponents,\n hasSection,\n hasNext,\n isControllerName,\n isLinkablePage,\n isQuestionPage\n} from '~/src/pages/helpers.js'\n\nexport { ControllerPath, ControllerType } from '~/src/pages/enums.js'\n"],"mappings":"AAAA,SACEA,eAAe,EACfC,eAAe;AAGjB,SAASC,SAAS;AAElB,SACEC,sBAAsB,EACtBC,eAAe,EACfC,aAAa,EACbC,iBAAiB,EACjBC,UAAU,EACVC,OAAO,EACPC,gBAAgB,EAChBC,cAAc,EACdC,cAAc;AAGhB,SAASC,cAAc,EAAEC,cAAc","ignoreList":[]}
@@ -25,19 +25,12 @@ export const PageTypes = Object.freeze([{
25
25
  next: [],
26
26
  components: []
27
27
  }, {
28
- title: 'File upload page',
29
- path: '/file-upload-page',
30
- controller: ControllerType.FileUpload,
31
- section: undefined,
32
- next: [],
33
- components: []
34
- }, {
35
- title: 'Check your answers',
28
+ title: 'Summary page',
36
29
  path: ControllerPath.Summary,
37
30
  controller: ControllerType.Summary,
38
31
  section: undefined
39
32
  }, {
40
- title: 'Form submitted',
33
+ title: 'Status page',
41
34
  path: ControllerPath.Status,
42
35
  controller: ControllerType.Status,
43
36
  section: undefined
@@ -1 +1 @@
1
- {"version":3,"file":"page-types.js","names":["ControllerType","ControllerPath","PageTypes","Object","freeze","title","path","Start","controller","section","undefined","next","components","Page","FileUpload","Summary","Status"],"sources":["../../../src/pages/page-types.ts"],"sourcesContent":["import { type Page } from '~/src/form/form-definition/types.js'\nimport { ControllerType, ControllerPath } from '~/src/pages/enums.js'\n\n/**\n * Defaults for creating new pages\n */\nexport const PageTypes: readonly Page[] = Object.freeze([\n {\n title: 'Start page',\n path: ControllerPath.Start,\n controller: ControllerType.Start,\n section: undefined,\n next: [],\n components: []\n },\n {\n title: 'Question page',\n path: '/question-page',\n controller: ControllerType.Page,\n section: undefined,\n next: [],\n components: []\n },\n {\n title: 'File upload page',\n path: '/file-upload-page',\n controller: ControllerType.FileUpload,\n section: undefined,\n next: [],\n components: []\n },\n {\n title: 'File upload page',\n path: '/file-upload-page',\n controller: ControllerType.FileUpload,\n section: undefined,\n next: [],\n components: []\n },\n {\n title: 'Check your answers',\n path: ControllerPath.Summary,\n controller: ControllerType.Summary,\n section: undefined\n },\n {\n title: 'Form submitted',\n path: ControllerPath.Status,\n controller: ControllerType.Status,\n section: undefined\n }\n])\n"],"mappings":"AACA,SAASA,cAAc,EAAEC,cAAc;;AAEvC;AACA;AACA;AACA,OAAO,MAAMC,SAA0B,GAAGC,MAAM,CAACC,MAAM,CAAC,CACtD;EACEC,KAAK,EAAE,YAAY;EACnBC,IAAI,EAAEL,cAAc,CAACM,KAAK;EAC1BC,UAAU,EAAER,cAAc,CAACO,KAAK;EAChCE,OAAO,EAAEC,SAAS;EAClBC,IAAI,EAAE,EAAE;EACRC,UAAU,EAAE;AACd,CAAC,EACD;EACEP,KAAK,EAAE,eAAe;EACtBC,IAAI,EAAE,gBAAgB;EACtBE,UAAU,EAAER,cAAc,CAACa,IAAI;EAC/BJ,OAAO,EAAEC,SAAS;EAClBC,IAAI,EAAE,EAAE;EACRC,UAAU,EAAE;AACd,CAAC,EACD;EACEP,KAAK,EAAE,kBAAkB;EACzBC,IAAI,EAAE,mBAAmB;EACzBE,UAAU,EAAER,cAAc,CAACc,UAAU;EACrCL,OAAO,EAAEC,SAAS;EAClBC,IAAI,EAAE,EAAE;EACRC,UAAU,EAAE;AACd,CAAC,EACD;EACEP,KAAK,EAAE,kBAAkB;EACzBC,IAAI,EAAE,mBAAmB;EACzBE,UAAU,EAAER,cAAc,CAACc,UAAU;EACrCL,OAAO,EAAEC,SAAS;EAClBC,IAAI,EAAE,EAAE;EACRC,UAAU,EAAE;AACd,CAAC,EACD;EACEP,KAAK,EAAE,oBAAoB;EAC3BC,IAAI,EAAEL,cAAc,CAACc,OAAO;EAC5BP,UAAU,EAAER,cAAc,CAACe,OAAO;EAClCN,OAAO,EAAEC;AACX,CAAC,EACD;EACEL,KAAK,EAAE,gBAAgB;EACvBC,IAAI,EAAEL,cAAc,CAACe,MAAM;EAC3BR,UAAU,EAAER,cAAc,CAACgB,MAAM;EACjCP,OAAO,EAAEC;AACX,CAAC,CACF,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"page-types.js","names":["ControllerType","ControllerPath","PageTypes","Object","freeze","title","path","Start","controller","section","undefined","next","components","Page","FileUpload","Summary","Status"],"sources":["../../../src/pages/page-types.ts"],"sourcesContent":["import { type Page } from '~/src/form/form-definition/types.js'\nimport { ControllerType, ControllerPath } from '~/src/pages/enums.js'\n\n/**\n * Defaults for creating new pages\n */\nexport const PageTypes: readonly Page[] = Object.freeze([\n {\n title: 'Start page',\n path: ControllerPath.Start,\n controller: ControllerType.Start,\n section: undefined,\n next: [],\n components: []\n },\n {\n title: 'Question page',\n path: '/question-page',\n controller: ControllerType.Page,\n section: undefined,\n next: [],\n components: []\n },\n {\n title: 'File upload page',\n path: '/file-upload-page',\n controller: ControllerType.FileUpload,\n section: undefined,\n next: [],\n components: []\n },\n {\n title: 'Summary page',\n path: ControllerPath.Summary,\n controller: ControllerType.Summary,\n section: undefined\n },\n {\n title: 'Status page',\n path: ControllerPath.Status,\n controller: ControllerType.Status,\n section: undefined\n }\n])\n"],"mappings":"AACA,SAASA,cAAc,EAAEC,cAAc;;AAEvC;AACA;AACA;AACA,OAAO,MAAMC,SAA0B,GAAGC,MAAM,CAACC,MAAM,CAAC,CACtD;EACEC,KAAK,EAAE,YAAY;EACnBC,IAAI,EAAEL,cAAc,CAACM,KAAK;EAC1BC,UAAU,EAAER,cAAc,CAACO,KAAK;EAChCE,OAAO,EAAEC,SAAS;EAClBC,IAAI,EAAE,EAAE;EACRC,UAAU,EAAE;AACd,CAAC,EACD;EACEP,KAAK,EAAE,eAAe;EACtBC,IAAI,EAAE,gBAAgB;EACtBE,UAAU,EAAER,cAAc,CAACa,IAAI;EAC/BJ,OAAO,EAAEC,SAAS;EAClBC,IAAI,EAAE,EAAE;EACRC,UAAU,EAAE;AACd,CAAC,EACD;EACEP,KAAK,EAAE,kBAAkB;EACzBC,IAAI,EAAE,mBAAmB;EACzBE,UAAU,EAAER,cAAc,CAACc,UAAU;EACrCL,OAAO,EAAEC,SAAS;EAClBC,IAAI,EAAE,EAAE;EACRC,UAAU,EAAE;AACd,CAAC,EACD;EACEP,KAAK,EAAE,cAAc;EACrBC,IAAI,EAAEL,cAAc,CAACc,OAAO;EAC5BP,UAAU,EAAER,cAAc,CAACe,OAAO;EAClCN,OAAO,EAAEC;AACX,CAAC,EACD;EACEL,KAAK,EAAE,aAAa;EACpBC,IAAI,EAAEL,cAAc,CAACe,MAAM;EAC3BR,UAAU,EAAER,cAAc,CAACgB,MAAM;EACjCP,OAAO,EAAEC;AACX,CAAC,CACF,CAAC","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"component-types.d.ts","sourceRoot":"","sources":["../../../src/components/component-types.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAE7D;;GAEG;AACH,eAAO,MAAM,cAAc,EAAE,SAAS,YAAY,EA8HhD,CAAA"}
1
+ {"version":3,"file":"component-types.d.ts","sourceRoot":"","sources":["../../../src/components/component-types.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAE7D;;GAEG;AACH,eAAO,MAAM,cAAc,EAAE,SAAS,YAAY,EAqIhD,CAAA"}
@@ -1,9 +1,9 @@
1
1
  import { ComponentType } from '../components/enums.js';
2
- import { type ComponentDef, type ConditionalComponentsDef, type ConditionalComponentType, type ContentComponentsDef, type FormComponentsDef, type HtmlComponent, type InsetTextComponent, type ListComponent, type ListComponentsDef, type SelectionComponentsDef } from '../components/types.js';
2
+ import { type ComponentDef, type ConditionalComponentsDef, type ConditionalComponentType, type ContentComponentsDef, type FormComponentsDef, type HtmlComponent, type InputFieldsComponentsDef, type InsetTextComponent, type ListComponent, type ListComponentsDef, type SelectionComponentsDef } from '../components/types.js';
3
3
  /**
4
4
  * Return component defaults by type
5
5
  */
6
- export declare function getComponentDefaults(component?: Partial<ComponentDef>): ComponentDef | undefined;
6
+ export declare function getComponentDefaults<FieldType extends ComponentDef>(component?: Pick<FieldType, 'type'>): FieldType;
7
7
  /**
8
8
  * Filter known components with support for conditions
9
9
  */
@@ -20,6 +20,7 @@ export declare function hasContentField(component?: Partial<ComponentDef>): comp
20
20
  export declare function isContentType(type?: ComponentType): type is ContentComponentsDef['type'];
21
21
  /**
22
22
  * Filter known components with form fields
23
+ * (includes input fields and selection fields)
23
24
  */
24
25
  export declare function hasFormField(component?: Partial<ComponentDef>): component is FormComponentsDef;
25
26
  export declare function isFormType(type?: ComponentType): type is FormComponentsDef['type'];
@@ -29,7 +30,13 @@ export declare function isFormType(type?: ComponentType): type is FormComponents
29
30
  export declare function hasListField(component?: Partial<ComponentDef>): component is ListComponentsDef;
30
31
  export declare function isListType(type?: ComponentType): type is ListComponentsDef['type'];
31
32
  /**
32
- * Filter known components with selection fields
33
+ * Filter known form components with input fields
34
+ * (excludes content and selection fields)
35
+ */
36
+ export declare function hasInputField(component?: Partial<ComponentDef>): component is InputFieldsComponentsDef;
37
+ /**
38
+ * Filter known form components with selection fields
39
+ * (excludes content and input fields)
33
40
  */
34
41
  export declare function hasSelectionFields(component?: Partial<ComponentDef>): component is SelectionComponentsDef;
35
42
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/components/helpers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AACzD,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,wBAAwB,EAC7B,KAAK,wBAAwB,EAC7B,KAAK,oBAAoB,EACzB,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,kBAAkB,EACvB,KAAK,aAAa,EAClB,KAAK,iBAAiB,EACtB,KAAK,sBAAsB,EAC5B,MAAM,2BAA2B,CAAA;AAElC;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,4BAQrE;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,SAAS,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,GAChC,SAAS,IAAI,wBAAwB,CAEvC;AAED,wBAAgB,iBAAiB,CAC/B,IAAI,CAAC,EAAE,aAAa,GACnB,IAAI,IAAI,wBAAwB,CAkBlC;AAED;;GAEG;AACH,wBAAgB,UAAU,CACxB,SAAS,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,GAChC,SAAS,IAAI,oBAAoB,CAEnC;AAED;;GAEG;AACH,wBAAgB,eAAe,CAC7B,SAAS,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,GAChC,SAAS,IAAI,OAAO,CAAC,oBAAoB,EAAE,aAAa,CAAC,CA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;AACH,wBAAgB,aAAa,CAC3B,SAAS,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,GAChC,SAAS,IAAI,wBAAwB,CAEvC;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,SAAS,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,GAChC,SAAS,IAAI,sBAAsB,CAUrC;AAED;;GAEG;AACH,wBAAgB,QAAQ,CACtB,SAAS,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,GAChC,SAAS,IAAI,OAAO,CAAC,YAAY,EAAE,kBAAkB,GAAG,aAAa,CAAC,CAGxE;AAED;;GAEG;AACH,wBAAgB,OAAO,CACrB,SAAS,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,GAChC,SAAS,IAAI,iBAAiB,GAAG,aAAa,CAEhD"}
@@ -1,4 +1,4 @@
1
1
  export { ComponentTypes } from '../components/component-types.js';
2
- export { getComponentDefaults, hasConditionSupport, hasContent, hasContentField, hasFormField, hasHint, hasListField, hasSelectionFields, hasTitle, isConditionalType, isContentType, isFormType, isListType } from '../components/helpers.js';
2
+ export { getComponentDefaults, hasConditionSupport, hasContent, hasContentField, hasFormField, hasHint, hasListField, hasInputField, hasSelectionFields, hasTitle, isConditionalType, isContentType, isFormType, isListType } from '../components/helpers.js';
3
3
  export { ComponentType } from '../components/enums.js';
4
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAA;AACpE,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,UAAU,EACV,eAAe,EACf,YAAY,EACZ,OAAO,EACP,YAAY,EACZ,kBAAkB,EAClB,QAAQ,EACR,iBAAiB,EACjB,aAAa,EACb,UAAU,EACV,UAAU,EACX,MAAM,6BAA6B,CAAA;AAEpC,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAA;AACpE,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,UAAU,EACV,eAAe,EACf,YAAY,EACZ,OAAO,EACP,YAAY,EACZ,aAAa,EACb,kBAAkB,EAClB,QAAQ,EACR,iBAAiB,EACjB,aAAa,EACb,UAAU,EACV,UAAU,EACX,MAAM,6BAA6B,CAAA;AAEpC,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA"}
@@ -11,28 +11,35 @@ export interface PageBase {
11
11
  path: string;
12
12
  }
13
13
  export interface PageStart extends PageBase {
14
+ path: ControllerPath.Start | string;
14
15
  controller: ControllerType.Start | ControllerType.Home;
15
16
  section?: string | undefined;
16
17
  next: Link[];
17
18
  components: ComponentDef[];
18
19
  }
19
20
  export interface PageQuestion extends PageBase {
20
- controller?: ControllerType.Page | ControllerType.FileUpload;
21
+ controller?: ControllerType.Page;
22
+ section?: string | undefined;
23
+ next: Link[];
24
+ components: ComponentDef[];
25
+ }
26
+ export interface PageFileUpload extends PageBase {
27
+ controller?: ControllerType.FileUpload;
21
28
  section?: string | undefined;
22
29
  next: Link[];
23
30
  components: ComponentDef[];
24
31
  }
25
32
  export interface PageSummary extends PageBase {
26
- path: ControllerPath.Summary;
33
+ path: ControllerPath.Summary | string;
27
34
  controller: ControllerType.Summary;
28
35
  section?: undefined;
29
36
  }
30
37
  export interface PageStatus extends PageBase {
31
- path: ControllerPath.Status;
38
+ path: ControllerPath.Status | string;
32
39
  controller: ControllerType.Status;
33
40
  section?: undefined;
34
41
  }
35
- export type Page = PageStart | PageQuestion | PageSummary | PageStatus;
42
+ export type Page = PageStart | PageQuestion | PageFileUpload | PageSummary | PageStatus;
36
43
  export type RequiredField<Type extends Partial<object>, KeyType extends keyof Type> = Omit<Type, KeyType> & Required<{
37
44
  [Key in Ke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,KAAK,EAAE,IAAI,EAAE,CAAA;IACb,UAAU,EAAE,gBAAgB,EAAE,CAAA;IAC9B,KAAK,EAAE,IAAI,EAAE,CAAA;IACb,QAAQ,EAAE,OAAO,EAAE,CAAA;IACnB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,QAAQ,CAAA;IACnB,WAAW,CAAC,EAAE,WAAW,CAAA;IACzB,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAClC,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB"}
@@ -1,24 +1,30 @@
1
1
  import { type ComponentDef } from '../components/types.js';
2
- import { type Link, type Page, type PageQuestion, type PageStart, type RequiredField } from '../form/form-definition/types.js';
2
+ import { type Link, type Page, type PageFileUpload, type PageQuestion, type PageStart, type RequiredField } from '../form/form-definition/types.js';
3
3
  import { ControllerType } from '../pages/enums.js';
4
4
  /**
5
5
  * Return component defaults by type
6
6
  */
7
- export declare function getPageDefaults(page: Pick<Page, 'controller'>): Page;
7
+ export declare function getPageDefaults<PageType extends Page>(page: Pick<PageType, 'controller'>): PageType;
8
8
  /**
9
9
  * Check page has components
10
10
  */
11
11
  export declare function hasComponents(page?: Partial<Page>): page is Extract<Page, {
12
12
  components: ComponentDef[];
13
13
  }>;
14
+ /**
15
+ * Check page has form components
16
+ */
17
+ export declare function hasFormComponents(page?: Partial<Page>): page is Extract<Page, {
18
+ components: ComponentDef[];
19
+ }>;
14
20
  /**
15
21
  * Check page has sections
16
22
  */
17
- export declare function hasSection(page?: Partial<Page>): page is RequiredField<PageStart | PageQuestion, 'section'>;
23
+ export declare function hasSection(page: Partial<Page>): page is RequiredField<PageStart, 'section'> | RequiredField<PageQuestion, 'section'> | RequiredField<PageFileUpload, 'section'>;
18
24
  /**
19
25
  * Check page has next link
20
26
  */
21
- export declare function hasNext(page?: Partial<Page>): page is PageStart | PageQuestion;
27
+ export declare function hasNext(page?: Partial<Page>): page is PageStart | PageQuestion | PageFileUpload;
22
28
  /**
23
29
  * Check for known page controller names
24
30
  */
@@ -37,5 +43,5 @@ export declare function isQuestionPage(page?: Partial<Page>): page is PageQuesti
37
43
  * Check and optionally replace legacy path with controller name
38
44
  * @param {string} [nameOrPath] - Controller name or legacy controller path
39
45
  */
40
- export declare function controllerNameFromPath(nameOrPath?: ControllerType | string): ControllerType;
46
+ export declare function controllerNameFromPath(nameOrPath?: ControllerType | string): ControllerType | undefined;
41
47
  //# sourceMappingURL=helpers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/pages/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAC7D,OAAO,EACL,KAAK,IAAI,EACT,KAAK,IAAI,EACT,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,KAAK,aAAa,EACnB,MAAM,qCAAqC,CAAA;AAK5C,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAGrD;;GAEG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,YAAY,CAAC,QAY7D;AAED;;GAEG;AACH,wBAAgB,aAAa,CAC3B,IAAI,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,GACnB,IAAI,IAAI,OAAO,CAAC,IAAI,EAAE;IAAE,UAAU,EAAE,YAAY,EAAE,CAAA;CAAE,CAAC,CAEvD;AAED;;GAEG;AACH,wBAAgB,UAAU,CACxB,IAAI,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,GACnB,IAAI,IAAI,aAAa,CAAC,SAAS,GAAG,YAAY,EAAE,SAAS,CAAC,CAE5D;AAED;;GAEG;AACH,wBAAgB,OAAO,CAAC,IAAI,CAAC,EAAE,OA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CAAC,GACnB,IAAI,IAAI,OAAO,CAAC,IAAI,EAAE;IAAE,UAAU,EAAE,YAAY,EAAE,CAAA;CAAE,CAAC,CAEvD;AAED;;GAEG;AACH,wBAAgB,UAAU,CACxB,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,GAClB,IAAI,IACH,aAAa,CAAC,SAAS,EAAE,SAAS,CAAC,GACnC,aAAa,CAAC,YAAY,EAAE,SAAS,CAAC,GACtC,aAAa,CAAC,cAAc,EAAE,SAAS,CAAC,CAE3C;AAED;;GAEG;AACH,wBAAgB,OAAO,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,qDAE3C;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,UAAU,CAAC,EAAE,cAAc,GAAG,MAAM,GACnC,UAAU,IAAI,cAAc,CAE9B;AAED;;GAEG;AACH,wBAAgB,cAAc,CAC5B,IAAI,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,GACnB,IAAI,IAAI,OAAO,CAAC,IAAI,EAAE;IAAE,IAAI,EAAE,IAAI,EAAE,CAAA;CAAE,CAAC,CAazC;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,IAAI,YAAY,CAQzE;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,UAAU,CAAC,EAAE,cAAc,GAAG,MAAM,8BAO1E"}
@@ -1,5 +1,5 @@
1
1
  export { ControllerNames, ControllerTypes } from '../pages/controller-types.js';
2
2
  export { PageTypes } from '../pages/page-types.js';
3
- export { controllerNameFromPath, getPageDefaults, hasComponents, hasSection, hasNext, isControllerName, isLinkablePage, isQuestionPage } from '../pages/helpers.js';
3
+ export { controllerNameFromPath, getPageDefaults, hasComponents, hasFormComponents, hasSection, hasNext, isControllerName, isLinkablePage, isQuestionPage } from '../pages/helpers.js';
4
4
  export { ControllerPath, ControllerType } from '../pages/enums.js';
5
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/pages/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,eAAe,EAChB,MAAM,iCAAiC,CAAA;AAExC,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AAErD,OAAO,EACL,sBAAsB,EACtB,eAAe,EACf,aAAa,EACb,UAAU,EACV,OAAO,EACP,gBAAgB,EAChB,cAAc,EACd,cAAc,EACf,MAAM,wBAAwB,CAAA;AAE/B,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/pages/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,eAAe,EAChB,MAAM,iCAAiC,CAAA;AAExC,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AAErD,OAAO,EACL,sBAAsB,EACtB,eAAe,EACf,aAAa,EACb,iBAAiB,EACjB,UAAU,EACV,OAAO,EACP,gBAAgB,EAChB,cAAc,EACd,cAAc,EACf,MAAM,wBAAwB,CAAA;AAE/B,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"page-types.d.ts","sourceRoot":"","sources":["../../../src/pages/page-types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,qCAAqC,CAAA;AAG/D;;GAEG;AACH,eAAO,MAAM,SAAS,EAAE,SAAS,IAAI,EA6CnC,CAAA"}
1
+ {"version":3,"file":"page-types.d.ts","sourceRoot":"","sources":["../../../src/pages/page-types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,qCAAqC,CAAA;AAG/D;;GAEG;AACH,eAAO,MAAM,SAAS,EAAE,SAAS,IAAI,EAqCnC,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defra/forms-model",
3
- "version": "3.0.313",
3
+ "version": "3.0.315",
4
4
  "description": "A hapi plugin providing the model for Defra forms",
5
5
  "homepage": "https://github.com/DEFRA/forms-designer/tree/main/model#readme",
6
6
  "repository": {
@@ -103,6 +103,13 @@ export const ComponentTypes: readonly ComponentDef[] = Object.freeze([
103
103
  hint: 'For example, ‘name@example.com’',
104
104
  options: {}
105
105
  },
106
+ {
107
+ name: 'FileUploadField',
108
+ title: 'File upload field',
109
+ type: ComponentType.FileUploadField,
110
+ options: {},
111
+ schema: {}
112
+ },
106
113
  {
107
114
  name: 'Html',
108
115
  title: 'Html',
@@ -7,6 +7,7 @@ import {
7
7
  type ContentComponentsDef,
8
8
  type FormComponentsDef,
9
9
  type HtmlComponent,
10
+ type InputFieldsComponentsDef,
10
11
  type InsetTextComponent,
11
12
  type ListComponent,
12
13
  type ListComponentsDef,
@@ -16,14 +17,18 @@ import {
16
17
  /**
17
18
  * Return component defaults by type
18
19
  */
19
- export function getComponentDefaults(component?: Partial<ComponentDef>) {
20
- if (!component?.type) {
21
- return
20
+ export function getComponentDefaults<FieldType extends ComponentDef>(
21
+ component?: Pick<FieldType, 'type'>
22
+ ) {
23
+ const defaults = ComponentTypes.find(({ type }) => type === component?.type)
24
+
25
+ if (!defaults) {
26
+ throw new Error(
27
+ `Defaults not found for component type '${component?.type}'`
28
+ )
22
29
  }
23
30
 
24
- return structuredClone(
25
- ComponentTypes.find(({ type }) => type === component.type)
26
- )
31
+ return structuredClone(defaults) as FieldType
27
32
  }
28
33
 
29
34
  /**
@@ -91,6 +96,7 @@ export function isContentType(
91
96
 
92
97
  /**
93
98
  * Filter known components with form fields
99
+ * (includes input fields and selection fields)
94
100
  */
95
101
  export function hasFormField(
96
102
  component?: Partial<ComponentDef>
@@ -128,7 +134,18 @@ export function isListType(
128
134
  }
129
135
 
130
136
  /**
131
- * Filter known components with selection fields
137
+ * Filter known form components with input fields
138
+ * (excludes content and selection fields)
139
+ */
140
+ export function hasInputField(
141
+ component?: Partial<ComponentDef>
142
+ ): component is InputFieldsComponentsDef {
143
+ return hasFormField(component) && !hasSelectionFields(component)
144
+ }
145
+
146
+ /**
147
+ * Filter known form components with selection fields
148
+ * (excludes content and input fields)
132
149
  */
133
150
  export function hasSelectionFields(
134
151
  component?: Partial<ComponentDef>
@@ -7,6 +7,7 @@ export {
7
7
  hasFormField,
8
8
  hasHint,
9
9
  hasListField,
10
+ hasInputField,
10
11
  hasSelectionFields,
11
12
  hasTitle,
12
13
  isConditionalType,
@@ -15,6 +15,7 @@ export interface PageBase {
15
15
  }
16
16
 
17
17
  export interface PageStart extends PageBase {
18
+ path: ControllerPath.Start | string
18
19
  controller: ControllerType.Start | ControllerType.Home
19
20
  section?: string | undefined
20
21
  next: Link[]
@@ -22,25 +23,37 @@ export interface PageStart extends PageBase {
22
23
  }
23
24
 
24
25
  export interface PageQuestion extends PageBase {
25
- controller?: ControllerType.Page | ControllerType.FileUpload
26
+ controller?: ControllerType.Page
27
+ section?: string | undefined
28
+ next: Link[]
29
+ components: ComponentDef[]
30
+ }
31
+
32
+ export interface PageFileUpload extends PageBase {
33
+ controller?: ControllerType.FileUpload
26
34
  section?: string | undefined
27
35
  next: Link[]
28
36
  components: ComponentDef[]
29
37
  }
30
38
 
31
39
  export interface PageSummary extends PageBase {
32
- path: ControllerPath.Summary
40
+ path: ControllerPath.Summary | string
33
41
  controller: ControllerType.Summary
34
42
  section?: undefined
35
43
  }
36
44
 
37
45
  export interface PageStatus extends PageBase {
38
- path: ControllerPath.Status
46
+ path: ControllerPath.Status | string
39
47
  controller: ControllerType.Status
40
48
  section?: undefined
41
49
  }
42
50
 
43
- export type Page = PageStart | PageQuestion | PageSummary | PageStatus
51
+ export type Page =
52
+ | PageStart
53
+ | PageQuestion
54
+ | PageFileUpload
55
+ | PageSummary
56
+ | PageStatus
44
57
 
45
58
  export type RequiredField<
46
59
  Type extends Partial<object>,
@@ -2,6 +2,7 @@ import { type ComponentDef } from '~/src/components/types.js'
2
2
  import {
3
3
  type Link,
4
4
  type Page,
5
+ type PageFileUpload,
5
6
  type PageQuestion,
6
7
  type PageStart,
7
8
  type RequiredField
@@ -16,18 +17,22 @@ import { PageTypes } from '~/src/pages/page-types.js'
16
17
  /**
17
18
  * Return component defaults by type
18
19
  */
19
- export function getPageDefaults(page: Pick<Page, 'controller'>) {
20
- const controller = controllerNameFromPath(page.controller)
20
+ export function getPageDefaults<PageType extends Page>(
21
+ page: Pick<PageType, 'controller'>
22
+ ) {
23
+ const controller = controllerNameFromPath(
24
+ page.controller ?? ControllerType.Page
25
+ )
21
26
 
22
27
  const defaults = PageTypes.find(
23
28
  (pageType) => pageType.controller === controller
24
29
  )
25
30
 
26
31
  if (!defaults) {
27
- throw new Error(`Defaults not found for ${page.controller}`)
32
+ throw new Error(`Defaults not found for page type '${page.controller}'`)
28
33
  }
29
34
 
30
- return structuredClone(defaults)
35
+ return structuredClone(defaults) as PageType
31
36
  }
32
37
 
33
38
  /**
@@ -39,12 +44,24 @@ export function hasComponents(
39
44
  return isLinkablePage(page) && Array.isArray(page.components)
40
45
  }
41
46
 
47
+ /**
48
+ * Check page has form components
49
+ */
50
+ export function hasFormComponents(
51
+ page?: Partial<Page>
52
+ ): page is Extract<Page, { components: ComponentDef[] }> {
53
+ return isLinkablePage(page) && Array.isArray(page.components)
54
+ }
55
+
42
56
  /**
43
57
  * Check page has sections
44
58
  */
45
59
  export function hasSection(
46
- page?: Partial<Page>
47
- ): page is RequiredField<PageStart | PageQuestion, 'section'> {
60
+ page: Partial<Page>
61
+ ): page is
62
+ | RequiredField<PageStart, 'section'>
63
+ | RequiredField<PageQuestion, 'section'>
64
+ | RequiredField<PageFileUpload, 'section'> {
48
65
  return isLinkablePage(page) && typeof page.section === 'string'
49
66
  }
50
67
 
@@ -77,6 +94,7 @@ export function isLinkablePage(
77
94
  const controller = controllerNameFromPath(page.controller)
78
95
 
79
96
  return (
97
+ !controller ||
80
98
  controller === ControllerType.Start ||
81
99
  controller === ControllerType.Page ||
82
100
  controller === ControllerType.FileUpload
@@ -90,6 +108,7 @@ export function isQuestionPage(page?: Partial<Page>): page is PageQuestion {
90
108
  const controller = controllerNameFromPath(page?.controller)
91
109
 
92
110
  return (
111
+ !controller ||
93
112
  controller === ControllerType.Page ||
94
113
  controller === ControllerType.FileUpload
95
114
  )
@@ -105,5 +124,5 @@ export function controllerNameFromPath(nameOrPath?: ControllerType | string) {
105
124
  }
106
125
 
107
126
  const options = ControllerTypes.find(({ path }) => path === nameOrPath)
108
- return options?.name ?? ControllerType.Page
127
+ return options?.name
109
128
  }
@@ -9,6 +9,7 @@ export {
9
9
  controllerNameFromPath,
10
10
  getPageDefaults,
11
11
  hasComponents,
12
+ hasFormComponents,
12
13
  hasSection,
13
14
  hasNext,
14
15
  isControllerName,
@@ -30,21 +30,13 @@ export const PageTypes: readonly Page[] = Object.freeze([
30
30
  components: []
31
31
  },
32
32
  {
33
- title: 'File upload page',
34
- path: '/file-upload-page',
35
- controller: ControllerType.FileUpload,
36
- section: undefined,
37
- next: [],
38
- components: []
39
- },
40
- {
41
- title: 'Check your answers',
33
+ title: 'Summary page',
42
34
  path: ControllerPath.Summary,
43
35
  controller: ControllerType.Summary,
44
36
  section: undefined
45
37
  },
46
38
  {
47
- title: 'Form submitted',
39
+ title: 'Status page',
48
40
  path: ControllerPath.Status,
49
41
  controller: ControllerType.Status,
50
42
  section: undefined