@defra/forms-model 3.0.552 → 3.0.554

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.
@@ -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.trim()) {
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.trim() && this.components.length === 1 && this._highlighted !== 'title';
119
+ return this._components.length > 0 && this._title.trim() === this._components[0]?.question?.trim() && this.components.length === 1 && this._highlighted !== 'title';
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,IAAI;EAC5C;AACF;AACA;AACA;EACEC,WAAW,GAAG,EAAE;;EAEhB;AACF;AACA;AACA;AACA;AACA;EACEC,WAAWA,CAACC,UAAU,EAAEC,QAAQ,EAAEC,UAAU,EAAEC,QAAQ,EAAE;IACtD,KAAK,CAACF,QAAQ,EAAEE,QAAQ,CAAC;IACzB,MAAMC,SAAS,GAAGJ,UAAU,CAACK,GAAG,CAC9Bf,6BAA6B,CAACE,gBAAgB,EAAEU,UAAU,CAC5D,CAAC;IACD,MAAMI,aAAa,GAAG;IACpBF,SAAS,CAACG,KAA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AE,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,EAAEC,QAAQ,EAAEC,UAAU,EAAEC,QAAQ,EAAE;IACtD,KAAK,CAACF,QAAQ,EAAEE,QAAQ,CAAC;IACzB,MAAMC,SAAS,GAAGJ,UAAU,CAACK,GAAG,CAC9Bf,6BAA6B,CAACE,gBAAgB,EAAEU,UAAU,CAC5D,CAAC;IACD,MAAMI,aAAa,GAAG;IACpBF,SAAS,CAACG,KAAK,CAAC,CACjB;IACD,IAAI,CAACC,kBAAkB,GACrBZ,qBAAqB,CAACa,4BAA4B,CAACH,aAAa,CAAC;IACnE,IAAI,CAACI,aAAa,GAA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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
- return (!this._question ? 'Question' : this._question) + optionalText;
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 return (!this._question ? 'Question' : this._question) + 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}\n */\n get question() {\n return this._question\n }\n\n /**\n * @param {string} 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;EAC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B;;EAEA;AACF;AACA;EACE,IAAI6B,EAAEA,CAACI,KAAK,EAAE;IACZ,IAAI,CAACjC,GAAG,GAAGiC,KAAK;EAClB;;EAEA;AACF;AACA;EACEE,gBAAgBA,CAAA,EAAG;IACjB,IAAI,CAAC1B,YAAY,GAAG,IAAI;EAC1B;;EAEA;AACF;AACA;EACE2B,kBAAkBA,CAAA,EAAG;IACnB,IAAI,CAAC3B,YAAY,GAAG,KAAK;EAC3B;AACF;;AAEA;AACA;AACA","ignoreList":[]}
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,G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zE;;EAEA;AACF;AACA;EACE,IAAInB,QAAQA,CAAA,EAAG;IACb,OAAO,IAAI,CAACG,SAAS;EACvB;;EAEA;AACF;AACA;EACE,IAAIH,QAAQA,CAACqB,KAAK,EAAE;IAClB,IAAI,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":[]}
@@ -9,7 +9,7 @@ export const formSubmitRecordSchema = Joi.object({
9
9
  name: Joi.string().required().description('Field identifier matching the component name'),
10
10
  title: Joi.string().required().description('Human-readable label for the field'),
11
11
  value: Joi.string().required().allow('').description('User-submitted value for the field, may be empty')
12
- }).description('Individual field value in a form submission');
12
+ }).label('FormSubmitRecord').description('Individual field value in a form submission');
13
13
 
14
14
  /**
15
15
  * Joi schema for `SubmitRecordset` interface
@@ -18,8 +18,8 @@ export const formSubmitRecordSchema = Joi.object({
18
18
  export const formSubmitRecordsetSchema = Joi.object({
19
19
  name: Joi.string().required().description('Identifier for the repeatable section'),
20
20
  title: Joi.string().required().description('Human-readable title for the repeatable section'),
21
- value: Joi.array().items(Joi.array().items(formSubmitRecordSchema).required()).required().description('Array of record arrays, each representing a repeated instance')
22
- }).description('Collection of repeated field values from a repeatable section');
21
+ value: Joi.array().items(Joi.array().items(formSubmitRecordSchema).required().label('FormSubmitRecordGroup')).required().description('Array of record arrays, each representing a repeated instance')
22
+ }).label('FormSubmitRecordset').description('Collection of repeated field values from a repeatable section');
23
23
 
24
24
  /**
25
25
  * Joi schema for `SubmitPayload` interface
@@ -30,22 +30,22 @@ export const formSubmitPayloadSchema = Joi.object().keys({
30
30
  sessionId: Joi.string().required().description('User session identifier for tracking and security'),
31
31
  main: Joi.array().items(formSubmitRecordSchema).required().description('Main (non-repeating) field values from the form'),
32
32
  repeaters: Joi.array().items(formSubmitRecordsetSchema).required().description('Repeatable section values from the form')
33
- }).required().description('Complete form submission payload structure with all form data');
33
+ }).required().label('FormSubmitPayload').description('Complete form submission payload structure with all form data');
34
34
  export const saveAndExitMessageData = Joi.object().keys({
35
- form: {
35
+ form: Joi.object({
36
36
  id: Joi.string().required(),
37
37
  title: Joi.string().required(),
38
38
  status: Joi.string().valid(FormStatus.Draft, FormStatus.Live).required(),
39
39
  isPreview: Joi.boolean().required(),
40
40
  baseUrl: Joi.string().required()
41
- },
41
+ }).label('SaveAndExitForm'),
42
42
  email: Joi.string().required(),
43
- security: {
43
+ security: Joi.object({
44
44
  question: Joi.string().valid(...Object.values(SecurityQuestionsEnum).map(value => value.toString())).required(),
45
45
  answer: Joi.string().required()
46
- },
46
+ }).label('SaveAndExitSecurity'),
47
47
  state: Joi.object().required()
48
- });
48
+ }).label('SaveAndExitMessageData');
49
49
  export const submissionMessageSchema = Joi.object().keys({
50
50
  schemaVersion: Joi.string().valid(...Object.values(SubmissionEventMessageSchemaVersion)).required().description('The version of the SubmissionMessage - bumped with breaking changes'),
51
51
  category: Joi.string().valid(...Object.values(SubmissionEventMessageCategory)).required().description('The message category - what does the entityId represent?'),
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["Joi","FormStatus","SecurityQuestionsEnum","SubmissionEventMessageCategory","SubmissionEventMessageSchemaVersion","SubmissionEventMessageSource","SubmissionEventMessageType","formSubmitRecordSchema","object","name","string","required","description","title","value","allow","formSubmitRecordsetSchema","array","items","formSubmitPayloadSchema","keys","retrievalKey","sessionId","main","repeaters","saveAndExitMessageData","form","id","status","valid","Draft","Live","isPreview","boolean","baseUrl","email","security","question","Object","values","map","toString","answer","state","submissionMessageSchema","schemaVersion","category","source","type","createdAt","date","messageCreatedAt","data"],"sources":["../../../../src/form/form-submission/index.ts"],"sourcesContent":["import Joi from 'joi'\n\nimport { FormStatus } from '~/src/common/enums.js'\nimport {\n SecurityQuestionsEnum,\n SubmissionEventMessageCategory,\n SubmissionEventMessageSchemaVersion,\n SubmissionEventMessageSource,\n SubmissionEventMessageType\n} from '~/src/form/form-submission/enums.js'\nimport {\n type SaveAndExitMessage,\n type SaveAndExitMessageData,\n type SubmitPayload,\n type SubmitRecord,\n type SubmitRecordset\n} from '~/src/form/form-submission/types.js'\n\n/**\n * Joi schema for `SubmitRecord` interface\n * @see {@link SubmitRecord}\n */\nexport const formSubmitRecordSchema = Joi.object<SubmitRecord>({\n name: Joi.string()\n .required()\n .description('Field identifier matching the component name'),\n title: Joi.string()\n .required()\n .description('Human-readable label for the field'),\n value: Joi.string()\n .required()\n .allow('')\n .description('User-submitted value for the field, may be empty')\n}).description('Individual field value in a form submission')\n\n/**\n * Joi schema for `SubmitRecordset` interface\n * @see {@link SubmitRecordset}\n */\nexport const formSubmitRecordsetSchema = Joi.object<SubmitRecordset>({\n name: Joi.string()\n .required()\n .description('Identifier for the repeatable section'),\n title: Joi.string()\n .required()\n .description('Human-readable title for the repeatable section'),\n value: Joi.array<SubmitRecord[]>()\n .items(Joi.array<SubmitRecord>().items(formSubmitRecordSchema).required())\n .required()\n .description(\n 'Array of record arrays, each representing a repeated instance'\n )\n}).description('Collection of repeated field values from a repeatable section')\n\n/**\n * Joi schema for `SubmitPayload` interface\n * @see {@link SubmitPayload}\n */\nexport const formSubmitPayloadSchema = Joi.object<SubmitPayload>()\n .keys({\n retrievalKey: Joi.string()\n .required()\n .description('Unique key to retrieve this submission later'),\n sessionId: Joi.string()\n .required()\n .description('User session identifier for tracking and security'),\n main: Joi.array<SubmitRecord>()\n .items(formSubmitRecordSchema)\n .required()\n .description('Main (non-repeating) field values from the form'),\n repeaters: Joi.array<SubmitRecordset>()\n .items(formSubmitRecordsetSchema)\n .required()\n .description('Repeatable section values from the form')\n })\n .required()\n .description('Complete form submission payload structure with all form data')\n\nexport const saveAndExitMessageData = Joi.object<SaveAndExitMessageData>().keys(\n {\n form: {\n id: Joi.string().required(),\n title: Joi.string().required(),\n status: Joi.string().valid(FormStatus.Draft, FormStatus.Live).required(),\n isPreview: Joi.boolean().required(),\n baseUrl: Joi.string().required()\n },\n email: Joi.string().required(),\n security: {\n question: Joi.string()\n .valid(\n ...Object.values(SecurityQuestionsEnum).map((value) =>\n value.toString()\n )\n )\n .required(),\n answer: Joi.string().required()\n },\n state: Joi.object().required()\n }\n)\n\nexport const submissionMessageSchema = Joi.object<SaveAndExitMessage>().keys({\n schemaVersion: Joi.string()\n .valid(...Object.values(SubmissionEventMessageSchemaVersion))\n .required()\n .description(\n 'The version of the SubmissionMessage - bumped with breaking changes'\n ),\n category: Joi.string()\n .valid(...Object.values(SubmissionEventMessageCategory))\n .required()\n .description('The message category - what does the entityId represent?'),\n source: Joi.string()\n .valid(...Object.values(SubmissionEventMessageSource))\n .required()\n .description('Source of the message - which service?'),\n type: Joi.string()\n .valid(...Object.values(SubmissionEventMessageType))\n .description('Event type'),\n createdAt: Joi.date()\n .required()\n .description(\n 'The ISO timestamp where the action took place - should be the same as updated_at field in DB'\n ),\n messageCreatedAt: Joi.date()\n .required()\n .description('ISO timestamp when the message was published'),\n data: saveAndExitMessageData\n})\n"],"mappings":"AAAA,OAAOA,GAAG,MAAM,KAAK;AAErB,SAASC,UAAU;AACnB,SACEC,qBAAqB,EACrBC,8BAA8B,EAC9BC,mCAAmC,EACnCC,4BAA4B,EAC5BC,0BAA0B;AAU5B;AACA;AACA;AACA;AACA,OAAO,MAAMC,sBAAsB,GAAGP,GAAG,CAACQ,MAAM,CAAe;EAC7DC,IAAI,EAAET,GAAG,CAACU,MAAM,CAAC,CAAC,CACfC,QAAQ,CAAC,CAAC,CACVC,WAAW,CAAC,8CAA8C,CAAC;EAC9DC,KAAK,EAAEb,GAAG,CAACU,MAAM,CAAC,CAAC,CAChBC,QAAQ,CAAC,CAAC,CACVC,WAAW,CAAC,oCAAoC,CAAC;EACpDE,KAAK,EAAEd,GAAG,CAACU,MAAM,CAAC,CAAC,CAChBC,QAAQ,CAAC,CAAC,CACVI,KAAK,CAAC,EAAE,CAAC,CACTH,WAAW,CAAC,kDAAkD;AACnE,CAAC,CAAC,CAACA,WAAW,CAAC,6CAA6C,CAAC;;AAE7D;AACA;AACA;AACA;AACA,OAAO,MAAMI,yBAAyB,GAAGhB,GAAG,CAACQ,MAAM,CAAkB;EACnEC,IAAI,EAAET,GAAG,CAACU,MAAM,CAAC,CAAC,CACfC,QAAQ,CAAC,CAAC,CACVC,WAAW,CAAC,uCAAuC,CAAC;EACvDC,KAAK,EAAEb,GAAG,CAACU,MAAM,CAAC,CAAC,CAChBC,QAAQ,CAAC,CAAC,CACVC,WAAW,CAAC,iDAAiD,CAAC;EACjEE,KAAK,EAAEd,GAAG,CAACiB,KAAK,CAAiB,CAAC,CAC/BC,KAAK,CAAClB,GAAG,CAACiB,KAAK,CAAe,CAAC,CAACC,KAAK,CAACX,sBAAsB,CAAC,CAACI,QAAQ,CAAC,CAA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C,CACrDM,QAAQ,CAAC,CAAC,CACVC,WAAW,CAAC,wCAAwC,CAAC;EACxDoC,IAAI,EAAEhD,GAAG,CAACU,MAAM,CAAC,CAAC,CACfmB,KAAK,CAAC,GAAGS,MAAM,CAACC,MAAM,CAACjC,0BAA0B,CAAC,CAAC,CACnDM,WAAW,CAAC,YAAY,CAAC;EAC5BqC,SAAS,EAAEjD,GAAG,CAACkD,IAAI,CAAC,CAAC,CAClBvC,QAAQ,CAAC,CAAC,CACVC,WAAW,CACV,8FACF,CAAC;EACHuC,gBAAgB,EAAEnD,GAAG,CAACkD,IAAI,CAAC,CAAC,CACzBvC,QAAQ,CAAC,CAAC,CACVC,WAAW,CAAC,8CAA8C,CAAC;EAC9DwC,IAAI,EAAE3B;AACR,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["Joi","FormStatus","SecurityQuestionsEnum","SubmissionEventMessageCategory","SubmissionEventMessageSchemaVersion","SubmissionEventMessageSource","SubmissionEventMessageType","formSubmitRecordSchema","object","name","string","required","description","title","value","allow","label","formSubmitRecordsetSchema","array","items","formSubmitPayloadSchema","keys","retrievalKey","sessionId","main","repeaters","saveAndExitMessageData","form","id","status","valid","Draft","Live","isPreview","boolean","baseUrl","email","security","question","Object","values","map","toString","answer","state","submissionMessageSchema","schemaVersion","category","source","type","createdAt","date","messageCreatedAt","data"],"sources":["../../../../src/form/form-submission/index.ts"],"sourcesContent":["import Joi from 'joi'\n\nimport { FormStatus } from '~/src/common/enums.js'\nimport {\n SecurityQuestionsEnum,\n SubmissionEventMessageCategory,\n SubmissionEventMessageSchemaVersion,\n SubmissionEventMessageSource,\n SubmissionEventMessageType\n} from '~/src/form/form-submission/enums.js'\nimport {\n type SaveAndExitMessage,\n type SaveAndExitMessageData,\n type SubmitPayload,\n type SubmitRecord,\n type SubmitRecordset\n} from '~/src/form/form-submission/types.js'\n\n/**\n * Joi schema for `SubmitRecord` interface\n * @see {@link SubmitRecord}\n */\nexport const formSubmitRecordSchema = Joi.object<SubmitRecord>({\n name: Joi.string()\n .required()\n .description('Field identifier matching the component name'),\n title: Joi.string()\n .required()\n .description('Human-readable label for the field'),\n value: Joi.string()\n .required()\n .allow('')\n .description('User-submitted value for the field, may be empty')\n})\n .label('FormSubmitRecord')\n .description('Individual field value in a form submission')\n\n/**\n * Joi schema for `SubmitRecordset` interface\n * @see {@link SubmitRecordset}\n */\nexport const formSubmitRecordsetSchema = Joi.object<SubmitRecordset>({\n name: Joi.string()\n .required()\n .description('Identifier for the repeatable section'),\n title: Joi.string()\n .required()\n .description('Human-readable title for the repeatable section'),\n value: Joi.array<SubmitRecord[]>()\n .items(\n Joi.array<SubmitRecord>()\n .items(formSubmitRecordSchema)\n .required()\n .label('FormSubmitRecordGroup')\n )\n .required()\n .description(\n 'Array of record arrays, each representing a repeated instance'\n )\n})\n .label('FormSubmitRecordset')\n .description('Collection of repeated field values from a repeatable section')\n\n/**\n * Joi schema for `SubmitPayload` interface\n * @see {@link SubmitPayload}\n */\nexport const formSubmitPayloadSchema = Joi.object<SubmitPayload>()\n .keys({\n retrievalKey: Joi.string()\n .required()\n .description('Unique key to retrieve this submission later'),\n sessionId: Joi.string()\n .required()\n .description('User session identifier for tracking and security'),\n main: Joi.array<SubmitRecord>()\n .items(formSubmitRecordSchema)\n .required()\n .description('Main (non-repeating) field values from the form'),\n repeaters: Joi.array<SubmitRecordset>()\n .items(formSubmitRecordsetSchema)\n .required()\n .description('Repeatable section values from the form')\n })\n .required()\n .label('FormSubmitPayload')\n .description('Complete form submission payload structure with all form data')\n\nexport const saveAndExitMessageData = Joi.object<SaveAndExitMessageData>()\n .keys({\n form: Joi.object({\n id: Joi.string().required(),\n title: Joi.string().required(),\n status: Joi.string().valid(FormStatus.Draft, FormStatus.Live).required(),\n isPreview: Joi.boolean().required(),\n baseUrl: Joi.string().required()\n }).label('SaveAndExitForm'),\n email: Joi.string().required(),\n security: Joi.object({\n question: Joi.string()\n .valid(\n ...Object.values(SecurityQuestionsEnum).map((value) =>\n value.toString()\n )\n )\n .required(),\n answer: Joi.string().required()\n }).label('SaveAndExitSecurity'),\n state: Joi.object().required()\n })\n .label('SaveAndExitMessageData')\n\nexport const submissionMessageSchema = Joi.object<SaveAndExitMessage>().keys({\n schemaVersion: Joi.string()\n .valid(...Object.values(SubmissionEventMessageSchemaVersion))\n .required()\n .description(\n 'The version of the SubmissionMessage - bumped with breaking changes'\n ),\n category: Joi.string()\n .valid(...Object.values(SubmissionEventMessageCategory))\n .required()\n .description('The message category - what does the entityId represent?'),\n source: Joi.string()\n .valid(...Object.values(SubmissionEventMessageSource))\n .required()\n .description('Source of the message - which service?'),\n type: Joi.string()\n .valid(...Object.values(SubmissionEventMessageType))\n .description('Event type'),\n createdAt: Joi.date()\n .required()\n .description(\n 'The ISO timestamp where the action took place - should be the same as updated_at field in DB'\n ),\n messageCreatedAt: Joi.date()\n .required()\n .description('ISO timestamp when the message was published'),\n data: saveAndExitMessageData\n})\n"],"mappings":"AAAA,OAAOA,GAAG,MAAM,KAAK;AAErB,SAASC,UAAU;AACnB,SACEC,qBAAqB,EACrBC,8BAA8B,EAC9BC,mCAAmC,EACnCC,4BAA4B,EAC5BC,0BAA0B;AAU5B;AACA;AACA;AACA;AACA,OAAO,MAAMC,sBAAsB,GAAGP,GAAG,CAACQ,MAAM,CAAe;EAC7DC,IAAI,EAAET,GAAG,CAACU,MAAM,CAAC,CAAC,CACfC,QAAQ,CAAC,CAAC,CACVC,WAAW,CAAC,8CAA8C,CAAC;EAC9DC,KAAK,EAAEb,GAAG,CAACU,MAAM,CAAC,CAAC,CAChBC,QAAQ,CAAC,CAAC,CACVC,WAAW,CAAC,oCAAoC,CAAC;EACpDE,KAAK,EAAEd,GAAG,CAACU,MAAM,CAAC,CAAC,CAChBC,QAAQ,CAAC,CAAC,CACVI,KAAK,CAAC,EAAE,CAAC,CACTH,WAAW,CAAC,kDAAkD;AACnE,CAAC,CAAC,CACCI,KAAK,CAAC,kBAAkB,CAAC,CACzBJ,WAA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,EAAE3B;AACR,CAAC,CAAC","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,wBAGC;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,EAKhB;IAbD;;OAEG;IACH,gBAFU,MAAM,CAIf;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;8BAlO6B,2BAA2B;sCAqOkD,yCAAyC;sCAAzC,yCAAyC;sCAAzC,yCAAyC;mCAAzC,yCAAyC;uCAAzC,yCAAyC"}
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"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/form/form-submission/index.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,KAAK,CAAA;AAUrB,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,sBAAsB,EAC3B,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,eAAe,EACrB,MAAM,qCAAqC,CAAA;AAE5C;;;GAGG;AACH,eAAO,MAAM,sBAAsB,gCAW0B,CAAA;AAE7D;;;GAGG;AACH,eAAO,MAAM,yBAAyB,mCAayC,CAAA;AAE/E;;;GAGG;AACH,eAAO,MAAM,uBAAuB,iCAkB2C,CAAA;AAE/E,eAAO,MAAM,sBAAsB,0CAsBlC,CAAA;AAED,eAAO,MAAM,uBAAuB,sCA2BlC,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/form/form-submission/index.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,KAAK,CAAA;AAUrB,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,sBAAsB,EAC3B,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,eAAe,EACrB,MAAM,qCAAqC,CAAA;AAE5C;;;GAGG;AACH,eAAO,MAAM,sBAAsB,gCAa0B,CAAA;AAE7D;;;GAGG;AACH,eAAO,MAAM,yBAAyB,mCAoByC,CAAA;AAE/E;;;GAGG;AACH,eAAO,MAAM,uBAAuB,iCAmB2C,CAAA;AAE/E,eAAO,MAAM,sBAAsB,0CAsBD,CAAA;AAElC,eAAO,MAAM,uBAAuB,sCA2BlC,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defra/forms-model",
3
- "version": "3.0.552",
3
+ "version": "3.0.554",
4
4
  "description": "A hapi plugin providing the model for Defra forms",
5
5
  "homepage": "https://github.com/DEFRA/forms-designer/tree/main/model#readme",
6
6
  "types": "dist/types/index.d.ts",
@@ -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.trim()) {
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.trim() &&
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
- return (!this._question ? 'Question' : this._question) + optionalText
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
@@ -31,7 +31,9 @@ export const formSubmitRecordSchema = Joi.object<SubmitRecord>({
31
31
  .required()
32
32
  .allow('')
33
33
  .description('User-submitted value for the field, may be empty')
34
- }).description('Individual field value in a form submission')
34
+ })
35
+ .label('FormSubmitRecord')
36
+ .description('Individual field value in a form submission')
35
37
 
36
38
  /**
37
39
  * Joi schema for `SubmitRecordset` interface
@@ -45,12 +47,19 @@ export const formSubmitRecordsetSchema = Joi.object<SubmitRecordset>({
45
47
  .required()
46
48
  .description('Human-readable title for the repeatable section'),
47
49
  value: Joi.array<SubmitRecord[]>()
48
- .items(Joi.array<SubmitRecord>().items(formSubmitRecordSchema).required())
50
+ .items(
51
+ Joi.array<SubmitRecord>()
52
+ .items(formSubmitRecordSchema)
53
+ .required()
54
+ .label('FormSubmitRecordGroup')
55
+ )
49
56
  .required()
50
57
  .description(
51
58
  'Array of record arrays, each representing a repeated instance'
52
59
  )
53
- }).description('Collection of repeated field values from a repeatable section')
60
+ })
61
+ .label('FormSubmitRecordset')
62
+ .description('Collection of repeated field values from a repeatable section')
54
63
 
55
64
  /**
56
65
  * Joi schema for `SubmitPayload` interface
@@ -74,19 +83,20 @@ export const formSubmitPayloadSchema = Joi.object<SubmitPayload>()
74
83
  .description('Repeatable section values from the form')
75
84
  })
76
85
  .required()
86
+ .label('FormSubmitPayload')
77
87
  .description('Complete form submission payload structure with all form data')
78
88
 
79
- export const saveAndExitMessageData = Joi.object<SaveAndExitMessageData>().keys(
80
- {
81
- form: {
89
+ export const saveAndExitMessageData = Joi.object<SaveAndExitMessageData>()
90
+ .keys({
91
+ form: Joi.object({
82
92
  id: Joi.string().required(),
83
93
  title: Joi.string().required(),
84
94
  status: Joi.string().valid(FormStatus.Draft, FormStatus.Live).required(),
85
95
  isPreview: Joi.boolean().required(),
86
96
  baseUrl: Joi.string().required()
87
- },
97
+ }).label('SaveAndExitForm'),
88
98
  email: Joi.string().required(),
89
- security: {
99
+ security: Joi.object({
90
100
  question: Joi.string()
91
101
  .valid(
92
102
  ...Object.values(SecurityQuestionsEnum).map((value) =>
@@ -95,10 +105,10 @@ export const saveAndExitMessageData = Joi.object<SaveAndExitMessageData>().keys(
95
105
  )
96
106
  .required(),
97
107
  answer: Joi.string().required()
98
- },
108
+ }).label('SaveAndExitSecurity'),
99
109
  state: Joi.object().required()
100
- }
101
- )
110
+ })
111
+ .label('SaveAndExitMessageData')
102
112
 
103
113
  export const submissionMessageSchema = Joi.object<SaveAndExitMessage>().keys({
104
114
  schemaVersion: Joi.string()