@mapcairn/map 0.0.0-stage → 0.1.0-rc.2

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 (315) hide show
  1. package/LICENSE +661 -0
  2. package/README.md +167 -2
  3. package/dist/chrome/Attribution/Attribution.js +304 -0
  4. package/dist/chrome/Attribution/Attribution.js.map +1 -0
  5. package/dist/chrome/Attribution/Attribution.styles.js +10 -0
  6. package/dist/chrome/Attribution/Attribution.styles.js.map +1 -0
  7. package/dist/chrome/Attribution/AttributionSkeleton.js +29 -0
  8. package/dist/chrome/Attribution/AttributionSkeleton.js.map +1 -0
  9. package/dist/chrome/ChromeSkeleton/ChromeSkeleton.js +83 -0
  10. package/dist/chrome/ChromeSkeleton/ChromeSkeleton.js.map +1 -0
  11. package/dist/chrome/EndStack/EndStack.js +157 -0
  12. package/dist/chrome/EndStack/EndStack.js.map +1 -0
  13. package/dist/chrome/EndStack/EndStack.styles.js +12 -0
  14. package/dist/chrome/EndStack/EndStack.styles.js.map +1 -0
  15. package/dist/chrome/EndStack/EndStackSkeleton.js +78 -0
  16. package/dist/chrome/EndStack/EndStackSkeleton.js.map +1 -0
  17. package/dist/chrome/EndStack/endStackHeight.js +22 -0
  18. package/dist/chrome/EndStack/endStackHeight.js.map +1 -0
  19. package/dist/chrome/MapChrome/MapChrome.js +488 -0
  20. package/dist/chrome/MapChrome/MapChrome.js.map +1 -0
  21. package/dist/chrome/MapChrome/MapChrome.styles.js +15 -0
  22. package/dist/chrome/MapChrome/MapChrome.styles.js.map +1 -0
  23. package/dist/chrome/MapChrome/chromeSurface.js +18 -0
  24. package/dist/chrome/MapChrome/chromeSurface.js.map +1 -0
  25. package/dist/chrome/MapChrome/chromeVars.js +71 -0
  26. package/dist/chrome/MapChrome/chromeVars.js.map +1 -0
  27. package/dist/chrome/MapChrome/mapKeyPlacement.js +41 -0
  28. package/dist/chrome/MapChrome/mapKeyPlacement.js.map +1 -0
  29. package/dist/chrome/MapChrome/sharesWidth.js +13 -0
  30. package/dist/chrome/MapChrome/sharesWidth.js.map +1 -0
  31. package/dist/chrome/MapReadout/MapReadout.js +199 -0
  32. package/dist/chrome/MapReadout/MapReadout.js.map +1 -0
  33. package/dist/chrome/MapReadout/MapReadout.styles.js +14 -0
  34. package/dist/chrome/MapReadout/MapReadout.styles.js.map +1 -0
  35. package/dist/chrome/Sheet/Sheet.js +412 -0
  36. package/dist/chrome/Sheet/Sheet.js.map +1 -0
  37. package/dist/chrome/Sheet/Sheet.styles.js +14 -0
  38. package/dist/chrome/Sheet/Sheet.styles.js.map +1 -0
  39. package/dist/chrome/focusRegistry.js +76 -0
  40. package/dist/chrome/focusRegistry.js.map +1 -0
  41. package/dist/chrome/layoutContext.js +30 -0
  42. package/dist/chrome/layoutContext.js.map +1 -0
  43. package/dist/chrome/useScrollEdges.js +53 -0
  44. package/dist/chrome/useScrollEdges.js.map +1 -0
  45. package/dist/host/MapContext.js +16 -0
  46. package/dist/host/MapContext.js.map +1 -0
  47. package/dist/host/MapView.js +189 -0
  48. package/dist/host/MapView.js.map +1 -0
  49. package/dist/host/MapView.styles.js +16 -0
  50. package/dist/host/MapView.styles.js.map +1 -0
  51. package/dist/host/overlays/AccuracyCircle.js +36 -0
  52. package/dist/host/overlays/AccuracyCircle.js.map +1 -0
  53. package/dist/host/overlays/CentreCrosshair.js +40 -0
  54. package/dist/host/overlays/CentreCrosshair.js.map +1 -0
  55. package/dist/host/overlays/DrawOverlay.js +221 -0
  56. package/dist/host/overlays/DrawOverlay.js.map +1 -0
  57. package/dist/host/overlays/MapOverlayLayer.js +27 -0
  58. package/dist/host/overlays/MapOverlayLayer.js.map +1 -0
  59. package/dist/host/overlays/MeasureOverlay.js +87 -0
  60. package/dist/host/overlays/MeasureOverlay.js.map +1 -0
  61. package/dist/host/overlays/PinMarker.js +40 -0
  62. package/dist/host/overlays/PinMarker.js.map +1 -0
  63. package/dist/host/overlays/geometry.js +41 -0
  64. package/dist/host/overlays/geometry.js.map +1 -0
  65. package/dist/host/overlays/overlays.styles.js +27 -0
  66. package/dist/host/overlays/overlays.styles.js.map +1 -0
  67. package/dist/host/pointerTargets.js +22 -0
  68. package/dist/host/pointerTargets.js.map +1 -0
  69. package/dist/host/useLongPress.js +102 -0
  70. package/dist/host/useLongPress.js.map +1 -0
  71. package/dist/host/useMapEngine.js +352 -0
  72. package/dist/host/useMapEngine.js.map +1 -0
  73. package/dist/host/usePointerPosition.js +60 -0
  74. package/dist/host/usePointerPosition.js.map +1 -0
  75. package/dist/index.d.ts +3845 -0
  76. package/dist/index.js +89 -0
  77. package/dist/layers/CatalogueStatus.js +138 -0
  78. package/dist/layers/CatalogueStatus.js.map +1 -0
  79. package/dist/layers/DateTimeControl.js +101 -0
  80. package/dist/layers/DateTimeControl.js.map +1 -0
  81. package/dist/layers/FeatureCard.js +147 -0
  82. package/dist/layers/FeatureCard.js.map +1 -0
  83. package/dist/layers/FeatureChoices.js +101 -0
  84. package/dist/layers/FeatureChoices.js.map +1 -0
  85. package/dist/layers/FeatureGlyph.js +56 -0
  86. package/dist/layers/FeatureGlyph.js.map +1 -0
  87. package/dist/layers/IdentifyStatus.js +36 -0
  88. package/dist/layers/IdentifyStatus.js.map +1 -0
  89. package/dist/layers/LayerItem.js +321 -0
  90. package/dist/layers/LayerItem.js.map +1 -0
  91. package/dist/layers/LayerKey.js +36 -0
  92. package/dist/layers/LayerKey.js.map +1 -0
  93. package/dist/layers/Layers.styles.js +50 -0
  94. package/dist/layers/Layers.styles.js.map +1 -0
  95. package/dist/layers/LayersSection.js +267 -0
  96. package/dist/layers/LayersSection.js.map +1 -0
  97. package/dist/layers/MapDataLayers.js +261 -0
  98. package/dist/layers/MapDataLayers.js.map +1 -0
  99. package/dist/layers/MapKey.js +131 -0
  100. package/dist/layers/MapKey.js.map +1 -0
  101. package/dist/layers/MapKey.styles.js +16 -0
  102. package/dist/layers/MapKey.styles.js.map +1 -0
  103. package/dist/layers/MarkerGlyph.js +84 -0
  104. package/dist/layers/MarkerGlyph.js.map +1 -0
  105. package/dist/layers/SelectionProvider.js +27 -0
  106. package/dist/layers/SelectionProvider.js.map +1 -0
  107. package/dist/layers/ShapeGlyph.js +122 -0
  108. package/dist/layers/ShapeGlyph.js.map +1 -0
  109. package/dist/layers/TurnOffActions.js +147 -0
  110. package/dist/layers/TurnOffActions.js.map +1 -0
  111. package/dist/layers/answersTap.js +16 -0
  112. package/dist/layers/answersTap.js.map +1 -0
  113. package/dist/layers/catalogueNotice.js +65 -0
  114. package/dist/layers/catalogueNotice.js.map +1 -0
  115. package/dist/layers/catalogueReconcile.js +55 -0
  116. package/dist/layers/catalogueReconcile.js.map +1 -0
  117. package/dist/layers/catalogueView.js +32 -0
  118. package/dist/layers/catalogueView.js.map +1 -0
  119. package/dist/layers/featureTitle.js +14 -0
  120. package/dist/layers/featureTitle.js.map +1 -0
  121. package/dist/layers/identifyFeedback.js +30 -0
  122. package/dist/layers/identifyFeedback.js.map +1 -0
  123. package/dist/layers/identifyRun.js +148 -0
  124. package/dist/layers/identifyRun.js.map +1 -0
  125. package/dist/layers/layerStatus.js +13 -0
  126. package/dist/layers/layerStatus.js.map +1 -0
  127. package/dist/layers/loadOutcome.js +107 -0
  128. package/dist/layers/loadOutcome.js.map +1 -0
  129. package/dist/layers/loadReport.js +33 -0
  130. package/dist/layers/loadReport.js.map +1 -0
  131. package/dist/layers/loadRequests.js +73 -0
  132. package/dist/layers/loadRequests.js.map +1 -0
  133. package/dist/layers/mapFeatures.js +307 -0
  134. package/dist/layers/mapFeatures.js.map +1 -0
  135. package/dist/layers/mapKeyBlocks.js +24 -0
  136. package/dist/layers/mapKeyBlocks.js.map +1 -0
  137. package/dist/layers/reveal.js +119 -0
  138. package/dist/layers/reveal.js.map +1 -0
  139. package/dist/layers/selectionMessages.js +53 -0
  140. package/dist/layers/selectionMessages.js.map +1 -0
  141. package/dist/layers/selectionResolve.js +111 -0
  142. package/dist/layers/selectionResolve.js.map +1 -0
  143. package/dist/layers/useDataLayers.js +940 -0
  144. package/dist/layers/useDataLayers.js.map +1 -0
  145. package/dist/layers/useFeatureSelection.js +179 -0
  146. package/dist/layers/useFeatureSelection.js.map +1 -0
  147. package/dist/layers/useScrolls.js +37 -0
  148. package/dist/layers/useScrolls.js.map +1 -0
  149. package/dist/panels/BasemapPicker/BasemapPicker.js +169 -0
  150. package/dist/panels/BasemapPicker/BasemapPicker.js.map +1 -0
  151. package/dist/panels/BasemapPicker/BasemapPicker.styles.js +42 -0
  152. package/dist/panels/BasemapPicker/BasemapPicker.styles.js.map +1 -0
  153. package/dist/panels/ExportSection/ExportSection.js +91 -0
  154. package/dist/panels/ExportSection/ExportSection.js.map +1 -0
  155. package/dist/panels/HelpSection/HelpSection.js +163 -0
  156. package/dist/panels/HelpSection/HelpSection.js.map +1 -0
  157. package/dist/panels/HelpSection/HelpSection.styles.js +9 -0
  158. package/dist/panels/HelpSection/HelpSection.styles.js.map +1 -0
  159. package/dist/panels/PinSection/PinSection.js +39 -0
  160. package/dist/panels/PinSection/PinSection.js.map +1 -0
  161. package/dist/panels/Section/Section.js +43 -0
  162. package/dist/panels/Section/Section.js.map +1 -0
  163. package/dist/panels/Section/Section.styles.js +13 -0
  164. package/dist/panels/Section/Section.styles.js.map +1 -0
  165. package/dist/panels/SettingsSection/LanguageField.js +126 -0
  166. package/dist/panels/SettingsSection/LanguageField.js.map +1 -0
  167. package/dist/panels/SettingsSection/SettingsSection.js +175 -0
  168. package/dist/panels/SettingsSection/SettingsSection.js.map +1 -0
  169. package/dist/panels/SettingsSection/SettingsSection.styles.js +9 -0
  170. package/dist/panels/SettingsSection/SettingsSection.styles.js.map +1 -0
  171. package/dist/panels/ShapesSection/ShapesSection.js +229 -0
  172. package/dist/panels/ShapesSection/ShapesSection.js.map +1 -0
  173. package/dist/panels/ShapesSection/ShapesSection.styles.js +7 -0
  174. package/dist/panels/ShapesSection/ShapesSection.styles.js.map +1 -0
  175. package/dist/panels/SheetContent/SheetContent.js +92 -0
  176. package/dist/panels/SheetContent/SheetContent.js.map +1 -0
  177. package/dist/panels/SheetContent/SheetContent.styles.js +6 -0
  178. package/dist/panels/SheetContent/SheetContent.styles.js.map +1 -0
  179. package/dist/services/ServicesProvider.js +42 -0
  180. package/dist/services/ServicesProvider.js.map +1 -0
  181. package/dist/services/activeMessages.js +140 -0
  182. package/dist/services/activeMessages.js.map +1 -0
  183. package/dist/services/basemapAvailability.js +78 -0
  184. package/dist/services/basemapAvailability.js.map +1 -0
  185. package/dist/services/englishMessages.js +10 -0
  186. package/dist/services/englishMessages.js.map +1 -0
  187. package/dist/services/hooks.js +214 -0
  188. package/dist/services/hooks.js.map +1 -0
  189. package/dist/styles.css +2866 -0
  190. package/dist/styles.css.d.ts +1 -0
  191. package/dist/tools/Directions/Directions.styles.js +25 -0
  192. package/dist/tools/Directions/Directions.styles.js.map +1 -0
  193. package/dist/tools/Directions/DirectionsOverlay.js +46 -0
  194. package/dist/tools/Directions/DirectionsOverlay.js.map +1 -0
  195. package/dist/tools/Directions/DirectionsPanel.js +428 -0
  196. package/dist/tools/Directions/DirectionsPanel.js.map +1 -0
  197. package/dist/tools/Directions/MapDirections.js +84 -0
  198. package/dist/tools/Directions/MapDirections.js.map +1 -0
  199. package/dist/tools/Directions/useDirections.js +226 -0
  200. package/dist/tools/Directions/useDirections.js.map +1 -0
  201. package/dist/tools/Directions/useFreeCentre.js +30 -0
  202. package/dist/tools/Directions/useFreeCentre.js.map +1 -0
  203. package/dist/tools/DrawToolbar/DrawMapBindings.js +34 -0
  204. package/dist/tools/DrawToolbar/DrawMapBindings.js.map +1 -0
  205. package/dist/tools/DrawToolbar/DrawToolbar.js +296 -0
  206. package/dist/tools/DrawToolbar/DrawToolbar.js.map +1 -0
  207. package/dist/tools/DrawToolbar/DrawToolbar.styles.js +21 -0
  208. package/dist/tools/DrawToolbar/DrawToolbar.styles.js.map +1 -0
  209. package/dist/tools/DrawToolbar/imageDrawing.js +24 -0
  210. package/dist/tools/DrawToolbar/imageDrawing.js.map +1 -0
  211. package/dist/tools/DrawToolbar/useDraw.js +543 -0
  212. package/dist/tools/DrawToolbar/useDraw.js.map +1 -0
  213. package/dist/tools/MeasureToolbar/MeasureToolbar.js +116 -0
  214. package/dist/tools/MeasureToolbar/MeasureToolbar.js.map +1 -0
  215. package/dist/tools/MeasureToolbar/MeasureToolbar.styles.js +12 -0
  216. package/dist/tools/MeasureToolbar/MeasureToolbar.styles.js.map +1 -0
  217. package/dist/tools/MeasureToolbar/useMeasure.js +75 -0
  218. package/dist/tools/MeasureToolbar/useMeasure.js.map +1 -0
  219. package/dist/tools/PinCard/PinCard.js +174 -0
  220. package/dist/tools/PinCard/PinCard.js.map +1 -0
  221. package/dist/tools/PinCard/PinCard.styles.js +16 -0
  222. package/dist/tools/PinCard/PinCard.styles.js.map +1 -0
  223. package/dist/tools/PinCard/useReverseAddress.js +77 -0
  224. package/dist/tools/PinCard/useReverseAddress.js.map +1 -0
  225. package/dist/tools/SearchPill/SearchPill.js +292 -0
  226. package/dist/tools/SearchPill/SearchPill.js.map +1 -0
  227. package/dist/tools/SearchPill/SearchPill.styles.js +16 -0
  228. package/dist/tools/SearchPill/SearchPill.styles.js.map +1 -0
  229. package/dist/tools/SearchPill/SearchPillSkeleton.js +41 -0
  230. package/dist/tools/SearchPill/SearchPillSkeleton.js.map +1 -0
  231. package/dist/tools/SearchPill/useSearch.js +143 -0
  232. package/dist/tools/SearchPill/useSearch.js.map +1 -0
  233. package/dist/tools/SearchPill/useSuggestions.js +105 -0
  234. package/dist/tools/SearchPill/useSuggestions.js.map +1 -0
  235. package/dist/tools/Tour/TourCard.js +156 -0
  236. package/dist/tools/Tour/TourCard.js.map +1 -0
  237. package/dist/tools/Tour/TourCard.styles.js +10 -0
  238. package/dist/tools/Tour/TourCard.styles.js.map +1 -0
  239. package/dist/tools/Tour/useTour.js +110 -0
  240. package/dist/tools/Tour/useTour.js.map +1 -0
  241. package/dist/tools/locate/useLocate.js +94 -0
  242. package/dist/tools/locate/useLocate.js.map +1 -0
  243. package/dist/ui/Button/Button.js +36 -0
  244. package/dist/ui/Button/Button.js.map +1 -0
  245. package/dist/ui/Button/Button.styles.js +17 -0
  246. package/dist/ui/Button/Button.styles.js.map +1 -0
  247. package/dist/ui/Chip/Chip.js +37 -0
  248. package/dist/ui/Chip/Chip.js.map +1 -0
  249. package/dist/ui/Chip/Chip.styles.js +29 -0
  250. package/dist/ui/Chip/Chip.styles.js.map +1 -0
  251. package/dist/ui/ControlGroup/ControlGroup.js +23 -0
  252. package/dist/ui/ControlGroup/ControlGroup.js.map +1 -0
  253. package/dist/ui/ControlGroup/ControlGroup.styles.js +6 -0
  254. package/dist/ui/ControlGroup/ControlGroup.styles.js.map +1 -0
  255. package/dist/ui/EmptyState/EmptyState.js +37 -0
  256. package/dist/ui/EmptyState/EmptyState.js.map +1 -0
  257. package/dist/ui/EmptyState/EmptyState.styles.js +10 -0
  258. package/dist/ui/EmptyState/EmptyState.styles.js.map +1 -0
  259. package/dist/ui/Icon/Icon.js +28 -0
  260. package/dist/ui/Icon/Icon.js.map +1 -0
  261. package/dist/ui/Icon/Icon.styles.js +8 -0
  262. package/dist/ui/Icon/Icon.styles.js.map +1 -0
  263. package/dist/ui/IconButton/IconButton.js +47 -0
  264. package/dist/ui/IconButton/IconButton.js.map +1 -0
  265. package/dist/ui/IconButton/IconButton.styles.js +27 -0
  266. package/dist/ui/IconButton/IconButton.styles.js.map +1 -0
  267. package/dist/ui/Isolate/Isolate.js +26 -0
  268. package/dist/ui/Isolate/Isolate.js.map +1 -0
  269. package/dist/ui/Isolate/fillSlots.js +27 -0
  270. package/dist/ui/Isolate/fillSlots.js.map +1 -0
  271. package/dist/ui/ListRow/ListRow.js +59 -0
  272. package/dist/ui/ListRow/ListRow.js.map +1 -0
  273. package/dist/ui/ListRow/ListRow.styles.js +30 -0
  274. package/dist/ui/ListRow/ListRow.styles.js.map +1 -0
  275. package/dist/ui/LiveRegion/LiveRegion.js +88 -0
  276. package/dist/ui/LiveRegion/LiveRegion.js.map +1 -0
  277. package/dist/ui/LiveRegion/announcer.js +114 -0
  278. package/dist/ui/LiveRegion/announcer.js.map +1 -0
  279. package/dist/ui/SegmentedControl/SegmentedControl.js +55 -0
  280. package/dist/ui/SegmentedControl/SegmentedControl.js.map +1 -0
  281. package/dist/ui/SegmentedControl/SegmentedControl.styles.js +9 -0
  282. package/dist/ui/SegmentedControl/SegmentedControl.styles.js.map +1 -0
  283. package/dist/ui/SkipLink/SkipLink.js +35 -0
  284. package/dist/ui/SkipLink/SkipLink.js.map +1 -0
  285. package/dist/ui/SkipLink/SkipLink.styles.js +6 -0
  286. package/dist/ui/SkipLink/SkipLink.styles.js.map +1 -0
  287. package/dist/ui/Slider/Slider.js +68 -0
  288. package/dist/ui/Slider/Slider.js.map +1 -0
  289. package/dist/ui/Slider/Slider.styles.js +13 -0
  290. package/dist/ui/Slider/Slider.styles.js.map +1 -0
  291. package/dist/ui/StatusMessage/StatusMessage.js +124 -0
  292. package/dist/ui/StatusMessage/StatusMessage.js.map +1 -0
  293. package/dist/ui/StatusMessage/StatusMessage.styles.js +28 -0
  294. package/dist/ui/StatusMessage/StatusMessage.styles.js.map +1 -0
  295. package/dist/ui/StatusMessage/StatusMessageFocus.js +30 -0
  296. package/dist/ui/StatusMessage/StatusMessageFocus.js.map +1 -0
  297. package/dist/ui/Surface/Surface.js +22 -0
  298. package/dist/ui/Surface/Surface.js.map +1 -0
  299. package/dist/ui/Surface/Surface.styles.js +27 -0
  300. package/dist/ui/Surface/Surface.styles.js.map +1 -0
  301. package/dist/ui/Switch/Switch.js +58 -0
  302. package/dist/ui/Switch/Switch.js.map +1 -0
  303. package/dist/ui/Switch/Switch.styles.js +13 -0
  304. package/dist/ui/Switch/Switch.styles.js.map +1 -0
  305. package/dist/ui/Tooltip/Tooltip.js +66 -0
  306. package/dist/ui/Tooltip/Tooltip.js.map +1 -0
  307. package/dist/ui/Tooltip/Tooltip.styles.js +6 -0
  308. package/dist/ui/Tooltip/Tooltip.styles.js.map +1 -0
  309. package/dist/ui/Tooltip/inheritColours.js +27 -0
  310. package/dist/ui/Tooltip/inheritColours.js.map +1 -0
  311. package/dist/ui/VisuallyHidden/VisuallyHidden.js +16 -0
  312. package/dist/ui/VisuallyHidden/VisuallyHidden.js.map +1 -0
  313. package/dist/ui/VisuallyHidden/VisuallyHidden.styles.js +6 -0
  314. package/dist/ui/VisuallyHidden/VisuallyHidden.styles.js.map +1 -0
  315. package/package.json +82 -4
@@ -0,0 +1,71 @@
1
+ // src/chrome/MapChrome/chromeVars.ts
2
+ /**
3
+ * The CSS custom properties `MapChrome` sets on its root with
4
+ * `style.setProperty` after measuring, and that slots and surfaces read in
5
+ * their stylesheets. They are plain names rather than vanilla-extract
6
+ * `createVar`s because they are written through CSSOM, never through a
7
+ * `style` attribute (production CSP is `style-src 'self'`).
8
+ *
9
+ * Every value is in CSS pixels, measured from the chrome container. Readers
10
+ * must give each one a fallback, because the properties are absent during
11
+ * server rendering and before the first measurement.
12
+ */
13
+ var chromeVars = {
14
+ /** Width of the chrome container. */
15
+ width: "--chrome-width",
16
+ /** Distance from the container top to the bottom edge of the top-start slot. */
17
+ topStartBottom: "--chrome-top-start-bottom",
18
+ /** The tallest the end stack may be before it scrolls. */
19
+ endStackMaxHeight: "--chrome-end-stack-max-height",
20
+ /** Width of the end stack, zero when it is absent. */
21
+ endStackWidth: "--chrome-end-stack-width",
22
+ /**
23
+ * How far the top of the bottom row is above the top of the bottom-end slot
24
+ * (zero or positive): the extra height of the bottom-start readout. The
25
+ * credits popover rises this far more, so it clears the whole row, unless it
26
+ * shares no width with the readout (`data-readout-clear`).
27
+ */
28
+ bottomEndRise: "--chrome-bottom-end-rise",
29
+ /**
30
+ * How much further the credits popover rises, over what its `transform` rise
31
+ * already gives, to clear the bottom-centre slot it shares width with (zero or
32
+ * positive). It is the `translate` property, written in the observer callback.
33
+ */
34
+ popoverCentreRise: "--chrome-popover-centre-rise",
35
+ /** Vertical room above the bottom row that stays clear of the end stack. */
36
+ bottomEndRoom: "--chrome-bottom-end-room",
37
+ /**
38
+ * Vertical room above the bottom row for something placed beside the end
39
+ * stack rather than under it: from the gap below the top-start slot.
40
+ */
41
+ bottomEndBesideRoom: "--chrome-bottom-end-beside-room",
42
+ /**
43
+ * Vertical shift of the bottom slots from the sheet alone (zero or
44
+ * negative). It is a `transform`, so it slides with the sheet.
45
+ */
46
+ bottomLift: "--chrome-bottom-lift",
47
+ /**
48
+ * How much further the bottom-start slot rises to clear the bottom-centre slot (zero or negative): zero
49
+ * while the two share no width. It is the `translate` property, which no
50
+ * transition covers, and `MapChrome` sets it in the observer callback that
51
+ * sees the slot change size, so it lands in the same frame.
52
+ */
53
+ bottomStartRaise: "--chrome-bottom-start-raise",
54
+ /**
55
+ * How much further the map key rises: to clear the bottom-centre slot where
56
+ * the key shares width with it (it can be wider than the readout it rests
57
+ * above), and never less than the readout's own rise. Zero or negative.
58
+ */
59
+ mapKeyRaise: "--chrome-map-key-raise",
60
+ /** The same for the bottom-end slot, which has its own: zero while it shares no width with the bottom-centre slot. */
61
+ bottomEndRaise: "--chrome-bottom-end-raise",
62
+ /** Horizontal shift of the bottom-start slot (zero or positive). */
63
+ bottomStartX: "--chrome-bottom-start-x",
64
+ /** Base room for the map key; the immediate toolbar raise is added in CSS. */
65
+ mapKeyRoom: "--chrome-map-key-room",
66
+ /** Base shift of the map key; sheet and toolbar lifts are separate. */
67
+ mapKeyLift: "--chrome-map-key-lift"
68
+ };
69
+ export { chromeVars };
70
+
71
+ //# sourceMappingURL=chromeVars.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chromeVars.js","names":[],"sources":["../../../src/chrome/MapChrome/chromeVars.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-only\n// Copyright MapCairn contributors\n/**\n * The CSS custom properties `MapChrome` sets on its root with\n * `style.setProperty` after measuring, and that slots and surfaces read in\n * their stylesheets. They are plain names rather than vanilla-extract\n * `createVar`s because they are written through CSSOM, never through a\n * `style` attribute (production CSP is `style-src 'self'`).\n *\n * Every value is in CSS pixels, measured from the chrome container. Readers\n * must give each one a fallback, because the properties are absent during\n * server rendering and before the first measurement.\n */\nexport const chromeVars = {\n /** Width of the chrome container. */\n width: \"--chrome-width\",\n /** Distance from the container top to the bottom edge of the top-start slot. */\n topStartBottom: \"--chrome-top-start-bottom\",\n /** The tallest the end stack may be before it scrolls. */\n endStackMaxHeight: \"--chrome-end-stack-max-height\",\n /** Width of the end stack, zero when it is absent. */\n endStackWidth: \"--chrome-end-stack-width\",\n /**\n * How far the top of the bottom row is above the top of the bottom-end slot\n * (zero or positive): the extra height of the bottom-start readout. The\n * credits popover rises this far more, so it clears the whole row, unless it\n * shares no width with the readout (`data-readout-clear`).\n */\n bottomEndRise: \"--chrome-bottom-end-rise\",\n /**\n * How much further the credits popover rises, over what its `transform` rise\n * already gives, to clear the bottom-centre slot it shares width with (zero or\n * positive). It is the `translate` property, written in the observer callback.\n */\n popoverCentreRise: \"--chrome-popover-centre-rise\",\n /** Vertical room above the bottom row that stays clear of the end stack. */\n bottomEndRoom: \"--chrome-bottom-end-room\",\n /**\n * Vertical room above the bottom row for something placed beside the end\n * stack rather than under it: from the gap below the top-start slot.\n */\n bottomEndBesideRoom: \"--chrome-bottom-end-beside-room\",\n /**\n * Vertical shift of the bottom slots from the sheet alone (zero or\n * negative). It is a `transform`, so it slides with the sheet.\n */\n bottomLift: \"--chrome-bottom-lift\",\n /**\n * How much further the bottom-start slot rises to clear the bottom-centre slot (zero or negative): zero\n * while the two share no width. It is the `translate` property, which no\n * transition covers, and `MapChrome` sets it in the observer callback that\n * sees the slot change size, so it lands in the same frame.\n */\n bottomStartRaise: \"--chrome-bottom-start-raise\",\n /**\n * How much further the map key rises: to clear the bottom-centre slot where\n * the key shares width with it (it can be wider than the readout it rests\n * above), and never less than the readout's own rise. Zero or negative.\n */\n mapKeyRaise: \"--chrome-map-key-raise\",\n /** The same for the bottom-end slot, which has its own: zero while it shares no width with the bottom-centre slot. */\n bottomEndRaise: \"--chrome-bottom-end-raise\",\n /** Horizontal shift of the bottom-start slot (zero or positive). */\n bottomStartX: \"--chrome-bottom-start-x\",\n /** Base room for the map key; the immediate toolbar raise is added in CSS. */\n mapKeyRoom: \"--chrome-map-key-room\",\n /** Base shift of the map key; sheet and toolbar lifts are separate. */\n mapKeyLift: \"--chrome-map-key-lift\",\n} as const;\n\n/** Reads a chrome variable in a stylesheet, with a fallback. */\nexport function chromeVar(\n name: (typeof chromeVars)[keyof typeof chromeVars],\n fallback: string,\n): string {\n return `var(${name}, ${fallback})`;\n}\n"],"mappings":";;;;;;;;;;;;AAaA,IAAa,aAAa;;CAExB,OAAO;;CAEP,gBAAgB;;CAEhB,mBAAmB;;CAEnB,eAAe;;;;;;;CAOf,eAAe;;;;;;CAMf,mBAAmB;;CAEnB,eAAe;;;;;CAKf,qBAAqB;;;;;CAKrB,YAAY;;;;;;;CAOZ,kBAAkB;;;;;;CAMlB,aAAa;;CAEb,gBAAgB;;CAEhB,cAAc;;CAEd,YAAY;;CAEZ,YAAY;AACd"}
@@ -0,0 +1,41 @@
1
+ import { chromeVars } from "./chromeVars.js";
2
+ // src/chrome/MapChrome/mapKeyPlacement.ts
3
+ /**
4
+ * The least room, in CSS pixels, the map key needs to show: its minimised
5
+ * chip, a 44 px target inside the panel's 1 px border, rounded up to the 48 px
6
+ * control size. With less, the key's slot gives way.
7
+ */
8
+ var MAP_KEY_MIN_ROOM_PX = 48;
9
+ /**
10
+ * Where the map key sits and how tall it may be. Its bottom edge rides a gap
11
+ * above the bottom row once that row has been lifted by `lift` (zero or
12
+ * negative); its top stays a gap below the search pill, or below the tour card
13
+ * while `tourBottom` says one shows. Null while the key has no size.
14
+ *
15
+ * @remarks The shift is measured from where the grid rests the key, not
16
+ * taken from the bottom row's lift, because a taller bottom row (a toolbar)
17
+ * has already moved the resting place.
18
+ */
19
+ function placeMapKey(m, lift, tourBottom) {
20
+ if (m.mapKeyBottom === null) return null;
21
+ const bottomEdge = m.bottomRowTop + lift - 12;
22
+ const topEdge = Math.max(m.topStartBottom, tourBottom ?? 0) + 12;
23
+ return {
24
+ room: Math.max(0, bottomEdge - topEdge),
25
+ shift: bottomEdge - m.mapKeyBottom
26
+ };
27
+ }
28
+ /** Applies a key placement in the same frame as a chrome measurement. */
29
+ function applyMapKeyPlacement(root, placement) {
30
+ if (!placement) return;
31
+ const cap = Math.max(MAP_KEY_MIN_ROOM_PX, placement.room);
32
+ root.style.setProperty(chromeVars.mapKeyRoom, `${cap}px`);
33
+ root.style.setProperty(chromeVars.mapKeyLift, `${placement.shift}px`);
34
+ }
35
+ /** Whether a placement leaves too little room for the key's chip. */
36
+ function isMapKeyCrowded(placement) {
37
+ return placement !== null && placement.room < MAP_KEY_MIN_ROOM_PX;
38
+ }
39
+ export { applyMapKeyPlacement, isMapKeyCrowded, placeMapKey };
40
+
41
+ //# sourceMappingURL=mapKeyPlacement.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mapKeyPlacement.js","names":[],"sources":["../../../src/chrome/MapChrome/mapKeyPlacement.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-only\n// Copyright MapCairn contributors\nimport { CHROME_GAP_PX } from \"../chromeSpacing\";\nimport { chromeVars } from \"./chromeVars\";\n\n/**\n * The least room, in CSS pixels, the map key needs to show: its minimised\n * chip, a 44 px target inside the panel's 1 px border, rounded up to the 48 px\n * control size. With less, the key's slot gives way.\n */\nconst MAP_KEY_MIN_ROOM_PX = 48;\n\n/** The edges the map key is placed from, in px from the chrome container's top. */\nexport interface MapKeyMeasurements {\n /** Bottom edge of the key's slot before any shift, or null while it has no size. */\n readonly mapKeyBottom: number | null;\n /** Top of the bottom row before any lift. */\n readonly bottomRowTop: number;\n /** Bottom edge of the search pill's slot. */\n readonly topStartBottom: number;\n}\n\n/** What {@link placeMapKey} works out. */\nexport interface MapKeyPlacement {\n /** The most the key may be tall: the room between its top and bottom edges. */\n readonly room: number;\n /** How far its resting place must move, negative is up, to put its bottom edge there. */\n readonly shift: number;\n}\n\n/**\n * Where the map key sits and how tall it may be. Its bottom edge rides a gap\n * above the bottom row once that row has been lifted by `lift` (zero or\n * negative); its top stays a gap below the search pill, or below the tour card\n * while `tourBottom` says one shows. Null while the key has no size.\n *\n * @remarks The shift is measured from where the grid rests the key, not\n * taken from the bottom row's lift, because a taller bottom row (a toolbar)\n * has already moved the resting place.\n */\nexport function placeMapKey(\n m: MapKeyMeasurements,\n lift: number,\n tourBottom: number | null,\n): MapKeyPlacement | null {\n if (m.mapKeyBottom === null) {\n return null;\n }\n const bottomEdge = m.bottomRowTop + lift - CHROME_GAP_PX;\n const topEdge = Math.max(m.topStartBottom, tourBottom ?? 0) + CHROME_GAP_PX;\n return {\n room: Math.max(0, bottomEdge - topEdge),\n shift: bottomEdge - m.mapKeyBottom,\n };\n}\n\n/** Applies a key placement in the same frame as a chrome measurement. */\nexport function applyMapKeyPlacement(\n root: HTMLElement,\n placement: MapKeyPlacement | null,\n): void {\n if (!placement) {\n return;\n }\n // A key that has given way keeps the height of its chip, so its slot\n // still measures and it can come back when the room does.\n const cap = Math.max(MAP_KEY_MIN_ROOM_PX, placement.room);\n root.style.setProperty(chromeVars.mapKeyRoom, `${cap}px`);\n root.style.setProperty(chromeVars.mapKeyLift, `${placement.shift}px`);\n}\n\n/** Whether a placement leaves too little room for the key's chip. */\nexport function isMapKeyCrowded(placement: MapKeyPlacement | null): boolean {\n return placement !== null && placement.room < MAP_KEY_MIN_ROOM_PX;\n}\n"],"mappings":";;;;;;;AAUA,IAAM,sBAAsB;;;;;;;;;;;AA8B5B,SAAgB,YACd,GACA,MACA,YACwB;CACxB,IAAI,EAAE,iBAAiB,MACrB,OAAO;CAET,MAAM,aAAa,EAAE,eAAe,OAAA;CACpC,MAAM,UAAU,KAAK,IAAI,EAAE,gBAAgB,cAAc,CAAC,IAAA;CAC1D,OAAO;EACL,MAAM,KAAK,IAAI,GAAG,aAAa,OAAO;EACtC,OAAO,aAAa,EAAE;CACxB;AACF;;AAGA,SAAgB,qBACd,MACA,WACM;CACN,IAAI,CAAC,WACH;CAIF,MAAM,MAAM,KAAK,IAAI,qBAAqB,UAAU,IAAI;CACxD,KAAK,MAAM,YAAY,WAAW,YAAY,GAAG,IAAI,GAAG;CACxD,KAAK,MAAM,YAAY,WAAW,YAAY,GAAG,UAAU,MAAM,GAAG;AACtE;;AAGA,SAAgB,gBAAgB,WAA4C;CAC1E,OAAO,cAAc,QAAQ,UAAU,OAAO;AAChD"}
@@ -0,0 +1,13 @@
1
+ // src/chrome/MapChrome/sharesWidth.ts
2
+ /**
3
+ * Whether two slots share any width, so that one of them stacked above the
4
+ * other would cover it. A slot that comes within `gap` of the other counts as
5
+ * sharing, so a control never ends up closer than a gap beside a surface it
6
+ * only just clears.
7
+ */
8
+ function sharesWidth(a, b, gap) {
9
+ return a.left < b.left + b.width + gap && b.left < a.left + a.width + gap;
10
+ }
11
+ export { sharesWidth };
12
+
13
+ //# sourceMappingURL=sharesWidth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sharesWidth.js","names":[],"sources":["../../../src/chrome/MapChrome/sharesWidth.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-only\n// Copyright MapCairn contributors\n\n/** A horizontal extent, in CSS pixels from the chrome container's left edge. */\nexport interface Span {\n readonly left: number;\n readonly width: number;\n}\n\n/**\n * Whether two slots share any width, so that one of them stacked above the\n * other would cover it. A slot that comes within `gap` of the other counts as\n * sharing, so a control never ends up closer than a gap beside a surface it\n * only just clears.\n */\nexport function sharesWidth(a: Span, b: Span, gap: number): boolean {\n return a.left < b.left + b.width + gap && b.left < a.left + a.width + gap;\n}\n"],"mappings":";;;;;;;AAeA,SAAgB,YAAY,GAAS,GAAS,KAAsB;CAClE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ;AACxE"}
@@ -0,0 +1,199 @@
1
+ import { useMap } from "../../host/MapContext.js";
2
+ import { CURSOR_READOUT_CHROME, isMapHost } from "../../host/pointerTargets.js";
3
+ import { useFormatMessage, useMessages, usePreferences } from "../../services/hooks.js";
4
+ import { Isolate } from "../../ui/Isolate/Isolate.js";
5
+ import { VisuallyHidden } from "../../ui/VisuallyHidden/VisuallyHidden.js";
6
+ import { useChromeLayout } from "../layoutContext.js";
7
+ import { coordinates, line, readout, scaleBar, tickEnd, tickStart, track, unselectable, zoomLevel } from "./MapReadout.styles.js";
8
+ import { computeScaleBar, formatLatLng, formatLocale, formatZoom } from "@mapcairn/core";
9
+ import { useEffect, useMemo, useRef, useState } from "react";
10
+ import { jsx, jsxs } from "react/jsx-runtime";
11
+ // src/chrome/MapReadout/MapReadout.tsx
12
+ /**
13
+ * The widest the scale bar may be, in CSS pixels.
14
+ *
15
+ * @internal
16
+ */
17
+ var SCALE_BAR_MAX_WIDTH_PX = 96;
18
+ /** How long the scale bar stays after the zoom last changed before it fades. */
19
+ var SCALE_BAR_IDLE_MS = 2e3;
20
+ /**
21
+ * Whether focus arrived from the keyboard. Where `:focus-visible` is not
22
+ * supported, focus is treated as keyboard focus, so the bar stays shown.
23
+ */
24
+ function isKeyboardFocus(target) {
25
+ if (!(target instanceof Element)) return false;
26
+ try {
27
+ return target.matches(":focus-visible");
28
+ } catch {
29
+ return true;
30
+ }
31
+ }
32
+ /**
33
+ * Tracks whether keyboard focus is inside the map host. The host is
34
+ * focusable, so a click or tap on the map focuses it too; that pointer focus
35
+ * does not count, and a pointer press on the map ends keyboard focus. Focus
36
+ * moving between elements inside the host does not count as leaving it.
37
+ */
38
+ function useMapHasKeyboardFocus(host) {
39
+ const [focused, setFocused] = useState(false);
40
+ useEffect(() => {
41
+ if (!host) {
42
+ setFocused(false);
43
+ return;
44
+ }
45
+ const onFocusIn = (event) => {
46
+ setFocused(isKeyboardFocus(event.target));
47
+ };
48
+ const onFocusOut = (event) => {
49
+ const next = event.relatedTarget;
50
+ if (!(next instanceof Node && host.contains(next))) setFocused(false);
51
+ };
52
+ const onPointerDown = () => {
53
+ setFocused(false);
54
+ };
55
+ host.addEventListener("focusin", onFocusIn);
56
+ host.addEventListener("focusout", onFocusOut);
57
+ host.addEventListener("pointerdown", onPointerDown);
58
+ return () => {
59
+ host.removeEventListener("focusin", onFocusIn);
60
+ host.removeEventListener("focusout", onFocusOut);
61
+ host.removeEventListener("pointerdown", onPointerDown);
62
+ };
63
+ }, [host]);
64
+ return focused;
65
+ }
66
+ /**
67
+ * A scale bar drawn straight on the map: a thin line with end ticks and a
68
+ * haloed label, re-computed whenever the view changes.
69
+ *
70
+ * @remarks It is an image named with the spoken scale ("Scale: 200 metres").
71
+ * It fades about two seconds after the zoom last changed and comes back on
72
+ * the next zoom, but never while the map has keyboard focus or the user
73
+ * asked for reduced motion. Its width changes through a CSS custom property
74
+ * and a transform, set with CSSOM so no `style` attribute is rendered.
75
+ * Reads the map with `useMap()`, so it must sit inside the map context.
76
+ */
77
+ function ScaleBar({ units }) {
78
+ const { adapter, view, hostElement } = useMap();
79
+ const { reducedMotion } = usePreferences();
80
+ const messages = useMessages();
81
+ const format = useFormatMessage();
82
+ const mapHasFocus = useMapHasKeyboardFocus(hostElement);
83
+ const trackRef = useRef(null);
84
+ const latitude = view.center.lat;
85
+ const zoom = view.zoom;
86
+ const bar = useMemo(() => {
87
+ if (!adapter) return null;
88
+ return computeScaleBar({
89
+ metresPerPixel: adapter.metresPerPixel(latitude),
90
+ maxWidthPx: 96,
91
+ units,
92
+ messages
93
+ });
94
+ }, [
95
+ adapter,
96
+ latitude,
97
+ zoom,
98
+ units,
99
+ messages
100
+ ]);
101
+ const canFade = !reducedMotion && !mapHasFocus;
102
+ const [idleAtZoom, setIdleAtZoom] = useState(null);
103
+ useEffect(() => {
104
+ if (!canFade) return;
105
+ const timer = setTimeout(() => {
106
+ setIdleAtZoom(zoom);
107
+ }, SCALE_BAR_IDLE_MS);
108
+ return () => {
109
+ clearTimeout(timer);
110
+ };
111
+ }, [canFade, zoom]);
112
+ const idle = canFade && idleAtZoom === zoom;
113
+ const ratio = bar ? bar.widthPx / 96 : 0;
114
+ useEffect(() => {
115
+ const track = trackRef.current;
116
+ if (!track) return;
117
+ track.style.setProperty("--scale-max", `96px`);
118
+ track.style.setProperty("--scale-ratio", String(ratio));
119
+ }, [ratio]);
120
+ if (!bar) return null;
121
+ return /* @__PURE__ */ jsxs("div", {
122
+ role: "img",
123
+ "aria-label": format(bar.accessibleLabel),
124
+ "data-chrome": "scale-bar",
125
+ "data-idle": idle ? "true" : "false",
126
+ className: scaleBar,
127
+ children: [/* @__PURE__ */ jsx("span", { children: /* @__PURE__ */ jsx(Isolate, { children: bar.label }) }), /* @__PURE__ */ jsxs("div", {
128
+ ref: trackRef,
129
+ className: track,
130
+ "data-testid": "scale-bar-track",
131
+ children: [
132
+ /* @__PURE__ */ jsx("span", { className: line }),
133
+ /* @__PURE__ */ jsx("span", { className: tickStart }),
134
+ /* @__PURE__ */ jsx("span", { className: tickEnd })
135
+ ]
136
+ })]
137
+ });
138
+ }
139
+ /**
140
+ * The position under the pointer and the zoom level, as plain muted text with
141
+ * tabular figures. It is not a live region: the settled zoom is already
142
+ * announced after each zoom, so a change here is not spoken.
143
+ *
144
+ * @remarks The zoom is drawn as "z 12.4", which is `aria-hidden` and not
145
+ * selectable, and carried as visually hidden text ("Zoom 12.4", after a
146
+ * comma when a position comes first), so a screen reader and a copy of the
147
+ * text read it once and in full, in the order the eye sees it.
148
+ */
149
+ function CursorCoordinates({ latlng, zoom }) {
150
+ const messages = useMessages();
151
+ const { t } = messages;
152
+ if (!latlng && zoom === void 0) return null;
153
+ const level = zoom === void 0 ? "" : formatZoom(zoom, formatLocale(messages));
154
+ return /* @__PURE__ */ jsxs("p", {
155
+ "data-chrome": "cursor-coordinates",
156
+ className: coordinates,
157
+ children: [latlng ? /* @__PURE__ */ jsx("span", { children: /* @__PURE__ */ jsx(Isolate, {
158
+ figure: true,
159
+ children: formatLatLng(latlng)
160
+ }) }) : null, zoom === void 0 ? null : /* @__PURE__ */ jsxs("span", {
161
+ "data-testid": "zoom-level",
162
+ className: zoomLevel,
163
+ children: [/* @__PURE__ */ jsx("span", {
164
+ "aria-hidden": "true",
165
+ className: unselectable,
166
+ children: /* @__PURE__ */ jsx(Isolate, { children: t("chrome.readout.zoomShort", { level }) })
167
+ }), /* @__PURE__ */ jsx(VisuallyHidden, { children: t(latlng ? "chrome.readout.zoomSpokenAfterPosition" : "chrome.readout.zoomSpoken", { level }) })]
168
+ })]
169
+ });
170
+ }
171
+ /**
172
+ * The bottom-start readout: the scale bar with the cursor coordinates and
173
+ * zoom level under it. One floating element, for the layout collision test,
174
+ * and a landmark named "Map scale" so its content is inside a landmark.
175
+ * Reads the zoom with `useMap()` and the layout with `useChromeLayout()`, so
176
+ * it must sit inside the map context and a `MapChrome`.
177
+ */
178
+ function MapReadout({ units, latlng, showZoom, onCursorLeave }) {
179
+ const { view } = useMap();
180
+ const { layout } = useChromeLayout();
181
+ const { t } = useMessages();
182
+ const zoomShown = showZoom ?? layout === "panel";
183
+ return /* @__PURE__ */ jsxs("section", {
184
+ "aria-label": t("chrome.readout.label", {}),
185
+ "data-chrome": CURSOR_READOUT_CHROME,
186
+ "data-testid": "map-readout",
187
+ className: readout,
188
+ onPointerLeave: (event) => {
189
+ if (!isMapHost(event.relatedTarget)) onCursorLeave?.();
190
+ },
191
+ children: [/* @__PURE__ */ jsx(ScaleBar, { units }), /* @__PURE__ */ jsx(CursorCoordinates, {
192
+ latlng,
193
+ zoom: zoomShown ? view.zoom : void 0
194
+ })]
195
+ });
196
+ }
197
+ export { CursorCoordinates, MapReadout, SCALE_BAR_IDLE_MS, SCALE_BAR_MAX_WIDTH_PX, ScaleBar };
198
+
199
+ //# sourceMappingURL=MapReadout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MapReadout.js","names":["styles.scaleBar","styles.track","styles.line","styles.tickStart","styles.tickEnd","styles.coordinates","styles.zoomLevel","styles.unselectable","styles.readout"],"sources":["../../../src/chrome/MapReadout/MapReadout.tsx"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-only\n// Copyright MapCairn contributors\nimport {\n computeScaleBar,\n formatLatLng,\n formatLocale,\n formatZoom,\n type LatLng,\n type UnitSystem,\n} from \"@mapcairn/core\";\nimport { useEffect, useMemo, useRef, useState } from \"react\";\nimport { useMap } from \"../../host\";\nimport { CURSOR_READOUT_CHROME, isMapHost } from \"../../host/pointerTargets\";\nimport { useFormatMessage, useMessages, usePreferences } from \"../../services\";\nimport { Isolate } from \"../../ui/Isolate\";\nimport { VisuallyHidden } from \"../../ui/VisuallyHidden\";\nimport { useChromeLayout } from \"../layoutContext\";\nimport * as styles from \"./MapReadout.css\";\n\n/**\n * The widest the scale bar may be, in CSS pixels.\n *\n * @internal\n */\nexport const SCALE_BAR_MAX_WIDTH_PX = 96;\n\n/** How long the scale bar stays after the zoom last changed before it fades. */\nexport const SCALE_BAR_IDLE_MS = 2000;\n\n/** Props for {@link ScaleBar}. */\nexport interface ScaleBarProps {\n readonly units: UnitSystem;\n}\n\n/**\n * Whether focus arrived from the keyboard. Where `:focus-visible` is not\n * supported, focus is treated as keyboard focus, so the bar stays shown.\n */\nfunction isKeyboardFocus(target: EventTarget | null): boolean {\n if (!(target instanceof Element)) {\n return false;\n }\n try {\n return target.matches(\":focus-visible\");\n } catch {\n return true;\n }\n}\n\n/**\n * Tracks whether keyboard focus is inside the map host. The host is\n * focusable, so a click or tap on the map focuses it too; that pointer focus\n * does not count, and a pointer press on the map ends keyboard focus. Focus\n * moving between elements inside the host does not count as leaving it.\n */\nfunction useMapHasKeyboardFocus(host: HTMLElement | null): boolean {\n const [focused, setFocused] = useState(false);\n useEffect(() => {\n if (!host) {\n setFocused(false);\n return;\n }\n const onFocusIn = (event: FocusEvent) => {\n setFocused(isKeyboardFocus(event.target));\n };\n const onFocusOut = (event: FocusEvent) => {\n const next = event.relatedTarget;\n if (!(next instanceof Node && host.contains(next))) {\n setFocused(false);\n }\n };\n const onPointerDown = () => {\n setFocused(false);\n };\n host.addEventListener(\"focusin\", onFocusIn);\n host.addEventListener(\"focusout\", onFocusOut);\n host.addEventListener(\"pointerdown\", onPointerDown);\n return () => {\n host.removeEventListener(\"focusin\", onFocusIn);\n host.removeEventListener(\"focusout\", onFocusOut);\n host.removeEventListener(\"pointerdown\", onPointerDown);\n };\n }, [host]);\n return focused;\n}\n\n/**\n * A scale bar drawn straight on the map: a thin line with end ticks and a\n * haloed label, re-computed whenever the view changes.\n *\n * @remarks It is an image named with the spoken scale (\"Scale: 200 metres\").\n * It fades about two seconds after the zoom last changed and comes back on\n * the next zoom, but never while the map has keyboard focus or the user\n * asked for reduced motion. Its width changes through a CSS custom property\n * and a transform, set with CSSOM so no `style` attribute is rendered.\n * Reads the map with `useMap()`, so it must sit inside the map context.\n */\nexport function ScaleBar({ units }: ScaleBarProps) {\n const { adapter, view, hostElement } = useMap();\n const { reducedMotion } = usePreferences();\n const messages = useMessages();\n const format = useFormatMessage();\n const mapHasFocus = useMapHasKeyboardFocus(hostElement);\n const trackRef = useRef<HTMLDivElement>(null);\n const latitude = view.center.lat;\n const zoom = view.zoom;\n\n // biome-ignore lint/correctness/useExhaustiveDependencies: the adapter object stays the same while the view moves, so the zoom is what makes its resolution change.\n const bar = useMemo(() => {\n if (!adapter) {\n return null;\n }\n // At the view centre a globe and a flat map share one scale: MapLibre\n // sizes the globe by 1 / cos(centre latitude) for exactly that reason\n // (`getGlobeRadiusPixels`), so the bar needs no globe case.\n return computeScaleBar({\n metresPerPixel: adapter.metresPerPixel(latitude),\n maxWidthPx: SCALE_BAR_MAX_WIDTH_PX,\n units,\n messages,\n });\n }, [adapter, latitude, zoom, units, messages]);\n\n const canFade = !reducedMotion && !mapHasFocus;\n const [idleAtZoom, setIdleAtZoom] = useState<number | null>(null);\n useEffect(() => {\n if (!canFade) {\n return;\n }\n const timer = setTimeout(() => {\n setIdleAtZoom(zoom);\n }, SCALE_BAR_IDLE_MS);\n return () => {\n clearTimeout(timer);\n };\n }, [canFade, zoom]);\n const idle = canFade && idleAtZoom === zoom;\n\n const ratio = bar ? bar.widthPx / SCALE_BAR_MAX_WIDTH_PX : 0;\n useEffect(() => {\n const track = trackRef.current;\n if (!track) {\n return;\n }\n track.style.setProperty(\"--scale-max\", `${SCALE_BAR_MAX_WIDTH_PX}px`);\n track.style.setProperty(\"--scale-ratio\", String(ratio));\n }, [ratio]);\n\n if (!bar) {\n return null;\n }\n return (\n <div\n role=\"img\"\n aria-label={format(bar.accessibleLabel)}\n data-chrome=\"scale-bar\"\n data-idle={idle ? \"true\" : \"false\"}\n className={styles.scaleBar}\n >\n <span>\n <Isolate>{bar.label}</Isolate>\n </span>\n <div\n ref={trackRef}\n className={styles.track}\n data-testid=\"scale-bar-track\"\n >\n <span className={styles.line} />\n <span className={styles.tickStart} />\n <span className={styles.tickEnd} />\n </div>\n </div>\n );\n}\n\n/** Props for {@link CursorCoordinates}. */\nexport interface CursorCoordinatesProps {\n /**\n * The position under the pointer, or null to show nothing. The app passes\n * null on touch devices, where there is no hovering pointer.\n */\n readonly latlng: LatLng | null;\n /**\n * The map's zoom level in the 256 px tile convention, shown beside the\n * position as \"z 12.4\", or undefined to leave it out.\n */\n readonly zoom?: number;\n}\n\n/**\n * The position under the pointer and the zoom level, as plain muted text with\n * tabular figures. It is not a live region: the settled zoom is already\n * announced after each zoom, so a change here is not spoken.\n *\n * @remarks The zoom is drawn as \"z 12.4\", which is `aria-hidden` and not\n * selectable, and carried as visually hidden text (\"Zoom 12.4\", after a\n * comma when a position comes first), so a screen reader and a copy of the\n * text read it once and in full, in the order the eye sees it.\n */\nexport function CursorCoordinates({ latlng, zoom }: CursorCoordinatesProps) {\n const messages = useMessages();\n const { t } = messages;\n if (!latlng && zoom === undefined) {\n return null;\n }\n const level =\n zoom === undefined ? \"\" : formatZoom(zoom, formatLocale(messages));\n return (\n <p data-chrome=\"cursor-coordinates\" className={styles.coordinates}>\n {latlng ? (\n <span>\n <Isolate figure>{formatLatLng(latlng)}</Isolate>\n </span>\n ) : null}\n {zoom === undefined ? null : (\n <span data-testid=\"zoom-level\" className={styles.zoomLevel}>\n <span aria-hidden=\"true\" className={styles.unselectable}>\n <Isolate>{t(\"chrome.readout.zoomShort\", { level })}</Isolate>\n </span>\n <VisuallyHidden>\n {t(\n latlng\n ? \"chrome.readout.zoomSpokenAfterPosition\"\n : \"chrome.readout.zoomSpoken\",\n { level },\n )}\n </VisuallyHidden>\n </span>\n )}\n </p>\n );\n}\n\n/** Props for {@link MapReadout}. */\nexport interface MapReadoutProps\n extends ScaleBarProps,\n Pick<CursorCoordinatesProps, \"latlng\"> {\n /**\n * Whether to show the map's zoom level beside the coordinates. Left out, it\n * follows the chrome layout: shown in the side panel layout and left out in\n * the bottom sheet layout, which keeps the readout short on a small screen.\n * Pass true or false to decide it yourself. The credits popover clears the\n * readout either way.\n */\n readonly showZoom?: boolean;\n /**\n * Called when the pointer leaves the readout for anything but the map. The\n * map keeps the last position while the pointer moves from it onto the\n * readout, so the coordinates stay put and can be copied; this is where the\n * host clears them.\n */\n readonly onCursorLeave?: () => void;\n}\n\n/**\n * The bottom-start readout: the scale bar with the cursor coordinates and\n * zoom level under it. One floating element, for the layout collision test,\n * and a landmark named \"Map scale\" so its content is inside a landmark.\n * Reads the zoom with `useMap()` and the layout with `useChromeLayout()`, so\n * it must sit inside the map context and a `MapChrome`.\n */\nexport function MapReadout({\n units,\n latlng,\n showZoom,\n onCursorLeave,\n}: MapReadoutProps) {\n const { view } = useMap();\n const { layout } = useChromeLayout();\n const { t } = useMessages();\n const zoomShown = showZoom ?? layout === \"panel\";\n return (\n <section\n aria-label={t(\"chrome.readout.label\", {})}\n data-chrome={CURSOR_READOUT_CHROME}\n data-testid=\"map-readout\"\n className={styles.readout}\n onPointerLeave={(event) => {\n if (!isMapHost(event.relatedTarget)) {\n onCursorLeave?.();\n }\n }}\n >\n <ScaleBar units={units} />\n <CursorCoordinates\n latlng={latlng}\n zoom={zoomShown ? view.zoom : undefined}\n />\n </section>\n );\n}\n"],"mappings":"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"}
@@ -0,0 +1,14 @@
1
+ /* empty css */
2
+ // src/chrome/MapReadout/MapReadout.css.ts
3
+ var readout = "c8zacs0";
4
+ var scaleBar = "c8zacs1";
5
+ var track = "c8zacs2";
6
+ var line = "c8zacs3";
7
+ var tickStart = "c8zacs4";
8
+ var tickEnd = "c8zacs5";
9
+ var coordinates = "c8zacs6";
10
+ var zoomLevel = "c8zacs7";
11
+ var unselectable = "c8zacs8";
12
+ export { coordinates, line, readout, scaleBar, tickEnd, tickStart, track, unselectable, zoomLevel };
13
+
14
+ //# sourceMappingURL=MapReadout.styles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MapReadout.styles.js","names":[],"sources":[],"mappings":""}