@defra/interactive-map 0.0.55-alpha → 0.0.56-alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/templates/style-switcher.njk +2 -2
- package/dist/esm/im-core.js +1 -1
- package/dist/esm/im-shell.js +1 -1
- package/dist/umd/im-core.js +1 -1
- package/dist/umd/index.js +1 -1
- package/docs/api/context.md +2 -0
- package/docs/api.md +17 -1
- package/docs/architecture/interactive-map.likec4 +4 -4
- package/docs/plugins/datasets.md +11 -0
- package/docs/plugins/draw.md +8 -2
- package/docs/plugins/interact.md +24 -1
- package/docs/plugins/search.md +2 -2
- package/docusaurus.config.cjs +25 -3
- package/govuk-prototype-kit.config.json +6 -7
- package/package.json +20 -23
- package/plugins/datasets/dist/esm/im-datasets-esri-adapter.js +1 -1
- package/plugins/datasets/dist/esm/im-datasets-ml-adapter.js +1 -1
- package/plugins/datasets/dist/esm/im-datasets-ol-adapter.js +1 -1
- package/plugins/datasets/dist/esm/im-datasets-plugin.js +1 -1
- package/plugins/datasets/dist/esm/index.js +1 -1
- package/plugins/datasets/dist/esm/mapboxStyleLayerAdapter.js +1 -1
- package/plugins/datasets/dist/umd/im-datasets-ml-adapter.js +1 -1
- package/plugins/datasets/dist/umd/im-datasets-ol-adapter.js +1 -1
- package/plugins/datasets/dist/umd/im-datasets-plugin.js +1 -1
- package/plugins/datasets/dist/umd/index.js +1 -1
- package/plugins/datasets/src/adapters/esri/esriLayerAdapter.js +18 -16
- package/plugins/datasets/src/adapters/esri/esriLayerAdapter.test.js +2 -2
- package/plugins/datasets/src/adapters/esri/registry/esriDataset.js +2 -3
- package/plugins/datasets/src/adapters/esri/registry/esriDataset.test.js +1 -1
- package/plugins/datasets/src/adapters/loadLayerAdapter.js +2 -20
- package/plugins/datasets/src/adapters/loadLayerAdapter.test.js +9 -9
- package/plugins/datasets/src/adapters/mapboxStyleLayerAdapter.js +7 -7
- package/plugins/datasets/src/adapters/maplibre/maplibreLayerAdapter.js +19 -19
- package/plugins/datasets/src/adapters/maplibre/maplibreLayerAdapter.test.js +1 -1
- package/plugins/datasets/src/adapters/maplibre/registry/mapLibreDataset.test.js +1 -1
- package/plugins/datasets/src/adapters/openlayers/canvasPatternStyle.test.js +2 -2
- package/plugins/datasets/src/adapters/openlayers/layerBuilders.test.js +1 -1
- package/plugins/datasets/src/adapters/openlayers/openlayersLayerAdapter.js +21 -21
- package/plugins/datasets/src/adapters/openlayers/openlayersLayerAdapter.test.js +5 -5
- package/plugins/datasets/src/adapters/openlayers/registry/openLayersDataset.js +2 -3
- package/plugins/datasets/src/adapters/openlayers/registry/openLayersDataset.test.js +2 -2
- package/plugins/datasets/src/api/getOpacity.js +1 -2
- package/plugins/datasets/src/api/getOpacity.test.js +9 -12
- package/plugins/datasets/src/api/getStyle.js +1 -2
- package/plugins/datasets/src/api/getStyle.test.js +5 -8
- package/plugins/datasets/src/api/removeDataset.js +2 -4
- package/plugins/datasets/src/api/removeDataset.test.js +5 -10
- package/plugins/datasets/src/api/setData.js +2 -4
- package/plugins/datasets/src/api/setData.test.js +6 -14
- package/plugins/datasets/src/api/setFeatureVisibility.js +1 -2
- package/plugins/datasets/src/api/setFeatureVisibility.test.js +8 -11
- package/plugins/datasets/src/components/LayersMenu/LayersMenu.jsx +1 -0
- package/plugins/datasets/src/components/LayersMenu/LayersMenuCheckbox.jsx +1 -3
- package/plugins/datasets/src/components/LayersMenu/LayersMenuCheckbox.test.jsx +13 -18
- package/plugins/datasets/src/index.js +2 -2
- package/plugins/datasets/src/index.test.js +8 -1
- package/plugins/datasets/src/initialise/DatasetsInit.jsx +48 -26
- package/plugins/datasets/src/initialise/DatasetsInit.test.jsx +160 -89
- package/plugins/datasets/src/initialise/initialiseDatasets.js +2 -3
- package/plugins/datasets/src/initialise/initialiseDatasets.test.js +23 -10
- package/plugins/datasets/src/manifest.js +53 -44
- package/plugins/datasets/src/manifest.test.js +36 -4
- package/plugins/datasets/src/reducers/pluginState.js +5 -5
- package/plugins/datasets/src/reducers/pluginState.test.js +21 -20
- package/plugins/datasets/src/registry/__mocks__/datasetRegistry.js +7 -6
- package/plugins/datasets/src/registry/createDataset.js +2 -2
- package/plugins/datasets/src/registry/dataset.js +9 -10
- package/plugins/datasets/src/registry/dataset.test.js +63 -64
- package/plugins/datasets/src/registry/datasetRegistry.js +39 -10
- package/plugins/datasets/src/registry/datasetRegistry.test.js +83 -1
- package/plugins/datasets/src/registry/globalDataset.js +9 -17
- package/plugins/datasets/src/registry/isVisibleWhen.js +9 -17
- package/plugins/datasets/src/registry/isVisibleWhen.test.js +27 -20
- package/plugins/datasets/src/registry/mapboxStyleDataset.test.js +26 -27
- package/plugins/datasets/src/utils/hasLayersMenu.js +13 -0
- package/plugins/datasets/src/utils/hasLayersMenu.test.js +25 -0
- package/plugins/draw/dist/esm/im-draw-plugin.js +1 -1
- package/plugins/draw/dist/esm/index.js +1 -1
- package/plugins/draw/dist/umd/im-draw-plugin.js +1 -1
- package/plugins/draw/dist/umd/index.js +1 -1
- package/plugins/draw/src/DrawInit.jsx +47 -26
- package/plugins/draw/src/DrawInit.test.jsx +90 -2
- package/plugins/draw/src/adapters/openlayers/core/styles.test.js +1 -1
- package/plugins/draw/src/adapters/openlayers/point/pointSymbolImages.test.js +1 -1
- package/plugins/draw/src/manifest.js +3 -2
- package/plugins/draw/src/manifest.test.js +13 -1
- package/plugins/draw/src/utils/needsDrawTarget.js +22 -0
- package/plugins/draw/src/utils/needsDrawTarget.test.js +42 -0
- package/plugins/draw-es/dist/esm/index.js +1 -0
- package/plugins/{beta/draw-es → draw-es}/src/DrawInit.jsx +1 -1
- package/plugins/{beta/draw-es → draw-es}/src/events.test.js +1 -1
- package/plugins/{beta/draw-es → draw-es}/src/graphic.js +1 -1
- package/plugins/frame/dist/esm/index.js +1 -0
- package/plugins/{beta/frame → frame}/dist/umd/im-frame-plugin.js +1 -1
- package/plugins/{beta/frame → frame}/dist/umd/index.js +1 -1
- package/plugins/{beta/frame → frame}/package.json +2 -2
- package/plugins/interact/dist/esm/im-interact-plugin.js +1 -1
- package/plugins/interact/dist/esm/index.js +1 -1
- package/plugins/interact/dist/umd/im-interact-plugin.js +1 -1
- package/plugins/interact/dist/umd/index.js +1 -1
- package/plugins/interact/src/InteractInit.jsx +3 -3
- package/plugins/interact/src/api/enable.test.js +13 -0
- package/plugins/interact/src/defaults.js +1 -0
- package/plugins/interact/src/hooks/useCrossHairVisibility.js +27 -17
- package/plugins/interact/src/hooks/useCrossHairVisibility.test.js +72 -7
- package/plugins/interact/src/manifest.js +4 -4
- package/plugins/interact/src/manifest.test.js +29 -0
- package/plugins/interact/src/reducer.js +7 -2
- package/plugins/interact/src/reducer.test.js +12 -2
- package/plugins/interact/src/utils/needsTarget.js +20 -0
- package/plugins/interact/src/utils/needsTarget.test.js +36 -0
- package/plugins/map-key/dist/esm/im-map-key-plugin.js +1 -1
- package/plugins/map-key/dist/esm/index.js +1 -1
- package/plugins/map-key/dist/umd/im-map-key-plugin.js +1 -1
- package/plugins/map-key/dist/umd/index.js +1 -1
- package/plugins/map-key/src/components/Key/KeySvgSymbol.jsx +4 -0
- package/plugins/map-key/src/components/Key/MapKey.jsx +15 -15
- package/plugins/map-key/src/components/Key/MapKey.test.jsx +29 -15
- package/plugins/map-key/src/initialise/MapKeyInit.jsx +5 -8
- package/plugins/map-key/src/initialise/MapKeyInit.test.jsx +9 -7
- package/plugins/map-key/src/manifest.test.js +0 -1
- package/plugins/map-key/src/reducers/mergeKeyGroupItems.js +14 -33
- package/plugins/map-key/src/reducers/mergeKeyGroupItems.test.js +34 -50
- package/plugins/map-key/src/reducers/pluginState.js +6 -1
- package/plugins/map-key/src/reducers/pluginState.test.js +13 -4
- package/plugins/map-styles/dist/esm/index.js +1 -0
- package/plugins/{beta/map-styles → map-styles}/dist/umd/im-map-styles-plugin.js +1 -1
- package/plugins/{beta/map-styles → map-styles}/dist/umd/index.js +1 -1
- package/plugins/{beta/map-styles → map-styles}/src/MapStyles.jsx +2 -2
- package/plugins/{beta/map-styles → map-styles}/src/MapStylesInit.jsx +1 -1
- package/plugins/menu/dist/esm/index.js +1 -1
- package/plugins/scale-bar/dist/esm/index.js +1 -0
- package/plugins/{beta/scale-bar → scale-bar}/dist/umd/im-scale-bar-plugin.js +1 -1
- package/plugins/{beta/scale-bar → scale-bar}/dist/umd/index.js +1 -1
- package/plugins/{beta/scale-bar → scale-bar}/package.json +2 -2
- package/plugins/search/dist/esm/im-search-plugin.js +1 -1
- package/plugins/search/dist/esm/index.js +1 -1
- package/plugins/search/dist/umd/im-search-plugin.js +1 -1
- package/plugins/search/dist/umd/index.js +1 -1
- package/plugins/search/src/components/Suggestions/Suggestions.jsx +3 -1
- package/plugins/search/src/components/Suggestions/Suggestions.test.jsx +11 -0
- package/plugins/search/src/utils/markedToElements.jsx +25 -0
- package/plugins/search/src/utils/markedToElements.test.jsx +49 -0
- package/plugins/search/src/utils/parseOsNamesResults.js +6 -4
- package/plugins/search/src/utils/parseOsNamesResults.test.js +18 -0
- package/plugins/use-location/dist/esm/index.js +1 -0
- package/plugins/{beta/use-location → use-location}/dist/umd/im-use-location-plugin.js +1 -1
- package/plugins/{beta/use-location → use-location}/dist/umd/index.js +1 -1
- package/providers/esri/dist/esm/index.js +1 -0
- package/providers/{beta/esri → esri}/src/esriProvider.js +1 -1
- package/providers/{beta/esri → esri}/src/mapEvents.js +2 -2
- package/providers/maplibre/dist/esm/index.js +1 -1
- package/providers/open-names/dist/esm/index.js +1 -0
- package/providers/{beta/open-names → open-names}/dist/umd/im-reverse-geocode.js +1 -1
- package/providers/{beta/open-names → open-names}/dist/umd/index.js +1 -1
- package/providers/openlayers/dist/esm/index.js +1 -0
- package/providers/openlayers/dist/umd/im-openlayers-provider.js +2 -0
- package/providers/{beta/openlayers → openlayers}/dist/umd/index.js +1 -1
- package/providers/{beta/openlayers → openlayers}/src/index.js +4 -4
- package/providers/{beta/openlayers → openlayers}/src/mapEvents.js +2 -2
- package/providers/{beta/openlayers → openlayers}/src/mapEvents.test.js +2 -2
- package/providers/{beta/openlayers → openlayers}/src/openlayersProvider.js +3 -3
- package/providers/{beta/openlayers → openlayers}/src/utils/highlightFeatures.js +1 -1
- package/providers/{beta/openlayers → openlayers}/src/utils/patternImages.js +1 -1
- package/providers/{beta/openlayers → openlayers}/src/utils/symbolImages.js +1 -1
- package/rollup.esm.mjs +43 -47
- package/sonar-project.properties +1 -1
- package/src/App/App.jsx +4 -1
- package/src/App/App.test.jsx +6 -0
- package/src/App/renderer/PluginInits.jsx +8 -7
- package/src/App/renderer/PluginInits.test.jsx +20 -5
- package/src/App/renderer/SlotItemsProvider.jsx +33 -0
- package/src/App/renderer/SlotItemsProvider.test.jsx +59 -0
- package/src/App/renderer/SlotRenderer.jsx +3 -14
- package/src/App/renderer/SlotRenderer.test.jsx +11 -44
- package/src/App/renderer/mapButtons.js +22 -11
- package/src/App/renderer/mapButtons.test.js +23 -1
- package/src/App/renderer/mapControls.js +6 -8
- package/src/App/renderer/mapControls.test.js +10 -0
- package/src/App/renderer/mapPanels.js +16 -19
- package/src/App/renderer/mapPanels.test.js +37 -9
- package/src/App/renderer/pluginWrapper.js +10 -8
- package/src/App/renderer/pluginWrapper.test.js +23 -9
- package/src/App/renderer/slotAggregator.js +18 -5
- package/src/App/renderer/slotAggregator.test.js +68 -25
- package/src/App/renderer/slotHelpers.js +13 -0
- package/src/App/renderer/slotHelpers.test.js +16 -1
- package/src/App/store/AppProvider.jsx +19 -1
- package/src/App/store/AppProvider.test.jsx +41 -0
- package/src/App/store/appActionsMap.js +10 -1
- package/src/App/store/appActionsMap.test.js +21 -0
- package/src/App/store/appDispatchMiddleware.js +29 -17
- package/src/App/store/appDispatchMiddleware.test.js +31 -0
- package/src/InteractiveMap/parseDataProperties.js +4 -4
- package/src/InteractiveMap/parseDataProperties.test.js +62 -6
- package/src/config/events.js +4 -2
- package/src/scss/tools/_govuk-content.scss +4 -3
- package/webpack.dev.mjs +9 -3
- package/webpack.prod.mjs +11 -4
- package/webpack.umd.mjs +6 -7
- package/plugins/beta/draw-es/dist/esm/index.js +0 -1
- package/plugins/beta/draw-ml/dist/esm/im-draw-ml-plugin.js +0 -1
- package/plugins/beta/draw-ml/dist/esm/index.js +0 -1
- package/plugins/beta/draw-ml/dist/umd/im-draw-ml-plugin.js +0 -1
- package/plugins/beta/draw-ml/dist/umd/index.js +0 -2
- package/plugins/beta/draw-ml/src/DrawInit.jsx +0 -85
- package/plugins/beta/draw-ml/src/api/addFeature.js +0 -27
- package/plugins/beta/draw-ml/src/api/deleteFeature.js +0 -13
- package/plugins/beta/draw-ml/src/api/editFeature.js +0 -75
- package/plugins/beta/draw-ml/src/api/merge.js +0 -9
- package/plugins/beta/draw-ml/src/api/newLine.js +0 -68
- package/plugins/beta/draw-ml/src/api/newPolygon.js +0 -68
- package/plugins/beta/draw-ml/src/api/split.js +0 -81
- package/plugins/beta/draw-ml/src/defaults.js +0 -17
- package/plugins/beta/draw-ml/src/draw.scss +0 -26
- package/plugins/beta/draw-ml/src/events.js +0 -185
- package/plugins/beta/draw-ml/src/index.js +0 -13
- package/plugins/beta/draw-ml/src/manifest.js +0 -110
- package/plugins/beta/draw-ml/src/mapboxDraw.js +0 -143
- package/plugins/beta/draw-ml/src/mapboxSnap.js +0 -321
- package/plugins/beta/draw-ml/src/modes/createDrawMode.js +0 -552
- package/plugins/beta/draw-ml/src/modes/disabledMode.js +0 -23
- package/plugins/beta/draw-ml/src/modes/drawLineMode.js +0 -18
- package/plugins/beta/draw-ml/src/modes/drawPolygonMode.js +0 -16
- package/plugins/beta/draw-ml/src/modes/editVertex/geometryHelpers.js +0 -135
- package/plugins/beta/draw-ml/src/modes/editVertex/helpers.js +0 -2
- package/plugins/beta/draw-ml/src/modes/editVertex/touchHandlers.js +0 -142
- package/plugins/beta/draw-ml/src/modes/editVertex/undoHandlers.js +0 -133
- package/plugins/beta/draw-ml/src/modes/editVertex/vertexOperations.js +0 -142
- package/plugins/beta/draw-ml/src/modes/editVertex/vertexQueries.js +0 -121
- package/plugins/beta/draw-ml/src/modes/editVertexMode.js +0 -495
- package/plugins/beta/draw-ml/src/reducer.js +0 -90
- package/plugins/beta/draw-ml/src/styles.js +0 -190
- package/plugins/beta/draw-ml/src/undoStack.js +0 -50
- package/plugins/beta/draw-ml/src/utils/debounce.js +0 -16
- package/plugins/beta/draw-ml/src/utils/flattenStyleProperties.js +0 -49
- package/plugins/beta/draw-ml/src/utils/snapHelpers.js +0 -200
- package/plugins/beta/draw-ml/src/utils/spatial.js +0 -258
- package/plugins/beta/draw-ol/dist/css/index.css +0 -1
- package/plugins/beta/draw-ol/dist/esm/DrawMode.js +0 -1
- package/plugins/beta/draw-ol/dist/esm/EditMode.js +0 -1
- package/plugins/beta/draw-ol/dist/esm/geometryHelpers.js +0 -1
- package/plugins/beta/draw-ol/dist/esm/im-draw-ol-plugin.js +0 -1
- package/plugins/beta/draw-ol/dist/esm/index.js +0 -1
- package/plugins/beta/draw-ol/src/DrawInit.jsx +0 -65
- package/plugins/beta/draw-ol/src/api/addFeature.js +0 -29
- package/plugins/beta/draw-ol/src/api/deleteFeature.js +0 -11
- package/plugins/beta/draw-ol/src/api/editFeature.js +0 -50
- package/plugins/beta/draw-ol/src/api/newLine.js +0 -44
- package/plugins/beta/draw-ol/src/api/newPolygon.js +0 -44
- package/plugins/beta/draw-ol/src/core/OLDrawManager.js +0 -153
- package/plugins/beta/draw-ol/src/core/featureStore.js +0 -65
- package/plugins/beta/draw-ol/src/core/styles.js +0 -98
- package/plugins/beta/draw-ol/src/core/undoStack.js +0 -31
- package/plugins/beta/draw-ol/src/defaults.js +0 -16
- package/plugins/beta/draw-ol/src/draw/DrawMode.js +0 -121
- package/plugins/beta/draw-ol/src/draw/drawInput.js +0 -243
- package/plugins/beta/draw-ol/src/draw.scss +0 -17
- package/plugins/beta/draw-ol/src/edit/EditMode.js +0 -424
- package/plugins/beta/draw-ol/src/edit/keyboardHandler.js +0 -229
- package/plugins/beta/draw-ol/src/edit/midpointLayer.js +0 -57
- package/plugins/beta/draw-ol/src/edit/touchHandler.js +0 -171
- package/plugins/beta/draw-ol/src/edit/undoOps.js +0 -95
- package/plugins/beta/draw-ol/src/edit/vertexHitTest.js +0 -72
- package/plugins/beta/draw-ol/src/edit/vertexLayer.js +0 -49
- package/plugins/beta/draw-ol/src/edit/vertexOps.js +0 -99
- package/plugins/beta/draw-ol/src/events.js +0 -114
- package/plugins/beta/draw-ol/src/index.js +0 -12
- package/plugins/beta/draw-ol/src/manifest.js +0 -125
- package/plugins/beta/draw-ol/src/olDraw.js +0 -38
- package/plugins/beta/draw-ol/src/reducer.js +0 -41
- package/plugins/beta/draw-ol/src/snap/snapEngine.js +0 -153
- package/plugins/beta/draw-ol/src/snap/snapGeometry.js +0 -177
- package/plugins/beta/draw-ol/src/snap/snapIndicator.js +0 -81
- package/plugins/beta/draw-ol/src/snap/snapInteraction.js +0 -57
- package/plugins/beta/draw-ol/src/snap/snapManager.js +0 -99
- package/plugins/beta/draw-ol/src/utils/flattenStyleProperties.js +0 -47
- package/plugins/beta/draw-ol/src/utils/geometryHelpers.js +0 -103
- package/plugins/beta/draw-ol/src/utils/olCoords.js +0 -35
- package/plugins/beta/draw-ol/src/utils/resolveColors.js +0 -39
- package/plugins/beta/draw-ol/src/utils/spatial.js +0 -24
- package/plugins/beta/draw-ol/src/utils/touchTarget.js +0 -61
- package/plugins/beta/frame/dist/esm/index.js +0 -1
- package/plugins/beta/map-styles/dist/esm/index.js +0 -1
- package/plugins/beta/scale-bar/dist/esm/index.js +0 -1
- package/plugins/beta/use-location/dist/esm/index.js +0 -1
- package/plugins/map-key/src/registry/getDatasetRegistry.js +0 -6
- package/plugins/map-key/src/registry/getDatasetRegistry.test.js +0 -23
- package/plugins/map-key/src/registry/index.js +0 -1
- package/plugins/map-key/src/registry/index.test.js +0 -7
- package/providers/beta/esri/dist/esm/index.js +0 -1
- package/providers/beta/open-names/dist/esm/index.js +0 -1
- package/providers/beta/openlayers/dist/esm/index.js +0 -1
- package/providers/beta/openlayers/dist/umd/im-openlayers-provider.js +0 -2
- package/providers/beta/openlayers/dist/umd/index.js.LICENSE.txt +0 -1
- /package/plugins/{beta/draw-es → draw-es}/dist/esm/im-draw-es-plugin.js +0 -0
- /package/plugins/{beta/draw-es → draw-es}/src/api/addFeature.js +0 -0
- /package/plugins/{beta/draw-es → draw-es}/src/api/deleteFeature.js +0 -0
- /package/plugins/{beta/draw-es → draw-es}/src/api/editFeature.js +0 -0
- /package/plugins/{beta/draw-es → draw-es}/src/api/newPolygon.js +0 -0
- /package/plugins/{beta/draw-es → draw-es}/src/api/removeSafeZone.js +0 -0
- /package/plugins/{beta/draw-es → draw-es}/src/events.js +0 -0
- /package/plugins/{beta/draw-es → draw-es}/src/index.js +0 -0
- /package/plugins/{beta/draw-es → draw-es}/src/manifest.js +0 -0
- /package/plugins/{beta/draw-es → draw-es}/src/reducer.js +0 -0
- /package/plugins/{beta/draw-es → draw-es}/src/sketchViewModel.js +0 -0
- /package/plugins/{beta/frame → frame}/dist/css/index.css +0 -0
- /package/plugins/{beta/frame → frame}/dist/esm/im-frame-plugin.js +0 -0
- /package/plugins/{beta/draw-ml → frame}/dist/umd/index.js.LICENSE.txt +0 -0
- /package/plugins/{beta/frame → frame}/src/Frame.jsx +0 -0
- /package/plugins/{beta/frame → frame}/src/FrameInit.jsx +0 -0
- /package/plugins/{beta/frame → frame}/src/api/addFrame.js +0 -0
- /package/plugins/{beta/frame → frame}/src/api/editFeature.js +0 -0
- /package/plugins/{beta/frame → frame}/src/config.js +0 -0
- /package/plugins/{beta/frame → frame}/src/frame.scss +0 -0
- /package/plugins/{beta/frame → frame}/src/index.js +0 -0
- /package/plugins/{beta/frame → frame}/src/manifest.js +0 -0
- /package/plugins/{beta/frame → frame}/src/reducer.js +0 -0
- /package/plugins/{beta/frame → frame}/src/utils.js +0 -0
- /package/plugins/{beta/map-styles → map-styles}/dist/css/index.css +0 -0
- /package/plugins/{beta/map-styles → map-styles}/dist/esm/im-map-styles-plugin.js +0 -0
- /package/plugins/{beta/frame → map-styles}/dist/umd/index.js.LICENSE.txt +0 -0
- /package/plugins/{beta/map-styles → map-styles}/src/config.js +0 -0
- /package/plugins/{beta/map-styles → map-styles}/src/index.js +0 -0
- /package/plugins/{beta/map-styles → map-styles}/src/manifest.js +0 -0
- /package/plugins/{beta/map-styles → map-styles}/src/mapStyles.scss +0 -0
- /package/plugins/{beta/scale-bar → scale-bar}/dist/css/index.css +0 -0
- /package/plugins/{beta/scale-bar → scale-bar}/dist/esm/im-scale-bar-plugin.js +0 -0
- /package/plugins/{beta/map-styles → scale-bar}/dist/umd/index.js.LICENSE.txt +0 -0
- /package/plugins/{beta/scale-bar → scale-bar}/src/ScaleBar.jsx +0 -0
- /package/plugins/{beta/scale-bar → scale-bar}/src/ScaleBar.test.jsx +0 -0
- /package/plugins/{beta/scale-bar → scale-bar}/src/index.js +0 -0
- /package/plugins/{beta/scale-bar → scale-bar}/src/index.test.js +0 -0
- /package/plugins/{beta/scale-bar → scale-bar}/src/manifest.js +0 -0
- /package/plugins/{beta/scale-bar → scale-bar}/src/scaleBar.scss +0 -0
- /package/plugins/{beta/scale-bar → scale-bar}/src/utils.js +0 -0
- /package/plugins/{beta/scale-bar → scale-bar}/src/utils.test.js +0 -0
- /package/plugins/{beta/use-location → use-location}/dist/esm/im-use-location-plugin.js +0 -0
- /package/plugins/{beta/scale-bar → use-location}/dist/umd/index.js.LICENSE.txt +0 -0
- /package/plugins/{beta/use-location → use-location}/src/UseLocation.jsx +0 -0
- /package/plugins/{beta/use-location → use-location}/src/UseLocationInit.jsx +0 -0
- /package/plugins/{beta/use-location → use-location}/src/defaults.js +0 -0
- /package/plugins/{beta/use-location → use-location}/src/events.js +0 -0
- /package/plugins/{beta/use-location → use-location}/src/index.js +0 -0
- /package/plugins/{beta/use-location → use-location}/src/manifest.js +0 -0
- /package/plugins/{beta/use-location → use-location}/src/reducer.js +0 -0
- /package/providers/{beta/esri → esri}/dist/css/index.css +0 -0
- /package/providers/{beta/esri → esri}/dist/esm/im-esri-provider.js +0 -0
- /package/providers/{beta/esri → esri}/src/appEvents.js +0 -0
- /package/providers/{beta/esri → esri}/src/defaults.js +0 -0
- /package/providers/{beta/esri → esri}/src/esriProvider.scss +0 -0
- /package/providers/{beta/esri → esri}/src/index.js +0 -0
- /package/providers/{beta/esri → esri}/src/utils/coords.js +0 -0
- /package/providers/{beta/esri → esri}/src/utils/coords.test.js +0 -0
- /package/providers/{beta/esri → esri}/src/utils/detectWebGL.js +0 -0
- /package/providers/{beta/esri → esri}/src/utils/esriFixes.js +0 -0
- /package/providers/{beta/esri → esri}/src/utils/query.js +0 -0
- /package/providers/{beta/esri → esri}/src/utils/spatial.js +0 -0
- /package/providers/{beta/esri → esri}/src/utils/spatial.test.js +0 -0
- /package/providers/{beta/open-names → open-names}/dist/esm/im-reverse-geocode.js +0 -0
- /package/providers/{beta/open-names → open-names}/dist/umd/im-reverse-geocode.js.LICENSE.txt +0 -0
- /package/{plugins/beta/use-location → providers/open-names}/dist/umd/index.js.LICENSE.txt +0 -0
- /package/providers/{beta/open-names → open-names}/src/index.js +0 -0
- /package/providers/{beta/open-names → open-names}/src/reverseGeocode.js +0 -0
- /package/providers/{beta/open-names → open-names}/src/utils/mapToLocationModel.js +0 -0
- /package/providers/{beta/open-names → open-names}/src/utils/mapToLocationModel.test.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/dist/esm/im-openlayers-provider.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/dist/umd/im-openlayers-provider.js.LICENSE.txt +0 -0
- /package/providers/{beta/open-names → openlayers}/dist/umd/index.js.LICENSE.txt +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/appEvents.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/appEvents.test.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/defaults.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/index.test.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/openlayersProvider.test.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/bngProjection.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/filterEvaluator.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/filterEvaluator.test.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/highlightFeatures.test.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/hoverCursor.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/hoverCursor.test.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/openLayersFixes.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/openLayersFixes.test.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/patternImages.test.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/queryFeatures.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/queryFeatures.test.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/spatial.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/spatial.test.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/symbolImages.test.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/tileLayers.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/tileLayers.test.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/vtTileFragments.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/vtTileFragments.test.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/zoom.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/zoom.test.js +0 -0
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export const removeDataset = ({ pluginState: { dispatch } }, datasetId) => {
|
|
1
|
+
export const removeDataset = ({ pluginState: { dispatch }, mapProvider }, datasetId) => {
|
|
4
2
|
// Here we need to remove the dataset from the adapter before removing it from state,
|
|
5
3
|
// otherwise the datasetDefinition will have been removed from the registry by the
|
|
6
4
|
// time the adapter tries to remove the dataset, which causes an error
|
|
7
|
-
|
|
5
|
+
mapProvider.datasets?.removeDataset(datasetId)
|
|
8
6
|
dispatch({ type: 'REMOVE_DATASET', payload: { id: datasetId } })
|
|
9
7
|
}
|
|
@@ -1,22 +1,17 @@
|
|
|
1
1
|
import { removeDataset } from './removeDataset.js'
|
|
2
|
-
import { layerAdapter } from '../adapters/loadLayerAdapter.js'
|
|
3
2
|
|
|
4
|
-
jest.
|
|
5
|
-
layerAdapter: {
|
|
6
|
-
removeDataset: jest.fn()
|
|
7
|
-
}
|
|
8
|
-
}))
|
|
3
|
+
const layerAdapter = { removeDataset: jest.fn() }
|
|
9
4
|
|
|
10
5
|
describe('removeDataset', () => {
|
|
11
6
|
const dispatch = jest.fn()
|
|
12
7
|
it('calls layerAdapter.removeDataset with the datasetId', () => {
|
|
13
|
-
removeDataset({ pluginState: {
|
|
8
|
+
removeDataset({ pluginState: { dispatch }, mapProvider: { datasets: layerAdapter } }, 'my-dataset')
|
|
14
9
|
|
|
15
10
|
expect(layerAdapter.removeDataset).toHaveBeenCalledWith('my-dataset')
|
|
16
11
|
})
|
|
17
12
|
|
|
18
13
|
it('dispatches REMOVE_DATASET with the datasetId', () => {
|
|
19
|
-
removeDataset({ pluginState: {
|
|
14
|
+
removeDataset({ pluginState: { dispatch }, mapProvider: { datasets: layerAdapter } }, 'my-dataset')
|
|
20
15
|
|
|
21
16
|
expect(dispatch).toHaveBeenCalledWith({
|
|
22
17
|
type: 'REMOVE_DATASET',
|
|
@@ -29,13 +24,13 @@ describe('removeDataset', () => {
|
|
|
29
24
|
dispatch.mockImplementationOnce(() => callOrder.push('dispatch'))
|
|
30
25
|
layerAdapter.removeDataset.mockImplementationOnce(() => callOrder.push('adapter'))
|
|
31
26
|
|
|
32
|
-
removeDataset({ pluginState: {
|
|
27
|
+
removeDataset({ pluginState: { dispatch }, mapProvider: { datasets: layerAdapter } }, 'my-dataset')
|
|
33
28
|
|
|
34
29
|
expect(callOrder).toEqual(['adapter', 'dispatch'])
|
|
35
30
|
})
|
|
36
31
|
|
|
37
32
|
it('still dispatches REMOVE_DATASET when layerAdapter is undefined', () => {
|
|
38
|
-
removeDataset({ pluginState: {
|
|
33
|
+
removeDataset({ pluginState: { dispatch }, mapProvider: { datasets: undefined } }, 'my-dataset')
|
|
39
34
|
|
|
40
35
|
expect(dispatch).toHaveBeenCalledWith({
|
|
41
36
|
type: 'REMOVE_DATASET',
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { logger } from '../../../../src/services/logger.js'
|
|
2
|
-
import { datasetRegistry } from '../registry/datasetRegistry.js'
|
|
3
|
-
import { layerAdapter } from '../adapters/loadLayerAdapter.js'
|
|
4
2
|
|
|
5
|
-
export const setData = ({
|
|
3
|
+
export const setData = ({ pluginState: { datasetRegistry }, mapProvider }, geojson, { datasetId }) => {
|
|
6
4
|
const registryDataset = datasetRegistry.getDataset(datasetId)
|
|
7
5
|
if (!registryDataset) {
|
|
8
6
|
logger.warn(`setData: Dataset with id ${datasetId} not found`)
|
|
@@ -12,5 +10,5 @@ export const setData = ({ _pluginState }, geojson, { datasetId }) => {
|
|
|
12
10
|
logger.warn(`setData called on vector tile dataset "${datasetId}" — has no effect`)
|
|
13
11
|
return
|
|
14
12
|
}
|
|
15
|
-
|
|
13
|
+
mapProvider.datasets?.setData(datasetId, geojson)
|
|
16
14
|
}
|
|
@@ -1,17 +1,9 @@
|
|
|
1
1
|
import { setData } from './setData.js'
|
|
2
|
-
import { datasetRegistry } from '../registry/datasetRegistry.js'
|
|
3
2
|
import { logger } from '../../../../src/services/logger.js'
|
|
4
|
-
import { layerAdapter } from '../adapters/loadLayerAdapter.js'
|
|
5
3
|
|
|
6
|
-
jest.
|
|
7
|
-
layerAdapter: {
|
|
8
|
-
setData: jest.fn()
|
|
9
|
-
}
|
|
10
|
-
}))
|
|
4
|
+
const layerAdapter = { setData: jest.fn() }
|
|
11
5
|
|
|
12
|
-
jest.
|
|
13
|
-
datasetRegistry: { getDataset: jest.fn() }
|
|
14
|
-
}))
|
|
6
|
+
const datasetRegistry = { getDataset: jest.fn() }
|
|
15
7
|
|
|
16
8
|
jest.mock('../../../../src/services/logger.js')
|
|
17
9
|
|
|
@@ -24,7 +16,7 @@ describe('setData', () => {
|
|
|
24
16
|
it('calls layerAdapter.setData with datasetId and geojson', () => {
|
|
25
17
|
datasetRegistry.getDataset.mockReturnValue({ id: 'my-dataset' })
|
|
26
18
|
|
|
27
|
-
setData({ pluginState: { layerAdapter } }, geojson, { datasetId: 'my-dataset' })
|
|
19
|
+
setData({ pluginState: { datasetRegistry }, mapProvider: { datasets: layerAdapter } }, geojson, { datasetId: 'my-dataset' })
|
|
28
20
|
|
|
29
21
|
expect(layerAdapter.setData).toHaveBeenCalledWith('my-dataset', geojson)
|
|
30
22
|
})
|
|
@@ -32,7 +24,7 @@ describe('setData', () => {
|
|
|
32
24
|
it('does nothing when the dataset is not found in the registry', () => {
|
|
33
25
|
datasetRegistry.getDataset.mockReturnValue(undefined)
|
|
34
26
|
|
|
35
|
-
setData({ pluginState: { layerAdapter } }, geojson, { datasetId: 'missing' })
|
|
27
|
+
setData({ pluginState: { datasetRegistry }, mapProvider: { datasets: layerAdapter } }, geojson, { datasetId: 'missing' })
|
|
36
28
|
|
|
37
29
|
expect(layerAdapter.setData).not.toHaveBeenCalled()
|
|
38
30
|
expect(logger.warn).toHaveBeenCalledWith(expect.stringContaining('missing'))
|
|
@@ -44,7 +36,7 @@ describe('setData', () => {
|
|
|
44
36
|
tiles: ['https://example.com/{z}/{x}/{y}']
|
|
45
37
|
})
|
|
46
38
|
|
|
47
|
-
setData({ pluginState: { layerAdapter } }, geojson, { datasetId: 'tiles-dataset' })
|
|
39
|
+
setData({ pluginState: { datasetRegistry }, mapProvider: { datasets: layerAdapter } }, geojson, { datasetId: 'tiles-dataset' })
|
|
48
40
|
|
|
49
41
|
expect(layerAdapter.setData).not.toHaveBeenCalled()
|
|
50
42
|
expect(logger.warn).toHaveBeenCalledWith(expect.stringContaining('tiles-dataset'))
|
|
@@ -54,7 +46,7 @@ describe('setData', () => {
|
|
|
54
46
|
datasetRegistry.getDataset.mockReturnValue({ id: 'my-dataset' })
|
|
55
47
|
// Should not throw even if layerAdapter is undefined
|
|
56
48
|
expect(() =>
|
|
57
|
-
setData({ pluginState: {
|
|
49
|
+
setData({ pluginState: { datasetRegistry }, mapProvider: { datasets: undefined } }, geojson, { datasetId: 'my-dataset' })
|
|
58
50
|
).not.toThrow()
|
|
59
51
|
})
|
|
60
52
|
})
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { logger } from '../../../../src/services/logger.js'
|
|
2
|
-
import { datasetRegistry } from '../registry/datasetRegistry.js'
|
|
3
2
|
|
|
4
|
-
export const setFeatureVisibility = ({ pluginState: { dispatch } }, visible, featureIds, { datasetId = null } = {}) => {
|
|
3
|
+
export const setFeatureVisibility = ({ pluginState: { dispatch, datasetRegistry } }, visible, featureIds, { datasetId = null } = {}) => {
|
|
5
4
|
if (datasetId) {
|
|
6
5
|
const dataset = datasetRegistry.getDataset(datasetId)
|
|
7
6
|
if (dataset && !dataset.idProperty && !dataset.generateIds) {
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { setFeatureVisibility } from './setFeatureVisibility.js'
|
|
2
|
-
import { datasetRegistry } from '../registry/datasetRegistry.js'
|
|
3
2
|
import { logger } from '../../../../src/services/logger.js'
|
|
4
3
|
|
|
5
|
-
jest.
|
|
6
|
-
datasetRegistry: { getDataset: jest.fn() }
|
|
7
|
-
}))
|
|
4
|
+
const datasetRegistry = { getDataset: jest.fn() }
|
|
8
5
|
|
|
9
6
|
jest.mock('../../../../src/services/logger.js')
|
|
10
7
|
|
|
@@ -19,7 +16,7 @@ describe('setFeatureVisibility', () => {
|
|
|
19
16
|
})
|
|
20
17
|
|
|
21
18
|
it('dispatches SHOW_FEATURES when visible is true', () => {
|
|
22
|
-
setFeatureVisibility({ pluginState: { dispatch } }, true, featureIds, { datasetId })
|
|
19
|
+
setFeatureVisibility({ pluginState: { dispatch, datasetRegistry } }, true, featureIds, { datasetId })
|
|
23
20
|
|
|
24
21
|
expect(dispatch).toHaveBeenCalledWith({
|
|
25
22
|
type: 'SHOW_FEATURES',
|
|
@@ -28,7 +25,7 @@ describe('setFeatureVisibility', () => {
|
|
|
28
25
|
})
|
|
29
26
|
|
|
30
27
|
it('dispatches HIDE_FEATURES when visible is false', () => {
|
|
31
|
-
setFeatureVisibility({ pluginState: { dispatch } }, false, featureIds, { datasetId })
|
|
28
|
+
setFeatureVisibility({ pluginState: { dispatch, datasetRegistry } }, false, featureIds, { datasetId })
|
|
32
29
|
|
|
33
30
|
expect(dispatch).toHaveBeenCalledWith({
|
|
34
31
|
type: 'HIDE_FEATURES',
|
|
@@ -37,7 +34,7 @@ describe('setFeatureVisibility', () => {
|
|
|
37
34
|
})
|
|
38
35
|
|
|
39
36
|
it('uses null datasetId when options are not provided', () => {
|
|
40
|
-
setFeatureVisibility({ pluginState: { dispatch } }, true, featureIds)
|
|
37
|
+
setFeatureVisibility({ pluginState: { dispatch, datasetRegistry } }, true, featureIds)
|
|
41
38
|
|
|
42
39
|
expect(dispatch).toHaveBeenCalledWith({
|
|
43
40
|
type: 'SHOW_FEATURES',
|
|
@@ -47,25 +44,25 @@ describe('setFeatureVisibility', () => {
|
|
|
47
44
|
|
|
48
45
|
it('does not warn when dataset has idProperty set', () => {
|
|
49
46
|
datasetRegistry.getDataset.mockReturnValue({ idProperty: 'parcel_id', generateIds: false })
|
|
50
|
-
setFeatureVisibility({ pluginState: { dispatch } }, false, featureIds, { datasetId })
|
|
47
|
+
setFeatureVisibility({ pluginState: { dispatch, datasetRegistry } }, false, featureIds, { datasetId })
|
|
51
48
|
expect(logger.warn).not.toHaveBeenCalled()
|
|
52
49
|
})
|
|
53
50
|
|
|
54
51
|
it('does not warn when dataset has generateIds set', () => {
|
|
55
52
|
datasetRegistry.getDataset.mockReturnValue({ idProperty: null, generateIds: true })
|
|
56
|
-
setFeatureVisibility({ pluginState: { dispatch } }, false, featureIds, { datasetId })
|
|
53
|
+
setFeatureVisibility({ pluginState: { dispatch, datasetRegistry } }, false, featureIds, { datasetId })
|
|
57
54
|
expect(logger.warn).not.toHaveBeenCalled()
|
|
58
55
|
})
|
|
59
56
|
|
|
60
57
|
it('warns when dataset has neither idProperty nor generateIds', () => {
|
|
61
58
|
datasetRegistry.getDataset.mockReturnValue({ idProperty: null, generateIds: false })
|
|
62
|
-
setFeatureVisibility({ pluginState: { dispatch } }, false, featureIds, { datasetId })
|
|
59
|
+
setFeatureVisibility({ pluginState: { dispatch, datasetRegistry } }, false, featureIds, { datasetId })
|
|
63
60
|
expect(logger.warn).toHaveBeenCalledWith(expect.stringContaining(`"${datasetId}"`))
|
|
64
61
|
expect(logger.warn).toHaveBeenCalledWith(expect.stringContaining('idProperty'))
|
|
65
62
|
})
|
|
66
63
|
|
|
67
64
|
it('does not warn or look up registry when datasetId is not provided', () => {
|
|
68
|
-
setFeatureVisibility({ pluginState: { dispatch } }, false, featureIds)
|
|
65
|
+
setFeatureVisibility({ pluginState: { dispatch, datasetRegistry } }, false, featureIds)
|
|
69
66
|
expect(datasetRegistry.getDataset).not.toHaveBeenCalled()
|
|
70
67
|
expect(logger.warn).not.toHaveBeenCalled()
|
|
71
68
|
})
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export const LayersMenuCheckbox = ({ menuGroupItem, onChange }) => {
|
|
1
|
+
export const LayersMenuCheckbox = ({ menuGroupItem, datasetRegistry, onChange }) => {
|
|
4
2
|
const registryDataset = datasetRegistry.getDataset(menuGroupItem.id)
|
|
5
3
|
if (!registryDataset) {
|
|
6
4
|
return null
|
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
import { render, screen, act } from '@testing-library/react'
|
|
2
|
-
import { datasetRegistry } from '../../registry/datasetRegistry.js'
|
|
3
2
|
import { LayersMenuCheckbox } from './LayersMenuCheckbox.jsx'
|
|
4
3
|
|
|
5
|
-
jest.
|
|
6
|
-
datasetRegistry: {
|
|
7
|
-
getDataset: jest.fn()
|
|
8
|
-
}
|
|
9
|
-
}))
|
|
4
|
+
const datasetRegistry = { getDataset: jest.fn() }
|
|
10
5
|
|
|
11
6
|
const onChange = jest.fn()
|
|
12
7
|
const menuGroupItem = { id: 'dataset-1' }
|
|
@@ -29,7 +24,7 @@ describe('LayersMenuCheckbox', () => {
|
|
|
29
24
|
describe('when the dataset is not in the registry', () => {
|
|
30
25
|
it('returns null', () => {
|
|
31
26
|
datasetRegistry.getDataset.mockReturnValue(undefined)
|
|
32
|
-
const { container } = render(<LayersMenuCheckbox menuGroupItem={menuGroupItem} onChange={onChange} />)
|
|
27
|
+
const { container } = render(<LayersMenuCheckbox menuGroupItem={menuGroupItem} datasetRegistry={datasetRegistry} onChange={onChange} />)
|
|
33
28
|
expect(container.firstChild).toBeNull()
|
|
34
29
|
})
|
|
35
30
|
})
|
|
@@ -37,19 +32,19 @@ describe('LayersMenuCheckbox', () => {
|
|
|
37
32
|
describe('when the dataset exists', () => {
|
|
38
33
|
it('renders a checkbox input', () => {
|
|
39
34
|
datasetRegistry.getDataset.mockReturnValue(baseDataset)
|
|
40
|
-
const { container } = render(<LayersMenuCheckbox menuGroupItem={menuGroupItem} onChange={onChange} />)
|
|
35
|
+
const { container } = render(<LayersMenuCheckbox menuGroupItem={menuGroupItem} datasetRegistry={datasetRegistry} onChange={onChange} />)
|
|
41
36
|
expect(container.querySelector('input[type="checkbox"]')).toBeTruthy()
|
|
42
37
|
})
|
|
43
38
|
|
|
44
39
|
it('renders the dataset label', () => {
|
|
45
40
|
datasetRegistry.getDataset.mockReturnValue(baseDataset)
|
|
46
|
-
render(<LayersMenuCheckbox menuGroupItem={menuGroupItem} onChange={onChange} />)
|
|
41
|
+
render(<LayersMenuCheckbox menuGroupItem={menuGroupItem} datasetRegistry={datasetRegistry} onChange={onChange} />)
|
|
47
42
|
expect(screen.getByText('Dataset One')).toBeTruthy()
|
|
48
43
|
})
|
|
49
44
|
|
|
50
45
|
it('associates the label with the input via htmlFor', () => {
|
|
51
46
|
datasetRegistry.getDataset.mockReturnValue(baseDataset)
|
|
52
|
-
const { container } = render(<LayersMenuCheckbox menuGroupItem={menuGroupItem} onChange={onChange} />)
|
|
47
|
+
const { container } = render(<LayersMenuCheckbox menuGroupItem={menuGroupItem} datasetRegistry={datasetRegistry} onChange={onChange} />)
|
|
53
48
|
const label = container.querySelector('label')
|
|
54
49
|
const input = container.querySelector('input')
|
|
55
50
|
expect(label.htmlFor).toBe(input.id)
|
|
@@ -57,7 +52,7 @@ describe('LayersMenuCheckbox', () => {
|
|
|
57
52
|
|
|
58
53
|
it('calls onChange when the checkbox changes', () => {
|
|
59
54
|
datasetRegistry.getDataset.mockReturnValue(baseDataset)
|
|
60
|
-
const { container } = render(<LayersMenuCheckbox menuGroupItem={menuGroupItem} onChange={onChange} />)
|
|
55
|
+
const { container } = render(<LayersMenuCheckbox menuGroupItem={menuGroupItem} datasetRegistry={datasetRegistry} onChange={onChange} />)
|
|
61
56
|
const input = container.querySelector('input')
|
|
62
57
|
const propsKey = Object.keys(input).find(k => k.startsWith('__reactProps'))
|
|
63
58
|
act(() => { input[propsKey].onChange({ target: { checked: true, value: input.value } }) })
|
|
@@ -68,13 +63,13 @@ describe('LayersMenuCheckbox', () => {
|
|
|
68
63
|
describe('checked state', () => {
|
|
69
64
|
it('is checked when isLocallyVisible is true', () => {
|
|
70
65
|
datasetRegistry.getDataset.mockReturnValue({ ...baseDataset, isLocallyVisible: true })
|
|
71
|
-
const { container } = render(<LayersMenuCheckbox menuGroupItem={menuGroupItem} onChange={onChange} />)
|
|
66
|
+
const { container } = render(<LayersMenuCheckbox menuGroupItem={menuGroupItem} datasetRegistry={datasetRegistry} onChange={onChange} />)
|
|
72
67
|
expect(container.querySelector('input').checked).toBe(true)
|
|
73
68
|
})
|
|
74
69
|
|
|
75
70
|
it('is unchecked when isLocallyVisible is false', () => {
|
|
76
71
|
datasetRegistry.getDataset.mockReturnValue({ ...baseDataset, isLocallyVisible: false })
|
|
77
|
-
const { container } = render(<LayersMenuCheckbox menuGroupItem={menuGroupItem} onChange={onChange} />)
|
|
72
|
+
const { container } = render(<LayersMenuCheckbox menuGroupItem={menuGroupItem} datasetRegistry={datasetRegistry} onChange={onChange} />)
|
|
78
73
|
expect(container.querySelector('input').checked).toBe(false)
|
|
79
74
|
})
|
|
80
75
|
})
|
|
@@ -82,13 +77,13 @@ describe('LayersMenuCheckbox', () => {
|
|
|
82
77
|
describe('item class', () => {
|
|
83
78
|
it('does not include the --checked modifier when visible is true', () => {
|
|
84
79
|
datasetRegistry.getDataset.mockReturnValue({ ...baseDataset, visible: true })
|
|
85
|
-
const { container } = render(<LayersMenuCheckbox menuGroupItem={menuGroupItem} onChange={onChange} />)
|
|
80
|
+
const { container } = render(<LayersMenuCheckbox menuGroupItem={menuGroupItem} datasetRegistry={datasetRegistry} onChange={onChange} />)
|
|
86
81
|
expect(container.firstChild.className).not.toContain('im-c-datasets-layers__item--checked')
|
|
87
82
|
})
|
|
88
83
|
|
|
89
84
|
it('includes the --checked modifier when visible is false', () => {
|
|
90
85
|
datasetRegistry.getDataset.mockReturnValue({ ...baseDataset, visible: false })
|
|
91
|
-
const { container } = render(<LayersMenuCheckbox menuGroupItem={menuGroupItem} onChange={onChange} />)
|
|
86
|
+
const { container } = render(<LayersMenuCheckbox menuGroupItem={menuGroupItem} datasetRegistry={datasetRegistry} onChange={onChange} />)
|
|
92
87
|
expect(container.firstChild.className).toContain('im-c-datasets-layers__item--checked')
|
|
93
88
|
})
|
|
94
89
|
})
|
|
@@ -96,7 +91,7 @@ describe('LayersMenuCheckbox', () => {
|
|
|
96
91
|
describe('data attributes', () => {
|
|
97
92
|
it('uses the dataset id as data-dataset-id when not a sublayer', () => {
|
|
98
93
|
datasetRegistry.getDataset.mockReturnValue({ ...baseDataset, isSublayer: false })
|
|
99
|
-
const { container } = render(<LayersMenuCheckbox menuGroupItem={menuGroupItem} onChange={onChange} />)
|
|
94
|
+
const { container } = render(<LayersMenuCheckbox menuGroupItem={menuGroupItem} datasetRegistry={datasetRegistry} onChange={onChange} />)
|
|
100
95
|
const input = container.querySelector('input')
|
|
101
96
|
expect(input.dataset.datasetId).toBe('dataset-1')
|
|
102
97
|
expect(input.dataset.sublayerId).toBeUndefined()
|
|
@@ -104,13 +99,13 @@ describe('LayersMenuCheckbox', () => {
|
|
|
104
99
|
|
|
105
100
|
it('uses parentId as data-dataset-id when a sublayer', () => {
|
|
106
101
|
datasetRegistry.getDataset.mockReturnValue({ ...baseDataset, id: 'sub-1', isSublayer: true, parentId: 'parent-1' })
|
|
107
|
-
const { container } = render(<LayersMenuCheckbox menuGroupItem={menuGroupItem} onChange={onChange} />)
|
|
102
|
+
const { container } = render(<LayersMenuCheckbox menuGroupItem={menuGroupItem} datasetRegistry={datasetRegistry} onChange={onChange} />)
|
|
108
103
|
expect(container.querySelector('input').dataset.datasetId).toBe('parent-1')
|
|
109
104
|
})
|
|
110
105
|
|
|
111
106
|
it('uses the sublayer id as data-sublayer-id when a sublayer', () => {
|
|
112
107
|
datasetRegistry.getDataset.mockReturnValue({ ...baseDataset, id: 'sub-1', isSublayer: true, parentId: 'parent-1' })
|
|
113
|
-
const { container } = render(<LayersMenuCheckbox menuGroupItem={menuGroupItem} onChange={onChange} />)
|
|
108
|
+
const { container } = render(<LayersMenuCheckbox menuGroupItem={menuGroupItem} datasetRegistry={datasetRegistry} onChange={onChange} />)
|
|
114
109
|
expect(container.querySelector('input').dataset.sublayerId).toBe('sub-1')
|
|
115
110
|
})
|
|
116
111
|
})
|
|
@@ -7,8 +7,8 @@ export default function createPlugin (options = { }) {
|
|
|
7
7
|
...options,
|
|
8
8
|
id: 'datasets',
|
|
9
9
|
load: async () => {
|
|
10
|
-
const
|
|
11
|
-
return
|
|
10
|
+
const { createManifest } = await import(/* webpackChunkName: "im-datasets-plugin" */ './manifest.js')
|
|
11
|
+
return createManifest(options)
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import createPlugin from './index.js'
|
|
2
|
+
import { createManifest } from './manifest.js'
|
|
2
3
|
|
|
3
4
|
jest.mock('./datasets.scss', () => {})
|
|
4
5
|
jest.mock('./manifest.js', () => ({
|
|
5
|
-
|
|
6
|
+
createManifest: jest.fn(() => ({ InitComponent: jest.fn(), reducer: {} }))
|
|
6
7
|
}))
|
|
7
8
|
|
|
8
9
|
describe('createPlugin', () => {
|
|
@@ -33,4 +34,10 @@ describe('createPlugin', () => {
|
|
|
33
34
|
const result = await plugin.load()
|
|
34
35
|
expect(result).toBeDefined()
|
|
35
36
|
})
|
|
37
|
+
|
|
38
|
+
it('load() builds the manifest from the plugin options', async () => {
|
|
39
|
+
const options = { hasMenu: false }
|
|
40
|
+
await createPlugin(options).load()
|
|
41
|
+
expect(createManifest).toHaveBeenCalledWith(options)
|
|
42
|
+
})
|
|
36
43
|
})
|
|
@@ -2,27 +2,41 @@
|
|
|
2
2
|
import { useEffect, useRef } from 'react'
|
|
3
3
|
import { EVENTS } from '../../../../src/config/events.js'
|
|
4
4
|
import { initialiseDatasets } from './initialiseDatasets.js'
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
5
|
+
import { loadLayerAdapter } from '../adapters/loadLayerAdapter.js'
|
|
6
|
+
import { hasLayersMenu } from '../utils/hasLayersMenu.js'
|
|
7
|
+
import { getPanelElementId } from '../../../../src/utils/getPanelElementId.js'
|
|
8
8
|
|
|
9
|
-
const
|
|
10
|
-
pluginConfig.datasets
|
|
11
|
-
.some(dataset => dataset.showInMenu || dataset.sublayers?.some(sublayer => sublayer.showInMenu))
|
|
9
|
+
const LAYERS_PANEL_ID = 'datasetsLayers'
|
|
12
10
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const { eventBus,
|
|
16
|
-
const
|
|
11
|
+
// Closes the Layers panel if its menu empties while it's open
|
|
12
|
+
function useCloseEmptyLayersPanel ({ appConfig, appState, pluginConfig, pluginState, services }) {
|
|
13
|
+
const { eventBus, focusMap } = services
|
|
14
|
+
const hasMenu = hasLayersMenu({ pluginConfig, pluginState })
|
|
15
|
+
const isLayersPanelOpen = Boolean(appState.openPanels[LAYERS_PANEL_ID])
|
|
16
|
+
const focusFrameRef = useRef(null)
|
|
17
17
|
|
|
18
18
|
useEffect(() => {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
if (hasMenu || !isLayersPanelOpen) {
|
|
20
|
+
return
|
|
21
|
+
}
|
|
22
|
+
const panelEl = document.getElementById(getPanelElementId(appConfig.id, LAYERS_PANEL_ID))
|
|
23
|
+
const hadFocus = Boolean(panelEl?.contains(document.activeElement))
|
|
24
|
+
eventBus.emit(EVENTS.APP_HIDE_PANEL, LAYERS_PANEL_ID)
|
|
25
|
+
if (hadFocus) {
|
|
26
|
+
// Let the panel close and release modal focus/inert first, as Panel's handleClose does
|
|
27
|
+
focusFrameRef.current = requestAnimationFrame(() => focusMap())
|
|
24
28
|
}
|
|
25
|
-
}, [
|
|
29
|
+
}, [hasMenu, isLayersPanelOpen])
|
|
30
|
+
|
|
31
|
+
useEffect(() => () => cancelAnimationFrame(focusFrameRef.current), [])
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function DatasetsInit ({ appConfig, appState, pluginConfig, pluginState, mapState, mapProvider, services }) {
|
|
35
|
+
const { dispatch, datasetRegistry } = pluginState
|
|
36
|
+
const { eventBus, symbolRegistry, patternRegistry } = services
|
|
37
|
+
const isBaseMapReady = Boolean(mapProvider?.isBaseMapReady())
|
|
38
|
+
|
|
39
|
+
useCloseEmptyLayersPanel({ appConfig, appState, pluginConfig, pluginState, services })
|
|
26
40
|
|
|
27
41
|
// Keep a ref to the latest pluginState so event handlers can access current data
|
|
28
42
|
const pluginStateRef = useRef(pluginState)
|
|
@@ -31,6 +45,14 @@ export function DatasetsInit ({ pluginConfig, pluginState, mapState, mapProvider
|
|
|
31
45
|
// Track initialisation and store cleanup function
|
|
32
46
|
const datasetsInstanceRef = useRef(null)
|
|
33
47
|
|
|
48
|
+
// Call layerAdapter methods queued from state updates. They wait until the adapter has loaded.
|
|
49
|
+
const runQueuedActions = (actionsArray) => {
|
|
50
|
+
const layerAdapter = mapProvider?.datasets
|
|
51
|
+
if (!actionsArray.length || !layerAdapter) { return }
|
|
52
|
+
actionsArray.forEach(({ method, parameters }) => layerAdapter[method](...parameters))
|
|
53
|
+
dispatch({ type: 'REMOVE_ADAPTER_ACTIONS', payload: actionsArray })
|
|
54
|
+
}
|
|
55
|
+
|
|
34
56
|
useEffect(() => {
|
|
35
57
|
if (!isBaseMapReady) {
|
|
36
58
|
return
|
|
@@ -42,10 +64,11 @@ export function DatasetsInit ({ pluginConfig, pluginState, mapState, mapProvider
|
|
|
42
64
|
}
|
|
43
65
|
|
|
44
66
|
const initDatasets = async () => {
|
|
45
|
-
const adapter = await loadLayerAdapter(mapProvider, symbolRegistry, patternRegistry)
|
|
67
|
+
const adapter = await loadLayerAdapter(mapProvider, symbolRegistry, patternRegistry, datasetRegistry)
|
|
46
68
|
|
|
47
69
|
datasetsInstanceRef.current = initialiseDatasets({
|
|
48
70
|
adapter,
|
|
71
|
+
datasetRegistry,
|
|
49
72
|
pluginConfig,
|
|
50
73
|
pluginStateRef,
|
|
51
74
|
mapStyle: mapState.mapStyle,
|
|
@@ -54,6 +77,9 @@ export function DatasetsInit ({ pluginConfig, pluginState, mapState, mapProvider
|
|
|
54
77
|
dispatch,
|
|
55
78
|
eventBus
|
|
56
79
|
})
|
|
80
|
+
// Each map has its own provider, so its API calls reach its own adapter
|
|
81
|
+
mapProvider.datasets = adapter
|
|
82
|
+
runQueuedActions(pluginStateRef.current.actionsArray)
|
|
57
83
|
}
|
|
58
84
|
|
|
59
85
|
initDatasets() // NOSONAR: Not changing for now as used in production
|
|
@@ -67,12 +93,13 @@ export function DatasetsInit ({ pluginConfig, pluginState, mapState, mapProvider
|
|
|
67
93
|
|
|
68
94
|
useEffect(() => {
|
|
69
95
|
datasetRegistry.attachMapStyle(mapState.mapStyle)
|
|
96
|
+
const layerAdapter = mapProvider?.datasets
|
|
70
97
|
if (layerAdapter?.onMapStyleChange) {
|
|
71
98
|
// MapLibre's own map.addImage()/setPaintProperty() calls (made while re-registering
|
|
72
99
|
// symbols/patterns below) naturally re-trigger MAP_DATA_CHANGE via the GL engine's own
|
|
73
100
|
// styledata event — nothing extra needed there. OL has no such generic signal (its
|
|
74
101
|
// MAP_DATA_CHANGE is tied only to the basemap tile source's own tileloadend — see
|
|
75
|
-
// providers/
|
|
102
|
+
// providers/openlayers/src/appEvents.js's comment), so re-registering a symbol on a
|
|
76
103
|
// plain ol/layer/Vector never fires it. Emitting it explicitly once re-registration
|
|
77
104
|
// genuinely finishes lets the interact plugin's settle-window re-apply (armed by
|
|
78
105
|
// MAP_STYLE_CHANGE, see useHighlightSync.js) pick up the new theme's selected/active
|
|
@@ -85,15 +112,9 @@ export function DatasetsInit ({ pluginConfig, pluginState, mapState, mapProvider
|
|
|
85
112
|
},
|
|
86
113
|
[mapState.mapStyle])
|
|
87
114
|
|
|
88
|
-
useEffect(() =>
|
|
115
|
+
useEffect(() => datasetRegistry.attachGlobals(pluginState.globals), [pluginState.globals])
|
|
89
116
|
|
|
90
|
-
|
|
91
|
-
useEffect(() => {
|
|
92
|
-
const { actionsArray } = pluginState
|
|
93
|
-
if (!actionsArray.length) { return }
|
|
94
|
-
actionsArray.forEach(({ method, parameters }) => layerAdapter[method](...parameters))
|
|
95
|
-
dispatch({ type: 'REMOVE_ADAPTER_ACTIONS', payload: actionsArray })
|
|
96
|
-
}, [pluginState.actionsArray])
|
|
117
|
+
useEffect(() => runQueuedActions(pluginState.actionsArray), [pluginState.actionsArray])
|
|
97
118
|
|
|
98
119
|
// Cleanup only on unmount
|
|
99
120
|
useEffect(() => {
|
|
@@ -101,6 +122,7 @@ export function DatasetsInit ({ pluginConfig, pluginState, mapState, mapProvider
|
|
|
101
122
|
if (datasetsInstanceRef.current) {
|
|
102
123
|
datasetsInstanceRef.current.remove()
|
|
103
124
|
datasetsInstanceRef.current = null
|
|
125
|
+
mapProvider.datasets = null
|
|
104
126
|
}
|
|
105
127
|
}
|
|
106
128
|
}, [])
|