@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.mjs CHANGED
@@ -440,7 +440,8 @@ function mapResolvedToPageConfig(payload) {
440
440
  meta: {
441
441
  // Stash edge meta for diagnostics (not visitor-facing)
442
442
  description: payload.meta?.degraded ? "degraded" : void 0
443
- }
443
+ },
444
+ ...payload.eventTracking && payload.eventTracking.length > 0 ? { eventTracking: payload.eventTracking } : {}
444
445
  };
445
446
  }
446
447
  function collectDegraded(payload) {
@@ -1615,6 +1616,11 @@ Available Console Commands:
1615
1616
  if (config.componentName) {
1616
1617
  properties.componentName = config.componentName;
1617
1618
  }
1619
+ if (config.staticProperties) {
1620
+ for (const [key, value] of Object.entries(config.staticProperties)) {
1621
+ if (key) properties[key] = value;
1622
+ }
1623
+ }
1618
1624
  if (config.properties && config.properties.length > 0) {
1619
1625
  config.properties.forEach((prop) => {
1620
1626
  const dataAttrValue = element.getAttribute(`data-${prop}`);
@@ -1981,13 +1987,23 @@ Available Console Commands:
1981
1987
  document.removeEventListener("click", this.eventSelectionClickHandler, true);
1982
1988
  this.eventSelectionClickHandler = null;
1983
1989
  }
1990
+ if (enabled && typeof window !== "undefined" && window.__AMPLIFYUP_PREVIEW_MODE__) {
1991
+ return;
1992
+ }
1984
1993
  if (enabled) {
1985
1994
  this.eventSelectionClickHandler = (e) => {
1986
- const target = e.target;
1987
- 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();
1988
2004
  const selector = this.generateSelectorForElement(target);
1989
2005
  const tagName = target.tagName.toLowerCase();
1990
- const text = target.textContent?.trim().substring(0, 50) || "";
2006
+ const text = (target.textContent || "").replace(/\s+/g, " ").trim().substring(0, 80);
1991
2007
  if (window.parent && window.parent !== window) {
1992
2008
  window.parent.postMessage({
1993
2009
  type: "ELEMENT_CLICKED_FOR_EVENT",
@@ -1996,9 +2012,6 @@ Available Console Commands:
1996
2012
  text
1997
2013
  }, "*");
1998
2014
  }
1999
- if (tagName === "a") {
2000
- e.preventDefault();
2001
- }
2002
2015
  };
2003
2016
  document.addEventListener("click", this.eventSelectionClickHandler, true);
2004
2017
  if (this.config?.debug) {
@@ -3192,6 +3205,54 @@ function RichText({
3192
3205
  }
3193
3206
  return /* @__PURE__ */ jsx(Tag, { className, dangerouslySetInnerHTML: { __html: html } });
3194
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
+ }
3195
3256
  var ComponentRenderBoundary = class extends Component {
3196
3257
  constructor() {
3197
3258
  super(...arguments);
@@ -3308,7 +3369,7 @@ function AmplifyRenderer({
3308
3369
  window.clearTimeout(t1);
3309
3370
  window.clearTimeout(t2);
3310
3371
  };
3311
- }, [pageConfig?.id]);
3372
+ }, [pageConfig?.id, pageConfig?.eventTracking]);
3312
3373
  useEffect(() => {
3313
3374
  if (!pageConfig) return;
3314
3375
  const t = window.setTimeout(() => {
@@ -3903,6 +3964,6 @@ function useAmplifyUp() {
3903
3964
  return context;
3904
3965
  }
3905
3966
 
3906
- 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 };
3907
3968
  //# sourceMappingURL=react.mjs.map
3908
3969
  //# sourceMappingURL=react.mjs.map