@ikas/storefront 4.15.0 → 4.15.1
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 +1 @@
|
|
|
1
|
-
import*as e from"react";import{observer as t}from"mobx-react-lite";import{CheckoutStep as n}from"../../model.js";import{Button as a}from"../button/index.js";import i from"./select/index.js";import o from"../svg/cross.js";import{useTranslation as r}from"../../../../utils/i18n.js";import c from"./style.module.scss.js";var s=function(t){var a,i,o=t.seconds,s=t.onFinish,u=t.campaignOffer,d=t.vm,f=t.isPopupClosed,m=t.step,p=r().t,v=e.useState(o),g=v[0],C=v[1];e.useEffect((function(){C(o)}),[o]),e.useEffect((function(){var e=setInterval((function(){g>0?C(g-1):(clearInterval(e),s())}),1e3);return function(){return clearInterval(e)}}),[g]);var S=u.offer.countdownMinutes&&(m!==n.SUCCESS?!!(null===(a=d.customizationProps)||void 0===a?void 0:a.campaignOfferCountdownStyleIsLine):!!(null===(i=d.customizationProps)||void 0===i?void 0:i.campaignOfferCountdownStyleIsLineSuccessPage))||f;return e.createElement("div",{className:S?c.CountdownContainerIsLine:c.CountdownContainer},e.createElement("div",{className:c.CountdownTextMain},!S&&e.createElement("span",{className:c.CountdownText},p("checkout-page:timeRemaining")),e.createElement("span",{className:c.CountdownTime},l(g))))},l=function(e){var t=Math.floor(e/60/60),n=Math.floor(e/60)-60*t,a=e%60;return 0!==t?t.toString().padStart(2,"0")+":":n.toString().padStart(2,"0")+":"+a.toString().padStart(2,"0")},u=t((function(t){var l,u,d,f,m,p,v,g=t.vm,C=t.campaignOffer,S=t.index,h=t.activeIndex,E=t.offersLength,P=t.handleNext,I=t.handlePrev,O=t.setActiveIndex,w=t.isPopupShow,V=t.closePopup,N=t.showPopup,M=t.isPopupClosed,B=t.desktopMiddlePhase,j=t.step,k=r().t,x=C.product,y=j!==n.SUCCESS?!!(null===(l=g.customizationProps)||void 0===l?void 0:l.campaignOfferIsSmallDesign)&&w:!!(null===(u=g.customizationProps)||void 0===u?void 0:u.showCampaignIsBiggerImage)&&j===n.SUCCESS,D=e.useRef(null),L=e.useRef(null),A=e.useRef(null),T=e.useState(0),z=T[0],R=T[1];e.useEffect((function(){var e,t,a,i,o,r,c,s;if(void 0!==typeof window){var l=.8*window.innerHeight,u=0,d=0,f=0;D.current&&(u=null===(t=null===(e=D.current)||void 0===e?void 0:e.getBoundingClientRect())||void 0===t?void 0:t.height),L.current&&(d=null===(i=null===(a=L.current)||void 0===a?void 0:a.getBoundingClientRect())||void 0===i?void 0:i.height),A.current&&(f=null===(r=null===(o=A.current)||void 0===o?void 0:o.getBoundingClientRect())||void 0===r?void 0:r.height);var m=(j===n.SUCCESS?null===(c=g.customizationProps)||void 0===c?void 0:c.campaignOfferCountdownStyleIsLineSuccessPage:null===(s=g.customizationProps)||void 0===s?void 0:s.campaignOfferCountdownStyleIsLine)?25:70,p=navigator.userAgent.match(/Version\/[\d\.]+.*Safari/)?20:0;R(l-u-d-f-p-m)}}),[w]);var U=e.useState(null),b=U[0],F=U[1],H=e.useState(null),X=H[0],q=H[1],G=e.useMemo((function(){var e,t,n,a,i,o,r,c=null===(e=x.selectedVariant.images)||void 0===e?void 0:e.filter((function(e){return!e.isVideo}));return(null===(t=x.selectedVariant.mainImage)||void 0===t?void 0:t.isVideo)&&(null==c?void 0:c.length)?null===(n=c[0].image)||void 0===n?void 0:n.thumbnailSrc:y||B?null===(i=null===(a=x.selectedVariant.mainImage)||void 0===a?void 0:a.image)||void 0===i?void 0:i.getSrc(360):null===(r=null===(o=x.selectedVariant.mainImage)||void 0===o?void 0:o.image)||void 0===r?void 0:r.thumbnailSrc}),[x.selectedVariant,y,B]),J=e.useMemo((function(){if(!C.offer.countdownMinutes||!C.campaignOffer.offerStartDate)return 0;var e=Math.round(((new Date).getTime()-new Date(C.campaignOffer.offerStartDate).getTime())/1e3);return e>60*C.offer.countdownMinutes?0:60*C.offer.countdownMinutes-e}),[C]),K=function(e){O(0),g.updateCartCampaignOffer({accepted:e,cartId:g.checkout.id,campaignOfferId:C.campaignOffer.campaignOfferId,campaignOfferProductId:C.offer.id,productId:C.offer.productId,variantId:x.selectedVariant.id})},Q=function(){K(!0)},W=function(){K(!1)},Y=C.offer.countdownMinutes&&(j!==n.SUCCESS?!!(null===(d=g.customizationProps)||void 0===d?void 0:d.campaignOfferCountdownStyleIsLine):!!(null===(f=g.customizationProps)||void 0===f?void 0:f.campaignOfferCountdownStyleIsLineSuccessPage))||M&&C.offer.countdownMinutes;return
|
|
1
|
+
import*as e from"react";import{observer as t}from"mobx-react-lite";import{CheckoutStep as n}from"../../model.js";import{Button as a}from"../button/index.js";import i from"./select/index.js";import o from"../svg/cross.js";import{useTranslation as r}from"../../../../utils/i18n.js";import c from"./style.module.scss.js";var s=function(t){var a,i,o=t.seconds,s=t.onFinish,u=t.campaignOffer,d=t.vm,f=t.isPopupClosed,m=t.step,p=r().t,v=e.useState(o),g=v[0],C=v[1];e.useEffect((function(){C(o)}),[o]),e.useEffect((function(){var e=setInterval((function(){g>0?C(g-1):(clearInterval(e),s())}),1e3);return function(){return clearInterval(e)}}),[g]);var S=u.offer.countdownMinutes&&(m!==n.SUCCESS?!!(null===(a=d.customizationProps)||void 0===a?void 0:a.campaignOfferCountdownStyleIsLine):!!(null===(i=d.customizationProps)||void 0===i?void 0:i.campaignOfferCountdownStyleIsLineSuccessPage))||f;return e.createElement("div",{className:S?c.CountdownContainerIsLine:c.CountdownContainer},e.createElement("div",{className:c.CountdownTextMain},!S&&e.createElement("span",{className:c.CountdownText},p("checkout-page:timeRemaining")),e.createElement("span",{className:c.CountdownTime},l(g))))},l=function(e){var t=Math.floor(e/60/60),n=Math.floor(e/60)-60*t,a=e%60;return 0!==t?t.toString().padStart(2,"0")+":":n.toString().padStart(2,"0")+":"+a.toString().padStart(2,"0")},u=t((function(t){var l,u,d,f,m,p,v,g=t.vm,C=t.campaignOffer,S=t.index,h=t.activeIndex,E=t.offersLength,P=t.handleNext,I=t.handlePrev,O=t.setActiveIndex,w=t.isPopupShow,V=t.closePopup,N=t.showPopup,M=t.isPopupClosed,B=t.desktopMiddlePhase,j=t.step,k=r().t,x=C.product,y=j!==n.SUCCESS?!!(null===(l=g.customizationProps)||void 0===l?void 0:l.campaignOfferIsSmallDesign)&&w:!!(null===(u=g.customizationProps)||void 0===u?void 0:u.showCampaignIsBiggerImage)&&j===n.SUCCESS,D=e.useRef(null),L=e.useRef(null),A=e.useRef(null),T=e.useState(0),z=T[0],R=T[1];e.useEffect((function(){var e,t,a,i,o,r,c,s;if(void 0!==typeof window){var l=.8*window.innerHeight,u=0,d=0,f=0;D.current&&(u=null===(t=null===(e=D.current)||void 0===e?void 0:e.getBoundingClientRect())||void 0===t?void 0:t.height),L.current&&(d=null===(i=null===(a=L.current)||void 0===a?void 0:a.getBoundingClientRect())||void 0===i?void 0:i.height),A.current&&(f=null===(r=null===(o=A.current)||void 0===o?void 0:o.getBoundingClientRect())||void 0===r?void 0:r.height);var m=(j===n.SUCCESS?null===(c=g.customizationProps)||void 0===c?void 0:c.campaignOfferCountdownStyleIsLineSuccessPage:null===(s=g.customizationProps)||void 0===s?void 0:s.campaignOfferCountdownStyleIsLine)?25:70,p=navigator.userAgent.match(/Version\/[\d\.]+.*Safari/)?20:0;R(l-u-d-f-p-m)}}),[w]);var U=e.useState(null),b=U[0],F=U[1],H=e.useState(null),X=H[0],q=H[1],G=e.useMemo((function(){var e,t,n,a,i,o,r,c=null===(e=x.selectedVariant.images)||void 0===e?void 0:e.filter((function(e){return!e.isVideo}));return(null===(t=x.selectedVariant.mainImage)||void 0===t?void 0:t.isVideo)&&(null==c?void 0:c.length)?null===(n=c[0].image)||void 0===n?void 0:n.thumbnailSrc:y||B?null===(i=null===(a=x.selectedVariant.mainImage)||void 0===a?void 0:a.image)||void 0===i?void 0:i.getSrc(360):null===(r=null===(o=x.selectedVariant.mainImage)||void 0===o?void 0:o.image)||void 0===r?void 0:r.thumbnailSrc}),[x.selectedVariant,y,B]),J=e.useMemo((function(){if(!C.offer.countdownMinutes||!C.campaignOffer.offerStartDate)return 0;var e=Math.round(((new Date).getTime()-new Date(C.campaignOffer.offerStartDate).getTime())/1e3);return e>60*C.offer.countdownMinutes?0:60*C.offer.countdownMinutes-e}),[C]),K=function(e){O(0),g.updateCartCampaignOffer({accepted:e,cartId:g.checkout.id,campaignOfferId:C.campaignOffer.campaignOfferId,campaignOfferProductId:C.offer.id,productId:C.offer.productId,variantId:x.selectedVariant.id})},Q=function(){K(!0)},W=function(){K(!1)},Y=C.offer.countdownMinutes&&(j!==n.SUCCESS?!!(null===(d=g.customizationProps)||void 0===d?void 0:d.campaignOfferCountdownStyleIsLine):!!(null===(f=g.customizationProps)||void 0===f?void 0:f.campaignOfferCountdownStyleIsLineSuccessPage))||M&&C.offer.countdownMinutes;return e.createElement("div",{style:{transform:"translateX(-".concat(100*h,"%)")},className:[c.Container,S===h?c.ActiveOffer:"",w?c.PopupContainer:"",B?c.PopupContainerDesktop:"",j===n.SUCCESS?c.Border:""].join(" ")},C.offer.countdownMinutes&&(j!==n.SUCCESS?!(null===(m=g.customizationProps)||void 0===m?void 0:m.campaignOfferCountdownStyleIsLine):!(null===(p=g.customizationProps)||void 0===p?void 0:p.campaignOfferCountdownStyleIsLineSuccessPage))&&!M&&e.createElement(s,{seconds:J,onFinish:W,vm:g,campaignOffer:C,step:j}),e.createElement("div",{onTouchStart:function(e){q(null),F(e.targetTouches[0].clientX)},onTouchMove:function(e){return q(e.targetTouches[0].clientX)},onTouchEnd:function(){if(b&&X&&E>1){var e=b-X,t=e>50;(t||e<-50)&&(t?P():I())}},className:[c.ContentContainer,E>1?c.ContentContainerItems:"",M?E>1?c.ContentContainerPopup:c.ContentContainerPopupItems:""].join(" ")},!!w&&e.createElement("div",{className:c.RejectButton,onClick:function(){return V&&V()}},e.createElement(o,null)),e.createElement("div",{ref:D,className:[c.HeaderMain,y&&!M?c.IsBigProductImage:"",Y?c.IsLineCountDown:"",M?c.MobileSmallHeader:""].join(" ")},e.createElement("div",{className:c.Header},e.createElement("div",{className:c.Title},C.offer.title),!!C.offer.description&&!M&&e.createElement("div",{className:c.Description},C.offer.description)),Y&&e.createElement(s,{seconds:J,onFinish:W,vm:g,campaignOffer:C,isPopupClosed:M,step:j})),e.createElement("div",{className:[c.ProductContainer,y&&!M?c.IsLineProductContainer:""].join(" ")},e.createElement("div",{style:w?{width:z,height:z}:{},className:[c.ImageContainer,y&&!M?c.BigImage:"",M?c.SmallImage:"",B?c.BiggerImage:""].join(" ")},e.createElement("img",{className:c.Image,src:G})),e.createElement("div",{ref:L,className:c.ProductDetails},e.createElement("div",{className:c.ProductName},x.name),x.hasVariant&&1===x.variants.length&&e.createElement("div",{className:c.VariantName},x.selectedVariant.variantValues.map((function(e){return e.name})).join(", ")),!(null===(v=g.customizationProps)||void 0===v?void 0:v.showCampaignHideDiscountBadge)&&x.selectedVariant.price.hasDiscount&&e.createElement("span",{className:c.DiscountBadge},"%",x.selectedVariant.price.discountPercentage," ",k("checkout-page:discount")),e.createElement("div",{className:c.ProductPriceMain},x.selectedVariant.price.hasDiscount&&e.createElement("span",{className:c.Discount},x.selectedVariant.price.formattedSellPrice," "),e.createElement("span",{className:c.ProductPrice},x.selectedVariant.price.formattedFinalPrice)),!M&&x.variants.length>1&&e.createElement("div",{className:c.Actions},x.variants.length>1&&e.createElement(i,{value:x.selectedVariant.id,onSelectChange:function(e){var t=null;x.displayedVariantTypes.forEach((function(n){n.displayedVariantValues.forEach((function(n){n.variant.id===e&&(t=n.variantValue)}))})),t&&x.selectVariantValue(t,!0)},options:x.variants.map((function(e){return{label:e.variantValues.map((function(e){return e.name})).join(", "),value:e.id}}))})),!!M&&e.createElement(a,{classes:[c.OfferButton,y?c.OfferAcceptButton:"",c.PopupOfferButton].join(" "),text:k("checkout-page:actions.acceptOffer"),onClick:function(){x.hasVariant?N&&N():Q()}}),!!B&&e.createElement("div",{className:[c.OfferActionsMain,y?c.OfferActionsMainBigImage:"",c.OfferActionsMainMiddlePhase].join(" ")},e.createElement(a,{classes:c.OfferButton,isLine:!0,text:k("checkout-page:actions.rejectOffer"),onClick:W}),e.createElement(a,{classes:[c.OfferButton,y?c.OfferAcceptButton:""].join(" "),text:e.createElement("div",null,e.createElement("span",null,k("checkout-page:actions.acceptOffer")),e.createElement("span",null),e.createElement("span",null,x.selectedVariant.price.formattedFinalPrice)),onClick:Q})))),!(M||B)&&e.createElement("div",{ref:A,className:[c.OfferActionsMain,y?c.OfferActionsMainBigImage:""].join(" ")},e.createElement(a,{classes:c.OfferButton,isLine:!0,text:k("checkout-page:actions.rejectOffer"),onClick:W}),e.createElement(a,{classes:[c.OfferButton,y?c.OfferAcceptButton:""].join(" "),text:k("checkout-page:actions.acceptOffer"),onClick:Q}))))}));export{u as default};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ikas/storefront",
|
|
3
|
-
"version": "4.15.
|
|
3
|
+
"version": "4.15.1",
|
|
4
4
|
"description": "Storefront functionality for ikas storefront themes.",
|
|
5
5
|
"author": "ikas",
|
|
6
6
|
"license": "ISC",
|
|
@@ -20,11 +20,11 @@
|
|
|
20
20
|
"web-streams-polyfill": "3.2.1"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@ikas/storefront-api": "^4.15.
|
|
24
|
-
"@ikas/storefront-config": "^4.15.
|
|
25
|
-
"@ikas/storefront-model-functions": "^4.15.
|
|
26
|
-
"@ikas/storefront-models": "^4.15.
|
|
27
|
-
"@ikas/storefront-providers": "^4.15.
|
|
23
|
+
"@ikas/storefront-api": "^4.15.1",
|
|
24
|
+
"@ikas/storefront-config": "^4.15.1",
|
|
25
|
+
"@ikas/storefront-model-functions": "^4.15.1",
|
|
26
|
+
"@ikas/storefront-models": "^4.15.1",
|
|
27
|
+
"@ikas/storefront-providers": "^4.15.1",
|
|
28
28
|
"@ikas/localized-address": "1.0.0-beta.3",
|
|
29
29
|
"@adyen/adyen-web": "^5.28.2",
|
|
30
30
|
"@rollup/plugin-commonjs": "^22.0.0",
|
|
@@ -58,11 +58,11 @@
|
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
60
|
"@ikas/localized-address": "1.0.0-beta.3",
|
|
61
|
-
"@ikas/storefront-api": "^4.15.
|
|
62
|
-
"@ikas/storefront-config": "^4.15.
|
|
63
|
-
"@ikas/storefront-model-functions": "^4.15.
|
|
64
|
-
"@ikas/storefront-models": "^4.15.
|
|
65
|
-
"@ikas/storefront-providers": "^4.15.
|
|
61
|
+
"@ikas/storefront-api": "^4.15.1",
|
|
62
|
+
"@ikas/storefront-config": "^4.15.1",
|
|
63
|
+
"@ikas/storefront-model-functions": "^4.15.1",
|
|
64
|
+
"@ikas/storefront-models": "^4.15.1",
|
|
65
|
+
"@ikas/storefront-providers": "^4.15.1",
|
|
66
66
|
"mobx": "^6.1.3",
|
|
67
67
|
"mobx-react-lite": "^3.1.5",
|
|
68
68
|
"next": "12.2.0",
|