@defra/interactive-map 0.0.43-fmp-experimental → 0.0.44-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 +5 -1
- package/assets/templates/add-symbols.njk +5 -1
- package/dist/css/index.css +1 -1
- package/dist/esm/im-core.js +1 -1
- package/dist/esm/im-shell.js +1 -1
- package/dist/umd/im-core.js +1 -1
- package/dist/umd/index.js +1 -1
- package/docs/api/context.md +24 -0
- package/docs/api/keyboard-shortcut-definition.md +102 -0
- package/docs/api.md +18 -8
- package/docs/building-a-plugin.md +1 -0
- package/docs/plugins/draw.md +2 -2
- package/docs/plugins/plugin-manifest.md +9 -0
- package/package.json +4 -2
- package/plugins/beta/draw-es/dist/esm/im-draw-es-plugin.js +1 -1
- package/plugins/beta/draw-es/src/api/newPolygon.js +1 -0
- package/plugins/beta/draw-es/src/events.js +17 -8
- package/plugins/beta/draw-es/src/reducer.js +8 -1
- package/plugins/beta/draw-ml/dist/esm/im-draw-ml-plugin.js +1 -1
- package/plugins/beta/draw-ml/dist/umd/im-draw-ml-plugin.js +1 -1
- package/plugins/beta/draw-ol/dist/css/index.css +1 -13
- package/plugins/beta/draw-ol/dist/esm/im-draw-ol-plugin.js +1 -1
- package/plugins/beta/frame/dist/css/index.css +1 -11
- package/plugins/beta/frame/dist/esm/im-frame-plugin.js +1 -1
- package/plugins/beta/frame/dist/umd/im-frame-plugin.js +1 -1
- package/plugins/beta/frame/src/Frame.jsx +28 -2
- package/plugins/beta/map-styles/dist/css/index.css +1 -1
- package/plugins/beta/map-styles/dist/umd/im-map-styles-plugin.js +1 -1
- package/plugins/beta/map-styles/dist/umd/index.js +1 -1
- package/plugins/beta/scale-bar/dist/css/index.css +1 -8
- package/plugins/datasets/dist/css/5648.index.css +1 -5
- package/plugins/datasets/dist/css/index.css +1 -1
- package/plugins/datasets/dist/esm/im-datasets-plugin.js +1 -1
- package/plugins/datasets/dist/umd/im-datasets-plugin.js +1 -1
- package/plugins/datasets/src/components/LayersMenu/Layers.module.scss +1 -0
- package/plugins/datasets/src/initialise/DatasetsInit.jsx +2 -2
- package/plugins/datasets/src/initialise/DatasetsInit.test.jsx +6 -5
- package/plugins/datasets/src/registry/dataset.js +8 -12
- package/plugins/datasets/src/registry/dataset.test.js +17 -0
- package/plugins/datasets/src/registry/datasetRegistry.js +4 -5
- package/plugins/draw/dist/esm/im-draw-ml-adapter.js +1 -1
- package/plugins/draw/dist/esm/im-draw-ol-adapter.js +1 -1
- package/plugins/draw/dist/esm/im-draw-plugin.js +1 -1
- package/plugins/draw/dist/esm/index.js +1 -1
- package/plugins/draw/dist/umd/im-draw-ml-adapter.js +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 +41 -26
- package/plugins/draw/src/DrawInit.test.jsx +55 -12
- package/plugins/draw/src/adapters/maplibre/MaplibreDrawAdapter.js +113 -114
- package/plugins/draw/src/adapters/maplibre/MaplibreDrawAdapter.test.js +82 -9
- package/plugins/draw/src/adapters/maplibre/drawEvents.js +3 -1
- package/plugins/draw/src/adapters/maplibre/modes/createDrawMode.test.js +1 -1
- package/plugins/draw/src/adapters/maplibre/modes/drawMode/__helpers__/harness.js +18 -9
- package/plugins/draw/src/adapters/maplibre/modes/drawMode/clickHandlers.js +9 -1
- package/plugins/draw/src/adapters/maplibre/modes/drawMode/clickHandlers.test.js +11 -1
- package/plugins/draw/src/adapters/maplibre/modes/drawMode/lifecycle.js +23 -2
- package/plugins/draw/src/adapters/maplibre/modes/drawMode/lifecycle.test.js +53 -0
- package/plugins/draw/src/adapters/maplibre/modes/drawMode/pointerHandlers.js +29 -19
- package/plugins/draw/src/adapters/maplibre/modes/drawMode/pointerHandlers.test.js +17 -2
- package/plugins/draw/src/adapters/maplibre/modes/drawMode/undoHandlers.test.js +1 -1
- package/plugins/draw/src/adapters/maplibre/modes/drawPointMode.js +35 -29
- package/plugins/draw/src/adapters/maplibre/modes/drawPointMode.test.js +24 -6
- package/plugins/draw/src/adapters/maplibre/modes/editPointMode/keyboardHandlers.js +22 -20
- package/plugins/draw/src/adapters/maplibre/modes/editPointMode/pointOperations.js +1 -1
- package/plugins/draw/src/adapters/maplibre/modes/editPointMode.js +2 -2
- package/plugins/draw/src/adapters/maplibre/modes/editPointMode.test.js +3 -3
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/geometryHelpers.js +31 -0
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/geometryHelpers.test.js +8 -1
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/keyboardHandlers.js +38 -30
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/keyboardHandlers.test.js +20 -3
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/pointerHandlers.js +5 -5
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/touchHandlers.js +2 -2
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/touchHandlers.test.js +2 -2
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/undoHandlers.js +3 -3
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/undoHandlers.test.js +7 -7
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/vertexOperations.js +4 -4
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/vertexOperations.test.js +14 -14
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/vertexQueries.js +12 -32
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/vertexQueries.test.js +10 -10
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode.js +48 -22
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode.test.js +74 -6
- package/plugins/draw/src/adapters/maplibre/utils/snapMovement.js +2 -2
- package/plugins/draw/src/adapters/openlayers/OLDrawAdapter.js +6 -0
- package/plugins/draw/src/adapters/openlayers/OLDrawAdapter.test.js +9 -0
- package/plugins/draw/src/adapters/openlayers/core/OLDrawManager.js +15 -2
- package/plugins/draw/src/adapters/openlayers/core/OLDrawManager.test.js +27 -1
- package/plugins/draw/src/adapters/openlayers/draw/DrawMode.test.js +1 -1
- package/plugins/draw/src/adapters/openlayers/draw/drawInput.js +40 -17
- package/plugins/draw/src/adapters/openlayers/draw/drawInput.test.js +55 -1
- package/plugins/draw/src/adapters/openlayers/draw/vertexPlacement.js +13 -7
- package/plugins/draw/src/adapters/openlayers/draw/vertexPlacement.test.js +7 -15
- package/plugins/draw/src/adapters/openlayers/edit/EditMode.js +36 -4
- package/plugins/draw/src/adapters/openlayers/edit/EditMode.test.js +41 -1
- package/plugins/draw/src/adapters/openlayers/edit/keyboardHandler.js +35 -25
- package/plugins/draw/src/adapters/openlayers/edit/keyboardHandler.test.js +40 -2
- package/plugins/draw/src/adapters/openlayers/edit/nudge.js +2 -2
- package/plugins/draw/src/adapters/openlayers/edit/nudge.test.js +2 -2
- package/plugins/draw/src/adapters/openlayers/point/drawPointMode.js +40 -54
- package/plugins/draw/src/adapters/openlayers/point/drawPointMode.test.js +32 -13
- package/plugins/draw/src/adapters/openlayers/point/editPointMode.js +1 -1
- package/plugins/draw/src/adapters/openlayers/point/editPointMode.test.js +17 -1
- package/plugins/draw/src/events.js +4 -4
- package/plugins/draw/src/events.test.js +1 -1
- package/plugins/draw/src/hooks/useSpatialList.js +180 -0
- package/plugins/draw/src/hooks/useSpatialList.test.js +339 -0
- package/plugins/draw/src/manifest.js +4 -1
- package/plugins/draw/src/manifest.test.js +19 -7
- package/plugins/draw/src/utils/spatial.js +1 -31
- package/plugins/draw/src/utils/spatial.test.js +1 -24
- package/plugins/interact/dist/esm/im-interact-plugin.js +1 -1
- package/plugins/interact/dist/umd/im-interact-plugin.js +1 -1
- package/plugins/interact/dist/umd/index.js +1 -1
- package/plugins/interact/src/InteractInit.jsx +2 -2
- package/plugins/interact/src/InteractInit.test.js +3 -3
- package/plugins/interact/src/events.js +11 -2
- package/plugins/interact/src/events.test.js +32 -0
- package/plugins/interact/src/hooks/useAttachEvents.js +20 -0
- package/plugins/interact/src/hooks/useAttachEvents.test.js +44 -1
- package/plugins/interact/src/hooks/useCrossHairVisibility.js +9 -4
- package/plugins/interact/src/hooks/useCrossHairVisibility.test.js +7 -7
- package/plugins/interact/src/hooks/useSpatialList.js +251 -0
- package/plugins/interact/src/hooks/{useMapItemList.test.js → useSpatialList.test.js} +216 -70
- package/plugins/interact/src/manifest.js +12 -1
- package/plugins/interact/src/manifest.test.js +20 -0
- package/plugins/interact/src/utils/spatial.js +24 -1
- package/plugins/interact/src/utils/spatial.test.js +26 -1
- package/plugins/map-key/dist/css/index.css +1 -106
- package/plugins/map-key/dist/esm/im-map-key-plugin.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/Key.jsx +3 -4
- package/plugins/map-key/src/components/Key/Key.module.scss +10 -8
- package/plugins/map-key/src/components/Key/KeyGroupItem.test.jsx +2 -2
- package/plugins/map-key/src/components/Key/KeyItem.jsx +2 -2
- package/plugins/map-key/src/components/Key/KeySvg.jsx +9 -7
- package/plugins/map-key/src/components/Key/KeySvg.test.jsx +4 -4
- package/plugins/map-key/src/components/Key/MapKey.jsx +5 -3
- package/plugins/map-key/src/manifest.js +1 -1
- package/plugins/map-key/src/utils/groupStyles.js +7 -0
- package/plugins/map-key/src/utils/mergeKeyGroupItems.js +12 -0
- package/plugins/map-key/src/utils/mergeKeyGroupItems.test.js +53 -0
- package/plugins/menu/dist/css/index.css +1 -80
- package/plugins/menu/dist/esm/im-menu-plugin.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/menu/src/initialise/MenuInit.jsx +15 -3
- package/plugins/menu/src/initialise/MenuInit.test.jsx +25 -0
- package/plugins/menu/src/initialise/createMenu.js +3 -1
- package/plugins/menu/src/initialise/createMenu.test.js +20 -5
- package/plugins/menu/src/initialise/updateUrl.js +44 -0
- package/plugins/menu/src/initialise/updateUrl.test.js +91 -0
- package/plugins/menu/src/reducers/menuStateReducer.js +19 -1
- package/plugins/menu/src/reducers/menuStateReducer.test.js +53 -20
- package/plugins/menu/src/reducers/pluginState.js +1 -6
- package/plugins/menu/src/reducers/pluginState.test.js +0 -25
- package/plugins/search/dist/css/index.css +1 -1
- package/plugins/search/dist/esm/im-search-plugin.js +1 -1
- package/plugins/search/dist/umd/im-search-plugin.js +1 -1
- package/plugins/search/src/manifest.js +5 -9
- package/plugins/search/src/manifest.test.js +5 -0
- package/providers/beta/esri/dist/css/index.css +1 -34
- package/providers/beta/openlayers/dist/esm/im-openlayers-provider.js +1 -1
- package/providers/beta/openlayers/dist/umd/im-openlayers-provider.js +1 -1
- package/providers/beta/openlayers/src/openlayersProvider.js +3 -3
- package/providers/beta/openlayers/src/openlayersProvider.test.js +6 -3
- package/providers/beta/openlayers/src/utils/queryFeatures.js +72 -0
- package/providers/beta/openlayers/src/utils/queryFeatures.test.js +122 -1
- package/providers/maplibre/dist/esm/im-maplibre-provider.js +1 -1
- package/providers/maplibre/dist/umd/im-maplibre-provider.js +1 -1
- package/providers/maplibre/dist/umd/index.js +1 -1
- package/providers/maplibre/src/defaults.test.js +26 -0
- package/providers/maplibre/src/utils/labels.js +2 -2
- package/providers/maplibre/src/utils/labels.test.js +5 -5
- package/providers/maplibre/src/utils/spatial.js +0 -57
- package/providers/maplibre/src/utils/spatial.test.js +0 -27
- package/rollup.esm.mjs +2 -1
- package/scripts/publish-package.sh +36 -0
- package/src/App/App.jsx +1 -1
- package/src/App/App.test.jsx +6 -1
- package/src/App/components/CrossHair/CrossHair.jsx +25 -11
- package/src/App/components/CrossHair/CrossHair.module.scss +37 -12
- package/src/App/components/CrossHair/CrossHair.test.jsx +40 -11
- package/src/App/components/Hints/Hints.jsx +3 -3
- package/src/App/components/Hints/Hints.test.jsx +3 -3
- package/src/App/components/KeyboardHelp/KeyboardHelp.jsx +4 -1
- package/src/App/components/KeyboardHelp/KeyboardHelp.test.jsx +17 -0
- package/src/App/components/MapButton/MapButton.jsx +19 -7
- package/src/App/components/MapButton/MapButton.module.scss +1 -2
- package/src/App/components/MapButton/MapButton.test.jsx +42 -4
- package/src/App/components/{MoveControls/MoveControls.jsx → MapControls/MapControls.jsx} +10 -10
- package/src/App/components/{MoveControls/MoveControls.module.scss → MapControls/MapControls.module.scss} +25 -25
- package/src/App/components/{MoveControls/MoveControls.test.jsx → MapControls/MapControls.test.jsx} +48 -48
- package/src/App/components/Markers/Markers.jsx +2 -2
- package/src/App/components/Markers/Markers.test.jsx +3 -3
- package/src/App/components/Markers/SymbolMarker.jsx +2 -3
- package/src/App/components/Markers/SymbolMarker.test.jsx +8 -9
- package/src/App/components/Panel/Panel.jsx +19 -20
- package/src/App/components/Panel/Panel.module.scss +5 -0
- package/src/App/components/Panel/Panel.test.jsx +69 -4
- package/src/App/components/PopupMenu/PopupMenu.jsx +7 -3
- package/src/App/components/PopupMenu/PopupMenu.test.jsx +71 -0
- package/src/App/components/PopupMenu/usePopupMenu.js +10 -9
- package/src/App/components/Viewport/MapStatus.jsx +1 -1
- package/src/App/components/Viewport/SpatialList.jsx +47 -0
- package/src/App/components/Viewport/{Features.module.scss → SpatialList.module.scss} +6 -6
- package/src/App/components/Viewport/SpatialList.test.jsx +285 -0
- package/src/App/components/Viewport/Viewport.jsx +21 -11
- package/src/App/components/Viewport/Viewport.test.jsx +18 -2
- package/src/App/controls/keyboardMappings.js +7 -2
- package/src/App/controls/keyboardMappings.test.js +21 -0
- package/src/App/controls/keyboardShortcuts.js +16 -2
- package/src/App/controls/keyboardShortcuts.test.js +21 -0
- package/src/App/hooks/useCrossHairAPI.js +29 -1
- package/src/App/hooks/useCrossHairAPI.test.js +17 -1
- package/src/App/hooks/useHintsAPI.js +5 -5
- package/src/App/hooks/useInterfaceAPI.js +2 -1
- package/src/App/hooks/useInterfaceAPI.test.js +9 -0
- package/src/App/hooks/useKeyboardShortcuts.js +66 -35
- package/src/App/hooks/useKeyboardShortcuts.test.js +52 -0
- package/src/App/hooks/useModalPanelBehaviour.js +48 -34
- package/src/App/hooks/useModalPanelBehaviour.test.js +59 -0
- package/src/App/hooks/useSpatialListFocus.js +296 -0
- package/src/App/hooks/useSpatialListFocus.test.js +957 -0
- package/src/App/hooks/useSpatialListItems.js +51 -0
- package/src/App/hooks/useSpatialListItems.test.js +217 -0
- package/src/App/initialiseApp.js +6 -3
- package/src/App/initialiseApp.test.js +11 -0
- package/src/App/layout/Layout.jsx +4 -2
- package/src/App/layout/Layout.test.jsx +21 -0
- package/src/App/layout/layout.module.scss +7 -1
- package/src/App/registry/keyboardShortcutRegistry.js +2 -2
- package/src/App/registry/keyboardShortcutRegistry.test.js +16 -0
- package/src/App/registry/pluginRegistry.js +13 -0
- package/src/App/registry/pluginRegistry.test.js +15 -0
- package/src/App/registry/spatialListRegistry.js +104 -0
- package/src/App/registry/spatialListRegistry.test.js +218 -0
- package/src/App/renderer/HtmlElementHost.jsx +12 -32
- package/src/App/renderer/mapButtons.js +4 -0
- package/src/App/renderer/mapButtons.test.js +20 -0
- package/src/App/renderer/mapPanels.js +33 -53
- package/src/App/renderer/mapPanels.test.js +29 -4
- package/src/App/renderer/slotHelpers.js +33 -0
- package/src/App/renderer/slotHelpers.test.js +79 -2
- package/src/App/store/AppProvider.jsx +3 -2
- package/src/App/store/ServiceProvider.jsx +5 -3
- package/src/App/store/ServiceProvider.test.jsx +20 -1
- package/src/InteractiveMap/InteractiveMap.js +13 -2
- package/src/InteractiveMap/InteractiveMap.test.js +33 -0
- package/src/config/appConfig.js +16 -16
- package/src/config/appConfig.test.js +19 -19
- package/src/config/defaults.js +2 -2
- package/src/config/events.js +8 -8
- package/src/scss/main.scss +2 -2
- package/src/test-utils.js +8 -0
- package/src/types.js +51 -9
- package/src/utils/findNearestItemInDirection.js +29 -0
- package/src/utils/findNearestItemInDirection.test.js +67 -0
- package/src/utils/getPanelElementId.js +4 -0
- package/src/utils/getPanelElementId.test.js +11 -0
- package/src/utils/getPanelRole.js +22 -0
- package/src/utils/getPanelRole.test.js +56 -0
- package/src/utils/globalAltShortcuts.js +12 -0
- package/src/utils/globalAltShortcuts.test.js +27 -0
- package/src/utils/spatialNavigate.js +49 -0
- package/src/utils/spatialNavigate.test.js +42 -0
- package/webpack.umd.mjs +6 -1
- package/plugins/interact/src/hooks/useMapItemList.js +0 -187
- package/src/App/components/Viewport/Features.jsx +0 -35
- package/src/App/components/Viewport/Features.test.jsx +0 -124
- package/src/App/hooks/useFeatureFocus.js +0 -199
- package/src/App/hooks/useFeatureFocus.test.js +0 -635
- package/src/App/hooks/useFeatureItems.js +0 -39
- package/src/App/hooks/useFeatureItems.test.js +0 -155
|
@@ -1,63 +1,63 @@
|
|
|
1
1
|
@use '../../../scss/tools/index' as tools;
|
|
2
2
|
|
|
3
3
|
// ===================================================
|
|
4
|
-
// Component:
|
|
4
|
+
// Component: MapControls
|
|
5
5
|
// ===================================================
|
|
6
6
|
|
|
7
7
|
// 1. Base styles
|
|
8
|
-
.im-c-
|
|
8
|
+
.im-c-map-controls {
|
|
9
9
|
display: flex;
|
|
10
10
|
flex-direction: column;
|
|
11
11
|
align-items: center;
|
|
12
12
|
gap: var(--divider-gap);
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
.im-c-
|
|
15
|
+
.im-c-map-controls.im-c-map-controls--collapsed {
|
|
16
16
|
display: none;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
// 2. Elements
|
|
20
|
-
.im-c-
|
|
20
|
+
.im-c-map-controls__directions {
|
|
21
21
|
display: grid;
|
|
22
22
|
grid-template-columns: repeat(3, var(--button-size));
|
|
23
23
|
grid-template-rows: repeat(3, var(--button-size));
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
.im-c-
|
|
26
|
+
.im-c-map-controls__directions .im-c-button-wrapper--pan-up {
|
|
27
27
|
grid-column: 2;
|
|
28
28
|
grid-row: 1;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
.im-c-
|
|
31
|
+
.im-c-map-controls__directions .im-c-button-wrapper--pan-left {
|
|
32
32
|
grid-column: 1;
|
|
33
33
|
grid-row: 2;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
.im-c-
|
|
36
|
+
.im-c-map-controls__directions .im-c-button-wrapper--pan-right {
|
|
37
37
|
grid-column: 3;
|
|
38
38
|
grid-row: 2;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
.im-c-
|
|
41
|
+
.im-c-map-controls__directions .im-c-button-wrapper--pan-down {
|
|
42
42
|
grid-column: 2;
|
|
43
43
|
grid-row: 3;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
.im-c-
|
|
46
|
+
.im-c-map-controls__directions .im-c-button-wrapper--nudge-step-toggle {
|
|
47
47
|
grid-column: 2;
|
|
48
48
|
grid-row: 2;
|
|
49
49
|
z-index: 1;
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
.im-c-
|
|
52
|
+
.im-c-map-controls__directions .im-c-map-button--pan-up svg {
|
|
53
53
|
transform: rotate(180deg);
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
.im-c-
|
|
56
|
+
.im-c-map-controls__directions .im-c-map-button--pan-left svg {
|
|
57
57
|
transform: rotate(90deg);
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
.im-c-
|
|
60
|
+
.im-c-map-controls__directions .im-c-map-button--pan-right svg {
|
|
61
61
|
transform: rotate(-90deg);
|
|
62
62
|
}
|
|
63
63
|
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
// express a plus-shaped grid where the centre button touches all four neighbours —
|
|
68
68
|
// clip-path is set directly per button instead, clipping only the side(s) where it
|
|
69
69
|
// touches another button and leaving the exposed side(s) showing the shadow as normal.
|
|
70
|
-
.im-c-
|
|
70
|
+
.im-c-map-controls__directions .im-c-button-wrapper--pan-up .im-c-map-button {
|
|
71
71
|
border-bottom-left-radius: 0;
|
|
72
72
|
border-bottom-right-radius: 0;
|
|
73
73
|
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
.im-c-
|
|
79
|
+
.im-c-map-controls__directions .im-c-button-wrapper--pan-left .im-c-map-button {
|
|
80
80
|
border-top-right-radius: 0;
|
|
81
81
|
border-bottom-right-radius: 0;
|
|
82
82
|
|
|
@@ -85,7 +85,7 @@
|
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
-
.im-c-
|
|
88
|
+
.im-c-map-controls__directions .im-c-button-wrapper--pan-right .im-c-map-button {
|
|
89
89
|
border-top-left-radius: 0;
|
|
90
90
|
border-bottom-left-radius: 0;
|
|
91
91
|
|
|
@@ -94,7 +94,7 @@
|
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
-
.im-c-
|
|
97
|
+
.im-c-map-controls__directions .im-c-button-wrapper--pan-down .im-c-map-button {
|
|
98
98
|
border-top-left-radius: 0;
|
|
99
99
|
border-top-right-radius: 0;
|
|
100
100
|
|
|
@@ -103,7 +103,7 @@
|
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
-
.im-c-
|
|
106
|
+
.im-c-map-controls__directions .im-c-button-wrapper--nudge-step-toggle .im-c-map-button {
|
|
107
107
|
border-radius: 0;
|
|
108
108
|
outline: 1px solid var(--button-hover-color);
|
|
109
109
|
|
|
@@ -114,13 +114,13 @@
|
|
|
114
114
|
|
|
115
115
|
// Same inverted "pressed" treatment already used for actions-slot toggle buttons
|
|
116
116
|
// (e.g. draw's Snap toggle) — reused here so Nudge mode reads consistently active.
|
|
117
|
-
.im-c-
|
|
117
|
+
.im-c-map-controls .im-c-map-button[aria-pressed="true"] {
|
|
118
118
|
color: var(--pressed-button-foreground-color);
|
|
119
119
|
border-color: var(--pressed-button-border-color);
|
|
120
120
|
background-color: var(--pressed-button-background-color);
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
-
// The trigger lives in the right-top slot, outside .im-c-
|
|
123
|
+
// The trigger lives in the right-top slot, outside .im-c-map-controls, so this is
|
|
124
124
|
// its own top-level rule. Same colour treatment as above, but keyed off
|
|
125
125
|
// aria-expanded rather than aria-pressed — the trigger is correctly a disclosure
|
|
126
126
|
// button (it reveals the control below), not a toggle button, so it doesn't carry
|
|
@@ -132,31 +132,31 @@
|
|
|
132
132
|
// hovering the expanded trigger button was a coin-flip decided by cascade order —
|
|
133
133
|
// one cssnano mergeRules reshuffle in production and hover started winning,
|
|
134
134
|
// showing the hover tint instead of the pressed colours. The sibling
|
|
135
|
-
// .im-c-
|
|
135
|
+
// .im-c-map-controls .im-c-map-button[aria-pressed="true"] rule above never had
|
|
136
136
|
// this problem (it's already (0,3,0), safely ahead of hover); this one needed the
|
|
137
137
|
// same headroom.
|
|
138
|
-
.im-c-map-button.im-c-map-button--
|
|
138
|
+
.im-c-map-button.im-c-map-button--map-controls[aria-expanded="true"] {
|
|
139
139
|
color: var(--pressed-button-foreground-color);
|
|
140
140
|
border-color: var(--pressed-button-border-color);
|
|
141
141
|
background-color: var(--pressed-button-background-color);
|
|
142
142
|
}
|
|
143
143
|
|
|
144
|
-
.im-c-
|
|
144
|
+
.im-c-map-controls__zoom {
|
|
145
145
|
display: flex;
|
|
146
146
|
flex-direction: row;
|
|
147
147
|
}
|
|
148
148
|
|
|
149
149
|
// A simple two-item linear row, so the standard button-group corner/shadow treatment
|
|
150
150
|
// applies directly (matches .im-o-app__top's first/last-child pattern).
|
|
151
|
-
.im-c-
|
|
151
|
+
.im-c-map-controls__zoom .im-c-button-wrapper--nudge-zoom-in .im-c-map-button {
|
|
152
152
|
@include tools.border-focus-corner-override($corners: 'left');
|
|
153
153
|
}
|
|
154
154
|
|
|
155
|
-
.im-c-
|
|
155
|
+
.im-c-map-controls__zoom .im-c-button-wrapper--nudge-zoom-out .im-c-map-button {
|
|
156
156
|
@include tools.border-focus-corner-override($corners: 'right');
|
|
157
157
|
}
|
|
158
158
|
|
|
159
159
|
// App dark modifiers
|
|
160
|
-
.im-o-app--dark-app .im-c-
|
|
160
|
+
.im-o-app--dark-app .im-c-map-controls__directions .im-c-button-wrapper--nudge-step-toggle .im-c-map-button {
|
|
161
161
|
outline-offset: -1px;
|
|
162
162
|
}
|
package/src/App/components/{MoveControls/MoveControls.test.jsx → MapControls/MapControls.test.jsx}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
2
|
import { render, screen, fireEvent } from '@testing-library/react'
|
|
3
|
-
import {
|
|
3
|
+
import { MapControls } from './MapControls.jsx'
|
|
4
4
|
import { useApp } from '../../store/appContext.js'
|
|
5
5
|
import { useConfig } from '../../store/configContext.js'
|
|
6
6
|
import { useMap } from '../../store/mapContext.js'
|
|
@@ -11,19 +11,19 @@ jest.mock('../../store/configContext.js', () => ({ useConfig: jest.fn() }))
|
|
|
11
11
|
jest.mock('../../store/mapContext.js', () => ({ useMap: jest.fn() }))
|
|
12
12
|
jest.mock('../../store/serviceContext.js', () => ({ useService: jest.fn() }))
|
|
13
13
|
|
|
14
|
-
describe('
|
|
14
|
+
describe('MapControls', () => {
|
|
15
15
|
let dispatch
|
|
16
16
|
let mapProvider
|
|
17
17
|
let announce
|
|
18
18
|
|
|
19
19
|
// MapButton and Tooltip also read from useApp() (buttonRefs, interfaceType), so every
|
|
20
|
-
// mockReturnValue needs to carry these alongside the fields
|
|
20
|
+
// mockReturnValue needs to carry these alongside the fields MapControls itself reads.
|
|
21
21
|
const buildAppState = (overrides) => ({
|
|
22
22
|
buttonRefs: { current: {} },
|
|
23
23
|
interfaceType: 'mouse',
|
|
24
24
|
breakpoint: 'desktop',
|
|
25
25
|
dispatch,
|
|
26
|
-
expandedButtons: new Set(['
|
|
26
|
+
expandedButtons: new Set(['mapControls']),
|
|
27
27
|
nudgeStepSize: 'large',
|
|
28
28
|
layoutRefs: { viewportRef: { current: { focus: jest.fn() } } },
|
|
29
29
|
...overrides
|
|
@@ -50,29 +50,29 @@ describe('MoveControls', () => {
|
|
|
50
50
|
afterEach(() => jest.clearAllMocks())
|
|
51
51
|
|
|
52
52
|
it('renders with the id matching the trigger button aria-controls value', () => {
|
|
53
|
-
const { container } = render(<
|
|
54
|
-
expect(container.querySelector('#im-
|
|
53
|
+
const { container } = render(<MapControls />)
|
|
54
|
+
expect(container.querySelector('#im-map-controls-content')).toBeInTheDocument()
|
|
55
55
|
})
|
|
56
56
|
|
|
57
|
-
it('is not visually collapsed when
|
|
58
|
-
const { container } = render(<
|
|
59
|
-
expect(container.querySelector('.im-c-
|
|
57
|
+
it('is not visually collapsed when mapControls is expanded', () => {
|
|
58
|
+
const { container } = render(<MapControls />)
|
|
59
|
+
expect(container.querySelector('.im-c-map-controls--collapsed')).not.toBeInTheDocument()
|
|
60
60
|
})
|
|
61
61
|
|
|
62
62
|
it('moves focus to the first direction button when the control opens', () => {
|
|
63
|
-
const { rerender } = render(<
|
|
63
|
+
const { rerender } = render(<MapControls />)
|
|
64
64
|
useApp.mockReturnValue(buildAppState({ expandedButtons: new Set() }))
|
|
65
|
-
rerender(<
|
|
65
|
+
rerender(<MapControls />)
|
|
66
66
|
|
|
67
|
-
useApp.mockReturnValue(buildAppState({ expandedButtons: new Set(['
|
|
68
|
-
rerender(<
|
|
67
|
+
useApp.mockReturnValue(buildAppState({ expandedButtons: new Set(['mapControls']) }))
|
|
68
|
+
rerender(<MapControls />)
|
|
69
69
|
expect(screen.getByRole('button', { name: 'Move up' })).toHaveFocus()
|
|
70
70
|
})
|
|
71
71
|
|
|
72
72
|
it('renders the directions group before the zoom group at every breakpoint', () => {
|
|
73
73
|
['mobile', 'tablet', 'desktop'].forEach(breakpoint => {
|
|
74
74
|
useApp.mockReturnValue(buildAppState({ breakpoint }))
|
|
75
|
-
const { container, unmount } = render(<
|
|
75
|
+
const { container, unmount } = render(<MapControls />)
|
|
76
76
|
const groups = container.querySelectorAll('[role="group"]')
|
|
77
77
|
expect(groups[0]).toHaveAttribute('aria-label', 'Direction controls')
|
|
78
78
|
expect(groups[1]).toHaveAttribute('aria-label', 'Zoom controls')
|
|
@@ -80,14 +80,14 @@ describe('MoveControls', () => {
|
|
|
80
80
|
})
|
|
81
81
|
})
|
|
82
82
|
|
|
83
|
-
it('is collapsed when
|
|
83
|
+
it('is collapsed when mapControls is not expanded', () => {
|
|
84
84
|
useApp.mockReturnValue(buildAppState({ expandedButtons: new Set() }))
|
|
85
|
-
const { container } = render(<
|
|
86
|
-
expect(container.querySelector('.im-c-
|
|
85
|
+
const { container } = render(<MapControls />)
|
|
86
|
+
expect(container.querySelector('.im-c-map-controls--collapsed')).toBeInTheDocument()
|
|
87
87
|
})
|
|
88
88
|
|
|
89
89
|
it('labels direction buttons "Move" and pans by the large delta by default', () => {
|
|
90
|
-
render(<
|
|
90
|
+
render(<MapControls />)
|
|
91
91
|
fireEvent.click(screen.getByRole('button', { name: 'Move right' }))
|
|
92
92
|
expect(mapProvider.panBy).toHaveBeenCalledWith([100, 0])
|
|
93
93
|
expect(announce).toHaveBeenCalledWith('Moved right')
|
|
@@ -95,7 +95,7 @@ describe('MoveControls', () => {
|
|
|
95
95
|
|
|
96
96
|
it('labels direction buttons "Nudge" and pans by the small delta when nudgeStepSize is small', () => {
|
|
97
97
|
useApp.mockReturnValue(buildAppState({ nudgeStepSize: 'small' }))
|
|
98
|
-
render(<
|
|
98
|
+
render(<MapControls />)
|
|
99
99
|
fireEvent.click(screen.getByRole('button', { name: 'Nudge up' }))
|
|
100
100
|
expect(mapProvider.panBy).toHaveBeenCalledWith([0, -5])
|
|
101
101
|
expect(announce).toHaveBeenCalledWith('Nudged up')
|
|
@@ -103,7 +103,7 @@ describe('MoveControls', () => {
|
|
|
103
103
|
|
|
104
104
|
it('routes direction clicks to mapProvider.activeMoveTarget instead of panning, when a plugin has claimed it', () => {
|
|
105
105
|
mapProvider.activeMoveTarget = { move: jest.fn(), label: 'vertex' }
|
|
106
|
-
render(<
|
|
106
|
+
render(<MapControls />)
|
|
107
107
|
fireEvent.click(screen.getByRole('button', { name: 'Move right' }))
|
|
108
108
|
expect(mapProvider.activeMoveTarget.move).toHaveBeenCalledWith(1, 0, true)
|
|
109
109
|
expect(mapProvider.panBy).not.toHaveBeenCalled()
|
|
@@ -112,22 +112,22 @@ describe('MoveControls', () => {
|
|
|
112
112
|
|
|
113
113
|
it('falls back to panning once activeMoveTarget is released', () => {
|
|
114
114
|
mapProvider.activeMoveTarget = { move: jest.fn(), label: 'vertex' }
|
|
115
|
-
const { rerender } = render(<
|
|
115
|
+
const { rerender } = render(<MapControls />)
|
|
116
116
|
mapProvider.activeMoveTarget = null
|
|
117
|
-
rerender(<
|
|
117
|
+
rerender(<MapControls />)
|
|
118
118
|
fireEvent.click(screen.getByRole('button', { name: 'Move right' }))
|
|
119
119
|
expect(mapProvider.panBy).toHaveBeenCalledWith([100, 0])
|
|
120
120
|
})
|
|
121
121
|
|
|
122
122
|
it('omits the target label from the announcement when activeMoveTarget has none', () => {
|
|
123
123
|
mapProvider.activeMoveTarget = { move: jest.fn() }
|
|
124
|
-
render(<
|
|
124
|
+
render(<MapControls />)
|
|
125
125
|
fireEvent.click(screen.getByRole('button', { name: 'Move up' }))
|
|
126
126
|
expect(announce).toHaveBeenCalledWith('Moved up')
|
|
127
127
|
})
|
|
128
128
|
|
|
129
129
|
it('zooms in and out by the large delta by default and announces the action', () => {
|
|
130
|
-
render(<
|
|
130
|
+
render(<MapControls />)
|
|
131
131
|
fireEvent.click(screen.getByRole('button', { name: 'Zoom in' }))
|
|
132
132
|
expect(mapProvider.zoomIn).toHaveBeenCalledWith(1)
|
|
133
133
|
expect(announce).toHaveBeenCalledWith('Zoomed in')
|
|
@@ -139,26 +139,26 @@ describe('MoveControls', () => {
|
|
|
139
139
|
|
|
140
140
|
it('zooms by the small delta when nudgeStepSize is small', () => {
|
|
141
141
|
useApp.mockReturnValue(buildAppState({ nudgeStepSize: 'small' }))
|
|
142
|
-
render(<
|
|
142
|
+
render(<MapControls />)
|
|
143
143
|
fireEvent.click(screen.getByRole('button', { name: 'Zoom in' }))
|
|
144
144
|
expect(mapProvider.zoomIn).toHaveBeenCalledWith(0.1)
|
|
145
145
|
})
|
|
146
146
|
|
|
147
147
|
it('disables the zoom in button at max zoom, and zoom out at min zoom', () => {
|
|
148
148
|
useMap.mockReturnValue({ isAtMaxZoom: true, isAtMinZoom: false })
|
|
149
|
-
const { rerender } = render(<
|
|
149
|
+
const { rerender } = render(<MapControls />)
|
|
150
150
|
expect(screen.getByRole('button', { name: 'Zoom in' })).toHaveAttribute('aria-disabled', 'true')
|
|
151
151
|
expect(screen.getByRole('button', { name: 'Zoom out' })).not.toHaveAttribute('aria-disabled')
|
|
152
152
|
|
|
153
153
|
useMap.mockReturnValue({ isAtMaxZoom: false, isAtMinZoom: true })
|
|
154
|
-
rerender(<
|
|
154
|
+
rerender(<MapControls />)
|
|
155
155
|
expect(screen.getByRole('button', { name: 'Zoom in' })).not.toHaveAttribute('aria-disabled')
|
|
156
156
|
expect(screen.getByRole('button', { name: 'Zoom out' })).toHaveAttribute('aria-disabled', 'true')
|
|
157
157
|
})
|
|
158
158
|
|
|
159
159
|
it('does not zoom when the relevant button is disabled at max/min zoom', () => {
|
|
160
160
|
useMap.mockReturnValue({ isAtMaxZoom: true, isAtMinZoom: true })
|
|
161
|
-
render(<
|
|
161
|
+
render(<MapControls />)
|
|
162
162
|
fireEvent.click(screen.getByRole('button', { name: 'Zoom in' }))
|
|
163
163
|
fireEvent.click(screen.getByRole('button', { name: 'Zoom out' }))
|
|
164
164
|
expect(mapProvider.zoomIn).not.toHaveBeenCalled()
|
|
@@ -177,7 +177,7 @@ describe('MoveControls', () => {
|
|
|
177
177
|
it('returns focus to the viewport after panning on mouse/touch, so arrow-key shortcuts elsewhere are not left stranded on the D-pad button', () => {
|
|
178
178
|
const appState = buildAppState({ interfaceType: 'mouse' })
|
|
179
179
|
useApp.mockReturnValue(appState)
|
|
180
|
-
render(<
|
|
180
|
+
render(<MapControls />)
|
|
181
181
|
|
|
182
182
|
fireEvent.click(screen.getByRole('button', { name: 'Move right' }))
|
|
183
183
|
expect(appState.layoutRefs.viewportRef.current.focus).toHaveBeenCalled()
|
|
@@ -185,19 +185,19 @@ describe('MoveControls', () => {
|
|
|
185
185
|
|
|
186
186
|
it('keeps focus on the button when driven by keyboard, so repeated Enter/Space presses do not require re-tabbing', () => {
|
|
187
187
|
useApp.mockReturnValue(buildAppState({ interfaceType: 'keyboard' }))
|
|
188
|
-
render(<
|
|
188
|
+
render(<MapControls />)
|
|
189
189
|
fireEvent.click(screen.getByRole('button', { name: 'Move right' }))
|
|
190
190
|
expect(rafSpy).not.toHaveBeenCalled()
|
|
191
191
|
})
|
|
192
192
|
|
|
193
193
|
it('also returns focus after zooming on mouse/touch, but not on keyboard', () => {
|
|
194
194
|
useApp.mockReturnValue(buildAppState({ interfaceType: 'mouse' }))
|
|
195
|
-
const { rerender } = render(<
|
|
195
|
+
const { rerender } = render(<MapControls />)
|
|
196
196
|
fireEvent.click(screen.getByRole('button', { name: 'Zoom in' }))
|
|
197
197
|
expect(rafSpy).toHaveBeenCalledTimes(1)
|
|
198
198
|
|
|
199
199
|
useApp.mockReturnValue(buildAppState({ interfaceType: 'keyboard' }))
|
|
200
|
-
rerender(<
|
|
200
|
+
rerender(<MapControls />)
|
|
201
201
|
fireEvent.click(screen.getByRole('button', { name: 'Zoom in' }))
|
|
202
202
|
expect(rafSpy).toHaveBeenCalledTimes(1)
|
|
203
203
|
})
|
|
@@ -205,7 +205,7 @@ describe('MoveControls', () => {
|
|
|
205
205
|
it('also returns focus after a vertex nudge via activeMoveTarget on mouse/touch', () => {
|
|
206
206
|
mapProvider.activeMoveTarget = { move: jest.fn(), label: 'vertex' }
|
|
207
207
|
useApp.mockReturnValue(buildAppState({ interfaceType: 'touch' }))
|
|
208
|
-
render(<
|
|
208
|
+
render(<MapControls />)
|
|
209
209
|
fireEvent.click(screen.getByRole('button', { name: 'Move right' }))
|
|
210
210
|
expect(rafSpy).toHaveBeenCalledTimes(1)
|
|
211
211
|
})
|
|
@@ -217,7 +217,7 @@ describe('MoveControls', () => {
|
|
|
217
217
|
// arrow keys without first tabbing all the way back out to the map.
|
|
218
218
|
it('pans the map on an arrow key, regardless of which button currently has focus', () => {
|
|
219
219
|
useApp.mockReturnValue(buildAppState({ interfaceType: 'keyboard' }))
|
|
220
|
-
render(<
|
|
220
|
+
render(<MapControls />)
|
|
221
221
|
// Focus a button unrelated to the direction being pressed, to prove this
|
|
222
222
|
// isn't just reading the focused button's own handler.
|
|
223
223
|
fireEvent.focus(screen.getByRole('button', { name: 'Zoom in' }))
|
|
@@ -229,7 +229,7 @@ describe('MoveControls', () => {
|
|
|
229
229
|
it('routes the arrow key through activeMoveTarget when a plugin has claimed the control', () => {
|
|
230
230
|
mapProvider.activeMoveTarget = { move: jest.fn(), label: 'vertex' }
|
|
231
231
|
useApp.mockReturnValue(buildAppState({ interfaceType: 'keyboard' }))
|
|
232
|
-
render(<
|
|
232
|
+
render(<MapControls />)
|
|
233
233
|
fireEvent.keyDown(screen.getByRole('button', { name: 'Move up' }), { key: 'ArrowUp' })
|
|
234
234
|
expect(mapProvider.activeMoveTarget.move).toHaveBeenCalledWith(0, -1, true)
|
|
235
235
|
expect(mapProvider.panBy).not.toHaveBeenCalled()
|
|
@@ -237,14 +237,14 @@ describe('MoveControls', () => {
|
|
|
237
237
|
|
|
238
238
|
it('ignores non-arrow keys, leaving default behaviour (e.g. Enter/Space activating the focused button) untouched', () => {
|
|
239
239
|
useApp.mockReturnValue(buildAppState({ interfaceType: 'keyboard' }))
|
|
240
|
-
render(<
|
|
240
|
+
render(<MapControls />)
|
|
241
241
|
fireEvent.keyDown(screen.getByRole('button', { name: 'Move up' }), { key: 'Enter' })
|
|
242
242
|
expect(mapProvider.panBy).not.toHaveBeenCalled()
|
|
243
243
|
})
|
|
244
244
|
|
|
245
245
|
it('shift+arrow overrides the Precision toggle to the small step, matching the map\'s own native keyboard shortcuts', () => {
|
|
246
246
|
useApp.mockReturnValue(buildAppState({ interfaceType: 'keyboard', nudgeStepSize: 'large' }))
|
|
247
|
-
render(<
|
|
247
|
+
render(<MapControls />)
|
|
248
248
|
fireEvent.keyDown(screen.getByRole('button', { name: 'Move right' }), { key: 'ArrowRight', shiftKey: true })
|
|
249
249
|
expect(mapProvider.panBy).toHaveBeenCalledWith([5, 0])
|
|
250
250
|
expect(announce).toHaveBeenCalledWith('Nudged right')
|
|
@@ -252,7 +252,7 @@ describe('MoveControls', () => {
|
|
|
252
252
|
|
|
253
253
|
it('shift+arrow still resolves to the small step when Precision is already on (idempotent, not a toggle-relative flip)', () => {
|
|
254
254
|
useApp.mockReturnValue(buildAppState({ interfaceType: 'keyboard', nudgeStepSize: 'small' }))
|
|
255
|
-
render(<
|
|
255
|
+
render(<MapControls />)
|
|
256
256
|
fireEvent.keyDown(screen.getByRole('button', { name: 'Nudge right' }), { key: 'ArrowRight', shiftKey: true })
|
|
257
257
|
expect(mapProvider.panBy).toHaveBeenCalledWith([5, 0])
|
|
258
258
|
expect(announce).toHaveBeenCalledWith('Nudged right')
|
|
@@ -261,14 +261,14 @@ describe('MoveControls', () => {
|
|
|
261
261
|
it('shift+arrow overrides activeMoveTarget.move to the small step too', () => {
|
|
262
262
|
mapProvider.activeMoveTarget = { move: jest.fn(), label: 'vertex' }
|
|
263
263
|
useApp.mockReturnValue(buildAppState({ interfaceType: 'keyboard', nudgeStepSize: 'large' }))
|
|
264
|
-
render(<
|
|
264
|
+
render(<MapControls />)
|
|
265
265
|
fireEvent.keyDown(screen.getByRole('button', { name: 'Move up' }), { key: 'ArrowUp', shiftKey: true })
|
|
266
266
|
expect(mapProvider.activeMoveTarget.move).toHaveBeenCalledWith(0, -1, false)
|
|
267
267
|
})
|
|
268
268
|
|
|
269
269
|
it('arrow key without shift still follows the Precision toggle as before', () => {
|
|
270
270
|
useApp.mockReturnValue(buildAppState({ interfaceType: 'keyboard', nudgeStepSize: 'large' }))
|
|
271
|
-
render(<
|
|
271
|
+
render(<MapControls />)
|
|
272
272
|
fireEvent.keyDown(screen.getByRole('button', { name: 'Move right' }), { key: 'ArrowRight' })
|
|
273
273
|
expect(mapProvider.panBy).toHaveBeenCalledWith([100, 0])
|
|
274
274
|
expect(announce).toHaveBeenCalledWith('Moved right')
|
|
@@ -276,11 +276,11 @@ describe('MoveControls', () => {
|
|
|
276
276
|
})
|
|
277
277
|
|
|
278
278
|
it('has a stable "Precision" label regardless of state', () => {
|
|
279
|
-
const { rerender } = render(<
|
|
279
|
+
const { rerender } = render(<MapControls />)
|
|
280
280
|
expect(screen.getByRole('button', { name: 'Precision' })).toBeInTheDocument()
|
|
281
281
|
|
|
282
282
|
useApp.mockReturnValue(buildAppState({ nudgeStepSize: 'small' }))
|
|
283
|
-
rerender(<
|
|
283
|
+
rerender(<MapControls />)
|
|
284
284
|
expect(screen.getByRole('button', { name: 'Precision' })).toBeInTheDocument()
|
|
285
285
|
})
|
|
286
286
|
|
|
@@ -294,29 +294,29 @@ describe('MoveControls', () => {
|
|
|
294
294
|
return document.getElementById(button.getAttribute('aria-labelledby'))
|
|
295
295
|
}
|
|
296
296
|
|
|
297
|
-
const { rerender } = render(<
|
|
297
|
+
const { rerender } = render(<MapControls />)
|
|
298
298
|
let tooltip = getOwnTooltip()
|
|
299
299
|
expect(tooltip.querySelector('[aria-hidden="true"]')).toHaveTextContent('(Off)')
|
|
300
300
|
expect(tooltip).toHaveTextContent('Precision (Off)')
|
|
301
301
|
|
|
302
302
|
useApp.mockReturnValue(buildAppState({ nudgeStepSize: 'small' }))
|
|
303
|
-
rerender(<
|
|
303
|
+
rerender(<MapControls />)
|
|
304
304
|
tooltip = getOwnTooltip()
|
|
305
305
|
expect(tooltip.querySelector('[aria-hidden="true"]')).toHaveTextContent('(On)')
|
|
306
306
|
expect(tooltip).toHaveTextContent('Precision (On)')
|
|
307
307
|
})
|
|
308
308
|
|
|
309
309
|
it('reflects precision mode via aria-pressed, not via label changes', () => {
|
|
310
|
-
const { rerender } = render(<
|
|
310
|
+
const { rerender } = render(<MapControls />)
|
|
311
311
|
expect(screen.getByRole('button', { name: 'Precision' })).toHaveAttribute('aria-pressed', 'false')
|
|
312
312
|
|
|
313
313
|
useApp.mockReturnValue(buildAppState({ nudgeStepSize: 'small' }))
|
|
314
|
-
rerender(<
|
|
314
|
+
rerender(<MapControls />)
|
|
315
315
|
expect(screen.getByRole('button', { name: 'Precision' })).toHaveAttribute('aria-pressed', 'true')
|
|
316
316
|
})
|
|
317
317
|
|
|
318
318
|
it('toggles precision on and announces it when currently in large-step mode', () => {
|
|
319
|
-
render(<
|
|
319
|
+
render(<MapControls />)
|
|
320
320
|
fireEvent.click(screen.getByRole('button', { name: 'Precision' }))
|
|
321
321
|
expect(dispatch).toHaveBeenCalledWith({ type: 'TOGGLE_NUDGE_STEP' })
|
|
322
322
|
expect(announce).toHaveBeenCalledWith('Precision on')
|
|
@@ -324,7 +324,7 @@ describe('MoveControls', () => {
|
|
|
324
324
|
|
|
325
325
|
it('toggles precision off and announces it when currently in small-step mode', () => {
|
|
326
326
|
useApp.mockReturnValue(buildAppState({ nudgeStepSize: 'small' }))
|
|
327
|
-
render(<
|
|
327
|
+
render(<MapControls />)
|
|
328
328
|
fireEvent.click(screen.getByRole('button', { name: 'Precision' }))
|
|
329
329
|
expect(dispatch).toHaveBeenCalledWith({ type: 'TOGGLE_NUDGE_STEP' })
|
|
330
330
|
expect(announce).toHaveBeenCalledWith('Precision off')
|
|
@@ -67,11 +67,11 @@ export const Markers = () => {
|
|
|
67
67
|
const handleSetActive = ({ id: markerId }) => setActiveMarkerId(markerId)
|
|
68
68
|
eventBus.on('interact:active', handleActive)
|
|
69
69
|
eventBus.on('interact:selectionchange', handleSelectionChange)
|
|
70
|
-
eventBus.on(EVENTS.
|
|
70
|
+
eventBus.on(EVENTS.MAP_SET_ACTIVE_ITEM, handleSetActive)
|
|
71
71
|
return () => {
|
|
72
72
|
eventBus.off('interact:active', handleActive)
|
|
73
73
|
eventBus.off('interact:selectionchange', handleSelectionChange)
|
|
74
|
-
eventBus.off(EVENTS.
|
|
74
|
+
eventBus.off(EVENTS.MAP_SET_ACTIVE_ITEM, handleSetActive)
|
|
75
75
|
}
|
|
76
76
|
}, [eventBus])
|
|
77
77
|
|
|
@@ -20,9 +20,9 @@ const SVG_SEL = 'svg'
|
|
|
20
20
|
const makeEventBus = () => {
|
|
21
21
|
const listeners = {}
|
|
22
22
|
return {
|
|
23
|
-
on: jest.fn((
|
|
23
|
+
on: jest.fn((eventName, fn) => { listeners[eventName] = fn }),
|
|
24
24
|
off: jest.fn(),
|
|
25
|
-
emit: (
|
|
25
|
+
emit: (eventName, payload) => listeners[eventName]?.(payload)
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
|
|
@@ -170,7 +170,7 @@ describe('Markers — selection', () => {
|
|
|
170
170
|
})
|
|
171
171
|
|
|
172
172
|
it('calls resolveActive when the marker is the active listbox item', () => {
|
|
173
|
-
const SET_ACTIVE = 'map:
|
|
173
|
+
const SET_ACTIVE = 'map:setactiveitem'
|
|
174
174
|
const sr = makeSymbolRegistry({ resolveActive: jest.fn(() => '<circle class="active"/>') })
|
|
175
175
|
const { eb } = setup({ markers: [makeMarker()], symbolRegistry: sr })
|
|
176
176
|
act(() => eb.emit(SET_ACTIVE, { id: MARKER_ID }))
|
|
@@ -3,7 +3,7 @@ import { stringToKebab } from '../../../utils/stringToKebab.js'
|
|
|
3
3
|
const SymbolMarker = ({ marker, mapId, markerRef, isSelected, symbolProps }) => { // NOSONAR: project does not use PropTypes
|
|
4
4
|
const { resolvedSvg, viewBox, anchor, shapeId, scaledWidth, scaledHeight } = symbolProps
|
|
5
5
|
return (
|
|
6
|
-
<svg
|
|
6
|
+
<svg
|
|
7
7
|
ref={markerRef(marker.id)}
|
|
8
8
|
id={`${mapId}-marker-${marker.id}`}
|
|
9
9
|
className={[
|
|
@@ -15,8 +15,7 @@ const SymbolMarker = ({ marker, mapId, markerRef, isSelected, symbolProps }) =>
|
|
|
15
15
|
height={scaledHeight}
|
|
16
16
|
viewBox={viewBox}
|
|
17
17
|
overflow='visible'
|
|
18
|
-
|
|
19
|
-
aria-label={marker.label || 'Map marker'}
|
|
18
|
+
aria-hidden='true'
|
|
20
19
|
style={{
|
|
21
20
|
display: marker.isVisible ? 'block' : 'none',
|
|
22
21
|
marginLeft: `${-anchor[0] * scaledWidth}px`,
|
|
@@ -19,19 +19,18 @@ describe('SymbolMarker', () => {
|
|
|
19
19
|
expect(container.querySelector('svg').getAttribute('id')).toBe('my-map-marker-marker-1')
|
|
20
20
|
})
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
// Decorative: the ancestor markers layer is aria-hidden, and SpatialList (the accessible
|
|
23
|
+
// spatial listbox) is the sole accessible surface for a marker's label — see SpatialList.jsx.
|
|
24
|
+
it('is aria-hidden', () => {
|
|
23
25
|
const { container } = render(<SymbolMarker marker={makeMarker()} mapId='map' markerRef={markerRef} isSelected={false} symbolProps={makeSymbolProps()} />)
|
|
24
|
-
expect(container.querySelector('svg').getAttribute('
|
|
26
|
+
expect(container.querySelector('svg').getAttribute('aria-hidden')).toBe('true')
|
|
25
27
|
})
|
|
26
28
|
|
|
27
|
-
it('aria-label
|
|
29
|
+
it('has no role or aria-label, regardless of marker.label', () => {
|
|
28
30
|
const { container } = render(<SymbolMarker marker={makeMarker({ label: 'My location' })} mapId='map' markerRef={markerRef} isSelected={false} symbolProps={makeSymbolProps()} />)
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
it('aria-label falls back to Map marker when no label', () => {
|
|
33
|
-
const { container } = render(<SymbolMarker marker={makeMarker()} mapId='map' markerRef={markerRef} isSelected={false} symbolProps={makeSymbolProps()} />)
|
|
34
|
-
expect(container.querySelector('svg').getAttribute('aria-label')).toBe('Map marker')
|
|
31
|
+
const svg = container.querySelector('svg')
|
|
32
|
+
expect(svg.getAttribute('role')).toBeNull()
|
|
33
|
+
expect(svg.getAttribute('aria-label')).toBeNull()
|
|
35
34
|
})
|
|
36
35
|
|
|
37
36
|
it('applies shapeId class', () => {
|