@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.
- package/LICENSE +661 -0
- package/README.md +167 -2
- package/dist/chrome/Attribution/Attribution.js +304 -0
- package/dist/chrome/Attribution/Attribution.js.map +1 -0
- package/dist/chrome/Attribution/Attribution.styles.js +10 -0
- package/dist/chrome/Attribution/Attribution.styles.js.map +1 -0
- package/dist/chrome/Attribution/AttributionSkeleton.js +29 -0
- package/dist/chrome/Attribution/AttributionSkeleton.js.map +1 -0
- package/dist/chrome/ChromeSkeleton/ChromeSkeleton.js +83 -0
- package/dist/chrome/ChromeSkeleton/ChromeSkeleton.js.map +1 -0
- package/dist/chrome/EndStack/EndStack.js +157 -0
- package/dist/chrome/EndStack/EndStack.js.map +1 -0
- package/dist/chrome/EndStack/EndStack.styles.js +12 -0
- package/dist/chrome/EndStack/EndStack.styles.js.map +1 -0
- package/dist/chrome/EndStack/EndStackSkeleton.js +78 -0
- package/dist/chrome/EndStack/EndStackSkeleton.js.map +1 -0
- package/dist/chrome/EndStack/endStackHeight.js +22 -0
- package/dist/chrome/EndStack/endStackHeight.js.map +1 -0
- package/dist/chrome/MapChrome/MapChrome.js +488 -0
- package/dist/chrome/MapChrome/MapChrome.js.map +1 -0
- package/dist/chrome/MapChrome/MapChrome.styles.js +15 -0
- package/dist/chrome/MapChrome/MapChrome.styles.js.map +1 -0
- package/dist/chrome/MapChrome/chromeSurface.js +18 -0
- package/dist/chrome/MapChrome/chromeSurface.js.map +1 -0
- package/dist/chrome/MapChrome/chromeVars.js +71 -0
- package/dist/chrome/MapChrome/chromeVars.js.map +1 -0
- package/dist/chrome/MapChrome/mapKeyPlacement.js +41 -0
- package/dist/chrome/MapChrome/mapKeyPlacement.js.map +1 -0
- package/dist/chrome/MapChrome/sharesWidth.js +13 -0
- package/dist/chrome/MapChrome/sharesWidth.js.map +1 -0
- package/dist/chrome/MapReadout/MapReadout.js +199 -0
- package/dist/chrome/MapReadout/MapReadout.js.map +1 -0
- package/dist/chrome/MapReadout/MapReadout.styles.js +14 -0
- package/dist/chrome/MapReadout/MapReadout.styles.js.map +1 -0
- package/dist/chrome/Sheet/Sheet.js +412 -0
- package/dist/chrome/Sheet/Sheet.js.map +1 -0
- package/dist/chrome/Sheet/Sheet.styles.js +14 -0
- package/dist/chrome/Sheet/Sheet.styles.js.map +1 -0
- package/dist/chrome/focusRegistry.js +76 -0
- package/dist/chrome/focusRegistry.js.map +1 -0
- package/dist/chrome/layoutContext.js +30 -0
- package/dist/chrome/layoutContext.js.map +1 -0
- package/dist/chrome/useScrollEdges.js +53 -0
- package/dist/chrome/useScrollEdges.js.map +1 -0
- package/dist/host/MapContext.js +16 -0
- package/dist/host/MapContext.js.map +1 -0
- package/dist/host/MapView.js +189 -0
- package/dist/host/MapView.js.map +1 -0
- package/dist/host/MapView.styles.js +16 -0
- package/dist/host/MapView.styles.js.map +1 -0
- package/dist/host/overlays/AccuracyCircle.js +36 -0
- package/dist/host/overlays/AccuracyCircle.js.map +1 -0
- package/dist/host/overlays/CentreCrosshair.js +40 -0
- package/dist/host/overlays/CentreCrosshair.js.map +1 -0
- package/dist/host/overlays/DrawOverlay.js +221 -0
- package/dist/host/overlays/DrawOverlay.js.map +1 -0
- package/dist/host/overlays/MapOverlayLayer.js +27 -0
- package/dist/host/overlays/MapOverlayLayer.js.map +1 -0
- package/dist/host/overlays/MeasureOverlay.js +87 -0
- package/dist/host/overlays/MeasureOverlay.js.map +1 -0
- package/dist/host/overlays/PinMarker.js +40 -0
- package/dist/host/overlays/PinMarker.js.map +1 -0
- package/dist/host/overlays/geometry.js +41 -0
- package/dist/host/overlays/geometry.js.map +1 -0
- package/dist/host/overlays/overlays.styles.js +27 -0
- package/dist/host/overlays/overlays.styles.js.map +1 -0
- package/dist/host/pointerTargets.js +22 -0
- package/dist/host/pointerTargets.js.map +1 -0
- package/dist/host/useLongPress.js +102 -0
- package/dist/host/useLongPress.js.map +1 -0
- package/dist/host/useMapEngine.js +352 -0
- package/dist/host/useMapEngine.js.map +1 -0
- package/dist/host/usePointerPosition.js +60 -0
- package/dist/host/usePointerPosition.js.map +1 -0
- package/dist/index.d.ts +3845 -0
- package/dist/index.js +89 -0
- package/dist/layers/CatalogueStatus.js +138 -0
- package/dist/layers/CatalogueStatus.js.map +1 -0
- package/dist/layers/DateTimeControl.js +101 -0
- package/dist/layers/DateTimeControl.js.map +1 -0
- package/dist/layers/FeatureCard.js +147 -0
- package/dist/layers/FeatureCard.js.map +1 -0
- package/dist/layers/FeatureChoices.js +101 -0
- package/dist/layers/FeatureChoices.js.map +1 -0
- package/dist/layers/FeatureGlyph.js +56 -0
- package/dist/layers/FeatureGlyph.js.map +1 -0
- package/dist/layers/IdentifyStatus.js +36 -0
- package/dist/layers/IdentifyStatus.js.map +1 -0
- package/dist/layers/LayerItem.js +321 -0
- package/dist/layers/LayerItem.js.map +1 -0
- package/dist/layers/LayerKey.js +36 -0
- package/dist/layers/LayerKey.js.map +1 -0
- package/dist/layers/Layers.styles.js +50 -0
- package/dist/layers/Layers.styles.js.map +1 -0
- package/dist/layers/LayersSection.js +267 -0
- package/dist/layers/LayersSection.js.map +1 -0
- package/dist/layers/MapDataLayers.js +261 -0
- package/dist/layers/MapDataLayers.js.map +1 -0
- package/dist/layers/MapKey.js +131 -0
- package/dist/layers/MapKey.js.map +1 -0
- package/dist/layers/MapKey.styles.js +16 -0
- package/dist/layers/MapKey.styles.js.map +1 -0
- package/dist/layers/MarkerGlyph.js +84 -0
- package/dist/layers/MarkerGlyph.js.map +1 -0
- package/dist/layers/SelectionProvider.js +27 -0
- package/dist/layers/SelectionProvider.js.map +1 -0
- package/dist/layers/ShapeGlyph.js +122 -0
- package/dist/layers/ShapeGlyph.js.map +1 -0
- package/dist/layers/TurnOffActions.js +147 -0
- package/dist/layers/TurnOffActions.js.map +1 -0
- package/dist/layers/answersTap.js +16 -0
- package/dist/layers/answersTap.js.map +1 -0
- package/dist/layers/catalogueNotice.js +65 -0
- package/dist/layers/catalogueNotice.js.map +1 -0
- package/dist/layers/catalogueReconcile.js +55 -0
- package/dist/layers/catalogueReconcile.js.map +1 -0
- package/dist/layers/catalogueView.js +32 -0
- package/dist/layers/catalogueView.js.map +1 -0
- package/dist/layers/featureTitle.js +14 -0
- package/dist/layers/featureTitle.js.map +1 -0
- package/dist/layers/identifyFeedback.js +30 -0
- package/dist/layers/identifyFeedback.js.map +1 -0
- package/dist/layers/identifyRun.js +148 -0
- package/dist/layers/identifyRun.js.map +1 -0
- package/dist/layers/layerStatus.js +13 -0
- package/dist/layers/layerStatus.js.map +1 -0
- package/dist/layers/loadOutcome.js +107 -0
- package/dist/layers/loadOutcome.js.map +1 -0
- package/dist/layers/loadReport.js +33 -0
- package/dist/layers/loadReport.js.map +1 -0
- package/dist/layers/loadRequests.js +73 -0
- package/dist/layers/loadRequests.js.map +1 -0
- package/dist/layers/mapFeatures.js +307 -0
- package/dist/layers/mapFeatures.js.map +1 -0
- package/dist/layers/mapKeyBlocks.js +24 -0
- package/dist/layers/mapKeyBlocks.js.map +1 -0
- package/dist/layers/reveal.js +119 -0
- package/dist/layers/reveal.js.map +1 -0
- package/dist/layers/selectionMessages.js +53 -0
- package/dist/layers/selectionMessages.js.map +1 -0
- package/dist/layers/selectionResolve.js +111 -0
- package/dist/layers/selectionResolve.js.map +1 -0
- package/dist/layers/useDataLayers.js +940 -0
- package/dist/layers/useDataLayers.js.map +1 -0
- package/dist/layers/useFeatureSelection.js +179 -0
- package/dist/layers/useFeatureSelection.js.map +1 -0
- package/dist/layers/useScrolls.js +37 -0
- package/dist/layers/useScrolls.js.map +1 -0
- package/dist/panels/BasemapPicker/BasemapPicker.js +169 -0
- package/dist/panels/BasemapPicker/BasemapPicker.js.map +1 -0
- package/dist/panels/BasemapPicker/BasemapPicker.styles.js +42 -0
- package/dist/panels/BasemapPicker/BasemapPicker.styles.js.map +1 -0
- package/dist/panels/ExportSection/ExportSection.js +91 -0
- package/dist/panels/ExportSection/ExportSection.js.map +1 -0
- package/dist/panels/HelpSection/HelpSection.js +163 -0
- package/dist/panels/HelpSection/HelpSection.js.map +1 -0
- package/dist/panels/HelpSection/HelpSection.styles.js +9 -0
- package/dist/panels/HelpSection/HelpSection.styles.js.map +1 -0
- package/dist/panels/PinSection/PinSection.js +39 -0
- package/dist/panels/PinSection/PinSection.js.map +1 -0
- package/dist/panels/Section/Section.js +43 -0
- package/dist/panels/Section/Section.js.map +1 -0
- package/dist/panels/Section/Section.styles.js +13 -0
- package/dist/panels/Section/Section.styles.js.map +1 -0
- package/dist/panels/SettingsSection/LanguageField.js +126 -0
- package/dist/panels/SettingsSection/LanguageField.js.map +1 -0
- package/dist/panels/SettingsSection/SettingsSection.js +175 -0
- package/dist/panels/SettingsSection/SettingsSection.js.map +1 -0
- package/dist/panels/SettingsSection/SettingsSection.styles.js +9 -0
- package/dist/panels/SettingsSection/SettingsSection.styles.js.map +1 -0
- package/dist/panels/ShapesSection/ShapesSection.js +229 -0
- package/dist/panels/ShapesSection/ShapesSection.js.map +1 -0
- package/dist/panels/ShapesSection/ShapesSection.styles.js +7 -0
- package/dist/panels/ShapesSection/ShapesSection.styles.js.map +1 -0
- package/dist/panels/SheetContent/SheetContent.js +92 -0
- package/dist/panels/SheetContent/SheetContent.js.map +1 -0
- package/dist/panels/SheetContent/SheetContent.styles.js +6 -0
- package/dist/panels/SheetContent/SheetContent.styles.js.map +1 -0
- package/dist/services/ServicesProvider.js +42 -0
- package/dist/services/ServicesProvider.js.map +1 -0
- package/dist/services/activeMessages.js +140 -0
- package/dist/services/activeMessages.js.map +1 -0
- package/dist/services/basemapAvailability.js +78 -0
- package/dist/services/basemapAvailability.js.map +1 -0
- package/dist/services/englishMessages.js +10 -0
- package/dist/services/englishMessages.js.map +1 -0
- package/dist/services/hooks.js +214 -0
- package/dist/services/hooks.js.map +1 -0
- package/dist/styles.css +2866 -0
- package/dist/styles.css.d.ts +1 -0
- package/dist/tools/Directions/Directions.styles.js +25 -0
- package/dist/tools/Directions/Directions.styles.js.map +1 -0
- package/dist/tools/Directions/DirectionsOverlay.js +46 -0
- package/dist/tools/Directions/DirectionsOverlay.js.map +1 -0
- package/dist/tools/Directions/DirectionsPanel.js +428 -0
- package/dist/tools/Directions/DirectionsPanel.js.map +1 -0
- package/dist/tools/Directions/MapDirections.js +84 -0
- package/dist/tools/Directions/MapDirections.js.map +1 -0
- package/dist/tools/Directions/useDirections.js +226 -0
- package/dist/tools/Directions/useDirections.js.map +1 -0
- package/dist/tools/Directions/useFreeCentre.js +30 -0
- package/dist/tools/Directions/useFreeCentre.js.map +1 -0
- package/dist/tools/DrawToolbar/DrawMapBindings.js +34 -0
- package/dist/tools/DrawToolbar/DrawMapBindings.js.map +1 -0
- package/dist/tools/DrawToolbar/DrawToolbar.js +296 -0
- package/dist/tools/DrawToolbar/DrawToolbar.js.map +1 -0
- package/dist/tools/DrawToolbar/DrawToolbar.styles.js +21 -0
- package/dist/tools/DrawToolbar/DrawToolbar.styles.js.map +1 -0
- package/dist/tools/DrawToolbar/imageDrawing.js +24 -0
- package/dist/tools/DrawToolbar/imageDrawing.js.map +1 -0
- package/dist/tools/DrawToolbar/useDraw.js +543 -0
- package/dist/tools/DrawToolbar/useDraw.js.map +1 -0
- package/dist/tools/MeasureToolbar/MeasureToolbar.js +116 -0
- package/dist/tools/MeasureToolbar/MeasureToolbar.js.map +1 -0
- package/dist/tools/MeasureToolbar/MeasureToolbar.styles.js +12 -0
- package/dist/tools/MeasureToolbar/MeasureToolbar.styles.js.map +1 -0
- package/dist/tools/MeasureToolbar/useMeasure.js +75 -0
- package/dist/tools/MeasureToolbar/useMeasure.js.map +1 -0
- package/dist/tools/PinCard/PinCard.js +174 -0
- package/dist/tools/PinCard/PinCard.js.map +1 -0
- package/dist/tools/PinCard/PinCard.styles.js +16 -0
- package/dist/tools/PinCard/PinCard.styles.js.map +1 -0
- package/dist/tools/PinCard/useReverseAddress.js +77 -0
- package/dist/tools/PinCard/useReverseAddress.js.map +1 -0
- package/dist/tools/SearchPill/SearchPill.js +292 -0
- package/dist/tools/SearchPill/SearchPill.js.map +1 -0
- package/dist/tools/SearchPill/SearchPill.styles.js +16 -0
- package/dist/tools/SearchPill/SearchPill.styles.js.map +1 -0
- package/dist/tools/SearchPill/SearchPillSkeleton.js +41 -0
- package/dist/tools/SearchPill/SearchPillSkeleton.js.map +1 -0
- package/dist/tools/SearchPill/useSearch.js +143 -0
- package/dist/tools/SearchPill/useSearch.js.map +1 -0
- package/dist/tools/SearchPill/useSuggestions.js +105 -0
- package/dist/tools/SearchPill/useSuggestions.js.map +1 -0
- package/dist/tools/Tour/TourCard.js +156 -0
- package/dist/tools/Tour/TourCard.js.map +1 -0
- package/dist/tools/Tour/TourCard.styles.js +10 -0
- package/dist/tools/Tour/TourCard.styles.js.map +1 -0
- package/dist/tools/Tour/useTour.js +110 -0
- package/dist/tools/Tour/useTour.js.map +1 -0
- package/dist/tools/locate/useLocate.js +94 -0
- package/dist/tools/locate/useLocate.js.map +1 -0
- package/dist/ui/Button/Button.js +36 -0
- package/dist/ui/Button/Button.js.map +1 -0
- package/dist/ui/Button/Button.styles.js +17 -0
- package/dist/ui/Button/Button.styles.js.map +1 -0
- package/dist/ui/Chip/Chip.js +37 -0
- package/dist/ui/Chip/Chip.js.map +1 -0
- package/dist/ui/Chip/Chip.styles.js +29 -0
- package/dist/ui/Chip/Chip.styles.js.map +1 -0
- package/dist/ui/ControlGroup/ControlGroup.js +23 -0
- package/dist/ui/ControlGroup/ControlGroup.js.map +1 -0
- package/dist/ui/ControlGroup/ControlGroup.styles.js +6 -0
- package/dist/ui/ControlGroup/ControlGroup.styles.js.map +1 -0
- package/dist/ui/EmptyState/EmptyState.js +37 -0
- package/dist/ui/EmptyState/EmptyState.js.map +1 -0
- package/dist/ui/EmptyState/EmptyState.styles.js +10 -0
- package/dist/ui/EmptyState/EmptyState.styles.js.map +1 -0
- package/dist/ui/Icon/Icon.js +28 -0
- package/dist/ui/Icon/Icon.js.map +1 -0
- package/dist/ui/Icon/Icon.styles.js +8 -0
- package/dist/ui/Icon/Icon.styles.js.map +1 -0
- package/dist/ui/IconButton/IconButton.js +47 -0
- package/dist/ui/IconButton/IconButton.js.map +1 -0
- package/dist/ui/IconButton/IconButton.styles.js +27 -0
- package/dist/ui/IconButton/IconButton.styles.js.map +1 -0
- package/dist/ui/Isolate/Isolate.js +26 -0
- package/dist/ui/Isolate/Isolate.js.map +1 -0
- package/dist/ui/Isolate/fillSlots.js +27 -0
- package/dist/ui/Isolate/fillSlots.js.map +1 -0
- package/dist/ui/ListRow/ListRow.js +59 -0
- package/dist/ui/ListRow/ListRow.js.map +1 -0
- package/dist/ui/ListRow/ListRow.styles.js +30 -0
- package/dist/ui/ListRow/ListRow.styles.js.map +1 -0
- package/dist/ui/LiveRegion/LiveRegion.js +88 -0
- package/dist/ui/LiveRegion/LiveRegion.js.map +1 -0
- package/dist/ui/LiveRegion/announcer.js +114 -0
- package/dist/ui/LiveRegion/announcer.js.map +1 -0
- package/dist/ui/SegmentedControl/SegmentedControl.js +55 -0
- package/dist/ui/SegmentedControl/SegmentedControl.js.map +1 -0
- package/dist/ui/SegmentedControl/SegmentedControl.styles.js +9 -0
- package/dist/ui/SegmentedControl/SegmentedControl.styles.js.map +1 -0
- package/dist/ui/SkipLink/SkipLink.js +35 -0
- package/dist/ui/SkipLink/SkipLink.js.map +1 -0
- package/dist/ui/SkipLink/SkipLink.styles.js +6 -0
- package/dist/ui/SkipLink/SkipLink.styles.js.map +1 -0
- package/dist/ui/Slider/Slider.js +68 -0
- package/dist/ui/Slider/Slider.js.map +1 -0
- package/dist/ui/Slider/Slider.styles.js +13 -0
- package/dist/ui/Slider/Slider.styles.js.map +1 -0
- package/dist/ui/StatusMessage/StatusMessage.js +124 -0
- package/dist/ui/StatusMessage/StatusMessage.js.map +1 -0
- package/dist/ui/StatusMessage/StatusMessage.styles.js +28 -0
- package/dist/ui/StatusMessage/StatusMessage.styles.js.map +1 -0
- package/dist/ui/StatusMessage/StatusMessageFocus.js +30 -0
- package/dist/ui/StatusMessage/StatusMessageFocus.js.map +1 -0
- package/dist/ui/Surface/Surface.js +22 -0
- package/dist/ui/Surface/Surface.js.map +1 -0
- package/dist/ui/Surface/Surface.styles.js +27 -0
- package/dist/ui/Surface/Surface.styles.js.map +1 -0
- package/dist/ui/Switch/Switch.js +58 -0
- package/dist/ui/Switch/Switch.js.map +1 -0
- package/dist/ui/Switch/Switch.styles.js +13 -0
- package/dist/ui/Switch/Switch.styles.js.map +1 -0
- package/dist/ui/Tooltip/Tooltip.js +66 -0
- package/dist/ui/Tooltip/Tooltip.js.map +1 -0
- package/dist/ui/Tooltip/Tooltip.styles.js +6 -0
- package/dist/ui/Tooltip/Tooltip.styles.js.map +1 -0
- package/dist/ui/Tooltip/inheritColours.js +27 -0
- package/dist/ui/Tooltip/inheritColours.js.map +1 -0
- package/dist/ui/VisuallyHidden/VisuallyHidden.js +16 -0
- package/dist/ui/VisuallyHidden/VisuallyHidden.js.map +1 -0
- package/dist/ui/VisuallyHidden/VisuallyHidden.styles.js +6 -0
- package/dist/ui/VisuallyHidden/VisuallyHidden.styles.js.map +1 -0
- package/package.json +82 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useScrollEdges.js","names":[],"sources":["../../src/chrome/useScrollEdges.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-only\n// Copyright MapCairn contributors\nimport { type RefObject, useEffect, useLayoutEffect } from \"react\";\n\n/** Whether a scroll container has more to scroll to, and in which direction. */\nexport type ScrollMore = \"none\" | \"above\" | \"below\" | \"both\";\n\n/** How far from an edge counts as being at it, for fractional scroll positions. */\nconst EDGE_SLACK_PX = 1;\n\n/**\n * What is left to scroll to in `element`: `below` while the end is out of\n * sight, `above` once it has scrolled away from the start, `both` in between,\n * `none` when everything fits.\n */\nexport function scrollMoreOf(element: HTMLElement): ScrollMore {\n const above = element.scrollTop > EDGE_SLACK_PX;\n const below =\n element.scrollTop + element.clientHeight <\n element.scrollHeight - EDGE_SLACK_PX;\n if (above && below) {\n return \"both\";\n }\n if (above) {\n return \"above\";\n }\n return below ? \"below\" : \"none\";\n}\n\n/**\n * Keeps `data-scroll-more` on a scroll container up to date with\n * {@link scrollMoreOf}, so its style can fade the edge that has more behind it\n * (`scrollFade`) and a test can read it. It is set directly on the element, not\n * through state, because it changes on every scroll.\n *\n * @param ref - The scroll container.\n * @remarks It is read again after every render of the caller (the content\n * changes with them), when the container or one of its children resizes, and\n * on scroll. Where there is no `ResizeObserver`, the render and the scroll\n * still keep it current.\n */\nexport function useScrollEdges(ref: RefObject<HTMLElement | null>): void {\n useLayoutEffect(() => {\n const element = ref.current;\n if (element) {\n element.dataset.scrollMore = scrollMoreOf(element);\n }\n });\n\n useEffect(() => {\n const element = ref.current;\n if (!element) {\n return;\n }\n const update = () => {\n element.dataset.scrollMore = scrollMoreOf(element);\n };\n element.addEventListener(\"scroll\", update, { passive: true });\n if (typeof ResizeObserver === \"undefined\") {\n return () => element.removeEventListener(\"scroll\", update);\n }\n const observer = new ResizeObserver(update);\n observer.observe(element);\n for (const child of element.children) {\n observer.observe(child);\n }\n return () => {\n element.removeEventListener(\"scroll\", update);\n observer.disconnect();\n };\n }, [ref]);\n}\n"],"mappings":";;;AAQA,IAAM,gBAAgB;;;;;;AAOtB,SAAgB,aAAa,SAAkC;CAC7D,MAAM,QAAQ,QAAQ,YAAY;CAClC,MAAM,QACJ,QAAQ,YAAY,QAAQ,eAC5B,QAAQ,eAAe;CACzB,IAAI,SAAS,OACX,OAAO;CAET,IAAI,OACF,OAAO;CAET,OAAO,QAAQ,UAAU;AAC3B;;;;;;;;;;;;;AAcA,SAAgB,eAAe,KAA0C;CACvE,sBAAsB;EACpB,MAAM,UAAU,IAAI;EACpB,IAAI,SACF,QAAQ,QAAQ,aAAa,aAAa,OAAO;CAErD,CAAC;CAED,gBAAgB;EACd,MAAM,UAAU,IAAI;EACpB,IAAI,CAAC,SACH;EAEF,MAAM,eAAe;GACnB,QAAQ,QAAQ,aAAa,aAAa,OAAO;EACnD;EACA,QAAQ,iBAAiB,UAAU,QAAQ,EAAE,SAAS,KAAK,CAAC;EAC5D,IAAI,OAAO,mBAAmB,aAC5B,aAAa,QAAQ,oBAAoB,UAAU,MAAM;EAE3D,MAAM,WAAW,IAAI,eAAe,MAAM;EAC1C,SAAS,QAAQ,OAAO;EACxB,KAAK,MAAM,SAAS,QAAQ,UAC1B,SAAS,QAAQ,KAAK;EAExB,aAAa;GACX,QAAQ,oBAAoB,UAAU,MAAM;GAC5C,SAAS,WAAW;EACtB;CACF,GAAG,CAAC,GAAG,CAAC;AACV"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { createContext, useContext } from "react";
|
|
2
|
+
// src/host/MapContext.ts
|
|
3
|
+
/** The map context. Provided by `MapView`; read it with {@link useMap}. */
|
|
4
|
+
var MapContext = createContext(null);
|
|
5
|
+
/**
|
|
6
|
+
* Returns the live map. Throws outside a `MapView`, because a missing map is a
|
|
7
|
+
* wiring bug, not a runtime condition.
|
|
8
|
+
*/
|
|
9
|
+
function useMap() {
|
|
10
|
+
const value = useContext(MapContext);
|
|
11
|
+
if (!value) throw new Error("useMap must be used inside a MapView.");
|
|
12
|
+
return value;
|
|
13
|
+
}
|
|
14
|
+
export { MapContext, useMap };
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=MapContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MapContext.js","names":[],"sources":["../../src/host/MapContext.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-only\n// Copyright MapCairn contributors\nimport type {\n MapAdapter,\n MapEngineError,\n MapProjection,\n ViewState,\n} from \"@mapcairn/core\";\nimport { createContext, useContext } from \"react\";\n\n/** What {@link useMap} returns: the live map, as seen by overlays and chrome. */\nexport interface MapContextValue {\n /**\n * The mounted adapter, or null while the engine is starting, after it failed\n * and during server rendering. Overlays draw nothing while it is null.\n */\n readonly adapter: MapAdapter | null;\n /**\n * The element the engine is mounted in, or null with no mounted engine.\n * A new element replaces it when a failed mount is retried.\n */\n readonly hostElement: HTMLElement | null;\n /**\n * The current view, updated at most once per animation frame while the map\n * moves, zooms or rotates, so overlays re-project without thrashing.\n */\n readonly view: ViewState;\n /**\n * The shape the map is drawn as, from the settings: flat or a globe.\n * Overlays read it to curve long lines and hide the far side.\n */\n readonly projection: MapProjection;\n /** Normalised zoom limits of the active basemap. */\n readonly minZoom: number;\n readonly maxZoom: number;\n readonly canZoomIn: boolean;\n readonly canZoomOut: boolean;\n /** True while the engine starts, the basemap changes or tiles load. */\n readonly loading: boolean;\n /** True after a tile or style request failed, until a later load succeeds without one. */\n readonly tileError: boolean;\n /**\n * Why the engine could not start, or why it stopped after it loaded\n * (reason `stopped`), or null. The app decides the fallback.\n */\n readonly error: MapEngineError | null;\n /**\n * Re-applies the active basemap after a tile error. After an engine error it\n * mounts the engine again instead.\n */\n readonly retry: () => void;\n /** Moves keyboard focus to the map region without scrolling. */\n readonly focusMap: () => void;\n /**\n * Calls `listener` each time the person zooms the map itself: with the\n * zoom keys on the map region, or with a gesture the engine handles (a\n * wheel, a pinch, a double-click). Zooms made in code, such as restoring a\n * permalink or applying a basemap's limits, never call it. Returns the\n * function that unsubscribes.\n */\n readonly onUserZoom: (listener: () => void) => () => void;\n}\n\n/** The map context. Provided by `MapView`; read it with {@link useMap}. */\nexport const MapContext = createContext<MapContextValue | null>(null);\n\n/**\n * Returns the live map. Throws outside a `MapView`, because a missing map is a\n * wiring bug, not a runtime condition.\n */\nexport function useMap(): MapContextValue {\n const value = useContext(MapContext);\n if (!value) {\n throw new Error(\"useMap must be used inside a MapView.\");\n }\n return value;\n}\n"],"mappings":";;;AAgEA,IAAa,aAAa,cAAsC,IAAI;;;;;AAMpE,SAAgB,SAA0B;CACxC,MAAM,QAAQ,WAAW,UAAU;CACnC,IAAI,CAAC,OACH,MAAM,IAAI,MAAM,uCAAuC;CAEzD,OAAO;AACT"}
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import { useMessages, usePreferences } from "../services/hooks.js";
|
|
2
|
+
import { StatusMessageFocusProvider } from "../ui/StatusMessage/StatusMessageFocus.js";
|
|
3
|
+
import { VisuallyHidden } from "../ui/VisuallyHidden/VisuallyHidden.js";
|
|
4
|
+
import { MapContext } from "./MapContext.js";
|
|
5
|
+
import { engineElement, engineSlot, host, loadingBar, loadingTrack } from "./MapView.styles.js";
|
|
6
|
+
import { useLongPress } from "./useLongPress.js";
|
|
7
|
+
import { useMapEngine } from "./useMapEngine.js";
|
|
8
|
+
import { usePointerPosition } from "./usePointerPosition.js";
|
|
9
|
+
import { MAP_KEY_HELP, mapKeyAction, resolveText } from "@mapcairn/core";
|
|
10
|
+
import { useCallback, useId, useMemo, useRef } from "react";
|
|
11
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
12
|
+
// src/host/MapView.tsx
|
|
13
|
+
/**
|
|
14
|
+
* The hidden keyboard instructions, as plain sentences in the catalogue's
|
|
15
|
+
* language: each line is "keys: description." by default. The description is
|
|
16
|
+
* used exactly as the catalogue wrote it, so no code changes its case.
|
|
17
|
+
*/
|
|
18
|
+
function keyboardInstructions(messages, extra) {
|
|
19
|
+
return [...MAP_KEY_HELP, ...extra].map(({ keys, description }) => messages.t("host.map.keyInstruction", {
|
|
20
|
+
keys: resolveText(messages, keys),
|
|
21
|
+
description: resolveText(messages, description)
|
|
22
|
+
})).join(" ");
|
|
23
|
+
}
|
|
24
|
+
/** Runs a key action against the adapter. */
|
|
25
|
+
function runKeyAction(adapter, action, props) {
|
|
26
|
+
switch (action.type) {
|
|
27
|
+
case "pan":
|
|
28
|
+
adapter.panBy(action.dx, action.dy);
|
|
29
|
+
break;
|
|
30
|
+
case "zoomIn":
|
|
31
|
+
adapter.zoomIn();
|
|
32
|
+
props.onUserZoom();
|
|
33
|
+
break;
|
|
34
|
+
case "zoomOut":
|
|
35
|
+
adapter.zoomOut();
|
|
36
|
+
props.onUserZoom();
|
|
37
|
+
break;
|
|
38
|
+
case "rotate":
|
|
39
|
+
adapter.rotateBy(action.degrees);
|
|
40
|
+
break;
|
|
41
|
+
case "resetBearing":
|
|
42
|
+
adapter.resetBearing();
|
|
43
|
+
break;
|
|
44
|
+
case "dropPin":
|
|
45
|
+
props.onDropPinKey?.();
|
|
46
|
+
break;
|
|
47
|
+
case "identify":
|
|
48
|
+
props.onIdentifyKey?.();
|
|
49
|
+
break;
|
|
50
|
+
case "escape": props.onEscape?.();
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* The engine host: the map region and the single focus stop of the map. It
|
|
55
|
+
* mounts the adapter the services build, without knowing which engine that
|
|
56
|
+
* is, and provides the live map to `children` through `useMap`.
|
|
57
|
+
*
|
|
58
|
+
* @remarks
|
|
59
|
+
* - Keyboard and long-press are implemented here once, against the adapter;
|
|
60
|
+
* the engine's own key handling is turned off.
|
|
61
|
+
* - A new basemap is swapped in on the mounted engine, keeping the centre,
|
|
62
|
+
* zoom and bearing. This component, its children and the chrome around it
|
|
63
|
+
* stay mounted.
|
|
64
|
+
* - Server rendering produces the empty region only; no style attributes are
|
|
65
|
+
* rendered, so it works under `style-src 'self'`. `data-zoom` is written
|
|
66
|
+
* with `setAttribute` once the engine reports a zoom.
|
|
67
|
+
* - The host fills its parent; `MapChrome` owns its placement.
|
|
68
|
+
* - The whole output, including `chrome`, is inside the map context.
|
|
69
|
+
*/
|
|
70
|
+
function MapView({ initialView, basemap, onViewChange, onEngineError, onBasemapApplied, onBasemapError, onBasemapUnavailable, onClick, onLongPress, onPointerMove, onDropPinKey, onIdentifyKey, onEscape, onKeyCommand, keyHelp, cursor = "grab", children, id, chrome, testId }) {
|
|
71
|
+
const hostRef = useRef(null);
|
|
72
|
+
const slotRef = useRef(null);
|
|
73
|
+
const adapterRef = useRef(null);
|
|
74
|
+
const helpId = useId();
|
|
75
|
+
const { reducedMotion } = usePreferences();
|
|
76
|
+
const messages = useMessages();
|
|
77
|
+
const { t } = messages;
|
|
78
|
+
const getAdapter = useCallback(() => adapterRef.current, []);
|
|
79
|
+
const longPress = useLongPress({
|
|
80
|
+
hostRef,
|
|
81
|
+
getAdapter,
|
|
82
|
+
onLongPress
|
|
83
|
+
});
|
|
84
|
+
const pointer = usePointerPosition({
|
|
85
|
+
hostRef,
|
|
86
|
+
getAdapter,
|
|
87
|
+
onPointerMove
|
|
88
|
+
});
|
|
89
|
+
const userZoomListeners = useRef(/* @__PURE__ */ new Set());
|
|
90
|
+
const notifyUserZoom = useCallback(() => {
|
|
91
|
+
for (const listener of [...userZoomListeners.current]) listener();
|
|
92
|
+
}, []);
|
|
93
|
+
const onUserZoom = useCallback((listener) => {
|
|
94
|
+
userZoomListeners.current.add(listener);
|
|
95
|
+
return () => {
|
|
96
|
+
userZoomListeners.current.delete(listener);
|
|
97
|
+
};
|
|
98
|
+
}, []);
|
|
99
|
+
const engine = useMapEngine({
|
|
100
|
+
hostRef,
|
|
101
|
+
slotRef,
|
|
102
|
+
adapterRef,
|
|
103
|
+
engineClassName: engineElement,
|
|
104
|
+
initialView,
|
|
105
|
+
basemap,
|
|
106
|
+
onViewChange,
|
|
107
|
+
onEngineError,
|
|
108
|
+
onBasemapApplied,
|
|
109
|
+
onBasemapError,
|
|
110
|
+
onBasemapUnavailable,
|
|
111
|
+
onClick,
|
|
112
|
+
onMoveEnd: longPress.cancel,
|
|
113
|
+
shouldDropClick: longPress.consumeClick,
|
|
114
|
+
onUserZoom: notifyUserZoom
|
|
115
|
+
});
|
|
116
|
+
const map = useMemo(() => ({
|
|
117
|
+
...engine,
|
|
118
|
+
onUserZoom
|
|
119
|
+
}), [engine, onUserZoom]);
|
|
120
|
+
const onKeyDown = (event) => {
|
|
121
|
+
const adapter = adapterRef.current;
|
|
122
|
+
const target = event.target;
|
|
123
|
+
if (!adapter || target !== event.currentTarget && !slotRef.current?.contains(target)) return;
|
|
124
|
+
if (onKeyCommand?.(event)) {
|
|
125
|
+
event.preventDefault();
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
const action = mapKeyAction(event);
|
|
129
|
+
if (!action) return;
|
|
130
|
+
event.preventDefault();
|
|
131
|
+
runKeyAction(adapter, action, {
|
|
132
|
+
onDropPinKey,
|
|
133
|
+
onIdentifyKey,
|
|
134
|
+
onEscape,
|
|
135
|
+
onUserZoom: notifyUserZoom
|
|
136
|
+
});
|
|
137
|
+
};
|
|
138
|
+
const motion = reducedMotion ? "static" : "animated";
|
|
139
|
+
const instructions = keyboardInstructions(messages, keyHelp ?? []);
|
|
140
|
+
const region = /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs("section", {
|
|
141
|
+
ref: hostRef,
|
|
142
|
+
id,
|
|
143
|
+
"aria-label": t("host.map.label", {}),
|
|
144
|
+
"aria-roledescription": t("host.map.roleDescription", {}),
|
|
145
|
+
"aria-describedby": helpId,
|
|
146
|
+
"aria-busy": map.loading,
|
|
147
|
+
tabIndex: 0,
|
|
148
|
+
"data-map-host": "",
|
|
149
|
+
"data-projection": map.projection,
|
|
150
|
+
"data-state": map.error ? "error" : void 0,
|
|
151
|
+
"data-testid": testId,
|
|
152
|
+
className: host[cursor],
|
|
153
|
+
onKeyDown,
|
|
154
|
+
...longPress.handlers,
|
|
155
|
+
onPointerMove: (event) => {
|
|
156
|
+
longPress.handlers.onPointerMove(event);
|
|
157
|
+
pointer.onPointerMove(event);
|
|
158
|
+
},
|
|
159
|
+
onPointerLeave: pointer.onPointerLeave,
|
|
160
|
+
children: [
|
|
161
|
+
/* @__PURE__ */ jsx("div", {
|
|
162
|
+
ref: slotRef,
|
|
163
|
+
className: engineSlot
|
|
164
|
+
}),
|
|
165
|
+
children,
|
|
166
|
+
map.loading ? /* @__PURE__ */ jsx("div", {
|
|
167
|
+
className: loadingTrack[motion],
|
|
168
|
+
"data-testid": "map-loading",
|
|
169
|
+
"data-motion": motion,
|
|
170
|
+
"aria-hidden": "true",
|
|
171
|
+
children: /* @__PURE__ */ jsx("div", { className: loadingBar })
|
|
172
|
+
}) : null
|
|
173
|
+
]
|
|
174
|
+
}), /* @__PURE__ */ jsx(VisuallyHidden, {
|
|
175
|
+
id: helpId,
|
|
176
|
+
children: instructions
|
|
177
|
+
})] });
|
|
178
|
+
const content = chrome ? chrome(region) : region;
|
|
179
|
+
return /* @__PURE__ */ jsx(MapContext.Provider, {
|
|
180
|
+
value: map,
|
|
181
|
+
children: /* @__PURE__ */ jsx(StatusMessageFocusProvider, {
|
|
182
|
+
fallback: map.focusMap,
|
|
183
|
+
children: content
|
|
184
|
+
})
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
export { MapView };
|
|
188
|
+
|
|
189
|
+
//# sourceMappingURL=MapView.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MapView.js","names":["styles.engineElement","_Fragment","styles.host","styles.engineSlot","styles.loadingTrack","styles.loadingBar"],"sources":["../../src/host/MapView.tsx"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-only\n// Copyright MapCairn contributors\nimport {\n type BasemapDefinition,\n type LatLng,\n MAP_KEY_HELP,\n type MapAdapter,\n type MapClickEvent,\n type MapEngineError,\n type MapKeyAction,\n type MapKeyHelpEntry,\n type MessageCatalogue,\n mapKeyAction,\n resolveText,\n type ViewState,\n} from \"@mapcairn/core\";\nimport {\n type KeyboardEvent,\n type ReactNode,\n useCallback,\n useId,\n useMemo,\n useRef,\n} from \"react\";\nimport { useMessages, usePreferences } from \"../services\";\nimport { StatusMessageFocusProvider } from \"../ui/StatusMessage\";\nimport { VisuallyHidden } from \"../ui/VisuallyHidden\";\nimport { MapContext, type MapContextValue } from \"./MapContext\";\nimport * as styles from \"./MapView.css\";\nimport { type MapLongPressEvent, useLongPress } from \"./useLongPress\";\nimport { useMapEngine } from \"./useMapEngine\";\nimport { usePointerPosition } from \"./usePointerPosition\";\n\n/** The pointer shown over the map: grab for panning, crosshair while measuring. */\nexport type MapCursor = \"grab\" | \"crosshair\";\n\n/** Props for {@link MapView}. */\nexport interface MapViewProps {\n /** The view the engine mounts with. Later changes are ignored. */\n readonly initialView: ViewState;\n /** The active basemap. A change is applied to the mounted engine with `setBasemap`. */\n readonly basemap: BasemapDefinition;\n /** Called when the view stops changing (`moveEnd`), not on every frame. */\n readonly onViewChange?: (view: ViewState) => void;\n /**\n * Called when the engine cannot start or stops working. The\n * app decides what to show, for example a message when WebGL is missing.\n */\n readonly onEngineError?: (\n error: MapEngineError,\n basemap: BasemapDefinition,\n ) => void;\n /**\n * Called when a change of `basemap` has loaded on the mounted engine, so\n * the app can save the choice only once it is known to work.\n */\n readonly onBasemapApplied?: (basemap: BasemapDefinition) => void;\n /**\n * Called when a change of `basemap` could not load. The map keeps drawing\n * `kept`, the basemap that last loaded, and this is not an engine error:\n * `useMap().error` stays null. Passing `kept` back as `basemap` causes no\n * second swap.\n */\n readonly onBasemapError?: (\n error: MapEngineError,\n failed: BasemapDefinition,\n kept: BasemapDefinition,\n ) => void;\n /**\n * Called when every tile of the basemap being drawn failed to load and none\n * loaded, once the map settled (its provider is down). The map keeps\n * working, so the host decides whether to draw another basemap instead.\n */\n readonly onBasemapUnavailable?: (basemap: BasemapDefinition) => void;\n /** A click or tap on the map. Not called for the click that ends a long-press. */\n readonly onClick?: (event: MapClickEvent) => void;\n /** A long-press (touch or mouse) or a right-click. */\n readonly onLongPress?: (event: MapLongPressEvent) => void;\n /**\n * The position under a mouse or pen, at most once per frame, or null when\n * it leaves the map. For the cursor coordinates readout; touch is ignored.\n * Leaving the map for `MapReadout` reports nothing, so the coordinates stay\n * put while the readout grows under the pointer: pass `MapReadout` an\n * `onCursorLeave` that clears the position, or it stays shown after the\n * pointer leaves the readout.\n */\n readonly onPointerMove?: (latlng: LatLng | null) => void;\n /** The P key, which drops a pin at the centre of the map. */\n readonly onDropPinKey?: () => void;\n /** The I key, which lists the features at the centre of the map. */\n readonly onIdentifyKey?: () => void;\n /** The Escape key while the map has focus. */\n readonly onEscape?: () => void;\n /**\n * Runs before the map's own keys, with each key pressed on the map region.\n * Return true to say the key was handled: the map then does nothing with it\n * and its default is prevented. A tool uses this to take keys the map would\n * otherwise use, such as the arrows that move a selected point.\n */\n readonly onKeyCommand?: (event: KeyboardEvent<HTMLElement>) => boolean;\n /**\n * Extra lines for the hidden keyboard instructions, after the map's own,\n * for the keys a tool adds while it is open. Descriptions are used as\n * written, so write each as a complete sentence without a trailing full\n * stop.\n */\n readonly keyHelp?: readonly MapKeyHelpEntry[];\n /** Defaults to `grab`. */\n readonly cursor?: MapCursor;\n /** Overlays and other content that reads the map through `useMap`. */\n readonly children?: ReactNode;\n /** The id of the map region, for example the target of a skip link. */\n readonly id?: string;\n /**\n * Renders the chrome around the map, inside the map context. It receives\n * the map region (with its hidden keyboard help) and returns the tree to\n * render in its place, so controls that call `useMap`, such as the scale\n * bar and the credits, can sit beside the map rather than inside it:\n * `chrome={(map) => <MapChrome background={map} ... />}`. Called on every\n * render; put hooks in the components it returns, not in the function.\n */\n readonly chrome?: (map: ReactNode) => ReactNode;\n readonly testId?: string;\n}\n\n/**\n * The hidden keyboard instructions, as plain sentences in the catalogue's\n * language: each line is \"keys: description.\" by default. The description is\n * used exactly as the catalogue wrote it, so no code changes its case.\n */\nfunction keyboardInstructions(\n messages: MessageCatalogue,\n extra: readonly MapKeyHelpEntry[],\n): string {\n return [...MAP_KEY_HELP, ...extra]\n .map(({ keys, description }) =>\n messages.t(\"host.map.keyInstruction\", {\n keys: resolveText(messages, keys),\n description: resolveText(messages, description),\n }),\n )\n .join(\" \");\n}\n\n/** Runs a key action against the adapter. */\nfunction runKeyAction(\n adapter: MapAdapter,\n action: MapKeyAction,\n props: Pick<MapViewProps, \"onDropPinKey\" | \"onIdentifyKey\" | \"onEscape\"> & {\n readonly onUserZoom: () => void;\n },\n): void {\n switch (action.type) {\n case \"pan\":\n adapter.panBy(action.dx, action.dy);\n break;\n case \"zoomIn\":\n adapter.zoomIn();\n props.onUserZoom();\n break;\n case \"zoomOut\":\n adapter.zoomOut();\n props.onUserZoom();\n break;\n case \"rotate\":\n adapter.rotateBy(action.degrees);\n break;\n case \"resetBearing\":\n adapter.resetBearing();\n break;\n case \"dropPin\":\n props.onDropPinKey?.();\n break;\n case \"identify\":\n props.onIdentifyKey?.();\n break;\n case \"escape\":\n props.onEscape?.();\n break;\n }\n}\n\n/**\n * The engine host: the map region and the single focus stop of the map. It\n * mounts the adapter the services build, without knowing which engine that\n * is, and provides the live map to `children` through `useMap`.\n *\n * @remarks\n * - Keyboard and long-press are implemented here once, against the adapter;\n * the engine's own key handling is turned off.\n * - A new basemap is swapped in on the mounted engine, keeping the centre,\n * zoom and bearing. This component, its children and the chrome around it\n * stay mounted.\n * - Server rendering produces the empty region only; no style attributes are\n * rendered, so it works under `style-src 'self'`. `data-zoom` is written\n * with `setAttribute` once the engine reports a zoom.\n * - The host fills its parent; `MapChrome` owns its placement.\n * - The whole output, including `chrome`, is inside the map context.\n */\nexport function MapView({\n initialView,\n basemap,\n onViewChange,\n onEngineError,\n onBasemapApplied,\n onBasemapError,\n onBasemapUnavailable,\n onClick,\n onLongPress,\n onPointerMove,\n onDropPinKey,\n onIdentifyKey,\n onEscape,\n onKeyCommand,\n keyHelp,\n cursor = \"grab\",\n children,\n id,\n chrome,\n testId,\n}: MapViewProps) {\n const hostRef = useRef<HTMLElement>(null);\n const slotRef = useRef<HTMLDivElement>(null);\n const adapterRef = useRef<MapAdapter | null>(null);\n const helpId = useId();\n const { reducedMotion } = usePreferences();\n const messages = useMessages();\n const { t } = messages;\n\n const getAdapter = useCallback(() => adapterRef.current, []);\n const longPress = useLongPress({ hostRef, getAdapter, onLongPress });\n const pointer = usePointerPosition({ hostRef, getAdapter, onPointerMove });\n\n // Listeners for zooms the person makes on the map itself. A set in a ref,\n // not state: a gesture reports many steps, and none should re-render.\n const userZoomListeners = useRef(new Set<() => void>());\n const notifyUserZoom = useCallback(() => {\n for (const listener of [...userZoomListeners.current]) {\n listener();\n }\n }, []);\n const onUserZoom = useCallback((listener: () => void) => {\n userZoomListeners.current.add(listener);\n return () => {\n userZoomListeners.current.delete(listener);\n };\n }, []);\n\n const engine = useMapEngine({\n hostRef,\n slotRef,\n adapterRef,\n engineClassName: styles.engineElement,\n initialView,\n basemap,\n onViewChange,\n onEngineError,\n onBasemapApplied,\n onBasemapError,\n onBasemapUnavailable,\n onClick,\n onMoveEnd: longPress.cancel,\n shouldDropClick: longPress.consumeClick,\n onUserZoom: notifyUserZoom,\n });\n const map = useMemo<MapContextValue>(\n () => ({ ...engine, onUserZoom }),\n [engine, onUserZoom],\n );\n\n const onKeyDown = (event: KeyboardEvent<HTMLElement>) => {\n const adapter = adapterRef.current;\n const target = event.target as Node;\n if (\n !adapter ||\n (target !== event.currentTarget && !slotRef.current?.contains(target))\n ) {\n return;\n }\n if (onKeyCommand?.(event)) {\n event.preventDefault();\n return;\n }\n const action = mapKeyAction(event);\n if (!action) {\n return;\n }\n event.preventDefault();\n runKeyAction(adapter, action, {\n onDropPinKey,\n onIdentifyKey,\n onEscape,\n onUserZoom: notifyUserZoom,\n });\n };\n\n const motion = reducedMotion ? \"static\" : \"animated\";\n\n const instructions = keyboardInstructions(messages, keyHelp ?? []);\n\n const region = (\n <>\n {/* biome-ignore lint/a11y/noNoninteractiveElementInteractions: the focused map region is the one keyboard and pointer target for panning, zooming, pins and long-press; each gesture has a button or key equivalent. */}\n <section\n ref={hostRef}\n id={id}\n aria-label={t(\"host.map.label\", {})}\n aria-roledescription={t(\"host.map.roleDescription\", {})}\n aria-describedby={helpId}\n aria-busy={map.loading}\n // biome-ignore lint/a11y/noNoninteractiveTabindex: the map region is the keyboard target for panning, zooming and pins.\n tabIndex={0}\n data-map-host=\"\"\n data-projection={map.projection}\n data-state={map.error ? \"error\" : undefined}\n data-testid={testId}\n className={styles.host[cursor]}\n onKeyDown={onKeyDown}\n {...longPress.handlers}\n onPointerMove={(event) => {\n longPress.handlers.onPointerMove(event);\n pointer.onPointerMove(event);\n }}\n onPointerLeave={pointer.onPointerLeave}\n >\n <div ref={slotRef} className={styles.engineSlot} />\n {children}\n {map.loading ? (\n <div\n className={styles.loadingTrack[motion]}\n data-testid=\"map-loading\"\n data-motion={motion}\n aria-hidden=\"true\"\n >\n <div className={styles.loadingBar} />\n </div>\n ) : null}\n </section>\n <VisuallyHidden id={helpId}>{instructions}</VisuallyHidden>\n </>\n );\n\n const content = chrome ? chrome(region) : region;\n\n return (\n <MapContext.Provider value={map}>\n <StatusMessageFocusProvider fallback={map.focusMap}>\n {content}\n </StatusMessageFocusProvider>\n </MapContext.Provider>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAkIA,SAAS,qBACP,UACA,OACQ;CACR,OAAO,CAAC,GAAG,cAAc,GAAG,KAAK,CAAC,CAC/B,KAAK,EAAE,MAAM,kBACZ,SAAS,EAAE,2BAA2B;EACpC,MAAM,YAAY,UAAU,IAAI;EAChC,aAAa,YAAY,UAAU,WAAW;CAChD,CAAC,CACH,CAAC,CACA,KAAK,GAAG;AACb;;AAGA,SAAS,aACP,SACA,QACA,OAGM;CACN,QAAQ,OAAO,MAAf;EACE,KAAK;GACH,QAAQ,MAAM,OAAO,IAAI,OAAO,EAAE;GAClC;EACF,KAAK;GACH,QAAQ,OAAO;GACf,MAAM,WAAW;GACjB;EACF,KAAK;GACH,QAAQ,QAAQ;GAChB,MAAM,WAAW;GACjB;EACF,KAAK;GACH,QAAQ,SAAS,OAAO,OAAO;GAC/B;EACF,KAAK;GACH,QAAQ,aAAa;GACrB;EACF,KAAK;GACH,MAAM,eAAe;GACrB;EACF,KAAK;GACH,MAAM,gBAAgB;GACtB;EACF,KAAK,UACH,MAAM,WAAW;CAErB;AACF;;;;;;;;;;;;;;;;;;AAmBA,SAAgB,QAAQ,EACtB,aACA,SACA,cACA,eACA,kBACA,gBACA,sBACA,SACA,aACA,eACA,cACA,eACA,UACA,cACA,SACA,SAAS,QACT,UACA,IACA,QACA,UACe;CACf,MAAM,UAAU,OAAoB,IAA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km3";
|
|
8
|
+
var engineElement = "_14x9kkm4";
|
|
9
|
+
var loadingTrack = {
|
|
10
|
+
animated: "_14x9kkm8 _14x9kkm7",
|
|
11
|
+
"static": "_14x9kkm9 _14x9kkm7"
|
|
12
|
+
};
|
|
13
|
+
var loadingBar = "_14x9kkma";
|
|
14
|
+
export { engineElement, engineSlot, host, loadingBar, loadingTrack };
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=MapView.styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MapView.styles.js","names":[],"sources":[],"mappings":""}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { useMap } from "../MapContext.js";
|
|
2
|
+
import { roundPixel, screenRadiusForMetres, usePlacement } from "./geometry.js";
|
|
3
|
+
import { accuracy } from "./overlays.styles.js";
|
|
4
|
+
import { placePoint } from "@mapcairn/core";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
// src/host/overlays/AccuracyCircle.tsx
|
|
7
|
+
/**
|
|
8
|
+
* The smallest radius drawn, so a very precise fix still shows a circle.
|
|
9
|
+
*
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
var MIN_ACCURACY_RADIUS_PX = 8;
|
|
13
|
+
/**
|
|
14
|
+
* The circle around a found location, sized from the ground resolution at its
|
|
15
|
+
* latitude so it matches the real accuracy at every zoom (on a globe, the
|
|
16
|
+
* resolution at the view centre, which holds across the sphere). Render it
|
|
17
|
+
* inside `MapOverlayLayer`.
|
|
18
|
+
*/
|
|
19
|
+
function AccuracyCircle({ center, accuracyMetres, testId }) {
|
|
20
|
+
const { adapter } = useMap();
|
|
21
|
+
const placement = usePlacement();
|
|
22
|
+
const at = placement ? placePoint(center, placement) : null;
|
|
23
|
+
if (!adapter || !at) return null;
|
|
24
|
+
const { x, y } = at;
|
|
25
|
+
const radius = screenRadiusForMetres(accuracyMetres, adapter.metresPerPixel(center.lat), 8);
|
|
26
|
+
return /* @__PURE__ */ jsx("circle", {
|
|
27
|
+
className: accuracy,
|
|
28
|
+
cx: roundPixel(x),
|
|
29
|
+
cy: roundPixel(y),
|
|
30
|
+
r: roundPixel(radius),
|
|
31
|
+
"data-testid": testId
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
export { AccuracyCircle, MIN_ACCURACY_RADIUS_PX };
|
|
35
|
+
|
|
36
|
+
//# sourceMappingURL=AccuracyCircle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AccuracyCircle.js","names":["styles.accuracy"],"sources":["../../../src/host/overlays/AccuracyCircle.tsx"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-only\n// Copyright MapCairn contributors\nimport { type LatLng, placePoint } from \"@mapcairn/core\";\nimport { useMap } from \"../MapContext\";\nimport { roundPixel, screenRadiusForMetres, usePlacement } from \"./geometry\";\nimport * as styles from \"./overlays.css\";\n\n/**\n * The smallest radius drawn, so a very precise fix still shows a circle.\n *\n * @internal\n */\nexport const MIN_ACCURACY_RADIUS_PX = 8;\n\n/** Props for {@link AccuracyCircle}. */\nexport interface AccuracyCircleProps {\n readonly center: LatLng;\n /** The location's accuracy radius on the ground. */\n readonly accuracyMetres: number;\n readonly testId?: string;\n}\n\n/**\n * The circle around a found location, sized from the ground resolution at its\n * latitude so it matches the real accuracy at every zoom (on a globe, the\n * resolution at the view centre, which holds across the sphere). Render it\n * inside `MapOverlayLayer`.\n */\nexport function AccuracyCircle({\n center,\n accuracyMetres,\n testId,\n}: AccuracyCircleProps) {\n const { adapter } = useMap();\n const placement = usePlacement();\n const at = placement ? placePoint(center, placement) : null;\n if (!adapter || !at) {\n return null;\n }\n const { x, y } = at;\n const radius = screenRadiusForMetres(\n accuracyMetres,\n adapter.metresPerPixel(center.lat),\n MIN_ACCURACY_RADIUS_PX,\n );\n return (\n <circle\n className={styles.accuracy}\n cx={roundPixel(x)}\n cy={roundPixel(y)}\n r={roundPixel(radius)}\n data-testid={testId}\n />\n );\n}\n"],"mappings":";;;;;;;;;;;AAYA,IAAa,yBAAyB;;;;;;;AAgBtC,SAAgB,eAAe,EAC7B,QACA,gBACA,UACsB;CACtB,MAAM,EAAE,YAAY,OAAO;CAC3B,MAAM,YAAY,aAAa;CAC/B,MAAM,KAAK,YAAY,WAAW,QAAQ,SAAS,IAAI;CACvD,IAAI,CAAC,WAAW,CAAC,IACf,OAAO;CAET,MAAM,EAAE,GAAG,MAAM;CACjB,MAAM,SAAS,sBACb,gBACA,QAAQ,eAAe,OAAO,GAAG,GAAA,CAEnC;CACA,OACE,oBAAC,UAAD;EACE,WAAWA;EACX,IAAI,WAAW,CAAC;EAChB,IAAI,WAAW,CAAC;EAChB,GAAG,WAAW,MAAM;EACpB,eAAa;CACd,CAAA;AAEL"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { useMap } from "../MapContext.js";
|
|
2
|
+
import { roundPixel } from "./geometry.js";
|
|
3
|
+
import { crosshairHalo, crosshairLine } from "./overlays.styles.js";
|
|
4
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
// src/host/overlays/CentreCrosshair.tsx
|
|
6
|
+
/** Half the length of each crosshair arm, in pixels. */
|
|
7
|
+
var CROSSHAIR_ARM_PX = 10;
|
|
8
|
+
/**
|
|
9
|
+
* A small crosshair at the centre of the map, shown while measuring so "Add
|
|
10
|
+
* point at map centre" has a visible target. Render it inside
|
|
11
|
+
* `MapOverlayLayer` only while measuring.
|
|
12
|
+
*/
|
|
13
|
+
function CentreCrosshair({ at, testId }) {
|
|
14
|
+
const { adapter, view } = useMap();
|
|
15
|
+
if (!adapter) return null;
|
|
16
|
+
const centre = at ?? adapter.project(view.center);
|
|
17
|
+
const x = roundPixel(centre.x);
|
|
18
|
+
const y = roundPixel(centre.y);
|
|
19
|
+
const arm = CROSSHAIR_ARM_PX;
|
|
20
|
+
const lines = (className) => /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("line", {
|
|
21
|
+
className,
|
|
22
|
+
x1: x - arm,
|
|
23
|
+
y1: y,
|
|
24
|
+
x2: x + arm,
|
|
25
|
+
y2: y
|
|
26
|
+
}), /* @__PURE__ */ jsx("line", {
|
|
27
|
+
className,
|
|
28
|
+
x1: x,
|
|
29
|
+
y1: y - arm,
|
|
30
|
+
x2: x,
|
|
31
|
+
y2: y + arm
|
|
32
|
+
})] });
|
|
33
|
+
return /* @__PURE__ */ jsxs("g", {
|
|
34
|
+
"data-testid": testId,
|
|
35
|
+
children: [lines(crosshairHalo), lines(crosshairLine)]
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
export { CentreCrosshair };
|
|
39
|
+
|
|
40
|
+
//# sourceMappingURL=CentreCrosshair.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CentreCrosshair.js","names":["_Fragment","styles.crosshairHalo","styles.crosshairLine"],"sources":["../../../src/host/overlays/CentreCrosshair.tsx"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-only\n// Copyright MapCairn contributors\nimport { useMap } from \"../MapContext\";\nimport { roundPixel } from \"./geometry\";\nimport * as styles from \"./overlays.css\";\n\n/** Half the length of each crosshair arm, in pixels. */\nconst CROSSHAIR_ARM_PX = 10;\n\n/** Props for {@link CentreCrosshair}. */\nexport interface CentreCrosshairProps {\n /**\n * Where to draw it, in pixels from the map's top left. Defaults to the\n * centre of the whole map; a tool whose panel covers part of the map passes\n * the middle of what is left.\n */\n readonly at?: { readonly x: number; readonly y: number };\n readonly testId?: string;\n}\n\n/**\n * A small crosshair at the centre of the map, shown while measuring so \"Add\n * point at map centre\" has a visible target. Render it inside\n * `MapOverlayLayer` only while measuring.\n */\nexport function CentreCrosshair({ at, testId }: CentreCrosshairProps) {\n const { adapter, view } = useMap();\n if (!adapter) {\n return null;\n }\n const centre = at ?? adapter.project(view.center);\n const x = roundPixel(centre.x);\n const y = roundPixel(centre.y);\n const arm = CROSSHAIR_ARM_PX;\n const lines = (className: string) => (\n <>\n <line className={className} x1={x - arm} y1={y} x2={x + arm} y2={y} />\n <line className={className} x1={x} y1={y - arm} x2={x} y2={y + arm} />\n </>\n );\n return (\n <g data-testid={testId}>\n {lines(styles.crosshairHalo)}\n {lines(styles.crosshairLine)}\n </g>\n );\n}\n"],"mappings":";;;;;;AAOA,IAAM,mBAAmB;;;;;;AAkBzB,SAAgB,gBAAgB,EAAE,IAAI,UAAgC;CACpE,MAAM,EAAE,SAAS,SAAS,OAAO;CACjC,IAAI,CAAC,SACH,OAAO;CAET,MAAM,SAAS,MAAM,QAAQ,QAAQ,KAAK,MAAM;CAChD,MAAM,IAAI,WAAW,OAAO,CAAC;CAC7B,MAAM,IAAI,WAAW,OAAO,CAAC;CAC7B,MAAM,MAAM;CACZ,MAAM,SAAS,cACb,qBAAAA,UAAA,EAAA,UAAA,CACE,oBAAC,QAAD;EAAiB;EAAW,IAAI,IAAI;EAAK,IAAI;EAAG,IAAI,IAAI;EAAK,IAAI;CAAI,CAAA,GACrE,oBAAC,QAAD;EAAiB;EAAW,IAAI;EAAG,IAAI,IAAI;EAAK,IAAI;EAAG,IAAI,IAAI;CAAM,CAAA,CACrE,EAAA,CAAA;CAEJ,OACE,qBAAC,KAAD;EAAG,eAAa;EAAhB,UAAA,CACG,MAAMC,aAAoB,GAC1B,MAAMC,aAAoB,CAC1B;;AAEP"}
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import { roundPixel, toSvgPoints, usePlacement } from "./geometry.js";
|
|
2
|
+
import { drawDraft, drawFill, drawLine, drawLineSelected, drawMidpoint, drawPoint, drawPointSelected, drawRadiusHandle, drawVertex, drawVertexSelected, measureHalo, measurePreview } from "./overlays.styles.js";
|
|
3
|
+
import { circleRing, distanceMetres, placePath, placePoint, shapeRing, visibleRuns } from "@mapcairn/core";
|
|
4
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
// src/host/overlays/DrawOverlay.tsx
|
|
6
|
+
/** Radius of a point shape's marker, in pixels. */
|
|
7
|
+
var DRAW_POINT_RADIUS_PX = 7;
|
|
8
|
+
/** Radius of a vertex handle, in pixels. The press reaches further than this. */
|
|
9
|
+
var DRAW_VERTEX_RADIUS_PX = 7;
|
|
10
|
+
/** Radius of the selected vertex's handle, in pixels, so it stands apart by size as well as fill. */
|
|
11
|
+
var DRAW_SELECTED_VERTEX_RADIUS_PX = 10;
|
|
12
|
+
/** Radius of a midpoint handle, in pixels. */
|
|
13
|
+
var DRAW_MIDPOINT_RADIUS_PX = 4;
|
|
14
|
+
/** Half the side of a circle's radius handle, in pixels. */
|
|
15
|
+
var DRAW_RADIUS_HANDLE_HALF_PX = 7;
|
|
16
|
+
/** How many positions the preview ring of a circle being drawn has. */
|
|
17
|
+
var PREVIEW_RING_STEPS = 48;
|
|
18
|
+
/** A line with a halo beneath it, open or closed. */
|
|
19
|
+
function HaloPath({ points, closed, className }) {
|
|
20
|
+
const Shape = closed ? "polygon" : "polyline";
|
|
21
|
+
const svgPoints = toSvgPoints(points);
|
|
22
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Shape, {
|
|
23
|
+
className: measureHalo,
|
|
24
|
+
points: svgPoints
|
|
25
|
+
}), /* @__PURE__ */ jsx(Shape, {
|
|
26
|
+
className,
|
|
27
|
+
points: svgPoints
|
|
28
|
+
})] });
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* An outline: the whole closed path while all of it is in sight, otherwise
|
|
32
|
+
* the runs of visible points, each as an open line.
|
|
33
|
+
*/
|
|
34
|
+
function Outline({ path, className }) {
|
|
35
|
+
if (path.closed && path.whole) return /* @__PURE__ */ jsx(HaloPath, {
|
|
36
|
+
points: path.pixels,
|
|
37
|
+
closed: true,
|
|
38
|
+
className
|
|
39
|
+
});
|
|
40
|
+
return /* @__PURE__ */ jsx(Fragment, { children: visibleRuns(path).map((run, index) => /* @__PURE__ */ jsx(HaloPath, {
|
|
41
|
+
points: run,
|
|
42
|
+
closed: false,
|
|
43
|
+
className
|
|
44
|
+
}, index)) });
|
|
45
|
+
}
|
|
46
|
+
function shapeClass(shape, selected) {
|
|
47
|
+
if (!shape.done) return drawDraft;
|
|
48
|
+
return selected ? drawLineSelected : drawLine;
|
|
49
|
+
}
|
|
50
|
+
/** One shape: its fill, outline and, for a point, its marker. */
|
|
51
|
+
function DrawnShape({ shape, selected, placement }) {
|
|
52
|
+
const className = shapeClass(shape, selected);
|
|
53
|
+
const common = {
|
|
54
|
+
"data-testid": "draw-shape",
|
|
55
|
+
"data-shape-id": shape.id,
|
|
56
|
+
"data-kind": shape.kind,
|
|
57
|
+
"data-selected": selected ? "true" : "false",
|
|
58
|
+
"data-done": shape.done ? "true" : "false"
|
|
59
|
+
};
|
|
60
|
+
const first = shape.vertices[0];
|
|
61
|
+
if (!first) return null;
|
|
62
|
+
if (shape.kind === "point") {
|
|
63
|
+
const at = placePoint(first, placement);
|
|
64
|
+
if (!at) return null;
|
|
65
|
+
return /* @__PURE__ */ jsx("circle", {
|
|
66
|
+
...common,
|
|
67
|
+
className: selected ? drawPointSelected : drawPoint,
|
|
68
|
+
cx: roundPixel(at.x),
|
|
69
|
+
cy: roundPixel(at.y),
|
|
70
|
+
r: DRAW_POINT_RADIUS_PX
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
if (shape.kind === "line") return shape.vertices.length >= 2 ? /* @__PURE__ */ jsx("g", {
|
|
74
|
+
...common,
|
|
75
|
+
children: /* @__PURE__ */ jsx(Outline, {
|
|
76
|
+
path: placePath(shape.vertices, false, placement),
|
|
77
|
+
className
|
|
78
|
+
})
|
|
79
|
+
}) : null;
|
|
80
|
+
if (shape.kind === "circle") {
|
|
81
|
+
const ring = placePath(shapeRing(shape), true, placement);
|
|
82
|
+
return ring.pixels.length >= 3 ? /* @__PURE__ */ jsxs("g", {
|
|
83
|
+
...common,
|
|
84
|
+
children: [ring.whole ? /* @__PURE__ */ jsx("polygon", {
|
|
85
|
+
className: drawFill,
|
|
86
|
+
points: toSvgPoints(ring.pixels)
|
|
87
|
+
}) : null, /* @__PURE__ */ jsx(Outline, {
|
|
88
|
+
path: ring,
|
|
89
|
+
className
|
|
90
|
+
})]
|
|
91
|
+
}) : null;
|
|
92
|
+
}
|
|
93
|
+
if (shape.vertices.length < 3) return shape.vertices.length === 2 ? /* @__PURE__ */ jsx("g", {
|
|
94
|
+
...common,
|
|
95
|
+
children: /* @__PURE__ */ jsx(Outline, {
|
|
96
|
+
path: placePath(shape.vertices, false, placement),
|
|
97
|
+
className
|
|
98
|
+
})
|
|
99
|
+
}) : null;
|
|
100
|
+
const path = placePath(shape.vertices, true, placement);
|
|
101
|
+
return /* @__PURE__ */ jsxs("g", {
|
|
102
|
+
...common,
|
|
103
|
+
children: [path.whole ? /* @__PURE__ */ jsx("polygon", {
|
|
104
|
+
className: drawFill,
|
|
105
|
+
points: toSvgPoints(path.pixels)
|
|
106
|
+
}) : null, /* @__PURE__ */ jsx(Outline, {
|
|
107
|
+
path,
|
|
108
|
+
className
|
|
109
|
+
})]
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
/** The dashed edge from the last vertex of the shape being drawn to the pointer. */
|
|
113
|
+
function Preview({ draft, hover, placement }) {
|
|
114
|
+
const last = draft.vertices.at(-1);
|
|
115
|
+
const first = draft.vertices[0];
|
|
116
|
+
if (!last || !first) return null;
|
|
117
|
+
if (draft.kind === "circle") {
|
|
118
|
+
const radius = distanceMetres(first, hover);
|
|
119
|
+
return radius > 0 ? /* @__PURE__ */ jsx(Outline, {
|
|
120
|
+
path: placePath(circleRing(first, radius, PREVIEW_RING_STEPS), true, placement),
|
|
121
|
+
className: measurePreview
|
|
122
|
+
}) : null;
|
|
123
|
+
}
|
|
124
|
+
const path = draft.kind === "polygon" && draft.vertices.length >= 2 ? [
|
|
125
|
+
last,
|
|
126
|
+
hover,
|
|
127
|
+
first
|
|
128
|
+
] : [last, hover];
|
|
129
|
+
return /* @__PURE__ */ jsx(Outline, {
|
|
130
|
+
path: placePath(path, false, placement),
|
|
131
|
+
className: measurePreview
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
/** One handle: a circle for a vertex, a small one for a midpoint and a square for a radius. */
|
|
135
|
+
function Handle({ handle, at, selected, hovered }) {
|
|
136
|
+
const common = {
|
|
137
|
+
"data-testid": "draw-handle",
|
|
138
|
+
"data-handle-id": handle.id,
|
|
139
|
+
"data-handle-kind": handle.kind,
|
|
140
|
+
"data-selected": selected ? "true" : "false",
|
|
141
|
+
"data-hovered": hovered ? "true" : "false"
|
|
142
|
+
};
|
|
143
|
+
const cx = roundPixel(at.x);
|
|
144
|
+
const cy = roundPixel(at.y);
|
|
145
|
+
if (handle.kind === "radius") {
|
|
146
|
+
const half = DRAW_RADIUS_HANDLE_HALF_PX + (hovered ? 2 : 0);
|
|
147
|
+
return /* @__PURE__ */ jsx("rect", {
|
|
148
|
+
...common,
|
|
149
|
+
className: drawRadiusHandle,
|
|
150
|
+
x: cx - half,
|
|
151
|
+
y: cy - half,
|
|
152
|
+
width: half * 2,
|
|
153
|
+
height: half * 2
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
if (handle.kind === "midpoint") return /* @__PURE__ */ jsx("circle", {
|
|
157
|
+
...common,
|
|
158
|
+
className: drawMidpoint,
|
|
159
|
+
cx,
|
|
160
|
+
cy,
|
|
161
|
+
r: DRAW_MIDPOINT_RADIUS_PX + (hovered ? 2 : 0)
|
|
162
|
+
});
|
|
163
|
+
const base = selected ? DRAW_SELECTED_VERTEX_RADIUS_PX : DRAW_VERTEX_RADIUS_PX;
|
|
164
|
+
return /* @__PURE__ */ jsx("circle", {
|
|
165
|
+
...common,
|
|
166
|
+
className: selected ? drawVertexSelected : drawVertex,
|
|
167
|
+
cx,
|
|
168
|
+
cy,
|
|
169
|
+
r: base + (hovered ? 2 : 0)
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
function selectedHandle(handle, selection) {
|
|
173
|
+
return selection !== null && selection.vertex !== null && handle.id === `${selection.shapeId}:v:${selection.vertex}`;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* The draw tool's drawing: every shape with its fill and outline, the
|
|
177
|
+
* unfinished one dashed, the selected one drawn heavier, a dashed preview of
|
|
178
|
+
* the next edge, and the handles of the selected shape. Render it inside
|
|
179
|
+
* `MapOverlayLayer`.
|
|
180
|
+
*
|
|
181
|
+
* @remarks Edges go the short way across the antimeridian. On a globe each
|
|
182
|
+
* edge follows its great circle and stops at the horizon: a point or
|
|
183
|
+
* handle beyond it is left out, and a closed shape's fill is drawn only
|
|
184
|
+
* while all of its outline is in sight.
|
|
185
|
+
* Selection is shown by weight, handles and a filled vertex as well
|
|
186
|
+
* as colour. The layer never takes the pointer: the adapter owns the press
|
|
187
|
+
* on a handle, and this only draws where the handles are.
|
|
188
|
+
*/
|
|
189
|
+
function DrawOverlay({ shapes, selection, handles = [], hoveredHandle = null, hover, testId }) {
|
|
190
|
+
const placement = usePlacement();
|
|
191
|
+
if (!placement) return null;
|
|
192
|
+
const draft = shapes.find((shape) => !shape.done);
|
|
193
|
+
const ordered = [...shapes.filter((shape) => shape.id !== selection?.shapeId), ...shapes.filter((shape) => shape.id === selection?.shapeId)];
|
|
194
|
+
return /* @__PURE__ */ jsxs("g", {
|
|
195
|
+
"data-testid": testId,
|
|
196
|
+
children: [
|
|
197
|
+
ordered.map((shape) => /* @__PURE__ */ jsx(DrawnShape, {
|
|
198
|
+
shape,
|
|
199
|
+
selected: shape.id === selection?.shapeId,
|
|
200
|
+
placement
|
|
201
|
+
}, shape.id)),
|
|
202
|
+
draft && hover ? /* @__PURE__ */ jsx(Preview, {
|
|
203
|
+
draft,
|
|
204
|
+
hover,
|
|
205
|
+
placement
|
|
206
|
+
}) : null,
|
|
207
|
+
handles.map((handle) => {
|
|
208
|
+
const at = placePoint(handle.position, placement);
|
|
209
|
+
return at ? /* @__PURE__ */ jsx(Handle, {
|
|
210
|
+
handle,
|
|
211
|
+
at,
|
|
212
|
+
selected: selectedHandle(handle, selection),
|
|
213
|
+
hovered: handle.id === hoveredHandle
|
|
214
|
+
}, handle.id) : null;
|
|
215
|
+
})
|
|
216
|
+
]
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
export { DrawOverlay };
|
|
220
|
+
|
|
221
|
+
//# sourceMappingURL=DrawOverlay.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DrawOverlay.js","names":["_Fragment","styles.measureHalo","styles.drawDraft","styles.drawLineSelected","styles.drawLine","styles.drawPointSelected","styles.drawPoint","styles.drawFill","styles.measurePreview","styles.drawRadiusHandle","styles.drawMidpoint","styles.drawVertexSelected","styles.drawVertex"],"sources":["../../../src/host/overlays/DrawOverlay.tsx"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-only\n// Copyright MapCairn contributors\nimport {\n circleRing,\n type DrawSelection,\n type DrawShape,\n distanceMetres,\n type LatLng,\n type MapEditHandle,\n type MapPlacement,\n type PixelPoint,\n type PlacedPath,\n placePath,\n placePoint,\n shapeRing,\n visibleRuns,\n} from \"@mapcairn/core\";\nimport { roundPixel, toSvgPoints, usePlacement } from \"./geometry\";\nimport * as styles from \"./overlays.css\";\n\n/** Radius of a point shape's marker, in pixels. */\nconst DRAW_POINT_RADIUS_PX = 7;\n\n/** Radius of a vertex handle, in pixels. The press reaches further than this. */\nconst DRAW_VERTEX_RADIUS_PX = 7;\n\n/** Radius of the selected vertex's handle, in pixels, so it stands apart by size as well as fill. */\nconst DRAW_SELECTED_VERTEX_RADIUS_PX = 10;\n\n/** Radius of a midpoint handle, in pixels. */\nconst DRAW_MIDPOINT_RADIUS_PX = 4;\n\n/** Half the side of a circle's radius handle, in pixels. */\nconst DRAW_RADIUS_HANDLE_HALF_PX = 7;\n\n/** How many positions the preview ring of a circle being drawn has. */\nconst PREVIEW_RING_STEPS = 48;\n\n/** Props for {@link DrawOverlay}. */\nexport interface DrawOverlayProps {\n /** Every shape, finished or being drawn. */\n readonly shapes: readonly DrawShape[];\n /** The selected shape and vertex. */\n readonly selection: DrawSelection | null;\n /**\n * The handles to draw, normally those of the selected shape. Leave empty\n * while the tool is closed, so finished shapes show with no handles.\n */\n readonly handles?: readonly MapEditHandle[];\n /** The handle a mouse is over, drawn larger. */\n readonly hoveredHandle?: string | null;\n /** The position under the pointer, for the dashed preview of the next edge. */\n readonly hover?: LatLng;\n readonly testId?: string;\n}\n\n/** A line with a halo beneath it, open or closed. */\nfunction HaloPath({\n points,\n closed,\n className,\n}: {\n points: readonly PixelPoint[];\n closed: boolean;\n className: string;\n}) {\n const Shape = closed ? \"polygon\" : \"polyline\";\n const svgPoints = toSvgPoints(points);\n return (\n <>\n <Shape className={styles.measureHalo} points={svgPoints} />\n <Shape className={className} points={svgPoints} />\n </>\n );\n}\n\n/**\n * An outline: the whole closed path while all of it is in sight, otherwise\n * the runs of visible points, each as an open line.\n */\nfunction Outline({ path, className }: { path: PlacedPath; className: string }) {\n if (path.closed && path.whole) {\n return (\n <HaloPath points={path.pixels} closed={true} className={className} />\n );\n }\n return (\n <>\n {visibleRuns(path).map((run, index) => (\n <HaloPath\n // biome-ignore lint/suspicious/noArrayIndexKey: the order is the identity.\n key={index}\n points={run}\n closed={false}\n className={className}\n />\n ))}\n </>\n );\n}\n\nfunction shapeClass(shape: DrawShape, selected: boolean): string {\n if (!shape.done) {\n return styles.drawDraft;\n }\n return selected ? styles.drawLineSelected : styles.drawLine;\n}\n\ninterface DrawnShapeProps {\n readonly shape: DrawShape;\n readonly selected: boolean;\n readonly placement: MapPlacement;\n}\n\n/** One shape: its fill, outline and, for a point, its marker. */\nfunction DrawnShape({ shape, selected, placement }: DrawnShapeProps) {\n const className = shapeClass(shape, selected);\n const common = {\n \"data-testid\": \"draw-shape\",\n \"data-shape-id\": shape.id,\n \"data-kind\": shape.kind,\n \"data-selected\": selected ? \"true\" : \"false\",\n \"data-done\": shape.done ? \"true\" : \"false\",\n } as const;\n const first = shape.vertices[0];\n if (!first) {\n return null;\n }\n if (shape.kind === \"point\") {\n const at = placePoint(first, placement);\n if (!at) {\n return null;\n }\n return (\n <circle\n {...common}\n className={selected ? styles.drawPointSelected : styles.drawPoint}\n cx={roundPixel(at.x)}\n cy={roundPixel(at.y)}\n r={DRAW_POINT_RADIUS_PX}\n />\n );\n }\n if (shape.kind === \"line\") {\n return shape.vertices.length >= 2 ? (\n <g {...common}>\n <Outline\n path={placePath(shape.vertices, false, placement)}\n className={className}\n />\n </g>\n ) : null;\n }\n if (shape.kind === \"circle\") {\n const ring = placePath(shapeRing(shape), true, placement);\n return ring.pixels.length >= 3 ? (\n <g {...common}>\n {ring.whole ? (\n <polygon\n className={styles.drawFill}\n points={toSvgPoints(ring.pixels)}\n />\n ) : null}\n <Outline path={ring} className={className} />\n </g>\n ) : null;\n }\n if (shape.vertices.length < 3) {\n return shape.vertices.length === 2 ? (\n <g {...common}>\n <Outline\n path={placePath(shape.vertices, false, placement)}\n className={className}\n />\n </g>\n ) : null;\n }\n const path = placePath(shape.vertices, true, placement);\n return (\n <g {...common}>\n {path.whole ? (\n <polygon\n className={styles.drawFill}\n points={toSvgPoints(path.pixels)}\n />\n ) : null}\n <Outline path={path} className={className} />\n </g>\n );\n}\n\n/** The dashed edge from the last vertex of the shape being drawn to the pointer. */\nfunction Preview({\n draft,\n hover,\n placement,\n}: {\n draft: DrawShape;\n hover: LatLng;\n placement: MapPlacement;\n}) {\n const last = draft.vertices.at(-1);\n const first = draft.vertices[0];\n if (!last || !first) {\n return null;\n }\n if (draft.kind === \"circle\") {\n const radius = distanceMetres(first, hover);\n return radius > 0 ? (\n <Outline\n path={placePath(\n circleRing(first, radius, PREVIEW_RING_STEPS),\n true,\n placement,\n )}\n className={styles.measurePreview}\n />\n ) : null;\n }\n const path =\n draft.kind === \"polygon\" && draft.vertices.length >= 2\n ? [last, hover, first]\n : [last, hover];\n return (\n <Outline\n path={placePath(path, false, placement)}\n className={styles.measurePreview}\n />\n );\n}\n\ninterface HandleProps {\n readonly handle: MapEditHandle;\n readonly at: PixelPoint;\n readonly selected: boolean;\n readonly hovered: boolean;\n}\n\n/** One handle: a circle for a vertex, a small one for a midpoint and a square for a radius. */\nfunction Handle({ handle, at, selected, hovered }: HandleProps) {\n const common = {\n \"data-testid\": \"draw-handle\",\n \"data-handle-id\": handle.id,\n \"data-handle-kind\": handle.kind,\n \"data-selected\": selected ? \"true\" : \"false\",\n \"data-hovered\": hovered ? \"true\" : \"false\",\n } as const;\n const cx = roundPixel(at.x);\n const cy = roundPixel(at.y);\n if (handle.kind === \"radius\") {\n const half = DRAW_RADIUS_HANDLE_HALF_PX + (hovered ? 2 : 0);\n return (\n <rect\n {...common}\n className={styles.drawRadiusHandle}\n x={cx - half}\n y={cy - half}\n width={half * 2}\n height={half * 2}\n />\n );\n }\n if (handle.kind === \"midpoint\") {\n return (\n <circle\n {...common}\n className={styles.drawMidpoint}\n cx={cx}\n cy={cy}\n r={DRAW_MIDPOINT_RADIUS_PX + (hovered ? 2 : 0)}\n />\n );\n }\n const base = selected\n ? DRAW_SELECTED_VERTEX_RADIUS_PX\n : DRAW_VERTEX_RADIUS_PX;\n return (\n <circle\n {...common}\n className={selected ? styles.drawVertexSelected : styles.drawVertex}\n cx={cx}\n cy={cy}\n r={base + (hovered ? 2 : 0)}\n />\n );\n}\n\nfunction selectedHandle(\n handle: MapEditHandle,\n selection: DrawSelection | null,\n): boolean {\n return (\n selection !== null &&\n selection.vertex !== null &&\n handle.id === `${selection.shapeId}:v:${selection.vertex}`\n );\n}\n\n/**\n * The draw tool's drawing: every shape with its fill and outline, the\n * unfinished one dashed, the selected one drawn heavier, a dashed preview of\n * the next edge, and the handles of the selected shape. Render it inside\n * `MapOverlayLayer`.\n *\n * @remarks Edges go the short way across the antimeridian. On a globe each\n * edge follows its great circle and stops at the horizon: a point or\n * handle beyond it is left out, and a closed shape's fill is drawn only\n * while all of its outline is in sight.\n * Selection is shown by weight, handles and a filled vertex as well\n * as colour. The layer never takes the pointer: the adapter owns the press\n * on a handle, and this only draws where the handles are.\n */\nexport function DrawOverlay({\n shapes,\n selection,\n handles = [],\n hoveredHandle = null,\n hover,\n testId,\n}: DrawOverlayProps) {\n const placement = usePlacement();\n if (!placement) {\n return null;\n }\n const draft = shapes.find((shape) => !shape.done);\n const ordered = [\n ...shapes.filter((shape) => shape.id !== selection?.shapeId),\n ...shapes.filter((shape) => shape.id === selection?.shapeId),\n ];\n\n return (\n <g data-testid={testId}>\n {ordered.map((shape) => (\n <DrawnShape\n key={shape.id}\n shape={shape}\n selected={shape.id === selection?.shapeId}\n placement={placement}\n />\n ))}\n {draft && hover ? (\n <Preview draft={draft} hover={hover} placement={placement} />\n ) : null}\n {handles.map((handle) => {\n const at = placePoint(handle.position, placement);\n return at ? (\n <Handle\n key={handle.id}\n handle={handle}\n at={at}\n selected={selectedHandle(handle, selection)}\n hovered={handle.id === hoveredHandle}\n />\n ) : null;\n })}\n </g>\n );\n}\n"],"mappings":";;;;;;AAqBA,IAAM,uBAAuB;;AAG7B,IAAM,wBAAwB;;AAG9B,IAAM,iCAAiC;;AAGvC,IAAM,0BAA0B;;AAGhC,IAAM,6BAA6B;;AAGnC,IAAM,qBAAqB;;AAqB3B,SAAS,SAAS,EAChB,QACA,QACA,aAKC;CACD,MAAM,QAAQ,SAAS,YAAY;CACnC,MAAM,YAAY,YAAY,MAAM;CACpC,OACE,qBAAAA,UAAA,EAAA,UAAA,CACE,oBAAC,OAAD;EAAO,WAAWC;EAAoB,QAAQ;CAAY,CAAA,GAC1D,oBAAC,OAAD;EAAkB;EAAW,QAAQ;CAAY,CAAA,CACjD,EAAA,CAAA;AAEN;;;;;AAMA,SAAS,QAAQ,EAAE,MAAM,aAAsD;CAC7E,IAAI,KAAK,UAAU,KAAK,OACtB,OACE,oBAAC,UAAD;EAAU,QAAQ,KAAK;EAAQ,QAAQ;EAAiB;CAAY,CAAA;CAGxE,OACE,oBAAAD,UAAA,EAAA,UACG,YAAY,IAAI,CAAC,CAAC,KAAK,KAAK,UAC3B,oBAAC,UAAD;EAGE,QAA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,QAAD;KAEU;KACJ;KACJ,UAAU,eAAe,QAAQ,SAAS;KAC1C,SAAS,OAAO,OAAO;IACxB,GALM,OAAO,EAKb,IACC;GACN,CAAC;EACA;;AAEP"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { canvas, layer } from "./overlays.styles.js";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
// src/host/overlays/MapOverlayLayer.tsx
|
|
4
|
+
/**
|
|
5
|
+
* The single layer every map overlay draws into: one SVG spanning the map
|
|
6
|
+
* host, above the engine and below the chrome. Place it inside `MapView`.
|
|
7
|
+
*
|
|
8
|
+
* @remarks It is hidden from assistive technology and never takes pointer
|
|
9
|
+
* events. Overlays are pictures of state that the interface also gives in
|
|
10
|
+
* text (the pin's coordinates, the measured distance, the location accuracy).
|
|
11
|
+
*/
|
|
12
|
+
function MapOverlayLayer({ children, testId }) {
|
|
13
|
+
return /* @__PURE__ */ jsx("div", {
|
|
14
|
+
className: layer,
|
|
15
|
+
"aria-hidden": "true",
|
|
16
|
+
"data-testid": testId,
|
|
17
|
+
children: /* @__PURE__ */ jsx("svg", {
|
|
18
|
+
className: canvas,
|
|
19
|
+
"aria-hidden": "true",
|
|
20
|
+
focusable: "false",
|
|
21
|
+
children
|
|
22
|
+
})
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
export { MapOverlayLayer };
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=MapOverlayLayer.js.map
|