@defra/forms-engine-plugin 4.0.5 → 4.0.7
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.
- package/.public/stylesheets/application.min.css +2 -2
- package/.public/stylesheets/application.min.css.map +1 -1
- package/.server/client/stylesheets/_location-input.scss +60 -0
- package/.server/client/stylesheets/application.scss +1 -6
- package/.server/client/stylesheets/shared.scss +8 -0
- package/.server/server/forms/register-as-a-unicorn-breeder.yaml +28 -0
- package/.server/server/plugins/engine/components/ComponentBase.d.ts +1 -1
- package/.server/server/plugins/engine/components/ComponentBase.js.map +1 -1
- package/.server/server/plugins/engine/components/EastingNorthingField.d.ts +121 -0
- package/.server/server/plugins/engine/components/EastingNorthingField.js +166 -0
- package/.server/server/plugins/engine/components/EastingNorthingField.js.map +1 -0
- package/.server/server/plugins/engine/components/LatLongField.d.ts +121 -0
- package/.server/server/plugins/engine/components/LatLongField.js +164 -0
- package/.server/server/plugins/engine/components/LatLongField.js.map +1 -0
- package/.server/server/plugins/engine/components/LocationFieldBase.d.ts +134 -0
- package/.server/server/plugins/engine/components/LocationFieldBase.js +85 -0
- package/.server/server/plugins/engine/components/LocationFieldBase.js.map +1 -0
- package/.server/server/plugins/engine/components/LocationFieldHelpers.d.ts +108 -0
- package/.server/server/plugins/engine/components/LocationFieldHelpers.js +96 -0
- package/.server/server/plugins/engine/components/LocationFieldHelpers.js.map +1 -0
- package/.server/server/plugins/engine/components/NationalGridFieldNumberField.d.ts +19 -0
- package/.server/server/plugins/engine/components/NationalGridFieldNumberField.js +40 -0
- package/.server/server/plugins/engine/components/NationalGridFieldNumberField.js.map +1 -0
- package/.server/server/plugins/engine/components/OsGridRefField.d.ts +19 -0
- package/.server/server/plugins/engine/components/OsGridRefField.js +56 -0
- package/.server/server/plugins/engine/components/OsGridRefField.js.map +1 -0
- package/.server/server/plugins/engine/components/helpers/components.d.ts +3 -4
- package/.server/server/plugins/engine/components/helpers/components.js +21 -29
- package/.server/server/plugins/engine/components/helpers/components.js.map +1 -1
- package/.server/server/plugins/engine/components/index.d.ts +4 -0
- package/.server/server/plugins/engine/components/index.js +4 -0
- package/.server/server/plugins/engine/components/index.js.map +1 -1
- package/.server/server/plugins/engine/components/markdownParser.d.ts +2 -0
- package/.server/server/plugins/engine/components/markdownParser.js +28 -0
- package/.server/server/plugins/engine/components/markdownParser.js.map +1 -0
- package/.server/server/plugins/engine/components/types.d.ts +10 -0
- package/.server/server/plugins/engine/components/types.js.map +1 -1
- package/.server/server/plugins/engine/pageControllers/helpers/pages.js +7 -0
- package/.server/server/plugins/engine/pageControllers/helpers/pages.js.map +1 -1
- package/.server/server/plugins/engine/types/index.d.ts +1 -1
- package/.server/server/plugins/engine/types/index.js.map +1 -1
- package/.server/server/plugins/engine/types.d.ts +2 -2
- package/.server/server/plugins/engine/types.js.map +1 -1
- package/.server/server/plugins/engine/views/components/_location-field-base.html +53 -0
- package/.server/server/plugins/engine/views/components/eastingnorthingfield.html +5 -0
- package/.server/server/plugins/engine/views/components/latlongfield.html +5 -0
- package/.server/server/plugins/engine/views/components/nationalgridfieldnumberfield.html +13 -0
- package/.server/server/plugins/engine/views/components/osgridreffield.html +13 -0
- package/.server/server/plugins/nunjucks/filters/field.d.ts +1 -1
- package/package.json +3 -3
- package/src/client/stylesheets/_location-input.scss +60 -0
- package/src/client/stylesheets/application.scss +1 -6
- package/src/client/stylesheets/shared.scss +8 -0
- package/src/server/forms/register-as-a-unicorn-breeder.yaml +28 -0
- package/src/server/plugins/engine/components/ComponentBase.ts +1 -1
- package/src/server/plugins/engine/components/EastingNorthingField.test.ts +665 -0
- package/src/server/plugins/engine/components/EastingNorthingField.ts +224 -0
- package/src/server/plugins/engine/components/LatLongField.test.ts +700 -0
- package/src/server/plugins/engine/components/LatLongField.ts +213 -0
- package/src/server/plugins/engine/components/LocationFieldBase.test.ts +253 -0
- package/src/server/plugins/engine/components/LocationFieldBase.ts +152 -0
- package/src/server/plugins/engine/components/LocationFieldHelpers.test.ts +338 -0
- package/src/server/plugins/engine/components/LocationFieldHelpers.ts +123 -0
- package/src/server/plugins/engine/components/NationalGridFieldNumberField.test.ts +438 -0
- package/src/server/plugins/engine/components/NationalGridFieldNumberField.ts +52 -0
- package/src/server/plugins/engine/components/OsGridRefField.test.ts +469 -0
- package/src/server/plugins/engine/components/OsGridRefField.ts +71 -0
- package/src/server/plugins/engine/components/helpers/components.test.ts +270 -0
- package/src/server/plugins/engine/components/helpers/components.ts +39 -47
- package/src/server/plugins/engine/components/helpers/helpers.test.ts +71 -1
- package/src/server/plugins/engine/components/index.ts +4 -0
- package/src/server/plugins/engine/components/markdownParser.ts +40 -0
- package/src/server/plugins/engine/components/types.ts +14 -0
- package/src/server/plugins/engine/outputFormatters/adapter/v1.location.test.ts +356 -0
- package/src/server/plugins/engine/pageControllers/helpers/helpers.test.ts +4 -0
- package/src/server/plugins/engine/pageControllers/helpers/pages.ts +8 -0
- package/src/server/plugins/engine/types/index.ts +2 -0
- package/src/server/plugins/engine/types.ts +4 -0
- package/src/server/plugins/engine/views/components/_location-field-base.html +53 -0
- package/src/server/plugins/engine/views/components/eastingnorthingfield.html +5 -0
- package/src/server/plugins/engine/views/components/latlongfield.html +5 -0
- package/src/server/plugins/engine/views/components/nationalgridfieldnumberfield.html +13 -0
- package/src/server/plugins/engine/views/components/osgridreffield.html +13 -0
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
@use "govuk-frontend" as *;
|
|
2
|
+
|
|
3
|
+
.app-location-input {
|
|
4
|
+
@include govuk-clearfix;
|
|
5
|
+
font-size: 0; // removes whitespace caused by inline-block
|
|
6
|
+
margin-bottom: govuk-spacing(6);
|
|
7
|
+
|
|
8
|
+
&:has(.govuk-input--error) {
|
|
9
|
+
border-left: $govuk-border-width-form-group-error solid $govuk-error-colour;
|
|
10
|
+
padding-left: govuk-spacing(3);
|
|
11
|
+
margin-top: 0;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.govuk-hint:has(+ .app-location-input .govuk-input--error) {
|
|
16
|
+
border-left: $govuk-border-width-form-group-error solid $govuk-error-colour;
|
|
17
|
+
padding-left: govuk-spacing(3);
|
|
18
|
+
margin-bottom: 0;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.govuk-fieldset:has(.app-location-input .govuk-input--error) {
|
|
22
|
+
.govuk-fieldset__legend {
|
|
23
|
+
border-left: $govuk-border-width-form-group-error solid $govuk-error-colour;
|
|
24
|
+
padding-left: govuk-spacing(3);
|
|
25
|
+
margin-bottom: 0;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.govuk-fieldset__legend + .govuk-hint {
|
|
29
|
+
margin-top: 0;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.app-location-input__item {
|
|
34
|
+
display: inline-block;
|
|
35
|
+
margin-right: govuk-spacing(4);
|
|
36
|
+
margin-bottom: govuk-spacing(4);
|
|
37
|
+
|
|
38
|
+
&:last-child {
|
|
39
|
+
margin-right: 0;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
@include govuk-media-query($from: tablet) {
|
|
43
|
+
margin-bottom: 0;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.govuk-form-group {
|
|
47
|
+
margin-bottom: 0;
|
|
48
|
+
display: inline-block;
|
|
49
|
+
width: auto;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.govuk-label {
|
|
53
|
+
display: block;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.govuk-input {
|
|
57
|
+
margin-bottom: 0;
|
|
58
|
+
width: auto;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
@use "shared";
|
|
3
3
|
@use "code";
|
|
4
4
|
@use "tag-env";
|
|
5
|
+
@use "location-input";
|
|
5
6
|
|
|
6
7
|
// An example of some user-supplied styling
|
|
7
8
|
// Not great practice but it illustrates the point
|
|
@@ -12,9 +13,3 @@
|
|
|
12
13
|
.govuk-header__container {
|
|
13
14
|
border-bottom: 10px solid #003d16;
|
|
14
15
|
}
|
|
15
|
-
|
|
16
|
-
@media print {
|
|
17
|
-
.govuk-link[href]::after {
|
|
18
|
-
content: none;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
@use "pkg:accessible-autocomplete";
|
|
3
3
|
@use "prose";
|
|
4
4
|
@use "summary-list";
|
|
5
|
+
@use "location-input";
|
|
5
6
|
|
|
6
7
|
// Use default GDS Transport font for autocomplete
|
|
7
8
|
.autocomplete__hint,
|
|
@@ -24,3 +25,10 @@
|
|
|
24
25
|
background-color: transparent;
|
|
25
26
|
@include govuk-font($size: 19);
|
|
26
27
|
}
|
|
28
|
+
|
|
29
|
+
// Hide urls for hyperlinks when in print mode
|
|
30
|
+
@media print {
|
|
31
|
+
.govuk-link[href]::after {
|
|
32
|
+
content: none;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -163,6 +163,34 @@ pages:
|
|
|
163
163
|
next:
|
|
164
164
|
- path: '/how-many-members-of-staff-will-look-after-the-unicorns'
|
|
165
165
|
components:
|
|
166
|
+
- name: dfGYuk
|
|
167
|
+
options: {}
|
|
168
|
+
schema: {}
|
|
169
|
+
type: EastingNorthingField
|
|
170
|
+
title: Easting and northing
|
|
171
|
+
hint:
|
|
172
|
+
This is an Easting and Northing component
|
|
173
|
+
- name: seTThb
|
|
174
|
+
options: {}
|
|
175
|
+
schema: {}
|
|
176
|
+
type: LatLongField
|
|
177
|
+
title: Latitute and longitude
|
|
178
|
+
hint:
|
|
179
|
+
This is an Latitute and Longitude component
|
|
180
|
+
- name: bhjloS
|
|
181
|
+
options: {}
|
|
182
|
+
schema: {}
|
|
183
|
+
type: NationalGridFieldNumberField
|
|
184
|
+
title: National grid field number
|
|
185
|
+
hint:
|
|
186
|
+
This is an National Grid Field Number component
|
|
187
|
+
- name: dfQQws
|
|
188
|
+
options: {}
|
|
189
|
+
schema: {}
|
|
190
|
+
type: OsGridRefField
|
|
191
|
+
title: Ordnance survey grid reference
|
|
192
|
+
hint:
|
|
193
|
+
This is an Ordnance survey Grid Reference component
|
|
166
194
|
- name: bClCvo
|
|
167
195
|
options: {}
|
|
168
196
|
schema: {}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComponentBase.js","names":["isConditionalRevealType","joi","ComponentBase","page","parent","collection","type","name","title","schema","options","isFormComponent","model","formSchema","string","stateSchema","constructor","def","props","viewModel","attributes","autocomplete","classes","condition"],"sources":["../../../../../src/server/plugins/engine/components/ComponentBase.ts"],"sourcesContent":["import { isConditionalRevealType, type ComponentDef } from '@defra/forms-model'\nimport joi, {\n type ArraySchema,\n type BooleanSchema,\n type DateSchema,\n type NumberSchema,\n type ObjectSchema,\n type StringSchema\n} from 'joi'\n\nimport { type ComponentCollection } from '~/src/server/plugins/engine/components/ComponentCollection.js'\nimport { type Component } from '~/src/server/plugins/engine/components/helpers/components.js'\nimport { type ViewModel } from '~/src/server/plugins/engine/components/types.js'\nimport { type FormModel } from '~/src/server/plugins/engine/models/index.js'\nimport { type PageControllerClass } from '~/src/server/plugins/engine/pageControllers/helpers/pages.js'\n\nexport class ComponentBase {\n page?: PageControllerClass\n parent: Component | undefined\n collection: ComponentCollection | undefined\n\n type: ComponentDef['type']\n name: ComponentDef['name']\n title: ComponentDef['title']\n schema?: Extract<ComponentDef, { schema
|
|
1
|
+
{"version":3,"file":"ComponentBase.js","names":["isConditionalRevealType","joi","ComponentBase","page","parent","collection","type","name","title","schema","options","isFormComponent","model","formSchema","string","stateSchema","constructor","def","props","viewModel","attributes","autocomplete","classes","condition"],"sources":["../../../../../src/server/plugins/engine/components/ComponentBase.ts"],"sourcesContent":["import { isConditionalRevealType, type ComponentDef } from '@defra/forms-model'\nimport joi, {\n type ArraySchema,\n type BooleanSchema,\n type DateSchema,\n type NumberSchema,\n type ObjectSchema,\n type StringSchema\n} from 'joi'\n\nimport { type ComponentCollection } from '~/src/server/plugins/engine/components/ComponentCollection.js'\nimport { type Component } from '~/src/server/plugins/engine/components/helpers/components.js'\nimport { type ViewModel } from '~/src/server/plugins/engine/components/types.js'\nimport { type FormModel } from '~/src/server/plugins/engine/models/index.js'\nimport { type PageControllerClass } from '~/src/server/plugins/engine/pageControllers/helpers/pages.js'\n\nexport class ComponentBase {\n page?: PageControllerClass\n parent: Component | undefined\n collection: ComponentCollection | undefined\n\n type: ComponentDef['type']\n name: ComponentDef['name']\n title: ComponentDef['title']\n schema?: Extract<ComponentDef, { schema?: object }>['schema']\n options?: Extract<ComponentDef, { options: object }>['options']\n\n isFormComponent = false\n model: FormModel\n\n /** joi schemas based on a component defined in the form JSON. This validates a user's answer and is generated from {@link ComponentDef} */\n formSchema: ComponentSchema = joi.string()\n stateSchema: ComponentSchema = joi.string()\n\n constructor(\n def: ComponentDef,\n props: {\n page?: PageControllerClass\n parent?: Component\n model: FormModel\n }\n ) {\n this.type = def.type\n this.name = def.name\n this.title = def.title\n\n if ('schema' in def) {\n this.schema = def.schema\n }\n\n if ('options' in def) {\n this.options = def.options\n }\n\n this.page = props.page\n this.parent = props.parent\n this.model = props.model\n }\n\n get viewModel() {\n const { options, type } = this\n\n const viewModel: ViewModel = {\n attributes: {}\n }\n\n if (!options) {\n return viewModel\n }\n\n if ('autocomplete' in options) {\n viewModel.attributes.autocomplete = options.autocomplete\n }\n\n if ('classes' in options) {\n viewModel.classes = options.classes\n }\n\n if ('condition' in options && isConditionalRevealType(type)) {\n viewModel.condition = options.condition\n }\n\n return viewModel\n }\n}\n\nexport type ComponentSchema =\n | ArraySchema<string>\n | ArraySchema<number>\n | ArraySchema<boolean>\n | ArraySchema<object>\n | BooleanSchema<string>\n | DateSchema\n | NumberSchema<string>\n | NumberSchema\n | ObjectSchema\n | StringSchema\n"],"mappings":"AAAA,SAASA,uBAAuB,QAA2B,oBAAoB;AAC/E,OAAOC,GAAG,MAOH,KAAK;AAQZ,OAAO,MAAMC,aAAa,CAAC;EACzBC,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IV,uBAAuB,CAACM,IAAI,CAAC,EAAE;MAC3Da,SAAS,CAACI,SAAS,GAAGb,OAAO,CAACa,SAAS;IACzC;IAEA,OAAOJ,SAAS;EAClB;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { type EastingNorthingFieldComponent } from '@defra/forms-model';
|
|
2
|
+
import { type ObjectSchema } from 'joi';
|
|
3
|
+
import { ComponentCollection } from '~/src/server/plugins/engine/components/ComponentCollection.js';
|
|
4
|
+
import { FormComponent } from '~/src/server/plugins/engine/components/FormComponent.js';
|
|
5
|
+
import { type EastingNorthingState } from '~/src/server/plugins/engine/components/types.js';
|
|
6
|
+
import { type ErrorMessageTemplateList, type FormPayload, type FormState, type FormStateValue, type FormSubmissionError, type FormSubmissionState } from '~/src/server/plugins/engine/types.js';
|
|
7
|
+
export declare class EastingNorthingField extends FormComponent {
|
|
8
|
+
options: EastingNorthingFieldComponent['options'];
|
|
9
|
+
formSchema: ObjectSchema<FormPayload>;
|
|
10
|
+
stateSchema: ObjectSchema<FormState>;
|
|
11
|
+
collection: ComponentCollection;
|
|
12
|
+
constructor(def: EastingNorthingFieldComponent, props: ConstructorParameters<typeof FormComponent>[1]);
|
|
13
|
+
getFormValueFromState(state: FormSubmissionState): EastingNorthingState | undefined;
|
|
14
|
+
getDisplayStringFromFormValue(value: EastingNorthingState | undefined): string;
|
|
15
|
+
getDisplayStringFromState(state: FormSubmissionState): string;
|
|
16
|
+
getContextValueFromFormValue(value: EastingNorthingState | undefined): string | null;
|
|
17
|
+
getContextValueFromState(state: FormSubmissionState): string | null;
|
|
18
|
+
getViewModel(payload: FormPayload, errors?: FormSubmissionError[]): {
|
|
19
|
+
fieldset: {
|
|
20
|
+
attributes?: string | Record<string, string>;
|
|
21
|
+
legend?: import("~/src/server/plugins/engine/components/types.js").Label;
|
|
22
|
+
};
|
|
23
|
+
items: import("~/src/server/plugins/engine/components/types.js").DateInputItem[];
|
|
24
|
+
label: import("~/src/server/plugins/engine/components/types.js").Label;
|
|
25
|
+
type?: string;
|
|
26
|
+
id: string;
|
|
27
|
+
name: string;
|
|
28
|
+
value: import("~/src/server/plugins/engine/types.js").FormValue;
|
|
29
|
+
hint?: {
|
|
30
|
+
id?: string;
|
|
31
|
+
text: string;
|
|
32
|
+
};
|
|
33
|
+
prefix?: import("~/src/server/plugins/engine/components/types.js").ComponentText;
|
|
34
|
+
suffix?: import("~/src/server/plugins/engine/components/types.js").ComponentText;
|
|
35
|
+
classes?: string;
|
|
36
|
+
condition?: string;
|
|
37
|
+
errors?: FormSubmissionError[];
|
|
38
|
+
errorMessage?: {
|
|
39
|
+
text: string;
|
|
40
|
+
};
|
|
41
|
+
summaryHtml?: string;
|
|
42
|
+
html?: string;
|
|
43
|
+
attributes: {
|
|
44
|
+
autocomplete?: string;
|
|
45
|
+
maxlength?: number;
|
|
46
|
+
multiple?: string;
|
|
47
|
+
accept?: string;
|
|
48
|
+
inputmode?: string;
|
|
49
|
+
};
|
|
50
|
+
content?: import("~/src/server/plugins/engine/components/types.js").Content | import("~/src/server/plugins/engine/components/types.js").Content[] | string;
|
|
51
|
+
maxlength?: number;
|
|
52
|
+
maxwords?: number;
|
|
53
|
+
rows?: number;
|
|
54
|
+
formGroup?: {
|
|
55
|
+
classes?: string;
|
|
56
|
+
attributes?: string | Record<string, string>;
|
|
57
|
+
};
|
|
58
|
+
components?: import("~/src/server/plugins/engine/components/types.js").ComponentViewModel[];
|
|
59
|
+
upload?: {
|
|
60
|
+
count: number;
|
|
61
|
+
summaryList: import("~/src/server/plugins/engine/types.js").SummaryList;
|
|
62
|
+
};
|
|
63
|
+
} | {
|
|
64
|
+
instructionText: string;
|
|
65
|
+
fieldset: {
|
|
66
|
+
attributes?: string | Record<string, string>;
|
|
67
|
+
legend?: import("~/src/server/plugins/engine/components/types.js").Label;
|
|
68
|
+
};
|
|
69
|
+
items: import("~/src/server/plugins/engine/components/types.js").DateInputItem[];
|
|
70
|
+
label: import("~/src/server/plugins/engine/components/types.js").Label;
|
|
71
|
+
type?: string;
|
|
72
|
+
id: string;
|
|
73
|
+
name: string;
|
|
74
|
+
value: import("~/src/server/plugins/engine/types.js").FormValue;
|
|
75
|
+
hint?: {
|
|
76
|
+
id?: string;
|
|
77
|
+
text: string;
|
|
78
|
+
};
|
|
79
|
+
prefix?: import("~/src/server/plugins/engine/components/types.js").ComponentText;
|
|
80
|
+
suffix?: import("~/src/server/plugins/engine/components/types.js").ComponentText;
|
|
81
|
+
classes?: string;
|
|
82
|
+
condition?: string;
|
|
83
|
+
errors?: FormSubmissionError[];
|
|
84
|
+
errorMessage?: {
|
|
85
|
+
text: string;
|
|
86
|
+
};
|
|
87
|
+
summaryHtml?: string;
|
|
88
|
+
html?: string;
|
|
89
|
+
attributes: {
|
|
90
|
+
autocomplete?: string;
|
|
91
|
+
maxlength?: number;
|
|
92
|
+
multiple?: string;
|
|
93
|
+
accept?: string;
|
|
94
|
+
inputmode?: string;
|
|
95
|
+
};
|
|
96
|
+
content?: import("~/src/server/plugins/engine/components/types.js").Content | import("~/src/server/plugins/engine/components/types.js").Content[] | string;
|
|
97
|
+
maxlength?: number;
|
|
98
|
+
maxwords?: number;
|
|
99
|
+
rows?: number;
|
|
100
|
+
formGroup?: {
|
|
101
|
+
classes?: string;
|
|
102
|
+
attributes?: string | Record<string, string>;
|
|
103
|
+
};
|
|
104
|
+
components?: import("~/src/server/plugins/engine/components/types.js").ComponentViewModel[];
|
|
105
|
+
upload?: {
|
|
106
|
+
count: number;
|
|
107
|
+
summaryList: import("~/src/server/plugins/engine/types.js").SummaryList;
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
isState(value?: FormStateValue | FormState): value is EastingNorthingState;
|
|
111
|
+
/**
|
|
112
|
+
* For error preview page that shows all possible errors on a component
|
|
113
|
+
*/
|
|
114
|
+
getAllPossibleErrors(): ErrorMessageTemplateList;
|
|
115
|
+
/**
|
|
116
|
+
* Static version of getAllPossibleErrors that doesn't require a component instance.
|
|
117
|
+
*/
|
|
118
|
+
static getAllPossibleErrors(): ErrorMessageTemplateList;
|
|
119
|
+
static isEastingNorthing(value?: FormStateValue | FormState): value is EastingNorthingState;
|
|
120
|
+
}
|
|
121
|
+
export declare function getValidatorEastingNorthing(component: EastingNorthingField): import("joi").CustomValidator;
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { ComponentType } from '@defra/forms-model';
|
|
2
|
+
import { ComponentCollection } from "./ComponentCollection.js";
|
|
3
|
+
import { FormComponent, isFormState } from "./FormComponent.js";
|
|
4
|
+
import { createLocationFieldValidator, getLocationFieldViewModel } from "./LocationFieldHelpers.js";
|
|
5
|
+
import { NumberField } from "./NumberField.js";
|
|
6
|
+
import { messageTemplate } from "../pageControllers/validationOptions.js";
|
|
7
|
+
import { convertToLanguageMessages } from "../../../utils/type-utils.js";
|
|
8
|
+
|
|
9
|
+
// British National Grid coordinate limits
|
|
10
|
+
const DEFAULT_EASTING_MIN = 0;
|
|
11
|
+
const DEFAULT_EASTING_MAX = 70000;
|
|
12
|
+
const DEFAULT_NORTHING_MIN = 0;
|
|
13
|
+
const DEFAULT_NORTHING_MAX = 1300000;
|
|
14
|
+
export class EastingNorthingField extends FormComponent {
|
|
15
|
+
constructor(def, props) {
|
|
16
|
+
super(def, props);
|
|
17
|
+
const {
|
|
18
|
+
name,
|
|
19
|
+
options,
|
|
20
|
+
schema
|
|
21
|
+
} = def;
|
|
22
|
+
const isRequired = options.required !== false;
|
|
23
|
+
const eastingMin = schema?.easting?.min ?? DEFAULT_EASTING_MIN;
|
|
24
|
+
const eastingMax = schema?.easting?.max ?? DEFAULT_EASTING_MAX;
|
|
25
|
+
const northingMin = schema?.northing?.min ?? DEFAULT_NORTHING_MIN;
|
|
26
|
+
const northingMax = schema?.northing?.max ?? DEFAULT_NORTHING_MAX;
|
|
27
|
+
const customValidationMessages = convertToLanguageMessages({
|
|
28
|
+
'any.required': messageTemplate.objectMissing,
|
|
29
|
+
'number.base': messageTemplate.objectMissing,
|
|
30
|
+
'number.min': `{{#label}} for ${this.title} must be between {{#limit}} and ${eastingMax}`,
|
|
31
|
+
'number.max': `{{#label}} for ${this.title} must be between ${eastingMin} and {{#limit}}`,
|
|
32
|
+
'number.precision': `{{#label}} for ${this.title} must be between 1 and 5 digits`,
|
|
33
|
+
'number.integer': `{{#label}} for ${this.title} must be between 1 and 5 digits`,
|
|
34
|
+
'number.unsafe': `{{#label}} for ${this.title} must be between 1 and 5 digits`
|
|
35
|
+
});
|
|
36
|
+
const northingValidationMessages = convertToLanguageMessages({
|
|
37
|
+
'any.required': messageTemplate.objectMissing,
|
|
38
|
+
'number.base': messageTemplate.objectMissing,
|
|
39
|
+
'number.min': `{{#label}} for ${this.title} must be between {{#limit}} and ${northingMax}`,
|
|
40
|
+
'number.max': `{{#label}} for ${this.title} must be between ${northingMin} and {{#limit}}`,
|
|
41
|
+
'number.precision': `{{#label}} for ${this.title} must be between 1 and 7 digits`,
|
|
42
|
+
'number.integer': `{{#label}} for ${this.title} must be between 1 and 7 digits`,
|
|
43
|
+
'number.unsafe': `{{#label}} for ${this.title} must be between 1 and 7 digits`
|
|
44
|
+
});
|
|
45
|
+
this.collection = new ComponentCollection([{
|
|
46
|
+
type: ComponentType.NumberField,
|
|
47
|
+
name: `${name}__easting`,
|
|
48
|
+
title: 'Easting',
|
|
49
|
+
schema: {
|
|
50
|
+
min: eastingMin,
|
|
51
|
+
max: eastingMax,
|
|
52
|
+
precision: 0
|
|
53
|
+
},
|
|
54
|
+
options: {
|
|
55
|
+
required: isRequired,
|
|
56
|
+
optionalText: true,
|
|
57
|
+
classes: 'govuk-input--width-10',
|
|
58
|
+
customValidationMessages
|
|
59
|
+
}
|
|
60
|
+
}, {
|
|
61
|
+
type: ComponentType.NumberField,
|
|
62
|
+
name: `${name}__northing`,
|
|
63
|
+
title: 'Northing',
|
|
64
|
+
schema: {
|
|
65
|
+
min: northingMin,
|
|
66
|
+
max: northingMax,
|
|
67
|
+
precision: 0
|
|
68
|
+
},
|
|
69
|
+
options: {
|
|
70
|
+
required: isRequired,
|
|
71
|
+
optionalText: true,
|
|
72
|
+
classes: 'govuk-input--width-10',
|
|
73
|
+
customValidationMessages: northingValidationMessages
|
|
74
|
+
}
|
|
75
|
+
}], {
|
|
76
|
+
...props,
|
|
77
|
+
parent: this
|
|
78
|
+
}, {
|
|
79
|
+
custom: getValidatorEastingNorthing(this),
|
|
80
|
+
peers: [`${name}__easting`, `${name}__northing`]
|
|
81
|
+
});
|
|
82
|
+
this.options = options;
|
|
83
|
+
this.formSchema = this.collection.formSchema;
|
|
84
|
+
this.stateSchema = this.collection.stateSchema;
|
|
85
|
+
}
|
|
86
|
+
getFormValueFromState(state) {
|
|
87
|
+
const value = super.getFormValueFromState(state);
|
|
88
|
+
return EastingNorthingField.isEastingNorthing(value) ? value : undefined;
|
|
89
|
+
}
|
|
90
|
+
getDisplayStringFromFormValue(value) {
|
|
91
|
+
if (!value) {
|
|
92
|
+
return '';
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// CYA page format: <<northingvalue, eastingvalue>>
|
|
96
|
+
return `${value.northing}, ${value.easting}`;
|
|
97
|
+
}
|
|
98
|
+
getDisplayStringFromState(state) {
|
|
99
|
+
const value = this.getFormValueFromState(state);
|
|
100
|
+
return this.getDisplayStringFromFormValue(value);
|
|
101
|
+
}
|
|
102
|
+
getContextValueFromFormValue(value) {
|
|
103
|
+
if (!value) {
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// Output format: Northing: <<entry>>\nEasting: <<entry>>
|
|
108
|
+
return `Northing: ${value.northing}\nEasting: ${value.easting}`;
|
|
109
|
+
}
|
|
110
|
+
getContextValueFromState(state) {
|
|
111
|
+
const value = this.getFormValueFromState(state);
|
|
112
|
+
return this.getContextValueFromFormValue(value);
|
|
113
|
+
}
|
|
114
|
+
getViewModel(payload, errors) {
|
|
115
|
+
const viewModel = super.getViewModel(payload, errors);
|
|
116
|
+
return getLocationFieldViewModel(this, viewModel, payload, errors);
|
|
117
|
+
}
|
|
118
|
+
isState(value) {
|
|
119
|
+
return EastingNorthingField.isEastingNorthing(value);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* For error preview page that shows all possible errors on a component
|
|
124
|
+
*/
|
|
125
|
+
getAllPossibleErrors() {
|
|
126
|
+
return EastingNorthingField.getAllPossibleErrors();
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Static version of getAllPossibleErrors that doesn't require a component instance.
|
|
131
|
+
*/
|
|
132
|
+
static getAllPossibleErrors() {
|
|
133
|
+
return {
|
|
134
|
+
baseErrors: [{
|
|
135
|
+
type: 'required',
|
|
136
|
+
template: messageTemplate.required
|
|
137
|
+
}, {
|
|
138
|
+
type: 'eastingFormat',
|
|
139
|
+
template: 'Easting for [short description] must be between 1 and 5 digits'
|
|
140
|
+
}, {
|
|
141
|
+
type: 'northingFormat',
|
|
142
|
+
template: 'Northing for [short description] must be between 1 and 7 digits'
|
|
143
|
+
}],
|
|
144
|
+
advancedSettingsErrors: [{
|
|
145
|
+
type: 'eastingMin',
|
|
146
|
+
template: `Easting for [short description] must be between ${DEFAULT_EASTING_MIN} and ${DEFAULT_EASTING_MAX}`
|
|
147
|
+
}, {
|
|
148
|
+
type: 'eastingMax',
|
|
149
|
+
template: `Easting for [short description] must be between ${DEFAULT_EASTING_MIN} and ${DEFAULT_EASTING_MAX}`
|
|
150
|
+
}, {
|
|
151
|
+
type: 'northingMin',
|
|
152
|
+
template: `Northing for [short description] must be between ${DEFAULT_NORTHING_MIN} and ${DEFAULT_NORTHING_MAX}`
|
|
153
|
+
}, {
|
|
154
|
+
type: 'northingMax',
|
|
155
|
+
template: `Northing for [short description] must be between ${DEFAULT_NORTHING_MIN} and ${DEFAULT_NORTHING_MAX}`
|
|
156
|
+
}]
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
static isEastingNorthing(value) {
|
|
160
|
+
return isFormState(value) && NumberField.isNumber(value.easting) && NumberField.isNumber(value.northing);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
export function getValidatorEastingNorthing(component) {
|
|
164
|
+
return createLocationFieldValidator(component);
|
|
165
|
+
}
|
|
166
|
+
//# sourceMappingURL=EastingNorthingField.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EastingNorthingField.js","names":["ComponentType","ComponentCollection","FormComponent","isFormState","createLocationFieldValidator","getLocationFieldViewModel","NumberField","messageTemplate","convertToLanguageMessages","DEFAULT_EASTING_MIN","DEFAULT_EASTING_MAX","DEFAULT_NORTHING_MIN","DEFAULT_NORTHING_MAX","EastingNorthingField","constructor","def","props","name","options","schema","isRequired","required","eastingMin","easting","min","eastingMax","max","northingMin","northing","northingMax","customValidationMessages","objectMissing","title","northingValidationMessages","collection","type","precision","optionalText","classes","parent","custom","getValidatorEastingNorthing","peers","formSchema","stateSchema","getFormValueFromState","state","value","isEastingNorthing","undefined","getDisplayStringFromFormValue","getDisplayStringFromState","getContextValueFromFormValue","getContextValueFromState","getViewModel","payload","errors","viewModel","isState","getAllPossibleErrors","baseErrors","template","advancedSettingsErrors","isNumber","component"],"sources":["../../../../../src/server/plugins/engine/components/EastingNorthingField.ts"],"sourcesContent":["import {\n ComponentType,\n type EastingNorthingFieldComponent\n} from '@defra/forms-model'\nimport { type LanguageMessages, type ObjectSchema } from 'joi'\n\nimport { ComponentCollection } from '~/src/server/plugins/engine/components/ComponentCollection.js'\nimport {\n FormComponent,\n isFormState\n} from '~/src/server/plugins/engine/components/FormComponent.js'\nimport {\n createLocationFieldValidator,\n getLocationFieldViewModel\n} from '~/src/server/plugins/engine/components/LocationFieldHelpers.js'\nimport { NumberField } from '~/src/server/plugins/engine/components/NumberField.js'\nimport { type EastingNorthingState } from '~/src/server/plugins/engine/components/types.js'\nimport { messageTemplate } from '~/src/server/plugins/engine/pageControllers/validationOptions.js'\nimport {\n type ErrorMessageTemplateList,\n type FormPayload,\n type FormState,\n type FormStateValue,\n type FormSubmissionError,\n type FormSubmissionState\n} from '~/src/server/plugins/engine/types.js'\nimport { convertToLanguageMessages } from '~/src/server/utils/type-utils.js'\n\n// British National Grid coordinate limits\nconst DEFAULT_EASTING_MIN = 0\nconst DEFAULT_EASTING_MAX = 70000\nconst DEFAULT_NORTHING_MIN = 0\nconst DEFAULT_NORTHING_MAX = 1300000\n\nexport class EastingNorthingField extends FormComponent {\n declare options: EastingNorthingFieldComponent['options']\n declare formSchema: ObjectSchema<FormPayload>\n declare stateSchema: ObjectSchema<FormState>\n declare collection: ComponentCollection\n\n constructor(\n def: EastingNorthingFieldComponent,\n props: ConstructorParameters<typeof FormComponent>[1]\n ) {\n super(def, props)\n\n const { name, options, schema } = def\n\n const isRequired = options.required !== false\n\n const eastingMin = schema?.easting?.min ?? DEFAULT_EASTING_MIN\n const eastingMax = schema?.easting?.max ?? DEFAULT_EASTING_MAX\n const northingMin = schema?.northing?.min ?? DEFAULT_NORTHING_MIN\n const northingMax = schema?.northing?.max ?? DEFAULT_NORTHING_MAX\n\n const customValidationMessages: LanguageMessages =\n convertToLanguageMessages({\n 'any.required': messageTemplate.objectMissing,\n 'number.base': messageTemplate.objectMissing,\n 'number.min': `{{#label}} for ${this.title} must be between {{#limit}} and ${eastingMax}`,\n 'number.max': `{{#label}} for ${this.title} must be between ${eastingMin} and {{#limit}}`,\n 'number.precision': `{{#label}} for ${this.title} must be between 1 and 5 digits`,\n 'number.integer': `{{#label}} for ${this.title} must be between 1 and 5 digits`,\n 'number.unsafe': `{{#label}} for ${this.title} must be between 1 and 5 digits`\n })\n\n const northingValidationMessages: LanguageMessages =\n convertToLanguageMessages({\n 'any.required': messageTemplate.objectMissing,\n 'number.base': messageTemplate.objectMissing,\n 'number.min': `{{#label}} for ${this.title} must be between {{#limit}} and ${northingMax}`,\n 'number.max': `{{#label}} for ${this.title} must be between ${northingMin} and {{#limit}}`,\n 'number.precision': `{{#label}} for ${this.title} must be between 1 and 7 digits`,\n 'number.integer': `{{#label}} for ${this.title} must be between 1 and 7 digits`,\n 'number.unsafe': `{{#label}} for ${this.title} must be between 1 and 7 digits`\n })\n\n this.collection = new ComponentCollection(\n [\n {\n type: ComponentType.NumberField,\n name: `${name}__easting`,\n title: 'Easting',\n schema: { min: eastingMin, max: eastingMax, precision: 0 },\n options: {\n required: isRequired,\n optionalText: true,\n classes: 'govuk-input--width-10',\n customValidationMessages\n }\n },\n {\n type: ComponentType.NumberField,\n name: `${name}__northing`,\n title: 'Northing',\n schema: { min: northingMin, max: northingMax, precision: 0 },\n options: {\n required: isRequired,\n optionalText: true,\n classes: 'govuk-input--width-10',\n customValidationMessages: northingValidationMessages\n }\n }\n ],\n { ...props, parent: this },\n {\n custom: getValidatorEastingNorthing(this),\n peers: [`${name}__easting`, `${name}__northing`]\n }\n )\n\n this.options = options\n this.formSchema = this.collection.formSchema\n this.stateSchema = this.collection.stateSchema\n }\n\n getFormValueFromState(state: FormSubmissionState) {\n const value = super.getFormValueFromState(state)\n return EastingNorthingField.isEastingNorthing(value) ? value : undefined\n }\n\n getDisplayStringFromFormValue(\n value: EastingNorthingState | undefined\n ): string {\n if (!value) {\n return ''\n }\n\n // CYA page format: <<northingvalue, eastingvalue>>\n return `${value.northing}, ${value.easting}`\n }\n\n getDisplayStringFromState(state: FormSubmissionState) {\n const value = this.getFormValueFromState(state)\n\n return this.getDisplayStringFromFormValue(value)\n }\n\n getContextValueFromFormValue(\n value: EastingNorthingState | undefined\n ): string | null {\n if (!value) {\n return null\n }\n\n // Output format: Northing: <<entry>>\\nEasting: <<entry>>\n return `Northing: ${value.northing}\\nEasting: ${value.easting}`\n }\n\n getContextValueFromState(state: FormSubmissionState) {\n const value = this.getFormValueFromState(state)\n\n return this.getContextValueFromFormValue(value)\n }\n\n getViewModel(payload: FormPayload, errors?: FormSubmissionError[]) {\n const viewModel = super.getViewModel(payload, errors)\n return getLocationFieldViewModel(this, viewModel, payload, errors)\n }\n\n isState(value?: FormStateValue | FormState) {\n return EastingNorthingField.isEastingNorthing(value)\n }\n\n /**\n * For error preview page that shows all possible errors on a component\n */\n getAllPossibleErrors(): ErrorMessageTemplateList {\n return EastingNorthingField.getAllPossibleErrors()\n }\n\n /**\n * Static version of getAllPossibleErrors that doesn't require a component instance.\n */\n static getAllPossibleErrors(): ErrorMessageTemplateList {\n return {\n baseErrors: [\n { type: 'required', template: messageTemplate.required },\n {\n type: 'eastingFormat',\n template:\n 'Easting for [short description] must be between 1 and 5 digits'\n },\n {\n type: 'northingFormat',\n template:\n 'Northing for [short description] must be between 1 and 7 digits'\n }\n ],\n advancedSettingsErrors: [\n {\n type: 'eastingMin',\n template: `Easting for [short description] must be between ${DEFAULT_EASTING_MIN} and ${DEFAULT_EASTING_MAX}`\n },\n {\n type: 'eastingMax',\n template: `Easting for [short description] must be between ${DEFAULT_EASTING_MIN} and ${DEFAULT_EASTING_MAX}`\n },\n {\n type: 'northingMin',\n template: `Northing for [short description] must be between ${DEFAULT_NORTHING_MIN} and ${DEFAULT_NORTHING_MAX}`\n },\n {\n type: 'northingMax',\n template: `Northing for [short description] must be between ${DEFAULT_NORTHING_MIN} and ${DEFAULT_NORTHING_MAX}`\n }\n ]\n }\n }\n\n static isEastingNorthing(\n value?: FormStateValue | FormState\n ): value is EastingNorthingState {\n return (\n isFormState(value) &&\n NumberField.isNumber(value.easting) &&\n NumberField.isNumber(value.northing)\n )\n }\n}\n\nexport function getValidatorEastingNorthing(component: EastingNorthingField) {\n return createLocationFieldValidator(component)\n}\n"],"mappings":"AAAA,SACEA,aAAa,QAER,oBAAoB;AAG3B,SAASC,mBAAmB;AAC5B,SACEC,aAAa,EACbC,WAAW;AAEb,SACEC,4BAA4B,EAC5BC,yBAAyB;AAE3B,SAASC,WAAW;AAEpB,SAASC,eAAe;AASxB,SAASC,yBAAyB;;AAElC;AACA,MAAMC,mBAAmB,GAAG,CAAC;AAC7B,MAAMC,mBAAmB,GAAG,KAAK;AACjC,MAAMC,oBAAoB,GAAG,CAAC;AAC9B,MAAMC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1,121 @@
|
|
|
1
|
+
import { type LatLongFieldComponent } from '@defra/forms-model';
|
|
2
|
+
import { type ObjectSchema } from 'joi';
|
|
3
|
+
import { ComponentCollection } from '~/src/server/plugins/engine/components/ComponentCollection.js';
|
|
4
|
+
import { FormComponent } from '~/src/server/plugins/engine/components/FormComponent.js';
|
|
5
|
+
import { type LatLongState } from '~/src/server/plugins/engine/components/types.js';
|
|
6
|
+
import { type ErrorMessageTemplateList, type FormPayload, type FormState, type FormStateValue, type FormSubmissionError, type FormSubmissionState } from '~/src/server/plugins/engine/types.js';
|
|
7
|
+
export declare class LatLongField extends FormComponent {
|
|
8
|
+
options: LatLongFieldComponent['options'];
|
|
9
|
+
formSchema: ObjectSchema<FormPayload>;
|
|
10
|
+
stateSchema: ObjectSchema<FormState>;
|
|
11
|
+
collection: ComponentCollection;
|
|
12
|
+
constructor(def: LatLongFieldComponent, props: ConstructorParameters<typeof FormComponent>[1]);
|
|
13
|
+
getFormValueFromState(state: FormSubmissionState): LatLongState | undefined;
|
|
14
|
+
getDisplayStringFromFormValue(value: LatLongState | undefined): string;
|
|
15
|
+
getDisplayStringFromState(state: FormSubmissionState): string;
|
|
16
|
+
getContextValueFromFormValue(value: LatLongState | undefined): string | null;
|
|
17
|
+
getContextValueFromState(state: FormSubmissionState): string | null;
|
|
18
|
+
getViewModel(payload: FormPayload, errors?: FormSubmissionError[]): {
|
|
19
|
+
fieldset: {
|
|
20
|
+
attributes?: string | Record<string, string>;
|
|
21
|
+
legend?: import("~/src/server/plugins/engine/components/types.js").Label;
|
|
22
|
+
};
|
|
23
|
+
items: import("~/src/server/plugins/engine/components/types.js").DateInputItem[];
|
|
24
|
+
label: import("~/src/server/plugins/engine/components/types.js").Label;
|
|
25
|
+
type?: string;
|
|
26
|
+
id: string;
|
|
27
|
+
name: string;
|
|
28
|
+
value: import("~/src/server/plugins/engine/types.js").FormValue;
|
|
29
|
+
hint?: {
|
|
30
|
+
id?: string;
|
|
31
|
+
text: string;
|
|
32
|
+
};
|
|
33
|
+
prefix?: import("~/src/server/plugins/engine/components/types.js").ComponentText;
|
|
34
|
+
suffix?: import("~/src/server/plugins/engine/components/types.js").ComponentText;
|
|
35
|
+
classes?: string;
|
|
36
|
+
condition?: string;
|
|
37
|
+
errors?: FormSubmissionError[];
|
|
38
|
+
errorMessage?: {
|
|
39
|
+
text: string;
|
|
40
|
+
};
|
|
41
|
+
summaryHtml?: string;
|
|
42
|
+
html?: string;
|
|
43
|
+
attributes: {
|
|
44
|
+
autocomplete?: string;
|
|
45
|
+
maxlength?: number;
|
|
46
|
+
multiple?: string;
|
|
47
|
+
accept?: string;
|
|
48
|
+
inputmode?: string;
|
|
49
|
+
};
|
|
50
|
+
content?: import("~/src/server/plugins/engine/components/types.js").Content | import("~/src/server/plugins/engine/components/types.js").Content[] | string;
|
|
51
|
+
maxlength?: number;
|
|
52
|
+
maxwords?: number;
|
|
53
|
+
rows?: number;
|
|
54
|
+
formGroup?: {
|
|
55
|
+
classes?: string;
|
|
56
|
+
attributes?: string | Record<string, string>;
|
|
57
|
+
};
|
|
58
|
+
components?: import("~/src/server/plugins/engine/components/types.js").ComponentViewModel[];
|
|
59
|
+
upload?: {
|
|
60
|
+
count: number;
|
|
61
|
+
summaryList: import("~/src/server/plugins/engine/types.js").SummaryList;
|
|
62
|
+
};
|
|
63
|
+
} | {
|
|
64
|
+
instructionText: string;
|
|
65
|
+
fieldset: {
|
|
66
|
+
attributes?: string | Record<string, string>;
|
|
67
|
+
legend?: import("~/src/server/plugins/engine/components/types.js").Label;
|
|
68
|
+
};
|
|
69
|
+
items: import("~/src/server/plugins/engine/components/types.js").DateInputItem[];
|
|
70
|
+
label: import("~/src/server/plugins/engine/components/types.js").Label;
|
|
71
|
+
type?: string;
|
|
72
|
+
id: string;
|
|
73
|
+
name: string;
|
|
74
|
+
value: import("~/src/server/plugins/engine/types.js").FormValue;
|
|
75
|
+
hint?: {
|
|
76
|
+
id?: string;
|
|
77
|
+
text: string;
|
|
78
|
+
};
|
|
79
|
+
prefix?: import("~/src/server/plugins/engine/components/types.js").ComponentText;
|
|
80
|
+
suffix?: import("~/src/server/plugins/engine/components/types.js").ComponentText;
|
|
81
|
+
classes?: string;
|
|
82
|
+
condition?: string;
|
|
83
|
+
errors?: FormSubmissionError[];
|
|
84
|
+
errorMessage?: {
|
|
85
|
+
text: string;
|
|
86
|
+
};
|
|
87
|
+
summaryHtml?: string;
|
|
88
|
+
html?: string;
|
|
89
|
+
attributes: {
|
|
90
|
+
autocomplete?: string;
|
|
91
|
+
maxlength?: number;
|
|
92
|
+
multiple?: string;
|
|
93
|
+
accept?: string;
|
|
94
|
+
inputmode?: string;
|
|
95
|
+
};
|
|
96
|
+
content?: import("~/src/server/plugins/engine/components/types.js").Content | import("~/src/server/plugins/engine/components/types.js").Content[] | string;
|
|
97
|
+
maxlength?: number;
|
|
98
|
+
maxwords?: number;
|
|
99
|
+
rows?: number;
|
|
100
|
+
formGroup?: {
|
|
101
|
+
classes?: string;
|
|
102
|
+
attributes?: string | Record<string, string>;
|
|
103
|
+
};
|
|
104
|
+
components?: import("~/src/server/plugins/engine/components/types.js").ComponentViewModel[];
|
|
105
|
+
upload?: {
|
|
106
|
+
count: number;
|
|
107
|
+
summaryList: import("~/src/server/plugins/engine/types.js").SummaryList;
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
isState(value?: FormStateValue | FormState): value is LatLongState;
|
|
111
|
+
/**
|
|
112
|
+
* For error preview page that shows all possible errors on a component
|
|
113
|
+
*/
|
|
114
|
+
getAllPossibleErrors(): ErrorMessageTemplateList;
|
|
115
|
+
/**
|
|
116
|
+
* Static version of getAllPossibleErrors that doesn't require a component instance.
|
|
117
|
+
*/
|
|
118
|
+
static getAllPossibleErrors(): ErrorMessageTemplateList;
|
|
119
|
+
static isLatLong(value?: FormStateValue | FormState): value is LatLongState;
|
|
120
|
+
}
|
|
121
|
+
export declare function getValidatorLatLong(component: LatLongField): import("joi").CustomValidator;
|