@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.cjs
CHANGED
|
@@ -1,19 +1,14 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var React6 = require('react');
|
|
4
4
|
var clsx = require('clsx');
|
|
5
5
|
var tailwindMerge = require('tailwind-merge');
|
|
6
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
7
7
|
var maplibregl = require('maplibre-gl');
|
|
8
|
-
require('maplibre-gl/dist/maplibre-gl.css');
|
|
9
|
-
require('@classic-homes/maps-core/styles/controls.css');
|
|
10
|
-
require('@classic-homes/maps-core/styles/marker.css');
|
|
11
8
|
var mapsCore = require('@classic-homes/maps-core');
|
|
12
9
|
var ReactDOM = require('react-dom');
|
|
13
10
|
var utils = require('@classic-homes/maps-core/utils');
|
|
14
11
|
var classVarianceAuthority = require('class-variance-authority');
|
|
15
|
-
require('@classic-homes/maps-core/styles/basemap-switcher.css');
|
|
16
|
-
require('@classic-homes/maps-core/styles/layer-manager.css');
|
|
17
12
|
var themeReact = require('@classic-homes/theme-react');
|
|
18
13
|
|
|
19
14
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -36,7 +31,7 @@ function _interopNamespace(e) {
|
|
|
36
31
|
return Object.freeze(n);
|
|
37
32
|
}
|
|
38
33
|
|
|
39
|
-
var
|
|
34
|
+
var React6__namespace = /*#__PURE__*/_interopNamespace(React6);
|
|
40
35
|
var maplibregl__default = /*#__PURE__*/_interopDefault(maplibregl);
|
|
41
36
|
var ReactDOM__namespace = /*#__PURE__*/_interopNamespace(ReactDOM);
|
|
42
37
|
|
|
@@ -44,7 +39,7 @@ var ReactDOM__namespace = /*#__PURE__*/_interopNamespace(ReactDOM);
|
|
|
44
39
|
function cn(...inputs) {
|
|
45
40
|
return tailwindMerge.twMerge(clsx.clsx(inputs));
|
|
46
41
|
}
|
|
47
|
-
var MapSkeleton =
|
|
42
|
+
var MapSkeleton = React6__namespace.forwardRef(
|
|
48
43
|
({ height = 400, className, ...props }, ref) => {
|
|
49
44
|
const heightStyle = typeof height === "number" ? `${height}px` : height;
|
|
50
45
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -98,7 +93,7 @@ var MapSkeleton = React26__namespace.forwardRef(
|
|
|
98
93
|
}
|
|
99
94
|
);
|
|
100
95
|
MapSkeleton.displayName = "MapSkeleton";
|
|
101
|
-
var MapError =
|
|
96
|
+
var MapError = React6__namespace.forwardRef(
|
|
102
97
|
({ message = "Failed to load map", height = 400, onRetry, className, ...props }, ref) => {
|
|
103
98
|
const heightStyle = typeof height === "number" ? `${height}px` : height;
|
|
104
99
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -144,7 +139,7 @@ var MapError = React26__namespace.forwardRef(
|
|
|
144
139
|
"button",
|
|
145
140
|
{
|
|
146
141
|
onClick: onRetry,
|
|
147
|
-
className: "mt-2 rounded-md border border-input bg-background px-4 py-2 text-sm font-medium shadow-sm
|
|
142
|
+
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",
|
|
148
143
|
children: "Retry"
|
|
149
144
|
}
|
|
150
145
|
)
|
|
@@ -154,7 +149,7 @@ var MapError = React26__namespace.forwardRef(
|
|
|
154
149
|
}
|
|
155
150
|
);
|
|
156
151
|
MapError.displayName = "MapError";
|
|
157
|
-
var MapEmpty =
|
|
152
|
+
var MapEmpty = React6__namespace.forwardRef(
|
|
158
153
|
({ message = "No map data to display", height = 400, className, ...props }, ref) => {
|
|
159
154
|
const heightStyle = typeof height === "number" ? `${height}px` : height;
|
|
160
155
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -197,7 +192,7 @@ var MapEmpty = React26__namespace.forwardRef(
|
|
|
197
192
|
}
|
|
198
193
|
);
|
|
199
194
|
MapEmpty.displayName = "MapEmpty";
|
|
200
|
-
var MapContainer =
|
|
195
|
+
var MapContainer = React6__namespace.forwardRef(
|
|
201
196
|
({
|
|
202
197
|
title,
|
|
203
198
|
description,
|
|
@@ -246,8 +241,8 @@ var MapContainer = React26__namespace.forwardRef(
|
|
|
246
241
|
);
|
|
247
242
|
MapContainer.displayName = "MapContainer";
|
|
248
243
|
function useMapTheme(preference = "auto") {
|
|
249
|
-
const [isDark, setIsDark] =
|
|
250
|
-
const updateTheme =
|
|
244
|
+
const [isDark, setIsDark] = React6.useState(false);
|
|
245
|
+
const updateTheme = React6.useCallback(() => {
|
|
251
246
|
if (preference !== "auto") {
|
|
252
247
|
setIsDark(preference === "dark");
|
|
253
248
|
return;
|
|
@@ -257,7 +252,7 @@ function useMapTheme(preference = "auto") {
|
|
|
257
252
|
setIsDark(hasDarkClass);
|
|
258
253
|
}
|
|
259
254
|
}, [preference]);
|
|
260
|
-
|
|
255
|
+
React6.useEffect(() => {
|
|
261
256
|
updateTheme();
|
|
262
257
|
if (preference !== "auto" || typeof document === "undefined") return;
|
|
263
258
|
const observer = new MutationObserver((mutations) => {
|
|
@@ -288,8 +283,8 @@ function useMapTheme(preference = "auto") {
|
|
|
288
283
|
};
|
|
289
284
|
}
|
|
290
285
|
function useReducedMotion() {
|
|
291
|
-
const [prefersReducedMotion, setPrefersReducedMotion] =
|
|
292
|
-
|
|
286
|
+
const [prefersReducedMotion, setPrefersReducedMotion] = React6.useState(false);
|
|
287
|
+
React6.useEffect(() => {
|
|
293
288
|
if (typeof window === "undefined") return;
|
|
294
289
|
const mediaQuery = window.matchMedia("(prefers-reduced-motion: reduce)");
|
|
295
290
|
setPrefersReducedMotion(mediaQuery.matches);
|
|
@@ -303,9 +298,9 @@ function useReducedMotion() {
|
|
|
303
298
|
}, []);
|
|
304
299
|
return prefersReducedMotion;
|
|
305
300
|
}
|
|
306
|
-
var MapContext =
|
|
301
|
+
var MapContext = React6__namespace.createContext(null);
|
|
307
302
|
function useMap() {
|
|
308
|
-
const context =
|
|
303
|
+
const context = React6__namespace.useContext(MapContext);
|
|
309
304
|
if (!context) {
|
|
310
305
|
throw new Error("useMap must be used within a Map component");
|
|
311
306
|
}
|
|
@@ -315,7 +310,11 @@ function useMapInstance() {
|
|
|
315
310
|
const { map, loaded } = useMap();
|
|
316
311
|
return loaded ? map : null;
|
|
317
312
|
}
|
|
318
|
-
|
|
313
|
+
function getStyleKey(style) {
|
|
314
|
+
if (!style) return "";
|
|
315
|
+
return typeof style === "string" ? style : JSON.stringify(style);
|
|
316
|
+
}
|
|
317
|
+
var Map2 = React6__namespace.forwardRef(
|
|
319
318
|
({
|
|
320
319
|
// Base props
|
|
321
320
|
title,
|
|
@@ -370,30 +369,30 @@ var Map2 = React26__namespace.forwardRef(
|
|
|
370
369
|
onZoom,
|
|
371
370
|
onError
|
|
372
371
|
}, ref) => {
|
|
373
|
-
const containerRef =
|
|
374
|
-
const mapRef =
|
|
375
|
-
const [mapLoaded, setMapLoaded] =
|
|
376
|
-
const [mapError, setMapError] =
|
|
377
|
-
const [initAttempt, setInitAttempt] =
|
|
378
|
-
const retryInit =
|
|
372
|
+
const containerRef = React6__namespace.useRef(null);
|
|
373
|
+
const mapRef = React6__namespace.useRef(null);
|
|
374
|
+
const [mapLoaded, setMapLoaded] = React6__namespace.useState(false);
|
|
375
|
+
const [mapError, setMapError] = React6__namespace.useState(null);
|
|
376
|
+
const [initAttempt, setInitAttempt] = React6__namespace.useState(0);
|
|
377
|
+
const retryInit = React6__namespace.useCallback(() => {
|
|
379
378
|
setMapError(null);
|
|
380
379
|
setInitAttempt((attempt) => attempt + 1);
|
|
381
380
|
}, []);
|
|
382
|
-
const [styleVersion, setStyleVersion] =
|
|
383
|
-
const styleVersionRef =
|
|
384
|
-
const bumpStyleVersion =
|
|
381
|
+
const [styleVersion, setStyleVersion] = React6__namespace.useState(0);
|
|
382
|
+
const styleVersionRef = React6__namespace.useRef(0);
|
|
383
|
+
const bumpStyleVersion = React6__namespace.useCallback(() => {
|
|
385
384
|
styleVersionRef.current += 1;
|
|
386
385
|
setStyleVersion(styleVersionRef.current);
|
|
387
386
|
}, []);
|
|
388
|
-
const activeStyleOverrideRef =
|
|
387
|
+
const activeStyleOverrideRef = React6__namespace.useRef(
|
|
389
388
|
null
|
|
390
389
|
);
|
|
391
|
-
const positioningCoordinatorRef =
|
|
390
|
+
const positioningCoordinatorRef = React6__namespace.useRef(null);
|
|
392
391
|
if (!positioningCoordinatorRef.current) {
|
|
393
392
|
positioningCoordinatorRef.current = mapsCore.createPositioningCoordinator();
|
|
394
393
|
}
|
|
395
394
|
const positioningCoordinator = positioningCoordinatorRef.current;
|
|
396
|
-
const setMapStyle =
|
|
395
|
+
const setMapStyle = React6__namespace.useCallback(
|
|
397
396
|
(style) => {
|
|
398
397
|
activeStyleOverrideRef.current = style;
|
|
399
398
|
const map = mapRef.current;
|
|
@@ -408,16 +407,20 @@ var Map2 = React26__namespace.forwardRef(
|
|
|
408
407
|
);
|
|
409
408
|
const prefersReducedMotion = useReducedMotion();
|
|
410
409
|
const { style: themeStyle } = useMapTheme(themePref);
|
|
411
|
-
const onLoadRef =
|
|
410
|
+
const onLoadRef = React6__namespace.useRef(onLoad);
|
|
412
411
|
onLoadRef.current = onLoad;
|
|
413
|
-
const onErrorRef =
|
|
412
|
+
const onErrorRef = React6__namespace.useRef(onError);
|
|
414
413
|
onErrorRef.current = onError;
|
|
415
414
|
const mapStyle = customStyle || themeStyle;
|
|
415
|
+
const mapStyleKey = React6__namespace.useMemo(() => getStyleKey(mapStyle), [mapStyle]);
|
|
416
|
+
const customStyleKey = React6__namespace.useMemo(() => getStyleKey(customStyle), [customStyle]);
|
|
417
|
+
const mapStyleRef = React6__namespace.useRef(mapStyle);
|
|
418
|
+
mapStyleRef.current = mapStyle;
|
|
416
419
|
const accessibleDescription = description || mapsCore.generateMapDescription(title, {
|
|
417
420
|
center,
|
|
418
421
|
zoom
|
|
419
422
|
});
|
|
420
|
-
|
|
423
|
+
React6__namespace.useEffect(() => {
|
|
421
424
|
if (!containerRef.current || !positioningCoordinator) return;
|
|
422
425
|
const updateDimensions = () => {
|
|
423
426
|
if (!containerRef.current) return;
|
|
@@ -433,12 +436,12 @@ var Map2 = React26__namespace.forwardRef(
|
|
|
433
436
|
resizeObserver.disconnect();
|
|
434
437
|
};
|
|
435
438
|
}, [positioningCoordinator]);
|
|
436
|
-
|
|
439
|
+
React6__namespace.useEffect(() => {
|
|
437
440
|
return () => {
|
|
438
441
|
positioningCoordinator.destroy();
|
|
439
442
|
};
|
|
440
443
|
}, [positioningCoordinator]);
|
|
441
|
-
|
|
444
|
+
React6__namespace.useEffect(() => {
|
|
442
445
|
if (!containerRef.current || mapRef.current) return;
|
|
443
446
|
try {
|
|
444
447
|
const map = new maplibregl__default.default.Map({
|
|
@@ -597,7 +600,7 @@ var Map2 = React26__namespace.forwardRef(
|
|
|
597
600
|
});
|
|
598
601
|
}
|
|
599
602
|
}, [initAttempt]);
|
|
600
|
-
|
|
603
|
+
React6__namespace.useEffect(() => {
|
|
601
604
|
const map = mapRef.current;
|
|
602
605
|
if (!map || !mapLoaded) return;
|
|
603
606
|
map.on("style.load", bumpStyleVersion);
|
|
@@ -605,22 +608,22 @@ var Map2 = React26__namespace.forwardRef(
|
|
|
605
608
|
map.off("style.load", bumpStyleVersion);
|
|
606
609
|
};
|
|
607
610
|
}, [mapLoaded, bumpStyleVersion]);
|
|
608
|
-
const styleInitialized =
|
|
609
|
-
|
|
611
|
+
const styleInitialized = React6__namespace.useRef(false);
|
|
612
|
+
React6__namespace.useEffect(() => {
|
|
610
613
|
if (!mapRef.current || !mapLoaded) return;
|
|
611
614
|
if (!styleInitialized.current) {
|
|
612
615
|
styleInitialized.current = true;
|
|
613
616
|
return;
|
|
614
617
|
}
|
|
615
618
|
if (activeStyleOverrideRef.current) return;
|
|
616
|
-
mapRef.current.setStyle(
|
|
617
|
-
}, [
|
|
618
|
-
|
|
619
|
-
if (
|
|
619
|
+
mapRef.current.setStyle(mapStyleRef.current);
|
|
620
|
+
}, [mapStyleKey, mapLoaded]);
|
|
621
|
+
React6__namespace.useEffect(() => {
|
|
622
|
+
if (customStyleKey) {
|
|
620
623
|
activeStyleOverrideRef.current = null;
|
|
621
624
|
}
|
|
622
|
-
}, [
|
|
623
|
-
|
|
625
|
+
}, [customStyleKey]);
|
|
626
|
+
React6__namespace.useEffect(() => {
|
|
624
627
|
const map = mapRef.current;
|
|
625
628
|
if (!map || !mapLoaded) return;
|
|
626
629
|
const createEventParams = (e) => ({
|
|
@@ -719,7 +722,7 @@ var Map2 = React26__namespace.forwardRef(
|
|
|
719
722
|
onZoom
|
|
720
723
|
]);
|
|
721
724
|
const combinedError = error || mapError;
|
|
722
|
-
const contextValue =
|
|
725
|
+
const contextValue = React6__namespace.useMemo(
|
|
723
726
|
() => ({
|
|
724
727
|
map: mapRef.current,
|
|
725
728
|
loaded: mapLoaded,
|
|
@@ -751,6 +754,7 @@ var Map2 = React26__namespace.forwardRef(
|
|
|
751
754
|
}
|
|
752
755
|
);
|
|
753
756
|
Map2.displayName = "Map";
|
|
757
|
+
var SourceContext = React6__namespace.createContext(null);
|
|
754
758
|
var Source = ({
|
|
755
759
|
id,
|
|
756
760
|
type,
|
|
@@ -771,10 +775,10 @@ var Source = ({
|
|
|
771
775
|
children
|
|
772
776
|
}) => {
|
|
773
777
|
const { map, loaded, styleVersion } = useMap();
|
|
774
|
-
const initialFitDone =
|
|
775
|
-
const
|
|
776
|
-
const
|
|
777
|
-
const fitBoundsParamsRef =
|
|
778
|
+
const initialFitDone = React6__namespace.useRef(false);
|
|
779
|
+
const appliedDataRef = React6__namespace.useRef(void 0);
|
|
780
|
+
const [sourceVersion, setSourceVersion] = React6__namespace.useState(0);
|
|
781
|
+
const fitBoundsParamsRef = React6__namespace.useRef({
|
|
778
782
|
shouldFitBounds,
|
|
779
783
|
data,
|
|
780
784
|
fitBoundsPadding,
|
|
@@ -790,7 +794,7 @@ var Source = ({
|
|
|
790
794
|
fitBoundsAnimate,
|
|
791
795
|
type
|
|
792
796
|
};
|
|
793
|
-
const performFitBounds =
|
|
797
|
+
const performFitBounds = React6__namespace.useCallback(
|
|
794
798
|
(cancelledRef) => {
|
|
795
799
|
const params = fitBoundsParamsRef.current;
|
|
796
800
|
if (cancelledRef.current || !params.shouldFitBounds || initialFitDone.current) return;
|
|
@@ -834,12 +838,8 @@ var Source = ({
|
|
|
834
838
|
},
|
|
835
839
|
[map]
|
|
836
840
|
);
|
|
837
|
-
|
|
841
|
+
React6__namespace.useEffect(() => {
|
|
838
842
|
if (!map || !loaded) return;
|
|
839
|
-
if (styleVersion !== lastStyleVersionRef.current) {
|
|
840
|
-
lastStyleVersionRef.current = styleVersion;
|
|
841
|
-
initialFitDone.current = false;
|
|
842
|
-
}
|
|
843
843
|
if (map.getSource(id)) {
|
|
844
844
|
return;
|
|
845
845
|
}
|
|
@@ -928,6 +928,7 @@ var Source = ({
|
|
|
928
928
|
map.once("idle", handleIdle);
|
|
929
929
|
map.addSource(id, sourceConfig);
|
|
930
930
|
appliedDataRef.current = type === "geojson" ? data : void 0;
|
|
931
|
+
setSourceVersion((v) => v + 1);
|
|
931
932
|
const source = map.getSource(id);
|
|
932
933
|
if (source && map.isSourceLoaded(id)) {
|
|
933
934
|
map.off("sourcedata", handleSourceData);
|
|
@@ -986,7 +987,7 @@ var Source = ({
|
|
|
986
987
|
styleVersion
|
|
987
988
|
// re-add source after basemap style changes
|
|
988
989
|
]);
|
|
989
|
-
|
|
990
|
+
React6__namespace.useEffect(() => {
|
|
990
991
|
if (!map || !loaded || type !== "geojson") return;
|
|
991
992
|
const source = map.getSource(id);
|
|
992
993
|
if (!source) return;
|
|
@@ -1017,10 +1018,11 @@ var Source = ({
|
|
|
1017
1018
|
console.error(`[maps-react] Failed to update source "${id}" data:`, err);
|
|
1018
1019
|
}
|
|
1019
1020
|
}, [map, loaded, id, type, data, cluster]);
|
|
1020
|
-
|
|
1021
|
+
const sourceContext = React6__namespace.useMemo(() => ({ id, version: sourceVersion }), [id, sourceVersion]);
|
|
1022
|
+
return /* @__PURE__ */ jsxRuntime.jsx(SourceContext.Provider, { value: sourceContext, children });
|
|
1021
1023
|
};
|
|
1022
1024
|
Source.displayName = "Source";
|
|
1023
|
-
var Marker =
|
|
1025
|
+
var Marker = React6__namespace.forwardRef(
|
|
1024
1026
|
({
|
|
1025
1027
|
id,
|
|
1026
1028
|
coordinates,
|
|
@@ -1036,30 +1038,30 @@ var Marker = React26__namespace.forwardRef(
|
|
|
1036
1038
|
children
|
|
1037
1039
|
}, ref) => {
|
|
1038
1040
|
const { map, loaded } = useMap();
|
|
1039
|
-
const markerRef =
|
|
1040
|
-
const elementRef =
|
|
1041
|
-
const originalLngLatRef =
|
|
1042
|
-
const clickHandlerRef =
|
|
1043
|
-
const dragStartHandlerRef =
|
|
1044
|
-
const dragHandlerRef =
|
|
1045
|
-
const dragEndHandlerRef =
|
|
1046
|
-
const [mounted, setMounted] =
|
|
1047
|
-
const onClickRef =
|
|
1041
|
+
const markerRef = React6__namespace.useRef(null);
|
|
1042
|
+
const elementRef = React6__namespace.useRef(null);
|
|
1043
|
+
const originalLngLatRef = React6__namespace.useRef();
|
|
1044
|
+
const clickHandlerRef = React6__namespace.useRef(null);
|
|
1045
|
+
const dragStartHandlerRef = React6__namespace.useRef(null);
|
|
1046
|
+
const dragHandlerRef = React6__namespace.useRef(null);
|
|
1047
|
+
const dragEndHandlerRef = React6__namespace.useRef(null);
|
|
1048
|
+
const [mounted, setMounted] = React6__namespace.useState(false);
|
|
1049
|
+
const onClickRef = React6__namespace.useRef(onClick);
|
|
1048
1050
|
onClickRef.current = onClick;
|
|
1049
|
-
const onDragRef =
|
|
1051
|
+
const onDragRef = React6__namespace.useRef(onDrag);
|
|
1050
1052
|
onDragRef.current = onDrag;
|
|
1051
|
-
const onDragEndRef =
|
|
1053
|
+
const onDragEndRef = React6__namespace.useRef(onDragEnd);
|
|
1052
1054
|
onDragEndRef.current = onDragEnd;
|
|
1053
|
-
|
|
1055
|
+
React6__namespace.useEffect(() => {
|
|
1054
1056
|
setMounted(true);
|
|
1055
1057
|
return () => setMounted(false);
|
|
1056
1058
|
}, []);
|
|
1057
|
-
|
|
1059
|
+
React6__namespace.useEffect(() => {
|
|
1058
1060
|
if (children && !elementRef.current) {
|
|
1059
1061
|
elementRef.current = document.createElement("div");
|
|
1060
1062
|
}
|
|
1061
1063
|
}, [children]);
|
|
1062
|
-
|
|
1064
|
+
React6__namespace.useEffect(() => {
|
|
1063
1065
|
if (!map || !loaded || !mounted) return;
|
|
1064
1066
|
if (markerRef.current) return;
|
|
1065
1067
|
const markerOptions = {
|
|
@@ -1163,12 +1165,12 @@ var Marker = React26__namespace.forwardRef(
|
|
|
1163
1165
|
}
|
|
1164
1166
|
};
|
|
1165
1167
|
}, [map, loaded, mounted]);
|
|
1166
|
-
|
|
1168
|
+
React6__namespace.useEffect(() => {
|
|
1167
1169
|
if (markerRef.current) {
|
|
1168
1170
|
markerRef.current.setLngLat(coordinates);
|
|
1169
1171
|
}
|
|
1170
1172
|
}, [coordinates]);
|
|
1171
|
-
|
|
1173
|
+
React6__namespace.useEffect(() => {
|
|
1172
1174
|
const marker = markerRef.current;
|
|
1173
1175
|
if (!marker) return;
|
|
1174
1176
|
marker.setDraggable(draggable);
|
|
@@ -1216,12 +1218,12 @@ var Marker = React26__namespace.forwardRef(
|
|
|
1216
1218
|
marker.on("dragend", handleDragEnd);
|
|
1217
1219
|
}
|
|
1218
1220
|
}, [draggable, id]);
|
|
1219
|
-
|
|
1221
|
+
React6__namespace.useEffect(() => {
|
|
1220
1222
|
if (markerRef.current && rotation !== void 0) {
|
|
1221
1223
|
markerRef.current.setRotation(rotation);
|
|
1222
1224
|
}
|
|
1223
1225
|
}, [rotation]);
|
|
1224
|
-
|
|
1226
|
+
React6__namespace.useEffect(() => {
|
|
1225
1227
|
if (markerRef.current && offset) {
|
|
1226
1228
|
markerRef.current.setOffset(offset);
|
|
1227
1229
|
}
|
|
@@ -1234,13 +1236,13 @@ var Marker = React26__namespace.forwardRef(
|
|
|
1234
1236
|
);
|
|
1235
1237
|
Marker.displayName = "Marker";
|
|
1236
1238
|
function useStructuralValue(next) {
|
|
1237
|
-
const ref =
|
|
1239
|
+
const ref = React6__namespace.useRef(next);
|
|
1238
1240
|
if (ref.current !== next && JSON.stringify(ref.current) !== JSON.stringify(next)) {
|
|
1239
1241
|
ref.current = next;
|
|
1240
1242
|
}
|
|
1241
1243
|
return ref.current;
|
|
1242
1244
|
}
|
|
1243
|
-
var Popup =
|
|
1245
|
+
var Popup = React6__namespace.forwardRef(
|
|
1244
1246
|
({
|
|
1245
1247
|
coordinates: coordinatesProp,
|
|
1246
1248
|
closeButton = true,
|
|
@@ -1261,26 +1263,26 @@ var Popup = React26__namespace.forwardRef(
|
|
|
1261
1263
|
const coordinates = useStructuralValue(coordinatesProp);
|
|
1262
1264
|
const offset = useStructuralValue(offsetProp);
|
|
1263
1265
|
const autoPanPadding = useStructuralValue(autoPanPaddingProp);
|
|
1264
|
-
const popupRef =
|
|
1265
|
-
const onOpenRef =
|
|
1266
|
+
const popupRef = React6__namespace.useRef(null);
|
|
1267
|
+
const onOpenRef = React6__namespace.useRef(onOpen);
|
|
1266
1268
|
onOpenRef.current = onOpen;
|
|
1267
|
-
const onCloseRef =
|
|
1269
|
+
const onCloseRef = React6__namespace.useRef(onClose);
|
|
1268
1270
|
onCloseRef.current = onClose;
|
|
1269
|
-
const coordinatesRef =
|
|
1271
|
+
const coordinatesRef = React6__namespace.useRef(coordinates);
|
|
1270
1272
|
coordinatesRef.current = coordinates;
|
|
1271
|
-
const containerRef =
|
|
1273
|
+
const containerRef = React6__namespace.useRef(null);
|
|
1272
1274
|
if (!containerRef.current && typeof document !== "undefined") {
|
|
1273
1275
|
containerRef.current = document.createElement("div");
|
|
1274
1276
|
containerRef.current.className = "maplibregl-popup-content-wrapper";
|
|
1275
1277
|
}
|
|
1276
|
-
const [contentReady, setContentReady] =
|
|
1277
|
-
const [popupVersion, setPopupVersion] =
|
|
1278
|
-
const contentCallbackRef =
|
|
1278
|
+
const [contentReady, setContentReady] = React6__namespace.useState(false);
|
|
1279
|
+
const [popupVersion, setPopupVersion] = React6__namespace.useState(0);
|
|
1280
|
+
const contentCallbackRef = React6__namespace.useCallback((node) => {
|
|
1279
1281
|
if (node && containerRef.current) {
|
|
1280
1282
|
setContentReady(true);
|
|
1281
1283
|
}
|
|
1282
1284
|
}, []);
|
|
1283
|
-
|
|
1285
|
+
React6__namespace.useEffect(() => {
|
|
1284
1286
|
if (!map || !loaded || !containerRef.current) return;
|
|
1285
1287
|
const popup = new maplibregl__default.default.Popup({
|
|
1286
1288
|
closeButton,
|
|
@@ -1321,7 +1323,7 @@ var Popup = React26__namespace.forwardRef(
|
|
|
1321
1323
|
maxWidth,
|
|
1322
1324
|
focusAfterOpen
|
|
1323
1325
|
]);
|
|
1324
|
-
|
|
1326
|
+
React6__namespace.useEffect(() => {
|
|
1325
1327
|
if (!popupRef.current || !ref) return;
|
|
1326
1328
|
if (typeof ref === "function") {
|
|
1327
1329
|
ref(popupRef.current);
|
|
@@ -1329,16 +1331,17 @@ var Popup = React26__namespace.forwardRef(
|
|
|
1329
1331
|
ref.current = popupRef.current;
|
|
1330
1332
|
}
|
|
1331
1333
|
}, [ref, popupVersion]);
|
|
1332
|
-
|
|
1334
|
+
React6__namespace.useEffect(() => {
|
|
1333
1335
|
if (popupRef.current) {
|
|
1334
1336
|
popupRef.current.setLngLat(coordinates);
|
|
1335
1337
|
}
|
|
1336
1338
|
}, [coordinates]);
|
|
1337
|
-
|
|
1339
|
+
React6__namespace.useEffect(() => {
|
|
1338
1340
|
if (!map || !popupRef.current || !contentReady) return;
|
|
1339
1341
|
let rafHandle;
|
|
1340
1342
|
if (open) {
|
|
1341
|
-
popupRef.current.setLngLat(coordinates)
|
|
1343
|
+
popupRef.current.setLngLat(coordinates);
|
|
1344
|
+
if (!popupRef.current.isOpen()) popupRef.current.addTo(map);
|
|
1342
1345
|
if (autoPan) {
|
|
1343
1346
|
rafHandle = requestAnimationFrame(() => {
|
|
1344
1347
|
if (popupRef.current && map) {
|
|
@@ -1363,7 +1366,7 @@ var Popup = React26__namespace.forwardRef(
|
|
|
1363
1366
|
}
|
|
1364
1367
|
);
|
|
1365
1368
|
Popup.displayName = "Popup";
|
|
1366
|
-
var PopupCard =
|
|
1369
|
+
var PopupCard = React6__namespace.forwardRef(
|
|
1367
1370
|
({ className, children, ...props }, ref) => {
|
|
1368
1371
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: cn("bg-popover text-popover-foreground", className), ...props, children });
|
|
1369
1372
|
}
|
|
@@ -1383,7 +1386,7 @@ var badgeVariants = classVarianceAuthority.cva("text-xs px-1.5 py-0.5 rounded fo
|
|
|
1383
1386
|
badgeVariant: "secondary"
|
|
1384
1387
|
}
|
|
1385
1388
|
});
|
|
1386
|
-
var PopupHeader =
|
|
1389
|
+
var PopupHeader = React6__namespace.forwardRef(
|
|
1387
1390
|
({ className, title, badge, badgeVariant, ...props }, ref) => {
|
|
1388
1391
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1389
1392
|
"div",
|
|
@@ -1403,13 +1406,13 @@ var PopupHeader = React26__namespace.forwardRef(
|
|
|
1403
1406
|
}
|
|
1404
1407
|
);
|
|
1405
1408
|
PopupHeader.displayName = "PopupHeader";
|
|
1406
|
-
var PopupContent =
|
|
1409
|
+
var PopupContent = React6__namespace.forwardRef(
|
|
1407
1410
|
({ className, children, ...props }, ref) => {
|
|
1408
1411
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: cn("px-4 py-3 text-sm", className), ...props, children });
|
|
1409
1412
|
}
|
|
1410
1413
|
);
|
|
1411
1414
|
PopupContent.displayName = "PopupContent";
|
|
1412
|
-
var PopupFooter =
|
|
1415
|
+
var PopupFooter = React6__namespace.forwardRef(
|
|
1413
1416
|
({ className, children, ...props }, ref) => {
|
|
1414
1417
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1415
1418
|
"div",
|
|
@@ -1426,6 +1429,11 @@ var PopupFooter = React26__namespace.forwardRef(
|
|
|
1426
1429
|
}
|
|
1427
1430
|
);
|
|
1428
1431
|
PopupFooter.displayName = "PopupFooter";
|
|
1432
|
+
function withoutVisibility(layout) {
|
|
1433
|
+
const next = { ...layout ?? {} };
|
|
1434
|
+
delete next.visibility;
|
|
1435
|
+
return next;
|
|
1436
|
+
}
|
|
1429
1437
|
function useLayer({
|
|
1430
1438
|
id,
|
|
1431
1439
|
source,
|
|
@@ -1444,40 +1452,32 @@ function useLayer({
|
|
|
1444
1452
|
hoverThrottleMs = 0
|
|
1445
1453
|
}) {
|
|
1446
1454
|
const { map, loaded, styleVersion } = useMap();
|
|
1447
|
-
const
|
|
1448
|
-
const
|
|
1449
|
-
const
|
|
1450
|
-
const
|
|
1451
|
-
|
|
1455
|
+
const sourceContext = React6__namespace.useContext(SourceContext);
|
|
1456
|
+
const sourceVersion = sourceContext?.id === source ? sourceContext.version : 0;
|
|
1457
|
+
const [layerAdded, setLayerAdded] = React6__namespace.useState(false);
|
|
1458
|
+
const hoveredFeatureId = React6__namespace.useRef(null);
|
|
1459
|
+
const lastHoverCallTime = React6__namespace.useRef(0);
|
|
1460
|
+
const lastMousePosition = React6__namespace.useRef(null);
|
|
1461
|
+
const lastAppliedPaintRef = React6__namespace.useRef(void 0);
|
|
1462
|
+
const lastAppliedLayoutRef = React6__namespace.useRef(void 0);
|
|
1463
|
+
React6__namespace.useEffect(() => {
|
|
1452
1464
|
hoveredFeatureId.current = null;
|
|
1453
1465
|
}, [styleVersion]);
|
|
1454
|
-
|
|
1466
|
+
React6__namespace.useEffect(() => {
|
|
1455
1467
|
if (!map || !loaded) return;
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
if (timeoutId) clearTimeout(timeoutId);
|
|
1461
|
-
addLayer();
|
|
1462
|
-
map.off("sourcedata", checkSource);
|
|
1463
|
-
}
|
|
1464
|
-
};
|
|
1465
|
-
timeoutId = setTimeout(() => {
|
|
1466
|
-
if (!map.getSource(source)) {
|
|
1467
|
-
console.warn(
|
|
1468
|
-
`[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.`
|
|
1469
|
-
);
|
|
1470
|
-
}
|
|
1471
|
-
}, 5e3);
|
|
1472
|
-
map.on("sourcedata", checkSource);
|
|
1473
|
-
return () => {
|
|
1468
|
+
let added = false;
|
|
1469
|
+
let timeoutId = null;
|
|
1470
|
+
const checkSource = () => {
|
|
1471
|
+
if (map.getSource(source)) {
|
|
1474
1472
|
if (timeoutId) clearTimeout(timeoutId);
|
|
1473
|
+
timeoutId = null;
|
|
1475
1474
|
map.off("sourcedata", checkSource);
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1475
|
+
addLayer();
|
|
1476
|
+
}
|
|
1477
|
+
};
|
|
1479
1478
|
function addLayer() {
|
|
1480
1479
|
if (map.getLayer(id)) {
|
|
1480
|
+
added = true;
|
|
1481
1481
|
setLayerAdded(true);
|
|
1482
1482
|
return;
|
|
1483
1483
|
}
|
|
@@ -1505,30 +1505,46 @@ function useLayer({
|
|
|
1505
1505
|
layerConfig.filter = filter;
|
|
1506
1506
|
}
|
|
1507
1507
|
map.addLayer(layerConfig, beforeId);
|
|
1508
|
+
added = true;
|
|
1509
|
+
lastAppliedPaintRef.current = { ...paint };
|
|
1510
|
+
lastAppliedLayoutRef.current = withoutVisibility(layout);
|
|
1508
1511
|
setLayerAdded(true);
|
|
1509
1512
|
} catch (err) {
|
|
1510
1513
|
console.error(`[maps-react] Failed to add layer "${id}":`, err);
|
|
1511
1514
|
}
|
|
1512
1515
|
}
|
|
1516
|
+
if (map.getSource(source)) {
|
|
1517
|
+
addLayer();
|
|
1518
|
+
} else {
|
|
1519
|
+
timeoutId = setTimeout(() => {
|
|
1520
|
+
if (!map.getSource(source)) {
|
|
1521
|
+
console.warn(
|
|
1522
|
+
`[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.`
|
|
1523
|
+
);
|
|
1524
|
+
}
|
|
1525
|
+
}, 5e3);
|
|
1526
|
+
map.on("sourcedata", checkSource);
|
|
1527
|
+
}
|
|
1513
1528
|
return () => {
|
|
1514
|
-
if (
|
|
1529
|
+
if (timeoutId) clearTimeout(timeoutId);
|
|
1530
|
+
map.off("sourcedata", checkSource);
|
|
1531
|
+
if (added) {
|
|
1515
1532
|
try {
|
|
1516
1533
|
if (map.getLayer(id)) {
|
|
1517
1534
|
map.removeLayer(id);
|
|
1518
1535
|
}
|
|
1519
1536
|
} catch {
|
|
1520
1537
|
}
|
|
1521
|
-
setLayerAdded(false);
|
|
1522
1538
|
}
|
|
1539
|
+
setLayerAdded(false);
|
|
1523
1540
|
};
|
|
1524
|
-
}, [map, loaded, id, source, sourceLayer, type, beforeId, styleVersion]);
|
|
1525
|
-
|
|
1541
|
+
}, [map, loaded, id, source, sourceLayer, type, beforeId, styleVersion, sourceVersion]);
|
|
1542
|
+
React6__namespace.useEffect(() => {
|
|
1526
1543
|
if (!map || !layerAdded) return;
|
|
1527
1544
|
if (!map.getLayer(id)) return;
|
|
1528
1545
|
map.setLayoutProperty(id, "visibility", visible ? "visible" : "none");
|
|
1529
1546
|
}, [map, id, visible, layerAdded]);
|
|
1530
|
-
|
|
1531
|
-
React26__namespace.useEffect(() => {
|
|
1547
|
+
React6__namespace.useEffect(() => {
|
|
1532
1548
|
if (!map || !layerAdded) return;
|
|
1533
1549
|
if (!map.getLayer(id)) return;
|
|
1534
1550
|
const diff = mapsCore.getChangedPaintProps(lastAppliedPaintRef.current, paint);
|
|
@@ -1544,12 +1560,10 @@ function useLayer({
|
|
|
1544
1560
|
} catch {
|
|
1545
1561
|
}
|
|
1546
1562
|
}, [map, id, paint, layerAdded]);
|
|
1547
|
-
|
|
1548
|
-
React26__namespace.useEffect(() => {
|
|
1563
|
+
React6__namespace.useEffect(() => {
|
|
1549
1564
|
if (!map || !layerAdded) return;
|
|
1550
1565
|
if (!map.getLayer(id)) return;
|
|
1551
|
-
const next =
|
|
1552
|
-
delete next.visibility;
|
|
1566
|
+
const next = withoutVisibility(layout);
|
|
1553
1567
|
const diff = mapsCore.getChangedPaintProps(lastAppliedLayoutRef.current, next);
|
|
1554
1568
|
if (!diff.hasChanges) return;
|
|
1555
1569
|
try {
|
|
@@ -1563,17 +1577,17 @@ function useLayer({
|
|
|
1563
1577
|
} catch {
|
|
1564
1578
|
}
|
|
1565
1579
|
}, [map, id, layout, layerAdded]);
|
|
1566
|
-
|
|
1580
|
+
React6__namespace.useEffect(() => {
|
|
1567
1581
|
if (!map || !layerAdded) return;
|
|
1568
1582
|
if (!map.getLayer(id)) return;
|
|
1569
1583
|
map.setLayerZoomRange(id, minZoom ?? 0, maxZoom ?? 24);
|
|
1570
1584
|
}, [map, id, minZoom, maxZoom, layerAdded]);
|
|
1571
|
-
|
|
1585
|
+
React6__namespace.useEffect(() => {
|
|
1572
1586
|
if (!map || !layerAdded) return;
|
|
1573
1587
|
if (!map.getLayer(id)) return;
|
|
1574
1588
|
map.setFilter(id, filter ?? null);
|
|
1575
1589
|
}, [map, id, filter, layerAdded]);
|
|
1576
|
-
|
|
1590
|
+
React6__namespace.useEffect(() => {
|
|
1577
1591
|
if (!map || !layerAdded) return;
|
|
1578
1592
|
const createFeatureParams = (e) => {
|
|
1579
1593
|
const feature = e.features?.[0];
|
|
@@ -1725,7 +1739,7 @@ var FillLayer = ({
|
|
|
1725
1739
|
fillTranslate,
|
|
1726
1740
|
fillAntialias
|
|
1727
1741
|
}) => {
|
|
1728
|
-
const paint =
|
|
1742
|
+
const paint = React6__namespace.useMemo(() => {
|
|
1729
1743
|
const p = {};
|
|
1730
1744
|
if (fillColor !== void 0) p["fill-color"] = fillColor;
|
|
1731
1745
|
if (fillOpacity !== void 0) p["fill-opacity"] = fillOpacity;
|
|
@@ -1746,7 +1760,7 @@ var FillLayer = ({
|
|
|
1746
1760
|
fillAntialias,
|
|
1747
1761
|
opacity
|
|
1748
1762
|
]);
|
|
1749
|
-
const layout =
|
|
1763
|
+
const layout = React6__namespace.useMemo(() => ({}), []);
|
|
1750
1764
|
useLayer({
|
|
1751
1765
|
id,
|
|
1752
1766
|
source,
|
|
@@ -1790,7 +1804,7 @@ var LineLayer = ({
|
|
|
1790
1804
|
lineOffset,
|
|
1791
1805
|
lineGradient
|
|
1792
1806
|
}) => {
|
|
1793
|
-
const paint =
|
|
1807
|
+
const paint = React6__namespace.useMemo(() => {
|
|
1794
1808
|
const p = {};
|
|
1795
1809
|
if (lineColor !== void 0) p["line-color"] = lineColor;
|
|
1796
1810
|
if (lineWidth !== void 0) p["line-width"] = lineWidth;
|
|
@@ -1815,7 +1829,7 @@ var LineLayer = ({
|
|
|
1815
1829
|
lineGradient,
|
|
1816
1830
|
opacity
|
|
1817
1831
|
]);
|
|
1818
|
-
const layout =
|
|
1832
|
+
const layout = React6__namespace.useMemo(() => {
|
|
1819
1833
|
const l = {};
|
|
1820
1834
|
if (lineCap !== void 0) l["line-cap"] = lineCap;
|
|
1821
1835
|
if (lineJoin !== void 0) l["line-join"] = lineJoin;
|
|
@@ -1864,7 +1878,7 @@ var CircleLayer = ({
|
|
|
1864
1878
|
circlePitchScale,
|
|
1865
1879
|
circleTranslate
|
|
1866
1880
|
}) => {
|
|
1867
|
-
const paint =
|
|
1881
|
+
const paint = React6__namespace.useMemo(() => {
|
|
1868
1882
|
const p = {};
|
|
1869
1883
|
if (circleRadius !== void 0) p["circle-radius"] = circleRadius;
|
|
1870
1884
|
if (circleColor !== void 0) p["circle-color"] = circleColor;
|
|
@@ -1893,7 +1907,7 @@ var CircleLayer = ({
|
|
|
1893
1907
|
circleTranslate,
|
|
1894
1908
|
opacity
|
|
1895
1909
|
]);
|
|
1896
|
-
const layout =
|
|
1910
|
+
const layout = React6__namespace.useMemo(() => ({}), []);
|
|
1897
1911
|
useLayer({
|
|
1898
1912
|
id,
|
|
1899
1913
|
source,
|
|
@@ -1953,7 +1967,7 @@ var SymbolLayer = ({
|
|
|
1953
1967
|
symbolSpacing,
|
|
1954
1968
|
symbolSortKey
|
|
1955
1969
|
}) => {
|
|
1956
|
-
const paint =
|
|
1970
|
+
const paint = React6__namespace.useMemo(() => {
|
|
1957
1971
|
const p = {};
|
|
1958
1972
|
if (iconOpacity !== void 0) p["icon-opacity"] = iconOpacity;
|
|
1959
1973
|
if (iconColor !== void 0) p["icon-color"] = iconColor;
|
|
@@ -1974,7 +1988,7 @@ var SymbolLayer = ({
|
|
|
1974
1988
|
textHaloColor,
|
|
1975
1989
|
textHaloWidth
|
|
1976
1990
|
]);
|
|
1977
|
-
const layout =
|
|
1991
|
+
const layout = React6__namespace.useMemo(() => {
|
|
1978
1992
|
const l = {};
|
|
1979
1993
|
if (iconImage !== void 0) l["icon-image"] = iconImage;
|
|
1980
1994
|
if (iconSize !== void 0) l["icon-size"] = iconSize;
|
|
@@ -2055,7 +2069,7 @@ var FillExtrusionLayer = ({
|
|
|
2055
2069
|
fillExtrusionTranslate,
|
|
2056
2070
|
fillExtrusionVerticalGradient
|
|
2057
2071
|
}) => {
|
|
2058
|
-
const paint =
|
|
2072
|
+
const paint = React6__namespace.useMemo(() => {
|
|
2059
2073
|
const p = {};
|
|
2060
2074
|
if (fillExtrusionHeight !== void 0) p["fill-extrusion-height"] = fillExtrusionHeight;
|
|
2061
2075
|
if (fillExtrusionBase !== void 0) p["fill-extrusion-base"] = fillExtrusionBase;
|
|
@@ -2081,7 +2095,7 @@ var FillExtrusionLayer = ({
|
|
|
2081
2095
|
fillExtrusionVerticalGradient,
|
|
2082
2096
|
opacity
|
|
2083
2097
|
]);
|
|
2084
|
-
const layout =
|
|
2098
|
+
const layout = React6__namespace.useMemo(() => ({}), []);
|
|
2085
2099
|
useLayer({
|
|
2086
2100
|
id,
|
|
2087
2101
|
source,
|
|
@@ -2120,7 +2134,7 @@ var HeatmapLayer = ({
|
|
|
2120
2134
|
heatmapRadius,
|
|
2121
2135
|
heatmapOpacity
|
|
2122
2136
|
}) => {
|
|
2123
|
-
const paint =
|
|
2137
|
+
const paint = React6__namespace.useMemo(() => {
|
|
2124
2138
|
const p = {};
|
|
2125
2139
|
if (heatmapIntensity !== void 0) p["heatmap-intensity"] = heatmapIntensity;
|
|
2126
2140
|
if (heatmapWeight !== void 0) p["heatmap-weight"] = heatmapWeight;
|
|
@@ -2132,7 +2146,7 @@ var HeatmapLayer = ({
|
|
|
2132
2146
|
}
|
|
2133
2147
|
return p;
|
|
2134
2148
|
}, [heatmapIntensity, heatmapWeight, heatmapColor, heatmapRadius, heatmapOpacity, opacity]);
|
|
2135
|
-
const layout =
|
|
2149
|
+
const layout = React6__namespace.useMemo(() => ({}), []);
|
|
2136
2150
|
useLayer({
|
|
2137
2151
|
id,
|
|
2138
2152
|
source,
|
|
@@ -2164,8 +2178,8 @@ function useControlPosition(ref, options) {
|
|
|
2164
2178
|
isBuiltIn = false
|
|
2165
2179
|
} = options;
|
|
2166
2180
|
const { positioningCoordinator } = useMap();
|
|
2167
|
-
const [offset, setOffset] =
|
|
2168
|
-
|
|
2181
|
+
const [offset, setOffset] = React6__namespace.useState(null);
|
|
2182
|
+
React6__namespace.useEffect(() => {
|
|
2169
2183
|
if (!ref.current || !positioningCoordinator) return;
|
|
2170
2184
|
const element = ref.current;
|
|
2171
2185
|
const initialOffset = positioningCoordinator.register({
|
|
@@ -2219,7 +2233,7 @@ function useControlPosition(ref, options) {
|
|
|
2219
2233
|
positioningCoordinator,
|
|
2220
2234
|
ref
|
|
2221
2235
|
]);
|
|
2222
|
-
|
|
2236
|
+
React6__namespace.useEffect(() => {
|
|
2223
2237
|
if (!positioningCoordinator) return;
|
|
2224
2238
|
positioningCoordinator.update(id, {
|
|
2225
2239
|
position: {
|
|
@@ -2230,7 +2244,7 @@ function useControlPosition(ref, options) {
|
|
|
2230
2244
|
zLayer
|
|
2231
2245
|
});
|
|
2232
2246
|
}, [id, position, fallbacks, priority, zLayer, positioningCoordinator]);
|
|
2233
|
-
const setExpanded =
|
|
2247
|
+
const setExpanded = React6__namespace.useCallback(
|
|
2234
2248
|
(isExpanded) => {
|
|
2235
2249
|
if (positioningCoordinator) {
|
|
2236
2250
|
positioningCoordinator.setExpanded(id, isExpanded);
|
|
@@ -2238,7 +2252,7 @@ function useControlPosition(ref, options) {
|
|
|
2238
2252
|
},
|
|
2239
2253
|
[id, positioningCoordinator]
|
|
2240
2254
|
);
|
|
2241
|
-
const style =
|
|
2255
|
+
const style = React6__namespace.useMemo(() => {
|
|
2242
2256
|
if (!offset) {
|
|
2243
2257
|
return {
|
|
2244
2258
|
position: "absolute",
|
|
@@ -2286,9 +2300,9 @@ var Legend = ({
|
|
|
2286
2300
|
class: className,
|
|
2287
2301
|
onItemClick
|
|
2288
2302
|
}) => {
|
|
2289
|
-
const [isCollapsed, setIsCollapsed] =
|
|
2290
|
-
const legendRef =
|
|
2291
|
-
const generatedId =
|
|
2303
|
+
const [isCollapsed, setIsCollapsed] = React6__namespace.useState(initialCollapsed);
|
|
2304
|
+
const legendRef = React6__namespace.useRef(null);
|
|
2305
|
+
const generatedId = React6__namespace.useId();
|
|
2292
2306
|
const legendId = `legend-${generatedId}`;
|
|
2293
2307
|
const { style, visible } = useControlPosition(legendRef, {
|
|
2294
2308
|
id: legendId,
|
|
@@ -2308,7 +2322,7 @@ var Legend = ({
|
|
|
2308
2322
|
setIsCollapsed(!isCollapsed);
|
|
2309
2323
|
}
|
|
2310
2324
|
};
|
|
2311
|
-
const gradientStyle =
|
|
2325
|
+
const gradientStyle = React6__namespace.useMemo(() => {
|
|
2312
2326
|
if (type !== "gradient" || gradient.length === 0) return "";
|
|
2313
2327
|
const stops = gradient.map((stop) => `${stop.color} ${stop.position * 100}%`).join(", ");
|
|
2314
2328
|
return `linear-gradient(to right, ${stops})`;
|
|
@@ -2409,14 +2423,14 @@ var LegendGroup = ({
|
|
|
2409
2423
|
allowCollapseAll = false,
|
|
2410
2424
|
class: className
|
|
2411
2425
|
}) => {
|
|
2412
|
-
const containerRef =
|
|
2413
|
-
const groupIdRef =
|
|
2426
|
+
const containerRef = React6__namespace.useRef(null);
|
|
2427
|
+
const groupIdRef = React6__namespace.useRef(`legend-group-${++legendGroupIdCounter}`);
|
|
2414
2428
|
const getInitialExpanded = () => {
|
|
2415
2429
|
if (controlledExpanded !== void 0) return controlledExpanded;
|
|
2416
2430
|
if (defaultExpanded) return defaultExpanded;
|
|
2417
2431
|
return legends[0]?.id || null;
|
|
2418
2432
|
};
|
|
2419
|
-
const [internalExpanded, setInternalExpanded] =
|
|
2433
|
+
const [internalExpanded, setInternalExpanded] = React6__namespace.useState(getInitialExpanded);
|
|
2420
2434
|
const expandedId = controlledExpanded !== void 0 ? controlledExpanded : internalExpanded;
|
|
2421
2435
|
const { style, visible, setExpanded } = useControlPosition(containerRef, {
|
|
2422
2436
|
id: groupIdRef.current,
|
|
@@ -2465,7 +2479,7 @@ var LegendGroup = ({
|
|
|
2465
2479
|
type: "button",
|
|
2466
2480
|
className: cn(
|
|
2467
2481
|
"w-full flex items-center justify-between px-3 py-2 font-medium text-card-foreground",
|
|
2468
|
-
"cursor-pointer hover:bg-muted
|
|
2482
|
+
"cursor-pointer hover:bg-muted",
|
|
2469
2483
|
isFirst && "rounded-t-lg",
|
|
2470
2484
|
isLast && !isExpanded && "rounded-b-lg"
|
|
2471
2485
|
),
|
|
@@ -2562,11 +2576,11 @@ var CoordinateDisplay = ({
|
|
|
2562
2576
|
class: className
|
|
2563
2577
|
}) => {
|
|
2564
2578
|
const { map, loaded } = useMap();
|
|
2565
|
-
const [cursorLngLat, setCursorLngLat] =
|
|
2566
|
-
const [currentZoom, setCurrentZoom] =
|
|
2567
|
-
const [currentBearing, setCurrentBearing] =
|
|
2568
|
-
const controlRef =
|
|
2569
|
-
const uniqueId =
|
|
2579
|
+
const [cursorLngLat, setCursorLngLat] = React6__namespace.useState(null);
|
|
2580
|
+
const [currentZoom, setCurrentZoom] = React6__namespace.useState(0);
|
|
2581
|
+
const [currentBearing, setCurrentBearing] = React6__namespace.useState(0);
|
|
2582
|
+
const controlRef = React6__namespace.useRef(null);
|
|
2583
|
+
const uniqueId = React6__namespace.useId();
|
|
2570
2584
|
const controlId = `coord-display${uniqueId}`;
|
|
2571
2585
|
const { style, visible } = useControlPosition(controlRef, {
|
|
2572
2586
|
id: controlId,
|
|
@@ -2575,7 +2589,7 @@ var CoordinateDisplay = ({
|
|
|
2575
2589
|
priority: "critical",
|
|
2576
2590
|
zLayer: "base"
|
|
2577
2591
|
});
|
|
2578
|
-
const adjustedStyle =
|
|
2592
|
+
const adjustedStyle = React6__namespace.useMemo(() => {
|
|
2579
2593
|
if (!style) return style;
|
|
2580
2594
|
if (position === "top-right") {
|
|
2581
2595
|
const rightOffset = NAV_CONTROL_WIDTH + mapsCore.STACK_GAP + mapsCore.EDGE_MARGIN;
|
|
@@ -2595,7 +2609,7 @@ var CoordinateDisplay = ({
|
|
|
2595
2609
|
}
|
|
2596
2610
|
return style;
|
|
2597
2611
|
}, [position, style]);
|
|
2598
|
-
const formatCoord =
|
|
2612
|
+
const formatCoord = React6__namespace.useCallback(
|
|
2599
2613
|
(lngLat) => {
|
|
2600
2614
|
return mapsCore.formatCoordinates(lngLat, precision, format);
|
|
2601
2615
|
},
|
|
@@ -2608,7 +2622,7 @@ var CoordinateDisplay = ({
|
|
|
2608
2622
|
const normalized = (bearing % 360 + 360) % 360;
|
|
2609
2623
|
return `${normalized.toFixed(0)}\xB0`;
|
|
2610
2624
|
};
|
|
2611
|
-
|
|
2625
|
+
React6__namespace.useEffect(() => {
|
|
2612
2626
|
if (!map || !loaded) return;
|
|
2613
2627
|
setCurrentZoom(map.getZoom());
|
|
2614
2628
|
setCurrentBearing(map.getBearing());
|
|
@@ -2675,16 +2689,19 @@ var BasemapSwitcher = ({
|
|
|
2675
2689
|
class: className
|
|
2676
2690
|
}) => {
|
|
2677
2691
|
const { setMapStyle } = useMap();
|
|
2678
|
-
const [isOpen, setIsOpen] =
|
|
2679
|
-
const [internalActiveId, setInternalActiveId] =
|
|
2692
|
+
const [isOpen, setIsOpen] = React6__namespace.useState(false);
|
|
2693
|
+
const [internalActiveId, setInternalActiveId] = React6__namespace.useState(
|
|
2680
2694
|
defaultBasemapId
|
|
2681
2695
|
);
|
|
2682
|
-
const containerRef =
|
|
2683
|
-
const panelRef =
|
|
2684
|
-
const
|
|
2696
|
+
const containerRef = React6__namespace.useRef(null);
|
|
2697
|
+
const panelRef = React6__namespace.useRef(null);
|
|
2698
|
+
const toggleRef = React6__namespace.useRef(null);
|
|
2699
|
+
const optionRefs = React6__namespace.useRef([]);
|
|
2700
|
+
const [tabStopIndex, setTabStopIndex] = React6__namespace.useState(0);
|
|
2701
|
+
const generatedId = React6__namespace.useId();
|
|
2685
2702
|
const switcherId = `basemap-switcher-${generatedId}`;
|
|
2686
2703
|
const sourceBasemaps = basemaps ?? mapsCore.FREE_BASEMAPS;
|
|
2687
|
-
const availableBasemaps =
|
|
2704
|
+
const availableBasemaps = React6__namespace.useMemo(() => {
|
|
2688
2705
|
const available = mapsCore.getAvailableBasemaps(sourceBasemaps, apiKeys);
|
|
2689
2706
|
if (extraBasemaps?.length) {
|
|
2690
2707
|
return [...available, ...mapsCore.getAvailableBasemaps(extraBasemaps, apiKeys)];
|
|
@@ -2692,6 +2709,15 @@ var BasemapSwitcher = ({
|
|
|
2692
2709
|
return available;
|
|
2693
2710
|
}, [sourceBasemaps, extraBasemaps, apiKeys]);
|
|
2694
2711
|
const currentActiveId = activeBasemapId ?? internalActiveId ?? availableBasemaps[0]?.id;
|
|
2712
|
+
const activeIndex = Math.max(
|
|
2713
|
+
0,
|
|
2714
|
+
availableBasemaps.findIndex((basemap) => basemap.id === currentActiveId)
|
|
2715
|
+
);
|
|
2716
|
+
React6__namespace.useEffect(() => {
|
|
2717
|
+
if (!isOpen) return;
|
|
2718
|
+
setTabStopIndex(activeIndex);
|
|
2719
|
+
optionRefs.current[activeIndex]?.focus();
|
|
2720
|
+
}, [isOpen]);
|
|
2695
2721
|
const { style, visible, setExpanded } = useControlPosition(containerRef, {
|
|
2696
2722
|
id: switcherId,
|
|
2697
2723
|
type: "basemap-switcher",
|
|
@@ -2700,7 +2726,7 @@ var BasemapSwitcher = ({
|
|
|
2700
2726
|
zLayer: "interactive",
|
|
2701
2727
|
hasExpandedState: true
|
|
2702
2728
|
});
|
|
2703
|
-
|
|
2729
|
+
React6__namespace.useEffect(() => {
|
|
2704
2730
|
if (!isOpen) return;
|
|
2705
2731
|
const handleMouseDown = (e) => {
|
|
2706
2732
|
if (containerRef.current && !containerRef.current.contains(e.target)) {
|
|
@@ -2711,12 +2737,13 @@ var BasemapSwitcher = ({
|
|
|
2711
2737
|
document.addEventListener("mousedown", handleMouseDown);
|
|
2712
2738
|
return () => document.removeEventListener("mousedown", handleMouseDown);
|
|
2713
2739
|
}, [isOpen, setExpanded]);
|
|
2714
|
-
|
|
2740
|
+
React6__namespace.useEffect(() => {
|
|
2715
2741
|
if (!isOpen) return;
|
|
2716
2742
|
const handleKeyDown = (e) => {
|
|
2717
2743
|
if (e.key === "Escape") {
|
|
2718
2744
|
setIsOpen(false);
|
|
2719
2745
|
setExpanded(false);
|
|
2746
|
+
toggleRef.current?.focus();
|
|
2720
2747
|
}
|
|
2721
2748
|
};
|
|
2722
2749
|
document.addEventListener("keydown", handleKeyDown);
|
|
@@ -2737,6 +2764,14 @@ var BasemapSwitcher = ({
|
|
|
2737
2764
|
onBasemapChange?.(basemap);
|
|
2738
2765
|
setIsOpen(false);
|
|
2739
2766
|
setExpanded(false);
|
|
2767
|
+
toggleRef.current?.focus();
|
|
2768
|
+
};
|
|
2769
|
+
const handleOptionsKeyDown = (e) => {
|
|
2770
|
+
const next = mapsCore.getGridNavigationIndex(e.key, tabStopIndex, availableBasemaps.length, columns);
|
|
2771
|
+
if (next === null) return;
|
|
2772
|
+
e.preventDefault();
|
|
2773
|
+
setTabStopIndex(next);
|
|
2774
|
+
optionRefs.current[next]?.focus();
|
|
2740
2775
|
};
|
|
2741
2776
|
const handleToggle = () => {
|
|
2742
2777
|
const newState = !isOpen;
|
|
@@ -2768,25 +2803,32 @@ var BasemapSwitcher = ({
|
|
|
2768
2803
|
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2769
2804
|
"div",
|
|
2770
2805
|
{
|
|
2771
|
-
role: "
|
|
2806
|
+
role: "radiogroup",
|
|
2772
2807
|
"aria-label": "Select basemap",
|
|
2773
2808
|
className: "grid gap-1.5",
|
|
2774
2809
|
style: {
|
|
2775
2810
|
gridTemplateColumns: `repeat(${columns}, 1fr)`
|
|
2776
2811
|
},
|
|
2777
|
-
|
|
2812
|
+
onKeyDown: handleOptionsKeyDown,
|
|
2813
|
+
children: availableBasemaps.map((basemap, index) => {
|
|
2778
2814
|
const isActive = basemap.id === currentActiveId;
|
|
2779
2815
|
const thumbUrl = mapsCore.resolveBasemapThumbnail(basemap, apiKeys);
|
|
2780
2816
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2781
2817
|
"button",
|
|
2782
2818
|
{
|
|
2819
|
+
ref: (el) => {
|
|
2820
|
+
optionRefs.current[index] = el;
|
|
2821
|
+
},
|
|
2783
2822
|
type: "button",
|
|
2784
|
-
"
|
|
2823
|
+
role: "radio",
|
|
2824
|
+
"aria-checked": isActive,
|
|
2825
|
+
tabIndex: index === tabStopIndex ? 0 : -1,
|
|
2785
2826
|
className: cn(
|
|
2786
2827
|
"flex flex-col items-center gap-1 p-1 rounded cursor-pointer",
|
|
2787
|
-
"hover:bg-muted
|
|
2828
|
+
"hover:bg-muted",
|
|
2788
2829
|
isActive && "ring-2 ring-primary"
|
|
2789
2830
|
),
|
|
2831
|
+
onFocus: () => setTabStopIndex(index),
|
|
2790
2832
|
onClick: () => handleSelect(basemap),
|
|
2791
2833
|
title: basemap.name,
|
|
2792
2834
|
children: [
|
|
@@ -2816,11 +2858,12 @@ var BasemapSwitcher = ({
|
|
|
2816
2858
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2817
2859
|
"button",
|
|
2818
2860
|
{
|
|
2861
|
+
ref: toggleRef,
|
|
2819
2862
|
type: "button",
|
|
2820
2863
|
className: cn(
|
|
2821
2864
|
"w-[40px] h-[40px] flex items-center justify-center",
|
|
2822
2865
|
"bg-card rounded shadow-lg border border-black dark:border-gray-400",
|
|
2823
|
-
"hover:bg-muted
|
|
2866
|
+
"hover:bg-muted cursor-pointer",
|
|
2824
2867
|
"text-foreground"
|
|
2825
2868
|
),
|
|
2826
2869
|
onClick: handleToggle,
|
|
@@ -2866,20 +2909,20 @@ var LayerManager = ({
|
|
|
2866
2909
|
class: className
|
|
2867
2910
|
}) => {
|
|
2868
2911
|
const { isDark } = useMapTheme();
|
|
2869
|
-
const [isOpen, setIsOpen] =
|
|
2870
|
-
const [layerStates, setLayerStates] =
|
|
2912
|
+
const [isOpen, setIsOpen] = React6__namespace.useState(false);
|
|
2913
|
+
const [layerStates, setLayerStates] = React6__namespace.useState(
|
|
2871
2914
|
() => mapsCore.createInitialLayerStates(layers, initialActiveLayers)
|
|
2872
2915
|
);
|
|
2873
|
-
const [searchQuery, setSearchQuery] =
|
|
2874
|
-
const [activeCategory, setActiveCategory] =
|
|
2875
|
-
const [expandedOpacity, setExpandedOpacity] =
|
|
2876
|
-
const [draggedId, setDraggedId] =
|
|
2877
|
-
const [dragOver, setDragOver] =
|
|
2878
|
-
const containerRef =
|
|
2879
|
-
const uniqueId =
|
|
2916
|
+
const [searchQuery, setSearchQuery] = React6__namespace.useState("");
|
|
2917
|
+
const [activeCategory, setActiveCategory] = React6__namespace.useState("all");
|
|
2918
|
+
const [expandedOpacity, setExpandedOpacity] = React6__namespace.useState(null);
|
|
2919
|
+
const [draggedId, setDraggedId] = React6__namespace.useState(null);
|
|
2920
|
+
const [dragOver, setDragOver] = React6__namespace.useState(null);
|
|
2921
|
+
const containerRef = React6__namespace.useRef(null);
|
|
2922
|
+
const uniqueId = React6__namespace.useId();
|
|
2880
2923
|
const managerId = `layer-manager${uniqueId}`;
|
|
2881
|
-
const lastLayerIdsRef =
|
|
2882
|
-
const tilesCacheRef =
|
|
2924
|
+
const lastLayerIdsRef = React6__namespace.useRef(new Set(layers.map((l) => l.id)));
|
|
2925
|
+
const tilesCacheRef = React6__namespace.useRef(/* @__PURE__ */ new Map());
|
|
2883
2926
|
const getTiles = (url) => {
|
|
2884
2927
|
let tiles = tilesCacheRef.current.get(url);
|
|
2885
2928
|
if (!tiles) {
|
|
@@ -2896,7 +2939,7 @@ var LayerManager = ({
|
|
|
2896
2939
|
zLayer: "interactive",
|
|
2897
2940
|
hasExpandedState: true
|
|
2898
2941
|
});
|
|
2899
|
-
|
|
2942
|
+
React6__namespace.useEffect(() => {
|
|
2900
2943
|
const currentLayerIds = new Set(layers.map((l) => l.id));
|
|
2901
2944
|
const hasNewLayers = layers.some((l) => !lastLayerIdsRef.current.has(l.id));
|
|
2902
2945
|
const hasRemovedLayers = Array.from(lastLayerIdsRef.current).some(
|
|
@@ -2927,8 +2970,8 @@ var LayerManager = ({
|
|
|
2927
2970
|
lastLayerIdsRef.current = currentLayerIds;
|
|
2928
2971
|
}
|
|
2929
2972
|
}, [layers, initialActiveLayers]);
|
|
2930
|
-
const categories =
|
|
2931
|
-
const filteredLayers =
|
|
2973
|
+
const categories = React6__namespace.useMemo(() => mapsCore.getLayerCategories(layers), [layers]);
|
|
2974
|
+
const filteredLayers = React6__namespace.useMemo(() => {
|
|
2932
2975
|
let result = layers;
|
|
2933
2976
|
if (searchQuery) {
|
|
2934
2977
|
result = mapsCore.searchLayers(result, searchQuery);
|
|
@@ -2942,11 +2985,11 @@ var LayerManager = ({
|
|
|
2942
2985
|
return orderA - orderB;
|
|
2943
2986
|
});
|
|
2944
2987
|
}, [layers, searchQuery, activeCategory, layerStates]);
|
|
2945
|
-
const layerGroups =
|
|
2988
|
+
const layerGroups = React6__namespace.useMemo(
|
|
2946
2989
|
() => showCategories ? mapsCore.groupLayersByCategory(filteredLayers) : null,
|
|
2947
2990
|
[filteredLayers, showCategories]
|
|
2948
2991
|
);
|
|
2949
|
-
|
|
2992
|
+
React6__namespace.useEffect(() => {
|
|
2950
2993
|
if (!isOpen) return;
|
|
2951
2994
|
const handleMouseDown = (e) => {
|
|
2952
2995
|
if (containerRef.current && !containerRef.current.contains(e.target)) {
|
|
@@ -2957,7 +3000,7 @@ var LayerManager = ({
|
|
|
2957
3000
|
document.addEventListener("mousedown", handleMouseDown);
|
|
2958
3001
|
return () => document.removeEventListener("mousedown", handleMouseDown);
|
|
2959
3002
|
}, [isOpen, setExpanded]);
|
|
2960
|
-
|
|
3003
|
+
React6__namespace.useEffect(() => {
|
|
2961
3004
|
if (!isOpen) return;
|
|
2962
3005
|
const handleKeyDown = (e) => {
|
|
2963
3006
|
if (e.key === "Escape") {
|
|
@@ -2968,7 +3011,7 @@ var LayerManager = ({
|
|
|
2968
3011
|
document.addEventListener("keydown", handleKeyDown);
|
|
2969
3012
|
return () => document.removeEventListener("keydown", handleKeyDown);
|
|
2970
3013
|
}, [isOpen, setExpanded]);
|
|
2971
|
-
const handleToggleLayer =
|
|
3014
|
+
const handleToggleLayer = React6__namespace.useCallback(
|
|
2972
3015
|
(layerId) => {
|
|
2973
3016
|
setLayerStates((prev) => {
|
|
2974
3017
|
const newStates = mapsCore.toggleLayerVisibility(prev, layerId);
|
|
@@ -2981,7 +3024,7 @@ var LayerManager = ({
|
|
|
2981
3024
|
},
|
|
2982
3025
|
[onLayerChange]
|
|
2983
3026
|
);
|
|
2984
|
-
const handleOpacityChange =
|
|
3027
|
+
const handleOpacityChange = React6__namespace.useCallback(
|
|
2985
3028
|
(layerId, opacity) => {
|
|
2986
3029
|
setLayerStates((prev) => {
|
|
2987
3030
|
const newStates = mapsCore.setLayerOpacity(prev, layerId, opacity);
|
|
@@ -2994,12 +3037,12 @@ var LayerManager = ({
|
|
|
2994
3037
|
},
|
|
2995
3038
|
[onLayerChange]
|
|
2996
3039
|
);
|
|
2997
|
-
const handleDragStart =
|
|
3040
|
+
const handleDragStart = React6__namespace.useCallback((e, layerId) => {
|
|
2998
3041
|
setDraggedId(layerId);
|
|
2999
3042
|
e.dataTransfer.effectAllowed = "move";
|
|
3000
3043
|
e.dataTransfer.setData("text/plain", layerId);
|
|
3001
3044
|
}, []);
|
|
3002
|
-
const handleDragOver =
|
|
3045
|
+
const handleDragOver = React6__namespace.useCallback(
|
|
3003
3046
|
(e, layerId) => {
|
|
3004
3047
|
e.preventDefault();
|
|
3005
3048
|
e.dataTransfer.dropEffect = "move";
|
|
@@ -3019,14 +3062,14 @@ var LayerManager = ({
|
|
|
3019
3062
|
},
|
|
3020
3063
|
[draggedId, dragOver]
|
|
3021
3064
|
);
|
|
3022
|
-
const handleDragLeave =
|
|
3065
|
+
const handleDragLeave = React6__namespace.useCallback(() => {
|
|
3023
3066
|
setDragOver(null);
|
|
3024
3067
|
}, []);
|
|
3025
|
-
const handleDragEnd =
|
|
3068
|
+
const handleDragEnd = React6__namespace.useCallback(() => {
|
|
3026
3069
|
setDraggedId(null);
|
|
3027
3070
|
setDragOver(null);
|
|
3028
3071
|
}, []);
|
|
3029
|
-
const handleDrop =
|
|
3072
|
+
const handleDrop = React6__namespace.useCallback(
|
|
3030
3073
|
(e, targetLayerId) => {
|
|
3031
3074
|
e.preventDefault();
|
|
3032
3075
|
const sourceLayerId = e.dataTransfer.getData("text/plain");
|
|
@@ -3362,7 +3405,7 @@ var LayerManager = ({
|
|
|
3362
3405
|
if (catLayers.length === 0) return null;
|
|
3363
3406
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
3364
3407
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-3 py-2 text-xs font-medium text-muted-foreground uppercase tracking-wider", children: mapsCore.CATEGORY_META[cat].label }),
|
|
3365
|
-
catLayers.map((layer) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3408
|
+
catLayers.map((layer) => /* @__PURE__ */ jsxRuntime.jsxs(React6__namespace.Fragment, { children: [
|
|
3366
3409
|
renderLayerItem(layer),
|
|
3367
3410
|
renderOpacitySlider(layer.id)
|
|
3368
3411
|
] }, layer.id))
|
|
@@ -3370,7 +3413,7 @@ var LayerManager = ({
|
|
|
3370
3413
|
})
|
|
3371
3414
|
) : (
|
|
3372
3415
|
// Flat list
|
|
3373
|
-
filteredLayers.map((layer) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3416
|
+
filteredLayers.map((layer) => /* @__PURE__ */ jsxRuntime.jsxs(React6__namespace.Fragment, { children: [
|
|
3374
3417
|
renderLayerItem(layer),
|
|
3375
3418
|
renderOpacitySlider(layer.id)
|
|
3376
3419
|
] }, layer.id))
|
|
@@ -3387,7 +3430,7 @@ var LayerManager = ({
|
|
|
3387
3430
|
className: cn(
|
|
3388
3431
|
"w-[40px] h-[40px] flex items-center justify-center",
|
|
3389
3432
|
"bg-card rounded shadow-lg border border-black dark:border-gray-400",
|
|
3390
|
-
"hover:bg-muted
|
|
3433
|
+
"hover:bg-muted cursor-pointer",
|
|
3391
3434
|
"text-foreground"
|
|
3392
3435
|
),
|
|
3393
3436
|
onClick: handleToggle,
|
|
@@ -3431,8 +3474,8 @@ var CustomControl = ({
|
|
|
3431
3474
|
style: userStyle,
|
|
3432
3475
|
children
|
|
3433
3476
|
}) => {
|
|
3434
|
-
const controlRef =
|
|
3435
|
-
const generatedId =
|
|
3477
|
+
const controlRef = React6__namespace.useRef(null);
|
|
3478
|
+
const generatedId = React6__namespace.useId();
|
|
3436
3479
|
const controlId = id ?? `custom-control-${generatedId}`;
|
|
3437
3480
|
const { style, visible, setExpanded } = useControlPosition(controlRef, {
|
|
3438
3481
|
id: controlId,
|
|
@@ -3443,14 +3486,14 @@ var CustomControl = ({
|
|
|
3443
3486
|
zLayer,
|
|
3444
3487
|
hasExpandedState
|
|
3445
3488
|
});
|
|
3446
|
-
const mergedStyle =
|
|
3447
|
-
const contextValue =
|
|
3489
|
+
const mergedStyle = React6__namespace.useMemo(() => ({ ...style, ...userStyle }), [style, userStyle]);
|
|
3490
|
+
const contextValue = React6__namespace.useMemo(() => ({ setExpanded }), [setExpanded]);
|
|
3448
3491
|
return /* @__PURE__ */ jsxRuntime.jsx(CustomControlContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsxRuntime.jsx("div", { ref: controlRef, className: cn(!visible && "invisible", className), style: mergedStyle, children }) });
|
|
3449
3492
|
};
|
|
3450
3493
|
CustomControl.displayName = "CustomControl";
|
|
3451
|
-
var CustomControlContext =
|
|
3494
|
+
var CustomControlContext = React6__namespace.createContext(null);
|
|
3452
3495
|
function useCustomControl() {
|
|
3453
|
-
const context =
|
|
3496
|
+
const context = React6__namespace.useContext(CustomControlContext);
|
|
3454
3497
|
if (!context) {
|
|
3455
3498
|
throw new Error("useCustomControl must be used within a CustomControl");
|
|
3456
3499
|
}
|
|
@@ -3466,11 +3509,11 @@ var DeckOverlay = ({
|
|
|
3466
3509
|
deckProps = {}
|
|
3467
3510
|
}) => {
|
|
3468
3511
|
const { map, loaded } = useMap();
|
|
3469
|
-
const overlayRef =
|
|
3470
|
-
const MapboxOverlayRef =
|
|
3471
|
-
const layersRef =
|
|
3512
|
+
const overlayRef = React6__namespace.useRef(null);
|
|
3513
|
+
const MapboxOverlayRef = React6__namespace.useRef(null);
|
|
3514
|
+
const layersRef = React6__namespace.useRef(layers);
|
|
3472
3515
|
layersRef.current = layers;
|
|
3473
|
-
|
|
3516
|
+
React6__namespace.useEffect(() => {
|
|
3474
3517
|
if (!map || !loaded) return;
|
|
3475
3518
|
let cancelled = false;
|
|
3476
3519
|
const initOverlay = async () => {
|
|
@@ -3510,12 +3553,12 @@ var DeckOverlay = ({
|
|
|
3510
3553
|
}
|
|
3511
3554
|
};
|
|
3512
3555
|
}, [map, loaded, interleaved]);
|
|
3513
|
-
|
|
3556
|
+
React6__namespace.useEffect(() => {
|
|
3514
3557
|
if (overlayRef.current && "setProps" in overlayRef.current) {
|
|
3515
3558
|
overlayRef.current.setProps({ layers });
|
|
3516
3559
|
}
|
|
3517
3560
|
}, [layers]);
|
|
3518
|
-
|
|
3561
|
+
React6__namespace.useEffect(() => {
|
|
3519
3562
|
if (overlayRef.current && "setProps" in overlayRef.current) {
|
|
3520
3563
|
overlayRef.current.setProps({
|
|
3521
3564
|
onHover,
|
|
@@ -3524,7 +3567,7 @@ var DeckOverlay = ({
|
|
|
3524
3567
|
});
|
|
3525
3568
|
}
|
|
3526
3569
|
}, [onHover, onClick, getCursor]);
|
|
3527
|
-
|
|
3570
|
+
React6__namespace.useEffect(() => {
|
|
3528
3571
|
if (overlayRef.current && effects && "setProps" in overlayRef.current) {
|
|
3529
3572
|
overlayRef.current.setProps({ effects });
|
|
3530
3573
|
}
|