@cleartrip/ct-platform-timer-widget 3.8.0-beta.25 → 3.8.0-beta.26
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"),i=require("react/jsx-runtime"),n=require("react"),t=require("react-countdown"),
|
|
1
|
+
"use strict";var e=require("tslib"),i=require("react/jsx-runtime"),n=require("react"),t=require("react-countdown"),o=require("@cleartrip/ct-platform-lazy-image"),l=require("@cleartrip/ct-platform-io-hoc"),r=require("@cleartrip/ct-platform-constants"),a=require("@cleartrip/ct-platform-utils");function s(e){return e&&e.__esModule?e:{default:e}}var d=s(t),c={display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",fontSize:"24px",fontWeight:"500",width:"60px",height:"72px",backgroundColor:"#fff",color:"#1a1a1a",border:"1px solid #1a1a1a",borderRadius:"8px"},u={fontSize:"32px",fontWeight:"500"},g={position:"absolute",width:"100%",height:"100%",display:"flex",flexDirection:"column",justifyContent:"end",alignItems:"center",bottom:"24px"},m={width:"calc(100% - 32px)",height:"40px",marginTop:"16px",fontSize:"14px",fontWeight:"600",borderRadius:"8px",backgroundColor:"#1a1a1a",color:"#fff"},p={fontSize:"12px",paddingTop:"4px"};var h="index-module_timer-bg-image__be1qA",_="index-module_placeholder__5zI9P",x="index-module_header-ph-img__CCrxL",v="index-module_content-ph-img__A20jD",f="index-module_placeholder-img-wrapper__mcqYX";!function(e,i){void 0===i&&(i={});var n=i.insertAt;if("undefined"!=typeof document){var t=document.head||document.getElementsByTagName("head")[0],o=document.createElement("style");o.type="text/css","top"===n&&t.firstChild?t.insertBefore(o,t.firstChild):t.appendChild(o),o.styleSheet?o.styleSheet.cssText=e:o.appendChild(document.createTextNode(e))}}(".index-module_timer-bg-image__be1qA{background-position:50%;background-repeat:no-repeat;background-size:cover;height:100%;position:relative;width:100%}.index-module_timer-content__p9q7H{align-items:center;bottom:24px;display:flex;flex-direction:column;font-family:Inter,Arial,sans-serif;height:100%;justify-content:end;position:absolute;width:100%}.index-module_timer-container__8bcOe{align-items:center;display:flex;width:calc(100% - 32px)}.index-module_timer-box__U7pgT{align-items:center;background-color:#fff;border:1px solid #1a1a1a;border-radius:8px;color:#1a1a1a;display:flex;flex-direction:column;font-size:24px;font-weight:500;height:72px;justify-content:center;width:60px}.index-module_timer-box__U7pgT>span:nth-child(2){font-size:12px;padding-top:4px}.index-module_timer-separator__7Ga7U{font-family:Inter!important;font-size:32px;font-weight:500}.index-module_timer-button__ZGHD-{background-color:#1a1a1a;border-radius:8px;color:#fff;font-size:14px;font-weight:600;height:40px;margin-top:16px;width:calc(100% - 32px)}.index-module_placeholder__5zI9P{padding:8px}.index-module_header-ph-img__CCrxL{height:50%;width:auto}.index-module_content-ph-img__A20jD{height:15%;position:absolute;top:40%;width:auto}.index-module_placeholder-img-wrapper__mcqYX{align-items:center;background:#fef5f2;border-radius:8px;display:flex;height:100%;justify-content:center;position:relative;width:100%}");exports.TimerWidget=function(t){var s,b,y,j,C=t.headerImg,w=t.widgetData,I=t.lazyWidget,S=void 0===I||I,k=t.onItemView,A=t.onItemClick,z=t.onItemImpression,q=t.styleConfig,N=t.renderItem,T=n.useState(!S),D=T[0],U=T[1],W=n.useState(S),H=W[0],F=W[1],L=n.useMemo((function(){var e;return a.getDimensionFromImageUrl(null===(e=null==w?void 0:w.image)||void 0===e?void 0:e.url)}),[null===(s=null==w?void 0:w.image)||void 0===s?void 0:s.url]),M=L.heightInNumber,O=L.widthInNumber,B=n.useState(M/O*100),E=B[0],R=B[1],P=n.useMemo((function(){return a.getDimensionFromImageUrl(C).height}),[C]);n.useEffect((function(){var e;Y(null===(e=null==w?void 0:w.image)||void 0===e?void 0:e.url)}),[]);var Y=n.useCallback((function(e){if(e){var i=new Image;i.src=e,i.onload=function(){!N&&R(i.height/i.width*100),F(!1)}}}),[]),G=n.useCallback((function(n){var t=n.days,o=n.hours,l=n.minutes,r=n.seconds;return i.jsxs("div",e.__assign({style:e.__assign({display:"flex",alignItems:"center",width:"calc(100% - 32px)"},t>0?{justifyContent:"space-between"}:{justifyContent:"center",gap:"8px"})},{children:[t>0&&i.jsxs(i.Fragment,{children:[i.jsxs("div",e.__assign({style:c},{children:[i.jsx("span",{children:String(t).padStart(2,"0")}),i.jsx("span",e.__assign({style:p},{children:"DAYS"}))]})),i.jsx("div",e.__assign({style:e.__assign(e.__assign({},u),{color:(null==w?void 0:w.colonColor)?"".concat(w.colonColor):"#1A1A1A"})},{children:":"}))]}),i.jsxs("div",e.__assign({style:c},{children:[i.jsx("span",{children:String(o).padStart(2,"0")}),i.jsx("span",e.__assign({style:p},{children:"HRS"}))]})),i.jsx("div",e.__assign({style:e.__assign(e.__assign({},u),{color:(null==w?void 0:w.colonColor)?"".concat(w.colonColor):"#1A1A1A"})},{children:":"})),i.jsxs("div",e.__assign({style:c},{children:[i.jsx("span",{children:String(l).padStart(2,"0")}),i.jsx("span",e.__assign({style:p},{children:"MINS"}))]})),i.jsx("div",e.__assign({style:e.__assign(e.__assign({},u),{color:(null==w?void 0:w.colonColor)?"".concat(w.colonColor):"#1A1A1A"})},{children:":"})),i.jsxs("div",e.__assign({style:c},{children:[i.jsx("span",{children:String(r).padStart(2,"0")}),i.jsx("span",e.__assign({style:p},{children:"SECS"}))]}))]}))}),[]),X=n.useCallback((function(e){var i,n;A&&(null==w?void 0:w.label)&&(null===(i=null==w?void 0:w.image)||void 0===i?void 0:i.url)&&A(null==w?void 0:w.label,null===(n=null==w?void 0:w.image)||void 0===n?void 0:n.url),window.location.href=e}),[A]),V=n.useCallback((function(){var e;k&&k(null==w?void 0:w.label,null===(e=null==w?void 0:w.image)||void 0===e?void 0:e.url)}),[w,k]),Z=n.useCallback((function(){var e;S&&U(!0),z&&z(null==w?void 0:w.label,null===(e=null==w?void 0:w.image)||void 0===e?void 0:e.url)}),[w,z]),J=n.useCallback((function(){var n,t=a.getHeightFromImgUrl(null===(n=null==w?void 0:w.image)||void 0===n?void 0:n.url)||180;return i.jsxs("div",{children:[C&&i.jsx("div",e.__assign({className:_,style:{height:P}},{children:i.jsx("div",e.__assign({className:f},{children:i.jsx("img",{src:r.placeholderLogo,className:x})}))})),i.jsx("div",e.__assign({className:_,style:{minHeight:"".concat(t,"px")}},{children:i.jsx("div",e.__assign({className:f,style:{paddingBottom:"".concat(E,"%")}},{children:i.jsx("img",{src:r.placeholderLogo,className:v})}))}))]})}),[C,w,E]),K=n.useMemo((function(){var e;return function(e,i,n){var t={position:"relative"};return e||Object.assign(t,{width:"100%",height:"100%",backgroundSize:"cover",backgroundRepeat:"no-repeat",backgroundPosition:"center",backgroundImage:"url(".concat(i,")"),paddingBottom:"".concat(n,"%")}),t}(!!N,null===(e=null==w?void 0:w.image)||void 0===e?void 0:e.url,E)}),[!!N,null===(b=null==w?void 0:w.image)||void 0===b?void 0:b.url,E]);return i.jsx(l.IntersectionObserverHOC,e.__assign({onIntersection:Z,onTimedObservationComplete:V},{children:D?i.jsxs("div",{children:[C&&i.jsx(o.LazyImage,{src:C,style:{width:"100%",height:P}}),!H&&i.jsxs("div",e.__assign({className:h,style:e.__assign(e.__assign({},K),null==q?void 0:q.timerWidgetImageWrapper),onClick:function(){var e;return X(null===(e=null==w?void 0:w.cta)||void 0===e?void 0:e.targetUrl)}},{children:[null==N?void 0:N(),i.jsxs("div",e.__assign({style:g},{children:[i.jsx(d.default,{date:null==w?void 0:w.endTime,renderer:G}),(null===(y=null==w?void 0:w.cta)||void 0===y?void 0:y.title)&&i.jsx("button",e.__assign({style:m},{children:null===(j=null==w?void 0:w.cta)||void 0===j?void 0:j.title}))]}))]}),null==w?void 0:w.label)]}):i.jsx(i.Fragment,{children:J()})}))};
|
|
2
2
|
//# sourceMappingURL=ct-platform-timer-widget.cjs.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__assign as e}from"tslib";import{jsxs as i,Fragment as t,jsx as
|
|
1
|
+
import{__assign as e}from"tslib";import{jsxs as i,Fragment as t,jsx as o}from"react/jsx-runtime";import{useState as n,useMemo as l,useEffect as r,useCallback as d}from"react";import a from"react-countdown";import{LazyImage as c}from"@cleartrip/ct-platform-lazy-image";import{IntersectionObserverHOC as u}from"@cleartrip/ct-platform-io-hoc";import{placeholderLogo as s}from"@cleartrip/ct-platform-constants";import{getDimensionFromImageUrl as p,getHeightFromImgUrl as m}from"@cleartrip/ct-platform-utils";var h={display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",fontSize:"24px",fontWeight:"500",width:"60px",height:"72px",backgroundColor:"#fff",color:"#1a1a1a",border:"1px solid #1a1a1a",borderRadius:"8px"},v={fontSize:"32px",fontWeight:"500"},g={position:"absolute",width:"100%",height:"100%",display:"flex",flexDirection:"column",justifyContent:"end",alignItems:"center",bottom:"24px"},f={width:"calc(100% - 32px)",height:"40px",marginTop:"16px",fontSize:"14px",fontWeight:"600",borderRadius:"8px",backgroundColor:"#1a1a1a",color:"#fff"},x={fontSize:"12px",paddingTop:"4px"};var _="index-module_timer-bg-image__be1qA",y="index-module_placeholder__5zI9P",b="index-module_header-ph-img__CCrxL",w="index-module_content-ph-img__A20jD",C="index-module_placeholder-img-wrapper__mcqYX";!function(e,i){void 0===i&&(i={});var t=i.insertAt;if("undefined"!=typeof document){var o=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css","top"===t&&o.firstChild?o.insertBefore(n,o.firstChild):o.appendChild(n),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}}(".index-module_timer-bg-image__be1qA{background-position:50%;background-repeat:no-repeat;background-size:cover;height:100%;position:relative;width:100%}.index-module_timer-content__p9q7H{align-items:center;bottom:24px;display:flex;flex-direction:column;font-family:Inter,Arial,sans-serif;height:100%;justify-content:end;position:absolute;width:100%}.index-module_timer-container__8bcOe{align-items:center;display:flex;width:calc(100% - 32px)}.index-module_timer-box__U7pgT{align-items:center;background-color:#fff;border:1px solid #1a1a1a;border-radius:8px;color:#1a1a1a;display:flex;flex-direction:column;font-size:24px;font-weight:500;height:72px;justify-content:center;width:60px}.index-module_timer-box__U7pgT>span:nth-child(2){font-size:12px;padding-top:4px}.index-module_timer-separator__7Ga7U{font-family:Inter!important;font-size:32px;font-weight:500}.index-module_timer-button__ZGHD-{background-color:#1a1a1a;border-radius:8px;color:#fff;font-size:14px;font-weight:600;height:40px;margin-top:16px;width:calc(100% - 32px)}.index-module_placeholder__5zI9P{padding:8px}.index-module_header-ph-img__CCrxL{height:50%;width:auto}.index-module_content-ph-img__A20jD{height:15%;position:absolute;top:40%;width:auto}.index-module_placeholder-img-wrapper__mcqYX{align-items:center;background:#fef5f2;border-radius:8px;display:flex;height:100%;justify-content:center;position:relative;width:100%}");var I=function(I){var S,A,k,z,N=I.headerImg,j=I.widgetData,T=I.lazyWidget,D=void 0===T||T,W=I.onItemView,q=I.onItemClick,B=I.onItemImpression,H=I.styleConfig,R=I.renderItem,U=n(!D),E=U[0],O=U[1],P=n(D),Y=P[0],G=P[1],L=l((function(){var e;return p(null===(e=null==j?void 0:j.image)||void 0===e?void 0:e.url)}),[null===(S=null==j?void 0:j.image)||void 0===S?void 0:S.url]),X=L.heightInNumber,M=L.widthInNumber,V=n(X/M*100),Z=V[0],F=V[1],J=l((function(){return p(N).height}),[N]);r((function(){var e;K(null===(e=null==j?void 0:j.image)||void 0===e?void 0:e.url)}),[]);var K=d((function(e){if(e){var i=new Image;i.src=e,i.onload=function(){!R&&F(i.height/i.width*100),G(!1)}}}),[]),Q=d((function(n){var l=n.days,r=n.hours,d=n.minutes,a=n.seconds;return i("div",e({style:e({display:"flex",alignItems:"center",width:"calc(100% - 32px)"},l>0?{justifyContent:"space-between"}:{justifyContent:"center",gap:"8px"})},{children:[l>0&&i(t,{children:[i("div",e({style:h},{children:[o("span",{children:String(l).padStart(2,"0")}),o("span",e({style:x},{children:"DAYS"}))]})),o("div",e({style:e(e({},v),{color:(null==j?void 0:j.colonColor)?"".concat(j.colonColor):"#1A1A1A"})},{children:":"}))]}),i("div",e({style:h},{children:[o("span",{children:String(r).padStart(2,"0")}),o("span",e({style:x},{children:"HRS"}))]})),o("div",e({style:e(e({},v),{color:(null==j?void 0:j.colonColor)?"".concat(j.colonColor):"#1A1A1A"})},{children:":"})),i("div",e({style:h},{children:[o("span",{children:String(d).padStart(2,"0")}),o("span",e({style:x},{children:"MINS"}))]})),o("div",e({style:e(e({},v),{color:(null==j?void 0:j.colonColor)?"".concat(j.colonColor):"#1A1A1A"})},{children:":"})),i("div",e({style:h},{children:[o("span",{children:String(a).padStart(2,"0")}),o("span",e({style:x},{children:"SECS"}))]}))]}))}),[]),$=d((function(e){var i,t;q&&(null==j?void 0:j.label)&&(null===(i=null==j?void 0:j.image)||void 0===i?void 0:i.url)&&q(null==j?void 0:j.label,null===(t=null==j?void 0:j.image)||void 0===t?void 0:t.url),window.location.href=e}),[q]),ee=d((function(){var e;W&&W(null==j?void 0:j.label,null===(e=null==j?void 0:j.image)||void 0===e?void 0:e.url)}),[j,W]),ie=d((function(){var e;D&&O(!0),B&&B(null==j?void 0:j.label,null===(e=null==j?void 0:j.image)||void 0===e?void 0:e.url)}),[j,B]),te=d((function(){var t,n=m(null===(t=null==j?void 0:j.image)||void 0===t?void 0:t.url)||180;return i("div",{children:[N&&o("div",e({className:y,style:{height:J}},{children:o("div",e({className:C},{children:o("img",{src:s,className:b})}))})),o("div",e({className:y,style:{minHeight:"".concat(n,"px")}},{children:o("div",e({className:C,style:{paddingBottom:"".concat(Z,"%")}},{children:o("img",{src:s,className:w})}))}))]})}),[N,j,Z]),oe=l((function(){var e;return function(e,i,t){var o={position:"relative"};return e||Object.assign(o,{width:"100%",height:"100%",backgroundSize:"cover",backgroundRepeat:"no-repeat",backgroundPosition:"center",backgroundImage:"url(".concat(i,")"),paddingBottom:"".concat(t,"%")}),o}(!!R,null===(e=null==j?void 0:j.image)||void 0===e?void 0:e.url,Z)}),[!!R,null===(A=null==j?void 0:j.image)||void 0===A?void 0:A.url,Z]);return o(u,e({onIntersection:ie,onTimedObservationComplete:ee},{children:E?i("div",{children:[N&&o(c,{src:N,style:{width:"100%",height:J}}),!Y&&i("div",e({className:_,style:e(e({},oe),null==H?void 0:H.timerWidgetImageWrapper),onClick:function(){var e;return $(null===(e=null==j?void 0:j.cta)||void 0===e?void 0:e.targetUrl)}},{children:[null==R?void 0:R(),i("div",e({style:g},{children:[o(a,{date:null==j?void 0:j.endTime,renderer:Q}),(null===(k=null==j?void 0:j.cta)||void 0===k?void 0:k.title)&&o("button",e({style:f},{children:null===(z=null==j?void 0:j.cta)||void 0===z?void 0:z.title}))]}))]}),null==j?void 0:j.label)]}):o(t,{children:te()})}))};export{I 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.8.0-beta.
|
|
3
|
+
"version": "3.8.0-beta.26",
|
|
4
4
|
"description": "Timer Widget Component",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"main": "dist/ct-platform-timer-widget.cjs.js",
|
|
@@ -11,11 +11,11 @@
|
|
|
11
11
|
],
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"react-countdown": "^2.3.5",
|
|
14
|
-
"@cleartrip/ct-platform-io-hoc": "3.0.3-beta.
|
|
15
|
-
"@cleartrip/ct-platform-
|
|
16
|
-
"@cleartrip/ct-platform-
|
|
17
|
-
"@cleartrip/ct-platform-constants": "3.3.3-beta.
|
|
18
|
-
"@cleartrip/ct-platform-lazy-image": "3.7.0-beta.
|
|
14
|
+
"@cleartrip/ct-platform-io-hoc": "3.0.3-beta.1",
|
|
15
|
+
"@cleartrip/ct-platform-utils": "3.13.1-beta.0",
|
|
16
|
+
"@cleartrip/ct-platform-merch-carousel": "3.9.0-beta.26",
|
|
17
|
+
"@cleartrip/ct-platform-constants": "3.3.3-beta.1",
|
|
18
|
+
"@cleartrip/ct-platform-lazy-image": "3.7.0-beta.23"
|
|
19
19
|
},
|
|
20
20
|
"peerDependencies": {
|
|
21
21
|
"react": ">=16.8.0",
|