@sonic-equipment/ui 258.0.4 → 259.0.0

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.
@@ -1,7 +1,5 @@
1
1
  import { OnCountryLanguageChangeHandler } from '../country-selector/connected-country-selector';
2
- import { NavigationLinkSource } from '../shared/api/bff/services/bff-service';
3
- export declare function ConnectedFooter({ className, onCountryLanguageChange, source, }: {
2
+ export declare function ConnectedFooter({ className, onCountryLanguageChange, }: {
4
3
  className?: string;
5
4
  onCountryLanguageChange: OnCountryLanguageChangeHandler;
6
- source: NavigationLinkSource;
7
5
  }): import("react/jsx-runtime").JSX.Element;
@@ -8,9 +8,9 @@ import { isNavigationSection } from '../shared/api/bff/model/bff.model.js';
8
8
  import { useIsAuthenticated } from '../shared/api/storefront/hooks/authentication/use-is-authenticated.js';
9
9
  import { Footer } from './footer.js';
10
10
 
11
- function ConnectedFooter({ className, onCountryLanguageChange, source, }) {
11
+ function ConnectedFooter({ className, onCountryLanguageChange, }) {
12
12
  const cultureCode = useCultureCode();
13
- const { data } = useFetchNavigationLinks({ cultureCode, source });
13
+ const { data } = useFetchNavigationLinks({ cultureCode });
14
14
  const isAuthenticated = useIsAuthenticated();
15
15
  if (data && data.key !== 'navigation')
16
16
  throw new Error('Invalid navigation data');
@@ -56,38 +56,41 @@ function ProductHitCard({ autocomplete, hit, index, source, }) {
56
56
  // It is just a boolean prop defaulting to true
57
57
  const { close } = useGlobalSearchDisclosure();
58
58
  const { sendAddToCartFromSearchEvent, sendAddToWishListFromSearchEvent, sendProductClickFromSearchEvent, } = useAlgoliaInsights();
59
+ const { currencyCode, id, image, isVatIncluded, labels, name, objectId, originalPrice, position, price, queryId, storefrontId, storefrontSlug, } = hit;
60
+ const href = storefrontSlug;
59
61
  return (jsx(ConnectedProductCard, { ...autocomplete.getItemProps({
60
62
  item: hit.hit,
61
63
  source,
62
- }), addToCartEnabled: false, addToFavoritesEnabled: false, href: hit.storefrontSlug, id: hit.storefrontId, image: {
64
+ }), addToCartEnabled: false, addToFavoritesEnabled: false, href: href, id: storefrontId, image: {
63
65
  fit: 'contain',
64
- image: hit.image,
65
- title: hit.name,
66
- }, onAddToCart: ({ cartLine }) => hit.queryId &&
66
+ image,
67
+ title: name,
68
+ }, onAddToCart: ({ cartLine }) => queryId &&
67
69
  sendAddToCartFromSearchEvent({
68
70
  cartLine,
69
- queryId: hit.queryId,
71
+ queryId,
70
72
  }), onClick: () => {
71
73
  close();
72
- if (hit.queryId)
74
+ if (queryId) {
73
75
  sendProductClickFromSearchEvent({
74
- objectId: hit.objectId,
75
- position: hit.position || index + 1,
76
- queryId: hit.queryId,
76
+ objectId,
77
+ position: position || index + 1,
78
+ queryId,
77
79
  });
80
+ }
78
81
  }, onFavoriting: () => {
79
- if (hit.queryId)
82
+ if (queryId)
80
83
  sendAddToWishListFromSearchEvent({
81
- objectId: hit.objectId,
82
- position: hit.position || index + 1,
83
- queryId: hit.queryId,
84
+ objectId,
85
+ position: position || index + 1,
86
+ queryId,
84
87
  });
85
88
  }, price: {
86
- currencyCode: hit.currencyCode,
87
- isVatIncluded: hit.isVatIncluded,
88
- originalPrice: hit.originalPrice,
89
- price: hit.price,
90
- }, sku: hit.id, tags: hit.labels, title: jsx(Highlight, { attribute: "name", hit: hit.hit }) }, hit.storefrontId));
89
+ currencyCode,
90
+ isVatIncluded,
91
+ originalPrice,
92
+ price,
93
+ }, sku: id, tags: labels, title: jsx(Highlight, { attribute: "name", hit: hit.hit }) }, storefrontId));
91
94
  }
92
95
  function ProductResultsSection() {
93
96
  const { autocomplete, products: collection } = useAlgoliaSearch();
@@ -1,5 +1,3 @@
1
- import { NavigationLinkSource } from '../shared/api/bff/services/bff-service';
2
- export declare function ConnectedHeader({ className, source, }: {
1
+ export declare function ConnectedHeader({ className }: {
3
2
  className?: string;
4
- source: NavigationLinkSource;
5
3
  }): import("react/jsx-runtime").JSX.Element;
@@ -5,9 +5,9 @@ import { useFetchNavigationLinks } from '../shared/api/bff/hooks/use-fetch-navig
5
5
  import { isNavigationSection } from '../shared/api/bff/model/bff.model.js';
6
6
  import { Header } from './header.js';
7
7
 
8
- function ConnectedHeader({ className, source, }) {
8
+ function ConnectedHeader({ className }) {
9
9
  const cultureCode = useCultureCode();
10
- const { data } = useFetchNavigationLinks({ cultureCode, source });
10
+ const { data } = useFetchNavigationLinks({ cultureCode });
11
11
  if (data && data.key !== 'navigation')
12
12
  throw new Error('Invalid navigation data');
13
13
  const headerNavigationSection = data?.items
@@ -73,7 +73,7 @@ function Header({ className, headerNavigationSection, sticky, }) {
73
73
  const mainNavigationSection = headerNavigationSection?.items
74
74
  .filter(isNavigationSection)
75
75
  .find(item => item.key === 'main-navigation');
76
- return (jsxs(Fragment, { children: [jsx("header", { ref: headerRef, className: clsx(styles['header'], sticky && styles['sticky'], className), "data-test-selector": "pageHeader", children: jsx(HeaderLayout, { hamburgerButton: jsx(HamburgerButton, { "aria-controls": "mobile-navigation", "data-test-selector": "pageHeaderHamburgerButton", isActive: mobileNavigationOpen, onActiveChange: toggleMobileNavigation }), hasDrawersOpen: hasDrawersOpen, logo: jsx(SonicLogo, { "data-test-selector": "pageHeaderLogo", href: homeLink?.href || undefined, title: t('Home') }), mainNavigation: jsx(NavigationLinkList, { activeLink: activeLinkGroup, "data-test-selector": "pageHeaderMainNavigation", navigationSection: mainNavigationSection, onSubmenuToggle: toggleActiveSubmenu }), navigationActions: jsxs(Fragment, { children: [jsx(ConnectedAccountButton, { "data-test-selector": "pageHeaderAccountButton" }), jsx(ConnectedFavoritesButton, { "data-test-selector": "pageHeaderFavoritesButton", href: paths.FAVORITES }), jsx(ConnectedCartButton, { "data-test-selector": "pageHeaderCartButton", href: paths.CART })] }), search: jsx(SearchButton, { "aria-controls": "global-search", "data-test-selector": "pageHeaderSearchButton", isActive: searchOpen, onActiveChange: toggleSearch }) }) }), jsx(SearchDrawer, { groupId: searchGroupId, instanceId: searchInstanceId }), !isXl && (jsx(MobileNavigationDrawer, { groupId: mobileNavigationDrawer.groupId, instanceId: mobileNavigationDrawer.instanceId, linkItems: mainNavigationSection?.items.filter(isNavigationLinkItem) })), isXl && (jsx(DesktopNavigationDrawer, { groupId: desktopNavigationDrawer.groupId, instanceId: desktopNavigationDrawer.instanceId, linkGroup: activeLinkGroup, onClosed: () => setActiveLinkGroup(undefined) }))] }));
76
+ return (jsxs(Fragment, { children: [jsx("header", { ref: headerRef, className: clsx(styles['header'], sticky && styles['sticky'], className), "data-test-selector": "pageHeader", children: jsx(HeaderLayout, { hamburgerButton: jsx(HamburgerButton, { "aria-controls": "mobile-navigation", "data-test-selector": "pageHeaderHamburgerButton", isActive: mobileNavigationOpen, onActiveChange: toggleMobileNavigation }), hasDrawersOpen: hasDrawersOpen, logo: jsx(SonicLogo, { "data-test-selector": "pageHeaderLogo", href: homeLink?.href || undefined, title: t('Home') }), mainNavigation: jsx(NavigationLinkList, { activeLink: activeLinkGroup, "data-test-selector": "pageHeaderMainNavigation", navigationSection: mainNavigationSection, onSubmenuToggle: toggleActiveSubmenu }), navigationActions: jsxs(Fragment, { children: [jsx(ConnectedAccountButton, { "data-test-selector": "pageHeaderAccountButton" }), jsx(ConnectedFavoritesButton, { "data-test-selector": "pageHeaderFavoritesButton", href: "abc" }), jsx(ConnectedCartButton, { "data-test-selector": "pageHeaderCartButton", href: paths.CART })] }), search: jsx(SearchButton, { "aria-controls": "global-search", "data-test-selector": "pageHeaderSearchButton", isActive: searchOpen, onActiveChange: toggleSearch }) }) }), jsx(SearchDrawer, { groupId: searchGroupId, instanceId: searchInstanceId }), !isXl && (jsx(MobileNavigationDrawer, { groupId: mobileNavigationDrawer.groupId, instanceId: mobileNavigationDrawer.instanceId, linkItems: mainNavigationSection?.items.filter(isNavigationLinkItem) })), isXl && (jsx(DesktopNavigationDrawer, { groupId: desktopNavigationDrawer.groupId, instanceId: desktopNavigationDrawer.instanceId, linkGroup: activeLinkGroup, onClosed: () => setActiveLinkGroup(undefined) }))] }));
77
77
  }
78
78
 
79
79
  export { Header };
package/dist/index.js CHANGED
@@ -327,7 +327,7 @@ export { useFetchProductDetailsPageData } from './shared/api/bff/hooks/use-fetch
327
327
  export { useFetchProductListingPageData } from './shared/api/bff/hooks/use-fetch-product-listing-page-data.js';
328
328
  export { useFetchProductsPrices } from './shared/api/bff/hooks/use-fetch-products-prices.js';
329
329
  export { useFetchRecentlyViewedProducts } from './shared/api/bff/hooks/use-fetch-recently-viewed-products.js';
330
- export { fetchAnnouncements, fetchNavigationLinks, fetchProductDetailsPageData, fetchProductListingPageData, fetchProductsPrices, fetchRecentlyViewedProducts, isNavigationLinkSource, patchCart, placeOrder, saveCartForLater } from './shared/api/bff/services/bff-service.js';
330
+ export { fetchAnnouncements, fetchNavigationLinks, fetchProductDetailsPageData, fetchProductListingPageData, fetchProductsPrices, fetchRecentlyViewedProducts, patchCart, placeOrder, saveCartForLater } from './shared/api/bff/services/bff-service.js';
331
331
  export { useAwaitableMutation } from './shared/api/shared/hooks/use-awaitable-mutation.js';
332
332
  export { useCreateAccount } from './shared/api/storefront/hooks/account/use-create-account.js';
333
333
  export { useCreateGuestAccount } from './shared/api/storefront/hooks/account/use-create-guest-account.js';
@@ -1,2 +1,2 @@
1
1
  import { FetchNavigationLinksArgs } from '../services/bff-service';
2
- export declare function useFetchNavigationLinks({ cultureCode, source, }: FetchNavigationLinksArgs): import("@tanstack/react-query").UseQueryResult<import("../model/bff.model").NavigationSection, Error>;
2
+ export declare function useFetchNavigationLinks({ cultureCode, }: FetchNavigationLinksArgs): import("@tanstack/react-query").UseQueryResult<import("../model/bff.model").NavigationSection, Error>;
@@ -3,11 +3,11 @@ import { useQuery } from '@tanstack/react-query';
3
3
  import { TIME } from '../../../utils/time.js';
4
4
  import { fetchNavigationLinks } from '../services/bff-service.js';
5
5
 
6
- function useFetchNavigationLinks({ cultureCode, source, }) {
6
+ function useFetchNavigationLinks({ cultureCode, }) {
7
7
  return useQuery({
8
8
  gcTime: 1 * TIME.DAY,
9
- queryFn: () => fetchNavigationLinks({ cultureCode, source }),
10
- queryKey: ['navigation', source, cultureCode],
9
+ queryFn: () => fetchNavigationLinks({ cultureCode }),
10
+ queryKey: ['navigation', cultureCode],
11
11
  refetchInterval: 5 * TIME.MINUTE,
12
12
  staleTime: 1 * TIME.DAY,
13
13
  });
@@ -15,13 +15,10 @@ export interface FetchProductPageDataArgs {
15
15
  }
16
16
  export declare function fetchProductDetailsPageData({ cultureCode, headers, ignoreCache, pageUrl, }: FetchProductPageDataArgs & APIArguments): Promise<ProductDetailsPageDataResponse>;
17
17
  export declare function fetchProductListingPageData({ cultureCode, headers, ignoreCache, pageUrl, }: FetchProductPageDataArgs & APIArguments): Promise<ProductListingPageData>;
18
- export type NavigationLinkSource = 'shop' | 'marketing';
19
- export declare function isNavigationLinkSource(value: unknown): value is NavigationLinkSource;
20
18
  export interface FetchNavigationLinksArgs {
21
19
  cultureCode: CultureCode;
22
- source: NavigationLinkSource;
23
20
  }
24
- export declare function fetchNavigationLinks({ cultureCode, headers, ignoreCache, source, }: FetchNavigationLinksArgs & APIArguments): Promise<NavigationResponse>;
21
+ export declare function fetchNavigationLinks({ cultureCode, headers, ignoreCache, }: FetchNavigationLinksArgs & APIArguments): Promise<NavigationResponse>;
25
22
  export declare function fetchRecentlyViewedProducts({ cultureCode, }: {
26
23
  cultureCode: CultureCode;
27
24
  }): Promise<ProductSummary[]>;
@@ -97,21 +97,14 @@ async function fetchProductListingPageData({ cultureCode, headers, ignoreCache,
97
97
  })),
98
98
  };
99
99
  }
100
- function isNavigationLinkSource(value) {
101
- return value === 'shop' || value === 'marketing';
102
- }
103
- async function fetchNavigationLinks({ cultureCode, headers, ignoreCache, source, }) {
100
+ async function fetchNavigationLinks({ cultureCode, headers, ignoreCache, }) {
104
101
  const { body } = await request({
105
- headers: { 'Current-Language-Id': cultureCode, Source: source, ...headers },
102
+ headers: { 'Current-Language-Id': cultureCode, ...headers },
106
103
  next: {
107
104
  revalidate: ignoreCache ? 0 : Infinity,
108
105
  tags: ignoreCache
109
106
  ? undefined
110
- : [
111
- 'navigation',
112
- `navigation-${source}`,
113
- `navigation-${source}-${cultureCode}`,
114
- ],
107
+ : ['navigation', `navigation-${cultureCode}`],
115
108
  },
116
109
  url: `${config.BFF_API_URL}/v2/navigation`,
117
110
  });
@@ -183,4 +176,4 @@ async function saveCartForLater({ cart }) {
183
176
  return body;
184
177
  }
185
178
 
186
- export { fetchAnnouncements, fetchNavigationLinks, fetchProductDetailsPageData, fetchProductListingPageData, fetchProductsPrices, fetchRecentlyViewedProducts, isNavigationLinkSource, patchCart, placeOrder, saveCartForLater };
179
+ export { fetchAnnouncements, fetchNavigationLinks, fetchProductDetailsPageData, fetchProductListingPageData, fetchProductsPrices, fetchRecentlyViewedProducts, patchCart, placeOrder, saveCartForLater };
package/dist/styles.css CHANGED
@@ -7957,7 +7957,7 @@ button.swiper-pagination-bullet {
7957
7957
  }
7958
7958
 
7959
7959
  .no-results-module-HGe-Y {
7960
- margin-top: var(--space-24);
7960
+ margin-block: var(--space-24);
7961
7961
  text-align: center;
7962
7962
  }
7963
7963
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sonic-equipment/ui",
3
- "version": "258.0.4",
3
+ "version": "259.0.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "engines": {