@sesionario/blocks 1.31.0 → 1.31.2

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,9 @@ function useZoomPanGestures(options = {}) {
1173
1173
  clearSnapBack
1174
1174
  };
1175
1175
  }
1176
+ function isBrokenImage(img) {
1177
+ return img.complete && img.naturalWidth === 0;
1178
+ }
1176
1179
  function SafeImage({
1177
1180
  src,
1178
1181
  fallback,
@@ -1181,10 +1184,17 @@ function SafeImage({
1181
1184
  ...imgProps
1182
1185
  }) {
1183
1186
  const [failed, setFailed] = React7.useState(false);
1187
+ const imgRef = React7.useRef(null);
1184
1188
  const resolvedSrc = typeof src === "string" && src.length > 0 ? src : null;
1185
- React7.useEffect(() => {
1189
+ React7.useLayoutEffect(() => {
1186
1190
  setFailed(false);
1187
1191
  }, [resolvedSrc]);
1192
+ React7.useLayoutEffect(() => {
1193
+ const img = imgRef.current;
1194
+ if (img && isBrokenImage(img)) {
1195
+ setFailed(true);
1196
+ }
1197
+ }, [resolvedSrc, failed]);
1188
1198
  if (!resolvedSrc || failed) {
1189
1199
  return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: fallback });
1190
1200
  }
@@ -1192,6 +1202,7 @@ function SafeImage({
1192
1202
  "img",
1193
1203
  {
1194
1204
  ...imgProps,
1205
+ ref: imgRef,
1195
1206
  src: resolvedSrc,
1196
1207
  alt,
1197
1208
  onError: (event) => {
@@ -1671,7 +1682,9 @@ function MediaViewerDialog({
1671
1682
  {
1672
1683
  showCloseButton: false,
1673
1684
  className: cn(
1674
- "inset-0 flex h-dvh max-h-dvh w-screen max-w-none translate-x-0 translate-y-0 top-0 left-0 gap-0 overflow-hidden rounded-none border-0 p-0 shadow-none sm:max-w-none",
1685
+ // flex-col is required: without it the single child is a row item
1686
+ // sized to max-content (toolbar width) and the viewport collapses.
1687
+ "inset-0 flex flex-col h-dvh max-h-dvh w-screen max-w-none translate-x-0 translate-y-0 top-0 left-0 gap-0 overflow-hidden rounded-none border-0 p-0 shadow-none sm:max-w-none",
1675
1688
  contentClassName,
1676
1689
  className
1677
1690
  ),
@@ -2141,23 +2154,27 @@ function TenantAvatar({
2141
2154
  }) {
2142
2155
  const sizeClass = size === "sm" ? "size-6" : "size-8";
2143
2156
  const textClass = size === "sm" ? "text-xs" : "text-sm";
2144
- return /* @__PURE__ */ jsxRuntime.jsx(
2157
+ const initials = getInitials(name);
2158
+ return /* @__PURE__ */ jsxRuntime.jsxs(
2145
2159
  "div",
2146
2160
  {
2147
2161
  className: cn(
2148
- "flex shrink-0 items-center justify-center overflow-hidden rounded-full font-medium",
2162
+ "relative flex shrink-0 items-center justify-center overflow-hidden rounded-full font-medium",
2149
2163
  sizeClass
2150
2164
  ),
2151
2165
  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
- )
2166
+ children: [
2167
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: textClass, children: initials }),
2168
+ logo ? /* @__PURE__ */ jsxRuntime.jsx(
2169
+ SafeImage,
2170
+ {
2171
+ src: logo,
2172
+ alt: "",
2173
+ className: "absolute inset-0 size-full object-cover",
2174
+ fallback: null
2175
+ }
2176
+ ) : null
2177
+ ]
2161
2178
  }
2162
2179
  );
2163
2180
  }
@@ -2677,30 +2694,26 @@ function MenuAvatar({
2677
2694
  sizeClass
2678
2695
  }) {
2679
2696
  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
- );
2688
- return /* @__PURE__ */ jsxRuntime.jsx(
2697
+ return /* @__PURE__ */ jsxRuntime.jsxs(
2689
2698
  "span",
2690
2699
  {
2691
2700
  className: cn(
2692
2701
  "relative flex shrink-0 overflow-hidden rounded-full",
2693
2702
  sizeClass
2694
2703
  ),
2695
- children: /* @__PURE__ */ jsxRuntime.jsx(
2696
- SafeImage,
2697
- {
2698
- src: image,
2699
- alt: "",
2700
- className: "aspect-square size-full object-cover",
2701
- fallback: initialsFallback
2702
- }
2703
- )
2704
+ style: avatarFallbackStyle(name),
2705
+ children: [
2706
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex size-full items-center justify-center text-xs font-semibold", children: initials }),
2707
+ image ? /* @__PURE__ */ jsxRuntime.jsx(
2708
+ SafeImage,
2709
+ {
2710
+ src: image,
2711
+ alt: "",
2712
+ className: "absolute inset-0 aspect-square size-full object-cover",
2713
+ fallback: null
2714
+ }
2715
+ ) : null
2716
+ ]
2704
2717
  }
2705
2718
  );
2706
2719
  }