@defra/forms-model 3.0.505 → 3.0.507

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. package/dist/module/conditions/index.js +1 -1
  2. package/dist/module/conditions/index.js.map +1 -1
  3. package/dist/module/conditions/migration.js +9 -1
  4. package/dist/module/conditions/migration.js.map +1 -1
  5. package/dist/module/form/form-editor/macros/types.js.map +1 -1
  6. package/dist/module/form/form-editor/preview/controller/summary-page-controller.js +151 -0
  7. package/dist/module/form/form-editor/preview/controller/summary-page-controller.js.map +1 -0
  8. package/dist/module/form/form-editor/preview/index.js +1 -0
  9. package/dist/module/form/form-editor/preview/index.js.map +1 -1
  10. package/dist/module/form/form-editor/preview/types.js.map +1 -1
  11. package/dist/types/conditions/index.d.ts +1 -1
  12. package/dist/types/conditions/index.d.ts.map +1 -1
  13. package/dist/types/conditions/migration.d.ts +6 -0
  14. package/dist/types/conditions/migration.d.ts.map +1 -1
  15. package/dist/types/form/form-editor/macros/types.d.ts +16 -0
  16. package/dist/types/form/form-editor/macros/types.d.ts.map +1 -1
  17. package/dist/types/form/form-editor/preview/controller/summary-page-controller.d.ts +45 -0
  18. package/dist/types/form/form-editor/preview/controller/summary-page-controller.d.ts.map +1 -0
  19. package/dist/types/form/form-editor/preview/index.d.ts +1 -0
  20. package/dist/types/form/form-editor/preview/types.d.ts +3 -0
  21. package/dist/types/form/form-editor/preview/types.d.ts.map +1 -1
  22. package/package.json +1 -1
  23. package/src/conditions/index.ts +1 -0
  24. package/src/conditions/migration.ts +10 -1
  25. package/src/form/form-editor/macros/types.ts +14 -0
  26. package/src/form/form-editor/preview/controller/summary-page-controller.js +157 -0
  27. package/src/form/form-editor/preview/index.js +1 -0
  28. package/src/form/form-editor/preview/types.ts +4 -0
@@ -7,6 +7,6 @@ export { ConditionGroup } from "./condition-group.js";
7
7
  export { ConditionsModel } from "./condition-model.js";
8
8
  export { ConditionGroupDef } from "./condition-group-def.js";
9
9
  export { getConditionV2, hasConditionField, hasConditionGroup, hasConditionName, hasNestedCondition, isDuplicateCondition, toExpression, toPresentationString } from "./helpers.js";
10
- export { convertConditionWrapperFromV2, isConditionBooleanValueDataV2, isConditionDateValueDataV2, isConditionListItemRefValueDataV2, isConditionNumberValueDataV2, isConditionRelativeDateValueDataV2, isConditionStringValueDataV2, isConditionWrapper, isConditionWrapperV2 } from "./migration.js";
10
+ export { convertConditionWrapperFromV2, generateConditionAlias, isConditionBooleanValueDataV2, isConditionDateValueDataV2, isConditionListItemRefValueDataV2, isConditionNumberValueDataV2, isConditionRelativeDateValueDataV2, isConditionStringValueDataV2, isConditionWrapper, isConditionWrapperV2 } from "./migration.js";
11
11
  export { ConditionType, Coordinator, DateDirections, DateUnits, Operator, OperatorName } from "./enums.js";
12
12
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["absoluteDateOperatorNames","getExpression","getOperatorNames","relativeDateOperatorNames","ConditionValue","RelativeDateValue","conditionValueFrom","ConditionField","Condition","ConditionRef","ConditionGroup","ConditionsModel","ConditionGroupDef","getConditionV2","hasConditionField","hasConditionGroup","hasConditionName","hasNestedCondition","isDuplicateCondition","toExpression","toPresentationString","convertConditionWrapperFromV2","isConditionBooleanValueDataV2","isConditionDateValueDataV2","isConditionListItemRefValueDataV2","isConditionNumberValueDataV2","isConditionRelativeDateValueDataV2","isConditionStringValueDataV2","isConditionWrapper","isConditionWrapperV2","ConditionType","Coordinator","DateDirections","DateUnits","Operator","OperatorName"],"sources":["../../../src/conditions/index.ts"],"sourcesContent":["export {\n absoluteDateOperatorNames,\n getExpression,\n getOperatorNames,\n relativeDateOperatorNames\n} from '~/src/conditions/condition-operators.js'\n\nexport {\n ConditionValue,\n RelativeDateValue,\n conditionValueFrom\n} from '~/src/conditions/condition-values.js'\n\nexport { ConditionField } from '~/src/conditions/condition-field.js'\nexport { Condition } from '~/src/conditions/condition.js'\nexport { ConditionRef } from '~/src/conditions/condition-ref.js'\nexport { ConditionGroup } from '~/src/conditions/condition-group.js'\nexport { ConditionsModel } from '~/src/conditions/condition-model.js'\nexport { ConditionGroupDef } from '~/src/conditions/condition-group-def.js'\nexport {\n getConditionV2,\n hasConditionField,\n hasConditionGroup,\n hasConditionName,\n hasNestedCondition,\n isDuplicateCondition,\n toExpression,\n toPresentationString\n} from '~/src/conditions/helpers.js'\n\nexport {\n convertConditionWrapperFromV2,\n isConditionBooleanValueDataV2,\n isConditionDateValueDataV2,\n isConditionListItemRefValueDataV2,\n isConditionNumberValueDataV2,\n isConditionRelativeDateValueDataV2,\n isConditionStringValueDataV2,\n isConditionWrapper,\n isConditionWrapperV2,\n type RuntimeFormModel\n} from '~/src/conditions/migration.js'\n\nexport {\n ConditionType,\n Coordinator,\n DateDirections,\n DateUnits,\n Operator,\n OperatorName\n} from '~/src/conditions/enums.js'\n"],"mappings":"AAAA,SACEA,yBAAyB,EACzBC,aAAa,EACbC,gBAAgB,EAChBC,yBAAyB;AAG3B,SACEC,cAAc,EACdC,iBAAiB,EACjBC,kBAAkB;AAGpB,SAASC,cAAc;AACvB,SAASC,SAAS;AAClB,SAASC,YAAY;AACrB,SAASC,cAAc;AACvB,SAASC,eAAe;AACxB,SAASC,iBAAiB;AAC1B,SACEC,cAAc,EACdC,iBAAiB,EACjBC,iBAAiB,EACjBC,gBAAgB,EAChBC,kBAAkB,EAClBC,oBAAoB,EACpBC,YAAY,EACZC,oBAAoB;AAGtB,SACEC,6BAA6B,EAC7BC,6BAA6B,EAC7BC,0BAA0B,EAC1BC,iCAAiC,EACjCC,4BAA4B,EAC5BC,kCAAkC,EAClCC,4BAA4B,EAC5BC,kBAAkB,EAClBC,oBAAoB;AAItB,SACEC,aAAa,EACbC,WAAW,EACXC,cAAc,EACdC,SAAS,EACTC,QAAQ,EACRC,YAAY","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["absoluteDateOperatorNames","getExpression","getOperatorNames","relativeDateOperatorNames","ConditionValue","RelativeDateValue","conditionValueFrom","ConditionField","Condition","ConditionRef","ConditionGroup","ConditionsModel","ConditionGroupDef","getConditionV2","hasConditionField","hasConditionGroup","hasConditionName","hasNestedCondition","isDuplicateCondition","toExpression","toPresentationString","convertConditionWrapperFromV2","generateConditionAlias","isConditionBooleanValueDataV2","isConditionDateValueDataV2","isConditionListItemRefValueDataV2","isConditionNumberValueDataV2","isConditionRelativeDateValueDataV2","isConditionStringValueDataV2","isConditionWrapper","isConditionWrapperV2","ConditionType","Coordinator","DateDirections","DateUnits","Operator","OperatorName"],"sources":["../../../src/conditions/index.ts"],"sourcesContent":["export {\n absoluteDateOperatorNames,\n getExpression,\n getOperatorNames,\n relativeDateOperatorNames\n} from '~/src/conditions/condition-operators.js'\n\nexport {\n ConditionValue,\n RelativeDateValue,\n conditionValueFrom\n} from '~/src/conditions/condition-values.js'\n\nexport { ConditionField } from '~/src/conditions/condition-field.js'\nexport { Condition } from '~/src/conditions/condition.js'\nexport { ConditionRef } from '~/src/conditions/condition-ref.js'\nexport { ConditionGroup } from '~/src/conditions/condition-group.js'\nexport { ConditionsModel } from '~/src/conditions/condition-model.js'\nexport { ConditionGroupDef } from '~/src/conditions/condition-group-def.js'\nexport {\n getConditionV2,\n hasConditionField,\n hasConditionGroup,\n hasConditionName,\n hasNestedCondition,\n isDuplicateCondition,\n toExpression,\n toPresentationString\n} from '~/src/conditions/helpers.js'\n\nexport {\n convertConditionWrapperFromV2,\n generateConditionAlias,\n isConditionBooleanValueDataV2,\n isConditionDateValueDataV2,\n isConditionListItemRefValueDataV2,\n isConditionNumberValueDataV2,\n isConditionRelativeDateValueDataV2,\n isConditionStringValueDataV2,\n isConditionWrapper,\n isConditionWrapperV2,\n type RuntimeFormModel\n} from '~/src/conditions/migration.js'\n\nexport {\n ConditionType,\n Coordinator,\n DateDirections,\n DateUnits,\n Operator,\n OperatorName\n} from '~/src/conditions/enums.js'\n"],"mappings":"AAAA,SACEA,yBAAyB,EACzBC,aAAa,EACbC,gBAAgB,EAChBC,yBAAyB;AAG3B,SACEC,cAAc,EACdC,iBAAiB,EACjBC,kBAAkB;AAGpB,SAASC,cAAc;AACvB,SAASC,SAAS;AAClB,SAASC,YAAY;AACrB,SAASC,cAAc;AACvB,SAASC,eAAe;AACxB,SAASC,iBAAiB;AAC1B,SACEC,cAAc,EACdC,iBAAiB,EACjBC,iBAAiB,EACjBC,gBAAgB,EAChBC,kBAAkB,EAClBC,oBAAoB,EACpBC,YAAY,EACZC,oBAAoB;AAGtB,SACEC,6BAA6B,EAC7BC,sBAAsB,EACtBC,6BAA6B,EAC7BC,0BAA0B,EAC1BC,iCAAiC,EACjCC,4BAA4B,EAC5BC,kCAAkC,EAClCC,4BAA4B,EAC5BC,kBAAkB,EAClBC,oBAAoB;AAItB,SACEC,aAAa,EACbC,WAAW,EACXC,cAAc,EACdC,SAAS,EACTC,QAAQ,EACRC,YAAY","ignoreList":[]}
@@ -1,4 +1,12 @@
1
1
  import { ConditionType } from "./enums.js";
2
+ /**
3
+ * Generate a valid JavaScript identifier from a condition ID
4
+ * @param conditionId - The condition ID (UUID)
5
+ * @returns A valid JavaScript identifier
6
+ */
7
+ export const generateConditionAlias = conditionId => {
8
+ return `cond_${conditionId.replaceAll('-', '')}`;
9
+ };
2
10
  export function isConditionListItemRefValueDataV2(condition) {
3
11
  return condition.type === ConditionType.ListItemRef;
4
12
  }
@@ -114,7 +122,7 @@ function convertConditionRefDataFromV2(model, condition, coordinator) {
114
122
  throw Error('Component not found');
115
123
  }
116
124
  return {
117
- conditionName: refCondition.displayName,
125
+ conditionName: generateConditionAlias(refCondition.id),
118
126
  conditionDisplayName: refCondition.displayName,
119
127
  coordinator
120
128
  };
@@ -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 ${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,KAAKH,aAAa,CAACI,WAAW;AACrD;AAEA,OAAO,SAASC,4BAA4BA,CAACH,SAA0B,EAAE;EACvE,OAAOA,SAAS,CAACC,IAAI,KAAKH,aAAa,CAACM,WAAW;AACrD;AAEA,OAAO,SAASC,6BAA6BA,CAACL,SAA0B,EAAE;EACxE,OAAOA,SAAS,CAACC,IAAI,KAAKH,aAAa,CAACQ,YAAY;AACtD;AAEA,OAAO,SAASC,4BAA4BA,CAACP,SAA0B,EAAE;EACvE,OAAOA,SAAS,CAACC,IAAI,KAAKH,aAAa,CAACU,WAAW;AACrD;AAEA,OAAO,SAASC,0BAA0BA,CAACT,SAA0B,EAAE;EACrE,OAAOA,SAAS,CAACC,IAAI,KAAKH,aAAa,CAACY,SAAS;AACnD;AAEA,OAAO,SAASC,kCAAkCA,CAACX,SAA0B,EAAE;EAC7E,OAAOA,SAAS,CAACC,IAAI,KAAKH,aAAa,CAACc,YAAY;AACtD;AAEA,SAASC,WAAWA,CAACC,KAAuB,EAAEC,MAAc,EAAEC,MA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KAAK,CAAC;AAC7D;AAEA,OAAO,SAASyC,kBAAkBA,CAChCH,OAA8C,EACjB;EAC7B,OAAO,CAACD,oBAAoB,CAACC,OAAO,CAAC;AACvC;AAEA,OAAO,SAASI,6BAA6BA,CAC3CC,gBAAoC,EACpClD,KAAuB,EACL;EAClB,IAAI4B,WAAW;EAEf,IAAIsB,gBAAgB,CAAC3C,KAAK,CAAC4C,MAAM,GAAG,CAAC,IAAI,CAACD,gBAAgB,CAACtB,WAAW,EAAE;IACtE,MAAM,IAAIvB,KAAK,CAAC,iDAAiD,CAAC;EACpE,CAAC,MAAM;IACLuB,WAAW,GAAGsB,gBAAgB,CAACtB,WAAW;EAC5C;EAEA,MAAMwB,mBAAqC,GAAG;IAC5ClB,IAAI,EAAEgB,gBAAgB,CAACzC,EAAE;IACzBiC,WAAW,EAAEQ,gBAAgB,CAACR,WAAW;IACzC/B,KAAK,EAAE;MACLuB,IAAI,EAAEgB,gBAAgB,CAACzC,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":[]}
1
+ {"version":3,"file":"migration.js","names":["ConditionType","generateConditionAlias","conditionId","replaceAll","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","conditionName","conditionDisplayName","displayName","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\n/**\n * Generate a valid JavaScript identifier from a condition ID\n * @param conditionId - The condition ID (UUID)\n * @returns A valid JavaScript identifier\n */\nexport const generateConditionAlias = (conditionId: string): string => {\n return `cond_${conditionId.replaceAll('-', '')}`\n}\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: generateConditionAlias(refCondition.id),\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;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,sBAAsB,GAAIC,WAAmB,IAAa;EACrE,OAAO,QAAQA,WAAW,CAACC,UAAU,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE;AAClD,CAAC;AAED,OAAO,SAASC,iCAAiCA,CAACC,SAA0B,EAAE;EAC5E,OAAOA,SAAS,CAACC,IAAI,KAAKN,aAAa,CAACO,WAAW;AACrD;AAEA,OAAO,SAASC,4BAA4BA,CAACH,SAA0B,EAAE;EACvE,OAAOA,SAAS,CAACC,IAAI,KAAKN,aAAa,CAACS,WAAW;AACrD;AAEA,OAAO,SAASC,6BAA6BA,CAACL,SAA0B,EAAE;EACxE,OAAOA,SAAS,CAACC,IAAI,KAAKN,aAA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ACnC3B,KAAK,EACLd,SAAS,EACToE,KAAK,GAAG,CAAC,GAAG1B,WAAW,GAAG4B,SAC5B,CAAC;QACH,CAAC,MAAM;UACLD,YAAY,GAAGlB,6BAA6B,CAC1CrC,KAAK,EACLd,SAAS,EACToE,KAAK,GAAG,CAAC,GAAG1B,WAAW,GAAG4B,SAC5B,CAAC;QACH;QAEA,OAAOD,YAAY;MACrB,CAAC;IACH;EACF,CAAC;EAED,OAAOJ,mBAAmB;AAC5B","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 readonly sectionTitle?: {\n text: string\n classes: string\n }\n readonly repeaterButton?: {\n text: string\n classes: string\n }\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\nexport interface SummaryRowActionItem {\n href: string\n text: string\n visuallyHiddenText: string\n}\n\nexport interface SummaryRow {\n key: { text: string }\n value: { text: string }\n actions: {\n items: SummaryRowActionItem[]\n }\n}\n"],"mappings":"","ignoreList":[]}
@@ -0,0 +1,151 @@
1
+ import { hasFormField } from "../../../../components/helpers.js";
2
+ import { HIGHLIGHT_CLASS } from "../constants.js";
3
+ import { PreviewPageControllerBase } from "./page-controller-base.js";
4
+ import { hasComponents } from "../../../../pages/helpers.js";
5
+ const EXAMPLE_TEXT = 'Answer goes here';
6
+ export class SummaryPageController extends PreviewPageControllerBase {
7
+ /**
8
+ * @type {string}
9
+ * @protected
10
+ */
11
+ _pageTemplate = PreviewPageControllerBase.PATH + 'summary-controller.njk';
12
+ /**
13
+ * @type {Markdown}
14
+ * @protected
15
+ */
16
+ _guidanceComponent = PreviewPageControllerBase.createGuidanceComponent(false);
17
+ /**
18
+ * @type {FormComponentsDef[]}
19
+ * @private
20
+ */
21
+ _componentDefs = [];
22
+ /**
23
+ * @type {boolean}
24
+ * @private
25
+ */
26
+ _makeDeclaration = false;
27
+ /**
28
+ * @param {SummaryPageElements} elements
29
+ * @param {FormDefinition} formDefinition
30
+ * @param {PageRenderer} renderer
31
+ */
32
+ constructor(elements, formDefinition, renderer) {
33
+ super(elements, renderer);
34
+ this._componentDefs = formDefinition.pages.flatMap(page => {
35
+ if (hasComponents(page)) {
36
+ return page.components.filter(hasFormField);
37
+ }
38
+ return [];
39
+ });
40
+ this._makeDeclaration = elements.declaration;
41
+ this._guidanceComponent.content = elements.guidance;
42
+ }
43
+
44
+ /**
45
+ * @returns {{ rows: SummaryRow[] }}
46
+ */
47
+ get componentRows() {
48
+ const rows = this._componentDefs.map(component => {
49
+ const summaryRowHeading = component.shortDescription ?? '';
50
+ return {
51
+ key: {
52
+ text: summaryRowHeading
53
+ },
54
+ value: {
55
+ text: EXAMPLE_TEXT
56
+ },
57
+ actions: {
58
+ items: [{
59
+ href: '#',
60
+ text: 'Change',
61
+ visuallyHiddenText: summaryRowHeading
62
+ }]
63
+ }
64
+ };
65
+ });
66
+ return {
67
+ rows
68
+ };
69
+ }
70
+
71
+ /**
72
+ * @returns {{ text: string; classes: string }}
73
+ */
74
+ get pageTitle() {
75
+ return {
76
+ text: 'Check your answers before sending your form',
77
+ classes: ''
78
+ };
79
+ }
80
+ get guidance() {
81
+ if (!this._makeDeclaration) {
82
+ return {
83
+ classes: '',
84
+ text: ''
85
+ };
86
+ }
87
+ const guidanceHighlighted = this._highlighted === 'guidance';
88
+ const classes = guidanceHighlighted ? HIGHLIGHT_CLASS : '';
89
+ let text = this._guidanceText.length ? this._guidanceText : '';
90
+ if (!text.length && guidanceHighlighted) {
91
+ text = 'Declaration text';
92
+ }
93
+ return {
94
+ text,
95
+ classes
96
+ };
97
+ }
98
+
99
+ /**
100
+ * @param {string} declarationText
101
+ */
102
+ set declarationText(declarationText) {
103
+ this.guidanceText = declarationText;
104
+ }
105
+ get declarationText() {
106
+ return this.guidanceText;
107
+ }
108
+ get declaration() {
109
+ return this.guidance;
110
+ }
111
+ setMakeDeclaration() {
112
+ this._makeDeclaration = true;
113
+ this.render();
114
+ }
115
+ unsetMakeDeclaration() {
116
+ this._makeDeclaration = false;
117
+ this.render();
118
+ }
119
+ get makeDeclaration() {
120
+ return this._makeDeclaration;
121
+ }
122
+ highlightDeclaration() {
123
+ this.highlightGuidance();
124
+ }
125
+ unhighlightDeclaration() {
126
+ this.clearHighlight();
127
+ }
128
+
129
+ /**
130
+ * @returns {Markdown[]}
131
+ * @protected
132
+ */
133
+ _getGuidanceComponents() {
134
+ if (!this._makeDeclaration) {
135
+ return [];
136
+ }
137
+ return super._getGuidanceComponents();
138
+ }
139
+ get buttonText() {
140
+ return this.makeDeclaration ? 'Accept and send' : 'Send';
141
+ }
142
+ }
143
+
144
+ /**
145
+ * @import { ComponentDef, ContentComponentsDef, ListComponent, FormComponentsDef } from '~/src/components/types.js'
146
+ * @import { FormDefinition } from '~/src/form/form-definition/types.js'
147
+ * @import { PageRenderer, PagePreviewBaseElements, SummaryPageElements } from '~/src/form/form-editor/preview/types.js'
148
+ * @import { SummaryRowActionItem, SummaryRow } from '~/src/form/form-editor/macros/types.js'
149
+ * @import { Markdown } from '~/src/form/form-editor/preview/markdown.js'
150
+ */
151
+ //# sourceMappingURL=summary-page-controller.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"summary-page-controller.js","names":["hasFormField","HIGHLIGHT_CLASS","PreviewPageControllerBase","hasComponents","EXAMPLE_TEXT","SummaryPageController","_pageTemplate","PATH","_guidanceComponent","createGuidanceComponent","_componentDefs","_makeDeclaration","constructor","elements","formDefinition","renderer","pages","flatMap","page","components","filter","declaration","content","guidance","componentRows","rows","map","component","summaryRowHeading","shortDescription","key","text","value","actions","items","href","visuallyHiddenText","pageTitle","classes","guidanceHighlighted","_highlighted","_guidanceText","length","declarationText","guidanceText","setMakeDeclaration","render","unsetMakeDeclaration","makeDeclaration","highlightDeclaration","highlightGuidance","unhighlightDeclaration","clearHighlight","_getGuidanceComponents","buttonText"],"sources":["../../../../../../src/form/form-editor/preview/controller/summary-page-controller.js"],"sourcesContent":["import { hasFormField } from '~/src/components/helpers.js'\nimport { HIGHLIGHT_CLASS } from '~/src/form/form-editor/preview/constants.js'\nimport { PreviewPageControllerBase } from '~/src/form/form-editor/preview/controller/page-controller-base.js'\nimport { hasComponents } from '~/src/pages/helpers.js'\n\nconst EXAMPLE_TEXT = 'Answer goes here'\n\nexport class SummaryPageController extends PreviewPageControllerBase {\n /**\n * @type {string}\n * @protected\n */\n _pageTemplate = PreviewPageControllerBase.PATH + 'summary-controller.njk'\n /**\n * @type {Markdown}\n * @protected\n */\n _guidanceComponent = PreviewPageControllerBase.createGuidanceComponent(false)\n /**\n * @type {FormComponentsDef[]}\n * @private\n */\n _componentDefs = []\n /**\n * @type {boolean}\n * @private\n */\n _makeDeclaration = false\n /**\n * @param {SummaryPageElements} elements\n * @param {FormDefinition} formDefinition\n * @param {PageRenderer} renderer\n */\n constructor(elements, formDefinition, renderer) {\n super(elements, renderer)\n this._componentDefs = formDefinition.pages.flatMap((page) => {\n if (hasComponents(page)) {\n return page.components.filter(hasFormField)\n }\n return []\n })\n this._makeDeclaration = elements.declaration\n\n this._guidanceComponent.content = elements.guidance\n }\n\n /**\n * @returns {{ rows: SummaryRow[] }}\n */\n get componentRows() {\n const rows = this._componentDefs.map((component) => {\n const summaryRowHeading = component.shortDescription ?? ''\n return {\n key: { text: summaryRowHeading },\n value: { text: EXAMPLE_TEXT },\n actions: {\n items: [\n { href: '#', text: 'Change', visuallyHiddenText: summaryRowHeading }\n ]\n }\n }\n })\n return {\n rows\n }\n }\n\n /**\n * @returns {{ text: string; classes: string }}\n */\n get pageTitle() {\n return {\n text: 'Check your answers before sending your form',\n classes: ''\n }\n }\n\n get guidance() {\n if (!this._makeDeclaration) {\n return {\n classes: '',\n text: ''\n }\n }\n const guidanceHighlighted = this._highlighted === 'guidance'\n const classes = guidanceHighlighted ? HIGHLIGHT_CLASS : ''\n let text = this._guidanceText.length ? this._guidanceText : ''\n\n if (!text.length && guidanceHighlighted) {\n text = 'Declaration text'\n }\n return {\n text,\n classes\n }\n }\n\n /**\n * @param {string} declarationText\n */\n set declarationText(declarationText) {\n this.guidanceText = declarationText\n }\n\n get declarationText() {\n return this.guidanceText\n }\n\n get declaration() {\n return this.guidance\n }\n\n setMakeDeclaration() {\n this._makeDeclaration = true\n this.render()\n }\n\n unsetMakeDeclaration() {\n this._makeDeclaration = false\n this.render()\n }\n\n get makeDeclaration() {\n return this._makeDeclaration\n }\n\n highlightDeclaration() {\n this.highlightGuidance()\n }\n\n unhighlightDeclaration() {\n this.clearHighlight()\n }\n\n /**\n * @returns {Markdown[]}\n * @protected\n */\n _getGuidanceComponents() {\n if (!this._makeDeclaration) {\n return []\n }\n return super._getGuidanceComponents()\n }\n\n get buttonText() {\n return this.makeDeclaration ? 'Accept and send' : 'Send'\n }\n}\n\n/**\n * @import { ComponentDef, ContentComponentsDef, ListComponent, FormComponentsDef } from '~/src/components/types.js'\n * @import { FormDefinition } from '~/src/form/form-definition/types.js'\n * @import { PageRenderer, PagePreviewBaseElements, SummaryPageElements } from '~/src/form/form-editor/preview/types.js'\n * @import { SummaryRowActionItem, SummaryRow } from '~/src/form/form-editor/macros/types.js'\n * @import { Markdown } from '~/src/form/form-editor/preview/markdown.js'\n */\n"],"mappings":"AAAA,SAASA,YAAY;AACrB,SAASC,eAAe;AACxB,SAASC,yBAAyB;AAClC,SAASC,aAAa;AAEtB,MAAMC,YAAY,GAAG,kBAAkB;AAEvC,OAAO,MAAMC,qBAAqB,SAASH,yBAAyB,CAAC;EACnE;AACF;AACA;AACA;EACEI,aAAa,GAAGJ,yBAAyB,CAACK,IAAI,GAAG,wBAAwB;EACzE;AACF;AACA;AACA;EACEC,kBAAkB,GAAGN,yBAAyB,CAACO,uBAAuB,CAAC,KAAK,CAAC;EAC7E;AACF;AACA;AACA;EACEC,cAAc,GAAG,EAAE;EACnB;AACF;AACA;AACA;EACEC,gBAAgB,GAAG,KAAK;EACxB;AACF;AACA;AACA;AACA;EACEC,WAAWA,CAACC,QAAQ,EAAEC,cAAc,EAAEC,QAAQ,EAAE;IAC9C,KAAK,CAACF,QAAQ,EAAEE,QAAQ,CAAC;IACzB,IAAI,CAACL,cAAc,GAAGI,cAAc,CAACE,KAAK,CAACC,OAAO,CAAEC,IAAI,IAAK;MAC3D,IAAIf,aA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G,EAAE;IAE9D,IAAI,CAACV,IAAI,CAACW,MAAM,IAAIH,mBAAmB,EAAE;MACvCR,IAAI,GAAG,kBAAkB;IAC3B;IACA,OAAO;MACLA,IAAI;MACJO;IACF,CAAC;EACH;;EAEA;AACF;AACA;EACE,IAAIK,eAAeA,CAACA,eAAe,EAAE;IACnC,IAAI,CAACC,YAAY,GAAGD,eAAe;EACrC;EAEA,IAAIA,eAAeA,CAAA,EAAG;IACpB,OAAO,IAAI,CAACC,YAAY;EAC1B;EAEA,IAAIvB,WAAWA,CAAA,EAAG;IAChB,OAAO,IAAI,CAACE,QAAQ;EACtB;EAEAsB,kBAAkBA,CAAA,EAAG;IACnB,IAAI,CAAClC,gBAAgB,GAAG,IAAI;IAC5B,IAAI,CAACmC,MAAM,CAAC,CAAC;EACf;EAEAC,oBAAoBA,CAAA,EAAG;IACrB,IAAI,CAACpC,gBAAgB,GAAG,KAAK;IAC7B,IAAI,CAACmC,MAAM,CAAC,CAAC;EACf;EAEA,IAAIE,eAAeA,CAAA,EAAG;IACpB,OAAO,IAAI,CAACrC,gBAAgB;EAC9B;EAEAsC,oBAAoBA,CAAA,EAAG;IACrB,IAAI,CAACC,iBAAiB,CAAC,CAAC;EAC1B;EAEAC,sBAAsBA,CAAA,EAAG;IACvB,IAAI,CAACC,cAAc,CAAC,CAAC;EACvB;;EAEA;AACF;AACA;AACA;EACEC,sBAAsBA,CAAA,EAAG;IACvB,IAAI,CAAC,IAAI,CAAC1C,gBAAgB,EAAE;MAC1B,OAAO,EAAE;IACX;IACA,OAAO,KAAK,CAAC0C,sBAAsB,CAAC,CAAC;EACvC;EAEA,IAAIC,UAAUA,CAAA,EAAG;IACf,OAAO,IAAI,CAACN,eAAe,GAAG,iBAAiB,GAAG,MAAM;EAC1D;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
@@ -22,5 +22,6 @@ export * from "./uk-address.js";
22
22
  export * from "./yes-no.js";
23
23
  export * from "./controller/page-controller.js";
24
24
  export * from "./controller/guidance-page-controller.js";
25
+ export * from "./controller/summary-page-controller.js";
25
26
  export * from "./controller/page-controller-base.js";
26
27
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../../../../src/form/form-editor/preview/index.js"],"sourcesContent":["export * from '~/src/form/form-editor/preview/autocomplete.js'\nexport * from '~/src/form/form-editor/preview/checkbox.js'\nexport * from '~/src/form/form-editor/preview/checkbox-sortable.js'\nexport * from '~/src/form/form-editor/preview/date-input.js'\nexport * from '~/src/form/form-editor/preview/email-address.js'\nexport * from '~/src/form/form-editor/preview/list.js'\nexport * from '~/src/form/form-editor/preview/list-sortable.js'\nexport * from '~/src/form/form-editor/preview/markdown.js'\nexport * from '~/src/form/form-editor/preview/month-year.js'\nexport * from '~/src/form/form-editor/preview/number-only.js'\nexport * from '~/src/form/form-editor/preview/phone-number.js'\nexport * from '~/src/form/form-editor/preview/question.js'\nexport * from '~/src/form/form-editor/preview/radio.js'\nexport * from '~/src/form/form-editor/preview/radio-sortable.js'\nexport * from '~/src/form/form-editor/preview/select-sortable.js'\nexport * from '~/src/form/form-editor/preview/short-answer.js'\nexport * from '~/src/form/form-editor/preview/select.js'\nexport * from '~/src/form/form-editor/preview/select-sortable.js'\nexport * from '~/src/form/form-editor/preview/supporting-evidence.js'\nexport * from '~/src/form/form-editor/preview/long-answer.js'\nexport * from '~/src/form/form-editor/preview/uk-address.js'\nexport * from '~/src/form/form-editor/preview/yes-no.js'\nexport * from '~/src/form/form-editor/preview/controller/page-controller.js'\nexport * from '~/src/form/form-editor/preview/controller/guidance-page-controller.js'\nexport * from '~/src/form/form-editor/preview/controller/page-controller-base.js'\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../../../src/form/form-editor/preview/index.js"],"sourcesContent":["export * from '~/src/form/form-editor/preview/autocomplete.js'\nexport * from '~/src/form/form-editor/preview/checkbox.js'\nexport * from '~/src/form/form-editor/preview/checkbox-sortable.js'\nexport * from '~/src/form/form-editor/preview/date-input.js'\nexport * from '~/src/form/form-editor/preview/email-address.js'\nexport * from '~/src/form/form-editor/preview/list.js'\nexport * from '~/src/form/form-editor/preview/list-sortable.js'\nexport * from '~/src/form/form-editor/preview/markdown.js'\nexport * from '~/src/form/form-editor/preview/month-year.js'\nexport * from '~/src/form/form-editor/preview/number-only.js'\nexport * from '~/src/form/form-editor/preview/phone-number.js'\nexport * from '~/src/form/form-editor/preview/question.js'\nexport * from '~/src/form/form-editor/preview/radio.js'\nexport * from '~/src/form/form-editor/preview/radio-sortable.js'\nexport * from '~/src/form/form-editor/preview/select-sortable.js'\nexport * from '~/src/form/form-editor/preview/short-answer.js'\nexport * from '~/src/form/form-editor/preview/select.js'\nexport * from '~/src/form/form-editor/preview/select-sortable.js'\nexport * from '~/src/form/form-editor/preview/supporting-evidence.js'\nexport * from '~/src/form/form-editor/preview/long-answer.js'\nexport * from '~/src/form/form-editor/preview/uk-address.js'\nexport * from '~/src/form/form-editor/preview/yes-no.js'\nexport * from '~/src/form/form-editor/preview/controller/page-controller.js'\nexport * from '~/src/form/form-editor/preview/controller/guidance-page-controller.js'\nexport * from '~/src/form/form-editor/preview/controller/summary-page-controller.js'\nexport * from '~/src/form/form-editor/preview/controller/page-controller-base.js'\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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 PagePreviewBaseElements {\n heading: string\n guidance: string\n}\n\nexport interface PageOverviewElements extends PagePreviewBaseElements {\n addHeading: boolean\n repeatQuestion: string | undefined\n hasRepeater: boolean\n}\n\nexport 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 PagePreviewBaseElements {\n heading: string\n guidance: string\n}\n\nexport interface PageOverviewElements extends PagePreviewBaseElements {\n addHeading: boolean\n repeatQuestion: string | undefined\n hasRepeater: boolean\n}\n\nexport interface SummaryPageElements extends PagePreviewBaseElements {\n declaration: 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":[]}
@@ -7,6 +7,6 @@ export { ConditionGroup } from '../conditions/condition-group.js';
7
7
  export { ConditionsModel } from '../conditions/condition-model.js';
8
8
  export { ConditionGroupDef } from '../conditions/condition-group-def.js';
9
9
  export { getConditionV2, hasConditionField, hasConditionGroup, hasConditionName, hasNestedCondition, isDuplicateCondition, toExpression, toPresentationString } from '../conditions/helpers.js';
10
- export { convertConditionWrapperFromV2, isConditionBooleanValueDataV2, isConditionDateValueDataV2, isConditionListItemRefValueDataV2, isConditionNumberValueDataV2, isConditionRelativeDateValueDataV2, isConditionStringValueDataV2, isConditionWrapper, isConditionWrapperV2, type RuntimeFormModel } from '../conditions/migration.js';
10
+ export { convertConditionWrapperFromV2, generateConditionAlias, isConditionBooleanValueDataV2, isConditionDateValueDataV2, isConditionListItemRefValueDataV2, isConditionNumberValueDataV2, isConditionRelativeDateValueDataV2, isConditionStringValueDataV2, isConditionWrapper, isConditionWrapperV2, type RuntimeFormModel } from '../conditions/migration.js';
11
11
  export { ConditionType, Coordinator, DateDirections, DateUnits, Operator, OperatorName } from '../conditions/enums.js';
12
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/conditions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,EACzB,aAAa,EACb,gBAAgB,EAChB,yBAAyB,EAC1B,MAAM,yCAAyC,CAAA;AAEhD,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,kBAAkB,EACnB,MAAM,sCAAsC,CAAA;AAE7C,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAA;AACpE,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAA;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAA;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAA;AACpE,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAA;AACrE,OAAO,EAAE,iBAAiB,EAAE,MAAM,yCAAyC,CAAA;AAC3E,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EAChB,kBAAkB,EAClB,oBAAoB,EACpB,YAAY,EACZ,oBAAoB,EACrB,MAAM,6BAA6B,CAAA;AAEpC,OAAO,EACL,6BAA6B,EAC7B,6BAA6B,EAC7B,0BAA0B,EAC1B,iCAAiC,EACjC,4BAA4B,EAC5B,kCAAkC,EAClC,4BAA4B,EAC5B,kBAAkB,EAClB,oBAAoB,EACpB,KAAK,gBAAgB,EACtB,MAAM,+BAA+B,CAAA;AAEtC,OAAO,EACL,aAAa,EACb,WAAW,EACX,cAAc,EACd,SAAS,EACT,QAAQ,EACR,YAAY,EACb,MAAM,2BAA2B,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/conditions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,EACzB,aAAa,EACb,gBAAgB,EAChB,yBAAyB,EAC1B,MAAM,yCAAyC,CAAA;AAEhD,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,kBAAkB,EACnB,MAAM,sCAAsC,CAAA;AAE7C,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAA;AACpE,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAA;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAA;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAA;AACpE,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAA;AACrE,OAAO,EAAE,iBAAiB,EAAE,MAAM,yCAAyC,CAAA;AAC3E,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EAChB,kBAAkB,EAClB,oBAAoB,EACpB,YAAY,EACZ,oBAAoB,EACrB,MAAM,6BAA6B,CAAA;AAEpC,OAAO,EACL,6BAA6B,EAC7B,sBAAsB,EACtB,6BAA6B,EAC7B,0BAA0B,EAC1B,iCAAiC,EACjC,4BAA4B,EAC5B,kCAAkC,EAClC,4BAA4B,EAC5B,kBAAkB,EAClB,oBAAoB,EACpB,KAAK,gBAAgB,EACtB,MAAM,+BAA+B,CAAA;AAEtC,OAAO,EACL,aAAa,EACb,WAAW,EACX,cAAc,EACd,SAAS,EACT,QAAQ,EACR,YAAY,EACb,MAAM,2BAA2B,CAAA"}
@@ -1,6 +1,12 @@
1
1
  import { type ComponentDef } from '../components/types.js';
2
2
  import { type ConditionDataV2 } from '../conditions/types.js';
3
3
  import { type ConditionWrapper, type ConditionWrapperV2, type List } from '../form/form-definition/types.js';
4
+ /**
5
+ * Generate a valid JavaScript identifier from a condition ID
6
+ * @param conditionId - The condition ID (UUID)
7
+ * @returns A valid JavaScript identifier
8
+ */
9
+ export declare const generateConditionAlias: (conditionId: string) => string;
4
10
  export declare function isConditionListItemRefValueDataV2(condition: ConditionDataV2): boolean;
5
11
  export declare function isConditionStringValueDataV2(condition: ConditionDataV2): boolean;
6
12
  export declare function isConditionBooleanValueDataV2(condition: ConditionDataV2): boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"migration.d.ts","sourceRoot":"","sources":["../../../src/conditions/migration.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,YAAY,EAElB,MAAM,2BAA2B,CAAA;AAElC,OAAO,EAEL,KAAK,eAAe,EAOrB,MAAM,2BAA2B,CAAA;AAClC,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACvB,KAAK,IAAI,EACV,MAAM,qCAAqC,CAAA;AAE5C,wBAAgB,iCAAiC,CAAC,SAAS,EAAE,eAAe,WAE3E;AAED,wBAAgB,4BAA4B,CAAC,SAAS,EAAE,eAAe,WAEtE;AAED,wBAAgB,6BAA6B,CAAC,SAAS,EAAE,eAAe,WAEvE;AAED,wBA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,wBAAgB,4BAA4B,CAAC,SAAS,EAAE,eAAe,WAEtE;AAED,wBAAgB,0BAA0B,CAAC,SAAS,EAAE,eAAe,WAEpE;AAED,wBAAgB,kCAAkC,CAAC,SAAS,EAAE,eAAe,WAE5E;AAsJD,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,gBAAgB,GAAG,kBAAkB,GAC7C,OAAO,IAAI,kBAAkB,CAE/B;AAED,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,gBAAgB,GAAG,kBAAkB,GAC7C,OAAO,IAAI,gBAAgB,CAE7B;AAED,wBAAgB,6BAA6B,CAC3C,gBAAgB,EAAE,kBAAkB,EACpC,KAAK,EAAE,gBAAgB,GACtB,gBAAgB,CAqClB;AAED,MAAM,WAAW,gBAAgB;IAC/B,WAAW,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,GAAG,SAAS,CAAA;IACjD,gBAAgB,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,YAAY,GAAG,SAAS,CAAA;IACnE,gBAAgB,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,kBAAkB,GAAG,SAAS,CAAA;CAC1E"}
@@ -75,4 +75,20 @@ export interface PagePreviewPanelMacro {
75
75
  classes: string;
76
76
  };
77
77
  }
78
+ export interface SummaryRowActionItem {
79
+ href: string;
80
+ text: string;
81
+ visuallyHiddenText: string;
82
+ }
83
+ export interface SummaryRow {
84
+ key: {
85
+ text: string;
86
+ };
87
+ value: {
88
+ text: string;
89
+ };
90
+ actions: {
91
+ items: SummaryRowActionItem[];
92
+ };
93
+ }
78
94
  //# 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,M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;CACF"}
@@ -0,0 +1,45 @@
1
+ export class SummaryPageController extends PreviewPageControllerBase {
2
+ /**
3
+ * @param {SummaryPageElements} elements
4
+ * @param {FormDefinition} formDefinition
5
+ * @param {PageRenderer} renderer
6
+ */
7
+ constructor(elements: SummaryPageElements, formDefinition: FormDefinition, renderer: PageRenderer);
8
+ /**
9
+ * @type {FormComponentsDef[]}
10
+ * @private
11
+ */
12
+ private _componentDefs;
13
+ /**
14
+ * @type {boolean}
15
+ * @private
16
+ */
17
+ private _makeDeclaration;
18
+ /**
19
+ * @returns {{ rows: SummaryRow[] }}
20
+ */
21
+ get componentRows(): {
22
+ rows: SummaryRow[];
23
+ };
24
+ /**
25
+ * @param {string} declarationText
26
+ */
27
+ set declarationText(declarationText: string);
28
+ get declarationText(): string;
29
+ get declaration(): {
30
+ classes: string;
31
+ text: string;
32
+ };
33
+ setMakeDeclaration(): void;
34
+ unsetMakeDeclaration(): void;
35
+ get makeDeclaration(): boolean;
36
+ highlightDeclaration(): void;
37
+ unhighlightDeclaration(): void;
38
+ get buttonText(): "Accept and send" | "Send";
39
+ }
40
+ import { PreviewPageControllerBase } from '../../../../form/form-editor/preview/controller/page-controller-base.js';
41
+ import type { SummaryRow } from '../../../../form/form-editor/macros/types.js';
42
+ import type { SummaryPageElements } from '../../../../form/form-editor/preview/types.js';
43
+ import type { FormDefinition } from '../../../../form/form-definition/types.js';
44
+ import type { PageRenderer } from '../../../../form/form-editor/preview/types.js';
45
+ //# sourceMappingURL=summary-page-controller.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"summary-page-controller.d.ts","sourceRoot":"","sources":["../../../../../../src/form/form-editor/preview/controller/summary-page-controller.js"],"names":[],"mappings":"AAOA;IAqBE;;;;OAIG;IACH,sBAJW,mBAAmB,kBACnB,cAAc,YACd,YAAY,EAatB;IA1BD;;;OAGG;IACH,uBAAmB;IACnB;;;OAGG;IACH,yBAAwB;IAmBxB;;OAEG;IACH,qBAFa;QAAE,IAAI,EAAE,UAAU,EAAE,CAAA;KAAE,CAkBlC;IAgCD;;OAEG;IACH,qCAFW,MAAM,EAIhB;IAED,uBANW,MAAM,CAQhB;IAED;;;MAEC;IAED,2BAGC;IAED,6BAGC;IAED,+BAEC;IAED,6BAEC;IAED,+BAEC;IAaD,6CAEC;CACF;0CAlJyC,mEAAmE;gCAwJxD,wCAAwC;yCADd,yCAAyC;oCADrF,qCAAqC;kCACO,yCAAyC"}
@@ -22,5 +22,6 @@ export * from "../../../form/form-editor/preview/uk-address.js";
22
22
  export * from "../../../form/form-editor/preview/yes-no.js";
23
23
  export * from "../../../form/form-editor/preview/controller/page-controller.js";
24
24
  export * from "../../../form/form-editor/preview/controller/guidance-page-controller.js";
25
+ export * from "../../../form/form-editor/preview/controller/summary-page-controller.js";
25
26
  export * from "../../../form/form-editor/preview/controller/page-controller-base.js";
26
27
  //# sourceMappingURL=index.d.ts.map
@@ -78,5 +78,8 @@ export interface PageOverviewElements extends PagePreviewBaseElements {
78
78
  repeatQuestion: string | undefined;
79
79
  hasRepeater: boolean;
80
80
  }
81
+ export interface SummaryPageElements extends PagePreviewBaseElements {
82
+ declaration: boolean;
83
+ }
81
84
  export type PreviewQuestion = DateInputQuestion | EmailAddressQuestion | ListSortableQuestion | LongAnswerQuestion | PhoneNumberQuestion | Question | RadioSortableQuestion | SelectSortableQuestion | ShortAnswerQuestion | UkAddressQuestion | AutocompleteQuestion;
82
85
  //# 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,EAA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model",
3
- "version": "3.0.505",
3
+ "version": "3.0.507",
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",
@@ -30,6 +30,7 @@ export {
30
30
 
31
31
  export {
32
32
  convertConditionWrapperFromV2,
33
+ generateConditionAlias,
33
34
  isConditionBooleanValueDataV2,
34
35
  isConditionDateValueDataV2,
35
36
  isConditionListItemRefValueDataV2,
@@ -19,6 +19,15 @@ import {
19
19
  type List
20
20
  } from '~/src/form/form-definition/types.js'
21
21
 
22
+ /**
23
+ * Generate a valid JavaScript identifier from a condition ID
24
+ * @param conditionId - The condition ID (UUID)
25
+ * @returns A valid JavaScript identifier
26
+ */
27
+ export const generateConditionAlias = (conditionId: string): string => {
28
+ return `cond_${conditionId.replaceAll('-', '')}`
29
+ }
30
+
22
31
  export function isConditionListItemRefValueDataV2(condition: ConditionDataV2) {
23
32
  return condition.type === ConditionType.ListItemRef
24
33
  }
@@ -185,7 +194,7 @@ function convertConditionRefDataFromV2(
185
194
  }
186
195
 
187
196
  return {
188
- conditionName: refCondition.displayName,
197
+ conditionName: generateConditionAlias(refCondition.id),
189
198
  conditionDisplayName: refCondition.displayName,
190
199
  coordinator
191
200
  }
@@ -82,3 +82,17 @@ export interface PagePreviewPanelMacro {
82
82
  classes: string
83
83
  }
84
84
  }
85
+
86
+ export interface SummaryRowActionItem {
87
+ href: string
88
+ text: string
89
+ visuallyHiddenText: string
90
+ }
91
+
92
+ export interface SummaryRow {
93
+ key: { text: string }
94
+ value: { text: string }
95
+ actions: {
96
+ items: SummaryRowActionItem[]
97
+ }
98
+ }
@@ -0,0 +1,157 @@
1
+ import { hasFormField } from '~/src/components/helpers.js'
2
+ import { HIGHLIGHT_CLASS } from '~/src/form/form-editor/preview/constants.js'
3
+ import { PreviewPageControllerBase } from '~/src/form/form-editor/preview/controller/page-controller-base.js'
4
+ import { hasComponents } from '~/src/pages/helpers.js'
5
+
6
+ const EXAMPLE_TEXT = 'Answer goes here'
7
+
8
+ export class SummaryPageController extends PreviewPageControllerBase {
9
+ /**
10
+ * @type {string}
11
+ * @protected
12
+ */
13
+ _pageTemplate = PreviewPageControllerBase.PATH + 'summary-controller.njk'
14
+ /**
15
+ * @type {Markdown}
16
+ * @protected
17
+ */
18
+ _guidanceComponent = PreviewPageControllerBase.createGuidanceComponent(false)
19
+ /**
20
+ * @type {FormComponentsDef[]}
21
+ * @private
22
+ */
23
+ _componentDefs = []
24
+ /**
25
+ * @type {boolean}
26
+ * @private
27
+ */
28
+ _makeDeclaration = false
29
+ /**
30
+ * @param {SummaryPageElements} elements
31
+ * @param {FormDefinition} formDefinition
32
+ * @param {PageRenderer} renderer
33
+ */
34
+ constructor(elements, formDefinition, renderer) {
35
+ super(elements, renderer)
36
+ this._componentDefs = formDefinition.pages.flatMap((page) => {
37
+ if (hasComponents(page)) {
38
+ return page.components.filter(hasFormField)
39
+ }
40
+ return []
41
+ })
42
+ this._makeDeclaration = elements.declaration
43
+
44
+ this._guidanceComponent.content = elements.guidance
45
+ }
46
+
47
+ /**
48
+ * @returns {{ rows: SummaryRow[] }}
49
+ */
50
+ get componentRows() {
51
+ const rows = this._componentDefs.map((component) => {
52
+ const summaryRowHeading = component.shortDescription ?? ''
53
+ return {
54
+ key: { text: summaryRowHeading },
55
+ value: { text: EXAMPLE_TEXT },
56
+ actions: {
57
+ items: [
58
+ { href: '#', text: 'Change', visuallyHiddenText: summaryRowHeading }
59
+ ]
60
+ }
61
+ }
62
+ })
63
+ return {
64
+ rows
65
+ }
66
+ }
67
+
68
+ /**
69
+ * @returns {{ text: string; classes: string }}
70
+ */
71
+ get pageTitle() {
72
+ return {
73
+ text: 'Check your answers before sending your form',
74
+ classes: ''
75
+ }
76
+ }
77
+
78
+ get guidance() {
79
+ if (!this._makeDeclaration) {
80
+ return {
81
+ classes: '',
82
+ text: ''
83
+ }
84
+ }
85
+ const guidanceHighlighted = this._highlighted === 'guidance'
86
+ const classes = guidanceHighlighted ? HIGHLIGHT_CLASS : ''
87
+ let text = this._guidanceText.length ? this._guidanceText : ''
88
+
89
+ if (!text.length && guidanceHighlighted) {
90
+ text = 'Declaration text'
91
+ }
92
+ return {
93
+ text,
94
+ classes
95
+ }
96
+ }
97
+
98
+ /**
99
+ * @param {string} declarationText
100
+ */
101
+ set declarationText(declarationText) {
102
+ this.guidanceText = declarationText
103
+ }
104
+
105
+ get declarationText() {
106
+ return this.guidanceText
107
+ }
108
+
109
+ get declaration() {
110
+ return this.guidance
111
+ }
112
+
113
+ setMakeDeclaration() {
114
+ this._makeDeclaration = true
115
+ this.render()
116
+ }
117
+
118
+ unsetMakeDeclaration() {
119
+ this._makeDeclaration = false
120
+ this.render()
121
+ }
122
+
123
+ get makeDeclaration() {
124
+ return this._makeDeclaration
125
+ }
126
+
127
+ highlightDeclaration() {
128
+ this.highlightGuidance()
129
+ }
130
+
131
+ unhighlightDeclaration() {
132
+ this.clearHighlight()
133
+ }
134
+
135
+ /**
136
+ * @returns {Markdown[]}
137
+ * @protected
138
+ */
139
+ _getGuidanceComponents() {
140
+ if (!this._makeDeclaration) {
141
+ return []
142
+ }
143
+ return super._getGuidanceComponents()
144
+ }
145
+
146
+ get buttonText() {
147
+ return this.makeDeclaration ? 'Accept and send' : 'Send'
148
+ }
149
+ }
150
+
151
+ /**
152
+ * @import { ComponentDef, ContentComponentsDef, ListComponent, FormComponentsDef } from '~/src/components/types.js'
153
+ * @import { FormDefinition } from '~/src/form/form-definition/types.js'
154
+ * @import { PageRenderer, PagePreviewBaseElements, SummaryPageElements } from '~/src/form/form-editor/preview/types.js'
155
+ * @import { SummaryRowActionItem, SummaryRow } from '~/src/form/form-editor/macros/types.js'
156
+ * @import { Markdown } from '~/src/form/form-editor/preview/markdown.js'
157
+ */
@@ -22,4 +22,5 @@ export * from '~/src/form/form-editor/preview/uk-address.js'
22
22
  export * from '~/src/form/form-editor/preview/yes-no.js'
23
23
  export * from '~/src/form/form-editor/preview/controller/page-controller.js'
24
24
  export * from '~/src/form/form-editor/preview/controller/guidance-page-controller.js'
25
+ export * from '~/src/form/form-editor/preview/controller/summary-page-controller.js'
25
26
  export * from '~/src/form/form-editor/preview/controller/page-controller-base.js'
@@ -99,6 +99,10 @@ export interface PageOverviewElements extends PagePreviewBaseElements {
99
99
  hasRepeater: boolean
100
100
  }
101
101
 
102
+ export interface SummaryPageElements extends PagePreviewBaseElements {
103
+ declaration: boolean
104
+ }
105
+
102
106
  export type PreviewQuestion =
103
107
  | DateInputQuestion
104
108
  | EmailAddressQuestion