@page-speed/maps 0.1.7 → 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.
- package/dist/components/geo-map.cjs +40 -51
- package/dist/components/geo-map.cjs.map +1 -1
- package/dist/components/geo-map.js +40 -51
- package/dist/components/geo-map.js.map +1 -1
- package/dist/components/index.cjs +40 -51
- package/dist/components/index.cjs.map +1 -1
- package/dist/components/index.js +40 -51
- package/dist/components/index.js.map +1 -1
- package/dist/core/MapLibre.cjs +34 -37
- package/dist/core/MapLibre.cjs.map +1 -1
- package/dist/core/MapLibre.js +34 -37
- package/dist/core/MapLibre.js.map +1 -1
- package/dist/core/index.cjs +34 -37
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.js +34 -37
- package/dist/core/index.js.map +1 -1
- package/dist/index.cjs +40 -51
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +40 -51
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -457,53 +457,50 @@ function MapLibre({
|
|
|
457
457
|
}
|
|
458
458
|
return getMapLibreStyleUrl("osm-bright", stadiaApiKey);
|
|
459
459
|
}, [mapStyle, stadiaApiKey, styleUrl]);
|
|
460
|
-
const
|
|
461
|
-
if (typeof window === "undefined") return false;
|
|
462
|
-
try {
|
|
463
|
-
return window.self !== window.top;
|
|
464
|
-
} catch {
|
|
465
|
-
return true;
|
|
466
|
-
}
|
|
467
|
-
}, []);
|
|
460
|
+
const containerRef = React3__default.useRef(null);
|
|
468
461
|
React3__default.useEffect(() => {
|
|
469
|
-
if (!
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
const
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
lastHeight = height;
|
|
483
|
-
resizeTimeout = setTimeout(() => {
|
|
484
|
-
mapRef.current?.resize();
|
|
485
|
-
}, 250);
|
|
462
|
+
if (!mapRef.current || !containerRef.current) return;
|
|
463
|
+
const enforceContainerHeight = () => {
|
|
464
|
+
const container = containerRef.current;
|
|
465
|
+
const map = mapRef.current;
|
|
466
|
+
if (!container || !map) return;
|
|
467
|
+
const rect = container.getBoundingClientRect();
|
|
468
|
+
const maxHeight = Math.min(rect.height, window.innerHeight);
|
|
469
|
+
const canvas = map.getCanvas();
|
|
470
|
+
if (canvas && canvas.style.height) {
|
|
471
|
+
const canvasHeight = parseInt(canvas.style.height);
|
|
472
|
+
if (canvasHeight > maxHeight || canvasHeight > 2e3) {
|
|
473
|
+
map.resize();
|
|
474
|
+
}
|
|
486
475
|
}
|
|
487
476
|
};
|
|
488
|
-
const
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
resizeObserver
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
};
|
|
477
|
+
const interval = setInterval(enforceContainerHeight, 1e3);
|
|
478
|
+
let resizeObserver = null;
|
|
479
|
+
if (typeof ResizeObserver !== "undefined") {
|
|
480
|
+
resizeObserver = new ResizeObserver(() => {
|
|
481
|
+
enforceContainerHeight();
|
|
482
|
+
});
|
|
483
|
+
resizeObserver.observe(containerRef.current);
|
|
496
484
|
}
|
|
497
|
-
|
|
485
|
+
return () => {
|
|
486
|
+
clearInterval(interval);
|
|
487
|
+
if (resizeObserver) {
|
|
488
|
+
resizeObserver.disconnect();
|
|
489
|
+
}
|
|
490
|
+
};
|
|
491
|
+
}, []);
|
|
498
492
|
return /* @__PURE__ */ jsx(
|
|
499
493
|
"div",
|
|
500
494
|
{
|
|
495
|
+
ref: containerRef,
|
|
501
496
|
className: joinClassNames("relative w-full h-full", className),
|
|
502
497
|
style: {
|
|
503
498
|
width: "100%",
|
|
504
499
|
height: "100%",
|
|
505
|
-
|
|
506
|
-
|
|
500
|
+
maxHeight: "100vh",
|
|
501
|
+
// Prevent excessive height
|
|
502
|
+
overflow: "hidden",
|
|
503
|
+
position: "relative",
|
|
507
504
|
...style
|
|
508
505
|
},
|
|
509
506
|
children: /* @__PURE__ */ jsxs(
|
|
@@ -517,7 +514,7 @@ function MapLibre({
|
|
|
517
514
|
onMoveEnd: handleMoveEnd,
|
|
518
515
|
onClick: handleMapClick,
|
|
519
516
|
attributionControl: false,
|
|
520
|
-
trackResize:
|
|
517
|
+
trackResize: true,
|
|
521
518
|
dragRotate: false,
|
|
522
519
|
touchZoomRotate: false,
|
|
523
520
|
children: [
|
|
@@ -1431,14 +1428,6 @@ function GeoMap({
|
|
|
1431
1428
|
}
|
|
1432
1429
|
return null;
|
|
1433
1430
|
};
|
|
1434
|
-
const isInIframe = React3.useMemo(() => {
|
|
1435
|
-
if (typeof window === "undefined") return false;
|
|
1436
|
-
try {
|
|
1437
|
-
return window.self !== window.top;
|
|
1438
|
-
} catch {
|
|
1439
|
-
return true;
|
|
1440
|
-
}
|
|
1441
|
-
}, []);
|
|
1442
1431
|
return /* @__PURE__ */ jsxs(
|
|
1443
1432
|
"div",
|
|
1444
1433
|
{
|
|
@@ -1446,10 +1435,6 @@ function GeoMap({
|
|
|
1446
1435
|
"relative overflow-hidden rounded-2xl border border-border bg-background",
|
|
1447
1436
|
className
|
|
1448
1437
|
),
|
|
1449
|
-
style: {
|
|
1450
|
-
// Use CSS containment to prevent layout shifts in iframes
|
|
1451
|
-
...isInIframe && { contain: "layout size" }
|
|
1452
|
-
},
|
|
1453
1438
|
children: [
|
|
1454
1439
|
/* @__PURE__ */ jsx(
|
|
1455
1440
|
"div",
|
|
@@ -1460,8 +1445,12 @@ function GeoMap({
|
|
|
1460
1445
|
mapWrapperClassName || "h-[520px]"
|
|
1461
1446
|
),
|
|
1462
1447
|
style: {
|
|
1463
|
-
//
|
|
1464
|
-
|
|
1448
|
+
// CRITICAL: Always use explicit height to prevent MapLibre canvas expansion
|
|
1449
|
+
height: mapWrapperClassName ? void 0 : "520px",
|
|
1450
|
+
maxHeight: "100vh",
|
|
1451
|
+
// Prevent excessive growth
|
|
1452
|
+
position: "relative",
|
|
1453
|
+
overflow: "hidden"
|
|
1465
1454
|
},
|
|
1466
1455
|
children: /* @__PURE__ */ jsx(
|
|
1467
1456
|
MapLibre,
|