@classic-homes/maps-react 0.2.7 → 0.2.9

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/dist/index.cjs CHANGED
@@ -10,6 +10,7 @@ require('@classic-homes/maps-core/styles/controls.css');
10
10
  require('@classic-homes/maps-core/styles/marker.css');
11
11
  var mapsCore = require('@classic-homes/maps-core');
12
12
  var ReactDOM = require('react-dom');
13
+ var utils = require('@classic-homes/maps-core/utils');
13
14
  var classVarianceAuthority = require('class-variance-authority');
14
15
  require('@classic-homes/maps-core/styles/basemap-switcher.css');
15
16
  require('@classic-homes/maps-core/styles/layer-manager.css');
@@ -287,7 +288,7 @@ function useMapTheme(preference = "auto") {
287
288
  };
288
289
  }
289
290
  function useReducedMotion() {
290
- const [prefersReducedMotion2, setPrefersReducedMotion] = React26.useState(false);
291
+ const [prefersReducedMotion, setPrefersReducedMotion] = React26.useState(false);
291
292
  React26.useEffect(() => {
292
293
  if (typeof window === "undefined") return;
293
294
  const mediaQuery = window.matchMedia("(prefers-reduced-motion: reduce)");
@@ -300,7 +301,7 @@ function useReducedMotion() {
300
301
  mediaQuery.removeEventListener("change", handleChange);
301
302
  };
302
303
  }, []);
303
- return prefersReducedMotion2;
304
+ return prefersReducedMotion;
304
305
  }
305
306
  var MapContext = React26__namespace.createContext(null);
306
307
  function useMap() {
@@ -383,9 +384,15 @@ var Map2 = React26__namespace.forwardRef(
383
384
  const positioningCoordinator = positioningCoordinatorRef.current;
384
385
  const setMapStyle = React26__namespace.useCallback((style) => {
385
386
  activeStyleOverrideRef.current = style;
386
- mapRef.current?.setStyle(style);
387
+ const map = mapRef.current;
388
+ if (map) {
389
+ map.setStyle(style);
390
+ map.once("idle", () => {
391
+ setStyleVersion((v) => v + 1);
392
+ });
393
+ }
387
394
  }, []);
388
- const prefersReducedMotion2 = useReducedMotion();
395
+ const prefersReducedMotion = useReducedMotion();
389
396
  const { style: themeStyle } = useMapTheme(themePref);
390
397
  const onLoadRef = React26__namespace.useRef(onLoad);
391
398
  onLoadRef.current = onLoad;
@@ -440,11 +447,6 @@ var Map2 = React26__namespace.forwardRef(
440
447
  attributionControl: attributionControl ? { customAttribution } : false
441
448
  });
442
449
  mapRef.current = map;
443
- map.on("data", (e) => {
444
- if (e.dataType === "style") {
445
- setStyleVersion((v) => v + 1);
446
- }
447
- });
448
450
  if (navigationControl) {
449
451
  map.addControl(
450
452
  new maplibregl__default.default.NavigationControl({
@@ -514,12 +516,24 @@ var Map2 = React26__namespace.forwardRef(
514
516
  zLayer: "base"
515
517
  });
516
518
  }
519
+ const initTimeoutId = setTimeout(() => {
520
+ if (!mapRef.current?.loaded()) {
521
+ const errorMessage = "Map initialization timeout - style may be unreachable";
522
+ setMapError(errorMessage);
523
+ onErrorRef.current?.({
524
+ type: "error",
525
+ message: errorMessage,
526
+ error: new Error(errorMessage)
527
+ });
528
+ }
529
+ }, 3e4);
517
530
  map.on("load", () => {
531
+ clearTimeout(initTimeoutId);
518
532
  setMapLoaded(true);
519
533
  if (bounds) {
520
534
  map.fitBounds(bounds, {
521
535
  padding: boundsPadding,
522
- animate: animation && !prefersReducedMotion2
536
+ animate: animation && !prefersReducedMotion
523
537
  });
524
538
  }
525
539
  onLoadRef.current?.({ type: "load", loaded: true });
@@ -528,11 +542,13 @@ var Map2 = React26__namespace.forwardRef(
528
542
  const errorMessage = e.error?.message || "Map error";
529
543
  const isTransient = errorMessage.includes("non-existing layer") || errorMessage.includes("Cannot filter");
530
544
  if (!isTransient) {
545
+ clearTimeout(initTimeoutId);
531
546
  setMapError(errorMessage);
532
547
  }
533
548
  onErrorRef.current?.({ type: "error", message: errorMessage, error: e.error });
534
549
  });
535
550
  return () => {
551
+ clearTimeout(initTimeoutId);
536
552
  map.remove();
537
553
  mapRef.current = null;
538
554
  setMapLoaded(false);
@@ -543,6 +559,17 @@ var Map2 = React26__namespace.forwardRef(
543
559
  onErrorRef.current?.({ type: "error", message: errorMessage, error: err });
544
560
  }
545
561
  }, []);
562
+ React26__namespace.useEffect(() => {
563
+ const map = mapRef.current;
564
+ if (!map || !mapLoaded) return;
565
+ const handleStyleLoad = () => {
566
+ setStyleVersion((v) => v + 1);
567
+ };
568
+ map.on("style.load", handleStyleLoad);
569
+ return () => {
570
+ map.off("style.load", handleStyleLoad);
571
+ };
572
+ }, [mapLoaded]);
546
573
  const styleInitialized = React26__namespace.useRef(false);
547
574
  React26__namespace.useEffect(() => {
548
575
  if (!mapRef.current || !mapLoaded) return;
@@ -627,23 +654,23 @@ var Map2 = React26__namespace.forwardRef(
627
654
  const handleZoom = () => {
628
655
  onZoom?.({ type: "zoom", ...createMoveParams() });
629
656
  };
630
- if (onClick) map.on("click", handleClick);
631
- if (onDblClick) map.on("dblclick", handleDblClick);
632
- if (onContextMenu) map.on("contextmenu", handleContextMenu);
633
- if (onMouseMove) map.on("mousemove", handleMouseMove);
634
- if (onMove) map.on("move", handleMove);
635
- if (onMoveStart) map.on("movestart", handleMoveStart);
636
- if (onMoveEnd) map.on("moveend", handleMoveEnd);
637
- if (onZoom) map.on("zoom", handleZoom);
657
+ map.on("click", handleClick);
658
+ map.on("dblclick", handleDblClick);
659
+ map.on("contextmenu", handleContextMenu);
660
+ map.on("mousemove", handleMouseMove);
661
+ map.on("move", handleMove);
662
+ map.on("movestart", handleMoveStart);
663
+ map.on("moveend", handleMoveEnd);
664
+ map.on("zoom", handleZoom);
638
665
  return () => {
639
- if (onClick) map.off("click", handleClick);
640
- if (onDblClick) map.off("dblclick", handleDblClick);
641
- if (onContextMenu) map.off("contextmenu", handleContextMenu);
642
- if (onMouseMove) map.off("mousemove", handleMouseMove);
643
- if (onMove) map.off("move", handleMove);
644
- if (onMoveStart) map.off("movestart", handleMoveStart);
645
- if (onMoveEnd) map.off("moveend", handleMoveEnd);
646
- if (onZoom) map.off("zoom", handleZoom);
666
+ map.off("click", handleClick);
667
+ map.off("dblclick", handleDblClick);
668
+ map.off("contextmenu", handleContextMenu);
669
+ map.off("mousemove", handleMouseMove);
670
+ map.off("move", handleMove);
671
+ map.off("movestart", handleMoveStart);
672
+ map.off("moveend", handleMoveEnd);
673
+ map.off("zoom", handleZoom);
647
674
  };
648
675
  }, [
649
676
  mapLoaded,
@@ -657,6 +684,16 @@ var Map2 = React26__namespace.forwardRef(
657
684
  onZoom
658
685
  ]);
659
686
  const combinedError = error || mapError;
687
+ const contextValue = React26__namespace.useMemo(
688
+ () => ({
689
+ map: mapRef.current,
690
+ loaded: mapLoaded,
691
+ styleVersion,
692
+ setMapStyle,
693
+ positioningCoordinator
694
+ }),
695
+ [mapLoaded, styleVersion, setMapStyle, positioningCoordinator]
696
+ );
660
697
  return /* @__PURE__ */ jsxRuntime.jsx(
661
698
  MapContainer,
662
699
  {
@@ -669,22 +706,10 @@ var Map2 = React26__namespace.forwardRef(
669
706
  error: combinedError,
670
707
  emptyMessage,
671
708
  className,
672
- children: /* @__PURE__ */ jsxRuntime.jsxs(
673
- MapContext.Provider,
674
- {
675
- value: {
676
- map: mapRef.current,
677
- loaded: mapLoaded,
678
- styleVersion,
679
- setMapStyle,
680
- positioningCoordinator
681
- },
682
- children: [
683
- /* @__PURE__ */ jsxRuntime.jsx("div", { ref: containerRef, className: "absolute inset-0" }),
684
- mapLoaded && children && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute inset-0 pointer-events-none [&>*]:pointer-events-auto", children })
685
- ]
686
- }
687
- )
709
+ children: /* @__PURE__ */ jsxRuntime.jsxs(MapContext.Provider, { value: contextValue, children: [
710
+ /* @__PURE__ */ jsxRuntime.jsx("div", { ref: containerRef, className: "absolute inset-0" }),
711
+ mapLoaded && children && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute inset-0 pointer-events-none [&>*]:pointer-events-auto", children })
712
+ ] })
688
713
  }
689
714
  );
690
715
  }
@@ -744,7 +769,7 @@ var Source = ({
744
769
  console.warn("[maps-react] Source: Invalid bounds calculated, skipping fitBounds");
745
770
  return;
746
771
  }
747
- const prefersReducedMotion2 = typeof window !== "undefined" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
772
+ const prefersReducedMotion = typeof window !== "undefined" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
748
773
  const rafHandle = requestAnimationFrame(() => {
749
774
  if (cancelledRef.current || initialFitDone.current) return;
750
775
  try {
@@ -760,7 +785,7 @@ var Source = ({
760
785
  map.flyTo({
761
786
  center: [centerLng, centerLat],
762
787
  zoom: Math.max(zoom, 1),
763
- animate: params.fitBoundsAnimate && !prefersReducedMotion2,
788
+ animate: params.fitBoundsAnimate && !prefersReducedMotion,
764
789
  padding: params.fitBoundsPadding
765
790
  });
766
791
  initialFitDone.current = true;
@@ -975,6 +1000,9 @@ var Marker = React26__namespace.forwardRef(
975
1000
  const elementRef = React26__namespace.useRef(null);
976
1001
  const originalLngLatRef = React26__namespace.useRef();
977
1002
  const clickHandlerRef = React26__namespace.useRef(null);
1003
+ const dragStartHandlerRef = React26__namespace.useRef(null);
1004
+ const dragHandlerRef = React26__namespace.useRef(null);
1005
+ const dragEndHandlerRef = React26__namespace.useRef(null);
978
1006
  const [mounted, setMounted] = React26__namespace.useState(false);
979
1007
  const onClickRef = React26__namespace.useRef(onClick);
980
1008
  onClickRef.current = onClick;
@@ -1040,11 +1068,11 @@ var Marker = React26__namespace.forwardRef(
1040
1068
  element.addEventListener("click", handleClick);
1041
1069
  }
1042
1070
  if (draggable) {
1043
- marker.on("dragstart", () => {
1071
+ const handleDragStart = () => {
1044
1072
  const lngLat = marker.getLngLat();
1045
1073
  originalLngLatRef.current = [lngLat.lng, lngLat.lat];
1046
- });
1047
- marker.on("drag", () => {
1074
+ };
1075
+ const handleDrag = () => {
1048
1076
  const lngLat = marker.getLngLat();
1049
1077
  onDragRef.current?.({
1050
1078
  type: "drag",
@@ -1052,8 +1080,8 @@ var Marker = React26__namespace.forwardRef(
1052
1080
  lngLat: [lngLat.lng, lngLat.lat],
1053
1081
  originalLngLat: originalLngLatRef.current
1054
1082
  });
1055
- });
1056
- marker.on("dragend", () => {
1083
+ };
1084
+ const handleDragEnd = () => {
1057
1085
  const lngLat = marker.getLngLat();
1058
1086
  onDragEndRef.current?.({
1059
1087
  type: "dragend",
@@ -1061,13 +1089,33 @@ var Marker = React26__namespace.forwardRef(
1061
1089
  lngLat: [lngLat.lng, lngLat.lat],
1062
1090
  originalLngLat: originalLngLatRef.current
1063
1091
  });
1064
- });
1092
+ };
1093
+ dragStartHandlerRef.current = handleDragStart;
1094
+ dragHandlerRef.current = handleDrag;
1095
+ dragEndHandlerRef.current = handleDragEnd;
1096
+ marker.on("dragstart", handleDragStart);
1097
+ marker.on("drag", handleDrag);
1098
+ marker.on("dragend", handleDragEnd);
1065
1099
  }
1066
1100
  return () => {
1067
1101
  if (clickHandlerRef.current && markerRef.current) {
1068
1102
  markerRef.current.getElement().removeEventListener("click", clickHandlerRef.current);
1069
1103
  clickHandlerRef.current = null;
1070
1104
  }
1105
+ if (markerRef.current) {
1106
+ if (dragStartHandlerRef.current) {
1107
+ markerRef.current.off("dragstart", dragStartHandlerRef.current);
1108
+ dragStartHandlerRef.current = null;
1109
+ }
1110
+ if (dragHandlerRef.current) {
1111
+ markerRef.current.off("drag", dragHandlerRef.current);
1112
+ dragHandlerRef.current = null;
1113
+ }
1114
+ if (dragEndHandlerRef.current) {
1115
+ markerRef.current.off("dragend", dragEndHandlerRef.current);
1116
+ dragEndHandlerRef.current = null;
1117
+ }
1118
+ }
1071
1119
  if (markerRef.current) {
1072
1120
  mapsCore.removeMarkerProtection(markerRef.current.getElement());
1073
1121
  markerRef.current.remove();
@@ -1081,10 +1129,53 @@ var Marker = React26__namespace.forwardRef(
1081
1129
  }
1082
1130
  }, [coordinates]);
1083
1131
  React26__namespace.useEffect(() => {
1084
- if (markerRef.current) {
1085
- markerRef.current.setDraggable(draggable);
1132
+ const marker = markerRef.current;
1133
+ if (!marker) return;
1134
+ marker.setDraggable(draggable);
1135
+ if (!draggable) {
1136
+ if (dragStartHandlerRef.current) {
1137
+ marker.off("dragstart", dragStartHandlerRef.current);
1138
+ dragStartHandlerRef.current = null;
1139
+ }
1140
+ if (dragHandlerRef.current) {
1141
+ marker.off("drag", dragHandlerRef.current);
1142
+ dragHandlerRef.current = null;
1143
+ }
1144
+ if (dragEndHandlerRef.current) {
1145
+ marker.off("dragend", dragEndHandlerRef.current);
1146
+ dragEndHandlerRef.current = null;
1147
+ }
1148
+ } else if (!dragStartHandlerRef.current) {
1149
+ const handleDragStart = () => {
1150
+ const lngLat = marker.getLngLat();
1151
+ originalLngLatRef.current = [lngLat.lng, lngLat.lat];
1152
+ };
1153
+ const handleDrag = () => {
1154
+ const lngLat = marker.getLngLat();
1155
+ onDragRef.current?.({
1156
+ type: "drag",
1157
+ markerId: id || "",
1158
+ lngLat: [lngLat.lng, lngLat.lat],
1159
+ originalLngLat: originalLngLatRef.current
1160
+ });
1161
+ };
1162
+ const handleDragEnd = () => {
1163
+ const lngLat = marker.getLngLat();
1164
+ onDragEndRef.current?.({
1165
+ type: "dragend",
1166
+ markerId: id || "",
1167
+ lngLat: [lngLat.lng, lngLat.lat],
1168
+ originalLngLat: originalLngLatRef.current
1169
+ });
1170
+ };
1171
+ dragStartHandlerRef.current = handleDragStart;
1172
+ dragHandlerRef.current = handleDrag;
1173
+ dragEndHandlerRef.current = handleDragEnd;
1174
+ marker.on("dragstart", handleDragStart);
1175
+ marker.on("drag", handleDrag);
1176
+ marker.on("dragend", handleDragEnd);
1086
1177
  }
1087
- }, [draggable]);
1178
+ }, [draggable, id]);
1088
1179
  React26__namespace.useEffect(() => {
1089
1180
  if (markerRef.current && rotation !== void 0) {
1090
1181
  markerRef.current.setRotation(rotation);
@@ -1097,40 +1188,6 @@ var Marker = React26__namespace.forwardRef(
1097
1188
  }
1098
1189
  );
1099
1190
  Marker.displayName = "Marker";
1100
- function normalizePadding(padding) {
1101
- if (typeof padding === "number") {
1102
- return { top: padding, right: padding, bottom: padding, left: padding };
1103
- }
1104
- return padding;
1105
- }
1106
- function prefersReducedMotion() {
1107
- if (typeof window === "undefined") return false;
1108
- return window.matchMedia("(prefers-reduced-motion: reduce)").matches;
1109
- }
1110
- function panToFitPopup(map, popup, padding) {
1111
- const popupEl = popup.getElement();
1112
- if (!popupEl) return;
1113
- const mapContainer = map.getContainer();
1114
- const mapRect = mapContainer.getBoundingClientRect();
1115
- const popupRect = popupEl.getBoundingClientRect();
1116
- let dx = 0;
1117
- let dy = 0;
1118
- if (popupRect.left < mapRect.left + padding.left) {
1119
- dx = popupRect.left - mapRect.left - padding.left;
1120
- } else if (popupRect.right > mapRect.right - padding.right) {
1121
- dx = popupRect.right - mapRect.right + padding.right;
1122
- }
1123
- if (popupRect.top < mapRect.top + padding.top) {
1124
- dy = popupRect.top - mapRect.top - padding.top;
1125
- } else if (popupRect.bottom > mapRect.bottom - padding.bottom) {
1126
- dy = popupRect.bottom - mapRect.bottom + padding.bottom;
1127
- }
1128
- if (dx !== 0 || dy !== 0) {
1129
- map.panBy([dx, dy], {
1130
- animate: !prefersReducedMotion()
1131
- });
1132
- }
1133
- }
1134
1191
  var Popup = React26__namespace.forwardRef(
1135
1192
  ({
1136
1193
  coordinates,
@@ -1228,7 +1285,7 @@ var Popup = React26__namespace.forwardRef(
1228
1285
  if (autoPan) {
1229
1286
  rafHandle = requestAnimationFrame(() => {
1230
1287
  if (popupRef.current && map) {
1231
- panToFitPopup(map, popupRef.current, normalizePadding(autoPanPadding));
1288
+ utils.panToFitPopup(map, popupRef.current, utils.normalizePadding(autoPanPadding));
1232
1289
  }
1233
1290
  });
1234
1291
  }
@@ -1444,7 +1501,11 @@ function useLayer({
1444
1501
  const handleClick = (e) => {
1445
1502
  const params = createFeatureParams(e);
1446
1503
  if (params) {
1447
- onClick?.({ type: "click", ...params });
1504
+ try {
1505
+ onClick?.({ type: "click", ...params });
1506
+ } catch (err) {
1507
+ console.error(`[maps-react] Layer "${id}" click handler error:`, err);
1508
+ }
1448
1509
  }
1449
1510
  };
1450
1511
  const handleMouseEnter = (e) => {
@@ -1466,7 +1527,11 @@ function useLayer({
1466
1527
  }
1467
1528
  const params = createFeatureParams(e);
1468
1529
  if (params) {
1469
- onHover?.({ type: "mouseenter", ...params });
1530
+ try {
1531
+ onHover?.({ type: "mouseenter", ...params });
1532
+ } catch (err) {
1533
+ console.error(`[maps-react] Layer "${id}" hover handler error:`, err);
1534
+ }
1470
1535
  }
1471
1536
  };
1472
1537
  const handleMouseMove = (e) => {
@@ -1491,7 +1556,11 @@ function useLayer({
1491
1556
  lastHoverCallTime.current = now;
1492
1557
  const params = createFeatureParams(e);
1493
1558
  if (params) {
1494
- onHover?.({ type: "mousemove", ...params });
1559
+ try {
1560
+ onHover?.({ type: "mousemove", ...params });
1561
+ } catch (err) {
1562
+ console.error(`[maps-react] Layer "${id}" hover handler error:`, err);
1563
+ }
1495
1564
  }
1496
1565
  }
1497
1566
  } else {
@@ -1509,15 +1578,19 @@ function useLayer({
1509
1578
  hoveredFeatureId.current = null;
1510
1579
  }
1511
1580
  const lastPos = lastMousePosition.current;
1512
- onHover?.({
1513
- type: "mouseleave",
1514
- feature: null,
1515
- layerId: id,
1516
- sourceId: source,
1517
- lngLat: lastPos?.lngLat ?? [0, 0],
1518
- point: lastPos?.point ?? [0, 0],
1519
- map
1520
- });
1581
+ try {
1582
+ onHover?.({
1583
+ type: "mouseleave",
1584
+ feature: null,
1585
+ layerId: id,
1586
+ sourceId: source,
1587
+ lngLat: lastPos?.lngLat ?? [0, 0],
1588
+ point: lastPos?.point ?? [0, 0],
1589
+ map
1590
+ });
1591
+ } catch (err) {
1592
+ console.error(`[maps-react] Layer "${id}" hover handler error:`, err);
1593
+ }
1521
1594
  lastMousePosition.current = null;
1522
1595
  };
1523
1596
  if (onClick) {
@@ -2109,7 +2182,6 @@ function useControlPosition(ref, options) {
2109
2182
  visible: offset?.visible ?? false
2110
2183
  };
2111
2184
  }
2112
- var legendIdCounter = 0;
2113
2185
  var Legend = ({
2114
2186
  title,
2115
2187
  position = "bottom-left",
@@ -2125,9 +2197,10 @@ var Legend = ({
2125
2197
  }) => {
2126
2198
  const [isCollapsed, setIsCollapsed] = React26__namespace.useState(initialCollapsed);
2127
2199
  const legendRef = React26__namespace.useRef(null);
2128
- const legendIdRef = React26__namespace.useRef(`legend-${++legendIdCounter}`);
2200
+ const generatedId = React26__namespace.useId();
2201
+ const legendId = `legend-${generatedId}`;
2129
2202
  const { style, visible } = useControlPosition(legendRef, {
2130
- id: legendIdRef.current,
2203
+ id: legendId,
2131
2204
  type: "legend",
2132
2205
  position,
2133
2206
  priority: "normal",
@@ -2388,7 +2461,6 @@ var LegendGroup = ({
2388
2461
  );
2389
2462
  };
2390
2463
  LegendGroup.displayName = "LegendGroup";
2391
- var coordDisplayIdCounter = 0;
2392
2464
  var NAV_CONTROL_WIDTH = 29;
2393
2465
  var CoordinateDisplay = ({
2394
2466
  position = "bottom-right",
@@ -2403,9 +2475,10 @@ var CoordinateDisplay = ({
2403
2475
  const [currentZoom, setCurrentZoom] = React26__namespace.useState(0);
2404
2476
  const [currentBearing, setCurrentBearing] = React26__namespace.useState(0);
2405
2477
  const controlRef = React26__namespace.useRef(null);
2406
- const controlIdRef = React26__namespace.useRef(`coord-display-${++coordDisplayIdCounter}`);
2478
+ const uniqueId = React26__namespace.useId();
2479
+ const controlId = `coord-display${uniqueId}`;
2407
2480
  const { style, visible } = useControlPosition(controlRef, {
2408
- id: controlIdRef.current,
2481
+ id: controlId,
2409
2482
  type: "coordinate-display",
2410
2483
  position,
2411
2484
  priority: "critical",
@@ -2497,7 +2570,6 @@ var CoordinateDisplay = ({
2497
2570
  );
2498
2571
  };
2499
2572
  CoordinateDisplay.displayName = "CoordinateDisplay";
2500
- var switcherIdCounter = 0;
2501
2573
  var BasemapSwitcher = ({
2502
2574
  basemaps,
2503
2575
  extraBasemaps,
@@ -2505,6 +2577,7 @@ var BasemapSwitcher = ({
2505
2577
  defaultBasemapId,
2506
2578
  activeBasemapId,
2507
2579
  onBasemapChange,
2580
+ onStyleError,
2508
2581
  columns = 3,
2509
2582
  thumbnailSize = 64,
2510
2583
  position = "bottom-right",
@@ -2517,7 +2590,8 @@ var BasemapSwitcher = ({
2517
2590
  );
2518
2591
  const containerRef = React26__namespace.useRef(null);
2519
2592
  const panelRef = React26__namespace.useRef(null);
2520
- const switcherIdRef = React26__namespace.useRef(`basemap-switcher-${++switcherIdCounter}`);
2593
+ const generatedId = React26__namespace.useId();
2594
+ const switcherId = `basemap-switcher-${generatedId}`;
2521
2595
  const sourceBasemaps = basemaps ?? mapsCore.FREE_BASEMAPS;
2522
2596
  const availableBasemaps = React26__namespace.useMemo(() => {
2523
2597
  const available = mapsCore.getAvailableBasemaps(sourceBasemaps, apiKeys);
@@ -2528,7 +2602,7 @@ var BasemapSwitcher = ({
2528
2602
  }, [sourceBasemaps, extraBasemaps, apiKeys]);
2529
2603
  const currentActiveId = activeBasemapId ?? internalActiveId ?? availableBasemaps[0]?.id;
2530
2604
  const { style, visible, setExpanded } = useControlPosition(containerRef, {
2531
- id: switcherIdRef.current,
2605
+ id: switcherId,
2532
2606
  type: "basemap-switcher",
2533
2607
  position,
2534
2608
  priority: "normal",
@@ -2559,7 +2633,12 @@ var BasemapSwitcher = ({
2559
2633
  }, [isOpen, setExpanded]);
2560
2634
  const handleSelect = (basemap) => {
2561
2635
  const resolvedStyle = mapsCore.resolveBasemapStyle(basemap, apiKeys);
2562
- if (!resolvedStyle) return;
2636
+ if (!resolvedStyle) {
2637
+ const reason = basemap.requiresApiKey ? `Basemap "${basemap.name}" requires an API key that was not provided` : `Failed to resolve style for basemap "${basemap.name}"`;
2638
+ console.warn(`[maps-react] BasemapSwitcher: ${reason}`);
2639
+ onStyleError?.({ basemap, reason });
2640
+ return;
2641
+ }
2563
2642
  if (!activeBasemapId) {
2564
2643
  setInternalActiveId(basemap.id);
2565
2644
  }
@@ -2683,7 +2762,6 @@ var BasemapSwitcher = ({
2683
2762
  );
2684
2763
  };
2685
2764
  BasemapSwitcher.displayName = "BasemapSwitcher";
2686
- var managerIdCounter = 0;
2687
2765
  var LayerManager = ({
2688
2766
  layers,
2689
2767
  apiKeys,
@@ -2708,10 +2786,11 @@ var LayerManager = ({
2708
2786
  const [draggedId, setDraggedId] = React26__namespace.useState(null);
2709
2787
  const [dragOver, setDragOver] = React26__namespace.useState(null);
2710
2788
  const containerRef = React26__namespace.useRef(null);
2711
- const managerIdRef = React26__namespace.useRef(`layer-manager-${++managerIdCounter}`);
2789
+ const uniqueId = React26__namespace.useId();
2790
+ const managerId = `layer-manager${uniqueId}`;
2712
2791
  const lastLayerIdsRef = React26__namespace.useRef(new Set(layers.map((l) => l.id)));
2713
2792
  const { style, visible, setExpanded } = useControlPosition(containerRef, {
2714
- id: managerIdRef.current,
2793
+ id: managerId,
2715
2794
  type: "layer-manager",
2716
2795
  position,
2717
2796
  priority: "high",
@@ -3239,7 +3318,6 @@ var LayerManager = ({
3239
3318
  ] });
3240
3319
  };
3241
3320
  LayerManager.displayName = "LayerManager";
3242
- var customControlIdCounter = 0;
3243
3321
  var CustomControl = ({
3244
3322
  position = "top-right",
3245
3323
  fallbacks,
@@ -3252,9 +3330,10 @@ var CustomControl = ({
3252
3330
  children
3253
3331
  }) => {
3254
3332
  const controlRef = React26__namespace.useRef(null);
3255
- const controlIdRef = React26__namespace.useRef(id ?? `custom-control-${++customControlIdCounter}`);
3333
+ const generatedId = React26__namespace.useId();
3334
+ const controlId = id ?? `custom-control-${generatedId}`;
3256
3335
  const { style, visible, setExpanded } = useControlPosition(controlRef, {
3257
- id: controlIdRef.current,
3336
+ id: controlId,
3258
3337
  type: "custom",
3259
3338
  position,
3260
3339
  fallbacks,
@@ -3336,10 +3415,11 @@ var DeckOverlay = ({
3336
3415
  if (overlayRef.current && "setProps" in overlayRef.current) {
3337
3416
  overlayRef.current.setProps({
3338
3417
  onHover,
3339
- onClick
3418
+ onClick,
3419
+ ...getCursor ? { getCursor } : {}
3340
3420
  });
3341
3421
  }
3342
- }, [onHover, onClick]);
3422
+ }, [onHover, onClick, getCursor]);
3343
3423
  React26__namespace.useEffect(() => {
3344
3424
  if (overlayRef.current && effects && "setProps" in overlayRef.current) {
3345
3425
  overlayRef.current.setProps({ effects });
@@ -3449,6 +3529,18 @@ Object.defineProperty(exports, "countFeaturesByType", {
3449
3529
  enumerable: true,
3450
3530
  get: function () { return mapsCore.countFeaturesByType; }
3451
3531
  });
3532
+ Object.defineProperty(exports, "createClusterCirclePaint", {
3533
+ enumerable: true,
3534
+ get: function () { return mapsCore.createClusterCirclePaint; }
3535
+ });
3536
+ Object.defineProperty(exports, "createClusterStyles", {
3537
+ enumerable: true,
3538
+ get: function () { return mapsCore.createClusterStyles; }
3539
+ });
3540
+ Object.defineProperty(exports, "createClusterTextLayout", {
3541
+ enumerable: true,
3542
+ get: function () { return mapsCore.createClusterTextLayout; }
3543
+ });
3452
3544
  Object.defineProperty(exports, "createHoverExpression", {
3453
3545
  enumerable: true,
3454
3546
  get: function () { return mapsCore.createHoverExpression; }
package/dist/index.d.cts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { MapProps, PositioningCoordinator, SourceProps, MarkerProps, PopupProps, BaseLayerProps, FeatureClickEventParams, FeatureHoverEventParams, FillLayerProps, LineLayerProps, CircleLayerProps, SymbolLayerProps, FillExtrusionLayerProps, HeatmapLayerProps, LegendProps, LegendGroupProps, CoordinateDisplayProps, BasemapSwitcherProps, LayerManagerProps, ExtendedControlPosition, ControlPriority, ZIndexLayer, MapTheme, MapStyleSpec, ControlType, ControlOffset } from '@classic-homes/maps-core';
3
- export { BIKE_LANES, BUILTIN_BASEMAPS, BUILTIN_OVERLAY_LAYERS, BaseMapProps, BasemapApiKeys, BasemapCategory, BasemapDefinition, BasemapProvider, BasemapSwitcherProps, BoundsArray, CATEGORY_META, CITY_LIMITS, CircleLayerProps, ClusterExpandOptions, ClusterFeatureProperties, ControlOffset, ControlPriority, ControlType, CoordinateDisplayProps, DEFAULT_BASEMAP, ExtendedControlPosition, FLOOD_ZONES, FREE_BASEMAPS, FeatureClickEventParams, FeatureHoverEventParams, FillExtrusionLayerProps, FillLayerProps, GeoJSONFeature, GeoJSONFeatureCollection, GradientStop, HeatmapLayerProps, LayerManagerProps, LegendConfig, LegendGroupProps, LegendItem, LegendProps, LineLayerProps, LngLat, LoadGeoJSONOptions, LoadGeoJSONResult, MapBounds, MapClickEventParams, MapHoverEventParams, MapMoveEventParams, MapProps, MapViewport, MarkerClickEventParams, MarkerData, MarkerDragEventParams, MarkerProps, OSM_STANDARD, OverlayApiKeys, OverlayLayerCategory, OverlayLayerDefinition, OverlayLayerState, PARKS, PRIMARY_BASEMAPS, PopupProps, SATELLITE_BASEMAP, SCHOOL_DISTRICTS, SPORTS_FACILITIES, SourceProps, SymbolLayerProps, THEME_DARK, THEME_LIGHT, TOPO_BASEMAP, TRAILS, TRANSIT_ROUTES, ValidationResult, WATERSHEDS, ZIndexLayer, ZONING_DISTRICTS, calculateBounds, calculateCentroid, combineBounds, countFeaturesByType, 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';
3
+ export { BIKE_LANES, BUILTIN_BASEMAPS, BUILTIN_OVERLAY_LAYERS, BaseMapProps, BasemapApiKeys, BasemapCategory, BasemapDefinition, BasemapProvider, BasemapSwitcherProps, BoundsArray, CATEGORY_META, CITY_LIMITS, CircleLayerProps, ClusterCircleStyleOptions, ClusterExpandOptions, ClusterFeatureProperties, ClusterLayerStyles, ClusterTextStyleOptions, ControlOffset, ControlPriority, ControlType, CoordinateDisplayProps, DEFAULT_BASEMAP, ExtendedControlPosition, FLOOD_ZONES, FREE_BASEMAPS, FeatureClickEventParams, FeatureHoverEventParams, FillExtrusionLayerProps, FillLayerProps, GeoJSONFeature, GeoJSONFeatureCollection, GradientStop, HeatmapLayerProps, LayerManagerProps, LegendConfig, LegendGroupProps, LegendItem, LegendProps, LineLayerProps, LngLat, LoadGeoJSONOptions, LoadGeoJSONResult, MapBounds, MapClickEventParams, MapHoverEventParams, MapMoveEventParams, MapProps, MapViewport, MarkerClickEventParams, MarkerData, MarkerDragEventParams, MarkerProps, OSM_STANDARD, OverlayApiKeys, OverlayLayerCategory, OverlayLayerDefinition, OverlayLayerState, PARKS, PRIMARY_BASEMAPS, PopupProps, SATELLITE_BASEMAP, SCHOOL_DISTRICTS, SPORTS_FACILITIES, SourceProps, SymbolLayerProps, THEME_DARK, THEME_LIGHT, TOPO_BASEMAP, TRAILS, TRANSIT_ROUTES, UnclusteredPointStyleOptions, ValidationResult, WATERSHEDS, ZIndexLayer, 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';
4
4
  import maplibregl, { Map as Map$1, StyleSpecification } from 'maplibre-gl';
5
5
  import * as class_variance_authority_types from 'class-variance-authority/types';
6
6
  import { VariantProps } from 'class-variance-authority';
@@ -108,7 +108,7 @@ interface MapContextValue {
108
108
  map: Map$1 | null;
109
109
  /** Whether the map has loaded */
110
110
  loaded: boolean;
111
- /** Counter incremented on each style change (via data event), used to re-initialize sources/layers */
111
+ /** Counter incremented on style changes, used to re-initialize sources/layers */
112
112
  styleVersion: number;
113
113
  /** Set the map style programmatically (e.g. basemap switching) */
114
114
  setMapStyle?: (style: string | StyleSpecification) => void;
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { MapProps, PositioningCoordinator, SourceProps, MarkerProps, PopupProps, BaseLayerProps, FeatureClickEventParams, FeatureHoverEventParams, FillLayerProps, LineLayerProps, CircleLayerProps, SymbolLayerProps, FillExtrusionLayerProps, HeatmapLayerProps, LegendProps, LegendGroupProps, CoordinateDisplayProps, BasemapSwitcherProps, LayerManagerProps, ExtendedControlPosition, ControlPriority, ZIndexLayer, MapTheme, MapStyleSpec, ControlType, ControlOffset } from '@classic-homes/maps-core';
3
- export { BIKE_LANES, BUILTIN_BASEMAPS, BUILTIN_OVERLAY_LAYERS, BaseMapProps, BasemapApiKeys, BasemapCategory, BasemapDefinition, BasemapProvider, BasemapSwitcherProps, BoundsArray, CATEGORY_META, CITY_LIMITS, CircleLayerProps, ClusterExpandOptions, ClusterFeatureProperties, ControlOffset, ControlPriority, ControlType, CoordinateDisplayProps, DEFAULT_BASEMAP, ExtendedControlPosition, FLOOD_ZONES, FREE_BASEMAPS, FeatureClickEventParams, FeatureHoverEventParams, FillExtrusionLayerProps, FillLayerProps, GeoJSONFeature, GeoJSONFeatureCollection, GradientStop, HeatmapLayerProps, LayerManagerProps, LegendConfig, LegendGroupProps, LegendItem, LegendProps, LineLayerProps, LngLat, LoadGeoJSONOptions, LoadGeoJSONResult, MapBounds, MapClickEventParams, MapHoverEventParams, MapMoveEventParams, MapProps, MapViewport, MarkerClickEventParams, MarkerData, MarkerDragEventParams, MarkerProps, OSM_STANDARD, OverlayApiKeys, OverlayLayerCategory, OverlayLayerDefinition, OverlayLayerState, PARKS, PRIMARY_BASEMAPS, PopupProps, SATELLITE_BASEMAP, SCHOOL_DISTRICTS, SPORTS_FACILITIES, SourceProps, SymbolLayerProps, THEME_DARK, THEME_LIGHT, TOPO_BASEMAP, TRAILS, TRANSIT_ROUTES, ValidationResult, WATERSHEDS, ZIndexLayer, ZONING_DISTRICTS, calculateBounds, calculateCentroid, combineBounds, countFeaturesByType, 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';
3
+ export { BIKE_LANES, BUILTIN_BASEMAPS, BUILTIN_OVERLAY_LAYERS, BaseMapProps, BasemapApiKeys, BasemapCategory, BasemapDefinition, BasemapProvider, BasemapSwitcherProps, BoundsArray, CATEGORY_META, CITY_LIMITS, CircleLayerProps, ClusterCircleStyleOptions, ClusterExpandOptions, ClusterFeatureProperties, ClusterLayerStyles, ClusterTextStyleOptions, ControlOffset, ControlPriority, ControlType, CoordinateDisplayProps, DEFAULT_BASEMAP, ExtendedControlPosition, FLOOD_ZONES, FREE_BASEMAPS, FeatureClickEventParams, FeatureHoverEventParams, FillExtrusionLayerProps, FillLayerProps, GeoJSONFeature, GeoJSONFeatureCollection, GradientStop, HeatmapLayerProps, LayerManagerProps, LegendConfig, LegendGroupProps, LegendItem, LegendProps, LineLayerProps, LngLat, LoadGeoJSONOptions, LoadGeoJSONResult, MapBounds, MapClickEventParams, MapHoverEventParams, MapMoveEventParams, MapProps, MapViewport, MarkerClickEventParams, MarkerData, MarkerDragEventParams, MarkerProps, OSM_STANDARD, OverlayApiKeys, OverlayLayerCategory, OverlayLayerDefinition, OverlayLayerState, PARKS, PRIMARY_BASEMAPS, PopupProps, SATELLITE_BASEMAP, SCHOOL_DISTRICTS, SPORTS_FACILITIES, SourceProps, SymbolLayerProps, THEME_DARK, THEME_LIGHT, TOPO_BASEMAP, TRAILS, TRANSIT_ROUTES, UnclusteredPointStyleOptions, ValidationResult, WATERSHEDS, ZIndexLayer, 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';
4
4
  import maplibregl, { Map as Map$1, StyleSpecification } from 'maplibre-gl';
5
5
  import * as class_variance_authority_types from 'class-variance-authority/types';
6
6
  import { VariantProps } from 'class-variance-authority';
@@ -108,7 +108,7 @@ interface MapContextValue {
108
108
  map: Map$1 | null;
109
109
  /** Whether the map has loaded */
110
110
  loaded: boolean;
111
- /** Counter incremented on each style change (via data event), used to re-initialize sources/layers */
111
+ /** Counter incremented on style changes, used to re-initialize sources/layers */
112
112
  styleVersion: number;
113
113
  /** Set the map style programmatically (e.g. basemap switching) */
114
114
  setMapStyle?: (style: string | StyleSpecification) => void;
package/dist/index.js CHANGED
@@ -8,8 +8,9 @@ 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
10
  import { createPositioningCoordinator, generateMapDescription, applyMarkerProtection, applyMarkerChildProtection, removeMarkerProtection, DEFAULT_BASEMAP, darkTheme, lightTheme, THEME_DARK, THEME_LIGHT, calculateBounds, 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';
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, 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';
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
+ import { panToFitPopup, normalizePadding } from '@classic-homes/maps-core/utils';
13
14
  import { cva } from 'class-variance-authority';
14
15
  import '@classic-homes/maps-core/styles/basemap-switcher.css';
15
16
  import '@classic-homes/maps-core/styles/layer-manager.css';
@@ -263,7 +264,7 @@ function useMapTheme(preference = "auto") {
263
264
  };
264
265
  }
265
266
  function useReducedMotion() {
266
- const [prefersReducedMotion2, setPrefersReducedMotion] = useState(false);
267
+ const [prefersReducedMotion, setPrefersReducedMotion] = useState(false);
267
268
  useEffect(() => {
268
269
  if (typeof window === "undefined") return;
269
270
  const mediaQuery = window.matchMedia("(prefers-reduced-motion: reduce)");
@@ -276,7 +277,7 @@ function useReducedMotion() {
276
277
  mediaQuery.removeEventListener("change", handleChange);
277
278
  };
278
279
  }, []);
279
- return prefersReducedMotion2;
280
+ return prefersReducedMotion;
280
281
  }
281
282
  var MapContext = React26.createContext(null);
282
283
  function useMap() {
@@ -359,9 +360,15 @@ var Map2 = React26.forwardRef(
359
360
  const positioningCoordinator = positioningCoordinatorRef.current;
360
361
  const setMapStyle = React26.useCallback((style) => {
361
362
  activeStyleOverrideRef.current = style;
362
- mapRef.current?.setStyle(style);
363
+ const map = mapRef.current;
364
+ if (map) {
365
+ map.setStyle(style);
366
+ map.once("idle", () => {
367
+ setStyleVersion((v) => v + 1);
368
+ });
369
+ }
363
370
  }, []);
364
- const prefersReducedMotion2 = useReducedMotion();
371
+ const prefersReducedMotion = useReducedMotion();
365
372
  const { style: themeStyle } = useMapTheme(themePref);
366
373
  const onLoadRef = React26.useRef(onLoad);
367
374
  onLoadRef.current = onLoad;
@@ -416,11 +423,6 @@ var Map2 = React26.forwardRef(
416
423
  attributionControl: attributionControl ? { customAttribution } : false
417
424
  });
418
425
  mapRef.current = map;
419
- map.on("data", (e) => {
420
- if (e.dataType === "style") {
421
- setStyleVersion((v) => v + 1);
422
- }
423
- });
424
426
  if (navigationControl) {
425
427
  map.addControl(
426
428
  new maplibregl.NavigationControl({
@@ -490,12 +492,24 @@ var Map2 = React26.forwardRef(
490
492
  zLayer: "base"
491
493
  });
492
494
  }
495
+ const initTimeoutId = setTimeout(() => {
496
+ if (!mapRef.current?.loaded()) {
497
+ const errorMessage = "Map initialization timeout - style may be unreachable";
498
+ setMapError(errorMessage);
499
+ onErrorRef.current?.({
500
+ type: "error",
501
+ message: errorMessage,
502
+ error: new Error(errorMessage)
503
+ });
504
+ }
505
+ }, 3e4);
493
506
  map.on("load", () => {
507
+ clearTimeout(initTimeoutId);
494
508
  setMapLoaded(true);
495
509
  if (bounds) {
496
510
  map.fitBounds(bounds, {
497
511
  padding: boundsPadding,
498
- animate: animation && !prefersReducedMotion2
512
+ animate: animation && !prefersReducedMotion
499
513
  });
500
514
  }
501
515
  onLoadRef.current?.({ type: "load", loaded: true });
@@ -504,11 +518,13 @@ var Map2 = React26.forwardRef(
504
518
  const errorMessage = e.error?.message || "Map error";
505
519
  const isTransient = errorMessage.includes("non-existing layer") || errorMessage.includes("Cannot filter");
506
520
  if (!isTransient) {
521
+ clearTimeout(initTimeoutId);
507
522
  setMapError(errorMessage);
508
523
  }
509
524
  onErrorRef.current?.({ type: "error", message: errorMessage, error: e.error });
510
525
  });
511
526
  return () => {
527
+ clearTimeout(initTimeoutId);
512
528
  map.remove();
513
529
  mapRef.current = null;
514
530
  setMapLoaded(false);
@@ -519,6 +535,17 @@ var Map2 = React26.forwardRef(
519
535
  onErrorRef.current?.({ type: "error", message: errorMessage, error: err });
520
536
  }
521
537
  }, []);
538
+ React26.useEffect(() => {
539
+ const map = mapRef.current;
540
+ if (!map || !mapLoaded) return;
541
+ const handleStyleLoad = () => {
542
+ setStyleVersion((v) => v + 1);
543
+ };
544
+ map.on("style.load", handleStyleLoad);
545
+ return () => {
546
+ map.off("style.load", handleStyleLoad);
547
+ };
548
+ }, [mapLoaded]);
522
549
  const styleInitialized = React26.useRef(false);
523
550
  React26.useEffect(() => {
524
551
  if (!mapRef.current || !mapLoaded) return;
@@ -603,23 +630,23 @@ var Map2 = React26.forwardRef(
603
630
  const handleZoom = () => {
604
631
  onZoom?.({ type: "zoom", ...createMoveParams() });
605
632
  };
606
- if (onClick) map.on("click", handleClick);
607
- if (onDblClick) map.on("dblclick", handleDblClick);
608
- if (onContextMenu) map.on("contextmenu", handleContextMenu);
609
- if (onMouseMove) map.on("mousemove", handleMouseMove);
610
- if (onMove) map.on("move", handleMove);
611
- if (onMoveStart) map.on("movestart", handleMoveStart);
612
- if (onMoveEnd) map.on("moveend", handleMoveEnd);
613
- if (onZoom) map.on("zoom", handleZoom);
633
+ map.on("click", handleClick);
634
+ map.on("dblclick", handleDblClick);
635
+ map.on("contextmenu", handleContextMenu);
636
+ map.on("mousemove", handleMouseMove);
637
+ map.on("move", handleMove);
638
+ map.on("movestart", handleMoveStart);
639
+ map.on("moveend", handleMoveEnd);
640
+ map.on("zoom", handleZoom);
614
641
  return () => {
615
- if (onClick) map.off("click", handleClick);
616
- if (onDblClick) map.off("dblclick", handleDblClick);
617
- if (onContextMenu) map.off("contextmenu", handleContextMenu);
618
- if (onMouseMove) map.off("mousemove", handleMouseMove);
619
- if (onMove) map.off("move", handleMove);
620
- if (onMoveStart) map.off("movestart", handleMoveStart);
621
- if (onMoveEnd) map.off("moveend", handleMoveEnd);
622
- if (onZoom) map.off("zoom", handleZoom);
642
+ map.off("click", handleClick);
643
+ map.off("dblclick", handleDblClick);
644
+ map.off("contextmenu", handleContextMenu);
645
+ map.off("mousemove", handleMouseMove);
646
+ map.off("move", handleMove);
647
+ map.off("movestart", handleMoveStart);
648
+ map.off("moveend", handleMoveEnd);
649
+ map.off("zoom", handleZoom);
623
650
  };
624
651
  }, [
625
652
  mapLoaded,
@@ -633,6 +660,16 @@ var Map2 = React26.forwardRef(
633
660
  onZoom
634
661
  ]);
635
662
  const combinedError = error || mapError;
663
+ const contextValue = React26.useMemo(
664
+ () => ({
665
+ map: mapRef.current,
666
+ loaded: mapLoaded,
667
+ styleVersion,
668
+ setMapStyle,
669
+ positioningCoordinator
670
+ }),
671
+ [mapLoaded, styleVersion, setMapStyle, positioningCoordinator]
672
+ );
636
673
  return /* @__PURE__ */ jsx(
637
674
  MapContainer,
638
675
  {
@@ -645,22 +682,10 @@ var Map2 = React26.forwardRef(
645
682
  error: combinedError,
646
683
  emptyMessage,
647
684
  className,
648
- children: /* @__PURE__ */ jsxs(
649
- MapContext.Provider,
650
- {
651
- value: {
652
- map: mapRef.current,
653
- loaded: mapLoaded,
654
- styleVersion,
655
- setMapStyle,
656
- positioningCoordinator
657
- },
658
- children: [
659
- /* @__PURE__ */ jsx("div", { ref: containerRef, className: "absolute inset-0" }),
660
- mapLoaded && children && /* @__PURE__ */ jsx("div", { className: "absolute inset-0 pointer-events-none [&>*]:pointer-events-auto", children })
661
- ]
662
- }
663
- )
685
+ children: /* @__PURE__ */ jsxs(MapContext.Provider, { value: contextValue, children: [
686
+ /* @__PURE__ */ jsx("div", { ref: containerRef, className: "absolute inset-0" }),
687
+ mapLoaded && children && /* @__PURE__ */ jsx("div", { className: "absolute inset-0 pointer-events-none [&>*]:pointer-events-auto", children })
688
+ ] })
664
689
  }
665
690
  );
666
691
  }
@@ -720,7 +745,7 @@ var Source = ({
720
745
  console.warn("[maps-react] Source: Invalid bounds calculated, skipping fitBounds");
721
746
  return;
722
747
  }
723
- const prefersReducedMotion2 = typeof window !== "undefined" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
748
+ const prefersReducedMotion = typeof window !== "undefined" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
724
749
  const rafHandle = requestAnimationFrame(() => {
725
750
  if (cancelledRef.current || initialFitDone.current) return;
726
751
  try {
@@ -736,7 +761,7 @@ var Source = ({
736
761
  map.flyTo({
737
762
  center: [centerLng, centerLat],
738
763
  zoom: Math.max(zoom, 1),
739
- animate: params.fitBoundsAnimate && !prefersReducedMotion2,
764
+ animate: params.fitBoundsAnimate && !prefersReducedMotion,
740
765
  padding: params.fitBoundsPadding
741
766
  });
742
767
  initialFitDone.current = true;
@@ -951,6 +976,9 @@ var Marker = React26.forwardRef(
951
976
  const elementRef = React26.useRef(null);
952
977
  const originalLngLatRef = React26.useRef();
953
978
  const clickHandlerRef = React26.useRef(null);
979
+ const dragStartHandlerRef = React26.useRef(null);
980
+ const dragHandlerRef = React26.useRef(null);
981
+ const dragEndHandlerRef = React26.useRef(null);
954
982
  const [mounted, setMounted] = React26.useState(false);
955
983
  const onClickRef = React26.useRef(onClick);
956
984
  onClickRef.current = onClick;
@@ -1016,11 +1044,11 @@ var Marker = React26.forwardRef(
1016
1044
  element.addEventListener("click", handleClick);
1017
1045
  }
1018
1046
  if (draggable) {
1019
- marker.on("dragstart", () => {
1047
+ const handleDragStart = () => {
1020
1048
  const lngLat = marker.getLngLat();
1021
1049
  originalLngLatRef.current = [lngLat.lng, lngLat.lat];
1022
- });
1023
- marker.on("drag", () => {
1050
+ };
1051
+ const handleDrag = () => {
1024
1052
  const lngLat = marker.getLngLat();
1025
1053
  onDragRef.current?.({
1026
1054
  type: "drag",
@@ -1028,8 +1056,8 @@ var Marker = React26.forwardRef(
1028
1056
  lngLat: [lngLat.lng, lngLat.lat],
1029
1057
  originalLngLat: originalLngLatRef.current
1030
1058
  });
1031
- });
1032
- marker.on("dragend", () => {
1059
+ };
1060
+ const handleDragEnd = () => {
1033
1061
  const lngLat = marker.getLngLat();
1034
1062
  onDragEndRef.current?.({
1035
1063
  type: "dragend",
@@ -1037,13 +1065,33 @@ var Marker = React26.forwardRef(
1037
1065
  lngLat: [lngLat.lng, lngLat.lat],
1038
1066
  originalLngLat: originalLngLatRef.current
1039
1067
  });
1040
- });
1068
+ };
1069
+ dragStartHandlerRef.current = handleDragStart;
1070
+ dragHandlerRef.current = handleDrag;
1071
+ dragEndHandlerRef.current = handleDragEnd;
1072
+ marker.on("dragstart", handleDragStart);
1073
+ marker.on("drag", handleDrag);
1074
+ marker.on("dragend", handleDragEnd);
1041
1075
  }
1042
1076
  return () => {
1043
1077
  if (clickHandlerRef.current && markerRef.current) {
1044
1078
  markerRef.current.getElement().removeEventListener("click", clickHandlerRef.current);
1045
1079
  clickHandlerRef.current = null;
1046
1080
  }
1081
+ if (markerRef.current) {
1082
+ if (dragStartHandlerRef.current) {
1083
+ markerRef.current.off("dragstart", dragStartHandlerRef.current);
1084
+ dragStartHandlerRef.current = null;
1085
+ }
1086
+ if (dragHandlerRef.current) {
1087
+ markerRef.current.off("drag", dragHandlerRef.current);
1088
+ dragHandlerRef.current = null;
1089
+ }
1090
+ if (dragEndHandlerRef.current) {
1091
+ markerRef.current.off("dragend", dragEndHandlerRef.current);
1092
+ dragEndHandlerRef.current = null;
1093
+ }
1094
+ }
1047
1095
  if (markerRef.current) {
1048
1096
  removeMarkerProtection(markerRef.current.getElement());
1049
1097
  markerRef.current.remove();
@@ -1057,10 +1105,53 @@ var Marker = React26.forwardRef(
1057
1105
  }
1058
1106
  }, [coordinates]);
1059
1107
  React26.useEffect(() => {
1060
- if (markerRef.current) {
1061
- markerRef.current.setDraggable(draggable);
1108
+ const marker = markerRef.current;
1109
+ if (!marker) return;
1110
+ marker.setDraggable(draggable);
1111
+ if (!draggable) {
1112
+ if (dragStartHandlerRef.current) {
1113
+ marker.off("dragstart", dragStartHandlerRef.current);
1114
+ dragStartHandlerRef.current = null;
1115
+ }
1116
+ if (dragHandlerRef.current) {
1117
+ marker.off("drag", dragHandlerRef.current);
1118
+ dragHandlerRef.current = null;
1119
+ }
1120
+ if (dragEndHandlerRef.current) {
1121
+ marker.off("dragend", dragEndHandlerRef.current);
1122
+ dragEndHandlerRef.current = null;
1123
+ }
1124
+ } else if (!dragStartHandlerRef.current) {
1125
+ const handleDragStart = () => {
1126
+ const lngLat = marker.getLngLat();
1127
+ originalLngLatRef.current = [lngLat.lng, lngLat.lat];
1128
+ };
1129
+ const handleDrag = () => {
1130
+ const lngLat = marker.getLngLat();
1131
+ onDragRef.current?.({
1132
+ type: "drag",
1133
+ markerId: id || "",
1134
+ lngLat: [lngLat.lng, lngLat.lat],
1135
+ originalLngLat: originalLngLatRef.current
1136
+ });
1137
+ };
1138
+ const handleDragEnd = () => {
1139
+ const lngLat = marker.getLngLat();
1140
+ onDragEndRef.current?.({
1141
+ type: "dragend",
1142
+ markerId: id || "",
1143
+ lngLat: [lngLat.lng, lngLat.lat],
1144
+ originalLngLat: originalLngLatRef.current
1145
+ });
1146
+ };
1147
+ dragStartHandlerRef.current = handleDragStart;
1148
+ dragHandlerRef.current = handleDrag;
1149
+ dragEndHandlerRef.current = handleDragEnd;
1150
+ marker.on("dragstart", handleDragStart);
1151
+ marker.on("drag", handleDrag);
1152
+ marker.on("dragend", handleDragEnd);
1062
1153
  }
1063
- }, [draggable]);
1154
+ }, [draggable, id]);
1064
1155
  React26.useEffect(() => {
1065
1156
  if (markerRef.current && rotation !== void 0) {
1066
1157
  markerRef.current.setRotation(rotation);
@@ -1073,40 +1164,6 @@ var Marker = React26.forwardRef(
1073
1164
  }
1074
1165
  );
1075
1166
  Marker.displayName = "Marker";
1076
- function normalizePadding(padding) {
1077
- if (typeof padding === "number") {
1078
- return { top: padding, right: padding, bottom: padding, left: padding };
1079
- }
1080
- return padding;
1081
- }
1082
- function prefersReducedMotion() {
1083
- if (typeof window === "undefined") return false;
1084
- return window.matchMedia("(prefers-reduced-motion: reduce)").matches;
1085
- }
1086
- function panToFitPopup(map, popup, padding) {
1087
- const popupEl = popup.getElement();
1088
- if (!popupEl) return;
1089
- const mapContainer = map.getContainer();
1090
- const mapRect = mapContainer.getBoundingClientRect();
1091
- const popupRect = popupEl.getBoundingClientRect();
1092
- let dx = 0;
1093
- let dy = 0;
1094
- if (popupRect.left < mapRect.left + padding.left) {
1095
- dx = popupRect.left - mapRect.left - padding.left;
1096
- } else if (popupRect.right > mapRect.right - padding.right) {
1097
- dx = popupRect.right - mapRect.right + padding.right;
1098
- }
1099
- if (popupRect.top < mapRect.top + padding.top) {
1100
- dy = popupRect.top - mapRect.top - padding.top;
1101
- } else if (popupRect.bottom > mapRect.bottom - padding.bottom) {
1102
- dy = popupRect.bottom - mapRect.bottom + padding.bottom;
1103
- }
1104
- if (dx !== 0 || dy !== 0) {
1105
- map.panBy([dx, dy], {
1106
- animate: !prefersReducedMotion()
1107
- });
1108
- }
1109
- }
1110
1167
  var Popup = React26.forwardRef(
1111
1168
  ({
1112
1169
  coordinates,
@@ -1420,7 +1477,11 @@ function useLayer({
1420
1477
  const handleClick = (e) => {
1421
1478
  const params = createFeatureParams(e);
1422
1479
  if (params) {
1423
- onClick?.({ type: "click", ...params });
1480
+ try {
1481
+ onClick?.({ type: "click", ...params });
1482
+ } catch (err) {
1483
+ console.error(`[maps-react] Layer "${id}" click handler error:`, err);
1484
+ }
1424
1485
  }
1425
1486
  };
1426
1487
  const handleMouseEnter = (e) => {
@@ -1442,7 +1503,11 @@ function useLayer({
1442
1503
  }
1443
1504
  const params = createFeatureParams(e);
1444
1505
  if (params) {
1445
- onHover?.({ type: "mouseenter", ...params });
1506
+ try {
1507
+ onHover?.({ type: "mouseenter", ...params });
1508
+ } catch (err) {
1509
+ console.error(`[maps-react] Layer "${id}" hover handler error:`, err);
1510
+ }
1446
1511
  }
1447
1512
  };
1448
1513
  const handleMouseMove = (e) => {
@@ -1467,7 +1532,11 @@ function useLayer({
1467
1532
  lastHoverCallTime.current = now;
1468
1533
  const params = createFeatureParams(e);
1469
1534
  if (params) {
1470
- onHover?.({ type: "mousemove", ...params });
1535
+ try {
1536
+ onHover?.({ type: "mousemove", ...params });
1537
+ } catch (err) {
1538
+ console.error(`[maps-react] Layer "${id}" hover handler error:`, err);
1539
+ }
1471
1540
  }
1472
1541
  }
1473
1542
  } else {
@@ -1485,15 +1554,19 @@ function useLayer({
1485
1554
  hoveredFeatureId.current = null;
1486
1555
  }
1487
1556
  const lastPos = lastMousePosition.current;
1488
- onHover?.({
1489
- type: "mouseleave",
1490
- feature: null,
1491
- layerId: id,
1492
- sourceId: source,
1493
- lngLat: lastPos?.lngLat ?? [0, 0],
1494
- point: lastPos?.point ?? [0, 0],
1495
- map
1496
- });
1557
+ try {
1558
+ onHover?.({
1559
+ type: "mouseleave",
1560
+ feature: null,
1561
+ layerId: id,
1562
+ sourceId: source,
1563
+ lngLat: lastPos?.lngLat ?? [0, 0],
1564
+ point: lastPos?.point ?? [0, 0],
1565
+ map
1566
+ });
1567
+ } catch (err) {
1568
+ console.error(`[maps-react] Layer "${id}" hover handler error:`, err);
1569
+ }
1497
1570
  lastMousePosition.current = null;
1498
1571
  };
1499
1572
  if (onClick) {
@@ -2085,7 +2158,6 @@ function useControlPosition(ref, options) {
2085
2158
  visible: offset?.visible ?? false
2086
2159
  };
2087
2160
  }
2088
- var legendIdCounter = 0;
2089
2161
  var Legend = ({
2090
2162
  title,
2091
2163
  position = "bottom-left",
@@ -2101,9 +2173,10 @@ var Legend = ({
2101
2173
  }) => {
2102
2174
  const [isCollapsed, setIsCollapsed] = React26.useState(initialCollapsed);
2103
2175
  const legendRef = React26.useRef(null);
2104
- const legendIdRef = React26.useRef(`legend-${++legendIdCounter}`);
2176
+ const generatedId = React26.useId();
2177
+ const legendId = `legend-${generatedId}`;
2105
2178
  const { style, visible } = useControlPosition(legendRef, {
2106
- id: legendIdRef.current,
2179
+ id: legendId,
2107
2180
  type: "legend",
2108
2181
  position,
2109
2182
  priority: "normal",
@@ -2364,7 +2437,6 @@ var LegendGroup = ({
2364
2437
  );
2365
2438
  };
2366
2439
  LegendGroup.displayName = "LegendGroup";
2367
- var coordDisplayIdCounter = 0;
2368
2440
  var NAV_CONTROL_WIDTH = 29;
2369
2441
  var CoordinateDisplay = ({
2370
2442
  position = "bottom-right",
@@ -2379,9 +2451,10 @@ var CoordinateDisplay = ({
2379
2451
  const [currentZoom, setCurrentZoom] = React26.useState(0);
2380
2452
  const [currentBearing, setCurrentBearing] = React26.useState(0);
2381
2453
  const controlRef = React26.useRef(null);
2382
- const controlIdRef = React26.useRef(`coord-display-${++coordDisplayIdCounter}`);
2454
+ const uniqueId = React26.useId();
2455
+ const controlId = `coord-display${uniqueId}`;
2383
2456
  const { style, visible } = useControlPosition(controlRef, {
2384
- id: controlIdRef.current,
2457
+ id: controlId,
2385
2458
  type: "coordinate-display",
2386
2459
  position,
2387
2460
  priority: "critical",
@@ -2473,7 +2546,6 @@ var CoordinateDisplay = ({
2473
2546
  );
2474
2547
  };
2475
2548
  CoordinateDisplay.displayName = "CoordinateDisplay";
2476
- var switcherIdCounter = 0;
2477
2549
  var BasemapSwitcher = ({
2478
2550
  basemaps,
2479
2551
  extraBasemaps,
@@ -2481,6 +2553,7 @@ var BasemapSwitcher = ({
2481
2553
  defaultBasemapId,
2482
2554
  activeBasemapId,
2483
2555
  onBasemapChange,
2556
+ onStyleError,
2484
2557
  columns = 3,
2485
2558
  thumbnailSize = 64,
2486
2559
  position = "bottom-right",
@@ -2493,7 +2566,8 @@ var BasemapSwitcher = ({
2493
2566
  );
2494
2567
  const containerRef = React26.useRef(null);
2495
2568
  const panelRef = React26.useRef(null);
2496
- const switcherIdRef = React26.useRef(`basemap-switcher-${++switcherIdCounter}`);
2569
+ const generatedId = React26.useId();
2570
+ const switcherId = `basemap-switcher-${generatedId}`;
2497
2571
  const sourceBasemaps = basemaps ?? FREE_BASEMAPS;
2498
2572
  const availableBasemaps = React26.useMemo(() => {
2499
2573
  const available = getAvailableBasemaps(sourceBasemaps, apiKeys);
@@ -2504,7 +2578,7 @@ var BasemapSwitcher = ({
2504
2578
  }, [sourceBasemaps, extraBasemaps, apiKeys]);
2505
2579
  const currentActiveId = activeBasemapId ?? internalActiveId ?? availableBasemaps[0]?.id;
2506
2580
  const { style, visible, setExpanded } = useControlPosition(containerRef, {
2507
- id: switcherIdRef.current,
2581
+ id: switcherId,
2508
2582
  type: "basemap-switcher",
2509
2583
  position,
2510
2584
  priority: "normal",
@@ -2535,7 +2609,12 @@ var BasemapSwitcher = ({
2535
2609
  }, [isOpen, setExpanded]);
2536
2610
  const handleSelect = (basemap) => {
2537
2611
  const resolvedStyle = resolveBasemapStyle(basemap, apiKeys);
2538
- if (!resolvedStyle) return;
2612
+ if (!resolvedStyle) {
2613
+ const reason = basemap.requiresApiKey ? `Basemap "${basemap.name}" requires an API key that was not provided` : `Failed to resolve style for basemap "${basemap.name}"`;
2614
+ console.warn(`[maps-react] BasemapSwitcher: ${reason}`);
2615
+ onStyleError?.({ basemap, reason });
2616
+ return;
2617
+ }
2539
2618
  if (!activeBasemapId) {
2540
2619
  setInternalActiveId(basemap.id);
2541
2620
  }
@@ -2659,7 +2738,6 @@ var BasemapSwitcher = ({
2659
2738
  );
2660
2739
  };
2661
2740
  BasemapSwitcher.displayName = "BasemapSwitcher";
2662
- var managerIdCounter = 0;
2663
2741
  var LayerManager = ({
2664
2742
  layers,
2665
2743
  apiKeys,
@@ -2684,10 +2762,11 @@ var LayerManager = ({
2684
2762
  const [draggedId, setDraggedId] = React26.useState(null);
2685
2763
  const [dragOver, setDragOver] = React26.useState(null);
2686
2764
  const containerRef = React26.useRef(null);
2687
- const managerIdRef = React26.useRef(`layer-manager-${++managerIdCounter}`);
2765
+ const uniqueId = React26.useId();
2766
+ const managerId = `layer-manager${uniqueId}`;
2688
2767
  const lastLayerIdsRef = React26.useRef(new Set(layers.map((l) => l.id)));
2689
2768
  const { style, visible, setExpanded } = useControlPosition(containerRef, {
2690
- id: managerIdRef.current,
2769
+ id: managerId,
2691
2770
  type: "layer-manager",
2692
2771
  position,
2693
2772
  priority: "high",
@@ -3215,7 +3294,6 @@ var LayerManager = ({
3215
3294
  ] });
3216
3295
  };
3217
3296
  LayerManager.displayName = "LayerManager";
3218
- var customControlIdCounter = 0;
3219
3297
  var CustomControl = ({
3220
3298
  position = "top-right",
3221
3299
  fallbacks,
@@ -3228,9 +3306,10 @@ var CustomControl = ({
3228
3306
  children
3229
3307
  }) => {
3230
3308
  const controlRef = React26.useRef(null);
3231
- const controlIdRef = React26.useRef(id ?? `custom-control-${++customControlIdCounter}`);
3309
+ const generatedId = React26.useId();
3310
+ const controlId = id ?? `custom-control-${generatedId}`;
3232
3311
  const { style, visible, setExpanded } = useControlPosition(controlRef, {
3233
- id: controlIdRef.current,
3312
+ id: controlId,
3234
3313
  type: "custom",
3235
3314
  position,
3236
3315
  fallbacks,
@@ -3312,10 +3391,11 @@ var DeckOverlay = ({
3312
3391
  if (overlayRef.current && "setProps" in overlayRef.current) {
3313
3392
  overlayRef.current.setProps({
3314
3393
  onHover,
3315
- onClick
3394
+ onClick,
3395
+ ...getCursor ? { getCursor } : {}
3316
3396
  });
3317
3397
  }
3318
- }, [onHover, onClick]);
3398
+ }, [onHover, onClick, getCursor]);
3319
3399
  React26.useEffect(() => {
3320
3400
  if (overlayRef.current && effects && "setProps" in overlayRef.current) {
3321
3401
  overlayRef.current.setProps({ effects });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@classic-homes/maps-react",
3
- "version": "0.2.7",
3
+ "version": "0.2.9",
4
4
  "description": "React MapLibre components for Classic Theme",
5
5
  "keywords": [
6
6
  "maps",
@@ -26,6 +26,7 @@
26
26
  "require": "./dist/index.cjs"
27
27
  }
28
28
  },
29
+ "sideEffects": false,
29
30
  "files": [
30
31
  "dist"
31
32
  ],