@defra/forms-engine-plugin 4.2.0 → 4.4.0
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/javascripts/application.min.js.map +1 -1
- package/.public/javascripts/shared.min.js +1 -1
- package/.public/javascripts/shared.min.js.map +1 -1
- package/.public/javascripts/vendor/accessible-autocomplete.min.js.map +1 -1
- package/.public/stylesheets/application.min.css +1 -1
- package/.public/stylesheets/application.min.css.map +1 -1
- package/.server/client/javascripts/geospatial-map.d.ts +189 -0
- package/.server/client/javascripts/geospatial-map.js +1068 -0
- package/.server/client/javascripts/geospatial-map.js.map +1 -0
- package/.server/client/javascripts/location-map.d.ts +6 -91
- package/.server/client/javascripts/location-map.js +78 -385
- package/.server/client/javascripts/location-map.js.map +1 -1
- package/.server/client/javascripts/map.d.ts +199 -0
- package/.server/client/javascripts/map.js +384 -0
- package/.server/client/javascripts/map.js.map +1 -0
- package/.server/client/javascripts/shared.d.ts +3 -1
- package/.server/client/javascripts/shared.js +3 -1
- package/.server/client/javascripts/shared.js.map +1 -1
- package/.server/client/stylesheets/shared.scss +7 -0
- package/.server/server/plugins/engine/components/ComponentBase.d.ts +1 -0
- package/.server/server/plugins/engine/components/ComponentBase.js +2 -0
- package/.server/server/plugins/engine/components/ComponentBase.js.map +1 -1
- package/.server/server/plugins/engine/components/FormComponent.d.ts +9 -1
- package/.server/server/plugins/engine/components/FormComponent.js +22 -0
- package/.server/server/plugins/engine/components/FormComponent.js.map +1 -1
- package/.server/server/plugins/engine/components/GeospatialField.d.ts +77 -0
- package/.server/server/plugins/engine/components/GeospatialField.js +102 -0
- package/.server/server/plugins/engine/components/GeospatialField.js.map +1 -0
- package/.server/server/plugins/engine/components/helpers/__stubs__/geospatial.d.ts +3 -0
- package/.server/server/plugins/engine/components/helpers/__stubs__/geospatial.js +63 -0
- package/.server/server/plugins/engine/components/helpers/__stubs__/geospatial.js.map +1 -0
- package/.server/server/plugins/engine/components/helpers/components.d.ts +1 -1
- package/.server/server/plugins/engine/components/helpers/components.js +7 -0
- package/.server/server/plugins/engine/components/helpers/components.js.map +1 -1
- package/.server/server/plugins/engine/components/helpers/geospatial.d.ts +6 -0
- package/.server/server/plugins/engine/components/helpers/geospatial.js +71 -0
- package/.server/server/plugins/engine/components/helpers/geospatial.js.map +1 -0
- package/.server/server/plugins/engine/components/helpers/geospatial.test.js +42 -0
- package/.server/server/plugins/engine/components/helpers/geospatial.test.js.map +1 -0
- package/.server/server/plugins/engine/components/index.d.ts +1 -0
- package/.server/server/plugins/engine/components/index.js +1 -0
- package/.server/server/plugins/engine/components/index.js.map +1 -1
- package/.server/server/plugins/engine/models/FormModel.js +0 -4
- package/.server/server/plugins/engine/models/FormModel.js.map +1 -1
- package/.server/server/plugins/engine/pageControllers/PageController.d.ts +1 -0
- package/.server/server/plugins/engine/pageControllers/PageController.js +2 -0
- package/.server/server/plugins/engine/pageControllers/PageController.js.map +1 -1
- package/.server/server/plugins/engine/pageControllers/QuestionPageController.js +2 -4
- package/.server/server/plugins/engine/pageControllers/QuestionPageController.js.map +1 -1
- package/.server/server/plugins/engine/pageControllers/helpers/state.d.ts +8 -7
- package/.server/server/plugins/engine/pageControllers/helpers/state.js +39 -12
- package/.server/server/plugins/engine/pageControllers/helpers/state.js.map +1 -1
- package/.server/server/plugins/engine/pageControllers/helpers/submission.js +13 -1
- package/.server/server/plugins/engine/pageControllers/helpers/submission.js.map +1 -1
- package/.server/server/plugins/engine/pageControllers/validationOptions.js +2 -1
- package/.server/server/plugins/engine/pageControllers/validationOptions.js.map +1 -1
- package/.server/server/plugins/engine/routes/index.js +8 -1
- package/.server/server/plugins/engine/routes/index.js.map +1 -1
- package/.server/server/plugins/engine/types.d.ts +63 -2
- package/.server/server/plugins/engine/types.js +33 -0
- package/.server/server/plugins/engine/types.js.map +1 -1
- package/.server/server/plugins/engine/views/components/geospatialfield.html +7 -0
- package/.server/server/plugins/nunjucks/context.test.js.map +1 -1
- package/.server/server/plugins/nunjucks/filters/field.d.ts +1 -1
- package/.server/server/routes/types.js.map +1 -1
- package/.server/server/services/cacheService.js +3 -0
- package/.server/server/services/cacheService.js.map +1 -1
- package/package.json +9 -5
- package/src/client/javascripts/geospatial-map.js +1023 -0
- package/src/client/javascripts/location-map.js +94 -390
- package/src/client/javascripts/map.js +389 -0
- package/src/client/javascripts/shared.js +3 -1
- package/src/client/stylesheets/shared.scss +7 -0
- package/src/server/plugins/engine/components/ComponentBase.ts +2 -0
- package/src/server/plugins/engine/components/FormComponent.ts +29 -0
- package/src/server/plugins/engine/components/GeospatialField.test.ts +380 -0
- package/src/server/plugins/engine/components/GeospatialField.ts +145 -0
- package/src/server/plugins/engine/components/helpers/__stubs__/geospatial.ts +85 -0
- package/src/server/plugins/engine/components/helpers/components.test.ts +44 -0
- package/src/server/plugins/engine/components/helpers/components.ts +10 -0
- package/src/server/plugins/engine/components/helpers/geospatial.test.js +55 -0
- package/src/server/plugins/engine/components/helpers/geospatial.ts +93 -0
- package/src/server/plugins/engine/components/index.ts +1 -0
- package/src/server/plugins/engine/models/FormModel.ts +0 -4
- package/src/server/plugins/engine/pageControllers/PageController.ts +2 -0
- package/src/server/plugins/engine/pageControllers/QuestionPageController.ts +2 -6
- package/src/server/plugins/engine/pageControllers/helpers/state.test.ts +80 -16
- package/src/server/plugins/engine/pageControllers/helpers/state.ts +57 -17
- package/src/server/plugins/engine/pageControllers/helpers/submission.test.ts +74 -0
- package/src/server/plugins/engine/pageControllers/helpers/submission.ts +17 -1
- package/src/server/plugins/engine/pageControllers/validationOptions.ts +3 -1
- package/src/server/plugins/engine/routes/index.test.ts +4 -2
- package/src/server/plugins/engine/routes/index.ts +13 -1
- package/src/server/plugins/engine/types.ts +77 -4
- package/src/server/plugins/engine/views/components/geospatialfield.html +7 -0
- package/src/server/plugins/nunjucks/context.test.js +2 -3
- package/src/server/routes/types.ts +4 -2
- package/src/server/services/cacheService.ts +2 -0
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extract and parses the GeoJSON from the textarea
|
|
3
|
+
* @param {HTMLTextAreaElement} geospatialInput - the textarea containing the geojson
|
|
4
|
+
*/
|
|
5
|
+
export function getGeoJSON(geospatialInput: HTMLTextAreaElement): GeoJSON;
|
|
6
|
+
/**
|
|
7
|
+
* Gets the bounding box covering a feature collection
|
|
8
|
+
* @param {GeoJSON} geojson - the geojson
|
|
9
|
+
*/
|
|
10
|
+
export function getBoundingBox(geojson: GeoJSON): import("geojson").BBox;
|
|
11
|
+
/**
|
|
12
|
+
* Processes a geospatial field to add map capability
|
|
13
|
+
* @param {MapsEnvironmentConfig} config - the geospatial field element
|
|
14
|
+
* @param {Element} geospatial - the geospatial field element
|
|
15
|
+
* @param {number} index - the 0-based index
|
|
16
|
+
*/
|
|
17
|
+
export function processGeospatial(config: MapsEnvironmentConfig, geospatial: Element, index: number): void;
|
|
18
|
+
/**
|
|
19
|
+
* Adds a feature to the map
|
|
20
|
+
* @param {Feature} feature - the geojson feature
|
|
21
|
+
* @param {any} drawPlugin - the map draw plugin
|
|
22
|
+
* @param {InteractiveMap} map - the interactive map
|
|
23
|
+
*/
|
|
24
|
+
export function addFeatureToMap(feature: Feature, drawPlugin: any, map: InteractiveMap): void;
|
|
25
|
+
/**
|
|
26
|
+
* Returns HTML summary list for the features
|
|
27
|
+
* @param {FeatureCollection} features - the features
|
|
28
|
+
* @param {string} mapId - the ID of the map
|
|
29
|
+
* @param {boolean} [readonly] - render the list in readonly mode
|
|
30
|
+
*/
|
|
31
|
+
export function createFeaturesHTML(features: FeatureCollection, mapId: string, readonly?: boolean): string;
|
|
32
|
+
/**
|
|
33
|
+
* Focus feature
|
|
34
|
+
* @param {Feature} feature - the feature
|
|
35
|
+
* @param {MapLibreMap} mapProvider - the feature id
|
|
36
|
+
*/
|
|
37
|
+
export function focusFeature(feature: Feature, mapProvider: MapLibreMap): void;
|
|
38
|
+
export type GeoJSON = {
|
|
39
|
+
/**
|
|
40
|
+
* - the GeoJSON type string
|
|
41
|
+
*/
|
|
42
|
+
type: "FeatureCollection";
|
|
43
|
+
/**
|
|
44
|
+
* - the features
|
|
45
|
+
*/
|
|
46
|
+
features: FeatureCollection;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Gets all the features
|
|
50
|
+
*/
|
|
51
|
+
export type GetFeatures = () => FeatureCollection;
|
|
52
|
+
/**
|
|
53
|
+
* Gets a feature from the geojson by id
|
|
54
|
+
*/
|
|
55
|
+
export type GetFeature = (id: string) => Feature | undefined;
|
|
56
|
+
/**
|
|
57
|
+
* Add a feature to the geojson
|
|
58
|
+
*/
|
|
59
|
+
export type AddFeature = (feature: Feature) => any;
|
|
60
|
+
/**
|
|
61
|
+
* Update a feature in the geojson
|
|
62
|
+
*/
|
|
63
|
+
export type UpdateFeature = (id: string, geometry: Geometry) => Feature | undefined;
|
|
64
|
+
/**
|
|
65
|
+
* Removes a feature from the geojson
|
|
66
|
+
*/
|
|
67
|
+
export type RemoveFeature = (id: string) => any;
|
|
68
|
+
/**
|
|
69
|
+
* Gets the active feature id
|
|
70
|
+
*/
|
|
71
|
+
export type GetActiveFeature = () => string | undefined;
|
|
72
|
+
/**
|
|
73
|
+
* Set the active feature id
|
|
74
|
+
*/
|
|
75
|
+
export type SetActiveFeature = (id: string) => void;
|
|
76
|
+
/**
|
|
77
|
+
* Resets the active feature id
|
|
78
|
+
*/
|
|
79
|
+
export type ResetActiveFeature = () => void;
|
|
80
|
+
/**
|
|
81
|
+
* Renders the features into the list
|
|
82
|
+
*/
|
|
83
|
+
export type RenderList = () => void;
|
|
84
|
+
/**
|
|
85
|
+
* Renders the features JSON into the hidden textarea
|
|
86
|
+
*/
|
|
87
|
+
export type RenderValue = () => void;
|
|
88
|
+
/**
|
|
89
|
+
* Toggles the action button hidden state
|
|
90
|
+
*/
|
|
91
|
+
export type ToggleActionButtons = (hidden: boolean) => void;
|
|
92
|
+
/**
|
|
93
|
+
* Set focus to the last description input
|
|
94
|
+
*/
|
|
95
|
+
export type FocusDescriptionInput = () => void;
|
|
96
|
+
export type FeaturesManager = {
|
|
97
|
+
/**
|
|
98
|
+
* - function that gets all the features
|
|
99
|
+
*/
|
|
100
|
+
getFeatures: GetFeatures;
|
|
101
|
+
/**
|
|
102
|
+
* - function that gets a feature from the geojson
|
|
103
|
+
*/
|
|
104
|
+
getFeature: GetFeature;
|
|
105
|
+
/**
|
|
106
|
+
* - function that adds feature to the geojson
|
|
107
|
+
*/
|
|
108
|
+
addFeature: AddFeature;
|
|
109
|
+
/**
|
|
110
|
+
* - function that updates a feature in the geojson
|
|
111
|
+
*/
|
|
112
|
+
updateFeature: UpdateFeature;
|
|
113
|
+
/**
|
|
114
|
+
* - function that removes a feature from the geojson
|
|
115
|
+
*/
|
|
116
|
+
removeFeature: RemoveFeature;
|
|
117
|
+
};
|
|
118
|
+
export type ActiveFeatureManager = {
|
|
119
|
+
/**
|
|
120
|
+
* - function that returns the current active feature id
|
|
121
|
+
*/
|
|
122
|
+
getActiveFeature: GetActiveFeature;
|
|
123
|
+
/**
|
|
124
|
+
* - function that sets the current active feature id
|
|
125
|
+
*/
|
|
126
|
+
setActiveFeature: SetActiveFeature;
|
|
127
|
+
/**
|
|
128
|
+
* - function that resets the current active feature id
|
|
129
|
+
*/
|
|
130
|
+
resetActiveFeature: ResetActiveFeature;
|
|
131
|
+
};
|
|
132
|
+
export type UIManager = {
|
|
133
|
+
/**
|
|
134
|
+
* - function that renders the features JSON into the hidden textarea
|
|
135
|
+
*/
|
|
136
|
+
renderValue: RenderValue;
|
|
137
|
+
/**
|
|
138
|
+
* - function that renders the features into the list
|
|
139
|
+
*/
|
|
140
|
+
renderList: RenderList;
|
|
141
|
+
/**
|
|
142
|
+
* - the summary list of features
|
|
143
|
+
*/
|
|
144
|
+
listEl: HTMLDivElement;
|
|
145
|
+
/**
|
|
146
|
+
* - function that toggles the action buttons
|
|
147
|
+
*/
|
|
148
|
+
toggleActionButtons: ToggleActionButtons;
|
|
149
|
+
/**
|
|
150
|
+
* - function that sets focus to a description input element
|
|
151
|
+
*/
|
|
152
|
+
focusDescriptionInput: FocusDescriptionInput;
|
|
153
|
+
};
|
|
154
|
+
export type Context = {
|
|
155
|
+
/**
|
|
156
|
+
* - the interactive map
|
|
157
|
+
*/
|
|
158
|
+
map: InteractiveMap;
|
|
159
|
+
/**
|
|
160
|
+
* - the interactive map provider
|
|
161
|
+
*/
|
|
162
|
+
mapProvider?: MapLibreMap | undefined;
|
|
163
|
+
/**
|
|
164
|
+
* - the features manager
|
|
165
|
+
*/
|
|
166
|
+
featuresManager: FeaturesManager;
|
|
167
|
+
/**
|
|
168
|
+
* - the active feature manager
|
|
169
|
+
*/
|
|
170
|
+
activeFeatureManager: ActiveFeatureManager;
|
|
171
|
+
/**
|
|
172
|
+
* - the UI manager
|
|
173
|
+
*/
|
|
174
|
+
uiManager: UIManager;
|
|
175
|
+
/**
|
|
176
|
+
* - the map interact plugin
|
|
177
|
+
*/
|
|
178
|
+
interactPlugin: any;
|
|
179
|
+
/**
|
|
180
|
+
* - the map draw plugin
|
|
181
|
+
*/
|
|
182
|
+
drawPlugin: any;
|
|
183
|
+
};
|
|
184
|
+
import type { MapsEnvironmentConfig } from '~/src/client/javascripts/map.js';
|
|
185
|
+
import type { Feature } from '~/src/server/plugins/engine/types.js';
|
|
186
|
+
import type { InteractiveMap } from '~/src/client/javascripts/map.js';
|
|
187
|
+
import type { FeatureCollection } from '~/src/server/plugins/engine/types.js';
|
|
188
|
+
import type { MapLibreMap } from '~/src/client/javascripts/map.js';
|
|
189
|
+
import type { Geometry } from '~/src/server/plugins/engine/types.js';
|