@defra/forms-model 3.0.480 → 3.0.482

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 (176) hide show
  1. package/dist/module/form/form-editor/__stubs__/preview.js +83 -4
  2. package/dist/module/form/form-editor/__stubs__/preview.js.map +1 -1
  3. package/dist/module/form/form-editor/index.js +2 -2
  4. package/dist/module/form/form-editor/index.js.map +1 -1
  5. package/dist/module/form/form-editor/macros/types.js +2 -0
  6. package/dist/module/form/form-editor/macros/types.js.map +1 -0
  7. package/dist/module/form/form-editor/preview/autocomplete.js +20 -4
  8. package/dist/module/form/form-editor/preview/autocomplete.js.map +1 -1
  9. package/dist/module/form/form-editor/preview/checkbox-sortable.js +7 -2
  10. package/dist/module/form/form-editor/preview/checkbox-sortable.js.map +1 -1
  11. package/dist/module/form/form-editor/preview/checkbox.js +17 -0
  12. package/dist/module/form/form-editor/preview/checkbox.js.map +1 -0
  13. package/dist/module/form/form-editor/preview/component-elements.js +61 -0
  14. package/dist/module/form/form-editor/preview/component-elements.js.map +1 -0
  15. package/dist/module/form/form-editor/preview/constants.js +2 -0
  16. package/dist/module/form/form-editor/preview/constants.js.map +1 -0
  17. package/dist/module/form/form-editor/preview/content.js +94 -0
  18. package/dist/module/form/form-editor/preview/content.js.map +1 -0
  19. package/dist/module/form/form-editor/preview/controller/page-controller.js +260 -0
  20. package/dist/module/form/form-editor/preview/controller/page-controller.js.map +1 -0
  21. package/dist/module/form/form-editor/preview/date-input.js +7 -2
  22. package/dist/module/form/form-editor/preview/date-input.js.map +1 -1
  23. package/dist/module/form/form-editor/preview/email-address.js +7 -1
  24. package/dist/module/form/form-editor/preview/email-address.js.map +1 -1
  25. package/dist/module/form/form-editor/preview/fieldset-question.js +5 -0
  26. package/dist/module/form/form-editor/preview/fieldset-question.js.map +1 -1
  27. package/dist/module/form/form-editor/preview/helpers.js +81 -0
  28. package/dist/module/form/form-editor/preview/helpers.js.map +1 -0
  29. package/dist/module/form/form-editor/preview/index.js +6 -0
  30. package/dist/module/form/form-editor/preview/index.js.map +1 -1
  31. package/dist/module/form/form-editor/preview/list.js +59 -3
  32. package/dist/module/form/form-editor/preview/list.js.map +1 -1
  33. package/dist/module/form/form-editor/preview/long-answer.js +7 -1
  34. package/dist/module/form/form-editor/preview/long-answer.js.map +1 -1
  35. package/dist/module/form/form-editor/preview/markdown.js +53 -0
  36. package/dist/module/form/form-editor/preview/markdown.js.map +1 -0
  37. package/dist/module/form/form-editor/preview/month-year.js +7 -2
  38. package/dist/module/form/form-editor/preview/month-year.js.map +1 -1
  39. package/dist/module/form/form-editor/preview/number-only.js +5 -0
  40. package/dist/module/form/form-editor/preview/number-only.js.map +1 -1
  41. package/dist/module/form/form-editor/preview/phone-number.js +7 -1
  42. package/dist/module/form/form-editor/preview/phone-number.js.map +1 -1
  43. package/dist/module/form/form-editor/preview/preview.js +212 -0
  44. package/dist/module/form/form-editor/preview/preview.js.map +1 -0
  45. package/dist/module/form/form-editor/preview/question.js +48 -138
  46. package/dist/module/form/form-editor/preview/question.js.map +1 -1
  47. package/dist/module/form/form-editor/preview/radio-sortable.js +7 -2
  48. package/dist/module/form/form-editor/preview/radio-sortable.js.map +1 -1
  49. package/dist/module/form/form-editor/preview/radio.js +7 -2
  50. package/dist/module/form/form-editor/preview/radio.js.map +1 -1
  51. package/dist/module/form/form-editor/preview/select-sortable.js +38 -0
  52. package/dist/module/form/form-editor/preview/select-sortable.js.map +1 -0
  53. package/dist/module/form/form-editor/preview/select.js +11 -0
  54. package/dist/module/form/form-editor/preview/select.js.map +1 -0
  55. package/dist/module/form/form-editor/preview/short-answer.js +7 -1
  56. package/dist/module/form/form-editor/preview/short-answer.js.map +1 -1
  57. package/dist/module/form/form-editor/preview/supporting-evidence.js +7 -1
  58. package/dist/module/form/form-editor/preview/supporting-evidence.js.map +1 -1
  59. package/dist/module/form/form-editor/preview/types.js.map +1 -1
  60. package/dist/module/form/form-editor/preview/uk-address.js +7 -2
  61. package/dist/module/form/form-editor/preview/uk-address.js.map +1 -1
  62. package/dist/module/form/form-editor/preview/yes-no.js +7 -2
  63. package/dist/module/form/form-editor/preview/yes-no.js.map +1 -1
  64. package/dist/module/form/form-editor/types.js.map +1 -1
  65. package/dist/module/form/form-metadata/index.js +1 -5
  66. package/dist/module/form/form-metadata/index.js.map +1 -1
  67. package/dist/module/form/utils/index.js +1 -0
  68. package/dist/module/form/utils/index.js.map +1 -1
  69. package/dist/module/form/utils/list.js +15 -0
  70. package/dist/module/form/utils/list.js.map +1 -0
  71. package/dist/module/index.js.map +1 -1
  72. package/dist/module/stubs.js +1 -0
  73. package/dist/module/stubs.js.map +1 -1
  74. package/dist/types/form/form-editor/__stubs__/preview.d.ts +58 -11
  75. package/dist/types/form/form-editor/__stubs__/preview.d.ts.map +1 -1
  76. package/dist/types/form/form-editor/index.d.ts.map +1 -1
  77. package/dist/types/form/form-editor/macros/types.d.ts +62 -0
  78. package/dist/types/form/form-editor/macros/types.d.ts.map +1 -0
  79. package/dist/types/form/form-editor/preview/autocomplete.d.ts +3 -1
  80. package/dist/types/form/form-editor/preview/autocomplete.d.ts.map +1 -1
  81. package/dist/types/form/form-editor/preview/checkbox-sortable.d.ts.map +1 -1
  82. package/dist/types/form/form-editor/preview/checkbox.d.ts +4 -0
  83. package/dist/types/form/form-editor/preview/checkbox.d.ts.map +1 -0
  84. package/dist/types/form/form-editor/preview/component-elements.d.ts +35 -0
  85. package/dist/types/form/form-editor/preview/component-elements.d.ts.map +1 -0
  86. package/dist/types/form/form-editor/preview/constants.d.ts +2 -0
  87. package/dist/types/form/form-editor/preview/constants.d.ts.map +1 -0
  88. package/dist/types/form/form-editor/preview/content.d.ts +43 -0
  89. package/dist/types/form/form-editor/preview/content.d.ts.map +1 -0
  90. package/dist/types/form/form-editor/preview/controller/page-controller.d.ts +132 -0
  91. package/dist/types/form/form-editor/preview/controller/page-controller.d.ts.map +1 -0
  92. package/dist/types/form/form-editor/preview/date-input.d.ts.map +1 -1
  93. package/dist/types/form/form-editor/preview/email-address.d.ts.map +1 -1
  94. package/dist/types/form/form-editor/preview/fieldset-question.d.ts +2 -0
  95. package/dist/types/form/form-editor/preview/fieldset-question.d.ts.map +1 -1
  96. package/dist/types/form/form-editor/preview/helpers.d.ts +11 -0
  97. package/dist/types/form/form-editor/preview/helpers.d.ts.map +1 -0
  98. package/dist/types/form/form-editor/preview/index.d.ts +6 -0
  99. package/dist/types/form/form-editor/preview/list-sortable.d.ts +1 -1
  100. package/dist/types/form/form-editor/preview/list.d.ts +25 -0
  101. package/dist/types/form/form-editor/preview/list.d.ts.map +1 -1
  102. package/dist/types/form/form-editor/preview/long-answer.d.ts.map +1 -1
  103. package/dist/types/form/form-editor/preview/markdown.d.ts +9 -0
  104. package/dist/types/form/form-editor/preview/markdown.d.ts.map +1 -0
  105. package/dist/types/form/form-editor/preview/month-year.d.ts.map +1 -1
  106. package/dist/types/form/form-editor/preview/number-only.d.ts.map +1 -1
  107. package/dist/types/form/form-editor/preview/phone-number.d.ts.map +1 -1
  108. package/dist/types/form/form-editor/preview/preview.d.ts +126 -0
  109. package/dist/types/form/form-editor/preview/preview.d.ts.map +1 -0
  110. package/dist/types/form/form-editor/preview/question.d.ts +19 -93
  111. package/dist/types/form/form-editor/preview/question.d.ts.map +1 -1
  112. package/dist/types/form/form-editor/preview/radio-sortable.d.ts.map +1 -1
  113. package/dist/types/form/form-editor/preview/radio.d.ts.map +1 -1
  114. package/dist/types/form/form-editor/preview/select-sortable.d.ts +18 -0
  115. package/dist/types/form/form-editor/preview/select-sortable.d.ts.map +1 -0
  116. package/dist/types/form/form-editor/preview/select.d.ts +4 -0
  117. package/dist/types/form/form-editor/preview/select.d.ts.map +1 -0
  118. package/dist/types/form/form-editor/preview/short-answer.d.ts.map +1 -1
  119. package/dist/types/form/form-editor/preview/supporting-evidence.d.ts.map +1 -1
  120. package/dist/types/form/form-editor/preview/types.d.ts +13 -17
  121. package/dist/types/form/form-editor/preview/types.d.ts.map +1 -1
  122. package/dist/types/form/form-editor/preview/uk-address.d.ts.map +1 -1
  123. package/dist/types/form/form-editor/preview/yes-no.d.ts.map +1 -1
  124. package/dist/types/form/form-editor/types.d.ts +6 -4
  125. package/dist/types/form/form-editor/types.d.ts.map +1 -1
  126. package/dist/types/form/form-metadata/index.d.ts.map +1 -1
  127. package/dist/types/form/utils/index.d.ts +1 -0
  128. package/dist/types/form/utils/index.d.ts.map +1 -1
  129. package/dist/types/form/utils/list.d.ts +10 -0
  130. package/dist/types/form/utils/list.d.ts.map +1 -0
  131. package/dist/types/index.d.ts +1 -0
  132. package/dist/types/index.d.ts.map +1 -1
  133. package/dist/types/stubs.d.ts +1 -0
  134. package/dist/types/stubs.d.ts.map +1 -1
  135. package/package.json +1 -1
  136. package/schemas/form-metadata-input-schema.json +1 -2
  137. package/schemas/form-metadata-schema.json +1 -2
  138. package/schemas/question-type-full-schema.json +2 -1
  139. package/src/form/form-editor/__stubs__/preview.js +84 -4
  140. package/src/form/form-editor/index.ts +4 -2
  141. package/src/form/form-editor/macros/types.ts +65 -0
  142. package/src/form/form-editor/preview/autocomplete.js +21 -4
  143. package/src/form/form-editor/preview/checkbox-sortable.js +7 -2
  144. package/src/form/form-editor/preview/checkbox.js +17 -0
  145. package/src/form/form-editor/preview/component-elements.js +61 -0
  146. package/src/form/form-editor/preview/constants.js +1 -0
  147. package/src/form/form-editor/preview/content.js +93 -0
  148. package/src/form/form-editor/preview/controller/page-controller.js +284 -0
  149. package/src/form/form-editor/preview/date-input.js +8 -2
  150. package/src/form/form-editor/preview/email-address.js +7 -1
  151. package/src/form/form-editor/preview/fieldset-question.js +6 -0
  152. package/src/form/form-editor/preview/helpers.js +95 -0
  153. package/src/form/form-editor/preview/index.js +6 -0
  154. package/src/form/form-editor/preview/list.js +62 -3
  155. package/src/form/form-editor/preview/long-answer.js +7 -1
  156. package/src/form/form-editor/preview/markdown.js +50 -0
  157. package/src/form/form-editor/preview/month-year.js +7 -2
  158. package/src/form/form-editor/preview/number-only.js +5 -0
  159. package/src/form/form-editor/preview/phone-number.js +7 -1
  160. package/src/form/form-editor/preview/preview.js +211 -0
  161. package/src/form/form-editor/preview/question.js +47 -142
  162. package/src/form/form-editor/preview/radio-sortable.js +7 -2
  163. package/src/form/form-editor/preview/radio.js +7 -2
  164. package/src/form/form-editor/preview/select-sortable.js +43 -0
  165. package/src/form/form-editor/preview/select.js +11 -0
  166. package/src/form/form-editor/preview/short-answer.js +7 -1
  167. package/src/form/form-editor/preview/supporting-evidence.js +7 -1
  168. package/src/form/form-editor/preview/types.ts +18 -18
  169. package/src/form/form-editor/preview/uk-address.js +7 -2
  170. package/src/form/form-editor/preview/yes-no.js +7 -2
  171. package/src/form/form-editor/types.ts +6 -4
  172. package/src/form/form-metadata/index.ts +2 -5
  173. package/src/form/utils/index.ts +1 -0
  174. package/src/form/utils/list.ts +25 -0
  175. package/src/index.ts +1 -0
  176. package/src/stubs.ts +1 -0
@@ -1,3 +1,37 @@
1
+ import { ComponentType } from "../../../components/enums.js";
2
+ import { ComponentElements } from "./component-elements.js";
3
+ import { PreviewComponent } from "./preview.js";
4
+
5
+ /**
6
+ * @implements {QuestionElements}
7
+ */
8
+ export class QuestionComponentElements extends ComponentElements {
9
+ /**
10
+ * @type {FormComponentsDef}
11
+ * @protected
12
+ */
13
+ _component;
14
+ /**
15
+ * @param {FormComponentsDef} component
16
+ */
17
+ constructor(component) {
18
+ super(component);
19
+ this._component = component;
20
+ }
21
+
22
+ /**
23
+ * @protected
24
+ * @returns {BaseSettings}
25
+ */
26
+ _getValues() {
27
+ return {
28
+ ...super._getValues(),
29
+ hintText: this._component.hint ?? '',
30
+ shortDesc: this._component.shortDescription ?? ''
31
+ };
32
+ }
33
+ }
34
+
1
35
  /**
2
36
  * @class Question
3
37
  * @classdesc
@@ -8,110 +42,37 @@
8
42
  * the HTML. Question classes should only be responsible for data and rendering as are reused in the
9
43
  * server side.
10
44
  */
11
- export class Question {
12
- static PATH = 'preview-components/';
13
-
45
+ export class Question extends PreviewComponent {
14
46
  /**
15
- * @type {string}
16
- * @protected
47
+ * @type {ComponentType}
17
48
  */
18
- _questionTemplate = Question.PATH + 'textfield.njk';
49
+ componentType = ComponentType.TextField;
50
+
19
51
  /**
20
- * @type { string|null }
52
+ * @type {string}
21
53
  * @protected
22
54
  */
23
- _highlight = null;
55
+ _questionTemplate = PreviewComponent.PATH + 'textfield.njk';
24
56
  /**
25
57
  * @type {string}
26
58
  * @protected
27
59
  */
28
60
  _fieldName = 'inputField';
29
- /**
30
- * @type {QuestionRenderer}
31
- * @protected
32
- */
33
- _questionRenderer;
34
-
35
- /**
36
- * @type {QuestionElements}
37
- * @private
38
- */
39
- _htmlElements;
40
61
 
41
62
  /**
42
63
  * @param {QuestionElements} htmlElements
43
64
  * @param {QuestionRenderer} questionRenderer
44
65
  */
45
66
  constructor(htmlElements, questionRenderer) {
67
+ super(htmlElements, questionRenderer);
46
68
  const {
47
- question,
48
- hintText,
49
- optional
69
+ hintText
50
70
  } = htmlElements.values;
51
-
52
- /**
53
- * @type {QuestionElements}
54
- * @protected
55
- */
56
- this._htmlElements = htmlElements;
57
- /**
58
- * @type {string}
59
- * @private
60
- */
61
- this._question = question;
62
71
  /**
63
72
  * @type {string}
64
73
  * @private
65
74
  */
66
75
  this._hintText = hintText;
67
- /**
68
- * @type {boolean}
69
- * @private
70
- */
71
- this._optional = optional;
72
- /**
73
- *
74
- * @type {QuestionRenderer}
75
- * @protected
76
- */
77
- this._questionRenderer = questionRenderer;
78
- }
79
-
80
- /**
81
- * @param {string} element
82
- * @returns {string}
83
- * @protected
84
- */
85
- getHighlight(element) {
86
- return this._highlight === element ? ' highlight' : '';
87
- }
88
- get titleText() {
89
- const optionalText = this._optional ? ' (optional)' : '';
90
- return (!this._question ? 'Question' : this._question) + optionalText;
91
- }
92
-
93
- /**
94
- * @protected
95
- * @type {DefaultComponent}
96
- */
97
- get label() {
98
- return {
99
- text: this.titleText,
100
- classes: 'govuk-label--l' + this.getHighlight('question')
101
- };
102
- }
103
-
104
- /**
105
- * @protected
106
- * @type {GovukFieldset}
107
- */
108
- get fieldSet() {
109
- return {
110
- legend: {
111
- text: this.titleText,
112
- classes: 'govuk-fieldset__legend--l' + this.getHighlight('question')
113
- }
114
- };
115
76
  }
116
77
 
117
78
  /**
@@ -127,42 +88,16 @@ export class Question {
127
88
  }
128
89
 
129
90
  /**
130
- * @returns {Partial<QuestionBaseModel>}
131
- */
132
- get customRenderFields() {
133
- return {};
134
- }
135
-
136
- /**
137
- * @type {QuestionBaseModel}
91
+ * @returns {QuestionBaseModel}
92
+ * @protected
138
93
  */
139
- get renderInput() {
94
+ _renderInput() {
140
95
  return {
141
- id: this._fieldName,
142
- name: this._fieldName,
96
+ ...super._renderInput(),
143
97
  label: this.label,
144
- hint: this.hint,
145
- ...this.customRenderFields
98
+ hint: this.hint
146
99
  };
147
100
  }
148
- render() {
149
- this._questionRenderer.render(this._questionTemplate, this.renderInput);
150
- }
151
-
152
- /**
153
- * @type {string}
154
- */
155
- get question() {
156
- return this._question;
157
- }
158
-
159
- /**
160
- * @param {string} value
161
- */
162
- set question(value) {
163
- this._question = value;
164
- this.render();
165
- }
166
101
 
167
102
  /**
168
103
  * @type {string}
@@ -178,36 +113,11 @@ export class Question {
178
113
  this._hintText = value;
179
114
  this.render();
180
115
  }
181
- get optional() {
182
- return this._optional;
183
- }
184
-
185
- /**
186
- * @param {boolean} value
187
- */
188
- set optional(value) {
189
- this._optional = value;
190
- this.render();
191
- }
192
-
193
- /**
194
- * @type {string | null}
195
- */
196
- get highlight() {
197
- return this._highlight;
198
- }
199
-
200
- /**
201
- * @param {string | null} value
202
- */
203
- set highlight(value) {
204
- this._highlight = value;
205
- this.render();
206
- }
207
116
  }
208
117
 
209
118
  /**
210
119
  * @import { ListenerRow, BaseSettings, QuestionElements, QuestionBaseModel, GovukFieldset, DefaultComponent, QuestionRenderer } from '~/src/form/form-editor/preview/types.js'
120
+ * @import { FormComponentsDef, ContentComponentsDef, ComponentDef } from '~/src/components/types.js'
211
121
  * @import { ListElement, ListItemReadonly } from '~/src/form/form-editor/types.js'
212
122
  */
213
123
  //# sourceMappingURL=question.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"question.js","names":["Question","PATH","_questionTemplate","_highlight","_fieldName","_questionRenderer","_htmlElements","constructor","htmlElements","questionRenderer","question","hintText","optional","values","_question","_hintText","_optional","getHighlight","element","titleText","optionalText","label","text","classes","fieldSet","legend","hint","length","customRenderFields","renderInput","id","name","render","value","highlight"],"sources":["../../../../../src/form/form-editor/preview/question.js"],"sourcesContent":["/**\n * @class Question\n * @classdesc\n * A data object that has access to the underlying data via the QuestionElements object interface\n * and the templating mechanism to render the HTML for the data.\n *\n * It does not have access to the DOM, but has access to QuestionElements.setPreviewHTML to update\n * the HTML. Question classes should only be responsible for data and rendering as are reused in the\n * server side.\n */\nexport class Question {\n static PATH = 'preview-components/'\n\n /**\n * @type {string}\n * @protected\n */\n _questionTemplate = Question.PATH + 'textfield.njk'\n /**\n * @type { string|null }\n * @protected\n */\n _highlight = null\n /**\n * @type {string}\n * @protected\n */\n _fieldName = 'inputField'\n /**\n * @type {QuestionRenderer}\n * @protected\n */\n _questionRenderer\n\n /**\n * @type {QuestionElements}\n * @private\n */\n _htmlElements\n\n /**\n * @param {QuestionElements} htmlElements\n * @param {QuestionRenderer} questionRenderer\n */\n constructor(htmlElements, questionRenderer) {\n const { question, hintText, optional } = htmlElements.values\n\n /**\n * @type {QuestionElements}\n * @protected\n */\n this._htmlElements = htmlElements\n /**\n * @type {string}\n * @private\n */\n this._question = question\n /**\n * @type {string}\n * @private\n */\n this._hintText = hintText\n /**\n * @type {boolean}\n * @private\n */\n this._optional = optional\n /**\n *\n * @type {QuestionRenderer}\n * @protected\n */\n this._questionRenderer = questionRenderer\n }\n\n /**\n * @param {string} element\n * @returns {string}\n * @protected\n */\n getHighlight(element) {\n return this._highlight === element ? ' highlight' : ''\n }\n\n get titleText() {\n const optionalText = this._optional ? ' (optional)' : ''\n return (!this._question ? 'Question' : this._question) + optionalText\n }\n\n /**\n * @protected\n * @type {DefaultComponent}\n */\n get label() {\n return {\n text: this.titleText,\n classes: 'govuk-label--l' + this.getHighlight('question')\n }\n }\n\n /**\n * @protected\n * @type {GovukFieldset}\n */\n get fieldSet() {\n return {\n legend: {\n text: this.titleText,\n classes: 'govuk-fieldset__legend--l' + this.getHighlight('question')\n }\n }\n }\n\n /**\n * @type {DefaultComponent}\n * @protected\n */\n get hint() {\n const text =\n this._highlight === 'hintText' && !this._hintText.length\n ? 'Hint text'\n : this._hintText\n\n return {\n text,\n classes: this.getHighlight('hintText')\n }\n }\n\n /**\n * @returns {Partial<QuestionBaseModel>}\n */\n get customRenderFields() {\n return {}\n }\n\n /**\n * @type {QuestionBaseModel}\n */\n get renderInput() {\n return {\n id: this._fieldName,\n name: this._fieldName,\n label: this.label,\n hint: this.hint,\n ...this.customRenderFields\n }\n }\n\n render() {\n this._questionRenderer.render(this._questionTemplate, this.renderInput)\n }\n\n /**\n * @type {string}\n */\n get question() {\n return this._question\n }\n\n /**\n * @param {string} value\n */\n set question(value) {\n this._question = value\n this.render()\n }\n\n /**\n * @type {string}\n */\n get hintText() {\n return this._hintText\n }\n\n /**\n * @param {string} value\n */\n set hintText(value) {\n this._hintText = value\n this.render()\n }\n\n get optional() {\n return this._optional\n }\n\n /**\n * @param {boolean} value\n */\n set optional(value) {\n this._optional = value\n this.render()\n }\n\n /**\n * @type {string | null}\n */\n get highlight() {\n return this._highlight\n }\n\n /**\n * @param {string | null} value\n */\n set highlight(value) {\n this._highlight = value\n this.render()\n }\n}\n\n/**\n * @import { ListenerRow, BaseSettings, QuestionElements, QuestionBaseModel, GovukFieldset, DefaultComponent, QuestionRenderer } from '~/src/form/form-editor/preview/types.js'\n * @import { ListElement, ListItemReadonly } from '~/src/form/form-editor/types.js'\n */\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMA,QAAQ,CAAC;EACpB,OAAOC,IAAI,GAAG,qBAAqB;;EAEnC;AACF;AACA;AACA;EACEC,iBAAiB,GAAGF,QAAQ,CAACC,IAAI,GAAG,eAAe;EACnD;AACF;AACA;AACA;EACEE,UAAU,GAAG,IAAI;EACjB;AACF;AACA;AACA;EACEC,UAAU,GAAG,YAAY;EACzB;AACF;AACA;AACA;EACEC,iBAAiB;;EAEjB;AACF;AACA;AACA;EACEC,aAAa;;EAEb;AACF;AACA;AACA;EACEC,WAAWA,CAACC,YAAY,EAAEC,gBAAgB,EAAE;IAC1C,MAAM;MAAEC,QAAQ;MAAEC,QAAQ;MAAEC;IAAS,CAAC,GAAGJ,YAAY,CAACK,MAAM;;IAE5D;AACJ;AACA;AACA;IACI,IAAI,CAACP,aAAa,GAAGE,YAAY;IACjC;AACJ;AACA;AACA;IACI,IAAI,CAACM,SAAS,GAAGJ,QAAQ;IACzB;AACJ;AACA;AACA;IACI,IAAI,CAACK,SAAS,GAAGJ,QAAQ;IACzB;AACJ;AACA;AACA;IACI,IAAI,CAACK,SAAS,GAAGJ,QAAQ;IACzB;AACJ;AACA;AACA;AACA;IACI,IAAI,CAACP,iBAAiB,GAAGI,gBAAgB;EAC3C;;EAEA;AACF;AACA;AACA;AACA;EACEQ,YAAYA,CAACC,OAAO,EAAE;IACpB,OAAO,IAAI,CAACf,UAAU,KAAKe,OAAO,GAAG,YAAY,GAAG,EAAE;EACxD;EAEA,IAAIC,SAASA,CAAA,EAAG;IACd,MAAMC,YAAY,GAAG,IAAI,CAACJ,SAAS,GAAG,aAAa,GAAG,EAAE;IACxD,OAAO,CAAC,CAAC,IAAI,CAACF,SAAS,GAAG,UAAU,GAAG,IAAI,CAACA,SAAS,IAAIM,YAAY;EACvE;;EAEA;AACF;AACA;AACA;EACE,IAAIC,KAAKA,CAAA,EAAG;IACV,OAAO;MACLC,IAAI,EAAE,IAAI,CAACH,SAAS;MACpBI,OAAO,EAAE,gBAAgB,GAAG,IAAI,CAACN,YAAY,CAAC,UAAU;IAC1D,CAAC;EACH;;EAEA;AACF;AACA;AACA;EACE,IAAIO,QAAQA,CAAA,EAAG;IACb,OAAO;MACLC,MAAM,EAAE;QACNH,IAAI,EAAE,IAAI,CAACH,SAAS;QACpBI,OAAO,EAAE,2BAA2B,GAAG,IAAI,CAACN,YAAY,CAAC,UAAU;MACrE;IACF,CAAC;EACH;;EAEA;AACF;AACA;AACA;EACE,IAAIS,IAAIA,CAAA,EAAG;IACT,MAAMJ,IAAI,GACR,IAAI,CAACnB,UAAU,KAAK,UAAU,IAAI,CAAC,IAAI,CAACY,SAAS,CAACY,MAAM,GACpD,WAAW,GACX,IAAI,CAACZ,SAAS;IAEpB,OAAO;MACLO,IAAI;MACJC,OAAO,EAAE,IAAI,CAACN,YAAY,CAAC,UAAU;IACvC,CAAC;EACH;;EAEA;AACF;AACA;EACE,IAAIW,kBAAkBA,CAAA,EAAG;IACvB,OAAO,CAAC,CAAC;EACX;;EAEA;AACF;AACA;EACE,IAAIC,WAAWA,CAAA,EAAG;IAChB,OAAO;MACLC,EAAE,EAAE,IAAI,CAAC1B,UAAU;MACnB2B,IAAI,EAAE,IAAI,CAAC3B,UAAU;MACrBiB,KAAK,EAAE,IAAI,CAACA,KAAK;MACjBK,IAAI,EAAE,IAAI,CAACA,IAAI;MACf,GAAG,IAAI,CAACE;IACV,CAAC;EACH;EAEAI,MAAMA,CAAA,EAAG;IACP,IAAI,CAAC3B,iBAAiB,CAAC2B,MAAM,CAAC,IAAI,CAAC9B,iBAAiB,EAAE,IAAI,CAAC2B,WAAW,CAAC;EACzE;;EAEA;AACF;AACA;EACE,IAAInB,QAAQA,CAAA,EAAG;IACb,OAAO,IAAI,CAACI,SAAS;EACvB;;EAEA;AACF;AACA;EACE,IAAIJ,QAAQA,CAACuB,KAAK,EAAE;IAClB,IAAI,CAACnB,SAAS,GAAGmB,KAAK;IACtB,IAAI,CAACD,MAAM,CAAC,CAAC;EACf;;EAEA;AACF;AACA;EACE,IAAIrB,QAAQA,CAAA,EAAG;IACb,OAAO,IAAI,CAACI,SAAS;EACvB;;EAEA;AACF;AACA;EACE,IAAIJ,QAAQA,CAACsB,KAAK,EAAE;IAClB,IAAI,CAAClB,SAAS,GAAGkB,KAAK;IACtB,IAAI,CAACD,MAAM,CAAC,CAAC;EACf;EAEA,IAAIpB,QAAQA,CAAA,EAAG;IACb,OAAO,IAAI,CAACI,SAAS;EACvB;;EAEA;AACF;AACA;EACE,IAAIJ,QAAQA,CAACqB,KAAK,EAAE;IAClB,IAAI,CAACjB,SAAS,GAAGiB,KAAK;IACtB,IAAI,CAACD,MAAM,CAAC,CAAC;EACf;;EAEA;AACF;AACA;EACE,IAAIE,SAASA,CAAA,EAAG;IACd,OAAO,IAAI,CAAC/B,UAAU;EACxB;;EAEA;AACF;AACA;EACE,IAAI+B,SAASA,CAACD,KAAK,EAAE;IACnB,IAAI,CAAC9B,UAAU,GAAG8B,KAAK;IACvB,IAAI,CAACD,MAAM,CAAC,CAAC;EACf;AACF;;AAEA;AACA;AACA;AACA","ignoreList":[]}
1
+ {"version":3,"file":"question.js","names":["ComponentType","ComponentElements","PreviewComponent","QuestionComponentElements","_component","constructor","component","_getValues","hintText","hint","shortDesc","shortDescription","Question","componentType","TextField","_questionTemplate","PATH","_fieldName","htmlElements","questionRenderer","values","_hintText","text","_highlight","length","classes","getHighlight","_renderInput","label","value","render"],"sources":["../../../../../src/form/form-editor/preview/question.js"],"sourcesContent":["import { ComponentType } from '~/src/components/enums.js'\nimport { ComponentElements } from '~/src/form/form-editor/preview/component-elements.js'\nimport { PreviewComponent } from '~/src/form/form-editor/preview/preview.js'\n\n/**\n * @implements {QuestionElements}\n */\nexport class QuestionComponentElements extends ComponentElements {\n /**\n * @type {FormComponentsDef}\n * @protected\n */\n _component\n /**\n * @param {FormComponentsDef} component\n */\n constructor(component) {\n super(component)\n this._component = component\n }\n\n /**\n * @protected\n * @returns {BaseSettings}\n */\n _getValues() {\n return {\n ...super._getValues(),\n hintText: this._component.hint ?? '',\n shortDesc: this._component.shortDescription ?? ''\n }\n }\n}\n\n/**\n * @class Question\n * @classdesc\n * A data object that has access to the underlying data via the QuestionElements object interface\n * and the templating mechanism to render the HTML for the data.\n *\n * It does not have access to the DOM, but has access to QuestionElements.setPreviewHTML to update\n * the HTML. Question classes should only be responsible for data and rendering as are reused in the\n * server side.\n */\nexport class Question extends PreviewComponent {\n /**\n * @type {ComponentType}\n */\n componentType = ComponentType.TextField\n\n /**\n * @type {string}\n * @protected\n */\n _questionTemplate = PreviewComponent.PATH + 'textfield.njk'\n /**\n * @type {string}\n * @protected\n */\n _fieldName = 'inputField'\n\n /**\n * @param {QuestionElements} htmlElements\n * @param {QuestionRenderer} questionRenderer\n */\n constructor(htmlElements, questionRenderer) {\n super(htmlElements, questionRenderer)\n const { hintText } = htmlElements.values\n /**\n * @type {string}\n * @private\n */\n this._hintText = hintText\n }\n\n /**\n * @type {DefaultComponent}\n * @protected\n */\n get hint() {\n const text =\n this._highlight === 'hintText' && !this._hintText.length\n ? 'Hint text'\n : this._hintText\n\n return {\n text,\n classes: this.getHighlight('hintText')\n }\n }\n\n /**\n * @returns {QuestionBaseModel}\n * @protected\n */\n _renderInput() {\n return { ...super._renderInput(), label: this.label, hint: this.hint }\n }\n\n /**\n * @type {string}\n */\n get hintText() {\n return this._hintText\n }\n\n /**\n * @param {string} value\n */\n set hintText(value) {\n this._hintText = value\n this.render()\n }\n}\n\n/**\n * @import { ListenerRow, BaseSettings, QuestionElements, QuestionBaseModel, GovukFieldset, DefaultComponent, QuestionRenderer } from '~/src/form/form-editor/preview/types.js'\n * @import { FormComponentsDef, ContentComponentsDef, ComponentDef } from '~/src/components/types.js'\n * @import { ListElement, ListItemReadonly } from '~/src/form/form-editor/types.js'\n */\n"],"mappings":"AAAA,SAASA,aAAa;AACtB,SAASC,iBAAiB;AAC1B,SAASC,gBAAgB;;AAEzB;AACA;AACA;AACA,OAAO,MAAMC,yBAAyB,SAASF,iBAAiB,CAAC;EAC/D;AACF;AACA;AACA;EACEG,UAAU;EACV;AACF;AACA;EACEC,WAAWA,CAACC,SAAS,EAAE;IACrB,KAAK,CAACA,SAAS,CAAC;IAChB,IAAI,CAACF,UAAU,GAAGE,SAAS;EAC7B;;EAEA;AACF;AACA;AACA;EACEC,UAAUA,CAAA,EAAG;IACX,OAAO;MACL,GAAG,KAAK,CAACA,UAAU,CAAC,CAAC;MACrBC,QAAQ,EAAE,IAAI,CAACJ,UAAU,CAACK,IAAI,IAAI,EAAE;MACpCC,SAAS,EAAE,IAAI,CAACN,UAAU,CAACO,gBAAgB,IAAI;IACjD,CAAC;EACH;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,QAAQ,SAASV,gBAAgB,CAAC;EAC7C;AACF;AACA;EACEW,aAAa,GAAGb,aAAa,CAACc,SAAS;;EAEvC;AACF;AACA;AACA;EACEC,iBAAiB,GAAGb,gBAAgB,CAACc,IAAI,GAAG,eAAe;EAC3D;AACF;AACA;AACA;EACEC,UAAU,GAAG,YAAY;;EAEzB;AACF;AACA;AACA;EACEZ,WAAWA,CAACa,YAAY,EAAEC,gBAAgB,EAAE;IAC1C,KAAK,CAACD,YAAY,EAAEC,gBAAgB,CAAC;IACrC,MAAM;MAAEX;IAAS,CAAC,GAAGU,YAAY,CAACE,MAAM;IACxC;AACJ;AACA;AACA;IACI,IAAI,CAACC,SAAS,GAAGb,QAAQ;EAC3B;;EAEA;AACF;AACA;AACA;EACE,IAAIC,IAAIA,CAAA,EAAG;IACT,MAAMa,IAAI,GACR,IAAI,CAACC,UAAU,KAAK,UAAU,IAAI,CAAC,IAAI,CAACF,SAAS,CAACG,MAAM,GACpD,WAAW,GACX,IAAI,CAACH,SAAS;IAEpB,OAAO;MACLC,IAAI;MACJG,OAAO,EAAE,IAAI,CAACC,YAAY,CAAC,UAAU;IACvC,CAAC;EACH;;EAEA;AACF;AACA;AACA;EACEC,YAAYA,CAAA,EAAG;IACb,OAAO;MAAE,GAAG,KAAK,CAACA,YAAY,CAAC,CAAC;MAAEC,KAAK,EAAE,IAAI,CAACA,KAAK;MAAEnB,IAAI,EAAE,IAAI,CAACA;IAAK,CAAC;EACxE;;EAEA;AACF;AACA;EACE,IAAID,QAAQA,CAAA,EAAG;IACb,OAAO,IAAI,CAACa,SAAS;EACvB;;EAEA;AACF;AACA;EACE,IAAIb,QAAQA,CAACqB,KAAK,EAAE;IAClB,IAAI,CAACR,SAAS,GAAGQ,KAAK;IACtB,IAAI,CAACC,MAAM,CAAC,CAAC;EACf;AACF;;AAEA;AACA;AACA;AACA;AACA","ignoreList":[]}
@@ -1,6 +1,11 @@
1
+ import { ComponentType } from "../../../components/enums.js";
1
2
  import { ListSortableQuestion } from "./list-sortable.js";
2
- import { Question } from "../../../index.js";
3
+ import { PreviewComponent } from "./preview.js";
3
4
  export class RadioSortableQuestion extends ListSortableQuestion {
4
- _questionTemplate = Question.PATH + 'radios.njk';
5
+ _questionTemplate = PreviewComponent.PATH + 'radios.njk';
6
+ /**
7
+ * @type {ComponentType}
8
+ */
9
+ componentType = ComponentType.RadiosField;
5
10
  }
6
11
  //# sourceMappingURL=radio-sortable.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"radio-sortable.js","names":["ListSortableQuestion","Question","RadioSortableQuestion","_questionTemplate","PATH"],"sources":["../../../../../src/form/form-editor/preview/radio-sortable.js"],"sourcesContent":["import { ListSortableQuestion } from '~/src/form/form-editor/preview/list-sortable.js'\nimport { Question } from '~/src/index.js'\n\nexport class RadioSortableQuestion extends ListSortableQuestion {\n _questionTemplate = Question.PATH + 'radios.njk'\n}\n"],"mappings":"AAAA,SAASA,oBAAoB;AAC7B,SAASC,QAAQ;AAEjB,OAAO,MAAMC,qBAAqB,SAASF,oBAAoB,CAAC;EAC9DG,iBAAiB,GAAGF,QAAQ,CAACG,IAAI,GAAG,YAAY;AAClD","ignoreList":[]}
1
+ {"version":3,"file":"radio-sortable.js","names":["ComponentType","ListSortableQuestion","PreviewComponent","RadioSortableQuestion","_questionTemplate","PATH","componentType","RadiosField"],"sources":["../../../../../src/form/form-editor/preview/radio-sortable.js"],"sourcesContent":["import { ComponentType } from '~/src/components/enums.js'\nimport { ListSortableQuestion } from '~/src/form/form-editor/preview/list-sortable.js'\nimport { PreviewComponent } from '~/src/form/form-editor/preview/preview.js'\n\nexport class RadioSortableQuestion extends ListSortableQuestion {\n _questionTemplate = PreviewComponent.PATH + 'radios.njk'\n /**\n * @type {ComponentType}\n */\n componentType = ComponentType.RadiosField\n}\n"],"mappings":"AAAA,SAASA,aAAa;AACtB,SAASC,oBAAoB;AAC7B,SAASC,gBAAgB;AAEzB,OAAO,MAAMC,qBAAqB,SAASF,oBAAoB,CAAC;EAC9DG,iBAAiB,GAAGF,gBAAgB,CAACG,IAAI,GAAG,YAAY;EACxD;AACF;AACA;EACEC,aAAa,GAAGN,aAAa,CAACO,WAAW;AAC3C","ignoreList":[]}
@@ -1,6 +1,11 @@
1
+ import { ComponentType } from "../../../components/enums.js";
1
2
  import { ListQuestion } from "./list.js";
2
- import { Question } from "../../../index.js";
3
+ import { PreviewComponent } from "./preview.js";
3
4
  export class RadioQuestion extends ListQuestion {
4
- _questionTemplate = Question.PATH + 'radios.njk';
5
+ /**
6
+ * @type {ComponentType}
7
+ */
8
+ componentType = ComponentType.RadiosField;
9
+ _questionTemplate = PreviewComponent.PATH + 'radios.njk';
5
10
  }
6
11
  //# sourceMappingURL=radio.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"radio.js","names":["ListQuestion","Question","RadioQuestion","_questionTemplate","PATH"],"sources":["../../../../../src/form/form-editor/preview/radio.js"],"sourcesContent":["import { ListQuestion } from '~/src/form/form-editor/preview/list.js'\nimport { Question } from '~/src/index.js'\n\nexport class RadioQuestion extends ListQuestion {\n _questionTemplate = Question.PATH + 'radios.njk'\n}\n"],"mappings":"AAAA,SAASA,YAAY;AACrB,SAASC,QAAQ;AAEjB,OAAO,MAAMC,aAAa,SAASF,YAAY,CAAC;EAC9CG,iBAAiB,GAAGF,QAAQ,CAACG,IAAI,GAAG,YAAY;AAClD","ignoreList":[]}
1
+ {"version":3,"file":"radio.js","names":["ComponentType","ListQuestion","PreviewComponent","RadioQuestion","componentType","RadiosField","_questionTemplate","PATH"],"sources":["../../../../../src/form/form-editor/preview/radio.js"],"sourcesContent":["import { ComponentType } from '~/src/components/enums.js'\nimport { ListQuestion } from '~/src/form/form-editor/preview/list.js'\nimport { PreviewComponent } from '~/src/form/form-editor/preview/preview.js'\n\nexport class RadioQuestion extends ListQuestion {\n /**\n * @type {ComponentType}\n */\n componentType = ComponentType.RadiosField\n _questionTemplate = PreviewComponent.PATH + 'radios.njk'\n}\n"],"mappings":"AAAA,SAASA,aAAa;AACtB,SAASC,YAAY;AACrB,SAASC,gBAAgB;AAEzB,OAAO,MAAMC,aAAa,SAASF,YAAY,CAAC;EAC9C;AACF;AACA;EACEG,aAAa,GAAGJ,aAAa,CAACK,WAAW;EACzCC,iBAAiB,GAAGJ,gBAAgB,CAACK,IAAI,GAAG,YAAY;AAC1D","ignoreList":[]}
@@ -0,0 +1,38 @@
1
+ import { ListSortableQuestion } from "./list-sortable.js";
2
+ import { PreviewComponent } from "./preview.js";
3
+ import { ComponentType } from "../../../index.js";
4
+ export class SelectSortableQuestion extends ListSortableQuestion {
5
+ _questionTemplate = PreviewComponent.PATH + 'selectfield.njk';
6
+ get selectList() {
7
+ return this.list.length ? [{
8
+ id: '',
9
+ value: '',
10
+ text: ' '
11
+ }, ...this.list] : this.list;
12
+ }
13
+
14
+ /**
15
+ * @type {ComponentType}
16
+ */
17
+ componentType = ComponentType.SelectField;
18
+ get renderInput() {
19
+ const afterInput = /** @type {{ formGroup?: { afterInputs: { html: string } } }} */
20
+ this.list.length ? {} : {
21
+ formGroup: {
22
+ afterInput: {
23
+ html: this._listElements.afterInputsHTML
24
+ }
25
+ }
26
+ };
27
+ return {
28
+ id: this._fieldName,
29
+ name: this._fieldName,
30
+ hint: this.hint,
31
+ label: this.label,
32
+ items: this.selectList,
33
+ classes: this.list.length ? '' : 'govuk-visually-hidden',
34
+ ...afterInput
35
+ };
36
+ }
37
+ }
38
+ //# sourceMappingURL=select-sortable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"select-sortable.js","names":["ListSortableQuestion","PreviewComponent","ComponentType","SelectSortableQuestion","_questionTemplate","PATH","selectList","list","length","id","value","text","componentType","SelectField","renderInput","afterInput","formGroup","html","_listElements","afterInputsHTML","_fieldName","name","hint","label","items","classes"],"sources":["../../../../../src/form/form-editor/preview/select-sortable.js"],"sourcesContent":["import { ListSortableQuestion } from '~/src/form/form-editor/preview/list-sortable.js'\nimport { PreviewComponent } from '~/src/form/form-editor/preview/preview.js'\nimport { ComponentType } from '~/src/index.js'\n\nexport class SelectSortableQuestion extends ListSortableQuestion {\n _questionTemplate = PreviewComponent.PATH + 'selectfield.njk'\n\n get selectList() {\n return this.list.length\n ? [{ id: '', value: '', text: ' ' }, ...this.list]\n : this.list\n }\n\n /**\n * @type {ComponentType}\n */\n componentType = ComponentType.SelectField\n\n get renderInput() {\n const afterInput =\n /** @type {{ formGroup?: { afterInputs: { html: string } } }} */ (\n this.list.length\n ? {}\n : {\n formGroup: {\n afterInput: {\n html: this._listElements.afterInputsHTML\n }\n }\n }\n )\n\n return {\n id: this._fieldName,\n name: this._fieldName,\n hint: this.hint,\n label: this.label,\n items: this.selectList,\n classes: this.list.length ? '' : 'govuk-visually-hidden',\n ...afterInput\n }\n }\n}\n"],"mappings":"AAAA,SAASA,oBAAoB;AAC7B,SAASC,gBAAgB;AACzB,SAASC,aAAa;AAEtB,OAAO,MAAMC,sBAAsB,SAASH,oBAAoB,CAAC;EAC/DI,iBAAiB,GAAGH,gBAAgB,CAACI,IAAI,GAAG,iBAAiB;EAE7D,IAAIC,UAAUA,CAAA,EAAG;IACf,OAAO,IAAI,CAACC,IAAI,CAACC,MAAM,GACnB,CAAC;MAAEC,EAAE,EAAE,EAAE;MAAEC,KAAK,EAAE,EAAE;MAAEC,IAAI,EAAE;IAAI,CAAC,EAAE,GAAG,IAAI,CAACJ,IAAI,CAAC,GAChD,IAAI,CAACA,IAAI;EACf;;EAEA;AACF;AACA;EACEK,aAAa,GAAGV,aAAa,CAACW,WAAW;EAEzC,IAAIC,WAAWA,CAAA,EAAG;IAChB,MAAMC,UAAU,GACd;IACE,IAAI,CAACR,IAAI,CAACC,MAAM,GACZ,CAAC,CAAC,GACF;MACEQ,SAAS,EAAE;QACTD,UAAU,EAAE;UACVE,IAAI,EAAE,IAAI,CAACC,aAAa,CAACC;QAC3B;MACF;IACF,CACL;IAEH,OAAO;MACLV,EAAE,EAAE,IAAI,CAACW,UAAU;MACnBC,IAAI,EAAE,IAAI,CAACD,UAAU;MACrBE,IAAI,EAAE,IAAI,CAACA,IAAI;MACfC,KAAK,EAAE,IAAI,CAACA,KAAK;MACjBC,KAAK,EAAE,IAAI,CAAClB,UAAU;MACtBmB,OAAO,EAAE,IAAI,CAAClB,IAAI,CAACC,MAAM,GAAG,EAAE,GAAG,uBAAuB;MACxD,GAAGO;IACL,CAAC;EACH;AACF","ignoreList":[]}
@@ -0,0 +1,11 @@
1
+ import { ComponentType } from "../../../components/enums.js";
2
+ import { ListQuestion } from "./list.js";
3
+ import { PreviewComponent } from "./preview.js";
4
+ export class SelectQuestion extends ListQuestion {
5
+ _questionTemplate = PreviewComponent.PATH + 'selectfield.njk';
6
+ /**
7
+ * @type {ComponentType}
8
+ */
9
+ componentType = ComponentType.SelectField;
10
+ }
11
+ //# sourceMappingURL=select.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"select.js","names":["ComponentType","ListQuestion","PreviewComponent","SelectQuestion","_questionTemplate","PATH","componentType","SelectField"],"sources":["../../../../../src/form/form-editor/preview/select.js"],"sourcesContent":["import { ComponentType } from '~/src/components/enums.js'\nimport { ListQuestion } from '~/src/form/form-editor/preview/list.js'\nimport { PreviewComponent } from '~/src/form/form-editor/preview/preview.js'\n\nexport class SelectQuestion extends ListQuestion {\n _questionTemplate = PreviewComponent.PATH + 'selectfield.njk'\n /**\n * @type {ComponentType}\n */\n componentType = ComponentType.SelectField\n}\n"],"mappings":"AAAA,SAASA,aAAa;AACtB,SAASC,YAAY;AACrB,SAASC,gBAAgB;AAEzB,OAAO,MAAMC,cAAc,SAASF,YAAY,CAAC;EAC/CG,iBAAiB,GAAGF,gBAAgB,CAACG,IAAI,GAAG,iBAAiB;EAC7D;AACF;AACA;EACEC,aAAa,GAAGN,aAAa,CAACO,WAAW;AAC3C","ignoreList":[]}
@@ -1,3 +1,9 @@
1
+ import { ComponentType } from "../../../components/enums.js";
1
2
  import { Question } from "./question.js";
2
- export class ShortAnswerQuestion extends Question {}
3
+ export class ShortAnswerQuestion extends Question {
4
+ /**
5
+ * @type {ComponentType}
6
+ */
7
+ componentType = ComponentType.TextField;
8
+ }
3
9
  //# sourceMappingURL=short-answer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"short-answer.js","names":["Question","ShortAnswerQuestion"],"sources":["../../../../../src/form/form-editor/preview/short-answer.js"],"sourcesContent":["import { Question } from '~/src/form/form-editor/preview/question.js'\n\nexport class ShortAnswerQuestion extends Question {}\n"],"mappings":"AAAA,SAASA,QAAQ;AAEjB,OAAO,MAAMC,mBAAmB,SAASD,QAAQ,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"short-answer.js","names":["ComponentType","Question","ShortAnswerQuestion","componentType","TextField"],"sources":["../../../../../src/form/form-editor/preview/short-answer.js"],"sourcesContent":["import { ComponentType } from '~/src/components/enums.js'\nimport { Question } from '~/src/form/form-editor/preview/question.js'\n\nexport class ShortAnswerQuestion extends Question {\n /**\n * @type {ComponentType}\n */\n componentType = ComponentType.TextField\n}\n"],"mappings":"AAAA,SAASA,aAAa;AACtB,SAASC,QAAQ;AAEjB,OAAO,MAAMC,mBAAmB,SAASD,QAAQ,CAAC;EAChD;AACF;AACA;EACEE,aAAa,GAAGH,aAAa,CAACI,SAAS;AACzC","ignoreList":[]}
@@ -1,10 +1,16 @@
1
+ import { ComponentType } from "../../../components/enums.js";
2
+ import { PreviewComponent } from "./preview.js";
1
3
  import { Question } from "./question.js";
2
4
  export class SupportingEvidenceQuestion extends Question {
5
+ /**
6
+ * @type {ComponentType}
7
+ */
8
+ componentType = ComponentType.FileUploadField;
3
9
  /**
4
10
  * @type {string}
5
11
  * @protected
6
12
  */
7
- _questionTemplate = Question.PATH + 'fileuploadfield.njk';
13
+ _questionTemplate = PreviewComponent.PATH + 'fileuploadfield.njk';
8
14
  /**
9
15
  * @type {string}
10
16
  * @protected
@@ -1 +1 @@
1
- {"version":3,"file":"supporting-evidence.js","names":["Question","SupportingEvidenceQuestion","_questionTemplate","PATH","_fieldName"],"sources":["../../../../../src/form/form-editor/preview/supporting-evidence.js"],"sourcesContent":["import { Question } from '~/src/form/form-editor/preview/question.js'\n\nexport class SupportingEvidenceQuestion extends Question {\n /**\n * @type {string}\n * @protected\n */\n _questionTemplate = Question.PATH + 'fileuploadfield.njk'\n /**\n * @type {string}\n * @protected\n */\n _fieldName = 'supportingEvidence'\n}\n"],"mappings":"AAAA,SAASA,QAAQ;AAEjB,OAAO,MAAMC,0BAA0B,SAASD,QAAQ,CAAC;EACvD;AACF;AACA;AACA;EACEE,iBAAiB,GAAGF,QAAQ,CAACG,IAAI,GAAG,qBAAqB;EACzD;AACF;AACA;AACA;EACEC,UAAU,GAAG,oBAAoB;AACnC","ignoreList":[]}
1
+ {"version":3,"file":"supporting-evidence.js","names":["ComponentType","PreviewComponent","Question","SupportingEvidenceQuestion","componentType","FileUploadField","_questionTemplate","PATH","_fieldName"],"sources":["../../../../../src/form/form-editor/preview/supporting-evidence.js"],"sourcesContent":["import { ComponentType } from '~/src/components/enums.js'\nimport { PreviewComponent } from '~/src/form/form-editor/preview/preview.js'\nimport { Question } from '~/src/form/form-editor/preview/question.js'\n\nexport class SupportingEvidenceQuestion extends Question {\n /**\n * @type {ComponentType}\n */\n componentType = ComponentType.FileUploadField\n /**\n * @type {string}\n * @protected\n */\n _questionTemplate = PreviewComponent.PATH + 'fileuploadfield.njk'\n /**\n * @type {string}\n * @protected\n */\n _fieldName = 'supportingEvidence'\n}\n"],"mappings":"AAAA,SAASA,aAAa;AACtB,SAASC,gBAAgB;AACzB,SAASC,QAAQ;AAEjB,OAAO,MAAMC,0BAA0B,SAASD,QAAQ,CAAC;EACvD;AACF;AACA;EACEE,aAAa,GAAGJ,aAAa,CAACK,eAAe;EAC7C;AACF;AACA;AACA;EACEC,iBAAiB,GAAGL,gBAAgB,CAACM,IAAI,GAAG,qBAAqB;EACjE;AACF;AACA;AACA;EACEC,UAAU,GAAG,oBAAoB;AACnC","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":[],"sources":["../../../../../src/form/form-editor/preview/types.ts"],"sourcesContent":["import { type AutocompleteQuestion } from '~/src/form/form-editor/preview/autocomplete.js'\nimport { type DateInputQuestion } from '~/src/form/form-editor/preview/date-input.js'\nimport { type EmailAddressQuestion } from '~/src/form/form-editor/preview/email-address.js'\nimport { type ListSortableQuestion } from '~/src/form/form-editor/preview/list-sortable.js'\nimport { type LongAnswerQuestion } from '~/src/form/form-editor/preview/long-answer.js'\nimport { type PhoneNumberQuestion } from '~/src/form/form-editor/preview/phone-number.js'\nimport { type Question } from '~/src/form/form-editor/preview/question.js'\nimport { type RadioSortableQuestion } from '~/src/form/form-editor/preview/radio-sortable.js'\nimport { type ShortAnswerQuestion } from '~/src/form/form-editor/preview/short-answer.js'\nimport { type UkAddressQuestion } from '~/src/form/form-editor/preview/uk-address.js'\nimport {\n type DateItem,\n type ListElement,\n type ListItemReadonly\n} from '~/src/form/form-editor/types.js'\n\nexport interface BaseSettings {\n question: string\n hintText: string\n optional: boolean\n shortDesc: string\n items: ListElement[]\n}\n\nexport interface DefaultComponent {\n id?: string\n text: string\n classes: string\n}\n\nexport interface GovukFieldset {\n legend: DefaultComponent\n}\n\nexport interface QuestionBaseModel {\n id?: string\n name?: string\n label?: DefaultComponent\n hint?: DefaultComponent\n fieldset?: GovukFieldset\n readonly items?: ListItemReadonly[] | DateItem[]\n text?: string\n formGroup?: { afterInputs: { html: string } }\n type?: 'text' | 'number' | 'boolean'\n}\n\nexport type ListenerRow = [\n HTMLInputElement | null,\n (target: HTMLInputElement, e: Event) => void,\n keyof HTMLElementEventMap\n]\n\nexport interface QuestionElements {\n readonly values: BaseSettings\n setPreviewHTML(value: string): void\n setPreviewDOM(element: HTMLElement): void\n}\nexport interface AutocompleteElements extends QuestionElements {\n autocompleteOptions: string\n}\n\nexport interface RenderContext {\n model: QuestionBaseModel\n}\n\nexport interface HTMLBuilder {\n buildHTML(questionTemplate: string, renderContext: RenderContext): string\n}\n\nexport interface QuestionRenderer {\n render(questionTemplate: string, questionBaseModel: QuestionBaseModel): void\n}\n\nexport interface ListElements extends QuestionElements {\n afterInputsHTML: string\n}\n\nexport type PreviewQuestion =\n | DateInputQuestion\n | EmailAddressQuestion\n | ListSortableQuestion\n | LongAnswerQuestion\n | PhoneNumberQuestion\n | Question\n | RadioSortableQuestion\n | ShortAnswerQuestion\n | UkAddressQuestion\n | AutocompleteQuestion\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"file":"types.js","names":[],"sources":["../../../../../src/form/form-editor/preview/types.ts"],"sourcesContent":["import {\n type PagePreviewPanelMacro,\n type QuestionBaseModel\n} from '~/src/form/form-editor/macros/types.js'\nimport { type AutocompleteQuestion } from '~/src/form/form-editor/preview/autocomplete.js'\nimport { type DateInputQuestion } from '~/src/form/form-editor/preview/date-input.js'\nimport { type EmailAddressQuestion } from '~/src/form/form-editor/preview/email-address.js'\nimport { type ListSortableQuestion } from '~/src/form/form-editor/preview/list-sortable.js'\nimport { type LongAnswerQuestion } from '~/src/form/form-editor/preview/long-answer.js'\nimport { type PhoneNumberQuestion } from '~/src/form/form-editor/preview/phone-number.js'\nimport { type Question } from '~/src/form/form-editor/preview/question.js'\nimport { type RadioSortableQuestion } from '~/src/form/form-editor/preview/radio-sortable.js'\nimport { type SelectSortableQuestion } from '~/src/form/form-editor/preview/select-sortable.js'\nimport { type ShortAnswerQuestion } from '~/src/form/form-editor/preview/short-answer.js'\nimport { type UkAddressQuestion } from '~/src/form/form-editor/preview/uk-address.js'\nimport { type ListElement } from '~/src/form/form-editor/types.js'\nexport { type QuestionBaseModel } from '~/src/form/form-editor/macros/types.js'\nexport interface BaseSettings {\n question: string\n hintText: string\n optional: boolean\n shortDesc: string\n items: ListElement[]\n content: string\n}\n\nexport interface DefaultComponent {\n id?: string\n text: string\n classes: string\n}\n\nexport interface GovukFieldset {\n legend: DefaultComponent\n}\n\nexport type ListenerRow = [\n HTMLInputElement | null,\n (target: HTMLInputElement, e: Event) => void,\n keyof HTMLElementEventMap\n]\n\nexport interface QuestionElements {\n readonly values: BaseSettings\n setPreviewHTML(value: string): void\n setPreviewDOM(element: HTMLElement): void\n}\nexport interface AutocompleteElements extends QuestionElements {\n autocompleteOptions: string\n}\n\nexport interface RenderContext {\n model: QuestionBaseModel\n}\n\nexport interface HTMLBuilder {\n buildHTML(questionTemplate: string, renderContext: RenderContext): string\n}\n\nexport interface QuestionRenderer {\n render(questionTemplate: string, questionBaseModel: QuestionBaseModel): void\n}\n\nexport interface PageRenderer {\n render(pageTemplate: string, pagePreview: PagePreviewPanelMacro): void\n}\n\nexport interface ListElements extends QuestionElements {\n afterInputsHTML: string\n}\n\nexport interface PageOverviewElements {\n heading: string\n guidance: string\n}\n\nexport type PreviewQuestion =\n | DateInputQuestion\n | EmailAddressQuestion\n | ListSortableQuestion\n | LongAnswerQuestion\n | PhoneNumberQuestion\n | Question\n | RadioSortableQuestion\n | SelectSortableQuestion\n | ShortAnswerQuestion\n | UkAddressQuestion\n | AutocompleteQuestion\n"],"mappings":"","ignoreList":[]}
@@ -1,7 +1,12 @@
1
+ import { ComponentType } from "../../../components/enums.js";
1
2
  import { FieldsetQuestion } from "./fieldset-question.js";
2
- import { Question } from "../../../index.js";
3
+ import { PreviewComponent } from "./preview.js";
3
4
  export class UkAddressQuestion extends FieldsetQuestion {
4
- _questionTemplate = Question.PATH + 'ukaddressfield.njk';
5
+ /**
6
+ * @type {ComponentType}
7
+ */
8
+ componentType = ComponentType.UkAddressField;
9
+ _questionTemplate = PreviewComponent.PATH + 'ukaddressfield.njk';
5
10
  _fieldName = 'addressField';
6
11
  }
7
12
 
@@ -1 +1 @@
1
- {"version":3,"file":"uk-address.js","names":["FieldsetQuestion","Question","UkAddressQuestion","_questionTemplate","PATH","_fieldName"],"sources":["../../../../../src/form/form-editor/preview/uk-address.js"],"sourcesContent":["import { FieldsetQuestion } from '~/src/form/form-editor/preview/fieldset-question.js'\nimport { Question } from '~/src/index.js'\n\nexport class UkAddressQuestion extends FieldsetQuestion {\n _questionTemplate = Question.PATH + 'ukaddressfield.njk'\n _fieldName = 'addressField'\n}\n\n/**\n * @import { QuestionBaseModel } from '~/src/form/form-editor/preview/types.js'\n */\n"],"mappings":"AAAA,SAASA,gBAAgB;AACzB,SAASC,QAAQ;AAEjB,OAAO,MAAMC,iBAAiB,SAASF,gBAAgB,CAAC;EACtDG,iBAAiB,GAAGF,QAAQ,CAACG,IAAI,GAAG,oBAAoB;EACxDC,UAAU,GAAG,cAAc;AAC7B;;AAEA;AACA;AACA","ignoreList":[]}
1
+ {"version":3,"file":"uk-address.js","names":["ComponentType","FieldsetQuestion","PreviewComponent","UkAddressQuestion","componentType","UkAddressField","_questionTemplate","PATH","_fieldName"],"sources":["../../../../../src/form/form-editor/preview/uk-address.js"],"sourcesContent":["import { ComponentType } from '~/src/components/enums.js'\nimport { FieldsetQuestion } from '~/src/form/form-editor/preview/fieldset-question.js'\nimport { PreviewComponent } from '~/src/form/form-editor/preview/preview.js'\n\nexport class UkAddressQuestion extends FieldsetQuestion {\n /**\n * @type {ComponentType}\n */\n componentType = ComponentType.UkAddressField\n _questionTemplate = PreviewComponent.PATH + 'ukaddressfield.njk'\n _fieldName = 'addressField'\n}\n\n/**\n * @import { QuestionBaseModel } from '~/src/form/form-editor/preview/types.js'\n */\n"],"mappings":"AAAA,SAASA,aAAa;AACtB,SAASC,gBAAgB;AACzB,SAASC,gBAAgB;AAEzB,OAAO,MAAMC,iBAAiB,SAASF,gBAAgB,CAAC;EACtD;AACF;AACA;EACEG,aAAa,GAAGJ,aAAa,CAACK,cAAc;EAC5CC,iBAAiB,GAAGJ,gBAAgB,CAACK,IAAI,GAAG,oBAAoB;EAChEC,UAAU,GAAG,cAAc;AAC7B;;AAEA;AACA;AACA","ignoreList":[]}
@@ -1,11 +1,16 @@
1
+ import { ComponentType } from "../../../components/enums.js";
1
2
  import { FieldsetQuestion } from "./fieldset-question.js";
2
- import { Question } from "../../../index.js";
3
+ import { PreviewComponent } from "./preview.js";
3
4
  export class YesNoQuestion extends FieldsetQuestion {
5
+ /**
6
+ * @type {ComponentType}
7
+ */
8
+ componentType = ComponentType.YesNoField;
4
9
  /**
5
10
  * @type {string}
6
11
  * @protected
7
12
  */
8
- _questionTemplate = Question.PATH + 'radios.njk';
13
+ _questionTemplate = PreviewComponent.PATH + 'radios.njk';
9
14
  _fieldName = 'yesNo';
10
15
 
11
16
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"yes-no.js","names":["FieldsetQuestion","Question","YesNoQuestion","_questionTemplate","PATH","_fieldName","customRenderFields","type","items","id","text","value","label","classes"],"sources":["../../../../../src/form/form-editor/preview/yes-no.js"],"sourcesContent":["import { FieldsetQuestion } from '~/src/form/form-editor/preview/fieldset-question.js'\nimport { Question } from '~/src/index.js'\n\nexport class YesNoQuestion extends FieldsetQuestion {\n /**\n * @type {string}\n * @protected\n */\n _questionTemplate = Question.PATH + 'radios.njk'\n _fieldName = 'yesNo'\n\n /**\n * @returns {Partial<QuestionBaseModel>}\n */\n get customRenderFields() {\n /**\n *\n */\n return {\n type: 'boolean',\n items: /** @type {ListElement[]} */ ([\n {\n id: 'yesNo-yes',\n text: 'Yes',\n value: true,\n label: {\n text: 'Yes',\n classes: ''\n }\n },\n {\n id: 'yesNo-no',\n text: 'No',\n value: false,\n label: {\n text: 'No',\n classes: ''\n }\n }\n ])\n }\n }\n}\n\n/**\n * @import { QuestionBaseModel } from '~/src/form/form-editor/preview/types.js'\n * @import { ListElement } from '~/src/form/form-editor/types.js'\n */\n"],"mappings":"AAAA,SAASA,gBAAgB;AACzB,SAASC,QAAQ;AAEjB,OAAO,MAAMC,aAAa,SAASF,gBAAgB,CAAC;EAClD;AACF;AACA;AACA;EACEG,iBAAiB,GAAGF,QAAQ,CAACG,IAAI,GAAG,YAAY;EAChDC,UAAU,GAAG,OAAO;;EAEpB;AACF;AACA;EACE,IAAIC,kBAAkBA,CAAA,EAAG;IACvB;AACJ;AACA;IACI,OAAO;MACLC,IAAI,EAAE,SAAS;MACfC,KAAK,GAAE,4BAA8B,CACnC;QACEC,EAAE,EAAE,WAAW;QACfC,IAAI,EAAE,KAAK;QACXC,KAAK,EAAE,IAAI;QACXC,KAAK,EAAE;UACLF,IAAI,EAAE,KAAK;UACXG,OAAO,EAAE;QACX;MACF,CAAC,EACD;QACEJ,EAAE,EAAE,UAAU;QACdC,IAAI,EAAE,IAAI;QACVC,KAAK,EAAE,KAAK;QACZC,KAAK,EAAE;UACLF,IAAI,EAAE,IAAI;UACVG,OAAO,EAAE;QACX;MACF,CAAC,CACF;IACH,CAAC;EACH;AACF;;AAEA;AACA;AACA;AACA","ignoreList":[]}
1
+ {"version":3,"file":"yes-no.js","names":["ComponentType","FieldsetQuestion","PreviewComponent","YesNoQuestion","componentType","YesNoField","_questionTemplate","PATH","_fieldName","customRenderFields","type","items","id","text","value","label","classes"],"sources":["../../../../../src/form/form-editor/preview/yes-no.js"],"sourcesContent":["import { ComponentType } from '~/src/components/enums.js'\nimport { FieldsetQuestion } from '~/src/form/form-editor/preview/fieldset-question.js'\nimport { PreviewComponent } from '~/src/form/form-editor/preview/preview.js'\n\nexport class YesNoQuestion extends FieldsetQuestion {\n /**\n * @type {ComponentType}\n */\n componentType = ComponentType.YesNoField\n /**\n * @type {string}\n * @protected\n */\n _questionTemplate = PreviewComponent.PATH + 'radios.njk'\n _fieldName = 'yesNo'\n\n /**\n * @returns {Partial<QuestionBaseModel>}\n */\n get customRenderFields() {\n /**\n *\n */\n return {\n type: 'boolean',\n items: /** @type {ListElement[]} */ ([\n {\n id: 'yesNo-yes',\n text: 'Yes',\n value: true,\n label: {\n text: 'Yes',\n classes: ''\n }\n },\n {\n id: 'yesNo-no',\n text: 'No',\n value: false,\n label: {\n text: 'No',\n classes: ''\n }\n }\n ])\n }\n }\n}\n\n/**\n * @import { QuestionBaseModel } from '~/src/form/form-editor/preview/types.js'\n * @import { ListElement } from '~/src/form/form-editor/types.js'\n */\n"],"mappings":"AAAA,SAASA,aAAa;AACtB,SAASC,gBAAgB;AACzB,SAASC,gBAAgB;AAEzB,OAAO,MAAMC,aAAa,SAASF,gBAAgB,CAAC;EAClD;AACF;AACA;EACEG,aAAa,GAAGJ,aAAa,CAACK,UAAU;EACxC;AACF;AACA;AACA;EACEC,iBAAiB,GAAGJ,gBAAgB,CAACK,IAAI,GAAG,YAAY;EACxDC,UAAU,GAAG,OAAO;;EAEpB;AACF;AACA;EACE,IAAIC,kBAAkBA,CAAA,EAAG;IACvB;AACJ;AACA;IACI,OAAO;MACLC,IAAI,EAAE,SAAS;MACfC,KAAK,GAAE,4BAA8B,CACnC;QACEC,EAAE,EAAE,WAAW;QACfC,IAAI,EAAE,KAAK;QACXC,KAAK,EAAE,IAAI;QACXC,KAAK,EAAE;UACLF,IAAI,EAAE,KAAK;UACXG,OAAO,EAAE;QACX;MACF,CAAC,EACD;QACEJ,EAAE,EAAE,UAAU;QACdC,IAAI,EAAE,IAAI;QACVC,KAAK,EAAE,KAAK;QACZC,KAAK,EAAE;UACLF,IAAI,EAAE,IAAI;UACVG,OAAO,EAAE;QACX;MACF,CAAC,CACF;IACH,CAAC;EACH;AACF;;AAEA;AACA;AACA;AACA","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":[],"sources":["../../../../src/form/form-editor/types.ts"],"sourcesContent":["import { type ComponentType } from '~/src/components/enums.js'\nimport { type ComponentDef } from '~/src/components/types.js'\nimport {\n type ConditionWrapperV2,\n type DateDirections,\n type DateUnits,\n type Item\n} from '~/src/index.js'\n\n/**\n * Interface for `FormEditor` Joi schema\n */\nexport interface FormEditor {\n /**\n * The type of the page\n */\n pageType: string\n\n /**\n * The type of the question\n */\n questionType: string | undefined\n\n /**\n * The sub-type of written answer\n */\n writtenAnswerSub: string\n\n /**\n * The sub-type of date\n */\n dateSub: string\n\n /**\n * The sub-type of lists\n */\n listSub: string\n\n /**\n * The name of the question (unique id)\n */\n name: string\n\n /**\n * The text of the question\n */\n question: string\n\n /**\n * The hint text of the question\n */\n hintText: string\n\n /**\n * Denotes if the question is optional\n */\n questionOptional: string\n\n /**\n * The short description of the question\n */\n shortDescription: string\n\n /**\n * The value of checkbox to reveal heading and guidance section\n */\n pageHeadingAndGuidance: string\n\n /**\n * The page heading\n */\n pageHeading: string\n\n /**\n * The page guidance text\n */\n guidanceText: string\n\n /**\n * The value of checkbox to reveal repeater section\n */\n repeater: string\n\n /**\n * The maximum number of repeater items\n */\n minItems: number\n\n /**\n * The minimum number of repeater items\n */\n maxItems: number\n\n /**\n * The repeater question set name\n */\n questionSetName: string\n\n /**\n * The value of radio to reveal declaration text field\n */\n needDeclaration: string\n\n /**\n * The check answers declaration text\n */\n declarationText: string\n\n /**\n * The min length a field can have\n */\n minLength: string\n\n /**\n * The max length a field can have\n */\n maxLength: string\n\n /**\n * The regex value of a field\n */\n regex: string\n\n /**\n * The number of rows of a textarea\n */\n rows: string\n\n /**\n * The classes to be applied to a field\n */\n classes: string\n\n /**\n * The prefix to be applied to a field\n */\n prefix: string\n\n /**\n * The suffix to be applied to a field\n */\n suffix: string\n\n /**\n * The decimal precision of a number field\n */\n precision: string\n\n /**\n * The lowest number allowed in a field\n */\n min: string\n\n /**\n * The highest number allowed in a field\n */\n max: string\n\n /**\n * The maximum days in the future to allow for a date\n */\n maxFuture: string\n\n /**\n * The maximum days in the past to allow for a date\n */\n maxPast: string\n\n /**\n * The exact number of files to upload\n */\n exactFiles: string\n\n /**\n * The minimum number of files to upload\n */\n minFiles: string\n\n /**\n * The maximum number of files to upload\n */\n maxFiles: string\n\n /**\n * The type of files for upload\n */\n fileTypes: string[]\n\n /**\n * The types of document files for upload\n */\n documentTypes: string[]\n\n /**\n * The types of image files for upload\n */\n imageTypes: string[]\n\n /**\n * The types of tabular data files for upload\n */\n tabularDataTypes: string[]\n\n /**\n * The action required from within a sub-section\n */\n enhancedAction: string\n\n /**\n * Placeholder for inserted section to handle adding/editing radios or checkboxes\n */\n radiosOrCheckboxes: string\n\n /**\n * The unique id of the radio item\n */\n radioId: string\n\n /**\n * The display text of the radio item\n */\n radioText?: string\n\n /**\n * The hint of the radio item\n */\n radioHint?: string\n\n /**\n * The value of the radio item\n */\n radioValue?: string\n\n /**\n * The list name to be applied to a field (if applicable)\n */\n list: string\n\n /**\n * List items in JSON format, such as for radios ro checkboxes\n */\n listItemsData: string\n\n /**\n * An array of options for autocomplete\n */\n autoCompleteOptions: Item[]\n\n /**\n * Set to 'true' is Javascript is enabled\n */\n jsEnabled: string\n\n /**\n * List item id for conditions\n */\n itemId: string\n\n /**\n * Relative date period for conditions\n */\n period: string\n\n /**\n * Relative date unit for conditions\n */\n unit: DateUnits\n\n /**\n * Relative date direction for conditions\n */\n direction: DateDirections\n}\n\nexport type FormEditorInputPage = Pick<\n FormEditor,\n 'pageType' | 'questionType' | 'writtenAnswerSub' | 'dateSub' | 'listSub'\n>\n\nexport type FormEditorInputCheckAnswersSettings = Pick<\n FormEditor,\n 'needDeclaration' | 'declarationText'\n>\n\nexport type FormEditorInputQuestion = Pick<\n FormEditor,\n | 'questionType'\n | 'name'\n | 'question'\n | 'shortDescription'\n | 'hintText'\n | 'questionOptional'\n | 'minLength'\n | 'maxLength'\n | 'regex'\n | 'rows'\n | 'classes'\n | 'prefix'\n | 'suffix'\n | 'precision'\n | 'min'\n | 'max'\n | 'maxFuture'\n | 'maxPast'\n | 'exactFiles'\n | 'minFiles'\n | 'maxFiles'\n | 'fileTypes'\n | 'documentTypes'\n | 'imageTypes'\n | 'tabularDataTypes'\n | 'autoCompleteOptions'\n | 'enhancedAction'\n | 'radioId'\n | 'radioText'\n | 'radioHint'\n | 'radioValue'\n | 'list'\n | 'listItemsData'\n | 'jsEnabled'\n>\n\nexport type FormEditorInputPageSettings = Pick<\n FormEditor,\n | 'pageHeadingAndGuidance'\n | 'pageHeading'\n | 'guidanceText'\n | 'repeater'\n | 'minItems'\n | 'maxItems'\n | 'questionSetName'\n>\n\nexport type FormEditorInputGuidancePage = Pick<\n FormEditor,\n 'pageHeading' | 'guidanceText'\n>\n\nexport type FormEditorInputQuestionDetails = Pick<\n FormEditorInputQuestion,\n | 'question'\n | 'hintText'\n | 'shortDescription'\n | 'questionOptional'\n | 'questionType'\n | 'fileTypes'\n | 'documentTypes'\n | 'imageTypes'\n | 'tabularDataTypes'\n | 'autoCompleteOptions'\n | 'enhancedAction'\n | 'radioId'\n | 'radioText'\n | 'radioHint'\n | 'radioValue'\n | 'listItemsData'\n | 'jsEnabled'\n>\n\nexport interface ListItem {\n id?: string\n text?: string\n hint?: {\n text: string\n }\n value?: string | boolean\n}\n\nexport interface ListLabel {\n text: string\n classes: string\n}\n\nexport interface ListElement extends ListItem {\n readonly id: string\n text: string\n value: string | boolean\n label?: ListLabel\n}\n\nexport interface ReadonlyHint {\n readonly text: string\n}\n\nexport interface ListItemReadonly extends ListElement {\n readonly text: string\n readonly hint?: ReadonlyHint\n readonly value: string | boolean\n readonly label?: ListLabel\n}\n\nexport interface DateItem {\n name: string\n classes: string\n}\n\nexport interface QuestionSessionState {\n questionType?: ComponentType\n questionDetails?: Partial<ComponentDef>\n editRow?: {\n radioId?: string\n radioText?: string\n radioHint?: string\n radioValue?: string | boolean\n expanded?: boolean\n }\n listItems?: ListItem[]\n isReordering?: boolean\n lastMovedId?: string\n lastMoveDirection?: string\n}\n\nexport interface ConditionSessionState {\n id?: string\n stateId?: string\n conditionWrapper?: ConditionWrapperV2\n originalConditionWrapper?: ConditionWrapperV2\n}\n\nexport interface GovukFieldItem {\n text?: string\n value?: string\n checked?: boolean\n}\n\nexport interface GovukField {\n id?: string\n name?: string\n idPrefix?: string\n fieldset?: {\n legend?: { text?: string; isPageHeading?: boolean; classes?: string }\n }\n value?: string | boolean | number | string[] | Item[]\n classes?: string\n label?: {\n text?: string\n html?: string\n classes?: string\n isPageHeading?: boolean\n }\n hint?: { text?: string; html?: string; classes?: string }\n items?: GovukFieldItem[]\n rows?: number\n type?: string\n customTemplate?: string\n}\n\nexport type GovukFieldQuestionOptional = Omit<GovukField, 'name' | 'items'> & {\n name: 'questionOptional'\n items: [\n {\n text?: string\n value?: string\n checked: boolean\n }\n ]\n}\n\nexport type GovukStringField = Omit<GovukField, 'value'> & { value: string }\n\nexport interface FormEditorGovukField {\n question?: GovukField\n hintText?: GovukField\n questionOptional?: GovukField\n shortDescription?: GovukField\n fileTypes?: GovukField\n documentTypes?: GovukField\n imageTypes?: GovukField\n tabularDataTypes?: GovukField\n radiosOrCheckboxes?: GovukField\n autoCompleteOptions?: GovukField\n errorMessage?: { text: string }\n}\n\nexport type FormEditorGovukFieldBase = Omit<\n FormEditorGovukField,\n 'errorMessage'\n>\n\nexport type FormEditorGovukFieldBaseKeys = keyof FormEditorGovukFieldBase\n\nexport interface FormEditorCheckbox {\n text?: string\n hint?: {\n text?: string\n }\n value?: string\n divider?: {\n text?: string\n hint?: string\n value?: string\n }\n}\n\nexport type AdvancedFieldMappingsType = Record<\n ComponentType,\n Record<string, string>\n>\n\nexport type HTMLElementOrNull = HTMLElement | null\n\nexport type HTMLInputElementOrNull = HTMLInputElement | null\n\nexport interface ErrorPreviewFieldMappingDef {\n min?: { fieldName: string; placeholder: string }\n max?: { fieldName: string; placeholder: string }\n}\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"file":"types.js","names":[],"sources":["../../../../src/form/form-editor/types.ts"],"sourcesContent":["import { type ComponentType } from '~/src/components/enums.js'\nimport { type ComponentDef } from '~/src/components/types.js'\nimport {\n type ConditionWrapperV2,\n type DateDirections,\n type DateUnits,\n type Item\n} from '~/src/index.js'\n\n/**\n * Interface for `FormEditor` Joi schema\n */\nexport interface FormEditor {\n /**\n * The type of the page\n */\n pageType: string\n\n /**\n * The type of the question\n */\n questionType: string | undefined\n\n /**\n * The sub-type of written answer\n */\n writtenAnswerSub: string\n\n /**\n * The sub-type of date\n */\n dateSub: string\n\n /**\n * The sub-type of lists\n */\n listSub: string\n\n /**\n * The name of the question (unique id)\n */\n name: string\n\n /**\n * The text of the question\n */\n question: string\n\n /**\n * The hint text of the question\n */\n hintText: string\n\n /**\n * Denotes if the question is optional\n */\n questionOptional: string\n\n /**\n * The short description of the question\n */\n shortDescription: string\n\n /**\n * The value of checkbox to reveal heading and guidance section\n */\n pageHeadingAndGuidance: string\n\n /**\n * The page heading\n */\n pageHeading: string\n\n /**\n * The page guidance text\n */\n guidanceText: string\n\n /**\n * The value of checkbox to reveal repeater section\n */\n repeater: string\n\n /**\n * The maximum number of repeater items\n */\n minItems: number\n\n /**\n * The minimum number of repeater items\n */\n maxItems: number\n\n /**\n * The repeater question set name\n */\n questionSetName: string\n\n /**\n * The value of radio to reveal declaration text field\n */\n needDeclaration: string\n\n /**\n * The check answers declaration text\n */\n declarationText: string\n\n /**\n * The min length a field can have\n */\n minLength: string\n\n /**\n * The max length a field can have\n */\n maxLength: string\n\n /**\n * The regex value of a field\n */\n regex: string\n\n /**\n * The number of rows of a textarea\n */\n rows: string\n\n /**\n * The classes to be applied to a field\n */\n classes: string\n\n /**\n * The prefix to be applied to a field\n */\n prefix: string\n\n /**\n * The suffix to be applied to a field\n */\n suffix: string\n\n /**\n * The decimal precision of a number field\n */\n precision: string\n\n /**\n * The lowest number allowed in a field\n */\n min: string\n\n /**\n * The highest number allowed in a field\n */\n max: string\n\n /**\n * The maximum days in the future to allow for a date\n */\n maxFuture: string\n\n /**\n * The maximum days in the past to allow for a date\n */\n maxPast: string\n\n /**\n * The exact number of files to upload\n */\n exactFiles: string\n\n /**\n * The minimum number of files to upload\n */\n minFiles: string\n\n /**\n * The maximum number of files to upload\n */\n maxFiles: string\n\n /**\n * The type of files for upload\n */\n fileTypes: string[]\n\n /**\n * The types of document files for upload\n */\n documentTypes: string[]\n\n /**\n * The types of image files for upload\n */\n imageTypes: string[]\n\n /**\n * The types of tabular data files for upload\n */\n tabularDataTypes: string[]\n\n /**\n * The action required from within a sub-section\n */\n enhancedAction: string\n\n /**\n * Placeholder for inserted section to handle adding/editing radios or checkboxes\n */\n radiosOrCheckboxes: string\n\n /**\n * The unique id of the radio item\n */\n radioId: string\n\n /**\n * The display text of the radio item\n */\n radioText?: string\n\n /**\n * The hint of the radio item\n */\n radioHint?: string\n\n /**\n * The value of the radio item\n */\n radioValue?: string\n\n /**\n * The list name to be applied to a field (if applicable)\n */\n list: string\n\n /**\n * List items in JSON format, such as for radios ro checkboxes\n */\n listItemsData: string\n\n /**\n * An array of options for autocomplete\n */\n autoCompleteOptions: Item[]\n\n /**\n * Set to 'true' is Javascript is enabled\n */\n jsEnabled: string\n\n /**\n * List item id for conditions\n */\n itemId: string\n\n /**\n * Relative date period for conditions\n */\n period: string\n\n /**\n * Relative date unit for conditions\n */\n unit: DateUnits\n\n /**\n * Relative date direction for conditions\n */\n direction: DateDirections\n}\n\nexport type FormEditorInputPage = Pick<\n FormEditor,\n 'pageType' | 'questionType' | 'writtenAnswerSub' | 'dateSub' | 'listSub'\n>\n\nexport type FormEditorInputCheckAnswersSettings = Pick<\n FormEditor,\n 'needDeclaration' | 'declarationText'\n>\n\nexport type FormEditorInputQuestion = Pick<\n FormEditor,\n | 'questionType'\n | 'name'\n | 'question'\n | 'shortDescription'\n | 'hintText'\n | 'questionOptional'\n | 'minLength'\n | 'maxLength'\n | 'regex'\n | 'rows'\n | 'classes'\n | 'prefix'\n | 'suffix'\n | 'precision'\n | 'min'\n | 'max'\n | 'maxFuture'\n | 'maxPast'\n | 'exactFiles'\n | 'minFiles'\n | 'maxFiles'\n | 'fileTypes'\n | 'documentTypes'\n | 'imageTypes'\n | 'tabularDataTypes'\n | 'autoCompleteOptions'\n | 'enhancedAction'\n | 'radioId'\n | 'radioText'\n | 'radioHint'\n | 'radioValue'\n | 'list'\n | 'listItemsData'\n | 'jsEnabled'\n>\n\nexport type FormEditorInputPageSettings = Pick<\n FormEditor,\n | 'pageHeadingAndGuidance'\n | 'pageHeading'\n | 'guidanceText'\n | 'repeater'\n | 'minItems'\n | 'maxItems'\n | 'questionSetName'\n>\n\nexport type FormEditorInputGuidancePage = Pick<\n FormEditor,\n 'pageHeading' | 'guidanceText'\n>\n\nexport type FormEditorInputQuestionDetails = Pick<\n FormEditorInputQuestion,\n | 'question'\n | 'hintText'\n | 'shortDescription'\n | 'questionOptional'\n | 'questionType'\n | 'fileTypes'\n | 'documentTypes'\n | 'imageTypes'\n | 'tabularDataTypes'\n | 'autoCompleteOptions'\n | 'enhancedAction'\n | 'radioId'\n | 'radioText'\n | 'radioHint'\n | 'radioValue'\n | 'listItemsData'\n | 'jsEnabled'\n>\n\ntype ListValue = string | boolean | number\n\nexport interface ListItem {\n id?: string\n text?: string\n hint?: {\n text: string\n }\n value?: ListValue\n}\n\nexport interface ListLabel {\n text: string\n classes: string\n}\n\nexport interface ListElement extends ListItem {\n readonly id: string\n text: string\n value: ListValue\n label?: ListLabel\n}\n\nexport interface ReadonlyHint {\n readonly text: string\n}\n\nexport interface ListItemReadonly extends ListElement {\n readonly text: string\n readonly hint?: ReadonlyHint\n readonly value: ListValue\n readonly label?: ListLabel\n}\n\nexport interface DateItem {\n name: string\n classes: string\n}\n\nexport interface QuestionSessionState {\n questionType?: ComponentType\n questionDetails?: Partial<ComponentDef>\n editRow?: {\n radioId?: string\n radioText?: string\n radioHint?: string\n radioValue?: ListValue\n expanded?: boolean\n }\n listItems?: ListItem[]\n isReordering?: boolean\n lastMovedId?: string\n lastMoveDirection?: string\n}\n\nexport interface ConditionSessionState {\n id?: string\n stateId?: string\n conditionWrapper?: ConditionWrapperV2\n originalConditionWrapper?: ConditionWrapperV2\n}\n\nexport interface GovukFieldItem {\n text?: string\n value?: string\n checked?: boolean\n}\n\nexport interface GovukField {\n id?: string\n name?: string\n idPrefix?: string\n fieldset?: {\n legend?: { text?: string; isPageHeading?: boolean; classes?: string }\n }\n value?: string | boolean | number | string[] | Item[]\n classes?: string\n label?: {\n text?: string\n html?: string\n classes?: string\n isPageHeading?: boolean\n }\n hint?: { text?: string; html?: string; classes?: string }\n items?: GovukFieldItem[]\n rows?: number\n type?: string\n customTemplate?: string\n}\n\nexport type GovukFieldQuestionOptional = Omit<GovukField, 'name' | 'items'> & {\n name: 'questionOptional'\n items: [\n {\n text?: string\n value?: string\n checked: boolean\n }\n ]\n}\n\nexport type GovukStringField = Omit<GovukField, 'value'> & { value: string }\n\nexport interface FormEditorGovukField {\n question?: GovukField\n hintText?: GovukField\n questionOptional?: GovukField\n shortDescription?: GovukField\n fileTypes?: GovukField\n documentTypes?: GovukField\n imageTypes?: GovukField\n tabularDataTypes?: GovukField\n radiosOrCheckboxes?: GovukField\n autoCompleteOptions?: GovukField\n errorMessage?: { text: string }\n}\n\nexport type FormEditorGovukFieldBase = Omit<\n FormEditorGovukField,\n 'errorMessage'\n>\n\nexport type FormEditorGovukFieldBaseKeys = keyof FormEditorGovukFieldBase\n\nexport interface FormEditorCheckbox {\n text?: string\n hint?: {\n text?: string\n }\n value?: string\n divider?: {\n text?: string\n hint?: string\n value?: string\n }\n}\n\nexport type AdvancedFieldMappingsType = Record<\n ComponentType,\n Record<string, string>\n>\n\nexport type HTMLElementOrNull = HTMLElement | null\n\nexport type HTMLInputElementOrNull = HTMLInputElement | null\n\nexport interface ErrorPreviewFieldMappingDef {\n min?: { fieldName: string; placeholder: string }\n max?: { fieldName: string; placeholder: string }\n}\n"],"mappings":"","ignoreList":[]}
@@ -36,11 +36,7 @@ export const submissionGuidanceSchema = Joi.string().trim().description('Guidanc
36
36
  export const privacyNoticeUrlSchema = Joi.string().uri({
37
37
  scheme: ['http', 'https']
38
38
  }).trim().description('URL to the privacy notice for this form');
39
- export const notificationEmailAddressSchema = Joi.string().email({
40
- tlds: {
41
- allow: ['uk']
42
- }
43
- }).trim().pattern(/\.gov\.uk$|\.org\.uk$/).description('Email address to receive form submission notifications, must be a .gov.uk or .org.uk address');
39
+ export const notificationEmailAddressSchema = Joi.string().email().trim().description('Email address to receive form submission notifications');
44
40
  export const authoredAtSchema = Joi.date().iso().required().description('ISO format timestamp of when an action occurred');
45
41
  export const authorIdSchema = Joi.string().trim().required().description('Unique identifier for the author');
46
42
  export const authorDisplayNameSchema = Joi.string().trim().required().description('Human-readable name of the author');