@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
package/dist/index.js
CHANGED
|
@@ -457,11 +457,55 @@ function MapLibre({
|
|
|
457
457
|
}
|
|
458
458
|
return getMapLibreStyleUrl("osm-bright", stadiaApiKey);
|
|
459
459
|
}, [mapStyle, stadiaApiKey, styleUrl]);
|
|
460
|
+
const isInIframe = React3__default.useMemo(() => {
|
|
461
|
+
if (typeof window === "undefined") return false;
|
|
462
|
+
try {
|
|
463
|
+
return window.self !== window.top;
|
|
464
|
+
} catch {
|
|
465
|
+
return true;
|
|
466
|
+
}
|
|
467
|
+
}, []);
|
|
468
|
+
React3__default.useEffect(() => {
|
|
469
|
+
if (!isInIframe || !mapRef.current) return;
|
|
470
|
+
let lastHeight = 0;
|
|
471
|
+
let lastWidth = 0;
|
|
472
|
+
let resizeTimeout;
|
|
473
|
+
const handleResize = (entries) => {
|
|
474
|
+
clearTimeout(resizeTimeout);
|
|
475
|
+
const entry = entries[0];
|
|
476
|
+
if (!entry) return;
|
|
477
|
+
const { width, height } = entry.contentRect;
|
|
478
|
+
const widthChanged = Math.abs(width - lastWidth) > 1;
|
|
479
|
+
const heightChanged = Math.abs(height - lastHeight) > 1;
|
|
480
|
+
if (widthChanged || heightChanged) {
|
|
481
|
+
lastWidth = width;
|
|
482
|
+
lastHeight = height;
|
|
483
|
+
resizeTimeout = setTimeout(() => {
|
|
484
|
+
mapRef.current?.resize();
|
|
485
|
+
}, 250);
|
|
486
|
+
}
|
|
487
|
+
};
|
|
488
|
+
const parentElement = mapRef.current.getContainer().parentElement;
|
|
489
|
+
if (parentElement) {
|
|
490
|
+
const resizeObserver = new ResizeObserver(handleResize);
|
|
491
|
+
resizeObserver.observe(parentElement);
|
|
492
|
+
return () => {
|
|
493
|
+
clearTimeout(resizeTimeout);
|
|
494
|
+
resizeObserver.disconnect();
|
|
495
|
+
};
|
|
496
|
+
}
|
|
497
|
+
}, [isInIframe]);
|
|
460
498
|
return /* @__PURE__ */ jsx(
|
|
461
499
|
"div",
|
|
462
500
|
{
|
|
463
501
|
className: joinClassNames("relative w-full h-full", className),
|
|
464
|
-
style: {
|
|
502
|
+
style: {
|
|
503
|
+
width: "100%",
|
|
504
|
+
height: "100%",
|
|
505
|
+
// Prevent content from pushing container size in iframes
|
|
506
|
+
...isInIframe && { overflow: "hidden", position: "relative" },
|
|
507
|
+
...style
|
|
508
|
+
},
|
|
465
509
|
children: /* @__PURE__ */ jsxs(
|
|
466
510
|
Map$1,
|
|
467
511
|
{
|
|
@@ -473,7 +517,7 @@ function MapLibre({
|
|
|
473
517
|
onMoveEnd: handleMoveEnd,
|
|
474
518
|
onClick: handleMapClick,
|
|
475
519
|
attributionControl: false,
|
|
476
|
-
trackResize:
|
|
520
|
+
trackResize: !isInIframe,
|
|
477
521
|
dragRotate: false,
|
|
478
522
|
touchZoomRotate: false,
|
|
479
523
|
children: [
|
|
@@ -751,10 +795,7 @@ function resolveActionKey(action, index) {
|
|
|
751
795
|
}
|
|
752
796
|
return `action:${index}`;
|
|
753
797
|
}
|
|
754
|
-
var FallbackIcon = ({
|
|
755
|
-
size = 20,
|
|
756
|
-
className
|
|
757
|
-
}) => /* @__PURE__ */ jsx(
|
|
798
|
+
var FallbackIcon = ({ size = 20, className }) => /* @__PURE__ */ jsx(
|
|
758
799
|
"svg",
|
|
759
800
|
{
|
|
760
801
|
width: size,
|
|
@@ -873,7 +914,7 @@ function MarkerMediaCarousel({
|
|
|
873
914
|
{
|
|
874
915
|
type: "button",
|
|
875
916
|
"aria-label": "Show previous media",
|
|
876
|
-
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-
|
|
917
|
+
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",
|
|
877
918
|
onClick: () => {
|
|
878
919
|
setActiveIndex(
|
|
879
920
|
(current) => (current - 1 + totalItems) % totalItems
|
|
@@ -1006,10 +1047,16 @@ function GeoMap({
|
|
|
1006
1047
|
const firstCoordinate = React3.useMemo(() => {
|
|
1007
1048
|
const allCoords = [];
|
|
1008
1049
|
normalizedStandaloneMarkers.forEach((marker) => {
|
|
1009
|
-
allCoords.push({
|
|
1050
|
+
allCoords.push({
|
|
1051
|
+
latitude: marker.latitude,
|
|
1052
|
+
longitude: marker.longitude
|
|
1053
|
+
});
|
|
1010
1054
|
});
|
|
1011
1055
|
normalizedClusters.forEach((cluster) => {
|
|
1012
|
-
allCoords.push({
|
|
1056
|
+
allCoords.push({
|
|
1057
|
+
latitude: cluster.latitude,
|
|
1058
|
+
longitude: cluster.longitude
|
|
1059
|
+
});
|
|
1013
1060
|
});
|
|
1014
1061
|
if (allCoords.length > 0) {
|
|
1015
1062
|
const sum = allCoords.reduce(
|
|
@@ -1035,10 +1082,16 @@ function GeoMap({
|
|
|
1035
1082
|
}
|
|
1036
1083
|
const allCoords = [];
|
|
1037
1084
|
normalizedStandaloneMarkers.forEach((marker) => {
|
|
1038
|
-
allCoords.push({
|
|
1085
|
+
allCoords.push({
|
|
1086
|
+
latitude: marker.latitude,
|
|
1087
|
+
longitude: marker.longitude
|
|
1088
|
+
});
|
|
1039
1089
|
});
|
|
1040
1090
|
normalizedClusters.forEach((cluster) => {
|
|
1041
|
-
allCoords.push({
|
|
1091
|
+
allCoords.push({
|
|
1092
|
+
latitude: cluster.latitude,
|
|
1093
|
+
longitude: cluster.longitude
|
|
1094
|
+
});
|
|
1042
1095
|
});
|
|
1043
1096
|
if (allCoords.length === 0) {
|
|
1044
1097
|
return DEFAULT_VIEW_STATE.zoom;
|
|
@@ -1266,7 +1319,7 @@ function GeoMap({
|
|
|
1266
1319
|
"div",
|
|
1267
1320
|
{
|
|
1268
1321
|
className: cn(
|
|
1269
|
-
"relative w-
|
|
1322
|
+
"relative w-80 overflow-hidden rounded-xl border border-border bg-card text-card-foreground shadow-2xl",
|
|
1270
1323
|
panelClassName
|
|
1271
1324
|
),
|
|
1272
1325
|
children: [
|
|
@@ -1340,7 +1393,7 @@ function GeoMap({
|
|
|
1340
1393
|
"div",
|
|
1341
1394
|
{
|
|
1342
1395
|
className: cn(
|
|
1343
|
-
"relative w-
|
|
1396
|
+
"relative w-80 overflow-hidden rounded-xl border border-border bg-card text-card-foreground p-4 shadow-2xl",
|
|
1344
1397
|
panelClassName
|
|
1345
1398
|
),
|
|
1346
1399
|
children: [
|
|
@@ -1378,6 +1431,14 @@ function GeoMap({
|
|
|
1378
1431
|
}
|
|
1379
1432
|
return null;
|
|
1380
1433
|
};
|
|
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
|
+
}, []);
|
|
1381
1442
|
return /* @__PURE__ */ jsxs(
|
|
1382
1443
|
"div",
|
|
1383
1444
|
{
|
|
@@ -1385,33 +1446,51 @@ function GeoMap({
|
|
|
1385
1446
|
"relative overflow-hidden rounded-2xl border border-border bg-background",
|
|
1386
1447
|
className
|
|
1387
1448
|
),
|
|
1449
|
+
style: {
|
|
1450
|
+
// Use CSS containment to prevent layout shifts in iframes
|
|
1451
|
+
...isInIframe && { contain: "layout size" }
|
|
1452
|
+
},
|
|
1388
1453
|
children: [
|
|
1389
|
-
/* @__PURE__ */ jsx(
|
|
1390
|
-
|
|
1454
|
+
/* @__PURE__ */ jsx(
|
|
1455
|
+
"div",
|
|
1391
1456
|
{
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
onMapClick?.(coord);
|
|
1401
|
-
if (clearSelectionOnMapClick) {
|
|
1402
|
-
clearSelection();
|
|
1403
|
-
}
|
|
1457
|
+
className: cn(
|
|
1458
|
+
"w-full",
|
|
1459
|
+
// Default height, can be overridden by mapWrapperClassName
|
|
1460
|
+
mapWrapperClassName || "h-[520px]"
|
|
1461
|
+
),
|
|
1462
|
+
style: {
|
|
1463
|
+
// Ensure proper height containment in iframes
|
|
1464
|
+
...isInIframe && !mapWrapperClassName && { height: "520px", minHeight: "420px" }
|
|
1404
1465
|
},
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1466
|
+
children: /* @__PURE__ */ jsx(
|
|
1467
|
+
MapLibre,
|
|
1468
|
+
{
|
|
1469
|
+
stadiaApiKey,
|
|
1470
|
+
mapStyle,
|
|
1471
|
+
styleUrl,
|
|
1472
|
+
mapLibreCssHref,
|
|
1473
|
+
viewState: resolvedViewState,
|
|
1474
|
+
onViewStateChange: applyViewState,
|
|
1475
|
+
markers: mapMarkers,
|
|
1476
|
+
onClick: (coord) => {
|
|
1477
|
+
onMapClick?.(coord);
|
|
1478
|
+
if (clearSelectionOnMapClick) {
|
|
1479
|
+
clearSelection();
|
|
1480
|
+
}
|
|
1481
|
+
},
|
|
1482
|
+
onMarkerDrag,
|
|
1483
|
+
showNavigationControl,
|
|
1484
|
+
showGeolocateControl,
|
|
1485
|
+
navigationControlPosition,
|
|
1486
|
+
geolocateControlPosition,
|
|
1487
|
+
flyToOptions,
|
|
1488
|
+
className: cn("h-full w-full", mapClassName),
|
|
1489
|
+
children: mapChildren
|
|
1490
|
+
}
|
|
1491
|
+
)
|
|
1413
1492
|
}
|
|
1414
|
-
)
|
|
1493
|
+
),
|
|
1415
1494
|
selection.type !== "none" ? /* @__PURE__ */ jsx(
|
|
1416
1495
|
"div",
|
|
1417
1496
|
{
|