@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/index.d.mts CHANGED
@@ -216,6 +216,14 @@ declare class AmplifyUpSDK {
216
216
  * Generate a CSS selector for an element
217
217
  */
218
218
  private generateSelectorForElement;
219
+ /** Clear drag-over highlight state (Composer overlay path or native drag end). */
220
+ private clearComposerDragHighlight;
221
+ /**
222
+ * Hit-test a slot at iframe-local coordinates (Composer overlay drag path).
223
+ * Required for cross-origin drags: the browser blocks native drop inside the iframe.
224
+ */
225
+ private handleComposerDragAtPoint;
226
+ private handleComposerDropAtPoint;
219
227
  /**
220
228
  * Enable component highlighting
221
229
  */
package/dist/index.d.ts CHANGED
@@ -216,6 +216,14 @@ declare class AmplifyUpSDK {
216
216
  * Generate a CSS selector for an element
217
217
  */
218
218
  private generateSelectorForElement;
219
+ /** Clear drag-over highlight state (Composer overlay path or native drag end). */
220
+ private clearComposerDragHighlight;
221
+ /**
222
+ * Hit-test a slot at iframe-local coordinates (Composer overlay drag path).
223
+ * Required for cross-origin drags: the browser blocks native drop inside the iframe.
224
+ */
225
+ private handleComposerDragAtPoint;
226
+ private handleComposerDropAtPoint;
219
227
  /**
220
228
  * Enable component highlighting
221
229
  */
package/dist/index.js CHANGED
@@ -1158,6 +1158,24 @@ Available Console Commands:
1158
1158
  }
1159
1159
  return;
1160
1160
  }
1161
+ if (event.data?.type === "COMPOSER_DRAG_AT_POINT") {
1162
+ const { x, y } = event.data;
1163
+ if (typeof x === "number" && typeof y === "number") {
1164
+ this.handleComposerDragAtPoint(x, y);
1165
+ }
1166
+ return;
1167
+ }
1168
+ if (event.data?.type === "COMPOSER_DROP_AT_POINT") {
1169
+ const { x, y } = event.data;
1170
+ if (typeof x === "number" && typeof y === "number") {
1171
+ this.handleComposerDropAtPoint(x, y);
1172
+ }
1173
+ return;
1174
+ }
1175
+ if (event.data?.type === "COMPOSER_DRAG_END") {
1176
+ this.clearComposerDragHighlight();
1177
+ return;
1178
+ }
1161
1179
  if (event.data?.type === "GET_ELEMENT_POSITION") {
1162
1180
  const { componentId, slotName } = event.data;
1163
1181
  const selector = slotName ? `[data-amplifyup-slot="${slotName}"], [data-slot-id="${slotName}"]` : `[data-amplifyup-component="${componentId}"], [data-component-id="${componentId}"]`;
@@ -1291,6 +1309,46 @@ Available Console Commands:
1291
1309
  }
1292
1310
  return el.tagName.toLowerCase();
1293
1311
  }
1312
+ /** Clear drag-over highlight state (Composer overlay path or native drag end). */
1313
+ clearComposerDragHighlight() {
1314
+ if (typeof document === "undefined") return;
1315
+ const slotSelector = "[data-slot-id], [data-amplifyup-slot]";
1316
+ document.querySelectorAll(`${slotSelector}.amplifyup-drag-over-slot`).forEach((el) => {
1317
+ el.classList.remove("amplifyup-drag-over-slot");
1318
+ });
1319
+ document.body.classList.remove("amplifyup-drag-no-drop");
1320
+ }
1321
+ /**
1322
+ * Hit-test a slot at iframe-local coordinates (Composer overlay drag path).
1323
+ * Required for cross-origin drags: the browser blocks native drop inside the iframe.
1324
+ */
1325
+ handleComposerDragAtPoint(x, y) {
1326
+ if (typeof document === "undefined") return;
1327
+ const slotSelector = "[data-slot-id], [data-amplifyup-slot]";
1328
+ this.clearComposerDragHighlight();
1329
+ const el = document.elementFromPoint(x, y)?.closest?.(slotSelector);
1330
+ if (el) {
1331
+ el.classList.add("amplifyup-drag-over-slot");
1332
+ } else {
1333
+ document.body.classList.add("amplifyup-drag-no-drop");
1334
+ }
1335
+ }
1336
+ handleComposerDropAtPoint(x, y) {
1337
+ if (typeof document === "undefined") return;
1338
+ const win = window;
1339
+ const slotSelector = "[data-slot-id], [data-amplifyup-slot]";
1340
+ this.clearComposerDragHighlight();
1341
+ const htmlEl = document.elementFromPoint(x, y)?.closest?.(slotSelector);
1342
+ if (!htmlEl || !win.parent || win.parent === win) return;
1343
+ const slotName = htmlEl.getAttribute("data-amplifyup-slot") || htmlEl.getAttribute("data-slot-id");
1344
+ if (!slotName) return;
1345
+ const isEmpty = htmlEl.getAttribute("data-slot-empty") === "true";
1346
+ win.parent.postMessage({
1347
+ type: "DROP_ON_SLOT",
1348
+ slotName,
1349
+ slotElement: { path: htmlEl.getAttribute("data-slot-path"), isEmpty }
1350
+ }, "*");
1351
+ }
1294
1352
  /**
1295
1353
  * Enable component highlighting
1296
1354
  */