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