@amplifyup/sdk 0.1.10 → 0.1.11
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/AmplifyRenderer.js +160 -3
- package/dist/AmplifyRenderer.js.map +1 -1
- package/dist/AmplifyRenderer.mjs +160 -3
- package/dist/AmplifyRenderer.mjs.map +1 -1
- package/dist/index.d.mts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +160 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +160 -3
- package/dist/index.mjs.map +1 -1
- package/dist/react.js +161 -4
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +161 -4
- package/dist/react.mjs.map +1 -1
- package/package.json +1 -1
package/dist/AmplifyRenderer.js
CHANGED
|
@@ -325,6 +325,7 @@ var AmplifyUpSDK = class {
|
|
|
325
325
|
this.componentRegistry = [];
|
|
326
326
|
this.messageListener = null;
|
|
327
327
|
this.mutationObserver = null;
|
|
328
|
+
this.composerDragHandlers = null;
|
|
328
329
|
this.isVisualEditorMode = false;
|
|
329
330
|
this.eventSelectionMode = false;
|
|
330
331
|
this.eventSelectionClickHandler = null;
|
|
@@ -1288,6 +1289,111 @@ Available Console Commands:
|
|
|
1288
1289
|
this.applyComponentHighlights(highlightComponents, showZones);
|
|
1289
1290
|
this.setupMutationObserver();
|
|
1290
1291
|
}
|
|
1292
|
+
if (showZones) {
|
|
1293
|
+
this.setupComposerDragDrop();
|
|
1294
|
+
}
|
|
1295
|
+
}
|
|
1296
|
+
/** Document-level drag/drop for cross-iframe drags from Composer sidebar. */
|
|
1297
|
+
setupComposerDragDrop() {
|
|
1298
|
+
if (typeof document === "undefined") return;
|
|
1299
|
+
this.teardownComposerDragDrop();
|
|
1300
|
+
const slotSelector = "[data-slot-id], [data-amplifyup-slot]";
|
|
1301
|
+
const clearDragOverState = () => {
|
|
1302
|
+
document.querySelectorAll(`${slotSelector}.amplifyup-drag-over-slot`).forEach((el) => {
|
|
1303
|
+
el.classList.remove("amplifyup-drag-over-slot");
|
|
1304
|
+
});
|
|
1305
|
+
document.body.classList.remove("amplifyup-drag-no-drop");
|
|
1306
|
+
};
|
|
1307
|
+
const dragenter = (e) => {
|
|
1308
|
+
e.preventDefault();
|
|
1309
|
+
if (e.dataTransfer?.types?.length) {
|
|
1310
|
+
document.body.classList.add("amplifyup-drag-no-drop");
|
|
1311
|
+
}
|
|
1312
|
+
};
|
|
1313
|
+
const dragover = (e) => {
|
|
1314
|
+
e.preventDefault();
|
|
1315
|
+
const target = e.target;
|
|
1316
|
+
const slot = target?.closest?.(slotSelector);
|
|
1317
|
+
if (e.dataTransfer) {
|
|
1318
|
+
e.dataTransfer.dropEffect = slot ? "copy" : "none";
|
|
1319
|
+
}
|
|
1320
|
+
document.querySelectorAll(`${slotSelector}.amplifyup-drag-over-slot`).forEach((el) => {
|
|
1321
|
+
el.classList.remove("amplifyup-drag-over-slot");
|
|
1322
|
+
});
|
|
1323
|
+
if (slot) {
|
|
1324
|
+
slot.classList.add("amplifyup-drag-over-slot");
|
|
1325
|
+
document.body.classList.remove("amplifyup-drag-no-drop");
|
|
1326
|
+
} else {
|
|
1327
|
+
document.body.classList.add("amplifyup-drag-no-drop");
|
|
1328
|
+
}
|
|
1329
|
+
};
|
|
1330
|
+
const dragleave = (e) => {
|
|
1331
|
+
const related = e.relatedTarget;
|
|
1332
|
+
if (!related || !document.body.contains(related)) {
|
|
1333
|
+
clearDragOverState();
|
|
1334
|
+
}
|
|
1335
|
+
};
|
|
1336
|
+
const drop = (e) => {
|
|
1337
|
+
e.preventDefault();
|
|
1338
|
+
const target = e.target;
|
|
1339
|
+
const slot = target?.closest?.(slotSelector);
|
|
1340
|
+
clearDragOverState();
|
|
1341
|
+
if (!slot || !this.isVisualEditorMode) return;
|
|
1342
|
+
const slotName = slot.getAttribute("data-amplifyup-slot") || slot.getAttribute("data-slot-id");
|
|
1343
|
+
const isEmpty = slot.getAttribute("data-slot-empty") === "true";
|
|
1344
|
+
const win = window;
|
|
1345
|
+
if (slotName && win.parent && win.parent !== win) {
|
|
1346
|
+
win.parent.postMessage({
|
|
1347
|
+
type: "DROP_ON_SLOT",
|
|
1348
|
+
slotName,
|
|
1349
|
+
slotElement: { path: slot.getAttribute("data-slot-path"), isEmpty }
|
|
1350
|
+
}, "*");
|
|
1351
|
+
}
|
|
1352
|
+
};
|
|
1353
|
+
const mouseover = (e) => {
|
|
1354
|
+
if (!this.showZonesEnabled) return;
|
|
1355
|
+
const target = e.target;
|
|
1356
|
+
const slot = target?.closest?.(slotSelector);
|
|
1357
|
+
if (!slot) return;
|
|
1358
|
+
document.querySelectorAll(`${slotSelector}.amplifyup-slot-hover`).forEach((el) => {
|
|
1359
|
+
el.classList.remove("amplifyup-slot-hover");
|
|
1360
|
+
});
|
|
1361
|
+
slot.classList.add("amplifyup-slot-hover");
|
|
1362
|
+
};
|
|
1363
|
+
const mouseout = (e) => {
|
|
1364
|
+
if (!this.showZonesEnabled) return;
|
|
1365
|
+
const related = e.relatedTarget;
|
|
1366
|
+
if (!related?.closest?.(slotSelector)) {
|
|
1367
|
+
document.querySelectorAll(`${slotSelector}.amplifyup-slot-hover`).forEach((el) => {
|
|
1368
|
+
el.classList.remove("amplifyup-slot-hover");
|
|
1369
|
+
});
|
|
1370
|
+
}
|
|
1371
|
+
};
|
|
1372
|
+
document.addEventListener("dragenter", dragenter, false);
|
|
1373
|
+
document.addEventListener("dragover", dragover, false);
|
|
1374
|
+
document.addEventListener("dragleave", dragleave, false);
|
|
1375
|
+
document.addEventListener("drop", drop, false);
|
|
1376
|
+
document.addEventListener("mouseover", mouseover, true);
|
|
1377
|
+
document.addEventListener("mouseout", mouseout, true);
|
|
1378
|
+
this.composerDragHandlers = { dragenter, dragover, dragleave, drop, mouseover, mouseout };
|
|
1379
|
+
}
|
|
1380
|
+
teardownComposerDragDrop() {
|
|
1381
|
+
if (!this.composerDragHandlers || typeof document === "undefined") return;
|
|
1382
|
+
const h = this.composerDragHandlers;
|
|
1383
|
+
document.removeEventListener("dragenter", h.dragenter, false);
|
|
1384
|
+
document.removeEventListener("dragover", h.dragover, false);
|
|
1385
|
+
document.removeEventListener("dragleave", h.dragleave, false);
|
|
1386
|
+
document.removeEventListener("drop", h.drop, false);
|
|
1387
|
+
document.removeEventListener("mouseover", h.mouseover, true);
|
|
1388
|
+
document.removeEventListener("mouseout", h.mouseout, true);
|
|
1389
|
+
this.composerDragHandlers = null;
|
|
1390
|
+
document.body.classList.remove("amplifyup-drag-no-drop");
|
|
1391
|
+
document.querySelectorAll("[data-slot-id].amplifyup-drag-over-slot, [data-amplifyup-slot].amplifyup-drag-over-slot").forEach((el) => {
|
|
1392
|
+
el.classList.remove("amplifyup-drag-over-slot");
|
|
1393
|
+
});
|
|
1394
|
+
document.querySelectorAll("[data-slot-id].amplifyup-slot-hover, [data-amplifyup-slot].amplifyup-slot-hover").forEach((el) => {
|
|
1395
|
+
el.classList.remove("amplifyup-slot-hover");
|
|
1396
|
+
});
|
|
1291
1397
|
}
|
|
1292
1398
|
/** Visual outlines for Composer (direct iframe path — no preview-frame proxy). */
|
|
1293
1399
|
injectComposerHighlightStyles(highlightComponents, showZones) {
|
|
@@ -1314,19 +1420,64 @@ Available Console Commands:
|
|
|
1314
1420
|
" outline: 2px dotted rgba(34, 197, 94, 0.75) !important;",
|
|
1315
1421
|
" outline-offset: 4px !important;",
|
|
1316
1422
|
" min-height: 3rem !important;",
|
|
1423
|
+
" padding: 20px !important;",
|
|
1317
1424
|
" box-sizing: border-box !important;",
|
|
1318
1425
|
" cursor: pointer !important;",
|
|
1426
|
+
" position: relative !important;",
|
|
1319
1427
|
"}",
|
|
1320
1428
|
'[data-slot-id="main"], [data-amplifyup-slot="main"] {',
|
|
1321
1429
|
" min-height: 50vh !important;",
|
|
1322
1430
|
"}",
|
|
1431
|
+
'[data-slot-id="main"][data-slot-empty="true"]::before,',
|
|
1432
|
+
'[data-amplifyup-slot="main"][data-slot-empty="true"]::before {',
|
|
1433
|
+
' content: "Drop components here" !important;',
|
|
1434
|
+
" position: absolute !important;",
|
|
1435
|
+
" top: 50% !important; left: 50% !important;",
|
|
1436
|
+
" transform: translate(-50%, -50%) !important;",
|
|
1437
|
+
" font-size: 14px !important; font-weight: 500 !important;",
|
|
1438
|
+
" color: rgba(34, 197, 94, 0.65) !important;",
|
|
1439
|
+
" pointer-events: none !important;",
|
|
1440
|
+
" white-space: nowrap !important;",
|
|
1441
|
+
"}",
|
|
1323
1442
|
"[data-slot-id].amplifyup-slot-hover, [data-amplifyup-slot].amplifyup-slot-hover {",
|
|
1324
1443
|
" outline-color: rgba(34, 197, 94, 1) !important;",
|
|
1325
1444
|
" background: rgba(34, 197, 94, 0.06) !important;",
|
|
1326
1445
|
"}",
|
|
1327
1446
|
"[data-slot-id].amplifyup-drag-over-slot, [data-amplifyup-slot].amplifyup-drag-over-slot {",
|
|
1328
1447
|
" outline: 2px solid rgba(34, 197, 94, 1) !important;",
|
|
1329
|
-
" background: rgba(34, 197, 94, 0.
|
|
1448
|
+
" background: rgba(34, 197, 94, 0.18) !important;",
|
|
1449
|
+
" position: relative !important;",
|
|
1450
|
+
"}",
|
|
1451
|
+
"[data-slot-id].amplifyup-drag-over-slot::after,",
|
|
1452
|
+
"[data-amplifyup-slot].amplifyup-drag-over-slot::after {",
|
|
1453
|
+
' content: "\\2713 Drop here" !important;',
|
|
1454
|
+
" position: absolute !important;",
|
|
1455
|
+
" top: 50% !important; left: 50% !important;",
|
|
1456
|
+
" transform: translate(-50%, -50%) !important;",
|
|
1457
|
+
" font-size: 14px !important; font-weight: 600 !important;",
|
|
1458
|
+
" color: rgb(22, 163, 74) !important;",
|
|
1459
|
+
" pointer-events: none !important;",
|
|
1460
|
+
" white-space: nowrap !important;",
|
|
1461
|
+
" z-index: 1 !important;",
|
|
1462
|
+
"}",
|
|
1463
|
+
"body.amplifyup-drag-no-drop { cursor: no-drop !important; }",
|
|
1464
|
+
"body.amplifyup-drag-no-drop::before {",
|
|
1465
|
+
' content: "" !important;',
|
|
1466
|
+
" position: fixed !important; top: 0 !important; left: 0 !important; right: 0 !important; bottom: 0 !important;",
|
|
1467
|
+
" background: rgba(239, 68, 68, 0.06) !important;",
|
|
1468
|
+
" pointer-events: none !important;",
|
|
1469
|
+
" z-index: 2147483646 !important;",
|
|
1470
|
+
"}",
|
|
1471
|
+
"body.amplifyup-drag-no-drop::after {",
|
|
1472
|
+
' content: "\\2717 Not a drop zone" !important;',
|
|
1473
|
+
" position: fixed !important; bottom: 12px !important; right: 12px !important;",
|
|
1474
|
+
" font-size: 12px !important; font-weight: 600 !important;",
|
|
1475
|
+
" color: rgb(185, 28, 28) !important;",
|
|
1476
|
+
" background: rgba(254, 226, 226, 0.95) !important;",
|
|
1477
|
+
" padding: 6px 10px !important; border-radius: 6px !important;",
|
|
1478
|
+
" pointer-events: none !important;",
|
|
1479
|
+
" z-index: 2147483647 !important;",
|
|
1480
|
+
" box-shadow: 0 1px 3px rgba(0,0,0,0.1) !important;",
|
|
1330
1481
|
"}"
|
|
1331
1482
|
);
|
|
1332
1483
|
}
|
|
@@ -1386,6 +1537,7 @@ Available Console Commands:
|
|
|
1386
1537
|
disableHighlighting() {
|
|
1387
1538
|
if (typeof document === "undefined") return;
|
|
1388
1539
|
this.highlightingEnabled = false;
|
|
1540
|
+
this.teardownComposerDragDrop();
|
|
1389
1541
|
if (this.mutationObserver) {
|
|
1390
1542
|
this.mutationObserver.disconnect();
|
|
1391
1543
|
this.mutationObserver = null;
|
|
@@ -1546,9 +1698,15 @@ Available Console Commands:
|
|
|
1546
1698
|
e.preventDefault();
|
|
1547
1699
|
e.stopPropagation();
|
|
1548
1700
|
htmlEl.classList.remove("amplifyup-drag-over-slot");
|
|
1701
|
+
if (!win.parent || win.parent === win) return;
|
|
1702
|
+
win.parent.postMessage({
|
|
1703
|
+
type: "DROP_ON_SLOT",
|
|
1704
|
+
slotName,
|
|
1705
|
+
slotElement: { path: htmlEl.getAttribute("data-slot-path"), isEmpty }
|
|
1706
|
+
}, "*");
|
|
1549
1707
|
try {
|
|
1550
1708
|
const data = JSON.parse(e.dataTransfer.getData("application/json"));
|
|
1551
|
-
if (data.type === "component"
|
|
1709
|
+
if (data.type === "component") {
|
|
1552
1710
|
win.parent.postMessage({
|
|
1553
1711
|
type: "COMPONENT_DROPPED",
|
|
1554
1712
|
componentId: data.componentId,
|
|
@@ -1556,7 +1714,6 @@ Available Console Commands:
|
|
|
1556
1714
|
slotName,
|
|
1557
1715
|
slotElement: { path: htmlEl.getAttribute("data-slot-path"), isEmpty }
|
|
1558
1716
|
}, "*");
|
|
1559
|
-
win.parent.postMessage({ type: "DROP_ON_SLOT", slotName }, "*");
|
|
1560
1717
|
}
|
|
1561
1718
|
} catch (_err) {
|
|
1562
1719
|
}
|