@amplifyup/sdk 0.1.28 → 0.1.29
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/AmplifyRenderer.js.map +1 -1
- package/dist/AmplifyRenderer.mjs.map +1 -1
- package/dist/react.d.mts +8 -28
- package/dist/react.d.ts +8 -28
- package/dist/react.js +44 -3
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +44 -4
- package/dist/react.mjs.map +1 -1
- package/package.json +1 -1
package/dist/react.mjs
CHANGED
|
@@ -2772,6 +2772,16 @@ function useLiveComposerProps(layoutNodeId, props) {
|
|
|
2772
2772
|
}, [layoutNodeId]);
|
|
2773
2773
|
return live;
|
|
2774
2774
|
}
|
|
2775
|
+
function useComponentProps() {
|
|
2776
|
+
const context = useContext(ComponentContext);
|
|
2777
|
+
if (!context) {
|
|
2778
|
+
console.warn(
|
|
2779
|
+
"[AmplifyUp SDK] useComponentProps used outside ComponentContextProvider"
|
|
2780
|
+
);
|
|
2781
|
+
return {};
|
|
2782
|
+
}
|
|
2783
|
+
return context.props || {};
|
|
2784
|
+
}
|
|
2775
2785
|
function ComponentContextProvider({
|
|
2776
2786
|
children,
|
|
2777
2787
|
slots,
|
|
@@ -3051,6 +3061,33 @@ function formatFieldValue(value) {
|
|
|
3051
3061
|
}
|
|
3052
3062
|
return "";
|
|
3053
3063
|
}
|
|
3064
|
+
function isLinkListItem(value) {
|
|
3065
|
+
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
3066
|
+
}
|
|
3067
|
+
function renderLinkList(items, className) {
|
|
3068
|
+
const links = items.filter(isLinkListItem).filter((item) => {
|
|
3069
|
+
const label = typeof item.label === "string" ? item.label.trim() : "";
|
|
3070
|
+
const href = typeof item.href === "string" ? item.href.trim() : "";
|
|
3071
|
+
return !!(label || href);
|
|
3072
|
+
});
|
|
3073
|
+
if (links.length === 0) return null;
|
|
3074
|
+
return /* @__PURE__ */ jsx("span", { className, style: { display: "contents" }, children: links.map((item, index) => {
|
|
3075
|
+
const label = typeof item.label === "string" && item.label.trim() ? item.label : typeof item.href === "string" ? item.href : "Link";
|
|
3076
|
+
const href = typeof item.href === "string" && item.href.trim() ? item.href : "#";
|
|
3077
|
+
const style = typeof item.style === "string" ? item.style.trim() : "";
|
|
3078
|
+
return /* @__PURE__ */ jsx(
|
|
3079
|
+
"a",
|
|
3080
|
+
{
|
|
3081
|
+
href,
|
|
3082
|
+
target: item.openInNewTab ? "_blank" : void 0,
|
|
3083
|
+
rel: item.openInNewTab ? "noreferrer" : void 0,
|
|
3084
|
+
"data-amplifyup-action-style": style || void 0,
|
|
3085
|
+
children: label
|
|
3086
|
+
},
|
|
3087
|
+
typeof item._key === "string" && item._key ? item._key : `${href}-${index}`
|
|
3088
|
+
);
|
|
3089
|
+
}) });
|
|
3090
|
+
}
|
|
3054
3091
|
function Field({
|
|
3055
3092
|
name,
|
|
3056
3093
|
fallback,
|
|
@@ -3068,6 +3105,9 @@ function Field({
|
|
|
3068
3105
|
console.warn(`[AmplifyUp SDK] Field "${name}" used outside ComponentContextProvider`);
|
|
3069
3106
|
return fallback ? /* @__PURE__ */ jsx(Fragment, { children: fallback }) : null;
|
|
3070
3107
|
}
|
|
3108
|
+
if (render) {
|
|
3109
|
+
return /* @__PURE__ */ jsx("span", { className, style: { display: "contents" }, children: render(fieldValue) });
|
|
3110
|
+
}
|
|
3071
3111
|
if (composerEdit && canInlineEdit(name, fieldValue)) {
|
|
3072
3112
|
return /* @__PURE__ */ jsx(
|
|
3073
3113
|
ComposerInlineField,
|
|
@@ -3076,7 +3116,6 @@ function Field({
|
|
|
3076
3116
|
value: fieldValue,
|
|
3077
3117
|
fallback,
|
|
3078
3118
|
className,
|
|
3079
|
-
render,
|
|
3080
3119
|
layoutNodeId: context.layoutNodeId,
|
|
3081
3120
|
componentId: context.componentId
|
|
3082
3121
|
}
|
|
@@ -3085,8 +3124,9 @@ function Field({
|
|
|
3085
3124
|
if (fieldValue === void 0 || fieldValue === null) {
|
|
3086
3125
|
return fallback ? /* @__PURE__ */ jsx("span", { className, children: fallback }) : null;
|
|
3087
3126
|
}
|
|
3088
|
-
if (
|
|
3089
|
-
|
|
3127
|
+
if (Array.isArray(fieldValue)) {
|
|
3128
|
+
const list = renderLinkList(fieldValue, className);
|
|
3129
|
+
if (list) return list;
|
|
3090
3130
|
}
|
|
3091
3131
|
const text = formatFieldValue(fieldValue);
|
|
3092
3132
|
if (!text) {
|
|
@@ -3863,6 +3903,6 @@ function useAmplifyUp() {
|
|
|
3863
3903
|
return context;
|
|
3864
3904
|
}
|
|
3865
3905
|
|
|
3866
|
-
export { AmplifyPageContent, AmplifyRenderer, AmplifyUpProvider, ComponentContextProvider, Field, RichText, Slot, fetchPageConfigServer, isComposerPreview, isPreviewRequest, useAmplifyUp, useLiveComposerProps };
|
|
3906
|
+
export { AmplifyPageContent, AmplifyRenderer, AmplifyUpProvider, ComponentContextProvider, Field, RichText, Slot, fetchPageConfigServer, isComposerPreview, isPreviewRequest, useAmplifyUp, useComponentProps, useLiveComposerProps };
|
|
3867
3907
|
//# sourceMappingURL=react.mjs.map
|
|
3868
3908
|
//# sourceMappingURL=react.mjs.map
|