@page-speed/maps 0.1.6 → 0.1.8

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.
@@ -566,11 +566,52 @@ function MapLibre({
566
566
  }
567
567
  return getMapLibreStyleUrl("osm-bright", stadiaApiKey);
568
568
  }, [mapStyle, stadiaApiKey, styleUrl]);
569
+ const containerRef = React3__default.useRef(null);
570
+ React3__default.useEffect(() => {
571
+ if (!mapRef.current || !containerRef.current) return;
572
+ const enforceContainerHeight = () => {
573
+ const container = containerRef.current;
574
+ const map = mapRef.current;
575
+ if (!container || !map) return;
576
+ const rect = container.getBoundingClientRect();
577
+ const maxHeight = Math.min(rect.height, window.innerHeight);
578
+ const canvas = map.getCanvas();
579
+ if (canvas && canvas.style.height) {
580
+ const canvasHeight = parseInt(canvas.style.height);
581
+ if (canvasHeight > maxHeight || canvasHeight > 2e3) {
582
+ map.resize();
583
+ }
584
+ }
585
+ };
586
+ const interval = setInterval(enforceContainerHeight, 1e3);
587
+ let resizeObserver = null;
588
+ if (typeof ResizeObserver !== "undefined") {
589
+ resizeObserver = new ResizeObserver(() => {
590
+ enforceContainerHeight();
591
+ });
592
+ resizeObserver.observe(containerRef.current);
593
+ }
594
+ return () => {
595
+ clearInterval(interval);
596
+ if (resizeObserver) {
597
+ resizeObserver.disconnect();
598
+ }
599
+ };
600
+ }, []);
569
601
  return /* @__PURE__ */ jsx(
570
602
  "div",
571
603
  {
604
+ ref: containerRef,
572
605
  className: joinClassNames("relative w-full h-full", className),
573
- style: { width: "100%", height: "100%", ...style },
606
+ style: {
607
+ width: "100%",
608
+ height: "100%",
609
+ maxHeight: "100vh",
610
+ // Prevent excessive height
611
+ overflow: "hidden",
612
+ position: "relative",
613
+ ...style
614
+ },
574
615
  children: /* @__PURE__ */ jsxs(
575
616
  Map$1,
576
617
  {
@@ -1169,7 +1210,7 @@ function GeoMap({
1169
1210
  "div",
1170
1211
  {
1171
1212
  className: cn(
1172
- "relative w-[320px] overflow-hidden rounded-xl border border-border bg-card text-card-foreground shadow-2xl",
1213
+ "relative w-80 overflow-hidden rounded-xl border border-border bg-card text-card-foreground shadow-2xl",
1173
1214
  panelClassName
1174
1215
  ),
1175
1216
  children: [
@@ -1243,7 +1284,7 @@ function GeoMap({
1243
1284
  "div",
1244
1285
  {
1245
1286
  className: cn(
1246
- "relative w-[320px] overflow-hidden rounded-xl border border-border bg-card text-card-foreground p-4 shadow-2xl",
1287
+ "relative w-80 overflow-hidden rounded-xl border border-border bg-card text-card-foreground p-4 shadow-2xl",
1247
1288
  panelClassName
1248
1289
  ),
1249
1290
  children: [
@@ -1289,32 +1330,50 @@ function GeoMap({
1289
1330
  className
1290
1331
  ),
1291
1332
  children: [
1292
- /* @__PURE__ */ jsx("div", { className: cn("h-[520px] w-full", mapWrapperClassName), children: /* @__PURE__ */ jsx(
1293
- MapLibre,
1333
+ /* @__PURE__ */ jsx(
1334
+ "div",
1294
1335
  {
1295
- stadiaApiKey,
1296
- mapStyle,
1297
- styleUrl,
1298
- mapLibreCssHref,
1299
- viewState: resolvedViewState,
1300
- onViewStateChange: applyViewState,
1301
- markers: mapMarkers,
1302
- onClick: (coord) => {
1303
- onMapClick?.(coord);
1304
- if (clearSelectionOnMapClick) {
1305
- clearSelection();
1306
- }
1336
+ className: cn(
1337
+ "w-full",
1338
+ // Default height, can be overridden by mapWrapperClassName
1339
+ mapWrapperClassName || "h-[520px]"
1340
+ ),
1341
+ style: {
1342
+ // CRITICAL: Always use explicit height to prevent MapLibre canvas expansion
1343
+ height: mapWrapperClassName ? void 0 : "520px",
1344
+ maxHeight: "100vh",
1345
+ // Prevent excessive growth
1346
+ position: "relative",
1347
+ overflow: "hidden"
1307
1348
  },
1308
- onMarkerDrag,
1309
- showNavigationControl,
1310
- showGeolocateControl,
1311
- navigationControlPosition,
1312
- geolocateControlPosition,
1313
- flyToOptions,
1314
- className: cn("h-full w-full", mapClassName),
1315
- children: mapChildren
1349
+ children: /* @__PURE__ */ jsx(
1350
+ MapLibre,
1351
+ {
1352
+ stadiaApiKey,
1353
+ mapStyle,
1354
+ styleUrl,
1355
+ mapLibreCssHref,
1356
+ viewState: resolvedViewState,
1357
+ onViewStateChange: applyViewState,
1358
+ markers: mapMarkers,
1359
+ onClick: (coord) => {
1360
+ onMapClick?.(coord);
1361
+ if (clearSelectionOnMapClick) {
1362
+ clearSelection();
1363
+ }
1364
+ },
1365
+ onMarkerDrag,
1366
+ showNavigationControl,
1367
+ showGeolocateControl,
1368
+ navigationControlPosition,
1369
+ geolocateControlPosition,
1370
+ flyToOptions,
1371
+ className: cn("h-full w-full", mapClassName),
1372
+ children: mapChildren
1373
+ }
1374
+ )
1316
1375
  }
1317
- ) }),
1376
+ ),
1318
1377
  selection.type !== "none" ? /* @__PURE__ */ jsx(
1319
1378
  "div",
1320
1379
  {