@defra/forms-model 3.0.490 → 3.0.492

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/dist/module/form/form-editor/__stubs__/preview.js +6 -7
  2. package/dist/module/form/form-editor/__stubs__/preview.js.map +1 -1
  3. package/dist/module/form/form-editor/preview/component-elements.js +2 -10
  4. package/dist/module/form/form-editor/preview/component-elements.js.map +1 -1
  5. package/dist/module/form/form-editor/preview/content.js +2 -3
  6. package/dist/module/form/form-editor/preview/content.js.map +1 -1
  7. package/dist/module/form/form-editor/preview/controller/page-controller.js +91 -6
  8. package/dist/module/form/form-editor/preview/controller/page-controller.js.map +1 -1
  9. package/dist/module/form/form-editor/preview/helpers.js +5 -6
  10. package/dist/module/form/form-editor/preview/helpers.js.map +1 -1
  11. package/dist/module/form/form-editor/preview/list.js +2 -3
  12. package/dist/module/form/form-editor/preview/list.js.map +1 -1
  13. package/dist/module/form/form-editor/preview/preview.js +3 -8
  14. package/dist/module/form/form-editor/preview/preview.js.map +1 -1
  15. package/dist/module/form/form-editor/preview/question.js +2 -2
  16. package/dist/module/form/form-editor/preview/question.js.map +1 -1
  17. package/dist/module/form/form-editor/preview/types.js.map +1 -1
  18. package/dist/module/form/form-editor/types.js.map +1 -1
  19. package/dist/module/stubs.js +3 -0
  20. package/dist/module/stubs.js.map +1 -1
  21. package/dist/types/form/form-editor/__stubs__/preview.d.ts +4 -3
  22. package/dist/types/form/form-editor/__stubs__/preview.d.ts.map +1 -1
  23. package/dist/types/form/form-editor/preview/component-elements.d.ts +1 -7
  24. package/dist/types/form/form-editor/preview/component-elements.d.ts.map +1 -1
  25. package/dist/types/form/form-editor/preview/content.d.ts +1 -2
  26. package/dist/types/form/form-editor/preview/content.d.ts.map +1 -1
  27. package/dist/types/form/form-editor/preview/controller/page-controller.d.ts +27 -0
  28. package/dist/types/form/form-editor/preview/controller/page-controller.d.ts.map +1 -1
  29. package/dist/types/form/form-editor/preview/helpers.d.ts +1 -2
  30. package/dist/types/form/form-editor/preview/helpers.d.ts.map +1 -1
  31. package/dist/types/form/form-editor/preview/list.d.ts +1 -2
  32. package/dist/types/form/form-editor/preview/list.d.ts.map +1 -1
  33. package/dist/types/form/form-editor/preview/preview.d.ts +4 -5
  34. package/dist/types/form/form-editor/preview/preview.d.ts.map +1 -1
  35. package/dist/types/form/form-editor/preview/question.d.ts +1 -1
  36. package/dist/types/form/form-editor/preview/question.d.ts.map +1 -1
  37. package/dist/types/form/form-editor/preview/types.d.ts +13 -4
  38. package/dist/types/form/form-editor/preview/types.d.ts.map +1 -1
  39. package/dist/types/form/form-editor/types.d.ts +0 -1
  40. package/dist/types/form/form-editor/types.d.ts.map +1 -1
  41. package/dist/types/stubs.d.ts +3 -0
  42. package/dist/types/stubs.d.ts.map +1 -1
  43. package/package.json +1 -1
  44. package/src/form/form-editor/__stubs__/preview.js +6 -14
  45. package/src/form/form-editor/preview/component-elements.js +2 -10
  46. package/src/form/form-editor/preview/content.js +2 -3
  47. package/src/form/form-editor/preview/controller/page-controller.js +109 -10
  48. package/src/form/form-editor/preview/helpers.js +5 -10
  49. package/src/form/form-editor/preview/list.js +2 -3
  50. package/src/form/form-editor/preview/preview.js +3 -11
  51. package/src/form/form-editor/preview/question.js +2 -2
  52. package/src/form/form-editor/preview/types.ts +18 -4
  53. package/src/form/form-editor/types.ts +0 -1
  54. package/src/stubs.ts +3 -0
@@ -96,7 +96,6 @@ export class QuestionPreviewElements {
96
96
  * @private
97
97
  */
98
98
  _items = [];
99
- _largeTitle = true;
100
99
  afterInputsHTML = '<div class="govuk-inset-text">No items added yet.</div>';
101
100
 
102
101
  /**
@@ -108,8 +107,7 @@ export class QuestionPreviewElements {
108
107
  optional,
109
108
  shortDesc,
110
109
  items,
111
- content,
112
- largeTitle = true
110
+ content
113
111
  }) {
114
112
  this._question = question;
115
113
  this._hintText = hintText;
@@ -117,7 +115,6 @@ export class QuestionPreviewElements {
117
115
  this._shortDesc = shortDesc;
118
116
  this._items = items;
119
117
  this._content = content;
120
- this._largeTitle = largeTitle;
121
118
  }
122
119
 
123
120
  /**
@@ -130,8 +127,7 @@ export class QuestionPreviewElements {
130
127
  optional: this._optional,
131
128
  shortDesc: this._shortDesc,
132
129
  items: this._items,
133
- content: this._content,
134
- largeTitle: this._largeTitle
130
+ content: this._content
135
131
  };
136
132
  }
137
133
 
@@ -172,14 +168,17 @@ export class AutocompletePreviewElements extends QuestionPreviewElements {
172
168
  export class PagePreviewElements {
173
169
  guidance;
174
170
  heading;
171
+ addHeading;
175
172
 
176
173
  /**
177
174
  * @param {string} heading
178
175
  * @param {string} guidance
176
+ * @param {boolean} [addHeading]
179
177
  */
180
- constructor(heading, guidance = '') {
178
+ constructor(heading, guidance = '', addHeading = undefined) {
181
179
  this.heading = heading;
182
180
  this.guidance = guidance;
181
+ this.addHeading = addHeading ?? heading.length > 0;
183
182
  }
184
183
  }
185
184
  export const baseElements = /** @type {BaseSettings} */{
@@ -1 +1 @@
1
- {"version":3,"file":"preview.js","names":["Question","QuestionRendererStub","renderMock","constructor","render","questionTemplate","questionBaseModel","buildHTML","_questionTemplate","_renderContext","PageRendererStub","pageTemplate","pagePreviewPanelMacro","QuestionPreviewElements","_question","_hintText","_optional","_shortDesc","_content","_items","_largeTitle","afterInputsHTML","question","hintText","optional","shortDesc","items","content","largeTitle","values","setPreviewHTML","_value","setPreviewDOM","AutocompletePreviewElements","autocompleteOptions","elements","PagePreviewElements","guidance","heading","baseElements","list1Id","list2Id","list3Id","list4Id","listElementsBase","label","text","value","id","listElementsStub","buildPreviewShortAnswer","partialBaseElements"],"sources":["../../../../../src/form/form-editor/__stubs__/preview.js"],"sourcesContent":["import { Question } from '~/src/form/form-editor/preview/question.js'\n\n/**\n * @implements {QuestionRenderer}\n */\nexport class QuestionRendererStub {\n /**\n * @type {jest.Mock<void, [string, QuestionBaseModel]>}\n */\n renderMock\n\n /**\n * @param {jest.Mock<void, [string, QuestionBaseModel]>} renderMock\n */\n constructor(renderMock) {\n this.renderMock = renderMock\n }\n\n /**\n * @param {string} questionTemplate\n * @param {QuestionBaseModel} questionBaseModel\n */\n render(questionTemplate, questionBaseModel) {\n this.renderMock(questionTemplate, questionBaseModel)\n }\n\n /**\n * @returns {string}\n * @param {string} _questionTemplate\n * @param {RenderContext} _renderContext\n */\n static buildHTML(_questionTemplate, _renderContext) {\n return '**** BUILT HTML ****'\n }\n}\n\n/**\n * @implements {PageRenderer}\n */\nexport class PageRendererStub {\n /**\n * @type {jest.Mock<void, [string, PagePreviewPanelMacro]>}\n */\n renderMock\n\n /**\n * @param {jest.Mock<void, [string, PagePreviewPanelMacro]>} renderMock\n */\n constructor(renderMock) {\n this.renderMock = renderMock\n }\n\n /**\n * @param {string} pageTemplate\n * @param {PagePreviewPanelMacro} pagePreviewPanelMacro\n */\n render(pageTemplate, pagePreviewPanelMacro) {\n this.renderMock(pageTemplate, pagePreviewPanelMacro)\n }\n\n /**\n * @returns {string}\n * @param {string} _questionTemplate\n * @param {RenderContext} _renderContext\n */\n static buildHTML(_questionTemplate, _renderContext) {\n return '**** BUILT HTML ****'\n }\n}\n\n/**\n * @implements {ListElements}\n */\nexport class QuestionPreviewElements {\n /**\n * @protected\n */\n _question = ''\n /** @protected */\n _hintText = ''\n /** @protected */\n _optional = false\n /**\n * @type {string}\n * @protected\n */\n _shortDesc = ''\n /**\n * @type {string}\n * @protected\n */\n _content = ''\n /**\n *\n * @type {ListElement[]}\n * @private\n */\n _items = []\n _largeTitle = true\n afterInputsHTML = '<div class=\"govuk-inset-text\">No items added yet.</div>'\n\n /**\n * @param {BaseSettings} baseSettings\n */\n constructor({\n question,\n hintText,\n optional,\n shortDesc,\n items,\n content,\n largeTitle = true\n }) {\n this._question = question\n this._hintText = hintText\n this._optional = optional\n this._shortDesc = shortDesc\n this._items = items\n this._content = content\n this._largeTitle = largeTitle\n }\n\n /**\n * @returns {BaseSettings}\n */\n get values() {\n return {\n question: this._question,\n hintText: this._hintText,\n optional: this._optional,\n shortDesc: this._shortDesc,\n items: this._items,\n content: this._content,\n largeTitle: this._largeTitle\n }\n }\n\n /**\n * @param {string} _value\n */\n setPreviewHTML(_value) {\n // Not implemented for server side render\n }\n\n /**\n * @param {HTMLElement} _value\n */\n setPreviewDOM(_value) {\n // Not implemented for server side render\n }\n}\n\n/**\n * @implements {AutocompleteElements}\n */\nexport class AutocompletePreviewElements extends QuestionPreviewElements {\n /**\n * @param {BaseSettings & {autocompleteOptions: string}} elements\n */\n constructor({ autocompleteOptions, ...elements }) {\n super(elements)\n this.autocompleteOptions = autocompleteOptions\n }\n}\n\n/**\n * @implements {PageOverviewElements}\n */\nexport class PagePreviewElements {\n guidance\n heading\n\n /**\n * @param {string} heading\n * @param {string} guidance\n */\n constructor(heading, guidance = '') {\n this.heading = heading\n this.guidance = guidance\n }\n}\n\nexport const baseElements = /** @type {BaseSettings} */ ({\n items: [],\n optional: false,\n question: 'Which quest would you like to pick?',\n hintText: 'Choose one adventure that best suits you.',\n shortDesc: '',\n content: '',\n largeTitle: true\n})\n\nconst list1Id = '414d82a3-4cab-416a-bd54-6b86fbd51120'\nconst list2Id = '801385a4-81e6-4171-96c3-6c6727d97f22'\nconst list3Id = 'e6e3f621-b875-4ca3-a054-cca9149149dd'\nconst list4Id = 'd71b3909-582f-4e90-b6f5-490b89a6eb8f'\n\nconst listElementsBase = /** @type {BaseSettings} */ ({\n ...baseElements,\n items: [\n {\n label: { text: 'Treasure Hunting' },\n text: 'Treasure Hunting',\n value: 'Treasure Hunting',\n id: list1Id\n },\n {\n label: { text: 'Rescuing the princess' },\n text: 'Rescuing the princess',\n value: 'Rescuing the princess',\n id: list2Id\n },\n {\n label: { text: 'Saving a city' },\n text: 'Saving a city',\n value: 'Saving a city',\n id: list3Id\n },\n {\n label: { text: 'Defeating the baron' },\n text: 'Defeating the baron',\n value: 'Defeating the baron',\n id: list4Id\n }\n ]\n})\n\nexport const listElementsStub = {\n list1Id,\n list2Id,\n list3Id,\n list4Id,\n baseElements: listElementsBase\n}\n\n/**\n * @param {Partial<BaseSettings>} partialBaseElements\n * @param {jest.Mock<void, [string, QuestionBaseModel]>} renderMock\n * @returns {Question}\n */\nexport function buildPreviewShortAnswer(partialBaseElements, renderMock) {\n return new Question(\n new QuestionPreviewElements({\n ...baseElements,\n ...partialBaseElements\n }),\n new QuestionRendererStub(renderMock)\n )\n}\n\n/**\n * @import { ListElement } from '~/src/form/form-editor/types.js'\n * @import { PagePreviewPanelMacro } from '~/src/form/form-editor/macros/types.js'\n * @import { BaseSettings, ListElements, RenderContext, QuestionBaseModel, QuestionElements, QuestionRenderer, AutocompleteElements, PageOverviewElements, PageRenderer } from '~/src/form/form-editor/preview/types.js'\n */\n"],"mappings":"AAAA,SAASA,QAAQ;;AAEjB;AACA;AACA;AACA,OAAO,MAAMC,oBAAoB,CAAC;EAChC;AACF;AACA;EACEC,UAAU;;EAEV;AACF;AACA;EACEC,WAAWA,CAACD,UAAU,EAAE;IACtB,IAAI,CAACA,UAAU,GAAGA,UAAU;EAC9B;;EAEA;AACF;AACA;AACA;EACEE,MAAMA,CAACC,gBAAgB,EAAEC,iBAAiB,EAAE;IAC1C,IAAI,CAACJ,UAAU,CAACG,gBAAgB,EAAEC,iBAAiB,CAAC;EACtD;;EAEA;AACF;AACA;AACA;AACA;EACE,OAAOC,SAASA,CAACC,iBAAiB,EAAEC,cAAc,EAAE;IAClD,OAAO,sBAAsB;EAC/B;AACF;;AAEA;AACA;AACA;AACA,OAAO,MAAMC,gBAAgB,CAAC;EAC5B;AACF;AACA;EACER,UAAU;;EAEV;AACF;AACA;EACEC,WAAWA,CAACD,UAAU,EAAE;IACtB,IAAI,CAACA,UAAU,GAAGA,UAAU;EAC9B;;EAEA;AACF;AACA;AACA;EACEE,MAAMA,CAACO,YAAY,EAAEC,qBAAqB,EAAE;IAC1C,IAAI,CAACV,UAAU,CAACS,YAAY,EAAEC,qBAAqB,CAAC;EACtD;;EAEA;AACF;AACA;AACA;AACA;EACE,OAAOL,SAASA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BC,EAAE,EAAEP;EACN,CAAC,EACD;IACEI,KAAK,EAAE;MAAEC,IAAI,EAAE;IAAgB,CAAC;IAChCA,IAAI,EAAE,eAAe;IACrBC,KAAK,EAAE,eAAe;IACtBC,EAAE,EAAEN;EACN,CAAC,EACD;IACEG,KAAK,EAAE;MAAEC,IAAI,EAAE;IAAsB,CAAC;IACtCA,IAAI,EAAE,qBAAqB;IAC3BC,KAAK,EAAE,qBAAqB;IAC5BC,EAAE,EAAEL;EACN,CAAC;AAEL,CAAE;AAEF,OAAO,MAAMM,gBAAgB,GAAG;EAC9BT,OAAO;EACPC,OAAO;EACPC,OAAO;EACPC,OAAO;EACPJ,YAAY,EAAEK;AAChB,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA,OAAO,SAASM,uBAAuBA,CAACC,mBAAmB,EAAEjD,UAAU,EAAE;EACvE,OAAO,IAAIF,QAAQ,CACjB,IAAIa,uBAAuB,CAAC;IAC1B,GAAG0B,YAAY;IACf,GAAGY;EACL,CAAC,CAAC,EACF,IAAIlD,oBAAoB,CAACC,UAAU,CACrC,CAAC;AACH;;AAEA;AACA;AACA;AACA;AACA","ignoreList":[]}
1
+ {"version":3,"file":"preview.js","names":["Question","QuestionRendererStub","renderMock","constructor","render","questionTemplate","questionBaseModel","buildHTML","_questionTemplate","_renderContext","PageRendererStub","pageTemplate","pagePreviewPanelMacro","QuestionPreviewElements","_question","_hintText","_optional","_shortDesc","_content","_items","afterInputsHTML","question","hintText","optional","shortDesc","items","content","values","setPreviewHTML","_value","setPreviewDOM","AutocompletePreviewElements","autocompleteOptions","elements","PagePreviewElements","guidance","heading","addHeading","undefined","length","baseElements","largeTitle","list1Id","list2Id","list3Id","list4Id","listElementsBase","label","text","value","id","listElementsStub","buildPreviewShortAnswer","partialBaseElements"],"sources":["../../../../../src/form/form-editor/__stubs__/preview.js"],"sourcesContent":["import { Question } from '~/src/form/form-editor/preview/question.js'\n\n/**\n * @implements {QuestionRenderer}\n */\nexport class QuestionRendererStub {\n /**\n * @type {jest.Mock<void, [string, QuestionBaseModel]>}\n */\n renderMock\n\n /**\n * @param {jest.Mock<void, [string, QuestionBaseModel]>} renderMock\n */\n constructor(renderMock) {\n this.renderMock = renderMock\n }\n\n /**\n * @param {string} questionTemplate\n * @param {QuestionBaseModel} questionBaseModel\n */\n render(questionTemplate, questionBaseModel) {\n this.renderMock(questionTemplate, questionBaseModel)\n }\n\n /**\n * @returns {string}\n * @param {string} _questionTemplate\n * @param {RenderContext} _renderContext\n */\n static buildHTML(_questionTemplate, _renderContext) {\n return '**** BUILT HTML ****'\n }\n}\n\n/**\n * @implements {PageRenderer}\n */\nexport class PageRendererStub {\n /**\n * @type {jest.Mock<void, [string, PagePreviewPanelMacro]>}\n */\n renderMock\n\n /**\n * @param {jest.Mock<void, [string, PagePreviewPanelMacro]>} renderMock\n */\n constructor(renderMock) {\n this.renderMock = renderMock\n }\n\n /**\n * @param {string} pageTemplate\n * @param {PagePreviewPanelMacro} pagePreviewPanelMacro\n */\n render(pageTemplate, pagePreviewPanelMacro) {\n this.renderMock(pageTemplate, pagePreviewPanelMacro)\n }\n\n /**\n * @returns {string}\n * @param {string} _questionTemplate\n * @param {RenderContext} _renderContext\n */\n static buildHTML(_questionTemplate, _renderContext) {\n return '**** BUILT HTML ****'\n }\n}\n\n/**\n * @implements {ListElements}\n */\nexport class QuestionPreviewElements {\n /**\n * @protected\n */\n _question = ''\n /** @protected */\n _hintText = ''\n /** @protected */\n _optional = false\n /**\n * @type {string}\n * @protected\n */\n _shortDesc = ''\n /**\n * @type {string}\n * @protected\n */\n _content = ''\n /**\n *\n * @type {ListElement[]}\n * @private\n */\n _items = []\n afterInputsHTML = '<div class=\"govuk-inset-text\">No items added yet.</div>'\n\n /**\n * @param {BaseSettings} baseSettings\n */\n constructor({ question, hintText, optional, shortDesc, items, content }) {\n this._question = question\n this._hintText = hintText\n this._optional = optional\n this._shortDesc = shortDesc\n this._items = items\n this._content = content\n }\n\n /**\n * @returns {BaseSettings}\n */\n get values() {\n return {\n question: this._question,\n hintText: this._hintText,\n optional: this._optional,\n shortDesc: this._shortDesc,\n items: this._items,\n content: this._content\n }\n }\n\n /**\n * @param {string} _value\n */\n setPreviewHTML(_value) {\n // Not implemented for server side render\n }\n\n /**\n * @param {HTMLElement} _value\n */\n setPreviewDOM(_value) {\n // Not implemented for server side render\n }\n}\n\n/**\n * @implements {AutocompleteElements}\n */\nexport class AutocompletePreviewElements extends QuestionPreviewElements {\n /**\n * @param {BaseSettings & {autocompleteOptions: string}} elements\n */\n constructor({ autocompleteOptions, ...elements }) {\n super(elements)\n this.autocompleteOptions = autocompleteOptions\n }\n}\n\n/**\n * @implements {PageOverviewElements}\n */\nexport class PagePreviewElements {\n guidance\n heading\n addHeading\n\n /**\n * @param {string} heading\n * @param {string} guidance\n * @param {boolean} [addHeading]\n */\n constructor(heading, guidance = '', addHeading = undefined) {\n this.heading = heading\n this.guidance = guidance\n this.addHeading = addHeading ?? heading.length > 0\n }\n}\n\nexport const baseElements = /** @type {BaseSettings} */ ({\n items: [],\n optional: false,\n question: 'Which quest would you like to pick?',\n hintText: 'Choose one adventure that best suits you.',\n shortDesc: '',\n content: '',\n largeTitle: true\n})\n\nconst list1Id = '414d82a3-4cab-416a-bd54-6b86fbd51120'\nconst list2Id = '801385a4-81e6-4171-96c3-6c6727d97f22'\nconst list3Id = 'e6e3f621-b875-4ca3-a054-cca9149149dd'\nconst list4Id = 'd71b3909-582f-4e90-b6f5-490b89a6eb8f'\n\nconst listElementsBase = /** @type {BaseSettings} */ ({\n ...baseElements,\n items: [\n {\n label: { text: 'Treasure Hunting' },\n text: 'Treasure Hunting',\n value: 'Treasure Hunting',\n id: list1Id\n },\n {\n label: { text: 'Rescuing the princess' },\n text: 'Rescuing the princess',\n value: 'Rescuing the princess',\n id: list2Id\n },\n {\n label: { text: 'Saving a city' },\n text: 'Saving a city',\n value: 'Saving a city',\n id: list3Id\n },\n {\n label: { text: 'Defeating the baron' },\n text: 'Defeating the baron',\n value: 'Defeating the baron',\n id: list4Id\n }\n ]\n})\n\nexport const listElementsStub = {\n list1Id,\n list2Id,\n list3Id,\n list4Id,\n baseElements: listElementsBase\n}\n\n/**\n * @param {Partial<BaseSettings>} partialBaseElements\n * @param {jest.Mock<void, [string, QuestionBaseModel]>} renderMock\n * @returns {Question}\n */\nexport function buildPreviewShortAnswer(partialBaseElements, renderMock) {\n return new Question(\n new QuestionPreviewElements({\n ...baseElements,\n ...partialBaseElements\n }),\n new QuestionRendererStub(renderMock)\n )\n}\n\n/**\n * @import { ListElement } from '~/src/form/form-editor/types.js'\n * @import { PagePreviewPanelMacro } from '~/src/form/form-editor/macros/types.js'\n * @import { BaseSettings, ListElements, RenderContext, QuestionBaseModel, QuestionElements, QuestionRenderer, AutocompleteElements, PageOverviewElements, PageRenderer } from '~/src/form/form-editor/preview/types.js'\n */\n"],"mappings":"AAAA,SAASA,QAAQ;;AAEjB;AACA;AACA;AACA,OAAO,MAAMC,oBAAoB,CAAC;EAChC;AACF;AACA;EACEC,UAAU;;EAEV;AACF;AACA;EACEC,WAAWA,CAACD,UAAU,EAAE;IACtB,IAAI,CAACA,UAAU,GAAGA,UAAU;EAC9B;;EAEA;AACF;AACA;AACA;EACEE,MAAMA,CAACC,gBAAgB,EAAEC,iBAAiB,EAAE;IAC1C,IAAI,CAACJ,UAAU,CAACG,gBAAgB,EAAEC,iBAAiB,CAAC;EACtD;;EAEA;AACF;AACA;AACA;AACA;EACE,OAAOC,SAASA,CAACC,iBAAiB,EAAEC,cAAc,EAAE;IAClD,OAAO,sBAAsB;EAC/B;AACF;;AAEA;AACA;AACA;AACA,OAAO,MAAMC,gBAAgB,CAAC;EAC5B;AACF;AACA;EACER,UAAU;;EAEV;AACF;AACA;EACEC,WAAWA,CAACD,UAAU,EAAE;IACtB,IAAI,CAACA,UAAU,GAAGA,UAAU;EAC9B;;EAEA;AACF;AACA;AACA;EACEE,MAAMA,CAACO,YAAY,EAAEC,qBAAqB,EAAE;IAC1C,IAAI,CAAC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AAEC,IAAI,EAAE;IAAwB,CAAC;IACxCA,IAAI,EAAE,uBAAuB;IAC7BC,KAAK,EAAE,uBAAuB;IAC9BC,EAAE,EAAEP;EACN,CAAC,EACD;IACEI,KAAK,EAAE;MAAEC,IAAI,EAAE;IAAgB,CAAC;IAChCA,IAAI,EAAE,eAAe;IACrBC,KAAK,EAAE,eAAe;IACtBC,EAAE,EAAEN;EACN,CAAC,EACD;IACEG,KAAK,EAAE;MAAEC,IAAI,EAAE;IAAsB,CAAC;IACtCA,IAAI,EAAE,qBAAqB;IAC3BC,KAAK,EAAE,qBAAqB;IAC5BC,EAAE,EAAEL;EACN,CAAC;AAEL,CAAE;AAEF,OAAO,MAAMM,gBAAgB,GAAG;EAC9BT,OAAO;EACPC,OAAO;EACPC,OAAO;EACPC,OAAO;EACPL,YAAY,EAAEM;AAChB,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA,OAAO,SAASM,uBAAuBA,CAACC,mBAAmB,EAAEnD,UAAU,EAAE;EACvE,OAAO,IAAIF,QAAQ,CACjB,IAAIa,uBAAuB,CAAC;IAC1B,GAAG2B,YAAY;IACf,GAAGa;EACL,CAAC,CAAC,EACF,IAAIpD,oBAAoB,CAACC,UAAU,CACrC,CAAC;AACH;;AAEA;AACA;AACA;AACA;AACA","ignoreList":[]}
@@ -7,18 +7,11 @@ export class ComponentElements {
7
7
  * @protected
8
8
  */
9
9
  _component;
10
- /**
11
- * @type {boolean}
12
- * @private
13
- */
14
- _largeTitle = true;
15
10
  /**
16
11
  * @param {ComponentDef} component
17
- * @param {boolean} [largeTitle]
18
12
  */
19
- constructor(component, largeTitle = true) {
13
+ constructor(component) {
20
14
  this._component = component;
21
- this._largeTitle = largeTitle;
22
15
  }
23
16
 
24
17
  /**
@@ -33,8 +26,7 @@ export class ComponentElements {
33
26
  optional: !required,
34
27
  shortDesc: '',
35
28
  items: [],
36
- content: '',
37
- largeTitle: this._largeTitle
29
+ content: ''
38
30
  };
39
31
  }
40
32
 
@@ -1 +1 @@
1
- {"version":3,"file":"component-elements.js","names":["ComponentElements","_component","_largeTitle","constructor","component","largeTitle","_getValues","required","options","question","title","hintText","optional","shortDesc","items","content","values","setPreviewDOM","_element","Error","setPreviewHTML","_value"],"sources":["../../../../../src/form/form-editor/preview/component-elements.js"],"sourcesContent":["/**\n * @implements {QuestionElements}\n */\nexport class ComponentElements {\n /**\n * @type {ComponentDef}\n * @protected\n */\n _component\n /**\n * @type {boolean}\n * @private\n */\n _largeTitle = true\n /**\n * @param {ComponentDef} component\n * @param {boolean} [largeTitle]\n */\n constructor(component, largeTitle = true) {\n this._component = component\n this._largeTitle = largeTitle\n }\n\n /**\n * @protected\n * @returns {BaseSettings}\n */\n _getValues() {\n const required = this._component.options?.required ?? true\n\n return {\n question: this._component.title,\n hintText: '',\n optional: !required,\n shortDesc: '',\n items: [],\n content: '',\n largeTitle: this._largeTitle\n }\n }\n\n /**\n * @returns {BaseSettings}\n */\n get values() {\n const values = this._getValues()\n return values\n }\n\n /**\n * @param {HTMLElement} _element\n */\n setPreviewDOM(_element) {\n throw new Error('Not implemented')\n }\n\n /**\n * @param {string} _value\n */\n setPreviewHTML(_value) {\n throw new Error('Not implemented')\n }\n}\n\n/**\n * @import { ListenerRow, BaseSettings, QuestionElements, QuestionBaseModel, GovukFieldset, DefaultComponent, QuestionRenderer } from '~/src/form/form-editor/preview/types.js'\n * @import { FormComponentsDef, ContentComponentsDef, ComponentDef } from '~/src/components/types.js'\n * @import { ListElement, ListItemReadonly } from '~/src/form/form-editor/types.js'\n */\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAO,MAAMA,iBAAiB,CAAC;EAC7B;AACF;AACA;AACA;EACEC,UAAU;EACV;AACF;AACA;AACA;EACEC,WAAW,GAAG,IAAI;EAClB;AACF;AACA;AACA;EACEC,WAAWA,CAACC,SAAS,EAAEC,UAAU,GAAG,IAAI,EAAE;IACxC,IAAI,CAACJ,UAAU,GAAGG,SAAS;IAC3B,IAAI,CAACF,WAAW,GAAGG,UAAU;EAC/B;;EAEA;AACF;AACA;AACA;EACEC,UAAUA,CAAA,EAAG;IACX,MAAMC,QAAQ,GAAG,IAAI,CAACN,UAAU,CAACO,OAAO,EAAED,QAAQ,IAAI,IAAI;IAE1D,OAAO;MACLE,QAAQ,EAAE,IAAI,CAACR,UAAU,CAACS,KAAK;MAC/BC,QAAQ,EAAE,EAAE;MACZC,QAAQ,EAAE,CAACL,QAAQ;MACnBM,SAAS,EAAE,EAAE;MACbC,KAAK,EAAE,EAAE;MACTC,OAAO,EAAE,EAAE;MACXV,UAAU,EAAE,IAAI,CAACH;IACnB,CAAC;EACH;;EAEA;AACF;AACA;EACE,IAAIc,MAAMA,CAAA,EAAG;IACX,MAAMA,MAAM,GAAG,IAAI,CAACV,UAAU,CAAC,CAAC;IAChC,OAAOU,MAAM;EACf;;EAEA;AACF;AACA;EACEC,aAAaA,CAACC,QAAQ,EAAE;IACtB,MAAM,IAAIC,KAAK,CAAC,iBAAiB,CAAC;EACpC;;EAEA;AACF;AACA;EACEC,cAAcA,CAACC,MAAM,EAAE;IACrB,MAAM,IAAIF,KAAK,CAAC,iBAAiB,CAAC;EACpC;AACF;;AAEA;AACA;AACA;AACA;AACA","ignoreList":[]}
1
+ {"version":3,"file":"component-elements.js","names":["ComponentElements","_component","constructor","component","_getValues","required","options","question","title","hintText","optional","shortDesc","items","content","values","setPreviewDOM","_element","Error","setPreviewHTML","_value"],"sources":["../../../../../src/form/form-editor/preview/component-elements.js"],"sourcesContent":["/**\n * @implements {QuestionElements}\n */\nexport class ComponentElements {\n /**\n * @type {ComponentDef}\n * @protected\n */\n _component\n /**\n * @param {ComponentDef} component\n */\n constructor(component) {\n this._component = component\n }\n\n /**\n * @protected\n * @returns {BaseSettings}\n */\n _getValues() {\n const required = this._component.options?.required ?? true\n\n return {\n question: this._component.title,\n hintText: '',\n optional: !required,\n shortDesc: '',\n items: [],\n content: ''\n }\n }\n\n /**\n * @returns {BaseSettings}\n */\n get values() {\n const values = this._getValues()\n return values\n }\n\n /**\n * @param {HTMLElement} _element\n */\n setPreviewDOM(_element) {\n throw new Error('Not implemented')\n }\n\n /**\n * @param {string} _value\n */\n setPreviewHTML(_value) {\n throw new Error('Not implemented')\n }\n}\n\n/**\n * @import { ListenerRow, BaseSettings, QuestionElements, QuestionBaseModel, GovukFieldset, DefaultComponent, QuestionRenderer } from '~/src/form/form-editor/preview/types.js'\n * @import { FormComponentsDef, ContentComponentsDef, ComponentDef } from '~/src/components/types.js'\n * @import { ListElement, ListItemReadonly } from '~/src/form/form-editor/types.js'\n */\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAO,MAAMA,iBAAiB,CAAC;EAC7B;AACF;AACA;AACA;EACEC,UAAU;EACV;AACF;AACA;EACEC,WAAWA,CAACC,SAAS,EAAE;IACrB,IAAI,CAACF,UAAU,GAAGE,SAAS;EAC7B;;EAEA;AACF;AACA;AACA;EACEC,UAAUA,CAAA,EAAG;IACX,MAAMC,QAAQ,GAAG,IAAI,CAACJ,UAAU,CAACK,OAAO,EAAED,QAAQ,IAAI,IAAI;IAE1D,OAAO;MACLE,QAAQ,EAAE,IAAI,CAACN,UAAU,CAACO,KAAK;MAC/BC,QAAQ,EAAE,EAAE;MACZC,QAAQ,EAAE,CAACL,QAAQ;MACnBM,SAAS,EAAE,EAAE;MACbC,KAAK,EAAE,EAAE;MACTC,OAAO,EAAE;IACX,CAAC;EACH;;EAEA;AACF;AACA;EACE,IAAIC,MAAMA,CAAA,EAAG;IACX,MAAMA,MAAM,GAAG,IAAI,CAACV,UAAU,CAAC,CAAC;IAChC,OAAOU,MAAM;EACf;;EAEA;AACF;AACA;EACEC,aAAaA,CAACC,QAAQ,EAAE;IACtB,MAAM,IAAIC,KAAK,CAAC,iBAAiB,CAAC;EACpC;;EAEA;AACF;AACA;EACEC,cAAcA,CAACC,MAAM,EAAE;IACrB,MAAM,IAAIF,KAAK,CAAC,iBAAiB,CAAC;EACpC;AACF;;AAEA;AACA;AACA;AACA;AACA","ignoreList":[]}
@@ -12,10 +12,9 @@ export class ContentElements extends ComponentElements {
12
12
  _component;
13
13
  /**
14
14
  * @param {Exclude<ContentComponentsDef, ListComponent>} component
15
- * @param {boolean} largeTitle
16
15
  */
17
- constructor(component, largeTitle = true) {
18
- super(component, largeTitle);
16
+ constructor(component) {
17
+ super(component);
19
18
  this._component = component;
20
19
  }
21
20
 
@@ -1 +1 @@
1
- {"version":3,"file":"content.js","names":["ComponentElements","PreviewComponent","ContentElements","_component","constructor","component","largeTitle","_getValues","content","Content","_content","htmlElements","questionRenderer","values","_renderInput","_setContent","value","render"],"sources":["../../../../../src/form/form-editor/preview/content.js"],"sourcesContent":["import { ComponentElements } from '~/src/form/form-editor/preview/component-elements.js'\nimport { PreviewComponent } from '~/src/form/form-editor/preview/preview.js'\n\n/**\n * @implements {QuestionElements}\n */\nexport class ContentElements extends ComponentElements {\n /**\n * @type {Exclude<ContentComponentsDef, ListComponent>}\n * @protected\n */\n _component\n /**\n * @param {Exclude<ContentComponentsDef, ListComponent>} component\n * @param {boolean} largeTitle\n */\n constructor(component, largeTitle = true) {\n super(component, largeTitle)\n this._component = component\n }\n\n /**\n * @protected\n * @returns {BaseSettings}\n */\n _getValues() {\n return {\n ...super._getValues(),\n content: this._component.content\n }\n }\n}\n\n/**\n * @abstract\n * @class Content\n * @classdesc\n * Base of Content preview classes\n */\nexport class Content extends PreviewComponent {\n /**\n * @type {string}\n * @protected\n */\n _content\n\n /**\n * @param {QuestionElements} htmlElements\n * @param {QuestionRenderer} questionRenderer\n */\n constructor(htmlElements, questionRenderer) {\n super(htmlElements, questionRenderer)\n const { content } = htmlElements.values\n\n this._content = content\n }\n\n /**\n * @returns {QuestionBaseModel}\n * @protected\n */\n _renderInput() {\n return {\n ...super._renderInput(),\n content: this.content\n }\n }\n\n /**\n * @param {string} value\n * @protected\n */\n _setContent(value) {\n this._content = value\n }\n\n /**\n * @returns {string}\n */\n get content() {\n return this._content\n }\n\n set content(value) {\n this._setContent(value)\n this.render()\n }\n}\n\n/**\n * @import { ListenerRow, BaseSettings, QuestionElements, QuestionBaseModel, GovukFieldset, DefaultComponent, QuestionRenderer } from '~/src/form/form-editor/preview/types.js'\n * @import { FormComponentsDef, ListComponent, ContentComponentsDef, ComponentDef } from '~/src/components/types.js'\n * @import { ListElement, ListItemReadonly } from '~/src/form/form-editor/types.js'\n */\n"],"mappings":"AAAA,SAASA,iBAAiB;AAC1B,SAASC,gBAAgB;;AAEzB;AACA;AACA;AACA,OAAO,MAAMC,eAAe,SAASF,iBAAiB,CAAC;EACrD;AACF;AACA;AACA;EACEG,UAAU;EACV;AACF;AACA;AACA;EACEC,WAAWA,CAACC,SAAS,EAAEC,UAAU,GAAG,IAAI,EAAE;IACxC,KAAK,CAACD,SAAS,EAAEC,UAAU,CAAC;IAC5B,IAAI,CAACH,UAAU,GAAGE,SAAS;EAC7B;;EAEA;AACF;AACA;AACA;EACEE,UAAUA,CAAA,EAAG;IACX,OAAO;MACL,GAAG,KAAK,CAACA,UAAU,CAAC,CAAC;MACrBC,OAAO,EAAE,IAAI,CAACL,UAAU,CAACK;IAC3B,CAAC;EACH;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,OAAO,SAASR,gBAAgB,CAAC;EAC5C;AACF;AACA;AACA;EACES,QAAQ;;EAER;AACF;AACA;AACA;EACEN,WAAWA,CAACO,YAAY,EAAEC,gBAAgB,EAAE;IAC1C,KAAK,CAACD,YAAY,EAAEC,gBAAgB,CAAC;IACrC,MAAM;MAAEJ;IAAQ,CAAC,GAAGG,YAAY,CAACE,MAAM;IAEvC,IAAI,CAACH,QAAQ,GAAGF,OAAO;EACzB;;EAEA;AACF;AACA;AACA;EACEM,YAAYA,CAAA,EAAG;IACb,OAAO;MACL,GAAG,KAAK,CAACA,YAAY,CAAC,CAAC;MACvBN,OAAO,EAAE,IAAI,CAACA;IAChB,CAAC;EACH;;EAEA;AACF;AACA;AACA;EACEO,WAAWA,CAACC,KAAK,EAAE;IACjB,IAAI,CAACN,QAAQ,GAAGM,KAAK;EACvB;;EAEA;AACF;AACA;EACE,IAAIR,OAAOA,CAAA,EAAG;IACZ,OAAO,IAAI,CAACE,QAAQ;EACtB;EAEA,IAAIF,OAAOA,CAACQ,KAAK,EAAE;IACjB,IAAI,CAACD,WAAW,CAACC,KAAK,CAAC;IACvB,IAAI,CAACC,MAAM,CAAC,CAAC;EACf;AACF;;AAEA;AACA;AACA;AACA;AACA","ignoreList":[]}
1
+ {"version":3,"file":"content.js","names":["ComponentElements","PreviewComponent","ContentElements","_component","constructor","component","_getValues","content","Content","_content","htmlElements","questionRenderer","values","_renderInput","_setContent","value","render"],"sources":["../../../../../src/form/form-editor/preview/content.js"],"sourcesContent":["import { ComponentElements } from '~/src/form/form-editor/preview/component-elements.js'\nimport { PreviewComponent } from '~/src/form/form-editor/preview/preview.js'\n\n/**\n * @implements {QuestionElements}\n */\nexport class ContentElements extends ComponentElements {\n /**\n * @type {Exclude<ContentComponentsDef, ListComponent>}\n * @protected\n */\n _component\n /**\n * @param {Exclude<ContentComponentsDef, ListComponent>} component\n */\n constructor(component) {\n super(component)\n this._component = component\n }\n\n /**\n * @protected\n * @returns {BaseSettings}\n */\n _getValues() {\n return {\n ...super._getValues(),\n content: this._component.content\n }\n }\n}\n\n/**\n * @abstract\n * @class Content\n * @classdesc\n * Base of Content preview classes\n */\nexport class Content extends PreviewComponent {\n /**\n * @type {string}\n * @protected\n */\n _content\n\n /**\n * @param {QuestionElements} htmlElements\n * @param {QuestionRenderer} questionRenderer\n */\n constructor(htmlElements, questionRenderer) {\n super(htmlElements, questionRenderer)\n const { content } = htmlElements.values\n\n this._content = content\n }\n\n /**\n * @returns {QuestionBaseModel}\n * @protected\n */\n _renderInput() {\n return {\n ...super._renderInput(),\n content: this.content\n }\n }\n\n /**\n * @param {string} value\n * @protected\n */\n _setContent(value) {\n this._content = value\n }\n\n /**\n * @returns {string}\n */\n get content() {\n return this._content\n }\n\n set content(value) {\n this._setContent(value)\n this.render()\n }\n}\n\n/**\n * @import { ListenerRow, BaseSettings, QuestionElements, QuestionBaseModel, GovukFieldset, DefaultComponent, QuestionRenderer } from '~/src/form/form-editor/preview/types.js'\n * @import { FormComponentsDef, ListComponent, ContentComponentsDef, ComponentDef } from '~/src/components/types.js'\n * @import { ListElement, ListItemReadonly } from '~/src/form/form-editor/types.js'\n */\n"],"mappings":"AAAA,SAASA,iBAAiB;AAC1B,SAASC,gBAAgB;;AAEzB;AACA;AACA;AACA,OAAO,MAAMC,eAAe,SAASF,iBAAiB,CAAC;EACrD;AACF;AACA;AACA;EACEG,UAAU;EACV;AACF;AACA;EACEC,WAAWA,CAACC,SAAS,EAAE;IACrB,KAAK,CAACA,SAAS,CAAC;IAChB,IAAI,CAACF,UAAU,GAAGE,SAAS;EAC7B;;EAEA;AACF;AACA;AACA;EACEC,UAAUA,CAAA,EAAG;IACX,OAAO;MACL,GAAG,KAAK,CAACA,UAAU,CAAC,CAAC;MACrBC,OAAO,EAAE,IAAI,CAACJ,UAAU,CAACI;IAC3B,CAAC;EACH;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,OAAO,SAASP,gBAAgB,CAAC;EAC5C;AACF;AACA;AACA;EACEQ,QAAQ;;EAER;AACF;AACA;AACA;EACEL,WAAWA,CAACM,YAAY,EAAEC,gBAAgB,EAAE;IAC1C,KAAK,CAACD,YAAY,EAAEC,gBAAgB,CAAC;IACrC,MAAM;MAAEJ;IAAQ,CAAC,GAAGG,YAAY,CAACE,MAAM;IAEvC,IAAI,CAACH,QAAQ,GAAGF,OAAO;EACzB;;EAEA;AACF;AACA;AACA;EACEM,YAAYA,CAAA,EAAG;IACb,OAAO;MACL,GAAG,KAAK,CAACA,YAAY,CAAC,CAAC;MACvBN,OAAO,EAAE,IAAI,CAACA;IAChB,CAAC;EACH;;EAEA;AACF;AACA;AACA;EACEO,WAAWA,CAACC,KAAK,EAAE;IACjB,IAAI,CAACN,QAAQ,GAAGM,KAAK;EACvB;;EAEA;AACF;AACA;EACE,IAAIR,OAAOA,CAAA,EAAG;IACZ,OAAO,IAAI,CAACE,QAAQ;EACtB;EAEA,IAAIF,OAAOA,CAACQ,KAAK,EAAE;IACjB,IAAI,CAACD,WAAW,CAACC,KAAK,CAAC;IACvB,IAAI,CAACC,MAAM,CAAC,CAAC;EACf;AACF;;AAEA;AACA;AACA;AACA;AACA","ignoreList":[]}
@@ -26,6 +26,7 @@ export class PagePreviewElements {
26
26
  * @private
27
27
  */
28
28
  _page;
29
+
29
30
  /**
30
31
  * @param {Page} page
31
32
  */
@@ -42,6 +43,9 @@ export class PagePreviewElements {
42
43
  const [possibleGuidanceComponent] = this._page.components;
43
44
  return possibleGuidanceComponent.type === ComponentType.Markdown ? possibleGuidanceComponent.content : '';
44
45
  }
46
+ get addHeading() {
47
+ return this._page.title.length > 0;
48
+ }
45
49
  }
46
50
 
47
51
  /**
@@ -89,6 +93,11 @@ export class PreviewPageController {
89
93
  * @protected
90
94
  */
91
95
  _guidanceComponent;
96
+ /**
97
+ * @type {boolean}
98
+ * @private
99
+ */
100
+ _showTitle = true;
92
101
  /**
93
102
  * @param {ComponentDef[]} components
94
103
  * @param {PageOverviewElements} elements
@@ -96,12 +105,13 @@ export class PreviewPageController {
96
105
  * @param {PageRenderer} renderer
97
106
  */
98
107
  constructor(components, elements, definition, renderer) {
99
- const questions = components.map(mapComponentToPreviewQuestion(questionRenderer, definition, elements.heading.length > 0));
108
+ const questions = components.map(mapComponentToPreviewQuestion(questionRenderer, definition));
100
109
  const firstQuestion = /** @type { Markdown | undefined | Question } */
101
110
  questions.shift();
102
111
  this._guidanceComponent = PreviewPageController.getOrCreateGuidanceComponent(firstQuestion);
103
112
  this._guidanceText = elements.guidance;
104
113
  this._components = this.#constructComponents(firstQuestion, questions);
114
+ this._showTitle = elements.addHeading;
105
115
  this.#pageRenderer = renderer;
106
116
  this.#title = elements.heading;
107
117
  }
@@ -134,10 +144,56 @@ export class PreviewPageController {
134
144
  */
135
145
  get components() {
136
146
  const componentsWithGuidance = /** @type {Question[]} */[...this._guidanceComponents, ...this._components];
137
- return componentsWithGuidance.map(component => ({
138
- model: component.renderInput,
139
- questionType: component.componentType
140
- }));
147
+ return componentsWithGuidance.map(component => {
148
+ return {
149
+ model: this._overrideComponentHeading(component),
150
+ questionType: component.componentType
151
+ };
152
+ });
153
+ }
154
+
155
+ /**
156
+ * @returns {boolean}
157
+ */
158
+ get showLargeTitle() {
159
+ const componentsLength = this._components.length + this._guidanceComponents.length;
160
+ if (componentsLength > 1 || this._highlighted === 'title') {
161
+ return false;
162
+ }
163
+ // |_ one component and title not highlighted
164
+ if (this.#title.trim() === this._components[0].question.trim()) {
165
+ return true;
166
+ }
167
+ // titles not the same
168
+
169
+ return !this._showTitle; // add page heading deselected?
170
+ }
171
+
172
+ /**
173
+ * @param {PreviewComponent} component
174
+ * @returns {QuestionBaseModel}
175
+ */
176
+ _overrideComponentHeading(component) {
177
+ const largeTitle = this.showLargeTitle;
178
+ const fieldset = component.renderInput.fieldset ? {
179
+ fieldset: {
180
+ legend: {
181
+ ...component.renderInput.fieldset.legend,
182
+ classes: largeTitle ? 'govuk-fieldset__legend--l' : 'govuk-fieldset__legend--m'
183
+ }
184
+ }
185
+ } : {};
186
+ const label = component.renderInput.label ? {
187
+ label: {
188
+ ...component.renderInput.label,
189
+ classes: largeTitle ? 'govuk-label--l' : 'govuk-label--m'
190
+ }
191
+ } : {};
192
+ return {
193
+ ...component.renderInput,
194
+ ...fieldset,
195
+ ...label
196
+ };
141
197
  }
142
198
  set guidanceText(text) {
143
199
  this._guidanceText = text;
@@ -145,8 +201,23 @@ export class PreviewPageController {
145
201
  this.render();
146
202
  }
147
203
  get guidanceText() {
204
+ if (!this._showTitle) {
205
+ return '';
206
+ }
148
207
  return this._guidanceText;
149
208
  }
209
+
210
+ /**
211
+ *
212
+ * @param {boolean} showTitle
213
+ */
214
+ set showTitle(showTitle) {
215
+ this._showTitle = showTitle;
216
+ this.render();
217
+ }
218
+ get showTitle() {
219
+ return this._showTitle;
220
+ }
150
221
  get guidance() {
151
222
  return {
152
223
  text: this.guidanceText,
@@ -167,11 +238,24 @@ export class PreviewPageController {
167
238
  this.#pageRenderer.render(this._pageTemplate, this);
168
239
  }
169
240
 
241
+ /**
242
+ * @returns {boolean}
243
+ */
244
+ get titleAndFirstTitleSame() {
245
+ return this._components.length > 0 && this.#title.trim() === this._components[0].question.trim() && this.components.length === 1 && this._highlighted !== 'title';
246
+ }
247
+
170
248
  /**
171
249
  * @returns {string}
172
250
  */
173
251
  get title() {
174
- return this.#title;
252
+ if (!this._showTitle || this.titleAndFirstTitleSame) {
253
+ return '';
254
+ }
255
+ if (this.#title.length) {
256
+ return this.#title;
257
+ }
258
+ return 'Page heading';
175
259
  }
176
260
 
177
261
  /**
@@ -239,6 +323,7 @@ export class PreviewPageController {
239
323
  /**
240
324
  * @import { PageRenderer, PageOverviewElements, QuestionRenderer, QuestionBaseModel } from '~/src/form/form-editor/preview/types.js'
241
325
  * @import { Question } from '~/src/form/form-editor/preview/question.js'
326
+ * @import { PreviewComponent } from '~/src/form/form-editor/preview/preview.js'
242
327
  * @import { FormDefinition, Page } from '~/src/form/form-definition/types.js'
243
328
  * @import { ComponentDef, MarkdownComponent } from '~/src/components/types.js'
244
329
  * @import { PagePreviewComponent, PagePreviewPanelMacro } from '~/src/form/form-editor/macros/types.js'
@@ -1 +1 @@
1
- {"version":3,"file":"page-controller.js","names":["ComponentType","HIGHLIGHT_CLASS","ContentElements","mapComponentToPreviewQuestion","Markdown","hasComponents","questionRenderer","render","_questionTemplate","_questionBaseModel","PagePreviewElements","_page","constructor","page","heading","title","guidance","components","length","possibleGuidanceComponent","type","content","PreviewPageController","PATH","_pageTemplate","_components","pageRenderer","_highlighted","undefined","_guidanceText","_emptyGuidance","createGuidanceComponent","_guidanceComponent","elements","definition","renderer","questions","map","firstQuestion","shift","getOrCreateGuidanceComponent","constructComponents","#constructComponents","_guidanceComponents","componentsWithGuidance","component","model","renderInput","questionType","componentType","guidanceText","text","classes","pageTitle","value","highlightTitle","setHighLighted","guidanceElement","name","options","guidanceComponent","highlightContent","highlightGuidance","highlightSection","clearHighlight","unHighlightContent"],"sources":["../../../../../../src/form/form-editor/preview/controller/page-controller.js"],"sourcesContent":["import { ComponentType } from '~/src/components/enums.js'\nimport { HIGHLIGHT_CLASS } from '~/src/form/form-editor/preview/constants.js'\nimport { ContentElements } from '~/src/form/form-editor/preview/content.js'\nimport { mapComponentToPreviewQuestion } from '~/src/form/form-editor/preview/helpers.js'\nimport { Markdown } from '~/src/form/form-editor/preview/markdown.js'\nimport { hasComponents } from '~/src/pages/helpers.js'\n/**\n * @type {QuestionRenderer}\n */\nconst questionRenderer = {\n /**\n * @param {string} _questionTemplate\n * @param {QuestionBaseModel} _questionBaseModel\n */\n render(_questionTemplate, _questionBaseModel) {\n //\n }\n}\n\n/**\n * @implements {PageOverviewElements}\n */\nexport class PagePreviewElements {\n /**\n * @type {Page}\n * @private\n */\n _page\n /**\n * @param {Page} page\n */\n constructor(page) {\n this._page = page\n }\n\n get heading() {\n return this._page.title\n }\n\n get guidance() {\n if (!hasComponents(this._page) || !this._page.components.length) {\n return ''\n }\n\n const [possibleGuidanceComponent] = this._page.components\n\n return possibleGuidanceComponent.type === ComponentType.Markdown\n ? possibleGuidanceComponent.content\n : ''\n }\n}\n\n/**\n * @implements {PagePreviewPanelMacro}\n */\nexport class PreviewPageController {\n static PATH = 'preview-controllers/'\n /**\n * @type {string}\n * @protected\n */\n _pageTemplate = PreviewPageController.PATH + 'page-controller.njk'\n /**\n * @protected\n * @type {Question[]}\n */\n _components = []\n /**\n * @type {string}\n */\n #title = ''\n /**\n *\n * @type {PageRenderer}\n */\n #pageRenderer\n /**\n * @type { undefined | 'title' | 'guidance'}\n * @protected\n */\n _highlighted = undefined\n /**\n * @type {string}\n * @private\n */\n _guidanceText = ''\n /**\n * @type {Markdown}\n * @private\n */\n _emptyGuidance = PreviewPageController.createGuidanceComponent()\n /**\n *\n * @type {Markdown}\n * @protected\n */\n _guidanceComponent\n /**\n * @param {ComponentDef[]} components\n * @param {PageOverviewElements} elements\n * @param {FormDefinition} definition\n * @param {PageRenderer} renderer\n */\n constructor(components, elements, definition, renderer) {\n const questions = components.map(\n mapComponentToPreviewQuestion(\n questionRenderer,\n definition,\n elements.heading.length > 0\n )\n )\n const firstQuestion = /** @type { Markdown | undefined | Question } */ (\n questions.shift()\n )\n\n this._guidanceComponent =\n PreviewPageController.getOrCreateGuidanceComponent(firstQuestion)\n this._guidanceText = elements.guidance\n this._components = this.#constructComponents(firstQuestion, questions)\n\n this.#pageRenderer = renderer\n this.#title = elements.heading\n }\n\n /**\n * @param { Question | Markdown | undefined} firstQuestion\n * @param {Question[]} questions\n * @returns {Question[]}\n */\n #constructComponents(firstQuestion, questions) {\n return firstQuestion instanceof Markdown || firstQuestion === undefined\n ? questions\n : [firstQuestion, ...questions]\n }\n\n /**\n * @returns {Markdown[]}\n * @private\n */\n get _guidanceComponents() {\n if (this._guidanceText.length) {\n return [this._guidanceComponent]\n }\n if (this._highlighted === 'guidance') {\n return [this._emptyGuidance]\n }\n return []\n }\n\n /**\n * @returns {PagePreviewComponent[]}\n */\n get components() {\n const componentsWithGuidance = /** @type {Question[]} */ ([\n ...this._guidanceComponents,\n ...this._components\n ])\n\n return componentsWithGuidance.map((component) => ({\n model: component.renderInput,\n questionType: component.componentType\n }))\n }\n\n set guidanceText(text) {\n this._guidanceText = text\n this._guidanceComponent.content = text\n this.render()\n }\n\n get guidanceText() {\n return this._guidanceText\n }\n\n get guidance() {\n return {\n text: this.guidanceText,\n classes: this._highlighted === 'guidance' ? 'highlight' : ''\n }\n }\n\n /**\n * @returns {{ text: string, classes: string }}\n */\n get pageTitle() {\n return {\n text: this.title,\n classes: this._highlighted === 'title' ? HIGHLIGHT_CLASS : ''\n }\n }\n\n render() {\n this.#pageRenderer.render(this._pageTemplate, this)\n }\n\n /**\n * @returns {string}\n */\n get title() {\n return this.#title\n }\n\n /**\n * @param {string} value\n */\n set title(value) {\n this.#title = value\n this.render()\n }\n\n highlightTitle() {\n this.setHighLighted('title')\n }\n\n /**\n * Creates a dummy component for when guidance is highlighted\n * but no guidance text exists\n * @returns {Markdown}\n */\n static createGuidanceComponent() {\n const guidanceElement = new ContentElements({\n type: ComponentType.Markdown,\n title: 'Guidance component',\n name: 'guidanceComponent',\n content: 'Guidance text',\n options: {}\n })\n const guidanceComponent = new Markdown(guidanceElement, questionRenderer)\n\n // the dummy component should always be highlighted\n guidanceComponent.highlightContent()\n return guidanceComponent\n }\n\n /**\n * Helper method to return the guidance or a new one\n * @param { Markdown | Question | undefined } guidanceComponent\n * @returns {Markdown}\n * @private\n */\n static getOrCreateGuidanceComponent(guidanceComponent) {\n if (guidanceComponent instanceof Markdown) {\n return guidanceComponent\n }\n return PreviewPageController.createGuidanceComponent()\n }\n\n highlightGuidance() {\n this._guidanceComponent.highlightContent()\n this.setHighLighted('guidance')\n }\n\n /**\n * @param {'title'|'guidance'} highlightSection\n */\n setHighLighted(highlightSection) {\n this._highlighted = highlightSection\n this.render()\n }\n\n clearHighlight() {\n this._highlighted = undefined\n\n this._guidanceComponent.unHighlightContent()\n this.render()\n }\n}\n\n/**\n * @import { PageRenderer, PageOverviewElements, QuestionRenderer, QuestionBaseModel } from '~/src/form/form-editor/preview/types.js'\n * @import { Question } from '~/src/form/form-editor/preview/question.js'\n * @import { FormDefinition, Page } from '~/src/form/form-definition/types.js'\n * @import { ComponentDef, MarkdownComponent } from '~/src/components/types.js'\n * @import { PagePreviewComponent, PagePreviewPanelMacro } from '~/src/form/form-editor/macros/types.js'\n */\n"],"mappings":"AAAA,SAASA,aAAa;AACtB,SAASC,eAAe;AACxB,SAASC,eAAe;AACxB,SAASC,6BAA6B;AACtC,SAASC,QAAQ;AACjB,SAASC,aAAa;AACtB;AACA;AACA;AACA,MAAMC,gBAAgB,GAAG;EACvB;AACF;AACA;AACA;EACEC,MAAMA,CAACC,iBAAiB,EAAEC,kBAAkB,EAAE;IAC5C;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AC1CkB,IAAI,EAAEpB,aAAa,CAACI,QAAQ;MAC5BW,KAAK,EAAE,oBAAoB;MAC3B2C,IAAI,EAAE,mBAAmB;MACzBrC,OAAO,EAAE,eAAe;MACxBsC,OAAO,EAAE,CAAC;IACZ,CAAC,CAAC;IACF,MAAMC,iBAAiB,GAAG,IAAIxD,QAAQ,CAACqD,eAAe,EAAEnD,gBAAgB,CAAC;;IAEzE;IACAsD,iBAAiB,CAACC,gBAAgB,CAAC,CAAC;IACpC,OAAOD,iBAAiB;EAC1B;;EAEA;AACF;AACA;AACA;AACA;AACA;EACE,OAAOpB,4BAA4BA,CAACoB,iBAAiB,EAAE;IACrD,IAAIA,iBAAiB,YAAYxD,QAAQ,EAAE;MACzC,OAAOwD,iBAAiB;IAC1B;IACA,OAAOtC,qBAAqB,CAACS,uBAAuB,CAAC,CAAC;EACxD;EAEA+B,iBAAiBA,CAAA,EAAG;IAClB,IAAI,CAAC9B,kBAAkB,CAAC6B,gBAAgB,CAAC,CAAC;IAC1C,IAAI,CAACL,cAAc,CAAC,UAAU,CAAC;EACjC;;EAEA;AACF;AACA;EACEA,cAAcA,CAACO,gBAAgB,EAAE;IAC/B,IAAI,CAACpC,YAAY,GAAGoC,gBAAgB;IACpC,IAAI,CAACxD,MAAM,CAAC,CAAC;EACf;EAEAyD,cAAcA,CAAA,EAAG;IACf,IAAI,CAACrC,YAAY,GAAGC,SAAS;IAE7B,IAAI,CAACI,kBAAkB,CAACiC,kBAAkB,CAAC,CAAC;IAC5C,IAAI,CAAC1D,MAAM,CAAC,CAAC;EACf;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
1
+ {"version":3,"file":"page-controller.js","names":["ComponentType","HIGHLIGHT_CLASS","ContentElements","mapComponentToPreviewQuestion","Markdown","hasComponents","questionRenderer","render","_questionTemplate","_questionBaseModel","PagePreviewElements","_page","constructor","page","heading","title","guidance","components","length","possibleGuidanceComponent","type","content","addHeading","PreviewPageController","PATH","_pageTemplate","_components","pageRenderer","_highlighted","undefined","_guidanceText","_emptyGuidance","createGuidanceComponent","_guidanceComponent","_showTitle","elements","definition","renderer","questions","map","firstQuestion","shift","getOrCreateGuidanceComponent","constructComponents","#constructComponents","_guidanceComponents","componentsWithGuidance","component","model","_overrideComponentHeading","questionType","componentType","showLargeTitle","componentsLength","trim","question","largeTitle","fieldset","renderInput","legend","classes","label","guidanceText","text","showTitle","pageTitle","titleAndFirstTitleSame","value","highlightTitle","setHighLighted","guidanceElement","name","options","guidanceComponent","highlightContent","highlightGuidance","highlightSection","clearHighlight","unHighlightContent"],"sources":["../../../../../../src/form/form-editor/preview/controller/page-controller.js"],"sourcesContent":["import { ComponentType } from '~/src/components/enums.js'\nimport { HIGHLIGHT_CLASS } from '~/src/form/form-editor/preview/constants.js'\nimport { ContentElements } from '~/src/form/form-editor/preview/content.js'\nimport { mapComponentToPreviewQuestion } from '~/src/form/form-editor/preview/helpers.js'\nimport { Markdown } from '~/src/form/form-editor/preview/markdown.js'\nimport { hasComponents } from '~/src/pages/helpers.js'\n/**\n * @type {QuestionRenderer}\n */\nconst questionRenderer = {\n /**\n * @param {string} _questionTemplate\n * @param {QuestionBaseModel} _questionBaseModel\n */\n render(_questionTemplate, _questionBaseModel) {\n //\n }\n}\n\n/**\n * @implements {PageOverviewElements}\n */\nexport class PagePreviewElements {\n /**\n * @type {Page}\n * @private\n */\n _page\n\n /**\n * @param {Page} page\n */\n constructor(page) {\n this._page = page\n }\n\n get heading() {\n return this._page.title\n }\n\n get guidance() {\n if (!hasComponents(this._page) || !this._page.components.length) {\n return ''\n }\n\n const [possibleGuidanceComponent] = this._page.components\n\n return possibleGuidanceComponent.type === ComponentType.Markdown\n ? possibleGuidanceComponent.content\n : ''\n }\n\n get addHeading() {\n return this._page.title.length > 0\n }\n}\n\n/**\n * @implements {PagePreviewPanelMacro}\n */\nexport class PreviewPageController {\n static PATH = 'preview-controllers/'\n /**\n * @type {string}\n * @protected\n */\n _pageTemplate = PreviewPageController.PATH + 'page-controller.njk'\n /**\n * @protected\n * @type {Question[]}\n */\n _components = []\n /**\n * @type {string}\n */\n #title = ''\n /**\n *\n * @type {PageRenderer}\n */\n #pageRenderer\n /**\n * @type { undefined | 'title' | 'guidance'}\n * @protected\n */\n _highlighted = undefined\n /**\n * @type {string}\n * @private\n */\n _guidanceText = ''\n /**\n * @type {Markdown}\n * @private\n */\n _emptyGuidance = PreviewPageController.createGuidanceComponent()\n /**\n *\n * @type {Markdown}\n * @protected\n */\n _guidanceComponent\n /**\n * @type {boolean}\n * @private\n */\n _showTitle = true\n /**\n * @param {ComponentDef[]} components\n * @param {PageOverviewElements} elements\n * @param {FormDefinition} definition\n * @param {PageRenderer} renderer\n */\n constructor(components, elements, definition, renderer) {\n const questions = components.map(\n mapComponentToPreviewQuestion(questionRenderer, definition)\n )\n const firstQuestion = /** @type { Markdown | undefined | Question } */ (\n questions.shift()\n )\n\n this._guidanceComponent =\n PreviewPageController.getOrCreateGuidanceComponent(firstQuestion)\n this._guidanceText = elements.guidance\n this._components = this.#constructComponents(firstQuestion, questions)\n this._showTitle = elements.addHeading\n\n this.#pageRenderer = renderer\n this.#title = elements.heading\n }\n\n /**\n * @param { Question | Markdown | undefined} firstQuestion\n * @param {Question[]} questions\n * @returns {Question[]}\n */\n #constructComponents(firstQuestion, questions) {\n return firstQuestion instanceof Markdown || firstQuestion === undefined\n ? questions\n : [firstQuestion, ...questions]\n }\n\n /**\n * @returns {Markdown[]}\n * @private\n */\n get _guidanceComponents() {\n if (this._guidanceText.length) {\n return [this._guidanceComponent]\n }\n if (this._highlighted === 'guidance') {\n return [this._emptyGuidance]\n }\n return []\n }\n\n /**\n * @returns {PagePreviewComponent[]}\n */\n get components() {\n const componentsWithGuidance = /** @type {Question[]} */ ([\n ...this._guidanceComponents,\n ...this._components\n ])\n\n return componentsWithGuidance.map((component) => {\n return {\n model: this._overrideComponentHeading(component),\n questionType: component.componentType\n }\n })\n }\n\n /**\n * @returns {boolean}\n */\n get showLargeTitle() {\n const componentsLength =\n this._components.length + this._guidanceComponents.length\n\n if (componentsLength > 1 || this._highlighted === 'title') {\n return false\n }\n // |_ one component and title not highlighted\n if (this.#title.trim() === this._components[0].question.trim()) {\n return true\n }\n // titles not the same\n\n return !this._showTitle // add page heading deselected?\n }\n\n /**\n * @param {PreviewComponent} component\n * @returns {QuestionBaseModel}\n */\n _overrideComponentHeading(component) {\n const largeTitle = this.showLargeTitle\n\n const fieldset = component.renderInput.fieldset\n ? {\n fieldset: {\n legend: {\n ...component.renderInput.fieldset.legend,\n classes: largeTitle\n ? 'govuk-fieldset__legend--l'\n : 'govuk-fieldset__legend--m'\n }\n }\n }\n : {}\n\n const label = component.renderInput.label\n ? {\n label: {\n ...component.renderInput.label,\n classes: largeTitle ? 'govuk-label--l' : 'govuk-label--m'\n }\n }\n : {}\n\n return {\n ...component.renderInput,\n ...fieldset,\n ...label\n }\n }\n\n set guidanceText(text) {\n this._guidanceText = text\n this._guidanceComponent.content = text\n this.render()\n }\n\n get guidanceText() {\n if (!this._showTitle) {\n return ''\n }\n return this._guidanceText\n }\n\n /**\n *\n * @param {boolean} showTitle\n */\n set showTitle(showTitle) {\n this._showTitle = showTitle\n this.render()\n }\n\n get showTitle() {\n return this._showTitle\n }\n\n get guidance() {\n return {\n text: this.guidanceText,\n classes: this._highlighted === 'guidance' ? 'highlight' : ''\n }\n }\n\n /**\n * @returns {{ text: string, classes: string }}\n */\n get pageTitle() {\n return {\n text: this.title,\n classes: this._highlighted === 'title' ? HIGHLIGHT_CLASS : ''\n }\n }\n\n render() {\n this.#pageRenderer.render(this._pageTemplate, this)\n }\n\n /**\n * @returns {boolean}\n */\n get titleAndFirstTitleSame() {\n return (\n this._components.length > 0 &&\n this.#title.trim() === this._components[0].question.trim() &&\n this.components.length === 1 &&\n this._highlighted !== 'title'\n )\n }\n\n /**\n * @returns {string}\n */\n get title() {\n if (!this._showTitle || this.titleAndFirstTitleSame) {\n return ''\n }\n if (this.#title.length) {\n return this.#title\n }\n return 'Page heading'\n }\n\n /**\n * @param {string} value\n */\n set title(value) {\n this.#title = value\n this.render()\n }\n\n highlightTitle() {\n this.setHighLighted('title')\n }\n\n /**\n * Creates a dummy component for when guidance is highlighted\n * but no guidance text exists\n * @returns {Markdown}\n */\n static createGuidanceComponent() {\n const guidanceElement = new ContentElements({\n type: ComponentType.Markdown,\n title: 'Guidance component',\n name: 'guidanceComponent',\n content: 'Guidance text',\n options: {}\n })\n const guidanceComponent = new Markdown(guidanceElement, questionRenderer)\n\n // the dummy component should always be highlighted\n guidanceComponent.highlightContent()\n return guidanceComponent\n }\n\n /**\n * Helper method to return the guidance or a new one\n * @param { Markdown | Question | undefined } guidanceComponent\n * @returns {Markdown}\n * @private\n */\n static getOrCreateGuidanceComponent(guidanceComponent) {\n if (guidanceComponent instanceof Markdown) {\n return guidanceComponent\n }\n return PreviewPageController.createGuidanceComponent()\n }\n\n highlightGuidance() {\n this._guidanceComponent.highlightContent()\n this.setHighLighted('guidance')\n }\n\n /**\n * @param {'title'|'guidance'} highlightSection\n */\n setHighLighted(highlightSection) {\n this._highlighted = highlightSection\n this.render()\n }\n\n clearHighlight() {\n this._highlighted = undefined\n\n this._guidanceComponent.unHighlightContent()\n this.render()\n }\n}\n\n/**\n * @import { PageRenderer, PageOverviewElements, QuestionRenderer, QuestionBaseModel } from '~/src/form/form-editor/preview/types.js'\n * @import { Question } from '~/src/form/form-editor/preview/question.js'\n * @import { PreviewComponent } from '~/src/form/form-editor/preview/preview.js'\n * @import { FormDefinition, Page } from '~/src/form/form-definition/types.js'\n * @import { ComponentDef, MarkdownComponent } from '~/src/components/types.js'\n * @import { PagePreviewComponent, PagePreviewPanelMacro } from '~/src/form/form-editor/macros/types.js'\n */\n"],"mappings":"AAAA,SAASA,aAAa;AACtB,SAASC,eAAe;AACxB,SAASC,eAAe;AACxB,SAASC,6BAA6B;AACtC,SAASC,QAAQ;AACjB,SAASC,aAAa;AACtB;AACA;AACA;AACA,MAAMC,gBAAgB,GAAG;EAC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,gBAAgB,CAAC,CAAC;IACpC,OAAOD,iBAAiB;EAC1B;;EAEA;AACF;AACA;AACA;AACA;AACA;EACE,OAAO/B,4BAA4BA,CAAC+B,iBAAiB,EAAE;IACrD,IAAIA,iBAAiB,YAAYrE,QAAQ,EAAE;MACzC,OAAOqE,iBAAiB;IAC1B;IACA,OAAOlD,qBAAqB,CAACS,uBAAuB,CAAC,CAAC;EACxD;EAEA2C,iBAAiBA,CAAA,EAAG;IAClB,IAAI,CAAC1C,kBAAkB,CAACyC,gBAAgB,CAAC,CAAC;IAC1C,IAAI,CAACL,cAAc,CAAC,UAAU,CAAC;EACjC;;EAEA;AACF;AACA;EACEA,cAAcA,CAACO,gBAAgB,EAAE;IAC/B,IAAI,CAAChD,YAAY,GAAGgD,gBAAgB;IACpC,IAAI,CAACrE,MAAM,CAAC,CAAC;EACf;EAEAsE,cAAcA,CAAA,EAAG;IACf,IAAI,CAACjD,YAAY,GAAGC,SAAS;IAE7B,IAAI,CAACI,kBAAkB,CAAC6C,kBAAkB,CAAC,CAAC;IAC5C,IAAI,CAACvE,MAAM,CAAC,CAAC;EACf;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
@@ -48,10 +48,9 @@ const InputFieldComponentDictionary = {
48
48
  /**
49
49
  * @param {QuestionRenderer} questionRenderer
50
50
  * @param {FormDefinition} definition
51
- * @param {boolean} hasTitle
52
51
  * @returns {(component: ComponentDef) => Question}
53
52
  */
54
- export function mapComponentToPreviewQuestion(questionRenderer, definition, hasTitle) {
53
+ export function mapComponentToPreviewQuestion(questionRenderer, definition) {
55
54
  return /** @type {(component: ComponentDef) => Question} */component => {
56
55
  /**
57
56
  * @type {QuestionElements}
@@ -59,13 +58,13 @@ export function mapComponentToPreviewQuestion(questionRenderer, definition, hasT
59
58
  let questionElements;
60
59
  if (hasSelectionFields(component) && hasListField(component)) {
61
60
  const list = findDefinitionListFromComponent(component, definition);
62
- questionElements = new ListComponentElements(component, list, !hasTitle);
61
+ questionElements = new ListComponentElements(component, list);
63
62
  } else if (hasInputField(component) || component.type === ComponentType.YesNoField) {
64
- questionElements = new QuestionComponentElements(component, !hasTitle);
63
+ questionElements = new QuestionComponentElements(component);
65
64
  } else if (hasContentField(component)) {
66
- questionElements = new ContentElements(component, !hasTitle);
65
+ questionElements = new ContentElements(component);
67
66
  } else {
68
- questionElements = new ComponentElements(component, !hasTitle);
67
+ questionElements = new ComponentElements(component);
69
68
  }
70
69
  const QuestionConstructor = InputFieldComponentDictionary[component.type];
71
70
  return new QuestionConstructor(questionElements, questionRenderer);
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.js","names":["ComponentType","AutocompleteListQuestion","CheckboxQuestion","ComponentElements","ContentElements","DateInputQuestion","EmailAddressQuestion","ListQuestion","LongAnswerQuestion","Markdown","MonthYearQuestion","NumberOnlyQuestion","PhoneNumberQuestion","RadioQuestion","SelectQuestion","ShortAnswerQuestion","SupportingEvidenceQuestion","UkAddressQuestion","YesNoQuestion","findDefinitionListFromComponent","ListComponentElements","QuestionComponentElements","hasContentField","hasInputField","hasListField","hasSelectionFields","InputFieldComponentDictionary","TextField","Details","InsetText","Html","List","EmailAddressField","NumberField","MultilineTextField","TelephoneNumberField","MonthYearField","DatePartsField","UkAddressField","AutocompleteField","RadiosField","CheckboxesField","SelectField","YesNoField","FileUploadField","mapComponentToPreviewQuestion","questionRenderer","definition","hasTitle","component","questionElements","list","type","QuestionConstructor"],"sources":["../../../../../src/form/form-editor/preview/helpers.js"],"sourcesContent":["import { ComponentType } from '~/src/components/enums.js'\nimport { AutocompleteListQuestion } from '~/src/form/form-editor/preview/autocomplete.js'\nimport { CheckboxQuestion } from '~/src/form/form-editor/preview/checkbox.js'\nimport { ComponentElements } from '~/src/form/form-editor/preview/component-elements.js'\nimport { ContentElements } from '~/src/form/form-editor/preview/content.js'\nimport { DateInputQuestion } from '~/src/form/form-editor/preview/date-input.js'\nimport { EmailAddressQuestion } from '~/src/form/form-editor/preview/email-address.js'\nimport { ListQuestion } from '~/src/form/form-editor/preview/list.js'\nimport { LongAnswerQuestion } from '~/src/form/form-editor/preview/long-answer.js'\nimport { Markdown } from '~/src/form/form-editor/preview/markdown.js'\nimport { MonthYearQuestion } from '~/src/form/form-editor/preview/month-year.js'\nimport { NumberOnlyQuestion } from '~/src/form/form-editor/preview/number-only.js'\nimport { PhoneNumberQuestion } from '~/src/form/form-editor/preview/phone-number.js'\nimport { RadioQuestion } from '~/src/form/form-editor/preview/radio.js'\nimport { SelectQuestion } from '~/src/form/form-editor/preview/select.js'\nimport { ShortAnswerQuestion } from '~/src/form/form-editor/preview/short-answer.js'\nimport { SupportingEvidenceQuestion } from '~/src/form/form-editor/preview/supporting-evidence.js'\nimport { UkAddressQuestion } from '~/src/form/form-editor/preview/uk-address.js'\nimport { YesNoQuestion } from '~/src/form/form-editor/preview/yes-no.js'\nimport { findDefinitionListFromComponent } from '~/src/form/utils/list.js'\nimport {\n ListComponentElements,\n QuestionComponentElements,\n hasContentField,\n hasInputField,\n hasListField,\n hasSelectionFields\n} from '~/src/index.js'\n\n/**\n * @type {Record<ComponentType, typeof PreviewComponent>}\n */\nconst InputFieldComponentDictionary = {\n [ComponentType.TextField]: ShortAnswerQuestion,\n [ComponentType.Details]: ShortAnswerQuestion,\n [ComponentType.InsetText]: ShortAnswerQuestion,\n [ComponentType.Html]: ShortAnswerQuestion,\n [ComponentType.Markdown]: Markdown,\n [ComponentType.List]: ListQuestion,\n [ComponentType.EmailAddressField]: EmailAddressQuestion,\n [ComponentType.NumberField]: NumberOnlyQuestion,\n [ComponentType.MultilineTextField]: LongAnswerQuestion,\n [ComponentType.TelephoneNumberField]: PhoneNumberQuestion,\n [ComponentType.MonthYearField]: MonthYearQuestion,\n [ComponentType.DatePartsField]: DateInputQuestion,\n [ComponentType.UkAddressField]: UkAddressQuestion,\n [ComponentType.AutocompleteField]: AutocompleteListQuestion,\n [ComponentType.RadiosField]: RadioQuestion,\n [ComponentType.CheckboxesField]: CheckboxQuestion,\n [ComponentType.SelectField]: SelectQuestion,\n [ComponentType.YesNoField]: YesNoQuestion,\n [ComponentType.FileUploadField]: SupportingEvidenceQuestion\n}\n\n/**\n * @param {QuestionRenderer} questionRenderer\n * @param {FormDefinition} definition\n * @param {boolean} hasTitle\n * @returns {(component: ComponentDef) => Question}\n */\nexport function mapComponentToPreviewQuestion(\n questionRenderer,\n definition,\n hasTitle\n) {\n return /** @type {(component: ComponentDef) => Question} */ (\n (component) => {\n /**\n * @type {QuestionElements}\n */\n let questionElements\n\n if (hasSelectionFields(component) && hasListField(component)) {\n const list = findDefinitionListFromComponent(component, definition)\n questionElements = new ListComponentElements(component, list, !hasTitle)\n } else if (\n hasInputField(component) ||\n component.type === ComponentType.YesNoField\n ) {\n questionElements = new QuestionComponentElements(component, !hasTitle)\n } else if (hasContentField(component)) {\n questionElements = new ContentElements(component, !hasTitle)\n } else {\n questionElements = new ComponentElements(component, !hasTitle)\n }\n\n const QuestionConstructor = InputFieldComponentDictionary[component.type]\n\n return new QuestionConstructor(questionElements, questionRenderer)\n }\n )\n}\n\n/**\n * @import { QuestionElements, QuestionRenderer } from '~/src/form/form-editor/preview/types.js'\n * @import { Question } from '~/src/form/form-editor/preview/question.js'\n * @import { PreviewComponent } from '~/src/form/form-editor/preview/preview.js'\n * @import { Item, FormDefinition } from '~/src/form/form-definition/types.js'\n * @import { FormComponentsDef, ComponentDef } from '~/src/components/types.js'\n */\n"],"mappings":"AAAA,SAASA,aAAa;AACtB,SAASC,wBAAwB;AACjC,SAASC,gBAAgB;AACzB,SAASC,iBAAiB;AAC1B,SAASC,eAAe;AACxB,SAASC,iBAAiB;AAC1B,SAASC,oBAAoB;AAC7B,SAASC,YAAY;AACrB,SAASC,kBAAkB;AAC3B,SAASC,QAAQ;AACjB,SAASC,iBAAiB;AAC1B,SAASC,kBAAkB;AAC3B,SAASC,mBAAmB;AAC5B,SAASC,aAAa;AACtB,SAASC,cAAc;AACvB,SAASC,mBAAmB;AAC5B,SAASC,0BA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Q,EACR;EACA,OAAO,oDACJC,SAAS,IAAK;IACb;AACN;AACA;IACM,IAAIC,gBAAgB;IAEpB,IAAIzB,kBAAkB,CAACwB,SAAS,CAAC,IAAIzB,YAAY,CAACyB,SAAS,CAAC,EAAE;MAC5D,MAAME,IAAI,GAAGhC,+BAA+B,CAAC8B,SAAS,EAAEF,UAAU,CAAC;MACnEG,gBAAgB,GAAG,IAAI9B,qBAAqB,CAAC6B,SAAS,EAAEE,IAAI,EAAE,CAACH,QAAQ,CAAC;IAC1E,CAAC,MAAM,IACLzB,aAAa,CAAC0B,SAAS,CAAC,IACxBA,SAAS,CAACG,IAAI,KAAKpD,aAAa,CAAC2C,UAAU,EAC3C;MACAO,gBAAgB,GAAG,IAAI7B,yBAAyB,CAAC4B,SAAS,EAAE,CAACD,QAAQ,CAAC;IACxE,CAAC,MAAM,IAAI1B,eAAe,CAAC2B,SAAS,CAAC,EAAE;MACrCC,gBAAgB,GAAG,IAAI9C,eAAe,CAAC6C,SAAS,EAAE,CAACD,QAAQ,CAAC;IAC9D,CAAC,MAAM;MACLE,gBAAgB,GAAG,IAAI/C,iBAAiB,CAAC8C,SAAS,EAAE,CAACD,QAAQ,CAAC;IAChE;IAEA,MAAMK,mBAAmB,GAAG3B,6BAA6B,CAACuB,SAAS,CAACG,IAAI,CAAC;IAEzE,OAAO,IAAIC,mBAAmB,CAACH,gBAAgB,EAAEJ,gBAAgB,CAAC;EACpE,CAAC;AAEL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
1
+ {"version":3,"file":"helpers.js","names":["ComponentType","AutocompleteListQuestion","CheckboxQuestion","ComponentElements","ContentElements","DateInputQuestion","EmailAddressQuestion","ListQuestion","LongAnswerQuestion","Markdown","MonthYearQuestion","NumberOnlyQuestion","PhoneNumberQuestion","RadioQuestion","SelectQuestion","ShortAnswerQuestion","SupportingEvidenceQuestion","UkAddressQuestion","YesNoQuestion","findDefinitionListFromComponent","ListComponentElements","QuestionComponentElements","hasContentField","hasInputField","hasListField","hasSelectionFields","InputFieldComponentDictionary","TextField","Details","InsetText","Html","List","EmailAddressField","NumberField","MultilineTextField","TelephoneNumberField","MonthYearField","DatePartsField","UkAddressField","AutocompleteField","RadiosField","CheckboxesField","SelectField","YesNoField","FileUploadField","mapComponentToPreviewQuestion","questionRenderer","definition","component","questionElements","list","type","QuestionConstructor"],"sources":["../../../../../src/form/form-editor/preview/helpers.js"],"sourcesContent":["import { ComponentType } from '~/src/components/enums.js'\nimport { AutocompleteListQuestion } from '~/src/form/form-editor/preview/autocomplete.js'\nimport { CheckboxQuestion } from '~/src/form/form-editor/preview/checkbox.js'\nimport { ComponentElements } from '~/src/form/form-editor/preview/component-elements.js'\nimport { ContentElements } from '~/src/form/form-editor/preview/content.js'\nimport { DateInputQuestion } from '~/src/form/form-editor/preview/date-input.js'\nimport { EmailAddressQuestion } from '~/src/form/form-editor/preview/email-address.js'\nimport { ListQuestion } from '~/src/form/form-editor/preview/list.js'\nimport { LongAnswerQuestion } from '~/src/form/form-editor/preview/long-answer.js'\nimport { Markdown } from '~/src/form/form-editor/preview/markdown.js'\nimport { MonthYearQuestion } from '~/src/form/form-editor/preview/month-year.js'\nimport { NumberOnlyQuestion } from '~/src/form/form-editor/preview/number-only.js'\nimport { PhoneNumberQuestion } from '~/src/form/form-editor/preview/phone-number.js'\nimport { RadioQuestion } from '~/src/form/form-editor/preview/radio.js'\nimport { SelectQuestion } from '~/src/form/form-editor/preview/select.js'\nimport { ShortAnswerQuestion } from '~/src/form/form-editor/preview/short-answer.js'\nimport { SupportingEvidenceQuestion } from '~/src/form/form-editor/preview/supporting-evidence.js'\nimport { UkAddressQuestion } from '~/src/form/form-editor/preview/uk-address.js'\nimport { YesNoQuestion } from '~/src/form/form-editor/preview/yes-no.js'\nimport { findDefinitionListFromComponent } from '~/src/form/utils/list.js'\nimport {\n ListComponentElements,\n QuestionComponentElements,\n hasContentField,\n hasInputField,\n hasListField,\n hasSelectionFields\n} from '~/src/index.js'\n\n/**\n * @type {Record<ComponentType, typeof PreviewComponent>}\n */\nconst InputFieldComponentDictionary = {\n [ComponentType.TextField]: ShortAnswerQuestion,\n [ComponentType.Details]: ShortAnswerQuestion,\n [ComponentType.InsetText]: ShortAnswerQuestion,\n [ComponentType.Html]: ShortAnswerQuestion,\n [ComponentType.Markdown]: Markdown,\n [ComponentType.List]: ListQuestion,\n [ComponentType.EmailAddressField]: EmailAddressQuestion,\n [ComponentType.NumberField]: NumberOnlyQuestion,\n [ComponentType.MultilineTextField]: LongAnswerQuestion,\n [ComponentType.TelephoneNumberField]: PhoneNumberQuestion,\n [ComponentType.MonthYearField]: MonthYearQuestion,\n [ComponentType.DatePartsField]: DateInputQuestion,\n [ComponentType.UkAddressField]: UkAddressQuestion,\n [ComponentType.AutocompleteField]: AutocompleteListQuestion,\n [ComponentType.RadiosField]: RadioQuestion,\n [ComponentType.CheckboxesField]: CheckboxQuestion,\n [ComponentType.SelectField]: SelectQuestion,\n [ComponentType.YesNoField]: YesNoQuestion,\n [ComponentType.FileUploadField]: SupportingEvidenceQuestion\n}\n\n/**\n * @param {QuestionRenderer} questionRenderer\n * @param {FormDefinition} definition\n * @returns {(component: ComponentDef) => Question}\n */\nexport function mapComponentToPreviewQuestion(questionRenderer, definition) {\n return /** @type {(component: ComponentDef) => Question} */ (\n (component) => {\n /**\n * @type {QuestionElements}\n */\n let questionElements\n\n if (hasSelectionFields(component) && hasListField(component)) {\n const list = findDefinitionListFromComponent(component, definition)\n questionElements = new ListComponentElements(component, list)\n } else if (\n hasInputField(component) ||\n component.type === ComponentType.YesNoField\n ) {\n questionElements = new QuestionComponentElements(component)\n } else if (hasContentField(component)) {\n questionElements = new ContentElements(component)\n } else {\n questionElements = new ComponentElements(component)\n }\n\n const QuestionConstructor = InputFieldComponentDictionary[component.type]\n\n return new QuestionConstructor(questionElements, questionRenderer)\n }\n )\n}\n\n/**\n * @import { QuestionElements, QuestionRenderer } from '~/src/form/form-editor/preview/types.js'\n * @import { Question } from '~/src/form/form-editor/preview/question.js'\n * @import { PreviewComponent } from '~/src/form/form-editor/preview/preview.js'\n * @import { Item, FormDefinition } from '~/src/form/form-definition/types.js'\n * @import { FormComponentsDef, ComponentDef } from '~/src/components/types.js'\n */\n"],"mappings":"AAAA,SAASA,aAAa;AACtB,SAASC,wBAAwB;AACjC,SAASC,gBAAgB;AACzB,SAASC,iBAAiB;AAC1B,SAASC,eAAe;AACxB,SAASC,iBAAiB;AAC1B,SAASC,oBAAoB;AAC7B,SAASC,YAAY;AACrB,SAASC,kBAAkB;AAC3B,SAASC,QAAQ;AACjB,SAASC,iBAAiB;AAC1B,SAASC,kBAAkB;AAC3B,SAASC,mBAAmB;AAC5B,SAASC,aAAa;AACtB,SAASC,cAAc;AACvB,SAASC,mBAAmB;AAC5B,SAASC,0BAA0B;AACnC,SAASC,iBAAiB;AAC1B,SAASC,aAAa;AACtB,SAASC,+BAA+B;AACxC,SACEC,qBAAqB,EACrBC,yBAAyB,EACzBC,eAAe,EACfC,aAAa,EACbC,YAAY,EACZC,kBAAkB;;AAGpB;AACA;AACA;AACA,MAAMC,6BAA6B,GAAG;EACpC,CAAC1B,aAAa,CAAC2B,SAAS,GAAGZ,mBAAmB;EAC9C,CAACf,aAAa,CAAC4B,OAAO,GAAGb,mBAAmB;EAC5C,CAACf,aAAa,CAAC6B,SAAS,GAAGd,mBAAmB;EAC9C,CAACf,aAAa,CAAC8B,IAAI,GAAGf,mBAAmB;EACzC,CAACf,aAAa,CAACS,QAAQ,GAAGA,QAAQ;EAClC,CAACT,aAAa,CAAC+B,IAAI,GAAGxB,YAAY;EAClC,CAACP,aAAa,CAACgC,iBAAiB,GAAG1B,oBAAoB;EACvD,CAACN,aAAa,CAACiC,WAAW,GAAGtB,kBAAkB;EAC/C,CAACX,aAAa,CAACkC,kBAAkB,GAAG1B,kBAAkB;EACtD,CAACR,aAAa,CAACmC,oBAAoB,GAAGvB,mBAAmB;EACzD,CAACZ,aAAa,CAACoC,cAAc,GAAG1B,iBA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AIC,mBAAmB,CAACH,gBAAgB,EAAEH,gBAAgB,CAAC;EACpE,CAAC;AAEL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
@@ -57,10 +57,9 @@ export class ListComponentElements extends QuestionComponentElements {
57
57
  /**
58
58
  * @param {SelectionComponentsDef} component
59
59
  * @param {List} list
60
- * @param {boolean} largeTitle
61
60
  */
62
- constructor(component, list, largeTitle = true) {
63
- super(component, largeTitle);
61
+ constructor(component, list) {
62
+ super(component);
64
63
  this._list = list;
65
64
  }
66
65
 
@@ -1 +1 @@
1
- {"version":3,"file":"list.js","names":["ComponentType","PreviewComponent","Question","QuestionComponentElements","DefaultListConst","TextElementId","HintElementId","Template","PATH","Input","RenderName","listItemMapper","listElement","id","listsElementToMap","listElements","entries","map","Map","listItemToListElement","item","text","label","classes","value","hint","ListComponentElements","_list","constructor","component","list","largeTitle","_getValues","items","ListQuestion","componentType","List","_questionTemplate","_listElements","listRenderId","listRenderName","questionRenderer","values","createListFromElements","renderInput","afterInputs","length","formGroup","html","afterInputsHTML","name","fieldset","fieldSet","push","set","render","delete","key","iterator","Array","from","listItem","hintText","_highlight","getHighlight","undefined","updateText","get","updateHint","updateValue"],"sources":["../../../../../src/form/form-editor/preview/list.js"],"sourcesContent":["import { ComponentType } from '~/src/components/enums.js'\nimport { PreviewComponent } from '~/src/form/form-editor/preview/preview.js'\nimport {\n Question,\n QuestionComponentElements\n} from '~/src/form/form-editor/preview/question.js'\n\nconst DefaultListConst = {\n TextElementId: 'radioText',\n HintElementId: 'radioHint',\n Template: PreviewComponent.PATH + 'radios.njk',\n Input: 'listInput',\n RenderName: 'listInputField'\n}\n\n/**\n * @param {ListElement} listElement\n * @returns {[string, ListElement]}\n */\nexport function listItemMapper(listElement) {\n return [listElement.id, listElement]\n}\n\n/**\n *\n * @param { ListElement[]| undefined } listElements\n * @returns {Map<string, ListElement>}\n */\nexport function listsElementToMap(listElements) {\n const entries = listElements ? listElements.map(listItemMapper) : []\n return new Map(entries)\n}\n\n/**\n * @param {Item} item\n * @returns {ListElement}\n */\nexport function listItemToListElement(item) {\n return {\n text: item.text,\n label: {\n text: item.text,\n classes: ''\n },\n value: item.value,\n id: item.id ?? '',\n hint: item.hint\n }\n}\n\n/**\n * @implements {QuestionElements}\n */\nexport class ListComponentElements extends QuestionComponentElements {\n /**\n * @type {List}\n * @protected\n */\n _list\n\n /**\n * @param {SelectionComponentsDef} component\n * @param {List} list\n * @param {boolean} largeTitle\n */\n constructor(component, list, largeTitle = true) {\n super(component, largeTitle)\n this._list = list\n }\n\n /**\n * @returns {BaseSettings}\n * @protected\n */\n _getValues() {\n return {\n ...super._getValues(),\n items: this._list.items.map(listItemToListElement)\n }\n }\n}\n\nexport class ListQuestion extends Question {\n /**\n * @type {ComponentType}\n */\n componentType = ComponentType.List\n /**\n * @type {string}\n * @protected\n */\n _questionTemplate = DefaultListConst.Template\n /** @type {ListElements} */\n _listElements\n listRenderId = DefaultListConst.Input\n listRenderName = DefaultListConst.RenderName\n\n /**\n * @type {Map<string, ListElement>}\n * @protected\n */\n _list\n\n /**\n * @param {ListElements} listElements\n * @param {QuestionRenderer} questionRenderer\n */\n constructor(listElements, questionRenderer) {\n super(listElements, questionRenderer)\n\n const items = /** @type {ListElement[]} */ (listElements.values.items)\n this._list = this.createListFromElements(items)\n this._listElements = listElements\n }\n\n /**\n * @returns {{\n * formGroup?: {afterInputs: {html: string}};\n * hint: DefaultComponent;\n * name: string;\n * fieldset?: GovukFieldset;\n * id: string;\n * items: ListItemReadonly[]\n * }}\n */\n get renderInput() {\n const afterInputs =\n /** @type {{ formGroup?: { afterInputs: { html: string } } }} */ (\n this.list.length\n ? {}\n : {\n formGroup: {\n afterInputs: {\n html: this._listElements.afterInputsHTML\n }\n }\n }\n )\n\n return {\n id: this.listRenderId,\n name: this.listRenderName,\n fieldset: this.fieldSet,\n hint: this.hint,\n items: this.list,\n ...afterInputs\n }\n }\n\n /**\n *\n * @param {ListElement} listElement\n */\n push(listElement) {\n this._list.set(listElement.id, listElement)\n this.render()\n }\n\n /**\n * @param {string} key\n */\n delete(key) {\n this._list.delete(key)\n this.render()\n }\n\n /**\n * @param {ListElement[]} listElements\n * @returns {Map<string, ListElement>}\n */\n createListFromElements(listElements) {\n this._list = listsElementToMap(listElements)\n return this._list\n }\n\n /**\n * @returns {ListItemReadonly[]}\n */\n get list() {\n const iterator = /** @type {MapIterator<ListElement>} */ (\n this._list.values()\n )\n return Array.from(iterator).map((listItem) => {\n const hintText =\n this._highlight === `${listItem.id}-hint` && !listItem.hint?.text.length\n ? 'Hint text'\n : (listItem.hint?.text ?? '')\n\n const hint = {\n hint: hintText\n ? {\n text: hintText,\n classes: this.getHighlight(listItem.id + '-hint')\n }\n : undefined\n }\n\n const text = listItem.text.length ? listItem.text : 'Item text'\n\n return {\n ...listItem,\n text,\n ...hint,\n label: {\n text: listItem.text,\n classes: this.getHighlight(listItem.id + '-label')\n }\n }\n })\n }\n\n /**\n *\n * @param {string | undefined} id\n * @param {string} text\n */\n updateText(id, text) {\n if (!id) {\n return\n }\n\n const listItem = this._list.get(id)\n if (listItem) {\n listItem.text = text\n this.render()\n }\n }\n\n /**\n *\n * @param {string | undefined} id\n * @param {string} hint\n */\n updateHint(id, hint) {\n if (!id) {\n return\n }\n\n const listItem = this._list.get(id)\n if (listItem) {\n listItem.hint = {\n ...listItem.hint,\n text: hint\n }\n this.render()\n }\n }\n\n /**\n * @param {string | undefined} id\n * @param {string} value\n */\n updateValue(id, value) {\n if (!id) {\n return\n }\n\n const listItem = this._list.get(id)\n if (listItem) {\n listItem.value = value\n this.render()\n }\n }\n}\n\n/**\n * @import { ListElement, ListItemReadonly } from '~/src/form/form-editor/types.js'\n * @import { SelectionComponentsDef, ListComponentsDef } from '~/src/components/types.js'\n * @import { List, Item } from '~/src/form/form-definition/types.js'\n * @import { ListElements, QuestionRenderer, DefaultComponent, GovukFieldset, BaseSettings, QuestionElements } from '~/src/form/form-editor/preview/types.js'\n */\n"],"mappings":"AA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,CAAC;IACf;EACF;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
1
+ {"version":3,"file":"list.js","names":["ComponentType","PreviewComponent","Question","QuestionComponentElements","DefaultListConst","TextElementId","HintElementId","Template","PATH","Input","RenderName","listItemMapper","listElement","id","listsElementToMap","listElements","entries","map","Map","listItemToListElement","item","text","label","classes","value","hint","ListComponentElements","_list","constructor","component","list","_getValues","items","ListQuestion","componentType","List","_questionTemplate","_listElements","listRenderId","listRenderName","questionRenderer","values","createListFromElements","renderInput","afterInputs","length","formGroup","html","afterInputsHTML","name","fieldset","fieldSet","push","set","render","delete","key","iterator","Array","from","listItem","hintText","_highlight","getHighlight","undefined","updateText","get","updateHint","updateValue"],"sources":["../../../../../src/form/form-editor/preview/list.js"],"sourcesContent":["import { ComponentType } from '~/src/components/enums.js'\nimport { PreviewComponent } from '~/src/form/form-editor/preview/preview.js'\nimport {\n Question,\n QuestionComponentElements\n} from '~/src/form/form-editor/preview/question.js'\n\nconst DefaultListConst = {\n TextElementId: 'radioText',\n HintElementId: 'radioHint',\n Template: PreviewComponent.PATH + 'radios.njk',\n Input: 'listInput',\n RenderName: 'listInputField'\n}\n\n/**\n * @param {ListElement} listElement\n * @returns {[string, ListElement]}\n */\nexport function listItemMapper(listElement) {\n return [listElement.id, listElement]\n}\n\n/**\n *\n * @param { ListElement[]| undefined } listElements\n * @returns {Map<string, ListElement>}\n */\nexport function listsElementToMap(listElements) {\n const entries = listElements ? listElements.map(listItemMapper) : []\n return new Map(entries)\n}\n\n/**\n * @param {Item} item\n * @returns {ListElement}\n */\nexport function listItemToListElement(item) {\n return {\n text: item.text,\n label: {\n text: item.text,\n classes: ''\n },\n value: item.value,\n id: item.id ?? '',\n hint: item.hint\n }\n}\n\n/**\n * @implements {QuestionElements}\n */\nexport class ListComponentElements extends QuestionComponentElements {\n /**\n * @type {List}\n * @protected\n */\n _list\n\n /**\n * @param {SelectionComponentsDef} component\n * @param {List} list\n */\n constructor(component, list) {\n super(component)\n this._list = list\n }\n\n /**\n * @returns {BaseSettings}\n * @protected\n */\n _getValues() {\n return {\n ...super._getValues(),\n items: this._list.items.map(listItemToListElement)\n }\n }\n}\n\nexport class ListQuestion extends Question {\n /**\n * @type {ComponentType}\n */\n componentType = ComponentType.List\n /**\n * @type {string}\n * @protected\n */\n _questionTemplate = DefaultListConst.Template\n /** @type {ListElements} */\n _listElements\n listRenderId = DefaultListConst.Input\n listRenderName = DefaultListConst.RenderName\n\n /**\n * @type {Map<string, ListElement>}\n * @protected\n */\n _list\n\n /**\n * @param {ListElements} listElements\n * @param {QuestionRenderer} questionRenderer\n */\n constructor(listElements, questionRenderer) {\n super(listElements, questionRenderer)\n\n const items = /** @type {ListElement[]} */ (listElements.values.items)\n this._list = this.createListFromElements(items)\n this._listElements = listElements\n }\n\n /**\n * @returns {{\n * formGroup?: {afterInputs: {html: string}};\n * hint: DefaultComponent;\n * name: string;\n * fieldset?: GovukFieldset;\n * id: string;\n * items: ListItemReadonly[]\n * }}\n */\n get renderInput() {\n const afterInputs =\n /** @type {{ formGroup?: { afterInputs: { html: string } } }} */ (\n this.list.length\n ? {}\n : {\n formGroup: {\n afterInputs: {\n html: this._listElements.afterInputsHTML\n }\n }\n }\n )\n\n return {\n id: this.listRenderId,\n name: this.listRenderName,\n fieldset: this.fieldSet,\n hint: this.hint,\n items: this.list,\n ...afterInputs\n }\n }\n\n /**\n *\n * @param {ListElement} listElement\n */\n push(listElement) {\n this._list.set(listElement.id, listElement)\n this.render()\n }\n\n /**\n * @param {string} key\n */\n delete(key) {\n this._list.delete(key)\n this.render()\n }\n\n /**\n * @param {ListElement[]} listElements\n * @returns {Map<string, ListElement>}\n */\n createListFromElements(listElements) {\n this._list = listsElementToMap(listElements)\n return this._list\n }\n\n /**\n * @returns {ListItemReadonly[]}\n */\n get list() {\n const iterator = /** @type {MapIterator<ListElement>} */ (\n this._list.values()\n )\n return Array.from(iterator).map((listItem) => {\n const hintText =\n this._highlight === `${listItem.id}-hint` && !listItem.hint?.text.length\n ? 'Hint text'\n : (listItem.hint?.text ?? '')\n\n const hint = {\n hint: hintText\n ? {\n text: hintText,\n classes: this.getHighlight(listItem.id + '-hint')\n }\n : undefined\n }\n\n const text = listItem.text.length ? listItem.text : 'Item text'\n\n return {\n ...listItem,\n text,\n ...hint,\n label: {\n text: listItem.text,\n classes: this.getHighlight(listItem.id + '-label')\n }\n }\n })\n }\n\n /**\n *\n * @param {string | undefined} id\n * @param {string} text\n */\n updateText(id, text) {\n if (!id) {\n return\n }\n\n const listItem = this._list.get(id)\n if (listItem) {\n listItem.text = text\n this.render()\n }\n }\n\n /**\n *\n * @param {string | undefined} id\n * @param {string} hint\n */\n updateHint(id, hint) {\n if (!id) {\n return\n }\n\n const listItem = this._list.get(id)\n if (listItem) {\n listItem.hint = {\n ...listItem.hint,\n text: hint\n }\n this.render()\n }\n }\n\n /**\n * @param {string | undefined} id\n * @param {string} value\n */\n updateValue(id, value) {\n if (!id) {\n return\n }\n\n const listItem = this._list.get(id)\n if (listItem) {\n listItem.value = value\n this.render()\n }\n }\n}\n\n/**\n * @import { ListElement, ListItemReadonly } from '~/src/form/form-editor/types.js'\n * @import { SelectionComponentsDef, ListComponentsDef } from '~/src/components/types.js'\n * @import { List, Item } from '~/src/form/form-definition/types.js'\n * @import { ListElements, QuestionRenderer, DefaultComponent, GovukFieldset, BaseSettings, QuestionElements } from '~/src/form/form-editor/preview/types.js'\n */\n"],"mappings":"AAAA,SAASA,aAAa;AACtB,SAASC,gBAAgB;AACzB,SACEC,QAAQ,EACRC,yBAAyB;AAG3B,MAAMC,gBAAgB,GAAG;EACvBC,aAAa,EAAE,WAAW;EAC1BC,aAAa,EAAE,WAAW;EAC1BC,QAAQ,EAAEN,gBAAgB,CAACO,IAAI,GAAG,YAAY;EAC9CC,KAAK,EAAE,WAAW;EAClBC,UAAU,EAAE;AACd,CAAC;;AAED;AACA;AACA;AACA;AACA,OAAO,SAASC,cAAcA,CAACC,WAAW,EAAE;EAC1C,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