@sentecacommerce-theme/lib 0.12.91 → 0.12.95

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.
@@ -16,7 +16,7 @@ var usePixelFinishOrder = function() {
16
16
  if ((typeof window === "undefined" ? "undefined" : _typeof(window)) !== undefined) {
17
17
  var pixel = window.pixel;
18
18
  if (payload) {
19
- pixel.finishOrder(payload);
19
+ pixel === null || pixel === void 0 ? void 0 : pixel.finishOrder(payload);
20
20
  }
21
21
  }
22
22
  };
@@ -37,18 +37,14 @@ function _objectSpread(target) {
37
37
  }
38
38
  return target;
39
39
  }
40
- var _typeof = function(obj) {
41
- "@swc/helpers - typeof";
42
- return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
43
- };
44
40
  var usePixelProductClick = function() {
45
41
  var defaultMerchant = (0, _index).useConfigState().defaultMerchant;
46
42
  var sendClickEvent = function(param) {
47
43
  var product = param.product, info = param.info;
48
- if ((typeof window === "undefined" ? "undefined" : _typeof(window)) !== undefined) {
44
+ if ((0, _index).canUseDOM() && defaultMerchant) {
49
45
  var pixel = window.pixel;
50
- pixel.productClick(product, _objectSpread({}, info, {
51
- merchantKey: defaultMerchant || ''
46
+ pixel === null || pixel === void 0 ? void 0 : pixel.productClick(product, _objectSpread({}, info, {
47
+ merchantKey: defaultMerchant
52
48
  }));
53
49
  }
54
50
  };
@@ -6,6 +6,7 @@ var _react = _interopRequireDefault(require("react"));
6
6
  var _router = require("next/router");
7
7
  var _index = require("../../../index");
8
8
  var _releva = require("../../Releva");
9
+ var _utils = require("../../../utils");
9
10
  function _arrayLikeToArray(arr, len) {
10
11
  if (len == null || len > arr.length) len = arr.length;
11
12
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
@@ -49,10 +50,6 @@ function _nonIterableRest() {
49
50
  function _slicedToArray(arr, i) {
50
51
  return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
51
52
  }
52
- var _typeof = function(obj) {
53
- "@swc/helpers - typeof";
54
- return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
55
- };
56
53
  function _unsupportedIterableToArray(o, minLen) {
57
54
  if (!o) return;
58
55
  if (typeof o === "string") return _arrayLikeToArray(o, minLen);
@@ -63,43 +60,56 @@ function _unsupportedIterableToArray(o, minLen) {
63
60
  }
64
61
  var usePixelProductsImpression = function(param) {
65
62
  var productsData = param.productsData, isCarousel = param.isCarousel;
66
- var ref3 = _slicedToArray((0, _index).useBoolean(false), 2), sentAlready = ref3[0], setSentAlready = ref3[1];
63
+ var ref5;
64
+ var ref1 = _slicedToArray((0, _index).useBoolean(false), 2), sentAlready = ref1[0], setSentAlready = ref1[1];
67
65
  var defaultMerchant = (0, _index).useConfigState().defaultMerchant;
68
66
  var router = (0, _router).useRouter();
69
67
  var products = [];
70
68
  if (!isCarousel) {
71
- products = (0, _releva).createMappedProducts(productsData.products);
69
+ products = (0, _releva).createMappedProducts(productsData === null || productsData === void 0 ? void 0 : productsData.products);
72
70
  }
73
71
  _react.default.useEffect(function() {
74
- if (sentAlready || !products.length) return;
75
- router.events.on('routeChangeComplete', function() {
76
- var ref, ref1;
77
- if ((typeof window === "undefined" ? "undefined" : _typeof(window)) !== undefined && !((ref = productsData.products) === null || ref === void 0 ? void 0 : (ref1 = ref[0]) === null || ref1 === void 0 ? void 0 : ref1.isPlaceholder) && (productsData === null || productsData === void 0 ? void 0 : productsData.length) > 0) {
78
- var ref2;
79
- var pixel = window.pixel;
80
- var title = window === null || window === void 0 ? void 0 : (ref2 = window.document) === null || ref2 === void 0 ? void 0 : ref2.title;
81
- var sendImpressions = function() {
82
- if (!title || title === 'за') {
83
- setTimeout(function() {
84
- return sendImpressions();
85
- }, 20);
86
- return;
72
+ setSentAlready.off();
73
+ }, [
74
+ router.asPath,
75
+ productsData === null || productsData === void 0 ? void 0 : (ref5 = productsData.products) === null || ref5 === void 0 ? void 0 : ref5.length,
76
+ setSentAlready
77
+ ]);
78
+ _react.default.useEffect(function() {
79
+ var ref, ref2, ref3;
80
+ if (sentAlready || !(products === null || products === void 0 ? void 0 : products.length)) return;
81
+ if ((0, _utils).canUseDOM() && !((ref = productsData.products) === null || ref === void 0 ? void 0 : (ref2 = ref[0]) === null || ref2 === void 0 ? void 0 : ref2.isPlaceholder) && (productsData === null || productsData === void 0 ? void 0 : (ref3 = productsData.products) === null || ref3 === void 0 ? void 0 : ref3.length) > 0) {
82
+ var ref4;
83
+ var pixel = window.pixel;
84
+ var title = window === null || window === void 0 ? void 0 : (ref4 = window.document) === null || ref4 === void 0 ? void 0 : ref4.title;
85
+ var sendImpressions = function() {
86
+ if (!title || title === 'за') {
87
+ setTimeout(function() {
88
+ return sendImpressions();
89
+ }, 20);
90
+ return;
91
+ }
92
+ pixel === null || pixel === void 0 ? void 0 : pixel.productsImpression(!isCarousel ? [
93
+ {
94
+ listName: title,
95
+ products: products
87
96
  }
88
- pixel === null || pixel === void 0 ? void 0 : pixel.productsImpression(!isCarousel ? [
89
- {
90
- listName: title,
91
- products: products
92
- }
93
- ] : productsData, {
94
- merchantKey: defaultMerchant || ''
95
- });
96
- };
97
- sendImpressions();
97
+ ] : productsData, {
98
+ merchantKey: defaultMerchant || ''
99
+ });
98
100
  setSentAlready.on();
99
- }
100
- });
101
+ };
102
+ sendImpressions();
103
+ }
101
104
  }, [
102
- router.route
105
+ router.route,
106
+ defaultMerchant,
107
+ sentAlready,
108
+ products,
109
+ router.events,
110
+ productsData,
111
+ setSentAlready,
112
+ isCarousel,
103
113
  ]);
104
114
  };
105
115
  exports.usePixelProductsImpression = usePixelProductsImpression;
@@ -13,7 +13,7 @@ var usePixelViewBasket = function() {
13
13
  if ((typeof window === "undefined" ? "undefined" : _typeof(window)) !== undefined) {
14
14
  var pixel = window.pixel;
15
15
  if (payload) {
16
- pixel.viewBasket(payload);
16
+ pixel === null || pixel === void 0 ? void 0 : pixel.viewBasket(payload);
17
17
  }
18
18
  }
19
19
  };
@@ -7,11 +7,18 @@ var _typeof = function(obj) {
7
7
  return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
8
8
  };
9
9
  var usePixelViewCategory = function() {
10
- var sendViewCategoryEvent = function(categoryBreadcrumb) {
10
+ var sendViewCategoryEvent = function(breadcrumbData) {
11
+ var breadcrumbString = breadcrumbData.reduce(function(res, curr, index) {
12
+ res += curr.name;
13
+ if (index !== breadcrumbData.length - 1) {
14
+ res += '/';
15
+ }
16
+ return res;
17
+ }, '');
11
18
  if ((typeof window === "undefined" ? "undefined" : _typeof(window)) !== undefined) {
12
19
  var pixel = window.pixel;
13
- if (categoryBreadcrumb) {
14
- pixel.viewCategory(categoryBreadcrumb);
20
+ if (breadcrumbString) {
21
+ pixel === null || pixel === void 0 ? void 0 : pixel.viewCategory(breadcrumbString);
15
22
  }
16
23
  }
17
24
  };
@@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", {
2
2
  value: true
3
3
  });
4
4
  exports.useWishlistItem = void 0;
5
- var _react = _interopRequireDefault(require("react"));
5
+ var _react = _interopRequireWildcard(require("react"));
6
6
  var _ = require("../../../");
7
7
  var _utils = require("../../basket-hooks/useBasketLineItem/utils");
8
8
  var _utils1 = require("../../../utils");
@@ -14,10 +14,26 @@ function _arrayLikeToArray(arr, len) {
14
14
  function _arrayWithHoles(arr) {
15
15
  if (Array.isArray(arr)) return arr;
16
16
  }
17
- function _interopRequireDefault(obj) {
18
- return obj && obj.__esModule ? obj : {
19
- default: obj
20
- };
17
+ function _interopRequireWildcard(obj) {
18
+ if (obj && obj.__esModule) {
19
+ return obj;
20
+ } else {
21
+ var newObj = {};
22
+ if (obj != null) {
23
+ for(var key in obj){
24
+ if (Object.prototype.hasOwnProperty.call(obj, key)) {
25
+ var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {};
26
+ if (desc.get || desc.set) {
27
+ Object.defineProperty(newObj, key, desc);
28
+ } else {
29
+ newObj[key] = obj[key];
30
+ }
31
+ }
32
+ }
33
+ }
34
+ newObj.default = obj;
35
+ return newObj;
36
+ }
21
37
  }
22
38
  function _iterableToArrayLimit(arr, i) {
23
39
  var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
@@ -59,15 +75,19 @@ function _unsupportedIterableToArray(o, minLen) {
59
75
  }
60
76
  var useWishlistItem = function(props) {
61
77
  var ref16;
62
- var ref1 = _slicedToArray(_react.default.useState(false), 2), isExpired = ref1[0], setIsExpired = ref1[1];
78
+ var item = props.item, expiry = props.expiry;
79
+ var ref1 = _slicedToArray((0, _).useBoolean(false), 2), isExpired = ref1[0], setIsExpired = ref1[1];
63
80
  var ref2 = _slicedToArray(_.wishlistApi.useSync(), 1), syncWishlist = ref2[0];
64
81
  var ref3 = (0, _).usePrefetchProduct((0, _).getTranslatableField(props === null || props === void 0 ? void 0 : (ref16 = props.item) === null || ref16 === void 0 ? void 0 : ref16.productSlug)), onMouseDown = ref3.onMouseDown, onMouseEnter = ref3.onMouseEnter, onMouseLeave = ref3.onMouseLeave;
82
+ (0, _react).useEffect(function() {
83
+ if (expiry) {
84
+ if (Date.now() > expiry + (item === null || item === void 0 ? void 0 : item.snapshotFrom)) {
85
+ setIsExpired.on();
86
+ }
87
+ }
88
+ }, []);
65
89
  var data = _react.default.useMemo(function() {
66
90
  var ref, ref4, ref5, ref6, ref7, ref8, ref9, ref10, ref11, ref12, ref13, ref14, ref15;
67
- var item = props.item;
68
- if (props.expiry && (0, _utils).getTimeStamp(props.expiry) < (item === null || item === void 0 ? void 0 : item.snapshotFrom)) {
69
- setIsExpired(true);
70
- }
71
91
  var offer = item === null || item === void 0 ? void 0 : (ref = item.productVariant) === null || ref === void 0 ? void 0 : ref.offer;
72
92
  var mappedAttributes = (0, _utils).createMappedAttributes(item === null || item === void 0 ? void 0 : (ref4 = item.productVariant) === null || ref4 === void 0 ? void 0 : ref4.attributes) || {};
73
93
  var mappedCustomField = (0, _utils1).customFieldsToMap(item.custom);
@@ -107,12 +127,16 @@ var useWishlistItem = function(props) {
107
127
  }
108
128
  };
109
129
  }, [
110
- props.item
130
+ item
131
+ ]);
132
+ (0, _react).useEffect(function() {
133
+ if (isExpired) {
134
+ syncWishlist();
135
+ setIsExpired.off();
136
+ }
137
+ }, [
138
+ isExpired
111
139
  ]);
112
- if (isExpired) {
113
- syncWishlist();
114
- setIsExpired(false);
115
- }
116
140
  return data;
117
141
  };
118
142
  exports.useWishlistItem = useWishlistItem;
@@ -89,38 +89,38 @@ var EmptyBox = function(param) {
89
89
  textColor: textColor || '',
90
90
  onClose: onClose
91
91
  })), /*#__PURE__*/ _react.default.createElement(SuggestedSearches, null, canDisplayPopular && /*#__PURE__*/ _react.default.createElement(_.PopularSearches, {
92
- title: (labels === null || labels === void 0 ? void 0 : labels.popularSearchesLabel) || '',
92
+ title: (labels === null || labels === void 0 ? void 0 : labels.popularSearches) || '',
93
93
  onClose: onClose,
94
94
  textColor: textColor || '',
95
95
  labelsColor: labelsColor || ''
96
96
  }), withRecent && canDisplayRecent && /*#__PURE__*/ _react.default.createElement(_.RecentSearches, {
97
- title: (labels === null || labels === void 0 ? void 0 : labels.recentSearchesLabel) || '',
97
+ title: (labels === null || labels === void 0 ? void 0 : labels.recentSearches) || '',
98
98
  data: searchHistory,
99
99
  onClose: onClose,
100
100
  textColor: textColor || '',
101
101
  labelsColor: labelsColor || ''
102
102
  }))) : /*#__PURE__*/ _react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/ _react.default.createElement(_.Container, {
103
103
  labelsColor: labelsColor,
104
- title: (labels === null || labels === void 0 ? void 0 : labels.productsLabel) || '',
104
+ title: (labels === null || labels === void 0 ? void 0 : labels.products) || '',
105
105
  onlyMobile: true
106
106
  }, /*#__PURE__*/ _react.default.createElement(NoResultsDesc, {
107
107
  className: "SEARCH_BOX_NO_RESULT"
108
- }, "No results found")), /*#__PURE__*/ _react.default.createElement(PromoCol, {
108
+ }, labels === null || labels === void 0 ? void 0 : labels.noResults)), /*#__PURE__*/ _react.default.createElement(PromoCol, {
109
109
  backgroundColor: backgroundColor
110
110
  }, /*#__PURE__*/ _react.default.createElement(_.Products, {
111
111
  data: promoOffers,
112
112
  textColor: textColor || '',
113
113
  labelsColor: labelsColor || '',
114
114
  onClose: onClose,
115
- title: (labels === null || labels === void 0 ? void 0 : labels.promoOffersLabel) || '',
115
+ title: (labels === null || labels === void 0 ? void 0 : labels.promoOffers) || '',
116
116
  offers: true
117
117
  })), /*#__PURE__*/ _react.default.createElement(_.Container, {
118
118
  labelsColor: labelsColor,
119
- title: (labels === null || labels === void 0 ? void 0 : labels.productsLabel) || '',
119
+ title: (labels === null || labels === void 0 ? void 0 : labels.products) || '',
120
120
  onlyDesktop: true
121
121
  }, /*#__PURE__*/ _react.default.createElement(NoResultsDesc, {
122
122
  className: "SEARCH_BOX_NO_RESULT"
123
- }, "No results found"))))));
123
+ }, labels === null || labels === void 0 ? void 0 : labels.noResults))))));
124
124
  };
125
125
  exports.EmptyBox = EmptyBox;
126
126
  var Wrapper = _styledComponents.default.div.attrs({
@@ -203,14 +203,14 @@ var SearchBox = function(param) {
203
203
  data: displayableBrands,
204
204
  onClose: onClose,
205
205
  searchValue: searchValue || '',
206
- title: (labels === null || labels === void 0 ? void 0 : labels.suggestedBrandsLabel) || '',
206
+ title: (labels === null || labels === void 0 ? void 0 : labels.suggestedBrands) || '',
207
207
  labelsColor: labelsColor || '',
208
208
  textColor: textColor || ''
209
209
  })), suggestedCategories.length > 0 && /*#__PURE__*/ _react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/ _react.default.createElement(_components.Suggestions, {
210
210
  data: suggestedCategories,
211
211
  onClose: onClose,
212
212
  searchValue: searchValue || '',
213
- title: (labels === null || labels === void 0 ? void 0 : labels.suggestedCategoriesLabel) || '',
213
+ title: (labels === null || labels === void 0 ? void 0 : labels.suggestedCategories) || '',
214
214
  labelsColor: labelsColor || '',
215
215
  textColor: textColor || ''
216
216
  }))), /*#__PURE__*/ _react.default.createElement(ProductsWrapper, {
@@ -218,7 +218,7 @@ var SearchBox = function(param) {
218
218
  }, /*#__PURE__*/ _react.default.createElement(_components.Products, {
219
219
  data: suggestions,
220
220
  bottomMenu: bottomMenu,
221
- title: labels === null || labels === void 0 ? void 0 : labels.productsLabel,
221
+ title: labels === null || labels === void 0 ? void 0 : labels.products,
222
222
  priceColor: priceColor,
223
223
  labelsColor: labelsColor,
224
224
  textColor: textColor,
@@ -227,7 +227,7 @@ var SearchBox = function(param) {
227
227
  productSpacing: productSpacing
228
228
  }), bottomMenu === BottomMenuEnum.promo && promoOffers && /*#__PURE__*/ _react.default.createElement(_components.Products, {
229
229
  data: promoOffers,
230
- title: labels.promoOffersLabel,
230
+ title: labels.promoOffers,
231
231
  labelsColor: labelsColor,
232
232
  textColor: textColor,
233
233
  onClose: onClose,
@@ -12,7 +12,7 @@ export var usePixelFinishOrder = function() {
12
12
  if ((typeof window === "undefined" ? "undefined" : _typeof(window)) !== undefined) {
13
13
  var pixel = window.pixel;
14
14
  if (payload) {
15
- pixel.finishOrder(payload);
15
+ pixel === null || pixel === void 0 ? void 0 : pixel.finishOrder(payload);
16
16
  }
17
17
  }
18
18
  };
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { useConfigState } from '../../../index';
2
+ import { useConfigState, canUseDOM } from '../../../index';
3
3
  function _defineProperty(obj, key, value) {
4
4
  if (key in obj) {
5
5
  Object.defineProperty(obj, key, {
@@ -28,18 +28,14 @@ function _objectSpread(target) {
28
28
  }
29
29
  return target;
30
30
  }
31
- var _typeof = function(obj) {
32
- "@swc/helpers - typeof";
33
- return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
34
- };
35
31
  export var usePixelProductClick = function() {
36
32
  var defaultMerchant = useConfigState().defaultMerchant;
37
33
  var sendClickEvent = function(param) {
38
34
  var product = param.product, info = param.info;
39
- if ((typeof window === "undefined" ? "undefined" : _typeof(window)) !== undefined) {
35
+ if (canUseDOM() && defaultMerchant) {
40
36
  var pixel = window.pixel;
41
- pixel.productClick(product, _objectSpread({}, info, {
42
- merchantKey: defaultMerchant || ''
37
+ pixel === null || pixel === void 0 ? void 0 : pixel.productClick(product, _objectSpread({}, info, {
38
+ merchantKey: defaultMerchant
43
39
  }));
44
40
  }
45
41
  };
@@ -2,6 +2,7 @@ import React from 'react';
2
2
  import { useRouter } from 'next/router';
3
3
  import { useConfigState, useBoolean } from '../../../index';
4
4
  import { createMappedProducts } from '../../Releva';
5
+ import { canUseDOM } from '../../../utils';
5
6
  function _arrayLikeToArray(arr, len) {
6
7
  if (len == null || len > arr.length) len = arr.length;
7
8
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
@@ -40,10 +41,6 @@ function _nonIterableRest() {
40
41
  function _slicedToArray(arr, i) {
41
42
  return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
42
43
  }
43
- var _typeof = function(obj) {
44
- "@swc/helpers - typeof";
45
- return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
46
- };
47
44
  function _unsupportedIterableToArray(o, minLen) {
48
45
  if (!o) return;
49
46
  if (typeof o === "string") return _arrayLikeToArray(o, minLen);
@@ -54,42 +51,55 @@ function _unsupportedIterableToArray(o, minLen) {
54
51
  }
55
52
  export var usePixelProductsImpression = function(param) {
56
53
  var productsData = param.productsData, isCarousel = param.isCarousel;
57
- var ref3 = _slicedToArray(useBoolean(false), 2), sentAlready = ref3[0], setSentAlready = ref3[1];
54
+ var ref5;
55
+ var ref1 = _slicedToArray(useBoolean(false), 2), sentAlready = ref1[0], setSentAlready = ref1[1];
58
56
  var defaultMerchant = useConfigState().defaultMerchant;
59
57
  var router = useRouter();
60
58
  var products = [];
61
59
  if (!isCarousel) {
62
- products = createMappedProducts(productsData.products);
60
+ products = createMappedProducts(productsData === null || productsData === void 0 ? void 0 : productsData.products);
63
61
  }
64
62
  React.useEffect(function() {
65
- if (sentAlready || !products.length) return;
66
- router.events.on('routeChangeComplete', function() {
67
- var ref, ref1;
68
- if ((typeof window === "undefined" ? "undefined" : _typeof(window)) !== undefined && !((ref = productsData.products) === null || ref === void 0 ? void 0 : (ref1 = ref[0]) === null || ref1 === void 0 ? void 0 : ref1.isPlaceholder) && (productsData === null || productsData === void 0 ? void 0 : productsData.length) > 0) {
69
- var ref2;
70
- var pixel = window.pixel;
71
- var title = window === null || window === void 0 ? void 0 : (ref2 = window.document) === null || ref2 === void 0 ? void 0 : ref2.title;
72
- var sendImpressions = function() {
73
- if (!title || title === 'за') {
74
- setTimeout(function() {
75
- return sendImpressions();
76
- }, 20);
77
- return;
63
+ setSentAlready.off();
64
+ }, [
65
+ router.asPath,
66
+ productsData === null || productsData === void 0 ? void 0 : (ref5 = productsData.products) === null || ref5 === void 0 ? void 0 : ref5.length,
67
+ setSentAlready
68
+ ]);
69
+ React.useEffect(function() {
70
+ var ref, ref2, ref3;
71
+ if (sentAlready || !(products === null || products === void 0 ? void 0 : products.length)) return;
72
+ if (canUseDOM() && !((ref = productsData.products) === null || ref === void 0 ? void 0 : (ref2 = ref[0]) === null || ref2 === void 0 ? void 0 : ref2.isPlaceholder) && (productsData === null || productsData === void 0 ? void 0 : (ref3 = productsData.products) === null || ref3 === void 0 ? void 0 : ref3.length) > 0) {
73
+ var ref4;
74
+ var pixel = window.pixel;
75
+ var title = window === null || window === void 0 ? void 0 : (ref4 = window.document) === null || ref4 === void 0 ? void 0 : ref4.title;
76
+ var sendImpressions = function() {
77
+ if (!title || title === 'за') {
78
+ setTimeout(function() {
79
+ return sendImpressions();
80
+ }, 20);
81
+ return;
82
+ }
83
+ pixel === null || pixel === void 0 ? void 0 : pixel.productsImpression(!isCarousel ? [
84
+ {
85
+ listName: title,
86
+ products: products
78
87
  }
79
- pixel === null || pixel === void 0 ? void 0 : pixel.productsImpression(!isCarousel ? [
80
- {
81
- listName: title,
82
- products: products
83
- }
84
- ] : productsData, {
85
- merchantKey: defaultMerchant || ''
86
- });
87
- };
88
- sendImpressions();
88
+ ] : productsData, {
89
+ merchantKey: defaultMerchant || ''
90
+ });
89
91
  setSentAlready.on();
90
- }
91
- });
92
+ };
93
+ sendImpressions();
94
+ }
92
95
  }, [
93
- router.route
96
+ router.route,
97
+ defaultMerchant,
98
+ sentAlready,
99
+ products,
100
+ router.events,
101
+ productsData,
102
+ setSentAlready,
103
+ isCarousel,
94
104
  ]);
95
105
  };
@@ -9,7 +9,7 @@ export var usePixelViewBasket = function() {
9
9
  if ((typeof window === "undefined" ? "undefined" : _typeof(window)) !== undefined) {
10
10
  var pixel = window.pixel;
11
11
  if (payload) {
12
- pixel.viewBasket(payload);
12
+ pixel === null || pixel === void 0 ? void 0 : pixel.viewBasket(payload);
13
13
  }
14
14
  }
15
15
  };
@@ -3,11 +3,18 @@ var _typeof = function(obj) {
3
3
  return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
4
4
  };
5
5
  export var usePixelViewCategory = function() {
6
- var sendViewCategoryEvent = function(categoryBreadcrumb) {
6
+ var sendViewCategoryEvent = function(breadcrumbData) {
7
+ var breadcrumbString = breadcrumbData.reduce(function(res, curr, index) {
8
+ res += curr.name;
9
+ if (index !== breadcrumbData.length - 1) {
10
+ res += '/';
11
+ }
12
+ return res;
13
+ }, '');
7
14
  if ((typeof window === "undefined" ? "undefined" : _typeof(window)) !== undefined) {
8
15
  var pixel = window.pixel;
9
- if (categoryBreadcrumb) {
10
- pixel.viewCategory(categoryBreadcrumb);
16
+ if (breadcrumbString) {
17
+ pixel === null || pixel === void 0 ? void 0 : pixel.viewCategory(breadcrumbString);
11
18
  }
12
19
  }
13
20
  };
@@ -1,7 +1,7 @@
1
- import React from 'react';
2
- import { wishlistApi } from '../../../';
1
+ import React, { useEffect } from 'react';
2
+ import { useBoolean, wishlistApi } from '../../../';
3
3
  import { usePrefetchProduct, getTranslatableField } from '../../../';
4
- import { getTimeStamp, createMappedAttributes } from '../../basket-hooks/useBasketLineItem/utils';
4
+ import { createMappedAttributes } from '../../basket-hooks/useBasketLineItem/utils';
5
5
  import { customFieldsToMap } from '../../../utils';
6
6
  function _arrayLikeToArray(arr, len) {
7
7
  if (len == null || len > arr.length) len = arr.length;
@@ -51,15 +51,19 @@ function _unsupportedIterableToArray(o, minLen) {
51
51
  }
52
52
  export var useWishlistItem = function(props) {
53
53
  var ref16;
54
- var ref1 = _slicedToArray(React.useState(false), 2), isExpired = ref1[0], setIsExpired = ref1[1];
54
+ var item = props.item, expiry = props.expiry;
55
+ var ref1 = _slicedToArray(useBoolean(false), 2), isExpired = ref1[0], setIsExpired = ref1[1];
55
56
  var ref2 = _slicedToArray(wishlistApi.useSync(), 1), syncWishlist = ref2[0];
56
57
  var ref3 = usePrefetchProduct(getTranslatableField(props === null || props === void 0 ? void 0 : (ref16 = props.item) === null || ref16 === void 0 ? void 0 : ref16.productSlug)), onMouseDown = ref3.onMouseDown, onMouseEnter = ref3.onMouseEnter, onMouseLeave = ref3.onMouseLeave;
58
+ useEffect(function() {
59
+ if (expiry) {
60
+ if (Date.now() > expiry + (item === null || item === void 0 ? void 0 : item.snapshotFrom)) {
61
+ setIsExpired.on();
62
+ }
63
+ }
64
+ }, []);
57
65
  var data = React.useMemo(function() {
58
66
  var ref, ref4, ref5, ref6, ref7, ref8, ref9, ref10, ref11, ref12, ref13, ref14, ref15;
59
- var item = props.item;
60
- if (props.expiry && getTimeStamp(props.expiry) < (item === null || item === void 0 ? void 0 : item.snapshotFrom)) {
61
- setIsExpired(true);
62
- }
63
67
  var offer = item === null || item === void 0 ? void 0 : (ref = item.productVariant) === null || ref === void 0 ? void 0 : ref.offer;
64
68
  var mappedAttributes = createMappedAttributes(item === null || item === void 0 ? void 0 : (ref4 = item.productVariant) === null || ref4 === void 0 ? void 0 : ref4.attributes) || {};
65
69
  var mappedCustomField = customFieldsToMap(item.custom);
@@ -99,11 +103,15 @@ export var useWishlistItem = function(props) {
99
103
  }
100
104
  };
101
105
  }, [
102
- props.item
106
+ item
107
+ ]);
108
+ useEffect(function() {
109
+ if (isExpired) {
110
+ syncWishlist();
111
+ setIsExpired.off();
112
+ }
113
+ }, [
114
+ isExpired
103
115
  ]);
104
- if (isExpired) {
105
- syncWishlist();
106
- setIsExpired(false);
107
- }
108
116
  return data;
109
117
  };
@@ -80,38 +80,38 @@ export var EmptyBox = function(param) {
80
80
  textColor: textColor || '',
81
81
  onClose: onClose
82
82
  })), /*#__PURE__*/ React.createElement(SuggestedSearches, null, canDisplayPopular && /*#__PURE__*/ React.createElement(PopularSearches, {
83
- title: (labels === null || labels === void 0 ? void 0 : labels.popularSearchesLabel) || '',
83
+ title: (labels === null || labels === void 0 ? void 0 : labels.popularSearches) || '',
84
84
  onClose: onClose,
85
85
  textColor: textColor || '',
86
86
  labelsColor: labelsColor || ''
87
87
  }), withRecent && canDisplayRecent && /*#__PURE__*/ React.createElement(RecentSearches, {
88
- title: (labels === null || labels === void 0 ? void 0 : labels.recentSearchesLabel) || '',
88
+ title: (labels === null || labels === void 0 ? void 0 : labels.recentSearches) || '',
89
89
  data: searchHistory,
90
90
  onClose: onClose,
91
91
  textColor: textColor || '',
92
92
  labelsColor: labelsColor || ''
93
93
  }))) : /*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement(Container, {
94
94
  labelsColor: labelsColor,
95
- title: (labels === null || labels === void 0 ? void 0 : labels.productsLabel) || '',
95
+ title: (labels === null || labels === void 0 ? void 0 : labels.products) || '',
96
96
  onlyMobile: true
97
97
  }, /*#__PURE__*/ React.createElement(NoResultsDesc, {
98
98
  className: "SEARCH_BOX_NO_RESULT"
99
- }, "No results found")), /*#__PURE__*/ React.createElement(PromoCol, {
99
+ }, labels === null || labels === void 0 ? void 0 : labels.noResults)), /*#__PURE__*/ React.createElement(PromoCol, {
100
100
  backgroundColor: backgroundColor
101
101
  }, /*#__PURE__*/ React.createElement(Products, {
102
102
  data: promoOffers,
103
103
  textColor: textColor || '',
104
104
  labelsColor: labelsColor || '',
105
105
  onClose: onClose,
106
- title: (labels === null || labels === void 0 ? void 0 : labels.promoOffersLabel) || '',
106
+ title: (labels === null || labels === void 0 ? void 0 : labels.promoOffers) || '',
107
107
  offers: true
108
108
  })), /*#__PURE__*/ React.createElement(Container, {
109
109
  labelsColor: labelsColor,
110
- title: (labels === null || labels === void 0 ? void 0 : labels.productsLabel) || '',
110
+ title: (labels === null || labels === void 0 ? void 0 : labels.products) || '',
111
111
  onlyDesktop: true
112
112
  }, /*#__PURE__*/ React.createElement(NoResultsDesc, {
113
113
  className: "SEARCH_BOX_NO_RESULT"
114
- }, "No results found"))))));
114
+ }, labels === null || labels === void 0 ? void 0 : labels.noResults))))));
115
115
  };
116
116
  var Wrapper = styled.div.attrs({
117
117
  className: 'd-flex flex-column flex-lg-row mx-lg-auto '
@@ -173,14 +173,14 @@ export var SearchBox = function(param) {
173
173
  data: displayableBrands,
174
174
  onClose: onClose,
175
175
  searchValue: searchValue || '',
176
- title: (labels === null || labels === void 0 ? void 0 : labels.suggestedBrandsLabel) || '',
176
+ title: (labels === null || labels === void 0 ? void 0 : labels.suggestedBrands) || '',
177
177
  labelsColor: labelsColor || '',
178
178
  textColor: textColor || ''
179
179
  })), suggestedCategories.length > 0 && /*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement(Suggestions, {
180
180
  data: suggestedCategories,
181
181
  onClose: onClose,
182
182
  searchValue: searchValue || '',
183
- title: (labels === null || labels === void 0 ? void 0 : labels.suggestedCategoriesLabel) || '',
183
+ title: (labels === null || labels === void 0 ? void 0 : labels.suggestedCategories) || '',
184
184
  labelsColor: labelsColor || '',
185
185
  textColor: textColor || ''
186
186
  }))), /*#__PURE__*/ React.createElement(ProductsWrapper, {
@@ -188,7 +188,7 @@ export var SearchBox = function(param) {
188
188
  }, /*#__PURE__*/ React.createElement(Products, {
189
189
  data: suggestions,
190
190
  bottomMenu: bottomMenu,
191
- title: labels === null || labels === void 0 ? void 0 : labels.productsLabel,
191
+ title: labels === null || labels === void 0 ? void 0 : labels.products,
192
192
  priceColor: priceColor,
193
193
  labelsColor: labelsColor,
194
194
  textColor: textColor,
@@ -197,7 +197,7 @@ export var SearchBox = function(param) {
197
197
  productSpacing: productSpacing
198
198
  }), bottomMenu === BottomMenuEnum.promo && promoOffers && /*#__PURE__*/ React.createElement(Products, {
199
199
  data: promoOffers,
200
- title: labels.promoOffersLabel,
200
+ title: labels.promoOffers,
201
201
  labelsColor: labelsColor,
202
202
  textColor: textColor,
203
203
  onClose: onClose,
@@ -1,3 +1,7 @@
1
1
  export declare const usePixelViewCategory: () => {
2
- sendViewCategoryEvent: (categoryBreadcrumb: string) => void;
2
+ sendViewCategoryEvent: (breadcrumbData: {
3
+ name: string;
4
+ id: string;
5
+ link: string;
6
+ }[]) => void;
3
7
  };
@@ -3,11 +3,12 @@ interface EmptyBoxProps {
3
3
  backgroundColor?: StringField;
4
4
  searchHistory?: any[];
5
5
  labels: GroupField<{
6
- promoOffersLabel: StringField;
7
- productsLabel: StringField;
8
- recentSearchesLabel: StringField;
9
- popularSearchesLabel: StringField;
6
+ promoOffers: StringField;
7
+ products: StringField;
8
+ recentSearches: StringField;
9
+ popularSearches: StringField;
10
10
  blogLabel: StringField;
11
+ noResults: StringField;
11
12
  blog: GroupField<{
12
13
  blogTitle: StringField;
13
14
  image: StringField;
@@ -1,12 +1,13 @@
1
1
  import { StringField, GroupField, BooleanField, NumberField } from '@sentecacommerce-theme/cms';
2
2
  interface SearchLabels {
3
- recentSearchesLabel: StringField;
4
- popularSearchesLabel: StringField;
5
- suggestedBrandsLabel: StringField;
6
- suggestedCategoriesLabel: StringField;
7
- promoOffersLabel: StringField;
8
- productsLabel: StringField;
3
+ recentSearches: StringField;
4
+ popularSearches: StringField;
5
+ suggestedBrands: StringField;
6
+ suggestedCategories: StringField;
7
+ promoOffers: StringField;
8
+ products: StringField;
9
9
  blogLabel: StringField;
10
+ noResults: StringField;
10
11
  blog: GroupField<{
11
12
  blogTitle: StringField;
12
13
  image: StringField;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sentecacommerce-theme/lib",
3
3
  "sideEffects": false,
4
- "version": "0.12.91",
4
+ "version": "0.12.95",
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": "bb0947520feb34f8271e3be4c9e76cfaeb3b5c5f",
34
+ "gitHead": "e4ce21f505cc0bea992d4a3fb45ff7d72cdee868",
35
35
  "peerDependencies": {
36
36
  "react-query": "^2.26.2"
37
37
  },
38
38
  "dependencies": {
39
- "@sentecacommerce-theme/base": "^0.12.91",
40
- "@sentecacommerce-theme/cms": "^0.12.91",
39
+ "@sentecacommerce-theme/base": "^0.12.95",
40
+ "@sentecacommerce-theme/cms": "^0.12.95",
41
41
  "@sentecacommerce/sdk": "2.0.161",
42
42
  "body-scroll-lock": "^3.1.5",
43
43
  "copy-to-clipboard": "^3.3.1",