@defra/forms-model 3.0.231 → 3.0.233
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 +22 -18
- package/dist/module/components/component-types.js.map +1 -1
- package/dist/module/components/helpers.js +13 -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/index.js +0 -1
- package/dist/module/form/form-definition/index.js.map +1 -1
- package/dist/types/components/component-types.d.ts +7 -1
- package/dist/types/components/component-types.d.ts.map +1 -1
- package/dist/types/components/helpers.d.ts +6 -0
- 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 +2 -16
- package/dist/types/components/types.d.ts.map +1 -1
- package/dist/types/form/form-definition/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/component-types.ts +25 -19
- package/src/components/helpers.ts +12 -0
- package/src/components/index.ts +1 -0
- package/src/components/types.ts +2 -19
- package/src/form/form-definition/index.ts +1 -5
@@ -1,144 +1,148 @@
|
|
1
1
|
import { ComponentSubType, ComponentType } from "./enums.js";
|
2
|
+
/**
|
3
|
+
* Defaults for creating new components
|
4
|
+
*/
|
2
5
|
export const ComponentTypes = [{
|
3
6
|
name: 'TextField',
|
4
|
-
type: ComponentType.TextField,
|
5
7
|
title: 'Text field',
|
8
|
+
type: ComponentType.TextField,
|
6
9
|
subType: ComponentSubType.Field,
|
7
10
|
hint: '',
|
8
11
|
options: {},
|
9
12
|
schema: {}
|
10
13
|
}, {
|
11
14
|
name: 'MultilineTextField',
|
12
|
-
type: ComponentType.MultilineTextField,
|
13
15
|
title: 'Multiline text field',
|
16
|
+
type: ComponentType.MultilineTextField,
|
14
17
|
subType: ComponentSubType.Field,
|
15
18
|
hint: '',
|
16
19
|
options: {},
|
17
20
|
schema: {}
|
18
21
|
}, {
|
19
22
|
name: 'YesNoField',
|
20
|
-
type: ComponentType.YesNoField,
|
21
23
|
title: 'Yes/No field',
|
24
|
+
type: ComponentType.YesNoField,
|
22
25
|
subType: ComponentSubType.Field,
|
23
26
|
hint: '',
|
24
27
|
options: {},
|
25
28
|
schema: {}
|
26
29
|
}, {
|
27
30
|
name: 'TimeField',
|
28
|
-
type: ComponentType.TimeField,
|
29
31
|
title: 'Time field',
|
32
|
+
type: ComponentType.TimeField,
|
30
33
|
subType: ComponentSubType.Field,
|
31
34
|
hint: '',
|
32
35
|
options: {},
|
33
36
|
schema: {}
|
34
37
|
}, {
|
35
38
|
name: 'DatePartsField',
|
36
|
-
type: ComponentType.DatePartsField,
|
37
39
|
title: 'Date field',
|
40
|
+
type: ComponentType.DatePartsField,
|
38
41
|
subType: ComponentSubType.Field,
|
39
42
|
hint: '',
|
40
43
|
options: {},
|
41
44
|
schema: {}
|
42
45
|
}, {
|
43
46
|
name: 'MonthYearField',
|
44
|
-
type: ComponentType.MonthYearField,
|
45
47
|
title: 'Month & year field',
|
48
|
+
type: ComponentType.MonthYearField,
|
46
49
|
subType: ComponentSubType.Field,
|
47
50
|
hint: '',
|
48
51
|
options: {},
|
49
52
|
schema: {}
|
50
53
|
}, {
|
51
54
|
name: 'SelectField',
|
52
|
-
type: ComponentType.SelectField,
|
53
55
|
title: 'Select field',
|
56
|
+
type: ComponentType.SelectField,
|
54
57
|
subType: ComponentSubType.ListField,
|
55
58
|
options: {},
|
56
59
|
schema: {},
|
57
60
|
list: ''
|
58
61
|
}, {
|
59
62
|
name: 'AutocompleteField',
|
60
|
-
type: ComponentType.AutocompleteField,
|
61
63
|
title: 'Autocomplete field',
|
64
|
+
type: ComponentType.AutocompleteField,
|
62
65
|
subType: ComponentSubType.ListField,
|
63
66
|
options: {},
|
64
67
|
schema: {},
|
65
68
|
list: ''
|
66
69
|
}, {
|
67
70
|
name: 'RadiosField',
|
68
|
-
type: ComponentType.RadiosField,
|
69
71
|
title: 'Radios field',
|
72
|
+
type: ComponentType.RadiosField,
|
70
73
|
subType: ComponentSubType.ListField,
|
71
74
|
options: {},
|
72
75
|
schema: {},
|
73
76
|
list: ''
|
74
77
|
}, {
|
75
78
|
name: 'CheckboxesField',
|
76
|
-
type: ComponentType.CheckboxesField,
|
77
79
|
title: 'Checkboxes field',
|
80
|
+
type: ComponentType.CheckboxesField,
|
78
81
|
subType: ComponentSubType.ListField,
|
79
82
|
options: {},
|
80
83
|
schema: {},
|
81
84
|
list: ''
|
82
85
|
}, {
|
83
86
|
name: 'NumberField',
|
84
|
-
type: ComponentType.NumberField,
|
85
87
|
title: 'Number field',
|
88
|
+
type: ComponentType.NumberField,
|
86
89
|
subType: ComponentSubType.Field,
|
87
90
|
hint: '',
|
88
91
|
options: {},
|
89
92
|
schema: {}
|
90
93
|
}, {
|
91
94
|
name: 'UkAddressField',
|
92
|
-
type: ComponentType.UkAddressField,
|
93
95
|
title: 'UK address field',
|
96
|
+
type: ComponentType.UkAddressField,
|
94
97
|
subType: ComponentSubType.Field,
|
95
98
|
hint: '',
|
96
99
|
options: {},
|
97
100
|
schema: {}
|
98
101
|
}, {
|
99
102
|
name: 'TelephoneNumberField',
|
100
|
-
type: ComponentType.TelephoneNumberField,
|
101
103
|
title: 'Telephone number field',
|
104
|
+
type: ComponentType.TelephoneNumberField,
|
102
105
|
subType: ComponentSubType.Field,
|
103
106
|
hint: '',
|
104
107
|
options: {},
|
105
108
|
schema: {}
|
106
109
|
}, {
|
107
110
|
name: 'EmailAddressField',
|
108
|
-
type: ComponentType.EmailAddressField,
|
109
111
|
title: 'Email address field',
|
112
|
+
type: ComponentType.EmailAddressField,
|
110
113
|
subType: ComponentSubType.Field,
|
111
114
|
hint: '',
|
112
115
|
options: {},
|
113
116
|
schema: {}
|
114
117
|
}, {
|
115
118
|
name: 'Html',
|
116
|
-
type: ComponentType.Html,
|
117
119
|
title: 'Html',
|
120
|
+
type: ComponentType.Html,
|
118
121
|
subType: ComponentSubType.Content,
|
119
122
|
content: '',
|
120
123
|
options: {},
|
121
124
|
schema: {}
|
122
125
|
}, {
|
123
126
|
name: 'InsetText',
|
124
|
-
type: ComponentType.InsetText,
|
125
127
|
title: 'Inset text',
|
128
|
+
type: ComponentType.InsetText,
|
126
129
|
subType: ComponentSubType.Content,
|
127
130
|
content: '',
|
128
131
|
options: {},
|
129
132
|
schema: {}
|
130
133
|
}, {
|
131
134
|
name: 'Details',
|
132
|
-
type: ComponentType.Details,
|
133
135
|
title: 'Details',
|
136
|
+
type: ComponentType.Details,
|
134
137
|
subType: ComponentSubType.Content,
|
135
138
|
content: '',
|
136
139
|
options: {},
|
137
140
|
schema: {}
|
138
141
|
}, {
|
139
142
|
name: 'List',
|
140
|
-
type: ComponentType.List,
|
141
143
|
title: 'List',
|
144
|
+
type: ComponentType.List,
|
145
|
+
subType: ComponentSubType.Content,
|
142
146
|
options: {},
|
143
147
|
schema: {},
|
144
148
|
list: ''
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"component-types.js","names":["ComponentSubType","ComponentType","ComponentTypes","name","
|
1
|
+
{"version":3,"file":"component-types.js","names":["ComponentSubType","ComponentType","ComponentTypes","name","title","type","TextField","subType","Field","hint","options","schema","MultilineTextField","YesNoField","TimeField","DatePartsField","MonthYearField","SelectField","ListField","list","AutocompleteField","RadiosField","CheckboxesField","NumberField","UkAddressField","TelephoneNumberField","EmailAddressField","Html","Content","content","InsetText","Details","List"],"sources":["../../../src/components/component-types.ts"],"sourcesContent":["import { ComponentSubType, 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 subType?: ComponentSubType\n})[] = [\n {\n name: 'TextField',\n title: 'Text field',\n type: ComponentType.TextField,\n subType: ComponentSubType.Field,\n hint: '',\n options: {},\n schema: {}\n },\n {\n name: 'MultilineTextField',\n title: 'Multiline text field',\n type: ComponentType.MultilineTextField,\n subType: ComponentSubType.Field,\n hint: '',\n options: {},\n schema: {}\n },\n {\n name: 'YesNoField',\n title: 'Yes/No field',\n type: ComponentType.YesNoField,\n subType: ComponentSubType.Field,\n hint: '',\n options: {},\n schema: {}\n },\n {\n name: 'TimeField',\n title: 'Time field',\n type: ComponentType.TimeField,\n subType: ComponentSubType.Field,\n hint: '',\n options: {},\n schema: {}\n },\n {\n name: 'DatePartsField',\n title: 'Date field',\n type: ComponentType.DatePartsField,\n subType: ComponentSubType.Field,\n hint: '',\n options: {},\n schema: {}\n },\n {\n name: 'MonthYearField',\n title: 'Month & year field',\n type: ComponentType.MonthYearField,\n subType: ComponentSubType.Field,\n hint: '',\n options: {},\n schema: {}\n },\n {\n name: 'SelectField',\n title: 'Select field',\n type: ComponentType.SelectField,\n subType: ComponentSubType.ListField,\n options: {},\n schema: {},\n list: ''\n },\n {\n name: 'AutocompleteField',\n title: 'Autocomplete field',\n type: ComponentType.AutocompleteField,\n subType: ComponentSubType.ListField,\n options: {},\n schema: {},\n list: ''\n },\n {\n name: 'RadiosField',\n title: 'Radios field',\n type: ComponentType.RadiosField,\n subType: ComponentSubType.ListField,\n options: {},\n schema: {},\n list: ''\n },\n {\n name: 'CheckboxesField',\n title: 'Checkboxes field',\n type: ComponentType.CheckboxesField,\n subType: ComponentSubType.ListField,\n options: {},\n schema: {},\n list: ''\n },\n {\n name: 'NumberField',\n title: 'Number field',\n type: ComponentType.NumberField,\n subType: ComponentSubType.Field,\n hint: '',\n options: {},\n schema: {}\n },\n {\n name: 'UkAddressField',\n title: 'UK address field',\n type: ComponentType.UkAddressField,\n subType: ComponentSubType.Field,\n hint: '',\n options: {},\n schema: {}\n },\n {\n name: 'TelephoneNumberField',\n title: 'Telephone number field',\n type: ComponentType.TelephoneNumberField,\n subType: ComponentSubType.Field,\n hint: '',\n options: {},\n schema: {}\n },\n {\n name: 'EmailAddressField',\n title: 'Email address field',\n type: ComponentType.EmailAddressField,\n subType: ComponentSubType.Field,\n hint: '',\n options: {},\n schema: {}\n },\n {\n name: 'Html',\n title: 'Html',\n type: ComponentType.Html,\n subType: ComponentSubType.Content,\n content: '',\n options: {},\n schema: {}\n },\n {\n name: 'InsetText',\n title: 'Inset text',\n type: ComponentType.InsetText,\n subType: ComponentSubType.Content,\n content: '',\n options: {},\n schema: {}\n },\n {\n name: 'Details',\n title: 'Details',\n type: ComponentType.Details,\n subType: ComponentSubType.Content,\n content: '',\n options: {},\n schema: {}\n },\n {\n name: 'List',\n title: 'List',\n type: ComponentType.List,\n subType: ComponentSubType.Content,\n options: {},\n schema: {},\n list: ''\n }\n]\n"],"mappings":"AAAA,SAASA,gBAAgB,EAAEC,aAAa;AAGxC;AACA;AACA;AACA,OAAO,MAAMC,cAET,GAAG,CACL;EACEC,IAAI,EAAE,WAAW;EACjBC,KAAK,EAAE,YAAY;EACnBC,IAAI,EAAEJ,aAAa,CAACK,SAAS;EAC7BC,OAAO,EAAEP,gBAAgB,CAACQ,KAAK;EAC/BC,IAAI,EAAE,EAAE;EACRC,OAAO,EAAE,CAAC,CAAC;EACXC,MAAM,EAAE,CAAC;AACX,CAAC,EACD;EACER,IAAI,EAAE,oBAAoB;EAC1BC,KAAK,EAAE,sBAAsB;EAC7BC,IAAI,EAAEJ,aAAa,CAACW,kBAAkB;EACtCL,OAAO,EAAEP,gBAAgB,CAACQ,KAAK;EAC/BC,IAAI,EAAE,EAAE;EACRC,OAAO,EAAE,CAAC,CAAC;EACXC,MAAM,EAAE,CAAC;AACX,CAAC,EACD;EACER,IAAI,EAAE,YAAY;EAClBC,KAAK,EAAE,cAAc;EACrBC,IAAI,EAAEJ,aAAa,CAACY,UAAU;EAC9BN,OAAO,EAAEP,gBAAgB,CAACQ,KAAK;EAC/BC,IAAI,EAAE,EAAE;EACRC,OAAO,EAAE,CAAC,CAAC;EACXC,MAAM,EAAE,CAAC;AACX,CAAC,EACD;EACER,IAAI,EAAE,WAAW;EACjBC,KAAK,EAAE,YAAY;EACnBC,IAAI,EAAEJ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M,EAAE,CAAC;AACX,CAAC,EACD;EACER,IAAI,EAAE,MAAM;EACZC,KAAK,EAAE,MAAM;EACbC,IAAI,EAAEJ,aAAa,CAAC0B,IAAI;EACxBpB,OAAO,EAAEP,gBAAgB,CAAC4B,OAAO;EACjCC,OAAO,EAAE,EAAE;EACXnB,OAAO,EAAE,CAAC,CAAC;EACXC,MAAM,EAAE,CAAC;AACX,CAAC,EACD;EACER,IAAI,EAAE,WAAW;EACjBC,KAAK,EAAE,YAAY;EACnBC,IAAI,EAAEJ,aAAa,CAAC6B,SAAS;EAC7BvB,OAAO,EAAEP,gBAAgB,CAAC4B,OAAO;EACjCC,OAAO,EAAE,EAAE;EACXnB,OAAO,EAAE,CAAC,CAAC;EACXC,MAAM,EAAE,CAAC;AACX,CAAC,EACD;EACER,IAAI,EAAE,SAAS;EACfC,KAAK,EAAE,SAAS;EAChBC,IAAI,EAAEJ,aAAa,CAAC8B,OAAO;EAC3BxB,OAAO,EAAEP,gBAAgB,CAAC4B,OAAO;EACjCC,OAAO,EAAE,EAAE;EACXnB,OAAO,EAAE,CAAC,CAAC;EACXC,MAAM,EAAE,CAAC;AACX,CAAC,EACD;EACER,IAAI,EAAE,MAAM;EACZC,KAAK,EAAE,MAAM;EACbC,IAAI,EAAEJ,aAAa,CAAC+B,IAAI;EACxBzB,OAAO,EAAEP,gBAAgB,CAAC4B,OAAO;EACjClB,OAAO,EAAE,CAAC,CAAC;EACXC,MAAM,EAAE,CAAC,CAAC;EACVQ,IAAI,EAAE;AACR,CAAC,CACF","ignoreList":[]}
|
@@ -1,4 +1,17 @@
|
|
1
|
+
import { ComponentTypes } from "./component-types.js";
|
1
2
|
import { ComponentType } from "./enums.js";
|
3
|
+
/**
|
4
|
+
* Return component defaults by type
|
5
|
+
*/
|
6
|
+
export function getComponentDefaults(component) {
|
7
|
+
if (!component?.type) {
|
8
|
+
return;
|
9
|
+
}
|
10
|
+
return ComponentTypes.find(({
|
11
|
+
type
|
12
|
+
}) => type === component.type);
|
13
|
+
}
|
14
|
+
|
2
15
|
/**
|
3
16
|
* Filter known components with support for conditions
|
4
17
|
*/
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"helpers.js","names":["ComponentType","
|
1
|
+
{"version":3,"file":"helpers.js","names":["ComponentTypes","ComponentType","getComponentDefaults","component","type","find","hasConditionSupport","isConditionalType","allowedTypes","RadiosField","CheckboxesField","DatePartsField","EmailAddressField","MultilineTextField","NumberField","TextField","TimeField","YesNoField","includes","hasContentField","Details","Html","InsetText","hasEditor","TelephoneNumberField","AutocompleteField","SelectField","List","hasInputField","MonthYearField","UkAddressField","hasListField","hasSelectionFields","hasTitle","deniedTypes"],"sources":["../../../src/components/helpers.ts"],"sourcesContent":["import { ComponentTypes } from '~/src/components/component-types.js'\nimport { ComponentType } from '~/src/components/enums.js'\nimport {\n type InputFieldsComponentsDef,\n type ComponentDef,\n type ConditionalComponentsDef,\n type ConditionalComponentType,\n type ContentComponentsDef,\n type HtmlComponent,\n type InsetTextComponent,\n type ListComponentsDef,\n type SelectionComponentsDef,\n type EditorComponentsDef\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.RadiosField,\n ComponentType.CheckboxesField,\n ComponentType.DatePartsField,\n ComponentType.EmailAddressField,\n ComponentType.MultilineTextField,\n ComponentType.NumberField,\n ComponentType.TextField,\n ComponentType.TimeField,\n ComponentType.YesNoField\n ]\n\n return !!type && allowedTypes.includes(type)\n}\n\n/**\n * Filter known components with content fields\n */\nexport function hasContentField(\n component?: Partial<ComponentDef>\n): component is ContentComponentsDef {\n const allowedTypes = [\n ComponentType.Details,\n ComponentType.Html,\n ComponentType.InsetText\n ]\n\n return !!component?.type && allowedTypes.includes(component.type)\n}\n\n/**\n * Filter known components with text editor or list select\n */\nexport function hasEditor(\n component?: Partial<ComponentDef>\n): component is EditorComponentsDef {\n const allowedTypes = [\n ComponentType.TextField,\n ComponentType.EmailAddressField,\n ComponentType.TelephoneNumberField,\n ComponentType.MultilineTextField,\n ComponentType.NumberField,\n ComponentType.AutocompleteField,\n ComponentType.SelectField,\n ComponentType.RadiosField,\n ComponentType.CheckboxesField,\n ComponentType.List,\n ComponentType.Details,\n ComponentType.Html,\n ComponentType.InsetText,\n ComponentType.DatePartsField\n ]\n\n return !!component?.type && allowedTypes.includes(component.type)\n}\n\n/**\n * Filter known components with input fields\n */\nexport function hasInputField(\n component?: Partial<ComponentDef>\n): component is InputFieldsComponentsDef {\n const allowedTypes = [\n ComponentType.TextField,\n ComponentType.EmailAddressField,\n ComponentType.NumberField,\n ComponentType.MultilineTextField,\n ComponentType.TelephoneNumberField,\n ComponentType.YesNoField,\n ComponentType.MonthYearField,\n ComponentType.TimeField,\n ComponentType.UkAddressField\n ]\n\n return !!component?.type && allowedTypes.includes(component.type)\n}\n\n/**\n * Filter known components with lists\n */\nexport function hasListField(\n component?: Partial<ComponentDef>\n): component is ListComponentsDef {\n const allowedTypes = [\n ComponentType.AutocompleteField,\n ComponentType.List,\n ComponentType.RadiosField,\n ComponentType.SelectField,\n ComponentType.CheckboxesField\n ]\n\n return !!component?.type && allowedTypes.includes(component.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.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;AActB;AACA;AACA;AACA,OAAO,SAASC,oBAAoBA,CAACC,SAAiC,EAAE;EACtE,IAAI,CAACA,SAAS,EAAEC,IAAI,EAAE;IACpB;EACF;EAEA,OAAOJ,cAAc,CAACK,IAAI,CAAC,CAAC;IAAED;EAAK,CAAC,KAAKA,IAAI,KAAKD,SAAS,CAACC,IAAI,CAAC;AACnE;;AAEA;AACA;AACA;AACA,OAAO,SAASE,mBAAmBA,CACjCH,SAAiC,EACM;EACvC,OAAOI,iBAAiB,CAACJ,SAAS,EAAEC,IAAI,CAAC;AAC3C;AAEA,OAAO,SAASG,iBAAiBA,CAC/BH,IAAoB,EACc;EAClC,MAAMI,YAAY,GAAG,CACnBP,aAAa,CAACQ,WAAW,EACzBR,aAAa,CAACS,eAAe,EAC7BT,aAAa,CAACU,cAAc,EAC5BV,aAAa,CAACW,iBAAiB,EAC/BX,aAAa,CAACY,kBAAkB,EAChCZ,aAAa,CAACa,WAAW,EACzBb,aAAa,CAACc,SAAS,EACvBd,aAAa,CAACe,SAAS,EACvBf,aAAa,CAACgB,UAAU,CACzB;EAED,OAAO,CAAC,CAACb,IAAI,IAAII,YAAY,CAACU,QAAQ,CAACd,IAAI,CAAC;AAC9C;;AAEA;AACA;AACA;AACA,OAAO,SAASe,eAAeA,CAC7BhB,SAAiC,EACE;EACnC,MAAMK,YAAY,GAAG,CACnBP,aAAa,CAACmB,OAAO,EACrBnB,aAAa,CAACoB,IAAI,EAClBpB,aAAa,CAACqB,SAAS,CACxB;EAED,OAAO,CAAC,CAACnB,SAAS,EAAEC,IAAI,IAAII,YAAY,CAACU,QAAQ,CAACf,SAAS,CAACC,IAAI,CAAC;AACnE;;AAEA;AACA;AACA;AACA,OAAO,SAASmB,SAASA,CACvBpB,SAAiC,E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CAACP,SAAS,EAAEC,IAAI,IAAII,YAAY,CAACU,QAAQ,CAACf,SAAS,CAACC,IAAI,CAAC;AACnE;;AAEA;AACA;AACA;AACA,OAAO,SAAS4B,kBAAkBA,CAChC7B,SAAiC,EACI;EACrC,MAAMK,YAAY,GAAG,CACnBP,aAAa,CAACS,eAAe,EAC7BT,aAAa,CAACQ,WAAW,EACzBR,aAAa,CAACyB,WAAW,EACzBzB,aAAa,CAACgB,UAAU,CACzB;EAED,OAAO,CAAC,CAACd,SAAS,EAAEC,IAAI,IAAII,YAAY,CAACU,QAAQ,CAACf,SAAS,CAACC,IAAI,CAAC;AACnE;;AAEA;AACA;AACA;AACA,OAAO,SAAS6B,QAAQA,CACtB9B,SAAiC,EACuC;EACxE,MAAM+B,WAAW,GAAG,CAACjC,aAAa,CAACqB,SAAS,EAAErB,aAAa,CAACoB,IAAI,CAAC;EACjE,OAAO,CAAC,CAAClB,SAAS,EAAEC,IAAI,IAAI,CAAC8B,WAAW,CAAChB,QAAQ,CAACf,SAAS,CAACC,IAAI,CAAC;AACnE","ignoreList":[]}
|
@@ -1,4 +1,4 @@
|
|
1
1
|
export { ComponentTypes } from "./component-types.js";
|
2
|
-
export { hasConditionSupport, hasContentField, hasEditor, hasInputField, hasListField, hasSelectionFields, hasTitle } from "./helpers.js";
|
2
|
+
export { getComponentDefaults, hasConditionSupport, hasContentField, hasEditor, hasInputField, hasListField, hasSelectionFields, hasTitle } from "./helpers.js";
|
3
3
|
export { ComponentType, ComponentSubType } from "./enums.js";
|
4
4
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","names":["ComponentTypes","hasConditionSupport","hasContentField","hasEditor","hasInputField","hasListField","hasSelectionFields","hasTitle","ComponentType","ComponentSubType"],"sources":["../../../src/components/index.ts"],"sourcesContent":["export { ComponentTypes } from '~/src/components/component-types.js'\nexport {\n hasConditionSupport,\n hasContentField,\n hasEditor,\n hasInputField,\n hasListField,\n hasSelectionFields,\n hasTitle\n} from '~/src/components/helpers.js'\n\nexport { ComponentType, ComponentSubType } from '~/src/components/enums.js'\n"],"mappings":"AAAA,SAASA,cAAc;AACvB,SACEC,mBAAmB,EACnBC,eAAe,EACfC,SAAS,EACTC,aAAa,EACbC,YAAY,EACZC,kBAAkB,EAClBC,QAAQ;AAGV,SAASC,aAAa,EAAEC,gBAAgB","ignoreList":[]}
|
1
|
+
{"version":3,"file":"index.js","names":["ComponentTypes","getComponentDefaults","hasConditionSupport","hasContentField","hasEditor","hasInputField","hasListField","hasSelectionFields","hasTitle","ComponentType","ComponentSubType"],"sources":["../../../src/components/index.ts"],"sourcesContent":["export { ComponentTypes } from '~/src/components/component-types.js'\nexport {\n getComponentDefaults,\n hasConditionSupport,\n hasContentField,\n hasEditor,\n hasInputField,\n hasListField,\n hasSelectionFields,\n hasTitle\n} from '~/src/components/helpers.js'\n\nexport { ComponentType, ComponentSubType } from '~/src/components/enums.js'\n"],"mappings":"AAAA,SAASA,cAAc;AACvB,SACEC,oBAAoB,EACpBC,mBAAmB,EACnBC,eAAe,EACfC,SAAS,EACTC,aAAa,EACbC,YAAY,EACZC,kBAAkB,EAClBC,QAAQ;AAGV,SAASC,aAAa,EAAEC,gBAAgB","ignoreList":[]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../../../src/components/types.ts"],"sourcesContent":["import {
|
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 =\n | ComponentType.RadiosField\n | ComponentType.CheckboxesField\n | ComponentType.DatePartsField\n | ComponentType.EmailAddressField\n | ComponentType.MultilineTextField\n | ComponentType.NumberField\n | ComponentType.TextField\n | ComponentType.TimeField\n | ComponentType.YesNoField\n\n/**\n * Types for Components JSON structure which are expected by engine and turned into actual form input/content/lists\n */\ninterface TextFieldBase {\n type:\n | ComponentType.EmailAddressField\n | ComponentType.MultilineTextField\n | ComponentType.NumberField\n | ComponentType.TelephoneNumberField\n | ComponentType.TextField\n | ComponentType.UkAddressField\n | ComponentType.YesNoField\n name: string\n title: string\n hint?: string\n options: {\n required?: boolean\n optionalText?: boolean\n classes?: string\n allow?: string\n autocomplete?: string\n }\n schema: {\n max?: number\n min?: number\n length?: number\n regex?: string\n error?: unknown\n }\n}\n\ninterface NumberFieldBase {\n type: ComponentType\n name: string\n title: string\n hint?: string\n options: {\n required?: boolean\n optionalText?: boolean\n classes?: string\n prefix?: string\n suffix?: string\n }\n schema: {\n min?: number\n max?: number\n precision?: number\n }\n}\n\ninterface ListFieldBase {\n type:\n | ComponentType.AutocompleteField\n | ComponentType.CheckboxesField\n | ComponentType.List\n | ComponentType.RadiosField\n | ComponentType.SelectField\n name: string\n title: string\n options: {\n type?: string\n required?: boolean\n optionalText?: boolean\n classes?: string\n bold?: boolean\n }\n list: string\n schema: object\n}\n\ninterface ContentFieldBase {\n type: ComponentType.Details | ComponentType.Html | ComponentType.InsetText\n name: string\n title: string\n content: string\n options: {\n condition?: string\n }\n schema: object\n}\n\ninterface DateFieldBase {\n type:\n | ComponentType.DatePartsField\n | ComponentType.MonthYearField\n | ComponentType.TimeField\n name: string\n title: string\n hint?: string\n options: {\n required?: boolean\n optionalText?: boolean\n maxDaysInFuture?: number\n maxDaysInPast?: number\n }\n schema: object\n}\n\n// Text Fields\nexport interface TextFieldComponent extends TextFieldBase {\n type: ComponentType.TextField\n options: TextFieldBase['options'] & {\n condition?: string\n customValidationMessage?: string\n }\n}\n\nexport interface EmailAddressFieldComponent extends TextFieldBase {\n type: ComponentType.EmailAddressField\n options: TextFieldBase['options'] & {\n condition?: string\n customValidationMessage?: string\n }\n}\n\nexport interface NumberFieldComponent extends NumberFieldBase {\n type: ComponentType.NumberField\n options: NumberFieldBase['options'] & {\n condition?: string\n customValidationMessage?: string\n }\n}\n\nexport interface TelephoneNumberFieldComponent extends TextFieldBase {\n type: ComponentType.TelephoneNumberField\n options: TextFieldBase['options'] & {\n customValidationMessage?: string\n }\n}\n\nexport interface YesNoFieldComponent extends TextFieldBase {\n type: ComponentType.YesNoField\n options: TextFieldBase['options'] & {\n condition?: string\n }\n}\n\nexport interface MultilineTextFieldComponent extends TextFieldBase {\n type: ComponentType.MultilineTextField\n options: TextFieldBase['options'] & {\n condition?: string\n customValidationMessage?: string\n rows?: number\n maxWords?: number\n }\n schema: {\n max?: number\n min?: number\n }\n}\n\nexport interface UkAddressFieldComponent extends TextFieldBase {\n type: ComponentType.UkAddressField\n options: TextFieldBase['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\nexport interface TimeFieldComponent extends DateFieldBase {\n type: ComponentType.TimeField\n options: DateFieldBase['options'] & {\n condition?: string\n }\n}\n\n// Content Fields\nexport interface DetailsComponent extends ContentFieldBase {\n type: ComponentType.Details\n}\n\nexport interface HtmlComponent extends ContentFieldBase {\n type: ComponentType.Html\n}\n\nexport interface InsetTextComponent extends ContentFieldBase {\n type: ComponentType.InsetText\n}\n\n// List Fields\nexport interface ListComponent extends ListFieldBase {\n type: ComponentType.List\n}\n\nexport interface AutocompleteFieldComponent extends ListFieldBase {\n type: ComponentType.AutocompleteField\n}\n\nexport interface CheckboxesFieldComponent extends ListFieldBase {\n type: ComponentType.CheckboxesField\n options: ListFieldBase['options'] & {\n condition?: string\n }\n}\n\nexport interface RadiosFieldComponent extends ListFieldBase {\n type: ComponentType.RadiosField\n options: ListFieldBase['options'] & {\n condition?: string\n }\n}\n\nexport interface SelectFieldComponent extends ListFieldBase {\n type: ComponentType.SelectField\n options: ListFieldBase['options'] & { autocomplete?: string }\n}\n\nexport type ComponentDef =\n | InsetTextComponent\n | AutocompleteFieldComponent\n | CheckboxesFieldComponent\n | DatePartsFieldFieldComponent\n | MonthYearFieldComponent\n | DetailsComponent\n | EmailAddressFieldComponent\n | HtmlComponent\n | ListComponent\n | MultilineTextFieldComponent\n | NumberFieldComponent\n | RadiosFieldComponent\n | SelectFieldComponent\n | TelephoneNumberFieldComponent\n | TextFieldComponent\n | TimeFieldComponent\n | UkAddressFieldComponent\n | YesNoFieldComponent\n\n// Components that render inputs\nexport type InputFieldsComponentsDef =\n | TextFieldComponent\n | EmailAddressFieldComponent\n | NumberFieldComponent\n | MultilineTextFieldComponent\n | TelephoneNumberFieldComponent\n | YesNoFieldComponent\n | MonthYearFieldComponent\n | TimeFieldComponent\n | UkAddressFieldComponent\n\n// Components that render content\nexport type ContentComponentsDef =\n | DetailsComponent\n | HtmlComponent\n | InsetTextComponent\n\n// Components with editors\nexport type EditorComponentsDef =\n | TextFieldComponent\n | EmailAddressFieldComponent\n | TelephoneNumberFieldComponent\n | MultilineTextFieldComponent\n | NumberFieldComponent\n | AutocompleteFieldComponent\n | SelectFieldComponent\n | RadiosFieldComponent\n | CheckboxesFieldComponent\n | ListComponent\n | DetailsComponent\n | HtmlComponent\n | InsetTextComponent\n | DatePartsFieldFieldComponent\n\n// Components that render lists\nexport type ListComponentsDef =\n | ListComponent\n | AutocompleteFieldComponent\n | CheckboxesFieldComponent\n | RadiosFieldComponent\n | SelectFieldComponent\n\n// Components that have selection fields\nexport type SelectionComponentsDef =\n | CheckboxesFieldComponent\n | RadiosFieldComponent\n | SelectFieldComponent\n | YesNoFieldComponent\n\n// Components that have custom condition operators\nexport type ConditionalComponentsDef =\n | CheckboxesFieldComponent\n | DatePartsFieldFieldComponent\n | EmailAddressFieldComponent\n | MultilineTextFieldComponent\n | NumberFieldComponent\n | TextFieldComponent\n | TimeFieldComponent\n | YesNoFieldComponent\n"],"mappings":"","ignoreList":[]}
|
@@ -53,7 +53,6 @@ const localisedString = Joi.alternatives().try(Joi.object({
|
|
53
53
|
a: Joi.any()
|
54
54
|
}).unknown(), Joi.string().allow(''));
|
55
55
|
export const componentSchema = Joi.object().keys({
|
56
|
-
subType: Joi.string().optional(),
|
57
56
|
type: Joi.string().required(),
|
58
57
|
name: Joi.string(),
|
59
58
|
title: localisedString,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","names":["Joi","CURRENT_VERSION","sectionsSchema","object","keys","name","string","required","title","hideTitle","boolean","optional","default","conditionFieldSchema","type","display","conditionValueSchema","value","relativeTimeValueSchema","timePeriod","timeUnit","direction","timeOnly","conditionRefSchema","conditionName","conditionDisplayName","coordinator","conditionSchema","field","operator","alternatives","try","conditionGroupSchema","conditions","array","items","any","conditionsModelSchema","conditionsSchema","displayName","localisedString","a","unknown","allow","componentSchema","subType","hint","options","schema","min","number","max","list","nextSchema","path","condition","redirect","pageSchema","disallow","section","controller","components","next","repeatField","backLinkFallback","toggleableString","confirmationPageSchema","customText","nextSteps","specialPagesSchema","confirmationPage","baseListItemSchema","text","description","conditional","unique","stringListItemSchema","append","numberListItemSchema","listSchema","valid","when","is","then","otherwise","feedbackSchema","feedbackForm","url","emailAddress","email","tlds","phaseBannerSchema","phase","formDefinitionSchema","feedback","startPage","pages","sections","lists","metadata","declaration","skipSummary","phaseBanner","specialPages","outputEmail","trim","Schema"],"sources":["../../../../src/form/form-definition/index.ts"],"sourcesContent":["import Joi from 'joi'\n\nimport {\n type ComponentSubType,\n type ComponentType\n} from '~/src/components/enums.js'\nimport { type ComponentDef } from '~/src/components/types.js'\nimport {\n type ConditionRawData,\n type ConditionWrapperValue,\n type ConfirmationPage,\n type FormDefinition,\n type Item,\n type List,\n type Next,\n type Page,\n type PhaseBanner,\n type RepeatingFieldPage,\n type Section,\n type SpecialPages\n} from '~/src/form/form-definition/types.js'\n\n/**\n * If an optional key is added, CURRENT_VERSION does not need to be incremented.\n * Only breaking changes will require an increment, as well as a migration script.\n */\nexport const CURRENT_VERSION = 2\n\nconst sectionsSchema = Joi.object<Section>().keys({\n name: Joi.string().required(),\n title: Joi.string().required(),\n hideTitle: Joi.boolean().optional().default(false)\n})\n\nconst conditionFieldSchema = Joi.object().keys({\n name: Joi.string().required(),\n type: Joi.string().required(),\n display: Joi.string().required()\n})\n\nconst conditionValueSchema = Joi.object().keys({\n type: Joi.string().required(),\n value: Joi.string().required(),\n display: Joi.string().required()\n})\n\nconst relativeTimeValueSchema = Joi.object().keys({\n type: Joi.string().required(),\n timePeriod: Joi.string().required(),\n timeUnit: Joi.string().required(),\n direction: Joi.string().required(),\n timeOnly: Joi.boolean().required()\n})\n\nconst conditionRefSchema = Joi.object().keys({\n conditionName: Joi.string().required(),\n conditionDisplayName: Joi.string().required(),\n coordinator: Joi.string().optional()\n})\n\nconst conditionSchema = Joi.object().keys({\n field: conditionFieldSchema,\n operator: Joi.string().required(),\n value: Joi.alternatives().try(conditionValueSchema, relativeTimeValueSchema),\n coordinator: Joi.string().optional()\n})\n\nconst conditionGroupSchema = Joi.object().keys({\n conditions: Joi.array().items(\n Joi.alternatives().try(\n conditionSchema,\n conditionRefSchema,\n Joi.any() /** Should be a joi.link('#conditionGroupSchema') */\n )\n )\n})\n\nconst conditionsModelSchema = Joi.alternatives<ConditionWrapperValue>().try(\n Joi.string(),\n Joi.object().keys({\n name: Joi.string().required(),\n conditions: Joi.array().items(\n Joi.alternatives().try(\n conditionSchema,\n conditionRefSchema,\n conditionGroupSchema\n )\n )\n })\n)\n\nconst conditionsSchema = Joi.object<ConditionRawData>().keys({\n name: Joi.string().required(),\n displayName: Joi.string(),\n value: conditionsModelSchema.required()\n})\n\nconst localisedString = Joi.alternatives().try(\n Joi.object({ a: Joi.any() }).unknown(),\n Joi.string().allow('')\n)\n\nexport const componentSchema = Joi.object<ComponentDef>()\n .keys({\n subType: Joi.string<ComponentSubType>().optional(),\n type: Joi.string<ComponentType>().required(),\n name: Joi.string(),\n title: localisedString,\n hint: localisedString.optional(),\n options: Joi.object().default({}),\n schema: Joi.object({ min: Joi.number(), max: Joi.number() })\n .unknown(true)\n .default({}),\n list: Joi.string().optional()\n })\n .unknown(true)\n\nconst nextSchema = Joi.object<Next>().keys({\n path: Joi.string().required(),\n condition: Joi.string().allow('').optional(),\n redirect: Joi.string().optional()\n})\n\n/**\n * `/status` is a special route for providing a user's application status.\n * It should not be configured via the designer.\n */\nconst pageSchema = Joi.object<Page | RepeatingFieldPage>().keys({\n path: Joi.string().required().disallow('/status'),\n title: localisedString,\n section: Joi.string(),\n controller: Joi.string().optional(),\n components: Joi.array<ComponentDef>().items(componentSchema),\n next: Joi.array<Next>().items(nextSchema),\n repeatField: Joi.string().optional(),\n options: Joi.object().optional(),\n backLinkFallback: Joi.string().optional()\n})\n\nconst toggleableString = Joi.alternatives().try(Joi.boolean(), Joi.string())\n\nconst confirmationPageSchema = Joi.object<ConfirmationPage>({\n customText: Joi.object<ConfirmationPage['customText']>({\n title: Joi.string().default('Application complete'),\n nextSteps: toggleableString.default(\n 'You will receive an email with details with the next steps.'\n )\n }).default(),\n components: Joi.array<ComponentDef>().items(componentSchema)\n})\n\nconst specialPagesSchema = Joi.object<SpecialPages>().keys({\n confirmationPage: confirmationPageSchema.optional()\n})\n\nconst baseListItemSchema = Joi.object<Item>().keys({\n text: localisedString,\n description: localisedString.optional(),\n conditional: Joi.object<Item['conditional']>()\n .keys({\n components: Joi.array<ComponentDef>()\n .required()\n .items(componentSchema.unknown(true))\n .unique('name')\n })\n .allow(null)\n .optional(),\n condition: Joi.string().allow(null, '').optional()\n})\n\nconst stringListItemSchema = baseListItemSchema.append({\n value: Joi.string().required()\n})\n\nconst numberListItemSchema = baseListItemSchema.append({\n value: Joi.number().required()\n})\n\nconst listSchema = Joi.object<List>().keys({\n name: Joi.string().required(),\n title: localisedString,\n type: Joi.string().required().valid('string', 'number'),\n items: Joi.when('type', {\n is: 'string',\n then: Joi.array()\n .items(stringListItemSchema)\n .unique('text')\n .unique('value'),\n otherwise: Joi.array()\n .items(numberListItemSchema)\n .unique('text')\n .unique('value')\n })\n})\n\nconst feedbackSchema = Joi.object<FormDefinition['feedback']>().keys({\n feedbackForm: Joi.boolean().default(false),\n url: Joi.when('feedbackForm', {\n is: Joi.boolean().valid(false),\n then: Joi.string().optional().allow('')\n }),\n emailAddress: Joi.string()\n .email({\n tlds: {\n allow: false\n }\n })\n .optional()\n})\n\nconst phaseBannerSchema = Joi.object<PhaseBanner>().keys({\n phase: Joi.string().valid('alpha', 'beta')\n})\n\n/**\n * Joi schema for `FormDefinition` interface\n * @see {@link FormDefinition}\n */\nexport const formDefinitionSchema = Joi.object<FormDefinition>()\n .required()\n .keys({\n name: localisedString.optional(),\n feedback: feedbackSchema.optional(),\n startPage: Joi.string().optional(),\n pages: Joi.array<Page | RepeatingFieldPage>()\n .required()\n .items(pageSchema)\n .unique('path'),\n sections: Joi.array<Section>()\n .items(sectionsSchema)\n .unique('name')\n .required(),\n conditions: Joi.array<ConditionRawData>()\n .items(conditionsSchema)\n .unique('name'),\n lists: Joi.array<List>().items(listSchema).unique('name'),\n metadata: Joi.object({ a: Joi.any() }).unknown().optional(),\n declaration: Joi.string().allow('').optional(),\n skipSummary: Joi.boolean().optional().default(false),\n phaseBanner: phaseBannerSchema.optional(),\n specialPages: specialPagesSchema.optional(),\n outputEmail: Joi.string()\n .email({ tlds: { allow: ['uk'] } })\n .trim()\n .optional()\n })\n\n// Maintain compatibility with legacy named export\n// E.g. `import { Schema } from '@defra/forms-model'`\nexport const Schema = formDefinitionSchema\n"],"mappings":"AAAA,OAAOA,GAAG,MAAM,KAAK;AAsBrB;AACA;AACA;AACA;AACA,OAAO,MAAMC,eAAe,GAAG,CAAC;AAEhC,MAAMC,cAAc,GAAGF,GAAG,CAACG,MAAM,CAAU,CAAC,CAACC,IAAI,CAAC;EAChDC,IAAI,EAAEL,GAAG,CAACM,MAAM,CAAC,CAAC,CAACC,QAAQ,CAAC,CAAC;EAC7BC,KAAK,EAAER,GAAG,CAACM,MAAM,CAAC,CAAC,CAACC,QAAQ,CAAC,CAAC;EAC9BE,SAAS,EAAET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,CAAC;;AAEJ;AACA;AACA,OAAO,MAAM+F,MAAM,GAAGb,oBAAoB","ignoreList":[]}
|
1
|
+
{"version":3,"file":"index.js","names":["Joi","CURRENT_VERSION","sectionsSchema","object","keys","name","string","required","title","hideTitle","boolean","optional","default","conditionFieldSchema","type","display","conditionValueSchema","value","relativeTimeValueSchema","timePeriod","timeUnit","direction","timeOnly","conditionRefSchema","conditionName","conditionDisplayName","coordinator","conditionSchema","field","operator","alternatives","try","conditionGroupSchema","conditions","array","items","any","conditionsModelSchema","conditionsSchema","displayName","localisedString","a","unknown","allow","componentSchema","hint","options","schema","min","number","max","list","nextSchema","path","condition","redirect","pageSchema","disallow","section","controller","components","next","repeatField","backLinkFallback","toggleableString","confirmationPageSchema","customText","nextSteps","specialPagesSchema","confirmationPage","baseListItemSchema","text","description","conditional","unique","stringListItemSchema","append","numberListItemSchema","listSchema","valid","when","is","then","otherwise","feedbackSchema","feedbackForm","url","emailAddress","email","tlds","phaseBannerSchema","phase","formDefinitionSchema","feedback","startPage","pages","sections","lists","metadata","declaration","skipSummary","phaseBanner","specialPages","outputEmail","trim","Schema"],"sources":["../../../../src/form/form-definition/index.ts"],"sourcesContent":["import Joi from 'joi'\n\nimport { type ComponentType } from '~/src/components/enums.js'\nimport { type ComponentDef } from '~/src/components/types.js'\nimport {\n type ConditionRawData,\n type ConditionWrapperValue,\n type ConfirmationPage,\n type FormDefinition,\n type Item,\n type List,\n type Next,\n type Page,\n type PhaseBanner,\n type RepeatingFieldPage,\n type Section,\n type SpecialPages\n} from '~/src/form/form-definition/types.js'\n\n/**\n * If an optional key is added, CURRENT_VERSION does not need to be incremented.\n * Only breaking changes will require an increment, as well as a migration script.\n */\nexport const CURRENT_VERSION = 2\n\nconst sectionsSchema = Joi.object<Section>().keys({\n name: Joi.string().required(),\n title: Joi.string().required(),\n hideTitle: Joi.boolean().optional().default(false)\n})\n\nconst conditionFieldSchema = Joi.object().keys({\n name: Joi.string().required(),\n type: Joi.string().required(),\n display: Joi.string().required()\n})\n\nconst conditionValueSchema = Joi.object().keys({\n type: Joi.string().required(),\n value: Joi.string().required(),\n display: Joi.string().required()\n})\n\nconst relativeTimeValueSchema = Joi.object().keys({\n type: Joi.string().required(),\n timePeriod: Joi.string().required(),\n timeUnit: Joi.string().required(),\n direction: Joi.string().required(),\n timeOnly: Joi.boolean().required()\n})\n\nconst conditionRefSchema = Joi.object().keys({\n conditionName: Joi.string().required(),\n conditionDisplayName: Joi.string().required(),\n coordinator: Joi.string().optional()\n})\n\nconst conditionSchema = Joi.object().keys({\n field: conditionFieldSchema,\n operator: Joi.string().required(),\n value: Joi.alternatives().try(conditionValueSchema, relativeTimeValueSchema),\n coordinator: Joi.string().optional()\n})\n\nconst conditionGroupSchema = Joi.object().keys({\n conditions: Joi.array().items(\n Joi.alternatives().try(\n conditionSchema,\n conditionRefSchema,\n Joi.any() /** Should be a joi.link('#conditionGroupSchema') */\n )\n )\n})\n\nconst conditionsModelSchema = Joi.alternatives<ConditionWrapperValue>().try(\n Joi.string(),\n Joi.object().keys({\n name: Joi.string().required(),\n conditions: Joi.array().items(\n Joi.alternatives().try(\n conditionSchema,\n conditionRefSchema,\n conditionGroupSchema\n )\n )\n })\n)\n\nconst conditionsSchema = Joi.object<ConditionRawData>().keys({\n name: Joi.string().required(),\n displayName: Joi.string(),\n value: conditionsModelSchema.required()\n})\n\nconst localisedString = Joi.alternatives().try(\n Joi.object({ a: Joi.any() }).unknown(),\n Joi.string().allow('')\n)\n\nexport const componentSchema = Joi.object<ComponentDef>()\n .keys({\n type: Joi.string<ComponentType>().required(),\n name: Joi.string(),\n title: localisedString,\n hint: localisedString.optional(),\n options: Joi.object().default({}),\n schema: Joi.object({ min: Joi.number(), max: Joi.number() })\n .unknown(true)\n .default({}),\n list: Joi.string().optional()\n })\n .unknown(true)\n\nconst nextSchema = Joi.object<Next>().keys({\n path: Joi.string().required(),\n condition: Joi.string().allow('').optional(),\n redirect: Joi.string().optional()\n})\n\n/**\n * `/status` is a special route for providing a user's application status.\n * It should not be configured via the designer.\n */\nconst pageSchema = Joi.object<Page | RepeatingFieldPage>().keys({\n path: Joi.string().required().disallow('/status'),\n title: localisedString,\n section: Joi.string(),\n controller: Joi.string().optional(),\n components: Joi.array<ComponentDef>().items(componentSchema),\n next: Joi.array<Next>().items(nextSchema),\n repeatField: Joi.string().optional(),\n options: Joi.object().optional(),\n backLinkFallback: Joi.string().optional()\n})\n\nconst toggleableString = Joi.alternatives().try(Joi.boolean(), Joi.string())\n\nconst confirmationPageSchema = Joi.object<ConfirmationPage>({\n customText: Joi.object<ConfirmationPage['customText']>({\n title: Joi.string().default('Application complete'),\n nextSteps: toggleableString.default(\n 'You will receive an email with details with the next steps.'\n )\n }).default(),\n components: Joi.array<ComponentDef>().items(componentSchema)\n})\n\nconst specialPagesSchema = Joi.object<SpecialPages>().keys({\n confirmationPage: confirmationPageSchema.optional()\n})\n\nconst baseListItemSchema = Joi.object<Item>().keys({\n text: localisedString,\n description: localisedString.optional(),\n conditional: Joi.object<Item['conditional']>()\n .keys({\n components: Joi.array<ComponentDef>()\n .required()\n .items(componentSchema.unknown(true))\n .unique('name')\n })\n .allow(null)\n .optional(),\n condition: Joi.string().allow(null, '').optional()\n})\n\nconst stringListItemSchema = baseListItemSchema.append({\n value: Joi.string().required()\n})\n\nconst numberListItemSchema = baseListItemSchema.append({\n value: Joi.number().required()\n})\n\nconst listSchema = Joi.object<List>().keys({\n name: Joi.string().required(),\n title: localisedString,\n type: Joi.string().required().valid('string', 'number'),\n items: Joi.when('type', {\n is: 'string',\n then: Joi.array()\n .items(stringListItemSchema)\n .unique('text')\n .unique('value'),\n otherwise: Joi.array()\n .items(numberListItemSchema)\n .unique('text')\n .unique('value')\n })\n})\n\nconst feedbackSchema = Joi.object<FormDefinition['feedback']>().keys({\n feedbackForm: Joi.boolean().default(false),\n url: Joi.when('feedbackForm', {\n is: Joi.boolean().valid(false),\n then: Joi.string().optional().allow('')\n }),\n emailAddress: Joi.string()\n .email({\n tlds: {\n allow: false\n }\n })\n .optional()\n})\n\nconst phaseBannerSchema = Joi.object<PhaseBanner>().keys({\n phase: Joi.string().valid('alpha', 'beta')\n})\n\n/**\n * Joi schema for `FormDefinition` interface\n * @see {@link FormDefinition}\n */\nexport const formDefinitionSchema = Joi.object<FormDefinition>()\n .required()\n .keys({\n name: localisedString.optional(),\n feedback: feedbackSchema.optional(),\n startPage: Joi.string().optional(),\n pages: Joi.array<Page | RepeatingFieldPage>()\n .required()\n .items(pageSchema)\n .unique('path'),\n sections: Joi.array<Section>()\n .items(sectionsSchema)\n .unique('name')\n .required(),\n conditions: Joi.array<ConditionRawData>()\n .items(conditionsSchema)\n .unique('name'),\n lists: Joi.array<List>().items(listSchema).unique('name'),\n metadata: Joi.object({ a: Joi.any() }).unknown().optional(),\n declaration: Joi.string().allow('').optional(),\n skipSummary: Joi.boolean().optional().default(false),\n phaseBanner: phaseBannerSchema.optional(),\n specialPages: specialPagesSchema.optional(),\n outputEmail: Joi.string()\n .email({ tlds: { allow: ['uk'] } })\n .trim()\n .optional()\n })\n\n// Maintain compatibility with legacy named export\n// E.g. `import { Schema } from '@defra/forms-model'`\nexport const Schema = formDefinitionSchema\n"],"mappings":"AAAA,OAAOA,GAAG,MAAM,KAAK;AAmBrB;AACA;AACA;AACA;AACA,OAAO,MAAMC,eAAe,GAAG,CAAC;AAEhC,MAAMC,cAAc,GAAGF,GAAG,CAACG,MAAM,CAAU,CAAC,CAACC,IAAI,CAAC;EAChDC,IAAI,EAAEL,GAAG,CAACM,MAAM,CAAC,CAAC,CAACC,QAAQ,CAAC,CAAC;EAC7BC,KAAK,EAAER,GAAG,CAACM,MAAM,CAAC,CAAC,CAACC,QAAQ,CAAC,CAAC;EAC9BE,SAAS,EAAET,GAAG,CAACU,OAAO,CAAC,CAAC,CAACC,QAAQ,CAAC,CAAC,CAACC,OAAO,CAAC,KAAK;AACnD,CAAC,CAAC;AAEF,MAAMC,oBAAoB,GAAGb,GAAG,CAACG,MAAM,CAAC,CAA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M,CAAC,MAAM,CAAC,CACdnE,QAAQ,CAAC,CAAC;EACb0B,UAAU,EAAEjC,GAAG,CAACkC,KAAK,CAAmB,CAAC,CACtCC,KAAK,CAACG,gBAAgB,CAAC,CACvBoC,MAAM,CAAC,MAAM,CAAC;EACjBuB,KAAK,EAAEjG,GAAG,CAACkC,KAAK,CAAO,CAAC,CAACC,KAAK,CAAC2C,UAAU,CAAC,CAACJ,MAAM,CAAC,MAAM,CAAC;EACzDwB,QAAQ,EAAElG,GAAG,CAACG,MAAM,CAAC;IAAEsC,CAAC,EAAEzC,GAAG,CAACoC,GAAG,CAAC;EAAE,CAAC,CAAC,CAACM,OAAO,CAAC,CAAC,CAAC/B,QAAQ,CAAC,CAAC;EAC3DwF,WAAW,EAAEnG,GAAG,CAACM,MAAM,CAAC,CAAC,CAACqC,KAAK,CAAC,EAAE,CAAC,CAAChC,QAAQ,CAAC,CAAC;EAC9CyF,WAAW,EAAEpG,GAAG,CAACU,OAAO,CAAC,CAAC,CAACC,QAAQ,CAAC,CAAC,CAACC,OAAO,CAAC,KAAK,CAAC;EACpDyF,WAAW,EAAEX,iBAAiB,CAAC/E,QAAQ,CAAC,CAAC;EACzC2F,YAAY,EAAElC,kBAAkB,CAACzD,QAAQ,CAAC,CAAC;EAC3C4F,WAAW,EAAEvG,GAAG,CAACM,MAAM,CAAC,CAAC,CACtBkF,KAAK,CAAC;IAAEC,IAAI,EAAE;MAAE9C,KAAK,EAAE,CAAC,IAAI;IAAE;EAAE,CAAC,CAAC,CAClC6D,IAAI,CAAC,CAAC,CACN7F,QAAQ,CAAC;AACd,CAAC,CAAC;;AAEJ;AACA;AACA,OAAO,MAAM8F,MAAM,GAAGb,oBAAoB","ignoreList":[]}
|
@@ -1,3 +1,9 @@
|
|
1
|
+
import { ComponentSubType } from '../components/enums.js';
|
1
2
|
import { type ComponentDef } from '../components/types.js';
|
2
|
-
|
3
|
+
/**
|
4
|
+
* Defaults for creating new components
|
5
|
+
*/
|
6
|
+
export declare const ComponentTypes: (ComponentDef & {
|
7
|
+
subType?: ComponentSubType;
|
8
|
+
})[];
|
3
9
|
//# 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":"
|
1
|
+
{"version":3,"file":"component-types.d.ts","sourceRoot":"","sources":["../../../src/components/component-types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAiB,MAAM,2BAA2B,CAAA;AAC3E,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAE7D;;GAEG;AACH,eAAO,MAAM,cAAc,EAAE,CAAC,YAAY,GAAG;IAC3C,OAAO,CAAC,EAAE,gBAAgB,CAAA;CAC3B,CAAC,EAmKD,CAAA"}
|
@@ -1,5 +1,11 @@
|
|
1
1
|
import { ComponentType } from '../components/enums.js';
|
2
2
|
import { type InputFieldsComponentsDef, type ComponentDef, type ConditionalComponentsDef, type ConditionalComponentType, type ContentComponentsDef, type HtmlComponent, type InsetTextComponent, type ListComponentsDef, type SelectionComponentsDef, type EditorComponentsDef } from '../components/types.js';
|
3
|
+
/**
|
4
|
+
* Return component defaults by type
|
5
|
+
*/
|
6
|
+
export declare function getComponentDefaults(component?: Partial<ComponentDef>): (ComponentDef & {
|
7
|
+
subType?: import("../components/enums.js").ComponentSubType;
|
8
|
+
}) | undefined;
|
3
9
|
/**
|
4
10
|
* Filter known components with support for conditions
|
5
11
|
*/
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/components/helpers.ts"],"names":[],"mappings":"
|
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,wBAAwB,EAC7B,KAAK,YAAY,EACjB,KAAK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1
|
export { ComponentTypes } from '../components/component-types.js';
|
2
|
-
export { hasConditionSupport, hasContentField, hasEditor, hasInputField, hasListField, hasSelectionFields, hasTitle } from '../components/helpers.js';
|
2
|
+
export { getComponentDefaults, hasConditionSupport, hasContentField, hasEditor, hasInputField, hasListField, hasSelectionFields, hasTitle } from '../components/helpers.js';
|
3
3
|
export { ComponentType, ComponentSubType } 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,mBAAmB,EACnB,eAAe,EACf,SAAS,EACT,aAAa,EACb,YAAY,EACZ,kBAAkB,EAClB,QAAQ,EACT,MAAM,6BAA6B,CAAA;AAEpC,OAAO,EAAE,aAAa,EAAE,gBAAgB,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,eAAe,EACf,SAAS,EACT,aAAa,EACb,YAAY,EACZ,kBAAkB,EAClB,QAAQ,EACT,MAAM,6BAA6B,CAAA;AAEpC,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAA"}
|
@@ -1,11 +1,10 @@
|
|
1
|
-
import { type
|
1
|
+
import { type ComponentType } from '../components/enums.js';
|
2
2
|
export type ConditionalComponentType = ComponentType.RadiosField | ComponentType.CheckboxesField | ComponentType.DatePartsField | ComponentType.EmailAddressField | ComponentType.MultilineTextField | ComponentType.NumberField | ComponentType.TextField | ComponentType.TimeField | ComponentType.YesNoField;
|
3
3
|
/**
|
4
4
|
* Types for Components JSON structure which are expected by engine and turned into actual form input/content/lists
|
5
5
|
*/
|
6
6
|
interface TextFieldBase {
|
7
7
|
type: ComponentType.EmailAddressField | ComponentType.MultilineTextField | ComponentType.NumberField | ComponentType.TelephoneNumberField | ComponentType.TextField | ComponentType.UkAddressField | ComponentType.YesNoField;
|
8
|
-
subType?: ComponentSubType.Field;
|
9
8
|
name: string;
|
10
9
|
title: string;
|
11
10
|
hint?: string;
|
@@ -15,7 +14,6 @@ interface TextFieldBase {
|
|
15
14
|
classes?: string;
|
16
15
|
allow?: string;
|
17
16
|
autocomplete?: string;
|
18
|
-
exposeToContext?: boolean;
|
19
17
|
};
|
20
18
|
schema: {
|
21
19
|
max?: number;
|
@@ -27,7 +25,6 @@ interface TextFieldBase {
|
|
27
25
|
}
|
28
26
|
interface NumberFieldBase {
|
29
27
|
type: ComponentType;
|
30
|
-
subType?: ComponentSubType.Field;
|
31
28
|
name: string;
|
32
29
|
title: string;
|
33
30
|
hint?: string;
|
@@ -37,7 +34,6 @@ interface NumberFieldBase {
|
|
37
34
|
classes?: string;
|
38
35
|
prefix?: string;
|
39
36
|
suffix?: string;
|
40
|
-
exposeToContext?: boolean;
|
41
37
|
};
|
42
38
|
schema: {
|
43
39
|
min?: number;
|
@@ -47,7 +43,6 @@ interface NumberFieldBase {
|
|
47
43
|
}
|
48
44
|
interface ListFieldBase {
|
49
45
|
type: ComponentType.AutocompleteField | ComponentType.CheckboxesField | ComponentType.List | ComponentType.RadiosField | ComponentType.SelectField;
|
50
|
-
subType?: ComponentSubType.Content | ComponentSubType.ListField;
|
51
46
|
name: string;
|
52
47
|
title: string;
|
53
48
|
options: {
|
@@ -56,26 +51,22 @@ interface ListFieldBase {
|
|
56
51
|
optionalText?: boolean;
|
57
52
|
classes?: string;
|
58
53
|
bold?: boolean;
|
59
|
-
exposeToContext?: boolean;
|
60
|
-
allowPrePopulation?: boolean;
|
61
54
|
};
|
62
55
|
list: string;
|
63
56
|
schema: object;
|
64
57
|
}
|
65
58
|
interface ContentFieldBase {
|
66
59
|
type: ComponentType.Details | ComponentType.Html | ComponentType.InsetText;
|
67
|
-
subType?: ComponentSubType.Content;
|
68
60
|
name: string;
|
69
61
|
title: string;
|
70
62
|
content: string;
|
71
63
|
options: {
|
72
64
|
condition?: string;
|
73
65
|
};
|
74
|
-
schema
|
66
|
+
schema: object;
|
75
67
|
}
|
76
68
|
interface DateFieldBase {
|
77
69
|
type: ComponentType.DatePartsField | ComponentType.MonthYearField | ComponentType.TimeField;
|
78
|
-
subType?: ComponentSubType.Field;
|
79
70
|
name: string;
|
80
71
|
title: string;
|
81
72
|
hint?: string;
|
@@ -84,7 +75,6 @@ interface DateFieldBase {
|
|
84
75
|
optionalText?: boolean;
|
85
76
|
maxDaysInFuture?: number;
|
86
77
|
maxDaysInPast?: number;
|
87
|
-
exposeToContext?: boolean;
|
88
78
|
};
|
89
79
|
schema: object;
|
90
80
|
}
|
@@ -172,25 +162,21 @@ export interface ListComponent extends ListFieldBase {
|
|
172
162
|
}
|
173
163
|
export interface AutocompleteFieldComponent extends ListFieldBase {
|
174
164
|
type: ComponentType.AutocompleteField;
|
175
|
-
subType?: ComponentSubType.ListField;
|
176
165
|
}
|
177
166
|
export interface CheckboxesFieldComponent extends ListFieldBase {
|
178
167
|
type: ComponentType.CheckboxesField;
|
179
|
-
subType?: ComponentSubType.ListField;
|
180
168
|
options: ListFieldBase['options'] & {
|
181
169
|
condition?: string;
|
182
170
|
};
|
183
171
|
}
|
184
172
|
export interface RadiosFieldComponent extends ListFieldBase {
|
185
173
|
type: ComponentType.RadiosField;
|
186
|
-
subType?: ComponentSubType.ListField;
|
187
174
|
options: ListFieldBase['options'] & {
|
188
175
|
condition?: string;
|
189
176
|
};
|
190
177
|
}
|
191
178
|
export interface SelectFieldComponent extends ListFieldBase {
|
192
179
|
type: ComponentType.SelectField;
|
193
|
-
subType?: ComponentSubType.ListField;
|
194
180
|
options: ListFieldBase['options'] & {
|
195
181
|
autocomplete?: string;
|
196
182
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/types.ts"],"names":[],"mappings":"AAAA,OAAO,
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,2BAA2B,CAAA;AAE9D,MAAM,MAAM,wBAAwB,GAChC,aAAa,CAAC,WAAW,GACzB,aAAa,CAAC,eAAe,GAC7B,aAAa,CAAC,cAAc,GAC5B,aAAa,CAAC,iBAAiB,GAC/B,aAAa,CAAC,kBAAkB,GAChC,aAAa,CAAC,WAAW,GACzB,aAAa,CAAC,SAAS,GACvB,aAAa,CAAC,SAAS,GACvB,aAAa,CAAC,UAAU,CAAA;AAE5B;;GAEG;AACH,UAAU,aAAa;IACrB,IAAI,EACA,aAAa,CAAC,iBAAiB,GAC/B,aAAa,CAAC,kBAAkB,GAChC,aAAa,CAAC,WAAW,GACzB,aAAa,CAAC,oBAAoB,GAClC,aAAa,CAAC,SAAS,GACvB,aAAa,CAAC,cAAc,GAC5B,aAAa,CAAC,UAAU,CAAA;IAC5B,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;QAChB,KAAK,CAAC,EAAE,MAAM,CAAA;QACd,YAAY,CAAC,EAAE,MAAM,CAAA;KACtB,CAAA;IACD,MAAM,EAAE;QACN,GAAG,CAAC,EAAE,MAAM,CAAA;QACZ,GAAG,CAAC,EAAE,MAAM,CAAA;QACZ,MAAM,CAAC,EAAE,MAAM,CAAA;QACf,KAAK,CAAC,EAAE,MAAM,CAAA;QACd,KAAK,CAAC,EAAE,OAAO,CAAA;KAChB,CAAA;CACF;AAED,UAAU,eAAe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AAuB,GACvB,gBAAgB,GAChB,0BAA0B,GAC1B,aAAa,GACb,aAAa,GACb,2BAA2B,GAC3B,oBAAoB,GACpB,oBAAoB,GACpB,oBAAoB,GACpB,6BAA6B,GAC7B,kBAAkB,GAClB,kBAAkB,GAClB,uBAAuB,GACvB,mBAAmB,CAAA;AAGvB,MAAM,MAAM,wBAAwB,GAChC,kBAAkB,GAClB,0BAA0B,GAC1B,oBAAoB,GACpB,2BAA2B,GAC3B,6BAA6B,GAC7B,mBAAmB,GACnB,uBAAuB,GACvB,kBAAkB,GAClB,uBAAuB,CAAA;AAG3B,MAAM,MAAM,oBAAoB,GAC5B,gBAAgB,GAChB,aAAa,GACb,kBAAkB,CAAA;AAGtB,MAAM,MAAM,mBAAmB,GAC3B,kBAAkB,GAClB,0BAA0B,GAC1B,6BAA6B,GAC7B,2BAA2B,GAC3B,oBAAoB,GACpB,0BAA0B,GAC1B,oBAAoB,GACpB,oBAAoB,GACpB,wBAAwB,GACxB,aAAa,GACb,gBAAgB,GAChB,aAAa,GACb,kBAAkB,GAClB,4BAA4B,CAAA;AAGhC,MAAM,MAAM,iBAAiB,GACzB,aAAa,GACb,0BAA0B,GAC1B,wBAAwB,GACxB,oBAAoB,GACpB,oBAAoB,CAAA;AAGxB,MAAM,MAAM,sBAAsB,GAC9B,wBAAwB,GACxB,oBAAoB,GACpB,oBAAoB,GACpB,mBAAmB,CAAA;AAGvB,MAAM,MAAM,wBAAwB,GAChC,wBAAwB,GACxB,4BAA4B,GAC5B,0BAA0B,GAC1B,2BAA2B,GAC3B,oBAAoB,GACpB,kBAAkB,GAClB,kBAAkB,GAClB,mBAAmB,CAAA"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/form/form-definition/index.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,KAAK,CAAA;
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/form/form-definition/index.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,KAAK,CAAA;AAGrB,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAC7D,OAAO,EAIL,KAAK,cAAc,EASpB,MAAM,qCAAqC,CAAA;AAE5C;;;GAGG;AACH,eAAO,MAAM,eAAe,IAAI,CAAA;AA4EhC,eAAO,MAAM,eAAe,gCAYZ,CAAA;AAmGhB;;;GAGG;AACH,eAAO,MAAM,oBAAoB,kCA2B7B,CAAA;AAIJ,eAAO,MAAM,MAAM,kCAAuB,CAAA"}
|
package/package.json
CHANGED
@@ -1,11 +1,16 @@
|
|
1
1
|
import { ComponentSubType, ComponentType } from '~/src/components/enums.js'
|
2
2
|
import { type ComponentDef } from '~/src/components/types.js'
|
3
3
|
|
4
|
-
|
4
|
+
/**
|
5
|
+
* Defaults for creating new components
|
6
|
+
*/
|
7
|
+
export const ComponentTypes: (ComponentDef & {
|
8
|
+
subType?: ComponentSubType
|
9
|
+
})[] = [
|
5
10
|
{
|
6
11
|
name: 'TextField',
|
7
|
-
type: ComponentType.TextField,
|
8
12
|
title: 'Text field',
|
13
|
+
type: ComponentType.TextField,
|
9
14
|
subType: ComponentSubType.Field,
|
10
15
|
hint: '',
|
11
16
|
options: {},
|
@@ -13,8 +18,8 @@ export const ComponentTypes: ComponentDef[] = [
|
|
13
18
|
},
|
14
19
|
{
|
15
20
|
name: 'MultilineTextField',
|
16
|
-
type: ComponentType.MultilineTextField,
|
17
21
|
title: 'Multiline text field',
|
22
|
+
type: ComponentType.MultilineTextField,
|
18
23
|
subType: ComponentSubType.Field,
|
19
24
|
hint: '',
|
20
25
|
options: {},
|
@@ -22,8 +27,8 @@ export const ComponentTypes: ComponentDef[] = [
|
|
22
27
|
},
|
23
28
|
{
|
24
29
|
name: 'YesNoField',
|
25
|
-
type: ComponentType.YesNoField,
|
26
30
|
title: 'Yes/No field',
|
31
|
+
type: ComponentType.YesNoField,
|
27
32
|
subType: ComponentSubType.Field,
|
28
33
|
hint: '',
|
29
34
|
options: {},
|
@@ -31,8 +36,8 @@ export const ComponentTypes: ComponentDef[] = [
|
|
31
36
|
},
|
32
37
|
{
|
33
38
|
name: 'TimeField',
|
34
|
-
type: ComponentType.TimeField,
|
35
39
|
title: 'Time field',
|
40
|
+
type: ComponentType.TimeField,
|
36
41
|
subType: ComponentSubType.Field,
|
37
42
|
hint: '',
|
38
43
|
options: {},
|
@@ -40,8 +45,8 @@ export const ComponentTypes: ComponentDef[] = [
|
|
40
45
|
},
|
41
46
|
{
|
42
47
|
name: 'DatePartsField',
|
43
|
-
type: ComponentType.DatePartsField,
|
44
48
|
title: 'Date field',
|
49
|
+
type: ComponentType.DatePartsField,
|
45
50
|
subType: ComponentSubType.Field,
|
46
51
|
hint: '',
|
47
52
|
options: {},
|
@@ -49,8 +54,8 @@ export const ComponentTypes: ComponentDef[] = [
|
|
49
54
|
},
|
50
55
|
{
|
51
56
|
name: 'MonthYearField',
|
52
|
-
type: ComponentType.MonthYearField,
|
53
57
|
title: 'Month & year field',
|
58
|
+
type: ComponentType.MonthYearField,
|
54
59
|
subType: ComponentSubType.Field,
|
55
60
|
hint: '',
|
56
61
|
options: {},
|
@@ -58,8 +63,8 @@ export const ComponentTypes: ComponentDef[] = [
|
|
58
63
|
},
|
59
64
|
{
|
60
65
|
name: 'SelectField',
|
61
|
-
type: ComponentType.SelectField,
|
62
66
|
title: 'Select field',
|
67
|
+
type: ComponentType.SelectField,
|
63
68
|
subType: ComponentSubType.ListField,
|
64
69
|
options: {},
|
65
70
|
schema: {},
|
@@ -67,8 +72,8 @@ export const ComponentTypes: ComponentDef[] = [
|
|
67
72
|
},
|
68
73
|
{
|
69
74
|
name: 'AutocompleteField',
|
70
|
-
type: ComponentType.AutocompleteField,
|
71
75
|
title: 'Autocomplete field',
|
76
|
+
type: ComponentType.AutocompleteField,
|
72
77
|
subType: ComponentSubType.ListField,
|
73
78
|
options: {},
|
74
79
|
schema: {},
|
@@ -76,8 +81,8 @@ export const ComponentTypes: ComponentDef[] = [
|
|
76
81
|
},
|
77
82
|
{
|
78
83
|
name: 'RadiosField',
|
79
|
-
type: ComponentType.RadiosField,
|
80
84
|
title: 'Radios field',
|
85
|
+
type: ComponentType.RadiosField,
|
81
86
|
subType: ComponentSubType.ListField,
|
82
87
|
options: {},
|
83
88
|
schema: {},
|
@@ -85,8 +90,8 @@ export const ComponentTypes: ComponentDef[] = [
|
|
85
90
|
},
|
86
91
|
{
|
87
92
|
name: 'CheckboxesField',
|
88
|
-
type: ComponentType.CheckboxesField,
|
89
93
|
title: 'Checkboxes field',
|
94
|
+
type: ComponentType.CheckboxesField,
|
90
95
|
subType: ComponentSubType.ListField,
|
91
96
|
options: {},
|
92
97
|
schema: {},
|
@@ -94,8 +99,8 @@ export const ComponentTypes: ComponentDef[] = [
|
|
94
99
|
},
|
95
100
|
{
|
96
101
|
name: 'NumberField',
|
97
|
-
type: ComponentType.NumberField,
|
98
102
|
title: 'Number field',
|
103
|
+
type: ComponentType.NumberField,
|
99
104
|
subType: ComponentSubType.Field,
|
100
105
|
hint: '',
|
101
106
|
options: {},
|
@@ -103,8 +108,8 @@ export const ComponentTypes: ComponentDef[] = [
|
|
103
108
|
},
|
104
109
|
{
|
105
110
|
name: 'UkAddressField',
|
106
|
-
type: ComponentType.UkAddressField,
|
107
111
|
title: 'UK address field',
|
112
|
+
type: ComponentType.UkAddressField,
|
108
113
|
subType: ComponentSubType.Field,
|
109
114
|
hint: '',
|
110
115
|
options: {},
|
@@ -112,8 +117,8 @@ export const ComponentTypes: ComponentDef[] = [
|
|
112
117
|
},
|
113
118
|
{
|
114
119
|
name: 'TelephoneNumberField',
|
115
|
-
type: ComponentType.TelephoneNumberField,
|
116
120
|
title: 'Telephone number field',
|
121
|
+
type: ComponentType.TelephoneNumberField,
|
117
122
|
subType: ComponentSubType.Field,
|
118
123
|
hint: '',
|
119
124
|
options: {},
|
@@ -121,8 +126,8 @@ export const ComponentTypes: ComponentDef[] = [
|
|
121
126
|
},
|
122
127
|
{
|
123
128
|
name: 'EmailAddressField',
|
124
|
-
type: ComponentType.EmailAddressField,
|
125
129
|
title: 'Email address field',
|
130
|
+
type: ComponentType.EmailAddressField,
|
126
131
|
subType: ComponentSubType.Field,
|
127
132
|
hint: '',
|
128
133
|
options: {},
|
@@ -130,8 +135,8 @@ export const ComponentTypes: ComponentDef[] = [
|
|
130
135
|
},
|
131
136
|
{
|
132
137
|
name: 'Html',
|
133
|
-
type: ComponentType.Html,
|
134
138
|
title: 'Html',
|
139
|
+
type: ComponentType.Html,
|
135
140
|
subType: ComponentSubType.Content,
|
136
141
|
content: '',
|
137
142
|
options: {},
|
@@ -139,8 +144,8 @@ export const ComponentTypes: ComponentDef[] = [
|
|
139
144
|
},
|
140
145
|
{
|
141
146
|
name: 'InsetText',
|
142
|
-
type: ComponentType.InsetText,
|
143
147
|
title: 'Inset text',
|
148
|
+
type: ComponentType.InsetText,
|
144
149
|
subType: ComponentSubType.Content,
|
145
150
|
content: '',
|
146
151
|
options: {},
|
@@ -148,8 +153,8 @@ export const ComponentTypes: ComponentDef[] = [
|
|
148
153
|
},
|
149
154
|
{
|
150
155
|
name: 'Details',
|
151
|
-
type: ComponentType.Details,
|
152
156
|
title: 'Details',
|
157
|
+
type: ComponentType.Details,
|
153
158
|
subType: ComponentSubType.Content,
|
154
159
|
content: '',
|
155
160
|
options: {},
|
@@ -157,8 +162,9 @@ export const ComponentTypes: ComponentDef[] = [
|
|
157
162
|
},
|
158
163
|
{
|
159
164
|
name: 'List',
|
160
|
-
type: ComponentType.List,
|
161
165
|
title: 'List',
|
166
|
+
type: ComponentType.List,
|
167
|
+
subType: ComponentSubType.Content,
|
162
168
|
options: {},
|
163
169
|
schema: {},
|
164
170
|
list: ''
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import { ComponentTypes } from '~/src/components/component-types.js'
|
1
2
|
import { ComponentType } from '~/src/components/enums.js'
|
2
3
|
import {
|
3
4
|
type InputFieldsComponentsDef,
|
@@ -12,6 +13,17 @@ import {
|
|
12
13
|
type EditorComponentsDef
|
13
14
|
} from '~/src/components/types.js'
|
14
15
|
|
16
|
+
/**
|
17
|
+
* Return component defaults by type
|
18
|
+
*/
|
19
|
+
export function getComponentDefaults(component?: Partial<ComponentDef>) {
|
20
|
+
if (!component?.type) {
|
21
|
+
return
|
22
|
+
}
|
23
|
+
|
24
|
+
return ComponentTypes.find(({ type }) => type === component.type)
|
25
|
+
}
|
26
|
+
|
15
27
|
/**
|
16
28
|
* Filter known components with support for conditions
|
17
29
|
*/
|
package/src/components/index.ts
CHANGED
package/src/components/types.ts
CHANGED
@@ -1,7 +1,4 @@
|
|
1
|
-
import {
|
2
|
-
type ComponentSubType,
|
3
|
-
type ComponentType
|
4
|
-
} from '~/src/components/enums.js'
|
1
|
+
import { type ComponentType } from '~/src/components/enums.js'
|
5
2
|
|
6
3
|
export type ConditionalComponentType =
|
7
4
|
| ComponentType.RadiosField
|
@@ -26,7 +23,6 @@ interface TextFieldBase {
|
|
26
23
|
| ComponentType.TextField
|
27
24
|
| ComponentType.UkAddressField
|
28
25
|
| ComponentType.YesNoField
|
29
|
-
subType?: ComponentSubType.Field
|
30
26
|
name: string
|
31
27
|
title: string
|
32
28
|
hint?: string
|
@@ -36,7 +32,6 @@ interface TextFieldBase {
|
|
36
32
|
classes?: string
|
37
33
|
allow?: string
|
38
34
|
autocomplete?: string
|
39
|
-
exposeToContext?: boolean
|
40
35
|
}
|
41
36
|
schema: {
|
42
37
|
max?: number
|
@@ -49,7 +44,6 @@ interface TextFieldBase {
|
|
49
44
|
|
50
45
|
interface NumberFieldBase {
|
51
46
|
type: ComponentType
|
52
|
-
subType?: ComponentSubType.Field
|
53
47
|
name: string
|
54
48
|
title: string
|
55
49
|
hint?: string
|
@@ -59,7 +53,6 @@ interface NumberFieldBase {
|
|
59
53
|
classes?: string
|
60
54
|
prefix?: string
|
61
55
|
suffix?: string
|
62
|
-
exposeToContext?: boolean
|
63
56
|
}
|
64
57
|
schema: {
|
65
58
|
min?: number
|
@@ -75,7 +68,6 @@ interface ListFieldBase {
|
|
75
68
|
| ComponentType.List
|
76
69
|
| ComponentType.RadiosField
|
77
70
|
| ComponentType.SelectField
|
78
|
-
subType?: ComponentSubType.Content | ComponentSubType.ListField
|
79
71
|
name: string
|
80
72
|
title: string
|
81
73
|
options: {
|
@@ -84,8 +76,6 @@ interface ListFieldBase {
|
|
84
76
|
optionalText?: boolean
|
85
77
|
classes?: string
|
86
78
|
bold?: boolean
|
87
|
-
exposeToContext?: boolean
|
88
|
-
allowPrePopulation?: boolean
|
89
79
|
}
|
90
80
|
list: string
|
91
81
|
schema: object
|
@@ -93,14 +83,13 @@ interface ListFieldBase {
|
|
93
83
|
|
94
84
|
interface ContentFieldBase {
|
95
85
|
type: ComponentType.Details | ComponentType.Html | ComponentType.InsetText
|
96
|
-
subType?: ComponentSubType.Content
|
97
86
|
name: string
|
98
87
|
title: string
|
99
88
|
content: string
|
100
89
|
options: {
|
101
90
|
condition?: string
|
102
91
|
}
|
103
|
-
schema
|
92
|
+
schema: object
|
104
93
|
}
|
105
94
|
|
106
95
|
interface DateFieldBase {
|
@@ -108,7 +97,6 @@ interface DateFieldBase {
|
|
108
97
|
| ComponentType.DatePartsField
|
109
98
|
| ComponentType.MonthYearField
|
110
99
|
| ComponentType.TimeField
|
111
|
-
subType?: ComponentSubType.Field
|
112
100
|
name: string
|
113
101
|
title: string
|
114
102
|
hint?: string
|
@@ -117,7 +105,6 @@ interface DateFieldBase {
|
|
117
105
|
optionalText?: boolean
|
118
106
|
maxDaysInFuture?: number
|
119
107
|
maxDaysInPast?: number
|
120
|
-
exposeToContext?: boolean
|
121
108
|
}
|
122
109
|
schema: object
|
123
110
|
}
|
@@ -224,12 +211,10 @@ export interface ListComponent extends ListFieldBase {
|
|
224
211
|
|
225
212
|
export interface AutocompleteFieldComponent extends ListFieldBase {
|
226
213
|
type: ComponentType.AutocompleteField
|
227
|
-
subType?: ComponentSubType.ListField
|
228
214
|
}
|
229
215
|
|
230
216
|
export interface CheckboxesFieldComponent extends ListFieldBase {
|
231
217
|
type: ComponentType.CheckboxesField
|
232
|
-
subType?: ComponentSubType.ListField
|
233
218
|
options: ListFieldBase['options'] & {
|
234
219
|
condition?: string
|
235
220
|
}
|
@@ -237,7 +222,6 @@ export interface CheckboxesFieldComponent extends ListFieldBase {
|
|
237
222
|
|
238
223
|
export interface RadiosFieldComponent extends ListFieldBase {
|
239
224
|
type: ComponentType.RadiosField
|
240
|
-
subType?: ComponentSubType.ListField
|
241
225
|
options: ListFieldBase['options'] & {
|
242
226
|
condition?: string
|
243
227
|
}
|
@@ -245,7 +229,6 @@ export interface RadiosFieldComponent extends ListFieldBase {
|
|
245
229
|
|
246
230
|
export interface SelectFieldComponent extends ListFieldBase {
|
247
231
|
type: ComponentType.SelectField
|
248
|
-
subType?: ComponentSubType.ListField
|
249
232
|
options: ListFieldBase['options'] & { autocomplete?: string }
|
250
233
|
}
|
251
234
|
|
@@ -1,9 +1,6 @@
|
|
1
1
|
import Joi from 'joi'
|
2
2
|
|
3
|
-
import {
|
4
|
-
type ComponentSubType,
|
5
|
-
type ComponentType
|
6
|
-
} from '~/src/components/enums.js'
|
3
|
+
import { type ComponentType } from '~/src/components/enums.js'
|
7
4
|
import { type ComponentDef } from '~/src/components/types.js'
|
8
5
|
import {
|
9
6
|
type ConditionRawData,
|
@@ -102,7 +99,6 @@ const localisedString = Joi.alternatives().try(
|
|
102
99
|
|
103
100
|
export const componentSchema = Joi.object<ComponentDef>()
|
104
101
|
.keys({
|
105
|
-
subType: Joi.string<ComponentSubType>().optional(),
|
106
102
|
type: Joi.string<ComponentType>().required(),
|
107
103
|
name: Joi.string(),
|
108
104
|
title: localisedString,
|