@ikas/storefront 5.0.14 → 5.0.15
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.
- package/build/components/popup/index.js +1 -1
- package/build/components/popup/renderer/index.js +1 -1
- package/build/components/popup/renderer/model.d.ts +5 -2
- package/build/components/popup/renderer/model.js +1 -1
- package/build/components/popup/utils/index.d.ts +5 -1
- package/build/components/popup/utils/index.js +1 -1
- package/build/ext/@ikas/popup-renderer/build/ext/libphonenumber-js/es6/AsYouType.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/ext/libphonenumber-js/es6/AsYouTypeFormatter.PatternMatcher.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/ext/libphonenumber-js/es6/AsYouTypeFormatter.PatternParser.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/ext/libphonenumber-js/es6/AsYouTypeFormatter.complete.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/ext/libphonenumber-js/es6/AsYouTypeFormatter.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/ext/libphonenumber-js/es6/AsYouTypeFormatter.util.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/ext/libphonenumber-js/es6/AsYouTypeParser.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/ext/libphonenumber-js/es6/AsYouTypeState.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/ext/libphonenumber-js/es6/ParseError.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/ext/libphonenumber-js/es6/PhoneNumber.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/ext/libphonenumber-js/es6/PhoneNumberMatcher.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/ext/libphonenumber-js/es6/constants.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/ext/libphonenumber-js/es6/findNumbers/LRUCache.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/ext/libphonenumber-js/es6/findNumbers/Leniency.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/ext/libphonenumber-js/es6/findNumbers/RegExpCache.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/ext/libphonenumber-js/es6/findNumbers/isValidCandidate.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/ext/libphonenumber-js/es6/findNumbers/isValidPreCandidate.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/ext/libphonenumber-js/es6/findNumbers/matchPhoneNumberStringAgainstPhoneNumber.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/ext/libphonenumber-js/es6/findNumbers/parsePreCandidate.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/ext/libphonenumber-js/es6/findNumbers/utf-8.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/ext/libphonenumber-js/es6/findNumbers/util.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/ext/libphonenumber-js/es6/format.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/ext/libphonenumber-js/es6/helpers/RFC3966.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/ext/libphonenumber-js/es6/helpers/applyInternationalSeparatorStyle.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/ext/libphonenumber-js/es6/helpers/checkNumberLength.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/ext/libphonenumber-js/es6/helpers/extension/createExtensionPattern.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/ext/libphonenumber-js/es6/helpers/extension/extractExtension.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/ext/libphonenumber-js/es6/helpers/extractCountryCallingCode.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/ext/libphonenumber-js/es6/helpers/extractCountryCallingCodeFromInternationalNumberWithoutPlusSign.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/ext/libphonenumber-js/es6/helpers/extractFormattedPhoneNumberFromPossibleRfc3966NumberUri.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/ext/libphonenumber-js/es6/helpers/extractNationalNumber.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/ext/libphonenumber-js/es6/helpers/extractNationalNumberFromPossiblyIncompleteNumber.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/ext/libphonenumber-js/es6/helpers/extractPhoneContext.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/ext/libphonenumber-js/es6/helpers/formatNationalNumberUsingFormat.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/ext/libphonenumber-js/es6/helpers/getCountryByCallingCode.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/ext/libphonenumber-js/es6/helpers/getCountryByNationalNumber.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/ext/libphonenumber-js/es6/helpers/getIddPrefix.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/ext/libphonenumber-js/es6/helpers/getNumberType.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/ext/libphonenumber-js/es6/helpers/getPossibleCountriesForNumber.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/ext/libphonenumber-js/es6/helpers/isObject.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/ext/libphonenumber-js/es6/helpers/isViablePhoneNumber.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/ext/libphonenumber-js/es6/helpers/matchesEntirely.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/ext/libphonenumber-js/es6/helpers/mergeArrays.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/ext/libphonenumber-js/es6/helpers/parseDigits.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/ext/libphonenumber-js/es6/helpers/stripIddPrefix.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/ext/libphonenumber-js/es6/isPossible.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/ext/libphonenumber-js/es6/isValid.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/ext/libphonenumber-js/es6/isValidPhoneNumber.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/ext/libphonenumber-js/es6/legacy/findPhoneNumbersInitialImplementation.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/ext/libphonenumber-js/es6/metadata.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/ext/libphonenumber-js/es6/normalizeArguments.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/ext/libphonenumber-js/es6/parse.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/ext/libphonenumber-js/es6/parseIncompletePhoneNumber.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/ext/libphonenumber-js/es6/parsePhoneNumber.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/ext/libphonenumber-js/es6/parsePhoneNumberWithError_.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/ext/libphonenumber-js/es6/parsePhoneNumber_.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/ext/libphonenumber-js/es6/tools/semver-compare.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/ext/libphonenumber-js/index.es6.exports/PhoneNumberSearch.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/ext/libphonenumber-js/metadata.min.json.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/ext/libphonenumber-js/min/exports/AsYouType.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/ext/libphonenumber-js/min/exports/Metadata.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/ext/libphonenumber-js/min/exports/PhoneNumberMatcher.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/ext/libphonenumber-js/min/exports/isValidPhoneNumber.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/ext/libphonenumber-js/min/exports/withMetadataArgument.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/popup-renderer/components/button-element-renderer/index.js +1 -1
- package/build/ext/@ikas/popup-renderer/build/popup-renderer/components/form-element-renderer/checkbox-item-view/index.js +1 -1
- package/build/ext/@ikas/popup-renderer/build/popup-renderer/components/form-element-renderer/index.js +1 -1
- package/build/ext/@ikas/popup-renderer/build/popup-renderer/components/form-element-renderer/input-item-view/index.js +1 -1
- package/build/ext/@ikas/popup-renderer/build/popup-renderer/components/image-column-element-renderer/index.js +1 -1
- package/build/ext/@ikas/popup-renderer/build/popup-renderer/components/image-element-renderer/index.js +1 -1
- package/build/ext/@ikas/popup-renderer/build/popup-renderer/components/index.js +1 -1
- package/build/ext/@ikas/popup-renderer/build/popup-renderer/components/product-list-renderer/index.js +1 -1
- package/build/ext/@ikas/popup-renderer/build/popup-renderer/components/social-element-renderer/index.js +1 -1
- package/build/ext/@ikas/popup-renderer/build/popup-renderer/helpers/index.js +1 -1
- package/build/ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/form/index.js +1 -1
- package/build/models/data/product/campaign/product-tiered-discount/index.d.ts +1 -1
- package/build/models/data/product/campaign/product-tiered-discount/index.js +1 -1
- package/build/models/data/product/index.d.ts +1 -35
- package/build/models/data/product/index.js +1 -1
- package/build/models/data/product/variant/index.d.ts +33 -0
- package/build/models/data/product/variant/index.js +1 -1
- package/build/models/data/storefront-popup/index.js +1 -1
- package/build/models/data/storefront-popup/storefront-popup-page-filter/index.d.ts +3 -1
- package/build/models/data/storefront-popup/storefront-popup-page-filter/index.js +1 -1
- package/package.json +12 -12
|
@@ -5,7 +5,7 @@ import { IkasProductVariantType } from "./variant-type";
|
|
|
5
5
|
import { IkasBrand } from "../brand";
|
|
6
6
|
import { IkasHTMLMetaData } from "../html-meta-data";
|
|
7
7
|
import { IkasProductTag } from "./tag";
|
|
8
|
-
import { IkasProduct as IProduct, IkasAppliedCampaignOffer, IkasProductType
|
|
8
|
+
import { IkasProduct as IProduct, IkasAppliedCampaignOffer, IkasProductType } from "@ikas/storefront-models";
|
|
9
9
|
import { IkasProductOptionSet } from "./option-set";
|
|
10
10
|
import { IkasVariantValue } from "../variant-type/variant-value";
|
|
11
11
|
import { IkasProductCampaign } from "./campaign";
|
|
@@ -56,7 +56,6 @@ export declare class IkasProduct implements IProduct {
|
|
|
56
56
|
offers?: IkasProductOffer[];
|
|
57
57
|
private productGroupItems?;
|
|
58
58
|
showVariantsInGroup: boolean;
|
|
59
|
-
tieredDiscountProducts?: IkasProductTieredDiscountItem[];
|
|
60
59
|
customerReviews?: IkasCustomerReviewList | null;
|
|
61
60
|
constructor(data?: Partial<IkasProduct>);
|
|
62
61
|
get hasVariant(): boolean;
|
|
@@ -87,22 +86,6 @@ export declare class IkasProduct implements IProduct {
|
|
|
87
86
|
initBundleProducts: () => Promise<void>;
|
|
88
87
|
setShowVariantsInGroup: (value: boolean) => void;
|
|
89
88
|
getBundleProductsOfVariant: (variant: IkasProductVariant) => Promise<void>;
|
|
90
|
-
getTieredCampaignProducts: () => Promise<{
|
|
91
|
-
amount: number | null;
|
|
92
|
-
lineItemQuantityRange: {
|
|
93
|
-
min: number;
|
|
94
|
-
max: number;
|
|
95
|
-
};
|
|
96
|
-
type: IkasCampaignType;
|
|
97
|
-
sellPrice: number;
|
|
98
|
-
finalPrice: number;
|
|
99
|
-
sellPriceWithQuantity: number;
|
|
100
|
-
finalPriceWithQuantity: number;
|
|
101
|
-
formattedSellPrice: string;
|
|
102
|
-
formattedSellPriceWithQuantity: string;
|
|
103
|
-
formattedFinalPrice: string;
|
|
104
|
-
formattedFinalPriceWithQuantity: string;
|
|
105
|
-
}[]>;
|
|
106
89
|
private setOptionPrices;
|
|
107
90
|
}
|
|
108
91
|
export { IkasProductType };
|
|
@@ -133,20 +116,3 @@ export declare type IkasDisplayedProductGroupItem = {
|
|
|
133
116
|
value: string;
|
|
134
117
|
isSelected: boolean;
|
|
135
118
|
};
|
|
136
|
-
declare type IkasProductTieredDiscountItem = {
|
|
137
|
-
amount: number | null;
|
|
138
|
-
lineItemQuantityRange: {
|
|
139
|
-
min: number;
|
|
140
|
-
max: number;
|
|
141
|
-
};
|
|
142
|
-
type: IkasCampaignType;
|
|
143
|
-
sellPrice: number;
|
|
144
|
-
sellPriceWithQuantity: number;
|
|
145
|
-
finalPriceWithQuantity: number;
|
|
146
|
-
finalPrice: number;
|
|
147
|
-
formattedSellPrice: string;
|
|
148
|
-
formattedSellPriceWithQuantity: string;
|
|
149
|
-
formattedFinalPrice: string;
|
|
150
|
-
formattedFinalPriceWithQuantity: string;
|
|
151
|
-
};
|
|
152
|
-
export type { IkasProductTieredDiscountItem };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__spreadArray as t,__assign as e,__awaiter as i,__generator as n}from'./../../../ext/tslib/tslib.es6.js';import r from"lodash/sortBy";import a from"lodash/cloneDeep";import{IkasCategory as o}from"../category/index.js";import{IkasProductVariant as u}from"./variant/index.js";import{IkasProductAttributeValue as s}from"./attribute-value/index.js";import{IkasProductVariantType as c}from"./variant-type/index.js";import{IkasBrand as d}from"../brand/index.js";import{IkasHTMLMetaData as l}from"../html-meta-data/index.js";import{IkasProductTag as p}from"./tag/index.js";import{IkasCampaignType as f,IkasProductType as m}from"@ikas/storefront-models";export{IkasProductType}from"@ikas/storefront-models";import{IkasProductOptionSet as v}from"./option-set/index.js";import{makeObservable as h,observable as g,computed as y}from"mobx";import{IkasProductFunctions as V}from"@ikas/storefront-model-functions";import{IkasProductCampaign as b}from"./campaign/index.js";import{IkasStorefrontConfig as P}from"@ikas/storefront-config";import{IkasBaseStore as I}from"../../../store/base.js";import w from"lodash/groupBy";import{IkasProductBaseUnit as S}from"./base-unit/index.js";import{formatCurrency as O}from"../../../utils/currency.js";import"lodash/get";import j from"../../../store/product/index.js";import{IkasCustomerReviewList as T}from"../../ui/customer-review-list/index.js";import{IkasProductStar as x}from"./star/index.js";import{IkasProductCampaignOffer as C,IkasProductOffer as R}from"./campaign-offer/index.js";import{IkasProductGroup as G}from"./group/index.js";import{IkasImage as D}from"../image/index.js";import{IkasProductSalesChannel as E}from"./sales-channel/index.js";var k=function(){function k(V){void 0===V&&(V={});var w,D,A,L=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.isStatic=!1,this.bundleProductCache={},this.productGroupItems=[],this.showVariantsInGroup=!1,this.tieredDiscountProducts=[],this.selectVariantValue=function(i,n){var r,a=L.metaData,o=L.selectedVariantValues.map((function(t){return t.variantTypeId===i.variantTypeId?i:t})),u=L.variants.find((function(t){return t.isActive&&o.every((function(e){return t.variantValues.some((function(t){return t.id===e.id}))}))}));if(u)L.selectedVariantValues=o;else{var s=L.variantTypes.findIndex((function(t){return t.variantType.id===i.variantTypeId}));if(s>0){var c=L.variantTypes.slice(0,s),d=L.selectedVariantValues.filter((function(t){return c.some((function(e){return e.variantType.id===t.variantTypeId}))})),l=t(t([],d,!0),[i],!1);u=L.variants.find((function(t){return t.isActive&&l.every((function(e){return t.variantValues.some((function(t){return t.id===e.id}))}))}))}else{var p=o.slice(0,o.length-1);(u=L.variants.find((function(t){return t.isActive&&p.every((function(e){return t.variantValues.some((function(t){return t.id===e.id}))}))})))||(u=L.variants.find((function(t){return t.isActive&&t.variantValues.some((function(t){return t.id===i.id}))})))}if(!u)return;L.selectedVariantValues=u.variantValues}var f={};new URLSearchParams(window.location.search).forEach((function(t,i){var n;"vid"!==i&&(f=e(e({},f),((n={})[i]=t,n)))})),L.variantTypes.map((function(t){delete f[t.variantType.slug]}));var m=t(t([],L.variantTypes.map((function(t){var e=t.variantType,i=e.values.find((function(t){return L.selectedVariantValues.some((function(e){return e.id===t.id}))}));if(i)return"".concat(e.slug,"=").concat(i.slug)})),!0),Object.entries(f).map((function(t){var e=t[0],i=t[1];return"".concat(e,"=").concat(i)})),!0).filter((function(t){return!!t})).join("&");if(!n){var v="/".concat(a.slug);if(m&&(v="/".concat(a.slug,"?").concat(m)),v===window.location.pathname)return;null===(r=I.getInstance().router)||void 0===r||r.replace(v,void 0,{shallow:!1,scroll:!1})}},this.getVariantUnitPriceText=function(t){var e,i,n=t.price;if(n.unitPrice&&L.baseUnit){var r=L.baseUnit.baseAmount,a=(null===(i=null===(e=L.baseUnit)||void 0===e?void 0:e.unit)||void 0===i?void 0:i.name)||"";return"".concat(O(n.unitPrice,n.currency||"",n.currencySymbol||"")," / ").concat(r&&1!==r?r:"").concat(a)}},this.getCampaigns=function(){return i(L,void 0,void 0,(function(){var t,e,i,r,a,o=this;return n(this,(function(n){switch(n.label){case 0:return t=I.getInstance(),e=t.customerStore.customer,i=e?e.customerGroupIds:null,r=this.variants.map((function(t){return t.id})),[4,j.getProductCampaigns({input:{customerGroupIds:i,salesChannelId:P.getSalesChannelId()||"",variantIds:r}})];case 1:return a=n.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.getAvailableStockLocations=function(){return i(L,void 0,void 0,(function(){var t,e;return n(this,(function(i){switch(i.label){case 0:return t=this.variants.map((function(t){return t.id})),e=P.getPickupStockLocationIds(),[4,j.getVariantStockLocations({stockLocationIdList:e,variantIds:t})];case 1:return[2,i.sent().data||[]]}}))}))},this.getCustomerReviews=function(t){return i(L,void 0,void 0,(function(){var i,r,a,o,u;return n(this,(function(n){switch(n.label){case 0:return i=!!(null===(o=this.selectedVariant.bundleSettings)||void 0===o?void 0:o.products.length),r=[this.id],i&&(null===(u=this.selectedVariant.bundleSettings)||void 0===u||u.products.forEach((function(t){r.push(t.productId)}))),[4,(a=new T(e(e(e({},i?{}:{productId:this.id}),{limit:null==t?void 0:t.limit,page:null==t?void 0:t.page,hasImage:null==t?void 0:t.hasImage}),i?{productIds:r}:{}))).getInitial()];case 1:return n.sent(),[2,a]}}))}))},this.getProductOptionSet=function(){return i(L,void 0,void 0,(function(){var t,e;return n(this,(function(i){switch(i.label){case 0:return this.productOptionSet?[2,!0]:this.productOptionSetId?[4,j.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.initBundleProducts=function(){return i(L,void 0,void 0,(function(){var t,e,i,r,a,o;return n(this,(function(n){switch(n.label){case 0:return t="","undefined"!=typeof window&&(e=new URLSearchParams(window.location.search),t=e.get("editLineID")||""),t?(i=null===(a=I.getInstance().cartStore.cart)||void 0===a?void 0:a.items.find((function(e){return e.id===t})))&&(r=this.variants.find((function(t){return t.id===i.variant.id})))?(this.selectedVariantValues=r.variantValues,[4,this.getBundleProductsOfVariant(r)]):[3,2]:[3,3];case 1:n.sent(),null===(o=r.bundleSettings)||void 0===o||o.products.forEach((function(t){var e,n,r;try{var a=null===(e=i.variant.bundleProducts)||void 0===e?void 0:e.find((function(e){return e.id===t.id})),o=t.product.variants.find((function(t){return t.id===(null==a?void 0:a.variant.id)}));t.product.selectedVariantValues=o.variantValues,t.quantity=(null===(r=null===(n=i.variant.bundleProducts)||void 0===n?void 0:n.find((function(t){return t.variant.id===o.id})))||void 0===r?void 0:r.quantity)||0}catch(t){console.error(t)}})),n.label=2;case 2:return[3,5];case 3:return[4,this.getBundleProductsOfVariant(this.selectedVariant)];case 4:n.sent(),n.label=5;case 5:return[2]}}))}))},this.setShowVariantsInGroup=function(t){L.showVariantsInGroup=t},this.getBundleProductsOfVariant=function(t){return i(L,void 0,void 0,(function(){var e,i,r,o,u,s,c=this;return n(this,(function(n){switch(n.label){case 0:return(null==(e=null===(r=t.bundleSettings)||void 0===r?void 0:r.products.map((function(t){return t.productId})).filter((function(t){return-1===Object.keys(c.bundleProductCache).indexOf(t)})))?void 0:e.length)?[4,j.searchProducts({input:{productIdList:e,perPage:200}})]:[3,2];case 1:(i=n.sent()).isSuccess&&(null===(u=null===(o=i.data)||void 0===o?void 0:o.data)||void 0===u||u.forEach((function(t){c.bundleProductCache[t.id]=t}))),n.label=2;case 2:return null===(s=t.bundleSettings)||void 0===s||s.products.forEach((function(t){var e=c.bundleProductCache[t.productId];t.setProduct(new k(a(e)))})),[2]}}))}))},this.getTieredCampaignProducts=function(){return i(L,void 0,void 0,(function(){var t,e,i,r=this;return n(this,(function(n){return(t=null===(i=null===(e=this.campaigns)||void 0===e?void 0:e.find((function(t){return!!t.campaign.tieredDiscount})))||void 0===i?void 0:i.campaign)&&t.tieredDiscount?[2,this.tieredDiscountProducts=t.tieredDiscount.rules.map((function(e){var i,n,a,o,u=r.selectedVariant.finalPrice,s=u*((null===(i=e.lineItemQuantityRange)||void 0===i?void 0:i.min)||1),c=O(u,r.selectedVariant.price.currency||"",r.selectedVariant.price.currencySymbol||""),d=O(s,r.selectedVariant.price.currency||"",r.selectedVariant.price.currencySymbol||""),l=t.type===f.RATIO?r.selectedVariant.finalPrice-r.selectedVariant.finalPrice*(e.amount||1)/100:r.selectedVariant.finalPrice,p=l*((null===(n=e.lineItemQuantityRange)||void 0===n?void 0:n.min)||1)-(t.type===f.FIXED_AMOUNT&&e.amount||0),m=O(l,r.selectedVariant.price.currency||"",r.selectedVariant.price.currencySymbol||""),v=O(p,r.selectedVariant.price.currency||"",r.selectedVariant.price.currencySymbol||"");return{amount:e.amount,lineItemQuantityRange:{min:(null===(a=e.lineItemQuantityRange)||void 0===a?void 0:a.min)||0,max:(null===(o=e.lineItemQuantityRange)||void 0===o?void 0:o.max)||0},type:t.type,sellPrice:u,finalPrice:l,sellPriceWithQuantity:s,finalPriceWithQuantity:p,formattedSellPrice:c,formattedSellPriceWithQuantity:d,formattedFinalPrice:m,formattedFinalPriceWithQuantity:v}}))]:[2,[]]}))}))},this.setOptionPrices=function(){var t,e=L.variants[0];if(e){var i=e.price.currency;null===(t=L.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||m.PHYSICAL,this.description=V.description||"",this.shortDescription=V.shortDescription||"",this.metaData=V.metaData?new l(V.metaData):null,this.brand=V.brand?new d(V.brand):null,this.categories=V.categories?V.categories.map((function(t){return new o(t)})):[],this.deleted=V.deleted||null,this.tags=V.tags?V.tags.map((function(t){return new p(t)})):[],this.variants=V.variants?V.variants.map((function(t){return new u(t)})):[],this.attributes=V.attributes?V.attributes.map((function(t){return new s(t)})):[],this.variantTypes=V.variantTypes?V.variantTypes.map((function(t){return new c(t)})):[],this.productOptionSetId=V.productOptionSetId||null,this.averageRating=null!==(w=V.averageRating)&&void 0!==w?w:null,this.reviewCount=null!==(D=V.reviewCount)&&void 0!==D?D:null,this.stars=V.stars?V.stars.map((function(t){return new x(t)})):null,this.baseUnit=V.baseUnit?new S(V.baseUnit):null,this.productOptionSet=V.productOptionSet?new v(V.productOptionSet):null,this.campaigns=(null===(A=V.campaigns)||void 0===A?void 0:A.map((function(t){return new b(t)})))||null,this.selectedVariantValues=V.selectedVariantValues||[],this.variantTypes=r(this.variantTypes,"order"),this.groupVariantsByVariantTypeId=V.groupVariantsByVariantTypeId||null,this.dynamicPriceListIds=V.dynamicPriceListIds||null,this.productVolumeDiscountId=V.productVolumeDiscountId||null,this.campaignOffers=V.campaignOffers?V.campaignOffers.map((function(t){return new C(t)})):null,this.appliedCampaignOffer=V.appliedCampaignOffer,this.offers=V.offers?V.offers.map((function(t){return new R(t)})):void 0,this.productGroup=V.productGroup?new G(V.productGroup):null,this.salesChannels=V.salesChannels?V.salesChannels.map((function(t){return new E(t)})):null,this.productGroupItems=V.productGroupItems,this.setOptionPrices(),this.variants.forEach((function(t){return t.product=L})),this.customerReviews=V.customerReviews?new T(V.customerReviews):null,h(this,{selectedVariantValues:g,isFiltered:g,isStatic:g,showVariantsInGroup:g,hasVariant:y,hasStock:y,hasValidProductOptionValues:y,href:y,productHref:y,mainVariantType:y,mainVariantValue:y,selectedVariant:y,displayedVariantTypes:y,isCustomerReviewEnabled:y,isCustomerReviewLoginRequired:y,isAddToCartEnabled:y,groupedAttributeValues:y,selectedVariantUnitPriceText:y,displayedProductGroups:y})}return Object.defineProperty(k.prototype,"hasVariant",{get:function(){return V.hasVariant(this,this.showVariantsInGroup)},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"hasStock",{get:function(){return this.isStatic?this.selectedVariant.hasStock:V.hasStock(this)},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"hasValidProductOptionValues",{get:function(){return!this.productOptionSet||this.productOptionSet.hasValidValues},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"href",{get:function(){return V.getSelectedVariantHref(this,this.selectedVariantValues)},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"productHref",{get:function(){return this.groupVariantsByVariantTypeId||this.isFiltered?this.href:V.getProductHref(this)},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"mainVariantType",{get:function(){return V.getMainVariantType(this)},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"mainVariantValue",{get:function(){return V.getMainVariantValue(this.selectedVariantValues)},enumerable:!1,configurable:!0}),Object.defineProperty(k.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(k.prototype,"displayedVariantTypes",{get:function(){return this.hasVariant?V.getDisplayedVariantTypes(this,this.selectedVariantValues):[]},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"isCustomerReviewEnabled",{get:function(){return P.isCustomerReviewEnabled()},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"isCustomerReviewLoginRequired",{get:function(){return P.isCustomerReviewLoginRequired()},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"isAddToCartEnabled",{get:function(){var t,e=!0;return null===(t=this.selectedVariant.bundleSettings)||void 0===t||t.products.forEach((function(t){0===t.quantity&&null!==t.minQuantity&&0!==t.minQuantity&&(e=!1)})),e&&this.hasValidProductOptionValues&&(this.selectedVariant.hasStock||this.selectedVariant.sellIfOutOfStock)},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"groupedAttributeValues",{get:function(){var t,e=w(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(k.prototype,"selectedVariantUnitPriceText",{get:function(){return this.getVariantUnitPriceText(this.selectedVariant)},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"displayedProductGroups",{get:function(){var e,i=this,n=[],a=[];return null===(e=this.productGroupItems)||void 0===e||e.forEach((function(t){t.groupValues.forEach((function(t){n.includes(t.name)||n.push(t.name)}))})),n.forEach((function(e){var n,o={name:e,items:[]};i.productGroupItems=r(i.productGroupItems,(function(t){var e;return parseInt((null===(e=t.order)||void 0===e?void 0:e.value)||"999",10)})),null===(n=i.productGroupItems)||void 0===n||n.forEach((function(n){var r,a,u,s=n.groupValues.find((function(t){return t.name===e}));if(s&&!o.items.some((function(t){return t.value===s.value}))){var c="";if(n.productId===i.id)c=i.href;else{var d=(null===(r=i.productGroup)||void 0===r?void 0:r.values.filter((function(t){return t.name!==e})))||[],l=t(t([],d,!0),[s],!1),p=null===(a=i.productGroupItems)||void 0===a?void 0:a.find((function(t){return l.every((function(e){return t.groupValues.some((function(t){return e.name===t.name&&e.value===t.value}))}))}));c=p?p.href:n.href}o.items.push({image:n.image?new D(n.image):null,href:c,value:s.value,isSelected:(null===(u=i.productGroupItems)||void 0===u?void 0:u.some((function(t){return t.groupValues.some((function(t){return t.value===s.value}))&&t.productId===i.id})))||!1})}})),a.push(o)})),a},enumerable:!1,configurable:!0}),k}();export{k as IkasProduct};
|
|
1
|
+
import{__spreadArray as t,__assign as e,__awaiter as n,__generator as i}from'./../../../ext/tslib/tslib.es6.js';import r from"lodash/sortBy";import a from"lodash/cloneDeep";import{IkasCategory as o}from"../category/index.js";import{IkasProductVariant as u}from"./variant/index.js";import{IkasProductAttributeValue as s}from"./attribute-value/index.js";import{IkasProductVariantType as c}from"./variant-type/index.js";import{IkasBrand as d}from"../brand/index.js";import{IkasHTMLMetaData as l}from"../html-meta-data/index.js";import{IkasProductTag as p}from"./tag/index.js";import{IkasProductType as f}from"@ikas/storefront-models";export{IkasProductType}from"@ikas/storefront-models";import{IkasProductOptionSet as h}from"./option-set/index.js";import{makeObservable as v,observable as m,computed as g}from"mobx";import{IkasProductFunctions as b}from"@ikas/storefront-model-functions";import{IkasProductCampaign as V}from"./campaign/index.js";import{IkasStorefrontConfig as y}from"@ikas/storefront-config";import{IkasBaseStore as I}from"../../../store/base.js";import P from"lodash/groupBy";import{IkasProductBaseUnit as w}from"./base-unit/index.js";import{formatCurrency as O}from"../../../utils/currency.js";import"lodash/get";import S from"../../../store/product/index.js";import{IkasCustomerReviewList as j}from"../../ui/customer-review-list/index.js";import{IkasProductStar as T}from"./star/index.js";import{IkasProductCampaignOffer as C,IkasProductOffer as x}from"./campaign-offer/index.js";import{IkasProductGroup as G}from"./group/index.js";import{IkasImage as E}from"../image/index.js";import{IkasProductSalesChannel as k}from"./sales-channel/index.js";var R=function(){function R(b){void 0===b&&(b={});var P,E,A,L=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.isStatic=!1,this.bundleProductCache={},this.productGroupItems=[],this.showVariantsInGroup=!1,this.selectVariantValue=function(n,i){var r,a=L.metaData,o=L.selectedVariantValues.map((function(t){return t.variantTypeId===n.variantTypeId?n:t})),u=L.variants.find((function(t){return t.isActive&&o.every((function(e){return t.variantValues.some((function(t){return t.id===e.id}))}))}));if(u)L.selectedVariantValues=o;else{var s=L.variantTypes.findIndex((function(t){return t.variantType.id===n.variantTypeId}));if(s>0){var c=L.variantTypes.slice(0,s),d=L.selectedVariantValues.filter((function(t){return c.some((function(e){return e.variantType.id===t.variantTypeId}))})),l=t(t([],d,!0),[n],!1);u=L.variants.find((function(t){return t.isActive&&l.every((function(e){return t.variantValues.some((function(t){return t.id===e.id}))}))}))}else{var p=o.slice(0,o.length-1);(u=L.variants.find((function(t){return t.isActive&&p.every((function(e){return t.variantValues.some((function(t){return t.id===e.id}))}))})))||(u=L.variants.find((function(t){return t.isActive&&t.variantValues.some((function(t){return t.id===n.id}))})))}if(!u)return;L.selectedVariantValues=u.variantValues}var f={};new URLSearchParams(window.location.search).forEach((function(t,n){var i;"vid"!==n&&(f=e(e({},f),((i={})[n]=t,i)))})),L.variantTypes.map((function(t){delete f[t.variantType.slug]}));var h=t(t([],L.variantTypes.map((function(t){var e=t.variantType,n=e.values.find((function(t){return L.selectedVariantValues.some((function(e){return e.id===t.id}))}));if(n)return"".concat(e.slug,"=").concat(n.slug)})),!0),Object.entries(f).map((function(t){var e=t[0],n=t[1];return"".concat(e,"=").concat(n)})),!0).filter((function(t){return!!t})).join("&");if(!i){var v="/".concat(a.slug);if(h&&(v="/".concat(a.slug,"?").concat(h)),v===window.location.pathname)return;null===(r=I.getInstance().router)||void 0===r||r.replace(v,void 0,{shallow:!1,scroll:!1})}},this.getVariantUnitPriceText=function(t){var e,n,i=t.price;if(i.unitPrice&&L.baseUnit){var r=L.baseUnit.baseAmount,a=(null===(n=null===(e=L.baseUnit)||void 0===e?void 0:e.unit)||void 0===n?void 0:n.name)||"";return"".concat(O(i.unitPrice,i.currency||"",i.currencySymbol||"")," / ").concat(r&&1!==r?r:"").concat(a)}},this.getCampaigns=function(){return n(L,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=I.getInstance(),e=t.customerStore.customer,n=e?e.customerGroupIds:null,r=this.variants.map((function(t){return t.id})),[4,S.getProductCampaigns({input:{customerGroupIds:n,salesChannelId:y.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 n;t.variantIds.some((function(t){return t===e.id}))&&(null===(n=e.campaigns)||void 0===n||n.push(t))}))})),[2,this.campaigns]):[2]}}))}))},this.getAvailableStockLocations=function(){return n(L,void 0,void 0,(function(){var t,e;return i(this,(function(n){switch(n.label){case 0:return t=this.variants.map((function(t){return t.id})),e=y.getPickupStockLocationIds(),[4,S.getVariantStockLocations({stockLocationIdList:e,variantIds:t})];case 1:return[2,n.sent().data||[]]}}))}))},this.getCustomerReviews=function(t){return n(L,void 0,void 0,(function(){var n,r,a,o,u;return i(this,(function(i){switch(i.label){case 0:return n=!!(null===(o=this.selectedVariant.bundleSettings)||void 0===o?void 0:o.products.length),r=[this.id],n&&(null===(u=this.selectedVariant.bundleSettings)||void 0===u||u.products.forEach((function(t){r.push(t.productId)}))),[4,(a=new j(e(e(e({},n?{}:{productId:this.id}),{limit:null==t?void 0:t.limit,page:null==t?void 0:t.page,hasImage:null==t?void 0:t.hasImage}),n?{productIds:r}:{}))).getInitial()];case 1:return i.sent(),[2,a]}}))}))},this.getProductOptionSet=function(){return n(L,void 0,void 0,(function(){var t,e;return i(this,(function(n){switch(n.label){case 0:return this.productOptionSet?[2,!0]:this.productOptionSetId?[4,S.listProductOptionSet({id:{eq:this.productOptionSetId}})]:[2,!1];case 1:return(t=n.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.initBundleProducts=function(){return n(L,void 0,void 0,(function(){var t,e,n,r,a,o;return i(this,(function(i){switch(i.label){case 0:return t="","undefined"!=typeof window&&(e=new URLSearchParams(window.location.search),t=e.get("editLineID")||""),t?(n=null===(a=I.getInstance().cartStore.cart)||void 0===a?void 0:a.items.find((function(e){return e.id===t})))&&(r=this.variants.find((function(t){return t.id===n.variant.id})))?(this.selectedVariantValues=r.variantValues,[4,this.getBundleProductsOfVariant(r)]):[3,2]:[3,3];case 1:i.sent(),null===(o=r.bundleSettings)||void 0===o||o.products.forEach((function(t){var e,i,r;try{var a=null===(e=n.variant.bundleProducts)||void 0===e?void 0:e.find((function(e){return e.id===t.id})),o=t.product.variants.find((function(t){return t.id===(null==a?void 0:a.variant.id)}));t.product.selectedVariantValues=o.variantValues,t.quantity=(null===(r=null===(i=n.variant.bundleProducts)||void 0===i?void 0:i.find((function(t){return t.variant.id===o.id})))||void 0===r?void 0:r.quantity)||0}catch(t){console.error(t)}})),i.label=2;case 2:return[3,5];case 3:return[4,this.getBundleProductsOfVariant(this.selectedVariant)];case 4:i.sent(),i.label=5;case 5:return[2]}}))}))},this.setShowVariantsInGroup=function(t){L.showVariantsInGroup=t},this.getBundleProductsOfVariant=function(t){return n(L,void 0,void 0,(function(){var e,n,r,o,u,s,c=this;return i(this,(function(i){switch(i.label){case 0:return(null==(e=null===(r=t.bundleSettings)||void 0===r?void 0:r.products.map((function(t){return t.productId})).filter((function(t){return-1===Object.keys(c.bundleProductCache).indexOf(t)})))?void 0:e.length)?[4,S.searchProducts({input:{productIdList:e,perPage:200}})]:[3,2];case 1:(n=i.sent()).isSuccess&&(null===(u=null===(o=n.data)||void 0===o?void 0:o.data)||void 0===u||u.forEach((function(t){c.bundleProductCache[t.id]=t}))),i.label=2;case 2:return null===(s=t.bundleSettings)||void 0===s||s.products.forEach((function(t){var e=c.bundleProductCache[t.productId];t.setProduct(new R(a(e)))})),[2]}}))}))},this.setOptionPrices=function(){var t,e=L.variants[0];if(e){var n=e.price.currency;null===(t=L.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===n})))||void 0===e?void 0:e.price)||t.price)})),t.otherPrices&&(t.price=(null===(e=t.otherPrices.find((function(t){return t.currencyCode===n})))||void 0===e?void 0:e.price)||t.price)}))}},this.id=b.id||Date.now()+"",this.name=b.name||"",this.type=b.type||f.PHYSICAL,this.description=b.description||"",this.shortDescription=b.shortDescription||"",this.metaData=b.metaData?new l(b.metaData):null,this.brand=b.brand?new d(b.brand):null,this.categories=b.categories?b.categories.map((function(t){return new o(t)})):[],this.deleted=b.deleted||null,this.tags=b.tags?b.tags.map((function(t){return new p(t)})):[],this.variants=b.variants?b.variants.map((function(t){return new u(t)})):[],this.attributes=b.attributes?b.attributes.map((function(t){return new s(t)})):[],this.variantTypes=b.variantTypes?b.variantTypes.map((function(t){return new c(t)})):[],this.productOptionSetId=b.productOptionSetId||null,this.averageRating=null!==(P=b.averageRating)&&void 0!==P?P:null,this.reviewCount=null!==(E=b.reviewCount)&&void 0!==E?E:null,this.stars=b.stars?b.stars.map((function(t){return new T(t)})):null,this.baseUnit=b.baseUnit?new w(b.baseUnit):null,this.productOptionSet=b.productOptionSet?new h(b.productOptionSet):null,this.campaigns=(null===(A=b.campaigns)||void 0===A?void 0:A.map((function(t){return new V(t)})))||null,this.selectedVariantValues=b.selectedVariantValues||[],this.variantTypes=r(this.variantTypes,"order"),this.groupVariantsByVariantTypeId=b.groupVariantsByVariantTypeId||null,this.dynamicPriceListIds=b.dynamicPriceListIds||null,this.productVolumeDiscountId=b.productVolumeDiscountId||null,this.campaignOffers=b.campaignOffers?b.campaignOffers.map((function(t){return new C(t)})):null,this.appliedCampaignOffer=b.appliedCampaignOffer,this.offers=b.offers?b.offers.map((function(t){return new x(t)})):void 0,this.productGroup=b.productGroup?new G(b.productGroup):null,this.salesChannels=b.salesChannels?b.salesChannels.map((function(t){return new k(t)})):null,this.productGroupItems=b.productGroupItems,this.setOptionPrices(),this.variants.forEach((function(t){return t.product=L})),this.customerReviews=b.customerReviews?new j(b.customerReviews):null,v(this,{selectedVariantValues:m,isFiltered:m,isStatic:m,showVariantsInGroup:m,hasVariant:g,hasStock:g,hasValidProductOptionValues:g,href:g,productHref:g,mainVariantType:g,mainVariantValue:g,selectedVariant:g,displayedVariantTypes:g,isCustomerReviewEnabled:g,isCustomerReviewLoginRequired:g,isAddToCartEnabled:g,groupedAttributeValues:g,selectedVariantUnitPriceText:g,displayedProductGroups:g})}return Object.defineProperty(R.prototype,"hasVariant",{get:function(){return b.hasVariant(this,this.showVariantsInGroup)},enumerable:!1,configurable:!0}),Object.defineProperty(R.prototype,"hasStock",{get:function(){return this.isStatic?this.selectedVariant.hasStock:b.hasStock(this)},enumerable:!1,configurable:!0}),Object.defineProperty(R.prototype,"hasValidProductOptionValues",{get:function(){return!this.productOptionSet||this.productOptionSet.hasValidValues},enumerable:!1,configurable:!0}),Object.defineProperty(R.prototype,"href",{get:function(){return b.getSelectedVariantHref(this,this.selectedVariantValues)},enumerable:!1,configurable:!0}),Object.defineProperty(R.prototype,"productHref",{get:function(){return this.groupVariantsByVariantTypeId||this.isFiltered?this.href:b.getProductHref(this)},enumerable:!1,configurable:!0}),Object.defineProperty(R.prototype,"mainVariantType",{get:function(){return b.getMainVariantType(this)},enumerable:!1,configurable:!0}),Object.defineProperty(R.prototype,"mainVariantValue",{get:function(){return b.getMainVariantValue(this.selectedVariantValues)},enumerable:!1,configurable:!0}),Object.defineProperty(R.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(R.prototype,"displayedVariantTypes",{get:function(){return this.hasVariant?b.getDisplayedVariantTypes(this,this.selectedVariantValues):[]},enumerable:!1,configurable:!0}),Object.defineProperty(R.prototype,"isCustomerReviewEnabled",{get:function(){return y.isCustomerReviewEnabled()},enumerable:!1,configurable:!0}),Object.defineProperty(R.prototype,"isCustomerReviewLoginRequired",{get:function(){return y.isCustomerReviewLoginRequired()},enumerable:!1,configurable:!0}),Object.defineProperty(R.prototype,"isAddToCartEnabled",{get:function(){var t,e=!0;return null===(t=this.selectedVariant.bundleSettings)||void 0===t||t.products.forEach((function(t){0===t.quantity&&null!==t.minQuantity&&0!==t.minQuantity&&(e=!1)})),e&&this.hasValidProductOptionValues&&(this.selectedVariant.hasStock||this.selectedVariant.sellIfOutOfStock)},enumerable:!1,configurable:!0}),Object.defineProperty(R.prototype,"groupedAttributeValues",{get:function(){var t,e=P(this.attributes,"productAttributeId");return(null===(t=this.attributes)||void 0===t?void 0:t.map((function(t){var n=t.productAttributeId;if(n){var i=e[n];return(null==i?void 0:i.length)&&i[0].productAttribute?{attribute:i[0].productAttribute,values:i}:void 0}})).filter((function(t){return!!t})))||[]},enumerable:!1,configurable:!0}),Object.defineProperty(R.prototype,"selectedVariantUnitPriceText",{get:function(){return this.getVariantUnitPriceText(this.selectedVariant)},enumerable:!1,configurable:!0}),Object.defineProperty(R.prototype,"displayedProductGroups",{get:function(){var e,n=this,i=[],a=[];return null===(e=this.productGroupItems)||void 0===e||e.forEach((function(t){t.groupValues.forEach((function(t){i.includes(t.name)||i.push(t.name)}))})),i.forEach((function(e){var i,o={name:e,items:[]};n.productGroupItems=r(n.productGroupItems,(function(t){var e;return parseInt((null===(e=t.order)||void 0===e?void 0:e.value)||"999",10)})),null===(i=n.productGroupItems)||void 0===i||i.forEach((function(i){var r,a,u,s=i.groupValues.find((function(t){return t.name===e}));if(s&&!o.items.some((function(t){return t.value===s.value}))){var c="";if(i.productId===n.id)c=n.href;else{var d=(null===(r=n.productGroup)||void 0===r?void 0:r.values.filter((function(t){return t.name!==e})))||[],l=t(t([],d,!0),[s],!1),p=null===(a=n.productGroupItems)||void 0===a?void 0:a.find((function(t){return l.every((function(e){return t.groupValues.some((function(t){return e.name===t.name&&e.value===t.value}))}))}));c=p?p.href:i.href}o.items.push({image:i.image?new E(i.image):null,href:c,value:s.value,isSelected:(null===(u=n.productGroupItems)||void 0===u?void 0:u.some((function(t){return t.groupValues.some((function(t){return t.value===s.value}))&&t.productId===n.id})))||!1})}})),a.push(o)})),a},enumerable:!1,configurable:!0}),R}();export{R as IkasProduct};
|
|
@@ -53,6 +53,22 @@ export declare class IkasProductVariant implements IProductVariant {
|
|
|
53
53
|
get sellPriceWithCampaignOffers(): number;
|
|
54
54
|
get formattedSellPriceWithCampaignOffers(): string;
|
|
55
55
|
get campaignOffersDiscountPercentage(): string | 0;
|
|
56
|
+
get tieredDiscountProducts(): {
|
|
57
|
+
amount: number | null;
|
|
58
|
+
lineItemQuantityRange: {
|
|
59
|
+
min: number;
|
|
60
|
+
max: number;
|
|
61
|
+
};
|
|
62
|
+
type: IkasCampaignType;
|
|
63
|
+
sellPrice: number;
|
|
64
|
+
finalPrice: number;
|
|
65
|
+
sellPriceWithQuantity: number;
|
|
66
|
+
finalPriceWithQuantity: number;
|
|
67
|
+
formattedSellPrice: string;
|
|
68
|
+
formattedSellPriceWithQuantity: string;
|
|
69
|
+
formattedFinalPrice: string;
|
|
70
|
+
formattedFinalPriceWithQuantity: string;
|
|
71
|
+
}[];
|
|
56
72
|
saveBackInStockReminder(email: string): Promise<boolean>;
|
|
57
73
|
toJSON(): this;
|
|
58
74
|
}
|
|
@@ -61,3 +77,20 @@ export declare type AppliedCampaignAmount = {
|
|
|
61
77
|
formattedPrice: string | null;
|
|
62
78
|
discountPercentage: string | null;
|
|
63
79
|
};
|
|
80
|
+
declare type IkasProductTieredDiscountItem = {
|
|
81
|
+
amount: number | null;
|
|
82
|
+
lineItemQuantityRange: {
|
|
83
|
+
min: number;
|
|
84
|
+
max: number;
|
|
85
|
+
};
|
|
86
|
+
type: IkasCampaignType;
|
|
87
|
+
sellPrice: number;
|
|
88
|
+
sellPriceWithQuantity: number;
|
|
89
|
+
finalPriceWithQuantity: number;
|
|
90
|
+
finalPrice: number;
|
|
91
|
+
formattedSellPrice: string;
|
|
92
|
+
formattedSellPriceWithQuantity: string;
|
|
93
|
+
formattedFinalPrice: string;
|
|
94
|
+
formattedFinalPriceWithQuantity: string;
|
|
95
|
+
};
|
|
96
|
+
export type { IkasProductTieredDiscountItem };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as e,__generator as t,__assign as i}from'./../../../../ext/tslib/tslib.es6.js';import{IkasProductPrice as r}from"./price/index.js";import{IkasVariantValue as n}from"../../variant-type/variant-value/index.js";import{IkasProductAttributeValue as o}from"../attribute-value/index.js";import{IkasProductImage as u}from"../image/index.js";import{IkasBundleSettings as c}from"./bundle-settings/index.js";import{IkasCustomerPriceListRuleValueType as s,IkasCampaignType as a,IkasCustomerPriceListRuleFilterType as l}from"@ikas/storefront-models";import{IkasProductVariantFunctions as d,IkasProductPriceFunctions as f}from"@ikas/storefront-model-functions";import{IkasStorefrontConfig as p}from"@ikas/storefront-config";import{saveProductBackInStockRemind as m,listProductBackInStockRemind as b}from"@ikas/storefront-api";import v from"lodash/groupBy";import h from"lodash/sortBy";import{IkasProductVariantUnit as g}from"./unit/index.js";import{formatCurrency as P}from"../../../../utils/currency.js";import{makeAutoObservable as y}from"mobx";import{IkasBaseStore as O}from"../../../../store/base.js";import"../../../../store/customer/index.js";import"../../../../store/cart/index.js";var S=function(){function S(e){void 0===e&&(e={}),this._backInStockReminderSaved=!1,this.product=null,this.id=e.id||Date.now()+"",this.productId=e.productId||"",this.sku=e.sku||null,this.barcodeList=e.barcodeList||[],this.baseBundlePrices=e.baseBundlePrices?e.baseBundlePrices.map((function(e){return new r(e)})):[],this.bundleSettings=e.bundleSettings?new c(e.bundleSettings):null,this.variantValues=e.variantValues?e.variantValues.map((function(e){return new n(e)})):[],this.images=e.images?e.images.map((function(e){return new u(e)})):[],this.attributes=e.attributes?e.attributes.map((function(e){return new o(e)})):[],this.prices=e.prices?e.prices.map((function(e){return new r(e)})):[],this.stock=e.stock||0,this.isActive=void 0===e.isActive||e.isActive,this.campaigns=e.campaigns||[],this.unit=e.unit?new g(e.unit):null,this.sellIfOutOfStock=e.sellIfOutOfStock||!1,this.images=h(this.images,"order"),y(this)}return Object.defineProperty(S.prototype,"mainImage",{get:function(){var e=d.getMainImage(this);return e?new u(e):void 0},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"hasStock",{get:function(){return d.hasStock(this)},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"isBackInStockEnabled",{get:function(){return p.isBackInStockEnabled()},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"isBackInStockCustomerLoginRequired",{get:function(){return p.isCustomerLoginRequiredForBackInStock()},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"isBackInStockReminderSaved",{get:function(){return this._backInStockReminderSaved},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"groupedAttributeValues",{get:function(){var e,t=v(this.attributes,"productAttributeId");return(null===(e=this.attributes)||void 0===e?void 0:e.map((function(e){var i=e.productAttributeId;if(i){var r=t[i];return(null==r?void 0:r.length)&&r[0].productAttribute?{attribute:r[0].productAttribute,values:r}:void 0}})).filter((function(e){return!!e})))||[]},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"b2bPriceRule",{get:function(){var e,t,i=this,r=O.getInstance().customerStore.customer,n=null==r?void 0:r.priceListRules,o=function(e){var t,r,n,o;if(e.type===l.CATEGORY)return u=null===(t=e.valueList)||void 0===t?void 0:t.some((function(e){var t;return null===(t=i.product)||void 0===t?void 0:t.categories.find((function(t){return t.id===e}))}));if(e.type===l.PRODUCT)return u=null===(r=e.valueList)||void 0===r?void 0:r.some((function(e){return i.id===e}));if(e.type===l.PRODUCT_BRAND){var u=null===(n=e.valueList)||void 0===n?void 0:n.some((function(e){var t,r;return(null===(r=null===(t=i.product)||void 0===t?void 0:t.brand)||void 0===r?void 0:r.id)===e}));return u}if(e.type===l.PRODUCT_TAG){u=null===(o=e.valueList)||void 0===o?void 0:o.some((function(e){var t,r;return null===(r=null===(t=i.product)||void 0===t?void 0:t.tags)||void 0===r?void 0:r.find((function(t){return t.id===e}))}));return u}};if(n){for(var u=0,c=n;u<c.length;u++){var s=c[u];if(s.shouldMatchAllFilters?null===(e=s.filters)||void 0===e?void 0:e.every(o):null===(t=s.filters)||void 0===t?void 0:t.some(o))return s}return null}return null},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"price",{get:function(){var e,t;if(p.isB2BStorefront()){var i=O.getInstance().customerStore.customer;if(null==i?void 0:i.priceListId){var r=null===(e=this.prices)||void 0===e?void 0:e.find((function(e){return e.priceListId===i.priceListId}));if(r)return r}}return null===(t=this.prices)||void 0===t?void 0:t.find((function(e){return p.getPriceListId()?e.priceListId===p.getPriceListId():null===e.priceListId}))},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"bundlePrice",{get:function(){var e,t;if(p.isB2BStorefront()){var i=O.getInstance().customerStore.customer;if(null==i?void 0:i.priceListId){var r=null===(e=this.baseBundlePrices)||void 0===e?void 0:e.find((function(e){return e.priceListId===i.priceListId}));if(r)return r}}return(null===(t=this.baseBundlePrices)||void 0===t?void 0:t.find((function(e){return p.getPriceListId()?e.priceListId===p.getPriceListId():null===e.priceListId})))||this.price},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"finalPrice",{get:function(){var e=0;this.bundleSettings&&this.bundleSettings.products.every((function(e){return!!e.product}))?e=f.getFinalPrice(this.bundlePrice)+this.bundleSettings.products.reduce((function(e,t){return e+(t.addToBundleBasePrice?t.finalPriceWithQuantity:0)}),0):e=f.getFinalPrice(this.price);if(!this.b2bPriceRule)return e;switch(this.b2bPriceRule.valueType){case s.DISCOUNT_RATE:return e*((100-this.b2bPriceRule.value)/100);case s.DISCOUNT_AMOUNT:return e-this.b2bPriceRule.value;case s.FIXED_PRICE:return this.b2bPriceRule.value;default:return e}},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"formattedFinalPrice",{get:function(){return P(this.finalPrice,this.price.currency||"",this.price.currencySymbol||"")},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"sellPrice",{get:function(){return this.bundleSettings&&this.bundleSettings.products.every((function(e){return!!e.product}))?this.bundlePrice.sellPrice+this.bundleSettings.products.reduce((function(e,t){return e+(t.addToBundleBasePrice?t.sellPriceWithQuantity:0)}),0):this.price.sellPrice},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"formattedSellPrice",{get:function(){return P(this.sellPrice,this.price.currency||"",this.price.currencySymbol||"")},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"formattedBuyPrice",{get:function(){return P(this.price.buyPrice||0,this.price.currency||"",this.price.currencySymbol||"")},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"appliedCampaignAmount",{get:function(){var e,t,i,r,n,o,u,c=this;if(!(null===(e=this.price.campaignPrice)||void 0===e?void 0:e.campaignId))return null;var s=(null===(r=null===(i=null===(t=this.product)||void 0===t?void 0:t.campaigns)||void 0===i?void 0:i.find((function(e){var t;return e.campaign.id===(null===(t=c.price.campaignPrice)||void 0===t?void 0:t.campaignId)})))||void 0===r?void 0:r.campaign)||null;if(!s)return null;var l={type:s.type,formattedPrice:null,discountPercentage:null};return s.type===a.FIXED_AMOUNT&&(l.formattedPrice=P((null===(n=s.fixedDiscount)||void 0===n?void 0:n.amount)||0,this.price.currency||"",this.price.currencySymbol||"")),s.type===a.RATIO&&(l.discountPercentage=(null===(u=null===(o=s.fixedDiscount)||void 0===o?void 0:o.amount)||void 0===u?void 0:u.toString())||null),l},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"campaignPrice",{get:function(){var e;return(null===(e=this.price.campaignPrice)||void 0===e?void 0:e.campaignPrice)||null},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"formattedCampaignPrice",{get:function(){return P(this.campaignPrice||0,this.price.currency||"",this.price.currencySymbol||"")},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"discountPrice",{get:function(){return this.finalPrice===this.sellPrice?null:this.finalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"formattedDiscountPrice",{get:function(){return P(this.discountPrice||0,this.price.currency||"",this.price.currencySymbol||"")},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"hasDiscount",{get:function(){return this.finalPrice!==this.sellPrice},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"discountAmount",{get:function(){return this.hasDiscount?this.sellPrice-this.finalPrice:0},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"discountPercentage",{get:function(){return this.hasDiscount?(100-100*this.finalPrice/this.sellPrice).toFixed(0):0},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"finalPriceWithCampaignOffers",{get:function(){var e,t;return this.finalPrice+((null===(t=null===(e=this.product)||void 0===e?void 0:e.offers)||void 0===t?void 0:t.filter((function(e){return e.isSelected&&!e.isAccepted})).reduce((function(e,t){return e+t.product.selectedVariant.finalPrice}),0))||0)},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"formattedFinalPriceWithCampaignOffers",{get:function(){return P(this.finalPriceWithCampaignOffers,this.price.currency||"",this.price.currencySymbol||"")},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"sellPriceWithCampaignOffers",{get:function(){var e,t;return this.sellPrice+((null===(t=null===(e=this.product)||void 0===e?void 0:e.offers)||void 0===t?void 0:t.filter((function(e){return e.isSelected&&!e.isAccepted})).reduce((function(e,t){return e+t.product.selectedVariant.sellPrice}),0))||0)},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"formattedSellPriceWithCampaignOffers",{get:function(){return P(this.sellPriceWithCampaignOffers,this.price.currency||"",this.price.currencySymbol||"")},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"campaignOffersDiscountPercentage",{get:function(){return this.finalPriceWithCampaignOffers!==this.sellPriceWithCampaignOffers?(100-100*this.finalPriceWithCampaignOffers/this.sellPriceWithCampaignOffers).toFixed(0):0},enumerable:!1,configurable:!0}),S.prototype.saveBackInStockReminder=function(i){var r;return e(this,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,b({email:{eq:i},productId:{eq:this.productId},variantId:{eq:this.id}})];case 1:return(e=t.sent())&&(null===(r=e.data)||void 0===r?void 0:r.length)?(this._backInStockReminderSaved=!0,[2,!1]):[3,2];case 2:return[4,m({input:{email:i,productId:this.productId,variantId:this.id}})];case 3:return t.sent().isSuccess?(this._backInStockReminderSaved=!0,[2,!0]):(this._backInStockReminderSaved=!1,[2,!1]);case 4:return[2]}}))}))},S.prototype.toJSON=function(){var e=i({},this);return delete e.product,e},S}();export{S as IkasProductVariant};
|
|
1
|
+
import{__awaiter as e,__generator as t,__assign as i}from'./../../../../ext/tslib/tslib.es6.js';import{IkasProductPrice as r}from"./price/index.js";import{IkasVariantValue as n}from"../../variant-type/variant-value/index.js";import{IkasProductAttributeValue as o}from"../attribute-value/index.js";import{IkasProductImage as c}from"../image/index.js";import{IkasBundleSettings as u}from"./bundle-settings/index.js";import{IkasCustomerPriceListRuleValueType as l,IkasCampaignType as a,IkasCampaignFilterType as s,IkasCampaignApplicablePrice as d,IkasCustomerPriceListRuleFilterType as p}from"@ikas/storefront-models";import{IkasProductVariantFunctions as f,IkasProductPriceFunctions as m}from"@ikas/storefront-model-functions";import{IkasStorefrontConfig as b}from"@ikas/storefront-config";import{saveProductBackInStockRemind as v,listProductBackInStockRemind as h}from"@ikas/storefront-api";import g from"lodash/groupBy";import y from"lodash/sortBy";import{IkasProductVariantUnit as P}from"./unit/index.js";import{formatCurrency as I}from"../../../../utils/currency.js";import{makeAutoObservable as S}from"mobx";import{IkasBaseStore as O}from"../../../../store/base.js";import"../../../../store/customer/index.js";import"../../../../store/cart/index.js";var j=function(){function j(e){void 0===e&&(e={}),this._backInStockReminderSaved=!1,this.product=null,this.id=e.id||Date.now()+"",this.productId=e.productId||"",this.sku=e.sku||null,this.barcodeList=e.barcodeList||[],this.baseBundlePrices=e.baseBundlePrices?e.baseBundlePrices.map((function(e){return new r(e)})):[],this.bundleSettings=e.bundleSettings?new u(e.bundleSettings):null,this.variantValues=e.variantValues?e.variantValues.map((function(e){return new n(e)})):[],this.images=e.images?e.images.map((function(e){return new c(e)})):[],this.attributes=e.attributes?e.attributes.map((function(e){return new o(e)})):[],this.prices=e.prices?e.prices.map((function(e){return new r(e)})):[],this.stock=e.stock||0,this.isActive=void 0===e.isActive||e.isActive,this.campaigns=e.campaigns||[],this.unit=e.unit?new P(e.unit):null,this.sellIfOutOfStock=e.sellIfOutOfStock||!1,this.images=y(this.images,"order"),S(this)}return Object.defineProperty(j.prototype,"mainImage",{get:function(){var e=f.getMainImage(this);return e?new c(e):void 0},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"hasStock",{get:function(){return f.hasStock(this)},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"isBackInStockEnabled",{get:function(){return b.isBackInStockEnabled()},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"isBackInStockCustomerLoginRequired",{get:function(){return b.isCustomerLoginRequiredForBackInStock()},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"isBackInStockReminderSaved",{get:function(){return this._backInStockReminderSaved},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"groupedAttributeValues",{get:function(){var e,t=g(this.attributes,"productAttributeId");return(null===(e=this.attributes)||void 0===e?void 0:e.map((function(e){var i=e.productAttributeId;if(i){var r=t[i];return(null==r?void 0:r.length)&&r[0].productAttribute?{attribute:r[0].productAttribute,values:r}:void 0}})).filter((function(e){return!!e})))||[]},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"b2bPriceRule",{get:function(){var e,t,i=this,r=O.getInstance().customerStore.customer,n=null==r?void 0:r.priceListRules,o=function(e){var t,r,n,o;if(e.type===p.CATEGORY)return c=null===(t=e.valueList)||void 0===t?void 0:t.some((function(e){var t;return null===(t=i.product)||void 0===t?void 0:t.categories.find((function(t){return t.id===e}))}));if(e.type===p.PRODUCT)return c=null===(r=e.valueList)||void 0===r?void 0:r.some((function(e){return i.id===e}));if(e.type===p.PRODUCT_BRAND){var c=null===(n=e.valueList)||void 0===n?void 0:n.some((function(e){var t,r;return(null===(r=null===(t=i.product)||void 0===t?void 0:t.brand)||void 0===r?void 0:r.id)===e}));return c}if(e.type===p.PRODUCT_TAG){c=null===(o=e.valueList)||void 0===o?void 0:o.some((function(e){var t,r;return null===(r=null===(t=i.product)||void 0===t?void 0:t.tags)||void 0===r?void 0:r.find((function(t){return t.id===e}))}));return c}};if(n){for(var c=0,u=n;c<u.length;c++){var l=u[c];if(l.shouldMatchAllFilters?null===(e=l.filters)||void 0===e?void 0:e.every(o):null===(t=l.filters)||void 0===t?void 0:t.some(o))return l}return null}return null},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"price",{get:function(){var e,t;if(b.isB2BStorefront()){var i=O.getInstance().customerStore.customer;if(null==i?void 0:i.priceListId){var r=null===(e=this.prices)||void 0===e?void 0:e.find((function(e){return e.priceListId===i.priceListId}));if(r)return r}}return null===(t=this.prices)||void 0===t?void 0:t.find((function(e){return b.getPriceListId()?e.priceListId===b.getPriceListId():null===e.priceListId}))},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"bundlePrice",{get:function(){var e,t;if(b.isB2BStorefront()){var i=O.getInstance().customerStore.customer;if(null==i?void 0:i.priceListId){var r=null===(e=this.baseBundlePrices)||void 0===e?void 0:e.find((function(e){return e.priceListId===i.priceListId}));if(r)return r}}return(null===(t=this.baseBundlePrices)||void 0===t?void 0:t.find((function(e){return b.getPriceListId()?e.priceListId===b.getPriceListId():null===e.priceListId})))||this.price},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"finalPrice",{get:function(){var e=0;this.bundleSettings&&this.bundleSettings.products.every((function(e){return!!e.product}))?e=m.getFinalPrice(this.bundlePrice)+this.bundleSettings.products.reduce((function(e,t){return e+(t.addToBundleBasePrice?t.finalPriceWithQuantity:0)}),0):e=m.getFinalPrice(this.price);if(!this.b2bPriceRule)return e;switch(this.b2bPriceRule.valueType){case l.DISCOUNT_RATE:return e*((100-this.b2bPriceRule.value)/100);case l.DISCOUNT_AMOUNT:return e-this.b2bPriceRule.value;case l.FIXED_PRICE:return this.b2bPriceRule.value;default:return e}},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"formattedFinalPrice",{get:function(){return I(this.finalPrice,this.price.currency||"",this.price.currencySymbol||"")},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"sellPrice",{get:function(){return this.bundleSettings&&this.bundleSettings.products.every((function(e){return!!e.product}))?this.bundlePrice.sellPrice+this.bundleSettings.products.reduce((function(e,t){return e+(t.addToBundleBasePrice?t.sellPriceWithQuantity:0)}),0):this.price.sellPrice},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"formattedSellPrice",{get:function(){return I(this.sellPrice,this.price.currency||"",this.price.currencySymbol||"")},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"formattedBuyPrice",{get:function(){return I(this.price.buyPrice||0,this.price.currency||"",this.price.currencySymbol||"")},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"appliedCampaignAmount",{get:function(){var e,t,i,r,n,o,c,u=this;if(!(null===(e=this.price.campaignPrice)||void 0===e?void 0:e.campaignId))return null;var l=(null===(r=null===(i=null===(t=this.product)||void 0===t?void 0:t.campaigns)||void 0===i?void 0:i.find((function(e){var t;return e.campaign.id===(null===(t=u.price.campaignPrice)||void 0===t?void 0:t.campaignId)})))||void 0===r?void 0:r.campaign)||null;if(!l)return null;var s={type:l.type,formattedPrice:null,discountPercentage:null};return l.type===a.FIXED_AMOUNT&&(s.formattedPrice=I((null===(n=l.fixedDiscount)||void 0===n?void 0:n.amount)||0,this.price.currency||"",this.price.currencySymbol||"")),l.type===a.RATIO&&(s.discountPercentage=(null===(c=null===(o=l.fixedDiscount)||void 0===o?void 0:o.amount)||void 0===c?void 0:c.toString())||null),s},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"campaignPrice",{get:function(){var e;return(null===(e=this.price.campaignPrice)||void 0===e?void 0:e.campaignPrice)||null},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"formattedCampaignPrice",{get:function(){return I(this.campaignPrice||0,this.price.currency||"",this.price.currencySymbol||"")},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"discountPrice",{get:function(){return this.finalPrice===this.sellPrice?null:this.finalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"formattedDiscountPrice",{get:function(){return I(this.discountPrice||0,this.price.currency||"",this.price.currencySymbol||"")},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"hasDiscount",{get:function(){return this.finalPrice!==this.sellPrice},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"discountAmount",{get:function(){return this.hasDiscount?this.sellPrice-this.finalPrice:0},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"discountPercentage",{get:function(){return this.hasDiscount?(100-100*this.finalPrice/this.sellPrice).toFixed(0):0},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"finalPriceWithCampaignOffers",{get:function(){var e,t;return this.finalPrice+((null===(t=null===(e=this.product)||void 0===e?void 0:e.offers)||void 0===t?void 0:t.filter((function(e){return e.isSelected&&!e.isAccepted})).reduce((function(e,t){return e+t.product.selectedVariant.finalPrice}),0))||0)},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"formattedFinalPriceWithCampaignOffers",{get:function(){return I(this.finalPriceWithCampaignOffers,this.price.currency||"",this.price.currencySymbol||"")},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"sellPriceWithCampaignOffers",{get:function(){var e,t;return this.sellPrice+((null===(t=null===(e=this.product)||void 0===e?void 0:e.offers)||void 0===t?void 0:t.filter((function(e){return e.isSelected&&!e.isAccepted})).reduce((function(e,t){return e+t.product.selectedVariant.sellPrice}),0))||0)},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"formattedSellPriceWithCampaignOffers",{get:function(){return I(this.sellPriceWithCampaignOffers,this.price.currency||"",this.price.currencySymbol||"")},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"campaignOffersDiscountPercentage",{get:function(){return this.finalPriceWithCampaignOffers!==this.sellPriceWithCampaignOffers?(100-100*this.finalPriceWithCampaignOffers/this.sellPriceWithCampaignOffers).toFixed(0):0},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"tieredDiscountProducts",{get:function(){var e,t,i,r,n=this,o=null===(i=null===(t=null===(e=this.product)||void 0===e?void 0:e.campaigns)||void 0===t?void 0:t.find((function(e){return!!e.campaign.tieredDiscount})))||void 0===i?void 0:i.campaign,c=null===(r=null==o?void 0:o.tieredDiscount)||void 0===r?void 0:r.filters;if(c){var u=c.find((function(e){return e.type===s.PRODUCT_AND_VARIANT}));if(u){var l=[];if(u.idList.map((function(e){l.push(e.replace("p:","").replace("v:",""))})),!l.some((function(e){return n.id===e||n.productId===e})))return[]}}return o&&o.tieredDiscount?o.tieredDiscount.rules.map((function(e){var t,i,r,c,u=o.applicablePrice===d.SELL_PRICE?n.sellPrice:n.finalPrice,l=u*((null===(t=e.lineItemQuantityRange)||void 0===t?void 0:t.min)||1),s=I(u,n.price.currency||"",n.price.currencySymbol||""),p=I(l,n.price.currency||"",n.price.currencySymbol||""),f=o.type===a.RATIO?u-u*(e.amount||1)/100:u,m=f*((null===(i=e.lineItemQuantityRange)||void 0===i?void 0:i.min)||1)-(o.type===a.FIXED_AMOUNT&&e.amount||0),b=I(f,n.price.currency||"",n.price.currencySymbol||""),v=I(m,n.price.currency||"",n.price.currencySymbol||"");return{amount:e.amount,lineItemQuantityRange:{min:(null===(r=e.lineItemQuantityRange)||void 0===r?void 0:r.min)||0,max:(null===(c=e.lineItemQuantityRange)||void 0===c?void 0:c.max)||0},type:o.type,sellPrice:u,finalPrice:f,sellPriceWithQuantity:l,finalPriceWithQuantity:m,formattedSellPrice:s,formattedSellPriceWithQuantity:p,formattedFinalPrice:b,formattedFinalPriceWithQuantity:v}})):[]},enumerable:!1,configurable:!0}),j.prototype.saveBackInStockReminder=function(i){var r;return e(this,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,h({email:{eq:i},productId:{eq:this.productId},variantId:{eq:this.id}})];case 1:return(e=t.sent())&&(null===(r=e.data)||void 0===r?void 0:r.length)?(this._backInStockReminderSaved=!0,[2,!1]):[3,2];case 2:return[4,v({input:{email:i,productId:this.productId,variantId:this.id}})];case 3:return t.sent().isSuccess?(this._backInStockReminderSaved=!0,[2,!0]):(this._backInStockReminderSaved=!1,[2,!1]);case 4:return[2]}}))}))},j.prototype.toJSON=function(){var e=i({},this);return delete e.product,e},j}();export{j as IkasProductVariant};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__extends as e}from'./../../../ext/tslib/tslib.es6.js';import{IkasBaseModel as
|
|
1
|
+
import{__extends as e}from'./../../../ext/tslib/tslib.es6.js';import{IkasBaseModel as r}from"../base/index.js";import{IkasStorefrontPopupAnalytics as o}from"./storefront-popup-analytics/index.js";import{IkasStorefrontPopupDateFilter as p}from"./storefront-popup-date-filter/index.js";import{IkasStorefrontPopupDisplayFilter as s}from"./storefront-popup-display-filter/index.js";import{IkasStorefrontPopupDisplaySettings as d}from"./storefront-popup-display-settings/index.js";import{IkasStorefrontPopupPageFilter as n}from"./storefront-popup-page-filter/index.js";import{IkasStorefrontPopupRouting as i}from"./storefront-popup-routing/index.js";import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/components/index.js';import'./../../../ext/@ikas/popup-renderer/build/ext/tslib/tslib.es6.mjs.js';import'./../../../ext/@ikas/popup-renderer/build/ext/libphonenumber-js/es6/PhoneNumberMatcher.js';import'./../../../ext/@ikas/popup-renderer/build/ext/libphonenumber-js/es6/AsYouTypeFormatter.js';import'./../../../ext/@ikas/popup-renderer/build/ext/libphonenumber-js/es6/ParseError.js';import'./../../../ext/@ikas/popup-renderer/build/ext/libphonenumber-js/es6/metadata.js';import'./../../../ext/@ikas/popup-renderer/build/ext/libphonenumber-js/es6/PhoneNumber.js';import'./../../../ext/@ikas/popup-renderer/build/ext/libphonenumber-js/min/exports/PhoneNumberMatcher.js';import'./../../../ext/@ikas/popup-renderer/build/ext/libphonenumber-js/min/exports/AsYouType.js';import'./../../../ext/@ikas/popup-renderer/build/ext/libphonenumber-js/min/exports/Metadata.js';import'./../../../ext/@ikas/popup-renderer/build/ext/libphonenumber-js/es6/findNumbers/isValidCandidate.js';import'./../../../ext/@ikas/popup-renderer/build/ext/libphonenumber-js/index.es6.exports/PhoneNumberSearch.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/base/index.js';import{Popup as t}from'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/settings/index.js';import"mobx";import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/settings/visibility-condition/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/teaser/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/button/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/divider/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/form/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/form/checkbox/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/form/customer-attribute/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/form/customer-gender/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/image/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/image-column/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/product/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/product/detail-settings/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/social/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/space/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/text/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/background-settings/index.js';import'./../../../ext/@ikas/popup-renderer/build/popup-renderer/models/modal/close-settings/index.js';import{IkasStorefrontConfig as l}from"@ikas/storefront-config";var u,m,a,b=function(r){function b(e){var b,j=this;(j=r.call(this,e)||this).analytics=e.analytics?new o(e.analytics):null,j.dateFilter=e.dateFilter?new p(e.dateFilter):null,j.displayFilters=e.displayFilters?e.displayFilters.map((function(e){return new s(e)})):null,j.displaySettings=e.displaySettings?new d(e.displaySettings):new d,j.name=e.name||"",j.pageFilters=e.pageFilters?e.pageFilters.map((function(e){return new n(e)})):null,j.status=e.status||u.ACTIVE,j.storefrontRoutings=e.storefrontRoutings?e.storefrontRoutings.map((function(e){return new i(e)})):[],j.type=e.type||m.FORM,j.visibleDevice=e.visibleDevice||a.ALL;var x=(null===(b=l.getMerchantSettings())||void 0===b?void 0:b.merchantId)||"",_=l.getCdnUrl()||"";return j.contentJson=e.contentJson?new t(e.contentJson,_,x):null,j}return e(b,r),b}(r);!function(e){e.ACTIVE="ACTIVE",e.DRAFT="DRAFT",e.PASSIVE="PASSIVE"}(u||(u={})),function(e){e.FORM="FORM",e.NOTIFICATION="NOTIFICATION",e.NOTIFICATION_BAR="NOTIFICATION_BAR",e.PAGE_OVERLAY="PAGE_OVERLAY",e.POPUP="POPUP"}(m||(m={})),function(e){e.ALL="ALL",e.DESKTOP="DESKTOP",e.MOBILE="MOBILE"}(a||(a={}));export{b as IkasStorefrontPopup,a as IkasStorefrontPopupDeviceTypeEnum,u as IkasStorefrontPopupStatusEnum,m as IkasStorefrontPopupTypeEnum};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{IkasStorefrontPopupPageFilterData as
|
|
1
|
+
import{IkasStorefrontPopupPageFilterData as T}from"./storefront-popup-page-filter-data/index.js";var C,t=function(t){void 0===t&&(t={}),this.filters=t.filters?t.filters.map((function(C){return new T(C)})):null,this.pageType=t.pageType||C.ACCOUNT};!function(T){T.ACCOUNT="ACCOUNT",T.CART="CART",T.CATEGORY="CATEGORY",T.CUSTOM="CUSTOM",T.HOME="HOME",T.PRODUCT="PRODUCT",T.PRODUCT_BRAND="PRODUCT_BRAND",T.REGISTER="REGISTER",T.LOGIN="LOGIN"}(C||(C={}));export{t as IkasStorefrontPopupPageFilter,C as IkasStorefrontPopupPageFilterTypeEnum};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ikas/storefront",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.15",
|
|
4
4
|
"description": "Storefront functionality for ikas storefront themes.",
|
|
5
5
|
"author": "ikas",
|
|
6
6
|
"license": "ISC",
|
|
@@ -17,15 +17,15 @@
|
|
|
17
17
|
"build": "rm -rf build && rollup -c"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@ikas/popup-renderer": "^1.0.
|
|
20
|
+
"@ikas/popup-renderer": "^1.0.154",
|
|
21
21
|
"swiper": "11.0.6"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@ikas/storefront-api": "^5.0.
|
|
25
|
-
"@ikas/storefront-config": "^5.0.
|
|
26
|
-
"@ikas/storefront-model-functions": "^5.0.
|
|
27
|
-
"@ikas/storefront-models": "^5.0.
|
|
28
|
-
"@ikas/storefront-providers": "^5.0.
|
|
24
|
+
"@ikas/storefront-api": "^5.0.15",
|
|
25
|
+
"@ikas/storefront-config": "^5.0.15",
|
|
26
|
+
"@ikas/storefront-model-functions": "^5.0.15",
|
|
27
|
+
"@ikas/storefront-models": "^5.0.15",
|
|
28
|
+
"@ikas/storefront-providers": "^5.0.15",
|
|
29
29
|
"@ikas/localized-address": "1.0.0-beta.3",
|
|
30
30
|
"@adyen/adyen-web": "^5.57.0",
|
|
31
31
|
"@rollup/plugin-commonjs": "^22.0.0",
|
|
@@ -60,11 +60,11 @@
|
|
|
60
60
|
},
|
|
61
61
|
"peerDependencies": {
|
|
62
62
|
"@ikas/localized-address": "1.0.0-beta.3",
|
|
63
|
-
"@ikas/storefront-api": "^5.0.
|
|
64
|
-
"@ikas/storefront-config": "^5.0.
|
|
65
|
-
"@ikas/storefront-model-functions": "^5.0.
|
|
66
|
-
"@ikas/storefront-models": "^5.0.
|
|
67
|
-
"@ikas/storefront-providers": "^5.0.
|
|
63
|
+
"@ikas/storefront-api": "^5.0.15",
|
|
64
|
+
"@ikas/storefront-config": "^5.0.15",
|
|
65
|
+
"@ikas/storefront-model-functions": "^5.0.15",
|
|
66
|
+
"@ikas/storefront-models": "^5.0.15",
|
|
67
|
+
"@ikas/storefront-providers": "^5.0.15",
|
|
68
68
|
"mobx": "^6.1.3",
|
|
69
69
|
"mobx-react-lite": "^3.1.5",
|
|
70
70
|
"next": "12.2.0",
|