@defra/forms-model 3.0.687 → 3.0.689

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/dist/module/__stubs__/examples.js +185 -0
  2. package/dist/module/__stubs__/examples.js.map +1 -0
  3. package/dist/module/components/helpers.js +4 -0
  4. package/dist/module/components/helpers.js.map +1 -1
  5. package/dist/module/components/types.js.map +1 -1
  6. package/dist/module/form/form-editor/translations/translations-config.js +168 -0
  7. package/dist/module/form/form-editor/translations/translations-config.js.map +1 -0
  8. package/dist/module/form/form-editor/translations/translations-overview.js +93 -0
  9. package/dist/module/form/form-editor/translations/translations-overview.js.map +1 -0
  10. package/dist/module/form/form-editor/translations/translations.js +214 -0
  11. package/dist/module/form/form-editor/translations/translations.js.map +1 -0
  12. package/dist/module/form/form-submission/index.js +3 -0
  13. package/dist/module/form/form-submission/index.js.map +1 -1
  14. package/dist/module/form/form-submission/types.js.map +1 -1
  15. package/dist/module/form/utils/list.js +23 -0
  16. package/dist/module/form/utils/list.js.map +1 -1
  17. package/dist/module/form/utils/numbering.js +43 -0
  18. package/dist/module/form/utils/numbering.js.map +1 -0
  19. package/dist/module/index.js +2 -0
  20. package/dist/module/index.js.map +1 -1
  21. package/dist/types/__stubs__/examples.d.ts +9 -0
  22. package/dist/types/__stubs__/examples.d.ts.map +1 -0
  23. package/dist/types/components/helpers.d.ts +2 -1
  24. package/dist/types/components/helpers.d.ts.map +1 -1
  25. package/dist/types/components/types.d.ts +1 -0
  26. package/dist/types/components/types.d.ts.map +1 -1
  27. package/dist/types/form/form-editor/translations/translations-config.d.ts +95 -0
  28. package/dist/types/form/form-editor/translations/translations-config.d.ts.map +1 -0
  29. package/dist/types/form/form-editor/translations/translations-overview.d.ts +14 -0
  30. package/dist/types/form/form-editor/translations/translations-overview.d.ts.map +1 -0
  31. package/dist/types/form/form-editor/translations/translations.d.ts +16 -0
  32. package/dist/types/form/form-editor/translations/translations.d.ts.map +1 -0
  33. package/dist/types/form/form-submission/index.d.ts.map +1 -1
  34. package/dist/types/form/form-submission/types.d.ts +4 -0
  35. package/dist/types/form/form-submission/types.d.ts.map +1 -1
  36. package/dist/types/form/utils/list.d.ts +8 -1
  37. package/dist/types/form/utils/list.d.ts.map +1 -1
  38. package/dist/types/form/utils/numbering.d.ts +18 -0
  39. package/dist/types/form/utils/numbering.d.ts.map +1 -0
  40. package/dist/types/index.d.ts +2 -0
  41. package/dist/types/index.d.ts.map +1 -1
  42. package/package.json +1 -1
  43. package/schemas/form-submit-payload-schema.json +5 -0
  44. package/src/__stubs__/examples.js +231 -0
  45. package/src/components/helpers.ts +14 -0
  46. package/src/components/types.ts +7 -0
  47. package/src/form/form-editor/translations/translations-config.js +186 -0
  48. package/src/form/form-editor/translations/translations-overview.js +137 -0
  49. package/src/form/form-editor/translations/translations.js +297 -0
  50. package/src/form/form-submission/index.ts +7 -0
  51. package/src/form/form-submission/types.ts +5 -0
  52. package/src/form/utils/list.ts +34 -1
  53. package/src/form/utils/numbering.js +47 -0
  54. package/src/index.ts +2 -0
@@ -0,0 +1,185 @@
1
+ import { buildDeclarationFieldComponent, buildLatLongFieldComponent, buildMarkdownComponent, buildRadiosComponent, buildTextFieldComponent } from "./components.js";
2
+ import { buildDefinition } from "./form-definition.js";
3
+ import { buildQuestionPage, buildRepeaterPage, buildSummaryPage } from "./pages.js";
4
+ export const formDefinitionWithSinglePage = buildDefinition({
5
+ pages: [buildQuestionPage({
6
+ id: 'p1',
7
+ section: 'section',
8
+ components: [buildTextFieldComponent({
9
+ id: 'c1',
10
+ name: 'textField',
11
+ title: 'This is your first field',
12
+ hint: 'Help text'
13
+ })],
14
+ next: [{
15
+ path: '/summary'
16
+ }]
17
+ }), buildSummaryPage({
18
+ id: 'c2'
19
+ })]
20
+ });
21
+ export const formDefinitionWithoutSummary = buildDefinition({
22
+ pages: [buildQuestionPage({
23
+ id: 'p1',
24
+ section: 'section',
25
+ components: [buildTextFieldComponent({
26
+ id: 'c1',
27
+ name: 'textField',
28
+ title: 'This is your first field',
29
+ hint: 'Help text'
30
+ })],
31
+ next: [{
32
+ path: '/summary'
33
+ }]
34
+ })]
35
+ });
36
+ export const formDefinitionWithTwoQuestions = buildDefinition({
37
+ pages: [buildQuestionPage({
38
+ id: 'p1',
39
+ section: 'section',
40
+ components: [buildTextFieldComponent({
41
+ id: 'q1',
42
+ name: 'textField',
43
+ title: 'This is your first question',
44
+ hint: 'Help text'
45
+ }), buildTextFieldComponent({
46
+ id: 'q2',
47
+ name: 'textField',
48
+ title: 'This is your second question',
49
+ hint: 'Help text'
50
+ })],
51
+ next: [{
52
+ path: '/summary'
53
+ }]
54
+ }), buildSummaryPage({
55
+ id: 'p2'
56
+ })]
57
+ });
58
+ export const formDefinitionWithTwoQuestionsAndGuidance = buildDefinition({
59
+ pages: [buildQuestionPage({
60
+ id: 'p1',
61
+ section: 'section',
62
+ components: [buildMarkdownComponent({
63
+ content: 'My markdown text'
64
+ }), buildTextFieldComponent({
65
+ id: 'q1',
66
+ name: 'textField',
67
+ title: 'This is the first textfield question',
68
+ hint: 'Help text'
69
+ }), buildTextFieldComponent({
70
+ id: 'q2',
71
+ name: 'textField',
72
+ title: 'This is the second textfield question',
73
+ hint: 'Help text'
74
+ })],
75
+ next: [{
76
+ path: '/summary'
77
+ }]
78
+ }), buildSummaryPage({
79
+ id: 'p2'
80
+ })]
81
+ });
82
+ export const formDefinitionWithLocationAndDeclaration = buildDefinition({
83
+ pages: [buildQuestionPage({
84
+ id: 'p1',
85
+ section: 'section',
86
+ components: [buildLatLongFieldComponent({
87
+ id: 'q1',
88
+ name: 'latLongField',
89
+ title: 'This is the first lat long field question',
90
+ hint: 'Hint text',
91
+ options: {
92
+ instructionText: 'Some instruction text'
93
+ }
94
+ }), buildDeclarationFieldComponent({
95
+ id: 'q2',
96
+ name: 'declarationField',
97
+ title: 'This is a declaration question',
98
+ hint: 'Declaration hint text',
99
+ content: 'This is the declaration that needs agreeing to',
100
+ shortDescription: 'Declaration short desc'
101
+ })],
102
+ next: [{
103
+ path: '/summary'
104
+ }]
105
+ }), buildSummaryPage({
106
+ id: 'p2'
107
+ })]
108
+ });
109
+ export const formDefinitionWithRepeater = buildDefinition({
110
+ pages: [buildRepeaterPage({
111
+ id: 'p1',
112
+ section: 'section',
113
+ components: [buildTextFieldComponent({
114
+ id: 'q1',
115
+ name: 'TextField',
116
+ title: 'This is the first text field field question',
117
+ hint: 'Hint text',
118
+ shortDescription: 'Short desc'
119
+ })],
120
+ next: [{
121
+ path: '/summary'
122
+ }]
123
+ }), buildSummaryPage({
124
+ id: 'p2'
125
+ })]
126
+ });
127
+ export const formDefinitionWithNoQuestions = buildDefinition({
128
+ pages: [buildQuestionPage({
129
+ id: 'p1',
130
+ section: 'section',
131
+ components: [],
132
+ next: [{
133
+ path: '/summary'
134
+ }]
135
+ }), buildSummaryPage({
136
+ id: 'p2'
137
+ })]
138
+ });
139
+ export const formDefinitionWithRadioQuestion = buildDefinition({
140
+ pages: [buildQuestionPage({
141
+ id: 'p1',
142
+ section: 'section',
143
+ components: [buildRadiosComponent({
144
+ id: 'q1',
145
+ name: 'radioField',
146
+ title: 'This is a radio question',
147
+ hint: 'Help text',
148
+ list: 'my-list-id'
149
+ })],
150
+ next: [{
151
+ path: '/summary'
152
+ }]
153
+ }), buildSummaryPage({
154
+ id: 'p2'
155
+ })],
156
+ lists: [{
157
+ name: 'my-list',
158
+ id: 'my-list-id',
159
+ type: 'string',
160
+ title: 'list for radio',
161
+ items: [{
162
+ id: 'option-1',
163
+ text: 'Option 1',
164
+ hint: {
165
+ text: 'Option 1 hint'
166
+ },
167
+ value: 'Option1'
168
+ }, {
169
+ id: 'option-2',
170
+ text: 'Option 2',
171
+ hint: {
172
+ text: 'Option 2 hint'
173
+ },
174
+ value: 'Option2'
175
+ }, {
176
+ id: 'option-3',
177
+ text: 'Option 3',
178
+ hint: {
179
+ text: 'Option 3 hint'
180
+ },
181
+ value: 'Option3'
182
+ }]
183
+ }]
184
+ });
185
+ //# sourceMappingURL=examples.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"examples.js","names":["buildDeclarationFieldComponent","buildLatLongFieldComponent","buildMarkdownComponent","buildRadiosComponent","buildTextFieldComponent","buildDefinition","buildQuestionPage","buildRepeaterPage","buildSummaryPage","formDefinitionWithSinglePage","pages","id","section","components","name","title","hint","next","path","formDefinitionWithoutSummary","formDefinitionWithTwoQuestions","formDefinitionWithTwoQuestionsAndGuidance","content","formDefinitionWithLocationAndDeclaration","options","instructionText","shortDescription","formDefinitionWithRepeater","formDefinitionWithNoQuestions","formDefinitionWithRadioQuestion","list","lists","type","items","text","value"],"sources":["../../../src/__stubs__/examples.js"],"sourcesContent":["import {\n buildDeclarationFieldComponent,\n buildLatLongFieldComponent,\n buildMarkdownComponent,\n buildRadiosComponent,\n buildTextFieldComponent\n} from '~/src/__stubs__/components.js'\nimport { buildDefinition } from '~/src/__stubs__/form-definition.js'\nimport {\n buildQuestionPage,\n buildRepeaterPage,\n buildSummaryPage\n} from '~/src/__stubs__/pages.js'\n\nexport const formDefinitionWithSinglePage = buildDefinition({\n pages: [\n buildQuestionPage({\n id: 'p1',\n section: 'section',\n components: [\n buildTextFieldComponent({\n id: 'c1',\n name: 'textField',\n title: 'This is your first field',\n hint: 'Help text'\n })\n ],\n next: [{ path: '/summary' }]\n }),\n buildSummaryPage({\n id: 'c2'\n })\n ]\n})\n\nexport const formDefinitionWithoutSummary = buildDefinition({\n pages: [\n buildQuestionPage({\n id: 'p1',\n section: 'section',\n components: [\n buildTextFieldComponent({\n id: 'c1',\n name: 'textField',\n title: 'This is your first field',\n hint: 'Help text'\n })\n ],\n next: [{ path: '/summary' }]\n })\n ]\n})\n\nexport const formDefinitionWithTwoQuestions = buildDefinition({\n pages: [\n buildQuestionPage({\n id: 'p1',\n section: 'section',\n components: [\n buildTextFieldComponent({\n id: 'q1',\n name: 'textField',\n title: 'This is your first question',\n hint: 'Help text'\n }),\n buildTextFieldComponent({\n id: 'q2',\n name: 'textField',\n title: 'This is your second question',\n hint: 'Help text'\n })\n ],\n next: [{ path: '/summary' }]\n }),\n buildSummaryPage({\n id: 'p2'\n })\n ]\n})\n\nexport const formDefinitionWithTwoQuestionsAndGuidance = buildDefinition({\n pages: [\n buildQuestionPage({\n id: 'p1',\n section: 'section',\n components: [\n buildMarkdownComponent({ content: 'My markdown text' }),\n buildTextFieldComponent({\n id: 'q1',\n name: 'textField',\n title: 'This is the first textfield question',\n hint: 'Help text'\n }),\n buildTextFieldComponent({\n id: 'q2',\n name: 'textField',\n title: 'This is the second textfield question',\n hint: 'Help text'\n })\n ],\n next: [{ path: '/summary' }]\n }),\n buildSummaryPage({\n id: 'p2'\n })\n ]\n})\n\nexport const formDefinitionWithLocationAndDeclaration = buildDefinition({\n pages: [\n buildQuestionPage({\n id: 'p1',\n section: 'section',\n components: [\n buildLatLongFieldComponent({\n id: 'q1',\n name: 'latLongField',\n title: 'This is the first lat long field question',\n hint: 'Hint text',\n options: {\n instructionText: 'Some instruction text'\n }\n }),\n buildDeclarationFieldComponent({\n id: 'q2',\n name: 'declarationField',\n title: 'This is a declaration question',\n hint: 'Declaration hint text',\n content: 'This is the declaration that needs agreeing to',\n shortDescription: 'Declaration short desc'\n })\n ],\n next: [{ path: '/summary' }]\n }),\n buildSummaryPage({\n id: 'p2'\n })\n ]\n})\n\nexport const formDefinitionWithRepeater = buildDefinition({\n pages: [\n buildRepeaterPage({\n id: 'p1',\n section: 'section',\n components: [\n buildTextFieldComponent({\n id: 'q1',\n name: 'TextField',\n title: 'This is the first text field field question',\n hint: 'Hint text',\n shortDescription: 'Short desc'\n })\n ],\n next: [{ path: '/summary' }]\n }),\n buildSummaryPage({\n id: 'p2'\n })\n ]\n})\n\nexport const formDefinitionWithNoQuestions = buildDefinition({\n pages: [\n buildQuestionPage({\n id: 'p1',\n section: 'section',\n components: [],\n next: [{ path: '/summary' }]\n }),\n buildSummaryPage({\n id: 'p2'\n })\n ]\n})\n\nexport const formDefinitionWithRadioQuestion = buildDefinition({\n pages: [\n buildQuestionPage({\n id: 'p1',\n section: 'section',\n components: [\n buildRadiosComponent({\n id: 'q1',\n name: 'radioField',\n title: 'This is a radio question',\n hint: 'Help text',\n list: 'my-list-id'\n })\n ],\n next: [{ path: '/summary' }]\n }),\n buildSummaryPage({\n id: 'p2'\n })\n ],\n lists: [\n {\n name: 'my-list',\n id: 'my-list-id',\n type: 'string',\n title: 'list for radio',\n items: [\n {\n id: 'option-1',\n text: 'Option 1',\n hint: {\n text: 'Option 1 hint'\n },\n value: 'Option1'\n },\n {\n id: 'option-2',\n text: 'Option 2',\n hint: {\n text: 'Option 2 hint'\n },\n value: 'Option2'\n },\n {\n id: 'option-3',\n text: 'Option 3',\n hint: {\n text: 'Option 3 hint'\n },\n value: 'Option3'\n }\n ]\n }\n ]\n})\n"],"mappings":"AAAA,SACEA,8BAA8B,EAC9BC,0BAA0B,EAC1BC,sBAAsB,EACtBC,oBAAoB,EACpBC,uBAAuB;AAEzB,SAASC,eAAe;AACxB,SACEC,iBAAiB,EACjBC,iBAAiB,EACjBC,gBAAgB;AAGlB,OAAO,MAAMC,4BAA4B,GAAGJ,eAAe,CAAC;EAC1DK,KAAK,EAAE,CACLJ,iBAAiB,CAAC;IAChBK,EAAE,EAAE,IAAI;IACRC,OAAO,EAAE,SAAS;IAClBC,UAAU,EAAE,CACVT,uBAAuB,CAAC;MACtBO,EAAE,EAAE,IAAI;MACRG,IAAI,EAAE,WAAW;MACjBC,KAAK,EAAE,0BAA0B;MACjCC,IAAI,EAAE;IACR,CAAC,CAAC,CACH;IACDC,IAAI,EAAE,CAAC;MAAEC,IAAI,EAAE;IAAW,CAAC;EAC7B,CAAC,CAAC,EACFV,gBAAgB,CAAC;IACfG,EAAE,EAAE;EACN,CAAC,CAAC;AAEN,CAAC,CAAC;AAEF,OAAO,MAAMQ,4BAA4B,GAAGd,eAAe,CAAC;EAC1DK,KAAK,EAAE,CACLJ,iBAAiB,CAAC;IAChBK,EAAE,EAA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C;MACDC,KAAK,EAAE;IACT,CAAC,EACD;MACExB,EAAE,EAAE,UAAU;MACduB,IAAI,EAAE,UAAU;MAChBlB,IAAI,EAAE;QACJkB,IAAI,EAAE;MACR,CAAC;MACDC,KAAK,EAAE;IACT,CAAC,EACD;MACExB,EAAE,EAAE,UAAU;MACduB,IAAI,EAAE,UAAU;MAChBlB,IAAI,EAAE;QACJkB,IAAI,EAAE;MACR,CAAC;MACDC,KAAK,EAAE;IACT,CAAC;EAEL,CAAC;AAEL,CAAC,CAAC","ignoreList":[]}
@@ -74,6 +74,10 @@ export function isListType(type) {
74
74
  const allowedTypes = [ComponentType.AutocompleteField, ComponentType.List, ComponentType.RadiosField, ComponentType.SelectField, ComponentType.CheckboxesField];
75
75
  return !!type && allowedTypes.includes(type);
76
76
  }
77
+ export function isTypeWithInstructions(type) {
78
+ const allowedTypes = [ComponentType.EastingNorthingField, ComponentType.OsGridRefField, ComponentType.NationalGridFieldNumberField, ComponentType.LatLongField];
79
+ return !!type && allowedTypes.includes(type);
80
+ }
77
81
 
78
82
  /**
79
83
  * Filter known form components with input fields
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.js","names":["ComponentTypes","ComponentType","getComponentDefaults","component","defaults","find","type","Error","structuredClone","hasConditionSupport","isConditionalType","allowedTypes","AutocompleteField","RadiosField","CheckboxesField","DatePartsField","EmailAddressField","MultilineTextField","TelephoneNumberField","NumberField","SelectField","TextField","YesNoField","DeclarationField","includes","isConditionalRevealType","isContentType","hasContent","hasContentField","deniedTypes","List","Details","Html","Markdown","InsetText","NotificationBanner","hasFormField","isFormType","hasListField","isListType","hasInputField","hasSelectionFields","hasTitle","hasHint"],"sources":["../../../src/components/helpers.ts"],"sourcesContent":["import { ComponentTypes } from '~/src/components/component-types.js'\nimport { ComponentType } from '~/src/components/enums.js'\nimport {\n type ComponentDef,\n type ConditionalComponentType,\n type ConditionalComponentsDef,\n type ContentComponentsDef,\n type FormComponentsDef,\n type HtmlComponent,\n type InputFieldsComponentsDef,\n type InsetTextComponent,\n type ListComponent,\n type ListComponentsDef,\n type MarkdownComponent,\n type SelectionComponentsDef\n} from '~/src/components/types.js'\n\n/**\n * Return component defaults by type\n */\nexport function getComponentDefaults<FieldType extends ComponentDef>(\n component?: Pick<FieldType, 'type'>\n) {\n const defaults = ComponentTypes.find(({ type }) => type === component?.type)\n\n if (!defaults) {\n throw new Error(\n `Defaults not found for component type '${component?.type}'`\n )\n }\n\n return structuredClone(defaults) as FieldType\n}\n\n/**\n * Filter known components with support for conditions\n */\nexport function hasConditionSupport(\n component?: Partial<ComponentDef>\n): component is ConditionalComponentsDef {\n return isConditionalType(component?.type)\n}\n\nexport function isConditionalType(\n type?: ComponentType\n): type is ConditionalComponentType {\n const allowedTypes = [\n ComponentType.AutocompleteField,\n ComponentType.RadiosField,\n ComponentType.CheckboxesField,\n ComponentType.DatePartsField,\n ComponentType.EmailAddressField,\n ComponentType.MultilineTextField,\n ComponentType.TelephoneNumberField,\n ComponentType.NumberField,\n ComponentType.SelectField,\n ComponentType.TextField,\n ComponentType.YesNoField,\n ComponentType.DeclarationField\n ]\n\n return !!type && allowedTypes.includes(type)\n}\n\n/**\n * Check if the component type is supported for conditional reveal.\n * As of today this is just content types, but we're providing this as a wrapper\n * function for clarity.\n * @param type - Component type to check\n */\nexport function isConditionalRevealType(type: ComponentType) {\n return isContentType(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.Markdown,\n ComponentType.InsetText,\n ComponentType.List,\n ComponentType.NotificationBanner\n ]\n\n return !!type && allowedTypes.includes(type)\n}\n\n/**\n * Filter known components with form fields\n * (includes input fields and selection fields)\n */\nexport function hasFormField(\n component?: Partial<ComponentDef>\n): component is FormComponentsDef {\n return isFormType(component?.type)\n}\n\nexport function isFormType(\n type?: ComponentType\n): type is FormComponentsDef['type'] {\n return !!type && !isContentType(type)\n}\n\n/**\n * Filter known components with lists\n */\nexport function hasListField(\n component?: Partial<ComponentDef>\n): component is ListComponentsDef {\n return isListType(component?.type)\n}\n\nexport function isListType(\n type?: ComponentType\n): type is ListComponentsDef['type'] {\n const allowedTypes = [\n ComponentType.AutocompleteField,\n ComponentType.List,\n ComponentType.RadiosField,\n ComponentType.SelectField,\n ComponentType.CheckboxesField\n ]\n\n return !!type && allowedTypes.includes(type)\n}\n\n/**\n * Filter known form components with input fields\n * (excludes content and selection fields)\n */\nexport function hasInputField(\n component?: Partial<ComponentDef>\n): component is InputFieldsComponentsDef {\n return hasFormField(component) && !hasSelectionFields(component)\n}\n\n/**\n * Filter known form components with selection fields\n * (excludes content and input fields)\n */\nexport function hasSelectionFields(\n component?: Partial<ComponentDef>\n): component is SelectionComponentsDef {\n const allowedTypes = [\n ComponentType.AutocompleteField,\n ComponentType.CheckboxesField,\n ComponentType.RadiosField,\n ComponentType.SelectField,\n ComponentType.YesNoField,\n ComponentType.DeclarationField\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<\n ComponentDef,\n InsetTextComponent | HtmlComponent | MarkdownComponent\n> {\n const deniedTypes = [\n ComponentType.InsetText,\n ComponentType.Html,\n ComponentType.Markdown\n ]\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,cA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AClB,IAAI,CAAC;AAC9C;;AAEA;AACA;AACA;AACA;AACA,OAAO,SAASkC,aAAaA,CAC3BrC,SAAiC,EACM;EACvC,OAAOiC,YAAY,CAACjC,SAAS,CAAC,IAAI,CAACsC,kBAAkB,CAACtC,SAAS,CAAC;AAClE;;AAEA;AACA;AACA;AACA;AACA,OAAO,SAASsC,kBAAkBA,CAChCtC,SAAiC,EACI;EACrC,MAAMQ,YAAY,GAAG,CACnBV,aAAa,CAACW,iBAAiB,EAC/BX,aAAa,CAACa,eAAe,EAC7Bb,aAAa,CAACY,WAAW,EACzBZ,aAAa,CAACmB,WAAW,EACzBnB,aAAa,CAACqB,UAAU,EACxBrB,aAAa,CAACsB,gBAAgB,CAC/B;EAED,OAAO,CAAC,CAACpB,SAAS,EAAEG,IAAI,IAAIK,YAAY,CAACa,QAAQ,CAACrB,SAAS,CAACG,IAAI,CAAC;AACnE;;AAEA;AACA;AACA;AACA,OAAO,SAASoC,QAAQA,CACtBvC,SAAiC,EAIjC;EACA,MAAM0B,WAAW,GAAG,CAClB5B,aAAa,CAACiC,SAAS,EACvBjC,aAAa,CAAC+B,IAAI,EAClB/B,aAAa,CAACgC,QAAQ,CACvB;EACD,OAAO,CAAC,CAAC9B,SAAS,EAAEG,IAAI,IAAI,CAACuB,WAAW,CAACL,QAAQ,CAACrB,SAAS,CAACG,IAAI,CAAC;AACnE;;AAEA;AACA;AACA;AACA,OAAO,SAASqC,OAAOA,CACrBxC,SAAiC,EACe;EAChD,OAAOkC,UAAU,CAAClC,SAAS,EAAEG,IAAI,CAAC,IAAIH,SAAS,EAAEG,IAAI,KAAKL,aAAa,CAAC6B,IAAI;AAC9E","ignoreList":[]}
1
+ {"version":3,"file":"helpers.js","names":["ComponentTypes","ComponentType","getComponentDefaults","component","defaults","find","type","Error","structuredClone","hasConditionSupport","isConditionalType","allowedTypes","AutocompleteField","RadiosField","CheckboxesField","DatePartsField","EmailAddressField","MultilineTextField","TelephoneNumberField","NumberField","SelectField","TextField","YesNoField","DeclarationField","includes","isConditionalRevealType","isContentType","hasContent","hasContentField","deniedTypes","List","Details","Html","Markdown","InsetText","NotificationBanner","hasFormField","isFormType","hasListField","isListType","isTypeWithInstructions","EastingNorthingField","OsGridRefField","NationalGridFieldNumberField","LatLongField","hasInputField","hasSelectionFields","hasTitle","hasHint"],"sources":["../../../src/components/helpers.ts"],"sourcesContent":["import { ComponentTypes } from '~/src/components/component-types.js'\nimport { ComponentType } from '~/src/components/enums.js'\nimport {\n type ComponentDef,\n type ComponentsDefWithInstructions,\n type ConditionalComponentType,\n type ConditionalComponentsDef,\n type ContentComponentsDef,\n type FormComponentsDef,\n type HtmlComponent,\n type InputFieldsComponentsDef,\n type InsetTextComponent,\n type ListComponent,\n type ListComponentsDef,\n type MarkdownComponent,\n type SelectionComponentsDef\n} from '~/src/components/types.js'\n\n/**\n * Return component defaults by type\n */\nexport function getComponentDefaults<FieldType extends ComponentDef>(\n component?: Pick<FieldType, 'type'>\n) {\n const defaults = ComponentTypes.find(({ type }) => type === component?.type)\n\n if (!defaults) {\n throw new Error(\n `Defaults not found for component type '${component?.type}'`\n )\n }\n\n return structuredClone(defaults) as FieldType\n}\n\n/**\n * Filter known components with support for conditions\n */\nexport function hasConditionSupport(\n component?: Partial<ComponentDef>\n): component is ConditionalComponentsDef {\n return isConditionalType(component?.type)\n}\n\nexport function isConditionalType(\n type?: ComponentType\n): type is ConditionalComponentType {\n const allowedTypes = [\n ComponentType.AutocompleteField,\n ComponentType.RadiosField,\n ComponentType.CheckboxesField,\n ComponentType.DatePartsField,\n ComponentType.EmailAddressField,\n ComponentType.MultilineTextField,\n ComponentType.TelephoneNumberField,\n ComponentType.NumberField,\n ComponentType.SelectField,\n ComponentType.TextField,\n ComponentType.YesNoField,\n ComponentType.DeclarationField\n ]\n\n return !!type && allowedTypes.includes(type)\n}\n\n/**\n * Check if the component type is supported for conditional reveal.\n * As of today this is just content types, but we're providing this as a wrapper\n * function for clarity.\n * @param type - Component type to check\n */\nexport function isConditionalRevealType(type: ComponentType) {\n return isContentType(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.Markdown,\n ComponentType.InsetText,\n ComponentType.List,\n ComponentType.NotificationBanner\n ]\n\n return !!type && allowedTypes.includes(type)\n}\n\n/**\n * Filter known components with form fields\n * (includes input fields and selection fields)\n */\nexport function hasFormField(\n component?: Partial<ComponentDef>\n): component is FormComponentsDef {\n return isFormType(component?.type)\n}\n\nexport function isFormType(\n type?: ComponentType\n): type is FormComponentsDef['type'] {\n return !!type && !isContentType(type)\n}\n\n/**\n * Filter known components with lists\n */\nexport function hasListField(\n component?: Partial<ComponentDef>\n): component is ListComponentsDef {\n return isListType(component?.type)\n}\n\nexport function isListType(\n type?: ComponentType\n): type is ListComponentsDef['type'] {\n const allowedTypes = [\n ComponentType.AutocompleteField,\n ComponentType.List,\n ComponentType.RadiosField,\n ComponentType.SelectField,\n ComponentType.CheckboxesField\n ]\n\n return !!type && allowedTypes.includes(type)\n}\n\nexport function isTypeWithInstructions(\n type?: ComponentType\n): type is ComponentsDefWithInstructions['type'] {\n const allowedTypes = [\n ComponentType.EastingNorthingField,\n ComponentType.OsGridRefField,\n ComponentType.NationalGridFieldNumberField,\n ComponentType.LatLongField\n ]\n\n return !!type && allowedTypes.includes(type)\n}\n\n/**\n * Filter known form components with input fields\n * (excludes content and selection fields)\n */\nexport function hasInputField(\n component?: Partial<ComponentDef>\n): component is InputFieldsComponentsDef {\n return hasFormField(component) && !hasSelectionFields(component)\n}\n\n/**\n * Filter known form components with selection fields\n * (excludes content and input fields)\n */\nexport function hasSelectionFields(\n component?: Partial<ComponentDef>\n): component is SelectionComponentsDef {\n const allowedTypes = [\n ComponentType.AutocompleteField,\n ComponentType.CheckboxesField,\n ComponentType.RadiosField,\n ComponentType.SelectField,\n ComponentType.YesNoField,\n ComponentType.DeclarationField\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<\n ComponentDef,\n InsetTextComponent | HtmlComponent | MarkdownComponent\n> {\n const deniedTypes = [\n ComponentType.InsetText,\n ComponentType.Html,\n ComponentType.Markdown\n ]\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;AAiBtB;AACA;AACA;AACA,OAAO,SAASC,oBAAoBA,CAClCC,SAAmC,EACnC;EACA,MAAMC,QAAQ,GAAGJ,cAAc,CAACK,IAAI,CAAC,CAAC;IAAEC;EAAK,CAAC,KAAKA,IAAI,KAAKH,SAAS,EAAEG,IAAI,CAAC;EAE5E,IAAI,CAACF,QAAQ,EAAE;IACb,MAAM,IAAIG,KAAK,CACb,0CAA0CJ,SAAS,EAAEG,IAAI,GAC3D,CAAC;EACH;EAEA,OAAOE,eAAe,CAACJ,QAAQ,CAAC;AAClC;;AAEA;AACA;AACA;AACA,OAAO,SAASK,mBAAmBA,CACjCN,SAAiC,EACM;EACvC,OAAOO,iBAAiB,CAACP,SAAS,EAAEG,IAAI,CAAC;AAC3C;AAEA,OAAO,SAASI,iBAAiBA,CAC/BJ,IAAoB,EACc;EAClC,MAAMK,YAAY,GAAG,CACnBV,aAAa,CAACW,iBAAiB,EAC/BX,aAAa,CAACY,WAAW,E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e,EAC7Bb,aAAa,CAACY,WAAW,EACzBZ,aAAa,CAACmB,WAAW,EACzBnB,aAAa,CAACqB,UAAU,EACxBrB,aAAa,CAACsB,gBAAgB,CAC/B;EAED,OAAO,CAAC,CAACpB,SAAS,EAAEG,IAAI,IAAIK,YAAY,CAACa,QAAQ,CAACrB,SAAS,CAACG,IAAI,CAAC;AACnE;;AAEA;AACA;AACA;AACA,OAAO,SAASyC,QAAQA,CACtB5C,SAAiC,EAIjC;EACA,MAAM0B,WAAW,GAAG,CAClB5B,aAAa,CAACiC,SAAS,EACvBjC,aAAa,CAAC+B,IAAI,EAClB/B,aAAa,CAACgC,QAAQ,CACvB;EACD,OAAO,CAAC,CAAC9B,SAAS,EAAEG,IAAI,IAAI,CAACuB,WAAW,CAACL,QAAQ,CAACrB,SAAS,CAACG,IAAI,CAAC;AACnE;;AAEA;AACA;AACA;AACA,OAAO,SAAS0C,OAAOA,CACrB7C,SAAiC,EACe;EAChD,OAAOkC,UAAU,CAAClC,SAAS,EAAEG,IAAI,CAAC,IAAIH,SAAS,EAAEG,IAAI,KAAKL,aAAa,CAAC6B,IAAI;AAC9E","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":[],"sources":["../../../src/components/types.ts"],"sourcesContent":["import { type LanguageMessages } from 'joi'\n\nimport {\n type ComponentType,\n type GeospatialFieldGeometryTypesEnum,\n type PreviewTypeEnum\n} from '~/src/components/enums.js'\nimport {\n type ListTypeContent,\n type ListTypeOption\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 id?: string\n type: FormComponentsDef['type']\n shortDescription?: string\n errorDescription?: string\n name: string\n title: string\n hint?: string\n options: {\n required?: boolean\n optionalText?: boolean\n classes?: string\n customValidationMessages?: LanguageMessages\n instructionText?: 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 id?: string\n type:\n | ComponentType.Details\n | ComponentType.Html\n | ComponentType.Markdown\n | ComponentType.InsetText\n | ComponentType.List\n | ComponentType.NotificationBanner\n name: string\n title: string\n options?: {\n required?: undefined\n optionalText?: undefined\n }\n}\n\ninterface DateFieldBase extends FormFieldBase {\n type: ComponentType.DatePartsField\n name: string\n title: string\n hint?: string\n options: FormFieldBase['options'] & {\n maxDaysInPast?: number\n maxDaysInFuture?: number\n earliestDate?: string\n latestDate?: string\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 autocomplete?: string\n condition?: string\n customValidationMessage?: string\n }\n schema: {\n max?: number\n min?: number\n precision?: number\n minPrecision?: number\n minLength?: number\n maxLength?: number\n }\n}\n\nexport type TelephoneNumberFieldOptionsFormat = 'international' | 'uk'\n\nexport interface TelephoneNumberFieldComponent extends FormFieldBase {\n type: ComponentType.TelephoneNumberField\n options: FormFieldBase['options'] & {\n condition?: string\n format?: TelephoneNumberFieldOptionsFormat\n customValidationMessage?: string\n }\n}\n\nexport interface FileUploadFieldComponent extends FormFieldBase {\n type: ComponentType.FileUploadField\n name: string\n title: string\n hint?: string\n options: FormFieldBase['options'] & {\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 DeclarationFieldComponent extends FormFieldBase {\n type: ComponentType.DeclarationField\n content: string\n options: FormFieldBase['options'] & {\n condition?: string\n declarationConfirmationLabel?: string\n }\n}\n\nexport interface MultilineTextFieldComponent extends FormFieldBase {\n type: ComponentType.MultilineTextField\n options: FormFieldBase['options'] & {\n autocomplete?: string\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 usePostcodeLookup?: boolean\n }\n}\n\nexport interface MapLayerOptions {\n sssi?: boolean\n}\n\n// Precise Location Fields\nexport interface EastingNorthingFieldComponent extends FormFieldBase {\n type: ComponentType.EastingNorthingField\n options: FormFieldBase['options'] & {\n condition?: string\n customValidationMessage?: string\n mapLayers?: MapLayerOptions\n }\n schema?: {\n easting?: {\n min?: number\n max?: number\n }\n northing?: {\n min?: number\n max?: number\n }\n }\n}\n\nexport interface OsGridRefFieldComponent extends FormFieldBase {\n type: ComponentType.OsGridRefField\n options: FormFieldBase['options'] & {\n condition?: string\n customValidationMessage?: string\n mapLayers?: MapLayerOptions\n }\n}\n\nexport interface NationalGridFieldNumberFieldComponent extends FormFieldBase {\n type: ComponentType.NationalGridFieldNumberField\n options: FormFieldBase['options'] & {\n condition?: string\n customValidationMessage?: string\n }\n}\n\nexport interface LatLongFieldComponent extends FormFieldBase {\n type: ComponentType.LatLongField\n options: FormFieldBase['options'] & {\n condition?: string\n customValidationMessage?: string\n mapLayers?: MapLayerOptions\n }\n schema?: {\n latitude?: {\n min?: number\n max?: number\n }\n longitude?: {\n min?: number\n max?: number\n }\n }\n}\n\nexport interface HiddenFieldComponent extends FormFieldBase {\n type: ComponentType.HiddenField\n options: FormFieldBase['options'] & {\n condition?: string\n }\n}\n\n// Date Fields\nexport interface DatePartsFieldComponent extends DateFieldBase {\n type: ComponentType.DatePartsField\n options: DateFieldBase['options'] & {\n condition?: string\n }\n}\n\nexport interface MonthYearFieldComponent extends FormFieldBase {\n type: ComponentType.MonthYearField\n options: FormFieldBase['options'] & {\n customValidationMessage?: string\n earliestMonthYear?: string\n latestMonthYear?: string\n }\n}\n\nexport interface PaymentFieldComponent extends FormFieldBase {\n type: ComponentType.PaymentField\n options: FormFieldBase['options'] & {\n amount: number\n description: string\n conditionalAmounts?: {\n condition: string\n amount: number\n }[]\n emailField?: string\n }\n}\n\nexport type GeospatialFieldOptionsCountry =\n | 'england'\n | 'wales'\n | 'northern-ireland'\n | 'scotland'\n\nexport interface GeospatialFieldComponent extends FormFieldBase {\n type: ComponentType.GeospatialField\n options: FormFieldBase['options'] & {\n condition?: string\n countries?: GeospatialFieldOptionsCountry[]\n geometryTypes?: GeospatialFieldGeometryTypesEnum[]\n mapLayers?: MapLayerOptions\n }\n schema?: {\n max?: number\n min?: number\n length?: number\n }\n}\n\n// Content Fields\nexport interface DetailsComponent extends ContentFieldBase {\n type: ComponentType.Details\n content: string\n options: ContentFieldBase['options'] & {\n condition?: string\n }\n}\n\nexport interface HtmlComponent extends ContentFieldBase {\n type: ComponentType.Html\n content: string\n options: ContentFieldBase['options'] & {\n condition?: string\n }\n}\n\nexport interface MarkdownComponent extends ContentFieldBase {\n type: ComponentType.Markdown\n content: string\n options: ContentFieldBase['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: ContentFieldBase['options'] & {\n type?: ListTypeOption\n classes?: string\n hideTitle?: boolean\n bold?: boolean\n }\n}\n\nexport interface NotificationBannerComponent extends ContentFieldBase {\n type: ComponentType.NotificationBanner\n content: string\n options: ContentFieldBase['options'] & {\n type?: 'success'\n heading?: string\n condition?: string\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 schema?: {\n max?: number\n min?: number\n length?: number\n }\n}\n\nexport interface RadiosFieldComponent extends ListFieldBase {\n type: ComponentType.RadiosField\n options: ListFieldBase['options'] & {\n bold?: boolean\n condition?: string\n }\n}\n\nexport interface SelectFieldComponent extends ListFieldBase {\n type: ComponentType.SelectField\n options: ListFieldBase['options'] & {\n autocomplete?: string\n condition?: string\n }\n}\n\nexport type ComponentDef = FormComponentsDef | ContentComponentsDef\n\n// Components that render form fields\nexport type FormComponentsDef =\n | InputFieldsComponentsDef\n | SelectionComponentsDef\n\n// Components that render inputs\nexport type InputFieldsComponentsDef =\n | TextFieldComponent\n | EmailAddressFieldComponent\n | NumberFieldComponent\n | MultilineTextFieldComponent\n | TelephoneNumberFieldComponent\n | MonthYearFieldComponent\n | DatePartsFieldComponent\n | UkAddressFieldComponent\n | FileUploadFieldComponent\n | DeclarationFieldComponent\n | EastingNorthingFieldComponent\n | OsGridRefFieldComponent\n | NationalGridFieldNumberFieldComponent\n | LatLongFieldComponent\n | HiddenFieldComponent\n | PaymentFieldComponent\n | GeospatialFieldComponent\n\n// Components that render content\nexport type ContentComponentsDef =\n | DetailsComponent\n | HtmlComponent\n | MarkdownComponent\n | InsetTextComponent\n | ListComponent\n | NotificationBannerComponent\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 | PaymentFieldComponent\n>\n\nexport type PreviewType = keyof typeof PreviewTypeEnum\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"file":"types.js","names":[],"sources":["../../../src/components/types.ts"],"sourcesContent":["import { type LanguageMessages } from 'joi'\n\nimport {\n type ComponentType,\n type GeospatialFieldGeometryTypesEnum,\n type PreviewTypeEnum\n} from '~/src/components/enums.js'\nimport {\n type ListTypeContent,\n type ListTypeOption\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 id?: string\n type: FormComponentsDef['type']\n shortDescription?: string\n errorDescription?: string\n name: string\n title: string\n hint?: string\n options: {\n required?: boolean\n optionalText?: boolean\n classes?: string\n customValidationMessages?: LanguageMessages\n instructionText?: 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 id?: string\n type:\n | ComponentType.Details\n | ComponentType.Html\n | ComponentType.Markdown\n | ComponentType.InsetText\n | ComponentType.List\n | ComponentType.NotificationBanner\n name: string\n title: string\n options?: {\n required?: undefined\n optionalText?: undefined\n }\n}\n\ninterface DateFieldBase extends FormFieldBase {\n type: ComponentType.DatePartsField\n name: string\n title: string\n hint?: string\n options: FormFieldBase['options'] & {\n maxDaysInPast?: number\n maxDaysInFuture?: number\n earliestDate?: string\n latestDate?: string\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 autocomplete?: string\n condition?: string\n customValidationMessage?: string\n }\n schema: {\n max?: number\n min?: number\n precision?: number\n minPrecision?: number\n minLength?: number\n maxLength?: number\n }\n}\n\nexport type TelephoneNumberFieldOptionsFormat = 'international' | 'uk'\n\nexport interface TelephoneNumberFieldComponent extends FormFieldBase {\n type: ComponentType.TelephoneNumberField\n options: FormFieldBase['options'] & {\n condition?: string\n format?: TelephoneNumberFieldOptionsFormat\n customValidationMessage?: string\n }\n}\n\nexport interface FileUploadFieldComponent extends FormFieldBase {\n type: ComponentType.FileUploadField\n name: string\n title: string\n hint?: string\n options: FormFieldBase['options'] & {\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 DeclarationFieldComponent extends FormFieldBase {\n type: ComponentType.DeclarationField\n content: string\n options: FormFieldBase['options'] & {\n condition?: string\n declarationConfirmationLabel?: string\n }\n}\n\nexport interface MultilineTextFieldComponent extends FormFieldBase {\n type: ComponentType.MultilineTextField\n options: FormFieldBase['options'] & {\n autocomplete?: string\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 usePostcodeLookup?: boolean\n }\n}\n\nexport interface MapLayerOptions {\n sssi?: boolean\n}\n\n// Precise Location Fields\nexport interface EastingNorthingFieldComponent extends FormFieldBase {\n type: ComponentType.EastingNorthingField\n options: FormFieldBase['options'] & {\n condition?: string\n customValidationMessage?: string\n mapLayers?: MapLayerOptions\n }\n schema?: {\n easting?: {\n min?: number\n max?: number\n }\n northing?: {\n min?: number\n max?: number\n }\n }\n}\n\nexport interface OsGridRefFieldComponent extends FormFieldBase {\n type: ComponentType.OsGridRefField\n options: FormFieldBase['options'] & {\n condition?: string\n customValidationMessage?: string\n mapLayers?: MapLayerOptions\n }\n}\n\nexport interface NationalGridFieldNumberFieldComponent extends FormFieldBase {\n type: ComponentType.NationalGridFieldNumberField\n options: FormFieldBase['options'] & {\n condition?: string\n customValidationMessage?: string\n }\n}\n\nexport interface LatLongFieldComponent extends FormFieldBase {\n type: ComponentType.LatLongField\n options: FormFieldBase['options'] & {\n condition?: string\n customValidationMessage?: string\n mapLayers?: MapLayerOptions\n }\n schema?: {\n latitude?: {\n min?: number\n max?: number\n }\n longitude?: {\n min?: number\n max?: number\n }\n }\n}\n\nexport interface HiddenFieldComponent extends FormFieldBase {\n type: ComponentType.HiddenField\n options: FormFieldBase['options'] & {\n condition?: string\n }\n}\n\n// Date Fields\nexport interface DatePartsFieldComponent extends DateFieldBase {\n type: ComponentType.DatePartsField\n options: DateFieldBase['options'] & {\n condition?: string\n }\n}\n\nexport interface MonthYearFieldComponent extends FormFieldBase {\n type: ComponentType.MonthYearField\n options: FormFieldBase['options'] & {\n customValidationMessage?: string\n earliestMonthYear?: string\n latestMonthYear?: string\n }\n}\n\nexport interface PaymentFieldComponent extends FormFieldBase {\n type: ComponentType.PaymentField\n options: FormFieldBase['options'] & {\n amount: number\n description: string\n conditionalAmounts?: {\n condition: string\n amount: number\n }[]\n emailField?: string\n }\n}\n\nexport type GeospatialFieldOptionsCountry =\n | 'england'\n | 'wales'\n | 'northern-ireland'\n | 'scotland'\n\nexport interface GeospatialFieldComponent extends FormFieldBase {\n type: ComponentType.GeospatialField\n options: FormFieldBase['options'] & {\n condition?: string\n countries?: GeospatialFieldOptionsCountry[]\n geometryTypes?: GeospatialFieldGeometryTypesEnum[]\n mapLayers?: MapLayerOptions\n }\n schema?: {\n max?: number\n min?: number\n length?: number\n }\n}\n\n// Content Fields\nexport interface DetailsComponent extends ContentFieldBase {\n type: ComponentType.Details\n content: string\n options: ContentFieldBase['options'] & {\n condition?: string\n }\n}\n\nexport interface HtmlComponent extends ContentFieldBase {\n type: ComponentType.Html\n content: string\n options: ContentFieldBase['options'] & {\n condition?: string\n }\n}\n\nexport interface MarkdownComponent extends ContentFieldBase {\n type: ComponentType.Markdown\n content: string\n options: ContentFieldBase['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: ContentFieldBase['options'] & {\n type?: ListTypeOption\n classes?: string\n hideTitle?: boolean\n bold?: boolean\n }\n}\n\nexport interface NotificationBannerComponent extends ContentFieldBase {\n type: ComponentType.NotificationBanner\n content: string\n options: ContentFieldBase['options'] & {\n type?: 'success'\n heading?: string\n condition?: string\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 schema?: {\n max?: number\n min?: number\n length?: number\n }\n}\n\nexport interface RadiosFieldComponent extends ListFieldBase {\n type: ComponentType.RadiosField\n options: ListFieldBase['options'] & {\n bold?: boolean\n condition?: string\n }\n}\n\nexport interface SelectFieldComponent extends ListFieldBase {\n type: ComponentType.SelectField\n options: ListFieldBase['options'] & {\n autocomplete?: string\n condition?: string\n }\n}\n\nexport type ComponentDef = FormComponentsDef | ContentComponentsDef\n\n// Components that render form fields\nexport type FormComponentsDef =\n | InputFieldsComponentsDef\n | SelectionComponentsDef\n\n// Components that render inputs\nexport type InputFieldsComponentsDef =\n | TextFieldComponent\n | EmailAddressFieldComponent\n | NumberFieldComponent\n | MultilineTextFieldComponent\n | TelephoneNumberFieldComponent\n | MonthYearFieldComponent\n | DatePartsFieldComponent\n | UkAddressFieldComponent\n | FileUploadFieldComponent\n | DeclarationFieldComponent\n | EastingNorthingFieldComponent\n | OsGridRefFieldComponent\n | NationalGridFieldNumberFieldComponent\n | LatLongFieldComponent\n | HiddenFieldComponent\n | PaymentFieldComponent\n | GeospatialFieldComponent\n\n// Components that render content\nexport type ContentComponentsDef =\n | DetailsComponent\n | HtmlComponent\n | MarkdownComponent\n | InsetTextComponent\n | ListComponent\n | NotificationBannerComponent\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 instruction fields\nexport type ComponentsDefWithInstructions =\n | EastingNorthingFieldComponent\n | OsGridRefFieldComponent\n | NationalGridFieldNumberFieldComponent\n | LatLongFieldComponent\n\n// Components that have condition support\nexport type ConditionalComponentsDef = Exclude<\n ComponentDef,\n | InsetTextComponent\n | ListComponent\n | MonthYearFieldComponent\n | UkAddressFieldComponent\n | FileUploadFieldComponent\n | PaymentFieldComponent\n>\n\nexport type PreviewType = keyof typeof PreviewTypeEnum\n"],"mappings":"","ignoreList":[]}
@@ -0,0 +1,168 @@
1
+ import { ComponentType } from "../../../components/enums.js";
2
+
3
+ /**
4
+ * @typedef {object} TranslationRow
5
+ * @property {string} name - the key name
6
+ * @property {string} [type] - type of text
7
+ * @property {string | undefined} englishContent - English text
8
+ * @property {string | undefined} welshContent - Welsh text
9
+ * @property {number} [pageNum] - page number
10
+ * @property {number} [questionNum] - question number
11
+ * @property {number} [itemNum] - list item number
12
+ * @property {string} [label] - label for field
13
+ */
14
+
15
+ /**
16
+ * @typedef {{ text: string, href?: string }} ErrorDetailsItem
17
+ * @typedef {Record<string, ErrorDetailsItem>} ErrorDetails
18
+ */
19
+
20
+ /**
21
+ * @template {object} [Schema=object]
22
+ * @typedef {object} ValidationFailure
23
+ * @property {ErrorDetails} formErrors - Formatted errors for error summary
24
+ * @property {Schema} formValues - Form POST payload from Hapi request
25
+ */
26
+
27
+ export const TranslationRowTypes = {
28
+ PageHeading: 'PageHeading',
29
+ PageGuidance: 'PageGuidance',
30
+ RepeatTitle: 'RepeatTitle',
31
+ QuestionText: 'QuestionText',
32
+ QuestionHint: 'QuestionHint',
33
+ ShortDescription: 'ShortDescription',
34
+ ErrorDescription: 'ErrorDescription',
35
+ ListItemText: 'ListItemText',
36
+ ListItemHint: 'ListItemHint',
37
+ InstructionText: 'InstructionText',
38
+ DeclarationBody: 'DeclarationBody',
39
+ PaymentDescription: 'PaymentDescription'
40
+ };
41
+ export const TEXTAREA_3_ROWS = 'textarea3';
42
+ export const TEXTAREA_5_ROWS = 'textarea5';
43
+ export const TEXTAREA_12_ROWS_WITH_MARKDOWN = 'textarea12markdown';
44
+ export const LIST_ITEM_HINT = 'listitemhint';
45
+ export const LIST_ITEM_WITH_HINT_FOLLOWING = 'listoptionwithhintfollowing';
46
+
47
+ /** @type {Record<string, { jsonPrefix: string, jsonSuffix: string, displayName: string, getLabel: (pageNum: number, questionNum?: number, itemNum?: number) => string }>} */
48
+ export const keyConfig = {
49
+ [TranslationRowTypes.QuestionText]: {
50
+ jsonPrefix: 'components',
51
+ jsonSuffix: 'title',
52
+ displayName: 'Question text',
53
+ getLabel: (pageNum, questionNum) => `Welsh question text - Page ${pageNum}, question ${questionNum}`
54
+ },
55
+ [TranslationRowTypes.QuestionHint]: {
56
+ jsonPrefix: 'components',
57
+ jsonSuffix: 'hint',
58
+ displayName: 'Hint',
59
+ getLabel: (pageNum, questionNum) => `Welsh hint - Page ${pageNum}, question ${questionNum}`
60
+ },
61
+ [TranslationRowTypes.ShortDescription]: {
62
+ jsonPrefix: 'components',
63
+ jsonSuffix: 'shortDescription',
64
+ displayName: 'Short description',
65
+ getLabel: (pageNum, questionNum) => `Welsh short description - Page ${pageNum}, question ${questionNum}`
66
+ },
67
+ [TranslationRowTypes.InstructionText]: {
68
+ jsonPrefix: 'components',
69
+ jsonSuffix: 'instructionText',
70
+ displayName: 'Instruction text',
71
+ getLabel: (pageNum, questionNum) => `Welsh instruction text - Page ${pageNum}, question ${questionNum}`
72
+ },
73
+ [TranslationRowTypes.DeclarationBody]: {
74
+ jsonPrefix: 'components',
75
+ jsonSuffix: 'content',
76
+ displayName: 'Declaration body',
77
+ getLabel: (pageNum, questionNum) => `Welsh declaration body - Page ${pageNum}, question ${questionNum}`
78
+ },
79
+ [TranslationRowTypes.PaymentDescription]: {
80
+ jsonPrefix: 'components',
81
+ jsonSuffix: 'paymentDescription',
82
+ displayName: 'Payment description',
83
+ getLabel: (pageNum, questionNum) => `Welsh payment description - Page ${pageNum}, question ${questionNum}`
84
+ },
85
+ [TranslationRowTypes.ListItemText]: {
86
+ jsonPrefix: 'listItems',
87
+ jsonSuffix: 'text',
88
+ displayName: 'Option',
89
+ getLabel: (pageNum, questionNum, itemNum) => `Welsh option ${itemNum} - Page ${pageNum}, question ${questionNum}`
90
+ },
91
+ [TranslationRowTypes.ListItemHint]: {
92
+ jsonPrefix: 'listItems',
93
+ jsonSuffix: 'hint',
94
+ displayName: 'Option hint',
95
+ getLabel: (pageNum, questionNum, itemNum) => `Welsh hint for option ${itemNum} - Page ${pageNum}, question ${questionNum}`
96
+ },
97
+ [TranslationRowTypes.PageGuidance]: {
98
+ jsonPrefix: 'components',
99
+ jsonSuffix: 'content',
100
+ displayName: 'Guidance text',
101
+ getLabel: pageNum => `Welsh guidance text (markdown) - page ${pageNum}`
102
+ },
103
+ [TranslationRowTypes.PageHeading]: {
104
+ jsonPrefix: 'pages',
105
+ jsonSuffix: 'title',
106
+ displayName: 'Page heading',
107
+ getLabel: pageNum => `Welsh page heading - page ${pageNum}`
108
+ },
109
+ [TranslationRowTypes.RepeatTitle]: {
110
+ jsonPrefix: 'pages',
111
+ jsonSuffix: 'repeatTitle',
112
+ displayName: 'Repeat name',
113
+ getLabel: pageNum => `Welsh repeat name - page ${pageNum}`
114
+ }
115
+ };
116
+ export const IGNORE_FIELDS = [ComponentType.Details, ComponentType.Html, ComponentType.InsetText, ComponentType.HiddenField];
117
+
118
+ /**
119
+ * Lookup a translation from a list of translation records.
120
+ * @param {string} key - The translation key to look up.
121
+ * @param {Record<string, string> | undefined} translations - The translation values to search.
122
+ */
123
+ export function lookupTranslation(key, translations) {
124
+ if (!translations) {
125
+ return '';
126
+ }
127
+ return translations[key] ?? '';
128
+ }
129
+
130
+ /**
131
+ * Resolve the underlying content for a translation row from an entity.
132
+ * Involves using the appropriate child properties if necessary.
133
+ * @param {string} keyType - The translation row type being resolved.
134
+ * @param {ComponentDef | Page | Item} entity - The entity that may contain the content to translate.
135
+ * @param {string} jsonSuffix - The property name to read from the entity.
136
+ */
137
+ export function drillDown(keyType, entity, jsonSuffix) {
138
+ /** @type {Partial<Record<string, (entity: ComponentDef | Page | Item) => string>>} */
139
+ const resolveData = {
140
+ [TranslationRowTypes.InstructionText]: () =>
141
+ // @ts-expect-error - dynamic property lookup
142
+ 'options' in entity ? entity.options?.instructionText : '',
143
+ [TranslationRowTypes.ListItemHint]: () =>
144
+ // @ts-expect-error - dynamic property lookup
145
+ 'hint' in entity ? entity.hint.text : '',
146
+ [TranslationRowTypes.DeclarationBody]: () => 'content' in entity ? entity.content : '',
147
+ [TranslationRowTypes.PaymentDescription]: () =>
148
+ // @ts-expect-error - dynamic property lookup
149
+ 'options' in entity ? entity.options?.description : ''
150
+ };
151
+ const func = resolveData[keyType];
152
+ if (func) {
153
+ return func(entity);
154
+ } else {
155
+ const entityWithDynamicProperties = /** @type {Record<string, unknown>} */
156
+ /** @type {unknown} */entity;
157
+ if (typeof entity === 'object') {
158
+ return jsonSuffix in entityWithDynamicProperties ? (/** @type {string} */entityWithDynamicProperties[jsonSuffix]) : '';
159
+ }
160
+ }
161
+ return entity;
162
+ }
163
+
164
+ /**
165
+ * @import { ComponentDef } from '~/src/components/types.js'
166
+ * @import { Item, Page } from '~/src/form/form-definition/types.js'
167
+ */
168
+ //# sourceMappingURL=translations-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"translations-config.js","names":["ComponentType","TranslationRowTypes","PageHeading","PageGuidance","RepeatTitle","QuestionText","QuestionHint","ShortDescription","ErrorDescription","ListItemText","ListItemHint","InstructionText","DeclarationBody","PaymentDescription","TEXTAREA_3_ROWS","TEXTAREA_5_ROWS","TEXTAREA_12_ROWS_WITH_MARKDOWN","LIST_ITEM_HINT","LIST_ITEM_WITH_HINT_FOLLOWING","keyConfig","jsonPrefix","jsonSuffix","displayName","getLabel","pageNum","questionNum","itemNum","IGNORE_FIELDS","Details","Html","InsetText","HiddenField","lookupTranslation","key","translations","drillDown","keyType","entity","resolveData","options","instructionText","hint","text","content","description","func","entityWithDynamicProperties"],"sources":["../../../../../src/form/form-editor/translations/translations-config.js"],"sourcesContent":["import { ComponentType } from '~/src/components/enums.js'\n\n/**\n * @typedef {object} TranslationRow\n * @property {string} name - the key name\n * @property {string} [type] - type of text\n * @property {string | undefined} englishContent - English text\n * @property {string | undefined} welshContent - Welsh text\n * @property {number} [pageNum] - page number\n * @property {number} [questionNum] - question number\n * @property {number} [itemNum] - list item number\n * @property {string} [label] - label for field\n */\n\n/**\n * @typedef {{ text: string, href?: string }} ErrorDetailsItem\n * @typedef {Record<string, ErrorDetailsItem>} ErrorDetails\n */\n\n/**\n * @template {object} [Schema=object]\n * @typedef {object} ValidationFailure\n * @property {ErrorDetails} formErrors - Formatted errors for error summary\n * @property {Schema} formValues - Form POST payload from Hapi request\n */\n\nexport const TranslationRowTypes = {\n PageHeading: 'PageHeading',\n PageGuidance: 'PageGuidance',\n RepeatTitle: 'RepeatTitle',\n QuestionText: 'QuestionText',\n QuestionHint: 'QuestionHint',\n ShortDescription: 'ShortDescription',\n ErrorDescription: 'ErrorDescription',\n ListItemText: 'ListItemText',\n ListItemHint: 'ListItemHint',\n InstructionText: 'InstructionText',\n DeclarationBody: 'DeclarationBody',\n PaymentDescription: 'PaymentDescription'\n}\n\nexport const TEXTAREA_3_ROWS = 'textarea3'\nexport const TEXTAREA_5_ROWS = 'textarea5'\nexport const TEXTAREA_12_ROWS_WITH_MARKDOWN = 'textarea12markdown'\nexport const LIST_ITEM_HINT = 'listitemhint'\nexport const LIST_ITEM_WITH_HINT_FOLLOWING = 'listoptionwithhintfollowing'\n\n/** @type {Record<string, { jsonPrefix: string, jsonSuffix: string, displayName: string, getLabel: (pageNum: number, questionNum?: number, itemNum?: number) => string }>} */\nexport const keyConfig = {\n [TranslationRowTypes.QuestionText]: {\n jsonPrefix: 'components',\n jsonSuffix: 'title',\n displayName: 'Question text',\n getLabel: (pageNum, questionNum) =>\n `Welsh question text - Page ${pageNum}, question ${questionNum}`\n },\n [TranslationRowTypes.QuestionHint]: {\n jsonPrefix: 'components',\n jsonSuffix: 'hint',\n displayName: 'Hint',\n getLabel: (pageNum, questionNum) =>\n `Welsh hint - Page ${pageNum}, question ${questionNum}`\n },\n [TranslationRowTypes.ShortDescription]: {\n jsonPrefix: 'components',\n jsonSuffix: 'shortDescription',\n displayName: 'Short description',\n getLabel: (pageNum, questionNum) =>\n `Welsh short description - Page ${pageNum}, question ${questionNum}`\n },\n [TranslationRowTypes.InstructionText]: {\n jsonPrefix: 'components',\n jsonSuffix: 'instructionText',\n displayName: 'Instruction text',\n getLabel: (pageNum, questionNum) =>\n `Welsh instruction text - Page ${pageNum}, question ${questionNum}`\n },\n [TranslationRowTypes.DeclarationBody]: {\n jsonPrefix: 'components',\n jsonSuffix: 'content',\n displayName: 'Declaration body',\n getLabel: (pageNum, questionNum) =>\n `Welsh declaration body - Page ${pageNum}, question ${questionNum}`\n },\n [TranslationRowTypes.PaymentDescription]: {\n jsonPrefix: 'components',\n jsonSuffix: 'paymentDescription',\n displayName: 'Payment description',\n getLabel: (pageNum, questionNum) =>\n `Welsh payment description - Page ${pageNum}, question ${questionNum}`\n },\n [TranslationRowTypes.ListItemText]: {\n jsonPrefix: 'listItems',\n jsonSuffix: 'text',\n displayName: 'Option',\n getLabel: (pageNum, questionNum, itemNum) =>\n `Welsh option ${itemNum} - Page ${pageNum}, question ${questionNum}`\n },\n [TranslationRowTypes.ListItemHint]: {\n jsonPrefix: 'listItems',\n jsonSuffix: 'hint',\n displayName: 'Option hint',\n getLabel: (pageNum, questionNum, itemNum) =>\n `Welsh hint for option ${itemNum} - Page ${pageNum}, question ${questionNum}`\n },\n [TranslationRowTypes.PageGuidance]: {\n jsonPrefix: 'components',\n jsonSuffix: 'content',\n displayName: 'Guidance text',\n getLabel: (pageNum) => `Welsh guidance text (markdown) - page ${pageNum}`\n },\n [TranslationRowTypes.PageHeading]: {\n jsonPrefix: 'pages',\n jsonSuffix: 'title',\n displayName: 'Page heading',\n getLabel: (pageNum) => `Welsh page heading - page ${pageNum}`\n },\n [TranslationRowTypes.RepeatTitle]: {\n jsonPrefix: 'pages',\n jsonSuffix: 'repeatTitle',\n displayName: 'Repeat name',\n getLabel: (pageNum) => `Welsh repeat name - page ${pageNum}`\n }\n}\n\nexport const IGNORE_FIELDS = [\n ComponentType.Details,\n ComponentType.Html,\n ComponentType.InsetText,\n ComponentType.HiddenField\n]\n\n/**\n * Lookup a translation from a list of translation records.\n * @param {string} key - The translation key to look up.\n * @param {Record<string, string> | undefined} translations - The translation values to search.\n */\nexport function lookupTranslation(key, translations) {\n if (!translations) {\n return ''\n }\n return translations[key] ?? ''\n}\n\n/**\n * Resolve the underlying content for a translation row from an entity.\n * Involves using the appropriate child properties if necessary.\n * @param {string} keyType - The translation row type being resolved.\n * @param {ComponentDef | Page | Item} entity - The entity that may contain the content to translate.\n * @param {string} jsonSuffix - The property name to read from the entity.\n */\nexport function drillDown(keyType, entity, jsonSuffix) {\n /** @type {Partial<Record<string, (entity: ComponentDef | Page | Item) => string>>} */\n const resolveData = {\n [TranslationRowTypes.InstructionText]: () =>\n // @ts-expect-error - dynamic property lookup\n 'options' in entity ? entity.options?.instructionText : '',\n [TranslationRowTypes.ListItemHint]: () =>\n // @ts-expect-error - dynamic property lookup\n 'hint' in entity ? entity.hint.text : '',\n [TranslationRowTypes.DeclarationBody]: () =>\n 'content' in entity ? entity.content : '',\n [TranslationRowTypes.PaymentDescription]: () =>\n // @ts-expect-error - dynamic property lookup\n 'options' in entity ? entity.options?.description : ''\n }\n const func = resolveData[keyType]\n if (func) {\n return func(entity)\n } else {\n const entityWithDynamicProperties = /** @type {Record<string, unknown>} */ (\n /** @type {unknown} */ (entity)\n )\n if (typeof entity === 'object') {\n return jsonSuffix in entityWithDynamicProperties\n ? /** @type {string} */ (entityWithDynamicProperties[jsonSuffix])\n : ''\n }\n }\n return entity\n}\n\n/**\n * @import { ComponentDef } from '~/src/components/types.js'\n * @import { Item, Page } from '~/src/form/form-definition/types.js'\n */\n"],"mappings":"AAAA,SAASA,aAAa;;AAEtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,MAAMC,mBAAmB,GAAG;EACjCC,WAAW,EAAE,aAAa;EAC1BC,YAAY,EAAE,cAAc;EAC5BC,WAAW,EAAE,aAAa;EAC1BC,YAAY,EAAE,cAAc;EAC5BC,YAAY,EAAE,cAAc;EAC5BC,gBAAgB,EAAE,kBAAkB;EACpCC,gBAAgB,EAAE,kBAAkB;EACpCC,YAAY,EAAE,cAAc;EAC5BC,YAAY,EAAE,cAAc;EAC5BC,eAAe,EAAE,iBAAiB;EAClCC,eAAe,EAAE,iBAAiB;EAClCC,kBAAkB,EAAE;AACtB,CAAC;AAED,OAAO,MAAMC,eAAe,GAAG,WAAW;AAC1C,OAAO,MA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,2BAA2B,IAC5C,qBAAuBA,2BAA2B,CAACzB,UAAU,CAAC,IAC9D,EAAE;IACR;EACF;EACA,OAAOgB,MAAM;AACf;;AAEA;AACA;AACA;AACA","ignoreList":[]}
@@ -0,0 +1,93 @@
1
+ import { lookupTranslation } from "./translations-config.js";
2
+ const formNameKey = 'form.title';
3
+ const contactEmailAddressKey = 'form.contact.email.address';
4
+ const contactEmailResponseKey = 'form.contact.email.responseTime';
5
+ const contactOnlineUrlKey = 'form.contact.online.url';
6
+ const contactOnlineTextKey = 'form.contact.online.text';
7
+ const contactPhoneKey = 'form.contact.phone';
8
+ const submissionGuidanceKey = 'form.submissionGuidance';
9
+ const privacyNoticeUrlKey = 'form.privacyNoticeUrl';
10
+ const privacyNoticeTextKey = 'form.privacyNoticeText';
11
+
12
+ /**
13
+ * Determine a field value, either from the user-entered payload (validation) or from a translation lookup
14
+ * @param {string} key
15
+ * @param {Record<string, string>} translations
16
+ * @param {ValidationFailure<any>} [validation]
17
+ * @returns { string | undefined }
18
+ */
19
+ function getTranslation(key, translations, validation) {
20
+ return validation?.formValues[key] ?? lookupTranslation(key, translations);
21
+ }
22
+
23
+ /**
24
+ * Build all translation rows in the form overview section (metatdata values).
25
+ * @param {FormMetadata} metadata
26
+ * @param {FormDefinition} definition
27
+ * @param {Record<string, string>} translations
28
+ * @param {ValidationFailure<any>} [validation]
29
+ * @returns {TranslationRow[]}
30
+ */
31
+ export function buildOverviewSection(metadata, definition, translations, validation) {
32
+ /** @type {TranslationRow[]} */
33
+ const rows = [];
34
+ rows.push({
35
+ name: formNameKey,
36
+ englishContent: definition.name,
37
+ welshContent: getTranslation(formNameKey, translations, validation),
38
+ label: 'Welsh form name'
39
+ }, {
40
+ name: contactEmailAddressKey,
41
+ englishContent: metadata.contact?.email?.address ?? 'Not set',
42
+ welshContent: getTranslation(contactEmailAddressKey, translations, validation),
43
+ label: 'Welsh support email address'
44
+ }, {
45
+ name: contactEmailResponseKey,
46
+ englishContent: metadata.contact?.email?.responseTime ?? '--',
47
+ welshContent: getTranslation(contactEmailResponseKey, translations, validation),
48
+ label: 'Welsh response time message'
49
+ }, {
50
+ name: contactOnlineUrlKey,
51
+ englishContent: metadata.contact?.online?.url ?? 'Not set',
52
+ welshContent: getTranslation(contactOnlineUrlKey, translations, validation),
53
+ label: 'Welsh contact link URL'
54
+ }, {
55
+ name: contactOnlineTextKey,
56
+ englishContent: metadata.contact?.online?.text ?? '--',
57
+ welshContent: getTranslation(contactOnlineTextKey, translations, validation),
58
+ label: 'Welsh text for the contact link'
59
+ }, {
60
+ name: contactPhoneKey,
61
+ englishContent: metadata.contact?.phone ?? 'Not set',
62
+ welshContent: getTranslation(contactPhoneKey, translations, validation),
63
+ label: 'Welsh phone number and opening times'
64
+ }, {
65
+ name: submissionGuidanceKey,
66
+ englishContent: metadata.submissionGuidance ?? 'Not set',
67
+ welshContent: getTranslation(submissionGuidanceKey, translations, validation),
68
+ label: 'Welsh information about what happens next'
69
+ });
70
+ if (metadata.privacyNoticeType === 'link') {
71
+ rows.push({
72
+ name: privacyNoticeUrlKey,
73
+ englishContent: metadata.privacyNoticeUrl ?? 'Not set',
74
+ welshContent: getTranslation(privacyNoticeUrlKey, translations, validation),
75
+ label: 'Welsh privacy notice URL'
76
+ });
77
+ } else {
78
+ rows.push({
79
+ name: privacyNoticeTextKey,
80
+ englishContent: metadata.privacyNoticeText ?? 'Not set',
81
+ welshContent: getTranslation(privacyNoticeTextKey, translations, validation),
82
+ label: 'Welsh privacy notice text'
83
+ });
84
+ }
85
+ return /** @type {TranslationRow[]} */rows;
86
+ }
87
+
88
+ /**
89
+ * @import { FormMetadata } from '~/src/form/form-metadata/types.js'
90
+ * @import { FormDefinition } from '~/src/form/form-definition/types.js'
91
+ * @import { TranslationRow, ValidationFailure} from '~/src/form/form-editor/translations/translations-config.js'
92
+ */
93
+ //# sourceMappingURL=translations-overview.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"translations-overview.js","names":["lookupTranslation","formNameKey","contactEmailAddressKey","contactEmailResponseKey","contactOnlineUrlKey","contactOnlineTextKey","contactPhoneKey","submissionGuidanceKey","privacyNoticeUrlKey","privacyNoticeTextKey","getTranslation","key","translations","validation","formValues","buildOverviewSection","metadata","definition","rows","push","name","englishContent","welshContent","label","contact","email","address","responseTime","online","url","text","phone","submissionGuidance","privacyNoticeType","privacyNoticeUrl","privacyNoticeText"],"sources":["../../../../../src/form/form-editor/translations/translations-overview.js"],"sourcesContent":["import { lookupTranslation } from '~/src/form/form-editor/translations/translations-config.js'\n\nconst formNameKey = 'form.title'\nconst contactEmailAddressKey = 'form.contact.email.address'\nconst contactEmailResponseKey = 'form.contact.email.responseTime'\nconst contactOnlineUrlKey = 'form.contact.online.url'\nconst contactOnlineTextKey = 'form.contact.online.text'\nconst contactPhoneKey = 'form.contact.phone'\nconst submissionGuidanceKey = 'form.submissionGuidance'\nconst privacyNoticeUrlKey = 'form.privacyNoticeUrl'\nconst privacyNoticeTextKey = 'form.privacyNoticeText'\n\n/**\n * Determine a field value, either from the user-entered payload (validation) or from a translation lookup\n * @param {string} key\n * @param {Record<string, string>} translations\n * @param {ValidationFailure<any>} [validation]\n * @returns { string | undefined }\n */\nfunction getTranslation(key, translations, validation) {\n return validation?.formValues[key] ?? lookupTranslation(key, translations)\n}\n\n/**\n * Build all translation rows in the form overview section (metatdata values).\n * @param {FormMetadata} metadata\n * @param {FormDefinition} definition\n * @param {Record<string, string>} translations\n * @param {ValidationFailure<any>} [validation]\n * @returns {TranslationRow[]}\n */\nexport function buildOverviewSection(\n metadata,\n definition,\n translations,\n validation\n) {\n /** @type {TranslationRow[]} */\n const rows = []\n\n rows.push(\n {\n name: formNameKey,\n englishContent: definition.name,\n welshContent: getTranslation(formNameKey, translations, validation),\n label: 'Welsh form name'\n },\n {\n name: contactEmailAddressKey,\n englishContent: metadata.contact?.email?.address ?? 'Not set',\n welshContent: getTranslation(\n contactEmailAddressKey,\n translations,\n validation\n ),\n label: 'Welsh support email address'\n },\n {\n name: contactEmailResponseKey,\n englishContent: metadata.contact?.email?.responseTime ?? '--',\n welshContent: getTranslation(\n contactEmailResponseKey,\n translations,\n validation\n ),\n label: 'Welsh response time message'\n },\n {\n name: contactOnlineUrlKey,\n englishContent: metadata.contact?.online?.url ?? 'Not set',\n welshContent: getTranslation(\n contactOnlineUrlKey,\n translations,\n validation\n ),\n label: 'Welsh contact link URL'\n },\n {\n name: contactOnlineTextKey,\n englishContent: metadata.contact?.online?.text ?? '--',\n welshContent: getTranslation(\n contactOnlineTextKey,\n translations,\n validation\n ),\n label: 'Welsh text for the contact link'\n },\n {\n name: contactPhoneKey,\n englishContent: metadata.contact?.phone ?? 'Not set',\n welshContent: getTranslation(contactPhoneKey, translations, validation),\n label: 'Welsh phone number and opening times'\n },\n {\n name: submissionGuidanceKey,\n englishContent: metadata.submissionGuidance ?? 'Not set',\n welshContent: getTranslation(\n submissionGuidanceKey,\n translations,\n validation\n ),\n label: 'Welsh information about what happens next'\n }\n )\n\n if (metadata.privacyNoticeType === 'link') {\n rows.push({\n name: privacyNoticeUrlKey,\n englishContent: metadata.privacyNoticeUrl ?? 'Not set',\n welshContent: getTranslation(\n privacyNoticeUrlKey,\n translations,\n validation\n ),\n label: 'Welsh privacy notice URL'\n })\n } else {\n rows.push({\n name: privacyNoticeTextKey,\n englishContent: metadata.privacyNoticeText ?? 'Not set',\n welshContent: getTranslation(\n privacyNoticeTextKey,\n translations,\n validation\n ),\n label: 'Welsh privacy notice text'\n })\n }\n\n return /** @type {TranslationRow[]} */ (rows)\n}\n\n/**\n * @import { FormMetadata } from '~/src/form/form-metadata/types.js'\n * @import { FormDefinition } from '~/src/form/form-definition/types.js'\n * @import { TranslationRow, ValidationFailure} from '~/src/form/form-editor/translations/translations-config.js'\n */\n"],"mappings":"AAAA,SAASA,iBAAiB;AAE1B,MAAMC,WAAW,GAAG,YAAY;AAChC,MAAMC,sBAAsB,GAAG,4BAA4B;AAC3D,MAAMC,uBAAuB,GAAG,iCAAiC;AACjE,MA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