@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.
@@ -587,11 +587,52 @@ function MapLibre({
587
587
  }
588
588
  return getMapLibreStyleUrl("osm-bright", stadiaApiKey);
589
589
  }, [mapStyle, stadiaApiKey, styleUrl]);
590
+ const containerRef = React3__namespace.default.useRef(null);
591
+ React3__namespace.default.useEffect(() => {
592
+ if (!mapRef.current || !containerRef.current) return;
593
+ const enforceContainerHeight = () => {
594
+ const container = containerRef.current;
595
+ const map = mapRef.current;
596
+ if (!container || !map) return;
597
+ const rect = container.getBoundingClientRect();
598
+ const maxHeight = Math.min(rect.height, window.innerHeight);
599
+ const canvas = map.getCanvas();
600
+ if (canvas && canvas.style.height) {
601
+ const canvasHeight = parseInt(canvas.style.height);
602
+ if (canvasHeight > maxHeight || canvasHeight > 2e3) {
603
+ map.resize();
604
+ }
605
+ }
606
+ };
607
+ const interval = setInterval(enforceContainerHeight, 1e3);
608
+ let resizeObserver = null;
609
+ if (typeof ResizeObserver !== "undefined") {
610
+ resizeObserver = new ResizeObserver(() => {
611
+ enforceContainerHeight();
612
+ });
613
+ resizeObserver.observe(containerRef.current);
614
+ }
615
+ return () => {
616
+ clearInterval(interval);
617
+ if (resizeObserver) {
618
+ resizeObserver.disconnect();
619
+ }
620
+ };
621
+ }, []);
590
622
  return /* @__PURE__ */ jsxRuntime.jsx(
591
623
  "div",
592
624
  {
625
+ ref: containerRef,
593
626
  className: joinClassNames("relative w-full h-full", className),
594
- style: { width: "100%", height: "100%", ...style },
627
+ style: {
628
+ width: "100%",
629
+ height: "100%",
630
+ maxHeight: "100vh",
631
+ // Prevent excessive height
632
+ overflow: "hidden",
633
+ position: "relative",
634
+ ...style
635
+ },
595
636
  children: /* @__PURE__ */ jsxRuntime.jsxs(
596
637
  maplibre.Map,
597
638
  {
@@ -1190,7 +1231,7 @@ function GeoMap({
1190
1231
  "div",
1191
1232
  {
1192
1233
  className: cn(
1193
- "relative w-[320px] overflow-hidden rounded-xl border border-border bg-card text-card-foreground shadow-2xl",
1234
+ "relative w-80 overflow-hidden rounded-xl border border-border bg-card text-card-foreground shadow-2xl",
1194
1235
  panelClassName
1195
1236
  ),
1196
1237
  children: [
@@ -1264,7 +1305,7 @@ function GeoMap({
1264
1305
  "div",
1265
1306
  {
1266
1307
  className: cn(
1267
- "relative w-[320px] overflow-hidden rounded-xl border border-border bg-card text-card-foreground p-4 shadow-2xl",
1308
+ "relative w-80 overflow-hidden rounded-xl border border-border bg-card text-card-foreground p-4 shadow-2xl",
1268
1309
  panelClassName
1269
1310
  ),
1270
1311
  children: [
@@ -1310,32 +1351,50 @@ function GeoMap({
1310
1351
  className
1311
1352
  ),
1312
1353
  children: [
1313
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("h-[520px] w-full", mapWrapperClassName), children: /* @__PURE__ */ jsxRuntime.jsx(
1314
- MapLibre,
1354
+ /* @__PURE__ */ jsxRuntime.jsx(
1355
+ "div",
1315
1356
  {
1316
- stadiaApiKey,
1317
- mapStyle,
1318
- styleUrl,
1319
- mapLibreCssHref,
1320
- viewState: resolvedViewState,
1321
- onViewStateChange: applyViewState,
1322
- markers: mapMarkers,
1323
- onClick: (coord) => {
1324
- onMapClick?.(coord);
1325
- if (clearSelectionOnMapClick) {
1326
- clearSelection();
1327
- }
1357
+ className: cn(
1358
+ "w-full",
1359
+ // Default height, can be overridden by mapWrapperClassName
1360
+ mapWrapperClassName || "h-[520px]"
1361
+ ),
1362
+ style: {
1363
+ // CRITICAL: Always use explicit height to prevent MapLibre canvas expansion
1364
+ height: mapWrapperClassName ? void 0 : "520px",
1365
+ maxHeight: "100vh",
1366
+ // Prevent excessive growth
1367
+ position: "relative",
1368
+ overflow: "hidden"
1328
1369
  },
1329
- onMarkerDrag,
1330
- showNavigationControl,
1331
- showGeolocateControl,
1332
- navigationControlPosition,
1333
- geolocateControlPosition,
1334
- flyToOptions,
1335
- className: cn("h-full w-full", mapClassName),
1336
- children: mapChildren
1370
+ children: /* @__PURE__ */ jsxRuntime.jsx(
1371
+ MapLibre,
1372
+ {
1373
+ stadiaApiKey,
1374
+ mapStyle,
1375
+ styleUrl,
1376
+ mapLibreCssHref,
1377
+ viewState: resolvedViewState,
1378
+ onViewStateChange: applyViewState,
1379
+ markers: mapMarkers,
1380
+ onClick: (coord) => {
1381
+ onMapClick?.(coord);
1382
+ if (clearSelectionOnMapClick) {
1383
+ clearSelection();
1384
+ }
1385
+ },
1386
+ onMarkerDrag,
1387
+ showNavigationControl,
1388
+ showGeolocateControl,
1389
+ navigationControlPosition,
1390
+ geolocateControlPosition,
1391
+ flyToOptions,
1392
+ className: cn("h-full w-full", mapClassName),
1393
+ children: mapChildren
1394
+ }
1395
+ )
1337
1396
  }
1338
- ) }),
1397
+ ),
1339
1398
  selection.type !== "none" ? /* @__PURE__ */ jsxRuntime.jsx(
1340
1399
  "div",
1341
1400
  {