@defra/forms-model 3.0.278 → 3.0.280
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 +19 -34
- package/dist/module/components/component-types.js.map +1 -1
- package/dist/module/components/helpers.js +17 -0
- package/dist/module/components/helpers.js.map +1 -1
- package/dist/module/components/index.js +1 -1
- package/dist/module/components/index.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/types/components/component-types.d.ts.map +1 -1
- package/dist/types/components/helpers.d.ts +10 -1
- package/dist/types/components/helpers.d.ts.map +1 -1
- package/dist/types/components/index.d.ts +1 -1
- package/dist/types/components/index.d.ts.map +1 -1
- package/dist/types/components/types.d.ts +61 -67
- package/dist/types/components/types.d.ts.map +1 -1
- package/dist/types/form/form-definition/types.d.ts +14 -4
- package/dist/types/form/form-definition/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/component-types.ts +19 -34
- package/src/components/helpers.ts +25 -0
- package/src/components/index.ts +4 -0
- package/src/components/types.ts +69 -75
- package/src/form/form-definition/types.ts +22 -5
@@ -21,54 +21,47 @@ export const ComponentTypes = [{
|
|
21
21
|
title: 'Yes/No field',
|
22
22
|
type: ComponentType.YesNoField,
|
23
23
|
hint: '',
|
24
|
-
options: {}
|
25
|
-
schema: {}
|
24
|
+
options: {}
|
26
25
|
}, {
|
27
26
|
name: 'DatePartsField',
|
28
27
|
title: 'Date field',
|
29
28
|
type: ComponentType.DatePartsField,
|
30
29
|
hint: '',
|
31
|
-
options: {}
|
32
|
-
schema: {}
|
30
|
+
options: {}
|
33
31
|
}, {
|
34
32
|
name: 'MonthYearField',
|
35
33
|
title: 'Month & year field',
|
36
34
|
type: ComponentType.MonthYearField,
|
37
35
|
hint: '',
|
38
|
-
options: {}
|
39
|
-
schema: {}
|
36
|
+
options: {}
|
40
37
|
}, {
|
41
38
|
name: 'SelectField',
|
42
39
|
title: 'Select field',
|
43
40
|
type: ComponentType.SelectField,
|
44
41
|
hint: '',
|
45
|
-
|
46
|
-
|
47
|
-
list: ''
|
42
|
+
list: '',
|
43
|
+
options: {}
|
48
44
|
}, {
|
49
45
|
name: 'AutocompleteField',
|
50
46
|
title: 'Autocomplete field',
|
51
47
|
type: ComponentType.AutocompleteField,
|
52
48
|
hint: '',
|
53
|
-
|
54
|
-
|
55
|
-
list: ''
|
49
|
+
list: '',
|
50
|
+
options: {}
|
56
51
|
}, {
|
57
52
|
name: 'RadiosField',
|
58
53
|
title: 'Radios field',
|
59
54
|
type: ComponentType.RadiosField,
|
60
55
|
hint: '',
|
61
|
-
|
62
|
-
|
63
|
-
list: ''
|
56
|
+
list: '',
|
57
|
+
options: {}
|
64
58
|
}, {
|
65
59
|
name: 'CheckboxesField',
|
66
60
|
title: 'Checkboxes field',
|
67
61
|
type: ComponentType.CheckboxesField,
|
68
62
|
hint: '',
|
69
|
-
|
70
|
-
|
71
|
-
list: ''
|
63
|
+
list: '',
|
64
|
+
options: {}
|
72
65
|
}, {
|
73
66
|
name: 'NumberField',
|
74
67
|
title: 'Number field',
|
@@ -81,49 +74,41 @@ export const ComponentTypes = [{
|
|
81
74
|
title: 'UK address field',
|
82
75
|
type: ComponentType.UkAddressField,
|
83
76
|
hint: '',
|
84
|
-
options: {}
|
85
|
-
schema: {}
|
77
|
+
options: {}
|
86
78
|
}, {
|
87
79
|
name: 'TelephoneNumberField',
|
88
80
|
title: 'Telephone number field',
|
89
81
|
type: ComponentType.TelephoneNumberField,
|
90
82
|
hint: '',
|
91
|
-
options: {}
|
92
|
-
schema: {}
|
83
|
+
options: {}
|
93
84
|
}, {
|
94
85
|
name: 'EmailAddressField',
|
95
86
|
title: 'Email address field',
|
96
87
|
type: ComponentType.EmailAddressField,
|
97
88
|
hint: 'For example, ‘name@example.com’',
|
98
|
-
options: {}
|
99
|
-
schema: {}
|
89
|
+
options: {}
|
100
90
|
}, {
|
101
91
|
name: 'Html',
|
102
92
|
title: 'Html',
|
103
93
|
type: ComponentType.Html,
|
104
94
|
content: '',
|
105
|
-
options: {}
|
106
|
-
schema: {}
|
95
|
+
options: {}
|
107
96
|
}, {
|
108
97
|
name: 'InsetText',
|
109
98
|
title: 'Inset text',
|
110
99
|
type: ComponentType.InsetText,
|
111
|
-
content: ''
|
112
|
-
options: {},
|
113
|
-
schema: {}
|
100
|
+
content: ''
|
114
101
|
}, {
|
115
102
|
name: 'Details',
|
116
103
|
title: 'Details',
|
117
104
|
type: ComponentType.Details,
|
118
105
|
content: '',
|
119
|
-
options: {}
|
120
|
-
schema: {}
|
106
|
+
options: {}
|
121
107
|
}, {
|
122
108
|
name: 'List',
|
123
109
|
title: 'List',
|
124
110
|
type: ComponentType.List,
|
125
|
-
|
126
|
-
|
127
|
-
list: ''
|
111
|
+
list: '',
|
112
|
+
options: {}
|
128
113
|
}];
|
129
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: {}
|
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,cAA8B,GAAG,CAC5C;EACEC,IAAI,EAAE,WAAW;EACjBC,KAAK,EAAE,YAAY;EACnBC,IAAI,EAAEJ,aAAa,CAACK,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,EAAEJ,aAAa,CAACS,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,EAAEJ,aAAa,CAACU,UAAU;EAC9BJ,IAAI,EAAE,EAAE;EACRC,OAAO,EAAE,CAAC;AACZ,CAAC,EACD;EACEL,IAAI,EAAE,gBAAgB;EACtBC,KAAK,EAAE,YAAY;EACnBC,IAAI,EAAEJ,aAAa,CAACW,cAAc;EAClCL,IAAI,EAAE,EAAE;EACRC,OAAO,EAAE,CAAC;AACZ,CAAC,EACD;EACEL,IAAI,EAAE,gBAAgB;EACtBC,KAAK,EAAE,oBAAoB;EAC3BC,IAAI,EAAEJ,aAAa,CAACY,cAAc;EAClCN,IAAI,EAAE,EAAE;EACRC,OAAO,EAAE,CAAC;AACZ,CAAC,EACD;EACEL,IAAI,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CAAC,EACD;EACEL,IAAI,EAAE,mBAAmB;EACzBC,KAAK,EAAE,qBAAqB;EAC5BC,IAAI,EAAEJ,aAAa,CAACqB,iBAAiB;EACrCf,IAAI,EAAE,iCAAiC;EACvCC,OAAO,EAAE,CAAC;AACZ,CAAC,EACD;EACEL,IAAI,EAAE,MAAM;EACZC,KAAK,EAAE,MAAM;EACbC,IAAI,EAAEJ,aAAa,CAACsB,IAAI;EACxBC,OAAO,EAAE,EAAE;EACXhB,OAAO,EAAE,CAAC;AACZ,CAAC,EACD;EACEL,IAAI,EAAE,WAAW;EACjBC,KAAK,EAAE,YAAY;EACnBC,IAAI,EAAEJ,aAAa,CAACwB,SAAS;EAC7BD,OAAO,EAAE;AACX,CAAC,EACD;EACErB,IAAI,EAAE,SAAS;EACfC,KAAK,EAAE,SAAS;EAChBC,IAAI,EAAEJ,aAAa,CAACyB,OAAO;EAC3BF,OAAO,EAAE,EAAE;EACXhB,OAAO,EAAE,CAAC;AACZ,CAAC,EACD;EACEL,IAAI,EAAE,MAAM;EACZC,KAAK,EAAE,MAAM;EACbC,IAAI,EAAEJ,aAAa,CAAC0B,IAAI;EACxBZ,IAAI,EAAE,EAAE;EACRP,OAAO,EAAE,CAAC;AACZ,CAAC,CACF","ignoreList":[]}
|
@@ -42,6 +42,16 @@ export function isContentType(type) {
|
|
42
42
|
return !!type && allowedTypes.includes(type);
|
43
43
|
}
|
44
44
|
|
45
|
+
/**
|
46
|
+
* Filter known components with form fields
|
47
|
+
*/
|
48
|
+
export function hasFormField(component) {
|
49
|
+
return isFormType(component?.type);
|
50
|
+
}
|
51
|
+
export function isFormType(type) {
|
52
|
+
return !!type && !isContentType(type);
|
53
|
+
}
|
54
|
+
|
45
55
|
/**
|
46
56
|
* Filter known components with lists
|
47
57
|
*/
|
@@ -68,4 +78,11 @@ export function hasTitle(component) {
|
|
68
78
|
const deniedTypes = [ComponentType.InsetText, ComponentType.Html];
|
69
79
|
return !!component?.type && !deniedTypes.includes(component.type);
|
70
80
|
}
|
81
|
+
|
82
|
+
/**
|
83
|
+
* Filter known components with hint text
|
84
|
+
*/
|
85
|
+
export function hasHint(component) {
|
86
|
+
return isFormType(component?.type) || component?.type === ComponentType.List;
|
87
|
+
}
|
71
88
|
//# sourceMappingURL=helpers.js.map
|
@@ -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","hasListField","isListType","hasSelectionFields","hasTitle"],"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 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 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"],"mappings":"AAAA,SAASA,cAAc;AACvB,SAASC,aAAa;
|
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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MAAMuB,WAAW,GAAG,CAACzB,aAAa,CAAC2B,SAAS,EAAE3B,aAAa,CAACmB,IAAI,CAAC;EACjE,OAAO,CAAC,CAACjB,SAAS,EAAEC,IAAI,IAAI,CAACsB,WAAW,CAACJ,QAAQ,CAACnB,SAAS,CAACC,IAAI,CAAC;AACnE;;AAEA;AACA;AACA;AACA,OAAO,SAAS+B,OAAOA,CACrBhC,SAAiC,EACe;EAChD,OAAO2B,UAAU,CAAC3B,SAAS,EAAEC,IAAI,CAAC,IAAID,SAAS,EAAEC,IAAI,KAAKH,aAAa,CAAC0B,IAAI;AAC9E","ignoreList":[]}
|
@@ -1,4 +1,4 @@
|
|
1
1
|
export { ComponentTypes } from "./component-types.js";
|
2
|
-
export { getComponentDefaults, hasConditionSupport, hasContent, hasContentField, hasListField, hasSelectionFields, hasTitle, isConditionalType, isListType } from "./helpers.js";
|
2
|
+
export { getComponentDefaults, hasConditionSupport, hasContent, hasContentField, hasFormField, hasHint, hasListField, 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","hasListField","hasSelectionFields","hasTitle","isConditionalType","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 hasListField,\n hasSelectionFields,\n hasTitle,\n isConditionalType,\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,kBAAkB,EAClBC,QAAQ,EACRC,iBAAiB,EACjBC,UAAU;AAGZ,SAASC,aAAa","ignoreList":[]}
|
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 +1 @@
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../../../src/components/types.ts"],"sourcesContent":["import { type ComponentType } from '~/src/components/enums.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 */\
|
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 DatePartsFieldFieldComponent 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 | DatePartsFieldFieldComponent\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
|
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?:\n | 'StartPageController'\n | 'FileUploadPageController'\n | 'SummaryPageController'\n components?: ComponentDef[]\n section?: string\n next?: Link[]\n}\n\nexport interface PageWithNext extends PageBase {\n controller?: Exclude<PageBase['controller'], 'SummaryPageController'>\n next: Link[]\n}\n\nexport interface PageWithComponents extends PageBase {\n components: ComponentDef[]\n}\n\nexport type Page = PageWithComponents | PageWithNext | PageBase\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 +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,YAAY,EA8HxC,CAAA"}
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { ComponentType } from '../components/enums.js';
|
2
|
-
import { type ComponentDef, type ConditionalComponentsDef, type ConditionalComponentType, type ContentComponentsDef, 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 InsetTextComponent, type ListComponent, type ListComponentsDef, type SelectionComponentsDef } from '../components/types.js';
|
3
3
|
/**
|
4
4
|
* Return component defaults by type
|
5
5
|
*/
|
@@ -18,6 +18,11 @@ export declare function hasContent(component?: Partial<ComponentDef>): component
|
|
18
18
|
*/
|
19
19
|
export declare function hasContentField(component?: Partial<ComponentDef>): component is Exclude<ContentComponentsDef, ListComponent>;
|
20
20
|
export declare function isContentType(type?: ComponentType): type is ContentComponentsDef['type'];
|
21
|
+
/**
|
22
|
+
* Filter known components with form fields
|
23
|
+
*/
|
24
|
+
export declare function hasFormField(component?: Partial<ComponentDef>): component is FormComponentsDef;
|
25
|
+
export declare function isFormType(type?: ComponentType): type is FormComponentsDef['type'];
|
21
26
|
/**
|
22
27
|
* Filter known components with lists
|
23
28
|
*/
|
@@ -31,4 +36,8 @@ export declare function hasSelectionFields(component?: Partial<ComponentDef>): c
|
|
31
36
|
* Filter known components with titles
|
32
37
|
*/
|
33
38
|
export declare function hasTitle(component?: Partial<ComponentDef>): component is Exclude<ComponentDef, InsetTextComponent | HtmlComponent>;
|
39
|
+
/**
|
40
|
+
* Filter known components with hint text
|
41
|
+
*/
|
42
|
+
export declare function hasHint(component?: Partial<ComponentDef>): component is FormComponentsDef | ListComponent;
|
34
43
|
//# sourceMappingURL=helpers.d.ts.map
|
@@ -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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hC;AAED,wBAAgB,UAAU,CACxB,IAAI,CAAC,EAAE,aAAa,GACnB,IAAI,IAAI,iBAAiB,CAAC,MAAM,CAAC,CAEnC;AAED;;GAEG;AACH,wBAAgB,YAAY,CAC1B,SAAS,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,GAChC,SAAS,IAAI,iBAAiB,CAEhC;AAED,wBAAgB,UAAU,CACxB,IAAI,CAAC,EAAE,aAAa,GACnB,IAAI,IAAI,iBAAiB,CAAC,MAAM,CAAC,CAUnC;AAED;;GAEG;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, hasListField, hasSelectionFields, hasTitle, isConditionalType, isListType } from '../components/helpers.js';
|
2
|
+
export { getComponentDefaults, hasConditionSupport, hasContent, hasContentField, hasFormField, hasHint, hasListField, 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,kBAAkB,EAClB,QAAQ,EACR,iBAAiB,EACjB,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,kBAAkB,EAClB,QAAQ,EACR,iBAAiB,EACjB,aAAa,EACb,UAAU,EACV,UAAU,EACX,MAAM,6BAA6B,CAAA;AAEpC,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA"}
|
@@ -1,10 +1,11 @@
|
|
1
1
|
import { type ComponentType } from '../components/enums.js';
|
2
|
+
import { type ListTypeOption, type ListTypeContent } from '../form/form-definition/types.js';
|
2
3
|
export type ConditionalComponentType = Exclude<ConditionalComponentsDef['type'], ContentComponentsDef>;
|
3
4
|
/**
|
4
5
|
* Types for Components JSON structure which are expected by engine and turned into actual form input/content/lists
|
5
6
|
*/
|
6
|
-
interface
|
7
|
-
type:
|
7
|
+
interface FormFieldBase {
|
8
|
+
type: FormComponentsDef['type'];
|
8
9
|
name: string;
|
9
10
|
title: string;
|
10
11
|
hint?: string;
|
@@ -12,59 +13,19 @@ interface TextFieldBase {
|
|
12
13
|
required?: boolean;
|
13
14
|
optionalText?: boolean;
|
14
15
|
classes?: string;
|
15
|
-
allow?: string;
|
16
|
-
autocomplete?: string;
|
17
|
-
};
|
18
|
-
schema: {
|
19
|
-
max?: number;
|
20
|
-
min?: number;
|
21
|
-
length?: number;
|
22
|
-
regex?: string;
|
23
|
-
error?: unknown;
|
24
|
-
};
|
25
|
-
}
|
26
|
-
interface NumberFieldBase {
|
27
|
-
type: ComponentType;
|
28
|
-
name: string;
|
29
|
-
title: string;
|
30
|
-
hint?: string;
|
31
|
-
options: {
|
32
|
-
required?: boolean;
|
33
|
-
optionalText?: boolean;
|
34
|
-
classes?: string;
|
35
|
-
prefix?: string;
|
36
|
-
suffix?: string;
|
37
|
-
};
|
38
|
-
schema: {
|
39
|
-
min?: number;
|
40
|
-
max?: number;
|
41
|
-
precision?: number;
|
42
16
|
};
|
43
17
|
}
|
44
|
-
interface ListFieldBase {
|
45
|
-
type: ComponentType.AutocompleteField | ComponentType.CheckboxesField | ComponentType.
|
46
|
-
name: string;
|
47
|
-
title: string;
|
48
|
-
hint?: string;
|
49
|
-
options: {
|
50
|
-
type?: string;
|
51
|
-
required?: boolean;
|
52
|
-
optionalText?: boolean;
|
53
|
-
classes?: string;
|
54
|
-
bold?: boolean;
|
55
|
-
};
|
18
|
+
interface ListFieldBase extends FormFieldBase {
|
19
|
+
type: ComponentType.AutocompleteField | ComponentType.CheckboxesField | ComponentType.RadiosField | ComponentType.SelectField;
|
56
20
|
list: string;
|
57
|
-
|
21
|
+
options: FormFieldBase['options'] & {
|
22
|
+
type?: ListTypeContent;
|
23
|
+
};
|
58
24
|
}
|
59
25
|
interface ContentFieldBase {
|
60
|
-
type: ComponentType.Details | ComponentType.Html | ComponentType.InsetText;
|
26
|
+
type: ComponentType.Details | ComponentType.Html | ComponentType.InsetText | ComponentType.List;
|
61
27
|
name: string;
|
62
28
|
title: string;
|
63
|
-
content: string;
|
64
|
-
options: {
|
65
|
-
condition?: string;
|
66
|
-
};
|
67
|
-
schema: object;
|
68
29
|
}
|
69
30
|
interface DateFieldBase {
|
70
31
|
type: ComponentType.DatePartsField | ComponentType.MonthYearField;
|
@@ -74,35 +35,49 @@ interface DateFieldBase {
|
|
74
35
|
options: {
|
75
36
|
required?: boolean;
|
76
37
|
optionalText?: boolean;
|
38
|
+
classes?: string;
|
77
39
|
maxDaysInPast?: number;
|
78
40
|
maxDaysInFuture?: number;
|
79
41
|
};
|
80
|
-
schema: object;
|
81
42
|
}
|
82
|
-
export interface TextFieldComponent extends
|
43
|
+
export interface TextFieldComponent extends FormFieldBase {
|
83
44
|
type: ComponentType.TextField;
|
84
|
-
options:
|
45
|
+
options: FormFieldBase['options'] & {
|
46
|
+
autocomplete?: string;
|
85
47
|
condition?: string;
|
86
48
|
customValidationMessage?: string;
|
87
49
|
};
|
50
|
+
schema: {
|
51
|
+
max?: number;
|
52
|
+
min?: number;
|
53
|
+
length?: number;
|
54
|
+
regex?: string;
|
55
|
+
};
|
88
56
|
}
|
89
|
-
export interface EmailAddressFieldComponent extends
|
57
|
+
export interface EmailAddressFieldComponent extends FormFieldBase {
|
90
58
|
type: ComponentType.EmailAddressField;
|
91
|
-
options:
|
59
|
+
options: FormFieldBase['options'] & {
|
92
60
|
condition?: string;
|
93
61
|
customValidationMessage?: string;
|
94
62
|
};
|
95
63
|
}
|
96
|
-
export interface NumberFieldComponent extends
|
64
|
+
export interface NumberFieldComponent extends FormFieldBase {
|
97
65
|
type: ComponentType.NumberField;
|
98
|
-
options:
|
66
|
+
options: FormFieldBase['options'] & {
|
67
|
+
prefix?: string;
|
68
|
+
suffix?: string;
|
99
69
|
condition?: string;
|
100
70
|
customValidationMessage?: string;
|
101
71
|
};
|
72
|
+
schema: {
|
73
|
+
max?: number;
|
74
|
+
min?: number;
|
75
|
+
precision?: number;
|
76
|
+
};
|
102
77
|
}
|
103
|
-
export interface TelephoneNumberFieldComponent extends
|
78
|
+
export interface TelephoneNumberFieldComponent extends FormFieldBase {
|
104
79
|
type: ComponentType.TelephoneNumberField;
|
105
|
-
options:
|
80
|
+
options: FormFieldBase['options'] & {
|
106
81
|
condition?: string;
|
107
82
|
customValidationMessage?: string;
|
108
83
|
};
|
@@ -114,6 +89,8 @@ export interface FileUploadFieldComponent {
|
|
114
89
|
hint?: string;
|
115
90
|
options: {
|
116
91
|
required?: boolean;
|
92
|
+
classes?: string;
|
93
|
+
optionalText?: boolean;
|
117
94
|
accept?: string;
|
118
95
|
};
|
119
96
|
schema: {
|
@@ -122,15 +99,15 @@ export interface FileUploadFieldComponent {
|
|
122
99
|
length?: number;
|
123
100
|
};
|
124
101
|
}
|
125
|
-
export interface YesNoFieldComponent extends
|
102
|
+
export interface YesNoFieldComponent extends FormFieldBase {
|
126
103
|
type: ComponentType.YesNoField;
|
127
|
-
options:
|
104
|
+
options: FormFieldBase['options'] & {
|
128
105
|
condition?: string;
|
129
106
|
};
|
130
107
|
}
|
131
|
-
export interface MultilineTextFieldComponent extends
|
108
|
+
export interface MultilineTextFieldComponent extends FormFieldBase {
|
132
109
|
type: ComponentType.MultilineTextField;
|
133
|
-
options:
|
110
|
+
options: FormFieldBase['options'] & {
|
134
111
|
condition?: string;
|
135
112
|
customValidationMessage?: string;
|
136
113
|
rows?: number;
|
@@ -143,9 +120,9 @@ export interface MultilineTextFieldComponent extends TextFieldBase {
|
|
143
120
|
regex?: string;
|
144
121
|
};
|
145
122
|
}
|
146
|
-
export interface UkAddressFieldComponent extends
|
123
|
+
export interface UkAddressFieldComponent extends FormFieldBase {
|
147
124
|
type: ComponentType.UkAddressField;
|
148
|
-
options:
|
125
|
+
options: FormFieldBase['options'] & {
|
149
126
|
hideTitle?: boolean;
|
150
127
|
};
|
151
128
|
}
|
@@ -163,17 +140,31 @@ export interface MonthYearFieldComponent extends DateFieldBase {
|
|
163
140
|
}
|
164
141
|
export interface DetailsComponent extends ContentFieldBase {
|
165
142
|
type: ComponentType.Details;
|
143
|
+
content: string;
|
144
|
+
options: {
|
145
|
+
condition?: string;
|
146
|
+
};
|
166
147
|
}
|
167
148
|
export interface HtmlComponent extends ContentFieldBase {
|
168
149
|
type: ComponentType.Html;
|
150
|
+
content: string;
|
151
|
+
options: {
|
152
|
+
condition?: string;
|
153
|
+
};
|
169
154
|
}
|
170
155
|
export interface InsetTextComponent extends ContentFieldBase {
|
171
156
|
type: ComponentType.InsetText;
|
157
|
+
content: string;
|
172
158
|
}
|
173
|
-
export interface ListComponent extends
|
159
|
+
export interface ListComponent extends ContentFieldBase {
|
174
160
|
type: ComponentType.List;
|
175
|
-
|
161
|
+
hint?: string;
|
162
|
+
list: string;
|
163
|
+
options: {
|
164
|
+
type?: ListTypeOption;
|
165
|
+
classes?: string;
|
176
166
|
hideTitle?: boolean;
|
167
|
+
bold?: boolean;
|
177
168
|
};
|
178
169
|
}
|
179
170
|
export interface AutocompleteFieldComponent extends ListFieldBase {
|
@@ -185,12 +176,14 @@ export interface AutocompleteFieldComponent extends ListFieldBase {
|
|
185
176
|
export interface CheckboxesFieldComponent extends ListFieldBase {
|
186
177
|
type: ComponentType.CheckboxesField;
|
187
178
|
options: ListFieldBase['options'] & {
|
179
|
+
bold?: boolean;
|
188
180
|
condition?: string;
|
189
181
|
};
|
190
182
|
}
|
191
183
|
export interface RadiosFieldComponent extends ListFieldBase {
|
192
184
|
type: ComponentType.RadiosField;
|
193
185
|
options: ListFieldBase['options'] & {
|
186
|
+
bold?: boolean;
|
194
187
|
condition?: string;
|
195
188
|
};
|
196
189
|
}
|
@@ -201,11 +194,12 @@ export interface SelectFieldComponent extends ListFieldBase {
|
|
201
194
|
condition?: string;
|
202
195
|
};
|
203
196
|
}
|
204
|
-
export type ComponentDef =
|
197
|
+
export type ComponentDef = FormComponentsDef | ContentComponentsDef;
|
198
|
+
export type FormComponentsDef = InputFieldsComponentsDef | SelectionComponentsDef;
|
205
199
|
export type InputFieldsComponentsDef = TextFieldComponent | EmailAddressFieldComponent | NumberFieldComponent | MultilineTextFieldComponent | TelephoneNumberFieldComponent | MonthYearFieldComponent | DatePartsFieldFieldComponent | UkAddressFieldComponent | FileUploadFieldComponent;
|
206
200
|
export type ContentComponentsDef = DetailsComponent | HtmlComponent | InsetTextComponent | ListComponent;
|
207
201
|
export type ListComponentsDef = Exclude<SelectionComponentsDef, YesNoFieldComponent> | ListComponent;
|
208
202
|
export type SelectionComponentsDef = AutocompleteFieldComponent | CheckboxesFieldComponent | RadiosFieldComponent | SelectFieldComponent | YesNoFieldComponent;
|
209
|
-
export type ConditionalComponentsDef = Exclude<ComponentDef, InsetTextComponent | ListComponent | MonthYearFieldComponent | UkAddressFieldComponent>;
|
203
|
+
export type ConditionalComponentsDef = Exclude<ComponentDef, InsetTextComponent | ListComponent | MonthYearFieldComponent | UkAddressFieldComponent | FileUploadFieldComponent>;
|
210
204
|
export {};
|
211
205
|
//# sourceMappingURL=types.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,2BAA2B,CAAA;
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,2BAA2B,CAAA;AAC9D,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,eAAe,EACrB,MAAM,qCAAqC,CAAA;AAE5C,MAAM,MAAM,wBAAwB,GAAG,OAAO,CAC5C,wBAAwB,CAAC,MAAM,CAAC,EAChC,oBAAoB,CACrB,CAAA;AAED;;GAEG;AAEH,UAAU,aAAa;IACrB,IAAI,EAAE,iBAAiB,CAAC,MAAM,CAAC,CAAA;IAC/B,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,OAAO,EAAE;QACP,QAAQ,CAAC,EAAE,OAAO,CAAA;QAClB,YAAY,CAAC,EAAE,OAAO,CAAA;QACtB,OAAO,CAAC,EAAE,MAAM,CAAA;KACjB,CAAA;CACF;AAED,UAAU,aAAc,SAAQ,aAAa;IAC3C,IAAI,EACA,aAAa,CAAC,iBAAiB,GAC/B,aAAa,CAAC,eAAe,GAC7B,aAAa,CAAC,WAAW,GACzB,aAAa,CAAC,WAAW,CAAA;IAC7B,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,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WAAW,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,4BAA4B,GAC5B,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"}
|
@@ -5,14 +5,22 @@ export interface Link {
|
|
5
5
|
condition?: string;
|
6
6
|
redirect?: string;
|
7
7
|
}
|
8
|
-
export interface
|
8
|
+
export interface PageBase {
|
9
9
|
title: string;
|
10
10
|
path: string;
|
11
|
-
controller?:
|
11
|
+
controller?: 'StartPageController' | 'FileUploadPageController' | 'SummaryPageController';
|
12
12
|
components?: ComponentDef[];
|
13
13
|
section?: string;
|
14
14
|
next?: Link[];
|
15
15
|
}
|
16
|
+
export interface PageWithNext extends PageBase {
|
17
|
+
controller?: Exclude<PageBase['controller'], 'SummaryPageController'>;
|
18
|
+
next: Link[];
|
19
|
+
}
|
20
|
+
export interface PageWithComponents extends PageBase {
|
21
|
+
components: ComponentDef[];
|
22
|
+
}
|
23
|
+
export type Page = PageWithComponents | PageWithNext | PageBase;
|
16
24
|
export interface Section {
|
17
25
|
name: string;
|
18
26
|
title: string;
|
@@ -30,9 +38,11 @@ export interface Item {
|
|
30
38
|
export interface List {
|
31
39
|
name: string;
|
32
40
|
title: string;
|
33
|
-
type:
|
41
|
+
type: ListTypeContent;
|
34
42
|
items: Item[];
|
35
43
|
}
|
44
|
+
export type ListTypeOption = 'bulleted' | 'numbered';
|
45
|
+
export type ListTypeContent = 'string' | 'number' | 'boolean';
|
36
46
|
export interface Feedback {
|
37
47
|
feedbackForm?: boolean;
|
38
48
|
url?: string;
|
@@ -56,7 +66,7 @@ export interface FormDefinition {
|
|
56
66
|
conditions: ConditionWrapper[];
|
57
67
|
lists: List[];
|
58
68
|
sections: Section[];
|
59
|
-
startPage?:
|
69
|
+
startPage?: string;
|
60
70
|
name?: string;
|
61
71
|
feedback?: Feedback;
|
62
72
|
phaseBanner?: PhaseBanner;
|
@@ -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,2BAA2B,CAAA;AAGpE,MAAM,WAAW,IAAI;IACnB,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,QAAQ,CAAC,EAA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O,CAAC,CAAA;IAClC,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB"}
|
package/package.json
CHANGED
@@ -26,60 +26,53 @@ export const ComponentTypes: ComponentDef[] = [
|
|
26
26
|
title: 'Yes/No field',
|
27
27
|
type: ComponentType.YesNoField,
|
28
28
|
hint: '',
|
29
|
-
options: {}
|
30
|
-
schema: {}
|
29
|
+
options: {}
|
31
30
|
},
|
32
31
|
{
|
33
32
|
name: 'DatePartsField',
|
34
33
|
title: 'Date field',
|
35
34
|
type: ComponentType.DatePartsField,
|
36
35
|
hint: '',
|
37
|
-
options: {}
|
38
|
-
schema: {}
|
36
|
+
options: {}
|
39
37
|
},
|
40
38
|
{
|
41
39
|
name: 'MonthYearField',
|
42
40
|
title: 'Month & year field',
|
43
41
|
type: ComponentType.MonthYearField,
|
44
42
|
hint: '',
|
45
|
-
options: {}
|
46
|
-
schema: {}
|
43
|
+
options: {}
|
47
44
|
},
|
48
45
|
{
|
49
46
|
name: 'SelectField',
|
50
47
|
title: 'Select field',
|
51
48
|
type: ComponentType.SelectField,
|
52
49
|
hint: '',
|
53
|
-
|
54
|
-
|
55
|
-
list: ''
|
50
|
+
list: '',
|
51
|
+
options: {}
|
56
52
|
},
|
57
53
|
{
|
58
54
|
name: 'AutocompleteField',
|
59
55
|
title: 'Autocomplete field',
|
60
56
|
type: ComponentType.AutocompleteField,
|
61
57
|
hint: '',
|
62
|
-
|
63
|
-
|
64
|
-
list: ''
|
58
|
+
list: '',
|
59
|
+
options: {}
|
65
60
|
},
|
66
61
|
{
|
67
62
|
name: 'RadiosField',
|
68
63
|
title: 'Radios field',
|
69
64
|
type: ComponentType.RadiosField,
|
70
65
|
hint: '',
|
71
|
-
|
72
|
-
|
73
|
-
list: ''
|
66
|
+
list: '',
|
67
|
+
options: {}
|
74
68
|
},
|
75
69
|
{
|
76
70
|
name: 'CheckboxesField',
|
77
71
|
title: 'Checkboxes field',
|
78
72
|
type: ComponentType.CheckboxesField,
|
79
73
|
hint: '',
|
80
|
-
|
81
|
-
|
82
|
-
list: ''
|
74
|
+
list: '',
|
75
|
+
options: {}
|
83
76
|
},
|
84
77
|
{
|
85
78
|
name: 'NumberField',
|
@@ -94,55 +87,47 @@ export const ComponentTypes: ComponentDef[] = [
|
|
94
87
|
title: 'UK address field',
|
95
88
|
type: ComponentType.UkAddressField,
|
96
89
|
hint: '',
|
97
|
-
options: {}
|
98
|
-
schema: {}
|
90
|
+
options: {}
|
99
91
|
},
|
100
92
|
{
|
101
93
|
name: 'TelephoneNumberField',
|
102
94
|
title: 'Telephone number field',
|
103
95
|
type: ComponentType.TelephoneNumberField,
|
104
96
|
hint: '',
|
105
|
-
options: {}
|
106
|
-
schema: {}
|
97
|
+
options: {}
|
107
98
|
},
|
108
99
|
{
|
109
100
|
name: 'EmailAddressField',
|
110
101
|
title: 'Email address field',
|
111
102
|
type: ComponentType.EmailAddressField,
|
112
103
|
hint: 'For example, ‘name@example.com’',
|
113
|
-
options: {}
|
114
|
-
schema: {}
|
104
|
+
options: {}
|
115
105
|
},
|
116
106
|
{
|
117
107
|
name: 'Html',
|
118
108
|
title: 'Html',
|
119
109
|
type: ComponentType.Html,
|
120
110
|
content: '',
|
121
|
-
options: {}
|
122
|
-
schema: {}
|
111
|
+
options: {}
|
123
112
|
},
|
124
113
|
{
|
125
114
|
name: 'InsetText',
|
126
115
|
title: 'Inset text',
|
127
116
|
type: ComponentType.InsetText,
|
128
|
-
content: ''
|
129
|
-
options: {},
|
130
|
-
schema: {}
|
117
|
+
content: ''
|
131
118
|
},
|
132
119
|
{
|
133
120
|
name: 'Details',
|
134
121
|
title: 'Details',
|
135
122
|
type: ComponentType.Details,
|
136
123
|
content: '',
|
137
|
-
options: {}
|
138
|
-
schema: {}
|
124
|
+
options: {}
|
139
125
|
},
|
140
126
|
{
|
141
127
|
name: 'List',
|
142
128
|
title: 'List',
|
143
129
|
type: ComponentType.List,
|
144
|
-
|
145
|
-
|
146
|
-
list: ''
|
130
|
+
list: '',
|
131
|
+
options: {}
|
147
132
|
}
|
148
133
|
]
|
@@ -5,6 +5,7 @@ import {
|
|
5
5
|
type ConditionalComponentsDef,
|
6
6
|
type ConditionalComponentType,
|
7
7
|
type ContentComponentsDef,
|
8
|
+
type FormComponentsDef,
|
8
9
|
type HtmlComponent,
|
9
10
|
type InsetTextComponent,
|
10
11
|
type ListComponent,
|
@@ -86,6 +87,21 @@ export function isContentType(
|
|
86
87
|
return !!type && allowedTypes.includes(type)
|
87
88
|
}
|
88
89
|
|
90
|
+
/**
|
91
|
+
* Filter known components with form fields
|
92
|
+
*/
|
93
|
+
export function hasFormField(
|
94
|
+
component?: Partial<ComponentDef>
|
95
|
+
): component is FormComponentsDef {
|
96
|
+
return isFormType(component?.type)
|
97
|
+
}
|
98
|
+
|
99
|
+
export function isFormType(
|
100
|
+
type?: ComponentType
|
101
|
+
): type is FormComponentsDef['type'] {
|
102
|
+
return !!type && !isContentType(type)
|
103
|
+
}
|
104
|
+
|
89
105
|
/**
|
90
106
|
* Filter known components with lists
|
91
107
|
*/
|
@@ -135,3 +151,12 @@ export function hasTitle(
|
|
135
151
|
const deniedTypes = [ComponentType.InsetText, ComponentType.Html]
|
136
152
|
return !!component?.type && !deniedTypes.includes(component.type)
|
137
153
|
}
|
154
|
+
|
155
|
+
/**
|
156
|
+
* Filter known components with hint text
|
157
|
+
*/
|
158
|
+
export function hasHint(
|
159
|
+
component?: Partial<ComponentDef>
|
160
|
+
): component is FormComponentsDef | ListComponent {
|
161
|
+
return isFormType(component?.type) || component?.type === ComponentType.List
|
162
|
+
}
|
package/src/components/index.ts
CHANGED
@@ -4,10 +4,14 @@ export {
|
|
4
4
|
hasConditionSupport,
|
5
5
|
hasContent,
|
6
6
|
hasContentField,
|
7
|
+
hasFormField,
|
8
|
+
hasHint,
|
7
9
|
hasListField,
|
8
10
|
hasSelectionFields,
|
9
11
|
hasTitle,
|
10
12
|
isConditionalType,
|
13
|
+
isContentType,
|
14
|
+
isFormType,
|
11
15
|
isListType
|
12
16
|
} from '~/src/components/helpers.js'
|
13
17
|
|
package/src/components/types.ts
CHANGED
@@ -1,4 +1,8 @@
|
|
1
1
|
import { type ComponentType } from '~/src/components/enums.js'
|
2
|
+
import {
|
3
|
+
type ListTypeOption,
|
4
|
+
type ListTypeContent
|
5
|
+
} from '~/src/form/form-definition/types.js'
|
2
6
|
|
3
7
|
export type ConditionalComponentType = Exclude<
|
4
8
|
ConditionalComponentsDef['type'],
|
@@ -8,36 +12,9 @@ export type ConditionalComponentType = Exclude<
|
|
8
12
|
/**
|
9
13
|
* Types for Components JSON structure which are expected by engine and turned into actual form input/content/lists
|
10
14
|
*/
|
11
|
-
interface TextFieldBase {
|
12
|
-
type:
|
13
|
-
| ComponentType.EmailAddressField
|
14
|
-
| ComponentType.MultilineTextField
|
15
|
-
| ComponentType.NumberField
|
16
|
-
| ComponentType.TelephoneNumberField
|
17
|
-
| ComponentType.TextField
|
18
|
-
| ComponentType.UkAddressField
|
19
|
-
| ComponentType.YesNoField
|
20
|
-
name: string
|
21
|
-
title: string
|
22
|
-
hint?: string
|
23
|
-
options: {
|
24
|
-
required?: boolean
|
25
|
-
optionalText?: boolean
|
26
|
-
classes?: string
|
27
|
-
allow?: string
|
28
|
-
autocomplete?: string
|
29
|
-
}
|
30
|
-
schema: {
|
31
|
-
max?: number
|
32
|
-
min?: number
|
33
|
-
length?: number
|
34
|
-
regex?: string
|
35
|
-
error?: unknown
|
36
|
-
}
|
37
|
-
}
|
38
15
|
|
39
|
-
interface
|
40
|
-
type:
|
16
|
+
interface FormFieldBase {
|
17
|
+
type: FormComponentsDef['type']
|
41
18
|
name: string
|
42
19
|
title: string
|
43
20
|
hint?: string
|
@@ -45,46 +22,29 @@ interface NumberFieldBase {
|
|
45
22
|
required?: boolean
|
46
23
|
optionalText?: boolean
|
47
24
|
classes?: string
|
48
|
-
prefix?: string
|
49
|
-
suffix?: string
|
50
|
-
}
|
51
|
-
schema: {
|
52
|
-
min?: number
|
53
|
-
max?: number
|
54
|
-
precision?: number
|
55
25
|
}
|
56
26
|
}
|
57
27
|
|
58
|
-
interface ListFieldBase {
|
28
|
+
interface ListFieldBase extends FormFieldBase {
|
59
29
|
type:
|
60
30
|
| ComponentType.AutocompleteField
|
61
31
|
| ComponentType.CheckboxesField
|
62
|
-
| ComponentType.List
|
63
32
|
| ComponentType.RadiosField
|
64
33
|
| ComponentType.SelectField
|
65
|
-
name: string
|
66
|
-
title: string
|
67
|
-
hint?: string
|
68
|
-
options: {
|
69
|
-
type?: string
|
70
|
-
required?: boolean
|
71
|
-
optionalText?: boolean
|
72
|
-
classes?: string
|
73
|
-
bold?: boolean
|
74
|
-
}
|
75
34
|
list: string
|
76
|
-
|
35
|
+
options: FormFieldBase['options'] & {
|
36
|
+
type?: ListTypeContent
|
37
|
+
}
|
77
38
|
}
|
78
39
|
|
79
40
|
interface ContentFieldBase {
|
80
|
-
type:
|
41
|
+
type:
|
42
|
+
| ComponentType.Details
|
43
|
+
| ComponentType.Html
|
44
|
+
| ComponentType.InsetText
|
45
|
+
| ComponentType.List
|
81
46
|
name: string
|
82
47
|
title: string
|
83
|
-
content: string
|
84
|
-
options: {
|
85
|
-
condition?: string
|
86
|
-
}
|
87
|
-
schema: object
|
88
48
|
}
|
89
49
|
|
90
50
|
interface DateFieldBase {
|
@@ -95,40 +55,54 @@ interface DateFieldBase {
|
|
95
55
|
options: {
|
96
56
|
required?: boolean
|
97
57
|
optionalText?: boolean
|
58
|
+
classes?: string
|
98
59
|
maxDaysInPast?: number
|
99
60
|
maxDaysInFuture?: number
|
100
61
|
}
|
101
|
-
schema: object
|
102
62
|
}
|
103
63
|
|
104
64
|
// Text Fields
|
105
|
-
export interface TextFieldComponent extends
|
65
|
+
export interface TextFieldComponent extends FormFieldBase {
|
106
66
|
type: ComponentType.TextField
|
107
|
-
options:
|
67
|
+
options: FormFieldBase['options'] & {
|
68
|
+
autocomplete?: string
|
108
69
|
condition?: string
|
109
70
|
customValidationMessage?: string
|
110
71
|
}
|
72
|
+
schema: {
|
73
|
+
max?: number
|
74
|
+
min?: number
|
75
|
+
length?: number
|
76
|
+
regex?: string
|
77
|
+
}
|
111
78
|
}
|
112
79
|
|
113
|
-
export interface EmailAddressFieldComponent extends
|
80
|
+
export interface EmailAddressFieldComponent extends FormFieldBase {
|
114
81
|
type: ComponentType.EmailAddressField
|
115
|
-
options:
|
82
|
+
options: FormFieldBase['options'] & {
|
116
83
|
condition?: string
|
117
84
|
customValidationMessage?: string
|
118
85
|
}
|
119
86
|
}
|
120
87
|
|
121
|
-
export interface NumberFieldComponent extends
|
88
|
+
export interface NumberFieldComponent extends FormFieldBase {
|
122
89
|
type: ComponentType.NumberField
|
123
|
-
options:
|
90
|
+
options: FormFieldBase['options'] & {
|
91
|
+
prefix?: string
|
92
|
+
suffix?: string
|
124
93
|
condition?: string
|
125
94
|
customValidationMessage?: string
|
126
95
|
}
|
96
|
+
schema: {
|
97
|
+
max?: number
|
98
|
+
min?: number
|
99
|
+
precision?: number
|
100
|
+
}
|
127
101
|
}
|
128
102
|
|
129
|
-
export interface TelephoneNumberFieldComponent extends
|
103
|
+
export interface TelephoneNumberFieldComponent extends FormFieldBase {
|
130
104
|
type: ComponentType.TelephoneNumberField
|
131
|
-
options:
|
105
|
+
options: FormFieldBase['options'] & {
|
132
106
|
condition?: string
|
133
107
|
customValidationMessage?: string
|
134
108
|
}
|
@@ -141,6 +115,8 @@ export interface FileUploadFieldComponent {
|
|
141
115
|
hint?: string
|
142
116
|
options: {
|
143
117
|
required?: boolean
|
118
|
+
classes?: string
|
119
|
+
optionalText?: boolean
|
144
120
|
accept?: string
|
145
121
|
}
|
146
122
|
schema: {
|
@@ -150,16 +126,16 @@ export interface FileUploadFieldComponent {
|
|
150
126
|
}
|
151
127
|
}
|
152
128
|
|
153
|
-
export interface YesNoFieldComponent extends
|
129
|
+
export interface YesNoFieldComponent extends FormFieldBase {
|
154
130
|
type: ComponentType.YesNoField
|
155
|
-
options:
|
131
|
+
options: FormFieldBase['options'] & {
|
156
132
|
condition?: string
|
157
133
|
}
|
158
134
|
}
|
159
135
|
|
160
|
-
export interface MultilineTextFieldComponent extends
|
136
|
+
export interface MultilineTextFieldComponent extends FormFieldBase {
|
161
137
|
type: ComponentType.MultilineTextField
|
162
|
-
options:
|
138
|
+
options: FormFieldBase['options'] & {
|
163
139
|
condition?: string
|
164
140
|
customValidationMessage?: string
|
165
141
|
rows?: number
|
@@ -173,9 +149,9 @@ export interface MultilineTextFieldComponent extends TextFieldBase {
|
|
173
149
|
}
|
174
150
|
}
|
175
151
|
|
176
|
-
export interface UkAddressFieldComponent extends
|
152
|
+
export interface UkAddressFieldComponent extends FormFieldBase {
|
177
153
|
type: ComponentType.UkAddressField
|
178
|
-
options:
|
154
|
+
options: FormFieldBase['options'] & {
|
179
155
|
hideTitle?: boolean
|
180
156
|
}
|
181
157
|
}
|
@@ -198,21 +174,34 @@ export interface MonthYearFieldComponent extends DateFieldBase {
|
|
198
174
|
// Content Fields
|
199
175
|
export interface DetailsComponent extends ContentFieldBase {
|
200
176
|
type: ComponentType.Details
|
177
|
+
content: string
|
178
|
+
options: {
|
179
|
+
condition?: string
|
180
|
+
}
|
201
181
|
}
|
202
182
|
|
203
183
|
export interface HtmlComponent extends ContentFieldBase {
|
204
184
|
type: ComponentType.Html
|
185
|
+
content: string
|
186
|
+
options: {
|
187
|
+
condition?: string
|
188
|
+
}
|
205
189
|
}
|
206
190
|
|
207
191
|
export interface InsetTextComponent extends ContentFieldBase {
|
208
192
|
type: ComponentType.InsetText
|
193
|
+
content: string
|
209
194
|
}
|
210
195
|
|
211
|
-
|
212
|
-
export interface ListComponent extends ListFieldBase {
|
196
|
+
export interface ListComponent extends ContentFieldBase {
|
213
197
|
type: ComponentType.List
|
214
|
-
|
198
|
+
hint?: string
|
199
|
+
list: string
|
200
|
+
options: {
|
201
|
+
type?: ListTypeOption
|
202
|
+
classes?: string
|
215
203
|
hideTitle?: boolean
|
204
|
+
bold?: boolean
|
216
205
|
}
|
217
206
|
}
|
218
207
|
|
@@ -226,6 +215,7 @@ export interface AutocompleteFieldComponent extends ListFieldBase {
|
|
226
215
|
export interface CheckboxesFieldComponent extends ListFieldBase {
|
227
216
|
type: ComponentType.CheckboxesField
|
228
217
|
options: ListFieldBase['options'] & {
|
218
|
+
bold?: boolean
|
229
219
|
condition?: string
|
230
220
|
}
|
231
221
|
}
|
@@ -233,6 +223,7 @@ export interface CheckboxesFieldComponent extends ListFieldBase {
|
|
233
223
|
export interface RadiosFieldComponent extends ListFieldBase {
|
234
224
|
type: ComponentType.RadiosField
|
235
225
|
options: ListFieldBase['options'] & {
|
226
|
+
bold?: boolean
|
236
227
|
condition?: string
|
237
228
|
}
|
238
229
|
}
|
@@ -245,10 +236,12 @@ export interface SelectFieldComponent extends ListFieldBase {
|
|
245
236
|
}
|
246
237
|
}
|
247
238
|
|
248
|
-
export type ComponentDef =
|
239
|
+
export type ComponentDef = FormComponentsDef | ContentComponentsDef
|
240
|
+
|
241
|
+
// Components that render form fields
|
242
|
+
export type FormComponentsDef =
|
249
243
|
| InputFieldsComponentsDef
|
250
244
|
| SelectionComponentsDef
|
251
|
-
| ContentComponentsDef
|
252
245
|
|
253
246
|
// Components that render inputs
|
254
247
|
export type InputFieldsComponentsDef =
|
@@ -289,4 +282,5 @@ export type ConditionalComponentsDef = Exclude<
|
|
289
282
|
| ListComponent
|
290
283
|
| MonthYearFieldComponent
|
291
284
|
| UkAddressFieldComponent
|
285
|
+
| FileUploadFieldComponent
|
292
286
|
>
|
@@ -8,15 +8,29 @@ export interface Link {
|
|
8
8
|
redirect?: string
|
9
9
|
}
|
10
10
|
|
11
|
-
export interface
|
11
|
+
export interface PageBase {
|
12
12
|
title: string
|
13
13
|
path: string
|
14
|
-
controller?:
|
14
|
+
controller?:
|
15
|
+
| 'StartPageController'
|
16
|
+
| 'FileUploadPageController'
|
17
|
+
| 'SummaryPageController'
|
15
18
|
components?: ComponentDef[]
|
16
|
-
section?: string
|
19
|
+
section?: string
|
17
20
|
next?: Link[]
|
18
21
|
}
|
19
22
|
|
23
|
+
export interface PageWithNext extends PageBase {
|
24
|
+
controller?: Exclude<PageBase['controller'], 'SummaryPageController'>
|
25
|
+
next: Link[]
|
26
|
+
}
|
27
|
+
|
28
|
+
export interface PageWithComponents extends PageBase {
|
29
|
+
components: ComponentDef[]
|
30
|
+
}
|
31
|
+
|
32
|
+
export type Page = PageWithComponents | PageWithNext | PageBase
|
33
|
+
|
20
34
|
export interface Section {
|
21
35
|
name: string
|
22
36
|
title: string
|
@@ -34,10 +48,13 @@ export interface Item {
|
|
34
48
|
export interface List {
|
35
49
|
name: string
|
36
50
|
title: string
|
37
|
-
type:
|
51
|
+
type: ListTypeContent
|
38
52
|
items: Item[]
|
39
53
|
}
|
40
54
|
|
55
|
+
export type ListTypeOption = 'bulleted' | 'numbered'
|
56
|
+
export type ListTypeContent = 'string' | 'number' | 'boolean'
|
57
|
+
|
41
58
|
export interface Feedback {
|
42
59
|
feedbackForm?: boolean
|
43
60
|
url?: string
|
@@ -64,7 +81,7 @@ export interface FormDefinition {
|
|
64
81
|
conditions: ConditionWrapper[]
|
65
82
|
lists: List[]
|
66
83
|
sections: Section[]
|
67
|
-
startPage?:
|
84
|
+
startPage?: string
|
68
85
|
name?: string
|
69
86
|
feedback?: Feedback
|
70
87
|
phaseBanner?: PhaseBanner
|