@sentecacommerce-theme/lib 0.13.9 → 0.13.10
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/dist/cjs/hooks/useLineItem/LineItemContext.js +3 -2
- package/dist/cjs/hooks/useProduct/index.js +2 -1
- package/dist/cjs/hooks/useProductVariants/index.js +17 -1
- package/dist/esm/hooks/useLineItem/LineItemContext.js +3 -2
- package/dist/esm/hooks/useProduct/index.js +2 -1
- package/dist/esm/hooks/useProductVariants/index.js +17 -1
- package/dist/types/hooks/useLineItem/LineItemContext.d.ts +2 -1
- package/dist/types/hooks/useProduct/index.d.ts +2 -1
- package/dist/types/hooks/useProductVariants/index.d.ts +2 -0
- package/package.json +4 -4
@@ -48,7 +48,7 @@ function LineItemStateProvider(param) {
|
|
48
48
|
product: product,
|
49
49
|
defaultVariantId: product.variantId,
|
50
50
|
isLineItem: true
|
51
|
-
}), variants = ref.variants, selectedVariant = ref.selectedVariant, getVariantById = ref.getVariantById, getVariantByAttribute = ref.getVariantByAttribute, getVariantByCombination = ref.getVariantByCombination, selectVariantById = ref.selectVariantById, selectVariantByAttribute = ref.selectVariantByAttribute, selectVariantByCombination = ref.selectVariantByCombination;
|
51
|
+
}), variants = ref.variants, selectedVariant = ref.selectedVariant, getVariantById = ref.getVariantById, getVariantByAttribute = ref.getVariantByAttribute, getVariantByCombination = ref.getVariantByCombination, selectVariantById = ref.selectVariantById, selectVariantByAttribute = ref.selectVariantByAttribute, selectVariantByCombination = ref.selectVariantByCombination, getAllPossibleSizesForCurrentVariant = ref.getAllPossibleSizesForCurrentVariant;
|
52
52
|
var state = {
|
53
53
|
variants: variants,
|
54
54
|
selectedVariant: _objectSpread({}, selectedVariant, {
|
@@ -62,7 +62,8 @@ function LineItemStateProvider(param) {
|
|
62
62
|
getVariantByCombination: getVariantByCombination,
|
63
63
|
selectVariantById: selectVariantById,
|
64
64
|
selectVariantByAttribute: selectVariantByAttribute,
|
65
|
-
selectVariantByCombination: selectVariantByCombination
|
65
|
+
selectVariantByCombination: selectVariantByCombination,
|
66
|
+
getAllPossibleSizesForCurrentVariant: getAllPossibleSizesForCurrentVariant
|
66
67
|
};
|
67
68
|
return(/*#__PURE__*/ _react.default.createElement(LineItemStateContext.Provider, {
|
68
69
|
value: state
|
@@ -23,7 +23,7 @@ function ProductProvider(param) {
|
|
23
23
|
var ref38 = (0, _useProductVariants).useProductVariants({
|
24
24
|
product: product,
|
25
25
|
defaultVariantId: defaultVariantId
|
26
|
-
}), selectedVariant = ref38.selectedVariant, attributeRules = ref38.attributeRules, variants = ref38.variants, getVariantById = ref38.getVariantById, getVariantByAttribute = ref38.getVariantByAttribute, getVariantByCombination = ref38.getVariantByCombination, getCustomFieldValue = ref38.getCustomFieldValue, getCombinationsForAttributeRule = ref38.getCombinationsForAttributeRule, selectVariantById = ref38.selectVariantById, selectVariantByAttribute = ref38.selectVariantByAttribute, selectVariantByCombination = ref38.selectVariantByCombination, selectVariantOptions = ref38.selectVariantOptions;
|
26
|
+
}), selectedVariant = ref38.selectedVariant, attributeRules = ref38.attributeRules, variants = ref38.variants, getVariantById = ref38.getVariantById, getVariantByAttribute = ref38.getVariantByAttribute, getVariantByCombination = ref38.getVariantByCombination, getCustomFieldValue = ref38.getCustomFieldValue, getCombinationsForAttributeRule = ref38.getCombinationsForAttributeRule, selectVariantById = ref38.selectVariantById, selectVariantByAttribute = ref38.selectVariantByAttribute, getAllPossibleSizesForCurrentVariant = ref38.getAllPossibleSizesForCurrentVariant, selectVariantByCombination = ref38.selectVariantByCombination, selectVariantOptions = ref38.selectVariantOptions;
|
27
27
|
var metaData = _react.default.useMemo(function() {
|
28
28
|
var ref, ref1, ref2, ref3, ref4, ref5, ref6, ref7, ref8, ref9, ref10, ref11, ref12, ref13, ref14, ref15, ref16, ref17, ref18, ref19, ref20, ref21, ref22, ref23, ref24, ref25, ref26, ref27, ref28, ref29, ref30, ref31, ref32, ref33, ref34, ref35, ref36, ref37;
|
29
29
|
var rootCategory = product === null || product === void 0 ? void 0 : (ref = product.categories) === null || ref === void 0 ? void 0 : ref[0];
|
@@ -99,6 +99,7 @@ function ProductProvider(param) {
|
|
99
99
|
selectVariantById: selectVariantById,
|
100
100
|
selectVariantByAttribute: selectVariantByAttribute,
|
101
101
|
selectVariantByCombination: selectVariantByCombination,
|
102
|
+
getAllPossibleSizesForCurrentVariant: getAllPossibleSizesForCurrentVariant,
|
102
103
|
getCombinationsForAttributeRule: getCombinationsForAttributeRule,
|
103
104
|
selectVariantOptions: selectVariantOptions,
|
104
105
|
getCustomFieldValue: getCustomFieldValue,
|
@@ -222,6 +222,21 @@ var useProductVariants = function(param) {
|
|
222
222
|
function selectVariantById(id) {
|
223
223
|
setSelectedVariant(variants[id]);
|
224
224
|
}
|
225
|
+
function getAllPossibleSizesForCurrentVariant(key) {
|
226
|
+
var split = key.split(':');
|
227
|
+
if (split[0] === 'collapseKey') {
|
228
|
+
var currentProduct = Object.keys(variants).filter(function(el) {
|
229
|
+
return variants[el].collapseKey === split[1];
|
230
|
+
}) || '';
|
231
|
+
return currentProduct.reduce(function(res, cur) {
|
232
|
+
res.push(variants[cur].attributes.find(function(a) {
|
233
|
+
return a.name === 'size';
|
234
|
+
}));
|
235
|
+
return res;
|
236
|
+
}, []);
|
237
|
+
}
|
238
|
+
return [];
|
239
|
+
}
|
225
240
|
function selectVariantByCombination(key, value) {
|
226
241
|
// Take collapseKey for SD
|
227
242
|
var split = value.split(':');
|
@@ -328,7 +343,8 @@ var useProductVariants = function(param) {
|
|
328
343
|
selectVariantByAttribute: selectVariantByAttribute,
|
329
344
|
selectVariantByCombination: selectVariantByCombination,
|
330
345
|
selectVariantOptions: selectVariantOptions,
|
331
|
-
selectVariantById: selectVariantById
|
346
|
+
selectVariantById: selectVariantById,
|
347
|
+
getAllPossibleSizesForCurrentVariant: getAllPossibleSizesForCurrentVariant
|
332
348
|
};
|
333
349
|
};
|
334
350
|
exports.useProductVariants = useProductVariants;
|
@@ -37,7 +37,7 @@ export function LineItemStateProvider(param) {
|
|
37
37
|
product: product,
|
38
38
|
defaultVariantId: product.variantId,
|
39
39
|
isLineItem: true
|
40
|
-
}), variants = ref.variants, selectedVariant = ref.selectedVariant, getVariantById = ref.getVariantById, getVariantByAttribute = ref.getVariantByAttribute, getVariantByCombination = ref.getVariantByCombination, selectVariantById = ref.selectVariantById, selectVariantByAttribute = ref.selectVariantByAttribute, selectVariantByCombination = ref.selectVariantByCombination;
|
40
|
+
}), variants = ref.variants, selectedVariant = ref.selectedVariant, getVariantById = ref.getVariantById, getVariantByAttribute = ref.getVariantByAttribute, getVariantByCombination = ref.getVariantByCombination, selectVariantById = ref.selectVariantById, selectVariantByAttribute = ref.selectVariantByAttribute, selectVariantByCombination = ref.selectVariantByCombination, getAllPossibleSizesForCurrentVariant = ref.getAllPossibleSizesForCurrentVariant;
|
41
41
|
var state = {
|
42
42
|
variants: variants,
|
43
43
|
selectedVariant: _objectSpread({}, selectedVariant, {
|
@@ -51,7 +51,8 @@ export function LineItemStateProvider(param) {
|
|
51
51
|
getVariantByCombination: getVariantByCombination,
|
52
52
|
selectVariantById: selectVariantById,
|
53
53
|
selectVariantByAttribute: selectVariantByAttribute,
|
54
|
-
selectVariantByCombination: selectVariantByCombination
|
54
|
+
selectVariantByCombination: selectVariantByCombination,
|
55
|
+
getAllPossibleSizesForCurrentVariant: getAllPossibleSizesForCurrentVariant
|
55
56
|
};
|
56
57
|
return(/*#__PURE__*/ React.createElement(LineItemStateContext.Provider, {
|
57
58
|
value: state
|
@@ -11,7 +11,7 @@ export function ProductProvider(param) {
|
|
11
11
|
var ref38 = useProductVariants({
|
12
12
|
product: product,
|
13
13
|
defaultVariantId: defaultVariantId
|
14
|
-
}), selectedVariant = ref38.selectedVariant, attributeRules = ref38.attributeRules, variants = ref38.variants, getVariantById = ref38.getVariantById, getVariantByAttribute = ref38.getVariantByAttribute, getVariantByCombination = ref38.getVariantByCombination, getCustomFieldValue = ref38.getCustomFieldValue, getCombinationsForAttributeRule = ref38.getCombinationsForAttributeRule, selectVariantById = ref38.selectVariantById, selectVariantByAttribute = ref38.selectVariantByAttribute, selectVariantByCombination = ref38.selectVariantByCombination, selectVariantOptions = ref38.selectVariantOptions;
|
14
|
+
}), selectedVariant = ref38.selectedVariant, attributeRules = ref38.attributeRules, variants = ref38.variants, getVariantById = ref38.getVariantById, getVariantByAttribute = ref38.getVariantByAttribute, getVariantByCombination = ref38.getVariantByCombination, getCustomFieldValue = ref38.getCustomFieldValue, getCombinationsForAttributeRule = ref38.getCombinationsForAttributeRule, selectVariantById = ref38.selectVariantById, selectVariantByAttribute = ref38.selectVariantByAttribute, getAllPossibleSizesForCurrentVariant = ref38.getAllPossibleSizesForCurrentVariant, selectVariantByCombination = ref38.selectVariantByCombination, selectVariantOptions = ref38.selectVariantOptions;
|
15
15
|
var metaData = React.useMemo(function() {
|
16
16
|
var ref, ref1, ref2, ref3, ref4, ref5, ref6, ref7, ref8, ref9, ref10, ref11, ref12, ref13, ref14, ref15, ref16, ref17, ref18, ref19, ref20, ref21, ref22, ref23, ref24, ref25, ref26, ref27, ref28, ref29, ref30, ref31, ref32, ref33, ref34, ref35, ref36, ref37;
|
17
17
|
var rootCategory = product === null || product === void 0 ? void 0 : (ref = product.categories) === null || ref === void 0 ? void 0 : ref[0];
|
@@ -87,6 +87,7 @@ export function ProductProvider(param) {
|
|
87
87
|
selectVariantById: selectVariantById,
|
88
88
|
selectVariantByAttribute: selectVariantByAttribute,
|
89
89
|
selectVariantByCombination: selectVariantByCombination,
|
90
|
+
getAllPossibleSizesForCurrentVariant: getAllPossibleSizesForCurrentVariant,
|
90
91
|
getCombinationsForAttributeRule: getCombinationsForAttributeRule,
|
91
92
|
selectVariantOptions: selectVariantOptions,
|
92
93
|
getCustomFieldValue: getCustomFieldValue,
|
@@ -160,6 +160,21 @@ export var useProductVariants = function(param) {
|
|
160
160
|
var selectVariantById = function selectVariantById(id) {
|
161
161
|
setSelectedVariant(variants[id]);
|
162
162
|
};
|
163
|
+
var getAllPossibleSizesForCurrentVariant = function getAllPossibleSizesForCurrentVariant(key) {
|
164
|
+
var split = key.split(':');
|
165
|
+
if (split[0] === 'collapseKey') {
|
166
|
+
var currentProduct = Object.keys(variants).filter(function(el) {
|
167
|
+
return variants[el].collapseKey === split[1];
|
168
|
+
}) || '';
|
169
|
+
return currentProduct.reduce(function(res, cur) {
|
170
|
+
res.push(variants[cur].attributes.find(function(a) {
|
171
|
+
return a.name === 'size';
|
172
|
+
}));
|
173
|
+
return res;
|
174
|
+
}, []);
|
175
|
+
}
|
176
|
+
return [];
|
177
|
+
};
|
163
178
|
var selectVariantByCombination = function selectVariantByCombination(key, value) {
|
164
179
|
// Take collapseKey for SD
|
165
180
|
var split = value.split(':');
|
@@ -288,6 +303,7 @@ export var useProductVariants = function(param) {
|
|
288
303
|
selectVariantByAttribute: selectVariantByAttribute,
|
289
304
|
selectVariantByCombination: selectVariantByCombination,
|
290
305
|
selectVariantOptions: selectVariantOptions,
|
291
|
-
selectVariantById: selectVariantById
|
306
|
+
selectVariantById: selectVariantById,
|
307
|
+
getAllPossibleSizesForCurrentVariant: getAllPossibleSizesForCurrentVariant
|
292
308
|
};
|
293
309
|
};
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { VariantMap, VariantType } from '../useProductVariants';
|
2
|
-
import { SearchResultDTO } from '@sentecacommerce/sdk';
|
2
|
+
import { ProductAttributeDraftDTO, SearchResultDTO } from '@sentecacommerce/sdk';
|
3
3
|
import { LineItemType } from '../../';
|
4
4
|
declare type LineItemStateContextType = {
|
5
5
|
variants?: VariantMap;
|
@@ -9,6 +9,7 @@ declare type CountFunctionsContextType = {
|
|
9
9
|
selectVariantById: (id: string) => void;
|
10
10
|
selectVariantByAttribute: (key: string) => void;
|
11
11
|
selectVariantByCombination: (key: string, value: string) => void;
|
12
|
+
getAllPossibleSizesForCurrentVariant: (key: string) => ProductAttributeDraftDTO[];
|
12
13
|
getVariantById: (id: string) => VariantType;
|
13
14
|
getVariantByAttribute: (key: string) => VariantType;
|
14
15
|
getVariantByCombination: (key: string, value: string) => VariantType;
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import React from 'react';
|
2
|
-
import type { ProductDTO, ReviewRatingStatisticsDTO } from '@sentecacommerce/sdk';
|
2
|
+
import type { ProductAttributeDraftDTO, ProductDTO, ReviewRatingStatisticsDTO } from '@sentecacommerce/sdk';
|
3
3
|
import { getProductBySlugConfig } from '../../api/productsApi';
|
4
4
|
import { AssetsMap } from '../../utils/assetsToMap';
|
5
5
|
import { VariantMap, VariantType, ContentType, AttributeRulesMap } from '../useProductVariants';
|
@@ -75,6 +75,7 @@ export declare type VideoType = {
|
|
75
75
|
declare type CountFunctionsContextType = {
|
76
76
|
selectVariantById: (id: string) => void;
|
77
77
|
selectVariantByAttribute: (key: string) => void;
|
78
|
+
getAllPossibleSizesForCurrentVariant: (key: string) => ProductAttributeDraftDTO[];
|
78
79
|
selectVariantByCombination: (key: string, value: string) => void;
|
79
80
|
selectVariantOptions: (optionId: string, elementId: string) => void;
|
80
81
|
getVariantById: (id: string) => VariantType;
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import React from 'react';
|
2
|
+
import type { ProductAttributeDraftDTO } from '@sentecacommerce/sdk';
|
2
3
|
import { VariantType, BooleanKVP, VariantMap, AttributeRulesMap, CombinationsMap } from './types';
|
3
4
|
export * from './types';
|
4
5
|
export declare const useProductVariants: ({ product, defaultVariantId, isLineItem, }: {
|
@@ -31,4 +32,5 @@ export declare const useProductVariants: ({ product, defaultVariantId, isLineIte
|
|
31
32
|
selectVariantByCombination: (key: string, value: string) => void;
|
32
33
|
selectVariantOptions: (definitionKey: string, optionKey: string) => void;
|
33
34
|
selectVariantById: (id: string) => void;
|
35
|
+
getAllPossibleSizesForCurrentVariant: (key: string) => ProductAttributeDraftDTO[];
|
34
36
|
};
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@sentecacommerce-theme/lib",
|
3
3
|
"sideEffects": false,
|
4
|
-
"version": "0.13.
|
4
|
+
"version": "0.13.10",
|
5
5
|
"main": "dist/cjs/index.js",
|
6
6
|
"module": "dist/esm/index.js",
|
7
7
|
"types": "dist/types/index.d.ts",
|
@@ -31,13 +31,13 @@
|
|
31
31
|
"watch:cjs": "swc src --out-dir dist/cjs -w",
|
32
32
|
"watch:esm": "swc src --out-dir dist/esm --no-swcrc -w"
|
33
33
|
},
|
34
|
-
"gitHead": "
|
34
|
+
"gitHead": "670581c6389f24e706bbf7d72cc397c1acce32e7",
|
35
35
|
"peerDependencies": {
|
36
36
|
"react-query": "^2.26.2"
|
37
37
|
},
|
38
38
|
"dependencies": {
|
39
|
-
"@sentecacommerce-theme/base": "^0.13.
|
40
|
-
"@sentecacommerce-theme/cms": "^0.13.
|
39
|
+
"@sentecacommerce-theme/base": "^0.13.10",
|
40
|
+
"@sentecacommerce-theme/cms": "^0.13.10",
|
41
41
|
"@sentecacommerce/sdk": "2.0.175",
|
42
42
|
"body-scroll-lock": "^3.1.5",
|
43
43
|
"copy-to-clipboard": "^3.3.1",
|