@ikas/storefront-model-functions 6.1.0-beta.21 → 6.1.0-beta.211

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,4 +1,4 @@
1
1
  import { IkasImage } from "@ikas/storefront-models";
2
2
  export declare function getDefaultSrc(image: IkasImage): string;
3
3
  export declare function getThumbnailSrc(image: IkasImage): string;
4
- export declare function getSrc(image: IkasImage, size: number): string;
4
+ export declare function getSrc(image: IkasImage, size: number, lossless?: boolean): string;
@@ -1 +1 @@
1
- import{IkasStorefrontConfig as c}from"@ikas/storefront-config";function n(c){return i(c,1080)}function a(c){return i(c,180)}function i(n,a){var i,o=c.getCdnUrl();if(n.id.includes("/"))return n.isVideo?"".concat(o,"videos/").concat(n.id,"/original.mp4"):n.fileName?"".concat(o,"images/").concat(n.id,"/").concat(a,"/").concat(n.fileName,".webp"):"".concat(o,"images/").concat(n.id,"/image_").concat(a,".webp");var t=null===(i=c.getMerchantSettings())||void 0===i?void 0:i.merchantId;return n.isVideo?"".concat(o,"videos/").concat(t,"/").concat(n.id,"/original.mp4"):n.fileName?"".concat(o,"images/").concat(t,"/").concat(n.id,"/").concat(a,"/").concat(n.fileName,".webp"):"".concat(o,"images/").concat(t,"/").concat(n.id,"/image_").concat(a,".webp")}export{n as getDefaultSrc,i as getSrc,a as getThumbnailSrc};
1
+ import{IkasStorefrontConfig as c}from"@ikas/storefront-config";function n(c){return i(c,1080)}function a(c){return i(c,180)}function i(n,a,i){var o;void 0===i&&(i=!1);var t=i?a+"L":a,e=c.getCdnUrl();if(n.id.includes("/"))return n.isVideo?"".concat(e,"videos/").concat(n.id,"/original.mp4"):n.fileName?"".concat(e,"images/").concat(n.id,"/").concat(t,"/").concat(n.fileName,".webp"):"".concat(e,"images/").concat(n.id,"/image_").concat(t,".webp");var r=null===(o=c.getMerchantSettings())||void 0===o?void 0:o.merchantId;return n.isVideo?"".concat(e,"videos/").concat(r,"/").concat(n.id,"/original.mp4"):n.fileName?"".concat(e,"images/").concat(r,"/").concat(n.id,"/").concat(t,"/").concat(n.fileName,".webp"):"".concat(e,"images/").concat(r,"/").concat(n.id,"/image_").concat(t,".webp")}export{n as getDefaultSrc,i as getSrc,a as getThumbnailSrc};
@@ -1,6 +1,7 @@
1
1
  import { IkasApplicableProductFilterValue, IkasFilterRangeValue, IkasProductFilter, IkasProductFilterDisplayType, IkasProductFilterNumberRangeListOption, IkasProductFilterType } from "@ikas/storefront-models";
2
2
  export declare function isCustomValueFilter(filter: IkasProductFilter): boolean;
3
3
  export declare function isStockFilter(filter: IkasProductFilter): boolean;
4
+ export declare function isDiscountStatusFilter(filter: IkasProductFilter): boolean;
4
5
  export declare function getValueList(filter: IkasProductFilter): string[];
5
6
  export declare function getKeyList(filter: IkasProductFilter): string[];
6
7
  export declare function getDisplayedValues(filter: IkasProductFilter): IkasApplicableProductFilterValue[];
@@ -13,6 +14,7 @@ export declare function applyQueryParam(filter: IkasProductFilter, value: string
13
14
  export declare function rangeToId(range: IkasFilterRangeValue): string;
14
15
  export declare function parseRangeStr(rangeStr: string): IkasFilterRangeValue;
15
16
  export declare function getIkasFilterHref(value: IkasApplicableProductFilterValue): string;
17
+ export declare function getDiscountStatusMapping(): Record<string, string>;
16
18
  export declare type IkasSearchInputFilterListInput = {
17
19
  displayType?: IkasProductFilterDisplayType | null;
18
20
  id: string;
@@ -1 +1 @@
1
- import{IkasProductFilterDisplayType as e,IkasProductFilterType as n,IkasProductFilterSortType as t}from"@ikas/storefront-models";import i from"lodash/sortBy";import r from"lodash/cloneDeep";import{stringToSlug as o}from"../../../utils/helper.js";function u(n){return[e.NUMBER_RANGE_LIST,e.NUMBER_RANGE].includes(n.displayType)}function l(e){return e.type===n.STOCK_STATUS}function s(e){var n;return e.numberRange?[E(e.numberRange)]:e.numberRangeListOptions?e.numberRangeListOptions.filter((function(e){return e.isSelected})).map((function(e){return E(e)})):(null===(n=e.values)||void 0===n?void 0:n.filter((function(e){return e.isSelected})).map((function(e){return e.id})))||[]}function c(e){var n;return e.numberRange?[E(e.numberRange)]:e.numberRangeListOptions?e.numberRangeListOptions.filter((function(e){return e.isSelected})).map((function(e){return E(e)})):(null===(n=e.values)||void 0===n?void 0:n.filter((function(e){return e.isSelected})).map((function(e){return o(e.name)})))||[]}function a(e){var n,r,o,u=(null===(n=e.settings)||void 0===n?void 0:n.sortType)||t.ALPHABETICAL_ASC,l=[t.ALPHABETICAL_DESC,t.PRODUCT_COUNT_DESC].includes(u),s=[t.ALPHABETICAL_ASC,t.ALPHABETICAL_DESC].includes(u),c=u===t.CUSTOM_SORT,a=null===(r=e.values)||void 0===r?void 0:r.filter((function(e){return 0!==e.resultCount||e.isSelected}));if(a=i(a,s?"key":"resultCount"),l&&(a=null==a?void 0:a.reverse()),c){var d=(null===(o=e.settings)||void 0===o?void 0:o.customSortedValues)||[];a=a.sort((function(e,n){return d.indexOf(e.id)-d.indexOf(n.id)}))}return a}function d(e,n){var t;if(u(e))throw new Error("onFilterValueClick cannot be used with NUMBER_RANGE | NUMBER_RANGE_LIST types!");n.isSelected=!n.isSelected,!e.isMultiSelect&&n.isSelected&&(null===(t=e.values)||void 0===t||t.forEach((function(e){e.id!==n.id&&(e.isSelected=!1)})))}function f(n,t){var i;if(n.displayType!==e.NUMBER_RANGE_LIST)throw new Error("onNumberRangeClick can only be used with NUMBER_RANGE filters!");t.isSelected=!t.isSelected,!n.isMultiSelect&&t.isSelected&&(null===(i=n.numberRangeListOptions)||void 0===i||i.forEach((function(e){e.key!==t.key&&(e.isSelected=!1)})))}function m(n,t){var i;if(n.displayType!==e.NUMBER_RANGE)throw new Error("onNumberRangeChange can only be used with NUMBER_RANGE filters!");if(t){var o=r(t);o.from<n.numberRangeLimit.from&&(o.from=n.numberRange.from),o.to&&(null===(i=n.numberRangeLimit)||void 0===i?void 0:i.to)&&o.to>n.numberRangeLimit.to&&(o.to=n.numberRangeLimit.to),n.numberRange=o}else n.numberRange=null}function R(e){var n,t;e.numberRange=null,null===(n=e.numberRangeListOptions)||void 0===n||n.forEach((function(e){return e.isSelected=!1})),null===(t=e.values)||void 0===t||t.forEach((function(e){return e.isSelected=!1}))}function v(e){var n;return{id:e.key,type:e.type,valueList:s(e),useAndFilter:null===(n=e.settings)||void 0===n?void 0:n.useAndFilter}}function p(n,t){var i,r,u=t.split(",");n.displayType===e.NUMBER_RANGE?n.numberRange=S(t):n.displayType===e.NUMBER_RANGE_LIST?null===(i=n.numberRangeListOptions)||void 0===i||i.forEach((function(e){u.includes(e.key)&&(e.isSelected=!0)})):null===(r=n.values)||void 0===r||r.forEach((function(e){u.includes(o(e.name,!1))&&0!==e.resultCount&&(e.isSelected=!0)}))}function E(e){return"".concat(e.from,":").concat(e.to||"")}function S(e){try{var n=e.split(":").map((function(e){return parseInt(e)}));return{from:isNaN(n[0])?0:n[0],to:isNaN(n[1])?void 0:n[1]}}catch(e){return console.log(e),{from:0,to:0}}}function g(e){return e.slug?"/".concat(e.slug):""}export{p as applyQueryParam,R as clear,a as getDisplayedValues,g as getIkasFilterHref,c as getKeyList,s as getValueList,u as isCustomValueFilter,l as isStockFilter,d as onFilterValueClick,m as onNumberRangeChange,f as onNumberRangeClick,S as parseRangeStr,E as rangeToId,v as toInput};
1
+ import{IkasProductFilterDisplayType as e,IkasProductFilterType as n,IkasProductFilterSortType as t}from"@ikas/storefront-models";import i from"lodash/sortBy";import r from"lodash/cloneDeep";import{stringToSlug as o}from"../../../utils/helper.js";function u(n){return[e.NUMBER_RANGE_LIST,e.NUMBER_RANGE].includes(n.displayType)}function l(e){return e.type===n.STOCK_STATUS}function s(e){return e.type===n.DISCOUNT_STATUS}function c(e){var n;return e.numberRange?[S(e.numberRange)]:e.numberRangeListOptions?e.numberRangeListOptions.filter((function(e){return e.isSelected})).map((function(e){return S(e)})):(null===(n=e.values)||void 0===n?void 0:n.filter((function(e){return e.isSelected})).map((function(e){return e.id})))||[]}function a(e){var n;return e.numberRange?[S(e.numberRange)]:e.numberRangeListOptions?e.numberRangeListOptions.filter((function(e){return e.isSelected})).map((function(e){return S(e)})):(null===(n=e.values)||void 0===n?void 0:n.filter((function(e){return e.isSelected})).map((function(e){return o(e.name)})))||[]}function f(e){var n,r,o,u=(null===(n=e.settings)||void 0===n?void 0:n.sortType)||t.ALPHABETICAL_ASC,l=[t.ALPHABETICAL_DESC,t.PRODUCT_COUNT_DESC].includes(u),s=[t.ALPHABETICAL_ASC,t.ALPHABETICAL_DESC].includes(u),c=u===t.CUSTOM_SORT,a=null===(r=e.values)||void 0===r?void 0:r.filter((function(e){return 0!==e.resultCount||e.isSelected}));if(a=i(a,s?"key":"resultCount"),l&&(a=null==a?void 0:a.reverse()),c){var f=(null===(o=e.settings)||void 0===o?void 0:o.customSortedValues)||[];a=a.sort((function(e,n){return f.indexOf(e.id)-f.indexOf(n.id)}))}return a}function d(e,n){var t;if(u(e))throw new Error("onFilterValueClick cannot be used with NUMBER_RANGE | NUMBER_RANGE_LIST types!");n.isSelected=!n.isSelected,!e.isMultiSelect&&n.isSelected&&(null===(t=e.values)||void 0===t||t.forEach((function(e){e.id!==n.id&&(e.isSelected=!1)})))}function m(n,t){var i;if(n.displayType!==e.NUMBER_RANGE_LIST)throw new Error("onNumberRangeClick can only be used with NUMBER_RANGE filters!");t.isSelected=!t.isSelected,!n.isMultiSelect&&t.isSelected&&(null===(i=n.numberRangeListOptions)||void 0===i||i.forEach((function(e){e.key!==t.key&&(e.isSelected=!1)})))}function v(n,t){var i;if(n.displayType!==e.NUMBER_RANGE)throw new Error("onNumberRangeChange can only be used with NUMBER_RANGE filters!");if(t){var o=r(t);o.from<n.numberRangeLimit.from&&(o.from=n.numberRange.from),o.to&&(null===(i=n.numberRangeLimit)||void 0===i?void 0:i.to)&&o.to>n.numberRangeLimit.to&&(o.to=n.numberRangeLimit.to),n.numberRange=o}else n.numberRange=null}function R(e){var n,t;e.numberRange=null,null===(n=e.numberRangeListOptions)||void 0===n||n.forEach((function(e){return e.isSelected=!1})),null===(t=e.values)||void 0===t||t.forEach((function(e){return e.isSelected=!1}))}function p(e){var n;return{id:e.key,type:e.type,valueList:c(e),useAndFilter:null===(n=e.settings)||void 0===n?void 0:n.useAndFilter}}function E(n,t){var i,r,u=t.split(",");n.displayType===e.NUMBER_RANGE?n.numberRange=g(t):n.displayType===e.NUMBER_RANGE_LIST?null===(i=n.numberRangeListOptions)||void 0===i||i.forEach((function(e){u.includes(e.key)&&(e.isSelected=!0)})):null===(r=n.values)||void 0===r||r.forEach((function(e){var t=s(n),i=t?Object.fromEntries(Object.entries(N()).map((function(e){var n=e[0];return[e[1],n]}))):{};(t?u.map((function(e){return i[e]})):u).includes(o(e.name,!1))&&0!==e.resultCount&&(e.isSelected=!0)}))}function S(e){return"".concat(e.from,":").concat(e.to||"")}function g(e){try{var n=e.split(":").map((function(e){return parseInt(e)}));return{from:isNaN(n[0])?0:n[0],to:isNaN(n[1])?void 0:n[1]}}catch(e){return console.log(e),{from:0,to:0}}}function A(e){return e.slug?"/".concat(e.slug):""}function N(){return{"in-stock":"1","out-of-stock":"0"}}export{E as applyQueryParam,R as clear,N as getDiscountStatusMapping,f as getDisplayedValues,A as getIkasFilterHref,a as getKeyList,c as getValueList,u as isCustomValueFilter,s as isDiscountStatusFilter,l as isStockFilter,d as onFilterValueClick,v as onNumberRangeChange,m as onNumberRangeClick,g as parseRangeStr,S as rangeToId,p as toInput};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ikas/storefront-model-functions",
3
- "version": "6.1.0-beta.21",
3
+ "version": "6.1.0-beta.211",
4
4
  "description": "Functions for ikas storefront models.",
5
5
  "author": "ikas",
6
6
  "license": "ISC",
@@ -16,8 +16,8 @@
16
16
  "build": "rm -rf build && rollup -c"
17
17
  },
18
18
  "devDependencies": {
19
- "@ikas/storefront-config": "^6.1.0-beta.21",
20
- "@ikas/storefront-models": "^6.1.0-beta.21",
19
+ "@ikas/storefront-config": "^6.1.0-beta.211",
20
+ "@ikas/storefront-models": "^6.1.0-beta.211",
21
21
  "@rollup/plugin-node-resolve": "^13.3.0",
22
22
  "@rollup/plugin-commonjs": "^22.0.0",
23
23
  "rollup-plugin-rename-node-modules": "^1.2.0",
@@ -33,8 +33,8 @@
33
33
  "lodash": "^4.17.21"
34
34
  },
35
35
  "peerDependencies": {
36
- "@ikas/storefront-config": "^6.1.0-beta.21",
37
- "@ikas/storefront-models": "^6.1.0-beta.21",
36
+ "@ikas/storefront-config": "^6.1.0-beta.211",
37
+ "@ikas/storefront-models": "^6.1.0-beta.211",
38
38
  "lodash": "^4.17.21"
39
39
  }
40
40
  }