@cleartrip/ct-platform-lazy-image 3.9.1-beta.5 → 3.9.1-beta.6

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 +1 @@
1
- {"version":3,"file":"LazyImage.d.ts","sourceRoot":"","sources":["../packages/components/LazyImage/src/LazyImage.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAyC,MAAM,OAAO,CAAC;AAa9D,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,QAAA,MAAM,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CAsFvC,CAAC;AAEF,eAAe,SAAS,CAAC"}
1
+ {"version":3,"file":"LazyImage.d.ts","sourceRoot":"","sources":["../packages/components/LazyImage/src/LazyImage.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAyC,MAAM,OAAO,CAAC;AAa9D,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,QAAA,MAAM,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CA8GvC,CAAC;AAEF,eAAe,SAAS,CAAC"}
@@ -4,6 +4,8 @@ export interface LazyImageProps {
4
4
  height?: number;
5
5
  isLazy?: boolean;
6
6
  inSwiper?: boolean;
7
+ isLoading?: boolean;
8
+ customPlaceholder?: string;
7
9
  [key: string]: any;
8
10
  }
9
11
  //# sourceMappingURL=LazyImage.types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"LazyImage.types.d.ts","sourceRoot":"","sources":["../packages/components/LazyImage/src/LazyImage.types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,cAAc;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACtB"}
1
+ {"version":3,"file":"LazyImage.types.d.ts","sourceRoot":"","sources":["../packages/components/LazyImage/src/LazyImage.types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,cAAc;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAE3B,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACtB"}
@@ -1,2 +1,2 @@
1
- "use strict";var e=require("tslib"),t=require("react/jsx-runtime"),i=require("react"),r=require("@cleartrip/ct-platform-io-hoc"),a=require("@cleartrip/ct-platform-constants"),n=require("@cleartrip/ct-platform-utils");var c="index-module_placeholder__5zI9P",o="index-module_placeholder-img__nUyer",s="index-module_placeholder-img-wrapper__mcqYX";!function(e,t){void 0===t&&(t={});var i=t.insertAt;if("undefined"!=typeof document){var r=document.head||document.getElementsByTagName("head")[0],a=document.createElement("style");a.type="text/css","top"===i&&r.firstChild?r.insertBefore(a,r.firstChild):r.appendChild(a),a.styleSheet?a.styleSheet.cssText=e:a.appendChild(document.createTextNode(e))}}(".index-module_placeholder__5zI9P{padding:8px}.index-module_placeholder-img__nUyer{height:24px!important;width:auto!important}.index-module_placeholder-img-wrapper__mcqYX{align-items:center;background:#fef5f2;border-radius:8px;display:flex;height:100%;justify-content:center;padding:20px 0;width:100%}");exports.LazyImage=function(d){var l=d.src,h=d.width,p=d.height,u=d.isLazy,m=void 0===u||u,g=d.inSwiper,_=void 0!==g&&g,x=e.__rest(d,["src","width","height","isLazy","inSwiper"]),f=i.useState(!m),y=f[0],v=f[1],w=i.useState(m?a.placeholderLogo:l),j=w[0],q=w[1],I=i.useMemo((function(){var e=n.getWidthFromImgUrl(l),t=n.getHeightFromImgUrl(l),i=e&&t&&e/t;return _?{}:{phWidth:h||e,phHeight:p||t,aspectRatio:_&&i?"".concat(i):"auto"}}),[l]),C=I.phWidth,b=I.phHeight,S=I.aspectRatio,z=i.useCallback((function(){return t.jsx("div",{children:t.jsx("div",e.__assign({className:c,style:{width:_?"auto":"".concat(C,"px"),height:_?"auto":"".concat(b,"px"),aspectRatio:_&&S?"".concat(S):"auto"}},{children:t.jsx("div",e.__assign({className:s},{children:t.jsx("img",{src:a.placeholderLogo,className:o})}))}))})}),[l]),L=i.useCallback((function(){var e=new Image;e.onload=function(){q(l),v(!0)},e.src=l}),[l]);return t.jsx(r.IntersectionObserverHOC,e.__assign({onIntersection:L},{children:y?t.jsx("div",e.__assign({style:{width:_?"auto":"".concat(C,"px"),height:_?"auto":"".concat(b,"px"),aspectRatio:_&&S?"".concat(S):"auto"}},{children:t.jsx("img",e.__assign({src:j},x,{style:{width:"100%",height:"100%"}}))})):t.jsx(t.Fragment,{children:z()})}))};
1
+ "use strict";var e=require("tslib"),t=require("react/jsx-runtime"),i=require("react"),a=require("@cleartrip/ct-platform-io-hoc"),r=require("@cleartrip/ct-platform-constants"),c=require("@cleartrip/ct-platform-utils");var o="index-module_placeholder__5zI9P",s="index-module_placeholder-img__nUyer",n="index-module_placeholder-img-wrapper__mcqYX";!function(e,t){void 0===t&&(t={});var i=t.insertAt;if("undefined"!=typeof document){var a=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css","top"===i&&a.firstChild?a.insertBefore(r,a.firstChild):a.appendChild(r),r.styleSheet?r.styleSheet.cssText=e:r.appendChild(document.createTextNode(e))}}(".index-module_placeholder__5zI9P{box-sizing:border-box;padding:8px}.index-module_placeholder-img__nUyer{height:24px!important;width:auto!important}.index-module_placeholder-img-wrapper__mcqYX{align-items:center;background:#fef5f2;border-radius:8px;display:flex;height:100%;justify-content:center;width:100%}");exports.LazyImage=function(d){var l=d.src,h=d.width,p=d.height,u=d.isLazy,m=void 0===u||u,g=d.inSwiper,_=void 0!==g&&g,x=d.isLoading,f=void 0!==x&&x,y=d.customPlaceholder,v=e.__rest(d,["src","width","height","isLazy","inSwiper","isLoading","customPlaceholder"]),j=i.useState(!m),w=j[0],b=j[1],q=i.useState(m?y:l),I=q[0],C=q[1],R=i.useMemo((function(){var e=c.getWidthFromImgUrl(l),t=c.getHeightFromImgUrl(l),i=e&&t&&e/t;return _?{}:{phWidth:h||e,phHeight:p||t,aspectRatio:_&&i?"".concat(i):"auto"}}),[l]),z=i.useCallback((function(){return t.jsx("div",e.__assign({style:{height:"100%"}},{children:t.jsx("div",e.__assign({className:y?"":o,style:{width:_?"auto":"".concat(R.phWidth,"px"),height:_?"100%":"".concat(R.phHeight,"px"),aspectRatio:_&&R.aspectRatio?"".concat(R.aspectRatio):"auto"}},{children:y?t.jsx("img",{src:y,alt:"placeholder_image",fetchPriority:"high"}):t.jsx("div",e.__assign({className:n},{children:t.jsx("img",{src:r.placeholderLogo,className:s})}))}))}))}),[R,f]),L=i.useCallback((function(){var e=new Image;e.onload=function(){C(l),b(!0)},e.src=l}),[l]);return t.jsx(a.IntersectionObserverHOC,e.__assign({onIntersection:L},{children:w?f?t.jsx(t.Fragment,{children:z()}):t.jsx("div",e.__assign({style:{width:_?"auto":"".concat(R.phWidth,"px"),height:_?"auto":"".concat(R.phHeight,"px"),aspectRatio:_&&R.aspectRatio?"".concat(R.aspectRatio):"auto"}},{children:t.jsx("img",e.__assign({src:I},v,{style:{width:"100%",height:"100%"}}))})):t.jsx(t.Fragment,{children:z()})}))};
2
2
  //# sourceMappingURL=ct-platform-lazy-image.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ct-platform-lazy-image.cjs.js","sources":["../../../../node_modules/.pnpm/style-inject@0.3.0/node_modules/style-inject/dist/style-inject.es.js","../packages/components/LazyImage/src/LazyImage.tsx"],"sourcesContent":["function styleInject(css, ref) {\n if ( ref === void 0 ) ref = {};\n var insertAt = ref.insertAt;\n\n if (!css || typeof document === 'undefined') { return; }\n\n var head = document.head || document.getElementsByTagName('head')[0];\n var style = document.createElement('style');\n style.type = 'text/css';\n\n if (insertAt === 'top') {\n if (head.firstChild) {\n head.insertBefore(style, head.firstChild);\n } else {\n head.appendChild(style);\n }\n } else {\n head.appendChild(style);\n }\n\n if (style.styleSheet) {\n style.styleSheet.cssText = css;\n } else {\n style.appendChild(document.createTextNode(css));\n }\n}\n\nexport default styleInject;\n",null],"names":["css","ref","insertAt","document","head","getElementsByTagName","style","createElement","type","firstChild","insertBefore","appendChild","styleSheet","cssText","createTextNode","_a","src","width","height","_b","isLazy","_c","inSwiper","props","__rest","_d","useState","visible","setVisible","_e","placeholderLogo","imgSrc","setImgSrc","_f","useMemo","imageWidth","getWidthFromImgUrl","imageHeight","getHeightFromImgUrl","aspectRatio","phWidth","phHeight","concat","showPlaceholders","useCallback","_jsx","children","__assign","className","styles","jsx","showContent","img","Image","onload","IntersectionObserverHOC","onIntersection","_Fragment","Fragment"],"mappings":"0VAAA,SAAqBA,EAAKC,QACX,IAARA,IAAiBA,EAAM,CAAA,GAC5B,IAAIC,EAAWD,EAAIC,SAEnB,GAAgC,oBAAbC,SAAnB,CAEA,IAAIC,EAAOD,SAASC,MAAQD,SAASE,qBAAqB,QAAQ,GAC9DC,EAAQH,SAASI,cAAc,SACnCD,EAAME,KAAO,WAEI,QAAbN,GACEE,EAAKK,WACPL,EAAKM,aAAaJ,EAAOF,EAAKK,YAKhCL,EAAKO,YAAYL,GAGfA,EAAMM,WACRN,EAAMM,WAAWC,QAAUb,EAE3BM,EAAMK,YAAYR,SAASW,eAAed,GAnBW,CAqBzD,oUCV4C,SAACe,GACzC,IAAAC,EAAGD,EAAAC,IACHC,EAAKF,EAAAE,MACLC,EAAMH,EAAAG,OACNC,EAAaJ,EAAAK,OAAbA,OAAM,IAAAD,GAAOA,EACbE,EAAgBN,EAAAO,SAAhBA,OAAQ,IAAAD,GAAQA,EACbE,EANsCC,EAAAA,OA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ACIzC,MAAO,CACHW,MAAOK,EAAW,OAAS,GAAGoB,OAAAF,EAAW,MACzCtB,OAAQI,EAAW,OAAS,GAAGoB,OAAAD,EAAY,MAC3CF,YACIjB,GAAYiB,EAAc,GAAAG,OAAGH,GAAgB,SAGrD,CAAAO,SAAAD,EAAAK,IAAA,MAAAH,EAAAA,SAAA,CACI/B,IAAKe,GACDR,EAAK,CACTjB,MAAO,CACHW,MAAO,OACPC,OAAQ,cAKpB2B,EAAGK,IAAAO,EAAAC,SAAA,CAAAZ,SAAAH,QAInB","x_google_ignoreList":[0]}
1
+ {"version":3,"file":"ct-platform-lazy-image.cjs.js","sources":["../../../../node_modules/.pnpm/style-inject@0.3.0/node_modules/style-inject/dist/style-inject.es.js","../packages/components/LazyImage/src/LazyImage.tsx"],"sourcesContent":["function styleInject(css, ref) {\n if ( ref === void 0 ) ref = {};\n var insertAt = ref.insertAt;\n\n if (!css || typeof document === 'undefined') { return; }\n\n var head = document.head || document.getElementsByTagName('head')[0];\n var style = document.createElement('style');\n style.type = 'text/css';\n\n if (insertAt === 'top') {\n if (head.firstChild) {\n head.insertBefore(style, head.firstChild);\n } else {\n head.appendChild(style);\n }\n } else {\n head.appendChild(style);\n }\n\n if (style.styleSheet) {\n style.styleSheet.cssText = css;\n } else {\n style.appendChild(document.createTextNode(css));\n }\n}\n\nexport default styleInject;\n",null],"names":["css","ref","insertAt","document","head","getElementsByTagName","style","createElement","type","firstChild","insertBefore","appendChild","styleSheet","cssText","createTextNode","_a","src","width","height","_b","isLazy","_c","inSwiper","_d","isLoading","customPlaceholder","props","__rest","_e","useState","visible","setVisible","_f","imgSrc","setImgSrc","phDimensions","useMemo","imageWidth","getWidthFromImgUrl","imageHeight","getHeightFromImgUrl","aspectRatio","phWidth","phHeight","concat","showPlaceholders","useCallback","_jsx","jsx","__assign","children","className","styles","alt","fetchPriority","placeholderLogo","showContent","img","Image","onload","IntersectionObserverHOC","onIntersection","_Fragment"],"mappings":"0VAAA,SAAqBA,EAAK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oB,GAAK2B,EACpC9C,MAAO,CACHW,MAAOK,EAAW,OAAS,GAAAsB,OAAGT,EAAaO,QAAW,MACtDxB,OAAQI,EACF,OACA,GAAAsB,OAAGT,EAAaQ,SAAY,MAClCF,YACInB,GAAYa,EAAaM,YACnB,GAAAG,OAAGT,EAAaM,aAChB,SAGb,CAAAS,SAAAzB,EACGsB,EACIC,IAAA,MAAA,CAAAhC,IAAKS,EACL4B,IAAK,oBACLC,cAAe,SAGnBP,EAAAA,IAAA,MAAAE,EAAAA,SAAA,CAAKE,UAAWC,aACZL,EACIC,IAAA,MAAA,CAAAhC,IAAKuC,kBACLJ,UAAWC,YAOvC,GAAG,CAACjB,EAAcX,IAEZgC,EAAcV,EAAAA,aAAY,WAC5B,IAAMW,EAAM,IAAIC,MAEhBD,EAAIE,OAAS,WACTzB,EAAUlB,GACVe,GAAW,EACf,EAEA0B,EAAIzC,IAAMA,CACd,GAAG,CAACA,IAEJ,OACI+B,EAAAC,IAACY,0BAAuBX,EAAAA,SAAA,CAACY,eAAgBL,GAAW,CAAAN,SAC/CpB,EACGN,EACIuB,EAAGC,IAAAc,WAAA,CAAAZ,SAAAL,MAEHE,EAAAA,IAAA,MAAAE,WAAA,CACI3C,MAAO,CACHW,MAAOK,EACD,OACA,GAAAsB,OAAGT,EAAaO,QAAW,MACjCxB,OAAQI,EACF,OACA,GAAAsB,OAAGT,EAAaQ,SAAY,MAClCF,YACInB,GAAYa,EAAaM,YACnB,GAAAG,OAAGT,EAAaM,aAChB,SAGd,CAAAS,SAAAH,EAAAC,IAAA,MAAAC,EAAAA,SAAA,CACIjC,IAAKiB,GACDP,EAAK,CACTpB,MAAO,CACHW,MAAO,OACPC,OAAQ,cAMxB6B,EAAAA,IAAGe,EAAAA,SAAA,CAAAZ,SAAAL,QAInB","x_google_ignoreList":[0]}
@@ -1,2 +1,2 @@
1
- import{__rest as e,__assign as t}from"tslib";import{jsx as i,Fragment as r}from"react/jsx-runtime";import{useState as o,useMemo as a,useCallback as c}from"react";import{IntersectionObserverHOC as n}from"@cleartrip/ct-platform-io-hoc";import{placeholderLogo as d}from"@cleartrip/ct-platform-constants";import{getWidthFromImgUrl as p,getHeightFromImgUrl as l}from"@cleartrip/ct-platform-utils";var h="index-module_placeholder__5zI9P",m="index-module_placeholder-img__nUyer",s="index-module_placeholder-img-wrapper__mcqYX";!function(e,t){void 0===t&&(t={});var i=t.insertAt;if("undefined"!=typeof document){var r=document.head||document.getElementsByTagName("head")[0],o=document.createElement("style");o.type="text/css","top"===i&&r.firstChild?r.insertBefore(o,r.firstChild):r.appendChild(o),o.styleSheet?o.styleSheet.cssText=e:o.appendChild(document.createTextNode(e))}}(".index-module_placeholder__5zI9P{padding:8px}.index-module_placeholder-img__nUyer{height:24px!important;width:auto!important}.index-module_placeholder-img-wrapper__mcqYX{align-items:center;background:#fef5f2;border-radius:8px;display:flex;height:100%;justify-content:center;padding:20px 0;width:100%}");var u=function(u){var f=u.src,g=u.width,x=u.height,_=u.isLazy,y=void 0===_||_,v=u.inSwiper,w=void 0!==v&&v,N=e(u,["src","width","height","isLazy","inSwiper"]),z=o(!y),C=z[0],I=z[1],R=o(y?d:f),S=R[0],b=R[1],T=a((function(){var e=p(f),t=l(f),i=e&&t&&e/t;return w?{}:{phWidth:g||e,phHeight:x||t,aspectRatio:w&&i?"".concat(i):"auto"}}),[f]),j=T.phWidth,q=T.phHeight,B=T.aspectRatio,E=c((function(){return i("div",{children:i("div",t({className:h,style:{width:w?"auto":"".concat(j,"px"),height:w?"auto":"".concat(q,"px"),aspectRatio:w&&B?"".concat(B):"auto"}},{children:i("div",t({className:s},{children:i("img",{src:d,className:m})}))}))})}),[f]),H=c((function(){var e=new Image;e.onload=function(){b(f),I(!0)},e.src=f}),[f]);return i(n,t({onIntersection:H},{children:C?i("div",t({style:{width:w?"auto":"".concat(j,"px"),height:w?"auto":"".concat(q,"px"),aspectRatio:w&&B?"".concat(B):"auto"}},{children:i("img",t({src:S},N,{style:{width:"100%",height:"100%"}}))})):i(r,{children:E()})}))};export{u as LazyImage};
1
+ import{__rest as e,__assign as t}from"tslib";import{jsx as i,Fragment as o}from"react/jsx-runtime";import{useState as r,useMemo as a,useCallback as c}from"react";import{IntersectionObserverHOC as d}from"@cleartrip/ct-platform-io-hoc";import{placeholderLogo as n}from"@cleartrip/ct-platform-constants";import{getWidthFromImgUrl as h,getHeightFromImgUrl as l}from"@cleartrip/ct-platform-utils";var p="index-module_placeholder__5zI9P",s="index-module_placeholder-img__nUyer",m="index-module_placeholder-img-wrapper__mcqYX";!function(e,t){void 0===t&&(t={});var i=t.insertAt;if("undefined"!=typeof document){var o=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css","top"===i&&o.firstChild?o.insertBefore(r,o.firstChild):o.appendChild(r),r.styleSheet?r.styleSheet.cssText=e:r.appendChild(document.createTextNode(e))}}(".index-module_placeholder__5zI9P{box-sizing:border-box;padding:8px}.index-module_placeholder-img__nUyer{height:24px!important;width:auto!important}.index-module_placeholder-img-wrapper__mcqYX{align-items:center;background:#fef5f2;border-radius:8px;display:flex;height:100%;justify-content:center;width:100%}");var u=function(u){var g=u.src,f=u.width,x=u.height,_=u.isLazy,y=void 0===_||_,v=u.inSwiper,w=void 0!==v&&v,R=u.isLoading,b=void 0!==R&&R,z=u.customPlaceholder,N=e(u,["src","width","height","isLazy","inSwiper","isLoading","customPlaceholder"]),P=r(!y),C=P[0],I=P[1],L=r(y?z:g),S=L[0],H=L[1],T=a((function(){var e=h(g),t=l(g),i=e&&t&&e/t;return w?{}:{phWidth:f||e,phHeight:x||t,aspectRatio:w&&i?"".concat(i):"auto"}}),[g]),W=c((function(){return i("div",t({style:{height:"100%"}},{children:i("div",t({className:z?"":p,style:{width:w?"auto":"".concat(T.phWidth,"px"),height:w?"100%":"".concat(T.phHeight,"px"),aspectRatio:w&&T.aspectRatio?"".concat(T.aspectRatio):"auto"}},{children:z?i("img",{src:z,alt:"placeholder_image",fetchPriority:"high"}):i("div",t({className:m},{children:i("img",{src:n,className:s})}))}))}))}),[T,b]),j=c((function(){var e=new Image;e.onload=function(){H(g),I(!0)},e.src=g}),[g]);return i(d,t({onIntersection:j},{children:C?b?i(o,{children:W()}):i("div",t({style:{width:w?"auto":"".concat(T.phWidth,"px"),height:w?"auto":"".concat(T.phHeight,"px"),aspectRatio:w&&T.aspectRatio?"".concat(T.aspectRatio):"auto"}},{children:i("img",t({src:S},N,{style:{width:"100%",height:"100%"}}))})):i(o,{children:W()})}))};export{u as LazyImage};
2
2
  //# sourceMappingURL=ct-platform-lazy-image.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ct-platform-lazy-image.esm.js","sources":["../../../../node_modules/.pnpm/style-inject@0.3.0/node_modules/style-inject/dist/style-inject.es.js","../packages/components/LazyImage/src/LazyImage.tsx"],"sourcesContent":["function styleInject(css, ref) {\n if ( ref === void 0 ) ref = {};\n var insertAt = ref.insertAt;\n\n if (!css || typeof document === 'undefined') { return; }\n\n var head = document.head || document.getElementsByTagName('head')[0];\n var style = document.createElement('style');\n style.type = 'text/css';\n\n if (insertAt === 'top') {\n if (head.firstChild) {\n head.insertBefore(style, head.firstChild);\n } else {\n head.appendChild(style);\n }\n } else {\n head.appendChild(style);\n }\n\n if (style.styleSheet) {\n style.styleSheet.cssText = css;\n } else {\n style.appendChild(document.createTextNode(css));\n }\n}\n\nexport default styleInject;\n",null],"names":["css","ref","insertAt","document","head","getElementsByTagName","style","createElement","type","firstChild","insertBefore","appendChild","styleSheet","cssText","createTextNode","LazyImage","_a","src","width","height","_b","isLazy","_c","inSwiper","props","__rest","_d","useState","visible","setVisible","_e","placeholderLogo","imgSrc","setImgSrc","_f","useMemo","imageWidth","getWidthFromImgUrl","imageHeight","getHeightFromImgUrl","aspectRatio","phWidth","phHeight","concat","showPlaceholders","useCallback","_jsx","children","__assign","className","styles","showContent","img","Image","onload","IntersectionObserverHOC","onIntersection","_Fragment"],"mappings":"ygBAAA,SAAqBA,EAAKC,QACX,IAARA,IAAiBA,EAAM,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,MAC3CF,YACIjB,GAAYiB,EAAc,GAAAG,OAAGH,GAAgB,SAGrD,CAAAO,SAAAD,EAAA,MAAAE,EAAA,CAAKC,UAAWC,GAAiC,CAAAH,SAC7CD,EACI,MAAA,CAAA7B,IAAKc,EACLkB,UAAWC,WAMnC,GAAG,CAACjC,IAEEkC,EAAcN,GAAY,WAC5B,IAAMO,EAAM,IAAIC,MAEhBD,EAAIE,OAAS,WACTrB,EAAUhB,GACVY,GAAW,EACf,EAEAuB,EAAInC,IAAMA,CACd,GAAG,CAACA,IAEJ,OACI6B,EAACS,EAAuBP,EAAA,CAACQ,eAAgBL,GACpC,CAAAJ,SAAAnB,EACGkB,EAAA,MAAAE,EAAA,CACI1C,MAAO,CACHY,MAAOK,EAAW,OAAS,GAAGoB,OAAAF,EAAW,MACzCtB,OAAQI,EAAW,OAAS,GAAGoB,OAAAD,EAAY,MAC3CF,YACIjB,GAAYiB,EAAc,GAAAG,OAAGH,GAAgB,SAGrD,CAAAO,SAAAD,EAAA,MAAAE,EAAA,CACI/B,IAAKe,GACDR,EAAK,CACTlB,MAAO,CACHY,MAAO,OACPC,OAAQ,cAKpB2B,EAAGW,EAAA,CAAAV,SAAAH,QAInB","x_google_ignoreList":[0]}
1
+ {"version":3,"file":"ct-platform-lazy-image.esm.js","sources":["../../../../node_modules/.pnpm/style-inject@0.3.0/node_modules/style-inject/dist/style-inject.es.js","../packages/components/LazyImage/src/LazyImage.tsx"],"sourcesContent":["function styleInject(css, ref) {\n if ( ref === void 0 ) ref = {};\n var insertAt = ref.insertAt;\n\n if (!css || typeof document === 'undefined') { return; }\n\n var head = document.head || document.getElementsByTagName('head')[0];\n var style = document.createElement('style');\n style.type = 'text/css';\n\n if (insertAt === 'top') {\n if (head.firstChild) {\n head.insertBefore(style, head.firstChild);\n } else {\n head.appendChild(style);\n }\n } else {\n head.appendChild(style);\n }\n\n if (style.styleSheet) {\n style.styleSheet.cssText = css;\n } else {\n style.appendChild(document.createTextNode(css));\n }\n}\n\nexport default styleInject;\n",null],"names":["css","ref","insertAt","document","head","getElementsByTagName","style","createElement","type","firstChild","insertBefore","appendChild","styleSheet","cssText","createTextNode","LazyImage","_a","src","width","height","_b","isLazy","_c","inSwiper","_d","isLoading","customPlaceholder","props","__rest","_e","useState","visible","setVisible","_f","imgSrc","setImgSrc","phDimensions","useMemo","imageWidth","getWidthFromImgUrl","imageHeight","getHeightFromImgUrl","aspectRatio","phWidth","phHeight","concat","showPlaceholders","useCallback","_jsx","__assign","children","className","styles","alt","fetchPriority","placeholderLogo","showContent","img","Image","onload","IntersectionObserverHOC","onIntersection","_Fragment"],"mappings":"ygBAAA,SAAqBA,EAAKC,QACX,IAARA,IAAiBA,EAAM,CAAA,GAC5B,IAAIC,EAAWD,EAAIC,SAEnB,GAAgC,oBAAbC,SAAnB,CAEA,IAAIC,EAAOD,SAASC,MAAQD,SAASE,qBAAqB,QAAQ,GAC9DC,EAAQH,SAASI,cAAc,SACnCD,EAAME,KAAO,WAEI,QAAbN,GACEE,EAAKK,WACPL,EAAKM,aAAaJ,EAAOF,EAAKK,YAKhCL,EAAKO,YAAYL,GAGfA,EAAMM,WACRN,EAAMM,WAAWC,QAAUb,EAE3BM,EAAMK,YAAYR,SAASW,eAAed,GAnBW,CAqBzD,yTCVM,IAAAe,EAAsC,SAACC,GACzC,IAAAC,EAAGD,EAAAC,IACHC,EAAKF,EAAAE,MACLC,EAAMH,EAAAG,OACNC,EAAAJ,EAAAK,OAAAA,OAAM,IAAAD,GAAOA,EACbE,EAAgBN,EAAAO,SAAhBA,OAAQ,IAAAD,GAAQA,EAChBE,EAAiBR,EAAAS,UAAjBA,OAAY,IAAAD,GAAKA,EACjBE,EAAiBV,EAAAU,kBACdC,EAAKC,EAAAZ,EARiC,8EAUnCa,EAAwBC,GAAUT,GAAjCU,EAAOF,EAAA,GAAEG,EAAUH,EAAA,GACpBI,EAAsBH,EAAST,EAASK,EAAoBT,GAA3DiB,OAAQC,OAETC,EAAeC,GAAQ,WACzB,IA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aAChB,SAGd,CAAAQ,SAAAF,EAAA,MAAAC,EAAA,CACIhC,IAAKiB,GACDP,EAAK,CACTrB,MAAO,CACHY,MAAO,OACPC,OAAQ,cAMxB6B,EAAGc,EAAA,CAAAZ,SAAAJ,QAInB","x_google_ignoreList":[0]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cleartrip/ct-platform-lazy-image",
3
- "version": "3.9.1-beta.5",
3
+ "version": "3.9.1-beta.6",
4
4
  "description": "Lazy Image Component",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/ct-platform-lazy-image.cjs.js",
@@ -11,9 +11,9 @@
11
11
  ],
12
12
  "devDependencies": {},
13
13
  "dependencies": {
14
- "@cleartrip/ct-platform-constants": "3.6.1-beta.4",
15
- "@cleartrip/ct-platform-io-hoc": "3.0.3-beta.15",
16
- "@cleartrip/ct-platform-utils": "3.18.1-beta.4"
14
+ "@cleartrip/ct-platform-constants": "3.6.1-beta.5",
15
+ "@cleartrip/ct-platform-utils": "3.18.1-beta.5",
16
+ "@cleartrip/ct-platform-io-hoc": "3.0.3-beta.16"
17
17
  },
18
18
  "peerDependencies": {
19
19
  "react": ">=16.8.0",