@cleartrip/ct-platform-timer-widget 3.10.1-beta.11 → 3.10.1-beta.13
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 i=require("tslib"),e=require("react/jsx-runtime"),n=require("react"),t=require("react-countdown"),l=require("@cleartrip/ct-platform-shimmer"),r=require("@cleartrip/ct-platform-lazy-image"),o=require("@cleartrip/ct-platform-io-hoc"),s=require("@cleartrip/ct-platform-constants"),a=require("@cleartrip/ct-platform-utils");function d(i){return i&&i.__esModule?i:{default:i}}var c=d(t),u={position:"absolute",width:"100%",height:"100%",display:"flex",flexDirection:"column",justifyContent:"end",alignItems:"center"},g={display:"flex",alignItems:"center",justifyContent:"center",padding:"8px",gap:"4px"},h={display:"flex",width:"36px",height:"24px",border:"1px solid rgba(0, 0, 0, 0.10)",borderRadius:"6px",background:"#FFF",alignItems:"center",justifyContent:"center",color:"#1A1A1A",fontSize:"12px",fontWeight:600,letterSpacing:"0.4px"},v={fontSize:"12px",fontWeight:600,letterSpacing:"0.4px",textAlign:"center"},p={width:"calc(100% - 32px)",height:"40px",padding:"8px 12px",marginTop:"8px",marginBottom:"12px",fontSize:"14px",fontWeight:"600",borderRadius:"8px",backgroundColor:"#1a1a1a",color:"#fff",border:"none"},m={fontSize:"12px"},_={position:"relative",width:"100%",height:"100%",backgroundSize:"cover",backgroundRepeat:"no-repeat",backgroundPosition:"center"},x={padding:"8px 16px"},f={height:"50%",width:"auto"},j={height:"
|
|
1
|
+
"use strict";var i=require("tslib"),e=require("react/jsx-runtime"),n=require("react"),t=require("react-countdown"),l=require("@cleartrip/ct-platform-shimmer"),r=require("@cleartrip/ct-platform-lazy-image"),o=require("@cleartrip/ct-platform-io-hoc"),s=require("@cleartrip/ct-platform-constants"),a=require("@cleartrip/ct-platform-utils");function d(i){return i&&i.__esModule?i:{default:i}}var c=d(t),u={position:"absolute",width:"100%",height:"100%",display:"flex",flexDirection:"column",justifyContent:"end",alignItems:"center"},g={display:"flex",alignItems:"center",justifyContent:"center",padding:"8px",gap:"4px"},h={display:"flex",width:"36px",height:"24px",border:"1px solid rgba(0, 0, 0, 0.10)",borderRadius:"6px",background:"#FFF",alignItems:"center",justifyContent:"center",color:"#1A1A1A",fontSize:"12px",fontWeight:600,letterSpacing:"0.4px"},v={fontSize:"12px",fontWeight:600,letterSpacing:"0.4px",textAlign:"center"},p={width:"calc(100% - 32px)",height:"40px",padding:"8px 12px",marginTop:"8px",marginBottom:"12px",fontSize:"14px",fontWeight:"600",borderRadius:"8px",backgroundColor:"#1a1a1a",color:"#fff",border:"none"},m={fontSize:"12px"},_={position:"relative",width:"100%",height:"100%",backgroundSize:"cover",backgroundRepeat:"no-repeat",backgroundPosition:"center"},x={padding:"8px 16px"},f={height:"50%",width:"auto"},j={height:"30%",width:"auto",top:"35%",position:"absolute"},b={width:"100%",height:"100%",display:"flex",position:"relative",borderRadius:"8px",alignItems:"center",background:"#fef5f2",justifyContent:"center"};exports.TimerWidget=function(t){var d,y,C,S,w=t.headerImg,I=t.widgetData,k=t.lazyWidget,F=void 0===k||k,q=t.onItemView,z=t.onItemClick,W=t.onItemImpression,R=t.styleConfig,A=t.renderItem,D=function(){var i=n.useRef(!1);return n.useEffect((function(){return i.current=!0,function(){i.current=!1}}),[]),n.useCallback((function(){return i.current}),[])}(),M=n.useState(!F),O=M[0],T=M[1],U=n.useState(F),B=U[0],H=U[1],L=n.useMemo((function(){var i;return a.getDimensionFromImageUrl(null===(i=null==I?void 0:I.image)||void 0===i?void 0:i.url)}),[null===(d=null==I?void 0:I.image)||void 0===d?void 0:d.url]),E=L.heightInNumber,N=L.widthInNumber,P=n.useState(E/N*100),V=P[0],G=P[1],J=n.useMemo((function(){return a.getDimensionFromImageUrl(w).height}),[w]);n.useEffect((function(){var i;K(null===(i=null==I?void 0:I.image)||void 0===i?void 0:i.url)}),[]);var K=n.useCallback((function(i){if(i){var e=new Image;e.src=i,e.onload=function(){!A&&G(e.height/e.width*100),H(!1)}}}),[]),Q=n.useCallback((function(n){var t=n.days,r=n.hours,o=n.minutes,s=n.seconds,a=D();return e.jsxs("div",i.__assign({style:g},{children:[t>0&&e.jsxs(e.Fragment,{children:[a?e.jsxs("div",i.__assign({style:h},{children:[e.jsx("span",{children:String(t).padStart(2,"0")}),e.jsx("span",i.__assign({style:m},{children:"d"}))]})):e.jsx(l.Shimmer,{height:24,width:36}),e.jsx("div",i.__assign({style:i.__assign(i.__assign({},v),{color:(null==I?void 0:I.colonColor)?"".concat(I.colonColor):"#FFF"})},{children:":"}))]}),a?e.jsxs("div",i.__assign({style:h},{children:[e.jsx("span",{children:String(r).padStart(2,"0")}),e.jsx("span",i.__assign({style:m},{children:"h"}))]})):e.jsx(l.Shimmer,{height:24,width:36}),e.jsx("div",i.__assign({style:i.__assign(i.__assign({},v),{color:(null==I?void 0:I.colonColor)?"".concat(I.colonColor):"#FFF"})},{children:":"})),a?e.jsxs("div",i.__assign({style:h},{children:[e.jsx("span",{children:String(o).padStart(2,"0")}),e.jsx("span",i.__assign({style:m},{children:"m"}))]})):e.jsx(l.Shimmer,{height:24,width:36}),e.jsx("div",i.__assign({style:i.__assign(i.__assign({},v),{color:(null==I?void 0:I.colonColor)?"".concat(I.colonColor):"#FFF"})},{children:":"})),a?e.jsxs("div",i.__assign({style:h},{children:[e.jsx("span",{children:String(s).padStart(2,"0")}),e.jsx("span",i.__assign({style:m},{children:"s"}))]})):e.jsx(l.Shimmer,{height:24,width:36})]}))}),[]),X=n.useCallback((function(i){var e,n;z&&(null==I?void 0:I.label)&&(null===(e=null==I?void 0:I.image)||void 0===e?void 0:e.url)&&z(null==I?void 0:I.label,null===(n=null==I?void 0:I.image)||void 0===n?void 0:n.url),window.location.href=i}),[z]),Y=n.useCallback((function(){var i;q&&q(null==I?void 0:I.label,null===(i=null==I?void 0:I.image)||void 0===i?void 0:i.url)}),[I,q]),Z=n.useCallback((function(){var i;F&&T(!0),W&&W(null==I?void 0:I.label,null===(i=null==I?void 0:I.image)||void 0===i?void 0:i.url)}),[I,W]),$=n.useCallback((function(){var n,t=a.getHeightFromImgUrl(null===(n=null==I?void 0:I.image)||void 0===n?void 0:n.url)||180;return e.jsxs("div",{children:[w&&e.jsx("div",i.__assign({style:i.__assign(i.__assign({},x),{height:J})},{children:e.jsx("div",i.__assign({style:b},{children:e.jsx("img",{src:s.placeholderLogo,style:f})}))})),e.jsx("div",i.__assign({style:i.__assign(i.__assign({},x),{minHeight:"".concat(t,"px")})},{children:e.jsx("div",i.__assign({style:i.__assign(i.__assign({},b),{paddingBottom:"".concat(V,"%")})},{children:e.jsx("img",{src:s.placeholderLogo,style:j})}))}))]})}),[w,I,V]),ii=n.useMemo((function(){var i;return function(i,e,n){var t={position:"relative"};return i||Object.assign(t,{width:"100%",height:"100%",backgroundSize:"cover",backgroundRepeat:"no-repeat",backgroundPosition:"center",backgroundImage:"url(".concat(e,")"),paddingBottom:"".concat(n,"%")}),t}(!!A,null===(i=null==I?void 0:I.image)||void 0===i?void 0:i.url,V)}),[!!A,null===(y=null==I?void 0:I.image)||void 0===y?void 0:y.url,V]);return e.jsx(o.IntersectionObserverHOC,i.__assign({onIntersection:Z,onTimedObservationComplete:Y},{children:O?e.jsxs("div",{children:[w&&e.jsx(r.LazyImage,{src:w,style:{width:"100%",height:J}}),!B&&e.jsxs("div",i.__assign({style:i.__assign(i.__assign(i.__assign({},_),ii),null==R?void 0:R.timerWidgetImageWrapper),onClick:function(){var i;return X(null===(i=null==I?void 0:I.cta)||void 0===i?void 0:i.targetUrl)}},{children:[null==A?void 0:A(),e.jsxs("div",i.__assign({style:u},{children:[e.jsx(c.default,{date:null==I?void 0:I.endTime,renderer:Q}),(null===(C=null==I?void 0:I.cta)||void 0===C?void 0:C.title)&&e.jsx("button",i.__assign({style:p},{children:null===(S=null==I?void 0:I.cta)||void 0===S?void 0:S.title}))]}))]}),null==I?void 0:I.label)]}):e.jsx(e.Fragment,{children:$()})}))};
|
|
2
2
|
//# sourceMappingURL=ct-platform-timer-widget.cjs.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__assign as i}from"tslib";import{jsxs as t,Fragment as n,jsx as e}from"react/jsx-runtime";import{useState as o,useMemo as l,useEffect as r,useCallback as d,useRef as a}from"react";import c from"react-countdown";import{Shimmer as u}from"@cleartrip/ct-platform-shimmer";import{LazyImage as v}from"@cleartrip/ct-platform-lazy-image";import{IntersectionObserverHOC as h}from"@cleartrip/ct-platform-io-hoc";import{placeholderLogo as p}from"@cleartrip/ct-platform-constants";import{getDimensionFromImageUrl as s,getHeightFromImgUrl as g}from"@cleartrip/ct-platform-utils";var m={position:"absolute",width:"100%",height:"100%",display:"flex",flexDirection:"column",justifyContent:"end",alignItems:"center"},f={display:"flex",alignItems:"center",justifyContent:"center",padding:"8px",gap:"4px"},y={display:"flex",width:"36px",height:"24px",border:"1px solid rgba(0, 0, 0, 0.10)",borderRadius:"6px",background:"#FFF",alignItems:"center",justifyContent:"center",color:"#1A1A1A",fontSize:"12px",fontWeight:600,letterSpacing:"0.4px"},x={fontSize:"12px",fontWeight:600,letterSpacing:"0.4px",textAlign:"center"},b={width:"calc(100% - 32px)",height:"40px",padding:"8px 12px",marginTop:"8px",marginBottom:"12px",fontSize:"14px",fontWeight:"600",borderRadius:"8px",backgroundColor:"#1a1a1a",color:"#fff",border:"none"},w={fontSize:"12px"},I={position:"relative",width:"100%",height:"100%",backgroundSize:"cover",backgroundRepeat:"no-repeat",backgroundPosition:"center"},S={padding:"8px 16px"},C={height:"50%",width:"auto"},k={height:"
|
|
1
|
+
import{__assign as i}from"tslib";import{jsxs as t,Fragment as n,jsx as e}from"react/jsx-runtime";import{useState as o,useMemo as l,useEffect as r,useCallback as d,useRef as a}from"react";import c from"react-countdown";import{Shimmer as u}from"@cleartrip/ct-platform-shimmer";import{LazyImage as v}from"@cleartrip/ct-platform-lazy-image";import{IntersectionObserverHOC as h}from"@cleartrip/ct-platform-io-hoc";import{placeholderLogo as p}from"@cleartrip/ct-platform-constants";import{getDimensionFromImageUrl as s,getHeightFromImgUrl as g}from"@cleartrip/ct-platform-utils";var m={position:"absolute",width:"100%",height:"100%",display:"flex",flexDirection:"column",justifyContent:"end",alignItems:"center"},f={display:"flex",alignItems:"center",justifyContent:"center",padding:"8px",gap:"4px"},y={display:"flex",width:"36px",height:"24px",border:"1px solid rgba(0, 0, 0, 0.10)",borderRadius:"6px",background:"#FFF",alignItems:"center",justifyContent:"center",color:"#1A1A1A",fontSize:"12px",fontWeight:600,letterSpacing:"0.4px"},x={fontSize:"12px",fontWeight:600,letterSpacing:"0.4px",textAlign:"center"},b={width:"calc(100% - 32px)",height:"40px",padding:"8px 12px",marginTop:"8px",marginBottom:"12px",fontSize:"14px",fontWeight:"600",borderRadius:"8px",backgroundColor:"#1a1a1a",color:"#fff",border:"none"},w={fontSize:"12px"},I={position:"relative",width:"100%",height:"100%",backgroundSize:"cover",backgroundRepeat:"no-repeat",backgroundPosition:"center"},S={padding:"8px 16px"},C={height:"50%",width:"auto"},k={height:"30%",width:"auto",top:"35%",position:"absolute"},F={width:"100%",height:"100%",display:"flex",position:"relative",borderRadius:"8px",alignItems:"center",background:"#fef5f2",justifyContent:"center"};var z=function(z){var j,W,R,A,B=z.headerImg,T=z.widgetData,D=z.lazyWidget,N=void 0===D||D,O=z.onItemView,P=z.onItemClick,H=z.onItemImpression,U=z.styleConfig,V=z.renderItem,q=function(){var i=a(!1);return r((function(){return i.current=!0,function(){i.current=!1}}),[]),d((function(){return i.current}),[])}(),E=o(!N),G=E[0],J=E[1],K=o(N),L=K[0],M=K[1],Q=l((function(){var i;return s(null===(i=null==T?void 0:T.image)||void 0===i?void 0:i.url)}),[null===(j=null==T?void 0:T.image)||void 0===j?void 0:j.url]),X=Q.heightInNumber,Y=Q.widthInNumber,Z=o(X/Y*100),$=Z[0],_=Z[1],ii=l((function(){return s(B).height}),[B]);r((function(){var i;ti(null===(i=null==T?void 0:T.image)||void 0===i?void 0:i.url)}),[]);var ti=d((function(i){if(i){var t=new Image;t.src=i,t.onload=function(){!V&&_(t.height/t.width*100),M(!1)}}}),[]),ni=d((function(o){var l=o.days,r=o.hours,d=o.minutes,a=o.seconds,c=q();return t("div",i({style:f},{children:[l>0&&t(n,{children:[c?t("div",i({style:y},{children:[e("span",{children:String(l).padStart(2,"0")}),e("span",i({style:w},{children:"d"}))]})):e(u,{height:24,width:36}),e("div",i({style:i(i({},x),{color:(null==T?void 0:T.colonColor)?"".concat(T.colonColor):"#FFF"})},{children:":"}))]}),c?t("div",i({style:y},{children:[e("span",{children:String(r).padStart(2,"0")}),e("span",i({style:w},{children:"h"}))]})):e(u,{height:24,width:36}),e("div",i({style:i(i({},x),{color:(null==T?void 0:T.colonColor)?"".concat(T.colonColor):"#FFF"})},{children:":"})),c?t("div",i({style:y},{children:[e("span",{children:String(d).padStart(2,"0")}),e("span",i({style:w},{children:"m"}))]})):e(u,{height:24,width:36}),e("div",i({style:i(i({},x),{color:(null==T?void 0:T.colonColor)?"".concat(T.colonColor):"#FFF"})},{children:":"})),c?t("div",i({style:y},{children:[e("span",{children:String(a).padStart(2,"0")}),e("span",i({style:w},{children:"s"}))]})):e(u,{height:24,width:36})]}))}),[]),ei=d((function(i){var t,n;P&&(null==T?void 0:T.label)&&(null===(t=null==T?void 0:T.image)||void 0===t?void 0:t.url)&&P(null==T?void 0:T.label,null===(n=null==T?void 0:T.image)||void 0===n?void 0:n.url),window.location.href=i}),[P]),oi=d((function(){var i;O&&O(null==T?void 0:T.label,null===(i=null==T?void 0:T.image)||void 0===i?void 0:i.url)}),[T,O]),li=d((function(){var i;N&&J(!0),H&&H(null==T?void 0:T.label,null===(i=null==T?void 0:T.image)||void 0===i?void 0:i.url)}),[T,H]),ri=d((function(){var n,o=g(null===(n=null==T?void 0:T.image)||void 0===n?void 0:n.url)||180;return t("div",{children:[B&&e("div",i({style:i(i({},S),{height:ii})},{children:e("div",i({style:F},{children:e("img",{src:p,style:C})}))})),e("div",i({style:i(i({},S),{minHeight:"".concat(o,"px")})},{children:e("div",i({style:i(i({},F),{paddingBottom:"".concat($,"%")})},{children:e("img",{src:p,style:k})}))}))]})}),[B,T,$]),di=l((function(){var i;return function(i,t,n){var e={position:"relative"};return i||Object.assign(e,{width:"100%",height:"100%",backgroundSize:"cover",backgroundRepeat:"no-repeat",backgroundPosition:"center",backgroundImage:"url(".concat(t,")"),paddingBottom:"".concat(n,"%")}),e}(!!V,null===(i=null==T?void 0:T.image)||void 0===i?void 0:i.url,$)}),[!!V,null===(W=null==T?void 0:T.image)||void 0===W?void 0:W.url,$]);return e(h,i({onIntersection:li,onTimedObservationComplete:oi},{children:G?t("div",{children:[B&&e(v,{src:B,style:{width:"100%",height:ii}}),!L&&t("div",i({style:i(i(i({},I),di),null==U?void 0:U.timerWidgetImageWrapper),onClick:function(){var i;return ei(null===(i=null==T?void 0:T.cta)||void 0===i?void 0:i.targetUrl)}},{children:[null==V?void 0:V(),t("div",i({style:m},{children:[e(c,{date:null==T?void 0:T.endTime,renderer:ni}),(null===(R=null==T?void 0:T.cta)||void 0===R?void 0:R.title)&&e("button",i({style:b},{children:null===(A=null==T?void 0:T.cta)||void 0===A?void 0:A.title}))]}))]}),null==T?void 0:T.label)]}):e(n,{children:ri()})}))};export{z as TimerWidget};
|
|
2
2
|
//# sourceMappingURL=ct-platform-timer-widget.esm.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cleartrip/ct-platform-timer-widget",
|
|
3
|
-
"version": "3.10.1-beta.
|
|
3
|
+
"version": "3.10.1-beta.13",
|
|
4
4
|
"description": "Timer Widget Component",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"main": "dist/ct-platform-timer-widget.cjs.js",
|
|
@@ -11,12 +11,12 @@
|
|
|
11
11
|
],
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"react-countdown": "^2.3.5",
|
|
14
|
-
"@cleartrip/ct-platform-
|
|
15
|
-
"@cleartrip/ct-platform-io-hoc": "3.0.3-beta.18",
|
|
16
|
-
"@cleartrip/ct-platform-merch-carousel": "3.11.1-beta.11",
|
|
17
|
-
"@cleartrip/ct-platform-shimmer": "3.0.3-beta.18",
|
|
14
|
+
"@cleartrip/ct-platform-lazy-image": "3.9.1-beta.11",
|
|
18
15
|
"@cleartrip/ct-platform-constants": "3.6.1-beta.7",
|
|
19
|
-
"@cleartrip/ct-platform-
|
|
16
|
+
"@cleartrip/ct-platform-io-hoc": "3.0.3-beta.18",
|
|
17
|
+
"@cleartrip/ct-platform-utils": "3.18.1-beta.7",
|
|
18
|
+
"@cleartrip/ct-platform-merch-carousel": "3.11.1-beta.12",
|
|
19
|
+
"@cleartrip/ct-platform-shimmer": "3.0.3-beta.18"
|
|
20
20
|
},
|
|
21
21
|
"peerDependencies": {
|
|
22
22
|
"react": ">=16.8.0",
|