@amplifyup/sdk 0.1.28 → 0.1.30

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) {
@@ -2772,6 +2773,16 @@ function useLiveComposerProps(layoutNodeId, props) {
2772
2773
  }, [layoutNodeId]);
2773
2774
  return live;
2774
2775
  }
2776
+ function useComponentProps() {
2777
+ const context = useContext(ComponentContext);
2778
+ if (!context) {
2779
+ console.warn(
2780
+ "[AmplifyUp SDK] useComponentProps used outside ComponentContextProvider"
2781
+ );
2782
+ return {};
2783
+ }
2784
+ return context.props || {};
2785
+ }
2775
2786
  function ComponentContextProvider({
2776
2787
  children,
2777
2788
  slots,
@@ -3051,6 +3062,33 @@ function formatFieldValue(value) {
3051
3062
  }
3052
3063
  return "";
3053
3064
  }
3065
+ function isLinkListItem(value) {
3066
+ return !!value && typeof value === "object" && !Array.isArray(value);
3067
+ }
3068
+ function renderLinkList(items, className) {
3069
+ const links = items.filter(isLinkListItem).filter((item) => {
3070
+ const label = typeof item.label === "string" ? item.label.trim() : "";
3071
+ const href = typeof item.href === "string" ? item.href.trim() : "";
3072
+ return !!(label || href);
3073
+ });
3074
+ if (links.length === 0) return null;
3075
+ return /* @__PURE__ */ jsx("span", { className, style: { display: "contents" }, children: links.map((item, index) => {
3076
+ const label = typeof item.label === "string" && item.label.trim() ? item.label : typeof item.href === "string" ? item.href : "Link";
3077
+ const href = typeof item.href === "string" && item.href.trim() ? item.href : "#";
3078
+ const style = typeof item.style === "string" ? item.style.trim() : "";
3079
+ return /* @__PURE__ */ jsx(
3080
+ "a",
3081
+ {
3082
+ href,
3083
+ target: item.openInNewTab ? "_blank" : void 0,
3084
+ rel: item.openInNewTab ? "noreferrer" : void 0,
3085
+ "data-amplifyup-action-style": style || void 0,
3086
+ children: label
3087
+ },
3088
+ typeof item._key === "string" && item._key ? item._key : `${href}-${index}`
3089
+ );
3090
+ }) });
3091
+ }
3054
3092
  function Field({
3055
3093
  name,
3056
3094
  fallback,
@@ -3068,6 +3106,9 @@ function Field({
3068
3106
  console.warn(`[AmplifyUp SDK] Field "${name}" used outside ComponentContextProvider`);
3069
3107
  return fallback ? /* @__PURE__ */ jsx(Fragment, { children: fallback }) : null;
3070
3108
  }
3109
+ if (render) {
3110
+ return /* @__PURE__ */ jsx("span", { className, style: { display: "contents" }, children: render(fieldValue) });
3111
+ }
3071
3112
  if (composerEdit && canInlineEdit(name, fieldValue)) {
3072
3113
  return /* @__PURE__ */ jsx(
3073
3114
  ComposerInlineField,
@@ -3076,7 +3117,6 @@ function Field({
3076
3117
  value: fieldValue,
3077
3118
  fallback,
3078
3119
  className,
3079
- render,
3080
3120
  layoutNodeId: context.layoutNodeId,
3081
3121
  componentId: context.componentId
3082
3122
  }
@@ -3085,8 +3125,9 @@ function Field({
3085
3125
  if (fieldValue === void 0 || fieldValue === null) {
3086
3126
  return fallback ? /* @__PURE__ */ jsx("span", { className, children: fallback }) : null;
3087
3127
  }
3088
- if (render) {
3089
- return /* @__PURE__ */ jsx("span", { className, children: render(fieldValue) });
3128
+ if (Array.isArray(fieldValue)) {
3129
+ const list = renderLinkList(fieldValue, className);
3130
+ if (list) return list;
3090
3131
  }
3091
3132
  const text = formatFieldValue(fieldValue);
3092
3133
  if (!text) {
@@ -3268,7 +3309,7 @@ function AmplifyRenderer({
3268
3309
  window.clearTimeout(t1);
3269
3310
  window.clearTimeout(t2);
3270
3311
  };
3271
- }, [pageConfig?.id]);
3312
+ }, [pageConfig?.id, pageConfig?.eventTracking]);
3272
3313
  useEffect(() => {
3273
3314
  if (!pageConfig) return;
3274
3315
  const t = window.setTimeout(() => {
@@ -3863,6 +3904,6 @@ function useAmplifyUp() {
3863
3904
  return context;
3864
3905
  }
3865
3906
 
3866
- export { AmplifyPageContent, AmplifyRenderer, AmplifyUpProvider, ComponentContextProvider, Field, RichText, Slot, fetchPageConfigServer, isComposerPreview, isPreviewRequest, useAmplifyUp, useLiveComposerProps };
3907
+ export { AmplifyPageContent, AmplifyRenderer, AmplifyUpProvider, ComponentContextProvider, Field, RichText, Slot, fetchPageConfigServer, isComposerPreview, isPreviewRequest, useAmplifyUp, useComponentProps, useLiveComposerProps };
3867
3908
  //# sourceMappingURL=react.mjs.map
3868
3909
  //# sourceMappingURL=react.mjs.map