@defra/forms-model 3.0.580 → 3.0.581
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/dist/module/__stubs__/components.js +46 -0
- package/dist/module/__stubs__/components.js.map +1 -1
- package/dist/module/components/component-types.js +1 -1
- package/dist/module/components/component-types.js.map +1 -1
- package/dist/module/form/form-editor/__stubs__/preview.js +27 -1
- package/dist/module/form/form-editor/__stubs__/preview.js.map +1 -1
- package/dist/module/form/form-editor/index.js +1 -1
- package/dist/module/form/form-editor/index.js.map +1 -1
- package/dist/module/form/form-editor/macros/types.js.map +1 -1
- package/dist/module/form/form-editor/preview/easting-northing.js +42 -0
- package/dist/module/form/form-editor/preview/easting-northing.js.map +1 -0
- package/dist/module/form/form-editor/preview/helpers.js +26 -5
- package/dist/module/form/form-editor/preview/helpers.js.map +1 -1
- package/dist/module/form/form-editor/preview/index.js +4 -0
- package/dist/module/form/form-editor/preview/index.js.map +1 -1
- package/dist/module/form/form-editor/preview/lat-long.js +42 -0
- package/dist/module/form/form-editor/preview/lat-long.js.map +1 -0
- package/dist/module/form/form-editor/preview/location-helpers.js +44 -0
- package/dist/module/form/form-editor/preview/location-helpers.js.map +1 -0
- package/dist/module/form/form-editor/preview/location-question-base.js +62 -0
- package/dist/module/form/form-editor/preview/location-question-base.js.map +1 -0
- package/dist/module/form/form-editor/preview/national-grid.js +46 -0
- package/dist/module/form/form-editor/preview/national-grid.js.map +1 -0
- package/dist/module/form/form-editor/preview/os-grid-ref.js +46 -0
- package/dist/module/form/form-editor/preview/os-grid-ref.js.map +1 -0
- package/dist/module/form/form-editor/preview/types.js.map +1 -1
- package/dist/types/__stubs__/components.d.ts +5 -1
- package/dist/types/__stubs__/components.d.ts.map +1 -1
- package/dist/types/form/form-editor/__stubs__/preview.d.ts +18 -0
- package/dist/types/form/form-editor/__stubs__/preview.d.ts.map +1 -1
- package/dist/types/form/form-editor/index.d.ts.map +1 -1
- package/dist/types/form/form-editor/macros/types.d.ts +50 -0
- package/dist/types/form/form-editor/macros/types.d.ts.map +1 -1
- package/dist/types/form/form-editor/preview/easting-northing.d.ts +17 -0
- package/dist/types/form/form-editor/preview/easting-northing.d.ts.map +1 -0
- package/dist/types/form/form-editor/preview/helpers.d.ts.map +1 -1
- package/dist/types/form/form-editor/preview/index.d.ts +4 -0
- package/dist/types/form/form-editor/preview/lat-long.d.ts +17 -0
- package/dist/types/form/form-editor/preview/lat-long.d.ts.map +1 -0
- package/dist/types/form/form-editor/preview/location-helpers.d.ts +23 -0
- package/dist/types/form/form-editor/preview/location-helpers.d.ts.map +1 -0
- package/dist/types/form/form-editor/preview/location-question-base.d.ts +43 -0
- package/dist/types/form/form-editor/preview/location-question-base.d.ts.map +1 -0
- package/dist/types/form/form-editor/preview/national-grid.d.ts +17 -0
- package/dist/types/form/form-editor/preview/national-grid.d.ts.map +1 -0
- package/dist/types/form/form-editor/preview/os-grid-ref.d.ts +17 -0
- package/dist/types/form/form-editor/preview/os-grid-ref.d.ts.map +1 -0
- package/dist/types/form/form-editor/preview/types.d.ts +21 -2
- package/dist/types/form/form-editor/preview/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/__stubs__/components.ts +62 -0
- package/src/components/component-types.ts +1 -1
- package/src/form/form-editor/__stubs__/preview.js +24 -1
- package/src/form/form-editor/index.ts +1 -0
- package/src/form/form-editor/macros/types.ts +54 -0
- package/src/form/form-editor/preview/easting-northing.js +55 -0
- package/src/form/form-editor/preview/helpers.js +40 -5
- package/src/form/form-editor/preview/index.js +4 -0
- package/src/form/form-editor/preview/lat-long.js +55 -0
- package/src/form/form-editor/preview/location-helpers.js +49 -0
- package/src/form/form-editor/preview/location-question-base.js +65 -0
- package/src/form/form-editor/preview/national-grid.js +56 -0
- package/src/form/form-editor/preview/os-grid-ref.js +56 -0
- package/src/form/form-editor/preview/types.ts +24 -2
|
@@ -14,7 +14,15 @@ import {
|
|
|
14
14
|
DeclarationComponentPreviewElements,
|
|
15
15
|
DeclarationQuestion
|
|
16
16
|
} from '~/src/form/form-editor/preview/declaration.js'
|
|
17
|
+
import {
|
|
18
|
+
EastingNorthingComponentPreviewElements,
|
|
19
|
+
EastingNorthingQuestion
|
|
20
|
+
} from '~/src/form/form-editor/preview/easting-northing.js'
|
|
17
21
|
import { EmailAddressQuestion } from '~/src/form/form-editor/preview/email-address.js'
|
|
22
|
+
import {
|
|
23
|
+
LatLongComponentPreviewElements,
|
|
24
|
+
LatLongQuestion
|
|
25
|
+
} from '~/src/form/form-editor/preview/lat-long.js'
|
|
18
26
|
import {
|
|
19
27
|
ListComponentElements,
|
|
20
28
|
ListQuestion,
|
|
@@ -23,10 +31,18 @@ import {
|
|
|
23
31
|
import { LongAnswerQuestion } from '~/src/form/form-editor/preview/long-answer.js'
|
|
24
32
|
import { Markdown } from '~/src/form/form-editor/preview/markdown.js'
|
|
25
33
|
import { MonthYearQuestion } from '~/src/form/form-editor/preview/month-year.js'
|
|
34
|
+
import {
|
|
35
|
+
NationalGridComponentPreviewElements,
|
|
36
|
+
NationalGridQuestion
|
|
37
|
+
} from '~/src/form/form-editor/preview/national-grid.js'
|
|
26
38
|
import {
|
|
27
39
|
NumberComponentPreviewElements,
|
|
28
40
|
NumberOnlyQuestion
|
|
29
41
|
} from '~/src/form/form-editor/preview/number-only.js'
|
|
42
|
+
import {
|
|
43
|
+
OsGridRefComponentPreviewElements,
|
|
44
|
+
OsGridRefQuestion
|
|
45
|
+
} from '~/src/form/form-editor/preview/os-grid-ref.js'
|
|
30
46
|
import { PhoneNumberQuestion } from '~/src/form/form-editor/preview/phone-number.js'
|
|
31
47
|
import { QuestionComponentElements } from '~/src/form/form-editor/preview/question.js'
|
|
32
48
|
import { RadioQuestion } from '~/src/form/form-editor/preview/radio.js'
|
|
@@ -63,10 +79,10 @@ const InputFieldComponentDictionary = {
|
|
|
63
79
|
[ComponentType.YesNoField]: YesNoQuestion,
|
|
64
80
|
[ComponentType.DeclarationField]: DeclarationQuestion,
|
|
65
81
|
[ComponentType.FileUploadField]: SupportingEvidenceQuestion,
|
|
66
|
-
[ComponentType.EastingNorthingField]:
|
|
67
|
-
[ComponentType.OsGridRefField]:
|
|
68
|
-
[ComponentType.NationalGridFieldNumberField]:
|
|
69
|
-
[ComponentType.LatLongField]:
|
|
82
|
+
[ComponentType.EastingNorthingField]: EastingNorthingQuestion,
|
|
83
|
+
[ComponentType.OsGridRefField]: OsGridRefQuestion,
|
|
84
|
+
[ComponentType.NationalGridFieldNumberField]: NationalGridQuestion,
|
|
85
|
+
[ComponentType.LatLongField]: LatLongQuestion
|
|
70
86
|
}
|
|
71
87
|
|
|
72
88
|
/**
|
|
@@ -102,6 +118,25 @@ const ComponentToPreviewQuestion = {
|
|
|
102
118
|
[ComponentType.YesNoField]: (component, _definition) => {
|
|
103
119
|
const componentCoerced = /** @type {YesNoFieldComponent} */ (component)
|
|
104
120
|
return new QuestionComponentElements(componentCoerced)
|
|
121
|
+
},
|
|
122
|
+
[ComponentType.EastingNorthingField]: (component, _definition) => {
|
|
123
|
+
const componentCoerced = /** @type {EastingNorthingFieldComponent} */ (
|
|
124
|
+
component
|
|
125
|
+
)
|
|
126
|
+
return new EastingNorthingComponentPreviewElements(componentCoerced)
|
|
127
|
+
},
|
|
128
|
+
[ComponentType.OsGridRefField]: (component, _definition) => {
|
|
129
|
+
const componentCoerced = /** @type {OsGridRefFieldComponent} */ (component)
|
|
130
|
+
return new OsGridRefComponentPreviewElements(componentCoerced)
|
|
131
|
+
},
|
|
132
|
+
[ComponentType.NationalGridFieldNumberField]: (component, _definition) => {
|
|
133
|
+
const componentCoerced =
|
|
134
|
+
/** @type {NationalGridFieldNumberFieldComponent} */ (component)
|
|
135
|
+
return new NationalGridComponentPreviewElements(componentCoerced)
|
|
136
|
+
},
|
|
137
|
+
[ComponentType.LatLongField]: (component, _definition) => {
|
|
138
|
+
const componentCoerced = /** @type {LatLongFieldComponent} */ (component)
|
|
139
|
+
return new LatLongComponentPreviewElements(componentCoerced)
|
|
105
140
|
}
|
|
106
141
|
}
|
|
107
142
|
|
|
@@ -150,5 +185,5 @@ export function mapComponentToPreviewQuestion(questionRenderer, definition) {
|
|
|
150
185
|
* @import { Question } from '~/src/form/form-editor/preview/question.js'
|
|
151
186
|
* @import { PreviewComponent } from '~/src/form/form-editor/preview/preview.js'
|
|
152
187
|
* @import { FormDefinition } from '~/src/form/form-definition/types.js'
|
|
153
|
-
* @import { AutocompleteFieldComponent, ComponentDef, DeclarationFieldComponent, NumberFieldComponent, SelectFieldComponent, UkAddressFieldComponent, YesNoFieldComponent } from '~/src/components/types.js'
|
|
188
|
+
* @import { AutocompleteFieldComponent, ComponentDef, DeclarationFieldComponent, EastingNorthingFieldComponent, LatLongFieldComponent, NationalGridFieldNumberFieldComponent, NumberFieldComponent, OsGridRefFieldComponent, SelectFieldComponent, UkAddressFieldComponent, YesNoFieldComponent } from '~/src/components/types.js'
|
|
154
189
|
*/
|
|
@@ -3,12 +3,16 @@ export * from '~/src/form/form-editor/preview/checkbox.js'
|
|
|
3
3
|
export * from '~/src/form/form-editor/preview/checkbox-sortable.js'
|
|
4
4
|
export * from '~/src/form/form-editor/preview/date-input.js'
|
|
5
5
|
export * from '~/src/form/form-editor/preview/declaration.js'
|
|
6
|
+
export * from '~/src/form/form-editor/preview/easting-northing.js'
|
|
6
7
|
export * from '~/src/form/form-editor/preview/email-address.js'
|
|
8
|
+
export * from '~/src/form/form-editor/preview/lat-long.js'
|
|
7
9
|
export * from '~/src/form/form-editor/preview/list.js'
|
|
8
10
|
export * from '~/src/form/form-editor/preview/list-sortable.js'
|
|
9
11
|
export * from '~/src/form/form-editor/preview/markdown.js'
|
|
10
12
|
export * from '~/src/form/form-editor/preview/month-year.js'
|
|
13
|
+
export * from '~/src/form/form-editor/preview/national-grid.js'
|
|
11
14
|
export * from '~/src/form/form-editor/preview/number-only.js'
|
|
15
|
+
export * from '~/src/form/form-editor/preview/os-grid-ref.js'
|
|
12
16
|
export * from '~/src/form/form-editor/preview/phone-number.js'
|
|
13
17
|
export * from '~/src/form/form-editor/preview/question.js'
|
|
14
18
|
export * from '~/src/form/form-editor/preview/radio.js'
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { ComponentType } from '~/src/components/enums.js'
|
|
2
|
+
import {
|
|
3
|
+
createFieldClasses,
|
|
4
|
+
createLocationFieldModel
|
|
5
|
+
} from '~/src/form/form-editor/preview/location-helpers.js'
|
|
6
|
+
import {
|
|
7
|
+
LocationQuestion,
|
|
8
|
+
LocationQuestionComponentPreviewElements
|
|
9
|
+
} from '~/src/form/form-editor/preview/location-question-base.js'
|
|
10
|
+
import { PreviewComponent } from '~/src/form/form-editor/preview/preview.js'
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @implements {QuestionElements}
|
|
14
|
+
*/
|
|
15
|
+
export class LatLongComponentPreviewElements extends LocationQuestionComponentPreviewElements {}
|
|
16
|
+
|
|
17
|
+
export class LatLongQuestion extends LocationQuestion {
|
|
18
|
+
/**
|
|
19
|
+
* @type {ComponentType}
|
|
20
|
+
*/
|
|
21
|
+
componentType = ComponentType.LatLongField
|
|
22
|
+
/**
|
|
23
|
+
* @type {string}
|
|
24
|
+
* @protected
|
|
25
|
+
*/
|
|
26
|
+
_questionTemplate = PreviewComponent.PATH + 'latlongfield.njk'
|
|
27
|
+
_fieldName = 'LatLongField'
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* @protected
|
|
31
|
+
* @returns {LatLongModel}
|
|
32
|
+
*/
|
|
33
|
+
_renderInput() {
|
|
34
|
+
const baseModel = super._renderInput()
|
|
35
|
+
const locationModel = createLocationFieldModel(
|
|
36
|
+
baseModel,
|
|
37
|
+
/** @type {LocationElements} */ (this._htmlElements),
|
|
38
|
+
this._highlight,
|
|
39
|
+
this._instructionText,
|
|
40
|
+
this.titleText
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
return {
|
|
44
|
+
...locationModel,
|
|
45
|
+
latitude: createFieldClasses('latitude', this._highlight),
|
|
46
|
+
longitude: createFieldClasses('longitude', this._highlight)
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* @import { LocationSettings, LocationElements, QuestionElements, QuestionRenderer } from '~/src/form/form-editor/preview/types.js'
|
|
53
|
+
* @import { LatLongModel } from '~/src/form/form-editor/macros/types.js'
|
|
54
|
+
* @import { LatLongFieldComponent } from '~/src/components/types.js'
|
|
55
|
+
*/
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { HIGHLIGHT_CLASS } from '~/src/form/form-editor/preview/constants.js'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Creates the standard location field model with common properties
|
|
5
|
+
* @param {QuestionBaseModel} baseModel - The base model from super._renderInput()
|
|
6
|
+
* @param {LocationElements} htmlElements - The HTML elements containing values
|
|
7
|
+
* @param {string | null} highlight - The currently highlighted element
|
|
8
|
+
* @param {string} instructionText - The instruction text to display
|
|
9
|
+
* @param {string} titleText - The title text including optional suffix
|
|
10
|
+
* @returns {LocationFieldModel}
|
|
11
|
+
*/
|
|
12
|
+
export function createLocationFieldModel(
|
|
13
|
+
baseModel,
|
|
14
|
+
htmlElements,
|
|
15
|
+
highlight,
|
|
16
|
+
instructionText,
|
|
17
|
+
titleText
|
|
18
|
+
) {
|
|
19
|
+
return {
|
|
20
|
+
...baseModel,
|
|
21
|
+
userClasses: htmlElements.values.userClasses,
|
|
22
|
+
fieldset: {
|
|
23
|
+
legend: {
|
|
24
|
+
text: titleText,
|
|
25
|
+
classes: highlight === 'question' ? HIGHLIGHT_CLASS : ''
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
instructionText,
|
|
29
|
+
details: {
|
|
30
|
+
classes: highlight === 'instructionText' ? HIGHLIGHT_CLASS : ''
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Creates field classes with highlight if needed
|
|
37
|
+
* @param {string} fieldName - The name of the field
|
|
38
|
+
* @param {string | null} highlight - The currently highlighted element
|
|
39
|
+
* @returns {{classes: string}}
|
|
40
|
+
*/
|
|
41
|
+
export function createFieldClasses(fieldName, highlight) {
|
|
42
|
+
return {
|
|
43
|
+
classes: highlight === fieldName ? HIGHLIGHT_CLASS : ''
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* @import { LocationElements, QuestionBaseModel, LocationFieldModel } from '~/src/form/form-editor/preview/types.js'
|
|
49
|
+
*/
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Question,
|
|
3
|
+
QuestionComponentElements
|
|
4
|
+
} from '~/src/form/form-editor/preview/question.js'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Base class for location question component preview elements with instruction text support
|
|
8
|
+
* @implements {QuestionElements}
|
|
9
|
+
*/
|
|
10
|
+
export class LocationQuestionComponentPreviewElements extends QuestionComponentElements {
|
|
11
|
+
/**
|
|
12
|
+
* @param {any} component - Component with options.instructionText
|
|
13
|
+
*/
|
|
14
|
+
constructor(component) {
|
|
15
|
+
super(component)
|
|
16
|
+
this._instructionText = component.options.instructionText ?? ''
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @protected
|
|
21
|
+
* @returns {LocationSettings}
|
|
22
|
+
*/
|
|
23
|
+
_getValues() {
|
|
24
|
+
return {
|
|
25
|
+
...super._getValues(),
|
|
26
|
+
instructionText: this._instructionText
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Base class for location questions with instruction text support
|
|
33
|
+
*/
|
|
34
|
+
export class LocationQuestion extends Question {
|
|
35
|
+
/**
|
|
36
|
+
* @type {string}
|
|
37
|
+
* @protected
|
|
38
|
+
*/
|
|
39
|
+
_instructionText = ''
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* @param {LocationElements} htmlElements
|
|
43
|
+
* @param {QuestionRenderer} questionRenderer
|
|
44
|
+
*/
|
|
45
|
+
constructor(htmlElements, questionRenderer) {
|
|
46
|
+
super(htmlElements, questionRenderer)
|
|
47
|
+
this._instructionText = htmlElements.values.instructionText
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
get instructionText() {
|
|
51
|
+
return this._instructionText
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* @param {string} val
|
|
56
|
+
*/
|
|
57
|
+
set instructionText(val) {
|
|
58
|
+
this._instructionText = val
|
|
59
|
+
this.render()
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* @import { LocationSettings, LocationElements, QuestionElements, QuestionRenderer } from '~/src/form/form-editor/preview/types.js'
|
|
65
|
+
*/
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { ComponentType } from '~/src/components/enums.js'
|
|
2
|
+
import { HIGHLIGHT_CLASS } from '~/src/form/form-editor/preview/constants.js'
|
|
3
|
+
import { createLocationFieldModel } from '~/src/form/form-editor/preview/location-helpers.js'
|
|
4
|
+
import {
|
|
5
|
+
LocationQuestion,
|
|
6
|
+
LocationQuestionComponentPreviewElements
|
|
7
|
+
} from '~/src/form/form-editor/preview/location-question-base.js'
|
|
8
|
+
import { PreviewComponent } from '~/src/form/form-editor/preview/preview.js'
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @implements {QuestionElements}
|
|
12
|
+
*/
|
|
13
|
+
export class NationalGridComponentPreviewElements extends LocationQuestionComponentPreviewElements {}
|
|
14
|
+
|
|
15
|
+
export class NationalGridQuestion extends LocationQuestion {
|
|
16
|
+
/**
|
|
17
|
+
* @type {ComponentType}
|
|
18
|
+
*/
|
|
19
|
+
componentType = ComponentType.NationalGridFieldNumberField
|
|
20
|
+
/**
|
|
21
|
+
* @type {string}
|
|
22
|
+
* @protected
|
|
23
|
+
*/
|
|
24
|
+
_questionTemplate = PreviewComponent.PATH + 'nationalgridfieldnumberfield.njk'
|
|
25
|
+
_fieldName = 'NationalGridFieldNumberField'
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* @protected
|
|
29
|
+
* @returns {NationalGridModel}
|
|
30
|
+
*/
|
|
31
|
+
_renderInput() {
|
|
32
|
+
const baseModel = super._renderInput()
|
|
33
|
+
const locationModel = createLocationFieldModel(
|
|
34
|
+
baseModel,
|
|
35
|
+
/** @type {LocationElements} */ (this._htmlElements),
|
|
36
|
+
this._highlight,
|
|
37
|
+
this._instructionText,
|
|
38
|
+
this.titleText
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
return {
|
|
42
|
+
...locationModel,
|
|
43
|
+
label: {
|
|
44
|
+
text: this.titleText,
|
|
45
|
+
classes: this._highlight === 'question' ? HIGHLIGHT_CLASS : ''
|
|
46
|
+
},
|
|
47
|
+
inputClasses: this._highlight === 'input' ? HIGHLIGHT_CLASS : ''
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* @import { LocationSettings, LocationElements, QuestionElements, QuestionRenderer } from '~/src/form/form-editor/preview/types.js'
|
|
54
|
+
* @import { NationalGridModel } from '~/src/form/form-editor/macros/types.js'
|
|
55
|
+
* @import { NationalGridFieldNumberFieldComponent } from '~/src/components/types.js'
|
|
56
|
+
*/
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { ComponentType } from '~/src/components/enums.js'
|
|
2
|
+
import { HIGHLIGHT_CLASS } from '~/src/form/form-editor/preview/constants.js'
|
|
3
|
+
import { createLocationFieldModel } from '~/src/form/form-editor/preview/location-helpers.js'
|
|
4
|
+
import {
|
|
5
|
+
LocationQuestion,
|
|
6
|
+
LocationQuestionComponentPreviewElements
|
|
7
|
+
} from '~/src/form/form-editor/preview/location-question-base.js'
|
|
8
|
+
import { PreviewComponent } from '~/src/form/form-editor/preview/preview.js'
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @implements {QuestionElements}
|
|
12
|
+
*/
|
|
13
|
+
export class OsGridRefComponentPreviewElements extends LocationQuestionComponentPreviewElements {}
|
|
14
|
+
|
|
15
|
+
export class OsGridRefQuestion extends LocationQuestion {
|
|
16
|
+
/**
|
|
17
|
+
* @type {ComponentType}
|
|
18
|
+
*/
|
|
19
|
+
componentType = ComponentType.OsGridRefField
|
|
20
|
+
/**
|
|
21
|
+
* @type {string}
|
|
22
|
+
* @protected
|
|
23
|
+
*/
|
|
24
|
+
_questionTemplate = PreviewComponent.PATH + 'osgridreffield.njk'
|
|
25
|
+
_fieldName = 'OsGridRefField'
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* @protected
|
|
29
|
+
* @returns {OsGridRefModel}
|
|
30
|
+
*/
|
|
31
|
+
_renderInput() {
|
|
32
|
+
const baseModel = super._renderInput()
|
|
33
|
+
const locationModel = createLocationFieldModel(
|
|
34
|
+
baseModel,
|
|
35
|
+
/** @type {LocationElements} */ (this._htmlElements),
|
|
36
|
+
this._highlight,
|
|
37
|
+
this._instructionText,
|
|
38
|
+
this.titleText
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
return {
|
|
42
|
+
...locationModel,
|
|
43
|
+
label: {
|
|
44
|
+
text: this.titleText,
|
|
45
|
+
classes: this._highlight === 'question' ? HIGHLIGHT_CLASS : ''
|
|
46
|
+
},
|
|
47
|
+
inputClasses: this._highlight === 'input' ? HIGHLIGHT_CLASS : ''
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* @import { LocationSettings, LocationElements, QuestionElements, QuestionRenderer } from '~/src/form/form-editor/preview/types.js'
|
|
54
|
+
* @import { OsGridRefModel } from '~/src/form/form-editor/macros/types.js'
|
|
55
|
+
* @import { OsGridRefFieldComponent } from '~/src/components/types.js'
|
|
56
|
+
*/
|
|
@@ -38,8 +38,8 @@ export interface GovukFieldset {
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
export type ListenerRow = [
|
|
41
|
-
HTMLInputElement | null,
|
|
42
|
-
(target: HTMLInputElement, e: Event) => void,
|
|
41
|
+
HTMLInputElement | HTMLTextAreaElement | null,
|
|
42
|
+
(target: HTMLInputElement | HTMLTextAreaElement, e: Event) => void,
|
|
43
43
|
keyof HTMLElementEventMap
|
|
44
44
|
]
|
|
45
45
|
|
|
@@ -83,6 +83,28 @@ export interface NumberElements extends DomElementsBase {
|
|
|
83
83
|
readonly values: NumberSettings
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
+
export interface LocationSettings extends BaseSettings {
|
|
87
|
+
instructionText: string
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export interface LocationElements extends DomElementsBase {
|
|
91
|
+
readonly values: LocationSettings
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export interface LocationFieldModel extends QuestionBaseModel {
|
|
95
|
+
userClasses: string
|
|
96
|
+
fieldset: {
|
|
97
|
+
legend: {
|
|
98
|
+
text: string
|
|
99
|
+
classes: string
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
instructionText: string
|
|
103
|
+
details: {
|
|
104
|
+
classes: string
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
86
108
|
export interface RenderBase {
|
|
87
109
|
render(questionTemplate: string, renderContext: RenderContext): void
|
|
88
110
|
}
|