@amplifyup/sdk 0.1.30 → 0.1.32
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.d.mts +1 -1
- package/dist/AmplifyRenderer.d.ts +1 -1
- package/dist/AmplifyRenderer.js +68 -6
- package/dist/AmplifyRenderer.js.map +1 -1
- package/dist/AmplifyRenderer.mjs +68 -6
- package/dist/AmplifyRenderer.mjs.map +1 -1
- package/dist/index.d.mts +8 -2
- package/dist/index.d.ts +8 -2
- package/dist/index.js +68 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +68 -6
- package/dist/index.mjs.map +1 -1
- package/dist/react.d.mts +18 -3
- package/dist/react.d.ts +18 -3
- package/dist/react.js +117 -6
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +117 -7
- package/dist/react.mjs.map +1 -1
- package/dist/server.d.mts +2 -2
- package/dist/server.d.ts +2 -2
- package/dist/{types-6qEnwLda.d.mts → types-npF_lNoq.d.mts} +2 -0
- package/dist/{types-6qEnwLda.d.ts → types-npF_lNoq.d.ts} +2 -0
- package/package.json +1 -1
package/dist/AmplifyRenderer.js
CHANGED
|
@@ -393,6 +393,8 @@ var AmplifyUpSDK = class {
|
|
|
393
393
|
this.showZonesEnabled = false;
|
|
394
394
|
this.componentRegistry = [];
|
|
395
395
|
this.messageListener = null;
|
|
396
|
+
this.composerBoundsRaf = 0;
|
|
397
|
+
this.composerBoundsScrollListener = null;
|
|
396
398
|
this.mutationObserver = null;
|
|
397
399
|
this.composerDragHandlers = null;
|
|
398
400
|
/** Last slot highlighted during Composer drag — avoid clear/re-add flicker. */
|
|
@@ -1446,6 +1448,11 @@ Available Console Commands:
|
|
|
1446
1448
|
if (config.componentName) {
|
|
1447
1449
|
properties.componentName = config.componentName;
|
|
1448
1450
|
}
|
|
1451
|
+
if (config.staticProperties) {
|
|
1452
|
+
for (const [key, value] of Object.entries(config.staticProperties)) {
|
|
1453
|
+
if (key) properties[key] = value;
|
|
1454
|
+
}
|
|
1455
|
+
}
|
|
1449
1456
|
if (config.properties && config.properties.length > 0) {
|
|
1450
1457
|
config.properties.forEach((prop) => {
|
|
1451
1458
|
const dataAttrValue = element.getAttribute(`data-${prop}`);
|
|
@@ -1812,13 +1819,23 @@ Available Console Commands:
|
|
|
1812
1819
|
document.removeEventListener("click", this.eventSelectionClickHandler, true);
|
|
1813
1820
|
this.eventSelectionClickHandler = null;
|
|
1814
1821
|
}
|
|
1822
|
+
if (enabled && typeof window !== "undefined" && window.__AMPLIFYUP_PREVIEW_MODE__) {
|
|
1823
|
+
return;
|
|
1824
|
+
}
|
|
1815
1825
|
if (enabled) {
|
|
1816
1826
|
this.eventSelectionClickHandler = (e) => {
|
|
1817
|
-
const
|
|
1818
|
-
if (!
|
|
1827
|
+
const raw = e.target;
|
|
1828
|
+
if (!raw) return;
|
|
1829
|
+
const interactive = raw.closest(
|
|
1830
|
+
'a, button, [role="button"], input, select, textarea, [data-el], [data-amplifyup-component], [data-component-id]'
|
|
1831
|
+
);
|
|
1832
|
+
const target = interactive instanceof HTMLElement ? interactive : raw;
|
|
1833
|
+
e.preventDefault();
|
|
1834
|
+
e.stopPropagation();
|
|
1835
|
+
e.stopImmediatePropagation();
|
|
1819
1836
|
const selector = this.generateSelectorForElement(target);
|
|
1820
1837
|
const tagName = target.tagName.toLowerCase();
|
|
1821
|
-
const text = target.textContent
|
|
1838
|
+
const text = (target.textContent || "").replace(/\s+/g, " ").trim().substring(0, 80);
|
|
1822
1839
|
if (window.parent && window.parent !== window) {
|
|
1823
1840
|
window.parent.postMessage({
|
|
1824
1841
|
type: "ELEMENT_CLICKED_FOR_EVENT",
|
|
@@ -1827,9 +1844,6 @@ Available Console Commands:
|
|
|
1827
1844
|
text
|
|
1828
1845
|
}, "*");
|
|
1829
1846
|
}
|
|
1830
|
-
if (tagName === "a") {
|
|
1831
|
-
e.preventDefault();
|
|
1832
|
-
}
|
|
1833
1847
|
};
|
|
1834
1848
|
document.addEventListener("click", this.eventSelectionClickHandler, true);
|
|
1835
1849
|
if (this.config?.debug) {
|
|
@@ -2039,6 +2053,7 @@ Available Console Commands:
|
|
|
2039
2053
|
this.applyComponentHighlights(highlightComponents, showZones);
|
|
2040
2054
|
this.setupMutationObserver();
|
|
2041
2055
|
this.setupComposerDragDrop();
|
|
2056
|
+
this.setupComposerBoundsTracking();
|
|
2042
2057
|
}
|
|
2043
2058
|
previouslySelected.forEach((el) => {
|
|
2044
2059
|
if (document.contains(el)) {
|
|
@@ -2193,6 +2208,52 @@ Available Console Commands:
|
|
|
2193
2208
|
this.clearComposerSelection();
|
|
2194
2209
|
element.classList.add("amplifyup-selected");
|
|
2195
2210
|
}
|
|
2211
|
+
postComposerSelectionBounds() {
|
|
2212
|
+
if (typeof document === "undefined") return;
|
|
2213
|
+
if (!window.parent || window.parent === window) return;
|
|
2214
|
+
const el = document.querySelector(".amplifyup-selected");
|
|
2215
|
+
if (!el) return;
|
|
2216
|
+
const rect = el.getBoundingClientRect();
|
|
2217
|
+
window.parent.postMessage(
|
|
2218
|
+
{
|
|
2219
|
+
type: "SELECTION_BOUNDS",
|
|
2220
|
+
bounds: {
|
|
2221
|
+
top: rect.top,
|
|
2222
|
+
left: rect.left,
|
|
2223
|
+
width: rect.width,
|
|
2224
|
+
height: rect.height
|
|
2225
|
+
}
|
|
2226
|
+
},
|
|
2227
|
+
"*"
|
|
2228
|
+
);
|
|
2229
|
+
}
|
|
2230
|
+
setupComposerBoundsTracking() {
|
|
2231
|
+
if (typeof document === "undefined") return;
|
|
2232
|
+
this.teardownComposerBoundsTracking();
|
|
2233
|
+
const onScroll = () => {
|
|
2234
|
+
if (this.composerBoundsRaf) return;
|
|
2235
|
+
this.composerBoundsRaf = requestAnimationFrame(() => {
|
|
2236
|
+
this.composerBoundsRaf = 0;
|
|
2237
|
+
this.postComposerSelectionBounds();
|
|
2238
|
+
});
|
|
2239
|
+
};
|
|
2240
|
+
this.composerBoundsScrollListener = onScroll;
|
|
2241
|
+
document.addEventListener("scroll", onScroll, { capture: true, passive: true });
|
|
2242
|
+
window.addEventListener("scroll", onScroll, { capture: true, passive: true });
|
|
2243
|
+
window.addEventListener("resize", onScroll);
|
|
2244
|
+
}
|
|
2245
|
+
teardownComposerBoundsTracking() {
|
|
2246
|
+
const onScroll = this.composerBoundsScrollListener;
|
|
2247
|
+
this.composerBoundsScrollListener = null;
|
|
2248
|
+
if (this.composerBoundsRaf) {
|
|
2249
|
+
cancelAnimationFrame(this.composerBoundsRaf);
|
|
2250
|
+
this.composerBoundsRaf = 0;
|
|
2251
|
+
}
|
|
2252
|
+
if (!onScroll || typeof document === "undefined") return;
|
|
2253
|
+
document.removeEventListener("scroll", onScroll, true);
|
|
2254
|
+
window.removeEventListener("scroll", onScroll, true);
|
|
2255
|
+
window.removeEventListener("resize", onScroll);
|
|
2256
|
+
}
|
|
2196
2257
|
/** Visual outlines for Composer (direct iframe path — no preview-frame proxy). */
|
|
2197
2258
|
injectComposerHighlightStyles(highlightComponents, showZones) {
|
|
2198
2259
|
if (typeof document === "undefined") return;
|
|
@@ -2360,6 +2421,7 @@ Available Console Commands:
|
|
|
2360
2421
|
if (typeof document === "undefined") return;
|
|
2361
2422
|
const clearSelection = opts?.clearSelection !== false;
|
|
2362
2423
|
this.highlightingEnabled = false;
|
|
2424
|
+
this.teardownComposerBoundsTracking();
|
|
2363
2425
|
this.teardownComposerDragDrop();
|
|
2364
2426
|
if (opts?.clearSelection !== false && typeof window !== "undefined") {
|
|
2365
2427
|
window.__AMPLIFYUP_COMPOSER_EDIT__ = false;
|