@defra/forms-model 3.0.481 → 3.0.483

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 (186) hide show
  1. package/dist/module/conditions/condition-operators.js +4 -1
  2. package/dist/module/conditions/condition-operators.js.map +1 -1
  3. package/dist/module/form/form-definition/index.js +0 -1
  4. package/dist/module/form/form-definition/index.js.map +1 -1
  5. package/dist/module/form/form-editor/__stubs__/preview.js +83 -4
  6. package/dist/module/form/form-editor/__stubs__/preview.js.map +1 -1
  7. package/dist/module/form/form-editor/index.js +2 -2
  8. package/dist/module/form/form-editor/index.js.map +1 -1
  9. package/dist/module/form/form-editor/macros/types.js +2 -0
  10. package/dist/module/form/form-editor/macros/types.js.map +1 -0
  11. package/dist/module/form/form-editor/preview/autocomplete.js +20 -4
  12. package/dist/module/form/form-editor/preview/autocomplete.js.map +1 -1
  13. package/dist/module/form/form-editor/preview/checkbox-sortable.js +7 -2
  14. package/dist/module/form/form-editor/preview/checkbox-sortable.js.map +1 -1
  15. package/dist/module/form/form-editor/preview/checkbox.js +17 -0
  16. package/dist/module/form/form-editor/preview/checkbox.js.map +1 -0
  17. package/dist/module/form/form-editor/preview/component-elements.js +61 -0
  18. package/dist/module/form/form-editor/preview/component-elements.js.map +1 -0
  19. package/dist/module/form/form-editor/preview/constants.js +2 -0
  20. package/dist/module/form/form-editor/preview/constants.js.map +1 -0
  21. package/dist/module/form/form-editor/preview/content.js +94 -0
  22. package/dist/module/form/form-editor/preview/content.js.map +1 -0
  23. package/dist/module/form/form-editor/preview/controller/page-controller.js +260 -0
  24. package/dist/module/form/form-editor/preview/controller/page-controller.js.map +1 -0
  25. package/dist/module/form/form-editor/preview/date-input.js +7 -2
  26. package/dist/module/form/form-editor/preview/date-input.js.map +1 -1
  27. package/dist/module/form/form-editor/preview/email-address.js +7 -1
  28. package/dist/module/form/form-editor/preview/email-address.js.map +1 -1
  29. package/dist/module/form/form-editor/preview/fieldset-question.js +5 -0
  30. package/dist/module/form/form-editor/preview/fieldset-question.js.map +1 -1
  31. package/dist/module/form/form-editor/preview/helpers.js +81 -0
  32. package/dist/module/form/form-editor/preview/helpers.js.map +1 -0
  33. package/dist/module/form/form-editor/preview/index.js +6 -0
  34. package/dist/module/form/form-editor/preview/index.js.map +1 -1
  35. package/dist/module/form/form-editor/preview/list.js +59 -3
  36. package/dist/module/form/form-editor/preview/list.js.map +1 -1
  37. package/dist/module/form/form-editor/preview/long-answer.js +7 -1
  38. package/dist/module/form/form-editor/preview/long-answer.js.map +1 -1
  39. package/dist/module/form/form-editor/preview/markdown.js +53 -0
  40. package/dist/module/form/form-editor/preview/markdown.js.map +1 -0
  41. package/dist/module/form/form-editor/preview/month-year.js +7 -2
  42. package/dist/module/form/form-editor/preview/month-year.js.map +1 -1
  43. package/dist/module/form/form-editor/preview/number-only.js +5 -0
  44. package/dist/module/form/form-editor/preview/number-only.js.map +1 -1
  45. package/dist/module/form/form-editor/preview/phone-number.js +7 -1
  46. package/dist/module/form/form-editor/preview/phone-number.js.map +1 -1
  47. package/dist/module/form/form-editor/preview/preview.js +212 -0
  48. package/dist/module/form/form-editor/preview/preview.js.map +1 -0
  49. package/dist/module/form/form-editor/preview/question.js +48 -138
  50. package/dist/module/form/form-editor/preview/question.js.map +1 -1
  51. package/dist/module/form/form-editor/preview/radio-sortable.js +7 -2
  52. package/dist/module/form/form-editor/preview/radio-sortable.js.map +1 -1
  53. package/dist/module/form/form-editor/preview/radio.js +7 -2
  54. package/dist/module/form/form-editor/preview/radio.js.map +1 -1
  55. package/dist/module/form/form-editor/preview/select-sortable.js +38 -0
  56. package/dist/module/form/form-editor/preview/select-sortable.js.map +1 -0
  57. package/dist/module/form/form-editor/preview/select.js +11 -0
  58. package/dist/module/form/form-editor/preview/select.js.map +1 -0
  59. package/dist/module/form/form-editor/preview/short-answer.js +7 -1
  60. package/dist/module/form/form-editor/preview/short-answer.js.map +1 -1
  61. package/dist/module/form/form-editor/preview/supporting-evidence.js +7 -1
  62. package/dist/module/form/form-editor/preview/supporting-evidence.js.map +1 -1
  63. package/dist/module/form/form-editor/preview/types.js.map +1 -1
  64. package/dist/module/form/form-editor/preview/uk-address.js +7 -2
  65. package/dist/module/form/form-editor/preview/uk-address.js.map +1 -1
  66. package/dist/module/form/form-editor/preview/yes-no.js +7 -2
  67. package/dist/module/form/form-editor/preview/yes-no.js.map +1 -1
  68. package/dist/module/form/form-editor/types.js.map +1 -1
  69. package/dist/module/form/form-metadata/index.js +1 -5
  70. package/dist/module/form/form-metadata/index.js.map +1 -1
  71. package/dist/module/form/utils/index.js +1 -0
  72. package/dist/module/form/utils/index.js.map +1 -1
  73. package/dist/module/form/utils/list.js +15 -0
  74. package/dist/module/form/utils/list.js.map +1 -0
  75. package/dist/module/index.js.map +1 -1
  76. package/dist/module/stubs.js +1 -0
  77. package/dist/module/stubs.js.map +1 -1
  78. package/dist/types/conditions/condition-operators.d.ts +0 -4
  79. package/dist/types/conditions/condition-operators.d.ts.map +1 -1
  80. package/dist/types/form/form-definition/index.d.ts.map +1 -1
  81. package/dist/types/form/form-editor/__stubs__/preview.d.ts +58 -11
  82. package/dist/types/form/form-editor/__stubs__/preview.d.ts.map +1 -1
  83. package/dist/types/form/form-editor/index.d.ts.map +1 -1
  84. package/dist/types/form/form-editor/macros/types.d.ts +62 -0
  85. package/dist/types/form/form-editor/macros/types.d.ts.map +1 -0
  86. package/dist/types/form/form-editor/preview/autocomplete.d.ts +3 -1
  87. package/dist/types/form/form-editor/preview/autocomplete.d.ts.map +1 -1
  88. package/dist/types/form/form-editor/preview/checkbox-sortable.d.ts.map +1 -1
  89. package/dist/types/form/form-editor/preview/checkbox.d.ts +4 -0
  90. package/dist/types/form/form-editor/preview/checkbox.d.ts.map +1 -0
  91. package/dist/types/form/form-editor/preview/component-elements.d.ts +35 -0
  92. package/dist/types/form/form-editor/preview/component-elements.d.ts.map +1 -0
  93. package/dist/types/form/form-editor/preview/constants.d.ts +2 -0
  94. package/dist/types/form/form-editor/preview/constants.d.ts.map +1 -0
  95. package/dist/types/form/form-editor/preview/content.d.ts +43 -0
  96. package/dist/types/form/form-editor/preview/content.d.ts.map +1 -0
  97. package/dist/types/form/form-editor/preview/controller/page-controller.d.ts +132 -0
  98. package/dist/types/form/form-editor/preview/controller/page-controller.d.ts.map +1 -0
  99. package/dist/types/form/form-editor/preview/date-input.d.ts.map +1 -1
  100. package/dist/types/form/form-editor/preview/email-address.d.ts.map +1 -1
  101. package/dist/types/form/form-editor/preview/fieldset-question.d.ts +2 -0
  102. package/dist/types/form/form-editor/preview/fieldset-question.d.ts.map +1 -1
  103. package/dist/types/form/form-editor/preview/helpers.d.ts +11 -0
  104. package/dist/types/form/form-editor/preview/helpers.d.ts.map +1 -0
  105. package/dist/types/form/form-editor/preview/index.d.ts +6 -0
  106. package/dist/types/form/form-editor/preview/list-sortable.d.ts +1 -1
  107. package/dist/types/form/form-editor/preview/list.d.ts +25 -0
  108. package/dist/types/form/form-editor/preview/list.d.ts.map +1 -1
  109. package/dist/types/form/form-editor/preview/long-answer.d.ts.map +1 -1
  110. package/dist/types/form/form-editor/preview/markdown.d.ts +9 -0
  111. package/dist/types/form/form-editor/preview/markdown.d.ts.map +1 -0
  112. package/dist/types/form/form-editor/preview/month-year.d.ts.map +1 -1
  113. package/dist/types/form/form-editor/preview/number-only.d.ts.map +1 -1
  114. package/dist/types/form/form-editor/preview/phone-number.d.ts.map +1 -1
  115. package/dist/types/form/form-editor/preview/preview.d.ts +126 -0
  116. package/dist/types/form/form-editor/preview/preview.d.ts.map +1 -0
  117. package/dist/types/form/form-editor/preview/question.d.ts +19 -93
  118. package/dist/types/form/form-editor/preview/question.d.ts.map +1 -1
  119. package/dist/types/form/form-editor/preview/radio-sortable.d.ts.map +1 -1
  120. package/dist/types/form/form-editor/preview/radio.d.ts.map +1 -1
  121. package/dist/types/form/form-editor/preview/select-sortable.d.ts +18 -0
  122. package/dist/types/form/form-editor/preview/select-sortable.d.ts.map +1 -0
  123. package/dist/types/form/form-editor/preview/select.d.ts +4 -0
  124. package/dist/types/form/form-editor/preview/select.d.ts.map +1 -0
  125. package/dist/types/form/form-editor/preview/short-answer.d.ts.map +1 -1
  126. package/dist/types/form/form-editor/preview/supporting-evidence.d.ts.map +1 -1
  127. package/dist/types/form/form-editor/preview/types.d.ts +13 -17
  128. package/dist/types/form/form-editor/preview/types.d.ts.map +1 -1
  129. package/dist/types/form/form-editor/preview/uk-address.d.ts.map +1 -1
  130. package/dist/types/form/form-editor/preview/yes-no.d.ts.map +1 -1
  131. package/dist/types/form/form-editor/types.d.ts +6 -4
  132. package/dist/types/form/form-editor/types.d.ts.map +1 -1
  133. package/dist/types/form/form-metadata/index.d.ts.map +1 -1
  134. package/dist/types/form/utils/index.d.ts +1 -0
  135. package/dist/types/form/utils/index.d.ts.map +1 -1
  136. package/dist/types/form/utils/list.d.ts +10 -0
  137. package/dist/types/form/utils/list.d.ts.map +1 -0
  138. package/dist/types/index.d.ts +1 -0
  139. package/dist/types/index.d.ts.map +1 -1
  140. package/dist/types/stubs.d.ts +1 -0
  141. package/dist/types/stubs.d.ts.map +1 -1
  142. package/package.json +1 -1
  143. package/schemas/form-definition-schema.json +0 -12
  144. package/schemas/form-metadata-input-schema.json +1 -2
  145. package/schemas/form-metadata-schema.json +1 -2
  146. package/schemas/question-type-full-schema.json +2 -1
  147. package/src/conditions/condition-operators.ts +4 -1
  148. package/src/form/form-definition/index.ts +0 -5
  149. package/src/form/form-editor/__stubs__/preview.js +84 -4
  150. package/src/form/form-editor/index.ts +4 -2
  151. package/src/form/form-editor/macros/types.ts +65 -0
  152. package/src/form/form-editor/preview/autocomplete.js +21 -4
  153. package/src/form/form-editor/preview/checkbox-sortable.js +7 -2
  154. package/src/form/form-editor/preview/checkbox.js +17 -0
  155. package/src/form/form-editor/preview/component-elements.js +61 -0
  156. package/src/form/form-editor/preview/constants.js +1 -0
  157. package/src/form/form-editor/preview/content.js +93 -0
  158. package/src/form/form-editor/preview/controller/page-controller.js +284 -0
  159. package/src/form/form-editor/preview/date-input.js +8 -2
  160. package/src/form/form-editor/preview/email-address.js +7 -1
  161. package/src/form/form-editor/preview/fieldset-question.js +6 -0
  162. package/src/form/form-editor/preview/helpers.js +95 -0
  163. package/src/form/form-editor/preview/index.js +6 -0
  164. package/src/form/form-editor/preview/list.js +62 -3
  165. package/src/form/form-editor/preview/long-answer.js +7 -1
  166. package/src/form/form-editor/preview/markdown.js +50 -0
  167. package/src/form/form-editor/preview/month-year.js +7 -2
  168. package/src/form/form-editor/preview/number-only.js +5 -0
  169. package/src/form/form-editor/preview/phone-number.js +7 -1
  170. package/src/form/form-editor/preview/preview.js +211 -0
  171. package/src/form/form-editor/preview/question.js +47 -142
  172. package/src/form/form-editor/preview/radio-sortable.js +7 -2
  173. package/src/form/form-editor/preview/radio.js +7 -2
  174. package/src/form/form-editor/preview/select-sortable.js +43 -0
  175. package/src/form/form-editor/preview/select.js +11 -0
  176. package/src/form/form-editor/preview/short-answer.js +7 -1
  177. package/src/form/form-editor/preview/supporting-evidence.js +7 -1
  178. package/src/form/form-editor/preview/types.ts +18 -18
  179. package/src/form/form-editor/preview/uk-address.js +7 -2
  180. package/src/form/form-editor/preview/yes-no.js +7 -2
  181. package/src/form/form-editor/types.ts +6 -4
  182. package/src/form/form-metadata/index.ts +2 -5
  183. package/src/form/utils/index.ts +1 -0
  184. package/src/form/utils/list.ts +25 -0
  185. package/src/index.ts +1 -0
  186. package/src/stubs.ts +1 -0
@@ -0,0 +1,260 @@
1
+ import { ComponentType } from "../../../../components/enums.js";
2
+ import { HIGHLIGHT_CLASS } from "../constants.js";
3
+ import { ContentElements } from "../content.js";
4
+ import { mapComponentToPreviewQuestion } from "../helpers.js";
5
+ import { Markdown } from "../markdown.js";
6
+ import { hasComponents } from "../../../../pages/helpers.js";
7
+ /**
8
+ * @type {QuestionRenderer}
9
+ */
10
+ const questionRenderer = {
11
+ /**
12
+ * @param {string} _questionTemplate
13
+ * @param {QuestionBaseModel} _questionBaseModel
14
+ */
15
+ render(_questionTemplate, _questionBaseModel) {
16
+ //
17
+ }
18
+ };
19
+
20
+ /**
21
+ * @implements {PageOverviewElements}
22
+ */
23
+ export class PagePreviewElements {
24
+ /**
25
+ * @type {Page}
26
+ * @private
27
+ */
28
+ _page;
29
+ /**
30
+ * @param {Page} page
31
+ */
32
+ constructor(page) {
33
+ this._page = page;
34
+ }
35
+ get heading() {
36
+ return this._page.title;
37
+ }
38
+ get guidance() {
39
+ if (!hasComponents(this._page) || !this._page.components.length) {
40
+ return '';
41
+ }
42
+ const [possibleGuidanceComponent] = this._page.components;
43
+ return possibleGuidanceComponent.type === ComponentType.Markdown ? possibleGuidanceComponent.content : '';
44
+ }
45
+ }
46
+
47
+ /**
48
+ * @implements {PagePreviewPanelMacro}
49
+ */
50
+ export class PreviewPageController {
51
+ static PATH = 'preview-controllers/';
52
+ /**
53
+ * @type {string}
54
+ * @protected
55
+ */
56
+ _pageTemplate = PreviewPageController.PATH + 'page-controller.njk';
57
+ /**
58
+ * @protected
59
+ * @type {Question[]}
60
+ */
61
+ _components = [];
62
+ /**
63
+ * @type {string}
64
+ */
65
+ #title = '';
66
+ /**
67
+ *
68
+ * @type {PageRenderer}
69
+ */
70
+ #pageRenderer;
71
+ /**
72
+ * @type { undefined | 'title' | 'guidance'}
73
+ * @protected
74
+ */
75
+ _highlighted = undefined;
76
+ /**
77
+ * @type {string}
78
+ * @private
79
+ */
80
+ _guidanceText = '';
81
+ /**
82
+ * @type {Markdown}
83
+ * @private
84
+ */
85
+ _emptyGuidance = PreviewPageController.createGuidanceComponent();
86
+ /**
87
+ *
88
+ * @type {Markdown}
89
+ * @protected
90
+ */
91
+ _guidanceComponent;
92
+
93
+ /**
94
+ * @type {boolean}
95
+ * @private
96
+ */
97
+ _showGuidance = false;
98
+ /**
99
+ * @param {ComponentDef[]} components
100
+ * @param {PageOverviewElements} elements
101
+ * @param {FormDefinition} definition
102
+ * @param {PageRenderer} renderer
103
+ */
104
+ constructor(components, elements, definition, renderer) {
105
+ const questions = components.map(mapComponentToPreviewQuestion(questionRenderer, definition));
106
+ const firstQuestion = /** @type { Markdown | undefined | Question } */
107
+ questions.shift();
108
+ this._guidanceComponent = PreviewPageController.getOrCreateGuidanceComponent(firstQuestion);
109
+ this._guidanceText = elements.guidance;
110
+ this._components = this.#constructComponents(firstQuestion, questions);
111
+ this.#title = elements.heading;
112
+ this.#pageRenderer = renderer;
113
+ }
114
+
115
+ /**
116
+ * @param { Question | Markdown | undefined} firstQuestion
117
+ * @param {Question[]} questions
118
+ * @returns {Question[]}
119
+ */
120
+ #constructComponents(firstQuestion, questions) {
121
+ return firstQuestion instanceof Markdown || firstQuestion === undefined ? questions : [firstQuestion, ...questions];
122
+ }
123
+
124
+ /**
125
+ * @returns {Markdown[]}
126
+ * @private
127
+ */
128
+ get _guidanceComponents() {
129
+ if (this._guidanceText.length) {
130
+ return [this._guidanceComponent];
131
+ }
132
+ if (this._highlighted === 'guidance') {
133
+ return [this._emptyGuidance];
134
+ }
135
+ return [];
136
+ }
137
+
138
+ /**
139
+ * @returns {PagePreviewComponent[]}
140
+ */
141
+ get components() {
142
+ const componentsWithGuidance = /** @type {Question[]} */[...this._guidanceComponents, ...this._components];
143
+ return componentsWithGuidance.map(component => ({
144
+ model: component.renderInput,
145
+ questionType: component.componentType
146
+ }));
147
+ }
148
+ set guidanceText(text) {
149
+ this._guidanceText = text;
150
+ this._guidanceComponent.content = text;
151
+ this.render();
152
+ }
153
+ get guidanceText() {
154
+ return this._guidanceText;
155
+ }
156
+ get guidance() {
157
+ return {
158
+ text: this.guidanceText,
159
+ classes: this._highlighted === 'guidance' ? 'highlight' : ''
160
+ };
161
+ }
162
+
163
+ /**
164
+ * @private
165
+ * @returns {string}
166
+ */
167
+ _fallBackTitle() {
168
+ return this._components[0]?.question ?? '';
169
+ }
170
+
171
+ /**
172
+ * @returns {{ text: string, classes: string }}
173
+ */
174
+ get pageTitle() {
175
+ return {
176
+ text: this.title,
177
+ classes: this._highlighted === 'title' ? HIGHLIGHT_CLASS : ''
178
+ };
179
+ }
180
+ render() {
181
+ this.#pageRenderer.render(this._pageTemplate, this);
182
+ }
183
+
184
+ /**
185
+ * @returns {string}
186
+ */
187
+ get title() {
188
+ return this.#title.length ? this.#title : this._fallBackTitle();
189
+ }
190
+
191
+ /**
192
+ * @param {string} value
193
+ */
194
+ set title(value) {
195
+ this.#title = value;
196
+ this.render();
197
+ }
198
+ highlightTitle() {
199
+ this.setHighLighted('title');
200
+ }
201
+
202
+ /**
203
+ * Creates a dummy component for when guidance is highlighted
204
+ * but no guidance text exists
205
+ * @returns {Markdown}
206
+ */
207
+ static createGuidanceComponent() {
208
+ const guidanceElement = new ContentElements({
209
+ type: ComponentType.Markdown,
210
+ title: 'Guidance component',
211
+ name: 'guidanceComponent',
212
+ content: 'Guidance text',
213
+ options: {}
214
+ });
215
+ const guidanceComponent = new Markdown(guidanceElement, questionRenderer);
216
+
217
+ // the dummy component should always be highlighted
218
+ guidanceComponent.highlightContent();
219
+ return guidanceComponent;
220
+ }
221
+
222
+ /**
223
+ * Helper method to return the guidance or a new one
224
+ * @param { Markdown | Question | undefined } guidanceComponent
225
+ * @returns {Markdown}
226
+ * @private
227
+ */
228
+ static getOrCreateGuidanceComponent(guidanceComponent) {
229
+ if (guidanceComponent instanceof Markdown) {
230
+ return guidanceComponent;
231
+ }
232
+ return PreviewPageController.createGuidanceComponent();
233
+ }
234
+ highlightGuidance() {
235
+ this._guidanceComponent.highlightContent();
236
+ this.setHighLighted('guidance');
237
+ }
238
+
239
+ /**
240
+ * @param {'title'|'guidance'} highlightSection
241
+ */
242
+ setHighLighted(highlightSection) {
243
+ this._highlighted = highlightSection;
244
+ this.render();
245
+ }
246
+ clearHighlight() {
247
+ this._highlighted = undefined;
248
+ this._guidanceComponent.unHighlightContent();
249
+ this.render();
250
+ }
251
+ }
252
+
253
+ /**
254
+ * @import { PageRenderer, PageOverviewElements, QuestionRenderer, QuestionBaseModel } from '~/src/form/form-editor/preview/types.js'
255
+ * @import { Question } from '~/src/form/form-editor/preview/question.js'
256
+ * @import { FormDefinition, Page } from '~/src/form/form-definition/types.js'
257
+ * @import { ComponentDef, MarkdownComponent } from '~/src/components/types.js'
258
+ * @import { PagePreviewComponent, PagePreviewPanelMacro } from '~/src/form/form-editor/macros/types.js'
259
+ */
260
+ //# sourceMappingURL=page-controller.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"page-controller.js","names":["ComponentType","HIGHLIGHT_CLASS","ContentElements","mapComponentToPreviewQuestion","Markdown","hasComponents","questionRenderer","render","_questionTemplate","_questionBaseModel","PagePreviewElements","_page","constructor","page","heading","title","guidance","components","length","possibleGuidanceComponent","type","content","PreviewPageController","PATH","_pageTemplate","_components","pageRenderer","_highlighted","undefined","_guidanceText","_emptyGuidance","createGuidanceComponent","_guidanceComponent","_showGuidance","elements","definition","renderer","questions","map","firstQuestion","shift","getOrCreateGuidanceComponent","constructComponents","#constructComponents","_guidanceComponents","componentsWithGuidance","component","model","renderInput","questionType","componentType","guidanceText","text","classes","_fallBackTitle","question","pageTitle","value","highlightTitle","setHighLighted","guidanceElement","name","options","guidanceComponent","highlightContent","highlightGuidance","highlightSection","clearHighlight","unHighlightContent"],"sources":["../../../../../../src/form/form-editor/preview/controller/page-controller.js"],"sourcesContent":["import { ComponentType } from '~/src/components/enums.js'\nimport { HIGHLIGHT_CLASS } from '~/src/form/form-editor/preview/constants.js'\nimport { ContentElements } from '~/src/form/form-editor/preview/content.js'\nimport { mapComponentToPreviewQuestion } from '~/src/form/form-editor/preview/helpers.js'\nimport { Markdown } from '~/src/form/form-editor/preview/markdown.js'\nimport { hasComponents } from '~/src/pages/helpers.js'\n/**\n * @type {QuestionRenderer}\n */\nconst questionRenderer = {\n /**\n * @param {string} _questionTemplate\n * @param {QuestionBaseModel} _questionBaseModel\n */\n render(_questionTemplate, _questionBaseModel) {\n //\n }\n}\n\n/**\n * @implements {PageOverviewElements}\n */\nexport class PagePreviewElements {\n /**\n * @type {Page}\n * @private\n */\n _page\n /**\n * @param {Page} page\n */\n constructor(page) {\n this._page = page\n }\n\n get heading() {\n return this._page.title\n }\n\n get guidance() {\n if (!hasComponents(this._page) || !this._page.components.length) {\n return ''\n }\n\n const [possibleGuidanceComponent] = this._page.components\n\n return possibleGuidanceComponent.type === ComponentType.Markdown\n ? possibleGuidanceComponent.content\n : ''\n }\n}\n\n/**\n * @implements {PagePreviewPanelMacro}\n */\nexport class PreviewPageController {\n static PATH = 'preview-controllers/'\n /**\n * @type {string}\n * @protected\n */\n _pageTemplate = PreviewPageController.PATH + 'page-controller.njk'\n /**\n * @protected\n * @type {Question[]}\n */\n _components = []\n /**\n * @type {string}\n */\n #title = ''\n /**\n *\n * @type {PageRenderer}\n */\n #pageRenderer\n /**\n * @type { undefined | 'title' | 'guidance'}\n * @protected\n */\n _highlighted = undefined\n /**\n * @type {string}\n * @private\n */\n _guidanceText = ''\n /**\n * @type {Markdown}\n * @private\n */\n _emptyGuidance = PreviewPageController.createGuidanceComponent()\n /**\n *\n * @type {Markdown}\n * @protected\n */\n _guidanceComponent\n\n /**\n * @type {boolean}\n * @private\n */\n _showGuidance = false\n /**\n * @param {ComponentDef[]} components\n * @param {PageOverviewElements} elements\n * @param {FormDefinition} definition\n * @param {PageRenderer} renderer\n */\n constructor(components, elements, definition, renderer) {\n const questions = components.map(\n mapComponentToPreviewQuestion(questionRenderer, definition)\n )\n const firstQuestion = /** @type { Markdown | undefined | Question } */ (\n questions.shift()\n )\n\n this._guidanceComponent =\n PreviewPageController.getOrCreateGuidanceComponent(firstQuestion)\n this._guidanceText = elements.guidance\n this._components = this.#constructComponents(firstQuestion, questions)\n this.#title = elements.heading\n this.#pageRenderer = renderer\n }\n\n /**\n * @param { Question | Markdown | undefined} firstQuestion\n * @param {Question[]} questions\n * @returns {Question[]}\n */\n #constructComponents(firstQuestion, questions) {\n return firstQuestion instanceof Markdown || firstQuestion === undefined\n ? questions\n : [firstQuestion, ...questions]\n }\n\n /**\n * @returns {Markdown[]}\n * @private\n */\n get _guidanceComponents() {\n if (this._guidanceText.length) {\n return [this._guidanceComponent]\n }\n if (this._highlighted === 'guidance') {\n return [this._emptyGuidance]\n }\n return []\n }\n\n /**\n * @returns {PagePreviewComponent[]}\n */\n get components() {\n const componentsWithGuidance = /** @type {Question[]} */ ([\n ...this._guidanceComponents,\n ...this._components\n ])\n\n return componentsWithGuidance.map((component) => ({\n model: component.renderInput,\n questionType: component.componentType\n }))\n }\n\n set guidanceText(text) {\n this._guidanceText = text\n this._guidanceComponent.content = text\n this.render()\n }\n\n get guidanceText() {\n return this._guidanceText\n }\n\n get guidance() {\n return {\n text: this.guidanceText,\n classes: this._highlighted === 'guidance' ? 'highlight' : ''\n }\n }\n\n /**\n * @private\n * @returns {string}\n */\n _fallBackTitle() {\n return this._components[0]?.question ?? ''\n }\n\n /**\n * @returns {{ text: string, classes: string }}\n */\n get pageTitle() {\n return {\n text: this.title,\n classes: this._highlighted === 'title' ? HIGHLIGHT_CLASS : ''\n }\n }\n\n render() {\n this.#pageRenderer.render(this._pageTemplate, this)\n }\n\n /**\n * @returns {string}\n */\n get title() {\n return this.#title.length ? this.#title : this._fallBackTitle()\n }\n\n /**\n * @param {string} value\n */\n set title(value) {\n this.#title = value\n this.render()\n }\n\n highlightTitle() {\n this.setHighLighted('title')\n }\n\n /**\n * Creates a dummy component for when guidance is highlighted\n * but no guidance text exists\n * @returns {Markdown}\n */\n static createGuidanceComponent() {\n const guidanceElement = new ContentElements({\n type: ComponentType.Markdown,\n title: 'Guidance component',\n name: 'guidanceComponent',\n content: 'Guidance text',\n options: {}\n })\n const guidanceComponent = new Markdown(guidanceElement, questionRenderer)\n\n // the dummy component should always be highlighted\n guidanceComponent.highlightContent()\n return guidanceComponent\n }\n\n /**\n * Helper method to return the guidance or a new one\n * @param { Markdown | Question | undefined } guidanceComponent\n * @returns {Markdown}\n * @private\n */\n static getOrCreateGuidanceComponent(guidanceComponent) {\n if (guidanceComponent instanceof Markdown) {\n return guidanceComponent\n }\n return PreviewPageController.createGuidanceComponent()\n }\n\n highlightGuidance() {\n this._guidanceComponent.highlightContent()\n this.setHighLighted('guidance')\n }\n\n /**\n * @param {'title'|'guidance'} highlightSection\n */\n setHighLighted(highlightSection) {\n this._highlighted = highlightSection\n this.render()\n }\n\n clearHighlight() {\n this._highlighted = undefined\n\n this._guidanceComponent.unHighlightContent()\n this.render()\n }\n}\n\n/**\n * @import { PageRenderer, PageOverviewElements, QuestionRenderer, QuestionBaseModel } from '~/src/form/form-editor/preview/types.js'\n * @import { Question } from '~/src/form/form-editor/preview/question.js'\n * @import { FormDefinition, Page } from '~/src/form/form-definition/types.js'\n * @import { ComponentDef, MarkdownComponent } from '~/src/components/types.js'\n * @import { PagePreviewComponent, PagePreviewPanelMacro } from '~/src/form/form-editor/macros/types.js'\n */\n"],"mappings":"AAAA,SAASA,aAAa;AACtB,SAASC,eAAe;AACxB,SAASC,eAAe;AACxB,SAASC,6BAA6B;AACtC,SAASC,QAAQ;AACjB,SAASC,aAAa;AACtB;AACA;AACA;AACA,MAAMC,gBAAgB,GAAG;EACvB;AACF;AACA;AACA;EACEC,MAAMA,CAACC,iBAAiB,EAAEC,kBAAkB,EAAE;IAC5C;EAAA;AAEJ,CAAC;;AAED;AACA;AACA;AACA,OAAO,MAAMC,mBAAmB,CAAC;EAC/B;AACF;AACA;AACA;EACEC,KAAK;EACL;AACF;AACA;EACEC,WAAWA,CAACC,IAAI,EAAE;IAChB,IAAI,CAACF,KAAK,GAAGE,IAAI;EACnB;EAEA,IAAIC,OAAOA,CAAA,EAAG;IACZ,OAAO,IAAI,CAACH,KAAK,CAACI,KAAK;EACzB;EAEA,IAAIC,QAAQA,CAAA,EAAG;IACb,IAAI,CAACX,aAAa,CAAC,IAAI,CAACM,KAAK,CAAC,IAAI,CAAC,IAAI,CAACA,KAAK,CAACM,UAAU,CAACC,MAAM,EAAE;MAC/D,OAAO,EAAE;IACX;IAEA,MAAM,CAACC,yBAAyB,CAAC,GAAG,IAAI,CAACR,KA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C,CAAC;IACpC,OAAOD,iBAAiB;EAC1B;;EAEA;AACF;AACA;AACA;AACA;AACA;EACE,OAAOtB,4BAA4BA,CAACsB,iBAAiB,EAAE;IACrD,IAAIA,iBAAiB,YAAY3D,QAAQ,EAAE;MACzC,OAAO2D,iBAAiB;IAC1B;IACA,OAAOzC,qBAAqB,CAACS,uBAAuB,CAAC,CAAC;EACxD;EAEAkC,iBAAiBA,CAAA,EAAG;IAClB,IAAI,CAACjC,kBAAkB,CAACgC,gBAAgB,CAAC,CAAC;IAC1C,IAAI,CAACL,cAAc,CAAC,UAAU,CAAC;EACjC;;EAEA;AACF;AACA;EACEA,cAAcA,CAACO,gBAAgB,EAAE;IAC/B,IAAI,CAACvC,YAAY,GAAGuC,gBAAgB;IACpC,IAAI,CAAC3D,MAAM,CAAC,CAAC;EACf;EAEA4D,cAAcA,CAAA,EAAG;IACf,IAAI,CAACxC,YAAY,GAAGC,SAAS;IAE7B,IAAI,CAACI,kBAAkB,CAACoC,kBAAkB,CAAC,CAAC;IAC5C,IAAI,CAAC7D,MAAM,CAAC,CAAC;EACf;AACF;;AAEA;AACA;AACA;AACA;AACA;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 "./question.js";
3
+ import { PreviewComponent } from "./preview.js";
3
4
  export class DateInputQuestion extends FieldsetQuestion {
5
+ /**
6
+ * @type {ComponentType}
7
+ */
8
+ componentType = ComponentType.DatePartsField;
4
9
  /**
5
10
  * @type {string}
6
11
  * @protected
7
12
  */
8
- _questionTemplate = Question.PATH + 'date-input.njk';
13
+ _questionTemplate = PreviewComponent.PATH + 'date-input.njk';
9
14
  _fieldName = 'dateInput';
10
15
  }
11
16
  //# sourceMappingURL=date-input.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"date-input.js","names":["FieldsetQuestion","Question","DateInputQuestion","_questionTemplate","PATH","_fieldName"],"sources":["../../../../../src/form/form-editor/preview/date-input.js"],"sourcesContent":["import { FieldsetQuestion } from '~/src/form/form-editor/preview/fieldset-question.js'\nimport { Question } from '~/src/form/form-editor/preview/question.js'\nexport class DateInputQuestion extends FieldsetQuestion {\n /**\n * @type {string}\n * @protected\n */\n _questionTemplate = Question.PATH + 'date-input.njk'\n _fieldName = 'dateInput'\n}\n"],"mappings":"AAAA,SAASA,gBAAgB;AACzB,SAASC,QAAQ;AACjB,OAAO,MAAMC,iBAAiB,SAASF,gBAAgB,CAAC;EACtD;AACF;AACA;AACA;EACEG,iBAAiB,GAAGF,QAAQ,CAACG,IAAI,GAAG,gBAAgB;EACpDC,UAAU,GAAG,WAAW;AAC1B","ignoreList":[]}
1
+ {"version":3,"file":"date-input.js","names":["ComponentType","FieldsetQuestion","PreviewComponent","DateInputQuestion","componentType","DatePartsField","_questionTemplate","PATH","_fieldName"],"sources":["../../../../../src/form/form-editor/preview/date-input.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 DateInputQuestion extends FieldsetQuestion {\n /**\n * @type {ComponentType}\n */\n componentType = ComponentType.DatePartsField\n /**\n * @type {string}\n * @protected\n */\n _questionTemplate = PreviewComponent.PATH + 'date-input.njk'\n _fieldName = 'dateInput'\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;EAC5C;AACF;AACA;AACA;EACEC,iBAAiB,GAAGJ,gBAAgB,CAACK,IAAI,GAAG,gBAAgB;EAC5DC,UAAU,GAAG,WAAW;AAC1B","ignoreList":[]}
@@ -1,6 +1,12 @@
1
+ import { ComponentType } from "../../../components/enums.js";
2
+ import { PreviewComponent } from "./preview.js";
1
3
  import { Question } from "./question.js";
2
4
  export class EmailAddressQuestion extends Question {
3
- _questionTemplate = Question.PATH + 'emailaddressfield.njk';
5
+ /**
6
+ * @type {ComponentType}
7
+ */
8
+ componentType = ComponentType.EmailAddressField;
9
+ _questionTemplate = PreviewComponent.PATH + 'emailaddressfield.njk';
4
10
  _fieldName = 'emailAddressField';
5
11
  }
6
12
  //# sourceMappingURL=email-address.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"email-address.js","names":["Question","EmailAddressQuestion","_questionTemplate","PATH","_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 = Question.PATH + 'emailaddressfield.njk'\n _fieldName = 'emailAddressField'\n}\n"],"mappings":"AAAA,SAASA,QAAQ;AAEjB,OAAO,MAAMC,oBAAoB,SAASD,QAAQ,CAAC;EACjDE,iBAAiB,GAAGF,QAAQ,CAACG,IAAI,GAAG,uBAAuB;EAC3DC,UAAU,GAAG,mBAAmB;AAClC","ignoreList":[]}
1
+ {"version":3,"file":"email-address.js","names":["ComponentType","PreviewComponent","Question","EmailAddressQuestion","componentType","EmailAddressField","_questionTemplate","PATH","_fieldName"],"sources":["../../../../../src/form/form-editor/preview/email-address.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 EmailAddressQuestion extends Question {\n /**\n * @type {ComponentType}\n */\n componentType = ComponentType.EmailAddressField\n _questionTemplate = PreviewComponent.PATH + 'emailaddressfield.njk'\n _fieldName = 'emailAddressField'\n}\n"],"mappings":"AAAA,SAASA,aAAa;AACtB,SAASC,gBAAgB;AACzB,SAASC,QAAQ;AAEjB,OAAO,MAAMC,oBAAoB,SAASD,QAAQ,CAAC;EACjD;AACF;AACA;EACEE,aAAa,GAAGJ,aAAa,CAACK,iBAAiB;EAC/CC,iBAAiB,GAAGL,gBAAgB,CAACM,IAAI,GAAG,uBAAuB;EACnEC,UAAU,GAAG,mBAAmB;AAClC","ignoreList":[]}
@@ -1,3 +1,4 @@
1
+ import { ComponentType } from "../../../components/enums.js";
1
2
  import { Question } from "./question.js";
2
3
 
3
4
  /**
@@ -5,6 +6,10 @@ import { Question } from "./question.js";
5
6
  * @abstract
6
7
  */
7
8
  export class FieldsetQuestion extends Question {
9
+ /**
10
+ * @type {ComponentType}
11
+ */
12
+ componentType = ComponentType.TextField;
8
13
  get renderInput() {
9
14
  return {
10
15
  id: this._fieldName,
@@ -1 +1 @@
1
- {"version":3,"file":"fieldset-question.js","names":["Question","FieldsetQuestion","renderInput","id","_fieldName","name","fieldset","fieldSet","hint","customRenderFields"],"sources":["../../../../../src/form/form-editor/preview/fieldset-question.js"],"sourcesContent":["import { Question } from '~/src/form/form-editor/preview/question.js'\n\n/**\n * Simple extension of Question that uses fieldset instead of label - not exported\n * @abstract\n */\nexport class FieldsetQuestion extends Question {\n get renderInput() {\n return {\n id: this._fieldName,\n name: this._fieldName,\n fieldset: this.fieldSet,\n hint: this.hint,\n ...this.customRenderFields\n }\n }\n}\n"],"mappings":"AAAA,SAASA,QAAQ;;AAEjB;AACA;AACA;AACA;AACA,OAAO,MAAMC,gBAAgB,SAASD,QAAQ,CAAC;EAC7C,IAAIE,WAAWA,CAAA,EAAG;IAChB,OAAO;MACLC,EAAE,EAAE,IAAI,CAACC,UAAU;MACnBC,IAAI,EAAE,IAAI,CAACD,UAAU;MACrBE,QAAQ,EAAE,IAAI,CAACC,QAAQ;MACvBC,IAAI,EAAE,IAAI,CAACA,IAAI;MACf,GAAG,IAAI,CAACC;IACV,CAAC;EACH;AACF","ignoreList":[]}
1
+ {"version":3,"file":"fieldset-question.js","names":["ComponentType","Question","FieldsetQuestion","componentType","TextField","renderInput","id","_fieldName","name","fieldset","fieldSet","hint","customRenderFields"],"sources":["../../../../../src/form/form-editor/preview/fieldset-question.js"],"sourcesContent":["import { ComponentType } from '~/src/components/enums.js'\nimport { Question } from '~/src/form/form-editor/preview/question.js'\n\n/**\n * Simple extension of Question that uses fieldset instead of label - not exported\n * @abstract\n */\nexport class FieldsetQuestion extends Question {\n /**\n * @type {ComponentType}\n */\n componentType = ComponentType.TextField\n\n get renderInput() {\n return {\n id: this._fieldName,\n name: this._fieldName,\n fieldset: this.fieldSet,\n hint: this.hint,\n ...this.customRenderFields\n }\n }\n}\n"],"mappings":"AAAA,SAASA,aAAa;AACtB,SAASC,QAAQ;;AAEjB;AACA;AACA;AACA;AACA,OAAO,MAAMC,gBAAgB,SAASD,QAAQ,CAAC;EAC7C;AACF;AACA;EACEE,aAAa,GAAGH,aAAa,CAACI,SAAS;EAEvC,IAAIC,WAAWA,CAAA,EAAG;IAChB,OAAO;MACLC,EAAE,EAAE,IAAI,CAACC,UAAU;MACnBC,IAAI,EAAE,IAAI,CAACD,UAAU;MACrBE,QAAQ,EAAE,IAAI,CAACC,QAAQ;MACvBC,IAAI,EAAE,IAAI,CAACA,IAAI;MACf,GAAG,IAAI,CAACC;IACV,CAAC;EACH;AACF","ignoreList":[]}
@@ -0,0 +1,81 @@
1
+ import { ComponentType } from "../../../components/enums.js";
2
+ import { AutocompleteListQuestion } from "./autocomplete.js";
3
+ import { CheckboxQuestion } from "./checkbox.js";
4
+ import { ComponentElements } from "./component-elements.js";
5
+ import { ContentElements } from "./content.js";
6
+ import { DateInputQuestion } from "./date-input.js";
7
+ import { EmailAddressQuestion } from "./email-address.js";
8
+ import { ListQuestion } from "./list.js";
9
+ import { LongAnswerQuestion } from "./long-answer.js";
10
+ import { Markdown } from "./markdown.js";
11
+ import { MonthYearQuestion } from "./month-year.js";
12
+ import { NumberOnlyQuestion } from "./number-only.js";
13
+ import { PhoneNumberQuestion } from "./phone-number.js";
14
+ import { RadioQuestion } from "./radio.js";
15
+ import { SelectQuestion } from "./select.js";
16
+ import { ShortAnswerQuestion } from "./short-answer.js";
17
+ import { SupportingEvidenceQuestion } from "./supporting-evidence.js";
18
+ import { UkAddressQuestion } from "./uk-address.js";
19
+ import { YesNoQuestion } from "./yes-no.js";
20
+ import { findDefinitionListFromComponent } from "../../utils/list.js";
21
+ import { ListComponentElements, QuestionComponentElements, hasContentField, hasInputField, hasListField, hasSelectionFields } from "../../../index.js";
22
+
23
+ /**
24
+ * @type {Record<ComponentType, typeof PreviewComponent>}
25
+ */
26
+ const InputFieldComponentDictionary = {
27
+ [ComponentType.TextField]: ShortAnswerQuestion,
28
+ [ComponentType.Details]: ShortAnswerQuestion,
29
+ [ComponentType.InsetText]: ShortAnswerQuestion,
30
+ [ComponentType.Html]: ShortAnswerQuestion,
31
+ [ComponentType.Markdown]: Markdown,
32
+ [ComponentType.List]: ListQuestion,
33
+ [ComponentType.EmailAddressField]: EmailAddressQuestion,
34
+ [ComponentType.NumberField]: NumberOnlyQuestion,
35
+ [ComponentType.MultilineTextField]: LongAnswerQuestion,
36
+ [ComponentType.TelephoneNumberField]: PhoneNumberQuestion,
37
+ [ComponentType.MonthYearField]: MonthYearQuestion,
38
+ [ComponentType.DatePartsField]: DateInputQuestion,
39
+ [ComponentType.UkAddressField]: UkAddressQuestion,
40
+ [ComponentType.AutocompleteField]: AutocompleteListQuestion,
41
+ [ComponentType.RadiosField]: RadioQuestion,
42
+ [ComponentType.CheckboxesField]: CheckboxQuestion,
43
+ [ComponentType.SelectField]: SelectQuestion,
44
+ [ComponentType.YesNoField]: YesNoQuestion,
45
+ [ComponentType.FileUploadField]: SupportingEvidenceQuestion
46
+ };
47
+
48
+ /**
49
+ * @param {QuestionRenderer} questionRenderer
50
+ * @param {FormDefinition} definition
51
+ * @returns {(component: ComponentDef) => Question}
52
+ */
53
+ export function mapComponentToPreviewQuestion(questionRenderer, definition) {
54
+ return /** @type {(component: ComponentDef) => Question} */component => {
55
+ /**
56
+ * @type {QuestionElements}
57
+ */
58
+ let questionElements;
59
+ if (hasSelectionFields(component) && hasListField(component)) {
60
+ const list = findDefinitionListFromComponent(component, definition);
61
+ questionElements = new ListComponentElements(component, list);
62
+ } else if (hasInputField(component) || component.type === ComponentType.YesNoField) {
63
+ questionElements = new QuestionComponentElements(component);
64
+ } else if (hasContentField(component)) {
65
+ questionElements = new ContentElements(component);
66
+ } else {
67
+ questionElements = new ComponentElements(component);
68
+ }
69
+ const QuestionConstructor = InputFieldComponentDictionary[component.type];
70
+ return new QuestionConstructor(questionElements, questionRenderer);
71
+ };
72
+ }
73
+
74
+ /**
75
+ * @import { QuestionElements, QuestionRenderer } from '~/src/form/form-editor/preview/types.js'
76
+ * @import { Question } from '~/src/form/form-editor/preview/question.js'
77
+ * @import { PreviewComponent } from '~/src/form/form-editor/preview/preview.js'
78
+ * @import { Item, FormDefinition } from '~/src/form/form-definition/types.js'
79
+ * @import { FormComponentsDef, ComponentDef } from '~/src/components/types.js'
80
+ */
81
+ //# sourceMappingURL=helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.js","names":["ComponentType","AutocompleteListQuestion","CheckboxQuestion","ComponentElements","ContentElements","DateInputQuestion","EmailAddressQuestion","ListQuestion","LongAnswerQuestion","Markdown","MonthYearQuestion","NumberOnlyQuestion","PhoneNumberQuestion","RadioQuestion","SelectQuestion","ShortAnswerQuestion","SupportingEvidenceQuestion","UkAddressQuestion","YesNoQuestion","findDefinitionListFromComponent","ListComponentElements","QuestionComponentElements","hasContentField","hasInputField","hasListField","hasSelectionFields","InputFieldComponentDictionary","TextField","Details","InsetText","Html","List","EmailAddressField","NumberField","MultilineTextField","TelephoneNumberField","MonthYearField","DatePartsField","UkAddressField","AutocompleteField","RadiosField","CheckboxesField","SelectField","YesNoField","FileUploadField","mapComponentToPreviewQuestion","questionRenderer","definition","component","questionElements","list","type","QuestionConstructor"],"sources":["../../../../../src/form/form-editor/preview/helpers.js"],"sourcesContent":["import { ComponentType } from '~/src/components/enums.js'\nimport { AutocompleteListQuestion } from '~/src/form/form-editor/preview/autocomplete.js'\nimport { CheckboxQuestion } from '~/src/form/form-editor/preview/checkbox.js'\nimport { ComponentElements } from '~/src/form/form-editor/preview/component-elements.js'\nimport { ContentElements } from '~/src/form/form-editor/preview/content.js'\nimport { DateInputQuestion } from '~/src/form/form-editor/preview/date-input.js'\nimport { EmailAddressQuestion } from '~/src/form/form-editor/preview/email-address.js'\nimport { ListQuestion } from '~/src/form/form-editor/preview/list.js'\nimport { LongAnswerQuestion } from '~/src/form/form-editor/preview/long-answer.js'\nimport { Markdown } from '~/src/form/form-editor/preview/markdown.js'\nimport { MonthYearQuestion } from '~/src/form/form-editor/preview/month-year.js'\nimport { NumberOnlyQuestion } from '~/src/form/form-editor/preview/number-only.js'\nimport { PhoneNumberQuestion } from '~/src/form/form-editor/preview/phone-number.js'\nimport { RadioQuestion } from '~/src/form/form-editor/preview/radio.js'\nimport { SelectQuestion } from '~/src/form/form-editor/preview/select.js'\nimport { ShortAnswerQuestion } from '~/src/form/form-editor/preview/short-answer.js'\nimport { SupportingEvidenceQuestion } from '~/src/form/form-editor/preview/supporting-evidence.js'\nimport { UkAddressQuestion } from '~/src/form/form-editor/preview/uk-address.js'\nimport { YesNoQuestion } from '~/src/form/form-editor/preview/yes-no.js'\nimport { findDefinitionListFromComponent } from '~/src/form/utils/list.js'\nimport {\n ListComponentElements,\n QuestionComponentElements,\n hasContentField,\n hasInputField,\n hasListField,\n hasSelectionFields\n} from '~/src/index.js'\n\n/**\n * @type {Record<ComponentType, typeof PreviewComponent>}\n */\nconst InputFieldComponentDictionary = {\n [ComponentType.TextField]: ShortAnswerQuestion,\n [ComponentType.Details]: ShortAnswerQuestion,\n [ComponentType.InsetText]: ShortAnswerQuestion,\n [ComponentType.Html]: ShortAnswerQuestion,\n [ComponentType.Markdown]: Markdown,\n [ComponentType.List]: ListQuestion,\n [ComponentType.EmailAddressField]: EmailAddressQuestion,\n [ComponentType.NumberField]: NumberOnlyQuestion,\n [ComponentType.MultilineTextField]: LongAnswerQuestion,\n [ComponentType.TelephoneNumberField]: PhoneNumberQuestion,\n [ComponentType.MonthYearField]: MonthYearQuestion,\n [ComponentType.DatePartsField]: DateInputQuestion,\n [ComponentType.UkAddressField]: UkAddressQuestion,\n [ComponentType.AutocompleteField]: AutocompleteListQuestion,\n [ComponentType.RadiosField]: RadioQuestion,\n [ComponentType.CheckboxesField]: CheckboxQuestion,\n [ComponentType.SelectField]: SelectQuestion,\n [ComponentType.YesNoField]: YesNoQuestion,\n [ComponentType.FileUploadField]: SupportingEvidenceQuestion\n}\n\n/**\n * @param {QuestionRenderer} questionRenderer\n * @param {FormDefinition} definition\n * @returns {(component: ComponentDef) => Question}\n */\nexport function mapComponentToPreviewQuestion(questionRenderer, definition) {\n return /** @type {(component: ComponentDef) => Question} */ (\n (component) => {\n /**\n * @type {QuestionElements}\n */\n let questionElements\n\n if (hasSelectionFields(component) && hasListField(component)) {\n const list = findDefinitionListFromComponent(component, definition)\n questionElements = new ListComponentElements(component, list)\n } else if (\n hasInputField(component) ||\n component.type === ComponentType.YesNoField\n ) {\n questionElements = new QuestionComponentElements(component)\n } else if (hasContentField(component)) {\n questionElements = new ContentElements(component)\n } else {\n questionElements = new ComponentElements(component)\n }\n\n const QuestionConstructor = InputFieldComponentDictionary[component.type]\n\n return new QuestionConstructor(questionElements, questionRenderer)\n }\n )\n}\n\n/**\n * @import { QuestionElements, QuestionRenderer } from '~/src/form/form-editor/preview/types.js'\n * @import { Question } from '~/src/form/form-editor/preview/question.js'\n * @import { PreviewComponent } from '~/src/form/form-editor/preview/preview.js'\n * @import { Item, FormDefinition } from '~/src/form/form-definition/types.js'\n * @import { FormComponentsDef, ComponentDef } from '~/src/components/types.js'\n */\n"],"mappings":"AAAA,SAASA,aAAa;AACtB,SAASC,wBAAwB;AACjC,SAASC,gBAAgB;AACzB,SAASC,iBAAiB;AAC1B,SAASC,eAAe;AACxB,SAASC,iBAAiB;AAC1B,SAASC,oBAAoB;AAC7B,SAASC,YAAY;AACrB,SAASC,kBAAkB;AAC3B,SAASC,QAAQ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aAAa,CAAC4C,eAAe,GAAG5B;AACnC,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA,OAAO,SAAS6B,6BAA6BA,CAACC,gBAAgB,EAAEC,UAAU,EAAE;EAC1E,OAAO,oDACJC,SAAS,IAAK;IACb;AACN;AACA;IACM,IAAIC,gBAAgB;IAEpB,IAAIxB,kBAAkB,CAACuB,SAAS,CAAC,IAAIxB,YAAY,CAACwB,SAAS,CAAC,EAAE;MAC5D,MAAME,IAAI,GAAG/B,+BAA+B,CAAC6B,SAAS,EAAED,UAAU,CAAC;MACnEE,gBAAgB,GAAG,IAAI7B,qBAAqB,CAAC4B,SAAS,EAAEE,IAAI,CAAC;IAC/D,CAAC,MAAM,IACL3B,aAAa,CAACyB,SAAS,CAAC,IACxBA,SAAS,CAACG,IAAI,KAAKnD,aAAa,CAAC2C,UAAU,EAC3C;MACAM,gBAAgB,GAAG,IAAI5B,yBAAyB,CAAC2B,SAAS,CAAC;IAC7D,CAAC,MAAM,IAAI1B,eAAe,CAAC0B,SAAS,CAAC,EAAE;MACrCC,gBAAgB,GAAG,IAAI7C,eAAe,CAAC4C,SAAS,CAAC;IACnD,CAAC,MAAM;MACLC,gBAAgB,GAAG,IAAI9C,iBAAiB,CAAC6C,SAAS,CAAC;IACrD;IAEA,MAAMI,mBAAmB,GAAG1B,6BAA6B,CAACsB,SAAS,CAACG,IAAI,CAAC;IAEzE,OAAO,IAAIC,mBAAmB,CAACH,gBAAgB,EAAEH,gBAAgB,CAAC;EACpE,CAAC;AAEL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
@@ -1,18 +1,24 @@
1
1
  export * from "./autocomplete.js";
2
+ export * from "./checkbox.js";
2
3
  export * from "./checkbox-sortable.js";
3
4
  export * from "./date-input.js";
4
5
  export * from "./email-address.js";
5
6
  export * from "./list.js";
6
7
  export * from "./list-sortable.js";
8
+ export * from "./markdown.js";
7
9
  export * from "./month-year.js";
8
10
  export * from "./number-only.js";
9
11
  export * from "./phone-number.js";
10
12
  export * from "./question.js";
11
13
  export * from "./radio.js";
12
14
  export * from "./radio-sortable.js";
15
+ export * from "./select-sortable.js";
13
16
  export * from "./short-answer.js";
17
+ export * from "./select.js";
18
+ export * from "./select-sortable.js";
14
19
  export * from "./supporting-evidence.js";
15
20
  export * from "./long-answer.js";
16
21
  export * from "./uk-address.js";
17
22
  export * from "./yes-no.js";
23
+ export * from "./controller/page-controller.js";
18
24
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../../../../src/form/form-editor/preview/index.js"],"sourcesContent":["export * from '~/src/form/form-editor/preview/autocomplete.js'\nexport * from '~/src/form/form-editor/preview/checkbox-sortable.js'\nexport * 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/month-year.js'\nexport * from '~/src/form/form-editor/preview/number-only.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/supporting-evidence.js'\nexport * from '~/src/form/form-editor/preview/long-answer.js'\nexport * from '~/src/form/form-editor/preview/uk-address.js'\nexport * from '~/src/form/form-editor/preview/yes-no.js'\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../../../src/form/form-editor/preview/index.js"],"sourcesContent":["export * from '~/src/form/form-editor/preview/autocomplete.js'\nexport * from '~/src/form/form-editor/preview/checkbox.js'\nexport * from '~/src/form/form-editor/preview/checkbox-sortable.js'\nexport * 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/markdown.js'\nexport * from '~/src/form/form-editor/preview/month-year.js'\nexport * from '~/src/form/form-editor/preview/number-only.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/select-sortable.js'\nexport * from '~/src/form/form-editor/preview/short-answer.js'\nexport * from '~/src/form/form-editor/preview/select.js'\nexport * from '~/src/form/form-editor/preview/select-sortable.js'\nexport * from '~/src/form/form-editor/preview/supporting-evidence.js'\nexport * from '~/src/form/form-editor/preview/long-answer.js'\nexport * from '~/src/form/form-editor/preview/uk-address.js'\nexport * from '~/src/form/form-editor/preview/yes-no.js'\nexport * from '~/src/form/form-editor/preview/controller/page-controller.js'\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
@@ -1,8 +1,10 @@
1
- import { Question } from "./question.js";
1
+ import { ComponentType } from "../../../components/enums.js";
2
+ import { PreviewComponent } from "./preview.js";
3
+ import { Question, QuestionComponentElements } from "./question.js";
2
4
  const DefaultListConst = {
3
5
  TextElementId: 'radioText',
4
6
  HintElementId: 'radioHint',
5
- Template: Question.PATH + 'radios.njk',
7
+ Template: PreviewComponent.PATH + 'radios.njk',
6
8
  Input: 'listInput',
7
9
  RenderName: 'listInputField'
8
10
  };
@@ -24,7 +26,59 @@ export function listsElementToMap(listElements) {
24
26
  const entries = listElements ? listElements.map(listItemMapper) : [];
25
27
  return new Map(entries);
26
28
  }
29
+
30
+ /**
31
+ * @param {Item} item
32
+ * @returns {ListElement}
33
+ */
34
+ export function listItemToListElement(item) {
35
+ return {
36
+ text: item.text,
37
+ label: {
38
+ text: item.text,
39
+ classes: ''
40
+ },
41
+ value: item.value,
42
+ id: item.id ?? '',
43
+ hint: item.hint
44
+ };
45
+ }
46
+
47
+ /**
48
+ * @implements {QuestionElements}
49
+ */
50
+ export class ListComponentElements extends QuestionComponentElements {
51
+ /**
52
+ * @type {List}
53
+ * @protected
54
+ */
55
+ _list;
56
+
57
+ /**
58
+ * @param {SelectionComponentsDef} component
59
+ * @param {List} list
60
+ */
61
+ constructor(component, list) {
62
+ super(component);
63
+ this._list = list;
64
+ }
65
+
66
+ /**
67
+ * @returns {BaseSettings}
68
+ * @protected
69
+ */
70
+ _getValues() {
71
+ return {
72
+ ...super._getValues(),
73
+ items: this._list.items.map(listItemToListElement)
74
+ };
75
+ }
76
+ }
27
77
  export class ListQuestion extends Question {
78
+ /**
79
+ * @type {ComponentType}
80
+ */
81
+ componentType = ComponentType.List;
28
82
  /**
29
83
  * @type {string}
30
84
  * @protected
@@ -187,6 +241,8 @@ export class ListQuestion extends Question {
187
241
 
188
242
  /**
189
243
  * @import { ListElement, ListItemReadonly } from '~/src/form/form-editor/types.js'
190
- * @import { ListElements, QuestionRenderer, DefaultComponent, GovukFieldset } from '~/src/form/form-editor/preview/types.js'
244
+ * @import { SelectionComponentsDef, ListComponentsDef } from '~/src/components/types.js'
245
+ * @import { List, Item } from '~/src/form/form-definition/types.js'
246
+ * @import { ListElements, QuestionRenderer, DefaultComponent, GovukFieldset, BaseSettings, QuestionElements } from '~/src/form/form-editor/preview/types.js'
191
247
  */
192
248
  //# sourceMappingURL=list.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"list.js","names":["Question","DefaultListConst","TextElementId","HintElementId","Template","PATH","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: Question.PATH + '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 /**\n * @returns {{\n * formGroup?: {afterInputs: {html: string}};\n * hint: DefaultComponent;\n * name: string;\n * fieldset?: GovukFieldset;\n * id: string;\n * items: ListItemReadonly[]\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 */\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 { ListElements, QuestionRenderer, DefaultComponent, GovukFieldset } from '~/src/form/form-editor/preview/types.js'\n */\n"],"mappings":"AAAA,SAASA,QAAQ;AAEjB,MAAMC,gBAAgB,GAAG;EACv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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":[]}
1
+ {"version":3,"file":"list.js","names":["ComponentType","PreviewComponent","Question","QuestionComponentElements","DefaultListConst","TextElementId","HintElementId","Template","PATH","Input","RenderName","listItemMapper","listElement","id","listsElementToMap","listElements","entries","map","Map","listItemToListElement","item","text","label","classes","value","hint","ListComponentElements","_list","constructor","component","list","_getValues","items","ListQuestion","componentType","List","_questionTemplate","_listElements","listRenderId","listRenderName","questionRenderer","values","createListFromElements","renderInput","afterInputs","length","formGroup","html","afterInputsHTML","name","fieldset","fieldSet","push","set","render","delete","key","iterator","Array","from","listItem","hintText","_highlight","getHighlight","undefined","updateText","get","updateHint","updateValue"],"sources":["../../../../../src/form/form-editor/preview/list.js"],"sourcesContent":["import { ComponentType } from '~/src/components/enums.js'\nimport { PreviewComponent } from '~/src/form/form-editor/preview/preview.js'\nimport {\n Question,\n QuestionComponentElements\n} from '~/src/form/form-editor/preview/question.js'\n\nconst DefaultListConst = {\n TextElementId: 'radioText',\n HintElementId: 'radioHint',\n Template: PreviewComponent.PATH + '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\n/**\n * @param {Item} item\n * @returns {ListElement}\n */\nexport function listItemToListElement(item) {\n return {\n text: item.text,\n label: {\n text: item.text,\n classes: ''\n },\n value: item.value,\n id: item.id ?? '',\n hint: item.hint\n }\n}\n\n/**\n * @implements {QuestionElements}\n */\nexport class ListComponentElements extends QuestionComponentElements {\n /**\n * @type {List}\n * @protected\n */\n _list\n\n /**\n * @param {SelectionComponentsDef} component\n * @param {List} list\n */\n constructor(component, list) {\n super(component)\n this._list = list\n }\n\n /**\n * @returns {BaseSettings}\n * @protected\n */\n _getValues() {\n return {\n ...super._getValues(),\n items: this._list.items.map(listItemToListElement)\n }\n }\n}\n\nexport class ListQuestion extends Question {\n /**\n * @type {ComponentType}\n */\n componentType = ComponentType.List\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 /**\n * @returns {{\n * formGroup?: {afterInputs: {html: string}};\n * hint: DefaultComponent;\n * name: string;\n * fieldset?: GovukFieldset;\n * id: string;\n * items: ListItemReadonly[]\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 */\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 { SelectionComponentsDef, ListComponentsDef } from '~/src/components/types.js'\n * @import { List, Item } from '~/src/form/form-definition/types.js'\n * @import { ListElements, QuestionRenderer, DefaultComponent, GovukFieldset, BaseSettings, QuestionElements } from '~/src/form/form-editor/preview/types.js'\n */\n"],"mappings":"AAAA,SAASA,aAAa;AACtB,SAASC,gBAAgB;AACzB,SACEC,QAAQ,EACRC,yBAAyB;AAG3B,MAAMC,gBAAgB,GAAG;EACvBC,aAAa,EAAE,WAAW;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