@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
|
@@ -587,53 +587,50 @@ function MapLibre({
|
|
|
587
587
|
}
|
|
588
588
|
return getMapLibreStyleUrl("osm-bright", stadiaApiKey);
|
|
589
589
|
}, [mapStyle, stadiaApiKey, styleUrl]);
|
|
590
|
-
const
|
|
591
|
-
if (typeof window === "undefined") return false;
|
|
592
|
-
try {
|
|
593
|
-
return window.self !== window.top;
|
|
594
|
-
} catch {
|
|
595
|
-
return true;
|
|
596
|
-
}
|
|
597
|
-
}, []);
|
|
590
|
+
const containerRef = React3__namespace.default.useRef(null);
|
|
598
591
|
React3__namespace.default.useEffect(() => {
|
|
599
|
-
if (!
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
const
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
lastHeight = height;
|
|
613
|
-
resizeTimeout = setTimeout(() => {
|
|
614
|
-
mapRef.current?.resize();
|
|
615
|
-
}, 250);
|
|
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
|
+
}
|
|
616
605
|
}
|
|
617
606
|
};
|
|
618
|
-
const
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
resizeObserver
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
};
|
|
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);
|
|
626
614
|
}
|
|
627
|
-
|
|
615
|
+
return () => {
|
|
616
|
+
clearInterval(interval);
|
|
617
|
+
if (resizeObserver) {
|
|
618
|
+
resizeObserver.disconnect();
|
|
619
|
+
}
|
|
620
|
+
};
|
|
621
|
+
}, []);
|
|
628
622
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
629
623
|
"div",
|
|
630
624
|
{
|
|
625
|
+
ref: containerRef,
|
|
631
626
|
className: joinClassNames("relative w-full h-full", className),
|
|
632
627
|
style: {
|
|
633
628
|
width: "100%",
|
|
634
629
|
height: "100%",
|
|
635
|
-
|
|
636
|
-
|
|
630
|
+
maxHeight: "100vh",
|
|
631
|
+
// Prevent excessive height
|
|
632
|
+
overflow: "hidden",
|
|
633
|
+
position: "relative",
|
|
637
634
|
...style
|
|
638
635
|
},
|
|
639
636
|
children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -647,7 +644,7 @@ function MapLibre({
|
|
|
647
644
|
onMoveEnd: handleMoveEnd,
|
|
648
645
|
onClick: handleMapClick,
|
|
649
646
|
attributionControl: false,
|
|
650
|
-
trackResize:
|
|
647
|
+
trackResize: true,
|
|
651
648
|
dragRotate: false,
|
|
652
649
|
touchZoomRotate: false,
|
|
653
650
|
children: [
|
|
@@ -1346,14 +1343,6 @@ function GeoMap({
|
|
|
1346
1343
|
}
|
|
1347
1344
|
return null;
|
|
1348
1345
|
};
|
|
1349
|
-
const isInIframe = React3__namespace.useMemo(() => {
|
|
1350
|
-
if (typeof window === "undefined") return false;
|
|
1351
|
-
try {
|
|
1352
|
-
return window.self !== window.top;
|
|
1353
|
-
} catch {
|
|
1354
|
-
return true;
|
|
1355
|
-
}
|
|
1356
|
-
}, []);
|
|
1357
1346
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1358
1347
|
"div",
|
|
1359
1348
|
{
|
|
@@ -1361,10 +1350,6 @@ function GeoMap({
|
|
|
1361
1350
|
"relative overflow-hidden rounded-2xl border border-border bg-background",
|
|
1362
1351
|
className
|
|
1363
1352
|
),
|
|
1364
|
-
style: {
|
|
1365
|
-
// Use CSS containment to prevent layout shifts in iframes
|
|
1366
|
-
...isInIframe && { contain: "layout size" }
|
|
1367
|
-
},
|
|
1368
1353
|
children: [
|
|
1369
1354
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1370
1355
|
"div",
|
|
@@ -1375,8 +1360,12 @@ function GeoMap({
|
|
|
1375
1360
|
mapWrapperClassName || "h-[520px]"
|
|
1376
1361
|
),
|
|
1377
1362
|
style: {
|
|
1378
|
-
//
|
|
1379
|
-
|
|
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"
|
|
1380
1369
|
},
|
|
1381
1370
|
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1382
1371
|
MapLibre,
|