@ikas/storefront 4.0.21 → 4.0.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- import{__spreadArray as 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)return"".concat(j(n.unitPrice,n.currency||"",n.currencySymbol||"")," / ").concat(null===(i=null===(e=x.baseUnit)||void 0===e?void 0:e.unit)||void 0===i?void 0:i.name)},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],[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 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)return"".concat(j(n.unitPrice,n.currency||"",n.currencySymbol||"")," / ").concat(null===(i=null===(e=x.baseUnit)||void 0===e?void 0:e.unit)||void 0===i?void 0:i.name)},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 +1 @@
1
- import{__awaiter as t,__generator as i,__assign as n}from'./../../../../ext/tslib/tslib.es6.js';import{makeAutoObservable as o}from"mobx";import{IkasProductOption as e}from"./option/index.js";import{IkasProductOptionSetFunctions as r}from"@ikas/storefront-model-functions";var s=function(t){this.id=t.id||"",this.value=t.value||null},u=function(t){var i;this.id=t.id||"",this.name=t.name||null,this.optionalText=t.optionalText||null,this.values=(null===(i=t.values)||void 0===i?void 0:i.map((function(t){return new s(t)})))||[]},l=function(t){var i;this.locale=t.locale||"",this.options=(null===(i=t.options)||void 0===i?void 0:i.map((function(t){return new u(t)})))||[]},a=function(){function s(r){var s,u,a=this;this.initOptionValues=function(){return t(a,void 0,void 0,(function(){return i(this,(function(t){return this.options.forEach((function(t){return t.initValues()})),[2]}))}))},this.id=r.id||"",this.name=r.name||"",this.options=(null===(s=r.options)||void 0===s?void 0:s.map((function(t){return new e(n(n({},t),{productOptionSetId:a.id}))})))||[],this.translations=r.translations?null===(u=r.translations)||void 0===u?void 0:u.map((function(t){return new l(t)})):null,this.initOptionValues(),o(this)}return Object.defineProperty(s.prototype,"displayedOptions",{get:function(){return r.getDisplayedOptions(this)},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"hasValidValues",{get:function(){return this.displayedOptions.every((function(t){return t.hasValidValues}))},enumerable:!1,configurable:!0}),s}();export{s as IkasProductOptionSelectValueTranslations,a as IkasProductOptionSet,l as IkasProductOptionSetTranslations,u as IkasProductOptionTranslations};
1
+ import{__awaiter as t,__generator as i,__assign as n}from'./../../../../ext/tslib/tslib.es6.js';import{makeAutoObservable as o}from"mobx";import{IkasProductOption as e}from"./option/index.js";import{setChildOptions as r}from"@ikas/storefront-models";import{IkasProductOptionSetFunctions as s}from"@ikas/storefront-model-functions";var u=function(t){this.id=t.id||"",this.value=t.value||null},l=function(t){var i;this.id=t.id||"",this.name=t.name||null,this.optionalText=t.optionalText||null,this.values=(null===(i=t.values)||void 0===i?void 0:i.map((function(t){return new u(t)})))||[]},a=function(t){var i;this.locale=t.locale||"",this.options=(null===(i=t.options)||void 0===i?void 0:i.map((function(t){return new l(t)})))||[]},p=function(){function u(s){var u,l,p=this;this.initOptionValues=function(){return t(p,void 0,void 0,(function(){return i(this,(function(t){return this.options.forEach((function(t){return t.initValues()})),[2]}))}))},this.id=s.id||"",this.name=s.name||"",this.options=(null===(u=s.options)||void 0===u?void 0:u.map((function(t){return new e(n(n({},t),{productOptionSetId:p.id}))})))||[],this.translations=s.translations?null===(l=s.translations)||void 0===l?void 0:l.map((function(t){return new a(t)})):null,this.options.forEach((function(t){return r(p)})),this.initOptionValues(),o(this)}return Object.defineProperty(u.prototype,"displayedOptions",{get:function(){return s.getDisplayedOptions(this)},enumerable:!1,configurable:!0}),Object.defineProperty(u.prototype,"hasValidValues",{get:function(){return this.displayedOptions.every((function(t){return t.hasValidValues}))},enumerable:!1,configurable:!0}),u}();export{u as IkasProductOptionSelectValueTranslations,p as IkasProductOptionSet,a as IkasProductOptionSetTranslations,l as IkasProductOptionTranslations};
@@ -57,16 +57,14 @@ export declare class IkasProductOption implements IProductOption {
57
57
  optionalText: string | null;
58
58
  requiredOptionId: string | null;
59
59
  requiredOptionValueIds: string[] | null;
60
- private _values;
61
- private _childOptions;
60
+ childOptions: IkasProductOption[];
61
+ private pValues;
62
62
  constructor(data: Partial<IProductOption>);
63
63
  get displayedChildOptions(): IkasProductOption[];
64
64
  productOptionFileUpload: (files: File[]) => Promise<string[]>;
65
65
  get hasValidValues(): boolean;
66
66
  get values(): string[];
67
67
  set values(values: string[]);
68
- get childOptions(): IkasProductOption[];
69
- set childOptions(options: IkasProductOption[]);
70
68
  initValues: () => void;
71
69
  }
72
70
  export { IkasProductOptionSelectType, IkasProductOptionType };
@@ -1 +1 @@
1
- import{__awaiter as t,__generator as i}from'./../../../../../ext/tslib/tslib.es6.js';import{IkasProductOptionSelectType as e,IkasProductOptionType as n}from"@ikas/storefront-models";export{IkasProductOptionSelectType,IkasProductOptionType}from"@ikas/storefront-models";import{makeAutoObservable as l}from"mobx";import{IkasImage as s}from"../../../image/index.js";import o from"lodash/sortBy";import{IkasProductOptionFunctions as a}from"@ikas/storefront-model-functions";import{uploadFile as r,getProductOptionFileUrl as u}from"@ikas/storefront-api";var d=function(t){this.currencyCode=t.currencyCode,this.price=t.price},h=function(t){void 0===t&&(t={}),this.id=t.id||"",this.order=t.order||0,this.value=t.value||"",this.price=t.price||null,this.otherPrices=t.otherPrices||null,this.thumbnailImageId=t.thumbnailImageId||null,this.colorCode=t.colorCode||null,this.thumbnailImage=t.thumbnailImage?new s(t.thumbnailImage):t.thumbnailImageId?new s({id:t.thumbnailImageId,isVideo:!1}):null},c=function(t){var i;void 0===t&&(t={}),this.type=t.type||e.BOX,this.minSelect=null!==t.minSelect&&void 0!==t.minSelect?t.minSelect:null,this.maxSelect=null!==t.maxSelect&&void 0!==t.maxSelect?t.maxSelect:null,this.values=o((null===(i=t.values)||void 0===i?void 0:i.map((function(t){return new h(t)})))||[],"order")},m=function(t){this.min=t.min||null,this.max=t.max||null,this.minRelativeNextDate=void 0!==t.minRelativeNextDate?t.minRelativeNextDate:null,this.maxRelativeNextDate=void 0!==t.maxRelativeNextDate?t.maxRelativeNextDate:null},p=function(t){void 0===t&&(t={}),this.min=null!==t.min&&void 0!==t.min?t.min:null,this.max=null!==t.max&&void 0!==t.max?t.max:null},f=function(t){this.allowedExtensions=t.allowedExtensions||null,this.minQuantity=null!==t.minQuantity&&void 0!==t.minQuantity?t.minQuantity:null,this.maxQuantity=null!==t.maxQuantity&&void 0!==t.maxQuantity?t.maxQuantity:null},v=function(){function e(s){var o=this;this._values=[],this._childOptions=[],this.productOptionFileUpload=function(e){return t(o,void 0,void 0,(function(){var t,n,l,s,o,a=this;return i(this,(function(i){switch(i.label){case 0:return 0===e.length||this.fileSettings&&this.fileSettings.maxQuantity&&this.fileSettings.maxQuantity<e.length?[2,[]]:[4,Promise.all(e.map((function(t){return u({fileName:t.name,productOptionSetId:a.productOptionSetId,productOptionId:a.id},t)})))];case 1:t=i.sent().filter((function(t){return t.data})),n=[],l=0,s=t,i.label=2;case 2:return l<s.length?(o=s[l],[4,r(o.data,o.data.file)]):[3,5];case 3:i.sent()&&n.push(o.data.optionUrl),i.label=4;case 4:return l++,[3,2];case 5:return[2,n]}}))}))},this.initValues=function(){o.isOptional||(o.values=[],o.childOptions&&o.childOptions.forEach((function(t){return t.initValues()})))},this.id=s.id||"",this.productOptionSetId=s.productOptionSetId||"",this.name=s.name||"",this.order=s.order||0,this.type=s.type||n.CHOICE,this.selectSettings=s.selectSettings?new c(s.selectSettings||{}):null,this.textSettings=s.textSettings?new p(s.textSettings||{}):null,this.fileSettings=s.fileSettings?new f(s.fileSettings||{}):null,this.dateSettings=s.dateSettings?new m(s.dateSettings||{}):null,this.price=s.price||null,this.otherPrices=s.otherPrices||null,this.isOptional=s.isOptional||!1,this.optionalText=s.optionalText||null,this.requiredOptionId=s.requiredOptionId||null,this.requiredOptionValueIds=s.requiredOptionValueIds||null,this.values=s.values||[],this.childOptions=s.childOptions?s.childOptions.map((function(t){return new e(t)})):[],l(this)}return Object.defineProperty(e.prototype,"displayedChildOptions",{get:function(){return a.getDisplayedChildOptions(this)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasValidValues",{get:function(){return a.hasValidValues(this)&&this.displayedChildOptions.every((function(t){return t.hasValidValues}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"values",{get:function(){return this._values},set:function(t){this._values=t,t.length||this.childOptions.forEach((function(t){return t.values=[]}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"childOptions",{get:function(){return this._childOptions},set:function(t){this._childOptions=t},enumerable:!1,configurable:!0}),e}();export{v as IkasProductOption,m as IkasProductOptionDateSettings,f as IkasProductOptionFileSettings,d as IkasProductOptionOtherPrice,c as IkasProductOptionSelectSettings,h as IkasProductOptionSelectValue,p as IkasProductOptionTextSettings};
1
+ import{__awaiter as t,__generator as i}from'./../../../../../ext/tslib/tslib.es6.js';import{IkasProductOptionSelectType as e,IkasProductOptionType as n}from"@ikas/storefront-models";export{IkasProductOptionSelectType,IkasProductOptionType}from"@ikas/storefront-models";import{makeAutoObservable as l}from"mobx";import{IkasImage as s}from"../../../image/index.js";import o from"lodash/sortBy";import{IkasProductOptionFunctions as a}from"@ikas/storefront-model-functions";import{uploadFile as r,getProductOptionFileUrl as u}from"@ikas/storefront-api";var d=function(t){this.currencyCode=t.currencyCode,this.price=t.price},h=function(t){void 0===t&&(t={}),this.id=t.id||"",this.order=t.order||0,this.value=t.value||"",this.price=t.price||null,this.otherPrices=t.otherPrices||null,this.thumbnailImageId=t.thumbnailImageId||null,this.colorCode=t.colorCode||null,this.thumbnailImage=t.thumbnailImage?new s(t.thumbnailImage):t.thumbnailImageId?new s({id:t.thumbnailImageId,isVideo:!1}):null},m=function(t){var i;void 0===t&&(t={}),this.type=t.type||e.BOX,this.minSelect=null!==t.minSelect&&void 0!==t.minSelect?t.minSelect:null,this.maxSelect=null!==t.maxSelect&&void 0!==t.maxSelect?t.maxSelect:null,this.values=o((null===(i=t.values)||void 0===i?void 0:i.map((function(t){return new h(t)})))||[],"order")},c=function(t){this.min=t.min||null,this.max=t.max||null,this.minRelativeNextDate=void 0!==t.minRelativeNextDate?t.minRelativeNextDate:null,this.maxRelativeNextDate=void 0!==t.maxRelativeNextDate?t.maxRelativeNextDate:null},p=function(t){void 0===t&&(t={}),this.min=null!==t.min&&void 0!==t.min?t.min:null,this.max=null!==t.max&&void 0!==t.max?t.max:null},f=function(t){this.allowedExtensions=t.allowedExtensions||null,this.minQuantity=null!==t.minQuantity&&void 0!==t.minQuantity?t.minQuantity:null,this.maxQuantity=null!==t.maxQuantity&&void 0!==t.maxQuantity?t.maxQuantity:null},x=function(){function e(e){var s=this;this.childOptions=[],this.pValues=[],this.productOptionFileUpload=function(e){return t(s,void 0,void 0,(function(){var t,n,l,s,o,a=this;return i(this,(function(i){switch(i.label){case 0:return 0===e.length||this.fileSettings&&this.fileSettings.maxQuantity&&this.fileSettings.maxQuantity<e.length?[2,[]]:[4,Promise.all(e.map((function(t){return u({fileName:t.name,productOptionSetId:a.productOptionSetId,productOptionId:a.id},t)})))];case 1:t=i.sent().filter((function(t){return t.data})),n=[],l=0,s=t,i.label=2;case 2:return l<s.length?(o=s[l],[4,r(o.data,o.data.file)]):[3,5];case 3:i.sent()&&n.push(o.data.optionUrl),i.label=4;case 4:return l++,[3,2];case 5:return[2,n]}}))}))},this.initValues=function(){s.isOptional||(s.values=[],s.childOptions&&s.childOptions.forEach((function(t){return t.initValues()})))},this.id=e.id||"",this.productOptionSetId=e.productOptionSetId||"",this.name=e.name||"",this.order=e.order||0,this.type=e.type||n.CHOICE,this.selectSettings=e.selectSettings?new m(e.selectSettings||{}):null,this.textSettings=e.textSettings?new p(e.textSettings||{}):null,this.fileSettings=e.fileSettings?new f(e.fileSettings||{}):null,this.dateSettings=e.dateSettings?new c(e.dateSettings||{}):null,this.price=e.price||null,this.otherPrices=e.otherPrices||null,this.isOptional=e.isOptional||!1,this.optionalText=e.optionalText||null,this.requiredOptionId=e.requiredOptionId||null,this.requiredOptionValueIds=e.requiredOptionValueIds||null,this.values=e.values||[],l(this)}return Object.defineProperty(e.prototype,"displayedChildOptions",{get:function(){return a.getDisplayedChildOptions(this)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasValidValues",{get:function(){return a.hasValidValues(this)&&this.displayedChildOptions.every((function(t){return t.hasValidValues}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"values",{get:function(){return this.pValues},set:function(t){this.pValues=t,t.length||this.childOptions.forEach((function(t){return t.values=[]}))},enumerable:!1,configurable:!0}),e}();export{x as IkasProductOption,c as IkasProductOptionDateSettings,f as IkasProductOptionFileSettings,d as IkasProductOptionOtherPrice,m as IkasProductOptionSelectSettings,h as IkasProductOptionSelectValue,p as IkasProductOptionTextSettings};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ikas/storefront",
3
- "version": "4.0.21",
3
+ "version": "4.0.22",
4
4
  "description": "Storefront functionality for ikas storefront themes.",
5
5
  "author": "ikas",
6
6
  "license": "ISC",
@@ -23,11 +23,11 @@
23
23
  "libphonenumber-js": "^1.10.6"
24
24
  },
25
25
  "devDependencies": {
26
- "@ikas/storefront-api": "^4.0.21",
27
- "@ikas/storefront-config": "^4.0.21",
28
- "@ikas/storefront-model-functions": "^4.0.21",
29
- "@ikas/storefront-models": "^4.0.21",
30
- "@ikas/storefront-providers": "^4.0.21",
26
+ "@ikas/storefront-api": "^4.0.22",
27
+ "@ikas/storefront-config": "^4.0.22",
28
+ "@ikas/storefront-model-functions": "^4.0.22",
29
+ "@ikas/storefront-models": "^4.0.22",
30
+ "@ikas/storefront-providers": "^4.0.22",
31
31
  "@rollup/plugin-commonjs": "^22.0.0",
32
32
  "@rollup/plugin-json": "^4.1.0",
33
33
  "@rollup/plugin-node-resolve": "^13.3.0",
@@ -53,11 +53,11 @@
53
53
  "query-string": "^6.13.8"
54
54
  },
55
55
  "peerDependencies": {
56
- "@ikas/storefront-api": "^4.0.21",
57
- "@ikas/storefront-config": "^4.0.21",
58
- "@ikas/storefront-model-functions": "^4.0.21",
59
- "@ikas/storefront-models": "^4.0.21",
60
- "@ikas/storefront-providers": "^4.0.21",
56
+ "@ikas/storefront-api": "^4.0.22",
57
+ "@ikas/storefront-config": "^4.0.22",
58
+ "@ikas/storefront-model-functions": "^4.0.22",
59
+ "@ikas/storefront-models": "^4.0.22",
60
+ "@ikas/storefront-providers": "^4.0.22",
61
61
  "mobx": "^6.1.3",
62
62
  "mobx-react-lite": "^3.1.5",
63
63
  "next": "12.2.0",