@defra/forms-model 3.0.594 → 3.0.596

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 (28) hide show
  1. package/dist/module/form/form-editor/preview/controller/guidance-page-controller.js +3 -2
  2. package/dist/module/form/form-editor/preview/controller/guidance-page-controller.js.map +1 -1
  3. package/dist/module/form/form-editor/preview/controller/page-controller-base.js +24 -3
  4. package/dist/module/form/form-editor/preview/controller/page-controller-base.js.map +1 -1
  5. package/dist/module/form/form-editor/preview/controller/page-controller.js +2 -1
  6. package/dist/module/form/form-editor/preview/controller/page-controller.js.map +1 -1
  7. package/dist/module/form/form-editor/preview/helpers.js +7 -2
  8. package/dist/module/form/form-editor/preview/helpers.js.map +1 -1
  9. package/dist/module/form/form-editor/preview/long-answer.js +88 -1
  10. package/dist/module/form/form-editor/preview/long-answer.js.map +1 -1
  11. package/dist/module/form/form-editor/preview/types.js.map +1 -1
  12. package/dist/types/form/form-editor/preview/controller/guidance-page-controller.d.ts +7 -0
  13. package/dist/types/form/form-editor/preview/controller/guidance-page-controller.d.ts.map +1 -1
  14. package/dist/types/form/form-editor/preview/controller/page-controller-base.d.ts +15 -1
  15. package/dist/types/form/form-editor/preview/controller/page-controller-base.d.ts.map +1 -1
  16. package/dist/types/form/form-editor/preview/controller/page-controller.d.ts.map +1 -1
  17. package/dist/types/form/form-editor/preview/helpers.d.ts.map +1 -1
  18. package/dist/types/form/form-editor/preview/long-answer.d.ts +137 -0
  19. package/dist/types/form/form-editor/preview/long-answer.d.ts.map +1 -1
  20. package/dist/types/form/form-editor/preview/types.d.ts +12 -0
  21. package/dist/types/form/form-editor/preview/types.d.ts.map +1 -1
  22. package/package.json +1 -1
  23. package/src/form/form-editor/preview/controller/guidance-page-controller.js +3 -2
  24. package/src/form/form-editor/preview/controller/page-controller-base.js +25 -3
  25. package/src/form/form-editor/preview/controller/page-controller.js +2 -1
  26. package/src/form/form-editor/preview/helpers.js +11 -2
  27. package/src/form/form-editor/preview/long-answer.js +90 -1
  28. package/src/form/form-editor/preview/types.ts +15 -0
@@ -14,7 +14,7 @@ export class GuidancePageController extends PreviewPageControllerBase {
14
14
  _guidanceComponent = PreviewPageControllerBase.createGuidanceComponent(false);
15
15
 
16
16
  /**
17
- * @param {PagePreviewBaseElements} elements
17
+ * @param {PageOverviewElements} elements
18
18
  * @param {PageRenderer} renderer
19
19
  */
20
20
  constructor(elements, renderer) {
@@ -22,6 +22,7 @@ export class GuidancePageController extends PreviewPageControllerBase {
22
22
  if (elements.guidance.length) {
23
23
  this._guidanceComponent.content = elements.guidance;
24
24
  }
25
+ this._section = elements.section;
25
26
  }
26
27
 
27
28
  /**
@@ -53,6 +54,6 @@ export class GuidancePageController extends PreviewPageControllerBase {
53
54
 
54
55
  /**
55
56
  * @import { Markdown } from '~/src/form/form-editor/preview/markdown.js'
56
- * @import { PageRenderer, PagePreviewBaseElements } from '~/src/form/form-editor/preview/types.js'
57
+ * @import { PageRenderer, PageOverviewElements } from '~/src/form/form-editor/preview/types.js'
57
58
  */
58
59
  //# sourceMappingURL=guidance-page-controller.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"guidance-page-controller.js","names":["PreviewPageControllerBase","FALLBACK_GUIDANCE_TEXT","GuidancePageController","_unhighlightedEmptyGuidance","createGuidanceComponent","_guidanceComponent","constructor","elements","renderer","guidance","length","content","_getGuidanceComponents","_guidanceText","_isHighlighted","HighlightClass","GUIDANCE","_emptyGuidance","_getGuidanceText","guidanceText"],"sources":["../../../../../../src/form/form-editor/preview/controller/guidance-page-controller.js"],"sourcesContent":["import { PreviewPageControllerBase } from '~/src/form/form-editor/preview/controller/page-controller-base.js'\n\nconst FALLBACK_GUIDANCE_TEXT = 'Guidance text'\n\nexport class GuidancePageController extends PreviewPageControllerBase {\n /**\n * @type {Markdown}\n * @protected\n */\n _unhighlightedEmptyGuidance =\n PreviewPageControllerBase.createGuidanceComponent(false)\n\n /**\n * @type {Markdown}\n * @protected\n */\n _guidanceComponent = PreviewPageControllerBase.createGuidanceComponent(false)\n\n /**\n * @param {PagePreviewBaseElements} elements\n * @param {PageRenderer} renderer\n */\n constructor(elements, renderer) {\n super(elements, renderer)\n if (elements.guidance.length) {\n this._guidanceComponent.content = elements.guidance\n }\n }\n\n /**\n * @returns {Markdown[]}\n * @protected\n */\n _getGuidanceComponents() {\n if (this._guidanceText.length) {\n return [this._guidanceComponent]\n }\n\n if (\n this._isHighlighted(PreviewPageControllerBase.HighlightClass.GUIDANCE)\n ) {\n return [this._emptyGuidance]\n }\n\n return [this._unhighlightedEmptyGuidance]\n }\n\n /**\n * @returns {string}\n * @protected\n */\n _getGuidanceText() {\n const guidanceText = super._getGuidanceText()\n if (!guidanceText.length) {\n return FALLBACK_GUIDANCE_TEXT\n }\n return super._getGuidanceText()\n }\n}\n\n/**\n * @import { Markdown } from '~/src/form/form-editor/preview/markdown.js'\n * @import { PageRenderer, PagePreviewBaseElements } from '~/src/form/form-editor/preview/types.js'\n */\n"],"mappings":"AAAA,SAASA,yBAAyB;AAElC,MAAMC,sBAAsB,GAAG,eAAe;AAE9C,OAAO,MAAMC,sBAAsB,SAASF,yBAAyB,CAAC;EACpE;AACF;AACA;AACA;EACEG,2BAA2B,GACzBH,yBAAyB,CAACI,uBAAuB,CAAC,KAAK,CAAC;;EAE1D;AACF;AACA;AACA;EACEC,kBAAkB,GAAGL,yBAAyB,CAACI,uBAAuB,CAAC,KAAK,CAAC;;EAE7E;AACF;AACA;AACA;EACEE,WAAWA,CAACC,QAAQ,EAAEC,QAAQ,EAAE;IAC9B,KAAK,CAACD,QAAQ,EAAEC,QAAQ,CAAC;IACzB,IAAID,QAAQ,CAACE,QAAQ,CAACC,MAAM,EAAE;MAC5B,IAAI,CAACL,kBAAkB,CAACM,OAAO,GAAGJ,QAAQ,CAACE,QAAQ;IACrD;EACF;;EAEA;AACF;AACA;AACA;EACEG,sBAAsBA,CAAA,EAAG;IACvB,IAAI,IAAI,CAACC,aAAa,CAACH,MAAM,EAAE;MAC7B,OAAO,CAAC,IAAI,CAACL,kBAAkB,CAAC;IAClC;IAEA,IACE,IAAI,CAACS,cAAc,CAACd,yBAAyB,CAACe,cAAc,CAACC,QAAQ,CAAC,EACtE;MACA,OAAO,CAAC,IAAI,CAACC,cAAc,CAAC;IAC9B;IAEA,OAAO,CAAC,IAAI,CAACd,2BAA2B,CAAC;EAC3C;;EAEA;AACF;AACA;AACA;EACEe,gBAAgBA,CAAA,EAAG;IACjB,MAAMC,YAAY,GAAG,KAAK,CAACD,gBAAgB,CAAC,CAAC;IAC7C,IAAI,CAACC,YAAY,CAACT,MAAM,EAAE;MACxB,OAAOT,sBAAsB;IAC/B;IACA,OAAO,KAAK,CAACiB,gBAAgB,CAAC,CAAC;EACjC;AACF;;AAEA;AACA;AACA;AACA","ignoreList":[]}
1
+ {"version":3,"file":"guidance-page-controller.js","names":["PreviewPageControllerBase","FALLBACK_GUIDANCE_TEXT","GuidancePageController","_unhighlightedEmptyGuidance","createGuidanceComponent","_guidanceComponent","constructor","elements","renderer","guidance","length","content","_section","section","_getGuidanceComponents","_guidanceText","_isHighlighted","HighlightClass","GUIDANCE","_emptyGuidance","_getGuidanceText","guidanceText"],"sources":["../../../../../../src/form/form-editor/preview/controller/guidance-page-controller.js"],"sourcesContent":["import { PreviewPageControllerBase } from '~/src/form/form-editor/preview/controller/page-controller-base.js'\n\nconst FALLBACK_GUIDANCE_TEXT = 'Guidance text'\n\nexport class GuidancePageController extends PreviewPageControllerBase {\n /**\n * @type {Markdown}\n * @protected\n */\n _unhighlightedEmptyGuidance =\n PreviewPageControllerBase.createGuidanceComponent(false)\n\n /**\n * @type {Markdown}\n * @protected\n */\n _guidanceComponent = PreviewPageControllerBase.createGuidanceComponent(false)\n\n /**\n * @param {PageOverviewElements} elements\n * @param {PageRenderer} renderer\n */\n constructor(elements, renderer) {\n super(elements, renderer)\n if (elements.guidance.length) {\n this._guidanceComponent.content = elements.guidance\n }\n this._section = elements.section\n }\n\n /**\n * @returns {Markdown[]}\n * @protected\n */\n _getGuidanceComponents() {\n if (this._guidanceText.length) {\n return [this._guidanceComponent]\n }\n\n if (\n this._isHighlighted(PreviewPageControllerBase.HighlightClass.GUIDANCE)\n ) {\n return [this._emptyGuidance]\n }\n\n return [this._unhighlightedEmptyGuidance]\n }\n\n /**\n * @returns {string}\n * @protected\n */\n _getGuidanceText() {\n const guidanceText = super._getGuidanceText()\n if (!guidanceText.length) {\n return FALLBACK_GUIDANCE_TEXT\n }\n return super._getGuidanceText()\n }\n}\n\n/**\n * @import { Markdown } from '~/src/form/form-editor/preview/markdown.js'\n * @import { PageRenderer, PageOverviewElements } from '~/src/form/form-editor/preview/types.js'\n */\n"],"mappings":"AAAA,SAASA,yBAAyB;AAElC,MAAMC,sBAAsB,GAAG,eAAe;AAE9C,OAAO,MAAMC,sBAAsB,SAASF,yBAAyB,CAAC;EACpE;AACF;AACA;AACA;EACEG,2BAA2B,GACzBH,yBAAyB,CAACI,uBAAuB,CAAC,KAAK,CAAC;;EAE1D;AACF;AACA;AACA;EACEC,kBAAkB,GAAGL,yBAAyB,CAACI,uBAAuB,CAAC,KAAK,CAAC;;EAE7E;AACF;AACA;AACA;EACEE,WAAWA,CAACC,QAAQ,EAAEC,QAAQ,EAAE;IAC9B,KAAK,CAACD,QAAQ,EAAEC,QAAQ,CAAC;IACzB,IAAID,QAAQ,CAACE,QAAQ,CAACC,MAAM,EAAE;MAC5B,IAAI,CAACL,kBAAkB,CAACM,OAAO,GAAGJ,QAAQ,CAACE,QAAQ;IACrD;IACA,IAAI,CAACG,QAAQ,GAAGL,QAAQ,CAACM,OAAO;EAClC;;EAEA;AACF;AACA;AACA;EACEC,sBAAsBA,CAAA,EAAG;IACvB,IAAI,IAAI,CAACC,aAAa,CAACL,MAAM,EAAE;MAC7B,OAAO,CAAC,IAAI,CAACL,kBAAkB,CAAC;IAClC;IAEA,IACE,IAAI,CAACW,cAAc,CAAChB,yBAAyB,CAACiB,cAAc,CAACC,QAAQ,CAAC,EACtE;MACA,OAAO,CAAC,IAAI,CAACC,cAAc,CAAC;IAC9B;IAEA,OAAO,CAAC,IAAI,CAAChB,2BAA2B,CAAC;EAC3C;;EAEA;AACF;AACA;AACA;EACEiB,gBAAgBA,CAAA,EAAG;IACjB,MAAMC,YAAY,GAAG,KAAK,CAACD,gBAAgB,CAAC,CAAC;IAC7C,IAAI,CAACC,YAAY,CAACX,MAAM,EAAE;MACxB,OAAOT,sBAAsB;IAC/B;IACA,OAAO,KAAK,CAACmB,gBAAgB,CAAC,CAAC;EACjC;AACF;;AAEA;AACA;AACA;AACA","ignoreList":[]}
@@ -39,13 +39,21 @@ export class PagePreviewElements {
39
39
  title: ''
40
40
  };
41
41
 
42
+ /**
43
+ * @type {PageSectionInfo | undefined}
44
+ * @protected
45
+ */
46
+ _section = undefined;
47
+
42
48
  /**
43
49
  * @param {Page|undefined} page
50
+ * @param {PageSectionInfo} [section]
44
51
  */
45
- constructor(page) {
52
+ constructor(page, section) {
46
53
  if (page !== undefined) {
47
54
  this._page = page;
48
55
  }
56
+ this._section = section;
49
57
  }
50
58
  get heading() {
51
59
  return this._page.title;
@@ -69,6 +77,9 @@ export class PagePreviewElements {
69
77
  get hasRepeater() {
70
78
  return hasRepeater(this._page);
71
79
  }
80
+ get section() {
81
+ return this._section;
82
+ }
72
83
  }
73
84
 
74
85
  /**
@@ -133,6 +144,13 @@ export class PreviewPageControllerBase {
133
144
  */
134
145
  _isRepeater = false;
135
146
 
147
+ /**
148
+ * Section info for the page
149
+ * @type {PageSectionInfo | undefined}
150
+ * @protected
151
+ */
152
+ _section = undefined;
153
+
136
154
  /**
137
155
  * @param {PagePreviewBaseElements} elements
138
156
  * @param {PageRenderer} renderer
@@ -291,7 +309,10 @@ export class PreviewPageControllerBase {
291
309
  * @protected
292
310
  */
293
311
  _getSectionTitleText() {
294
- return this._sectionTitle;
312
+ if (this._section && !this._section.hideTitle) {
313
+ return this._section.title;
314
+ }
315
+ return undefined;
295
316
  }
296
317
 
297
318
  /**
@@ -365,7 +386,7 @@ export class PreviewPageControllerBase {
365
386
  }
366
387
 
367
388
  /**
368
- * @import { PageRenderer, PageOverviewElements, PagePreviewBaseElements, QuestionRenderer, QuestionBaseModel } from '~/src/form/form-editor/preview/types.js'
389
+ * @import { PageRenderer, PageOverviewElements, PagePreviewBaseElements, PageSectionInfo, QuestionRenderer, QuestionBaseModel } from '~/src/form/form-editor/preview/types.js'
369
390
  * @import { Question } from '~/src/form/form-editor/preview/question.js'
370
391
  * @import { Page } from '~/src/form/form-definition/types.js'
371
392
  * @import { PagePreviewComponent, PagePreviewPanelMacro } from '~/src/form/form-editor/macros/types.js'
@@ -1 +1 @@
1
- {"version":3,"file":"page-controller-base.js","names":["ComponentType","HIGHLIGHT_CLASS","ContentElements","Markdown","hasComponents","hasRepeater","questionRenderer","render","_questionTemplate","_questionBaseModel","HighlightClass","TITLE","GUIDANCE","REPEATER","PagePreviewElements","_page","title","constructor","page","undefined","heading","guidance","components","length","possibleGuidanceComponent","type","content","addHeading","repeatQuestion","repeat","options","PreviewPageControllerBase","PATH","_pageTemplate","_components","_showTitle","_title","pageRenderer","_highlighted","_guidanceText","_sectionTitle","_emptyGuidance","createGuidanceComponent","_guidanceComponent","_isRepeater","elements","renderer","_getGuidanceComponents","_guidanceComponents","componentsWithGuidance","map","component","model","renderInput","questionType","componentType","_getGuidanceText","guidanceText","text","classes","_isHighlighted","showTitle","pageTitle","setRepeater","unsetRepeater","isRepeater","_getTitle","value","highlightTitle","setHighLighted","sectionTitle","sectionTitleText","_getSectionTitleText","val","highlight","guidanceElement","name","guidanceComponent","highlightContent","highlightGuidance","highlightSection","clearHighlight","unHighlightContent","field","highlightQuestion","questionId","question","find","comp","id","filter","forEach","comp2"],"sources":["../../../../../../src/form/form-editor/preview/controller/page-controller-base.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 { Markdown } from '~/src/form/form-editor/preview/markdown.js'\nimport { hasComponents, hasRepeater } from '~/src/pages/helpers.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/**\n * Enum for Highlight classes\n * @readonly\n * @enum {string}\n */\nconst HighlightClass = {\n TITLE: 'title',\n GUIDANCE: 'guidance',\n REPEATER: 'repeater'\n}\n\n/**\n * @implements {PageOverviewElements}\n */\nexport class PagePreviewElements {\n /**\n * @type {Page | { title: string }}\n * @private\n */\n _page = {\n title: ''\n }\n\n /**\n * @param {Page|undefined} page\n */\n constructor(page) {\n if (page !== undefined) {\n this._page = page\n }\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 get repeatQuestion() {\n if (hasRepeater(this._page)) {\n return this._page.repeat.options.title\n }\n return undefined\n }\n\n get hasRepeater() {\n return hasRepeater(this._page)\n }\n}\n\n/**\n * @abstract\n * @implements {PagePreviewPanelMacro}\n */\nexport class PreviewPageControllerBase {\n static PATH = 'preview-controllers/'\n /**\n * @type {string}\n * @protected\n */\n _pageTemplate = PreviewPageControllerBase.PATH + 'page-controller.njk'\n /**\n * @protected\n * @type {Question[]}\n */\n _components = []\n /**\n * @type {boolean}\n * @protected\n */\n _showTitle = true\n /**\n * @protected\n * @type {string}\n */\n _title = ''\n /**\n *\n * @type {PageRenderer}\n */\n #pageRenderer\n /**\n * @type { undefined | HighlightClass }\n * @protected\n */\n _highlighted = undefined\n /**\n * @type {string}\n * @protected\n */\n _guidanceText = ''\n /**\n * @type { string }\n * @protected\n */\n _sectionTitle = ''\n /**\n * @type {Markdown}\n * @protected\n */\n _emptyGuidance = PreviewPageControllerBase.createGuidanceComponent()\n /**\n * @type {Markdown}\n * @protected\n */\n _guidanceComponent = PreviewPageControllerBase.createGuidanceComponent()\n /**\n * @protected\n * @type {boolean}\n */\n _isRepeater = false\n\n /**\n * @param {PagePreviewBaseElements} elements\n * @param {PageRenderer} renderer\n */\n constructor(elements, renderer) {\n this._guidanceText = elements.guidance\n this.#pageRenderer = renderer\n this._title = elements.heading\n }\n\n /**\n * @type {typeof HighlightClass}\n */\n static HighlightClass = HighlightClass\n\n /**\n * @returns {Markdown[]}\n * @protected\n */\n _getGuidanceComponents() {\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 {Markdown[]}\n * @protected\n */\n get _guidanceComponents() {\n return this._getGuidanceComponents()\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: component.renderInput,\n questionType: component.componentType\n }\n })\n }\n\n /**\n * @returns {string}\n * @protected\n */\n _getGuidanceText() {\n return this._guidanceText\n }\n\n set guidanceText(text) {\n this._guidanceText = text\n this._guidanceComponent.content = text\n this.render()\n }\n\n /**\n * @returns {string}\n */\n get guidanceText() {\n return this._getGuidanceText()\n }\n\n get guidance() {\n return {\n text: this.guidanceText,\n classes: this._isHighlighted(HighlightClass.GUIDANCE)\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 /**\n * @returns {{ text: string, classes: string }}\n */\n get pageTitle() {\n return {\n text: this.title,\n classes: this._isHighlighted(HighlightClass.TITLE)\n }\n }\n\n setRepeater() {\n this._isRepeater = true\n this.render()\n }\n\n unsetRepeater() {\n this._isRepeater = false\n this.render()\n }\n\n get isRepeater() {\n return this._isRepeater\n }\n\n render() {\n this.#pageRenderer.render(this._pageTemplate, this)\n }\n\n /**\n * @returns {string}\n * @protected\n */\n _getTitle() {\n if (this._title.length) {\n return this._title\n }\n return 'Page heading'\n }\n\n /**\n * @returns {string}\n */\n get title() {\n return this._getTitle()\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(HighlightClass.TITLE)\n }\n\n /**\n * @returns {{classes: string, text: string} | undefined}\n */\n get sectionTitle() {\n if (this.sectionTitleText === undefined) {\n return undefined\n }\n return {\n classes: this._isHighlighted(HighlightClass.REPEATER),\n text: this.sectionTitleText\n }\n }\n\n /**\n * @returns {string|undefined}\n * @protected\n */\n _getSectionTitleText() {\n return this._sectionTitle\n }\n\n /**\n * @param {string | undefined} val\n */\n set sectionTitleText(val) {\n this._sectionTitle = val ?? ''\n this.render()\n }\n\n get sectionTitleText() {\n return this._getSectionTitleText()\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(highlight = true) {\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 if (highlight) {\n guidanceComponent.highlightContent()\n }\n return guidanceComponent\n }\n\n highlightGuidance() {\n this._guidanceComponent.highlightContent()\n this.setHighLighted(HighlightClass.GUIDANCE)\n }\n\n /**\n * @param {HighlightClass} 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 * @param {string} field\n * @protected\n * @returns {string}\n */\n _isHighlighted(field) {\n return this._highlighted === field ? HIGHLIGHT_CLASS : ''\n }\n\n /**\n * @param {string} questionId\n */\n highlightQuestion(questionId) {\n const question = this._components.find((comp) => comp.id === questionId)\n if (question) {\n this._components\n .filter((comp) => comp.id !== questionId)\n .forEach((comp2) => comp2.unHighlightContent())\n question.highlightContent()\n this.render()\n }\n }\n}\n\n/**\n * @import { PageRenderer, PageOverviewElements, PagePreviewBaseElements, QuestionRenderer, QuestionBaseModel } from '~/src/form/form-editor/preview/types.js'\n * @import { Question } from '~/src/form/form-editor/preview/question.js'\n * @import { Page } from '~/src/form/form-definition/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,QAAQ;AACjB,SAASC,aAAa,EAAEC,WAAW;;AAEnC;AACA;AACA;AACA,MAAMC,gBAAgB,GAAG;EACvB;AACF;AACA;AACA;EACEC,MAAMA,CAACC,iBAAiB,EAAEC,kBAAkB,EAAE;IAC5C;EAAA;AAEJ,CAAC;AACD;AACA;AACA;AACA;AACA;AACA,MAAMC,cAAc,GAAG;EACrBC,KAAK,EAAE,OAAO;EACdC,QAAQ,EAAE,UAAU;EACpBC,QAAQ,EAAE;AACZ,CAAC;;AAED;AACA;AACA;AACA,OAAO,MAAMC,mBAAmB,CAAC;EAC/B;AACF;AACA;AACA;EACEC,KAAK,GAAG;IACNC,KAAK,EAAE;EACT,CAAC;;EAED;AACF;AACA;EACEC,WAAWA,CAACC,IAAI,EAAE;IAChB,IAAIA,IAAI,KAAKC,SAAS,EAAE;MACtB,IAAI,CAACJ,KAAK,GAAGG,IAAI;IACnB;EACF;EAEA,IAAIE,OAAOA,CAAA,EAAG;IACZ,OAAO,IAAI,CAACL,KAAK,CAACC,KAAK;EACzB;EAEA,IAAIK,QAAQA,CAAA,EAAG;IACb,IAAI,CAACjB,aAAa,CAAC,IAAI,CAACW,KAAK,CAAC,IAAI,CAAC,IAAI,CAACA,KAAK,CAACO,UAAU,C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C;IACf;EACF;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
1
+ {"version":3,"file":"page-controller-base.js","names":["ComponentType","HIGHLIGHT_CLASS","ContentElements","Markdown","hasComponents","hasRepeater","questionRenderer","render","_questionTemplate","_questionBaseModel","HighlightClass","TITLE","GUIDANCE","REPEATER","PagePreviewElements","_page","title","_section","undefined","constructor","page","section","heading","guidance","components","length","possibleGuidanceComponent","type","content","addHeading","repeatQuestion","repeat","options","PreviewPageControllerBase","PATH","_pageTemplate","_components","_showTitle","_title","pageRenderer","_highlighted","_guidanceText","_sectionTitle","_emptyGuidance","createGuidanceComponent","_guidanceComponent","_isRepeater","elements","renderer","_getGuidanceComponents","_guidanceComponents","componentsWithGuidance","map","component","model","renderInput","questionType","componentType","_getGuidanceText","guidanceText","text","classes","_isHighlighted","showTitle","pageTitle","setRepeater","unsetRepeater","isRepeater","_getTitle","value","highlightTitle","setHighLighted","sectionTitle","sectionTitleText","_getSectionTitleText","hideTitle","val","highlight","guidanceElement","name","guidanceComponent","highlightContent","highlightGuidance","highlightSection","clearHighlight","unHighlightContent","field","highlightQuestion","questionId","question","find","comp","id","filter","forEach","comp2"],"sources":["../../../../../../src/form/form-editor/preview/controller/page-controller-base.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 { Markdown } from '~/src/form/form-editor/preview/markdown.js'\nimport { hasComponents, hasRepeater } from '~/src/pages/helpers.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/**\n * Enum for Highlight classes\n * @readonly\n * @enum {string}\n */\nconst HighlightClass = {\n TITLE: 'title',\n GUIDANCE: 'guidance',\n REPEATER: 'repeater'\n}\n\n/**\n * @implements {PageOverviewElements}\n */\nexport class PagePreviewElements {\n /**\n * @type {Page | { title: string }}\n * @private\n */\n _page = {\n title: ''\n }\n\n /**\n * @type {PageSectionInfo | undefined}\n * @protected\n */\n _section = undefined\n\n /**\n * @param {Page|undefined} page\n * @param {PageSectionInfo} [section]\n */\n constructor(page, section) {\n if (page !== undefined) {\n this._page = page\n }\n this._section = section\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 get repeatQuestion() {\n if (hasRepeater(this._page)) {\n return this._page.repeat.options.title\n }\n return undefined\n }\n\n get hasRepeater() {\n return hasRepeater(this._page)\n }\n\n get section() {\n return this._section\n }\n}\n\n/**\n * @abstract\n * @implements {PagePreviewPanelMacro}\n */\nexport class PreviewPageControllerBase {\n static PATH = 'preview-controllers/'\n /**\n * @type {string}\n * @protected\n */\n _pageTemplate = PreviewPageControllerBase.PATH + 'page-controller.njk'\n /**\n * @protected\n * @type {Question[]}\n */\n _components = []\n /**\n * @type {boolean}\n * @protected\n */\n _showTitle = true\n /**\n * @protected\n * @type {string}\n */\n _title = ''\n /**\n *\n * @type {PageRenderer}\n */\n #pageRenderer\n /**\n * @type { undefined | HighlightClass }\n * @protected\n */\n _highlighted = undefined\n /**\n * @type {string}\n * @protected\n */\n _guidanceText = ''\n /**\n * @type { string }\n * @protected\n */\n _sectionTitle = ''\n /**\n * @type {Markdown}\n * @protected\n */\n _emptyGuidance = PreviewPageControllerBase.createGuidanceComponent()\n /**\n * @type {Markdown}\n * @protected\n */\n _guidanceComponent = PreviewPageControllerBase.createGuidanceComponent()\n /**\n * @protected\n * @type {boolean}\n */\n _isRepeater = false\n\n /**\n * Section info for the page\n * @type {PageSectionInfo | undefined}\n * @protected\n */\n _section = undefined\n\n /**\n * @param {PagePreviewBaseElements} elements\n * @param {PageRenderer} renderer\n */\n constructor(elements, renderer) {\n this._guidanceText = elements.guidance\n this.#pageRenderer = renderer\n this._title = elements.heading\n }\n\n /**\n * @type {typeof HighlightClass}\n */\n static HighlightClass = HighlightClass\n\n /**\n * @returns {Markdown[]}\n * @protected\n */\n _getGuidanceComponents() {\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 {Markdown[]}\n * @protected\n */\n get _guidanceComponents() {\n return this._getGuidanceComponents()\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: component.renderInput,\n questionType: component.componentType\n }\n })\n }\n\n /**\n * @returns {string}\n * @protected\n */\n _getGuidanceText() {\n return this._guidanceText\n }\n\n set guidanceText(text) {\n this._guidanceText = text\n this._guidanceComponent.content = text\n this.render()\n }\n\n /**\n * @returns {string}\n */\n get guidanceText() {\n return this._getGuidanceText()\n }\n\n get guidance() {\n return {\n text: this.guidanceText,\n classes: this._isHighlighted(HighlightClass.GUIDANCE)\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 /**\n * @returns {{ text: string, classes: string }}\n */\n get pageTitle() {\n return {\n text: this.title,\n classes: this._isHighlighted(HighlightClass.TITLE)\n }\n }\n\n setRepeater() {\n this._isRepeater = true\n this.render()\n }\n\n unsetRepeater() {\n this._isRepeater = false\n this.render()\n }\n\n get isRepeater() {\n return this._isRepeater\n }\n\n render() {\n this.#pageRenderer.render(this._pageTemplate, this)\n }\n\n /**\n * @returns {string}\n * @protected\n */\n _getTitle() {\n if (this._title.length) {\n return this._title\n }\n return 'Page heading'\n }\n\n /**\n * @returns {string}\n */\n get title() {\n return this._getTitle()\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(HighlightClass.TITLE)\n }\n\n /**\n * @returns {{classes: string, text: string} | undefined}\n */\n get sectionTitle() {\n if (this.sectionTitleText === undefined) {\n return undefined\n }\n return {\n classes: this._isHighlighted(HighlightClass.REPEATER),\n text: this.sectionTitleText\n }\n }\n\n /**\n * @returns {string|undefined}\n * @protected\n */\n _getSectionTitleText() {\n if (this._section && !this._section.hideTitle) {\n return this._section.title\n }\n return undefined\n }\n\n /**\n * @param {string | undefined} val\n */\n set sectionTitleText(val) {\n this._sectionTitle = val ?? ''\n this.render()\n }\n\n get sectionTitleText() {\n return this._getSectionTitleText()\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(highlight = true) {\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 if (highlight) {\n guidanceComponent.highlightContent()\n }\n return guidanceComponent\n }\n\n highlightGuidance() {\n this._guidanceComponent.highlightContent()\n this.setHighLighted(HighlightClass.GUIDANCE)\n }\n\n /**\n * @param {HighlightClass} 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 * @param {string} field\n * @protected\n * @returns {string}\n */\n _isHighlighted(field) {\n return this._highlighted === field ? HIGHLIGHT_CLASS : ''\n }\n\n /**\n * @param {string} questionId\n */\n highlightQuestion(questionId) {\n const question = this._components.find((comp) => comp.id === questionId)\n if (question) {\n this._components\n .filter((comp) => comp.id !== questionId)\n .forEach((comp2) => comp2.unHighlightContent())\n question.highlightContent()\n this.render()\n }\n }\n}\n\n/**\n * @import { PageRenderer, PageOverviewElements, PagePreviewBaseElements, PageSectionInfo, QuestionRenderer, QuestionBaseModel } from '~/src/form/form-editor/preview/types.js'\n * @import { Question } from '~/src/form/form-editor/preview/question.js'\n * @import { Page } from '~/src/form/form-definition/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,QAAQ;AACjB,SAASC,aAAa,EAAEC,WAAW;;AAEnC;AACA;AACA;AACA,MAAMC,gBAAgB,GAAG;EACvB;AACF;AACA;AACA;EACEC,MAAMA,CAACC,iBAAiB,EAAEC,kBAAkB,EAAE;IAC5C;EAAA;AAEJ,CAAC;AACD;AACA;AACA;AACA;AACA;AACA,MAAMC,cAAc,GAAG;EACrBC,KAAK,EAAE,OAAO;EACdC,QAAQ,EAAE,UAAU;EACpBC,QAAQ,EAAE;AACZ,CAAC;;AAED;AACA;AACA;AACA,OAAO,MAAMC,mBAAmB,CAAC;EAC/B;AACF;AACA;AACA;EACEC,KAAK,GAAG;IACNC,KAAK,EAAE;EACT,CAAC;;EAED;AACF;AACA;AACA;EACEC,QAAQ,GAAGC,SAAS;;EAEpB;AACF;AACA;AACA;EACEC,WAAWA,CAACC,IAAI,EAAEC,OAAO,EAAE;IACzB,IAAID,IAAI,KAAKF,SAAS,EAAE;MACtB,IAAI,CAACH,KAAK,GAAGK,IAAI;IACnB;IACA,IAAI,CAACH,QAAQ,GAAGI,OAAO;EACzB;EAEA,IAAIC,OAAOA,CAAA,EAAG;IACZ,OAAO,IAAI,CAACP,KAAK,CAACC,KAAK;EACzB;EAEA,IAAIO,QAAQA,CAAA,EAAG;IACb,IAAI,CAACnB,aAAa,CAAC,IAAI,CAACW,KAAK,CAAC,IAAI,CAAC,IAAI,CAACA,KAAK,CAACS,UAAU,CAACC,MAAM,EAAE;MAC/D,OA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AAW,CACbyD,MAAM,CAAEF,IAAI,IAAKA,IAAI,CAACC,EAAE,KAAKJ,UAAU,CAAC,CACxCM,OAAO,CAAEC,KAAK,IAAKA,KAAK,CAACV,kBAAkB,CAAC,CAAC,CAAC;MACjDI,QAAQ,CAACR,gBAAgB,CAAC,CAAC;MAC3B,IAAI,CAAC1E,MAAM,CAAC,CAAC;IACf;EACF;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
@@ -39,6 +39,7 @@ export class PreviewPageController extends PreviewPageControllerBase {
39
39
  this._showTitle = elements.addHeading;
40
40
  this._sectionTitle = elements.repeatQuestion ?? '';
41
41
  this._isRepeater = elements.hasRepeater;
42
+ this._section = elements.section;
42
43
  }
43
44
 
44
45
  /**
@@ -158,7 +159,7 @@ export class PreviewPageController extends PreviewPageControllerBase {
158
159
  if (this._isRepeater) {
159
160
  return this.repeaterText;
160
161
  }
161
- return undefined;
162
+ return super._getSectionTitleText();
162
163
  }
163
164
 
164
165
  /**
@@ -1 +1 @@
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","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\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 /**\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 } from '~/src/form/form-definition/types.js'\n * @import { ComponentDef } from '~/src/components/types.js'\n * @import { PagePreviewComponent } 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;IAED,MAAMI,aAAa,GAAG;IACpBF,SAAS,CAACG,KAAK,CAAC,CACjB;IACD,IAAI,CAACC,kBAAkB,GACrBZ,qBAAqB,CAACa,4BAA4B,CAACH,aAAa,CAAC;IACnE,IAAI,CAACI,aAAa,GAAGT,QAAQ,CAACU,QAAQ;IACtC,IAAI,CAACb,WAAW,GAAG,IAAI,CAAC,CAACc,mBAAmB,CAACN,aAAa,EAAEF,SAAS,CAAC;IACtE,IAAI,CAACS,UAAU,GAAGZ,QAAQ,CAACa,UAAU;IACrC,IAAI,CAACC,aAAa,GAAGd,QAAQ,CAACe,cAAc,IAAI,EAAE;IAClD,IAAI,CA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AAC,CAAC;EACjC;EAEA,IAAIC,YAAYA,CAAA,EAAG;IACjB,IAAI,CAAC,IAAI,CAAC5B,WAAW,EAAE;MACrB,OAAOI,SAAS;IAClB;IACA,IAAI,CAAC,IAAI,CAACN,aAAa,CAACgB,MAAM,EAAE;MAC9B,OAAO,mBAAmB;IAC5B;IACA,OAAO,IAAI,CAAChB,aAAa,GAAG,IAAI;EAClC;;EAEA;AACF;AACA;AACA;EACE+B,oBAAoBA,CAAA,EAAG;IACrB,IAAI,IAAI,CAAC7B,WAAW,EAAE;MACpB,OAAO,IAAI,CAAC4B,YAAY;IAC1B;IACA,OAAOxB,SAAS;EAClB;;EAEA;AACF;AACA;AACA;AACA;AACA;EACE,OAAOZ,4BAA4BA,CAACsC,iBAAiB,EAAE;IACrD,IAAIA,iBAAiB,YAAYxD,QAAQ,EAAE;MACzC,OAAOwD,iBAAiB;IAC1B;IACA,OAAO1D,yBAAyB,CAAC2D,uBAAuB,CAAC,CAAC;EAC5D;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","_section","section","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","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\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 this._section = elements.section\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 super._getSectionTitleText()\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 } from '~/src/form/form-definition/types.js'\n * @import { ComponentDef } from '~/src/components/types.js'\n * @import { PagePreviewComponent } 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;IAED,MAAMI,aAAa,GAAG;IACpBF,SAAS,CAACG,KAAK,CAAC,CACjB;IACD,IAAI,CAACC,kBAAkB,GACrBZ,qBAAqB,CAACa,4BAA4B,CAACH,aAAa,CAAC;IACnE,IAAI,CAACI,aAAa,GAAGT,QAAQ,CAACU,QAAQ;IACtC,IAAI,CAACb,WAAW,GAAG,IAAI,CAAC,CAACc,mBAAmB,CAACN,aAAa,EAAEF,SAAS,CAAC;IACtE,IAAI,CAACS,UAAU,GAAGZ,QAAQ,CAACa,UAAU;IACrC,IAAI,C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A,CAAA,EAAG;IACjB,IAAI,CAAC,IAAI,CAACjC,UAAU,EAAE;MACpB,OAAO,EAAE;IACX;IACA,OAAO,KAAK,CAACiC,gBAAgB,CAAC,CAAC;EACjC;EAEA,IAAIC,YAAYA,CAAA,EAAG;IACjB,IAAI,CAAC,IAAI,CAAC9B,WAAW,EAAE;MACrB,OAAOM,SAAS;IAClB;IACA,IAAI,CAAC,IAAI,CAACR,aAAa,CAACkB,MAAM,EAAE;MAC9B,OAAO,mBAAmB;IAC5B;IACA,OAAO,IAAI,CAAClB,aAAa,GAAG,IAAI;EAClC;;EAEA;AACF;AACA;AACA;EACEiC,oBAAoBA,CAAA,EAAG;IACrB,IAAI,IAAI,CAAC/B,WAAW,EAAE;MACpB,OAAO,IAAI,CAAC8B,YAAY;IAC1B;IACA,OAAO,KAAK,CAACC,oBAAoB,CAAC,CAAC;EACrC;;EAEA;AACF;AACA;AACA;AACA;AACA;EACE,OAAOvC,4BAA4BA,CAACwC,iBAAiB,EAAE;IACrD,IAAIA,iBAAiB,YAAY1D,QAAQ,EAAE;MACzC,OAAO0D,iBAAiB;IAC1B;IACA,OAAO5D,yBAAyB,CAAC6D,uBAAuB,CAAC,CAAC;EAC5D;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
@@ -11,7 +11,7 @@ import { EmailAddressQuestion } from "./email-address.js";
11
11
  import { HiddenQuestion } from "./hidden.js";
12
12
  import { LatLongComponentPreviewElements, LatLongQuestion } from "./lat-long.js";
13
13
  import { ListComponentElements, ListQuestion, SelectComponentElements } from "./list.js";
14
- import { LongAnswerQuestion } from "./long-answer.js";
14
+ import { LongAnswerQuestion, MultilineTextFieldComponentPreviewElements } from "./long-answer.js";
15
15
  import { Markdown } from "./markdown.js";
16
16
  import { MonthYearQuestion } from "./month-year.js";
17
17
  import { NationalGridComponentPreviewElements, NationalGridQuestion } from "./national-grid.js";
@@ -77,6 +77,11 @@ const ComponentToPreviewQuestion = {
77
77
  const list = findDefinitionListFromComponent(componentCoerced, definition);
78
78
  return new SelectComponentElements(componentCoerced, list);
79
79
  },
80
+ [ComponentType.MultilineTextField]: (component, _definition) => {
81
+ const componentCoerced = /** @type {MultilineTextFieldComponent} */
82
+ component;
83
+ return new MultilineTextFieldComponentPreviewElements(componentCoerced);
84
+ },
80
85
  [ComponentType.UkAddressField]: (component, _definition) => {
81
86
  const componentCoerced = /** @type {UkAddressFieldComponent} */component;
82
87
  return new UkAddressComponentPreviewElements(componentCoerced);
@@ -151,6 +156,6 @@ export function mapComponentToPreviewQuestion(questionRenderer, definition) {
151
156
  * @import { Question } from '~/src/form/form-editor/preview/question.js'
152
157
  * @import { PreviewComponent } from '~/src/form/form-editor/preview/preview.js'
153
158
  * @import { FormDefinition } from '~/src/form/form-definition/types.js'
154
- * @import { AutocompleteFieldComponent, ComponentDef, DeclarationFieldComponent, EastingNorthingFieldComponent, LatLongFieldComponent, NationalGridFieldNumberFieldComponent, NumberFieldComponent, OsGridRefFieldComponent, SelectFieldComponent, UkAddressFieldComponent, YesNoFieldComponent } from '~/src/components/types.js'
159
+ * @import { AutocompleteFieldComponent, ComponentDef, DeclarationFieldComponent, EastingNorthingFieldComponent, LatLongFieldComponent, MultilineTextFieldComponent, NationalGridFieldNumberFieldComponent, NumberFieldComponent, OsGridRefFieldComponent, SelectFieldComponent, UkAddressFieldComponent, YesNoFieldComponent } from '~/src/components/types.js'
155
160
  */
156
161
  //# sourceMappingURL=helpers.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.js","names":["ComponentType","hasContentField","hasInputField","hasListField","hasSelectionFields","AutocompleteListQuestion","CheckboxQuestion","ComponentElements","ContentElements","DateInputQuestion","DeclarationComponentPreviewElements","DeclarationQuestion","EastingNorthingComponentPreviewElements","EastingNorthingQuestion","EmailAddressQuestion","HiddenQuestion","LatLongComponentPreviewElements","LatLongQuestion","ListComponentElements","ListQuestion","SelectComponentElements","LongAnswerQuestion","Markdown","MonthYearQuestion","NationalGridComponentPreviewElements","NationalGridQuestion","NumberComponentPreviewElements","NumberOnlyQuestion","OsGridRefComponentPreviewElements","OsGridRefQuestion","PhoneNumberQuestion","QuestionComponentElements","RadioQuestion","SelectQuestion","ShortAnswerQuestion","SupportingEvidenceQuestion","UkAddressComponentPreviewElements","UkAddressQuestion","YesNoQuestion","findDefinitionListFromComponent","InputFieldComponentDefault","InputFieldComponentDictionary","TextField","Details","InsetText","Html","List","EmailAddressField","NumberField","MultilineTextField","TelephoneNumberField","MonthYearField","DatePartsField","UkAddressField","AutocompleteField","RadiosField","CheckboxesField","SelectField","YesNoField","DeclarationField","FileUploadField","EastingNorthingField","OsGridRefField","NationalGridFieldNumberField","LatLongField","HiddenField","ComponentToPreviewQuestion","component","definition","componentCoerced","list","_definition","mapComponentToPreviewQuestion","questionRenderer","questionElements","getQuestionElementsFunc","type","QuestionConstructor","previewComponent","id"],"sources":["../../../../../src/form/form-editor/preview/helpers.js"],"sourcesContent":["import { ComponentType } from '~/src/components/enums.js'\nimport {\n hasContentField,\n hasInputField,\n hasListField,\n hasSelectionFields\n} from '~/src/components/helpers.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 {\n DeclarationComponentPreviewElements,\n DeclarationQuestion\n} from '~/src/form/form-editor/preview/declaration.js'\nimport {\n EastingNorthingComponentPreviewElements,\n EastingNorthingQuestion\n} from '~/src/form/form-editor/preview/easting-northing.js'\nimport { EmailAddressQuestion } from '~/src/form/form-editor/preview/email-address.js'\nimport { HiddenQuestion } from '~/src/form/form-editor/preview/hidden.js'\nimport {\n LatLongComponentPreviewElements,\n LatLongQuestion\n} from '~/src/form/form-editor/preview/lat-long.js'\nimport {\n ListComponentElements,\n ListQuestion,\n SelectComponentElements\n} 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 {\n NationalGridComponentPreviewElements,\n NationalGridQuestion\n} from '~/src/form/form-editor/preview/national-grid.js'\nimport {\n NumberComponentPreviewElements,\n NumberOnlyQuestion\n} from '~/src/form/form-editor/preview/number-only.js'\nimport {\n OsGridRefComponentPreviewElements,\n OsGridRefQuestion\n} from '~/src/form/form-editor/preview/os-grid-ref.js'\nimport { PhoneNumberQuestion } from '~/src/form/form-editor/preview/phone-number.js'\nimport { QuestionComponentElements } from '~/src/form/form-editor/preview/question.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 {\n UkAddressComponentPreviewElements,\n UkAddressQuestion\n} 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'\n/**\n * @type {typeof PreviewComponent}\n */\nconst InputFieldComponentDefault = ShortAnswerQuestion\n\n/**\n * @type {Partial<Record<ComponentType, typeof PreviewComponent>>}\n */\nconst InputFieldComponentDictionary = {\n [ComponentType.TextField]: InputFieldComponentDefault,\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.DeclarationField]: DeclarationQuestion,\n [ComponentType.FileUploadField]: SupportingEvidenceQuestion,\n [ComponentType.EastingNorthingField]: EastingNorthingQuestion,\n [ComponentType.OsGridRefField]: OsGridRefQuestion,\n [ComponentType.NationalGridFieldNumberField]: NationalGridQuestion,\n [ComponentType.LatLongField]: LatLongQuestion,\n [ComponentType.HiddenField]: HiddenQuestion\n}\n\n/**\n * @type {Partial<Record<ComponentType, (component: ComponentDef, definition: FormDefinition ) => QuestionElements>>}\n */\nconst ComponentToPreviewQuestion = {\n [ComponentType.AutocompleteField]: (component, definition) => {\n const componentCoerced = /** @type {AutocompleteFieldComponent} */ (\n component\n )\n const list = findDefinitionListFromComponent(componentCoerced, definition)\n return new SelectComponentElements(componentCoerced, list)\n },\n [ComponentType.SelectField]: (component, definition) => {\n const componentCoerced = /** @type {SelectFieldComponent} */ (component)\n const list = findDefinitionListFromComponent(componentCoerced, definition)\n return new SelectComponentElements(componentCoerced, list)\n },\n [ComponentType.UkAddressField]: (component, _definition) => {\n const componentCoerced = /** @type {UkAddressFieldComponent} */ (component)\n return new UkAddressComponentPreviewElements(componentCoerced)\n },\n [ComponentType.NumberField]: (component, _definition) => {\n const componentCoerced = /** @type {NumberFieldComponent} */ (component)\n return new NumberComponentPreviewElements(componentCoerced)\n },\n [ComponentType.DeclarationField]: (component, _definition) => {\n const componentCoerced = /** @type {DeclarationFieldComponent} */ (\n component\n )\n return new DeclarationComponentPreviewElements(componentCoerced)\n },\n [ComponentType.YesNoField]: (component, _definition) => {\n const componentCoerced = /** @type {YesNoFieldComponent} */ (component)\n return new QuestionComponentElements(componentCoerced)\n },\n [ComponentType.EastingNorthingField]: (component, _definition) => {\n const componentCoerced = /** @type {EastingNorthingFieldComponent} */ (\n component\n )\n return new EastingNorthingComponentPreviewElements(componentCoerced)\n },\n [ComponentType.OsGridRefField]: (component, _definition) => {\n const componentCoerced = /** @type {OsGridRefFieldComponent} */ (component)\n return new OsGridRefComponentPreviewElements(componentCoerced)\n },\n [ComponentType.NationalGridFieldNumberField]: (component, _definition) => {\n const componentCoerced =\n /** @type {NationalGridFieldNumberFieldComponent} */ (component)\n return new NationalGridComponentPreviewElements(componentCoerced)\n },\n [ComponentType.LatLongField]: (component, _definition) => {\n const componentCoerced = /** @type {LatLongFieldComponent} */ (component)\n return new LatLongComponentPreviewElements(componentCoerced)\n }\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 // Look for one-to-one mapping first, then fallback if not found\n const getQuestionElementsFunc = ComponentToPreviewQuestion[component.type]\n if (getQuestionElementsFunc) {\n questionElements = getQuestionElementsFunc(component, definition)\n } else if (hasSelectionFields(component) && hasListField(component)) {\n const list = findDefinitionListFromComponent(component, definition)\n questionElements = new ListComponentElements(component, list)\n } else if (hasInputField(component)) {\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 =\n InputFieldComponentDictionary[component.type] ??\n InputFieldComponentDefault\n const previewComponent = new QuestionConstructor(\n questionElements,\n questionRenderer\n )\n previewComponent.id = component.id\n return previewComponent\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 { FormDefinition } from '~/src/form/form-definition/types.js'\n * @import { AutocompleteFieldComponent, ComponentDef, DeclarationFieldComponent, EastingNorthingFieldComponent, LatLongFieldComponent, NationalGridFieldNumberFieldComponent, NumberFieldComponent, OsGridRefFieldComponent, SelectFieldComponent, UkAddressFieldComponent, YesNoFieldComponent } from '~/src/components/types.js'\n */\n"],"mappings":"AAAA,SAASA,aAAa;AACtB,SACEC,eAAe,EACfC,aAAa,EACbC,YAAY,EACZC,kBAAkB;AAEpB,SAASC,wBAAwB;AACjC,SAASC,gBAAgB;AACzB,SAASC,iBAAiB;AAC1B,SAASC,eAAe;AACxB,SAASC,iBAAiB;AAC1B,SACEC,mCAAmC,EACnCC,mBAAmB;AAErB,SACEC,uCAAuC,EACvCC,uBAAuB;AAEzB,SAASC,oBAAoB;AAC7B,SAASC,cAAc;AACvB,SACEC,+BAA+B,EAC/BC,eAAe;AAEjB,SACEC,qBAAqB,EACrBC,YAAY,EACZC,uBAAuB;AAEzB,SAASC,kBAAkB;AAC3B,SAASC,QAAQ;AACjB,SAASC,iBAAiB;AAC1B,SACEC,oCAAoC,EACpCC,oBAAoB;AAEtB,SACEC,8BAA8B,EAC9BC,kBAAkB;AAEpB,SACEC,iCAAiC,EACjCC,iBAAiB;AAEnB,SAASC,mBAAmB;AAC5B,SAASC,yBAAyB;AAClC,SAASC,aAAa;AACtB,SAASC,cAAc;AACvB,SAASC,mBAAmB;AAC5B,SAASC,0BAA0B;AACnC,SACEC,iCAAiC,EACjCC,iBAAiB;AAEnB,SAASC,aAAa;AACtB,SAASC,+BAA+B;AACxC;AACA;AACA;AACA,MAAMC,0BAA0B,GAAGN,mBAAmB;;AAEtD;AACA;AACA;AACA,MAAMO,6BAA6B,GAAG;EACpC,CAACzC,aAAa,CAAC0C,SAAS,GAAGF,0BAA0B;EACrD,CAACxC,aAAa,CAAC2C,OAAO,GAAGT,mBAAmB;EA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AC/D,CAAC,MAAM,IAAIpE,aAAa,CAACiE,SAAS,CAAC,EAAE;MACnCO,gBAAgB,GAAG,IAAI3C,yBAAyB,CAACoC,SAAS,CAAC;IAC7D,CAAC,MAAM,IAAIlE,eAAe,CAACkE,SAAS,CAAC,EAAE;MACrCO,gBAAgB,GAAG,IAAIlE,eAAe,CAAC2D,SAAS,CAAC;IACnD,CAAC,MAAM;MACLO,gBAAgB,GAAG,IAAInE,iBAAiB,CAAC4D,SAAS,CAAC;IACrD;IAEA,MAAMU,mBAAmB,GACvBpC,6BAA6B,CAAC0B,SAAS,CAACS,IAAI,CAAC,IAC7CpC,0BAA0B;IAC5B,MAAMsC,gBAAgB,GAAG,IAAID,mBAAmB,CAC9CH,gBAAgB,EAChBD,gBACF,CAAC;IACDK,gBAAgB,CAACC,EAAE,GAAGZ,SAAS,CAACY,EAAE;IAClC,OAAOD,gBAAgB;EACzB,CAAC;AAEL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
1
+ {"version":3,"file":"helpers.js","names":["ComponentType","hasContentField","hasInputField","hasListField","hasSelectionFields","AutocompleteListQuestion","CheckboxQuestion","ComponentElements","ContentElements","DateInputQuestion","DeclarationComponentPreviewElements","DeclarationQuestion","EastingNorthingComponentPreviewElements","EastingNorthingQuestion","EmailAddressQuestion","HiddenQuestion","LatLongComponentPreviewElements","LatLongQuestion","ListComponentElements","ListQuestion","SelectComponentElements","LongAnswerQuestion","MultilineTextFieldComponentPreviewElements","Markdown","MonthYearQuestion","NationalGridComponentPreviewElements","NationalGridQuestion","NumberComponentPreviewElements","NumberOnlyQuestion","OsGridRefComponentPreviewElements","OsGridRefQuestion","PhoneNumberQuestion","QuestionComponentElements","RadioQuestion","SelectQuestion","ShortAnswerQuestion","SupportingEvidenceQuestion","UkAddressComponentPreviewElements","UkAddressQuestion","YesNoQuestion","findDefinitionListFromComponent","InputFieldComponentDefault","InputFieldComponentDictionary","TextField","Details","InsetText","Html","List","EmailAddressField","NumberField","MultilineTextField","TelephoneNumberField","MonthYearField","DatePartsField","UkAddressField","AutocompleteField","RadiosField","CheckboxesField","SelectField","YesNoField","DeclarationField","FileUploadField","EastingNorthingField","OsGridRefField","NationalGridFieldNumberField","LatLongField","HiddenField","ComponentToPreviewQuestion","component","definition","componentCoerced","list","_definition","mapComponentToPreviewQuestion","questionRenderer","questionElements","getQuestionElementsFunc","type","QuestionConstructor","previewComponent","id"],"sources":["../../../../../src/form/form-editor/preview/helpers.js"],"sourcesContent":["import { ComponentType } from '~/src/components/enums.js'\nimport {\n hasContentField,\n hasInputField,\n hasListField,\n hasSelectionFields\n} from '~/src/components/helpers.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 {\n DeclarationComponentPreviewElements,\n DeclarationQuestion\n} from '~/src/form/form-editor/preview/declaration.js'\nimport {\n EastingNorthingComponentPreviewElements,\n EastingNorthingQuestion\n} from '~/src/form/form-editor/preview/easting-northing.js'\nimport { EmailAddressQuestion } from '~/src/form/form-editor/preview/email-address.js'\nimport { HiddenQuestion } from '~/src/form/form-editor/preview/hidden.js'\nimport {\n LatLongComponentPreviewElements,\n LatLongQuestion\n} from '~/src/form/form-editor/preview/lat-long.js'\nimport {\n ListComponentElements,\n ListQuestion,\n SelectComponentElements\n} from '~/src/form/form-editor/preview/list.js'\nimport {\n LongAnswerQuestion,\n MultilineTextFieldComponentPreviewElements\n} 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 {\n NationalGridComponentPreviewElements,\n NationalGridQuestion\n} from '~/src/form/form-editor/preview/national-grid.js'\nimport {\n NumberComponentPreviewElements,\n NumberOnlyQuestion\n} from '~/src/form/form-editor/preview/number-only.js'\nimport {\n OsGridRefComponentPreviewElements,\n OsGridRefQuestion\n} from '~/src/form/form-editor/preview/os-grid-ref.js'\nimport { PhoneNumberQuestion } from '~/src/form/form-editor/preview/phone-number.js'\nimport { QuestionComponentElements } from '~/src/form/form-editor/preview/question.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 {\n UkAddressComponentPreviewElements,\n UkAddressQuestion\n} 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'\n/**\n * @type {typeof PreviewComponent}\n */\nconst InputFieldComponentDefault = ShortAnswerQuestion\n\n/**\n * @type {Partial<Record<ComponentType, typeof PreviewComponent>>}\n */\nconst InputFieldComponentDictionary = {\n [ComponentType.TextField]: InputFieldComponentDefault,\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.DeclarationField]: DeclarationQuestion,\n [ComponentType.FileUploadField]: SupportingEvidenceQuestion,\n [ComponentType.EastingNorthingField]: EastingNorthingQuestion,\n [ComponentType.OsGridRefField]: OsGridRefQuestion,\n [ComponentType.NationalGridFieldNumberField]: NationalGridQuestion,\n [ComponentType.LatLongField]: LatLongQuestion,\n [ComponentType.HiddenField]: HiddenQuestion\n}\n\n/**\n * @type {Partial<Record<ComponentType, (component: ComponentDef, definition: FormDefinition ) => QuestionElements>>}\n */\nconst ComponentToPreviewQuestion = {\n [ComponentType.AutocompleteField]: (component, definition) => {\n const componentCoerced = /** @type {AutocompleteFieldComponent} */ (\n component\n )\n const list = findDefinitionListFromComponent(componentCoerced, definition)\n return new SelectComponentElements(componentCoerced, list)\n },\n [ComponentType.SelectField]: (component, definition) => {\n const componentCoerced = /** @type {SelectFieldComponent} */ (component)\n const list = findDefinitionListFromComponent(componentCoerced, definition)\n return new SelectComponentElements(componentCoerced, list)\n },\n [ComponentType.MultilineTextField]: (component, _definition) => {\n const componentCoerced = /** @type {MultilineTextFieldComponent} */ (\n component\n )\n return new MultilineTextFieldComponentPreviewElements(componentCoerced)\n },\n [ComponentType.UkAddressField]: (component, _definition) => {\n const componentCoerced = /** @type {UkAddressFieldComponent} */ (component)\n return new UkAddressComponentPreviewElements(componentCoerced)\n },\n [ComponentType.NumberField]: (component, _definition) => {\n const componentCoerced = /** @type {NumberFieldComponent} */ (component)\n return new NumberComponentPreviewElements(componentCoerced)\n },\n [ComponentType.DeclarationField]: (component, _definition) => {\n const componentCoerced = /** @type {DeclarationFieldComponent} */ (\n component\n )\n return new DeclarationComponentPreviewElements(componentCoerced)\n },\n [ComponentType.YesNoField]: (component, _definition) => {\n const componentCoerced = /** @type {YesNoFieldComponent} */ (component)\n return new QuestionComponentElements(componentCoerced)\n },\n [ComponentType.EastingNorthingField]: (component, _definition) => {\n const componentCoerced = /** @type {EastingNorthingFieldComponent} */ (\n component\n )\n return new EastingNorthingComponentPreviewElements(componentCoerced)\n },\n [ComponentType.OsGridRefField]: (component, _definition) => {\n const componentCoerced = /** @type {OsGridRefFieldComponent} */ (component)\n return new OsGridRefComponentPreviewElements(componentCoerced)\n },\n [ComponentType.NationalGridFieldNumberField]: (component, _definition) => {\n const componentCoerced =\n /** @type {NationalGridFieldNumberFieldComponent} */ (component)\n return new NationalGridComponentPreviewElements(componentCoerced)\n },\n [ComponentType.LatLongField]: (component, _definition) => {\n const componentCoerced = /** @type {LatLongFieldComponent} */ (component)\n return new LatLongComponentPreviewElements(componentCoerced)\n }\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 // Look for one-to-one mapping first, then fallback if not found\n const getQuestionElementsFunc = ComponentToPreviewQuestion[component.type]\n if (getQuestionElementsFunc) {\n questionElements = getQuestionElementsFunc(component, definition)\n } else if (hasSelectionFields(component) && hasListField(component)) {\n const list = findDefinitionListFromComponent(component, definition)\n questionElements = new ListComponentElements(component, list)\n } else if (hasInputField(component)) {\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 =\n InputFieldComponentDictionary[component.type] ??\n InputFieldComponentDefault\n const previewComponent = new QuestionConstructor(\n questionElements,\n questionRenderer\n )\n previewComponent.id = component.id\n return previewComponent\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 { FormDefinition } from '~/src/form/form-definition/types.js'\n * @import { AutocompleteFieldComponent, ComponentDef, DeclarationFieldComponent, EastingNorthingFieldComponent, LatLongFieldComponent, MultilineTextFieldComponent, NationalGridFieldNumberFieldComponent, NumberFieldComponent, OsGridRefFieldComponent, SelectFieldComponent, UkAddressFieldComponent, YesNoFieldComponent } from '~/src/components/types.js'\n */\n"],"mappings":"AAAA,SAASA,aAAa;AACtB,SACEC,eAAe,EACfC,aAAa,EACbC,YAAY,EACZC,kBAAkB;AAEpB,SAASC,wBAAwB;AACjC,SAASC,gBAAgB;AACzB,SAASC,iBAAiB;AAC1B,SAASC,eAAe;AACxB,SAASC,iBAAiB;AAC1B,SACEC,mCAAmC,EACnCC,mBAAmB;AAErB,SACEC,uCAAuC,EACvCC,uBAAuB;AAEzB,SAASC,oBAAoB;AAC7B,SAASC,cAAc;AACvB,SACEC,+BAA+B,EAC/BC,eAAe;AAEjB,SACEC,qBAAqB,EACrBC,YAAY,EACZC,uBAAuB;AAEzB,SACEC,kBAAkB,EAClBC,0CAA0C;AAE5C,SAASC,QAAQ;AACjB,SAASC,iBAAiB;AAC1B,SACEC,oCAAoC,EACpCC,oBAAoB;AAEtB,SACEC,8BAA8B,EAC9BC,kBAAkB;AAEpB,SACEC,iCAAiC,EACjCC,iBAAiB;AAEnB,SAASC,mBAAmB;AAC5B,SAASC,yBAAyB;AAClC,SAASC,aAAa;AACtB,SAASC,cAAc;AACvB,SAASC,mBAAmB;AAC5B,SAASC,0BAA0B;AACnC,SACEC,iCAAiC,EACjCC,iBAAiB;AAEnB,SAASC,aAAa;AACtB,SAASC,+BAA+B;AACxC;AACA;AACA;AACA,MAAMC,0BAA0B,GAAGN,mBAAmB;;AAEtD;AACA;AACA;AACA,MAAMO,6BAA6B,GAAG;EACpC,CAAC1C,aAAa,CAAC2C,SAAS,GAAGF,0BAA0B;EACrD,CAACzC,aAAa,CAAC4C,OAAO,GAAGT,mBAAmB;EAC5C,CAACnC,aAAa,CAAC6C,SAAS,GAAGV,mBAAmB;EAC9C,CAACnC,aAAa,CAAC8C,IAAI,GAAGX,mBAAmB;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AAC;MACnEM,gBAAgB,GAAG,IAAIzD,qBAAqB,CAACkD,SAAS,EAAEG,IAAI,CAAC;IAC/D,CAAC,MAAM,IAAIrE,aAAa,CAACkE,SAAS,CAAC,EAAE;MACnCO,gBAAgB,GAAG,IAAI3C,yBAAyB,CAACoC,SAAS,CAAC;IAC7D,CAAC,MAAM,IAAInE,eAAe,CAACmE,SAAS,CAAC,EAAE;MACrCO,gBAAgB,GAAG,IAAInE,eAAe,CAAC4D,SAAS,CAAC;IACnD,CAAC,MAAM;MACLO,gBAAgB,GAAG,IAAIpE,iBAAiB,CAAC6D,SAAS,CAAC;IACrD;IAEA,MAAMU,mBAAmB,GACvBpC,6BAA6B,CAAC0B,SAAS,CAACS,IAAI,CAAC,IAC7CpC,0BAA0B;IAC5B,MAAMsC,gBAAgB,GAAG,IAAID,mBAAmB,CAC9CH,gBAAgB,EAChBD,gBACF,CAAC;IACDK,gBAAgB,CAACC,EAAE,GAAGZ,SAAS,CAACY,EAAE;IAClC,OAAOD,gBAAgB;EACzB,CAAC;AAEL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
@@ -1,6 +1,39 @@
1
1
  import { ComponentType } from "../../../components/enums.js";
2
2
  import { PreviewComponent } from "./preview.js";
3
- import { Question } from "./question.js";
3
+ import { Question, QuestionComponentElements } from "./question.js";
4
+
5
+ /**
6
+ * @constant
7
+ * @type {number}
8
+ * The default number of rows for a multiline text field.
9
+ */
10
+ export const MULTILINE_TEXT_QUESTION_DEFAULT_ROWS = 5;
11
+
12
+ /**
13
+ * @implements {QuestionElements}
14
+ */
15
+ export class MultilineTextFieldComponentPreviewElements extends QuestionComponentElements {
16
+ /**
17
+ * @param {MultilineTextFieldComponent} component
18
+ */
19
+ constructor(component) {
20
+ super(component);
21
+ this._maxLength = component.schema.max;
22
+ this._rows = component.options.rows;
23
+ }
24
+
25
+ /**
26
+ * @protected
27
+ * @returns {MultilineTextFieldSettings}
28
+ */
29
+ _getValues() {
30
+ return {
31
+ ...super._getValues(),
32
+ maxLength: this._maxLength ?? 0,
33
+ rows: this._rows ?? MULTILINE_TEXT_QUESTION_DEFAULT_ROWS
34
+ };
35
+ }
36
+ }
4
37
  export class LongAnswerQuestion extends Question {
5
38
  /**
6
39
  * @type {ComponentType}
@@ -16,5 +49,59 @@ export class LongAnswerQuestion extends Question {
16
49
  * @protected
17
50
  */
18
51
  _fieldName = 'longAnswerField';
52
+
53
+ /**
54
+ * @param {MultilineTextFieldElements} htmlElements
55
+ * @param {QuestionRenderer} questionRenderer
56
+ */
57
+ constructor(htmlElements, questionRenderer) {
58
+ super(htmlElements, questionRenderer);
59
+ this._maxLength = htmlElements.values.maxLength;
60
+ this._rows = htmlElements.values.rows;
61
+ }
62
+ get maxLength() {
63
+ return this._maxLength;
64
+ }
65
+
66
+ /**
67
+ * @param {number} val
68
+ */
69
+ set maxLength(val) {
70
+ this._maxLength = val;
71
+ this.render();
72
+ }
73
+ get rows() {
74
+ return this._rows;
75
+ }
76
+
77
+ /**
78
+ * @param {number} val
79
+ */
80
+ set rows(val) {
81
+ this._rows = val;
82
+ this.render();
83
+ }
84
+
85
+ /**
86
+ * @protected
87
+ */
88
+ _renderInput() {
89
+ const maxLengthObj = this.maxLength && this.maxLength > 0 ? {
90
+ maxlength: this.maxLength
91
+ } : {};
92
+ const rowsObj = this.rows ? {
93
+ rows: this.rows
94
+ } : {};
95
+ return {
96
+ ...super._renderInput(),
97
+ ...maxLengthObj,
98
+ ...rowsObj
99
+ };
100
+ }
19
101
  }
102
+
103
+ /**
104
+ * @import { MultilineTextFieldSettings, MultilineTextFieldElements, QuestionElements, QuestionRenderer } from '~/src/form/form-editor/preview/types.js'
105
+ * @import { MultilineTextFieldComponent } from '~/src/components/types.js'
106
+ */
20
107
  //# sourceMappingURL=long-answer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"long-answer.js","names":["ComponentType","PreviewComponent","Question","LongAnswerQuestion","componentType","MultilineTextField","_questionTemplate","PATH","_fieldName"],"sources":["../../../../../src/form/form-editor/preview/long-answer.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 LongAnswerQuestion extends Question {\n /**\n * @type {ComponentType}\n */\n componentType = ComponentType.MultilineTextField\n /**\n * @type {string}\n * @protected\n */\n _questionTemplate = PreviewComponent.PATH + 'textarea.njk'\n /**\n * @type {string}\n * @protected\n */\n _fieldName = 'longAnswerField'\n}\n"],"mappings":"AAAA,SAASA,aAAa;AACtB,SAASC,gBAAgB;AACzB,SAASC,QAAQ;AAEjB,OAAO,MAAMC,kBAAkB,SAASD,QAAQ,CAAC;EAC/C;AACF;AACA;EACEE,aAAa,GAAGJ,aAAa,CAACK,kBAAkB;EAChD;AACF;AACA;AACA;EACEC,iBAAiB,GAAGL,gBAAgB,CAACM,IAAI,GAAG,cAAc;EAC1D;AACF;AACA;AACA;EACEC,UAAU,GAAG,iBAAiB;AAChC","ignoreList":[]}
1
+ {"version":3,"file":"long-answer.js","names":["ComponentType","PreviewComponent","Question","QuestionComponentElements","MULTILINE_TEXT_QUESTION_DEFAULT_ROWS","MultilineTextFieldComponentPreviewElements","constructor","component","_maxLength","schema","max","_rows","options","rows","_getValues","maxLength","LongAnswerQuestion","componentType","MultilineTextField","_questionTemplate","PATH","_fieldName","htmlElements","questionRenderer","values","val","render","_renderInput","maxLengthObj","maxlength","rowsObj"],"sources":["../../../../../src/form/form-editor/preview/long-answer.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\n/**\n * @constant\n * @type {number}\n * The default number of rows for a multiline text field.\n */\nexport const MULTILINE_TEXT_QUESTION_DEFAULT_ROWS = 5\n\n/**\n * @implements {QuestionElements}\n */\nexport class MultilineTextFieldComponentPreviewElements extends QuestionComponentElements {\n /**\n * @param {MultilineTextFieldComponent} component\n */\n constructor(component) {\n super(component)\n this._maxLength = component.schema.max\n this._rows = component.options.rows\n }\n\n /**\n * @protected\n * @returns {MultilineTextFieldSettings}\n */\n _getValues() {\n return {\n ...super._getValues(),\n maxLength: this._maxLength ?? 0,\n rows: this._rows ?? MULTILINE_TEXT_QUESTION_DEFAULT_ROWS\n }\n }\n}\n\nexport class LongAnswerQuestion extends Question {\n /**\n * @type {ComponentType}\n */\n componentType = ComponentType.MultilineTextField\n /**\n * @type {string}\n * @protected\n */\n _questionTemplate = PreviewComponent.PATH + 'textarea.njk'\n /**\n * @type {string}\n * @protected\n */\n _fieldName = 'longAnswerField'\n\n /**\n * @param {MultilineTextFieldElements} htmlElements\n * @param {QuestionRenderer} questionRenderer\n */\n constructor(htmlElements, questionRenderer) {\n super(htmlElements, questionRenderer)\n this._maxLength = htmlElements.values.maxLength\n this._rows = htmlElements.values.rows\n }\n\n get maxLength() {\n return this._maxLength\n }\n\n /**\n * @param {number} val\n */\n set maxLength(val) {\n this._maxLength = val\n this.render()\n }\n\n get rows() {\n return this._rows\n }\n\n /**\n * @param {number} val\n */\n set rows(val) {\n this._rows = val\n this.render()\n }\n\n /**\n * @protected\n */\n _renderInput() {\n const maxLengthObj =\n this.maxLength && this.maxLength > 0 ? { maxlength: this.maxLength } : {}\n const rowsObj = this.rows ? { rows: this.rows } : {}\n return {\n ...super._renderInput(),\n ...maxLengthObj,\n ...rowsObj\n }\n }\n}\n\n/**\n * @import { MultilineTextFieldSettings, MultilineTextFieldElements, QuestionElements, QuestionRenderer } from '~/src/form/form-editor/preview/types.js'\n * @import { MultilineTextFieldComponent } from '~/src/components/types.js'\n */\n"],"mappings":"AAAA,SAASA,aAAa;AACtB,SAASC,gBAAgB;AACzB,SACEC,QAAQ,EACRC,yBAAyB;;AAG3B;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,oCAAoC,GAAG,CAAC;;AAErD;AACA;AACA;AACA,OAAO,MAA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AAIA,CAACY,GAAG,EAAE;IACZ,IAAI,CAACd,KAAK,GAAGc,GAAG;IAChB,IAAI,CAACC,MAAM,CAAC,CAAC;EACf;;EAEA;AACF;AACA;EACEC,YAAYA,CAAA,EAAG;IACb,MAAMC,YAAY,GAChB,IAAI,CAACb,SAAS,IAAI,IAAI,CAACA,SAAS,GAAG,CAAC,GAAG;MAAEc,SAAS,EAAE,IAAI,CAACd;IAAU,CAAC,GAAG,CAAC,CAAC;IAC3E,MAAMe,OAAO,GAAG,IAAI,CAACjB,IAAI,GAAG;MAAEA,IAAI,EAAE,IAAI,CAACA;IAAK,CAAC,GAAG,CAAC,CAAC;IACpD,OAAO;MACL,GAAG,KAAK,CAACc,YAAY,CAAC,CAAC;MACvB,GAAGC,YAAY;MACf,GAAGE;IACL,CAAC;EACH;AACF;;AAEA;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 userClasses: 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 isPageHeading?: boolean\n}\n\nexport interface GovukFieldset {\n legend: DefaultComponent\n}\n\nexport type ListenerRow = [\n HTMLInputElement | HTMLTextAreaElement | null,\n (target: HTMLInputElement | HTMLTextAreaElement, 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 NumberSettings extends BaseSettings {\n prefix: string\n suffix: string\n}\n\nexport interface DeclarationSettings extends BaseSettings {\n declarationText: string\n}\n\nexport interface DeclarationElements extends DomElementsBase {\n readonly values: DeclarationSettings\n}\n\nexport interface UkAddressSettings extends BaseSettings {\n usePostcodeLookup?: boolean\n}\n\nexport interface UkAddressElements extends DomElementsBase {\n readonly values: UkAddressSettings\n}\n\nexport interface NumberElements extends DomElementsBase {\n readonly values: NumberSettings\n}\n\nexport interface LocationSettings extends BaseSettings {\n instructionText: string\n}\n\nexport interface LocationElements extends DomElementsBase {\n readonly values: LocationSettings\n}\n\nexport interface LocationFieldModel extends QuestionBaseModel {\n userClasses: string\n fieldset: {\n legend: {\n text: string\n classes: string\n }\n }\n instructionText: string\n details: {\n classes: string\n }\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 interface SectionForPreview {\n name: string\n title: string\n pages: { title: string }[]\n}\n\nexport interface SummaryPageElements extends PagePreviewBaseElements {\n declaration: boolean\n showConfirmationEmail: boolean\n isConfirmationEmailSettingsPanel: boolean\n sections?: SectionForPreview[]\n unassignedPages?: { title: string }[]\n}\n\nexport interface SummaryPageInitialState {\n showConfirmationEmail: boolean\n declarationText: string\n needDeclaration: boolean\n isConfirmationEmailSettingsPanel: boolean\n sections?: SectionForPreview[]\n unassignedPages?: { title: string }[]\n}\n\nexport type PreviewQuestion =\n | DateInputQuestion\n | EmailAddressQuestion\n | ListSortableQuestion\n | LongAnswerQuestion\n | PhoneNumberQuestion\n | Question\n | RadioSortableQuestion\n | SelectSortableQuestion\n | ShortAnswerQuestion\n | UkAddressQuestion\n | AutocompleteQuestion\n"],"mappings":"","ignoreList":[]}
1
+ {"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 userClasses: 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 isPageHeading?: boolean\n}\n\nexport interface GovukFieldset {\n legend: DefaultComponent\n}\n\nexport type ListenerRow = [\n HTMLInputElement | HTMLTextAreaElement | null,\n (target: HTMLInputElement | HTMLTextAreaElement, 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 NumberSettings extends BaseSettings {\n prefix: string\n suffix: string\n}\n\nexport interface DeclarationSettings extends BaseSettings {\n declarationText: string\n}\n\nexport interface DeclarationElements extends DomElementsBase {\n readonly values: DeclarationSettings\n}\n\nexport interface UkAddressSettings extends BaseSettings {\n usePostcodeLookup?: boolean\n}\n\nexport interface UkAddressElements extends DomElementsBase {\n readonly values: UkAddressSettings\n}\n\nexport interface NumberElements extends DomElementsBase {\n readonly values: NumberSettings\n}\n\nexport interface MultilineTextFieldSettings extends BaseSettings {\n maxLength: number\n rows: number\n}\n\nexport interface MultilineTextFieldElements extends DomElementsBase {\n readonly values: MultilineTextFieldSettings\n}\n\nexport interface LocationSettings extends BaseSettings {\n instructionText: string\n}\n\nexport interface LocationElements extends DomElementsBase {\n readonly values: LocationSettings\n}\n\nexport interface LocationFieldModel extends QuestionBaseModel {\n userClasses: string\n fieldset: {\n legend: {\n text: string\n classes: string\n }\n }\n instructionText: string\n details: {\n classes: string\n }\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 PageSectionInfo {\n title: string\n hideTitle: boolean\n}\n\nexport interface PageOverviewElements extends PagePreviewBaseElements {\n addHeading: boolean\n repeatQuestion: string | undefined\n hasRepeater: boolean\n section?: PageSectionInfo\n}\n\nexport interface SectionForPreview {\n name: string\n title: string\n pages: { title: string }[]\n}\n\nexport interface SummaryPageElements extends PagePreviewBaseElements {\n declaration: boolean\n showConfirmationEmail: boolean\n isConfirmationEmailSettingsPanel: boolean\n sections?: SectionForPreview[]\n unassignedPages?: { title: string }[]\n}\n\nexport interface SummaryPageInitialState {\n showConfirmationEmail: boolean\n declarationText: string\n needDeclaration: boolean\n isConfirmationEmailSettingsPanel: boolean\n sections?: SectionForPreview[]\n unassignedPages?: { title: string }[]\n}\n\nexport type PreviewQuestion =\n | DateInputQuestion\n | EmailAddressQuestion\n | ListSortableQuestion\n | LongAnswerQuestion\n | PhoneNumberQuestion\n | Question\n | RadioSortableQuestion\n | SelectSortableQuestion\n | ShortAnswerQuestion\n | UkAddressQuestion\n | AutocompleteQuestion\n"],"mappings":"","ignoreList":[]}
@@ -1,4 +1,9 @@
1
1
  export class GuidancePageController extends PreviewPageControllerBase {
2
+ /**
3
+ * @param {PageOverviewElements} elements
4
+ * @param {PageRenderer} renderer
5
+ */
6
+ constructor(elements: PageOverviewElements, renderer: PageRenderer);
2
7
  /**
3
8
  * @type {Markdown}
4
9
  * @protected
@@ -7,4 +12,6 @@ export class GuidancePageController extends PreviewPageControllerBase {
7
12
  }
8
13
  import { PreviewPageControllerBase } from '../../../../form/form-editor/preview/controller/page-controller-base.js';
9
14
  import type { Markdown } from '../../../../form/form-editor/preview/markdown.js';
15
+ import type { PageOverviewElements } from '../../../../form/form-editor/preview/types.js';
16
+ import type { PageRenderer } from '../../../../form/form-editor/preview/types.js';
10
17
  //# sourceMappingURL=guidance-page-controller.d.ts.map
@@ -1 +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"}
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,sBAHW,oBAAoB,YACpB,YAAY,EAQtB;IAvBD;;;OAGG;IACH,uCAHU,QAAQ,CAIwC;CAiD3D;0CA3DyC,mEAAmE;8BA8DhF,4CAA4C;0CAClB,yCAAyC;kCAAzC,yCAAyC"}
@@ -4,18 +4,25 @@
4
4
  export class PagePreviewElements implements PageOverviewElements {
5
5
  /**
6
6
  * @param {Page|undefined} page
7
+ * @param {PageSectionInfo} [section]
7
8
  */
8
- constructor(page: Page | undefined);
9
+ constructor(page: Page | undefined, section?: PageSectionInfo);
9
10
  /**
10
11
  * @type {Page | { title: string }}
11
12
  * @private
12
13
  */
13
14
  private _page;
15
+ /**
16
+ * @type {PageSectionInfo | undefined}
17
+ * @protected
18
+ */
19
+ protected _section: PageSectionInfo | undefined;
14
20
  get heading(): string;
15
21
  get guidance(): string;
16
22
  get addHeading(): boolean;
17
23
  get repeatQuestion(): string | undefined;
18
24
  get hasRepeater(): boolean;
25
+ get section(): PageSectionInfo | undefined;
19
26
  }
20
27
  /**
21
28
  * @abstract
@@ -88,6 +95,12 @@ export class PreviewPageControllerBase implements PagePreviewPanelMacro {
88
95
  * @type {boolean}
89
96
  */
90
97
  protected _isRepeater: boolean;
98
+ /**
99
+ * Section info for the page
100
+ * @type {PageSectionInfo | undefined}
101
+ * @protected
102
+ */
103
+ protected _section: PageSectionInfo | undefined;
91
104
  /**
92
105
  * @returns {Markdown[]}
93
106
  * @protected
@@ -182,6 +195,7 @@ export class PreviewPageControllerBase implements PagePreviewPanelMacro {
182
195
  #private;
183
196
  }
184
197
  import type { PageOverviewElements } from '../../../../form/form-editor/preview/types.js';
198
+ import type { PageSectionInfo } from '../../../../form/form-editor/preview/types.js';
185
199
  import type { Page } from '../../../../form/form-definition/types.js';
186
200
  import type { PagePreviewPanelMacro } from '../../../../form/form-editor/macros/types.js';
187
201
  import type { Question } from '../../../../form/form-editor/preview/question.js';
@@ -1 +1 @@
1
- {"version":3,"file":"page-controller-base.d.ts","sourceRoot":"","sources":["../../../../../../src/form/form-editor/preview/controller/page-controller-base.js"],"names":[],"mappings":"AA6BA;;GAEG;AACH;IASE;;OAEG;IACH,kBAFW,IAAI,GAAC,SAAS,EAMxB;IAfD;;;OAGG;IACH,cAEC;IAWD,sBAEC;IAED,uBAUC;IAED,0BAEC;IAED,yCAKC;IAED,2BAEC;CACF;AAED;;;GAGG;AACH;IACE,oBAAoC;IAmEpC;;OAEG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CAUvD;IAED;;;OAGG;IACH,kCAHa,MAAM,GAAC,SAAS,CAK5B;IAED;;OAEG;IACH,0BAFW,MAAM,GAAG,SAAS,EAK5B;IAED,wBAPW,MAAM,GAAG,SAAS,CAS5B;IAuBD,0BAGC;IAED;;OAEG;IACH,iCAFW,cAAc,QAKxB;IAED,uBAKC;IAED;;;;OAIG;IACH,gCAJW,MAAM,GAEJ,MAAM,CAIlB;IAED;;OAEG;IACH,8BAFW,MAAM,QAWhB;;CACF;0CAGoH,yCAAyC;0BAErI,qCAAqC;2CACE,wCAAwC;8BAF3E,4CAA4C;;;;sBAvX/D,MAAM;;;;;;yBAlBS,4CAA4C;0CA2YL,wCAAwC;6CAHa,yCAAyC;kCAAzC,yCAAyC"}
1
+ {"version":3,"file":"page-controller-base.d.ts","sourceRoot":"","sources":["../../../../../../src/form/form-editor/preview/controller/page-controller-base.js"],"names":[],"mappings":"AA6BA;;GAEG;AACH;IAeE;;;OAGG;IACH,kBAHW,IAAI,GAAC,SAAS,YACd,eAAe,EAOzB;IAvBD;;;OAGG;IACH,cAEC;IAED;;;OAGG;IACH,oBAHU,eAAe,GAAG,SAAS,CAGjB;IAapB,sBAEC;IAED,uBAUC;IAED,0BAEC;IAED,yCAKC;IAED,2BAEC;IAED,2CAEC;CACF;AAED;;;GAGG;AACH;IACE,oBAAoC;IA0EpC;;OAEG;IACH,uBAFU,OAAO,cAAc,CAEO;IA+KtC;;;;OAIG;IACH,qDAFa,QAAQ,CAgBpB;IA/MD;;;OAGG;IACH,sBAHW,uBAAuB,YACvB,YAAY,EAMtB;IAvED;;;OAGG;IACH,yBAHU,MAAM,CAGsD;IACtE;;;OAGG;IACH,uBAFU,QAAQ,EAAE,CAEJ;IAChB;;;OAGG;IACH,sBAHU,OAAO,CAGA;IACjB;;;OAGG;IACH,kBAFU,MAAM,CAEL;IAMX;;;OAGG;IACH,wBAHW,SAAS,GAAG,cAAc,CAGb;IACxB;;;OAGG;IACH,yBAHU,MAAM,CAGE;IAClB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yC;0BAEtJ,qCAAqC;2CACE,wCAAwC;8BAF3E,4CAA4C;;;;sBA7Y/D,MAAM;;;;;;yBAlBS,4CAA4C;0CAiaL,wCAAwC;6CAH8B,yCAAyC;kCAAzC,yCAAyC"}
@@ -1 +1 @@
1
- {"version":3,"file":"page-controller.d.ts","sourceRoot":"","sources":["../../../../../../src/form/form-editor/preview/controller/page-controller.js"],"names":[],"mappings":"AAiBA;IA+KE;;;;;OAKG;IACH,4CAKC;IAlLD;;;;;OAKG;IACH,wBALW,YAAY,EAAE,YACd,oBAAoB,cACpB,cAAc,YACd,YAAY,EAkBtB;IAmCD;;OAEG;IACH,sBAFa,OAAO,CAgBnB;IAED;;;OAGG;IACH,qCAHW,gBAAgB,GACd,iBAAiB,CAgC7B;IAED;;OAEG;IACH,8BAFa,OAAO,CASnB;IAwBD,uCAQC;;CAyBF;0CA5MyC,mEAAmE;sCAiNxE,2CAA2C;uCAFY,yCAAyC;kCAIpG,2BAA2B;0CAJgC,yCAAyC;oCAGlG,qCAAqC;kCAHoB,yCAAyC"}
1
+ {"version":3,"file":"page-controller.d.ts","sourceRoot":"","sources":["../../../../../../src/form/form-editor/preview/controller/page-controller.js"],"names":[],"mappings":"AAiBA;IAgLE;;;;;OAKG;IACH,4CAKC;IAnLD;;;;;OAKG;IACH,wBALW,YAAY,EAAE,YACd,oBAAoB,cACpB,cAAc,YACd,YAAY,EAmBtB;IAmCD;;OAEG;IACH,sBAFa,OAAO,CAgBnB;IAED;;;OAGG;IACH,qCAHW,gBAAgB,GACd,iBAAiB,CAgC7B;IAED;;OAEG;IACH,8BAFa,OAAO,CASnB;IAwBD,uCAQC;;CAyBF;0CA7MyC,mEAAmE;sCAkNxE,2CAA2C;uCAFY,yCAAyC;kCAIpG,2BAA2B;0CAJgC,yCAAyC;oCAGlG,qCAAqC;kCAHoB,yCAAyC"}
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../../../src/form/form-editor/preview/helpers.js"],"names":[],"mappings":"AAqJA;;;;GAIG;AACH,gEAJW,gBAAgB,cAChB,cAAc,GACZ,CAAC,SAAS,EAAE,YAAY,KAAK,QAAQ,CAoCjD;sCAGsD,yCAAyC;oCAG7D,qCAAqC;kCACgO,2BAA2B;8BAHtS,4CAA4C"}
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../../../src/form/form-editor/preview/helpers.js"],"names":[],"mappings":"AA8JA;;;;GAIG;AACH,gEAJW,gBAAgB,cAChB,cAAc,GACZ,CAAC,SAAS,EAAE,YAAY,KAAK,QAAQ,CAoCjD;sCAGsD,yCAAyC;oCAG7D,qCAAqC;kCAC6P,2BAA2B;8BAHnU,4CAA4C"}
@@ -1,4 +1,141 @@
1
+ /**
2
+ * @constant
3
+ * @type {number}
4
+ * The default number of rows for a multiline text field.
5
+ */
6
+ export const MULTILINE_TEXT_QUESTION_DEFAULT_ROWS: number;
7
+ /**
8
+ * @implements {QuestionElements}
9
+ */
10
+ export class MultilineTextFieldComponentPreviewElements extends QuestionComponentElements implements QuestionElements {
11
+ /**
12
+ * @param {MultilineTextFieldComponent} component
13
+ */
14
+ constructor(component: MultilineTextFieldComponent);
15
+ _maxLength: number | undefined;
16
+ _rows: number | undefined;
17
+ /**
18
+ * @protected
19
+ * @returns {MultilineTextFieldSettings}
20
+ */
21
+ protected _getValues(): MultilineTextFieldSettings;
22
+ }
1
23
  export class LongAnswerQuestion extends Question {
24
+ /**
25
+ * @param {MultilineTextFieldElements} htmlElements
26
+ * @param {QuestionRenderer} questionRenderer
27
+ */
28
+ constructor(htmlElements: MultilineTextFieldElements, questionRenderer: QuestionRenderer);
29
+ _maxLength: number;
30
+ _rows: number;
31
+ /**
32
+ * @param {number} val
33
+ */
34
+ set maxLength(val: number);
35
+ get maxLength(): number;
36
+ /**
37
+ * @param {number} val
38
+ */
39
+ set rows(val: number);
40
+ get rows(): number;
41
+ /**
42
+ * @protected
43
+ */
44
+ protected _renderInput(): {
45
+ rows: number;
46
+ maxlength: number;
47
+ id?: string;
48
+ name?: string;
49
+ content?: string;
50
+ attributes?: Record<string, string>;
51
+ label?: import("../../../form/form-editor/preview/types.js").DefaultComponent;
52
+ hint?: import("../../../form/form-editor/preview/types.js").DefaultComponent;
53
+ fieldset?: import("../../../form/form-editor/preview/types.js").GovukFieldset;
54
+ items?: import("../types.js").ListItemReadonly[] | import("../types.js").DateItem[];
55
+ text?: string;
56
+ formGroup?: import("../macros/types.js").FormGroupAfterInput;
57
+ type?: "text" | "number" | "boolean";
58
+ classes?: string;
59
+ previewClasses?: string;
60
+ prefix?: {
61
+ text: string;
62
+ };
63
+ suffix?: {
64
+ text: string;
65
+ };
66
+ } | {
67
+ rows?: undefined;
68
+ maxlength: number;
69
+ id?: string;
70
+ name?: string;
71
+ content?: string;
72
+ attributes?: Record<string, string>;
73
+ label?: import("../../../form/form-editor/preview/types.js").DefaultComponent;
74
+ hint?: import("../../../form/form-editor/preview/types.js").DefaultComponent;
75
+ fieldset?: import("../../../form/form-editor/preview/types.js").GovukFieldset;
76
+ items?: import("../types.js").ListItemReadonly[] | import("../types.js").DateItem[];
77
+ text?: string;
78
+ formGroup?: import("../macros/types.js").FormGroupAfterInput;
79
+ type?: "text" | "number" | "boolean";
80
+ classes?: string;
81
+ previewClasses?: string;
82
+ prefix?: {
83
+ text: string;
84
+ };
85
+ suffix?: {
86
+ text: string;
87
+ };
88
+ } | {
89
+ rows: number;
90
+ maxlength?: undefined;
91
+ id?: string;
92
+ name?: string;
93
+ content?: string;
94
+ attributes?: Record<string, string>;
95
+ label?: import("../../../form/form-editor/preview/types.js").DefaultComponent;
96
+ hint?: import("../../../form/form-editor/preview/types.js").DefaultComponent;
97
+ fieldset?: import("../../../form/form-editor/preview/types.js").GovukFieldset;
98
+ items?: import("../types.js").ListItemReadonly[] | import("../types.js").DateItem[];
99
+ text?: string;
100
+ formGroup?: import("../macros/types.js").FormGroupAfterInput;
101
+ type?: "text" | "number" | "boolean";
102
+ classes?: string;
103
+ previewClasses?: string;
104
+ prefix?: {
105
+ text: string;
106
+ };
107
+ suffix?: {
108
+ text: string;
109
+ };
110
+ } | {
111
+ rows?: undefined;
112
+ maxlength?: undefined;
113
+ id?: string;
114
+ name?: string;
115
+ content?: string;
116
+ attributes?: Record<string, string>;
117
+ label?: import("../../../form/form-editor/preview/types.js").DefaultComponent;
118
+ hint?: import("../../../form/form-editor/preview/types.js").DefaultComponent;
119
+ fieldset?: import("../../../form/form-editor/preview/types.js").GovukFieldset;
120
+ items?: import("../types.js").ListItemReadonly[] | import("../types.js").DateItem[];
121
+ text?: string;
122
+ formGroup?: import("../macros/types.js").FormGroupAfterInput;
123
+ type?: "text" | "number" | "boolean";
124
+ classes?: string;
125
+ previewClasses?: string;
126
+ prefix?: {
127
+ text: string;
128
+ };
129
+ suffix?: {
130
+ text: string;
131
+ };
132
+ };
2
133
  }
134
+ import type { QuestionElements } from '../../../form/form-editor/preview/types.js';
135
+ import { QuestionComponentElements } from '../../../form/form-editor/preview/question.js';
136
+ import type { MultilineTextFieldSettings } from '../../../form/form-editor/preview/types.js';
137
+ import type { MultilineTextFieldComponent } from '../../../components/types.js';
3
138
  import { Question } from '../../../form/form-editor/preview/question.js';
139
+ import type { MultilineTextFieldElements } from '../../../form/form-editor/preview/types.js';
140
+ import type { QuestionRenderer } from '../../../form/form-editor/preview/types.js';
4
141
  //# sourceMappingURL=long-answer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"long-answer.d.ts","sourceRoot":"","sources":["../../../../../src/form/form-editor/preview/long-answer.js"],"names":[],"mappings":"AAIA;CAeC;yBAjBwB,4CAA4C"}
1
+ {"version":3,"file":"long-answer.d.ts","sourceRoot":"","sources":["../../../../../src/form/form-editor/preview/long-answer.js"],"names":[],"mappings":"AAOA;;;;GAIG;AACH,mDAHU,MAAM,CAGqC;AAErD;;GAEG;AACH;IACE;;OAEG;IACH,uBAFW,2BAA2B,EAMrC;IAFC,+BAAsC;IACtC,0BAAmC;IAGrC;;;OAGG;IACH,wBAFa,0BAA0B,CAQtC;CACF;AAED;IAgBE;;;OAGG;IACH,0BAHW,0BAA0B,oBAC1B,gBAAgB,EAM1B;IAFC,mBAA+C;IAC/C,cAAqC;IAOvC;;OAEG;IACH,mBAFW,MAAM,EAKhB;IAVD,iBAKW,MAAM,CAHhB;IAcD;;OAEG;IACH,cAFW,MAAM,EAKhB;IAVD,YAKW,MAAM,CAHhB;IAUD;;OAEG;IACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MASC;CACF;sCAG8G,yCAAyC;0CArGjJ,4CAA4C;gDAqG4D,yCAAyC;iDACxG,2BAA2B;yBAtGpE,4CAA4C;gDAqG4D,yCAAyC;sCAAzC,yCAAyC"}
@@ -67,6 +67,13 @@ export interface UkAddressElements extends DomElementsBase {
67
67
  export interface NumberElements extends DomElementsBase {
68
68
  readonly values: NumberSettings;
69
69
  }
70
+ export interface MultilineTextFieldSettings extends BaseSettings {
71
+ maxLength: number;
72
+ rows: number;
73
+ }
74
+ export interface MultilineTextFieldElements extends DomElementsBase {
75
+ readonly values: MultilineTextFieldSettings;
76
+ }
70
77
  export interface LocationSettings extends BaseSettings {
71
78
  instructionText: string;
72
79
  }
@@ -113,10 +120,15 @@ export interface PagePreviewBaseElements {
113
120
  heading: string;
114
121
  guidance: string;
115
122
  }
123
+ export interface PageSectionInfo {
124
+ title: string;
125
+ hideTitle: boolean;
126
+ }
116
127
  export interface PageOverviewElements extends PagePreviewBaseElements {
117
128
  addHeading: boolean;
118
129
  repeatQuestion: string | undefined;
119
130
  hasRepeater: boolean;
131
+ section?: PageSectionInfo;
120
132
  }
121
133
  export interface SectionForPreview {
122
134
  name: string;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/form/form-editor/preview/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,qBAAqB,EAC1B,KA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,WAAW,uBAAuB;IACtC,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED,MAAM,WAAW,oBAAqB,SAAQ,uBAAuB;IACnE,UAAU,EAAE,OAAO,CAAA;IACnB,cAAc,EAAE,MAAM,GAAG,SAAS,CAAA;IAClC,WAAW,EAAE,OAAO,CAAA;CACrB;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAA;CAC3B;AAED,MAAM,WAAW,mBAAoB,SAAQ,uBAAuB;IAClE,WAAW,EAAE,OAAO,CAAA;IACpB,qBAAqB,EAAE,OAAO,CAAA;IAC9B,gCAAgC,EAAE,OAAO,CAAA;IACzC,QAAQ,CAAC,EAAE,iBAAiB,EAAE,CAAA;IAC9B,eAAe,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAA;CACtC;AAED,MAAM,WAAW,uBAAuB;IACtC,qBAAqB,EAAE,OAAO,CAAA;IAC9B,eAAe,EAAE,MAAM,CAAA;IACvB,eAAe,EAAE,OAAO,CAAA;IACxB,gCAAgC,EAAE,OAAO,CAAA;IACzC,QAAQ,CAAC,EAAE,iBAAiB,EAAE,CAAA;IAC9B,eAAe,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAA;CACtC;AAED,MAAM,MAAM,eAAe,GACvB,iBAAiB,GACjB,oBAAoB,GACpB,oBAAoB,GACpB,kBAAkB,GAClB,mBAAmB,GACnB,QAAQ,GACR,qBAAqB,GACrB,sBAAsB,GACtB,mBAAmB,GACnB,iBAAiB,GACjB,oBAAoB,CAAA"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/form/form-editor/preview/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,qBAAqB,EAC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KAAE,EAAE,CAAA;CACtC;AAED,MAAM,MAAM,eAAe,GACvB,iBAAiB,GACjB,oBAAoB,GACpB,oBAAoB,GACpB,kBAAkB,GAClB,mBAAmB,GACnB,QAAQ,GACR,qBAAqB,GACrB,sBAAsB,GACtB,mBAAmB,GACnB,iBAAiB,GACjB,oBAAoB,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defra/forms-model",
3
- "version": "3.0.594",
3
+ "version": "3.0.596",
4
4
  "description": "A hapi plugin providing the model for Defra forms",
5
5
  "homepage": "https://github.com/DEFRA/forms-designer/tree/main/model#readme",
6
6
  "types": "dist/types/index.d.ts",
@@ -17,7 +17,7 @@ export class GuidancePageController extends PreviewPageControllerBase {
17
17
  _guidanceComponent = PreviewPageControllerBase.createGuidanceComponent(false)
18
18
 
19
19
  /**
20
- * @param {PagePreviewBaseElements} elements
20
+ * @param {PageOverviewElements} elements
21
21
  * @param {PageRenderer} renderer
22
22
  */
23
23
  constructor(elements, renderer) {
@@ -25,6 +25,7 @@ export class GuidancePageController extends PreviewPageControllerBase {
25
25
  if (elements.guidance.length) {
26
26
  this._guidanceComponent.content = elements.guidance
27
27
  }
28
+ this._section = elements.section
28
29
  }
29
30
 
30
31
  /**
@@ -60,5 +61,5 @@ export class GuidancePageController extends PreviewPageControllerBase {
60
61
 
61
62
  /**
62
63
  * @import { Markdown } from '~/src/form/form-editor/preview/markdown.js'
63
- * @import { PageRenderer, PagePreviewBaseElements } from '~/src/form/form-editor/preview/types.js'
64
+ * @import { PageRenderer, PageOverviewElements } from '~/src/form/form-editor/preview/types.js'
64
65
  */
@@ -39,13 +39,21 @@ export class PagePreviewElements {
39
39
  title: ''
40
40
  }
41
41
 
42
+ /**
43
+ * @type {PageSectionInfo | undefined}
44
+ * @protected
45
+ */
46
+ _section = undefined
47
+
42
48
  /**
43
49
  * @param {Page|undefined} page
50
+ * @param {PageSectionInfo} [section]
44
51
  */
45
- constructor(page) {
52
+ constructor(page, section) {
46
53
  if (page !== undefined) {
47
54
  this._page = page
48
55
  }
56
+ this._section = section
49
57
  }
50
58
 
51
59
  get heading() {
@@ -78,6 +86,10 @@ export class PagePreviewElements {
78
86
  get hasRepeater() {
79
87
  return hasRepeater(this._page)
80
88
  }
89
+
90
+ get section() {
91
+ return this._section
92
+ }
81
93
  }
82
94
 
83
95
  /**
@@ -142,6 +154,13 @@ export class PreviewPageControllerBase {
142
154
  */
143
155
  _isRepeater = false
144
156
 
157
+ /**
158
+ * Section info for the page
159
+ * @type {PageSectionInfo | undefined}
160
+ * @protected
161
+ */
162
+ _section = undefined
163
+
145
164
  /**
146
165
  * @param {PagePreviewBaseElements} elements
147
166
  * @param {PageRenderer} renderer
@@ -312,7 +331,10 @@ export class PreviewPageControllerBase {
312
331
  * @protected
313
332
  */
314
333
  _getSectionTitleText() {
315
- return this._sectionTitle
334
+ if (this._section && !this._section.hideTitle) {
335
+ return this._section.title
336
+ }
337
+ return undefined
316
338
  }
317
339
 
318
340
  /**
@@ -393,7 +415,7 @@ export class PreviewPageControllerBase {
393
415
  }
394
416
 
395
417
  /**
396
- * @import { PageRenderer, PageOverviewElements, PagePreviewBaseElements, QuestionRenderer, QuestionBaseModel } from '~/src/form/form-editor/preview/types.js'
418
+ * @import { PageRenderer, PageOverviewElements, PagePreviewBaseElements, PageSectionInfo, QuestionRenderer, QuestionBaseModel } from '~/src/form/form-editor/preview/types.js'
397
419
  * @import { Question } from '~/src/form/form-editor/preview/question.js'
398
420
  * @import { Page } from '~/src/form/form-definition/types.js'
399
421
  * @import { PagePreviewComponent, PagePreviewPanelMacro } from '~/src/form/form-editor/macros/types.js'
@@ -45,6 +45,7 @@ export class PreviewPageController extends PreviewPageControllerBase {
45
45
  this._showTitle = elements.addHeading
46
46
  this._sectionTitle = elements.repeatQuestion ?? ''
47
47
  this._isRepeater = elements.hasRepeater
48
+ this._section = elements.section
48
49
  }
49
50
 
50
51
  /**
@@ -187,7 +188,7 @@ export class PreviewPageController extends PreviewPageControllerBase {
187
188
  if (this._isRepeater) {
188
189
  return this.repeaterText
189
190
  }
190
- return undefined
191
+ return super._getSectionTitleText()
191
192
  }
192
193
 
193
194
  /**
@@ -29,7 +29,10 @@ import {
29
29
  ListQuestion,
30
30
  SelectComponentElements
31
31
  } from '~/src/form/form-editor/preview/list.js'
32
- import { LongAnswerQuestion } from '~/src/form/form-editor/preview/long-answer.js'
32
+ import {
33
+ LongAnswerQuestion,
34
+ MultilineTextFieldComponentPreviewElements
35
+ } from '~/src/form/form-editor/preview/long-answer.js'
33
36
  import { Markdown } from '~/src/form/form-editor/preview/markdown.js'
34
37
  import { MonthYearQuestion } from '~/src/form/form-editor/preview/month-year.js'
35
38
  import {
@@ -108,6 +111,12 @@ const ComponentToPreviewQuestion = {
108
111
  const list = findDefinitionListFromComponent(componentCoerced, definition)
109
112
  return new SelectComponentElements(componentCoerced, list)
110
113
  },
114
+ [ComponentType.MultilineTextField]: (component, _definition) => {
115
+ const componentCoerced = /** @type {MultilineTextFieldComponent} */ (
116
+ component
117
+ )
118
+ return new MultilineTextFieldComponentPreviewElements(componentCoerced)
119
+ },
111
120
  [ComponentType.UkAddressField]: (component, _definition) => {
112
121
  const componentCoerced = /** @type {UkAddressFieldComponent} */ (component)
113
122
  return new UkAddressComponentPreviewElements(componentCoerced)
@@ -193,5 +202,5 @@ export function mapComponentToPreviewQuestion(questionRenderer, definition) {
193
202
  * @import { Question } from '~/src/form/form-editor/preview/question.js'
194
203
  * @import { PreviewComponent } from '~/src/form/form-editor/preview/preview.js'
195
204
  * @import { FormDefinition } from '~/src/form/form-definition/types.js'
196
- * @import { AutocompleteFieldComponent, ComponentDef, DeclarationFieldComponent, EastingNorthingFieldComponent, LatLongFieldComponent, NationalGridFieldNumberFieldComponent, NumberFieldComponent, OsGridRefFieldComponent, SelectFieldComponent, UkAddressFieldComponent, YesNoFieldComponent } from '~/src/components/types.js'
205
+ * @import { AutocompleteFieldComponent, ComponentDef, DeclarationFieldComponent, EastingNorthingFieldComponent, LatLongFieldComponent, MultilineTextFieldComponent, NationalGridFieldNumberFieldComponent, NumberFieldComponent, OsGridRefFieldComponent, SelectFieldComponent, UkAddressFieldComponent, YesNoFieldComponent } from '~/src/components/types.js'
197
206
  */
@@ -1,6 +1,42 @@
1
1
  import { ComponentType } from '~/src/components/enums.js'
2
2
  import { PreviewComponent } from '~/src/form/form-editor/preview/preview.js'
3
- import { Question } from '~/src/form/form-editor/preview/question.js'
3
+ import {
4
+ Question,
5
+ QuestionComponentElements
6
+ } from '~/src/form/form-editor/preview/question.js'
7
+
8
+ /**
9
+ * @constant
10
+ * @type {number}
11
+ * The default number of rows for a multiline text field.
12
+ */
13
+ export const MULTILINE_TEXT_QUESTION_DEFAULT_ROWS = 5
14
+
15
+ /**
16
+ * @implements {QuestionElements}
17
+ */
18
+ export class MultilineTextFieldComponentPreviewElements extends QuestionComponentElements {
19
+ /**
20
+ * @param {MultilineTextFieldComponent} component
21
+ */
22
+ constructor(component) {
23
+ super(component)
24
+ this._maxLength = component.schema.max
25
+ this._rows = component.options.rows
26
+ }
27
+
28
+ /**
29
+ * @protected
30
+ * @returns {MultilineTextFieldSettings}
31
+ */
32
+ _getValues() {
33
+ return {
34
+ ...super._getValues(),
35
+ maxLength: this._maxLength ?? 0,
36
+ rows: this._rows ?? MULTILINE_TEXT_QUESTION_DEFAULT_ROWS
37
+ }
38
+ }
39
+ }
4
40
 
5
41
  export class LongAnswerQuestion extends Question {
6
42
  /**
@@ -17,4 +53,57 @@ export class LongAnswerQuestion extends Question {
17
53
  * @protected
18
54
  */
19
55
  _fieldName = 'longAnswerField'
56
+
57
+ /**
58
+ * @param {MultilineTextFieldElements} htmlElements
59
+ * @param {QuestionRenderer} questionRenderer
60
+ */
61
+ constructor(htmlElements, questionRenderer) {
62
+ super(htmlElements, questionRenderer)
63
+ this._maxLength = htmlElements.values.maxLength
64
+ this._rows = htmlElements.values.rows
65
+ }
66
+
67
+ get maxLength() {
68
+ return this._maxLength
69
+ }
70
+
71
+ /**
72
+ * @param {number} val
73
+ */
74
+ set maxLength(val) {
75
+ this._maxLength = val
76
+ this.render()
77
+ }
78
+
79
+ get rows() {
80
+ return this._rows
81
+ }
82
+
83
+ /**
84
+ * @param {number} val
85
+ */
86
+ set rows(val) {
87
+ this._rows = val
88
+ this.render()
89
+ }
90
+
91
+ /**
92
+ * @protected
93
+ */
94
+ _renderInput() {
95
+ const maxLengthObj =
96
+ this.maxLength && this.maxLength > 0 ? { maxlength: this.maxLength } : {}
97
+ const rowsObj = this.rows ? { rows: this.rows } : {}
98
+ return {
99
+ ...super._renderInput(),
100
+ ...maxLengthObj,
101
+ ...rowsObj
102
+ }
103
+ }
20
104
  }
105
+
106
+ /**
107
+ * @import { MultilineTextFieldSettings, MultilineTextFieldElements, QuestionElements, QuestionRenderer } from '~/src/form/form-editor/preview/types.js'
108
+ * @import { MultilineTextFieldComponent } from '~/src/components/types.js'
109
+ */
@@ -83,6 +83,15 @@ export interface NumberElements extends DomElementsBase {
83
83
  readonly values: NumberSettings
84
84
  }
85
85
 
86
+ export interface MultilineTextFieldSettings extends BaseSettings {
87
+ maxLength: number
88
+ rows: number
89
+ }
90
+
91
+ export interface MultilineTextFieldElements extends DomElementsBase {
92
+ readonly values: MultilineTextFieldSettings
93
+ }
94
+
86
95
  export interface LocationSettings extends BaseSettings {
87
96
  instructionText: string
88
97
  }
@@ -142,10 +151,16 @@ export interface PagePreviewBaseElements {
142
151
  guidance: string
143
152
  }
144
153
 
154
+ export interface PageSectionInfo {
155
+ title: string
156
+ hideTitle: boolean
157
+ }
158
+
145
159
  export interface PageOverviewElements extends PagePreviewBaseElements {
146
160
  addHeading: boolean
147
161
  repeatQuestion: string | undefined
148
162
  hasRepeater: boolean
163
+ section?: PageSectionInfo
149
164
  }
150
165
 
151
166
  export interface SectionForPreview {