@amplifyup/sdk 0.1.55 → 0.1.56
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 +4 -4
- package/dist/react.d.ts +4 -4
- package/dist/react.js +44 -26
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +44 -26
- package/dist/react.mjs.map +1 -1
- package/package.json +1 -1
package/dist/react.mjs
CHANGED
|
@@ -3679,13 +3679,31 @@ function htmlHasVisualChrome(html) {
|
|
|
3679
3679
|
);
|
|
3680
3680
|
}
|
|
3681
3681
|
function canInlineEdit(name, value) {
|
|
3682
|
-
if (isLikelyNonTextFieldName(name)) return false;
|
|
3682
|
+
if (!name || isLikelyNonTextFieldName(name)) return false;
|
|
3683
3683
|
if (value !== void 0 && value !== null && typeof value === "object") {
|
|
3684
3684
|
return false;
|
|
3685
3685
|
}
|
|
3686
3686
|
if (typeof value === "boolean") return false;
|
|
3687
3687
|
return true;
|
|
3688
3688
|
}
|
|
3689
|
+
function canInlineEditRichText(name, value) {
|
|
3690
|
+
if (!name || isLikelyNonTextFieldName(name)) return false;
|
|
3691
|
+
if (typeof value === "boolean") return false;
|
|
3692
|
+
if (value !== void 0 && value !== null && typeof value === "object" && !Array.isArray(value)) {
|
|
3693
|
+
return false;
|
|
3694
|
+
}
|
|
3695
|
+
return true;
|
|
3696
|
+
}
|
|
3697
|
+
function inferEditName(explicitName, contextProps, sourceValue) {
|
|
3698
|
+
if (explicitName) return explicitName;
|
|
3699
|
+
if (!contextProps) return "";
|
|
3700
|
+
const keys = Object.keys(contextProps).filter(
|
|
3701
|
+
(key) => Object.is(contextProps[key], sourceValue)
|
|
3702
|
+
);
|
|
3703
|
+
if (keys.length === 1) return keys[0];
|
|
3704
|
+
if (keys.length === 0 || isComposerEmptyText(sourceValue)) return "";
|
|
3705
|
+
return keys[0];
|
|
3706
|
+
}
|
|
3689
3707
|
function subscribeComposerEdit(onStoreChange) {
|
|
3690
3708
|
if (typeof window === "undefined") return () => {
|
|
3691
3709
|
};
|
|
@@ -3880,9 +3898,11 @@ function ComposerInlineHtml({
|
|
|
3880
3898
|
const finishEdit = () => {
|
|
3881
3899
|
const el = elRef.current;
|
|
3882
3900
|
if (!el) return;
|
|
3883
|
-
const
|
|
3884
|
-
|
|
3885
|
-
|
|
3901
|
+
const nextHtml = el.innerHTML;
|
|
3902
|
+
const nextText = (el.innerText ?? "").replace(/\u00a0/g, " ").replace(/\n+$/g, "").trim();
|
|
3903
|
+
if (nextText === sourceTextRef.current && nextHtml === html) return;
|
|
3904
|
+
const commitValue = htmlHasVisualChrome(html) || /<[a-z][\s\S]*>/i.test(html) ? nextHtml : nextText;
|
|
3905
|
+
commitComposerField(layoutNodeId, componentId, name, commitValue);
|
|
3886
3906
|
};
|
|
3887
3907
|
return React.createElement(Tag, {
|
|
3888
3908
|
ref: elRef,
|
|
@@ -3924,15 +3944,10 @@ function formatFieldValue(value) {
|
|
|
3924
3944
|
}
|
|
3925
3945
|
function warnProjectionProps(component, name, hasExplicitValue) {
|
|
3926
3946
|
if (process.env.NODE_ENV === "production") return;
|
|
3927
|
-
if (hasExplicitValue
|
|
3928
|
-
console.warn(
|
|
3929
|
-
`[AmplifyUp SDK] ${component}: pass either value={\u2026} or deprecated name="\u2026", not both. Prefer value={\u2026} and omit name.`
|
|
3930
|
-
);
|
|
3931
|
-
return;
|
|
3932
|
-
}
|
|
3947
|
+
if (hasExplicitValue) return;
|
|
3933
3948
|
if (name) {
|
|
3934
3949
|
console.warn(
|
|
3935
|
-
`[AmplifyUp SDK] ${component} \`name\` is deprecated and will be removed. Prefer value={${name}} from your component props
|
|
3950
|
+
`[AmplifyUp SDK] ${component} \`name\` is deprecated and will be removed. Prefer value={${name}} from your component props.`
|
|
3936
3951
|
);
|
|
3937
3952
|
}
|
|
3938
3953
|
}
|
|
@@ -3972,7 +3987,7 @@ function Field(props) {
|
|
|
3972
3987
|
const composerEdit = useComposerEditMode();
|
|
3973
3988
|
const hasExplicitValue = hasOwnProp(props, "value");
|
|
3974
3989
|
const sourceValue = hasExplicitValue ? value : name ? context?.props?.[name] : void 0;
|
|
3975
|
-
const editName =
|
|
3990
|
+
const editName = inferEditName(name, context?.props, sourceValue);
|
|
3976
3991
|
const fieldValue = useFieldOverlay(
|
|
3977
3992
|
context?.layoutNodeId,
|
|
3978
3993
|
editName,
|
|
@@ -3986,6 +4001,20 @@ function Field(props) {
|
|
|
3986
4001
|
return fallback ? /* @__PURE__ */ jsx(Fragment, { children: fallback }) : null;
|
|
3987
4002
|
}
|
|
3988
4003
|
if (render) {
|
|
4004
|
+
if (composerEdit && editName && context && canInlineEdit(editName, fieldValue)) {
|
|
4005
|
+
return /* @__PURE__ */ jsx(
|
|
4006
|
+
ComposerInlineField,
|
|
4007
|
+
{
|
|
4008
|
+
name: editName,
|
|
4009
|
+
value: fieldValue,
|
|
4010
|
+
fallback,
|
|
4011
|
+
className,
|
|
4012
|
+
render,
|
|
4013
|
+
layoutNodeId: context.layoutNodeId,
|
|
4014
|
+
componentId: context.componentId
|
|
4015
|
+
}
|
|
4016
|
+
);
|
|
4017
|
+
}
|
|
3989
4018
|
return /* @__PURE__ */ jsx("span", { className, style: { display: "contents" }, children: render(fieldValue) });
|
|
3990
4019
|
}
|
|
3991
4020
|
if (Array.isArray(fieldValue)) {
|
|
@@ -4039,7 +4068,7 @@ function RichText(props) {
|
|
|
4039
4068
|
const hasValueProp = hasOwnProp(props, "value");
|
|
4040
4069
|
const hasExplicitValue = hasValueProp || childrenValue !== void 0;
|
|
4041
4070
|
const sourceValue = hasValueProp ? value : childrenValue !== void 0 ? childrenValue : name ? context?.props?.[name] : void 0;
|
|
4042
|
-
const editName =
|
|
4071
|
+
const editName = inferEditName(name, context?.props, sourceValue);
|
|
4043
4072
|
const fieldValue = useFieldOverlay(
|
|
4044
4073
|
context?.layoutNodeId,
|
|
4045
4074
|
editName,
|
|
@@ -4052,7 +4081,7 @@ function RichText(props) {
|
|
|
4052
4081
|
return fallback ? /* @__PURE__ */ jsx(Fragment, { children: fallback }) : null;
|
|
4053
4082
|
}
|
|
4054
4083
|
warnProjectionProps("RichText", name, hasExplicitValue);
|
|
4055
|
-
const canEdit = !!
|
|
4084
|
+
const canEdit = !!context && canInlineEditRichText(editName, fieldValue);
|
|
4056
4085
|
if (isComposerEmptyText(fieldValue)) {
|
|
4057
4086
|
if (composerEdit && canEdit && !isReactNodeFallback(fallback) && !classNameIsBlock(className)) {
|
|
4058
4087
|
return /* @__PURE__ */ jsx(
|
|
@@ -4084,17 +4113,6 @@ function RichText(props) {
|
|
|
4084
4113
|
if (!html) {
|
|
4085
4114
|
return fallback ? /* @__PURE__ */ jsx(Tag, { className, children: fallback }) : null;
|
|
4086
4115
|
}
|
|
4087
|
-
if (composerEdit && htmlHasVisualChrome(html)) {
|
|
4088
|
-
return /* @__PURE__ */ jsx(
|
|
4089
|
-
Tag,
|
|
4090
|
-
{
|
|
4091
|
-
className,
|
|
4092
|
-
"data-amplifyup-field": editName || void 0,
|
|
4093
|
-
"data-amplifyup-node-id": context?.layoutNodeId || void 0,
|
|
4094
|
-
dangerouslySetInnerHTML: { __html: html }
|
|
4095
|
-
}
|
|
4096
|
-
);
|
|
4097
|
-
}
|
|
4098
4116
|
if (composerEdit && canEdit) {
|
|
4099
4117
|
return /* @__PURE__ */ jsx(
|
|
4100
4118
|
ComposerInlineHtml,
|
|
@@ -4135,7 +4153,7 @@ function Image(props) {
|
|
|
4135
4153
|
const sourceValue = hasExplicitValue ? value : name ? context?.props?.[name] : void 0;
|
|
4136
4154
|
const fieldValue = useFieldOverlay(
|
|
4137
4155
|
context?.layoutNodeId,
|
|
4138
|
-
|
|
4156
|
+
inferEditName(name, context?.props, sourceValue),
|
|
4139
4157
|
sourceValue
|
|
4140
4158
|
);
|
|
4141
4159
|
warnProjectionProps("Image", name, hasExplicitValue);
|