@amplifyup/sdk 0.1.30 → 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-6qEnwLda.mjs';
4
- export { Z as ZoneConfig } from './types-6qEnwLda.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-6qEnwLda.js';
4
- export { Z as ZoneConfig } from './types-6qEnwLda.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
@@ -1618,6 +1618,11 @@ Available Console Commands:
1618
1618
  if (config.componentName) {
1619
1619
  properties.componentName = config.componentName;
1620
1620
  }
1621
+ if (config.staticProperties) {
1622
+ for (const [key, value] of Object.entries(config.staticProperties)) {
1623
+ if (key) properties[key] = value;
1624
+ }
1625
+ }
1621
1626
  if (config.properties && config.properties.length > 0) {
1622
1627
  config.properties.forEach((prop) => {
1623
1628
  const dataAttrValue = element.getAttribute(`data-${prop}`);
@@ -1984,13 +1989,23 @@ Available Console Commands:
1984
1989
  document.removeEventListener("click", this.eventSelectionClickHandler, true);
1985
1990
  this.eventSelectionClickHandler = null;
1986
1991
  }
1992
+ if (enabled && typeof window !== "undefined" && window.__AMPLIFYUP_PREVIEW_MODE__) {
1993
+ return;
1994
+ }
1987
1995
  if (enabled) {
1988
1996
  this.eventSelectionClickHandler = (e) => {
1989
- const target = e.target;
1990
- 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();
1991
2006
  const selector = this.generateSelectorForElement(target);
1992
2007
  const tagName = target.tagName.toLowerCase();
1993
- const text = target.textContent?.trim().substring(0, 50) || "";
2008
+ const text = (target.textContent || "").replace(/\s+/g, " ").trim().substring(0, 80);
1994
2009
  if (window.parent && window.parent !== window) {
1995
2010
  window.parent.postMessage({
1996
2011
  type: "ELEMENT_CLICKED_FOR_EVENT",
@@ -1999,9 +2014,6 @@ Available Console Commands:
1999
2014
  text
2000
2015
  }, "*");
2001
2016
  }
2002
- if (tagName === "a") {
2003
- e.preventDefault();
2004
- }
2005
2017
  };
2006
2018
  document.addEventListener("click", this.eventSelectionClickHandler, true);
2007
2019
  if (this.config?.debug) {
@@ -3195,6 +3207,54 @@ function RichText({
3195
3207
  }
3196
3208
  return /* @__PURE__ */ jsxRuntime.jsx(Tag, { className, dangerouslySetInnerHTML: { __html: html } });
3197
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
+ }
3198
3258
  var ComponentRenderBoundary = class extends react.Component {
3199
3259
  constructor() {
3200
3260
  super(...arguments);
@@ -3911,6 +3971,7 @@ exports.AmplifyRenderer = AmplifyRenderer;
3911
3971
  exports.AmplifyUpProvider = AmplifyUpProvider;
3912
3972
  exports.ComponentContextProvider = ComponentContextProvider;
3913
3973
  exports.Field = Field;
3974
+ exports.Image = Image;
3914
3975
  exports.RichText = RichText;
3915
3976
  exports.Slot = Slot;
3916
3977
  exports.fetchPageConfigServer = fetchPageConfigServer;