@mailwoman/react 9.4.0 → 10.1.0
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/README.md +17 -16
- package/fonts.css +97 -22
- package/lib/common/About.tsx +87 -71
- package/lib/common/ClientOnly.tsx +2 -14
- package/lib/common/CopyButton.tsx +3 -1
- package/lib/common/LoadingIndicator.tsx +4 -2
- package/lib/common/PresetChips.tsx +9 -8
- package/lib/common/confidence-tiers.ts +7 -6
- package/lib/common/cx.ts +3 -1
- package/lib/common/text-tokens.ts +7 -4
- package/lib/common/useBuildInfo.ts +54 -0
- package/lib/common/useClipboard.ts +2 -11
- package/lib/common.ts +22 -0
- package/lib/index.ts +27 -112
- package/lib/map/AppIdentity.tsx +85 -0
- package/lib/map/BackendControl.tsx +16 -13
- package/lib/map/CompareToggle.tsx +11 -33
- package/lib/map/DebugInfo.tsx +88 -0
- package/lib/map/Geocoder.tsx +92 -58
- package/lib/map/GeocoderControls.tsx +582 -127
- package/lib/map/GraticuleLayer.tsx +54 -0
- package/lib/map/MapCanvas.tsx +23 -12
- package/lib/map/MapChipRow.tsx +73 -0
- package/lib/map/MapCompass.tsx +68 -0
- package/lib/map/MapControlStack.tsx +97 -0
- package/lib/map/MapFooter.tsx +101 -0
- package/lib/map/MapProgressBar.tsx +55 -0
- package/lib/map/MapSearchBar.tsx +82 -0
- package/lib/map/MapSheet.tsx +71 -0
- package/lib/map/OverlayLayers.tsx +1 -1
- package/lib/map/PlaceAutocomplete.tsx +10 -21
- package/lib/map/PlaceMarker.tsx +4 -2
- package/lib/map/ResolvedPlaceLayers.tsx +5 -14
- package/lib/map/ResultCamera.tsx +8 -31
- package/lib/map/ResultOverlay.tsx +2 -12
- package/lib/map/ResultPanel.tsx +1 -20
- package/lib/map/VersionPicker.tsx +10 -19
- package/lib/map/fake-runtime.ts +10 -12
- package/lib/map/geometry.ts +14 -47
- package/lib/map/graticule.ts +80 -0
- package/lib/map/map-debug.ts +1 -1
- package/lib/map/place-render.ts +28 -60
- package/lib/map/types.ts +65 -97
- package/lib/map/useCompareState.ts +5 -4
- package/lib/map/useGeocode.ts +7 -5
- package/lib/map/useMapBearing.ts +56 -0
- package/lib/map/useMapLabelPick.ts +114 -0
- package/lib/map/useMapPlaceRender.ts +2 -6
- package/lib/map/usePlaceAutocomplete.ts +44 -50
- package/lib/map.ts +95 -0
- package/lib/pipeline/CandidatePicker.tsx +13 -5
- package/lib/pipeline/ConfidenceCell.tsx +1 -1
- package/lib/pipeline/FailureDiagnostic.tsx +8 -2
- package/lib/pipeline/QueryForm.tsx +5 -2
- package/lib/pipeline/ResolvedPlace.tsx +1 -1
- package/lib/pipeline/SpanHighlight.tsx +7 -5
- package/lib/pipeline/TimingPanel.tsx +1 -1
- package/lib/pipeline/TreeView.tsx +1 -1
- package/lib/pipeline/copy.ts +22 -25
- package/lib/pipeline/presets.ts +15 -13
- package/lib/pipeline/types.ts +21 -14
- package/lib/pipeline/useParsePipeline.ts +38 -24
- package/lib/pipeline.ts +36 -0
- package/lib/poi/AbstainPanel.tsx +1 -1
- package/lib/poi/LiveResultsBlock.tsx +2 -1
- package/lib/poi/POIExplorer.tsx +24 -15
- package/lib/poi/QueryInput.tsx +1 -1
- package/lib/poi/SubjectPanel.tsx +4 -3
- package/lib/poi/runtime.ts +5 -16
- package/lib/poi/types.ts +39 -27
- package/lib/poi/usePOISearch.ts +39 -44
- package/lib/poi.ts +39 -0
- package/lib/runtime/useReleaseRuntime.ts +125 -74
- package/lib/runtime.ts +16 -0
- package/lib/search/SearchModal.tsx +317 -0
- package/lib/search/search.css +144 -0
- package/lib/search/types.ts +67 -0
- package/lib/search.ts +11 -0
- package/out/common/About.d.ts +13 -4
- package/out/common/About.d.ts.map +1 -1
- package/out/common/About.js +5 -2
- package/out/common/About.js.map +1 -1
- package/out/common/ClientOnly.d.ts +2 -11
- package/out/common/ClientOnly.d.ts.map +1 -1
- package/out/common/ClientOnly.js +1 -13
- package/out/common/ClientOnly.js.map +1 -1
- package/out/common/CopyButton.d.ts +3 -1
- package/out/common/CopyButton.d.ts.map +1 -1
- package/out/common/CopyButton.js.map +1 -1
- package/out/common/LoadingIndicator.d.ts +4 -2
- package/out/common/LoadingIndicator.d.ts.map +1 -1
- package/out/common/LoadingIndicator.js.map +1 -1
- package/out/common/PresetChips.d.ts +9 -8
- package/out/common/PresetChips.d.ts.map +1 -1
- package/out/common/PresetChips.js.map +1 -1
- package/out/common/confidence-tiers.d.ts +7 -6
- package/out/common/confidence-tiers.d.ts.map +1 -1
- package/out/common/confidence-tiers.js +7 -6
- package/out/common/confidence-tiers.js.map +1 -1
- package/out/common/cx.d.ts +3 -1
- package/out/common/cx.d.ts.map +1 -1
- package/out/common/cx.js +3 -1
- package/out/common/cx.js.map +1 -1
- package/out/common/text-tokens.d.ts +4 -3
- package/out/common/text-tokens.d.ts.map +1 -1
- package/out/common/text-tokens.js +6 -3
- package/out/common/text-tokens.js.map +1 -1
- package/out/common/useBuildInfo.d.ts +27 -0
- package/out/common/useBuildInfo.d.ts.map +1 -0
- package/out/common/useBuildInfo.js +32 -0
- package/out/common/useBuildInfo.js.map +1 -0
- package/out/common/useClipboard.d.ts +1 -3
- package/out/common/useClipboard.d.ts.map +1 -1
- package/out/common/useClipboard.js +2 -11
- package/out/common/useClipboard.js.map +1 -1
- package/out/common.d.ts +22 -0
- package/out/common.d.ts.map +1 -0
- package/out/common.js +15 -0
- package/out/common.js.map +1 -0
- package/out/index.d.ts +26 -71
- package/out/index.d.ts.map +1 -1
- package/out/index.js +21 -47
- package/out/index.js.map +1 -1
- package/out/map/AppIdentity.d.ts +42 -0
- package/out/map/AppIdentity.d.ts.map +1 -0
- package/out/map/AppIdentity.js +16 -0
- package/out/map/AppIdentity.js.map +1 -0
- package/out/map/BackendControl.d.ts +9 -10
- package/out/map/BackendControl.d.ts.map +1 -1
- package/out/map/BackendControl.js +2 -2
- package/out/map/BackendControl.js.map +1 -1
- package/out/map/CompareToggle.d.ts +8 -31
- package/out/map/CompareToggle.d.ts.map +1 -1
- package/out/map/CompareToggle.js +5 -2
- package/out/map/CompareToggle.js.map +1 -1
- package/out/map/DebugInfo.d.ts +34 -0
- package/out/map/DebugInfo.d.ts.map +1 -0
- package/out/map/DebugInfo.js +39 -0
- package/out/map/DebugInfo.js.map +1 -0
- package/out/map/Geocoder.d.ts +47 -26
- package/out/map/Geocoder.d.ts.map +1 -1
- package/out/map/Geocoder.js +34 -50
- package/out/map/Geocoder.js.map +1 -1
- package/out/map/GeocoderControls.d.ts +23 -33
- package/out/map/GeocoderControls.d.ts.map +1 -1
- package/out/map/GeocoderControls.js +277 -16
- package/out/map/GeocoderControls.js.map +1 -1
- package/out/map/GraticuleLayer.d.ts +28 -0
- package/out/map/GraticuleLayer.d.ts.map +1 -0
- package/out/map/GraticuleLayer.js +25 -0
- package/out/map/GraticuleLayer.js.map +1 -0
- package/out/map/MapCanvas.d.ts +23 -12
- package/out/map/MapCanvas.d.ts.map +1 -1
- package/out/map/MapCanvas.js +5 -2
- package/out/map/MapCanvas.js.map +1 -1
- package/out/map/MapChipRow.d.ts +43 -0
- package/out/map/MapChipRow.d.ts.map +1 -0
- package/out/map/MapChipRow.js +12 -0
- package/out/map/MapChipRow.js.map +1 -0
- package/out/map/MapCompass.d.ts +33 -0
- package/out/map/MapCompass.d.ts.map +1 -0
- package/out/map/MapCompass.js +15 -0
- package/out/map/MapCompass.js.map +1 -0
- package/out/map/MapControlStack.d.ts +56 -0
- package/out/map/MapControlStack.d.ts.map +1 -0
- package/out/map/MapControlStack.js +18 -0
- package/out/map/MapControlStack.js.map +1 -0
- package/out/map/MapFooter.d.ts +27 -0
- package/out/map/MapFooter.d.ts.map +1 -0
- package/out/map/MapFooter.js +37 -0
- package/out/map/MapFooter.js.map +1 -0
- package/out/map/MapProgressBar.d.ts +31 -0
- package/out/map/MapProgressBar.d.ts.map +1 -0
- package/out/map/MapProgressBar.js +8 -0
- package/out/map/MapProgressBar.js.map +1 -0
- package/out/map/MapSearchBar.d.ts +48 -0
- package/out/map/MapSearchBar.d.ts.map +1 -0
- package/out/map/MapSearchBar.js +12 -0
- package/out/map/MapSearchBar.js.map +1 -0
- package/out/map/MapSheet.d.ts +35 -0
- package/out/map/MapSheet.d.ts.map +1 -0
- package/out/map/MapSheet.js +29 -0
- package/out/map/MapSheet.js.map +1 -0
- package/out/map/OverlayLayers.d.ts +1 -1
- package/out/map/OverlayLayers.js +2 -2
- package/out/map/PlaceAutocomplete.d.ts +10 -21
- package/out/map/PlaceAutocomplete.d.ts.map +1 -1
- package/out/map/PlaceAutocomplete.js +2 -1
- package/out/map/PlaceAutocomplete.js.map +1 -1
- package/out/map/PlaceMarker.d.ts +4 -2
- package/out/map/PlaceMarker.d.ts.map +1 -1
- package/out/map/PlaceMarker.js +3 -1
- package/out/map/PlaceMarker.js.map +1 -1
- package/out/map/ResolvedPlaceLayers.d.ts +5 -14
- package/out/map/ResolvedPlaceLayers.d.ts.map +1 -1
- package/out/map/ResolvedPlaceLayers.js +2 -2
- package/out/map/ResolvedPlaceLayers.js.map +1 -1
- package/out/map/ResultCamera.d.ts +8 -31
- package/out/map/ResultCamera.d.ts.map +1 -1
- package/out/map/ResultCamera.js +3 -28
- package/out/map/ResultCamera.js.map +1 -1
- package/out/map/ResultOverlay.d.ts +2 -12
- package/out/map/ResultOverlay.d.ts.map +1 -1
- package/out/map/ResultOverlay.js +1 -2
- package/out/map/ResultOverlay.js.map +1 -1
- package/out/map/ResultPanel.d.ts +1 -20
- package/out/map/ResultPanel.d.ts.map +1 -1
- package/out/map/ResultPanel.js +1 -1
- package/out/map/ResultPanel.js.map +1 -1
- package/out/map/VersionPicker.d.ts +7 -19
- package/out/map/VersionPicker.d.ts.map +1 -1
- package/out/map/VersionPicker.js +5 -2
- package/out/map/VersionPicker.js.map +1 -1
- package/out/map/fake-runtime.d.ts +9 -11
- package/out/map/fake-runtime.d.ts.map +1 -1
- package/out/map/fake-runtime.js +9 -12
- package/out/map/fake-runtime.js.map +1 -1
- package/out/map/geometry.d.ts +13 -34
- package/out/map/geometry.d.ts.map +1 -1
- package/out/map/geometry.js +9 -34
- package/out/map/geometry.js.map +1 -1
- package/out/map/graticule.d.ts +17 -0
- package/out/map/graticule.d.ts.map +1 -0
- package/out/map/graticule.js +67 -0
- package/out/map/graticule.js.map +1 -0
- package/out/map/map-debug.d.ts +1 -1
- package/out/map/map-debug.d.ts.map +1 -1
- package/out/map/map-debug.js +1 -1
- package/out/map/map-debug.js.map +1 -1
- package/out/map/place-render.d.ts +23 -43
- package/out/map/place-render.d.ts.map +1 -1
- package/out/map/place-render.js +4 -39
- package/out/map/place-render.js.map +1 -1
- package/out/map/types.d.ts +67 -95
- package/out/map/types.d.ts.map +1 -1
- package/out/map/types.js +1 -10
- package/out/map/types.js.map +1 -1
- package/out/map/useCompareState.d.ts +5 -4
- package/out/map/useCompareState.d.ts.map +1 -1
- package/out/map/useCompareState.js +3 -3
- package/out/map/useCompareState.js.map +1 -1
- package/out/map/useGeocode.d.ts +5 -3
- package/out/map/useGeocode.d.ts.map +1 -1
- package/out/map/useGeocode.js +4 -4
- package/out/map/useGeocode.js.map +1 -1
- package/out/map/useMapBearing.d.ts +28 -0
- package/out/map/useMapBearing.d.ts.map +1 -0
- package/out/map/useMapBearing.js +30 -0
- package/out/map/useMapBearing.js.map +1 -0
- package/out/map/useMapLabelPick.d.ts +13 -0
- package/out/map/useMapLabelPick.d.ts.map +1 -0
- package/out/map/useMapLabelPick.js +95 -0
- package/out/map/useMapLabelPick.js.map +1 -0
- package/out/map/useMapPlaceRender.d.ts +2 -6
- package/out/map/useMapPlaceRender.d.ts.map +1 -1
- package/out/map/useMapPlaceRender.js +2 -6
- package/out/map/useMapPlaceRender.js.map +1 -1
- package/out/map/usePlaceAutocomplete.d.ts +30 -28
- package/out/map/usePlaceAutocomplete.d.ts.map +1 -1
- package/out/map/usePlaceAutocomplete.js +6 -33
- package/out/map/usePlaceAutocomplete.js.map +1 -1
- package/out/map.d.ts +69 -0
- package/out/map.d.ts.map +1 -0
- package/out/map.js +46 -0
- package/out/map.js.map +1 -0
- package/out/pipeline/CandidatePicker.d.ts +12 -2
- package/out/pipeline/CandidatePicker.d.ts.map +1 -1
- package/out/pipeline/CandidatePicker.js +2 -2
- package/out/pipeline/CandidatePicker.js.map +1 -1
- package/out/pipeline/ConfidenceCell.d.ts +1 -1
- package/out/pipeline/ConfidenceCell.js +1 -1
- package/out/pipeline/FailureDiagnostic.d.ts +8 -2
- package/out/pipeline/FailureDiagnostic.d.ts.map +1 -1
- package/out/pipeline/FailureDiagnostic.js +3 -0
- package/out/pipeline/FailureDiagnostic.js.map +1 -1
- package/out/pipeline/PipelineExplorer.js +1 -1
- package/out/pipeline/QueryForm.d.ts +5 -2
- package/out/pipeline/QueryForm.d.ts.map +1 -1
- package/out/pipeline/QueryForm.js +1 -1
- package/out/pipeline/QueryForm.js.map +1 -1
- package/out/pipeline/ResolvedPlace.js +1 -1
- package/out/pipeline/SpanHighlight.d.ts +4 -3
- package/out/pipeline/SpanHighlight.d.ts.map +1 -1
- package/out/pipeline/SpanHighlight.js +3 -2
- package/out/pipeline/SpanHighlight.js.map +1 -1
- package/out/pipeline/TimingPanel.d.ts +1 -1
- package/out/pipeline/TimingPanel.js +1 -1
- package/out/pipeline/TreeView.d.ts +1 -1
- package/out/pipeline/copy.d.ts +1 -1
- package/out/pipeline/copy.d.ts.map +1 -1
- package/out/pipeline/copy.js +4 -3
- package/out/pipeline/copy.js.map +1 -1
- package/out/pipeline/presets.d.ts +5 -4
- package/out/pipeline/presets.d.ts.map +1 -1
- package/out/pipeline/presets.js +15 -13
- package/out/pipeline/presets.js.map +1 -1
- package/out/pipeline/types.d.ts +21 -14
- package/out/pipeline/types.d.ts.map +1 -1
- package/out/pipeline/types.js +2 -4
- package/out/pipeline/types.js.map +1 -1
- package/out/pipeline/useParsePipeline.d.ts +15 -7
- package/out/pipeline/useParsePipeline.d.ts.map +1 -1
- package/out/pipeline/useParsePipeline.js +10 -7
- package/out/pipeline/useParsePipeline.js.map +1 -1
- package/out/pipeline.d.ts +33 -0
- package/out/pipeline.d.ts.map +1 -0
- package/out/pipeline.js +21 -0
- package/out/pipeline.js.map +1 -0
- package/out/poi/AbstainPanel.d.ts +1 -1
- package/out/poi/LiveResultsBlock.d.ts +2 -1
- package/out/poi/LiveResultsBlock.d.ts.map +1 -1
- package/out/poi/LiveResultsBlock.js +1 -1
- package/out/poi/LiveResultsBlock.js.map +1 -1
- package/out/poi/POIExplorer.d.ts +22 -12
- package/out/poi/POIExplorer.d.ts.map +1 -1
- package/out/poi/POIExplorer.js +10 -9
- package/out/poi/POIExplorer.js.map +1 -1
- package/out/poi/QueryInput.d.ts +1 -1
- package/out/poi/SubjectPanel.d.ts +2 -2
- package/out/poi/SubjectPanel.d.ts.map +1 -1
- package/out/poi/SubjectPanel.js +3 -2
- package/out/poi/SubjectPanel.js.map +1 -1
- package/out/poi/runtime.d.ts +5 -14
- package/out/poi/runtime.d.ts.map +1 -1
- package/out/poi/runtime.js +5 -16
- package/out/poi/runtime.js.map +1 -1
- package/out/poi/types.d.ts +39 -27
- package/out/poi/types.d.ts.map +1 -1
- package/out/poi/types.js +2 -4
- package/out/poi/types.js.map +1 -1
- package/out/poi/usePOISearch.d.ts +28 -17
- package/out/poi/usePOISearch.d.ts.map +1 -1
- package/out/poi/usePOISearch.js +6 -32
- package/out/poi/usePOISearch.js.map +1 -1
- package/out/poi.d.ts +23 -0
- package/out/poi.d.ts.map +1 -0
- package/out/poi.js +15 -0
- package/out/poi.js.map +1 -0
- package/out/runtime/useReleaseRuntime.d.ts +64 -65
- package/out/runtime/useReleaseRuntime.d.ts.map +1 -1
- package/out/runtime/useReleaseRuntime.js +31 -26
- package/out/runtime/useReleaseRuntime.js.map +1 -1
- package/out/runtime.d.ts +9 -0
- package/out/runtime.d.ts.map +1 -0
- package/out/runtime.js +8 -0
- package/out/runtime.js.map +1 -0
- package/out/search/SearchModal.d.ts +33 -0
- package/out/search/SearchModal.d.ts.map +1 -0
- package/out/search/SearchModal.js +187 -0
- package/out/search/SearchModal.js.map +1 -0
- package/out/search/types.d.ts +64 -0
- package/out/search/types.d.ts.map +1 -0
- package/out/search/types.js +13 -0
- package/out/search/types.js.map +1 -0
- package/out/search.d.ts +11 -0
- package/out/search.d.ts.map +1 -0
- package/out/search.js +9 -0
- package/out/search.js.map +1 -0
- package/package.json +132 -133
- package/styles.css +1340 -202
- package/tokens/index.css +26 -7
- package/tokens/tokens.json +121 -6
- package/tokens/tokens.resolver.json +1 -1
- package/lib/map/index.ts +0 -76
- package/out/map/index.d.ts +0 -52
- package/out/map/index.d.ts.map +0 -1
- package/out/map/index.js +0 -36
- package/out/map/index.js.map +0 -1
- package/styleframe.config.ts +0 -321
- package/vitest.node.config.ts +0 -20
package/lib/map/Geocoder.tsx
CHANGED
|
@@ -2,24 +2,9 @@
|
|
|
2
2
|
* @copyright Sister Software
|
|
3
3
|
* @license AGPL-3.0
|
|
4
4
|
* @author Teffen Ellis, et al.
|
|
5
|
-
*
|
|
6
|
-
* `<Geocoder>` — the WHOLE geocoder, composed. It is the map analogue of `PipelineExplorer`
|
|
7
|
-
* and takes the SAME DI shape: an injected {@link GeocoderRuntime} (the host owns ONNX / httpvfs / R2 /
|
|
8
|
-
* the composed map style) plus a {@link GeocoderPanels} bag (the host's ModelVisualizer / VersionCompare /
|
|
9
|
-
* About / Permalink). Everything here is composition + a `ClientOnly` boundary:
|
|
10
|
-
*
|
|
11
|
-
* - the floating {@link GeocoderControls} panel (version / compare / backend / query+autocomplete / result),
|
|
12
|
-
* - the declarative {@link MapCanvas} with the phase-2 overlays ({@link OverlayLayers}) and the
|
|
13
|
-
* resolved-place marker/outline/camera ({@link ResolvedPlaceLayers}) driven by the parse state,
|
|
14
|
-
* - the hooks that wire them: {@link useGeocode} (parse + viewport bias + map place),
|
|
15
|
-
* {@link usePlaceAutocomplete}, {@link useCompareState}.
|
|
16
|
-
*
|
|
17
|
-
* Because it pulls {@link MapCanvas} (→ `react-map-gl` → `maplibre-gl`, WebGL + DOM at import), it lives on
|
|
18
|
-
* the `@mailwoman/react/map` subpath ONLY — never the package root. The whole thing renders in Storybook
|
|
19
|
-
* over a fake runtime (offline stub style + canned geocode) with no network, no ONNX, no gazetteer.
|
|
20
5
|
*/
|
|
21
6
|
|
|
22
|
-
import { type ReactNode, useCallback, useEffect, useRef } from "react"
|
|
7
|
+
import { type ReactNode, useCallback, useEffect, useRef, useState } from "react"
|
|
23
8
|
import type { MapRef } from "react-map-gl/maplibre"
|
|
24
9
|
|
|
25
10
|
import type { GeocoderPanels, GeocoderRuntime, MapBias } from "#map/types"
|
|
@@ -31,45 +16,80 @@ import { usePlaceAutocomplete } from "#map/usePlaceAutocomplete"
|
|
|
31
16
|
import { ClientOnly } from "../common/ClientOnly.tsx"
|
|
32
17
|
import type { Preset } from "../common/PresetChips.tsx"
|
|
33
18
|
import { GeocoderControls } from "./GeocoderControls.tsx"
|
|
19
|
+
import { GraticuleLayer } from "./GraticuleLayer.tsx"
|
|
34
20
|
import { MapCanvas } from "./MapCanvas.tsx"
|
|
35
21
|
import { OverlayLayers } from "./OverlayLayers.tsx"
|
|
36
22
|
import { ResolvedPlaceLayers } from "./ResolvedPlaceLayers.tsx"
|
|
37
23
|
|
|
24
|
+
/**
|
|
25
|
+
* Props for {@linkcode Geocoder}.
|
|
26
|
+
*/
|
|
38
27
|
export interface GeocoderProps {
|
|
39
28
|
/**
|
|
40
|
-
* The
|
|
29
|
+
* The geocoder runtime supplies the map style and overlays.
|
|
30
|
+
*
|
|
31
|
+
* It also supplies the parser and version and backend controls.
|
|
41
32
|
*/
|
|
42
33
|
runtime: GeocoderRuntime
|
|
43
34
|
/**
|
|
44
|
-
*
|
|
35
|
+
* Panels supplied by the host.
|
|
45
36
|
*/
|
|
46
37
|
panels?: GeocoderPanels
|
|
47
38
|
/**
|
|
48
|
-
*
|
|
39
|
+
* The address that pre-fills the search field.
|
|
40
|
+
* It is not run automatically.
|
|
49
41
|
*/
|
|
50
42
|
defaultAddress?: string
|
|
51
43
|
/**
|
|
52
|
-
*
|
|
44
|
+
* A query to run once when the runtime is ready, such as a permalink's `?q=` value.
|
|
45
|
+
*
|
|
46
|
+
* Unlike {@link GeocoderProps.defaultAddress}, this query is submitted,
|
|
47
|
+
* so a shared link reproduces its result.
|
|
48
|
+
*/
|
|
49
|
+
initialQuery?: string | null
|
|
50
|
+
/**
|
|
51
|
+
* The example chips.
|
|
52
|
+
*
|
|
53
|
+
* @default []
|
|
53
54
|
*/
|
|
54
55
|
presets?: ReadonlyArray<Preset>
|
|
55
56
|
/**
|
|
56
|
-
*
|
|
57
|
-
*
|
|
57
|
+
* Whether the developer panel starts open.
|
|
58
|
+
*
|
|
59
|
+
* @default false
|
|
60
|
+
*/
|
|
61
|
+
developer?: boolean
|
|
62
|
+
/**
|
|
63
|
+
* Called with each user-submitted query.
|
|
64
|
+
*
|
|
65
|
+
* The host decides how to write the query to its URL.
|
|
66
|
+
* This package never touches `location`.
|
|
67
|
+
*/
|
|
68
|
+
onSubmitQuery?: (query: string) => void
|
|
69
|
+
/**
|
|
70
|
+
* The minimum map zoom at which the viewport is sent as a location bias.
|
|
71
|
+
*
|
|
72
|
+
* @default 4
|
|
58
73
|
*/
|
|
59
74
|
minBiasZoom?: number
|
|
60
75
|
/**
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
76
|
+
* Whether the map moves to each resolved place.
|
|
77
|
+
*
|
|
78
|
+
* Set it to false when the host controls the camera or a test needs a fixed view.
|
|
79
|
+
* The marker and outline render either way.
|
|
80
|
+
*
|
|
81
|
+
* @default true
|
|
64
82
|
*/
|
|
65
83
|
applyResultCamera?: boolean
|
|
66
84
|
}
|
|
67
85
|
|
|
68
86
|
interface GeocoderInnerProps extends Required<
|
|
69
|
-
Pick<GeocoderProps, "runtime" | "defaultAddress" | "minBiasZoom" | "applyResultCamera">
|
|
87
|
+
Pick<GeocoderProps, "runtime" | "defaultAddress" | "minBiasZoom" | "applyResultCamera" | "developer">
|
|
70
88
|
> {
|
|
71
89
|
panels: GeocoderPanels
|
|
72
90
|
presets: ReadonlyArray<Preset>
|
|
91
|
+
initialQuery: string | null
|
|
92
|
+
onSubmitQuery?: (query: string) => void
|
|
73
93
|
}
|
|
74
94
|
|
|
75
95
|
function GeocoderInner({
|
|
@@ -79,42 +99,44 @@ function GeocoderInner({
|
|
|
79
99
|
presets,
|
|
80
100
|
minBiasZoom,
|
|
81
101
|
applyResultCamera,
|
|
102
|
+
developer,
|
|
103
|
+
initialQuery,
|
|
104
|
+
onSubmitQuery,
|
|
82
105
|
}: GeocoderInnerProps): ReactNode {
|
|
83
106
|
const mapRef = useRef<MapRef>(null)
|
|
107
|
+
// The controls render outside `<MapCanvas>` and cannot call `useMap()`.
|
|
108
|
+
// The map is kept in state so they re-render when it loads.
|
|
109
|
+
const [map, setMap] = useState<ReturnType<MapRef["getMap"]> | null>(null)
|
|
84
110
|
|
|
85
|
-
//
|
|
86
|
-
|
|
87
|
-
// republished on `globalThis.__mailwomanMapCanvas`. The ref fills only after react-map-gl instantiates
|
|
88
|
-
// the map, hence the short poll; cleared on unmount so a torn-down geocoder never leaves a stale
|
|
89
|
-
// handle behind.
|
|
90
|
-
useEffect(() => {
|
|
91
|
-
const host = globalThis as { __mailwomanMapCanvas?: ReturnType<MapRef["getMap"]> }
|
|
111
|
+
// The graticule is inserted before the first non-background layer, so it draws under the data layers.
|
|
112
|
+
const [baseLayerID, setBaseLayerID] = useState<string | undefined>(undefined)
|
|
92
113
|
|
|
93
|
-
|
|
94
|
-
|
|
114
|
+
const onMapLoad = useCallback((event: { target: ReturnType<MapRef["getMap"]> }) => {
|
|
115
|
+
// Browser tests read the map from this global.
|
|
116
|
+
;(globalThis as { __mailwomanMapCanvas?: ReturnType<MapRef["getMap"]> }).__mailwomanMapCanvas = event.target
|
|
117
|
+
setMap(event.target)
|
|
95
118
|
|
|
96
|
-
|
|
97
|
-
host.__mailwomanMapCanvas = map
|
|
98
|
-
clearInterval(timer)
|
|
99
|
-
}
|
|
100
|
-
}, 250)
|
|
119
|
+
const layers = event.target.getStyle()?.layers ?? []
|
|
101
120
|
|
|
102
|
-
|
|
103
|
-
clearInterval(timer)
|
|
104
|
-
delete host.__mailwomanMapCanvas
|
|
105
|
-
}
|
|
121
|
+
setBaseLayerID(layers.find((layer) => layer.type !== "background")?.id)
|
|
106
122
|
}, [])
|
|
107
123
|
|
|
108
|
-
|
|
109
|
-
|
|
124
|
+
useEffect(
|
|
125
|
+
() => () => {
|
|
126
|
+
setMap(null)
|
|
127
|
+
delete (globalThis as { __mailwomanMapCanvas?: ReturnType<MapRef["getMap"]> }).__mailwomanMapCanvas
|
|
128
|
+
},
|
|
129
|
+
[]
|
|
130
|
+
)
|
|
131
|
+
|
|
110
132
|
const getBias = useCallback((): MapBias | null => {
|
|
111
|
-
const
|
|
133
|
+
const live = mapRef.current?.getMap()
|
|
112
134
|
|
|
113
|
-
if (!
|
|
114
|
-
const zoom =
|
|
135
|
+
if (!live) return null
|
|
136
|
+
const zoom = live.getZoom()
|
|
115
137
|
|
|
116
138
|
if (zoom < minBiasZoom) return null
|
|
117
|
-
const center =
|
|
139
|
+
const center = live.getCenter()
|
|
118
140
|
|
|
119
141
|
return { center: [center.lng, center.lat], zoom }
|
|
120
142
|
}, [minBiasZoom])
|
|
@@ -152,10 +174,11 @@ function GeocoderInner({
|
|
|
152
174
|
zoom: runtime.initialZoom ?? 3,
|
|
153
175
|
}}
|
|
154
176
|
style={{ width: "100%", height: "100%" }}
|
|
155
|
-
//
|
|
156
|
-
//
|
|
157
|
-
mapProps={{ attributionControl: { compact: true }, maplibreLogo: false }}
|
|
177
|
+
// The attribution is compact.
|
|
178
|
+
// The MapLibre logo is hidden.
|
|
179
|
+
mapProps={{ attributionControl: { compact: true }, maplibreLogo: false, onLoad: onMapLoad }}
|
|
158
180
|
>
|
|
181
|
+
<GraticuleLayer beforeID={baseLayerID} />
|
|
159
182
|
<OverlayLayers overlays={runtime.overlays} />
|
|
160
183
|
<ResolvedPlaceLayers spec={spec} applyCamera={applyResultCamera} />
|
|
161
184
|
{panels.mapControls}
|
|
@@ -170,23 +193,28 @@ function GeocoderInner({
|
|
|
170
193
|
panels={panels}
|
|
171
194
|
presets={presets}
|
|
172
195
|
placeholder={defaultAddress}
|
|
196
|
+
initialQuery={initialQuery}
|
|
197
|
+
map={map}
|
|
198
|
+
onSubmitQuery={onSubmitQuery}
|
|
173
199
|
onSelectVersion={onSelectVersion}
|
|
174
200
|
onForceWASMChange={onForceWASMChange}
|
|
201
|
+
developer={developer}
|
|
175
202
|
/>
|
|
176
|
-
|
|
177
203
|
{panels.debugDrawer ? panels.debugDrawer({ result: geocode.result }) : null}
|
|
178
204
|
</div>
|
|
179
205
|
)
|
|
180
206
|
}
|
|
181
207
|
|
|
182
|
-
|
|
183
|
-
* Stable empty defaults — a fresh `{}`/`[]` per render would churn every downstream memo dep.
|
|
184
|
-
*/
|
|
208
|
+
// These defaults are module constants so each render sees the same reference and memo dependencies stay stable.
|
|
185
209
|
const NO_PANELS: GeocoderPanels = {}
|
|
186
210
|
const NO_PRESETS: ReadonlyArray<Preset> = []
|
|
187
211
|
|
|
188
212
|
/**
|
|
189
|
-
*
|
|
213
|
+
* Renders the map and search controls as one geocoder.
|
|
214
|
+
* It also renders host panels.
|
|
215
|
+
*
|
|
216
|
+
* It renders only on the client because MapLibre needs browser APIs.
|
|
217
|
+
* Import it from `@mailwoman/react/map`.
|
|
190
218
|
*/
|
|
191
219
|
export function Geocoder({
|
|
192
220
|
runtime,
|
|
@@ -195,6 +223,9 @@ export function Geocoder({
|
|
|
195
223
|
presets = NO_PRESETS,
|
|
196
224
|
minBiasZoom = 4,
|
|
197
225
|
applyResultCamera = true,
|
|
226
|
+
developer = false,
|
|
227
|
+
initialQuery = null,
|
|
228
|
+
onSubmitQuery,
|
|
198
229
|
}: GeocoderProps): ReactNode {
|
|
199
230
|
return (
|
|
200
231
|
<ClientOnly
|
|
@@ -212,6 +243,9 @@ export function Geocoder({
|
|
|
212
243
|
presets={presets}
|
|
213
244
|
minBiasZoom={minBiasZoom}
|
|
214
245
|
applyResultCamera={applyResultCamera}
|
|
246
|
+
developer={developer}
|
|
247
|
+
initialQuery={initialQuery}
|
|
248
|
+
onSubmitQuery={onSubmitQuery}
|
|
215
249
|
/>
|
|
216
250
|
)}
|
|
217
251
|
</ClientOnly>
|