@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.mjs CHANGED
@@ -1616,6 +1616,11 @@ Available Console Commands:
1616
1616
  if (config.componentName) {
1617
1617
  properties.componentName = config.componentName;
1618
1618
  }
1619
+ if (config.staticProperties) {
1620
+ for (const [key, value] of Object.entries(config.staticProperties)) {
1621
+ if (key) properties[key] = value;
1622
+ }
1623
+ }
1619
1624
  if (config.properties && config.properties.length > 0) {
1620
1625
  config.properties.forEach((prop) => {
1621
1626
  const dataAttrValue = element.getAttribute(`data-${prop}`);
@@ -1982,13 +1987,23 @@ Available Console Commands:
1982
1987
  document.removeEventListener("click", this.eventSelectionClickHandler, true);
1983
1988
  this.eventSelectionClickHandler = null;
1984
1989
  }
1990
+ if (enabled && typeof window !== "undefined" && window.__AMPLIFYUP_PREVIEW_MODE__) {
1991
+ return;
1992
+ }
1985
1993
  if (enabled) {
1986
1994
  this.eventSelectionClickHandler = (e) => {
1987
- const target = e.target;
1988
- if (!target) return;
1995
+ const raw = e.target;
1996
+ if (!raw) return;
1997
+ const interactive = raw.closest(
1998
+ 'a, button, [role="button"], input, select, textarea, [data-el], [data-amplifyup-component], [data-component-id]'
1999
+ );
2000
+ const target = interactive instanceof HTMLElement ? interactive : raw;
2001
+ e.preventDefault();
2002
+ e.stopPropagation();
2003
+ e.stopImmediatePropagation();
1989
2004
  const selector = this.generateSelectorForElement(target);
1990
2005
  const tagName = target.tagName.toLowerCase();
1991
- const text = target.textContent?.trim().substring(0, 50) || "";
2006
+ const text = (target.textContent || "").replace(/\s+/g, " ").trim().substring(0, 80);
1992
2007
  if (window.parent && window.parent !== window) {
1993
2008
  window.parent.postMessage({
1994
2009
  type: "ELEMENT_CLICKED_FOR_EVENT",
@@ -1997,9 +2012,6 @@ Available Console Commands:
1997
2012
  text
1998
2013
  }, "*");
1999
2014
  }
2000
- if (tagName === "a") {
2001
- e.preventDefault();
2002
- }
2003
2015
  };
2004
2016
  document.addEventListener("click", this.eventSelectionClickHandler, true);
2005
2017
  if (this.config?.debug) {
@@ -3193,6 +3205,54 @@ function RichText({
3193
3205
  }
3194
3206
  return /* @__PURE__ */ jsx(Tag, { className, dangerouslySetInnerHTML: { __html: html } });
3195
3207
  }
3208
+ function isPortableImageValue(value) {
3209
+ if (!value || typeof value !== "object" || Array.isArray(value)) return false;
3210
+ const url = value.url;
3211
+ return typeof url === "string" && url.trim().length > 0;
3212
+ }
3213
+ function imageSrc(value) {
3214
+ if (typeof value === "string") return value.trim();
3215
+ if (isPortableImageValue(value)) return value.url.trim();
3216
+ return "";
3217
+ }
3218
+ function Image({
3219
+ name,
3220
+ alt: altProp,
3221
+ className,
3222
+ width: widthProp,
3223
+ height: heightProp,
3224
+ ...imgProps
3225
+ }) {
3226
+ const context = useContext(ComponentContext);
3227
+ const fieldValue = useFieldOverlay(
3228
+ context?.layoutNodeId,
3229
+ name,
3230
+ context?.props?.[name]
3231
+ );
3232
+ if (!context) {
3233
+ console.warn(
3234
+ `[AmplifyUp SDK] Image "${name}" used outside ComponentContextProvider`
3235
+ );
3236
+ return null;
3237
+ }
3238
+ const src = imageSrc(fieldValue);
3239
+ if (!src) return null;
3240
+ const portable = isPortableImageValue(fieldValue) ? fieldValue : null;
3241
+ const alt = altProp ?? portable?.alt ?? "";
3242
+ const width = widthProp ?? portable?.width;
3243
+ const height = heightProp ?? portable?.height;
3244
+ return /* @__PURE__ */ jsx(
3245
+ "img",
3246
+ {
3247
+ ...imgProps,
3248
+ src,
3249
+ alt,
3250
+ className,
3251
+ width,
3252
+ height
3253
+ }
3254
+ );
3255
+ }
3196
3256
  var ComponentRenderBoundary = class extends Component {
3197
3257
  constructor() {
3198
3258
  super(...arguments);
@@ -3904,6 +3964,6 @@ function useAmplifyUp() {
3904
3964
  return context;
3905
3965
  }
3906
3966
 
3907
- export { AmplifyPageContent, AmplifyRenderer, AmplifyUpProvider, ComponentContextProvider, Field, RichText, Slot, fetchPageConfigServer, isComposerPreview, isPreviewRequest, useAmplifyUp, useComponentProps, useLiveComposerProps };
3967
+ export { AmplifyPageContent, AmplifyRenderer, AmplifyUpProvider, ComponentContextProvider, Field, Image, RichText, Slot, fetchPageConfigServer, isComposerPreview, isPreviewRequest, useAmplifyUp, useComponentProps, useLiveComposerProps };
3908
3968
  //# sourceMappingURL=react.mjs.map
3909
3969
  //# sourceMappingURL=react.mjs.map