@ikas/storefront-model-functions 6.1.0-beta.12 → 6.1.0-beta.14
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{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
|
|
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};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ikas/storefront-model-functions",
|
|
3
|
-
"version": "6.1.0-beta.
|
|
3
|
+
"version": "6.1.0-beta.14",
|
|
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.
|
|
20
|
-
"@ikas/storefront-models": "^6.1.0-beta.
|
|
19
|
+
"@ikas/storefront-config": "^6.1.0-beta.14",
|
|
20
|
+
"@ikas/storefront-models": "^6.1.0-beta.14",
|
|
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.
|
|
37
|
-
"@ikas/storefront-models": "^6.1.0-beta.
|
|
36
|
+
"@ikas/storefront-config": "^6.1.0-beta.14",
|
|
37
|
+
"@ikas/storefront-models": "^6.1.0-beta.14",
|
|
38
38
|
"lodash": "^4.17.21"
|
|
39
39
|
}
|
|
40
40
|
}
|