@defra/forms-model 3.0.299 → 3.0.301
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.
- package/dist/module/components/component-types.js +2 -2
- package/dist/module/components/component-types.js.map +1 -1
- package/dist/module/components/helpers.js +2 -2
- package/dist/module/components/helpers.js.map +1 -1
- package/dist/module/components/types.js.map +1 -1
- package/dist/module/form/form-definition/types.js.map +1 -1
- package/dist/module/form/utils/find-start-page.js +3 -1
- package/dist/module/form/utils/find-start-page.js.map +1 -1
- package/dist/module/index.js +1 -0
- package/dist/module/index.js.map +1 -1
- package/dist/module/pages/controller-types.js +24 -0
- package/dist/module/pages/controller-types.js.map +1 -0
- package/dist/module/pages/enums.js +16 -0
- package/dist/module/pages/enums.js.map +1 -0
- package/dist/module/pages/helpers.js +77 -0
- package/dist/module/pages/helpers.js.map +1 -0
- package/dist/module/pages/index.js +5 -0
- package/dist/module/pages/index.js.map +1 -0
- package/dist/module/pages/page-types.js +45 -0
- package/dist/module/pages/page-types.js.map +1 -0
- package/dist/types/components/component-types.d.ts +1 -1
- package/dist/types/components/component-types.d.ts.map +1 -1
- package/dist/types/components/helpers.d.ts.map +1 -1
- package/dist/types/components/types.d.ts +2 -2
- package/dist/types/components/types.d.ts.map +1 -1
- package/dist/types/form/form-definition/types.d.ts +23 -8
- package/dist/types/form/form-definition/types.d.ts.map +1 -1
- package/dist/types/form/utils/find-start-page.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/pages/controller-types.d.ts +7 -0
- package/dist/types/pages/controller-types.d.ts.map +1 -0
- package/dist/types/pages/enums.d.ts +14 -0
- package/dist/types/pages/enums.d.ts.map +1 -0
- package/dist/types/pages/helpers.d.ts +41 -0
- package/dist/types/pages/helpers.d.ts.map +1 -0
- package/dist/types/pages/index.d.ts +5 -0
- package/dist/types/pages/index.d.ts.map +1 -0
- package/dist/types/pages/page-types.d.ts +6 -0
- package/dist/types/pages/page-types.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/components/component-types.ts +2 -2
- package/src/components/helpers.ts +3 -1
- package/src/components/types.ts +2 -2
- package/src/form/form-definition/types.ts +30 -11
- package/src/form/utils/find-start-page.ts +2 -1
- package/src/index.ts +1 -0
- package/src/pages/controller-types.ts +32 -0
- package/src/pages/enums.ts +14 -0
- package/src/pages/helpers.ts +109 -0
- package/src/pages/index.ts +19 -0
- package/src/pages/page-types.ts +52 -0
@@ -2,7 +2,7 @@ import { ComponentType } from "./enums.js";
|
|
2
2
|
/**
|
3
3
|
* Defaults for creating new components
|
4
4
|
*/
|
5
|
-
export const ComponentTypes = [{
|
5
|
+
export const ComponentTypes = Object.freeze([{
|
6
6
|
name: 'TextField',
|
7
7
|
title: 'Text field',
|
8
8
|
type: ComponentType.TextField,
|
@@ -110,5 +110,5 @@ export const ComponentTypes = [{
|
|
110
110
|
type: ComponentType.List,
|
111
111
|
list: '',
|
112
112
|
options: {}
|
113
|
-
}];
|
113
|
+
}]);
|
114
114
|
//# sourceMappingURL=component-types.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"component-types.js","names":["ComponentType","ComponentTypes","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: ComponentDef[] = [\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,
|
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,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,EAA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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":[]}
|
@@ -7,9 +7,9 @@ export function getComponentDefaults(component) {
|
|
7
7
|
if (!component?.type) {
|
8
8
|
return;
|
9
9
|
}
|
10
|
-
return ComponentTypes.find(({
|
10
|
+
return structuredClone(ComponentTypes.find(({
|
11
11
|
type
|
12
|
-
}) => type === component.type);
|
12
|
+
}) => type === component.type));
|
13
13
|
}
|
14
14
|
|
15
15
|
/**
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"helpers.js","names":["ComponentTypes","ComponentType","getComponentDefaults","component","type","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 ComponentTypes.find(({ type }) => type === component.type)\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,
|
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,EAA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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 +1 @@
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../../../src/components/types.ts"],"sourcesContent":["import { type ComponentType } from '~/src/components/enums.js'\nimport {\n type ListTypeOption,\n type ListTypeContent\n} from '~/src/form/form-definition/types.js'\n\nexport type ConditionalComponentType = Exclude<\n ConditionalComponentsDef['type'],\n ContentComponentsDef\n>\n\n/**\n * Types for Components JSON structure which are expected by engine and turned into actual form input/content/lists\n */\n\ninterface FormFieldBase {\n type: FormComponentsDef['type']\n name: string\n title: string\n hint?: string\n options: {\n required?: boolean\n optionalText?: boolean\n classes?: string\n }\n}\n\ninterface ListFieldBase extends FormFieldBase {\n type:\n | ComponentType.AutocompleteField\n | ComponentType.CheckboxesField\n | ComponentType.RadiosField\n | ComponentType.SelectField\n list: string\n options: FormFieldBase['options'] & {\n type?: ListTypeContent\n }\n}\n\ninterface ContentFieldBase {\n type:\n | ComponentType.Details\n | ComponentType.Html\n | ComponentType.InsetText\n | ComponentType.List\n name: string\n title: string\n}\n\ninterface DateFieldBase {\n type: ComponentType.DatePartsField | ComponentType.MonthYearField\n name: string\n title: string\n hint?: string\n options: {\n required?: boolean\n optionalText?: boolean\n classes?: string\n maxDaysInPast?: number\n maxDaysInFuture?: number\n }\n}\n\n// Text Fields\nexport interface TextFieldComponent extends FormFieldBase {\n type: ComponentType.TextField\n options: FormFieldBase['options'] & {\n autocomplete?: string\n condition?: string\n customValidationMessage?: string\n }\n schema: {\n max?: number\n min?: number\n length?: number\n regex?: string\n }\n}\n\nexport interface EmailAddressFieldComponent extends FormFieldBase {\n type: ComponentType.EmailAddressField\n options: FormFieldBase['options'] & {\n condition?: string\n customValidationMessage?: string\n }\n}\n\nexport interface NumberFieldComponent extends FormFieldBase {\n type: ComponentType.NumberField\n options: FormFieldBase['options'] & {\n prefix?: string\n suffix?: string\n condition?: string\n customValidationMessage?: string\n }\n schema: {\n max?: number\n min?: number\n precision?: number\n }\n}\n\nexport interface TelephoneNumberFieldComponent extends FormFieldBase {\n type: ComponentType.TelephoneNumberField\n options: FormFieldBase['options'] & {\n condition?: string\n customValidationMessage?: string\n }\n}\n\nexport interface FileUploadFieldComponent {\n type: ComponentType.FileUploadField\n name: string\n title: string\n hint?: string\n options: {\n required?: boolean\n classes?: string\n optionalText?: boolean\n accept?: string\n }\n schema: {\n max?: number\n min?: number\n length?: number\n }\n}\n\nexport interface YesNoFieldComponent extends FormFieldBase {\n type: ComponentType.YesNoField\n options: FormFieldBase['options'] & {\n condition?: string\n }\n}\n\nexport interface MultilineTextFieldComponent extends FormFieldBase {\n type: ComponentType.MultilineTextField\n options: FormFieldBase['options'] & {\n condition?: string\n customValidationMessage?: string\n rows?: number\n maxWords?: number\n }\n schema: {\n max?: number\n min?: number\n length?: number\n regex?: string\n }\n}\n\nexport interface UkAddressFieldComponent extends FormFieldBase {\n type: ComponentType.UkAddressField\n options: FormFieldBase['options'] & {\n hideTitle?: boolean\n }\n}\n\n// Date Fields\nexport interface
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../../src/components/types.ts"],"sourcesContent":["import { type ComponentType } from '~/src/components/enums.js'\nimport {\n type ListTypeOption,\n type ListTypeContent\n} from '~/src/form/form-definition/types.js'\n\nexport type ConditionalComponentType = Exclude<\n ConditionalComponentsDef['type'],\n ContentComponentsDef\n>\n\n/**\n * Types for Components JSON structure which are expected by engine and turned into actual form input/content/lists\n */\n\ninterface FormFieldBase {\n type: FormComponentsDef['type']\n name: string\n title: string\n hint?: string\n options: {\n required?: boolean\n optionalText?: boolean\n classes?: string\n }\n}\n\ninterface ListFieldBase extends FormFieldBase {\n type:\n | ComponentType.AutocompleteField\n | ComponentType.CheckboxesField\n | ComponentType.RadiosField\n | ComponentType.SelectField\n list: string\n options: FormFieldBase['options'] & {\n type?: ListTypeContent\n }\n}\n\ninterface ContentFieldBase {\n type:\n | ComponentType.Details\n | ComponentType.Html\n | ComponentType.InsetText\n | ComponentType.List\n name: string\n title: string\n}\n\ninterface DateFieldBase {\n type: ComponentType.DatePartsField | ComponentType.MonthYearField\n name: string\n title: string\n hint?: string\n options: {\n required?: boolean\n optionalText?: boolean\n classes?: string\n maxDaysInPast?: number\n maxDaysInFuture?: number\n }\n}\n\n// Text Fields\nexport interface TextFieldComponent extends FormFieldBase {\n type: ComponentType.TextField\n options: FormFieldBase['options'] & {\n autocomplete?: string\n condition?: string\n customValidationMessage?: string\n }\n schema: {\n max?: number\n min?: number\n length?: number\n regex?: string\n }\n}\n\nexport interface EmailAddressFieldComponent extends FormFieldBase {\n type: ComponentType.EmailAddressField\n options: FormFieldBase['options'] & {\n condition?: string\n customValidationMessage?: string\n }\n}\n\nexport interface NumberFieldComponent extends FormFieldBase {\n type: ComponentType.NumberField\n options: FormFieldBase['options'] & {\n prefix?: string\n suffix?: string\n condition?: string\n customValidationMessage?: string\n }\n schema: {\n max?: number\n min?: number\n precision?: number\n }\n}\n\nexport interface TelephoneNumberFieldComponent extends FormFieldBase {\n type: ComponentType.TelephoneNumberField\n options: FormFieldBase['options'] & {\n condition?: string\n customValidationMessage?: string\n }\n}\n\nexport interface FileUploadFieldComponent {\n type: ComponentType.FileUploadField\n name: string\n title: string\n hint?: string\n options: {\n required?: boolean\n classes?: string\n optionalText?: boolean\n accept?: string\n }\n schema: {\n max?: number\n min?: number\n length?: number\n }\n}\n\nexport interface YesNoFieldComponent extends FormFieldBase {\n type: ComponentType.YesNoField\n options: FormFieldBase['options'] & {\n condition?: string\n }\n}\n\nexport interface MultilineTextFieldComponent extends FormFieldBase {\n type: ComponentType.MultilineTextField\n options: FormFieldBase['options'] & {\n condition?: string\n customValidationMessage?: string\n rows?: number\n maxWords?: number\n }\n schema: {\n max?: number\n min?: number\n length?: number\n regex?: string\n }\n}\n\nexport interface UkAddressFieldComponent extends FormFieldBase {\n type: ComponentType.UkAddressField\n options: FormFieldBase['options'] & {\n hideTitle?: boolean\n }\n}\n\n// Date Fields\nexport interface DatePartsFieldComponent extends DateFieldBase {\n type: ComponentType.DatePartsField\n options: DateFieldBase['options'] & {\n condition?: string\n }\n}\n\nexport interface MonthYearFieldComponent extends DateFieldBase {\n type: ComponentType.MonthYearField\n options: DateFieldBase['options'] & {\n customValidationMessage?: string\n }\n}\n\n// Content Fields\nexport interface DetailsComponent extends ContentFieldBase {\n type: ComponentType.Details\n content: string\n options: {\n condition?: string\n }\n}\n\nexport interface HtmlComponent extends ContentFieldBase {\n type: ComponentType.Html\n content: string\n options: {\n condition?: string\n }\n}\n\nexport interface InsetTextComponent extends ContentFieldBase {\n type: ComponentType.InsetText\n content: string\n}\n\nexport interface ListComponent extends ContentFieldBase {\n type: ComponentType.List\n hint?: string\n list: string\n options: {\n type?: ListTypeOption\n classes?: string\n hideTitle?: boolean\n bold?: boolean\n }\n}\n\nexport interface AutocompleteFieldComponent extends ListFieldBase {\n type: ComponentType.AutocompleteField\n options: ListFieldBase['options'] & {\n condition?: string\n }\n}\n\nexport interface CheckboxesFieldComponent extends ListFieldBase {\n type: ComponentType.CheckboxesField\n options: ListFieldBase['options'] & {\n bold?: boolean\n condition?: string\n }\n}\n\nexport interface RadiosFieldComponent extends ListFieldBase {\n type: ComponentType.RadiosField\n options: ListFieldBase['options'] & {\n bold?: boolean\n condition?: string\n }\n}\n\nexport interface SelectFieldComponent extends ListFieldBase {\n type: ComponentType.SelectField\n options: ListFieldBase['options'] & {\n autocomplete?: string\n condition?: string\n }\n}\n\nexport type ComponentDef = FormComponentsDef | ContentComponentsDef\n\n// Components that render form fields\nexport type FormComponentsDef =\n | InputFieldsComponentsDef\n | SelectionComponentsDef\n\n// Components that render inputs\nexport type InputFieldsComponentsDef =\n | TextFieldComponent\n | EmailAddressFieldComponent\n | NumberFieldComponent\n | MultilineTextFieldComponent\n | TelephoneNumberFieldComponent\n | MonthYearFieldComponent\n | DatePartsFieldComponent\n | UkAddressFieldComponent\n | FileUploadFieldComponent\n\n// Components that render content\nexport type ContentComponentsDef =\n | DetailsComponent\n | HtmlComponent\n | InsetTextComponent\n | ListComponent\n\n// Components that render lists\nexport type ListComponentsDef =\n | Exclude<SelectionComponentsDef, YesNoFieldComponent>\n | ListComponent\n\n// Components that have selection fields\nexport type SelectionComponentsDef =\n | AutocompleteFieldComponent\n | CheckboxesFieldComponent\n | RadiosFieldComponent\n | SelectFieldComponent\n | YesNoFieldComponent\n\n// Components that have condition support\nexport type ConditionalComponentsDef = Exclude<\n ComponentDef,\n | InsetTextComponent\n | ListComponent\n | MonthYearFieldComponent\n | UkAddressFieldComponent\n | FileUploadFieldComponent\n>\n"],"mappings":"","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'\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 controller
|
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,3 +1,5 @@
|
|
1
|
+
import { hasNext } from "../../pages/helpers.js";
|
2
|
+
|
1
3
|
/**
|
2
4
|
* Find correct start page for form definition
|
3
5
|
*
|
@@ -16,7 +18,7 @@ export function findStartPage(data) {
|
|
16
18
|
} = data;
|
17
19
|
|
18
20
|
// Get a unique list of all pages that are linked to by other pages
|
19
|
-
const pageReferences = new Set(pages.flatMap(page => page.next
|
21
|
+
const pageReferences = new Set(pages.filter(hasNext).flatMap(page => page.next.map(next => next.path)));
|
20
22
|
|
21
23
|
// For each page on the form, work out if it's referenced by another page
|
22
24
|
// those that aren't referenced must be start pages
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"find-start-page.js","names":["findStartPage","data","pages","pageReferences","Set","flatMap","page","next","map","path","startPages","
|
1
|
+
{"version":3,"file":"find-start-page.js","names":["hasNext","findStartPage","data","pages","pageReferences","Set","filter","flatMap","page","next","map","path","startPages","has","length"],"sources":["../../../../src/form/utils/find-start-page.ts"],"sourcesContent":["import { type FormDefinition } from '~/src/form/form-definition/types.js'\nimport { hasNext } from '~/src/pages/helpers.js'\n\n/**\n * Find correct start page for form definition\n *\n * Computed by counting the next paths in a form definition and returning page\n * that doesn't have a reference, meaning it must be a start page / root node\n *\n * It's possibe for forms to be malformed and have multiple start pages while\n * they're being developed. This may be valid during development, but in this\n * scenario we can't detect the real start page and we require the user to fix\n * this themselves\n * @param data - Form definition\n */\nexport function findStartPage(data: FormDefinition) {\n const { pages } = data\n\n // Get a unique list of all pages that are linked to by other pages\n const pageReferences = new Set(\n pages.filter(hasNext).flatMap((page) => page.next.map((next) => next.path))\n )\n\n // For each page on the form, work out if it's referenced by another page\n // those that aren't referenced must be start pages\n const startPages = pages\n .map((page) => page.path)\n .filter((page) => !pageReferences.has(page))\n\n // We can only set the start page if there is a single one, else the user has made an error\n if (startPages.length === 1) {\n return startPages[0]\n }\n}\n"],"mappings":"AACA,SAASA,OAAO;;AAEhB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,aAAaA,CAACC,IAAoB,EAAE;EAClD,MAAM;IAAEC;EAAM,CAAC,GAAGD,IAAI;;EAEtB;EACA,MAAME,cAAc,GAAG,IAAIC,GAAG,CAC5BF,KAAK,CAACG,MAAM,CAACN,OAAO,CAAC,CAACO,OAAO,CAAEC,IAAI,IAAKA,IAAI,CAACC,IAAI,CAACC,GAAG,CAAED,IAAI,IAAKA,IAAI,CAACE,IAAI,CAAC,CAC5E,CAAC;;EAED;EACA;EACA,MAAMC,UAAU,GAAGT,KAAK,CACrBO,GAAG,CAAEF,IAAI,IAAKA,IAAI,CAACG,IAAI,CAAC,CACxBL,MAAM,CAAEE,IAAI,IAAK,CAACJ,cAAc,CAACS,GAAG,CAACL,IAAI,CAAC,CAAC;;EAE9C;EACA,IAAII,UAAU,CAACE,MAAM,KAAK,CAAC,EAAE;IAC3B,OAAOF,UAAU,CAAC,CAAC,CAAC;EACtB;AACF","ignoreList":[]}
|
package/dist/module/index.js
CHANGED
@@ -3,5 +3,6 @@ export * from "./form/form-metadata/index.js";
|
|
3
3
|
export * from "./form/utils/index.js";
|
4
4
|
export * from "./components/index.js";
|
5
5
|
export * from "./conditions/index.js";
|
6
|
+
export * from "./pages/index.js";
|
6
7
|
export * from "./utils/helpers.js";
|
7
8
|
//# sourceMappingURL=index.js.map
|
package/dist/module/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/index.ts"],"sourcesContent":["export * from '~/src/form/form-definition/index.js'\nexport * from '~/src/form/form-metadata/index.js'\nexport * from '~/src/form/utils/index.js'\nexport * from '~/src/components/index.js'\nexport * from '~/src/conditions/index.js'\nexport * from '~/src/utils/helpers.js'\nexport type * from '~/src/components/types.js'\nexport type * from '~/src/conditions/types.js'\nexport type * from '~/src/form/form-definition/types.js'\nexport type * from '~/src/form/form-metadata/types.js'\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/index.ts"],"sourcesContent":["export * from '~/src/form/form-definition/index.js'\nexport * from '~/src/form/form-metadata/index.js'\nexport * from '~/src/form/utils/index.js'\nexport * from '~/src/components/index.js'\nexport * from '~/src/conditions/index.js'\nexport * from '~/src/pages/index.js'\nexport * from '~/src/utils/helpers.js'\nexport type * from '~/src/components/types.js'\nexport type * from '~/src/conditions/types.js'\nexport type * from '~/src/form/form-definition/types.js'\nexport type * from '~/src/form/form-metadata/types.js'\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
|
@@ -0,0 +1,24 @@
|
|
1
|
+
import { ControllerType } from "./enums.js";
|
2
|
+
export const ControllerTypes = [{
|
3
|
+
name: ControllerType.Start,
|
4
|
+
path: './pages/start.js'
|
5
|
+
}, {
|
6
|
+
name: ControllerType.Home,
|
7
|
+
path: './pages/home.js'
|
8
|
+
}, {
|
9
|
+
name: ControllerType.Page,
|
10
|
+
path: './pages/page.js'
|
11
|
+
}, {
|
12
|
+
name: ControllerType.FileUpload,
|
13
|
+
path: './pages/file-upload.js'
|
14
|
+
}, {
|
15
|
+
name: ControllerType.Summary,
|
16
|
+
path: './pages/summary.js'
|
17
|
+
}, {
|
18
|
+
name: ControllerType.Status,
|
19
|
+
path: './pages/status.js'
|
20
|
+
}];
|
21
|
+
export const ControllerNames = ControllerTypes.map(({
|
22
|
+
name
|
23
|
+
}) => name.toString());
|
24
|
+
//# sourceMappingURL=controller-types.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"controller-types.js","names":["ControllerType","ControllerTypes","name","Start","path","Home","Page","FileUpload","Summary","Status","ControllerNames","map","toString"],"sources":["../../../src/pages/controller-types.ts"],"sourcesContent":["import { ControllerType } from '~/src/pages/enums.js'\n\nexport const ControllerTypes = [\n {\n name: ControllerType.Start,\n path: './pages/start.js'\n },\n {\n name: ControllerType.Home,\n path: './pages/home.js'\n },\n {\n name: ControllerType.Page,\n path: './pages/page.js'\n },\n {\n name: ControllerType.FileUpload,\n path: './pages/file-upload.js'\n },\n {\n name: ControllerType.Summary,\n path: './pages/summary.js'\n },\n {\n name: ControllerType.Status,\n path: './pages/status.js'\n }\n]\n\nexport const ControllerNames = ControllerTypes.map(({ name }) =>\n name.toString()\n)\n"],"mappings":"AAAA,SAASA,cAAc;AAEvB,OAAO,MAAMC,eAAe,GAAG,CAC7B;EACEC,IAAI,EAAEF,cAAc,CAACG,KAAK;EAC1BC,IAAI,EAAE;AACR,CAAC,EACD;EACEF,IAAI,EAAEF,cAAc,CAACK,IAAI;EACzBD,IAAI,EAAE;AACR,CAAC,EACD;EACEF,IAAI,EAAEF,cAAc,CAACM,IAAI;EACzBF,IAAI,EAAE;AACR,CAAC,EACD;EACEF,IAAI,EAAEF,cAAc,CAACO,UAAU;EAC/BH,IAAI,EAAE;AACR,CAAC,EACD;EACEF,IAAI,EAAEF,cAAc,CAACQ,OAAO;EAC5BJ,IAAI,EAAE;AACR,CAAC,EACD;EACEF,IAAI,EAAEF,cAAc,CAACS,MAAM;EAC3BL,IAAI,EAAE;AACR,CAAC,CACF;AAED,OAAO,MAAMM,eAAe,GAAGT,eAAe,CAACU,GAAG,CAAC,CAAC;EAAET;AAAK,CAAC,KAC1DA,IAAI,CAACU,QAAQ,CAAC,CAChB,CAAC","ignoreList":[]}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
export let ControllerPath = /*#__PURE__*/function (ControllerPath) {
|
2
|
+
ControllerPath["Start"] = "/start";
|
3
|
+
ControllerPath["Summary"] = "/summary";
|
4
|
+
ControllerPath["Status"] = "/status";
|
5
|
+
return ControllerPath;
|
6
|
+
}({});
|
7
|
+
export let ControllerType = /*#__PURE__*/function (ControllerType) {
|
8
|
+
ControllerType["Start"] = "StartPageController";
|
9
|
+
ControllerType["Home"] = "HomePageController";
|
10
|
+
ControllerType["Page"] = "PageController";
|
11
|
+
ControllerType["FileUpload"] = "FileUploadPageController";
|
12
|
+
ControllerType["Summary"] = "SummaryPageController";
|
13
|
+
ControllerType["Status"] = "StatusPageController";
|
14
|
+
return ControllerType;
|
15
|
+
}({});
|
16
|
+
//# sourceMappingURL=enums.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"enums.js","names":["ControllerPath","ControllerType"],"sources":["../../../src/pages/enums.ts"],"sourcesContent":["export enum ControllerPath {\n Start = '/start',\n Summary = '/summary',\n Status = '/status'\n}\n\nexport enum ControllerType {\n Start = 'StartPageController',\n Home = 'HomePageController',\n Page = 'PageController',\n FileUpload = 'FileUploadPageController',\n Summary = 'SummaryPageController',\n Status = 'StatusPageController'\n}\n"],"mappings":"AAAA,WAAYA,cAAc,0BAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAA,OAAdA,cAAc;AAAA;AAM1B,WAAYC,cAAc,0BAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAA,OAAdA,cAAc;AAAA","ignoreList":[]}
|
@@ -0,0 +1,77 @@
|
|
1
|
+
import { ControllerNames, ControllerTypes } from "./controller-types.js";
|
2
|
+
import { ControllerType } from "./enums.js";
|
3
|
+
import { PageTypes } from "./page-types.js";
|
4
|
+
|
5
|
+
/**
|
6
|
+
* Return component defaults by type
|
7
|
+
*/
|
8
|
+
export function getPageDefaults(page) {
|
9
|
+
const controller = controllerNameFromPath(page.controller);
|
10
|
+
const defaults = PageTypes.find(pageType => pageType.controller === controller);
|
11
|
+
if (!defaults) {
|
12
|
+
throw new Error(`Defaults not found for ${page.controller}`);
|
13
|
+
}
|
14
|
+
return structuredClone(defaults);
|
15
|
+
}
|
16
|
+
|
17
|
+
/**
|
18
|
+
* Check page has components
|
19
|
+
*/
|
20
|
+
export function hasComponents(page) {
|
21
|
+
return isLinkablePage(page) && Array.isArray(page.components);
|
22
|
+
}
|
23
|
+
|
24
|
+
/**
|
25
|
+
* Check page has sections
|
26
|
+
*/
|
27
|
+
export function hasSection(page) {
|
28
|
+
return isLinkablePage(page) && typeof page.section === 'string';
|
29
|
+
}
|
30
|
+
|
31
|
+
/**
|
32
|
+
* Check page has next link
|
33
|
+
*/
|
34
|
+
export function hasNext(page) {
|
35
|
+
return isLinkablePage(page);
|
36
|
+
}
|
37
|
+
|
38
|
+
/**
|
39
|
+
* Check for known page controller names
|
40
|
+
*/
|
41
|
+
export function isControllerName(nameOrPath) {
|
42
|
+
return !!nameOrPath && ControllerNames.includes(nameOrPath);
|
43
|
+
}
|
44
|
+
|
45
|
+
/**
|
46
|
+
* Check page is linkable
|
47
|
+
*/
|
48
|
+
export function isLinkablePage(page) {
|
49
|
+
if (!page || !('next' in page)) {
|
50
|
+
return false;
|
51
|
+
}
|
52
|
+
const controller = controllerNameFromPath(page.controller);
|
53
|
+
return controller === ControllerType.Start || controller === ControllerType.Page || controller === ControllerType.FileUpload;
|
54
|
+
}
|
55
|
+
|
56
|
+
/**
|
57
|
+
* Check page supports questions
|
58
|
+
*/
|
59
|
+
export function isQuestionPage(page) {
|
60
|
+
const controller = controllerNameFromPath(page?.controller);
|
61
|
+
return controller === ControllerType.Page || controller === ControllerType.FileUpload;
|
62
|
+
}
|
63
|
+
|
64
|
+
/**
|
65
|
+
* Check and optionally replace legacy path with controller name
|
66
|
+
* @param {string} [nameOrPath] - Controller name or legacy controller path
|
67
|
+
*/
|
68
|
+
export function controllerNameFromPath(nameOrPath) {
|
69
|
+
if (isControllerName(nameOrPath)) {
|
70
|
+
return nameOrPath;
|
71
|
+
}
|
72
|
+
const options = ControllerTypes.find(({
|
73
|
+
path
|
74
|
+
}) => path === nameOrPath);
|
75
|
+
return options?.name ?? ControllerType.Page;
|
76
|
+
}
|
77
|
+
//# sourceMappingURL=helpers.js.map
|
@@ -0,0 +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,EAAE;IACb,MAAM,IAAIG,KAAK,CAAC,0BAA0BN,IAAI,CAACC,UAAU,EAAE,CAAC;EAC9D;EAEA,OAAOM,eAAe,CAACJ,QAAQ,CAAC;AAClC;;AAEA;AACA;AACA;AACA,OAAO,SAASK,aAAaA,CAC3BR,IAAoB,EACmC;EACvD,OAAOS,cAAc,CAACT,IAAI,CAAC,IAAIU,KAAK,CAACC,OAAO,CAACX,IAAI,CAACY,UAAU,CAAC;AAC/D;;AAEA;AACA;AACA;AACA,OAAO,SAASC,UAAUA,CACxBb,IAAoB,EACwC;EAC5D,OAAOS,cAAc,CAACT,IAAI,CAAC,IAAI,OAAOA,IAAI,CAACc,OAAO,KAAK,QAAQ;AACjE;;AAEA;AACA;AACA;AACA,OAAO,SAASC,OAAOA,CAACf,IAAoB,EAAE;EAC5C,OAAOS,cAAc,CAACT,IAAI,CAAC;AAC7B;;AAEA;AACA;AACA;AACA,OAAO,SAASgB,gBAAgBA,CAC9BC,UAAoC,EACN;EAC9B,OAAO,CAAC,CAACA,UAAU,IAAItB,eAAe,CAACuB,QAAQ,CAACD,UAAU,CAAC;AAC7D;;AAEA;AACA;AACA;AACA,OAAO,SAASR,cAAcA,CAC5BT,IAAoB,EACqB;EACzC,IAAI,CAACA,IAAI,IAAI,EAAE,MAAM,IAAIA,IAAI,CAAC,EAAE;IAC9B,OAAO,KAAK;EACd;EAEA,MAAMC,UAAU,GAAGC,sBAAsB,CAACF,IAAI,CAACC,UAAU,CAAC;EAE1D,OACEA,UAAU,KAAKJ,cAAc,CAACsB,KAAK,IACnClB,UAAU,KAAKJ,cAAc,CAACuB,IAAI,IAClCnB,UAAU,KAAKJ,cAAc,CAACwB,UAAU;AAE5C;;AAEA;AACA;AACA;AACA,OAAO,SAASC,cAAcA,CAACtB,IAAoB,EAAwB;EACzE,MAAMC,UAAU,GAAGC,sBAAsB,CAACF,IAAI,EAAEC,UAAU,CAAC;EAE3D,OACEA,UAAU,KAAKJ,cAAc,CAACuB,IAAI,IAClCnB,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":[]}
|
@@ -0,0 +1,5 @@
|
|
1
|
+
export { ControllerNames, ControllerTypes } from "./controller-types.js";
|
2
|
+
export { PageTypes } from "./page-types.js";
|
3
|
+
export { controllerNameFromPath, getPageDefaults, hasComponents, hasSection, hasNext, isControllerName, isLinkablePage, isQuestionPage } from "./helpers.js";
|
4
|
+
export { ControllerPath, ControllerType } from "./enums.js";
|
5
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +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":[]}
|
@@ -0,0 +1,45 @@
|
|
1
|
+
import { ControllerType, ControllerPath } from "./enums.js";
|
2
|
+
|
3
|
+
/**
|
4
|
+
* Defaults for creating new pages
|
5
|
+
*/
|
6
|
+
export const PageTypes = Object.freeze([{
|
7
|
+
title: 'Start page',
|
8
|
+
path: ControllerPath.Start,
|
9
|
+
controller: ControllerType.Start,
|
10
|
+
section: undefined,
|
11
|
+
next: [],
|
12
|
+
components: []
|
13
|
+
}, {
|
14
|
+
title: 'Question page',
|
15
|
+
path: '/question-page',
|
16
|
+
controller: ControllerType.Page,
|
17
|
+
section: undefined,
|
18
|
+
next: [],
|
19
|
+
components: []
|
20
|
+
}, {
|
21
|
+
title: 'File upload page',
|
22
|
+
path: '/file-upload-page',
|
23
|
+
controller: ControllerType.FileUpload,
|
24
|
+
section: undefined,
|
25
|
+
next: [],
|
26
|
+
components: []
|
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',
|
36
|
+
path: ControllerPath.Summary,
|
37
|
+
controller: ControllerType.Summary,
|
38
|
+
section: undefined
|
39
|
+
}, {
|
40
|
+
title: 'Form submitted',
|
41
|
+
path: ControllerPath.Status,
|
42
|
+
controller: ControllerType.Status,
|
43
|
+
section: undefined
|
44
|
+
}]);
|
45
|
+
//# sourceMappingURL=page-types.js.map
|
@@ -0,0 +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":[]}
|
@@ -2,5 +2,5 @@ import { type ComponentDef } from '../components/types.js';
|
|
2
2
|
/**
|
3
3
|
* Defaults for creating new components
|
4
4
|
*/
|
5
|
-
export declare const ComponentTypes: ComponentDef[];
|
5
|
+
export declare const ComponentTypes: readonly ComponentDef[];
|
6
6
|
//# sourceMappingURL=component-types.d.ts.map
|
@@ -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,YAAY,
|
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 +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,
|
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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,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"}
|
@@ -126,7 +126,7 @@ export interface UkAddressFieldComponent extends FormFieldBase {
|
|
126
126
|
hideTitle?: boolean;
|
127
127
|
};
|
128
128
|
}
|
129
|
-
export interface
|
129
|
+
export interface DatePartsFieldComponent extends DateFieldBase {
|
130
130
|
type: ComponentType.DatePartsField;
|
131
131
|
options: DateFieldBase['options'] & {
|
132
132
|
condition?: string;
|
@@ -196,7 +196,7 @@ export interface SelectFieldComponent extends ListFieldBase {
|
|
196
196
|
}
|
197
197
|
export type ComponentDef = FormComponentsDef | ContentComponentsDef;
|
198
198
|
export type FormComponentsDef = InputFieldsComponentsDef | SelectionComponentsDef;
|
199
|
-
export type InputFieldsComponentsDef = TextFieldComponent | EmailAddressFieldComponent | NumberFieldComponent | MultilineTextFieldComponent | TelephoneNumberFieldComponent | MonthYearFieldComponent |
|
199
|
+
export type InputFieldsComponentsDef = TextFieldComponent | EmailAddressFieldComponent | NumberFieldComponent | MultilineTextFieldComponent | TelephoneNumberFieldComponent | MonthYearFieldComponent | DatePartsFieldComponent | UkAddressFieldComponent | FileUploadFieldComponent;
|
200
200
|
export type ContentComponentsDef = DetailsComponent | HtmlComponent | InsetTextComponent | ListComponent;
|
201
201
|
export type ListComponentsDef = Exclude<SelectionComponentsDef, YesNoFieldComponent> | ListComponent;
|
202
202
|
export type SelectionComponentsDef = AutocompleteFieldComponent | CheckboxesFieldComponent | RadiosFieldComponent | SelectFieldComponent | YesNoFieldComponent;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":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AAW,CAAA;IAC/B,OAAO,EAAE,aAAa,CAAC,SAAS,CAAC,GAAG;QAClC,IAAI,CAAC,EAAE,OAAO,CAAA;QACd,SAAS,CAAC,EAAE,MAAM,CAAA;KACnB,CAAA;CACF;AAED,MAAM,WAAW,oBAAqB,SAAQ,aAAa;IACzD,IAAI,EAAE,aAAa,CAAC,WAAW,CAAA;IAC/B,OAAO,EAAE,aAAa,CAAC,SAAS,CAAC,GAAG;QAClC,YAAY,CAAC,EAAE,MAAM,CAAA;QACrB,SAAS,CAAC,EAAE,MAAM,CAAA;KACnB,CAAA;CACF;AAED,MAAM,MAAM,YAAY,GAAG,iBAAiB,GAAG,oBAAoB,CAAA;AAGnE,MAAM,MAAM,iBAAiB,GACzB,wBAAwB,GACxB,sBAAsB,CAAA;AAG1B,MAAM,MAAM,wBAAwB,GAChC,kBAAkB,GAClB,0BAA0B,GAC1B,oBAAoB,GACpB,2BAA2B,GAC3B,6BAA6B,GAC7B,uBAAuB,GACvB,uBAAuB,GACvB,uBAAuB,GACvB,wBAAwB,CAAA;AAG5B,MAAM,MAAM,oBAAoB,GAC5B,gBAAgB,GAChB,aAAa,GACb,kBAAkB,GAClB,aAAa,CAAA;AAGjB,MAAM,MAAM,iBAAiB,GACzB,OAAO,CAAC,sBAAsB,EAAE,mBAAmB,CAAC,GACpD,aAAa,CAAA;AAGjB,MAAM,MAAM,sBAAsB,GAC9B,0BAA0B,GAC1B,wBAAwB,GACxB,oBAAoB,GACpB,oBAAoB,GACpB,mBAAmB,CAAA;AAGvB,MAAM,MAAM,wBAAwB,GAAG,OAAO,CAC5C,YAAY,EACV,kBAAkB,GAClB,aAAa,GACb,uBAAuB,GACvB,uBAAuB,GACvB,wBAAwB,CAC3B,CAAA"}
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import { type ComponentDef } from '../../components/types.js';
|
2
2
|
import { type ConditionsModelData } from '../../conditions/types.js';
|
3
|
+
import { type ControllerPath, type ControllerType } from '../../pages/enums.js';
|
3
4
|
export interface Link {
|
4
5
|
path: string;
|
5
6
|
condition?: string;
|
@@ -8,19 +9,33 @@ export interface Link {
|
|
8
9
|
export interface PageBase {
|
9
10
|
title: string;
|
10
11
|
path: string;
|
11
|
-
controller?: 'StartPageController' | 'FileUploadPageController' | 'SummaryPageController';
|
12
|
-
components?: ComponentDef[];
|
13
|
-
section?: string;
|
14
|
-
next?: Link[];
|
15
12
|
}
|
16
|
-
export interface
|
17
|
-
controller
|
13
|
+
export interface PageStart extends PageBase {
|
14
|
+
controller: ControllerType.Start | ControllerType.Home;
|
15
|
+
section?: string | undefined;
|
18
16
|
next: Link[];
|
17
|
+
components: ComponentDef[];
|
19
18
|
}
|
20
|
-
export interface
|
19
|
+
export interface PageQuestion extends PageBase {
|
20
|
+
controller?: ControllerType.Page | ControllerType.FileUpload;
|
21
|
+
section?: string | undefined;
|
22
|
+
next: Link[];
|
21
23
|
components: ComponentDef[];
|
22
24
|
}
|
23
|
-
export
|
25
|
+
export interface PageSummary extends PageBase {
|
26
|
+
path: ControllerPath.Summary;
|
27
|
+
controller: ControllerType.Summary;
|
28
|
+
section?: undefined;
|
29
|
+
}
|
30
|
+
export interface PageStatus extends PageBase {
|
31
|
+
path: ControllerPath.Status;
|
32
|
+
controller: ControllerType.Status;
|
33
|
+
section?: undefined;
|
34
|
+
}
|
35
|
+
export type Page = PageStart | PageQuestion | PageSummary | PageStatus;
|
36
|
+
export type RequiredField<Type extends Partial<object>, KeyType extends keyof Type> = Omit<Type, KeyType> & Required<{
|
37
|
+
[Key in KeyType]: Type[Key];
|
38
|
+
}>;
|
24
39
|
export interface Section {
|
25
40
|
name: string;
|
26
41
|
title: string;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/form/form-definition/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAC7D,OAAO,EAAE,KAAK,mBAAmB,EAAE,MAAM,2BAA2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AAE,OAAO,GAAG,MAAM,CAAA;IACxB,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,CAAA;IACnB,KAAK,EAAE,mBAAmB,CAAA;CAC3B;AAED;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,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 +1 @@
|
|
1
|
-
{"version":3,"file":"find-start-page.d.ts","sourceRoot":"","sources":["../../../../src/form/utils/find-start-page.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,qCAAqC,CAAA;
|
1
|
+
{"version":3,"file":"find-start-page.d.ts","sourceRoot":"","sources":["../../../../src/form/utils/find-start-page.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,qCAAqC,CAAA;AAGzE;;;;;;;;;;;GAWG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,cAAc,sBAkBjD"}
|
package/dist/types/index.d.ts
CHANGED
@@ -3,6 +3,7 @@ export * from './form/form-metadata/index.js';
|
|
3
3
|
export * from './form/utils/index.js';
|
4
4
|
export * from './components/index.js';
|
5
5
|
export * from './conditions/index.js';
|
6
|
+
export * from './pages/index.js';
|
6
7
|
export * from './utils/helpers.js';
|
7
8
|
export type * from './components/types.js';
|
8
9
|
export type * from './conditions/types.js';
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,qCAAqC,CAAA;AACnD,cAAc,mCAAmC,CAAA;AACjD,cAAc,2BAA2B,CAAA;AACzC,cAAc,2BAA2B,CAAA;AACzC,cAAc,2BAA2B,CAAA;AACzC,cAAc,wBAAwB,CAAA;AACtC,mBAAmB,2BAA2B,CAAA;AAC9C,mBAAmB,2BAA2B,CAAA;AAC9C,mBAAmB,qCAAqC,CAAA;AACxD,mBAAmB,mCAAmC,CAAA"}
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,qCAAqC,CAAA;AACnD,cAAc,mCAAmC,CAAA;AACjD,cAAc,2BAA2B,CAAA;AACzC,cAAc,2BAA2B,CAAA;AACzC,cAAc,2BAA2B,CAAA;AACzC,cAAc,sBAAsB,CAAA;AACpC,cAAc,wBAAwB,CAAA;AACtC,mBAAmB,2BAA2B,CAAA;AAC9C,mBAAmB,2BAA2B,CAAA;AAC9C,mBAAmB,qCAAqC,CAAA;AACxD,mBAAmB,mCAAmC,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"controller-types.d.ts","sourceRoot":"","sources":["../../../src/pages/controller-types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAErD,eAAO,MAAM,eAAe;;;GAyB3B,CAAA;AAED,eAAO,MAAM,eAAe,UAE3B,CAAA"}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
export declare enum ControllerPath {
|
2
|
+
Start = "/start",
|
3
|
+
Summary = "/summary",
|
4
|
+
Status = "/status"
|
5
|
+
}
|
6
|
+
export declare enum ControllerType {
|
7
|
+
Start = "StartPageController",
|
8
|
+
Home = "HomePageController",
|
9
|
+
Page = "PageController",
|
10
|
+
FileUpload = "FileUploadPageController",
|
11
|
+
Summary = "SummaryPageController",
|
12
|
+
Status = "StatusPageController"
|
13
|
+
}
|
14
|
+
//# sourceMappingURL=enums.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"enums.d.ts","sourceRoot":"","sources":["../../../src/pages/enums.ts"],"names":[],"mappings":"AAAA,oBAAY,cAAc;IACxB,KAAK,WAAW;IAChB,OAAO,aAAa;IACpB,MAAM,YAAY;CACnB;AAED,oBAAY,cAAc;IACxB,KAAK,wBAAwB;IAC7B,IAAI,uBAAuB;IAC3B,IAAI,mBAAmB;IACvB,UAAU,6BAA6B;IACvC,OAAO,0BAA0B;IACjC,MAAM,yBAAyB;CAChC"}
|
@@ -0,0 +1,41 @@
|
|
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';
|
3
|
+
import { ControllerType } from '../pages/enums.js';
|
4
|
+
/**
|
5
|
+
* Return component defaults by type
|
6
|
+
*/
|
7
|
+
export declare function getPageDefaults(page: Pick<Page, 'controller'>): Page;
|
8
|
+
/**
|
9
|
+
* Check page has components
|
10
|
+
*/
|
11
|
+
export declare function hasComponents(page?: Partial<Page>): page is Extract<Page, {
|
12
|
+
components: ComponentDef[];
|
13
|
+
}>;
|
14
|
+
/**
|
15
|
+
* Check page has sections
|
16
|
+
*/
|
17
|
+
export declare function hasSection(page?: Partial<Page>): page is RequiredField<PageStart | PageQuestion, 'section'>;
|
18
|
+
/**
|
19
|
+
* Check page has next link
|
20
|
+
*/
|
21
|
+
export declare function hasNext(page?: Partial<Page>): page is PageStart | PageQuestion;
|
22
|
+
/**
|
23
|
+
* Check for known page controller names
|
24
|
+
*/
|
25
|
+
export declare function isControllerName(nameOrPath?: ControllerType | string): nameOrPath is ControllerType;
|
26
|
+
/**
|
27
|
+
* Check page is linkable
|
28
|
+
*/
|
29
|
+
export declare function isLinkablePage(page?: Partial<Page>): page is Extract<Page, {
|
30
|
+
next: Link[];
|
31
|
+
}>;
|
32
|
+
/**
|
33
|
+
* Check page supports questions
|
34
|
+
*/
|
35
|
+
export declare function isQuestionPage(page?: Partial<Page>): page is PageQuestion;
|
36
|
+
/**
|
37
|
+
* Check and optionally replace legacy path with controller name
|
38
|
+
* @param {string} [nameOrPath] - Controller name or legacy controller path
|
39
|
+
*/
|
40
|
+
export declare function controllerNameFromPath(nameOrPath?: ControllerType | string): ControllerType;
|
41
|
+
//# sourceMappingURL=helpers.d.ts.map
|
@@ -0,0 +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,OAAO,CAAC,IAAI,CAAC,oCAE3C;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,CAYzC;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,IAAI,YAAY,CAOzE;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,UAAU,CAAC,EAAE,cAAc,GAAG,MAAM,kBAO1E"}
|
@@ -0,0 +1,5 @@
|
|
1
|
+
export { ControllerNames, ControllerTypes } from '../pages/controller-types.js';
|
2
|
+
export { PageTypes } from '../pages/page-types.js';
|
3
|
+
export { controllerNameFromPath, getPageDefaults, hasComponents, hasSection, hasNext, isControllerName, isLinkablePage, isQuestionPage } from '../pages/helpers.js';
|
4
|
+
export { ControllerPath, ControllerType } from '../pages/enums.js';
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
@@ -0,0 +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"}
|
@@ -0,0 +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"}
|
package/package.json
CHANGED
@@ -4,7 +4,7 @@ import { type ComponentDef } from '~/src/components/types.js'
|
|
4
4
|
/**
|
5
5
|
* Defaults for creating new components
|
6
6
|
*/
|
7
|
-
export const ComponentTypes: ComponentDef[] = [
|
7
|
+
export const ComponentTypes: readonly ComponentDef[] = Object.freeze([
|
8
8
|
{
|
9
9
|
name: 'TextField',
|
10
10
|
title: 'Text field',
|
@@ -130,4 +130,4 @@ export const ComponentTypes: ComponentDef[] = [
|
|
130
130
|
list: '',
|
131
131
|
options: {}
|
132
132
|
}
|
133
|
-
]
|
133
|
+
])
|
@@ -21,7 +21,9 @@ export function getComponentDefaults(component?: Partial<ComponentDef>) {
|
|
21
21
|
return
|
22
22
|
}
|
23
23
|
|
24
|
-
return
|
24
|
+
return structuredClone(
|
25
|
+
ComponentTypes.find(({ type }) => type === component.type)
|
26
|
+
)
|
25
27
|
}
|
26
28
|
|
27
29
|
/**
|
package/src/components/types.ts
CHANGED
@@ -157,7 +157,7 @@ export interface UkAddressFieldComponent extends FormFieldBase {
|
|
157
157
|
}
|
158
158
|
|
159
159
|
// Date Fields
|
160
|
-
export interface
|
160
|
+
export interface DatePartsFieldComponent extends DateFieldBase {
|
161
161
|
type: ComponentType.DatePartsField
|
162
162
|
options: DateFieldBase['options'] & {
|
163
163
|
condition?: string
|
@@ -251,7 +251,7 @@ export type InputFieldsComponentsDef =
|
|
251
251
|
| MultilineTextFieldComponent
|
252
252
|
| TelephoneNumberFieldComponent
|
253
253
|
| MonthYearFieldComponent
|
254
|
-
|
|
254
|
+
| DatePartsFieldComponent
|
255
255
|
| UkAddressFieldComponent
|
256
256
|
| FileUploadFieldComponent
|
257
257
|
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import { type ComponentDef } from '~/src/components/types.js'
|
2
2
|
import { type ConditionsModelData } from '~/src/conditions/types.js'
|
3
3
|
import { formDefinitionSchema } from '~/src/form/form-definition/index.js'
|
4
|
+
import { type ControllerPath, type ControllerType } from '~/src/pages/enums.js'
|
4
5
|
|
5
6
|
export interface Link {
|
6
7
|
path: string
|
@@ -11,25 +12,43 @@ export interface Link {
|
|
11
12
|
export interface PageBase {
|
12
13
|
title: string
|
13
14
|
path: string
|
14
|
-
controller?:
|
15
|
-
| 'StartPageController'
|
16
|
-
| 'FileUploadPageController'
|
17
|
-
| 'SummaryPageController'
|
18
|
-
components?: ComponentDef[]
|
19
|
-
section?: string
|
20
|
-
next?: Link[]
|
21
15
|
}
|
22
16
|
|
23
|
-
export interface
|
24
|
-
controller
|
17
|
+
export interface PageStart extends PageBase {
|
18
|
+
controller: ControllerType.Start | ControllerType.Home
|
19
|
+
section?: string | undefined
|
25
20
|
next: Link[]
|
21
|
+
components: ComponentDef[]
|
26
22
|
}
|
27
23
|
|
28
|
-
export interface
|
24
|
+
export interface PageQuestion extends PageBase {
|
25
|
+
controller?: ControllerType.Page | ControllerType.FileUpload
|
26
|
+
section?: string | undefined
|
27
|
+
next: Link[]
|
29
28
|
components: ComponentDef[]
|
30
29
|
}
|
31
30
|
|
32
|
-
export
|
31
|
+
export interface PageSummary extends PageBase {
|
32
|
+
path: ControllerPath.Summary
|
33
|
+
controller: ControllerType.Summary
|
34
|
+
section?: undefined
|
35
|
+
}
|
36
|
+
|
37
|
+
export interface PageStatus extends PageBase {
|
38
|
+
path: ControllerPath.Status
|
39
|
+
controller: ControllerType.Status
|
40
|
+
section?: undefined
|
41
|
+
}
|
42
|
+
|
43
|
+
export type Page = PageStart | PageQuestion | PageSummary | PageStatus
|
44
|
+
|
45
|
+
export type RequiredField<
|
46
|
+
Type extends Partial<object>,
|
47
|
+
KeyType extends keyof Type
|
48
|
+
> = Omit<Type, KeyType> &
|
49
|
+
Required<{
|
50
|
+
[Key in KeyType]: Type[Key]
|
51
|
+
}>
|
33
52
|
|
34
53
|
export interface Section {
|
35
54
|
name: string
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import { type FormDefinition } from '~/src/form/form-definition/types.js'
|
2
|
+
import { hasNext } from '~/src/pages/helpers.js'
|
2
3
|
|
3
4
|
/**
|
4
5
|
* Find correct start page for form definition
|
@@ -17,7 +18,7 @@ export function findStartPage(data: FormDefinition) {
|
|
17
18
|
|
18
19
|
// Get a unique list of all pages that are linked to by other pages
|
19
20
|
const pageReferences = new Set(
|
20
|
-
pages.flatMap((page) => page.next
|
21
|
+
pages.filter(hasNext).flatMap((page) => page.next.map((next) => next.path))
|
21
22
|
)
|
22
23
|
|
23
24
|
// For each page on the form, work out if it's referenced by another page
|
package/src/index.ts
CHANGED
@@ -3,6 +3,7 @@ export * from '~/src/form/form-metadata/index.js'
|
|
3
3
|
export * from '~/src/form/utils/index.js'
|
4
4
|
export * from '~/src/components/index.js'
|
5
5
|
export * from '~/src/conditions/index.js'
|
6
|
+
export * from '~/src/pages/index.js'
|
6
7
|
export * from '~/src/utils/helpers.js'
|
7
8
|
export type * from '~/src/components/types.js'
|
8
9
|
export type * from '~/src/conditions/types.js'
|
@@ -0,0 +1,32 @@
|
|
1
|
+
import { ControllerType } from '~/src/pages/enums.js'
|
2
|
+
|
3
|
+
export const ControllerTypes = [
|
4
|
+
{
|
5
|
+
name: ControllerType.Start,
|
6
|
+
path: './pages/start.js'
|
7
|
+
},
|
8
|
+
{
|
9
|
+
name: ControllerType.Home,
|
10
|
+
path: './pages/home.js'
|
11
|
+
},
|
12
|
+
{
|
13
|
+
name: ControllerType.Page,
|
14
|
+
path: './pages/page.js'
|
15
|
+
},
|
16
|
+
{
|
17
|
+
name: ControllerType.FileUpload,
|
18
|
+
path: './pages/file-upload.js'
|
19
|
+
},
|
20
|
+
{
|
21
|
+
name: ControllerType.Summary,
|
22
|
+
path: './pages/summary.js'
|
23
|
+
},
|
24
|
+
{
|
25
|
+
name: ControllerType.Status,
|
26
|
+
path: './pages/status.js'
|
27
|
+
}
|
28
|
+
]
|
29
|
+
|
30
|
+
export const ControllerNames = ControllerTypes.map(({ name }) =>
|
31
|
+
name.toString()
|
32
|
+
)
|
@@ -0,0 +1,14 @@
|
|
1
|
+
export enum ControllerPath {
|
2
|
+
Start = '/start',
|
3
|
+
Summary = '/summary',
|
4
|
+
Status = '/status'
|
5
|
+
}
|
6
|
+
|
7
|
+
export enum ControllerType {
|
8
|
+
Start = 'StartPageController',
|
9
|
+
Home = 'HomePageController',
|
10
|
+
Page = 'PageController',
|
11
|
+
FileUpload = 'FileUploadPageController',
|
12
|
+
Summary = 'SummaryPageController',
|
13
|
+
Status = 'StatusPageController'
|
14
|
+
}
|
@@ -0,0 +1,109 @@
|
|
1
|
+
import { type ComponentDef } from '~/src/components/types.js'
|
2
|
+
import {
|
3
|
+
type Link,
|
4
|
+
type Page,
|
5
|
+
type PageQuestion,
|
6
|
+
type PageStart,
|
7
|
+
type RequiredField
|
8
|
+
} from '~/src/form/form-definition/types.js'
|
9
|
+
import {
|
10
|
+
ControllerNames,
|
11
|
+
ControllerTypes
|
12
|
+
} from '~/src/pages/controller-types.js'
|
13
|
+
import { ControllerType } from '~/src/pages/enums.js'
|
14
|
+
import { PageTypes } from '~/src/pages/page-types.js'
|
15
|
+
|
16
|
+
/**
|
17
|
+
* Return component defaults by type
|
18
|
+
*/
|
19
|
+
export function getPageDefaults(page: Pick<Page, 'controller'>) {
|
20
|
+
const controller = controllerNameFromPath(page.controller)
|
21
|
+
|
22
|
+
const defaults = PageTypes.find(
|
23
|
+
(pageType) => pageType.controller === controller
|
24
|
+
)
|
25
|
+
|
26
|
+
if (!defaults) {
|
27
|
+
throw new Error(`Defaults not found for ${page.controller}`)
|
28
|
+
}
|
29
|
+
|
30
|
+
return structuredClone(defaults)
|
31
|
+
}
|
32
|
+
|
33
|
+
/**
|
34
|
+
* Check page has components
|
35
|
+
*/
|
36
|
+
export function hasComponents(
|
37
|
+
page?: Partial<Page>
|
38
|
+
): page is Extract<Page, { components: ComponentDef[] }> {
|
39
|
+
return isLinkablePage(page) && Array.isArray(page.components)
|
40
|
+
}
|
41
|
+
|
42
|
+
/**
|
43
|
+
* Check page has sections
|
44
|
+
*/
|
45
|
+
export function hasSection(
|
46
|
+
page?: Partial<Page>
|
47
|
+
): page is RequiredField<PageStart | PageQuestion, 'section'> {
|
48
|
+
return isLinkablePage(page) && typeof page.section === 'string'
|
49
|
+
}
|
50
|
+
|
51
|
+
/**
|
52
|
+
* Check page has next link
|
53
|
+
*/
|
54
|
+
export function hasNext(page?: Partial<Page>) {
|
55
|
+
return isLinkablePage(page)
|
56
|
+
}
|
57
|
+
|
58
|
+
/**
|
59
|
+
* Check for known page controller names
|
60
|
+
*/
|
61
|
+
export function isControllerName(
|
62
|
+
nameOrPath?: ControllerType | string
|
63
|
+
): nameOrPath is ControllerType {
|
64
|
+
return !!nameOrPath && ControllerNames.includes(nameOrPath)
|
65
|
+
}
|
66
|
+
|
67
|
+
/**
|
68
|
+
* Check page is linkable
|
69
|
+
*/
|
70
|
+
export function isLinkablePage(
|
71
|
+
page?: Partial<Page>
|
72
|
+
): page is Extract<Page, { next: Link[] }> {
|
73
|
+
if (!page || !('next' in page)) {
|
74
|
+
return false
|
75
|
+
}
|
76
|
+
|
77
|
+
const controller = controllerNameFromPath(page.controller)
|
78
|
+
|
79
|
+
return (
|
80
|
+
controller === ControllerType.Start ||
|
81
|
+
controller === ControllerType.Page ||
|
82
|
+
controller === ControllerType.FileUpload
|
83
|
+
)
|
84
|
+
}
|
85
|
+
|
86
|
+
/**
|
87
|
+
* Check page supports questions
|
88
|
+
*/
|
89
|
+
export function isQuestionPage(page?: Partial<Page>): page is PageQuestion {
|
90
|
+
const controller = controllerNameFromPath(page?.controller)
|
91
|
+
|
92
|
+
return (
|
93
|
+
controller === ControllerType.Page ||
|
94
|
+
controller === ControllerType.FileUpload
|
95
|
+
)
|
96
|
+
}
|
97
|
+
|
98
|
+
/**
|
99
|
+
* Check and optionally replace legacy path with controller name
|
100
|
+
* @param {string} [nameOrPath] - Controller name or legacy controller path
|
101
|
+
*/
|
102
|
+
export function controllerNameFromPath(nameOrPath?: ControllerType | string) {
|
103
|
+
if (isControllerName(nameOrPath)) {
|
104
|
+
return nameOrPath
|
105
|
+
}
|
106
|
+
|
107
|
+
const options = ControllerTypes.find(({ path }) => path === nameOrPath)
|
108
|
+
return options?.name ?? ControllerType.Page
|
109
|
+
}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
export {
|
2
|
+
ControllerNames,
|
3
|
+
ControllerTypes
|
4
|
+
} from '~/src/pages/controller-types.js'
|
5
|
+
|
6
|
+
export { PageTypes } from '~/src/pages/page-types.js'
|
7
|
+
|
8
|
+
export {
|
9
|
+
controllerNameFromPath,
|
10
|
+
getPageDefaults,
|
11
|
+
hasComponents,
|
12
|
+
hasSection,
|
13
|
+
hasNext,
|
14
|
+
isControllerName,
|
15
|
+
isLinkablePage,
|
16
|
+
isQuestionPage
|
17
|
+
} from '~/src/pages/helpers.js'
|
18
|
+
|
19
|
+
export { ControllerPath, ControllerType } from '~/src/pages/enums.js'
|
@@ -0,0 +1,52 @@
|
|
1
|
+
import { type Page } from '~/src/form/form-definition/types.js'
|
2
|
+
import { ControllerType, ControllerPath } from '~/src/pages/enums.js'
|
3
|
+
|
4
|
+
/**
|
5
|
+
* Defaults for creating new pages
|
6
|
+
*/
|
7
|
+
export const PageTypes: readonly Page[] = Object.freeze([
|
8
|
+
{
|
9
|
+
title: 'Start page',
|
10
|
+
path: ControllerPath.Start,
|
11
|
+
controller: ControllerType.Start,
|
12
|
+
section: undefined,
|
13
|
+
next: [],
|
14
|
+
components: []
|
15
|
+
},
|
16
|
+
{
|
17
|
+
title: 'Question page',
|
18
|
+
path: '/question-page',
|
19
|
+
controller: ControllerType.Page,
|
20
|
+
section: undefined,
|
21
|
+
next: [],
|
22
|
+
components: []
|
23
|
+
},
|
24
|
+
{
|
25
|
+
title: 'File upload page',
|
26
|
+
path: '/file-upload-page',
|
27
|
+
controller: ControllerType.FileUpload,
|
28
|
+
section: undefined,
|
29
|
+
next: [],
|
30
|
+
components: []
|
31
|
+
},
|
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',
|
42
|
+
path: ControllerPath.Summary,
|
43
|
+
controller: ControllerType.Summary,
|
44
|
+
section: undefined
|
45
|
+
},
|
46
|
+
{
|
47
|
+
title: 'Form submitted',
|
48
|
+
path: ControllerPath.Status,
|
49
|
+
controller: ControllerType.Status,
|
50
|
+
section: undefined
|
51
|
+
}
|
52
|
+
])
|