@ikas/storefront 4.2.0-beta.1 → 4.2.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- import*as e from"react";import{observer as t}from"mobx-react-lite";import"../../../../../models/data/blog/category/index.js";import"../../../../../models/data/blog/content/index.js";import"../../../../../models/data/blog/meta-data/index.js";import"../../../../../models/data/blog/tag/index.js";import"../../../../../models/data/blog/index.js";import"../../../../../models/data/brand/index.js";import{IkasProductOptionType as a}from"@ikas/storefront-models";import"mobx";import"../../../../../models/data/campaign-offer/index.js";import"../../../../../models/data/cart/campaign-offer/index.js";import"../../../../../models/data/cart/index.js";import"../../../../../models/data/category/path-item/index.js";import"../../../../../models/data/category/index.js";import"../../../../../models/data/checkout/index.js";import"../../../../../models/data/checkout-settings/index.js";import"../../../../../models/data/city/index.js";import"../../../../../models/data/country/index.js";import"../../../../../models/data/customer/address/index.js";import"../../../../../models/data/customer/attribute/index.js";import"../../../../../models/data/customer/review/summary/index.js";import"../../../../../models/data/customer/review/index.js";import"../../../../../models/data/customer/index.js";import"../../../../../models/data/district/index.js";import"../../../../../models/data/favorite-product/index.js";import"../../../../../models/data/filter-category/index.js";import"../../../../../models/data/html-meta-data/index.js";import"../../../../../models/data/image/index.js";import"../../../../../models/data/order/address/index.js";import"../../../../../models/data/order/line-item/option/value/index.js";import"../../../../../models/data/order/line-item/variant/value/index.js";import"../../../../../models/data/order/line-item/variant/index.js";import"../../../../../models/data/order/line-item/index.js";import"../../../../../models/data/order/package/index.js";import"../../../../../models/data/order/transaction/index.js";import"../../../../../models/data/order/index.js";import"../../../../../models/data/payment-gateway/index.js";import"../../../../../models/data/product/attribute-value/index.js";import"../../../../../models/data/product/filter/index.js";import"../../../../../models/data/product/option-set/option/index.js";import"../../../../../models/data/product/option-set/index.js";import"../../../../../models/data/product/variant/price/index.js";import"../../../../../models/data/product/variant/index.js";import"../../../../../models/data/variant-type/index.js";import"../../../../../models/data/product/index.js";import"../../../../../models/data/raffle/index.js";import"../../../../../models/data/state/index.js";import"../../../../../models/data/theme-json/index.js";import"../../../../../models/data/theme-json/custom-data/index.js";import"../../../../../models/data/variant-type/variant-value/index.js";import"../../../../../models/ui/blog-list/index.js";import"../../../../../models/ui/blog-category-list/index.js";import"../../../../../models/ui/brand-list/index.js";import"../../../../../models/ui/category-list/index.js";import"../../../../../models/ui/product-list/index.js";import"../../../../../models/ui/product-attribute-detail/index.js";import"../../../../../models/ui/product-attribute-list/index.js";import"../../../../../models/ui/customer-review-list/index.js";import"../../../../../models/ui/customer-review-summary-list/index.js";import"../../../../../models/ui/validator/index.js";import"../../../../../models/ui/validator/rules/index.js";import"../../../../../models/ui/validator/form/login.js";import"../../../../../models/ui/validator/form/address.js";import"../../../../../models/ui/validator/form/register.js";import"../../../../../models/ui/validator/form/contact-form.js";import"../../../../../models/ui/validator/form/forgot-password.js";import"../../../../../models/ui/validator/form/recover-password.js";import"../../../../../models/ui/validator/form/account-info.js";import"../../../../../models/ui/validator/form/raffle-form.js";import"../../../../../models/ui/validator/form/customer-review.js";import"../../../../../models/ui/raffle-list/index.js";import{formatDate as i}from"../../../../../utils/helper.js";import"@ikas/storefront-config";import{useTranslation as o}from"../../../../../utils/i18n.js";import{Modal as r}from"../../modal/index.js";import m from"./svg/arrow-right.js";import s from"./style.module.scss.js";var d=t((function(t){var d,n,l;t.vm,t.currencyCode;var c=t.cartItem,p=t.stockErrorItem,u=o().t,v=!p,j=e.useState(!1),x=j[0],f=j[1],E=e.useMemo((function(){var t;return e.createElement("div",null,null===(t=c.options)||void 0===t?void 0:t.map((function(t){switch(t.type){case a.TEXT:case a.TEXT_AREA:case a.CHOICE:return e.createElement("div",{className:s.OptionRow},e.createElement("div",{className:s.OptionName},t.name),e.createElement("div",{className:s.OptionValue},t.values.map((function(e){return e.name||e.value})).join(", ")));case a.DATE_PICKER:return e.createElement("div",{className:s.OptionRow},e.createElement("div",{className:s.OptionName},t.name),e.createElement("div",{className:s.OptionValue},t.values.map((function(e){return t=e.value,(a=i(new Date(t)).split(" ")).splice(-1),a.join(" ");var t,a})).join(", ")));case a.FILE:return e.createElement("div",{className:s.OptionRow},e.createElement("div",{className:s.OptionName},t.name),e.createElement("div",{className:s.OptionValue},t.values.map((function(e){return t=e.value,decodeURIComponent(t.split("/")[t.split("/").length-1]);var t})).join(", ")));case a.CHECKBOX:return e.createElement("div",{className:s.OptionRow},e.createElement("div",{className:s.OptionName},t.name),e.createElement("div",{className:s.OptionValue},t.values.length&&"true"===t.values[0].value?u("checkout-page:yes"):u("checkout-page:no")));case a.COLOR_PICKER:return e.createElement("div",{className:s.OptionRow},e.createElement("div",{className:s.OptionName},t.name),e.createElement("div",{className:s.OptionsHorContainer},t.values.map((function(t,a){return e.createElement("div",{key:a,className:s.OptionColorValue,style:{backgroundColor:t.value}})}))))}})))}),[]);return e.createElement("div",{className:s.CheckoutItem},e.createElement("div",{className:s.ImageContainer},e.createElement("img",{className:s.Image,src:null===(d=c.variant.mainImage)||void 0===d?void 0:d.thumbnailSrc}),e.createElement("div",{className:s.QuantityCircle},c.quantity)),e.createElement("div",{className:s.Center},!!p&&e.createElement("div",{className:s.StockErrorItemMain},e.createElement("span",null,c.quantity," ",u("common:quantity")),e.createElement("span",null,e.createElement(m,null)),e.createElement("span",null,p.stockCount," ",u("common:quantity"))),e.createElement("div",{className:s.Name},c.variant.name),e.createElement("div",{className:[s.LightText,s.Small].join(" ")},null===(n=c.variant.variantValues)||void 0===n?void 0:n.map((function(e){return e.variantValueName})).join(" / ")),!!(null===(l=c.options)||void 0===l?void 0:l.length)&&e.createElement("div",{className:s.OptionsText,onClick:function(){return f(!0)}},u("checkout-page:customizedProduct")),!!x&&e.createElement(r,{title:c.variant.name,modalContent:E,onClose:function(){return f(!1)}})),v&&e.createElement("div",{className:s.Right},e.createElement("div",{className:s.Price},!!c.overridenPriceWithQuantity&&e.createElement("span",{className:s.GrayPrice},c.formattedOverridenPriceWithQuantity),c.formattedFinalPriceWithQuantity),c.unitPriceText&&e.createElement("div",{className:[s.LightText,s.Small].join(" ")},c.unitPriceText)))}));export{d as CartItem};
1
+ import*as e from"react";import{observer as t}from"mobx-react-lite";import"../../../../../models/data/blog/category/index.js";import"../../../../../models/data/blog/content/index.js";import"../../../../../models/data/blog/meta-data/index.js";import"../../../../../models/data/blog/tag/index.js";import"../../../../../models/data/blog/index.js";import"../../../../../models/data/brand/index.js";import{IkasProductOptionType as a}from"@ikas/storefront-models";import"mobx";import"../../../../../models/data/campaign-offer/index.js";import"../../../../../models/data/cart/campaign-offer/index.js";import"../../../../../models/data/cart/index.js";import"../../../../../models/data/category/path-item/index.js";import"../../../../../models/data/category/index.js";import"../../../../../models/data/checkout/index.js";import"../../../../../models/data/checkout-settings/index.js";import"../../../../../models/data/city/index.js";import"../../../../../models/data/country/index.js";import"../../../../../models/data/customer/address/index.js";import"../../../../../models/data/customer/attribute/index.js";import"../../../../../models/data/customer/review/summary/index.js";import"../../../../../models/data/customer/review/index.js";import"../../../../../models/data/customer/index.js";import"../../../../../models/data/district/index.js";import"../../../../../models/data/favorite-product/index.js";import"../../../../../models/data/filter-category/index.js";import"../../../../../models/data/html-meta-data/index.js";import"../../../../../models/data/image/index.js";import"../../../../../models/data/order/address/index.js";import"../../../../../models/data/order/line-item/option/value/index.js";import"../../../../../models/data/order/line-item/variant/value/index.js";import"../../../../../models/data/order/line-item/variant/index.js";import"../../../../../models/data/order/line-item/index.js";import"../../../../../models/data/order/package/index.js";import"../../../../../models/data/order/transaction/index.js";import"../../../../../models/data/order/index.js";import"../../../../../models/data/payment-gateway/index.js";import"../../../../../models/data/product/attribute-value/index.js";import"../../../../../models/data/product/filter/index.js";import"../../../../../models/data/product/option-set/option/index.js";import"../../../../../models/data/product/option-set/index.js";import"../../../../../models/data/product/variant/price/index.js";import"../../../../../models/data/product/variant/index.js";import"../../../../../models/data/variant-type/index.js";import"../../../../../models/data/product/index.js";import"../../../../../models/data/raffle/index.js";import"../../../../../models/data/state/index.js";import"../../../../../models/data/theme-json/index.js";import"../../../../../models/data/theme-json/custom-data/index.js";import"../../../../../models/data/variant-type/variant-value/index.js";import"../../../../../models/ui/blog-list/index.js";import"../../../../../models/ui/blog-category-list/index.js";import"../../../../../models/ui/brand-list/index.js";import"../../../../../models/ui/category-list/index.js";import"../../../../../models/ui/product-list/index.js";import"../../../../../models/ui/product-attribute-detail/index.js";import"../../../../../models/ui/product-attribute-list/index.js";import"../../../../../models/ui/customer-review-list/index.js";import"../../../../../models/ui/customer-review-summary-list/index.js";import"../../../../../models/ui/validator/index.js";import"../../../../../models/ui/validator/rules/index.js";import"../../../../../models/ui/validator/form/login.js";import"../../../../../models/ui/validator/form/address.js";import"../../../../../models/ui/validator/form/register.js";import"../../../../../models/ui/validator/form/contact-form.js";import"../../../../../models/ui/validator/form/forgot-password.js";import"../../../../../models/ui/validator/form/recover-password.js";import"../../../../../models/ui/validator/form/account-info.js";import"../../../../../models/ui/validator/form/raffle-form.js";import"../../../../../models/ui/validator/form/customer-review.js";import"../../../../../models/ui/raffle-list/index.js";import{formatDate as i}from"../../../../../utils/helper.js";import"@ikas/storefront-config";import{useTranslation as o}from"../../../../../utils/i18n.js";import{Modal as r}from"../../modal/index.js";import m from"./svg/arrow-right.js";import s from"./style.module.scss.js";var d=t((function(t){var d,n,l;t.vm,t.currencyCode;var c=t.cartItem,p=t.stockErrorItem,u=o().t,v=!p,j=e.useState(!1),x=j[0],f=j[1],E=e.useMemo((function(){var t;return e.createElement("div",null,null===(t=c.options)||void 0===t?void 0:t.map((function(t){switch(t.type){case a.TEXT:case a.TEXT_AREA:case a.CHOICE:return e.createElement("div",{className:s.OptionRow},e.createElement("div",{className:s.OptionName},t.name),e.createElement("div",{className:s.OptionValue},t.values.map((function(e){return e.name||e.value})).join(", ")));case a.DATE_PICKER:return e.createElement("div",{className:s.OptionRow},e.createElement("div",{className:s.OptionName},t.name),e.createElement("div",{className:s.OptionValue},t.values.map((function(e){return t=e.value,(a=i(new Date(t)).split(" ")).splice(-1),a.join(" ");var t,a})).join(", ")));case a.FILE:return e.createElement("div",{className:s.OptionRow},e.createElement("div",{className:s.OptionName},t.name),e.createElement("div",{className:s.OptionValue},t.values.map((function(e){return t=e.value,decodeURIComponent(t.split("/")[t.split("/").length-1]);var t})).join(", ")));case a.CHECKBOX:return e.createElement("div",{className:s.OptionRow},e.createElement("div",{className:s.OptionName},t.name),e.createElement("div",{className:s.OptionValue},t.values.length&&"true"===t.values[0].value?u("checkout-page:yes"):u("checkout-page:no")));case a.COLOR_PICKER:return e.createElement("div",{className:s.OptionRow},e.createElement("div",{className:s.OptionName},t.name),e.createElement("div",{className:s.OptionsHorContainer},t.values.map((function(t,a){return e.createElement("div",{key:a,className:s.OptionColorValue,style:{backgroundColor:t.value}})}))))}})))}),[]);return e.createElement("div",{className:s.CheckoutItem},e.createElement("div",{className:s.ImageContainer},e.createElement("img",{className:s.Image,src:null===(d=c.variant.mainImage)||void 0===d?void 0:d.thumbnailSrc}),e.createElement("div",{className:s.QuantityCircle},c.quantity)),e.createElement("div",{className:s.Center},!!p&&e.createElement("div",{className:s.StockErrorItemMain},e.createElement("span",null,c.quantity," ",u("checkout-page:quantity")),e.createElement("span",null,e.createElement(m,null)),e.createElement("span",null,p.stockCount," ",u("checkout-page:quantity"))),e.createElement("div",{className:s.Name},c.variant.name),e.createElement("div",{className:[s.LightText,s.Small].join(" ")},null===(n=c.variant.variantValues)||void 0===n?void 0:n.map((function(e){return e.variantValueName})).join(" / ")),!!(null===(l=c.options)||void 0===l?void 0:l.length)&&e.createElement("div",{className:s.OptionsText,onClick:function(){return f(!0)}},u("checkout-page:customizedProduct")),!!x&&e.createElement(r,{title:c.variant.name,modalContent:E,onClose:function(){return f(!1)}})),v&&e.createElement("div",{className:s.Right},e.createElement("div",{className:s.Price},!!c.overridenPriceWithQuantity&&e.createElement("span",{className:s.GrayPrice},c.formattedOverridenPriceWithQuantity),c.formattedFinalPriceWithQuantity),c.unitPriceText&&e.createElement("div",{className:[s.LightText,s.Small].join(" ")},c.unitPriceText)))}));export{d as CartItem};
@@ -53,6 +53,8 @@ export default class CountrySettingsModel {
53
53
  isFreeTextDistrict(country: string): boolean | undefined;
54
54
  getAddressFormCountrySettings: () => Promise<void>;
55
55
  getAddressFormCountryLabels: () => Promise<void>;
56
+ validatePhoneNumber: (str: string) => boolean;
57
+ validateByRegexString: (str: string, regexStr: string) => boolean;
56
58
  }
57
59
  export declare const countryFormsLocales: string[];
58
60
  export declare type IkasAddressFormCountrySettings = {
@@ -1 +1 @@
1
- import{__awaiter as t,__generator as e}from'./../../ext/tslib/tslib.es6.js';import{makeAutoObservable as i}from"mobx";import{IkasStorefrontConfig as n}from"@ikas/storefront-config";import{IkasCheckoutRequirement as r}from"@ikas/storefront-models";import s from"lodash/difference";import o from"lodash/mapValues";import{validatePhoneNumber as u,validateByRegexString as d}from"@ikas/storefront-model-functions/src/utils/helper";var a,l=function(){function l(a){var l=this;this._initialized=!1,this.init=function(){return t(l,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,this.getAddressFormCountrySettings()];case 1:return t.sent(),[4,this.getAddressFormCountryLabels()];case 2:return t.sent(),this._initialized=!0,[2]}}))}))},this.waitUntilInitialized=function(){return new Promise((function(t){var e=setInterval((function(){l.initialized&&(clearInterval(e),t(null))}),100)}))},this.getCountrySettings=function(t){return l._addressFormCountrySettings.countrySettings[t]},this.getCountryLabels=function(t){return l._addressFormCountryLabels.countryLabels[t]},this.getFieldSettings=function(t){return l.getCountrySettings(t).fields},this.getFieldLabels=function(t){var e=l.getCountryLabels(t);if(e)return o(e.fields,(function(t,e){return null==t?void 0:t.label}))},this.getAddressFormatView=function(t){return l._addressFormCountrySettings.addressFormats[t]},this.getBillingFormatView=function(t){return l._addressFormCountrySettings.billingFormats[t]},this.getAddressFormat=function(t){var e=l.getCountrySettings(t),i=l.getAddressFormatView(e.addressFormat);if(l.checkoutSettings&&i){var n=[];return l.checkoutSettings.identityNumberRequirement===r.INVISIBLE&&n.push("identityNumber"),l.checkoutSettings.postalCodeRequirement===r.INVISIBLE&&n.push("postalCode"),l.checkoutSettings.phoneRequirement===r.INVISIBLE&&n.push("phone"),i.map((function(t){return s(t,n)}))||[]}return i},this.getBillingFormat=function(t){var e=l.getCountrySettings(t);return l.getBillingFormatView(e.billingFormat)},this.getAddressFormatIgnoreCountry=function(t){return l.getAddressFormat(t).map((function(t){return s(t,["country"])}))},this.getValidationResult=function(t){var e,i,n,s,o,d,a=l.getFieldSettings((null===(e=t.country)||void 0===e?void 0:e.iso2)||"TR");if(l.checkoutSettings&&a){var c=!!t.phone&&t.phone.length>=10&&u(t.phone);return{firstName:l.isValidField(t.firstName,a.firstName),lastName:l.isValidField(t.lastName,a.lastName),addressLine1:l.isValidField(t.addressLine1,a.addressLine1),country:l.isValidField((null===(i=t.country)||void 0===i?void 0:i.name)||"",a.country),state:l.isValidField((null===(n=t.state)||void 0===n?void 0:n.name)||"",a.state),city:l.isValidField((null===(s=t.city)||void 0===s?void 0:s.name)||"",a.city),district:l.isValidField((null===(o=t.district)||void 0===o?void 0:o.name)||"",a.district),phone:(null===(d=a.phone)||void 0===d?void 0:d.regex)?l.isValidField(t.phone||"",a.phone,l.checkoutSettings.phoneRequirement):!(l.checkoutSettings.phoneRequirement===r.MANDATORY||l.checkoutSettings.phoneRequirement===r.OPTIONAL&&t.phone)||c,postalCode:l.isValidField(t.postalCode||"",a.postalCode,l.checkoutSettings.postalCodeRequirement),identityNumber:l.isValidField(t.identityNumber||"",a.identityNumber,l.checkoutSettings.identityNumberRequirement)}}},this.isValidField=function(t,e,i){var n=!0,s=i?i===r.MANDATORY:(null==e?void 0:e.required)||!1,o=!!(null==e?void 0:e.regex)||!1;return s&&!o&&(n=!!t),s&&o&&(n=!!t||d(t,e.regex)),!s&&o&&t&&(n=d(t,e.regex)),n},this.getAddressFormCountrySettings=function(){return t(l,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return"https://cdn.myikas.com/sf/static/location/settings.json",[4,fetch("https://cdn.myikas.com/sf/static/location/settings.json")];case 1:return[4,e.sent().json()];case 2:return t=e.sent(),this._addressFormCountrySettings=t,[2]}}))}))},this.getAddressFormCountryLabels=function(){return t(l,void 0,void 0,(function(){var t,i,r;return e(this,(function(e){switch(e.label){case 0:return t=n.getCurrentLocale(),c.find((function(e){return e===t}))||(t="en"),i="https://cdn.myikas.com/sf/static/location/".concat(t,".json"),[4,fetch(i)];case 1:return[4,e.sent().json()];case 2:return r=e.sent(),this._addressFormCountryLabels=r,[2]}}))}))},this.checkoutSettings=a.checkoutSettings,this.init(),i(this)}return Object.defineProperty(l.prototype,"initialized",{get:function(){return this._initialized},enumerable:!1,configurable:!0}),l.prototype.isValidAddress=function(t){var e=this.getValidationResult(t);return!!e&&Object.values(e).every((function(t){return t}))},l.prototype.isFreeTextCity=function(t){var e=this.getFieldSettings(t);return e&&e.city&&e.city.type===a.TEXT},l.prototype.isFreeTextDistrict=function(t){var e=this.getFieldSettings(t);return e&&e.district&&e.district.type===a.TEXT},l}(),c=["tr","de","en","it","es","fr","ru"];!function(t){t.TEXT="text",t.DROPDOWN="dropdown"}(a||(a={}));export{c as countryFormsLocales,l as default};
1
+ import{__awaiter as t,__generator as e}from'./../../ext/tslib/tslib.es6.js';import{makeAutoObservable as i}from"mobx";import{IkasStorefrontConfig as n}from"@ikas/storefront-config";import{IkasCheckoutRequirement as r}from"@ikas/storefront-models";import s from"lodash/difference";import o from"lodash/mapValues";var u,a=function(){function a(u){var a=this;this._initialized=!1,this.init=function(){return t(a,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,this.getAddressFormCountrySettings()];case 1:return t.sent(),[4,this.getAddressFormCountryLabels()];case 2:return t.sent(),this._initialized=!0,[2]}}))}))},this.waitUntilInitialized=function(){return new Promise((function(t){var e=setInterval((function(){a.initialized&&(clearInterval(e),t(null))}),100)}))},this.getCountrySettings=function(t){return a._addressFormCountrySettings.countrySettings[t]},this.getCountryLabels=function(t){return a._addressFormCountryLabels.countryLabels[t]},this.getFieldSettings=function(t){return a.getCountrySettings(t).fields},this.getFieldLabels=function(t){var e=a.getCountryLabels(t);if(e)return o(e.fields,(function(t,e){return null==t?void 0:t.label}))},this.getAddressFormatView=function(t){return a._addressFormCountrySettings.addressFormats[t]},this.getBillingFormatView=function(t){return a._addressFormCountrySettings.billingFormats[t]},this.getAddressFormat=function(t){var e=a.getCountrySettings(t),i=a.getAddressFormatView(e.addressFormat);if(a.checkoutSettings&&i){var n=[];return a.checkoutSettings.identityNumberRequirement===r.INVISIBLE&&n.push("identityNumber"),a.checkoutSettings.postalCodeRequirement===r.INVISIBLE&&n.push("postalCode"),a.checkoutSettings.phoneRequirement===r.INVISIBLE&&n.push("phone"),i.map((function(t){return s(t,n)}))||[]}return i},this.getBillingFormat=function(t){var e=a.getCountrySettings(t);return a.getBillingFormatView(e.billingFormat)},this.getAddressFormatIgnoreCountry=function(t){return a.getAddressFormat(t).map((function(t){return s(t,["country"])}))},this.getValidationResult=function(t){var e,i,n,s,o,u,d=a.getFieldSettings((null===(e=t.country)||void 0===e?void 0:e.iso2)||"TR");if(a.checkoutSettings&&d){var l=!!t.phone&&t.phone.length>=10&&a.validatePhoneNumber(t.phone);return{firstName:a.isValidField(t.firstName,d.firstName),lastName:a.isValidField(t.lastName,d.lastName),addressLine1:a.isValidField(t.addressLine1,d.addressLine1),country:a.isValidField((null===(i=t.country)||void 0===i?void 0:i.name)||"",d.country),state:a.isValidField((null===(n=t.state)||void 0===n?void 0:n.name)||"",d.state),city:a.isValidField((null===(s=t.city)||void 0===s?void 0:s.name)||"",d.city),district:a.isValidField((null===(o=t.district)||void 0===o?void 0:o.name)||"",d.district),phone:(null===(u=d.phone)||void 0===u?void 0:u.regex)?a.isValidField(t.phone||"",d.phone,a.checkoutSettings.phoneRequirement):!(a.checkoutSettings.phoneRequirement===r.MANDATORY||a.checkoutSettings.phoneRequirement===r.OPTIONAL&&t.phone)||l,postalCode:a.isValidField(t.postalCode||"",d.postalCode,a.checkoutSettings.postalCodeRequirement),identityNumber:a.isValidField(t.identityNumber||"",d.identityNumber,a.checkoutSettings.identityNumberRequirement)}}},this.isValidField=function(t,e,i){var n=!0,s=i?i===r.MANDATORY:(null==e?void 0:e.required)||!1,o=!!(null==e?void 0:e.regex)||!1;return s&&!o&&(n=!!t),s&&o&&(n=!!t||a.validateByRegexString(t,e.regex)),!s&&o&&t&&(n=a.validateByRegexString(t,e.regex)),n},this.getAddressFormCountrySettings=function(){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return"https://cdn.myikas.com/sf/static/location/settings.json",[4,fetch("https://cdn.myikas.com/sf/static/location/settings.json")];case 1:return[4,e.sent().json()];case 2:return t=e.sent(),this._addressFormCountrySettings=t,[2]}}))}))},this.getAddressFormCountryLabels=function(){return t(a,void 0,void 0,(function(){var t,i,r;return e(this,(function(e){switch(e.label){case 0:return t=n.getCurrentLocale(),d.find((function(e){return e===t}))||(t="en"),i="https://cdn.myikas.com/sf/static/location/".concat(t,".json"),[4,fetch(i)];case 1:return[4,e.sent().json()];case 2:return r=e.sent(),this._addressFormCountryLabels=r,[2]}}))}))},this.validatePhoneNumber=function(t){return/^\+?\d+$/.test(t)},this.validateByRegexString=function(t,e){return new RegExp(e).test(t)},this.checkoutSettings=u.checkoutSettings,this.init(),i(this)}return Object.defineProperty(a.prototype,"initialized",{get:function(){return this._initialized},enumerable:!1,configurable:!0}),a.prototype.isValidAddress=function(t){var e=this.getValidationResult(t);return!!e&&Object.values(e).every((function(t){return t}))},a.prototype.isFreeTextCity=function(t){var e=this.getFieldSettings(t);return e&&e.city&&e.city.type===u.TEXT},a.prototype.isFreeTextDistrict=function(t){var e=this.getFieldSettings(t);return e&&e.district&&e.district.type===u.TEXT},a}(),d=["tr","de","en","it","es","fr","ru"];!function(t){t.TEXT="text",t.DROPDOWN="dropdown"}(u||(u={}));export{d as countryFormsLocales,a as default};
@@ -30,9 +30,11 @@ export declare class IkasProduct implements IProduct {
30
30
  baseUnit: IkasProductBaseUnit | null;
31
31
  averageRating: number | null;
32
32
  reviewCount: number | null;
33
+ groupVariantsByVariantTypeId: string | null;
33
34
  productOptionSet?: IkasProductOptionSet | null;
34
35
  campaigns?: IkasProductCampaign[] | null;
35
36
  selectedVariantValues: IkasVariantValue[];
37
+ isFiltered: boolean;
36
38
  constructor(data?: Partial<IkasProduct>);
37
39
  get hasVariant(): boolean;
38
40
  get hasStock(): boolean;
@@ -1 +1 @@
1
- import{__spreadArray as t,__awaiter as e,__generator as i}from'./../../../ext/tslib/tslib.es6.js';import n from"lodash/sortBy";import{IkasCategory as r}from"../category/index.js";import{IkasProductVariant as a}from"./variant/index.js";import{IkasProductAttributeValue as o}from"./attribute-value/index.js";import{IkasProductVariantType as s}from"./variant-type/index.js";import{IkasBrand as u}from"../brand/index.js";import{IkasHTMLMetaData as c}from"../html-meta-data/index.js";import{IkasProductTag as l}from"./tag/index.js";import{IkasProductType as d}from"@ikas/storefront-models";export{IkasProductType}from"@ikas/storefront-models";import{IkasProductOptionSet as p}from"./option-set/index.js";import{makeObservable as f,observable as m,computed as v}from"mobx";import{IkasProductFunctions as h}from"@ikas/storefront-model-functions";import{IkasProductCampaign as g}from"./campaign/index.js";import{IkasStorefrontConfig as b}from"@ikas/storefront-config";import{Analytics as y}from"../../../analytics/analytics.js";import"../../../analytics/head/index.js";import{IkasBaseStore as V}from"../../../store/base.js";import O from"lodash/groupBy";import{IkasProductBaseUnit as P}from"./base-unit/index.js";import{formatCurrency as j}from"../../../utils/currency.js";import"lodash/get";import w from"../../../store/product/index.js";import{IkasCustomerReviewList as S}from"../../ui/customer-review-list/index.js";var T=function(){function T(h){void 0===h&&(h={});var O,T,I,x=this;this.metaData=null,this.brand=null,this.tags=null,this.productOptionSetId=null,this.productOptionSet=null,this.campaigns=null,this.selectedVariantValues=[],this.selectVariantValue=function(e,i){var n,r=x.metaData,a=x.selectedVariantValues.map((function(t){return t.variantTypeId===e.variantTypeId?e:t})),o=x.variants.find((function(t){return t.isActive&&a.every((function(e){return t.variantValues.some((function(t){return t.id===e.id}))}))}));if(o)x.selectedVariantValues=a;else{var s=x.variantTypes.findIndex((function(t){return t.variantType.id===e.variantTypeId}));if(s>0){var u=x.variantTypes.slice(0,s),c=x.selectedVariantValues.filter((function(t){return u.some((function(e){return e.variantType.id===t.variantTypeId}))})),l=t(t([],c,!0),[e],!1);o=x.variants.find((function(t){return t.isActive&&l.every((function(e){return t.variantValues.some((function(t){return t.id===e.id}))}))}))}else{var d=a.slice(0,a.length-1);(o=x.variants.find((function(t){return t.isActive&&d.every((function(e){return t.variantValues.some((function(t){return t.id===e.id}))}))})))||(o=x.variants.find((function(t){return t.isActive&&t.variantValues.some((function(t){return t.id===e.id}))})))}if(!o)return;x.selectedVariantValues=o.variantValues}var p=x.variantTypes.map((function(t){var e=t.variantType,i=e.values.find((function(t){return x.selectedVariantValues.some((function(e){return e.id===t.id}))}));if(i)return"".concat(e.slug,"=").concat(i.slug)})).filter((function(t){return!!t})).join("&");if(!i){var f="/".concat(r.slug);if(p&&(f="/".concat(r.slug,"?").concat(p)),f===window.location.pathname)return;var m="production"!==process.env.NODE_ENV;null===(n=V.getInstance().router)||void 0===n||n.replace(f,void 0,{shallow:m,scroll:!1})}y.productView(x)},this.getVariantUnitPriceText=function(t){var e,i,n=t.price;if(n.unitPrice&&x.baseUnit){var r=x.baseUnit.baseAmount,a=(null===(i=null===(e=x.baseUnit)||void 0===e?void 0:e.unit)||void 0===i?void 0:i.name)||"";return"".concat(j(n.unitPrice,n.currency||"",n.currencySymbol||"")," / ").concat(r&&1!==r?r:"").concat(a)}},this.getCampaigns=function(){return e(x,void 0,void 0,(function(){var t,e,n,r,a,o=this;return i(this,(function(i){switch(i.label){case 0:return t=V.getInstance(),e=t.customerStore.customer,n=e?e.customerGroupIds:null,r=this.variants.map((function(t){return t.id})),[4,w.getProductCampaigns({input:{customerGroupIds:n,salesChannelId:b.getSalesChannelId()||"",variantIds:r}})];case 1:return a=i.sent(),this.campaigns=a.data,this.campaigns?(this.campaigns.map((function(t){o.variants.map((function(e){var i;t.variantIds.some((function(t){return t===e.id}))&&(null===(i=e.campaigns)||void 0===i||i.push(t))}))})),[2,this.campaigns]):[2]}}))}))},this.getCustomerReviews=function(t){return e(x,void 0,void 0,(function(){var e;return i(this,(function(i){switch(i.label){case 0:return[4,(e=new S({productId:this.id,limit:null==t?void 0:t.limit,page:null==t?void 0:t.page})).getInitial()];case 1:return i.sent(),[2,e]}}))}))},this.getProductOptionSet=function(){return e(x,void 0,void 0,(function(){var t,e;return i(this,(function(i){switch(i.label){case 0:return this.productOptionSet?[2,!0]:this.productOptionSetId?[4,w.listProductOptionSet({id:{eq:this.productOptionSetId}})]:[2,!1];case 1:return(t=i.sent()).isSuccess&&(null===(e=t.data)||void 0===e?void 0:e.length)?(this.productOptionSet=t.data[0],this.setOptionPrices(),[2,!0]):[2,!1]}}))}))},this.setOptionPrices=function(){var t,e=x.variants[0];if(e){var i=e.price.currency;null===(t=x.productOptionSet)||void 0===t||t.options.forEach((function(t){var e;t.selectSettings&&t.selectSettings.values.forEach((function(t){var e;t.otherPrices&&(t.price=(null===(e=t.otherPrices.find((function(t){return t.currencyCode===i})))||void 0===e?void 0:e.price)||t.price)})),t.otherPrices&&(t.price=(null===(e=t.otherPrices.find((function(t){return t.currencyCode===i})))||void 0===e?void 0:e.price)||t.price)}))}},this.id=h.id||Date.now()+"",this.name=h.name||"",this.type=h.type||d.PHYSICAL,this.description=h.description||"",this.shortDescription=h.shortDescription||"",this.metaData=h.metaData?new c(h.metaData):null,this.brand=h.brand?new u(h.brand):null,this.categories=h.categories?h.categories.map((function(t){return new r(t)})):[],this.tags=h.tags?h.tags.map((function(t){return new l(t)})):[],this.variants=h.variants?h.variants.map((function(t){return new a(t)})):[],this.attributes=h.attributes?h.attributes.map((function(t){return new o(t)})):[],this.variantTypes=h.variantTypes?h.variantTypes.map((function(t){return new s(t)})):[],this.productOptionSetId=h.productOptionSetId||null,this.averageRating=null!==(O=h.averageRating)&&void 0!==O?O:null,this.reviewCount=null!==(T=h.reviewCount)&&void 0!==T?T:null,this.baseUnit=h.baseUnit?new P(h.baseUnit):null,this.productOptionSet=h.productOptionSet?new p(h.productOptionSet):null,this.campaigns=(null===(I=h.campaigns)||void 0===I?void 0:I.map((function(t){return new g(t)})))||null,this.selectedVariantValues=h.selectedVariantValues||[],this.variantTypes=n(this.variantTypes,"order"),this.setOptionPrices(),f(this,{selectedVariantValues:m,hasVariant:v,hasStock:v,hasValidProductOptionValues:v,href:v,productHref:v,mainVariantType:v,mainVariantValue:v,selectedVariant:v,displayedVariantTypes:v,isCustomerReviewEnabled:v,isCustomerReviewLoginRequired:v,isAddToCartEnabled:v,groupedAttributeValues:v,selectedVariantUnitPriceText:v})}return Object.defineProperty(T.prototype,"hasVariant",{get:function(){return h.hasVariant(this)},enumerable:!1,configurable:!0}),Object.defineProperty(T.prototype,"hasStock",{get:function(){return h.hasStock(this)},enumerable:!1,configurable:!0}),Object.defineProperty(T.prototype,"hasValidProductOptionValues",{get:function(){return!this.productOptionSet||this.productOptionSet.hasValidValues},enumerable:!1,configurable:!0}),Object.defineProperty(T.prototype,"href",{get:function(){return h.getSelectedVariantHref(this,this.selectedVariantValues)},enumerable:!1,configurable:!0}),Object.defineProperty(T.prototype,"productHref",{get:function(){return h.getProductHref(this)},enumerable:!1,configurable:!0}),Object.defineProperty(T.prototype,"mainVariantType",{get:function(){return h.getMainVariantType(this)},enumerable:!1,configurable:!0}),Object.defineProperty(T.prototype,"mainVariantValue",{get:function(){return h.getMainVariantValue(this.selectedVariantValues)},enumerable:!1,configurable:!0}),Object.defineProperty(T.prototype,"selectedVariant",{get:function(){if(!this.hasVariant)return this.variants[0];var t=this.selectedVariantValues.map((function(t){return t.id}));return this.variants.find((function(e){return e.variantValues.every((function(e){return t.includes(e.id)}))}))},enumerable:!1,configurable:!0}),Object.defineProperty(T.prototype,"displayedVariantTypes",{get:function(){return h.getDisplayedVariantTypes(this,this.selectedVariantValues)},enumerable:!1,configurable:!0}),Object.defineProperty(T.prototype,"isCustomerReviewEnabled",{get:function(){return b.isCustomerReviewEnabled()},enumerable:!1,configurable:!0}),Object.defineProperty(T.prototype,"isCustomerReviewLoginRequired",{get:function(){return b.isCustomerReviewLoginRequired()},enumerable:!1,configurable:!0}),Object.defineProperty(T.prototype,"isAddToCartEnabled",{get:function(){return this.hasValidProductOptionValues&&(this.selectedVariant.hasStock||this.selectedVariant.sellIfOutOfStock)},enumerable:!1,configurable:!0}),Object.defineProperty(T.prototype,"groupedAttributeValues",{get:function(){var t,e=O(this.attributes,"productAttributeId");return(null===(t=this.attributes)||void 0===t?void 0:t.map((function(t){var i=t.productAttributeId;if(i){var n=e[i];return(null==n?void 0:n.length)&&n[0].productAttribute?{attribute:n[0].productAttribute,values:n}:void 0}})).filter((function(t){return!!t})))||[]},enumerable:!1,configurable:!0}),Object.defineProperty(T.prototype,"selectedVariantUnitPriceText",{get:function(){return this.getVariantUnitPriceText(this.selectedVariant)},enumerable:!1,configurable:!0}),T}();export{T as IkasProduct};
1
+ import{__spreadArray as t,__awaiter as e,__generator as i}from'./../../../ext/tslib/tslib.es6.js';import r from"lodash/sortBy";import{IkasCategory as n}from"../category/index.js";import{IkasProductVariant as a}from"./variant/index.js";import{IkasProductAttributeValue as o}from"./attribute-value/index.js";import{IkasProductVariantType as s}from"./variant-type/index.js";import{IkasBrand as u}from"../brand/index.js";import{IkasHTMLMetaData as c}from"../html-meta-data/index.js";import{IkasProductTag as l}from"./tag/index.js";import{IkasProductType as d}from"@ikas/storefront-models";export{IkasProductType}from"@ikas/storefront-models";import{IkasProductOptionSet as p}from"./option-set/index.js";import{makeObservable as f,observable as m,computed as h}from"mobx";import{IkasProductFunctions as v}from"@ikas/storefront-model-functions";import{IkasProductCampaign as g}from"./campaign/index.js";import{IkasStorefrontConfig as b}from"@ikas/storefront-config";import{Analytics as y}from"../../../analytics/analytics.js";import"../../../analytics/head/index.js";import{IkasBaseStore as V}from"../../../store/base.js";import O from"lodash/groupBy";import{IkasProductBaseUnit as P}from"./base-unit/index.js";import{formatCurrency as j}from"../../../utils/currency.js";import"lodash/get";import T from"../../../store/product/index.js";import{IkasCustomerReviewList as w}from"../../ui/customer-review-list/index.js";var S=function(){function S(v){void 0===v&&(v={});var O,S,I,x=this;this.metaData=null,this.brand=null,this.tags=null,this.productOptionSetId=null,this.productOptionSet=null,this.campaigns=null,this.selectedVariantValues=[],this.isFiltered=!1,this.selectVariantValue=function(e,i){var r,n=x.metaData,a=x.selectedVariantValues.map((function(t){return t.variantTypeId===e.variantTypeId?e:t})),o=x.variants.find((function(t){return t.isActive&&a.every((function(e){return t.variantValues.some((function(t){return t.id===e.id}))}))}));if(o)x.selectedVariantValues=a;else{var s=x.variantTypes.findIndex((function(t){return t.variantType.id===e.variantTypeId}));if(s>0){var u=x.variantTypes.slice(0,s),c=x.selectedVariantValues.filter((function(t){return u.some((function(e){return e.variantType.id===t.variantTypeId}))})),l=t(t([],c,!0),[e],!1);o=x.variants.find((function(t){return t.isActive&&l.every((function(e){return t.variantValues.some((function(t){return t.id===e.id}))}))}))}else{var d=a.slice(0,a.length-1);(o=x.variants.find((function(t){return t.isActive&&d.every((function(e){return t.variantValues.some((function(t){return t.id===e.id}))}))})))||(o=x.variants.find((function(t){return t.isActive&&t.variantValues.some((function(t){return t.id===e.id}))})))}if(!o)return;x.selectedVariantValues=o.variantValues}var p=x.variantTypes.map((function(t){var e=t.variantType,i=e.values.find((function(t){return x.selectedVariantValues.some((function(e){return e.id===t.id}))}));if(i)return"".concat(e.slug,"=").concat(i.slug)})).filter((function(t){return!!t})).join("&");if(!i){var f="/".concat(n.slug);if(p&&(f="/".concat(n.slug,"?").concat(p)),f===window.location.pathname)return;var m="production"!==process.env.NODE_ENV;null===(r=V.getInstance().router)||void 0===r||r.replace(f,void 0,{shallow:m,scroll:!1})}y.productView(x)},this.getVariantUnitPriceText=function(t){var e,i,r=t.price;if(r.unitPrice&&x.baseUnit){var n=x.baseUnit.baseAmount,a=(null===(i=null===(e=x.baseUnit)||void 0===e?void 0:e.unit)||void 0===i?void 0:i.name)||"";return"".concat(j(r.unitPrice,r.currency||"",r.currencySymbol||"")," / ").concat(n&&1!==n?n:"").concat(a)}},this.getCampaigns=function(){return e(x,void 0,void 0,(function(){var t,e,r,n,a,o=this;return i(this,(function(i){switch(i.label){case 0:return t=V.getInstance(),e=t.customerStore.customer,r=e?e.customerGroupIds:null,n=this.variants.map((function(t){return t.id})),[4,T.getProductCampaigns({input:{customerGroupIds:r,salesChannelId:b.getSalesChannelId()||"",variantIds:n}})];case 1:return a=i.sent(),this.campaigns=a.data,this.campaigns?(this.campaigns.map((function(t){o.variants.map((function(e){var i;t.variantIds.some((function(t){return t===e.id}))&&(null===(i=e.campaigns)||void 0===i||i.push(t))}))})),[2,this.campaigns]):[2]}}))}))},this.getCustomerReviews=function(t){return e(x,void 0,void 0,(function(){var e;return i(this,(function(i){switch(i.label){case 0:return[4,(e=new w({productId:this.id,limit:null==t?void 0:t.limit,page:null==t?void 0:t.page})).getInitial()];case 1:return i.sent(),[2,e]}}))}))},this.getProductOptionSet=function(){return e(x,void 0,void 0,(function(){var t,e;return i(this,(function(i){switch(i.label){case 0:return this.productOptionSet?[2,!0]:this.productOptionSetId?[4,T.listProductOptionSet({id:{eq:this.productOptionSetId}})]:[2,!1];case 1:return(t=i.sent()).isSuccess&&(null===(e=t.data)||void 0===e?void 0:e.length)?(this.productOptionSet=t.data[0],this.setOptionPrices(),[2,!0]):[2,!1]}}))}))},this.setOptionPrices=function(){var t,e=x.variants[0];if(e){var i=e.price.currency;null===(t=x.productOptionSet)||void 0===t||t.options.forEach((function(t){var e;t.selectSettings&&t.selectSettings.values.forEach((function(t){var e;t.otherPrices&&(t.price=(null===(e=t.otherPrices.find((function(t){return t.currencyCode===i})))||void 0===e?void 0:e.price)||t.price)})),t.otherPrices&&(t.price=(null===(e=t.otherPrices.find((function(t){return t.currencyCode===i})))||void 0===e?void 0:e.price)||t.price)}))}},this.id=v.id||Date.now()+"",this.name=v.name||"",this.type=v.type||d.PHYSICAL,this.description=v.description||"",this.shortDescription=v.shortDescription||"",this.metaData=v.metaData?new c(v.metaData):null,this.brand=v.brand?new u(v.brand):null,this.categories=v.categories?v.categories.map((function(t){return new n(t)})):[],this.tags=v.tags?v.tags.map((function(t){return new l(t)})):[],this.variants=v.variants?v.variants.map((function(t){return new a(t)})):[],this.attributes=v.attributes?v.attributes.map((function(t){return new o(t)})):[],this.variantTypes=v.variantTypes?v.variantTypes.map((function(t){return new s(t)})):[],this.productOptionSetId=v.productOptionSetId||null,this.averageRating=null!==(O=v.averageRating)&&void 0!==O?O:null,this.reviewCount=null!==(S=v.reviewCount)&&void 0!==S?S:null,this.baseUnit=v.baseUnit?new P(v.baseUnit):null,this.productOptionSet=v.productOptionSet?new p(v.productOptionSet):null,this.campaigns=(null===(I=v.campaigns)||void 0===I?void 0:I.map((function(t){return new g(t)})))||null,this.selectedVariantValues=v.selectedVariantValues||[],this.variantTypes=r(this.variantTypes,"order"),this.groupVariantsByVariantTypeId=v.groupVariantsByVariantTypeId||null,this.setOptionPrices(),f(this,{selectedVariantValues:m,isFiltered:m,hasVariant:h,hasStock:h,hasValidProductOptionValues:h,href:h,productHref:h,mainVariantType:h,mainVariantValue:h,selectedVariant:h,displayedVariantTypes:h,isCustomerReviewEnabled:h,isCustomerReviewLoginRequired:h,isAddToCartEnabled:h,groupedAttributeValues:h,selectedVariantUnitPriceText:h})}return Object.defineProperty(S.prototype,"hasVariant",{get:function(){return v.hasVariant(this)},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"hasStock",{get:function(){return v.hasStock(this)},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"hasValidProductOptionValues",{get:function(){return!this.productOptionSet||this.productOptionSet.hasValidValues},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"href",{get:function(){return v.getSelectedVariantHref(this,this.selectedVariantValues)},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"productHref",{get:function(){return this.groupVariantsByVariantTypeId||this.isFiltered?this.href:v.getProductHref(this)},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"mainVariantType",{get:function(){return v.getMainVariantType(this)},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"mainVariantValue",{get:function(){return v.getMainVariantValue(this.selectedVariantValues)},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"selectedVariant",{get:function(){if(!this.hasVariant)return this.variants[0];var t=this.selectedVariantValues.map((function(t){return t.id}));return this.variants.find((function(e){return e.variantValues.every((function(e){return t.includes(e.id)}))}))},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"displayedVariantTypes",{get:function(){return v.getDisplayedVariantTypes(this,this.selectedVariantValues)},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"isCustomerReviewEnabled",{get:function(){return b.isCustomerReviewEnabled()},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"isCustomerReviewLoginRequired",{get:function(){return b.isCustomerReviewLoginRequired()},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"isAddToCartEnabled",{get:function(){return this.hasValidProductOptionValues&&(this.selectedVariant.hasStock||this.selectedVariant.sellIfOutOfStock)},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"groupedAttributeValues",{get:function(){var t,e=O(this.attributes,"productAttributeId");return(null===(t=this.attributes)||void 0===t?void 0:t.map((function(t){var i=t.productAttributeId;if(i){var r=e[i];return(null==r?void 0:r.length)&&r[0].productAttribute?{attribute:r[0].productAttribute,values:r}:void 0}})).filter((function(t){return!!t})))||[]},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"selectedVariantUnitPriceText",{get:function(){return this.getVariantUnitPriceText(this.selectedVariant)},enumerable:!1,configurable:!0}),S}();export{S as IkasProduct};
@@ -50,6 +50,7 @@ export declare class IkasProductList {
50
50
  get filterCategories(): IkasFilterCategory[] | undefined;
51
51
  get hasAppliedfilter(): boolean | undefined;
52
52
  get isFeaturedSortEnabled(): boolean;
53
+ private setIsFilteredForProducts;
53
54
  private setPageSpecificSort;
54
55
  private getSortParams;
55
56
  private searchProducts;
@@ -1 +1 @@
1
- import{__awaiter as t,__generator as e,__assign as i}from'./../../../ext/tslib/tslib.es6.js';import{makeAutoObservable as r}from"mobx";import s from"lodash/debounce";import"../../data/blog/category/index.js";import"../../data/blog/content/index.js";import"../../data/blog/meta-data/index.js";import"../../data/blog/tag/index.js";import"../../data/blog/index.js";import"../../data/brand/index.js";import{IkasCategoryProductsOrderType as a,IkasThemeJsonPageType as o,IkasThemeJsonStockPreference as n}from"@ikas/storefront-models";import"../../data/campaign-offer/index.js";import"../../data/cart/campaign-offer/index.js";import"../../data/cart/index.js";import"../../data/category/path-item/index.js";import"../../data/category/index.js";import"../../data/checkout/index.js";import"../../data/checkout-settings/index.js";import"../../data/city/index.js";import"../../data/country/index.js";import"../../data/customer/address/index.js";import"../../data/customer/attribute/index.js";import"../../data/customer/review/summary/index.js";import"../../data/customer/review/index.js";import"../../data/customer/index.js";import"../../data/district/index.js";import"../../data/favorite-product/index.js";import{IkasFilterCategory as d}from"../../data/filter-category/index.js";import"../../data/html-meta-data/index.js";import"../../data/image/index.js";import"../../data/order/address/index.js";import"../../data/order/line-item/option/value/index.js";import"../../data/order/line-item/variant/value/index.js";import"../../data/order/line-item/variant/index.js";import"../../data/order/line-item/index.js";import"../../data/order/package/index.js";import"../../data/order/transaction/index.js";import"../../data/order/index.js";import"../../data/payment-gateway/index.js";import"../../data/product/attribute-value/index.js";import{IkasProductFilter as u,IkasProductFilterValue as c}from"../../data/product/filter/index.js";import"../../data/product/option-set/option/index.js";import"../../data/product/option-set/index.js";import"../../data/product/variant/price/index.js";import"../../data/product/variant/index.js";import"../../data/variant-type/index.js";import{IkasProduct as l}from"../../data/product/index.js";import"../../data/raffle/index.js";import"../../data/state/index.js";import"../../data/theme-json/index.js";import"../../data/theme-json/custom-data/index.js";import"../../data/variant-type/variant-value/index.js";import p from"../../../store/product/index.js";import h from"query-string";import{SortByDirectionEnum as f,SortByTypeEnum as m}from"@ikas/storefront-api";import{IkasStorefrontConfig as g}from"@ikas/storefront-config";import{Analytics as v}from"../../../analytics/analytics.js";import"../../../analytics/head/index.js";import"../../../components/page/index.js";import"../../../components/page/head.js";import"react";import"next/image.js";import"@ikas/storefront-model-functions";import"../../../components/link/index.js";import"../../../components/page-editor/loader/style.module.scss.js";import"../../../components/google-captcha/index.js";import"../blog-list/index.js";import"../blog-category-list/index.js";import"../brand-list/index.js";import"../category-list/index.js";import"../product-attribute-detail/index.js";import"../product-attribute-list/index.js";import"../customer-review-list/index.js";import"../customer-review-summary-list/index.js";import"../validator/index.js";import"../validator/rules/index.js";import"../validator/form/login.js";import"../validator/form/address.js";import"../validator/form/register.js";import"../validator/form/contact-form.js";import"../validator/form/forgot-password.js";import"../validator/form/recover-password.js";import"../validator/form/account-info.js";import"../validator/form/raffle-form.js";import"../validator/form/customer-review.js";import"../raffle-list/index.js";import"../../../pages/home.js";import"../../../pages/_slug_/index.js";import"../../../pages/pages/_slug_.js";import"../../../pages/checkout.js";import"../../../pages/account/index.js";import"../../../pages/account/addresses.js";import"../../../pages/account/orders/index.js";import"../../../pages/account/orders/_id_.js";import"../../../pages/account/login.js";import"../../../pages/account/register.js";import"../../../pages/account/forgot-password.js";import"../../../pages/account/recover-password.js";import"../../../pages/cart.js";import"../../../pages/editor.js";import"../../../pages/account/favorite-products.js";import"../../../pages/search.js";import"next/error.js";import"../../../pages/blog/index.js";import"../../../pages/blog/_slug_.js";import"../../../pages/raffle/_slug_.js";import"../../../pages/raffle/index.js";import"../../../pages/account/raffles.js";import{IkasBaseStore as _}from"../../../store/base.js";import"../../../store/customer/index.js";import"../../../store/cart/index.js";import"lodash/get";var y,I,S,C=function(){function S(a,n){var c=this;this.filters=null,this._filterCategories=null,this._infiniteScrollPage=null,this._initialized=!1,this._minPage=null,this._filterBrandId=null,this._filterCategoryId=null,this._relatedProductData=null,this.pageSpecificData=null,this._recommendFor=null,this._isLoading=!1,this._fetchRequestTime=0,this.router=null,this.applyFilters=function(){return t(c,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return[4,this.getInitial()];case 1:return t=e.sent(),[o.CATEGORY,o.BRAND,o.SEARCH].includes(this._pageType)?(t&&this.isBrowser()&&!this.isSearch&&!g.getIsEditor()&&(null===(i=this.router)||void 0===i||i.replace("".concat(location.pathname).concat(this.filterQueryParams?"?"+this.filterQueryParams:""),void 0,{shallow:!0})),[2]):[2]}}))}))},this.getInitial=function(r,s){return t(c,void 0,void 0,(function(){var t,a,o,n,d,u,c,p,h,f,m,g,v,y,I;return e(this,(function(e){switch(e.label){case 0:this._isLoading=!0,t=Date.now(),this._fetchRequestTime=t,e.label=1;case 1:return e.trys.push([1,14,15,16]),a=s?this._page:1,o=this._limit,!this.isFilterable||this.filters?[3,3]:[4,this.getFilters()];case 2:e.sent(),e.label=3;case 3:return this.applyQueryParamFilters(r),this.isSearch&&!this.hasAppliedfilter?(this.data=[],this._page=1,this._minPage=1,this._count=0,this._initialized=!0,[2,!0]):(n=void 0,d=!1,this.isStatic?(a=void 0,o=200,[3,10]):[3,4]);case 4:return this.isDiscounted?(a=1,o=10,[3,10]):[3,5];case 5:return this.isRecommended?(a=1,o=10,[3,10]):[3,6];case 6:return this.isLastViewed?this.isBrowser()?[4,this.waitForCustomerStoreInit()]:[3,9]:[3,10];case 7:return e.sent(),[4,_.getInstance().customerStore.getLastViewedProducts()];case 8:return(u=e.sent())&&u.length?(n=u.map((function(t){return t.productId})),d=_.getInstance().customerStore.useLastViewedProductResponse,[3,10]):[2];case 9:return[2];case 10:return d?(p=_.getInstance().customerStore._savedLastViewedProductsResponse,[3,13]):[3,11];case 11:return[4,this.searchProducts(a||1,o||10,n)];case 12:p=e.sent(),e.label=13;case 13:return(c=p)&&this._fetchRequestTime===t?(h=[],!d&&this.isLastViewed&&_.getInstance().customerStore.setSavedLastViewedProductsResponse(c),this.isStatic||this.isLastViewed?(f=this.isStatic?this._productListPropValue.productIds:_.getInstance().customerStore._lastViewedProducts,h=(null==f?void 0:f.map((function(t){var e,r,s=null===(r=null===(e=c.data)||void 0===e?void 0:e.data)||void 0===r?void 0:r.find((function(e){return e.id===t.productId})),a=null==s?void 0:s.variants.find((function(e){return e.id===t.variantId}));if((null==a?void 0:a.isActive)||(a=null==s?void 0:s.variants.find((function(t){return t.isActive}))),s&&a)return new l(i(i({},s),{selectedVariantValues:a.variantValues}))})).filter((function(t){return!!t})))||[]):h=(null===(v=null===(g=c.data)||void 0===g?void 0:g.data)||void 0===v?void 0:v.map((function(t){var e=t.variants.find((function(t){return t.isActive}));return new l(i(i({},t),{selectedVariantValues:(e||t.variants[0]).variantValues}))})))||[],this.applyFacets(null===(y=c.data)||void 0===y?void 0:y.facets),this.data=h,this._count=(null===(I=c.data)||void 0===I?void 0:I.count)||0,this._initialized=!0,this._page=a||1,this._minPage=this.page,s||(this._infiniteScrollPage=null),this.handleListingEvent(),[2,!0]):[2];case 14:return m=e.sent(),console.log(m),[3,16];case 15:return t===this._fetchRequestTime&&(this._isLoading=!1),[7];case 16:return[2]}}))}))},this.getPrev=function(){return t(c,void 0,void 0,(function(){var t,r,s,a,o,n,d;return e(this,(function(e){switch(e.label){case 0:if(this.isStatic||this.isDiscounted||this.isRecommended||this.isLastViewed||this._isLoading||!this.hasPrev)return[2];this._isLoading=!0,e.label=1;case 1:return e.trys.push([1,3,4,5]),t=this._minPage-1,[4,this.searchProducts(t,this.limit)];case 2:return(r=e.sent())?(s=null===(n=null===(o=r.data)||void 0===o?void 0:o.data)||void 0===n?void 0:n.map((function(t){var e=t.variants.find((function(t){return t.isActive}));return new l(i(i({},t),{selectedVariantValues:(e||t.variants[0]).variantValues}))})),this.data=(null==s?void 0:s.concat(this.data))||this.data,this._count=(null===(d=r.data)||void 0===d?void 0:d.count)||this._count,this._minPage=t,[3,5]):[2];case 3:return a=e.sent(),console.log(a),[3,5];case 4:return this._isLoading=!1,[7];case 5:return[2]}}))}))},this.getNext=function(){return t(c,void 0,void 0,(function(){var t,r,s,a,o,n;return e(this,(function(e){switch(e.label){case 0:if(this.isStatic||this.isDiscounted||this.isRecommended||this.isLastViewed||this._isLoading||!this.hasNext)return[2];this._isLoading=!0,e.label=1;case 1:return e.trys.push([1,3,4,5]),[4,this.searchProducts(this.page+1,this.limit)];case 2:return(t=e.sent())?(r=null===(o=null===(a=t.data)||void 0===a?void 0:a.data)||void 0===o?void 0:o.map((function(t){var e=t.variants.find((function(t){return t.isActive}));return new l(i(i({},t),{selectedVariantValues:(e||t.variants[0]).variantValues}))})),this.data=this.data.concat(r||[]),this._count=(null===(n=t.data)||void 0===n?void 0:n.count)||this._count,this._page=this.page+1,[3,5]):[2];case 3:return s=e.sent(),console.log(s),[3,5];case 4:return this._isLoading=!1,[7];case 5:return[2]}}))}))},this.getPage=function(r){return t(c,void 0,void 0,(function(){var t,s,a,o,n,d;return e(this,(function(e){switch(e.label){case 0:if(this._isLoading||this.isStatic||this.isDiscounted||this.isRecommended||this.isLastViewed)return[2];this._isLoading=!0,e.label=1;case 1:return e.trys.push([1,3,4,5]),[4,this.searchProducts(r,this.limit)];case 2:return(t=e.sent())?(s=null===(n=null===(o=t.data)||void 0===o?void 0:o.data)||void 0===n?void 0:n.map((function(t){var e=t.variants.find((function(t){return t.isActive}));return new l(i(i({},t),{selectedVariantValues:(e||t.variants[0]).variantValues}))})),this.data=s||[],this._count=(null===(d=t.data)||void 0===d?void 0:d.count)||0,this._page=r,this._minPage=r,[3,5]):[2];case 3:return a=e.sent(),console.log(a),[3,5];case 4:return this._isLoading=!1,[7];case 5:return[2]}}))}))},this.setVisibleInfiniteScrollPage=function(t){var e;c._infiniteScrollPage!==t&&(c._infiniteScrollPage=t,g.getIsEditor()||null===(e=c.router)||void 0===e||e.replace("".concat(location.pathname).concat(c.filterQueryParams?"?"+c.filterQueryParams:""),void 0,{shallow:!0}))},this.searchDebouncer=s((function(){c.applyFilters()}),500),this.searchAnalyticsDebouncer=s((function(){v.search(c._searchKeyword)}),1e3);var p=a,h=a;if(this.data=a.data?a.data.map((function(t){return new l(t)})):[],this._type=p.type||h._type||p.productListPropValue.productListType||h._productListPropValue.productListType||y.ALL,this._pageType=a.pageType,this._sort=a.sort||a.productListPropValue.initialSort||I.LAST_ADDED,this._limit=a.limit||p.productListPropValue.initialLimit||h._productListPropValue.initialLimit||20,this._page=a.page||1,this._minPage=a.minPage||null,this._count=a.count||0,this._searchKeyword=a.searchKeyword||"",this._productListPropValue=p.productListPropValue||h._productListPropValue,this._filterBrandId=p.filterBrandId||h._filterBrandId||null,this._filterCategoryId=p.filterCategoryId||h._filterCategoryId||null,this._relatedProductData=p.relatedProductData||h._relatedProductData||null,this._recommendFor=p.recommendFor||h._recommendFor,this.filters=a.filters?a.filters.map((function(t){return new u(t,c)})):null,this._filterCategories=a.filterCategories?a.filterCategories.map((function(t){return new d(t)})):null,this.pageSpecificData=p.pageSpecificData||h.pageSpecificData||null,this.router=n,r(this,{router:!1}),this.setPageSpecificSort(),this.isBrowser())if(this.restoreInfiniteScrollPage(),location.search&&(this.isFilterable||this._type===y.SEARCH)){var f=this.getQueryParams();this.getInitial(f,this._page>1)}else this._page>1?this.getInitial(void 0,!0):this.isLastViewed?this.getInitial():this.handleListingEvent()}return Object.defineProperty(S.prototype,"sort",{get:function(){return this._sort},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"limit",{get:function(){return this._limit},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"pageType",{get:function(){return this._pageType},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"page",{get:function(){return this._page},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"minPage",{get:function(){return this._minPage||1},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"count",{get:function(){return this._count},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"pageCount",{get:function(){return Math.ceil(this._count/this._limit)},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"searchKeyword",{get:function(){return this._searchKeyword},set:function(t){t!==this._searchKeyword&&(this._searchKeyword=t,this.searchDebouncer(),this.searchAnalyticsDebouncer())},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"isInitialized",{get:function(){return this._initialized},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"isFilterable",{get:function(){return this._type===y.ALL||this._type===y.CATEGORY},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"isFiltered",{get:function(){var t,e;return(null===(t=this.filters)||void 0===t?void 0:t.some((function(t){return!!t.valueList.length})))||!!this._searchKeyword||this._pageType!==o.CATEGORY&&(!!this._filterCategoryId||(null===(e=this._filterCategories)||void 0===e?void 0:e.some((function(t){return t.isSelected}))))},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"isStatic",{get:function(){return this._type===y.STATIC},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"isDiscounted",{get:function(){return this._type===y.DISCOUNTED},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"isRecommended",{get:function(){return this._type===y.RECOMMENDED},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"isLastViewed",{get:function(){return this._type===y.LAST_VIEWED},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"isRelatedProducts",{get:function(){return this._type===y.RELATED_PRODUCTS},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"isSearch",{get:function(){return this._type===y.SEARCH},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"hasPrev",{get:function(){return!(this.isStatic||this.isDiscounted||this.isRecommended||!this._minPage)&&this._minPage>1},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"hasNext",{get:function(){return!(this.isStatic||this.isDiscounted||this.isRecommended)&&this.page*this.limit<this.count},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"isLoading",{get:function(){return this._isLoading},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"filterQueryParams",{get:function(){var t,e,i,r,s=this,a={};if(null===(t=this.filters)||void 0===t||t.forEach((function(t){t.keyList.length&&(a[t.key]=t.keyList)})),this._searchKeyword&&(a.s=this._searchKeyword),this._infiniteScrollPage&&(a.page=this._infiniteScrollPage),this._pageType!==o.CATEGORY){var n=null===(e=this.filterCategories)||void 0===e?void 0:e.filter((function(t){return t.isSelected}));if(!!(null==n?void 0:n.length))a.c=null==n?void 0:n.map((function(t){return t.slug}));else if(this._filterCategoryId){var d=null===(r=null===(i=this.filterCategories)||void 0===i?void 0:i.find((function(t){return t.id===s._filterCategoryId})))||void 0===r?void 0:r.slug;d&&(a.c=d)}}return h.stringify(a,{arrayFormat:"comma"})},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"filterCategories",{get:function(){var t;return null===(t=this._filterCategories)||void 0===t?void 0:t.filter((function(t){return 0!==t.resultCount}))},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"hasAppliedfilter",{get:function(){var t;return!!this._searchKeyword||(null===(t=this.filters)||void 0===t?void 0:t.some((function(t){return!!t.valueList.length})))},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"isFeaturedSortEnabled",{get:function(){var t;return(null===(t=this.pageSpecificData)||void 0===t?void 0:t.orderType)===a.MANUALLY&&[y.ALL,y.CATEGORY].includes(this._type)},enumerable:!1,configurable:!0}),S.prototype.setPageSpecificSort=function(){var t;if((null===(t=this.pageSpecificData)||void 0===t?void 0:t.orderType)&&[y.ALL].includes(this._type))switch(this.pageSpecificData.orderType){case a.HIGHEST_DISCOUNT_RATIO:this._sort=I.DECRASING_DISCOUNT;break;case a.LOWEST_DISCOUNT_RATIO:this._sort=I.INCREASING_DISCOUNT;break;case a.HIGHEST_PRICE:this._sort=I.DECREASING_PRICE;break;case a.LOWEST_PRICE:this._sort=I.INCREASING_PRICE;break;case a.NEWEST:this._sort=I.LAST_ADDED;break;case a.OLDEST:this._sort=I.FIRST_ADDED;break;case a.MANUALLY:this._sort=I.FEATURED}},S.prototype.getSortParams=function(){var t,e;switch(this._sort){case I.INCREASING_PRICE:t=f.ASC,e=m.PRICE;break;case I.DECREASING_PRICE:t=f.DESC,e=m.PRICE;break;case I.FIRST_ADDED:t=f.ASC,e=m.CREATED_AT;break;case I.LAST_ADDED:t=f.DESC,e=m.CREATED_AT;break;case I.INCREASING_DISCOUNT:t=f.ASC,e=m.DISCOUNT_RATIO;break;case I.DECRASING_DISCOUNT:t=f.DESC,e=m.DISCOUNT_RATIO;break;case I.FEATURED:if(this.isSearch)return;t=f.ASC,e=m.MANUAL_SORT;break;case I.DEFAULT:t=void 0,e=void 0}if(t&&e)return{direction:t,type:e}},S.prototype.searchProducts=function(i,r,s){var a,d,u;return t(this,void 0,void 0,(function(){var t,l,h,f;return e(this,(function(e){switch(e.label){case 0:return t=[],l=[],null===(a=this.filters)||void 0===a||a.forEach((function(e){e.valueList.length&&t.push(new c({id:e.id,type:e.type,displayType:e.displayType,valueList:e.valueList})),e.isFacetFilter&&l.push({id:e.id,type:e.type,displayType:e.displayType})})),h=null===(d=this._filterCategories)||void 0===d?void 0:d.filter((function(t){return t.isSelected})).map((function(t){return t.id})),f=this.getSortParams(),this.isRelatedProducts&&this._relatedProductData?[4,p.getRelatedProducts({priceListId:g.getPriceListId(),salesChannelId:g.getSalesChannelId(),productId:this._relatedProductData.productId,brandIds:this._relatedProductData.brandIds,categoryIds:this._relatedProductData.categoryIds,locale:g.getCurrentLocale()})]:[3,2];case 1:case 3:return[2,e.sent()];case 2:return[4,p.searchProducts({input:{page:i,perPage:r,productIdList:this.isStatic?null===(u=this._productListPropValue.productIds)||void 0===u?void 0:u.map((function(t){return t.productId})):s,filterList:t,facetList:l,brandId:this._pageType===o.BRAND&&this._type!==y.SEARCH?this._filterBrandId:void 0,categoryIdList:h&&h.length?h:this._filterCategoryId?[this._filterCategoryId]:void 0,priceListId:g.getPriceListId(),salesChannelId:g.getSalesChannelId(),query:this._searchKeyword,order:this._type===y.SEARCH?[]:f?[f]:[],showStockOption:g.getStockPreference()||n.SHOW_ALL}})]}}))}))},S.prototype.getFilters=function(){var i,r,s;return t(this,void 0,void 0,(function(){var t,a,n=this;return e(this,(function(e){switch(e.label){case 0:return[4,p.getProductFilterData({categoryId:this._filterCategoryId?this._filterCategoryId:void 0,locale:g.getCurrentLocale()})];case 1:return t=e.sent(),this.filters=null===(i=null==t?void 0:t.data)||void 0===i?void 0:i.filters.map((function(t){return new u(t,n)})),this._filterCategories=null===(r=null==t?void 0:t.data)||void 0===r?void 0:r.categories,this.pageType!==o.CATEGORY&&this._filterCategoryId&&(a=null===(s=this._filterCategories)||void 0===s?void 0:s.find((function(t){return t.id===n._filterCategoryId})))&&(a.isSelected=!0),this.filters&&this.filters.sort((function(t,e){return t.order>e.order?1:-1})),[2]}}))}))},S.prototype.applyQueryParamFilters=function(t){var e,i=this;try{null==t||t.forEach((function(t,e){var r,s=null===(r=i.filters)||void 0===r?void 0:r.find((function(t){return t.key===e}));s&&s.applyQueryParam(t)}));var r=null==t?void 0:t.get("s");if(r&&(this._searchKeyword=r),this._pageType!==o.CATEGORY){var s=null==t?void 0:t.get("c"),a=null==s?void 0:s.split(",");a&&a.length&&(null===(e=this.filterCategories)||void 0===e||e.forEach((function(t){t.isSelected=a.some((function(e){return e===t.slug}))})))}}catch(t){console.log(t)}},S.prototype.applyFacets=function(t){var e,i;null===(e=this.filters)||void 0===e||e.forEach((function(e){var i,r,s,a=null==t?void 0:t.find((function(t){return t.id===e.id}));a?null===(i=e.values)||void 0===i||i.forEach((function(t){var i=a.values.find((function(e){return e.id===t.id}));i?t.resultCount=i.count:e.isCustomValueFilter?t.resultCount=null:t.resultCount=0})):e.isCustomValueFilter?null===(r=e.values)||void 0===r||r.forEach((function(t){return t.resultCount=null})):null===(s=e.values)||void 0===s||s.forEach((function(t){return t.resultCount=0}))}));var r=null==t?void 0:t.find((function(t){return"category"===t.id}));r&&(null===(i=this._filterCategories)||void 0===i||i.forEach((function(t){var e=r.values.find((function(e){return e.id===t.id}));t.resultCount=e?e.count:0})))},S.prototype.clearFilters=function(){var t,e;null===(t=this.filters)||void 0===t||t.forEach((function(t){return t.clear()})),this._searchKeyword="",this._pageType!==o.CATEGORY&&(this._filterCategoryId=void 0),null===(e=this._filterCategories)||void 0===e||e.forEach((function(t){return t.isSelected=!1})),this.applyFilters()},S.prototype.setSortType=function(i){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return this._sort=i,[4,this.getInitial()];case 1:return t.sent(),[2]}}))}))},S.prototype.onFilterCategoryClick=function(i,r){var s,a;return void 0===r&&(r=!1),t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return r?(null===(s=this._filterCategories)||void 0===s||s.forEach((function(t){t.id===i.id&&(t.isSelected=!t.isSelected)})),[4,this.applyFilters()]):[3,2];case 1:return t.sent(),[3,3];case 2:g.getIsEditor()||null===(a=_.getInstance().router)||void 0===a||a.push(i.href+(this.filterQueryParams?"?"+this.filterQueryParams:"")),t.label=3;case 3:return[2]}}))}))},S.prototype.toJSON=function(){return{data:this.data,type:this._type,pageType:this._pageType,sort:this._sort,limit:this._limit,page:this._page,count:this._count,searchKeyword:this._searchKeyword,initialized:this._initialized,minPage:this._minPage,filterBrandId:this._filterBrandId,filterCategoryId:this._filterCategoryId,filterCategories:this._filterCategories,filters:this.filters,recommendFor:this._recommendFor,productListPropValue:this._productListPropValue,pageSpecificData:this.pageSpecificData}},S.prototype.restoreInfiniteScrollPage=function(){var t=this.getQueryParams(),e=null==t?void 0:t.get("page");if(e){var i=parseInt(e);isNaN(i)||(this._page=i,this._infiniteScrollPage=i)}},S.prototype.getQueryParams=function(){if(this.isBrowser())return new URLSearchParams(location.search)},S.prototype.isBrowser=function(){return"undefined"!=typeof window},S.prototype.waitForCustomerStoreInit=function(){return new Promise((function(t){var e=setInterval((function(){_.getInstance().customerStore.initialized&&(clearInterval(e),t(null))}),1e3)}))},S.prototype.handleListingEvent=function(){this.searchKeyword&&this.data.length?v.viewSearchResults(this._searchKeyword,this.data):this.data.length&&this._type===y.ALL&&v.viewListing(this.data)},S}();!function(t){t.ALL="ALL",t.STATIC="STATIC",t.DISCOUNTED="DISCOUNTED",t.RECOMMENDED="RECOMMENDED",t.CATEGORY="CATEGORY",t.SEARCH="SEARCH",t.LAST_VIEWED="LAST_VIEWED",t.RELATED_PRODUCTS="RELATED_PRODUCTS"}(y||(y={})),function(t){t.INCREASING_PRICE="INCREASING_PRICE",t.DECREASING_PRICE="DECREASING_PRICE",t.LAST_ADDED="LAST_ADDED",t.FIRST_ADDED="FIRST_ADDED",t.INCREASING_DISCOUNT="INCREASING_DISCOUNT",t.DECRASING_DISCOUNT="DECRASING_DISCOUNT",t.FEATURED="FEATURED",t.DEFAULT="DEFAULT"}(I||(I={})),function(t){t.CATEGORY="CATEGORY",t.BRAND="BRAND"}(S||(S={}));export{C as IkasProductList,I as IkasProductListSortType,y as IkasProductListType,S as IkasRelatedProductsType};
1
+ import{__awaiter as t,__generator as e,__assign as i}from'./../../../ext/tslib/tslib.es6.js';import{makeAutoObservable as r}from"mobx";import s from"lodash/debounce";import"../../data/blog/category/index.js";import"../../data/blog/content/index.js";import"../../data/blog/meta-data/index.js";import"../../data/blog/tag/index.js";import"../../data/blog/index.js";import"../../data/brand/index.js";import{IkasCategoryProductsOrderType as o,IkasThemeJsonPageType as a,IkasThemeJsonStockPreference as n}from"@ikas/storefront-models";import"../../data/campaign-offer/index.js";import"../../data/cart/campaign-offer/index.js";import"../../data/cart/index.js";import"../../data/category/path-item/index.js";import"../../data/category/index.js";import"../../data/checkout/index.js";import"../../data/checkout-settings/index.js";import"../../data/city/index.js";import"../../data/country/index.js";import"../../data/customer/address/index.js";import"../../data/customer/attribute/index.js";import"../../data/customer/review/summary/index.js";import"../../data/customer/review/index.js";import"../../data/customer/index.js";import"../../data/district/index.js";import"../../data/favorite-product/index.js";import{IkasFilterCategory as d}from"../../data/filter-category/index.js";import"../../data/html-meta-data/index.js";import"../../data/image/index.js";import"../../data/order/address/index.js";import"../../data/order/line-item/option/value/index.js";import"../../data/order/line-item/variant/value/index.js";import"../../data/order/line-item/variant/index.js";import"../../data/order/line-item/index.js";import"../../data/order/package/index.js";import"../../data/order/transaction/index.js";import"../../data/order/index.js";import"../../data/payment-gateway/index.js";import"../../data/product/attribute-value/index.js";import{IkasProductFilter as u,IkasProductFilterValue as c}from"../../data/product/filter/index.js";import"../../data/product/option-set/option/index.js";import"../../data/product/option-set/index.js";import"../../data/product/variant/price/index.js";import"../../data/product/variant/index.js";import"../../data/variant-type/index.js";import{IkasProduct as l}from"../../data/product/index.js";import"../../data/raffle/index.js";import"../../data/state/index.js";import"../../data/theme-json/index.js";import"../../data/theme-json/custom-data/index.js";import"../../data/variant-type/variant-value/index.js";import p from"../../../store/product/index.js";import h from"query-string";import{SortByDirectionEnum as f,SortByTypeEnum as m}from"@ikas/storefront-api";import{IkasStorefrontConfig as g}from"@ikas/storefront-config";import{Analytics as v}from"../../../analytics/analytics.js";import"../../../analytics/head/index.js";import"../../../components/page/index.js";import"../../../components/page/head.js";import"react";import"next/image.js";import"@ikas/storefront-model-functions";import"../../../components/link/index.js";import"../../../components/page-editor/loader/style.module.scss.js";import"../../../components/google-captcha/index.js";import"../blog-list/index.js";import"../blog-category-list/index.js";import"../brand-list/index.js";import"../category-list/index.js";import"../product-attribute-detail/index.js";import"../product-attribute-list/index.js";import"../customer-review-list/index.js";import"../customer-review-summary-list/index.js";import"../validator/index.js";import"../validator/rules/index.js";import"../validator/form/login.js";import"../validator/form/address.js";import"../validator/form/register.js";import"../validator/form/contact-form.js";import"../validator/form/forgot-password.js";import"../validator/form/recover-password.js";import"../validator/form/account-info.js";import"../validator/form/raffle-form.js";import"../validator/form/customer-review.js";import"../raffle-list/index.js";import"../../../pages/home.js";import"../../../pages/_slug_/index.js";import"../../../pages/pages/_slug_.js";import"../../../pages/checkout.js";import"../../../pages/account/index.js";import"../../../pages/account/addresses.js";import"../../../pages/account/orders/index.js";import"../../../pages/account/orders/_id_.js";import"../../../pages/account/login.js";import"../../../pages/account/register.js";import"../../../pages/account/forgot-password.js";import"../../../pages/account/recover-password.js";import"../../../pages/cart.js";import"../../../pages/editor.js";import"../../../pages/account/favorite-products.js";import"../../../pages/search.js";import"next/error.js";import"../../../pages/blog/index.js";import"../../../pages/blog/_slug_.js";import"../../../pages/raffle/_slug_.js";import"../../../pages/raffle/index.js";import"../../../pages/account/raffles.js";import{IkasBaseStore as _}from"../../../store/base.js";import"../../../store/customer/index.js";import"../../../store/cart/index.js";import"lodash/get";var y,I,S,C=function(){function S(o,n){var c=this;this.filters=null,this._filterCategories=null,this._infiniteScrollPage=null,this._initialized=!1,this._minPage=null,this._filterBrandId=null,this._filterCategoryId=null,this._relatedProductData=null,this.pageSpecificData=null,this._recommendFor=null,this._isLoading=!1,this._fetchRequestTime=0,this.router=null,this.applyFilters=function(){return t(c,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return[4,this.getInitial()];case 1:return t=e.sent(),[a.CATEGORY,a.BRAND,a.SEARCH].includes(this._pageType)?(t&&this.isBrowser()&&!this.isSearch&&!g.getIsEditor()&&(null===(i=this.router)||void 0===i||i.replace("".concat(location.pathname).concat(this.filterQueryParams?"?"+this.filterQueryParams:""),void 0,{shallow:!0})),[2]):[2]}}))}))},this.getInitial=function(r,s){return t(c,void 0,void 0,(function(){var t,o,a,n,d,u,c,p,h,f,m,g,v,y,I;return e(this,(function(e){switch(e.label){case 0:this._isLoading=!0,t=Date.now(),this._fetchRequestTime=t,e.label=1;case 1:return e.trys.push([1,14,15,16]),o=s?this._page:1,a=this._limit,!this.isFilterable||this.filters?[3,3]:[4,this.getFilters()];case 2:e.sent(),e.label=3;case 3:return this.applyQueryParamFilters(r),this.isSearch&&!this.hasAppliedfilter?(this.data=[],this._page=1,this._minPage=1,this._count=0,this._initialized=!0,[2,!0]):(n=void 0,d=!1,this.isStatic?(o=void 0,a=200,[3,10]):[3,4]);case 4:return this.isDiscounted?(o=1,a=10,[3,10]):[3,5];case 5:return this.isRecommended?(o=1,a=10,[3,10]):[3,6];case 6:return this.isLastViewed?this.isBrowser()?[4,this.waitForCustomerStoreInit()]:[3,9]:[3,10];case 7:return e.sent(),[4,_.getInstance().customerStore.getLastViewedProducts()];case 8:return(u=e.sent())&&u.length?(n=u.map((function(t){return t.productId})),d=_.getInstance().customerStore.useLastViewedProductResponse,[3,10]):[2];case 9:return[2];case 10:return d?(p=_.getInstance().customerStore._savedLastViewedProductsResponse,[3,13]):[3,11];case 11:return[4,this.searchProducts(o||1,a||10,n)];case 12:p=e.sent(),e.label=13;case 13:return(c=p)&&this._fetchRequestTime===t?(h=[],!d&&this.isLastViewed&&_.getInstance().customerStore.setSavedLastViewedProductsResponse(c),this.isStatic||this.isLastViewed?(f=this.isStatic?this._productListPropValue.productIds:_.getInstance().customerStore._lastViewedProducts,h=(null==f?void 0:f.map((function(t){var e,r,s=null===(r=null===(e=c.data)||void 0===e?void 0:e.data)||void 0===r?void 0:r.find((function(e){return e.id===t.productId})),o=null==s?void 0:s.variants.find((function(e){return e.id===t.variantId}));if((null==o?void 0:o.isActive)||(o=null==s?void 0:s.variants.find((function(t){return t.isActive}))),s&&o)return new l(i(i({},s),{selectedVariantValues:o.variantValues}))})).filter((function(t){return!!t})))||[]):h=(null===(v=null===(g=c.data)||void 0===g?void 0:g.data)||void 0===v?void 0:v.map((function(t){var e=t.variants.find((function(t){return t.isActive}));return new l(i(i({},t),{selectedVariantValues:(e||t.variants[0]).variantValues}))})))||[],this.applyFacets(null===(y=c.data)||void 0===y?void 0:y.facets),this.data=h,this._count=(null===(I=c.data)||void 0===I?void 0:I.count)||0,this._initialized=!0,this._page=o||1,this._minPage=this.page,this.setIsFilteredForProducts(),s||(this._infiniteScrollPage=null),this.handleListingEvent(),[2,!0]):[2];case 14:return m=e.sent(),console.log(m),[3,16];case 15:return t===this._fetchRequestTime&&(this._isLoading=!1),[7];case 16:return[2]}}))}))},this.getPrev=function(){return t(c,void 0,void 0,(function(){var t,r,s,o,a,n,d;return e(this,(function(e){switch(e.label){case 0:if(this.isStatic||this.isDiscounted||this.isRecommended||this.isLastViewed||this._isLoading||!this.hasPrev)return[2];this._isLoading=!0,e.label=1;case 1:return e.trys.push([1,3,4,5]),t=this._minPage-1,[4,this.searchProducts(t,this.limit)];case 2:return(r=e.sent())?(s=null===(n=null===(a=r.data)||void 0===a?void 0:a.data)||void 0===n?void 0:n.map((function(t){var e=t.variants.find((function(t){return t.isActive}));return new l(i(i({},t),{selectedVariantValues:(e||t.variants[0]).variantValues}))})),this.data=(null==s?void 0:s.concat(this.data))||this.data,this._count=(null===(d=r.data)||void 0===d?void 0:d.count)||this._count,this._minPage=t,this.setIsFilteredForProducts(),[3,5]):[2];case 3:return o=e.sent(),console.log(o),[3,5];case 4:return this._isLoading=!1,[7];case 5:return[2]}}))}))},this.getNext=function(){return t(c,void 0,void 0,(function(){var t,r,s,o,a,n;return e(this,(function(e){switch(e.label){case 0:if(this.isStatic||this.isDiscounted||this.isRecommended||this.isLastViewed||this._isLoading||!this.hasNext)return[2];this._isLoading=!0,e.label=1;case 1:return e.trys.push([1,3,4,5]),[4,this.searchProducts(this.page+1,this.limit)];case 2:return(t=e.sent())?(r=null===(a=null===(o=t.data)||void 0===o?void 0:o.data)||void 0===a?void 0:a.map((function(t){var e=t.variants.find((function(t){return t.isActive}));return new l(i(i({},t),{selectedVariantValues:(e||t.variants[0]).variantValues}))})),this.data=this.data.concat(r||[]),this._count=(null===(n=t.data)||void 0===n?void 0:n.count)||this._count,this._page=this.page+1,this.setIsFilteredForProducts(),[3,5]):[2];case 3:return s=e.sent(),console.log(s),[3,5];case 4:return this._isLoading=!1,[7];case 5:return[2]}}))}))},this.getPage=function(r){return t(c,void 0,void 0,(function(){var t,s,o,a,n,d;return e(this,(function(e){switch(e.label){case 0:if(this._isLoading||this.isStatic||this.isDiscounted||this.isRecommended||this.isLastViewed)return[2];this._isLoading=!0,e.label=1;case 1:return e.trys.push([1,3,4,5]),[4,this.searchProducts(r,this.limit)];case 2:return(t=e.sent())?(s=null===(n=null===(a=t.data)||void 0===a?void 0:a.data)||void 0===n?void 0:n.map((function(t){var e=t.variants.find((function(t){return t.isActive}));return new l(i(i({},t),{selectedVariantValues:(e||t.variants[0]).variantValues}))})),this.data=s||[],this._count=(null===(d=t.data)||void 0===d?void 0:d.count)||0,this._page=r,this._minPage=r,this.setIsFilteredForProducts(),[3,5]):[2];case 3:return o=e.sent(),console.log(o),[3,5];case 4:return this._isLoading=!1,[7];case 5:return[2]}}))}))},this.setVisibleInfiniteScrollPage=function(t){var e;c._infiniteScrollPage!==t&&(c._infiniteScrollPage=t,g.getIsEditor()||null===(e=c.router)||void 0===e||e.replace("".concat(location.pathname).concat(c.filterQueryParams?"?"+c.filterQueryParams:""),void 0,{shallow:!0}))},this.searchDebouncer=s((function(){c.applyFilters()}),500),this.searchAnalyticsDebouncer=s((function(){v.search(c._searchKeyword)}),1e3);var p=o,h=o;if(this.data=o.data?o.data.map((function(t){return new l(t)})):[],this._type=p.type||h._type||p.productListPropValue.productListType||h._productListPropValue.productListType||y.ALL,this._pageType=o.pageType,this._sort=o.sort||o.productListPropValue.initialSort||I.LAST_ADDED,this._limit=o.limit||p.productListPropValue.initialLimit||h._productListPropValue.initialLimit||20,this._page=o.page||1,this._minPage=o.minPage||null,this._count=o.count||0,this._searchKeyword=o.searchKeyword||"",this._productListPropValue=p.productListPropValue||h._productListPropValue,this._filterBrandId=p.filterBrandId||h._filterBrandId||null,this._filterCategoryId=p.filterCategoryId||h._filterCategoryId||null,this._relatedProductData=p.relatedProductData||h._relatedProductData||null,this._recommendFor=p.recommendFor||h._recommendFor,this.filters=o.filters?o.filters.map((function(t){return new u(t,c)})):null,this._filterCategories=o.filterCategories?o.filterCategories.map((function(t){return new d(t)})):null,this.pageSpecificData=p.pageSpecificData||h.pageSpecificData||null,this.router=n,r(this,{router:!1}),this.setPageSpecificSort(),this.setIsFilteredForProducts(),this.isBrowser())if(this.restoreInfiniteScrollPage(),location.search&&(this.isFilterable||this._type===y.SEARCH)){var f=this.getQueryParams();this.getInitial(f,this._page>1)}else this._page>1?this.getInitial(void 0,!0):this.isLastViewed?this.getInitial():this.handleListingEvent()}return Object.defineProperty(S.prototype,"sort",{get:function(){return this._sort},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"limit",{get:function(){return this._limit},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"pageType",{get:function(){return this._pageType},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"page",{get:function(){return this._page},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"minPage",{get:function(){return this._minPage||1},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"count",{get:function(){return this._count},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"pageCount",{get:function(){return Math.ceil(this._count/this._limit)},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"searchKeyword",{get:function(){return this._searchKeyword},set:function(t){t!==this._searchKeyword&&(this._searchKeyword=t,this.searchDebouncer(),this.searchAnalyticsDebouncer())},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"isInitialized",{get:function(){return this._initialized},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"isFilterable",{get:function(){return this._type===y.ALL||this._type===y.CATEGORY},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"isFiltered",{get:function(){var t,e;return(null===(t=this.filters)||void 0===t?void 0:t.some((function(t){return!!t.valueList.length})))||!!this._searchKeyword||this._pageType!==a.CATEGORY&&(!!this._filterCategoryId||(null===(e=this._filterCategories)||void 0===e?void 0:e.some((function(t){return t.isSelected}))))},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"isStatic",{get:function(){return this._type===y.STATIC},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"isDiscounted",{get:function(){return this._type===y.DISCOUNTED},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"isRecommended",{get:function(){return this._type===y.RECOMMENDED},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"isLastViewed",{get:function(){return this._type===y.LAST_VIEWED},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"isRelatedProducts",{get:function(){return this._type===y.RELATED_PRODUCTS},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"isSearch",{get:function(){return this._type===y.SEARCH},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"hasPrev",{get:function(){return!(this.isStatic||this.isDiscounted||this.isRecommended||!this._minPage)&&this._minPage>1},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"hasNext",{get:function(){return!(this.isStatic||this.isDiscounted||this.isRecommended)&&this.page*this.limit<this.count},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"isLoading",{get:function(){return this._isLoading},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"filterQueryParams",{get:function(){var t,e,i,r,s=this,o={};if(null===(t=this.filters)||void 0===t||t.forEach((function(t){t.keyList.length&&(o[t.key]=t.keyList)})),this._searchKeyword&&(o.s=this._searchKeyword),this._infiniteScrollPage&&(o.page=this._infiniteScrollPage),this._pageType!==a.CATEGORY){var n=null===(e=this.filterCategories)||void 0===e?void 0:e.filter((function(t){return t.isSelected}));if(!!(null==n?void 0:n.length))o.c=null==n?void 0:n.map((function(t){return t.slug}));else if(this._filterCategoryId){var d=null===(r=null===(i=this.filterCategories)||void 0===i?void 0:i.find((function(t){return t.id===s._filterCategoryId})))||void 0===r?void 0:r.slug;d&&(o.c=d)}}return h.stringify(o,{arrayFormat:"comma"})},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"filterCategories",{get:function(){var t;return null===(t=this._filterCategories)||void 0===t?void 0:t.filter((function(t){return 0!==t.resultCount}))},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"hasAppliedfilter",{get:function(){var t;return!!this._searchKeyword||(null===(t=this.filters)||void 0===t?void 0:t.some((function(t){return!!t.valueList.length})))},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"isFeaturedSortEnabled",{get:function(){var t;return(null===(t=this.pageSpecificData)||void 0===t?void 0:t.orderType)===o.MANUALLY&&[y.ALL,y.CATEGORY].includes(this._type)},enumerable:!1,configurable:!0}),S.prototype.setIsFilteredForProducts=function(){var t=this;this.data.forEach((function(e){return e.isFiltered=t.isFiltered||!1}))},S.prototype.setPageSpecificSort=function(){var t;if((null===(t=this.pageSpecificData)||void 0===t?void 0:t.orderType)&&[y.ALL].includes(this._type))switch(this.pageSpecificData.orderType){case o.HIGHEST_DISCOUNT_RATIO:this._sort=I.DECRASING_DISCOUNT;break;case o.LOWEST_DISCOUNT_RATIO:this._sort=I.INCREASING_DISCOUNT;break;case o.HIGHEST_PRICE:this._sort=I.DECREASING_PRICE;break;case o.LOWEST_PRICE:this._sort=I.INCREASING_PRICE;break;case o.NEWEST:this._sort=I.LAST_ADDED;break;case o.OLDEST:this._sort=I.FIRST_ADDED;break;case o.MANUALLY:this._sort=I.FEATURED}},S.prototype.getSortParams=function(){var t,e;switch(this._sort){case I.INCREASING_PRICE:t=f.ASC,e=m.PRICE;break;case I.DECREASING_PRICE:t=f.DESC,e=m.PRICE;break;case I.FIRST_ADDED:t=f.ASC,e=m.CREATED_AT;break;case I.LAST_ADDED:t=f.DESC,e=m.CREATED_AT;break;case I.INCREASING_DISCOUNT:t=f.ASC,e=m.DISCOUNT_RATIO;break;case I.DECRASING_DISCOUNT:t=f.DESC,e=m.DISCOUNT_RATIO;break;case I.FEATURED:if(this.isSearch)return;t=f.ASC,e=m.MANUAL_SORT;break;case I.DEFAULT:t=void 0,e=void 0}if(t&&e)return{direction:t,type:e}},S.prototype.searchProducts=function(i,r,s){var o,d,u;return t(this,void 0,void 0,(function(){var t,l,h,f;return e(this,(function(e){switch(e.label){case 0:return t=[],l=[],null===(o=this.filters)||void 0===o||o.forEach((function(e){e.valueList.length&&t.push(new c({id:e.id,type:e.type,displayType:e.displayType,valueList:e.valueList})),e.isFacetFilter&&l.push({id:e.id,type:e.type,displayType:e.displayType})})),h=null===(d=this._filterCategories)||void 0===d?void 0:d.filter((function(t){return t.isSelected})).map((function(t){return t.id})),f=this.getSortParams(),this.isRelatedProducts&&this._relatedProductData?[4,p.getSuggestedProducts({priceListId:g.getPriceListId(),salesChannelId:g.getSalesChannelId(),productId:this._relatedProductData.productId,brandIds:this._relatedProductData.brandIds,categoryIds:this._relatedProductData.categoryIds,locale:g.getCurrentLocale()})]:[3,2];case 1:case 3:return[2,e.sent()];case 2:return[4,p.searchProducts({input:{page:i,perPage:r,productIdList:this.isStatic?null===(u=this._productListPropValue.productIds)||void 0===u?void 0:u.map((function(t){return t.productId})):s,filterList:t,facetList:l,brandId:this._pageType===a.BRAND&&this._type!==y.SEARCH?this._filterBrandId:void 0,categoryIdList:h&&h.length?h:this._filterCategoryId?[this._filterCategoryId]:void 0,priceListId:g.getPriceListId(),salesChannelId:g.getSalesChannelId(),query:this._searchKeyword,order:this._type===y.SEARCH?[]:f?[f]:[],showStockOption:g.getStockPreference()||n.SHOW_ALL}})]}}))}))},S.prototype.getFilters=function(){var i,r,s;return t(this,void 0,void 0,(function(){var t,o,n=this;return e(this,(function(e){switch(e.label){case 0:return[4,p.getProductFilterData({categoryId:this._filterCategoryId?this._filterCategoryId:void 0,locale:g.getCurrentLocale()})];case 1:return t=e.sent(),this.filters=null===(i=null==t?void 0:t.data)||void 0===i?void 0:i.filters.map((function(t){return new u(t,n)})),this._filterCategories=null===(r=null==t?void 0:t.data)||void 0===r?void 0:r.categories,this.pageType!==a.CATEGORY&&this._filterCategoryId&&(o=null===(s=this._filterCategories)||void 0===s?void 0:s.find((function(t){return t.id===n._filterCategoryId})))&&(o.isSelected=!0),this.filters&&this.filters.sort((function(t,e){return t.order>e.order?1:-1})),[2]}}))}))},S.prototype.applyQueryParamFilters=function(t){var e,i=this;try{null==t||t.forEach((function(t,e){var r,s=null===(r=i.filters)||void 0===r?void 0:r.find((function(t){return t.key===e}));s&&s.applyQueryParam(t)}));var r=null==t?void 0:t.get("s");if(r&&(this._searchKeyword=r),this._pageType!==a.CATEGORY){var s=null==t?void 0:t.get("c"),o=null==s?void 0:s.split(",");o&&o.length&&(null===(e=this.filterCategories)||void 0===e||e.forEach((function(t){t.isSelected=o.some((function(e){return e===t.slug}))})))}}catch(t){console.log(t)}},S.prototype.applyFacets=function(t){var e,i;null===(e=this.filters)||void 0===e||e.forEach((function(e){var i,r,s,o=null==t?void 0:t.find((function(t){return t.id===e.id}));o?null===(i=e.values)||void 0===i||i.forEach((function(t){var i=o.values.find((function(e){return e.id===t.id}));i?t.resultCount=i.count:e.isCustomValueFilter?t.resultCount=null:t.resultCount=0})):e.isCustomValueFilter?null===(r=e.values)||void 0===r||r.forEach((function(t){return t.resultCount=null})):null===(s=e.values)||void 0===s||s.forEach((function(t){return t.resultCount=0}))}));var r=null==t?void 0:t.find((function(t){return"category"===t.id}));r&&(null===(i=this._filterCategories)||void 0===i||i.forEach((function(t){var e=r.values.find((function(e){return e.id===t.id}));t.resultCount=e?e.count:0})))},S.prototype.clearFilters=function(){var t,e;null===(t=this.filters)||void 0===t||t.forEach((function(t){return t.clear()})),this._searchKeyword="",this._pageType!==a.CATEGORY&&(this._filterCategoryId=void 0),null===(e=this._filterCategories)||void 0===e||e.forEach((function(t){return t.isSelected=!1})),this.applyFilters()},S.prototype.setSortType=function(i){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return this._sort=i,[4,this.getInitial()];case 1:return t.sent(),[2]}}))}))},S.prototype.onFilterCategoryClick=function(i,r){var s,o;return void 0===r&&(r=!1),t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return r?(null===(s=this._filterCategories)||void 0===s||s.forEach((function(t){t.id===i.id&&(t.isSelected=!t.isSelected)})),[4,this.applyFilters()]):[3,2];case 1:return t.sent(),[3,3];case 2:g.getIsEditor()||null===(o=_.getInstance().router)||void 0===o||o.push(i.href+(this.filterQueryParams?"?"+this.filterQueryParams:"")),t.label=3;case 3:return[2]}}))}))},S.prototype.toJSON=function(){return{data:this.data,type:this._type,pageType:this._pageType,sort:this._sort,limit:this._limit,page:this._page,count:this._count,searchKeyword:this._searchKeyword,initialized:this._initialized,minPage:this._minPage,filterBrandId:this._filterBrandId,filterCategoryId:this._filterCategoryId,filterCategories:this._filterCategories,filters:this.filters,recommendFor:this._recommendFor,productListPropValue:this._productListPropValue,pageSpecificData:this.pageSpecificData}},S.prototype.restoreInfiniteScrollPage=function(){var t=this.getQueryParams(),e=null==t?void 0:t.get("page");if(e){var i=parseInt(e);isNaN(i)||(this._page=i,this._infiniteScrollPage=i)}},S.prototype.getQueryParams=function(){if(this.isBrowser())return new URLSearchParams(location.search)},S.prototype.isBrowser=function(){return"undefined"!=typeof window},S.prototype.waitForCustomerStoreInit=function(){return new Promise((function(t){var e=setInterval((function(){_.getInstance().customerStore.initialized&&(clearInterval(e),t(null))}),1e3)}))},S.prototype.handleListingEvent=function(){this.searchKeyword&&this.data.length?v.viewSearchResults(this._searchKeyword,this.data):this.data.length&&this._type===y.ALL&&v.viewListing(this.data)},S}();!function(t){t.ALL="ALL",t.STATIC="STATIC",t.DISCOUNTED="DISCOUNTED",t.RECOMMENDED="RECOMMENDED",t.CATEGORY="CATEGORY",t.SEARCH="SEARCH",t.LAST_VIEWED="LAST_VIEWED",t.RELATED_PRODUCTS="RELATED_PRODUCTS"}(y||(y={})),function(t){t.INCREASING_PRICE="INCREASING_PRICE",t.DECREASING_PRICE="DECREASING_PRICE",t.LAST_ADDED="LAST_ADDED",t.FIRST_ADDED="FIRST_ADDED",t.INCREASING_DISCOUNT="INCREASING_DISCOUNT",t.DECRASING_DISCOUNT="DECRASING_DISCOUNT",t.FEATURED="FEATURED",t.DEFAULT="DEFAULT"}(I||(I={})),function(t){t.CATEGORY="CATEGORY",t.BRAND="BRAND"}(S||(S={}));export{C as IkasProductList,I as IkasProductListSortType,y as IkasProductListType,S as IkasRelatedProductsType};
@@ -1,4 +1,4 @@
1
- import { APIResponse, GetOrderLineFileQueryParams, GetProductCampaignsQueryParams, GetProductFilterDataQueryParams, GetRelatedProductsQueryParams, ListProductAttributeQueryParams, ListProductBackInStockRemindQueryParams, ListProductOptionSetQueryParams, SaveProductBackInStockRemindQueryParams, SearchProductsQueryParams } from "@ikas/storefront-api";
1
+ import { APIResponse, GetOrderLineFileQueryParams, GetProductCampaignsQueryParams, GetProductFilterDataQueryParams, GetRelatedProductsQueryParams, GetSuggestedProductsQueryParams, ListProductAttributeQueryParams, ListProductBackInStockRemindQueryParams, ListProductOptionSetQueryParams, SaveProductBackInStockRemindQueryParams, SearchProductsQueryParams } from "@ikas/storefront-api";
2
2
  import { IkasProduct } from "../../models/data/product";
3
3
  import { IkasProductAttribute } from "../../models/data/product/attribute";
4
4
  import { IkasProductCampaign } from "../../models/data/product/campaign";
@@ -30,6 +30,14 @@ export default class ProductStore {
30
30
  page?: number | undefined;
31
31
  totalCount?: any;
32
32
  }>>;
33
+ static getSuggestedProducts(params: GetSuggestedProductsQueryParams): Promise<APIResponse<{
34
+ data: IkasProduct[] | undefined;
35
+ count?: number | undefined;
36
+ facets?: null | undefined;
37
+ limit?: number | undefined;
38
+ page?: number | undefined;
39
+ totalCount?: number | undefined;
40
+ }>>;
33
41
  static listProductAttribute(params: ListProductAttributeQueryParams): Promise<APIResponse<IkasProductAttribute[]>>;
34
42
  static getProductCampaigns(params: GetProductCampaignsQueryParams): Promise<APIResponse<IkasProductCampaign[]>>;
35
43
  static getOrderLineFile(params: GetOrderLineFileQueryParams): Promise<APIResponse<undefined> | APIResponse<string>>;
@@ -1 +1 @@
1
- import{__awaiter as t,__generator as r,__assign as n}from'./../../ext/tslib/tslib.es6.js';import{listProductBackInStockRemind as e,saveProductBackInStockRemind as i,APIResponse as o,searchProducts as a,getProductFilterData as u,getRelatedProducts as s,listProductAttribute as c,getProductCampaigns as d,getOrderLineFile as l,listProductOptionSet as f}from"@ikas/storefront-api";import{IkasProduct as v}from"../../models/data/product/index.js";import{IkasProductAttribute as m}from"../../models/data/product/attribute/index.js";import{IkasProductCampaign as h}from"../../models/data/product/campaign/index.js";import{IkasProductFilter as p}from"../../models/data/product/filter/index.js";import{IkasProductOptionSet as w}from"../../models/data/product/option-set/index.js";import{IkasFilterCategory as g}from"../../models/data/filter-category/index.js";import{IkasStorefrontConfig as b}from"@ikas/storefront-config";var P=function(){function P(){}return P.listProductBackInStockRemind=function(n){return t(this,void 0,void 0,(function(){return r(this,(function(t){switch(t.label){case 0:return[4,e(n)];case 1:return[2,t.sent()]}}))}))},P.saveProductBackInStockRemind=function(n){return t(this,void 0,void 0,(function(){return r(this,(function(t){switch(t.label){case 0:return[4,i(n)];case 1:return[2,t.sent()]}}))}))},P.searchProducts=function(e){var i,u;return t(this,void 0,void 0,(function(){var t;return r(this,(function(r){switch(r.label){case 0:return[4,a(e)];case 1:return t=r.sent(),[2,new o(n(n({locale:b.getCurrentLocale()},t.data),{data:null===(u=null===(i=t.data)||void 0===i?void 0:i.data)||void 0===u?void 0:u.map((function(t){return new v(t)}))}))]}}))}))},P.getProductFilterData=function(n){var e;return t(this,void 0,void 0,(function(){var t;return r(this,(function(r){switch(r.label){case 0:return[4,u(n)];case 1:return t=r.sent(),[2,new o(t.data?{filters:t.data.filters.map((function(t){return new p(t)})),categories:null===(e=t.data.categories)||void 0===e?void 0:e.map((function(t){return new g(t)}))}:null,t.graphQLErrors)]}}))}))},P.getRelatedProducts=function(e){var i,a;return t(this,void 0,void 0,(function(){var t;return r(this,(function(r){switch(r.label){case 0:return[4,s(e)];case 1:return t=r.sent(),[2,new o(n(n({},t.data),{data:null===(a=null===(i=t.data)||void 0===i?void 0:i.data)||void 0===a?void 0:a.map((function(t){return new v(t)}))}),t.graphQLErrors)]}}))}))},P.listProductAttribute=function(n){var e;return t(this,void 0,void 0,(function(){var t;return r(this,(function(r){switch(r.label){case 0:return[4,c(n)];case 1:return t=r.sent(),[2,new o(null===(e=t.data)||void 0===e?void 0:e.map((function(t){return new m(t)})),t.graphQLErrors)]}}))}))},P.getProductCampaigns=function(n){var e;return t(this,void 0,void 0,(function(){var t;return r(this,(function(r){switch(r.label){case 0:return[4,d(n)];case 1:return t=r.sent(),[2,new o(null===(e=t.data)||void 0===e?void 0:e.map((function(t){return new h(t)})),t.graphQLErrors)]}}))}))},P.getOrderLineFile=function(n){return t(this,void 0,void 0,(function(){return r(this,(function(t){switch(t.label){case 0:return[4,l(n)];case 1:return[2,t.sent()]}}))}))},P.listProductOptionSet=function(n){var e;return t(this,void 0,void 0,(function(){var t;return r(this,(function(r){switch(r.label){case 0:return[4,f(n)];case 1:return t=r.sent(),[2,new o(null===(e=t.data)||void 0===e?void 0:e.map((function(t){return new w(t)})),t.graphQLErrors)]}}))}))},P}();export{P as default};
1
+ import{__awaiter as t,__generator as r,__assign as n}from'./../../ext/tslib/tslib.es6.js';import{listProductBackInStockRemind as e,saveProductBackInStockRemind as i,APIResponse as o,searchProducts as a,getProductFilterData as u,getRelatedProducts as s,getSuggestedProducts as d,listProductAttribute as c,getProductCampaigns as l,getOrderLineFile as f,listProductOptionSet as v}from"@ikas/storefront-api";import{IkasProduct as h}from"../../models/data/product/index.js";import{IkasProductAttribute as m}from"../../models/data/product/attribute/index.js";import{IkasProductCampaign as p}from"../../models/data/product/campaign/index.js";import{IkasProductFilter as w}from"../../models/data/product/filter/index.js";import{IkasProductOptionSet as g}from"../../models/data/product/option-set/index.js";import{IkasFilterCategory as b}from"../../models/data/filter-category/index.js";import{IkasStorefrontConfig as P}from"@ikas/storefront-config";var L=function(){function L(){}return L.listProductBackInStockRemind=function(n){return t(this,void 0,void 0,(function(){return r(this,(function(t){switch(t.label){case 0:return[4,e(n)];case 1:return[2,t.sent()]}}))}))},L.saveProductBackInStockRemind=function(n){return t(this,void 0,void 0,(function(){return r(this,(function(t){switch(t.label){case 0:return[4,i(n)];case 1:return[2,t.sent()]}}))}))},L.searchProducts=function(e){var i,u;return t(this,void 0,void 0,(function(){var t;return r(this,(function(r){switch(r.label){case 0:return[4,a(e)];case 1:return t=r.sent(),[2,new o(n(n({locale:P.getCurrentLocale()},t.data),{data:null===(u=null===(i=t.data)||void 0===i?void 0:i.data)||void 0===u?void 0:u.map((function(t){return new h(t)}))}))]}}))}))},L.getProductFilterData=function(n){var e;return t(this,void 0,void 0,(function(){var t;return r(this,(function(r){switch(r.label){case 0:return[4,u(n)];case 1:return t=r.sent(),[2,new o(t.data?{filters:t.data.filters.map((function(t){return new w(t)})),categories:null===(e=t.data.categories)||void 0===e?void 0:e.map((function(t){return new b(t)}))}:null,t.graphQLErrors)]}}))}))},L.getRelatedProducts=function(e){var i,a;return t(this,void 0,void 0,(function(){var t;return r(this,(function(r){switch(r.label){case 0:return[4,s(e)];case 1:return t=r.sent(),[2,new o(n(n({},t.data),{data:null===(a=null===(i=t.data)||void 0===i?void 0:i.data)||void 0===a?void 0:a.map((function(t){return new h(t)}))}),t.graphQLErrors)]}}))}))},L.getSuggestedProducts=function(e){var i,a;return t(this,void 0,void 0,(function(){var t;return r(this,(function(r){switch(r.label){case 0:return[4,d(e)];case 1:return t=r.sent(),[2,new o(n(n({},t.data),{data:null===(a=null===(i=t.data)||void 0===i?void 0:i.data)||void 0===a?void 0:a.map((function(t){return new h(t)}))}),t.graphQLErrors)]}}))}))},L.listProductAttribute=function(n){var e;return t(this,void 0,void 0,(function(){var t;return r(this,(function(r){switch(r.label){case 0:return[4,c(n)];case 1:return t=r.sent(),[2,new o(null===(e=t.data)||void 0===e?void 0:e.map((function(t){return new m(t)})),t.graphQLErrors)]}}))}))},L.getProductCampaigns=function(n){var e;return t(this,void 0,void 0,(function(){var t;return r(this,(function(r){switch(r.label){case 0:return[4,l(n)];case 1:return t=r.sent(),[2,new o(null===(e=t.data)||void 0===e?void 0:e.map((function(t){return new p(t)})),t.graphQLErrors)]}}))}))},L.getOrderLineFile=function(n){return t(this,void 0,void 0,(function(){return r(this,(function(t){switch(t.label){case 0:return[4,f(n)];case 1:return[2,t.sent()]}}))}))},L.listProductOptionSet=function(n){var e;return t(this,void 0,void 0,(function(){var t;return r(this,(function(r){switch(r.label){case 0:return[4,v(n)];case 1:return t=r.sent(),[2,new o(null===(e=t.data)||void 0===e?void 0:e.map((function(t){return new g(t)})),t.graphQLErrors)]}}))}))},L}();export{L as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ikas/storefront",
3
- "version": "4.2.0-beta.1",
3
+ "version": "4.2.0-beta.3",
4
4
  "description": "Storefront functionality for ikas storefront themes.",
5
5
  "author": "ikas",
6
6
  "license": "ISC",
@@ -18,11 +18,11 @@
18
18
  },
19
19
  "dependencies": {},
20
20
  "devDependencies": {
21
- "@ikas/storefront-api": "^4.2.0-beta.1",
22
- "@ikas/storefront-config": "^4.2.0-beta.1",
23
- "@ikas/storefront-model-functions": "^4.2.0-beta.1",
24
- "@ikas/storefront-models": "^4.2.0-beta.1",
25
- "@ikas/storefront-providers": "^4.2.0-beta.1",
21
+ "@ikas/storefront-api": "^4.2.0-beta.3",
22
+ "@ikas/storefront-config": "^4.2.0-beta.3",
23
+ "@ikas/storefront-model-functions": "^4.2.0-beta.3",
24
+ "@ikas/storefront-models": "^4.2.0-beta.3",
25
+ "@ikas/storefront-providers": "^4.2.0-beta.3",
26
26
  "@rollup/plugin-commonjs": "^22.0.0",
27
27
  "@rollup/plugin-json": "^4.1.0",
28
28
  "@rollup/plugin-node-resolve": "^13.3.0",
@@ -52,11 +52,11 @@
52
52
  "libphonenumber-js": "^1.10.6"
53
53
  },
54
54
  "peerDependencies": {
55
- "@ikas/storefront-api": "^4.2.0-beta.1",
56
- "@ikas/storefront-config": "^4.2.0-beta.1",
57
- "@ikas/storefront-model-functions": "^4.2.0-beta.1",
58
- "@ikas/storefront-models": "^4.2.0-beta.1",
59
- "@ikas/storefront-providers": "^4.2.0-beta.1",
55
+ "@ikas/storefront-api": "^4.2.0-beta.3",
56
+ "@ikas/storefront-config": "^4.2.0-beta.3",
57
+ "@ikas/storefront-model-functions": "^4.2.0-beta.3",
58
+ "@ikas/storefront-models": "^4.2.0-beta.3",
59
+ "@ikas/storefront-providers": "^4.2.0-beta.3",
60
60
  "mobx": "^6.1.3",
61
61
  "mobx-react-lite": "^3.1.5",
62
62
  "next": "12.2.0",