@defra/forms-model 3.0.376 → 3.0.377

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 (32) hide show
  1. package/dist/module/form/form-definition/index.js +17 -0
  2. package/dist/module/form/form-definition/index.js.map +1 -1
  3. package/dist/module/form/form-definition/types.js.map +1 -1
  4. package/dist/module/pages/controller-types.js +3 -0
  5. package/dist/module/pages/controller-types.js.map +1 -1
  6. package/dist/module/pages/enums.js +1 -0
  7. package/dist/module/pages/enums.js.map +1 -1
  8. package/dist/module/pages/helpers.js +8 -1
  9. package/dist/module/pages/helpers.js.map +1 -1
  10. package/dist/module/pages/index.js +1 -1
  11. package/dist/module/pages/index.js.map +1 -1
  12. package/dist/module/pages/page-types.js +17 -0
  13. package/dist/module/pages/page-types.js.map +1 -1
  14. package/dist/types/form/form-definition/index.d.ts.map +1 -1
  15. package/dist/types/form/form-definition/types.d.ts +20 -1
  16. package/dist/types/form/form-definition/types.d.ts.map +1 -1
  17. package/dist/types/pages/controller-types.d.ts.map +1 -1
  18. package/dist/types/pages/enums.d.ts +1 -0
  19. package/dist/types/pages/enums.d.ts.map +1 -1
  20. package/dist/types/pages/helpers.d.ts +5 -1
  21. package/dist/types/pages/helpers.d.ts.map +1 -1
  22. package/dist/types/pages/index.d.ts +1 -1
  23. package/dist/types/pages/index.d.ts.map +1 -1
  24. package/dist/types/pages/page-types.d.ts.map +1 -1
  25. package/package.json +1 -1
  26. package/src/form/form-definition/index.ts +23 -0
  27. package/src/form/form-definition/types.ts +24 -0
  28. package/src/pages/controller-types.ts +4 -0
  29. package/src/pages/enums.ts +1 -0
  30. package/src/pages/helpers.ts +10 -1
  31. package/src/pages/index.ts +1 -0
  32. package/src/pages/page-types.ts +12 -0
@@ -67,6 +67,18 @@ const nextSchema = Joi.object().keys({
67
67
  condition: Joi.string().allow('').optional(),
68
68
  redirect: Joi.string().optional()
69
69
  });
70
+ const repeatOptions = Joi.object().keys({
71
+ name: Joi.string().required(),
72
+ title: Joi.string().required()
73
+ });
74
+ const repeatSchema = Joi.object().keys({
75
+ min: Joi.number().empty('').required(),
76
+ max: Joi.number().empty('').required()
77
+ });
78
+ const pageRepeatSchema = Joi.object().keys({
79
+ options: repeatOptions.required(),
80
+ schema: repeatSchema.required()
81
+ });
70
82
 
71
83
  /**
72
84
  * `/status` is a special route for providing a user's application status.
@@ -78,6 +90,11 @@ const pageSchema = Joi.object().keys({
78
90
  section: Joi.string(),
79
91
  controller: Joi.string().optional(),
80
92
  components: Joi.array().items(componentSchema).unique('name'),
93
+ repeat: Joi.when('controller', {
94
+ is: Joi.string().valid('RepeatPageController').required(),
95
+ then: pageRepeatSchema.required(),
96
+ otherwise: Joi.any().strip()
97
+ }),
81
98
  next: Joi.array().items(nextSchema)
82
99
  });
83
100
  const baseListItemSchema = Joi.object().keys({
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["Joi","sectionsSchema","object","keys","name","string","required","title","hideTitle","boolean","optional","default","conditionFieldSchema","type","display","conditionValueSchema","value","relativeDateValueSchema","period","unit","direction","conditionRefSchema","conditionName","conditionDisplayName","coordinator","conditionSchema","field","operator","alternatives","try","conditionGroupSchema","conditions","array","items","link","id","conditionsModelSchema","conditionWrapperSchema","displayName","componentSchema","hint","allow","options","rows","number","empty","maxWords","maxDaysInPast","maxDaysInFuture","customValidationMessage","unknown","schema","min","max","length","list","nextSchema","path","condition","redirect","pageSchema","disallow","section","controller","components","unique","next","baseListItemSchema","text","description","conditional","stringListItemSchema","append","numberListItemSchema","listSchema","valid","when","is","then","otherwise","feedbackSchema","feedbackForm","url","emailAddress","email","tlds","phaseBannerSchema","phase","formDefinitionSchema","feedback","startPage","pages","sections","lists","metadata","a","any","declaration","skipSummary","phaseBanner","outputEmail","trim","Schema"],"sources":["../../../../src/form/form-definition/index.ts"],"sourcesContent":["import Joi from 'joi'\n\nimport { type ComponentType } from '~/src/components/enums.js'\nimport { type ComponentDef } from '~/src/components/types.js'\nimport {\n type ConditionData,\n type ConditionFieldData,\n type ConditionGroupData,\n type ConditionRefData,\n type ConditionValueData,\n type ConditionsModelData,\n type RelativeDateValueData\n} from '~/src/conditions/types.js'\nimport {\n type ConditionWrapper,\n type FormDefinition,\n type Item,\n type Link,\n type List,\n type Page,\n type PhaseBanner,\n type Section\n} from '~/src/form/form-definition/types.js'\n\nconst sectionsSchema = Joi.object<Section>().keys({\n name: Joi.string().required(),\n title: Joi.string().required(),\n hideTitle: Joi.boolean().optional().default(false)\n})\n\nconst conditionFieldSchema = Joi.object<ConditionFieldData>().keys({\n name: Joi.string().required(),\n type: Joi.string().required(),\n display: Joi.string().required()\n})\n\nconst conditionValueSchema = Joi.object<ConditionValueData>().keys({\n type: Joi.string().required(),\n value: Joi.string().required(),\n display: Joi.string().required()\n})\n\nconst relativeDateValueSchema = Joi.object<RelativeDateValueData>().keys({\n type: Joi.string().required(),\n period: Joi.string().required(),\n unit: Joi.string().required(),\n direction: Joi.string().required()\n})\n\nconst conditionRefSchema = Joi.object<ConditionRefData>().keys({\n conditionName: Joi.string().required(),\n conditionDisplayName: Joi.string().required(),\n coordinator: Joi.string().optional()\n})\n\nconst conditionSchema = Joi.object<ConditionData>().keys({\n field: conditionFieldSchema,\n operator: Joi.string().required(),\n value: Joi.alternatives().try(conditionValueSchema, relativeDateValueSchema),\n coordinator: Joi.string().optional()\n})\n\nconst conditionGroupSchema = Joi.object<ConditionGroupData>()\n .keys({\n conditions: Joi.array().items(\n Joi.alternatives().try(\n conditionSchema,\n conditionRefSchema,\n Joi.link('#conditionGroupSchema')\n )\n )\n })\n .id('conditionGroupSchema')\n\nconst conditionsModelSchema = Joi.object<ConditionsModelData>().keys({\n name: Joi.string().required(),\n conditions: Joi.array().items(\n Joi.alternatives().try(\n conditionSchema,\n conditionRefSchema,\n conditionGroupSchema\n )\n )\n})\n\nconst conditionWrapperSchema = Joi.object<ConditionWrapper>().keys({\n name: Joi.string().required(),\n displayName: Joi.string(),\n value: conditionsModelSchema.required()\n})\n\nexport const componentSchema = Joi.object<ComponentDef>()\n .keys({\n type: Joi.string<ComponentType>().required(),\n name: Joi.string().required(),\n title: Joi.string().required(),\n hint: Joi.string().allow('').optional(),\n options: Joi.object({\n rows: Joi.number().empty(''),\n maxWords: Joi.number().empty(''),\n maxDaysInPast: Joi.number().empty(''),\n maxDaysInFuture: Joi.number().empty(''),\n customValidationMessage: Joi.string().allow('')\n })\n .default({})\n .unknown(true),\n schema: Joi.object({\n min: Joi.number().empty(''),\n max: Joi.number().empty(''),\n length: Joi.number().empty('')\n })\n .unknown(true)\n .default({}),\n list: Joi.string().optional()\n })\n .unknown(true)\n\nconst nextSchema = Joi.object<Link>().keys({\n path: Joi.string().required(),\n condition: Joi.string().allow('').optional(),\n redirect: Joi.string().optional()\n})\n\n/**\n * `/status` is a special route for providing a user's application status.\n * It should not be configured via the designer.\n */\nconst pageSchema = Joi.object<Page>().keys({\n path: Joi.string().required().disallow('/status'),\n title: Joi.string().required(),\n section: Joi.string(),\n controller: Joi.string().optional(),\n components: Joi.array<ComponentDef>().items(componentSchema).unique('name'),\n next: Joi.array<Link>().items(nextSchema)\n})\n\nconst baseListItemSchema = Joi.object<Item>().keys({\n text: Joi.string().allow(''),\n description: Joi.string().allow('').optional(),\n conditional: Joi.object<Item['conditional']>()\n .keys({\n components: Joi.array<ComponentDef>()\n .required()\n .items(componentSchema.unknown(true))\n .unique('name')\n })\n .optional(),\n condition: Joi.string().allow('').optional()\n})\n\nconst stringListItemSchema = baseListItemSchema.append({\n value: Joi.string().required()\n})\n\nconst numberListItemSchema = baseListItemSchema.append({\n value: Joi.number().required()\n})\n\nconst listSchema = Joi.object<List>().keys({\n name: Joi.string().required(),\n title: Joi.string().required(),\n type: Joi.string().required().valid('string', 'number'),\n items: Joi.when('type', {\n is: 'string',\n then: Joi.array()\n .items(stringListItemSchema)\n .unique('text')\n .unique('value'),\n otherwise: Joi.array()\n .items(numberListItemSchema)\n .unique('text')\n .unique('value')\n })\n})\n\nconst feedbackSchema = Joi.object<FormDefinition['feedback']>().keys({\n feedbackForm: Joi.boolean().default(false),\n url: Joi.when('feedbackForm', {\n is: Joi.boolean().valid(false),\n then: Joi.string().optional().allow('')\n }),\n emailAddress: Joi.string()\n .email({\n tlds: {\n allow: false\n }\n })\n .optional()\n})\n\nconst phaseBannerSchema = Joi.object<PhaseBanner>().keys({\n phase: Joi.string().valid('alpha', 'beta')\n})\n\n/**\n * Joi schema for `FormDefinition` interface\n * @see {@link FormDefinition}\n */\nexport const formDefinitionSchema = Joi.object<FormDefinition>()\n .required()\n .keys({\n name: Joi.string().allow('').optional(),\n feedback: feedbackSchema.optional(),\n startPage: Joi.string().optional(),\n pages: Joi.array<Page>().required().items(pageSchema).unique('path'),\n sections: Joi.array<Section>()\n .items(sectionsSchema)\n .unique('name')\n .unique('title')\n .required(),\n conditions: Joi.array<ConditionWrapper>()\n .items(conditionWrapperSchema)\n .unique('name')\n .unique('displayName'),\n lists: Joi.array<List>().items(listSchema).unique('name').unique('title'),\n metadata: Joi.object({ a: Joi.any() }).unknown().optional(),\n declaration: Joi.string().allow('').optional(),\n skipSummary: Joi.boolean().optional().default(false),\n phaseBanner: phaseBannerSchema.optional(),\n outputEmail: Joi.string()\n .email({ tlds: { allow: ['uk'] } })\n .trim()\n .optional()\n })\n\n// Maintain compatibility with legacy named export\n// E.g. `import { Schema } from '@defra/forms-model'`\nexport const Schema = formDefinitionSchema\n"],"mappings":"AAAA,OAAOA,GAAG,MAAM,KAAK;AAwBrB,MAAMC,cAAc,GAAGD,GAAG,CAACE,MAAM,CAAU,CAAC,CAACC,IAAI,CAAC;EAChDC,IAAI,EAAEJ,GAAG,CAACK,MAAM,CAAC,CAAC,CAACC,QAAQ,CAAC,CAAC;EAC7BC,KAAK,EAAEP,GAAG,CAACK,MAAM,CAAC,CAAC,CAACC,QAAQ,CAAC,CAAC;EAC9BE,SAAS,EAAER,GAAG,CAACS,OAAO,CAAC,CAAC,CAACC,QAAQ,CAAC,CAAC,CAACC,OAAO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AK,EAAE7F,GAAG,CAACgC,KAAK,CAAO,CAAC,CAACC,KAAK,CAACyC,UAAU,CAAC,CAACT,MAAM,CAAC,MAAM,CAAC,CAACA,MAAM,CAAC,OAAO,CAAC;EACzE6B,QAAQ,EAAE9F,GAAG,CAACE,MAAM,CAAC;IAAE6F,CAAC,EAAE/F,GAAG,CAACgG,GAAG,CAAC;EAAE,CAAC,CAAC,CAAC9C,OAAO,CAAC,CAAC,CAACxC,QAAQ,CAAC,CAAC;EAC3DuF,WAAW,EAAEjG,GAAG,CAACK,MAAM,CAAC,CAAC,CAACoC,KAAK,CAAC,EAAE,CAAC,CAAC/B,QAAQ,CAAC,CAAC;EAC9CwF,WAAW,EAAElG,GAAG,CAACS,OAAO,CAAC,CAAC,CAACC,QAAQ,CAAC,CAAC,CAACC,OAAO,CAAC,KAAK,CAAC;EACpDwF,WAAW,EAAEb,iBAAiB,CAAC5E,QAAQ,CAAC,CAAC;EACzC0F,WAAW,EAAEpG,GAAG,CAACK,MAAM,CAAC,CAAC,CACtB+E,KAAK,CAAC;IAAEC,IAAI,EAAE;MAAE5C,KAAK,EAAE,CAAC,IAAI;IAAE;EAAE,CAAC,CAAC,CAClC4D,IAAI,CAAC,CAAC,CACN3F,QAAQ,CAAC;AACd,CAAC,CAAC;;AAEJ;AACA;AACA,OAAO,MAAM4F,MAAM,GAAGd,oBAAoB","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["Joi","sectionsSchema","object","keys","name","string","required","title","hideTitle","boolean","optional","default","conditionFieldSchema","type","display","conditionValueSchema","value","relativeDateValueSchema","period","unit","direction","conditionRefSchema","conditionName","conditionDisplayName","coordinator","conditionSchema","field","operator","alternatives","try","conditionGroupSchema","conditions","array","items","link","id","conditionsModelSchema","conditionWrapperSchema","displayName","componentSchema","hint","allow","options","rows","number","empty","maxWords","maxDaysInPast","maxDaysInFuture","customValidationMessage","unknown","schema","min","max","length","list","nextSchema","path","condition","redirect","repeatOptions","repeatSchema","pageRepeatSchema","pageSchema","disallow","section","controller","components","unique","repeat","when","is","valid","then","otherwise","any","strip","next","baseListItemSchema","text","description","conditional","stringListItemSchema","append","numberListItemSchema","listSchema","feedbackSchema","feedbackForm","url","emailAddress","email","tlds","phaseBannerSchema","phase","formDefinitionSchema","feedback","startPage","pages","sections","lists","metadata","a","declaration","skipSummary","phaseBanner","outputEmail","trim","Schema"],"sources":["../../../../src/form/form-definition/index.ts"],"sourcesContent":["import Joi from 'joi'\n\nimport { type ComponentType } from '~/src/components/enums.js'\nimport { type ComponentDef } from '~/src/components/types.js'\nimport {\n type ConditionData,\n type ConditionFieldData,\n type ConditionGroupData,\n type ConditionRefData,\n type ConditionValueData,\n type ConditionsModelData,\n type RelativeDateValueData\n} from '~/src/conditions/types.js'\nimport {\n type ConditionWrapper,\n type FormDefinition,\n type Item,\n type Link,\n type List,\n type Page,\n type PhaseBanner,\n type Repeat,\n type RepeatOptions,\n type RepeatSchema,\n type Section\n} from '~/src/form/form-definition/types.js'\n\nconst sectionsSchema = Joi.object<Section>().keys({\n name: Joi.string().required(),\n title: Joi.string().required(),\n hideTitle: Joi.boolean().optional().default(false)\n})\n\nconst conditionFieldSchema = Joi.object<ConditionFieldData>().keys({\n name: Joi.string().required(),\n type: Joi.string().required(),\n display: Joi.string().required()\n})\n\nconst conditionValueSchema = Joi.object<ConditionValueData>().keys({\n type: Joi.string().required(),\n value: Joi.string().required(),\n display: Joi.string().required()\n})\n\nconst relativeDateValueSchema = Joi.object<RelativeDateValueData>().keys({\n type: Joi.string().required(),\n period: Joi.string().required(),\n unit: Joi.string().required(),\n direction: Joi.string().required()\n})\n\nconst conditionRefSchema = Joi.object<ConditionRefData>().keys({\n conditionName: Joi.string().required(),\n conditionDisplayName: Joi.string().required(),\n coordinator: Joi.string().optional()\n})\n\nconst conditionSchema = Joi.object<ConditionData>().keys({\n field: conditionFieldSchema,\n operator: Joi.string().required(),\n value: Joi.alternatives().try(conditionValueSchema, relativeDateValueSchema),\n coordinator: Joi.string().optional()\n})\n\nconst conditionGroupSchema = Joi.object<ConditionGroupData>()\n .keys({\n conditions: Joi.array().items(\n Joi.alternatives().try(\n conditionSchema,\n conditionRefSchema,\n Joi.link('#conditionGroupSchema')\n )\n )\n })\n .id('conditionGroupSchema')\n\nconst conditionsModelSchema = Joi.object<ConditionsModelData>().keys({\n name: Joi.string().required(),\n conditions: Joi.array().items(\n Joi.alternatives().try(\n conditionSchema,\n conditionRefSchema,\n conditionGroupSchema\n )\n )\n})\n\nconst conditionWrapperSchema = Joi.object<ConditionWrapper>().keys({\n name: Joi.string().required(),\n displayName: Joi.string(),\n value: conditionsModelSchema.required()\n})\n\nexport const componentSchema = Joi.object<ComponentDef>()\n .keys({\n type: Joi.string<ComponentType>().required(),\n name: Joi.string().required(),\n title: Joi.string().required(),\n hint: Joi.string().allow('').optional(),\n options: Joi.object({\n rows: Joi.number().empty(''),\n maxWords: Joi.number().empty(''),\n maxDaysInPast: Joi.number().empty(''),\n maxDaysInFuture: Joi.number().empty(''),\n customValidationMessage: Joi.string().allow('')\n })\n .default({})\n .unknown(true),\n schema: Joi.object({\n min: Joi.number().empty(''),\n max: Joi.number().empty(''),\n length: Joi.number().empty('')\n })\n .unknown(true)\n .default({}),\n list: Joi.string().optional()\n })\n .unknown(true)\n\nconst nextSchema = Joi.object<Link>().keys({\n path: Joi.string().required(),\n condition: Joi.string().allow('').optional(),\n redirect: Joi.string().optional()\n})\n\nconst repeatOptions = Joi.object<RepeatOptions>().keys({\n name: Joi.string().required(),\n title: Joi.string().required()\n})\n\nconst repeatSchema = Joi.object<RepeatSchema>().keys({\n min: Joi.number().empty('').required(),\n max: Joi.number().empty('').required()\n})\n\nconst pageRepeatSchema = Joi.object<Repeat>().keys({\n options: repeatOptions.required(),\n schema: repeatSchema.required()\n})\n\n/**\n * `/status` is a special route for providing a user's application status.\n * It should not be configured via the designer.\n */\nconst pageSchema = Joi.object<Page>().keys({\n path: Joi.string().required().disallow('/status'),\n title: Joi.string().required(),\n section: Joi.string(),\n controller: Joi.string().optional(),\n components: Joi.array<ComponentDef>().items(componentSchema).unique('name'),\n repeat: Joi.when('controller', {\n is: Joi.string().valid('RepeatPageController').required(),\n then: pageRepeatSchema.required(),\n otherwise: Joi.any().strip()\n }),\n next: Joi.array<Link>().items(nextSchema)\n})\n\nconst baseListItemSchema = Joi.object<Item>().keys({\n text: Joi.string().allow(''),\n description: Joi.string().allow('').optional(),\n conditional: Joi.object<Item['conditional']>()\n .keys({\n components: Joi.array<ComponentDef>()\n .required()\n .items(componentSchema.unknown(true))\n .unique('name')\n })\n .optional(),\n condition: Joi.string().allow('').optional()\n})\n\nconst stringListItemSchema = baseListItemSchema.append({\n value: Joi.string().required()\n})\n\nconst numberListItemSchema = baseListItemSchema.append({\n value: Joi.number().required()\n})\n\nconst listSchema = Joi.object<List>().keys({\n name: Joi.string().required(),\n title: Joi.string().required(),\n type: Joi.string().required().valid('string', 'number'),\n items: Joi.when('type', {\n is: 'string',\n then: Joi.array()\n .items(stringListItemSchema)\n .unique('text')\n .unique('value'),\n otherwise: Joi.array()\n .items(numberListItemSchema)\n .unique('text')\n .unique('value')\n })\n})\n\nconst feedbackSchema = Joi.object<FormDefinition['feedback']>().keys({\n feedbackForm: Joi.boolean().default(false),\n url: Joi.when('feedbackForm', {\n is: Joi.boolean().valid(false),\n then: Joi.string().optional().allow('')\n }),\n emailAddress: Joi.string()\n .email({\n tlds: {\n allow: false\n }\n })\n .optional()\n})\n\nconst phaseBannerSchema = Joi.object<PhaseBanner>().keys({\n phase: Joi.string().valid('alpha', 'beta')\n})\n\n/**\n * Joi schema for `FormDefinition` interface\n * @see {@link FormDefinition}\n */\nexport const formDefinitionSchema = Joi.object<FormDefinition>()\n .required()\n .keys({\n name: Joi.string().allow('').optional(),\n feedback: feedbackSchema.optional(),\n startPage: Joi.string().optional(),\n pages: Joi.array<Page>().required().items(pageSchema).unique('path'),\n sections: Joi.array<Section>()\n .items(sectionsSchema)\n .unique('name')\n .unique('title')\n .required(),\n conditions: Joi.array<ConditionWrapper>()\n .items(conditionWrapperSchema)\n .unique('name')\n .unique('displayName'),\n lists: Joi.array<List>().items(listSchema).unique('name').unique('title'),\n metadata: Joi.object({ a: Joi.any() }).unknown().optional(),\n declaration: Joi.string().allow('').optional(),\n skipSummary: Joi.boolean().optional().default(false),\n phaseBanner: phaseBannerSchema.optional(),\n outputEmail: Joi.string()\n .email({ tlds: { allow: ['uk'] } })\n .trim()\n .optional()\n })\n\n// Maintain compatibility with legacy named export\n// E.g. `import { Schema } from '@defra/forms-model'`\nexport const Schema = formDefinitionSchema\n"],"mappings":"AAAA,OAAOA,GAAG,MAAM,KAAK;AA2BrB,MAAMC,cAAc,GAAGD,GAAG,CAACE,MAAM,CAAU,CAAC,CAACC,IAAI,CAAC;EAChDC,IAAI,EAAEJ,GAAG,CAACK,MAAM,CAAC,CAAC,CAACC,QAAQ,CAAC,CAAC;EAC7BC,KAAK,EAAEP,GAAG,CAACK,MAAM,CAAC,CAAC,CAACC,QAAQ,CAAC,CAAC;EAC9BE,SAAS,EAAER,GAAG,CAACS,OAAO,CAAC,CAAC,CAACC,QAAQ,CAAC,CAAC,CAACC,OAAO,CAAC,KAAK;AACnD,CAAC,CAAC;AAEF,MAAMC,oBAAoB,GAAGZ,GAAG,CAACE,MAAM,CAAqB,CAAC,CAACC,IAAI,CAAC;EACjEC,IAAI,EAAEJ,GAAG,CAACK,MAAM,CAAC,CAAC,CAACC,QAAQ,CAAC,CAAC;EAC7BO,IAAI,EAAEb,GAAG,CAACK,MAAM,CAAC,CAAC,CAACC,QAAQ,CAAC,CAAC;EAC7BQ,OAAO,EAAEd,GAAG,CAACK,MAAM,CAAC,CAAC,CAACC,QAAQ,CAAC;AACjC,CAAC,CAAC;AAEF,MAAMS,oBAAoB,GAAGf,GAAG,CAACE,MAAM,CAAqB,CAAC,CAACC,IAAI,CAAC;EACjEU,IAAI,EAAEb,GAAG,CAACK,MAAM,CAAC,CAAC,CAACC,QAAQ,CAAC,CAAC;EAC7BU,KAAK,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E;MAAElD,KAAK,EAAE,CAAC,IAAI;IAAE;EAAE,CAAC,CAAC,CAClCiE,IAAI,CAAC,CAAC,CACNhG,QAAQ,CAAC;AACd,CAAC,CAAC;;AAEJ;AACA;AACA,OAAO,MAAMiG,MAAM,GAAGb,oBAAoB","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":[],"sources":["../../../../src/form/form-definition/types.ts"],"sourcesContent":["import { type ComponentDef } from '~/src/components/types.js'\nimport { type ConditionsModelData } from '~/src/conditions/types.js'\nimport { formDefinitionSchema } from '~/src/form/form-definition/index.js'\nimport { type ControllerPath, type ControllerType } from '~/src/pages/enums.js'\n\nexport interface Link {\n path: string\n condition?: string\n redirect?: string\n}\n\nexport interface PageBase {\n title: string\n path: string\n}\n\nexport interface PageStart extends PageBase {\n path: ControllerPath.Start | string\n controller: ControllerType.Start | ControllerType.Home\n section?: string | undefined\n next: Link[]\n components: ComponentDef[]\n}\n\nexport interface PageQuestion extends PageBase {\n controller?: ControllerType.Page\n section?: string | undefined\n next: Link[]\n components: ComponentDef[]\n}\n\nexport interface PageFileUpload extends PageBase {\n controller?: ControllerType.FileUpload\n section?: string | undefined\n next: Link[]\n components: ComponentDef[]\n}\n\nexport interface PageSummary extends PageBase {\n path: ControllerPath.Summary | string\n controller: ControllerType.Summary\n section?: undefined\n}\n\nexport interface PageStatus extends PageBase {\n path: ControllerPath.Status | string\n controller: ControllerType.Status\n section?: undefined\n}\n\nexport type Page =\n | PageStart\n | PageQuestion\n | PageFileUpload\n | PageSummary\n | PageStatus\n\nexport type RequiredField<\n Type extends Partial<object>,\n KeyType extends keyof Type\n> = Omit<Type, KeyType> &\n Required<{\n [Key in KeyType]: Type[Key]\n }>\n\nexport interface Section {\n name: string\n title: string\n hideTitle?: boolean\n}\n\nexport interface Item {\n text: string\n value: string | number | boolean\n description?: string\n conditional?: { components: ComponentDef[] }\n condition?: string\n}\n\nexport interface List {\n name: string\n title: string\n type: ListTypeContent\n items: Item[]\n}\n\nexport type ListTypeOption = 'bulleted' | 'numbered'\nexport type ListTypeContent = 'string' | 'number' | 'boolean'\n\nexport interface Feedback {\n feedbackForm?: boolean\n url?: string\n emailAddress?: string\n}\n\nexport interface PhaseBanner {\n phase?: 'alpha' | 'beta'\n feedbackUrl?: string\n}\n\nexport interface ConditionWrapper {\n name: string\n displayName: string\n value: ConditionsModelData\n}\n\n/**\n * Interface for `formDefinitionSchema` Joi schema\n * @see {@link formDefinitionSchema}\n */\nexport interface FormDefinition {\n pages: Page[]\n conditions: ConditionWrapper[]\n lists: List[]\n sections: Section[]\n startPage?: string\n name?: string\n feedback?: Feedback\n phaseBanner?: PhaseBanner\n skipSummary?: boolean\n declaration?: string\n metadata?: Record<string, unknown>\n outputEmail?: string\n}\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"file":"types.js","names":[],"sources":["../../../../src/form/form-definition/types.ts"],"sourcesContent":["import { type ComponentDef } from '~/src/components/types.js'\nimport { type ConditionsModelData } from '~/src/conditions/types.js'\nimport { formDefinitionSchema } from '~/src/form/form-definition/index.js'\nimport { type ControllerPath, type ControllerType } from '~/src/pages/enums.js'\n\nexport interface Link {\n path: string\n condition?: string\n redirect?: string\n}\n\nexport interface PageBase {\n title: string\n path: string\n}\n\nexport interface RepeatOptions {\n name: string\n title: string\n}\n\nexport interface RepeatSchema {\n min: number\n max: number\n}\n\nexport interface Repeat {\n options: RepeatOptions\n schema: RepeatSchema\n}\n\nexport interface PageStart extends PageBase {\n path: ControllerPath.Start | string\n controller: ControllerType.Start | ControllerType.Home\n section?: string | undefined\n next: Link[]\n components: ComponentDef[]\n}\n\nexport interface PageQuestion extends PageBase {\n controller?: ControllerType.Page\n section?: string | undefined\n next: Link[]\n components: ComponentDef[]\n}\n\nexport interface PageRepeat extends PageBase {\n controller?: ControllerType.Repeat\n repeat: Repeat\n section?: string | undefined\n next: Link[]\n components: ComponentDef[]\n}\n\nexport interface PageFileUpload extends PageBase {\n controller?: ControllerType.FileUpload\n section?: string | undefined\n next: Link[]\n components: ComponentDef[]\n}\n\nexport interface PageSummary extends PageBase {\n path: ControllerPath.Summary | string\n controller: ControllerType.Summary\n section?: undefined\n}\n\nexport interface PageStatus extends PageBase {\n path: ControllerPath.Status | string\n controller: ControllerType.Status\n section?: undefined\n}\n\nexport type Page =\n | PageStart\n | PageQuestion\n | PageFileUpload\n | PageRepeat\n | PageSummary\n | PageStatus\n\nexport type RequiredField<\n Type extends Partial<object>,\n KeyType extends keyof Type\n> = Omit<Type, KeyType> &\n Required<{\n [Key in KeyType]: Type[Key]\n }>\n\nexport interface Section {\n name: string\n title: string\n hideTitle?: boolean\n}\n\nexport interface Item {\n text: string\n value: string | number | boolean\n description?: string\n conditional?: { components: ComponentDef[] }\n condition?: string\n}\n\nexport interface List {\n name: string\n title: string\n type: ListTypeContent\n items: Item[]\n}\n\nexport type ListTypeOption = 'bulleted' | 'numbered'\nexport type ListTypeContent = 'string' | 'number' | 'boolean'\n\nexport interface Feedback {\n feedbackForm?: boolean\n url?: string\n emailAddress?: string\n}\n\nexport interface PhaseBanner {\n phase?: 'alpha' | 'beta'\n feedbackUrl?: string\n}\n\nexport interface ConditionWrapper {\n name: string\n displayName: string\n value: ConditionsModelData\n}\n\n/**\n * Interface for `formDefinitionSchema` Joi schema\n * @see {@link formDefinitionSchema}\n */\nexport interface FormDefinition {\n pages: Page[]\n conditions: ConditionWrapper[]\n lists: List[]\n sections: Section[]\n startPage?: string\n name?: string\n feedback?: Feedback\n phaseBanner?: PhaseBanner\n skipSummary?: boolean\n declaration?: string\n metadata?: Record<string, unknown>\n outputEmail?: string\n}\n"],"mappings":"","ignoreList":[]}
@@ -8,6 +8,9 @@ export const ControllerTypes = [{
8
8
  }, {
9
9
  name: ControllerType.Page,
10
10
  path: './pages/page.js'
11
+ }, {
12
+ name: ControllerType.Repeat,
13
+ path: './pages/repeat.js'
11
14
  }, {
12
15
  name: ControllerType.FileUpload,
13
16
  path: './pages/file-upload.js'
@@ -1 +1 @@
1
- {"version":3,"file":"controller-types.js","names":["ControllerType","ControllerTypes","name","Start","path","Home","Page","FileUpload","Summary","Status","ControllerNames","map"],"sources":["../../../src/pages/controller-types.ts"],"sourcesContent":["import { ControllerType } from '~/src/pages/enums.js'\n\nexport const ControllerTypes = [\n {\n name: ControllerType.Start,\n path: './pages/start.js'\n },\n {\n name: ControllerType.Home,\n path: './pages/home.js'\n },\n {\n name: ControllerType.Page,\n path: './pages/page.js'\n },\n {\n name: ControllerType.FileUpload,\n path: './pages/file-upload.js'\n },\n {\n name: ControllerType.Summary,\n path: './pages/summary.js'\n },\n {\n name: ControllerType.Status,\n path: './pages/status.js'\n }\n]\n\nexport const ControllerNames = ControllerTypes.map(({ name }) => name)\n"],"mappings":"AAAA,SAASA,cAAc;AAEvB,OAAO,MAAMC,eAAe,GAAG,CAC7B;EACEC,IAAI,EAAEF,cAAc,CAACG,KAAK;EAC1BC,IAAI,EAAE;AACR,CAAC,EACD;EACEF,IAAI,EAAEF,cAAc,CAACK,IAAI;EACzBD,IAAI,EAAE;AACR,CAAC,EACD;EACEF,IAAI,EAAEF,cAAc,CAACM,IAAI;EACzBF,IAAI,EAAE;AACR,CAAC,EACD;EACEF,IAAI,EAAEF,cAAc,CAACO,UAAU;EAC/BH,IAAI,EAAE;AACR,CAAC,EACD;EACEF,IAAI,EAAEF,cAAc,CAACQ,OAAO;EAC5BJ,IAAI,EAAE;AACR,CAAC,EACD;EACEF,IAAI,EAAEF,cAAc,CAACS,MAAM;EAC3BL,IAAI,EAAE;AACR,CAAC,CACF;AAED,OAAO,MAAMM,eAAe,GAAGT,eAAe,CAACU,GAAG,CAAC,CAAC;EAAET;AAAK,CAAC,KAAKA,IAAI,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"controller-types.js","names":["ControllerType","ControllerTypes","name","Start","path","Home","Page","Repeat","FileUpload","Summary","Status","ControllerNames","map"],"sources":["../../../src/pages/controller-types.ts"],"sourcesContent":["import { ControllerType } from '~/src/pages/enums.js'\n\nexport const ControllerTypes = [\n {\n name: ControllerType.Start,\n path: './pages/start.js'\n },\n {\n name: ControllerType.Home,\n path: './pages/home.js'\n },\n {\n name: ControllerType.Page,\n path: './pages/page.js'\n },\n {\n name: ControllerType.Repeat,\n path: './pages/repeat.js'\n },\n {\n name: ControllerType.FileUpload,\n path: './pages/file-upload.js'\n },\n {\n name: ControllerType.Summary,\n path: './pages/summary.js'\n },\n {\n name: ControllerType.Status,\n path: './pages/status.js'\n }\n]\n\nexport const ControllerNames = ControllerTypes.map(({ name }) => name)\n"],"mappings":"AAAA,SAASA,cAAc;AAEvB,OAAO,MAAMC,eAAe,GAAG,CAC7B;EACEC,IAAI,EAAEF,cAAc,CAACG,KAAK;EAC1BC,IAAI,EAAE;AACR,CAAC,EACD;EACEF,IAAI,EAAEF,cAAc,CAACK,IAAI;EACzBD,IAAI,EAAE;AACR,CAAC,EACD;EACEF,IAAI,EAAEF,cAAc,CAACM,IAAI;EACzBF,IAAI,EAAE;AACR,CAAC,EACD;EACEF,IAAI,EAAEF,cAAc,CAACO,MAAM;EAC3BH,IAAI,EAAE;AACR,CAAC,EACD;EACEF,IAAI,EAAEF,cAAc,CAACQ,UAAU;EAC/BJ,IAAI,EAAE;AACR,CAAC,EACD;EACEF,IAAI,EAAEF,cAAc,CAACS,OAAO;EAC5BL,IAAI,EAAE;AACR,CAAC,EACD;EACEF,IAAI,EAAEF,cAAc,CAACU,MAAM;EAC3BN,IAAI,EAAE;AACR,CAAC,CACF;AAED,OAAO,MAAMO,eAAe,GAAGV,eAAe,CAACW,GAAG,CAAC,CAAC;EAAEV;AAAK,CAAC,KAAKA,IAAI,CAAC","ignoreList":[]}
@@ -8,6 +8,7 @@ export let ControllerType = /*#__PURE__*/function (ControllerType) {
8
8
  ControllerType["Start"] = "StartPageController";
9
9
  ControllerType["Home"] = "HomePageController";
10
10
  ControllerType["Page"] = "PageController";
11
+ ControllerType["Repeat"] = "RepeatPageController";
11
12
  ControllerType["FileUpload"] = "FileUploadPageController";
12
13
  ControllerType["Summary"] = "SummaryPageController";
13
14
  ControllerType["Status"] = "StatusPageController";
@@ -1 +1 @@
1
- {"version":3,"file":"enums.js","names":["ControllerPath","ControllerType"],"sources":["../../../src/pages/enums.ts"],"sourcesContent":["export enum ControllerPath {\n Start = '/start',\n Summary = '/summary',\n Status = '/status'\n}\n\nexport enum ControllerType {\n Start = 'StartPageController',\n Home = 'HomePageController',\n Page = 'PageController',\n FileUpload = 'FileUploadPageController',\n Summary = 'SummaryPageController',\n Status = 'StatusPageController'\n}\n"],"mappings":"AAAA,WAAYA,cAAc,0BAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAA,OAAdA,cAAc;AAAA;AAM1B,WAAYC,cAAc,0BAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAA,OAAdA,cAAc;AAAA","ignoreList":[]}
1
+ {"version":3,"file":"enums.js","names":["ControllerPath","ControllerType"],"sources":["../../../src/pages/enums.ts"],"sourcesContent":["export enum ControllerPath {\n Start = '/start',\n Summary = '/summary',\n Status = '/status'\n}\n\nexport enum ControllerType {\n Start = 'StartPageController',\n Home = 'HomePageController',\n Page = 'PageController',\n Repeat = 'RepeatPageController',\n FileUpload = 'FileUploadPageController',\n Summary = 'SummaryPageController',\n Status = 'StatusPageController'\n}\n"],"mappings":"AAAA,WAAYA,cAAc,0BAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAA,OAAdA,cAAc;AAAA;AAM1B,WAAYC,cAAc,0BAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAA,OAAdA,cAAc;AAAA","ignoreList":[]}
@@ -37,6 +37,13 @@ export function hasSection(page) {
37
37
  return hasNext(page) && typeof page.section === 'string';
38
38
  }
39
39
 
40
+ /**
41
+ * Check page has repeater
42
+ */
43
+ export function hasRepeater(page) {
44
+ return controllerNameFromPath(page?.controller) === ControllerType.Repeat;
45
+ }
46
+
40
47
  /**
41
48
  * Check for known page controller names
42
49
  */
@@ -52,7 +59,7 @@ export function hasNext(page) {
52
59
  return false;
53
60
  }
54
61
  const controller = controllerNameFromPath(page.controller);
55
- return !controller || controller === ControllerType.Start || controller === ControllerType.Page || controller === ControllerType.FileUpload;
62
+ return !controller || controller === ControllerType.Start || controller === ControllerType.Page || controller === ControllerType.FileUpload || controller === ControllerType.Repeat;
56
63
  }
57
64
 
58
65
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.js","names":["ControllerNames","ControllerTypes","ControllerType","PageTypes","getPageDefaults","page","nameOrPath","controller","Page","controllerNameFromPath","defaults","find","pageType","Error","structuredClone","hasComponents","hasNext","Array","isArray","components","hasFormComponents","Start","hasSection","section","isControllerName","map","String","includes","FileUpload","options","path","name"],"sources":["../../../src/pages/helpers.ts"],"sourcesContent":["import { type ComponentDef } from '~/src/components/types.js'\nimport {\n type Link,\n type Page,\n type PageFileUpload,\n type PageQuestion,\n type PageStart,\n type RequiredField\n} from '~/src/form/form-definition/types.js'\nimport {\n ControllerNames,\n ControllerTypes\n} from '~/src/pages/controller-types.js'\nimport { ControllerType } from '~/src/pages/enums.js'\nimport { PageTypes } from '~/src/pages/page-types.js'\n\n/**\n * Return component defaults by type\n */\nexport function getPageDefaults<PageType extends Page>(\n page?: Pick<PageType, 'controller'>\n) {\n const nameOrPath = page?.controller ?? ControllerType.Page\n const controller = controllerNameFromPath(nameOrPath)\n\n const defaults = PageTypes.find(\n (pageType) => pageType.controller === controller\n )\n\n if (!defaults) {\n throw new Error(`Defaults not found for page type '${nameOrPath}'`)\n }\n\n return structuredClone(defaults) as PageType\n}\n\n/**\n * Check page has components\n */\nexport function hasComponents(\n page?: Partial<Page>\n): page is Extract<Page, { components: ComponentDef[] }> {\n return hasNext(page) && Array.isArray(page.components)\n}\n\n/**\n * Check page has form components\n */\nexport function hasFormComponents(\n page?: Partial<Page>\n): page is PageQuestion | PageFileUpload {\n const controller = controllerNameFromPath(page?.controller)\n return hasComponents(page) && controller !== ControllerType.Start\n}\n\n/**\n * Check page has sections\n */\nexport function hasSection(\n page?: Partial<Page>\n): page is\n | RequiredField<PageStart, 'section'>\n | RequiredField<PageQuestion, 'section'>\n | RequiredField<PageFileUpload, 'section'> {\n return hasNext(page) && typeof page.section === 'string'\n}\n\n/**\n * Check for known page controller names\n */\nexport function isControllerName(\n nameOrPath?: ControllerType | string\n): nameOrPath is ControllerType {\n return !!nameOrPath && ControllerNames.map(String).includes(nameOrPath)\n}\n\n/**\n * Check page has next link\n */\nexport function hasNext(\n page?: Partial<Page>\n): page is Extract<Page, { next: Link[] }> {\n if (!page || !('next' in page)) {\n return false\n }\n\n const controller = controllerNameFromPath(page.controller)\n\n return (\n !controller ||\n controller === ControllerType.Start ||\n controller === ControllerType.Page ||\n controller === ControllerType.FileUpload\n )\n}\n\n/**\n * Check and optionally replace legacy path with controller name\n * @param {string} [nameOrPath] - Controller name or legacy controller path\n */\nexport function controllerNameFromPath(nameOrPath?: ControllerType | string) {\n if (isControllerName(nameOrPath)) {\n return nameOrPath\n }\n\n const options = ControllerTypes.find(({ path }) => path === nameOrPath)\n return options?.name\n}\n"],"mappings":"AASA,SACEA,eAAe,EACfC,eAAe;AAEjB,SAASC,cAAc;AACvB,SAASC,SAAS;;AAElB;AACA;AACA;AACA,OAAO,SAASC,eAAeA,CAC7BC,IAAmC,EACnC;EACA,MAAMC,UAAU,GAAGD,IAAI,EAAEE,UAAU,IAAIL,cAAc,CAACM,IAAI;EAC1D,MAAMD,UAAU,GAAGE,sBAAsB,CAACH,UAAU,CAAC;EAErD,MAAMI,QAAQ,GAAGP,SAAS,CAACQ,IAAI,CAC5BC,QAAQ,IAAKA,QAAQ,CAACL,UAAU,KAAKA,UACxC,CAAC;EAED,IAAI,CAACG,QAAQ,EAAE;IACb,MAAM,IAAIG,KAAK,CAAC,qCA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,IAAIkB,gBAAgB,CAAClB,UAAU,CAAC,EAAE;IAChC,OAAOA,UAAU;EACnB;EAEA,MAAMuB,OAAO,GAAG5B,eAAe,CAACU,IAAI,CAAC,CAAC;IAAEmB;EAAK,CAAC,KAAKA,IAAI,KAAKxB,UAAU,CAAC;EACvE,OAAOuB,OAAO,EAAEE,IAAI;AACtB","ignoreList":[]}
1
+ {"version":3,"file":"helpers.js","names":["ControllerNames","ControllerTypes","ControllerType","PageTypes","getPageDefaults","page","nameOrPath","controller","Page","controllerNameFromPath","defaults","find","pageType","Error","structuredClone","hasComponents","hasNext","Array","isArray","components","hasFormComponents","Start","hasSection","section","hasRepeater","Repeat","isControllerName","map","String","includes","FileUpload","options","path","name"],"sources":["../../../src/pages/helpers.ts"],"sourcesContent":["import { type ComponentDef } from '~/src/components/types.js'\nimport {\n type Link,\n type Page,\n type PageFileUpload,\n type PageQuestion,\n type PageRepeat,\n type PageStart,\n type RequiredField\n} from '~/src/form/form-definition/types.js'\nimport {\n ControllerNames,\n ControllerTypes\n} from '~/src/pages/controller-types.js'\nimport { ControllerType } from '~/src/pages/enums.js'\nimport { PageTypes } from '~/src/pages/page-types.js'\n\n/**\n * Return component defaults by type\n */\nexport function getPageDefaults<PageType extends Page>(\n page?: Pick<PageType, 'controller'>\n) {\n const nameOrPath = page?.controller ?? ControllerType.Page\n const controller = controllerNameFromPath(nameOrPath)\n\n const defaults = PageTypes.find(\n (pageType) => pageType.controller === controller\n )\n\n if (!defaults) {\n throw new Error(`Defaults not found for page type '${nameOrPath}'`)\n }\n\n return structuredClone(defaults) as PageType\n}\n\n/**\n * Check page has components\n */\nexport function hasComponents(\n page?: Partial<Page>\n): page is Extract<Page, { components: ComponentDef[] }> {\n return hasNext(page) && Array.isArray(page.components)\n}\n\n/**\n * Check page has form components\n */\nexport function hasFormComponents(\n page?: Partial<Page>\n): page is PageQuestion | PageFileUpload {\n const controller = controllerNameFromPath(page?.controller)\n return hasComponents(page) && controller !== ControllerType.Start\n}\n\n/**\n * Check page has sections\n */\nexport function hasSection(\n page?: Partial<Page>\n): page is\n | RequiredField<PageStart, 'section'>\n | RequiredField<PageQuestion, 'section'>\n | RequiredField<PageFileUpload, 'section'> {\n return hasNext(page) && typeof page.section === 'string'\n}\n\n/**\n * Check page has repeater\n */\nexport function hasRepeater(page?: Partial<Page>): page is PageRepeat {\n return controllerNameFromPath(page?.controller) === ControllerType.Repeat\n}\n\n/**\n * Check for known page controller names\n */\nexport function isControllerName(\n nameOrPath?: ControllerType | string\n): nameOrPath is ControllerType {\n return !!nameOrPath && ControllerNames.map(String).includes(nameOrPath)\n}\n\n/**\n * Check page has next link\n */\nexport function hasNext(\n page?: Partial<Page>\n): page is Extract<Page, { next: Link[] }> {\n if (!page || !('next' in page)) {\n return false\n }\n\n const controller = controllerNameFromPath(page.controller)\n\n return (\n !controller ||\n controller === ControllerType.Start ||\n controller === ControllerType.Page ||\n controller === ControllerType.FileUpload ||\n controller === ControllerType.Repeat\n )\n}\n\n/**\n * Check and optionally replace legacy path with controller name\n * @param {string} [nameOrPath] - Controller name or legacy controller path\n */\nexport function controllerNameFromPath(nameOrPath?: ControllerType | string) {\n if (isControllerName(nameOrPath)) {\n return nameOrPath\n }\n\n const options = ControllerTypes.find(({ path }) => path === nameOrPath)\n return options?.name\n}\n"],"mappings":"AAUA,SACEA,eAAe,EACfC,eAAe;AAEjB,SAASC,cAAc;AACvB,SAASC,SAAS;;AAElB;AACA;AACA;AACA,OAAO,SAASC,eAAeA,CAC7BC,IAAmC,EACnC;EACA,MAAMC,UAAU,GAAGD,IAAI,EAAEE,UAAU,IAAIL,cAAc,CAACM,IAAI;EAC1D,MAAMD,UAAU,GAAGE,sBAAsB,CAACH,UAAU,CAAC;EAErD,MAAMI,QAAQ,GAAGP,SAAS,CAACQ,IAAI,CAC5BC,QAAQ,IAAKA,QAAQ,CAACL,UAAU,KAAKA,UACxC,CAAC;EAED,IAAI,CAACG,QAAQ,EAAE;IACb,MAAM,IAAIG,KAAK,CA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nCd,UAAU,KAAKL,cAAc,CAACM,IAAI,IAClCD,UAAU,KAAKL,cAAc,CAAC4B,UAAU,IACxCvB,UAAU,KAAKL,cAAc,CAACuB,MAAM;AAExC;;AAEA;AACA;AACA;AACA;AACA,OAAO,SAAShB,sBAAsBA,CAACH,UAAoC,EAAE;EAC3E,IAAIoB,gBAAgB,CAACpB,UAAU,CAAC,EAAE;IAChC,OAAOA,UAAU;EACnB;EAEA,MAAMyB,OAAO,GAAG9B,eAAe,CAACU,IAAI,CAAC,CAAC;IAAEqB;EAAK,CAAC,KAAKA,IAAI,KAAK1B,UAAU,CAAC;EACvE,OAAOyB,OAAO,EAAEE,IAAI;AACtB","ignoreList":[]}
@@ -1,5 +1,5 @@
1
1
  export { ControllerNames, ControllerTypes } from "./controller-types.js";
2
2
  export { PageTypes } from "./page-types.js";
3
- export { controllerNameFromPath, getPageDefaults, hasComponents, hasFormComponents, hasNext, hasSection, isControllerName } from "./helpers.js";
3
+ export { controllerNameFromPath, getPageDefaults, hasComponents, hasFormComponents, hasNext, hasRepeater, hasSection, isControllerName } from "./helpers.js";
4
4
  export { ControllerPath, ControllerType } from "./enums.js";
5
5
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["ControllerNames","ControllerTypes","PageTypes","controllerNameFromPath","getPageDefaults","hasComponents","hasFormComponents","hasNext","hasSection","isControllerName","ControllerPath","ControllerType"],"sources":["../../../src/pages/index.ts"],"sourcesContent":["export {\n ControllerNames,\n ControllerTypes\n} from '~/src/pages/controller-types.js'\n\nexport { PageTypes } from '~/src/pages/page-types.js'\n\nexport {\n controllerNameFromPath,\n getPageDefaults,\n hasComponents,\n hasFormComponents,\n hasNext,\n hasSection,\n isControllerName\n} from '~/src/pages/helpers.js'\n\nexport { ControllerPath, ControllerType } from '~/src/pages/enums.js'\n"],"mappings":"AAAA,SACEA,eAAe,EACfC,eAAe;AAGjB,SAASC,SAAS;AAElB,SACEC,sBAAsB,EACtBC,eAAe,EACfC,aAAa,EACbC,iBAAiB,EACjBC,OAAO,EACPC,UAAU,EACVC,gBAAgB;AAGlB,SAASC,cAAc,EAAEC,cAAc","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["ControllerNames","ControllerTypes","PageTypes","controllerNameFromPath","getPageDefaults","hasComponents","hasFormComponents","hasNext","hasRepeater","hasSection","isControllerName","ControllerPath","ControllerType"],"sources":["../../../src/pages/index.ts"],"sourcesContent":["export {\n ControllerNames,\n ControllerTypes\n} from '~/src/pages/controller-types.js'\n\nexport { PageTypes } from '~/src/pages/page-types.js'\n\nexport {\n controllerNameFromPath,\n getPageDefaults,\n hasComponents,\n hasFormComponents,\n hasNext,\n hasRepeater,\n hasSection,\n isControllerName\n} from '~/src/pages/helpers.js'\n\nexport { ControllerPath, ControllerType } from '~/src/pages/enums.js'\n"],"mappings":"AAAA,SACEA,eAAe,EACfC,eAAe;AAGjB,SAASC,SAAS;AAElB,SACEC,sBAAsB,EACtBC,eAAe,EACfC,aAAa,EACbC,iBAAiB,EACjBC,OAAO,EACPC,WAAW,EACXC,UAAU,EACVC,gBAAgB;AAGlB,SAASC,cAAc,EAAEC,cAAc","ignoreList":[]}
@@ -17,6 +17,23 @@ export const PageTypes = Object.freeze([{
17
17
  section: undefined,
18
18
  next: [],
19
19
  components: []
20
+ }, {
21
+ title: 'Add another',
22
+ path: '/add-another-page',
23
+ controller: ControllerType.Repeat,
24
+ repeat: {
25
+ options: {
26
+ name: '',
27
+ title: ''
28
+ },
29
+ schema: {
30
+ min: 1,
31
+ max: 25
32
+ }
33
+ },
34
+ section: undefined,
35
+ next: [],
36
+ components: []
20
37
  }, {
21
38
  title: 'File upload page',
22
39
  path: '/file-upload-page',
@@ -1 +1 @@
1
- {"version":3,"file":"page-types.js","names":["ControllerPath","ControllerType","PageTypes","Object","freeze","title","path","Start","controller","section","undefined","next","components","Page","FileUpload","Summary","Status"],"sources":["../../../src/pages/page-types.ts"],"sourcesContent":["import { type Page } from '~/src/form/form-definition/types.js'\nimport { ControllerPath, ControllerType } from '~/src/pages/enums.js'\n\n/**\n * Defaults for creating new pages\n */\nexport const PageTypes: readonly Page[] = Object.freeze([\n {\n title: 'Start page',\n path: ControllerPath.Start,\n controller: ControllerType.Start,\n section: undefined,\n next: [],\n components: []\n },\n {\n title: 'Question page',\n path: '/question-page',\n controller: ControllerType.Page,\n section: undefined,\n next: [],\n components: []\n },\n {\n title: 'File upload page',\n path: '/file-upload-page',\n controller: ControllerType.FileUpload,\n section: undefined,\n next: [],\n components: []\n },\n {\n title: 'Summary page',\n path: ControllerPath.Summary,\n controller: ControllerType.Summary,\n section: undefined\n },\n {\n title: 'Status page',\n path: ControllerPath.Status,\n controller: ControllerType.Status,\n section: undefined\n }\n])\n"],"mappings":"AACA,SAASA,cAAc,EAAEC,cAAc;;AAEvC;AACA;AACA;AACA,OAAO,MAAMC,SAA0B,GAAGC,MAAM,CAACC,MAAM,CAAC,CACtD;EACEC,KAAK,EAAE,YAAY;EACnBC,IAAI,EAAEN,cAAc,CAACO,KAAK;EAC1BC,UAAU,EAAEP,cAAc,CAACM,KAAK;EAChCE,OAAO,EAAEC,SAAS;EAClBC,IAAI,EAAE,EAAE;EACRC,UAAU,EAAE;AACd,CAAC,EACD;EACEP,KAAK,EAAE,eAAe;EACtBC,IAAI,EAAE,gBAAgB;EACtBE,UAAU,EAAEP,cAAc,CAACY,IAAI;EAC/BJ,OAAO,EAAEC,SAAS;EAClBC,IAAI,EAAE,EAAE;EACRC,UAAU,EAAE;AACd,CAAC,EACD;EACEP,KAAK,EAAE,kBAAkB;EACzBC,IAAI,EAAE,mBAAmB;EACzBE,UAAU,EAAEP,cAAc,CAACa,UAAU;EACrCL,OAAO,EAAEC,SAAS;EAClBC,IAAI,EAAE,EAAE;EACRC,UAAU,EAAE;AACd,CAAC,EACD;EACEP,KAAK,EAAE,cAAc;EACrBC,IAAI,EAAEN,cAAc,CAACe,OAAO;EAC5BP,UAAU,EAAEP,cAAc,CAACc,OAAO;EAClCN,OAAO,EAAEC;AACX,CAAC,EACD;EACEL,KAAK,EAAE,aAAa;EACpBC,IAAI,EAAEN,cAAc,CAACgB,MAAM;EAC3BR,UAAU,EAAEP,cAAc,CAACe,MAAM;EACjCP,OAAO,EAAEC;AACX,CAAC,CACF,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"page-types.js","names":["ControllerPath","ControllerType","PageTypes","Object","freeze","title","path","Start","controller","section","undefined","next","components","Page","Repeat","repeat","options","name","schema","min","max","FileUpload","Summary","Status"],"sources":["../../../src/pages/page-types.ts"],"sourcesContent":["import { type Page } from '~/src/form/form-definition/types.js'\nimport { ControllerPath, ControllerType } from '~/src/pages/enums.js'\n\n/**\n * Defaults for creating new pages\n */\nexport const PageTypes: readonly Page[] = Object.freeze([\n {\n title: 'Start page',\n path: ControllerPath.Start,\n controller: ControllerType.Start,\n section: undefined,\n next: [],\n components: []\n },\n {\n title: 'Question page',\n path: '/question-page',\n controller: ControllerType.Page,\n section: undefined,\n next: [],\n components: []\n },\n {\n title: 'Add another',\n path: '/add-another-page',\n controller: ControllerType.Repeat,\n repeat: {\n options: { name: '', title: '' },\n schema: { min: 1, max: 25 }\n },\n section: undefined,\n next: [],\n components: []\n },\n {\n title: 'File upload page',\n path: '/file-upload-page',\n controller: ControllerType.FileUpload,\n section: undefined,\n next: [],\n components: []\n },\n {\n title: 'Summary page',\n path: ControllerPath.Summary,\n controller: ControllerType.Summary,\n section: undefined\n },\n {\n title: 'Status page',\n path: ControllerPath.Status,\n controller: ControllerType.Status,\n section: undefined\n }\n])\n"],"mappings":"AACA,SAASA,cAAc,EAAEC,cAAc;;AAEvC;AACA;AACA;AACA,OAAO,MAAMC,SAA0B,GAAGC,MAAM,CAACC,MAAM,CAAC,CACtD;EACEC,KAAK,EAAE,YAAY;EACnBC,IAAI,EAAEN,cAAc,CAACO,KAAK;EAC1BC,UAAU,EAAEP,cAAc,CAACM,KAAK;EAChCE,OAAO,EAAEC,SAAS;EAClBC,IAAI,EAAE,EAAE;EACRC,UAAU,EAAE;AACd,CAAC,EACD;EACEP,KAAK,EAAE,eAAe;EACtBC,IAAI,EAAE,gBAAgB;EACtBE,UAAU,EAAEP,cAAc,CAACY,IAAI;EAC/BJ,OAAO,EAAEC,SAAS;EAClBC,IAAI,EAAE,EAAE;EACRC,UAAU,EAAE;AACd,CAAC,EACD;EACEP,KAAK,EAAE,aAAa;EACpBC,IAAI,EAAE,mBAAmB;EACzBE,UAAU,EAAEP,cAAc,CAACa,MAAM;EACjCC,MAAM,EAAE;IACNC,OAAO,EAAE;MAAEC,IAAI,EAAE,EAAE;MAAEZ,KAAK,EAAE;IAAG,CAAC;IAChCa,MAAM,EAAE;MAAEC,GAAG,EAAE,CAAC;MAAEC,GAAG,EAAE;IAAG;EAC5B,CAAC;EACDX,OAAO,EAAEC,SAAS;EAClBC,IAAI,EAAE,EAAE;EACRC,UAAU,EAAE;AACd,CAAC,EACD;EACEP,KAAK,EAAE,kBAAkB;EACzBC,IAAI,EAAE,mBAAmB;EACzBE,UAAU,EAAEP,cAAc,CAACoB,UAAU;EACrCZ,OAAO,EAAEC,SAAS;EAClBC,IAAI,EAAE,EAAE;EACRC,UAAU,EAAE;AACd,CAAC,EACD;EACEP,KAAK,EAAE,cAAc;EACrBC,IAAI,EAAEN,cAAc,CAACsB,OAAO;EAC5Bd,UAAU,EAAEP,cAAc,CAACqB,OAAO;EAClCb,OAAO,EAAEC;AACX,CAAC,EACD;EACEL,KAAK,EAAE,aAAa;EACpBC,IAAI,EAAEN,cAAc,CAACuB,MAAM;EAC3Bf,UAAU,EAAEP,cAAc,CAACsB,MAAM;EACjCd,OAAO,EAAEC;AACX,CAAC,CACF,CAAC","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/form/form-definition/index.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,KAAK,CAAA;AAGrB,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAU7D,OAAO,EAEL,KAAK,cAAc,EAOpB,MAAM,qCAAqC,CAAA;AAqE5C,eAAO,MAAM,eAAe,gCAwBZ,CAAA;AA+EhB;;;GAGG;AACH,eAAO,MAAM,oBAAoB,kCAyB7B,CAAA;AAIJ,eAAO,MAAM,MAAM,kCAAuB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/form/form-definition/index.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,KAAK,CAAA;AAGrB,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAU7D,OAAO,EAEL,KAAK,cAAc,EAUpB,MAAM,qCAAqC,CAAA;AAqE5C,eAAO,MAAM,eAAe,gCAwBZ,CAAA;AAmGhB;;;GAGG;AACH,eAAO,MAAM,oBAAoB,kCAyB7B,CAAA;AAIJ,eAAO,MAAM,MAAM,kCAAuB,CAAA"}
@@ -10,6 +10,18 @@ export interface PageBase {
10
10
  title: string;
11
11
  path: string;
12
12
  }
13
+ export interface RepeatOptions {
14
+ name: string;
15
+ title: string;
16
+ }
17
+ export interface RepeatSchema {
18
+ min: number;
19
+ max: number;
20
+ }
21
+ export interface Repeat {
22
+ options: RepeatOptions;
23
+ schema: RepeatSchema;
24
+ }
13
25
  export interface PageStart extends PageBase {
14
26
  path: ControllerPath.Start | string;
15
27
  controller: ControllerType.Start | ControllerType.Home;
@@ -23,6 +35,13 @@ export interface PageQuestion extends PageBase {
23
35
  next: Link[];
24
36
  components: ComponentDef[];
25
37
  }
38
+ export interface PageRepeat extends PageBase {
39
+ controller?: ControllerType.Repeat;
40
+ repeat: Repeat;
41
+ section?: string | undefined;
42
+ next: Link[];
43
+ components: ComponentDef[];
44
+ }
26
45
  export interface PageFileUpload extends PageBase {
27
46
  controller?: ControllerType.FileUpload;
28
47
  section?: string | undefined;
@@ -39,7 +58,7 @@ export interface PageStatus extends PageBase {
39
58
  controller: ControllerType.Status;
40
59
  section?: undefined;
41
60
  }
42
- export type Page = PageStart | PageQuestion | PageFileUpload | PageSummary | PageStatus;
61
+ export type Page = PageStart | PageQuestion | PageFileUpload | PageRepeat | PageSummary | PageStatus;
43
62
  export type RequiredField<Type extends Partial<object>, KeyType extends keyof Type> = Omit<Type, KeyType> & Required<{
44
63
  [Key in KeyType]: Type[Key];
45
64
  }>;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/form/form-definition/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAC7D,OAAO,EAAE,KAAK,mBAAmB,EAAE,MAAM,2BAA2B,CAAA;AAEpE,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAE/E,MAAM,WAAW,IAAI;IACnB,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAED,MAAM,WAAW,QAAQ;IACvB,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;CACb;AAED,MAAM,WAAW,SAAU,SAAQ,QAAQ;IACzC,IAAI,EAAE,cAAc,CAAC,KAAK,GAAG,MAAM,CAAA;IACnC,UAAU,EAAE,cAAc,CAAC,KAAK,GAAG,cAAc,CAAC,IAAI,CAAA;IACtD,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC5B,IAAI,EAAE,IAAI,EAAE,CAAA;IACZ,UAAU,EAAE,YAAY,EAAE,CAAA;CAC3B;AAED,MAAM,WAAW,YAAa,SAAQ,QAAQ;IAC5C,UAAU,CAAC,EAAE,cAAc,CAAC,IAAI,CAAA;IAChC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC5B,IAAI,EAAE,IAAI,EAAE,CAAA;IACZ,UAAU,EAAE,YAAY,EAAE,CAAA;CAC3B;AAED,MAAM,W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AA;IACnB,WAAW,CAAC,EAAE,WAAW,CAAA;IACzB,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAClC,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB"}
@@ -1 +1 @@
1
- {"version":3,"file":"controller-types.d.ts","sourceRoot":"","sources":["../../../src/pages/controller-types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAErD,eAAO,MAAM,eAAe;;;GAyB3B,CAAA;AAED,eAAO,MAAM,eAAe,kBAA0C,CAAA"}
1
+ {"version":3,"file":"controller-types.d.ts","sourceRoot":"","sources":["../../../src/pages/controller-types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAErD,eAAO,MAAM,eAAe;;;GA6B3B,CAAA;AAED,eAAO,MAAM,eAAe,kBAA0C,CAAA"}
@@ -7,6 +7,7 @@ export declare enum ControllerType {
7
7
  Start = "StartPageController",
8
8
  Home = "HomePageController",
9
9
  Page = "PageController",
10
+ Repeat = "RepeatPageController",
10
11
  FileUpload = "FileUploadPageController",
11
12
  Summary = "SummaryPageController",
12
13
  Status = "StatusPageController"
@@ -1 +1 @@
1
- {"version":3,"file":"enums.d.ts","sourceRoot":"","sources":["../../../src/pages/enums.ts"],"names":[],"mappings":"AAAA,oBAAY,cAAc;IACxB,KAAK,WAAW;IAChB,OAAO,aAAa;IACpB,MAAM,YAAY;CACnB;AAED,oBAAY,cAAc;IACxB,KAAK,wBAAwB;IAC7B,IAAI,uBAAuB;IAC3B,IAAI,mBAAmB;IACvB,UAAU,6BAA6B;IACvC,OAAO,0BAA0B;IACjC,MAAM,yBAAyB;CAChC"}
1
+ {"version":3,"file":"enums.d.ts","sourceRoot":"","sources":["../../../src/pages/enums.ts"],"names":[],"mappings":"AAAA,oBAAY,cAAc;IACxB,KAAK,WAAW;IAChB,OAAO,aAAa;IACpB,MAAM,YAAY;CACnB;AAED,oBAAY,cAAc;IACxB,KAAK,wBAAwB;IAC7B,IAAI,uBAAuB;IAC3B,IAAI,mBAAmB;IACvB,MAAM,yBAAyB;IAC/B,UAAU,6BAA6B;IACvC,OAAO,0BAA0B;IACjC,MAAM,yBAAyB;CAChC"}
@@ -1,5 +1,5 @@
1
1
  import { type ComponentDef } from '../components/types.js';
2
- import { type Link, type Page, type PageFileUpload, type PageQuestion, type PageStart, type RequiredField } from '../form/form-definition/types.js';
2
+ import { type Link, type Page, type PageFileUpload, type PageQuestion, type PageRepeat, type PageStart, type RequiredField } from '../form/form-definition/types.js';
3
3
  import { ControllerType } from '../pages/enums.js';
4
4
  /**
5
5
  * Return component defaults by type
@@ -19,6 +19,10 @@ export declare function hasFormComponents(page?: Partial<Page>): page is PageQue
19
19
  * Check page has sections
20
20
  */
21
21
  export declare function hasSection(page?: Partial<Page>): page is RequiredField<PageStart, 'section'> | RequiredField<PageQuestion, 'section'> | RequiredField<PageFileUpload, 'section'>;
22
+ /**
23
+ * Check page has repeater
24
+ */
25
+ export declare function hasRepeater(page?: Partial<Page>): page is PageRepeat;
22
26
  /**
23
27
  * Check for known page controller names
24
28
  */
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/pages/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAC7D,OAAO,EACL,KAAK,IAAI,EACT,KAAK,IAAI,EACT,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,KAAK,aAAa,EACnB,MAAM,qCAAqC,CAAA;AAK5C,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAGrD;;GAEG;AACH,wBAAgB,eAAe,CAAC,QAAQ,SAAS,IAAI,EACnD,IAAI,CAAC,EAAE,IAAI,CAAC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1
  export { ControllerNames, ControllerTypes } from '../pages/controller-types.js';
2
2
  export { PageTypes } from '../pages/page-types.js';
3
- export { controllerNameFromPath, getPageDefaults, hasComponents, hasFormComponents, hasNext, hasSection, isControllerName } from '../pages/helpers.js';
3
+ export { controllerNameFromPath, getPageDefaults, hasComponents, hasFormComponents, hasNext, hasRepeater, hasSection, isControllerName } from '../pages/helpers.js';
4
4
  export { ControllerPath, ControllerType } from '../pages/enums.js';
5
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/pages/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,eAAe,EAChB,MAAM,iCAAiC,CAAA;AAExC,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AAErD,OAAO,EACL,sBAAsB,EACtB,eAAe,EACf,aAAa,EACb,iBAAiB,EACjB,OAAO,EACP,UAAU,EACV,gBAAgB,EACjB,MAAM,wBAAwB,CAAA;AAE/B,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/pages/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,eAAe,EAChB,MAAM,iCAAiC,CAAA;AAExC,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AAErD,OAAO,EACL,sBAAsB,EACtB,eAAe,EACf,aAAa,EACb,iBAAiB,EACjB,OAAO,EACP,WAAW,EACX,UAAU,EACV,gBAAgB,EACjB,MAAM,wBAAwB,CAAA;AAE/B,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"page-types.d.ts","sourceRoot":"","sources":["../../../src/pages/page-types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,qCAAqC,CAAA;AAG/D;;GAEG;AACH,eAAO,MAAM,SAAS,EAAE,SAAS,IAAI,EAqCnC,CAAA"}
1
+ {"version":3,"file":"page-types.d.ts","sourceRoot":"","sources":["../../../src/pages/page-types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,qCAAqC,CAAA;AAG/D;;GAEG;AACH,eAAO,MAAM,SAAS,EAAE,SAAS,IAAI,EAiDnC,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defra/forms-model",
3
- "version": "3.0.376",
3
+ "version": "3.0.377",
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
  "repository": {
@@ -19,6 +19,9 @@ import {
19
19
  type List,
20
20
  type Page,
21
21
  type PhaseBanner,
22
+ type Repeat,
23
+ type RepeatOptions,
24
+ type RepeatSchema,
22
25
  type Section
23
26
  } from '~/src/form/form-definition/types.js'
24
27
 
@@ -121,6 +124,21 @@ const nextSchema = Joi.object<Link>().keys({
121
124
  redirect: Joi.string().optional()
122
125
  })
123
126
 
127
+ const repeatOptions = Joi.object<RepeatOptions>().keys({
128
+ name: Joi.string().required(),
129
+ title: Joi.string().required()
130
+ })
131
+
132
+ const repeatSchema = Joi.object<RepeatSchema>().keys({
133
+ min: Joi.number().empty('').required(),
134
+ max: Joi.number().empty('').required()
135
+ })
136
+
137
+ const pageRepeatSchema = Joi.object<Repeat>().keys({
138
+ options: repeatOptions.required(),
139
+ schema: repeatSchema.required()
140
+ })
141
+
124
142
  /**
125
143
  * `/status` is a special route for providing a user's application status.
126
144
  * It should not be configured via the designer.
@@ -131,6 +149,11 @@ const pageSchema = Joi.object<Page>().keys({
131
149
  section: Joi.string(),
132
150
  controller: Joi.string().optional(),
133
151
  components: Joi.array<ComponentDef>().items(componentSchema).unique('name'),
152
+ repeat: Joi.when('controller', {
153
+ is: Joi.string().valid('RepeatPageController').required(),
154
+ then: pageRepeatSchema.required(),
155
+ otherwise: Joi.any().strip()
156
+ }),
134
157
  next: Joi.array<Link>().items(nextSchema)
135
158
  })
136
159
 
@@ -14,6 +14,21 @@ export interface PageBase {
14
14
  path: string
15
15
  }
16
16
 
17
+ export interface RepeatOptions {
18
+ name: string
19
+ title: string
20
+ }
21
+
22
+ export interface RepeatSchema {
23
+ min: number
24
+ max: number
25
+ }
26
+
27
+ export interface Repeat {
28
+ options: RepeatOptions
29
+ schema: RepeatSchema
30
+ }
31
+
17
32
  export interface PageStart extends PageBase {
18
33
  path: ControllerPath.Start | string
19
34
  controller: ControllerType.Start | ControllerType.Home
@@ -29,6 +44,14 @@ export interface PageQuestion extends PageBase {
29
44
  components: ComponentDef[]
30
45
  }
31
46
 
47
+ export interface PageRepeat extends PageBase {
48
+ controller?: ControllerType.Repeat
49
+ repeat: Repeat
50
+ section?: string | undefined
51
+ next: Link[]
52
+ components: ComponentDef[]
53
+ }
54
+
32
55
  export interface PageFileUpload extends PageBase {
33
56
  controller?: ControllerType.FileUpload
34
57
  section?: string | undefined
@@ -52,6 +75,7 @@ export type Page =
52
75
  | PageStart
53
76
  | PageQuestion
54
77
  | PageFileUpload
78
+ | PageRepeat
55
79
  | PageSummary
56
80
  | PageStatus
57
81
 
@@ -13,6 +13,10 @@ export const ControllerTypes = [
13
13
  name: ControllerType.Page,
14
14
  path: './pages/page.js'
15
15
  },
16
+ {
17
+ name: ControllerType.Repeat,
18
+ path: './pages/repeat.js'
19
+ },
16
20
  {
17
21
  name: ControllerType.FileUpload,
18
22
  path: './pages/file-upload.js'
@@ -8,6 +8,7 @@ export enum ControllerType {
8
8
  Start = 'StartPageController',
9
9
  Home = 'HomePageController',
10
10
  Page = 'PageController',
11
+ Repeat = 'RepeatPageController',
11
12
  FileUpload = 'FileUploadPageController',
12
13
  Summary = 'SummaryPageController',
13
14
  Status = 'StatusPageController'
@@ -4,6 +4,7 @@ import {
4
4
  type Page,
5
5
  type PageFileUpload,
6
6
  type PageQuestion,
7
+ type PageRepeat,
7
8
  type PageStart,
8
9
  type RequiredField
9
10
  } from '~/src/form/form-definition/types.js'
@@ -65,6 +66,13 @@ export function hasSection(
65
66
  return hasNext(page) && typeof page.section === 'string'
66
67
  }
67
68
 
69
+ /**
70
+ * Check page has repeater
71
+ */
72
+ export function hasRepeater(page?: Partial<Page>): page is PageRepeat {
73
+ return controllerNameFromPath(page?.controller) === ControllerType.Repeat
74
+ }
75
+
68
76
  /**
69
77
  * Check for known page controller names
70
78
  */
@@ -90,7 +98,8 @@ export function hasNext(
90
98
  !controller ||
91
99
  controller === ControllerType.Start ||
92
100
  controller === ControllerType.Page ||
93
- controller === ControllerType.FileUpload
101
+ controller === ControllerType.FileUpload ||
102
+ controller === ControllerType.Repeat
94
103
  )
95
104
  }
96
105
 
@@ -11,6 +11,7 @@ export {
11
11
  hasComponents,
12
12
  hasFormComponents,
13
13
  hasNext,
14
+ hasRepeater,
14
15
  hasSection,
15
16
  isControllerName
16
17
  } from '~/src/pages/helpers.js'
@@ -21,6 +21,18 @@ export const PageTypes: readonly Page[] = Object.freeze([
21
21
  next: [],
22
22
  components: []
23
23
  },
24
+ {
25
+ title: 'Add another',
26
+ path: '/add-another-page',
27
+ controller: ControllerType.Repeat,
28
+ repeat: {
29
+ options: { name: '', title: '' },
30
+ schema: { min: 1, max: 25 }
31
+ },
32
+ section: undefined,
33
+ next: [],
34
+ components: []
35
+ },
24
36
  {
25
37
  title: 'File upload page',
26
38
  path: '/file-upload-page',