@amplifyup/sdk 0.1.15 → 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 +109 -29
- package/dist/AmplifyRenderer.js.map +1 -1
- package/dist/AmplifyRenderer.mjs +110 -30
- 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 +109 -29
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +110 -30
- package/dist/react.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1195,6 +1195,10 @@ Available Console Commands:
|
|
|
1195
1195
|
this.clearComposerDragHighlight();
|
|
1196
1196
|
return;
|
|
1197
1197
|
}
|
|
1198
|
+
if (event.data?.type === "CLEAR_SELECTION") {
|
|
1199
|
+
this.clearComposerSelection();
|
|
1200
|
+
return;
|
|
1201
|
+
}
|
|
1198
1202
|
if (event.data?.type === "GET_ELEMENT_POSITION") {
|
|
1199
1203
|
const { componentId, slotName, nodeId, isPageSlot } = event.data;
|
|
1200
1204
|
let element = null;
|
|
@@ -1236,6 +1240,7 @@ Available Console Commands:
|
|
|
1236
1240
|
found: !!element
|
|
1237
1241
|
});
|
|
1238
1242
|
if (element) {
|
|
1243
|
+
this.markComposerSelection(element);
|
|
1239
1244
|
const rect = element.getBoundingClientRect();
|
|
1240
1245
|
const position = {
|
|
1241
1246
|
x: rect.left + rect.width / 2,
|
|
@@ -1303,6 +1308,7 @@ Available Console Commands:
|
|
|
1303
1308
|
break;
|
|
1304
1309
|
case "SHOW_COMPONENT_TOOLTIP":
|
|
1305
1310
|
case "HIDE_ALL_TOOLTIPS":
|
|
1311
|
+
this.clearComposerSelection();
|
|
1306
1312
|
break;
|
|
1307
1313
|
case "ENABLE_EVENT_SELECTION":
|
|
1308
1314
|
console.log("[AmplifyUp SDK] Enable event selection mode:", message.enabled);
|
|
@@ -1540,29 +1546,46 @@ Available Console Commands:
|
|
|
1540
1546
|
*/
|
|
1541
1547
|
enableHighlighting(componentRegistry, highlightComponents, showZones) {
|
|
1542
1548
|
if (typeof document === "undefined") return;
|
|
1549
|
+
const previouslySelected = Array.from(
|
|
1550
|
+
document.querySelectorAll(".amplifyup-selected")
|
|
1551
|
+
);
|
|
1543
1552
|
this.componentRegistry = componentRegistry;
|
|
1544
1553
|
this.highlightingEnabled = true;
|
|
1545
1554
|
this.highlightComponentsEnabled = highlightComponents;
|
|
1546
1555
|
this.showZonesEnabled = showZones;
|
|
1547
|
-
this.disableHighlighting();
|
|
1556
|
+
this.disableHighlighting({ clearSelection: false });
|
|
1548
1557
|
this.highlightingEnabled = true;
|
|
1549
1558
|
this.injectComposerHighlightStyles(highlightComponents, showZones);
|
|
1550
1559
|
if (highlightComponents || showZones) {
|
|
1551
1560
|
this.applyComponentHighlights(highlightComponents, showZones);
|
|
1552
1561
|
this.setupMutationObserver();
|
|
1553
|
-
}
|
|
1554
|
-
if (showZones) {
|
|
1555
1562
|
this.setupComposerDragDrop();
|
|
1556
1563
|
}
|
|
1564
|
+
previouslySelected.forEach((el) => {
|
|
1565
|
+
if (document.contains(el)) {
|
|
1566
|
+
el.classList.add("amplifyup-selected");
|
|
1567
|
+
}
|
|
1568
|
+
});
|
|
1557
1569
|
}
|
|
1558
1570
|
/** Document-level drag/drop for cross-iframe drags from Composer sidebar. */
|
|
1559
1571
|
setupComposerDragDrop() {
|
|
1560
1572
|
if (typeof document === "undefined") return;
|
|
1561
1573
|
this.teardownComposerDragDrop();
|
|
1562
1574
|
const slotSelector = "[data-slot-id], [data-amplifyup-slot]";
|
|
1575
|
+
const componentSelector = "[data-amplifyup-component], [data-component-id]";
|
|
1563
1576
|
const clearDragOverState = () => {
|
|
1564
1577
|
this.clearComposerDragHighlight();
|
|
1565
1578
|
};
|
|
1579
|
+
const clearComponentHover = () => {
|
|
1580
|
+
document.querySelectorAll(".amplifyup-component-hover").forEach((el) => {
|
|
1581
|
+
el.classList.remove("amplifyup-component-hover");
|
|
1582
|
+
});
|
|
1583
|
+
};
|
|
1584
|
+
const clearSlotHover = () => {
|
|
1585
|
+
document.querySelectorAll(`${slotSelector}.amplifyup-slot-hover`).forEach((el) => {
|
|
1586
|
+
el.classList.remove("amplifyup-slot-hover");
|
|
1587
|
+
});
|
|
1588
|
+
};
|
|
1566
1589
|
const dragenter = (e) => {
|
|
1567
1590
|
e.preventDefault();
|
|
1568
1591
|
};
|
|
@@ -1593,31 +1616,59 @@ Available Console Commands:
|
|
|
1593
1616
|
this.postDropOnSlot(slot);
|
|
1594
1617
|
};
|
|
1595
1618
|
const mouseover = (e) => {
|
|
1596
|
-
if (!this.showZonesEnabled) return;
|
|
1619
|
+
if (!this.highlightComponentsEnabled && !this.showZonesEnabled) return;
|
|
1597
1620
|
const target = e.target;
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1621
|
+
if (!target?.closest) return;
|
|
1622
|
+
const component = target.closest(componentSelector);
|
|
1623
|
+
const slot = target.closest(slotSelector);
|
|
1624
|
+
if (this.highlightComponentsEnabled && component) {
|
|
1625
|
+
if (!component.classList.contains("amplifyup-component-hover")) {
|
|
1626
|
+
clearComponentHover();
|
|
1627
|
+
component.classList.add("amplifyup-component-hover");
|
|
1628
|
+
}
|
|
1629
|
+
if (slot && !component.contains(slot)) {
|
|
1630
|
+
clearSlotHover();
|
|
1631
|
+
}
|
|
1632
|
+
return;
|
|
1633
|
+
}
|
|
1634
|
+
clearComponentHover();
|
|
1635
|
+
if (this.showZonesEnabled && slot) {
|
|
1636
|
+
if (!slot.classList.contains("amplifyup-slot-hover")) {
|
|
1637
|
+
clearSlotHover();
|
|
1638
|
+
slot.classList.add("amplifyup-slot-hover");
|
|
1639
|
+
}
|
|
1640
|
+
}
|
|
1604
1641
|
};
|
|
1605
1642
|
const mouseout = (e) => {
|
|
1606
|
-
if (!this.showZonesEnabled) return;
|
|
1643
|
+
if (!this.highlightComponentsEnabled && !this.showZonesEnabled) return;
|
|
1607
1644
|
const related = e.relatedTarget;
|
|
1608
|
-
if (
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
}
|
|
1645
|
+
if (this.highlightComponentsEnabled) {
|
|
1646
|
+
if (!related?.closest?.(componentSelector)) {
|
|
1647
|
+
clearComponentHover();
|
|
1648
|
+
}
|
|
1649
|
+
}
|
|
1650
|
+
if (this.showZonesEnabled) {
|
|
1651
|
+
if (!related?.closest?.(slotSelector)) {
|
|
1652
|
+
clearSlotHover();
|
|
1653
|
+
}
|
|
1612
1654
|
}
|
|
1613
1655
|
};
|
|
1614
|
-
document.addEventListener("dragenter", dragenter, false);
|
|
1615
|
-
document.addEventListener("dragover", dragover, false);
|
|
1616
|
-
document.addEventListener("dragleave", dragleave, false);
|
|
1617
|
-
document.addEventListener("drop", drop, false);
|
|
1618
1656
|
document.addEventListener("mouseover", mouseover, true);
|
|
1619
1657
|
document.addEventListener("mouseout", mouseout, true);
|
|
1620
|
-
this.
|
|
1658
|
+
if (this.showZonesEnabled) {
|
|
1659
|
+
document.addEventListener("dragenter", dragenter, false);
|
|
1660
|
+
document.addEventListener("dragover", dragover, false);
|
|
1661
|
+
document.addEventListener("dragleave", dragleave, false);
|
|
1662
|
+
document.addEventListener("drop", drop, false);
|
|
1663
|
+
}
|
|
1664
|
+
this.composerDragHandlers = {
|
|
1665
|
+
dragenter,
|
|
1666
|
+
dragover,
|
|
1667
|
+
dragleave,
|
|
1668
|
+
drop,
|
|
1669
|
+
mouseover,
|
|
1670
|
+
mouseout
|
|
1671
|
+
};
|
|
1621
1672
|
}
|
|
1622
1673
|
teardownComposerDragDrop() {
|
|
1623
1674
|
if (!this.composerDragHandlers || typeof document === "undefined") return;
|
|
@@ -1640,6 +1691,20 @@ Available Console Commands:
|
|
|
1640
1691
|
document.querySelectorAll("[data-slot-id].amplifyup-slot-hover, [data-amplifyup-slot].amplifyup-slot-hover").forEach((el) => {
|
|
1641
1692
|
el.classList.remove("amplifyup-slot-hover");
|
|
1642
1693
|
});
|
|
1694
|
+
document.querySelectorAll(".amplifyup-component-hover").forEach((el) => {
|
|
1695
|
+
el.classList.remove("amplifyup-component-hover");
|
|
1696
|
+
});
|
|
1697
|
+
}
|
|
1698
|
+
clearComposerSelection() {
|
|
1699
|
+
if (typeof document === "undefined") return;
|
|
1700
|
+
document.querySelectorAll(
|
|
1701
|
+
"[data-slot-id].amplifyup-selected, [data-amplifyup-slot].amplifyup-selected, [data-amplifyup-component].amplifyup-selected, [data-component-id].amplifyup-selected"
|
|
1702
|
+
).forEach((el) => el.classList.remove("amplifyup-selected"));
|
|
1703
|
+
}
|
|
1704
|
+
markComposerSelection(element) {
|
|
1705
|
+
if (typeof document === "undefined") return;
|
|
1706
|
+
this.clearComposerSelection();
|
|
1707
|
+
element.classList.add("amplifyup-selected");
|
|
1643
1708
|
}
|
|
1644
1709
|
/** Visual outlines for Composer (direct iframe path — no preview-frame proxy). */
|
|
1645
1710
|
injectComposerHighlightStyles(highlightComponents, showZones) {
|
|
@@ -1647,16 +1712,29 @@ Available Console Commands:
|
|
|
1647
1712
|
if (!highlightComponents && !showZones) return;
|
|
1648
1713
|
const existing = document.getElementById("amplifyup-preview-highlights");
|
|
1649
1714
|
if (existing) existing.remove();
|
|
1715
|
+
const primary = "hsl(82 92% 42%)";
|
|
1650
1716
|
const lines = [];
|
|
1651
1717
|
if (highlightComponents) {
|
|
1652
1718
|
lines.push(
|
|
1653
1719
|
"[data-amplifyup-component], [data-component-id] {",
|
|
1654
|
-
" outline: 1px dashed rgba(59, 130, 246, 0.8) !important;",
|
|
1655
|
-
" outline-offset: 2px !important;",
|
|
1656
1720
|
" cursor: pointer !important;",
|
|
1657
1721
|
"}",
|
|
1658
|
-
"[data-amplifyup-component]
|
|
1659
|
-
|
|
1722
|
+
"[data-amplifyup-component].amplifyup-selected, [data-component-id].amplifyup-selected {",
|
|
1723
|
+
` outline: 2px solid ${primary} !important;`,
|
|
1724
|
+
" outline-offset: -2px !important;",
|
|
1725
|
+
" box-shadow: inset 0 0 0 1px hsl(82 92% 42% / 0.25) !important;",
|
|
1726
|
+
"}",
|
|
1727
|
+
"[data-amplifyup-component].amplifyup-component-hover:not(.amplifyup-selected),",
|
|
1728
|
+
"[data-component-id].amplifyup-component-hover:not(.amplifyup-selected) {",
|
|
1729
|
+
` outline: 2px solid ${primary} !important;`,
|
|
1730
|
+
" outline-offset: -2px !important;",
|
|
1731
|
+
"}"
|
|
1732
|
+
);
|
|
1733
|
+
}
|
|
1734
|
+
if (highlightComponents || showZones) {
|
|
1735
|
+
lines.push(
|
|
1736
|
+
"[data-slot-id].amplifyup-selected, [data-amplifyup-slot].amplifyup-selected {",
|
|
1737
|
+
" background-color: rgba(245, 245, 220, 0.35) !important;",
|
|
1660
1738
|
"}"
|
|
1661
1739
|
);
|
|
1662
1740
|
}
|
|
@@ -1791,8 +1869,9 @@ Available Console Commands:
|
|
|
1791
1869
|
/**
|
|
1792
1870
|
* Disable component highlighting
|
|
1793
1871
|
*/
|
|
1794
|
-
disableHighlighting() {
|
|
1872
|
+
disableHighlighting(opts) {
|
|
1795
1873
|
if (typeof document === "undefined") return;
|
|
1874
|
+
const clearSelection = opts?.clearSelection !== false;
|
|
1796
1875
|
this.highlightingEnabled = false;
|
|
1797
1876
|
this.teardownComposerDragDrop();
|
|
1798
1877
|
if (this.mutationObserver) {
|
|
@@ -1821,10 +1900,10 @@ Available Console Commands:
|
|
|
1821
1900
|
delete htmlEl._amplifyupSlotHandlers;
|
|
1822
1901
|
htmlEl.classList.remove("amplifyup-slot-highlight");
|
|
1823
1902
|
});
|
|
1903
|
+
if (clearSelection) {
|
|
1904
|
+
this.clearComposerSelection();
|
|
1905
|
+
}
|
|
1824
1906
|
}
|
|
1825
|
-
/**
|
|
1826
|
-
* Build component hierarchy for ancestor selection
|
|
1827
|
-
*/
|
|
1828
1907
|
buildComponentHierarchy(element) {
|
|
1829
1908
|
const hierarchy = [];
|
|
1830
1909
|
let current = element;
|
|
@@ -1888,6 +1967,7 @@ Available Console Commands:
|
|
|
1888
1967
|
window.parent.postMessage(message, "*");
|
|
1889
1968
|
console.log("[AmplifyUp SDK] Sent selection message:", message);
|
|
1890
1969
|
}
|
|
1970
|
+
this.markComposerSelection(element);
|
|
1891
1971
|
}
|
|
1892
1972
|
/**
|
|
1893
1973
|
* Send component tree to orchestrator
|