@defra/forms-model 3.0.687 → 3.0.689

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/dist/module/__stubs__/examples.js +185 -0
  2. package/dist/module/__stubs__/examples.js.map +1 -0
  3. package/dist/module/components/helpers.js +4 -0
  4. package/dist/module/components/helpers.js.map +1 -1
  5. package/dist/module/components/types.js.map +1 -1
  6. package/dist/module/form/form-editor/translations/translations-config.js +168 -0
  7. package/dist/module/form/form-editor/translations/translations-config.js.map +1 -0
  8. package/dist/module/form/form-editor/translations/translations-overview.js +93 -0
  9. package/dist/module/form/form-editor/translations/translations-overview.js.map +1 -0
  10. package/dist/module/form/form-editor/translations/translations.js +214 -0
  11. package/dist/module/form/form-editor/translations/translations.js.map +1 -0
  12. package/dist/module/form/form-submission/index.js +3 -0
  13. package/dist/module/form/form-submission/index.js.map +1 -1
  14. package/dist/module/form/form-submission/types.js.map +1 -1
  15. package/dist/module/form/utils/list.js +23 -0
  16. package/dist/module/form/utils/list.js.map +1 -1
  17. package/dist/module/form/utils/numbering.js +43 -0
  18. package/dist/module/form/utils/numbering.js.map +1 -0
  19. package/dist/module/index.js +2 -0
  20. package/dist/module/index.js.map +1 -1
  21. package/dist/types/__stubs__/examples.d.ts +9 -0
  22. package/dist/types/__stubs__/examples.d.ts.map +1 -0
  23. package/dist/types/components/helpers.d.ts +2 -1
  24. package/dist/types/components/helpers.d.ts.map +1 -1
  25. package/dist/types/components/types.d.ts +1 -0
  26. package/dist/types/components/types.d.ts.map +1 -1
  27. package/dist/types/form/form-editor/translations/translations-config.d.ts +95 -0
  28. package/dist/types/form/form-editor/translations/translations-config.d.ts.map +1 -0
  29. package/dist/types/form/form-editor/translations/translations-overview.d.ts +14 -0
  30. package/dist/types/form/form-editor/translations/translations-overview.d.ts.map +1 -0
  31. package/dist/types/form/form-editor/translations/translations.d.ts +16 -0
  32. package/dist/types/form/form-editor/translations/translations.d.ts.map +1 -0
  33. package/dist/types/form/form-submission/index.d.ts.map +1 -1
  34. package/dist/types/form/form-submission/types.d.ts +4 -0
  35. package/dist/types/form/form-submission/types.d.ts.map +1 -1
  36. package/dist/types/form/utils/list.d.ts +8 -1
  37. package/dist/types/form/utils/list.d.ts.map +1 -1
  38. package/dist/types/form/utils/numbering.d.ts +18 -0
  39. package/dist/types/form/utils/numbering.d.ts.map +1 -0
  40. package/dist/types/index.d.ts +2 -0
  41. package/dist/types/index.d.ts.map +1 -1
  42. package/package.json +1 -1
  43. package/schemas/form-submit-payload-schema.json +5 -0
  44. package/src/__stubs__/examples.js +231 -0
  45. package/src/components/helpers.ts +14 -0
  46. package/src/components/types.ts +7 -0
  47. package/src/form/form-editor/translations/translations-config.js +186 -0
  48. package/src/form/form-editor/translations/translations-overview.js +137 -0
  49. package/src/form/form-editor/translations/translations.js +297 -0
  50. package/src/form/form-submission/index.ts +7 -0
  51. package/src/form/form-submission/types.ts +5 -0
  52. package/src/form/utils/list.ts +34 -1
  53. package/src/form/utils/numbering.js +47 -0
  54. package/src/index.ts +2 -0
@@ -0,0 +1,95 @@
1
+ /**
2
+ * Lookup a translation from a list of translation records.
3
+ * @param {string} key - The translation key to look up.
4
+ * @param {Record<string, string> | undefined} translations - The translation values to search.
5
+ */
6
+ export function lookupTranslation(key: string, translations: Record<string, string> | undefined): string;
7
+ /**
8
+ * Resolve the underlying content for a translation row from an entity.
9
+ * Involves using the appropriate child properties if necessary.
10
+ * @param {string} keyType - The translation row type being resolved.
11
+ * @param {ComponentDef | Page | Item} entity - The entity that may contain the content to translate.
12
+ * @param {string} jsonSuffix - The property name to read from the entity.
13
+ */
14
+ export function drillDown(keyType: string, entity: ComponentDef | Page | Item, jsonSuffix: string): string;
15
+ export namespace TranslationRowTypes {
16
+ let PageHeading: string;
17
+ let PageGuidance: string;
18
+ let RepeatTitle: string;
19
+ let QuestionText: string;
20
+ let QuestionHint: string;
21
+ let ShortDescription: string;
22
+ let ErrorDescription: string;
23
+ let ListItemText: string;
24
+ let ListItemHint: string;
25
+ let InstructionText: string;
26
+ let DeclarationBody: string;
27
+ let PaymentDescription: string;
28
+ }
29
+ export const TEXTAREA_3_ROWS: "textarea3";
30
+ export const TEXTAREA_5_ROWS: "textarea5";
31
+ export const TEXTAREA_12_ROWS_WITH_MARKDOWN: "textarea12markdown";
32
+ export const LIST_ITEM_HINT: "listitemhint";
33
+ export const LIST_ITEM_WITH_HINT_FOLLOWING: "listoptionwithhintfollowing";
34
+ /** @type {Record<string, { jsonPrefix: string, jsonSuffix: string, displayName: string, getLabel: (pageNum: number, questionNum?: number, itemNum?: number) => string }>} */
35
+ export const keyConfig: Record<string, {
36
+ jsonPrefix: string;
37
+ jsonSuffix: string;
38
+ displayName: string;
39
+ getLabel: (pageNum: number, questionNum?: number, itemNum?: number) => string;
40
+ }>;
41
+ export const IGNORE_FIELDS: ComponentType[];
42
+ export type TranslationRow = {
43
+ /**
44
+ * - the key name
45
+ */
46
+ name: string;
47
+ /**
48
+ * - type of text
49
+ */
50
+ type?: string | undefined;
51
+ /**
52
+ * - English text
53
+ */
54
+ englishContent: string | undefined;
55
+ /**
56
+ * - Welsh text
57
+ */
58
+ welshContent: string | undefined;
59
+ /**
60
+ * - page number
61
+ */
62
+ pageNum?: number | undefined;
63
+ /**
64
+ * - question number
65
+ */
66
+ questionNum?: number | undefined;
67
+ /**
68
+ * - list item number
69
+ */
70
+ itemNum?: number | undefined;
71
+ /**
72
+ * - label for field
73
+ */
74
+ label?: string | undefined;
75
+ };
76
+ export type ErrorDetailsItem = {
77
+ text: string;
78
+ href?: string;
79
+ };
80
+ export type ErrorDetails = Record<string, ErrorDetailsItem>;
81
+ export type ValidationFailure<Schema extends unknown = any> = {
82
+ /**
83
+ * - Formatted errors for error summary
84
+ */
85
+ formErrors: ErrorDetails;
86
+ /**
87
+ * - Form POST payload from Hapi request
88
+ */
89
+ formValues: Schema;
90
+ };
91
+ import type { ComponentDef } from '../../../components/types.js';
92
+ import type { Page } from '../../../form/form-definition/types.js';
93
+ import type { Item } from '../../../form/form-definition/types.js';
94
+ import { ComponentType } from '../../../components/enums.js';
95
+ //# sourceMappingURL=translations-config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"translations-config.d.ts","sourceRoot":"","sources":["../../../../../src/form/form-editor/translations/translations-config.js"],"names":[],"mappings":"AAoIA;;;;GAIG;AACH,uCAHW,MAAM,gBACN,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,UAO5C;AAED;;;;;;GAMG;AACH,mCAJW,MAAM,UACN,YAAY,GAAG,IAAI,GAAG,IAAI,cAC1B,MAAM,UA+BhB;;;;;;;;;;;;;;;AA3ID,8BAA+B,WAAW,CAAA;AAC1C,8BAA+B,WAAW,CAAA;AAC1C,6CAA8C,oBAAoB,CAAA;AAClE,6BAA8B,cAAc,CAAA;AAC5C,4CAA6C,6BAA6B,CAAA;AAE1E,6KAA6K;AAC7K,wBADW,MAAM,CAAC,MAAM,EAAE;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,KAAK,MAAM,CAAA;CAAE,CAAC,CA4ExK;AAED,4CAKC;;;;;UA9Ha,MAAM;;;;;;;;oBAEN,MAAM,GAAG,SAAS;;;;kBAClB,MAAM,GAAG,SAAS;;;;;;;;;;;;;;;;;;+BAQnB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE;2BAC/B,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC;8BAItB,MAAM;;;;gBAEf,YAAY;;;;gBACZ,MAAM;;kCAgKa,2BAA2B;0BAC7B,qCAAqC;0BAArC,qCAAqC;8BAxLtC,2BAA2B"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Build all translation rows in the form overview section (metatdata values).
3
+ * @param {FormMetadata} metadata
4
+ * @param {FormDefinition} definition
5
+ * @param {Record<string, string>} translations
6
+ * @param {ValidationFailure<any>} [validation]
7
+ * @returns {TranslationRow[]}
8
+ */
9
+ export function buildOverviewSection(metadata: FormMetadata, definition: FormDefinition, translations: Record<string, string>, validation?: ValidationFailure<any>): TranslationRow[];
10
+ import type { FormMetadata } from '../../../form/form-metadata/types.js';
11
+ import type { FormDefinition } from '../../../form/form-definition/types.js';
12
+ import type { ValidationFailure } from '../../../form/form-editor/translations/translations-config.js';
13
+ import type { TranslationRow } from '../../../form/form-editor/translations/translations-config.js';
14
+ //# sourceMappingURL=translations-overview.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"translations-overview.d.ts","sourceRoot":"","sources":["../../../../../src/form/form-editor/translations/translations-overview.js"],"names":[],"mappings":"AAuBA;;;;;;;GAOG;AACH,+CANW,YAAY,cACZ,cAAc,gBACd,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,eACtB,kBAAkB,GAAG,CAAC,GACpB,cAAc,EAAE,CAqG5B;kCAGgC,mCAAmC;oCACjC,qCAAqC;uCACnB,4DAA4D;oCAA5D,4DAA4D"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Build the overview and form translation rows for a form definition.
3
+ * @param {FormMetadata} metadata - The form metadata used to build the overview section.
4
+ * @param {FormDefinition} definition - The form definition containing pages and components.
5
+ * @param {ValidationFailure<any>} [validation] - Optional validation context for posted form values.
6
+ * @returns {{ overviewRows: TranslationRow[], formRows: TranslationRow[] }} The generated overview and form translation rows.
7
+ */
8
+ export function buildTranslationDataRows(metadata: FormMetadata, definition: FormDefinition, validation?: ValidationFailure<any>): {
9
+ overviewRows: TranslationRow[];
10
+ formRows: TranslationRow[];
11
+ };
12
+ import type { FormMetadata } from '../../../form/form-metadata/types.js';
13
+ import type { FormDefinition } from '../../../form/form-definition/types.js';
14
+ import type { ValidationFailure } from '../../../form/form-editor/translations/translations-config.js';
15
+ import type { TranslationRow } from '../../../form/form-editor/translations/translations-config.js';
16
+ //# sourceMappingURL=translations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"translations.d.ts","sourceRoot":"","sources":["../../../../../src/form/form-editor/translations/translations.js"],"names":[],"mappings":"AA0OA;;;;;;GAMG;AACH,mDALW,YAAY,cACZ,cAAc,eACd,kBAAkB,GAAG,CAAC,GACpB;IAAE,YAAY,EAAE,cAAc,EAAE,CAAC;IAAC,QAAQ,EAAE,cAAc,EAAE,CAAA;CAAE,CAkD1E;kCAIgC,mCAAmC;oCACrB,qCAAqC;uCAC9B,4DAA4D;oCAA5D,4DAA4D"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/form/form-submission/index.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,KAAK,CAAA;AAUrB,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,sBAAsB,EAC3B,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,eAAe,EACrB,MAAM,qCAAqC,CAAA;AAE5C;;;GAGG;AACH,eAAO,MAAM,sBAAsB,gCAa0B,CAAA;AAE7D;;;GAGG;AACH,eAAO,MAAM,yBAAyB,mCAoByC,CAAA;AAE/E;;;GAGG;AACH,eAAO,MAAM,uBAAuB,iCAwB2C,CAAA;AAE/E,eAAO,MAAM,sBAAsB,0CAmBD,CAAA;AAElC,eAAO,MAAM,uBAAuB,sCA2BlC,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/form/form-submission/index.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,KAAK,CAAA;AAUrB,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,sBAAsB,EAC3B,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,eAAe,EACrB,MAAM,qCAAqC,CAAA;AAE5C;;;GAGG;AACH,eAAO,MAAM,sBAAsB,gCAa0B,CAAA;AAE7D;;;GAGG;AACH,eAAO,MAAM,yBAAyB,mCAoByC,CAAA;AAE/E;;;GAGG;AACH,eAAO,MAAM,uBAAuB,iCA+B2C,CAAA;AAE/E,eAAO,MAAM,sBAAsB,0CAmBD,CAAA;AAElC,eAAO,MAAM,uBAAuB,sCA2BlC,CAAA"}
@@ -53,6 +53,10 @@ export interface SubmitPayload {
53
53
  * The reference number of the user session
54
54
  */
55
55
  referenceNumber?: string;
56
+ /**
57
+ * The currently-selected language at the point of submission
58
+ */
59
+ language?: string;
56
60
  /**
57
61
  * The main form anwsers
58
62
  */
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/form/form-submission/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,uBAAuB,CAAA;AACvD,OAAO,EACL,KAAK,qBAAqB,EAC1B,KAAK,8BAA8B,EACnC,KAAK,mCAAmC,EACxC,KAAK,4BAA4B,EACjC,KAAK,0BAA0B,EAChC,MAAM,qCAAqC,CAAA;AAO5C;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;IAEZ;;OAEG;IACH,KAAK,EAAE,MAAM,CAAA;IAEb;;OAEG;IACH,KAAK,EAAE,MAAM,CAAA;CACd;AAED;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;IAEZ;;OAEG;IACH,KAAK,EAAE,MAAM,CAAA;IAEb;;OAEG;IACH,KAAK,EAAE,YAAY,EAAE,EAAE,CAAA;CACxB;AAED;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,YAAY,EAAE,MAAM,CAAA;IAEpB;;OAEG;IACH,SAAS,EAAE,MAAM,CAAA;IAEjB;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,CAAA;IAExB;;OAEG;IACH,IAAI,EAAE,YAAY,EAAE,CA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xB,IAAI,EAAE;QACJ,EAAE,EAAE,MAAM,CAAA;QACV,MAAM,EAAE,UAAU,CAAA;QAClB,SAAS,EAAE,OAAO,CAAA;QAClB,OAAO,EAAE,MAAM,CAAA;KAChB,CAAA;IACD,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE;QACR,QAAQ,EAAE,qBAAqB,CAAA;QAC/B,MAAM,EAAE,MAAM,CAAA;KACf,CAAA;IACD,KAAK,EAAE,MAAM,CAAA;IACb,uBAAuB,EAAE,MAAM,CAAA;IAC/B,SAAS,EAAE,IAAI,CAAA;CAChB;AAED,MAAM,MAAM,aAAa,GAAG,kBAAkB,CAAA;AAE9C,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,MAAM,CAAA;IACjB,eAAe,EAAE,IAAI,CAAA;CACtB;AAED,MAAM,WAAW,qBAAsB,SAAQ,gBAAgB;IAC7D,EAAE,EAAE,MAAM,CAAA;CACX;AAED,MAAM,MAAM,iBAAiB,GAAG,aAAa,GAAG,gBAAgB,CAAA;AAEhE,MAAM,MAAM,YAAY,GAAG,aAAa,GAAG,qBAAqB,CAAA"}
@@ -1,4 +1,4 @@
1
- import { type ListComponentsDef } from '../../components/types.js';
1
+ import { type ComponentDef, type ListComponentsDef } from '../../components/types.js';
2
2
  import { type FormDefinition, type List } from '../../form/form-definition/types.js';
3
3
  /**
4
4
  * Given a SelectionComponent finds the associated list
@@ -7,4 +7,11 @@ import { type FormDefinition, type List } from '../../form/form-definition/types
7
7
  * @returns {List}
8
8
  */
9
9
  export declare function findDefinitionListFromComponent(selectionComponent: ListComponentsDef, definition: FormDefinition): List;
10
+ /**
11
+ * Finds the list in the component, if it exists. Handles a Yes/No list which doesn't link to the list in the normal way
12
+ * @param { ComponentDef | undefined } component
13
+ * @param {FormDefinition} definition
14
+ * @returns { List | undefined }
15
+ */
16
+ export declare function getListFromComponent(component: ComponentDef | undefined, definition: FormDefinition): List | undefined;
10
17
  //# sourceMappingURL=list.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../../src/form/utils/list.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,2BAA2B,CAAA;AAClE,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,IAAI,EACV,MAAM,qCAAqC,CAAA;AAE5C;;;;;GAKG;AACH,wBAAgB,+BAA+B,CAC7C,kBAAkB,EAAE,iBAAiB,EACrC,UAAU,EAAE,cAAc,GACzB,IAAI,CASN"}
1
+ {"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../../src/form/utils/list.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,iBAAiB,EACvB,MAAM,2BAA2B,CAAA;AAElC,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,IAAI,EACV,MAAM,qCAAqC,CAAA;AAE5C;;;;;GAKG;AACH,wBAAgB,+BAA+B,CAC7C,kBAAkB,EAAE,iBAAiB,EACrC,UAAU,EAAE,cAAc,GACzB,IAAI,CASN;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,SAAS,EAAE,YAAY,GAAG,SAAS,EACnC,UAAU,EAAE,cAAc,oBAiB3B"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * @param {FormDefinition} definition
3
+ * @param {string} pageId
4
+ */
5
+ export function getPageNum(definition: FormDefinition, pageId: string): number;
6
+ /**
7
+ * @param {FormDefinition} definition
8
+ * @param {string} pageId
9
+ */
10
+ export function getQuestionsOnPage(definition: FormDefinition, pageId: string): import("../../index.js").ComponentDef[];
11
+ /**
12
+ * @param {FormDefinition} definition
13
+ * @param {string} pageId
14
+ * @param {string} questionId
15
+ */
16
+ export function getQuestionNum(definition: FormDefinition, pageId: string, questionId: string): number;
17
+ import type { FormDefinition } from '../../form/form-definition/types.js';
18
+ //# sourceMappingURL=numbering.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"numbering.d.ts","sourceRoot":"","sources":["../../../../src/form/utils/numbering.js"],"names":[],"mappings":"AAOA;;;GAGG;AACH,uCAHW,cAAc,UACd,MAAM,UAQhB;AAED;;;GAGG;AACH,+CAHW,cAAc,UACd,MAAM,2CAKhB;AAED;;;;GAIG;AACH,2CAJW,cAAc,UACd,MAAM,cACN,MAAM,UAWhB;oCAGkC,qCAAqC"}
@@ -19,6 +19,8 @@ export * from './form/utils/index.js';
19
19
  export * from './form/form-editor/enums.js';
20
20
  export * from './form/form-editor/index.js';
21
21
  export * from './form/form-editor/preview/index.js';
22
+ export * from './form/form-editor/translations/translations-config.js';
23
+ export * from './form/form-editor/translations/translations.js';
22
24
  export * from './form/form-manager/types.js';
23
25
  export * from './form/form-manager/errors.js';
24
26
  export * from './manage/dead-letter-queues.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAA;AACrC,cAAc,2BAA2B,CAAA;AACzC,cAAc,wBAAwB,CAAA;AACtC,cAAc,kCAAkC,CAAA;AAChD,cAAc,8BAA8B,CAAA;AAC5C,cAAc,+BAA+B,CAAA;AAC7C,cAAc,2BAA2B,CAAA;AACzC,cAAc,2BAA2B,CAAA;AACzC,cAAc,qCAAqC,CAAA;AACnD,cAAc,qCAAqC,CAAA;AACnD,cAAc,uCAAuC,CAAA;AACrD,cAAc,mCAAmC,CAAA;AACjD,cAAc,kCAAkC,CAAA;AAChD,cAAc,kCAAkC,CAAA;AAChD,cAAc,kCAAkC,CAAA;AAChD,cAAc,qCAAqC,CAAA;AACnD,cAAc,qCAAqC,CAAA;AACnD,cAAc,2BAA2B,CAAA;AACzC,cAAc,iCAAiC,CAAA;AAC/C,cAAc,iCAAiC,CAAA;AAC/C,cAAc,yCAAyC,CAAA;AACvD,cAAc,kCAAkC,CAAA;AAChD,cAAc,mCAAmC,CAAA;AACjD,cAAc,oCAAoC,CAAA;AAClD,cAAc,uBAAuB,CAAA;AACrC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Ac,4DAA4D,CAAA;AAC1E,cAAc,qDAAqD,CAAA;AACnE,cAAc,kCAAkC,CAAA;AAChD,cAAc,mCAAmC,CAAA;AACjD,cAAc,oCAAoC,CAAA;AAClD,cAAc,uBAAuB,CAAA;AACrC,cAAc,uBAAuB,CAAA;AACrC,cAAc,sBAAsB,CAAA;AACpC,cAAc,wBAAwB,CAAA;AACtC,cAAc,yBAAyB,CAAA;AACvC,cAAc,gCAAgC,CAAA;AAC9C,cAAc,gCAAgC,CAAA;AAC9C,cAAc,wCAAwC,CAAA;AAEtD,mBAAmB,uBAAuB,CAAA;AAC1C,mBAAmB,kCAAkC,CAAA;AACrD,mBAAmB,8BAA8B,CAAA;AACjD,mBAAmB,+BAA+B,CAAA;AAClD,mBAAmB,2BAA2B,CAAA;AAC9C,mBAAmB,2BAA2B,CAAA;AAC9C,mBAAmB,qCAAqC,CAAA;AACxD,mBAAmB,mCAAmC,CAAA;AACtD,mBAAmB,qCAAqC,CAAA;AACxD,mBAAmB,yCAAyC,CAAA;AAC5D,mBAAmB,iCAAiC,CAAA;AACpD,mBAAmB,wCAAwC,CAAA;AAC3D,mBAAmB,gCAAgC,CAAA;AACnD,mBAAmB,uBAAuB,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defra/forms-model",
3
- "version": "3.0.687",
3
+ "version": "3.0.689",
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",
@@ -17,6 +17,11 @@
17
17
  "description": "Reference number for the form submission",
18
18
  "title": "Reference Number"
19
19
  },
20
+ "language": {
21
+ "type": "string",
22
+ "description": "The currently-selected language at point of form submission",
23
+ "title": "Language"
24
+ },
20
25
  "main": {
21
26
  "type": "array",
22
27
  "description": "Main (non-repeating) field values from the form",
@@ -0,0 +1,231 @@
1
+ import {
2
+ buildDeclarationFieldComponent,
3
+ buildLatLongFieldComponent,
4
+ buildMarkdownComponent,
5
+ buildRadiosComponent,
6
+ buildTextFieldComponent
7
+ } from '~/src/__stubs__/components.js'
8
+ import { buildDefinition } from '~/src/__stubs__/form-definition.js'
9
+ import {
10
+ buildQuestionPage,
11
+ buildRepeaterPage,
12
+ buildSummaryPage
13
+ } from '~/src/__stubs__/pages.js'
14
+
15
+ export const formDefinitionWithSinglePage = buildDefinition({
16
+ pages: [
17
+ buildQuestionPage({
18
+ id: 'p1',
19
+ section: 'section',
20
+ components: [
21
+ buildTextFieldComponent({
22
+ id: 'c1',
23
+ name: 'textField',
24
+ title: 'This is your first field',
25
+ hint: 'Help text'
26
+ })
27
+ ],
28
+ next: [{ path: '/summary' }]
29
+ }),
30
+ buildSummaryPage({
31
+ id: 'c2'
32
+ })
33
+ ]
34
+ })
35
+
36
+ export const formDefinitionWithoutSummary = buildDefinition({
37
+ pages: [
38
+ buildQuestionPage({
39
+ id: 'p1',
40
+ section: 'section',
41
+ components: [
42
+ buildTextFieldComponent({
43
+ id: 'c1',
44
+ name: 'textField',
45
+ title: 'This is your first field',
46
+ hint: 'Help text'
47
+ })
48
+ ],
49
+ next: [{ path: '/summary' }]
50
+ })
51
+ ]
52
+ })
53
+
54
+ export const formDefinitionWithTwoQuestions = buildDefinition({
55
+ pages: [
56
+ buildQuestionPage({
57
+ id: 'p1',
58
+ section: 'section',
59
+ components: [
60
+ buildTextFieldComponent({
61
+ id: 'q1',
62
+ name: 'textField',
63
+ title: 'This is your first question',
64
+ hint: 'Help text'
65
+ }),
66
+ buildTextFieldComponent({
67
+ id: 'q2',
68
+ name: 'textField',
69
+ title: 'This is your second question',
70
+ hint: 'Help text'
71
+ })
72
+ ],
73
+ next: [{ path: '/summary' }]
74
+ }),
75
+ buildSummaryPage({
76
+ id: 'p2'
77
+ })
78
+ ]
79
+ })
80
+
81
+ export const formDefinitionWithTwoQuestionsAndGuidance = buildDefinition({
82
+ pages: [
83
+ buildQuestionPage({
84
+ id: 'p1',
85
+ section: 'section',
86
+ components: [
87
+ buildMarkdownComponent({ content: 'My markdown text' }),
88
+ buildTextFieldComponent({
89
+ id: 'q1',
90
+ name: 'textField',
91
+ title: 'This is the first textfield question',
92
+ hint: 'Help text'
93
+ }),
94
+ buildTextFieldComponent({
95
+ id: 'q2',
96
+ name: 'textField',
97
+ title: 'This is the second textfield question',
98
+ hint: 'Help text'
99
+ })
100
+ ],
101
+ next: [{ path: '/summary' }]
102
+ }),
103
+ buildSummaryPage({
104
+ id: 'p2'
105
+ })
106
+ ]
107
+ })
108
+
109
+ export const formDefinitionWithLocationAndDeclaration = buildDefinition({
110
+ pages: [
111
+ buildQuestionPage({
112
+ id: 'p1',
113
+ section: 'section',
114
+ components: [
115
+ buildLatLongFieldComponent({
116
+ id: 'q1',
117
+ name: 'latLongField',
118
+ title: 'This is the first lat long field question',
119
+ hint: 'Hint text',
120
+ options: {
121
+ instructionText: 'Some instruction text'
122
+ }
123
+ }),
124
+ buildDeclarationFieldComponent({
125
+ id: 'q2',
126
+ name: 'declarationField',
127
+ title: 'This is a declaration question',
128
+ hint: 'Declaration hint text',
129
+ content: 'This is the declaration that needs agreeing to',
130
+ shortDescription: 'Declaration short desc'
131
+ })
132
+ ],
133
+ next: [{ path: '/summary' }]
134
+ }),
135
+ buildSummaryPage({
136
+ id: 'p2'
137
+ })
138
+ ]
139
+ })
140
+
141
+ export const formDefinitionWithRepeater = buildDefinition({
142
+ pages: [
143
+ buildRepeaterPage({
144
+ id: 'p1',
145
+ section: 'section',
146
+ components: [
147
+ buildTextFieldComponent({
148
+ id: 'q1',
149
+ name: 'TextField',
150
+ title: 'This is the first text field field question',
151
+ hint: 'Hint text',
152
+ shortDescription: 'Short desc'
153
+ })
154
+ ],
155
+ next: [{ path: '/summary' }]
156
+ }),
157
+ buildSummaryPage({
158
+ id: 'p2'
159
+ })
160
+ ]
161
+ })
162
+
163
+ export const formDefinitionWithNoQuestions = buildDefinition({
164
+ pages: [
165
+ buildQuestionPage({
166
+ id: 'p1',
167
+ section: 'section',
168
+ components: [],
169
+ next: [{ path: '/summary' }]
170
+ }),
171
+ buildSummaryPage({
172
+ id: 'p2'
173
+ })
174
+ ]
175
+ })
176
+
177
+ export const formDefinitionWithRadioQuestion = buildDefinition({
178
+ pages: [
179
+ buildQuestionPage({
180
+ id: 'p1',
181
+ section: 'section',
182
+ components: [
183
+ buildRadiosComponent({
184
+ id: 'q1',
185
+ name: 'radioField',
186
+ title: 'This is a radio question',
187
+ hint: 'Help text',
188
+ list: 'my-list-id'
189
+ })
190
+ ],
191
+ next: [{ path: '/summary' }]
192
+ }),
193
+ buildSummaryPage({
194
+ id: 'p2'
195
+ })
196
+ ],
197
+ lists: [
198
+ {
199
+ name: 'my-list',
200
+ id: 'my-list-id',
201
+ type: 'string',
202
+ title: 'list for radio',
203
+ items: [
204
+ {
205
+ id: 'option-1',
206
+ text: 'Option 1',
207
+ hint: {
208
+ text: 'Option 1 hint'
209
+ },
210
+ value: 'Option1'
211
+ },
212
+ {
213
+ id: 'option-2',
214
+ text: 'Option 2',
215
+ hint: {
216
+ text: 'Option 2 hint'
217
+ },
218
+ value: 'Option2'
219
+ },
220
+ {
221
+ id: 'option-3',
222
+ text: 'Option 3',
223
+ hint: {
224
+ text: 'Option 3 hint'
225
+ },
226
+ value: 'Option3'
227
+ }
228
+ ]
229
+ }
230
+ ]
231
+ })
@@ -2,6 +2,7 @@ import { ComponentTypes } from '~/src/components/component-types.js'
2
2
  import { ComponentType } from '~/src/components/enums.js'
3
3
  import {
4
4
  type ComponentDef,
5
+ type ComponentsDefWithInstructions,
5
6
  type ConditionalComponentType,
6
7
  type ConditionalComponentsDef,
7
8
  type ContentComponentsDef,
@@ -145,6 +146,19 @@ export function isListType(
145
146
  return !!type && allowedTypes.includes(type)
146
147
  }
147
148
 
149
+ export function isTypeWithInstructions(
150
+ type?: ComponentType
151
+ ): type is ComponentsDefWithInstructions['type'] {
152
+ const allowedTypes = [
153
+ ComponentType.EastingNorthingField,
154
+ ComponentType.OsGridRefField,
155
+ ComponentType.NationalGridFieldNumberField,
156
+ ComponentType.LatLongField
157
+ ]
158
+
159
+ return !!type && allowedTypes.includes(type)
160
+ }
161
+
148
162
  /**
149
163
  * Filter known form components with input fields
150
164
  * (excludes content and selection fields)
@@ -443,6 +443,13 @@ export type SelectionComponentsDef =
443
443
  | SelectFieldComponent
444
444
  | YesNoFieldComponent
445
445
 
446
+ // Components that have instruction fields
447
+ export type ComponentsDefWithInstructions =
448
+ | EastingNorthingFieldComponent
449
+ | OsGridRefFieldComponent
450
+ | NationalGridFieldNumberFieldComponent
451
+ | LatLongFieldComponent
452
+
446
453
  // Components that have condition support
447
454
  export type ConditionalComponentsDef = Exclude<
448
455
  ComponentDef,