@defra/forms-model 3.0.448 → 3.0.449

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 (80) hide show
  1. package/dist/module/form/form-editor/__stubs__/preview.js +105 -0
  2. package/dist/module/form/form-editor/__stubs__/preview.js.map +1 -0
  3. package/dist/module/form/form-editor/index.js +10 -0
  4. package/dist/module/form/form-editor/index.js.map +1 -1
  5. package/dist/module/form/form-editor/preview/date-input.js +17 -0
  6. package/dist/module/form/form-editor/preview/date-input.js.map +1 -0
  7. package/dist/module/form/form-editor/preview/email-address.js +6 -0
  8. package/dist/module/form/form-editor/preview/email-address.js.map +1 -0
  9. package/dist/module/form/form-editor/preview/index.js +11 -0
  10. package/dist/module/form/form-editor/preview/index.js.map +1 -0
  11. package/dist/module/form/form-editor/preview/list-sortable.js +40 -0
  12. package/dist/module/form/form-editor/preview/list-sortable.js.map +1 -0
  13. package/dist/module/form/form-editor/preview/list.js +182 -0
  14. package/dist/module/form/form-editor/preview/list.js.map +1 -0
  15. package/dist/module/form/form-editor/preview/phone-number.js +10 -0
  16. package/dist/module/form/form-editor/preview/phone-number.js.map +1 -0
  17. package/dist/module/form/form-editor/preview/question.js +197 -0
  18. package/dist/module/form/form-editor/preview/question.js.map +1 -0
  19. package/dist/module/form/form-editor/preview/radio-sortable.js +5 -0
  20. package/dist/module/form/form-editor/preview/radio-sortable.js.map +1 -0
  21. package/dist/module/form/form-editor/preview/radio.js +5 -0
  22. package/dist/module/form/form-editor/preview/radio.js.map +1 -0
  23. package/dist/module/form/form-editor/preview/short-answer.js +3 -0
  24. package/dist/module/form/form-editor/preview/short-answer.js.map +1 -0
  25. package/dist/module/form/form-editor/preview/types.js +2 -0
  26. package/dist/module/form/form-editor/preview/types.js.map +1 -0
  27. package/dist/module/form/form-editor/preview/uk-address.js +6 -0
  28. package/dist/module/form/form-editor/preview/uk-address.js.map +1 -0
  29. package/dist/module/form/form-editor/types.js.map +1 -1
  30. package/dist/module/index.js +1 -0
  31. package/dist/module/index.js.map +1 -1
  32. package/dist/types/form/form-editor/__stubs__/preview.d.ts +72 -0
  33. package/dist/types/form/form-editor/__stubs__/preview.d.ts.map +1 -0
  34. package/dist/types/form/form-editor/index.d.ts +3 -1
  35. package/dist/types/form/form-editor/index.d.ts.map +1 -1
  36. package/dist/types/form/form-editor/preview/date-input.d.ts +10 -0
  37. package/dist/types/form/form-editor/preview/date-input.d.ts.map +1 -0
  38. package/dist/types/form/form-editor/preview/email-address.d.ts +4 -0
  39. package/dist/types/form/form-editor/preview/email-address.d.ts.map +1 -0
  40. package/dist/types/form/form-editor/preview/index.d.ts +11 -0
  41. package/dist/types/form/form-editor/preview/index.d.ts.map +1 -0
  42. package/dist/types/form/form-editor/preview/list-sortable.d.ts +17 -0
  43. package/dist/types/form/form-editor/preview/list-sortable.d.ts.map +1 -0
  44. package/dist/types/form/form-editor/preview/list.d.ts +81 -0
  45. package/dist/types/form/form-editor/preview/list.d.ts.map +1 -0
  46. package/dist/types/form/form-editor/preview/phone-number.d.ts +4 -0
  47. package/dist/types/form/form-editor/preview/phone-number.d.ts.map +1 -0
  48. package/dist/types/form/form-editor/preview/question.d.ts +119 -0
  49. package/dist/types/form/form-editor/preview/question.d.ts.map +1 -0
  50. package/dist/types/form/form-editor/preview/radio-sortable.d.ts +4 -0
  51. package/dist/types/form/form-editor/preview/radio-sortable.d.ts.map +1 -0
  52. package/dist/types/form/form-editor/preview/radio.d.ts +4 -0
  53. package/dist/types/form/form-editor/preview/radio.d.ts.map +1 -0
  54. package/dist/types/form/form-editor/preview/short-answer.d.ts +4 -0
  55. package/dist/types/form/form-editor/preview/short-answer.d.ts.map +1 -0
  56. package/dist/types/form/form-editor/preview/types.d.ts +52 -0
  57. package/dist/types/form/form-editor/preview/types.d.ts.map +1 -0
  58. package/dist/types/form/form-editor/preview/uk-address.d.ts +4 -0
  59. package/dist/types/form/form-editor/preview/uk-address.d.ts.map +1 -0
  60. package/dist/types/form/form-editor/types.d.ts +19 -5
  61. package/dist/types/form/form-editor/types.d.ts.map +1 -1
  62. package/dist/types/index.d.ts +2 -0
  63. package/dist/types/index.d.ts.map +1 -1
  64. package/package.json +2 -2
  65. package/src/form/form-editor/__stubs__/preview.js +101 -0
  66. package/src/form/form-editor/index.ts +22 -1
  67. package/src/form/form-editor/preview/date-input.js +18 -0
  68. package/src/form/form-editor/preview/email-address.js +6 -0
  69. package/src/form/form-editor/preview/index.js +10 -0
  70. package/src/form/form-editor/preview/list-sortable.js +39 -0
  71. package/src/form/form-editor/preview/list.js +202 -0
  72. package/src/form/form-editor/preview/phone-number.js +10 -0
  73. package/src/form/form-editor/preview/question.js +199 -0
  74. package/src/form/form-editor/preview/radio-sortable.js +5 -0
  75. package/src/form/form-editor/preview/radio.js +5 -0
  76. package/src/form/form-editor/preview/short-answer.js +3 -0
  77. package/src/form/form-editor/preview/types.ts +60 -0
  78. package/src/form/form-editor/preview/uk-address.js +6 -0
  79. package/src/form/form-editor/types.ts +20 -1
  80. package/src/index.ts +2 -0
@@ -0,0 +1,105 @@
1
+ /**
2
+ * @implements {QuestionRenderer}
3
+ */
4
+ export class QuestionRendererStub {
5
+ /**
6
+ * @type {jest.Mock<void, [string, QuestionBaseModel]>}
7
+ */
8
+ renderMock;
9
+
10
+ /**
11
+ * @param {jest.Mock<void, [string, QuestionBaseModel]>} renderMock
12
+ */
13
+ constructor(renderMock) {
14
+ this.renderMock = renderMock;
15
+ }
16
+
17
+ /**
18
+ * @param {string} questionTemplate
19
+ * @param {QuestionBaseModel} questionBaseModel
20
+ */
21
+ render(questionTemplate, questionBaseModel) {
22
+ this.renderMock(questionTemplate, questionBaseModel);
23
+ }
24
+
25
+ /**
26
+ * @returns {string}
27
+ * @param {string} _questionTemplate
28
+ * @param {RenderContext} _renderContext
29
+ */
30
+ static buildHTML(_questionTemplate, _renderContext) {
31
+ return '**** BUILT HTML ****';
32
+ }
33
+ }
34
+
35
+ /**
36
+ * @implements {ListElements}
37
+ */
38
+ export class QuestionPreviewElements {
39
+ /**
40
+ * @protected
41
+ */
42
+ _question = '';
43
+ /** @protected */
44
+ _hintText = '';
45
+ /** @protected */
46
+ _optional = false;
47
+ /**
48
+ * @type {string}
49
+ * @protected
50
+ */
51
+ _shortDesc = '';
52
+ /**
53
+ *
54
+ * @type {ListElement[]}
55
+ * @private
56
+ */
57
+ _items = [];
58
+ afterInputsHTML = '<div class="govuk-inset-text">No items added yet.</div>';
59
+
60
+ /**
61
+ * @param {BaseSettings} baseSettings
62
+ */
63
+ constructor({
64
+ question,
65
+ hintText,
66
+ optional,
67
+ shortDesc,
68
+ items
69
+ }) {
70
+ this._question = question;
71
+ this._hintText = hintText;
72
+ this._optional = optional;
73
+ this._shortDesc = shortDesc;
74
+ this._items = items;
75
+ }
76
+ get values() {
77
+ return {
78
+ question: this._question,
79
+ hintText: this._hintText,
80
+ optional: this._optional,
81
+ shortDesc: this._shortDesc,
82
+ items: this._items
83
+ };
84
+ }
85
+
86
+ /**
87
+ * @param {string} _value
88
+ */
89
+ setPreviewHTML(_value) {
90
+ // Not implemented for server side render
91
+ }
92
+ }
93
+ export const baseElements = /** @type {BaseSettings} */{
94
+ items: [],
95
+ optional: false,
96
+ question: 'Which quest would you like to pick?',
97
+ hintText: 'Choose one adventure that best suits you.',
98
+ shortDesc: ''
99
+ };
100
+
101
+ /**
102
+ * @import { ListElement } from '~/src/form/form-editor/types.js'
103
+ * @import { BaseSettings, ListElements, RenderContext, QuestionBaseModel, QuestionElements, QuestionRenderer } from '~/src/form/form-editor/preview/types.js'
104
+ */
105
+ //# sourceMappingURL=preview.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preview.js","names":["QuestionRendererStub","renderMock","constructor","render","questionTemplate","questionBaseModel","buildHTML","_questionTemplate","_renderContext","QuestionPreviewElements","_question","_hintText","_optional","_shortDesc","_items","afterInputsHTML","question","hintText","optional","shortDesc","items","values","setPreviewHTML","_value","baseElements"],"sources":["../../../../../src/form/form-editor/__stubs__/preview.js"],"sourcesContent":["/**\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 {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 *\n * @type {ListElement[]}\n * @private\n */\n _items = []\n\n afterInputsHTML = '<div class=\"govuk-inset-text\">No items added yet.</div>'\n\n /**\n * @param {BaseSettings} baseSettings\n */\n constructor({ question, hintText, optional, shortDesc, items }) {\n this._question = question\n this._hintText = hintText\n this._optional = optional\n this._shortDesc = shortDesc\n this._items = items\n }\n\n get values() {\n return {\n question: this._question,\n hintText: this._hintText,\n optional: this._optional,\n shortDesc: this._shortDesc,\n items: this._items\n }\n }\n\n /**\n * @param {string} _value\n */\n setPreviewHTML(_value) {\n // Not implemented for server side render\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 shortDesc: ''\n})\n\n/**\n * @import { ListElement } from '~/src/form/form-editor/types.js'\n * @import { BaseSettings, ListElements, RenderContext, QuestionBaseModel, QuestionElements, QuestionRenderer } from '~/src/form/form-editor/preview/types.js'\n */\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAO,MAAMA,oBAAoB,CAAC;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ACC,MAAM,EAAE;IACrB;EAAA;AAEJ;AAEA,OAAO,MAAMC,YAAY,GAAG,2BAA6B;EACvDJ,KAAK,EAAE,EAAE;EACTF,QAAQ,EAAE,KAAK;EACfF,QAAQ,EAAE,qCAAqC;EAC/CC,QAAQ,EAAE,2CAA2C;EACrDE,SAAS,EAAE;AACb,CAAE;;AAEF;AACA;AACA;AACA","ignoreList":[]}
@@ -241,4 +241,14 @@ export const formEditorInputPageSettingsKeys = {
241
241
  * @see {@link FormEditorInputPageSettings}
242
242
  */
243
243
  export const formEditorInputPageSettingsSchema = Joi.object().keys(formEditorInputPageSettingsKeys).required().description('Settings for page content and display in the form editor');
244
+ export function govukFieldValueIsString(govukField) {
245
+ return ['question', 'hintText', 'shortDescription'].includes(`${govukField.name}`);
246
+ }
247
+ export function govukFieldIsQuestionOptional(govukField) {
248
+ if (govukField.name !== 'questionOptional') {
249
+ return false;
250
+ }
251
+ const checkedValue = govukField.items?.[0].checked;
252
+ return typeof checkedValue === 'boolean';
253
+ }
244
254
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["Joi","ComponentType","QuestionTypeSubGroup","pageTypeSchema","string","required","valid","description","questionTypeSchema","WrittenAnswerSubGroup","DateSubGroup","UkAddressField","TelephoneNumberField","FileUploadField","EmailAddressField","ListSubGroup","YesNoField","CheckboxesField","RadiosField","AutocompleteField","questionTypeFullSchema","TextField","MultilineTextField","NumberField","DatePartsField","MonthYearField","writtenAnswerSubSchema","dateSubSchema","listSubSchema","nameSchema","trim","questionSchema","hintTextSchema","optional","allow","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","repeaterSchema","minItemsSchema","maxItemsSchema","questionSetNameSchema","needDeclarationSchema","declarationTextSchema","minSchema","maxSchema","minLengthSchema","maxLengthSchema","maxFutureSchema","maxPastSchema","precisionSchema","prefixSchema","regexSchema","rowsSchema","suffixSchema","classesSchema","jsEnabledSchema","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"],"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 type FormEditorInputCheckAnswersSettings,\n type FormEditorInputPage,\n type FormEditorInputPageSettings,\n type FormEditorInputQuestion\n} from '~/src/form/form-editor/types.js'\n\nexport enum QuestionTypeSubGroup {\n WrittenAnswerSubGroup = 'writtenAnswerSub',\n DateSubGroup = 'dateSub',\n ListSubGroup = 'listSub'\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 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 )\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)\nexport const listSubSchema = Joi.string()\n .required()\n .valid(\n ComponentType.YesNoField,\n ComponentType.CheckboxesField,\n ComponentType.RadiosField,\n ComponentType.AutocompleteField\n )\n .description('Subtype for date-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 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 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(1)\n .description('The minimum number of repeater items')\n\nexport const maxItemsSchema = Joi.number()\n .empty('')\n .max(25)\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\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 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}\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"],"mappings":"AAA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[]}
1
+ {"version":3,"file":"index.js","names":["Joi","ComponentType","QuestionTypeSubGroup","pageTypeSchema","string","required","valid","description","questionTypeSchema","WrittenAnswerSubGroup","DateSubGroup","UkAddressField","TelephoneNumberField","FileUploadField","EmailAddressField","ListSubGroup","YesNoField","CheckboxesField","RadiosField","AutocompleteField","questionTypeFullSchema","TextField","MultilineTextField","NumberField","DatePartsField","MonthYearField","writtenAnswerSubSchema","dateSubSchema","listSubSchema","nameSchema","trim","questionSchema","hintTextSchema","optional","allow","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","repeaterSchema","minItemsSchema","maxItemsSchema","questionSetNameSchema","needDeclarationSchema","declarationTextSchema","minSchema","maxSchema","minLengthSchema","maxLengthSchema","maxFutureSchema","maxPastSchema","precisionSchema","prefixSchema","regexSchema","rowsSchema","suffixSchema","classesSchema","jsEnabledSchema","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","govukFieldIsQuestionOptional","checkedValue","checked"],"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 type FormEditorInputCheckAnswersSettings,\n type FormEditorInputPage,\n type FormEditorInputPageSettings,\n type FormEditorInputQuestion,\n type GovukField,\n type GovukFieldQuestionOptional,\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}\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 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 )\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)\nexport const listSubSchema = Joi.string()\n .required()\n .valid(\n ComponentType.YesNoField,\n ComponentType.CheckboxesField,\n ComponentType.RadiosField,\n ComponentType.AutocompleteField\n )\n .description('Subtype for date-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 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 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(1)\n .description('The minimum number of repeater items')\n\nexport const maxItemsSchema = Joi.number()\n .empty('')\n .max(25)\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\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 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}\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 ['question', 'hintText', 'shortDescription'].includes(\n `${govukField.name}`\n )\n}\n\nexport function govukFieldIsQuestionOptional(\n govukField: GovukField\n): govukField is GovukFieldQuestionOptional {\n if (govukField.name !== 'questionOptional') {\n return false\n }\n const checkedValue = govukField.items?.[0].checked\n return typeof checkedValue === 'boolean'\n}\n"],"mappings":"AAAA,OAAOA,GAAG,MAAiD,KAAK;AAEhE,SAASC,aAAa;AAWtB,WAAYC,oBAAoB,0BAApBA,oBAAoB;EAApBA,oBAAoB;EAApBA,oBAAoB;EAApBA,oBAAoB;EAAA,OAApBA,oBAAoB;AAAA;AAMhC,OAAO,MAAMC,cAAc,GAAGH,GAAG,CAACI,MAAM,CAAC,CAAC,CACvCC,QAAQ,CAAC,CAAC,CACVC,KAAK,CAAC,UAAU,EAAE,UAAU,CAAC,CAC7BC,WAAW,CAAC,wDAAwD,C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CAAC/G,KAAK,GAAG,CAAC,CAAC,CAACmH,OAAO;EAClD,OAAO,OAAOD,YAAY,KAAK,SAAS;AAC1C","ignoreList":[]}
@@ -0,0 +1,17 @@
1
+ import { Question } from "./question.js";
2
+ export class DateInputQuestion extends Question {
3
+ /**
4
+ * @type {string}
5
+ * @protected
6
+ */
7
+ _questionTemplate = 'date-input.njk';
8
+ get renderInput() {
9
+ return {
10
+ id: 'dateInput',
11
+ name: 'dateInputField',
12
+ fieldset: this.fieldSet,
13
+ hint: this.hint
14
+ };
15
+ }
16
+ }
17
+ //# sourceMappingURL=date-input.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"date-input.js","names":["Question","DateInputQuestion","_questionTemplate","renderInput","id","name","fieldset","fieldSet","hint"],"sources":["../../../../../src/form/form-editor/preview/date-input.js"],"sourcesContent":["import { Question } from '~/src/form/form-editor/preview/question.js'\n\nexport class DateInputQuestion extends Question {\n /**\n * @type {string}\n * @protected\n */\n _questionTemplate = 'date-input.njk'\n\n get renderInput() {\n return {\n id: 'dateInput',\n name: 'dateInputField',\n fieldset: this.fieldSet,\n hint: this.hint\n }\n }\n}\n"],"mappings":"AAAA,SAASA,QAAQ;AAEjB,OAAO,MAAMC,iBAAiB,SAASD,QAAQ,CAAC;EAC9C;AACF;AACA;AACA;EACEE,iBAAiB,GAAG,gBAAgB;EAEpC,IAAIC,WAAWA,CAAA,EAAG;IAChB,OAAO;MACLC,EAAE,EAAE,WAAW;MACfC,IAAI,EAAE,gBAAgB;MACtBC,QAAQ,EAAE,IAAI,CAACC,QAAQ;MACvBC,IAAI,EAAE,IAAI,CAACA;IACb,CAAC;EACH;AACF","ignoreList":[]}
@@ -0,0 +1,6 @@
1
+ import { Question } from "./question.js";
2
+ export class EmailAddressQuestion extends Question {
3
+ _questionTemplate = 'emailaddressfield.njk';
4
+ _fieldName = 'emailAddressField';
5
+ }
6
+ //# sourceMappingURL=email-address.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"email-address.js","names":["Question","EmailAddressQuestion","_questionTemplate","_fieldName"],"sources":["../../../../../src/form/form-editor/preview/email-address.js"],"sourcesContent":["import { Question } from '~/src/form/form-editor/preview/question.js'\n\nexport class EmailAddressQuestion extends Question {\n _questionTemplate = 'emailaddressfield.njk'\n _fieldName = 'emailAddressField'\n}\n"],"mappings":"AAAA,SAASA,QAAQ;AAEjB,OAAO,MAAMC,oBAAoB,SAASD,QAAQ,CAAC;EACjDE,iBAAiB,GAAG,uBAAuB;EAC3CC,UAAU,GAAG,mBAAmB;AAClC","ignoreList":[]}
@@ -0,0 +1,11 @@
1
+ export * from "./date-input.js";
2
+ export * from "./email-address.js";
3
+ export * from "./list.js";
4
+ export * from "./list-sortable.js";
5
+ export * from "./phone-number.js";
6
+ export * from "./question.js";
7
+ export * from "./radio.js";
8
+ export * from "./radio-sortable.js";
9
+ export * from "./short-answer.js";
10
+ export * from "./uk-address.js";
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../../../src/form/form-editor/preview/index.js"],"sourcesContent":["export * from '~/src/form/form-editor/preview/date-input.js'\nexport * from '~/src/form/form-editor/preview/email-address.js'\nexport * from '~/src/form/form-editor/preview/list.js'\nexport * from '~/src/form/form-editor/preview/list-sortable.js'\nexport * from '~/src/form/form-editor/preview/phone-number.js'\nexport * from '~/src/form/form-editor/preview/question.js'\nexport * from '~/src/form/form-editor/preview/radio.js'\nexport * from '~/src/form/form-editor/preview/radio-sortable.js'\nexport * from '~/src/form/form-editor/preview/short-answer.js'\nexport * from '~/src/form/form-editor/preview/uk-address.js'\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
@@ -0,0 +1,40 @@
1
+ import { ListQuestion } from "./list.js";
2
+ export class ListSortableQuestion extends ListQuestion {
3
+ /**
4
+ * @param {ListElements} listElements
5
+ * @param {QuestionRenderer} questionRenderer
6
+ */
7
+ constructor(listElements, questionRenderer) {
8
+ super(listElements, questionRenderer);
9
+ const items = /** @type {ListElement[]} */listElements.values.items;
10
+ this._list = this.createListFromElements(items);
11
+ this._listElements = listElements;
12
+ }
13
+
14
+ /**
15
+ * @returns {Map<string, ListElement>}
16
+ */
17
+ resyncPreviewAfterReorder() {
18
+ const newList = this._listElements.values.items;
19
+ this._list = this.createListFromElements(newList);
20
+ this.render();
21
+ return this._list;
22
+ }
23
+ get listElementObjects() {
24
+ return Array.from(this._list).map(([, value]) => ({
25
+ id: value.id,
26
+ text: value.text,
27
+ hint: value.hint?.text ? {
28
+ text: value.hint.text
29
+ } : undefined,
30
+ value: value.value
31
+ }));
32
+ }
33
+ }
34
+
35
+ /**
36
+ * @import {ListElement} from '~/src/form/form-editor/types.js'
37
+ * @import { QuestionRenderer, HTMLBuilder, ListElements, BaseSettings } from '~/src/form/form-editor/preview/types.js'
38
+ * @import { SortableEvent, SortableOptions } from 'sortablejs'
39
+ */
40
+ //# sourceMappingURL=list-sortable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list-sortable.js","names":["ListQuestion","ListSortableQuestion","constructor","listElements","questionRenderer","items","values","_list","createListFromElements","_listElements","resyncPreviewAfterReorder","newList","render","listElementObjects","Array","from","map","value","id","text","hint","undefined"],"sources":["../../../../../src/form/form-editor/preview/list-sortable.js"],"sourcesContent":["import { ListQuestion } from '~/src/form/form-editor/preview/list.js'\n\nexport class ListSortableQuestion extends ListQuestion {\n /**\n * @param {ListElements} listElements\n * @param {QuestionRenderer} questionRenderer\n */\n constructor(listElements, questionRenderer) {\n super(listElements, questionRenderer)\n const items = /** @type {ListElement[]} */ (listElements.values.items)\n this._list = this.createListFromElements(items)\n this._listElements = listElements\n }\n\n /**\n * @returns {Map<string, ListElement>}\n */\n resyncPreviewAfterReorder() {\n const newList = this._listElements.values.items\n this._list = this.createListFromElements(newList)\n this.render()\n return this._list\n }\n\n get listElementObjects() {\n return Array.from(this._list).map(([, value]) => ({\n id: value.id,\n text: value.text,\n hint: value.hint?.text ? { text: value.hint.text } : undefined,\n value: value.value\n }))\n }\n}\n\n/**\n * @import {ListElement} from '~/src/form/form-editor/types.js'\n * @import { QuestionRenderer, HTMLBuilder, ListElements, BaseSettings } from '~/src/form/form-editor/preview/types.js'\n * @import { SortableEvent, SortableOptions } from 'sortablejs'\n */\n"],"mappings":"AAAA,SAASA,YAAY;AAErB,OAAO,MAAMC,oBAAoB,SAASD,YAAY,CAAC;EACrD;AACF;AACA;AACA;EACEE,WAAWA,CAACC,YAAY,EAAEC,gBAAgB,EAAE;IAC1C,KAAK,CAACD,YAAY,EAAEC,gBAAgB,CAAC;IACrC,MAAMC,KAAK,GAAG,4BAA8BF,YAAY,CAACG,MAAM,CAACD,KAAM;IACtE,IAAI,CAACE,KAAK,GAAG,IAAI,CAACC,sBAAsB,CAACH,KAAK,CAAC;IAC/C,IAAI,CAACI,aAAa,GAAGN,YAAY;EACnC;;EAEA;AACF;AACA;EACEO,yBAAyBA,CAAA,EAAG;IAC1B,MAAMC,OAAO,GAAG,IAAI,CAACF,aAAa,CAACH,MAAM,CAACD,KAAK;IAC/C,IAAI,CAACE,KAAK,GAAG,IAAI,CAACC,sBAAsB,CAACG,OAAO,CAAC;IACjD,IAAI,CAACC,MAAM,CAAC,CAAC;IACb,OAAO,IAAI,CAACL,KAAK;EACnB;EAEA,IAAIM,kBAAkBA,CAAA,EAAG;IACvB,OAAOC,KAAK,CAACC,IAAI,CAAC,IAAI,CAACR,KAAK,CAAC,CAACS,GAAG,CAAC,CAAC,GAAGC,KAAK,CAAC,MAAM;MAChDC,EAAE,EAAED,KAAK,CAACC,EAAE;MACZC,IAAI,EAAEF,KAAK,CAACE,IAAI;MAChBC,IAAI,EAAEH,KAAK,CAACG,IAAI,EAAED,IAAI,GAAG;QAAEA,IAAI,EAAEF,KAAK,CAACG,IAAI,CAACD;MAAK,CAAC,GAAGE,SAAS;MAC9DJ,KAAK,EAAEA,KAAK,CAACA;IACf,CAAC,CAAC,CAAC;EACL;AACF;;AAEA;AACA;AACA;AACA;AACA","ignoreList":[]}
@@ -0,0 +1,182 @@
1
+ import { Question } from "./question.js";
2
+ const DefaultListConst = {
3
+ TextElementId: 'radioText',
4
+ HintElementId: 'radioHint',
5
+ Template: 'radios.njk',
6
+ Input: 'listInput',
7
+ RenderName: 'listInputField'
8
+ };
9
+
10
+ /**
11
+ * @param {ListElement} listElement
12
+ * @returns {[string, ListElement]}
13
+ */
14
+ export function listItemMapper(listElement) {
15
+ return [listElement.id, listElement];
16
+ }
17
+
18
+ /**
19
+ *
20
+ * @param { ListElement[]| undefined } listElements
21
+ * @returns {Map<string, ListElement>}
22
+ */
23
+ export function listsElementToMap(listElements) {
24
+ const entries = listElements ? listElements.map(listItemMapper) : [];
25
+ return new Map(entries);
26
+ }
27
+ export class ListQuestion extends Question {
28
+ /**
29
+ * @type {string}
30
+ * @protected
31
+ */
32
+ _questionTemplate = DefaultListConst.Template;
33
+ /** @type {ListElements} */
34
+ _listElements;
35
+ listRenderId = DefaultListConst.Input;
36
+ listRenderName = DefaultListConst.RenderName;
37
+
38
+ /**
39
+ * @type {Map<string, ListElement>}
40
+ * @protected
41
+ */
42
+ _list;
43
+
44
+ /**
45
+ * @param {ListElements} listElements
46
+ * @param {QuestionRenderer} questionRenderer
47
+ */
48
+ constructor(listElements, questionRenderer) {
49
+ super(listElements, questionRenderer);
50
+ const items = /** @type {ListElement[]} */listElements.values.items;
51
+ this._list = this.createListFromElements(items);
52
+ this._listElements = listElements;
53
+ }
54
+ get renderInput() {
55
+ const afterInputs = /** @type {{ formGroup?: { afterInputs: { html: string } } }} */
56
+ this.list.length ? {} : {
57
+ formGroup: {
58
+ afterInputs: {
59
+ html: this._listElements.afterInputsHTML
60
+ }
61
+ }
62
+ };
63
+ return {
64
+ id: this.listRenderId,
65
+ name: this.listRenderName,
66
+ fieldset: this.fieldSet,
67
+ hint: this.hint,
68
+ items: this.list,
69
+ ...afterInputs
70
+ };
71
+ }
72
+
73
+ /**
74
+ *
75
+ * @param {ListElement} listElement
76
+ */
77
+ push(listElement) {
78
+ this._list.set(listElement.id, listElement);
79
+ this.render();
80
+ }
81
+
82
+ /**
83
+ * @param {string} key
84
+ */
85
+ delete(key) {
86
+ this._list.delete(key);
87
+ this.render();
88
+ }
89
+
90
+ /**
91
+ * @param {ListElement[]} listElements
92
+ * @returns {Map<string, ListElement>}
93
+ */
94
+ createListFromElements(listElements) {
95
+ this._list = listsElementToMap(listElements);
96
+ return this._list;
97
+ }
98
+
99
+ /**
100
+ * @returns {ListItemReadonly[]}
101
+ * @readonly
102
+ */
103
+ get list() {
104
+ const iterator = /** @type {MapIterator<ListElement>} */
105
+ this._list.values();
106
+ return Array.from(iterator).map(listItem => {
107
+ const hintText = this._highlight === `${listItem.id}-hint` && !listItem.hint?.text.length ? 'Hint text' : listItem.hint?.text ?? '';
108
+ const hint = {
109
+ hint: hintText ? {
110
+ text: hintText,
111
+ classes: this.getHighlight(listItem.id + '-hint')
112
+ } : undefined
113
+ };
114
+ const text = listItem.text.length ? listItem.text : 'Item text';
115
+ return {
116
+ ...listItem,
117
+ text,
118
+ ...hint,
119
+ label: {
120
+ text: listItem.text,
121
+ classes: this.getHighlight(listItem.id + '-label')
122
+ }
123
+ };
124
+ });
125
+ }
126
+
127
+ /**
128
+ *
129
+ * @param {string | undefined} id
130
+ * @param {string} text
131
+ */
132
+ updateText(id, text) {
133
+ if (!id) {
134
+ return;
135
+ }
136
+ const listItem = this._list.get(id);
137
+ if (listItem) {
138
+ listItem.text = text;
139
+ this.render();
140
+ }
141
+ }
142
+
143
+ /**
144
+ *
145
+ * @param {string | undefined} id
146
+ * @param {string} hint
147
+ */
148
+ updateHint(id, hint) {
149
+ if (!id) {
150
+ return;
151
+ }
152
+ const listItem = this._list.get(id);
153
+ if (listItem) {
154
+ listItem.hint = {
155
+ ...listItem.hint,
156
+ text: hint
157
+ };
158
+ this.render();
159
+ }
160
+ }
161
+
162
+ /**
163
+ * @param {string | undefined} id
164
+ * @param {string} value
165
+ */
166
+ updateValue(id, value) {
167
+ if (!id) {
168
+ return;
169
+ }
170
+ const listItem = this._list.get(id);
171
+ if (listItem) {
172
+ listItem.value = value;
173
+ this.render();
174
+ }
175
+ }
176
+ }
177
+
178
+ /**
179
+ * @import { ListElement, ListItemReadonly } from '~/src/form/form-editor/types.js'
180
+ * @import { ListenerRow, ListElements, QuestionRenderer, HTMLBuilder } from '~/src/form/form-editor/preview/types.js'
181
+ */
182
+ //# sourceMappingURL=list.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list.js","names":["Question","DefaultListConst","TextElementId","HintElementId","Template","Input","RenderName","listItemMapper","listElement","id","listsElementToMap","listElements","entries","map","Map","ListQuestion","_questionTemplate","_listElements","listRenderId","listRenderName","_list","constructor","questionRenderer","items","values","createListFromElements","renderInput","afterInputs","list","length","formGroup","html","afterInputsHTML","name","fieldset","fieldSet","hint","push","set","render","delete","key","iterator","Array","from","listItem","hintText","_highlight","text","classes","getHighlight","undefined","label","updateText","get","updateHint","updateValue","value"],"sources":["../../../../../src/form/form-editor/preview/list.js"],"sourcesContent":["import { Question } from '~/src/form/form-editor/preview/question.js'\n\nconst DefaultListConst = {\n TextElementId: 'radioText',\n HintElementId: 'radioHint',\n Template: 'radios.njk',\n Input: 'listInput',\n RenderName: 'listInputField'\n}\n\n/**\n * @param {ListElement} listElement\n * @returns {[string, ListElement]}\n */\nexport function listItemMapper(listElement) {\n return [listElement.id, listElement]\n}\n\n/**\n *\n * @param { ListElement[]| undefined } listElements\n * @returns {Map<string, ListElement>}\n */\nexport function listsElementToMap(listElements) {\n const entries = listElements ? listElements.map(listItemMapper) : []\n return new Map(entries)\n}\n\nexport class ListQuestion extends Question {\n /**\n * @type {string}\n * @protected\n */\n _questionTemplate = DefaultListConst.Template\n /** @type {ListElements} */\n _listElements\n listRenderId = DefaultListConst.Input\n listRenderName = DefaultListConst.RenderName\n\n /**\n * @type {Map<string, ListElement>}\n * @protected\n */\n _list\n\n /**\n * @param {ListElements} listElements\n * @param {QuestionRenderer} questionRenderer\n */\n constructor(listElements, questionRenderer) {\n super(listElements, questionRenderer)\n\n const items = /** @type {ListElement[]} */ (listElements.values.items)\n this._list = this.createListFromElements(items)\n this._listElements = listElements\n }\n\n get renderInput() {\n const afterInputs =\n /** @type {{ formGroup?: { afterInputs: { html: string } } }} */ (\n this.list.length\n ? {}\n : {\n formGroup: {\n afterInputs: {\n html: this._listElements.afterInputsHTML\n }\n }\n }\n )\n\n return {\n id: this.listRenderId,\n name: this.listRenderName,\n fieldset: this.fieldSet,\n hint: this.hint,\n items: this.list,\n ...afterInputs\n }\n }\n\n /**\n *\n * @param {ListElement} listElement\n */\n push(listElement) {\n this._list.set(listElement.id, listElement)\n this.render()\n }\n\n /**\n * @param {string} key\n */\n delete(key) {\n this._list.delete(key)\n this.render()\n }\n\n /**\n * @param {ListElement[]} listElements\n * @returns {Map<string, ListElement>}\n */\n createListFromElements(listElements) {\n this._list = listsElementToMap(listElements)\n return this._list\n }\n\n /**\n * @returns {ListItemReadonly[]}\n * @readonly\n */\n get list() {\n const iterator = /** @type {MapIterator<ListElement>} */ (\n this._list.values()\n )\n return Array.from(iterator).map((listItem) => {\n const hintText =\n this._highlight === `${listItem.id}-hint` && !listItem.hint?.text.length\n ? 'Hint text'\n : (listItem.hint?.text ?? '')\n\n const hint = {\n hint: hintText\n ? {\n text: hintText,\n classes: this.getHighlight(listItem.id + '-hint')\n }\n : undefined\n }\n\n const text = listItem.text.length ? listItem.text : 'Item text'\n\n return {\n ...listItem,\n text,\n ...hint,\n label: {\n text: listItem.text,\n classes: this.getHighlight(listItem.id + '-label')\n }\n }\n })\n }\n\n /**\n *\n * @param {string | undefined} id\n * @param {string} text\n */\n updateText(id, text) {\n if (!id) {\n return\n }\n\n const listItem = this._list.get(id)\n if (listItem) {\n listItem.text = text\n this.render()\n }\n }\n\n /**\n *\n * @param {string | undefined} id\n * @param {string} hint\n */\n updateHint(id, hint) {\n if (!id) {\n return\n }\n\n const listItem = this._list.get(id)\n if (listItem) {\n listItem.hint = {\n ...listItem.hint,\n text: hint\n }\n this.render()\n }\n }\n\n /**\n * @param {string | undefined} id\n * @param {string} value\n */\n updateValue(id, value) {\n if (!id) {\n return\n }\n\n const listItem = this._list.get(id)\n if (listItem) {\n listItem.value = value\n this.render()\n }\n }\n}\n\n/**\n * @import { ListElement, ListItemReadonly } from '~/src/form/form-editor/types.js'\n * @import { ListenerRow, ListElements, QuestionRenderer, HTMLBuilder } from '~/src/form/form-editor/preview/types.js'\n */\n"],"mappings":"AAAA,SAASA,QAAQ;AAEjB,MAAMC,gBAAgB,GAAG;EACvBC,aAAa,EAAE,WAAW;EAC1BC,aAAa,EAAE,WAAW;EAC1BC,QAAQ,EAAE,YAAY;EACtBC,KAAK,EAAE,WAAW;EAClBC,UAAU,EAAE;AACd,CAAC;;AAED;AACA;AACA;AACA;AACA,OAAO,SAASC,cAAcA,CAACC,WAAW,EAAE;EAC1C,OAAO,CAACA,WAAW,CAACC,EAAE,EAAED,WAAW,CAAC;AACtC;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASE,iBAAiBA,CAACC,YAAY,EAAE;EAC9C,MAAMC,OAAO,GAAGD,YAAY,GAAGA,YAAY,CAACE,GAAG,CAACN,cAAc,CAAC,GAAG,EAAE;EACpE,OAAO,IAAIO,GAAG,CAACF,OAAO,CAAC;AACzB;AAEA,OAAO,MAAMG,YAAY,SAASf,QAAQ,CAAC;EACzC;AACF;AACA;AACA;EACEgB,iBAAiB,GAAGf,gBAAgB,CAACG,QAAQ;EAC7C;EACAa,aAAa;EACbC,YAAY,GAAGjB,gBAAgB,CAACI,KAAK;EACrCc,cAAc,GAAGlB,gBAAgB,CAACK,UAAU;;EAE5C;AACF;AACA;AACA;EACEc,KAAK;;EAEL;AACF;AACA;AACA;EACEC,WAAWA,CAACV,YAAY,EAAEW,gBAAgB,EAAE;IAC1C,KAAK,CAACX,YAAY,EAAEW,gBAAgB,CAAC;IAErC,MAAMC,KAAK,GAAG,4BA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AQ,GAAG,IAAI,CAACzB,KAAK,CAACkC,GAAG,CAAC7C,EAAE,CAAC;IACnC,IAAIoC,QAAQ,EAAE;MACZA,QAAQ,CAACT,IAAI,GAAG;QACd,GAAGS,QAAQ,CAACT,IAAI;QAChBY,IAAI,EAAEZ;MACR,CAAC;MACD,IAAI,CAACG,MAAM,CAAC,CAAC;IACf;EACF;;EAEA;AACF;AACA;AACA;EACEiB,WAAWA,CAAC/C,EAAE,EAAEgD,KAAK,EAAE;IACrB,IAAI,CAAChD,EAAE,EAAE;MACP;IACF;IAEA,MAAMoC,QAAQ,GAAG,IAAI,CAACzB,KAAK,CAACkC,GAAG,CAAC7C,EAAE,CAAC;IACnC,IAAIoC,QAAQ,EAAE;MACZA,QAAQ,CAACY,KAAK,GAAGA,KAAK;MACtB,IAAI,CAAClB,MAAM,CAAC,CAAC;IACf;EACF;AACF;;AAEA;AACA;AACA;AACA","ignoreList":[]}
@@ -0,0 +1,10 @@
1
+ import { Question } from "./question.js";
2
+ export class PhoneNumberQuestion extends Question {
3
+ _questionTemplate = 'telephonenumberfield.njk';
4
+ _fieldName = 'phoneNumberField';
5
+ }
6
+
7
+ /**
8
+ * @import { QuestionBaseModel } from '~/src/form/form-editor/preview/question.js'
9
+ */
10
+ //# sourceMappingURL=phone-number.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"phone-number.js","names":["Question","PhoneNumberQuestion","_questionTemplate","_fieldName"],"sources":["../../../../../src/form/form-editor/preview/phone-number.js"],"sourcesContent":["import { Question } from '~/src/form/form-editor/preview/question.js'\n\nexport class PhoneNumberQuestion extends Question {\n _questionTemplate = 'telephonenumberfield.njk'\n _fieldName = 'phoneNumberField'\n}\n\n/**\n * @import { QuestionBaseModel } from '~/src/form/form-editor/preview/question.js'\n */\n"],"mappings":"AAAA,SAASA,QAAQ;AAEjB,OAAO,MAAMC,mBAAmB,SAASD,QAAQ,CAAC;EAChDE,iBAAiB,GAAG,0BAA0B;EAC9CC,UAAU,GAAG,kBAAkB;AACjC;;AAEA;AACA;AACA","ignoreList":[]}