@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.js CHANGED
@@ -1142,6 +1142,9 @@ function useZoomPanGestures(options = {}) {
1142
1142
  clearSnapBack
1143
1143
  };
1144
1144
  }
1145
+ function isBrokenImage(img) {
1146
+ return img.complete && img.naturalWidth === 0;
1147
+ }
1145
1148
  function SafeImage({
1146
1149
  src,
1147
1150
  fallback,
@@ -1150,10 +1153,17 @@ function SafeImage({
1150
1153
  ...imgProps
1151
1154
  }) {
1152
1155
  const [failed, setFailed] = useState(false);
1156
+ const imgRef = useRef(null);
1153
1157
  const resolvedSrc = typeof src === "string" && src.length > 0 ? src : null;
1154
- useEffect(() => {
1158
+ useLayoutEffect(() => {
1155
1159
  setFailed(false);
1156
1160
  }, [resolvedSrc]);
1161
+ useLayoutEffect(() => {
1162
+ const img = imgRef.current;
1163
+ if (img && isBrokenImage(img)) {
1164
+ setFailed(true);
1165
+ }
1166
+ }, [resolvedSrc, failed]);
1157
1167
  if (!resolvedSrc || failed) {
1158
1168
  return /* @__PURE__ */ jsx(Fragment, { children: fallback });
1159
1169
  }
@@ -1161,6 +1171,7 @@ function SafeImage({
1161
1171
  "img",
1162
1172
  {
1163
1173
  ...imgProps,
1174
+ ref: imgRef,
1164
1175
  src: resolvedSrc,
1165
1176
  alt,
1166
1177
  onError: (event) => {
@@ -1640,7 +1651,9 @@ function MediaViewerDialog({
1640
1651
  {
1641
1652
  showCloseButton: false,
1642
1653
  className: cn(
1643
- "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",
1654
+ // flex-col is required: without it the single child is a row item
1655
+ // sized to max-content (toolbar width) and the viewport collapses.
1656
+ "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",
1644
1657
  contentClassName,
1645
1658
  className
1646
1659
  ),
@@ -2110,23 +2123,27 @@ function TenantAvatar({
2110
2123
  }) {
2111
2124
  const sizeClass = size === "sm" ? "size-6" : "size-8";
2112
2125
  const textClass = size === "sm" ? "text-xs" : "text-sm";
2113
- return /* @__PURE__ */ jsx(
2126
+ const initials = getInitials(name);
2127
+ return /* @__PURE__ */ jsxs(
2114
2128
  "div",
2115
2129
  {
2116
2130
  className: cn(
2117
- "flex shrink-0 items-center justify-center overflow-hidden rounded-full font-medium",
2131
+ "relative flex shrink-0 items-center justify-center overflow-hidden rounded-full font-medium",
2118
2132
  sizeClass
2119
2133
  ),
2120
2134
  style: avatarFallbackStyle(name),
2121
- children: /* @__PURE__ */ jsx(
2122
- SafeImage,
2123
- {
2124
- src: logo,
2125
- alt: "",
2126
- className: "size-full object-cover",
2127
- fallback: /* @__PURE__ */ jsx("span", { className: textClass, children: getInitials(name) })
2128
- }
2129
- )
2135
+ children: [
2136
+ /* @__PURE__ */ jsx("span", { className: textClass, children: initials }),
2137
+ logo ? /* @__PURE__ */ jsx(
2138
+ SafeImage,
2139
+ {
2140
+ src: logo,
2141
+ alt: "",
2142
+ className: "absolute inset-0 size-full object-cover",
2143
+ fallback: null
2144
+ }
2145
+ ) : null
2146
+ ]
2130
2147
  }
2131
2148
  );
2132
2149
  }
@@ -2646,30 +2663,26 @@ function MenuAvatar({
2646
2663
  sizeClass
2647
2664
  }) {
2648
2665
  const initials = getInitials(name);
2649
- const initialsFallback = /* @__PURE__ */ jsx(
2650
- "span",
2651
- {
2652
- className: "flex size-full items-center justify-center text-xs font-semibold",
2653
- style: avatarFallbackStyle(name),
2654
- children: initials
2655
- }
2656
- );
2657
- return /* @__PURE__ */ jsx(
2666
+ return /* @__PURE__ */ jsxs(
2658
2667
  "span",
2659
2668
  {
2660
2669
  className: cn(
2661
2670
  "relative flex shrink-0 overflow-hidden rounded-full",
2662
2671
  sizeClass
2663
2672
  ),
2664
- children: /* @__PURE__ */ jsx(
2665
- SafeImage,
2666
- {
2667
- src: image,
2668
- alt: "",
2669
- className: "aspect-square size-full object-cover",
2670
- fallback: initialsFallback
2671
- }
2672
- )
2673
+ style: avatarFallbackStyle(name),
2674
+ children: [
2675
+ /* @__PURE__ */ jsx("span", { className: "flex size-full items-center justify-center text-xs font-semibold", children: initials }),
2676
+ image ? /* @__PURE__ */ jsx(
2677
+ SafeImage,
2678
+ {
2679
+ src: image,
2680
+ alt: "",
2681
+ className: "absolute inset-0 aspect-square size-full object-cover",
2682
+ fallback: null
2683
+ }
2684
+ ) : null
2685
+ ]
2673
2686
  }
2674
2687
  );
2675
2688
  }