@amplifyup/sdk 0.1.12 → 0.1.13

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/index.d.mts CHANGED
@@ -38,6 +38,15 @@ declare class AmplifyUpSDK {
38
38
  private messageListener;
39
39
  private mutationObserver;
40
40
  private composerDragHandlers;
41
+ /** Last slot highlighted during Composer drag — avoid clear/re-add flicker. */
42
+ private lastComposerDragSlot;
43
+ /** Consecutive miss frames before clearing highlight (anti-jitter). */
44
+ private composerDragMissFrames;
45
+ /**
46
+ * Parent overlay is driving drag via postMessage. Native iframe dragleave must
47
+ * not clear highlight — overlay takeover fires a spurious document dragleave.
48
+ */
49
+ private composerOverlayDragActive;
41
50
  private isVisualEditorMode;
42
51
  private eventSelectionMode;
43
52
  private eventSelectionClickHandler;
@@ -218,11 +227,19 @@ declare class AmplifyUpSDK {
218
227
  private generateSelectorForElement;
219
228
  /** Clear drag-over highlight state (Composer overlay path or native drag end). */
220
229
  private clearComposerDragHighlight;
230
+ /** Re-apply drag-over class only if missing (avoids classList churn / flicker). */
231
+ private ensureDragOverClass;
221
232
  /**
222
- * Hit-test a slot at iframe-local coordinates (Composer overlay drag path).
223
- * Required for cross-origin drags: the browser blocks native drop inside the iframe.
233
+ * Composer drag targets the innermost (most specific) slot under the cursor.
234
+ * e.g. FullWidthGrid's main wins over a page-level main that wraps it.
224
235
  */
236
+ private resolveSlotAtPoint;
237
+ /** Parent layout node that owns this slot (null for page-level code main). */
238
+ private parentComponentForSlot;
239
+ private pointInRect;
240
+ private setComposerDragHighlight;
225
241
  private handleComposerDragAtPoint;
242
+ private postDropOnSlot;
226
243
  private handleComposerDropAtPoint;
227
244
  /**
228
245
  * Enable component highlighting
package/dist/index.d.ts CHANGED
@@ -38,6 +38,15 @@ declare class AmplifyUpSDK {
38
38
  private messageListener;
39
39
  private mutationObserver;
40
40
  private composerDragHandlers;
41
+ /** Last slot highlighted during Composer drag — avoid clear/re-add flicker. */
42
+ private lastComposerDragSlot;
43
+ /** Consecutive miss frames before clearing highlight (anti-jitter). */
44
+ private composerDragMissFrames;
45
+ /**
46
+ * Parent overlay is driving drag via postMessage. Native iframe dragleave must
47
+ * not clear highlight — overlay takeover fires a spurious document dragleave.
48
+ */
49
+ private composerOverlayDragActive;
41
50
  private isVisualEditorMode;
42
51
  private eventSelectionMode;
43
52
  private eventSelectionClickHandler;
@@ -218,11 +227,19 @@ declare class AmplifyUpSDK {
218
227
  private generateSelectorForElement;
219
228
  /** Clear drag-over highlight state (Composer overlay path or native drag end). */
220
229
  private clearComposerDragHighlight;
230
+ /** Re-apply drag-over class only if missing (avoids classList churn / flicker). */
231
+ private ensureDragOverClass;
221
232
  /**
222
- * Hit-test a slot at iframe-local coordinates (Composer overlay drag path).
223
- * Required for cross-origin drags: the browser blocks native drop inside the iframe.
233
+ * Composer drag targets the innermost (most specific) slot under the cursor.
234
+ * e.g. FullWidthGrid's main wins over a page-level main that wraps it.
224
235
  */
236
+ private resolveSlotAtPoint;
237
+ /** Parent layout node that owns this slot (null for page-level code main). */
238
+ private parentComponentForSlot;
239
+ private pointInRect;
240
+ private setComposerDragHighlight;
225
241
  private handleComposerDragAtPoint;
242
+ private postDropOnSlot;
226
243
  private handleComposerDropAtPoint;
227
244
  /**
228
245
  * Enable component highlighting
package/dist/index.js CHANGED
@@ -344,6 +344,15 @@ var AmplifyUpSDK = class {
344
344
  this.messageListener = null;
345
345
  this.mutationObserver = null;
346
346
  this.composerDragHandlers = null;
347
+ /** Last slot highlighted during Composer drag — avoid clear/re-add flicker. */
348
+ this.lastComposerDragSlot = null;
349
+ /** Consecutive miss frames before clearing highlight (anti-jitter). */
350
+ this.composerDragMissFrames = 0;
351
+ /**
352
+ * Parent overlay is driving drag via postMessage. Native iframe dragleave must
353
+ * not clear highlight — overlay takeover fires a spurious document dragleave.
354
+ */
355
+ this.composerOverlayDragActive = false;
347
356
  this.isVisualEditorMode = false;
348
357
  this.eventSelectionMode = false;
349
358
  this.eventSelectionClickHandler = null;
@@ -874,6 +883,12 @@ Available Console Commands:
874
883
  }
875
884
  throw new Error(`Failed to fetch page: ${response.statusText}`);
876
885
  }
886
+ const contentType = response.headers.get("content-type") || "";
887
+ if (!contentType.includes("application/json")) {
888
+ throw new Error(
889
+ `Layout provider returned non-JSON (${contentType || "unknown"}). Check Composer preview routing.`
890
+ );
891
+ }
877
892
  const data = await response.json();
878
893
  const pageConfig = data.page;
879
894
  if (pageConfig?.eventTracking) {
@@ -1158,6 +1173,13 @@ Available Console Commands:
1158
1173
  }
1159
1174
  return;
1160
1175
  }
1176
+ if (event.data?.type === "COMPOSER_DRAG_START") {
1177
+ this.composerOverlayDragActive = true;
1178
+ if (typeof document !== "undefined") {
1179
+ document.body.classList.add("amplifyup-composer-dragging");
1180
+ }
1181
+ return;
1182
+ }
1161
1183
  if (event.data?.type === "COMPOSER_DRAG_AT_POINT") {
1162
1184
  const { x, y } = event.data;
1163
1185
  if (typeof x === "number" && typeof y === "number") {
@@ -1173,36 +1195,72 @@ Available Console Commands:
1173
1195
  return;
1174
1196
  }
1175
1197
  if (event.data?.type === "COMPOSER_DRAG_END") {
1198
+ this.composerOverlayDragActive = false;
1176
1199
  this.clearComposerDragHighlight();
1177
1200
  return;
1178
1201
  }
1179
1202
  if (event.data?.type === "GET_ELEMENT_POSITION") {
1180
- const { componentId, slotName } = event.data;
1181
- const selector = slotName ? `[data-amplifyup-slot="${slotName}"], [data-slot-id="${slotName}"]` : `[data-amplifyup-component="${componentId}"], [data-component-id="${componentId}"]`;
1182
- console.log("[AmplifyUp SDK] Finding element position:", { selector, componentId, slotName });
1183
- const element = document.querySelector(selector);
1203
+ const { componentId, slotName, nodeId, isPageSlot } = event.data;
1204
+ let element = null;
1205
+ if (isPageSlot || slotName === "main" && !nodeId && !componentId) {
1206
+ element = document.querySelector(
1207
+ '[data-slot-source="page"]'
1208
+ );
1209
+ }
1210
+ if (!element && nodeId && slotName) {
1211
+ element = document.querySelector(
1212
+ `[data-parent-node-id="${nodeId}"][data-slot-id="${slotName}"], [data-parent-node-id="${nodeId}"][data-amplifyup-slot="${slotName}"]`
1213
+ );
1214
+ }
1215
+ if (!element && nodeId && !slotName) {
1216
+ element = document.querySelector(
1217
+ `[data-node-id="${nodeId}"]`
1218
+ );
1219
+ }
1220
+ if (!element && slotName) {
1221
+ element = document.querySelector(
1222
+ `[data-amplifyup-slot="${slotName}"], [data-slot-id="${slotName}"]`
1223
+ );
1224
+ }
1225
+ if (!element && componentId) {
1226
+ element = document.querySelector(
1227
+ `[data-amplifyup-component="${componentId}"], [data-component-id="${componentId}"]`
1228
+ );
1229
+ }
1230
+ console.log("[AmplifyUp SDK] Finding element position:", {
1231
+ componentId,
1232
+ slotName,
1233
+ nodeId,
1234
+ isPageSlot,
1235
+ found: !!element
1236
+ });
1184
1237
  if (element) {
1185
1238
  const rect = element.getBoundingClientRect();
1186
1239
  const position = {
1187
1240
  x: rect.left + rect.width / 2,
1188
- // Center of element
1189
1241
  y: rect.top - 50,
1190
- // Position above element
1191
1242
  width: rect.width,
1192
1243
  height: rect.height
1193
1244
  };
1194
- console.log("[AmplifyUp SDK] Element position calculated:", { rect, position });
1245
+ const bounds = {
1246
+ top: rect.top,
1247
+ left: rect.left,
1248
+ width: rect.width,
1249
+ height: rect.height
1250
+ };
1195
1251
  if (window.parent && window.parent !== window) {
1196
1252
  window.parent.postMessage({
1197
1253
  type: "ELEMENT_POSITION",
1198
- componentId,
1199
- slotName,
1200
- position
1254
+ componentId: componentId || null,
1255
+ slotName: slotName || null,
1256
+ nodeId: nodeId || null,
1257
+ isPageSlot: !!isPageSlot,
1258
+ position,
1259
+ bounds
1201
1260
  }, "*");
1202
- console.log("[AmplifyUp SDK] Sent ELEMENT_POSITION message");
1203
1261
  }
1204
1262
  } else {
1205
- console.warn("[AmplifyUp SDK] Element not found for selector:", selector);
1263
+ console.warn("[AmplifyUp SDK] Element not found for position request");
1206
1264
  }
1207
1265
  return;
1208
1266
  }
@@ -1317,37 +1375,148 @@ Available Console Commands:
1317
1375
  el.classList.remove("amplifyup-drag-over-slot");
1318
1376
  });
1319
1377
  document.body.classList.remove("amplifyup-drag-no-drop");
1378
+ document.body.classList.remove("amplifyup-composer-dragging");
1379
+ this.lastComposerDragSlot = null;
1380
+ this.composerDragMissFrames = 0;
1381
+ }
1382
+ /** Re-apply drag-over class only if missing (avoids classList churn / flicker). */
1383
+ ensureDragOverClass(slot) {
1384
+ if (!slot.classList.contains("amplifyup-drag-over-slot")) {
1385
+ slot.classList.add("amplifyup-drag-over-slot");
1386
+ }
1387
+ if (document.body.classList.contains("amplifyup-drag-no-drop")) {
1388
+ document.body.classList.remove("amplifyup-drag-no-drop");
1389
+ }
1320
1390
  }
1321
1391
  /**
1322
- * Hit-test a slot at iframe-local coordinates (Composer overlay drag path).
1323
- * Required for cross-origin drags: the browser blocks native drop inside the iframe.
1392
+ * Composer drag targets the innermost (most specific) slot under the cursor.
1393
+ * e.g. FullWidthGrid's main wins over a page-level main that wraps it.
1324
1394
  */
1325
- handleComposerDragAtPoint(x, y) {
1326
- if (typeof document === "undefined") return;
1395
+ resolveSlotAtPoint(x, y) {
1396
+ if (typeof document === "undefined") return null;
1327
1397
  const slotSelector = "[data-slot-id], [data-amplifyup-slot]";
1328
- this.clearComposerDragHighlight();
1329
- const el = document.elementFromPoint(x, y)?.closest?.(slotSelector);
1330
- if (el) {
1331
- el.classList.add("amplifyup-drag-over-slot");
1332
- } else {
1398
+ const containing = [];
1399
+ document.querySelectorAll(slotSelector).forEach((node) => {
1400
+ const el = node;
1401
+ const r = el.getBoundingClientRect();
1402
+ if (x >= r.left && x <= r.right && y >= r.top && y <= r.bottom) {
1403
+ containing.push(el);
1404
+ }
1405
+ });
1406
+ if (containing.length === 0) return null;
1407
+ const innermost = containing.filter(
1408
+ (el) => !containing.some((other) => other !== el && el.contains(other))
1409
+ );
1410
+ if (innermost.length === 1) return innermost[0];
1411
+ let best = innermost[0];
1412
+ let bestArea = Infinity;
1413
+ for (const el of innermost) {
1414
+ const r = el.getBoundingClientRect();
1415
+ const area = Math.max(1, r.width) * Math.max(1, r.height);
1416
+ if (area < bestArea) {
1417
+ bestArea = area;
1418
+ best = el;
1419
+ }
1420
+ }
1421
+ return best;
1422
+ }
1423
+ /** Parent layout node that owns this slot (null for page-level code main). */
1424
+ parentComponentForSlot(slotEl) {
1425
+ let componentId = slotEl.getAttribute("data-parent-component-id");
1426
+ let nodeId = slotEl.getAttribute("data-parent-node-id");
1427
+ let el = slotEl.parentElement;
1428
+ while (el && (!nodeId || !componentId)) {
1429
+ if (!nodeId && el.hasAttribute("data-node-id")) {
1430
+ nodeId = el.getAttribute("data-node-id");
1431
+ }
1432
+ if (!componentId) {
1433
+ componentId = el.getAttribute("data-amplifyup-component") || el.getAttribute("data-component-id");
1434
+ }
1435
+ if (nodeId) break;
1436
+ el = el.parentElement;
1437
+ }
1438
+ return { componentId, nodeId };
1439
+ }
1440
+ pointInRect(x, y, el, pad = 8) {
1441
+ const r = el.getBoundingClientRect();
1442
+ return x >= r.left - pad && x <= r.right + pad && y >= r.top - pad && y <= r.bottom + pad;
1443
+ }
1444
+ setComposerDragHighlight(slot, x, y) {
1445
+ if (slot && slot === this.lastComposerDragSlot) {
1446
+ this.composerDragMissFrames = 0;
1447
+ this.ensureDragOverClass(slot);
1448
+ return;
1449
+ }
1450
+ if (slot && this.lastComposerDragSlot && this.lastComposerDragSlot.contains(slot) && slot !== this.lastComposerDragSlot) {
1451
+ this.composerDragMissFrames = 0;
1452
+ this.lastComposerDragSlot.classList.remove("amplifyup-drag-over-slot");
1453
+ this.lastComposerDragSlot = slot;
1454
+ this.ensureDragOverClass(slot);
1455
+ return;
1456
+ }
1457
+ if (this.lastComposerDragSlot && typeof x === "number" && typeof y === "number" && this.pointInRect(x, y, this.lastComposerDragSlot)) {
1458
+ if (!slot || slot.contains(this.lastComposerDragSlot) || slot === this.lastComposerDragSlot) {
1459
+ this.composerDragMissFrames = 0;
1460
+ this.ensureDragOverClass(this.lastComposerDragSlot);
1461
+ return;
1462
+ }
1463
+ }
1464
+ if (slot) {
1465
+ this.composerDragMissFrames = 0;
1466
+ if (this.lastComposerDragSlot && this.lastComposerDragSlot !== slot) {
1467
+ this.lastComposerDragSlot.classList.remove("amplifyup-drag-over-slot");
1468
+ }
1469
+ this.lastComposerDragSlot = slot;
1470
+ this.ensureDragOverClass(slot);
1471
+ return;
1472
+ }
1473
+ this.composerDragMissFrames += 1;
1474
+ if (this.lastComposerDragSlot && this.composerDragMissFrames < 8) {
1475
+ this.ensureDragOverClass(this.lastComposerDragSlot);
1476
+ return;
1477
+ }
1478
+ if (this.lastComposerDragSlot) {
1479
+ this.lastComposerDragSlot.classList.remove("amplifyup-drag-over-slot");
1480
+ this.lastComposerDragSlot = null;
1481
+ }
1482
+ if (!document.body.classList.contains("amplifyup-drag-no-drop")) {
1333
1483
  document.body.classList.add("amplifyup-drag-no-drop");
1334
1484
  }
1335
1485
  }
1486
+ handleComposerDragAtPoint(x, y) {
1487
+ this.composerOverlayDragActive = true;
1488
+ if (!document.body.classList.contains("amplifyup-composer-dragging")) {
1489
+ document.body.classList.add("amplifyup-composer-dragging");
1490
+ }
1491
+ this.setComposerDragHighlight(this.resolveSlotAtPoint(x, y), x, y);
1492
+ }
1493
+ postDropOnSlot(slotEl) {
1494
+ const win = window;
1495
+ if (!win.parent || win.parent === win) return;
1496
+ const slotName = slotEl.getAttribute("data-amplifyup-slot") || slotEl.getAttribute("data-slot-id");
1497
+ if (!slotName) return;
1498
+ const { componentId, nodeId } = this.parentComponentForSlot(slotEl);
1499
+ const isEmpty = slotEl.getAttribute("data-slot-empty") === "true";
1500
+ win.parent.postMessage(
1501
+ {
1502
+ type: "DROP_ON_SLOT",
1503
+ slotName,
1504
+ slotElement: {
1505
+ path: slotEl.getAttribute("data-slot-path"),
1506
+ isEmpty,
1507
+ parentComponentId: componentId,
1508
+ parentNodeId: nodeId
1509
+ }
1510
+ },
1511
+ "*"
1512
+ );
1513
+ }
1336
1514
  handleComposerDropAtPoint(x, y) {
1337
1515
  if (typeof document === "undefined") return;
1338
- const win = window;
1339
- const slotSelector = "[data-slot-id], [data-amplifyup-slot]";
1516
+ const htmlEl = this.resolveSlotAtPoint(x, y);
1340
1517
  this.clearComposerDragHighlight();
1341
- const htmlEl = document.elementFromPoint(x, y)?.closest?.(slotSelector);
1342
- if (!htmlEl || !win.parent || win.parent === win) return;
1343
- const slotName = htmlEl.getAttribute("data-amplifyup-slot") || htmlEl.getAttribute("data-slot-id");
1344
- if (!slotName) return;
1345
- const isEmpty = htmlEl.getAttribute("data-slot-empty") === "true";
1346
- win.parent.postMessage({
1347
- type: "DROP_ON_SLOT",
1348
- slotName,
1349
- slotElement: { path: htmlEl.getAttribute("data-slot-path"), isEmpty }
1350
- }, "*");
1518
+ if (!htmlEl) return;
1519
+ this.postDropOnSlot(htmlEl);
1351
1520
  }
1352
1521
  /**
1353
1522
  * Enable component highlighting
@@ -1375,35 +1544,25 @@ Available Console Commands:
1375
1544
  this.teardownComposerDragDrop();
1376
1545
  const slotSelector = "[data-slot-id], [data-amplifyup-slot]";
1377
1546
  const clearDragOverState = () => {
1378
- document.querySelectorAll(`${slotSelector}.amplifyup-drag-over-slot`).forEach((el) => {
1379
- el.classList.remove("amplifyup-drag-over-slot");
1380
- });
1381
- document.body.classList.remove("amplifyup-drag-no-drop");
1547
+ this.clearComposerDragHighlight();
1382
1548
  };
1383
1549
  const dragenter = (e) => {
1384
1550
  e.preventDefault();
1385
- if (e.dataTransfer?.types?.length) {
1386
- document.body.classList.add("amplifyup-drag-no-drop");
1387
- }
1388
1551
  };
1389
1552
  const dragover = (e) => {
1390
1553
  e.preventDefault();
1391
- const target = e.target;
1392
- const slot = target?.closest?.(slotSelector);
1554
+ if (this.composerOverlayDragActive) {
1555
+ if (e.dataTransfer) e.dataTransfer.dropEffect = "copy";
1556
+ return;
1557
+ }
1558
+ const slot = this.resolveSlotAtPoint(e.clientX, e.clientY);
1393
1559
  if (e.dataTransfer) {
1394
1560
  e.dataTransfer.dropEffect = slot ? "copy" : "none";
1395
1561
  }
1396
- document.querySelectorAll(`${slotSelector}.amplifyup-drag-over-slot`).forEach((el) => {
1397
- el.classList.remove("amplifyup-drag-over-slot");
1398
- });
1399
- if (slot) {
1400
- slot.classList.add("amplifyup-drag-over-slot");
1401
- document.body.classList.remove("amplifyup-drag-no-drop");
1402
- } else {
1403
- document.body.classList.add("amplifyup-drag-no-drop");
1404
- }
1562
+ this.setComposerDragHighlight(slot, e.clientX, e.clientY);
1405
1563
  };
1406
1564
  const dragleave = (e) => {
1565
+ if (this.composerOverlayDragActive) return;
1407
1566
  const related = e.relatedTarget;
1408
1567
  if (!related || !document.body.contains(related)) {
1409
1568
  clearDragOverState();
@@ -1411,20 +1570,10 @@ Available Console Commands:
1411
1570
  };
1412
1571
  const drop = (e) => {
1413
1572
  e.preventDefault();
1414
- const target = e.target;
1415
- const slot = target?.closest?.(slotSelector);
1573
+ const slot = this.resolveSlotAtPoint(e.clientX, e.clientY);
1416
1574
  clearDragOverState();
1417
1575
  if (!slot || !this.isVisualEditorMode) return;
1418
- const slotName = slot.getAttribute("data-amplifyup-slot") || slot.getAttribute("data-slot-id");
1419
- const isEmpty = slot.getAttribute("data-slot-empty") === "true";
1420
- const win = window;
1421
- if (slotName && win.parent && win.parent !== win) {
1422
- win.parent.postMessage({
1423
- type: "DROP_ON_SLOT",
1424
- slotName,
1425
- slotElement: { path: slot.getAttribute("data-slot-path"), isEmpty }
1426
- }, "*");
1427
- }
1576
+ this.postDropOnSlot(slot);
1428
1577
  };
1429
1578
  const mouseover = (e) => {
1430
1579
  if (!this.showZonesEnabled) return;
@@ -1463,7 +1612,11 @@ Available Console Commands:
1463
1612
  document.removeEventListener("mouseover", h.mouseover, true);
1464
1613
  document.removeEventListener("mouseout", h.mouseout, true);
1465
1614
  this.composerDragHandlers = null;
1615
+ this.composerOverlayDragActive = false;
1616
+ this.lastComposerDragSlot = null;
1617
+ this.composerDragMissFrames = 0;
1466
1618
  document.body.classList.remove("amplifyup-drag-no-drop");
1619
+ document.body.classList.remove("amplifyup-composer-dragging");
1467
1620
  document.querySelectorAll("[data-slot-id].amplifyup-drag-over-slot, [data-amplifyup-slot].amplifyup-drag-over-slot").forEach((el) => {
1468
1621
  el.classList.remove("amplifyup-drag-over-slot");
1469
1622
  });
@@ -1504,21 +1657,32 @@ Available Console Commands:
1504
1657
  '[data-slot-id="main"], [data-amplifyup-slot="main"] {',
1505
1658
  " min-height: 50vh !important;",
1506
1659
  "}",
1507
- '[data-slot-id="main"][data-slot-empty="true"]::before,',
1508
- '[data-amplifyup-slot="main"][data-slot-empty="true"]::before {',
1509
- ' content: "Drop components here" !important;',
1510
- " position: absolute !important;",
1511
- " top: 50% !important; left: 50% !important;",
1512
- " transform: translate(-50%, -50%) !important;",
1513
- " font-size: 14px !important; font-weight: 500 !important;",
1514
- " color: rgba(34, 197, 94, 0.65) !important;",
1660
+ /* Single empty-state hint — Slot React label uses .amplifyup-slot-placeholder */
1661
+ ".amplifyup-slot-placeholder {",
1662
+ " display: flex !important;",
1663
+ " align-items: center !important;",
1664
+ " justify-content: center !important;",
1665
+ " min-height: inherit !important;",
1666
+ " color: rgba(34, 197, 94, 0.75) !important;",
1667
+ " font-size: 14px !important;",
1668
+ " font-weight: 500 !important;",
1515
1669
  " pointer-events: none !important;",
1516
- " white-space: nowrap !important;",
1670
+ " text-align: center !important;",
1517
1671
  "}",
1518
1672
  "[data-slot-id].amplifyup-slot-hover, [data-amplifyup-slot].amplifyup-slot-hover {",
1519
1673
  " outline-color: rgba(34, 197, 94, 1) !important;",
1520
1674
  " background: rgba(34, 197, 94, 0.06) !important;",
1521
1675
  "}",
1676
+ /* During any Composer drag, hide idle slot labels so they don't flash
1677
+ when the active drag-over class briefly changes */
1678
+ "body.amplifyup-composer-dragging .amplifyup-slot-placeholder {",
1679
+ " visibility: hidden !important;",
1680
+ " opacity: 0 !important;",
1681
+ "}",
1682
+ "body.amplifyup-composer-dragging [data-slot-id]::before,",
1683
+ "body.amplifyup-composer-dragging [data-amplifyup-slot]::before {",
1684
+ " content: none !important;",
1685
+ "}",
1522
1686
  "[data-slot-id].amplifyup-drag-over-slot, [data-amplifyup-slot].amplifyup-drag-over-slot {",
1523
1687
  " outline: 2px solid rgba(34, 197, 94, 1) !important;",
1524
1688
  " background: rgba(34, 197, 94, 0.18) !important;",
@@ -1534,7 +1698,7 @@ Available Console Commands:
1534
1698
  " color: rgb(22, 163, 74) !important;",
1535
1699
  " pointer-events: none !important;",
1536
1700
  " white-space: nowrap !important;",
1537
- " z-index: 1 !important;",
1701
+ " z-index: 2 !important;",
1538
1702
  "}",
1539
1703
  "body.amplifyup-drag-no-drop { cursor: no-drop !important; }",
1540
1704
  "body.amplifyup-drag-no-drop::before {",
@@ -1661,18 +1825,23 @@ Available Console Commands:
1661
1825
  sendSelectionMessage(element, hierarchy, isEmpty) {
1662
1826
  if (!this.isVisualEditorMode) return;
1663
1827
  const componentId = element.getAttribute("data-amplifyup-component") || element.getAttribute("data-component-id");
1664
- const slotName = element.getAttribute("data-amplifyup-slot") || element.getAttribute("data-slot-id");
1828
+ const slotName = componentId ? null : element.getAttribute("data-amplifyup-slot") || element.getAttribute("data-slot-id");
1665
1829
  const componentName = element.getAttribute("data-component-name");
1666
1830
  const hierarchyInfo = hierarchy.map((el, index) => {
1667
1831
  const elComponentId = el.getAttribute("data-amplifyup-component") || el.getAttribute("data-component-id");
1668
1832
  const elSlotName = el.getAttribute("data-amplifyup-slot") || el.getAttribute("data-slot-id");
1669
1833
  const elComponentName = el.getAttribute("data-component-name");
1834
+ const isSlot = !elComponentId && !!elSlotName;
1835
+ const isPageSlot = isSlot && el.getAttribute("data-slot-source") === "page";
1836
+ const nodeId = el.getAttribute("data-node-id") || (isSlot ? el.getAttribute("data-parent-node-id") : null);
1670
1837
  return {
1671
1838
  index,
1672
1839
  componentId: elComponentId,
1673
- componentName: elComponentName,
1674
- slotName: elSlotName,
1675
- isSlot: !!elSlotName
1840
+ componentName: isPageSlot ? "Page" : elComponentName,
1841
+ slotName: isSlot ? elSlotName : null,
1842
+ isSlot,
1843
+ isPageSlot,
1844
+ nodeId
1676
1845
  };
1677
1846
  });
1678
1847
  const rect = element.getBoundingClientRect ? element.getBoundingClientRect() : null;
@@ -1709,7 +1878,6 @@ Available Console Commands:
1709
1878
  return;
1710
1879
  }
1711
1880
  const doc = document;
1712
- const win = window;
1713
1881
  if (highlightComponents) {
1714
1882
  const componentElements = doc.querySelectorAll("[data-amplifyup-component], [data-component-id]");
1715
1883
  console.log("[AmplifyUp SDK] Found", componentElements.length, "components to highlight");
@@ -1770,52 +1938,8 @@ Available Console Commands:
1770
1938
  e.stopPropagation();
1771
1939
  this.sendSelectionMessage(htmlEl, hierarchy, isEmpty);
1772
1940
  };
1773
- const handleDrop = (e) => {
1774
- e.preventDefault();
1775
- e.stopPropagation();
1776
- htmlEl.classList.remove("amplifyup-drag-over-slot");
1777
- if (!win.parent || win.parent === win) return;
1778
- win.parent.postMessage({
1779
- type: "DROP_ON_SLOT",
1780
- slotName,
1781
- slotElement: { path: htmlEl.getAttribute("data-slot-path"), isEmpty }
1782
- }, "*");
1783
- try {
1784
- const data = JSON.parse(e.dataTransfer.getData("application/json"));
1785
- if (data.type === "component") {
1786
- win.parent.postMessage({
1787
- type: "COMPONENT_DROPPED",
1788
- componentId: data.componentId,
1789
- componentName: data.componentName,
1790
- slotName,
1791
- slotElement: { path: htmlEl.getAttribute("data-slot-path"), isEmpty }
1792
- }, "*");
1793
- }
1794
- } catch (_err) {
1795
- }
1796
- };
1797
- const handleDragOver = (e) => {
1798
- e.preventDefault();
1799
- e.stopPropagation();
1800
- e.dataTransfer.dropEffect = "copy";
1801
- htmlEl.classList.add("amplifyup-drag-over-slot");
1802
- };
1803
- const handleDragLeave = (e) => {
1804
- const related = e.relatedTarget;
1805
- if (!related || !htmlEl.contains(related)) {
1806
- htmlEl.classList.remove("amplifyup-drag-over-slot");
1807
- }
1808
- };
1809
1941
  htmlEl.addEventListener("click", handleClick);
1810
- htmlEl.addEventListener("dragover", handleDragOver);
1811
- htmlEl.addEventListener("dragleave", handleDragLeave);
1812
- htmlEl.addEventListener("drop", handleDrop);
1813
- htmlEl._amplifyupSlotHandlers = {
1814
- handleClick,
1815
- handleDragOver,
1816
- handleDragLeave,
1817
- handleDrop
1818
- };
1942
+ htmlEl._amplifyupSlotHandlers = { handleClick };
1819
1943
  });
1820
1944
  }
1821
1945
  }