@cleartrip/ct-platform-timer-widget 3.8.0-beta.23 → 3.8.0-beta.25
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"),l=require("@cleartrip/ct-platform-lazy-image"),o=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__Sijt2",_="index-module_placeholder__wP5wX",x="index-module_header-ph-img__UNHQP",v="index-module_content-ph-img__CNQxE",f="index-module_placeholder-img-wrapper__n6YwL";!function(e,i){void 0===i&&(i={});var n=i.insertAt;if("undefined"!=typeof document){var t=document.head||document.getElementsByTagName("head")[0],l=document.createElement("style");l.type="text/css","top"===n&&t.firstChild?t.insertBefore(l,t.firstChild):t.appendChild(l),l.styleSheet?l.styleSheet.cssText=e:l.appendChild(document.createTextNode(e))}}(".index-module_timer-bg-image__Sijt2{background-position:50%;background-repeat:no-repeat;background-size:cover;height:100%;position:relative;width:100%}.index-module_timer-content__2zNIK{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__eM0Ge{align-items:center;display:flex;width:calc(100% - 32px)}.index-module_timer-box__Rkpl7{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__Rkpl7>span:nth-child(2){font-size:12px;padding-top:4px}.index-module_timer-separator__pLdY6{font-family:Inter!important;font-size:32px;font-weight:500}.index-module_timer-button__xhq-3{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__wP5wX{padding:8px}.index-module_header-ph-img__UNHQP{height:50%;width:auto}.index-module_content-ph-img__CNQxE{height:15%;position:absolute;top:40%;width:auto}.index-module_placeholder-img-wrapper__n6YwL{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,w=t.headerImg,C=t.widgetData,S=t.lazyWidget,I=void 0===S||S,k=t.onItemView,N=t.onItemClick,z=t.onItemImpression,A=t.styleConfig,q=t.renderItem,T=n.useState(!I),W=T[0],D=T[1],E=n.useState(I),H=E[0],L=E[1],M=n.useMemo((function(){var e;return a.getDimensionFromImageUrl(null===(e=null==C?void 0:C.image)||void 0===e?void 0:e.url)}),[null===(s=null==C?void 0:C.image)||void 0===s?void 0:s.url]),R=M.heightInNumber,U=M.widthInNumber,F=n.useState(R/U*100),P=F[0],B=F[1],O=n.useMemo((function(){return a.getDimensionFromImageUrl(w).height}),[w]);n.useEffect((function(){var e;Q(null===(e=null==C?void 0:C.image)||void 0===e?void 0:e.url)}),[]);var Q=n.useCallback((function(e){if(e){var i=new Image;i.src=e,i.onload=function(){!q&&B(i.height/i.width*100),L(!1)}}}),[]),Y=n.useCallback((function(n){var t=n.days,l=n.hours,o=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==C?void 0:C.colonColor)?"".concat(C.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:"HRS"}))]})),i.jsx("div",e.__assign({style:e.__assign(e.__assign({},u),{color:(null==C?void 0:C.colonColor)?"".concat(C.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:"MINS"}))]})),i.jsx("div",e.__assign({style:e.__assign(e.__assign({},u),{color:(null==C?void 0:C.colonColor)?"".concat(C.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;N&&(null==C?void 0:C.label)&&(null===(i=null==C?void 0:C.image)||void 0===i?void 0:i.url)&&N(null==C?void 0:C.label,null===(n=null==C?void 0:C.image)||void 0===n?void 0:n.url),window.location.href=e}),[N]),G=n.useCallback((function(){var e;k&&k(null==C?void 0:C.label,null===(e=null==C?void 0:C.image)||void 0===e?void 0:e.url)}),[C,k]),K=n.useCallback((function(){var e;I&&D(!0),z&&z(null==C?void 0:C.label,null===(e=null==C?void 0:C.image)||void 0===e?void 0:e.url)}),[C,z]),V=n.useCallback((function(){var n,t=a.getHeightFromImgUrl(null===(n=null==C?void 0:C.image)||void 0===n?void 0:n.url)||180;return i.jsxs("div",{children:[w&&i.jsx("div",e.__assign({className:_,style:{height:O}},{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(P,"%")}},{children:i.jsx("img",{src:r.placeholderLogo,className:v})}))}))]})}),[w,C,P]),J=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}(!!q,null===(e=null==C?void 0:C.image)||void 0===e?void 0:e.url,P)}),[!!q,null===(b=null==C?void 0:C.image)||void 0===b?void 0:b.url,P]);return i.jsx(o.IntersectionObserverHOC,e.__assign({onIntersection:K,onTimedObservationComplete:G},{children:W?i.jsxs("div",{children:[w&&i.jsx(l.LazyImage,{src:w,style:{width:"100%",height:O}}),!H&&i.jsxs("div",e.__assign({className:h,style:e.__assign(e.__assign({},J),null==A?void 0:A.timerWidgetImageWrapper),onClick:function(){var e;return X(null===(e=null==C?void 0:C.cta)||void 0===e?void 0:e.targetUrl)}},{children:[null==q?void 0:q(),i.jsxs("div",e.__assign({style:g},{children:[i.jsx(d.default,{date:null==C?void 0:C.endTime,renderer:Y}),(null===(y=null==C?void 0:C.cta)||void 0===y?void 0:y.title)&&i.jsx("button",e.__assign({style:m},{children:null===(j=null==C?void 0:C.cta)||void 0===j?void 0:j.title}))]}))]}),null==C?void 0:C.label)]}):i.jsx(i.Fragment,{children:V()})}))};
|
|
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 n}from"react/jsx-runtime";import{useState as o,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__Sijt2",y="index-module_placeholder__wP5wX",b="index-module_header-ph-img__UNHQP",w="index-module_content-ph-img__CNQxE",C="index-module_placeholder-img-wrapper__n6YwL";!function(e,i){void 0===i&&(i={});var t=i.insertAt;if("undefined"!=typeof document){var n=document.head||document.getElementsByTagName("head")[0],o=document.createElement("style");o.type="text/css","top"===t&&n.firstChild?n.insertBefore(o,n.firstChild):n.appendChild(o),o.styleSheet?o.styleSheet.cssText=e:o.appendChild(document.createTextNode(e))}}(".index-module_timer-bg-image__Sijt2{background-position:50%;background-repeat:no-repeat;background-size:cover;height:100%;position:relative;width:100%}.index-module_timer-content__2zNIK{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__eM0Ge{align-items:center;display:flex;width:calc(100% - 32px)}.index-module_timer-box__Rkpl7{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__Rkpl7>span:nth-child(2){font-size:12px;padding-top:4px}.index-module_timer-separator__pLdY6{font-family:Inter!important;font-size:32px;font-weight:500}.index-module_timer-button__xhq-3{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__wP5wX{padding:8px}.index-module_header-ph-img__UNHQP{height:50%;width:auto}.index-module_content-ph-img__CNQxE{height:15%;position:absolute;top:40%;width:auto}.index-module_placeholder-img-wrapper__n6YwL{align-items:center;background:#fef5f2;border-radius:8px;display:flex;height:100%;justify-content:center;position:relative;width:100%}");var S=function(S){var I,N,k,z,A=S.headerImg,j=S.widgetData,T=S.lazyWidget,R=void 0===T||T,W=S.onItemView,E=S.onItemClick,P=S.onItemImpression,B=S.styleConfig,D=S.renderItem,H=o(!R),Q=H[0],Y=H[1],L=o(R),U=L[0],M=L[1],O=l((function(){var e;return p(null===(e=null==j?void 0:j.image)||void 0===e?void 0:e.url)}),[null===(I=null==j?void 0:j.image)||void 0===I?void 0:I.url]),X=O.heightInNumber,q=O.widthInNumber,G=o(X/q*100),K=G[0],V=G[1],F=l((function(){return p(A).height}),[A]);r((function(){var e;J(null===(e=null==j?void 0:j.image)||void 0===e?void 0:e.url)}),[]);var J=d((function(e){if(e){var i=new Image;i.src=e,i.onload=function(){!D&&V(i.height/i.width*100),M(!1)}}}),[]),Z=d((function(o){var l=o.days,r=o.hours,d=o.minutes,a=o.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:[n("span",{children:String(l).padStart(2,"0")}),n("span",e({style:x},{children:"DAYS"}))]})),n("div",e({style:e(e({},v),{color:(null==j?void 0:j.colonColor)?"".concat(j.colonColor):"#1A1A1A"})},{children:":"}))]}),i("div",e({style:h},{children:[n("span",{children:String(r).padStart(2,"0")}),n("span",e({style:x},{children:"HRS"}))]})),n("div",e({style:e(e({},v),{color:(null==j?void 0:j.colonColor)?"".concat(j.colonColor):"#1A1A1A"})},{children:":"})),i("div",e({style:h},{children:[n("span",{children:String(d).padStart(2,"0")}),n("span",e({style:x},{children:"MINS"}))]})),n("div",e({style:e(e({},v),{color:(null==j?void 0:j.colonColor)?"".concat(j.colonColor):"#1A1A1A"})},{children:":"})),i("div",e({style:h},{children:[n("span",{children:String(a).padStart(2,"0")}),n("span",e({style:x},{children:"SECS"}))]}))]}))}),[]),$=d((function(e){var i,t;E&&(null==j?void 0:j.label)&&(null===(i=null==j?void 0:j.image)||void 0===i?void 0:i.url)&&E(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}),[E]),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;R&&Y(!0),P&&P(null==j?void 0:j.label,null===(e=null==j?void 0:j.image)||void 0===e?void 0:e.url)}),[j,P]),te=d((function(){var t,o=m(null===(t=null==j?void 0:j.image)||void 0===t?void 0:t.url)||180;return i("div",{children:[A&&n("div",e({className:y,style:{height:F}},{children:n("div",e({className:C},{children:n("img",{src:s,className:b})}))})),n("div",e({className:y,style:{minHeight:"".concat(o,"px")}},{children:n("div",e({className:C,style:{paddingBottom:"".concat(K,"%")}},{children:n("img",{src:s,className:w})}))}))]})}),[A,j,K]),ne=l((function(){var e;return function(e,i,t){var n={position:"relative"};return e||Object.assign(n,{width:"100%",height:"100%",backgroundSize:"cover",backgroundRepeat:"no-repeat",backgroundPosition:"center",backgroundImage:"url(".concat(i,")"),paddingBottom:"".concat(t,"%")}),n}(!!D,null===(e=null==j?void 0:j.image)||void 0===e?void 0:e.url,K)}),[!!D,null===(N=null==j?void 0:j.image)||void 0===N?void 0:N.url,K]);return n(u,e({onIntersection:ie,onTimedObservationComplete:ee},{children:Q?i("div",{children:[A&&n(c,{src:A,style:{width:"100%",height:F}}),!U&&i("div",e({className:_,style:e(e({},ne),null==B?void 0:B.timerWidgetImageWrapper),onClick:function(){var e;return $(null===(e=null==j?void 0:j.cta)||void 0===e?void 0:e.targetUrl)}},{children:[null==D?void 0:D(),i("div",e({style:g},{children:[n(a,{date:null==j?void 0:j.endTime,renderer:Z}),(null===(k=null==j?void 0:j.cta)||void 0===k?void 0:k.title)&&n("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)]}):n(t,{children:te()})}))};export{S 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.25",
|
|
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.
|
|
15
|
-
"@cleartrip/ct-platform-
|
|
16
|
-
"@cleartrip/ct-platform-
|
|
17
|
-
"@cleartrip/ct-platform-constants": "3.3.
|
|
18
|
-
"@cleartrip/ct-platform-lazy-image": "3.7.0-beta.
|
|
14
|
+
"@cleartrip/ct-platform-io-hoc": "3.0.3-beta.0",
|
|
15
|
+
"@cleartrip/ct-platform-merch-carousel": "3.9.0-beta.25",
|
|
16
|
+
"@cleartrip/ct-platform-utils": "3.12.0-beta.22",
|
|
17
|
+
"@cleartrip/ct-platform-constants": "3.3.3-beta.0",
|
|
18
|
+
"@cleartrip/ct-platform-lazy-image": "3.7.0-beta.22"
|
|
19
19
|
},
|
|
20
20
|
"peerDependencies": {
|
|
21
21
|
"react": ">=16.8.0",
|