@page-speed/maps 0.1.8 → 0.1.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
@@ -1008,9 +1008,25 @@ function GeoMap({
1008
1008
  clearSelectionOnMapClick = true,
1009
1009
  mapChildren,
1010
1010
  optixFlowConfig,
1011
+ mapSize,
1011
1012
  IconComponent = FallbackIcon,
1012
1013
  ImgComponent = FallbackImg
1013
1014
  }) {
1015
+ const [isMobile, setIsMobile] = React3__namespace.useState(false);
1016
+ React3__namespace.useEffect(() => {
1017
+ const checkMobile = () => {
1018
+ setIsMobile(window.innerWidth < 768);
1019
+ };
1020
+ checkMobile();
1021
+ window.addEventListener("resize", checkMobile);
1022
+ return () => window.removeEventListener("resize", checkMobile);
1023
+ }, []);
1024
+ const calculatedHeight = React3__namespace.useMemo(() => {
1025
+ if (mapSize) {
1026
+ return isMobile ? mapSize.mobile : mapSize.desktop;
1027
+ }
1028
+ return isMobile ? 420 : 520;
1029
+ }, [mapSize, isMobile]);
1014
1030
  const normalizedStandaloneMarkers = React3__namespace.useMemo(
1015
1031
  () => markers.map((marker, index) => ({
1016
1032
  ...marker,
@@ -1119,14 +1135,17 @@ function GeoMap({
1119
1135
  const latDiff = Math.max(...lats) - Math.min(...lats);
1120
1136
  const lngDiff = Math.max(...lngs) - Math.min(...lngs);
1121
1137
  const maxDiff = Math.max(latDiff, lngDiff);
1122
- if (maxDiff > 10) return 3;
1123
- if (maxDiff > 5) return 5;
1124
- if (maxDiff > 2) return 7;
1125
- if (maxDiff > 1) return 9;
1126
- if (maxDiff > 0.5) return 10;
1127
- if (maxDiff > 0.1) return 12;
1128
- return 13;
1129
- }, [normalizedClusters, normalizedStandaloneMarkers, markerFocusZoom]);
1138
+ const heightFactor = calculatedHeight / 520;
1139
+ const paddingFactor = 0.85;
1140
+ if (maxDiff > 10) return Math.max(2, 3 * heightFactor * paddingFactor);
1141
+ if (maxDiff > 5) return Math.max(4, 5 * heightFactor * paddingFactor);
1142
+ if (maxDiff > 2) return Math.max(6, 7 * heightFactor * paddingFactor);
1143
+ if (maxDiff > 1) return Math.max(8, 9 * heightFactor * paddingFactor);
1144
+ if (maxDiff > 0.5) return Math.max(9, 10 * heightFactor * paddingFactor);
1145
+ if (maxDiff > 0.1) return Math.max(11, 12 * heightFactor * paddingFactor);
1146
+ if (maxDiff > 0.01) return Math.max(12, 13 * heightFactor * paddingFactor);
1147
+ return Math.max(11, 12 * heightFactor * paddingFactor);
1148
+ }, [normalizedClusters, normalizedStandaloneMarkers, markerFocusZoom, calculatedHeight]);
1130
1149
  const [uncontrolledViewState, setUncontrolledViewState] = React3__namespace.useState({
1131
1150
  latitude: defaultViewState?.latitude ?? firstCoordinate.latitude,
1132
1151
  longitude: defaultViewState?.longitude ?? firstCoordinate.longitude,
@@ -1453,24 +1472,33 @@ function GeoMap({
1453
1472
  "div",
1454
1473
  {
1455
1474
  className: cn(
1456
- "relative overflow-hidden rounded-2xl border border-border bg-background",
1475
+ "relative rounded-2xl border border-border bg-background",
1476
+ // Remove overflow-hidden from outer container to allow panel to overflow
1457
1477
  className
1458
1478
  ),
1479
+ style: {
1480
+ // If className includes height settings, they'll override via CSS specificity
1481
+ height: className?.includes("h-[") || className?.includes("min-h-[") || className?.includes("max-h-[") ? void 0 : `${calculatedHeight}px`,
1482
+ // Explicitly allow overflow for marker panels
1483
+ overflow: "visible"
1484
+ },
1459
1485
  children: [
1460
1486
  /* @__PURE__ */ jsxRuntime.jsx(
1461
1487
  "div",
1462
1488
  {
1463
1489
  className: cn(
1464
- "w-full",
1465
- // Default height, can be overridden by mapWrapperClassName
1466
- mapWrapperClassName || "h-[520px]"
1490
+ "w-full rounded-2xl",
1491
+ // Only apply default height class if mapWrapperClassName not provided
1492
+ !mapWrapperClassName && `h-[${calculatedHeight}px]`,
1493
+ mapWrapperClassName
1467
1494
  ),
1468
1495
  style: {
1469
- // CRITICAL: Always use explicit height to prevent MapLibre canvas expansion
1470
- height: mapWrapperClassName ? void 0 : "520px",
1496
+ // If mapWrapperClassName includes height, let it handle the height
1497
+ height: mapWrapperClassName?.includes("h-[") || mapWrapperClassName?.includes("min-h-[") || mapWrapperClassName?.includes("max-h-[") ? void 0 : `${calculatedHeight}px`,
1471
1498
  maxHeight: "100vh",
1472
1499
  // Prevent excessive growth
1473
1500
  position: "relative",
1501
+ // Keep overflow hidden only on the map wrapper to contain the canvas
1474
1502
  overflow: "hidden"
1475
1503
  },
1476
1504
  children: /* @__PURE__ */ jsxRuntime.jsx(
@@ -1496,6 +1524,10 @@ function GeoMap({
1496
1524
  geolocateControlPosition,
1497
1525
  flyToOptions,
1498
1526
  className: cn("h-full w-full", mapClassName),
1527
+ style: {
1528
+ // Pass the calculated height to MapLibre for better zoom calculations
1529
+ height: mapClassName?.includes("h-[") || mapClassName?.includes("min-h-[") || mapClassName?.includes("max-h-[") ? void 0 : `${calculatedHeight}px`
1530
+ },
1499
1531
  children: mapChildren
1500
1532
  }
1501
1533
  )
@@ -1505,9 +1537,13 @@ function GeoMap({
1505
1537
  "div",
1506
1538
  {
1507
1539
  className: cn(
1508
- "pointer-events-none absolute z-20",
1540
+ "pointer-events-none absolute z-30",
1509
1541
  PANEL_POSITION_CLASS[panelPosition]
1510
1542
  ),
1543
+ style: {
1544
+ // Ensure panel can overflow and has higher z-index
1545
+ zIndex: 30
1546
+ },
1511
1547
  children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pointer-events-auto", children: renderMarkerPanel() })
1512
1548
  }
1513
1549
  ) : null