@defra/interactive-map 0.0.55-alpha → 0.0.57-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.
Files changed (502) hide show
  1. package/assets/templates/style-switcher.njk +2 -2
  2. package/dist/esm/im-core.js +1 -1
  3. package/dist/esm/im-shell.js +1 -1
  4. package/dist/umd/im-core.js +1 -1
  5. package/dist/umd/index.js +1 -1
  6. package/docs/api/button-definition.md +11 -0
  7. package/docs/api/context.md +4 -0
  8. package/docs/api.md +20 -2
  9. package/docs/architecture/interactive-map.likec4 +4 -4
  10. package/docs/plugins/datasets.md +11 -0
  11. package/docs/plugins/draw.md +197 -35
  12. package/docs/plugins/interact.md +24 -1
  13. package/docs/plugins/search.md +2 -2
  14. package/docusaurus.config.cjs +25 -3
  15. package/govuk-prototype-kit.config.json +6 -7
  16. package/package.json +20 -23
  17. package/plugins/datasets/dist/esm/im-datasets-esri-adapter.js +1 -1
  18. package/plugins/datasets/dist/esm/im-datasets-ml-adapter.js +1 -1
  19. package/plugins/datasets/dist/esm/im-datasets-ol-adapter.js +1 -1
  20. package/plugins/datasets/dist/esm/im-datasets-plugin.js +1 -1
  21. package/plugins/datasets/dist/esm/index.js +1 -1
  22. package/plugins/datasets/dist/esm/mapboxStyleLayerAdapter.js +1 -1
  23. package/plugins/datasets/dist/umd/im-datasets-ml-adapter.js +1 -1
  24. package/plugins/datasets/dist/umd/im-datasets-ol-adapter.js +1 -1
  25. package/plugins/datasets/dist/umd/im-datasets-plugin.js +1 -1
  26. package/plugins/datasets/dist/umd/index.js +1 -1
  27. package/plugins/datasets/src/adapters/esri/esriLayerAdapter.js +18 -16
  28. package/plugins/datasets/src/adapters/esri/esriLayerAdapter.test.js +2 -2
  29. package/plugins/datasets/src/adapters/esri/registry/esriDataset.js +2 -3
  30. package/plugins/datasets/src/adapters/esri/registry/esriDataset.test.js +1 -1
  31. package/plugins/datasets/src/adapters/loadLayerAdapter.js +2 -20
  32. package/plugins/datasets/src/adapters/loadLayerAdapter.test.js +9 -9
  33. package/plugins/datasets/src/adapters/mapboxStyleLayerAdapter.js +7 -7
  34. package/plugins/datasets/src/adapters/maplibre/maplibreLayerAdapter.js +19 -19
  35. package/plugins/datasets/src/adapters/maplibre/maplibreLayerAdapter.test.js +1 -1
  36. package/plugins/datasets/src/adapters/maplibre/registry/mapLibreDataset.test.js +1 -1
  37. package/plugins/datasets/src/adapters/openlayers/canvasPatternStyle.test.js +2 -2
  38. package/plugins/datasets/src/adapters/openlayers/layerBuilders.test.js +1 -1
  39. package/plugins/datasets/src/adapters/openlayers/openlayersLayerAdapter.js +21 -21
  40. package/plugins/datasets/src/adapters/openlayers/openlayersLayerAdapter.test.js +5 -5
  41. package/plugins/datasets/src/adapters/openlayers/registry/openLayersDataset.js +2 -3
  42. package/plugins/datasets/src/adapters/openlayers/registry/openLayersDataset.test.js +2 -2
  43. package/plugins/datasets/src/api/getOpacity.js +1 -2
  44. package/plugins/datasets/src/api/getOpacity.test.js +9 -12
  45. package/plugins/datasets/src/api/getStyle.js +1 -2
  46. package/plugins/datasets/src/api/getStyle.test.js +5 -8
  47. package/plugins/datasets/src/api/removeDataset.js +2 -4
  48. package/plugins/datasets/src/api/removeDataset.test.js +5 -10
  49. package/plugins/datasets/src/api/setData.js +2 -4
  50. package/plugins/datasets/src/api/setData.test.js +6 -14
  51. package/plugins/datasets/src/api/setFeatureVisibility.js +1 -2
  52. package/plugins/datasets/src/api/setFeatureVisibility.test.js +8 -11
  53. package/plugins/datasets/src/components/LayersMenu/LayersMenu.jsx +1 -0
  54. package/plugins/datasets/src/components/LayersMenu/LayersMenuCheckbox.jsx +1 -3
  55. package/plugins/datasets/src/components/LayersMenu/LayersMenuCheckbox.test.jsx +13 -18
  56. package/plugins/datasets/src/index.js +2 -2
  57. package/plugins/datasets/src/index.test.js +8 -1
  58. package/plugins/datasets/src/initialise/DatasetsInit.jsx +37 -26
  59. package/plugins/datasets/src/initialise/DatasetsInit.test.jsx +120 -89
  60. package/plugins/datasets/src/initialise/initialiseDatasets.js +2 -3
  61. package/plugins/datasets/src/initialise/initialiseDatasets.test.js +23 -10
  62. package/plugins/datasets/src/manifest.js +53 -44
  63. package/plugins/datasets/src/manifest.test.js +36 -4
  64. package/plugins/datasets/src/reducers/pluginState.js +5 -5
  65. package/plugins/datasets/src/reducers/pluginState.test.js +21 -20
  66. package/plugins/datasets/src/registry/__mocks__/datasetRegistry.js +7 -6
  67. package/plugins/datasets/src/registry/createDataset.js +2 -2
  68. package/plugins/datasets/src/registry/dataset.js +9 -10
  69. package/plugins/datasets/src/registry/dataset.test.js +63 -64
  70. package/plugins/datasets/src/registry/datasetRegistry.js +39 -10
  71. package/plugins/datasets/src/registry/datasetRegistry.test.js +83 -1
  72. package/plugins/datasets/src/registry/globalDataset.js +9 -17
  73. package/plugins/datasets/src/registry/isVisibleWhen.js +9 -17
  74. package/plugins/datasets/src/registry/isVisibleWhen.test.js +27 -20
  75. package/plugins/datasets/src/registry/mapboxStyleDataset.test.js +26 -27
  76. package/plugins/datasets/src/utils/hasLayersMenu.js +13 -0
  77. package/plugins/datasets/src/utils/hasLayersMenu.test.js +25 -0
  78. package/plugins/draw/dist/esm/im-draw-ml-adapter.js +1 -1
  79. package/plugins/draw/dist/esm/im-draw-ol-adapter.js +1 -1
  80. package/plugins/draw/dist/esm/im-draw-plugin.js +1 -1
  81. package/plugins/draw/dist/esm/index.js +1 -1
  82. package/plugins/draw/dist/esm/liveDrawChecks.js +1 -1
  83. package/plugins/draw/dist/umd/im-draw-ml-adapter.js +1 -1
  84. package/plugins/draw/dist/umd/im-draw-ol-adapter.js +1 -1
  85. package/plugins/draw/dist/umd/im-draw-plugin.js +1 -1
  86. package/plugins/draw/dist/umd/index.js +1 -1
  87. package/plugins/draw/src/DrawInit.jsx +53 -29
  88. package/plugins/draw/src/DrawInit.test.jsx +105 -2
  89. package/plugins/draw/src/adapterEvents.js +78 -44
  90. package/plugins/draw/src/adapters/adapterContract.test.js +3 -3
  91. package/plugins/draw/src/adapters/maplibre/MaplibreDrawAdapter.js +18 -10
  92. package/plugins/draw/src/adapters/maplibre/MaplibreDrawAdapter.test.js +31 -22
  93. package/plugins/draw/src/adapters/maplibre/drawEvents.js +2 -1
  94. package/plugins/draw/src/adapters/maplibre/modes/drawMode/clickHandlers.js +13 -12
  95. package/plugins/draw/src/adapters/maplibre/modes/drawMode/clickHandlers.test.js +5 -5
  96. package/plugins/draw/src/adapters/maplibre/modes/drawMode/undoHandlers.js +1 -1
  97. package/plugins/draw/src/adapters/maplibre/modes/drawMode/undoHandlers.test.js +2 -2
  98. package/plugins/draw/src/adapters/maplibre/modes/drawPointMode.js +6 -9
  99. package/plugins/draw/src/adapters/maplibre/modes/drawPointMode.test.js +4 -4
  100. package/plugins/draw/src/adapters/maplibre/modes/editPointMode/pointerHandlers.js +6 -9
  101. package/plugins/draw/src/adapters/maplibre/modes/editPointMode/pointerHandlers.test.js +1 -1
  102. package/plugins/draw/src/adapters/maplibre/modes/editPointMode/undoHandlers.js +8 -14
  103. package/plugins/draw/src/adapters/maplibre/modes/editPointMode/undoHandlers.test.js +37 -8
  104. package/plugins/draw/src/adapters/maplibre/modes/editPointMode.js +11 -1
  105. package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/undoHandlers.js +14 -19
  106. package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/undoHandlers.test.js +41 -4
  107. package/plugins/draw/src/adapters/maplibre/modes/editVertexMode.js +12 -1
  108. package/plugins/draw/src/adapters/maplibre/utils/editModeEvents.js +3 -1
  109. package/plugins/draw/src/adapters/maplibre/utils/geometryValidation.js +9 -10
  110. package/plugins/draw/src/adapters/maplibre/utils/geometryValidation.test.js +5 -24
  111. package/plugins/draw/src/adapters/openlayers/OLDrawAdapter.js +10 -7
  112. package/plugins/draw/src/adapters/openlayers/OLDrawAdapter.test.js +12 -7
  113. package/plugins/draw/src/adapters/openlayers/core/OLDrawManager.js +5 -0
  114. package/plugins/draw/src/adapters/openlayers/core/OLDrawManager.test.js +7 -3
  115. package/plugins/draw/src/adapters/openlayers/core/styles.test.js +1 -1
  116. package/plugins/draw/src/adapters/openlayers/draw/DrawMode.js +11 -11
  117. package/plugins/draw/src/adapters/openlayers/draw/DrawMode.test.js +15 -15
  118. package/plugins/draw/src/adapters/openlayers/edit/EditMode.js +21 -28
  119. package/plugins/draw/src/adapters/openlayers/edit/EditMode.test.js +26 -5
  120. package/plugins/draw/src/adapters/openlayers/edit/selectionState.js +5 -6
  121. package/plugins/draw/src/adapters/openlayers/edit/selectionState.test.js +2 -12
  122. package/plugins/draw/src/adapters/openlayers/edit/undoOps.js +9 -0
  123. package/plugins/draw/src/adapters/openlayers/edit/undoOps.test.js +7 -0
  124. package/plugins/draw/src/adapters/openlayers/point/drawPointMode.js +6 -9
  125. package/plugins/draw/src/adapters/openlayers/point/drawPointMode.test.js +3 -3
  126. package/plugins/draw/src/adapters/openlayers/point/editPointMode.js +18 -9
  127. package/plugins/draw/src/adapters/openlayers/point/editPointMode.test.js +29 -4
  128. package/plugins/draw/src/adapters/openlayers/point/pointOps.js +3 -2
  129. package/plugins/draw/src/adapters/openlayers/point/pointOps.test.js +6 -0
  130. package/plugins/draw/src/adapters/openlayers/point/pointSelectionState.js +3 -4
  131. package/plugins/draw/src/adapters/openlayers/point/pointSelectionState.test.js +2 -12
  132. package/plugins/draw/src/adapters/openlayers/point/pointSymbolImages.test.js +1 -1
  133. package/plugins/draw/src/api/createNewShape.js +4 -4
  134. package/plugins/draw/src/api/createNewShape.test.js +1 -1
  135. package/plugins/draw/src/api/editFeature.js +8 -11
  136. package/plugins/draw/src/api/editFeature.test.js +33 -22
  137. package/plugins/draw/src/api/newLine.test.js +3 -3
  138. package/plugins/draw/src/api/newPoint.js +4 -5
  139. package/plugins/draw/src/api/newPoint.test.js +3 -3
  140. package/plugins/draw/src/api/newPolygon.test.js +3 -3
  141. package/plugins/draw/src/api/recheckGeometry.js +32 -0
  142. package/plugins/draw/src/api/recheckGeometry.test.js +55 -0
  143. package/plugins/draw/src/api/setGeometry.js +33 -0
  144. package/plugins/draw/src/api/setGeometry.test.js +48 -0
  145. package/plugins/draw/src/api/split.js +23 -22
  146. package/plugins/draw/src/api/split.test.js +33 -18
  147. package/plugins/draw/src/events.js +265 -77
  148. package/plugins/draw/src/events.test.js +708 -34
  149. package/plugins/draw/src/hooks/useSpatialList.js +10 -11
  150. package/plugins/draw/src/hooks/useSpatialList.test.js +3 -3
  151. package/plugins/draw/src/manifest.js +33 -17
  152. package/plugins/draw/src/manifest.test.js +104 -10
  153. package/plugins/draw/src/reducer.js +31 -9
  154. package/plugins/draw/src/reducer.test.js +35 -3
  155. package/plugins/draw/src/utils/drawModes.js +27 -0
  156. package/plugins/draw/src/utils/drawModes.test.js +27 -0
  157. package/plugins/draw/src/utils/needsDrawTarget.js +18 -0
  158. package/plugins/draw/src/utils/needsDrawTarget.test.js +32 -0
  159. package/plugins/draw/src/utils/touchTarget.js +34 -26
  160. package/plugins/draw/src/utils/touchTarget.test.js +32 -20
  161. package/plugins/draw/src/validation/commitChecks.js +185 -0
  162. package/plugins/draw/src/validation/commitChecks.test.js +205 -0
  163. package/plugins/draw/src/validation/liveDrawChecks.js +11 -11
  164. package/plugins/draw/src/validation/liveDrawChecks.test.js +37 -37
  165. package/plugins/draw/src/validation/liveStroke.js +6 -6
  166. package/plugins/draw/src/validation/liveStroke.test.js +27 -27
  167. package/plugins/draw/src/validation/rules.js +16 -14
  168. package/plugins/draw/src/validation/rules.test.js +5 -5
  169. package/plugins/draw/src/validation/validateGeometry.js +58 -31
  170. package/plugins/draw/src/validation/validateGeometry.test.js +68 -44
  171. package/plugins/draw-es/dist/esm/index.js +1 -0
  172. package/plugins/{beta/draw-es → draw-es}/src/DrawInit.jsx +1 -1
  173. package/plugins/{beta/draw-es → draw-es}/src/events.test.js +1 -1
  174. package/plugins/{beta/draw-es → draw-es}/src/graphic.js +1 -1
  175. package/plugins/frame/dist/esm/index.js +1 -0
  176. package/plugins/{beta/frame → frame}/dist/umd/im-frame-plugin.js +1 -1
  177. package/plugins/{beta/frame → frame}/dist/umd/index.js +1 -1
  178. package/plugins/{beta/frame → frame}/package.json +2 -2
  179. package/plugins/interact/dist/esm/im-interact-plugin.js +1 -1
  180. package/plugins/interact/dist/esm/index.js +1 -1
  181. package/plugins/interact/dist/umd/im-interact-plugin.js +1 -1
  182. package/plugins/interact/dist/umd/index.js +1 -1
  183. package/plugins/interact/src/InteractInit.jsx +3 -3
  184. package/plugins/interact/src/api/enable.test.js +13 -0
  185. package/plugins/interact/src/defaults.js +1 -0
  186. package/plugins/interact/src/hooks/useCrossHairVisibility.js +27 -17
  187. package/plugins/interact/src/hooks/useCrossHairVisibility.test.js +72 -7
  188. package/plugins/interact/src/hooks/useInteractionHandlers.js +3 -5
  189. package/plugins/interact/src/hooks/useInteractionHandlers.test.js +4 -3
  190. package/plugins/interact/src/hooks/useSpatialList.js +16 -17
  191. package/plugins/interact/src/hooks/useSpatialList.test.js +9 -9
  192. package/plugins/interact/src/manifest.js +4 -4
  193. package/plugins/interact/src/manifest.test.js +29 -0
  194. package/plugins/interact/src/reducer.js +7 -2
  195. package/plugins/interact/src/reducer.test.js +12 -2
  196. package/plugins/interact/src/utils/needsTarget.js +20 -0
  197. package/plugins/interact/src/utils/needsTarget.test.js +36 -0
  198. package/plugins/map-key/dist/esm/im-map-key-plugin.js +1 -1
  199. package/plugins/map-key/dist/esm/index.js +1 -1
  200. package/plugins/map-key/dist/umd/im-map-key-plugin.js +1 -1
  201. package/plugins/map-key/dist/umd/index.js +1 -1
  202. package/plugins/map-key/src/components/Key/KeySvgSymbol.jsx +4 -0
  203. package/plugins/map-key/src/components/Key/MapKey.jsx +15 -15
  204. package/plugins/map-key/src/components/Key/MapKey.test.jsx +29 -15
  205. package/plugins/map-key/src/initialise/MapKeyInit.jsx +5 -8
  206. package/plugins/map-key/src/initialise/MapKeyInit.test.jsx +9 -7
  207. package/plugins/map-key/src/manifest.test.js +0 -1
  208. package/plugins/map-key/src/reducers/mergeKeyGroupItems.js +14 -33
  209. package/plugins/map-key/src/reducers/mergeKeyGroupItems.test.js +34 -50
  210. package/plugins/map-key/src/reducers/pluginState.js +6 -1
  211. package/plugins/map-key/src/reducers/pluginState.test.js +13 -4
  212. package/plugins/map-styles/dist/esm/im-map-styles-plugin.js +1 -0
  213. package/plugins/map-styles/dist/esm/index.js +1 -0
  214. package/plugins/map-styles/dist/umd/im-map-styles-plugin.js +1 -0
  215. package/plugins/{beta/map-styles → map-styles}/dist/umd/index.js +1 -1
  216. package/plugins/{beta/map-styles → map-styles}/src/MapStyles.jsx +3 -3
  217. package/plugins/{beta/map-styles → map-styles}/src/MapStylesInit.jsx +1 -1
  218. package/plugins/menu/dist/esm/index.js +1 -1
  219. package/plugins/scale-bar/dist/esm/index.js +1 -0
  220. package/plugins/{beta/scale-bar → scale-bar}/dist/umd/im-scale-bar-plugin.js +1 -1
  221. package/plugins/{beta/scale-bar → scale-bar}/dist/umd/index.js +1 -1
  222. package/plugins/{beta/scale-bar → scale-bar}/package.json +2 -2
  223. package/plugins/search/dist/esm/im-search-plugin.js +1 -1
  224. package/plugins/search/dist/esm/index.js +1 -1
  225. package/plugins/search/dist/umd/im-search-plugin.js +1 -1
  226. package/plugins/search/dist/umd/index.js +1 -1
  227. package/plugins/search/src/components/Suggestions/Suggestions.jsx +3 -1
  228. package/plugins/search/src/components/Suggestions/Suggestions.test.jsx +11 -0
  229. package/plugins/search/src/utils/markedToElements.jsx +25 -0
  230. package/plugins/search/src/utils/markedToElements.test.jsx +49 -0
  231. package/plugins/search/src/utils/parseOsNamesResults.js +6 -4
  232. package/plugins/search/src/utils/parseOsNamesResults.test.js +18 -0
  233. package/plugins/use-location/dist/esm/index.js +1 -0
  234. package/plugins/{beta/use-location → use-location}/dist/umd/im-use-location-plugin.js +1 -1
  235. package/plugins/{beta/use-location → use-location}/dist/umd/index.js +1 -1
  236. package/providers/esri/dist/esm/index.js +1 -0
  237. package/providers/{beta/esri → esri}/src/esriProvider.js +1 -1
  238. package/providers/{beta/esri → esri}/src/mapEvents.js +2 -2
  239. package/providers/maplibre/dist/esm/index.js +1 -1
  240. package/providers/maplibre/dist/umd/index.js +1 -1
  241. package/providers/maplibre/src/index.js +11 -2
  242. package/providers/maplibre/src/index.test.js +23 -1
  243. package/providers/maplibre/src/utils/detectModuleWorker.js +8 -19
  244. package/providers/maplibre/src/utils/detectModuleWorker.test.js +19 -23
  245. package/providers/maplibre/src/utils/workerUrl.js +12 -0
  246. package/providers/maplibre/src/utils/workerUrl.test.js +14 -1
  247. package/providers/open-names/dist/esm/index.js +1 -0
  248. package/providers/{beta/open-names → open-names}/dist/umd/im-reverse-geocode.js +1 -1
  249. package/providers/{beta/open-names → open-names}/dist/umd/index.js +1 -1
  250. package/providers/openlayers/dist/esm/index.js +1 -0
  251. package/providers/openlayers/dist/umd/im-openlayers-provider.js +2 -0
  252. package/providers/{beta/openlayers → openlayers}/dist/umd/index.js +1 -1
  253. package/providers/{beta/openlayers → openlayers}/src/index.js +4 -4
  254. package/providers/{beta/openlayers → openlayers}/src/mapEvents.js +2 -2
  255. package/providers/{beta/openlayers → openlayers}/src/mapEvents.test.js +2 -2
  256. package/providers/{beta/openlayers → openlayers}/src/openlayersProvider.js +3 -3
  257. package/providers/{beta/openlayers → openlayers}/src/utils/highlightFeatures.js +1 -1
  258. package/providers/{beta/openlayers → openlayers}/src/utils/patternImages.js +1 -1
  259. package/providers/{beta/openlayers → openlayers}/src/utils/symbolImages.js +1 -1
  260. package/rollup.esm.mjs +43 -47
  261. package/sonar-project.properties +1 -1
  262. package/src/App/App.jsx +4 -1
  263. package/src/App/App.test.jsx +6 -0
  264. package/src/App/components/MapButton/MapButton.jsx +6 -0
  265. package/src/App/components/MapButton/MapButton.test.jsx +10 -0
  266. package/src/App/components/Markers/Markers.jsx +3 -5
  267. package/src/App/components/Markers/Markers.test.jsx +9 -11
  268. package/src/App/components/Panel/Panel.jsx +2 -9
  269. package/src/App/hooks/useInterfaceAPI.js +16 -4
  270. package/src/App/hooks/useInterfaceAPI.test.js +66 -1
  271. package/src/App/renderer/PluginInits.jsx +8 -7
  272. package/src/App/renderer/PluginInits.test.jsx +20 -5
  273. package/src/App/renderer/SlotItemsProvider.jsx +33 -0
  274. package/src/App/renderer/SlotItemsProvider.test.jsx +59 -0
  275. package/src/App/renderer/SlotRenderer.jsx +3 -14
  276. package/src/App/renderer/SlotRenderer.test.jsx +11 -44
  277. package/src/App/renderer/mapButtons.js +24 -12
  278. package/src/App/renderer/mapButtons.test.js +32 -1
  279. package/src/App/renderer/mapControls.js +6 -8
  280. package/src/App/renderer/mapControls.test.js +10 -0
  281. package/src/App/renderer/mapPanels.js +16 -19
  282. package/src/App/renderer/mapPanels.test.js +37 -9
  283. package/src/App/renderer/pluginWrapper.js +10 -8
  284. package/src/App/renderer/pluginWrapper.test.js +23 -9
  285. package/src/App/renderer/slotAggregator.js +18 -5
  286. package/src/App/renderer/slotAggregator.test.js +68 -25
  287. package/src/App/renderer/slotHelpers.js +13 -0
  288. package/src/App/renderer/slotHelpers.test.js +16 -1
  289. package/src/App/store/AppProvider.jsx +19 -1
  290. package/src/App/store/AppProvider.test.jsx +41 -0
  291. package/src/App/store/MapProvider.jsx +3 -0
  292. package/src/App/store/MapProvider.test.jsx +24 -0
  293. package/src/App/store/appActionsMap.js +10 -1
  294. package/src/App/store/appActionsMap.test.js +21 -0
  295. package/src/App/store/appDispatchMiddleware.js +29 -17
  296. package/src/App/store/appDispatchMiddleware.test.js +31 -0
  297. package/src/InteractiveMap/parseDataProperties.js +4 -4
  298. package/src/InteractiveMap/parseDataProperties.test.js +62 -6
  299. package/src/config/events.js +4 -2
  300. package/src/config/mapSizeScales.js +3 -0
  301. package/src/scss/tools/_govuk-content.scss +4 -3
  302. package/src/types.js +4 -0
  303. package/src/utils/focusAfterPanelClose.js +9 -0
  304. package/src/utils/focusAfterPanelClose.test.js +40 -0
  305. package/webpack.dev.mjs +9 -3
  306. package/webpack.prod.mjs +11 -4
  307. package/webpack.umd.mjs +6 -7
  308. package/plugins/beta/draw-es/dist/esm/index.js +0 -1
  309. package/plugins/beta/draw-ml/dist/esm/im-draw-ml-plugin.js +0 -1
  310. package/plugins/beta/draw-ml/dist/esm/index.js +0 -1
  311. package/plugins/beta/draw-ml/dist/umd/im-draw-ml-plugin.js +0 -1
  312. package/plugins/beta/draw-ml/dist/umd/index.js +0 -2
  313. package/plugins/beta/draw-ml/src/DrawInit.jsx +0 -85
  314. package/plugins/beta/draw-ml/src/api/addFeature.js +0 -27
  315. package/plugins/beta/draw-ml/src/api/deleteFeature.js +0 -13
  316. package/plugins/beta/draw-ml/src/api/editFeature.js +0 -75
  317. package/plugins/beta/draw-ml/src/api/merge.js +0 -9
  318. package/plugins/beta/draw-ml/src/api/newLine.js +0 -68
  319. package/plugins/beta/draw-ml/src/api/newPolygon.js +0 -68
  320. package/plugins/beta/draw-ml/src/api/split.js +0 -81
  321. package/plugins/beta/draw-ml/src/defaults.js +0 -17
  322. package/plugins/beta/draw-ml/src/draw.scss +0 -26
  323. package/plugins/beta/draw-ml/src/events.js +0 -185
  324. package/plugins/beta/draw-ml/src/index.js +0 -13
  325. package/plugins/beta/draw-ml/src/manifest.js +0 -110
  326. package/plugins/beta/draw-ml/src/mapboxDraw.js +0 -143
  327. package/plugins/beta/draw-ml/src/mapboxSnap.js +0 -321
  328. package/plugins/beta/draw-ml/src/modes/createDrawMode.js +0 -552
  329. package/plugins/beta/draw-ml/src/modes/disabledMode.js +0 -23
  330. package/plugins/beta/draw-ml/src/modes/drawLineMode.js +0 -18
  331. package/plugins/beta/draw-ml/src/modes/drawPolygonMode.js +0 -16
  332. package/plugins/beta/draw-ml/src/modes/editVertex/geometryHelpers.js +0 -135
  333. package/plugins/beta/draw-ml/src/modes/editVertex/helpers.js +0 -2
  334. package/plugins/beta/draw-ml/src/modes/editVertex/touchHandlers.js +0 -142
  335. package/plugins/beta/draw-ml/src/modes/editVertex/undoHandlers.js +0 -133
  336. package/plugins/beta/draw-ml/src/modes/editVertex/vertexOperations.js +0 -142
  337. package/plugins/beta/draw-ml/src/modes/editVertex/vertexQueries.js +0 -121
  338. package/plugins/beta/draw-ml/src/modes/editVertexMode.js +0 -495
  339. package/plugins/beta/draw-ml/src/reducer.js +0 -90
  340. package/plugins/beta/draw-ml/src/styles.js +0 -190
  341. package/plugins/beta/draw-ml/src/undoStack.js +0 -50
  342. package/plugins/beta/draw-ml/src/utils/debounce.js +0 -16
  343. package/plugins/beta/draw-ml/src/utils/flattenStyleProperties.js +0 -49
  344. package/plugins/beta/draw-ml/src/utils/snapHelpers.js +0 -200
  345. package/plugins/beta/draw-ml/src/utils/spatial.js +0 -258
  346. package/plugins/beta/draw-ol/dist/css/index.css +0 -1
  347. package/plugins/beta/draw-ol/dist/esm/DrawMode.js +0 -1
  348. package/plugins/beta/draw-ol/dist/esm/EditMode.js +0 -1
  349. package/plugins/beta/draw-ol/dist/esm/geometryHelpers.js +0 -1
  350. package/plugins/beta/draw-ol/dist/esm/im-draw-ol-plugin.js +0 -1
  351. package/plugins/beta/draw-ol/dist/esm/index.js +0 -1
  352. package/plugins/beta/draw-ol/src/DrawInit.jsx +0 -65
  353. package/plugins/beta/draw-ol/src/api/addFeature.js +0 -29
  354. package/plugins/beta/draw-ol/src/api/deleteFeature.js +0 -11
  355. package/plugins/beta/draw-ol/src/api/editFeature.js +0 -50
  356. package/plugins/beta/draw-ol/src/api/newLine.js +0 -44
  357. package/plugins/beta/draw-ol/src/api/newPolygon.js +0 -44
  358. package/plugins/beta/draw-ol/src/core/OLDrawManager.js +0 -153
  359. package/plugins/beta/draw-ol/src/core/featureStore.js +0 -65
  360. package/plugins/beta/draw-ol/src/core/styles.js +0 -98
  361. package/plugins/beta/draw-ol/src/core/undoStack.js +0 -31
  362. package/plugins/beta/draw-ol/src/defaults.js +0 -16
  363. package/plugins/beta/draw-ol/src/draw/DrawMode.js +0 -121
  364. package/plugins/beta/draw-ol/src/draw/drawInput.js +0 -243
  365. package/plugins/beta/draw-ol/src/draw.scss +0 -17
  366. package/plugins/beta/draw-ol/src/edit/EditMode.js +0 -424
  367. package/plugins/beta/draw-ol/src/edit/keyboardHandler.js +0 -229
  368. package/plugins/beta/draw-ol/src/edit/midpointLayer.js +0 -57
  369. package/plugins/beta/draw-ol/src/edit/touchHandler.js +0 -171
  370. package/plugins/beta/draw-ol/src/edit/undoOps.js +0 -95
  371. package/plugins/beta/draw-ol/src/edit/vertexHitTest.js +0 -72
  372. package/plugins/beta/draw-ol/src/edit/vertexLayer.js +0 -49
  373. package/plugins/beta/draw-ol/src/edit/vertexOps.js +0 -99
  374. package/plugins/beta/draw-ol/src/events.js +0 -114
  375. package/plugins/beta/draw-ol/src/index.js +0 -12
  376. package/plugins/beta/draw-ol/src/manifest.js +0 -125
  377. package/plugins/beta/draw-ol/src/olDraw.js +0 -38
  378. package/plugins/beta/draw-ol/src/reducer.js +0 -41
  379. package/plugins/beta/draw-ol/src/snap/snapEngine.js +0 -153
  380. package/plugins/beta/draw-ol/src/snap/snapGeometry.js +0 -177
  381. package/plugins/beta/draw-ol/src/snap/snapIndicator.js +0 -81
  382. package/plugins/beta/draw-ol/src/snap/snapInteraction.js +0 -57
  383. package/plugins/beta/draw-ol/src/snap/snapManager.js +0 -99
  384. package/plugins/beta/draw-ol/src/utils/flattenStyleProperties.js +0 -47
  385. package/plugins/beta/draw-ol/src/utils/geometryHelpers.js +0 -103
  386. package/plugins/beta/draw-ol/src/utils/olCoords.js +0 -35
  387. package/plugins/beta/draw-ol/src/utils/resolveColors.js +0 -39
  388. package/plugins/beta/draw-ol/src/utils/spatial.js +0 -24
  389. package/plugins/beta/draw-ol/src/utils/touchTarget.js +0 -61
  390. package/plugins/beta/frame/dist/esm/index.js +0 -1
  391. package/plugins/beta/map-styles/dist/esm/im-map-styles-plugin.js +0 -1
  392. package/plugins/beta/map-styles/dist/esm/index.js +0 -1
  393. package/plugins/beta/map-styles/dist/umd/im-map-styles-plugin.js +0 -1
  394. package/plugins/beta/scale-bar/dist/esm/index.js +0 -1
  395. package/plugins/beta/use-location/dist/esm/index.js +0 -1
  396. package/plugins/map-key/src/registry/getDatasetRegistry.js +0 -6
  397. package/plugins/map-key/src/registry/getDatasetRegistry.test.js +0 -23
  398. package/plugins/map-key/src/registry/index.js +0 -1
  399. package/plugins/map-key/src/registry/index.test.js +0 -7
  400. package/providers/beta/esri/dist/esm/index.js +0 -1
  401. package/providers/beta/open-names/dist/esm/index.js +0 -1
  402. package/providers/beta/openlayers/dist/esm/index.js +0 -1
  403. package/providers/beta/openlayers/dist/umd/im-openlayers-provider.js +0 -2
  404. package/providers/beta/openlayers/dist/umd/index.js.LICENSE.txt +0 -1
  405. /package/plugins/{beta/draw-es → draw-es}/dist/esm/im-draw-es-plugin.js +0 -0
  406. /package/plugins/{beta/draw-es → draw-es}/src/api/addFeature.js +0 -0
  407. /package/plugins/{beta/draw-es → draw-es}/src/api/deleteFeature.js +0 -0
  408. /package/plugins/{beta/draw-es → draw-es}/src/api/editFeature.js +0 -0
  409. /package/plugins/{beta/draw-es → draw-es}/src/api/newPolygon.js +0 -0
  410. /package/plugins/{beta/draw-es → draw-es}/src/api/removeSafeZone.js +0 -0
  411. /package/plugins/{beta/draw-es → draw-es}/src/events.js +0 -0
  412. /package/plugins/{beta/draw-es → draw-es}/src/index.js +0 -0
  413. /package/plugins/{beta/draw-es → draw-es}/src/manifest.js +0 -0
  414. /package/plugins/{beta/draw-es → draw-es}/src/reducer.js +0 -0
  415. /package/plugins/{beta/draw-es → draw-es}/src/sketchViewModel.js +0 -0
  416. /package/plugins/{beta/frame → frame}/dist/css/index.css +0 -0
  417. /package/plugins/{beta/frame → frame}/dist/esm/im-frame-plugin.js +0 -0
  418. /package/plugins/{beta/draw-ml → frame}/dist/umd/index.js.LICENSE.txt +0 -0
  419. /package/plugins/{beta/frame → frame}/src/Frame.jsx +0 -0
  420. /package/plugins/{beta/frame → frame}/src/FrameInit.jsx +0 -0
  421. /package/plugins/{beta/frame → frame}/src/api/addFrame.js +0 -0
  422. /package/plugins/{beta/frame → frame}/src/api/editFeature.js +0 -0
  423. /package/plugins/{beta/frame → frame}/src/config.js +0 -0
  424. /package/plugins/{beta/frame → frame}/src/frame.scss +0 -0
  425. /package/plugins/{beta/frame → frame}/src/index.js +0 -0
  426. /package/plugins/{beta/frame → frame}/src/manifest.js +0 -0
  427. /package/plugins/{beta/frame → frame}/src/reducer.js +0 -0
  428. /package/plugins/{beta/frame → frame}/src/utils.js +0 -0
  429. /package/plugins/{beta/map-styles → map-styles}/dist/css/index.css +0 -0
  430. /package/plugins/{beta/frame → map-styles}/dist/umd/index.js.LICENSE.txt +0 -0
  431. /package/plugins/{beta/map-styles → map-styles}/src/config.js +0 -0
  432. /package/plugins/{beta/map-styles → map-styles}/src/index.js +0 -0
  433. /package/plugins/{beta/map-styles → map-styles}/src/manifest.js +0 -0
  434. /package/plugins/{beta/map-styles → map-styles}/src/mapStyles.scss +0 -0
  435. /package/plugins/{beta/scale-bar → scale-bar}/dist/css/index.css +0 -0
  436. /package/plugins/{beta/scale-bar → scale-bar}/dist/esm/im-scale-bar-plugin.js +0 -0
  437. /package/plugins/{beta/map-styles → scale-bar}/dist/umd/index.js.LICENSE.txt +0 -0
  438. /package/plugins/{beta/scale-bar → scale-bar}/src/ScaleBar.jsx +0 -0
  439. /package/plugins/{beta/scale-bar → scale-bar}/src/ScaleBar.test.jsx +0 -0
  440. /package/plugins/{beta/scale-bar → scale-bar}/src/index.js +0 -0
  441. /package/plugins/{beta/scale-bar → scale-bar}/src/index.test.js +0 -0
  442. /package/plugins/{beta/scale-bar → scale-bar}/src/manifest.js +0 -0
  443. /package/plugins/{beta/scale-bar → scale-bar}/src/scaleBar.scss +0 -0
  444. /package/plugins/{beta/scale-bar → scale-bar}/src/utils.js +0 -0
  445. /package/plugins/{beta/scale-bar → scale-bar}/src/utils.test.js +0 -0
  446. /package/plugins/{beta/use-location → use-location}/dist/esm/im-use-location-plugin.js +0 -0
  447. /package/plugins/{beta/scale-bar → use-location}/dist/umd/index.js.LICENSE.txt +0 -0
  448. /package/plugins/{beta/use-location → use-location}/src/UseLocation.jsx +0 -0
  449. /package/plugins/{beta/use-location → use-location}/src/UseLocationInit.jsx +0 -0
  450. /package/plugins/{beta/use-location → use-location}/src/defaults.js +0 -0
  451. /package/plugins/{beta/use-location → use-location}/src/events.js +0 -0
  452. /package/plugins/{beta/use-location → use-location}/src/index.js +0 -0
  453. /package/plugins/{beta/use-location → use-location}/src/manifest.js +0 -0
  454. /package/plugins/{beta/use-location → use-location}/src/reducer.js +0 -0
  455. /package/providers/{beta/esri → esri}/dist/css/index.css +0 -0
  456. /package/providers/{beta/esri → esri}/dist/esm/im-esri-provider.js +0 -0
  457. /package/providers/{beta/esri → esri}/src/appEvents.js +0 -0
  458. /package/providers/{beta/esri → esri}/src/defaults.js +0 -0
  459. /package/providers/{beta/esri → esri}/src/esriProvider.scss +0 -0
  460. /package/providers/{beta/esri → esri}/src/index.js +0 -0
  461. /package/providers/{beta/esri → esri}/src/utils/coords.js +0 -0
  462. /package/providers/{beta/esri → esri}/src/utils/coords.test.js +0 -0
  463. /package/providers/{beta/esri → esri}/src/utils/detectWebGL.js +0 -0
  464. /package/providers/{beta/esri → esri}/src/utils/esriFixes.js +0 -0
  465. /package/providers/{beta/esri → esri}/src/utils/query.js +0 -0
  466. /package/providers/{beta/esri → esri}/src/utils/spatial.js +0 -0
  467. /package/providers/{beta/esri → esri}/src/utils/spatial.test.js +0 -0
  468. /package/providers/{beta/open-names → open-names}/dist/esm/im-reverse-geocode.js +0 -0
  469. /package/providers/{beta/open-names → open-names}/dist/umd/im-reverse-geocode.js.LICENSE.txt +0 -0
  470. /package/{plugins/beta/use-location → providers/open-names}/dist/umd/index.js.LICENSE.txt +0 -0
  471. /package/providers/{beta/open-names → open-names}/src/index.js +0 -0
  472. /package/providers/{beta/open-names → open-names}/src/reverseGeocode.js +0 -0
  473. /package/providers/{beta/open-names → open-names}/src/utils/mapToLocationModel.js +0 -0
  474. /package/providers/{beta/open-names → open-names}/src/utils/mapToLocationModel.test.js +0 -0
  475. /package/providers/{beta/openlayers → openlayers}/dist/esm/im-openlayers-provider.js +0 -0
  476. /package/providers/{beta/openlayers → openlayers}/dist/umd/im-openlayers-provider.js.LICENSE.txt +0 -0
  477. /package/providers/{beta/open-names → openlayers}/dist/umd/index.js.LICENSE.txt +0 -0
  478. /package/providers/{beta/openlayers → openlayers}/src/appEvents.js +0 -0
  479. /package/providers/{beta/openlayers → openlayers}/src/appEvents.test.js +0 -0
  480. /package/providers/{beta/openlayers → openlayers}/src/defaults.js +0 -0
  481. /package/providers/{beta/openlayers → openlayers}/src/index.test.js +0 -0
  482. /package/providers/{beta/openlayers → openlayers}/src/openlayersProvider.test.js +0 -0
  483. /package/providers/{beta/openlayers → openlayers}/src/utils/bngProjection.js +0 -0
  484. /package/providers/{beta/openlayers → openlayers}/src/utils/filterEvaluator.js +0 -0
  485. /package/providers/{beta/openlayers → openlayers}/src/utils/filterEvaluator.test.js +0 -0
  486. /package/providers/{beta/openlayers → openlayers}/src/utils/highlightFeatures.test.js +0 -0
  487. /package/providers/{beta/openlayers → openlayers}/src/utils/hoverCursor.js +0 -0
  488. /package/providers/{beta/openlayers → openlayers}/src/utils/hoverCursor.test.js +0 -0
  489. /package/providers/{beta/openlayers → openlayers}/src/utils/openLayersFixes.js +0 -0
  490. /package/providers/{beta/openlayers → openlayers}/src/utils/openLayersFixes.test.js +0 -0
  491. /package/providers/{beta/openlayers → openlayers}/src/utils/patternImages.test.js +0 -0
  492. /package/providers/{beta/openlayers → openlayers}/src/utils/queryFeatures.js +0 -0
  493. /package/providers/{beta/openlayers → openlayers}/src/utils/queryFeatures.test.js +0 -0
  494. /package/providers/{beta/openlayers → openlayers}/src/utils/spatial.js +0 -0
  495. /package/providers/{beta/openlayers → openlayers}/src/utils/spatial.test.js +0 -0
  496. /package/providers/{beta/openlayers → openlayers}/src/utils/symbolImages.test.js +0 -0
  497. /package/providers/{beta/openlayers → openlayers}/src/utils/tileLayers.js +0 -0
  498. /package/providers/{beta/openlayers → openlayers}/src/utils/tileLayers.test.js +0 -0
  499. /package/providers/{beta/openlayers → openlayers}/src/utils/vtTileFragments.js +0 -0
  500. /package/providers/{beta/openlayers → openlayers}/src/utils/vtTileFragments.test.js +0 -0
  501. /package/providers/{beta/openlayers → openlayers}/src/utils/zoom.js +0 -0
  502. /package/providers/{beta/openlayers → openlayers}/src/utils/zoom.test.js +0 -0
@@ -1,2 +1,2 @@
1
1
  /*! For license information please see index.js.LICENSE.txt */
2
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("defra",[],t):"object"==typeof exports?exports.defra=t():(e.defra=e.defra||{},e.defra.mapKeyPlugin=t())}(Object("undefined"!=typeof self?self:this),function(){return function(){"use strict";var e,t,r={738:function(e){e.exports=preactCompat},287:function(e){e.exports=preactJsxRuntime}},n={};function o(e){var t=n[e];if(void 0!==t)return t.exports;var i=n[e]={exports:{}};return r[e](i,i.exports,o),i.exports}o.m=r,o.d=function(e,t){for(var r in t)o.o(t,r)&&!o.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},o.f={},o.e=function(e){return Promise.all(Object.keys(o.f).reduce(function(t,r){return o.f[r](e,t),t},[]))},o.u=function(e){return"im-map-key-plugin.js"},o.miniCssF=function(e){},o.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},e={},t="defra.mapKeyPlugin:",o.l=function(r,n,i,u){if(e[r])e[r].push(n);else{var c,a;if(void 0!==i)for(var f=document.getElementsByTagName("script"),p=0;p<f.length;p++){var l=f[p];if(l.getAttribute("src")==r||l.getAttribute("data-webpack")==t+i){c=l;break}}c||(a=!0,(c=document.createElement("script")).charset="utf-8",o.nc&&c.setAttribute("nonce",o.nc),c.setAttribute("data-webpack",t+i),c.src=r),e[r]=[n];var s=function(t,n){c.onerror=c.onload=null,clearTimeout(d);var o=e[r];if(delete e[r],c.parentNode&&c.parentNode.removeChild(c),o&&o.forEach(function(e){return e(n)}),t)return t(n)},d=setTimeout(s.bind(null,void 0,{type:"timeout",target:c}),12e4);c.onerror=s.bind(null,c.onerror),c.onload=s.bind(null,c.onload),a&&document.head.appendChild(c)}},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},function(){var e;o.g.importScripts&&(e=o.g.location+"");var t=o.g.document;if(!e&&t&&(t.currentScript&&"SCRIPT"===t.currentScript.tagName.toUpperCase()&&(e=t.currentScript.src),!e)){var r=t.getElementsByTagName("script");if(r.length)for(var n=r.length-1;n>-1&&(!e||!/^http(s?):/.test(e));)e=r[n--].src}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),o.p=e}(),function(){var e={57:0};o.f.j=function(t,r){var n=o.o(e,t)?e[t]:void 0;if(0!==n)if(n)r.push(n[2]);else{var i=new Promise(function(r,o){n=e[t]=[r,o]});r.push(n[2]=i);var u=o.p+o.u(t),c=new Error;o.l(u,function(r){if(o.o(e,t)&&(0!==(n=e[t])&&(e[t]=void 0),n)){var i=r&&("load"===r.type?"missing":r.type),u=r&&r.target&&r.target.src;c.message="Loading chunk "+t+" failed.\n("+i+": "+u+")",c.name="ChunkLoadError",c.type=i,c.request=u,n[1](c)}},"chunk-"+t,t)}};var t=function(t,r){var n,i,u=r[0],c=r[1],a=r[2],f=0;if(u.some(function(t){return 0!==e[t]})){for(n in c)o.o(c,n)&&(o.m[n]=c[n]);a&&a(o)}for(t&&t(r);f<u.length;f++)i=u[f],o.o(e,i)&&e[i]&&e[i][0](),e[i]=0},r=Object("undefined"!=typeof self?self:this).webpackChunkdefra_DefraMap=Object("undefined"!=typeof self?self:this).webpackChunkdefra_DefraMap||[];r.forEach(t.bind(null,0)),r.push=t.bind(null,r.push.bind(r))}();var i={};function u(e){return u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},u(e)}function c(){var e,t,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function i(r,n,o,i){var c=n&&n.prototype instanceof f?n:f,p=Object.create(c.prototype);return a(p,"_invoke",function(r,n,o){var i,c,a,f=0,p=o||[],l=!1,s={p:0,n:0,v:e,a:d,f:d.bind(e,4),d:function(t,r){return i=t,c=0,a=e,s.n=r,u}};function d(r,n){for(c=r,a=n,t=0;!l&&f&&!o&&t<p.length;t++){var o,i=p[t],d=s.p,b=i[2];r>3?(o=b===n)&&(a=i[(c=i[4])?5:(c=3,3)],i[4]=i[5]=e):i[0]<=d&&((o=r<2&&d<i[1])?(c=0,s.v=n,s.n=i[1]):d<b&&(o=r<3||i[0]>n||n>b)&&(i[4]=r,i[5]=n,s.n=b,c=0))}if(o||r>1)return u;throw l=!0,n}return function(o,p,b){if(f>1)throw TypeError("Generator is already running");for(l&&1===p&&d(p,b),c=p,a=b;(t=c<2?e:a)||!l;){i||(c?c<3?(c>1&&(s.n=-1),d(c,a)):s.n=a:s.v=a);try{if(f=2,i){if(c||(o="next"),t=i[o]){if(!(t=t.call(i,a)))throw TypeError("iterator result is not an object");if(!t.done)return t;a=t.value,c<2&&(c=0)}else 1===c&&(t=i.return)&&t.call(i),c<2&&(a=TypeError("The iterator does not provide a '"+o+"' method"),c=1);i=e}else if((t=(l=s.n<0)?a:r.call(n,s))!==u)break}catch(t){i=e,c=1,a=t}finally{f=1}}return{value:t,done:l}}}(r,o,i),!0),p}var u={};function f(){}function p(){}function l(){}t=Object.getPrototypeOf;var s=[][n]?t(t([][n]())):(a(t={},n,function(){return this}),t),d=l.prototype=f.prototype=Object.create(s);function b(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,a(e,o,"GeneratorFunction")),e.prototype=Object.create(d),e}return p.prototype=l,a(d,"constructor",l),a(l,"constructor",p),p.displayName="GeneratorFunction",a(l,o,"GeneratorFunction"),a(d),a(d,o,"Generator"),a(d,n,function(){return this}),a(d,"toString",function(){return"[object Generator]"}),(c=function(){return{w:i,m:b}})()}function a(e,t,r,n){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}a=function(e,t,r,n){function i(t,r){a(e,t,function(e){return this._invoke(t,r,e)})}t?o?o(e,t,{value:r,enumerable:!n,configurable:!n,writable:!n}):e[t]=r:(i("next",0),i("throw",1),i("return",2))},a(e,t,r,n)}function f(e,t,r,n,o,i,u){try{var c=e[i](u),a=c.value}catch(e){return void r(e)}c.done?t(a):Promise.resolve(a).then(n,o)}function p(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function l(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?p(Object(r),!0).forEach(function(t){s(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):p(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function s(e,t,r){return(t=function(e){var t=function(e){if("object"!=u(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=u(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==u(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function d(){var e,t;return l(l({noKeyItemText:"No features displayed"},arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),{},{id:"mapKey",load:(e=c().m(function e(){var t;return c().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,o.e(414).then(o.bind(o,718));case 1:return t=e.v.manifest,e.a(2,t)}},e)}),t=function(){var t=this,r=arguments;return new Promise(function(n,o){var i=e.apply(t,r);function u(e){f(i,n,o,u,c,"next",e)}function c(e){f(i,n,o,u,c,"throw",e)}u(void 0)})},function(){return t.apply(this,arguments)})})}return o.d(i,{default:function(){return d}}),i.default}()});
2
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("defra",[],t):"object"==typeof exports?exports.defra=t():(e.defra=e.defra||{},e.defra.mapKeyPlugin=t())}(Object("undefined"!=typeof self?self:this),function(){return function(){"use strict";var e,t,r={738:function(e){e.exports=preactCompat},287:function(e){e.exports=preactJsxRuntime}},n={};function o(e){var t=n[e];if(void 0!==t)return t.exports;var i=n[e]={exports:{}};return r[e](i,i.exports,o),i.exports}o.m=r,o.d=function(e,t){for(var r in t)o.o(t,r)&&!o.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},o.f={},o.e=function(e){return Promise.all(Object.keys(o.f).reduce(function(t,r){return o.f[r](e,t),t},[]))},o.u=function(e){return"im-map-key-plugin.js"},o.miniCssF=function(e){},o.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},e={},t="defra.mapKeyPlugin:",o.l=function(r,n,i,u){if(e[r])e[r].push(n);else{var c,a;if(void 0!==i)for(var f=document.getElementsByTagName("script"),p=0;p<f.length;p++){var l=f[p];if(l.getAttribute("src")==r||l.getAttribute("data-webpack")==t+i){c=l;break}}c||(a=!0,(c=document.createElement("script")).charset="utf-8",o.nc&&c.setAttribute("nonce",o.nc),c.setAttribute("data-webpack",t+i),c.src=r),e[r]=[n];var s=function(t,n){c.onerror=c.onload=null,clearTimeout(d);var o=e[r];if(delete e[r],c.parentNode&&c.parentNode.removeChild(c),o&&o.forEach(function(e){return e(n)}),t)return t(n)},d=setTimeout(s.bind(null,void 0,{type:"timeout",target:c}),12e4);c.onerror=s.bind(null,c.onerror),c.onload=s.bind(null,c.onload),a&&document.head.appendChild(c)}},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},function(){var e;o.g.importScripts&&(e=o.g.location+"");var t=o.g.document;if(!e&&t&&(t.currentScript&&"SCRIPT"===t.currentScript.tagName.toUpperCase()&&(e=t.currentScript.src),!e)){var r=t.getElementsByTagName("script");if(r.length)for(var n=r.length-1;n>-1&&(!e||!/^http(s?):/.test(e));)e=r[n--].src}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),o.p=e}(),function(){var e={57:0};o.f.j=function(t,r){var n=o.o(e,t)?e[t]:void 0;if(0!==n)if(n)r.push(n[2]);else{var i=new Promise(function(r,o){n=e[t]=[r,o]});r.push(n[2]=i);var u=o.p+o.u(t),c=new Error;o.l(u,function(r){if(o.o(e,t)&&(0!==(n=e[t])&&(e[t]=void 0),n)){var i=r&&("load"===r.type?"missing":r.type),u=r&&r.target&&r.target.src;c.message="Loading chunk "+t+" failed.\n("+i+": "+u+")",c.name="ChunkLoadError",c.type=i,c.request=u,n[1](c)}},"chunk-"+t,t)}};var t=function(t,r){var n,i,u=r[0],c=r[1],a=r[2],f=0;if(u.some(function(t){return 0!==e[t]})){for(n in c)o.o(c,n)&&(o.m[n]=c[n]);a&&a(o)}for(t&&t(r);f<u.length;f++)i=u[f],o.o(e,i)&&e[i]&&e[i][0](),e[i]=0},r=Object("undefined"!=typeof self?self:this).webpackChunkdefra_DefraMap=Object("undefined"!=typeof self?self:this).webpackChunkdefra_DefraMap||[];r.forEach(t.bind(null,0)),r.push=t.bind(null,r.push.bind(r))}();var i={};function u(e){return u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},u(e)}function c(){var e,t,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function i(r,n,o,i){var c=n&&n.prototype instanceof f?n:f,p=Object.create(c.prototype);return a(p,"_invoke",function(r,n,o){var i,c,a,f=0,p=o||[],l=!1,s={p:0,n:0,v:e,a:d,f:d.bind(e,4),d:function(t,r){return i=t,c=0,a=e,s.n=r,u}};function d(r,n){for(c=r,a=n,t=0;!l&&f&&!o&&t<p.length;t++){var o,i=p[t],d=s.p,b=i[2];r>3?(o=b===n)&&(a=i[(c=i[4])?5:(c=3,3)],i[4]=i[5]=e):i[0]<=d&&((o=r<2&&d<i[1])?(c=0,s.v=n,s.n=i[1]):d<b&&(o=r<3||i[0]>n||n>b)&&(i[4]=r,i[5]=n,s.n=b,c=0))}if(o||r>1)return u;throw l=!0,n}return function(o,p,b){if(f>1)throw TypeError("Generator is already running");for(l&&1===p&&d(p,b),c=p,a=b;(t=c<2?e:a)||!l;){i||(c?c<3?(c>1&&(s.n=-1),d(c,a)):s.n=a:s.v=a);try{if(f=2,i){if(c||(o="next"),t=i[o]){if(!(t=t.call(i,a)))throw TypeError("iterator result is not an object");if(!t.done)return t;a=t.value,c<2&&(c=0)}else 1===c&&(t=i.return)&&t.call(i),c<2&&(a=TypeError("The iterator does not provide a '"+o+"' method"),c=1);i=e}else if((t=(l=s.n<0)?a:r.call(n,s))!==u)break}catch(t){i=e,c=1,a=t}finally{f=1}}return{value:t,done:l}}}(r,o,i),!0),p}var u={};function f(){}function p(){}function l(){}t=Object.getPrototypeOf;var s=[][n]?t(t([][n]())):(a(t={},n,function(){return this}),t),d=l.prototype=f.prototype=Object.create(s);function b(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,a(e,o,"GeneratorFunction")),e.prototype=Object.create(d),e}return p.prototype=l,a(d,"constructor",l),a(l,"constructor",p),p.displayName="GeneratorFunction",a(l,o,"GeneratorFunction"),a(d),a(d,o,"Generator"),a(d,n,function(){return this}),a(d,"toString",function(){return"[object Generator]"}),(c=function(){return{w:i,m:b}})()}function a(e,t,r,n){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}a=function(e,t,r,n){function i(t,r){a(e,t,function(e){return this._invoke(t,r,e)})}t?o?o(e,t,{value:r,enumerable:!n,configurable:!n,writable:!n}):e[t]=r:(i("next",0),i("throw",1),i("return",2))},a(e,t,r,n)}function f(e,t,r,n,o,i,u){try{var c=e[i](u),a=c.value}catch(e){return void r(e)}c.done?t(a):Promise.resolve(a).then(n,o)}function p(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function l(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?p(Object(r),!0).forEach(function(t){s(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):p(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function s(e,t,r){return(t=function(e){var t=function(e){if("object"!=u(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=u(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==u(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function d(){var e,t;return l(l({noKeyItemText:"No features displayed"},arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),{},{id:"mapKey",load:(e=c().m(function e(){var t;return c().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,o.e(414).then(o.bind(o,883));case 1:return t=e.v.manifest,e.a(2,t)}},e)}),t=function(){var t=this,r=arguments;return new Promise(function(n,o){var i=e.apply(t,r);function u(e){f(i,n,o,u,c,"next",e)}function c(e){f(i,n,o,u,c,"throw",e)}u(void 0)})},function(){return t.apply(this,arguments)})})}return o.d(i,{default:function(){return d}}),i.default}()});
@@ -18,9 +18,13 @@ export const KeySvgSymbol = ({ keySymbol }) => {
18
18
  const drawnWidth = width * scale
19
19
  const drawnHeight = height * scale
20
20
 
21
+ // The symbol is decorative: the key item's text labels it. The outer svg is aria-hidden via
22
+ // svgSymbolProps, which already hides the inner one; the inner one repeats aria-hidden so it
23
+ // can't be exposed as a second, unnamed graphic.
21
24
  return (
22
25
  <svg {...svgSymbolProps} overflow='visible'>
23
26
  <svg
27
+ aria-hidden='true'
24
28
  x={(SVG_SYMBOL_SIZE - drawnWidth) * HALF}
25
29
  y={(SVG_SYMBOL_SIZE - drawnHeight) * HALF}
26
30
  width={drawnWidth}
@@ -1,5 +1,4 @@
1
- import React, { useState, useEffect } from 'react'
2
- import { getDatasetRegistry } from '../../registry/index.js'
1
+ import React, { useState, useEffect, useRef } from 'react'
3
2
  import { mergeKeyGroupItems } from '../../reducers/mergeKeyGroupItems.js'
4
3
  import { Key } from './Key.jsx'
5
4
 
@@ -9,7 +8,10 @@ export function MapKey ({
9
8
  pluginState,
10
9
  services: { eventBus, symbolRegistry, patternRegistry }
11
10
  }) {
12
- const [datasetRegistry, setDatasetRegistry] = useState(getDatasetRegistry())
11
+ const { datasetRegistry } = pluginState
12
+ // The event handlers below outlive the render that registers them, so they read the latest state
13
+ const pluginStateRef = useRef(pluginState)
14
+ pluginStateRef.current = pluginState
13
15
  // Lazily seed from the registry (already populated whenever the key is opened after
14
16
  // datasets:ready) so the first paint shows real content instead of flashing the empty
15
17
  // state while the effect below catches up on the next tick.
@@ -19,7 +21,7 @@ export function MapKey ({
19
21
  const getKeyItems = () => {
20
22
  const { items, hasGroups: _hasGroups } = datasetRegistry.keyItems()
21
23
  // Post Process the items - based on the map-key pluginConfig adding any groupConfigs
22
- const groupItems = mergeKeyGroupItems(items)
24
+ const groupItems = mergeKeyGroupItems(items, pluginStateRef.current)
23
25
  setKeyGroups(groupItems)
24
26
  setHasGroups(_hasGroups)
25
27
  }
@@ -30,19 +32,17 @@ export function MapKey ({
30
32
  }
31
33
 
32
34
  useEffect(() => {
35
+ // MapKeyInit puts the registry in plugin state once the datasets plugin is ready
33
36
  if (!datasetRegistry) {
34
- // 'datasets:registry' is only required when the key is opened before datasets:ready
35
- eventBus.requestOnce('datasets:registry', setDatasetRegistry)
36
- return () => {}
37
- } else {
38
- getKeyItems() // populate the initial KeyItems from the datasetRegistry (which caches them)
39
- eventBus
40
- .on('menu:changed', onMenuChanged) // Ensure keyItems refresh when menu updates
41
- .on('datasets:changed', getKeyItems) // Ensure keyItems refresh when datasets change
42
- return () => eventBus
43
- .off('menu:changed', onMenuChanged)
44
- .off('datasets:changed', getKeyItems)
37
+ return undefined
45
38
  }
39
+ getKeyItems() // populate the initial KeyItems from the datasetRegistry (which caches them)
40
+ eventBus
41
+ .on('menu:changed', onMenuChanged) // Ensure keyItems refresh when menu updates
42
+ .on('datasets:changed', getKeyItems) // Ensure keyItems refresh when datasets change
43
+ return () => eventBus
44
+ .off('menu:changed', onMenuChanged)
45
+ .off('datasets:changed', getKeyItems)
46
46
  }, [datasetRegistry])
47
47
 
48
48
  useEffect(() => {
@@ -1,10 +1,5 @@
1
1
  import { render, act } from '@testing-library/react'
2
2
  import { MapKey } from './MapKey'
3
- import { getDatasetRegistry } from '../../registry/index.js'
4
-
5
- jest.mock('../../registry/index.js', () => ({
6
- getDatasetRegistry: jest.fn()
7
- }))
8
3
 
9
4
  // eslint-disable-next-line no-var -- jest.mock factories may only reference vars prefixed "mock"
10
5
  var mockKeyRenderCount = 0
@@ -40,9 +35,12 @@ const makeRegistry = (items = [], hasGroups = false) => ({
40
35
  })
41
36
 
42
37
  let eventBus
43
- const baseProps = () => ({
38
+ // This map's datasets registry, which MapKeyInit puts in plugin state
39
+ let datasetRegistry
40
+ const baseProps = (pluginState = {}) => ({
44
41
  mapState: { mapStyle: { id: 'default' } },
45
42
  pluginConfig: { noKeyItemText: 'No items' },
43
+ pluginState: { datasetRegistry, ...pluginState },
46
44
  services: { eventBus }
47
45
  })
48
46
 
@@ -54,7 +52,7 @@ beforeEach(() => {
54
52
 
55
53
  describe('MapKey', () => {
56
54
  describe('when datasetRegistry is null', () => {
57
- beforeEach(() => { getDatasetRegistry.mockReturnValue(null) })
55
+ beforeEach(() => { datasetRegistry = null })
58
56
 
59
57
  it('passes empty items and hasGroups false to Key', () => {
60
58
  const { getByTestId } = render(<MapKey {...baseProps()} />)
@@ -62,17 +60,17 @@ describe('MapKey', () => {
62
60
  expect(getByTestId('key').dataset.hasGroups).toBe('false')
63
61
  })
64
62
 
65
- it('calls requestOnce for datasets:registry', () => {
63
+ it('does not request the registry itself', () => {
66
64
  render(<MapKey {...baseProps()} />)
67
- expect(eventBus.requestOnce).toHaveBeenCalledWith('datasets:registry', expect.any(Function))
65
+ expect(eventBus.requestOnce).not.toHaveBeenCalled()
68
66
  })
69
67
 
70
- it('populates key items when the registry arrives via requestOnce', () => {
71
- render(<MapKey {...baseProps()} />)
72
- const setReg = eventBus.requestOnce.mock.calls[0][1]
68
+ it('populates key items when the registry arrives in plugin state', () => {
69
+ const { rerender, getByTestId } = render(<MapKey {...baseProps()} />)
73
70
  const registry = makeRegistry([{ id: '1' }, { id: '2' }], true)
74
- act(() => { setReg(registry) })
71
+ rerender(<MapKey {...baseProps({ datasetRegistry: registry })} />)
75
72
  expect(registry.keyItems).toHaveBeenCalled()
73
+ expect(getByTestId('key').dataset.keyGroupsLength).toBe('2')
76
74
  })
77
75
  })
78
76
 
@@ -81,7 +79,7 @@ describe('MapKey', () => {
81
79
 
82
80
  beforeEach(() => {
83
81
  registry = makeRegistry([{ id: '1' }, { id: '2' }], true)
84
- getDatasetRegistry.mockReturnValue(registry)
82
+ datasetRegistry = registry
85
83
  })
86
84
 
87
85
  it('passes keyGroups and hasGroups from the registry to Key', () => {
@@ -129,10 +127,26 @@ describe('MapKey', () => {
129
127
  expect(registry.invalidateKeyItemsOnMenuStateChange).toHaveBeenCalledWith(menuState)
130
128
  expect(registry.keyItems).toHaveBeenCalledTimes(callsAtMount + 1)
131
129
  })
130
+
131
+ it('merges the latest key groups from plugin state when an event fires after they change', () => {
132
+ datasetRegistry = makeRegistry([
133
+ { id: '1', type: 'flat', keyDefinition: { id: '1' } },
134
+ { id: '2', type: 'flat', keyDefinition: { id: '2' } }
135
+ ])
136
+ const { rerender, getByTestId } = render(<MapKey {...baseProps()} />)
137
+ const groupState = {
138
+ groups: [{ id: 'manual', type: 'group', groupLabel: 'Manual' }],
139
+ keyDefinitions: [{ id: 'm1', groupId: 'manual' }]
140
+ }
141
+ rerender(<MapKey {...baseProps(groupState)} />)
142
+ const onDatasetsChanged = eventBus.on.mock.calls.find(([e]) => e === 'datasets:changed')[1]
143
+ act(() => { onDatasetsChanged() })
144
+ expect(getByTestId('key').dataset.keyGroupsLength).toBe('3')
145
+ })
132
146
  })
133
147
 
134
148
  describe('props forwarded to Key', () => {
135
- beforeEach(() => { getDatasetRegistry.mockReturnValue(null) })
149
+ beforeEach(() => { datasetRegistry = null })
136
150
 
137
151
  it('passes noKeyItemText from pluginConfig', () => {
138
152
  const { getByTestId } = render(<MapKey {...baseProps()} />)
@@ -1,21 +1,18 @@
1
- import { useEffect, useRef } from 'react'
2
- import { setDatasetRegistry } from '../registry/getDatasetRegistry.js'
3
- import { attachPluginStateRef } from '../reducers/mergeKeyGroupItems.js'
1
+ import { useEffect } from 'react'
4
2
 
5
3
  // additional possible params here are: pluginConfig, appState, mapProvider,
6
4
  export function MapKeyInit ({ pluginConfig, pluginState, mapState, services }) {
7
5
  const { dispatch } = pluginState
8
6
  const { eventBus } = services
9
- const pluginStateRef = useRef(pluginState)
10
- pluginStateRef.current = pluginState
11
7
 
12
8
  useEffect(() => {
13
9
  if (!mapState.isMapReady) {
14
10
  return
15
11
  }
16
- attachPluginStateRef(pluginStateRef)
17
- // Request a handle on the datasetsRegistry singleton
18
- eventBus.requestOnce('datasets:registry', setDatasetRegistry)
12
+ // Request this map's datasets registry, which arrives straight away if the datasets plugin is ready
13
+ eventBus.requestOnce('datasets:registry', (datasetRegistry) => {
14
+ dispatch({ type: 'SET_DATASET_REGISTRY', payload: datasetRegistry })
15
+ })
19
16
  eventBus.emit('map-key:ready')
20
17
  }, [mapState.isMapReady])
21
18
 
@@ -1,11 +1,5 @@
1
1
  import { render } from '@testing-library/react'
2
2
  import { MapKeyInit } from './MapKeyInit.jsx'
3
- import { setDatasetRegistry } from '../registry/getDatasetRegistry.js'
4
-
5
- jest.mock('../registry/getDatasetRegistry.js', () => ({
6
- setDatasetRegistry: jest.fn()
7
- }))
8
-
9
3
  const eventBus = { requestOnce: jest.fn(), emit: jest.fn() }
10
4
  const pluginState = { dispatch: jest.fn() }
11
5
  const pluginConfig = {
@@ -35,7 +29,15 @@ describe('MapKeyInit', () => {
35
29
 
36
30
  it('calls requestOnce for datasets:registry when map is ready', () => {
37
31
  renderInit({ isMapReady: true })
38
- expect(eventBus.requestOnce).toHaveBeenCalledWith('datasets:registry', setDatasetRegistry)
32
+ expect(eventBus.requestOnce).toHaveBeenCalledWith('datasets:registry', expect.any(Function))
33
+ })
34
+
35
+ it('puts the datasets registry it receives in this map\'s plugin state', () => {
36
+ renderInit({ isMapReady: true })
37
+ const datasetRegistry = { keyItems: jest.fn() }
38
+ const [, onRegistry] = eventBus.requestOnce.mock.calls[0]
39
+ onRegistry(datasetRegistry)
40
+ expect(pluginState.dispatch).toHaveBeenCalledWith({ type: 'SET_DATASET_REGISTRY', payload: datasetRegistry })
39
41
  })
40
42
 
41
43
  it('dispatches configured groups when pluginConfig.groups is provided', () => {
@@ -4,7 +4,6 @@ import { MapKeyInit } from './initialise/MapKeyInit.jsx'
4
4
 
5
5
  jest.mock('./components/Key/MapKey.jsx', () => ({ MapKey: jest.fn() }))
6
6
  jest.mock('./initialise/MapKeyInit.jsx', () => ({ MapKeyInit: jest.fn() }))
7
- jest.mock('./registry/getDatasetRegistry.js', () => ({}))
8
7
 
9
8
  describe('manifest', () => {
10
9
  it('sets InitComponent to MapKeyInit', () => {
@@ -1,41 +1,22 @@
1
- let _pluginStateRef = {}
2
- export const attachPluginStateRef = (pluginStateRef) => { _pluginStateRef = pluginStateRef }
3
-
4
- let previousRef = null
5
- let addedKeyGroups = []
6
-
7
- const getStateKeyGroups = () => {
8
- if (!_pluginStateRef?.current) {
9
- return []
10
- }
11
- if (previousRef === _pluginStateRef.current) {
12
- return addedKeyGroups
13
- }
14
- previousRef = _pluginStateRef.current
15
- const { groups = [], keyDefinitions = [] } = _pluginStateRef.current
16
-
17
- addedKeyGroups = groups.map(group => {
18
- if (group.type === 'flat') {
19
- return {
20
- ...group,
21
- keyDefinition: keyDefinitions.find(item => item.id === group.id)
22
- }
23
- }
24
-
1
+ // Turns the key groups and symbols added through the map-key API into key group items
2
+ const getStateKeyGroups = ({ groups = [], keyDefinitions = [] }) => groups.map(group => {
3
+ if (group.type === 'flat') {
25
4
  return {
26
5
  ...group,
27
- keyDefinitions: keyDefinitions.filter(item => item.groupId === group.id)
6
+ keyDefinition: keyDefinitions.find(item => item.id === group.id)
28
7
  }
29
- })
30
- return addedKeyGroups
31
- }
8
+ }
9
+
10
+ return {
11
+ ...group,
12
+ keyDefinitions: keyDefinitions.filter(item => item.groupId === group.id)
13
+ }
14
+ })
32
15
 
33
- // Merges the state key group items with items provided by another plugin,
16
+ // Merges this map's key groups from the map-key plugin state with items provided by another plugin,
34
17
  // specifically the datasets plugin
35
- export const mergeKeyGroupItems = (keyGroupItemsToMerge = []) => {
36
- // Clone the current state key groups from the plugin state reference
37
- // to avoid mutating the original array
38
- const stateKeyGroups = [...getStateKeyGroups()]
18
+ export const mergeKeyGroupItems = (keyGroupItemsToMerge = [], pluginState = {}) => {
19
+ const stateKeyGroups = getStateKeyGroups(pluginState)
39
20
  if (stateKeyGroups.length === 0) {
40
21
  // if there is nothing in the state key groups, just return the items that were passed in
41
22
  return keyGroupItemsToMerge
@@ -1,82 +1,68 @@
1
- import { attachPluginStateRef, mergeKeyGroupItems } from './mergeKeyGroupItems.js'
1
+ import { mergeKeyGroupItems } from './mergeKeyGroupItems.js'
2
2
 
3
3
  describe('mergeKeyGroupItems', () => {
4
- afterEach(() => {
5
- attachPluginStateRef({ current: null })
6
- })
7
-
8
- it('returns the incoming items unchanged when no plugin state is attached', () => {
9
- attachPluginStateRef({ current: null })
4
+ it('returns the incoming items unchanged when no plugin state is passed', () => {
10
5
  const items = [{ id: 'dataset-1', keyDefinitions: [{ id: 'k1' }] }]
11
6
 
12
7
  expect(mergeKeyGroupItems(items)).toBe(items)
13
8
  })
14
9
 
15
10
  it('returns dataset items unchanged when plugin state groups are empty', () => {
16
- attachPluginStateRef({ current: { groups: [], keyDefinitions: [] } })
11
+ const pluginState = { groups: [], keyDefinitions: [] }
17
12
  const items = [{ id: 'dataset-1', keyDefinitions: [{ id: 'k1' }] }]
18
13
 
19
- expect(mergeKeyGroupItems(items)).toEqual(items)
14
+ expect(mergeKeyGroupItems(items, pluginState)).toEqual(items)
20
15
  })
21
16
 
22
17
  it('uses default empty state values and empty arguments when no groups or items are supplied', () => {
23
- attachPluginStateRef({ current: {} })
18
+ const pluginState = {}
24
19
 
25
- expect(mergeKeyGroupItems()).toEqual([])
20
+ expect(mergeKeyGroupItems(undefined, pluginState)).toEqual([])
26
21
  })
27
22
 
28
23
  it('merges a matched group even when the state group has no keyDefinitions array', () => {
29
- attachPluginStateRef({
30
- current: {
31
- groups: [{ id: 'dataset-1', type: 'group', groupLabel: 'Dataset 1' }],
32
- keyDefinitions: []
33
- }
34
- })
24
+ const pluginState = {
25
+ groups: [{ id: 'dataset-1', type: 'group', groupLabel: 'Dataset 1' }],
26
+ keyDefinitions: []
27
+ }
35
28
 
36
29
  const items = [{ id: 'dataset-1', keyDefinitions: [{ id: 'd1' }] }]
37
30
 
38
- expect(mergeKeyGroupItems(items)).toEqual([
31
+ expect(mergeKeyGroupItems(items, pluginState)).toEqual([
39
32
  { id: 'dataset-1', type: 'group', groupLabel: 'Dataset 1', keyDefinitions: [{ id: 'd1' }] }
40
33
  ])
41
34
  })
42
35
 
43
36
  it('merges a matched group even when the incoming item has no keyDefinitions array', () => {
44
- attachPluginStateRef({
45
- current: {
46
- groups: [{ id: 'group-1', type: 'group', groupLabel: 'Group 1' }],
47
- keyDefinitions: [{ id: 'k1', groupId: 'group-1' }]
48
- }
49
- })
37
+ const pluginState = {
38
+ groups: [{ id: 'group-1', type: 'group', groupLabel: 'Group 1' }],
39
+ keyDefinitions: [{ id: 'k1', groupId: 'group-1' }]
40
+ }
50
41
 
51
42
  const items = [{ id: 'group-1' }]
52
43
 
53
- expect(mergeKeyGroupItems(items)).toEqual([
44
+ expect(mergeKeyGroupItems(items, pluginState)).toEqual([
54
45
  { id: 'group-1', type: 'group', groupLabel: 'Group 1', keyDefinitions: [{ id: 'k1', groupId: 'group-1' }] }
55
46
  ])
56
47
  })
57
48
 
58
- it('reuses the cached plugin-state groups when the ref object is unchanged', () => {
59
- const ref = { current: { groups: [{ id: 'group-1', type: 'group', groupLabel: 'Group 1' }], keyDefinitions: [{ id: 'k1', groupId: 'group-1' }] } }
60
- attachPluginStateRef(ref)
49
+ it('uses only the plugin state it is given, so each map keeps its own groups', () => {
50
+ const mapAState = { groups: [{ id: 'group-a', type: 'group', groupLabel: 'Group A' }], keyDefinitions: [{ id: 'a1', groupId: 'group-a' }] }
51
+ const mapBState = { groups: [{ id: 'group-b', type: 'group', groupLabel: 'Group B' }], keyDefinitions: [{ id: 'b1', groupId: 'group-b' }] }
61
52
 
62
- const first = mergeKeyGroupItems([{ id: 'dataset-1', keyDefinitions: [{ id: 'd1' }] }])
63
- const second = mergeKeyGroupItems([{ id: 'dataset-1', keyDefinitions: [{ id: 'd2' }] }])
64
-
65
- expect(first).toEqual([{ id: 'group-1', type: 'group', groupLabel: 'Group 1', keyDefinitions: [{ id: 'k1', groupId: 'group-1' }] }])
66
- expect(second).toEqual(first)
53
+ expect(mergeKeyGroupItems([], mapAState)).toEqual([{ id: 'group-a', type: 'group', groupLabel: 'Group A', keyDefinitions: [{ id: 'a1', groupId: 'group-a' }] }])
54
+ expect(mergeKeyGroupItems([], mapBState)).toEqual([{ id: 'group-b', type: 'group', groupLabel: 'Group B', keyDefinitions: [{ id: 'b1', groupId: 'group-b' }] }])
67
55
  })
68
56
 
69
57
  it('merges a matching flat group into the dataset item when the key definition matches the same id', () => {
70
- attachPluginStateRef({
71
- current: {
72
- groups: [{ id: 'dataset-1', type: 'flat' }],
73
- keyDefinitions: [{ id: 'dataset-1' }]
74
- }
75
- })
58
+ const pluginState = {
59
+ groups: [{ id: 'dataset-1', type: 'flat' }],
60
+ keyDefinitions: [{ id: 'dataset-1' }]
61
+ }
76
62
 
77
63
  const items = [{ id: 'dataset-1', keyDefinitions: [{ id: 'dataset-1' }] }]
78
64
 
79
- expect(mergeKeyGroupItems(items)).toEqual([
65
+ expect(mergeKeyGroupItems(items, pluginState)).toEqual([
80
66
  {
81
67
  id: 'dataset-1',
82
68
  type: 'flat',
@@ -87,19 +73,17 @@ describe('mergeKeyGroupItems', () => {
87
73
  })
88
74
 
89
75
  it('keeps only unmatched state groups that still have key definitions', () => {
90
- attachPluginStateRef({
91
- current: {
92
- groups: [
93
- { id: 'group-1', type: 'group', groupLabel: 'Group 1' },
94
- { id: 'group-2', type: 'group', groupLabel: 'Group 2' }
95
- ],
96
- keyDefinitions: [{ id: 'k1', groupId: 'group-1' }]
97
- }
98
- })
76
+ const pluginState = {
77
+ groups: [
78
+ { id: 'group-1', type: 'group', groupLabel: 'Group 1' },
79
+ { id: 'group-2', type: 'group', groupLabel: 'Group 2' }
80
+ ],
81
+ keyDefinitions: [{ id: 'k1', groupId: 'group-1' }]
82
+ }
99
83
 
100
84
  const items = [{ id: 'dataset-1', keyDefinitions: [{ id: 'd1' }] }]
101
85
 
102
- expect(mergeKeyGroupItems(items)).toEqual([
86
+ expect(mergeKeyGroupItems(items, pluginState)).toEqual([
103
87
  { id: 'group-1', type: 'group', groupLabel: 'Group 1', keyDefinitions: [{ id: 'k1', groupId: 'group-1' }] }
104
88
  ])
105
89
  })
@@ -1,6 +1,8 @@
1
1
  const initialState = {
2
2
  keyDefinitions: [],
3
- groups: []
3
+ groups: [],
4
+ // This map's datasets registry, if the datasets plugin is in use
5
+ datasetRegistry: null
4
6
  }
5
7
 
6
8
  const labelToId = (label) => label ? label.toLowerCase().replace(/\s+/g, '-') : null
@@ -56,7 +58,10 @@ const addKeyGroups = (state, groups) => {
56
58
  }
57
59
  }
58
60
 
61
+ const setDatasetRegistry = (state, datasetRegistry) => ({ ...state, datasetRegistry })
62
+
59
63
  const actions = {
64
+ SET_DATASET_REGISTRY: setDatasetRegistry,
60
65
  ADD_KEY_SYMBOL: addSymbol,
61
66
  REMOVE_KEY_SYMBOL: removeSymbol,
62
67
  ADD_KEY_GROUPS: addKeyGroups
@@ -2,7 +2,13 @@ import { actions, initialState } from './pluginState.js'
2
2
 
3
3
  describe('pluginState reducer helpers', () => {
4
4
  it('returns the initial state', () => {
5
- expect(initialState).toEqual({ keyDefinitions: [], groups: [] })
5
+ expect(initialState).toEqual({ keyDefinitions: [], groups: [], datasetRegistry: null })
6
+ })
7
+
8
+ it('stores this map\'s datasets registry', () => {
9
+ const datasetRegistry = { keyItems: jest.fn() }
10
+
11
+ expect(actions.SET_DATASET_REGISTRY(initialState, datasetRegistry)).toEqual({ ...initialState, datasetRegistry })
6
12
  })
7
13
 
8
14
  it('adds a flat key item and creates a flat group when needed', () => {
@@ -10,7 +16,8 @@ describe('pluginState reducer helpers', () => {
10
16
 
11
17
  expect(nextState).toEqual({
12
18
  keyDefinitions: [{ id: 'flat-key', label: 'Flat key', type: 'manual' }],
13
- groups: [{ id: 'flat-key', type: 'flat' }]
19
+ groups: [{ id: 'flat-key', type: 'flat' }],
20
+ datasetRegistry: null
14
21
  })
15
22
  })
16
23
 
@@ -25,7 +32,8 @@ describe('pluginState reducer helpers', () => {
25
32
  label: 'Group key',
26
33
  type: 'manual'
27
34
  }],
28
- groups: [{ id: 'group-label', type: 'group', groupLabel: 'Group Label' }]
35
+ groups: [{ id: 'group-label', type: 'group', groupLabel: 'Group Label' }],
36
+ datasetRegistry: null
29
37
  })
30
38
  })
31
39
 
@@ -76,7 +84,8 @@ describe('pluginState reducer helpers', () => {
76
84
 
77
85
  expect(actions.ADD_KEY_GROUPS(initialState, groups)).toEqual({
78
86
  keyDefinitions: [],
79
- groups: [{ id: 'g1', type: 'group', groupLabel: 'G1' }]
87
+ groups: [{ id: 'g1', type: 'group', groupLabel: 'G1' }],
88
+ datasetRegistry: null
80
89
  })
81
90
  })
82
91
  })
@@ -0,0 +1 @@
1
+ import{useEffect as e}from"preact/compat";import{jsx as i,Fragment as s,jsxs as a}from"preact/jsx-runtime";const l="app:ready",t="map:setstyle",m="map:setsize",p="map:setpixelratio",d="map:initmapstyles";const c={small:1,medium:1.5,large:2},r={InitComponent:function({pluginConfig:a,services:t}){const{eventBus:m}=t,p=()=>{m.emit(d,a.mapStyles)};return e(()=>(m.on(l,p),()=>m.off(l,p)),[]),i(s,{})},panels:[{id:"mapStyles",label:"Map styles",mobile:{slot:"drawer",modal:!0,dismissible:!0},tablet:{slot:"left-top",modal:!0,width:"400px",dismissible:!0},desktop:{slot:"left-top",modal:!0,width:"400px",dismissible:!0},render:({mapState:e,pluginConfig:s,services:l,mapProvider:d})=>{const{mapStyle:r,mapSize:o}=e,{mapStyles:n}=s,{eventBus:h}=l,{supportsMapSizes:v}=d.capabilities;return a("div",{className:"im-c-map-styles",children:[i("div",{className:"im-c-map-styles__group",children:i("div",{className:"im-c-map-styles__inner",children:n.filter(e=>e.url).map(e=>i("div",{className:"im-c-map-styles__item",children:a("button",{className:"im-c-map-styles__button","aria-pressed":e.id===r.id,onClick:()=>{return i=e,void h.emit(t,i);var i},children:[i("div",{className:"im-c-map-styles__image",children:i("img",{src:e.thumbnail||void 0,alt:"",height:"60",width:"60"})}),e.label]})},e.id))})}),v&&a("div",{className:"im-c-map-styles__group",children:[i("h3",{className:"im-c-map-styles__heading",id:"map-text-sizes",children:"Map size"}),i("div",{className:"im-c-map-styles__inner",children:["small","medium","large"].map(e=>i("div",{className:"im-c-map-styles__item",children:a("button",{className:"im-c-map-styles__button",onClick:()=>{return i=e,h.emit(m,i),void h.emit(p,window.devicePixelRatio*c[i]);var i},"aria-pressed":e===o,children:[i("div",{className:"im-c-map-styles__image",children:a("svg",{width:"60",height:"60",viewBox:"0 0 60 60",fillRule:"evenodd","aria-hidden":"true",children:[i("rect",{className:"im-c-map-styles__image-bg",width:"100%",height:"100%"}),i("g",{style:{transform:`scale(${c[e]})`,transformOrigin:"8px 52px"},children:i("path",{d:"M8 51.785L12.948 38.9h1.837l5.274 12.885h-1.943l-1.503-3.903h-5.387l-1.415 3.903H8zm3.718-5.291h4.368l-1.345-3.569-.914-2.671c-.164.826-.395 1.646-.694 2.46l-1.415 3.78zm15.592 4.139c-3.698 3.143-7.836.271-6.315-2.562.963-1.794 5.529-1.982 6.183-2.21.022-.825.052-2.27-2.241-2.312-1.751-.031-2.242 1.025-2.435 1.776l-1.547-.211c.234-1.102.963-2.856 4.21-2.874 4.037-.022 3.612 2.962 3.612 3.524v2.11c0 .315 0 3.012.501 3.911h-1.652c-.164-.328-.27-.712-.316-1.152zm-.132-3.533c-.907.37-3.444.694-3.964.914-1.293.548-.911 2.399.225 2.637.639.134 3.739.476 3.739-2.971v-.58z"})})]})}),e[0].toUpperCase()+e.slice(1)]})},e))})]})]})}}],buttons:[{id:"mapStyles",label:"Styles",panelId:"mapStyles",iconId:"map",mobile:{slot:"top-left",showLabel:!1},tablet:{slot:"top-left",showLabel:!0},desktop:{slot:"top-left",showLabel:!0}}],icons:[{id:"map",svgContent:'<path d="M14.106 5.553a2 2 0 0 0 1.788 0l3.659-1.83A1 1 0 0 1 21 4.619v12.764a1 1 0 0 1-.553.894l-4.553 2.277a2 2 0 0 1-1.788 0l-4.212-2.106a2 2 0 0 0-1.788 0l-3.659 1.83A1 1 0 0 1 3 19.381V6.618a1 1 0 0 1 .553-.894l4.553-2.277a2 2 0 0 1 1.788 0z"/><path d="M15 5.764v15"/><path d="M9 3.236v15"/>'}]};export{r as manifest};
@@ -0,0 +1 @@
1
+ import e from"@babel/runtime/helpers/regenerator";import t from"@babel/runtime/helpers/asyncToGenerator";function r(){var r,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{id:"mapStyles",manifest:n.manifest,mapStyles:n.mapStyles,load:(r=t(e().m(function t(){var r;return e().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,import(/* webpackChunkName: "im-map-styles-plugin" */ "./im-map-styles-plugin.js");case 1:return r=e.v.manifest,e.a(2,r)}},t)})),function(){return r.apply(this,arguments)}),handlesMapStyle:!0,api:{}}}export{r as default};
@@ -0,0 +1 @@
1
+ "use strict";(Object("undefined"!=typeof self?self:this).webpackChunkdefra_DefraMap=Object("undefined"!=typeof self?self:this).webpackChunkdefra_DefraMap||[]).push([[657],{868:function(e,s,i){i.r(s),i.d(s,{manifest:function(){return m}});var t=i(738),a="app:ready",l=i(287),n={small:1,medium:1.5,large:2},m={InitComponent:function(e){var s=e.pluginConfig,i=e.services.eventBus,n=function(){i.emit("map:initmapstyles",s.mapStyles)};return(0,t.useEffect)(function(){return i.on(a,n),function(){return i.off(a,n)}},[]),(0,l.jsx)(l.Fragment,{})},panels:[{id:"mapStyles",label:"Map styles",mobile:{slot:"drawer",modal:!0,dismissible:!0},tablet:{slot:"left-top",modal:!0,width:"400px",dismissible:!0},desktop:{slot:"left-top",modal:!0,width:"400px",dismissible:!0},render:function(e){var s=e.mapState,i=e.pluginConfig,t=e.services,a=e.mapProvider,m=s.mapStyle,r=s.mapSize,c=i.mapStyles,d=t.eventBus,p=a.capabilities.supportsMapSizes;return(0,l.jsxs)("div",{className:"im-c-map-styles",children:[(0,l.jsx)("div",{className:"im-c-map-styles__group",children:(0,l.jsx)("div",{className:"im-c-map-styles__inner",children:c.filter(function(e){return e.url}).map(function(e){return(0,l.jsx)("div",{className:"im-c-map-styles__item",children:(0,l.jsxs)("button",{className:"im-c-map-styles__button","aria-pressed":e.id===m.id,onClick:function(){return s=e,void d.emit("map:setstyle",s);var s},children:[(0,l.jsx)("div",{className:"im-c-map-styles__image",children:(0,l.jsx)("img",{src:e.thumbnail||void 0,alt:"",height:"60",width:"60"})}),e.label]})},e.id)})})}),p&&(0,l.jsxs)("div",{className:"im-c-map-styles__group",children:[(0,l.jsx)("h3",{className:"im-c-map-styles__heading",id:"map-text-sizes",children:"Map size"}),(0,l.jsx)("div",{className:"im-c-map-styles__inner",children:["small","medium","large"].map(function(e){return(0,l.jsx)("div",{className:"im-c-map-styles__item",children:(0,l.jsxs)("button",{className:"im-c-map-styles__button",onClick:function(){return s=e,d.emit("map:setsize",s),void d.emit("map:setpixelratio",window.devicePixelRatio*n[s]);var s},"aria-pressed":e===r,children:[(0,l.jsx)("div",{className:"im-c-map-styles__image",children:(0,l.jsxs)("svg",{width:"60",height:"60",viewBox:"0 0 60 60",fillRule:"evenodd","aria-hidden":"true",children:[(0,l.jsx)("rect",{className:"im-c-map-styles__image-bg",width:"100%",height:"100%"}),(0,l.jsx)("g",{style:{transform:"scale(".concat(n[e],")"),transformOrigin:"8px 52px"},children:(0,l.jsx)("path",{d:"M8 51.785L12.948 38.9h1.837l5.274 12.885h-1.943l-1.503-3.903h-5.387l-1.415 3.903H8zm3.718-5.291h4.368l-1.345-3.569-.914-2.671c-.164.826-.395 1.646-.694 2.46l-1.415 3.78zm15.592 4.139c-3.698 3.143-7.836.271-6.315-2.562.963-1.794 5.529-1.982 6.183-2.21.022-.825.052-2.27-2.241-2.312-1.751-.031-2.242 1.025-2.435 1.776l-1.547-.211c.234-1.102.963-2.856 4.21-2.874 4.037-.022 3.612 2.962 3.612 3.524v2.11c0 .315 0 3.012.501 3.911h-1.652c-.164-.328-.27-.712-.316-1.152zm-.132-3.533c-.907.37-3.444.694-3.964.914-1.293.548-.911 2.399.225 2.637.639.134 3.739.476 3.739-2.971v-.58z"})})]})}),e[0].toUpperCase()+e.slice(1)]})},e)})})]})]})}}],buttons:[{id:"mapStyles",label:"Styles",panelId:"mapStyles",iconId:"map",mobile:{slot:"top-left",showLabel:!1},tablet:{slot:"top-left",showLabel:!0},desktop:{slot:"top-left",showLabel:!0}}],icons:[{id:"map",svgContent:'<path d="M14.106 5.553a2 2 0 0 0 1.788 0l3.659-1.83A1 1 0 0 1 21 4.619v12.764a1 1 0 0 1-.553.894l-4.553 2.277a2 2 0 0 1-1.788 0l-4.212-2.106a2 2 0 0 0-1.788 0l-3.659 1.83A1 1 0 0 1 3 19.381V6.618a1 1 0 0 1 .553-.894l4.553-2.277a2 2 0 0 1 1.788 0z"/><path d="M15 5.764v15"/><path d="M9 3.236v15"/>'}]}}}]);
@@ -1,2 +1,2 @@
1
1
  /*! For license information please see index.js.LICENSE.txt */
2
- !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("defra",[],e):"object"==typeof exports?exports.defra=e():(t.defra=t.defra||{},t.defra.mapStylesPlugin=e())}(Object("undefined"!=typeof self?self:this),function(){return function(){"use strict";var t,e,r={738:function(t){t.exports=preactCompat},287:function(t){t.exports=preactJsxRuntime}},n={};function o(t){var e=n[t];if(void 0!==e)return e.exports;var i=n[t]={exports:{}};return r[t](i,i.exports,o),i.exports}o.m=r,o.d=function(t,e){for(var r in e)o.o(e,r)&&!o.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},o.f={},o.e=function(t){return Promise.all(Object.keys(o.f).reduce(function(e,r){return o.f[r](t,e),e},[]))},o.u=function(t){return"im-map-styles-plugin.js"},o.miniCssF=function(t){},o.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),o.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},t={},e="defra.mapStylesPlugin:",o.l=function(r,n,i,a){if(t[r])t[r].push(n);else{var u,c;if(void 0!==i)for(var f=document.getElementsByTagName("script"),p=0;p<f.length;p++){var l=f[p];if(l.getAttribute("src")==r||l.getAttribute("data-webpack")==e+i){u=l;break}}u||(c=!0,(u=document.createElement("script")).charset="utf-8",o.nc&&u.setAttribute("nonce",o.nc),u.setAttribute("data-webpack",e+i),u.src=r),t[r]=[n];var s=function(e,n){u.onerror=u.onload=null,clearTimeout(d);var o=t[r];if(delete t[r],u.parentNode&&u.parentNode.removeChild(u),o&&o.forEach(function(t){return t(n)}),e)return e(n)},d=setTimeout(s.bind(null,void 0,{type:"timeout",target:u}),12e4);u.onerror=s.bind(null,u.onerror),u.onload=s.bind(null,u.onload),c&&document.head.appendChild(u)}},o.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},function(){var t;o.g.importScripts&&(t=o.g.location+"");var e=o.g.document;if(!t&&e&&(e.currentScript&&"SCRIPT"===e.currentScript.tagName.toUpperCase()&&(t=e.currentScript.src),!t)){var r=e.getElementsByTagName("script");if(r.length)for(var n=r.length-1;n>-1&&(!t||!/^http(s?):/.test(t));)t=r[n--].src}if(!t)throw new Error("Automatic publicPath is not supported in this browser");t=t.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),o.p=t}(),function(){var t={57:0};o.f.j=function(e,r){var n=o.o(t,e)?t[e]:void 0;if(0!==n)if(n)r.push(n[2]);else{var i=new Promise(function(r,o){n=t[e]=[r,o]});r.push(n[2]=i);var a=o.p+o.u(e),u=new Error;o.l(a,function(r){if(o.o(t,e)&&(0!==(n=t[e])&&(t[e]=void 0),n)){var i=r&&("load"===r.type?"missing":r.type),a=r&&r.target&&r.target.src;u.message="Loading chunk "+e+" failed.\n("+i+": "+a+")",u.name="ChunkLoadError",u.type=i,u.request=a,n[1](u)}},"chunk-"+e,e)}};var e=function(e,r){var n,i,a=r[0],u=r[1],c=r[2],f=0;if(a.some(function(e){return 0!==t[e]})){for(n in u)o.o(u,n)&&(o.m[n]=u[n]);c&&c(o)}for(e&&e(r);f<a.length;f++)i=a[f],o.o(t,i)&&t[i]&&t[i][0](),t[i]=0},r=Object("undefined"!=typeof self?self:this).webpackChunkdefra_DefraMap=Object("undefined"!=typeof self?self:this).webpackChunkdefra_DefraMap||[];r.forEach(e.bind(null,0)),r.push=e.bind(null,r.push.bind(r))}();var i={};function a(){var t,e,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function i(r,n,o,i){var a=n&&n.prototype instanceof f?n:f,p=Object.create(a.prototype);return u(p,"_invoke",function(r,n,o){var i,a,u,f=0,p=o||[],l=!1,s={p:0,n:0,v:t,a:d,f:d.bind(t,4),d:function(e,r){return i=e,a=0,u=t,s.n=r,c}};function d(r,n){for(a=r,u=n,e=0;!l&&f&&!o&&e<p.length;e++){var o,i=p[e],d=s.p,y=i[2];r>3?(o=y===n)&&(u=i[(a=i[4])?5:(a=3,3)],i[4]=i[5]=t):i[0]<=d&&((o=r<2&&d<i[1])?(a=0,s.v=n,s.n=i[1]):d<y&&(o=r<3||i[0]>n||n>y)&&(i[4]=r,i[5]=n,s.n=y,a=0))}if(o||r>1)return c;throw l=!0,n}return function(o,p,y){if(f>1)throw TypeError("Generator is already running");for(l&&1===p&&d(p,y),a=p,u=y;(e=a<2?t:u)||!l;){i||(a?a<3?(a>1&&(s.n=-1),d(a,u)):s.n=u:s.v=u);try{if(f=2,i){if(a||(o="next"),e=i[o]){if(!(e=e.call(i,u)))throw TypeError("iterator result is not an object");if(!e.done)return e;u=e.value,a<2&&(a=0)}else 1===a&&(e=i.return)&&e.call(i),a<2&&(u=TypeError("The iterator does not provide a '"+o+"' method"),a=1);i=t}else if((e=(l=s.n<0)?u:r.call(n,s))!==c)break}catch(e){i=t,a=1,u=e}finally{f=1}}return{value:e,done:l}}}(r,o,i),!0),p}var c={};function f(){}function p(){}function l(){}e=Object.getPrototypeOf;var s=[][n]?e(e([][n]())):(u(e={},n,function(){return this}),e),d=l.prototype=f.prototype=Object.create(s);function y(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,l):(t.__proto__=l,u(t,o,"GeneratorFunction")),t.prototype=Object.create(d),t}return p.prototype=l,u(d,"constructor",l),u(l,"constructor",p),p.displayName="GeneratorFunction",u(l,o,"GeneratorFunction"),u(d),u(d,o,"Generator"),u(d,n,function(){return this}),u(d,"toString",function(){return"[object Generator]"}),(a=function(){return{w:i,m:y}})()}function u(t,e,r,n){var o=Object.defineProperty;try{o({},"",{})}catch(t){o=0}u=function(t,e,r,n){function i(e,r){u(t,e,function(t){return this._invoke(e,r,t)})}e?o?o(t,e,{value:r,enumerable:!n,configurable:!n,writable:!n}):t[e]=r:(i("next",0),i("throw",1),i("return",2))},u(t,e,r,n)}function c(t,e,r,n,o,i,a){try{var u=t[i](a),c=u.value}catch(t){return void r(t)}u.done?e(c):Promise.resolve(c).then(n,o)}function f(){var t,e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{id:"mapStyles",manifest:r.manifest,mapStyles:r.mapStyles,load:(t=a().m(function t(){var e;return a().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,o.e(657).then(o.bind(o,790));case 1:return e=t.v.manifest,t.a(2,e)}},t)}),e=function(){var e=this,r=arguments;return new Promise(function(n,o){var i=t.apply(e,r);function a(t){c(i,n,o,a,u,"next",t)}function u(t){c(i,n,o,a,u,"throw",t)}a(void 0)})},function(){return e.apply(this,arguments)}),handlesMapStyle:!0,api:{}}}return o.d(i,{default:function(){return f}}),i.default}()});
2
+ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("defra",[],e):"object"==typeof exports?exports.defra=e():(t.defra=t.defra||{},t.defra.mapStylesPlugin=e())}(Object("undefined"!=typeof self?self:this),function(){return function(){"use strict";var t,e,r={738:function(t){t.exports=preactCompat},287:function(t){t.exports=preactJsxRuntime}},n={};function o(t){var e=n[t];if(void 0!==e)return e.exports;var i=n[t]={exports:{}};return r[t](i,i.exports,o),i.exports}o.m=r,o.d=function(t,e){for(var r in e)o.o(e,r)&&!o.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},o.f={},o.e=function(t){return Promise.all(Object.keys(o.f).reduce(function(e,r){return o.f[r](t,e),e},[]))},o.u=function(t){return"im-map-styles-plugin.js"},o.miniCssF=function(t){},o.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),o.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},t={},e="defra.mapStylesPlugin:",o.l=function(r,n,i,a){if(t[r])t[r].push(n);else{var u,c;if(void 0!==i)for(var f=document.getElementsByTagName("script"),p=0;p<f.length;p++){var l=f[p];if(l.getAttribute("src")==r||l.getAttribute("data-webpack")==e+i){u=l;break}}u||(c=!0,(u=document.createElement("script")).charset="utf-8",o.nc&&u.setAttribute("nonce",o.nc),u.setAttribute("data-webpack",e+i),u.src=r),t[r]=[n];var s=function(e,n){u.onerror=u.onload=null,clearTimeout(d);var o=t[r];if(delete t[r],u.parentNode&&u.parentNode.removeChild(u),o&&o.forEach(function(t){return t(n)}),e)return e(n)},d=setTimeout(s.bind(null,void 0,{type:"timeout",target:u}),12e4);u.onerror=s.bind(null,u.onerror),u.onload=s.bind(null,u.onload),c&&document.head.appendChild(u)}},o.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},function(){var t;o.g.importScripts&&(t=o.g.location+"");var e=o.g.document;if(!t&&e&&(e.currentScript&&"SCRIPT"===e.currentScript.tagName.toUpperCase()&&(t=e.currentScript.src),!t)){var r=e.getElementsByTagName("script");if(r.length)for(var n=r.length-1;n>-1&&(!t||!/^http(s?):/.test(t));)t=r[n--].src}if(!t)throw new Error("Automatic publicPath is not supported in this browser");t=t.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),o.p=t}(),function(){var t={57:0};o.f.j=function(e,r){var n=o.o(t,e)?t[e]:void 0;if(0!==n)if(n)r.push(n[2]);else{var i=new Promise(function(r,o){n=t[e]=[r,o]});r.push(n[2]=i);var a=o.p+o.u(e),u=new Error;o.l(a,function(r){if(o.o(t,e)&&(0!==(n=t[e])&&(t[e]=void 0),n)){var i=r&&("load"===r.type?"missing":r.type),a=r&&r.target&&r.target.src;u.message="Loading chunk "+e+" failed.\n("+i+": "+a+")",u.name="ChunkLoadError",u.type=i,u.request=a,n[1](u)}},"chunk-"+e,e)}};var e=function(e,r){var n,i,a=r[0],u=r[1],c=r[2],f=0;if(a.some(function(e){return 0!==t[e]})){for(n in u)o.o(u,n)&&(o.m[n]=u[n]);c&&c(o)}for(e&&e(r);f<a.length;f++)i=a[f],o.o(t,i)&&t[i]&&t[i][0](),t[i]=0},r=Object("undefined"!=typeof self?self:this).webpackChunkdefra_DefraMap=Object("undefined"!=typeof self?self:this).webpackChunkdefra_DefraMap||[];r.forEach(e.bind(null,0)),r.push=e.bind(null,r.push.bind(r))}();var i={};function a(){var t,e,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function i(r,n,o,i){var a=n&&n.prototype instanceof f?n:f,p=Object.create(a.prototype);return u(p,"_invoke",function(r,n,o){var i,a,u,f=0,p=o||[],l=!1,s={p:0,n:0,v:t,a:d,f:d.bind(t,4),d:function(e,r){return i=e,a=0,u=t,s.n=r,c}};function d(r,n){for(a=r,u=n,e=0;!l&&f&&!o&&e<p.length;e++){var o,i=p[e],d=s.p,y=i[2];r>3?(o=y===n)&&(u=i[(a=i[4])?5:(a=3,3)],i[4]=i[5]=t):i[0]<=d&&((o=r<2&&d<i[1])?(a=0,s.v=n,s.n=i[1]):d<y&&(o=r<3||i[0]>n||n>y)&&(i[4]=r,i[5]=n,s.n=y,a=0))}if(o||r>1)return c;throw l=!0,n}return function(o,p,y){if(f>1)throw TypeError("Generator is already running");for(l&&1===p&&d(p,y),a=p,u=y;(e=a<2?t:u)||!l;){i||(a?a<3?(a>1&&(s.n=-1),d(a,u)):s.n=u:s.v=u);try{if(f=2,i){if(a||(o="next"),e=i[o]){if(!(e=e.call(i,u)))throw TypeError("iterator result is not an object");if(!e.done)return e;u=e.value,a<2&&(a=0)}else 1===a&&(e=i.return)&&e.call(i),a<2&&(u=TypeError("The iterator does not provide a '"+o+"' method"),a=1);i=t}else if((e=(l=s.n<0)?u:r.call(n,s))!==c)break}catch(e){i=t,a=1,u=e}finally{f=1}}return{value:e,done:l}}}(r,o,i),!0),p}var c={};function f(){}function p(){}function l(){}e=Object.getPrototypeOf;var s=[][n]?e(e([][n]())):(u(e={},n,function(){return this}),e),d=l.prototype=f.prototype=Object.create(s);function y(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,l):(t.__proto__=l,u(t,o,"GeneratorFunction")),t.prototype=Object.create(d),t}return p.prototype=l,u(d,"constructor",l),u(l,"constructor",p),p.displayName="GeneratorFunction",u(l,o,"GeneratorFunction"),u(d),u(d,o,"Generator"),u(d,n,function(){return this}),u(d,"toString",function(){return"[object Generator]"}),(a=function(){return{w:i,m:y}})()}function u(t,e,r,n){var o=Object.defineProperty;try{o({},"",{})}catch(t){o=0}u=function(t,e,r,n){function i(e,r){u(t,e,function(t){return this._invoke(e,r,t)})}e?o?o(t,e,{value:r,enumerable:!n,configurable:!n,writable:!n}):t[e]=r:(i("next",0),i("throw",1),i("return",2))},u(t,e,r,n)}function c(t,e,r,n,o,i,a){try{var u=t[i](a),c=u.value}catch(t){return void r(t)}u.done?e(c):Promise.resolve(c).then(n,o)}function f(){var t,e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{id:"mapStyles",manifest:r.manifest,mapStyles:r.mapStyles,load:(t=a().m(function t(){var e;return a().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,o.e(657).then(o.bind(o,868));case 1:return e=t.v.manifest,t.a(2,e)}},t)}),e=function(){var e=this,r=arguments;return new Promise(function(n,o){var i=t.apply(e,r);function a(t){c(i,n,o,a,u,"next",t)}function u(t){c(i,n,o,a,u,"throw",t)}a(void 0)})},function(){return e.apply(this,arguments)}),handlesMapStyle:!0,api:{}}}return o.d(i,{default:function(){return f}}),i.default}()});
@@ -1,7 +1,7 @@
1
1
  import React from 'react'
2
- import { EVENTS } from '../../../../src/config/events.js'
2
+ import { EVENTS } from '../../../src/config/events.js'
3
3
  import { textSizeSvgPath } from './config.js'
4
- import { scaleFactor } from '../../../../src/config/appConfig.js'
4
+ import { scaleFactor } from '../../../src/config/mapSizeScales.js'
5
5
 
6
6
  export const MapStyles = ({ mapState, pluginConfig, services, mapProvider }) => {
7
7
  const { mapStyle: currentMapStyle, mapSize: currentMapSize } = mapState
@@ -42,7 +42,7 @@ export const MapStyles = ({ mapState, pluginConfig, services, mapProvider }) =>
42
42
  <div className='im-c-map-styles__item' key={size}>
43
43
  <button className='im-c-map-styles__button' onClick={() => handleMapSizeClick(size)} aria-pressed={size === currentMapSize}>
44
44
  <div className='im-c-map-styles__image'>
45
- <svg width='60' height='60' viewBox='0 0 60 60' fillRule='evenodd'>
45
+ <svg width='60' height='60' viewBox='0 0 60 60' fillRule='evenodd' aria-hidden='true'>
46
46
  <rect className='im-c-map-styles__image-bg' width='100%' height='100%' />
47
47
  <g style={{ transform: `scale(${scaleFactor[size]})`, transformOrigin: '8px 52px' }}>
48
48
  <path d={textSizeSvgPath} />
@@ -1,6 +1,6 @@
1
1
  // src/plugins/mapStyles/MapStylesInit.jsx
2
2
  import { useEffect } from 'react'
3
- import { EVENTS } from '../../../../src/config/events.js'
3
+ import { EVENTS } from '../../../src/config/events.js'
4
4
 
5
5
  export function MapStylesInit ({ pluginConfig, services }) {
6
6
  const { eventBus } = services