@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
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/* empty css */
|
|
2
|
+
// src/tools/Directions/Directions.css.ts
|
|
3
|
+
var stopDisc = "xjsg0i0";
|
|
4
|
+
var stopLetter = "xjsg0i1";
|
|
5
|
+
var panel = "xjsg0i2";
|
|
6
|
+
var group = "xjsg0i3";
|
|
7
|
+
var groupHeading = "xjsg0i4";
|
|
8
|
+
var hint = "xjsg0i5";
|
|
9
|
+
var stopList = "xjsg0i6";
|
|
10
|
+
var stopRow = "xjsg0i7";
|
|
11
|
+
var badge = "xjsg0i8";
|
|
12
|
+
var stopName = "xjsg0i9";
|
|
13
|
+
var stopActions = "xjsg0ia";
|
|
14
|
+
var actions = "xjsg0ib";
|
|
15
|
+
var searchRow = "xjsg0ic";
|
|
16
|
+
var searchInput = "xjsg0id";
|
|
17
|
+
var resultList = "xjsg0ie";
|
|
18
|
+
var result = "xjsg0if";
|
|
19
|
+
var figures = "xjsg0ig";
|
|
20
|
+
var legList = "xjsg0ih";
|
|
21
|
+
var statusLine = "xjsg0ii";
|
|
22
|
+
var errorIcon = "xjsg0ij";
|
|
23
|
+
export { actions, badge, errorIcon, figures, group, groupHeading, hint, legList, panel, result, resultList, searchInput, searchRow, statusLine, stopActions, stopDisc, stopLetter, stopList, stopName, stopRow };
|
|
24
|
+
|
|
25
|
+
//# sourceMappingURL=Directions.styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Directions.styles.js","names":[],"sources":[],"mappings":""}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { CentreCrosshair } from "../../host/overlays/CentreCrosshair.js";
|
|
2
|
+
import { roundPixel, usePlacement } from "../../host/overlays/geometry.js";
|
|
3
|
+
import { stopDisc, stopLetter as stopLetter$1 } from "./Directions.styles.js";
|
|
4
|
+
import { useFreeCentre } from "./useFreeCentre.js";
|
|
5
|
+
import { placePoint, stopLetter } from "@mapcairn/core";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
// src/tools/Directions/DirectionsOverlay.tsx
|
|
8
|
+
/** Radius of a stop's disc, in pixels. */
|
|
9
|
+
var STOP_DISC_RADIUS_PX = 12;
|
|
10
|
+
/**
|
|
11
|
+
* The stops of a set of directions, drawn as lettered discs, and the crosshair
|
|
12
|
+
* that shows where the next stop goes when it is added at the map centre.
|
|
13
|
+
* Render it inside `MapOverlayLayer`. Like every overlay it is a picture of
|
|
14
|
+
* state the panel gives in words, and the letters mean it never depends on
|
|
15
|
+
* colour.
|
|
16
|
+
*/
|
|
17
|
+
function DirectionsOverlay({ stops, showCrosshair, testId }) {
|
|
18
|
+
const placement = usePlacement();
|
|
19
|
+
const { pixel } = useFreeCentre();
|
|
20
|
+
if (!placement) return null;
|
|
21
|
+
return /* @__PURE__ */ jsxs("g", {
|
|
22
|
+
"data-testid": testId,
|
|
23
|
+
children: [stops.map((stop, index) => {
|
|
24
|
+
const at = placePoint(stop.position, placement);
|
|
25
|
+
if (!at) return null;
|
|
26
|
+
const { x, y } = at;
|
|
27
|
+
return /* @__PURE__ */ jsxs("g", {
|
|
28
|
+
transform: `translate(${roundPixel(x)} ${roundPixel(y)})`,
|
|
29
|
+
"data-testid": "directions-stop",
|
|
30
|
+
children: [/* @__PURE__ */ jsx("circle", {
|
|
31
|
+
className: stopDisc,
|
|
32
|
+
r: STOP_DISC_RADIUS_PX
|
|
33
|
+
}), /* @__PURE__ */ jsx("text", {
|
|
34
|
+
className: stopLetter$1,
|
|
35
|
+
children: stopLetter(index)
|
|
36
|
+
})]
|
|
37
|
+
}, stop.id);
|
|
38
|
+
}), showCrosshair && pixel ? /* @__PURE__ */ jsx(CentreCrosshair, {
|
|
39
|
+
at: pixel,
|
|
40
|
+
testId: "directions-crosshair"
|
|
41
|
+
}) : null]
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
export { DirectionsOverlay };
|
|
45
|
+
|
|
46
|
+
//# sourceMappingURL=DirectionsOverlay.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DirectionsOverlay.js","names":["styles.stopDisc","styles.stopLetter"],"sources":["../../../src/tools/Directions/DirectionsOverlay.tsx"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-only\n// Copyright MapCairn contributors\nimport { type DirectionStop, placePoint, stopLetter } from \"@mapcairn/core\";\nimport { CentreCrosshair } from \"../../host/overlays/CentreCrosshair\";\nimport { roundPixel, usePlacement } from \"../../host/overlays/geometry\";\nimport * as styles from \"./Directions.css\";\nimport { useFreeCentre } from \"./useFreeCentre\";\n\n/** Radius of a stop's disc, in pixels. */\nconst STOP_DISC_RADIUS_PX = 12;\n\n/** Props for {@link DirectionsOverlay}. */\nexport interface DirectionsOverlayProps {\n /** The stops, in order. Each is drawn as a lettered disc. */\n readonly stops: readonly DirectionStop[];\n /**\n * Draws a crosshair where \"Add stop at map centre\" will put a stop, which\n * is the middle of the part of the map the panel leaves free.\n */\n readonly showCrosshair: boolean;\n readonly testId?: string;\n}\n\n/**\n * The stops of a set of directions, drawn as lettered discs, and the crosshair\n * that shows where the next stop goes when it is added at the map centre.\n * Render it inside `MapOverlayLayer`. Like every overlay it is a picture of\n * state the panel gives in words, and the letters mean it never depends on\n * colour.\n */\nexport function DirectionsOverlay({\n stops,\n showCrosshair,\n testId,\n}: DirectionsOverlayProps) {\n const placement = usePlacement();\n const { pixel } = useFreeCentre();\n if (!placement) {\n return null;\n }\n return (\n <g data-testid={testId}>\n {stops.map((stop, index) => {\n const at = placePoint(stop.position, placement);\n if (!at) {\n return null;\n }\n const { x, y } = at;\n return (\n <g\n key={stop.id}\n transform={`translate(${roundPixel(x)} ${roundPixel(y)})`}\n data-testid=\"directions-stop\"\n >\n <circle className={styles.stopDisc} r={STOP_DISC_RADIUS_PX} />\n <text className={styles.stopLetter}>{stopLetter(index)}</text>\n </g>\n );\n })}\n {showCrosshair && pixel ? (\n <CentreCrosshair at={pixel} testId=\"directions-crosshair\" />\n ) : null}\n </g>\n );\n}\n"],"mappings":";;;;;;;;AASA,IAAM,sBAAsB;;;;;;;;AAqB5B,SAAgB,kBAAkB,EAChC,OACA,eACA,UACyB;CACzB,MAAM,YAAY,aAAa;CAC/B,MAAM,EAAE,UAAU,cAAc;CAChC,IAAI,CAAC,WACH,OAAO;CAET,OACE,qBAAC,KAAD;EAAG,eAAa;EAAhB,UAAA,CACG,MAAM,KAAK,MAAM,UAAU;GAC1B,MAAM,KAAK,WAAW,KAAK,UAAU,SAAS;GAC9C,IAAI,CAAC,IACH,OAAO;GAET,MAAM,EAAE,GAAG,MAAM;GACjB,OACE,qBAAC,KAAD;IAEE,WAAW,aAAa,WAAW,CAAC,EAAE,GAAG,WAAW,CAAC,EAAE;IACvD,eAAY;IAHd,UAAA,CAKE,oBAAC,UAAD;KAAQ,WAAWA;KAAiB,GAAG;IAAsB,CAAA,GAC7D,oBAAC,QAAD;KAAM,WAAWC;KAAoB,UAAA,WAAW,KAAK;IAAQ,CAAA,CAC5D;GANI,GAAA,KAAK,EAMT;EAEP,CAAC,GACA,iBAAiB,QAChB,oBAAC,iBAAD;GAAiB,IAAI;GAAO,QAAO;EAAwB,CAAA,IACzD,IACH;;AAEP"}
|
|
@@ -0,0 +1,428 @@
|
|
|
1
|
+
import { useFormatMessage, useMessages, usePreferences, useSettings } from "../../services/hooks.js";
|
|
2
|
+
import { Button } from "../../ui/Button/Button.js";
|
|
3
|
+
import { Icon } from "../../ui/Icon/Icon.js";
|
|
4
|
+
import { IconButton } from "../../ui/IconButton/IconButton.js";
|
|
5
|
+
import { fillSlots } from "../../ui/Isolate/fillSlots.js";
|
|
6
|
+
import { Isolate } from "../../ui/Isolate/Isolate.js";
|
|
7
|
+
import { SegmentedControl } from "../../ui/SegmentedControl/SegmentedControl.js";
|
|
8
|
+
import { VisuallyHidden } from "../../ui/VisuallyHidden/VisuallyHidden.js";
|
|
9
|
+
import { useSearch } from "../SearchPill/useSearch.js";
|
|
10
|
+
import { actions, badge, errorIcon, figures, group, groupHeading, hint, legList, panel, result, resultList, searchInput, searchRow, statusLine, stopActions, stopList, stopName, stopRow } from "./Directions.styles.js";
|
|
11
|
+
import { useFreeCentre } from "./useFreeCentre.js";
|
|
12
|
+
import { AREA_MINUTES, MAX_DIRECTION_STOPS, TRAVEL_MODES, formatArea, formatDistance, formatDuration, formatLatLng, message, routingErrorMessage, stopLetter, travelModeLabel, travelModeParticiple } from "@mapcairn/core";
|
|
13
|
+
import { Bike, Car, ChevronDown, ChevronUp, Crosshair, Footprints, MapPin, Route, Search, Trash2, TriangleAlert, X } from "lucide-react";
|
|
14
|
+
import { useEffect, useRef } from "react";
|
|
15
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
16
|
+
// src/tools/Directions/DirectionsPanel.tsx
|
|
17
|
+
var MODE_ICONS = {
|
|
18
|
+
drive: Car,
|
|
19
|
+
walk: Footprints,
|
|
20
|
+
cycle: Bike
|
|
21
|
+
};
|
|
22
|
+
function ResultCard({ result: result$1, units }) {
|
|
23
|
+
const messages = useMessages();
|
|
24
|
+
const { t } = messages;
|
|
25
|
+
const format = useFormatMessage();
|
|
26
|
+
const how = travelModeParticiple(result$1.mode);
|
|
27
|
+
if (result$1.kind === "area") return /* @__PURE__ */ jsxs("div", {
|
|
28
|
+
className: result,
|
|
29
|
+
"data-testid": "directions-result",
|
|
30
|
+
children: [/* @__PURE__ */ jsx("p", {
|
|
31
|
+
className: figures,
|
|
32
|
+
"data-testid": "directions-figures",
|
|
33
|
+
children: fillSlots(t("common.followedBy", {
|
|
34
|
+
first: "{minutes}",
|
|
35
|
+
second: format(how)
|
|
36
|
+
}), { minutes: /* @__PURE__ */ jsx(Isolate, { children: format(message("duration.short.minute", { count: result$1.minutes })) }) })
|
|
37
|
+
}), /* @__PURE__ */ jsx("p", { children: fillSlots(t("tools.directions.reachesArea", { area: "{area}" }), { area: /* @__PURE__ */ jsx("span", {
|
|
38
|
+
"data-testid": "directions-area",
|
|
39
|
+
children: /* @__PURE__ */ jsx(Isolate, { children: formatArea(result$1.size, units, messages) })
|
|
40
|
+
}) }) })]
|
|
41
|
+
});
|
|
42
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
43
|
+
className: result,
|
|
44
|
+
"data-testid": "directions-result",
|
|
45
|
+
children: [
|
|
46
|
+
/* @__PURE__ */ jsx("p", {
|
|
47
|
+
className: figures,
|
|
48
|
+
"data-testid": "directions-figures",
|
|
49
|
+
children: fillSlots(t("common.commaJoined", {
|
|
50
|
+
first: "{distance}",
|
|
51
|
+
second: "{duration}"
|
|
52
|
+
}), {
|
|
53
|
+
distance: /* @__PURE__ */ jsx(Isolate, { children: formatDistance(result$1.distance, units, messages) }),
|
|
54
|
+
duration: /* @__PURE__ */ jsx(Isolate, { children: format(formatDuration(result$1.duration)) })
|
|
55
|
+
})
|
|
56
|
+
}),
|
|
57
|
+
/* @__PURE__ */ jsx("p", {
|
|
58
|
+
className: hint,
|
|
59
|
+
children: messages.plural("tools.directions.routeSummary", {
|
|
60
|
+
mode: format(travelModeLabel(result$1.mode)),
|
|
61
|
+
how: format(how),
|
|
62
|
+
count: result$1.stops.length
|
|
63
|
+
})
|
|
64
|
+
}),
|
|
65
|
+
result$1.legs.length > 1 ? /* @__PURE__ */ jsx("ol", {
|
|
66
|
+
className: legList,
|
|
67
|
+
"aria-label": t("tools.directions.legs", {}),
|
|
68
|
+
children: result$1.legs.map((leg, index) => /* @__PURE__ */ jsx("li", {
|
|
69
|
+
"data-testid": "directions-leg",
|
|
70
|
+
children: fillSlots(t("tools.directions.leg", {
|
|
71
|
+
from: stopLetter(index),
|
|
72
|
+
to: stopLetter(index + 1),
|
|
73
|
+
distance: "{distance}",
|
|
74
|
+
duration: "{duration}"
|
|
75
|
+
}), {
|
|
76
|
+
distance: /* @__PURE__ */ jsx(Isolate, { children: formatDistance(leg.properties.distance, units, messages) }),
|
|
77
|
+
duration: /* @__PURE__ */ jsx(Isolate, { children: format(formatDuration(leg.properties.duration)) })
|
|
78
|
+
})
|
|
79
|
+
}, index))
|
|
80
|
+
}) : null
|
|
81
|
+
]
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* The directions tool's panel, for the sheet or side panel: the stops (added
|
|
86
|
+
* by tapping the map, at the map centre, from a place search or from the
|
|
87
|
+
* dropped pin, and reordered or removed with buttons), the way of travelling,
|
|
88
|
+
* "Get route", the travel time areas and the result.
|
|
89
|
+
*
|
|
90
|
+
* @remarks Every action a pointer can do has a button: adding a stop at the
|
|
91
|
+
* map centre stands in for a tap on the map, and Move up, Move down and
|
|
92
|
+
* Remove stand in for any drag. "Add stop at map centre" uses the middle of
|
|
93
|
+
* the part of the map the panel leaves free, which is where the crosshair is
|
|
94
|
+
* drawn. Results and failures are announced by `useDirections`, so the
|
|
95
|
+
* panel's own text carries no live region. A request is sent only when a
|
|
96
|
+
* button asks for it, and the note under them says what goes where.
|
|
97
|
+
*/
|
|
98
|
+
function DirectionsPanel({ directions, pin, getBias, note, headingLevel = 3 }) {
|
|
99
|
+
const { settings } = useSettings();
|
|
100
|
+
const format = useFormatMessage();
|
|
101
|
+
const messages = useMessages();
|
|
102
|
+
const { t } = messages;
|
|
103
|
+
const { reducedMotion } = usePreferences();
|
|
104
|
+
const search = useSearch({ getBias });
|
|
105
|
+
const centre = useFreeCentre();
|
|
106
|
+
const stopsHeading = useRef(null);
|
|
107
|
+
const resultRef = useRef(null);
|
|
108
|
+
const Heading = `h${headingLevel}`;
|
|
109
|
+
const { state, stops, mode } = directions;
|
|
110
|
+
const busy = state.status === "loading";
|
|
111
|
+
const full = !directions.canAddStop;
|
|
112
|
+
const needsTwo = stops.length < 2;
|
|
113
|
+
const shown = state.status === "done" || state.status === "error";
|
|
114
|
+
useEffect(() => {
|
|
115
|
+
if (shown) resultRef.current?.scrollIntoView?.({
|
|
116
|
+
block: "nearest",
|
|
117
|
+
behavior: reducedMotion ? "auto" : "smooth"
|
|
118
|
+
});
|
|
119
|
+
}, [shown, reducedMotion]);
|
|
120
|
+
const addAtCentre = () => {
|
|
121
|
+
const position = centre.position();
|
|
122
|
+
if (position) directions.addStop(position);
|
|
123
|
+
};
|
|
124
|
+
const submitSearch = (event) => {
|
|
125
|
+
event.preventDefault();
|
|
126
|
+
search.submit();
|
|
127
|
+
};
|
|
128
|
+
const remove = (id) => {
|
|
129
|
+
directions.removeStop(id);
|
|
130
|
+
stopsHeading.current?.focus();
|
|
131
|
+
};
|
|
132
|
+
const results = search.state.status === "results" ? search.state.results : [];
|
|
133
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
134
|
+
className: panel,
|
|
135
|
+
"data-testid": "directions-panel",
|
|
136
|
+
children: [
|
|
137
|
+
/* @__PURE__ */ jsxs("section", {
|
|
138
|
+
className: group,
|
|
139
|
+
"aria-labelledby": "directions-stops",
|
|
140
|
+
children: [
|
|
141
|
+
/* @__PURE__ */ jsx(Heading, {
|
|
142
|
+
id: "directions-stops",
|
|
143
|
+
ref: stopsHeading,
|
|
144
|
+
tabIndex: -1,
|
|
145
|
+
className: groupHeading,
|
|
146
|
+
children: t("tools.directions.stops", {})
|
|
147
|
+
}),
|
|
148
|
+
/* @__PURE__ */ jsx("p", {
|
|
149
|
+
className: hint,
|
|
150
|
+
children: t("tools.directions.stopsHint", {})
|
|
151
|
+
}),
|
|
152
|
+
stops.length > 0 ? /* @__PURE__ */ jsx("ol", {
|
|
153
|
+
className: stopList,
|
|
154
|
+
"data-testid": "directions-stops",
|
|
155
|
+
children: stops.map((stop, index) => {
|
|
156
|
+
const letter = stopLetter(index);
|
|
157
|
+
return /* @__PURE__ */ jsxs("li", {
|
|
158
|
+
className: stopRow,
|
|
159
|
+
"data-testid": "directions-stop-row",
|
|
160
|
+
children: [
|
|
161
|
+
/* @__PURE__ */ jsx("span", {
|
|
162
|
+
className: badge,
|
|
163
|
+
"aria-hidden": "true",
|
|
164
|
+
children: letter
|
|
165
|
+
}),
|
|
166
|
+
/* @__PURE__ */ jsxs("span", {
|
|
167
|
+
className: stopName,
|
|
168
|
+
children: [/* @__PURE__ */ jsxs(VisuallyHidden, { children: [t("tools.directions.stopPrefix", { letter }), " "] }), stop.label === void 0 ? /* @__PURE__ */ jsx(Isolate, {
|
|
169
|
+
figure: true,
|
|
170
|
+
children: formatLatLng(stop.position)
|
|
171
|
+
}) : /* @__PURE__ */ jsx(Isolate, { children: stop.label })]
|
|
172
|
+
}),
|
|
173
|
+
/* @__PURE__ */ jsxs("span", {
|
|
174
|
+
className: stopActions,
|
|
175
|
+
children: [
|
|
176
|
+
/* @__PURE__ */ jsx(IconButton, {
|
|
177
|
+
label: t("tools.directions.moveUp", { letter }),
|
|
178
|
+
icon: ChevronUp,
|
|
179
|
+
size: "compact",
|
|
180
|
+
disabled: index === 0,
|
|
181
|
+
onClick: () => directions.moveStop(stop.id, -1)
|
|
182
|
+
}),
|
|
183
|
+
/* @__PURE__ */ jsx(IconButton, {
|
|
184
|
+
label: t("tools.directions.moveDown", { letter }),
|
|
185
|
+
icon: ChevronDown,
|
|
186
|
+
size: "compact",
|
|
187
|
+
disabled: index === stops.length - 1,
|
|
188
|
+
onClick: () => directions.moveStop(stop.id, 1)
|
|
189
|
+
}),
|
|
190
|
+
/* @__PURE__ */ jsx(IconButton, {
|
|
191
|
+
label: t("tools.directions.remove", { letter }),
|
|
192
|
+
icon: X,
|
|
193
|
+
size: "compact",
|
|
194
|
+
"data-testid": "directions-remove",
|
|
195
|
+
onClick: () => remove(stop.id)
|
|
196
|
+
})
|
|
197
|
+
]
|
|
198
|
+
})
|
|
199
|
+
]
|
|
200
|
+
}, stop.id);
|
|
201
|
+
})
|
|
202
|
+
}) : null,
|
|
203
|
+
/* @__PURE__ */ jsxs("div", {
|
|
204
|
+
className: actions,
|
|
205
|
+
children: [/* @__PURE__ */ jsx(Button, {
|
|
206
|
+
variant: "secondary",
|
|
207
|
+
icon: Crosshair,
|
|
208
|
+
disabled: full,
|
|
209
|
+
"data-testid": "directions-add-centre",
|
|
210
|
+
onClick: addAtCentre,
|
|
211
|
+
children: t("tools.directions.addAtCentre", {})
|
|
212
|
+
}), pin ? /* @__PURE__ */ jsx(Button, {
|
|
213
|
+
variant: "secondary",
|
|
214
|
+
icon: MapPin,
|
|
215
|
+
disabled: full,
|
|
216
|
+
"data-testid": "directions-add-pin",
|
|
217
|
+
onClick: () => directions.addStop(pin, t("tools.directions.droppedPin", {})),
|
|
218
|
+
children: t("tools.directions.addPin", {})
|
|
219
|
+
}) : null]
|
|
220
|
+
}),
|
|
221
|
+
full ? /* @__PURE__ */ jsx("p", {
|
|
222
|
+
className: hint,
|
|
223
|
+
children: t("tools.directions.full", { max: MAX_DIRECTION_STOPS })
|
|
224
|
+
}) : null
|
|
225
|
+
]
|
|
226
|
+
}),
|
|
227
|
+
/* @__PURE__ */ jsxs("section", {
|
|
228
|
+
className: group,
|
|
229
|
+
"aria-labelledby": "directions-route",
|
|
230
|
+
children: [
|
|
231
|
+
/* @__PURE__ */ jsx(VisuallyHidden, {
|
|
232
|
+
as: Heading,
|
|
233
|
+
id: "directions-route",
|
|
234
|
+
children: t("tools.directions.route", {})
|
|
235
|
+
}),
|
|
236
|
+
/* @__PURE__ */ jsx(SegmentedControl, {
|
|
237
|
+
label: t("tools.directions.travelMode", {}),
|
|
238
|
+
options: TRAVEL_MODES.map((value) => ({
|
|
239
|
+
value,
|
|
240
|
+
label: format(travelModeLabel(value)),
|
|
241
|
+
icon: /* @__PURE__ */ jsx(Icon, { icon: MODE_ICONS[value] })
|
|
242
|
+
})),
|
|
243
|
+
value: mode,
|
|
244
|
+
onValueChange: (next) => directions.setMode(next),
|
|
245
|
+
"data-testid": "directions-mode"
|
|
246
|
+
}),
|
|
247
|
+
/* @__PURE__ */ jsxs("div", {
|
|
248
|
+
className: actions,
|
|
249
|
+
children: [/* @__PURE__ */ jsx(Button, {
|
|
250
|
+
icon: Route,
|
|
251
|
+
disabled: needsTwo,
|
|
252
|
+
busy: state.status === "loading" && state.request === "route",
|
|
253
|
+
"data-testid": "directions-get-route",
|
|
254
|
+
onClick: directions.requestRoute,
|
|
255
|
+
children: t("tools.directions.getRoute", {})
|
|
256
|
+
}), busy ? /* @__PURE__ */ jsx(Button, {
|
|
257
|
+
variant: "quiet",
|
|
258
|
+
"data-testid": "directions-cancel",
|
|
259
|
+
onClick: directions.cancel,
|
|
260
|
+
children: t("tools.directions.cancel", {})
|
|
261
|
+
}) : null]
|
|
262
|
+
}),
|
|
263
|
+
needsTwo ? /* @__PURE__ */ jsx("p", {
|
|
264
|
+
className: hint,
|
|
265
|
+
children: t("tools.directions.needTwo", {})
|
|
266
|
+
}) : null
|
|
267
|
+
]
|
|
268
|
+
}),
|
|
269
|
+
/* @__PURE__ */ jsxs("section", {
|
|
270
|
+
className: group,
|
|
271
|
+
"aria-labelledby": "directions-search",
|
|
272
|
+
children: [/* @__PURE__ */ jsx(Heading, {
|
|
273
|
+
id: "directions-search",
|
|
274
|
+
className: groupHeading,
|
|
275
|
+
children: t("tools.directions.searchHeading", {})
|
|
276
|
+
}), /* @__PURE__ */ jsxs("form", {
|
|
277
|
+
"aria-label": t("tools.directions.searchForm", {}),
|
|
278
|
+
className: group,
|
|
279
|
+
onSubmit: submitSearch,
|
|
280
|
+
children: [
|
|
281
|
+
/* @__PURE__ */ jsxs("div", {
|
|
282
|
+
className: searchRow,
|
|
283
|
+
children: [/* @__PURE__ */ jsx("input", {
|
|
284
|
+
className: searchInput,
|
|
285
|
+
type: "text",
|
|
286
|
+
"aria-label": t("tools.directions.searchInput", {}),
|
|
287
|
+
placeholder: t("tools.directions.searchPlaceholder", {}),
|
|
288
|
+
autoComplete: "off",
|
|
289
|
+
autoCapitalize: "off",
|
|
290
|
+
spellCheck: false,
|
|
291
|
+
enterKeyHint: "search",
|
|
292
|
+
value: search.query,
|
|
293
|
+
"data-testid": "directions-search-input",
|
|
294
|
+
onChange: (event) => search.setQuery(event.target.value)
|
|
295
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
296
|
+
variant: "secondary",
|
|
297
|
+
type: "submit",
|
|
298
|
+
icon: Search,
|
|
299
|
+
disabled: search.query.trim().length < 2 || full,
|
|
300
|
+
busy: search.state.status === "loading",
|
|
301
|
+
"data-testid": "directions-search-submit",
|
|
302
|
+
children: t("tools.search.label", {})
|
|
303
|
+
})]
|
|
304
|
+
}),
|
|
305
|
+
search.state.status === "empty" ? /* @__PURE__ */ jsx("p", {
|
|
306
|
+
className: hint,
|
|
307
|
+
children: t("tools.search.nothingMatched", {})
|
|
308
|
+
}) : null,
|
|
309
|
+
search.state.status === "error" ? /* @__PURE__ */ jsxs("p", {
|
|
310
|
+
className: statusLine,
|
|
311
|
+
children: [
|
|
312
|
+
/* @__PURE__ */ jsx(Icon, {
|
|
313
|
+
icon: TriangleAlert,
|
|
314
|
+
className: errorIcon
|
|
315
|
+
}),
|
|
316
|
+
/* @__PURE__ */ jsx("span", { children: t("tools.search.unavailable", {}) }),
|
|
317
|
+
/* @__PURE__ */ jsx(Button, {
|
|
318
|
+
variant: "quiet",
|
|
319
|
+
onClick: search.retry,
|
|
320
|
+
children: t("tools.search.retry", {})
|
|
321
|
+
})
|
|
322
|
+
]
|
|
323
|
+
}) : null,
|
|
324
|
+
results.length > 0 ? /* @__PURE__ */ jsx("ul", {
|
|
325
|
+
className: resultList,
|
|
326
|
+
"aria-label": t("tools.directions.placesFound", {}),
|
|
327
|
+
"data-testid": "directions-search-results",
|
|
328
|
+
children: results.map((place) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx(Button, {
|
|
329
|
+
variant: "quiet",
|
|
330
|
+
"data-testid": "directions-search-result",
|
|
331
|
+
disabled: full,
|
|
332
|
+
onClick: () => {
|
|
333
|
+
directions.addStop(place.centre, place.label);
|
|
334
|
+
search.clear();
|
|
335
|
+
},
|
|
336
|
+
children: t("tools.directions.addPlace", { place: place.secondaryLabel ? t("common.commaJoined", {
|
|
337
|
+
first: place.label,
|
|
338
|
+
second: place.secondaryLabel
|
|
339
|
+
}) : place.label })
|
|
340
|
+
}) }, place.id))
|
|
341
|
+
}) : null
|
|
342
|
+
]
|
|
343
|
+
})]
|
|
344
|
+
}),
|
|
345
|
+
/* @__PURE__ */ jsxs("section", {
|
|
346
|
+
className: group,
|
|
347
|
+
"aria-labelledby": "directions-area",
|
|
348
|
+
children: [
|
|
349
|
+
/* @__PURE__ */ jsx(Heading, {
|
|
350
|
+
id: "directions-area",
|
|
351
|
+
className: groupHeading,
|
|
352
|
+
children: t("tools.directions.areaHeading", {})
|
|
353
|
+
}),
|
|
354
|
+
/* @__PURE__ */ jsx("p", {
|
|
355
|
+
className: hint,
|
|
356
|
+
children: t("tools.directions.areaHint", {})
|
|
357
|
+
}),
|
|
358
|
+
/* @__PURE__ */ jsx("div", {
|
|
359
|
+
className: actions,
|
|
360
|
+
"data-testid": "directions-area-actions",
|
|
361
|
+
children: AREA_MINUTES.map((minutes) => /* @__PURE__ */ jsx(Button, {
|
|
362
|
+
variant: "secondary",
|
|
363
|
+
disabled: stops.length < 1,
|
|
364
|
+
busy: state.status === "loading" && state.request === "area" && state.minutes === minutes,
|
|
365
|
+
"aria-pressed": directions.result?.kind === "area" && directions.result.minutes === minutes,
|
|
366
|
+
"aria-label": messages.plural("tools.directions.showArea", { count: minutes }),
|
|
367
|
+
"data-testid": `directions-area-${minutes}`,
|
|
368
|
+
onClick: () => directions.requestArea(minutes),
|
|
369
|
+
children: messages.plural("duration.short.minute", { count: minutes })
|
|
370
|
+
}, minutes))
|
|
371
|
+
}),
|
|
372
|
+
/* @__PURE__ */ jsx("p", {
|
|
373
|
+
className: hint,
|
|
374
|
+
"data-testid": "directions-note",
|
|
375
|
+
children: note ?? t("tools.directions.note", {})
|
|
376
|
+
})
|
|
377
|
+
]
|
|
378
|
+
}),
|
|
379
|
+
/* @__PURE__ */ jsxs("div", {
|
|
380
|
+
ref: resultRef,
|
|
381
|
+
"data-testid": "directions-status",
|
|
382
|
+
children: [
|
|
383
|
+
state.status === "loading" ? /* @__PURE__ */ jsx("p", {
|
|
384
|
+
className: hint,
|
|
385
|
+
"data-testid": "directions-loading",
|
|
386
|
+
children: state.request === "route" ? t("tools.directions.findingRoute", {}) : t("tools.directions.findingArea", {})
|
|
387
|
+
}) : null,
|
|
388
|
+
state.status === "error" ? /* @__PURE__ */ jsxs("div", {
|
|
389
|
+
className: group,
|
|
390
|
+
"data-testid": "directions-error",
|
|
391
|
+
children: [/* @__PURE__ */ jsxs("p", {
|
|
392
|
+
className: statusLine,
|
|
393
|
+
children: [/* @__PURE__ */ jsx(Icon, {
|
|
394
|
+
icon: TriangleAlert,
|
|
395
|
+
className: errorIcon
|
|
396
|
+
}), /* @__PURE__ */ jsx("span", { children: format(routingErrorMessage(state.kind, state.request)) })]
|
|
397
|
+
}), state.kind === "network" || state.kind === "rate-limited" ? /* @__PURE__ */ jsx("div", {
|
|
398
|
+
className: actions,
|
|
399
|
+
children: /* @__PURE__ */ jsx(Button, {
|
|
400
|
+
variant: "secondary",
|
|
401
|
+
"data-testid": "directions-retry",
|
|
402
|
+
onClick: directions.retry,
|
|
403
|
+
children: t("tools.tryAgain", {})
|
|
404
|
+
})
|
|
405
|
+
}) : null]
|
|
406
|
+
}) : null,
|
|
407
|
+
state.status === "done" ? /* @__PURE__ */ jsx(ResultCard, {
|
|
408
|
+
result: state.result,
|
|
409
|
+
units: settings.units
|
|
410
|
+
}) : null
|
|
411
|
+
]
|
|
412
|
+
}),
|
|
413
|
+
stops.length > 0 ? /* @__PURE__ */ jsx("div", {
|
|
414
|
+
className: actions,
|
|
415
|
+
children: /* @__PURE__ */ jsx(Button, {
|
|
416
|
+
variant: "quiet",
|
|
417
|
+
icon: Trash2,
|
|
418
|
+
"data-testid": "directions-clear",
|
|
419
|
+
onClick: directions.clear,
|
|
420
|
+
children: t("tools.directions.clear", {})
|
|
421
|
+
})
|
|
422
|
+
}) : null
|
|
423
|
+
]
|
|
424
|
+
});
|
|
425
|
+
}
|
|
426
|
+
export { DirectionsPanel };
|
|
427
|
+
|
|
428
|
+
//# sourceMappingURL=DirectionsPanel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DirectionsPanel.js","names":["result","styles.result","styles.figures","styles.hint","styles.legList","styles.panel","styles.group","styles.groupHeading","styles.stopList","styles.stopRow","styles.badge","styles.stopName","styles.stopActions","styles.actions","styles.searchRow","styles.searchInput","styles.statusLine","styles.errorIcon","styles.resultList"],"sources":["../../../src/tools/Directions/DirectionsPanel.tsx"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-only\n// Copyright MapCairn contributors\nimport {\n AREA_MINUTES,\n type Bounds,\n formatArea,\n formatDistance,\n formatDuration,\n formatLatLng,\n type LatLng,\n MAX_DIRECTION_STOPS,\n message,\n routingErrorMessage,\n stopLetter,\n TRAVEL_MODES,\n type TravelMode,\n travelModeLabel,\n travelModeParticiple,\n type UnitSystem,\n} from \"@mapcairn/core\";\nimport {\n Bike,\n Car,\n ChevronDown,\n ChevronUp,\n Crosshair,\n Footprints,\n MapPin,\n Route,\n Search,\n Trash2,\n TriangleAlert,\n X,\n} from \"lucide-react\";\nimport { type ReactNode, type SyntheticEvent, useEffect, useRef } from \"react\";\nimport {\n useFormatMessage,\n useMessages,\n usePreferences,\n useSettings,\n} from \"../../services\";\nimport { Button } from \"../../ui/Button\";\nimport { Icon } from \"../../ui/Icon\";\nimport { IconButton } from \"../../ui/IconButton\";\nimport { fillSlots, Isolate } from \"../../ui/Isolate\";\nimport { SegmentedControl } from \"../../ui/SegmentedControl\";\nimport { VisuallyHidden } from \"../../ui/VisuallyHidden\";\nimport { MIN_SEARCH_LENGTH, useSearch } from \"../SearchPill/useSearch\";\nimport * as styles from \"./Directions.css\";\nimport type { DirectionsOutcome, UseDirections } from \"./useDirections\";\nimport { useFreeCentre } from \"./useFreeCentre\";\n\nconst MODE_ICONS: Readonly<Record<TravelMode, typeof Car>> = {\n drive: Car,\n walk: Footprints,\n cycle: Bike,\n};\n\n/** Props for {@link DirectionsPanel}. */\nexport interface DirectionsPanelProps {\n /** The directions state and actions, from `useDirections`. */\n readonly directions: UseDirections;\n /** The dropped pin, offered as a stop, or null when there is none. */\n readonly pin: LatLng | null;\n /**\n * Returns the box to favour in the place search, usually the visible map.\n * Optional, and passed to {@link useSearch}, whose note on what a bias\n * sends applies.\n */\n readonly getBias?: () => Bounds | undefined;\n /**\n * What a request sends and to whom, shown under the buttons. Defaults to\n * the catalogue's `tools.directions.note`, which does not name the service.\n * A host names its routing service here.\n */\n readonly note?: ReactNode;\n /** The level of the group headings, one below the sheet's title. Defaults to 3. */\n readonly headingLevel?: 3 | 4;\n}\n\nfunction ResultCard({\n result,\n units,\n}: {\n result: DirectionsOutcome;\n units: UnitSystem;\n}) {\n const messages = useMessages();\n const { t } = messages;\n const format = useFormatMessage();\n const how = travelModeParticiple(result.mode);\n if (result.kind === \"area\") {\n return (\n <div className={styles.result} data-testid=\"directions-result\">\n <p className={styles.figures} data-testid=\"directions-figures\">\n {fillSlots(\n t(\"common.followedBy\", {\n first: \"{minutes}\",\n second: format(how),\n }),\n {\n minutes: (\n <Isolate>\n {format(\n message(\"duration.short.minute\", {\n count: result.minutes,\n }),\n )}\n </Isolate>\n ),\n },\n )}\n </p>\n <p>\n {fillSlots(t(\"tools.directions.reachesArea\", { area: \"{area}\" }), {\n area: (\n <span data-testid=\"directions-area\">\n <Isolate>{formatArea(result.size, units, messages)}</Isolate>\n </span>\n ),\n })}\n </p>\n </div>\n );\n }\n return (\n <div className={styles.result} data-testid=\"directions-result\">\n <p className={styles.figures} data-testid=\"directions-figures\">\n {fillSlots(\n t(\"common.commaJoined\", {\n first: \"{distance}\",\n second: \"{duration}\",\n }),\n {\n distance: (\n <Isolate>\n {formatDistance(result.distance, units, messages)}\n </Isolate>\n ),\n duration: (\n <Isolate>{format(formatDuration(result.duration))}</Isolate>\n ),\n },\n )}\n </p>\n <p className={styles.hint}>\n {messages.plural(\"tools.directions.routeSummary\", {\n mode: format(travelModeLabel(result.mode)),\n how: format(how),\n count: result.stops.length,\n })}\n </p>\n {result.legs.length > 1 ? (\n <ol\n className={styles.legList}\n aria-label={t(\"tools.directions.legs\", {})}\n >\n {result.legs.map((leg, index) => (\n <li\n // biome-ignore lint/suspicious/noArrayIndexKey: legs are positional.\n key={index}\n data-testid=\"directions-leg\"\n >\n {fillSlots(\n t(\"tools.directions.leg\", {\n from: stopLetter(index),\n to: stopLetter(index + 1),\n distance: \"{distance}\",\n duration: \"{duration}\",\n }),\n {\n distance: (\n <Isolate>\n {formatDistance(leg.properties.distance, units, messages)}\n </Isolate>\n ),\n duration: (\n <Isolate>\n {format(formatDuration(leg.properties.duration))}\n </Isolate>\n ),\n },\n )}\n </li>\n ))}\n </ol>\n ) : null}\n </div>\n );\n}\n\n/**\n * The directions tool's panel, for the sheet or side panel: the stops (added\n * by tapping the map, at the map centre, from a place search or from the\n * dropped pin, and reordered or removed with buttons), the way of travelling,\n * \"Get route\", the travel time areas and the result.\n *\n * @remarks Every action a pointer can do has a button: adding a stop at the\n * map centre stands in for a tap on the map, and Move up, Move down and\n * Remove stand in for any drag. \"Add stop at map centre\" uses the middle of\n * the part of the map the panel leaves free, which is where the crosshair is\n * drawn. Results and failures are announced by `useDirections`, so the\n * panel's own text carries no live region. A request is sent only when a\n * button asks for it, and the note under them says what goes where.\n */\nexport function DirectionsPanel({\n directions,\n pin,\n getBias,\n note,\n headingLevel = 3,\n}: DirectionsPanelProps) {\n const { settings } = useSettings();\n const format = useFormatMessage();\n const messages = useMessages();\n const { t } = messages;\n const { reducedMotion } = usePreferences();\n const search = useSearch({ getBias });\n const centre = useFreeCentre();\n const stopsHeading = useRef<HTMLHeadingElement>(null);\n const resultRef = useRef<HTMLDivElement>(null);\n const Heading = `h${headingLevel}` as const;\n const { state, stops, mode } = directions;\n const busy = state.status === \"loading\";\n const full = !directions.canAddStop;\n const needsTwo = stops.length < 2;\n\n // A result appears below the buttons that asked for it, which on a short\n // sheet may be out of sight.\n const shown = state.status === \"done\" || state.status === \"error\";\n useEffect(() => {\n if (shown) {\n resultRef.current?.scrollIntoView?.({\n block: \"nearest\",\n behavior: reducedMotion ? \"auto\" : \"smooth\",\n });\n }\n }, [shown, reducedMotion]);\n\n const addAtCentre = () => {\n const position = centre.position();\n if (position) {\n directions.addStop(position);\n }\n };\n\n const submitSearch = (event: SyntheticEvent) => {\n event.preventDefault();\n search.submit();\n };\n\n const remove = (id: string) => {\n directions.removeStop(id);\n stopsHeading.current?.focus();\n };\n\n const results = search.state.status === \"results\" ? search.state.results : [];\n\n return (\n <div className={styles.panel} data-testid=\"directions-panel\">\n <section className={styles.group} aria-labelledby=\"directions-stops\">\n <Heading\n id=\"directions-stops\"\n ref={stopsHeading}\n tabIndex={-1}\n className={styles.groupHeading}\n >\n {t(\"tools.directions.stops\", {})}\n </Heading>\n <p className={styles.hint}>{t(\"tools.directions.stopsHint\", {})}</p>\n {stops.length > 0 ? (\n <ol className={styles.stopList} data-testid=\"directions-stops\">\n {stops.map((stop, index) => {\n const letter = stopLetter(index);\n return (\n <li\n key={stop.id}\n className={styles.stopRow}\n data-testid=\"directions-stop-row\"\n >\n <span className={styles.badge} aria-hidden=\"true\">\n {letter}\n </span>\n <span className={styles.stopName}>\n <VisuallyHidden>\n {t(\"tools.directions.stopPrefix\", { letter })}{\" \"}\n </VisuallyHidden>\n {stop.label === undefined ? (\n <Isolate figure>{formatLatLng(stop.position)}</Isolate>\n ) : (\n <Isolate>{stop.label}</Isolate>\n )}\n </span>\n <span className={styles.stopActions}>\n <IconButton\n label={t(\"tools.directions.moveUp\", { letter })}\n icon={ChevronUp}\n size=\"compact\"\n disabled={index === 0}\n onClick={() => directions.moveStop(stop.id, -1)}\n />\n <IconButton\n label={t(\"tools.directions.moveDown\", { letter })}\n icon={ChevronDown}\n size=\"compact\"\n disabled={index === stops.length - 1}\n onClick={() => directions.moveStop(stop.id, 1)}\n />\n <IconButton\n label={t(\"tools.directions.remove\", { letter })}\n icon={X}\n size=\"compact\"\n data-testid=\"directions-remove\"\n onClick={() => remove(stop.id)}\n />\n </span>\n </li>\n );\n })}\n </ol>\n ) : null}\n <div className={styles.actions}>\n <Button\n variant=\"secondary\"\n icon={Crosshair}\n disabled={full}\n data-testid=\"directions-add-centre\"\n onClick={addAtCentre}\n >\n {t(\"tools.directions.addAtCentre\", {})}\n </Button>\n {pin ? (\n <Button\n variant=\"secondary\"\n icon={MapPin}\n disabled={full}\n data-testid=\"directions-add-pin\"\n onClick={() =>\n directions.addStop(pin, t(\"tools.directions.droppedPin\", {}))\n }\n >\n {t(\"tools.directions.addPin\", {})}\n </Button>\n ) : null}\n </div>\n {full ? (\n <p className={styles.hint}>\n {t(\"tools.directions.full\", { max: MAX_DIRECTION_STOPS })}\n </p>\n ) : null}\n </section>\n\n <section className={styles.group} aria-labelledby=\"directions-route\">\n {/* The controls name themselves, and the room matters on a half-height sheet. */}\n <VisuallyHidden as={Heading} id=\"directions-route\">\n {t(\"tools.directions.route\", {})}\n </VisuallyHidden>\n <SegmentedControl\n label={t(\"tools.directions.travelMode\", {})}\n options={TRAVEL_MODES.map((value) => ({\n value,\n label: format(travelModeLabel(value)),\n icon: <Icon icon={MODE_ICONS[value]} />,\n }))}\n value={mode}\n onValueChange={(next) => directions.setMode(next as TravelMode)}\n data-testid=\"directions-mode\"\n />\n <div className={styles.actions}>\n <Button\n icon={Route}\n disabled={needsTwo}\n busy={state.status === \"loading\" && state.request === \"route\"}\n data-testid=\"directions-get-route\"\n onClick={directions.requestRoute}\n >\n {t(\"tools.directions.getRoute\", {})}\n </Button>\n {busy ? (\n <Button\n variant=\"quiet\"\n data-testid=\"directions-cancel\"\n onClick={directions.cancel}\n >\n {t(\"tools.directions.cancel\", {})}\n </Button>\n ) : null}\n </div>\n {needsTwo ? (\n <p className={styles.hint}>{t(\"tools.directions.needTwo\", {})}</p>\n ) : null}\n </section>\n\n <section className={styles.group} aria-labelledby=\"directions-search\">\n <Heading id=\"directions-search\" className={styles.groupHeading}>\n {t(\"tools.directions.searchHeading\", {})}\n </Heading>\n <form\n aria-label={t(\"tools.directions.searchForm\", {})}\n className={styles.group}\n onSubmit={submitSearch}\n >\n <div className={styles.searchRow}>\n <input\n className={styles.searchInput}\n type=\"text\"\n aria-label={t(\"tools.directions.searchInput\", {})}\n placeholder={t(\"tools.directions.searchPlaceholder\", {})}\n autoComplete=\"off\"\n autoCapitalize=\"off\"\n spellCheck={false}\n enterKeyHint=\"search\"\n value={search.query}\n data-testid=\"directions-search-input\"\n onChange={(event) => search.setQuery(event.target.value)}\n />\n <Button\n variant=\"secondary\"\n type=\"submit\"\n icon={Search}\n disabled={search.query.trim().length < MIN_SEARCH_LENGTH || full}\n busy={search.state.status === \"loading\"}\n data-testid=\"directions-search-submit\"\n >\n {t(\"tools.search.label\", {})}\n </Button>\n </div>\n {search.state.status === \"empty\" ? (\n <p className={styles.hint}>\n {t(\"tools.search.nothingMatched\", {})}\n </p>\n ) : null}\n {search.state.status === \"error\" ? (\n <p className={styles.statusLine}>\n <Icon icon={TriangleAlert} className={styles.errorIcon} />\n <span>{t(\"tools.search.unavailable\", {})}</span>\n <Button variant=\"quiet\" onClick={search.retry}>\n {t(\"tools.search.retry\", {})}\n </Button>\n </p>\n ) : null}\n {results.length > 0 ? (\n <ul\n className={styles.resultList}\n aria-label={t(\"tools.directions.placesFound\", {})}\n data-testid=\"directions-search-results\"\n >\n {results.map((place) => (\n <li key={place.id}>\n <Button\n variant=\"quiet\"\n data-testid=\"directions-search-result\"\n disabled={full}\n onClick={() => {\n directions.addStop(place.centre, place.label);\n search.clear();\n }}\n >\n {t(\"tools.directions.addPlace\", {\n place: place.secondaryLabel\n ? t(\"common.commaJoined\", {\n first: place.label,\n second: place.secondaryLabel,\n })\n : place.label,\n })}\n </Button>\n </li>\n ))}\n </ul>\n ) : null}\n </form>\n </section>\n\n <section className={styles.group} aria-labelledby=\"directions-area\">\n <Heading id=\"directions-area\" className={styles.groupHeading}>\n {t(\"tools.directions.areaHeading\", {})}\n </Heading>\n <p className={styles.hint}>{t(\"tools.directions.areaHint\", {})}</p>\n <div className={styles.actions} data-testid=\"directions-area-actions\">\n {AREA_MINUTES.map((minutes) => (\n <Button\n key={minutes}\n variant=\"secondary\"\n disabled={stops.length < 1}\n busy={\n state.status === \"loading\" &&\n state.request === \"area\" &&\n state.minutes === minutes\n }\n aria-pressed={\n directions.result?.kind === \"area\" &&\n directions.result.minutes === minutes\n }\n aria-label={messages.plural(\"tools.directions.showArea\", {\n count: minutes,\n })}\n data-testid={`directions-area-${minutes}`}\n onClick={() => directions.requestArea(minutes)}\n >\n {messages.plural(\"duration.short.minute\", { count: minutes })}\n </Button>\n ))}\n </div>\n <p className={styles.hint} data-testid=\"directions-note\">\n {note ?? t(\"tools.directions.note\", {})}\n </p>\n </section>\n\n <div ref={resultRef} data-testid=\"directions-status\">\n {state.status === \"loading\" ? (\n <p className={styles.hint} data-testid=\"directions-loading\">\n {state.request === \"route\"\n ? t(\"tools.directions.findingRoute\", {})\n : t(\"tools.directions.findingArea\", {})}\n </p>\n ) : null}\n {state.status === \"error\" ? (\n <div className={styles.group} data-testid=\"directions-error\">\n <p className={styles.statusLine}>\n <Icon icon={TriangleAlert} className={styles.errorIcon} />\n <span>\n {format(routingErrorMessage(state.kind, state.request))}\n </span>\n </p>\n {state.kind === \"network\" || state.kind === \"rate-limited\" ? (\n <div className={styles.actions}>\n <Button\n variant=\"secondary\"\n data-testid=\"directions-retry\"\n onClick={directions.retry}\n >\n {t(\"tools.tryAgain\", {})}\n </Button>\n </div>\n ) : null}\n </div>\n ) : null}\n {state.status === \"done\" ? (\n <ResultCard result={state.result} units={settings.units} />\n ) : null}\n </div>\n\n {stops.length > 0 ? (\n <div className={styles.actions}>\n <Button\n variant=\"quiet\"\n icon={Trash2}\n data-testid=\"directions-clear\"\n onClick={directions.clear}\n >\n {t(\"tools.directions.clear\", {})}\n </Button>\n </div>\n ) : null}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAoDA,IAAM,aAAuD;CAC3D,OAAO;CACP,MAAM;CACN,OAAO;AACT;AAwBA,SAAS,WAAW,EAClB,QAAA,UACA,SAIC;CACD,MAAM,WAAW,YAAY;CAC7B,MAAM,EAAE,MAAM;CACd,MAAM,SAAS,iBAAiB;CAChC,MAAM,MAAM,qBAAqBA,SAAO,IAAI;CAC5C,IAAIA,SAAO,SAAS,QAClB,OACE,qBAAC,OAAD;EAAK,WAAWC;EAAe,eAAY;EAA3C,UAAA,CACE,oBAAC,KAAD;GAAG,WAAWC;GAAgB,eAAY;GACvC,UAAA,UACC,EAAE,qBAAqB;IACrB,OAAO;IACP,QAAQ,OAAO,GAAG;GACpB,CAAC,GACD,EACE,SACE,oBAAC,SAAD,EAAA,UACG,OACC,QAAQ,yBAAyB,EAC/B,OAAOF,SAAO,QAChB,CAAC,CACH,EACO,CAAA,EAEb,CACF;EACC,CAAA,GACH,oB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useChromeLayout } from "../../chrome/layoutContext.js";
|
|
2
|
+
import { useMap } from "../../host/MapContext.js";
|
|
3
|
+
import { fitPadding } from "../../layers/reveal.js";
|
|
4
|
+
import { routeBounds } from "@mapcairn/core";
|
|
5
|
+
import { useEffect } from "react";
|
|
6
|
+
import { useReadingDirection } from "@mapcairn/react";
|
|
7
|
+
import { tokenValues } from "@mapcairn/theme";
|
|
8
|
+
// src/tools/Directions/MapDirections.tsx
|
|
9
|
+
/**
|
|
10
|
+
* Map ids of what directions draws. Definition ids cannot contain a colon, so they never meet a layer's.
|
|
11
|
+
*
|
|
12
|
+
* @internal
|
|
13
|
+
*/
|
|
14
|
+
var ROUTE_CASING_LAYER_ID = ":route-casing";
|
|
15
|
+
/**
|
|
16
|
+
* Map id of the route line.
|
|
17
|
+
*
|
|
18
|
+
* @internal
|
|
19
|
+
*/
|
|
20
|
+
var ROUTE_LAYER_ID = ":route";
|
|
21
|
+
/**
|
|
22
|
+
* Map id of the travel-time area.
|
|
23
|
+
*
|
|
24
|
+
* @internal
|
|
25
|
+
*/
|
|
26
|
+
var AREA_LAYER_ID = ":area";
|
|
27
|
+
/** Width of the route line, in pixels, and of the white casing under it. */
|
|
28
|
+
var ROUTE_WIDTH_PX = 5;
|
|
29
|
+
var ROUTE_CASING_WIDTH_PX = 9;
|
|
30
|
+
/**
|
|
31
|
+
* Draws a route as a line with a white casing, or a travel-time area as an
|
|
32
|
+
* outlined, tinted shape, through the map adapter's shape layers, and fits the
|
|
33
|
+
* map to it, clear of the sheet or side panel. Renders nothing; put it inside
|
|
34
|
+
* `MapView`. The engine draws the shapes, so they stay sharp while the map
|
|
35
|
+
* moves and come back after a basemap swap.
|
|
36
|
+
*/
|
|
37
|
+
function MapDirections({ result }) {
|
|
38
|
+
const { adapter } = useMap();
|
|
39
|
+
const { layout, viewport, panelEdge } = useChromeLayout();
|
|
40
|
+
const direction = useReadingDirection();
|
|
41
|
+
useEffect(() => {
|
|
42
|
+
if (!adapter || !result) return;
|
|
43
|
+
const colour = tokenValues.dataPalette.blue;
|
|
44
|
+
if (result.kind === "route") {
|
|
45
|
+
const geometries = result.legs.map((leg) => leg.geometry);
|
|
46
|
+
adapter.setShapeLayer(ROUTE_CASING_LAYER_ID, {
|
|
47
|
+
geometries,
|
|
48
|
+
colour: tokenValues.dataMarker.halo,
|
|
49
|
+
lineWidth: ROUTE_CASING_WIDTH_PX
|
|
50
|
+
});
|
|
51
|
+
adapter.setShapeLayer(ROUTE_LAYER_ID, {
|
|
52
|
+
geometries,
|
|
53
|
+
colour,
|
|
54
|
+
lineWidth: ROUTE_WIDTH_PX
|
|
55
|
+
});
|
|
56
|
+
} else adapter.setShapeLayer(AREA_LAYER_ID, {
|
|
57
|
+
geometries: result.features.map((feature) => feature.geometry),
|
|
58
|
+
colour
|
|
59
|
+
});
|
|
60
|
+
return () => {
|
|
61
|
+
adapter.removeLayer(ROUTE_CASING_LAYER_ID);
|
|
62
|
+
adapter.removeLayer(ROUTE_LAYER_ID);
|
|
63
|
+
adapter.removeLayer(AREA_LAYER_ID);
|
|
64
|
+
};
|
|
65
|
+
}, [adapter, result]);
|
|
66
|
+
useEffect(() => {
|
|
67
|
+
if (!adapter || !result) return;
|
|
68
|
+
const bounds = routeBounds(result.kind === "route" ? result.legs : result.features);
|
|
69
|
+
if (!bounds) return;
|
|
70
|
+
adapter.fitBounds(bounds, {
|
|
71
|
+
maxZoom: 16,
|
|
72
|
+
padding: fitPadding({
|
|
73
|
+
layout,
|
|
74
|
+
viewport,
|
|
75
|
+
panelEdge,
|
|
76
|
+
direction
|
|
77
|
+
})
|
|
78
|
+
});
|
|
79
|
+
}, [adapter, result]);
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
export { AREA_LAYER_ID, MapDirections, ROUTE_CASING_LAYER_ID, ROUTE_LAYER_ID };
|
|
83
|
+
|
|
84
|
+
//# sourceMappingURL=MapDirections.js.map
|