@page-speed/maps 0.1.5 → 0.1.7
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 +115 -36
- package/dist/components/geo-map.cjs.map +1 -1
- package/dist/components/geo-map.js +115 -36
- package/dist/components/geo-map.js.map +1 -1
- package/dist/components/index.cjs +115 -36
- package/dist/components/index.cjs.map +1 -1
- package/dist/components/index.js +115 -36
- package/dist/components/index.js.map +1 -1
- package/dist/core/MapLibre.cjs +46 -2
- package/dist/core/MapLibre.cjs.map +1 -1
- package/dist/core/MapLibre.js +46 -2
- package/dist/core/MapLibre.js.map +1 -1
- package/dist/core/index.cjs +46 -2
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.js +46 -2
- package/dist/core/index.js.map +1 -1
- package/dist/index.cjs +115 -36
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +115 -36
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -587,11 +587,55 @@ function MapLibre({
|
|
|
587
587
|
}
|
|
588
588
|
return getMapLibreStyleUrl("osm-bright", stadiaApiKey);
|
|
589
589
|
}, [mapStyle, stadiaApiKey, styleUrl]);
|
|
590
|
+
const isInIframe = React3__namespace.default.useMemo(() => {
|
|
591
|
+
if (typeof window === "undefined") return false;
|
|
592
|
+
try {
|
|
593
|
+
return window.self !== window.top;
|
|
594
|
+
} catch {
|
|
595
|
+
return true;
|
|
596
|
+
}
|
|
597
|
+
}, []);
|
|
598
|
+
React3__namespace.default.useEffect(() => {
|
|
599
|
+
if (!isInIframe || !mapRef.current) return;
|
|
600
|
+
let lastHeight = 0;
|
|
601
|
+
let lastWidth = 0;
|
|
602
|
+
let resizeTimeout;
|
|
603
|
+
const handleResize = (entries) => {
|
|
604
|
+
clearTimeout(resizeTimeout);
|
|
605
|
+
const entry = entries[0];
|
|
606
|
+
if (!entry) return;
|
|
607
|
+
const { width, height } = entry.contentRect;
|
|
608
|
+
const widthChanged = Math.abs(width - lastWidth) > 1;
|
|
609
|
+
const heightChanged = Math.abs(height - lastHeight) > 1;
|
|
610
|
+
if (widthChanged || heightChanged) {
|
|
611
|
+
lastWidth = width;
|
|
612
|
+
lastHeight = height;
|
|
613
|
+
resizeTimeout = setTimeout(() => {
|
|
614
|
+
mapRef.current?.resize();
|
|
615
|
+
}, 250);
|
|
616
|
+
}
|
|
617
|
+
};
|
|
618
|
+
const parentElement = mapRef.current.getContainer().parentElement;
|
|
619
|
+
if (parentElement) {
|
|
620
|
+
const resizeObserver = new ResizeObserver(handleResize);
|
|
621
|
+
resizeObserver.observe(parentElement);
|
|
622
|
+
return () => {
|
|
623
|
+
clearTimeout(resizeTimeout);
|
|
624
|
+
resizeObserver.disconnect();
|
|
625
|
+
};
|
|
626
|
+
}
|
|
627
|
+
}, [isInIframe]);
|
|
590
628
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
591
629
|
"div",
|
|
592
630
|
{
|
|
593
631
|
className: joinClassNames("relative w-full h-full", className),
|
|
594
|
-
style: {
|
|
632
|
+
style: {
|
|
633
|
+
width: "100%",
|
|
634
|
+
height: "100%",
|
|
635
|
+
// Prevent content from pushing container size in iframes
|
|
636
|
+
...isInIframe && { overflow: "hidden", position: "relative" },
|
|
637
|
+
...style
|
|
638
|
+
},
|
|
595
639
|
children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
596
640
|
maplibre.Map,
|
|
597
641
|
{
|
|
@@ -603,7 +647,7 @@ function MapLibre({
|
|
|
603
647
|
onMoveEnd: handleMoveEnd,
|
|
604
648
|
onClick: handleMapClick,
|
|
605
649
|
attributionControl: false,
|
|
606
|
-
trackResize:
|
|
650
|
+
trackResize: !isInIframe,
|
|
607
651
|
dragRotate: false,
|
|
608
652
|
touchZoomRotate: false,
|
|
609
653
|
children: [
|
|
@@ -666,10 +710,7 @@ function resolveActionKey(action, index) {
|
|
|
666
710
|
}
|
|
667
711
|
return `action:${index}`;
|
|
668
712
|
}
|
|
669
|
-
var FallbackIcon = ({
|
|
670
|
-
size = 20,
|
|
671
|
-
className
|
|
672
|
-
}) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
713
|
+
var FallbackIcon = ({ size = 20, className }) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
673
714
|
"svg",
|
|
674
715
|
{
|
|
675
716
|
width: size,
|
|
@@ -788,7 +829,7 @@ function MarkerMediaCarousel({
|
|
|
788
829
|
{
|
|
789
830
|
type: "button",
|
|
790
831
|
"aria-label": "Show previous media",
|
|
791
|
-
className: "absolute left-4 top-1/2 inline-flex size-10 -translate-y-1/2 items-center justify-center rounded-2xl bg-card text-card-foreground shadow-lg border-4 border-black hover:border-white hover:bg-black hover:text-white transition-all duration-500 z-
|
|
832
|
+
className: "absolute left-4 top-1/2 inline-flex size-10 -translate-y-1/2 items-center justify-center rounded-2xl bg-card text-card-foreground shadow-lg border-4 border-black hover:border-white hover:bg-black hover:text-white transition-all duration-500 z-2",
|
|
792
833
|
onClick: () => {
|
|
793
834
|
setActiveIndex(
|
|
794
835
|
(current) => (current - 1 + totalItems) % totalItems
|
|
@@ -921,10 +962,16 @@ function GeoMap({
|
|
|
921
962
|
const firstCoordinate = React3__namespace.useMemo(() => {
|
|
922
963
|
const allCoords = [];
|
|
923
964
|
normalizedStandaloneMarkers.forEach((marker) => {
|
|
924
|
-
allCoords.push({
|
|
965
|
+
allCoords.push({
|
|
966
|
+
latitude: marker.latitude,
|
|
967
|
+
longitude: marker.longitude
|
|
968
|
+
});
|
|
925
969
|
});
|
|
926
970
|
normalizedClusters.forEach((cluster) => {
|
|
927
|
-
allCoords.push({
|
|
971
|
+
allCoords.push({
|
|
972
|
+
latitude: cluster.latitude,
|
|
973
|
+
longitude: cluster.longitude
|
|
974
|
+
});
|
|
928
975
|
});
|
|
929
976
|
if (allCoords.length > 0) {
|
|
930
977
|
const sum = allCoords.reduce(
|
|
@@ -950,10 +997,16 @@ function GeoMap({
|
|
|
950
997
|
}
|
|
951
998
|
const allCoords = [];
|
|
952
999
|
normalizedStandaloneMarkers.forEach((marker) => {
|
|
953
|
-
allCoords.push({
|
|
1000
|
+
allCoords.push({
|
|
1001
|
+
latitude: marker.latitude,
|
|
1002
|
+
longitude: marker.longitude
|
|
1003
|
+
});
|
|
954
1004
|
});
|
|
955
1005
|
normalizedClusters.forEach((cluster) => {
|
|
956
|
-
allCoords.push({
|
|
1006
|
+
allCoords.push({
|
|
1007
|
+
latitude: cluster.latitude,
|
|
1008
|
+
longitude: cluster.longitude
|
|
1009
|
+
});
|
|
957
1010
|
});
|
|
958
1011
|
if (allCoords.length === 0) {
|
|
959
1012
|
return DEFAULT_VIEW_STATE.zoom;
|
|
@@ -1181,7 +1234,7 @@ function GeoMap({
|
|
|
1181
1234
|
"div",
|
|
1182
1235
|
{
|
|
1183
1236
|
className: cn(
|
|
1184
|
-
"relative w-
|
|
1237
|
+
"relative w-80 overflow-hidden rounded-xl border border-border bg-card text-card-foreground shadow-2xl",
|
|
1185
1238
|
panelClassName
|
|
1186
1239
|
),
|
|
1187
1240
|
children: [
|
|
@@ -1255,7 +1308,7 @@ function GeoMap({
|
|
|
1255
1308
|
"div",
|
|
1256
1309
|
{
|
|
1257
1310
|
className: cn(
|
|
1258
|
-
"relative w-
|
|
1311
|
+
"relative w-80 overflow-hidden rounded-xl border border-border bg-card text-card-foreground p-4 shadow-2xl",
|
|
1259
1312
|
panelClassName
|
|
1260
1313
|
),
|
|
1261
1314
|
children: [
|
|
@@ -1293,6 +1346,14 @@ function GeoMap({
|
|
|
1293
1346
|
}
|
|
1294
1347
|
return null;
|
|
1295
1348
|
};
|
|
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
|
+
}, []);
|
|
1296
1357
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1297
1358
|
"div",
|
|
1298
1359
|
{
|
|
@@ -1300,33 +1361,51 @@ function GeoMap({
|
|
|
1300
1361
|
"relative overflow-hidden rounded-2xl border border-border bg-background",
|
|
1301
1362
|
className
|
|
1302
1363
|
),
|
|
1364
|
+
style: {
|
|
1365
|
+
// Use CSS containment to prevent layout shifts in iframes
|
|
1366
|
+
...isInIframe && { contain: "layout size" }
|
|
1367
|
+
},
|
|
1303
1368
|
children: [
|
|
1304
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1305
|
-
|
|
1369
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1370
|
+
"div",
|
|
1306
1371
|
{
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
onMapClick?.(coord);
|
|
1316
|
-
if (clearSelectionOnMapClick) {
|
|
1317
|
-
clearSelection();
|
|
1318
|
-
}
|
|
1372
|
+
className: cn(
|
|
1373
|
+
"w-full",
|
|
1374
|
+
// Default height, can be overridden by mapWrapperClassName
|
|
1375
|
+
mapWrapperClassName || "h-[520px]"
|
|
1376
|
+
),
|
|
1377
|
+
style: {
|
|
1378
|
+
// Ensure proper height containment in iframes
|
|
1379
|
+
...isInIframe && !mapWrapperClassName && { height: "520px", minHeight: "420px" }
|
|
1319
1380
|
},
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1381
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1382
|
+
MapLibre,
|
|
1383
|
+
{
|
|
1384
|
+
stadiaApiKey,
|
|
1385
|
+
mapStyle,
|
|
1386
|
+
styleUrl,
|
|
1387
|
+
mapLibreCssHref,
|
|
1388
|
+
viewState: resolvedViewState,
|
|
1389
|
+
onViewStateChange: applyViewState,
|
|
1390
|
+
markers: mapMarkers,
|
|
1391
|
+
onClick: (coord) => {
|
|
1392
|
+
onMapClick?.(coord);
|
|
1393
|
+
if (clearSelectionOnMapClick) {
|
|
1394
|
+
clearSelection();
|
|
1395
|
+
}
|
|
1396
|
+
},
|
|
1397
|
+
onMarkerDrag,
|
|
1398
|
+
showNavigationControl,
|
|
1399
|
+
showGeolocateControl,
|
|
1400
|
+
navigationControlPosition,
|
|
1401
|
+
geolocateControlPosition,
|
|
1402
|
+
flyToOptions,
|
|
1403
|
+
className: cn("h-full w-full", mapClassName),
|
|
1404
|
+
children: mapChildren
|
|
1405
|
+
}
|
|
1406
|
+
)
|
|
1328
1407
|
}
|
|
1329
|
-
)
|
|
1408
|
+
),
|
|
1330
1409
|
selection.type !== "none" ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1331
1410
|
"div",
|
|
1332
1411
|
{
|