@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/react.mjs
CHANGED
|
@@ -563,6 +563,8 @@ var AmplifyUpSDK = class {
|
|
|
563
563
|
this.showZonesEnabled = false;
|
|
564
564
|
this.componentRegistry = [];
|
|
565
565
|
this.messageListener = null;
|
|
566
|
+
this.composerBoundsRaf = 0;
|
|
567
|
+
this.composerBoundsScrollListener = null;
|
|
566
568
|
this.mutationObserver = null;
|
|
567
569
|
this.composerDragHandlers = null;
|
|
568
570
|
/** Last slot highlighted during Composer drag — avoid clear/re-add flicker. */
|
|
@@ -1616,6 +1618,11 @@ Available Console Commands:
|
|
|
1616
1618
|
if (config.componentName) {
|
|
1617
1619
|
properties.componentName = config.componentName;
|
|
1618
1620
|
}
|
|
1621
|
+
if (config.staticProperties) {
|
|
1622
|
+
for (const [key, value] of Object.entries(config.staticProperties)) {
|
|
1623
|
+
if (key) properties[key] = value;
|
|
1624
|
+
}
|
|
1625
|
+
}
|
|
1619
1626
|
if (config.properties && config.properties.length > 0) {
|
|
1620
1627
|
config.properties.forEach((prop) => {
|
|
1621
1628
|
const dataAttrValue = element.getAttribute(`data-${prop}`);
|
|
@@ -1982,13 +1989,23 @@ Available Console Commands:
|
|
|
1982
1989
|
document.removeEventListener("click", this.eventSelectionClickHandler, true);
|
|
1983
1990
|
this.eventSelectionClickHandler = null;
|
|
1984
1991
|
}
|
|
1992
|
+
if (enabled && typeof window !== "undefined" && window.__AMPLIFYUP_PREVIEW_MODE__) {
|
|
1993
|
+
return;
|
|
1994
|
+
}
|
|
1985
1995
|
if (enabled) {
|
|
1986
1996
|
this.eventSelectionClickHandler = (e) => {
|
|
1987
|
-
const
|
|
1988
|
-
if (!
|
|
1997
|
+
const raw = e.target;
|
|
1998
|
+
if (!raw) return;
|
|
1999
|
+
const interactive = raw.closest(
|
|
2000
|
+
'a, button, [role="button"], input, select, textarea, [data-el], [data-amplifyup-component], [data-component-id]'
|
|
2001
|
+
);
|
|
2002
|
+
const target = interactive instanceof HTMLElement ? interactive : raw;
|
|
2003
|
+
e.preventDefault();
|
|
2004
|
+
e.stopPropagation();
|
|
2005
|
+
e.stopImmediatePropagation();
|
|
1989
2006
|
const selector = this.generateSelectorForElement(target);
|
|
1990
2007
|
const tagName = target.tagName.toLowerCase();
|
|
1991
|
-
const text = target.textContent
|
|
2008
|
+
const text = (target.textContent || "").replace(/\s+/g, " ").trim().substring(0, 80);
|
|
1992
2009
|
if (window.parent && window.parent !== window) {
|
|
1993
2010
|
window.parent.postMessage({
|
|
1994
2011
|
type: "ELEMENT_CLICKED_FOR_EVENT",
|
|
@@ -1997,9 +2014,6 @@ Available Console Commands:
|
|
|
1997
2014
|
text
|
|
1998
2015
|
}, "*");
|
|
1999
2016
|
}
|
|
2000
|
-
if (tagName === "a") {
|
|
2001
|
-
e.preventDefault();
|
|
2002
|
-
}
|
|
2003
2017
|
};
|
|
2004
2018
|
document.addEventListener("click", this.eventSelectionClickHandler, true);
|
|
2005
2019
|
if (this.config?.debug) {
|
|
@@ -2209,6 +2223,7 @@ Available Console Commands:
|
|
|
2209
2223
|
this.applyComponentHighlights(highlightComponents, showZones);
|
|
2210
2224
|
this.setupMutationObserver();
|
|
2211
2225
|
this.setupComposerDragDrop();
|
|
2226
|
+
this.setupComposerBoundsTracking();
|
|
2212
2227
|
}
|
|
2213
2228
|
previouslySelected.forEach((el) => {
|
|
2214
2229
|
if (document.contains(el)) {
|
|
@@ -2363,6 +2378,52 @@ Available Console Commands:
|
|
|
2363
2378
|
this.clearComposerSelection();
|
|
2364
2379
|
element.classList.add("amplifyup-selected");
|
|
2365
2380
|
}
|
|
2381
|
+
postComposerSelectionBounds() {
|
|
2382
|
+
if (typeof document === "undefined") return;
|
|
2383
|
+
if (!window.parent || window.parent === window) return;
|
|
2384
|
+
const el = document.querySelector(".amplifyup-selected");
|
|
2385
|
+
if (!el) return;
|
|
2386
|
+
const rect = el.getBoundingClientRect();
|
|
2387
|
+
window.parent.postMessage(
|
|
2388
|
+
{
|
|
2389
|
+
type: "SELECTION_BOUNDS",
|
|
2390
|
+
bounds: {
|
|
2391
|
+
top: rect.top,
|
|
2392
|
+
left: rect.left,
|
|
2393
|
+
width: rect.width,
|
|
2394
|
+
height: rect.height
|
|
2395
|
+
}
|
|
2396
|
+
},
|
|
2397
|
+
"*"
|
|
2398
|
+
);
|
|
2399
|
+
}
|
|
2400
|
+
setupComposerBoundsTracking() {
|
|
2401
|
+
if (typeof document === "undefined") return;
|
|
2402
|
+
this.teardownComposerBoundsTracking();
|
|
2403
|
+
const onScroll = () => {
|
|
2404
|
+
if (this.composerBoundsRaf) return;
|
|
2405
|
+
this.composerBoundsRaf = requestAnimationFrame(() => {
|
|
2406
|
+
this.composerBoundsRaf = 0;
|
|
2407
|
+
this.postComposerSelectionBounds();
|
|
2408
|
+
});
|
|
2409
|
+
};
|
|
2410
|
+
this.composerBoundsScrollListener = onScroll;
|
|
2411
|
+
document.addEventListener("scroll", onScroll, { capture: true, passive: true });
|
|
2412
|
+
window.addEventListener("scroll", onScroll, { capture: true, passive: true });
|
|
2413
|
+
window.addEventListener("resize", onScroll);
|
|
2414
|
+
}
|
|
2415
|
+
teardownComposerBoundsTracking() {
|
|
2416
|
+
const onScroll = this.composerBoundsScrollListener;
|
|
2417
|
+
this.composerBoundsScrollListener = null;
|
|
2418
|
+
if (this.composerBoundsRaf) {
|
|
2419
|
+
cancelAnimationFrame(this.composerBoundsRaf);
|
|
2420
|
+
this.composerBoundsRaf = 0;
|
|
2421
|
+
}
|
|
2422
|
+
if (!onScroll || typeof document === "undefined") return;
|
|
2423
|
+
document.removeEventListener("scroll", onScroll, true);
|
|
2424
|
+
window.removeEventListener("scroll", onScroll, true);
|
|
2425
|
+
window.removeEventListener("resize", onScroll);
|
|
2426
|
+
}
|
|
2366
2427
|
/** Visual outlines for Composer (direct iframe path — no preview-frame proxy). */
|
|
2367
2428
|
injectComposerHighlightStyles(highlightComponents, showZones) {
|
|
2368
2429
|
if (typeof document === "undefined") return;
|
|
@@ -2530,6 +2591,7 @@ Available Console Commands:
|
|
|
2530
2591
|
if (typeof document === "undefined") return;
|
|
2531
2592
|
const clearSelection = opts?.clearSelection !== false;
|
|
2532
2593
|
this.highlightingEnabled = false;
|
|
2594
|
+
this.teardownComposerBoundsTracking();
|
|
2533
2595
|
this.teardownComposerDragDrop();
|
|
2534
2596
|
if (opts?.clearSelection !== false && typeof window !== "undefined") {
|
|
2535
2597
|
window.__AMPLIFYUP_COMPOSER_EDIT__ = false;
|
|
@@ -3193,6 +3255,54 @@ function RichText({
|
|
|
3193
3255
|
}
|
|
3194
3256
|
return /* @__PURE__ */ jsx(Tag, { className, dangerouslySetInnerHTML: { __html: html } });
|
|
3195
3257
|
}
|
|
3258
|
+
function isPortableImageValue(value) {
|
|
3259
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
3260
|
+
const url = value.url;
|
|
3261
|
+
return typeof url === "string" && url.trim().length > 0;
|
|
3262
|
+
}
|
|
3263
|
+
function imageSrc(value) {
|
|
3264
|
+
if (typeof value === "string") return value.trim();
|
|
3265
|
+
if (isPortableImageValue(value)) return value.url.trim();
|
|
3266
|
+
return "";
|
|
3267
|
+
}
|
|
3268
|
+
function Image({
|
|
3269
|
+
name,
|
|
3270
|
+
alt: altProp,
|
|
3271
|
+
className,
|
|
3272
|
+
width: widthProp,
|
|
3273
|
+
height: heightProp,
|
|
3274
|
+
...imgProps
|
|
3275
|
+
}) {
|
|
3276
|
+
const context = useContext(ComponentContext);
|
|
3277
|
+
const fieldValue = useFieldOverlay(
|
|
3278
|
+
context?.layoutNodeId,
|
|
3279
|
+
name,
|
|
3280
|
+
context?.props?.[name]
|
|
3281
|
+
);
|
|
3282
|
+
if (!context) {
|
|
3283
|
+
console.warn(
|
|
3284
|
+
`[AmplifyUp SDK] Image "${name}" used outside ComponentContextProvider`
|
|
3285
|
+
);
|
|
3286
|
+
return null;
|
|
3287
|
+
}
|
|
3288
|
+
const src = imageSrc(fieldValue);
|
|
3289
|
+
if (!src) return null;
|
|
3290
|
+
const portable = isPortableImageValue(fieldValue) ? fieldValue : null;
|
|
3291
|
+
const alt = altProp ?? portable?.alt ?? "";
|
|
3292
|
+
const width = widthProp ?? portable?.width;
|
|
3293
|
+
const height = heightProp ?? portable?.height;
|
|
3294
|
+
return /* @__PURE__ */ jsx(
|
|
3295
|
+
"img",
|
|
3296
|
+
{
|
|
3297
|
+
...imgProps,
|
|
3298
|
+
src,
|
|
3299
|
+
alt,
|
|
3300
|
+
className,
|
|
3301
|
+
width,
|
|
3302
|
+
height
|
|
3303
|
+
}
|
|
3304
|
+
);
|
|
3305
|
+
}
|
|
3196
3306
|
var ComponentRenderBoundary = class extends Component {
|
|
3197
3307
|
constructor() {
|
|
3198
3308
|
super(...arguments);
|
|
@@ -3904,6 +4014,6 @@ function useAmplifyUp() {
|
|
|
3904
4014
|
return context;
|
|
3905
4015
|
}
|
|
3906
4016
|
|
|
3907
|
-
export { AmplifyPageContent, AmplifyRenderer, AmplifyUpProvider, ComponentContextProvider, Field, RichText, Slot, fetchPageConfigServer, isComposerPreview, isPreviewRequest, useAmplifyUp, useComponentProps, useLiveComposerProps };
|
|
4017
|
+
export { AmplifyPageContent, AmplifyRenderer, AmplifyUpProvider, ComponentContextProvider, Field, Image, RichText, Slot, fetchPageConfigServer, isComposerPreview, isPreviewRequest, useAmplifyUp, useComponentProps, useLiveComposerProps };
|
|
3908
4018
|
//# sourceMappingURL=react.mjs.map
|
|
3909
4019
|
//# sourceMappingURL=react.mjs.map
|