@sesionario/blocks 1.30.1 → 1.31.0

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/index.cjs CHANGED
@@ -1173,6 +1173,34 @@ function useZoomPanGestures(options = {}) {
1173
1173
  clearSnapBack
1174
1174
  };
1175
1175
  }
1176
+ function SafeImage({
1177
+ src,
1178
+ fallback,
1179
+ alt = "",
1180
+ onError,
1181
+ ...imgProps
1182
+ }) {
1183
+ const [failed, setFailed] = React7.useState(false);
1184
+ const resolvedSrc = typeof src === "string" && src.length > 0 ? src : null;
1185
+ React7.useEffect(() => {
1186
+ setFailed(false);
1187
+ }, [resolvedSrc]);
1188
+ if (!resolvedSrc || failed) {
1189
+ return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: fallback });
1190
+ }
1191
+ return /* @__PURE__ */ jsxRuntime.jsx(
1192
+ "img",
1193
+ {
1194
+ ...imgProps,
1195
+ src: resolvedSrc,
1196
+ alt,
1197
+ onError: (event) => {
1198
+ setFailed(true);
1199
+ onError?.(event);
1200
+ }
1201
+ }
1202
+ );
1203
+ }
1176
1204
  function ImageLightbox({
1177
1205
  images,
1178
1206
  index,
@@ -1296,7 +1324,7 @@ function ImageLightbox({
1296
1324
  onPointerUp: handlers.onPointerUp,
1297
1325
  onPointerCancel: handlers.onPointerCancel,
1298
1326
  children: /* @__PURE__ */ jsxRuntime.jsx(
1299
- "img",
1327
+ SafeImage,
1300
1328
  {
1301
1329
  src: images[index],
1302
1330
  alt: "",
@@ -1307,7 +1335,14 @@ function ImageLightbox({
1307
1335
  transition,
1308
1336
  cursor: scale > ZOOM_PAN_MIN_SCALE ? "grab" : "default"
1309
1337
  },
1310
- onTransitionEnd: clearSnapBack
1338
+ onTransitionEnd: clearSnapBack,
1339
+ fallback: /* @__PURE__ */ jsxRuntime.jsx(
1340
+ "div",
1341
+ {
1342
+ "aria-hidden": true,
1343
+ className: "h-48 w-full max-w-md rounded-lg bg-muted"
1344
+ }
1345
+ )
1311
1346
  }
1312
1347
  )
1313
1348
  }
@@ -1421,7 +1456,7 @@ function MediaCarousel({
1421
1456
  onPointerUp: handlers.onPointerUp,
1422
1457
  onPointerCancel: handlers.onPointerCancel,
1423
1458
  children: /* @__PURE__ */ jsxRuntime.jsx(
1424
- "img",
1459
+ SafeImage,
1425
1460
  {
1426
1461
  src: item.src,
1427
1462
  alt: item.alt ?? "",
@@ -1432,7 +1467,14 @@ function MediaCarousel({
1432
1467
  transition,
1433
1468
  cursor: scale > ZOOM_PAN_MIN_SCALE ? "grab" : "default"
1434
1469
  },
1435
- onTransitionEnd: clearSnapBack
1470
+ onTransitionEnd: clearSnapBack,
1471
+ fallback: /* @__PURE__ */ jsxRuntime.jsx(
1472
+ "div",
1473
+ {
1474
+ "aria-hidden": true,
1475
+ className: "h-48 w-full max-w-md rounded-lg bg-muted"
1476
+ }
1477
+ )
1436
1478
  }
1437
1479
  )
1438
1480
  }
@@ -2106,8 +2148,16 @@ function TenantAvatar({
2106
2148
  "flex shrink-0 items-center justify-center overflow-hidden rounded-full font-medium",
2107
2149
  sizeClass
2108
2150
  ),
2109
- style: logo ? void 0 : avatarFallbackStyle(name),
2110
- children: logo ? /* @__PURE__ */ jsxRuntime.jsx("img", { src: logo, alt: "", className: "size-full object-cover" }) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: textClass, children: getInitials(name) })
2151
+ style: avatarFallbackStyle(name),
2152
+ children: /* @__PURE__ */ jsxRuntime.jsx(
2153
+ SafeImage,
2154
+ {
2155
+ src: logo,
2156
+ alt: "",
2157
+ className: "size-full object-cover",
2158
+ fallback: /* @__PURE__ */ jsxRuntime.jsx("span", { className: textClass, children: getInitials(name) })
2159
+ }
2160
+ )
2111
2161
  }
2112
2162
  );
2113
2163
  }
@@ -2627,6 +2677,14 @@ function MenuAvatar({
2627
2677
  sizeClass
2628
2678
  }) {
2629
2679
  const initials = getInitials(name);
2680
+ const initialsFallback = /* @__PURE__ */ jsxRuntime.jsx(
2681
+ "span",
2682
+ {
2683
+ className: "flex size-full items-center justify-center text-xs font-semibold",
2684
+ style: avatarFallbackStyle(name),
2685
+ children: initials
2686
+ }
2687
+ );
2630
2688
  return /* @__PURE__ */ jsxRuntime.jsx(
2631
2689
  "span",
2632
2690
  {
@@ -2634,19 +2692,13 @@ function MenuAvatar({
2634
2692
  "relative flex shrink-0 overflow-hidden rounded-full",
2635
2693
  sizeClass
2636
2694
  ),
2637
- children: image ? /* @__PURE__ */ jsxRuntime.jsx(
2638
- "img",
2695
+ children: /* @__PURE__ */ jsxRuntime.jsx(
2696
+ SafeImage,
2639
2697
  {
2640
2698
  src: image,
2641
2699
  alt: "",
2642
- className: "aspect-square size-full object-cover"
2643
- }
2644
- ) : /* @__PURE__ */ jsxRuntime.jsx(
2645
- "span",
2646
- {
2647
- className: "flex size-full items-center justify-center text-xs font-semibold",
2648
- style: avatarFallbackStyle(name),
2649
- children: initials
2700
+ className: "aspect-square size-full object-cover",
2701
+ fallback: initialsFallback
2650
2702
  }
2651
2703
  )
2652
2704
  }
@@ -3740,30 +3792,31 @@ function AvatarEditorDialog({
3740
3792
  {
3741
3793
  className: "relative w-full h-full rounded-full overflow-hidden bg-muted border-2 border-border flex items-center justify-center",
3742
3794
  style: { width: displaySize, height: displaySize },
3743
- children: value ? /* @__PURE__ */ jsxRuntime.jsx(
3744
- "img",
3795
+ children: /* @__PURE__ */ jsxRuntime.jsx(
3796
+ SafeImage,
3745
3797
  {
3746
- src: value || "/placeholder.svg",
3798
+ src: value,
3747
3799
  alt: "Avatar",
3748
- className: "absolute -inset-px object-cover"
3749
- }
3750
- ) : /* @__PURE__ */ jsxRuntime.jsxs(
3751
- "div",
3752
- {
3753
- className: cn(
3754
- "flex flex-col items-center justify-center text-muted-foreground",
3755
- caption ? "gap-1" : "gap-0"
3756
- ),
3757
- children: [
3758
- /* @__PURE__ */ jsxRuntime.jsx(
3759
- lucideReact.User,
3760
- {
3761
- className: "h-1/2 w-1/2 max-h-[55%] max-w-[55%] shrink-0",
3762
- "aria-hidden": true
3763
- }
3764
- ),
3765
- caption ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs text-center px-1", children: caption }) : null
3766
- ]
3800
+ className: "absolute -inset-px object-cover",
3801
+ fallback: /* @__PURE__ */ jsxRuntime.jsxs(
3802
+ "div",
3803
+ {
3804
+ className: cn(
3805
+ "flex flex-col items-center justify-center text-muted-foreground",
3806
+ caption ? "gap-1" : "gap-0"
3807
+ ),
3808
+ children: [
3809
+ /* @__PURE__ */ jsxRuntime.jsx(
3810
+ lucideReact.User,
3811
+ {
3812
+ className: "h-1/2 w-1/2 max-h-[55%] max-w-[55%] shrink-0",
3813
+ "aria-hidden": true
3814
+ }
3815
+ ),
3816
+ caption ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs text-center px-1", children: caption }) : null
3817
+ ]
3818
+ }
3819
+ )
3767
3820
  }
3768
3821
  )
3769
3822
  }
@@ -8829,15 +8882,16 @@ function ListPanel({
8829
8882
  "span",
8830
8883
  {
8831
8884
  className: "flex size-9 shrink-0 items-center justify-center overflow-hidden rounded-full text-xs font-semibold text-white",
8832
- style: item.avatarUrl ? void 0 : avatarFallbackStyle(item.title),
8833
- children: item.avatarUrl ? /* @__PURE__ */ jsxRuntime.jsx(
8834
- "img",
8885
+ style: avatarFallbackStyle(item.title),
8886
+ children: /* @__PURE__ */ jsxRuntime.jsx(
8887
+ SafeImage,
8835
8888
  {
8836
8889
  src: item.avatarUrl,
8837
8890
  alt: "",
8838
- className: "size-full object-cover"
8891
+ className: "size-full object-cover",
8892
+ fallback: getInitials(item.title)
8839
8893
  }
8840
- ) : getInitials(item.title)
8894
+ )
8841
8895
  }
8842
8896
  ),
8843
8897
  /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "min-w-0 flex-1", children: [
@@ -9414,6 +9468,7 @@ exports.PaymentIcon = PaymentIcon;
9414
9468
  exports.PhoneInput = PhoneInput;
9415
9469
  exports.PlatformAccountMenu = PlatformAccountMenu;
9416
9470
  exports.PlatformNavbar = PlatformNavbar;
9471
+ exports.SafeImage = SafeImage;
9417
9472
  exports.ScrollRestorationProvider = ScrollRestorationProvider;
9418
9473
  exports.SearchCommand = SearchCommand;
9419
9474
  exports.SearchablePicker = SearchablePicker;