@ikas/storefront 4.15.0-beta.127 → 4.15.0-beta.129

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{__spreadArray as e}from'./../../ext/tslib/tslib.es6.js';import*as t from"react";import{observer as r}from"mobx-react-lite";import{IkasStorefrontConfig as i}from"@ikas/storefront-config";import n from"../../hooks/useDimension.js";import o from"./renderer/index.js";import{checkSavedSessionForPopups as s}from"./utils/index.js";import{IkasStorefrontPopupDeviceTypeEnum as m}from"@ikas/storefront-models";var l=r((function(){var r=n().isMobile,l=t.useState([]),p=l[0],c=l[1];return t.useEffect((function(){s();var t=i.getStorefrontPopups().filter((function(e){return r?[m.ALL,m.MOBILE].includes(e.visibleDevice):[m.ALL,m.DESKTOP].includes(e.visibleDevice)})),n=document.head.querySelector('link[href="https://cdn.jsdelivr.net/npm/swiper@11/swiper-bundle.min.css"]');if(t.length&&!n){var o=document.createElement("link");o.type="text/css",o.rel="stylesheet",o.href="https://cdn.jsdelivr.net/npm/swiper@11/swiper-bundle.min.css",document.head.appendChild(o)}c(e([],t,!0))}),[r]),t.createElement(t.Fragment,null,p.map((function(e,r){return t.createElement(o,{storefrontPopup:e,key:e.id})})))}));export{l as PopupListRendererForPage};
1
+ import{__spreadArray as e}from'./../../ext/tslib/tslib.es6.js';import*as t from"react";import{observer as r}from"mobx-react-lite";import{IkasStorefrontConfig as i}from"@ikas/storefront-config";import n from"../../hooks/useDimension.js";import o from"./renderer/index.js";import{checkSavedSessionForPopups as s,checkIsPopupSavedToLocalStorage as m}from"./utils/index.js";import{IkasStorefrontPopupDeviceTypeEnum as l}from"@ikas/storefront-models";var p=r((function(){var r=n().isMobile,p=t.useState([]),c=p[0],d=p[1];return t.useEffect((function(){s();var t=i.getStorefrontPopups().filter((function(e){return!m(e.id)&&(r?[l.ALL,l.MOBILE].includes(e.visibleDevice):[l.ALL,l.DESKTOP].includes(e.visibleDevice))})),n=document.head.querySelector('link[href="https://cdn.jsdelivr.net/npm/swiper@11/swiper-bundle.min.css"]');if(t.length&&!n){var o=document.createElement("link");o.type="text/css",o.rel="stylesheet",o.href="https://cdn.jsdelivr.net/npm/swiper@11/swiper-bundle.min.css",document.head.appendChild(o)}d(e([],t,!0))}),[r]),t.createElement(t.Fragment,null,c.map((function(e,r){return t.createElement(o,{storefrontPopup:e,key:e.id})})))}));export{p as PopupListRendererForPage};
@@ -1 +1 @@
1
- import{__awaiter as e,__generator as o}from'./../../../ext/tslib/tslib.es6.js';import*as r from"react";import{observer as p}from"mobx-react-lite";import d from"../../../hooks/useDimension.js";import{IkasBaseStore as s}from"../../../store/base.js";import"../../../store/customer/index.js";import"../../../store/cart/index.js";import{IkasStorefrontPopupDisplayTriggerTypeEnum as n}from"../../../models/data/storefront-popup/storefront-popup-display-settings/index.js";import{exitIntent as t}from"../utils/index.js";import{IkasStorefrontPopupRendererViewModel as i}from"./model.js";import"react-date-picker/dist/DatePicker.css";import u from'./../../../ext/@ikas/popup-renderer/build/popup-renderer/components/index.js';import'./../../../ext/@ikas/popup-renderer/build/ext/tslib/tslib.es6.mjs.js';import'./../../../ext/@ikas/popup-renderer/build/ext/libphonenumber-js/es6/PhoneNumberMatcher.js';import'./../../../ext/@ikas/popup-renderer/build/ext/libphonenumber-js/es6/AsYouTypeFormatter.js';import'./../../../ext/@ikas/popup-renderer/build/ext/libphonenumber-js/es6/ParseError.js';import'./../../../ext/@ikas/popup-renderer/build/ext/libphonenumber-js/es6/metadata.js';import'./../../../ext/@ikas/popup-renderer/build/ext/libphonenumber-js/es6/PhoneNumber.js';import'./../../../ext/@ikas/popup-renderer/build/ext/libphonenumber-js/min/exports/PhoneNumberMatcher.js';import'./../../../ext/@ikas/popup-renderer/build/ext/libphonenumber-js/min/exports/AsYouType.js';import'./../../../ext/@ikas/popup-renderer/build/ext/libphonenumber-js/min/exports/Metadata.js';import'./../../../ext/@ikas/popup-renderer/build/ext/libphonenumber-js/es6/findNumbers/isValidCandidate.js';import'./../../../ext/@ikas/popup-renderer/build/ext/libphonenumber-js/index.es6.exports/PhoneNumberSearch.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/base/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/settings/index.js';import"mobx";import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/settings/visibility-condition/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/teaser/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/button/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/divider/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/form/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/form/checkbox/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/form/customer-attribute/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/form/customer-gender/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/image/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/image-column/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/product/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/product/detail-settings/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/social/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/space/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/text/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/background-settings/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/close-settings/index.js';var m=p((function(p){var m=p.storefrontPopup,l=r.useState((function(){return new i({},m)}))[0],a=d().isMobile;r.useEffect((function(){e(void 0,void 0,void 0,(function(){var e,r;return o(this,(function(o){switch(o.label){case 0:return[4,l.init()];case 1:if(o.sent(),!l.storefrontPopupData)return[2];if(!l.isModalClosedByUser){if((e=l.storefrontPopupData.displaySettings.triggerType)===n.SCROLL_DOWN)return window.addEventListener("scroll",l.handleScroll),[2,function(){window.removeEventListener("scroll",l.handleScroll)}];if(e===n.EXIT_INTENT)return r=t({onExitIntent:function(){l.openModal()}}),[2,function(){r()}]}return[2]}}))}))}),[]);var b=r.useCallback((function(r){return e(void 0,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return[4,l.addProductToCart(r)];case 1:return e.sent(),[2]}}))}))}),[]);return l.storefrontPopupData&&l.storefrontPopupData.contentJson&&!l.isLoading?r.createElement(u,{key:l.storefrontPopupData.id,popup:l.storefrontPopupData.contentJson,dynamicData:{products:l.popupProducts},sfProps:{onModalClose:l.onModalClose,onCustomerSave:l.onCustomerFormDataSave,isCustomerLoggedIn:l.isCustomerLoggedIn,currentCountryCode:s.getInstance().currentCountryCode||void 0,addProductToCart:b},isMobile:a}):null}));export{m as default};
1
+ import{__awaiter as e,__generator as o}from'./../../../ext/tslib/tslib.es6.js';import*as r from"react";import{observer as p}from"mobx-react-lite";import d from"../../../hooks/useDimension.js";import{IkasBaseStore as s}from"../../../store/base.js";import"../../../store/customer/index.js";import"../../../store/cart/index.js";import{IkasStorefrontPopupDisplayTriggerTypeEnum as n}from"../../../models/data/storefront-popup/storefront-popup-display-settings/index.js";import{exitIntent as t}from"../utils/index.js";import{IkasStorefrontPopupRendererViewModel as i}from"./model.js";import"react-date-picker/dist/DatePicker.css";import u from'./../../../ext/@ikas/popup-renderer/build/popup-renderer/components/index.js';import'./../../../ext/@ikas/popup-renderer/build/ext/tslib/tslib.es6.mjs.js';import'./../../../ext/@ikas/popup-renderer/build/ext/libphonenumber-js/es6/PhoneNumberMatcher.js';import'./../../../ext/@ikas/popup-renderer/build/ext/libphonenumber-js/es6/AsYouTypeFormatter.js';import'./../../../ext/@ikas/popup-renderer/build/ext/libphonenumber-js/es6/ParseError.js';import'./../../../ext/@ikas/popup-renderer/build/ext/libphonenumber-js/es6/metadata.js';import'./../../../ext/@ikas/popup-renderer/build/ext/libphonenumber-js/es6/PhoneNumber.js';import'./../../../ext/@ikas/popup-renderer/build/ext/libphonenumber-js/min/exports/PhoneNumberMatcher.js';import'./../../../ext/@ikas/popup-renderer/build/ext/libphonenumber-js/min/exports/AsYouType.js';import'./../../../ext/@ikas/popup-renderer/build/ext/libphonenumber-js/min/exports/Metadata.js';import'./../../../ext/@ikas/popup-renderer/build/ext/libphonenumber-js/es6/findNumbers/isValidCandidate.js';import'./../../../ext/@ikas/popup-renderer/build/ext/libphonenumber-js/index.es6.exports/PhoneNumberSearch.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/base/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/settings/index.js';import"mobx";import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/settings/visibility-condition/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/teaser/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/button/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/divider/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/form/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/form/checkbox/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/form/customer-attribute/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/form/customer-gender/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/image/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/image-column/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/product/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/product/detail-settings/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/social/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/space/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/text/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/background-settings/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/close-settings/index.js';var m=p((function(p){var m=p.storefrontPopup,l=r.useState((function(){return new i({},m)}))[0],a=d().isMobile;r.useEffect((function(){e(void 0,void 0,void 0,(function(){var e,r;return o(this,(function(o){switch(o.label){case 0:return[4,l.init()];case 1:if(o.sent(),!l.storefrontPopupData)return[2];if(!l.isModalClosedByUser){if((e=l.storefrontPopupData.displaySettings.triggerType)===n.SCROLL_DOWN)return window.addEventListener("scroll",l.handleScroll),[2,function(){window.removeEventListener("scroll",l.handleScroll)}];if(e===n.EXIT_INTENT)return r=t({onExitIntent:function(){l.openModal()}}),[2,function(){r()}]}return[2]}}))}))}),[]);var b=r.useCallback((function(r){return e(void 0,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return[4,l.addProductToCart(r)];case 1:return[2,e.sent()]}}))}))}),[]);return l.storefrontPopupData&&l.storefrontPopupData.contentJson&&!l.isLoading?r.createElement(u,{key:l.storefrontPopupData.id,popup:l.storefrontPopupData.contentJson,dynamicData:{products:l.popupProducts},sfProps:{onModalClose:l.onModalClose,onCustomerSave:l.onCustomerFormDataSave,isCustomerLoggedIn:l.isCustomerLoggedIn,currentCountryCode:s.getInstance().currentCountryCode||void 0,addProductToCart:b},isMobile:a}):null}));export{m as default};
@@ -12,7 +12,7 @@ export declare class IkasStorefrontPopupRendererViewModel {
12
12
  init(): Promise<void>;
13
13
  getStorefrontPopup(): Promise<void>;
14
14
  getStorefrontPopupProducts(): Promise<void>;
15
- addProductToCart(popupProduct: PopupProduct): Promise<void>;
15
+ addProductToCart(popupProduct: PopupProduct): Promise<boolean>;
16
16
  openModal(): void;
17
17
  onModalClose(addToLocalStorage?: boolean): void;
18
18
  onCustomerFormDataSave(customer: PopupRendererSaveCustomerInput): Promise<void>;
@@ -1 +1 @@
1
- import{__awaiter as t,__generator as o}from'./../../../ext/tslib/tslib.es6.js';import{IkasStorefrontConfig as e}from"@ikas/storefront-config";import{makeObservable as r,observable as s,action as i,computed as n}from"mobx";import a from"../../../store/storefront-popup/index.js";import{IkasStorefrontPopup as p}from"../../../models/data/storefront-popup/index.js";import{addPopupToLocalStorage as u,getPopupsFromLocalStorage as d,getPopupProducts as l}from"../utils/index.js";import{IkasStorefrontPopupDisplayFrequencyEnum as c,IkasStorefrontPopupDisplayTriggerTypeEnum as f}from"../../../models/data/storefront-popup/storefront-popup-display-settings/index.js";import{IkasBaseStore as h}from"../../../store/base.js";import"../../../store/customer/index.js";import"../../../store/cart/index.js";import{Analytics as m}from"../../../analytics/analytics.js";import"../../../analytics/head/index.js";var P=function(){function P(t,o){this.isLoading=t.isLoading||!0,this.storefrontPopup=o,this.storefrontPopupData=t.storefrontPopupData||null,this.popupProducts=t.popupProducts||{},this.isModalClosedByUser=t.isModalClosedByUser||!1,this.ikasProducts=t.ikasProducts||[],r(this,{isLoading:s,storefrontPopup:s,storefrontPopupData:s,popupProducts:s,isModalClosedByUser:s,ikasProducts:s,getStorefrontPopup:i.bound,getStorefrontPopupProducts:i.bound,openModal:i.bound,onModalClose:i.bound,init:i.bound,initTeaser:i.bound,checkDeviceType:i.bound,initTriggerType:i.bound,handleScroll:i.bound,onCustomerFormDataSave:i.bound,isCustomerLoggedIn:n})}return P.prototype.init=function(){return t(this,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return[4,this.getStorefrontPopup()];case 1:return t.sent(),[4,this.getStorefrontPopupProducts()];case 2:return t.sent(),this.initTeaser(),this.checkDeviceType(),this.initTriggerType(),this.isLoading=!1,[2]}}))}))},P.prototype.getStorefrontPopup=function(){var r,s;return t(this,void 0,void 0,(function(){var t,i,n;return o(this,(function(o){switch(o.label){case 0:return[4,a.listStorefrontPopup({idList:[this.storefrontPopup.id]})];case 1:return t=o.sent(),(null===(s=null===(r=t.data)||void 0===r?void 0:r.data)||void 0===s?void 0:s.length)&&(this.storefrontPopupData=new p(t.data.data[0]),i=d(),n=e.getSessionId(),i&&n&&i[n]&&this.storefrontPopupData.displaySettings.frequency===c.ONCE_PER_SESSION&&i[n].includes(this.storefrontPopup.id)&&(this.isModalClosedByUser=!0)),[2]}}))}))},P.prototype.getStorefrontPopupProducts=function(){var r,s;return t(this,void 0,void 0,(function(){var t,i,n;return o(this,(function(o){switch(o.label){case 0:return(null===(r=this.storefrontPopupData)||void 0===r?void 0:r.contentJson)?[4,l(this.storefrontPopupData.contentJson,e.getCdnUrl()||"",(null===(s=e.getMerchantSettings())||void 0===s?void 0:s.merchantId)||"",e.getPriceListId())]:[2];case 1:return t=o.sent(),i=t.totalProducts,n=t.ikasProducts,this.popupProducts=i,this.ikasProducts=n,[2]}}))}))},P.prototype.addProductToCart=function(e){return t(this,void 0,void 0,(function(){var t,r;return o(this,(function(o){switch(o.label){case 0:return t=this.ikasProducts.find((function(t){return t.id===e.productId})),r=null==t?void 0:t.variants.find((function(t){return t.id===e.variantId})),t&&r?[4,h.getInstance().cartStore.addItem(r,t)]:[3,2];case 1:o.sent(),o.label=2;case 2:return[2]}}))}))},P.prototype.openModal=function(){var t;(null===(t=this.storefrontPopupData)||void 0===t?void 0:t.contentJson)&&(this.isModalClosedByUser||(this.storefrontPopupData.contentJson.modal.isVisible=!0,m.viewStorefrontPopup(this.storefrontPopup)))},P.prototype.onModalClose=function(t){(this.isModalClosedByUser=!0,this.storefrontPopupData)&&((this.storefrontPopupData.displaySettings.frequency===c.ONCE_PER_SESSION||t)&&u(this.storefrontPopup.id))},P.prototype.onCustomerFormDataSave=function(e){return t(this,void 0,void 0,(function(){var t,r,s,i;return o(this,(function(o){switch(o.label){case 0:return t=h.getInstance(),r=t.customerStore,s=r.customer,i="",i=s&&s.email?s.email:e.email?e.email:e.firstName+e.lastName,[4,r.saveCustomerFormData({email:i,firstName:e.firstName||(null==s?void 0:s.firstName)||"",lastName:e.lastName||(null==s?void 0:s.lastName)||"",birthDate:e.birthday||(null==s?void 0:s.birthDate)||"",phone:e.phone||(null==s?void 0:s.phone)||"",storefrontPopupId:this.storefrontPopup.id,subscriptions:{email:!!e.hasPermission,phone:!!e.hasPermission,sms:!!e.hasPermission}})];case 1:return o.sent(),[2]}}))}))},P.prototype.initTeaser=function(){var t;(null===(t=this.storefrontPopupData)||void 0===t?void 0:t.contentJson)&&this.storefrontPopupData.contentJson.modal.teaser.isActive&&(this.storefrontPopupData.contentJson.modal.selectedStep=this.storefrontPopupData.contentJson.modal.teaser.step)},P.prototype.checkDeviceType=function(){this.storefrontPopupData&&this.storefrontPopupData.visibleDevice},P.prototype.initTriggerType=function(){var t=this;if(this.storefrontPopupData){var o=this.storefrontPopupData.displaySettings.triggerType,e=this.storefrontPopupData.displaySettings.triggerValue||0;if(o===f.ON_PAGE_LOAD)setTimeout((function(){t.openModal()}),1e3*e)}},P.prototype.handleScroll=function(){if(this.storefrontPopupData){var t=this.storefrontPopupData.displaySettings.triggerType,o=this.storefrontPopupData.displaySettings.triggerValue||0;if(f.SCROLL_DOWN===t&&this.storefrontPopupData&&!this.isModalClosedByUser){var e=o,r=window.innerHeight,s=document.documentElement.scrollHeight;window.scrollY/(s-r)*100>=e&&this.openModal()}}},Object.defineProperty(P.prototype,"isCustomerLoggedIn",{get:function(){return!!h.getInstance().customerStore.customer},enumerable:!1,configurable:!0}),P}();export{P as IkasStorefrontPopupRendererViewModel};
1
+ import{__awaiter as t,__generator as o}from'./../../../ext/tslib/tslib.es6.js';import{IkasStorefrontConfig as e}from"@ikas/storefront-config";import{makeObservable as r,observable as s,action as i,computed as n}from"mobx";import a from"../../../store/storefront-popup/index.js";import{IkasStorefrontPopup as p}from"../../../models/data/storefront-popup/index.js";import{addPopupToLocalStorage as u,getPopupsFromLocalStorage as d,getPopupProducts as l}from"../utils/index.js";import{IkasStorefrontPopupDisplayFrequencyEnum as c,IkasStorefrontPopupDisplayTriggerTypeEnum as f}from"../../../models/data/storefront-popup/storefront-popup-display-settings/index.js";import{IkasBaseStore as h}from"../../../store/base.js";import"../../../store/customer/index.js";import"../../../store/cart/index.js";import{Analytics as m}from"../../../analytics/analytics.js";import"../../../analytics/head/index.js";var P=function(){function P(t,o){this.isLoading=t.isLoading||!0,this.storefrontPopup=o,this.storefrontPopupData=t.storefrontPopupData||null,this.popupProducts=t.popupProducts||{},this.isModalClosedByUser=t.isModalClosedByUser||!1,this.ikasProducts=t.ikasProducts||[],r(this,{isLoading:s,storefrontPopup:s,storefrontPopupData:s,popupProducts:s,isModalClosedByUser:s,ikasProducts:s,getStorefrontPopup:i.bound,getStorefrontPopupProducts:i.bound,openModal:i.bound,onModalClose:i.bound,init:i.bound,initTeaser:i.bound,checkDeviceType:i.bound,initTriggerType:i.bound,handleScroll:i.bound,onCustomerFormDataSave:i.bound,isCustomerLoggedIn:n})}return P.prototype.init=function(){return t(this,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return[4,this.getStorefrontPopup()];case 1:return t.sent(),[4,this.getStorefrontPopupProducts()];case 2:return t.sent(),this.initTeaser(),this.checkDeviceType(),this.initTriggerType(),this.isLoading=!1,[2]}}))}))},P.prototype.getStorefrontPopup=function(){var r,s;return t(this,void 0,void 0,(function(){var t,i,n;return o(this,(function(o){switch(o.label){case 0:return[4,a.listStorefrontPopup({idList:[this.storefrontPopup.id]})];case 1:return t=o.sent(),(null===(s=null===(r=t.data)||void 0===r?void 0:r.data)||void 0===s?void 0:s.length)&&(this.storefrontPopupData=new p(t.data.data[0]),i=d(),n=e.getSessionId(),i&&n&&i[n]&&this.storefrontPopupData.displaySettings.frequency===c.ONCE_PER_SESSION&&i[n].includes(this.storefrontPopup.id)&&(this.isModalClosedByUser=!0)),[2]}}))}))},P.prototype.getStorefrontPopupProducts=function(){var r,s;return t(this,void 0,void 0,(function(){var t,i,n;return o(this,(function(o){switch(o.label){case 0:return(null===(r=this.storefrontPopupData)||void 0===r?void 0:r.contentJson)?[4,l(this.storefrontPopupData.contentJson,e.getCdnUrl()||"",(null===(s=e.getMerchantSettings())||void 0===s?void 0:s.merchantId)||"",e.getPriceListId())]:[2];case 1:return t=o.sent(),i=t.totalProducts,n=t.ikasProducts,this.popupProducts=i,this.ikasProducts=n,[2]}}))}))},P.prototype.addProductToCart=function(e){return t(this,void 0,void 0,(function(){var t,r,s,i;return o(this,(function(o){switch(o.label){case 0:return t=this.ikasProducts.find((function(t){return t.id===e.productId})),r=null==t?void 0:t.variants.find((function(t){return t.id===e.variantId})),s=void 0,((null==t?void 0:t.hasVariant)||(null==t?void 0:t.productOptionSetId))&&e.url&&((i=document.createElement("a")).href=e.url,i.target="_self",i.click()),t&&r?[4,h.getInstance().cartStore.addItem(r,t)]:[3,2];case 1:s=o.sent(),o.label=2;case 2:return[2,!!(null==s?void 0:s.success)]}}))}))},P.prototype.openModal=function(){var t;(null===(t=this.storefrontPopupData)||void 0===t?void 0:t.contentJson)&&!this.storefrontPopupData.contentJson.modal.isVisible&&(this.isModalClosedByUser||(this.storefrontPopupData.contentJson.modal.isVisible=!0,m.viewStorefrontPopup(this.storefrontPopup)))},P.prototype.onModalClose=function(t){(this.isModalClosedByUser=!0,this.storefrontPopupData)&&((this.storefrontPopupData.displaySettings.frequency===c.ONCE_PER_SESSION||t)&&u(this.storefrontPopup.id))},P.prototype.onCustomerFormDataSave=function(e){return t(this,void 0,void 0,(function(){var t,r,s,i;return o(this,(function(o){switch(o.label){case 0:return t=h.getInstance(),r=t.customerStore,s=r.customer,i="",i=s&&s.email?s.email:e.email?e.email:e.firstName+e.lastName,[4,r.saveCustomerFormData({email:i,firstName:e.firstName||(null==s?void 0:s.firstName)||"",lastName:e.lastName||(null==s?void 0:s.lastName)||"",birthDate:e.birthday||(null==s?void 0:s.birthDate)||"",phone:e.phone||(null==s?void 0:s.phone)||"",storefrontPopupId:this.storefrontPopup.id,subscriptions:{email:!!e.hasPermission,phone:!!e.hasPermission,sms:!!e.hasPermission}})];case 1:return o.sent(),[2]}}))}))},P.prototype.initTeaser=function(){var t;(null===(t=this.storefrontPopupData)||void 0===t?void 0:t.contentJson)&&this.storefrontPopupData.contentJson.modal.teaser.isActive&&(this.storefrontPopupData.contentJson.modal.selectedStep=this.storefrontPopupData.contentJson.modal.teaser.step)},P.prototype.checkDeviceType=function(){this.storefrontPopupData&&this.storefrontPopupData.visibleDevice},P.prototype.initTriggerType=function(){var t=this;if(this.storefrontPopupData){var o=this.storefrontPopupData.displaySettings.triggerType,e=this.storefrontPopupData.displaySettings.triggerValue||0;if(o===f.ON_PAGE_LOAD)setTimeout((function(){t.openModal()}),1e3*e)}},P.prototype.handleScroll=function(){if(this.storefrontPopupData){var t=this.storefrontPopupData.displaySettings.triggerType,o=this.storefrontPopupData.displaySettings.triggerValue||0;if(f.SCROLL_DOWN===t&&this.storefrontPopupData&&!this.isModalClosedByUser){var e=o,r=window.innerHeight,s=document.documentElement.scrollHeight;window.scrollY/(s-r)*100>=e&&this.openModal()}}},Object.defineProperty(P.prototype,"isCustomerLoggedIn",{get:function(){return!!h.getInstance().customerStore.customer},enumerable:!1,configurable:!0}),P}();export{P as IkasStorefrontPopupRendererViewModel};
@@ -5,6 +5,7 @@ export declare const SESSION_POPUPS_KEY = "ikas-storefront-popups";
5
5
  export declare const getPopupsFromLocalStorage: () => SessionStorefrontPopups | null;
6
6
  export declare const addPopupToLocalStorage: (popupId: string) => void;
7
7
  export declare const checkSavedSessionForPopups: () => void;
8
+ export declare const checkIsPopupSavedToLocalStorage: (popupId: string) => boolean;
8
9
  export declare function getPopupProducts(model: Popup, cdnURL: string, merchantId: string, priceListId?: string): Promise<{
9
10
  totalProducts: Record<string, PopupProduct[]>;
10
11
  ikasProducts: IkasProduct[];
@@ -1 +1 @@
1
- import{__spreadArray as e,__awaiter as r,__generator as o,__assign as n}from'./../../../ext/tslib/tslib.es6.js';import{IkasStorefrontConfig as d}from"@ikas/storefront-config";import t from"lodash/throttle";import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/components/index.js';import{getPopupDynamicData as s}from'./../../../ext/@ikas/popup-renderer/build/popup-renderer/helpers/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/settings/index.js';import"mobx";import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/settings/visibility-condition/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/teaser/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/index.js';import{PopupElementTypeEnum as i}from'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/base/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/button/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/divider/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/form/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/form/checkbox/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/form/customer-attribute/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/form/customer-gender/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/image/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/image-column/index.js';import{ProductListTypeEnum as p,PopupProduct as u,MAX_PRODUCT_COUNT as l}from'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/product/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/product/detail-settings/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/social/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/space/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/text/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/background-settings/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/close-settings/index.js';import{SortByDirectionEnum as a}from"@ikas/storefront-api";import m from"../../../store/product/index.js";var c="ikas-storefront-popups",f=function(){var e=localStorage.getItem("ikas-storefront-popups");return e?JSON.parse(e):null},v=function(r){var o=f()||{},n=d.getSessionId();if(n){var t=o[n]?o[n]:[],s=r;o[n]=e(e([],t,!0),[s],!1),localStorage.setItem("ikas-storefront-popups",JSON.stringify(o))}},g=function(){var e=d.getSessionId(),r=f();r&&e&&!Object.keys(r).includes(e)&&localStorage.removeItem("ikas-storefront-popups")};function b(e,t,c,f){var v,g,b;return r(this,void 0,void 0,(function(){var r,f,k,x,h,_,I,j;return o(this,(function(P){switch(P.label){case 0:r={},f=[],k=[],e.modal.steps.forEach((function(e){e.elements.forEach((function(e){e.type===i.PRODUCT_LIST&&k.push(e)}))})),x=s(e),h=function(s){var i,k,h,_,I,j,P,E,y,S;return o(this,(function(o){switch(o.label){case 0:switch(i={input:{}},k=s.sortType.includes("ASC")?a.ASC:a.DESC,h=s.sortType.replace("ASC_","").replace("DESC_",""),_={direction:k,type:h},s.listType){case p.ALL:case p.LAST_VIEWED:i.input={page:1,perPage:l,order:_?[_]:void 0};break;case p.SPECIFIC:(I=s.variantPairs||[]).length&&(j=I.map((function(e){return e.productId})),i.input={productIdList:j,page:1,perPage:l,order:_?[_]:void 0});break;case p.CATEGORY:P=s.categoryId,i.input={categoryIdList:P?[P]:void 0,page:1,perPage:l,order:_?[_]:void 0}}return s.listType!==p.CATEGORY||i.input.categoryIdList?[4,m.searchProducts({input:n(n({},i.input),{priceListId:d.getPriceListId(),salesChannelId:d.getSalesChannelId()})})]:[2,"continue"];case 1:return(E=o.sent())&&E.isSuccess&&(null===(g=null===(v=E.data)||void 0===v?void 0:v.data)||void 0===g?void 0:g.length)&&(null==(y=null===(b=E.data)||void 0===b?void 0:b.data)?void 0:y.length)&&(S=[],y.forEach((function(r){var o,n,d;if(s.listType===p.SPECIFIC){var i=x.variantPairs.filter((function(e){return e.productListElementId===s.id}));(m=r.variants.find((function(e){return i.some((function(o){return o.productId===r.id&&o.variantId===e.id}))})))&&(d=[m])}else d=(null==r?void 0:r.variants[0])?[r.variants[0]]:[];for(var l=0,a=d||[];l<a.length;l++){var m;if((m=a[l])&&r){var v=(null===(o=m.images)||void 0===o?void 0:o.length)?m.images[0]:null;S.push(new u({productId:r.id,variantId:m.id,name:r.name,price:m.formattedSellPrice,discountPrice:m.hasDiscount?m.formattedDiscountPrice:null,discountRatio:m.discountPercentage?m.discountPercentage:null,imageURL:v?"".concat(t,"images/").concat(c,"/").concat(v.imageId):null,url:"".concat(e.storeUrl,"/").concat(null===(n=r.metaData)||void 0===n?void 0:n.slug)})),f.find((function(e){return e.id===r.id}))||f.push(r)}}})),r[s.id]=S),[2]}}))},_=0,I=k,P.label=1;case 1:return _<I.length?(j=I[_],[5,h(j)]):[3,4];case 2:P.sent(),P.label=3;case 3:return _++,[3,1];case 4:return[2,{totalProducts:r,ikasProducts:f}]}}))}))}var k=function(e){var r,o,d,s,i,p;return void 0===e&&(e={}),d=n(n({},{threshold:20,maxDisplays:1,eventThrottle:200,onExitIntent:function(){}}),e),s=new Map,i=0,p=function(){s.forEach((function(e,r,o){return function(e){var r=s.get(e),o=r.eventName,n=r.callback;document.removeEventListener(o,n),s.delete(e)}(r)}))},r="mousemove",o=t((function(e){e.clientY<=d.threshold&&i<d.maxDisplays&&(i++,1)&&(d.onExitIntent(),i>=d.maxDisplays&&p())}),d.eventThrottle),document.addEventListener(r,o,!1),s.set("document:".concat(r),{eventName:r,callback:o}),p};export{c as SESSION_POPUPS_KEY,v as addPopupToLocalStorage,g as checkSavedSessionForPopups,k as exitIntent,b as getPopupProducts,f as getPopupsFromLocalStorage};
1
+ import{__spreadArray as e,__awaiter as r,__generator as o,__assign as n}from'./../../../ext/tslib/tslib.es6.js';import{IkasStorefrontConfig as t}from"@ikas/storefront-config";import d from"lodash/throttle";import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/components/index.js';import{getPopupDynamicData as s}from'./../../../ext/@ikas/popup-renderer/build/popup-renderer/helpers/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/settings/index.js';import"mobx";import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/settings/visibility-condition/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/teaser/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/index.js';import{PopupElementTypeEnum as i}from'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/base/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/button/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/divider/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/form/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/form/checkbox/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/form/customer-attribute/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/form/customer-gender/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/image/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/image-column/index.js';import{ProductListTypeEnum as p,PopupProduct as u,MAX_PRODUCT_COUNT as a}from'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/product/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/product/detail-settings/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/social/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/space/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/text/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/background-settings/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/close-settings/index.js';import{SortByDirectionEnum as l}from"@ikas/storefront-api";import m from"../../../store/product/index.js";var c="ikas-storefront-popups",f=function(){var e=localStorage.getItem("ikas-storefront-popups");return e?JSON.parse(e):null},v=function(r){var o=f()||{},n=t.getSessionId();if(n){var d=o[n]?o[n]:[],s=r;o[n]=e(e([],d,!0),[s],!1),localStorage.setItem("ikas-storefront-popups",JSON.stringify(o))}},g=function(){var e=t.getSessionId(),r=f();r&&e&&!Object.keys(r).includes(e)&&localStorage.removeItem("ikas-storefront-popups")},b=function(e){var r=f();if(!r)return!1;var o=!1;return Object.keys(r).forEach((function(n){r[n].includes(e)&&(o=!0)})),o};function k(e,d,c,f){var v,g,b;return r(this,void 0,void 0,(function(){var r,f,k,h,x,_,j,I;return o(this,(function(P){switch(P.label){case 0:r={},f=[],k=[],e.modal.steps.forEach((function(e){e.elements.forEach((function(e){e.type===i.PRODUCT_LIST&&k.push(e)}))})),h=s(e),x=function(s){var i,k,x,_,j,I,P,E,y,S;return o(this,(function(o){switch(o.label){case 0:switch(i={input:{}},k=s.sortType.includes("ASC")?l.ASC:l.DESC,x=s.sortType.replace("ASC_","").replace("DESC_",""),_={direction:k,type:x},s.listType){case p.ALL:case p.LAST_VIEWED:i.input={page:1,perPage:a,order:_?[_]:void 0};break;case p.SPECIFIC:(j=s.variantPairs||[]).length&&(I=j.map((function(e){return e.productId})),i.input={productIdList:I,page:1,perPage:a,order:_?[_]:void 0});break;case p.CATEGORY:P=s.categoryId,i.input={categoryIdList:P?[P]:void 0,page:1,perPage:a,order:_?[_]:void 0}}return s.listType!==p.CATEGORY||i.input.categoryIdList?[4,m.searchProducts({input:n(n({},i.input),{priceListId:t.getPriceListId(),salesChannelId:t.getSalesChannelId()})})]:[2,"continue"];case 1:return(E=o.sent())&&E.isSuccess&&(null===(g=null===(v=E.data)||void 0===v?void 0:v.data)||void 0===g?void 0:g.length)&&(null==(y=null===(b=E.data)||void 0===b?void 0:b.data)?void 0:y.length)&&(S=[],y.forEach((function(r){var o,n,t;if(s.listType===p.SPECIFIC){var i=h.variantPairs.filter((function(e){return e.productListElementId===s.id}));(m=r.variants.find((function(e){return i.some((function(o){return o.productId===r.id&&o.variantId===e.id}))})))&&(t=[m])}else t=(null==r?void 0:r.variants[0])?[r.variants[0]]:[];for(var a=0,l=t||[];a<l.length;a++){var m;if((m=l[a])&&r){var v=(null===(o=m.images)||void 0===o?void 0:o.length)?m.images[0]:null;S.push(new u({productId:r.id,variantId:m.id,name:r.name,price:m.formattedSellPrice,discountPrice:m.hasDiscount?m.formattedDiscountPrice:null,discountRatio:m.discountPercentage?m.discountPercentage:null,imageURL:v?"".concat(d,"images/").concat(c,"/").concat(v.imageId):null,url:"".concat(e.storeUrl,"/").concat(null===(n=r.metaData)||void 0===n?void 0:n.slug)})),f.find((function(e){return e.id===r.id}))||f.push(r)}}})),r[s.id]=S),[2]}}))},_=0,j=k,P.label=1;case 1:return _<j.length?(I=j[_],[5,x(I)]):[3,4];case 2:P.sent(),P.label=3;case 3:return _++,[3,1];case 4:return[2,{totalProducts:r,ikasProducts:f}]}}))}))}var h=function(e){var r,o,t,s,i,p;return void 0===e&&(e={}),t=n(n({},{threshold:20,maxDisplays:1,eventThrottle:200,onExitIntent:function(){}}),e),s=new Map,i=0,p=function(){s.forEach((function(e,r,o){return function(e){var r=s.get(e),o=r.eventName,n=r.callback;document.removeEventListener(o,n),s.delete(e)}(r)}))},r="mousemove",o=d((function(e){e.clientY<=t.threshold&&i<t.maxDisplays&&(i++,1)&&(t.onExitIntent(),i>=t.maxDisplays&&p())}),t.eventThrottle),document.addEventListener(r,o,!1),s.set("document:".concat(r),{eventName:r,callback:o}),p};export{c as SESSION_POPUPS_KEY,v as addPopupToLocalStorage,b as checkIsPopupSavedToLocalStorage,g as checkSavedSessionForPopups,h as exitIntent,k as getPopupProducts,f as getPopupsFromLocalStorage};
@@ -1 +1 @@
1
- import{__spreadArray as t,__assign as e,__awaiter as o,__generator as n}from"../../../ext/tslib/tslib.es6.mjs.js";import i from"react";import{observer as l}from"../../../../../../mobx-react/dist/mobxreact.esm.js";import{getHorizontalAlignment as r,injectFontScript as d}from"../../helpers/index.js";import{ProductListTypeEnum as a,ProductListLayoutEnum as c}from"../../models/modal/step/elements/product/index.js";import s from"../button-element-renderer/index.js";import u from"../../../../../../swiper/modules/navigation.mjs.js";import m from"../../../../../../swiper/modules/scrollbar.mjs.js";import{Swiper as v,SwiperSlide as g}from"../../../../../../swiper/swiper-react.mjs.js";import p from"../../assets/left-arrow.js";import f from"../../assets/right-arrow.js";import{ProductActionTypeEnum as b}from"../../models/modal/step/elements/product/detail-settings/index.js";var h=l((function(l){var h,x=l.element,y=l.products,E=l.popup,C=l.editModeChildren,w=l.isPreviewMode,P=l.sfProps,S=l.onClose,j=i.useState(null),R=j[0],z=j[1],W=i.useState(!1),A=W[0],I=W[1],_=i.useState(!1),D=_[0],F=_[1],k=x,T=[];if(y&&(T=k.listType===a.SPECIFIC?(null===(h=k.variantPairs)||void 0===h?void 0:h.length)?y.slice().sort((function(t,e){return k.variantPairs.findIndex((function(e){return e.variantId===t.variantId}))-k.variantPairs.findIndex((function(t){return t.variantId===e.variantId}))})):[]:t([],y,!0)),T.length>k.maxProductsToShow&&(T.length=k.maxProductsToShow),!(T&&T.length||!E.isPreviewMode)&&C)return C;if(!T||!T.length)return null;k.gapBetweenProductElements;var L=k.productDetailSettings.image,N=k.productDetailSettings.button,B=k.buttonSettings,M=k.productDetailSettings.discountRatio,O=k.productDetailSettings.finalPrice,U=k.productDetailSettings.originalPrice,H=k.productDetailSettings.name,V=r(k.horizontalAlignment),$=1;k.layout===c.ONE_COLUMN?$=1:k.layout===c.TWO_COLUMN?$=2:k.layout===c.THREE_COLUMN&&($=3);var q={padding:"".concat(k.outerVerticalPadding,"px ").concat(k.outerHorizontalPadding,"px"),backgroundColor:k.productBgColor,width:"100%",height:"max-content"},G={display:"flex",flexDirection:"column",justifyContent:"space-between",alignItems:"center",height:"100%"},J={display:"flex",justifyContent:V,alignItems:"center",width:"100%",backgroundColor:null==L?void 0:L.bgColor,borderRadius:(null==L?void 0:L.borderRadius)?"".concat(L.borderRadius,"px"):void 0},K={width:"".concat(null==L?void 0:L.maxWidth,"%"),objectFit:"contain",borderRadius:(null==L?void 0:L.borderRadius)?"".concat(L.borderRadius,"px"):void 0},Q={display:"flex",flexDirection:"column",width:"100%"},X={display:"flex",flexDirection:"column"},Y={backgroundColor:null==H?void 0:H.bgColor,color:null==H?void 0:H.color,fontFamily:H?d(H.fontFamily):void 0,fontSize:null==H?void 0:H.fontSize,fontWeight:null==H?void 0:H.fontWeight,padding:"".concat(null==H?void 0:H.verticalPadding,"px ").concat(null==H?void 0:H.horizontalPadding,"px"),width:"100%",textAlign:null==H?void 0:H.horizontalAlignment,border:"".concat(null==H?void 0:H.borderWidth,"px ").concat(null==H?void 0:H.borderStyle," ").concat(null==H?void 0:H.borderColor),borderRadius:null==H?void 0:H.borderRadius},Z={backgroundColor:null==M?void 0:M.bgColor,color:null==M?void 0:M.color,fontFamily:M?d(M.fontFamily):void 0,fontSize:null==M?void 0:M.fontSize,fontWeight:null==M?void 0:M.fontWeight,padding:"".concat(null==M?void 0:M.verticalPadding,"px ").concat(null==M?void 0:M.horizontalPadding,"px"),width:"100%",textAlign:null==M?void 0:M.horizontalAlignment,border:"".concat(null==M?void 0:M.borderWidth,"px ").concat(null==M?void 0:M.borderStyle," ").concat(null==M?void 0:M.borderColor),borderRadius:null==M?void 0:M.borderRadius},tt={textDecoration:"line-through",backgroundColor:null==U?void 0:U.bgColor,color:null==U?void 0:U.color,fontFamily:U?d(U.fontFamily):void 0,fontSize:null==U?void 0:U.fontSize,fontWeight:null==U?void 0:U.fontWeight,padding:"".concat(null==U?void 0:U.verticalPadding,"px ").concat(null==U?void 0:U.horizontalPadding,"px"),width:"100%",textAlign:null==U?void 0:U.horizontalAlignment,border:"".concat(null==U?void 0:U.borderWidth,"px ").concat(null==U?void 0:U.borderStyle," ").concat(null==U?void 0:U.borderColor),borderRadius:null==U?void 0:U.borderRadius},et={backgroundColor:null==O?void 0:O.bgColor,color:null==O?void 0:O.color,fontFamily:O?d(O.fontFamily):void 0,fontSize:null==O?void 0:O.fontSize,fontWeight:null==O?void 0:O.fontWeight,padding:"".concat(null==O?void 0:O.verticalPadding,"px ").concat(null==O?void 0:O.horizontalPadding,"px"),width:"100%",textAlign:null==O?void 0:O.horizontalAlignment,border:"".concat(null==O?void 0:O.borderWidth,"px ").concat(null==O?void 0:O.borderStyle," ").concat(null==O?void 0:O.borderColor),borderRadius:null==O?void 0:O.borderRadius},ot={width:"".concat(B.width,"%"),minWidth:"fit-content"},nt=e({display:"flex",justifyContent:"center",width:"100%",gap:"10px"},1===$?{position:"absolute",top:0,left:0,right:0,bottom:0,alignItems:"center",justifyContent:"space-between",zIndex:10}:void 0),it={padding:10,display:"flex",justifyContent:"center",alignItems:"center",borderRadius:"100%",border:"1px solid #EEF2F6",cursor:"pointer"};return i.createElement("div",{style:q},i.createElement(v,{onSwiper:z,modules:[u,m],spaceBetween:k.gapBetweenProducts,slidesPerView:$,navigation:{nextEl:".custom-next-button",prevEl:".custom-prev-button"},scrollbar:void 0},T.map((function(t,e){return i.createElement(g,{style:{height:"auto"},key:t.variantId},i.createElement("div",{style:G,onClick:function(){return function(t){return o(void 0,void 0,void 0,(function(){var e,o;return n(this,(function(n){switch(n.label){case 0:return w||!t.url?[3,4]:(null===(o=k.productDetailSettings.button)||void 0===o?void 0:o.action)===b.ADD_TO_CART&&P?[4,P.addProductToCart(t)]:[3,2];case 1:return n.sent(),[3,3];case 2:(e=document.createElement("a")).href=t.url,e.target="_self",e.click(),n.label=3;case 3:S(!0),n.label=4;case 4:return[2]}}))}))}(t)}},i.createElement("div",{style:Q},!!L&&t.imageURL&&i.createElement("div",{style:J},i.createElement("img",{src:t.imageURL||void 0,alt:t.name||void 0,style:K})),(!!H||!!M)&&i.createElement("div",{style:X},!!H&&i.createElement("div",{style:Y},t.name),!!M&&!!t.discountPrice&&i.createElement("div",{style:Z},t.$discountRatio)),(!!U||!!O)&&i.createElement("div",null,!!U&&!!t.discountPrice&&i.createElement("div",{style:tt},t.price),!!O&&i.createElement("div",{style:et},t.discountPrice||t.price))),!!N&&i.createElement("div",{style:ot}," ",i.createElement(s,{element:B})," ")))})),i.createElement("div",{style:nt},i.createElement("div",{className:"custom-prev-button",style:e(e({},it),A?{opacity:.5,cursor:"not-allowed"}:{}),onClick:function(){R&&(R.slidePrev(),F(R.isEnd),I(R.isBeginning))}},i.createElement(p,null)),i.createElement("div",{className:"custom-next-button",style:e(e({},it),D?{opacity:.5,cursor:"not-allowed"}:{}),onClick:function(){R&&(R.slideNext(),F(R.isEnd),I(R.isBeginning))}},i.createElement(f,null)))))}));export{h as default};
1
+ import{__spreadArray as t,__assign as e,__awaiter as o,__generator as n}from"../../../ext/tslib/tslib.es6.mjs.js";import i from"react";import{observer as l}from"../../../../../../mobx-react/dist/mobxreact.esm.js";import{getHorizontalAlignment as r,injectFontScript as d}from"../../helpers/index.js";import{ProductListTypeEnum as a,ProductListLayoutEnum as c}from"../../models/modal/step/elements/product/index.js";import s from"../button-element-renderer/index.js";import u from"../../../../../../swiper/modules/navigation.mjs.js";import m from"../../../../../../swiper/modules/scrollbar.mjs.js";import{Swiper as v,SwiperSlide as p}from"../../../../../../swiper/swiper-react.mjs.js";import g from"../../assets/left-arrow.js";import f from"../../assets/right-arrow.js";import{ProductActionTypeEnum as b}from"../../models/modal/step/elements/product/detail-settings/index.js";var x=l((function(l){var x,h=l.element,y=l.products,E=l.popup,P=l.editModeChildren,w=l.isPreviewMode,C=l.sfProps,S=l.onClose,R=i.useState(null),z=R[0],j=R[1],D=i.useState(!1),W=D[0],I=D[1],_=i.useState(!1),A=_[0],F=_[1],k=h,T=[];if(y&&(T=k.listType===a.SPECIFIC?(null===(x=k.variantPairs)||void 0===x?void 0:x.length)?y.slice().sort((function(t,e){return k.variantPairs.findIndex((function(e){return e.variantId===t.variantId}))-k.variantPairs.findIndex((function(t){return t.variantId===e.variantId}))})):[]:t([],y,!0)),T.length>k.maxProductsToShow&&(T.length=k.maxProductsToShow),!(T&&T.length||!E.isPreviewMode)&&P)return P;if(!T||!T.length)return null;k.gapBetweenProductElements;var L=k.productDetailSettings.image,N=k.productDetailSettings.button,B=k.buttonSettings,H=k.productDetailSettings.discountRatio,M=k.productDetailSettings.finalPrice,O=k.productDetailSettings.originalPrice,U=k.productDetailSettings.name,V=r(k.horizontalAlignment),$=1;k.layout===c.ONE_COLUMN?$=1:k.layout===c.TWO_COLUMN?$=2:k.layout===c.THREE_COLUMN&&($=3);var q={padding:"".concat(k.outerVerticalPadding,"px ").concat(k.outerHorizontalPadding,"px"),backgroundColor:k.productBgColor,width:"100%",height:"max-content"},G={display:"flex",flexDirection:"column",justifyContent:"space-between",alignItems:"center",height:"100%"},J={display:"flex",justifyContent:V,alignItems:"center",width:"100%",backgroundColor:null==L?void 0:L.bgColor,borderRadius:(null==L?void 0:L.borderRadius)?"".concat(L.borderRadius,"px"):void 0},K={width:"".concat(null==L?void 0:L.maxWidth,"%"),objectFit:"contain",borderRadius:(null==L?void 0:L.borderRadius)?"".concat(L.borderRadius,"px"):void 0},Q={display:"flex",flexDirection:"column",width:"100%"},X={display:"flex",flexDirection:"column"},Y={backgroundColor:null==U?void 0:U.bgColor,color:null==U?void 0:U.color,fontFamily:U?d(U.fontFamily):void 0,fontSize:null==U?void 0:U.fontSize,fontWeight:null==U?void 0:U.fontWeight,padding:"".concat(null==U?void 0:U.verticalPadding,"px ").concat(null==U?void 0:U.horizontalPadding,"px"),width:"100%",textAlign:null==U?void 0:U.horizontalAlignment,border:"".concat(null==U?void 0:U.borderWidth,"px ").concat(null==U?void 0:U.borderStyle," ").concat(null==U?void 0:U.borderColor),borderRadius:null==U?void 0:U.borderRadius},Z={backgroundColor:null==H?void 0:H.bgColor,color:null==H?void 0:H.color,fontFamily:H?d(H.fontFamily):void 0,fontSize:null==H?void 0:H.fontSize,fontWeight:null==H?void 0:H.fontWeight,padding:"".concat(null==H?void 0:H.verticalPadding,"px ").concat(null==H?void 0:H.horizontalPadding,"px"),width:"100%",textAlign:null==H?void 0:H.horizontalAlignment,border:"".concat(null==H?void 0:H.borderWidth,"px ").concat(null==H?void 0:H.borderStyle," ").concat(null==H?void 0:H.borderColor),borderRadius:null==H?void 0:H.borderRadius},tt={textDecoration:"line-through",backgroundColor:null==O?void 0:O.bgColor,color:null==O?void 0:O.color,fontFamily:O?d(O.fontFamily):void 0,fontSize:null==O?void 0:O.fontSize,fontWeight:null==O?void 0:O.fontWeight,padding:"".concat(null==O?void 0:O.verticalPadding,"px ").concat(null==O?void 0:O.horizontalPadding,"px"),width:"100%",textAlign:null==O?void 0:O.horizontalAlignment,border:"".concat(null==O?void 0:O.borderWidth,"px ").concat(null==O?void 0:O.borderStyle," ").concat(null==O?void 0:O.borderColor),borderRadius:null==O?void 0:O.borderRadius},et={backgroundColor:null==M?void 0:M.bgColor,color:null==M?void 0:M.color,fontFamily:M?d(M.fontFamily):void 0,fontSize:null==M?void 0:M.fontSize,fontWeight:null==M?void 0:M.fontWeight,padding:"".concat(null==M?void 0:M.verticalPadding,"px ").concat(null==M?void 0:M.horizontalPadding,"px"),width:"100%",textAlign:null==M?void 0:M.horizontalAlignment,border:"".concat(null==M?void 0:M.borderWidth,"px ").concat(null==M?void 0:M.borderStyle," ").concat(null==M?void 0:M.borderColor),borderRadius:null==M?void 0:M.borderRadius},ot={width:"".concat(B.width,"%"),minWidth:"fit-content"},nt=e({display:"flex",justifyContent:"center",width:"100%",gap:"10px"},1===$?{position:"absolute",top:"calc(50% - 25px)",alignItems:"center",justifyContent:"space-between",zIndex:10}:void 0),it={padding:10,display:"flex",justifyContent:"center",alignItems:"center",borderRadius:"100%",border:"1px solid #EEF2F6",cursor:"pointer"};return i.createElement("div",{style:q},i.createElement(v,{onSwiper:j,modules:[u,m],spaceBetween:k.gapBetweenProducts,slidesPerView:$,navigation:{nextEl:".custom-next-button",prevEl:".custom-prev-button"},scrollbar:void 0},T.map((function(t,e){return i.createElement(p,{style:{height:"auto"},key:t.variantId},i.createElement("div",{style:G,onClick:function(){return function(t){return o(void 0,void 0,void 0,(function(){var e,o;return n(this,(function(n){switch(n.label){case 0:return w||!t.url?[3,4]:(null===(o=k.productDetailSettings.button)||void 0===o?void 0:o.action)===b.ADD_TO_CART&&C?[4,C.addProductToCart(t)]:[3,2];case 1:return n.sent()&&((e=document.createElement("a")).href="".concat(E.storeUrl,"/cart"),e.target="_self",e.click()),[3,3];case 2:(e=document.createElement("a")).href=t.url,e.target="_self",e.click(),n.label=3;case 3:S(!0),n.label=4;case 4:return[2]}}))}))}(t)}},i.createElement("div",{style:Q},!!L&&t.imageURL&&i.createElement("div",{style:J},i.createElement("img",{src:t.imageURL||void 0,alt:t.name||void 0,style:K})),!!U&&i.createElement("div",{style:X},!!U&&i.createElement("div",{style:Y},t.name)),(!!O||!!M||!!H)&&i.createElement("div",{style:{display:"flex",flexDirection:"column",gap:2}},!!H&&!!t.discountPrice&&i.createElement("div",{style:{padding:"".concat(H.outerVerticalPadding,"px ").concat(H.outerHorizontalPadding,"px"),width:"fit-content"}},i.createElement("div",{style:Z},function(t){return t.$discountRatio?k.productDetailSettings.discountRatioText?"".concat(t.$discountRatio," ").concat(k.productDetailSettings.discountRatioText):t.$discountRatio:null}(t))),i.createElement("div",{style:{display:"flex",alignItems:"center",gap:4,flexWrap:"wrap",overflow:"hidden"}},!!O&&!!t.discountPrice&&i.createElement("div",{style:{padding:"".concat(O.outerVerticalPadding,"px ").concat(O.outerHorizontalPadding,"px")}},i.createElement("div",{style:tt},t.price)),!!M&&i.createElement("div",{style:{padding:"".concat(M.outerVerticalPadding,"px ").concat(M.outerHorizontalPadding,"px")}},i.createElement("div",{style:et},t.discountPrice||t.price))))),!!N&&i.createElement("div",{style:ot}," ",i.createElement(s,{element:B})," ")))})),T.length>1&&i.createElement("div",{style:nt},i.createElement("div",{className:"custom-prev-button",style:e(e({},it),W?{opacity:.5,cursor:"not-allowed"}:{}),onClick:function(){z&&(z.slidePrev(),F(z.isEnd),I(z.isBeginning))}},i.createElement(g,null)),i.createElement("div",{className:"custom-next-button",style:e(e({},it),A?{opacity:.5,cursor:"not-allowed"}:{}),onClick:function(){z&&(z.slideNext(),F(z.isEnd),I(z.isBeginning))}},i.createElement(f,null)))))}));export{x as default};
@@ -1 +1 @@
1
- import{makeObservable as i,observable as t}from"mobx";import{TextElement as n}from"../../text/index.js";import"../../base/index.js";import{Popup as o}from"../../../../../index.js";var a,e,r=function(o){void 0===o&&(o={}),this.image=o.image?new s(o.image):new s({}),this.name=o.name?new n(o.name):new n({horizontalPadding:0,verticalPadding:6}),this.discountRatio=o.discountRatio?new n(o.discountRatio):null,this.originalPrice=o.originalPrice?new n(o.originalPrice):new n({horizontalPadding:0,verticalPadding:2,fontSize:14,color:"#697586"}),this.finalPrice=o.finalPrice?new n(o.finalPrice):new n({horizontalPadding:0,verticalPadding:2}),this.button=o.button?new d(o.button):new d({}),i(this,{image:t,name:t,discountRatio:t,originalPrice:t,finalPrice:t,button:t})},s=function(n){var o,a;this.bgColor=n.bgColor||"",this.maxWidth=null!==(o=n.maxWidth)&&void 0!==o?o:100,this.borderRadius=null!==(a=n.borderRadius)&&void 0!==a?a:0,i(this,{bgColor:t,maxWidth:t,borderRadius:t})};(e=a||(a={})).ADD_TO_CART="ADD_TO_CART",e.NAVIGATE_TO_PRODUCT_DETAIL="NAVIGATE_TO_PRODUCT_DETAIL";var d=function(n){void 0===n&&(n={}),this.text=n.text||o.t("popup:initialClassTranslations.productButtonText"),this.action=n.action||a.ADD_TO_CART,i(this,{text:t,action:t})};export{a as ProductActionTypeEnum,d as ProductButtonSettings,r as ProductDetailSettings,s as ProductImageSettings};
1
+ import{makeObservable as i,observable as t}from"mobx";import{TextElement as n}from"../../text/index.js";import"../../base/index.js";import{Popup as o}from"../../../../../index.js";var a,e,r=function(o){void 0===o&&(o={}),this.image=o.image?new s(o.image):new s({}),this.name=o.name?new n(o.name):new n({horizontalPadding:0,verticalPadding:6}),this.discountRatio=o.discountRatio?new n(o.discountRatio):null,this.originalPrice=o.originalPrice?new n(o.originalPrice):new n({horizontalPadding:0,verticalPadding:2,fontSize:14,color:"#697586"}),this.finalPrice=o.finalPrice?new n(o.finalPrice):new n({horizontalPadding:0,verticalPadding:2}),this.button=o.button?new d(o.button):new d({}),this.discountRatioText=o.discountRatioText||null,i(this,{image:t,name:t,discountRatio:t,originalPrice:t,finalPrice:t,button:t,discountRatioText:t})},s=function(n){var o,a;this.bgColor=n.bgColor||"",this.maxWidth=null!==(o=n.maxWidth)&&void 0!==o?o:100,this.borderRadius=null!==(a=n.borderRadius)&&void 0!==a?a:0,i(this,{bgColor:t,maxWidth:t,borderRadius:t})};(e=a||(a={})).ADD_TO_CART="ADD_TO_CART",e.NAVIGATE_TO_PRODUCT_DETAIL="NAVIGATE_TO_PRODUCT_DETAIL";var d=function(n){void 0===n&&(n={}),this.text=n.text||o.t("popup:initialClassTranslations.productButtonText"),this.action=n.action||a.ADD_TO_CART,i(this,{text:t,action:t})};export{a as ProductActionTypeEnum,d as ProductButtonSettings,r as ProductDetailSettings,s as ProductImageSettings};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ikas/storefront",
3
- "version": "4.15.0-beta.127",
3
+ "version": "4.15.0-beta.129",
4
4
  "description": "Storefront functionality for ikas storefront themes.",
5
5
  "author": "ikas",
6
6
  "license": "ISC",
@@ -17,15 +17,15 @@
17
17
  "build": "rm -rf build && rollup -c"
18
18
  },
19
19
  "dependencies": {
20
- "@ikas/popup-renderer": "^1.0.156",
20
+ "@ikas/popup-renderer": "^1.0.166",
21
21
  "swiper": "11.0.6"
22
22
  },
23
23
  "devDependencies": {
24
- "@ikas/storefront-api": "^4.15.0-beta.127",
25
- "@ikas/storefront-config": "^4.15.0-beta.127",
26
- "@ikas/storefront-model-functions": "^4.15.0-beta.127",
27
- "@ikas/storefront-models": "^4.15.0-beta.127",
28
- "@ikas/storefront-providers": "^4.15.0-beta.127",
24
+ "@ikas/storefront-api": "^4.15.0-beta.129",
25
+ "@ikas/storefront-config": "^4.15.0-beta.129",
26
+ "@ikas/storefront-model-functions": "^4.15.0-beta.129",
27
+ "@ikas/storefront-models": "^4.15.0-beta.129",
28
+ "@ikas/storefront-providers": "^4.15.0-beta.129",
29
29
  "@ikas/localized-address": "1.0.0-beta.3",
30
30
  "@adyen/adyen-web": "^5.57.0",
31
31
  "@rollup/plugin-commonjs": "^22.0.0",
@@ -60,11 +60,11 @@
60
60
  },
61
61
  "peerDependencies": {
62
62
  "@ikas/localized-address": "1.0.0-beta.3",
63
- "@ikas/storefront-api": "^4.15.0-beta.127",
64
- "@ikas/storefront-config": "^4.15.0-beta.127",
65
- "@ikas/storefront-model-functions": "^4.15.0-beta.127",
66
- "@ikas/storefront-models": "^4.15.0-beta.127",
67
- "@ikas/storefront-providers": "^4.15.0-beta.127",
63
+ "@ikas/storefront-api": "^4.15.0-beta.129",
64
+ "@ikas/storefront-config": "^4.15.0-beta.129",
65
+ "@ikas/storefront-model-functions": "^4.15.0-beta.129",
66
+ "@ikas/storefront-models": "^4.15.0-beta.129",
67
+ "@ikas/storefront-providers": "^4.15.0-beta.129",
68
68
  "mobx": "^6.1.3",
69
69
  "mobx-react-lite": "^3.1.5",
70
70
  "next": "12.2.0",