@amplifyup/sdk 0.1.16 → 0.1.17
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 +108 -28
- package/dist/AmplifyRenderer.js.map +1 -1
- package/dist/AmplifyRenderer.mjs +108 -28
- package/dist/AmplifyRenderer.mjs.map +1 -1
- package/dist/index.d.mts +2 -3
- package/dist/index.d.ts +2 -3
- package/dist/index.js +108 -28
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +108 -28
- package/dist/index.mjs.map +1 -1
- package/dist/react.js +108 -28
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +108 -28
- package/dist/react.mjs.map +1 -1
- package/package.json +1 -1
package/dist/react.mjs
CHANGED
|
@@ -1205,6 +1205,10 @@ Available Console Commands:
|
|
|
1205
1205
|
this.clearComposerDragHighlight();
|
|
1206
1206
|
return;
|
|
1207
1207
|
}
|
|
1208
|
+
if (event.data?.type === "CLEAR_SELECTION") {
|
|
1209
|
+
this.clearComposerSelection();
|
|
1210
|
+
return;
|
|
1211
|
+
}
|
|
1208
1212
|
if (event.data?.type === "GET_ELEMENT_POSITION") {
|
|
1209
1213
|
const { componentId, slotName, nodeId, isPageSlot } = event.data;
|
|
1210
1214
|
let element = null;
|
|
@@ -1246,6 +1250,7 @@ Available Console Commands:
|
|
|
1246
1250
|
found: !!element
|
|
1247
1251
|
});
|
|
1248
1252
|
if (element) {
|
|
1253
|
+
this.markComposerSelection(element);
|
|
1249
1254
|
const rect = element.getBoundingClientRect();
|
|
1250
1255
|
const position = {
|
|
1251
1256
|
x: rect.left + rect.width / 2,
|
|
@@ -1313,6 +1318,7 @@ Available Console Commands:
|
|
|
1313
1318
|
break;
|
|
1314
1319
|
case "SHOW_COMPONENT_TOOLTIP":
|
|
1315
1320
|
case "HIDE_ALL_TOOLTIPS":
|
|
1321
|
+
this.clearComposerSelection();
|
|
1316
1322
|
break;
|
|
1317
1323
|
case "ENABLE_EVENT_SELECTION":
|
|
1318
1324
|
console.log("[AmplifyUp SDK] Enable event selection mode:", message.enabled);
|
|
@@ -1550,29 +1556,46 @@ Available Console Commands:
|
|
|
1550
1556
|
*/
|
|
1551
1557
|
enableHighlighting(componentRegistry, highlightComponents, showZones) {
|
|
1552
1558
|
if (typeof document === "undefined") return;
|
|
1559
|
+
const previouslySelected = Array.from(
|
|
1560
|
+
document.querySelectorAll(".amplifyup-selected")
|
|
1561
|
+
);
|
|
1553
1562
|
this.componentRegistry = componentRegistry;
|
|
1554
1563
|
this.highlightingEnabled = true;
|
|
1555
1564
|
this.highlightComponentsEnabled = highlightComponents;
|
|
1556
1565
|
this.showZonesEnabled = showZones;
|
|
1557
|
-
this.disableHighlighting();
|
|
1566
|
+
this.disableHighlighting({ clearSelection: false });
|
|
1558
1567
|
this.highlightingEnabled = true;
|
|
1559
1568
|
this.injectComposerHighlightStyles(highlightComponents, showZones);
|
|
1560
1569
|
if (highlightComponents || showZones) {
|
|
1561
1570
|
this.applyComponentHighlights(highlightComponents, showZones);
|
|
1562
1571
|
this.setupMutationObserver();
|
|
1563
|
-
}
|
|
1564
|
-
if (showZones) {
|
|
1565
1572
|
this.setupComposerDragDrop();
|
|
1566
1573
|
}
|
|
1574
|
+
previouslySelected.forEach((el) => {
|
|
1575
|
+
if (document.contains(el)) {
|
|
1576
|
+
el.classList.add("amplifyup-selected");
|
|
1577
|
+
}
|
|
1578
|
+
});
|
|
1567
1579
|
}
|
|
1568
1580
|
/** Document-level drag/drop for cross-iframe drags from Composer sidebar. */
|
|
1569
1581
|
setupComposerDragDrop() {
|
|
1570
1582
|
if (typeof document === "undefined") return;
|
|
1571
1583
|
this.teardownComposerDragDrop();
|
|
1572
1584
|
const slotSelector = "[data-slot-id], [data-amplifyup-slot]";
|
|
1585
|
+
const componentSelector = "[data-amplifyup-component], [data-component-id]";
|
|
1573
1586
|
const clearDragOverState = () => {
|
|
1574
1587
|
this.clearComposerDragHighlight();
|
|
1575
1588
|
};
|
|
1589
|
+
const clearComponentHover = () => {
|
|
1590
|
+
document.querySelectorAll(".amplifyup-component-hover").forEach((el) => {
|
|
1591
|
+
el.classList.remove("amplifyup-component-hover");
|
|
1592
|
+
});
|
|
1593
|
+
};
|
|
1594
|
+
const clearSlotHover = () => {
|
|
1595
|
+
document.querySelectorAll(`${slotSelector}.amplifyup-slot-hover`).forEach((el) => {
|
|
1596
|
+
el.classList.remove("amplifyup-slot-hover");
|
|
1597
|
+
});
|
|
1598
|
+
};
|
|
1576
1599
|
const dragenter = (e) => {
|
|
1577
1600
|
e.preventDefault();
|
|
1578
1601
|
};
|
|
@@ -1603,31 +1626,59 @@ Available Console Commands:
|
|
|
1603
1626
|
this.postDropOnSlot(slot);
|
|
1604
1627
|
};
|
|
1605
1628
|
const mouseover = (e) => {
|
|
1606
|
-
if (!this.showZonesEnabled) return;
|
|
1629
|
+
if (!this.highlightComponentsEnabled && !this.showZonesEnabled) return;
|
|
1607
1630
|
const target = e.target;
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1631
|
+
if (!target?.closest) return;
|
|
1632
|
+
const component = target.closest(componentSelector);
|
|
1633
|
+
const slot = target.closest(slotSelector);
|
|
1634
|
+
if (this.highlightComponentsEnabled && component) {
|
|
1635
|
+
if (!component.classList.contains("amplifyup-component-hover")) {
|
|
1636
|
+
clearComponentHover();
|
|
1637
|
+
component.classList.add("amplifyup-component-hover");
|
|
1638
|
+
}
|
|
1639
|
+
if (slot && !component.contains(slot)) {
|
|
1640
|
+
clearSlotHover();
|
|
1641
|
+
}
|
|
1642
|
+
return;
|
|
1643
|
+
}
|
|
1644
|
+
clearComponentHover();
|
|
1645
|
+
if (this.showZonesEnabled && slot) {
|
|
1646
|
+
if (!slot.classList.contains("amplifyup-slot-hover")) {
|
|
1647
|
+
clearSlotHover();
|
|
1648
|
+
slot.classList.add("amplifyup-slot-hover");
|
|
1649
|
+
}
|
|
1650
|
+
}
|
|
1614
1651
|
};
|
|
1615
1652
|
const mouseout = (e) => {
|
|
1616
|
-
if (!this.showZonesEnabled) return;
|
|
1653
|
+
if (!this.highlightComponentsEnabled && !this.showZonesEnabled) return;
|
|
1617
1654
|
const related = e.relatedTarget;
|
|
1618
|
-
if (
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
}
|
|
1655
|
+
if (this.highlightComponentsEnabled) {
|
|
1656
|
+
if (!related?.closest?.(componentSelector)) {
|
|
1657
|
+
clearComponentHover();
|
|
1658
|
+
}
|
|
1659
|
+
}
|
|
1660
|
+
if (this.showZonesEnabled) {
|
|
1661
|
+
if (!related?.closest?.(slotSelector)) {
|
|
1662
|
+
clearSlotHover();
|
|
1663
|
+
}
|
|
1622
1664
|
}
|
|
1623
1665
|
};
|
|
1624
|
-
document.addEventListener("dragenter", dragenter, false);
|
|
1625
|
-
document.addEventListener("dragover", dragover, false);
|
|
1626
|
-
document.addEventListener("dragleave", dragleave, false);
|
|
1627
|
-
document.addEventListener("drop", drop, false);
|
|
1628
1666
|
document.addEventListener("mouseover", mouseover, true);
|
|
1629
1667
|
document.addEventListener("mouseout", mouseout, true);
|
|
1630
|
-
this.
|
|
1668
|
+
if (this.showZonesEnabled) {
|
|
1669
|
+
document.addEventListener("dragenter", dragenter, false);
|
|
1670
|
+
document.addEventListener("dragover", dragover, false);
|
|
1671
|
+
document.addEventListener("dragleave", dragleave, false);
|
|
1672
|
+
document.addEventListener("drop", drop, false);
|
|
1673
|
+
}
|
|
1674
|
+
this.composerDragHandlers = {
|
|
1675
|
+
dragenter,
|
|
1676
|
+
dragover,
|
|
1677
|
+
dragleave,
|
|
1678
|
+
drop,
|
|
1679
|
+
mouseover,
|
|
1680
|
+
mouseout
|
|
1681
|
+
};
|
|
1631
1682
|
}
|
|
1632
1683
|
teardownComposerDragDrop() {
|
|
1633
1684
|
if (!this.composerDragHandlers || typeof document === "undefined") return;
|
|
@@ -1650,6 +1701,20 @@ Available Console Commands:
|
|
|
1650
1701
|
document.querySelectorAll("[data-slot-id].amplifyup-slot-hover, [data-amplifyup-slot].amplifyup-slot-hover").forEach((el) => {
|
|
1651
1702
|
el.classList.remove("amplifyup-slot-hover");
|
|
1652
1703
|
});
|
|
1704
|
+
document.querySelectorAll(".amplifyup-component-hover").forEach((el) => {
|
|
1705
|
+
el.classList.remove("amplifyup-component-hover");
|
|
1706
|
+
});
|
|
1707
|
+
}
|
|
1708
|
+
clearComposerSelection() {
|
|
1709
|
+
if (typeof document === "undefined") return;
|
|
1710
|
+
document.querySelectorAll(
|
|
1711
|
+
"[data-slot-id].amplifyup-selected, [data-amplifyup-slot].amplifyup-selected, [data-amplifyup-component].amplifyup-selected, [data-component-id].amplifyup-selected"
|
|
1712
|
+
).forEach((el) => el.classList.remove("amplifyup-selected"));
|
|
1713
|
+
}
|
|
1714
|
+
markComposerSelection(element) {
|
|
1715
|
+
if (typeof document === "undefined") return;
|
|
1716
|
+
this.clearComposerSelection();
|
|
1717
|
+
element.classList.add("amplifyup-selected");
|
|
1653
1718
|
}
|
|
1654
1719
|
/** Visual outlines for Composer (direct iframe path — no preview-frame proxy). */
|
|
1655
1720
|
injectComposerHighlightStyles(highlightComponents, showZones) {
|
|
@@ -1657,16 +1722,29 @@ Available Console Commands:
|
|
|
1657
1722
|
if (!highlightComponents && !showZones) return;
|
|
1658
1723
|
const existing = document.getElementById("amplifyup-preview-highlights");
|
|
1659
1724
|
if (existing) existing.remove();
|
|
1725
|
+
const primary = "hsl(82 92% 42%)";
|
|
1660
1726
|
const lines = [];
|
|
1661
1727
|
if (highlightComponents) {
|
|
1662
1728
|
lines.push(
|
|
1663
1729
|
"[data-amplifyup-component], [data-component-id] {",
|
|
1664
|
-
" outline: 1px dashed rgba(59, 130, 246, 0.8) !important;",
|
|
1665
|
-
" outline-offset: 2px !important;",
|
|
1666
1730
|
" cursor: pointer !important;",
|
|
1667
1731
|
"}",
|
|
1668
|
-
"[data-amplifyup-component]
|
|
1669
|
-
|
|
1732
|
+
"[data-amplifyup-component].amplifyup-selected, [data-component-id].amplifyup-selected {",
|
|
1733
|
+
` outline: 2px solid ${primary} !important;`,
|
|
1734
|
+
" outline-offset: -2px !important;",
|
|
1735
|
+
" box-shadow: inset 0 0 0 1px hsl(82 92% 42% / 0.25) !important;",
|
|
1736
|
+
"}",
|
|
1737
|
+
"[data-amplifyup-component].amplifyup-component-hover:not(.amplifyup-selected),",
|
|
1738
|
+
"[data-component-id].amplifyup-component-hover:not(.amplifyup-selected) {",
|
|
1739
|
+
` outline: 2px solid ${primary} !important;`,
|
|
1740
|
+
" outline-offset: -2px !important;",
|
|
1741
|
+
"}"
|
|
1742
|
+
);
|
|
1743
|
+
}
|
|
1744
|
+
if (highlightComponents || showZones) {
|
|
1745
|
+
lines.push(
|
|
1746
|
+
"[data-slot-id].amplifyup-selected, [data-amplifyup-slot].amplifyup-selected {",
|
|
1747
|
+
" background-color: rgba(245, 245, 220, 0.35) !important;",
|
|
1670
1748
|
"}"
|
|
1671
1749
|
);
|
|
1672
1750
|
}
|
|
@@ -1801,8 +1879,9 @@ Available Console Commands:
|
|
|
1801
1879
|
/**
|
|
1802
1880
|
* Disable component highlighting
|
|
1803
1881
|
*/
|
|
1804
|
-
disableHighlighting() {
|
|
1882
|
+
disableHighlighting(opts) {
|
|
1805
1883
|
if (typeof document === "undefined") return;
|
|
1884
|
+
const clearSelection = opts?.clearSelection !== false;
|
|
1806
1885
|
this.highlightingEnabled = false;
|
|
1807
1886
|
this.teardownComposerDragDrop();
|
|
1808
1887
|
if (this.mutationObserver) {
|
|
@@ -1831,10 +1910,10 @@ Available Console Commands:
|
|
|
1831
1910
|
delete htmlEl._amplifyupSlotHandlers;
|
|
1832
1911
|
htmlEl.classList.remove("amplifyup-slot-highlight");
|
|
1833
1912
|
});
|
|
1913
|
+
if (clearSelection) {
|
|
1914
|
+
this.clearComposerSelection();
|
|
1915
|
+
}
|
|
1834
1916
|
}
|
|
1835
|
-
/**
|
|
1836
|
-
* Build component hierarchy for ancestor selection
|
|
1837
|
-
*/
|
|
1838
1917
|
buildComponentHierarchy(element) {
|
|
1839
1918
|
const hierarchy = [];
|
|
1840
1919
|
let current = element;
|
|
@@ -1898,6 +1977,7 @@ Available Console Commands:
|
|
|
1898
1977
|
window.parent.postMessage(message, "*");
|
|
1899
1978
|
console.log("[AmplifyUp SDK] Sent selection message:", message);
|
|
1900
1979
|
}
|
|
1980
|
+
this.markComposerSelection(element);
|
|
1901
1981
|
}
|
|
1902
1982
|
/**
|
|
1903
1983
|
* Send component tree to orchestrator
|