@page-speed/maps 0.1.6 → 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 +97 -27
- package/dist/components/geo-map.cjs.map +1 -1
- package/dist/components/geo-map.js +97 -27
- package/dist/components/geo-map.js.map +1 -1
- package/dist/components/index.cjs +97 -27
- package/dist/components/index.cjs.map +1 -1
- package/dist/components/index.js +97 -27
- 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 +97 -27
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +97 -27
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/components/index.js
CHANGED
|
@@ -566,11 +566,55 @@ function MapLibre({
|
|
|
566
566
|
}
|
|
567
567
|
return getMapLibreStyleUrl("osm-bright", stadiaApiKey);
|
|
568
568
|
}, [mapStyle, stadiaApiKey, styleUrl]);
|
|
569
|
+
const isInIframe = React3__default.useMemo(() => {
|
|
570
|
+
if (typeof window === "undefined") return false;
|
|
571
|
+
try {
|
|
572
|
+
return window.self !== window.top;
|
|
573
|
+
} catch {
|
|
574
|
+
return true;
|
|
575
|
+
}
|
|
576
|
+
}, []);
|
|
577
|
+
React3__default.useEffect(() => {
|
|
578
|
+
if (!isInIframe || !mapRef.current) return;
|
|
579
|
+
let lastHeight = 0;
|
|
580
|
+
let lastWidth = 0;
|
|
581
|
+
let resizeTimeout;
|
|
582
|
+
const handleResize = (entries) => {
|
|
583
|
+
clearTimeout(resizeTimeout);
|
|
584
|
+
const entry = entries[0];
|
|
585
|
+
if (!entry) return;
|
|
586
|
+
const { width, height } = entry.contentRect;
|
|
587
|
+
const widthChanged = Math.abs(width - lastWidth) > 1;
|
|
588
|
+
const heightChanged = Math.abs(height - lastHeight) > 1;
|
|
589
|
+
if (widthChanged || heightChanged) {
|
|
590
|
+
lastWidth = width;
|
|
591
|
+
lastHeight = height;
|
|
592
|
+
resizeTimeout = setTimeout(() => {
|
|
593
|
+
mapRef.current?.resize();
|
|
594
|
+
}, 250);
|
|
595
|
+
}
|
|
596
|
+
};
|
|
597
|
+
const parentElement = mapRef.current.getContainer().parentElement;
|
|
598
|
+
if (parentElement) {
|
|
599
|
+
const resizeObserver = new ResizeObserver(handleResize);
|
|
600
|
+
resizeObserver.observe(parentElement);
|
|
601
|
+
return () => {
|
|
602
|
+
clearTimeout(resizeTimeout);
|
|
603
|
+
resizeObserver.disconnect();
|
|
604
|
+
};
|
|
605
|
+
}
|
|
606
|
+
}, [isInIframe]);
|
|
569
607
|
return /* @__PURE__ */ jsx(
|
|
570
608
|
"div",
|
|
571
609
|
{
|
|
572
610
|
className: joinClassNames("relative w-full h-full", className),
|
|
573
|
-
style: {
|
|
611
|
+
style: {
|
|
612
|
+
width: "100%",
|
|
613
|
+
height: "100%",
|
|
614
|
+
// Prevent content from pushing container size in iframes
|
|
615
|
+
...isInIframe && { overflow: "hidden", position: "relative" },
|
|
616
|
+
...style
|
|
617
|
+
},
|
|
574
618
|
children: /* @__PURE__ */ jsxs(
|
|
575
619
|
Map$1,
|
|
576
620
|
{
|
|
@@ -582,7 +626,7 @@ function MapLibre({
|
|
|
582
626
|
onMoveEnd: handleMoveEnd,
|
|
583
627
|
onClick: handleMapClick,
|
|
584
628
|
attributionControl: false,
|
|
585
|
-
trackResize:
|
|
629
|
+
trackResize: !isInIframe,
|
|
586
630
|
dragRotate: false,
|
|
587
631
|
touchZoomRotate: false,
|
|
588
632
|
children: [
|
|
@@ -1169,7 +1213,7 @@ function GeoMap({
|
|
|
1169
1213
|
"div",
|
|
1170
1214
|
{
|
|
1171
1215
|
className: cn(
|
|
1172
|
-
"relative w-
|
|
1216
|
+
"relative w-80 overflow-hidden rounded-xl border border-border bg-card text-card-foreground shadow-2xl",
|
|
1173
1217
|
panelClassName
|
|
1174
1218
|
),
|
|
1175
1219
|
children: [
|
|
@@ -1243,7 +1287,7 @@ function GeoMap({
|
|
|
1243
1287
|
"div",
|
|
1244
1288
|
{
|
|
1245
1289
|
className: cn(
|
|
1246
|
-
"relative w-
|
|
1290
|
+
"relative w-80 overflow-hidden rounded-xl border border-border bg-card text-card-foreground p-4 shadow-2xl",
|
|
1247
1291
|
panelClassName
|
|
1248
1292
|
),
|
|
1249
1293
|
children: [
|
|
@@ -1281,6 +1325,14 @@ function GeoMap({
|
|
|
1281
1325
|
}
|
|
1282
1326
|
return null;
|
|
1283
1327
|
};
|
|
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
|
+
}, []);
|
|
1284
1336
|
return /* @__PURE__ */ jsxs(
|
|
1285
1337
|
"div",
|
|
1286
1338
|
{
|
|
@@ -1288,33 +1340,51 @@ function GeoMap({
|
|
|
1288
1340
|
"relative overflow-hidden rounded-2xl border border-border bg-background",
|
|
1289
1341
|
className
|
|
1290
1342
|
),
|
|
1343
|
+
style: {
|
|
1344
|
+
// Use CSS containment to prevent layout shifts in iframes
|
|
1345
|
+
...isInIframe && { contain: "layout size" }
|
|
1346
|
+
},
|
|
1291
1347
|
children: [
|
|
1292
|
-
/* @__PURE__ */ jsx(
|
|
1293
|
-
|
|
1348
|
+
/* @__PURE__ */ jsx(
|
|
1349
|
+
"div",
|
|
1294
1350
|
{
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
onMapClick?.(coord);
|
|
1304
|
-
if (clearSelectionOnMapClick) {
|
|
1305
|
-
clearSelection();
|
|
1306
|
-
}
|
|
1351
|
+
className: cn(
|
|
1352
|
+
"w-full",
|
|
1353
|
+
// Default height, can be overridden by mapWrapperClassName
|
|
1354
|
+
mapWrapperClassName || "h-[520px]"
|
|
1355
|
+
),
|
|
1356
|
+
style: {
|
|
1357
|
+
// Ensure proper height containment in iframes
|
|
1358
|
+
...isInIframe && !mapWrapperClassName && { height: "520px", minHeight: "420px" }
|
|
1307
1359
|
},
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1360
|
+
children: /* @__PURE__ */ jsx(
|
|
1361
|
+
MapLibre,
|
|
1362
|
+
{
|
|
1363
|
+
stadiaApiKey,
|
|
1364
|
+
mapStyle,
|
|
1365
|
+
styleUrl,
|
|
1366
|
+
mapLibreCssHref,
|
|
1367
|
+
viewState: resolvedViewState,
|
|
1368
|
+
onViewStateChange: applyViewState,
|
|
1369
|
+
markers: mapMarkers,
|
|
1370
|
+
onClick: (coord) => {
|
|
1371
|
+
onMapClick?.(coord);
|
|
1372
|
+
if (clearSelectionOnMapClick) {
|
|
1373
|
+
clearSelection();
|
|
1374
|
+
}
|
|
1375
|
+
},
|
|
1376
|
+
onMarkerDrag,
|
|
1377
|
+
showNavigationControl,
|
|
1378
|
+
showGeolocateControl,
|
|
1379
|
+
navigationControlPosition,
|
|
1380
|
+
geolocateControlPosition,
|
|
1381
|
+
flyToOptions,
|
|
1382
|
+
className: cn("h-full w-full", mapClassName),
|
|
1383
|
+
children: mapChildren
|
|
1384
|
+
}
|
|
1385
|
+
)
|
|
1316
1386
|
}
|
|
1317
|
-
)
|
|
1387
|
+
),
|
|
1318
1388
|
selection.type !== "none" ? /* @__PURE__ */ jsx(
|
|
1319
1389
|
"div",
|
|
1320
1390
|
{
|