@bonlineza/luxity-lib 2.37.0 → 2.37.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/bundle.js CHANGED
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('react-animate-height'), require('styled-components'), require('numeral'), require('@bonlineza/b-lib/EllipsisLoader'), require('@bonlineza/b-lib/PageReady'), require('stylis-rule-sheet'), require('react-dom'), require('prop-types'), require('raf'), require('react-input-autosize'), require('react-transition-group'), require('@bonlineza/b-lib/functions'), require('rc-slider'), require('react-notify-toast'), require('axios'), require('js-cookie')) :
3
- typeof define === 'function' && define.amd ? define(['exports', 'react', 'react-animate-height', 'styled-components', 'numeral', '@bonlineza/b-lib/EllipsisLoader', '@bonlineza/b-lib/PageReady', 'stylis-rule-sheet', 'react-dom', 'prop-types', 'raf', 'react-input-autosize', 'react-transition-group', '@bonlineza/b-lib/functions', 'rc-slider', 'react-notify-toast', 'axios', 'js-cookie'], factory) :
4
- (global = global || self, factory(global.blib = {}, global.React, global.AnimateHeight, global.styled, global.numeral, global.EllipsisLoader, global.PageReady, global['stylis-rule-sheet'], global.reactDom, global.PropTypes, global.raf, global['react-input-autosize'], global['react-transition-group'], global.function, global.rcSlider, global['react-notify-toast'], global.axios, global.Cookies));
5
- }(this, (function (exports, React, AnimateHeight, styled, numeral, EllipsisLoader, PageReady, stylisRuleSheet, reactDom, PropTypes, raf, AutosizeInput, reactTransitionGroup, functions, rcSlider, Notifications, axios, Cookies) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('react-animate-height'), require('styled-components'), require('numeral'), require('@bonlineza/b-lib/EllipsisLoader'), require('@bonlineza/b-lib/PageReady'), require('stylis-rule-sheet'), require('react-dom'), require('prop-types'), require('raf'), require('react-input-autosize'), require('react-transition-group'), require('@bonlineza/b-lib/functions'), require('rc-slider'), require('react-notify-toast'), require('axios')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', 'react', 'react-animate-height', 'styled-components', 'numeral', '@bonlineza/b-lib/EllipsisLoader', '@bonlineza/b-lib/PageReady', 'stylis-rule-sheet', 'react-dom', 'prop-types', 'raf', 'react-input-autosize', 'react-transition-group', '@bonlineza/b-lib/functions', 'rc-slider', 'react-notify-toast', 'axios'], factory) :
4
+ (global = global || self, factory(global.blib = {}, global.React, global.AnimateHeight, global.styled, global.numeral, global.EllipsisLoader, global.PageReady, global['stylis-rule-sheet'], global.reactDom, global.PropTypes, global.raf, global['react-input-autosize'], global['react-transition-group'], global.function, global.rcSlider, global['react-notify-toast'], global.axios));
5
+ }(this, (function (exports, React, AnimateHeight, styled, numeral, EllipsisLoader, PageReady, stylisRuleSheet, reactDom, PropTypes, raf, AutosizeInput, reactTransitionGroup, functions, rcSlider, Notifications, axios) { 'use strict';
6
6
 
7
7
  var React__default = 'default' in React ? React['default'] : React;
8
8
  AnimateHeight = AnimateHeight && Object.prototype.hasOwnProperty.call(AnimateHeight, 'default') ? AnimateHeight['default'] : AnimateHeight;
@@ -16,7 +16,6 @@
16
16
  AutosizeInput = AutosizeInput && Object.prototype.hasOwnProperty.call(AutosizeInput, 'default') ? AutosizeInput['default'] : AutosizeInput;
17
17
  var Notifications__default = 'default' in Notifications ? Notifications['default'] : Notifications;
18
18
  axios = axios && Object.prototype.hasOwnProperty.call(axios, 'default') ? axios['default'] : axios;
19
- Cookies = Cookies && Object.prototype.hasOwnProperty.call(Cookies, 'default') ? Cookies['default'] : Cookies;
20
19
 
21
20
  function ownKeys(object, enumerableOnly) {
22
21
  var keys = Object.keys(object);
@@ -11444,127 +11443,6 @@
11444
11443
  }));
11445
11444
  });
11446
11445
 
11447
- function getToken() {
11448
- var _Cookies$get;
11449
-
11450
- return (_Cookies$get = Cookies.get('_tk')) === null || _Cookies$get === void 0 ? void 0 : _Cookies$get.replace('*', 'Bearer ');
11451
- }
11452
- function setToken(value) {
11453
- Cookies.set('_tk', value, 30);
11454
- }
11455
-
11456
- /** @format */
11457
-
11458
- function getEncodedSearch(currentUrl) {
11459
- var splitUrl = currentUrl.split('?');
11460
- var baseUrl = splitUrl[0];
11461
- var nextUrlSegments = splitUrl[1].split('&');
11462
- var nextQueryString = splitUrl[1];
11463
-
11464
- if (nextUrlSegments.length > 0) {
11465
- nextQueryString = nextUrlSegments.map(function (v) {
11466
- var nextValue = v;
11467
-
11468
- if (v.includes('search=')) {
11469
- var temp = v.split('=');
11470
- nextValue = "".concat(temp[0], "=").concat(encodeURIComponent(temp[1]));
11471
- }
11472
-
11473
- return nextValue;
11474
- }).join('&');
11475
- }
11476
-
11477
- return "".concat(baseUrl, "?").concat(nextQueryString);
11478
- }
11479
- /**
11480
- * Gets an instance of Axios that is configured with the custom failure handlers
11481
- * @param {Function} onAuthFailed - callback triggers when auth fails - ie, server error is one of ['token_invalid', 'token_not_provided', 'user_not_found', 'token_expired'] or http status is one of [401, 503, 400]
11482
- * @param {Function} onForbidden - callback triggers when http status = 403
11483
- */
11484
-
11485
-
11486
- var axiosInstance = function axiosInstance(onAuthFailed, onForbidden) {
11487
- var instance = axios.create({
11488
- validateStatus: function validateStatus(status) {
11489
- return status >= 200 && status < 300;
11490
- }
11491
- });
11492
- var token = getToken();
11493
-
11494
- if (token !== '') {
11495
- instance.defaults.headers.common.Authorization = token;
11496
- }
11497
-
11498
- instance.defaults.headers.common['Content-Type'] = 'application/json;charset=UTF-8'; // Add a request interceptor
11499
-
11500
- instance.interceptors.request.use(function (request, error) {
11501
- if (error) {
11502
- return Promise.reject(error.response);
11503
- }
11504
-
11505
- if (request.url.includes('search') && request.url.includes('?')) {
11506
- // do some uri manipulation for ie
11507
- // https://stackoverflow.com/questions/18220057
11508
- // eslint-disable-next-line no-param-reassign
11509
- request.url = getEncodedSearch(request.url);
11510
- } // eslint-disable-next-line no-param-reassign
11511
-
11512
-
11513
- request.headers.common['Content-Type'] = 'application/json; charset=utf-8';
11514
-
11515
- if (typeof request.body === 'undefined') {
11516
- request.body = {};
11517
- }
11518
-
11519
- token = getToken();
11520
-
11521
- if (token !== '') {
11522
- // eslint-disable-next-line no-param-reassign
11523
- request.headers.common.Authorization = token;
11524
- }
11525
-
11526
- return request;
11527
- }, function (error) {
11528
- return Promise.reject(error.message);
11529
- }); // Add a response interceptor
11530
-
11531
- instance.interceptors.response.use(function (response, error) {
11532
- if (error) {
11533
- return Promise.reject(error.response);
11534
- }
11535
-
11536
- if (response.headers.authorization) {
11537
- setToken(response.headers.authorization);
11538
- }
11539
-
11540
- return response;
11541
- }, function (error) {
11542
- if (error.response) {
11543
- // network error
11544
- if (error.response.data && error.response.data.error && (error.response.data.error === 'token_invalid' || error.response.data.error === 'token_not_provided' || error.response.data.error === 'user_not_found' || error.response.data.error === 'token_expired') || error.response.status === 401 || error.response.status === 503 || error.response.status === 400) {
11545
- onAuthFailed();
11546
- } // if (error.response.status === 500) {
11547
- // // INTERNAL SERVER ERROR
11548
- // store.dispatch({
11549
- // type: AppConstants.OVERLAY.SERVER_ERROR,
11550
- // });
11551
- // return Promise.reject(error.response);
11552
- // }
11553
-
11554
-
11555
- if (error.response.status === 403) {
11556
- // FORBIDDEN
11557
- onForbidden();
11558
- }
11559
-
11560
- return Promise.reject(error.response);
11561
- }
11562
-
11563
- return Promise.reject(error);
11564
- });
11565
- return instance;
11566
- }; // NOTE: this to be instanciated with params: onAuthFailed, onForbidden
11567
-
11568
11446
  var _excluded$8 = ["children"];
11569
11447
 
11570
11448
  var DropdownSelector = function DropdownSelector(_ref) {
@@ -11786,7 +11664,7 @@
11786
11664
  case 0:
11787
11665
  _context.prev = 0;
11788
11666
  _context.next = 3;
11789
- return axiosInstance.post("".concat(baseGraphApi, "?id=getBrands"), {
11667
+ return requestInstance.post("".concat(baseGraphApi, "?id=getBrands"), {
11790
11668
  query: getBrandsGraphQuery(1000, 1, 'id|desc')
11791
11669
  });
11792
11670
 
@@ -11817,7 +11695,7 @@
11817
11695
  }
11818
11696
  }
11819
11697
  }, _callee, null, [[0, 7]]);
11820
- })), [baseGraphApi, getBrandsGraphQuery]);
11698
+ })), [baseGraphApi, getBrandsGraphQuery, requestInstance]);
11821
11699
  var fetchModels = React.useCallback( /*#__PURE__*/function () {
11822
11700
  var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(brandId) {
11823
11701
  var _response$data2, _response$data2$data, _response$data2$data$, response, formattedModels;
@@ -11828,7 +11706,7 @@
11828
11706
  case 0:
11829
11707
  _context2.prev = 0;
11830
11708
  _context2.next = 3;
11831
- return axiosInstance.post("".concat(baseGraphApi, "?id=getModels"), {
11709
+ return requestInstance.post("".concat(baseGraphApi, "?id=getModels"), {
11832
11710
  query: getModelsGraphQuery(brandId)
11833
11711
  });
11834
11712
 
@@ -11864,7 +11742,7 @@
11864
11742
  return function (_x) {
11865
11743
  return _ref3.apply(this, arguments);
11866
11744
  };
11867
- }(), [baseGraphApi, getModelsGraphQuery]);
11745
+ }(), [baseGraphApi, getModelsGraphQuery, requestInstance]);
11868
11746
  var fetchMaterials = React.useCallback( /*#__PURE__*/function () {
11869
11747
  var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(brandId) {
11870
11748
  var _response$data3, _response$data3$data, _response$data3$data$, response, formattedMaterials;
@@ -11875,7 +11753,7 @@
11875
11753
  case 0:
11876
11754
  _context3.prev = 0;
11877
11755
  _context3.next = 3;
11878
- return axiosInstance.post("".concat(baseGraphApi, "?id=getMaterials"), {
11756
+ return requestInstance.post("".concat(baseGraphApi, "?id=getMaterials"), {
11879
11757
  query: getMaterialsGraphQuery(brandId)
11880
11758
  });
11881
11759
 
@@ -11911,7 +11789,7 @@
11911
11789
  return function (_x2) {
11912
11790
  return _ref4.apply(this, arguments);
11913
11791
  };
11914
- }(), [baseGraphApi, getMaterialsGraphQuery]);
11792
+ }(), [baseGraphApi, getMaterialsGraphQuery, requestInstance]);
11915
11793
  React.useEffect(function () {
11916
11794
  fetchBrands();
11917
11795
  }, [fetchBrands]);
@@ -15943,7 +15821,9 @@
15943
15821
  isSearchFocused = _ref.isSearchFocused,
15944
15822
  setIsSearchFocused = _ref.setIsSearchFocused,
15945
15823
  currency = _ref.currency,
15946
- currencySymbol = _ref.currencySymbol;
15824
+ currencySymbol = _ref.currencySymbol,
15825
+ onProductSearchResultClick = _ref.onProductSearchResultClick,
15826
+ onBrandSearchResultClick = _ref.onBrandSearchResultClick;
15947
15827
 
15948
15828
  var _useState = React.useState(false),
15949
15829
  _useState2 = _slicedToArray(_useState, 2),
@@ -15991,7 +15871,18 @@
15991
15871
  return /*#__PURE__*/React__default.createElement("a", {
15992
15872
  key: product.link,
15993
15873
  href: product.link,
15994
- className: "product-card"
15874
+ className: "product-card",
15875
+ onClick: function onClick() {
15876
+ if (typeof onProductSearchResultClick === 'function') {
15877
+ onProductSearchResultClick({
15878
+ product_name: product.name,
15879
+ product_brand: product.brand,
15880
+ product_link: product.link,
15881
+ search_string: searchValue,
15882
+ is_popular: shouldShowInitialData
15883
+ });
15884
+ }
15885
+ }
15995
15886
  }, product.featured_image && /*#__PURE__*/React__default.createElement("div", {
15996
15887
  className: "product-card__image-container"
15997
15888
  }, /*#__PURE__*/React__default.createElement("img", {
@@ -16044,13 +15935,33 @@
16044
15935
  return /*#__PURE__*/React__default.createElement("a", {
16045
15936
  key: brand.id,
16046
15937
  href: getBrandLink(brand),
16047
- className: "search-results__item"
15938
+ className: "search-results__item",
15939
+ onClick: function onClick() {
15940
+ if (typeof onBrandSearchResultClick === 'function') {
15941
+ onBrandSearchResultClick({
15942
+ brand_name: brand.name,
15943
+ brand_link: getBrandLink(brand),
15944
+ search_string: searchValue,
15945
+ is_trending: true
15946
+ });
15947
+ }
15948
+ }
16048
15949
  }, brand.name);
16049
15950
  }) : (_limitBrands2 = limitBrands(searchResults === null || searchResults === void 0 ? void 0 : searchResults.brands)) === null || _limitBrands2 === void 0 ? void 0 : _limitBrands2.map(function (brand) {
16050
15951
  return /*#__PURE__*/React__default.createElement("a", {
16051
15952
  key: brand.link,
16052
15953
  href: brand.link,
16053
- className: "search-results__item"
15954
+ className: "search-results__item",
15955
+ onClick: function onClick() {
15956
+ if (typeof onBrandSearchResultClick === 'function') {
15957
+ onBrandSearchResultClick({
15958
+ brand_name: brand.name,
15959
+ brand_link: brand.link,
15960
+ search_string: searchValue,
15961
+ is_trending: false
15962
+ });
15963
+ }
15964
+ }
16054
15965
  }, brand.name);
16055
15966
  }))), /*#__PURE__*/React__default.createElement("div", {
16056
15967
  className: "search-results__section"
@@ -16095,7 +16006,8 @@
16095
16006
  var useSearch = function useSearch(_ref) {
16096
16007
  var endpoint = _ref.endpoint,
16097
16008
  onProductIdsReceived = _ref.onProductIdsReceived,
16098
- currency = _ref.currency;
16009
+ currency = _ref.currency,
16010
+ onSearchPreview = _ref.onSearchPreview;
16099
16011
  var currentSearchRequestToken = React.useRef(null);
16100
16012
  var debounce = React.useCallback(function (func, wait) {
16101
16013
  var timeout;
@@ -16156,6 +16068,16 @@
16156
16068
  onProductIdsReceived(searchResults.luxity_product_ids);
16157
16069
  }
16158
16070
 
16071
+ if (typeof onSearchPreview === 'function') {
16072
+ var _searchResults$brands, _searchResults$produc;
16073
+
16074
+ var hasResults = ((_searchResults$brands = searchResults.brands) === null || _searchResults$brands === void 0 ? void 0 : _searchResults$brands.length) > 0 || ((_searchResults$produc = searchResults.products) === null || _searchResults$produc === void 0 ? void 0 : _searchResults$produc.length) > 0;
16075
+ onSearchPreview({
16076
+ search_string: searchQuery,
16077
+ has_results: hasResults
16078
+ });
16079
+ }
16080
+
16159
16081
  currentSearchRequestToken.current = null;
16160
16082
  }
16161
16083
  }).catch(function (error) {
@@ -16168,7 +16090,7 @@
16168
16090
  currentSearchRequestToken.current = null;
16169
16091
  }
16170
16092
  });
16171
- }, [endpoint, currency, onProductIdsReceived]);
16093
+ }, [endpoint, currency, onSearchPreview, onProductIdsReceived]);
16172
16094
  var debouncedSearch = React.useMemo(function () {
16173
16095
  return debounce(function (searchQuery, setSearchResults) {
16174
16096
  return performSearch(searchQuery, setSearchResults);
@@ -16304,7 +16226,10 @@
16304
16226
  endpoint = _ref.endpoint,
16305
16227
  initialSearchData = _ref.initialSearchData,
16306
16228
  onSearchSubmit = _ref.onSearchSubmit,
16307
- onSearchClick = _ref.onSearchClick,
16229
+ onSearchBarClick = _ref.onSearchBarClick,
16230
+ onSearchPreview = _ref.onSearchPreview,
16231
+ onProductSearchResultClick = _ref.onProductSearchResultClick,
16232
+ onBrandSearchResultClick = _ref.onBrandSearchResultClick,
16308
16233
  onProductIdsReceived = _ref.onProductIdsReceived,
16309
16234
  currency = _ref.currency,
16310
16235
  currencySymbol = _ref.currencySymbol,
@@ -16324,7 +16249,8 @@
16324
16249
  var _useSearch = useSearch({
16325
16250
  endpoint: endpoint,
16326
16251
  onProductIdsReceived: onProductIdsReceived,
16327
- currency: currency
16252
+ currency: currency,
16253
+ onSearchPreview: onSearchPreview
16328
16254
  }),
16329
16255
  fetchInitialSearchData = _useSearch.fetchInitialSearchData,
16330
16256
  createDebouncedSearch = _useSearch.createDebouncedSearch,
@@ -16389,15 +16315,15 @@
16389
16315
  useSearchClickOutside(searchResultsRef, searchResults, setCachedResults, setIsSearchFocused, setSearchResults);
16390
16316
 
16391
16317
  var handleSearchClick = function handleSearchClick() {
16392
- if (typeof onSearchClick === 'function') {
16393
- onSearchClick();
16318
+ if (typeof onSearchBarClick === 'function') {
16319
+ onSearchBarClick();
16394
16320
  return;
16395
16321
  }
16396
16322
 
16397
16323
  handleSearchFocus();
16398
16324
  };
16399
16325
 
16400
- var handleSearchFocus = useSearchInputFocus(searchValue, setIsSearchFocused, cachedResults, setSearchResults, onSearchClick);
16326
+ var handleSearchFocus = useSearchInputFocus(searchValue, setIsSearchFocused, cachedResults, setSearchResults);
16401
16327
  var handleKeyDown = useSearchInputKeyDown(searchValue, immediateSearch, setIsSearchFocused);
16402
16328
 
16403
16329
  function addCategoryToElements(elements, categoryName) {
@@ -16520,7 +16446,9 @@
16520
16446
  isSearchFocused: isSearchFocused,
16521
16447
  setIsSearchFocused: setIsSearchFocused,
16522
16448
  currency: currency,
16523
- currencySymbol: currencySymbol
16449
+ currencySymbol: currencySymbol,
16450
+ onProductSearchResultClick: onProductSearchResultClick,
16451
+ onBrandSearchResultClick: onBrandSearchResultClick
16524
16452
  }), /*#__PURE__*/React__default.createElement("nav", {
16525
16453
  className: "navbar__nav-links navbar__nav-links--wrap"
16526
16454
  }, renderDropdownLinks(), !!stores.length && /*#__PURE__*/React__default.createElement("li", {
@@ -17213,6 +17141,10 @@
17213
17141
  endpoint = _ref.endpoint,
17214
17142
  initialSearchData = _ref.initialSearchData,
17215
17143
  onSearchSubmit = _ref.onSearchSubmit,
17144
+ onSearchBarClick = _ref.onSearchBarClick,
17145
+ onSearchPreview = _ref.onSearchPreview,
17146
+ onProductSearchResultClick = _ref.onProductSearchResultClick,
17147
+ onBrandSearchResultClick = _ref.onBrandSearchResultClick,
17216
17148
  onProductIdsReceived = _ref.onProductIdsReceived,
17217
17149
  onLogoutClick = _ref.onLogoutClick,
17218
17150
  onInterestClick = _ref.onInterestClick,
@@ -17239,7 +17171,8 @@
17239
17171
  var _useSearch = useSearch({
17240
17172
  endpoint: endpoint,
17241
17173
  onProductIdsReceived: onProductIdsReceived,
17242
- currency: currency
17174
+ currency: currency,
17175
+ onSearchPreview: onSearchPreview
17243
17176
  }),
17244
17177
  fetchInitialSearchData = _useSearch.fetchInitialSearchData,
17245
17178
  createDebouncedSearch = _useSearch.createDebouncedSearch,
@@ -17314,6 +17247,10 @@
17314
17247
  }, [showSearchBar]);
17315
17248
 
17316
17249
  var onSearchClick = function onSearchClick() {
17250
+ if (!showSearchBar && typeof onSearchBarClick === 'function') {
17251
+ onSearchBarClick();
17252
+ }
17253
+
17317
17254
  setShowSearchbar(function (prev) {
17318
17255
  return !prev;
17319
17256
  });
@@ -17517,7 +17454,9 @@
17517
17454
  isSearchFocused: isSearchFocused,
17518
17455
  setIsSearchFocused: setIsSearchFocused,
17519
17456
  currency: currency,
17520
- currencySymbol: currencySymbol
17457
+ currencySymbol: currencySymbol,
17458
+ onProductSearchResultClick: onProductSearchResultClick,
17459
+ onBrandSearchResultClick: onBrandSearchResultClick
17521
17460
  }))), shop && /*#__PURE__*/React__default.createElement(LuxitySideNav, {
17522
17461
  accordionIcon: accordionIcon,
17523
17462
  logoSrc: logoSrc,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bonlineza/luxity-lib",
3
- "version": "2.37.0",
3
+ "version": "2.37.2",
4
4
  "scripts": {
5
5
  "start": "start-storybook -p 9001 -c .storybook -s ./public",
6
6
  "clean": "rimraf ./build/*.*",
@@ -0,0 +1,6 @@
1
+ module.exports = {
2
+ plugins: {
3
+ tailwindcss: {},
4
+ autoprefixer: {},
5
+ },
6
+ };
package/build/.gitignore DELETED
@@ -1,3 +0,0 @@
1
- bundle.css
2
- bundle.js
3
- constants.js
package/build/.npmignore DELETED
File without changes