@defra/interactive-map 0.0.54-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/add-polygons.njk +1 -1
- package/assets/templates/add-symbols.njk +4 -4
- package/assets/templates/draw-tools.njk +7 -7
- package/assets/templates/marker-panel.njk +5 -5
- package/assets/templates/place-marker.njk +8 -8
- package/assets/templates/search-control.njk +1 -1
- package/assets/templates/select-feature.njk +7 -7
- package/assets/templates/style-switcher.njk +6 -6
- package/assets/templates/toggle-marker-label.njk +3 -3
- package/dist/esm/im-core.js +1 -1
- package/dist/esm/im-shell.js +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/umd/im-core.js +1 -1
- package/dist/umd/im-core.js.LICENSE.txt +0 -30
- package/dist/umd/index.js +1 -1
- package/dist/umd/index.js.LICENSE.txt +0 -20
- package/docs/api/context.md +2 -0
- package/docs/api.md +20 -14
- package/docs/architecture/interactive-map.likec4 +4 -4
- package/docs/building-a-plugin.md +2 -2
- package/docs/examples/add-marker-with-panel.mdx +46 -44
- package/docs/examples/add-polygons.mdx +100 -98
- package/docs/examples/add-symbols.mdx +75 -73
- package/docs/examples/basic-map.mdx +16 -14
- package/docs/examples/button-map.mdx +16 -14
- package/docs/examples/draw-tools.mdx +119 -117
- package/docs/examples/place-marker.mdx +51 -49
- package/docs/examples/search-control.mdx +22 -20
- package/docs/examples/select-feature.mdx +107 -105
- package/docs/examples/style-switcher.mdx +47 -45
- package/docs/examples/toggle-marker-label.mdx +30 -28
- package/docs/getting-started.md +26 -24
- package/docs/plugins/datasets.md +11 -0
- package/docs/plugins/draw.md +18 -12
- package/docs/plugins/interact.md +33 -10
- package/docs/plugins/plugin-descriptor.md +1 -1
- package/docs/plugins/search.md +5 -5
- package/docusaurus.config.cjs +48 -3
- package/govuk-prototype-kit.config.json +6 -7
- package/package.json +22 -29
- 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/layerAdapter.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-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/esm/liveDrawChecks.js +1 -1
- package/plugins/draw/dist/umd/im-draw-ml-adapter.js +1 -1
- 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 +47 -26
- package/plugins/draw/src/DrawInit.test.jsx +90 -2
- package/plugins/draw/src/adapters/maplibre/styles.js +3 -2
- package/plugins/draw/src/adapters/maplibre/styles.test.js +3 -3
- 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/im-draw-es-plugin.js +1 -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/im-frame-plugin.js +1 -0
- package/plugins/frame/dist/esm/index.js +1 -0
- package/plugins/frame/dist/umd/im-frame-plugin.js +1 -0
- package/plugins/frame/dist/umd/index.js +2 -0
- 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/im-map-styles-plugin.js +1 -0
- package/plugins/map-styles/dist/esm/index.js +1 -0
- package/plugins/map-styles/dist/umd/im-map-styles-plugin.js +1 -0
- package/plugins/map-styles/dist/umd/index.js +2 -0
- 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/im-menu-plugin.js +1 -1
- package/plugins/menu/dist/esm/index.js +1 -1
- package/plugins/menu/dist/umd/im-menu-plugin.js +1 -1
- package/plugins/menu/dist/umd/index.js +1 -1
- package/plugins/scale-bar/dist/esm/im-scale-bar-plugin.js +1 -0
- package/plugins/scale-bar/dist/esm/index.js +1 -0
- package/plugins/scale-bar/dist/umd/im-scale-bar-plugin.js +1 -0
- package/plugins/scale-bar/dist/umd/index.js +2 -0
- 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/im-use-location-plugin.js +1 -0
- package/plugins/use-location/dist/esm/index.js +1 -0
- package/plugins/use-location/dist/umd/im-use-location-plugin.js +1 -0
- package/plugins/use-location/dist/umd/index.js +2 -0
- package/providers/esri/dist/esm/im-esri-provider.js +1 -0
- 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/im-maplibre-provider.js +1 -1
- package/providers/maplibre/dist/esm/index.js +1 -1
- package/providers/maplibre/dist/umd/im-maplibre-framework.js +1 -1
- package/providers/maplibre/dist/umd/im-maplibre-framework.js.LICENSE.txt +3 -3
- package/providers/maplibre/dist/umd/im-maplibre-provider.js +1 -1
- package/providers/maplibre/dist/umd/im-maplibre-worker.js +2 -0
- package/providers/maplibre/dist/umd/im-maplibre-worker.js.LICENSE.txt +4 -0
- package/providers/maplibre/dist/umd/index.js +1 -1
- package/providers/maplibre/src/index.js +41 -12
- package/providers/maplibre/src/index.test.js +43 -12
- package/providers/maplibre/src/utils/detectModuleWorker.js +25 -0
- package/providers/maplibre/src/utils/detectModuleWorker.test.js +40 -0
- package/providers/maplibre/src/utils/spatial.js +22 -12
- package/providers/maplibre/src/utils/spatial.test.js +6 -6
- package/providers/maplibre/src/utils/workerUrl.js +15 -0
- package/providers/maplibre/src/utils/workerUrl.test.js +14 -0
- package/providers/open-names/dist/esm/im-reverse-geocode.js +1 -0
- package/providers/open-names/dist/esm/index.js +1 -0
- package/providers/open-names/dist/umd/im-reverse-geocode.js +2 -0
- package/providers/open-names/dist/umd/index.js +2 -0
- package/providers/openlayers/dist/esm/im-openlayers-provider.js +1 -0
- package/providers/openlayers/dist/esm/index.js +1 -0
- package/providers/openlayers/dist/umd/im-openlayers-provider.js +2 -0
- package/providers/openlayers/dist/umd/index.js +2 -0
- package/providers/openlayers/src/index.js +60 -0
- package/providers/openlayers/src/index.test.js +47 -0
- 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 +79 -46
- 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/InteractiveMap.js +2 -1
- package/src/InteractiveMap/InteractiveMap.test.js +9 -2
- package/src/InteractiveMap/domStateManager.js +21 -1
- package/src/InteractiveMap/domStateManager.test.js +48 -1
- package/src/InteractiveMap/parseDataProperties.js +4 -4
- package/src/InteractiveMap/parseDataProperties.test.js +62 -6
- package/src/InteractiveMap/polyfills.js +4 -3
- package/src/InteractiveMap/polyfills.test.js +12 -0
- package/src/config/events.js +4 -2
- package/src/scss/tools/_govuk-content.scss +4 -3
- package/src/types.js +3 -5
- package/webpack.dev.mjs +11 -3
- package/webpack.prod.mjs +11 -4
- package/webpack.umd.mjs +34 -14
- package/plugins/beta/draw-es/dist/esm/im-draw-es-plugin.js +0 -1
- 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/im-frame-plugin.js +0 -1
- package/plugins/beta/frame/dist/esm/index.js +0 -1
- package/plugins/beta/frame/dist/umd/im-frame-plugin.js +0 -1
- package/plugins/beta/frame/dist/umd/index.js +0 -2
- package/plugins/beta/map-styles/dist/esm/im-map-styles-plugin.js +0 -1
- package/plugins/beta/map-styles/dist/esm/index.js +0 -1
- package/plugins/beta/map-styles/dist/umd/im-map-styles-plugin.js +0 -1
- package/plugins/beta/map-styles/dist/umd/index.js +0 -2
- package/plugins/beta/scale-bar/dist/esm/im-scale-bar-plugin.js +0 -1
- package/plugins/beta/scale-bar/dist/esm/index.js +0 -1
- package/plugins/beta/scale-bar/dist/umd/im-scale-bar-plugin.js +0 -1
- package/plugins/beta/scale-bar/dist/umd/index.js +0 -2
- package/plugins/beta/use-location/dist/esm/im-use-location-plugin.js +0 -1
- package/plugins/beta/use-location/dist/esm/index.js +0 -1
- package/plugins/beta/use-location/dist/umd/im-use-location-plugin.js +0 -1
- package/plugins/beta/use-location/dist/umd/index.js +0 -2
- 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/im-esri-provider.js +0 -1
- package/providers/beta/esri/dist/esm/index.js +0 -1
- package/providers/beta/open-names/dist/esm/im-reverse-geocode.js +0 -1
- package/providers/beta/open-names/dist/esm/index.js +0 -1
- package/providers/beta/open-names/dist/umd/im-reverse-geocode.js +0 -2
- package/providers/beta/open-names/dist/umd/index.js +0 -2
- package/providers/beta/openlayers/dist/esm/im-openlayers-provider.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 +0 -2
- package/providers/beta/openlayers/dist/umd/index.js.LICENSE.txt +0 -1
- package/providers/beta/openlayers/src/index.js +0 -37
- /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/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/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/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/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}/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/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/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/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,12 +1,16 @@
|
|
|
1
1
|
import { useCallback, useEffect, useRef } from 'react'
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
const LISTBOX_SELECTOR = '[role="listbox"], [role="option"]'
|
|
4
|
+
|
|
5
|
+
export function useCrossHairVisibility ({ crossHair, enabled, targetNeeded, appState, dispatch }) {
|
|
4
6
|
const enabledRef = useRef(enabled)
|
|
5
7
|
enabledRef.current = enabled
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
+
const targetNeededRef = useRef(targetNeeded)
|
|
9
|
+
targetNeededRef.current = targetNeeded
|
|
8
10
|
const crossHairRef = useRef(crossHair)
|
|
9
11
|
crossHairRef.current = crossHair
|
|
12
|
+
const dispatchRef = useRef(dispatch)
|
|
13
|
+
dispatchRef.current = dispatch
|
|
10
14
|
const listboxFocusRef = useRef(false)
|
|
11
15
|
// True while focus is inside an element (marked `data-map-keyboard-scope`) that actually routes cursor keys to the map, e.g. the viewport or MapControl's D-pad.
|
|
12
16
|
const mapKeyboardScopedRef = useRef(false)
|
|
@@ -14,34 +18,40 @@ export function useCrossHairVisibility ({ crossHair, enabled, selectMarkerOnly,
|
|
|
14
18
|
interfaceTypeRef.current = appState.interfaceType
|
|
15
19
|
|
|
16
20
|
const updateCrossHair = useCallback(() => {
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
// user — same audience this crosshair already exists for — so it counts as its own reason
|
|
22
|
-
// to show it, independent of the currently-inferred interface type (which, for a Voice
|
|
23
|
-
// Control user, will never register as anything but the default 'mouse').
|
|
24
|
-
const mapControlsOpen = appState.expandedButtons?.has('mapControls')
|
|
25
|
-
if (enabledRef.current && (keyboardCanOperateMap || touchCanOperateMap || mapControlsOpen)) {
|
|
21
|
+
const keyboardCanOperateMap = interfaceTypeRef.current === 'keyboard' && mapKeyboardScopedRef.current
|
|
22
|
+
// hide() is a no-op while MapControls is open (useCrossHairAPI.js), so listbox focus never hides it then.
|
|
23
|
+
const targetCanShow = targetNeededRef.current && !listboxFocusRef.current
|
|
24
|
+
if (enabledRef.current && (keyboardCanOperateMap || targetCanShow)) {
|
|
26
25
|
crossHairRef.current.fixAtCenter()
|
|
27
26
|
} else {
|
|
28
27
|
crossHairRef.current.hide()
|
|
29
28
|
}
|
|
30
|
-
}, [
|
|
29
|
+
}, [])
|
|
31
30
|
|
|
32
31
|
useEffect(() => {
|
|
33
32
|
updateCrossHair()
|
|
34
|
-
}, [enabled,
|
|
33
|
+
}, [enabled, targetNeeded, appState.interfaceType, updateCrossHair])
|
|
35
34
|
|
|
36
35
|
useEffect(() => {
|
|
37
36
|
const container = appState.layoutRefs?.appContainerRef?.current
|
|
38
37
|
if (!container) { return undefined }
|
|
38
|
+
const setListboxFocus = (inListbox) => {
|
|
39
|
+
listboxFocusRef.current = inListbox
|
|
40
|
+
// Mirrored into plugin state so the Select button (manifest hiddenWhen) hides with the crosshair.
|
|
41
|
+
dispatchRef.current?.({ type: 'SET_LISTBOX_FOCUSED', payload: inListbox })
|
|
42
|
+
}
|
|
39
43
|
mapKeyboardScopedRef.current = !!document.activeElement?.closest('[data-map-keyboard-scope]')
|
|
44
|
+
if (document.activeElement?.closest(LISTBOX_SELECTOR)) {
|
|
45
|
+
setListboxFocus(true)
|
|
46
|
+
}
|
|
40
47
|
const handleFocusIn = (e) => {
|
|
41
|
-
const inListbox = !!e.target.closest(
|
|
48
|
+
const inListbox = !!e.target.closest(LISTBOX_SELECTOR)
|
|
42
49
|
const inMapKeyboardScope = !!e.target.closest('[data-map-keyboard-scope]')
|
|
43
|
-
const
|
|
44
|
-
|
|
50
|
+
const listboxChanged = listboxFocusRef.current !== inListbox
|
|
51
|
+
const changed = listboxChanged || mapKeyboardScopedRef.current !== inMapKeyboardScope
|
|
52
|
+
if (listboxChanged) {
|
|
53
|
+
setListboxFocus(inListbox)
|
|
54
|
+
}
|
|
45
55
|
mapKeyboardScopedRef.current = inMapKeyboardScope
|
|
46
56
|
// Keep the refs current regardless, but only touch the crosshair while enabled — while disabled, another owner (e.g. draw mode) is responsible for it.
|
|
47
57
|
if (changed && enabledRef.current) {
|
|
@@ -15,14 +15,14 @@ beforeEach(() => {
|
|
|
15
15
|
describe('useCrossHairVisibility', () => {
|
|
16
16
|
it('skips listbox focus listeners when appContainerRef is null', () => {
|
|
17
17
|
appState.layoutRefs.appContainerRef = { current: null }
|
|
18
|
-
renderHook(() => useCrossHairVisibility({ crossHair, enabled: true,
|
|
18
|
+
renderHook(() => useCrossHairVisibility({ crossHair, enabled: true, targetNeeded: false, appState }))
|
|
19
19
|
expect(crossHair.hide).toHaveBeenCalled()
|
|
20
20
|
})
|
|
21
21
|
|
|
22
22
|
it('shows crosshair on touch and hides when listbox has focus', () => {
|
|
23
23
|
const container = appState.layoutRefs.appContainerRef.current
|
|
24
24
|
appState.interfaceType = 'touch'
|
|
25
|
-
renderHook(() => useCrossHairVisibility({ crossHair, enabled: true,
|
|
25
|
+
renderHook(() => useCrossHairVisibility({ crossHair, enabled: true, targetNeeded: true, appState }))
|
|
26
26
|
|
|
27
27
|
expect(crossHair.fixAtCenter).toHaveBeenCalled()
|
|
28
28
|
|
|
@@ -47,6 +47,71 @@ describe('useCrossHairVisibility', () => {
|
|
|
47
47
|
expect(crossHair.fixAtCenter).toHaveBeenCalledTimes(2)
|
|
48
48
|
})
|
|
49
49
|
|
|
50
|
+
it('hides crosshair on touch when the target is not needed, and shows it once it is (e.g. map controls opened)', () => {
|
|
51
|
+
appState.interfaceType = 'touch'
|
|
52
|
+
const { rerender } = renderHook(
|
|
53
|
+
(props) => useCrossHairVisibility(props),
|
|
54
|
+
{ initialProps: { crossHair, enabled: true, targetNeeded: false, appState } }
|
|
55
|
+
)
|
|
56
|
+
expect(crossHair.hide).toHaveBeenCalled()
|
|
57
|
+
expect(crossHair.fixAtCenter).not.toHaveBeenCalled()
|
|
58
|
+
|
|
59
|
+
rerender({ crossHair, enabled: true, targetNeeded: true, appState })
|
|
60
|
+
expect(crossHair.fixAtCenter).toHaveBeenCalledTimes(1)
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
it('applies the touch rule straight away when interact is re-enabled after another owner (e.g. draw)', () => {
|
|
64
|
+
appState.interfaceType = 'touch'
|
|
65
|
+
const { rerender } = renderHook(
|
|
66
|
+
(props) => useCrossHairVisibility(props),
|
|
67
|
+
{ initialProps: { crossHair, enabled: false, targetNeeded: false, appState } }
|
|
68
|
+
)
|
|
69
|
+
crossHair.hide.mockClear()
|
|
70
|
+
|
|
71
|
+
rerender({ crossHair, enabled: true, targetNeeded: false, appState })
|
|
72
|
+
expect(crossHair.hide).toHaveBeenCalledTimes(1)
|
|
73
|
+
expect(crossHair.fixAtCenter).not.toHaveBeenCalled()
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
it('dispatches listbox focus changes, only when the value changes', () => {
|
|
77
|
+
const container = appState.layoutRefs.appContainerRef.current
|
|
78
|
+
const dispatch = jest.fn()
|
|
79
|
+
renderHook(() => useCrossHairVisibility({ crossHair, enabled: true, targetNeeded: true, appState, dispatch }))
|
|
80
|
+
expect(dispatch).not.toHaveBeenCalled()
|
|
81
|
+
|
|
82
|
+
const option = document.createElement('div')
|
|
83
|
+
option.setAttribute('role', 'option')
|
|
84
|
+
const otherOption = document.createElement('div')
|
|
85
|
+
otherOption.setAttribute('role', 'option')
|
|
86
|
+
const outside = document.createElement('button')
|
|
87
|
+
container.append(option, otherOption, outside)
|
|
88
|
+
|
|
89
|
+
act(() => option.dispatchEvent(new FocusEvent('focusin', { bubbles: true })))
|
|
90
|
+
act(() => otherOption.dispatchEvent(new FocusEvent('focusin', { bubbles: true })))
|
|
91
|
+
act(() => outside.dispatchEvent(new FocusEvent('focusin', { bubbles: true })))
|
|
92
|
+
|
|
93
|
+
expect(dispatch.mock.calls).toEqual([
|
|
94
|
+
[{ type: 'SET_LISTBOX_FOCUSED', payload: true }],
|
|
95
|
+
[{ type: 'SET_LISTBOX_FOCUSED', payload: false }]
|
|
96
|
+
])
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
it('dispatches listbox focus on mount when the listbox already has focus', () => {
|
|
100
|
+
const container = appState.layoutRefs.appContainerRef.current
|
|
101
|
+
const listbox = document.createElement('div')
|
|
102
|
+
listbox.setAttribute('role', 'listbox')
|
|
103
|
+
listbox.tabIndex = 0
|
|
104
|
+
container.appendChild(listbox)
|
|
105
|
+
document.body.appendChild(container)
|
|
106
|
+
listbox.focus()
|
|
107
|
+
const dispatch = jest.fn()
|
|
108
|
+
|
|
109
|
+
renderHook(() => useCrossHairVisibility({ crossHair, enabled: true, targetNeeded: true, appState, dispatch }))
|
|
110
|
+
|
|
111
|
+
expect(dispatch).toHaveBeenCalledWith({ type: 'SET_LISTBOX_FOCUSED', payload: true })
|
|
112
|
+
container.remove()
|
|
113
|
+
})
|
|
114
|
+
|
|
50
115
|
it('hides crosshair in keyboard mode until focus enters the map keyboard scope', () => {
|
|
51
116
|
const container = appState.layoutRefs.appContainerRef.current
|
|
52
117
|
const viewportEl = document.createElement('div')
|
|
@@ -54,7 +119,7 @@ describe('useCrossHairVisibility', () => {
|
|
|
54
119
|
container.appendChild(viewportEl)
|
|
55
120
|
appState.interfaceType = 'keyboard'
|
|
56
121
|
|
|
57
|
-
renderHook(() => useCrossHairVisibility({ crossHair, enabled: true,
|
|
122
|
+
renderHook(() => useCrossHairVisibility({ crossHair, enabled: true, targetNeeded: false, appState }))
|
|
58
123
|
|
|
59
124
|
// interfaceType is 'keyboard' but nothing in the map keyboard scope has focus yet
|
|
60
125
|
expect(crossHair.hide).toHaveBeenCalled()
|
|
@@ -82,7 +147,7 @@ describe('useCrossHairVisibility', () => {
|
|
|
82
147
|
container.appendChild(mapControlScope)
|
|
83
148
|
appState.interfaceType = 'keyboard'
|
|
84
149
|
|
|
85
|
-
renderHook(() => useCrossHairVisibility({ crossHair, enabled: true,
|
|
150
|
+
renderHook(() => useCrossHairVisibility({ crossHair, enabled: true, targetNeeded: false, appState }))
|
|
86
151
|
expect(crossHair.fixAtCenter).not.toHaveBeenCalled()
|
|
87
152
|
|
|
88
153
|
// Focus lands on a direction button nested inside the scoped control, not
|
|
@@ -101,7 +166,7 @@ describe('useCrossHairVisibility', () => {
|
|
|
101
166
|
// interact starts disabled (e.g. a draw session already took over) — the crosshair
|
|
102
167
|
// is presumed to already be showing via that other owner, mirroring what
|
|
103
168
|
// DrawInit.jsx/drawInput.js would have set moments earlier.
|
|
104
|
-
renderHook(() => useCrossHairVisibility({ crossHair, enabled: false,
|
|
169
|
+
renderHook(() => useCrossHairVisibility({ crossHair, enabled: false, targetNeeded: false, appState }))
|
|
105
170
|
crossHair.fixAtCenter.mockClear()
|
|
106
171
|
crossHair.hide.mockClear()
|
|
107
172
|
|
|
@@ -120,7 +185,7 @@ describe('useCrossHairVisibility', () => {
|
|
|
120
185
|
|
|
121
186
|
const { rerender } = renderHook(
|
|
122
187
|
(props) => useCrossHairVisibility(props),
|
|
123
|
-
{ initialProps: { crossHair, enabled: true,
|
|
188
|
+
{ initialProps: { crossHair, enabled: true, targetNeeded: false, appState } }
|
|
124
189
|
)
|
|
125
190
|
expect(crossHair.hide).toHaveBeenCalled()
|
|
126
191
|
|
|
@@ -129,7 +194,7 @@ describe('useCrossHairVisibility', () => {
|
|
|
129
194
|
// 'keyboard' along the way, but the map keyboard scope was never entered.
|
|
130
195
|
act(() => menuButton.dispatchEvent(new FocusEvent('focusin', { bubbles: true })))
|
|
131
196
|
appState = { ...appState, interfaceType: 'keyboard' }
|
|
132
|
-
rerender({ crossHair, enabled: true,
|
|
197
|
+
rerender({ crossHair, enabled: true, targetNeeded: false, appState })
|
|
133
198
|
|
|
134
199
|
expect(crossHair.fixAtCenter).not.toHaveBeenCalled()
|
|
135
200
|
})
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// /plugins/interact/manifest.js
|
|
2
2
|
import { InteractInit } from './InteractInit.jsx'
|
|
3
|
-
import {
|
|
3
|
+
import { needsTarget } from './utils/needsTarget.js'
|
|
4
4
|
import { initialState, actions } from './reducer.js'
|
|
5
5
|
import { enable } from './api/enable.js'
|
|
6
6
|
import { disable } from './api/disable.js'
|
|
@@ -28,10 +28,10 @@ export const manifest = {
|
|
|
28
28
|
id: 'selectAtTarget',
|
|
29
29
|
label: 'Select',
|
|
30
30
|
variant: 'primary',
|
|
31
|
-
//
|
|
32
|
-
// and the
|
|
31
|
+
// Shown with the crosshair, using the same needsTarget rule. Not shown for keyboard focus in
|
|
32
|
+
// the map (Enter selects, and the button would hide as focus moved to it) or while the listbox has focus.
|
|
33
33
|
hiddenWhen: ({ appState, pluginState }) =>
|
|
34
|
-
!pluginState.enabled ||
|
|
34
|
+
!pluginState.enabled || pluginState.listboxFocused || !needsTarget({ appState, pluginState }),
|
|
35
35
|
mobile: {
|
|
36
36
|
slot: 'actions'
|
|
37
37
|
},
|
|
@@ -43,6 +43,35 @@ describe('manifest', () => {
|
|
|
43
43
|
expect(atTarget.hiddenWhen({ appState: { interfaceType: 'touch' }, pluginState: { enabled: false } })).toBe(true)
|
|
44
44
|
})
|
|
45
45
|
|
|
46
|
+
describe('selectAtTarget visibility', () => {
|
|
47
|
+
const atTarget = () => manifest.buttons.find(b => b.id === 'selectAtTarget')
|
|
48
|
+
const mapControlsOpen = new Set(['mapControls'])
|
|
49
|
+
const isShown = (appState, pluginState = {}) =>
|
|
50
|
+
!atTarget().hiddenWhen({ appState, pluginState: { enabled: true, interactionModes: ['selectFeature'], ...pluginState } })
|
|
51
|
+
|
|
52
|
+
it.each([
|
|
53
|
+
['touch', true],
|
|
54
|
+
['mouse', false],
|
|
55
|
+
['keyboard', false]
|
|
56
|
+
])('%s with map controls closed: shown %s', (interfaceType, expected) => {
|
|
57
|
+
expect(isShown({ interfaceType, expandedButtons: new Set() })).toBe(expected)
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
it.each(['touch', 'mouse', 'keyboard'])('%s with map controls open: shown', (interfaceType) => {
|
|
61
|
+
expect(isShown({ interfaceType, expandedButtons: mapControlsOpen })).toBe(true)
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
it('touchTarget: false hides it on touch until the map controls are opened', () => {
|
|
65
|
+
expect(isShown({ interfaceType: 'touch' }, { touchTarget: false })).toBe(false)
|
|
66
|
+
expect(isShown({ interfaceType: 'touch', expandedButtons: mapControlsOpen }, { touchTarget: false })).toBe(true)
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
it('hidden while the listbox has focus, even with map controls open', () => {
|
|
70
|
+
expect(isShown({ interfaceType: 'touch' }, { listboxFocused: true })).toBe(false)
|
|
71
|
+
expect(isShown({ interfaceType: 'mouse', expandedButtons: mapControlsOpen }, { listboxFocused: true })).toBe(false)
|
|
72
|
+
})
|
|
73
|
+
})
|
|
74
|
+
|
|
46
75
|
it('keyboardShortcuts array exists', () => {
|
|
47
76
|
expect(Array.isArray(manifest.keyboardShortcuts)).toBe(true)
|
|
48
77
|
})
|
|
@@ -5,10 +5,12 @@ const initialState = {
|
|
|
5
5
|
interactionModes: null,
|
|
6
6
|
multiSelect: false,
|
|
7
7
|
deselectOnClickOutside: false,
|
|
8
|
+
touchTarget: true,
|
|
8
9
|
selectedFeatures: [],
|
|
9
10
|
selectedMarkers: [],
|
|
10
11
|
closeOnAction: true, // Done or Cancel
|
|
11
|
-
listboxActiveItem: null // { featureId, layerId, idProperty, geometry } | null — ring shown but no selectionchange
|
|
12
|
+
listboxActiveItem: null, // { featureId, layerId, idProperty, geometry } | null — ring shown but no selectionchange
|
|
13
|
+
listboxFocused: false
|
|
12
14
|
}
|
|
13
15
|
|
|
14
16
|
const enable = (state, payload) => {
|
|
@@ -95,6 +97,8 @@ const clearSelectedFeatures = (state) => {
|
|
|
95
97
|
|
|
96
98
|
const setListboxActive = (state, payload) => ({ ...state, listboxActiveItem: payload ?? null })
|
|
97
99
|
|
|
100
|
+
const setListboxFocused = (state, payload) => ({ ...state, listboxFocused: !!payload })
|
|
101
|
+
|
|
98
102
|
/**
|
|
99
103
|
* Explicitly select a marker. Has no effect if already selected.
|
|
100
104
|
* In single-select mode, clears selectedFeatures and replaces the selection.
|
|
@@ -141,7 +145,8 @@ const actions = {
|
|
|
141
145
|
SET_SELECTED_FEATURES: setSelectedFeatures,
|
|
142
146
|
SELECT_MARKER: selectMarker,
|
|
143
147
|
UNSELECT_MARKER: unselectMarker,
|
|
144
|
-
SET_LISTBOX_ACTIVE: setListboxActive
|
|
148
|
+
SET_LISTBOX_ACTIVE: setListboxActive,
|
|
149
|
+
SET_LISTBOX_FOCUSED: setListboxFocused
|
|
145
150
|
}
|
|
146
151
|
|
|
147
152
|
export {
|
|
@@ -9,10 +9,12 @@ describe('initialState', () => {
|
|
|
9
9
|
interactionModes: null,
|
|
10
10
|
multiSelect: false,
|
|
11
11
|
deselectOnClickOutside: false,
|
|
12
|
+
touchTarget: true,
|
|
12
13
|
selectedFeatures: [],
|
|
13
14
|
selectedMarkers: [],
|
|
14
15
|
closeOnAction: true,
|
|
15
|
-
listboxActiveItem: null
|
|
16
|
+
listboxActiveItem: null,
|
|
17
|
+
listboxFocused: false
|
|
16
18
|
})
|
|
17
19
|
})
|
|
18
20
|
})
|
|
@@ -179,6 +181,13 @@ describe('SET_LISTBOX_ACTIVE action', () => {
|
|
|
179
181
|
})
|
|
180
182
|
})
|
|
181
183
|
|
|
184
|
+
describe('SET_LISTBOX_FOCUSED action', () => {
|
|
185
|
+
it('sets listboxFocused from the payload', () => {
|
|
186
|
+
expect(actions.SET_LISTBOX_FOCUSED(initialState, true).listboxFocused).toBe(true)
|
|
187
|
+
expect(actions.SET_LISTBOX_FOCUSED({ ...initialState, listboxFocused: true }, false).listboxFocused).toBe(false)
|
|
188
|
+
})
|
|
189
|
+
})
|
|
190
|
+
|
|
182
191
|
describe('SELECT_MARKER action', () => {
|
|
183
192
|
it('adds a marker in single-select mode, clearing selectedFeatures', () => {
|
|
184
193
|
const state = { ...initialState, selectedFeatures: [{ featureId: 'f1' }], selectedMarkers: [] }
|
|
@@ -239,7 +248,8 @@ describe('actions object', () => {
|
|
|
239
248
|
'SET_SELECTED_FEATURES',
|
|
240
249
|
'SELECT_MARKER',
|
|
241
250
|
'UNSELECT_MARKER',
|
|
242
|
-
'SET_LISTBOX_ACTIVE'
|
|
251
|
+
'SET_LISTBOX_ACTIVE',
|
|
252
|
+
'SET_LISTBOX_FOCUSED'
|
|
243
253
|
])
|
|
244
254
|
Object.values(actions).forEach(fn => expect(typeof fn).toBe('function'))
|
|
245
255
|
})
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { isSelectMarkerOnly } from './interactionModes.js'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Returns true when the user needs the crosshair and Select button to choose a point on the map.
|
|
5
|
+
*
|
|
6
|
+
* Shared by the crosshair (useCrossHairVisibility) and the Select button (manifest hiddenWhen)
|
|
7
|
+
* so the two can't drift apart. The crosshair adds focus-based rules on top: it also shows
|
|
8
|
+
* while keyboard focus is in the map, and hides while the listbox has focus.
|
|
9
|
+
*
|
|
10
|
+
* - Map controls open: an explicit "I can't drag/pinch this map" signal from the user, so it
|
|
11
|
+
* counts for every interface type (a Voice Control user never registers as anything but 'mouse').
|
|
12
|
+
* - Touch: unless turned off with `touchTarget: false`, or selectMarker is the only mode
|
|
13
|
+
* (markers are big enough to tap).
|
|
14
|
+
*
|
|
15
|
+
* @param {{ appState: Object, pluginState: Object }} context
|
|
16
|
+
* @returns {boolean}
|
|
17
|
+
*/
|
|
18
|
+
export const needsTarget = ({ appState, pluginState }) =>
|
|
19
|
+
!!appState.expandedButtons?.has('mapControls') ||
|
|
20
|
+
(appState.interfaceType === 'touch' && pluginState.touchTarget !== false && !isSelectMarkerOnly(pluginState.interactionModes))
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { needsTarget } from './needsTarget.js'
|
|
2
|
+
|
|
3
|
+
const mapControlsOpen = new Set(['mapControls'])
|
|
4
|
+
const closed = new Set()
|
|
5
|
+
|
|
6
|
+
const check = (appState, pluginState = {}) =>
|
|
7
|
+
needsTarget({ appState, pluginState: { interactionModes: ['selectFeature'], ...pluginState } })
|
|
8
|
+
|
|
9
|
+
describe('needsTarget', () => {
|
|
10
|
+
it.each([
|
|
11
|
+
['touch', closed, true],
|
|
12
|
+
['mouse', closed, false],
|
|
13
|
+
['keyboard', closed, false],
|
|
14
|
+
['touch', mapControlsOpen, true],
|
|
15
|
+
['mouse', mapControlsOpen, true],
|
|
16
|
+
['keyboard', mapControlsOpen, true]
|
|
17
|
+
])('%s, map controls %p: %s', (interfaceType, expandedButtons, expected) => {
|
|
18
|
+
expect(check({ interfaceType, expandedButtons })).toBe(expected)
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
it('is false on touch when touchTarget is false', () => {
|
|
22
|
+
expect(check({ interfaceType: 'touch', expandedButtons: closed }, { touchTarget: false })).toBe(false)
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
it('is true with touchTarget false once the map controls are open', () => {
|
|
26
|
+
expect(check({ interfaceType: 'touch', expandedButtons: mapControlsOpen }, { touchTarget: false })).toBe(true)
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
it('is false on touch when selectMarker is the only mode', () => {
|
|
30
|
+
expect(check({ interfaceType: 'touch' }, { interactionModes: ['selectMarker'] })).toBe(false)
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
it('treats a missing expandedButtons as map controls closed', () => {
|
|
34
|
+
expect(check({ interfaceType: 'mouse' })).toBe(false)
|
|
35
|
+
})
|
|
36
|
+
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useId as e,useState as t,useLayoutEffect as r,useRef as n,useEffect as i}from"preact/compat";import{jsx as o,jsxs as a}from"preact/jsx-runtime";import l from"@babel/runtime/helpers/defineProperty";var s=null,c=e=>s=e;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 y(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){l(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}var u={},m=null,f=[],b=()=>{var e;if(null===(e=u)||void 0===e||!e.current)return[];if(m===u.current)return f;m=u.current;var{groups:t=[],keyDefinitions:r=[]}=u.current;return f=t.map(e=>"flat"===e.type?y(y({},e),{},{keyDefinition:r.find(t=>t.id===e.id)}):y(y({},e),{},{keyDefinitions:r.filter(t=>t.groupId===e.id)}))},g=e=>{var{text:t}=e;return o("div",{className:"im-c-map-key",children:o("p",{className:"im-c-map-key__empty-message",children:t})})},d=(e,t)=>{if(!e)return null;if("string"==typeof e)return e.trim();if("object"==typeof e){if(t&&e[t])return e[t];var r=Object.values(e)[0];return null!=r?r:null}return null};function O(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 h(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?O(Object(r),!0).forEach(function(t){l(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):O(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var v=20,k=44,j={xmlns:"http://www.w3.org/2000/svg",width:v,height:v,viewBox:"0 0 ".concat(v," ").concat(v),className:"im-c-map-key-symbol","aria-hidden":"true",focusable:"false"},S=h(h({},j),{},{width:k,height:k,viewBox:"0 0 ".concat(k," ").concat(k),className:"im-c-map-key-symbol im-c-map-key-symbol--point"});function w(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 P(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?w(Object(r),!0).forEach(function(t){l(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):w(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var D=e=>{var{keyDefinition:t,mapStyle:r,patternRegistry:n}=e,{style:i}=t,l=n.getKeyPatternPaths(i,r.id);return l?a("svg",P(P({},j),{},{children:[o("g",{dangerouslySetInnerHTML:{__html:l.border}}),o("g",{transform:"translate(".concat(2,", ").concat(2,")"),dangerouslySetInnerHTML:{__html:l.content}})]})):null};function R(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 _(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?R(Object(r),!0).forEach(function(t){l(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):R(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var E=e=>{var{keySymbol:t}=e,{svg:r,viewBox:n}=null!=t?t:{};if(!r||!n)return null;var[,,i,a]=n.split(" ").map(Number),l=Math.min(1,56/Math.max(i,a)),s=i*l,c=a*l;return o("svg",_(_({},S),{},{overflow:"visible",children:o("svg",{x:.5*(k-s),y:.5*(k-c),width:s,height:c,viewBox:n,overflow:"hidden",children:o("g",{dangerouslySetInnerHTML:{__html:r}})})}))};function x(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 M(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?x(Object(r),!0).forEach(function(t){l(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):x(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var I=e=>{var{mapStyle:t,keyDefinition:r}=e,{style:n}=r,i=n.strokeWidth,a=d(n.stroke,t.id);return o("svg",M(M({},j),{},{children:o("line",{x1:i/2,y1:10,x2:v-i/2,y2:10,stroke:a,strokeWidth:i,strokeLinecap:"round"})}))};function L(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 K(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?L(Object(r),!0).forEach(function(t){l(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):L(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var N,B=e=>{var{mapStyle:t,keyDefinition:r}=e,{style:n}=r,i=n.strokeWidth,a=d(n.fill,t.id),l=d(n.stroke,t.id);return o("svg",K(K({},j),{},{children:o("rect",{x:i/2,y:i/2,width:v-i,height:v-i,rx:i,ry:i,fill:a,stroke:l,strokeWidth:i,strokeLinejoin:"round"})}))},C=t=>{var{mapStyle:r,keyDefinition:n,patternRegistry:i}=t,{style:l,hasPattern:s}=n,c="im-c-map-key-ramp-"+e().replace(/[^\w-]/g,""),p=s?i.getKeyPatternPaths(l,r.id):null,y=d(l.stroke,r.id),u=p?"url(#".concat(c,")"):d(l.fill,r.id);return a("svg",{xmlns:"http://www.w3.org/2000/svg",className:"im-c-map-key-symbol","aria-hidden":"true",focusable:"false",children:[p&&o("defs",{children:o("pattern",{id:c,patternUnits:"userSpaceOnUse",x:2,y:2,width:16,height:16,dangerouslySetInnerHTML:{__html:p.content}})}),o("rect",{width:"100%",height:"100%",fill:u||"none",stroke:y,strokeWidth:y?4:void 0})]})},Y="ramp",G=e=>{var{keyDefinition:t,groupStyle:r,mapStyle:n,symbolRegistry:i,patternRegistry:a}=e,{symbolShape:l,keySymbol:s}=((e,t,r,n)=>{if(!e)return{symbolShape:null,keySymbol:null};var{hasSymbol:i,hasPattern:o,style:a}=e;if(t===Y)return{symbolShape:Y,keySymbol:null};if(i){var l=n.getKeySymbol(a,r);return{symbolShape:l?"symbol":"rect",keySymbol:l}}return o?{symbolShape:"pattern",keySymbol:null}:null==a.fill&&a.stroke?{symbolShape:"line",keySymbol:null}:{symbolShape:"rect",keySymbol:null}})(t,r,n,i);return l?"symbol"===l?o(E,{keySymbol:s}):"pattern"===l?o(D,{mapStyle:n,keyDefinition:t,patternRegistry:a}):"line"===l?o(I,{mapStyle:n,keyDefinition:t}):l===Y?o(C,{mapStyle:n,keyDefinition:t,patternRegistry:a}):o(B,{mapStyle:n,keyDefinition:t}):null},T=e=>{var{keyDefinition:t,groupStyle:r,mapStyle:n,symbolRegistry:i,patternRegistry:l}=e,s=t.label,c=d(t.symbolDescription,n.id);return a("div",{className:"im-c-map-key-list__item",children:[o("dt",{className:"im-c-map-key-list__item-symbol",children:o(G,{keyDefinition:t,groupStyle:r,mapStyle:n,symbolRegistry:i,patternRegistry:l})}),a("dd",{className:"im-c-map-key-list__item-label",children:[s,c&&a("span",{className:"govuk-visually-hidden",children:["(",c,")"]})]})]})},W=(e,t)=>{var r,n=e.querySelector(".im-c-map-key-list__item-label"),i=(void 0===N&&(N=null!==(r=document.createElement("canvas").getContext("2d"))&&void 0!==r?r:null),N);if(!n||!i||!e.clientWidth)return null;var{fontStyle:o,fontWeight:a,fontSize:l,fontFamily:s}=getComputedStyle(n);i.font="".concat(o," ").concat(a," ").concat(l," ").concat(s);var c=getComputedStyle(e),p=Number.parseFloat(c.columnGap)||0,y=(Number.parseFloat(c.paddingLeft)||0)+(Number.parseFloat(c.paddingRight)||0),u=(e.clientWidth-y-p*(t.length-1))/t.length;return t.every(e=>i.measureText(e).width<=u)},z=e=>{var{headingId:i,label:l,groupStyle:s,keyDefinitions:c,mapStyle:p,symbolRegistry:y,patternRegistry:u}=e,m=n(null),f=((e,t)=>e===Y&&t.some(e=>{return!!(null!=(t=e.style)&&t.symbol||null!=t&&t.symbolSvgContent);var t})?void 0:e)(s,c),b=f===Y,g=b&&c.some(e=>{var t;return d(null===(t=e.style)||void 0===t?void 0:t.stroke,p.id)}),O=((e,n,i,o)=>{var[a,l]=t(!0),s=n.join("\n");return r(()=>{var t,r=e.current;if(i&&r){var o=!0,a=()=>{var e=o?W(r,n):null;null!==e&&l(e)};a();var s="function"==typeof ResizeObserver?new ResizeObserver(a):null;return null==s||s.observe(r),null===(t=document.fonts)||void 0===t||t.ready.then(a,()=>{}),()=>{o=!1,null==s||s.disconnect()}}},[i,o,s]),a?"horizontal":"vertical"})(m,c.map(e=>{var t;return null!==(t=e.label)&&void 0!==t?t:""}),b,g),h=((e,t,r)=>{if(!e)return"im-c-map-key-list";var n="im-c-map-key-list im-c-map-key-list--".concat(e);if(e!==Y)return n;var i="".concat(n," im-c-map-key-list--ramp-").concat(t);return r?"".concat(i," im-c-map-key-list--has-stroke"):i})(f,O,g);return a("section",{className:"im-c-map-key__group","aria-labelledby":i,children:[o("h3",{id:i,className:"im-c-map-key__group-heading",children:l}),o("dl",{ref:m,className:h,children:c.map(e=>o(T,{keyDefinition:e,mapStyle:p,symbolRegistry:y,patternRegistry:u,groupStyle:f},"".concat(e.id)))})]})},A="im-c-map-key",F=e=>{var{item:t,groupStyle:r,mapStyle:n,symbolRegistry:i,patternRegistry:a}=e;return"group"===t.type?o(z,{headingId:"key-heading-".concat(t.id),label:t.groupLabel,groupStyle:r,keyDefinitions:t.keyDefinitions,mapStyle:n,symbolRegistry:i,patternRegistry:a}):o(T,{keyDefinition:t.keyDefinition,mapStyle:n,symbolRegistry:i,patternRegistry:a})},H=e=>{var{noKeyItemText:t,keyGroups:r,hasGroups:n,mapStyle:i,symbolRegistry:a,patternRegistry:l}=e;if(null==r||!r.length)return o(g,{text:t});var s=n?"".concat(A," ").concat("im-c-map-key--has-groups"):A;return o("div",{className:s,children:r.map(e=>o(F,{item:e,mapStyle:i,symbolRegistry:a,patternRegistry:l,groupStyle:e.groupStyle},e.id))})};function U(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 q(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?U(Object(r),!0).forEach(function(t){l(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):U(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function V(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 J(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?V(Object(r),!0).forEach(function(t){l(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):V(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var Q={InitComponent:function(e){var{pluginConfig:t,pluginState:r,mapState:o,services:a}=e,{dispatch:l}=r,{eventBus:s}=a,p=n(r);p.current=r,i(()=>{o.isMapReady&&((e=>{u=e})(p),s.requestOnce("datasets:registry",c),s.emit("map-key:ready"))},[o.isMapReady]),i(()=>{if(t.groups){var e=Object.entries(t.groups).map(e=>{var[t,r]=e;return q(q({},r),{},{id:t,label:r.groupLabel})});l({type:"ADD_KEY_GROUPS",payload:e})}},[t.groups])},reducer:{initialState:{keyDefinitions:[],groups:[]},actions:{ADD_KEY_SYMBOL:(e,t)=>{var r,{id:n,groupLabel:i}=t,o=t.groupId||((r=i)?r.toLowerCase().replace(/\s+/g,"-"):null),a=((e,t,r)=>e.groups.find(e=>"group"===e.type&&e.id===r||"flat"===e.type&&e.id===t))(e,n,o),l=a?null:((e,t,r)=>t?{id:t,type:"group",groupLabel:r}:{id:e,type:"flat"})(n,o,i),s=l?[...e.groups,l]:e.groups,c=[...e.keyDefinitions,J(J({},t),{},{type:"manual"},o?{groupId:o}:{})];return J(J({},e),{},{keyDefinitions:c,groups:s})},REMOVE_KEY_SYMBOL:(e,t)=>{var{id:r}=t;return J(J({},e),{},{keyDefinitions:e.keyDefinitions.filter(e=>e.id!==r)})},ADD_KEY_GROUPS:(e,t)=>J(J({},e),{},{groups:[...e.groups,...t]})}},panels:[{id:"mapKey",label:"Key",mobile:{slot:"drawer",modal:!0},tablet:{slot:"left-top",width:"260px"},desktop:{slot:"left-top",width:"280px"},render:function(e){var{mapState:{mapStyle:r},pluginConfig:{noKeyItemText:n},pluginState:a,services:{eventBus:l,symbolRegistry:c,patternRegistry:p}}=e,[u,m]=t(s),[f,g]=t(()=>{var e;return null!==(e=null==u?void 0:u.keyItems().items)&&void 0!==e?e:[]}),[d,O]=t(()=>{var e;return null!==(e=null==u?void 0:u.keyItems().hasGroups)&&void 0!==e&&e}),h=()=>{var{items:e,hasGroups:t}=u.keyItems(),r=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=[...b()];return 0===t.length?e:[...e.map(e=>{var r=t.findIndex(t=>t.id===e.id);if(-1===r)return e;var n=t.splice(r,1)[0];return y(y(y({},e),n),{},{keyDefinitions:[...n.keyDefinitions||[],...e.keyDefinitions||[]]})}),...t].filter(e=>{var t;return"flat"===e.type&&e.keyDefinition||"group"===e.type&&(null===(t=e.keyDefinitions)||void 0===t?void 0:t.length)})}(e);g(r),O(t)},v=e=>{u.invalidateKeyItemsOnMenuStateChange(e),h()};return i(()=>u?(h(),l.on("menu:changed",v).on("datasets:changed",h),()=>l.off("menu:changed",v).off("datasets:changed",h)):(l.requestOnce("datasets:registry",m),()=>{}),[u]),i(()=>{u&&h()},[a]),o(H,{noKeyItemText:n,keyGroups:f,hasGroups:d,mapStyle:r,symbolRegistry:c,patternRegistry:p})}}],buttons:[{id:"mapKey",panelId:"mapKey",label:"Key",iconId:"key",mobile:{slot:"top-left",showLabel:!0},tablet:{slot:"top-left",showLabel:!0},desktop:{slot:"top-left",showLabel:!0}}],icons:[{id:"key",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"/>'}],api:{addSymbol:(e,t)=>{var{pluginState:{dispatch:r}}=e;r({type:"ADD_KEY_SYMBOL",payload:t})},removeSymbol:(e,t)=>{var{pluginState:{dispatch:r}}=e;r({type:"REMOVE_KEY_SYMBOL",payload:t})}}};export{Q as manifest};
|
|
1
|
+
import{useId as e,useState as t,useLayoutEffect as i,useRef as n,useEffect as r}from"preact/compat";import{jsx as s,jsxs as l}from"preact/jsx-runtime";const o=({text:e})=>s("div",{className:"im-c-map-key",children:s("p",{className:"im-c-map-key__empty-message",children:e})}),a=(e,t)=>{if(!e)return null;if("string"==typeof e)return e.trim();if("object"==typeof e){if(t&&e[t])return e[t];return Object.values(e)[0]??null}return null},y=20,p=44,m={xmlns:"http://www.w3.org/2000/svg",width:y,height:y,viewBox:"0 0 20 20",className:"im-c-map-key-symbol","aria-hidden":"true",focusable:"false"},d={...m,width:p,height:p,viewBox:"0 0 44 44",className:"im-c-map-key-symbol im-c-map-key-symbol--point"},u=({keyDefinition:e,mapStyle:t,patternRegistry:i})=>{const{style:n}=e,r=i.getKeyPatternPaths(n,t.id);return r?l("svg",{...m,children:[s("g",{dangerouslySetInnerHTML:{__html:r.border}}),s("g",{transform:"translate(2, 2)",dangerouslySetInnerHTML:{__html:r.content}})]}):null},c=({keySymbol:e})=>{const{svg:t,viewBox:i}=e??{};if(!t||!i)return null;const[,,n,r]=i.split(" ").map(Number),l=Math.min(1,56/Math.max(n,r)),o=n*l,a=r*l;return s("svg",{...d,overflow:"visible",children:s("svg",{"aria-hidden":"true",x:.5*(p-o),y:.5*(p-a),width:o,height:a,viewBox:i,overflow:"hidden",children:s("g",{dangerouslySetInnerHTML:{__html:t}})})})},g=({mapStyle:e,keyDefinition:t})=>{const{style:i}=t,n=i.strokeWidth,r=a(i.stroke,e.id);return s("svg",{...m,children:s("line",{x1:n/2,y1:10,x2:y-n/2,y2:10,stroke:r,strokeWidth:n,strokeLinecap:"round"})})},h=({mapStyle:e,keyDefinition:t})=>{const{style:i}=t,n=i.strokeWidth,r=a(i.fill,e.id),l=a(i.stroke,e.id);return s("svg",{...m,children:s("rect",{x:n/2,y:n/2,width:y-n,height:y-n,rx:n,ry:n,fill:r,stroke:l,strokeWidth:n,strokeLinejoin:"round"})})},f=({mapStyle:t,keyDefinition:i,patternRegistry:n})=>{const{style:r,hasPattern:o}=i,y="im-c-map-key-ramp-"+e().replace(/[^\w-]/g,""),p=o?n.getKeyPatternPaths(r,t.id):null,m=a(r.stroke,t.id),d=p?`url(#${y})`:a(r.fill,t.id);return l("svg",{xmlns:"http://www.w3.org/2000/svg",className:"im-c-map-key-symbol","aria-hidden":"true",focusable:"false",children:[p&&s("defs",{children:s("pattern",{id:y,patternUnits:"userSpaceOnUse",x:2,y:2,width:16,height:16,dangerouslySetInnerHTML:{__html:p.content}})}),s("rect",{width:"100%",height:"100%",fill:d||"none",stroke:m,strokeWidth:m?4:void 0})]})},k="ramp",S=({keyDefinition:e,groupStyle:t,mapStyle:i,symbolRegistry:n,patternRegistry:r})=>{const{symbolShape:l,keySymbol:o}=((e,t,i,n)=>{if(!e)return{symbolShape:null,keySymbol:null};const{hasSymbol:r,hasPattern:s,style:l}=e;if(t===k)return{symbolShape:k,keySymbol:null};if(r){const e=n.getKeySymbol(l,i);return{symbolShape:e?"symbol":"rect",keySymbol:e}}return s?{symbolShape:"pattern",keySymbol:null}:null==l.fill&&l.stroke?{symbolShape:"line",keySymbol:null}:{symbolShape:"rect",keySymbol:null}})(e,t,i,n);return l?"symbol"===l?s(c,{keySymbol:o}):"pattern"===l?s(u,{mapStyle:i,keyDefinition:e,patternRegistry:r}):"line"===l?s(g,{mapStyle:i,keyDefinition:e}):l===k?s(f,{mapStyle:i,keyDefinition:e,patternRegistry:r}):s(h,{mapStyle:i,keyDefinition:e}):null},b=({keyDefinition:e,groupStyle:t,mapStyle:i,symbolRegistry:n,patternRegistry:r})=>{const o=e.label,y=a(e.symbolDescription,i.id);return l("div",{className:"im-c-map-key-list__item",children:[s("dt",{className:"im-c-map-key-list__item-symbol",children:s(S,{keyDefinition:e,groupStyle:t,mapStyle:i,symbolRegistry:n,patternRegistry:r})}),l("dd",{className:"im-c-map-key-list__item-label",children:[o,y&&l("span",{className:"govuk-visually-hidden",children:["(",y,")"]})]})]})};let R;const v=(e,t)=>{const i=e.querySelector(".im-c-map-key-list__item-label"),n=(void 0===R&&(R=document.createElement("canvas").getContext("2d")??null),R);if(!i||!n||!e.clientWidth)return null;const{fontStyle:r,fontWeight:s,fontSize:l,fontFamily:o}=getComputedStyle(i);n.font=`${r} ${s} ${l} ${o}`;const a=getComputedStyle(e),y=Number.parseFloat(a.columnGap)||0,p=(Number.parseFloat(a.paddingLeft)||0)+(Number.parseFloat(a.paddingRight)||0),m=(e.clientWidth-p-y*(t.length-1))/t.length;return t.every(e=>n.measureText(e).width<=m)},D=({headingId:e,label:r,groupStyle:o,keyDefinitions:y,mapStyle:p,symbolRegistry:m,patternRegistry:d})=>{const u=n(null),c=((e,t)=>e===k&&t.some(e=>{return t=e.style,!(!t?.symbol&&!t?.symbolSvgContent);var t})?void 0:e)(o,y),g=c===k,h=g&&y.some(e=>a(e.style?.stroke,p.id)),f=((e,n,r,s)=>{const[l,o]=t(!0),a=n.join("\n");return i(()=>{const t=e.current;if(!r||!t)return;let i=!0;const s=()=>{const e=i?v(t,n):null;null!==e&&o(e)};s();const l="function"==typeof ResizeObserver?new ResizeObserver(s):null;return l?.observe(t),document.fonts?.ready.then(s,()=>{}),()=>{i=!1,l?.disconnect()}},[r,s,a]),l?"horizontal":"vertical"})(u,y.map(e=>e.label??""),g,h),S=((e,t,i)=>{if(!e)return"im-c-map-key-list";const n=`im-c-map-key-list im-c-map-key-list--${e}`;if(e!==k)return n;const r=`${n} im-c-map-key-list--ramp-${t}`;return i?`${r} im-c-map-key-list--has-stroke`:r})(c,f,h);return l("section",{className:"im-c-map-key__group","aria-labelledby":e,children:[s("h3",{id:e,className:"im-c-map-key__group-heading",children:r}),s("dl",{ref:u,className:S,children:y.map(e=>s(b,{keyDefinition:e,mapStyle:p,symbolRegistry:m,patternRegistry:d,groupStyle:c},`${e.id}`))})]})},_="im-c-map-key",w=({item:e,groupStyle:t,mapStyle:i,symbolRegistry:n,patternRegistry:r})=>"group"===e.type?s(D,{headingId:`key-heading-${e.id}`,label:e.groupLabel,groupStyle:t,keyDefinitions:e.keyDefinitions,mapStyle:i,symbolRegistry:n,patternRegistry:r}):s(b,{keyDefinition:e.keyDefinition,mapStyle:i,symbolRegistry:n,patternRegistry:r}),x=({noKeyItemText:e,keyGroups:t,hasGroups:i,mapStyle:n,symbolRegistry:r,patternRegistry:l})=>{if(!t?.length)return s(o,{text:e});return s("div",{className:i?`${_} im-c-map-key--has-groups`:_,children:t.map(e=>s(w,{item:e,mapStyle:n,symbolRegistry:r,patternRegistry:l,groupStyle:e.groupStyle},e.id))})};const I={InitComponent:function({pluginConfig:e,pluginState:t,mapState:i,services:n}){const{dispatch:s}=t,{eventBus:l}=n;r(()=>{i.isMapReady&&(l.requestOnce("datasets:registry",e=>{s({type:"SET_DATASET_REGISTRY",payload:e})}),l.emit("map-key:ready"))},[i.isMapReady]),r(()=>{if(!e.groups)return;const t=Object.entries(e.groups).map(([e,t])=>({...t,id:e,label:t.groupLabel}));s({type:"ADD_KEY_GROUPS",payload:t})},[e.groups])},reducer:{initialState:{keyDefinitions:[],groups:[],datasetRegistry:null},actions:{SET_DATASET_REGISTRY:(e,t)=>({...e,datasetRegistry:t}),ADD_KEY_SYMBOL:(e,t)=>{const{id:i,groupLabel:n}=t,r=t.groupId||((s=n)?s.toLowerCase().replace(/\s+/g,"-"):null);var s;const l=((e,t,i)=>e.groups.find(e=>"group"===e.type&&e.id===i||"flat"===e.type&&e.id===t))(e,i,r),o=l?null:((e,t,i)=>t?{id:t,type:"group",groupLabel:i}:{id:e,type:"flat"})(i,r,n),a=o?[...e.groups,o]:e.groups,y=[...e.keyDefinitions,{...t,type:"manual",...r?{groupId:r}:{}}];return{...e,keyDefinitions:y,groups:a}},REMOVE_KEY_SYMBOL:(e,t)=>{const{id:i}=t;return{...e,keyDefinitions:e.keyDefinitions.filter(e=>e.id!==i)}},ADD_KEY_GROUPS:(e,t)=>({...e,groups:[...e.groups,...t]})}},panels:[{id:"mapKey",label:"Key",mobile:{slot:"drawer",modal:!0},tablet:{slot:"left-top",width:"260px"},desktop:{slot:"left-top",width:"280px"},render:function({mapState:{mapStyle:e},pluginConfig:{noKeyItemText:i},pluginState:l,services:{eventBus:o,symbolRegistry:a,patternRegistry:y}}){const{datasetRegistry:p}=l,m=n(l);m.current=l;const[d,u]=t(()=>p?.keyItems().items??[]),[c,g]=t(()=>p?.keyItems().hasGroups??!1),h=()=>{const{items:e,hasGroups:t}=p.keyItems(),i=((e=[],t={})=>{const i=(({groups:e=[],keyDefinitions:t=[]})=>e.map(e=>"flat"===e.type?{...e,keyDefinition:t.find(t=>t.id===e.id)}:{...e,keyDefinitions:t.filter(t=>t.groupId===e.id)}))(t);return 0===i.length?e:[...e.map(e=>{const t=i.findIndex(t=>t.id===e.id);if(-1===t)return e;const n=i.splice(t,1)[0];return{...e,...n,keyDefinitions:[...n.keyDefinitions||[],...e.keyDefinitions||[]]}}),...i].filter(e=>"flat"===e.type&&e.keyDefinition||"group"===e.type&&e.keyDefinitions?.length)})(e,m.current);u(i),g(t)},f=e=>{p.invalidateKeyItemsOnMenuStateChange(e),h()};return r(()=>{if(p)return h(),o.on("menu:changed",f).on("datasets:changed",h),()=>o.off("menu:changed",f).off("datasets:changed",h)},[p]),r(()=>{p&&h()},[l]),s(x,{noKeyItemText:i,keyGroups:d,hasGroups:c,mapStyle:e,symbolRegistry:a,patternRegistry:y})}}],buttons:[{id:"mapKey",panelId:"mapKey",label:"Key",iconId:"key",mobile:{slot:"top-left",showLabel:!0},tablet:{slot:"top-left",showLabel:!0},desktop:{slot:"top-left",showLabel:!0}}],icons:[{id:"key",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"/>'}],api:{addSymbol:({pluginState:{dispatch:e}},t)=>{e({type:"ADD_KEY_SYMBOL",payload:t})},removeSymbol:({pluginState:{dispatch:e}},t)=>{e({type:"REMOVE_KEY_SYMBOL",payload:t})}}};export{I as manifest};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"@babel/runtime/helpers/
|
|
1
|
+
import e from"@babel/runtime/helpers/regenerator";import r from"@babel/runtime/helpers/asyncToGenerator";import t from"@babel/runtime/helpers/objectSpread2";function n(){var n;return t(t({noKeyItemText:"No features displayed"},arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),{},{id:"mapKey",load:(n=r(e().m(function r(){var t;return e().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,import(/* webpackChunkName: "im-map-key-plugin" */ "./im-map-key-plugin.js");case 1:return t=e.v.manifest,e.a(2,t)}},r)})),function(){return n.apply(this,arguments)})})}export{n as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(this.webpackChunkdefra_DefraMap=this.webpackChunkdefra_DefraMap||[]).push([[414],{718(t,e,r){r.r(e),r.d(e,{manifest:()=>gt});var n=r(738),o=null,i=function(t){return o=t};function u(t){return u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(t)}function l(t){return function(t){if(Array.isArray(t))return a(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return a(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?a(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function a(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function c(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function y(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?c(Object(r),!0).forEach(function(e){f(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):c(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function f(t,e,r){return(e=function(t){var e=function(t){if("object"!=u(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=u(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==u(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var s={},p=null,m=[],b=r(287),d=function(t){var e=t.text;return(0,b.jsx)("div",{className:"im-c-map-key",children:(0,b.jsx)("p",{className:"im-c-map-key__empty-message",children:e})})};function v(t){return v="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},v(t)}var g=function(t,e){if(!t)return null;if("string"==typeof t)return t.trim();if("object"===v(t)){if(e&&t[e])return t[e];var r=Object.values(t)[0];return null!=r?r:null}return null};function h(t){return h="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},h(t)}function S(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function O(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?S(Object(r),!0).forEach(function(e){j(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):S(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function j(t,e,r){return(e=function(t){var e=function(t){if("object"!=h(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=h(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==h(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var w=20,k=44,P={xmlns:"http://www.w3.org/2000/svg",width:w,height:w,viewBox:"0 0 ".concat(w," ").concat(w),className:"im-c-map-key-symbol","aria-hidden":"true",focusable:"false"},D=O(O({},P),{},{width:k,height:k,viewBox:"0 0 ".concat(k," ").concat(k),className:"im-c-map-key-symbol im-c-map-key-symbol--point"});function x(t){return x="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},x(t)}function E(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function A(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?E(Object(r),!0).forEach(function(e){I(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):E(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function I(t,e,r){return(e=function(t){var e=function(t){if("object"!=x(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=x(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==x(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var R=function(t){var e=t.keyDefinition,r=t.mapStyle,n=t.patternRegistry,o=e.style,i=n.getKeyPatternPaths(o,r.id);return i?(0,b.jsxs)("svg",A(A({},P),{},{children:[(0,b.jsx)("g",{dangerouslySetInnerHTML:{__html:i.border}}),(0,b.jsx)("g",{transform:"translate(".concat(2,", ").concat(2,")"),dangerouslySetInnerHTML:{__html:i.content}})]})):null};function _(t){return _="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_(t)}function M(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function T(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?M(Object(r),!0).forEach(function(e){C(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):M(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function C(t,e,r){return(e=function(t){var e=function(t){if("object"!=_(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=_(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==_(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function L(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var K=function(t){var e=t.keySymbol,r=null!=e?e:{},n=r.svg,o=r.viewBox;if(!n||!o)return null;var i,u,l=(i=o.split(" ").map(Number),u=4,function(t){if(Array.isArray(t))return t}(i)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,u,l=[],a=!0,c=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;a=!1}else for(;!(a=(n=i.call(r)).done)&&(l.push(n.value),l.length!==e);a=!0);}catch(t){c=!0,o=t}finally{try{if(!a&&null!=r.return&&(u=r.return(),Object(u)!==u))return}finally{if(c)throw o}}return l}}(i,u)||function(t,e){if(t){if("string"==typeof t)return L(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?L(t,e):void 0}}(i,u)||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.")}()),a=l[2],c=l[3],y=Math.min(1,56/Math.max(a,c)),f=a*y,s=c*y;return(0,b.jsx)("svg",T(T({},D),{},{overflow:"visible",children:(0,b.jsx)("svg",{x:.5*(k-f),y:.5*(k-s),width:f,height:s,viewBox:o,overflow:"hidden",children:(0,b.jsx)("g",{dangerouslySetInnerHTML:{__html:n}})})}))};function N(t){return N="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},N(t)}function B(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function G(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?B(Object(r),!0).forEach(function(e){U(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):B(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function U(t,e,r){return(e=function(t){var e=function(t){if("object"!=N(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=N(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==N(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var Y=function(t){var e=t.mapStyle,r=t.keyDefinition.style,n=r.strokeWidth,o=g(r.stroke,e.id);return(0,b.jsx)("svg",G(G({},P),{},{children:(0,b.jsx)("line",{x1:n/2,y1:10,x2:w-n/2,y2:10,stroke:o,strokeWidth:n,strokeLinecap:"round"})}))};function W(t){return W="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},W(t)}function $(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function F(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?$(Object(r),!0).forEach(function(e){H(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):$(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function H(t,e,r){return(e=function(t){var e=function(t){if("object"!=W(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=W(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==W(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var z=function(t){var e=t.mapStyle,r=t.keyDefinition.style,n=r.strokeWidth,o=g(r.fill,e.id),i=g(r.stroke,e.id);return(0,b.jsx)("svg",F(F({},P),{},{children:(0,b.jsx)("rect",{x:n/2,y:n/2,width:w-n,height:w-n,rx:n,ry:n,fill:o,stroke:i,strokeWidth:n,strokeLinejoin:"round"})}))},q=function(t){var e=t.mapStyle,r=t.keyDefinition,o=t.patternRegistry,i=r.style,u=r.hasPattern,l="im-c-map-key-ramp-"+(0,n.useId)().replace(/[^\w-]/g,""),a=u?o.getKeyPatternPaths(i,e.id):null,c=g(i.stroke,e.id),y=a?"url(#".concat(l,")"):g(i.fill,e.id);return(0,b.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",className:"im-c-map-key-symbol","aria-hidden":"true",focusable:"false",children:[a&&(0,b.jsx)("defs",{children:(0,b.jsx)("pattern",{id:l,patternUnits:"userSpaceOnUse",x:2,y:2,width:16,height:16,dangerouslySetInnerHTML:{__html:a.content}})}),(0,b.jsx)("rect",{width:"100%",height:"100%",fill:y||"none",stroke:c,strokeWidth:c?4:void 0})]})},V="ramp",J=function(t){var e=t.keyDefinition,r=t.groupStyle,n=t.mapStyle,o=t.symbolRegistry,i=t.patternRegistry,u=function(t,e,r,n){if(!t)return{symbolShape:null,keySymbol:null};var o=t.hasSymbol,i=t.hasPattern,u=t.style;if(e===V)return{symbolShape:V,keySymbol:null};if(o){var l=n.getKeySymbol(u,r);return{symbolShape:l?"symbol":"rect",keySymbol:l}}return i?{symbolShape:"pattern",keySymbol:null}:null==u.fill&&u.stroke?{symbolShape:"line",keySymbol:null}:{symbolShape:"rect",keySymbol:null}}(e,r,n,o),l=u.symbolShape,a=u.keySymbol;return l?"symbol"===l?(0,b.jsx)(K,{keySymbol:a}):"pattern"===l?(0,b.jsx)(R,{mapStyle:n,keyDefinition:e,patternRegistry:i}):"line"===l?(0,b.jsx)(Y,{mapStyle:n,keyDefinition:e}):l===V?(0,b.jsx)(q,{mapStyle:n,keyDefinition:e,patternRegistry:i}):(0,b.jsx)(z,{mapStyle:n,keyDefinition:e}):null},Q=function(t){var e=t.keyDefinition,r=t.groupStyle,n=t.mapStyle,o=t.symbolRegistry,i=t.patternRegistry,u=e.label,l=g(e.symbolDescription,n.id);return(0,b.jsxs)("div",{className:"im-c-map-key-list__item",children:[(0,b.jsx)("dt",{className:"im-c-map-key-list__item-symbol",children:(0,b.jsx)(J,{keyDefinition:e,groupStyle:r,mapStyle:n,symbolRegistry:o,patternRegistry:i})}),(0,b.jsxs)("dd",{className:"im-c-map-key-list__item-label",children:[u,l&&(0,b.jsxs)("span",{className:"govuk-visually-hidden",children:["(",l,")"]})]})]})},X=(new Set,new Set(["symbolBackgroundColor","symbolForegroundColor","symbolHaloWidth","symbolGraphic"]),function(t){return!!(null!=t&&t.symbol||null!=t&&t.symbolSvgContent)});function Z(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var tt,et=function(t){var e=t.headingId,r=t.label,o=t.groupStyle,i=t.keyDefinitions,u=t.mapStyle,l=t.symbolRegistry,a=t.patternRegistry,c=(0,n.useRef)(null),y=function(t,e){return t===V&&e.some(function(t){return X(t.style)})?void 0:t}(o,i),f=y===V,s=f&&i.some(function(t){var e;return g(null===(e=t.style)||void 0===e?void 0:e.stroke,u.id)}),p=function(t,e,r,o){var i,u,l=(i=(0,n.useState)(!0),u=2,function(t){if(Array.isArray(t))return t}(i)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,u,l=[],a=!0,c=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;a=!1}else for(;!(a=(n=i.call(r)).done)&&(l.push(n.value),l.length!==e);a=!0);}catch(t){c=!0,o=t}finally{try{if(!a&&null!=r.return&&(u=r.return(),Object(u)!==u))return}finally{if(c)throw o}}return l}}(i,u)||function(t,e){if(t){if("string"==typeof t)return Z(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Z(t,e):void 0}}(i,u)||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.")}()),a=l[0],c=l[1],y=e.join("\n");return(0,n.useLayoutEffect)(function(){var n,o=t.current;if(r&&o){var i=!0,u=function(){var t=i?function(t,e){var r,n=t.querySelector(".im-c-map-key-list__item-label"),o=(void 0===tt&&(tt=null!==(r=document.createElement("canvas").getContext("2d"))&&void 0!==r?r:null),tt);if(!n||!o||!t.clientWidth)return null;var i=getComputedStyle(n),u=i.fontStyle,l=i.fontWeight,a=i.fontSize,c=i.fontFamily;o.font="".concat(u," ").concat(l," ").concat(a," ").concat(c);var y=getComputedStyle(t),f=Number.parseFloat(y.columnGap)||0,s=(Number.parseFloat(y.paddingLeft)||0)+(Number.parseFloat(y.paddingRight)||0),p=(t.clientWidth-s-f*(e.length-1))/e.length;return e.every(function(t){return o.measureText(t).width<=p})}(o,e):null;null!==t&&c(t)};u();var l="function"==typeof ResizeObserver?new ResizeObserver(u):null;return null==l||l.observe(o),null===(n=document.fonts)||void 0===n||n.ready.then(u,function(){}),function(){i=!1,null==l||l.disconnect()}}},[r,o,y]),a?"horizontal":"vertical"}(c,i.map(function(t){var e;return null!==(e=t.label)&&void 0!==e?e:""}),f,s),m=function(t,e,r){if(!t)return"im-c-map-key-list";var n="im-c-map-key-list im-c-map-key-list--".concat(t);if(t!==V)return n;var o="".concat(n," im-c-map-key-list--ramp-").concat(e);return r?"".concat(o," im-c-map-key-list--has-stroke"):o}(y,p,s);return(0,b.jsxs)("section",{className:"im-c-map-key__group","aria-labelledby":e,children:[(0,b.jsx)("h3",{id:e,className:"im-c-map-key__group-heading",children:r}),(0,b.jsx)("dl",{ref:c,className:m,children:i.map(function(t){return(0,b.jsx)(Q,{keyDefinition:t,mapStyle:u,symbolRegistry:l,patternRegistry:a,groupStyle:y},"".concat(t.id))})})]})},rt="im-c-map-key",nt=function(t){var e=t.item,r=t.groupStyle,n=t.mapStyle,o=t.symbolRegistry,i=t.patternRegistry;return"group"===e.type?(0,b.jsx)(et,{headingId:"key-heading-".concat(e.id),label:e.groupLabel,groupStyle:r,keyDefinitions:e.keyDefinitions,mapStyle:n,symbolRegistry:o,patternRegistry:i}):(0,b.jsx)(Q,{keyDefinition:e.keyDefinition,mapStyle:n,symbolRegistry:o,patternRegistry:i})},ot=function(t){var e=t.noKeyItemText,r=t.keyGroups,n=t.hasGroups,o=t.mapStyle,i=t.symbolRegistry,u=t.patternRegistry;if(null==r||!r.length)return(0,b.jsx)(d,{text:e});var l=n?"".concat(rt," ").concat("im-c-map-key--has-groups"):rt;return(0,b.jsx)("div",{className:l,children:r.map(function(t){return(0,b.jsx)(nt,{item:t,mapStyle:o,symbolRegistry:i,patternRegistry:u,groupStyle:t.groupStyle},t.id)})})};function it(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,u,l=[],a=!0,c=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;a=!1}else for(;!(a=(n=i.call(r)).done)&&(l.push(n.value),l.length!==e);a=!0);}catch(t){c=!0,o=t}finally{try{if(!a&&null!=r.return&&(u=r.return(),Object(u)!==u))return}finally{if(c)throw o}}return l}}(t,e)||function(t,e){if(t){if("string"==typeof t)return ut(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?ut(t,e):void 0}}(t,e)||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 ut(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function lt(t){return lt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},lt(t)}function at(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function ct(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?at(Object(r),!0).forEach(function(e){yt(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):at(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function yt(t,e,r){return(e=function(t){var e=function(t){if("object"!=lt(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=lt(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==lt(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function ft(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function st(t){return st="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},st(t)}function pt(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function mt(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?pt(Object(r),!0).forEach(function(e){bt(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):pt(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function bt(t,e,r){return(e=function(t){var e=function(t){if("object"!=st(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=st(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==st(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function dt(t){return function(t){if(Array.isArray(t))return vt(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return vt(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?vt(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function vt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var gt={InitComponent:function(t){var e=t.pluginConfig,r=t.pluginState,o=t.mapState,u=t.services,l=r.dispatch,a=u.eventBus,c=(0,n.useRef)(r);c.current=r,(0,n.useEffect)(function(){o.isMapReady&&(function(t){s=t}(c),a.requestOnce("datasets:registry",i),a.emit("map-key:ready"))},[o.isMapReady]),(0,n.useEffect)(function(){if(e.groups){var t=Object.entries(e.groups).map(function(t){var e,r,n=(r=2,function(t){if(Array.isArray(t))return t}(e=t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,u,l=[],a=!0,c=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;a=!1}else for(;!(a=(n=i.call(r)).done)&&(l.push(n.value),l.length!==e);a=!0);}catch(t){c=!0,o=t}finally{try{if(!a&&null!=r.return&&(u=r.return(),Object(u)!==u))return}finally{if(c)throw o}}return l}}(e,r)||function(t,e){if(t){if("string"==typeof t)return ft(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?ft(t,e):void 0}}(e,r)||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.")}()),o=n[0],i=n[1];return ct(ct({},i),{},{id:o,label:i.groupLabel})});l({type:"ADD_KEY_GROUPS",payload:t})}},[e.groups])},reducer:{initialState:{keyDefinitions:[],groups:[]},actions:{ADD_KEY_SYMBOL:function(t,e){var r,n=e.id,o=e.groupLabel,i=e.groupId||((r=o)?r.toLowerCase().replace(/\s+/g,"-"):null),u=function(t,e,r){return t.groups.find(function(t){return"group"===t.type&&t.id===r||"flat"===t.type&&t.id===e})}(t,n,i),l=u?null:function(t,e,r){return e?{id:e,type:"group",groupLabel:r}:{id:t,type:"flat"}}(n,i,o),a=l?[].concat(dt(t.groups),[l]):t.groups,c=[].concat(dt(t.keyDefinitions),[mt(mt({},e),{},{type:"manual"},i?{groupId:i}:{})]);return mt(mt({},t),{},{keyDefinitions:c,groups:a})},REMOVE_KEY_SYMBOL:function(t,e){var r=e.id;return mt(mt({},t),{},{keyDefinitions:t.keyDefinitions.filter(function(t){return t.id!==r})})},ADD_KEY_GROUPS:function(t,e){return mt(mt({},t),{},{groups:[].concat(dt(t.groups),dt(e))})}}},panels:[{id:"mapKey",label:"Key",mobile:{slot:"drawer",modal:!0},tablet:{slot:"left-top",width:"260px"},desktop:{slot:"left-top",width:"280px"},render:function(t){var e=t.mapState.mapStyle,r=t.pluginConfig.noKeyItemText,i=t.pluginState,u=t.services,a=u.eventBus,c=u.symbolRegistry,f=u.patternRegistry,d=it((0,n.useState)(o),2),v=d[0],g=d[1],h=it((0,n.useState)(function(){var t;return null!==(t=null==v?void 0:v.keyItems().items)&&void 0!==t?t:[]}),2),S=h[0],O=h[1],j=it((0,n.useState)(function(){var t;return null!==(t=null==v?void 0:v.keyItems().hasGroups)&&void 0!==t&&t}),2),w=j[0],k=j[1],P=function(){var t=v.keyItems(),e=t.items,r=t.hasGroups,n=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=l(function(){var t;if(null===(t=s)||void 0===t||!t.current)return[];if(p===s.current)return m;p=s.current;var e=s.current,r=e.groups,n=void 0===r?[]:r,o=e.keyDefinitions,i=void 0===o?[]:o;return m=n.map(function(t){return"flat"===t.type?y(y({},t),{},{keyDefinition:i.find(function(e){return e.id===t.id})}):y(y({},t),{},{keyDefinitions:i.filter(function(e){return e.groupId===t.id})})})}());if(0===e.length)return t;var r=t.map(function(t){var r=e.findIndex(function(e){return e.id===t.id});if(-1===r)return t;var n=e.splice(r,1)[0];return y(y(y({},t),n),{},{keyDefinitions:[].concat(l(n.keyDefinitions||[]),l(t.keyDefinitions||[]))})});return[].concat(l(r),l(e)).filter(function(t){var e;return"flat"===t.type&&t.keyDefinition||"group"===t.type&&(null===(e=t.keyDefinitions)||void 0===e?void 0:e.length)})}(e);O(n),k(r)},D=function(t){v.invalidateKeyItemsOnMenuStateChange(t),P()};return(0,n.useEffect)(function(){return v?(P(),a.on("menu:changed",D).on("datasets:changed",P),function(){return a.off("menu:changed",D).off("datasets:changed",P)}):(a.requestOnce("datasets:registry",g),function(){})},[v]),(0,n.useEffect)(function(){v&&P()},[i]),(0,b.jsx)(ot,{noKeyItemText:r,keyGroups:S,hasGroups:w,mapStyle:e,symbolRegistry:c,patternRegistry:f})}}],buttons:[{id:"mapKey",panelId:"mapKey",label:"Key",iconId:"key",mobile:{slot:"top-left",showLabel:!0},tablet:{slot:"top-left",showLabel:!0},desktop:{slot:"top-left",showLabel:!0}}],icons:[{id:"key",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"/>'}],api:{addSymbol:function(t,e){(0,t.pluginState.dispatch)({type:"ADD_KEY_SYMBOL",payload:e})},removeSymbol:function(t,e){(0,t.pluginState.dispatch)({type:"REMOVE_KEY_SYMBOL",payload:e})}}}}}]);
|
|
1
|
+
"use strict";(Object("undefined"!=typeof self?self:this).webpackChunkdefra_DefraMap=Object("undefined"!=typeof self?self:this).webpackChunkdefra_DefraMap||[]).push([[414],{883:function(t,e,r){r.r(e),r.d(e,{manifest:function(){return pt}});var n=r(738);function o(t){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},o(t)}function i(t){return function(t){if(Array.isArray(t))return u(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return u(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?u(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function u(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function l(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function a(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?l(Object(r),!0).forEach(function(e){c(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):l(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function c(t,e,r){return(e=function(t){var e=function(t){if("object"!=o(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=o(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==o(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var y=r(287),f=function(t){var e=t.text;return(0,y.jsx)("div",{className:"im-c-map-key",children:(0,y.jsx)("p",{className:"im-c-map-key__empty-message",children:e})})};function s(t){return s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},s(t)}var p=function(t,e){if(!t)return null;if("string"==typeof t)return t.trim();if("object"===s(t)){if(e&&t[e])return t[e];var r=Object.values(t)[0];return null!=r?r:null}return null};function m(t){return m="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},m(t)}function b(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function d(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?b(Object(r),!0).forEach(function(e){v(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):b(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function v(t,e,r){return(e=function(t){var e=function(t){if("object"!=m(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=m(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==m(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var g=20,h=44,S={xmlns:"http://www.w3.org/2000/svg",width:g,height:g,viewBox:"0 0 ".concat(g," ").concat(g),className:"im-c-map-key-symbol","aria-hidden":"true",focusable:"false"},j=d(d({},S),{},{width:h,height:h,viewBox:"0 0 ".concat(h," ").concat(h),className:"im-c-map-key-symbol im-c-map-key-symbol--point"});function O(t){return O="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},O(t)}function w(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function k(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?w(Object(r),!0).forEach(function(e){P(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):w(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function P(t,e,r){return(e=function(t){var e=function(t){if("object"!=O(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=O(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==O(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var D=function(t){var e=t.keyDefinition,r=t.mapStyle,n=t.patternRegistry,o=e.style,i=n.getKeyPatternPaths(o,r.id);return i?(0,y.jsxs)("svg",k(k({},S),{},{children:[(0,y.jsx)("g",{dangerouslySetInnerHTML:{__html:i.border}}),(0,y.jsx)("g",{transform:"translate(".concat(2,", ").concat(2,")"),dangerouslySetInnerHTML:{__html:i.content}})]})):null};function x(t){return x="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},x(t)}function E(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function A(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?E(Object(r),!0).forEach(function(e){R(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):E(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function R(t,e,r){return(e=function(t){var e=function(t){if("object"!=x(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=x(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==x(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function I(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var _=function(t){var e=t.keySymbol,r=null!=e?e:{},n=r.svg,o=r.viewBox;if(!n||!o)return null;var i,u,l=(i=o.split(" ").map(Number),u=4,function(t){if(Array.isArray(t))return t}(i)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,u,l=[],a=!0,c=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;a=!1}else for(;!(a=(n=i.call(r)).done)&&(l.push(n.value),l.length!==e);a=!0);}catch(t){c=!0,o=t}finally{try{if(!a&&null!=r.return&&(u=r.return(),Object(u)!==u))return}finally{if(c)throw o}}return l}}(i,u)||function(t,e){if(t){if("string"==typeof t)return I(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?I(t,e):void 0}}(i,u)||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.")}()),a=l[2],c=l[3],f=Math.min(1,56/Math.max(a,c)),s=a*f,p=c*f;return(0,y.jsx)("svg",A(A({},j),{},{overflow:"visible",children:(0,y.jsx)("svg",{"aria-hidden":"true",x:.5*(h-s),y:.5*(h-p),width:s,height:p,viewBox:o,overflow:"hidden",children:(0,y.jsx)("g",{dangerouslySetInnerHTML:{__html:n}})})}))};function T(t){return T="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},T(t)}function M(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function C(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?M(Object(r),!0).forEach(function(e){L(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):M(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function L(t,e,r){return(e=function(t){var e=function(t){if("object"!=T(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=T(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==T(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var K=function(t){var e=t.mapStyle,r=t.keyDefinition.style,n=r.strokeWidth,o=p(r.stroke,e.id);return(0,y.jsx)("svg",C(C({},S),{},{children:(0,y.jsx)("line",{x1:n/2,y1:10,x2:g-n/2,y2:10,stroke:o,strokeWidth:n,strokeLinecap:"round"})}))};function N(t){return N="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},N(t)}function G(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function Y(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?G(Object(r),!0).forEach(function(e){B(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):G(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function B(t,e,r){return(e=function(t){var e=function(t){if("object"!=N(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=N(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==N(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var U=function(t){var e=t.mapStyle,r=t.keyDefinition.style,n=r.strokeWidth,o=p(r.fill,e.id),i=p(r.stroke,e.id);return(0,y.jsx)("svg",Y(Y({},S),{},{children:(0,y.jsx)("rect",{x:n/2,y:n/2,width:g-n,height:g-n,rx:n,ry:n,fill:o,stroke:i,strokeWidth:n,strokeLinejoin:"round"})}))},W=function(t){var e=t.mapStyle,r=t.keyDefinition,o=t.patternRegistry,i=r.style,u=r.hasPattern,l="im-c-map-key-ramp-"+(0,n.useId)().replace(/[^\w-]/g,""),a=u?o.getKeyPatternPaths(i,e.id):null,c=p(i.stroke,e.id),f=a?"url(#".concat(l,")"):p(i.fill,e.id);return(0,y.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",className:"im-c-map-key-symbol","aria-hidden":"true",focusable:"false",children:[a&&(0,y.jsx)("defs",{children:(0,y.jsx)("pattern",{id:l,patternUnits:"userSpaceOnUse",x:2,y:2,width:16,height:16,dangerouslySetInnerHTML:{__html:a.content}})}),(0,y.jsx)("rect",{width:"100%",height:"100%",fill:f||"none",stroke:c,strokeWidth:c?4:void 0})]})},$="ramp",F=function(t){var e=t.keyDefinition,r=t.groupStyle,n=t.mapStyle,o=t.symbolRegistry,i=t.patternRegistry,u=function(t,e,r,n){if(!t)return{symbolShape:null,keySymbol:null};var o=t.hasSymbol,i=t.hasPattern,u=t.style;if(e===$)return{symbolShape:$,keySymbol:null};if(o){var l=n.getKeySymbol(u,r);return{symbolShape:l?"symbol":"rect",keySymbol:l}}return i?{symbolShape:"pattern",keySymbol:null}:null==u.fill&&u.stroke?{symbolShape:"line",keySymbol:null}:{symbolShape:"rect",keySymbol:null}}(e,r,n,o),l=u.symbolShape,a=u.keySymbol;return l?"symbol"===l?(0,y.jsx)(_,{keySymbol:a}):"pattern"===l?(0,y.jsx)(D,{mapStyle:n,keyDefinition:e,patternRegistry:i}):"line"===l?(0,y.jsx)(K,{mapStyle:n,keyDefinition:e}):l===$?(0,y.jsx)(W,{mapStyle:n,keyDefinition:e,patternRegistry:i}):(0,y.jsx)(U,{mapStyle:n,keyDefinition:e}):null},H=function(t){var e=t.keyDefinition,r=t.groupStyle,n=t.mapStyle,o=t.symbolRegistry,i=t.patternRegistry,u=e.label,l=p(e.symbolDescription,n.id);return(0,y.jsxs)("div",{className:"im-c-map-key-list__item",children:[(0,y.jsx)("dt",{className:"im-c-map-key-list__item-symbol",children:(0,y.jsx)(F,{keyDefinition:e,groupStyle:r,mapStyle:n,symbolRegistry:o,patternRegistry:i})}),(0,y.jsxs)("dd",{className:"im-c-map-key-list__item-label",children:[u,l&&(0,y.jsxs)("span",{className:"govuk-visually-hidden",children:["(",l,")"]})]})]})},z=(new Set,new Set(["symbolBackgroundColor","symbolForegroundColor","symbolHaloWidth","symbolGraphic"]),function(t){return!!(null!=t&&t.symbol||null!=t&&t.symbolSvgContent)});function q(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var V,J=function(t){var e=t.headingId,r=t.label,o=t.groupStyle,i=t.keyDefinitions,u=t.mapStyle,l=t.symbolRegistry,a=t.patternRegistry,c=(0,n.useRef)(null),f=function(t,e){return t===$&&e.some(function(t){return z(t.style)})?void 0:t}(o,i),s=f===$,m=s&&i.some(function(t){var e;return p(null===(e=t.style)||void 0===e?void 0:e.stroke,u.id)}),b=function(t,e,r,o){var i,u,l=(i=(0,n.useState)(!0),u=2,function(t){if(Array.isArray(t))return t}(i)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,u,l=[],a=!0,c=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;a=!1}else for(;!(a=(n=i.call(r)).done)&&(l.push(n.value),l.length!==e);a=!0);}catch(t){c=!0,o=t}finally{try{if(!a&&null!=r.return&&(u=r.return(),Object(u)!==u))return}finally{if(c)throw o}}return l}}(i,u)||function(t,e){if(t){if("string"==typeof t)return q(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?q(t,e):void 0}}(i,u)||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.")}()),a=l[0],c=l[1],y=e.join("\n");return(0,n.useLayoutEffect)(function(){var n,o=t.current;if(r&&o){var i=!0,u=function(){var t=i?function(t,e){var r,n=t.querySelector(".im-c-map-key-list__item-label"),o=(void 0===V&&(V=null!==(r=document.createElement("canvas").getContext("2d"))&&void 0!==r?r:null),V);if(!n||!o||!t.clientWidth)return null;var i=getComputedStyle(n),u=i.fontStyle,l=i.fontWeight,a=i.fontSize,c=i.fontFamily;o.font="".concat(u," ").concat(l," ").concat(a," ").concat(c);var y=getComputedStyle(t),f=Number.parseFloat(y.columnGap)||0,s=(Number.parseFloat(y.paddingLeft)||0)+(Number.parseFloat(y.paddingRight)||0),p=(t.clientWidth-s-f*(e.length-1))/e.length;return e.every(function(t){return o.measureText(t).width<=p})}(o,e):null;null!==t&&c(t)};u();var l="function"==typeof ResizeObserver?new ResizeObserver(u):null;return null==l||l.observe(o),null===(n=document.fonts)||void 0===n||n.ready.then(u,function(){}),function(){i=!1,null==l||l.disconnect()}}},[r,o,y]),a?"horizontal":"vertical"}(c,i.map(function(t){var e;return null!==(e=t.label)&&void 0!==e?e:""}),s,m),d=function(t,e,r){if(!t)return"im-c-map-key-list";var n="im-c-map-key-list im-c-map-key-list--".concat(t);if(t!==$)return n;var o="".concat(n," im-c-map-key-list--ramp-").concat(e);return r?"".concat(o," im-c-map-key-list--has-stroke"):o}(f,b,m);return(0,y.jsxs)("section",{className:"im-c-map-key__group","aria-labelledby":e,children:[(0,y.jsx)("h3",{id:e,className:"im-c-map-key__group-heading",children:r}),(0,y.jsx)("dl",{ref:c,className:d,children:i.map(function(t){return(0,y.jsx)(H,{keyDefinition:t,mapStyle:u,symbolRegistry:l,patternRegistry:a,groupStyle:f},"".concat(t.id))})})]})},Q="im-c-map-key",X=function(t){var e=t.item,r=t.groupStyle,n=t.mapStyle,o=t.symbolRegistry,i=t.patternRegistry;return"group"===e.type?(0,y.jsx)(J,{headingId:"key-heading-".concat(e.id),label:e.groupLabel,groupStyle:r,keyDefinitions:e.keyDefinitions,mapStyle:n,symbolRegistry:o,patternRegistry:i}):(0,y.jsx)(H,{keyDefinition:e.keyDefinition,mapStyle:n,symbolRegistry:o,patternRegistry:i})},Z=function(t){var e=t.noKeyItemText,r=t.keyGroups,n=t.hasGroups,o=t.mapStyle,i=t.symbolRegistry,u=t.patternRegistry;if(null==r||!r.length)return(0,y.jsx)(f,{text:e});var l=n?"".concat(Q," ").concat("im-c-map-key--has-groups"):Q;return(0,y.jsx)("div",{className:l,children:r.map(function(t){return(0,y.jsx)(X,{item:t,mapStyle:o,symbolRegistry:i,patternRegistry:u,groupStyle:t.groupStyle},t.id)})})};function tt(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,u,l=[],a=!0,c=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;a=!1}else for(;!(a=(n=i.call(r)).done)&&(l.push(n.value),l.length!==e);a=!0);}catch(t){c=!0,o=t}finally{try{if(!a&&null!=r.return&&(u=r.return(),Object(u)!==u))return}finally{if(c)throw o}}return l}}(t,e)||function(t,e){if(t){if("string"==typeof t)return et(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?et(t,e):void 0}}(t,e)||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 et(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function rt(t){return rt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},rt(t)}function nt(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function ot(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?nt(Object(r),!0).forEach(function(e){it(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):nt(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function it(t,e,r){return(e=function(t){var e=function(t){if("object"!=rt(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=rt(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==rt(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function ut(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function lt(t){return lt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},lt(t)}function at(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function ct(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?at(Object(r),!0).forEach(function(e){yt(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):at(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function yt(t,e,r){return(e=function(t){var e=function(t){if("object"!=lt(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=lt(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==lt(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function ft(t){return function(t){if(Array.isArray(t))return st(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return st(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?st(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function st(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var pt={InitComponent:function(t){var e=t.pluginConfig,r=t.pluginState,o=t.mapState,i=t.services,u=r.dispatch,l=i.eventBus;(0,n.useEffect)(function(){o.isMapReady&&(l.requestOnce("datasets:registry",function(t){u({type:"SET_DATASET_REGISTRY",payload:t})}),l.emit("map-key:ready"))},[o.isMapReady]),(0,n.useEffect)(function(){if(e.groups){var t=Object.entries(e.groups).map(function(t){var e,r,n=(r=2,function(t){if(Array.isArray(t))return t}(e=t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,u,l=[],a=!0,c=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;a=!1}else for(;!(a=(n=i.call(r)).done)&&(l.push(n.value),l.length!==e);a=!0);}catch(t){c=!0,o=t}finally{try{if(!a&&null!=r.return&&(u=r.return(),Object(u)!==u))return}finally{if(c)throw o}}return l}}(e,r)||function(t,e){if(t){if("string"==typeof t)return ut(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?ut(t,e):void 0}}(e,r)||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.")}()),o=n[0],i=n[1];return ot(ot({},i),{},{id:o,label:i.groupLabel})});u({type:"ADD_KEY_GROUPS",payload:t})}},[e.groups])},reducer:{initialState:{keyDefinitions:[],groups:[],datasetRegistry:null},actions:{SET_DATASET_REGISTRY:function(t,e){return ct(ct({},t),{},{datasetRegistry:e})},ADD_KEY_SYMBOL:function(t,e){var r,n=e.id,o=e.groupLabel,i=e.groupId||((r=o)?r.toLowerCase().replace(/\s+/g,"-"):null),u=function(t,e,r){return t.groups.find(function(t){return"group"===t.type&&t.id===r||"flat"===t.type&&t.id===e})}(t,n,i),l=u?null:function(t,e,r){return e?{id:e,type:"group",groupLabel:r}:{id:t,type:"flat"}}(n,i,o),a=l?[].concat(ft(t.groups),[l]):t.groups,c=[].concat(ft(t.keyDefinitions),[ct(ct({},e),{},{type:"manual"},i?{groupId:i}:{})]);return ct(ct({},t),{},{keyDefinitions:c,groups:a})},REMOVE_KEY_SYMBOL:function(t,e){var r=e.id;return ct(ct({},t),{},{keyDefinitions:t.keyDefinitions.filter(function(t){return t.id!==r})})},ADD_KEY_GROUPS:function(t,e){return ct(ct({},t),{},{groups:[].concat(ft(t.groups),ft(e))})}}},panels:[{id:"mapKey",label:"Key",mobile:{slot:"drawer",modal:!0},tablet:{slot:"left-top",width:"260px"},desktop:{slot:"left-top",width:"280px"},render:function(t){var e=t.mapState.mapStyle,r=t.pluginConfig.noKeyItemText,o=t.pluginState,u=t.services,l=u.eventBus,c=u.symbolRegistry,f=u.patternRegistry,s=o.datasetRegistry,p=(0,n.useRef)(o);p.current=o;var m=tt((0,n.useState)(function(){var t;return null!==(t=null==s?void 0:s.keyItems().items)&&void 0!==t?t:[]}),2),b=m[0],d=m[1],v=tt((0,n.useState)(function(){var t;return null!==(t=null==s?void 0:s.keyItems().hasGroups)&&void 0!==t&&t}),2),g=v[0],h=v[1],S=function(){var t=s.keyItems(),e=t.items,r=t.hasGroups,n=function(){var t,e,r,n,o,u=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],l=(r=void 0===(e=(t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).groups)?[]:e,n=t.keyDefinitions,o=void 0===n?[]:n,r.map(function(t){return"flat"===t.type?a(a({},t),{},{keyDefinition:o.find(function(e){return e.id===t.id})}):a(a({},t),{},{keyDefinitions:o.filter(function(e){return e.groupId===t.id})})}));if(0===l.length)return u;var c=u.map(function(t){var e=l.findIndex(function(e){return e.id===t.id});if(-1===e)return t;var r=l.splice(e,1)[0];return a(a(a({},t),r),{},{keyDefinitions:[].concat(i(r.keyDefinitions||[]),i(t.keyDefinitions||[]))})});return[].concat(i(c),i(l)).filter(function(t){var e;return"flat"===t.type&&t.keyDefinition||"group"===t.type&&(null===(e=t.keyDefinitions)||void 0===e?void 0:e.length)})}(e,p.current);d(n),h(r)},j=function(t){s.invalidateKeyItemsOnMenuStateChange(t),S()};return(0,n.useEffect)(function(){if(s)return S(),l.on("menu:changed",j).on("datasets:changed",S),function(){return l.off("menu:changed",j).off("datasets:changed",S)}},[s]),(0,n.useEffect)(function(){s&&S()},[o]),(0,y.jsx)(Z,{noKeyItemText:r,keyGroups:b,hasGroups:g,mapStyle:e,symbolRegistry:c,patternRegistry:f})}}],buttons:[{id:"mapKey",panelId:"mapKey",label:"Key",iconId:"key",mobile:{slot:"top-left",showLabel:!0},tablet:{slot:"top-left",showLabel:!0},desktop:{slot:"top-left",showLabel:!0}}],icons:[{id:"key",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"/>'}],api:{addSymbol:function(t,e){(0,t.pluginState.dispatch)({type:"ADD_KEY_SYMBOL",payload:e})},removeSymbol:function(t,e){(0,t.pluginState.dispatch)({type:"REMOVE_KEY_SYMBOL",payload:e})}}}}}]);
|