@defra/interactive-map 0.0.15-alpha → 0.0.17-alpha
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/assets/css/docusaurus.css +104 -0
- package/assets/images/favicon.svg +1 -0
- package/assets/images/hero.png +0 -0
- package/assets/images/slot-map.svg +264 -0
- package/dist/css/index.css +1 -1
- package/dist/esm/im-core.js +1 -1
- package/dist/esm/im-shell.js +1 -1
- package/dist/umd/im-core.js +1 -1
- package/dist/umd/index.js +1 -1
- package/docs/api/slots.md +90 -6
- package/docs/api.md +4 -4
- package/docs/architecture.md +3 -1
- package/docs/{demo.mdx → examples.mdx} +1 -1
- package/docs/getting-started.md +5 -4
- package/docs/index.mdx +42 -0
- package/docs/plugins/datasets.md +561 -0
- package/docs/plugins/interact.md +176 -55
- package/docs/plugins/map-styles.md +64 -7
- package/docs/plugins/search.md +207 -63
- package/docs/plugins.md +8 -16
- package/docusaurus.config.cjs +34 -34
- package/jest.setup.js +1 -1
- package/package.json +6 -5
- package/plugins/beta/datasets/dist/css/index.css +85 -15
- package/plugins/beta/datasets/dist/esm/im-datasets-plugin.js +1 -1
- package/plugins/beta/datasets/dist/umd/im-datasets-plugin.js +1 -1
- package/plugins/beta/datasets/dist/umd/index.js +1 -1
- package/plugins/beta/datasets/src/DatasetsInit.jsx +24 -9
- package/plugins/beta/datasets/src/adapters/maplibre/index.js +18 -0
- package/plugins/beta/datasets/src/adapters/maplibre/layerBuilders.js +113 -0
- package/plugins/beta/datasets/src/adapters/maplibre/layerIds.js +69 -0
- package/plugins/beta/datasets/src/adapters/maplibre/maplibreLayerAdapter.js +338 -0
- package/plugins/beta/datasets/src/adapters/maplibre/patternRegistry.js +48 -0
- package/plugins/beta/datasets/src/api/addDataset.js +3 -9
- package/plugins/beta/datasets/src/api/getOpacity.js +17 -0
- package/plugins/beta/datasets/src/api/getStyle.js +13 -0
- package/plugins/beta/datasets/src/api/removeDataset.js +3 -45
- package/plugins/beta/datasets/src/api/setData.js +8 -0
- package/plugins/beta/datasets/src/api/setDatasetVisibility.js +37 -0
- package/plugins/beta/datasets/src/api/setFeatureVisibility.js +22 -0
- package/plugins/beta/datasets/src/api/setOpacity.js +29 -0
- package/plugins/beta/datasets/src/api/setStyle.js +22 -0
- package/plugins/beta/datasets/src/datasets.js +33 -59
- package/plugins/beta/datasets/src/defaults.js +43 -9
- package/plugins/beta/datasets/src/fetch/createDynamicSource.js +39 -30
- package/plugins/beta/datasets/src/fetch/fetchGeoJSON.js +2 -2
- package/plugins/beta/datasets/src/manifest.js +27 -19
- package/plugins/beta/datasets/src/panels/Key.jsx +129 -49
- package/plugins/beta/datasets/src/panels/Key.module.scss +48 -9
- package/plugins/beta/datasets/src/panels/Layers.jsx +131 -29
- package/plugins/beta/datasets/src/panels/Layers.module.scss +50 -8
- package/plugins/beta/datasets/src/reducer.js +128 -9
- package/plugins/beta/datasets/src/styles/patterns.js +157 -0
- package/plugins/beta/datasets/src/utils/bbox.js +8 -6
- package/plugins/beta/datasets/src/utils/filters.js +5 -2
- package/plugins/beta/datasets/src/utils/mergeSublayer.js +78 -0
- package/plugins/beta/draw-es/dist/esm/im-draw-es-plugin.js +1 -1
- package/plugins/beta/draw-es/src/DrawInit.jsx +16 -16
- package/plugins/beta/draw-es/src/api/addFeature.js +3 -3
- package/plugins/beta/draw-es/src/api/deleteFeature.js +3 -3
- package/plugins/beta/draw-es/src/api/editFeature.js +3 -3
- package/plugins/beta/draw-es/src/api/newPolygon.js +3 -3
- package/plugins/beta/draw-es/src/events.js +52 -20
- package/plugins/beta/draw-es/src/events.test.js +301 -0
- package/plugins/beta/draw-es/src/graphic.js +1 -1
- package/plugins/beta/draw-es/src/manifest.js +4 -4
- package/plugins/beta/draw-es/src/reducer.js +1 -1
- package/plugins/beta/draw-es/src/sketchViewModel.js +1 -1
- package/plugins/beta/draw-ml/dist/css/index.css +1 -1
- package/plugins/beta/draw-ml/dist/esm/im-draw-ml-plugin.js +1 -1
- package/plugins/beta/draw-ml/dist/umd/im-draw-ml-plugin.js +1 -1
- package/plugins/beta/draw-ml/src/DrawInit.jsx +49 -52
- package/plugins/beta/draw-ml/src/api/deleteFeature.js +1 -1
- package/plugins/beta/draw-ml/src/api/editFeature.js +8 -5
- package/plugins/beta/draw-ml/src/api/newLine.js +0 -1
- package/plugins/beta/draw-ml/src/api/newPolygon.js +0 -1
- package/plugins/beta/draw-ml/src/api/split.js +4 -4
- package/plugins/beta/draw-ml/src/defaults.js +1 -1
- package/plugins/beta/draw-ml/src/draw.scss +0 -7
- package/plugins/beta/draw-ml/src/events.js +8 -6
- package/plugins/beta/draw-ml/src/manifest.js +29 -29
- package/plugins/beta/draw-ml/src/mapboxDraw.js +1 -1
- package/plugins/beta/draw-ml/src/mapboxSnap.js +17 -18
- package/plugins/beta/draw-ml/src/modes/createDrawMode.js +31 -31
- package/plugins/beta/draw-ml/src/modes/disabledMode.js +1 -1
- package/plugins/beta/draw-ml/src/modes/editVertex/touchHandlers.js +11 -11
- package/plugins/beta/draw-ml/src/modes/editVertex/undoHandlers.js +7 -7
- package/plugins/beta/draw-ml/src/modes/editVertex/vertexOperations.js +8 -8
- package/plugins/beta/draw-ml/src/modes/editVertex/vertexQueries.js +7 -7
- package/plugins/beta/draw-ml/src/modes/editVertexMode.js +32 -24
- package/plugins/beta/draw-ml/src/reducer.js +1 -1
- package/plugins/beta/draw-ml/src/undoStack.js +4 -4
- package/plugins/beta/draw-ml/src/utils/snapHelpers.js +12 -12
- package/plugins/beta/draw-ml/src/utils/spatial.js +11 -11
- package/plugins/beta/frame/dist/esm/im-frame-plugin.js +1 -1
- package/plugins/beta/frame/dist/umd/im-frame-plugin.js +1 -1
- package/plugins/beta/frame/src/Frame.jsx +9 -9
- package/plugins/beta/frame/src/FrameInit.jsx +4 -4
- package/plugins/beta/frame/src/api/addFrame.js +1 -1
- package/plugins/beta/frame/src/api/editFeature.js +1 -1
- package/plugins/beta/frame/src/config.js +1 -1
- package/plugins/beta/frame/src/manifest.js +3 -3
- package/plugins/beta/frame/src/reducer.js +1 -1
- package/plugins/beta/frame/src/utils.js +1 -1
- package/plugins/beta/map-styles/dist/esm/im-map-styles-plugin.js +1 -1
- package/plugins/beta/map-styles/dist/umd/im-map-styles-plugin.js +1 -1
- package/plugins/beta/map-styles/src/MapStyles.jsx +18 -18
- package/plugins/beta/map-styles/src/manifest.js +1 -1
- package/plugins/beta/scale-bar/dist/css/index.css +1 -1
- package/plugins/beta/scale-bar/dist/esm/im-scale-bar-plugin.js +1 -1
- package/plugins/beta/scale-bar/dist/umd/im-scale-bar-plugin.js +1 -1
- package/plugins/beta/scale-bar/src/ScaleBar.jsx +5 -5
- package/plugins/beta/scale-bar/src/index.test.js +3 -3
- package/plugins/beta/scale-bar/src/manifest.js +3 -3
- package/plugins/beta/scale-bar/src/scaleBar.scss +2 -1
- package/plugins/beta/use-location/src/UseLocation.jsx +1 -1
- package/plugins/beta/use-location/src/defaults.js +1 -1
- package/plugins/beta/use-location/src/events.js +3 -3
- package/plugins/interact/dist/css/index.css +1 -1
- package/plugins/interact/dist/esm/im-interact-plugin.js +1 -1
- package/plugins/interact/dist/umd/im-interact-plugin.js +1 -1
- package/plugins/interact/src/InteractInit.jsx +1 -2
- package/plugins/interact/src/api/enable.js +8 -5
- package/plugins/interact/src/api/enable.test.js +2 -2
- package/plugins/interact/src/api/selectFeature.js +4 -4
- package/plugins/interact/src/api/unselectFeature.js +5 -5
- package/plugins/interact/src/defaults.js +0 -1
- package/plugins/interact/src/events.test.js +15 -15
- package/plugins/interact/src/hooks/useHighlightSync.js +1 -1
- package/plugins/interact/src/hooks/useInteractionHandlers.js +2 -2
- package/plugins/interact/src/hooks/useInteractionHandlers.test.js +5 -5
- package/plugins/interact/src/interact.scss +0 -7
- package/plugins/interact/src/manifest.js +15 -19
- package/plugins/interact/src/manifest.test.js +6 -5
- package/plugins/interact/src/reducer.js +3 -3
- package/plugins/interact/src/reducer.test.js +0 -1
- package/plugins/interact/src/utils/spatial.js +10 -10
- package/plugins/interact/src/utils/spatial.test.js +14 -14
- package/plugins/search/dist/css/index.css +1 -1
- package/plugins/search/dist/esm/im-search-plugin.js +1 -1
- package/plugins/search/dist/esm/index.js +1 -1
- package/plugins/search/dist/umd/im-search-plugin.js +1 -1
- package/plugins/search/dist/umd/index.js +1 -1
- package/plugins/search/src/Search.jsx +7 -6
- package/plugins/search/src/Search.test.jsx +23 -23
- package/plugins/search/src/components/CloseButton/CloseButton.jsx +15 -15
- package/plugins/search/src/components/CloseButton/CloseButton.test.jsx +2 -2
- package/plugins/search/src/components/Form/Form.jsx +14 -14
- package/plugins/search/src/components/Form/Form.module.scss +2 -1
- package/plugins/search/src/components/Form/Form.test.jsx +11 -11
- package/plugins/search/src/components/OpenButton/OpenButton.jsx +16 -15
- package/plugins/search/src/components/OpenButton/OpenButton.test.jsx +6 -2
- package/plugins/search/src/components/SubmitButton/SubmitButton.jsx +15 -15
- package/plugins/search/src/components/Suggestions/Suggestions.jsx +6 -6
- package/plugins/search/src/components/Suggestions/Suggestions.test.jsx +4 -4
- package/plugins/search/src/datasets.js +12 -13
- package/plugins/search/src/datasets.test.js +1 -1
- package/plugins/search/src/defaults.js +1 -1
- package/plugins/search/src/events/fetchSuggestions.js +3 -3
- package/plugins/search/src/events/fetchSuggestions.test.js +1 -1
- package/plugins/search/src/events/formHandlers.js +3 -3
- package/plugins/search/src/events/formHandlers.test.js +1 -1
- package/plugins/search/src/events/index.js +2 -2
- package/plugins/search/src/events/index.test.js +2 -2
- package/plugins/search/src/events/inputHandlers.js +4 -4
- package/plugins/search/src/events/inputHandlers.test.js +1 -1
- package/plugins/search/src/events/suggestionHandlers.js +2 -2
- package/plugins/search/src/events/suggestionHandlers.test.js +1 -1
- package/plugins/search/src/index.js +2 -1
- package/plugins/search/src/index.test.js +3 -3
- package/plugins/search/src/manifest.js +6 -4
- package/plugins/search/src/reducer.js +1 -2
- package/plugins/search/src/reducer.test.js +2 -2
- package/plugins/search/src/search.scss +10 -3
- package/plugins/search/src/utils/parseOsNamesResults.js +1 -2
- package/plugins/search/src/utils/parseOsNamesResults.test.js +2 -2
- package/plugins/search/src/utils/updateMap.js +1 -1
- package/plugins/search/src/utils/updateMap.test.js +5 -5
- package/providers/beta/esri/dist/esm/im-esri-provider.js +1 -1
- package/providers/beta/esri/src/esriProvider.js +5 -5
- package/providers/beta/esri/src/utils/coords.js +1 -1
- package/providers/beta/esri/src/utils/esriFixes.js +1 -1
- package/providers/beta/esri/src/utils/query.js +4 -4
- package/providers/beta/esri/src/utils/spatial.js +1 -2
- package/providers/beta/esri/src/utils/spatial.test.js +4 -1
- package/providers/beta/open-names/src/utils/mapToLocationModel.test.js +1 -1
- package/providers/maplibre/dist/esm/im-maplibre-provider.js +1 -1
- package/providers/maplibre/dist/umd/im-maplibre-framework.js +1 -1
- package/providers/maplibre/dist/umd/im-maplibre-framework.js.LICENSE.txt +1 -1
- package/providers/maplibre/dist/umd/im-maplibre-provider.js +1 -1
- package/providers/maplibre/src/appEvents.test.js +1 -1
- package/providers/maplibre/src/index.js +1 -1
- package/providers/maplibre/src/index.test.js +3 -5
- package/providers/maplibre/src/mapEvents.test.js +15 -5
- package/providers/maplibre/src/maplibreProvider.test.js +6 -2
- package/providers/maplibre/src/utils/calculateLinearTextSize.js +4 -4
- package/providers/maplibre/src/utils/calculateLinearTextSize.test.js +3 -3
- package/providers/maplibre/src/utils/detectWebgl.test.js +1 -1
- package/providers/maplibre/src/utils/highlightFeatures.js +3 -2
- package/providers/maplibre/src/utils/highlightFeatures.test.js +13 -6
- package/providers/maplibre/src/utils/labels.js +19 -20
- package/providers/maplibre/src/utils/labels.test.js +15 -13
- package/providers/maplibre/src/utils/maplibreFixes.test.js +1 -1
- package/providers/maplibre/src/utils/queryFeatures.js +6 -6
- package/providers/maplibre/src/utils/queryFeatures.test.js +13 -13
- package/providers/maplibre/src/utils/spatial.js +0 -1
- package/providers/maplibre/src/utils/spatial.test.js +26 -27
- package/src/App/components/Actions/Actions.jsx +2 -2
- package/src/App/components/Actions/Actions.module.scss +0 -7
- package/src/App/components/Actions/Actions.test.jsx +1 -1
- package/src/App/components/Icon/Icon.jsx +3 -2
- package/src/App/components/Icon/Icon.module.scss +4 -0
- package/src/App/components/Icon/Icon.test.jsx +43 -4
- package/src/App/components/MapButton/MapButton.jsx +42 -17
- package/src/App/components/MapButton/MapButton.module.scss +4 -13
- package/src/App/components/MapButton/MapButton.test.jsx +27 -3
- package/src/App/components/PopupMenu/PopupMenu.jsx +51 -274
- package/src/App/components/PopupMenu/PopupMenu.module.scss +14 -7
- package/src/App/components/PopupMenu/PopupMenu.test.jsx +70 -1
- package/src/App/components/PopupMenu/usePopupMenu.js +258 -0
- package/src/App/hooks/useButtonStateEvaluator.js +12 -2
- package/src/App/hooks/useButtonStateEvaluator.test.js +38 -4
- package/src/App/hooks/useInterfaceAPI.js +6 -0
- package/src/App/hooks/useLayoutMeasurements.js +84 -18
- package/src/App/hooks/useLayoutMeasurements.test.js +124 -17
- package/src/App/layout/Layout.jsx +12 -7
- package/src/App/layout/Layout.test.jsx +2 -2
- package/src/App/layout/layout.module.scss +67 -29
- package/src/App/registry/pluginRegistry.js +17 -0
- package/src/App/registry/pluginRegistry.test.js +33 -0
- package/src/App/renderer/HtmlElementHost.jsx +2 -1
- package/src/App/renderer/HtmlElementHost.test.jsx +7 -7
- package/src/App/renderer/mapButtons.js +3 -2
- package/src/App/renderer/mapPanels.test.js +2 -2
- package/src/App/renderer/slotHelpers.js +2 -2
- package/src/App/renderer/slotHelpers.test.js +5 -5
- package/src/App/renderer/slots.js +9 -5
- package/src/App/store/AppProvider.jsx +3 -1
- package/src/App/store/AppProvider.test.jsx +1 -1
- package/src/App/store/ServiceProvider.jsx +3 -1
- package/src/App/store/appActionsMap.js +16 -0
- package/src/App/store/appActionsMap.test.js +27 -0
- package/src/App/store/appDispatchMiddleware.js +33 -1
- package/src/App/store/appDispatchMiddleware.test.js +250 -222
- package/src/App/store/appReducer.js +2 -0
- package/src/InteractiveMap/InteractiveMap.js +4 -0
- package/src/config/appConfig.js +7 -4
- package/src/config/events.js +28 -0
- package/src/scss/main.scss +1 -0
- package/src/scss/settings/_dimensions.scss +0 -1
- package/src/services/logger.js +6 -0
- package/src/services/logger.test.js +32 -0
- package/src/utils/getSafeZoneInset.js +9 -7
- package/src/utils/getSafeZoneInset.test.js +10 -10
- package/webpack.dev.mjs +23 -19
- package/docs/govuk-prototype.md +0 -23
- package/docs/index.md +0 -19
- package/plugins/beta/datasets/src/api/hideDataset.js +0 -14
- package/plugins/beta/datasets/src/api/hideFeatures.js +0 -41
- package/plugins/beta/datasets/src/api/showDataset.js +0 -14
- package/plugins/beta/datasets/src/api/showFeatures.js +0 -44
- package/plugins/beta/datasets/src/handleSetMapStyle.js +0 -54
- package/plugins/beta/datasets/src/mapLayers.js +0 -165
|
@@ -10,227 +10,255 @@ const run = (action, state, panelConfig = {}) =>
|
|
|
10
10
|
|
|
11
11
|
const flushMicrotasks = () => new Promise(queueMicrotask)
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
{
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
},
|
|
88
|
-
{
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
{
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
{
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
{
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
})
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
13
|
+
const INVALID_SLOT = 'invalid-slot'
|
|
14
|
+
const LOG_PREFIX = '[interactive-map]'
|
|
15
|
+
|
|
16
|
+
beforeEach(() => {
|
|
17
|
+
jest.clearAllMocks()
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
describe('CLOSE_PANEL', () => {
|
|
21
|
+
it('emits panel closed event', async () => {
|
|
22
|
+
run(
|
|
23
|
+
{ type: 'CLOSE_PANEL', payload: 'testPanel' },
|
|
24
|
+
{ openPanels: {} }
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
await flushMicrotasks()
|
|
28
|
+
|
|
29
|
+
expect(eventBus.emit).toHaveBeenCalledWith(
|
|
30
|
+
events.APP_PANEL_CLOSED,
|
|
31
|
+
{ panelId: 'testPanel' }
|
|
32
|
+
)
|
|
33
|
+
})
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
describe('CLOSE_ALL_PANELS', () => {
|
|
37
|
+
it('emits closed event for each panel', async () => {
|
|
38
|
+
run(
|
|
39
|
+
{ type: 'CLOSE_ALL_PANELS' },
|
|
40
|
+
{ openPanels: { panel1: {}, panel2: {} } }
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
await flushMicrotasks()
|
|
44
|
+
|
|
45
|
+
expect(eventBus.emit).toHaveBeenCalledTimes(2)
|
|
46
|
+
expect(eventBus.emit).toHaveBeenCalledWith(
|
|
47
|
+
events.APP_PANEL_CLOSED,
|
|
48
|
+
{ panelId: 'panel1' }
|
|
49
|
+
)
|
|
50
|
+
expect(eventBus.emit).toHaveBeenCalledWith(
|
|
51
|
+
events.APP_PANEL_CLOSED,
|
|
52
|
+
{ panelId: 'panel2' }
|
|
53
|
+
)
|
|
54
|
+
})
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
describe('OPEN_PANEL — regular panel', () => {
|
|
58
|
+
it('emits panel opened event', async () => {
|
|
59
|
+
run(
|
|
60
|
+
{
|
|
61
|
+
type: 'OPEN_PANEL',
|
|
62
|
+
payload: { panelId: 'newPanel', props: { foo: 'bar' } }
|
|
63
|
+
},
|
|
64
|
+
{ openPanels: {}, breakpoint: 'md' },
|
|
65
|
+
{ newPanel: { md: { exclusive: false, modal: false } } }
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
await flushMicrotasks()
|
|
69
|
+
|
|
70
|
+
expect(eventBus.emit).toHaveBeenCalledWith(
|
|
71
|
+
events.APP_PANEL_OPENED,
|
|
72
|
+
{ panelId: 'newPanel', props: { foo: 'bar' } }
|
|
73
|
+
)
|
|
74
|
+
})
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
const CLOSED_PLUS_OPENED = 3
|
|
78
|
+
|
|
79
|
+
describe('OPEN_PANEL — opening exclusive closes non-exclusive', () => {
|
|
80
|
+
it('closes all non-exclusive panels', async () => {
|
|
81
|
+
run(
|
|
82
|
+
{ type: 'OPEN_PANEL', payload: { panelId: 'exclusivePanel', props: {} } },
|
|
83
|
+
{ openPanels: { regularPanel1: {}, regularPanel2: {}, exclusivePanel2: {} }, breakpoint: 'md' },
|
|
84
|
+
{
|
|
85
|
+
exclusivePanel: { md: { exclusive: true, modal: false } },
|
|
86
|
+
regularPanel1: { md: { exclusive: false, modal: false } },
|
|
87
|
+
regularPanel2: { md: { exclusive: false, modal: false } },
|
|
88
|
+
exclusivePanel2: { md: { exclusive: true, modal: false } }
|
|
89
|
+
}
|
|
90
|
+
)
|
|
91
|
+
await flushMicrotasks()
|
|
92
|
+
expect(eventBus.emit).toHaveBeenCalledTimes(CLOSED_PLUS_OPENED)
|
|
93
|
+
expect(eventBus.emit).toHaveBeenCalledWith(events.APP_PANEL_CLOSED, { panelId: 'regularPanel1' })
|
|
94
|
+
expect(eventBus.emit).toHaveBeenCalledWith(events.APP_PANEL_CLOSED, { panelId: 'regularPanel2' })
|
|
95
|
+
expect(eventBus.emit).toHaveBeenCalledWith(events.APP_PANEL_OPENED, { panelId: 'exclusivePanel', props: {} })
|
|
96
|
+
})
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
describe('OPEN_PANEL — opening regular closes exclusive non-modal', () => {
|
|
100
|
+
it('closes all exclusive non-modal panels', async () => {
|
|
101
|
+
run(
|
|
102
|
+
{ type: 'OPEN_PANEL', payload: { panelId: 'regularPanel', props: {} } },
|
|
103
|
+
{ openPanels: { exclusivePanel1: {}, exclusivePanel2: {}, exclusiveModalPanel: {}, regularPanel2: {} }, breakpoint: 'md' },
|
|
104
|
+
{
|
|
105
|
+
regularPanel: { md: { exclusive: false, modal: false } },
|
|
106
|
+
exclusivePanel1: { md: { exclusive: true, modal: false } },
|
|
107
|
+
exclusivePanel2: { md: { exclusive: true, modal: false } },
|
|
108
|
+
exclusiveModalPanel: { md: { exclusive: true, modal: true } },
|
|
109
|
+
regularPanel2: { md: { exclusive: false, modal: false } }
|
|
110
|
+
}
|
|
111
|
+
)
|
|
112
|
+
await flushMicrotasks()
|
|
113
|
+
expect(eventBus.emit).toHaveBeenCalledTimes(CLOSED_PLUS_OPENED)
|
|
114
|
+
expect(eventBus.emit).toHaveBeenCalledWith(events.APP_PANEL_CLOSED, { panelId: 'exclusivePanel1' })
|
|
115
|
+
expect(eventBus.emit).toHaveBeenCalledWith(events.APP_PANEL_CLOSED, { panelId: 'exclusivePanel2' })
|
|
116
|
+
expect(eventBus.emit).toHaveBeenCalledWith(events.APP_PANEL_OPENED, { panelId: 'regularPanel', props: {} })
|
|
117
|
+
})
|
|
118
|
+
})
|
|
119
|
+
|
|
120
|
+
describe('OPEN_PANEL — modal panel', () => {
|
|
121
|
+
it('does not close any panels when opening modal', async () => {
|
|
122
|
+
run(
|
|
123
|
+
{
|
|
124
|
+
type: 'OPEN_PANEL',
|
|
125
|
+
payload: { panelId: 'modalPanel', props: {} }
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
openPanels: { regularPanel: {}, exclusivePanel: {} },
|
|
129
|
+
breakpoint: 'md'
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
modalPanel: { md: { modal: true } },
|
|
133
|
+
regularPanel: { md: { exclusive: false, modal: false } },
|
|
134
|
+
exclusivePanel: { md: { exclusive: true, modal: false } }
|
|
135
|
+
}
|
|
136
|
+
)
|
|
137
|
+
|
|
138
|
+
await flushMicrotasks()
|
|
139
|
+
|
|
140
|
+
expect(eventBus.emit).toHaveBeenCalledTimes(1)
|
|
141
|
+
expect(eventBus.emit).toHaveBeenCalledWith(
|
|
142
|
+
events.APP_PANEL_OPENED,
|
|
143
|
+
{ panelId: 'modalPanel', props: {} }
|
|
144
|
+
)
|
|
145
|
+
})
|
|
146
|
+
})
|
|
147
|
+
|
|
148
|
+
describe('ADD_BUTTON', () => {
|
|
149
|
+
beforeEach(() => jest.spyOn(console, 'warn').mockImplementation(() => {}))
|
|
150
|
+
afterEach(() => jest.restoreAllMocks())
|
|
151
|
+
|
|
152
|
+
it('warns when button has an invalid slot', () => {
|
|
153
|
+
run(
|
|
154
|
+
{ type: 'ADD_BUTTON', payload: { id: 'myBtn', config: { desktop: { slot: INVALID_SLOT } } } },
|
|
155
|
+
{ breakpoint: 'desktop' }
|
|
156
|
+
)
|
|
157
|
+
expect(console.warn).toHaveBeenCalledWith(LOG_PREFIX, expect.stringContaining(INVALID_SLOT))
|
|
158
|
+
})
|
|
159
|
+
|
|
160
|
+
it('does not warn when button has a valid slot', () => {
|
|
161
|
+
run(
|
|
162
|
+
{ type: 'ADD_BUTTON', payload: { id: 'myBtn', config: { mobile: { slot: 'top-left' }, tablet: { slot: 'top-left' }, desktop: { slot: 'top-left' } } } },
|
|
163
|
+
{ breakpoint: 'desktop' }
|
|
164
|
+
)
|
|
165
|
+
expect(console.warn).not.toHaveBeenCalled()
|
|
166
|
+
})
|
|
167
|
+
})
|
|
168
|
+
|
|
169
|
+
describe('ADD_CONTROL', () => {
|
|
170
|
+
beforeEach(() => jest.spyOn(console, 'warn').mockImplementation(() => {}))
|
|
171
|
+
afterEach(() => jest.restoreAllMocks())
|
|
172
|
+
|
|
173
|
+
it('warns when control has an invalid slot', () => {
|
|
174
|
+
run(
|
|
175
|
+
{ type: 'ADD_CONTROL', payload: { id: 'myCtrl', config: { desktop: { slot: INVALID_SLOT } } } },
|
|
176
|
+
{ breakpoint: 'desktop' }
|
|
177
|
+
)
|
|
178
|
+
expect(console.warn).toHaveBeenCalledWith(LOG_PREFIX, expect.stringContaining(INVALID_SLOT))
|
|
179
|
+
})
|
|
180
|
+
|
|
181
|
+
it('does not warn when control has a valid slot', () => {
|
|
182
|
+
run(
|
|
183
|
+
{ type: 'ADD_CONTROL', payload: { id: 'myCtrl', config: { mobile: { slot: 'drawer' }, tablet: { slot: 'top-left' }, desktop: { slot: 'top-left' } } } },
|
|
184
|
+
{ breakpoint: 'desktop' }
|
|
185
|
+
)
|
|
186
|
+
expect(console.warn).not.toHaveBeenCalled()
|
|
187
|
+
})
|
|
188
|
+
})
|
|
189
|
+
|
|
190
|
+
describe('ADD_PANEL', () => {
|
|
191
|
+
it('emits APP_PANEL_OPENED with slot when panel opens by default', async () => {
|
|
192
|
+
run(
|
|
193
|
+
{ type: 'ADD_PANEL', payload: { id: 'newPanel', config: {} } },
|
|
194
|
+
{ breakpoint: 'desktop' }
|
|
195
|
+
)
|
|
196
|
+
|
|
197
|
+
await flushMicrotasks()
|
|
198
|
+
|
|
199
|
+
expect(eventBus.emit).toHaveBeenCalledWith(
|
|
200
|
+
events.APP_PANEL_OPENED,
|
|
201
|
+
{ panelId: 'newPanel', slot: 'left-top' }
|
|
202
|
+
)
|
|
203
|
+
})
|
|
204
|
+
|
|
205
|
+
it('emits APP_PANEL_OPENED with visibleGeometry when provided in config', async () => {
|
|
206
|
+
const visibleGeometry = { type: 'Feature', geometry: { type: 'Point', coordinates: [1, 2] }, properties: {} }
|
|
207
|
+
run(
|
|
208
|
+
{ type: 'ADD_PANEL', payload: { id: 'geoPanel', config: { visibleGeometry } } },
|
|
209
|
+
{ breakpoint: 'desktop' }
|
|
210
|
+
)
|
|
211
|
+
|
|
212
|
+
await flushMicrotasks()
|
|
213
|
+
|
|
214
|
+
expect(eventBus.emit).toHaveBeenCalledWith(
|
|
215
|
+
events.APP_PANEL_OPENED,
|
|
216
|
+
{ panelId: 'geoPanel', slot: 'left-top', visibleGeometry }
|
|
217
|
+
)
|
|
218
|
+
})
|
|
219
|
+
|
|
220
|
+
it('does not emit APP_PANEL_OPENED when breakpoint config sets open: false', async () => {
|
|
221
|
+
run(
|
|
222
|
+
{ type: 'ADD_PANEL', payload: { id: 'hiddenPanel', config: { desktop: { open: false } } } },
|
|
223
|
+
{ breakpoint: 'desktop' }
|
|
224
|
+
)
|
|
225
|
+
|
|
226
|
+
await flushMicrotasks()
|
|
227
|
+
|
|
228
|
+
expect(eventBus.emit).not.toHaveBeenCalled()
|
|
229
|
+
})
|
|
230
|
+
|
|
231
|
+
it('emits APP_PANEL_OPENED with slot for mobile breakpoint', async () => {
|
|
232
|
+
run(
|
|
233
|
+
{ type: 'ADD_PANEL', payload: { id: 'mobilePanel', config: {} } },
|
|
234
|
+
{ breakpoint: 'mobile' }
|
|
235
|
+
)
|
|
236
|
+
|
|
237
|
+
await flushMicrotasks()
|
|
238
|
+
|
|
239
|
+
expect(eventBus.emit).toHaveBeenCalledWith(
|
|
240
|
+
events.APP_PANEL_OPENED,
|
|
241
|
+
{ panelId: 'mobilePanel', slot: 'drawer' }
|
|
242
|
+
)
|
|
243
|
+
})
|
|
244
|
+
|
|
245
|
+
it('warns when panel has an invalid slot', () => {
|
|
246
|
+
jest.spyOn(console, 'warn').mockImplementation(() => {})
|
|
247
|
+
run(
|
|
248
|
+
{ type: 'ADD_PANEL', payload: { id: 'badPanel', config: { desktop: { slot: INVALID_SLOT, open: false } } } },
|
|
249
|
+
{ breakpoint: 'desktop' }
|
|
250
|
+
)
|
|
251
|
+
expect(console.warn).toHaveBeenCalledWith(LOG_PREFIX, expect.stringContaining(INVALID_SLOT))
|
|
252
|
+
jest.restoreAllMocks()
|
|
253
|
+
})
|
|
254
|
+
|
|
255
|
+
it('does not warn for a panel with a button-adjacent slot', () => {
|
|
256
|
+
jest.spyOn(console, 'warn').mockImplementation(() => {})
|
|
257
|
+
run(
|
|
258
|
+
{ type: 'ADD_PANEL', payload: { id: 'btnPanel', config: { desktop: { slot: 'left-top-button', open: false } } } },
|
|
259
|
+
{ breakpoint: 'desktop' }
|
|
260
|
+
)
|
|
261
|
+
expect(console.warn).not.toHaveBeenCalled()
|
|
262
|
+
jest.restoreAllMocks()
|
|
235
263
|
})
|
|
236
264
|
})
|
|
@@ -29,7 +29,9 @@ export const initialState = (config) => {
|
|
|
29
29
|
const openPanels = getInitialOpenPanels(panelConfig, initialBreakpoint)
|
|
30
30
|
|
|
31
31
|
return {
|
|
32
|
+
appVisible: null,
|
|
32
33
|
isLayoutReady: false,
|
|
34
|
+
arePluginsEvaluated: false,
|
|
33
35
|
breakpoint: initialBreakpoint,
|
|
34
36
|
interfaceType: initialInterfaceType,
|
|
35
37
|
preferredColorScheme: autoColorScheme ? preferredColorScheme : appColorScheme,
|
|
@@ -245,6 +245,8 @@ export default class InteractiveMap {
|
|
|
245
245
|
if (parts.length > 1) {
|
|
246
246
|
document.title = parts[parts.length - 1]
|
|
247
247
|
}
|
|
248
|
+
|
|
249
|
+
this.eventBus.emit(events.APP_HIDDEN)
|
|
248
250
|
}
|
|
249
251
|
|
|
250
252
|
/**
|
|
@@ -262,6 +264,8 @@ export default class InteractiveMap {
|
|
|
262
264
|
}
|
|
263
265
|
|
|
264
266
|
updateDOMState(this)
|
|
267
|
+
|
|
268
|
+
this.eventBus.emit(events.APP_VISIBLE)
|
|
265
269
|
}
|
|
266
270
|
|
|
267
271
|
/**
|
package/src/config/appConfig.js
CHANGED
|
@@ -93,6 +93,9 @@ export const defaultAppConfig = {
|
|
|
93
93
|
}, {
|
|
94
94
|
id: 'minus',
|
|
95
95
|
svgContent: '<path d="M5 12h14"/>'
|
|
96
|
+
}, {
|
|
97
|
+
id: 'chevron',
|
|
98
|
+
svgContent: '<path d="m6 9 6 6 6-6"/>'
|
|
96
99
|
}]
|
|
97
100
|
}
|
|
98
101
|
|
|
@@ -113,7 +116,7 @@ export const defaultButtonConfig = {
|
|
|
113
116
|
export const defaultPanelConfig = {
|
|
114
117
|
label: 'Panel',
|
|
115
118
|
mobile: {
|
|
116
|
-
slot: '
|
|
119
|
+
slot: 'drawer',
|
|
117
120
|
open: true,
|
|
118
121
|
dismissible: true,
|
|
119
122
|
modal: false,
|
|
@@ -141,13 +144,13 @@ export const defaultPanelConfig = {
|
|
|
141
144
|
export const defaultControlConfig = {
|
|
142
145
|
label: 'Control',
|
|
143
146
|
mobile: {
|
|
144
|
-
slot: '
|
|
147
|
+
slot: 'drawer'
|
|
145
148
|
},
|
|
146
149
|
tablet: {
|
|
147
|
-
slot: 'left
|
|
150
|
+
slot: 'top-left'
|
|
148
151
|
},
|
|
149
152
|
desktop: {
|
|
150
|
-
slot: 'left
|
|
153
|
+
slot: 'top-left'
|
|
151
154
|
}
|
|
152
155
|
}
|
|
153
156
|
|
package/src/config/events.js
CHANGED
|
@@ -61,6 +61,34 @@ export const EVENTS = {
|
|
|
61
61
|
*/
|
|
62
62
|
APP_READY: 'app:ready',
|
|
63
63
|
|
|
64
|
+
/**
|
|
65
|
+
* Emitted when the map application becomes visible after being hidden.
|
|
66
|
+
*
|
|
67
|
+
* This can occur in 'hybrid behaviour' responsive scenarios where the map is already initialized
|
|
68
|
+
* (e.g. initialized inline on desktop) but was hidden and then shown again
|
|
69
|
+
* (e.g. resizing to mobile and opening the map).
|
|
70
|
+
*
|
|
71
|
+
* @remarks
|
|
72
|
+
* - Only emitted when transitioning from hidden → visible.
|
|
73
|
+
* - Not fired on initial open.
|
|
74
|
+
* - The existing map state may be preserved depending on configuration.
|
|
75
|
+
*/
|
|
76
|
+
APP_VISIBLE: 'app:visible',
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Emitted when the map application becomes hidden.
|
|
80
|
+
*
|
|
81
|
+
* This can occur in 'hybrid behaviour' responsive scenarios where the map was initialized inline
|
|
82
|
+
* (e.g. visible on desktop) but then becomes hidden
|
|
83
|
+
* (e.g. resizing to mobile or closing the map view).
|
|
84
|
+
*
|
|
85
|
+
* @remarks
|
|
86
|
+
* - Only emitted when transitioning from visible → hidden.
|
|
87
|
+
* - Not fired on initial load if the map starts hidden.
|
|
88
|
+
* - The map state may be preserved depending on configuration.
|
|
89
|
+
*/
|
|
90
|
+
APP_HIDDEN: 'app:hidden',
|
|
91
|
+
|
|
64
92
|
/**
|
|
65
93
|
* Emitted when a panel is opened.
|
|
66
94
|
* Payload: { panelId: string }
|
package/src/scss/main.scss
CHANGED
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
@use '../App/components/KeyboardHelp/KeyboardHelp.module';
|
|
20
20
|
@use '../App/components/MapButton/MapButton.module';
|
|
21
21
|
@use '../App/components/Panel/Panel.module';
|
|
22
|
+
@use '../App/components/Icon/Icon.module';
|
|
22
23
|
@use '../App/components/Viewport/Viewport.module';
|
|
23
24
|
@use '../App/components/Tooltip/Tooltip.module';
|
|
24
25
|
@use '../App/components/PopupMenu/PopupMenu.module';
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { logger } from './logger.js'
|
|
2
|
+
|
|
3
|
+
beforeEach(() => {
|
|
4
|
+
jest.spyOn(console, 'warn').mockImplementation(() => {})
|
|
5
|
+
jest.spyOn(console, 'error').mockImplementation(() => {})
|
|
6
|
+
})
|
|
7
|
+
|
|
8
|
+
afterEach(() => {
|
|
9
|
+
jest.restoreAllMocks()
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
describe('logger', () => {
|
|
13
|
+
it('logger.warn calls console.warn with the [interactive-map] prefix', () => {
|
|
14
|
+
logger.warn('something went wrong')
|
|
15
|
+
expect(console.warn).toHaveBeenCalledWith('[interactive-map]', 'something went wrong')
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
it('logger.error calls console.error with the [interactive-map] prefix', () => {
|
|
19
|
+
logger.error('critical failure')
|
|
20
|
+
expect(console.error).toHaveBeenCalledWith('[interactive-map]', 'critical failure')
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
it('logger.warn forwards multiple arguments', () => {
|
|
24
|
+
logger.warn('slot', 'invalid', { detail: true })
|
|
25
|
+
expect(console.warn).toHaveBeenCalledWith('[interactive-map]', 'slot', 'invalid', { detail: true })
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
it('logger.error forwards multiple arguments', () => {
|
|
29
|
+
logger.error('code', 42, null)
|
|
30
|
+
expect(console.error).toHaveBeenCalledWith('[interactive-map]', 'code', 42, null)
|
|
31
|
+
})
|
|
32
|
+
})
|