@amplifyup/sdk 0.1.29 → 0.1.31

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/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-BxpG9Gsy.mjs';
4
- export { Z as ZoneConfig } from './types-BxpG9Gsy.mjs';
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-BxpG9Gsy.js';
4
- export { Z as ZoneConfig } from './types-BxpG9Gsy.js';
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
@@ -442,7 +442,8 @@ function mapResolvedToPageConfig(payload) {
442
442
  meta: {
443
443
  // Stash edge meta for diagnostics (not visitor-facing)
444
444
  description: payload.meta?.degraded ? "degraded" : void 0
445
- }
445
+ },
446
+ ...payload.eventTracking && payload.eventTracking.length > 0 ? { eventTracking: payload.eventTracking } : {}
446
447
  };
447
448
  }
448
449
  function collectDegraded(payload) {
@@ -1617,6 +1618,11 @@ Available Console Commands:
1617
1618
  if (config.componentName) {
1618
1619
  properties.componentName = config.componentName;
1619
1620
  }
1621
+ if (config.staticProperties) {
1622
+ for (const [key, value] of Object.entries(config.staticProperties)) {
1623
+ if (key) properties[key] = value;
1624
+ }
1625
+ }
1620
1626
  if (config.properties && config.properties.length > 0) {
1621
1627
  config.properties.forEach((prop) => {
1622
1628
  const dataAttrValue = element.getAttribute(`data-${prop}`);
@@ -1983,13 +1989,23 @@ Available Console Commands:
1983
1989
  document.removeEventListener("click", this.eventSelectionClickHandler, true);
1984
1990
  this.eventSelectionClickHandler = null;
1985
1991
  }
1992
+ if (enabled && typeof window !== "undefined" && window.__AMPLIFYUP_PREVIEW_MODE__) {
1993
+ return;
1994
+ }
1986
1995
  if (enabled) {
1987
1996
  this.eventSelectionClickHandler = (e) => {
1988
- const target = e.target;
1989
- if (!target) return;
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();
1990
2006
  const selector = this.generateSelectorForElement(target);
1991
2007
  const tagName = target.tagName.toLowerCase();
1992
- const text = target.textContent?.trim().substring(0, 50) || "";
2008
+ const text = (target.textContent || "").replace(/\s+/g, " ").trim().substring(0, 80);
1993
2009
  if (window.parent && window.parent !== window) {
1994
2010
  window.parent.postMessage({
1995
2011
  type: "ELEMENT_CLICKED_FOR_EVENT",
@@ -1998,9 +2014,6 @@ Available Console Commands:
1998
2014
  text
1999
2015
  }, "*");
2000
2016
  }
2001
- if (tagName === "a") {
2002
- e.preventDefault();
2003
- }
2004
2017
  };
2005
2018
  document.addEventListener("click", this.eventSelectionClickHandler, true);
2006
2019
  if (this.config?.debug) {
@@ -3194,6 +3207,54 @@ function RichText({
3194
3207
  }
3195
3208
  return /* @__PURE__ */ jsxRuntime.jsx(Tag, { className, dangerouslySetInnerHTML: { __html: html } });
3196
3209
  }
3210
+ function isPortableImageValue(value) {
3211
+ if (!value || typeof value !== "object" || Array.isArray(value)) return false;
3212
+ const url = value.url;
3213
+ return typeof url === "string" && url.trim().length > 0;
3214
+ }
3215
+ function imageSrc(value) {
3216
+ if (typeof value === "string") return value.trim();
3217
+ if (isPortableImageValue(value)) return value.url.trim();
3218
+ return "";
3219
+ }
3220
+ function Image({
3221
+ name,
3222
+ alt: altProp,
3223
+ className,
3224
+ width: widthProp,
3225
+ height: heightProp,
3226
+ ...imgProps
3227
+ }) {
3228
+ const context = react.useContext(ComponentContext);
3229
+ const fieldValue = useFieldOverlay(
3230
+ context?.layoutNodeId,
3231
+ name,
3232
+ context?.props?.[name]
3233
+ );
3234
+ if (!context) {
3235
+ console.warn(
3236
+ `[AmplifyUp SDK] Image "${name}" used outside ComponentContextProvider`
3237
+ );
3238
+ return null;
3239
+ }
3240
+ const src = imageSrc(fieldValue);
3241
+ if (!src) return null;
3242
+ const portable = isPortableImageValue(fieldValue) ? fieldValue : null;
3243
+ const alt = altProp ?? portable?.alt ?? "";
3244
+ const width = widthProp ?? portable?.width;
3245
+ const height = heightProp ?? portable?.height;
3246
+ return /* @__PURE__ */ jsxRuntime.jsx(
3247
+ "img",
3248
+ {
3249
+ ...imgProps,
3250
+ src,
3251
+ alt,
3252
+ className,
3253
+ width,
3254
+ height
3255
+ }
3256
+ );
3257
+ }
3197
3258
  var ComponentRenderBoundary = class extends react.Component {
3198
3259
  constructor() {
3199
3260
  super(...arguments);
@@ -3310,7 +3371,7 @@ function AmplifyRenderer({
3310
3371
  window.clearTimeout(t1);
3311
3372
  window.clearTimeout(t2);
3312
3373
  };
3313
- }, [pageConfig?.id]);
3374
+ }, [pageConfig?.id, pageConfig?.eventTracking]);
3314
3375
  react.useEffect(() => {
3315
3376
  if (!pageConfig) return;
3316
3377
  const t = window.setTimeout(() => {
@@ -3910,6 +3971,7 @@ exports.AmplifyRenderer = AmplifyRenderer;
3910
3971
  exports.AmplifyUpProvider = AmplifyUpProvider;
3911
3972
  exports.ComponentContextProvider = ComponentContextProvider;
3912
3973
  exports.Field = Field;
3974
+ exports.Image = Image;
3913
3975
  exports.RichText = RichText;
3914
3976
  exports.Slot = Slot;
3915
3977
  exports.fetchPageConfigServer = fetchPageConfigServer;