@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/index.d.mts
CHANGED
|
@@ -37,6 +37,7 @@ declare class AmplifyUpSDK {
|
|
|
37
37
|
private componentRegistry;
|
|
38
38
|
private messageListener;
|
|
39
39
|
private mutationObserver;
|
|
40
|
+
private composerDragHandlers;
|
|
40
41
|
private isVisualEditorMode;
|
|
41
42
|
private eventSelectionMode;
|
|
42
43
|
private eventSelectionClickHandler;
|
|
@@ -219,6 +220,9 @@ declare class AmplifyUpSDK {
|
|
|
219
220
|
* Enable component highlighting
|
|
220
221
|
*/
|
|
221
222
|
private enableHighlighting;
|
|
223
|
+
/** Document-level drag/drop for cross-iframe drags from Composer sidebar. */
|
|
224
|
+
private setupComposerDragDrop;
|
|
225
|
+
private teardownComposerDragDrop;
|
|
222
226
|
/** Visual outlines for Composer (direct iframe path — no preview-frame proxy). */
|
|
223
227
|
private injectComposerHighlightStyles;
|
|
224
228
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -37,6 +37,7 @@ declare class AmplifyUpSDK {
|
|
|
37
37
|
private componentRegistry;
|
|
38
38
|
private messageListener;
|
|
39
39
|
private mutationObserver;
|
|
40
|
+
private composerDragHandlers;
|
|
40
41
|
private isVisualEditorMode;
|
|
41
42
|
private eventSelectionMode;
|
|
42
43
|
private eventSelectionClickHandler;
|
|
@@ -219,6 +220,9 @@ declare class AmplifyUpSDK {
|
|
|
219
220
|
* Enable component highlighting
|
|
220
221
|
*/
|
|
221
222
|
private enableHighlighting;
|
|
223
|
+
/** Document-level drag/drop for cross-iframe drags from Composer sidebar. */
|
|
224
|
+
private setupComposerDragDrop;
|
|
225
|
+
private teardownComposerDragDrop;
|
|
222
226
|
/** Visual outlines for Composer (direct iframe path — no preview-frame proxy). */
|
|
223
227
|
private injectComposerHighlightStyles;
|
|
224
228
|
/**
|
package/dist/index.js
CHANGED
|
@@ -343,6 +343,7 @@ var AmplifyUpSDK = class {
|
|
|
343
343
|
this.componentRegistry = [];
|
|
344
344
|
this.messageListener = null;
|
|
345
345
|
this.mutationObserver = null;
|
|
346
|
+
this.composerDragHandlers = null;
|
|
346
347
|
this.isVisualEditorMode = false;
|
|
347
348
|
this.eventSelectionMode = false;
|
|
348
349
|
this.eventSelectionClickHandler = null;
|
|
@@ -1306,6 +1307,111 @@ Available Console Commands:
|
|
|
1306
1307
|
this.applyComponentHighlights(highlightComponents, showZones);
|
|
1307
1308
|
this.setupMutationObserver();
|
|
1308
1309
|
}
|
|
1310
|
+
if (showZones) {
|
|
1311
|
+
this.setupComposerDragDrop();
|
|
1312
|
+
}
|
|
1313
|
+
}
|
|
1314
|
+
/** Document-level drag/drop for cross-iframe drags from Composer sidebar. */
|
|
1315
|
+
setupComposerDragDrop() {
|
|
1316
|
+
if (typeof document === "undefined") return;
|
|
1317
|
+
this.teardownComposerDragDrop();
|
|
1318
|
+
const slotSelector = "[data-slot-id], [data-amplifyup-slot]";
|
|
1319
|
+
const clearDragOverState = () => {
|
|
1320
|
+
document.querySelectorAll(`${slotSelector}.amplifyup-drag-over-slot`).forEach((el) => {
|
|
1321
|
+
el.classList.remove("amplifyup-drag-over-slot");
|
|
1322
|
+
});
|
|
1323
|
+
document.body.classList.remove("amplifyup-drag-no-drop");
|
|
1324
|
+
};
|
|
1325
|
+
const dragenter = (e) => {
|
|
1326
|
+
e.preventDefault();
|
|
1327
|
+
if (e.dataTransfer?.types?.length) {
|
|
1328
|
+
document.body.classList.add("amplifyup-drag-no-drop");
|
|
1329
|
+
}
|
|
1330
|
+
};
|
|
1331
|
+
const dragover = (e) => {
|
|
1332
|
+
e.preventDefault();
|
|
1333
|
+
const target = e.target;
|
|
1334
|
+
const slot = target?.closest?.(slotSelector);
|
|
1335
|
+
if (e.dataTransfer) {
|
|
1336
|
+
e.dataTransfer.dropEffect = slot ? "copy" : "none";
|
|
1337
|
+
}
|
|
1338
|
+
document.querySelectorAll(`${slotSelector}.amplifyup-drag-over-slot`).forEach((el) => {
|
|
1339
|
+
el.classList.remove("amplifyup-drag-over-slot");
|
|
1340
|
+
});
|
|
1341
|
+
if (slot) {
|
|
1342
|
+
slot.classList.add("amplifyup-drag-over-slot");
|
|
1343
|
+
document.body.classList.remove("amplifyup-drag-no-drop");
|
|
1344
|
+
} else {
|
|
1345
|
+
document.body.classList.add("amplifyup-drag-no-drop");
|
|
1346
|
+
}
|
|
1347
|
+
};
|
|
1348
|
+
const dragleave = (e) => {
|
|
1349
|
+
const related = e.relatedTarget;
|
|
1350
|
+
if (!related || !document.body.contains(related)) {
|
|
1351
|
+
clearDragOverState();
|
|
1352
|
+
}
|
|
1353
|
+
};
|
|
1354
|
+
const drop = (e) => {
|
|
1355
|
+
e.preventDefault();
|
|
1356
|
+
const target = e.target;
|
|
1357
|
+
const slot = target?.closest?.(slotSelector);
|
|
1358
|
+
clearDragOverState();
|
|
1359
|
+
if (!slot || !this.isVisualEditorMode) return;
|
|
1360
|
+
const slotName = slot.getAttribute("data-amplifyup-slot") || slot.getAttribute("data-slot-id");
|
|
1361
|
+
const isEmpty = slot.getAttribute("data-slot-empty") === "true";
|
|
1362
|
+
const win = window;
|
|
1363
|
+
if (slotName && win.parent && win.parent !== win) {
|
|
1364
|
+
win.parent.postMessage({
|
|
1365
|
+
type: "DROP_ON_SLOT",
|
|
1366
|
+
slotName,
|
|
1367
|
+
slotElement: { path: slot.getAttribute("data-slot-path"), isEmpty }
|
|
1368
|
+
}, "*");
|
|
1369
|
+
}
|
|
1370
|
+
};
|
|
1371
|
+
const mouseover = (e) => {
|
|
1372
|
+
if (!this.showZonesEnabled) return;
|
|
1373
|
+
const target = e.target;
|
|
1374
|
+
const slot = target?.closest?.(slotSelector);
|
|
1375
|
+
if (!slot) return;
|
|
1376
|
+
document.querySelectorAll(`${slotSelector}.amplifyup-slot-hover`).forEach((el) => {
|
|
1377
|
+
el.classList.remove("amplifyup-slot-hover");
|
|
1378
|
+
});
|
|
1379
|
+
slot.classList.add("amplifyup-slot-hover");
|
|
1380
|
+
};
|
|
1381
|
+
const mouseout = (e) => {
|
|
1382
|
+
if (!this.showZonesEnabled) return;
|
|
1383
|
+
const related = e.relatedTarget;
|
|
1384
|
+
if (!related?.closest?.(slotSelector)) {
|
|
1385
|
+
document.querySelectorAll(`${slotSelector}.amplifyup-slot-hover`).forEach((el) => {
|
|
1386
|
+
el.classList.remove("amplifyup-slot-hover");
|
|
1387
|
+
});
|
|
1388
|
+
}
|
|
1389
|
+
};
|
|
1390
|
+
document.addEventListener("dragenter", dragenter, false);
|
|
1391
|
+
document.addEventListener("dragover", dragover, false);
|
|
1392
|
+
document.addEventListener("dragleave", dragleave, false);
|
|
1393
|
+
document.addEventListener("drop", drop, false);
|
|
1394
|
+
document.addEventListener("mouseover", mouseover, true);
|
|
1395
|
+
document.addEventListener("mouseout", mouseout, true);
|
|
1396
|
+
this.composerDragHandlers = { dragenter, dragover, dragleave, drop, mouseover, mouseout };
|
|
1397
|
+
}
|
|
1398
|
+
teardownComposerDragDrop() {
|
|
1399
|
+
if (!this.composerDragHandlers || typeof document === "undefined") return;
|
|
1400
|
+
const h = this.composerDragHandlers;
|
|
1401
|
+
document.removeEventListener("dragenter", h.dragenter, false);
|
|
1402
|
+
document.removeEventListener("dragover", h.dragover, false);
|
|
1403
|
+
document.removeEventListener("dragleave", h.dragleave, false);
|
|
1404
|
+
document.removeEventListener("drop", h.drop, false);
|
|
1405
|
+
document.removeEventListener("mouseover", h.mouseover, true);
|
|
1406
|
+
document.removeEventListener("mouseout", h.mouseout, true);
|
|
1407
|
+
this.composerDragHandlers = null;
|
|
1408
|
+
document.body.classList.remove("amplifyup-drag-no-drop");
|
|
1409
|
+
document.querySelectorAll("[data-slot-id].amplifyup-drag-over-slot, [data-amplifyup-slot].amplifyup-drag-over-slot").forEach((el) => {
|
|
1410
|
+
el.classList.remove("amplifyup-drag-over-slot");
|
|
1411
|
+
});
|
|
1412
|
+
document.querySelectorAll("[data-slot-id].amplifyup-slot-hover, [data-amplifyup-slot].amplifyup-slot-hover").forEach((el) => {
|
|
1413
|
+
el.classList.remove("amplifyup-slot-hover");
|
|
1414
|
+
});
|
|
1309
1415
|
}
|
|
1310
1416
|
/** Visual outlines for Composer (direct iframe path — no preview-frame proxy). */
|
|
1311
1417
|
injectComposerHighlightStyles(highlightComponents, showZones) {
|
|
@@ -1332,19 +1438,64 @@ Available Console Commands:
|
|
|
1332
1438
|
" outline: 2px dotted rgba(34, 197, 94, 0.75) !important;",
|
|
1333
1439
|
" outline-offset: 4px !important;",
|
|
1334
1440
|
" min-height: 3rem !important;",
|
|
1441
|
+
" padding: 20px !important;",
|
|
1335
1442
|
" box-sizing: border-box !important;",
|
|
1336
1443
|
" cursor: pointer !important;",
|
|
1444
|
+
" position: relative !important;",
|
|
1337
1445
|
"}",
|
|
1338
1446
|
'[data-slot-id="main"], [data-amplifyup-slot="main"] {',
|
|
1339
1447
|
" min-height: 50vh !important;",
|
|
1340
1448
|
"}",
|
|
1449
|
+
'[data-slot-id="main"][data-slot-empty="true"]::before,',
|
|
1450
|
+
'[data-amplifyup-slot="main"][data-slot-empty="true"]::before {',
|
|
1451
|
+
' content: "Drop components here" !important;',
|
|
1452
|
+
" position: absolute !important;",
|
|
1453
|
+
" top: 50% !important; left: 50% !important;",
|
|
1454
|
+
" transform: translate(-50%, -50%) !important;",
|
|
1455
|
+
" font-size: 14px !important; font-weight: 500 !important;",
|
|
1456
|
+
" color: rgba(34, 197, 94, 0.65) !important;",
|
|
1457
|
+
" pointer-events: none !important;",
|
|
1458
|
+
" white-space: nowrap !important;",
|
|
1459
|
+
"}",
|
|
1341
1460
|
"[data-slot-id].amplifyup-slot-hover, [data-amplifyup-slot].amplifyup-slot-hover {",
|
|
1342
1461
|
" outline-color: rgba(34, 197, 94, 1) !important;",
|
|
1343
1462
|
" background: rgba(34, 197, 94, 0.06) !important;",
|
|
1344
1463
|
"}",
|
|
1345
1464
|
"[data-slot-id].amplifyup-drag-over-slot, [data-amplifyup-slot].amplifyup-drag-over-slot {",
|
|
1346
1465
|
" outline: 2px solid rgba(34, 197, 94, 1) !important;",
|
|
1347
|
-
" background: rgba(34, 197, 94, 0.
|
|
1466
|
+
" background: rgba(34, 197, 94, 0.18) !important;",
|
|
1467
|
+
" position: relative !important;",
|
|
1468
|
+
"}",
|
|
1469
|
+
"[data-slot-id].amplifyup-drag-over-slot::after,",
|
|
1470
|
+
"[data-amplifyup-slot].amplifyup-drag-over-slot::after {",
|
|
1471
|
+
' content: "\\2713 Drop here" !important;',
|
|
1472
|
+
" position: absolute !important;",
|
|
1473
|
+
" top: 50% !important; left: 50% !important;",
|
|
1474
|
+
" transform: translate(-50%, -50%) !important;",
|
|
1475
|
+
" font-size: 14px !important; font-weight: 600 !important;",
|
|
1476
|
+
" color: rgb(22, 163, 74) !important;",
|
|
1477
|
+
" pointer-events: none !important;",
|
|
1478
|
+
" white-space: nowrap !important;",
|
|
1479
|
+
" z-index: 1 !important;",
|
|
1480
|
+
"}",
|
|
1481
|
+
"body.amplifyup-drag-no-drop { cursor: no-drop !important; }",
|
|
1482
|
+
"body.amplifyup-drag-no-drop::before {",
|
|
1483
|
+
' content: "" !important;',
|
|
1484
|
+
" position: fixed !important; top: 0 !important; left: 0 !important; right: 0 !important; bottom: 0 !important;",
|
|
1485
|
+
" background: rgba(239, 68, 68, 0.06) !important;",
|
|
1486
|
+
" pointer-events: none !important;",
|
|
1487
|
+
" z-index: 2147483646 !important;",
|
|
1488
|
+
"}",
|
|
1489
|
+
"body.amplifyup-drag-no-drop::after {",
|
|
1490
|
+
' content: "\\2717 Not a drop zone" !important;',
|
|
1491
|
+
" position: fixed !important; bottom: 12px !important; right: 12px !important;",
|
|
1492
|
+
" font-size: 12px !important; font-weight: 600 !important;",
|
|
1493
|
+
" color: rgb(185, 28, 28) !important;",
|
|
1494
|
+
" background: rgba(254, 226, 226, 0.95) !important;",
|
|
1495
|
+
" padding: 6px 10px !important; border-radius: 6px !important;",
|
|
1496
|
+
" pointer-events: none !important;",
|
|
1497
|
+
" z-index: 2147483647 !important;",
|
|
1498
|
+
" box-shadow: 0 1px 3px rgba(0,0,0,0.1) !important;",
|
|
1348
1499
|
"}"
|
|
1349
1500
|
);
|
|
1350
1501
|
}
|
|
@@ -1404,6 +1555,7 @@ Available Console Commands:
|
|
|
1404
1555
|
disableHighlighting() {
|
|
1405
1556
|
if (typeof document === "undefined") return;
|
|
1406
1557
|
this.highlightingEnabled = false;
|
|
1558
|
+
this.teardownComposerDragDrop();
|
|
1407
1559
|
if (this.mutationObserver) {
|
|
1408
1560
|
this.mutationObserver.disconnect();
|
|
1409
1561
|
this.mutationObserver = null;
|
|
@@ -1564,9 +1716,15 @@ Available Console Commands:
|
|
|
1564
1716
|
e.preventDefault();
|
|
1565
1717
|
e.stopPropagation();
|
|
1566
1718
|
htmlEl.classList.remove("amplifyup-drag-over-slot");
|
|
1719
|
+
if (!win.parent || win.parent === win) return;
|
|
1720
|
+
win.parent.postMessage({
|
|
1721
|
+
type: "DROP_ON_SLOT",
|
|
1722
|
+
slotName,
|
|
1723
|
+
slotElement: { path: htmlEl.getAttribute("data-slot-path"), isEmpty }
|
|
1724
|
+
}, "*");
|
|
1567
1725
|
try {
|
|
1568
1726
|
const data = JSON.parse(e.dataTransfer.getData("application/json"));
|
|
1569
|
-
if (data.type === "component"
|
|
1727
|
+
if (data.type === "component") {
|
|
1570
1728
|
win.parent.postMessage({
|
|
1571
1729
|
type: "COMPONENT_DROPPED",
|
|
1572
1730
|
componentId: data.componentId,
|
|
@@ -1574,7 +1732,6 @@ Available Console Commands:
|
|
|
1574
1732
|
slotName,
|
|
1575
1733
|
slotElement: { path: htmlEl.getAttribute("data-slot-path"), isEmpty }
|
|
1576
1734
|
}, "*");
|
|
1577
|
-
win.parent.postMessage({ type: "DROP_ON_SLOT", slotName }, "*");
|
|
1578
1735
|
}
|
|
1579
1736
|
} catch (_err) {
|
|
1580
1737
|
}
|