@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
|
@@ -447,11 +447,55 @@ function MapLibre({
|
|
|
447
447
|
}
|
|
448
448
|
return getMapLibreStyleUrl("osm-bright", stadiaApiKey);
|
|
449
449
|
}, [mapStyle, stadiaApiKey, styleUrl]);
|
|
450
|
+
const isInIframe = React3__default.useMemo(() => {
|
|
451
|
+
if (typeof window === "undefined") return false;
|
|
452
|
+
try {
|
|
453
|
+
return window.self !== window.top;
|
|
454
|
+
} catch {
|
|
455
|
+
return true;
|
|
456
|
+
}
|
|
457
|
+
}, []);
|
|
458
|
+
React3__default.useEffect(() => {
|
|
459
|
+
if (!isInIframe || !mapRef.current) return;
|
|
460
|
+
let lastHeight = 0;
|
|
461
|
+
let lastWidth = 0;
|
|
462
|
+
let resizeTimeout;
|
|
463
|
+
const handleResize = (entries) => {
|
|
464
|
+
clearTimeout(resizeTimeout);
|
|
465
|
+
const entry = entries[0];
|
|
466
|
+
if (!entry) return;
|
|
467
|
+
const { width, height } = entry.contentRect;
|
|
468
|
+
const widthChanged = Math.abs(width - lastWidth) > 1;
|
|
469
|
+
const heightChanged = Math.abs(height - lastHeight) > 1;
|
|
470
|
+
if (widthChanged || heightChanged) {
|
|
471
|
+
lastWidth = width;
|
|
472
|
+
lastHeight = height;
|
|
473
|
+
resizeTimeout = setTimeout(() => {
|
|
474
|
+
mapRef.current?.resize();
|
|
475
|
+
}, 250);
|
|
476
|
+
}
|
|
477
|
+
};
|
|
478
|
+
const parentElement = mapRef.current.getContainer().parentElement;
|
|
479
|
+
if (parentElement) {
|
|
480
|
+
const resizeObserver = new ResizeObserver(handleResize);
|
|
481
|
+
resizeObserver.observe(parentElement);
|
|
482
|
+
return () => {
|
|
483
|
+
clearTimeout(resizeTimeout);
|
|
484
|
+
resizeObserver.disconnect();
|
|
485
|
+
};
|
|
486
|
+
}
|
|
487
|
+
}, [isInIframe]);
|
|
450
488
|
return /* @__PURE__ */ jsx(
|
|
451
489
|
"div",
|
|
452
490
|
{
|
|
453
491
|
className: joinClassNames("relative w-full h-full", className),
|
|
454
|
-
style: {
|
|
492
|
+
style: {
|
|
493
|
+
width: "100%",
|
|
494
|
+
height: "100%",
|
|
495
|
+
// Prevent content from pushing container size in iframes
|
|
496
|
+
...isInIframe && { overflow: "hidden", position: "relative" },
|
|
497
|
+
...style
|
|
498
|
+
},
|
|
455
499
|
children: /* @__PURE__ */ jsxs(
|
|
456
500
|
Map$1,
|
|
457
501
|
{
|
|
@@ -463,7 +507,7 @@ function MapLibre({
|
|
|
463
507
|
onMoveEnd: handleMoveEnd,
|
|
464
508
|
onClick: handleMapClick,
|
|
465
509
|
attributionControl: false,
|
|
466
|
-
trackResize:
|
|
510
|
+
trackResize: !isInIframe,
|
|
467
511
|
dragRotate: false,
|
|
468
512
|
touchZoomRotate: false,
|
|
469
513
|
children: [
|
|
@@ -526,10 +570,7 @@ function resolveActionKey(action, index) {
|
|
|
526
570
|
}
|
|
527
571
|
return `action:${index}`;
|
|
528
572
|
}
|
|
529
|
-
var FallbackIcon = ({
|
|
530
|
-
size = 20,
|
|
531
|
-
className
|
|
532
|
-
}) => /* @__PURE__ */ jsx(
|
|
573
|
+
var FallbackIcon = ({ size = 20, className }) => /* @__PURE__ */ jsx(
|
|
533
574
|
"svg",
|
|
534
575
|
{
|
|
535
576
|
width: size,
|
|
@@ -648,7 +689,7 @@ function MarkerMediaCarousel({
|
|
|
648
689
|
{
|
|
649
690
|
type: "button",
|
|
650
691
|
"aria-label": "Show previous media",
|
|
651
|
-
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-
|
|
692
|
+
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",
|
|
652
693
|
onClick: () => {
|
|
653
694
|
setActiveIndex(
|
|
654
695
|
(current) => (current - 1 + totalItems) % totalItems
|
|
@@ -781,10 +822,16 @@ function GeoMap({
|
|
|
781
822
|
const firstCoordinate = React3.useMemo(() => {
|
|
782
823
|
const allCoords = [];
|
|
783
824
|
normalizedStandaloneMarkers.forEach((marker) => {
|
|
784
|
-
allCoords.push({
|
|
825
|
+
allCoords.push({
|
|
826
|
+
latitude: marker.latitude,
|
|
827
|
+
longitude: marker.longitude
|
|
828
|
+
});
|
|
785
829
|
});
|
|
786
830
|
normalizedClusters.forEach((cluster) => {
|
|
787
|
-
allCoords.push({
|
|
831
|
+
allCoords.push({
|
|
832
|
+
latitude: cluster.latitude,
|
|
833
|
+
longitude: cluster.longitude
|
|
834
|
+
});
|
|
788
835
|
});
|
|
789
836
|
if (allCoords.length > 0) {
|
|
790
837
|
const sum = allCoords.reduce(
|
|
@@ -810,10 +857,16 @@ function GeoMap({
|
|
|
810
857
|
}
|
|
811
858
|
const allCoords = [];
|
|
812
859
|
normalizedStandaloneMarkers.forEach((marker) => {
|
|
813
|
-
allCoords.push({
|
|
860
|
+
allCoords.push({
|
|
861
|
+
latitude: marker.latitude,
|
|
862
|
+
longitude: marker.longitude
|
|
863
|
+
});
|
|
814
864
|
});
|
|
815
865
|
normalizedClusters.forEach((cluster) => {
|
|
816
|
-
allCoords.push({
|
|
866
|
+
allCoords.push({
|
|
867
|
+
latitude: cluster.latitude,
|
|
868
|
+
longitude: cluster.longitude
|
|
869
|
+
});
|
|
817
870
|
});
|
|
818
871
|
if (allCoords.length === 0) {
|
|
819
872
|
return DEFAULT_VIEW_STATE.zoom;
|
|
@@ -1041,7 +1094,7 @@ function GeoMap({
|
|
|
1041
1094
|
"div",
|
|
1042
1095
|
{
|
|
1043
1096
|
className: cn(
|
|
1044
|
-
"relative w-
|
|
1097
|
+
"relative w-80 overflow-hidden rounded-xl border border-border bg-card text-card-foreground shadow-2xl",
|
|
1045
1098
|
panelClassName
|
|
1046
1099
|
),
|
|
1047
1100
|
children: [
|
|
@@ -1115,7 +1168,7 @@ function GeoMap({
|
|
|
1115
1168
|
"div",
|
|
1116
1169
|
{
|
|
1117
1170
|
className: cn(
|
|
1118
|
-
"relative w-
|
|
1171
|
+
"relative w-80 overflow-hidden rounded-xl border border-border bg-card text-card-foreground p-4 shadow-2xl",
|
|
1119
1172
|
panelClassName
|
|
1120
1173
|
),
|
|
1121
1174
|
children: [
|
|
@@ -1153,6 +1206,14 @@ function GeoMap({
|
|
|
1153
1206
|
}
|
|
1154
1207
|
return null;
|
|
1155
1208
|
};
|
|
1209
|
+
const isInIframe = React3.useMemo(() => {
|
|
1210
|
+
if (typeof window === "undefined") return false;
|
|
1211
|
+
try {
|
|
1212
|
+
return window.self !== window.top;
|
|
1213
|
+
} catch {
|
|
1214
|
+
return true;
|
|
1215
|
+
}
|
|
1216
|
+
}, []);
|
|
1156
1217
|
return /* @__PURE__ */ jsxs(
|
|
1157
1218
|
"div",
|
|
1158
1219
|
{
|
|
@@ -1160,33 +1221,51 @@ function GeoMap({
|
|
|
1160
1221
|
"relative overflow-hidden rounded-2xl border border-border bg-background",
|
|
1161
1222
|
className
|
|
1162
1223
|
),
|
|
1224
|
+
style: {
|
|
1225
|
+
// Use CSS containment to prevent layout shifts in iframes
|
|
1226
|
+
...isInIframe && { contain: "layout size" }
|
|
1227
|
+
},
|
|
1163
1228
|
children: [
|
|
1164
|
-
/* @__PURE__ */ jsx(
|
|
1165
|
-
|
|
1229
|
+
/* @__PURE__ */ jsx(
|
|
1230
|
+
"div",
|
|
1166
1231
|
{
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
onMapClick?.(coord);
|
|
1176
|
-
if (clearSelectionOnMapClick) {
|
|
1177
|
-
clearSelection();
|
|
1178
|
-
}
|
|
1232
|
+
className: cn(
|
|
1233
|
+
"w-full",
|
|
1234
|
+
// Default height, can be overridden by mapWrapperClassName
|
|
1235
|
+
mapWrapperClassName || "h-[520px]"
|
|
1236
|
+
),
|
|
1237
|
+
style: {
|
|
1238
|
+
// Ensure proper height containment in iframes
|
|
1239
|
+
...isInIframe && !mapWrapperClassName && { height: "520px", minHeight: "420px" }
|
|
1179
1240
|
},
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1241
|
+
children: /* @__PURE__ */ jsx(
|
|
1242
|
+
MapLibre,
|
|
1243
|
+
{
|
|
1244
|
+
stadiaApiKey,
|
|
1245
|
+
mapStyle,
|
|
1246
|
+
styleUrl,
|
|
1247
|
+
mapLibreCssHref,
|
|
1248
|
+
viewState: resolvedViewState,
|
|
1249
|
+
onViewStateChange: applyViewState,
|
|
1250
|
+
markers: mapMarkers,
|
|
1251
|
+
onClick: (coord) => {
|
|
1252
|
+
onMapClick?.(coord);
|
|
1253
|
+
if (clearSelectionOnMapClick) {
|
|
1254
|
+
clearSelection();
|
|
1255
|
+
}
|
|
1256
|
+
},
|
|
1257
|
+
onMarkerDrag,
|
|
1258
|
+
showNavigationControl,
|
|
1259
|
+
showGeolocateControl,
|
|
1260
|
+
navigationControlPosition,
|
|
1261
|
+
geolocateControlPosition,
|
|
1262
|
+
flyToOptions,
|
|
1263
|
+
className: cn("h-full w-full", mapClassName),
|
|
1264
|
+
children: mapChildren
|
|
1265
|
+
}
|
|
1266
|
+
)
|
|
1188
1267
|
}
|
|
1189
|
-
)
|
|
1268
|
+
),
|
|
1190
1269
|
selection.type !== "none" ? /* @__PURE__ */ jsx(
|
|
1191
1270
|
"div",
|
|
1192
1271
|
{
|