@cleartrip/ct-platform-lazy-image 3.7.0-beta.20 → 3.7.0-beta.22

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
- "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"),n=require("@cleartrip/ct-platform-utils");var o="index-module_placeholder__wP5wX",c="index-module_placeholder-img__ZY60e",s="index-module_placeholder-img-wrapper__n6YwL";!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__wP5wX{padding:8px}.index-module_placeholder-img__ZY60e{height:24px!important;width:auto!important}.index-module_placeholder-img-wrapper__n6YwL{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),w=f[0],v=f[1],y=i.useState(m?r.placeholderLogo:l),j=y[0],C=y[1],L=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]),b=L.phWidth,q=L.phHeight,I=L.aspectRatio,S=i.useCallback((function(){return t.jsx("div",{children:t.jsx("div",e.__assign({className:o,style:{width:_?"auto":"".concat(b,"px"),height:_?"auto":"".concat(q,"px"),aspectRatio:_&&I?"".concat(I):"auto"}},{children:t.jsx("div",e.__assign({className:s},{children:t.jsx("img",{src:r.placeholderLogo,className:c})}))}))})}),[l]),N=i.useCallback((function(){var e=new Image;e.onload=function(){C(l),v(!0)},e.src=l}),[l]);return t.jsx(a.IntersectionObserverHOC,e.__assign({onIntersection:N},{children:w?t.jsx("div",e.__assign({style:{width:_?"auto":"".concat(b,"px"),height:_?"auto":"".concat(q,"px"),aspectRatio:_&&I?"".concat(I):"auto"}},{children:t.jsx("img",e.__assign({src:j},x,{style:{width:"100%",height:"100%"}}))})):t.jsx(t.Fragment,{children:S()})}))};
2
2
  //# sourceMappingURL=ct-platform-lazy-image.cjs.js.map
@@ -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 n}from"react";import{IntersectionObserverHOC as c}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__wP5wX",m="index-module_placeholder-img__ZY60e",s="index-module_placeholder-img-wrapper__n6YwL";!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__wP5wX{padding:8px}.index-module_placeholder-img__ZY60e{height:24px!important;width:auto!important}.index-module_placeholder-img-wrapper__n6YwL{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,w=u.isLazy,_=void 0===w||w,v=u.inSwiper,y=void 0!==v&&v,N=e(u,["src","width","height","isLazy","inSwiper"]),C=r(!_),L=C[0],R=C[1],S=r(_?d:f),Y=S[0],b=S[1],T=a((function(){var e=p(f),t=l(f),i=e&&t&&e/t;return y?{}:{phWidth:g||e,phHeight:x||t,aspectRatio:y&&i?"".concat(i):"auto"}}),[f]),j=T.phWidth,z=T.phHeight,B=T.aspectRatio,E=n((function(){return i("div",{children:i("div",t({className:h,style:{width:y?"auto":"".concat(j,"px"),height:y?"auto":"".concat(z,"px"),aspectRatio:y&&B?"".concat(B):"auto"}},{children:i("div",t({className:s},{children:i("img",{src:d,className:m})}))}))})}),[f]),H=n((function(){var e=new Image;e.onload=function(){b(f),R(!0)},e.src=f}),[f]);return i(c,t({onIntersection:H},{children:L?i("div",t({style:{width:y?"auto":"".concat(j,"px"),height:y?"auto":"".concat(z,"px"),aspectRatio:y&&B?"".concat(B):"auto"}},{children:i("img",t({src:Y},N,{style:{width:"100%",height:"100%"}}))})):i(o,{children:E()})}))};export{u as LazyImage};
2
2
  //# sourceMappingURL=ct-platform-lazy-image.esm.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cleartrip/ct-platform-lazy-image",
3
- "version": "3.7.0-beta.20",
3
+ "version": "3.7.0-beta.22",
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-io-hoc": "3.0.2",
15
- "@cleartrip/ct-platform-utils": "3.12.0-beta.20",
16
- "@cleartrip/ct-platform-constants": "3.3.2"
14
+ "@cleartrip/ct-platform-constants": "3.3.3-beta.0",
15
+ "@cleartrip/ct-platform-utils": "3.12.0-beta.22",
16
+ "@cleartrip/ct-platform-io-hoc": "3.0.3-beta.0"
17
17
  },
18
18
  "peerDependencies": {
19
19
  "react": ">=16.8.0",