@bonlineza/luxity-lib 2.35.7 → 2.35.9

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.
@@ -367,7 +367,7 @@
367
367
  return null;
368
368
  }
369
369
 
370
- if (!isSearchFocused && !hasResults) {
370
+ if (!isSearchFocused) {
371
371
  return null;
372
372
  }
373
373
 
@@ -390,7 +390,7 @@
390
390
  key: product.link,
391
391
  href: product.link,
392
392
  className: "product-card"
393
- }, (product.image_url || product.featured_image) && /*#__PURE__*/React__default.createElement("div", {
393
+ }, product.featured_image && /*#__PURE__*/React__default.createElement("div", {
394
394
  className: "product-card__image-container"
395
395
  }, /*#__PURE__*/React__default.createElement("img", {
396
396
  src: product.featured_image,
@@ -697,6 +697,7 @@
697
697
  var endpoint = _ref.endpoint,
698
698
  onProductIdsReceived = _ref.onProductIdsReceived,
699
699
  currency = _ref.currency;
700
+ var currentSearchRequestToken = React.useRef(null);
700
701
  var debounce = React.useCallback(function (func, wait) {
701
702
  var timeout;
702
703
  return function executedFunction() {
@@ -727,49 +728,75 @@
727
728
  });
728
729
  });
729
730
  }, []);
730
- var performSearch = React.useCallback(function (nextValue, setSearchResults) {
731
- if (!nextValue || nextValue.trim() === '') {
731
+ var performSearch = React.useCallback(function (searchQuery, setSearchResults) {
732
+ if (!searchQuery || searchQuery.trim() === '') {
732
733
  setSearchResults({
733
734
  brands: [],
734
735
  products: [],
735
736
  luxity_product_ids: []
736
737
  });
737
738
  return;
738
- }
739
+ } // Cancel any ongoing search request to prevent race conditions
740
+
741
+
742
+ if (currentSearchRequestToken.current) {
743
+ currentSearchRequestToken.current.cancel();
744
+ } // Create a new token for this specific search request
745
+
739
746
 
740
- axios.post(endpoint, searchProducts(nextValue, 3, currency)).then(function (response) {
741
- var searchResults = response.data.data.luxity_products_serach_results;
742
- setSearchResults(searchResults);
747
+ var newSearchToken = axios.CancelToken.source();
748
+ currentSearchRequestToken.current = newSearchToken;
749
+ axios.post(endpoint, searchProducts(searchQuery, 3, currency), {
750
+ cancelToken: newSearchToken.token
751
+ }).then(function (response) {
752
+ if (currentSearchRequestToken.current === newSearchToken) {
753
+ var searchResults = response.data.data.luxity_products_serach_results;
754
+ setSearchResults(searchResults);
743
755
 
744
- if (searchResults && searchResults.luxity_product_ids) {
745
- onProductIdsReceived(searchResults.luxity_product_ids);
756
+ if (searchResults && searchResults.luxity_product_ids) {
757
+ onProductIdsReceived(searchResults.luxity_product_ids);
758
+ }
759
+
760
+ currentSearchRequestToken.current = null;
761
+ }
762
+ }).catch(function (error) {
763
+ if (!axios.isCancel(error)) {
764
+ setSearchResults({
765
+ brands: [],
766
+ products: [],
767
+ luxity_product_ids: []
768
+ });
769
+ currentSearchRequestToken.current = null;
746
770
  }
747
- }).catch(function () {
748
- setSearchResults({
749
- brands: [],
750
- products: [],
751
- luxity_product_ids: []
752
- });
753
771
  });
754
772
  }, [endpoint, currency, onProductIdsReceived]);
755
773
  var debouncedSearch = React.useMemo(function () {
756
- return debounce(function (nextValue, setSearchResults) {
757
- return performSearch(nextValue, setSearchResults);
774
+ return debounce(function (searchQuery, setSearchResults) {
775
+ return performSearch(searchQuery, setSearchResults);
758
776
  }, 500);
759
777
  }, [debounce, performSearch]);
760
778
  var createDebouncedSearch = React.useCallback(function (setSearchResults) {
761
- return function (nextValue) {
762
- return debouncedSearch(nextValue, setSearchResults);
779
+ return function (searchQuery) {
780
+ return debouncedSearch(searchQuery, setSearchResults);
763
781
  };
764
782
  }, [debouncedSearch]);
765
783
  var createImmediateSearch = React.useCallback(function (setSearchValue, setSearchResults, onSearchSubmit) {
766
- return function (value) {
784
+ return function (searchQuery) {
785
+ /*
786
+ * Cancel any pending search request when immediate search is performed
787
+ * Immediate search is when the user types a search query and presses enter
788
+ */
789
+ if (currentSearchRequestToken.current) {
790
+ currentSearchRequestToken.current.cancel();
791
+ currentSearchRequestToken.current = null;
792
+ }
793
+
767
794
  setSearchValue('');
768
795
  setSearchResults({
769
796
  brands: [],
770
797
  products: []
771
798
  });
772
- onSearchSubmit(value);
799
+ onSearchSubmit(searchQuery);
773
800
  };
774
801
  }, []);
775
802
  return {
@@ -779,6 +806,72 @@
779
806
  };
780
807
  };
781
808
 
809
+ var useSearchClickOutside = function useSearchClickOutside(ref, searchResults, setCachedResults, setIsSearchFocused, setSearchResults) {
810
+ React.useEffect(function () {
811
+ var handleClickOutside = function handleClickOutside(event) {
812
+ if (ref.current && !ref.current.contains(event.target)) {
813
+ setCachedResults(searchResults);
814
+ setIsSearchFocused(false);
815
+ setSearchResults({
816
+ brands: [],
817
+ products: []
818
+ });
819
+ }
820
+ };
821
+
822
+ document.addEventListener('mousedown', handleClickOutside);
823
+ return function () {
824
+ document.removeEventListener('mousedown', handleClickOutside);
825
+ };
826
+ }, [ref, searchResults, setCachedResults, setIsSearchFocused, setSearchResults]);
827
+ };
828
+ var useSearchInputChange = function useSearchInputChange(setSearchValue, setIsSearchFocused, debouncedSearch, setSearchResults, setCachedResults) {
829
+ return React.useCallback(function (event) {
830
+ var value = event.target.value;
831
+ setSearchValue(value);
832
+ setIsSearchFocused(true);
833
+
834
+ if (value.trim().length >= 3) {
835
+ debouncedSearch(value);
836
+ } else {
837
+ setSearchResults({
838
+ brands: [],
839
+ products: []
840
+ });
841
+ setCachedResults({
842
+ brands: [],
843
+ products: []
844
+ });
845
+ }
846
+ }, [setSearchValue, setIsSearchFocused, debouncedSearch, setSearchResults, setCachedResults]);
847
+ };
848
+ var useSearchInputFocus = function useSearchInputFocus(searchValue, setIsSearchFocused, cachedResults, setSearchResults) {
849
+ return React.useCallback(function () {
850
+ setIsSearchFocused(true);
851
+
852
+ if (searchValue.trim().length >= 3) {
853
+ setSearchResults(cachedResults);
854
+ }
855
+ }, [searchValue, setIsSearchFocused, cachedResults, setSearchResults]);
856
+ };
857
+ var useSearchInputKeyDown = function useSearchInputKeyDown(searchValue, immediateSearch, setIsSearchFocused) {
858
+ var setSearchValue = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
859
+ return React.useCallback(function (event) {
860
+ if (event.key === 'Enter') {
861
+ event.preventDefault();
862
+
863
+ if (searchValue.trim().length >= 3) {
864
+ immediateSearch(searchValue);
865
+ }
866
+
867
+ setIsSearchFocused(false);
868
+ } else if (event.key === 'Escape' && setSearchValue) {
869
+ setSearchValue('');
870
+ setIsSearchFocused(false);
871
+ }
872
+ }, [searchValue, immediateSearch, setIsSearchFocused, setSearchValue]);
873
+ };
874
+
782
875
  var LuxityDesktopHeader = function LuxityDesktopHeader(_ref) {
783
876
  var accountIcon = _ref.accountIcon,
784
877
  cartIcon = _ref.cartIcon,
@@ -800,7 +893,6 @@
800
893
  onCartClick = _ref.onCartClick,
801
894
  onAccountClick = _ref.onAccountClick,
802
895
  inputSearchIcon = _ref.inputSearchIcon,
803
- onSearch = _ref.onSearch,
804
896
  onSellToUsClick = _ref.onSellToUsClick,
805
897
  contactUsLink = _ref.contactUsLink,
806
898
  ourStoryLink = _ref.ourStoryLink,
@@ -881,56 +973,24 @@
881
973
  searchResults = _useState14[0],
882
974
  setSearchResults = _useState14[1];
883
975
 
976
+ var _useState15 = React.useState({
977
+ brands: [],
978
+ products: []
979
+ }),
980
+ _useState16 = _slicedToArray(_useState15, 2),
981
+ cachedResults = _useState16[0],
982
+ setCachedResults = _useState16[1];
983
+
884
984
  var searchResultsRef = React.useRef(null);
885
- var debouncedSearch = createDebouncedSearch(setSearchResults);
985
+ var debouncedSearch = createDebouncedSearch(function (results) {
986
+ setSearchResults(results);
987
+ setCachedResults(results);
988
+ });
886
989
  var immediateSearch = createImmediateSearch(setSearchValue, setSearchResults, onSearchSubmit);
887
-
888
- var handleChange = function handleChange(event) {
889
- var value = event.target.value;
890
- setSearchValue(value);
891
- setIsSearchFocused(true);
892
-
893
- if (value.trim().length >= 3) {
894
- debouncedSearch(value);
895
- } else {
896
- setSearchResults({
897
- brands: [],
898
- products: []
899
- });
900
- }
901
- };
902
-
903
- React.useEffect(function () {
904
- var handleClickOutside = function handleClickOutside(event) {
905
- if (searchResultsRef.current && !searchResultsRef.current.contains(event.target)) {
906
- setSearchValue('');
907
- setIsSearchFocused(false);
908
- setSearchResults({
909
- brands: [],
910
- products: []
911
- });
912
- }
913
- };
914
-
915
- document.addEventListener('mousedown', handleClickOutside);
916
- return function () {
917
- document.removeEventListener('mousedown', handleClickOutside);
918
- };
919
- }, []);
920
-
921
- var handleKeyDown = function handleKeyDown(event) {
922
- if (event.key === 'Enter') {
923
- event.preventDefault();
924
-
925
- if (searchValue.trim().length >= 3) {
926
- immediateSearch(searchValue);
927
- }
928
- } else if (event.key === 'Escape') {
929
- setSearchValue('');
930
- }
931
-
932
- setIsSearchFocused(false);
933
- };
990
+ var handleChange = useSearchInputChange(setSearchValue, setIsSearchFocused, debouncedSearch, setSearchResults, setCachedResults);
991
+ useSearchClickOutside(searchResultsRef, searchResults, setCachedResults, setIsSearchFocused, setSearchResults);
992
+ var handleSearchFocus = useSearchInputFocus(searchValue, setIsSearchFocused, cachedResults, setSearchResults);
993
+ var handleKeyDown = useSearchInputKeyDown(searchValue, immediateSearch, setIsSearchFocused);
934
994
 
935
995
  function addCategoryToElements(elements, categoryName) {
936
996
  return elements.map(function (element) {
@@ -1002,13 +1062,8 @@
1002
1062
  value: searchValue,
1003
1063
  onChange: handleChange,
1004
1064
  onKeyDown: handleKeyDown,
1005
- onClick: function onClick() {
1006
- onSearch();
1007
- setIsSearchFocused(true);
1008
- },
1009
- onFocus: function onFocus() {
1010
- return setIsSearchFocused(true);
1011
- }
1065
+ onClick: handleSearchFocus,
1066
+ onFocus: handleSearchFocus
1012
1067
  })), /*#__PURE__*/React__default.createElement(SearchResults, {
1013
1068
  searchValue: searchValue,
1014
1069
  searchResults: searchResults,
@@ -1078,7 +1078,7 @@
1078
1078
  return null;
1079
1079
  }
1080
1080
 
1081
- if (!isSearchFocused && !hasResults) {
1081
+ if (!isSearchFocused) {
1082
1082
  return null;
1083
1083
  }
1084
1084
 
@@ -1101,7 +1101,7 @@
1101
1101
  key: product.link,
1102
1102
  href: product.link,
1103
1103
  className: "product-card"
1104
- }, (product.image_url || product.featured_image) && /*#__PURE__*/React__default.createElement("div", {
1104
+ }, product.featured_image && /*#__PURE__*/React__default.createElement("div", {
1105
1105
  className: "product-card__image-container"
1106
1106
  }, /*#__PURE__*/React__default.createElement("img", {
1107
1107
  src: product.featured_image,
@@ -1205,6 +1205,7 @@
1205
1205
  var endpoint = _ref.endpoint,
1206
1206
  onProductIdsReceived = _ref.onProductIdsReceived,
1207
1207
  currency = _ref.currency;
1208
+ var currentSearchRequestToken = React.useRef(null);
1208
1209
  var debounce = React.useCallback(function (func, wait) {
1209
1210
  var timeout;
1210
1211
  return function executedFunction() {
@@ -1235,49 +1236,75 @@
1235
1236
  });
1236
1237
  });
1237
1238
  }, []);
1238
- var performSearch = React.useCallback(function (nextValue, setSearchResults) {
1239
- if (!nextValue || nextValue.trim() === '') {
1239
+ var performSearch = React.useCallback(function (searchQuery, setSearchResults) {
1240
+ if (!searchQuery || searchQuery.trim() === '') {
1240
1241
  setSearchResults({
1241
1242
  brands: [],
1242
1243
  products: [],
1243
1244
  luxity_product_ids: []
1244
1245
  });
1245
1246
  return;
1246
- }
1247
+ } // Cancel any ongoing search request to prevent race conditions
1248
+
1249
+
1250
+ if (currentSearchRequestToken.current) {
1251
+ currentSearchRequestToken.current.cancel();
1252
+ } // Create a new token for this specific search request
1253
+
1247
1254
 
1248
- axios.post(endpoint, searchProducts(nextValue, 3, currency)).then(function (response) {
1249
- var searchResults = response.data.data.luxity_products_serach_results;
1250
- setSearchResults(searchResults);
1255
+ var newSearchToken = axios.CancelToken.source();
1256
+ currentSearchRequestToken.current = newSearchToken;
1257
+ axios.post(endpoint, searchProducts(searchQuery, 3, currency), {
1258
+ cancelToken: newSearchToken.token
1259
+ }).then(function (response) {
1260
+ if (currentSearchRequestToken.current === newSearchToken) {
1261
+ var searchResults = response.data.data.luxity_products_serach_results;
1262
+ setSearchResults(searchResults);
1251
1263
 
1252
- if (searchResults && searchResults.luxity_product_ids) {
1253
- onProductIdsReceived(searchResults.luxity_product_ids);
1264
+ if (searchResults && searchResults.luxity_product_ids) {
1265
+ onProductIdsReceived(searchResults.luxity_product_ids);
1266
+ }
1267
+
1268
+ currentSearchRequestToken.current = null;
1269
+ }
1270
+ }).catch(function (error) {
1271
+ if (!axios.isCancel(error)) {
1272
+ setSearchResults({
1273
+ brands: [],
1274
+ products: [],
1275
+ luxity_product_ids: []
1276
+ });
1277
+ currentSearchRequestToken.current = null;
1254
1278
  }
1255
- }).catch(function () {
1256
- setSearchResults({
1257
- brands: [],
1258
- products: [],
1259
- luxity_product_ids: []
1260
- });
1261
1279
  });
1262
1280
  }, [endpoint, currency, onProductIdsReceived]);
1263
1281
  var debouncedSearch = React.useMemo(function () {
1264
- return debounce(function (nextValue, setSearchResults) {
1265
- return performSearch(nextValue, setSearchResults);
1282
+ return debounce(function (searchQuery, setSearchResults) {
1283
+ return performSearch(searchQuery, setSearchResults);
1266
1284
  }, 500);
1267
1285
  }, [debounce, performSearch]);
1268
1286
  var createDebouncedSearch = React.useCallback(function (setSearchResults) {
1269
- return function (nextValue) {
1270
- return debouncedSearch(nextValue, setSearchResults);
1287
+ return function (searchQuery) {
1288
+ return debouncedSearch(searchQuery, setSearchResults);
1271
1289
  };
1272
1290
  }, [debouncedSearch]);
1273
1291
  var createImmediateSearch = React.useCallback(function (setSearchValue, setSearchResults, onSearchSubmit) {
1274
- return function (value) {
1292
+ return function (searchQuery) {
1293
+ /*
1294
+ * Cancel any pending search request when immediate search is performed
1295
+ * Immediate search is when the user types a search query and presses enter
1296
+ */
1297
+ if (currentSearchRequestToken.current) {
1298
+ currentSearchRequestToken.current.cancel();
1299
+ currentSearchRequestToken.current = null;
1300
+ }
1301
+
1275
1302
  setSearchValue('');
1276
1303
  setSearchResults({
1277
1304
  brands: [],
1278
1305
  products: []
1279
1306
  });
1280
- onSearchSubmit(value);
1307
+ onSearchSubmit(searchQuery);
1281
1308
  };
1282
1309
  }, []);
1283
1310
  return {
@@ -1287,6 +1314,72 @@
1287
1314
  };
1288
1315
  };
1289
1316
 
1317
+ var useSearchClickOutside = function useSearchClickOutside(ref, searchResults, setCachedResults, setIsSearchFocused, setSearchResults) {
1318
+ React.useEffect(function () {
1319
+ var handleClickOutside = function handleClickOutside(event) {
1320
+ if (ref.current && !ref.current.contains(event.target)) {
1321
+ setCachedResults(searchResults);
1322
+ setIsSearchFocused(false);
1323
+ setSearchResults({
1324
+ brands: [],
1325
+ products: []
1326
+ });
1327
+ }
1328
+ };
1329
+
1330
+ document.addEventListener('mousedown', handleClickOutside);
1331
+ return function () {
1332
+ document.removeEventListener('mousedown', handleClickOutside);
1333
+ };
1334
+ }, [ref, searchResults, setCachedResults, setIsSearchFocused, setSearchResults]);
1335
+ };
1336
+ var useSearchInputChange = function useSearchInputChange(setSearchValue, setIsSearchFocused, debouncedSearch, setSearchResults, setCachedResults) {
1337
+ return React.useCallback(function (event) {
1338
+ var value = event.target.value;
1339
+ setSearchValue(value);
1340
+ setIsSearchFocused(true);
1341
+
1342
+ if (value.trim().length >= 3) {
1343
+ debouncedSearch(value);
1344
+ } else {
1345
+ setSearchResults({
1346
+ brands: [],
1347
+ products: []
1348
+ });
1349
+ setCachedResults({
1350
+ brands: [],
1351
+ products: []
1352
+ });
1353
+ }
1354
+ }, [setSearchValue, setIsSearchFocused, debouncedSearch, setSearchResults, setCachedResults]);
1355
+ };
1356
+ var useSearchInputFocus = function useSearchInputFocus(searchValue, setIsSearchFocused, cachedResults, setSearchResults) {
1357
+ return React.useCallback(function () {
1358
+ setIsSearchFocused(true);
1359
+
1360
+ if (searchValue.trim().length >= 3) {
1361
+ setSearchResults(cachedResults);
1362
+ }
1363
+ }, [searchValue, setIsSearchFocused, cachedResults, setSearchResults]);
1364
+ };
1365
+ var useSearchInputKeyDown = function useSearchInputKeyDown(searchValue, immediateSearch, setIsSearchFocused) {
1366
+ var setSearchValue = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
1367
+ return React.useCallback(function (event) {
1368
+ if (event.key === 'Enter') {
1369
+ event.preventDefault();
1370
+
1371
+ if (searchValue.trim().length >= 3) {
1372
+ immediateSearch(searchValue);
1373
+ }
1374
+
1375
+ setIsSearchFocused(false);
1376
+ } else if (event.key === 'Escape' && setSearchValue) {
1377
+ setSearchValue('');
1378
+ setIsSearchFocused(false);
1379
+ }
1380
+ }, [searchValue, immediateSearch, setIsSearchFocused, setSearchValue]);
1381
+ };
1382
+
1290
1383
  var LuxityMobileHeader = function LuxityMobileHeader(_ref) {
1291
1384
  var logoSrc = _ref.logoSrc,
1292
1385
  menuIcon = _ref.menuIcon,
@@ -1369,73 +1462,41 @@
1369
1462
  searchResults = _useState8[0],
1370
1463
  setSearchResults = _useState8[1];
1371
1464
 
1372
- var _useState9 = React.useState(false),
1465
+ var _useState9 = React.useState({
1466
+ brands: [],
1467
+ products: []
1468
+ }),
1373
1469
  _useState10 = _slicedToArray(_useState9, 2),
1374
- isSearchFocused = _useState10[0],
1375
- setIsSearchFocused = _useState10[1];
1470
+ cachedResults = _useState10[0],
1471
+ setCachedResults = _useState10[1];
1376
1472
 
1377
- var _useState11 = React.useState({
1473
+ var _useState11 = React.useState(false),
1474
+ _useState12 = _slicedToArray(_useState11, 2),
1475
+ isSearchFocused = _useState12[0],
1476
+ setIsSearchFocused = _useState12[1];
1477
+
1478
+ var _useState13 = React.useState({
1378
1479
  trending_brands: [],
1379
1480
  latest_products: []
1380
1481
  }),
1381
- _useState12 = _slicedToArray(_useState11, 2),
1382
- initialSearchView = _useState12[0],
1383
- setInitialSearchView = _useState12[1];
1482
+ _useState14 = _slicedToArray(_useState13, 2),
1483
+ initialSearchView = _useState14[0],
1484
+ setInitialSearchView = _useState14[1];
1384
1485
 
1385
1486
  var searchResultsRef = React.useRef(null);
1386
1487
  var searchInputRef = React.useRef(null);
1387
- var debouncedSearch = createDebouncedSearch(setSearchResults);
1488
+ var debouncedSearch = createDebouncedSearch(function (results) {
1489
+ setSearchResults(results);
1490
+ setCachedResults(results);
1491
+ });
1388
1492
  var immediateSearch = createImmediateSearch(setSearchValue, setSearchResults, onSearchSubmit);
1389
-
1390
- var handleChange = function handleChange(event) {
1391
- var value = event.target.value;
1392
- setSearchValue(value);
1393
- setIsSearchFocused(true);
1394
-
1395
- if (value.trim().length >= 3) {
1396
- debouncedSearch(value);
1397
- } else {
1398
- setSearchResults({
1399
- brands: [],
1400
- products: []
1401
- });
1402
- }
1403
- };
1404
-
1405
- var handleKeyDown = function handleKeyDown(event) {
1406
- if (event.key === 'Enter') {
1407
- event.preventDefault();
1408
-
1409
- if (searchValue.trim().length >= 3) {
1410
- immediateSearch(searchValue);
1411
- setIsSearchFocused(false);
1412
- }
1413
- } else if (event.key === 'Escape') {
1414
- setSearchValue('');
1415
- setIsSearchFocused(false);
1416
- }
1417
- };
1418
-
1493
+ var handleChange = useSearchInputChange(setSearchValue, setIsSearchFocused, debouncedSearch, setSearchResults, setCachedResults);
1494
+ var handleKeyDown = useSearchInputKeyDown(searchValue, immediateSearch, setIsSearchFocused, setSearchValue);
1419
1495
  React.useMemo(function () {
1420
1496
  fetchInitialSearchData(initialSearchData, setInitialSearchView);
1421
1497
  }, [initialSearchData, fetchInitialSearchData]);
1422
- React.useEffect(function () {
1423
- var handleClickOutside = function handleClickOutside(event) {
1424
- if (searchResultsRef.current && !searchResultsRef.current.contains(event.target)) {
1425
- setSearchValue('');
1426
- setIsSearchFocused(false);
1427
- setSearchResults({
1428
- brands: [],
1429
- products: []
1430
- });
1431
- }
1432
- };
1433
-
1434
- document.addEventListener('mousedown', handleClickOutside);
1435
- return function () {
1436
- document.removeEventListener('mousedown', handleClickOutside);
1437
- };
1438
- }, []);
1498
+ useSearchClickOutside(searchResultsRef, searchResults, setCachedResults, setIsSearchFocused, setSearchResults);
1499
+ var handleSearchFocus = useSearchInputFocus(searchValue, setIsSearchFocused, cachedResults, setSearchResults);
1439
1500
  React.useEffect(function () {
1440
1501
  if (showSearchBar && searchInputRef.current) {
1441
1502
  searchInputRef.current.focus();
@@ -1599,9 +1660,7 @@
1599
1660
  value: searchValue,
1600
1661
  onChange: handleChange,
1601
1662
  onKeyDown: handleKeyDown,
1602
- onFocus: function onFocus() {
1603
- return setIsSearchFocused(true);
1604
- }
1663
+ onFocus: handleSearchFocus
1605
1664
  })), /*#__PURE__*/React__default.createElement("button", {
1606
1665
  type: "button",
1607
1666
  onClick: onSearchClick
package/build/bundle.css CHANGED
@@ -1 +1 @@
1
- .navbar{box-shadow:2px 2px 10px #dfdede;display:flex;padding-bottom:10px;padding-top:20px;position:relative}.navbar__link-item--desktop{align-items:center;display:flex;height:35px;margin:auto 0;padding-top:5px}.navbar__mobile-wrapper{align-items:center;display:flex;flex-direction:column;padding-bottom:20px;padding-left:32px;padding-right:32px}.navbar__container{display:flex;margin:0 auto;max-width:1280px;padding-left:12px;padding-right:12px;width:100%}.navbar__body{flex-basis:60%}.navbar__wrapper{align-items:center;display:flex;justify-content:space-between;width:100%}.navbar__product-search-wrapper{align-items:center;display:flex;justify-content:center;padding:0 20%;width:100%}@media only screen and (max-width:879px){.navbar__product-search-wrapper{padding:0}}.navbar__input-close-icon{height:auto;margin-bottom:10px;margin-left:10px;width:20px}@media only screen and (max-width:879px){.navbar__input-close-icon{margin-bottom:0;margin-left:0;width:15px}}.navbar__menu-icon{width:30px}.navbar__product-search{align-items:center;display:flex;max-width:545px;width:100%}.navbar__logo-wrapper{margin-right:18px;width:200px}.navbar__logo{width:200px}@media only screen and (max-width:879px){.navbar__logo{margin-left:10px;margin-top:5px;width:125px}}.navbar__form-input{align-items:center;background:transparent;border:none;display:flex;font-size:13px;outline:none;padding:8px;width:100%}.navbar__product-search{border:1px solid #dfdede;margin-bottom:10px}@media only screen and (max-width:879px){.navbar__product-search{border:none;border-bottom:1px solid #dfdede;margin-bottom:0;margin-right:10px;margin-top:10px}}.navbar__section{align-items:flex-start;display:flex;flex-direction:row;justify-content:space-between;width:100%}.navbar__link{display:inline-block;font-family:Martel Sans;font-size:14px;font-weight:700;margin-right:10px;overflow:hidden;text-transform:uppercase;transition:.3s ease-in-out}.navbar__link:after{background-color:#000;content:"";display:block;height:2px;transition:width .25s ease-out;width:0}.navbar__link:hover:after{width:100%}.navbar__link:hover .navbar__dropdown{animation:fadeInDropdown .3s ease-in-out;display:block}.navbar__dropdown{background-color:#fff;box-shadow:5px 5px 5px #dfdede;display:none;left:0;position:absolute;width:100%;z-index:999}@keyframes fadeInDropdown{0%{opacity:0;transform:translateY(-10px)}to{opacity:1;transform:translateY(0)}}.navbar__company-link{font-size:13px;font-weight:400;list-style:none;margin-left:18px;text-decoration:none}.navbar__company-block{align-items:center;background-color:#000;color:#fff;display:flex;font-weight:700;height:33px;justify-content:center;margin-right:0;padding:0 18px;text-transform:uppercase}.navbar__input-search-icon{height:auto;margin-left:1.125rem;margin-right:.375rem;width:15px}.navbar__nav-links{align-items:center;display:flex}.navbar__nav-links--wrap{flex-wrap:wrap}.navbar__icons{align-items:center;display:flex;height:40px;justify-content:flex-end;margin-bottom:10px}@media only screen and (max-width:879px){.navbar__icons{display:block;height:20px;margin-bottom:0}}.navbar__icon{cursor:pointer;height:auto;margin-right:18px;width:20px}@media only screen and (max-width:879px){.navbar__icon{margin-right:0}}.navbar__icon--app{cursor:pointer;height:auto;margin-left:12px;width:20px}@media only screen and (max-width:879px){.navbar__icon--app{margin-right:0}}.navbar__vip-icon{height:16px;position:absolute;right:-12px;top:-4px;width:16px}.navbar__cart-icon{position:relative}.navbar__cart-count{align-items:center;background-color:#000;border-radius:50%;bottom:50%;color:#fff;display:flex;font-size:13px;height:20px;justify-content:center;left:100%;position:absolute;width:20px}.footer__newsletter-section{align-items:center;background-color:#000;color:#fff;display:flex;justify-content:space-between;padding:2.265rem 0}@media only screen and (max-width:879px){.footer__newsletter-section{flex-direction:column}}.footer__newsletter-wrapper{align-items:center;display:flex;justify-content:space-between;margin:0 auto;max-width:1280px;padding-left:32px;padding-right:32px;width:100%}@media only screen and (max-width:879px){.footer__newsletter-wrapper{flex-direction:column}.footer__link-container{flex-basis:50%}}.footer__newsletter-icon{height:30px;position:absolute;right:0;top:0;width:32px}.footer__newsletter-form{flex-basis:50%;max-width:250px;position:relative}@media only screen and (max-width:879px){.footer__newsletter-form{display:block;margin-top:20px;max-width:100%;width:100%}}.footer__newsletter-title{font-family:Martel Sans,sans-serif;font-size:14px;font-weight:700;letter-spacing:3px;margin-bottom:1.125rem;text-transform:uppercase}.footer__newsletter-text{font-size:14px}.footer__form-input{background-color:#000;border:none;border-bottom:1px solid #fff;color:#fff;height:30px;outline:none;width:100%}.footer__form-input::-moz-placeholder{color:#fff;font-weight:400}.footer__form-input::placeholder{color:#fff;font-weight:400}.footer__form-errors{color:#fff;margin-top:5px}.footer__main-section{align-items:flex-start;display:flex;justify-content:space-between;margin-bottom:50px;margin-top:80px}.footer__link-title{font-family:El Messiri;font-size:16px;font-weight:700;margin-bottom:20px;text-transform:uppercase}@media only screen and (max-width:879px){.footer__link-title{margin-bottom:10px}}.footer__link-child{margin-top:25px}.footer__links{display:flex;flex-direction:column}.footer__link{color:#939393;cursor:pointer;font-family:Martel Sans;font-size:14px;line-height:20px;margin-bottom:7px;text-align:left;text-decoration:none}.footer__link:hover{color:#000;text-decoration:underline}@media only screen and (max-width:879px){.footer__link{margin-bottom:10px}}.footer__link-wrapper{align-items:center;display:flex;gap:5px}.footer__link-icon{height:30px;margin-bottom:18px}.footer__text{color:#939393;font-family:Martel Sans;font-size:14px;line-height:20px;margin-bottom:15px;text-align:left;text-decoration:none}.footer__store-hours{margin-top:35px}.footer__copyrights-section{border-top:1px solid;display:flex;justify-content:space-between;padding-bottom:20px;padding-top:20px}.footer__logo{height:30px;width:135px}.footer__payment-icons{align-items:center;display:flex;gap:8px}.footer__wrapper{margin:0 auto;max-width:1280px;padding-left:32px;padding-right:32px;width:100%}@media only screen and (max-width:879px){.footer__wrapper{padding:32px 0 0 24px}}.footer__wrapper--desktop{display:block}@media only screen and (max-width:879px){.footer__wrapper--desktop{display:none}}.footer__wrapper--mobile{display:none}@media only screen and (max-width:879px){.footer__wrapper--mobile{display:block;padding-top:30px}}.footer__copyright{font-size:10px;line-height:22px}.footer__copyright--mobile{display:none}@media only screen and (max-width:879px){.footer__copyright--mobile{display:block;padding:30px 10px 30px 0;text-align:center}}.footer__section-row{display:flex;gap:50%}@media only screen and (max-width:879px){.footer__section-row{gap:unset}}.side-nav{font-family:Martel Sans}.side-nav__errors{align-items:center;color:red;display:flex;font-size:16px;justify-content:center}.side-nav__overlay{background-color:rgba(78,73,73,.51);height:100%;opacity:0;position:fixed;top:0;transition:opacity .5s ease-out 0s,visibility .5s ease-out 0s;width:100%;z-index:99999}.side-nav__overlay--visible{opacity:1;visibility:visible}.side-nav__overlay--hidden{opacity:1;visibility:hidden}.side-nav__content{background-color:#fff;bottom:0;overflow-y:scroll;padding:1.5rem;position:fixed;top:0;transition:left .5s ease-in-out;width:80%;z-index:99999}.side-nav__content--hidden{display:none}.side-nav__content--open{left:0}.side-nav__content--closed{left:-100%}.side-nav__menu-title-wrapper{align-items:center;background-color:transparent;border:none;display:flex;justify-content:space-between;outline:none;width:100%}.side-nav__icon-container{float:right;margin-bottom:10px}.side-nav__menu-title{font-size:14px;font-weight:700;line-height:20px;text-transform:uppercase}.side-nav__accordion-icon{height:auto;width:15px}.side-nav__menu-item{margin-bottom:25px}.side-nav__close-icon{height:20px;margin-left:auto;width:20px}.side-nav__back-button-wrapper{align-items:center;display:flex;margin-bottom:25px}.side-nav__back-icon{height:20px;width:20px}.side-nav__back-button,.side-nav__sub-menu-title{font-weight:700;text-transform:uppercase}.side-nav__sub-menu-title{font-size:14px;margin-bottom:10px}.side-nav__elements{display:flex;flex-direction:column}.side-nav__element{color:#555;cursor:pointer;line-height:20px;margin-bottom:10px}.side-nav__element,.side-nav__sub-link{font-size:14px;font-weight:400;text-transform:capitalize}.side-nav__block-button{background-color:#000;color:#fff;font-weight:700;padding:10px 0;width:100%}.interests__add-button{display:flex;flex-direction:row;gap:10px;width:100%}@media only screen and (max-width:879px){.interests__add-button{flex-direction:column}}.interests__section-wrapper{display:flex;flex-direction:column;width:100%}.interests__select-option{display:flex;flex-direction:column;margin-bottom:15px}.interests__title{font-family:El Messiri;font-size:16px;margin-bottom:10px}@charset "UTF-8";.currency-select-container{align-items:center;display:flex;margin-right:18px;position:relative}.currency-select-container .currency-flag{margin-right:5px}.currency-select-container .currency-flag img{height:15px;-o-object-fit:cover;object-fit:cover;width:20px}.currency-select-container .currency-select{appearance:none;-webkit-appearance:none;-moz-appearance:none;background-color:transparent;border:none;color:#000;cursor:pointer;font-family:inherit;font-size:14px;margin:0;outline:none;padding:5px 15px 5px 5px}.currency-select-container .currency-select::-ms-expand{display:none}.currency-select-container .currency-select:focus{box-shadow:none;outline:none}.currency-select-container .currency-select:-moz-focusring{color:transparent;text-shadow:0 0 0 #000}.currency-select-container:after{color:#000;content:"▼";font-size:10px;pointer-events:none;position:absolute;right:0;top:50%;transform:translateY(-50%)}@media only screen and (max-width:879px){.currency-select-container .currency-select{appearance:menulist;-webkit-appearance:menulist;-moz-appearance:menulist;padding-right:0}.currency-select-container:after{display:none}}.currency-select-container.disabled{cursor:not-allowed;opacity:.7}.currency-select-container.disabled .currency-select{pointer-events:none}.side-nav{font-family:Martel Sans}.side-nav__errors{align-items:center;color:red;display:flex;font-size:16px;justify-content:center}.side-nav__overlay{background-color:rgba(78,73,73,.51);height:100%;opacity:0;position:fixed;top:0;transition:opacity .5s ease-out 0s,visibility .5s ease-out 0s;width:100%;z-index:99999}.side-nav__overlay--visible{opacity:1;visibility:visible}.side-nav__overlay--hidden{opacity:1;visibility:hidden}.side-nav__content{background-color:#fff;bottom:0;overflow-y:scroll;padding:1.5rem;position:fixed;top:0;transition:left .5s ease-in-out;width:80%;z-index:99999}.side-nav__content--hidden{display:none}.side-nav__content--open{left:0}.side-nav__content--closed{left:-100%}.side-nav__menu-title-wrapper{align-items:center;background-color:transparent;border:none;display:flex;outline:none;width:100%}.side-nav__icon-container{float:right;margin-bottom:10px}.side-nav__menu-title{align-items:center;display:flex;font-size:14px;font-weight:700;justify-content:center;line-height:20px;text-transform:uppercase}.side-nav__menu-icon{display:flex;height:25px;margin-right:10px;width:25px}.side-nav__menu-divider{margin-bottom:40px}.side-nav__accordion-icon{height:auto;width:15px}.side-nav__menu-item{margin-bottom:25px}.side-nav__close-icon{height:20px;margin-left:auto;width:20px}.side-nav__back-button-wrapper{align-items:center;display:flex;margin-bottom:25px}.side-nav__back-icon{height:20px;width:20px}.side-nav__back-button,.side-nav__sub-menu-title{font-weight:700;text-transform:uppercase}.side-nav__sub-menu-title{font-size:14px;margin-bottom:10px}.side-nav__elements{display:flex;flex-direction:column}.side-nav__element{color:#555;cursor:pointer;line-height:20px;margin-bottom:10px}.side-nav__element,.side-nav__sub-link{font-size:14px;font-weight:400;text-transform:capitalize}.side-nav__block-button{background-color:#000;color:#fff;font-weight:700;padding:10px 0;width:100%}.stores-dropdown{align-items:flex-start;display:flex;font-family:Martel Sans;gap:20px;margin-left:auto;margin-right:auto;max-width:1280px;overflow-x:auto;padding:20px 15px}.stores-dropdown__image{height:200px;-o-object-fit:cover;object-fit:cover;width:100%}.stores-dropdown__store-details{flex-basis:20%}.stores-dropdown__title{font-family:El Messiri}.stores-dropdown__main-title,.stores-dropdown__title{font-size:16px;font-weight:400;letter-spacing:3px;margin-top:20px}.stores-dropdown__main-title{font-weight:700;margin-bottom:10px}.stores-dropdown__open-days{font-size:12px;font-weight:700;line-height:20px}.stores-dropdown__open-hours{font-size:12px;font-weight:400;line-height:20px}.stores-dropdown__queries-title{font-family:El Messiri;font-size:16px;font-weight:400;letter-spacing:3px}.stores-dropdown__contact-details{font-size:16px;font-weight:700}.stores-dropdown__view-more{cursor:pointer;font-size:14px;font-weight:400;margin-top:10px;text-transform:capitalize}.search-results{background:#fff;border:1px solid #dfdede;border-radius:2px;box-shadow:0 2px 8px rgba(0,0,0,.08);display:flex;position:absolute;width:770px;z-index:50}@media only screen and (max-width:1052px){.search-results{border:none;box-shadow:none;flex-direction:column;top:120px;width:100%}}.search-results__section:first-child{border-right:1px solid #dfdede;flex:1;min-width:240px}.search-results__section:last-child{display:flex;flex:2;flex-direction:column}.search-results__section-header{align-items:center;display:flex;justify-content:space-between}.search-results__header{color:#000;font-family:Martel Sans;font-size:14px;font-weight:600;margin-bottom:0;padding:16px 20px;text-transform:uppercase}.search-results__view-all-link{display:none}@media only screen and (max-width:879px){.search-results__view-all-link{color:#000;display:block;font-family:Martel Sans;font-size:14px;margin-right:20px}}.search-results__list{display:flex;flex-direction:column}.search-results__item{color:grey;font-family:Martel Sans;font-size:14px;padding:8px 20px;text-decoration:none}.search-results__product-list{display:flex;flex-direction:column;overflow-y:auto}.product-card{color:inherit;display:flex;padding:12px 20px;text-decoration:none;transition:background-color .15s ease}.product-card:hover{background-color:#f4f4f4}.product-card__image-container{border-radius:2px;flex-shrink:0;height:90px;margin-right:16px;overflow:hidden;width:90px}.product-card__image{height:100%;-o-object-fit:cover;object-fit:cover;width:100%}.product-card__details{display:flex;flex:1;flex-direction:column}.product-card__name{color:#000;font-family:Martel Sans;font-size:14px;line-height:1.4;margin-bottom:24px}.product-card__brand-name{font-weight:600}.product-card__info-row{align-items:flex-end;display:flex;justify-content:space-between}@media only screen and (max-width:879px){.product-card__info-row{align-items:flex-start;flex-direction:column}}.product-card__price-group{display:flex;flex-direction:column;gap:4px}.product-card__price{color:#000;font-family:Martel Sans;font-size:14px;font-weight:600;line-height:1}.product-card__retail-price{color:#939393;font-family:Martel Sans;font-size:14px;text-decoration:line-through}.product-card__condition{color:#000;font-family:Martel Sans;font-size:13px;margin-right:20px;text-align:right}.product-card__condition-label{color:#939393;margin-right:4px}.search-results__view-all-button{background-color:#f5f0ea!important;border:none;color:#000;cursor:pointer;font-family:Martel Sans;font-size:13px;font-weight:400;padding:16px;text-align:center}@media only screen and (max-width:879px){.search-results__view-all-button{display:none}}.dropdown{display:flex;justify-content:space-between;margin-left:auto;margin-right:auto;max-width:1280px;min-height:500px;overflow-x:auto;padding:20px 0}.dropdown__errors{align-items:center;color:red;display:flex;font-size:16px;justify-content:center;min-height:300px}.dropdown__column{flex:1;padding-left:12px}.dropdown__column:nth-child(2){flex:2}.dropdown__title{font-family:El Messiri;font-size:16px;font-weight:700;letter-spacing:3px;line-height:1;margin-bottom:20px;text-transform:uppercase}.dropdown__elements{display:grid;grid-template-columns:repeat(auto-fill,minmax(200px,1fr));max-height:800px;overflow-y:auto}.dropdown__brand-elements{-moz-column-count:3;column-count:3;max-height:800px}.dropdown__brand-element{cursor:pointer;margin-bottom:10px}.dropdown__element{flex-basis:33.33%;font-family:Martel Sans;font-size:14px;font-weight:400;margin-bottom:10px;text-transform:capitalize}.cover-spinner{align-items:center;background-color:hsla(0,0%,100%,.7);display:flex;height:100%;justify-content:center;min-height:400px;position:relative;top:50%;width:100%;z-index:9999}.cover-spinner:after{animation:spin 1.5s linear infinite;border:4px dotted #000;border-radius:50%;border-top-color:transparent;content:"";display:block;height:40px;position:absolute;width:40px}@keyframes spin{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}
1
+ .footer__newsletter-section{align-items:center;background-color:#000;color:#fff;display:flex;justify-content:space-between;padding:2.265rem 0}@media only screen and (max-width:879px){.footer__newsletter-section{flex-direction:column}}.footer__newsletter-wrapper{align-items:center;display:flex;justify-content:space-between;margin:0 auto;max-width:1280px;padding-left:32px;padding-right:32px;width:100%}@media only screen and (max-width:879px){.footer__newsletter-wrapper{flex-direction:column}.footer__link-container{flex-basis:50%}}.footer__newsletter-icon{height:30px;position:absolute;right:0;top:0;width:32px}.footer__newsletter-form{flex-basis:50%;max-width:250px;position:relative}@media only screen and (max-width:879px){.footer__newsletter-form{display:block;margin-top:20px;max-width:100%;width:100%}}.footer__newsletter-title{font-family:Martel Sans,sans-serif;font-size:14px;font-weight:700;letter-spacing:3px;margin-bottom:1.125rem;text-transform:uppercase}.footer__newsletter-text{font-size:14px}.footer__form-input{background-color:#000;border:none;border-bottom:1px solid #fff;color:#fff;height:30px;outline:none;width:100%}.footer__form-input::-moz-placeholder{color:#fff;font-weight:400}.footer__form-input::placeholder{color:#fff;font-weight:400}.footer__form-errors{color:#fff;margin-top:5px}.footer__main-section{align-items:flex-start;display:flex;justify-content:space-between;margin-bottom:50px;margin-top:80px}.footer__link-title{font-family:El Messiri;font-size:16px;font-weight:700;margin-bottom:20px;text-transform:uppercase}@media only screen and (max-width:879px){.footer__link-title{margin-bottom:10px}}.footer__link-child{margin-top:25px}.footer__links{display:flex;flex-direction:column}.footer__link{color:#939393;cursor:pointer;font-family:Martel Sans;font-size:14px;line-height:20px;margin-bottom:7px;text-align:left;text-decoration:none}.footer__link:hover{color:#000;text-decoration:underline}@media only screen and (max-width:879px){.footer__link{margin-bottom:10px}}.footer__link-wrapper{align-items:center;display:flex;gap:5px}.footer__link-icon{height:30px;margin-bottom:18px}.footer__text{color:#939393;font-family:Martel Sans;font-size:14px;line-height:20px;margin-bottom:15px;text-align:left;text-decoration:none}.footer__store-hours{margin-top:35px}.footer__copyrights-section{border-top:1px solid;display:flex;justify-content:space-between;padding-bottom:20px;padding-top:20px}.footer__logo{height:30px;width:135px}.footer__payment-icons{align-items:center;display:flex;gap:8px}.footer__wrapper{margin:0 auto;max-width:1280px;padding-left:32px;padding-right:32px;width:100%}@media only screen and (max-width:879px){.footer__wrapper{padding:32px 0 0 24px}}.footer__wrapper--desktop{display:block}@media only screen and (max-width:879px){.footer__wrapper--desktop{display:none}}.footer__wrapper--mobile{display:none}@media only screen and (max-width:879px){.footer__wrapper--mobile{display:block;padding-top:30px}}.footer__copyright{font-size:10px;line-height:22px}.footer__copyright--mobile{display:none}@media only screen and (max-width:879px){.footer__copyright--mobile{display:block;padding:30px 10px 30px 0;text-align:center}}.footer__section-row{display:flex;gap:50%}@media only screen and (max-width:879px){.footer__section-row{gap:unset}}.navbar{box-shadow:2px 2px 10px #dfdede;display:flex;padding-bottom:10px;padding-top:20px;position:relative}.navbar__link-item--desktop{align-items:center;display:flex;height:35px;margin:auto 0;padding-top:5px}.navbar__mobile-wrapper{align-items:center;display:flex;flex-direction:column;padding-bottom:20px;padding-left:32px;padding-right:32px}.navbar__container{display:flex;margin:0 auto;max-width:1280px;padding-left:12px;padding-right:12px;width:100%}.navbar__body{flex-basis:60%}.navbar__wrapper{align-items:center;display:flex;justify-content:space-between;width:100%}.navbar__product-search-wrapper{align-items:center;display:flex;justify-content:center;padding:0 20%;width:100%}@media only screen and (max-width:879px){.navbar__product-search-wrapper{padding:0}}.navbar__input-close-icon{height:auto;margin-bottom:10px;margin-left:10px;width:20px}@media only screen and (max-width:879px){.navbar__input-close-icon{margin-bottom:0;margin-left:0;width:15px}}.navbar__menu-icon{width:30px}.navbar__product-search{align-items:center;display:flex;max-width:545px;width:100%}.navbar__logo-wrapper{margin-right:18px;width:200px}.navbar__logo{width:200px}@media only screen and (max-width:879px){.navbar__logo{margin-left:10px;margin-top:5px;width:125px}}.navbar__form-input{align-items:center;background:transparent;border:none;display:flex;font-size:13px;outline:none;padding:8px;width:100%}.navbar__product-search{border:1px solid #dfdede;margin-bottom:10px}@media only screen and (max-width:879px){.navbar__product-search{border:none;border-bottom:1px solid #dfdede;margin-bottom:0;margin-right:10px;margin-top:10px}}.navbar__section{align-items:flex-start;display:flex;flex-direction:row;justify-content:space-between;width:100%}.navbar__link{display:inline-block;font-family:Martel Sans;font-size:14px;font-weight:700;margin-right:10px;overflow:hidden;text-transform:uppercase;transition:.3s ease-in-out}.navbar__link:after{background-color:#000;content:"";display:block;height:2px;transition:width .25s ease-out;width:0}.navbar__link:hover:after{width:100%}.navbar__link:hover .navbar__dropdown{animation:fadeInDropdown .3s ease-in-out;display:block}.navbar__dropdown{background-color:#fff;box-shadow:5px 5px 5px #dfdede;display:none;left:0;position:absolute;width:100%;z-index:999}@keyframes fadeInDropdown{0%{opacity:0;transform:translateY(-10px)}to{opacity:1;transform:translateY(0)}}.navbar__company-link{font-size:13px;font-weight:400;list-style:none;margin-left:18px;text-decoration:none}.navbar__company-block{align-items:center;background-color:#000;color:#fff;display:flex;font-weight:700;height:33px;justify-content:center;margin-right:0;padding:0 18px;text-transform:uppercase}.navbar__input-search-icon{height:auto;margin-left:1.125rem;margin-right:.375rem;width:15px}.navbar__nav-links{align-items:center;display:flex}.navbar__nav-links--wrap{flex-wrap:wrap}.navbar__icons{align-items:center;display:flex;height:40px;justify-content:flex-end;margin-bottom:10px}@media only screen and (max-width:879px){.navbar__icons{display:block;height:20px;margin-bottom:0}}.navbar__icon{cursor:pointer;height:auto;margin-right:18px;width:20px}@media only screen and (max-width:879px){.navbar__icon{margin-right:0}}.navbar__icon--app{cursor:pointer;height:auto;margin-left:12px;width:20px}@media only screen and (max-width:879px){.navbar__icon--app{margin-right:0}}.navbar__vip-icon{height:16px;position:absolute;right:-12px;top:-4px;width:16px}.navbar__cart-icon{position:relative}.navbar__cart-count{align-items:center;background-color:#000;border-radius:50%;bottom:50%;color:#fff;display:flex;font-size:13px;height:20px;justify-content:center;left:100%;position:absolute;width:20px}.side-nav{font-family:Martel Sans}.side-nav__errors{align-items:center;color:red;display:flex;font-size:16px;justify-content:center}.side-nav__overlay{background-color:rgba(78,73,73,.51);height:100%;opacity:0;position:fixed;top:0;transition:opacity .5s ease-out 0s,visibility .5s ease-out 0s;width:100%;z-index:99999}.side-nav__overlay--visible{opacity:1;visibility:visible}.side-nav__overlay--hidden{opacity:1;visibility:hidden}.side-nav__content{background-color:#fff;bottom:0;overflow-y:scroll;padding:1.5rem;position:fixed;top:0;transition:left .5s ease-in-out;width:80%;z-index:99999}.side-nav__content--hidden{display:none}.side-nav__content--open{left:0}.side-nav__content--closed{left:-100%}.side-nav__menu-title-wrapper{align-items:center;background-color:transparent;border:none;display:flex;justify-content:space-between;outline:none;width:100%}.side-nav__icon-container{float:right;margin-bottom:10px}.side-nav__menu-title{font-size:14px;font-weight:700;line-height:20px;text-transform:uppercase}.side-nav__accordion-icon{height:auto;width:15px}.side-nav__menu-item{margin-bottom:25px}.side-nav__close-icon{height:20px;margin-left:auto;width:20px}.side-nav__back-button-wrapper{align-items:center;display:flex;margin-bottom:25px}.side-nav__back-icon{height:20px;width:20px}.side-nav__back-button,.side-nav__sub-menu-title{font-weight:700;text-transform:uppercase}.side-nav__sub-menu-title{font-size:14px;margin-bottom:10px}.side-nav__elements{display:flex;flex-direction:column}.side-nav__element{color:#555;cursor:pointer;line-height:20px;margin-bottom:10px}.side-nav__element,.side-nav__sub-link{font-size:14px;font-weight:400;text-transform:capitalize}.side-nav__block-button{background-color:#000;color:#fff;font-weight:700;padding:10px 0;width:100%}.side-nav{font-family:Martel Sans}.side-nav__errors{align-items:center;color:red;display:flex;font-size:16px;justify-content:center}.side-nav__overlay{background-color:rgba(78,73,73,.51);height:100%;opacity:0;position:fixed;top:0;transition:opacity .5s ease-out 0s,visibility .5s ease-out 0s;width:100%;z-index:99999}.side-nav__overlay--visible{opacity:1;visibility:visible}.side-nav__overlay--hidden{opacity:1;visibility:hidden}.side-nav__content{background-color:#fff;bottom:0;overflow-y:scroll;padding:1.5rem;position:fixed;top:0;transition:left .5s ease-in-out;width:80%;z-index:99999}.side-nav__content--hidden{display:none}.side-nav__content--open{left:0}.side-nav__content--closed{left:-100%}.side-nav__menu-title-wrapper{align-items:center;background-color:transparent;border:none;display:flex;outline:none;width:100%}.side-nav__icon-container{float:right;margin-bottom:10px}.side-nav__menu-title{align-items:center;display:flex;font-size:14px;font-weight:700;justify-content:center;line-height:20px;text-transform:uppercase}.side-nav__menu-icon{display:flex;height:25px;margin-right:10px;width:25px}.side-nav__menu-divider{margin-bottom:40px}.side-nav__accordion-icon{height:auto;width:15px}.side-nav__menu-item{margin-bottom:25px}.side-nav__close-icon{height:20px;margin-left:auto;width:20px}.side-nav__back-button-wrapper{align-items:center;display:flex;margin-bottom:25px}.side-nav__back-icon{height:20px;width:20px}.side-nav__back-button,.side-nav__sub-menu-title{font-weight:700;text-transform:uppercase}.side-nav__sub-menu-title{font-size:14px;margin-bottom:10px}.side-nav__elements{display:flex;flex-direction:column}.side-nav__element{color:#555;cursor:pointer;line-height:20px;margin-bottom:10px}.side-nav__element,.side-nav__sub-link{font-size:14px;font-weight:400;text-transform:capitalize}.side-nav__block-button{background-color:#000;color:#fff;font-weight:700;padding:10px 0;width:100%}.interests__add-button{display:flex;flex-direction:row;gap:10px;width:100%}@media only screen and (max-width:879px){.interests__add-button{flex-direction:column}}.interests__section-wrapper{display:flex;flex-direction:column;width:100%}.interests__select-option{display:flex;flex-direction:column;margin-bottom:15px}.interests__title{font-family:El Messiri;font-size:16px;margin-bottom:10px}@charset "UTF-8";.currency-select-container{align-items:center;display:flex;margin-right:18px;position:relative}.currency-select-container .currency-flag{margin-right:5px}.currency-select-container .currency-flag img{height:15px;-o-object-fit:cover;object-fit:cover;width:20px}.currency-select-container .currency-select{appearance:none;-webkit-appearance:none;-moz-appearance:none;background-color:transparent;border:none;color:#000;cursor:pointer;font-family:inherit;font-size:14px;margin:0;outline:none;padding:5px 15px 5px 5px}.currency-select-container .currency-select::-ms-expand{display:none}.currency-select-container .currency-select:focus{box-shadow:none;outline:none}.currency-select-container .currency-select:-moz-focusring{color:transparent;text-shadow:0 0 0 #000}.currency-select-container:after{color:#000;content:"▼";font-size:10px;pointer-events:none;position:absolute;right:0;top:50%;transform:translateY(-50%)}@media only screen and (max-width:879px){.currency-select-container .currency-select{appearance:menulist;-webkit-appearance:menulist;-moz-appearance:menulist;padding-right:0}.currency-select-container:after{display:none}}.currency-select-container.disabled{cursor:not-allowed;opacity:.7}.currency-select-container.disabled .currency-select{pointer-events:none}.stores-dropdown{align-items:flex-start;display:flex;font-family:Martel Sans;gap:20px;margin-left:auto;margin-right:auto;max-width:1280px;overflow-x:auto;padding:20px 15px}.stores-dropdown__image{height:200px;-o-object-fit:cover;object-fit:cover;width:100%}.stores-dropdown__store-details{flex-basis:20%}.stores-dropdown__title{font-family:El Messiri}.stores-dropdown__main-title,.stores-dropdown__title{font-size:16px;font-weight:400;letter-spacing:3px;margin-top:20px}.stores-dropdown__main-title{font-weight:700;margin-bottom:10px}.stores-dropdown__open-days{font-size:12px;font-weight:700;line-height:20px}.stores-dropdown__open-hours{font-size:12px;font-weight:400;line-height:20px}.stores-dropdown__queries-title{font-family:El Messiri;font-size:16px;font-weight:400;letter-spacing:3px}.stores-dropdown__contact-details{font-size:16px;font-weight:700}.stores-dropdown__view-more{cursor:pointer;font-size:14px;font-weight:400;margin-top:10px;text-transform:capitalize}.search-results{background:#fff;border:1px solid #dfdede;border-radius:2px;box-shadow:0 2px 8px rgba(0,0,0,.08);display:flex;position:absolute;width:770px;z-index:50}@media only screen and (max-width:1052px){.search-results{border:none;box-shadow:none;flex-direction:column;top:120px;width:100%}}.search-results__section:first-child{border-right:1px solid #dfdede;flex:1;min-width:240px}.search-results__section:last-child{display:flex;flex:2;flex-direction:column}.search-results__section-header{align-items:center;display:flex;justify-content:space-between}.search-results__header{color:#000;font-family:Martel Sans;font-size:14px;font-weight:600;margin-bottom:0;padding:16px 20px;text-transform:uppercase}.search-results__view-all-link{display:none}@media only screen and (max-width:879px){.search-results__view-all-link{color:#000;display:block;font-family:Martel Sans;font-size:14px;margin-right:20px}}.search-results__list{display:flex;flex-direction:column}.search-results__item{color:grey;font-family:Martel Sans;font-size:14px;padding:8px 20px;text-decoration:none}.search-results__product-list{display:flex;flex-direction:column;overflow-y:auto}.product-card{color:inherit;display:flex;padding:12px 20px;text-decoration:none;transition:background-color .15s ease}.product-card:hover{background-color:#f4f4f4}.product-card__image-container{border-radius:2px;flex-shrink:0;height:90px;margin-right:16px;overflow:hidden;width:90px}.product-card__image{height:100%;-o-object-fit:cover;object-fit:cover;width:100%}.product-card__details{display:flex;flex:1;flex-direction:column}.product-card__name{color:#000;font-family:Martel Sans;font-size:14px;line-height:1.4;margin-bottom:24px}.product-card__brand-name{font-weight:600}.product-card__info-row{align-items:flex-end;display:flex;justify-content:space-between}@media only screen and (max-width:879px){.product-card__info-row{align-items:flex-start;flex-direction:column}}.product-card__price-group{display:flex;flex-direction:column;gap:4px}.product-card__price{color:#000;font-family:Martel Sans;font-size:14px;font-weight:600;line-height:1}.product-card__retail-price{color:#939393;font-family:Martel Sans;font-size:14px;text-decoration:line-through}.product-card__condition{color:#000;font-family:Martel Sans;font-size:13px;margin-right:20px;text-align:right}.product-card__condition-label{color:#939393;margin-right:4px}.search-results__view-all-button{background-color:#f5f0ea!important;border:none;color:#000;cursor:pointer;font-family:Martel Sans;font-size:13px;font-weight:400;padding:16px;text-align:center}@media only screen and (max-width:879px){.search-results__view-all-button{display:none}}.dropdown{display:flex;justify-content:space-between;margin-left:auto;margin-right:auto;max-width:1280px;min-height:500px;overflow-x:auto;padding:20px 0}.dropdown__errors{align-items:center;color:red;display:flex;font-size:16px;justify-content:center;min-height:300px}.dropdown__column{flex:1;padding-left:12px}.dropdown__column:nth-child(2){flex:2}.dropdown__title{font-family:El Messiri;font-size:16px;font-weight:700;letter-spacing:3px;line-height:1;margin-bottom:20px;text-transform:uppercase}.dropdown__elements{display:grid;grid-template-columns:repeat(auto-fill,minmax(200px,1fr));max-height:800px;overflow-y:auto}.dropdown__brand-elements{-moz-column-count:3;column-count:3;max-height:800px}.dropdown__brand-element{cursor:pointer;margin-bottom:10px}.dropdown__element{flex-basis:33.33%;font-family:Martel Sans;font-size:14px;font-weight:400;margin-bottom:10px;text-transform:capitalize}.cover-spinner{align-items:center;background-color:hsla(0,0%,100%,.7);display:flex;height:100%;justify-content:center;min-height:400px;position:relative;top:50%;width:100%;z-index:9999}.cover-spinner:after{animation:spin 1.5s linear infinite;border:4px dotted #000;border-radius:50%;border-top-color:transparent;content:"";display:block;height:40px;position:absolute;width:40px}@keyframes spin{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}
package/build/bundle.js CHANGED
@@ -15999,7 +15999,7 @@
15999
15999
  return null;
16000
16000
  }
16001
16001
 
16002
- if (!isSearchFocused && !hasResults) {
16002
+ if (!isSearchFocused) {
16003
16003
  return null;
16004
16004
  }
16005
16005
 
@@ -16022,7 +16022,7 @@
16022
16022
  key: product.link,
16023
16023
  href: product.link,
16024
16024
  className: "product-card"
16025
- }, (product.image_url || product.featured_image) && /*#__PURE__*/React__default.createElement("div", {
16025
+ }, product.featured_image && /*#__PURE__*/React__default.createElement("div", {
16026
16026
  className: "product-card__image-container"
16027
16027
  }, /*#__PURE__*/React__default.createElement("img", {
16028
16028
  src: product.featured_image,
@@ -16126,6 +16126,7 @@
16126
16126
  var endpoint = _ref.endpoint,
16127
16127
  onProductIdsReceived = _ref.onProductIdsReceived,
16128
16128
  currency = _ref.currency;
16129
+ var currentSearchRequestToken = React.useRef(null);
16129
16130
  var debounce = React.useCallback(function (func, wait) {
16130
16131
  var timeout;
16131
16132
  return function executedFunction() {
@@ -16156,49 +16157,75 @@
16156
16157
  });
16157
16158
  });
16158
16159
  }, []);
16159
- var performSearch = React.useCallback(function (nextValue, setSearchResults) {
16160
- if (!nextValue || nextValue.trim() === '') {
16160
+ var performSearch = React.useCallback(function (searchQuery, setSearchResults) {
16161
+ if (!searchQuery || searchQuery.trim() === '') {
16161
16162
  setSearchResults({
16162
16163
  brands: [],
16163
16164
  products: [],
16164
16165
  luxity_product_ids: []
16165
16166
  });
16166
16167
  return;
16167
- }
16168
+ } // Cancel any ongoing search request to prevent race conditions
16169
+
16170
+
16171
+ if (currentSearchRequestToken.current) {
16172
+ currentSearchRequestToken.current.cancel();
16173
+ } // Create a new token for this specific search request
16168
16174
 
16169
- axios.post(endpoint, searchProducts(nextValue, 3, currency)).then(function (response) {
16170
- var searchResults = response.data.data.luxity_products_serach_results;
16171
- setSearchResults(searchResults);
16172
16175
 
16173
- if (searchResults && searchResults.luxity_product_ids) {
16174
- onProductIdsReceived(searchResults.luxity_product_ids);
16176
+ var newSearchToken = axios.CancelToken.source();
16177
+ currentSearchRequestToken.current = newSearchToken;
16178
+ axios.post(endpoint, searchProducts(searchQuery, 3, currency), {
16179
+ cancelToken: newSearchToken.token
16180
+ }).then(function (response) {
16181
+ if (currentSearchRequestToken.current === newSearchToken) {
16182
+ var searchResults = response.data.data.luxity_products_serach_results;
16183
+ setSearchResults(searchResults);
16184
+
16185
+ if (searchResults && searchResults.luxity_product_ids) {
16186
+ onProductIdsReceived(searchResults.luxity_product_ids);
16187
+ }
16188
+
16189
+ currentSearchRequestToken.current = null;
16190
+ }
16191
+ }).catch(function (error) {
16192
+ if (!axios.isCancel(error)) {
16193
+ setSearchResults({
16194
+ brands: [],
16195
+ products: [],
16196
+ luxity_product_ids: []
16197
+ });
16198
+ currentSearchRequestToken.current = null;
16175
16199
  }
16176
- }).catch(function () {
16177
- setSearchResults({
16178
- brands: [],
16179
- products: [],
16180
- luxity_product_ids: []
16181
- });
16182
16200
  });
16183
16201
  }, [endpoint, currency, onProductIdsReceived]);
16184
16202
  var debouncedSearch = React.useMemo(function () {
16185
- return debounce(function (nextValue, setSearchResults) {
16186
- return performSearch(nextValue, setSearchResults);
16203
+ return debounce(function (searchQuery, setSearchResults) {
16204
+ return performSearch(searchQuery, setSearchResults);
16187
16205
  }, 500);
16188
16206
  }, [debounce, performSearch]);
16189
16207
  var createDebouncedSearch = React.useCallback(function (setSearchResults) {
16190
- return function (nextValue) {
16191
- return debouncedSearch(nextValue, setSearchResults);
16208
+ return function (searchQuery) {
16209
+ return debouncedSearch(searchQuery, setSearchResults);
16192
16210
  };
16193
16211
  }, [debouncedSearch]);
16194
16212
  var createImmediateSearch = React.useCallback(function (setSearchValue, setSearchResults, onSearchSubmit) {
16195
- return function (value) {
16213
+ return function (searchQuery) {
16214
+ /*
16215
+ * Cancel any pending search request when immediate search is performed
16216
+ * Immediate search is when the user types a search query and presses enter
16217
+ */
16218
+ if (currentSearchRequestToken.current) {
16219
+ currentSearchRequestToken.current.cancel();
16220
+ currentSearchRequestToken.current = null;
16221
+ }
16222
+
16196
16223
  setSearchValue('');
16197
16224
  setSearchResults({
16198
16225
  brands: [],
16199
16226
  products: []
16200
16227
  });
16201
- onSearchSubmit(value);
16228
+ onSearchSubmit(searchQuery);
16202
16229
  };
16203
16230
  }, []);
16204
16231
  return {
@@ -16208,6 +16235,72 @@
16208
16235
  };
16209
16236
  };
16210
16237
 
16238
+ var useSearchClickOutside = function useSearchClickOutside(ref, searchResults, setCachedResults, setIsSearchFocused, setSearchResults) {
16239
+ React.useEffect(function () {
16240
+ var handleClickOutside = function handleClickOutside(event) {
16241
+ if (ref.current && !ref.current.contains(event.target)) {
16242
+ setCachedResults(searchResults);
16243
+ setIsSearchFocused(false);
16244
+ setSearchResults({
16245
+ brands: [],
16246
+ products: []
16247
+ });
16248
+ }
16249
+ };
16250
+
16251
+ document.addEventListener('mousedown', handleClickOutside);
16252
+ return function () {
16253
+ document.removeEventListener('mousedown', handleClickOutside);
16254
+ };
16255
+ }, [ref, searchResults, setCachedResults, setIsSearchFocused, setSearchResults]);
16256
+ };
16257
+ var useSearchInputChange = function useSearchInputChange(setSearchValue, setIsSearchFocused, debouncedSearch, setSearchResults, setCachedResults) {
16258
+ return React.useCallback(function (event) {
16259
+ var value = event.target.value;
16260
+ setSearchValue(value);
16261
+ setIsSearchFocused(true);
16262
+
16263
+ if (value.trim().length >= 3) {
16264
+ debouncedSearch(value);
16265
+ } else {
16266
+ setSearchResults({
16267
+ brands: [],
16268
+ products: []
16269
+ });
16270
+ setCachedResults({
16271
+ brands: [],
16272
+ products: []
16273
+ });
16274
+ }
16275
+ }, [setSearchValue, setIsSearchFocused, debouncedSearch, setSearchResults, setCachedResults]);
16276
+ };
16277
+ var useSearchInputFocus = function useSearchInputFocus(searchValue, setIsSearchFocused, cachedResults, setSearchResults) {
16278
+ return React.useCallback(function () {
16279
+ setIsSearchFocused(true);
16280
+
16281
+ if (searchValue.trim().length >= 3) {
16282
+ setSearchResults(cachedResults);
16283
+ }
16284
+ }, [searchValue, setIsSearchFocused, cachedResults, setSearchResults]);
16285
+ };
16286
+ var useSearchInputKeyDown = function useSearchInputKeyDown(searchValue, immediateSearch, setIsSearchFocused) {
16287
+ var setSearchValue = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
16288
+ return React.useCallback(function (event) {
16289
+ if (event.key === 'Enter') {
16290
+ event.preventDefault();
16291
+
16292
+ if (searchValue.trim().length >= 3) {
16293
+ immediateSearch(searchValue);
16294
+ }
16295
+
16296
+ setIsSearchFocused(false);
16297
+ } else if (event.key === 'Escape' && setSearchValue) {
16298
+ setSearchValue('');
16299
+ setIsSearchFocused(false);
16300
+ }
16301
+ }, [searchValue, immediateSearch, setIsSearchFocused, setSearchValue]);
16302
+ };
16303
+
16211
16304
  var LuxityDesktopHeader = function LuxityDesktopHeader(_ref) {
16212
16305
  var accountIcon = _ref.accountIcon,
16213
16306
  cartIcon = _ref.cartIcon,
@@ -16229,7 +16322,6 @@
16229
16322
  onCartClick = _ref.onCartClick,
16230
16323
  onAccountClick = _ref.onAccountClick,
16231
16324
  inputSearchIcon = _ref.inputSearchIcon,
16232
- onSearch = _ref.onSearch,
16233
16325
  onSellToUsClick = _ref.onSellToUsClick,
16234
16326
  contactUsLink = _ref.contactUsLink,
16235
16327
  ourStoryLink = _ref.ourStoryLink,
@@ -16310,56 +16402,24 @@
16310
16402
  searchResults = _useState14[0],
16311
16403
  setSearchResults = _useState14[1];
16312
16404
 
16405
+ var _useState15 = React.useState({
16406
+ brands: [],
16407
+ products: []
16408
+ }),
16409
+ _useState16 = _slicedToArray(_useState15, 2),
16410
+ cachedResults = _useState16[0],
16411
+ setCachedResults = _useState16[1];
16412
+
16313
16413
  var searchResultsRef = React.useRef(null);
16314
- var debouncedSearch = createDebouncedSearch(setSearchResults);
16414
+ var debouncedSearch = createDebouncedSearch(function (results) {
16415
+ setSearchResults(results);
16416
+ setCachedResults(results);
16417
+ });
16315
16418
  var immediateSearch = createImmediateSearch(setSearchValue, setSearchResults, onSearchSubmit);
16316
-
16317
- var handleChange = function handleChange(event) {
16318
- var value = event.target.value;
16319
- setSearchValue(value);
16320
- setIsSearchFocused(true);
16321
-
16322
- if (value.trim().length >= 3) {
16323
- debouncedSearch(value);
16324
- } else {
16325
- setSearchResults({
16326
- brands: [],
16327
- products: []
16328
- });
16329
- }
16330
- };
16331
-
16332
- React.useEffect(function () {
16333
- var handleClickOutside = function handleClickOutside(event) {
16334
- if (searchResultsRef.current && !searchResultsRef.current.contains(event.target)) {
16335
- setSearchValue('');
16336
- setIsSearchFocused(false);
16337
- setSearchResults({
16338
- brands: [],
16339
- products: []
16340
- });
16341
- }
16342
- };
16343
-
16344
- document.addEventListener('mousedown', handleClickOutside);
16345
- return function () {
16346
- document.removeEventListener('mousedown', handleClickOutside);
16347
- };
16348
- }, []);
16349
-
16350
- var handleKeyDown = function handleKeyDown(event) {
16351
- if (event.key === 'Enter') {
16352
- event.preventDefault();
16353
-
16354
- if (searchValue.trim().length >= 3) {
16355
- immediateSearch(searchValue);
16356
- }
16357
- } else if (event.key === 'Escape') {
16358
- setSearchValue('');
16359
- }
16360
-
16361
- setIsSearchFocused(false);
16362
- };
16419
+ var handleChange = useSearchInputChange(setSearchValue, setIsSearchFocused, debouncedSearch, setSearchResults, setCachedResults);
16420
+ useSearchClickOutside(searchResultsRef, searchResults, setCachedResults, setIsSearchFocused, setSearchResults);
16421
+ var handleSearchFocus = useSearchInputFocus(searchValue, setIsSearchFocused, cachedResults, setSearchResults);
16422
+ var handleKeyDown = useSearchInputKeyDown(searchValue, immediateSearch, setIsSearchFocused);
16363
16423
 
16364
16424
  function addCategoryToElements(elements, categoryName) {
16365
16425
  return elements.map(function (element) {
@@ -16431,13 +16491,8 @@
16431
16491
  value: searchValue,
16432
16492
  onChange: handleChange,
16433
16493
  onKeyDown: handleKeyDown,
16434
- onClick: function onClick() {
16435
- onSearch();
16436
- setIsSearchFocused(true);
16437
- },
16438
- onFocus: function onFocus() {
16439
- return setIsSearchFocused(true);
16440
- }
16494
+ onClick: handleSearchFocus,
16495
+ onFocus: handleSearchFocus
16441
16496
  })), /*#__PURE__*/React__default.createElement(SearchResults, {
16442
16497
  searchValue: searchValue,
16443
16498
  searchResults: searchResults,
@@ -17361,73 +17416,41 @@
17361
17416
  searchResults = _useState8[0],
17362
17417
  setSearchResults = _useState8[1];
17363
17418
 
17364
- var _useState9 = React.useState(false),
17419
+ var _useState9 = React.useState({
17420
+ brands: [],
17421
+ products: []
17422
+ }),
17365
17423
  _useState10 = _slicedToArray(_useState9, 2),
17366
- isSearchFocused = _useState10[0],
17367
- setIsSearchFocused = _useState10[1];
17424
+ cachedResults = _useState10[0],
17425
+ setCachedResults = _useState10[1];
17426
+
17427
+ var _useState11 = React.useState(false),
17428
+ _useState12 = _slicedToArray(_useState11, 2),
17429
+ isSearchFocused = _useState12[0],
17430
+ setIsSearchFocused = _useState12[1];
17368
17431
 
17369
- var _useState11 = React.useState({
17432
+ var _useState13 = React.useState({
17370
17433
  trending_brands: [],
17371
17434
  latest_products: []
17372
17435
  }),
17373
- _useState12 = _slicedToArray(_useState11, 2),
17374
- initialSearchView = _useState12[0],
17375
- setInitialSearchView = _useState12[1];
17436
+ _useState14 = _slicedToArray(_useState13, 2),
17437
+ initialSearchView = _useState14[0],
17438
+ setInitialSearchView = _useState14[1];
17376
17439
 
17377
17440
  var searchResultsRef = React.useRef(null);
17378
17441
  var searchInputRef = React.useRef(null);
17379
- var debouncedSearch = createDebouncedSearch(setSearchResults);
17442
+ var debouncedSearch = createDebouncedSearch(function (results) {
17443
+ setSearchResults(results);
17444
+ setCachedResults(results);
17445
+ });
17380
17446
  var immediateSearch = createImmediateSearch(setSearchValue, setSearchResults, onSearchSubmit);
17381
-
17382
- var handleChange = function handleChange(event) {
17383
- var value = event.target.value;
17384
- setSearchValue(value);
17385
- setIsSearchFocused(true);
17386
-
17387
- if (value.trim().length >= 3) {
17388
- debouncedSearch(value);
17389
- } else {
17390
- setSearchResults({
17391
- brands: [],
17392
- products: []
17393
- });
17394
- }
17395
- };
17396
-
17397
- var handleKeyDown = function handleKeyDown(event) {
17398
- if (event.key === 'Enter') {
17399
- event.preventDefault();
17400
-
17401
- if (searchValue.trim().length >= 3) {
17402
- immediateSearch(searchValue);
17403
- setIsSearchFocused(false);
17404
- }
17405
- } else if (event.key === 'Escape') {
17406
- setSearchValue('');
17407
- setIsSearchFocused(false);
17408
- }
17409
- };
17410
-
17447
+ var handleChange = useSearchInputChange(setSearchValue, setIsSearchFocused, debouncedSearch, setSearchResults, setCachedResults);
17448
+ var handleKeyDown = useSearchInputKeyDown(searchValue, immediateSearch, setIsSearchFocused, setSearchValue);
17411
17449
  React.useMemo(function () {
17412
17450
  fetchInitialSearchData(initialSearchData, setInitialSearchView);
17413
17451
  }, [initialSearchData, fetchInitialSearchData]);
17414
- React.useEffect(function () {
17415
- var handleClickOutside = function handleClickOutside(event) {
17416
- if (searchResultsRef.current && !searchResultsRef.current.contains(event.target)) {
17417
- setSearchValue('');
17418
- setIsSearchFocused(false);
17419
- setSearchResults({
17420
- brands: [],
17421
- products: []
17422
- });
17423
- }
17424
- };
17425
-
17426
- document.addEventListener('mousedown', handleClickOutside);
17427
- return function () {
17428
- document.removeEventListener('mousedown', handleClickOutside);
17429
- };
17430
- }, []);
17452
+ useSearchClickOutside(searchResultsRef, searchResults, setCachedResults, setIsSearchFocused, setSearchResults);
17453
+ var handleSearchFocus = useSearchInputFocus(searchValue, setIsSearchFocused, cachedResults, setSearchResults);
17431
17454
  React.useEffect(function () {
17432
17455
  if (showSearchBar && searchInputRef.current) {
17433
17456
  searchInputRef.current.focus();
@@ -17591,9 +17614,7 @@
17591
17614
  value: searchValue,
17592
17615
  onChange: handleChange,
17593
17616
  onKeyDown: handleKeyDown,
17594
- onFocus: function onFocus() {
17595
- return setIsSearchFocused(true);
17596
- }
17617
+ onFocus: handleSearchFocus
17597
17618
  })), /*#__PURE__*/React__default.createElement("button", {
17598
17619
  type: "button",
17599
17620
  onClick: onSearchClick
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bonlineza/luxity-lib",
3
- "version": "2.35.7",
3
+ "version": "2.35.9",
4
4
  "scripts": {
5
5
  "start": "start-storybook -p 9001 -c .storybook -s ./public",
6
6
  "clean": "rimraf ./build/*.*",