@sonic-equipment/ui 0.0.47 → 0.0.49

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/config.d.ts CHANGED
@@ -3,7 +3,9 @@ interface Config {
3
3
  ALGOLIA_API_KEY: string;
4
4
  ALGOLIA_APP_ID: string;
5
5
  ALGOLIA_HOST: string;
6
+ ALGOLIA_PROXY_HOST: string;
6
7
  BFF_API_URL: string;
8
+ PROXY_API_URL: string;
7
9
  SHOP_API_URL: string;
8
10
  }
9
11
  export declare const configPerEnvironment: Record<Environment, Config>;
@@ -2,7 +2,7 @@ import React, { ReactNode } from 'react';
2
2
  import { SearchClient } from 'algoliasearch';
3
3
  import { Autocomplete, GlobalSearchContextValue } from 'global-search/types';
4
4
  export declare const GlobalSearchContext: React.Context<GlobalSearchContextValue | null>;
5
- export declare function AlgoliaSearchProvider({ children, searchClient, }: {
5
+ export declare function AlgoliaSearchProvider({ children, searchClient: _searchClient, }: {
6
6
  children?: ReactNode | ((autocomplete: Autocomplete) => ReactNode);
7
- searchClient: SearchClient;
7
+ searchClient?: SearchClient;
8
8
  }): import("react/jsx-runtime").JSX.Element;
@@ -2,7 +2,7 @@ import { ReactNode } from 'react';
2
2
  import { SearchClient } from 'algoliasearch';
3
3
  interface GlobalSearchProps {
4
4
  children: ReactNode;
5
- searchClient: SearchClient;
5
+ searchClient?: SearchClient;
6
6
  }
7
7
  /**
8
8
  * Global search using algolia autocomplete with a custom renderer
package/dist/index.d.ts CHANGED
@@ -16,7 +16,9 @@ interface Config {
16
16
  ALGOLIA_API_KEY: string;
17
17
  ALGOLIA_APP_ID: string;
18
18
  ALGOLIA_HOST: string;
19
+ ALGOLIA_PROXY_HOST: string;
19
20
  BFF_API_URL: string;
21
+ PROXY_API_URL: string;
20
22
  SHOP_API_URL: string;
21
23
  }
22
24
  declare const configPerEnvironment: Record<Environment, Config>;
@@ -4065,7 +4067,7 @@ declare function AlgoliaSortBy(): react_jsx_runtime.JSX.Element | null;
4065
4067
 
4066
4068
  interface GlobalSearchProps {
4067
4069
  children: ReactNode;
4068
- searchClient: SearchClient;
4070
+ searchClient?: SearchClient;
4069
4071
  }
4070
4072
  /**
4071
4073
  * Global search using algolia autocomplete with a custom renderer
package/dist/index.js CHANGED
@@ -53,7 +53,9 @@ const configPerEnvironment = {
53
53
  ALGOLIA_API_KEY: 'e31a3a53449eceb4d0f9273b9bcd9759',
54
54
  ALGOLIA_APP_ID: '14CUFCVMAD',
55
55
  ALGOLIA_HOST: 'bff.shop.sonic-equipment.com',
56
+ ALGOLIA_PROXY_HOST: 'sonicequipment.commerce.insitesandbox.com',
56
57
  BFF_API_URL: 'https://bff.shop.sonic-equipment.com',
58
+ PROXY_API_URL: 'https://shop.sonic-equipment.com/bff',
57
59
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
58
60
  SHOP_API_URL: '',
59
61
  },
@@ -61,7 +63,9 @@ const configPerEnvironment = {
61
63
  ALGOLIA_API_KEY: 'e0edf30798a6b2e4e44fd25f0f2f9646',
62
64
  ALGOLIA_APP_ID: 'testing9VXJ0U4GSV',
63
65
  ALGOLIA_HOST: 'test-bff.shop.sonic-equipment.com',
66
+ ALGOLIA_PROXY_HOST: 'sonicequipment.commerce.insitesandbox.com',
64
67
  BFF_API_URL: 'https://test-bff.shop.sonic-equipment.com',
68
+ PROXY_API_URL: 'https://sonicequipment.commerce.insitesandbox.com/bff',
65
69
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
66
70
  SHOP_API_URL: '',
67
71
  },
@@ -124,7 +128,7 @@ function useFetchProductListingPageData({ languageCode, pageUrl, }) {
124
128
  return useQuery({
125
129
  gcTime: 1000 * 60 * 60 * 24,
126
130
  queryFn: async () => {
127
- const res = await fetch(`${config.BFF_API_URL}/api/v1/plp/?pageUrl=${pageUrl}`, {
131
+ const res = await fetch(`${config.PROXY_API_URL}/api/v1/plp/?pageUrl=${pageUrl}`, {
128
132
  headers: { 'Current-Language-Id': languageCode },
129
133
  });
130
134
  if (!res.ok)
@@ -1348,7 +1352,22 @@ function elementChildren(element, selector) {
1348
1352
  if (selector === void 0) {
1349
1353
  selector = '';
1350
1354
  }
1351
- return [...element.children].filter(el => el.matches(selector));
1355
+ const children = [...element.children];
1356
+ if (element instanceof HTMLSlotElement) {
1357
+ children.push(...element.assignedElements());
1358
+ }
1359
+ if (!selector) {
1360
+ return children;
1361
+ }
1362
+ return children.filter(el => el.matches(selector));
1363
+ }
1364
+ function elementIsChildOf(el, parent) {
1365
+ const isChild = parent.contains(el);
1366
+ if (!isChild && parent instanceof HTMLSlotElement) {
1367
+ const children = [...element.assignedElements()];
1368
+ return children.includes(el);
1369
+ }
1370
+ return isChild;
1352
1371
  }
1353
1372
  function showWarning(text) {
1354
1373
  try {
@@ -3857,7 +3876,7 @@ function onTouchStart(event) {
3857
3876
  }
3858
3877
  let targetEl = e.target;
3859
3878
  if (params.touchEventsTarget === 'wrapper') {
3860
- if (!swiper.wrapperEl.contains(targetEl)) return;
3879
+ if (!elementIsChildOf(targetEl, swiper.wrapperEl)) return;
3861
3880
  }
3862
3881
  if ('which' in e && e.which === 3) return;
3863
3882
  if ('button' in e && e.button > 0) return;
@@ -5926,7 +5945,7 @@ const updateOnVirtualData = swiper => {
5926
5945
  };
5927
5946
 
5928
5947
  /**
5929
- * Swiper React 11.1.5
5948
+ * Swiper React 11.1.7
5930
5949
  * Most modern mobile touch slider and framework with hardware accelerated transitions
5931
5950
  * https://swiperjs.com
5932
5951
  *
@@ -5934,7 +5953,7 @@ const updateOnVirtualData = swiper => {
5934
5953
  *
5935
5954
  * Released under the MIT License
5936
5955
  *
5937
- * Released on: July 15, 2024
5956
+ * Released on: July 24, 2024
5938
5957
  */
5939
5958
 
5940
5959
 
@@ -6876,7 +6895,7 @@ const createSonicSearchClient = ({ apiKey, appId, host, path, }) => {
6876
6895
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
6877
6896
  // @ts-ignore
6878
6897
  searchClient.search = async (requests) => {
6879
- const res = await fetch(`${config.BFF_API_URL}${path}`, {
6898
+ const res = await fetch(`${config.PROXY_API_URL}${path}`, {
6880
6899
  body: JSON.stringify({ requests }),
6881
6900
  headers: { 'Content-Type': 'application/json' },
6882
6901
  method: 'post',
@@ -7171,7 +7190,7 @@ function ProductListingPage({ pageUrl, searchClient: _searchClient, }) {
7171
7190
  createSonicSearchClient({
7172
7191
  apiKey: config.ALGOLIA_API_KEY,
7173
7192
  appId: config.ALGOLIA_APP_ID,
7174
- host: config.ALGOLIA_HOST,
7193
+ host: config.ALGOLIA_PROXY_HOST,
7175
7194
  path: '/search',
7176
7195
  }), [_searchClient]);
7177
7196
  if (isError) {
@@ -7479,7 +7498,7 @@ const recentSearchesPlugin = createLocalStorageRecentSearchesPlugin({
7479
7498
  });
7480
7499
 
7481
7500
  const GlobalSearchContext = createContext(null);
7482
- function AlgoliaSearchProvider({ children, searchClient, }) {
7501
+ function AlgoliaSearchProvider({ children, searchClient: _searchClient, }) {
7483
7502
  const [state, setState] = useState({
7484
7503
  activeItemId: null,
7485
7504
  collections: [],
@@ -7489,6 +7508,13 @@ function AlgoliaSearchProvider({ children, searchClient, }) {
7489
7508
  query: '',
7490
7509
  status: 'idle',
7491
7510
  });
7511
+ const searchClient = useMemo(() => _searchClient ||
7512
+ createSonicSearchClient({
7513
+ apiKey: config.ALGOLIA_API_KEY,
7514
+ appId: config.ALGOLIA_APP_ID,
7515
+ host: config.ALGOLIA_PROXY_HOST,
7516
+ path: '/autocomplete',
7517
+ }), [_searchClient]);
7492
7518
  const languageCode = useLanguageCode();
7493
7519
  const index = getAlgoliaIndex(environment, languageCode);
7494
7520
  const productsIndexName = index.default;
package/dist/styles.css CHANGED
@@ -991,7 +991,7 @@
991
991
  }
992
992
 
993
993
  /**
994
- * Swiper 11.1.5
994
+ * Swiper 11.1.7
995
995
  * Most modern mobile touch slider and framework with hardware accelerated transitions
996
996
  * https://swiperjs.com
997
997
  *
@@ -999,7 +999,7 @@
999
999
  *
1000
1000
  * Released under the MIT License
1001
1001
  *
1002
- * Released on: July 15, 2024
1002
+ * Released on: July 24, 2024
1003
1003
  */
1004
1004
 
1005
1005
  /* FONT_START */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sonic-equipment/ui",
3
- "version": "0.0.47",
3
+ "version": "0.0.49",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "engines": {