@defra/interactive-map 0.0.40-alpha → 0.0.42-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/dist/css/index.css +1 -1
- package/dist/esm/im-core.js +1 -1
- package/dist/esm/im-shell.js +1 -1
- package/dist/umd/im-core.js +1 -1
- package/dist/umd/index.js +1 -1
- package/docs/api/button-definition.md +7 -8
- package/docs/api/control-definition.md +17 -1
- package/docs/api/panel-definition.md +5 -0
- package/docs/api/slots.md +50 -6
- package/docs/assets/images/slot-map.svg +61 -262
- package/docs/examples/add-polygons.mdx +8 -2
- package/docs/examples/add-symbols.mdx +8 -2
- package/docs/examples/draw-tools.mdx +3 -3
- package/docs/plugins/datasets.md +23 -15
- package/docs/plugins/draw.md +79 -16
- package/docs/plugins/map-key.md +147 -0
- package/docs/plugins/search.md +1 -1
- package/docs/plugins.md +5 -1
- package/govuk-prototype-kit.config.json +2 -0
- package/jest.setup.js +5 -0
- package/package.json +9 -1
- package/plugins/beta/draw-es/dist/esm/im-draw-es-plugin.js +1 -1
- package/plugins/beta/draw-ml/dist/esm/im-draw-ml-plugin.js +1 -1
- package/plugins/beta/draw-ml/dist/umd/im-draw-ml-plugin.js +1 -1
- package/plugins/beta/draw-ol/dist/esm/im-draw-ol-plugin.js +1 -1
- package/plugins/beta/map-styles/dist/umd/im-map-styles-plugin.js +1 -1
- package/plugins/beta/map-styles/dist/umd/index.js +1 -1
- package/plugins/beta/use-location/dist/esm/im-use-location-plugin.js +1 -1
- package/plugins/beta/use-location/dist/umd/im-use-location-plugin.js +1 -1
- package/plugins/beta/use-location/src/manifest.js +1 -1
- package/plugins/datasets/dist/css/index.css +1 -1
- package/plugins/datasets/dist/esm/esriLayerAdapter.js +1 -1
- package/plugins/datasets/dist/esm/im-datasets-ml-adapter.js +1 -1
- package/plugins/datasets/dist/esm/im-datasets-plugin.js +1 -1
- package/plugins/datasets/dist/umd/im-datasets-esri-adapter.js +1 -1
- package/plugins/datasets/dist/umd/im-datasets-ml-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.test.js +175 -0
- package/plugins/datasets/src/adapters/esri/registry/esriDataset.test.js +55 -0
- package/plugins/datasets/src/adapters/loadLayerAdapter.test.js +61 -0
- package/plugins/datasets/src/adapters/maplibre/maplibreLayerAdapter.test.js +14 -0
- package/plugins/datasets/src/api/setOpacity.test.js +9 -0
- package/plugins/datasets/src/components/LayersMenu/LayersMenu.jsx +10 -25
- package/plugins/datasets/src/components/LayersMenu/LayersMenu.test.jsx +0 -42
- package/plugins/datasets/src/datasets.scss +0 -1
- package/plugins/datasets/src/fetch/createDynamicSource.js +135 -129
- package/plugins/datasets/src/fetch/createDynamicSource.test.js +318 -0
- package/plugins/datasets/src/fetch/fetchGeoJSON.test.js +83 -0
- package/plugins/datasets/src/index.test.js +36 -0
- package/plugins/datasets/src/initialise/DatasetsInit.jsx +17 -7
- package/plugins/datasets/src/initialise/DatasetsInit.test.jsx +262 -0
- package/plugins/datasets/src/initialise/initialiseDatasets.js +16 -4
- package/plugins/datasets/src/initialise/initialiseDatasets.test.js +42 -0
- package/plugins/datasets/src/manifest.js +0 -38
- package/plugins/datasets/src/manifest.test.js +49 -0
- package/plugins/datasets/src/reducers/datasetsToMenu.test.js +54 -1
- package/plugins/datasets/src/reducers/pluginState.js +3 -16
- package/plugins/datasets/src/reducers/pluginState.test.js +23 -0
- package/plugins/datasets/src/registry/dataset.js +13 -1
- package/plugins/datasets/src/registry/dataset.test.js +61 -0
- package/plugins/datasets/src/registry/datasetRegistry.js +12 -6
- package/plugins/datasets/src/registry/datasetRegistry.test.js +16 -4
- package/plugins/datasets/src/registry/isVisibleWhen.js +6 -3
- package/plugins/datasets/src/registry/isVisibleWhen.test.js +11 -1
- package/plugins/datasets/src/utils/bbox.test.js +125 -0
- package/plugins/draw/dist/esm/im-draw-ml-adapter.js +1 -1
- package/plugins/draw/dist/esm/im-draw-ol-adapter.js +1 -1
- 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-ml-adapter.js +2 -1
- package/plugins/draw/dist/umd/im-draw-ml-adapter.js.LICENSE.txt +1 -0
- package/plugins/draw/dist/umd/im-draw-ol-adapter.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 +10 -2
- package/plugins/draw/src/DrawInit.test.jsx +51 -10
- package/plugins/draw/src/adapters/maplibre/MaplibreDrawAdapter.js +91 -11
- package/plugins/draw/src/adapters/maplibre/MaplibreDrawAdapter.test.js +246 -4
- package/plugins/draw/src/adapters/maplibre/mapboxDraw.js +109 -14
- package/plugins/draw/src/adapters/maplibre/mapboxDraw.test.js +174 -11
- package/plugins/draw/src/adapters/maplibre/modes/drawMode/clickHandlers.test.js +12 -0
- package/plugins/draw/src/adapters/maplibre/modes/drawMode/lifecycle.js +9 -1
- package/plugins/draw/src/adapters/maplibre/modes/drawMode/lifecycle.test.js +24 -3
- package/plugins/draw/src/adapters/maplibre/modes/drawPointMode.js +194 -0
- package/plugins/draw/src/adapters/maplibre/modes/drawPointMode.test.js +457 -0
- package/plugins/draw/src/adapters/maplibre/modes/editPointMode/__helpers__/harness.js +102 -0
- package/plugins/draw/src/adapters/maplibre/modes/editPointMode/keyboardHandlers.js +82 -0
- package/plugins/draw/src/adapters/maplibre/modes/editPointMode/keyboardHandlers.test.js +83 -0
- package/plugins/draw/src/adapters/maplibre/modes/editPointMode/pointOperations.js +55 -0
- package/plugins/draw/src/adapters/maplibre/modes/editPointMode/pointOperations.test.js +62 -0
- package/plugins/draw/src/adapters/maplibre/modes/editPointMode/pointerHandlers.js +138 -0
- package/plugins/draw/src/adapters/maplibre/modes/editPointMode/pointerHandlers.test.js +197 -0
- package/plugins/draw/src/adapters/maplibre/modes/editPointMode/touchHandlers.js +92 -0
- package/plugins/draw/src/adapters/maplibre/modes/editPointMode/touchHandlers.test.js +101 -0
- package/plugins/draw/src/adapters/maplibre/modes/editPointMode/undoHandlers.js +46 -0
- package/plugins/draw/src/adapters/maplibre/modes/editPointMode/undoHandlers.test.js +42 -0
- package/plugins/draw/src/adapters/maplibre/modes/editPointMode.js +151 -0
- package/plugins/draw/src/adapters/maplibre/modes/editPointMode.test.js +156 -0
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/keyboardHandlers.js +4 -27
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/keyboardHandlers.test.js +24 -39
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/pointerHandlers.js +4 -5
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/touchHandlers.js +20 -23
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/touchHandlers.test.js +25 -5
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/undoHandlers.js +6 -36
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/undoHandlers.test.js +7 -49
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/vertexOperations.js +3 -53
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/vertexOperations.test.js +8 -33
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode.js +29 -72
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode.test.js +10 -3
- package/plugins/draw/src/adapters/maplibre/pointSymbolImages.js +158 -0
- package/plugins/draw/src/adapters/maplibre/pointSymbolImages.test.js +314 -0
- package/plugins/draw/src/adapters/maplibre/snap/prototypePatches.js +6 -1
- package/plugins/draw/src/adapters/maplibre/snap/prototypePatches.test.js +21 -0
- package/plugins/draw/src/adapters/maplibre/snap/snapInstance.js +6 -2
- package/plugins/draw/src/adapters/maplibre/snap/snapInstance.test.js +12 -0
- package/plugins/draw/src/adapters/maplibre/styles.js +38 -11
- package/plugins/draw/src/adapters/maplibre/styles.test.js +39 -0
- package/plugins/draw/src/adapters/maplibre/utils/editModeEvents.js +79 -0
- package/plugins/draw/src/adapters/maplibre/utils/editModeEvents.test.js +135 -0
- package/plugins/draw/src/adapters/maplibre/utils/geometryValidation.js +42 -0
- package/plugins/draw/src/adapters/maplibre/utils/geometryValidation.test.js +85 -0
- package/plugins/draw/src/adapters/maplibre/utils/keyboardShortcuts.js +34 -0
- package/plugins/draw/src/adapters/maplibre/utils/keyboardShortcuts.test.js +78 -0
- package/plugins/draw/src/adapters/maplibre/utils/snapHelpers.js +16 -3
- package/plugins/draw/src/adapters/maplibre/utils/snapHelpers.test.js +21 -3
- package/plugins/draw/src/adapters/maplibre/utils/snapMovement.js +59 -0
- package/plugins/draw/src/adapters/maplibre/utils/snapMovement.test.js +73 -0
- package/plugins/draw/src/adapters/maplibre/utils/touchDragMath.js +33 -0
- package/plugins/draw/src/adapters/maplibre/utils/touchDragMath.test.js +70 -0
- package/plugins/draw/src/adapters/openlayers/OLDrawAdapter.js +27 -2
- package/plugins/draw/src/adapters/openlayers/OLDrawAdapter.test.js +93 -0
- package/plugins/draw/src/adapters/openlayers/__helpers__/harness.js +9 -0
- package/plugins/draw/src/adapters/openlayers/core/OLDrawManager.js +19 -1
- package/plugins/draw/src/adapters/openlayers/core/OLDrawManager.test.js +34 -1
- package/plugins/draw/src/adapters/openlayers/core/styles.js +73 -1
- package/plugins/draw/src/adapters/openlayers/core/styles.test.js +122 -3
- package/plugins/draw/src/adapters/openlayers/draw/DrawMode.test.js +12 -0
- package/plugins/draw/src/adapters/openlayers/draw/drawInput.js +8 -2
- package/plugins/draw/src/adapters/openlayers/edit/EditMode.test.js +31 -0
- package/plugins/draw/src/adapters/openlayers/edit/keyboardHandler.js +9 -5
- package/plugins/draw/src/adapters/openlayers/edit/keyboardHandler.test.js +33 -0
- package/plugins/draw/src/adapters/openlayers/edit/modifyInteraction.js +5 -3
- package/plugins/draw/src/adapters/openlayers/edit/modifyInteraction.test.js +11 -0
- package/plugins/draw/src/adapters/openlayers/edit/nudge.js +10 -3
- package/plugins/draw/src/adapters/openlayers/edit/nudge.test.js +24 -1
- package/plugins/draw/src/adapters/openlayers/edit/touchHandler.js +18 -13
- package/plugins/draw/src/adapters/openlayers/edit/touchHandler.test.js +46 -1
- package/plugins/draw/src/adapters/openlayers/olDraw.js +11 -4
- package/plugins/draw/src/adapters/openlayers/olDraw.test.js +48 -6
- package/plugins/draw/src/adapters/openlayers/point/drawPointMode.js +156 -0
- package/plugins/draw/src/adapters/openlayers/point/drawPointMode.test.js +246 -0
- package/plugins/draw/src/adapters/openlayers/point/editPointMode.js +267 -0
- package/plugins/draw/src/adapters/openlayers/point/editPointMode.test.js +327 -0
- package/plugins/draw/src/adapters/openlayers/point/pointDragInteraction.js +71 -0
- package/plugins/draw/src/adapters/openlayers/point/pointOps.js +34 -0
- package/plugins/draw/src/adapters/openlayers/point/pointOps.test.js +32 -0
- package/plugins/draw/src/adapters/openlayers/point/pointSelectionState.js +82 -0
- package/plugins/draw/src/adapters/openlayers/point/pointSelectionState.test.js +107 -0
- package/plugins/draw/src/adapters/openlayers/point/pointSymbolImages.js +83 -0
- package/plugins/draw/src/adapters/openlayers/point/pointSymbolImages.test.js +214 -0
- package/plugins/draw/src/adapters/openlayers/snap/snapIndicator.js +3 -1
- package/plugins/draw/src/adapters/openlayers/snap/snapInteraction.js +6 -9
- package/plugins/draw/src/adapters/openlayers/snap/snapInteraction.test.js +15 -4
- package/plugins/draw/src/adapters/openlayers/utils/olCoords.js +1 -1
- package/plugins/draw/src/api/addFeature.js +16 -1
- package/plugins/draw/src/api/addFeature.test.js +62 -5
- package/plugins/draw/src/api/createNewShape.js +41 -0
- package/plugins/draw/src/api/createNewShape.test.js +63 -0
- package/plugins/draw/src/api/editFeature.js +7 -4
- package/plugins/draw/src/api/editFeature.test.js +16 -0
- package/plugins/draw/src/api/newLine.js +2 -40
- package/plugins/draw/src/api/newPoint.js +42 -0
- package/plugins/draw/src/api/newPoint.test.js +117 -0
- package/plugins/draw/src/api/newPolygon.js +2 -40
- package/plugins/draw/src/api/setStyle.js +43 -0
- package/plugins/draw/src/api/setStyle.test.js +75 -0
- package/plugins/draw/src/events.js +17 -10
- package/plugins/draw/src/events.test.js +14 -0
- package/plugins/draw/src/manifest.js +18 -6
- package/plugins/draw/src/manifest.test.js +32 -1
- package/plugins/draw/src/reducer.test.js +7 -0
- package/plugins/draw/src/utils/stripInternalProperties.js +19 -0
- package/plugins/draw/src/utils/stripInternalProperties.test.js +50 -0
- package/plugins/draw/src/utils/symbolKeys.js +5 -0
- package/plugins/draw/src/validation/liveDrawChecks.test.js +54 -0
- package/plugins/draw/src/validation/liveStroke.test.js +64 -1
- package/plugins/interact/dist/esm/im-interact-plugin.js +1 -1
- package/plugins/interact/dist/umd/im-interact-plugin.js +1 -1
- package/plugins/interact/dist/umd/index.js +1 -1
- package/plugins/interact/src/hooks/useHighlightSync.js +33 -12
- package/plugins/interact/src/hooks/useHighlightSync.test.js +96 -25
- package/plugins/interact/src/manifest.js +1 -1
- package/plugins/interact/src/utils/featureQueries.js +18 -0
- package/plugins/interact/src/utils/featureQueries.test.js +15 -0
- package/plugins/interact/src/utils/spatial.js +9 -3
- package/plugins/interact/src/utils/spatial.test.js +12 -1
- package/plugins/map-key/dist/css/index.css +68 -0
- package/plugins/map-key/dist/esm/im-map-key-plugin.js +1 -0
- package/plugins/map-key/dist/esm/index.js +1 -0
- package/plugins/map-key/dist/umd/im-map-key-plugin.js +2 -0
- package/plugins/map-key/dist/umd/im-map-key-plugin.js.LICENSE.txt +1 -0
- package/plugins/map-key/dist/umd/index.js +2 -0
- package/plugins/map-key/dist/umd/index.js.LICENSE.txt +1 -0
- package/plugins/map-key/package.json +28 -0
- package/plugins/map-key/src/components/Key/EmptyKey.jsx +7 -0
- package/plugins/{datasets → map-key}/src/components/Key/EmptyKey.test.jsx +2 -2
- package/plugins/map-key/src/components/Key/Key.jsx +43 -0
- package/plugins/{datasets → map-key}/src/components/Key/Key.module.scss +21 -14
- package/plugins/map-key/src/components/Key/Key.test.jsx +73 -0
- package/plugins/map-key/src/components/Key/KeyGroupItem.jsx +16 -0
- package/plugins/map-key/src/components/Key/KeyGroupItem.test.jsx +53 -0
- package/plugins/map-key/src/components/Key/KeyItem.jsx +26 -0
- package/plugins/map-key/src/components/Key/KeyItem.test.jsx +67 -0
- package/plugins/map-key/src/components/Key/KeySvg.jsx +41 -0
- package/plugins/{datasets → map-key}/src/components/Key/KeySvg.test.jsx +14 -12
- package/plugins/map-key/src/components/Key/KeySvgLine.jsx +22 -0
- package/plugins/{datasets → map-key}/src/components/Key/KeySvgLine.test.jsx +1 -1
- package/plugins/{datasets → map-key}/src/components/Key/KeySvgPattern.jsx +7 -2
- package/plugins/{datasets → map-key}/src/components/Key/KeySvgPattern.test.jsx +8 -2
- package/plugins/map-key/src/components/Key/KeySvgRect.jsx +26 -0
- package/plugins/{datasets → map-key}/src/components/Key/KeySvgRect.test.jsx +1 -1
- package/plugins/{datasets → map-key}/src/components/Key/KeySvgSymbol.jsx +8 -3
- package/plugins/{datasets → map-key}/src/components/Key/KeySvgSymbol.test.jsx +17 -6
- package/plugins/map-key/src/components/Key/MapKey.jsx +53 -0
- package/plugins/map-key/src/components/Key/MapKey.test.jsx +147 -0
- package/plugins/{datasets → map-key}/src/components/Key/svgProperties.js +2 -2
- package/plugins/{datasets → map-key}/src/components/Key/svgProperties.test.js +2 -2
- package/plugins/map-key/src/index.js +13 -0
- package/plugins/map-key/src/index.test.js +31 -0
- package/plugins/map-key/src/initialise/MapKeyInit.jsx +15 -0
- package/plugins/map-key/src/initialise/MapKeyInit.test.jsx +39 -0
- package/plugins/map-key/src/manifest.js +30 -0
- package/plugins/map-key/src/manifest.test.js +63 -0
- package/plugins/map-key/src/mapKey.scss +4 -0
- package/plugins/map-key/src/registry/getDatasetRegistry.js +6 -0
- package/plugins/map-key/src/registry/getDatasetRegistry.test.js +23 -0
- package/plugins/map-key/src/registry/index.js +3 -0
- package/plugins/map-key/src/registry/index.test.js +15 -0
- package/plugins/menu/dist/css/index.css +80 -0
- package/plugins/menu/dist/esm/im-menu-plugin.js +1 -0
- package/plugins/menu/dist/esm/index.js +1 -0
- package/plugins/menu/dist/umd/im-menu-plugin.js +1 -0
- package/plugins/menu/dist/umd/index.js +2 -0
- package/plugins/menu/dist/umd/index.js.LICENSE.txt +1 -0
- package/plugins/menu/package.json +28 -0
- package/plugins/menu/src/components/Menu/CheckboxGroupWrapper.jsx +21 -0
- package/plugins/menu/src/components/Menu/GroupLegend.jsx +17 -0
- package/plugins/menu/src/components/Menu/GroupLegend.test.jsx +68 -0
- package/plugins/menu/src/components/Menu/Menu.jsx +19 -0
- package/plugins/menu/src/components/Menu/Menu.module.scss +90 -0
- package/plugins/menu/src/components/Menu/Menu.test.jsx +161 -0
- package/plugins/menu/src/components/Menu/MenuCheckbox.jsx +35 -0
- package/plugins/menu/src/components/Menu/MenuCheckbox.test.jsx +93 -0
- package/plugins/menu/src/components/Menu/MenuGroup.jsx +11 -0
- package/plugins/{datasets/src/components/LayersMenu/LayersMenuRadio.jsx → menu/src/components/Menu/MenuRadio.jsx} +6 -4
- package/plugins/{datasets/src/components/LayersMenu/LayersMenuRadio.test.jsx → menu/src/components/Menu/MenuRadio.test.jsx} +18 -18
- package/plugins/menu/src/components/Menu/RadioGroupWrapper.jsx +32 -0
- package/plugins/{datasets/src/components/LayersMenu/LayersRadioGroupWrapper.test.jsx → menu/src/components/Menu/RadioGroupWrapper.test.jsx} +21 -21
- package/plugins/menu/src/components/Menu/useIdPrefix.jsx +4 -0
- package/plugins/menu/src/index.js +13 -0
- package/plugins/menu/src/index.test.js +31 -0
- package/plugins/menu/src/initialise/MenuInit.jsx +24 -0
- package/plugins/menu/src/initialise/MenuInit.test.jsx +50 -0
- package/plugins/menu/src/initialise/createMenu.js +10 -0
- package/plugins/menu/src/initialise/createMenu.test.js +37 -0
- package/plugins/menu/src/manifest.js +35 -0
- package/plugins/menu/src/manifest.test.js +63 -0
- package/plugins/menu/src/menu.scss +4 -0
- package/plugins/menu/src/reducers/menuStateReducer.test.js +38 -0
- package/plugins/menu/src/reducers/pluginState.js +35 -0
- package/plugins/menu/src/reducers/pluginState.test.js +57 -0
- package/plugins/menu/src/registry/getDatasetRegistry.js +9 -0
- package/plugins/menu/src/registry/getDatasetRegistry.test.js +23 -0
- package/plugins/menu/src/registry/index.js +3 -0
- package/plugins/menu/src/registry/index.test.js +15 -0
- package/plugins/menu/src/registry/isVisibleWhen.js +43 -0
- package/plugins/menu/src/registry/isVisibleWhen.test.js +48 -0
- package/plugins/search/dist/css/index.css +1 -1
- package/plugins/search/dist/esm/im-search-plugin.js +1 -1
- package/plugins/search/dist/esm/index.js +1 -1
- package/plugins/search/dist/umd/im-search-plugin.js +1 -1
- package/plugins/search/dist/umd/index.js +1 -1
- package/plugins/search/src/Search.jsx +2 -3
- package/plugins/search/src/components/Form/Form.module.scss +9 -20
- package/plugins/search/src/index.js +0 -1
- package/plugins/search/src/index.test.js +2 -4
- package/plugins/search/src/manifest.js +1 -1
- package/plugins/search/src/search.scss +17 -16
- package/providers/beta/openlayers/dist/esm/im-openlayers-provider.js +1 -1
- package/providers/beta/openlayers/dist/umd/im-openlayers-provider.js +1 -1
- package/providers/beta/openlayers/dist/umd/index.js +1 -1
- package/providers/beta/openlayers/src/openlayersProvider.js +4 -1
- package/providers/beta/openlayers/src/openlayersProvider.test.js +18 -0
- package/providers/beta/openlayers/src/utils/highlightFeatures.js +52 -5
- package/providers/beta/openlayers/src/utils/highlightFeatures.test.js +176 -0
- package/providers/beta/openlayers/src/utils/symbolImages.js +40 -0
- package/providers/beta/openlayers/src/utils/symbolImages.test.js +58 -0
- package/providers/maplibre/dist/esm/im-maplibre-provider.js +1 -1
- package/providers/maplibre/dist/umd/im-maplibre-provider.js +1 -1
- package/providers/maplibre/dist/umd/index.js +1 -1
- package/providers/maplibre/src/utils/drawLayerBuckets.js +14 -0
- package/providers/maplibre/src/utils/drawLayerBuckets.test.js +18 -0
- package/providers/maplibre/src/utils/highlightFeatures.js +80 -55
- package/providers/maplibre/src/utils/highlightFeatures.test.js +156 -17
- package/providers/maplibre/src/utils/hoverCursor.js +30 -14
- package/providers/maplibre/src/utils/hoverCursor.test.js +35 -0
- package/providers/maplibre/src/utils/patternImages.js +1 -1
- package/providers/maplibre/src/utils/symbolImages.js +41 -3
- package/providers/maplibre/src/utils/symbolImages.test.js +40 -6
- package/rollup.esm.mjs +11 -1
- package/src/App/components/Actions/Actions.test.jsx +47 -0
- package/src/App/components/Hints/Hints.test.jsx +13 -0
- package/src/App/components/KeyboardHelp/KeyboardHelp.jsx +25 -23
- package/src/App/components/KeyboardHelp/KeyboardHelp.test.jsx +22 -5
- package/src/App/components/MoveControls/MoveControls.module.scss +41 -10
- package/src/App/components/Panel/Panel.jsx +65 -8
- package/src/App/components/Panel/Panel.module.scss +49 -15
- package/src/App/components/Panel/Panel.test.jsx +114 -1
- package/src/App/components/Tabs/Tabs.jsx +43 -17
- package/src/App/components/Tabs/Tabs.module.scss +32 -5
- package/src/App/components/Tabs/Tabs.test.jsx +40 -10
- package/src/App/components/Tooltip/Tooltip.test.jsx +12 -14
- package/src/App/hooks/useFeatureItems.js +16 -7
- package/src/App/hooks/useFeatureItems.test.js +57 -0
- package/src/App/hooks/useLayoutMeasurements.js +95 -84
- package/src/App/hooks/useLayoutMeasurements.test.js +61 -1
- package/src/App/layout/Layout.jsx +9 -10
- package/src/App/layout/Layout.test.jsx +2 -0
- package/src/App/layout/layout.module.scss +31 -17
- package/src/App/registry/pluginRegistry.js +1 -1
- package/src/App/registry/pluginRegistry.test.js +12 -0
- package/src/App/renderer/HtmlElementHost.jsx +18 -5
- package/src/App/renderer/HtmlElementHost.test.jsx +54 -0
- package/src/App/renderer/groupByKey.js +28 -0
- package/src/App/renderer/groupByKey.test.js +39 -0
- package/src/App/renderer/groupIntoTabs.js +42 -0
- package/src/App/renderer/groupIntoTabs.test.js +95 -0
- package/src/App/renderer/mapButtons.js +97 -129
- package/src/App/renderer/mapButtons.test.js +67 -83
- package/src/App/renderer/mapControls.js +4 -1
- package/src/App/renderer/mapControls.test.js +32 -0
- package/src/App/renderer/mapPanels.js +53 -11
- package/src/App/renderer/mapPanels.test.js +95 -2
- package/src/App/renderer/orderItems.js +28 -0
- package/src/App/renderer/orderItems.test.js +50 -0
- package/src/App/renderer/slotAggregator.js +2 -18
- package/src/App/renderer/slotHelpers.js +3 -1
- package/src/App/renderer/slotHelpers.test.js +5 -0
- package/src/App/renderer/slots.js +3 -0
- package/src/App/store/AppProvider.jsx +1 -0
- package/src/App/store/appDispatchMiddleware.js +1 -1
- package/src/App/store/appDispatchMiddleware.test.js +8 -0
- package/src/config/appConfig.js +2 -2
- package/src/config/events.js +2 -0
- package/src/scss/settings/_colors.scss +1 -0
- package/src/scss/settings/_dimensions.scss +2 -3
- package/src/scss/settings/_transition.scss +1 -1
- package/src/services/eventBus.js +44 -0
- package/src/services/eventBus.test.js +83 -0
- package/src/services/symbolRegistry.js +1 -1
- package/src/types.js +31 -3
- package/webpack.umd.mjs +2 -0
- package/plugins/datasets/src/components/Key/EmptyKey.jsx +0 -7
- package/plugins/datasets/src/components/Key/Key.jsx +0 -50
- package/plugins/datasets/src/components/Key/KeyGroupItem.jsx +0 -18
- package/plugins/datasets/src/components/Key/KeyItem.jsx +0 -23
- package/plugins/datasets/src/components/Key/KeySvg.jsx +0 -22
- package/plugins/datasets/src/components/Key/KeySvgLine.jsx +0 -19
- package/plugins/datasets/src/components/Key/KeySvgRect.jsx +0 -22
- package/plugins/datasets/src/components/LayersMenu/LayersRadioGroupWrapper.jsx +0 -41
- /package/plugins/{datasets → menu}/src/reducers/menuStateReducer.js +0 -0
- /package/{providers/maplibre/src → src}/utils/rasteriseToImageData.js +0 -0
- /package/{providers/maplibre/src → src}/utils/rasteriseToImageData.test.js +0 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import React, { useState, useEffect } from 'react'
|
|
2
|
+
import { getDatasetRegistry } from '../../registry/index.js'
|
|
3
|
+
|
|
4
|
+
import { Key } from './Key.jsx'
|
|
5
|
+
|
|
6
|
+
export function MapKey ({
|
|
7
|
+
mapState: { mapStyle },
|
|
8
|
+
pluginConfig: { noKeyItemText },
|
|
9
|
+
services: { eventBus }
|
|
10
|
+
}) {
|
|
11
|
+
const [datasetRegistry, setDatasetRegistry] = useState(getDatasetRegistry())
|
|
12
|
+
// Lazily seed from the registry (already populated whenever the key is opened after
|
|
13
|
+
// datasets:ready) so the first paint shows real content instead of flashing the empty
|
|
14
|
+
// state while the effect below catches up on the next tick.
|
|
15
|
+
const [keyGroups, setKeyGroups] = useState(() => datasetRegistry?.keyItems().items ?? [])
|
|
16
|
+
const [hasGroups, setHasGroups] = useState(() => datasetRegistry?.keyItems().hasGroups ?? false)
|
|
17
|
+
|
|
18
|
+
const getKeyItems = () => {
|
|
19
|
+
const { items, hasGroups: _hasGroups } = datasetRegistry.keyItems()
|
|
20
|
+
setKeyGroups(items)
|
|
21
|
+
setHasGroups(_hasGroups)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const onMenuChanged = (menuState) => {
|
|
25
|
+
datasetRegistry.invalidateKeyItemsOnMenuStateChange(menuState)
|
|
26
|
+
getKeyItems()
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
if (!datasetRegistry) {
|
|
31
|
+
// 'datasets:registry' is only required when the key is opened before datasets:ready
|
|
32
|
+
eventBus.requestOnce('datasets:registry', setDatasetRegistry)
|
|
33
|
+
return () => {}
|
|
34
|
+
} else {
|
|
35
|
+
getKeyItems() // populate the initial KeyItems from the datasetRegistry (which caches them)
|
|
36
|
+
eventBus
|
|
37
|
+
.on('menu:changed', onMenuChanged) // Ensure keyItems refresh when menu updates
|
|
38
|
+
.on('datasets:changed', getKeyItems) // Ensure keyItems refresh when datasets change
|
|
39
|
+
return () => eventBus
|
|
40
|
+
.off('menu:changed', onMenuChanged)
|
|
41
|
+
.off('datasets:changed', getKeyItems)
|
|
42
|
+
}
|
|
43
|
+
}, [datasetRegistry])
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<Key
|
|
47
|
+
noKeyItemText={noKeyItemText}
|
|
48
|
+
keyGroups={keyGroups}
|
|
49
|
+
hasGroups={hasGroups}
|
|
50
|
+
mapStyle={mapStyle}
|
|
51
|
+
/>
|
|
52
|
+
)
|
|
53
|
+
}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { render, act } from '@testing-library/react'
|
|
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
|
+
|
|
9
|
+
// eslint-disable-next-line no-var -- jest.mock factories may only reference vars prefixed "mock"
|
|
10
|
+
var mockKeyRenderCount = 0
|
|
11
|
+
jest.mock('./Key.jsx', () => ({
|
|
12
|
+
Key: ({ noKeyItemText, keyGroups, hasGroups, mapStyle }) => {
|
|
13
|
+
mockKeyRenderCount++
|
|
14
|
+
return (
|
|
15
|
+
<div
|
|
16
|
+
data-testid='key'
|
|
17
|
+
data-no-key-item-text={noKeyItemText}
|
|
18
|
+
data-has-groups={String(hasGroups)}
|
|
19
|
+
data-map-style-id={mapStyle.id}
|
|
20
|
+
data-key-groups-length={keyGroups.length}
|
|
21
|
+
/>
|
|
22
|
+
)
|
|
23
|
+
}
|
|
24
|
+
}))
|
|
25
|
+
|
|
26
|
+
const makeEventBus = () => {
|
|
27
|
+
const eventBus = {
|
|
28
|
+
requestOnce: jest.fn(),
|
|
29
|
+
on: jest.fn(),
|
|
30
|
+
off: jest.fn()
|
|
31
|
+
}
|
|
32
|
+
eventBus.on.mockReturnValue(eventBus)
|
|
33
|
+
eventBus.off.mockReturnValue(eventBus)
|
|
34
|
+
return eventBus
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const makeRegistry = (items = [], hasGroups = false) => ({
|
|
38
|
+
keyItems: jest.fn().mockReturnValue({ items, hasGroups }),
|
|
39
|
+
invalidateKeyItemsOnMenuStateChange: jest.fn()
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
let eventBus
|
|
43
|
+
const baseProps = () => ({
|
|
44
|
+
mapState: { mapStyle: { id: 'default' } },
|
|
45
|
+
pluginConfig: { noKeyItemText: 'No items' },
|
|
46
|
+
services: { eventBus }
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
beforeEach(() => {
|
|
50
|
+
jest.clearAllMocks()
|
|
51
|
+
eventBus = makeEventBus()
|
|
52
|
+
mockKeyRenderCount = 0
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
describe('MapKey', () => {
|
|
56
|
+
describe('when datasetRegistry is null', () => {
|
|
57
|
+
beforeEach(() => { getDatasetRegistry.mockReturnValue(null) })
|
|
58
|
+
|
|
59
|
+
it('passes empty items and hasGroups false to Key', () => {
|
|
60
|
+
const { getByTestId } = render(<MapKey {...baseProps()} />)
|
|
61
|
+
expect(getByTestId('key').dataset.keyGroupsLength).toBe('0')
|
|
62
|
+
expect(getByTestId('key').dataset.hasGroups).toBe('false')
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
it('calls requestOnce for datasets:registry', () => {
|
|
66
|
+
render(<MapKey {...baseProps()} />)
|
|
67
|
+
expect(eventBus.requestOnce).toHaveBeenCalledWith('datasets:registry', expect.any(Function))
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
it('populates key items when the registry arrives via requestOnce', () => {
|
|
71
|
+
render(<MapKey {...baseProps()} />)
|
|
72
|
+
const setReg = eventBus.requestOnce.mock.calls[0][1]
|
|
73
|
+
const registry = makeRegistry([{ id: '1' }, { id: '2' }], true)
|
|
74
|
+
act(() => { setReg(registry) })
|
|
75
|
+
expect(registry.keyItems).toHaveBeenCalled()
|
|
76
|
+
})
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
describe('when datasetRegistry exists', () => {
|
|
80
|
+
let registry
|
|
81
|
+
|
|
82
|
+
beforeEach(() => {
|
|
83
|
+
registry = makeRegistry([{ id: '1' }, { id: '2' }], true)
|
|
84
|
+
getDatasetRegistry.mockReturnValue(registry)
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
it('passes keyGroups and hasGroups from the registry to Key', () => {
|
|
88
|
+
const { getByTestId } = render(<MapKey {...baseProps()} />)
|
|
89
|
+
expect(getByTestId('key').dataset.keyGroupsLength).toBe('2')
|
|
90
|
+
expect(getByTestId('key').dataset.hasGroups).toBe('true')
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
// Regression: when the registry is already populated at mount (e.g. reopening the key
|
|
94
|
+
// panel after datasets:ready), Key must render with real data straight away rather than
|
|
95
|
+
// painting the empty state first and flashing to the real content once the mount effect
|
|
96
|
+
// catches up — see MapKey.jsx's lazy useState initializers.
|
|
97
|
+
it('renders Key only once, already carrying the real items, instead of flashing empty first', () => {
|
|
98
|
+
render(<MapKey {...baseProps()} />)
|
|
99
|
+
expect(mockKeyRenderCount).toBe(1)
|
|
100
|
+
})
|
|
101
|
+
|
|
102
|
+
it('registers menu:changed and datasets:changed listeners', () => {
|
|
103
|
+
render(<MapKey {...baseProps()} />)
|
|
104
|
+
expect(eventBus.on).toHaveBeenCalledWith('menu:changed', expect.any(Function))
|
|
105
|
+
expect(eventBus.on).toHaveBeenCalledWith('datasets:changed', expect.any(Function))
|
|
106
|
+
})
|
|
107
|
+
|
|
108
|
+
it('deregisters listeners on unmount', () => {
|
|
109
|
+
const { unmount } = render(<MapKey {...baseProps()} />)
|
|
110
|
+
unmount()
|
|
111
|
+
expect(eventBus.off).toHaveBeenCalledWith('menu:changed', expect.any(Function))
|
|
112
|
+
expect(eventBus.off).toHaveBeenCalledWith('datasets:changed', expect.any(Function))
|
|
113
|
+
})
|
|
114
|
+
|
|
115
|
+
it('refreshes key items when datasets:changed fires', () => {
|
|
116
|
+
render(<MapKey {...baseProps()} />)
|
|
117
|
+
const callsAtMount = registry.keyItems.mock.calls.length
|
|
118
|
+
const onDatasetsChanged = eventBus.on.mock.calls.find(([e]) => e === 'datasets:changed')[1]
|
|
119
|
+
act(() => { onDatasetsChanged() })
|
|
120
|
+
expect(registry.keyItems).toHaveBeenCalledTimes(callsAtMount + 1)
|
|
121
|
+
})
|
|
122
|
+
|
|
123
|
+
it('invalidates and refreshes key items when menu:changed fires', () => {
|
|
124
|
+
render(<MapKey {...baseProps()} />)
|
|
125
|
+
const callsAtMount = registry.keyItems.mock.calls.length
|
|
126
|
+
const onMenuChanged = eventBus.on.mock.calls.find(([e]) => e === 'menu:changed')[1]
|
|
127
|
+
const menuState = { someKey: 'value' }
|
|
128
|
+
act(() => { onMenuChanged(menuState) })
|
|
129
|
+
expect(registry.invalidateKeyItemsOnMenuStateChange).toHaveBeenCalledWith(menuState)
|
|
130
|
+
expect(registry.keyItems).toHaveBeenCalledTimes(callsAtMount + 1)
|
|
131
|
+
})
|
|
132
|
+
})
|
|
133
|
+
|
|
134
|
+
describe('props forwarded to Key', () => {
|
|
135
|
+
beforeEach(() => { getDatasetRegistry.mockReturnValue(null) })
|
|
136
|
+
|
|
137
|
+
it('passes noKeyItemText from pluginConfig', () => {
|
|
138
|
+
const { getByTestId } = render(<MapKey {...baseProps()} />)
|
|
139
|
+
expect(getByTestId('key').dataset.noKeyItemText).toBe('No items')
|
|
140
|
+
})
|
|
141
|
+
|
|
142
|
+
it('passes mapStyle from mapState', () => {
|
|
143
|
+
const { getByTestId } = render(<MapKey {...baseProps()} />)
|
|
144
|
+
expect(getByTestId('key').dataset.mapStyleId).toBe('default')
|
|
145
|
+
})
|
|
146
|
+
})
|
|
147
|
+
})
|
|
@@ -7,7 +7,7 @@ export const svgProps = {
|
|
|
7
7
|
width: SVG_SIZE,
|
|
8
8
|
height: SVG_SIZE,
|
|
9
9
|
viewBox: `0 0 ${SVG_SIZE} ${SVG_SIZE}`,
|
|
10
|
-
className: 'am-c-
|
|
10
|
+
className: 'am-c-map-key-symbol',
|
|
11
11
|
'aria-hidden': 'true',
|
|
12
12
|
focusable: 'false'
|
|
13
13
|
}
|
|
@@ -16,5 +16,5 @@ export const svgSymbolProps = {
|
|
|
16
16
|
...svgProps,
|
|
17
17
|
width: SVG_SYMBOL_SIZE,
|
|
18
18
|
height: SVG_SYMBOL_SIZE,
|
|
19
|
-
className: 'am-c-
|
|
19
|
+
className: 'am-c-map-key-symbol am-c-map-key-symbol--point'
|
|
20
20
|
}
|
|
@@ -25,7 +25,7 @@ describe('svgProps', () => {
|
|
|
25
25
|
})
|
|
26
26
|
|
|
27
27
|
it('has the correct className', () => {
|
|
28
|
-
expect(svgProps.className).toBe('am-c-
|
|
28
|
+
expect(svgProps.className).toBe('am-c-map-key-symbol')
|
|
29
29
|
})
|
|
30
30
|
|
|
31
31
|
it('is aria-hidden', () => {
|
|
@@ -55,7 +55,7 @@ describe('svgSymbolProps', () => {
|
|
|
55
55
|
})
|
|
56
56
|
|
|
57
57
|
it('className includes the base class and a modifier', () => {
|
|
58
|
-
expect(svgSymbolProps.className).toContain('am-c-
|
|
58
|
+
expect(svgSymbolProps.className).toContain('am-c-map-key-symbol')
|
|
59
59
|
expect(svgSymbolProps.className).toContain('--point')
|
|
60
60
|
})
|
|
61
61
|
})
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import './mapKey.scss'
|
|
2
|
+
|
|
3
|
+
export default function createPlugin (options = {}) {
|
|
4
|
+
return {
|
|
5
|
+
noKeyItemText: 'No features displayed',
|
|
6
|
+
...options,
|
|
7
|
+
id: 'mapKey',
|
|
8
|
+
load: async () => {
|
|
9
|
+
const module = (await import(/* webpackChunkName: "im-map-key-plugin" */ './manifest.js')).manifest
|
|
10
|
+
return module
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import createPlugin from './index.js'
|
|
2
|
+
|
|
3
|
+
jest.mock('./mapKey.scss', () => {})
|
|
4
|
+
jest.mock('./manifest.js', () => ({ manifest: { InitComponent: 'MapKeyInit', panels: [] } }))
|
|
5
|
+
|
|
6
|
+
describe('createPlugin', () => {
|
|
7
|
+
it('returns the mapKey id', () => {
|
|
8
|
+
expect(createPlugin().id).toBe('mapKey')
|
|
9
|
+
})
|
|
10
|
+
|
|
11
|
+
it('id cannot be overridden by options', () => {
|
|
12
|
+
expect(createPlugin({ id: 'other' }).id).toBe('mapKey')
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
it('returns the default noKeyItemText', () => {
|
|
16
|
+
expect(createPlugin().noKeyItemText).toBe('No features displayed')
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
it('allows noKeyItemText to be overridden', () => {
|
|
20
|
+
expect(createPlugin({ noKeyItemText: 'Nothing here' }).noKeyItemText).toBe('Nothing here')
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
it('merges additional options into the returned object', () => {
|
|
24
|
+
expect(createPlugin({ custom: true }).custom).toBe(true)
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
it('load() resolves to the manifest', async () => {
|
|
28
|
+
const result = await createPlugin().load()
|
|
29
|
+
expect(result).toEqual({ InitComponent: 'MapKeyInit', panels: [] })
|
|
30
|
+
})
|
|
31
|
+
})
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { useEffect } from 'react'
|
|
2
|
+
import { setDatasetRegistry } from '../registry/getDatasetRegistry.js'
|
|
3
|
+
|
|
4
|
+
// additional possible params here are: pluginConfig, pluginState, appState, mapProvider,
|
|
5
|
+
export function MapKeyInit ({ mapState, services }) {
|
|
6
|
+
const { eventBus } = services
|
|
7
|
+
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
if (!mapState.isMapReady) {
|
|
10
|
+
return
|
|
11
|
+
}
|
|
12
|
+
// Request a handle on the datasetsRegistry singleton
|
|
13
|
+
eventBus.requestOnce('datasets:registry', setDatasetRegistry)
|
|
14
|
+
}, [mapState.isMapReady])
|
|
15
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { render } from '@testing-library/react'
|
|
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
|
+
const eventBus = { requestOnce: jest.fn() }
|
|
10
|
+
const services = { eventBus }
|
|
11
|
+
|
|
12
|
+
beforeEach(() => {
|
|
13
|
+
jest.clearAllMocks()
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
describe('MapKeyInit', () => {
|
|
17
|
+
it('does not call requestOnce when map is not ready', () => {
|
|
18
|
+
render(<MapKeyInit mapState={{ isMapReady: false }} services={services} />)
|
|
19
|
+
expect(eventBus.requestOnce).not.toHaveBeenCalled()
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
it('calls requestOnce for datasets:registry when map is ready', () => {
|
|
23
|
+
render(<MapKeyInit mapState={{ isMapReady: true }} services={services} />)
|
|
24
|
+
expect(eventBus.requestOnce).toHaveBeenCalledWith('datasets:registry', setDatasetRegistry)
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
it('calls requestOnce when isMapReady changes to true', () => {
|
|
28
|
+
const { rerender } = render(<MapKeyInit mapState={{ isMapReady: false }} services={services} />)
|
|
29
|
+
expect(eventBus.requestOnce).not.toHaveBeenCalled()
|
|
30
|
+
rerender(<MapKeyInit mapState={{ isMapReady: true }} services={services} />)
|
|
31
|
+
expect(eventBus.requestOnce).toHaveBeenCalledTimes(1)
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
it('does not call requestOnce again on re-render when isMapReady stays true', () => {
|
|
35
|
+
const { rerender } = render(<MapKeyInit mapState={{ isMapReady: true }} services={services} />)
|
|
36
|
+
rerender(<MapKeyInit mapState={{ isMapReady: true }} services={services} />)
|
|
37
|
+
expect(eventBus.requestOnce).toHaveBeenCalledTimes(1)
|
|
38
|
+
})
|
|
39
|
+
})
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { MapKey } from './components/Key/MapKey.jsx'
|
|
2
|
+
import { MapKeyInit } from './initialise/MapKeyInit.jsx'
|
|
3
|
+
|
|
4
|
+
export const manifest = {
|
|
5
|
+
InitComponent: MapKeyInit,
|
|
6
|
+
panels: [
|
|
7
|
+
{
|
|
8
|
+
id: 'mapKey',
|
|
9
|
+
label: 'Key',
|
|
10
|
+
mobile: { slot: 'drawer', modal: true },
|
|
11
|
+
tablet: { slot: 'left-top', width: '260px' },
|
|
12
|
+
desktop: { slot: 'left-top', width: '280px' },
|
|
13
|
+
render: MapKey
|
|
14
|
+
}],
|
|
15
|
+
|
|
16
|
+
buttons: [{
|
|
17
|
+
id: 'mapKey',
|
|
18
|
+
panelId: 'mapKey',
|
|
19
|
+
label: 'Key',
|
|
20
|
+
iconId: 'key',
|
|
21
|
+
mobile: { slot: 'top-left', showLabel: false },
|
|
22
|
+
tablet: { slot: 'top-left', showLabel: true },
|
|
23
|
+
desktop: { slot: 'top-left', showLabel: true }
|
|
24
|
+
}],
|
|
25
|
+
|
|
26
|
+
icons: [{
|
|
27
|
+
id: 'key',
|
|
28
|
+
svgContent: '<path d="M3 5h.01"/><path d="M3 12h.01"/><path d="M3 19h.01"/><path d="M8 5h13"/><path d="M8 12h13"/><path d="M8 19h13"/>'
|
|
29
|
+
}]
|
|
30
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { manifest } from './manifest.js'
|
|
2
|
+
import { MapKey } from './components/Key/MapKey.jsx'
|
|
3
|
+
import { MapKeyInit } from './initialise/MapKeyInit.jsx'
|
|
4
|
+
|
|
5
|
+
jest.mock('./components/Key/MapKey.jsx', () => ({ MapKey: jest.fn() }))
|
|
6
|
+
jest.mock('./initialise/MapKeyInit.jsx', () => ({ MapKeyInit: jest.fn() }))
|
|
7
|
+
jest.mock('./registry/getDatasetRegistry.js', () => ({}))
|
|
8
|
+
|
|
9
|
+
describe('manifest', () => {
|
|
10
|
+
it('sets InitComponent to MapKeyInit', () => {
|
|
11
|
+
expect(manifest.InitComponent).toBe(MapKeyInit)
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
describe('panels', () => {
|
|
15
|
+
it('defines one panel', () => {
|
|
16
|
+
expect(manifest.panels).toHaveLength(1)
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
it('panel has id mapKey', () => {
|
|
20
|
+
expect(manifest.panels[0].id).toBe('mapKey')
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
it('panel render is MapKey', () => {
|
|
24
|
+
expect(manifest.panels[0].render).toBe(MapKey)
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
it('panel defines mobile, tablet and desktop slots', () => {
|
|
28
|
+
const { mobile, tablet, desktop } = manifest.panels[0]
|
|
29
|
+
expect(mobile.slot).toBe('drawer')
|
|
30
|
+
expect(tablet.slot).toBe('left-top')
|
|
31
|
+
expect(desktop.slot).toBe('left-top')
|
|
32
|
+
})
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
describe('buttons', () => {
|
|
36
|
+
it('defines one button', () => {
|
|
37
|
+
expect(manifest.buttons).toHaveLength(1)
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
it('button has id mapKey and links to the mapKey panel', () => {
|
|
41
|
+
expect(manifest.buttons[0].id).toBe('mapKey')
|
|
42
|
+
expect(manifest.buttons[0].panelId).toBe('mapKey')
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
it('button references the key icon', () => {
|
|
46
|
+
expect(manifest.buttons[0].iconId).toBe('key')
|
|
47
|
+
})
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
describe('icons', () => {
|
|
51
|
+
it('defines one icon', () => {
|
|
52
|
+
expect(manifest.icons).toHaveLength(1)
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
it('icon id matches the button iconId', () => {
|
|
56
|
+
expect(manifest.icons[0].id).toBe(manifest.buttons[0].iconId)
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
it('icon has svgContent', () => {
|
|
60
|
+
expect(manifest.icons[0].svgContent).toBeTruthy()
|
|
61
|
+
})
|
|
62
|
+
})
|
|
63
|
+
})
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// the local _datasetRegistry will only be initialised if the datasets plugin is in use,
|
|
2
|
+
// otherwise it will remain null.
|
|
3
|
+
let _datasetRegistry = null
|
|
4
|
+
|
|
5
|
+
export const getDatasetRegistry = () => _datasetRegistry
|
|
6
|
+
export const setDatasetRegistry = (datasetRegistry) => (_datasetRegistry = datasetRegistry)
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { getDatasetRegistry, setDatasetRegistry } from './getDatasetRegistry.js'
|
|
2
|
+
|
|
3
|
+
afterEach(() => {
|
|
4
|
+
setDatasetRegistry(null)
|
|
5
|
+
})
|
|
6
|
+
|
|
7
|
+
describe('getDatasetRegistry', () => {
|
|
8
|
+
it('returns null before any registry is set', () => {
|
|
9
|
+
expect(getDatasetRegistry()).toBeNull()
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
it('returns the registry after setDatasetRegistry is called', () => {
|
|
13
|
+
const registry = { keyItems: jest.fn() }
|
|
14
|
+
setDatasetRegistry(registry)
|
|
15
|
+
expect(getDatasetRegistry()).toBe(registry)
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
it('returns null after being reset to null', () => {
|
|
19
|
+
setDatasetRegistry({ keyItems: jest.fn() })
|
|
20
|
+
setDatasetRegistry(null)
|
|
21
|
+
expect(getDatasetRegistry()).toBeNull()
|
|
22
|
+
})
|
|
23
|
+
})
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { getDatasetRegistry, patternRegistry, symbolRegistry } from './index.js'
|
|
2
|
+
|
|
3
|
+
describe('registry/index', () => {
|
|
4
|
+
it('exports getDatasetRegistry as a function', () => {
|
|
5
|
+
expect(typeof getDatasetRegistry).toBe('function')
|
|
6
|
+
})
|
|
7
|
+
|
|
8
|
+
it('exports patternRegistry', () => {
|
|
9
|
+
expect(patternRegistry).toBeDefined()
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
it('exports symbolRegistry', () => {
|
|
13
|
+
expect(symbolRegistry).toBeDefined()
|
|
14
|
+
})
|
|
15
|
+
})
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
.im-c-menu--has-groups > *:not(:first-child) {
|
|
2
|
+
border-top: 1px solid var(--button-hover-color);
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.im-c-menu > *:first-child {
|
|
6
|
+
padding-top: 5px;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.im-c-menu > *:last-child {
|
|
10
|
+
margin-bottom: -5px;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.im-c-menu-group:not(:last-child) {
|
|
14
|
+
padding-bottom: 5px;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.im-c-menu__item {
|
|
18
|
+
padding-bottom: 5px;
|
|
19
|
+
}
|
|
20
|
+
.im-c-menu__item:first-child {
|
|
21
|
+
padding-top: 0;
|
|
22
|
+
}
|
|
23
|
+
.im-c-menu--has-groups > .im-c-menu__item:not(:first-child) {
|
|
24
|
+
padding-top: 5px;
|
|
25
|
+
}
|
|
26
|
+
.im-c-menu-group .im-c-menu__item {
|
|
27
|
+
padding-top: 0;
|
|
28
|
+
padding-bottom: 0;
|
|
29
|
+
}
|
|
30
|
+
.im-c-menu-group .im-c-menu__item:not(:last-child) {
|
|
31
|
+
margin-bottom: 0;
|
|
32
|
+
}
|
|
33
|
+
.im-c-menu__item .im-c-menu__item-label {
|
|
34
|
+
width: 100%;
|
|
35
|
+
max-width: none;
|
|
36
|
+
align-items: start;
|
|
37
|
+
padding-top: 12px;
|
|
38
|
+
padding-bottom: 10px;
|
|
39
|
+
align-self: auto;
|
|
40
|
+
font-size: 1rem;
|
|
41
|
+
line-height: 1.2;
|
|
42
|
+
color: var(--foreground-color);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.im-c-menu__item .govuk-checkboxes__item,
|
|
46
|
+
.im-c-menu__item .govuk-radios__item {
|
|
47
|
+
flex-wrap: nowrap;
|
|
48
|
+
}
|
|
49
|
+
.im-c-menu__item .govuk-checkboxes__item .govuk-checkboxes__input, .im-c-menu__item .govuk-checkboxes__item .govuk-radios__input,
|
|
50
|
+
.im-c-menu__item .govuk-radios__item .govuk-checkboxes__input,
|
|
51
|
+
.im-c-menu__item .govuk-radios__item .govuk-radios__input {
|
|
52
|
+
margin-left: -3px;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.im-c-menu-group__fieldset {
|
|
56
|
+
border: none;
|
|
57
|
+
padding: 0;
|
|
58
|
+
margin: 0;
|
|
59
|
+
min-width: 0;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.im-c-menu-group__legend {
|
|
63
|
+
padding-top: 15px;
|
|
64
|
+
padding-bottom: 10px;
|
|
65
|
+
padding-inline: 0;
|
|
66
|
+
font-size: 1rem;
|
|
67
|
+
font-weight: bold;
|
|
68
|
+
color: var(--foreground-color);
|
|
69
|
+
}
|
|
70
|
+
.im-c-menu-group__legend h3 {
|
|
71
|
+
font-size: inherit;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.im-c-menu-group:first-child .im-c-menu-group__legend {
|
|
75
|
+
padding-top: 0;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.im-c-menu .govuk-checkboxes__input[aria-disabled=true] + .govuk-checkboxes__label {
|
|
79
|
+
opacity: 0.5;
|
|
80
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createContext as e,useContext as t,useRef as a,useEffect as n}from"preact/compat";import{jsx as r,jsxs as i,Fragment as u}from"preact/jsx-runtime";import o from"@babel/runtime/helpers/defineProperty";var l={},c=e=>{var t,a=(null===(t=l)||void 0===t||null===(t=t.current)||void 0===t?void 0:t.menuState)||{};for(var[n,r]of Object.entries(e)){var i=a[n];if(!r.includes(i))return!1}return!0},m=e=>{if(null==e)return!0;if("boolean"==typeof e)return e;if("object"==typeof e){for(var[t,a]of Object.entries(e))if("menu"===t&&!c(a))return!1;return!0}return!0},s=e("map-menu"),d=e=>"".concat(t(s),"-").concat(e),p=e=>{var{menuGroupItem:t,name:a,checked:n,onChange:u}=e,o=d("radio-".concat(t.id)),{visibleWhen:l}=t;return!l||m(l)?r("div",{className:'im-c-menu__item govuk-radios govuk-radios--small"',"data-module":"govuk-radios",children:i("div",{className:"govuk-radios__item",children:[r("input",{id:o,className:"govuk-radios__input",type:"radio",name:a,value:t.id,checked:n,onChange:u}),r("label",{className:"im-c-menu__item-label govuk-label govuk-radios__label",htmlFor:o,children:t.label})]})}):null},h=e=>{var{menuGroup:t,children:a}=e,n=t.groupLabel||t.label;if(!n)return r(u,{children:a});return r("div",{className:"govuk-form-group im-c-menu-group",children:i("fieldset",{className:"im-c-menu-group__fieldset",children:[r("legend",{className:"im-c-menu-group__legend",children:i("h3",{children:[" ",n," "]})}),a]})},t.id)},v=e=>{var{menuState:t,dispatch:a,menuGroup:n}=e,{id:i,items:u,visibleWhen:o}=n;if(!(!o||m(o)))return null;var l=t[i],c=e=>{a({type:"UPDATE_MENU_STATE",payload:{[i]:e.target.value}})};return r(h,{menuGroup:n,children:r("div",{className:"govuk-radios govuk-radios--small","data-module":"govuk-radios",children:u.map(e=>r(p,{menuGroupItem:e,name:i,checked:e.id===l,onChange:c},e.id))})})},b=e=>{var{dispatch:t,menuGroupItem:a,onChange:n,checked:u}=e,o="im-c-menu__item govuk-checkboxes govuk-checkboxes--small".concat(u?"":" im-c-menu__item--checked"),l=d("checkbox-".concat(a.id));return r("div",{className:o,"data-module":"govuk-checkboxes",children:i("div",{className:"govuk-checkboxes__item",children:[r("input",{className:"govuk-checkboxes__input",id:l,name:l,type:"checkbox",checked:u,onChange:e=>{var r,i=Boolean(null===(r=e.target)||void 0===r?void 0:r.checked);n&&n(i),t({type:"UPDATE_MENU_STATE",payload:{[a.id]:i}})}}),r("label",{className:"im-c-menu__item-label govuk-label govuk-checkboxes__label",htmlFor:l,children:a.label})]})},l)},g=e=>{var{dispatch:t,menuGroup:a,menuState:n}=e;return i(h,{menuGroup:a,children:[" ",a.items.map(e=>r(b,{dispatch:t,menuGroupItem:e,checked:n[e.id],onChange:e.handleOnChange},e.id))]})},f=e=>{var{menuGroup:t,dispatch:a,menuState:n}=e;return"checkbox"===t.type?r(g,{menuGroup:t,dispatch:a,menuState:n}):r(v,{menuGroup:t,dispatch:a,menuState:n})},k=e=>{};function _(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),a.push.apply(a,n)}return a}function y(e){for(var t=1;t<arguments.length;t++){var a=null!=arguments[t]?arguments[t]:{};t%2?_(Object(a),!0).forEach(function(t){o(e,t,a[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):_(Object(a)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(a,t))})}return e}var S={InitComponent:function(e){var{pluginConfig:t,pluginState:r,mapState:i,services:u}=e,{dispatch:o}=r,{eventBus:c}=u,m=a(r);m.current=r,n(()=>{if(!i.isMapReady)return()=>{};(e=>{l=e})(m);var{menu:e}=t;return(e=>{var{menu:t,eventBus:a,dispatch:n,pluginStateRef:r}=e;return n({type:"SET_MENU",payload:{menu:t}}),a.requestOnce("datasets:registry",k),a.emitWhenRequested("menu:state",r)})({menu:e,eventBus:c,dispatch:o,pluginStateRef:m})},[i.isMapReady]),n(()=>c.emit("menu:changed",r.menuState),[r.menuState])},reducer:{initialState:{actionsArray:[],menu:[],menuState:{}},actions:{SET_MENU:(e,t)=>{var{menu:a}=t,n=(e=>{var t={};return e.forEach(e=>{var a;"radio"===e.type&&(t[e.id]=e.value||(null===(a=e.items)||void 0===a?void 0:a[0].value))}),t})(a);return y(y({},e),{},{menu:a,menuState:n})},UPDATE_MENU_STATE:(e,t)=>y(y({},e),{},{menuState:y(y({},e.menuState),t)})}},panels:[{id:"menu",label:"Layers",mobile:{slot:"drawer",modal:!0,dismissible:!0},tablet:{slot:"left-top",dismissible:!0,exclusive:!0,width:"260px"},desktop:{slot:"left-top",modal:!1,dismissible:!0,exclusive:!0,width:"280px"},render:e=>{var{pluginState:t,appConfig:a}=e,{menu:n=[],dispatch:u,menuState:o}=t,l=(null==a?void 0:a.id)||"map",c=n.some(e=>e.groupLabel),m="im-c-menu".concat(c?" im-c-menu--has-groups":"");return r(s,{value:"".concat(l,"-menu"),children:i("div",{className:m,children:[" ",n.map(e=>r(f,{menuGroup:e,dispatch:u,menuState:o},e.id))]})})}}],buttons:[{id:"menuButton",label:"Layers",panelId:"menu",iconId:"layersMenu",mobile:{slot:"top-left",showLabel:!0},tablet:{slot:"top-left",showLabel:!0},desktop:{slot:"top-left",showLabel:!0}}],icons:[{id:"layersMenu",svgContent:'<path d="M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z"></path><path d="M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12"></path><path d="M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17"></path>'}]};export{S as manifest};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"@babel/runtime/helpers/asyncToGenerator";import r from"@babel/runtime/helpers/defineProperty";function t(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),t.push.apply(t,n)}return t}function n(e){for(var n=1;n<arguments.length;n++){var o=null!=arguments[n]?arguments[n]:{};n%2?t(Object(o),!0).forEach(function(t){r(e,t,o[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):t(Object(o)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(o,r))})}return e}function o(){var r;return n(n({noKeyItemText:"No features displayed"},arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),{},{id:"menu",load:(r=e(function*(){return(yield import(/* webpackChunkName: "im-menu-plugin" */ "./im-menu-plugin.js")).manifest}),function(){return r.apply(this,arguments)})})}export{o as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(this.webpackChunkdefra_DefraMap=this.webpackChunkdefra_DefraMap||[]).push([[217],{77(e,t,n){n.r(t),n.d(t,{manifest:()=>w});var r=n(738);function o(e){return o="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},o(e)}function i(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,i,u,a=[],c=!0,l=!1;try{if(i=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=i.call(n)).done)&&(a.push(r.value),a.length!==t);c=!0);}catch(e){l=!0,o=e}finally{try{if(!c&&null!=n.return&&(u=n.return(),Object(u)!==u))return}finally{if(l)throw o}}return a}}(e,t)||function(e,t){if(e){if("string"==typeof e)return u(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?u(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function u(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}var a={},c=function(e){for(var t,n=(null===(t=a)||void 0===t||null===(t=t.current)||void 0===t?void 0:t.menuState)||{},r=0,o=Object.entries(e);r<o.length;r++){var u=i(o[r],2),c=u[0],l=u[1],s=n[c];if(!l.includes(s))return!1}return!0},l=function(e){if(null==e)return!0;if("boolean"==typeof e)return e;if("object"===o(e)){for(var t=0,n=Object.entries(e);t<n.length;t++){var r=i(n[t],2),u=r[0],a=r[1];if("menu"===u&&!c(a))return!1}return!0}return!0},s=(0,r.createContext)("map-menu"),m=function(e){return"".concat((0,r.useContext)(s),"-").concat(e)},f=n(287),p=function(e){var t=e.menuGroupItem,n=e.name,r=e.checked,o=e.onChange,i=m("radio-".concat(t.id)),u=t.visibleWhen;return!u||l(u)?(0,f.jsx)("div",{className:'im-c-menu__item govuk-radios govuk-radios--small"',"data-module":"govuk-radios",children:(0,f.jsxs)("div",{className:"govuk-radios__item",children:[(0,f.jsx)("input",{id:i,className:"govuk-radios__input",type:"radio",name:n,value:t.id,checked:r,onChange:o}),(0,f.jsx)("label",{className:"im-c-menu__item-label govuk-label govuk-radios__label",htmlFor:i,children:t.label})]})}):null},d=function(e){var t=e.menuGroup,n=e.children,r=t.groupLabel||t.label;return r?(0,f.jsx)("div",{className:"govuk-form-group im-c-menu-group",children:(0,f.jsxs)("fieldset",{className:"im-c-menu-group__fieldset",children:[(0,f.jsx)("legend",{className:"im-c-menu-group__legend",children:(0,f.jsxs)("h3",{children:[" ",r," "]})}),n]})},t.id):(0,f.jsx)(f.Fragment,{children:n})};function b(e){return b="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},b(e)}var v=function(e){var t=e.menuState,n=e.dispatch,r=e.menuGroup,o=r.id,i=r.items,u=r.visibleWhen;if(u&&!l(u))return null;var a=t[o],c=function(e){var t,r,i;n({type:"UPDATE_MENU_STATE",payload:(t={},r=o,i=e.target.value,(r=function(e){var t=function(e){if("object"!=b(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=b(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==b(t)?t:t+""}(r))in t?Object.defineProperty(t,r,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[r]=i,t)})};return(0,f.jsx)(d,{menuGroup:r,children:(0,f.jsx)("div",{className:"govuk-radios govuk-radios--small","data-module":"govuk-radios",children:i.map(function(e){return(0,f.jsx)(p,{menuGroupItem:e,name:o,checked:e.id===a,onChange:c},e.id)})})})};function y(e){return y="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},y(e)}var h=function(e){var t=e.dispatch,n=e.menuGroupItem,r=e.onChange,o=e.checked,i="im-c-menu__item govuk-checkboxes govuk-checkboxes--small".concat(o?"":" im-c-menu__item--checked"),u=m("checkbox-".concat(n.id));return(0,f.jsx)("div",{className:i,"data-module":"govuk-checkboxes",children:(0,f.jsxs)("div",{className:"govuk-checkboxes__item",children:[(0,f.jsx)("input",{className:"govuk-checkboxes__input",id:u,name:u,type:"checkbox",checked:o,onChange:function(e){var o,i,u,a,c=Boolean(null===(o=e.target)||void 0===o?void 0:o.checked);r&&r(c),t({type:"UPDATE_MENU_STATE",payload:(i={},u=n.id,a=c,(u=function(e){var t=function(e){if("object"!=y(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=y(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==y(t)?t:t+""}(u))in i?Object.defineProperty(i,u,{value:a,enumerable:!0,configurable:!0,writable:!0}):i[u]=a,i)})}}),(0,f.jsx)("label",{className:"im-c-menu__item-label govuk-label govuk-checkboxes__label",htmlFor:u,children:n.label})]})},u)},g=function(e){var t=e.dispatch,n=e.menuGroup,r=e.menuState;return(0,f.jsxs)(d,{menuGroup:n,children:[" ",n.items.map(function(e){return(0,f.jsx)(h,{dispatch:t,menuGroupItem:e,checked:r[e.id],onChange:e.handleOnChange},e.id)})]})},S=function(e){var t=e.menuGroup,n=e.dispatch,r=e.menuState;return"checkbox"===t.type?(0,f.jsx)(g,{menuGroup:t,dispatch:n,menuState:r}):(0,f.jsx)(v,{menuGroup:t,dispatch:n,menuState:r})},j=function(e){};function k(e){return k="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},k(e)}function x(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function _(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?x(Object(n),!0).forEach(function(t){O(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):x(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function O(e,t,n){return(t=function(e){var t=function(e){if("object"!=k(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=k(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==k(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var w={InitComponent:function(e){var t=e.pluginConfig,n=e.pluginState,o=e.mapState,i=e.services,u=n.dispatch,c=i.eventBus,l=(0,r.useRef)(n);l.current=n,(0,r.useEffect)(function(){return o.isMapReady?(function(e){a=e}(l),function(e){var t=e.eventBus,n=e.pluginStateRef;return(0,e.dispatch)({type:"SET_MENU",payload:{menu:e.menu}}),t.requestOnce("datasets:registry",j),t.emitWhenRequested("menu:state",n)}({menu:t.menu,eventBus:c,dispatch:u,pluginStateRef:l})):function(){}},[o.isMapReady]),(0,r.useEffect)(function(){return c.emit("menu:changed",n.menuState)},[n.menuState])},reducer:{initialState:{actionsArray:[],menu:[],menuState:{}},actions:{SET_MENU:function(e,t){var n=t.menu,r=function(e){var t={};return e.forEach(function(e){var n;"radio"===e.type&&(t[e.id]=e.value||(null===(n=e.items)||void 0===n?void 0:n[0].value))}),t}(n);return _(_({},e),{},{menu:n,menuState:r})},UPDATE_MENU_STATE:function(e,t){return _(_({},e),{},{menuState:_(_({},e.menuState),t)})}}},panels:[{id:"menu",label:"Layers",mobile:{slot:"drawer",modal:!0,dismissible:!0},tablet:{slot:"left-top",dismissible:!0,exclusive:!0,width:"260px"},desktop:{slot:"left-top",modal:!1,dismissible:!0,exclusive:!0,width:"280px"},render:function(e){var t=e.pluginState,n=e.appConfig,r=t.menu,o=void 0===r?[]:r,i=t.dispatch,u=t.menuState,a=(null==n?void 0:n.id)||"map",c=o.some(function(e){return e.groupLabel}),l="im-c-menu".concat(c?" im-c-menu--has-groups":"");return(0,f.jsx)(s,{value:"".concat(a,"-menu"),children:(0,f.jsxs)("div",{className:l,children:[" ",o.map(function(e){return(0,f.jsx)(S,{menuGroup:e,dispatch:i,menuState:u},e.id)})]})})}}],buttons:[{id:"menuButton",label:"Layers",panelId:"menu",iconId:"layersMenu",mobile:{slot:"top-left",showLabel:!0},tablet:{slot:"top-left",showLabel:!0},desktop:{slot:"top-left",showLabel:!0}}],icons:[{id:"layersMenu",svgContent:'<path d="M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z"></path><path d="M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12"></path><path d="M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17"></path>'}]}}}]);
|
|
@@ -0,0 +1,2 @@
|
|
|
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.menuPlugin=t())}(this,()=>(()=>{"use strict";var e,t,r={738(e){e.exports=preactCompat},287(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=(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=e=>Promise.all(Object.keys(o.f).reduce((t,r)=>(o.f[r](e,t),t),[])),o.u=e=>"im-menu-plugin.js",o.miniCssF=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=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),e={},t="defra.menuPlugin:",o.l=(r,n,i,a)=>{if(e[r])e[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")==t+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",t+i),u.src=r),e[r]=[n];var s=(t,n)=>{u.onerror=u.onload=null,clearTimeout(d);var o=e[r];if(delete e[r],u.parentNode&&u.parentNode.removeChild(u),o&&o.forEach(e=>e(n)),t)return t(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=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{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})(),(()=>{var e={57:0};o.f.j=(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((r,o)=>n=e[t]=[r,o]);r.push(n[2]=i);var a=o.p+o.u(t),u=new Error;o.l(a,r=>{if(o.o(e,t)&&(0!==(n=e[t])&&(e[t]=void 0),n)){var i=r&&("load"===r.type?"missing":r.type),a=r&&r.target&&r.target.src;u.message="Loading chunk "+t+" failed.\n("+i+": "+a+")",u.name="ChunkLoadError",u.type=i,u.request=a,n[1](u)}},"chunk-"+t,t)}};var t=(t,r)=>{var n,i,[a,u,c]=r,f=0;if(a.some(t=>0!==e[t])){for(n in u)o.o(u,n)&&(o.m[n]=u[n]);c&&c(o)}for(t&&t(r);f<a.length;f++)i=a[f],o.o(e,i)&&e[i]&&e[i][0](),e[i]=0},r=this.webpackChunkdefra_DefraMap=this.webpackChunkdefra_DefraMap||[];r.forEach(t.bind(null,0)),r.push=t.bind(null,r.push.bind(r))})();var i={};function a(e){return a="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},a(e)}function u(){var e,t,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function i(r,n,o,i){var u=n&&n.prototype instanceof f?n:f,p=Object.create(u.prototype);return c(p,"_invoke",function(r,n,o){var i,u,c,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,u=0,c=e,s.n=r,a}};function d(r,n){for(u=r,c=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)&&(c=i[(u=i[4])?5:(u=3,3)],i[4]=i[5]=e):i[0]<=d&&((o=r<2&&d<i[1])?(u=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,u=0))}if(o||r>1)return a;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),u=p,c=b;(t=u<2?e:c)||!l;){i||(u?u<3?(u>1&&(s.n=-1),d(u,c)):s.n=c:s.v=c);try{if(f=2,i){if(u||(o="next"),t=i[o]){if(!(t=t.call(i,c)))throw TypeError("iterator result is not an object");if(!t.done)return t;c=t.value,u<2&&(u=0)}else 1===u&&(t=i.return)&&t.call(i),u<2&&(c=TypeError("The iterator does not provide a '"+o+"' method"),u=1);i=e}else if((t=(l=s.n<0)?c:r.call(n,s))!==a)break}catch(t){i=e,u=1,c=t}finally{f=1}}return{value:t,done:l}}}(r,o,i),!0),p}var a={};function f(){}function p(){}function l(){}t=Object.getPrototypeOf;var s=[][n]?t(t([][n]())):(c(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,c(e,o,"GeneratorFunction")),e.prototype=Object.create(d),e}return p.prototype=l,c(d,"constructor",l),c(l,"constructor",p),p.displayName="GeneratorFunction",c(l,o,"GeneratorFunction"),c(d),c(d,o,"Generator"),c(d,n,function(){return this}),c(d,"toString",function(){return"[object Generator]"}),(u=function(){return{w:i,m:b}})()}function c(e,t,r,n){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}c=function(e,t,r,n){function i(t,r){c(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))},c(e,t,r,n)}function f(e,t,r,n,o,i,a){try{var u=e[i](a),c=u.value}catch(e){return void r(e)}u.done?t(c):Promise.resolve(c).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"!=a(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=a(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==a(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:"menu",load:(e=u().m(function e(){var t;return u().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,o.e(217).then(o.bind(o,77));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 a(e){f(i,n,o,a,u,"next",e)}function u(e){f(i,n,o,a,u,"throw",e)}a(void 0)})},function(){return t.apply(this,arguments)})})}return o.d(i,{default:()=>d}),i.default})());
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
|