@macive/ui 0.0.25 → 0.0.26

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.
@@ -23,17 +23,16 @@ const errorkSVG = `
23
23
  </svg>
24
24
  `;
25
25
  const fallbackImageURL = `data:image/svg+xml;utf8,${encodeURIComponent(fallbackSVG)}`;
26
- function Image({ alt, sourceSet, source, crossOrigin, onLoad, onError, className, rounded, lazy = true, // Default to false
26
+ function Image({ alt, sourceSet, source, crossOrigin, onLoad, onError, className, rounded, lazy = true, // Default to true
27
27
  style, ...rest }) {
28
28
  const [isLoading, setIsLoading] = (0, react_1.useState)(true);
29
- const [imgSrc, setImgSrc] = (0, react_1.useState)(lazy ? '' : source); // Start with empty src if lazy
29
+ const [imgSrc, setImgSrc] = (0, react_1.useState)(lazy ? null : source); // Use null instead of '' for lazy loading
30
30
  const [isInView, setIsInView] = (0, react_1.useState)(!lazy); // Assume visible if not lazy
31
31
  const imgRef = (0, react_1.useRef)(null);
32
32
  // Intersection Observer for lazy loading
33
33
  (0, react_1.useEffect)(() => {
34
34
  if (!lazy)
35
35
  return;
36
- // Store the current ref value in a variable
37
36
  const currentImgRef = imgRef.current;
38
37
  if (!currentImgRef)
39
38
  return;
@@ -96,7 +95,7 @@ style, ...rest }) {
96
95
  };
97
96
  return (
98
97
  // eslint-disable-next-line @next/next/no-img-element
99
- (0, jsx_runtime_1.jsx)("img", { ...rest, ref: imgRef, alt: alt, src: imgSrc, style: combinedStyle, crossOrigin: crossOrigin, srcSet: sourceSet === null || sourceSet === void 0 ? void 0 : sourceSet.map(({ source, descriptor }) => `${source} ${descriptor || ''}`).join(', '), className: className, loading: lazy ? 'lazy' : 'eager', onError: (e) => {
98
+ (0, jsx_runtime_1.jsx)("img", { ...rest, ref: imgRef, alt: alt, src: imgSrc !== null && imgSrc !== void 0 ? imgSrc : undefined, style: combinedStyle, crossOrigin: crossOrigin, srcSet: sourceSet === null || sourceSet === void 0 ? void 0 : sourceSet.map(({ source, descriptor }) => `${source} ${descriptor || ''}`).join(', '), className: className, loading: lazy ? 'lazy' : 'eager', onError: (e) => {
100
99
  e.currentTarget.src = fallbackImageURL; // Set fallback SVG on error
101
100
  setIsLoading(false);
102
101
  onError === null || onError === void 0 ? void 0 : onError();