@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/react.js
CHANGED
|
@@ -1166,6 +1166,24 @@ Available Console Commands:
|
|
|
1166
1166
|
}
|
|
1167
1167
|
return;
|
|
1168
1168
|
}
|
|
1169
|
+
if (event.data?.type === "COMPOSER_DRAG_AT_POINT") {
|
|
1170
|
+
const { x, y } = event.data;
|
|
1171
|
+
if (typeof x === "number" && typeof y === "number") {
|
|
1172
|
+
this.handleComposerDragAtPoint(x, y);
|
|
1173
|
+
}
|
|
1174
|
+
return;
|
|
1175
|
+
}
|
|
1176
|
+
if (event.data?.type === "COMPOSER_DROP_AT_POINT") {
|
|
1177
|
+
const { x, y } = event.data;
|
|
1178
|
+
if (typeof x === "number" && typeof y === "number") {
|
|
1179
|
+
this.handleComposerDropAtPoint(x, y);
|
|
1180
|
+
}
|
|
1181
|
+
return;
|
|
1182
|
+
}
|
|
1183
|
+
if (event.data?.type === "COMPOSER_DRAG_END") {
|
|
1184
|
+
this.clearComposerDragHighlight();
|
|
1185
|
+
return;
|
|
1186
|
+
}
|
|
1169
1187
|
if (event.data?.type === "GET_ELEMENT_POSITION") {
|
|
1170
1188
|
const { componentId, slotName } = event.data;
|
|
1171
1189
|
const selector = slotName ? `[data-amplifyup-slot="${slotName}"], [data-slot-id="${slotName}"]` : `[data-amplifyup-component="${componentId}"], [data-component-id="${componentId}"]`;
|
|
@@ -1299,6 +1317,46 @@ Available Console Commands:
|
|
|
1299
1317
|
}
|
|
1300
1318
|
return el.tagName.toLowerCase();
|
|
1301
1319
|
}
|
|
1320
|
+
/** Clear drag-over highlight state (Composer overlay path or native drag end). */
|
|
1321
|
+
clearComposerDragHighlight() {
|
|
1322
|
+
if (typeof document === "undefined") return;
|
|
1323
|
+
const slotSelector = "[data-slot-id], [data-amplifyup-slot]";
|
|
1324
|
+
document.querySelectorAll(`${slotSelector}.amplifyup-drag-over-slot`).forEach((el) => {
|
|
1325
|
+
el.classList.remove("amplifyup-drag-over-slot");
|
|
1326
|
+
});
|
|
1327
|
+
document.body.classList.remove("amplifyup-drag-no-drop");
|
|
1328
|
+
}
|
|
1329
|
+
/**
|
|
1330
|
+
* Hit-test a slot at iframe-local coordinates (Composer overlay drag path).
|
|
1331
|
+
* Required for cross-origin drags: the browser blocks native drop inside the iframe.
|
|
1332
|
+
*/
|
|
1333
|
+
handleComposerDragAtPoint(x, y) {
|
|
1334
|
+
if (typeof document === "undefined") return;
|
|
1335
|
+
const slotSelector = "[data-slot-id], [data-amplifyup-slot]";
|
|
1336
|
+
this.clearComposerDragHighlight();
|
|
1337
|
+
const el = document.elementFromPoint(x, y)?.closest?.(slotSelector);
|
|
1338
|
+
if (el) {
|
|
1339
|
+
el.classList.add("amplifyup-drag-over-slot");
|
|
1340
|
+
} else {
|
|
1341
|
+
document.body.classList.add("amplifyup-drag-no-drop");
|
|
1342
|
+
}
|
|
1343
|
+
}
|
|
1344
|
+
handleComposerDropAtPoint(x, y) {
|
|
1345
|
+
if (typeof document === "undefined") return;
|
|
1346
|
+
const win = window;
|
|
1347
|
+
const slotSelector = "[data-slot-id], [data-amplifyup-slot]";
|
|
1348
|
+
this.clearComposerDragHighlight();
|
|
1349
|
+
const htmlEl = document.elementFromPoint(x, y)?.closest?.(slotSelector);
|
|
1350
|
+
if (!htmlEl || !win.parent || win.parent === win) return;
|
|
1351
|
+
const slotName = htmlEl.getAttribute("data-amplifyup-slot") || htmlEl.getAttribute("data-slot-id");
|
|
1352
|
+
if (!slotName) return;
|
|
1353
|
+
const isEmpty = htmlEl.getAttribute("data-slot-empty") === "true";
|
|
1354
|
+
win.parent.postMessage({
|
|
1355
|
+
type: "DROP_ON_SLOT",
|
|
1356
|
+
slotName,
|
|
1357
|
+
slotElement: { path: htmlEl.getAttribute("data-slot-path"), isEmpty }
|
|
1358
|
+
}, "*");
|
|
1359
|
+
}
|
|
1302
1360
|
/**
|
|
1303
1361
|
* Enable component highlighting
|
|
1304
1362
|
*/
|