@defra/forms-model 3.0.645 → 3.0.647

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 (30) hide show
  1. package/dist/module/components/component-types.js +2 -1
  2. package/dist/module/components/component-types.js.map +1 -1
  3. package/dist/module/components/types.js.map +1 -1
  4. package/dist/module/form/form-definition/index.js +13 -2
  5. package/dist/module/form/form-definition/index.js.map +1 -1
  6. package/dist/module/form/form-editor/index.js +7 -1
  7. package/dist/module/form/form-editor/index.js.map +1 -1
  8. package/dist/module/form/form-editor/types.js.map +1 -1
  9. package/dist/types/components/component-types.d.ts.map +1 -1
  10. package/dist/types/components/types.d.ts +10 -0
  11. package/dist/types/components/types.d.ts.map +1 -1
  12. package/dist/types/form/form-definition/index.d.ts.map +1 -1
  13. package/dist/types/form/form-editor/index.d.ts +6 -0
  14. package/dist/types/form/form-editor/index.d.ts.map +1 -1
  15. package/dist/types/form/form-editor/types.d.ts +13 -1
  16. package/dist/types/form/form-editor/types.d.ts.map +1 -1
  17. package/package.json +1 -1
  18. package/schemas/component-schema-v2.json +35 -2
  19. package/schemas/component-schema.json +35 -2
  20. package/schemas/form-definition-schema.json +105 -6
  21. package/schemas/form-definition-v2-schema.json +175 -10
  22. package/schemas/list-schema-v2.json +70 -4
  23. package/schemas/list-schema.json +70 -4
  24. package/schemas/page-schema-v2.json +105 -6
  25. package/schemas/page-schema.json +35 -2
  26. package/src/components/component-types.ts +2 -1
  27. package/src/components/types.ts +10 -0
  28. package/src/form/form-definition/index.ts +31 -3
  29. package/src/form/form-editor/index.ts +22 -1
  30. package/src/form/form-editor/types.ts +18 -0
@@ -297,8 +297,8 @@
297
297
  },
298
298
  "amount": {
299
299
  "type": "number",
300
- "description": "Payment amount in GBP (£0.30 - £100,000)",
301
- "minimum": 0.3,
300
+ "description": "Payment amount in GBP (£0 - £100,000)",
301
+ "minimum": 0,
302
302
  "maximum": 100000,
303
303
  "title": "Amount"
304
304
  },
@@ -307,6 +307,39 @@
307
307
  "description": "Payment description (max 230 chars)",
308
308
  "maxLength": 230,
309
309
  "title": "Description"
310
+ },
311
+ "conditionalAmounts": {
312
+ "type": "array",
313
+ "description": "Conditional payment amounts evaluated in order",
314
+ "items": {
315
+ "type": "object",
316
+ "properties": {
317
+ "condition": {
318
+ "type": "string",
319
+ "description": "Condition ID for this amount",
320
+ "title": "Condition"
321
+ },
322
+ "amount": {
323
+ "type": "number",
324
+ "description": "Amount in GBP when condition is true (min £0.30)",
325
+ "minimum": 0.3,
326
+ "maximum": 100000,
327
+ "title": "Amount"
328
+ }
329
+ },
330
+ "required": [
331
+ "condition",
332
+ "amount"
333
+ ],
334
+ "additionalProperties": false,
335
+ "title": "Conditional Amounts Item"
336
+ },
337
+ "title": "Conditional Amounts"
338
+ },
339
+ "emailField": {
340
+ "type": "string",
341
+ "description": "Name of EmailAddressField to prepopulate GOV.UK Pay email",
342
+ "title": "Email Field"
310
343
  }
311
344
  },
312
345
  "additionalProperties": true,
@@ -506,8 +539,8 @@
506
539
  },
507
540
  "amount": {
508
541
  "type": "number",
509
- "description": "Payment amount in GBP (£0.30 - £100,000)",
510
- "minimum": 0.3,
542
+ "description": "Payment amount in GBP (£0 - £100,000)",
543
+ "minimum": 0,
511
544
  "maximum": 100000,
512
545
  "title": "Amount"
513
546
  },
@@ -516,6 +549,39 @@
516
549
  "description": "Payment description (max 230 chars)",
517
550
  "maxLength": 230,
518
551
  "title": "Description"
552
+ },
553
+ "conditionalAmounts": {
554
+ "type": "array",
555
+ "description": "Conditional payment amounts evaluated in order",
556
+ "items": {
557
+ "type": "object",
558
+ "properties": {
559
+ "condition": {
560
+ "type": "string",
561
+ "description": "Condition ID for this amount",
562
+ "title": "Condition"
563
+ },
564
+ "amount": {
565
+ "type": "number",
566
+ "description": "Amount in GBP when condition is true (min £0.30)",
567
+ "minimum": 0.3,
568
+ "maximum": 100000,
569
+ "title": "Amount"
570
+ }
571
+ },
572
+ "required": [
573
+ "condition",
574
+ "amount"
575
+ ],
576
+ "additionalProperties": false,
577
+ "title": "Conditional Amounts Item"
578
+ },
579
+ "title": "Conditional Amounts"
580
+ },
581
+ "emailField": {
582
+ "type": "string",
583
+ "description": "Name of EmailAddressField to prepopulate GOV.UK Pay email",
584
+ "title": "Email Field"
519
585
  }
520
586
  },
521
587
  "additionalProperties": true,
@@ -798,8 +864,8 @@
798
864
  },
799
865
  "amount": {
800
866
  "type": "number",
801
- "description": "Payment amount in GBP (£0.30 - £100,000)",
802
- "minimum": 0.3,
867
+ "description": "Payment amount in GBP (£0 - £100,000)",
868
+ "minimum": 0,
803
869
  "maximum": 100000,
804
870
  "title": "Amount"
805
871
  },
@@ -808,6 +874,39 @@
808
874
  "description": "Payment description (max 230 chars)",
809
875
  "maxLength": 230,
810
876
  "title": "Description"
877
+ },
878
+ "conditionalAmounts": {
879
+ "type": "array",
880
+ "description": "Conditional payment amounts evaluated in order",
881
+ "items": {
882
+ "type": "object",
883
+ "properties": {
884
+ "condition": {
885
+ "type": "string",
886
+ "description": "Condition ID for this amount",
887
+ "title": "Condition"
888
+ },
889
+ "amount": {
890
+ "type": "number",
891
+ "description": "Amount in GBP when condition is true (min £0.30)",
892
+ "minimum": 0.3,
893
+ "maximum": 100000,
894
+ "title": "Amount"
895
+ }
896
+ },
897
+ "required": [
898
+ "condition",
899
+ "amount"
900
+ ],
901
+ "additionalProperties": false,
902
+ "title": "Conditional Amounts Item"
903
+ },
904
+ "title": "Conditional Amounts"
905
+ },
906
+ "emailField": {
907
+ "type": "string",
908
+ "description": "Name of EmailAddressField to prepopulate GOV.UK Pay email",
909
+ "title": "Email Field"
811
910
  }
812
911
  },
813
912
  "additionalProperties": true,
@@ -160,8 +160,8 @@
160
160
  },
161
161
  "amount": {
162
162
  "type": "number",
163
- "description": "Payment amount in GBP (£0.30 - £100,000)",
164
- "minimum": 0.3,
163
+ "description": "Payment amount in GBP (£0 - £100,000)",
164
+ "minimum": 0,
165
165
  "maximum": 100000,
166
166
  "title": "Amount"
167
167
  },
@@ -170,6 +170,39 @@
170
170
  "description": "Payment description (max 230 chars)",
171
171
  "maxLength": 230,
172
172
  "title": "Description"
173
+ },
174
+ "conditionalAmounts": {
175
+ "type": "array",
176
+ "description": "Conditional payment amounts evaluated in order",
177
+ "items": {
178
+ "type": "object",
179
+ "properties": {
180
+ "condition": {
181
+ "type": "string",
182
+ "description": "Condition ID for this amount",
183
+ "title": "Condition"
184
+ },
185
+ "amount": {
186
+ "type": "number",
187
+ "description": "Amount in GBP when condition is true (min £0.30)",
188
+ "minimum": 0.3,
189
+ "maximum": 100000,
190
+ "title": "Amount"
191
+ }
192
+ },
193
+ "required": [
194
+ "condition",
195
+ "amount"
196
+ ],
197
+ "additionalProperties": false,
198
+ "title": "Conditional Amounts Item"
199
+ },
200
+ "title": "Conditional Amounts"
201
+ },
202
+ "emailField": {
203
+ "type": "string",
204
+ "description": "Name of EmailAddressField to prepopulate GOV.UK Pay email",
205
+ "title": "Email Field"
173
206
  }
174
207
  },
175
208
  "additionalProperties": true,
@@ -198,7 +198,8 @@ export const ComponentTypes: readonly ComponentDef[] = Object.freeze([
198
198
  hint: '',
199
199
  options: {
200
200
  amount: 1,
201
- description: 'payment desc'
201
+ description: 'payment desc',
202
+ conditionalAmounts: []
202
203
  }
203
204
  } as PaymentFieldComponent,
204
205
  {
@@ -260,6 +260,11 @@ export interface PaymentFieldComponent extends FormFieldBase {
260
260
  options: FormFieldBase['options'] & {
261
261
  amount: number
262
262
  description: string
263
+ conditionalAmounts?: {
264
+ condition: string
265
+ amount: number
266
+ }[]
267
+ emailField?: string
263
268
  }
264
269
  }
265
270
 
@@ -325,6 +330,11 @@ export interface CheckboxesFieldComponent extends ListFieldBase {
325
330
  bold?: boolean
326
331
  condition?: string
327
332
  }
333
+ schema?: {
334
+ max?: number
335
+ min?: number
336
+ length?: number
337
+ }
328
338
  }
329
339
 
330
340
  export interface RadiosFieldComponent extends ListFieldBase {
@@ -580,10 +580,10 @@ export const componentSchema = Joi.object<ComponentDef>()
580
580
  amount: Joi.when('type', {
581
581
  is: Joi.string().trim().valid(ComponentType.PaymentField).required(),
582
582
  then: Joi.number()
583
- .min(0.3)
583
+ .min(0)
584
584
  .max(100000)
585
585
  .required()
586
- .description('Payment amount in GBP (£0.30 - £100,000)')
586
+ .description('Payment amount in GBP (£0 - £100,000)')
587
587
  }).description('Payment amount - for PaymentField only'),
588
588
  description: Joi.when('type', {
589
589
  is: Joi.string().trim().valid(ComponentType.PaymentField).required(),
@@ -591,7 +591,35 @@ export const componentSchema = Joi.object<ComponentDef>()
591
591
  .max(230)
592
592
  .required()
593
593
  .description('Payment description (max 230 chars)')
594
- }).description('Payment description - for PaymentField only')
594
+ }).description('Payment description - for PaymentField only'),
595
+ conditionalAmounts: Joi.when('type', {
596
+ is: Joi.string().trim().valid(ComponentType.PaymentField).required(),
597
+ then: Joi.array()
598
+ .items(
599
+ Joi.object({
600
+ condition: Joi.string()
601
+ .trim()
602
+ .required()
603
+ .description('Condition ID for this amount'),
604
+ amount: Joi.number()
605
+ .min(0.3)
606
+ .max(100000)
607
+ .required()
608
+ .description('Amount in GBP when condition is true (min £0.30)')
609
+ })
610
+ )
611
+ .optional()
612
+ .description('Conditional payment amounts evaluated in order')
613
+ }).description('Conditional amounts - for PaymentField only'),
614
+ emailField: Joi.when('type', {
615
+ is: Joi.string().trim().valid(ComponentType.PaymentField).required(),
616
+ then: Joi.string()
617
+ .trim()
618
+ .optional()
619
+ .description(
620
+ 'Name of EmailAddressField to prepopulate GOV.UK Pay email'
621
+ )
622
+ }).description('Email field reference - for PaymentField only')
595
623
  })
596
624
  .default({})
597
625
  .unknown(true)
@@ -429,6 +429,24 @@ export const paymentApiKeySchema = Joi.string()
429
429
  .trim()
430
430
  .description('API key for payment configuration')
431
431
 
432
+ export const exactChecksSchema = Joi.number()
433
+ .empty('')
434
+ .integer()
435
+ .min(2)
436
+ .description('Specifies the exact number of items required to be selected.')
437
+
438
+ export const minChecksSchema = Joi.number()
439
+ .empty('')
440
+ .integer()
441
+ .min(2)
442
+ .description('Minimum number of items required to be selected.')
443
+
444
+ export const maxChecksSchema = Joi.number()
445
+ .empty('')
446
+ .integer()
447
+ .min(2)
448
+ .description('Maximum number of items allowed to be selected.')
449
+
432
450
  type GenericRuleOptions<K extends string, T> = Omit<GetRuleOptions, 'args'> & {
433
451
  args: Record<K, T>
434
452
  }
@@ -617,7 +635,10 @@ export const questionDetailsFullSchema = {
617
635
  shortDescriptionSchema,
618
636
  suffixSchema,
619
637
  tabularDataTypesSchema,
620
- usePostcodeLookupSchema
638
+ usePostcodeLookupSchema,
639
+ minChecksSchema,
640
+ maxChecksSchema,
641
+ exactChecksSchema
621
642
  }
622
643
 
623
644
  export const formEditorInputPageKeys = {
@@ -270,6 +270,21 @@ export interface FormEditor {
270
270
  */
271
271
  listItemsData: string
272
272
 
273
+ /**
274
+ * The exact number of items to select
275
+ */
276
+ exactChecks: string
277
+
278
+ /**
279
+ * The minimum number of items to select
280
+ */
281
+ minChecks: string
282
+
283
+ /**
284
+ * The maximum number of items to select
285
+ */
286
+ maxChecks: string
287
+
273
288
  /**
274
289
  * An array of options for autocomplete
275
290
  */
@@ -402,6 +417,9 @@ export type FormEditorInputQuestion = Pick<
402
417
  | 'radioValue'
403
418
  | 'list'
404
419
  | 'listItemsData'
420
+ | 'exactChecks'
421
+ | 'minChecks'
422
+ | 'maxChecks'
405
423
  | 'jsEnabled'
406
424
  | 'usePostcodeLookup'
407
425
  | 'giveInstructions'