@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/components/index.js
CHANGED
|
@@ -566,53 +566,50 @@ function MapLibre({
|
|
|
566
566
|
}
|
|
567
567
|
return getMapLibreStyleUrl("osm-bright", stadiaApiKey);
|
|
568
568
|
}, [mapStyle, stadiaApiKey, styleUrl]);
|
|
569
|
-
const
|
|
570
|
-
if (typeof window === "undefined") return false;
|
|
571
|
-
try {
|
|
572
|
-
return window.self !== window.top;
|
|
573
|
-
} catch {
|
|
574
|
-
return true;
|
|
575
|
-
}
|
|
576
|
-
}, []);
|
|
569
|
+
const containerRef = React3__default.useRef(null);
|
|
577
570
|
React3__default.useEffect(() => {
|
|
578
|
-
if (!
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
const
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
lastHeight = height;
|
|
592
|
-
resizeTimeout = setTimeout(() => {
|
|
593
|
-
mapRef.current?.resize();
|
|
594
|
-
}, 250);
|
|
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
|
+
}
|
|
595
584
|
}
|
|
596
585
|
};
|
|
597
|
-
const
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
resizeObserver
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
};
|
|
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);
|
|
605
593
|
}
|
|
606
|
-
|
|
594
|
+
return () => {
|
|
595
|
+
clearInterval(interval);
|
|
596
|
+
if (resizeObserver) {
|
|
597
|
+
resizeObserver.disconnect();
|
|
598
|
+
}
|
|
599
|
+
};
|
|
600
|
+
}, []);
|
|
607
601
|
return /* @__PURE__ */ jsx(
|
|
608
602
|
"div",
|
|
609
603
|
{
|
|
604
|
+
ref: containerRef,
|
|
610
605
|
className: joinClassNames("relative w-full h-full", className),
|
|
611
606
|
style: {
|
|
612
607
|
width: "100%",
|
|
613
608
|
height: "100%",
|
|
614
|
-
|
|
615
|
-
|
|
609
|
+
maxHeight: "100vh",
|
|
610
|
+
// Prevent excessive height
|
|
611
|
+
overflow: "hidden",
|
|
612
|
+
position: "relative",
|
|
616
613
|
...style
|
|
617
614
|
},
|
|
618
615
|
children: /* @__PURE__ */ jsxs(
|
|
@@ -626,7 +623,7 @@ function MapLibre({
|
|
|
626
623
|
onMoveEnd: handleMoveEnd,
|
|
627
624
|
onClick: handleMapClick,
|
|
628
625
|
attributionControl: false,
|
|
629
|
-
trackResize:
|
|
626
|
+
trackResize: true,
|
|
630
627
|
dragRotate: false,
|
|
631
628
|
touchZoomRotate: false,
|
|
632
629
|
children: [
|
|
@@ -1325,14 +1322,6 @@ function GeoMap({
|
|
|
1325
1322
|
}
|
|
1326
1323
|
return null;
|
|
1327
1324
|
};
|
|
1328
|
-
const isInIframe = React3.useMemo(() => {
|
|
1329
|
-
if (typeof window === "undefined") return false;
|
|
1330
|
-
try {
|
|
1331
|
-
return window.self !== window.top;
|
|
1332
|
-
} catch {
|
|
1333
|
-
return true;
|
|
1334
|
-
}
|
|
1335
|
-
}, []);
|
|
1336
1325
|
return /* @__PURE__ */ jsxs(
|
|
1337
1326
|
"div",
|
|
1338
1327
|
{
|
|
@@ -1340,10 +1329,6 @@ function GeoMap({
|
|
|
1340
1329
|
"relative overflow-hidden rounded-2xl border border-border bg-background",
|
|
1341
1330
|
className
|
|
1342
1331
|
),
|
|
1343
|
-
style: {
|
|
1344
|
-
// Use CSS containment to prevent layout shifts in iframes
|
|
1345
|
-
...isInIframe && { contain: "layout size" }
|
|
1346
|
-
},
|
|
1347
1332
|
children: [
|
|
1348
1333
|
/* @__PURE__ */ jsx(
|
|
1349
1334
|
"div",
|
|
@@ -1354,8 +1339,12 @@ function GeoMap({
|
|
|
1354
1339
|
mapWrapperClassName || "h-[520px]"
|
|
1355
1340
|
),
|
|
1356
1341
|
style: {
|
|
1357
|
-
//
|
|
1358
|
-
|
|
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"
|
|
1359
1348
|
},
|
|
1360
1349
|
children: /* @__PURE__ */ jsx(
|
|
1361
1350
|
MapLibre,
|