@defra/interactive-map 0.0.52-alpha → 0.0.54-alpha

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (194) hide show
  1. package/dist/css/index.css +1 -1
  2. package/dist/esm/im-core.js +1 -1
  3. package/dist/esm/im-shell.js +1 -1
  4. package/dist/umd/im-core.js +1 -1
  5. package/dist/umd/index.js +1 -1
  6. package/docs/api/context.md +30 -12
  7. package/docs/api/marker-config.md +16 -8
  8. package/docs/api/symbol-config.md +24 -9
  9. package/docs/api/symbol-registry.md +49 -14
  10. package/docs/api.md +11 -3
  11. package/docs/plugins/datasets.md +6 -10
  12. package/docs/plugins/draw.md +2 -1
  13. package/docs/plugins/map-key.md +47 -4
  14. package/package.json +1 -1
  15. package/plugins/beta/map-styles/dist/esm/im-map-styles-plugin.js +1 -1
  16. package/plugins/beta/map-styles/dist/umd/im-map-styles-plugin.js +1 -1
  17. package/plugins/beta/map-styles/dist/umd/index.js +1 -1
  18. package/plugins/datasets/dist/esm/im-datasets-ml-adapter.js +1 -1
  19. package/plugins/datasets/dist/esm/im-datasets-ol-adapter.js +1 -1
  20. package/plugins/datasets/dist/esm/im-datasets-plugin.js +1 -1
  21. package/plugins/datasets/dist/esm/mapboxStyleLayerAdapter.js +1 -1
  22. package/plugins/datasets/dist/umd/im-datasets-ml-adapter.js +1 -1
  23. package/plugins/datasets/dist/umd/im-datasets-ol-adapter.js +1 -1
  24. package/plugins/datasets/dist/umd/im-datasets-plugin.js +1 -1
  25. package/plugins/datasets/src/adapters/esri/esriLayerAdapter.js +6 -6
  26. package/plugins/datasets/src/adapters/esri/registry/esriDataset.test.js +1 -1
  27. package/plugins/datasets/src/adapters/maplibre/layerBuilders.js +10 -10
  28. package/plugins/datasets/src/adapters/maplibre/layerBuilders.test.js +22 -6
  29. package/plugins/datasets/src/adapters/maplibre/maplibreLayerAdapter.js +9 -3
  30. package/plugins/datasets/src/adapters/maplibre/maplibreLayerAdapter.test.js +18 -3
  31. package/plugins/datasets/src/adapters/maplibre/registry/mapLibreDataset.js +3 -3
  32. package/plugins/datasets/src/adapters/maplibre/registry/mapLibreDataset.test.js +20 -27
  33. package/plugins/datasets/src/adapters/openlayers/canvasPatternStyle.js +16 -70
  34. package/plugins/datasets/src/adapters/openlayers/canvasPatternStyle.test.js +30 -115
  35. package/plugins/datasets/src/adapters/openlayers/layerBuilders.js +11 -13
  36. package/plugins/datasets/src/adapters/openlayers/layerBuilders.test.js +11 -3
  37. package/plugins/datasets/src/adapters/openlayers/openlayersLayerAdapter.js +48 -19
  38. package/plugins/datasets/src/adapters/openlayers/openlayersLayerAdapter.test.js +101 -13
  39. package/plugins/datasets/src/adapters/openlayers/registry/openLayersDataset.js +27 -28
  40. package/plugins/datasets/src/adapters/openlayers/registry/openLayersDataset.test.js +51 -32
  41. package/plugins/datasets/src/fetch/createDynamicSource.js +2 -2
  42. package/plugins/datasets/src/initialise/DatasetsInit.jsx +2 -2
  43. package/plugins/datasets/src/initialise/defaults.js +16 -27
  44. package/plugins/datasets/src/initialise/defaults.test.js +25 -57
  45. package/plugins/datasets/src/initialise/initialiseDatasets.js +1 -4
  46. package/plugins/datasets/src/reducers/__data__/demoDatasets.js +1 -3
  47. package/plugins/datasets/src/reducers/mappedDatasetsReducer.test.js +1 -1
  48. package/plugins/datasets/src/registry/dataset.js +23 -17
  49. package/plugins/datasets/src/registry/dataset.test.js +114 -11
  50. package/plugins/datasets/src/registry/mapboxStyleDataset.js +1 -1
  51. package/plugins/datasets/src/registry/mapboxStyleDataset.test.js +1 -1
  52. package/plugins/draw/dist/esm/im-draw-ml-adapter.js +1 -1
  53. package/plugins/draw/dist/esm/im-draw-ol-adapter.js +1 -1
  54. package/plugins/draw/dist/esm/im-draw-plugin.js +1 -1
  55. package/plugins/draw/dist/esm/index.js +1 -1
  56. package/plugins/draw/dist/esm/liveDrawChecks.js +1 -1
  57. package/plugins/draw/dist/umd/im-draw-ml-adapter.js +1 -1
  58. package/plugins/draw/dist/umd/im-draw-ol-adapter.js +1 -1
  59. package/plugins/draw/dist/umd/im-draw-plugin.js +1 -1
  60. package/plugins/draw/dist/umd/index.js +1 -1
  61. package/plugins/draw/src/DrawInit.jsx +7 -5
  62. package/plugins/draw/src/DrawInit.test.jsx +18 -2
  63. package/plugins/draw/src/adapters/maplibre/MaplibreDrawAdapter.js +11 -5
  64. package/plugins/draw/src/adapters/maplibre/MaplibreDrawAdapter.test.js +27 -11
  65. package/plugins/draw/src/adapters/maplibre/mapboxDraw.js +12 -9
  66. package/plugins/draw/src/adapters/maplibre/mapboxDraw.test.js +18 -0
  67. package/plugins/draw/src/adapters/maplibre/pointSymbolImages.js +81 -56
  68. package/plugins/draw/src/adapters/maplibre/pointSymbolImages.test.js +149 -80
  69. package/plugins/draw/src/adapters/openlayers/OLDrawAdapter.js +7 -6
  70. package/plugins/draw/src/adapters/openlayers/OLDrawAdapter.test.js +22 -25
  71. package/plugins/draw/src/adapters/openlayers/core/OLDrawManager.js +26 -8
  72. package/plugins/draw/src/adapters/openlayers/core/OLDrawManager.test.js +58 -16
  73. package/plugins/draw/src/adapters/openlayers/core/styles.js +33 -20
  74. package/plugins/draw/src/adapters/openlayers/core/styles.test.js +47 -21
  75. package/plugins/draw/src/adapters/openlayers/olDraw.js +16 -12
  76. package/plugins/draw/src/adapters/openlayers/olDraw.test.js +27 -32
  77. package/plugins/draw/src/adapters/openlayers/point/pointSymbolImages.js +44 -49
  78. package/plugins/draw/src/adapters/openlayers/point/pointSymbolImages.test.js +100 -119
  79. package/plugins/draw/src/defaults.js +2 -6
  80. package/plugins/draw/src/utils/stripInternalProperties.test.js +2 -1
  81. package/plugins/draw/src/utils/symbolKeys.js +3 -4
  82. package/plugins/interact/dist/esm/im-interact-plugin.js +1 -1
  83. package/plugins/interact/dist/umd/im-interact-plugin.js +1 -1
  84. package/plugins/interact/dist/umd/index.js +1 -1
  85. package/plugins/map-key/dist/css/index.css +1 -1
  86. package/plugins/map-key/dist/esm/im-map-key-plugin.js +1 -1
  87. package/plugins/map-key/dist/umd/im-map-key-plugin.js +1 -2
  88. package/plugins/map-key/dist/umd/index.js +1 -1
  89. package/plugins/map-key/src/components/Key/Key.jsx +8 -4
  90. package/plugins/map-key/src/components/Key/Key.module.scss +144 -53
  91. package/plugins/map-key/src/components/Key/KeyGroupItem.jsx +36 -3
  92. package/plugins/map-key/src/components/Key/KeyGroupItem.test.jsx +44 -2
  93. package/plugins/map-key/src/components/Key/KeyItem.jsx +2 -2
  94. package/plugins/map-key/src/components/Key/KeySvg.jsx +19 -18
  95. package/plugins/map-key/src/components/Key/KeySvg.test.jsx +25 -18
  96. package/plugins/map-key/src/components/Key/KeySvgPattern.jsx +1 -2
  97. package/plugins/map-key/src/components/Key/KeySvgPattern.test.jsx +3 -1
  98. package/plugins/map-key/src/components/Key/KeySvgRamp.jsx +35 -6
  99. package/plugins/map-key/src/components/Key/KeySvgRamp.test.jsx +56 -16
  100. package/plugins/map-key/src/components/Key/KeySvgSymbol.jsx +26 -12
  101. package/plugins/map-key/src/components/Key/KeySvgSymbol.test.jsx +24 -74
  102. package/plugins/map-key/src/components/Key/MapKey.jsx +3 -1
  103. package/plugins/map-key/src/components/Key/svgProperties.js +8 -2
  104. package/plugins/map-key/src/components/Key/useRampOrientation.js +61 -0
  105. package/plugins/map-key/src/components/Key/useRampOrientation.test.jsx +155 -0
  106. package/plugins/map-key/src/index.js +34 -0
  107. package/plugins/map-key/src/reducers/mergeKeyGroupItems.test.js +15 -0
  108. package/plugins/map-key/src/registry/index.js +0 -2
  109. package/plugins/map-key/src/registry/index.test.js +1 -9
  110. package/plugins/map-key/src/utils/groupStyles.js +5 -2
  111. package/plugins/menu/src/registry/index.js +0 -2
  112. package/plugins/menu/src/registry/index.test.js +1 -9
  113. package/plugins/search/dist/esm/im-search-plugin.js +1 -1
  114. package/plugins/search/dist/umd/im-search-plugin.js +1 -1
  115. package/plugins/search/dist/umd/index.js +1 -1
  116. package/plugins/search/src/Search.jsx +0 -1
  117. package/plugins/search/src/components/Form/Form.jsx +3 -3
  118. package/plugins/search/src/components/Suggestions/Suggestions.jsx +2 -0
  119. package/plugins/search/src/components/Suggestions/Suggestions.test.jsx +6 -0
  120. package/plugins/search/src/defaults.js +3 -0
  121. package/plugins/search/src/events/formHandlers.js +3 -9
  122. package/plugins/search/src/events/formHandlers.test.js +6 -9
  123. package/plugins/search/src/events/inputHandlers.js +8 -2
  124. package/plugins/search/src/events/inputHandlers.test.js +20 -0
  125. package/plugins/search/src/events/suggestionHandlers.js +3 -5
  126. package/plugins/search/src/events/suggestionHandlers.test.js +5 -8
  127. package/plugins/search/src/utils/showResult.js +9 -0
  128. package/plugins/search/src/utils/showResult.test.js +16 -0
  129. package/providers/beta/esri/dist/esm/im-esri-provider.js +1 -1
  130. package/providers/beta/openlayers/dist/esm/im-openlayers-provider.js +1 -1
  131. package/providers/beta/openlayers/dist/umd/im-openlayers-provider.js +1 -1
  132. package/providers/beta/openlayers/dist/umd/index.js +1 -1
  133. package/providers/beta/openlayers/src/openlayersProvider.js +102 -2
  134. package/providers/beta/openlayers/src/openlayersProvider.test.js +95 -0
  135. package/providers/beta/openlayers/src/utils/highlightFeatures.js +20 -25
  136. package/providers/beta/openlayers/src/utils/highlightFeatures.test.js +73 -38
  137. package/providers/beta/openlayers/src/utils/patternImages.js +61 -0
  138. package/providers/beta/openlayers/src/utils/patternImages.test.js +74 -0
  139. package/providers/beta/openlayers/src/utils/symbolImages.js +103 -95
  140. package/providers/beta/openlayers/src/utils/symbolImages.test.js +136 -85
  141. package/providers/mapProvider.js +53 -1
  142. package/providers/mapProvider.test.js +6 -0
  143. package/providers/maplibre/dist/esm/im-maplibre-provider.js +1 -1
  144. package/providers/maplibre/dist/umd/im-maplibre-provider.js +1 -1
  145. package/providers/maplibre/dist/umd/index.js +1 -1
  146. package/providers/maplibre/src/maplibreProvider.js +50 -17
  147. package/providers/maplibre/src/maplibreProvider.test.js +74 -20
  148. package/providers/maplibre/src/utils/highlightFeatures.js +19 -14
  149. package/providers/maplibre/src/utils/highlightFeatures.test.js +20 -14
  150. package/providers/maplibre/src/utils/patternImages.js +46 -29
  151. package/providers/maplibre/src/utils/patternImages.test.js +52 -4
  152. package/providers/maplibre/src/utils/symbolImages.js +80 -39
  153. package/providers/maplibre/src/utils/symbolImages.test.js +157 -54
  154. package/src/App/components/Hints/Hints.module.scss +1 -1
  155. package/src/App/components/Markers/Markers.jsx +16 -25
  156. package/src/App/components/Markers/Markers.test.jsx +34 -48
  157. package/src/App/components/Markers/SymbolLabelMarker.jsx +1 -1
  158. package/src/App/components/Markers/SymbolMarker.jsx +1 -1
  159. package/src/App/components/Viewport/Viewport.jsx +6 -4
  160. package/src/App/components/Viewport/Viewport.test.jsx +18 -1
  161. package/src/App/hooks/useMapAnnouncements.js +7 -2
  162. package/src/App/hooks/useMapAnnouncements.test.js +13 -2
  163. package/src/App/hooks/useModalPanelBehaviour.js +3 -1
  164. package/src/App/initialiseApp.js +1 -1
  165. package/src/App/store/ServiceProvider.jsx +12 -3
  166. package/src/App/store/ServiceProvider.test.jsx +39 -0
  167. package/src/InteractiveMap/InteractiveMap.js +3 -3
  168. package/src/config/appConfig.js +1 -5
  169. package/src/config/mapSizeScales.js +8 -0
  170. package/src/config/symbolConfig.js +101 -25
  171. package/src/services/mapFocus.js +64 -0
  172. package/src/services/mapFocus.test.js +76 -0
  173. package/src/services/patternRegistry.js +97 -76
  174. package/src/services/patternRegistry.test.js +19 -1
  175. package/src/services/symbolComposer.js +184 -0
  176. package/src/services/symbolComposer.test.js +132 -0
  177. package/src/services/symbolRegistry.js +326 -155
  178. package/src/services/symbolRegistry.test.js +334 -32
  179. package/src/types.js +11 -5
  180. package/src/utils/detectInterfaceType.js +16 -5
  181. package/src/utils/detectInterfaceType.test.js +32 -0
  182. package/src/utils/hashString.js +23 -0
  183. package/src/utils/hashString.test.js +29 -0
  184. package/src/utils/imageDataCache.js +43 -0
  185. package/src/utils/imageDataCache.test.js +38 -0
  186. package/src/utils/pathBounds.js +330 -0
  187. package/src/utils/pathBounds.test.js +145 -0
  188. package/src/utils/patternUtils.js +0 -8
  189. package/src/utils/patternUtils.test.js +0 -25
  190. package/src/utils/recentImageSets.js +35 -0
  191. package/src/utils/recentImageSets.test.js +46 -0
  192. package/src/utils/symbolUtils.js +26 -29
  193. package/src/utils/symbolUtils.test.js +27 -41
  194. package/plugins/map-key/dist/umd/im-map-key-plugin.js.LICENSE.txt +0 -1
@@ -26,11 +26,11 @@ const makeEventBus = () => {
26
26
  }
27
27
  }
28
28
 
29
+ // Stands in for the registry: every marker resolves to a 38×38 symbol anchored at its bottom centre
29
30
  const makeSymbolRegistry = (overrides = {}) => ({
30
- get: jest.fn(() => ({ svg: '<circle/>', viewBox: '0 0 38 38', anchor: [0.5, 1] })),
31
- getDefaults: jest.fn(() => ({ symbol: 'pin', viewBox: '0 0 38 38', anchor: [0.5, 1] })),
32
- resolve: jest.fn(() => '<circle/>'),
33
- resolveSelected: jest.fn(() => '<circle class="selected"/>'),
31
+ getDefaults: jest.fn(() => ({ symbol: 'pin' })),
32
+ getMarkerSymbolDef: jest.fn(() => ({ svg: '<circle/>', viewBox: '0 0 38 38', anchor: [0.5, 1] })),
33
+ resolveVariant: jest.fn((symbolDef, styleValues, mapStyle, variant) => `<circle class="${variant}"/>`),
34
34
  ...overrides
35
35
  })
36
36
 
@@ -76,7 +76,7 @@ describe('Markers — basic rendering', () => {
76
76
 
77
77
  describe('Markers — routing', () => {
78
78
  it('renders a LabelMarker for a marker with symbol: null', () => {
79
- const marker = makeMarker({ id: 'lbl', label: 'My label', symbol: null, symbolSvgContent: null })
79
+ const marker = makeMarker({ id: 'lbl', label: 'My label', symbol: null, svgContent: null })
80
80
  const { result } = setup({ markers: [marker] })
81
81
  const wrapper = result.container.querySelector('.im-c-marker-wrapper--label')
82
82
  expect(wrapper).toBeTruthy()
@@ -103,42 +103,30 @@ describe('Markers — routing', () => {
103
103
  // ─── Markers — symbol resolution ─────────────────────────────────────────────
104
104
 
105
105
  describe('Markers — symbol resolution', () => {
106
- it('uses inline symbolSvgContent over the symbol registry', () => {
107
- const sr = makeSymbolRegistry()
108
- setup({ markers: [makeMarker({ symbolSvgContent: '<rect/>' })], symbolRegistry: sr })
109
- expect(sr.get).not.toHaveBeenCalled()
106
+ it('asks the registry for the marker\'s symbol definition', () => {
107
+ const marker = makeMarker({ size: 'large', viewBox: '0 0 50 60' })
108
+ const { sr } = setup({ markers: [marker] })
109
+ expect(sr.getMarkerSymbolDef).toHaveBeenCalledWith(marker)
110
110
  })
111
111
 
112
- it('falls back to defaults.symbolSvgContent', () => {
113
- const sr = makeSymbolRegistry({
114
- getDefaults: jest.fn(() => ({ symbolSvgContent: '<default-svg/>', viewBox: '0 0 38 38', anchor: [0.5, 1] }))
115
- })
116
- setup({ markers: [makeMarker({ symbol: null })], symbolRegistry: sr })
117
- expect(sr.get).not.toHaveBeenCalled()
112
+ it('renders at the definition\'s viewBox and anchor, and keeps marker options out of the style values', () => {
113
+ const sr = makeSymbolRegistry({ getMarkerSymbolDef: jest.fn(() => ({ svg: '<circle/>', viewBox: '0 0 30 40', anchor: [0.5, 1] })) })
114
+ const { result } = setup({ markers: [makeMarker({ size: 'large', anchor: [0, 0], backgroundColor: '#123456' })], symbolRegistry: sr })
115
+ const svg = result.container.querySelector(SVG_SEL)
116
+ expect(svg.getAttribute('width')).toBe('30')
117
+ expect(svg.getAttribute('height')).toBe('40')
118
+ expect(svg).toHaveStyle({ marginLeft: '-15px', marginTop: '-40px' })
119
+ const styleValues = sr.resolveVariant.mock.calls[0][1]
120
+ expect(styleValues).toEqual({ backgroundColor: '#123456' })
118
121
  })
119
122
 
120
- it('uses marker.viewBox when provided', () => {
121
- const svg = setup({ markers: [makeMarker({ viewBox: '0 0 50 60' })] }).result.container.querySelector(SVG_SEL)
122
- expect(svg.getAttribute('viewBox')).toBe('0 0 50 60')
123
- expect(svg.getAttribute('width')).toBe('50')
124
- expect(svg.getAttribute('height')).toBe('60')
125
- })
126
-
127
- it("falls back to '0 0 44 44' viewBox when none is provided", () => {
128
- const sr = makeSymbolRegistry({
129
- get: jest.fn(() => ({ svg: '<circle/>' })),
130
- getDefaults: jest.fn(() => ({ symbol: 'pin' }))
131
- })
132
- expect(setup({ markers: [makeMarker()], symbolRegistry: sr }).result.container.querySelector(SVG_SEL).getAttribute('viewBox')).toBe('0 0 44 44')
133
- })
134
-
135
- it.each([
136
- ['marker.anchor', makeMarker({ anchor: [0, 0] }), null, '0px', '0px'],
137
- ['symbolDef.anchor', makeMarker(), { get: jest.fn(() => ({ svg: '<circle/>', viewBox: '0 0 38 38', anchor: [0, 0.5] })), getDefaults: jest.fn(() => ({ symbol: 'pin', viewBox: '0 0 38 38' })) }, '0px', '-19px'],
138
- ['[0.5, 0.5] fallback', makeMarker(), { get: jest.fn(() => ({ svg: '<circle/>', viewBox: '0 0 38 38' })), getDefaults: jest.fn(() => ({ symbol: 'pin', viewBox: '0 0 38 38' })) }, '-19px', '-19px']
139
- ])('resolveAnchor uses %s', (_, marker, srOverrides, left, top) => {
140
- const sr = srOverrides ? makeSymbolRegistry(srOverrides) : null
141
- expect(setup({ markers: [marker], symbolRegistry: sr }).result.container.querySelector(SVG_SEL)).toHaveStyle({ marginLeft: left, marginTop: top })
123
+ it('falls back to a centred 44×44 viewBox for a marker with no known symbol', () => {
124
+ const sr = makeSymbolRegistry({ getMarkerSymbolDef: jest.fn(() => undefined) })
125
+ const { result } = setup({ markers: [makeMarker({ symbol: 'not-registered' })], symbolRegistry: sr })
126
+ const svg = result.container.querySelector(SVG_SEL)
127
+ expect(sr.resolveVariant).toHaveBeenCalledWith(undefined, expect.any(Object), 'outdoor', 'normal')
128
+ expect(svg.getAttribute('viewBox')).toBe('0 0 44 44')
129
+ expect(svg).toHaveStyle({ marginLeft: '-22px', marginTop: '-22px' })
142
130
  })
143
131
 
144
132
  it.each([
@@ -161,27 +149,25 @@ describe('Markers — symbol resolution', () => {
161
149
  // ─── Markers — selection ──────────────────────────────────────────────────────
162
150
 
163
151
  describe('Markers — selection', () => {
164
- it('adds selected class and calls resolveSelected when marker is selected', () => {
152
+ it('adds selected class and resolves the selected variant when marker is selected', () => {
165
153
  const { eb, sr, result } = setup({ markers: [makeMarker()] })
166
154
  act(() => eb.emit(SEL_CHANGE, { selectedMarkers: [MARKER_ID] }))
167
155
  expect(result.container.querySelector(SVG_SEL)).toHaveClass(SELECTED_CLASS)
168
- expect(sr.resolveSelected).toHaveBeenCalled()
169
- expect(sr.resolve).not.toHaveBeenCalledAfter?.(sr.resolveSelected)
156
+ expect(sr.resolveVariant).toHaveBeenLastCalledWith(expect.anything(), expect.any(Object), 'outdoor', 'selected')
170
157
  })
171
158
 
172
- it('calls resolveActive when the marker is the active listbox item', () => {
159
+ it('resolves the active variant for the active listbox item, even when selected', () => {
173
160
  const SET_ACTIVE = 'map:setactiveitem'
174
- const sr = makeSymbolRegistry({ resolveActive: jest.fn(() => '<circle class="active"/>') })
175
- const { eb } = setup({ markers: [makeMarker()], symbolRegistry: sr })
161
+ const { eb, sr } = setup({ markers: [makeMarker()] })
162
+ act(() => eb.emit(SEL_CHANGE, { selectedMarkers: [MARKER_ID] }))
176
163
  act(() => eb.emit(SET_ACTIVE, { id: MARKER_ID }))
177
- expect(sr.resolveActive).toHaveBeenCalled()
178
- expect(sr.resolveSelected).not.toHaveBeenCalled()
164
+ expect(sr.resolveVariant).toHaveBeenLastCalledWith(expect.anything(), expect.any(Object), 'outdoor', 'active')
179
165
  })
180
166
 
181
- it('uses resolve (not resolveSelected) for unselected markers', () => {
167
+ it('resolves the normal variant for unselected markers', () => {
182
168
  const { sr } = setup({ markers: [makeMarker()] })
183
- expect(sr.resolve).toHaveBeenCalled()
184
- expect(sr.resolveSelected).not.toHaveBeenCalled()
169
+ expect(sr.resolveVariant).toHaveBeenCalledWith(expect.anything(), expect.any(Object), 'outdoor', 'normal')
170
+ expect(sr.resolveVariant).not.toHaveBeenCalledWith(expect.anything(), expect.any(Object), 'outdoor', 'selected')
185
171
  })
186
172
 
187
173
  it.each([
@@ -28,7 +28,7 @@ const SymbolLabelMarker = ({ marker, mapId, markerRef, isSelected, symbolProps }
28
28
  width={scaledWidth}
29
29
  height={scaledHeight}
30
30
  viewBox={viewBox}
31
- overflow='visible'
31
+ overflow='hidden'
32
32
  aria-hidden='true'
33
33
  >
34
34
  <g dangerouslySetInnerHTML={{ __html: resolvedSvg }} />
@@ -14,7 +14,7 @@ const SymbolMarker = ({ marker, mapId, markerRef, isSelected, symbolProps }) =>
14
14
  width={scaledWidth}
15
15
  height={scaledHeight}
16
16
  viewBox={viewBox}
17
- overflow='visible'
17
+ overflow='hidden'
18
18
  aria-hidden='true'
19
19
  style={{
20
20
  display: marker.isVisible ? 'block' : 'none',
@@ -22,7 +22,7 @@ export const Viewport = () => {
22
22
  const { id, mapProvider, mapLabel, keyboardHintText, focusOnMount } = useConfig()
23
23
  const { layoutRefs, safeZoneInset, dispatch } = useApp()
24
24
  const { mapSize, isMapReady } = useMap()
25
- const { eventBus, hints } = useService()
25
+ const { eventBus, hints, mapFocus } = useService()
26
26
 
27
27
  const mapContainerRef = useRef(null)
28
28
  const spatialListRef = useRef(null)
@@ -75,7 +75,7 @@ export const Viewport = () => {
75
75
  return (
76
76
  <>
77
77
  <MapController mapContainerRef={mapContainerRef} />
78
- <div
78
+ <div // NOSONAR - role="application" is interactive: the map handles its own keyboard and pointer input
79
79
  id={`${id}-viewport`}
80
80
  className={`im-c-viewport im-c-viewport--${mapSize}`}
81
81
  aria-label={mapLabel}
@@ -83,10 +83,12 @@ export const Viewport = () => {
83
83
  tabIndex='0' // nosonar
84
84
  data-map-keyboard-scope
85
85
  onFocus={handleFocus}
86
- onBlur={handleBlur}
86
+ onBlur={(event) => { handleBlur(event); mapFocus.clear() }}
87
+ onKeyDown={() => mapFocus.releaseAnnouncements()}
88
+ onPointerDown={() => mapFocus.releaseAnnouncements()}
87
89
  ref={layoutRefs.viewportRef}
88
90
  aria-describedby={`${id}-keyboard-desc`}
89
- aria-controls={`${id}-features`}
91
+ aria-controls={`${id}-spatial-list`}
90
92
  >
91
93
  <div className='im-c-viewport__map-container' ref={mapContainerRef} aria-hidden='true' />
92
94
  <MapStatus />
@@ -46,7 +46,8 @@ function setupHookMocks (mainEl, viewportEl) {
46
46
  useService.mockReturnValue({
47
47
  announce: jest.fn(),
48
48
  hints: { show: jest.fn(), dismiss: jest.fn(), subscribe: jest.fn(() => jest.fn()) },
49
- eventBus: { on: jest.fn(), off: jest.fn(), emit: jest.fn() }
49
+ eventBus: { on: jest.fn(), off: jest.fn(), emit: jest.fn() },
50
+ mapFocus: { clear: jest.fn(), releaseAnnouncements: jest.fn() }
50
51
  })
51
52
  useKeyboardHint.mockImplementation(({ onViewportFocusChange }) => ({
52
53
  handleFocus: () => onViewportFocusChange(true),
@@ -114,6 +115,22 @@ describe('Viewport rendering', () => {
114
115
  expect(viewport).toHaveAttribute('aria-describedby', 'test-map-keyboard-desc')
115
116
  })
116
117
 
118
+ it('restores the map label via mapFocus when the viewport loses focus', () => {
119
+ const { mapFocus } = useService()
120
+ const { viewport } = renderViewport()
121
+ fireEvent.blur(viewport)
122
+ expect(mapFocus.clear).toHaveBeenCalled()
123
+ })
124
+
125
+ it('releases held map announcements on a key or pointer press in the viewport', () => {
126
+ const { mapFocus } = useService()
127
+ const { viewport } = renderViewport()
128
+ fireEvent.keyDown(viewport, { key: 'ArrowUp' })
129
+ fireEvent.pointerDown(viewport)
130
+ expect(mapFocus.releaseAnnouncements).toHaveBeenCalledTimes(2)
131
+ expect(mapFocus.clear).not.toHaveBeenCalled()
132
+ })
133
+
117
134
  it('calls hints.show() with keyboardHintText when viewport gains keyboard focus', () => {
118
135
  const { hints } = useService()
119
136
  renderViewport()
@@ -40,7 +40,7 @@ const resolveMessage = (previous, current, mapProvider) => {
40
40
 
41
41
  export function useMapAnnouncements () {
42
42
  const { mapProvider } = useConfig()
43
- const { eventBus, announce } = useService()
43
+ const { eventBus, announce, mapFocus } = useService()
44
44
 
45
45
  useEffect(() => {
46
46
  const handleAnnounceStateUpdate = ({ previous, current }) => {
@@ -48,6 +48,11 @@ export function useMapAnnouncements () {
48
48
  return
49
49
  }
50
50
 
51
+ // A map focus message already describes this move
52
+ if (mapFocus.isHoldingAnnouncements()) {
53
+ return
54
+ }
55
+
51
56
  const message = resolveMessage(previous, current, mapProvider)
52
57
  if (message) {
53
58
  announce(message, 'action')
@@ -59,5 +64,5 @@ export function useMapAnnouncements () {
59
64
  return () => {
60
65
  eventBus.off(events.MAP_STATE_UPDATED, handleAnnounceStateUpdate)
61
66
  }
62
- }, [mapProvider, announce])
67
+ }, [mapProvider, announce, mapFocus])
63
68
  }
@@ -22,14 +22,15 @@ const setup = (overrides = {}) => {
22
22
  }
23
23
 
24
24
  useConfig.mockReturnValue({ mapProvider, ...overrides.config })
25
- useService.mockReturnValue({ announce, eventBus, ...overrides.service })
25
+ const mapFocus = { isHoldingAnnouncements: jest.fn(() => false) }
26
+ useService.mockReturnValue({ announce, eventBus, mapFocus, ...overrides.service })
26
27
 
27
28
  getMapStatusMessage.moved = jest.fn(() => 'Moved north')
28
29
  getMapStatusMessage.zoomed = jest.fn(() => 'Zoomed in')
29
30
  getMapStatusMessage.noChange = jest.fn(() => 'No change')
30
31
  getMapStatusMessage.newArea = jest.fn(() => 'New area')
31
32
 
32
- return { announce, mapProvider, eventBus }
33
+ return { announce, mapProvider, eventBus, mapFocus }
33
34
  }
34
35
 
35
36
  describe('useMapAnnouncements', () => {
@@ -50,6 +51,16 @@ describe('useMapAnnouncements', () => {
50
51
  expect(eventBus.off).toHaveBeenCalledWith('map:stateupdated', expect.any(Function))
51
52
  })
52
53
 
54
+ test('does not announce while a map focus message is holding announcements', () => {
55
+ const { announce, eventBus, mapFocus } = setup()
56
+ mapFocus.isHoldingAnnouncements.mockReturnValue(true)
57
+ renderHook(() => useMapAnnouncements())
58
+ const handler = eventBus.on.mock.calls[0][1]
59
+
60
+ handler({ previous: { center: [0, 0], zoom: 1 }, current: { center: [1, 1], zoom: 2 } })
61
+ expect(announce).not.toHaveBeenCalled()
62
+ })
63
+
53
64
  test('early returns when previous or current center is missing', () => {
54
65
  const { announce, eventBus } = setup()
55
66
  renderHook(() => useMapAnnouncements())
@@ -200,7 +200,9 @@ export function useModalPanelBehaviour ({
200
200
  }, [isModal, rootEl, handleClose])
201
201
 
202
202
  // === Inert everything outside the panel but within the app === //
203
- useEffect(() => {
203
+ // Layout effect so the cleanup restores aria-hidden at commit, before handleClose's
204
+ // requestAnimationFrame returns focus to the trigger (which sits inside an inerted branch).
205
+ useLayoutEffect(() => {
204
206
  if (!isModal || !panelRef.current || !rootEl) {
205
207
  return undefined
206
208
  }
@@ -38,7 +38,7 @@ const getOrCreateRegistries = (rootElement, eventBus) => {
38
38
  const loadPlugins = async (plugins, registerPlugin) => {
39
39
  for (const plugin of plugins) {
40
40
  if (typeof plugin.load === 'function') {
41
- const module = await plugin.load()
41
+ const module = await plugin.load() // NOSONAR: Await inside a for loop is fine, parent function is async
42
42
  const { id: pluginId, load, manifest: overrideManifest, ...config } = plugin
43
43
  const { InitComponent, api, reducer, ...baseManifest } = module
44
44
 
@@ -2,11 +2,13 @@
2
2
  import React, { createContext, useMemo, useRef } from 'react'
3
3
  import { createAnnouncer } from '../../services/announcer.js'
4
4
  import { createHints } from '../../services/hints.js'
5
+ import { createMapFocus } from '../../services/mapFocus.js'
5
6
  import { reverseGeocode } from '../../services/reverseGeocode.js'
6
7
  import { useConfig } from '../store/configContext.js'
8
+ import { useApp } from '../store/appContext.js'
7
9
  import { closeApp } from '../../services/closeApp.js'
8
- import { symbolRegistry } from '../../services/symbolRegistry.js'
9
- import { patternRegistry } from '../../services/patternRegistry.js'
10
+ import { createSymbolRegistry } from '../../services/symbolRegistry.js'
11
+ import { createPatternRegistry } from '../../services/patternRegistry.js'
10
12
 
11
13
  export const ServiceContext = createContext(null)
12
14
 
@@ -15,6 +17,11 @@ export const ServiceProvider = ({ eventBus, pluginRegistry, children }) => {
15
17
  const mapStatusRef = useRef(null)
16
18
  const announce = useMemo(() => createAnnouncer(mapStatusRef), [])
17
19
  const hints = useMemo(() => createHints(announce), [announce])
20
+ const { layoutRefs } = useApp()
21
+ const mapFocus = useMemo(() => createMapFocus({ viewportRef: layoutRefs.viewportRef }), [])
22
+ // One of each per map, so maps on the same page keep their own symbols, symbolDefaults and patterns
23
+ const symbolRegistry = useMemo(() => createSymbolRegistry(), [])
24
+ const patternRegistry = useMemo(() => createPatternRegistry(), [])
18
25
 
19
26
  symbolRegistry.setDefaults(constructorSymbolDefaults || {})
20
27
 
@@ -24,12 +31,14 @@ export const ServiceProvider = ({ eventBus, pluginRegistry, children }) => {
24
31
  reverseGeocode: (zoom, center) => reverseGeocode(zoom, center),
25
32
  eventBus,
26
33
  mapStatusRef,
34
+ focusMap: mapFocus.focus,
35
+ mapFocus,
27
36
  closeApp: () => closeApp(id, handleExitClick, eventBus),
28
37
  symbolRegistry,
29
38
  patternRegistry,
30
39
  // See pluginRegistry.js's getPlugin() for what this does and doesn't guarantee.
31
40
  getPlugin: (pluginId) => pluginRegistry?.getPlugin(pluginId)
32
- }), [announce, hints, pluginRegistry])
41
+ }), [announce, hints, mapFocus, pluginRegistry, symbolRegistry, patternRegistry])
33
42
 
34
43
  return (
35
44
  <ServiceContext.Provider value={services}>
@@ -24,6 +24,11 @@ jest.mock('../../services/closeApp.js', () => ({
24
24
  closeApp: jest.fn()
25
25
  }))
26
26
 
27
+ const mockViewportRef = { current: { focus: jest.fn(), getAttribute: jest.fn(), setAttribute: jest.fn() } }
28
+ jest.mock('../store/appContext.js', () => ({
29
+ useApp: jest.fn(() => ({ layoutRefs: { viewportRef: mockViewportRef } }))
30
+ }))
31
+
27
32
  // Mock config values including id + handleExitClick
28
33
  jest.mock('../store/configContext.js', () => ({
29
34
  useConfig: jest.fn(() => ({
@@ -56,6 +61,40 @@ describe('ServiceProvider', () => {
56
61
  expect(result.current.mapStatusRef.current).toBeNull()
57
62
  })
58
63
 
64
+ test('focusMap names and focuses the viewport from layoutRefs', () => {
65
+ const { result } = renderHook(() => React.useContext(ServiceContext), { wrapper })
66
+
67
+ result.current.focusMap({ message: 'Map moved to Carlisle' })
68
+
69
+ expect(mockViewportRef.current.setAttribute).toHaveBeenCalledWith('aria-label', 'Map moved to Carlisle')
70
+ expect(mockViewportRef.current.focus).toHaveBeenCalled()
71
+ expect(result.current.mapFocus.isHoldingAnnouncements()).toBe(true)
72
+ })
73
+
74
+ test('gives each map its own symbol registry, kept across renders, with that map\'s symbolDefaults', () => {
75
+ const { useConfig } = jest.requireMock('../store/configContext.js')
76
+ useConfig.mockReturnValue({ id: 'map-a', symbolDefaults: { backgroundColor: '#111111' } })
77
+ const first = renderHook(() => React.useContext(ServiceContext), { wrapper })
78
+ const firstRegistry = first.result.current.symbolRegistry
79
+ first.rerender()
80
+ expect(first.result.current.symbolRegistry).toBe(firstRegistry)
81
+
82
+ useConfig.mockReturnValue({ id: 'map-b', symbolDefaults: { backgroundColor: '#222222' } })
83
+ const second = renderHook(() => React.useContext(ServiceContext), { wrapper })
84
+ expect(second.result.current.symbolRegistry).not.toBe(firstRegistry)
85
+ expect(firstRegistry.getDefaults().backgroundColor).toBe('#111111')
86
+ expect(second.result.current.symbolRegistry.getDefaults().backgroundColor).toBe('#222222')
87
+ })
88
+
89
+ test('gives each map its own pattern registry, kept across renders', () => {
90
+ const first = renderHook(() => React.useContext(ServiceContext), { wrapper })
91
+ const firstRegistry = first.result.current.patternRegistry
92
+ first.rerender()
93
+ expect(first.result.current.patternRegistry).toBe(firstRegistry)
94
+ const second = renderHook(() => React.useContext(ServiceContext), { wrapper })
95
+ expect(second.result.current.patternRegistry).not.toBe(firstRegistry)
96
+ })
97
+
59
98
  test('renders children', () => {
60
99
  const { result } = renderHook(() => React.useContext(ServiceContext), {
61
100
  wrapper,
@@ -99,7 +99,7 @@ export default class InteractiveMap {
99
99
  this._hybridBehaviourCleanup = setupBehavior(this)
100
100
 
101
101
  if (shouldLoadComponent(this.config)) {
102
- this.loadApp()
102
+ this.loadApp() // NOSONAR: Not changing for now as used in production
103
103
  } else {
104
104
  removeLoadingState()
105
105
  }
@@ -120,7 +120,7 @@ export default class InteractiveMap {
120
120
  history.pushState({ isBack: true }, '', e.currentTarget.getAttribute('href'))
121
121
  }
122
122
  // Only a genuine launcher click moves focus into the map — never a resize/breakpoint transition.
123
- this.loadApp({ focusOnMount: true })
123
+ this.loadApp({ focusOnMount: true }) // NOSONAR: Not changing for now as used in production
124
124
  }
125
125
  }
126
126
 
@@ -564,7 +564,7 @@ export default class InteractiveMap {
564
564
  } else if (this._root) {
565
565
  // App is already open — no-op
566
566
  } else {
567
- this.loadApp()
567
+ this.loadApp() // NOSONAR: Not changing for now as used in production
568
568
  }
569
569
  }
570
570
 
@@ -228,8 +228,4 @@ export const defaultControlConfig = {
228
228
  }
229
229
  }
230
230
 
231
- export const scaleFactor = {
232
- small: 1,
233
- medium: 1.5,
234
- large: 2
235
- }
231
+ export { scaleFactor } from './mapSizeScales.js'
@@ -0,0 +1,8 @@
1
+ // Scale factor per app map size — applied to the map's pixel ratio, marker/symbol sizes and the
2
+ // draw UI. Kept in its own module (re-exported by appConfig.js) so plugins can share the one
3
+ // table without importing appConfig's UI components.
4
+ export const scaleFactor = {
5
+ small: 1,
6
+ medium: 1.5,
7
+ large: 2
8
+ }
@@ -6,27 +6,64 @@
6
6
  */
7
7
  export const symbolDefaults = {
8
8
  symbol: 'pin',
9
+ size: 'medium',
9
10
  backgroundColor: '#ca3535',
10
11
  foregroundColor: '#ffffff'
11
12
  }
12
13
 
14
+ /** The symbol style keys a dataset or draw style can set (see docs/plugins/datasets.md) */
15
+ export const SYMBOL_STYLE_KEYS = [
16
+ 'symbol', 'symbolSvgContent', 'symbolViewBox', 'symbolAnchor', 'symbolSize',
17
+ 'symbolBackgroundColor', 'symbolForegroundColor', 'symbolHaloWidth', 'symbolGraphic'
18
+ ]
19
+
20
+ /**
21
+ * Scale factor for each symbol size (`size` on markers, `symbolSize` on dataset and draw styles).
22
+ * Scales a symbol's shape and graphic; the halo and the selected/active rings stay a fixed width at
23
+ * every size (see getSymbolScale in symbolUtils.js).
24
+ */
25
+ export const SYMBOL_SIZES = {
26
+ small: 0.75, // NOSONAR
27
+ medium: 1,
28
+ large: 1.25 // NOSONAR
29
+ }
30
+
13
31
  /** Stroke width for the halo (background shape outline) in SVG units */
14
32
  export const HALO_STROKE_WIDTH = 2
15
33
 
16
34
  /** Stroke width for the selected state — symbol rings and feature highlight lines */
17
35
  export const SELECTED_STROKE_WIDTH = 3
18
36
 
37
+ // A stroke is centred on its path, so it reaches half its width either side
38
+ const BOTH_SIDES = 2
39
+
19
40
  /** Stroke width for the active (keyboard cursor) state — double selected, extends 1× each side */
20
- export const ACTIVE_STROKE_WIDTH = SELECTED_STROKE_WIDTH * 2
41
+ export const ACTIVE_STROKE_WIDTH = SELECTED_STROKE_WIDTH * BOTH_SIDES
42
+
43
+ // Built-in symbols draw their halo and rings as strokes centred on the body outline, so each
44
+ // stroke is twice the distance its visible edge reaches beyond the body: halo 1, selected ring
45
+ // 1 + 3 = 4, active ring 4 + 3 = 7. A stroke is an exact offset, so rings stay even round corners.
46
+ export const SELECTED_RING_STROKE_WIDTH = HALO_STROKE_WIDTH + SELECTED_STROKE_WIDTH * BOTH_SIDES
47
+ export const ACTIVE_RING_STROKE_WIDTH = SELECTED_RING_STROKE_WIDTH + ACTIVE_STROKE_WIDTH
48
+
49
+ const CENTRE = 0.5
50
+
51
+ /** Anchor used when a symbol doesn't set one — its centre */
52
+ export const DEFAULT_SYMBOL_ANCHOR = [CENTRE, CENTRE]
53
+
54
+ /** View box used when a custom SVG symbol doesn't set one */
55
+ export const DEFAULT_SYMBOL_VIEWBOX = '0 0 44 44'
56
+
57
+ /** Space around a built-in symbol's body: its outermost (active) ring plus 1px clearance */
58
+ export const SYMBOL_PADDING = ACTIVE_RING_STROKE_WIDTH / BOTH_SIDES + 1
21
59
 
22
60
  /**
23
61
  * Built-in graphic path data strings for use with the `graphic` token.
24
62
  *
25
63
  * Each value is an SVG `d` attribute string in a 16×16 coordinate space,
26
- * centred at (8, 8). The built-in symbols (`pin`, `circle`, `square`) apply a
27
- * `translate` transform to position this 16×16 area correctly within their
28
- * 38×38 viewBox — so graphic path data does not need to account for symbol
29
- * positioning.
64
+ * centred at (8, 8). The built-in symbols (`pin`, `circle`, `square`, `hexagon`, `triangle`, `diamond`)
65
+ * centre this 16×16 area on their `graphicCentre` at 0.8 scale — so graphic path data does not
66
+ * need to account for symbol positioning or size.
30
67
  *
31
68
  * @example
32
69
  * markers.add('id', coords, { symbol: 'pin', graphic: graphics.dot })
@@ -53,35 +90,74 @@ export const graphics = {
53
90
  }
54
91
 
55
92
  // ─── Built-in symbol definitions ─────────────────────────────────────────────
56
- // Each symbol uses a 44×44 viewBox. SVG templates use {{token}} placeholders
57
- // resolved at render time by the symbolRegistry.
93
+ // Each is a single body `path` in its own coordinates, with:
94
+ // bounds [x, y, width, height] — the body path's tight bounding box
95
+ // anchorPoint [x, y] — the point that sits on the map coordinate
96
+ // graphicCentre [x, y] — where the 16×16 graphic is centred (drawn at 0.8 scale)
97
+ // symbolRegistry composes the rendered SVG, viewBox and fractional anchor from these for each
98
+ // size: the body and graphic scale, the halo and rings don't.
58
99
 
100
+ // Circle-headed pin, head r=13. The anchor is the halo's tip, 1 below the body's.
59
101
  export const pin = {
60
102
  id: 'pin',
61
- viewBox: '0 0 44 44',
62
- anchor: [0.5, 0.9], // NOSONAR
63
- graphic: graphics.dot,
64
- svg: `<path d="M22 40.999c-3.621 0-8.306-5.864-10.258-8.3C9.02 29.302 6 23.66 6 19.002a16.01 16.01 0 0 1 16-16 16.01 16.01 0 0 1 16 16c0 4.658-3.02 10.3-5.742 13.697-1.952 2.437-6.637 8.3-10.258 8.3z" fill="{{selectedColor}}" stroke="{{activeColor}}" stroke-width="6" paint-order="stroke fill"/>
65
- <path d="M22 7.001a12.01 12.01 0 0 1 12 12c0 7.623-10.377 17.998-12 17.998S10 26.624 10 19.001a12.01 12.01 0 0 1 12-12z" fill="{{backgroundColor}}" stroke="{{haloColor}}" stroke-width="2" paint-order="stroke fill"/>
66
- <g transform="translate(22, 19) scale(0.8) translate(-8, -8)"><path d="{{graphic}}" fill="{{foregroundColor}}"/></g>`
103
+ path: 'M22 7a13 13 0 0 1 13 13C35 28.258 23.758 39.499 22 39.499S9 28.259 9 20.001a13 13 0 0 1 13-13z',
104
+ bounds: [9, 7, 26, 32.499], // NOSONAR
105
+ anchorPoint: [22, 40.5], // NOSONAR
106
+ graphicCentre: [22, 20], // NOSONAR
107
+ graphic: graphics.dot
67
108
  }
68
109
 
110
+ // r=13 — the reference size the other shapes' areas are compared against.
69
111
  export const circle = {
70
112
  id: 'circle',
71
- viewBox: '0 0 44 44',
72
- anchor: [0.5, 0.5],
73
- graphic: graphics.dot,
74
- svg: `<circle cx="22" cy="22" r="16" fill="{{selectedColor}}" stroke="{{activeColor}}" stroke-width="6" paint-order="stroke fill"/>
75
- <circle cx="22" cy="22" r="12" fill="{{backgroundColor}}" stroke="{{haloColor}}" stroke-width="2" paint-order="stroke fill"/>
76
- <g transform="translate(22, 22) scale(0.8) translate(-8, -8)"><path d="{{graphic}}" fill="{{foregroundColor}}"/></g>`
113
+ path: 'M22 9a13 13 0 1 1 0 26 13 13 0 1 1 0-26z',
114
+ bounds: [9, 9, 26, 26], // NOSONAR
115
+ anchorPoint: [22, 22], // NOSONAR
116
+ graphicCentre: [22, 22], // NOSONAR
117
+ graphic: graphics.dot
77
118
  }
78
119
 
120
+ // 23.6 body with 3px corner radii — ~103% of circle's area, Material's square-to-circle keyline
121
+ // ratio (18×18 square vs 20 circle).
79
122
  export const square = {
80
123
  id: 'square',
81
- viewBox: '0 0 44 44',
82
- anchor: [0.5, 0.5],
83
- graphic: graphics.dot,
84
- svg: `<path d="M13 6h18c3.863 0 7 3.137 7 7v18c0 3.863-3.137 7-7 7H13c-3.863 0-7-3.137-7-7V13c0-3.863 3.137-7 7-7" fill="{{selectedColor}}" stroke="{{activeColor}}" stroke-width="6" paint-order="stroke fill"/>
85
- <path d="M13 34a3 3 0 0 1-3-3V13a3 3 0 0 1 3-3h18a3 3 0 0 1 3 3v18a3 3 0 0 1-3 3H13z" fill-rule="nonzero" fill="{{backgroundColor}}" stroke="{{haloColor}}" stroke-width="2" paint-order="stroke fill"/>
86
- <g transform="translate(22, 22) scale(0.8) translate(-8, -8)"><path d="{{graphic}}" fill="{{foregroundColor}}"/></g>`
124
+ path: 'M13.2 33.8a3 3 0 0 1-3-3V13.2a3 3 0 0 1 3-3h17.6a3 3 0 0 1 3 3v17.6a3 3 0 0 1-3 3H13.2z',
125
+ bounds: [10.2, 10.2, 23.6, 23.6], // NOSONAR
126
+ anchorPoint: [22, 22], // NOSONAR
127
+ graphicCentre: [22, 22], // NOSONAR
128
+ graphic: graphics.dot
129
+ }
130
+
131
+ // Pointy-top hexagon, flat sides 12.6 from the centre, 3px corner radii — ~103% of circle's
132
+ // area, between circle and square (cornered shapes need slightly more area than a circle to
133
+ // read as the same size).
134
+ export const hexagon = {
135
+ id: 'hexagon',
136
+ path: 'M23.5 8.317L33.1 13.859A3 3 0 0 1 34.6 16.457L34.6 27.543A3 3 0 0 1 33.1 30.141L23.5 35.683A3 3 0 0 1 20.5 35.683L10.9 30.141A3 3 0 0 1 9.4 27.543L9.4 16.457A3 3 0 0 1 10.9 13.859L20.5 8.317A3 3 0 0 1 23.5 8.317z',
137
+ bounds: [9.4, 7.915, 25.2, 28.17], // NOSONAR
138
+ anchorPoint: [22, 22], // NOSONAR
139
+ graphicCentre: [22, 22], // NOSONAR
140
+ graphic: graphics.dot
141
+ }
142
+
143
+ // Point-up equilateral triangle, edges 10.4 from the centroid, 3px corner radii — ~102% of
144
+ // circle's area. Anchored at the centroid; the graphic sits 0.5 below it.
145
+ export const triangle = {
146
+ id: 'triangle',
147
+ path: 'M25.598 9.7L38.415 31.9A3 3 0 0 1 35.817 36.4L10.183 36.4A3 3 0 0 1 7.585 31.9L20.402 9.7A3 3 0 0 1 25.598 9.7z',
148
+ bounds: [7.183, 8.2, 31.634, 28.2], // NOSONAR
149
+ anchorPoint: [23, 26], // NOSONAR
150
+ graphicCentre: [23, 26.5], // NOSONAR
151
+ graphic: graphics.dot
152
+ }
153
+
154
+ // A square rotated 45°, edges 11.6 from the centre, 3px corner radii — the same area as circle
155
+ // (less than square's, since its points reach further and make it read larger).
156
+ export const diamond = {
157
+ id: 'diamond',
158
+ path: 'M25.121 8.716L37.284 20.879A3 3 0 0 1 37.284 25.121L25.121 37.284A3 3 0 0 1 20.879 37.284L8.716 25.121A3 3 0 0 1 8.716 20.879L20.879 8.716A3 3 0 0 1 25.121 8.716z',
159
+ bounds: [7.838, 7.838, 30.325, 30.325], // NOSONAR
160
+ anchorPoint: [23, 23], // NOSONAR
161
+ graphicCentre: [23, 23], // NOSONAR
162
+ graphic: graphics.dot
87
163
  }