@defra/forms-model 3.0.500 → 3.0.502

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.
@@ -20,11 +20,11 @@ export function isConditionRelativeDateValueDataV2(condition) {
20
20
  function getListItem(model, listId, itemId) {
21
21
  const foundList = model.getListById(listId);
22
22
  if (!foundList) {
23
- throw Error('List not found');
23
+ throw Error(`List ${listId} not found`);
24
24
  }
25
25
  const item = foundList.items.find(item => item.id === itemId);
26
26
  if (!item) {
27
- throw Error('List item not found');
27
+ throw Error(`List item ${itemId} not found`);
28
28
  }
29
29
  return item;
30
30
  }
@@ -1 +1 @@
1
- {"version":3,"file":"migration.js","names":["ConditionType","isConditionListItemRefValueDataV2","condition","type","ListItemRef","isConditionStringValueDataV2","StringValue","isConditionBooleanValueDataV2","BooleanValue","isConditionNumberValueDataV2","NumberValue","isConditionDateValueDataV2","DateValue","isConditionRelativeDateValueDataV2","RelativeDate","getListItem","model","listId","itemId","foundList","getListById","Error","item","items","find","id","createConditionValueDataFromListItemRefV2","value","refValue","display","text","Value","toString","createConditionValueDataFromStringOrDateValueDataV2","createConditionValueDataFromStringValueDataV2","createConditionValueDataFromDateValueDataV2","createConditionValueDataFromRelativeDateValueDataV2","period","unit","direction","createConditionValueDataFromNumberValueDataV2","createConditionValueDataFromBooleanValueDataV2","isConditionDataV2","convertConditionDataV2","coordinator","component","getComponentById","componentId","newValue","field","name","title","operator","convertConditionRefDataFromV2","refCondition","getConditionById","conditionId","conditionName","displayName","conditionDisplayName","isConditionWrapperV2","wrapper","Array","isArray","isConditionWrapper","convertConditionWrapperFromV2","conditionWrapper","length","newConditionWrapper","conditions","map","index","newCondition","undefined"],"sources":["../../../src/conditions/migration.ts"],"sourcesContent":["import {\n type ComponentDef,\n type ConditionalComponentType\n} from '~/src/components/types.js'\nimport { ConditionType, type Coordinator } from '~/src/conditions/enums.js'\nimport {\n type ConditionData,\n type ConditionDataV2,\n type ConditionListItemRefValueDataV2,\n type ConditionRefData,\n type ConditionRefDataV2,\n type ConditionValueData,\n type RelativeDateValueData,\n type RelativeDateValueDataV2\n} from '~/src/conditions/types.js'\nimport {\n type ConditionWrapper,\n type ConditionWrapperV2,\n type List\n} from '~/src/form/form-definition/types.js'\n\nexport function isConditionListItemRefValueDataV2(condition: ConditionDataV2) {\n return condition.type === ConditionType.ListItemRef\n}\n\nexport function isConditionStringValueDataV2(condition: ConditionDataV2) {\n return condition.type === ConditionType.StringValue\n}\n\nexport function isConditionBooleanValueDataV2(condition: ConditionDataV2) {\n return condition.type === ConditionType.BooleanValue\n}\n\nexport function isConditionNumberValueDataV2(condition: ConditionDataV2) {\n return condition.type === ConditionType.NumberValue\n}\n\nexport function isConditionDateValueDataV2(condition: ConditionDataV2) {\n return condition.type === ConditionType.DateValue\n}\n\nexport function isConditionRelativeDateValueDataV2(condition: ConditionDataV2) {\n return condition.type === ConditionType.RelativeDate\n}\n\nfunction getListItem(model: RuntimeFormModel, listId: string, itemId: string) {\n const foundList = model.getListById(listId)\n\n if (!foundList) {\n throw Error('List not found')\n }\n\n const item = foundList.items.find((item) => item.id === itemId)\n\n if (!item) {\n throw Error('List item not found')\n }\n\n return item\n}\n\nfunction createConditionValueDataFromListItemRefV2(\n condition: ConditionDataV2,\n model: RuntimeFormModel\n): ConditionValueData {\n const value = condition.value as ConditionListItemRefValueDataV2\n const refValue = getListItem(model, value.listId, value.itemId)\n\n return {\n display: refValue.text,\n type: ConditionType.Value,\n value: refValue.value.toString()\n }\n}\n\nfunction createConditionValueDataFromStringOrDateValueDataV2(\n condition: ConditionDataV2\n): ConditionValueData {\n return {\n type: ConditionType.Value,\n value: condition.value as string,\n display: condition.value as string\n }\n}\n\nfunction createConditionValueDataFromStringValueDataV2(\n condition: ConditionDataV2\n): ConditionValueData {\n return createConditionValueDataFromStringOrDateValueDataV2(condition)\n}\n\nfunction createConditionValueDataFromDateValueDataV2(\n condition: ConditionDataV2\n): ConditionValueData {\n return createConditionValueDataFromStringOrDateValueDataV2(condition)\n}\n\nfunction createConditionValueDataFromRelativeDateValueDataV2(\n condition: ConditionDataV2\n): RelativeDateValueData {\n const value = condition.value as RelativeDateValueDataV2\n return {\n type: ConditionType.RelativeDate,\n period: value.period.toString(),\n unit: value.unit,\n direction: value.direction\n }\n}\n\nfunction createConditionValueDataFromNumberValueDataV2(\n condition: ConditionDataV2\n): ConditionValueData {\n return {\n type: ConditionType.Value,\n value: (condition.value as number).toString(),\n display: (condition.value as number).toString()\n }\n}\n\nfunction createConditionValueDataFromBooleanValueDataV2(\n condition: ConditionDataV2\n): ConditionValueData {\n return {\n type: ConditionType.Value,\n value: (condition.value as boolean).toString(),\n display: (condition.value as boolean) ? 'Yes' : 'No'\n }\n}\n\nfunction isConditionDataV2(\n condition: ConditionDataV2 | ConditionRefDataV2\n): condition is ConditionDataV2 {\n return 'componentId' in condition\n}\n\nfunction convertConditionDataV2(\n model: RuntimeFormModel,\n condition: ConditionDataV2,\n coordinator: Coordinator | undefined\n): ConditionData {\n const component = model.getComponentById(condition.componentId)\n\n if (!component) {\n throw Error('Component not found')\n }\n\n let newValue\n if (isConditionListItemRefValueDataV2(condition)) {\n newValue = createConditionValueDataFromListItemRefV2(condition, model)\n } else if (isConditionStringValueDataV2(condition)) {\n newValue = createConditionValueDataFromStringValueDataV2(condition)\n } else if (isConditionBooleanValueDataV2(condition)) {\n newValue = createConditionValueDataFromBooleanValueDataV2(condition)\n } else if (isConditionNumberValueDataV2(condition)) {\n newValue = createConditionValueDataFromNumberValueDataV2(condition)\n } else if (isConditionDateValueDataV2(condition)) {\n newValue = createConditionValueDataFromDateValueDataV2(condition)\n } else if (isConditionRelativeDateValueDataV2(condition)) {\n newValue = createConditionValueDataFromRelativeDateValueDataV2(condition)\n } else {\n throw Error('Unsupported condition type')\n }\n\n return {\n field: {\n name: component.name,\n type: component.type as ConditionalComponentType /** @todo fix this */,\n display: component.title\n },\n operator: condition.operator,\n value: newValue,\n coordinator\n }\n}\n\nfunction convertConditionRefDataFromV2(\n model: RuntimeFormModel,\n condition: ConditionRefDataV2,\n coordinator: Coordinator | undefined\n): ConditionRefData {\n const refCondition = model.getConditionById(condition.conditionId)\n\n if (!refCondition) {\n throw Error('Component not found')\n }\n\n return {\n conditionName: refCondition.displayName,\n conditionDisplayName: refCondition.displayName,\n coordinator\n }\n}\n\nexport function isConditionWrapperV2(\n wrapper: ConditionWrapper | ConditionWrapperV2\n): wrapper is ConditionWrapperV2 {\n return Array.isArray((wrapper as ConditionWrapperV2).items)\n}\n\nexport function isConditionWrapper(\n wrapper: ConditionWrapper | ConditionWrapperV2\n): wrapper is ConditionWrapper {\n return !isConditionWrapperV2(wrapper)\n}\n\nexport function convertConditionWrapperFromV2(\n conditionWrapper: ConditionWrapperV2,\n model: RuntimeFormModel\n): ConditionWrapper {\n let coordinator\n\n if (conditionWrapper.items.length > 1 && !conditionWrapper.coordinator) {\n throw new Error('Coordinator is required for multiple conditions')\n } else {\n coordinator = conditionWrapper.coordinator\n }\n\n const newConditionWrapper: ConditionWrapper = {\n name: conditionWrapper.id,\n displayName: conditionWrapper.displayName,\n value: {\n name: conditionWrapper.id,\n conditions: conditionWrapper.items.map((condition, index) => {\n let newCondition: ConditionData | ConditionRefData\n\n if (isConditionDataV2(condition)) {\n newCondition = convertConditionDataV2(\n model,\n condition,\n index > 0 ? coordinator : undefined\n )\n } else {\n newCondition = convertConditionRefDataFromV2(\n model,\n condition,\n index > 0 ? coordinator : undefined\n )\n }\n\n return newCondition\n })\n }\n }\n\n return newConditionWrapper\n}\n\nexport interface RuntimeFormModel {\n getListById: (listId: string) => List | undefined\n getComponentById: (componentId: string) => ComponentDef | undefined\n getConditionById: (conditionId: string) => ConditionWrapperV2 | undefined\n}\n"],"mappings":"AAIA,SAASA,aAAa;AAiBtB,OAAO,SAASC,iCAAiCA,CAACC,SAA0B,EAAE;EAC5E,OAAOA,SAAS,CAACC,IAAI,KAAKH,aAAa,CAACI,WAAW;AACrD;AAEA,OAAO,SAASC,4BAA4BA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,SAAS,EAAEqE,KAAK,KAAK;QAC3D,IAAIC,YAA8C;QAElD,IAAI9B,iBAAiB,CAACxC,SAAS,CAAC,EAAE;UAChCsE,YAAY,GAAG7B,sBAAsB,CACnC3B,KAAK,EACLd,SAAS,EACTqE,KAAK,GAAG,CAAC,GAAG3B,WAAW,GAAG6B,SAC5B,CAAC;QACH,CAAC,MAAM;UACLD,YAAY,GAAGnB,6BAA6B,CAC1CrC,KAAK,EACLd,SAAS,EACTqE,KAAK,GAAG,CAAC,GAAG3B,WAAW,GAAG6B,SAC5B,CAAC;QACH;QAEA,OAAOD,YAAY;MACrB,CAAC;IACH;EACF,CAAC;EAED,OAAOJ,mBAAmB;AAC5B","ignoreList":[]}
1
+ {"version":3,"file":"migration.js","names":["ConditionType","isConditionListItemRefValueDataV2","condition","type","ListItemRef","isConditionStringValueDataV2","StringValue","isConditionBooleanValueDataV2","BooleanValue","isConditionNumberValueDataV2","NumberValue","isConditionDateValueDataV2","DateValue","isConditionRelativeDateValueDataV2","RelativeDate","getListItem","model","listId","itemId","foundList","getListById","Error","item","items","find","id","createConditionValueDataFromListItemRefV2","value","refValue","display","text","Value","toString","createConditionValueDataFromStringOrDateValueDataV2","createConditionValueDataFromStringValueDataV2","createConditionValueDataFromDateValueDataV2","createConditionValueDataFromRelativeDateValueDataV2","period","unit","direction","createConditionValueDataFromNumberValueDataV2","createConditionValueDataFromBooleanValueDataV2","isConditionDataV2","convertConditionDataV2","coordinator","component","getComponentById","componentId","newValue","field","name","title","operator","convertConditionRefDataFromV2","refCondition","getConditionById","conditionId","conditionName","displayName","conditionDisplayName","isConditionWrapperV2","wrapper","Array","isArray","isConditionWrapper","convertConditionWrapperFromV2","conditionWrapper","length","newConditionWrapper","conditions","map","index","newCondition","undefined"],"sources":["../../../src/conditions/migration.ts"],"sourcesContent":["import {\n type ComponentDef,\n type ConditionalComponentType\n} from '~/src/components/types.js'\nimport { ConditionType, type Coordinator } from '~/src/conditions/enums.js'\nimport {\n type ConditionData,\n type ConditionDataV2,\n type ConditionListItemRefValueDataV2,\n type ConditionRefData,\n type ConditionRefDataV2,\n type ConditionValueData,\n type RelativeDateValueData,\n type RelativeDateValueDataV2\n} from '~/src/conditions/types.js'\nimport {\n type ConditionWrapper,\n type ConditionWrapperV2,\n type List\n} from '~/src/form/form-definition/types.js'\n\nexport function isConditionListItemRefValueDataV2(condition: ConditionDataV2) {\n return condition.type === ConditionType.ListItemRef\n}\n\nexport function isConditionStringValueDataV2(condition: ConditionDataV2) {\n return condition.type === ConditionType.StringValue\n}\n\nexport function isConditionBooleanValueDataV2(condition: ConditionDataV2) {\n return condition.type === ConditionType.BooleanValue\n}\n\nexport function isConditionNumberValueDataV2(condition: ConditionDataV2) {\n return condition.type === ConditionType.NumberValue\n}\n\nexport function isConditionDateValueDataV2(condition: ConditionDataV2) {\n return condition.type === ConditionType.DateValue\n}\n\nexport function isConditionRelativeDateValueDataV2(condition: ConditionDataV2) {\n return condition.type === ConditionType.RelativeDate\n}\n\nfunction getListItem(model: RuntimeFormModel, listId: string, itemId: string) {\n const foundList = model.getListById(listId)\n\n if (!foundList) {\n throw Error(`List ${listId} not found`)\n }\n\n const item = foundList.items.find((item) => item.id === itemId)\n\n if (!item) {\n throw Error(`List item ${itemId} not found`)\n }\n\n return item\n}\n\nfunction createConditionValueDataFromListItemRefV2(\n condition: ConditionDataV2,\n model: RuntimeFormModel\n): ConditionValueData {\n const value = condition.value as ConditionListItemRefValueDataV2\n const refValue = getListItem(model, value.listId, value.itemId)\n\n return {\n display: refValue.text,\n type: ConditionType.Value,\n value: refValue.value.toString()\n }\n}\n\nfunction createConditionValueDataFromStringOrDateValueDataV2(\n condition: ConditionDataV2\n): ConditionValueData {\n return {\n type: ConditionType.Value,\n value: condition.value as string,\n display: condition.value as string\n }\n}\n\nfunction createConditionValueDataFromStringValueDataV2(\n condition: ConditionDataV2\n): ConditionValueData {\n return createConditionValueDataFromStringOrDateValueDataV2(condition)\n}\n\nfunction createConditionValueDataFromDateValueDataV2(\n condition: ConditionDataV2\n): ConditionValueData {\n return createConditionValueDataFromStringOrDateValueDataV2(condition)\n}\n\nfunction createConditionValueDataFromRelativeDateValueDataV2(\n condition: ConditionDataV2\n): RelativeDateValueData {\n const value = condition.value as RelativeDateValueDataV2\n return {\n type: ConditionType.RelativeDate,\n period: value.period.toString(),\n unit: value.unit,\n direction: value.direction\n }\n}\n\nfunction createConditionValueDataFromNumberValueDataV2(\n condition: ConditionDataV2\n): ConditionValueData {\n return {\n type: ConditionType.Value,\n value: (condition.value as number).toString(),\n display: (condition.value as number).toString()\n }\n}\n\nfunction createConditionValueDataFromBooleanValueDataV2(\n condition: ConditionDataV2\n): ConditionValueData {\n return {\n type: ConditionType.Value,\n value: (condition.value as boolean).toString(),\n display: (condition.value as boolean) ? 'Yes' : 'No'\n }\n}\n\nfunction isConditionDataV2(\n condition: ConditionDataV2 | ConditionRefDataV2\n): condition is ConditionDataV2 {\n return 'componentId' in condition\n}\n\nfunction convertConditionDataV2(\n model: RuntimeFormModel,\n condition: ConditionDataV2,\n coordinator: Coordinator | undefined\n): ConditionData {\n const component = model.getComponentById(condition.componentId)\n\n if (!component) {\n throw Error('Component not found')\n }\n\n let newValue\n if (isConditionListItemRefValueDataV2(condition)) {\n newValue = createConditionValueDataFromListItemRefV2(condition, model)\n } else if (isConditionStringValueDataV2(condition)) {\n newValue = createConditionValueDataFromStringValueDataV2(condition)\n } else if (isConditionBooleanValueDataV2(condition)) {\n newValue = createConditionValueDataFromBooleanValueDataV2(condition)\n } else if (isConditionNumberValueDataV2(condition)) {\n newValue = createConditionValueDataFromNumberValueDataV2(condition)\n } else if (isConditionDateValueDataV2(condition)) {\n newValue = createConditionValueDataFromDateValueDataV2(condition)\n } else if (isConditionRelativeDateValueDataV2(condition)) {\n newValue = createConditionValueDataFromRelativeDateValueDataV2(condition)\n } else {\n throw Error('Unsupported condition type')\n }\n\n return {\n field: {\n name: component.name,\n type: component.type as ConditionalComponentType /** @todo fix this */,\n display: component.title\n },\n operator: condition.operator,\n value: newValue,\n coordinator\n }\n}\n\nfunction convertConditionRefDataFromV2(\n model: RuntimeFormModel,\n condition: ConditionRefDataV2,\n coordinator: Coordinator | undefined\n): ConditionRefData {\n const refCondition = model.getConditionById(condition.conditionId)\n\n if (!refCondition) {\n throw Error('Component not found')\n }\n\n return {\n conditionName: refCondition.displayName,\n conditionDisplayName: refCondition.displayName,\n coordinator\n }\n}\n\nexport function isConditionWrapperV2(\n wrapper: ConditionWrapper | ConditionWrapperV2\n): wrapper is ConditionWrapperV2 {\n return Array.isArray((wrapper as ConditionWrapperV2).items)\n}\n\nexport function isConditionWrapper(\n wrapper: ConditionWrapper | ConditionWrapperV2\n): wrapper is ConditionWrapper {\n return !isConditionWrapperV2(wrapper)\n}\n\nexport function convertConditionWrapperFromV2(\n conditionWrapper: ConditionWrapperV2,\n model: RuntimeFormModel\n): ConditionWrapper {\n let coordinator\n\n if (conditionWrapper.items.length > 1 && !conditionWrapper.coordinator) {\n throw new Error('Coordinator is required for multiple conditions')\n } else {\n coordinator = conditionWrapper.coordinator\n }\n\n const newConditionWrapper: ConditionWrapper = {\n name: conditionWrapper.id,\n displayName: conditionWrapper.displayName,\n value: {\n name: conditionWrapper.id,\n conditions: conditionWrapper.items.map((condition, index) => {\n let newCondition: ConditionData | ConditionRefData\n\n if (isConditionDataV2(condition)) {\n newCondition = convertConditionDataV2(\n model,\n condition,\n index > 0 ? coordinator : undefined\n )\n } else {\n newCondition = convertConditionRefDataFromV2(\n model,\n condition,\n index > 0 ? coordinator : undefined\n )\n }\n\n return newCondition\n })\n }\n }\n\n return newConditionWrapper\n}\n\nexport interface RuntimeFormModel {\n getListById: (listId: string) => List | undefined\n getComponentById: (componentId: string) => ComponentDef | undefined\n getConditionById: (conditionId: string) => ConditionWrapperV2 | undefined\n}\n"],"mappings":"AAIA,SAASA,aAAa;AAiBtB,OAAO,SAASC,iCAAiCA,CAACC,SAA0B,EAAE;EAC5E,OAAOA,SAAS,CAACC,IAAI,KAA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EAAE;MACzB4C,UAAU,EAAEH,gBAAgB,CAAC3C,KAAK,CAAC+C,GAAG,CAAC,CAACpE,SAAS,EAAEqE,KAAK,KAAK;QAC3D,IAAIC,YAA8C;QAElD,IAAI9B,iBAAiB,CAACxC,SAAS,CAAC,EAAE;UAChCsE,YAAY,GAAG7B,sBAAsB,CACnC3B,KAAK,EACLd,SAAS,EACTqE,KAAK,GAAG,CAAC,GAAG3B,WAAW,GAAG6B,SAC5B,CAAC;QACH,CAAC,MAAM;UACLD,YAAY,GAAGnB,6BAA6B,CAC1CrC,KAAK,EACLd,SAAS,EACTqE,KAAK,GAAG,CAAC,GAAG3B,WAAW,GAAG6B,SAC5B,CAAC;QACH;QAEA,OAAOD,YAAY;MACrB,CAAC;IACH;EACF,CAAC;EAED,OAAOJ,mBAAmB;AAC5B","ignoreList":[]}
@@ -169,16 +169,22 @@ export class PagePreviewElements {
169
169
  guidance;
170
170
  heading;
171
171
  addHeading;
172
+ repeatQuestion;
173
+ hasRepeater;
172
174
 
173
175
  /**
174
176
  * @param {string} heading
175
177
  * @param {string} guidance
176
178
  * @param {boolean} [addHeading]
179
+ * @param {string} repeatQuestion
180
+ * @param {boolean} hasRepeater
177
181
  */
178
- constructor(heading, guidance = '', addHeading = undefined) {
182
+ constructor(heading, guidance = '', addHeading = undefined, repeatQuestion = '', hasRepeater = false) {
179
183
  this.heading = heading;
180
184
  this.guidance = guidance;
181
185
  this.addHeading = addHeading ?? heading.length > 0;
186
+ this.repeatQuestion = repeatQuestion;
187
+ this.hasRepeater = hasRepeater;
182
188
  }
183
189
  }
184
190
  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","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,E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ACtD,MAAMC,OAAO,GAAG,sCAAsC;AACtD,MAAMC,OAAO,GAAG,sCAAsC;AAEtD,MAAMC,gBAAgB,GAAG,2BAA6B;EACpD,GAAGN,YAAY;EACff,KAAK,EAAE,CACL;IACEsB,KAAK,EAAE;MAAEC,IAAI,EAAE;IAAmB,CAAC;IACnCA,IAAI,EAAE,kBAAkB;IACxBC,KAAK,EAAE,kBAAkB;IACzBC,EAAE,EAAER;EACN,CAAC,EACD;IACEK,KAAK,EAAE;MAAEC,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":[]}
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","repeatQuestion","hasRepeater","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 repeatQuestion\n hasRepeater\n\n /**\n * @param {string} heading\n * @param {string} guidance\n * @param {boolean} [addHeading]\n * @param {string} repeatQuestion\n * @param {boolean} hasRepeater\n */\n constructor(\n heading,\n guidance = '',\n addHeading = undefined,\n repeatQuestion = '',\n hasRepeater = false\n ) {\n this.heading = heading\n this.guidance = guidance\n this.addHeading = addHeading ?? heading.length > 0\n this.repeatQuestion = repeatQuestion\n this.hasRepeater = hasRepeater\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,E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;AAChB,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA,OAAO,SAASM,uBAAuBA,CAACC,mBAAmB,EAAErD,UAAU,EAAE;EACvE,OAAO,IAAIF,QAAQ,CACjB,IAAIa,uBAAuB,CAAC;IAC1B,GAAG6B,YAAY;IACf,GAAGa;EACL,CAAC,CAAC,EACF,IAAItD,oBAAoB,CAACC,UAAU,CACrC,CAAC;AACH;;AAEA;AACA;AACA;AACA;AACA","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":[],"sources":["../../../../../src/form/form-editor/macros/types.ts"],"sourcesContent":["import { type ComponentType } from '~/src/components/enums.js'\nimport {\n type DateItem,\n type GovukField,\n type ListItemReadonly\n} from '~/src/form/form-editor/types.js'\nimport { type DefaultComponent, type GovukFieldset } from '~/src/index.js'\n\nexport interface AppPreviewErrorPanelMacroErrorTemplate {\n advancedSettingsErrors: []\n baseErrors: { template: unknown; type: string }[]\n}\n\nexport interface AppPreviewErrorPanelMacro {\n errorTemplates: AppPreviewErrorPanelMacroErrorTemplate\n fieldDetails: {\n extraFields: GovukField[]\n basePageFields: GovukField[]\n }\n questionType: ComponentType\n}\n\nexport interface AppPreviewPanelTabsMacro {\n questionType: ComponentType\n previewPageUrl: string\n previewErrorsUrl: string\n errorTemplates: AppPreviewErrorPanelMacroErrorTemplate\n extraFields: GovukField[]\n basePageFields: GovukField[]\n}\n\nexport interface SelectAfterInput {\n afterInput: { html: string }\n}\nexport interface RadioAndCheckboxAfterInputs {\n afterInputs: { html: string }\n}\n\n// GDS components - Select uses afterInput, while Radio uses afterInputs\nexport type FormGroupAfterInput = SelectAfterInput | RadioAndCheckboxAfterInputs\n\nexport interface QuestionBaseModel {\n id?: string\n name?: string\n content?: string\n attributes?: Record<string, string>\n label?: DefaultComponent\n hint?: DefaultComponent\n fieldset?: GovukFieldset\n readonly items?: ListItemReadonly[] | DateItem[]\n text?: string\n formGroup?: FormGroupAfterInput\n type?: 'text' | 'number' | 'boolean'\n classes?: string\n}\n\nexport interface AppPreviewPanelMacro extends AppPreviewPanelTabsMacro {\n model: QuestionBaseModel\n}\n\nexport interface PagePreviewComponent {\n model: QuestionBaseModel\n questionType: ComponentType\n}\n\nexport interface PagePreviewPanelMacro {\n readonly pageTitle: {\n text: string\n classes: string\n }\n readonly guidance: {\n text: string\n classes: string\n }\n readonly components: PagePreviewComponent[]\n}\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"file":"types.js","names":[],"sources":["../../../../../src/form/form-editor/macros/types.ts"],"sourcesContent":["import { type ComponentType } from '~/src/components/enums.js'\nimport {\n type DateItem,\n type GovukField,\n type ListItemReadonly\n} from '~/src/form/form-editor/types.js'\nimport { type DefaultComponent, type GovukFieldset } from '~/src/index.js'\n\nexport interface AppPreviewErrorPanelMacroErrorTemplate {\n advancedSettingsErrors: []\n baseErrors: { template: unknown; type: string }[]\n}\n\nexport interface AppPreviewErrorPanelMacro {\n errorTemplates: AppPreviewErrorPanelMacroErrorTemplate\n fieldDetails: {\n extraFields: GovukField[]\n basePageFields: GovukField[]\n }\n questionType: ComponentType\n}\n\nexport interface AppPreviewPanelTabsMacro {\n questionType: ComponentType\n previewPageUrl: string\n previewErrorsUrl: string\n errorTemplates: AppPreviewErrorPanelMacroErrorTemplate\n extraFields: GovukField[]\n basePageFields: GovukField[]\n}\n\nexport interface SelectAfterInput {\n afterInput: { html: string }\n}\nexport interface RadioAndCheckboxAfterInputs {\n afterInputs: { html: string }\n}\n\n// GDS components - Select uses afterInput, while Radio uses afterInputs\nexport type FormGroupAfterInput = SelectAfterInput | RadioAndCheckboxAfterInputs\n\nexport interface QuestionBaseModel {\n id?: string\n name?: string\n content?: string\n attributes?: Record<string, string>\n label?: DefaultComponent\n hint?: DefaultComponent\n fieldset?: GovukFieldset\n readonly items?: ListItemReadonly[] | DateItem[]\n text?: string\n formGroup?: FormGroupAfterInput\n type?: 'text' | 'number' | 'boolean'\n classes?: string\n}\n\nexport interface AppPreviewPanelMacro extends AppPreviewPanelTabsMacro {\n model: QuestionBaseModel\n}\n\nexport interface PagePreviewComponent {\n model: QuestionBaseModel\n questionType: ComponentType\n}\n\nexport interface PagePreviewPanelMacro {\n readonly pageTitle: {\n text: string\n classes: string\n }\n readonly guidance: {\n text: string\n classes: string\n }\n readonly components: PagePreviewComponent[]\n readonly sectionTitle?: {\n text: string\n classes: string\n }\n readonly repeaterButton?: {\n text: string\n classes: string\n }\n}\n"],"mappings":"","ignoreList":[]}
@@ -3,7 +3,9 @@ import { HIGHLIGHT_CLASS } from "../constants.js";
3
3
  import { ContentElements } from "../content.js";
4
4
  import { mapComponentToPreviewQuestion } from "../helpers.js";
5
5
  import { Markdown } from "../markdown.js";
6
+ import { hasRepeater } from "../../../../index.js";
6
7
  import { hasComponents } from "../../../../pages/helpers.js";
8
+
7
9
  /**
8
10
  * @type {QuestionRenderer}
9
11
  */
@@ -46,8 +48,28 @@ export class PagePreviewElements {
46
48
  get addHeading() {
47
49
  return this._page.title.length > 0;
48
50
  }
51
+ get repeatQuestion() {
52
+ if (hasRepeater(this._page)) {
53
+ return this._page.repeat.options.title;
54
+ }
55
+ return undefined;
56
+ }
57
+ get hasRepeater() {
58
+ return hasRepeater(this._page);
59
+ }
49
60
  }
50
61
 
62
+ /**
63
+ * Enum for Highlight classes
64
+ * @readonly
65
+ * @enum {string}
66
+ */
67
+ const HighlightClass = {
68
+ TITLE: 'title',
69
+ GUIDANCE: 'guidance',
70
+ REPEATER: 'repeater'
71
+ };
72
+
51
73
  /**
52
74
  * @implements {PagePreviewPanelMacro}
53
75
  */
@@ -73,7 +95,7 @@ export class PreviewPageController {
73
95
  */
74
96
  #pageRenderer;
75
97
  /**
76
- * @type { undefined | 'title' | 'guidance'}
98
+ * @type { undefined | HighlightClass }
77
99
  * @protected
78
100
  */
79
101
  _highlighted = undefined;
@@ -82,6 +104,11 @@ export class PreviewPageController {
82
104
  * @private
83
105
  */
84
106
  _guidanceText = '';
107
+ /**
108
+ * @type { string }
109
+ * @protected
110
+ */
111
+ _sectionTitle = '';
85
112
  /**
86
113
  * @type {Markdown}
87
114
  * @private
@@ -98,6 +125,11 @@ export class PreviewPageController {
98
125
  * @private
99
126
  */
100
127
  _showTitle = true;
128
+ /**
129
+ * @type {boolean}
130
+ */
131
+ #isRepeater = false;
132
+
101
133
  /**
102
134
  * @param {ComponentDef[]} components
103
135
  * @param {PageOverviewElements} elements
@@ -114,8 +146,15 @@ export class PreviewPageController {
114
146
  this._showTitle = elements.addHeading;
115
147
  this.#pageRenderer = renderer;
116
148
  this.#title = elements.heading;
149
+ this._sectionTitle = elements.repeatQuestion ?? '';
150
+ this.#isRepeater = elements.hasRepeater;
117
151
  }
118
152
 
153
+ /**
154
+ * @type {typeof HighlightClass}
155
+ */
156
+ static HighlightClass = HighlightClass;
157
+
119
158
  /**
120
159
  * @param { Question | Markdown | undefined} firstQuestion
121
160
  * @param {Question[]} questions
@@ -221,7 +260,7 @@ export class PreviewPageController {
221
260
  get guidance() {
222
261
  return {
223
262
  text: this.guidanceText,
224
- classes: this._highlighted === 'guidance' ? 'highlight' : ''
263
+ classes: this.#isHighlighted(HighlightClass.GUIDANCE)
225
264
  };
226
265
  }
227
266
 
@@ -231,7 +270,7 @@ export class PreviewPageController {
231
270
  get pageTitle() {
232
271
  return {
233
272
  text: this.title,
234
- classes: this._highlighted === 'title' ? HIGHLIGHT_CLASS : ''
273
+ classes: this.#isHighlighted(HighlightClass.TITLE)
235
274
  };
236
275
  }
237
276
  render() {
@@ -266,7 +305,75 @@ export class PreviewPageController {
266
305
  this.render();
267
306
  }
268
307
  highlightTitle() {
269
- this.setHighLighted('title');
308
+ this.setHighLighted(HighlightClass.TITLE);
309
+ }
310
+ setRepeater() {
311
+ this.#isRepeater = true;
312
+ this.render();
313
+ }
314
+ unsetRepeater() {
315
+ this.#isRepeater = false;
316
+ this.render();
317
+ }
318
+ get isRepeater() {
319
+ return this.#isRepeater;
320
+ }
321
+
322
+ /**
323
+ * @returns {{classes: string, text: string} | undefined}
324
+ */
325
+ get sectionTitle() {
326
+ if (this.sectionTitleText === undefined) {
327
+ return undefined;
328
+ }
329
+ return {
330
+ classes: this.#isHighlighted(HighlightClass.REPEATER),
331
+ text: this.sectionTitleText
332
+ };
333
+ }
334
+ get repeaterText() {
335
+ if (!this.#isRepeater) {
336
+ return undefined;
337
+ }
338
+ if (!this._sectionTitle.length) {
339
+ return 'Question set name';
340
+ }
341
+ return this._sectionTitle + ' 1';
342
+ }
343
+
344
+ /**
345
+ * @param {string | undefined} val
346
+ */
347
+ set sectionTitleText(val) {
348
+ this._sectionTitle = val ?? '';
349
+ this.render();
350
+ }
351
+ get sectionTitleText() {
352
+ if (this.#isRepeater) {
353
+ return this.repeaterText;
354
+ }
355
+ return undefined;
356
+ }
357
+ get repeaterButton() {
358
+ if (this.repeaterButtonText === undefined) {
359
+ return undefined;
360
+ }
361
+ return {
362
+ classes: this.#isHighlighted(HighlightClass.REPEATER),
363
+ text: this.repeaterButtonText
364
+ };
365
+ }
366
+ get repeaterButtonText() {
367
+ if (!this.#isRepeater) {
368
+ return undefined;
369
+ }
370
+ if (this._sectionTitle === '') {
371
+ return '[question set name]';
372
+ }
373
+ const [firstToken, ...rest] = this._sectionTitle;
374
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
375
+ const restOfStr = rest ? rest.join('') : '';
376
+ return firstToken.toLowerCase() + restOfStr;
270
377
  }
271
378
 
272
379
  /**
@@ -303,11 +410,11 @@ export class PreviewPageController {
303
410
  }
304
411
  highlightGuidance() {
305
412
  this._guidanceComponent.highlightContent();
306
- this.setHighLighted('guidance');
413
+ this.setHighLighted(HighlightClass.GUIDANCE);
307
414
  }
308
415
 
309
416
  /**
310
- * @param {'title'|'guidance'} highlightSection
417
+ * @param {HighlightClass} highlightSection
311
418
  */
312
419
  setHighLighted(highlightSection) {
313
420
  this._highlighted = highlightSection;
@@ -318,6 +425,14 @@ export class PreviewPageController {
318
425
  this._guidanceComponent.unHighlightContent();
319
426
  this.render();
320
427
  }
428
+
429
+ /**
430
+ * @param {string} field
431
+ * @returns {string}
432
+ */
433
+ #isHighlighted(field) {
434
+ return this._highlighted === field ? HIGHLIGHT_CLASS : '';
435
+ }
321
436
  }
322
437
 
323
438
  /**
@@ -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","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;EACvB;AACF;AACA;AACA;EACEC,MAAMA,CAACC,iBAAiB,EAAEC,kBAAkB,EAAE;IAC5C;EAAA;AAEJ,CAAC;;AAED;AACA;AACA;AACA,OAAO,MAAMC,mBAAmB,CAAC;EAC/B;AACF;AACA;AACA;EACEC,KAAK;;EAEL;AACF;AACA;EACEC,WAAWA,CAACC,IAAI,EAAE;IAChB,IAAI,CAACF,KAAK,GAAGE,IAAI;EACnB;EAEA,IAAIC,OAAOA,CAAA,EAAG;IACZ,OAAO,IAAI,CAACH,KAAK,CAACI,KAAK;EACzB;EAEA,IAAIC,QAAQA,CAAA,EAAG;IACb,IAAI,CAACX,aAAa,CAAC,IAAI,CAACM,KAAK,CAAC,IAAI,CAAC,IAAI,CAACA,KAAK,CAACM,UAAU,CAACC,MAAM,EAAE;MAC/D,OAAO,EAAE;IACX;IAEA,MAAM,CAACC,yBAAyB,CAAC,GAAG,IAAI,CAACR,KAAK,CAACM,UAAU;IAEzD,OAAOE,yBAAyB,CAACC,IAAI,KAAKpB,aAAa,CAACI,QAAQ,GAC5De,yBAAyB,CAACE,OAAO,GACjC,EAAE;EACR;EAEA,IAAIC,UAAUA,CAAA,EAAG;IACf,OAAO,IAAI,CAACX,KAAK,CAACI,KAAK,CAACG,MAAM,GAAG,CAAC;EACpC;AACF;;AAEA;AACA;AACA;AACA,OAAO,MAAMK,qBAAqB,CAAC;EACjC,OAAOC,IAAI,GAAG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AAOrC,uBAAuBA,CAAA,EAAG;IAC/B,MAAMsC,eAAe,GAAG,IAAIpE,eAAe,CAAC;MAC1CkB,IAAI,EAAEpB,aAAa,CAACI,QAAQ;MAC5BW,KAAK,EAAE,oBAAoB;MAC3BwD,IAAI,EAAE,mBAAmB;MACzBlD,OAAO,EAAE,eAAe;MACxBmD,OAAO,EAAE,CAAC;IACZ,CAAC,CAAC;IACF,MAAMC,iBAAiB,GAAG,IAAIrE,QAAQ,CAACkE,eAAe,EAAEhE,gBAAgB,CAAC;;IAEzE;IACAmE,iBAAiB,CAACC,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":[]}
1
+ {"version":3,"file":"page-controller.js","names":["ComponentType","HIGHLIGHT_CLASS","ContentElements","mapComponentToPreviewQuestion","Markdown","hasRepeater","hasComponents","questionRenderer","render","_questionTemplate","_questionBaseModel","PagePreviewElements","_page","constructor","page","heading","title","guidance","components","length","possibleGuidanceComponent","type","content","addHeading","repeatQuestion","repeat","options","undefined","HighlightClass","TITLE","GUIDANCE","REPEATER","PreviewPageController","PATH","_pageTemplate","_components","pageRenderer","_highlighted","_guidanceText","_sectionTitle","_emptyGuidance","createGuidanceComponent","_guidanceComponent","_showTitle","isRepeater","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","isHighlighted","pageTitle","titleAndFirstTitleSame","value","highlightTitle","setHighLighted","setRepeater","unsetRepeater","sectionTitle","sectionTitleText","repeaterText","val","repeaterButton","repeaterButtonText","firstToken","rest","restOfStr","join","toLowerCase","guidanceElement","name","guidanceComponent","highlightContent","highlightGuidance","highlightSection","clearHighlight","unHighlightContent","#isHighlighted","field"],"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 { hasRepeater } from '~/src/index.js'\nimport { hasComponents } from '~/src/pages/helpers.js'\n\n/**\n * @type {QuestionRenderer}\n */\nconst questionRenderer = {\n /**\n * @param {string} _questionTemplate\n * @param {QuestionBaseModel} _questionBaseModel\n */\n render(_questionTemplate, _questionBaseModel) {\n //\n }\n}\n\n/**\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 get repeatQuestion() {\n if (hasRepeater(this._page)) {\n return this._page.repeat.options.title\n }\n return undefined\n }\n\n get hasRepeater() {\n return hasRepeater(this._page)\n }\n}\n\n/**\n * Enum for Highlight classes\n * @readonly\n * @enum {string}\n */\nconst HighlightClass = {\n TITLE: 'title',\n GUIDANCE: 'guidance',\n REPEATER: 'repeater'\n}\n\n/**\n * @implements {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 | HighlightClass }\n * @protected\n */\n _highlighted = undefined\n /**\n * @type {string}\n * @private\n */\n _guidanceText = ''\n /**\n * @type { string }\n * @protected\n */\n _sectionTitle = ''\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 * @type {boolean}\n */\n #isRepeater = false\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 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 this._sectionTitle = elements.repeatQuestion ?? ''\n this.#isRepeater = elements.hasRepeater\n }\n\n /**\n * @type {typeof HighlightClass}\n */\n static HighlightClass = 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 {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.#isHighlighted(HighlightClass.GUIDANCE)\n }\n }\n\n /**\n * @returns {{ text: string, classes: string }}\n */\n get pageTitle() {\n return {\n text: this.title,\n classes: this.#isHighlighted(HighlightClass.TITLE)\n }\n }\n\n 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(HighlightClass.TITLE)\n }\n\n setRepeater() {\n this.#isRepeater = true\n this.render()\n }\n\n unsetRepeater() {\n this.#isRepeater = false\n this.render()\n }\n\n get isRepeater() {\n return this.#isRepeater\n }\n\n /**\n * @returns {{classes: string, text: string} | undefined}\n */\n get sectionTitle() {\n if (this.sectionTitleText === undefined) {\n return undefined\n }\n return {\n classes: this.#isHighlighted(HighlightClass.REPEATER),\n text: this.sectionTitleText\n }\n }\n\n 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 * @param {string | undefined} val\n */\n set sectionTitleText(val) {\n this._sectionTitle = val ?? ''\n this.render()\n }\n\n get sectionTitleText() {\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(HighlightClass.REPEATER),\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 * 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(HighlightClass.GUIDANCE)\n }\n\n /**\n * @param {HighlightClass} highlightSection\n */\n setHighLighted(highlightSection) {\n this._highlighted = highlightSection\n this.render()\n }\n\n clearHighlight() {\n this._highlighted = undefined\n\n this._guidanceComponent.unHighlightContent()\n this.render()\n }\n\n /**\n * @param {string} field\n * @returns {string}\n */\n #isHighlighted(field) {\n return this._highlighted === field ? HIGHLIGHT_CLASS : ''\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,WAAW;AACpB,SAASC,aAAa;;AAEtB;AACA;AACA;AACA,MAAMC,gBAAgB,GAAG;EACvB;AACF;AACA;AACA;EACEC,MAAMA,CAACC,iBAAiB,EAAEC,kBAAkB,EAAE;IAC5C;EAAA;AAEJ,CAAC;;AAED;AACA;AACA;AACA,OAAO,MAAMC,mBAAmB,CAAC;EAC/B;AACF;AACA;AACA;EACEC,KAAK;;EAEL;AACF;AACA;EACEC,WAAWA,CAACC,IAAI,EAAE;IAChB,IAAI,CAACF,KAAK,GAAGE,IAAI;EACnB;EAEA,IAAIC,OAAOA,CAAA,EAAG;IACZ,OAAO,IAAI,CAACH,KAAK,CAACI,KAAK;EACzB;EAEA,IAAIC,QAAQA,CAAA,EAAG;IACb,IAAI,CAACX,aAAa,CAAC,IAAI,CAACM,KAAK,CAAC,IAAI,CAAC,IAAI,CAACA,KAAK,CAACM,UAAU,CAACC,MAAM,EAAE;MAC/D,OAAO,EAAE;IACX;IAEA,MAAM,CAACC,yBAAyB,CAAC,GAAG,IAAI,CAACR,KAAK,CAACM,UAAU;IAEzD,OAAOE,yBAAyB,CAACC,IAAI,KAAKrB,aAAa,CAACI,QAAQ,GAC5DgB,yBAAyB,CAACE,OAAO,GACjC,EAAE;EACR;EAEA,IAAIC,UAAUA,CAAA,EAAG;IACf,OAAO,IAAI,CAACX,KAAK,CAACI,KAAK,CAACG,MAAM,GAAG,CAAC;EACpC;EAEA,IAAIK,cAAcA,CAAA,EAAG;IACnB,IAA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,KAAK,GAAGtG,eAAe,GAAG,EAAE;EAC3D;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":[],"sources":["../../../../../src/form/form-editor/preview/types.ts"],"sourcesContent":["import {\n type PagePreviewPanelMacro,\n type QuestionBaseModel\n} from '~/src/form/form-editor/macros/types.js'\nimport { type AutocompleteQuestion } from '~/src/form/form-editor/preview/autocomplete.js'\nimport { type DateInputQuestion } from '~/src/form/form-editor/preview/date-input.js'\nimport { type EmailAddressQuestion } from '~/src/form/form-editor/preview/email-address.js'\nimport { type ListSortableQuestion } from '~/src/form/form-editor/preview/list-sortable.js'\nimport { type LongAnswerQuestion } from '~/src/form/form-editor/preview/long-answer.js'\nimport { type PhoneNumberQuestion } from '~/src/form/form-editor/preview/phone-number.js'\nimport { type Question } from '~/src/form/form-editor/preview/question.js'\nimport { type RadioSortableQuestion } from '~/src/form/form-editor/preview/radio-sortable.js'\nimport { type SelectSortableQuestion } from '~/src/form/form-editor/preview/select-sortable.js'\nimport { type ShortAnswerQuestion } from '~/src/form/form-editor/preview/short-answer.js'\nimport { type UkAddressQuestion } from '~/src/form/form-editor/preview/uk-address.js'\nimport { type ListElement } from '~/src/form/form-editor/types.js'\nexport { type QuestionBaseModel } from '~/src/form/form-editor/macros/types.js'\nexport interface BaseSettings {\n question: string\n hintText: string\n optional: boolean\n shortDesc: string\n items: ListElement[]\n content: string\n attributes?: Record<string, string>\n}\n\nexport interface DefaultComponent {\n id?: string\n text: string\n classes: string\n}\n\nexport interface GovukFieldset {\n legend: DefaultComponent\n}\n\nexport type ListenerRow = [\n HTMLInputElement | null,\n (target: HTMLInputElement, e: Event) => void,\n keyof HTMLElementEventMap\n]\n\nexport interface DomElementsBase {\n readonly values?: BaseSettings\n autocompleteOptions?: string\n setPreviewHTML(value: string): void\n setPreviewDOM(element: HTMLElement): void\n}\n\nexport interface QuestionElements extends DomElementsBase {\n readonly values: BaseSettings\n}\n\nexport interface AutocompleteElements extends QuestionElements {\n autocompleteOptions: string\n}\n\nexport interface RenderBase {\n render(questionTemplate: string, renderContext: RenderContext): void\n}\n\nexport interface QuestionRenderContext {\n model: QuestionBaseModel\n}\n\nexport interface PageRenderContext {\n params: PagePreviewPanelMacro\n}\n\nexport type RenderContext = QuestionRenderContext | PageRenderContext\n\nexport interface HTMLBuilder {\n buildHTML(questionTemplate: string, renderContext: RenderContext): string\n}\n\nexport interface QuestionRenderer {\n render(questionTemplate: string, questionBaseModel: QuestionBaseModel): void\n}\n\nexport interface PageRenderer {\n render(pageTemplate: string, pagePreview: PagePreviewPanelMacro): void\n}\n\nexport type Renderer = QuestionRenderer | PageRenderer\n\nexport interface ListElements extends QuestionElements {\n afterInputsHTML: string\n}\n\nexport interface PageOverviewElements {\n heading: string\n guidance: string\n addHeading: boolean\n}\n\nexport type PreviewQuestion =\n | DateInputQuestion\n | EmailAddressQuestion\n | ListSortableQuestion\n | LongAnswerQuestion\n | PhoneNumberQuestion\n | Question\n | RadioSortableQuestion\n | SelectSortableQuestion\n | ShortAnswerQuestion\n | UkAddressQuestion\n | AutocompleteQuestion\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"file":"types.js","names":[],"sources":["../../../../../src/form/form-editor/preview/types.ts"],"sourcesContent":["import {\n type PagePreviewPanelMacro,\n type QuestionBaseModel\n} from '~/src/form/form-editor/macros/types.js'\nimport { type AutocompleteQuestion } from '~/src/form/form-editor/preview/autocomplete.js'\nimport { type DateInputQuestion } from '~/src/form/form-editor/preview/date-input.js'\nimport { type EmailAddressQuestion } from '~/src/form/form-editor/preview/email-address.js'\nimport { type ListSortableQuestion } from '~/src/form/form-editor/preview/list-sortable.js'\nimport { type LongAnswerQuestion } from '~/src/form/form-editor/preview/long-answer.js'\nimport { type PhoneNumberQuestion } from '~/src/form/form-editor/preview/phone-number.js'\nimport { type Question } from '~/src/form/form-editor/preview/question.js'\nimport { type RadioSortableQuestion } from '~/src/form/form-editor/preview/radio-sortable.js'\nimport { type SelectSortableQuestion } from '~/src/form/form-editor/preview/select-sortable.js'\nimport { type ShortAnswerQuestion } from '~/src/form/form-editor/preview/short-answer.js'\nimport { type UkAddressQuestion } from '~/src/form/form-editor/preview/uk-address.js'\nimport { type ListElement } from '~/src/form/form-editor/types.js'\nexport { type QuestionBaseModel } from '~/src/form/form-editor/macros/types.js'\nexport interface BaseSettings {\n question: string\n hintText: string\n optional: boolean\n shortDesc: string\n items: ListElement[]\n content: string\n attributes?: Record<string, string>\n}\n\nexport interface DefaultComponent {\n id?: string\n text: string\n classes: string\n}\n\nexport interface GovukFieldset {\n legend: DefaultComponent\n}\n\nexport type ListenerRow = [\n HTMLInputElement | null,\n (target: HTMLInputElement, e: Event) => void,\n keyof HTMLElementEventMap\n]\n\nexport interface DomElementsBase {\n readonly values?: BaseSettings\n autocompleteOptions?: string\n setPreviewHTML(value: string): void\n setPreviewDOM(element: HTMLElement): void\n}\n\nexport interface QuestionElements extends DomElementsBase {\n readonly values: BaseSettings\n}\n\nexport interface AutocompleteElements extends QuestionElements {\n autocompleteOptions: string\n}\n\nexport interface RenderBase {\n render(questionTemplate: string, renderContext: RenderContext): void\n}\n\nexport interface QuestionRenderContext {\n model: QuestionBaseModel\n}\n\nexport interface PageRenderContext {\n params: PagePreviewPanelMacro\n}\n\nexport type RenderContext = QuestionRenderContext | PageRenderContext\n\nexport interface HTMLBuilder {\n buildHTML(questionTemplate: string, renderContext: RenderContext): string\n}\n\nexport interface QuestionRenderer {\n render(questionTemplate: string, questionBaseModel: QuestionBaseModel): void\n}\n\nexport interface PageRenderer {\n render(pageTemplate: string, pagePreview: PagePreviewPanelMacro): void\n}\n\nexport type Renderer = QuestionRenderer | PageRenderer\n\nexport interface ListElements extends QuestionElements {\n afterInputsHTML: string\n}\n\nexport interface PageOverviewElements {\n heading: string\n guidance: string\n addHeading: boolean\n repeatQuestion: string | undefined\n hasRepeater: boolean\n}\n\nexport type PreviewQuestion =\n | DateInputQuestion\n | EmailAddressQuestion\n | ListSortableQuestion\n | LongAnswerQuestion\n | PhoneNumberQuestion\n | Question\n | RadioSortableQuestion\n | SelectSortableQuestion\n | ShortAnswerQuestion\n | UkAddressQuestion\n | AutocompleteQuestion\n"],"mappings":"","ignoreList":[]}
@@ -118,11 +118,15 @@ export class PagePreviewElements implements PageOverviewElements {
118
118
  * @param {string} heading
119
119
  * @param {string} guidance
120
120
  * @param {boolean} [addHeading]
121
+ * @param {string} repeatQuestion
122
+ * @param {boolean} hasRepeater
121
123
  */
122
- constructor(heading: string, guidance?: string, addHeading?: boolean);
124
+ constructor(heading: string, guidance?: string, addHeading?: boolean, repeatQuestion?: string, hasRepeater?: boolean);
123
125
  guidance: string;
124
126
  heading: string;
125
127
  addHeading: boolean;
128
+ repeatQuestion: string;
129
+ hasRepeater: boolean;
126
130
  }
127
131
  export const baseElements: BaseSettings;
128
132
  export namespace listElementsStub {
@@ -1 +1 @@
1
- {"version":3,"file":"preview.d.ts","sourceRoot":"","sources":["../../../../../src/form/form-editor/__stubs__/preview.js"],"names":[],"mappings":"AAmOA;;;;GAIG;AACH,6DAJW,OAAO,CAAC,YAAY,CAAC,cACrB,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC,GAC1C,QAAQ,CAUpB;AA9OD;;GAEG;AACH;IAqBE;;;;OAIG;IACH,oCAHW,MAAM,kBACN,aAAa,GAFX,MAAM,CAMlB;IAtBD;;OAEG;IACH,wBAFW,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC,EAItD;IAVD;;OAEG;IACH,YAFU,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC,CAE5C;IASV;;;OAGG;IACH,yBAHW,MAAM,qBACN,iBAAiB,QAI3B;CAUF;AAED;;GAEG;AACH;IAqBE;;;;OAIG;IACH,oCAHW,MAAM,kB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AA;AAEtD,gCAAoC,YAAY,CA4B9C"}
1
+ {"version":3,"file":"preview.d.ts","sourceRoot":"","sources":["../../../../../src/form/form-editor/__stubs__/preview.js"],"names":[],"mappings":"AA+OA;;;;GAIG;AACH,6DAJW,OAAO,CAAC,YAAY,CAAC,cACrB,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC,GAC1C,QAAQ,CAUpB;AA1PD;;GAEG;AACH;IAqBE;;;;OAIG;IACH,oCAHW,MAAM,kBACN,aAAa,GAFX,MAAM,CAMlB;IAtBD;;OAEG;IACH,wBAFW,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC,EAItD;IAVD;;OAEG;IACH,YAFU,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC,CAE5C;IASV;;;OAGG;IACH,yBAHW,MAAM,qBACN,iBAAiB,QAI3B;CAUF;AAED;;GAEG;AACH;IAqBE;;;;OAIG;IACH,oCAHW,MAAM,kBACN,aAAa,GAFX,MAAM,CAMlB;IAtBD;;OAEG;IACH,wBAFW,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC,EAI1D;IAVD;;OAEG;IACH,YAFU,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC,CAEhD;IASV;;;OAGG;IACH,qBAHW,MAAM,yBACN,qBAAqB,QAI/B;CAUF;AAED;;GAEG;AACH;IA2BE;;OAEG;IACH,yEAFW,YAAY,EAStB;IApCD;;OAEG;IACH,4BAAc;IACd,iBAAiB;IACjB,4BAAc;IACd,iBAAiB;IACjB,6BAAiB;IACjB;;;OAGG;IACH,sBAHU,MAAM,CAGD;IACf;;;OAGG;IACH,oBAHU,MAAM,CAGH;IACb;;;;OAIG;IACH,eAAW;IACX,wBAA2E;IAc3E;;OAEG;IACH,cAFa,YAAY,CAWxB;IAED;;OAEG;IACH,uBAFW,MAAM,QAIhB;IAED;;OAEG;IACH,sBAFW,WAAW,QAIrB;CACF;AAED;;GAEG;AACH;IACE;;OAEG;IACH,kDAFW,YAAY,GAAG;QAAC,mBAAmB,EAAE,MAAM,CAAA;KAAC,EAKtD;IADC,4BAA8C;CAEjD;AAED;;GAEG;AACH;IAOE;;;;;;OAMG;IACH,qBANW,MAAM,aACN,MAAM,eACN,OAAO,mBACP,MAAM,gBACN,OAAO,EAcjB;IAzBD,iBAAQ;IACR,gBAAO;IACP,oBAAU;IACV,uBAAc;IACd,qBAAW;CAsBZ;AAED,2BAAuC,YAAY,CAQjD;;;;;;;;kCA+D8K,yCAAyC;uCAAzC,yCAAyC;yBAjQhM,4CAA4C;sCAiQ2G,yCAAyC;mCAAzC,yCAAyC;kCAAzC,yCAAyC;2CAD/K,wCAAwC;kCAC8F,yCAAyC;0CAAzC,yCAAyC;0CAAzC,yCAAyC;AA7DzN,uBAAgB,sCAAsC,CAAA;AACtD,uBAAgB,sCAAsC,CAAA;AACtD,uBAAgB,sCAAsC,CAAA;AACtD,uBAAgB,sCAAsC,CAAA;AAEtD,gCAAoC,YAAY,CA4B9C"}
@@ -66,5 +66,13 @@ export interface PagePreviewPanelMacro {
66
66
  classes: string;
67
67
  };
68
68
  readonly components: PagePreviewComponent[];
69
+ readonly sectionTitle?: {
70
+ text: string;
71
+ classes: string;
72
+ };
73
+ readonly repeaterButton?: {
74
+ text: string;
75
+ classes: string;
76
+ };
69
77
  }
70
78
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/form/form-editor/macros/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,2BAA2B,CAAA;AAC9D,OAAO,EACL,KAAK,QAAQ,EACb,KAAK,UAAU,EACf,KAAK,gBAAgB,EACtB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;AAED,MAAM,WAAW,oBAAqB,SAAQ,wBAAwB;IACpE,KAAK,EAAE,iBAAiB,CAAA;CACzB;AAED,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,iBAAiB,CAAA;IACxB,YAAY,EAAE,aAAa,CAAA;CAC5B;AAED,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,SAAS,EAAE;QAClB,IAAI,EAAE,MAAM,CAAA;QACZ,OAAO,EAAE,MAAM,CAAA;KAChB,CAAA;IACD,QAAQ,CAAC,QAAQ,EAAE;QACjB,IAAI,EAAE,MAAM,CAAA;QACZ,OAAO,EAAE,MAAM,CAAA;KAChB,CAAA;IACD,QAAQ,CAAC,UAAU,EAAE,oBAAoB,EAAE,CAAA;IAC3C,QAAQ,CAAC,YAAY,CAAC,EAAE;QACtB,IAAI,EAAE,MAAM,CAAA;QACZ,OAAO,EAAE,MAAM,CAAA;KAChB,CAAA;IACD,QAAQ,CAAC,cAAc,CAAC,EAAE;QACxB,IAAI,EAAE,MAAM,CAAA;QACZ,OAAO,EAAE,MAAM,CAAA;KAChB,CAAA;CACF"}
@@ -14,12 +14,18 @@ export class PagePreviewElements implements PageOverviewElements {
14
14
  get heading(): string;
15
15
  get guidance(): string;
16
16
  get addHeading(): boolean;
17
+ get repeatQuestion(): string | undefined;
18
+ get hasRepeater(): boolean;
17
19
  }
18
20
  /**
19
21
  * @implements {PagePreviewPanelMacro}
20
22
  */
21
23
  export class PreviewPageController implements PagePreviewPanelMacro {
22
24
  static PATH: string;
25
+ /**
26
+ * @type {typeof HighlightClass}
27
+ */
28
+ static HighlightClass: typeof HighlightClass;
23
29
  /**
24
30
  * Creates a dummy component for when guidance is highlighted
25
31
  * but no guidance text exists
@@ -51,15 +57,20 @@ export class PreviewPageController implements PagePreviewPanelMacro {
51
57
  */
52
58
  protected _components: Question[];
53
59
  /**
54
- * @type { undefined | 'title' | 'guidance'}
60
+ * @type { undefined | HighlightClass }
55
61
  * @protected
56
62
  */
57
- protected _highlighted: undefined | "title" | "guidance";
63
+ protected _highlighted: undefined | HighlightClass;
58
64
  /**
59
65
  * @type {string}
60
66
  * @private
61
67
  */
62
68
  private _guidanceText;
69
+ /**
70
+ * @type { string }
71
+ * @protected
72
+ */
73
+ protected _sectionTitle: string;
63
74
  /**
64
75
  * @type {Markdown}
65
76
  * @private
@@ -127,11 +138,32 @@ export class PreviewPageController implements PagePreviewPanelMacro {
127
138
  */
128
139
  get title(): string;
129
140
  highlightTitle(): void;
141
+ setRepeater(): void;
142
+ unsetRepeater(): void;
143
+ get isRepeater(): boolean;
144
+ /**
145
+ * @returns {{classes: string, text: string} | undefined}
146
+ */
147
+ get sectionTitle(): {
148
+ classes: string;
149
+ text: string;
150
+ } | undefined;
151
+ get repeaterText(): string | undefined;
152
+ /**
153
+ * @param {string | undefined} val
154
+ */
155
+ set sectionTitleText(val: string | undefined);
156
+ get sectionTitleText(): string | undefined;
157
+ get repeaterButton(): {
158
+ classes: string;
159
+ text: string;
160
+ } | undefined;
161
+ get repeaterButtonText(): string | undefined;
130
162
  highlightGuidance(): void;
131
163
  /**
132
- * @param {'title'|'guidance'} highlightSection
164
+ * @param {HighlightClass} highlightSection
133
165
  */
134
- setHighLighted(highlightSection: "title" | "guidance"): void;
166
+ setHighLighted(highlightSection: HighlightClass): void;
135
167
  clearHighlight(): void;
136
168
  #private;
137
169
  }
@@ -139,6 +171,15 @@ import type { PageOverviewElements } from '../../../../form/form-editor/preview/
139
171
  import type { Page } from '../../../../form/form-definition/types.js';
140
172
  import type { PagePreviewPanelMacro } from '../../../../form/form-editor/macros/types.js';
141
173
  import type { Question } from '../../../../form/form-editor/preview/question.js';
174
+ /**
175
+ * Enum for Highlight classes
176
+ */
177
+ type HighlightClass = string;
178
+ declare namespace HighlightClass {
179
+ let TITLE: string;
180
+ let GUIDANCE: string;
181
+ let REPEATER: string;
182
+ }
142
183
  import { Markdown } from '../../../../form/form-editor/preview/markdown.js';
143
184
  import type { PagePreviewComponent } from '../../../../form/form-editor/macros/types.js';
144
185
  import type { PreviewComponent } from '../../../../form/form-editor/preview/preview.js';
@@ -146,4 +187,5 @@ import type { QuestionBaseModel } from '../../../../form/form-editor/preview/typ
146
187
  import type { ComponentDef } from '../../../../components/types.js';
147
188
  import type { FormDefinition } from '../../../../form/form-definition/types.js';
148
189
  import type { PageRenderer } from '../../../../form/form-editor/preview/types.js';
190
+ export {};
149
191
  //# sourceMappingURL=page-controller.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"page-controller.d.ts","sourceRoot":"","sources":["../../../../../../src/form/form-editor/preview/controller/page-controller.js"],"names":[],"mappings":"AAmBA;;GAEG;AACH;IAOE;;OAEG;IACH,kBAFW,IAAI,EAId;IAXD;;;OAGG;IACH,cAAK;IASL,sBAEC;IAED,uBAUC;IAED,0BAEC;CACF;AAED;;GAEG;AACH;IACE,oBAAoC;IA2PpC;;;;OAIG;IACH,kCAFa,QAAQ,CAepB;IAED;;;;;OAKG;IACH,4CAKC;IA5OD;;;;;OAKG;IACH,wBALW,YAAY,EAAE,YACd,oBAAoB,cACpB,cAAc,YACd,YAAY,EAkBtB;IAnED;;;OAGG;IACH,yBAHU,MAAM,CAGkD;IAClE;;;OAGG;IACH,uBAFU,QAAQ,EAAE,CAEJ;IAUhB;;;OAGG;IACH,wBAHW,SAAS,GAAG,OAAO,GAAG,UAAU,CAGnB;IACxB;;;OAGG;IACH,sBAAkB;IAClB;;;OAGG;IACH,uBAAgE;IAChE;;;;OAIG;IACH,8BAHU,QAAQ,CAGA;IAClB;;;OAGG;IACH,mBAAiB;IAoCjB;;;OAGG;IACH,kCAQC;IAED;;OAEG;IACH,kBAFa,oBAAoB,EAAE,CAclC;IAED;;OAEG;IACH,sBAFa,OAAO,CAgBnB;IAED;;;OAGG;IACH,qCAHW,gBAAgB,GACd,iBAAiB,CAgC7B;IAED,+BAIC;IAED,2BAKC;IAED;;;OAGG;IACH,yBAFW,OAAO,EAKjB;IAED,iBAPW,OAAO,CASjB;IAED;;;MAKC;IAED;;OAEG;IACH,iBAFa;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAO7C;IAED,eAEC;IAED;;OAEG;IACH,8BAFa,OAAO,CASnB;IAeD;;OAEG;IACH,iBAFW,MAAM,EAKhB;IAnBD;;OAEG;IACH,aAFa,MAAM,CAUlB;IAUD,uBAEC;IAmCD,0BAGC;IAED;;OAEG;IACH,iCAFW,OAAO,GAAC,UAAU,QAK5B;IAED,uBAKC;;CACF;0CAG2F,yCAAyC;0BAG5F,qCAAqC;2CAEd,wCAAwC;8BAJ3E,4CAA4C;yBA5WhD,4CAA4C;0CAgXL,wCAAwC;sCAHnE,2CAA2C;uCAFY,yCAAyC;kCAIjF,2BAA2B;oCADtC,qCAAqC;kCAHc,yCAAyC"}
1
+ {"version":3,"file":"page-controller.d.ts","sourceRoot":"","sources":["../../../../../../src/form/form-editor/preview/controller/page-controller.js"],"names":[],"mappings":"AAqBA;;GAEG;AACH;IAOE;;OAEG;IACH,kBAFW,IAAI,EAId;IAXD;;;OAGG;IACH,cAAK;IASL,sBAEC;IAED,uBAUC;IAED,0BAEC;IAED,yCAKC;IAED,2BAEC;CACF;AAaD;;GAEG;AACH;IACE,oBAAoC;IAkFpC;;OAEG;IACH,uBAFU,OAAO,cAAc,CAEO;IAoQtC;;;;OAIG;IACH,kCAFa,QAAQ,CAepB;IAED;;;;;OAKG;IACH,4CAKC;IAhUD;;;;;OAKG;IACH,wBALW,YAAY,EAAE,YACd,oBAAoB,cACpB,cAAc,YACd,YAAY,EAoBtB;IA/ED;;;OAGG;IACH,yBAHU,MAAM,CAGkD;IAClE;;;OAGG;IACH,uBAFU,QAAQ,EAAE,CAEJ;IAUhB;;;OAGG;IACH,wBAHW,SAAS,GAAG,cAAc,CAGb;IACxB;;;OAGG;IACH,sBAAkB;IAClB;;;OAGG;IACH,yBAHW,MAAM,CAGC;IAClB;;;OAGG;IACH,uBAAgE;IAChE;;;;OAIG;IACH,8BAHU,QAAQ,CAGA;IAClB;;;OAGG;IACH,mBAAiB;IAgDjB;;;OAGG;IACH,kCAQC;IAED;;OAEG;IACH,kBAFa,oBAAoB,EAAE,CAclC;IAED;;OAEG;IACH,sBAFa,OAAO,CAgBnB;IAED;;;OAGG;IACH,qCAHW,gBAAgB,GACd,iBAAiB,CAgC7B;IAED,+BAIC;IAED,2BAKC;IAED;;;OAGG;IACH,yBAFW,OAAO,EAKjB;IAED,iBAPW,OAAO,CASjB;IAED;;;MAKC;IAED;;OAEG;IACH,iBAFa;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAO7C;IAED,eAEC;IAED;;OAEG;IACH,8BAFa,OAAO,CASnB;IAeD;;OAEG;IACH,iBAFW,MAAM,EAKhB;IAnBD;;OAEG;IACH,aAFa,MAAM,CAUlB;IAUD,uBAEC;IAED,oBAGC;IAED,sBAGC;IAED,0BAEC;IAED;;OAEG;IACH,oBAFa;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAC,GAAG,SAAS,CAUvD;IAED,uCAQC;IAED;;OAEG;IACH,0BAFW,MAAM,GAAG,SAAS,EAK5B;IAED,wBAPW,MAAM,GAAG,SAAS,CAY5B;IAED;;;kBAQC;IAED,6CAaC;IAmCD,0BAGC;IAED;;OAEG;IACH,iCAFW,cAAc,QAKxB;IAED,uBAKC;;CASF;0CAG2F,yCAAyC;0BAG5F,qCAAqC;2CAEd,wCAAwC;8BAJ3E,4CAA4C;;;;sBAra/D,MAAM;;;;;;yBArES,4CAA4C;0CA8eL,wCAAwC;sCAHnE,2CAA2C;uCAFY,yCAAyC;kCAIjF,2BAA2B;oCADtC,qCAAqC;kCAHc,yCAAyC"}
@@ -73,6 +73,8 @@ export interface PageOverviewElements {
73
73
  heading: string;
74
74
  guidance: string;
75
75
  addHeading: boolean;
76
+ repeatQuestion: string | undefined;
77
+ hasRepeater: boolean;
76
78
  }
77
79
  export type PreviewQuestion = DateInputQuestion | EmailAddressQuestion | ListSortableQuestion | LongAnswerQuestion | PhoneNumberQuestion | Question | RadioSortableQuestion | SelectSortableQuestion | ShortAnswerQuestion | UkAddressQuestion | AutocompleteQuestion;
78
80
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/form/form-editor/preview/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,qBAAqB,EAC1B,KAAK,iBAAiB,EACvB,MAAM,wCAAwC,CAAA;AAC/C,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,gDAAgD,CAAA;AAC1F,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,8CAA8C,CAAA;AACrF,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,iDAAiD,CAAA;AAC3F,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,iDAAiD,CAAA;AAC3F,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,+CAA+C,CAAA;AACvF,OAAO,EAAE,KAAK,mBAAmB,EAAE,MAAM,gDAAgD,CAAA;AACzF,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,4CAA4C,CAAA;AAC1E,OAAO,EAAE,KAAK,qBAAqB,EAAE,MAAM,kDAAkD,CAAA;AAC7F,OAAO,EAAE,KAAK,sBAAsB,EAAE,MAAM,mDAAmD,CAAA;AAC/F,OAAO,EAAE,KAAK,mBAAmB,EAAE,MAAM,gDAAgD,CAAA;AACzF,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,8CAA8C,CAAA;AACrF,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,iCAAiC,CAAA;AAClE,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,wCAAwC,CAAA;AAC/E,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,EAAE,OAAO,C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AAA;CACrB;AAED,MAAM,MAAM,eAAe,GACvB,iBAAiB,GACjB,oBAAoB,GACpB,oBAAoB,GACpB,kBAAkB,GAClB,mBAAmB,GACnB,QAAQ,GACR,qBAAqB,GACrB,sBAAsB,GACtB,mBAAmB,GACnB,iBAAiB,GACjB,oBAAoB,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defra/forms-model",
3
- "version": "3.0.500",
3
+ "version": "3.0.502",
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",
@@ -47,13 +47,13 @@ function getListItem(model: RuntimeFormModel, listId: string, itemId: string) {
47
47
  const foundList = model.getListById(listId)
48
48
 
49
49
  if (!foundList) {
50
- throw Error('List not found')
50
+ throw Error(`List ${listId} not found`)
51
51
  }
52
52
 
53
53
  const item = foundList.items.find((item) => item.id === itemId)
54
54
 
55
55
  if (!item) {
56
- throw Error('List item not found')
56
+ throw Error(`List item ${itemId} not found`)
57
57
  }
58
58
 
59
59
  return item
@@ -159,16 +159,28 @@ export class PagePreviewElements {
159
159
  guidance
160
160
  heading
161
161
  addHeading
162
+ repeatQuestion
163
+ hasRepeater
162
164
 
163
165
  /**
164
166
  * @param {string} heading
165
167
  * @param {string} guidance
166
168
  * @param {boolean} [addHeading]
169
+ * @param {string} repeatQuestion
170
+ * @param {boolean} hasRepeater
167
171
  */
168
- constructor(heading, guidance = '', addHeading = undefined) {
172
+ constructor(
173
+ heading,
174
+ guidance = '',
175
+ addHeading = undefined,
176
+ repeatQuestion = '',
177
+ hasRepeater = false
178
+ ) {
169
179
  this.heading = heading
170
180
  this.guidance = guidance
171
181
  this.addHeading = addHeading ?? heading.length > 0
182
+ this.repeatQuestion = repeatQuestion
183
+ this.hasRepeater = hasRepeater
172
184
  }
173
185
  }
174
186
 
@@ -73,4 +73,12 @@ export interface PagePreviewPanelMacro {
73
73
  classes: string
74
74
  }
75
75
  readonly components: PagePreviewComponent[]
76
+ readonly sectionTitle?: {
77
+ text: string
78
+ classes: string
79
+ }
80
+ readonly repeaterButton?: {
81
+ text: string
82
+ classes: string
83
+ }
76
84
  }
@@ -3,7 +3,9 @@ import { HIGHLIGHT_CLASS } from '~/src/form/form-editor/preview/constants.js'
3
3
  import { ContentElements } from '~/src/form/form-editor/preview/content.js'
4
4
  import { mapComponentToPreviewQuestion } from '~/src/form/form-editor/preview/helpers.js'
5
5
  import { Markdown } from '~/src/form/form-editor/preview/markdown.js'
6
+ import { hasRepeater } from '~/src/index.js'
6
7
  import { hasComponents } from '~/src/pages/helpers.js'
8
+
7
9
  /**
8
10
  * @type {QuestionRenderer}
9
11
  */
@@ -53,6 +55,28 @@ export class PagePreviewElements {
53
55
  get addHeading() {
54
56
  return this._page.title.length > 0
55
57
  }
58
+
59
+ get repeatQuestion() {
60
+ if (hasRepeater(this._page)) {
61
+ return this._page.repeat.options.title
62
+ }
63
+ return undefined
64
+ }
65
+
66
+ get hasRepeater() {
67
+ return hasRepeater(this._page)
68
+ }
69
+ }
70
+
71
+ /**
72
+ * Enum for Highlight classes
73
+ * @readonly
74
+ * @enum {string}
75
+ */
76
+ const HighlightClass = {
77
+ TITLE: 'title',
78
+ GUIDANCE: 'guidance',
79
+ REPEATER: 'repeater'
56
80
  }
57
81
 
58
82
  /**
@@ -80,7 +104,7 @@ export class PreviewPageController {
80
104
  */
81
105
  #pageRenderer
82
106
  /**
83
- * @type { undefined | 'title' | 'guidance'}
107
+ * @type { undefined | HighlightClass }
84
108
  * @protected
85
109
  */
86
110
  _highlighted = undefined
@@ -89,6 +113,11 @@ export class PreviewPageController {
89
113
  * @private
90
114
  */
91
115
  _guidanceText = ''
116
+ /**
117
+ * @type { string }
118
+ * @protected
119
+ */
120
+ _sectionTitle = ''
92
121
  /**
93
122
  * @type {Markdown}
94
123
  * @private
@@ -105,6 +134,11 @@ export class PreviewPageController {
105
134
  * @private
106
135
  */
107
136
  _showTitle = true
137
+ /**
138
+ * @type {boolean}
139
+ */
140
+ #isRepeater = false
141
+
108
142
  /**
109
143
  * @param {ComponentDef[]} components
110
144
  * @param {PageOverviewElements} elements
@@ -127,8 +161,15 @@ export class PreviewPageController {
127
161
 
128
162
  this.#pageRenderer = renderer
129
163
  this.#title = elements.heading
164
+ this._sectionTitle = elements.repeatQuestion ?? ''
165
+ this.#isRepeater = elements.hasRepeater
130
166
  }
131
167
 
168
+ /**
169
+ * @type {typeof HighlightClass}
170
+ */
171
+ static HighlightClass = HighlightClass
172
+
132
173
  /**
133
174
  * @param { Question | Markdown | undefined} firstQuestion
134
175
  * @param {Question[]} questions
@@ -255,7 +296,7 @@ export class PreviewPageController {
255
296
  get guidance() {
256
297
  return {
257
298
  text: this.guidanceText,
258
- classes: this._highlighted === 'guidance' ? 'highlight' : ''
299
+ classes: this.#isHighlighted(HighlightClass.GUIDANCE)
259
300
  }
260
301
  }
261
302
 
@@ -265,7 +306,7 @@ export class PreviewPageController {
265
306
  get pageTitle() {
266
307
  return {
267
308
  text: this.title,
268
- classes: this._highlighted === 'title' ? HIGHLIGHT_CLASS : ''
309
+ classes: this.#isHighlighted(HighlightClass.TITLE)
269
310
  }
270
311
  }
271
312
 
@@ -307,7 +348,84 @@ export class PreviewPageController {
307
348
  }
308
349
 
309
350
  highlightTitle() {
310
- this.setHighLighted('title')
351
+ this.setHighLighted(HighlightClass.TITLE)
352
+ }
353
+
354
+ setRepeater() {
355
+ this.#isRepeater = true
356
+ this.render()
357
+ }
358
+
359
+ unsetRepeater() {
360
+ this.#isRepeater = false
361
+ this.render()
362
+ }
363
+
364
+ get isRepeater() {
365
+ return this.#isRepeater
366
+ }
367
+
368
+ /**
369
+ * @returns {{classes: string, text: string} | undefined}
370
+ */
371
+ get sectionTitle() {
372
+ if (this.sectionTitleText === undefined) {
373
+ return undefined
374
+ }
375
+ return {
376
+ classes: this.#isHighlighted(HighlightClass.REPEATER),
377
+ text: this.sectionTitleText
378
+ }
379
+ }
380
+
381
+ get repeaterText() {
382
+ if (!this.#isRepeater) {
383
+ return undefined
384
+ }
385
+ if (!this._sectionTitle.length) {
386
+ return 'Question set name'
387
+ }
388
+ return this._sectionTitle + ' 1'
389
+ }
390
+
391
+ /**
392
+ * @param {string | undefined} val
393
+ */
394
+ set sectionTitleText(val) {
395
+ this._sectionTitle = val ?? ''
396
+ this.render()
397
+ }
398
+
399
+ get sectionTitleText() {
400
+ if (this.#isRepeater) {
401
+ return this.repeaterText
402
+ }
403
+ return undefined
404
+ }
405
+
406
+ get repeaterButton() {
407
+ if (this.repeaterButtonText === undefined) {
408
+ return undefined
409
+ }
410
+ return {
411
+ classes: this.#isHighlighted(HighlightClass.REPEATER),
412
+ text: this.repeaterButtonText
413
+ }
414
+ }
415
+
416
+ get repeaterButtonText() {
417
+ if (!this.#isRepeater) {
418
+ return undefined
419
+ }
420
+
421
+ if (this._sectionTitle === '') {
422
+ return '[question set name]'
423
+ }
424
+
425
+ const [firstToken, ...rest] = this._sectionTitle
426
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
427
+ const restOfStr = rest ? rest.join('') : ''
428
+ return firstToken.toLowerCase() + restOfStr
311
429
  }
312
430
 
313
431
  /**
@@ -345,11 +463,11 @@ export class PreviewPageController {
345
463
 
346
464
  highlightGuidance() {
347
465
  this._guidanceComponent.highlightContent()
348
- this.setHighLighted('guidance')
466
+ this.setHighLighted(HighlightClass.GUIDANCE)
349
467
  }
350
468
 
351
469
  /**
352
- * @param {'title'|'guidance'} highlightSection
470
+ * @param {HighlightClass} highlightSection
353
471
  */
354
472
  setHighLighted(highlightSection) {
355
473
  this._highlighted = highlightSection
@@ -362,6 +480,14 @@ export class PreviewPageController {
362
480
  this._guidanceComponent.unHighlightContent()
363
481
  this.render()
364
482
  }
483
+
484
+ /**
485
+ * @param {string} field
486
+ * @returns {string}
487
+ */
488
+ #isHighlighted(field) {
489
+ return this._highlighted === field ? HIGHLIGHT_CLASS : ''
490
+ }
365
491
  }
366
492
 
367
493
  /**
@@ -92,6 +92,8 @@ export interface PageOverviewElements {
92
92
  heading: string
93
93
  guidance: string
94
94
  addHeading: boolean
95
+ repeatQuestion: string | undefined
96
+ hasRepeater: boolean
95
97
  }
96
98
 
97
99
  export type PreviewQuestion =