@ikas/storefront 5.0.0-beta.18 → 5.0.0-beta.19

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{__assign as e,__awaiter as t,__generator as o}from'./../../ext/tslib/tslib.es6.js';import*as i from"react";import{observer as r}from"mobx-react-lite";import{useRouter as n}from"next/router.js";import{IkasThemeJsonPageType as a}from"@ikas/storefront-models";import"@ikas/localized-address";import{IkasStorefrontConfig as s}from"@ikas/storefront-config";import{viewCart as c,productView as m,viewCategory as u,pageView as p}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import{IkasPageHead as d}from"./head.js";import{IkasBaseStore as f}from"../../store/base/index.js";import{checkLocalization as l}from"../../store/base/functions.js";import"../../store/customer/index.js";import{routeChangeInit as g}from"../../store/customer/functions.js";import"../../store/customer/consent/data.js";import"../../store/customer/captcha/data.js";import{handleProductViewEvent as j}from"../../store/customer/product/functions.js";import"../../store/customer/account-auth/data.js";import{setAPIClientConfig as v}from"@ikas/storefront-api";import'./../../ext/@ikas/fe-api-client/build/utils/api.js';import'./../../ext/axios/index.js';import'./../../ext/@ikas/fe-api-client/build/ext/lodash/_defineProperty.js';import'./../../ext/@ikas/fe-api-client/build/ext/lodash/_baseGetTag.js';import'./../../ext/@ikas/fe-api-client/build/ext/lodash/_stringToPath.js';import'./../../ext/@ikas/fe-api-client/build/ext/lodash/_baseToString.js';import{getCart as h,waitForCartStoreInit as b}from"../../store/cart/functions.js";import{IkasProductFunctions as x}from"@ikas/storefront-model-functions";import"../../store/customer/marketing/data.js";import"../../store/customer/order/data.js";import"@ikas/storefront-providers";import{IkasCartStore as y}from"../../store/cart/index.js";import{initIkasEvents as S}from"../../analytics/events.js";import{IkasPageDataInit as k}from"../../page-data-init/index.js";import{IkasThemeJsonCustomData as D}from"../../models/data/theme-json/custom-data/index.js";import{renderComponent as P}from"./functions.js";var T=r((function(r){var T=r.propValues,_=r.themeJsonComponents,w=r.customDataList,C=r.pageType,E=r.pageTitle,O=r.pageDescription,R=r.pageSpecificData,I=r.canonicals,M=r.disableIndex,B=r.settings,F=r.configJson,H=r.reInitOnBrowser,V=r.addOgpMetas,A=r.components,G=r.productReviewSummary,J=n(),U=i.useState(),q=U[0],z=U[1];s.init(e(e({},F),{currentPageComponents:A,loginRequiredCallback:function(){J.push("/account/login")}})),f.router=J,v();var L=f;L.router=J,L.currentPageType=C;var Y=i.useState(!1),K=Y[0],N=Y[1],Q=i.useMemo((function(){return(null==q?void 0:q.id)===(null==R?void 0:R.id)&&k.pageSpecificData&&k.isBrowser?C===a.PRODUCT&&k._initProductOnBrowser(k.pageSpecificData):k.setPageSpecificData(R,C,K),k.initPagePropValues(T,_,w.map((function(e){return new D(e)})),B,K)}),[K,T,C,B,R,_]);i.useEffect((function(){H&&N("undefined"!=typeof window),h(),l(),S()}),[]),i.useEffect((function(){R?(null==q?void 0:q.id)!==R.id&&z(R):z(null)}),[R]),i.useEffect((function(){var e=function(){g()};return J.events.on("routeChangeStart",e),function(){J.events.off("routeChangeStart",e)}}),[]),i.useEffect((function(){!function(e,i){var r,n;t(this,void 0,void 0,(function(){var t,s,d,f,l;return o(this,(function(o){switch(o.label){case 0:p(e),o.label=1;case 1:return o.trys.push([1,4,,5]),e===a.PRODUCT&&(m(t=i),s=x.getSelectedVariant,j(t.id,s(t).id)),e===a.CATEGORY&&(f=null===(r=(d=i).categoryPathItems)||void 0===r?void 0:r.map((function(e){return e.name})).join(" > "),f=d.categoryPathItems&&(null===(n=d.categoryPathItems)||void 0===n?void 0:n.length)>0?f+" > "+d.name:d.name,u(f,d)),e!==a.CART?[3,3]:[4,b()];case 2:o.sent(),c(y.cart),o.label=3;case 3:return[3,5];case 4:return l=o.sent(),console.error(l),[3,5];case 5:return[2]}}))}))}(C,k.pageSpecificData)}),[C,R]);var W=i.useMemo((function(){var e=Q.find((function(e){return e.component.isHeader})),t=Q.find((function(e){return e.component.isFooter})),o=Q.filter((function(e){return!e.component.isHeader&&!e.component.isFooter}))||[];return i.createElement("div",{style:{position:"relative",minHeight:"100vh",display:"flex",flexDirection:"column",justifyContent:"space-between"}},i.createElement("div",null,e&&P(e,B,-1),o.map((function(e,t){return P(e,B,t)}))),t&&P(t,B,-1))}),[Q,B]),X=s.getMerchantSettings();return i.createElement(i.Fragment,null,i.createElement(d,{pageType:C,pageTitle:E,pageDescription:O,pageSpecificData:k.pageSpecificData,canonicals:I,disableIndex:M,merchantSettings:X,addOgpMetas:V,productReviewSummary:G}),W)}));export{T as IkasPage};
1
+ import{__assign as e,__awaiter as t,__generator as o}from'./../../ext/tslib/tslib.es6.js';import*as i from"react";import{observer as r}from"mobx-react-lite";import{useRouter as n}from"next/router.js";import{IkasThemeJsonPageType as a}from"@ikas/storefront-models";import"@ikas/localized-address";import{IkasStorefrontConfig as s}from"@ikas/storefront-config";import{viewCart as c,productView as m,viewCategory as u,pageView as p}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import{IkasPageHead as d}from"./head.js";import{IkasBaseStore as f}from"../../store/base/index.js";import{checkLocalization as l,initBaseStore as g}from"../../store/base/functions.js";import"../../store/customer/index.js";import{routeChangeInit as j}from"../../store/customer/functions.js";import"../../store/customer/consent/data.js";import"../../store/customer/captcha/data.js";import{handleProductViewEvent as v}from"../../store/customer/product/functions.js";import"../../store/customer/account-auth/data.js";import{setAPIClientConfig as h}from"@ikas/storefront-api";import'./../../ext/@ikas/fe-api-client/build/utils/api.js';import'./../../ext/axios/index.js';import'./../../ext/@ikas/fe-api-client/build/ext/lodash/_defineProperty.js';import'./../../ext/@ikas/fe-api-client/build/ext/lodash/_baseGetTag.js';import'./../../ext/@ikas/fe-api-client/build/ext/lodash/_stringToPath.js';import'./../../ext/@ikas/fe-api-client/build/ext/lodash/_baseToString.js';import{getCart as b,waitForCartStoreInit as x}from"../../store/cart/functions.js";import{IkasProductFunctions as y}from"@ikas/storefront-model-functions";import"../../store/customer/marketing/data.js";import"../../store/customer/order/data.js";import"@ikas/storefront-providers";import{IkasCartStore as S}from"../../store/cart/index.js";import{initIkasEvents as k}from"../../analytics/events.js";import{IkasPageDataInit as D}from"../../page-data-init/index.js";import{IkasThemeJsonCustomData as P}from"../../models/data/theme-json/custom-data/index.js";import{renderComponent as T}from"./functions.js";var _=r((function(r){var _=r.propValues,w=r.themeJsonComponents,C=r.customDataList,E=r.pageType,O=r.pageTitle,R=r.pageDescription,I=r.pageSpecificData,M=r.canonicals,B=r.disableIndex,F=r.settings,H=r.configJson,V=r.reInitOnBrowser,A=r.addOgpMetas,G=r.components,J=r.productReviewSummary,U=n(),q=i.useState(),z=q[0],L=q[1];s.init(e(e({},H),{currentPageComponents:G,loginRequiredCallback:function(){U.push("/account/login")}})),f.router=U,h();var Y=f;Y.router=U,Y.currentPageType=E;var K=i.useState(!1),N=K[0],Q=K[1],W=i.useMemo((function(){return(null==z?void 0:z.id)===(null==I?void 0:I.id)&&D.pageSpecificData&&D.isBrowser?E===a.PRODUCT&&D._initProductOnBrowser(D.pageSpecificData):D.setPageSpecificData(I,E,N),D.initPagePropValues(_,w,C.map((function(e){return new P(e)})),F,N)}),[N,_,E,F,I,w]);i.useEffect((function(){V&&Q("undefined"!=typeof window),b(),l(),k(),g()}),[]),i.useEffect((function(){I?(null==z?void 0:z.id)!==I.id&&L(I):L(null)}),[I]),i.useEffect((function(){var e=function(){j()};return U.events.on("routeChangeStart",e),function(){U.events.off("routeChangeStart",e)}}),[]),i.useEffect((function(){!function(e,i){var r,n;t(this,void 0,void 0,(function(){var t,s,d,f,l;return o(this,(function(o){switch(o.label){case 0:p(e),o.label=1;case 1:return o.trys.push([1,4,,5]),e===a.PRODUCT&&(m(t=i),s=y.getSelectedVariant,v(t.id,s(t).id)),e===a.CATEGORY&&(f=null===(r=(d=i).categoryPathItems)||void 0===r?void 0:r.map((function(e){return e.name})).join(" > "),f=d.categoryPathItems&&(null===(n=d.categoryPathItems)||void 0===n?void 0:n.length)>0?f+" > "+d.name:d.name,u(f,d)),e!==a.CART?[3,3]:[4,x()];case 2:o.sent(),c(S.cart),o.label=3;case 3:return[3,5];case 4:return l=o.sent(),console.error(l),[3,5];case 5:return[2]}}))}))}(E,D.pageSpecificData)}),[E,I]);var X=i.useMemo((function(){var e=W.find((function(e){return e.component.isHeader})),t=W.find((function(e){return e.component.isFooter})),o=W.filter((function(e){return!e.component.isHeader&&!e.component.isFooter}))||[];return i.createElement("div",{style:{position:"relative",minHeight:"100vh",display:"flex",flexDirection:"column",justifyContent:"space-between"}},i.createElement("div",null,e&&T(e,F,-1),o.map((function(e,t){return T(e,F,t)}))),t&&T(t,F,-1))}),[W,F]),Z=s.getMerchantSettings();return i.createElement(i.Fragment,null,i.createElement(d,{pageType:E,pageTitle:O,pageDescription:R,pageSpecificData:D.pageSpecificData,canonicals:M,disableIndex:B,merchantSettings:Z,addOgpMetas:A,productReviewSummary:J}),X)}));export{_ as IkasPage};
@@ -3,5 +3,5 @@ import { IkasProduct, IkasVariantValue } from "@ikas/storefront-models";
3
3
  export declare function setLocalization(localeOption: IkasLocaleOption): void;
4
4
  export declare function setLanguage(language: IkasLanguageOption): void;
5
5
  export declare function checkLocalization(): Promise<void>;
6
- export declare function init(): void;
6
+ export declare function initBaseStore(): void;
7
7
  export declare function selectVariantValueCallback(product: IkasProduct, variantValue: IkasVariantValue, disableRoute?: boolean): void;
@@ -1 +1 @@
1
- import{__awaiter as o,__generator as i}from'./../../ext/tslib/tslib.es6.js';import{listCountry as t,getMyCountry as n}from"@ikas/storefront-api";import{IkasStorefrontConfig as e}from"@ikas/storefront-config";import{IkasBaseStore as r}from"./index.js";import s from"lodash/flatten";import a from"lodash/sortBy";import"@ikas/storefront-model-functions";import"../cart/index.js";import"../../components/checkout/types.js";import"../customer/index.js";import"../../analytics/events.js";import"lodash/cloneDeep";import"../analytics/index.js";import"../../analytics/ikas.js";import"../customer/consent/data.js";import"../../analytics/head/index.js";import"../customer/account-auth/data.js";import"../customer/captcha/data.js";import"../customer/product/data.js";import"lodash/xorBy";import'./../../ext/@ikas/fe-api-client/build/utils/api.js';import'./../../ext/axios/index.js';import'./../../ext/@ikas/fe-api-client/build/ext/lodash/_defineProperty.js';import'./../../ext/@ikas/fe-api-client/build/ext/lodash/_baseGetTag.js';import'./../../ext/@ikas/fe-api-client/build/ext/lodash/_stringToPath.js';import'./../../ext/@ikas/fe-api-client/build/ext/lodash/_baseToString.js';function u(o){o.routing.domain?window.location.replace("https://"+o.routing.domain):window.location.replace(window.location.origin+(o.routing.path?"/"+o.routing.path:"")+(r.router?r.router.asPath:""))}function d(o){var i=e.getRoutings().find((function(i){return i.id===o.id}));i&&window.location.replace(window.location.origin+(i.path?"/"+i.path:"")+(r.router?r.router.asPath:""))}function l(){return o(this,void 0,void 0,(function(){var o,u,d,l,c,m,p,f,g,h,v;return i(this,(function(i){switch(i.label){case 0:return r.localeChecked?[2]:"undefined"==typeof window?(console.warn("checkLocalization should be called on the client side!"),[2]):[4,n()];case 1:return(o=i.sent()).isSuccess?(u=o.data,d=e.getCurrentRouting(),r.currentCountryCode=u,d&&u?(l=!0,c=e.getRoutings().filter((function(o){var i;return null===(i=o.countryCodes)||void 0===i?void 0:i.includes(u)})),m=e.getRoutings().find((function(o){var i;return!(null===(i=o.countryCodes)||void 0===i?void 0:i.length)})),c.length?c.some((function(o){return o.id===d.id}))||(l=!1):m&&d.id!==m.id&&(l=!1),p=[],f=[],g=s(e.getRoutings().map((function(o){return o.countryCodes||[]}))),[4,t({iso2:{in:g}})]):[3,3]):[2];case 2:if(!(h=i.sent()).isSuccess)return[2];v=h.data||[],e.getRoutings().forEach((function(o){var i;(null===(i=o.countryCodes)||void 0===i?void 0:i.length)?o.countryCodes.forEach((function(i){var t=v.find((function(o){return o.iso2===i}));p.some((function(o){return o.iso2===(null==t?void 0:t.iso2)}))||p.push({id:(null==t?void 0:t.iso2)||(null==t?void 0:t.iso3)||Date.now()+"",countryName:(null==t?void 0:t.native)||(null==t?void 0:t.name)||"",iso2:(null==t?void 0:t.iso2)||void 0,iso3:(null==t?void 0:t.iso3)||void 0,routing:o,isRecommended:i===u})})):p.push({id:o.id,routing:o,isRecommended:!e.getRoutings().some((function(o){var i;return null===(i=o.countryCodes)||void 0===i?void 0:i.includes(u)}))})})),c.length&&(e.getRoutings().forEach((function(o){var i;c.some((function(i){return i.id===o.id}))&&f.push({id:o.id,currencyCode:o.currencyCode,currencySymbol:o.currencySymbol,language:new Intl.DisplayNames([],{type:"language"}).of(o.locale)||"",locale:o.locale,isSelected:o.id===(null===(i=e.getCurrentRouting())||void 0===i?void 0:i.id)||!1})})),r.languageOptions=a(f,"language")),r.localeOptions=a(p,"countryName"),l||(r.showLocaleOptions=!0),r.localeChecked=!0,i.label=3;case 3:return[2]}}))}))}export{l as checkLocalization,d as setLanguage,u as setLocalization};
1
+ import{__awaiter as n,__generator as o}from'./../../ext/tslib/tslib.es6.js';import{listCountry as i,getMyCountry as t}from"@ikas/storefront-api";import{IkasStorefrontConfig as e}from"@ikas/storefront-config";import{IkasBaseStore as r}from"./index.js";import a from"lodash/flatten";import u from"lodash/sortBy";import{IkasProductFunctions as c,IkasVariantTypeFunctions as l,IkasVariantValueFunctions as s}from"@ikas/storefront-model-functions";import{initCustomerStore as d}from"../customer/functions.js";import{productView as f}from"../../analytics/analytics.js";import"../../analytics/head/index.js";function g(n){n.routing.domain?window.location.replace("https://"+n.routing.domain):window.location.replace(window.location.origin+(n.routing.path?"/"+n.routing.path:"")+(r.router?r.router.asPath:""))}function m(n){var o=e.getRoutings().find((function(o){return o.id===n.id}));o&&window.location.replace(window.location.origin+(o.path?"/"+o.path:"")+(r.router?r.router.asPath:""))}function v(){return n(this,void 0,void 0,(function(){var n,c,l,s,d,f,g,m,v,p,h;return o(this,(function(o){switch(o.label){case 0:return r.localeChecked?[2]:"undefined"==typeof window?(console.warn("checkLocalization should be called on the client side!"),[2]):[4,t()];case 1:return(n=o.sent()).isSuccess?(c=n.data,l=e.getCurrentRouting(),r.currentCountryCode=c,l&&c?(s=!0,d=e.getRoutings().filter((function(n){var o;return null===(o=n.countryCodes)||void 0===o?void 0:o.includes(c)})),f=e.getRoutings().find((function(n){var o;return!(null===(o=n.countryCodes)||void 0===o?void 0:o.length)})),d.length?d.some((function(n){return n.id===l.id}))||(s=!1):f&&l.id!==f.id&&(s=!1),g=[],m=[],v=a(e.getRoutings().map((function(n){return n.countryCodes||[]}))),[4,i({iso2:{in:v}})]):[3,3]):[2];case 2:if(!(p=o.sent()).isSuccess)return[2];h=p.data||[],e.getRoutings().forEach((function(n){var o;(null===(o=n.countryCodes)||void 0===o?void 0:o.length)?n.countryCodes.forEach((function(o){var i=h.find((function(n){return n.iso2===o}));g.some((function(n){return n.iso2===(null==i?void 0:i.iso2)}))||g.push({id:(null==i?void 0:i.iso2)||(null==i?void 0:i.iso3)||Date.now()+"",countryName:(null==i?void 0:i.native)||(null==i?void 0:i.name)||"",iso2:(null==i?void 0:i.iso2)||void 0,iso3:(null==i?void 0:i.iso3)||void 0,routing:n,isRecommended:o===c})})):g.push({id:n.id,routing:n,isRecommended:!e.getRoutings().some((function(n){var o;return null===(o=n.countryCodes)||void 0===o?void 0:o.includes(c)}))})})),d.length&&(e.getRoutings().forEach((function(n){var o;d.some((function(o){return o.id===n.id}))&&m.push({id:n.id,currencyCode:n.currencyCode,currencySymbol:n.currencySymbol,language:new Intl.DisplayNames([],{type:"language"}).of(n.locale)||"",locale:n.locale,isSelected:n.id===(null===(o=e.getCurrentRouting())||void 0===o?void 0:o.id)||!1})})),r.languageOptions=u(m,"language")),r.localeOptions=u(g,"countryName"),s||(r.showLocaleOptions=!0),r.localeChecked=!0,o.label=3;case 3:return[2]}}))}))}function p(){"undefined"!=typeof window&&(r.spaLinksDisabled=navigator.userAgent.includes("Instagram")),c._setSelectVariantValueCallback(h),d()}function h(n,o,i){var t,e=n.metaData,a=n.variantTypes.map((function(o){var i=o.variantType,t=i.values.find((function(o){return n.selectedVariantValues.some((function(n){return n.id===o.id}))}));if(t)return"".concat(l.getVariantTypeSlug(i),"=").concat(s.getVariantValueSlug(t))})).filter((function(n){return!!n})).join("&");if(!i){var u="/".concat(e.slug);if(a&&(u="/".concat(e.slug,"?").concat(a)),u===window.location.pathname)return;null===(t=r.router)||void 0===t||t.replace(u,void 0,{shallow:!1,scroll:!1})}f(n)}export{v as checkLocalization,p as initBaseStore,h as selectVariantValueCallback,m as setLanguage,g as setLocalization};
@@ -1,4 +1,4 @@
1
- import { IkasCart, IkasOrderLineItem, IkasProduct, IkasProductVariant } from "@ikas/storefront-models";
1
+ import { IkasCart, IkasOrderLineItem, IkasProduct, IkasProductOption, IkasProductVariant } from "@ikas/storefront-models";
2
2
  import { IkasCartOperationResult } from ".";
3
3
  import { CartLineOptionInput } from "@ikas/storefront-api";
4
4
  export declare const CART_LS_KEY = "cartId";
@@ -19,3 +19,6 @@ export declare function setCart(cart: IkasCart): Promise<void>;
19
19
  export declare function beforeCartOperationCheck(): Promise<void>;
20
20
  export declare function createCartLineOptions(item: IkasOrderLineItem): CartLineOptionInput[] | null;
21
21
  export declare function getOptionValues(product: IkasProduct): CartLineOptionInput[];
22
+ export declare function checkOptionValues(productOptions: IkasProductOption[]): IkasProductOption[];
23
+ export declare function mergedProductOptions(productOptions: IkasProductOption[]): {};
24
+ export declare function setNewProductOptionValues(product: IkasProduct): IkasProductOption[];
@@ -1 +1 @@
1
- import{__awaiter as t,__generator as n}from'./../../ext/tslib/tslib.es6.js';import{useCartStore as e,IkasCartStore as r,IkasCartOperationValidationError as i}from"./index.js";import{IkasProductFunctions as o,IkasProductVariantFunctions as s,IkasProductOptionSetFunctions as a,IkasOrderFunctions as u}from"@ikas/storefront-model-functions";import{addItemToCart as c,saveCartCouponCode as d,SaveCartInput as l,saveCart as f,getCartById as v}from"@ikas/storefront-api";import{IkasStorefrontConfig as p}from"@ikas/storefront-config";import{addToCart as h,removeFromCart as I}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import{IkasCustomerStore as m}from"../customer/index.js";var S="cartId";function g(){var t=e().cart;return null==t?void 0:t.id}function O(){var t=g();if(t)return"/checkout?id=".concat(t,"&step=info")}function b(e,u,d){return void 0===d&&(d=1),t(this,void 0,void 0,(function(){var t,l,f,v,I,m,S,g,O,b,L;return n(this,(function(n){switch(n.label){case 0:t=o.hasValidProductOptionValues,l=s.hasVariantStock,f=a.initOptionValues,n.label=1;case 1:return n.trys.push([1,6,,7]),t(u)?l(e)||e.sellIfOutOfStock?[4,A()]:[2,{success:!1,validationError:i.INSUFFICIENT_STOCK}]:[2,{success:!1,validationError:i.INVALID_PRODUCT_OPTION_VALUES}];case 2:return n.sent(),(v=r.cart)&&(I=k(e,u))?(u.productOptionSet&&f(u.productOptionSet),[2,C(I,I.quantity+1)]):(m=x(u),S=(null==v?void 0:v.id)||localStorage.getItem("cartId"),[4,c({input:{cartId:S,item:{id:null,quantity:d,variant:{id:e.id,name:u.name}},options:m.length?m:null,priceListId:p.getPriceListId()||null,salesChannelId:p.getSalesChannelId(),storefrontThemeId:p.getStorefrontThemeId()}})]);case 3:return(g=n.sent()).isSuccess&&g.data?[4,j(g.data)]:[3,5];case 4:n.sent(),n.label=5;case 5:return(v=r.cart)&&(O="".concat(v.id,"-").concat(v.updatedAt),(b=v.orderLineItems.find((function(t){return t.variant.id===e.id})))&&h(b,d,O,v)),u.productOptionSet&&f(u.productOptionSet),[2,{success:g.isSuccess,response:g}];case 6:return L=n.sent(),console.log(L),[2,{success:!1}];case 7:return[2]}}))}))}function C(e,i){return t(this,void 0,void 0,(function(){var t,o,s,a,u;return n(this,(function(n){switch(n.label){case 0:return n.trys.push([0,5,,6]),[4,A()];case 1:return n.sent(),t=r.cart,[4,c({input:{cartId:(null==t?void 0:t.id)||null,item:{id:e.id,quantity:i,variant:{id:e.variant.id,name:e.variant.name}},options:q(e),priceListId:p.getPriceListId()||null,salesChannelId:p.getSalesChannelId(),storefrontThemeId:p.getStorefrontThemeId()}})];case 2:return(o=n.sent()).isSuccess&&o.data?[4,j(o.data)]:[3,4];case 3:n.sent(),n.label=4;case 4:return V(),(t=r.cart)&&(s="".concat(t.id,"-").concat(t.updatedAt),(a=e.quantity)>i?I(e,a-i,t):h(e,i-a,s,t)),[2,{success:o.isSuccess,response:o}];case 5:return u=n.sent(),console.log(u),[2,{success:!1}];case 6:return[2]}}))}))}function L(e){return t(this,void 0,void 0,(function(){return n(this,(function(t){switch(t.label){case 0:return[4,C(e,0)];case 1:return[2,t.sent()]}}))}))}function y(){localStorage.removeItem("cartId"),r.cart=null}function T(){return new Promise((function(t){var n=setInterval((function(){r.isCartLoadFinished&&(clearInterval(n),t(null))}),100)}))}function k(t,n){var e,i,o,s=r.cart;if(!n.productOptionSetId)return null==s?void 0:s.orderLineItems.find((function(n){return n.variant.id===t.id}));for(var a=x(n),u=(null==s?void 0:s.orderLineItems.filter((function(n){var e;return n.variant.id===t.id&&(null===(e=n.options)||void 0===e?void 0:e.length)===a.length})))||[],c=0,d=u;c<d.length;c++){var l=d[c];if(l.options){for(var f=!0,v=function(t){var r=t.values.map((function(t){return t.value})),s=null===(o=null===(i=null===(e=n.productOptionSet)||void 0===e?void 0:e.options)||void 0===i?void 0:i.find((function(n){return n.id===t.productOptionId})))||void 0===o?void 0:o.values;if(!(f=f&&r.length===(null==s?void 0:s.length)&&r.every((function(t){return null==s?void 0:s.includes(t)}))))return"break"},p=0,h=l.options;p<h.length;p++){if("break"===v(h[p]))break}if(f)return l}}}function w(e){return t(this,void 0,void 0,(function(){var t,o;return n(this,(function(n){switch(n.label){case 0:return(t=r.cart)?[4,d({cartId:t.id,couponCode:e})]:[2,{success:!1,validationError:i.EMPTY_CART}];case 1:return(o=n.sent()).isSuccess&&o.data&&(r.cart=o.data),[2,{success:o.isSuccess,response:o}]}}))}))}function E(){return t(this,void 0,void 0,(function(){return n(this,(function(t){return[2,w(null)]}))}))}function P(e){return t(this,void 0,void 0,(function(){var t,r;return n(this,(function(n){switch(n.label){case 0:return t=new l(e),[4,f({input:t})];case 1:return[2,{success:(r=n.sent()).isSuccess,response:r}]}}))}))}function V(){r.cart&&0===u.getItemCount(r.cart)&&y()}function _(){var e,i;return t(this,void 0,void 0,(function(){var t,o,s,a;return n(this,(function(n){switch(n.label){case 0:if(!("undefined"!=typeof localStorage))return[2];n.label=1;case 1:return n.trys.push([1,6,7,8]),r.isLoadingCart=!0,t=null===(e=m.customer)||void 0===e?void 0:e.id,(o=(null===(i=r.cart)||void 0===i?void 0:i.id)||localStorage.getItem("cartId"))||t?[4,v({id:o})]:[2];case 2:return(s=n.sent()).isSuccess&&s.data?[4,j(s.data)]:[3,4];case 3:return n.sent(),[3,5];case 4:y(),n.label=5;case 5:return[3,8];case 6:return a=n.sent(),console.log(a),[3,8];case 7:return r.isLoadingCart=!1,r.isCartLoadFinished=!0,[7];case 8:return[2]}}))}))}function j(e){return t(this,void 0,void 0,(function(){return n(this,(function(t){return localStorage.setItem("cartId",e.id),r.cart=e,[2]}))}))}function A(){return t(this,void 0,void 0,(function(){var t;return n(this,(function(n){switch(n.label){case 0:return t=localStorage.getItem("cartId"),!r.cart||t?[3,1]:(y(),[3,3]);case 1:return r.cart||!t?[3,3]:[4,_()];case 2:n.sent(),n.label=3;case 3:return[2]}}))}))}function q(t){if(t&&t.options){for(var n=[],e=0,r=t.options;e<r.length;e++){var i=r[e],o={productOptionId:i.productOptionId,productOptionsSetId:i.productOptionsSetId,values:i.values.map((function(t){return t.value}))};n.push(o)}return n}return null}function x(t){var n,e=[];return null===(n=t.productOptionSet)||void 0===n||n.options.forEach((function(t){t.values.length&&e.push({productOptionId:t.id,productOptionsSetId:t.productOptionSetId,values:t.values})})),e}export{S as CART_LS_KEY,b as addItem,A as beforeCartOperationCheck,C as changeItemQuantity,q as createCartLineOptions,k as findExistingItem,_ as getCart,g as getCheckoutId,O as getCheckoutUrl,x as getOptionValues,V as removeCardIfEmpty,y as removeCart,E as removeCouponCode,L as removeItem,P as saveCart,w as saveCouponCode,j as setCart,T as waitForCartStoreInit};
1
+ import{__awaiter as t,__generator as n,__spreadArray as e,__assign as r}from'./../../ext/tslib/tslib.es6.js';import{useCartStore as i,IkasCartStore as o,IkasCartOperationValidationError as s}from"./index.js";import{IkasProductFunctions as u,IkasProductVariantFunctions as a,IkasProductOptionSetFunctions as c,IkasOrderFunctions as d}from"@ikas/storefront-model-functions";import{addItemToCart as l,saveCartCouponCode as v,SaveCartInput as p,saveCart as f,getCartById as h}from"@ikas/storefront-api";import{IkasStorefrontConfig as I}from"@ikas/storefront-config";import{addToCart as m,removeFromCart as S}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import{IkasCustomerStore as g}from"../customer/index.js";var O="cartId";function b(){var t=i().cart;return null==t?void 0:t.id}function C(){var t=b();if(t)return"/checkout?id=".concat(t,"&step=info")}function L(e,r,i){var d;return void 0===i&&(i=1),t(this,void 0,void 0,(function(){var t,v,p,f,h,S,g,O,b,C,L;return n(this,(function(n){switch(n.label){case 0:t=u.hasValidProductOptionValues,v=a.hasVariantStock,p=c.initOptionValues,n.label=1;case 1:return n.trys.push([1,6,,7]),t(r)?v(e)||e.sellIfOutOfStock?[4,x()]:[2,{success:!1,validationError:s.INSUFFICIENT_STOCK}]:[2,{success:!1,validationError:s.INVALID_PRODUCT_OPTION_VALUES}];case 2:return n.sent(),(f=o.cart)&&(h=E(e,r))?(r.productOptionSet&&p(r.productOptionSet),[2,y(h,h.quantity+1)]):((null===(d=r.productOptionSet)||void 0===d?void 0:d.options.length)&&(r.productOptionSet.options=R(r)),S=N(r),g=(null==f?void 0:f.id)||localStorage.getItem("cartId"),[4,l({input:{cartId:g,item:{id:null,quantity:i,variant:{id:e.id,name:r.name}},options:S.length?S:null,priceListId:I.getPriceListId()||null,salesChannelId:I.getSalesChannelId(),storefrontThemeId:I.getStorefrontThemeId()}})]);case 3:return(O=n.sent()).isSuccess&&O.data?[4,q(O.data)]:[3,5];case 4:n.sent(),n.label=5;case 5:return(f=o.cart)&&(b="".concat(f.id,"-").concat(f.updatedAt),(C=f.orderLineItems.find((function(t){return t.variant.id===e.id})))&&m(C,i,b,f)),r.productOptionSet&&p(r.productOptionSet),[2,{success:O.isSuccess,response:O}];case 6:return L=n.sent(),console.log(L),[2,{success:!1}];case 7:return[2]}}))}))}function y(e,r){return t(this,void 0,void 0,(function(){var t,i,s,u,a;return n(this,(function(n){switch(n.label){case 0:return n.trys.push([0,5,,6]),[4,x()];case 1:return n.sent(),t=o.cart,[4,l({input:{cartId:(null==t?void 0:t.id)||null,item:{id:e.id,quantity:r,variant:{id:e.variant.id,name:e.variant.name}},options:F(e),priceListId:I.getPriceListId()||null,salesChannelId:I.getSalesChannelId(),storefrontThemeId:I.getStorefrontThemeId()}})];case 2:return(i=n.sent()).isSuccess&&i.data?[4,q(i.data)]:[3,4];case 3:n.sent(),n.label=4;case 4:return _(),(t=o.cart)&&(s="".concat(t.id,"-").concat(t.updatedAt),(u=e.quantity)>r?S(e,u-r,t):m(e,r-u,s,t)),[2,{success:i.isSuccess,response:i}];case 5:return a=n.sent(),console.log(a),[2,{success:!1}];case 6:return[2]}}))}))}function T(e){return t(this,void 0,void 0,(function(){return n(this,(function(t){switch(t.label){case 0:return[4,y(e,0)];case 1:return[2,t.sent()]}}))}))}function k(){localStorage.removeItem("cartId"),o.cart=null}function w(){return new Promise((function(t){var n=setInterval((function(){o.isCartLoadFinished&&(clearInterval(n),t(null))}),100)}))}function E(t,n){var e,r,i,s,u=o.cart;if(!n.productOptionSetId)return null==u?void 0:u.orderLineItems.find((function(n){return n.variant.id===t.id}));(null===(e=n.productOptionSet)||void 0===e?void 0:e.options.length)&&(n.productOptionSet.options=R(n));for(var a=N(n),c=(null==u?void 0:u.orderLineItems.filter((function(n){var e;return n.variant.id===t.id&&(null===(e=n.options)||void 0===e?void 0:e.length)===a.length})))||[],d=0,l=c;d<l.length;d++){var v=l[d];if(v.options){for(var p=!0,f=function(t){var e=t.values.map((function(t){return t.value})),o=null===(s=null===(i=null===(r=n.productOptionSet)||void 0===r?void 0:r.options)||void 0===i?void 0:i.find((function(n){return n.id===t.productOptionId})))||void 0===s?void 0:s.values;if(!(p=p&&e.length===(null==o?void 0:o.length)&&e.every((function(t){return null==o?void 0:o.includes(t)}))))return"break"},h=0,I=v.options;h<I.length;h++){if("break"===f(I[h]))break}if(p)return v}}}function P(e){return t(this,void 0,void 0,(function(){var t,r;return n(this,(function(n){switch(n.label){case 0:return(t=o.cart)?[4,v({cartId:t.id,couponCode:e})]:[2,{success:!1,validationError:s.EMPTY_CART}];case 1:return(r=n.sent()).isSuccess&&r.data&&(o.cart=r.data),[2,{success:r.isSuccess,response:r}]}}))}))}function j(){return t(this,void 0,void 0,(function(){return n(this,(function(t){return[2,P(null)]}))}))}function V(e){return t(this,void 0,void 0,(function(){var t,r;return n(this,(function(n){switch(n.label){case 0:return t=new p(e),[4,f({input:t})];case 1:return[2,{success:(r=n.sent()).isSuccess,response:r}]}}))}))}function _(){o.cart&&0===d.getItemCount(o.cart)&&k()}function A(){var e,r;return t(this,void 0,void 0,(function(){var t,i,s,u;return n(this,(function(n){switch(n.label){case 0:if(!("undefined"!=typeof localStorage))return[2];n.label=1;case 1:return n.trys.push([1,6,7,8]),o.isLoadingCart=!0,t=null===(e=g.customer)||void 0===e?void 0:e.id,(i=(null===(r=o.cart)||void 0===r?void 0:r.id)||localStorage.getItem("cartId"))||t?[4,h({id:i})]:[2];case 2:return(s=n.sent()).isSuccess&&s.data?[4,q(s.data)]:[3,4];case 3:return n.sent(),[3,5];case 4:k(),n.label=5;case 5:return[3,8];case 6:return u=n.sent(),console.log(u),[3,8];case 7:return o.isLoadingCart=!1,o.isCartLoadFinished=!0,[7];case 8:return[2]}}))}))}function q(e){return t(this,void 0,void 0,(function(){return n(this,(function(t){return localStorage.setItem("cartId",e.id),o.cart=e,[2]}))}))}function x(){return t(this,void 0,void 0,(function(){var t;return n(this,(function(n){switch(n.label){case 0:return t=localStorage.getItem("cartId"),!o.cart||t?[3,1]:(k(),[3,3]);case 1:return o.cart||!t?[3,3]:[4,A()];case 2:n.sent(),n.label=3;case 3:return[2]}}))}))}function F(t){if(t&&t.options){for(var n=[],e=0,r=t.options;e<r.length;e++){var i=r[e],o={productOptionId:i.productOptionId,productOptionsSetId:i.productOptionsSetId,values:i.values.map((function(t){return t.value}))};n.push(o)}return n}return null}function N(t){var n,e=[];return null===(n=t.productOptionSet)||void 0===n||n.options.forEach((function(t){t.values.length&&e.push({productOptionId:t.id,productOptionsSetId:t.productOptionSetId,values:t.values})})),e}function U(t){for(var n=[],e=0,r=t;e<r.length;e++){var i=r[e];n.push(i),n=n.concat(U(i.childOptions))}return n}function D(t){return t.reduce((function(t,n){return t[n.id]?t[n.id].values=e([],t[n.id].values,!0):t[n.id]=r({},n),t}),{})}function R(t){var n,e,r=[],i=(null===(n=t.productOptionSet)||void 0===n?void 0:n.options.length)?U(t.productOptionSet.options):[];return(null===(e=t.productOptionSet)||void 0===e?void 0:e.options.length)&&i.length&&(r=Object.values(D(i))),r}export{O as CART_LS_KEY,L as addItem,x as beforeCartOperationCheck,y as changeItemQuantity,U as checkOptionValues,F as createCartLineOptions,E as findExistingItem,A as getCart,b as getCheckoutId,C as getCheckoutUrl,N as getOptionValues,D as mergedProductOptions,_ as removeCardIfEmpty,k as removeCart,j as removeCouponCode,T as removeItem,V as saveCart,P as saveCouponCode,q as setCart,R as setNewProductOptionValues,w as waitForCartStoreInit};
@@ -1 +1 @@
1
- import{isServer as t}from"../../../utils/helper.js";import{IkasCustomerConsentData as o}from"./data.js";var e="customerConsent";function n(){return o.customerConsentGranted}function r(){s()}function s(){t()||(o.customerConsentGranted=!0,window.localStorage.setItem("customerConsent","true"))}export{e as LS_CUSTOMER_CONSENT,n as isCustomerConsentGranted,r as onCustomerConsentGrant,s as saveCustomerConsent};
1
+ import{isServer as t}from"../../../utils/helper.js";import{IkasCustomerConsentData as o}from"./data.js";var e="customerConsent";function n(){return o.customerConsentGranted}function r(){s()}function s(){t()||(o.customerConsentGranted=!0,window.localStorage.setItem("customerConsent","true"))}function u(){t()||(o.customerConsentGranted=!!window.localStorage.getItem("customerConsent"))}export{e as LS_CUSTOMER_CONSENT,n as isCustomerConsentGranted,u as loadCustomerConsent,r as onCustomerConsentGrant,s as saveCustomerConsent};
@@ -1 +1 @@
1
- import{__awaiter as t,__generator as o}from'./../../ext/tslib/tslib.es6.js';import"@ikas/storefront-model-functions";import"../cart/index.js";import"../../components/checkout/types.js";import{IkasCustomerStore as i,setCustomer as r}from"./index.js";import"../../analytics/events.js";import"lodash/cloneDeep";import{isServer as n}from"../../utils/helper.js";import"../analytics/index.js";import"../../analytics/ikas.js";import"./consent/data.js";import"../../analytics/head/index.js";import{IkasCustomerAuthData as s}from"./account-auth/data.js";import{loadToken as e,clearLocalData as a}from"./account-auth/functions.js";import"@ikas/storefront-config";import"./product/data.js";import"lodash/xorBy";import{getCustomer as c}from"@ikas/storefront-api";function m(){return new Promise((function(t){var o=setInterval((function(){i.initialized&&(clearInterval(o),t(null))}),100)}))}function u(){e(),!s.token&&i.customer&&a(),s.token&&!i.customer&&p()}function p(){return t(this,void 0,void 0,(function(){var t;return o(this,(function(o){switch(o.label){case 0:return n()||!s.token?[2]:[4,c()];case 1:return(t=o.sent()).data&&r(t.data),[2]}}))}))}export{p as getCustomer,u as routeChangeInit,m as waitForCustomerStoreInit};
1
+ import{__awaiter as t,__generator as n}from'./../../ext/tslib/tslib.es6.js';import{customerVisit as r}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import{isServer as o}from"../../utils/helper.js";import{IkasCustomerAuthData as i}from"./account-auth/data.js";import{loadToken as e,refreshToken as s,clearLocalData as u}from"./account-auth/functions.js";import{loadLastViewedProducts as a}from"./product/functions.js";import{loadCustomerConsent as c}from"./consent/functions.js";import{getCustomer as m}from"@ikas/storefront-api";import{IkasCustomerStore as f,setCustomer as l}from"./index.js";function d(){return new Promise((function(t){var n=setInterval((function(){f.initialized&&(clearInterval(n),t(null))}),100)}))}function p(){return t(this,void 0,void 0,(function(){return n(this,(function(t){switch(t.label){case 0:return e(),a(),c(),[4,s()];case 1:return t.sent(),[4,j()];case 2:return t.sent(),f.initialized=!0,f.customer&&r(),[2]}}))}))}function h(){e(),!i.token&&f.customer&&u(),i.token&&!f.customer&&j()}function j(){return t(this,void 0,void 0,(function(){var t;return n(this,(function(n){switch(n.label){case 0:return o()||!i.token?[2]:[4,m()];case 1:return(t=n.sent()).data&&l(t.data),[2]}}))}))}export{j as getCustomer,p as initCustomerStore,h as routeChangeInit,d as waitForCustomerStoreInit};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ikas/storefront",
3
- "version": "5.0.0-beta.18",
3
+ "version": "5.0.0-beta.19",
4
4
  "description": "Storefront functionality for ikas storefront themes.",
5
5
  "author": "ikas",
6
6
  "license": "ISC",
@@ -17,11 +17,11 @@
17
17
  "build": "rm -rf build && rollup -c"
18
18
  },
19
19
  "devDependencies": {
20
- "@ikas/storefront-api": "^5.0.0-beta.18",
21
- "@ikas/storefront-config": "^5.0.0-beta.18",
22
- "@ikas/storefront-model-functions": "^5.0.0-beta.18",
23
- "@ikas/storefront-models": "^5.0.0-beta.18",
24
- "@ikas/storefront-providers": "^5.0.0-beta.18",
20
+ "@ikas/storefront-api": "^5.0.0-beta.19",
21
+ "@ikas/storefront-config": "^5.0.0-beta.19",
22
+ "@ikas/storefront-model-functions": "^5.0.0-beta.19",
23
+ "@ikas/storefront-models": "^5.0.0-beta.19",
24
+ "@ikas/storefront-providers": "^5.0.0-beta.19",
25
25
  "@ikas/localized-address": "^1.0.0-beta.2",
26
26
  "@adyen/adyen-web": "^5.28.2",
27
27
  "@rollup/plugin-commonjs": "^22.0.0",
@@ -55,11 +55,11 @@
55
55
  },
56
56
  "peerDependencies": {
57
57
  "@ikas/localized-address": "^1.0.0-beta.2",
58
- "@ikas/storefront-api": "^5.0.0-beta.18",
59
- "@ikas/storefront-config": "^5.0.0-beta.18",
60
- "@ikas/storefront-model-functions": "^5.0.0-beta.18",
61
- "@ikas/storefront-models": "^5.0.0-beta.18",
62
- "@ikas/storefront-providers": "^5.0.0-beta.18",
58
+ "@ikas/storefront-api": "^5.0.0-beta.19",
59
+ "@ikas/storefront-config": "^5.0.0-beta.19",
60
+ "@ikas/storefront-model-functions": "^5.0.0-beta.19",
61
+ "@ikas/storefront-models": "^5.0.0-beta.19",
62
+ "@ikas/storefront-providers": "^5.0.0-beta.19",
63
63
  "mobx": "^6.1.3",
64
64
  "mobx-react-lite": "^3.1.5",
65
65
  "next": "12.2.0",