@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/react.mjs CHANGED
@@ -3740,6 +3740,20 @@ function canInlineEditRichText(name, value) {
3740
3740
  }
3741
3741
  return true;
3742
3742
  }
3743
+ function isLikelyImagePropName(name) {
3744
+ const n = name.toLowerCase();
3745
+ 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");
3746
+ }
3747
+ function portableImageUrl(value) {
3748
+ if (typeof value === "string") return value.trim();
3749
+ if (value && typeof value === "object" && !Array.isArray(value) && "url" in value) {
3750
+ const url = value.url;
3751
+ if (url == null) return "";
3752
+ if (typeof url === "string") return url.trim();
3753
+ return null;
3754
+ }
3755
+ return null;
3756
+ }
3743
3757
  function inferEditName(explicitName, contextProps, sourceValue) {
3744
3758
  if (explicitName) return explicitName;
3745
3759
  if (!contextProps) return "";
@@ -3747,6 +3761,22 @@ function inferEditName(explicitName, contextProps, sourceValue) {
3747
3761
  (key) => Object.is(contextProps[key], sourceValue)
3748
3762
  );
3749
3763
  if (keys.length === 1) return keys[0];
3764
+ const srcUrl = portableImageUrl(sourceValue);
3765
+ if (srcUrl !== null) {
3766
+ const byUrl = Object.keys(contextProps).filter((key) => {
3767
+ const other = portableImageUrl(contextProps[key]);
3768
+ return other !== null && other === srcUrl;
3769
+ });
3770
+ if (byUrl.length === 1) return byUrl[0];
3771
+ if (srcUrl === "") {
3772
+ const emptyImageKeys = Object.keys(contextProps).filter((key) => {
3773
+ if (!isLikelyImagePropName(key)) return false;
3774
+ const other = portableImageUrl(contextProps[key]);
3775
+ return other === "" || contextProps[key] == null;
3776
+ });
3777
+ if (emptyImageKeys.length === 1) return emptyImageKeys[0];
3778
+ }
3779
+ }
3750
3780
  if (keys.length === 0 || isComposerEmptyText(sourceValue)) return "";
3751
3781
  return keys[0];
3752
3782
  }
@@ -4276,6 +4306,11 @@ function Image(props) {
4276
4306
  "data-amplifyup-field-type": "image",
4277
4307
  "data-amplifyup-node-id": context?.layoutNodeId || void 0
4278
4308
  } : null;
4309
+ if (composerEdit && !editName && (hasExplicitValue || name)) {
4310
+ console.warn(
4311
+ '[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.'
4312
+ );
4313
+ }
4279
4314
  if (!src) {
4280
4315
  if (!composerEdit || !fieldAttrs) return null;
4281
4316
  return /* @__PURE__ */ jsx(
@@ -4286,14 +4321,16 @@ function Image(props) {
4286
4321
  role: "img",
4287
4322
  "aria-label": alt || editName || "Image",
4288
4323
  style: {
4289
- display: "inline-block",
4290
- minWidth: width ? void 0 : 48,
4291
- minHeight: height ? void 0 : 48,
4292
- width: width || void 0,
4324
+ display: "block",
4325
+ boxSizing: "border-box",
4326
+ minWidth: width ? void 0 : 120,
4327
+ minHeight: height ? void 0 : 80,
4328
+ width: width || "100%",
4293
4329
  height: height || void 0,
4294
4330
  background: "color-mix(in srgb, currentColor 8%, transparent)",
4295
- outline: "1px dashed color-mix(in srgb, currentColor 40%, transparent)",
4296
- outlineOffset: 2
4331
+ outline: "2px dashed hsl(82 100% 45%)",
4332
+ outlineOffset: 2,
4333
+ cursor: "pointer"
4297
4334
  }
4298
4335
  }
4299
4336
  );
@@ -4307,7 +4344,11 @@ function Image(props) {
4307
4344
  alt,
4308
4345
  className,
4309
4346
  width,
4310
- height
4347
+ height,
4348
+ style: {
4349
+ ...typeof imgProps.style === "object" && imgProps.style ? imgProps.style : {},
4350
+ ...composerEdit && fieldAttrs ? { cursor: "pointer" } : null
4351
+ }
4311
4352
  }
4312
4353
  );
4313
4354
  }