dinocollab-core 2.1.10 → 2.1.11

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.
@@ -1,2 +1,2 @@
1
- import{objectWithoutProperties as r,slicedToArray as o,objectSpread2 as a}from"../_virtual/_rollupPluginBabelHelpers.js";import{jsx as t,Fragment as e,jsxs as n}from"react/jsx-runtime";import{useState as l,useEffect as c,Fragment as i}from"react";import{useDebounce as u}from"../hooks/debounce.js";var s=["src","fallbackSrc","alt","loading","debounceDelay"],d=function(d){var f=d.src,m=d.fallbackSrc,p=d.alt,b=d.loading,g=d.debounceDelay,j=void 0===g?0:g,v=r(d,s),S=u(f,j),h=u(m,j),k=j>0?S:f,y=j>0?h:m,x=l(!0),D=o(x,2),L=D[0],P=D[1],_=l(null!=k?k:y),A=o(_,2),B=A[0],E=A[1];c((function(){E(null!=k?k:y),P(!0)}),[k,y]);var F=L&&b?b:t(e,{});return n(i,{children:[F,t("img",a(a({},v),{},{src:B,alt:p,onLoadStart:function(){return P(!0)},onLoad:function(){return P(!1)},onError:function(){E(m),P(!1)}}))]})};export{d as ImageWithFallback,d as default};
1
+ import{objectWithoutProperties as r,slicedToArray as t,objectSpread2 as e}from"../_virtual/_rollupPluginBabelHelpers.js";import{jsx as o,Fragment as n,jsxs as a}from"react/jsx-runtime";import{useState as l,useRef as i,useEffect as u,Fragment as c}from"react";import{useDebounce as s}from"../hooks/debounce.js";var f=["src","fallbackSrc","alt","loading","debounceDelay"],m=function(m){var d=m.src,p=m.fallbackSrc,b=m.alt,y=m.loading,g=m.debounceDelay,h=void 0===g?0:g,j=r(m,f),v=s(d,h),S=s(p,h),k=h>0?v:d,T=h>0?S:p,x=l(!0),D=t(x,2),L=D[0],P=D[1],_=l(null!=k?k:T),A=t(_,2),B=A[0],E=A[1],F=i(null),H=function(){F.current&&(clearTimeout(F.current),F.current=null),F.current=setTimeout((function(){L&&P(!1)}),2e3)};u((function(){E(null!=k?k:T),P(!0)}),[k,T]);var W,q=L&&y?y:o(n,{});return a(c,{children:[q,o("img",e(e(e({},j),(W={},j.style&&(W.style=j.style),L&&(W.style=e(e({},W.style),{},{height:"0!important",transition:"height 0.2s ease-in-out"})),W)),{},{src:B,alt:b,onLoadStart:function(){return P(!0)},onLoad:function(){P(!1),H()},onError:function(){E(p),P(!1),H()}}))]})};export{m as ImageWithFallback,m as default};
2
2
  //# sourceMappingURL=image-with-fallback.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"image-with-fallback.js","sources":["../../src/components/image-with-fallback.tsx"],"sourcesContent":["import { Fragment, useEffect, useState } from 'react'\r\nimport type { FC, ImgHTMLAttributes, ReactNode } from 'react'\r\nimport { useDebounce } from '../hooks'\r\n\r\nexport interface IImageWithFallbackPropsOwner {\r\n src?: string\r\n alt?: string\r\n fallbackSrc: string\r\n loading?: ReactNode\r\n debounceDelay?: number\r\n}\r\n\r\nexport type IImageProps = Omit<ImgHTMLAttributes<HTMLImageElement>, keyof IImageWithFallbackPropsOwner>\r\n\r\nexport interface IImageWithFallbackProps extends IImageProps, IImageWithFallbackPropsOwner {}\r\n\r\nexport const ImageWithFallback: FC<IImageWithFallbackProps> = ({ src, fallbackSrc, alt, loading, debounceDelay = 0, ...props }) => {\r\n const debouncedSrc = useDebounce(src, debounceDelay)\r\n const debouncedFallbackSrc = useDebounce(fallbackSrc, debounceDelay)\r\n\r\n const effectiveSrc = debounceDelay > 0 ? debouncedSrc : src\r\n const effectiveFallbackSrc = debounceDelay > 0 ? debouncedFallbackSrc : fallbackSrc\r\n\r\n const [isLoading, setLoading] = useState(true)\r\n const [imgSrc, setImgSrc] = useState(effectiveSrc ?? effectiveFallbackSrc)\r\n\r\n useEffect(() => {\r\n setImgSrc(effectiveSrc ?? effectiveFallbackSrc)\r\n setLoading(true)\r\n }, [effectiveSrc, effectiveFallbackSrc])\r\n\r\n const loadingElement = isLoading && loading ? loading : <></>\r\n\r\n return (\r\n <Fragment>\r\n {loadingElement}\r\n <img\r\n {...props}\r\n src={imgSrc}\r\n alt={alt}\r\n onLoadStart={() => setLoading(true)}\r\n onLoad={() => setLoading(false)}\r\n onError={() => {\r\n setImgSrc(fallbackSrc)\r\n setLoading(false)\r\n }}\r\n />\r\n </Fragment>\r\n )\r\n}\r\nexport default ImageWithFallback\r\n"],"names":["ImageWithFallback","_ref","src","fallbackSrc","alt","loading","_ref$debounceDelay","debounceDelay","props","_objectWithoutProperties","_excluded","debouncedSrc","useDebounce","debouncedFallbackSrc","effectiveSrc","effectiveFallbackSrc","_useState","useState","_useState2","_slicedToArray","isLoading","setLoading","_useState3","_useState4","imgSrc","setImgSrc","useEffect","loadingElement","_jsx","_jsxs","Fragment","onLoadStart","onLoad","onError"],"mappings":"sWAgBaA,EAAiD,SAAhCC,GAAoG,IAAjEC,EAAGD,EAAHC,IAAKC,EAAWF,EAAXE,YAAaC,EAAGH,EAAHG,IAAKC,EAAOJ,EAAPI,QAAOC,EAAAL,EAAEM,cAAAA,OAAgB,IAAHD,EAAG,EAACA,EAAKE,EAAKC,EAAAR,EAAAS,GACpHC,EAAeC,EAAYV,EAAKK,GAChCM,EAAuBD,EAAYT,EAAaI,GAEhDO,EAAeP,EAAgB,EAAII,EAAeT,EAClDa,EAAuBR,EAAgB,EAAIM,EAAuBV,EAExEa,EAAgCC,GAAS,GAAKC,EAAAC,EAAAH,EAAA,GAAvCI,EAASF,EAAA,GAAEG,EAAUH,EAAA,GAC5BI,EAA4BL,EAASH,QAAAA,EAAgBC,GAAqBQ,EAAAJ,EAAAG,EAAA,GAAnEE,EAAMD,EAAA,GAAEE,EAASF,EAAA,GAExBG,GAAU,WACRD,EAAUX,QAAAA,EAAgBC,GAC1BM,GAAW,EACb,GAAG,CAACP,EAAcC,IAElB,IAAMY,EAAiBP,GAAaf,EAAUA,EAAUuB,QAExD,OACEC,EAACC,aACEH,EACDC,eACMpB,GAAK,GAAA,CACTN,IAAKsB,EACLpB,IAAKA,EACL2B,YAAa,WAAF,OAAQV,GAAW,EAAK,EACnCW,OAAQ,WAAF,OAAQX,GAAW,EAAM,EAC/BY,QAAS,WACPR,EAAUtB,GACVkB,GAAW,EACb,OAIR"}
1
+ {"version":3,"file":"image-with-fallback.js","sources":["../../src/components/image-with-fallback.tsx"],"sourcesContent":["import { Fragment, useEffect, useRef, useState } from 'react'\r\nimport type { CSSProperties, FC, ImgHTMLAttributes, ReactNode } from 'react'\r\nimport { useDebounce } from '../hooks'\r\n\r\nexport interface IImageWithFallbackPropsOwner {\r\n src?: string\r\n alt?: string\r\n fallbackSrc: string\r\n loading?: ReactNode\r\n debounceDelay?: number\r\n}\r\n\r\nexport type IImageProps = Omit<ImgHTMLAttributes<HTMLImageElement>, keyof IImageWithFallbackPropsOwner>\r\n\r\nexport interface IImageWithFallbackProps extends IImageProps, IImageWithFallbackPropsOwner {}\r\n\r\nexport const ImageWithFallback: FC<IImageWithFallbackProps> = ({ src, fallbackSrc, alt, loading, debounceDelay = 0, ...props }) => {\r\n const debouncedSrc = useDebounce(src, debounceDelay)\r\n const debouncedFallbackSrc = useDebounce(fallbackSrc, debounceDelay)\r\n\r\n const effectiveSrc = debounceDelay > 0 ? debouncedSrc : src\r\n const effectiveFallbackSrc = debounceDelay > 0 ? debouncedFallbackSrc : fallbackSrc\r\n\r\n const [isLoading, setLoading] = useState(true)\r\n const [imgSrc, setImgSrc] = useState(effectiveSrc ?? effectiveFallbackSrc)\r\n\r\n const timeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null)\r\n const forceStopLoading = () => {\r\n if (timeoutRef.current) {\r\n clearTimeout(timeoutRef.current)\r\n timeoutRef.current = null\r\n }\r\n timeoutRef.current = setTimeout(() => {\r\n if (isLoading) setLoading(false)\r\n }, 2000)\r\n }\r\n\r\n useEffect(() => {\r\n setImgSrc(effectiveSrc ?? effectiveFallbackSrc)\r\n setLoading(true)\r\n }, [effectiveSrc, effectiveFallbackSrc])\r\n\r\n const loadingElement = isLoading && loading ? loading : <></>\r\n\r\n const mapStyle = () => {\r\n const obj: { style?: CSSProperties } = {}\r\n if (props.style) obj.style = props.style\r\n if (isLoading) obj.style = { ...obj.style, height: '0!important', transition: 'height 0.2s ease-in-out' }\r\n return obj\r\n }\r\n\r\n return (\r\n <Fragment>\r\n {loadingElement}\r\n <img\r\n {...props}\r\n {...mapStyle()}\r\n src={imgSrc}\r\n alt={alt}\r\n onLoadStart={() => setLoading(true)}\r\n onLoad={() => {\r\n setLoading(false)\r\n forceStopLoading()\r\n }}\r\n onError={() => {\r\n setImgSrc(fallbackSrc)\r\n setLoading(false)\r\n forceStopLoading()\r\n }}\r\n />\r\n </Fragment>\r\n )\r\n}\r\nexport default ImageWithFallback\r\n"],"names":["ImageWithFallback","_ref","src","fallbackSrc","alt","loading","_ref$debounceDelay","debounceDelay","props","_objectWithoutProperties","_excluded","debouncedSrc","useDebounce","debouncedFallbackSrc","effectiveSrc","effectiveFallbackSrc","_useState","useState","_useState2","_slicedToArray","isLoading","setLoading","_useState3","_useState4","imgSrc","setImgSrc","timeoutRef","useRef","forceStopLoading","current","clearTimeout","setTimeout","useEffect","obj","loadingElement","_jsx","_jsxs","Fragment","children","_objectSpread","style","height","transition","onLoadStart","onLoad","onError"],"mappings":"kXAgBaA,EAAiD,SAAhCC,GAAoG,IAAjEC,EAAGD,EAAHC,IAAKC,EAAWF,EAAXE,YAAaC,EAAGH,EAAHG,IAAKC,EAAOJ,EAAPI,QAAOC,EAAAL,EAAEM,cAAAA,OAAgB,IAAHD,EAAG,EAACA,EAAKE,EAAKC,EAAAR,EAAAS,GACpHC,EAAeC,EAAYV,EAAKK,GAChCM,EAAuBD,EAAYT,EAAaI,GAEhDO,EAAeP,EAAgB,EAAII,EAAeT,EAClDa,EAAuBR,EAAgB,EAAIM,EAAuBV,EAExEa,EAAgCC,GAAS,GAAKC,EAAAC,EAAAH,EAAA,GAAvCI,EAASF,EAAA,GAAEG,EAAUH,EAAA,GAC5BI,EAA4BL,EAASH,QAAAA,EAAgBC,GAAqBQ,EAAAJ,EAAAG,EAAA,GAAnEE,EAAMD,EAAA,GAAEE,EAASF,EAAA,GAElBG,EAAaC,EAA6C,MAC1DC,EAAmB,WACnBF,EAAWG,UACbC,aAAaJ,EAAWG,SACxBH,EAAWG,QAAU,MAEvBH,EAAWG,QAAUE,YAAW,WAC1BX,GAAWC,GAAW,EAC3B,GAAE,IACJ,EAEDW,GAAU,WACRP,EAAUX,QAAAA,EAAgBC,GAC1BM,GAAW,EACb,GAAG,CAACP,EAAcC,IAElB,IAGQkB,EAHFC,EAAiBd,GAAaf,EAAUA,EAAU8B,QASxD,OACEC,EAACC,EAAQ,CAAAC,SAAA,CACNJ,EACDC,EAAA,MAAAI,EAAAA,EAAAA,EAAA,CAAA,EACM/B,IAVFyB,EAAiC,CAAE,EACrCzB,EAAMgC,QAAOP,EAAIO,MAAQhC,EAAMgC,OAC/BpB,IAAWa,EAAIO,MAAKD,EAAAA,EAAA,CAAA,EAAQN,EAAIO,OAAK,GAAA,CAAEC,OAAQ,cAAeC,WAAY,6BACvET,IAQW,CAAA,EAAA,CACd/B,IAAKsB,EACLpB,IAAKA,EACLuC,YAAa,WAAF,OAAQtB,GAAW,EAAK,EACnCuB,OAAQ,WACNvB,GAAW,GACXO,GACD,EACDiB,QAAS,WACPpB,EAAUtB,GACVkB,GAAW,GACXO,GACF,OAIR"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dinocollab-core",
3
- "version": "2.1.10",
3
+ "version": "2.1.11",
4
4
  "description": "Dinocollab core - libraries for building collaborative applications with React 18",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",