@amplifyup/sdk 0.1.11 → 0.1.12
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 +58 -0
- package/dist/AmplifyRenderer.js.map +1 -1
- package/dist/AmplifyRenderer.mjs +58 -0
- package/dist/AmplifyRenderer.mjs.map +1 -1
- package/dist/index.d.mts +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +58 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +58 -0
- package/dist/index.mjs.map +1 -1
- package/dist/react.js +58 -0
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +58 -0
- package/dist/react.mjs.map +1 -1
- package/package.json +1 -1
package/dist/AmplifyRenderer.js
CHANGED
|
@@ -1140,6 +1140,24 @@ Available Console Commands:
|
|
|
1140
1140
|
}
|
|
1141
1141
|
return;
|
|
1142
1142
|
}
|
|
1143
|
+
if (event.data?.type === "COMPOSER_DRAG_AT_POINT") {
|
|
1144
|
+
const { x, y } = event.data;
|
|
1145
|
+
if (typeof x === "number" && typeof y === "number") {
|
|
1146
|
+
this.handleComposerDragAtPoint(x, y);
|
|
1147
|
+
}
|
|
1148
|
+
return;
|
|
1149
|
+
}
|
|
1150
|
+
if (event.data?.type === "COMPOSER_DROP_AT_POINT") {
|
|
1151
|
+
const { x, y } = event.data;
|
|
1152
|
+
if (typeof x === "number" && typeof y === "number") {
|
|
1153
|
+
this.handleComposerDropAtPoint(x, y);
|
|
1154
|
+
}
|
|
1155
|
+
return;
|
|
1156
|
+
}
|
|
1157
|
+
if (event.data?.type === "COMPOSER_DRAG_END") {
|
|
1158
|
+
this.clearComposerDragHighlight();
|
|
1159
|
+
return;
|
|
1160
|
+
}
|
|
1143
1161
|
if (event.data?.type === "GET_ELEMENT_POSITION") {
|
|
1144
1162
|
const { componentId, slotName } = event.data;
|
|
1145
1163
|
const selector = slotName ? `[data-amplifyup-slot="${slotName}"], [data-slot-id="${slotName}"]` : `[data-amplifyup-component="${componentId}"], [data-component-id="${componentId}"]`;
|
|
@@ -1273,6 +1291,46 @@ Available Console Commands:
|
|
|
1273
1291
|
}
|
|
1274
1292
|
return el.tagName.toLowerCase();
|
|
1275
1293
|
}
|
|
1294
|
+
/** Clear drag-over highlight state (Composer overlay path or native drag end). */
|
|
1295
|
+
clearComposerDragHighlight() {
|
|
1296
|
+
if (typeof document === "undefined") return;
|
|
1297
|
+
const slotSelector = "[data-slot-id], [data-amplifyup-slot]";
|
|
1298
|
+
document.querySelectorAll(`${slotSelector}.amplifyup-drag-over-slot`).forEach((el) => {
|
|
1299
|
+
el.classList.remove("amplifyup-drag-over-slot");
|
|
1300
|
+
});
|
|
1301
|
+
document.body.classList.remove("amplifyup-drag-no-drop");
|
|
1302
|
+
}
|
|
1303
|
+
/**
|
|
1304
|
+
* Hit-test a slot at iframe-local coordinates (Composer overlay drag path).
|
|
1305
|
+
* Required for cross-origin drags: the browser blocks native drop inside the iframe.
|
|
1306
|
+
*/
|
|
1307
|
+
handleComposerDragAtPoint(x, y) {
|
|
1308
|
+
if (typeof document === "undefined") return;
|
|
1309
|
+
const slotSelector = "[data-slot-id], [data-amplifyup-slot]";
|
|
1310
|
+
this.clearComposerDragHighlight();
|
|
1311
|
+
const el = document.elementFromPoint(x, y)?.closest?.(slotSelector);
|
|
1312
|
+
if (el) {
|
|
1313
|
+
el.classList.add("amplifyup-drag-over-slot");
|
|
1314
|
+
} else {
|
|
1315
|
+
document.body.classList.add("amplifyup-drag-no-drop");
|
|
1316
|
+
}
|
|
1317
|
+
}
|
|
1318
|
+
handleComposerDropAtPoint(x, y) {
|
|
1319
|
+
if (typeof document === "undefined") return;
|
|
1320
|
+
const win = window;
|
|
1321
|
+
const slotSelector = "[data-slot-id], [data-amplifyup-slot]";
|
|
1322
|
+
this.clearComposerDragHighlight();
|
|
1323
|
+
const htmlEl = document.elementFromPoint(x, y)?.closest?.(slotSelector);
|
|
1324
|
+
if (!htmlEl || !win.parent || win.parent === win) return;
|
|
1325
|
+
const slotName = htmlEl.getAttribute("data-amplifyup-slot") || htmlEl.getAttribute("data-slot-id");
|
|
1326
|
+
if (!slotName) return;
|
|
1327
|
+
const isEmpty = htmlEl.getAttribute("data-slot-empty") === "true";
|
|
1328
|
+
win.parent.postMessage({
|
|
1329
|
+
type: "DROP_ON_SLOT",
|
|
1330
|
+
slotName,
|
|
1331
|
+
slotElement: { path: htmlEl.getAttribute("data-slot-path"), isEmpty }
|
|
1332
|
+
}, "*");
|
|
1333
|
+
}
|
|
1276
1334
|
/**
|
|
1277
1335
|
* Enable component highlighting
|
|
1278
1336
|
*/
|