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