@defra/forms-model 3.0.594 → 3.0.595
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.
- package/dist/module/form/form-editor/preview/controller/guidance-page-controller.js +3 -2
- package/dist/module/form/form-editor/preview/controller/guidance-page-controller.js.map +1 -1
- package/dist/module/form/form-editor/preview/controller/page-controller-base.js +24 -3
- package/dist/module/form/form-editor/preview/controller/page-controller-base.js.map +1 -1
- package/dist/module/form/form-editor/preview/controller/page-controller.js +2 -1
- package/dist/module/form/form-editor/preview/controller/page-controller.js.map +1 -1
- package/dist/module/form/form-editor/preview/types.js.map +1 -1
- package/dist/types/form/form-editor/preview/controller/guidance-page-controller.d.ts +7 -0
- package/dist/types/form/form-editor/preview/controller/guidance-page-controller.d.ts.map +1 -1
- package/dist/types/form/form-editor/preview/controller/page-controller-base.d.ts +15 -1
- package/dist/types/form/form-editor/preview/controller/page-controller-base.d.ts.map +1 -1
- package/dist/types/form/form-editor/preview/controller/page-controller.d.ts.map +1 -1
- package/dist/types/form/form-editor/preview/types.d.ts +5 -0
- package/dist/types/form/form-editor/preview/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/form/form-editor/preview/controller/guidance-page-controller.js +3 -2
- package/src/form/form-editor/preview/controller/page-controller-base.js +25 -3
- package/src/form/form-editor/preview/controller/page-controller.js +2 -1
- package/src/form/form-editor/preview/types.ts +6 -0
|
@@ -14,7 +14,7 @@ export class GuidancePageController extends PreviewPageControllerBase {
|
|
|
14
14
|
_guidanceComponent = PreviewPageControllerBase.createGuidanceComponent(false);
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
|
-
* @param {
|
|
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,
|
|
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 {
|
|
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
|
-
|
|
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,CAACC,MAAM,EAAE;MAC/D,OAAO,EAAE;IACX;IAEA,MAAM,CAACC,yBAAyB,CAAC,GAAG,IAAI,CAACT,KAAK,CAACO,UAAU;IAEzD,OAAOE,yBAAyB,CAACC,IAAI,KAAKzB,aAAa,CAACG,QAAQ,GAC5DqB,yBAAyB,CAACE,OAAO,GACjC,EAAE;EACR;EAEA,IAAIC,UAAUA,CAAA,EAAG;IACf,OAAO,IAAI,CAACZ,KAAK,CAACC,K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AACT,cAAc,CAAC3D,cAAc,CAACE,QAAQ,CAAC;EAC9C;;EAEA;AACF;AACA;EACEyD,cAAcA,CAACW,gBAAgB,EAAE;IAC/B,IAAI,CAAC1C,YAAY,GAAG0C,gBAAgB;IACpC,IAAI,CAACzE,MAAM,CAAC,CAAC;EACf;EAEA0E,cAAcA,CAAA,EAAG;IACf,IAAI,CAAC3C,YAAY,GAAGnB,SAAS;IAE7B,IAAI,CAACwB,kBAAkB,CAACuC,kBAAkB,CAAC,CAAC;IAC5C,IAAI,CAAC3E,MAAM,CAAC,CAAC;EACf;;EAEA;AACF;AACA;AACA;AACA;EACEqD,cAAcA,CAACuB,KAAK,EAAE;IACpB,OAAO,IAAI,CAAC7C,YAAY,KAAK6C,KAAK,GAAGlF,eAAe,GAAG,EAAE;EAC3D;;EAEA;AACF;AACA;EACEmF,iBAAiBA,CAACC,UAAU,EAAE;IAC5B,MAAMC,QAAQ,GAAG,IAAI,CAACpD,WAAW,CAACqD,IAAI,CAAEC,IAAI,IAAKA,IAAI,CAACC,EAAE,KAAKJ,UAAU,CAAC;IACxE,IAAIC,QAAQ,EAAE;MACZ,IAAI,CAACpD,WAAW,CACbwD,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,CAACvE,MAAM,CAAC,CAAC;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;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":[]}
|
|
@@ -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
|
|
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,CAACC,WAAW,GAAGhB,QAAQ,CAACiB,WAAW;EACzC;;EAEA;AACF;AACA;EACE,OAAOC,cAAc,GAAG9B,yBAAyB,CAAC8B,cAAc;;EAEhE;AACF;AACA;AACA;AACA;EACE,CAACP,mBAAmBQ,CAAC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AM,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,CAACC,aAAa,GAAGd,QAAQ,CAACe,cAAc,IAAI,EAAE;IAClD,IAAI,CAACC,WAAW,GAAGhB,QAAQ,CAACiB,WAAW;IACvC,IAAI,CAACC,QAAQ,GAAGlB,QAAQ,CAACmB,OAAO;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,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":[]}
|
|
@@ -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 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;
|
|
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;
|
|
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;;;OAGG;IACH,yBAHW,MAAM,CAGC;IAClB;;;OAGG;IACH,0BAHU,QAAQ,CAGkD;IACpE;;;OAGG;IACH,8BAHU,QAAQ,CAGsD;IACxE;;;OAGG;IACH,uBAFU,OAAO,CAEE;IAEnB;;;;OAIG;IACH,oBAHU,eAAe,GAAG,SAAS,CAGjB;IAiBpB;;;OAGG;IACH,oCAHa,Q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or/preview/controller/page-controller.js"],"names":[],"mappings":"AAiBA;
|
|
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"}
|
|
@@ -113,10 +113,15 @@ export interface PagePreviewBaseElements {
|
|
|
113
113
|
heading: string;
|
|
114
114
|
guidance: string;
|
|
115
115
|
}
|
|
116
|
+
export interface PageSectionInfo {
|
|
117
|
+
title: string;
|
|
118
|
+
hideTitle: boolean;
|
|
119
|
+
}
|
|
116
120
|
export interface PageOverviewElements extends PagePreviewBaseElements {
|
|
117
121
|
addHeading: boolean;
|
|
118
122
|
repeatQuestion: string | undefined;
|
|
119
123
|
hasRepeater: boolean;
|
|
124
|
+
section?: PageSectionInfo;
|
|
120
125
|
}
|
|
121
126
|
export interface SectionForPreview {
|
|
122
127
|
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,KAAK,iBAAiB,EACvB,MAAM,wCAAwC,CAAA;AAC/C,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,gDAAgD,CAAA;AAC1F,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,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AM,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"}
|
package/package.json
CHANGED
|
@@ -17,7 +17,7 @@ export class GuidancePageController extends PreviewPageControllerBase {
|
|
|
17
17
|
_guidanceComponent = PreviewPageControllerBase.createGuidanceComponent(false)
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
|
-
* @param {
|
|
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,
|
|
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
|
-
|
|
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
|
|
191
|
+
return super._getSectionTitleText()
|
|
191
192
|
}
|
|
192
193
|
|
|
193
194
|
/**
|
|
@@ -142,10 +142,16 @@ export interface PagePreviewBaseElements {
|
|
|
142
142
|
guidance: string
|
|
143
143
|
}
|
|
144
144
|
|
|
145
|
+
export interface PageSectionInfo {
|
|
146
|
+
title: string
|
|
147
|
+
hideTitle: boolean
|
|
148
|
+
}
|
|
149
|
+
|
|
145
150
|
export interface PageOverviewElements extends PagePreviewBaseElements {
|
|
146
151
|
addHeading: boolean
|
|
147
152
|
repeatQuestion: string | undefined
|
|
148
153
|
hasRepeater: boolean
|
|
154
|
+
section?: PageSectionInfo
|
|
149
155
|
}
|
|
150
156
|
|
|
151
157
|
export interface SectionForPreview {
|