@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.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import React, { ReactNode } from 'react';
|
|
3
|
-
import { P as PageConfig, b as AmplifyUpConfig, C as ContentSource, A as AmplifyContentMeta } from './types-
|
|
4
|
-
export { Z as ZoneConfig } from './types-
|
|
3
|
+
import { P as PageConfig, b as AmplifyUpConfig, C as ContentSource, A as AmplifyContentMeta } from './types-npF_lNoq.mjs';
|
|
4
|
+
export { Z as ZoneConfig } from './types-npF_lNoq.mjs';
|
|
5
5
|
export { AmplifyRenderer } from './AmplifyRenderer.mjs';
|
|
6
6
|
export { i as isComposerPreview, a as isPreviewRequest } from './preview-BMrIgUvp.mjs';
|
|
7
7
|
export { fetchPageConfigServer } from './server.mjs';
|
|
@@ -106,6 +106,21 @@ declare function RichText({ name, fallback, className, as: Tag, }: {
|
|
|
106
106
|
className?: string;
|
|
107
107
|
as?: keyof JSX.IntrinsicElements;
|
|
108
108
|
}): react_jsx_runtime.JSX.Element | null;
|
|
109
|
+
/**
|
|
110
|
+
* Image — renders a provider-backed image field as `<img>`.
|
|
111
|
+
*
|
|
112
|
+
* Values are portable `{ url, alt?, width?, height? }` (or a plain URL string).
|
|
113
|
+
* AmplifyUp does not host image files; the browser loads `url` from the provider CDN.
|
|
114
|
+
*
|
|
115
|
+
* @example
|
|
116
|
+
* ```tsx
|
|
117
|
+
* <Image name="backgroundImage" className="h-full w-full object-cover" />
|
|
118
|
+
* ```
|
|
119
|
+
*/
|
|
120
|
+
declare function Image({ name, alt: altProp, className, width: widthProp, height: heightProp, ...imgProps }: {
|
|
121
|
+
name: string;
|
|
122
|
+
alt?: string;
|
|
123
|
+
} & Omit<React.ImgHTMLAttributes<HTMLImageElement>, 'src' | 'alt' | 'name'>): react_jsx_runtime.JSX.Element | null;
|
|
109
124
|
|
|
110
125
|
interface AmplifyUpContextType {
|
|
111
126
|
pageConfig: PageConfig | null;
|
|
@@ -121,4 +136,4 @@ interface AmplifyUpProviderProps {
|
|
|
121
136
|
declare function AmplifyUpProvider({ children, config }: AmplifyUpProviderProps): react_jsx_runtime.JSX.Element;
|
|
122
137
|
declare function useAmplifyUp(): AmplifyUpContextType;
|
|
123
138
|
|
|
124
|
-
export { AmplifyContentMeta, AmplifyPageContent, AmplifyUpProvider, ComponentContextProvider, ContentSource, Field, PageConfig, RichText, Slot, useAmplifyUp, useComponentProps, useLiveComposerProps };
|
|
139
|
+
export { AmplifyContentMeta, AmplifyPageContent, AmplifyUpProvider, ComponentContextProvider, ContentSource, Field, Image, PageConfig, RichText, Slot, useAmplifyUp, useComponentProps, useLiveComposerProps };
|
package/dist/react.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import React, { ReactNode } from 'react';
|
|
3
|
-
import { P as PageConfig, b as AmplifyUpConfig, C as ContentSource, A as AmplifyContentMeta } from './types-
|
|
4
|
-
export { Z as ZoneConfig } from './types-
|
|
3
|
+
import { P as PageConfig, b as AmplifyUpConfig, C as ContentSource, A as AmplifyContentMeta } from './types-npF_lNoq.js';
|
|
4
|
+
export { Z as ZoneConfig } from './types-npF_lNoq.js';
|
|
5
5
|
export { AmplifyRenderer } from './AmplifyRenderer.js';
|
|
6
6
|
export { i as isComposerPreview, a as isPreviewRequest } from './preview-BMrIgUvp.js';
|
|
7
7
|
export { fetchPageConfigServer } from './server.js';
|
|
@@ -106,6 +106,21 @@ declare function RichText({ name, fallback, className, as: Tag, }: {
|
|
|
106
106
|
className?: string;
|
|
107
107
|
as?: keyof JSX.IntrinsicElements;
|
|
108
108
|
}): react_jsx_runtime.JSX.Element | null;
|
|
109
|
+
/**
|
|
110
|
+
* Image — renders a provider-backed image field as `<img>`.
|
|
111
|
+
*
|
|
112
|
+
* Values are portable `{ url, alt?, width?, height? }` (or a plain URL string).
|
|
113
|
+
* AmplifyUp does not host image files; the browser loads `url` from the provider CDN.
|
|
114
|
+
*
|
|
115
|
+
* @example
|
|
116
|
+
* ```tsx
|
|
117
|
+
* <Image name="backgroundImage" className="h-full w-full object-cover" />
|
|
118
|
+
* ```
|
|
119
|
+
*/
|
|
120
|
+
declare function Image({ name, alt: altProp, className, width: widthProp, height: heightProp, ...imgProps }: {
|
|
121
|
+
name: string;
|
|
122
|
+
alt?: string;
|
|
123
|
+
} & Omit<React.ImgHTMLAttributes<HTMLImageElement>, 'src' | 'alt' | 'name'>): react_jsx_runtime.JSX.Element | null;
|
|
109
124
|
|
|
110
125
|
interface AmplifyUpContextType {
|
|
111
126
|
pageConfig: PageConfig | null;
|
|
@@ -121,4 +136,4 @@ interface AmplifyUpProviderProps {
|
|
|
121
136
|
declare function AmplifyUpProvider({ children, config }: AmplifyUpProviderProps): react_jsx_runtime.JSX.Element;
|
|
122
137
|
declare function useAmplifyUp(): AmplifyUpContextType;
|
|
123
138
|
|
|
124
|
-
export { AmplifyContentMeta, AmplifyPageContent, AmplifyUpProvider, ComponentContextProvider, ContentSource, Field, PageConfig, RichText, Slot, useAmplifyUp, useComponentProps, useLiveComposerProps };
|
|
139
|
+
export { AmplifyContentMeta, AmplifyPageContent, AmplifyUpProvider, ComponentContextProvider, ContentSource, Field, Image, PageConfig, RichText, Slot, useAmplifyUp, useComponentProps, useLiveComposerProps };
|
package/dist/react.js
CHANGED
|
@@ -565,6 +565,8 @@ var AmplifyUpSDK = class {
|
|
|
565
565
|
this.showZonesEnabled = false;
|
|
566
566
|
this.componentRegistry = [];
|
|
567
567
|
this.messageListener = null;
|
|
568
|
+
this.composerBoundsRaf = 0;
|
|
569
|
+
this.composerBoundsScrollListener = null;
|
|
568
570
|
this.mutationObserver = null;
|
|
569
571
|
this.composerDragHandlers = null;
|
|
570
572
|
/** Last slot highlighted during Composer drag — avoid clear/re-add flicker. */
|
|
@@ -1618,6 +1620,11 @@ Available Console Commands:
|
|
|
1618
1620
|
if (config.componentName) {
|
|
1619
1621
|
properties.componentName = config.componentName;
|
|
1620
1622
|
}
|
|
1623
|
+
if (config.staticProperties) {
|
|
1624
|
+
for (const [key, value] of Object.entries(config.staticProperties)) {
|
|
1625
|
+
if (key) properties[key] = value;
|
|
1626
|
+
}
|
|
1627
|
+
}
|
|
1621
1628
|
if (config.properties && config.properties.length > 0) {
|
|
1622
1629
|
config.properties.forEach((prop) => {
|
|
1623
1630
|
const dataAttrValue = element.getAttribute(`data-${prop}`);
|
|
@@ -1984,13 +1991,23 @@ Available Console Commands:
|
|
|
1984
1991
|
document.removeEventListener("click", this.eventSelectionClickHandler, true);
|
|
1985
1992
|
this.eventSelectionClickHandler = null;
|
|
1986
1993
|
}
|
|
1994
|
+
if (enabled && typeof window !== "undefined" && window.__AMPLIFYUP_PREVIEW_MODE__) {
|
|
1995
|
+
return;
|
|
1996
|
+
}
|
|
1987
1997
|
if (enabled) {
|
|
1988
1998
|
this.eventSelectionClickHandler = (e) => {
|
|
1989
|
-
const
|
|
1990
|
-
if (!
|
|
1999
|
+
const raw = e.target;
|
|
2000
|
+
if (!raw) return;
|
|
2001
|
+
const interactive = raw.closest(
|
|
2002
|
+
'a, button, [role="button"], input, select, textarea, [data-el], [data-amplifyup-component], [data-component-id]'
|
|
2003
|
+
);
|
|
2004
|
+
const target = interactive instanceof HTMLElement ? interactive : raw;
|
|
2005
|
+
e.preventDefault();
|
|
2006
|
+
e.stopPropagation();
|
|
2007
|
+
e.stopImmediatePropagation();
|
|
1991
2008
|
const selector = this.generateSelectorForElement(target);
|
|
1992
2009
|
const tagName = target.tagName.toLowerCase();
|
|
1993
|
-
const text = target.textContent
|
|
2010
|
+
const text = (target.textContent || "").replace(/\s+/g, " ").trim().substring(0, 80);
|
|
1994
2011
|
if (window.parent && window.parent !== window) {
|
|
1995
2012
|
window.parent.postMessage({
|
|
1996
2013
|
type: "ELEMENT_CLICKED_FOR_EVENT",
|
|
@@ -1999,9 +2016,6 @@ Available Console Commands:
|
|
|
1999
2016
|
text
|
|
2000
2017
|
}, "*");
|
|
2001
2018
|
}
|
|
2002
|
-
if (tagName === "a") {
|
|
2003
|
-
e.preventDefault();
|
|
2004
|
-
}
|
|
2005
2019
|
};
|
|
2006
2020
|
document.addEventListener("click", this.eventSelectionClickHandler, true);
|
|
2007
2021
|
if (this.config?.debug) {
|
|
@@ -2211,6 +2225,7 @@ Available Console Commands:
|
|
|
2211
2225
|
this.applyComponentHighlights(highlightComponents, showZones);
|
|
2212
2226
|
this.setupMutationObserver();
|
|
2213
2227
|
this.setupComposerDragDrop();
|
|
2228
|
+
this.setupComposerBoundsTracking();
|
|
2214
2229
|
}
|
|
2215
2230
|
previouslySelected.forEach((el) => {
|
|
2216
2231
|
if (document.contains(el)) {
|
|
@@ -2365,6 +2380,52 @@ Available Console Commands:
|
|
|
2365
2380
|
this.clearComposerSelection();
|
|
2366
2381
|
element.classList.add("amplifyup-selected");
|
|
2367
2382
|
}
|
|
2383
|
+
postComposerSelectionBounds() {
|
|
2384
|
+
if (typeof document === "undefined") return;
|
|
2385
|
+
if (!window.parent || window.parent === window) return;
|
|
2386
|
+
const el = document.querySelector(".amplifyup-selected");
|
|
2387
|
+
if (!el) return;
|
|
2388
|
+
const rect = el.getBoundingClientRect();
|
|
2389
|
+
window.parent.postMessage(
|
|
2390
|
+
{
|
|
2391
|
+
type: "SELECTION_BOUNDS",
|
|
2392
|
+
bounds: {
|
|
2393
|
+
top: rect.top,
|
|
2394
|
+
left: rect.left,
|
|
2395
|
+
width: rect.width,
|
|
2396
|
+
height: rect.height
|
|
2397
|
+
}
|
|
2398
|
+
},
|
|
2399
|
+
"*"
|
|
2400
|
+
);
|
|
2401
|
+
}
|
|
2402
|
+
setupComposerBoundsTracking() {
|
|
2403
|
+
if (typeof document === "undefined") return;
|
|
2404
|
+
this.teardownComposerBoundsTracking();
|
|
2405
|
+
const onScroll = () => {
|
|
2406
|
+
if (this.composerBoundsRaf) return;
|
|
2407
|
+
this.composerBoundsRaf = requestAnimationFrame(() => {
|
|
2408
|
+
this.composerBoundsRaf = 0;
|
|
2409
|
+
this.postComposerSelectionBounds();
|
|
2410
|
+
});
|
|
2411
|
+
};
|
|
2412
|
+
this.composerBoundsScrollListener = onScroll;
|
|
2413
|
+
document.addEventListener("scroll", onScroll, { capture: true, passive: true });
|
|
2414
|
+
window.addEventListener("scroll", onScroll, { capture: true, passive: true });
|
|
2415
|
+
window.addEventListener("resize", onScroll);
|
|
2416
|
+
}
|
|
2417
|
+
teardownComposerBoundsTracking() {
|
|
2418
|
+
const onScroll = this.composerBoundsScrollListener;
|
|
2419
|
+
this.composerBoundsScrollListener = null;
|
|
2420
|
+
if (this.composerBoundsRaf) {
|
|
2421
|
+
cancelAnimationFrame(this.composerBoundsRaf);
|
|
2422
|
+
this.composerBoundsRaf = 0;
|
|
2423
|
+
}
|
|
2424
|
+
if (!onScroll || typeof document === "undefined") return;
|
|
2425
|
+
document.removeEventListener("scroll", onScroll, true);
|
|
2426
|
+
window.removeEventListener("scroll", onScroll, true);
|
|
2427
|
+
window.removeEventListener("resize", onScroll);
|
|
2428
|
+
}
|
|
2368
2429
|
/** Visual outlines for Composer (direct iframe path — no preview-frame proxy). */
|
|
2369
2430
|
injectComposerHighlightStyles(highlightComponents, showZones) {
|
|
2370
2431
|
if (typeof document === "undefined") return;
|
|
@@ -2532,6 +2593,7 @@ Available Console Commands:
|
|
|
2532
2593
|
if (typeof document === "undefined") return;
|
|
2533
2594
|
const clearSelection = opts?.clearSelection !== false;
|
|
2534
2595
|
this.highlightingEnabled = false;
|
|
2596
|
+
this.teardownComposerBoundsTracking();
|
|
2535
2597
|
this.teardownComposerDragDrop();
|
|
2536
2598
|
if (opts?.clearSelection !== false && typeof window !== "undefined") {
|
|
2537
2599
|
window.__AMPLIFYUP_COMPOSER_EDIT__ = false;
|
|
@@ -3195,6 +3257,54 @@ function RichText({
|
|
|
3195
3257
|
}
|
|
3196
3258
|
return /* @__PURE__ */ jsxRuntime.jsx(Tag, { className, dangerouslySetInnerHTML: { __html: html } });
|
|
3197
3259
|
}
|
|
3260
|
+
function isPortableImageValue(value) {
|
|
3261
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
3262
|
+
const url = value.url;
|
|
3263
|
+
return typeof url === "string" && url.trim().length > 0;
|
|
3264
|
+
}
|
|
3265
|
+
function imageSrc(value) {
|
|
3266
|
+
if (typeof value === "string") return value.trim();
|
|
3267
|
+
if (isPortableImageValue(value)) return value.url.trim();
|
|
3268
|
+
return "";
|
|
3269
|
+
}
|
|
3270
|
+
function Image({
|
|
3271
|
+
name,
|
|
3272
|
+
alt: altProp,
|
|
3273
|
+
className,
|
|
3274
|
+
width: widthProp,
|
|
3275
|
+
height: heightProp,
|
|
3276
|
+
...imgProps
|
|
3277
|
+
}) {
|
|
3278
|
+
const context = react.useContext(ComponentContext);
|
|
3279
|
+
const fieldValue = useFieldOverlay(
|
|
3280
|
+
context?.layoutNodeId,
|
|
3281
|
+
name,
|
|
3282
|
+
context?.props?.[name]
|
|
3283
|
+
);
|
|
3284
|
+
if (!context) {
|
|
3285
|
+
console.warn(
|
|
3286
|
+
`[AmplifyUp SDK] Image "${name}" used outside ComponentContextProvider`
|
|
3287
|
+
);
|
|
3288
|
+
return null;
|
|
3289
|
+
}
|
|
3290
|
+
const src = imageSrc(fieldValue);
|
|
3291
|
+
if (!src) return null;
|
|
3292
|
+
const portable = isPortableImageValue(fieldValue) ? fieldValue : null;
|
|
3293
|
+
const alt = altProp ?? portable?.alt ?? "";
|
|
3294
|
+
const width = widthProp ?? portable?.width;
|
|
3295
|
+
const height = heightProp ?? portable?.height;
|
|
3296
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3297
|
+
"img",
|
|
3298
|
+
{
|
|
3299
|
+
...imgProps,
|
|
3300
|
+
src,
|
|
3301
|
+
alt,
|
|
3302
|
+
className,
|
|
3303
|
+
width,
|
|
3304
|
+
height
|
|
3305
|
+
}
|
|
3306
|
+
);
|
|
3307
|
+
}
|
|
3198
3308
|
var ComponentRenderBoundary = class extends react.Component {
|
|
3199
3309
|
constructor() {
|
|
3200
3310
|
super(...arguments);
|
|
@@ -3911,6 +4021,7 @@ exports.AmplifyRenderer = AmplifyRenderer;
|
|
|
3911
4021
|
exports.AmplifyUpProvider = AmplifyUpProvider;
|
|
3912
4022
|
exports.ComponentContextProvider = ComponentContextProvider;
|
|
3913
4023
|
exports.Field = Field;
|
|
4024
|
+
exports.Image = Image;
|
|
3914
4025
|
exports.RichText = RichText;
|
|
3915
4026
|
exports.Slot = Slot;
|
|
3916
4027
|
exports.fetchPageConfigServer = fetchPageConfigServer;
|