@amplifyup/sdk 0.1.60 → 0.1.61
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.js +48 -7
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +48 -7
- package/dist/react.mjs.map +1 -1
- package/package.json +1 -1
package/dist/react.js
CHANGED
|
@@ -3746,6 +3746,20 @@ function canInlineEditRichText(name, value) {
|
|
|
3746
3746
|
}
|
|
3747
3747
|
return true;
|
|
3748
3748
|
}
|
|
3749
|
+
function isLikelyImagePropName(name) {
|
|
3750
|
+
const n = name.toLowerCase();
|
|
3751
|
+
return n.includes("image") || n.includes("thumbnail") || n.includes("photo") || n.includes("avatar") || n.includes("poster") || n.includes("logo") || n.endsWith("img") || n.endsWith("_src") || n.endsWith("Src");
|
|
3752
|
+
}
|
|
3753
|
+
function portableImageUrl(value) {
|
|
3754
|
+
if (typeof value === "string") return value.trim();
|
|
3755
|
+
if (value && typeof value === "object" && !Array.isArray(value) && "url" in value) {
|
|
3756
|
+
const url = value.url;
|
|
3757
|
+
if (url == null) return "";
|
|
3758
|
+
if (typeof url === "string") return url.trim();
|
|
3759
|
+
return null;
|
|
3760
|
+
}
|
|
3761
|
+
return null;
|
|
3762
|
+
}
|
|
3749
3763
|
function inferEditName(explicitName, contextProps, sourceValue) {
|
|
3750
3764
|
if (explicitName) return explicitName;
|
|
3751
3765
|
if (!contextProps) return "";
|
|
@@ -3753,6 +3767,22 @@ function inferEditName(explicitName, contextProps, sourceValue) {
|
|
|
3753
3767
|
(key) => Object.is(contextProps[key], sourceValue)
|
|
3754
3768
|
);
|
|
3755
3769
|
if (keys.length === 1) return keys[0];
|
|
3770
|
+
const srcUrl = portableImageUrl(sourceValue);
|
|
3771
|
+
if (srcUrl !== null) {
|
|
3772
|
+
const byUrl = Object.keys(contextProps).filter((key) => {
|
|
3773
|
+
const other = portableImageUrl(contextProps[key]);
|
|
3774
|
+
return other !== null && other === srcUrl;
|
|
3775
|
+
});
|
|
3776
|
+
if (byUrl.length === 1) return byUrl[0];
|
|
3777
|
+
if (srcUrl === "") {
|
|
3778
|
+
const emptyImageKeys = Object.keys(contextProps).filter((key) => {
|
|
3779
|
+
if (!isLikelyImagePropName(key)) return false;
|
|
3780
|
+
const other = portableImageUrl(contextProps[key]);
|
|
3781
|
+
return other === "" || contextProps[key] == null;
|
|
3782
|
+
});
|
|
3783
|
+
if (emptyImageKeys.length === 1) return emptyImageKeys[0];
|
|
3784
|
+
}
|
|
3785
|
+
}
|
|
3756
3786
|
if (keys.length === 0 || isComposerEmptyText(sourceValue)) return "";
|
|
3757
3787
|
return keys[0];
|
|
3758
3788
|
}
|
|
@@ -4282,6 +4312,11 @@ function Image(props) {
|
|
|
4282
4312
|
"data-amplifyup-field-type": "image",
|
|
4283
4313
|
"data-amplifyup-node-id": context?.layoutNodeId || void 0
|
|
4284
4314
|
} : null;
|
|
4315
|
+
if (composerEdit && !editName && (hasExplicitValue || name)) {
|
|
4316
|
+
console.warn(
|
|
4317
|
+
'[AmplifyUp SDK] Image could not infer a Composer field name from value={\u2026}. Pass name="yourProp" (same as the component prop) so the image can be selected.'
|
|
4318
|
+
);
|
|
4319
|
+
}
|
|
4285
4320
|
if (!src) {
|
|
4286
4321
|
if (!composerEdit || !fieldAttrs) return null;
|
|
4287
4322
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -4292,14 +4327,16 @@ function Image(props) {
|
|
|
4292
4327
|
role: "img",
|
|
4293
4328
|
"aria-label": alt || editName || "Image",
|
|
4294
4329
|
style: {
|
|
4295
|
-
display: "
|
|
4296
|
-
|
|
4297
|
-
|
|
4298
|
-
|
|
4330
|
+
display: "block",
|
|
4331
|
+
boxSizing: "border-box",
|
|
4332
|
+
minWidth: width ? void 0 : 120,
|
|
4333
|
+
minHeight: height ? void 0 : 80,
|
|
4334
|
+
width: width || "100%",
|
|
4299
4335
|
height: height || void 0,
|
|
4300
4336
|
background: "color-mix(in srgb, currentColor 8%, transparent)",
|
|
4301
|
-
outline: "
|
|
4302
|
-
outlineOffset: 2
|
|
4337
|
+
outline: "2px dashed hsl(82 100% 45%)",
|
|
4338
|
+
outlineOffset: 2,
|
|
4339
|
+
cursor: "pointer"
|
|
4303
4340
|
}
|
|
4304
4341
|
}
|
|
4305
4342
|
);
|
|
@@ -4313,7 +4350,11 @@ function Image(props) {
|
|
|
4313
4350
|
alt,
|
|
4314
4351
|
className,
|
|
4315
4352
|
width,
|
|
4316
|
-
height
|
|
4353
|
+
height,
|
|
4354
|
+
style: {
|
|
4355
|
+
...typeof imgProps.style === "object" && imgProps.style ? imgProps.style : {},
|
|
4356
|
+
...composerEdit && fieldAttrs ? { cursor: "pointer" } : null
|
|
4357
|
+
}
|
|
4317
4358
|
}
|
|
4318
4359
|
);
|
|
4319
4360
|
}
|