@cleartrip/ct-platform-lazy-image 3.2.1-beta.9 → 3.3.0
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/LazyImage.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LazyImage.d.ts","sourceRoot":"","sources":["../packages/components/LazyImage/src/LazyImage.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"LazyImage.d.ts","sourceRoot":"","sources":["../packages/components/LazyImage/src/LazyImage.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAgC,MAAM,OAAO,CAAC;AAarD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,QAAA,MAAM,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CAkEvC,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var e=require("tslib"),t=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";var e=require("tslib"),t=require("react/jsx-runtime"),r=require("react"),i=require("@cleartrip/ct-platform-io-hoc"),a=require("@cleartrip/ct-platform-constants"),n=require("@cleartrip/ct-platform-utils");var c="index-module_placeholder__5zI9P",d="index-module_placeholder-img__nUyer",o="index-module_placeholder-img-wrapper__mcqYX";!function(e,t){void 0===t&&(t={});var r=t.insertAt;if("undefined"!=typeof document){var i=document.head||document.getElementsByTagName("head")[0],a=document.createElement("style");a.type="text/css","top"===r&&i.firstChild?i.insertBefore(a,i.firstChild):i.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(s){var l=s.src,p=s.width,h=s.height,m=s.isLazy,u=void 0===m||m,g=s.inSwiper,_=void 0!==g&&g,x=e.__rest(s,["src","width","height","isLazy","inSwiper"]),f=r.useState(!u),v=f[0],y=f[1],w=r.useState(u?a.placeholderLogo:l),j=w[0],N=w[1],q=r.useCallback((function(){var r=NaN,i=NaN,s=n.getWidthFromImgUrl(l),m=n.getHeightFromImgUrl(l),u=s&&m&&s/m;return _||(r=p||s,i=h||m),t.jsx("div",{children:t.jsx("div",e.__assign({className:c,style:{width:_?"auto":"".concat(r,"px"),height:_?"auto":"".concat(i,"px"),aspectRatio:_&&u?"".concat(u):"auto"}},{children:t.jsx("div",e.__assign({className:o},{children:t.jsx("img",{src:a.placeholderLogo,className:d})}))}))})}),[l]),I=r.useCallback((function(){var e=new Image;e.onload=function(){N(l),y(!0)},e.src=l}),[l]);return t.jsx(i.IntersectionObserverHOC,e.__assign({onIntersection:I},{children:v?t.jsx("img",e.__assign({src:j},x)):t.jsx(t.Fragment,{children:q()})}))};
|
|
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","
|
|
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","showPlaceholders","useCallback","phWidth","NaN","phHeight","imageWidth","getWidthFromImgUrl","imageHeight","getHeightFromImgUrl","aspectRatio","_jsx","children","__assign","className","styles","concat","jsx","showContent","img","Image","onload","IntersectionObserverHOC","onIntersection","_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,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AInC,IAAMA,CACd,GAAG,CAACA,IAEJ,OACI2B,MAACW,EAAAA,wBAAuBT,EAAAA,SAAA,CAACU,eAAgBL,GACpC,CAAAN,SAAAjB,EACGgB,wBAAK3B,IAAKe,GAAYR,IAEtBoB,EAAAA,IAAGa,EAAAA,SAAA,CAAAZ,SAAAX,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,
|
|
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,useCallback as a}from"react";import{IntersectionObserverHOC as n}from"@cleartrip/ct-platform-io-hoc";import{placeholderLogo as d}from"@cleartrip/ct-platform-constants";import{getWidthFromImgUrl as c,getHeightFromImgUrl as l}from"@cleartrip/ct-platform-utils";var m="index-module_placeholder__5zI9P",p="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 h=function(h){var u=h.src,f=h.width,g=h.height,x=h.isLazy,_=void 0===x||x,v=h.inSwiper,y=void 0!==v&&v,w=e(h,["src","width","height","isLazy","inSwiper"]),N=o(!_),z=N[0],C=N[1],I=o(_?d:u),S=I[0],b=I[1],T=a((function(){var e=NaN,r=NaN,o=c(u),a=l(u),n=o&&a&&o/a;return y||(e=f||o,r=g||a),i("div",{children:i("div",t({className:m,style:{width:y?"auto":"".concat(e,"px"),height:y?"auto":"".concat(r,"px"),aspectRatio:y&&n?"".concat(n):"auto"}},{children:i("div",t({className:s},{children:i("img",{src:d,className:p})}))}))})}),[u]),j=a((function(){var e=new Image;e.onload=function(){b(u),C(!0)},e.src=u}),[u]);return i(n,t({onIntersection:j},{children:z?i("img",t({src:S},w)):i(r,{children:T()})}))};export{h 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","
|
|
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","showPlaceholders","useCallback","phWidth","NaN","phHeight","imageWidth","getWidthFromImgUrl","imageHeight","getHeightFromImgUrl","aspectRatio","_jsx","children","__assign","className","styles","concat","showContent","img","Image","onload","IntersectionObserverHOC","onIntersection","_Fragment"],"mappings":"4fAAA,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,kTCVM,IAAAe,EAAsC,SAACC,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,EAAAT,EAAA,CAAA,MAAA,QAAA,SAAA,SAAA,aAQnCU,EAAwBC,GAAUN,GAAjCO,EAAOF,EAAA,GAAEG,EAAUH,EAAA,GACpBI,EAAsBH,EAASN,EAASU,EAAkBd,GAAzDe,OAAQC,OAETC,EAAmBC,GAAY,WACjC,IAAIC,EAAkBC,IAClBC,EAAmBD,IACjBE,EAAaC,EAAmBvB,GAChCwB,EAAcC,EAAoBzB,GAClC0B,EACFJ,GAAcE,GAAeF,EAAaE,EAO9C,OALKlB,IACDa,EAAUlB,GAAUqB,EACpBD,EAAWnB,GAAWsB,GAItBG,EACI,MAAA,CAAAC,SAAAD,EAAA,MAAAE,EAAA,CACIC,UAAWC,EACX1C,MAAO,CACHY,MAAOK,EAAW,OAAS,GAAG0B,OAAAb,EAAW,MACzCjB,OAAQI,EAAW,OAAS,GAAG0B,OAAAX,EAAY,MAC3CK,YACIpB,GAAYoB,EAAc,GAAAM,OAAGN,GAAgB,SAGrD,CAAAE,SAAAD,EAAA,MAAAE,EAAA,CAAKC,UAAWC,GAAiC,CAAAH,SAC7CD,EACI,MAAA,CAAA3B,IAAKc,EACLgB,UAAWC,WAMnC,GAAG,CAAC/B,IAEEiC,EAAcf,GAAY,WAC5B,IAAMgB,EAAM,IAAIC,MAEhBD,EAAIE,OAAS,WACTpB,EAAUhB,GACVY,GAAW,EACf,EAEAsB,EAAIlC,IAAMA,CACd,GAAG,CAACA,IAEJ,OACI2B,EAACU,EAAuBR,EAAA,CAACS,eAAgBL,GACpC,CAAAL,SAAAjB,EACGgB,WAAK3B,IAAKe,GAAYR,IAEtBoB,EAAGY,EAAA,CAAAX,SAAAX,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.
|
|
3
|
+
"version": "3.3.0",
|
|
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-
|
|
15
|
-
"@cleartrip/ct-platform-utils": "3.
|
|
16
|
-
"@cleartrip/ct-platform-
|
|
14
|
+
"@cleartrip/ct-platform-constants": "3.2.0",
|
|
15
|
+
"@cleartrip/ct-platform-utils": "3.6.0",
|
|
16
|
+
"@cleartrip/ct-platform-io-hoc": "3.0.0"
|
|
17
17
|
},
|
|
18
18
|
"peerDependencies": {
|
|
19
19
|
"react": ">=16.8.0",
|