@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
package/README.md CHANGED
@@ -1,3 +1,168 @@
1
- # Temporary Holding Version
1
+ # `@mapcairn/map`
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ The map user interface of MapCairn, in React: the chrome around the map, the bottom sheet and its panels, the search, locate, measure, draw and directions tools, the first-visit tour, the accessible primitives and the `MapView` host. Use it to put a finished, accessible interface around a MapLibre map without building each control yourself.
4
+
5
+ It never imports a map engine, an adapter or a browser service. Everything it needs comes from the `Services` bundle that `ServicesProvider` supplies, so the same components run against real adapters in an app and against fakes in a test. It is built on [`@mapcairn/core`](https://github.com/MapCairn/mapcairn/tree/main/packages/core), [`@mapcairn/react`](https://github.com/MapCairn/mapcairn/tree/main/packages/react) and [`@mapcairn/theme`](https://github.com/MapCairn/mapcairn/tree/main/packages/theme).
6
+
7
+ **Status:** a release candidate, for early adopters. The API is still settling, so a breaking change can land before `0.1.0`; the [changelog](https://github.com/MapCairn/mapcairn/blob/main/CHANGELOG.md) lists each one. Until `0.1.0`, add `@next` to every package name in the install commands below.
8
+
9
+ ## Install
10
+
11
+ ```bash
12
+ npm install @mapcairn/map@next @mapcairn/core@next @mapcairn/theme@next
13
+ pnpm add @mapcairn/map@next @mapcairn/core@next @mapcairn/theme@next
14
+ yarn add @mapcairn/map@next @mapcairn/core@next @mapcairn/theme@next
15
+ ```
16
+
17
+ The examples below import from `@mapcairn/core` and `@mapcairn/theme` too, so install them beside it. React and React DOM 19 are peer dependencies, and your app already has them.
18
+
19
+ The package is ESM only: it has no `main` field and no CommonJS build. A TypeScript project needs `moduleResolution` set to `node16`, `nodenext` or `bundler`; `node10` is not supported.
20
+
21
+ ## Set up
22
+
23
+ Import the two stylesheets once, in your entry module. The first holds the design tokens and the second the styles of every component. Both are plain CSS, so an app needs no vanilla-extract plugin.
24
+
25
+ ```tsx
26
+ import "@mapcairn/theme/tokens.css";
27
+ import "@mapcairn/map/styles.css";
28
+ ```
29
+
30
+ The JavaScript imports no CSS, so the components render on the server as plain modules. A few things are yours to provide:
31
+
32
+ - `MapChrome` fills its container, so give `html`, `body` and the element you render into a height.
33
+ - The tokens name the IBM Plex Sans Variable font, which your app loads (for example from `@fontsource-variable/ibm-plex-sans`). Without it the type falls back to the system font.
34
+ - The map engine and its styles. The package never imports one; your app supplies a `MapAdapter` over MapLibre GL JS in the `Services` bundle. The reference adapter is in the repository's `packages/web` and is not published as a package yet.
35
+
36
+ The styles of the primitives (buttons, chips, surfaces and list rows) sit in a cascade layer, so an unlayered rule in your own CSS, such as `button { background: transparent; border: 0; padding: 0 }` or `:focus-visible { outline: none }`, beats them. Put your app's base styles and resets in an `@layer` that is declared before `@mapcairn/map/styles.css` is imported, and they rank below the primitives. This is a known trade-off for 0.1.0; see [Overriding a primitive](https://github.com/MapCairn/mapcairn/blob/main/DESIGN.md#overriding-a-primitive).
37
+
38
+ The generated names of the CSS custom properties in `tokens.css` are private and can change in any release, so do not write your own stylesheet against them. [How the CSS ships](https://github.com/MapCairn/mapcairn/blob/main/DESIGN.md#how-the-css-ships) says what is and is not settled.
39
+
40
+ ## Usage
41
+
42
+ Build the services once, wrap the tree, then render the map with its chrome. This is a whole app. It runs on the SDK's in-memory fakes, so it requests nothing and draws no map tiles; a real map swaps in a `MapAdapter`.
43
+
44
+ ```tsx
45
+ import { createFakeServices } from "@mapcairn/core";
46
+ import {
47
+ FocusRegistryProvider,
48
+ LiveRegionProvider,
49
+ MapChrome,
50
+ MapView,
51
+ SearchPill,
52
+ ServicesProvider,
53
+ TooltipProvider,
54
+ useBasemaps,
55
+ useMap,
56
+ } from "@mapcairn/map";
57
+ import { type ReactNode, useState } from "react";
58
+
59
+ export function App() {
60
+ const [services] = useState(createFakeServices);
61
+ return (
62
+ <ServicesProvider services={services}>
63
+ <LiveRegionProvider>
64
+ <TooltipProvider>
65
+ <MapScreen />
66
+ </TooltipProvider>
67
+ </LiveRegionProvider>
68
+ </ServicesProvider>
69
+ );
70
+ }
71
+
72
+ function MapScreen() {
73
+ const basemaps = useBasemaps();
74
+ return (
75
+ <MapView
76
+ initialView={{
77
+ center: { lat: -33.92, lng: 18.42 },
78
+ zoom: 11,
79
+ bearing: 0,
80
+ }}
81
+ basemap={basemaps.resolve(basemaps.defaultId)}
82
+ chrome={(background) => <Chrome background={background} />}
83
+ />
84
+ );
85
+ }
86
+
87
+ function Chrome({ background }: { readonly background: ReactNode }) {
88
+ const map = useMap();
89
+ return (
90
+ <FocusRegistryProvider focusMap={map.focusMap}>
91
+ <MapChrome
92
+ background={background}
93
+ modal={false}
94
+ topStart={
95
+ <SearchPill
96
+ onSelect={(result) =>
97
+ map.adapter?.setView({ center: result.centre, zoom: 14 })
98
+ }
99
+ />
100
+ }
101
+ />
102
+ </FocusRegistryProvider>
103
+ );
104
+ }
105
+ ```
106
+
107
+ The repository's `examples/embed` is the full version of this app, with the end stack of controls, the sheet, the measure tool, layers and a search provider of its own. A test in the repository fails if this snippet uses an import, a component or a prop that the example does not. `LiveRegionProvider` is the one announcer: without it, announcements are dropped.
108
+
109
+ ## Loading the map in a chunk of its own
110
+
111
+ `@mapcairn/map` is a whole interface, so an app that imports it in its entry module ships all of it with the first page. The example app on the fakes, which loads no map engine, builds to a single script large enough that Vite warns about its size. If the map is not the first thing a visitor needs, load it on demand. Put the code that imports `@mapcairn/map` in a module of its own (here `App.tsx`, which exports `App`, as above) and load it with a dynamic import:
112
+
113
+ ```tsx
114
+ import "@mapcairn/theme/tokens.css";
115
+ import "@mapcairn/map/styles.css";
116
+ import { lazy, Suspense } from "react";
117
+ import { createRoot } from "react-dom/client";
118
+
119
+ const App = lazy(() =>
120
+ import("./App").then((module) => ({ default: module.App })),
121
+ );
122
+
123
+ const root = document.getElementById("root");
124
+ if (root) {
125
+ createRoot(root).render(
126
+ <Suspense fallback={null}>
127
+ <App />
128
+ </Suspense>,
129
+ );
130
+ }
131
+ ```
132
+
133
+ A bundler that splits on dynamic imports, such as Vite, then writes `App.tsx` and everything only it imports, which is the whole interface, to a separate chunk that loads when the app mounts. Put the code that imports your map engine in the same module, so the engine loads with the map. Show something useful in the `Suspense` fallback, such as a placeholder with the page's height.
134
+
135
+ ## What it exports
136
+
137
+ Everything comes from `@mapcairn/map`. In outline:
138
+
139
+ - **Services:** `ServicesProvider` and a hook for each service.
140
+ - **Map host:** `MapView`, which mounts the adapter and wires its events, and `useMap`.
141
+ - **Chrome:** `MapChrome`, which owns the position of every control floating over the map, and the controls that fill its slots.
142
+ - **Panels and layers:** the sheet content, the basemap picker, settings, the layers panel, feature cards and `useDataLayers`.
143
+ - **Tools:** search, locate, measure, draw and directions, each as a component and a hook.
144
+ - **Primitives:** buttons, chips, list rows, sliders, the live region and the other accessible building blocks, with the one `Icon` component.
145
+
146
+ ## Exports in detail
147
+
148
+ The Source column names folders under `packages/map/src` in the repository.
149
+
150
+ | Area | Source | What it holds |
151
+ | ---------- | -------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
152
+ | Services | `src/services` | `ServicesProvider` and `useServices`, with a typed hook per service: `useSearchProvider`, `useSuggestionProvider`, `useRoutingProvider`, `useFileOpener`, `useSelectionStore` (the host's store of selected features) and `useFeatureQuery` (the host's query for the features inside a shape; each of these last five is undefined when the host has none), `useLocationProvider`, `useClipboard`, `useFileSaver`, `useUrlState`, `useThemeSource`, `usePreferences`, `useOnline` (whether the browser says the device is online, true where the host gives no signal), `useSaveData`, `useLayers` (the host's layer catalogue, a store `useDataLayers` reads with `useSyncExternalStore`), `useBasemaps` (the host's basemap catalogue, or the built-in one), `useMessages` (the active message catalogue, which follows the language setting when the host offers languages) and `useLanguages` (the host's `LanguageCatalogue`, or undefined), `useMapAdapterFactory`, plus `useSettings` and `useTheme`. Throws outside a provider. |
153
+ | Map host | `src/host` | `MapView`, which mounts one adapter from the services in a host element and wires its events, and `useMap` for components below it. It takes an `initialView`, the active `basemap`, event callbacks, overlay `children` and a `chrome` render prop. The overlays (`MapOverlayLayer`, `PinMarker`, `MeasureOverlay`, `AccuracyCircle`, `CentreCrosshair`), `useLongPress` and `usePointerPosition` live here too. |
154
+ | Chrome | `src/chrome` | `MapChrome`, which owns the position of every control floating over the map, and its slot contents: `EndStack`, `MapReadout` (scale bar, cursor coordinates and the zoom level as "z 12.4"; the zoom follows the chrome layout, shown in the side panel layout only, unless `showZoom` says otherwise; a host that shows the position from `MapView`'s `onPointerMove` passes `onCursorLeave` to clear it, because the map keeps the position while the pointer is over the readout), `Attribution` and `Sheet` (bottom sheet or side panel). `MapChrome` also has a `mapKey` slot above the scale bar for `MapKey` (see Panels); a host that leaves the prop out has no map key. Also the layout and focus contexts. |
155
+ | Panels | `src/panels` | The sheet content: `SheetContent` (Settings and Help for the `settings` and `help` sections, and the Map options sections otherwise), `BasemapPicker`, `SettingsSection` (with a language switcher when the host offers more than one language; its privacy statement is the host's `privacyNote`, passed through `SheetContent`, with a neutral default), `PinSection`, `HelpSection` (with an optional host About block, the `about` prop also on `SheetContent`), `ShapesSection` (its import offers a native "WKT coordinate order" select, longitude first until changed and kept for the session, backed by `useDraw().wktAxisOrder`, and when a WKT file's first position fits only the other order it imports nothing and offers a button that reads the file the other way through `useDraw().rereadImport`) and `ExportSection`. `LayersSection` is in `src/layers`. It lists the layers of a ready `LayerCatalogue`, and for a catalogue that loads it says so while it loads, when it has failed (with a Try again button that `useDataLayers.retryCatalogue()` backs), when it is empty, and how many definitions were skipped; a refresh that fails keeps the last list. A host whose catalogue was ready with no layers at the start has no Layers section. Its `intro` prop (also on `SheetContent`) replaces the line above the layers, "Open data from public providers", for a host whose layers are not public. It offers "Turn off all layers", a "Turn off N in `<group name>`" action for each group and an Undo below either (`useDataLayers` has `turnOff`, `turnedOff` and `undoTurnOff`); a host that does not want them passes `showTurnOffAll={false}` to `LayersSection` or `SheetContent`. `LayerKey` draws one layer's key and is used by the Layers section and by `MapKey`, which shows the key of every layer that is on, over the map, with a button that minimises it to a chip (a phone in either orientation starts it minimised, a larger screen starts it open, or `defaultMinimised` says; that is decided when it first appears, and the choice is held in memory only). `mapKeyBlocks` returns the same blocks as data. |
156
+ | Layers | `src/layers` | `useDataLayers` (the data layers' state and every action on them), `MapDataLayers` (draws them through the adapter), `FeatureCard`, `LayersSection` and `SelectionMarker` (the ring round the feature whose card is open). `useDataLayers.identifyAt(target, { focus })` asks the tile layers that have an `identify` block what is at a place, at most `MAX_IDENTIFY_LAYERS` (4) layers with `IDENTIFY_TIMEOUT_MS` (8 seconds) each, opens what they find as a card or a list and says one message (sent with the announcer's `keep` option, because it reports the outcome of the person's tap); it resolves with `{ asked, found }`, or null when it was cancelled. `cancelIdentify()` ends one in flight and returns whether there was one, and `identifying` is true while one waits. `select` and `choose` cancel it when they open a card or a list, and `MapDataLayers` cancels it when `ignoreTaps` turns true; a host calls `identifyAt` from its map click and its `I` key, and `cancelIdentify` when the open surface changes, on a long press and on Escape (`packages/web/src/app/useMapApp.ts` is the reference). `LayersSection` says an identifiable layer can be tapped, and `useIdentifyFeedback(layers.identifying)` with `<IdentifyStatus onCancel={layers.cancelIdentify} />` give a host the "Looking up what is here" line to show in its bottom-centre slot after `IDENTIFY_FEEDBACK_MS` (400 ms; it is a `StatusMessage`, so it says itself once, and the result is said separately when it arrives). No layer of the reference site defines `identify`, so it asks nothing there. `useFeatureSelection(layers, { formatters })` holds the host's store of selected features for the ui, and returns null when the host supplies no store (`formatters` are the ones card templates may name, for the titles in its messages); call it once beside `useDataLayers` and pass the result to `SelectionProvider`, and components read it with `useSelection()`. The reference host and the example app call the hook and mount the provider; no component reads `useSelection()` yet. Layer card and list templates, feed-shape labels and units can use host translations through the active message catalogue. |
157
+ | Tools | `src/tools` | `SearchPill` with `useSearch` and `useSuggestions` (places as the person types, only when the host supplies a suggestion provider), `useLocate`, `MeasureToolbar` with `useMeasure`, `DrawToolbar` with `useDraw` and `DrawMapBindings`, `DirectionsPanel` with `useDirections`, `MapDirections` and `DirectionsOverlay` (`useDirections` reports `available` only when the host has a routing provider, and a host shows the Directions button, `EndStack`'s `directions` prop, only then), `PinCard` with `useReverseAddress` (the host's `lookupNote` says what the lookup sends and to whom, with a neutral default), and `TourCard` with `useTour`. |
158
+ | Primitives | `src/ui` | `Button`, `Chip`, `ControlGroup`, `EmptyState`, `Icon` (the one way to draw a Lucide icon, with `mirrorInRtl` for one that points along the reading direction), `IconButton`, `ListRow`, `LiveRegionProvider` with `useAnnounce` (the one announcer), `SegmentedControl`, `SkipLink`, `Slider`, `StatusMessage` with `StatusMessageFocusProvider` (where focus goes when a message goes away and its origin cannot take it; `MapView` supplies the map region), `Surface`, `Switch`, `Tooltip` and `VisuallyHidden`. |
159
+
160
+ The `MapChrome` slots, the sheet detents and the accessibility contract of each component are in [`DESIGN.md`](https://github.com/MapCairn/mapcairn/blob/main/DESIGN.md). For how map fits with the other packages, read [`ARCHITECTURE.md`](https://github.com/MapCairn/mapcairn/blob/main/ARCHITECTURE.md).
161
+
162
+ ## Licence
163
+
164
+ `@mapcairn/map` is licensed under AGPL-3.0-only, and the [licence text](https://github.com/MapCairn/mapcairn/blob/main/packages/map/LICENSE) comes with the package. If you ship it in a product, or let people use a modified version over a network, you must publish the corresponding source under the same licence. The SDK packages depend only on permissively licensed packages. The [licence section of the repository README](https://github.com/MapCairn/mapcairn#licence) says more, including how to talk about other terms for closed-source use.
165
+
166
+ ## Contributing and changes
167
+
168
+ The source and the issue tracker are in the [repository](https://github.com/MapCairn/mapcairn); file a bug in the [issue tracker](https://github.com/MapCairn/mapcairn/issues). Read [`CONTRIBUTING.md`](https://github.com/MapCairn/mapcairn/blob/main/CONTRIBUTING.md) before you send a pull request. Changes between releases are listed in [`CHANGELOG.md`](https://github.com/MapCairn/mapcairn/blob/main/CHANGELOG.md).
@@ -0,0 +1,304 @@
1
+ import { useMap } from "../../host/MapContext.js";
2
+ import { useMessages, usePreferences } from "../../services/hooks.js";
3
+ import { IconButton } from "../../ui/IconButton/IconButton.js";
4
+ import { link, list, onMapIcon, popover, root } from "./Attribution.styles.js";
5
+ import { buildAttribution, clearsInlineEnd } from "@mapcairn/core";
6
+ import { Info } from "lucide-react";
7
+ import { useCallback, useEffect, useId, useLayoutEffect, useRef, useState } from "react";
8
+ import { jsx, jsxs } from "react/jsx-runtime";
9
+ // src/chrome/Attribution/Attribution.tsx
10
+ /**
11
+ * How long the credits stay on screen by themselves once the map has
12
+ * started, if the person does nothing with the map first.
13
+ *
14
+ * @internal
15
+ */
16
+ var ATTRIBUTION_INTRO_MS = 5e3;
17
+ /**
18
+ * How long the credits take to fade out after their first showing.
19
+ *
20
+ * @internal
21
+ */
22
+ var ATTRIBUTION_FADE_MS = 200;
23
+ /** Smaller differences than this, in degrees or zoom levels, are not a move. */
24
+ var VIEW_EPSILON = 1e-9;
25
+ /** Whether two views show the same place at the same zoom and bearing. */
26
+ function sameView(a, b) {
27
+ return Math.abs(a.center.lat - b.center.lat) < VIEW_EPSILON && Math.abs(a.center.lng - b.center.lng) < VIEW_EPSILON && Math.abs(a.zoom - b.zoom) < VIEW_EPSILON && Math.abs(a.bearing - b.bearing) < VIEW_EPSILON;
28
+ }
29
+ /**
30
+ * Whether the open credits popover starts a gap after the end edge of the
31
+ * readout in bottom-start, so the two share no width and the popover need not
32
+ * rise over the readout's height. True when the chrome has no readout. It is
33
+ * measured before the popover is painted and again whenever the popover, the
34
+ * readout or the chrome changes size (the cursor coordinates widen the readout
35
+ * as the pointer enters the map) and whenever the readout finishes sliding
36
+ * sideways (the side panel opening or closing moves it with a transform and
37
+ * no change of size). Nothing is observed while the popover is closed.
38
+ */
39
+ function useClearOfReadout(regionRef, open, placement) {
40
+ const [clear, setClear] = useState(false);
41
+ useLayoutEffect(() => {
42
+ const region = regionRef.current;
43
+ if (!open || region === null) return;
44
+ const chrome = region.closest("[data-chrome-root]");
45
+ const readout = chrome?.querySelector("[data-chrome=\"bottom-start\"]") ?? null;
46
+ const measure = () => {
47
+ setClear(readout === null || clearsInlineEnd(readout.getBoundingClientRect(), region.getBoundingClientRect(), 12, getComputedStyle(region).direction === "rtl" ? "rtl" : "ltr"));
48
+ };
49
+ measure();
50
+ const onTransitionEnd = (event) => {
51
+ if (event.target === readout && event.propertyName === "transform") measure();
52
+ };
53
+ readout?.addEventListener("transitionend", onTransitionEnd);
54
+ const observer = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(measure);
55
+ for (const element of [
56
+ region,
57
+ chrome,
58
+ readout
59
+ ]) if (element) observer?.observe(element);
60
+ return () => {
61
+ readout?.removeEventListener("transitionend", onTransitionEnd);
62
+ observer?.disconnect();
63
+ };
64
+ }, [
65
+ open,
66
+ placement,
67
+ regionRef
68
+ ]);
69
+ return clear;
70
+ }
71
+ /**
72
+ * Whether the open popover has been on screen for a frame. Its offset slides
73
+ * (see `Attribution.css`) only from then on, so the position it takes when it
74
+ * opens, which the first measurement may still change before it is painted, is
75
+ * never animated.
76
+ */
77
+ function useSettled(open) {
78
+ const [settled, setSettled] = useState(false);
79
+ useEffect(() => {
80
+ if (!open) {
81
+ setSettled(false);
82
+ return;
83
+ }
84
+ const frame = requestAnimationFrame(() => {
85
+ setSettled(true);
86
+ });
87
+ return () => {
88
+ cancelAnimationFrame(frame);
89
+ };
90
+ }, [open]);
91
+ return settled;
92
+ }
93
+ var NO_CREDITS = [];
94
+ /**
95
+ * The map credits for the bottom-end slot: a compact "Map credits" button
96
+ * (a 44 px target around a small info glyph) that expands into a labelled
97
+ * region of credit links built with `buildAttribution`.
98
+ *
99
+ * @remarks The credits are shown by themselves once, when the map has
100
+ * started, because the OpenStreetMap attribution guidelines allow them to
101
+ * be collapsed only after they have been seen. That first showing moves no
102
+ * focus and is a plain region, not a dialog or live region, so nothing is
103
+ * announced. It collapses on the first map interaction (a zoom the person
104
+ * makes, the map moving, a press outside it) or after
105
+ * {@link ATTRIBUTION_INTRO_MS}, whichever comes first, fading out unless
106
+ * reduced motion is on. Focus moving into it during that time keeps it
107
+ * open as if the person had opened it.
108
+ *
109
+ * After that it behaves as a popover the person opens. It opens above the
110
+ * bottom row, clear of the readout beside the button; where it starts a gap
111
+ * after the readout's end edge, so the two share no width, it sits next to
112
+ * the button instead of rising over the readout's height, and it is
113
+ * measured again when the readout resizes or slides sideways. If the
114
+ * credits would scroll there, it moves beside the end stack before it is
115
+ * painted, where
116
+ * `MapChrome` measures more room; it scrolls only if that is not enough
117
+ * either. Opening moves focus to the first link.
118
+ * The popover closes on Escape, on a second press of the button, on a
119
+ * pointer down outside it, and when the map moves; if focus was inside it,
120
+ * focus goes back to the button with an explicit `focus()` (Safari does not
121
+ * focus buttons on click). The credits are always reachable through the
122
+ * button; nothing here hides or removes them. Reads the map with
123
+ * `useMap()`, so it must sit inside the map context.
124
+ */
125
+ function Attribution({ basemap, layerCredits = NO_CREDITS }) {
126
+ const { adapter, view, onUserZoom } = useMap();
127
+ const { reducedMotion } = usePreferences();
128
+ const [open, setOpen] = useState(false);
129
+ const [intro, setIntro] = useState(false);
130
+ const [introStarted, setIntroStarted] = useState(false);
131
+ const [fading, setFading] = useState(false);
132
+ const [openRequest, setOpenRequest] = useState(0);
133
+ const [placement, setPlacement] = useState("above");
134
+ const { t } = useMessages();
135
+ const regionId = useId();
136
+ const rootRef = useRef(null);
137
+ const regionRef = useRef(null);
138
+ const clearOfReadout = useClearOfReadout(regionRef, open, placement);
139
+ const settled = useSettled(open && !reducedMotion);
140
+ const openedOnView = useRef(view);
141
+ const introShown = useRef(false);
142
+ const basemapEntries = buildAttribution(basemap);
143
+ const entries = [...basemapEntries, ...layerCredits.filter((credit) => !basemapEntries.some((entry) => entry.text === credit.text)).map((credit) => ({
144
+ text: credit.text,
145
+ href: credit.url
146
+ }))];
147
+ const close = useCallback(() => {
148
+ const root = rootRef.current;
149
+ const active = root?.ownerDocument.activeElement ?? null;
150
+ const focusWasInside = active !== null && root?.contains(active) === true;
151
+ setOpen(false);
152
+ setIntro(false);
153
+ setFading(false);
154
+ if (focusWasInside) root?.querySelector("button")?.focus();
155
+ }, []);
156
+ /** Closes, fading out first if the credits are showing by themselves. */
157
+ const dismiss = useCallback(() => {
158
+ if (intro && !reducedMotion) {
159
+ setIntro(false);
160
+ setFading(true);
161
+ return;
162
+ }
163
+ close();
164
+ }, [
165
+ close,
166
+ intro,
167
+ reducedMotion
168
+ ]);
169
+ const toggle = () => {
170
+ if (open && !fading) {
171
+ close();
172
+ return;
173
+ }
174
+ openedOnView.current = view;
175
+ setPlacement("above");
176
+ setIntro(false);
177
+ setFading(false);
178
+ setOpen(true);
179
+ setOpenRequest((count) => count + 1);
180
+ };
181
+ useEffect(() => {
182
+ if (adapter === null || introShown.current) return;
183
+ introShown.current = true;
184
+ openedOnView.current = view;
185
+ setPlacement("above");
186
+ setOpen(true);
187
+ setIntro(true);
188
+ setIntroStarted(true);
189
+ }, [adapter, view]);
190
+ useEffect(() => {
191
+ if (!intro) return;
192
+ const timer = setTimeout(dismiss, ATTRIBUTION_INTRO_MS);
193
+ const unsubscribe = onUserZoom(dismiss);
194
+ return () => {
195
+ clearTimeout(timer);
196
+ unsubscribe();
197
+ };
198
+ }, [
199
+ intro,
200
+ dismiss,
201
+ onUserZoom
202
+ ]);
203
+ useEffect(() => {
204
+ if (!fading) return;
205
+ const timer = setTimeout(close, 200);
206
+ return () => {
207
+ clearTimeout(timer);
208
+ };
209
+ }, [fading, close]);
210
+ useLayoutEffect(() => {
211
+ const region = regionRef.current;
212
+ if (open && placement === "above" && region !== null && region.scrollHeight > region.clientHeight) setPlacement("beside");
213
+ }, [open, placement]);
214
+ useLayoutEffect(() => {
215
+ const region = regionRef.current;
216
+ if (!open || placement !== "above" || region === null || typeof ResizeObserver === "undefined") return;
217
+ const observer = new ResizeObserver(() => {
218
+ if (region.scrollHeight > region.clientHeight) setPlacement("beside");
219
+ });
220
+ observer.observe(region);
221
+ return () => {
222
+ observer.disconnect();
223
+ };
224
+ }, [open, placement]);
225
+ useEffect(() => {
226
+ if (openRequest === 0) return;
227
+ const region = regionRef.current;
228
+ (region?.querySelector("a[href]") ?? region)?.focus();
229
+ }, [openRequest]);
230
+ useEffect(() => {
231
+ const root = rootRef.current;
232
+ if (!open || fading || !root) return;
233
+ const doc = root.ownerDocument;
234
+ const onPointerDown = (event) => {
235
+ if (!(event.target instanceof Node && root.contains(event.target))) dismiss();
236
+ };
237
+ doc.addEventListener("pointerdown", onPointerDown);
238
+ return () => {
239
+ doc.removeEventListener("pointerdown", onPointerDown);
240
+ };
241
+ }, [
242
+ open,
243
+ fading,
244
+ dismiss
245
+ ]);
246
+ useEffect(() => {
247
+ if (open && !fading && !sameView(view, openedOnView.current)) dismiss();
248
+ }, [
249
+ open,
250
+ fading,
251
+ view,
252
+ dismiss
253
+ ]);
254
+ const onKeyDown = (event) => {
255
+ if (open && event.key === "Escape") {
256
+ event.preventDefault();
257
+ close();
258
+ }
259
+ };
260
+ const onFocus = () => {
261
+ if (intro) setIntro(false);
262
+ };
263
+ return /* @__PURE__ */ jsxs("div", {
264
+ ref: rootRef,
265
+ "data-chrome": "attribution",
266
+ "data-intro-started": introStarted ? "true" : void 0,
267
+ className: root,
268
+ onKeyDown,
269
+ onFocus,
270
+ children: [/* @__PURE__ */ jsx(IconButton, {
271
+ label: t("chrome.attribution.label", {}),
272
+ icon: Info,
273
+ size: "compact",
274
+ className: onMapIcon,
275
+ expanded: open && !fading,
276
+ controls: regionId,
277
+ onClick: toggle
278
+ }), /* @__PURE__ */ jsx("section", {
279
+ ref: regionRef,
280
+ id: regionId,
281
+ "aria-label": t("chrome.attribution.label", {}),
282
+ tabIndex: -1,
283
+ hidden: !open,
284
+ "data-chrome": "attribution-popover",
285
+ "data-placement": placement,
286
+ "data-readout-clear": clearOfReadout ? "true" : void 0,
287
+ "data-settled": settled ? "true" : void 0,
288
+ "data-closing": fading ? "true" : void 0,
289
+ className: popover,
290
+ children: /* @__PURE__ */ jsx("ul", {
291
+ className: list,
292
+ children: entries.map((entry) => /* @__PURE__ */ jsx("li", { children: entry.href ? /* @__PURE__ */ jsx("a", {
293
+ href: entry.href,
294
+ rel: "noopener",
295
+ className: link,
296
+ children: entry.text
297
+ }) : entry.text }, entry.text))
298
+ })
299
+ })]
300
+ });
301
+ }
302
+ export { ATTRIBUTION_FADE_MS, ATTRIBUTION_INTRO_MS, Attribution };
303
+
304
+ //# sourceMappingURL=Attribution.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Attribution.js","names":["styles.root","styles.onMapIcon","styles.popover","styles.list","styles.link"],"sources":["../../../src/chrome/Attribution/Attribution.tsx"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-only\n// Copyright MapCairn contributors\nimport {\n type BasemapDefinition,\n buildAttribution,\n clearsInlineEnd,\n type LayerAttribution,\n type ViewState,\n} from \"@mapcairn/core\";\nimport { Info } from \"lucide-react\";\nimport {\n type KeyboardEvent,\n type RefObject,\n useCallback,\n useEffect,\n useId,\n useLayoutEffect,\n useRef,\n useState,\n} from \"react\";\nimport { useMap } from \"../../host\";\nimport { useMessages, usePreferences } from \"../../services\";\nimport { IconButton } from \"../../ui\";\nimport { CHROME_GAP_PX } from \"../chromeSpacing\";\nimport * as styles from \"./Attribution.css\";\n\n/**\n * How long the credits stay on screen by themselves once the map has\n * started, if the person does nothing with the map first.\n *\n * @internal\n */\nexport const ATTRIBUTION_INTRO_MS = 5000;\n\n/**\n * How long the credits take to fade out after their first showing.\n *\n * @internal\n */\nexport const ATTRIBUTION_FADE_MS = 200;\n\n/**\n * Where the credits popover sits: straight above the bottom row, or, when the\n * list would have to scroll there, beside the end stack where there is more\n * height (a short landscape phone).\n */\ntype Placement = \"above\" | \"beside\";\n\n/** Smaller differences than this, in degrees or zoom levels, are not a move. */\nconst VIEW_EPSILON = 1e-9;\n\n/** Whether two views show the same place at the same zoom and bearing. */\nfunction sameView(a: ViewState, b: ViewState): boolean {\n return (\n Math.abs(a.center.lat - b.center.lat) < VIEW_EPSILON &&\n Math.abs(a.center.lng - b.center.lng) < VIEW_EPSILON &&\n Math.abs(a.zoom - b.zoom) < VIEW_EPSILON &&\n Math.abs(a.bearing - b.bearing) < VIEW_EPSILON\n );\n}\n\n/**\n * Whether the open credits popover starts a gap after the end edge of the\n * readout in bottom-start, so the two share no width and the popover need not\n * rise over the readout's height. True when the chrome has no readout. It is\n * measured before the popover is painted and again whenever the popover, the\n * readout or the chrome changes size (the cursor coordinates widen the readout\n * as the pointer enters the map) and whenever the readout finishes sliding\n * sideways (the side panel opening or closing moves it with a transform and\n * no change of size). Nothing is observed while the popover is closed.\n */\nfunction useClearOfReadout(\n regionRef: RefObject<HTMLElement | null>,\n open: boolean,\n placement: Placement,\n): boolean {\n const [clear, setClear] = useState(false);\n // biome-ignore lint/correctness/useExhaustiveDependencies: the placement moves the popover sideways, which is what is measured.\n useLayoutEffect(() => {\n const region = regionRef.current;\n if (!open || region === null) {\n return;\n }\n const chrome = region.closest(\"[data-chrome-root]\");\n const readout =\n chrome?.querySelector<HTMLElement>('[data-chrome=\"bottom-start\"]') ??\n null;\n const measure = () => {\n setClear(\n readout === null ||\n clearsInlineEnd(\n readout.getBoundingClientRect(),\n region.getBoundingClientRect(),\n CHROME_GAP_PX,\n getComputedStyle(region).direction === \"rtl\" ? \"rtl\" : \"ltr\",\n ),\n );\n };\n measure();\n const onTransitionEnd = (event: TransitionEvent) => {\n if (event.target === readout && event.propertyName === \"transform\") {\n measure();\n }\n };\n readout?.addEventListener(\"transitionend\", onTransitionEnd);\n const observer =\n typeof ResizeObserver === \"undefined\"\n ? null\n : new ResizeObserver(measure);\n for (const element of [region, chrome, readout]) {\n if (element) {\n observer?.observe(element);\n }\n }\n return () => {\n readout?.removeEventListener(\"transitionend\", onTransitionEnd);\n observer?.disconnect();\n };\n }, [open, placement, regionRef]);\n return clear;\n}\n\n/**\n * Whether the open popover has been on screen for a frame. Its offset slides\n * (see `Attribution.css`) only from then on, so the position it takes when it\n * opens, which the first measurement may still change before it is painted, is\n * never animated.\n */\nfunction useSettled(open: boolean): boolean {\n const [settled, setSettled] = useState(false);\n useEffect(() => {\n if (!open) {\n setSettled(false);\n return;\n }\n const frame = requestAnimationFrame(() => {\n setSettled(true);\n });\n return () => {\n cancelAnimationFrame(frame);\n };\n }, [open]);\n return settled;\n}\n\nconst NO_CREDITS: readonly LayerAttribution[] = [];\n\n/** Props for {@link Attribution}. */\nexport interface AttributionProps {\n /** The active basemap. Its credits, plus the engine's, are listed. */\n readonly basemap: BasemapDefinition;\n /** Credits of the data layers that are on, listed after the map's own. */\n readonly layerCredits?: readonly LayerAttribution[];\n}\n\n/**\n * The map credits for the bottom-end slot: a compact \"Map credits\" button\n * (a 44 px target around a small info glyph) that expands into a labelled\n * region of credit links built with `buildAttribution`.\n *\n * @remarks The credits are shown by themselves once, when the map has\n * started, because the OpenStreetMap attribution guidelines allow them to\n * be collapsed only after they have been seen. That first showing moves no\n * focus and is a plain region, not a dialog or live region, so nothing is\n * announced. It collapses on the first map interaction (a zoom the person\n * makes, the map moving, a press outside it) or after\n * {@link ATTRIBUTION_INTRO_MS}, whichever comes first, fading out unless\n * reduced motion is on. Focus moving into it during that time keeps it\n * open as if the person had opened it.\n *\n * After that it behaves as a popover the person opens. It opens above the\n * bottom row, clear of the readout beside the button; where it starts a gap\n * after the readout's end edge, so the two share no width, it sits next to\n * the button instead of rising over the readout's height, and it is\n * measured again when the readout resizes or slides sideways. If the\n * credits would scroll there, it moves beside the end stack before it is\n * painted, where\n * `MapChrome` measures more room; it scrolls only if that is not enough\n * either. Opening moves focus to the first link.\n * The popover closes on Escape, on a second press of the button, on a\n * pointer down outside it, and when the map moves; if focus was inside it,\n * focus goes back to the button with an explicit `focus()` (Safari does not\n * focus buttons on click). The credits are always reachable through the\n * button; nothing here hides or removes them. Reads the map with\n * `useMap()`, so it must sit inside the map context.\n */\nexport function Attribution({\n basemap,\n layerCredits = NO_CREDITS,\n}: AttributionProps) {\n const { adapter, view, onUserZoom } = useMap();\n const { reducedMotion } = usePreferences();\n const [open, setOpen] = useState(false);\n // True while the credits show by themselves after the map started.\n const [intro, setIntro] = useState(false);\n // Set when the first showing has started, so a test or a caller can tell a\n // collapsed start (no map yet) from an intro that has finished.\n const [introStarted, setIntroStarted] = useState(false);\n const [fading, setFading] = useState(false);\n // Counts the openings the person asked for, each of which moves focus in.\n const [openRequest, setOpenRequest] = useState(0);\n const [placement, setPlacement] = useState<Placement>(\"above\");\n const { t } = useMessages();\n const regionId = useId();\n const rootRef = useRef<HTMLDivElement>(null);\n const regionRef = useRef<HTMLElement>(null);\n const clearOfReadout = useClearOfReadout(regionRef, open, placement);\n // With reduced motion the offset is never given a transition: even a\n // near-zero one shows the old position for a frame or two before the new one.\n const settled = useSettled(open && !reducedMotion);\n const openedOnView = useRef(view);\n const introShown = useRef(false);\n // A credit the basemap already gives, such as OpenStreetMap's, is listed\n // once.\n const basemapEntries = buildAttribution(basemap);\n const entries = [\n ...basemapEntries,\n ...layerCredits\n .filter(\n (credit) => !basemapEntries.some((entry) => entry.text === credit.text),\n )\n .map((credit) => ({ text: credit.text, href: credit.url })),\n ];\n\n const close = useCallback(() => {\n const root = rootRef.current;\n const active = root?.ownerDocument.activeElement ?? null;\n const focusWasInside = active !== null && root?.contains(active) === true;\n setOpen(false);\n setIntro(false);\n setFading(false);\n if (focusWasInside) {\n root?.querySelector<HTMLButtonElement>(\"button\")?.focus();\n }\n }, []);\n\n /** Closes, fading out first if the credits are showing by themselves. */\n const dismiss = useCallback(() => {\n if (intro && !reducedMotion) {\n setIntro(false);\n setFading(true);\n return;\n }\n close();\n }, [close, intro, reducedMotion]);\n\n const toggle = () => {\n if (open && !fading) {\n close();\n return;\n }\n openedOnView.current = view;\n setPlacement(\"above\");\n setIntro(false);\n setFading(false);\n setOpen(true);\n setOpenRequest((count) => count + 1);\n };\n\n // Shown once, when the map has started: before that there is no map to credit.\n useEffect(() => {\n if (adapter === null || introShown.current) {\n return;\n }\n introShown.current = true;\n openedOnView.current = view;\n setPlacement(\"above\");\n setOpen(true);\n setIntro(true);\n setIntroStarted(true);\n }, [adapter, view]);\n\n useEffect(() => {\n if (!intro) {\n return;\n }\n const timer = setTimeout(dismiss, ATTRIBUTION_INTRO_MS);\n const unsubscribe = onUserZoom(dismiss);\n return () => {\n clearTimeout(timer);\n unsubscribe();\n };\n }, [intro, dismiss, onUserZoom]);\n\n useEffect(() => {\n if (!fading) {\n return;\n }\n const timer = setTimeout(close, ATTRIBUTION_FADE_MS);\n return () => {\n clearTimeout(timer);\n };\n }, [fading, close]);\n\n // Before the first paint of an open popover: if the credits overflow the\n // room above the button, use the room beside the end stack instead.\n useLayoutEffect(() => {\n const region = regionRef.current;\n if (\n open &&\n placement === \"above\" &&\n region !== null &&\n region.scrollHeight > region.clientHeight\n ) {\n setPlacement(\"beside\");\n }\n }, [open, placement]);\n\n // The room above can shrink after that decision: `MapChrome` writes the\n // popover's rise over a toolbar once it has seen the popover open, and the\n // popover's box shrinks with it. Decide again when its box changes.\n useLayoutEffect(() => {\n const region = regionRef.current;\n if (\n !open ||\n placement !== \"above\" ||\n region === null ||\n typeof ResizeObserver === \"undefined\"\n ) {\n return;\n }\n const observer = new ResizeObserver(() => {\n if (region.scrollHeight > region.clientHeight) {\n setPlacement(\"beside\");\n }\n });\n observer.observe(region);\n return () => {\n observer.disconnect();\n };\n }, [open, placement]);\n\n // Focus moves into the popover when the person opens it.\n useEffect(() => {\n if (openRequest === 0) {\n return;\n }\n const region = regionRef.current;\n const first = region?.querySelector<HTMLElement>(\"a[href]\");\n (first ?? region)?.focus();\n }, [openRequest]);\n\n // A pointer down anywhere outside closes it.\n useEffect(() => {\n const root = rootRef.current;\n if (!open || fading || !root) {\n return;\n }\n const doc = root.ownerDocument;\n const onPointerDown = (event: PointerEvent) => {\n if (!(event.target instanceof Node && root.contains(event.target))) {\n dismiss();\n }\n };\n doc.addEventListener(\"pointerdown\", onPointerDown);\n return () => {\n doc.removeEventListener(\"pointerdown\", onPointerDown);\n };\n }, [open, fading, dismiss]);\n\n // Moving the map closes it, so it never hides what the user is looking at.\n // Compared by value: a resize reports the same view as a new object.\n useEffect(() => {\n if (open && !fading && !sameView(view, openedOnView.current)) {\n dismiss();\n }\n }, [open, fading, view, dismiss]);\n\n const onKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n if (open && event.key === \"Escape\") {\n event.preventDefault();\n close();\n }\n };\n\n // Focus arriving during the first showing means the person is reading it.\n const onFocus = () => {\n if (intro) {\n setIntro(false);\n }\n };\n\n return (\n // biome-ignore lint/a11y/noStaticElementInteractions: Escape is handled for the button and the popover together.\n // biome-ignore lint/a11y/noNoninteractiveElementInteractions: Escape is handled for the button and the popover together.\n <div\n ref={rootRef}\n data-chrome=\"attribution\"\n data-intro-started={introStarted ? \"true\" : undefined}\n className={styles.root}\n onKeyDown={onKeyDown}\n onFocus={onFocus}\n >\n <IconButton\n label={t(\"chrome.attribution.label\", {})}\n icon={Info}\n size=\"compact\"\n className={styles.onMapIcon}\n expanded={open && !fading}\n controls={regionId}\n onClick={toggle}\n />\n <section\n ref={regionRef}\n id={regionId}\n aria-label={t(\"chrome.attribution.label\", {})}\n tabIndex={-1}\n hidden={!open}\n data-chrome=\"attribution-popover\"\n data-placement={placement}\n data-readout-clear={clearOfReadout ? \"true\" : undefined}\n data-settled={settled ? \"true\" : undefined}\n data-closing={fading ? \"true\" : undefined}\n className={styles.popover}\n >\n <ul className={styles.list}>\n {entries.map((entry) => (\n <li key={entry.text}>\n {entry.href ? (\n <a href={entry.href} rel=\"noopener\" className={styles.link}>\n {entry.text}\n </a>\n ) : (\n entry.text\n )}\n </li>\n ))}\n </ul>\n </section>\n </div>\n );\n}\n"],"mappings":"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"}
@@ -0,0 +1,10 @@
1
+ /* empty css */
2
+ // src/chrome/Attribution/Attribution.css.ts
3
+ var root = "_1ao5vz20";
4
+ var onMapIcon = "_1ao5vz21";
5
+ var popover = "_1ao5vz22";
6
+ var list = "_1ao5vz23";
7
+ var link = "_1ao5vz24";
8
+ export { link, list, onMapIcon, popover, root };
9
+
10
+ //# sourceMappingURL=Attribution.styles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Attribution.styles.js","names":[],"sources":[],"mappings":""}
@@ -0,0 +1,29 @@
1
+ import { IconButton } from "../../ui/IconButton/IconButton.js";
2
+ import { onMapIcon, root } from "./Attribution.styles.js";
3
+ import { Info } from "lucide-react";
4
+ import { jsx } from "react/jsx-runtime";
5
+ // src/chrome/Attribution/AttributionSkeleton.tsx
6
+ /**
7
+ * The credits button as a decorative stand-in for the server-rendered
8
+ * `ChromeSkeleton`: the same anchor and icon classes as {@link Attribution},
9
+ * so it sits in the same box, with the popover left out.
10
+ *
11
+ * @remarks Only ever rendered inside an `aria-hidden`, `inert` container. It
12
+ * uses no hooks, so it needs no map or provider: its name arrives as `label`.
13
+ */
14
+ function AttributionSkeleton({ label }) {
15
+ return /* @__PURE__ */ jsx("div", {
16
+ className: root,
17
+ "data-skeleton": "credits",
18
+ children: /* @__PURE__ */ jsx(IconButton, {
19
+ label,
20
+ icon: Info,
21
+ size: "compact",
22
+ className: onMapIcon,
23
+ tabIndex: -1
24
+ })
25
+ });
26
+ }
27
+ export { AttributionSkeleton };
28
+
29
+ //# sourceMappingURL=AttributionSkeleton.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AttributionSkeleton.js","names":["styles.root","styles.onMapIcon"],"sources":["../../../src/chrome/Attribution/AttributionSkeleton.tsx"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-only\n// Copyright MapCairn contributors\nimport { Info } from \"lucide-react\";\nimport { IconButton } from \"../../ui\";\nimport * as styles from \"./Attribution.css\";\n\n/** Props for {@link AttributionSkeleton}. */\nexport interface AttributionSkeletonProps {\n /** The credits button's name, in the host's default language. */\n readonly label: string;\n}\n\n/**\n * The credits button as a decorative stand-in for the server-rendered\n * `ChromeSkeleton`: the same anchor and icon classes as {@link Attribution},\n * so it sits in the same box, with the popover left out.\n *\n * @remarks Only ever rendered inside an `aria-hidden`, `inert` container. It\n * uses no hooks, so it needs no map or provider: its name arrives as `label`.\n */\nexport function AttributionSkeleton({ label }: AttributionSkeletonProps) {\n return (\n <div className={styles.root} data-skeleton=\"credits\">\n <IconButton\n label={label}\n icon={Info}\n size=\"compact\"\n className={styles.onMapIcon}\n tabIndex={-1}\n />\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;AAoBA,SAAgB,oBAAoB,EAAE,SAAmC;CACvE,OACE,oBAAC,OAAD;EAAK,WAAWA;EAAa,iBAAc;EACzC,UAAA,oBAAC,YAAD;GACS;GACP,MAAM;GACN,MAAK;GACL,WAAWC;GACX,UAAU;EACX,CAAA;CACE,CAAA;AAET"}