@sentecacommerce-theme/lib 0.14.4 → 0.14.7

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.
@@ -249,14 +249,15 @@ var WishlistApiFactory = function() {
249
249
  });
250
250
  },
251
251
  useIsExisting: function(productId, identifier) {
252
+ var useVariant = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : true;
252
253
  return (0, _reactQuery).useQuery([
253
254
  cacheKeys.useIsExisting,
254
255
  productId,
255
256
  identifier
256
257
  ], function() {
257
- var ref, ref1;
258
+ var ref, ref1, ref2;
258
259
  var parsedData = (0, _utils).readFromLocalStorage(WISHLIST_STORAGE_KEY);
259
- return !!(parsedData === null || parsedData === void 0 ? void 0 : (ref = parsedData.items) === null || ref === void 0 ? void 0 : (ref1 = ref[productId]) === null || ref1 === void 0 ? void 0 : ref1[identifier]);
260
+ return useVariant ? !!(parsedData === null || parsedData === void 0 ? void 0 : (ref = parsedData.items) === null || ref === void 0 ? void 0 : (ref1 = ref[productId]) === null || ref1 === void 0 ? void 0 : ref1[identifier]) : !!(parsedData === null || parsedData === void 0 ? void 0 : (ref2 = parsedData.items) === null || ref2 === void 0 ? void 0 : ref2[productId]);
260
261
  });
261
262
  }
262
263
  });
@@ -60,11 +60,12 @@ function _objectWithoutPropertiesLoose(source, excluded) {
60
60
  return target;
61
61
  }
62
62
  var useBasketItemWithErrorList = function() {
63
+ var ref;
63
64
  var _ref = _myCartApi.myCartApi.useGet(), data = _ref.data, rest = _objectWithoutProperties(_ref, [
64
65
  "data"
65
66
  ]);
66
67
  return _objectSpread({
67
- data: (data === null || data === void 0 ? void 0 : data.lineItems.filter(function(item) {
68
+ data: (data === null || data === void 0 ? void 0 : (ref = data.lineItems) === null || ref === void 0 ? void 0 : ref.filter(function(item) {
68
69
  return item.status !== _sdk.LineItemDTOStatusEnum.CanPurchase;
69
70
  })) || []
70
71
  }, rest);
@@ -50,10 +50,10 @@ function _unsupportedIterableToArray(o, minLen) {
50
50
  if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
51
51
  }
52
52
  var useWishlist = function(param) {
53
- var productId = param.productId, variantId = param.variantId, collapseKey = param.collapseKey, onAddCallback = param.onAddCallback, onRemoveCallback = param.onRemoveCallback;
53
+ var productId = param.productId, variantId = param.variantId, collapseKey = param.collapseKey, onAddCallback = param.onAddCallback, onRemoveCallback = param.onRemoveCallback, _useVariant = param.useVariant, useVariant = _useVariant === void 0 ? true : _useVariant;
54
54
  var ref = _slicedToArray(_wishlistApi.wishlistApi.useAdd(onAddCallback), 1), add = ref[0];
55
55
  var ref1 = _slicedToArray(_wishlistApi.wishlistApi.useRemove(onRemoveCallback), 1), remove = ref1[0];
56
- var ref2 = _wishlistApi.wishlistApi.useIsExisting(productId, collapseKey !== null && collapseKey !== void 0 ? collapseKey : variantId), isExisting = ref2.data;
56
+ var ref2 = _wishlistApi.wishlistApi.useIsExisting(productId, collapseKey !== null && collapseKey !== void 0 ? collapseKey : variantId, useVariant), isExisting = ref2.data;
57
57
  return {
58
58
  addToWishlist: function() {
59
59
  return add({
@@ -106,7 +106,7 @@ var buildCategoryQuery = function(param) {
106
106
  };
107
107
  var _obj;
108
108
  var query = (_obj = {}, _defineProperty(_obj, type, aggValue), _defineProperty(_obj, "filter", getFilters()), _obj);
109
- if (pageType === _index.ListingTypesEnum.Collection) {
109
+ if (pageType === _index.ListingTypesEnum.Collection && (config === null || config === void 0 ? void 0 : config.collapseMode)) {
110
110
  var collapseMode = config === null || config === void 0 ? void 0 : config.collapseMode;
111
111
  query = _objectSpread({}, query, {
112
112
  collapseMode: collapseMode
@@ -237,14 +237,15 @@ export var WishlistApiFactory = function() {
237
237
  });
238
238
  },
239
239
  useIsExisting: function(productId, identifier) {
240
+ var useVariant = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : true;
240
241
  return useQuery([
241
242
  cacheKeys.useIsExisting,
242
243
  productId,
243
244
  identifier
244
245
  ], function() {
245
- var ref, ref1;
246
+ var ref, ref1, ref2;
246
247
  var parsedData = readFromLocalStorage(WISHLIST_STORAGE_KEY);
247
- return !!(parsedData === null || parsedData === void 0 ? void 0 : (ref = parsedData.items) === null || ref === void 0 ? void 0 : (ref1 = ref[productId]) === null || ref1 === void 0 ? void 0 : ref1[identifier]);
248
+ return useVariant ? !!(parsedData === null || parsedData === void 0 ? void 0 : (ref = parsedData.items) === null || ref === void 0 ? void 0 : (ref1 = ref[productId]) === null || ref1 === void 0 ? void 0 : ref1[identifier]) : !!(parsedData === null || parsedData === void 0 ? void 0 : (ref2 = parsedData.items) === null || ref2 === void 0 ? void 0 : ref2[productId]);
248
249
  });
249
250
  }
250
251
  });
@@ -56,11 +56,12 @@ function _objectWithoutPropertiesLoose(source, excluded) {
56
56
  return target;
57
57
  }
58
58
  var useBasketItemWithErrorList = function() {
59
+ var ref;
59
60
  var _ref = myCartApi.useGet(), data = _ref.data, rest = _objectWithoutProperties(_ref, [
60
61
  "data"
61
62
  ]);
62
63
  return _objectSpread({
63
- data: (data === null || data === void 0 ? void 0 : data.lineItems.filter(function(item) {
64
+ data: (data === null || data === void 0 ? void 0 : (ref = data.lineItems) === null || ref === void 0 ? void 0 : ref.filter(function(item) {
64
65
  return item.status !== LineItemDTOStatusEnum.CanPurchase;
65
66
  })) || []
66
67
  }, rest);
@@ -1,4 +1,4 @@
1
- import { wishlistApi } from "../../../api/wishlistApi";
1
+ import { wishlistApi } from '../../../api/wishlistApi';
2
2
  function _arrayLikeToArray(arr, len) {
3
3
  if (len == null || len > arr.length) len = arr.length;
4
4
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
@@ -46,10 +46,10 @@ function _unsupportedIterableToArray(o, minLen) {
46
46
  if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
47
47
  }
48
48
  export var useWishlist = function(param) {
49
- var productId = param.productId, variantId = param.variantId, collapseKey = param.collapseKey, onAddCallback = param.onAddCallback, onRemoveCallback = param.onRemoveCallback;
49
+ var productId = param.productId, variantId = param.variantId, collapseKey = param.collapseKey, onAddCallback = param.onAddCallback, onRemoveCallback = param.onRemoveCallback, _useVariant = param.useVariant, useVariant = _useVariant === void 0 ? true : _useVariant;
50
50
  var ref = _slicedToArray(wishlistApi.useAdd(onAddCallback), 1), add = ref[0];
51
51
  var ref1 = _slicedToArray(wishlistApi.useRemove(onRemoveCallback), 1), remove = ref1[0];
52
- var ref2 = wishlistApi.useIsExisting(productId, collapseKey !== null && collapseKey !== void 0 ? collapseKey : variantId), isExisting = ref2.data;
52
+ var ref2 = wishlistApi.useIsExisting(productId, collapseKey !== null && collapseKey !== void 0 ? collapseKey : variantId, useVariant), isExisting = ref2.data;
53
53
  return {
54
54
  addToWishlist: function() {
55
55
  return add({
@@ -102,7 +102,7 @@ export var buildCategoryQuery = function(param) {
102
102
  };
103
103
  var _obj;
104
104
  var query = (_obj = {}, _defineProperty(_obj, type, aggValue), _defineProperty(_obj, "filter", getFilters()), _obj);
105
- if (pageType === ListingTypesEnum.Collection) {
105
+ if (pageType === ListingTypesEnum.Collection && (config === null || config === void 0 ? void 0 : config.collapseMode)) {
106
106
  var collapseMode = config === null || config === void 0 ? void 0 : config.collapseMode;
107
107
  query = _objectSpread({}, query, {
108
108
  collapseMode: collapseMode
@@ -12,7 +12,7 @@ declare type WishlistApiType = {
12
12
  offset: number;
13
13
  }) => InfiniteQueryResult<WishListDTO, unknown>;
14
14
  readonly useGetCompact: () => QueryResult<CompactWishlist, unknown>;
15
- readonly useIsExisting: (productId: string, variantId: string) => QueryResult<boolean, unknown>;
15
+ readonly useIsExisting: (productId: string, variantId: string, useVariant?: boolean) => QueryResult<boolean, unknown>;
16
16
  readonly useAdd: (onSuccess?: () => void) => MutationResultPair<WishListDTO, unknown, WishListItemDraftDTO, unknown>;
17
17
  readonly useSync: (onSuccess?: () => void) => MutationResultPair<WishListDTO, unknown, {
18
18
  query?: {
@@ -1,9 +1,10 @@
1
- export declare const useWishlist: ({ productId, variantId, collapseKey, onAddCallback, onRemoveCallback, }: {
1
+ export declare const useWishlist: ({ productId, variantId, collapseKey, onAddCallback, onRemoveCallback, useVariant, }: {
2
2
  productId: string;
3
3
  variantId?: string | undefined;
4
4
  collapseKey?: string | undefined;
5
5
  onAddCallback?: (() => void) | undefined;
6
6
  onRemoveCallback?: (() => void) | undefined;
7
+ useVariant?: boolean | undefined;
7
8
  }) => {
8
9
  addToWishlist: () => Promise<import("@sentecacommerce/sdk").WishListDTO | undefined>;
9
10
  removeFromWishlist: () => void;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sentecacommerce-theme/lib",
3
3
  "sideEffects": false,
4
- "version": "0.14.4",
4
+ "version": "0.14.7",
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": "d12a4f7247f20f26a42e09061a153f31734a7c1b",
34
+ "gitHead": "3a3ca6dce2d1b35de64812bd10698268c03dccf5",
35
35
  "peerDependencies": {
36
36
  "react-query": "^2.26.2"
37
37
  },
38
38
  "dependencies": {
39
- "@sentecacommerce-theme/base": "^0.14.4",
40
- "@sentecacommerce-theme/cms": "^0.14.4",
39
+ "@sentecacommerce-theme/base": "^0.14.7",
40
+ "@sentecacommerce-theme/cms": "^0.14.7",
41
41
  "@sentecacommerce/sdk": "2.0.175",
42
42
  "body-scroll-lock": "^3.1.5",
43
43
  "copy-to-clipboard": "^3.3.1",