@defra/forms-model 3.0.576 → 3.0.577
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/form/form-editor/__stubs__/preview.js +53 -17
- package/dist/module/form/form-editor/__stubs__/preview.js.map +1 -1
- package/dist/module/form/form-editor/index.js +3 -2
- package/dist/module/form/form-editor/index.js.map +1 -1
- package/dist/module/form/form-editor/macros/types.js.map +1 -1
- package/dist/module/form/form-editor/preview/declaration.js +82 -0
- package/dist/module/form/form-editor/preview/declaration.js.map +1 -0
- package/dist/module/form/form-editor/preview/helpers.js +43 -10
- package/dist/module/form/form-editor/preview/helpers.js.map +1 -1
- package/dist/module/form/form-editor/preview/index.js +1 -0
- package/dist/module/form/form-editor/preview/index.js.map +1 -1
- package/dist/module/form/form-editor/preview/types.js.map +1 -1
- package/dist/module/form/form-editor/preview/uk-address.js +3 -3
- package/dist/module/form/form-editor/preview/uk-address.js.map +1 -1
- package/dist/module/form/form-editor/types.js.map +1 -1
- package/dist/types/form/form-editor/__stubs__/preview.d.ts +38 -12
- package/dist/types/form/form-editor/__stubs__/preview.d.ts.map +1 -1
- package/dist/types/form/form-editor/index.d.ts +1 -0
- package/dist/types/form/form-editor/index.d.ts.map +1 -1
- package/dist/types/form/form-editor/macros/types.d.ts +6 -0
- package/dist/types/form/form-editor/macros/types.d.ts.map +1 -1
- package/dist/types/form/form-editor/preview/declaration.d.ts +42 -0
- package/dist/types/form/form-editor/preview/declaration.d.ts.map +1 -0
- package/dist/types/form/form-editor/preview/helpers.d.ts.map +1 -1
- package/dist/types/form/form-editor/preview/index.d.ts +1 -0
- package/dist/types/form/form-editor/preview/types.d.ts +12 -1
- package/dist/types/form/form-editor/preview/types.d.ts.map +1 -1
- package/dist/types/form/form-editor/preview/uk-address.d.ts +13 -0
- package/dist/types/form/form-editor/preview/uk-address.d.ts.map +1 -1
- package/dist/types/form/form-editor/types.d.ts +8 -1
- package/dist/types/form/form-editor/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/schemas/form-editor-input-page-schema.json +1 -0
- package/schemas/question-type-full-schema.json +1 -0
- package/schemas/question-type-schema.json +1 -0
- package/src/form/form-editor/__stubs__/preview.js +47 -17
- package/src/form/form-editor/index.ts +3 -0
- package/src/form/form-editor/macros/types.ts +7 -0
- package/src/form/form-editor/preview/declaration.js +88 -0
- package/src/form/form-editor/preview/helpers.js +47 -16
- package/src/form/form-editor/preview/index.js +1 -0
- package/src/form/form-editor/preview/types.ts +16 -1
- package/src/form/form-editor/preview/uk-address.js +3 -3
- package/src/form/form-editor/types.ts +8 -0
|
@@ -101,11 +101,6 @@ export class QuestionPreviewElements {
|
|
|
101
101
|
* @private
|
|
102
102
|
*/
|
|
103
103
|
_items = [];
|
|
104
|
-
/**
|
|
105
|
-
* @protected
|
|
106
|
-
* @type {boolean}
|
|
107
|
-
*/
|
|
108
|
-
_usePostcodeLookup = false;
|
|
109
104
|
afterInputsHTML = '<div class="govuk-inset-text">No items added yet.</div>';
|
|
110
105
|
|
|
111
106
|
/**
|
|
@@ -117,7 +112,6 @@ export class QuestionPreviewElements {
|
|
|
117
112
|
optional,
|
|
118
113
|
shortDesc,
|
|
119
114
|
userClasses,
|
|
120
|
-
usePostcodeLookup,
|
|
121
115
|
items,
|
|
122
116
|
content
|
|
123
117
|
}) {
|
|
@@ -128,7 +122,6 @@ export class QuestionPreviewElements {
|
|
|
128
122
|
this._userClasses = userClasses;
|
|
129
123
|
this._items = items;
|
|
130
124
|
this._content = content;
|
|
131
|
-
this._usePostcodeLookup = usePostcodeLookup ?? false;
|
|
132
125
|
}
|
|
133
126
|
|
|
134
127
|
/**
|
|
@@ -141,7 +134,6 @@ export class QuestionPreviewElements {
|
|
|
141
134
|
optional: this._optional,
|
|
142
135
|
shortDesc: this._shortDesc,
|
|
143
136
|
userClasses: this._userClasses,
|
|
144
|
-
usePostcodeLookup: this._usePostcodeLookup,
|
|
145
137
|
items: this._items,
|
|
146
138
|
content: this._content
|
|
147
139
|
};
|
|
@@ -178,6 +170,58 @@ export class AutocompletePreviewElements extends QuestionPreviewElements {
|
|
|
178
170
|
}
|
|
179
171
|
}
|
|
180
172
|
|
|
173
|
+
/**
|
|
174
|
+
* @implements {UkAddressElements}
|
|
175
|
+
*/
|
|
176
|
+
export class UkAddressPreviewElements extends QuestionPreviewElements {
|
|
177
|
+
/**
|
|
178
|
+
* @param {BaseSettings & {usePostcodeLookup?: boolean}} elements
|
|
179
|
+
*/
|
|
180
|
+
constructor({
|
|
181
|
+
usePostcodeLookup,
|
|
182
|
+
...elements
|
|
183
|
+
}) {
|
|
184
|
+
super(elements);
|
|
185
|
+
this._usePostcodeLookup = usePostcodeLookup ?? false;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* @returns {UkAddressSettings}
|
|
190
|
+
*/
|
|
191
|
+
get values() {
|
|
192
|
+
return {
|
|
193
|
+
...super.values,
|
|
194
|
+
usePostcodeLookup: this._usePostcodeLookup
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* @implements {DeclarationElements}
|
|
201
|
+
*/
|
|
202
|
+
export class DeclarationPreviewElements extends QuestionPreviewElements {
|
|
203
|
+
/**
|
|
204
|
+
* @param {BaseSettings & {declarationText: string}} elements
|
|
205
|
+
*/
|
|
206
|
+
constructor({
|
|
207
|
+
declarationText,
|
|
208
|
+
...elements
|
|
209
|
+
}) {
|
|
210
|
+
super(elements);
|
|
211
|
+
this._declarationText = declarationText;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* @returns {DeclarationSettings}
|
|
216
|
+
*/
|
|
217
|
+
get values() {
|
|
218
|
+
return {
|
|
219
|
+
...super.values,
|
|
220
|
+
declarationText: this._declarationText
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
181
225
|
/**
|
|
182
226
|
* @implements {PageOverviewElements}
|
|
183
227
|
*/
|
|
@@ -320,11 +364,6 @@ export class NumberPreviewElements {
|
|
|
320
364
|
* @private
|
|
321
365
|
*/
|
|
322
366
|
_items = [];
|
|
323
|
-
/**
|
|
324
|
-
* @protected
|
|
325
|
-
* @type {boolean}
|
|
326
|
-
*/
|
|
327
|
-
_usePostcodeLookup = false;
|
|
328
367
|
afterInputsHTML = '<div class="govuk-inset-text">No items added yet.</div>';
|
|
329
368
|
|
|
330
369
|
/**
|
|
@@ -338,7 +377,6 @@ export class NumberPreviewElements {
|
|
|
338
377
|
userClasses,
|
|
339
378
|
prefix,
|
|
340
379
|
suffix,
|
|
341
|
-
usePostcodeLookup,
|
|
342
380
|
items,
|
|
343
381
|
content
|
|
344
382
|
}) {
|
|
@@ -351,7 +389,6 @@ export class NumberPreviewElements {
|
|
|
351
389
|
this._suffix = suffix;
|
|
352
390
|
this._items = items;
|
|
353
391
|
this._content = content;
|
|
354
|
-
this._usePostcodeLookup = usePostcodeLookup ?? false;
|
|
355
392
|
}
|
|
356
393
|
|
|
357
394
|
/**
|
|
@@ -366,7 +403,6 @@ export class NumberPreviewElements {
|
|
|
366
403
|
userClasses: this._userClasses,
|
|
367
404
|
prefix: this._prefix,
|
|
368
405
|
suffix: this._suffix,
|
|
369
|
-
usePostcodeLookup: this._usePostcodeLookup,
|
|
370
406
|
items: this._items,
|
|
371
407
|
content: this._content
|
|
372
408
|
};
|
|
@@ -390,6 +426,6 @@ export class NumberPreviewElements {
|
|
|
390
426
|
/**
|
|
391
427
|
* @import { ListElement } from '~/src/form/form-editor/types.js'
|
|
392
428
|
* @import { PagePreviewPanelMacro } from '~/src/form/form-editor/macros/types.js'
|
|
393
|
-
* @import { BaseSettings, ListElements, NumberSettings, RenderContext, QuestionBaseModel, QuestionRenderer, AutocompleteElements, PageOverviewElements, PageRenderer } from '~/src/form/form-editor/preview/types.js'
|
|
429
|
+
* @import { BaseSettings, ListElements, NumberSettings, RenderContext, QuestionBaseModel, QuestionRenderer, AutocompleteElements, PageOverviewElements, PageRenderer, UkAddressElements, UkAddressSettings, DeclarationElements, DeclarationSettings } from '~/src/form/form-editor/preview/types.js'
|
|
394
430
|
*/
|
|
395
431
|
//# sourceMappingURL=preview.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preview.js","names":["Question","QuestionRendererStub","renderMock","constructor","render","questionTemplate","questionBaseModel","buildHTML","_questionTemplate","_renderContext","PageRendererStub","pageTemplate","pagePreviewPanelMacro","QuestionPreviewElements","_question","_hintText","_optional","_shortDesc","_userClasses","_content","_items","_usePostcodeLookup","afterInputsHTML","question","hintText","optional","shortDesc","userClasses","usePostcodeLookup","items","content","values","setPreviewHTML","_value","setPreviewDOM","AutocompletePreviewElements","autocompleteOptions","elements","PagePreviewElements","guidance","heading","addHeading","repeatQuestion","hasRepeater","undefined","length","baseElements","largeTitle","numberElements","prefix","suffix","list1Id","list2Id","list3Id","list4Id","listElementsBase","label","text","value","id","listElementsStub","buildPreviewShortAnswer","partialBaseElements","NumberPreviewElements","_prefix","_suffix"],"sources":["../../../../../src/form/form-editor/__stubs__/preview.js"],"sourcesContent":["import { Question } from '~/src/form/form-editor/preview/question.js'\n\n/**\n * @implements {QuestionRenderer}\n */\nexport class QuestionRendererStub {\n /**\n * @type {jest.Mock<void, [string, QuestionBaseModel]>}\n */\n renderMock\n\n /**\n * @param {jest.Mock<void, [string, QuestionBaseModel]>} renderMock\n */\n constructor(renderMock) {\n this.renderMock = renderMock\n }\n\n /**\n * @param {string} questionTemplate\n * @param {QuestionBaseModel} questionBaseModel\n */\n render(questionTemplate, questionBaseModel) {\n this.renderMock(questionTemplate, questionBaseModel)\n }\n\n /**\n * @returns {string}\n * @param {string} _questionTemplate\n * @param {RenderContext} _renderContext\n */\n static buildHTML(_questionTemplate, _renderContext) {\n return '**** BUILT HTML ****'\n }\n}\n\n/**\n * @implements {PageRenderer}\n */\nexport class PageRendererStub {\n /**\n * @type {jest.Mock<void, [string, PagePreviewPanelMacro]>}\n */\n renderMock\n\n /**\n * @param {jest.Mock<void, [string, PagePreviewPanelMacro]>} renderMock\n */\n constructor(renderMock) {\n this.renderMock = renderMock\n }\n\n /**\n * @param {string} pageTemplate\n * @param {PagePreviewPanelMacro} pagePreviewPanelMacro\n */\n render(pageTemplate, pagePreviewPanelMacro) {\n this.renderMock(pageTemplate, pagePreviewPanelMacro)\n }\n\n /**\n * @returns {string}\n * @param {string} _questionTemplate\n * @param {RenderContext} _renderContext\n */\n static buildHTML(_questionTemplate, _renderContext) {\n return '**** BUILT HTML ****'\n }\n}\n\n/**\n * @implements {ListElements}\n */\nexport class QuestionPreviewElements {\n /**\n * @protected\n */\n _question = ''\n /** @protected */\n _hintText = ''\n /** @protected */\n _optional = false\n /**\n * @type {string}\n * @protected\n */\n _shortDesc = ''\n /**\n * @type {string}\n * @protected\n */\n _userClasses = ''\n /**\n * @type {string}\n * @protected\n */\n _content = ''\n /**\n *\n * @type {ListElement[]}\n * @private\n */\n _items = []\n /**\n * @protected\n * @type {boolean}\n */\n _usePostcodeLookup = false\n afterInputsHTML = '<div class=\"govuk-inset-text\">No items added yet.</div>'\n\n /**\n * @param {BaseSettings} baseSettings\n */\n constructor({\n question,\n hintText,\n optional,\n shortDesc,\n userClasses,\n usePostcodeLookup,\n items,\n content\n }) {\n this._question = question\n this._hintText = hintText\n this._optional = optional\n this._shortDesc = shortDesc\n this._userClasses = userClasses\n this._items = items\n this._content = content\n this._usePostcodeLookup = usePostcodeLookup ?? false\n }\n\n /**\n * @returns {BaseSettings}\n */\n get values() {\n return {\n question: this._question,\n hintText: this._hintText,\n optional: this._optional,\n shortDesc: this._shortDesc,\n userClasses: this._userClasses,\n usePostcodeLookup: this._usePostcodeLookup,\n items: this._items,\n content: this._content\n }\n }\n\n /**\n * @param {string} _value\n */\n setPreviewHTML(_value) {\n // Not implemented for server side render\n }\n\n /**\n * @param {HTMLElement} _value\n */\n setPreviewDOM(_value) {\n // Not implemented for server side render\n }\n}\n\n/**\n * @implements {AutocompleteElements}\n */\nexport class AutocompletePreviewElements extends QuestionPreviewElements {\n /**\n * @param {BaseSettings & {autocompleteOptions: string}} elements\n */\n constructor({ autocompleteOptions, ...elements }) {\n super(elements)\n this.autocompleteOptions = autocompleteOptions\n }\n}\n\n/**\n * @implements {PageOverviewElements}\n */\nexport class PagePreviewElements {\n guidance\n heading\n addHeading\n repeatQuestion\n hasRepeater\n\n /**\n * @param {string} heading\n * @param {string} guidance\n * @param {boolean} [addHeading]\n * @param {string} repeatQuestion\n * @param {boolean} hasRepeater\n */\n constructor(\n heading,\n guidance = '',\n addHeading = undefined,\n repeatQuestion = '',\n hasRepeater = false\n ) {\n this.heading = heading\n this.guidance = guidance\n this.addHeading = addHeading ?? heading.length > 0\n this.repeatQuestion = repeatQuestion\n this.hasRepeater = hasRepeater\n }\n}\n\nexport const baseElements = /** @type {BaseSettings} */ ({\n items: [],\n optional: false,\n question: 'Which quest would you like to pick?',\n hintText: 'Choose one adventure that best suits you.',\n userClasses: '',\n shortDesc: '',\n content: '',\n largeTitle: true\n})\n\nexport const numberElements = /** @type {NumberSettings} */ ({\n items: [],\n optional: false,\n question: 'Which quest would you like to pick?',\n hintText: 'Choose one adventure that best suits you.',\n userClasses: '',\n shortDesc: '',\n content: '',\n largeTitle: true,\n prefix: '',\n suffix: ''\n})\n\nconst list1Id = '414d82a3-4cab-416a-bd54-6b86fbd51120'\nconst list2Id = '801385a4-81e6-4171-96c3-6c6727d97f22'\nconst list3Id = 'e6e3f621-b875-4ca3-a054-cca9149149dd'\nconst list4Id = 'd71b3909-582f-4e90-b6f5-490b89a6eb8f'\n\nconst listElementsBase = /** @type {BaseSettings} */ ({\n ...baseElements,\n items: [\n {\n label: { text: 'Treasure Hunting' },\n text: 'Treasure Hunting',\n value: 'Treasure Hunting',\n id: list1Id\n },\n {\n label: { text: 'Rescuing the princess' },\n text: 'Rescuing the princess',\n value: 'Rescuing the princess',\n id: list2Id\n },\n {\n label: { text: 'Saving a city' },\n text: 'Saving a city',\n value: 'Saving a city',\n id: list3Id\n },\n {\n label: { text: 'Defeating the baron' },\n text: 'Defeating the baron',\n value: 'Defeating the baron',\n id: list4Id\n }\n ]\n})\n\nexport const listElementsStub = {\n list1Id,\n list2Id,\n list3Id,\n list4Id,\n baseElements: listElementsBase\n}\n\n/**\n * @param {Partial<BaseSettings>} partialBaseElements\n * @param {jest.Mock<void, [string, QuestionBaseModel]>} renderMock\n * @returns {Question}\n */\nexport function buildPreviewShortAnswer(partialBaseElements, renderMock) {\n return new Question(\n new QuestionPreviewElements({\n ...baseElements,\n ...partialBaseElements\n }),\n new QuestionRendererStub(renderMock)\n )\n}\n\nexport class NumberPreviewElements {\n /**\n * @protected\n */\n _question = ''\n /** @protected */\n _hintText = ''\n /** @protected */\n _optional = false\n /**\n * @type {string}\n * @protected\n */\n _shortDesc = ''\n /**\n * @type {string}\n * @protected\n */\n _userClasses = ''\n /**\n * @type {string}\n * @protected\n */\n _prefix = ''\n /**\n * @type {string}\n * @protected\n */\n _suffix = ''\n /**\n * @type {string}\n * @protected\n */\n _content = ''\n /**\n *\n * @type {ListElement[]}\n * @private\n */\n _items = []\n /**\n * @protected\n * @type {boolean}\n */\n _usePostcodeLookup = false\n afterInputsHTML = '<div class=\"govuk-inset-text\">No items added yet.</div>'\n\n /**\n * @param {NumberSettings} baseSettings\n */\n constructor({\n question,\n hintText,\n optional,\n shortDesc,\n userClasses,\n prefix,\n suffix,\n usePostcodeLookup,\n items,\n content\n }) {\n this._question = question\n this._hintText = hintText\n this._optional = optional\n this._shortDesc = shortDesc\n this._userClasses = userClasses\n this._prefix = prefix\n this._suffix = suffix\n this._items = items\n this._content = content\n this._usePostcodeLookup = usePostcodeLookup ?? false\n }\n\n /**\n * @returns {NumberSettings}\n */\n get values() {\n return {\n question: this._question,\n hintText: this._hintText,\n optional: this._optional,\n shortDesc: this._shortDesc,\n userClasses: this._userClasses,\n prefix: this._prefix,\n suffix: this._suffix,\n usePostcodeLookup: this._usePostcodeLookup,\n items: this._items,\n content: this._content\n }\n }\n\n /**\n * @param {string} _value\n */\n setPreviewHTML(_value) {\n // Not implemented for server side render\n }\n\n /**\n * @param {HTMLElement} _value\n */\n setPreviewDOM(_value) {\n // Not implemented for server side render\n }\n}\n\n/**\n * @import { ListElement } from '~/src/form/form-editor/types.js'\n * @import { PagePreviewPanelMacro } from '~/src/form/form-editor/macros/types.js'\n * @import { BaseSettings, ListElements, NumberSettings, RenderContext, QuestionBaseModel, QuestionRenderer, AutocompleteElements, PageOverviewElements, PageRenderer } from '~/src/form/form-editor/preview/types.js'\n */\n"],"mappings":"AAAA,SAASA,QAAQ;;AAEjB;AACA;AACA;AACA,OAAO,MAAMC,oBAAoB,CAAC;EAChC;AACF;AACA;EACEC,UAAU;;EAEV;AACF;AACA;EACEC,WAAWA,CAACD,UAAU,EAAE;IACtB,IAAI,CAACA,UAAU,GAAGA,UAAU;EAC9B;;EAEA;AACF;AACA;AACA;EACEE,MAAMA,CAACC,gBAAgB,EAAEC,iBAAiB,EAAE;IAC1C,IAAI,CAACJ,UAAU,CAACG,gBAAgB,EAAEC,iBAAiB,CAAC;EACtD;;EAEA;AACF;AACA;AACA;AACA;EACE,OAAOC,SAASA,CAACC,iBAAiB,EAAEC,cAAc,EAAE;IAClD,OAAO,sBAAsB;EAC/B;AACF;;AAEA;AACA;AACA;AACA,OAAO,MAAMC,gBAAgB,CAAC;EAC5B;AACF;AACA;EACER,UAAU;;EAEV;AACF;AACA;EACEC,WAAWA,CAACD,UAAU,EAAE;IACtB,IAAI,CAACA,UAAU,GAAGA,UAAU;EAC9B;;EAEA;AACF;AACA;AACA;EACEE,MAAMA,CAACO,YAAY,EAAEC,qBAAqB,EAAE;IAC1C,IAAI,CAACV,UAAU,CAACS,YAAY,EAAEC,qBAAqB,CAAC;EACtD;;EAEA;AACF;AACA;AACA;AACA;EACE,OAAOL,SAASA,CAACC,iBAAiB,EAAEC,cAAc,EAAE;IAClD,OAAO,sBAAsB;EAC/B;AACF;;AAEA;AACA;AACA;A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AMA,CAAA,EAAG;IACX,OAAO;MACLR,QAAQ,EAAE,IAAI,CAACT,SAAS;MACxBU,QAAQ,EAAE,IAAI,CAACT,SAAS;MACxBU,QAAQ,EAAE,IAAI,CAACT,SAAS;MACxBU,SAAS,EAAE,IAAI,CAACT,UAAU;MAC1BU,WAAW,EAAE,IAAI,CAACT,YAAY;MAC9B+B,MAAM,EAAE,IAAI,CAACe,OAAO;MACpBd,MAAM,EAAE,IAAI,CAACe,OAAO;MACpBrC,iBAAiB,EAAE,IAAI,CAACP,kBAAkB;MAC1CQ,KAAK,EAAE,IAAI,CAACT,MAAM;MAClBU,OAAO,EAAE,IAAI,CAACX;IAChB,CAAC;EACH;;EAEA;AACF;AACA;EACEa,cAAcA,CAACC,MAAM,EAAE;IACrB;EAAA;;EAGF;AACF;AACA;EACEC,aAAaA,CAACD,MAAM,EAAE;IACpB;EAAA;AAEJ;;AAEA;AACA;AACA;AACA;AACA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"preview.js","names":["Question","QuestionRendererStub","renderMock","constructor","render","questionTemplate","questionBaseModel","buildHTML","_questionTemplate","_renderContext","PageRendererStub","pageTemplate","pagePreviewPanelMacro","QuestionPreviewElements","_question","_hintText","_optional","_shortDesc","_userClasses","_content","_items","afterInputsHTML","question","hintText","optional","shortDesc","userClasses","items","content","values","setPreviewHTML","_value","setPreviewDOM","AutocompletePreviewElements","autocompleteOptions","elements","UkAddressPreviewElements","usePostcodeLookup","_usePostcodeLookup","DeclarationPreviewElements","declarationText","_declarationText","PagePreviewElements","guidance","heading","addHeading","repeatQuestion","hasRepeater","undefined","length","baseElements","largeTitle","numberElements","prefix","suffix","list1Id","list2Id","list3Id","list4Id","listElementsBase","label","text","value","id","listElementsStub","buildPreviewShortAnswer","partialBaseElements","NumberPreviewElements","_prefix","_suffix"],"sources":["../../../../../src/form/form-editor/__stubs__/preview.js"],"sourcesContent":["import { Question } from '~/src/form/form-editor/preview/question.js'\n\n/**\n * @implements {QuestionRenderer}\n */\nexport class QuestionRendererStub {\n /**\n * @type {jest.Mock<void, [string, QuestionBaseModel]>}\n */\n renderMock\n\n /**\n * @param {jest.Mock<void, [string, QuestionBaseModel]>} renderMock\n */\n constructor(renderMock) {\n this.renderMock = renderMock\n }\n\n /**\n * @param {string} questionTemplate\n * @param {QuestionBaseModel} questionBaseModel\n */\n render(questionTemplate, questionBaseModel) {\n this.renderMock(questionTemplate, questionBaseModel)\n }\n\n /**\n * @returns {string}\n * @param {string} _questionTemplate\n * @param {RenderContext} _renderContext\n */\n static buildHTML(_questionTemplate, _renderContext) {\n return '**** BUILT HTML ****'\n }\n}\n\n/**\n * @implements {PageRenderer}\n */\nexport class PageRendererStub {\n /**\n * @type {jest.Mock<void, [string, PagePreviewPanelMacro]>}\n */\n renderMock\n\n /**\n * @param {jest.Mock<void, [string, PagePreviewPanelMacro]>} renderMock\n */\n constructor(renderMock) {\n this.renderMock = renderMock\n }\n\n /**\n * @param {string} pageTemplate\n * @param {PagePreviewPanelMacro} pagePreviewPanelMacro\n */\n render(pageTemplate, pagePreviewPanelMacro) {\n this.renderMock(pageTemplate, pagePreviewPanelMacro)\n }\n\n /**\n * @returns {string}\n * @param {string} _questionTemplate\n * @param {RenderContext} _renderContext\n */\n static buildHTML(_questionTemplate, _renderContext) {\n return '**** BUILT HTML ****'\n }\n}\n\n/**\n * @implements {ListElements}\n */\nexport class QuestionPreviewElements {\n /**\n * @protected\n */\n _question = ''\n /** @protected */\n _hintText = ''\n /** @protected */\n _optional = false\n /**\n * @type {string}\n * @protected\n */\n _shortDesc = ''\n /**\n * @type {string}\n * @protected\n */\n _userClasses = ''\n /**\n * @type {string}\n * @protected\n */\n _content = ''\n /**\n *\n * @type {ListElement[]}\n * @private\n */\n _items = []\n afterInputsHTML = '<div class=\"govuk-inset-text\">No items added yet.</div>'\n\n /**\n * @param {BaseSettings} baseSettings\n */\n constructor({\n question,\n hintText,\n optional,\n shortDesc,\n userClasses,\n items,\n content\n }) {\n this._question = question\n this._hintText = hintText\n this._optional = optional\n this._shortDesc = shortDesc\n this._userClasses = userClasses\n this._items = items\n this._content = content\n }\n\n /**\n * @returns {BaseSettings}\n */\n get values() {\n return {\n question: this._question,\n hintText: this._hintText,\n optional: this._optional,\n shortDesc: this._shortDesc,\n userClasses: this._userClasses,\n items: this._items,\n content: this._content\n }\n }\n\n /**\n * @param {string} _value\n */\n setPreviewHTML(_value) {\n // Not implemented for server side render\n }\n\n /**\n * @param {HTMLElement} _value\n */\n setPreviewDOM(_value) {\n // Not implemented for server side render\n }\n}\n\n/**\n * @implements {AutocompleteElements}\n */\nexport class AutocompletePreviewElements extends QuestionPreviewElements {\n /**\n * @param {BaseSettings & {autocompleteOptions: string}} elements\n */\n constructor({ autocompleteOptions, ...elements }) {\n super(elements)\n this.autocompleteOptions = autocompleteOptions\n }\n}\n\n/**\n * @implements {UkAddressElements}\n */\nexport class UkAddressPreviewElements extends QuestionPreviewElements {\n /**\n * @param {BaseSettings & {usePostcodeLookup?: boolean}} elements\n */\n constructor({ usePostcodeLookup, ...elements }) {\n super(elements)\n this._usePostcodeLookup = usePostcodeLookup ?? false\n }\n\n /**\n * @returns {UkAddressSettings}\n */\n get values() {\n return {\n ...super.values,\n usePostcodeLookup: this._usePostcodeLookup\n }\n }\n}\n\n/**\n * @implements {DeclarationElements}\n */\nexport class DeclarationPreviewElements extends QuestionPreviewElements {\n /**\n * @param {BaseSettings & {declarationText: string}} elements\n */\n constructor({ declarationText, ...elements }) {\n super(elements)\n this._declarationText = declarationText\n }\n\n /**\n * @returns {DeclarationSettings}\n */\n get values() {\n return {\n ...super.values,\n declarationText: this._declarationText\n }\n }\n}\n\n/**\n * @implements {PageOverviewElements}\n */\nexport class PagePreviewElements {\n guidance\n heading\n addHeading\n repeatQuestion\n hasRepeater\n\n /**\n * @param {string} heading\n * @param {string} guidance\n * @param {boolean} [addHeading]\n * @param {string} repeatQuestion\n * @param {boolean} hasRepeater\n */\n constructor(\n heading,\n guidance = '',\n addHeading = undefined,\n repeatQuestion = '',\n hasRepeater = false\n ) {\n this.heading = heading\n this.guidance = guidance\n this.addHeading = addHeading ?? heading.length > 0\n this.repeatQuestion = repeatQuestion\n this.hasRepeater = hasRepeater\n }\n}\n\nexport const baseElements = /** @type {BaseSettings} */ ({\n items: [],\n optional: false,\n question: 'Which quest would you like to pick?',\n hintText: 'Choose one adventure that best suits you.',\n userClasses: '',\n shortDesc: '',\n content: '',\n largeTitle: true\n})\n\nexport const numberElements = /** @type {NumberSettings} */ ({\n items: [],\n optional: false,\n question: 'Which quest would you like to pick?',\n hintText: 'Choose one adventure that best suits you.',\n userClasses: '',\n shortDesc: '',\n content: '',\n largeTitle: true,\n prefix: '',\n suffix: ''\n})\n\nconst list1Id = '414d82a3-4cab-416a-bd54-6b86fbd51120'\nconst list2Id = '801385a4-81e6-4171-96c3-6c6727d97f22'\nconst list3Id = 'e6e3f621-b875-4ca3-a054-cca9149149dd'\nconst list4Id = 'd71b3909-582f-4e90-b6f5-490b89a6eb8f'\n\nconst listElementsBase = /** @type {BaseSettings} */ ({\n ...baseElements,\n items: [\n {\n label: { text: 'Treasure Hunting' },\n text: 'Treasure Hunting',\n value: 'Treasure Hunting',\n id: list1Id\n },\n {\n label: { text: 'Rescuing the princess' },\n text: 'Rescuing the princess',\n value: 'Rescuing the princess',\n id: list2Id\n },\n {\n label: { text: 'Saving a city' },\n text: 'Saving a city',\n value: 'Saving a city',\n id: list3Id\n },\n {\n label: { text: 'Defeating the baron' },\n text: 'Defeating the baron',\n value: 'Defeating the baron',\n id: list4Id\n }\n ]\n})\n\nexport const listElementsStub = {\n list1Id,\n list2Id,\n list3Id,\n list4Id,\n baseElements: listElementsBase\n}\n\n/**\n * @param {Partial<BaseSettings>} partialBaseElements\n * @param {jest.Mock<void, [string, QuestionBaseModel]>} renderMock\n * @returns {Question}\n */\nexport function buildPreviewShortAnswer(partialBaseElements, renderMock) {\n return new Question(\n new QuestionPreviewElements({\n ...baseElements,\n ...partialBaseElements\n }),\n new QuestionRendererStub(renderMock)\n )\n}\n\nexport class NumberPreviewElements {\n /**\n * @protected\n */\n _question = ''\n /** @protected */\n _hintText = ''\n /** @protected */\n _optional = false\n /**\n * @type {string}\n * @protected\n */\n _shortDesc = ''\n /**\n * @type {string}\n * @protected\n */\n _userClasses = ''\n /**\n * @type {string}\n * @protected\n */\n _prefix = ''\n /**\n * @type {string}\n * @protected\n */\n _suffix = ''\n /**\n * @type {string}\n * @protected\n */\n _content = ''\n /**\n *\n * @type {ListElement[]}\n * @private\n */\n _items = []\n afterInputsHTML = '<div class=\"govuk-inset-text\">No items added yet.</div>'\n\n /**\n * @param {NumberSettings} baseSettings\n */\n constructor({\n question,\n hintText,\n optional,\n shortDesc,\n userClasses,\n prefix,\n suffix,\n items,\n content\n }) {\n this._question = question\n this._hintText = hintText\n this._optional = optional\n this._shortDesc = shortDesc\n this._userClasses = userClasses\n this._prefix = prefix\n this._suffix = suffix\n this._items = items\n this._content = content\n }\n\n /**\n * @returns {NumberSettings}\n */\n get values() {\n return {\n question: this._question,\n hintText: this._hintText,\n optional: this._optional,\n shortDesc: this._shortDesc,\n userClasses: this._userClasses,\n prefix: this._prefix,\n suffix: this._suffix,\n items: this._items,\n content: this._content\n }\n }\n\n /**\n * @param {string} _value\n */\n setPreviewHTML(_value) {\n // Not implemented for server side render\n }\n\n /**\n * @param {HTMLElement} _value\n */\n setPreviewDOM(_value) {\n // Not implemented for server side render\n }\n}\n\n/**\n * @import { ListElement } from '~/src/form/form-editor/types.js'\n * @import { PagePreviewPanelMacro } from '~/src/form/form-editor/macros/types.js'\n * @import { BaseSettings, ListElements, NumberSettings, RenderContext, QuestionBaseModel, QuestionRenderer, AutocompleteElements, PageOverviewElements, PageRenderer, UkAddressElements, UkAddressSettings, DeclarationElements, DeclarationSettings } from '~/src/form/form-editor/preview/types.js'\n */\n"],"mappings":"AAAA,SAASA,QAAQ;;AAEjB;AACA;AACA;AACA,OAAO,MAAMC,oBAAoB,CAAC;EAChC;AACF;AACA;EACEC,UA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ACA;EACE,IAAIC,MAAMA,CAAA,EAAG;IACX,OAAO;MACLP,QAAQ,EAAE,IAAI,CAACR,SAAS;MACxBS,QAAQ,EAAE,IAAI,CAACR,SAAS;MACxBS,QAAQ,EAAE,IAAI,CAACR,SAAS;MACxBS,SAAS,EAAE,IAAI,CAACR,UAAU;MAC1BS,WAAW,EAAE,IAAI,CAACR,YAAY;MAC9BmC,MAAM,EAAE,IAAI,CAACe,OAAO;MACpBd,MAAM,EAAE,IAAI,CAACe,OAAO;MACpB1C,KAAK,EAAE,IAAI,CAACP,MAAM;MAClBQ,OAAO,EAAE,IAAI,CAACT;IAChB,CAAC;EACH;;EAEA;AACF;AACA;EACEW,cAAcA,CAACC,MAAM,EAAE;IACrB;EAAA;;EAGF;AACF;AACA;EACEC,aAAaA,CAACD,MAAM,EAAE;IACpB;EAAA;AAEJ;;AAEA;AACA;AACA;AACA;AACA","ignoreList":[]}
|
|
@@ -9,8 +9,8 @@ export let QuestionTypeSubGroup = /*#__PURE__*/function (QuestionTypeSubGroup) {
|
|
|
9
9
|
return QuestionTypeSubGroup;
|
|
10
10
|
}({});
|
|
11
11
|
export const pageTypeSchema = Joi.string().required().valid('question', 'guidance').description('Type of page - either a question page or guidance page');
|
|
12
|
-
export const questionTypeSchema = Joi.string().required().valid(QuestionTypeSubGroup.WrittenAnswerSubGroup, QuestionTypeSubGroup.DateSubGroup, QuestionTypeSubGroup.LocationSubGroup, ComponentType.UkAddressField, ComponentType.TelephoneNumberField, ComponentType.FileUploadField, ComponentType.EmailAddressField, QuestionTypeSubGroup.ListSubGroup, ComponentType.YesNoField, ComponentType.CheckboxesField, ComponentType.RadiosField, ComponentType.AutocompleteField).description('The high-level type of question, including grouped types');
|
|
13
|
-
export const questionTypeFullSchema = Joi.string().required().valid(ComponentType.TextField, ComponentType.MultilineTextField, ComponentType.NumberField, ComponentType.DatePartsField, ComponentType.MonthYearField, ComponentType.UkAddressField, ComponentType.TelephoneNumberField, ComponentType.FileUploadField, ComponentType.EmailAddressField, ComponentType.YesNoField, ComponentType.CheckboxesField, ComponentType.RadiosField, ComponentType.AutocompleteField, ComponentType.SelectField, ComponentType.EastingNorthingField, ComponentType.OsGridRefField, ComponentType.NationalGridFieldNumberField, ComponentType.LatLongField).description('The specific component type to use for this question');
|
|
12
|
+
export const questionTypeSchema = Joi.string().required().valid(QuestionTypeSubGroup.WrittenAnswerSubGroup, QuestionTypeSubGroup.DateSubGroup, QuestionTypeSubGroup.LocationSubGroup, ComponentType.UkAddressField, ComponentType.TelephoneNumberField, ComponentType.FileUploadField, ComponentType.EmailAddressField, ComponentType.DeclarationField, QuestionTypeSubGroup.ListSubGroup, ComponentType.YesNoField, ComponentType.CheckboxesField, ComponentType.RadiosField, ComponentType.AutocompleteField).description('The high-level type of question, including grouped types');
|
|
13
|
+
export const questionTypeFullSchema = Joi.string().required().valid(ComponentType.TextField, ComponentType.MultilineTextField, ComponentType.NumberField, ComponentType.DatePartsField, ComponentType.MonthYearField, ComponentType.UkAddressField, ComponentType.TelephoneNumberField, ComponentType.FileUploadField, ComponentType.EmailAddressField, ComponentType.DeclarationField, ComponentType.YesNoField, ComponentType.CheckboxesField, ComponentType.RadiosField, ComponentType.AutocompleteField, ComponentType.SelectField, ComponentType.EastingNorthingField, ComponentType.OsGridRefField, ComponentType.NationalGridFieldNumberField, ComponentType.LatLongField).description('The specific component type to use for this question');
|
|
14
14
|
export const writtenAnswerSubSchema = Joi.string().required().valid(ComponentType.TextField, ComponentType.MultilineTextField, ComponentType.NumberField).description('Subtype for written answer questions');
|
|
15
15
|
export const dateSubSchema = Joi.string().required().valid(ComponentType.DatePartsField, ComponentType.MonthYearField).description('Subtype for date-related questions');
|
|
16
16
|
export const listSubSchema = Joi.string().required().valid(ComponentType.YesNoField, ComponentType.CheckboxesField, ComponentType.RadiosField, ComponentType.AutocompleteField, ComponentType.SelectField).description('Subtype for list-related questions');
|
|
@@ -171,6 +171,7 @@ export const autoCompleteOptionsSchema = customValidator.dsv().row(/\r?\n/).col(
|
|
|
171
171
|
export const questionDetailsFullSchema = {
|
|
172
172
|
autoCompleteOptionsSchema,
|
|
173
173
|
classesSchema,
|
|
174
|
+
declarationTextSchema,
|
|
174
175
|
documentTypesSchema,
|
|
175
176
|
enhancedActionSchema,
|
|
176
177
|
exactFilesSchema,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["Joi","ComponentType","MAX_NUMBER_OF_REPEAT_ITEMS","MIN_NUMBER_OF_REPEAT_ITEMS","QuestionTypeSubGroup","pageTypeSchema","string","required","valid","description","questionTypeSchema","WrittenAnswerSubGroup","DateSubGroup","LocationSubGroup","UkAddressField","TelephoneNumberField","FileUploadField","EmailAddressField","ListSubGroup","YesNoField","CheckboxesField","RadiosField","AutocompleteField","questionTypeFullSchema","TextField","MultilineTextField","NumberField","DatePartsField","MonthYearField","SelectField","EastingNorthingField","OsGridRefField","NationalGridFieldNumberField","LatLongField","writtenAnswerSubSchema","dateSubSchema","listSubSchema","locationSubSchema","nameSchema","trim","questionSchema","hintTextSchema","optional","allow","instructionTextSchema","questionOptionalSchema","listForQuestionSchema","listItemCountSchema","number","listItemsDataSchema","exactFilesSchema","empty","integer","min","max","minFilesSchema","maxFilesSchema","fileTypesSchema","array","items","single","default","documentTypesSchema","imageTypesSchema","tabularDataTypesSchema","enhancedActionSchema","radioIdSchema","radioTextSchema","radioHintSchema","radioValueSchema","shortDescriptionSchema","pageHeadingAndGuidanceSchema","pageHeadingSchema","guidanceTextSchema","exitPageSchema","boolean","repeaterSchema","minItemsSchema","maxItemsSchema","questionSetNameSchema","needDeclarationSchema","declarationTextSchema","minSchema","maxSchema","minLengthSchema","maxLengthSchema","maxFutureSchema","maxPastSchema","precisionSchema","prefixSchema","regexSchema","rowsSchema","suffixSchema","classesSchema","jsEnabledSchema","usePostcodeLookupSchema","customValidator","extend","joi","type","base","messages","coerce","from","method","value","helpers","rowSeparatorRule","schema","$_getRule","colSeparatorRule","keysRule","rowSeparator","args","rows","split","map","v","filter","Boolean","colSeparator","keys","coercedValue","row","reduce","acc","col","idx","_err","console","error","errors","rules","convert","alias","$_addRule","name","ref","assert","RegExp","message","Array","isArray","every","k","autoCompleteOptionsSchema","dsv","object","text","disallow","parent","unique","ignoreUndefined","questionDetailsFullSchema","formEditorInputPageKeys","pageType","questionType","formEditorInputPageSchema","formEditorInputheckAnswersSettingsKeys","declarationText","formEditorInputCheckAnswersSettingSchema","formEditorInputQuestionKeys","question","shortDescription","hintText","questionOptional","formEditorInputQuestionSchema","formEditorInputPageSettingsKeys","pageHeadingAndGuidance","pageHeading","guidanceText","formEditorInputPageSettingsSchema","govukFieldValueIsString","govukField","includes","govukFieldIsChecked","checkedValue","checked","allowedErrorTemplateFunctions"],"sources":["../../../../src/form/form-editor/index.ts"],"sourcesContent":["import Joi, { type ArraySchema, type GetRuleOptions } from 'joi'\n\nimport { ComponentType } from '~/src/components/enums.js'\nimport {\n MAX_NUMBER_OF_REPEAT_ITEMS,\n MIN_NUMBER_OF_REPEAT_ITEMS\n} from '~/src/form/form-definition/index.js'\nimport {\n type FormEditorInputCheckAnswersSettings,\n type FormEditorInputPage,\n type FormEditorInputPageSettings,\n type FormEditorInputQuestion,\n type GovukField,\n type GovukFieldQuestionOptional,\n type GovukFieldUsePostcodeLookup,\n type GovukStringField\n} from '~/src/form/form-editor/types.js'\n\nexport enum QuestionTypeSubGroup {\n WrittenAnswerSubGroup = 'writtenAnswerSub',\n DateSubGroup = 'dateSub',\n ListSubGroup = 'listSub',\n LocationSubGroup = 'locationSub'\n}\n\nexport const pageTypeSchema = Joi.string()\n .required()\n .valid('question', 'guidance')\n .description('Type of page - either a question page or guidance page')\n\nexport const questionTypeSchema = Joi.string()\n .required()\n .valid(\n QuestionTypeSubGroup.WrittenAnswerSubGroup,\n QuestionTypeSubGroup.DateSubGroup,\n QuestionTypeSubGroup.LocationSubGroup,\n ComponentType.UkAddressField,\n ComponentType.TelephoneNumberField,\n ComponentType.FileUploadField,\n ComponentType.EmailAddressField,\n QuestionTypeSubGroup.ListSubGroup,\n ComponentType.YesNoField,\n ComponentType.CheckboxesField,\n ComponentType.RadiosField,\n ComponentType.AutocompleteField\n )\n .description('The high-level type of question, including grouped types')\n\nexport const questionTypeFullSchema = Joi.string()\n .required()\n .valid(\n ComponentType.TextField,\n ComponentType.MultilineTextField,\n ComponentType.NumberField,\n ComponentType.DatePartsField,\n ComponentType.MonthYearField,\n ComponentType.UkAddressField,\n ComponentType.TelephoneNumberField,\n ComponentType.FileUploadField,\n ComponentType.EmailAddressField,\n ComponentType.YesNoField,\n ComponentType.CheckboxesField,\n ComponentType.RadiosField,\n ComponentType.AutocompleteField,\n ComponentType.SelectField,\n ComponentType.EastingNorthingField,\n ComponentType.OsGridRefField,\n ComponentType.NationalGridFieldNumberField,\n ComponentType.LatLongField\n )\n .description('The specific component type to use for this question')\n\nexport const writtenAnswerSubSchema = Joi.string()\n .required()\n .valid(\n ComponentType.TextField,\n ComponentType.MultilineTextField,\n ComponentType.NumberField\n )\n .description('Subtype for written answer questions')\n\nexport const dateSubSchema = Joi.string()\n .required()\n .valid(ComponentType.DatePartsField, ComponentType.MonthYearField)\n .description('Subtype for date-related questions')\n\nexport const listSubSchema = Joi.string()\n .required()\n .valid(\n ComponentType.YesNoField,\n ComponentType.CheckboxesField,\n ComponentType.RadiosField,\n ComponentType.AutocompleteField,\n ComponentType.SelectField\n )\n .description('Subtype for list-related questions')\n\nexport const locationSubSchema = Joi.string()\n .required()\n .valid(\n ComponentType.EastingNorthingField,\n ComponentType.OsGridRefField,\n ComponentType.NationalGridFieldNumberField,\n ComponentType.LatLongField\n )\n .description('Subtype for location-related questions')\n\nexport const nameSchema = Joi.string()\n .trim()\n .required()\n .description('Unique identifier for the field')\n\nexport const questionSchema = Joi.string()\n .trim()\n .required()\n .description('The question text displayed to the user')\n\nexport const hintTextSchema = Joi.string()\n .trim()\n .optional()\n .allow('')\n .description('Optional guidance text displayed below the question')\n\nexport const instructionTextSchema = Joi.string()\n .trim()\n .optional()\n .allow('')\n .description(\n 'Optional instruction text with markdown support to help users answer the question'\n )\n\nexport const questionOptionalSchema = Joi.string()\n .trim()\n .optional()\n .valid('', 'true')\n .description(\n 'Indicates whether a question is optional. Empty string or \"true\" values are accepted.'\n )\n\nexport const listForQuestionSchema = Joi.string()\n .trim()\n .optional()\n .allow('')\n .description('Unique identifier for the list used by the field')\n\nexport const listItemCountSchema = Joi.number()\n .optional()\n .description('Number of list items in the list used by the field')\n\nexport const listItemsDataSchema = Joi.string()\n .allow('')\n .description('List items in JSON format, such as for radios or checkboxes.')\n\nexport const exactFilesSchema = Joi.number()\n .empty('')\n .integer()\n .min(1)\n .max(25)\n .description(\n 'Specifies the exact number of files required for upload. Must be between 1 and 25.'\n )\n\nexport const minFilesSchema = Joi.number()\n .empty('')\n .integer()\n .min(1)\n .max(25)\n .description(\n 'Minimum number of files required for upload. Must be between 1 and 25.'\n )\n\nexport const maxFilesSchema = Joi.number()\n .empty('')\n .integer()\n .min(1)\n .max(25)\n .description(\n 'Maximum number of files allowed for upload. Must be between 1 and 25.'\n )\n\nexport const fileTypesSchema = Joi.array()\n .items(Joi.string())\n .single()\n .empty(null)\n .default([])\n .description(\n 'Array of allowed file types. Can be provided as a single value or an array.'\n )\n\nexport const documentTypesSchema = Joi.array()\n .items(Joi.string())\n .single()\n .empty(null)\n .default([])\n .description(\n 'Array of allowed document types. Can be provided as a single value or an array.'\n )\n\nexport const imageTypesSchema = Joi.array()\n .items(Joi.string())\n .single()\n .empty(null)\n .default([])\n .description(\n 'Array of allowed image types. Can be provided as a single value or an array.'\n )\n\nexport const tabularDataTypesSchema = Joi.array()\n .items(Joi.string())\n .single()\n .empty(null)\n .default([])\n\nexport const enhancedActionSchema = Joi.string()\n .trim()\n .optional()\n .allow('')\n .description('Action field that can include enhanced functionality')\n\nexport const radioIdSchema = Joi.string()\n .trim()\n .optional()\n .allow('')\n .description('Unique identifier for radio options')\n\nexport const radioTextSchema = Joi.string()\n .trim()\n .required()\n .description('The visible text shown next to radio options')\n\nexport const radioHintSchema = Joi.string()\n .trim()\n .optional()\n .allow('')\n .description(\n 'Optional hint text displayed with radio buttons to provide additional guidance'\n )\n\nexport const radioValueSchema = Joi.string()\n .trim()\n .optional()\n .allow('')\n .description(\n 'Array of allowed tabular data types. Can be provided as a single value or an array.'\n )\n\nexport const shortDescriptionSchema = Joi.string()\n .trim()\n .required()\n .description('Brief description of the question for internal use')\n\nexport const pageHeadingAndGuidanceSchema = Joi.string()\n .trim()\n .optional()\n .description('Combined heading and guidance for the page')\n\nexport const pageHeadingSchema = Joi.string()\n .trim()\n .required()\n .description('Main heading displayed at the top of the page')\n\nexport const guidanceTextSchema = Joi.string()\n .trim()\n .description('Guidance text to assist users in completing the page')\n\nexport const exitPageSchema = Joi.boolean()\n .default(false)\n .optional()\n .description('Determines if page is set as an Exit Page')\n\nexport const repeaterSchema = Joi.string()\n .trim()\n .optional()\n .description(\n 'Combined min/max items and question set name for the repeater page'\n )\n\nexport const minItemsSchema = Joi.number()\n .empty('')\n .min(MIN_NUMBER_OF_REPEAT_ITEMS)\n .description('The minimum number of repeater items')\n\nexport const maxItemsSchema = Joi.number()\n .empty('')\n .max(MAX_NUMBER_OF_REPEAT_ITEMS)\n .description('The maximum number of repeater items')\n\nexport const questionSetNameSchema = Joi.string()\n .trim()\n .description('The repeater question set name')\n\nexport const needDeclarationSchema = Joi.string()\n .trim()\n .required()\n .description('Whether a declaration is needed')\n\nexport const declarationTextSchema = Joi.string()\n .trim()\n .required()\n .description('Text of the declaration that users must agree to')\n\nexport const minSchema = Joi.number()\n .empty('')\n .integer()\n .description('Minimum value for numeric inputs')\n\nexport const maxSchema = Joi.number()\n .empty('')\n .integer()\n .description('Maximum value for numeric inputs')\n\nexport const minLengthSchema = Joi.number()\n .empty('')\n .integer()\n .min(1)\n .description('Minimum character length for text inputs')\n\nexport const maxLengthSchema = Joi.number()\n .empty('')\n .integer()\n .min(1)\n .description('Maximum character length for text inputs')\n\nexport const maxFutureSchema = Joi.number()\n .empty('')\n .integer()\n .min(0)\n .description('Maximum days in the future allowed for date inputs')\n\nexport const maxPastSchema = Joi.number()\n .empty('')\n .integer()\n .min(0)\n .description('Maximum days in the past allowed for date inputs')\n\nexport const precisionSchema = Joi.number()\n .empty('')\n .integer()\n .min(0)\n .description('Decimal precision for numeric inputs')\n\nexport const prefixSchema = Joi.string()\n .trim()\n .optional()\n .allow('')\n .description('Text to display before the input (e.g., £)')\n\nexport const regexSchema = Joi.string()\n .optional()\n .allow('')\n .description('Regular expression pattern for validation')\n\nexport const rowsSchema = Joi.number()\n .empty('')\n .integer()\n .min(1)\n .description('Number of rows for multiline text fields')\n\nexport const suffixSchema = Joi.string()\n .trim()\n .optional()\n .allow('')\n .description('Text to display after the input (e.g., kg)')\n\nexport const classesSchema = Joi.string()\n .trim()\n .optional()\n .allow('')\n .description('Custom CSS classes to apply to the component')\n\nexport const jsEnabledSchema = Joi.string()\n .trim()\n .optional()\n .allow('false', 'true')\n .description('Flag to show if Javascript is enabled or not')\n\nexport const usePostcodeLookupSchema = Joi.string()\n .trim()\n .optional()\n .valid('', 'true')\n .description(\n 'Indicates whether a UK address component supports postcode lookup. Empty string or \"true\" values are accepted.'\n )\n\ntype GenericRuleOptions<K extends string, T> = Omit<GetRuleOptions, 'args'> & {\n args: Record<K, T>\n}\n\ninterface DSLSchema<TSchema = Record<string, unknown>[]>\n extends ArraySchema<TSchema> {\n rowSeparator: (rowSep: string | RegExp) => DSLSchema<TSchema>\n row: (rowSep: string | RegExp) => DSLSchema<TSchema>\n colSeparator: (colSep: string | RegExp) => DSLSchema<TSchema>\n col: (colSep: string | RegExp) => DSLSchema<TSchema>\n keys: (keys: string[]) => DSLSchema<TSchema>\n}\n\ninterface CustomValidator extends Joi.Root {\n dsv<TSchema>(): DSLSchema<TSchema>\n}\n\nexport const customValidator = Joi.extend((joi: Joi.Root) => {\n return {\n type: 'dsv',\n base: joi.array(),\n messages: {\n 'dsv.invalid': 'Invalid parse string'\n },\n coerce: {\n from: 'string',\n method(value: string, helpers) {\n try {\n // Only called when prefs.convert is true\n // Rules\n const rowSeparatorRule = helpers.schema.$_getRule('rowSeparator') as\n | undefined\n | GenericRuleOptions<'rowSeparator', string | RegExp>\n const colSeparatorRule = helpers.schema.$_getRule('colSeparator') as\n | undefined\n | GenericRuleOptions<'colSeparator', string | RegExp>\n const keysRule = helpers.schema.$_getRule('keys') as\n | undefined\n | GenericRuleOptions<'keys', string[]>\n\n // Rows\n const rowSeparator = rowSeparatorRule?.args.rowSeparator ?? /\\r?\\n/\n const rows = value\n .split(rowSeparator)\n .map((v) => v.trim())\n .filter(Boolean)\n\n // Columns\n const colSeparator = colSeparatorRule?.args.colSeparator ?? ','\n const keys = keysRule?.args.keys ?? ['key', 'value']\n\n const coercedValue = rows.map((row) => {\n return row\n .split(colSeparator)\n .reduce<Record<string, string>>((acc, col, idx) => {\n return {\n ...acc,\n [keys[idx]]: col.trim()\n }\n }, {})\n })\n return { value: coercedValue }\n } catch (_err) {\n // eslint-disable-next-line no-console\n console.error(_err)\n return { value, errors: [helpers.error('dsv.invalid')] }\n }\n }\n },\n rules: {\n rowSeparator: {\n convert: true,\n alias: 'row',\n method(rowSeparator: string) {\n return this.$_addRule({\n name: 'rowSeparator',\n args: { rowSeparator }\n })\n },\n args: [\n {\n name: 'rowSeparator',\n ref: true,\n assert: (value) =>\n typeof value === 'string' || value instanceof RegExp,\n message: 'must be a string or regex'\n }\n ]\n },\n colSeparator: {\n convert: true,\n alias: 'col',\n method(colSeparator: string) {\n return this.$_addRule({\n name: 'colSeparator',\n args: { colSeparator }\n })\n },\n args: [\n {\n name: 'colSeparator',\n ref: true,\n assert: (value) =>\n typeof value === 'string' || value instanceof RegExp,\n message: 'must be a string or regex'\n }\n ]\n },\n keys: {\n convert: true,\n method(keys: string[]) {\n return this.$_addRule({ name: 'keys', args: { keys } })\n },\n args: [\n {\n name: 'keys',\n ref: true,\n assert: (value) =>\n Array.isArray(value) && value.every((k) => typeof k === 'string'),\n message: 'must be an array of strings'\n }\n ]\n }\n }\n }\n}) as CustomValidator\n\nexport const autoCompleteOptionsSchema = customValidator\n .dsv<{ text: string; value: string }[]>()\n .row(/\\r?\\n/)\n .col(':')\n .keys(['text', 'value'])\n .items(\n customValidator.object({\n text: customValidator.string().min(1).disallow('').required(),\n value: customValidator\n .string()\n .default((parent: { text: string; value?: string }) => parent.text)\n .min(1)\n .disallow('')\n })\n )\n .min(1)\n .unique('text')\n .unique('value', { ignoreUndefined: true })\n .required()\n\nexport const questionDetailsFullSchema = {\n autoCompleteOptionsSchema,\n classesSchema,\n documentTypesSchema,\n enhancedActionSchema,\n exactFilesSchema,\n fileTypesSchema,\n hintTextSchema,\n imageTypesSchema,\n instructionTextSchema,\n jsEnabledSchema,\n listForQuestionSchema,\n listItemCountSchema,\n listItemsDataSchema,\n maxFilesSchema,\n maxFutureSchema,\n maxLengthSchema,\n maxPastSchema,\n maxSchema,\n minFilesSchema,\n minLengthSchema,\n minSchema,\n nameSchema,\n precisionSchema,\n prefixSchema,\n questionOptionalSchema,\n questionSchema,\n questionTypeFullSchema,\n radioHintSchema,\n radioIdSchema,\n radioTextSchema,\n radioValueSchema,\n regexSchema,\n rowsSchema,\n shortDescriptionSchema,\n suffixSchema,\n tabularDataTypesSchema,\n usePostcodeLookupSchema\n}\n\nexport const formEditorInputPageKeys = {\n pageType: pageTypeSchema,\n questionType: questionTypeSchema\n}\n\n/**\n * Joi schema for `FormEditorInputPage` interface\n * @see {@link FormEditorInputPage}\n */\nexport const formEditorInputPageSchema = Joi.object<FormEditorInputPage>()\n .keys(formEditorInputPageKeys)\n .required()\n .description('Input schema for creating a new page in the form editor')\n\nexport const formEditorInputheckAnswersSettingsKeys = {\n declarationText: shortDescriptionSchema\n}\n\n/**\n * Joi schema for `FormEditorInputCheckAnswersSettings` interface\n * @see {@link FormEditorInputCheckAnswersSettings}\n */\nexport const formEditorInputCheckAnswersSettingSchema =\n Joi.object<FormEditorInputCheckAnswersSettings>()\n .keys(formEditorInputheckAnswersSettingsKeys)\n .required()\n .description('Configuration for the check-answers page')\n\nexport const formEditorInputQuestionKeys = {\n question: questionSchema,\n shortDescription: shortDescriptionSchema,\n hintText: hintTextSchema,\n questionOptional: questionOptionalSchema\n}\n\n/**\n * Joi schema for `FormEditorInputQuestion` interface\n * @see {@link FormEditorInputQuestion}\n */\nexport const formEditorInputQuestionSchema =\n Joi.object<FormEditorInputQuestion>()\n .keys(formEditorInputQuestionKeys)\n .required()\n .description(\n 'Input schema for creating or updating a question in the form editor'\n )\n\nexport const formEditorInputPageSettingsKeys = {\n pageHeadingAndGuidance: pageHeadingAndGuidanceSchema,\n pageHeading: pageHeadingSchema,\n guidanceText: guidanceTextSchema\n}\n\n/**\n * Joi schema for `FormEditorInputPageSettings` interface\n * @see {@link FormEditorInputPageSettings}\n */\nexport const formEditorInputPageSettingsSchema =\n Joi.object<FormEditorInputPageSettings>()\n .keys(formEditorInputPageSettingsKeys)\n .required()\n .description('Settings for page content and display in the form editor')\n\nexport function govukFieldValueIsString(\n govukField: GovukField\n): govukField is GovukStringField {\n return [\n 'question',\n 'hintText',\n 'shortDescription',\n 'autoCompleteOptions',\n 'classes',\n 'prefix',\n 'suffix'\n ].includes(`${govukField.name}`)\n}\n\nexport function govukFieldIsChecked(\n govukField: GovukField\n): govukField is GovukFieldQuestionOptional | GovukFieldUsePostcodeLookup {\n if (\n govukField.name !== 'questionOptional' &&\n govukField.name !== 'usePostcodeLookup'\n ) {\n return false\n }\n const checkedValue = govukField.items?.[0].checked\n return typeof checkedValue === 'boolean'\n}\n\n// A list of allowed template funtions for use within error message templates\nexport const allowedErrorTemplateFunctions = ['lowerFirst', 'capitalise']\n"],"mappings":"AAAA,OAAOA,GAAG,MAAiD,KAAK;AAEhE,SAASC,aAAa;AACtB,SACEC,0BAA0B,EAC1BC,0BAA0B;AAa5B,WAAYC,oBAAoB,0BAApBA,oBAAoB;EAApBA,oBAAoB;EAApBA,oBAAoB;EAApBA,oBAAoB;EAApBA,oBAA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AmBA,CACjCF,UAAsB,EACkD;EACxE,IACEA,UAAU,CAACrC,IAAI,KAAK,kBAAkB,IACtCqC,UAAU,CAACrC,IAAI,KAAK,mBAAmB,EACvC;IACA,OAAO,KAAK;EACd;EACA,MAAMwC,YAAY,GAAGH,UAAU,CAAClH,KAAK,GAAG,CAAC,CAAC,CAACsH,OAAO;EAClD,OAAO,OAAOD,YAAY,KAAK,SAAS;AAC1C;;AAEA;AACA,OAAO,MAAME,6BAA6B,GAAG,CAAC,YAAY,EAAE,YAAY,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["Joi","ComponentType","MAX_NUMBER_OF_REPEAT_ITEMS","MIN_NUMBER_OF_REPEAT_ITEMS","QuestionTypeSubGroup","pageTypeSchema","string","required","valid","description","questionTypeSchema","WrittenAnswerSubGroup","DateSubGroup","LocationSubGroup","UkAddressField","TelephoneNumberField","FileUploadField","EmailAddressField","DeclarationField","ListSubGroup","YesNoField","CheckboxesField","RadiosField","AutocompleteField","questionTypeFullSchema","TextField","MultilineTextField","NumberField","DatePartsField","MonthYearField","SelectField","EastingNorthingField","OsGridRefField","NationalGridFieldNumberField","LatLongField","writtenAnswerSubSchema","dateSubSchema","listSubSchema","locationSubSchema","nameSchema","trim","questionSchema","hintTextSchema","optional","allow","instructionTextSchema","questionOptionalSchema","listForQuestionSchema","listItemCountSchema","number","listItemsDataSchema","exactFilesSchema","empty","integer","min","max","minFilesSchema","maxFilesSchema","fileTypesSchema","array","items","single","default","documentTypesSchema","imageTypesSchema","tabularDataTypesSchema","enhancedActionSchema","radioIdSchema","radioTextSchema","radioHintSchema","radioValueSchema","shortDescriptionSchema","pageHeadingAndGuidanceSchema","pageHeadingSchema","guidanceTextSchema","exitPageSchema","boolean","repeaterSchema","minItemsSchema","maxItemsSchema","questionSetNameSchema","needDeclarationSchema","declarationTextSchema","minSchema","maxSchema","minLengthSchema","maxLengthSchema","maxFutureSchema","maxPastSchema","precisionSchema","prefixSchema","regexSchema","rowsSchema","suffixSchema","classesSchema","jsEnabledSchema","usePostcodeLookupSchema","customValidator","extend","joi","type","base","messages","coerce","from","method","value","helpers","rowSeparatorRule","schema","$_getRule","colSeparatorRule","keysRule","rowSeparator","args","rows","split","map","v","filter","Boolean","colSeparator","keys","coercedValue","row","reduce","acc","col","idx","_err","console","error","errors","rules","convert","alias","$_addRule","name","ref","assert","RegExp","message","Array","isArray","every","k","autoCompleteOptionsSchema","dsv","object","text","disallow","parent","unique","ignoreUndefined","questionDetailsFullSchema","formEditorInputPageKeys","pageType","questionType","formEditorInputPageSchema","formEditorInputheckAnswersSettingsKeys","declarationText","formEditorInputCheckAnswersSettingSchema","formEditorInputQuestionKeys","question","shortDescription","hintText","questionOptional","formEditorInputQuestionSchema","formEditorInputPageSettingsKeys","pageHeadingAndGuidance","pageHeading","guidanceText","formEditorInputPageSettingsSchema","govukFieldValueIsString","govukField","includes","govukFieldIsChecked","checkedValue","checked","allowedErrorTemplateFunctions"],"sources":["../../../../src/form/form-editor/index.ts"],"sourcesContent":["import Joi, { type ArraySchema, type GetRuleOptions } from 'joi'\n\nimport { ComponentType } from '~/src/components/enums.js'\nimport {\n MAX_NUMBER_OF_REPEAT_ITEMS,\n MIN_NUMBER_OF_REPEAT_ITEMS\n} from '~/src/form/form-definition/index.js'\nimport {\n type FormEditorInputCheckAnswersSettings,\n type FormEditorInputPage,\n type FormEditorInputPageSettings,\n type FormEditorInputQuestion,\n type GovukField,\n type GovukFieldQuestionOptional,\n type GovukFieldUsePostcodeLookup,\n type GovukStringField\n} from '~/src/form/form-editor/types.js'\n\nexport enum QuestionTypeSubGroup {\n WrittenAnswerSubGroup = 'writtenAnswerSub',\n DateSubGroup = 'dateSub',\n ListSubGroup = 'listSub',\n LocationSubGroup = 'locationSub'\n}\n\nexport const pageTypeSchema = Joi.string()\n .required()\n .valid('question', 'guidance')\n .description('Type of page - either a question page or guidance page')\n\nexport const questionTypeSchema = Joi.string()\n .required()\n .valid(\n QuestionTypeSubGroup.WrittenAnswerSubGroup,\n QuestionTypeSubGroup.DateSubGroup,\n QuestionTypeSubGroup.LocationSubGroup,\n ComponentType.UkAddressField,\n ComponentType.TelephoneNumberField,\n ComponentType.FileUploadField,\n ComponentType.EmailAddressField,\n ComponentType.DeclarationField,\n QuestionTypeSubGroup.ListSubGroup,\n ComponentType.YesNoField,\n ComponentType.CheckboxesField,\n ComponentType.RadiosField,\n ComponentType.AutocompleteField\n )\n .description('The high-level type of question, including grouped types')\n\nexport const questionTypeFullSchema = Joi.string()\n .required()\n .valid(\n ComponentType.TextField,\n ComponentType.MultilineTextField,\n ComponentType.NumberField,\n ComponentType.DatePartsField,\n ComponentType.MonthYearField,\n ComponentType.UkAddressField,\n ComponentType.TelephoneNumberField,\n ComponentType.FileUploadField,\n ComponentType.EmailAddressField,\n ComponentType.DeclarationField,\n ComponentType.YesNoField,\n ComponentType.CheckboxesField,\n ComponentType.RadiosField,\n ComponentType.AutocompleteField,\n ComponentType.SelectField,\n ComponentType.EastingNorthingField,\n ComponentType.OsGridRefField,\n ComponentType.NationalGridFieldNumberField,\n ComponentType.LatLongField\n )\n .description('The specific component type to use for this question')\n\nexport const writtenAnswerSubSchema = Joi.string()\n .required()\n .valid(\n ComponentType.TextField,\n ComponentType.MultilineTextField,\n ComponentType.NumberField\n )\n .description('Subtype for written answer questions')\n\nexport const dateSubSchema = Joi.string()\n .required()\n .valid(ComponentType.DatePartsField, ComponentType.MonthYearField)\n .description('Subtype for date-related questions')\n\nexport const listSubSchema = Joi.string()\n .required()\n .valid(\n ComponentType.YesNoField,\n ComponentType.CheckboxesField,\n ComponentType.RadiosField,\n ComponentType.AutocompleteField,\n ComponentType.SelectField\n )\n .description('Subtype for list-related questions')\n\nexport const locationSubSchema = Joi.string()\n .required()\n .valid(\n ComponentType.EastingNorthingField,\n ComponentType.OsGridRefField,\n ComponentType.NationalGridFieldNumberField,\n ComponentType.LatLongField\n )\n .description('Subtype for location-related questions')\n\nexport const nameSchema = Joi.string()\n .trim()\n .required()\n .description('Unique identifier for the field')\n\nexport const questionSchema = Joi.string()\n .trim()\n .required()\n .description('The question text displayed to the user')\n\nexport const hintTextSchema = Joi.string()\n .trim()\n .optional()\n .allow('')\n .description('Optional guidance text displayed below the question')\n\nexport const instructionTextSchema = Joi.string()\n .trim()\n .optional()\n .allow('')\n .description(\n 'Optional instruction text with markdown support to help users answer the question'\n )\n\nexport const questionOptionalSchema = Joi.string()\n .trim()\n .optional()\n .valid('', 'true')\n .description(\n 'Indicates whether a question is optional. Empty string or \"true\" values are accepted.'\n )\n\nexport const listForQuestionSchema = Joi.string()\n .trim()\n .optional()\n .allow('')\n .description('Unique identifier for the list used by the field')\n\nexport const listItemCountSchema = Joi.number()\n .optional()\n .description('Number of list items in the list used by the field')\n\nexport const listItemsDataSchema = Joi.string()\n .allow('')\n .description('List items in JSON format, such as for radios or checkboxes.')\n\nexport const exactFilesSchema = Joi.number()\n .empty('')\n .integer()\n .min(1)\n .max(25)\n .description(\n 'Specifies the exact number of files required for upload. Must be between 1 and 25.'\n )\n\nexport const minFilesSchema = Joi.number()\n .empty('')\n .integer()\n .min(1)\n .max(25)\n .description(\n 'Minimum number of files required for upload. Must be between 1 and 25.'\n )\n\nexport const maxFilesSchema = Joi.number()\n .empty('')\n .integer()\n .min(1)\n .max(25)\n .description(\n 'Maximum number of files allowed for upload. Must be between 1 and 25.'\n )\n\nexport const fileTypesSchema = Joi.array()\n .items(Joi.string())\n .single()\n .empty(null)\n .default([])\n .description(\n 'Array of allowed file types. Can be provided as a single value or an array.'\n )\n\nexport const documentTypesSchema = Joi.array()\n .items(Joi.string())\n .single()\n .empty(null)\n .default([])\n .description(\n 'Array of allowed document types. Can be provided as a single value or an array.'\n )\n\nexport const imageTypesSchema = Joi.array()\n .items(Joi.string())\n .single()\n .empty(null)\n .default([])\n .description(\n 'Array of allowed image types. Can be provided as a single value or an array.'\n )\n\nexport const tabularDataTypesSchema = Joi.array()\n .items(Joi.string())\n .single()\n .empty(null)\n .default([])\n\nexport const enhancedActionSchema = Joi.string()\n .trim()\n .optional()\n .allow('')\n .description('Action field that can include enhanced functionality')\n\nexport const radioIdSchema = Joi.string()\n .trim()\n .optional()\n .allow('')\n .description('Unique identifier for radio options')\n\nexport const radioTextSchema = Joi.string()\n .trim()\n .required()\n .description('The visible text shown next to radio options')\n\nexport const radioHintSchema = Joi.string()\n .trim()\n .optional()\n .allow('')\n .description(\n 'Optional hint text displayed with radio buttons to provide additional guidance'\n )\n\nexport const radioValueSchema = Joi.string()\n .trim()\n .optional()\n .allow('')\n .description(\n 'Array of allowed tabular data types. Can be provided as a single value or an array.'\n )\n\nexport const shortDescriptionSchema = Joi.string()\n .trim()\n .required()\n .description('Brief description of the question for internal use')\n\nexport const pageHeadingAndGuidanceSchema = Joi.string()\n .trim()\n .optional()\n .description('Combined heading and guidance for the page')\n\nexport const pageHeadingSchema = Joi.string()\n .trim()\n .required()\n .description('Main heading displayed at the top of the page')\n\nexport const guidanceTextSchema = Joi.string()\n .trim()\n .description('Guidance text to assist users in completing the page')\n\nexport const exitPageSchema = Joi.boolean()\n .default(false)\n .optional()\n .description('Determines if page is set as an Exit Page')\n\nexport const repeaterSchema = Joi.string()\n .trim()\n .optional()\n .description(\n 'Combined min/max items and question set name for the repeater page'\n )\n\nexport const minItemsSchema = Joi.number()\n .empty('')\n .min(MIN_NUMBER_OF_REPEAT_ITEMS)\n .description('The minimum number of repeater items')\n\nexport const maxItemsSchema = Joi.number()\n .empty('')\n .max(MAX_NUMBER_OF_REPEAT_ITEMS)\n .description('The maximum number of repeater items')\n\nexport const questionSetNameSchema = Joi.string()\n .trim()\n .description('The repeater question set name')\n\nexport const needDeclarationSchema = Joi.string()\n .trim()\n .required()\n .description('Whether a declaration is needed')\n\nexport const declarationTextSchema = Joi.string()\n .trim()\n .required()\n .description('Text of the declaration that users must agree to')\n\nexport const minSchema = Joi.number()\n .empty('')\n .integer()\n .description('Minimum value for numeric inputs')\n\nexport const maxSchema = Joi.number()\n .empty('')\n .integer()\n .description('Maximum value for numeric inputs')\n\nexport const minLengthSchema = Joi.number()\n .empty('')\n .integer()\n .min(1)\n .description('Minimum character length for text inputs')\n\nexport const maxLengthSchema = Joi.number()\n .empty('')\n .integer()\n .min(1)\n .description('Maximum character length for text inputs')\n\nexport const maxFutureSchema = Joi.number()\n .empty('')\n .integer()\n .min(0)\n .description('Maximum days in the future allowed for date inputs')\n\nexport const maxPastSchema = Joi.number()\n .empty('')\n .integer()\n .min(0)\n .description('Maximum days in the past allowed for date inputs')\n\nexport const precisionSchema = Joi.number()\n .empty('')\n .integer()\n .min(0)\n .description('Decimal precision for numeric inputs')\n\nexport const prefixSchema = Joi.string()\n .trim()\n .optional()\n .allow('')\n .description('Text to display before the input (e.g., £)')\n\nexport const regexSchema = Joi.string()\n .optional()\n .allow('')\n .description('Regular expression pattern for validation')\n\nexport const rowsSchema = Joi.number()\n .empty('')\n .integer()\n .min(1)\n .description('Number of rows for multiline text fields')\n\nexport const suffixSchema = Joi.string()\n .trim()\n .optional()\n .allow('')\n .description('Text to display after the input (e.g., kg)')\n\nexport const classesSchema = Joi.string()\n .trim()\n .optional()\n .allow('')\n .description('Custom CSS classes to apply to the component')\n\nexport const jsEnabledSchema = Joi.string()\n .trim()\n .optional()\n .allow('false', 'true')\n .description('Flag to show if Javascript is enabled or not')\n\nexport const usePostcodeLookupSchema = Joi.string()\n .trim()\n .optional()\n .valid('', 'true')\n .description(\n 'Indicates whether a UK address component supports postcode lookup. Empty string or \"true\" values are accepted.'\n )\n\ntype GenericRuleOptions<K extends string, T> = Omit<GetRuleOptions, 'args'> & {\n args: Record<K, T>\n}\n\ninterface DSLSchema<TSchema = Record<string, unknown>[]>\n extends ArraySchema<TSchema> {\n rowSeparator: (rowSep: string | RegExp) => DSLSchema<TSchema>\n row: (rowSep: string | RegExp) => DSLSchema<TSchema>\n colSeparator: (colSep: string | RegExp) => DSLSchema<TSchema>\n col: (colSep: string | RegExp) => DSLSchema<TSchema>\n keys: (keys: string[]) => DSLSchema<TSchema>\n}\n\ninterface CustomValidator extends Joi.Root {\n dsv<TSchema>(): DSLSchema<TSchema>\n}\n\nexport const customValidator = Joi.extend((joi: Joi.Root) => {\n return {\n type: 'dsv',\n base: joi.array(),\n messages: {\n 'dsv.invalid': 'Invalid parse string'\n },\n coerce: {\n from: 'string',\n method(value: string, helpers) {\n try {\n // Only called when prefs.convert is true\n // Rules\n const rowSeparatorRule = helpers.schema.$_getRule('rowSeparator') as\n | undefined\n | GenericRuleOptions<'rowSeparator', string | RegExp>\n const colSeparatorRule = helpers.schema.$_getRule('colSeparator') as\n | undefined\n | GenericRuleOptions<'colSeparator', string | RegExp>\n const keysRule = helpers.schema.$_getRule('keys') as\n | undefined\n | GenericRuleOptions<'keys', string[]>\n\n // Rows\n const rowSeparator = rowSeparatorRule?.args.rowSeparator ?? /\\r?\\n/\n const rows = value\n .split(rowSeparator)\n .map((v) => v.trim())\n .filter(Boolean)\n\n // Columns\n const colSeparator = colSeparatorRule?.args.colSeparator ?? ','\n const keys = keysRule?.args.keys ?? ['key', 'value']\n\n const coercedValue = rows.map((row) => {\n return row\n .split(colSeparator)\n .reduce<Record<string, string>>((acc, col, idx) => {\n return {\n ...acc,\n [keys[idx]]: col.trim()\n }\n }, {})\n })\n return { value: coercedValue }\n } catch (_err) {\n // eslint-disable-next-line no-console\n console.error(_err)\n return { value, errors: [helpers.error('dsv.invalid')] }\n }\n }\n },\n rules: {\n rowSeparator: {\n convert: true,\n alias: 'row',\n method(rowSeparator: string) {\n return this.$_addRule({\n name: 'rowSeparator',\n args: { rowSeparator }\n })\n },\n args: [\n {\n name: 'rowSeparator',\n ref: true,\n assert: (value) =>\n typeof value === 'string' || value instanceof RegExp,\n message: 'must be a string or regex'\n }\n ]\n },\n colSeparator: {\n convert: true,\n alias: 'col',\n method(colSeparator: string) {\n return this.$_addRule({\n name: 'colSeparator',\n args: { colSeparator }\n })\n },\n args: [\n {\n name: 'colSeparator',\n ref: true,\n assert: (value) =>\n typeof value === 'string' || value instanceof RegExp,\n message: 'must be a string or regex'\n }\n ]\n },\n keys: {\n convert: true,\n method(keys: string[]) {\n return this.$_addRule({ name: 'keys', args: { keys } })\n },\n args: [\n {\n name: 'keys',\n ref: true,\n assert: (value) =>\n Array.isArray(value) && value.every((k) => typeof k === 'string'),\n message: 'must be an array of strings'\n }\n ]\n }\n }\n }\n}) as CustomValidator\n\nexport const autoCompleteOptionsSchema = customValidator\n .dsv<{ text: string; value: string }[]>()\n .row(/\\r?\\n/)\n .col(':')\n .keys(['text', 'value'])\n .items(\n customValidator.object({\n text: customValidator.string().min(1).disallow('').required(),\n value: customValidator\n .string()\n .default((parent: { text: string; value?: string }) => parent.text)\n .min(1)\n .disallow('')\n })\n )\n .min(1)\n .unique('text')\n .unique('value', { ignoreUndefined: true })\n .required()\n\nexport const questionDetailsFullSchema = {\n autoCompleteOptionsSchema,\n classesSchema,\n declarationTextSchema,\n documentTypesSchema,\n enhancedActionSchema,\n exactFilesSchema,\n fileTypesSchema,\n hintTextSchema,\n imageTypesSchema,\n instructionTextSchema,\n jsEnabledSchema,\n listForQuestionSchema,\n listItemCountSchema,\n listItemsDataSchema,\n maxFilesSchema,\n maxFutureSchema,\n maxLengthSchema,\n maxPastSchema,\n maxSchema,\n minFilesSchema,\n minLengthSchema,\n minSchema,\n nameSchema,\n precisionSchema,\n prefixSchema,\n questionOptionalSchema,\n questionSchema,\n questionTypeFullSchema,\n radioHintSchema,\n radioIdSchema,\n radioTextSchema,\n radioValueSchema,\n regexSchema,\n rowsSchema,\n shortDescriptionSchema,\n suffixSchema,\n tabularDataTypesSchema,\n usePostcodeLookupSchema\n}\n\nexport const formEditorInputPageKeys = {\n pageType: pageTypeSchema,\n questionType: questionTypeSchema\n}\n\n/**\n * Joi schema for `FormEditorInputPage` interface\n * @see {@link FormEditorInputPage}\n */\nexport const formEditorInputPageSchema = Joi.object<FormEditorInputPage>()\n .keys(formEditorInputPageKeys)\n .required()\n .description('Input schema for creating a new page in the form editor')\n\nexport const formEditorInputheckAnswersSettingsKeys = {\n declarationText: shortDescriptionSchema\n}\n\n/**\n * Joi schema for `FormEditorInputCheckAnswersSettings` interface\n * @see {@link FormEditorInputCheckAnswersSettings}\n */\nexport const formEditorInputCheckAnswersSettingSchema =\n Joi.object<FormEditorInputCheckAnswersSettings>()\n .keys(formEditorInputheckAnswersSettingsKeys)\n .required()\n .description('Configuration for the check-answers page')\n\nexport const formEditorInputQuestionKeys = {\n question: questionSchema,\n shortDescription: shortDescriptionSchema,\n hintText: hintTextSchema,\n questionOptional: questionOptionalSchema\n}\n\n/**\n * Joi schema for `FormEditorInputQuestion` interface\n * @see {@link FormEditorInputQuestion}\n */\nexport const formEditorInputQuestionSchema =\n Joi.object<FormEditorInputQuestion>()\n .keys(formEditorInputQuestionKeys)\n .required()\n .description(\n 'Input schema for creating or updating a question in the form editor'\n )\n\nexport const formEditorInputPageSettingsKeys = {\n pageHeadingAndGuidance: pageHeadingAndGuidanceSchema,\n pageHeading: pageHeadingSchema,\n guidanceText: guidanceTextSchema\n}\n\n/**\n * Joi schema for `FormEditorInputPageSettings` interface\n * @see {@link FormEditorInputPageSettings}\n */\nexport const formEditorInputPageSettingsSchema =\n Joi.object<FormEditorInputPageSettings>()\n .keys(formEditorInputPageSettingsKeys)\n .required()\n .description('Settings for page content and display in the form editor')\n\nexport function govukFieldValueIsString(\n govukField: GovukField\n): govukField is GovukStringField {\n return [\n 'question',\n 'hintText',\n 'shortDescription',\n 'autoCompleteOptions',\n 'classes',\n 'prefix',\n 'suffix'\n ].includes(`${govukField.name}`)\n}\n\nexport function govukFieldIsChecked(\n govukField: GovukField\n): govukField is GovukFieldQuestionOptional | GovukFieldUsePostcodeLookup {\n if (\n govukField.name !== 'questionOptional' &&\n govukField.name !== 'usePostcodeLookup'\n ) {\n return false\n }\n const checkedValue = govukField.items?.[0].checked\n return typeof checkedValue === 'boolean'\n}\n\n// A list of allowed template funtions for use within error message templates\nexport const allowedErrorTemplateFunctions = ['lowerFirst', 'capitalise']\n"],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AC,CACVE,WAAW,CAAC,0DAA0D,CAAC;AAE5E,OAAO,SAASoK,uBAAuBA,CACrCC,UAAsB,EACU;EAChC,OAAO,CACL,UAAU,EACV,UAAU,EACV,kBAAkB,EAClB,qBAAqB,EACrB,SAAS,EACT,QAAQ,EACR,QAAQ,CACT,CAACC,QAAQ,CAAC,GAAGD,UAAU,CAACrC,IAAI,EAAE,CAAC;AAClC;AAEA,OAAO,SAASuC,mBAAmBA,CACjCF,UAAsB,EACkD;EACxE,IACEA,UAAU,CAACrC,IAAI,KAAK,kBAAkB,IACtCqC,UAAU,CAACrC,IAAI,KAAK,mBAAmB,EACvC;IACA,OAAO,KAAK;EACd;EACA,MAAMwC,YAAY,GAAGH,UAAU,CAAClH,KAAK,GAAG,CAAC,CAAC,CAACsH,OAAO;EAClD,OAAO,OAAOD,YAAY,KAAK,SAAS;AAC1C;;AAEA;AACA,OAAO,MAAME,6BAA6B,GAAG,CAAC,YAAY,EAAE,YAAY,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../../../../../src/form/form-editor/macros/types.ts"],"sourcesContent":["import { type ComponentType } from '~/src/components/enums.js'\nimport {\n type DefaultComponent,\n type GovukFieldset\n} from '~/src/form/form-editor/preview/types.js'\nimport {\n type DateItem,\n type GovukField,\n type ListItemReadonly\n} from '~/src/form/form-editor/types.js'\n\nexport interface AppPreviewErrorPanelMacroErrorTemplate {\n advancedSettingsErrors: []\n baseErrors: { template: unknown; type: string }[]\n}\n\nexport interface AppPreviewErrorPanelMacro {\n errorTemplates: AppPreviewErrorPanelMacroErrorTemplate\n fieldDetails: {\n extraFields: GovukField[]\n basePageFields: GovukField[]\n }\n questionType: ComponentType\n}\n\nexport interface AppPreviewPanelTabsMacro {\n questionType: ComponentType\n previewPageUrl: string\n previewErrorsUrl: string\n errorTemplates: AppPreviewErrorPanelMacroErrorTemplate\n extraFields: GovukField[]\n basePageFields: GovukField[]\n}\n\nexport interface SelectAfterInput {\n afterInput: { html: string }\n}\nexport interface RadioAndCheckboxAfterInputs {\n afterInputs: { html: string }\n}\n\n// GDS components - Select uses afterInput, while Radio uses afterInputs\nexport type FormGroupAfterInput = SelectAfterInput | RadioAndCheckboxAfterInputs\n\nexport interface QuestionBaseModel {\n id?: string\n name?: string\n content?: string\n attributes?: Record<string, string>\n label?: DefaultComponent\n hint?: DefaultComponent\n fieldset?: GovukFieldset\n readonly items?: ListItemReadonly[] | DateItem[]\n text?: string\n formGroup?: FormGroupAfterInput\n type?: 'text' | 'number' | 'boolean'\n classes?: string\n previewClasses?: string\n prefix?: { text: string }\n suffix?: { text: string }\n}\n\nexport interface AppPreviewPanelMacro extends AppPreviewPanelTabsMacro {\n model: QuestionBaseModel\n}\n\nexport interface PagePreviewComponent {\n model: QuestionBaseModel\n questionType: ComponentType\n}\n\nexport interface PagePreviewPanelMacro {\n readonly pageTitle: {\n text: string\n classes: string\n }\n readonly guidance: {\n text: string\n classes: string\n }\n readonly components: PagePreviewComponent[]\n readonly sectionTitle?: {\n text: string\n classes: string\n }\n}\n\nexport interface SummaryRowActionItem {\n href: string\n text: string\n visuallyHiddenText: string\n}\n\nexport interface SummaryRow {\n key: { text: string }\n value: { text: string }\n actions: {\n items: SummaryRowActionItem[]\n }\n}\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../../../../src/form/form-editor/macros/types.ts"],"sourcesContent":["import { type ComponentType } from '~/src/components/enums.js'\nimport {\n type DefaultComponent,\n type GovukFieldset\n} from '~/src/form/form-editor/preview/types.js'\nimport {\n type DateItem,\n type GovukField,\n type ListItemReadonly\n} from '~/src/form/form-editor/types.js'\n\nexport interface AppPreviewErrorPanelMacroErrorTemplate {\n advancedSettingsErrors: []\n baseErrors: { template: unknown; type: string }[]\n}\n\nexport interface AppPreviewErrorPanelMacro {\n errorTemplates: AppPreviewErrorPanelMacroErrorTemplate\n fieldDetails: {\n extraFields: GovukField[]\n basePageFields: GovukField[]\n }\n questionType: ComponentType\n}\n\nexport interface AppPreviewPanelTabsMacro {\n questionType: ComponentType\n previewPageUrl: string\n previewErrorsUrl: string\n errorTemplates: AppPreviewErrorPanelMacroErrorTemplate\n extraFields: GovukField[]\n basePageFields: GovukField[]\n}\n\nexport interface SelectAfterInput {\n afterInput: { html: string }\n}\nexport interface RadioAndCheckboxAfterInputs {\n afterInputs: { html: string }\n}\n\n// GDS components - Select uses afterInput, while Radio uses afterInputs\nexport type FormGroupAfterInput = SelectAfterInput | RadioAndCheckboxAfterInputs\n\nexport interface QuestionBaseModel {\n id?: string\n name?: string\n content?: string\n attributes?: Record<string, string>\n label?: DefaultComponent\n hint?: DefaultComponent\n fieldset?: GovukFieldset\n readonly items?: ListItemReadonly[] | DateItem[]\n text?: string\n formGroup?: FormGroupAfterInput\n type?: 'text' | 'number' | 'boolean'\n classes?: string\n previewClasses?: string\n prefix?: { text: string }\n suffix?: { text: string }\n}\n\nexport interface DeclarationModel extends QuestionBaseModel {\n declaration?: {\n text?: string\n classes?: string\n }\n}\n\nexport interface AppPreviewPanelMacro extends AppPreviewPanelTabsMacro {\n model: QuestionBaseModel\n}\n\nexport interface PagePreviewComponent {\n model: QuestionBaseModel\n questionType: ComponentType\n}\n\nexport interface PagePreviewPanelMacro {\n readonly pageTitle: {\n text: string\n classes: string\n }\n readonly guidance: {\n text: string\n classes: string\n }\n readonly components: PagePreviewComponent[]\n readonly sectionTitle?: {\n text: string\n classes: string\n }\n}\n\nexport interface SummaryRowActionItem {\n href: string\n text: string\n visuallyHiddenText: string\n}\n\nexport interface SummaryRow {\n key: { text: string }\n value: { text: string }\n actions: {\n items: SummaryRowActionItem[]\n }\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { ComponentType } from "../../../components/enums.js";
|
|
2
|
+
import { HIGHLIGHT_CLASS } from "./constants.js";
|
|
3
|
+
import { PreviewComponent } from "./preview.js";
|
|
4
|
+
import { Question, QuestionComponentElements } from "./question.js";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @implements {QuestionElements}
|
|
8
|
+
*/
|
|
9
|
+
export class DeclarationComponentPreviewElements extends QuestionComponentElements {
|
|
10
|
+
/**
|
|
11
|
+
* @param {DeclarationFieldComponent} component
|
|
12
|
+
*/
|
|
13
|
+
constructor(component) {
|
|
14
|
+
super(component);
|
|
15
|
+
this._declarationText = component.content;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @protected
|
|
20
|
+
* @returns {DeclarationSettings}
|
|
21
|
+
*/
|
|
22
|
+
_getValues() {
|
|
23
|
+
return {
|
|
24
|
+
...super._getValues(),
|
|
25
|
+
declarationText: this._declarationText
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export class DeclarationQuestion extends Question {
|
|
30
|
+
/**
|
|
31
|
+
* @type {ComponentType}
|
|
32
|
+
*/
|
|
33
|
+
componentType = ComponentType.DeclarationField;
|
|
34
|
+
/**
|
|
35
|
+
* @type {string}
|
|
36
|
+
* @protected
|
|
37
|
+
*/
|
|
38
|
+
_questionTemplate = PreviewComponent.PATH + 'declarationfield.njk';
|
|
39
|
+
_fieldName = 'DeclarationField';
|
|
40
|
+
_declarationText = '';
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* @param {DeclarationElements} htmlElements
|
|
44
|
+
* @param {QuestionRenderer} questionRenderer
|
|
45
|
+
*/
|
|
46
|
+
constructor(htmlElements, questionRenderer) {
|
|
47
|
+
super(htmlElements, questionRenderer);
|
|
48
|
+
this._declarationText = htmlElements.values.declarationText;
|
|
49
|
+
}
|
|
50
|
+
get declarationText() {
|
|
51
|
+
return this._declarationText;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* @param {string} val
|
|
56
|
+
*/
|
|
57
|
+
set declarationText(val) {
|
|
58
|
+
this._declarationText = val;
|
|
59
|
+
this.render();
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* @protected
|
|
64
|
+
* @returns {DeclarationModel}
|
|
65
|
+
*/
|
|
66
|
+
_renderInput() {
|
|
67
|
+
return {
|
|
68
|
+
...super._renderInput(),
|
|
69
|
+
declaration: {
|
|
70
|
+
text: this._declarationText ? this._declarationText : 'Declaration text',
|
|
71
|
+
classes: this._highlight === 'declarationText' ? HIGHLIGHT_CLASS : ''
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* @import { DeclarationSettings, DeclarationElements, QuestionElements, QuestionRenderer } from '~/src/form/form-editor/preview/types.js'
|
|
79
|
+
* @import { DeclarationModel } from '~/src/form/form-editor/macros/types.js'
|
|
80
|
+
* @import { DeclarationFieldComponent } from '~/src/components/types.js'
|
|
81
|
+
*/
|
|
82
|
+
//# sourceMappingURL=declaration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"declaration.js","names":["ComponentType","HIGHLIGHT_CLASS","PreviewComponent","Question","QuestionComponentElements","DeclarationComponentPreviewElements","constructor","component","_declarationText","content","_getValues","declarationText","DeclarationQuestion","componentType","DeclarationField","_questionTemplate","PATH","_fieldName","htmlElements","questionRenderer","values","val","render","_renderInput","declaration","text","classes","_highlight"],"sources":["../../../../../src/form/form-editor/preview/declaration.js"],"sourcesContent":["import { ComponentType } from '~/src/components/enums.js'\nimport { HIGHLIGHT_CLASS } from '~/src/form/form-editor/preview/constants.js'\nimport { PreviewComponent } from '~/src/form/form-editor/preview/preview.js'\nimport {\n Question,\n QuestionComponentElements\n} from '~/src/form/form-editor/preview/question.js'\n\n/**\n * @implements {QuestionElements}\n */\nexport class DeclarationComponentPreviewElements extends QuestionComponentElements {\n /**\n * @param {DeclarationFieldComponent} component\n */\n constructor(component) {\n super(component)\n this._declarationText = component.content\n }\n\n /**\n * @protected\n * @returns {DeclarationSettings}\n */\n _getValues() {\n return {\n ...super._getValues(),\n declarationText: this._declarationText\n }\n }\n}\n\nexport class DeclarationQuestion extends Question {\n /**\n * @type {ComponentType}\n */\n componentType = ComponentType.DeclarationField\n /**\n * @type {string}\n * @protected\n */\n _questionTemplate = PreviewComponent.PATH + 'declarationfield.njk'\n _fieldName = 'DeclarationField'\n _declarationText = ''\n\n /**\n * @param {DeclarationElements} htmlElements\n * @param {QuestionRenderer} questionRenderer\n */\n constructor(htmlElements, questionRenderer) {\n super(htmlElements, questionRenderer)\n this._declarationText = htmlElements.values.declarationText\n }\n\n get declarationText() {\n return this._declarationText\n }\n\n /**\n * @param {string} val\n */\n set declarationText(val) {\n this._declarationText = val\n this.render()\n }\n\n /**\n * @protected\n * @returns {DeclarationModel}\n */\n _renderInput() {\n return {\n ...super._renderInput(),\n declaration: {\n text: this._declarationText\n ? this._declarationText\n : 'Declaration text',\n classes: this._highlight === 'declarationText' ? HIGHLIGHT_CLASS : ''\n }\n }\n }\n}\n\n/**\n * @import { DeclarationSettings, DeclarationElements, QuestionElements, QuestionRenderer } from '~/src/form/form-editor/preview/types.js'\n * @import { DeclarationModel } from '~/src/form/form-editor/macros/types.js'\n * @import { DeclarationFieldComponent } from '~/src/components/types.js'\n */\n"],"mappings":"AAAA,SAASA,aAAa;AACtB,SAASC,eAAe;AACxB,SAASC,gBAAgB;AACzB,SACEC,QAAQ,EACRC,yBAAyB;;AAG3B;AACA;AACA;AACA,OAAO,MAAMC,mCAAmC,SAASD,yBAAyB,CAAC;EACjF;AACF;AACA;EACEE,WAAWA,CAACC,SAAS,EAAE;IACrB,KAAK,CAACA,SAAS,CAAC;IAChB,IAAI,CAACC,gBAAgB,GAAGD,SAAS,CAACE,OAAO;EAC3C;;EAEA;AACF;AACA;AACA;EACEC,UAAUA,CAAA,EAAG;IACX,OAAO;MACL,GAAG,KAAK,CAACA,UAAU,CAAC,CAAC;MACrBC,eAAe,EAAE,IAAI,CAACH;IACxB,CAAC;EACH;AACF;AAEA,OAAO,MAAMI,mBAAmB,SAAST,QAAQ,CAAC;EAChD;AACF;AACA;EACEU,aAAa,GAAGb,aAAa,CAACc,gBAAgB;EAC9C;AACF;AACA;AACA;EACEC,iBAAiB,GAAGb,gBAAgB,CAACc,IAAI,GAAG,sBAAsB;EAClEC,UAAU,GAAG,kBAAkB;EAC/BT,gBAAgB,GAAG,EAAE;;EAErB;AACF;AACA;AACA;EACEF,WAAWA,CAACY,YAAY,EAAEC,gBAAgB,EAAE;IAC1C,KAAK,CAACD,YAAY,EAAEC,gBAAgB,CAAC;IACrC,IAAI,CAACX,gBAAgB,GAAGU,YAAY,CAACE,MAAM,CAACT,eAAe;EAC7D;EAEA,IAAIA,eAAeA,CAAA,EAAG;IACpB,OAAO,IAAI,CAACH,gBAAgB;EAC9B;;EAEA;AACF;AACA;EACE,IAAIG,eAAeA,CAACU,GAAG,EAAE;IACvB,IAAI,CAACb,gBAAgB,GAAGa,GAAG;IAC3B,IAAI,CAACC,MAAM,CAAC,CAAC;EACf;;EAEA;AACF;AACA;AACA;EACEC,YAAYA,CAAA,EAAG;IACb,OAAO;MACL,GAAG,KAAK,CAACA,YAAY,CAAC,CAAC;MACvBC,WAAW,EAAE;QACXC,IAAI,EAAE,IAAI,CAACjB,gBAAgB,GACvB,IAAI,CAACA,gBAAgB,GACrB,kBAAkB;QACtBkB,OAAO,EAAE,IAAI,CAACC,UAAU,KAAK,iBAAiB,GAAG1B,eAAe,GAAG;MACrE;IACF,CAAC;EACH;AACF;;AAEA;AACA;AACA;AACA;AACA","ignoreList":[]}
|
|
@@ -5,6 +5,7 @@ import { CheckboxQuestion } from "./checkbox.js";
|
|
|
5
5
|
import { ComponentElements } from "./component-elements.js";
|
|
6
6
|
import { ContentElements } from "./content.js";
|
|
7
7
|
import { DateInputQuestion } from "./date-input.js";
|
|
8
|
+
import { DeclarationComponentPreviewElements, DeclarationQuestion } from "./declaration.js";
|
|
8
9
|
import { EmailAddressQuestion } from "./email-address.js";
|
|
9
10
|
import { ListComponentElements, ListQuestion, SelectComponentElements } from "./list.js";
|
|
10
11
|
import { LongAnswerQuestion } from "./long-answer.js";
|
|
@@ -42,7 +43,7 @@ const InputFieldComponentDictionary = {
|
|
|
42
43
|
[ComponentType.CheckboxesField]: CheckboxQuestion,
|
|
43
44
|
[ComponentType.SelectField]: SelectQuestion,
|
|
44
45
|
[ComponentType.YesNoField]: YesNoQuestion,
|
|
45
|
-
[ComponentType.DeclarationField]:
|
|
46
|
+
[ComponentType.DeclarationField]: DeclarationQuestion,
|
|
46
47
|
[ComponentType.FileUploadField]: SupportingEvidenceQuestion,
|
|
47
48
|
[ComponentType.EastingNorthingField]: ShortAnswerQuestion,
|
|
48
49
|
[ComponentType.OsGridRefField]: ShortAnswerQuestion,
|
|
@@ -50,6 +51,40 @@ const InputFieldComponentDictionary = {
|
|
|
50
51
|
[ComponentType.LatLongField]: ShortAnswerQuestion
|
|
51
52
|
};
|
|
52
53
|
|
|
54
|
+
/**
|
|
55
|
+
* @type {Partial<Record<ComponentType, (component: ComponentDef, definition: FormDefinition ) => QuestionElements>>}
|
|
56
|
+
*/
|
|
57
|
+
const ComponentToPreviewQuestion = {
|
|
58
|
+
[ComponentType.AutocompleteField]: (component, definition) => {
|
|
59
|
+
const componentCoerced = /** @type {AutocompleteFieldComponent} */
|
|
60
|
+
component;
|
|
61
|
+
const list = findDefinitionListFromComponent(componentCoerced, definition);
|
|
62
|
+
return new SelectComponentElements(componentCoerced, list);
|
|
63
|
+
},
|
|
64
|
+
[ComponentType.SelectField]: (component, definition) => {
|
|
65
|
+
const componentCoerced = /** @type {SelectFieldComponent} */component;
|
|
66
|
+
const list = findDefinitionListFromComponent(componentCoerced, definition);
|
|
67
|
+
return new SelectComponentElements(componentCoerced, list);
|
|
68
|
+
},
|
|
69
|
+
[ComponentType.UkAddressField]: (component, _definition) => {
|
|
70
|
+
const componentCoerced = /** @type {UkAddressFieldComponent} */component;
|
|
71
|
+
return new UkAddressComponentPreviewElements(componentCoerced);
|
|
72
|
+
},
|
|
73
|
+
[ComponentType.NumberField]: (component, _definition) => {
|
|
74
|
+
const componentCoerced = /** @type {NumberFieldComponent} */component;
|
|
75
|
+
return new NumberComponentPreviewElements(componentCoerced);
|
|
76
|
+
},
|
|
77
|
+
[ComponentType.DeclarationField]: (component, _definition) => {
|
|
78
|
+
const componentCoerced = /** @type {DeclarationFieldComponent} */
|
|
79
|
+
component;
|
|
80
|
+
return new DeclarationComponentPreviewElements(componentCoerced);
|
|
81
|
+
},
|
|
82
|
+
[ComponentType.YesNoField]: (component, _definition) => {
|
|
83
|
+
const componentCoerced = /** @type {YesNoFieldComponent} */component;
|
|
84
|
+
return new QuestionComponentElements(componentCoerced);
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
|
|
53
88
|
/**
|
|
54
89
|
* @param {QuestionRenderer} questionRenderer
|
|
55
90
|
* @param {FormDefinition} definition
|
|
@@ -61,17 +96,15 @@ export function mapComponentToPreviewQuestion(questionRenderer, definition) {
|
|
|
61
96
|
* @type {QuestionElements}
|
|
62
97
|
*/
|
|
63
98
|
let questionElements;
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
questionElements =
|
|
69
|
-
} else if (component.type === ComponentType.NumberField) {
|
|
70
|
-
questionElements = new NumberComponentPreviewElements(component);
|
|
99
|
+
|
|
100
|
+
// Look for one-to-one mapping first, then fallback if not found
|
|
101
|
+
const getQuestionElementsFunc = ComponentToPreviewQuestion[component.type];
|
|
102
|
+
if (getQuestionElementsFunc) {
|
|
103
|
+
questionElements = getQuestionElementsFunc(component, definition);
|
|
71
104
|
} else if (hasSelectionFields(component) && hasListField(component)) {
|
|
72
105
|
const list = findDefinitionListFromComponent(component, definition);
|
|
73
106
|
questionElements = new ListComponentElements(component, list);
|
|
74
|
-
} else if (hasInputField(component)
|
|
107
|
+
} else if (hasInputField(component)) {
|
|
75
108
|
questionElements = new QuestionComponentElements(component);
|
|
76
109
|
} else if (hasContentField(component)) {
|
|
77
110
|
questionElements = new ContentElements(component);
|
|
@@ -90,6 +123,6 @@ export function mapComponentToPreviewQuestion(questionRenderer, definition) {
|
|
|
90
123
|
* @import { Question } from '~/src/form/form-editor/preview/question.js'
|
|
91
124
|
* @import { PreviewComponent } from '~/src/form/form-editor/preview/preview.js'
|
|
92
125
|
* @import { FormDefinition } from '~/src/form/form-definition/types.js'
|
|
93
|
-
* @import { ComponentDef } from '~/src/components/types.js'
|
|
126
|
+
* @import { AutocompleteFieldComponent, ComponentDef, DeclarationFieldComponent, NumberFieldComponent, SelectFieldComponent, UkAddressFieldComponent, YesNoFieldComponent } from '~/src/components/types.js'
|
|
94
127
|
*/
|
|
95
128
|
//# sourceMappingURL=helpers.js.map
|