@defra/forms-model 3.0.552 → 3.0.553
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/page-controller.js +2 -2
- package/dist/module/form/form-editor/preview/controller/page-controller.js.map +1 -1
- package/dist/module/form/form-editor/preview/preview.js +5 -4
- package/dist/module/form/form-editor/preview/preview.js.map +1 -1
- package/dist/types/form/form-editor/preview/preview.d.ts +5 -5
- package/dist/types/form/form-editor/preview/preview.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/form/form-editor/preview/controller/page-controller.js +2 -2
- package/src/form/form-editor/preview/preview.js +6 -4
@@ -77,7 +77,7 @@ export class PreviewPageController extends PreviewPageControllerBase {
|
|
77
77
|
return false;
|
78
78
|
}
|
79
79
|
// |_ one component and title not highlighted
|
80
|
-
if (this._title.trim() === this._components[0]?.question
|
80
|
+
if (this._title.trim() === this._components[0]?.question?.trim()) {
|
81
81
|
return true;
|
82
82
|
}
|
83
83
|
// titles not the same
|
@@ -116,7 +116,7 @@ export class PreviewPageController extends PreviewPageControllerBase {
|
|
116
116
|
* @returns {boolean}
|
117
117
|
*/
|
118
118
|
get titleAndFirstTitleSame() {
|
119
|
-
return this._components.length > 0 && this._title.trim() === this._components[0]?.question
|
119
|
+
return this._components.length > 0 && this._title.trim() === this._components[0]?.question?.trim() && this.components.length === 1 && this._highlighted !== 'title';
|
120
120
|
}
|
121
121
|
|
122
122
|
/**
|
@@ -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","repeaterButton","repeaterButtonText","_isHighlighted","REPEATER","text","firstToken","rest","restOfStr","join","toLowerCase","guidanceComponent","createGuidanceComponent"],"sources":["../../../../../../src/form/form-editor/preview/controller/page-controller.js"],"sourcesContent":["import { PreviewPageControllerBase } from '~/src/form/form-editor/preview/controller/page-controller-base.js'\nimport { mapComponentToPreviewQuestion } from '~/src/form/form-editor/preview/helpers.js'\nimport { Markdown } from '~/src/form/form-editor/preview/markdown.js'\n\n/**\n * @type {QuestionRenderer}\n */\nconst questionRenderer = {\n /**\n * @param {string} _questionTemplate\n * @param {QuestionBaseModel} _questionBaseModel\n */\n render(_questionTemplate, _questionBaseModel) {\n //\n }\n}\n\nexport class PreviewPageController extends PreviewPageControllerBase {\n static PATH = PreviewPageControllerBase.PATH\n /**\n * @protected\n * @type {Question[]}\n */\n _components = []\n\n /**\n * @param {ComponentDef[]} components\n * @param {PageOverviewElements} elements\n * @param {FormDefinition} definition\n * @param {PageRenderer} renderer\n */\n constructor(components, elements, definition, renderer) {\n super(elements, renderer)\n const questions = components.map(\n mapComponentToPreviewQuestion(questionRenderer, definition)\n )\n const firstQuestion = /** @type { Markdown | undefined | Question } */ (\n questions.shift()\n )\n this._guidanceComponent =\n PreviewPageController.getOrCreateGuidanceComponent(firstQuestion)\n this._guidanceText = elements.guidance\n this._components = this.#constructComponents(firstQuestion, questions)\n this._showTitle = elements.addHeading\n this._sectionTitle = elements.repeatQuestion ?? ''\n this._isRepeater = elements.hasRepeater\n }\n\n /**\n * @type {typeof PreviewPageControllerBase.HighlightClass}\n */\n static HighlightClass = PreviewPageControllerBase.HighlightClass\n\n /**\n * @param { Question | Markdown | undefined} firstQuestion\n * @param {Question[]} questions\n * @returns {Question[]}\n */\n #constructComponents(firstQuestion, questions) {\n return firstQuestion instanceof Markdown || firstQuestion === undefined\n ? questions\n : [firstQuestion, ...questions]\n }\n\n /**\n * @returns {PagePreviewComponent[]}\n */\n get components() {\n const componentsWithGuidance = /** @type {Question[]} */ ([\n ...this._guidanceComponents,\n ...this._components\n ])\n\n return componentsWithGuidance.map((component) => {\n return {\n model: this._overrideComponentHeading(component),\n questionType: component.componentType\n }\n })\n }\n\n /**\n * @returns {boolean}\n */\n get showLargeTitle() {\n const componentsLength =\n this._components.length + this._guidanceComponents.length\n\n if (componentsLength > 1 || this._highlighted === 'title') {\n return false\n }\n // |_ one component and title not highlighted\n if (this._title.trim() === this._components[0]?.question.trim()) {\n return true\n }\n // titles not the same\n\n return !this._showTitle // add page heading deselected?\n }\n\n /**\n * @param {PreviewComponent} component\n * @returns {QuestionBaseModel}\n */\n _overrideComponentHeading(component) {\n const largeTitle = this.showLargeTitle\n\n const fieldset = component.renderInput.fieldset\n ? {\n fieldset: {\n legend: {\n ...component.renderInput.fieldset.legend,\n classes: largeTitle\n ? 'govuk-fieldset__legend--l'\n : 'govuk-fieldset__legend--m'\n }\n }\n }\n : {}\n\n const label = component.renderInput.label\n ? {\n label: {\n ...component.renderInput.label,\n classes: largeTitle ? 'govuk-label--l' : 'govuk-label--m'\n }\n }\n : {}\n\n return {\n ...component.renderInput,\n ...fieldset,\n ...label\n }\n }\n\n /**\n * @returns {boolean}\n */\n get titleAndFirstTitleSame() {\n return (\n this._components.length > 0 &&\n this._title.trim() === this._components[0]?.question.trim() &&\n this.components.length === 1 &&\n this._highlighted !== 'title'\n )\n }\n\n /**\n * @returns {string}\n * @protected\n */\n _getTitle() {\n if (!this._showTitle || this.titleAndFirstTitleSame) {\n return ''\n }\n return super._getTitle()\n }\n\n /**\n * @returns {string}\n * @protected\n */\n _getGuidanceText() {\n if (!this._showTitle) {\n return ''\n }\n return super._getGuidanceText()\n }\n\n get repeaterText() {\n if (!this._isRepeater) {\n return undefined\n }\n if (!this._sectionTitle.length) {\n return 'Question set name'\n }\n return this._sectionTitle + ' 1'\n }\n\n /**\n * @returns {string|undefined}\n * @protected\n */\n _getSectionTitleText() {\n if (this._isRepeater) {\n return this.repeaterText\n }\n return undefined\n }\n\n get repeaterButton() {\n if (this.repeaterButtonText === undefined) {\n return undefined\n }\n return {\n classes: this._isHighlighted(\n PreviewPageControllerBase.HighlightClass.REPEATER\n ),\n text: this.repeaterButtonText\n }\n }\n\n get repeaterButtonText() {\n if (!this._isRepeater) {\n return undefined\n }\n\n if (this._sectionTitle === '') {\n return '[question set name]'\n }\n\n const [firstToken, ...rest] = this._sectionTitle\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n const restOfStr = rest ? rest.join('') : ''\n return firstToken.toLowerCase() + restOfStr\n }\n\n /**\n * Helper method to return the guidance or a new one\n * @param { Markdown | Question | undefined } guidanceComponent\n * @returns {Markdown}\n * @private\n */\n static getOrCreateGuidanceComponent(guidanceComponent) {\n if (guidanceComponent instanceof Markdown) {\n return guidanceComponent\n }\n return PreviewPageControllerBase.createGuidanceComponent()\n }\n}\n\n/**\n * @import { PageRenderer, PageOverviewElements, QuestionRenderer, QuestionBaseModel } from '~/src/form/form-editor/preview/types.js'\n * @import { Question } from '~/src/form/form-editor/preview/question.js'\n * @import { PreviewComponent } from '~/src/form/form-editor/preview/preview.js'\n * @import { FormDefinition } 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,IA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OAAO;MACLmB,OAAO,EAAE,IAAI,CAACS,cAAc,CAC1B5D,yBAAyB,CAAC8B,cAAc,CAAC+B,QAC3C,CAAC;MACDC,IAAI,EAAE,IAAI,CAACH;IACb,CAAC;EACH;EAEA,IAAIA,kBAAkBA,CAAA,EAAG;IACvB,IAAI,CAAC,IAAI,CAAC/B,WAAW,EAAE;MACrB,OAAOI,SAAS;IAClB;IAEA,IAAI,IAAI,CAACN,aAAa,KAAK,EAAE,EAAE;MAC7B,OAAO,qBAAqB;IAC9B;IAEA,MAAM,CAACqC,UAAU,EAAE,GAAGC,IAAI,CAAC,GAAG,IAAI,CAACtC,aAAa;IAChD;IACA,MAAMuC,SAAS,GAAGD,IAAI,GAAGA,IAAI,CAACE,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE;IAC3C,OAAOH,UAAU,CAACI,WAAW,CAAC,CAAC,GAAGF,SAAS;EAC7C;;EAEA;AACF;AACA;AACA;AACA;AACA;EACE,OAAO7C,4BAA4BA,CAACgD,iBAAiB,EAAE;IACrD,IAAIA,iBAAiB,YAAYlE,QAAQ,EAAE;MACzC,OAAOkE,iBAAiB;IAC1B;IACA,OAAOpE,yBAAyB,CAACqE,uBAAuB,CAAC,CAAC;EAC5D;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
|
1
|
+
{"version":3,"file":"page-controller.js","names":["PreviewPageControllerBase","mapComponentToPreviewQuestion","Markdown","questionRenderer","render","_questionTemplate","_questionBaseModel","PreviewPageController","PATH","_components","constructor","components","elements","definition","renderer","questions","map","firstQuestion","shift","_guidanceComponent","getOrCreateGuidanceComponent","_guidanceText","guidance","constructComponents","_showTitle","addHeading","_sectionTitle","repeatQuestion","_isRepeater","hasRepeater","HighlightClass","#constructComponents","undefined","componentsWithGuidance","_guidanceComponents","component","model","_overrideComponentHeading","questionType","componentType","showLargeTitle","componentsLength","length","_highlighted","_title","trim","question","largeTitle","fieldset","renderInput","legend","classes","label","titleAndFirstTitleSame","_getTitle","_getGuidanceText","repeaterText","_getSectionTitleText","repeaterButton","repeaterButtonText","_isHighlighted","REPEATER","text","firstToken","rest","restOfStr","join","toLowerCase","guidanceComponent","createGuidanceComponent"],"sources":["../../../../../../src/form/form-editor/preview/controller/page-controller.js"],"sourcesContent":["import { PreviewPageControllerBase } from '~/src/form/form-editor/preview/controller/page-controller-base.js'\nimport { mapComponentToPreviewQuestion } from '~/src/form/form-editor/preview/helpers.js'\nimport { Markdown } from '~/src/form/form-editor/preview/markdown.js'\n\n/**\n * @type {QuestionRenderer}\n */\nconst questionRenderer = {\n /**\n * @param {string} _questionTemplate\n * @param {QuestionBaseModel} _questionBaseModel\n */\n render(_questionTemplate, _questionBaseModel) {\n //\n }\n}\n\nexport class PreviewPageController extends PreviewPageControllerBase {\n static PATH = PreviewPageControllerBase.PATH\n /**\n * @protected\n * @type {Question[]}\n */\n _components = []\n\n /**\n * @param {ComponentDef[]} components\n * @param {PageOverviewElements} elements\n * @param {FormDefinition} definition\n * @param {PageRenderer} renderer\n */\n constructor(components, elements, definition, renderer) {\n super(elements, renderer)\n const questions = components.map(\n mapComponentToPreviewQuestion(questionRenderer, definition)\n )\n const firstQuestion = /** @type { Markdown | undefined | Question } */ (\n questions.shift()\n )\n this._guidanceComponent =\n PreviewPageController.getOrCreateGuidanceComponent(firstQuestion)\n this._guidanceText = elements.guidance\n this._components = this.#constructComponents(firstQuestion, questions)\n this._showTitle = elements.addHeading\n this._sectionTitle = elements.repeatQuestion ?? ''\n this._isRepeater = elements.hasRepeater\n }\n\n /**\n * @type {typeof PreviewPageControllerBase.HighlightClass}\n */\n static HighlightClass = PreviewPageControllerBase.HighlightClass\n\n /**\n * @param { Question | Markdown | undefined} firstQuestion\n * @param {Question[]} questions\n * @returns {Question[]}\n */\n #constructComponents(firstQuestion, questions) {\n return firstQuestion instanceof Markdown || firstQuestion === undefined\n ? questions\n : [firstQuestion, ...questions]\n }\n\n /**\n * @returns {PagePreviewComponent[]}\n */\n get components() {\n const componentsWithGuidance = /** @type {Question[]} */ ([\n ...this._guidanceComponents,\n ...this._components\n ])\n\n return componentsWithGuidance.map((component) => {\n return {\n model: this._overrideComponentHeading(component),\n questionType: component.componentType\n }\n })\n }\n\n /**\n * @returns {boolean}\n */\n get showLargeTitle() {\n const componentsLength =\n this._components.length + this._guidanceComponents.length\n\n if (componentsLength > 1 || this._highlighted === 'title') {\n return false\n }\n // |_ one component and title not highlighted\n if (this._title.trim() === this._components[0]?.question?.trim()) {\n return true\n }\n // titles not the same\n\n return !this._showTitle // add page heading deselected?\n }\n\n /**\n * @param {PreviewComponent} component\n * @returns {QuestionBaseModel}\n */\n _overrideComponentHeading(component) {\n const largeTitle = this.showLargeTitle\n\n const fieldset = component.renderInput.fieldset\n ? {\n fieldset: {\n legend: {\n ...component.renderInput.fieldset.legend,\n classes: largeTitle\n ? 'govuk-fieldset__legend--l'\n : 'govuk-fieldset__legend--m'\n }\n }\n }\n : {}\n\n const label = component.renderInput.label\n ? {\n label: {\n ...component.renderInput.label,\n classes: largeTitle ? 'govuk-label--l' : 'govuk-label--m'\n }\n }\n : {}\n\n return {\n ...component.renderInput,\n ...fieldset,\n ...label\n }\n }\n\n /**\n * @returns {boolean}\n */\n get titleAndFirstTitleSame() {\n return (\n this._components.length > 0 &&\n this._title.trim() === this._components[0]?.question?.trim() &&\n this.components.length === 1 &&\n this._highlighted !== 'title'\n )\n }\n\n /**\n * @returns {string}\n * @protected\n */\n _getTitle() {\n if (!this._showTitle || this.titleAndFirstTitleSame) {\n return ''\n }\n return super._getTitle()\n }\n\n /**\n * @returns {string}\n * @protected\n */\n _getGuidanceText() {\n if (!this._showTitle) {\n return ''\n }\n return super._getGuidanceText()\n }\n\n get repeaterText() {\n if (!this._isRepeater) {\n return undefined\n }\n if (!this._sectionTitle.length) {\n return 'Question set name'\n }\n return this._sectionTitle + ' 1'\n }\n\n /**\n * @returns {string|undefined}\n * @protected\n */\n _getSectionTitleText() {\n if (this._isRepeater) {\n return this.repeaterText\n }\n return undefined\n }\n\n get repeaterButton() {\n if (this.repeaterButtonText === undefined) {\n return undefined\n }\n return {\n classes: this._isHighlighted(\n PreviewPageControllerBase.HighlightClass.REPEATER\n ),\n text: this.repeaterButtonText\n }\n }\n\n get repeaterButtonText() {\n if (!this._isRepeater) {\n return undefined\n }\n\n if (this._sectionTitle === '') {\n return '[question set name]'\n }\n\n const [firstToken, ...rest] = this._sectionTitle\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n const restOfStr = rest ? rest.join('') : ''\n return firstToken.toLowerCase() + restOfStr\n }\n\n /**\n * Helper method to return the guidance or a new one\n * @param { Markdown | Question | undefined } guidanceComponent\n * @returns {Markdown}\n * @private\n */\n static getOrCreateGuidanceComponent(guidanceComponent) {\n if (guidanceComponent instanceof Markdown) {\n return guidanceComponent\n }\n return PreviewPageControllerBase.createGuidanceComponent()\n }\n}\n\n/**\n * @import { PageRenderer, PageOverviewElements, QuestionRenderer, QuestionBaseModel } from '~/src/form/form-editor/preview/types.js'\n * @import { Question } from '~/src/form/form-editor/preview/question.js'\n * @import { PreviewComponent } from '~/src/form/form-editor/preview/preview.js'\n * @import { FormDefinition } 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,EAAE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E,IAAI,CAACH;IACb,CAAC;EACH;EAEA,IAAIA,kBAAkBA,CAAA,EAAG;IACvB,IAAI,CAAC,IAAI,CAAC/B,WAAW,EAAE;MACrB,OAAOI,SAAS;IAClB;IAEA,IAAI,IAAI,CAACN,aAAa,KAAK,EAAE,EAAE;MAC7B,OAAO,qBAAqB;IAC9B;IAEA,MAAM,CAACqC,UAAU,EAAE,GAAGC,IAAI,CAAC,GAAG,IAAI,CAACtC,aAAa;IAChD;IACA,MAAMuC,SAAS,GAAGD,IAAI,GAAGA,IAAI,CAACE,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE;IAC3C,OAAOH,UAAU,CAACI,WAAW,CAAC,CAAC,GAAGF,SAAS;EAC7C;;EAEA;AACF;AACA;AACA;AACA;AACA;EACE,OAAO7C,4BAA4BA,CAACgD,iBAAiB,EAAE;IACrD,IAAIA,iBAAiB,YAAYlE,QAAQ,EAAE;MACzC,OAAOkE,iBAAiB;IAC1B;IACA,OAAOpE,yBAAyB,CAACqE,uBAAuB,CAAC,CAAC;EAC5D;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
|
@@ -69,7 +69,7 @@ export class PreviewComponent {
|
|
69
69
|
*/
|
70
70
|
this._htmlElements = htmlElements;
|
71
71
|
/**
|
72
|
-
* @type {string}
|
72
|
+
* @type {string | undefined}
|
73
73
|
* @private
|
74
74
|
*/
|
75
75
|
this._question = question;
|
@@ -96,7 +96,8 @@ export class PreviewComponent {
|
|
96
96
|
}
|
97
97
|
get titleText() {
|
98
98
|
const optionalText = this._optional ? ' (optional)' : '';
|
99
|
-
|
99
|
+
const questionText = this._question === '' || !this._question ? 'Question' : this._question;
|
100
|
+
return questionText + optionalText;
|
100
101
|
}
|
101
102
|
|
102
103
|
/**
|
@@ -157,14 +158,14 @@ export class PreviewComponent {
|
|
157
158
|
}
|
158
159
|
|
159
160
|
/**
|
160
|
-
* @type {string}
|
161
|
+
* @type {string | undefined}
|
161
162
|
*/
|
162
163
|
get question() {
|
163
164
|
return this._question;
|
164
165
|
}
|
165
166
|
|
166
167
|
/**
|
167
|
-
* @param {string} value
|
168
|
+
* @param {string | undefined} value
|
168
169
|
*/
|
169
170
|
set question(value) {
|
170
171
|
this._question = value;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"preview.js","names":["ComponentType","HIGHLIGHT_CLASS","PreviewComponent","PATH","_id","undefined","componentType","Details","_questionTemplate","_highlight","_fieldName","_questionRenderer","_htmlElements","_highlighted","constructor","htmlElements","questionRenderer","question","optional","values","_question","_optional","getHighlight","element","titleText","optionalText","label","text","classes","fieldSet","legend","customRenderFields","_renderInput","id","name","renderInput","render","value","highlight","highlightContent","unHighlightContent"],"sources":["../../../../../src/form/form-editor/preview/preview.js"],"sourcesContent":["import { ComponentType } from '~/src/components/enums.js'\nimport { HIGHLIGHT_CLASS } from '~/src/form/form-editor/preview/constants.js'\n\n/**\n * @abstract\n */\nexport class PreviewComponent {\n static PATH = 'preview-components/'\n /**\n * @type { string | undefined }\n */\n _id = undefined\n /**\n * @abstract\n * @type {ComponentType}\n */\n componentType = ComponentType.Details\n /**\n * @abstract\n * @type {string}\n * @protected\n */\n _questionTemplate = ''\n /**\n * @type { string|null }\n * @protected\n */\n _highlight = null\n /**\n * @abstract\n * @type {string}\n * @protected\n */\n _fieldName = ''\n /**\n * @type {QuestionRenderer}\n * @protected\n */\n _questionRenderer\n\n /**\n * @type {QuestionElements}\n * @protected\n */\n _htmlElements\n /**\n * @type {boolean}\n * @protected\n */\n _highlighted = false\n /**\n * @type {boolean}\n * @protected\n */\n\n /**\n * @param {QuestionElements} htmlElements\n * @param {QuestionRenderer} questionRenderer\n */\n constructor(htmlElements, questionRenderer) {\n const { question, optional } = htmlElements.values\n\n /**\n * @type {QuestionElements}\n * @protected\n */\n this._htmlElements = htmlElements\n /**\n * @type {string}\n * @private\n */\n this._question = question\n /**\n * @type {boolean}\n * @private\n */\n this._optional = optional\n /**\n *\n * @type {QuestionRenderer}\n * @protected\n */\n this._questionRenderer = questionRenderer\n }\n\n /**\n * @param {string} element\n * @returns {string}\n * @protected\n */\n getHighlight(element) {\n return this._highlight === element ? ' highlight' : ''\n }\n\n get titleText() {\n const optionalText = this._optional ? ' (optional)' : ''\n
|
1
|
+
{"version":3,"file":"preview.js","names":["ComponentType","HIGHLIGHT_CLASS","PreviewComponent","PATH","_id","undefined","componentType","Details","_questionTemplate","_highlight","_fieldName","_questionRenderer","_htmlElements","_highlighted","constructor","htmlElements","questionRenderer","question","optional","values","_question","_optional","getHighlight","element","titleText","optionalText","questionText","label","text","classes","fieldSet","legend","customRenderFields","_renderInput","id","name","renderInput","render","value","highlight","highlightContent","unHighlightContent"],"sources":["../../../../../src/form/form-editor/preview/preview.js"],"sourcesContent":["import { ComponentType } from '~/src/components/enums.js'\nimport { HIGHLIGHT_CLASS } from '~/src/form/form-editor/preview/constants.js'\n\n/**\n * @abstract\n */\nexport class PreviewComponent {\n static PATH = 'preview-components/'\n /**\n * @type { string | undefined }\n */\n _id = undefined\n /**\n * @abstract\n * @type {ComponentType}\n */\n componentType = ComponentType.Details\n /**\n * @abstract\n * @type {string}\n * @protected\n */\n _questionTemplate = ''\n /**\n * @type { string|null }\n * @protected\n */\n _highlight = null\n /**\n * @abstract\n * @type {string}\n * @protected\n */\n _fieldName = ''\n /**\n * @type {QuestionRenderer}\n * @protected\n */\n _questionRenderer\n\n /**\n * @type {QuestionElements}\n * @protected\n */\n _htmlElements\n /**\n * @type {boolean}\n * @protected\n */\n _highlighted = false\n /**\n * @type {boolean}\n * @protected\n */\n\n /**\n * @param {QuestionElements} htmlElements\n * @param {QuestionRenderer} questionRenderer\n */\n constructor(htmlElements, questionRenderer) {\n const { question, optional } = htmlElements.values\n\n /**\n * @type {QuestionElements}\n * @protected\n */\n this._htmlElements = htmlElements\n /**\n * @type {string | undefined}\n * @private\n */\n this._question = question\n /**\n * @type {boolean}\n * @private\n */\n this._optional = optional\n /**\n *\n * @type {QuestionRenderer}\n * @protected\n */\n this._questionRenderer = questionRenderer\n }\n\n /**\n * @param {string} element\n * @returns {string}\n * @protected\n */\n getHighlight(element) {\n return this._highlight === element ? ' highlight' : ''\n }\n\n get titleText() {\n const optionalText = this._optional ? ' (optional)' : ''\n const questionText =\n this._question === '' || !this._question ? 'Question' : this._question\n return questionText + optionalText\n }\n\n /**\n * @protected\n * @type {DefaultComponent}\n */\n get label() {\n return {\n text: this.titleText,\n classes: 'govuk-label--l' + this.getHighlight('question')\n }\n }\n\n /**\n * @protected\n * @type {GovukFieldset}\n */\n get fieldSet() {\n return {\n legend: {\n text: this.titleText,\n classes: 'govuk-fieldset__legend--l' + this.getHighlight('question')\n }\n }\n }\n\n /**\n * @returns {Partial<QuestionBaseModel>}\n */\n get customRenderFields() {\n return {}\n }\n\n /**\n *\n * @returns {QuestionBaseModel}\n * @protected\n */\n _renderInput() {\n return {\n id: this._fieldName,\n name: this._fieldName,\n classes: this._highlighted ? HIGHLIGHT_CLASS : ''\n }\n }\n\n /**\n * @type {QuestionBaseModel}\n */\n get renderInput() {\n return {\n ...this._renderInput(),\n ...this.customRenderFields\n }\n }\n\n render() {\n this._questionRenderer.render(this._questionTemplate, this.renderInput)\n }\n\n /**\n * @type {string | undefined}\n */\n get question() {\n return this._question\n }\n\n /**\n * @param {string | undefined} value\n */\n set question(value) {\n this._question = value\n this.render()\n }\n\n get optional() {\n return this._optional\n }\n\n /**\n * @param {boolean} value\n */\n set optional(value) {\n this._optional = value\n this.render()\n }\n\n /**\n * @type {string | null}\n */\n get highlight() {\n return this._highlight\n }\n\n /**\n * @param {string | null} value\n */\n set highlight(value) {\n this._highlight = value\n this.render()\n }\n\n /**\n * @type { string | undefined }\n */\n get id() {\n return this._id\n }\n\n /**\n * @param { string | undefined } value\n */\n set id(value) {\n this._id = value\n }\n\n /**\n * no render\n */\n highlightContent() {\n this._highlighted = true\n }\n\n /**\n * no render\n */\n unHighlightContent() {\n this._highlighted = false\n }\n}\n\n/**\n * @import { QuestionElements, QuestionBaseModel, GovukFieldset, DefaultComponent, QuestionRenderer } from '~/src/form/form-editor/preview/types.js'\n */\n"],"mappings":"AAAA,SAASA,aAAa;AACtB,SAASC,eAAe;;AAExB;AACA;AACA;AACA,OAAO,MAAMC,gBAAgB,CAAC;EAC5B,OAAOC,IAAI,GAAG,qBAAqB;EACnC;AACF;AACA;EACEC,GAAG,GAAGC,SAAS;EACf;AACF;AACA;AACA;EACEC,aAAa,GAAGN,aAAa,CAACO,OAAO;EACrC;AACF;AACA;AACA;AACA;EACEC,iBAAiB,GAAG,EAAE;EACtB;AACF;AACA;AACA;EACEC,UAAU,GAAG,IAAI;EACjB;AACF;AACA;AACA;AACA;EACEC,UAAU,GAAG,EAAE;EACf;AACF;AACA;AACA;EACEC,iBAAiB;;EAEjB;AACF;AACA;AACA;EACEC,aAAa;EACb;AACF;AACA;AACA;EACEC,YAAY,GAAG,KAAK;EACpB;AACF;AACA;AACA;;EAEE;AACF;AACA;AACA;EACEC,WAAWA,CAACC,YAAY,EAAEC,gBAAgB,EAAE;IAC1C,MAAM;MAAEC,QAAQ;MAAEC;IAAS,CAAC,GAAGH,YAAY,CAACI,MAAM;;IAElD;AACJ;AACA;AACA;IACI,IAAI,CAACP,aAAa,GAAGG,YAAY;IACjC;AACJ;AACA;AACA;IACI,IAAI,CAACK,SAAS,GAAGH,QAAQ;IACzB;AACJ;AACA;AACA;IACI,IAAI,CAACI,SAAS,GAAGH,QAAQ;IACzB;AACJ;AACA;AACA;AACA;IACI,IAAI,CAACP,iBAAiB,GAAGK,gBAAgB;EAC3C;;EAEA;AACF;AACA;AACA;AACA;EACEM,YAAYA,CAACC,OAAO,EAAE;IACpB,OAAO,IAAI,CAACd,UAAU,KAAKc,OAAO,GAAG,YAAY,GAAG,EAAE;EACxD;EAEA,IAAIC,SAASA,CAAA,EAAG;IACd,MAAMC,YAAY,GAAG,IAAI,CAACJ,SAAS,GAAG,aAAa,GAAG,EAAE;IACxD,MAAMK,YAAY,GAChB,IAAI,CAACN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I,CAAClB,SAAS,GAAGkB,KAAK;IACtB,IAAI,CAACD,MAAM,CAAC,CAAC;EACf;EAEA,IAAInB,QAAQA,CAAA,EAAG;IACb,OAAO,IAAI,CAACG,SAAS;EACvB;;EAEA;AACF;AACA;EACE,IAAIH,QAAQA,CAACoB,KAAK,EAAE;IAClB,IAAI,CAACjB,SAAS,GAAGiB,KAAK;IACtB,IAAI,CAACD,MAAM,CAAC,CAAC;EACf;;EAEA;AACF;AACA;EACE,IAAIE,SAASA,CAAA,EAAG;IACd,OAAO,IAAI,CAAC9B,UAAU;EACxB;;EAEA;AACF;AACA;EACE,IAAI8B,SAASA,CAACD,KAAK,EAAE;IACnB,IAAI,CAAC7B,UAAU,GAAG6B,KAAK;IACvB,IAAI,CAACD,MAAM,CAAC,CAAC;EACf;;EAEA;AACF;AACA;EACE,IAAIH,EAAEA,CAAA,EAAG;IACP,OAAO,IAAI,CAAC9B,GAAG;EACjB;;EAEA;AACF;AACA;EACE,IAAI8B,EAAEA,CAACI,KAAK,EAAE;IACZ,IAAI,CAAClC,GAAG,GAAGkC,KAAK;EAClB;;EAEA;AACF;AACA;EACEE,gBAAgBA,CAAA,EAAG;IACjB,IAAI,CAAC3B,YAAY,GAAG,IAAI;EAC1B;;EAEA;AACF;AACA;EACE4B,kBAAkBA,CAAA,EAAG;IACnB,IAAI,CAAC5B,YAAY,GAAG,KAAK;EAC3B;AACF;;AAEA;AACA;AACA","ignoreList":[]}
|
@@ -54,7 +54,7 @@ export class PreviewComponent {
|
|
54
54
|
*/
|
55
55
|
protected _highlighted: boolean;
|
56
56
|
/**
|
57
|
-
* @type {string}
|
57
|
+
* @type {string | undefined}
|
58
58
|
* @private
|
59
59
|
*/
|
60
60
|
private _question;
|
@@ -96,13 +96,13 @@ export class PreviewComponent {
|
|
96
96
|
get renderInput(): QuestionBaseModel;
|
97
97
|
render(): void;
|
98
98
|
/**
|
99
|
-
* @param {string} value
|
99
|
+
* @param {string | undefined} value
|
100
100
|
*/
|
101
|
-
set question(value: string);
|
101
|
+
set question(value: string | undefined);
|
102
102
|
/**
|
103
|
-
* @type {string}
|
103
|
+
* @type {string | undefined}
|
104
104
|
*/
|
105
|
-
get question(): string;
|
105
|
+
get question(): string | undefined;
|
106
106
|
/**
|
107
107
|
* @param {boolean} value
|
108
108
|
*/
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"preview.d.ts","sourceRoot":"","sources":["../../../../../src/form/form-editor/preview/preview.js"],"names":[],"mappings":"AAGA;;GAEG;AACH;IACE,oBAAmC;IA2CnC;;;OAGG;IAEH;;;OAGG;IACH,0BAHW,gBAAgB,oBAChB,gBAAgB,EA0B1B;IA3ED;;OAEG;IACH,KAFW,MAAM,GAAG,SAAS,CAEd;IACf;;;OAGG;IACH,eAFU,aAAa,CAEc;IACrC;;;;OAIG;IACH,6BAHU,MAAM,CAGM;IACtB;;;OAGG;IACH,sBAHW,MAAM,GAAC,IAAI,CAGL;IACjB;;;;OAIG;IACH,sBAHU,MAAM,CAGD;IACf;;;OAGG;IACH,6BAHU,gBAAgB,CAGT;IAEjB;;;OAGG;IACH,yBAHU,gBAAgB,CAGb;IACb;;;OAGG;IACH,wBAHU,OAAO,CAGG;IAkBlB;;;OAGG;IACH,kBAAyB;IACzB;;;OAGG;IACH,kBAAyB;IAS3B;;;;OAIG;IACH,gCAJW,MAAM,GACJ,MAAM,CAKlB;IAED,
|
1
|
+
{"version":3,"file":"preview.d.ts","sourceRoot":"","sources":["../../../../../src/form/form-editor/preview/preview.js"],"names":[],"mappings":"AAGA;;GAEG;AACH;IACE,oBAAmC;IA2CnC;;;OAGG;IAEH;;;OAGG;IACH,0BAHW,gBAAgB,oBAChB,gBAAgB,EA0B1B;IA3ED;;OAEG;IACH,KAFW,MAAM,GAAG,SAAS,CAEd;IACf;;;OAGG;IACH,eAFU,aAAa,CAEc;IACrC;;;;OAIG;IACH,6BAHU,MAAM,CAGM;IACtB;;;OAGG;IACH,sBAHW,MAAM,GAAC,IAAI,CAGL;IACjB;;;;OAIG;IACH,sBAHU,MAAM,CAGD;IACf;;;OAGG;IACH,6BAHU,gBAAgB,CAGT;IAEjB;;;OAGG;IACH,yBAHU,gBAAgB,CAGb;IACb;;;OAGG;IACH,wBAHU,OAAO,CAGG;IAkBlB;;;OAGG;IACH,kBAAyB;IACzB;;;OAGG;IACH,kBAAyB;IAS3B;;;;OAIG;IACH,gCAJW,MAAM,GACJ,MAAM,CAKlB;IAED,wBAKC;IAED;;;OAGG;IACH,uBAFU,gBAAgB,CAOzB;IAED;;;OAGG;IACH,0BAFU,aAAa,CAStB;IAED;;OAEG;IACH,0BAFa,OAAO,CAAC,iBAAiB,CAAC,CAItC;IAED;;;;OAIG;IACH,0BAHa,iBAAiB,CAS7B;IAED;;OAEG;IACH,mBAFU,iBAAiB,CAO1B;IAED,eAEC;IASD;;OAEG;IACH,oBAFW,MAAM,GAAG,SAAS,EAK5B;IAbD;;OAEG;IACH,gBAFU,MAAM,GAAG,SAAS,CAI3B;IAcD;;OAEG;IACH,oBAFW,OAAO,EAKjB;IAVD,gBAKW,OAAO,CAHjB;IAiBD;;OAEG;IACH,qBAFW,MAAM,GAAG,IAAI,EAKvB;IAbD;;OAEG;IACH,iBAFU,MAAM,GAAG,IAAI,CAItB;IAiBD;;OAEG;IACH,cAFY,MAAM,GAAG,SAAS,EAI7B;IAZD;;OAEG;IACH,UAFW,MAAM,GAAG,SAAS,CAI5B;IASD;;OAEG;IACH,yBAEC;IAED;;OAEG;IACH,2BAEC;CACF;8BApO6B,2BAA2B;sCAuOkD,yCAAyC;sCAAzC,yCAAyC;sCAAzC,yCAAyC;mCAAzC,yCAAyC;uCAAzC,yCAAyC"}
|
package/package.json
CHANGED
@@ -90,7 +90,7 @@ export class PreviewPageController extends PreviewPageControllerBase {
|
|
90
90
|
return false
|
91
91
|
}
|
92
92
|
// |_ one component and title not highlighted
|
93
|
-
if (this._title.trim() === this._components[0]?.question
|
93
|
+
if (this._title.trim() === this._components[0]?.question?.trim()) {
|
94
94
|
return true
|
95
95
|
}
|
96
96
|
// titles not the same
|
@@ -140,7 +140,7 @@ export class PreviewPageController extends PreviewPageControllerBase {
|
|
140
140
|
get titleAndFirstTitleSame() {
|
141
141
|
return (
|
142
142
|
this._components.length > 0 &&
|
143
|
-
this._title.trim() === this._components[0]?.question
|
143
|
+
this._title.trim() === this._components[0]?.question?.trim() &&
|
144
144
|
this.components.length === 1 &&
|
145
145
|
this._highlighted !== 'title'
|
146
146
|
)
|
@@ -66,7 +66,7 @@ export class PreviewComponent {
|
|
66
66
|
*/
|
67
67
|
this._htmlElements = htmlElements
|
68
68
|
/**
|
69
|
-
* @type {string}
|
69
|
+
* @type {string | undefined}
|
70
70
|
* @private
|
71
71
|
*/
|
72
72
|
this._question = question
|
@@ -94,7 +94,9 @@ export class PreviewComponent {
|
|
94
94
|
|
95
95
|
get titleText() {
|
96
96
|
const optionalText = this._optional ? ' (optional)' : ''
|
97
|
-
|
97
|
+
const questionText =
|
98
|
+
this._question === '' || !this._question ? 'Question' : this._question
|
99
|
+
return questionText + optionalText
|
98
100
|
}
|
99
101
|
|
100
102
|
/**
|
@@ -156,14 +158,14 @@ export class PreviewComponent {
|
|
156
158
|
}
|
157
159
|
|
158
160
|
/**
|
159
|
-
* @type {string}
|
161
|
+
* @type {string | undefined}
|
160
162
|
*/
|
161
163
|
get question() {
|
162
164
|
return this._question
|
163
165
|
}
|
164
166
|
|
165
167
|
/**
|
166
|
-
* @param {string} value
|
168
|
+
* @param {string | undefined} value
|
167
169
|
*/
|
168
170
|
set question(value) {
|
169
171
|
this._question = value
|