@classic-homes/maps-react 0.5.3 → 0.6.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 +4 -0
- package/dist/index.cjs +266 -223
- package/dist/index.css +1049 -0
- package/dist/index.js +261 -213
- package/package.json +8 -4
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as React6 from 'react';
|
|
2
2
|
import { useState, useEffect, useCallback } from 'react';
|
|
3
3
|
import { clsx } from 'clsx';
|
|
4
4
|
import { twMerge } from 'tailwind-merge';
|
|
@@ -7,7 +7,7 @@ import maplibregl from 'maplibre-gl';
|
|
|
7
7
|
import 'maplibre-gl/dist/maplibre-gl.css';
|
|
8
8
|
import '@classic-homes/maps-core/styles/controls.css';
|
|
9
9
|
import '@classic-homes/maps-core/styles/marker.css';
|
|
10
|
-
import { createPositioningCoordinator, generateMapDescription, applyMarkerProtection, applyMarkerChildProtection, removeMarkerProtection, DEFAULT_BASEMAP, darkTheme, lightTheme, THEME_DARK, THEME_LIGHT, calculateBounds, getChangedPaintProps, EDGE_MARGIN, formatCoordinates, getAvailableBasemaps, FREE_BASEMAPS, resolveBasemapThumbnail, createInitialLayerStates, getLayerCategories, searchLayers, groupLayersByCategory, toggleLayerVisibility, setLayerOpacity, getLayerStatesArray, reorderLayers, CATEGORY_META, resolveBasemapStyle, STACK_GAP, getLayerStyleForTheme, resolveLayerSourceUrl } from '@classic-homes/maps-core';
|
|
10
|
+
import { createPositioningCoordinator, generateMapDescription, applyMarkerProtection, applyMarkerChildProtection, removeMarkerProtection, DEFAULT_BASEMAP, darkTheme, lightTheme, THEME_DARK, THEME_LIGHT, calculateBounds, getChangedPaintProps, EDGE_MARGIN, formatCoordinates, getAvailableBasemaps, FREE_BASEMAPS, resolveBasemapThumbnail, createInitialLayerStates, getLayerCategories, searchLayers, groupLayersByCategory, toggleLayerVisibility, setLayerOpacity, getLayerStatesArray, reorderLayers, CATEGORY_META, resolveBasemapStyle, getGridNavigationIndex, STACK_GAP, getLayerStyleForTheme, resolveLayerSourceUrl } from '@classic-homes/maps-core';
|
|
11
11
|
export { BIKE_LANES, BUILTIN_BASEMAPS, BUILTIN_OVERLAY_LAYERS, CATEGORY_META, CITY_LIMITS, DEFAULT_BASEMAP, FLOOD_ZONES, FREE_BASEMAPS, OSM_STANDARD, PARKS, PRIMARY_BASEMAPS, SATELLITE_BASEMAP, SCHOOL_DISTRICTS, SPORTS_FACILITIES, THEME_DARK, THEME_LIGHT, TOPO_BASEMAP, TRAILS, TRANSIT_ROUTES, WATERSHEDS, ZONING_DISTRICTS, calculateBounds, calculateCentroid, combineBounds, countFeaturesByType, createClusterCirclePaint, createClusterStyles, createClusterTextLayout, createHoverExpression, createInitialLayerStates, createSelectionExpression, darkBasicStyle, darkTheme, expandCluster, expandClusterToBounds, extendBounds, filterByGeometryType, formatArea, formatCoordinates, formatDistance, generateMapDescription, getAvailableBasemaps, getClusterBounds, getClusterChildren, getClusterExpansionZoom, getClusterLeaves, getHighlightStyle, getLayerCategories, getLayerStyleForTheme, getLayersByCategory, getSelectionStyle, groupLayersByCategory, isClusterFeature, isValidBounds, lightBasicStyle, lightTheme, loadGeoJSON, resolveBasemapStyle, resolveLayerSourceUrl, searchLayers, setLayerOpacity, toggleLayerVisibility, validateGeoJSON } from '@classic-homes/maps-core';
|
|
12
12
|
import * as ReactDOM from 'react-dom';
|
|
13
13
|
import { panToFitPopup, normalizePadding } from '@classic-homes/maps-core/utils';
|
|
@@ -20,7 +20,7 @@ import { Switch } from '@classic-homes/theme-react';
|
|
|
20
20
|
function cn(...inputs) {
|
|
21
21
|
return twMerge(clsx(inputs));
|
|
22
22
|
}
|
|
23
|
-
var MapSkeleton =
|
|
23
|
+
var MapSkeleton = React6.forwardRef(
|
|
24
24
|
({ height = 400, className, ...props }, ref) => {
|
|
25
25
|
const heightStyle = typeof height === "number" ? `${height}px` : height;
|
|
26
26
|
return /* @__PURE__ */ jsxs(
|
|
@@ -74,7 +74,7 @@ var MapSkeleton = React26.forwardRef(
|
|
|
74
74
|
}
|
|
75
75
|
);
|
|
76
76
|
MapSkeleton.displayName = "MapSkeleton";
|
|
77
|
-
var MapError =
|
|
77
|
+
var MapError = React6.forwardRef(
|
|
78
78
|
({ message = "Failed to load map", height = 400, onRetry, className, ...props }, ref) => {
|
|
79
79
|
const heightStyle = typeof height === "number" ? `${height}px` : height;
|
|
80
80
|
return /* @__PURE__ */ jsx(
|
|
@@ -120,7 +120,7 @@ var MapError = React26.forwardRef(
|
|
|
120
120
|
"button",
|
|
121
121
|
{
|
|
122
122
|
onClick: onRetry,
|
|
123
|
-
className: "mt-2 rounded-md border border-input bg-background px-4 py-2 text-sm font-medium shadow-sm
|
|
123
|
+
className: "mt-2 rounded-md border border-input bg-background px-4 py-2 text-sm font-medium shadow-sm hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
|
|
124
124
|
children: "Retry"
|
|
125
125
|
}
|
|
126
126
|
)
|
|
@@ -130,7 +130,7 @@ var MapError = React26.forwardRef(
|
|
|
130
130
|
}
|
|
131
131
|
);
|
|
132
132
|
MapError.displayName = "MapError";
|
|
133
|
-
var MapEmpty =
|
|
133
|
+
var MapEmpty = React6.forwardRef(
|
|
134
134
|
({ message = "No map data to display", height = 400, className, ...props }, ref) => {
|
|
135
135
|
const heightStyle = typeof height === "number" ? `${height}px` : height;
|
|
136
136
|
return /* @__PURE__ */ jsx(
|
|
@@ -173,7 +173,7 @@ var MapEmpty = React26.forwardRef(
|
|
|
173
173
|
}
|
|
174
174
|
);
|
|
175
175
|
MapEmpty.displayName = "MapEmpty";
|
|
176
|
-
var MapContainer =
|
|
176
|
+
var MapContainer = React6.forwardRef(
|
|
177
177
|
({
|
|
178
178
|
title,
|
|
179
179
|
description,
|
|
@@ -279,9 +279,9 @@ function useReducedMotion() {
|
|
|
279
279
|
}, []);
|
|
280
280
|
return prefersReducedMotion;
|
|
281
281
|
}
|
|
282
|
-
var MapContext =
|
|
282
|
+
var MapContext = React6.createContext(null);
|
|
283
283
|
function useMap() {
|
|
284
|
-
const context =
|
|
284
|
+
const context = React6.useContext(MapContext);
|
|
285
285
|
if (!context) {
|
|
286
286
|
throw new Error("useMap must be used within a Map component");
|
|
287
287
|
}
|
|
@@ -291,7 +291,11 @@ function useMapInstance() {
|
|
|
291
291
|
const { map, loaded } = useMap();
|
|
292
292
|
return loaded ? map : null;
|
|
293
293
|
}
|
|
294
|
-
|
|
294
|
+
function getStyleKey(style) {
|
|
295
|
+
if (!style) return "";
|
|
296
|
+
return typeof style === "string" ? style : JSON.stringify(style);
|
|
297
|
+
}
|
|
298
|
+
var Map2 = React6.forwardRef(
|
|
295
299
|
({
|
|
296
300
|
// Base props
|
|
297
301
|
title,
|
|
@@ -346,30 +350,30 @@ var Map2 = React26.forwardRef(
|
|
|
346
350
|
onZoom,
|
|
347
351
|
onError
|
|
348
352
|
}, ref) => {
|
|
349
|
-
const containerRef =
|
|
350
|
-
const mapRef =
|
|
351
|
-
const [mapLoaded, setMapLoaded] =
|
|
352
|
-
const [mapError, setMapError] =
|
|
353
|
-
const [initAttempt, setInitAttempt] =
|
|
354
|
-
const retryInit =
|
|
353
|
+
const containerRef = React6.useRef(null);
|
|
354
|
+
const mapRef = React6.useRef(null);
|
|
355
|
+
const [mapLoaded, setMapLoaded] = React6.useState(false);
|
|
356
|
+
const [mapError, setMapError] = React6.useState(null);
|
|
357
|
+
const [initAttempt, setInitAttempt] = React6.useState(0);
|
|
358
|
+
const retryInit = React6.useCallback(() => {
|
|
355
359
|
setMapError(null);
|
|
356
360
|
setInitAttempt((attempt) => attempt + 1);
|
|
357
361
|
}, []);
|
|
358
|
-
const [styleVersion, setStyleVersion] =
|
|
359
|
-
const styleVersionRef =
|
|
360
|
-
const bumpStyleVersion =
|
|
362
|
+
const [styleVersion, setStyleVersion] = React6.useState(0);
|
|
363
|
+
const styleVersionRef = React6.useRef(0);
|
|
364
|
+
const bumpStyleVersion = React6.useCallback(() => {
|
|
361
365
|
styleVersionRef.current += 1;
|
|
362
366
|
setStyleVersion(styleVersionRef.current);
|
|
363
367
|
}, []);
|
|
364
|
-
const activeStyleOverrideRef =
|
|
368
|
+
const activeStyleOverrideRef = React6.useRef(
|
|
365
369
|
null
|
|
366
370
|
);
|
|
367
|
-
const positioningCoordinatorRef =
|
|
371
|
+
const positioningCoordinatorRef = React6.useRef(null);
|
|
368
372
|
if (!positioningCoordinatorRef.current) {
|
|
369
373
|
positioningCoordinatorRef.current = createPositioningCoordinator();
|
|
370
374
|
}
|
|
371
375
|
const positioningCoordinator = positioningCoordinatorRef.current;
|
|
372
|
-
const setMapStyle =
|
|
376
|
+
const setMapStyle = React6.useCallback(
|
|
373
377
|
(style) => {
|
|
374
378
|
activeStyleOverrideRef.current = style;
|
|
375
379
|
const map = mapRef.current;
|
|
@@ -384,16 +388,20 @@ var Map2 = React26.forwardRef(
|
|
|
384
388
|
);
|
|
385
389
|
const prefersReducedMotion = useReducedMotion();
|
|
386
390
|
const { style: themeStyle } = useMapTheme(themePref);
|
|
387
|
-
const onLoadRef =
|
|
391
|
+
const onLoadRef = React6.useRef(onLoad);
|
|
388
392
|
onLoadRef.current = onLoad;
|
|
389
|
-
const onErrorRef =
|
|
393
|
+
const onErrorRef = React6.useRef(onError);
|
|
390
394
|
onErrorRef.current = onError;
|
|
391
395
|
const mapStyle = customStyle || themeStyle;
|
|
396
|
+
const mapStyleKey = React6.useMemo(() => getStyleKey(mapStyle), [mapStyle]);
|
|
397
|
+
const customStyleKey = React6.useMemo(() => getStyleKey(customStyle), [customStyle]);
|
|
398
|
+
const mapStyleRef = React6.useRef(mapStyle);
|
|
399
|
+
mapStyleRef.current = mapStyle;
|
|
392
400
|
const accessibleDescription = description || generateMapDescription(title, {
|
|
393
401
|
center,
|
|
394
402
|
zoom
|
|
395
403
|
});
|
|
396
|
-
|
|
404
|
+
React6.useEffect(() => {
|
|
397
405
|
if (!containerRef.current || !positioningCoordinator) return;
|
|
398
406
|
const updateDimensions = () => {
|
|
399
407
|
if (!containerRef.current) return;
|
|
@@ -409,12 +417,12 @@ var Map2 = React26.forwardRef(
|
|
|
409
417
|
resizeObserver.disconnect();
|
|
410
418
|
};
|
|
411
419
|
}, [positioningCoordinator]);
|
|
412
|
-
|
|
420
|
+
React6.useEffect(() => {
|
|
413
421
|
return () => {
|
|
414
422
|
positioningCoordinator.destroy();
|
|
415
423
|
};
|
|
416
424
|
}, [positioningCoordinator]);
|
|
417
|
-
|
|
425
|
+
React6.useEffect(() => {
|
|
418
426
|
if (!containerRef.current || mapRef.current) return;
|
|
419
427
|
try {
|
|
420
428
|
const map = new maplibregl.Map({
|
|
@@ -573,7 +581,7 @@ var Map2 = React26.forwardRef(
|
|
|
573
581
|
});
|
|
574
582
|
}
|
|
575
583
|
}, [initAttempt]);
|
|
576
|
-
|
|
584
|
+
React6.useEffect(() => {
|
|
577
585
|
const map = mapRef.current;
|
|
578
586
|
if (!map || !mapLoaded) return;
|
|
579
587
|
map.on("style.load", bumpStyleVersion);
|
|
@@ -581,22 +589,22 @@ var Map2 = React26.forwardRef(
|
|
|
581
589
|
map.off("style.load", bumpStyleVersion);
|
|
582
590
|
};
|
|
583
591
|
}, [mapLoaded, bumpStyleVersion]);
|
|
584
|
-
const styleInitialized =
|
|
585
|
-
|
|
592
|
+
const styleInitialized = React6.useRef(false);
|
|
593
|
+
React6.useEffect(() => {
|
|
586
594
|
if (!mapRef.current || !mapLoaded) return;
|
|
587
595
|
if (!styleInitialized.current) {
|
|
588
596
|
styleInitialized.current = true;
|
|
589
597
|
return;
|
|
590
598
|
}
|
|
591
599
|
if (activeStyleOverrideRef.current) return;
|
|
592
|
-
mapRef.current.setStyle(
|
|
593
|
-
}, [
|
|
594
|
-
|
|
595
|
-
if (
|
|
600
|
+
mapRef.current.setStyle(mapStyleRef.current);
|
|
601
|
+
}, [mapStyleKey, mapLoaded]);
|
|
602
|
+
React6.useEffect(() => {
|
|
603
|
+
if (customStyleKey) {
|
|
596
604
|
activeStyleOverrideRef.current = null;
|
|
597
605
|
}
|
|
598
|
-
}, [
|
|
599
|
-
|
|
606
|
+
}, [customStyleKey]);
|
|
607
|
+
React6.useEffect(() => {
|
|
600
608
|
const map = mapRef.current;
|
|
601
609
|
if (!map || !mapLoaded) return;
|
|
602
610
|
const createEventParams = (e) => ({
|
|
@@ -695,7 +703,7 @@ var Map2 = React26.forwardRef(
|
|
|
695
703
|
onZoom
|
|
696
704
|
]);
|
|
697
705
|
const combinedError = error || mapError;
|
|
698
|
-
const contextValue =
|
|
706
|
+
const contextValue = React6.useMemo(
|
|
699
707
|
() => ({
|
|
700
708
|
map: mapRef.current,
|
|
701
709
|
loaded: mapLoaded,
|
|
@@ -727,6 +735,7 @@ var Map2 = React26.forwardRef(
|
|
|
727
735
|
}
|
|
728
736
|
);
|
|
729
737
|
Map2.displayName = "Map";
|
|
738
|
+
var SourceContext = React6.createContext(null);
|
|
730
739
|
var Source = ({
|
|
731
740
|
id,
|
|
732
741
|
type,
|
|
@@ -747,10 +756,10 @@ var Source = ({
|
|
|
747
756
|
children
|
|
748
757
|
}) => {
|
|
749
758
|
const { map, loaded, styleVersion } = useMap();
|
|
750
|
-
const initialFitDone =
|
|
751
|
-
const
|
|
752
|
-
const
|
|
753
|
-
const fitBoundsParamsRef =
|
|
759
|
+
const initialFitDone = React6.useRef(false);
|
|
760
|
+
const appliedDataRef = React6.useRef(void 0);
|
|
761
|
+
const [sourceVersion, setSourceVersion] = React6.useState(0);
|
|
762
|
+
const fitBoundsParamsRef = React6.useRef({
|
|
754
763
|
shouldFitBounds,
|
|
755
764
|
data,
|
|
756
765
|
fitBoundsPadding,
|
|
@@ -766,7 +775,7 @@ var Source = ({
|
|
|
766
775
|
fitBoundsAnimate,
|
|
767
776
|
type
|
|
768
777
|
};
|
|
769
|
-
const performFitBounds =
|
|
778
|
+
const performFitBounds = React6.useCallback(
|
|
770
779
|
(cancelledRef) => {
|
|
771
780
|
const params = fitBoundsParamsRef.current;
|
|
772
781
|
if (cancelledRef.current || !params.shouldFitBounds || initialFitDone.current) return;
|
|
@@ -810,12 +819,8 @@ var Source = ({
|
|
|
810
819
|
},
|
|
811
820
|
[map]
|
|
812
821
|
);
|
|
813
|
-
|
|
822
|
+
React6.useEffect(() => {
|
|
814
823
|
if (!map || !loaded) return;
|
|
815
|
-
if (styleVersion !== lastStyleVersionRef.current) {
|
|
816
|
-
lastStyleVersionRef.current = styleVersion;
|
|
817
|
-
initialFitDone.current = false;
|
|
818
|
-
}
|
|
819
824
|
if (map.getSource(id)) {
|
|
820
825
|
return;
|
|
821
826
|
}
|
|
@@ -904,6 +909,7 @@ var Source = ({
|
|
|
904
909
|
map.once("idle", handleIdle);
|
|
905
910
|
map.addSource(id, sourceConfig);
|
|
906
911
|
appliedDataRef.current = type === "geojson" ? data : void 0;
|
|
912
|
+
setSourceVersion((v) => v + 1);
|
|
907
913
|
const source = map.getSource(id);
|
|
908
914
|
if (source && map.isSourceLoaded(id)) {
|
|
909
915
|
map.off("sourcedata", handleSourceData);
|
|
@@ -962,7 +968,7 @@ var Source = ({
|
|
|
962
968
|
styleVersion
|
|
963
969
|
// re-add source after basemap style changes
|
|
964
970
|
]);
|
|
965
|
-
|
|
971
|
+
React6.useEffect(() => {
|
|
966
972
|
if (!map || !loaded || type !== "geojson") return;
|
|
967
973
|
const source = map.getSource(id);
|
|
968
974
|
if (!source) return;
|
|
@@ -993,10 +999,11 @@ var Source = ({
|
|
|
993
999
|
console.error(`[maps-react] Failed to update source "${id}" data:`, err);
|
|
994
1000
|
}
|
|
995
1001
|
}, [map, loaded, id, type, data, cluster]);
|
|
996
|
-
|
|
1002
|
+
const sourceContext = React6.useMemo(() => ({ id, version: sourceVersion }), [id, sourceVersion]);
|
|
1003
|
+
return /* @__PURE__ */ jsx(SourceContext.Provider, { value: sourceContext, children });
|
|
997
1004
|
};
|
|
998
1005
|
Source.displayName = "Source";
|
|
999
|
-
var Marker =
|
|
1006
|
+
var Marker = React6.forwardRef(
|
|
1000
1007
|
({
|
|
1001
1008
|
id,
|
|
1002
1009
|
coordinates,
|
|
@@ -1012,30 +1019,30 @@ var Marker = React26.forwardRef(
|
|
|
1012
1019
|
children
|
|
1013
1020
|
}, ref) => {
|
|
1014
1021
|
const { map, loaded } = useMap();
|
|
1015
|
-
const markerRef =
|
|
1016
|
-
const elementRef =
|
|
1017
|
-
const originalLngLatRef =
|
|
1018
|
-
const clickHandlerRef =
|
|
1019
|
-
const dragStartHandlerRef =
|
|
1020
|
-
const dragHandlerRef =
|
|
1021
|
-
const dragEndHandlerRef =
|
|
1022
|
-
const [mounted, setMounted] =
|
|
1023
|
-
const onClickRef =
|
|
1022
|
+
const markerRef = React6.useRef(null);
|
|
1023
|
+
const elementRef = React6.useRef(null);
|
|
1024
|
+
const originalLngLatRef = React6.useRef();
|
|
1025
|
+
const clickHandlerRef = React6.useRef(null);
|
|
1026
|
+
const dragStartHandlerRef = React6.useRef(null);
|
|
1027
|
+
const dragHandlerRef = React6.useRef(null);
|
|
1028
|
+
const dragEndHandlerRef = React6.useRef(null);
|
|
1029
|
+
const [mounted, setMounted] = React6.useState(false);
|
|
1030
|
+
const onClickRef = React6.useRef(onClick);
|
|
1024
1031
|
onClickRef.current = onClick;
|
|
1025
|
-
const onDragRef =
|
|
1032
|
+
const onDragRef = React6.useRef(onDrag);
|
|
1026
1033
|
onDragRef.current = onDrag;
|
|
1027
|
-
const onDragEndRef =
|
|
1034
|
+
const onDragEndRef = React6.useRef(onDragEnd);
|
|
1028
1035
|
onDragEndRef.current = onDragEnd;
|
|
1029
|
-
|
|
1036
|
+
React6.useEffect(() => {
|
|
1030
1037
|
setMounted(true);
|
|
1031
1038
|
return () => setMounted(false);
|
|
1032
1039
|
}, []);
|
|
1033
|
-
|
|
1040
|
+
React6.useEffect(() => {
|
|
1034
1041
|
if (children && !elementRef.current) {
|
|
1035
1042
|
elementRef.current = document.createElement("div");
|
|
1036
1043
|
}
|
|
1037
1044
|
}, [children]);
|
|
1038
|
-
|
|
1045
|
+
React6.useEffect(() => {
|
|
1039
1046
|
if (!map || !loaded || !mounted) return;
|
|
1040
1047
|
if (markerRef.current) return;
|
|
1041
1048
|
const markerOptions = {
|
|
@@ -1139,12 +1146,12 @@ var Marker = React26.forwardRef(
|
|
|
1139
1146
|
}
|
|
1140
1147
|
};
|
|
1141
1148
|
}, [map, loaded, mounted]);
|
|
1142
|
-
|
|
1149
|
+
React6.useEffect(() => {
|
|
1143
1150
|
if (markerRef.current) {
|
|
1144
1151
|
markerRef.current.setLngLat(coordinates);
|
|
1145
1152
|
}
|
|
1146
1153
|
}, [coordinates]);
|
|
1147
|
-
|
|
1154
|
+
React6.useEffect(() => {
|
|
1148
1155
|
const marker = markerRef.current;
|
|
1149
1156
|
if (!marker) return;
|
|
1150
1157
|
marker.setDraggable(draggable);
|
|
@@ -1192,12 +1199,12 @@ var Marker = React26.forwardRef(
|
|
|
1192
1199
|
marker.on("dragend", handleDragEnd);
|
|
1193
1200
|
}
|
|
1194
1201
|
}, [draggable, id]);
|
|
1195
|
-
|
|
1202
|
+
React6.useEffect(() => {
|
|
1196
1203
|
if (markerRef.current && rotation !== void 0) {
|
|
1197
1204
|
markerRef.current.setRotation(rotation);
|
|
1198
1205
|
}
|
|
1199
1206
|
}, [rotation]);
|
|
1200
|
-
|
|
1207
|
+
React6.useEffect(() => {
|
|
1201
1208
|
if (markerRef.current && offset) {
|
|
1202
1209
|
markerRef.current.setOffset(offset);
|
|
1203
1210
|
}
|
|
@@ -1210,13 +1217,13 @@ var Marker = React26.forwardRef(
|
|
|
1210
1217
|
);
|
|
1211
1218
|
Marker.displayName = "Marker";
|
|
1212
1219
|
function useStructuralValue(next) {
|
|
1213
|
-
const ref =
|
|
1220
|
+
const ref = React6.useRef(next);
|
|
1214
1221
|
if (ref.current !== next && JSON.stringify(ref.current) !== JSON.stringify(next)) {
|
|
1215
1222
|
ref.current = next;
|
|
1216
1223
|
}
|
|
1217
1224
|
return ref.current;
|
|
1218
1225
|
}
|
|
1219
|
-
var Popup =
|
|
1226
|
+
var Popup = React6.forwardRef(
|
|
1220
1227
|
({
|
|
1221
1228
|
coordinates: coordinatesProp,
|
|
1222
1229
|
closeButton = true,
|
|
@@ -1237,26 +1244,26 @@ var Popup = React26.forwardRef(
|
|
|
1237
1244
|
const coordinates = useStructuralValue(coordinatesProp);
|
|
1238
1245
|
const offset = useStructuralValue(offsetProp);
|
|
1239
1246
|
const autoPanPadding = useStructuralValue(autoPanPaddingProp);
|
|
1240
|
-
const popupRef =
|
|
1241
|
-
const onOpenRef =
|
|
1247
|
+
const popupRef = React6.useRef(null);
|
|
1248
|
+
const onOpenRef = React6.useRef(onOpen);
|
|
1242
1249
|
onOpenRef.current = onOpen;
|
|
1243
|
-
const onCloseRef =
|
|
1250
|
+
const onCloseRef = React6.useRef(onClose);
|
|
1244
1251
|
onCloseRef.current = onClose;
|
|
1245
|
-
const coordinatesRef =
|
|
1252
|
+
const coordinatesRef = React6.useRef(coordinates);
|
|
1246
1253
|
coordinatesRef.current = coordinates;
|
|
1247
|
-
const containerRef =
|
|
1254
|
+
const containerRef = React6.useRef(null);
|
|
1248
1255
|
if (!containerRef.current && typeof document !== "undefined") {
|
|
1249
1256
|
containerRef.current = document.createElement("div");
|
|
1250
1257
|
containerRef.current.className = "maplibregl-popup-content-wrapper";
|
|
1251
1258
|
}
|
|
1252
|
-
const [contentReady, setContentReady] =
|
|
1253
|
-
const [popupVersion, setPopupVersion] =
|
|
1254
|
-
const contentCallbackRef =
|
|
1259
|
+
const [contentReady, setContentReady] = React6.useState(false);
|
|
1260
|
+
const [popupVersion, setPopupVersion] = React6.useState(0);
|
|
1261
|
+
const contentCallbackRef = React6.useCallback((node) => {
|
|
1255
1262
|
if (node && containerRef.current) {
|
|
1256
1263
|
setContentReady(true);
|
|
1257
1264
|
}
|
|
1258
1265
|
}, []);
|
|
1259
|
-
|
|
1266
|
+
React6.useEffect(() => {
|
|
1260
1267
|
if (!map || !loaded || !containerRef.current) return;
|
|
1261
1268
|
const popup = new maplibregl.Popup({
|
|
1262
1269
|
closeButton,
|
|
@@ -1297,7 +1304,7 @@ var Popup = React26.forwardRef(
|
|
|
1297
1304
|
maxWidth,
|
|
1298
1305
|
focusAfterOpen
|
|
1299
1306
|
]);
|
|
1300
|
-
|
|
1307
|
+
React6.useEffect(() => {
|
|
1301
1308
|
if (!popupRef.current || !ref) return;
|
|
1302
1309
|
if (typeof ref === "function") {
|
|
1303
1310
|
ref(popupRef.current);
|
|
@@ -1305,16 +1312,17 @@ var Popup = React26.forwardRef(
|
|
|
1305
1312
|
ref.current = popupRef.current;
|
|
1306
1313
|
}
|
|
1307
1314
|
}, [ref, popupVersion]);
|
|
1308
|
-
|
|
1315
|
+
React6.useEffect(() => {
|
|
1309
1316
|
if (popupRef.current) {
|
|
1310
1317
|
popupRef.current.setLngLat(coordinates);
|
|
1311
1318
|
}
|
|
1312
1319
|
}, [coordinates]);
|
|
1313
|
-
|
|
1320
|
+
React6.useEffect(() => {
|
|
1314
1321
|
if (!map || !popupRef.current || !contentReady) return;
|
|
1315
1322
|
let rafHandle;
|
|
1316
1323
|
if (open) {
|
|
1317
|
-
popupRef.current.setLngLat(coordinates)
|
|
1324
|
+
popupRef.current.setLngLat(coordinates);
|
|
1325
|
+
if (!popupRef.current.isOpen()) popupRef.current.addTo(map);
|
|
1318
1326
|
if (autoPan) {
|
|
1319
1327
|
rafHandle = requestAnimationFrame(() => {
|
|
1320
1328
|
if (popupRef.current && map) {
|
|
@@ -1339,7 +1347,7 @@ var Popup = React26.forwardRef(
|
|
|
1339
1347
|
}
|
|
1340
1348
|
);
|
|
1341
1349
|
Popup.displayName = "Popup";
|
|
1342
|
-
var PopupCard =
|
|
1350
|
+
var PopupCard = React6.forwardRef(
|
|
1343
1351
|
({ className, children, ...props }, ref) => {
|
|
1344
1352
|
return /* @__PURE__ */ jsx("div", { ref, className: cn("bg-popover text-popover-foreground", className), ...props, children });
|
|
1345
1353
|
}
|
|
@@ -1359,7 +1367,7 @@ var badgeVariants = cva("text-xs px-1.5 py-0.5 rounded font-medium flex-shrink-0
|
|
|
1359
1367
|
badgeVariant: "secondary"
|
|
1360
1368
|
}
|
|
1361
1369
|
});
|
|
1362
|
-
var PopupHeader =
|
|
1370
|
+
var PopupHeader = React6.forwardRef(
|
|
1363
1371
|
({ className, title, badge, badgeVariant, ...props }, ref) => {
|
|
1364
1372
|
return /* @__PURE__ */ jsxs(
|
|
1365
1373
|
"div",
|
|
@@ -1379,13 +1387,13 @@ var PopupHeader = React26.forwardRef(
|
|
|
1379
1387
|
}
|
|
1380
1388
|
);
|
|
1381
1389
|
PopupHeader.displayName = "PopupHeader";
|
|
1382
|
-
var PopupContent =
|
|
1390
|
+
var PopupContent = React6.forwardRef(
|
|
1383
1391
|
({ className, children, ...props }, ref) => {
|
|
1384
1392
|
return /* @__PURE__ */ jsx("div", { ref, className: cn("px-4 py-3 text-sm", className), ...props, children });
|
|
1385
1393
|
}
|
|
1386
1394
|
);
|
|
1387
1395
|
PopupContent.displayName = "PopupContent";
|
|
1388
|
-
var PopupFooter =
|
|
1396
|
+
var PopupFooter = React6.forwardRef(
|
|
1389
1397
|
({ className, children, ...props }, ref) => {
|
|
1390
1398
|
return /* @__PURE__ */ jsx(
|
|
1391
1399
|
"div",
|
|
@@ -1402,6 +1410,11 @@ var PopupFooter = React26.forwardRef(
|
|
|
1402
1410
|
}
|
|
1403
1411
|
);
|
|
1404
1412
|
PopupFooter.displayName = "PopupFooter";
|
|
1413
|
+
function withoutVisibility(layout) {
|
|
1414
|
+
const next = { ...layout ?? {} };
|
|
1415
|
+
delete next.visibility;
|
|
1416
|
+
return next;
|
|
1417
|
+
}
|
|
1405
1418
|
function useLayer({
|
|
1406
1419
|
id,
|
|
1407
1420
|
source,
|
|
@@ -1420,40 +1433,32 @@ function useLayer({
|
|
|
1420
1433
|
hoverThrottleMs = 0
|
|
1421
1434
|
}) {
|
|
1422
1435
|
const { map, loaded, styleVersion } = useMap();
|
|
1423
|
-
const
|
|
1424
|
-
const
|
|
1425
|
-
const
|
|
1426
|
-
const
|
|
1427
|
-
|
|
1436
|
+
const sourceContext = React6.useContext(SourceContext);
|
|
1437
|
+
const sourceVersion = sourceContext?.id === source ? sourceContext.version : 0;
|
|
1438
|
+
const [layerAdded, setLayerAdded] = React6.useState(false);
|
|
1439
|
+
const hoveredFeatureId = React6.useRef(null);
|
|
1440
|
+
const lastHoverCallTime = React6.useRef(0);
|
|
1441
|
+
const lastMousePosition = React6.useRef(null);
|
|
1442
|
+
const lastAppliedPaintRef = React6.useRef(void 0);
|
|
1443
|
+
const lastAppliedLayoutRef = React6.useRef(void 0);
|
|
1444
|
+
React6.useEffect(() => {
|
|
1428
1445
|
hoveredFeatureId.current = null;
|
|
1429
1446
|
}, [styleVersion]);
|
|
1430
|
-
|
|
1447
|
+
React6.useEffect(() => {
|
|
1431
1448
|
if (!map || !loaded) return;
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
if (timeoutId) clearTimeout(timeoutId);
|
|
1437
|
-
addLayer();
|
|
1438
|
-
map.off("sourcedata", checkSource);
|
|
1439
|
-
}
|
|
1440
|
-
};
|
|
1441
|
-
timeoutId = setTimeout(() => {
|
|
1442
|
-
if (!map.getSource(source)) {
|
|
1443
|
-
console.warn(
|
|
1444
|
-
`[maps-react] Layer "${id}" is waiting for source "${source}" which has not been added after 5 seconds. Ensure the Source component with id="${source}" is rendered before or alongside this layer.`
|
|
1445
|
-
);
|
|
1446
|
-
}
|
|
1447
|
-
}, 5e3);
|
|
1448
|
-
map.on("sourcedata", checkSource);
|
|
1449
|
-
return () => {
|
|
1449
|
+
let added = false;
|
|
1450
|
+
let timeoutId = null;
|
|
1451
|
+
const checkSource = () => {
|
|
1452
|
+
if (map.getSource(source)) {
|
|
1450
1453
|
if (timeoutId) clearTimeout(timeoutId);
|
|
1454
|
+
timeoutId = null;
|
|
1451
1455
|
map.off("sourcedata", checkSource);
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1456
|
+
addLayer();
|
|
1457
|
+
}
|
|
1458
|
+
};
|
|
1455
1459
|
function addLayer() {
|
|
1456
1460
|
if (map.getLayer(id)) {
|
|
1461
|
+
added = true;
|
|
1457
1462
|
setLayerAdded(true);
|
|
1458
1463
|
return;
|
|
1459
1464
|
}
|
|
@@ -1481,30 +1486,46 @@ function useLayer({
|
|
|
1481
1486
|
layerConfig.filter = filter;
|
|
1482
1487
|
}
|
|
1483
1488
|
map.addLayer(layerConfig, beforeId);
|
|
1489
|
+
added = true;
|
|
1490
|
+
lastAppliedPaintRef.current = { ...paint };
|
|
1491
|
+
lastAppliedLayoutRef.current = withoutVisibility(layout);
|
|
1484
1492
|
setLayerAdded(true);
|
|
1485
1493
|
} catch (err) {
|
|
1486
1494
|
console.error(`[maps-react] Failed to add layer "${id}":`, err);
|
|
1487
1495
|
}
|
|
1488
1496
|
}
|
|
1497
|
+
if (map.getSource(source)) {
|
|
1498
|
+
addLayer();
|
|
1499
|
+
} else {
|
|
1500
|
+
timeoutId = setTimeout(() => {
|
|
1501
|
+
if (!map.getSource(source)) {
|
|
1502
|
+
console.warn(
|
|
1503
|
+
`[maps-react] Layer "${id}" is waiting for source "${source}" which has not been added after 5 seconds. Ensure the Source component with id="${source}" is rendered before or alongside this layer.`
|
|
1504
|
+
);
|
|
1505
|
+
}
|
|
1506
|
+
}, 5e3);
|
|
1507
|
+
map.on("sourcedata", checkSource);
|
|
1508
|
+
}
|
|
1489
1509
|
return () => {
|
|
1490
|
-
if (
|
|
1510
|
+
if (timeoutId) clearTimeout(timeoutId);
|
|
1511
|
+
map.off("sourcedata", checkSource);
|
|
1512
|
+
if (added) {
|
|
1491
1513
|
try {
|
|
1492
1514
|
if (map.getLayer(id)) {
|
|
1493
1515
|
map.removeLayer(id);
|
|
1494
1516
|
}
|
|
1495
1517
|
} catch {
|
|
1496
1518
|
}
|
|
1497
|
-
setLayerAdded(false);
|
|
1498
1519
|
}
|
|
1520
|
+
setLayerAdded(false);
|
|
1499
1521
|
};
|
|
1500
|
-
}, [map, loaded, id, source, sourceLayer, type, beforeId, styleVersion]);
|
|
1501
|
-
|
|
1522
|
+
}, [map, loaded, id, source, sourceLayer, type, beforeId, styleVersion, sourceVersion]);
|
|
1523
|
+
React6.useEffect(() => {
|
|
1502
1524
|
if (!map || !layerAdded) return;
|
|
1503
1525
|
if (!map.getLayer(id)) return;
|
|
1504
1526
|
map.setLayoutProperty(id, "visibility", visible ? "visible" : "none");
|
|
1505
1527
|
}, [map, id, visible, layerAdded]);
|
|
1506
|
-
|
|
1507
|
-
React26.useEffect(() => {
|
|
1528
|
+
React6.useEffect(() => {
|
|
1508
1529
|
if (!map || !layerAdded) return;
|
|
1509
1530
|
if (!map.getLayer(id)) return;
|
|
1510
1531
|
const diff = getChangedPaintProps(lastAppliedPaintRef.current, paint);
|
|
@@ -1520,12 +1541,10 @@ function useLayer({
|
|
|
1520
1541
|
} catch {
|
|
1521
1542
|
}
|
|
1522
1543
|
}, [map, id, paint, layerAdded]);
|
|
1523
|
-
|
|
1524
|
-
React26.useEffect(() => {
|
|
1544
|
+
React6.useEffect(() => {
|
|
1525
1545
|
if (!map || !layerAdded) return;
|
|
1526
1546
|
if (!map.getLayer(id)) return;
|
|
1527
|
-
const next =
|
|
1528
|
-
delete next.visibility;
|
|
1547
|
+
const next = withoutVisibility(layout);
|
|
1529
1548
|
const diff = getChangedPaintProps(lastAppliedLayoutRef.current, next);
|
|
1530
1549
|
if (!diff.hasChanges) return;
|
|
1531
1550
|
try {
|
|
@@ -1539,17 +1558,17 @@ function useLayer({
|
|
|
1539
1558
|
} catch {
|
|
1540
1559
|
}
|
|
1541
1560
|
}, [map, id, layout, layerAdded]);
|
|
1542
|
-
|
|
1561
|
+
React6.useEffect(() => {
|
|
1543
1562
|
if (!map || !layerAdded) return;
|
|
1544
1563
|
if (!map.getLayer(id)) return;
|
|
1545
1564
|
map.setLayerZoomRange(id, minZoom ?? 0, maxZoom ?? 24);
|
|
1546
1565
|
}, [map, id, minZoom, maxZoom, layerAdded]);
|
|
1547
|
-
|
|
1566
|
+
React6.useEffect(() => {
|
|
1548
1567
|
if (!map || !layerAdded) return;
|
|
1549
1568
|
if (!map.getLayer(id)) return;
|
|
1550
1569
|
map.setFilter(id, filter ?? null);
|
|
1551
1570
|
}, [map, id, filter, layerAdded]);
|
|
1552
|
-
|
|
1571
|
+
React6.useEffect(() => {
|
|
1553
1572
|
if (!map || !layerAdded) return;
|
|
1554
1573
|
const createFeatureParams = (e) => {
|
|
1555
1574
|
const feature = e.features?.[0];
|
|
@@ -1701,7 +1720,7 @@ var FillLayer = ({
|
|
|
1701
1720
|
fillTranslate,
|
|
1702
1721
|
fillAntialias
|
|
1703
1722
|
}) => {
|
|
1704
|
-
const paint =
|
|
1723
|
+
const paint = React6.useMemo(() => {
|
|
1705
1724
|
const p = {};
|
|
1706
1725
|
if (fillColor !== void 0) p["fill-color"] = fillColor;
|
|
1707
1726
|
if (fillOpacity !== void 0) p["fill-opacity"] = fillOpacity;
|
|
@@ -1722,7 +1741,7 @@ var FillLayer = ({
|
|
|
1722
1741
|
fillAntialias,
|
|
1723
1742
|
opacity
|
|
1724
1743
|
]);
|
|
1725
|
-
const layout =
|
|
1744
|
+
const layout = React6.useMemo(() => ({}), []);
|
|
1726
1745
|
useLayer({
|
|
1727
1746
|
id,
|
|
1728
1747
|
source,
|
|
@@ -1766,7 +1785,7 @@ var LineLayer = ({
|
|
|
1766
1785
|
lineOffset,
|
|
1767
1786
|
lineGradient
|
|
1768
1787
|
}) => {
|
|
1769
|
-
const paint =
|
|
1788
|
+
const paint = React6.useMemo(() => {
|
|
1770
1789
|
const p = {};
|
|
1771
1790
|
if (lineColor !== void 0) p["line-color"] = lineColor;
|
|
1772
1791
|
if (lineWidth !== void 0) p["line-width"] = lineWidth;
|
|
@@ -1791,7 +1810,7 @@ var LineLayer = ({
|
|
|
1791
1810
|
lineGradient,
|
|
1792
1811
|
opacity
|
|
1793
1812
|
]);
|
|
1794
|
-
const layout =
|
|
1813
|
+
const layout = React6.useMemo(() => {
|
|
1795
1814
|
const l = {};
|
|
1796
1815
|
if (lineCap !== void 0) l["line-cap"] = lineCap;
|
|
1797
1816
|
if (lineJoin !== void 0) l["line-join"] = lineJoin;
|
|
@@ -1840,7 +1859,7 @@ var CircleLayer = ({
|
|
|
1840
1859
|
circlePitchScale,
|
|
1841
1860
|
circleTranslate
|
|
1842
1861
|
}) => {
|
|
1843
|
-
const paint =
|
|
1862
|
+
const paint = React6.useMemo(() => {
|
|
1844
1863
|
const p = {};
|
|
1845
1864
|
if (circleRadius !== void 0) p["circle-radius"] = circleRadius;
|
|
1846
1865
|
if (circleColor !== void 0) p["circle-color"] = circleColor;
|
|
@@ -1869,7 +1888,7 @@ var CircleLayer = ({
|
|
|
1869
1888
|
circleTranslate,
|
|
1870
1889
|
opacity
|
|
1871
1890
|
]);
|
|
1872
|
-
const layout =
|
|
1891
|
+
const layout = React6.useMemo(() => ({}), []);
|
|
1873
1892
|
useLayer({
|
|
1874
1893
|
id,
|
|
1875
1894
|
source,
|
|
@@ -1929,7 +1948,7 @@ var SymbolLayer = ({
|
|
|
1929
1948
|
symbolSpacing,
|
|
1930
1949
|
symbolSortKey
|
|
1931
1950
|
}) => {
|
|
1932
|
-
const paint =
|
|
1951
|
+
const paint = React6.useMemo(() => {
|
|
1933
1952
|
const p = {};
|
|
1934
1953
|
if (iconOpacity !== void 0) p["icon-opacity"] = iconOpacity;
|
|
1935
1954
|
if (iconColor !== void 0) p["icon-color"] = iconColor;
|
|
@@ -1950,7 +1969,7 @@ var SymbolLayer = ({
|
|
|
1950
1969
|
textHaloColor,
|
|
1951
1970
|
textHaloWidth
|
|
1952
1971
|
]);
|
|
1953
|
-
const layout =
|
|
1972
|
+
const layout = React6.useMemo(() => {
|
|
1954
1973
|
const l = {};
|
|
1955
1974
|
if (iconImage !== void 0) l["icon-image"] = iconImage;
|
|
1956
1975
|
if (iconSize !== void 0) l["icon-size"] = iconSize;
|
|
@@ -2031,7 +2050,7 @@ var FillExtrusionLayer = ({
|
|
|
2031
2050
|
fillExtrusionTranslate,
|
|
2032
2051
|
fillExtrusionVerticalGradient
|
|
2033
2052
|
}) => {
|
|
2034
|
-
const paint =
|
|
2053
|
+
const paint = React6.useMemo(() => {
|
|
2035
2054
|
const p = {};
|
|
2036
2055
|
if (fillExtrusionHeight !== void 0) p["fill-extrusion-height"] = fillExtrusionHeight;
|
|
2037
2056
|
if (fillExtrusionBase !== void 0) p["fill-extrusion-base"] = fillExtrusionBase;
|
|
@@ -2057,7 +2076,7 @@ var FillExtrusionLayer = ({
|
|
|
2057
2076
|
fillExtrusionVerticalGradient,
|
|
2058
2077
|
opacity
|
|
2059
2078
|
]);
|
|
2060
|
-
const layout =
|
|
2079
|
+
const layout = React6.useMemo(() => ({}), []);
|
|
2061
2080
|
useLayer({
|
|
2062
2081
|
id,
|
|
2063
2082
|
source,
|
|
@@ -2096,7 +2115,7 @@ var HeatmapLayer = ({
|
|
|
2096
2115
|
heatmapRadius,
|
|
2097
2116
|
heatmapOpacity
|
|
2098
2117
|
}) => {
|
|
2099
|
-
const paint =
|
|
2118
|
+
const paint = React6.useMemo(() => {
|
|
2100
2119
|
const p = {};
|
|
2101
2120
|
if (heatmapIntensity !== void 0) p["heatmap-intensity"] = heatmapIntensity;
|
|
2102
2121
|
if (heatmapWeight !== void 0) p["heatmap-weight"] = heatmapWeight;
|
|
@@ -2108,7 +2127,7 @@ var HeatmapLayer = ({
|
|
|
2108
2127
|
}
|
|
2109
2128
|
return p;
|
|
2110
2129
|
}, [heatmapIntensity, heatmapWeight, heatmapColor, heatmapRadius, heatmapOpacity, opacity]);
|
|
2111
|
-
const layout =
|
|
2130
|
+
const layout = React6.useMemo(() => ({}), []);
|
|
2112
2131
|
useLayer({
|
|
2113
2132
|
id,
|
|
2114
2133
|
source,
|
|
@@ -2140,8 +2159,8 @@ function useControlPosition(ref, options) {
|
|
|
2140
2159
|
isBuiltIn = false
|
|
2141
2160
|
} = options;
|
|
2142
2161
|
const { positioningCoordinator } = useMap();
|
|
2143
|
-
const [offset, setOffset] =
|
|
2144
|
-
|
|
2162
|
+
const [offset, setOffset] = React6.useState(null);
|
|
2163
|
+
React6.useEffect(() => {
|
|
2145
2164
|
if (!ref.current || !positioningCoordinator) return;
|
|
2146
2165
|
const element = ref.current;
|
|
2147
2166
|
const initialOffset = positioningCoordinator.register({
|
|
@@ -2195,7 +2214,7 @@ function useControlPosition(ref, options) {
|
|
|
2195
2214
|
positioningCoordinator,
|
|
2196
2215
|
ref
|
|
2197
2216
|
]);
|
|
2198
|
-
|
|
2217
|
+
React6.useEffect(() => {
|
|
2199
2218
|
if (!positioningCoordinator) return;
|
|
2200
2219
|
positioningCoordinator.update(id, {
|
|
2201
2220
|
position: {
|
|
@@ -2206,7 +2225,7 @@ function useControlPosition(ref, options) {
|
|
|
2206
2225
|
zLayer
|
|
2207
2226
|
});
|
|
2208
2227
|
}, [id, position, fallbacks, priority, zLayer, positioningCoordinator]);
|
|
2209
|
-
const setExpanded =
|
|
2228
|
+
const setExpanded = React6.useCallback(
|
|
2210
2229
|
(isExpanded) => {
|
|
2211
2230
|
if (positioningCoordinator) {
|
|
2212
2231
|
positioningCoordinator.setExpanded(id, isExpanded);
|
|
@@ -2214,7 +2233,7 @@ function useControlPosition(ref, options) {
|
|
|
2214
2233
|
},
|
|
2215
2234
|
[id, positioningCoordinator]
|
|
2216
2235
|
);
|
|
2217
|
-
const style =
|
|
2236
|
+
const style = React6.useMemo(() => {
|
|
2218
2237
|
if (!offset) {
|
|
2219
2238
|
return {
|
|
2220
2239
|
position: "absolute",
|
|
@@ -2262,9 +2281,9 @@ var Legend = ({
|
|
|
2262
2281
|
class: className,
|
|
2263
2282
|
onItemClick
|
|
2264
2283
|
}) => {
|
|
2265
|
-
const [isCollapsed, setIsCollapsed] =
|
|
2266
|
-
const legendRef =
|
|
2267
|
-
const generatedId =
|
|
2284
|
+
const [isCollapsed, setIsCollapsed] = React6.useState(initialCollapsed);
|
|
2285
|
+
const legendRef = React6.useRef(null);
|
|
2286
|
+
const generatedId = React6.useId();
|
|
2268
2287
|
const legendId = `legend-${generatedId}`;
|
|
2269
2288
|
const { style, visible } = useControlPosition(legendRef, {
|
|
2270
2289
|
id: legendId,
|
|
@@ -2284,7 +2303,7 @@ var Legend = ({
|
|
|
2284
2303
|
setIsCollapsed(!isCollapsed);
|
|
2285
2304
|
}
|
|
2286
2305
|
};
|
|
2287
|
-
const gradientStyle =
|
|
2306
|
+
const gradientStyle = React6.useMemo(() => {
|
|
2288
2307
|
if (type !== "gradient" || gradient.length === 0) return "";
|
|
2289
2308
|
const stops = gradient.map((stop) => `${stop.color} ${stop.position * 100}%`).join(", ");
|
|
2290
2309
|
return `linear-gradient(to right, ${stops})`;
|
|
@@ -2385,14 +2404,14 @@ var LegendGroup = ({
|
|
|
2385
2404
|
allowCollapseAll = false,
|
|
2386
2405
|
class: className
|
|
2387
2406
|
}) => {
|
|
2388
|
-
const containerRef =
|
|
2389
|
-
const groupIdRef =
|
|
2407
|
+
const containerRef = React6.useRef(null);
|
|
2408
|
+
const groupIdRef = React6.useRef(`legend-group-${++legendGroupIdCounter}`);
|
|
2390
2409
|
const getInitialExpanded = () => {
|
|
2391
2410
|
if (controlledExpanded !== void 0) return controlledExpanded;
|
|
2392
2411
|
if (defaultExpanded) return defaultExpanded;
|
|
2393
2412
|
return legends[0]?.id || null;
|
|
2394
2413
|
};
|
|
2395
|
-
const [internalExpanded, setInternalExpanded] =
|
|
2414
|
+
const [internalExpanded, setInternalExpanded] = React6.useState(getInitialExpanded);
|
|
2396
2415
|
const expandedId = controlledExpanded !== void 0 ? controlledExpanded : internalExpanded;
|
|
2397
2416
|
const { style, visible, setExpanded } = useControlPosition(containerRef, {
|
|
2398
2417
|
id: groupIdRef.current,
|
|
@@ -2441,7 +2460,7 @@ var LegendGroup = ({
|
|
|
2441
2460
|
type: "button",
|
|
2442
2461
|
className: cn(
|
|
2443
2462
|
"w-full flex items-center justify-between px-3 py-2 font-medium text-card-foreground",
|
|
2444
|
-
"cursor-pointer hover:bg-muted
|
|
2463
|
+
"cursor-pointer hover:bg-muted",
|
|
2445
2464
|
isFirst && "rounded-t-lg",
|
|
2446
2465
|
isLast && !isExpanded && "rounded-b-lg"
|
|
2447
2466
|
),
|
|
@@ -2538,11 +2557,11 @@ var CoordinateDisplay = ({
|
|
|
2538
2557
|
class: className
|
|
2539
2558
|
}) => {
|
|
2540
2559
|
const { map, loaded } = useMap();
|
|
2541
|
-
const [cursorLngLat, setCursorLngLat] =
|
|
2542
|
-
const [currentZoom, setCurrentZoom] =
|
|
2543
|
-
const [currentBearing, setCurrentBearing] =
|
|
2544
|
-
const controlRef =
|
|
2545
|
-
const uniqueId =
|
|
2560
|
+
const [cursorLngLat, setCursorLngLat] = React6.useState(null);
|
|
2561
|
+
const [currentZoom, setCurrentZoom] = React6.useState(0);
|
|
2562
|
+
const [currentBearing, setCurrentBearing] = React6.useState(0);
|
|
2563
|
+
const controlRef = React6.useRef(null);
|
|
2564
|
+
const uniqueId = React6.useId();
|
|
2546
2565
|
const controlId = `coord-display${uniqueId}`;
|
|
2547
2566
|
const { style, visible } = useControlPosition(controlRef, {
|
|
2548
2567
|
id: controlId,
|
|
@@ -2551,7 +2570,7 @@ var CoordinateDisplay = ({
|
|
|
2551
2570
|
priority: "critical",
|
|
2552
2571
|
zLayer: "base"
|
|
2553
2572
|
});
|
|
2554
|
-
const adjustedStyle =
|
|
2573
|
+
const adjustedStyle = React6.useMemo(() => {
|
|
2555
2574
|
if (!style) return style;
|
|
2556
2575
|
if (position === "top-right") {
|
|
2557
2576
|
const rightOffset = NAV_CONTROL_WIDTH + STACK_GAP + EDGE_MARGIN;
|
|
@@ -2571,7 +2590,7 @@ var CoordinateDisplay = ({
|
|
|
2571
2590
|
}
|
|
2572
2591
|
return style;
|
|
2573
2592
|
}, [position, style]);
|
|
2574
|
-
const formatCoord =
|
|
2593
|
+
const formatCoord = React6.useCallback(
|
|
2575
2594
|
(lngLat) => {
|
|
2576
2595
|
return formatCoordinates(lngLat, precision, format);
|
|
2577
2596
|
},
|
|
@@ -2584,7 +2603,7 @@ var CoordinateDisplay = ({
|
|
|
2584
2603
|
const normalized = (bearing % 360 + 360) % 360;
|
|
2585
2604
|
return `${normalized.toFixed(0)}\xB0`;
|
|
2586
2605
|
};
|
|
2587
|
-
|
|
2606
|
+
React6.useEffect(() => {
|
|
2588
2607
|
if (!map || !loaded) return;
|
|
2589
2608
|
setCurrentZoom(map.getZoom());
|
|
2590
2609
|
setCurrentBearing(map.getBearing());
|
|
@@ -2651,16 +2670,19 @@ var BasemapSwitcher = ({
|
|
|
2651
2670
|
class: className
|
|
2652
2671
|
}) => {
|
|
2653
2672
|
const { setMapStyle } = useMap();
|
|
2654
|
-
const [isOpen, setIsOpen] =
|
|
2655
|
-
const [internalActiveId, setInternalActiveId] =
|
|
2673
|
+
const [isOpen, setIsOpen] = React6.useState(false);
|
|
2674
|
+
const [internalActiveId, setInternalActiveId] = React6.useState(
|
|
2656
2675
|
defaultBasemapId
|
|
2657
2676
|
);
|
|
2658
|
-
const containerRef =
|
|
2659
|
-
const panelRef =
|
|
2660
|
-
const
|
|
2677
|
+
const containerRef = React6.useRef(null);
|
|
2678
|
+
const panelRef = React6.useRef(null);
|
|
2679
|
+
const toggleRef = React6.useRef(null);
|
|
2680
|
+
const optionRefs = React6.useRef([]);
|
|
2681
|
+
const [tabStopIndex, setTabStopIndex] = React6.useState(0);
|
|
2682
|
+
const generatedId = React6.useId();
|
|
2661
2683
|
const switcherId = `basemap-switcher-${generatedId}`;
|
|
2662
2684
|
const sourceBasemaps = basemaps ?? FREE_BASEMAPS;
|
|
2663
|
-
const availableBasemaps =
|
|
2685
|
+
const availableBasemaps = React6.useMemo(() => {
|
|
2664
2686
|
const available = getAvailableBasemaps(sourceBasemaps, apiKeys);
|
|
2665
2687
|
if (extraBasemaps?.length) {
|
|
2666
2688
|
return [...available, ...getAvailableBasemaps(extraBasemaps, apiKeys)];
|
|
@@ -2668,6 +2690,15 @@ var BasemapSwitcher = ({
|
|
|
2668
2690
|
return available;
|
|
2669
2691
|
}, [sourceBasemaps, extraBasemaps, apiKeys]);
|
|
2670
2692
|
const currentActiveId = activeBasemapId ?? internalActiveId ?? availableBasemaps[0]?.id;
|
|
2693
|
+
const activeIndex = Math.max(
|
|
2694
|
+
0,
|
|
2695
|
+
availableBasemaps.findIndex((basemap) => basemap.id === currentActiveId)
|
|
2696
|
+
);
|
|
2697
|
+
React6.useEffect(() => {
|
|
2698
|
+
if (!isOpen) return;
|
|
2699
|
+
setTabStopIndex(activeIndex);
|
|
2700
|
+
optionRefs.current[activeIndex]?.focus();
|
|
2701
|
+
}, [isOpen]);
|
|
2671
2702
|
const { style, visible, setExpanded } = useControlPosition(containerRef, {
|
|
2672
2703
|
id: switcherId,
|
|
2673
2704
|
type: "basemap-switcher",
|
|
@@ -2676,7 +2707,7 @@ var BasemapSwitcher = ({
|
|
|
2676
2707
|
zLayer: "interactive",
|
|
2677
2708
|
hasExpandedState: true
|
|
2678
2709
|
});
|
|
2679
|
-
|
|
2710
|
+
React6.useEffect(() => {
|
|
2680
2711
|
if (!isOpen) return;
|
|
2681
2712
|
const handleMouseDown = (e) => {
|
|
2682
2713
|
if (containerRef.current && !containerRef.current.contains(e.target)) {
|
|
@@ -2687,12 +2718,13 @@ var BasemapSwitcher = ({
|
|
|
2687
2718
|
document.addEventListener("mousedown", handleMouseDown);
|
|
2688
2719
|
return () => document.removeEventListener("mousedown", handleMouseDown);
|
|
2689
2720
|
}, [isOpen, setExpanded]);
|
|
2690
|
-
|
|
2721
|
+
React6.useEffect(() => {
|
|
2691
2722
|
if (!isOpen) return;
|
|
2692
2723
|
const handleKeyDown = (e) => {
|
|
2693
2724
|
if (e.key === "Escape") {
|
|
2694
2725
|
setIsOpen(false);
|
|
2695
2726
|
setExpanded(false);
|
|
2727
|
+
toggleRef.current?.focus();
|
|
2696
2728
|
}
|
|
2697
2729
|
};
|
|
2698
2730
|
document.addEventListener("keydown", handleKeyDown);
|
|
@@ -2713,6 +2745,14 @@ var BasemapSwitcher = ({
|
|
|
2713
2745
|
onBasemapChange?.(basemap);
|
|
2714
2746
|
setIsOpen(false);
|
|
2715
2747
|
setExpanded(false);
|
|
2748
|
+
toggleRef.current?.focus();
|
|
2749
|
+
};
|
|
2750
|
+
const handleOptionsKeyDown = (e) => {
|
|
2751
|
+
const next = getGridNavigationIndex(e.key, tabStopIndex, availableBasemaps.length, columns);
|
|
2752
|
+
if (next === null) return;
|
|
2753
|
+
e.preventDefault();
|
|
2754
|
+
setTabStopIndex(next);
|
|
2755
|
+
optionRefs.current[next]?.focus();
|
|
2716
2756
|
};
|
|
2717
2757
|
const handleToggle = () => {
|
|
2718
2758
|
const newState = !isOpen;
|
|
@@ -2744,25 +2784,32 @@ var BasemapSwitcher = ({
|
|
|
2744
2784
|
children: /* @__PURE__ */ jsx(
|
|
2745
2785
|
"div",
|
|
2746
2786
|
{
|
|
2747
|
-
role: "
|
|
2787
|
+
role: "radiogroup",
|
|
2748
2788
|
"aria-label": "Select basemap",
|
|
2749
2789
|
className: "grid gap-1.5",
|
|
2750
2790
|
style: {
|
|
2751
2791
|
gridTemplateColumns: `repeat(${columns}, 1fr)`
|
|
2752
2792
|
},
|
|
2753
|
-
|
|
2793
|
+
onKeyDown: handleOptionsKeyDown,
|
|
2794
|
+
children: availableBasemaps.map((basemap, index) => {
|
|
2754
2795
|
const isActive = basemap.id === currentActiveId;
|
|
2755
2796
|
const thumbUrl = resolveBasemapThumbnail(basemap, apiKeys);
|
|
2756
2797
|
return /* @__PURE__ */ jsxs(
|
|
2757
2798
|
"button",
|
|
2758
2799
|
{
|
|
2800
|
+
ref: (el) => {
|
|
2801
|
+
optionRefs.current[index] = el;
|
|
2802
|
+
},
|
|
2759
2803
|
type: "button",
|
|
2760
|
-
"
|
|
2804
|
+
role: "radio",
|
|
2805
|
+
"aria-checked": isActive,
|
|
2806
|
+
tabIndex: index === tabStopIndex ? 0 : -1,
|
|
2761
2807
|
className: cn(
|
|
2762
2808
|
"flex flex-col items-center gap-1 p-1 rounded cursor-pointer",
|
|
2763
|
-
"hover:bg-muted
|
|
2809
|
+
"hover:bg-muted",
|
|
2764
2810
|
isActive && "ring-2 ring-primary"
|
|
2765
2811
|
),
|
|
2812
|
+
onFocus: () => setTabStopIndex(index),
|
|
2766
2813
|
onClick: () => handleSelect(basemap),
|
|
2767
2814
|
title: basemap.name,
|
|
2768
2815
|
children: [
|
|
@@ -2792,11 +2839,12 @@ var BasemapSwitcher = ({
|
|
|
2792
2839
|
/* @__PURE__ */ jsx(
|
|
2793
2840
|
"button",
|
|
2794
2841
|
{
|
|
2842
|
+
ref: toggleRef,
|
|
2795
2843
|
type: "button",
|
|
2796
2844
|
className: cn(
|
|
2797
2845
|
"w-[40px] h-[40px] flex items-center justify-center",
|
|
2798
2846
|
"bg-card rounded shadow-lg border border-black dark:border-gray-400",
|
|
2799
|
-
"hover:bg-muted
|
|
2847
|
+
"hover:bg-muted cursor-pointer",
|
|
2800
2848
|
"text-foreground"
|
|
2801
2849
|
),
|
|
2802
2850
|
onClick: handleToggle,
|
|
@@ -2842,20 +2890,20 @@ var LayerManager = ({
|
|
|
2842
2890
|
class: className
|
|
2843
2891
|
}) => {
|
|
2844
2892
|
const { isDark } = useMapTheme();
|
|
2845
|
-
const [isOpen, setIsOpen] =
|
|
2846
|
-
const [layerStates, setLayerStates] =
|
|
2893
|
+
const [isOpen, setIsOpen] = React6.useState(false);
|
|
2894
|
+
const [layerStates, setLayerStates] = React6.useState(
|
|
2847
2895
|
() => createInitialLayerStates(layers, initialActiveLayers)
|
|
2848
2896
|
);
|
|
2849
|
-
const [searchQuery, setSearchQuery] =
|
|
2850
|
-
const [activeCategory, setActiveCategory] =
|
|
2851
|
-
const [expandedOpacity, setExpandedOpacity] =
|
|
2852
|
-
const [draggedId, setDraggedId] =
|
|
2853
|
-
const [dragOver, setDragOver] =
|
|
2854
|
-
const containerRef =
|
|
2855
|
-
const uniqueId =
|
|
2897
|
+
const [searchQuery, setSearchQuery] = React6.useState("");
|
|
2898
|
+
const [activeCategory, setActiveCategory] = React6.useState("all");
|
|
2899
|
+
const [expandedOpacity, setExpandedOpacity] = React6.useState(null);
|
|
2900
|
+
const [draggedId, setDraggedId] = React6.useState(null);
|
|
2901
|
+
const [dragOver, setDragOver] = React6.useState(null);
|
|
2902
|
+
const containerRef = React6.useRef(null);
|
|
2903
|
+
const uniqueId = React6.useId();
|
|
2856
2904
|
const managerId = `layer-manager${uniqueId}`;
|
|
2857
|
-
const lastLayerIdsRef =
|
|
2858
|
-
const tilesCacheRef =
|
|
2905
|
+
const lastLayerIdsRef = React6.useRef(new Set(layers.map((l) => l.id)));
|
|
2906
|
+
const tilesCacheRef = React6.useRef(/* @__PURE__ */ new Map());
|
|
2859
2907
|
const getTiles = (url) => {
|
|
2860
2908
|
let tiles = tilesCacheRef.current.get(url);
|
|
2861
2909
|
if (!tiles) {
|
|
@@ -2872,7 +2920,7 @@ var LayerManager = ({
|
|
|
2872
2920
|
zLayer: "interactive",
|
|
2873
2921
|
hasExpandedState: true
|
|
2874
2922
|
});
|
|
2875
|
-
|
|
2923
|
+
React6.useEffect(() => {
|
|
2876
2924
|
const currentLayerIds = new Set(layers.map((l) => l.id));
|
|
2877
2925
|
const hasNewLayers = layers.some((l) => !lastLayerIdsRef.current.has(l.id));
|
|
2878
2926
|
const hasRemovedLayers = Array.from(lastLayerIdsRef.current).some(
|
|
@@ -2903,8 +2951,8 @@ var LayerManager = ({
|
|
|
2903
2951
|
lastLayerIdsRef.current = currentLayerIds;
|
|
2904
2952
|
}
|
|
2905
2953
|
}, [layers, initialActiveLayers]);
|
|
2906
|
-
const categories =
|
|
2907
|
-
const filteredLayers =
|
|
2954
|
+
const categories = React6.useMemo(() => getLayerCategories(layers), [layers]);
|
|
2955
|
+
const filteredLayers = React6.useMemo(() => {
|
|
2908
2956
|
let result = layers;
|
|
2909
2957
|
if (searchQuery) {
|
|
2910
2958
|
result = searchLayers(result, searchQuery);
|
|
@@ -2918,11 +2966,11 @@ var LayerManager = ({
|
|
|
2918
2966
|
return orderA - orderB;
|
|
2919
2967
|
});
|
|
2920
2968
|
}, [layers, searchQuery, activeCategory, layerStates]);
|
|
2921
|
-
const layerGroups =
|
|
2969
|
+
const layerGroups = React6.useMemo(
|
|
2922
2970
|
() => showCategories ? groupLayersByCategory(filteredLayers) : null,
|
|
2923
2971
|
[filteredLayers, showCategories]
|
|
2924
2972
|
);
|
|
2925
|
-
|
|
2973
|
+
React6.useEffect(() => {
|
|
2926
2974
|
if (!isOpen) return;
|
|
2927
2975
|
const handleMouseDown = (e) => {
|
|
2928
2976
|
if (containerRef.current && !containerRef.current.contains(e.target)) {
|
|
@@ -2933,7 +2981,7 @@ var LayerManager = ({
|
|
|
2933
2981
|
document.addEventListener("mousedown", handleMouseDown);
|
|
2934
2982
|
return () => document.removeEventListener("mousedown", handleMouseDown);
|
|
2935
2983
|
}, [isOpen, setExpanded]);
|
|
2936
|
-
|
|
2984
|
+
React6.useEffect(() => {
|
|
2937
2985
|
if (!isOpen) return;
|
|
2938
2986
|
const handleKeyDown = (e) => {
|
|
2939
2987
|
if (e.key === "Escape") {
|
|
@@ -2944,7 +2992,7 @@ var LayerManager = ({
|
|
|
2944
2992
|
document.addEventListener("keydown", handleKeyDown);
|
|
2945
2993
|
return () => document.removeEventListener("keydown", handleKeyDown);
|
|
2946
2994
|
}, [isOpen, setExpanded]);
|
|
2947
|
-
const handleToggleLayer =
|
|
2995
|
+
const handleToggleLayer = React6.useCallback(
|
|
2948
2996
|
(layerId) => {
|
|
2949
2997
|
setLayerStates((prev) => {
|
|
2950
2998
|
const newStates = toggleLayerVisibility(prev, layerId);
|
|
@@ -2957,7 +3005,7 @@ var LayerManager = ({
|
|
|
2957
3005
|
},
|
|
2958
3006
|
[onLayerChange]
|
|
2959
3007
|
);
|
|
2960
|
-
const handleOpacityChange =
|
|
3008
|
+
const handleOpacityChange = React6.useCallback(
|
|
2961
3009
|
(layerId, opacity) => {
|
|
2962
3010
|
setLayerStates((prev) => {
|
|
2963
3011
|
const newStates = setLayerOpacity(prev, layerId, opacity);
|
|
@@ -2970,12 +3018,12 @@ var LayerManager = ({
|
|
|
2970
3018
|
},
|
|
2971
3019
|
[onLayerChange]
|
|
2972
3020
|
);
|
|
2973
|
-
const handleDragStart =
|
|
3021
|
+
const handleDragStart = React6.useCallback((e, layerId) => {
|
|
2974
3022
|
setDraggedId(layerId);
|
|
2975
3023
|
e.dataTransfer.effectAllowed = "move";
|
|
2976
3024
|
e.dataTransfer.setData("text/plain", layerId);
|
|
2977
3025
|
}, []);
|
|
2978
|
-
const handleDragOver =
|
|
3026
|
+
const handleDragOver = React6.useCallback(
|
|
2979
3027
|
(e, layerId) => {
|
|
2980
3028
|
e.preventDefault();
|
|
2981
3029
|
e.dataTransfer.dropEffect = "move";
|
|
@@ -2995,14 +3043,14 @@ var LayerManager = ({
|
|
|
2995
3043
|
},
|
|
2996
3044
|
[draggedId, dragOver]
|
|
2997
3045
|
);
|
|
2998
|
-
const handleDragLeave =
|
|
3046
|
+
const handleDragLeave = React6.useCallback(() => {
|
|
2999
3047
|
setDragOver(null);
|
|
3000
3048
|
}, []);
|
|
3001
|
-
const handleDragEnd =
|
|
3049
|
+
const handleDragEnd = React6.useCallback(() => {
|
|
3002
3050
|
setDraggedId(null);
|
|
3003
3051
|
setDragOver(null);
|
|
3004
3052
|
}, []);
|
|
3005
|
-
const handleDrop =
|
|
3053
|
+
const handleDrop = React6.useCallback(
|
|
3006
3054
|
(e, targetLayerId) => {
|
|
3007
3055
|
e.preventDefault();
|
|
3008
3056
|
const sourceLayerId = e.dataTransfer.getData("text/plain");
|
|
@@ -3338,7 +3386,7 @@ var LayerManager = ({
|
|
|
3338
3386
|
if (catLayers.length === 0) return null;
|
|
3339
3387
|
return /* @__PURE__ */ jsxs("div", { children: [
|
|
3340
3388
|
/* @__PURE__ */ jsx("div", { className: "px-3 py-2 text-xs font-medium text-muted-foreground uppercase tracking-wider", children: CATEGORY_META[cat].label }),
|
|
3341
|
-
catLayers.map((layer) => /* @__PURE__ */ jsxs(
|
|
3389
|
+
catLayers.map((layer) => /* @__PURE__ */ jsxs(React6.Fragment, { children: [
|
|
3342
3390
|
renderLayerItem(layer),
|
|
3343
3391
|
renderOpacitySlider(layer.id)
|
|
3344
3392
|
] }, layer.id))
|
|
@@ -3346,7 +3394,7 @@ var LayerManager = ({
|
|
|
3346
3394
|
})
|
|
3347
3395
|
) : (
|
|
3348
3396
|
// Flat list
|
|
3349
|
-
filteredLayers.map((layer) => /* @__PURE__ */ jsxs(
|
|
3397
|
+
filteredLayers.map((layer) => /* @__PURE__ */ jsxs(React6.Fragment, { children: [
|
|
3350
3398
|
renderLayerItem(layer),
|
|
3351
3399
|
renderOpacitySlider(layer.id)
|
|
3352
3400
|
] }, layer.id))
|
|
@@ -3363,7 +3411,7 @@ var LayerManager = ({
|
|
|
3363
3411
|
className: cn(
|
|
3364
3412
|
"w-[40px] h-[40px] flex items-center justify-center",
|
|
3365
3413
|
"bg-card rounded shadow-lg border border-black dark:border-gray-400",
|
|
3366
|
-
"hover:bg-muted
|
|
3414
|
+
"hover:bg-muted cursor-pointer",
|
|
3367
3415
|
"text-foreground"
|
|
3368
3416
|
),
|
|
3369
3417
|
onClick: handleToggle,
|
|
@@ -3407,8 +3455,8 @@ var CustomControl = ({
|
|
|
3407
3455
|
style: userStyle,
|
|
3408
3456
|
children
|
|
3409
3457
|
}) => {
|
|
3410
|
-
const controlRef =
|
|
3411
|
-
const generatedId =
|
|
3458
|
+
const controlRef = React6.useRef(null);
|
|
3459
|
+
const generatedId = React6.useId();
|
|
3412
3460
|
const controlId = id ?? `custom-control-${generatedId}`;
|
|
3413
3461
|
const { style, visible, setExpanded } = useControlPosition(controlRef, {
|
|
3414
3462
|
id: controlId,
|
|
@@ -3419,14 +3467,14 @@ var CustomControl = ({
|
|
|
3419
3467
|
zLayer,
|
|
3420
3468
|
hasExpandedState
|
|
3421
3469
|
});
|
|
3422
|
-
const mergedStyle =
|
|
3423
|
-
const contextValue =
|
|
3470
|
+
const mergedStyle = React6.useMemo(() => ({ ...style, ...userStyle }), [style, userStyle]);
|
|
3471
|
+
const contextValue = React6.useMemo(() => ({ setExpanded }), [setExpanded]);
|
|
3424
3472
|
return /* @__PURE__ */ jsx(CustomControlContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx("div", { ref: controlRef, className: cn(!visible && "invisible", className), style: mergedStyle, children }) });
|
|
3425
3473
|
};
|
|
3426
3474
|
CustomControl.displayName = "CustomControl";
|
|
3427
|
-
var CustomControlContext =
|
|
3475
|
+
var CustomControlContext = React6.createContext(null);
|
|
3428
3476
|
function useCustomControl() {
|
|
3429
|
-
const context =
|
|
3477
|
+
const context = React6.useContext(CustomControlContext);
|
|
3430
3478
|
if (!context) {
|
|
3431
3479
|
throw new Error("useCustomControl must be used within a CustomControl");
|
|
3432
3480
|
}
|
|
@@ -3442,11 +3490,11 @@ var DeckOverlay = ({
|
|
|
3442
3490
|
deckProps = {}
|
|
3443
3491
|
}) => {
|
|
3444
3492
|
const { map, loaded } = useMap();
|
|
3445
|
-
const overlayRef =
|
|
3446
|
-
const MapboxOverlayRef =
|
|
3447
|
-
const layersRef =
|
|
3493
|
+
const overlayRef = React6.useRef(null);
|
|
3494
|
+
const MapboxOverlayRef = React6.useRef(null);
|
|
3495
|
+
const layersRef = React6.useRef(layers);
|
|
3448
3496
|
layersRef.current = layers;
|
|
3449
|
-
|
|
3497
|
+
React6.useEffect(() => {
|
|
3450
3498
|
if (!map || !loaded) return;
|
|
3451
3499
|
let cancelled = false;
|
|
3452
3500
|
const initOverlay = async () => {
|
|
@@ -3486,12 +3534,12 @@ var DeckOverlay = ({
|
|
|
3486
3534
|
}
|
|
3487
3535
|
};
|
|
3488
3536
|
}, [map, loaded, interleaved]);
|
|
3489
|
-
|
|
3537
|
+
React6.useEffect(() => {
|
|
3490
3538
|
if (overlayRef.current && "setProps" in overlayRef.current) {
|
|
3491
3539
|
overlayRef.current.setProps({ layers });
|
|
3492
3540
|
}
|
|
3493
3541
|
}, [layers]);
|
|
3494
|
-
|
|
3542
|
+
React6.useEffect(() => {
|
|
3495
3543
|
if (overlayRef.current && "setProps" in overlayRef.current) {
|
|
3496
3544
|
overlayRef.current.setProps({
|
|
3497
3545
|
onHover,
|
|
@@ -3500,7 +3548,7 @@ var DeckOverlay = ({
|
|
|
3500
3548
|
});
|
|
3501
3549
|
}
|
|
3502
3550
|
}, [onHover, onClick, getCursor]);
|
|
3503
|
-
|
|
3551
|
+
React6.useEffect(() => {
|
|
3504
3552
|
if (overlayRef.current && effects && "setProps" in overlayRef.current) {
|
|
3505
3553
|
overlayRef.current.setProps({ effects });
|
|
3506
3554
|
}
|