@ikas/storefront 5.0.61 → 5.0.63
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{__awaiter as t,__generator as e,__assign as r}from'./../../../ext/tslib/tslib.es6.js';import*as n from"react";import{listStorefrontPopup as o,SortByDirectionEnum as i}from"@ikas/storefront-api";import{IkasStorefrontConfig as s}from"@ikas/storefront-config";import{Analytics as a}from"../../../analytics/analytics.js";import"../../../analytics/head/index.js";import{IkasBaseStore as u}from"../../../store/base.js";import"../../../store/customer/index.js";import"../../../store/cart/index.js";import c from"../../../store/product/index.js";import{resolveStoreUrl as d,resolveCartUrl as l}from"./common.js";var p=function(r){return t(void 0,void 0,void 0,(function(){var n,o,i,p,v,m,h,g,w,I,P,S,y,k,C;return e(this,(function(L){switch(L.label){case 0:return n={popups:r,cartUrl:""},[4,function(){return new Promise((function(t){var e=setInterval((function(){var r=s.getSessionId();r&&(clearInterval(e),t(r))}),100)}))}()];case 1:return L.sent(),(o=s.getSessionId())&&(n.sessionId=o),(i=s.getCdnUrl())&&(n.cdnUrl=i),(p=null===(y=s.getMerchantSettings())||void 0===y?void 0:y.merchantId)&&(n.merchantId=p),(v=d())&&(n.storeUrl=v),(m=l())&&(n.cartUrl=m),(h=s.getCustomerToken())&&(n.customerToken=h),(g=s.getCurrentLocale())&&(n.locale=g),(w=null===(C=null===(k=s.getCurrentRouting())||void 0===k?void 0:k.countryCodes)||void 0===C?void 0:C[0])&&(n.countryCode=w),(I=s.getPriceListId())&&(n.priceListId=I),(P=s.getSalesChannelId())&&(n.salesChannelId=P),b=u.getInstance().customerStore.customer,(S=b?{email:b.email,firstName:b.firstName,lastName:b.lastName,birthDate:b.birthDate,phone:b.phone}:null)&&(n.customer=S),n.services=function(){var r=this,n=u.getInstance();return{searchProducts:function(n){return t(r,void 0,void 0,(function(){var t,r,o;return e(this,(function(e){switch(e.label){case 0:return[4,c.searchProducts(f(n))];case 1:return(null==(t=e.sent())?void 0:t.isSuccess)&&(null===(o=null===(r=t.data)||void 0===r?void 0:r.data)||void 0===o?void 0:o.length)?[2,t.data.data]:[2,[]]}}))}))},addItemToCart:function(o){var i=o.product,s=o.variant,a=o.quantity;return t(r,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,n.cartStore.addItem(s,i,null!=a?a:1)];case 1:return[2,{success:!!(null==(t=e.sent())?void 0:t.success)}]}}))}))},saveCustomerFormData:function(o){return t(r,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,n.customerStore.saveCustomerFormData({email:o.email,firstName:o.firstName,lastName:o.lastName,birthDate:o.birthDate||"",phone:o.phone||"",storefrontPopupId:o.popupId,subscriptions:o.subscriptions})];case 1:return t.sent(),[2]}}))}))},getLastViewedProducts:function(){return t(r,void 0,void 0,(function(){var t;return e(this,(function(e){return"function"==typeof(t=n.customerStore).getLastViewedProducts?[2,t.getLastViewedProducts()]:[2,[]]}))}))},formatVariantSellPrice:function(t){return t.formattedSellPrice||""},formatVariantDiscountPrice:function(t){return t.formattedDiscountPrice||null},hasVariantDiscount:function(t){return!!t.hasDiscount},getVariantDiscountPercentage:function(t){var e=t.discountPercentage;return null==e?null:"number"==typeof e?e.toString():e},redirectToProduct:function(t){return!!t.url&&(window.location.href=t.url,!0)},viewPopup:function(t){a.viewStorefrontPopup(t)}}}(),[2,n]}var b}))}))};function f(t){var e,r,n,o,a,u=null===(e=t.order)||void 0===e?void 0:e.map((function(t){return{direction:"ASC"===t.direction?i.ASC:i.DESC,type:t.type}}));return{input:{page:null!==(r=t.page)&&void 0!==r?r:1,perPage:null!==(n=t.perPage)&&void 0!==n?n:10,order:u,productIdList:t.productIdList,categoryIdList:t.categoryIdList,priceListId:null!==(o=t.priceListId)&&void 0!==o?o:s.getPriceListId(),salesChannelId:null!==(a=t.salesChannelId)&&void 0!==a?a:s.getSalesChannelId()}}}function v(i){var a=this
|
|
1
|
+
import{__awaiter as t,__generator as e,__assign as r}from'./../../../ext/tslib/tslib.es6.js';import*as n from"react";import{listStorefrontPopup as o,SortByDirectionEnum as i}from"@ikas/storefront-api";import{IkasStorefrontConfig as s}from"@ikas/storefront-config";import{Analytics as a}from"../../../analytics/analytics.js";import"../../../analytics/head/index.js";import{IkasBaseStore as u}from"../../../store/base.js";import"../../../store/customer/index.js";import"../../../store/cart/index.js";import c from"../../../store/product/index.js";import{resolveStoreUrl as d,resolveCartUrl as l}from"./common.js";var p=function(r){return t(void 0,void 0,void 0,(function(){var n,o,i,p,v,m,h,g,w,I,P,S,y,k,C;return e(this,(function(L){switch(L.label){case 0:return n={popups:r,cartUrl:""},[4,function(){return new Promise((function(t){var e=setInterval((function(){var r=s.getSessionId();r&&(clearInterval(e),t(r))}),100)}))}()];case 1:return L.sent(),(o=s.getSessionId())&&(n.sessionId=o),(i=s.getCdnUrl())&&(n.cdnUrl=i),(p=null===(y=s.getMerchantSettings())||void 0===y?void 0:y.merchantId)&&(n.merchantId=p),(v=d())&&(n.storeUrl=v),(m=l())&&(n.cartUrl=m),(h=s.getCustomerToken())&&(n.customerToken=h),(g=s.getCurrentLocale())&&(n.locale=g),(w=null===(C=null===(k=s.getCurrentRouting())||void 0===k?void 0:k.countryCodes)||void 0===C?void 0:C[0])&&(n.countryCode=w),(I=s.getPriceListId())&&(n.priceListId=I),(P=s.getSalesChannelId())&&(n.salesChannelId=P),b=u.getInstance().customerStore.customer,(S=b?{email:b.email,firstName:b.firstName,lastName:b.lastName,birthDate:b.birthDate,phone:b.phone}:null)&&(n.customer=S),n.services=function(){var r=this,n=u.getInstance();return{searchProducts:function(n){return t(r,void 0,void 0,(function(){var t,r,o;return e(this,(function(e){switch(e.label){case 0:return[4,c.searchProducts(f(n))];case 1:return(null==(t=e.sent())?void 0:t.isSuccess)&&(null===(o=null===(r=t.data)||void 0===r?void 0:r.data)||void 0===o?void 0:o.length)?[2,t.data.data]:[2,[]]}}))}))},addItemToCart:function(o){var i=o.product,s=o.variant,a=o.quantity;return t(r,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,n.cartStore.addItem(s,i,null!=a?a:1)];case 1:return[2,{success:!!(null==(t=e.sent())?void 0:t.success)}]}}))}))},saveCustomerFormData:function(o){return t(r,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,n.customerStore.saveCustomerFormData({email:o.email,firstName:o.firstName,lastName:o.lastName,birthDate:o.birthDate||"",phone:o.phone||"",storefrontPopupId:o.popupId,subscriptions:o.subscriptions})];case 1:return t.sent(),[2]}}))}))},getLastViewedProducts:function(){return t(r,void 0,void 0,(function(){var t;return e(this,(function(e){return"function"==typeof(t=n.customerStore).getLastViewedProducts?[2,t.getLastViewedProducts()]:[2,[]]}))}))},formatVariantSellPrice:function(t){return t.formattedSellPrice||""},formatVariantDiscountPrice:function(t){return t.formattedDiscountPrice||null},hasVariantDiscount:function(t){return!!t.hasDiscount},getVariantDiscountPercentage:function(t){var e=t.discountPercentage;return null==e?null:"number"==typeof e?e.toString():e},redirectToProduct:function(t){return!!t.url&&(window.location.href=t.url,!0)},viewPopup:function(t){a.viewStorefrontPopup(t)}}}(),[2,n]}var b}))}))};function f(t){var e,r,n,o,a,u=null===(e=t.order)||void 0===e?void 0:e.map((function(t){return{direction:"ASC"===t.direction?i.ASC:i.DESC,type:t.type}}));return{input:{page:null!==(r=t.page)&&void 0!==r?r:1,perPage:null!==(n=t.perPage)&&void 0!==n?n:10,order:u,productIdList:t.productIdList,categoryIdList:t.categoryIdList,priceListId:null!==(o=t.priceListId)&&void 0!==o?o:s.getPriceListId(),salesChannelId:null!==(a=t.salesChannelId)&&void 0!==a?a:s.getSalesChannelId()}}}function v(i){var a=this;i.router;var u=i.pageSpecificDataId,c=i.pageType;n.useEffect((function(){if("undefined"!=typeof window&&"undefined"!=typeof document){var n,i=!1,u=function(t,e){if(function(t){t.setAttribute("data-ikas-popup-widget","true"),!t.dataset.ikasPopupWidgetUrl&&t.src&&(t.dataset.ikasPopupWidgetUrl=t.src)}(t),"true"===t.dataset.ikasPopupWidgetLoaded)return e(),function(){};var r=function(){t.dataset.ikasPopupWidgetLoaded="true",e()},n=function(e){console.error("[@ikas/storefront] Failed to load popup widget script",t.src,e)};return t.addEventListener("load",r,{once:!0}),t.addEventListener("error",n,{once:!0}),function(){t.removeEventListener("load",r),t.removeEventListener("error",n)}},c=function(t){var e=window.location.href.includes("http://localhost:3333/")?"http://localhost:9000/popup-script-injector.iife.js":"/sf/assets/popup/popup-script-injector.iife.js";if(e){var r=function(){i||function(t){if("function"==typeof window.startIkasPopupWidget)try{window.startIkasPopupWidget(t)}catch(t){console.error("[@ikas/storefront] Failed to start popup widget",t)}}(t)},o=document.querySelector('script[data-ikas-popup-widget="true"]');if(o)n=u(o,r);else{var s=document.createElement("script");s.src=e,s.defer=!0,n=u(s,r),document.body.appendChild(s)}}},d=function(t){var e=window.location.href.includes("http://localhost:3333/")?"http://localhost:9000/style.css":"/sf/assets/popup/style.css";if(e&&!document.querySelector('link[href="'.concat(e,'"]'))){var r=document.createElement("link");r.rel="stylesheet",r.href=e,r.setAttribute("data-ikas-popup-widget","true");r.addEventListener("error",(function(t){console.error("[@ikas/storefront] Failed to load popup widget CSS",e,t)}),{once:!0}),document.head.appendChild(r)}};return t(a,void 0,void 0,(function(){var n,u,l;return e(this,(function(f){switch(f.label){case 0:return n=s.getStorefrontPopups()||[],[4,(v=n,t(a,void 0,void 0,(function(){var t,n,i,s,a;return e(this,(function(e){switch(e.label){case 0:if(!(t=v.map((function(t){return t.id})).filter(Boolean)).length)return[2,v];e.label=1;case 1:return e.trys.push([1,3,,4]),[4,o({idList:t})];case 2:return(null==(n=e.sent())?void 0:n.isSuccess)&&(null===(a=n.data)||void 0===a?void 0:a.length)?(i=n.data,[2,v.map((function(t){var e=i.find((function(e){return e.id===t.id}));return e?r(r({},e),{isFilteredOnServerSide:t.isFilteredOnServerSide}):t}))]):[3,4];case 3:return s=e.sent(),console.error("[@ikas/storefront] Failed to fetch popup details",s),[3,4];case 4:return[2,v]}}))})))];case 1:return u=f.sent(),i?[2]:[4,p(u)];case 2:return l=f.sent(),window.ikasPopupConfig=l,c(l),d(),[2]}var v}))})),function(){i=!0,null==n||n(),"function"==typeof window.destroyIkasPopupWidget&&window.destroyIkasPopupWidget()}}}),[u,c])}export{v as usePopupWidget};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ikas/storefront",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.63",
|
|
4
4
|
"description": "Storefront functionality for ikas storefront themes.",
|
|
5
5
|
"author": "ikas",
|
|
6
6
|
"license": "ISC",
|
|
@@ -23,11 +23,11 @@
|
|
|
23
23
|
"swiper": "11.0.6"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@ikas/storefront-api": "^5.0.
|
|
27
|
-
"@ikas/storefront-config": "^5.0.
|
|
28
|
-
"@ikas/storefront-model-functions": "^5.0.
|
|
29
|
-
"@ikas/storefront-models": "^5.0.
|
|
30
|
-
"@ikas/storefront-providers": "^5.0.
|
|
26
|
+
"@ikas/storefront-api": "^5.0.63",
|
|
27
|
+
"@ikas/storefront-config": "^5.0.63",
|
|
28
|
+
"@ikas/storefront-model-functions": "^5.0.63",
|
|
29
|
+
"@ikas/storefront-models": "^5.0.63",
|
|
30
|
+
"@ikas/storefront-providers": "^5.0.63",
|
|
31
31
|
"@ikas/localized-address": "1.0.0-beta.6",
|
|
32
32
|
"@adyen/adyen-web": "^5.57.0",
|
|
33
33
|
"@rollup/plugin-commonjs": "^22.0.0",
|
|
@@ -62,11 +62,11 @@
|
|
|
62
62
|
},
|
|
63
63
|
"peerDependencies": {
|
|
64
64
|
"@ikas/localized-address": "1.0.0-beta.6",
|
|
65
|
-
"@ikas/storefront-api": "^5.0.
|
|
66
|
-
"@ikas/storefront-config": "^5.0.
|
|
67
|
-
"@ikas/storefront-model-functions": "^5.0.
|
|
68
|
-
"@ikas/storefront-models": "^5.0.
|
|
69
|
-
"@ikas/storefront-providers": "^5.0.
|
|
65
|
+
"@ikas/storefront-api": "^5.0.63",
|
|
66
|
+
"@ikas/storefront-config": "^5.0.63",
|
|
67
|
+
"@ikas/storefront-model-functions": "^5.0.63",
|
|
68
|
+
"@ikas/storefront-models": "^5.0.63",
|
|
69
|
+
"@ikas/storefront-providers": "^5.0.63",
|
|
70
70
|
"mobx": "^6.1.3",
|
|
71
71
|
"mobx-react-lite": "^3.1.5",
|
|
72
72
|
"next": "12.2.0",
|