@defra/forms-model 3.0.501 → 3.0.503

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 (42) hide show
  1. package/dist/module/__stubs__/pages.js +14 -1
  2. package/dist/module/__stubs__/pages.js.map +1 -1
  3. package/dist/module/form/form-editor/__stubs__/preview.js +7 -1
  4. package/dist/module/form/form-editor/__stubs__/preview.js.map +1 -1
  5. package/dist/module/form/form-editor/macros/types.js.map +1 -1
  6. package/dist/module/form/form-editor/preview/controller/guidance-page-controller.js +58 -0
  7. package/dist/module/form/form-editor/preview/controller/guidance-page-controller.js.map +1 -0
  8. package/dist/module/form/form-editor/preview/controller/page-controller-base.js +363 -0
  9. package/dist/module/form/form-editor/preview/controller/page-controller-base.js.map +1 -0
  10. package/dist/module/form/form-editor/preview/controller/page-controller.js +62 -186
  11. package/dist/module/form/form-editor/preview/controller/page-controller.js.map +1 -1
  12. package/dist/module/form/form-editor/preview/index.js +2 -0
  13. package/dist/module/form/form-editor/preview/index.js.map +1 -1
  14. package/dist/module/form/form-editor/preview/types.js.map +1 -1
  15. package/dist/module/pages/helpers.js +2 -1
  16. package/dist/module/pages/helpers.js.map +1 -1
  17. package/dist/types/__stubs__/pages.d.ts +14 -0
  18. package/dist/types/__stubs__/pages.d.ts.map +1 -1
  19. package/dist/types/form/form-editor/__stubs__/preview.d.ts +5 -1
  20. package/dist/types/form/form-editor/__stubs__/preview.d.ts.map +1 -1
  21. package/dist/types/form/form-editor/macros/types.d.ts +8 -0
  22. package/dist/types/form/form-editor/macros/types.d.ts.map +1 -1
  23. package/dist/types/form/form-editor/preview/controller/guidance-page-controller.d.ts +10 -0
  24. package/dist/types/form/form-editor/preview/controller/guidance-page-controller.d.ts.map +1 -0
  25. package/dist/types/form/form-editor/preview/controller/page-controller-base.d.ts +198 -0
  26. package/dist/types/form/form-editor/preview/controller/page-controller-base.d.ts.map +1 -0
  27. package/dist/types/form/form-editor/preview/controller/page-controller.d.ts +9 -114
  28. package/dist/types/form/form-editor/preview/controller/page-controller.d.ts.map +1 -1
  29. package/dist/types/form/form-editor/preview/index.d.ts +2 -0
  30. package/dist/types/form/form-editor/preview/types.d.ts +5 -1
  31. package/dist/types/form/form-editor/preview/types.d.ts.map +1 -1
  32. package/dist/types/pages/helpers.d.ts.map +1 -1
  33. package/package.json +1 -1
  34. package/src/__stubs__/pages.ts +20 -1
  35. package/src/form/form-editor/__stubs__/preview.js +13 -1
  36. package/src/form/form-editor/macros/types.ts +8 -0
  37. package/src/form/form-editor/preview/controller/guidance-page-controller.js +64 -0
  38. package/src/form/form-editor/preview/controller/page-controller-base.js +388 -0
  39. package/src/form/form-editor/preview/controller/page-controller.js +67 -201
  40. package/src/form/form-editor/preview/index.js +2 -0
  41. package/src/form/form-editor/preview/types.ts +6 -1
  42. package/src/pages/helpers.ts +2 -1
@@ -1,9 +1,7 @@
1
- import { ComponentType } from "../../../../components/enums.js";
2
- import { HIGHLIGHT_CLASS } from "../constants.js";
3
- import { ContentElements } from "../content.js";
1
+ import { PreviewPageControllerBase } from "./page-controller-base.js";
4
2
  import { mapComponentToPreviewQuestion } from "../helpers.js";
5
3
  import { Markdown } from "../markdown.js";
6
- import { hasComponents } from "../../../../pages/helpers.js";
4
+
7
5
  /**
8
6
  * @type {QuestionRenderer}
9
7
  */
@@ -16,88 +14,14 @@ const questionRenderer = {
16
14
  //
17
15
  }
18
16
  };
19
-
20
- /**
21
- * @implements {PageOverviewElements}
22
- */
23
- export class PagePreviewElements {
24
- /**
25
- * @type {Page}
26
- * @private
27
- */
28
- _page;
29
-
30
- /**
31
- * @param {Page} page
32
- */
33
- constructor(page) {
34
- this._page = page;
35
- }
36
- get heading() {
37
- return this._page.title;
38
- }
39
- get guidance() {
40
- if (!hasComponents(this._page) || !this._page.components.length) {
41
- return '';
42
- }
43
- const [possibleGuidanceComponent] = this._page.components;
44
- return possibleGuidanceComponent.type === ComponentType.Markdown ? possibleGuidanceComponent.content : '';
45
- }
46
- get addHeading() {
47
- return this._page.title.length > 0;
48
- }
49
- }
50
-
51
- /**
52
- * @implements {PagePreviewPanelMacro}
53
- */
54
- export class PreviewPageController {
55
- static PATH = 'preview-controllers/';
56
- /**
57
- * @type {string}
58
- * @protected
59
- */
60
- _pageTemplate = PreviewPageController.PATH + 'page-controller.njk';
17
+ export class PreviewPageController extends PreviewPageControllerBase {
18
+ static PATH = PreviewPageControllerBase.PATH;
61
19
  /**
62
20
  * @protected
63
21
  * @type {Question[]}
64
22
  */
65
23
  _components = [];
66
- /**
67
- * @type {string}
68
- */
69
- #title = '';
70
- /**
71
- *
72
- * @type {PageRenderer}
73
- */
74
- #pageRenderer;
75
- /**
76
- * @type { undefined | 'title' | 'guidance'}
77
- * @protected
78
- */
79
- _highlighted = undefined;
80
- /**
81
- * @type {string}
82
- * @private
83
- */
84
- _guidanceText = '';
85
- /**
86
- * @type {Markdown}
87
- * @private
88
- */
89
- _emptyGuidance = PreviewPageController.createGuidanceComponent();
90
- /**
91
- *
92
- * @type {Markdown}
93
- * @protected
94
- */
95
- _guidanceComponent;
96
- /**
97
- * @type {boolean}
98
- * @private
99
- */
100
- _showTitle = true;
24
+
101
25
  /**
102
26
  * @param {ComponentDef[]} components
103
27
  * @param {PageOverviewElements} elements
@@ -105,6 +29,7 @@ export class PreviewPageController {
105
29
  * @param {PageRenderer} renderer
106
30
  */
107
31
  constructor(components, elements, definition, renderer) {
32
+ super(elements, renderer);
108
33
  const questions = components.map(mapComponentToPreviewQuestion(questionRenderer, definition));
109
34
  const firstQuestion = /** @type { Markdown | undefined | Question } */
110
35
  questions.shift();
@@ -112,10 +37,15 @@ export class PreviewPageController {
112
37
  this._guidanceText = elements.guidance;
113
38
  this._components = this.#constructComponents(firstQuestion, questions);
114
39
  this._showTitle = elements.addHeading;
115
- this.#pageRenderer = renderer;
116
- this.#title = elements.heading;
40
+ this._sectionTitle = elements.repeatQuestion ?? '';
41
+ this._isRepeater = elements.hasRepeater;
117
42
  }
118
43
 
44
+ /**
45
+ * @type {typeof PreviewPageControllerBase.HighlightClass}
46
+ */
47
+ static HighlightClass = PreviewPageControllerBase.HighlightClass;
48
+
119
49
  /**
120
50
  * @param { Question | Markdown | undefined} firstQuestion
121
51
  * @param {Question[]} questions
@@ -125,20 +55,6 @@ export class PreviewPageController {
125
55
  return firstQuestion instanceof Markdown || firstQuestion === undefined ? questions : [firstQuestion, ...questions];
126
56
  }
127
57
 
128
- /**
129
- * @returns {Markdown[]}
130
- * @private
131
- */
132
- get _guidanceComponents() {
133
- if (this._guidanceText.length) {
134
- return [this._guidanceComponent];
135
- }
136
- if (this._highlighted === 'guidance') {
137
- return [this._emptyGuidance];
138
- }
139
- return [];
140
- }
141
-
142
58
  /**
143
59
  * @returns {PagePreviewComponent[]}
144
60
  */
@@ -161,7 +77,7 @@ export class PreviewPageController {
161
77
  return false;
162
78
  }
163
79
  // |_ one component and title not highlighted
164
- if (this.#title.trim() === this._components[0].question.trim()) {
80
+ if (this._title.trim() === this._components[0]?.question.trim()) {
165
81
  return true;
166
82
  }
167
83
  // titles not the same
@@ -195,98 +111,75 @@ export class PreviewPageController {
195
111
  ...label
196
112
  };
197
113
  }
198
- set guidanceText(text) {
199
- this._guidanceText = text;
200
- this._guidanceComponent.content = text;
201
- this.render();
202
- }
203
- get guidanceText() {
204
- if (!this._showTitle) {
205
- return '';
206
- }
207
- return this._guidanceText;
208
- }
209
-
210
- /**
211
- *
212
- * @param {boolean} showTitle
213
- */
214
- set showTitle(showTitle) {
215
- this._showTitle = showTitle;
216
- this.render();
217
- }
218
- get showTitle() {
219
- return this._showTitle;
220
- }
221
- get guidance() {
222
- return {
223
- text: this.guidanceText,
224
- classes: this._highlighted === 'guidance' ? 'highlight' : ''
225
- };
226
- }
227
-
228
- /**
229
- * @returns {{ text: string, classes: string }}
230
- */
231
- get pageTitle() {
232
- return {
233
- text: this.title,
234
- classes: this._highlighted === 'title' ? HIGHLIGHT_CLASS : ''
235
- };
236
- }
237
- render() {
238
- this.#pageRenderer.render(this._pageTemplate, this);
239
- }
240
114
 
241
115
  /**
242
116
  * @returns {boolean}
243
117
  */
244
118
  get titleAndFirstTitleSame() {
245
- return this._components.length > 0 && this.#title.trim() === this._components[0].question.trim() && this.components.length === 1 && this._highlighted !== 'title';
119
+ return this._components.length > 0 && this._title.trim() === this._components[0]?.question.trim() && this.components.length === 1 && this._highlighted !== 'title';
246
120
  }
247
121
 
248
122
  /**
249
123
  * @returns {string}
124
+ * @protected
250
125
  */
251
- get title() {
126
+ _getTitle() {
252
127
  if (!this._showTitle || this.titleAndFirstTitleSame) {
253
128
  return '';
254
129
  }
255
- if (this.#title.length) {
256
- return this.#title;
257
- }
258
- return 'Page heading';
130
+ return super._getTitle();
259
131
  }
260
132
 
261
133
  /**
262
- * @param {string} value
134
+ * @returns {string}
135
+ * @protected
263
136
  */
264
- set title(value) {
265
- this.#title = value;
266
- this.render();
137
+ _getGuidanceText() {
138
+ if (!this._showTitle) {
139
+ return '';
140
+ }
141
+ return super._getGuidanceText();
267
142
  }
268
- highlightTitle() {
269
- this.setHighLighted('title');
143
+ get repeaterText() {
144
+ if (!this._isRepeater) {
145
+ return undefined;
146
+ }
147
+ if (!this._sectionTitle.length) {
148
+ return 'Question set name';
149
+ }
150
+ return this._sectionTitle + ' 1';
270
151
  }
271
152
 
272
153
  /**
273
- * Creates a dummy component for when guidance is highlighted
274
- * but no guidance text exists
275
- * @returns {Markdown}
154
+ * @returns {string|undefined}
155
+ * @protected
276
156
  */
277
- static createGuidanceComponent() {
278
- const guidanceElement = new ContentElements({
279
- type: ComponentType.Markdown,
280
- title: 'Guidance component',
281
- name: 'guidanceComponent',
282
- content: 'Guidance text',
283
- options: {}
284
- });
285
- const guidanceComponent = new Markdown(guidanceElement, questionRenderer);
286
-
287
- // the dummy component should always be highlighted
288
- guidanceComponent.highlightContent();
289
- return guidanceComponent;
157
+ _getSectionTitleText() {
158
+ if (this._isRepeater) {
159
+ return this.repeaterText;
160
+ }
161
+ return undefined;
162
+ }
163
+ get repeaterButton() {
164
+ if (this.repeaterButtonText === undefined) {
165
+ return undefined;
166
+ }
167
+ return {
168
+ classes: this._isHighlighted(PreviewPageControllerBase.HighlightClass.REPEATER),
169
+ text: this.repeaterButtonText
170
+ };
171
+ }
172
+ get repeaterButtonText() {
173
+ if (!this._isRepeater) {
174
+ return undefined;
175
+ }
176
+ if (this._sectionTitle === '') {
177
+ return '[question set name]';
178
+ }
179
+ const [firstToken, ...rest] = this._sectionTitle;
180
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
181
+ const restOfStr = rest ? rest.join('') : '';
182
+ return firstToken.toLowerCase() + restOfStr;
290
183
  }
291
184
 
292
185
  /**
@@ -299,24 +192,7 @@ export class PreviewPageController {
299
192
  if (guidanceComponent instanceof Markdown) {
300
193
  return guidanceComponent;
301
194
  }
302
- return PreviewPageController.createGuidanceComponent();
303
- }
304
- highlightGuidance() {
305
- this._guidanceComponent.highlightContent();
306
- this.setHighLighted('guidance');
307
- }
308
-
309
- /**
310
- * @param {'title'|'guidance'} highlightSection
311
- */
312
- setHighLighted(highlightSection) {
313
- this._highlighted = highlightSection;
314
- this.render();
315
- }
316
- clearHighlight() {
317
- this._highlighted = undefined;
318
- this._guidanceComponent.unHighlightContent();
319
- this.render();
195
+ return PreviewPageControllerBase.createGuidanceComponent();
320
196
  }
321
197
  }
322
198
 
@@ -1 +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","addHeading","PreviewPageController","PATH","_pageTemplate","_components","pageRenderer","_highlighted","undefined","_guidanceText","_emptyGuidance","createGuidanceComponent","_guidanceComponent","_showTitle","elements","definition","renderer","questions","map","firstQuestion","shift","getOrCreateGuidanceComponent","constructComponents","#constructComponents","_guidanceComponents","componentsWithGuidance","component","model","_overrideComponentHeading","questionType","componentType","showLargeTitle","componentsLength","trim","question","largeTitle","fieldset","renderInput","legend","classes","label","guidanceText","text","showTitle","pageTitle","titleAndFirstTitleSame","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 /**\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 get addHeading() {\n return this._page.title.length > 0\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 * @type {boolean}\n * @private\n */\n _showTitle = true\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._showTitle = elements.addHeading\n\n this.#pageRenderer = renderer\n this.#title = elements.heading\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 return {\n model: this._overrideComponentHeading(component),\n questionType: component.componentType\n }\n })\n }\n\n /**\n * @returns {boolean}\n */\n get showLargeTitle() {\n const componentsLength =\n this._components.length + this._guidanceComponents.length\n\n if (componentsLength > 1 || this._highlighted === 'title') {\n return false\n }\n // |_ one component and title not highlighted\n if (this.#title.trim() === this._components[0].question.trim()) {\n return true\n }\n // titles not the same\n\n return !this._showTitle // add page heading deselected?\n }\n\n /**\n * @param {PreviewComponent} component\n * @returns {QuestionBaseModel}\n */\n _overrideComponentHeading(component) {\n const largeTitle = this.showLargeTitle\n\n const fieldset = component.renderInput.fieldset\n ? {\n fieldset: {\n legend: {\n ...component.renderInput.fieldset.legend,\n classes: largeTitle\n ? 'govuk-fieldset__legend--l'\n : 'govuk-fieldset__legend--m'\n }\n }\n }\n : {}\n\n const label = component.renderInput.label\n ? {\n label: {\n ...component.renderInput.label,\n classes: largeTitle ? 'govuk-label--l' : 'govuk-label--m'\n }\n }\n : {}\n\n return {\n ...component.renderInput,\n ...fieldset,\n ...label\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 if (!this._showTitle) {\n return ''\n }\n return this._guidanceText\n }\n\n /**\n *\n * @param {boolean} showTitle\n */\n set showTitle(showTitle) {\n this._showTitle = showTitle\n this.render()\n }\n\n get showTitle() {\n return this._showTitle\n }\n\n get guidance() {\n return {\n text: this.guidanceText,\n classes: this._highlighted === 'guidance' ? 'highlight' : ''\n }\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 {boolean}\n */\n get titleAndFirstTitleSame() {\n return (\n this._components.length > 0 &&\n this.#title.trim() === this._components[0].question.trim() &&\n this.components.length === 1 &&\n this._highlighted !== 'title'\n )\n }\n\n /**\n * @returns {string}\n */\n get title() {\n if (!this._showTitle || this.titleAndFirstTitleSame) {\n return ''\n }\n if (this.#title.length) {\n return this.#title\n }\n return 'Page heading'\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 { PreviewComponent } from '~/src/form/form-editor/preview/preview.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,KA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ACzC,OAAOqE,iBAAiB;IAC1B;IACA,OAAOlD,qBAAqB,CAACS,uBAAuB,CAAC,CAAC;EACxD;EAEA2C,iBAAiBA,CAAA,EAAG;IAClB,IAAI,CAAC1C,kBAAkB,CAACyC,gBAAgB,CAAC,CAAC;IAC1C,IAAI,CAACL,cAAc,CAAC,UAAU,CAAC;EACjC;;EAEA;AACF;AACA;EACEA,cAAcA,CAACO,gBAAgB,EAAE;IAC/B,IAAI,CAAChD,YAAY,GAAGgD,gBAAgB;IACpC,IAAI,CAACrE,MAAM,CAAC,CAAC;EACf;EAEAsE,cAAcA,CAAA,EAAG;IACf,IAAI,CAACjD,YAAY,GAAGC,SAAS;IAE7B,IAAI,CAACI,kBAAkB,CAAC6C,kBAAkB,CAAC,CAAC;IAC5C,IAAI,CAACvE,MAAM,CAAC,CAAC;EACf;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
1
+ {"version":3,"file":"page-controller.js","names":["PreviewPageControllerBase","mapComponentToPreviewQuestion","Markdown","questionRenderer","render","_questionTemplate","_questionBaseModel","PreviewPageController","PATH","_components","constructor","components","elements","definition","renderer","questions","map","firstQuestion","shift","_guidanceComponent","getOrCreateGuidanceComponent","_guidanceText","guidance","constructComponents","_showTitle","addHeading","_sectionTitle","repeatQuestion","_isRepeater","hasRepeater","HighlightClass","#constructComponents","undefined","componentsWithGuidance","_guidanceComponents","component","model","_overrideComponentHeading","questionType","componentType","showLargeTitle","componentsLength","length","_highlighted","_title","trim","question","largeTitle","fieldset","renderInput","legend","classes","label","titleAndFirstTitleSame","_getTitle","_getGuidanceText","repeaterText","_getSectionTitleText","repeaterButton","repeaterButtonText","_isHighlighted","REPEATER","text","firstToken","rest","restOfStr","join","toLowerCase","guidanceComponent","createGuidanceComponent"],"sources":["../../../../../../src/form/form-editor/preview/controller/page-controller.js"],"sourcesContent":["import { PreviewPageControllerBase } from '~/src/form/form-editor/preview/controller/page-controller-base.js'\nimport { mapComponentToPreviewQuestion } from '~/src/form/form-editor/preview/helpers.js'\nimport { Markdown } from '~/src/form/form-editor/preview/markdown.js'\n\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\nexport class PreviewPageController extends PreviewPageControllerBase {\n static PATH = PreviewPageControllerBase.PATH\n /**\n * @protected\n * @type {Question[]}\n */\n _components = []\n\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 super(elements, renderer)\n const questions = components.map(\n mapComponentToPreviewQuestion(questionRenderer, definition)\n )\n const firstQuestion = /** @type { Markdown | undefined | Question } */ (\n questions.shift()\n )\n this._guidanceComponent =\n PreviewPageController.getOrCreateGuidanceComponent(firstQuestion)\n this._guidanceText = elements.guidance\n this._components = this.#constructComponents(firstQuestion, questions)\n this._showTitle = elements.addHeading\n this._sectionTitle = elements.repeatQuestion ?? ''\n this._isRepeater = elements.hasRepeater\n }\n\n /**\n * @type {typeof PreviewPageControllerBase.HighlightClass}\n */\n static HighlightClass = PreviewPageControllerBase.HighlightClass\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 {PagePreviewComponent[]}\n */\n get components() {\n const componentsWithGuidance = /** @type {Question[]} */ ([\n ...this._guidanceComponents,\n ...this._components\n ])\n\n return componentsWithGuidance.map((component) => {\n return {\n model: this._overrideComponentHeading(component),\n questionType: component.componentType\n }\n })\n }\n\n /**\n * @returns {boolean}\n */\n get showLargeTitle() {\n const componentsLength =\n this._components.length + this._guidanceComponents.length\n\n if (componentsLength > 1 || this._highlighted === 'title') {\n return false\n }\n // |_ one component and title not highlighted\n if (this._title.trim() === this._components[0]?.question.trim()) {\n return true\n }\n // titles not the same\n\n return !this._showTitle // add page heading deselected?\n }\n\n /**\n * @param {PreviewComponent} component\n * @returns {QuestionBaseModel}\n */\n _overrideComponentHeading(component) {\n const largeTitle = this.showLargeTitle\n\n const fieldset = component.renderInput.fieldset\n ? {\n fieldset: {\n legend: {\n ...component.renderInput.fieldset.legend,\n classes: largeTitle\n ? 'govuk-fieldset__legend--l'\n : 'govuk-fieldset__legend--m'\n }\n }\n }\n : {}\n\n const label = component.renderInput.label\n ? {\n label: {\n ...component.renderInput.label,\n classes: largeTitle ? 'govuk-label--l' : 'govuk-label--m'\n }\n }\n : {}\n\n return {\n ...component.renderInput,\n ...fieldset,\n ...label\n }\n }\n\n /**\n * @returns {boolean}\n */\n get titleAndFirstTitleSame() {\n return (\n this._components.length > 0 &&\n this._title.trim() === this._components[0]?.question.trim() &&\n this.components.length === 1 &&\n this._highlighted !== 'title'\n )\n }\n\n /**\n * @returns {string}\n * @protected\n */\n _getTitle() {\n if (!this._showTitle || this.titleAndFirstTitleSame) {\n return ''\n }\n return super._getTitle()\n }\n\n /**\n * @returns {string}\n * @protected\n */\n _getGuidanceText() {\n if (!this._showTitle) {\n return ''\n }\n return super._getGuidanceText()\n }\n\n get repeaterText() {\n if (!this._isRepeater) {\n return undefined\n }\n if (!this._sectionTitle.length) {\n return 'Question set name'\n }\n return this._sectionTitle + ' 1'\n }\n\n /**\n * @returns {string|undefined}\n * @protected\n */\n _getSectionTitleText() {\n if (this._isRepeater) {\n return this.repeaterText\n }\n return undefined\n }\n\n get repeaterButton() {\n if (this.repeaterButtonText === undefined) {\n return undefined\n }\n return {\n classes: this._isHighlighted(\n PreviewPageControllerBase.HighlightClass.REPEATER\n ),\n text: this.repeaterButtonText\n }\n }\n\n get repeaterButtonText() {\n if (!this._isRepeater) {\n return undefined\n }\n\n if (this._sectionTitle === '') {\n return '[question set name]'\n }\n\n const [firstToken, ...rest] = this._sectionTitle\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n const restOfStr = rest ? rest.join('') : ''\n return firstToken.toLowerCase() + restOfStr\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 PreviewPageControllerBase.createGuidanceComponent()\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 { PreviewComponent } from '~/src/form/form-editor/preview/preview.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,yBAAyB;AAClC,SAASC,6BAA6B;AACtC,SAASC,QAAQ;;AAEjB;AACA;AACA;AACA,MAAMC,gBAAgB,GAAG;EACvB;AACF;AACA;AACA;EACEC,MAAMA,CAACC,iBAAiB,EAAEC,kBAAkB,EAAE;IAC5C;EAAA;AAEJ,CAAC;AAED,OAAO,MAAMC,qBAAqB,SAASP,yBAAyB,CAAC;EACnE,OAAOQ,IAAI,GAAGR,yBAAyB,CAACQ,IAAI;EAC5C;AACF;AACA;AACA;EACEC,WAAW,GAAG,EAAE;;EAEhB;AACF;AACA;AACA;AACA;AACA;EACEC,WAAWA,CAACC,UAAU,EAAEC,QAAQ,EAAEC,UAAU,EAAEC,QAAQ,EAAE;IACtD,KAAK,CAACF,QAAQ,EAAEE,QAAQ,CAAC;IACzB,MAAMC,SAAS,GAAGJ,UAAU,CAACK,GAAG,CAC9Bf,6BAA6B,CAACE,gBAAgB,EAAEU,UAAU,CAC5D,CAAC;IACD,MAAMI,aAAa,GAAG;IACpB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M,CAACqC,UAAU,EAAE,GAAGC,IAAI,CAAC,GAAG,IAAI,CAACtC,aAAa;IAChD;IACA,MAAMuC,SAAS,GAAGD,IAAI,GAAGA,IAAI,CAACE,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE;IAC3C,OAAOH,UAAU,CAACI,WAAW,CAAC,CAAC,GAAGF,SAAS;EAC7C;;EAEA;AACF;AACA;AACA;AACA;AACA;EACE,OAAO7C,4BAA4BA,CAACgD,iBAAiB,EAAE;IACrD,IAAIA,iBAAiB,YAAYlE,QAAQ,EAAE;MACzC,OAAOkE,iBAAiB;IAC1B;IACA,OAAOpE,yBAAyB,CAACqE,uBAAuB,CAAC,CAAC;EAC5D;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
@@ -21,4 +21,6 @@ export * from "./long-answer.js";
21
21
  export * from "./uk-address.js";
22
22
  export * from "./yes-no.js";
23
23
  export * from "./controller/page-controller.js";
24
+ export * from "./controller/guidance-page-controller.js";
25
+ export * from "./controller/page-controller-base.js";
24
26
  //# 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.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
+ {"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'\nexport * from '~/src/form/form-editor/preview/controller/guidance-page-controller.js'\nexport * from '~/src/form/form-editor/preview/controller/page-controller-base.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;AACA;AACA","ignoreList":[]}
@@ -1 +1 @@
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 attributes?: Record<string, 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 DomElementsBase {\n readonly values?: BaseSettings\n autocompleteOptions?: string\n setPreviewHTML(value: string): void\n setPreviewDOM(element: HTMLElement): void\n}\n\nexport interface QuestionElements extends DomElementsBase {\n readonly values: BaseSettings\n}\n\nexport interface AutocompleteElements extends QuestionElements {\n autocompleteOptions: string\n}\n\nexport interface RenderBase {\n render(questionTemplate: string, renderContext: RenderContext): void\n}\n\nexport interface QuestionRenderContext {\n model: QuestionBaseModel\n}\n\nexport interface PageRenderContext {\n params: PagePreviewPanelMacro\n}\n\nexport type RenderContext = QuestionRenderContext | PageRenderContext\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 type Renderer = QuestionRenderer | PageRenderer\n\nexport interface ListElements extends QuestionElements {\n afterInputsHTML: string\n}\n\nexport interface PageOverviewElements {\n heading: string\n guidance: string\n addHeading: boolean\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
+ {"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 attributes?: Record<string, 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 DomElementsBase {\n readonly values?: BaseSettings\n autocompleteOptions?: string\n setPreviewHTML(value: string): void\n setPreviewDOM(element: HTMLElement): void\n}\n\nexport interface QuestionElements extends DomElementsBase {\n readonly values: BaseSettings\n}\n\nexport interface AutocompleteElements extends QuestionElements {\n autocompleteOptions: string\n}\n\nexport interface RenderBase {\n render(questionTemplate: string, renderContext: RenderContext): void\n}\n\nexport interface QuestionRenderContext {\n model: QuestionBaseModel\n}\n\nexport interface PageRenderContext {\n params: PagePreviewPanelMacro\n}\n\nexport type RenderContext = QuestionRenderContext | PageRenderContext\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 type Renderer = QuestionRenderer | PageRenderer\n\nexport interface ListElements extends QuestionElements {\n afterInputsHTML: string\n}\n\nexport interface PagePreviewBaseElements {\n heading: string\n guidance: string\n}\n\nexport interface PageOverviewElements extends PagePreviewBaseElements {\n addHeading: boolean\n repeatQuestion: string | undefined\n hasRepeater: boolean\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,4 +1,5 @@
1
- import { ComponentType, hasFormField } from "../index.js";
1
+ import { ComponentType } from "../components/enums.js";
2
+ import { hasFormField } from "../components/helpers.js";
2
3
  import { ControllerNames, ControllerTypes } from "./controller-types.js";
3
4
  import { ControllerType } from "./enums.js";
4
5
  import { PageTypes } from "./page-types.js";
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.js","names":["ComponentType","hasFormField","ControllerNames","ControllerTypes","ControllerType","PageTypes","getPageDefaults","page","nameOrPath","controller","Page","controllerNameFromPath","defaults","find","pageType","Error","structuredClone","hasComponents","hasNext","Array","isArray","components","hasComponentsEvenIfNoNext","undefined","hasFormComponents","Start","hasRepeater","Repeat","isControllerName","map","String","includes","Terminal","FileUpload","options","path","name","includesFileUploadField","some","component","type","FileUploadField","SHOW_REPEATER_CONTROLLERS","showRepeaterSettings","omitFileUploadComponent","length","getPageTitle","title","firstComp"],"sources":["../../../src/pages/helpers.ts"],"sourcesContent":["import { type ComponentDef } from '~/src/components/types.js'\nimport {\n type Link,\n type Page,\n type PageFileUpload,\n type PageQuestion,\n type PageRepeat\n} from '~/src/form/form-definition/types.js'\nimport { ComponentType, hasFormField } from '~/src/index.js'\nimport {\n ControllerNames,\n ControllerTypes\n} from '~/src/pages/controller-types.js'\nimport { ControllerType } from '~/src/pages/enums.js'\nimport { PageTypes } from '~/src/pages/page-types.js'\n\n/**\n * Return component defaults by type\n */\nexport function getPageDefaults<PageType extends Page>(\n page?: Pick<PageType, 'controller'>\n) {\n const nameOrPath = page?.controller ?? ControllerType.Page\n const controller = controllerNameFromPath(nameOrPath)\n\n const defaults = PageTypes.find(\n (pageType) => pageType.controller === controller\n )\n\n if (!defaults) {\n throw new Error(`Defaults not found for page type '${nameOrPath}'`)\n }\n\n return structuredClone(defaults) as PageType\n}\n\n/**\n * Check page has components\n */\nexport function hasComponents(\n page?: Partial<Page>\n): page is Extract<Page, { components: ComponentDef[] }> {\n return hasNext(page) && Array.isArray(page.components)\n}\n\n/**\n * Check if the page has components (the page can be any page type e.g. SummaryPage)\n */\nexport function hasComponentsEvenIfNoNext(\n page?: Partial<Page>\n): page is Extract<Page, { components: ComponentDef[] }> {\n return (\n page !== undefined && 'components' in page && Array.isArray(page.components)\n )\n}\n\n/**\n * Check page has form components\n */\nexport function hasFormComponents(\n page?: Partial<Page>\n): page is PageQuestion | PageFileUpload {\n const controller = controllerNameFromPath(page?.controller)\n return hasComponents(page) && controller !== ControllerType.Start\n}\n\n/**\n * Check page has repeater\n */\nexport function hasRepeater(page?: Partial<Page>): page is PageRepeat {\n return controllerNameFromPath(page?.controller) === ControllerType.Repeat\n}\n\n/**\n * Check for known page controller names\n */\nexport function isControllerName(\n nameOrPath?: ControllerType | string\n): nameOrPath is ControllerType {\n return !!nameOrPath && ControllerNames.map(String).includes(nameOrPath)\n}\n\n/**\n * Check page has next link\n */\nexport function hasNext(\n page?: Partial<Page>\n): page is Extract<Page, { next: Link[] }> {\n if (!page || !('next' in page)) {\n return false\n }\n\n const controller = controllerNameFromPath(page.controller)\n\n return (\n !controller ||\n controller === ControllerType.Start ||\n controller === ControllerType.Page ||\n controller === ControllerType.Terminal ||\n controller === ControllerType.FileUpload ||\n controller === ControllerType.Repeat\n )\n}\n\n/**\n * Check and optionally replace legacy path with controller name\n * @param {string} [nameOrPath] - Controller name or legacy controller path\n */\nexport function controllerNameFromPath(nameOrPath?: ControllerType | string) {\n if (isControllerName(nameOrPath)) {\n return nameOrPath\n }\n\n const options = ControllerTypes.find(({ path }) => path === nameOrPath)\n return options?.name\n}\n\nfunction includesFileUploadField(components: ComponentDef[]): boolean {\n return components.some(\n (component) => component.type === ComponentType.FileUploadField\n )\n}\n\nconst SHOW_REPEATER_CONTROLLERS = [ControllerType.Page, ControllerType.Repeat]\n\nexport function showRepeaterSettings(page: Page): boolean {\n if (page.controller && !SHOW_REPEATER_CONTROLLERS.includes(page.controller)) {\n return false\n }\n if (hasComponents(page) && includesFileUploadField(page.components)) {\n return false\n }\n return true\n}\n\n/**\n * High level check for whether file upload component should be omitted\n * @param { Page | undefined } page\n * @returns {boolean}\n */\nexport function omitFileUploadComponent(page: Page | undefined): boolean {\n if (page?.controller === ControllerType.Repeat) {\n return true\n }\n if (!hasComponents(page)) {\n return false\n }\n if (page.components.length > 1) {\n return true\n }\n if (includesFileUploadField(page.components)) {\n return true\n }\n return false\n}\n\n/**\n * Gets page title, or title of first question (if no page title set)\n * @param {Page} page\n * @returns {string}\n */\nexport function getPageTitle(page: Page) {\n if (page.title !== '') {\n return page.title\n }\n\n if (hasComponentsEvenIfNoNext(page)) {\n const firstComp = page.components.find(hasFormField)\n if (firstComp) {\n return firstComp.title\n }\n }\n return 'Page title unknown'\n}\n"],"mappings":"AAQA,SAASA,aAAa,EAAEC,YAAY;AACpC,SACEC,eAAe,EACfC,eAAe;AAEjB,SAASC,cAAc;AACvB,SAASC,SAAS;;AAElB;AACA;AACA;AACA,OAAO,SAASC,eAAeA,CAC7BC,IAAmC,EACnC;EACA,MAAMC,UAAU,GAAGD,IAAI,EAAEE,UAAU,IAAIL,cAAc,CAACM,IAAI;EAC1D,MAAMD,UAAU,GAAGE,sBAAsB,CAACH,UAAU,CAAC;EAErD,MAAMI,QAAQ,GAAGP,SAAS,CAACQ,IAAI,CAC5BC,QAAQ,IAAKA,QAAQ,CAACL,UAAU,KAAKA,UACxC,CAAC;EAED,IAAI,CAACG,QAAQ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IAAI;EACb;EACA,IAAI,CAACV,aAAa,CAACV,IAAI,CAAC,EAAE;IACxB,OAAO,KAAK;EACd;EACA,IAAIA,IAAI,CAACc,UAAU,CAACwB,MAAM,GAAG,CAAC,EAAE;IAC9B,OAAO,IAAI;EACb;EACA,IAAIR,uBAAuB,CAAC9B,IAAI,CAACc,UAAU,CAAC,EAAE;IAC5C,OAAO,IAAI;EACb;EACA,OAAO,KAAK;AACd;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASyB,YAAYA,CAACvC,IAAU,EAAE;EACvC,IAAIA,IAAI,CAACwC,KAAK,KAAK,EAAE,EAAE;IACrB,OAAOxC,IAAI,CAACwC,KAAK;EACnB;EAEA,IAAIzB,yBAAyB,CAACf,IAAI,CAAC,EAAE;IACnC,MAAMyC,SAAS,GAAGzC,IAAI,CAACc,UAAU,CAACR,IAAI,CAACZ,YAAY,CAAC;IACpD,IAAI+C,SAAS,EAAE;MACb,OAAOA,SAAS,CAACD,KAAK;IACxB;EACF;EACA,OAAO,oBAAoB;AAC7B","ignoreList":[]}
1
+ {"version":3,"file":"helpers.js","names":["ComponentType","hasFormField","ControllerNames","ControllerTypes","ControllerType","PageTypes","getPageDefaults","page","nameOrPath","controller","Page","controllerNameFromPath","defaults","find","pageType","Error","structuredClone","hasComponents","hasNext","Array","isArray","components","hasComponentsEvenIfNoNext","undefined","hasFormComponents","Start","hasRepeater","Repeat","isControllerName","map","String","includes","Terminal","FileUpload","options","path","name","includesFileUploadField","some","component","type","FileUploadField","SHOW_REPEATER_CONTROLLERS","showRepeaterSettings","omitFileUploadComponent","length","getPageTitle","title","firstComp"],"sources":["../../../src/pages/helpers.ts"],"sourcesContent":["import { ComponentType } from '~/src/components/enums.js'\nimport { hasFormField } from '~/src/components/helpers.js'\nimport { type ComponentDef } from '~/src/components/types.js'\nimport {\n type Link,\n type Page,\n type PageFileUpload,\n type PageQuestion,\n type PageRepeat\n} from '~/src/form/form-definition/types.js'\nimport {\n ControllerNames,\n ControllerTypes\n} from '~/src/pages/controller-types.js'\nimport { ControllerType } from '~/src/pages/enums.js'\nimport { PageTypes } from '~/src/pages/page-types.js'\n\n/**\n * Return component defaults by type\n */\nexport function getPageDefaults<PageType extends Page>(\n page?: Pick<PageType, 'controller'>\n) {\n const nameOrPath = page?.controller ?? ControllerType.Page\n const controller = controllerNameFromPath(nameOrPath)\n\n const defaults = PageTypes.find(\n (pageType) => pageType.controller === controller\n )\n\n if (!defaults) {\n throw new Error(`Defaults not found for page type '${nameOrPath}'`)\n }\n\n return structuredClone(defaults) as PageType\n}\n\n/**\n * Check page has components\n */\nexport function hasComponents(\n page?: Partial<Page>\n): page is Extract<Page, { components: ComponentDef[] }> {\n return hasNext(page) && Array.isArray(page.components)\n}\n\n/**\n * Check if the page has components (the page can be any page type e.g. SummaryPage)\n */\nexport function hasComponentsEvenIfNoNext(\n page?: Partial<Page>\n): page is Extract<Page, { components: ComponentDef[] }> {\n return (\n page !== undefined && 'components' in page && Array.isArray(page.components)\n )\n}\n\n/**\n * Check page has form components\n */\nexport function hasFormComponents(\n page?: Partial<Page>\n): page is PageQuestion | PageFileUpload {\n const controller = controllerNameFromPath(page?.controller)\n return hasComponents(page) && controller !== ControllerType.Start\n}\n\n/**\n * Check page has repeater\n */\nexport function hasRepeater(page?: Partial<Page>): page is PageRepeat {\n return controllerNameFromPath(page?.controller) === ControllerType.Repeat\n}\n\n/**\n * Check for known page controller names\n */\nexport function isControllerName(\n nameOrPath?: ControllerType | string\n): nameOrPath is ControllerType {\n return !!nameOrPath && ControllerNames.map(String).includes(nameOrPath)\n}\n\n/**\n * Check page has next link\n */\nexport function hasNext(\n page?: Partial<Page>\n): page is Extract<Page, { next: Link[] }> {\n if (!page || !('next' in page)) {\n return false\n }\n\n const controller = controllerNameFromPath(page.controller)\n\n return (\n !controller ||\n controller === ControllerType.Start ||\n controller === ControllerType.Page ||\n controller === ControllerType.Terminal ||\n controller === ControllerType.FileUpload ||\n controller === ControllerType.Repeat\n )\n}\n\n/**\n * Check and optionally replace legacy path with controller name\n * @param {string} [nameOrPath] - Controller name or legacy controller path\n */\nexport function controllerNameFromPath(nameOrPath?: ControllerType | string) {\n if (isControllerName(nameOrPath)) {\n return nameOrPath\n }\n\n const options = ControllerTypes.find(({ path }) => path === nameOrPath)\n return options?.name\n}\n\nfunction includesFileUploadField(components: ComponentDef[]): boolean {\n return components.some(\n (component) => component.type === ComponentType.FileUploadField\n )\n}\n\nconst SHOW_REPEATER_CONTROLLERS = [ControllerType.Page, ControllerType.Repeat]\n\nexport function showRepeaterSettings(page: Page): boolean {\n if (page.controller && !SHOW_REPEATER_CONTROLLERS.includes(page.controller)) {\n return false\n }\n if (hasComponents(page) && includesFileUploadField(page.components)) {\n return false\n }\n return true\n}\n\n/**\n * High level check for whether file upload component should be omitted\n * @param { Page | undefined } page\n * @returns {boolean}\n */\nexport function omitFileUploadComponent(page: Page | undefined): boolean {\n if (page?.controller === ControllerType.Repeat) {\n return true\n }\n if (!hasComponents(page)) {\n return false\n }\n if (page.components.length > 1) {\n return true\n }\n if (includesFileUploadField(page.components)) {\n return true\n }\n return false\n}\n\n/**\n * Gets page title, or title of first question (if no page title set)\n * @param {Page} page\n * @returns {string}\n */\nexport function getPageTitle(page: Page) {\n if (page.title !== '') {\n return page.title\n }\n\n if (hasComponentsEvenIfNoNext(page)) {\n const firstComp = page.components.find(hasFormField)\n if (firstComp) {\n return firstComp.title\n }\n }\n return 'Page title unknown'\n}\n"],"mappings":"AAAA,SAASA,aAAa;AACtB,SAASC,YAAY;AASrB,SACEC,eAAe,EACfC,eAAe;AAEjB,SAASC,cAAc;AACvB,SAASC,SAAS;;AAElB;AACA;AACA;AACA,OAAO,SAASC,eAAeA,CAC7BC,IAAmC,EACnC;EACA,MAAMC,UAAU,GAAGD,IAAI,EAAEE,UAAU,IAAIL,cAAc,CAACM,IAAI;EAC1D,MAAMD,UAAU,GAAGE,sBAAsB,CAACH,UAAU,CAAC;EAErD,MAAMI,QAAQ,GAAGP,SAAS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AACrC,IAAsB,EAAW;EACvE,IAAIA,IAAI,EAAEE,UAAU,KAAKL,cAAc,CAACuB,MAAM,EAAE;IAC9C,OAAO,IAAI;EACb;EACA,IAAI,CAACV,aAAa,CAACV,IAAI,CAAC,EAAE;IACxB,OAAO,KAAK;EACd;EACA,IAAIA,IAAI,CAACc,UAAU,CAACwB,MAAM,GAAG,CAAC,EAAE;IAC9B,OAAO,IAAI;EACb;EACA,IAAIR,uBAAuB,CAAC9B,IAAI,CAACc,UAAU,CAAC,EAAE;IAC5C,OAAO,IAAI;EACb;EACA,OAAO,KAAK;AACd;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASyB,YAAYA,CAACvC,IAAU,EAAE;EACvC,IAAIA,IAAI,CAACwC,KAAK,KAAK,EAAE,EAAE;IACrB,OAAOxC,IAAI,CAACwC,KAAK;EACnB;EAEA,IAAIzB,yBAAyB,CAACf,IAAI,CAAC,EAAE;IACnC,MAAMyC,SAAS,GAAGzC,IAAI,CAACc,UAAU,CAACR,IAAI,CAACZ,YAAY,CAAC;IACpD,IAAI+C,SAAS,EAAE;MACb,OAAOA,SAAS,CAACD,KAAK;IACxB;EACF;EACA,OAAO,oBAAoB;AAC7B","ignoreList":[]}
@@ -1,10 +1,24 @@
1
1
  import { type PageFileUpload, type PageQuestion, type PageRepeat, type PageSummary } from '../form/form-definition/types.js';
2
+ import { ControllerType } from '../pages/enums.js';
2
3
  /**
3
4
  * Stub builder for a question page
4
5
  * @param {Partial<PageQuestion>} [partialPage]
5
6
  * @returns {PageQuestion}
6
7
  */
7
8
  export declare function buildQuestionPage(partialPage: Partial<PageQuestion>): PageQuestion;
9
+ export declare const GUIDANCE_PAGE_CONTENT = "Lorem ipsum dolar sit amet";
10
+ export declare function buildGuidancePage(partialPage: Partial<PageQuestion>): {
11
+ controller?: ControllerType.Page | undefined;
12
+ section?: string | undefined | undefined;
13
+ next: import("../form/form-definition/types.js").Link[];
14
+ components: import("../index.js").ComponentDef[];
15
+ id: string;
16
+ title: string;
17
+ path: string;
18
+ condition?: string | undefined;
19
+ events?: import("../form/form-definition/types.js").Events | undefined;
20
+ view?: string | undefined;
21
+ };
8
22
  /**
9
23
  * Stub builder for a Summary page
10
24
  * @param {Partial<PageSummary>} [partialSummaryPage]
@@ -1 +1 @@
1
- {"version":3,"file":"pages.d.ts","sourceRoot":"","sources":["../../../src/__stubs__/pages.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,UAAU,EACf,KAAK,WAAW,EACjB,MAAM,qCAAqC,CAAA;AAG5C;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,WAAW,EAAE,OAAO,CAAC,YAAY,CAAC,GACjC,YAAY,CASd;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,kBAAkB,GAAE,OAAO,CAAC,WAAW,CAAM,GAC5C,WAAW,CAQb;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,qBAAqB,GAAE,OAAO,CAAC,cAAc,CAAM,GAClD,cAAc,CAwBhB;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,mBAAmB,GAAE,OAAO,CAAC,UAAU,CAAM,GAC5C,UAAU,CAyBZ"}
1
+ {"version":3,"file":"pages.d.ts","sourceRoot":"","sources":["../../../src/__stubs__/pages.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,UAAU,EACf,KAAK,WAAW,EACjB,MAAM,qCAAqC,CAAA;AAC5C,OAAO,EAAkB,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAErE;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,WAAW,EAAE,OAAO,CAAC,YAAY,CAAC,GACjC,YAAY,CASd;AAED,eAAO,MAAM,qBAAqB,+BAA+B,CAAA;AACjE,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,OAAO,CAAC,YAAY,CAAC;iBAoB/D,eAAiB,IAAG;;;;;;;;;;EAPxB;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,kBAAkB,GAAE,OAAO,CAAC,WAAW,CAAM,GAC5C,WAAW,CAQb;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,qBAAqB,GAAE,OAAO,CAAC,cAAc,CAAM,GAClD,cAAc,CAwBhB;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,mBAAmB,GAAE,OAAO,CAAC,UAAU,CAAM,GAC5C,UAAU,CAyBZ"}
@@ -118,11 +118,15 @@ export class PagePreviewElements implements PageOverviewElements {
118
118
  * @param {string} heading
119
119
  * @param {string} guidance
120
120
  * @param {boolean} [addHeading]
121
+ * @param {string} repeatQuestion
122
+ * @param {boolean} hasRepeater
121
123
  */
122
- constructor(heading: string, guidance?: string, addHeading?: boolean);
124
+ constructor(heading: string, guidance?: string, addHeading?: boolean, repeatQuestion?: string, hasRepeater?: boolean);
123
125
  guidance: string;
124
126
  heading: string;
125
127
  addHeading: boolean;
128
+ repeatQuestion: string;
129
+ hasRepeater: boolean;
126
130
  }
127
131
  export const baseElements: BaseSettings;
128
132
  export namespace listElementsStub {
@@ -1 +1 @@
1
- {"version":3,"file":"preview.d.ts","sourceRoot":"","sources":["../../../../../src/form/form-editor/__stubs__/preview.js"],"names":[],"mappings":"AAmOA;;;;GAIG;AACH,6DAJW,OAAO,CAAC,YAAY,CAAC,cACrB,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC,GAC1C,QAAQ,CAUpB;AA9OD;;GAEG;AACH;IAqBE;;;;OAIG;IACH,oCAHW,MAAM,kBACN,aAAa,GAFX,MAAM,CAMlB;IAtBD;;OAEG;IACH,wBAFW,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC,EAItD;IAVD;;OAEG;IACH,YAFU,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAA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CAAyC;0CAAzC,yCAAyC;0CAAzC,yCAAyC;AA7DzN,uBAAgB,sCAAsC,CAAA;AACtD,uBAAgB,sCAAsC,CAAA;AACtD,uBAAgB,sCAAsC,CAAA;AACtD,uBAAgB,sCAAsC,CAAA;AAEtD,gCAAoC,YAAY,CA4B9C"}
1
+ {"version":3,"file":"preview.d.ts","sourceRoot":"","sources":["../../../../../src/form/form-editor/__stubs__/preview.js"],"names":[],"mappings":"AA+OA;;;;GAIG;AACH,6DAJW,OAAO,CAAC,YAAY,CAAC,cACrB,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC,GAC1C,QAAQ,CAUpB;AA1PD;;GAEG;AACH;IAqBE;;;;OAIG;IACH,oCAHW,MAAM,kBACN,aAAa,GAFX,MAAM,CAMlB;IAtBD;;OAEG;IACH,wBAFW,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC,EAItD;IAVD;;OAEG;IACH,YAFU,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC,CAE5C;IASV;;;OAGG;IACH,yBAHW,MAAM,qBACN,iBAAiB,QAI3B;CAUF;AAED;;GAEG;AACH;IAqBE;;;;OAIG;IACH,oCAHW,MAAM,kBACN,aAAa,GAFX,MAAM,CAMlB;IAtBD;;OAEG;IACH,wBAFW,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC,EAI1D;IAVD;;OAEG;IACH,YAFU,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC,CAEhD;IASV;;;OAGG;IACH,qBAHW,MAAM,yBACN,qBAAqB,QAI/B;CAUF;AAED;;GAEG;AACH;IA2BE;;OAEG;IACH,yEAFW,YAAY,EAStB;IApCD;;OAEG;IACH,4BAAc;IACd,iBAAiB;IACjB,4BAAc;IACd,iBAAiB;IACjB,6BAAiB;IACjB;;;OAGG;IACH,sBAHU,MAAM,CAGD;IACf;;;OAGG;IACH,oBAHU,MAAM,CAGH;IACb;;;;OAIG;IACH,eAAW;IACX,wBAA2E;IAc3E;;OAEG;IACH,cAFa,YAAY,CAWxB;IAED;;OAEG;IACH,uBAFW,MAAM,QAIhB;IAED;;OAEG;IACH,sBAFW,WAAW,QAIrB;CACF;AAED;;GAEG;AACH;IACE;;OAEG;IACH,kDAFW,YAAY,GAAG;QAAC,mBAAmB,EAAE,MAAM,CAAA;KAAC,EAKtD;IADC,4BAA8C;CAEjD;AAED;;GAEG;AACH;IAOE;;;;;;OAMG;IACH,qBANW,MAAM,aACN,MAAM,eACN,OAAO,mBACP,MAAM,gBACN,OAAO,EAcjB;IAzBD,iBAAQ;IACR,gBAAO;IACP,oBAAU;IACV,uBAAc;IACd,qBAAW;CAsBZ;AAED,2BAAuC,YAAY,CAQjD;;;;;;;;kCA+D8K,yCAAyC;uCAAzC,yCAAyC;yBAjQhM,4CAA4C;sCAiQ2G,yCAAyC;mCAAzC,yCAAyC;kCAAzC,yCAAyC;2CAD/K,wCAAwC;kCAC8F,yCAAyC;0CAAzC,yCAAyC;0CAAzC,yCAAyC;AA7DzN,uBAAgB,sCAAsC,CAAA;AACtD,uBAAgB,sCAAsC,CAAA;AACtD,uBAAgB,sCAAsC,CAAA;AACtD,uBAAgB,sCAAsC,CAAA;AAEtD,gCAAoC,YAAY,CA4B9C"}
@@ -66,5 +66,13 @@ export interface PagePreviewPanelMacro {
66
66
  classes: string;
67
67
  };
68
68
  readonly components: PagePreviewComponent[];
69
+ readonly sectionTitle?: {
70
+ text: string;
71
+ classes: string;
72
+ };
73
+ readonly repeaterButton?: {
74
+ text: string;
75
+ classes: string;
76
+ };
69
77
  }
70
78
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/form/form-edit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E,MAAM,CAAA;IACb,SAAS,CAAC,EAAE,mBAAmB,CAAA;IAC/B,IAAI,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,SAAS,CAAA;IACpC,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED,MAAM,WAAW,oBAAqB,SAAQ,wBAAwB;IACpE,KAAK,EAAE,iBAAiB,CAAA;CACzB;AAED,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,iBAAiB,CAAA;IACxB,YAAY,EAAE,aAAa,CAAA;CAC5B;AAED,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,SAAS,EAAE;QAClB,IAAI,EAAE,MAAM,CAAA;QACZ,OAAO,EAAE,MAAM,CAAA;KAChB,CAAA;IACD,QAAQ,CAAC,QAAQ,EAAE;QACjB,IAAI,EAAE,MAAM,CAAA;QACZ,OAAO,EAAE,MAAM,CAAA;KAChB,CAAA;IACD,QAAQ,CAAC,UAAU,EAAE,oBAAoB,EAAE,CAAA;IAC3C,QAAQ,CAAC,YAAY,CAAC,EAAE;QACtB,IAAI,EAAE,MAAM,CAAA;QACZ,OAAO,EAAE,MAAM,CAAA;KAChB,CAAA;IACD,QAAQ,CAAC,cAAc,CAAC,EAAE;QACxB,IAAI,EAAE,MAAM,CAAA;QACZ,OAAO,EAAE,MAAM,CAAA;KAChB,CAAA;CACF"}
@@ -0,0 +1,10 @@
1
+ export class GuidancePageController extends PreviewPageControllerBase {
2
+ /**
3
+ * @type {Markdown}
4
+ * @protected
5
+ */
6
+ protected _unhighlightedEmptyGuidance: Markdown;
7
+ }
8
+ import { PreviewPageControllerBase } from '../../../../form/form-editor/preview/controller/page-controller-base.js';
9
+ import type { Markdown } from '../../../../form/form-editor/preview/markdown.js';
10
+ //# sourceMappingURL=guidance-page-controller.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"guidance-page-controller.d.ts","sourceRoot":"","sources":["../../../../../../src/form/form-editor/preview/controller/guidance-page-controller.js"],"names":[],"mappings":"AAIA;IACE;;;OAGG;IACH,uCAHU,QAAQ,CAIwC;CAgD3D;0CA1DyC,mEAAmE;8BA6DhF,4CAA4C"}