@sonic-equipment/ui 178.0.0 → 180.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.
Files changed (102) hide show
  1. package/dist/algolia/algolia-active-filters.js +4 -0
  2. package/dist/config.js +4 -7
  3. package/dist/country-select/country-select.d.ts +1 -0
  4. package/dist/exports.d.ts +19 -9
  5. package/dist/forms/input/input.d.ts +1 -0
  6. package/dist/forms/input/input.js +4 -4
  7. package/dist/forms/input/input.module.css.js +1 -1
  8. package/dist/forms/password-field/password-field.d.ts +2 -0
  9. package/dist/forms/password-field/password-field.js +15 -0
  10. package/dist/forms/search-field/search-field.d.ts +5 -0
  11. package/dist/forms/search-field/search-field.js +19 -0
  12. package/dist/forms/text-field/text-field.d.ts +25 -24
  13. package/dist/forms/text-field/text-field.js +7 -14
  14. package/dist/forms/textarea/textarea.d.ts +1 -0
  15. package/dist/forms/textarea/textarea.js +2 -2
  16. package/dist/forms/textarea/textarea.module.css.js +1 -1
  17. package/dist/global-search/search-highlight/highlight.d.ts +1 -0
  18. package/dist/header/buttons/account/connected-account-button.js +1 -1
  19. package/dist/icons/solid/solid-rating-icon.js +7 -0
  20. package/dist/index.js +20 -10
  21. package/dist/intl/translation-id.d.ts +1 -1
  22. package/dist/modals/dialog/dialog.d.ts +5 -1
  23. package/dist/modals/dialog/dialog.js +10 -4
  24. package/dist/navigation/mobile-navigation/mobile-navigation.js +1 -1
  25. package/dist/observers/intersection-observer.d.ts +9 -1
  26. package/dist/observers/intersection-observer.js +6 -3
  27. package/dist/pages/account/components/create-account-form/create-account-form.js +3 -2
  28. package/dist/pages/account/components/sign-in-form/sign-in-form.js +2 -1
  29. package/dist/pages/my-sonic/actions/change-customer/change-customer-dialog.d.ts +15 -0
  30. package/dist/pages/my-sonic/actions/change-customer/change-customer-dialog.js +23 -0
  31. package/dist/pages/my-sonic/actions/change-customer/change-customer-dialog.module.css.js +3 -0
  32. package/dist/pages/my-sonic/actions/change-customer/change-customer.d.ts +13 -0
  33. package/dist/pages/my-sonic/actions/change-customer/change-customer.js +66 -0
  34. package/dist/pages/my-sonic/actions/change-customer/change-customer.module.css.js +3 -0
  35. package/dist/pages/my-sonic/actions/change-customer/connected-change-customer-dialog.d.ts +2 -0
  36. package/dist/pages/my-sonic/actions/change-customer/connected-change-customer-dialog.js +39 -0
  37. package/dist/pages/my-sonic/navigation/connected-my-sonic-navigation.d.ts +1 -0
  38. package/dist/pages/{my-account/navigation/connected-my-account-navigation.js → my-sonic/navigation/connected-my-sonic-navigation.js} +5 -5
  39. package/dist/pages/my-sonic/navigation/my-sonic-desktop-navigation.d.ts +6 -0
  40. package/dist/pages/my-sonic/navigation/my-sonic-desktop-navigation.js +19 -0
  41. package/dist/pages/my-sonic/navigation/my-sonic-desktop-navigation.module.css.js +3 -0
  42. package/dist/pages/{my-account/navigation/my-account-mobile-navigation.d.ts → my-sonic/navigation/my-sonic-mobile-navigation.d.ts} +1 -1
  43. package/dist/pages/my-sonic/navigation/my-sonic-mobile-navigation.js +22 -0
  44. package/dist/pages/my-sonic/navigation/my-sonic-navigation-items.d.ts +18 -0
  45. package/dist/pages/my-sonic/navigation/my-sonic-navigation-items.js +29 -0
  46. package/dist/pages/my-sonic/widgets/connected-customer-information-widget.d.ts +1 -0
  47. package/dist/pages/my-sonic/widgets/connected-customer-information-widget.js +56 -0
  48. package/dist/pages/product/layouts/product-details-page-layout/product-details-page-layout.d.ts +2 -2
  49. package/dist/pages/product/layouts/product-details-page-layout/product-details-page-layout.js +3 -2
  50. package/dist/pages/product/layouts/product-details-page-layout/product-details-page-layout.module.css.js +1 -1
  51. package/dist/pages/product/product-details-page/components/product-details-recently-viewed-section/product-details-recently-viewed-section.d.ts +1 -0
  52. package/dist/pages/product/product-details-page/components/product-details-recently-viewed-section/product-details-recently-viewed-section.js +24 -0
  53. package/dist/pages/product/product-details-page/components/product-details-recently-viewed-section/product-details-recently-viewed-section.module.css.js +3 -0
  54. package/dist/pages/product/product-details-page/product-details.d.ts +1 -2
  55. package/dist/pages/product/product-details-page/product-details.js +4 -5
  56. package/dist/shared/api/bff/hooks/use-fetch-product-details-page-data.js +6 -2
  57. package/dist/shared/api/bff/hooks/use-fetch-recently-viewed-products.d.ts +4 -0
  58. package/dist/shared/api/bff/hooks/use-fetch-recently-viewed-products.js +15 -0
  59. package/dist/shared/api/bff/model/bff.model.d.ts +0 -1
  60. package/dist/shared/api/bff/services/bff-service.d.ts +4 -1
  61. package/dist/shared/api/bff/services/bff-service.js +11 -1
  62. package/dist/shared/api/storefront/hooks/authentication/use-patch-session.d.ts +12 -1
  63. package/dist/shared/api/storefront/hooks/customer/use-fetch-bill-to-addresses.d.ts +4 -1
  64. package/dist/shared/api/storefront/hooks/customer/use-fetch-bill-to-addresses.js +5 -6
  65. package/dist/shared/api/storefront/hooks/product/use-mark-product-as-viewed.d.ts +2 -0
  66. package/dist/shared/api/storefront/hooks/product/use-mark-product-as-viewed.js +17 -0
  67. package/dist/shared/api/storefront/model/storefront.model.d.ts +4 -1
  68. package/dist/shared/api/storefront/services/customer-service.d.ts +5 -1
  69. package/dist/shared/api/storefront/services/customer-service.js +3 -3
  70. package/dist/shared/api/storefront/services/product-service.d.ts +4 -0
  71. package/dist/shared/api/storefront/services/product-service.js +10 -0
  72. package/dist/shared/feature-flags/use-feature-flags.d.ts +0 -3
  73. package/dist/shared/feature-flags/use-feature-flags.js +0 -3
  74. package/dist/shared/fetch/request.d.ts +1 -1
  75. package/dist/shared/ga/google-analytics-provider.d.ts +1 -1
  76. package/dist/shared/hooks/use-intersection-observer.d.ts +2 -1
  77. package/dist/shared/hooks/use-intersection-observer.js +3 -2
  78. package/dist/styles.css +228 -101
  79. package/dist/text/highlight-text/highlight-text.d.ts +10 -0
  80. package/dist/text/highlight-text/highlight-text.js +19 -0
  81. package/dist/text/highlight-text/highlight-text.module.css.js +3 -0
  82. package/dist/typography/heading/heading.d.ts +3 -1
  83. package/dist/typography/heading/heading.js +2 -1
  84. package/package.json +2 -1
  85. package/dist/icons/solid/solid-dashboard-icon.js +0 -7
  86. package/dist/pages/my-account/navigation/connected-my-account-navigation.d.ts +0 -1
  87. package/dist/pages/my-account/navigation/my-account-desktop-navigation.d.ts +0 -6
  88. package/dist/pages/my-account/navigation/my-account-desktop-navigation.js +0 -17
  89. package/dist/pages/my-account/navigation/my-account-desktop-navigation.module.css.js +0 -3
  90. package/dist/pages/my-account/navigation/my-account-mobile-navigation.js +0 -25
  91. package/dist/pages/my-account/widgets/connected-company-information-widget.d.ts +0 -1
  92. package/dist/pages/my-account/widgets/connected-company-information-widget.js +0 -43
  93. package/dist/pages/product/product-details-page/components/product-details-recently-viewed/product-details-recently-viewed.d.ts +0 -4
  94. package/dist/pages/product/product-details-page/components/product-details-recently-viewed/product-details-recently-viewed.js +0 -15
  95. /package/dist/pages/{my-account → my-sonic}/widgets/components/address-data-card.d.ts +0 -0
  96. /package/dist/pages/{my-account → my-sonic}/widgets/components/address-data-card.js +0 -0
  97. /package/dist/pages/{my-account → my-sonic}/widgets/connected-bill-to-address-widget.d.ts +0 -0
  98. /package/dist/pages/{my-account → my-sonic}/widgets/connected-bill-to-address-widget.js +0 -0
  99. /package/dist/pages/{my-account → my-sonic}/widgets/connected-ship-to-address-widget.d.ts +0 -0
  100. /package/dist/pages/{my-account → my-sonic}/widgets/connected-ship-to-address-widget.js +0 -0
  101. /package/dist/pages/{my-account → my-sonic}/widgets/connected-user-account-widget.d.ts +0 -0
  102. /package/dist/pages/{my-account → my-sonic}/widgets/connected-user-account-widget.js +0 -0
@@ -0,0 +1,15 @@
1
+ import { useQuery } from '@tanstack/react-query';
2
+ import { TIME } from '../../../utils/time.js';
3
+ import { fetchRecentlyViewedProducts } from '../services/bff-service.js';
4
+
5
+ function useFetchRecentlyViewedProducts({ cultureCode, }) {
6
+ return useQuery({
7
+ gcTime: 1 * TIME.DAY,
8
+ queryFn: () => fetchRecentlyViewedProducts({ cultureCode }),
9
+ queryKey: ['products', 'recently-viewed'],
10
+ // refetchInterval: TIME.MINUTE,
11
+ staleTime: 1 * TIME.DAY,
12
+ });
13
+ }
14
+
15
+ export { useFetchRecentlyViewedProducts };
@@ -149,7 +149,6 @@ export interface ProductDetailsPageDataResponse {
149
149
  included: ProductSummary[];
150
150
  page: PageModel;
151
151
  product: ProductDetails;
152
- recentlyViewed: ProductSummary[];
153
152
  usps?: Usp[];
154
153
  }
155
154
  export interface ProductListingPageDataResponse {
@@ -1,7 +1,7 @@
1
1
  import { CultureCode } from '../../../../intl/types';
2
2
  import { ProductListingPageData } from '../../../../pages/product/product-listing-page/product-listing-page-data-types';
3
3
  import { AnnouncementObject } from '../../../model/announcement';
4
- import { NavigationLinkResponse, ProductDetailsPageDataResponse } from '../model/bff.model';
4
+ import { NavigationLinkResponse, ProductDetailsPageDataResponse, ProductSummary } from '../model/bff.model';
5
5
  export interface FetchAnnouncementsArgs {
6
6
  cultureCode: CultureCode;
7
7
  }
@@ -18,3 +18,6 @@ export interface FetchNavigationLinksArgs {
18
18
  source: NavigationLinkSource;
19
19
  }
20
20
  export declare function fetchNavigationLinks({ cultureCode, source, }: FetchNavigationLinksArgs): Promise<NavigationLinkResponse>;
21
+ export declare function fetchRecentlyViewedProducts({ cultureCode, }: {
22
+ cultureCode: CultureCode;
23
+ }): Promise<ProductSummary[]>;
@@ -2,6 +2,7 @@ import { config } from '../../../../config.js';
2
2
  import { request } from '../../../fetch/request.js';
3
3
  import { isAnnouncementType, isAnnouncementSubtype } from '../../../model/announcement.js';
4
4
  import { TIME } from '../../../utils/time.js';
5
+ import { markProductAsRecentlyViewed } from '../../storefront/services/product-service.js';
5
6
 
6
7
  async function fetchAnnouncements({ cultureCode, }) {
7
8
  const { body } = await request({
@@ -45,6 +46,7 @@ async function fetchProductDetailsPageData({ cultureCode, pageUrl, }) {
45
46
  },
46
47
  url: `${config.BFF_API_URL}/pdp/?pageUrl=${pageUrl}`,
47
48
  });
49
+ markProductAsRecentlyViewed({ productId: body.product.id });
48
50
  return body;
49
51
  }
50
52
  async function fetchProductListingPageData({ cultureCode, pageUrl, }) {
@@ -106,5 +108,13 @@ async function fetchNavigationLinks({ cultureCode, source, }) {
106
108
  });
107
109
  return body;
108
110
  }
111
+ async function fetchRecentlyViewedProducts({ cultureCode, }) {
112
+ const { body } = await request({
113
+ credentials: 'include',
114
+ headers: { 'Current-Language-Id': cultureCode },
115
+ url: `${config.BFF_API_URL}/recently-viewed`,
116
+ });
117
+ return body;
118
+ }
109
119
 
110
- export { fetchAnnouncements, fetchNavigationLinks, fetchProductDetailsPageData, fetchProductListingPageData };
120
+ export { fetchAnnouncements, fetchNavigationLinks, fetchProductDetailsPageData, fetchProductListingPageData, fetchRecentlyViewedProducts };
@@ -3,5 +3,16 @@ export declare function usePatchSession(): {
3
3
  isError: boolean;
4
4
  isLoading: boolean;
5
5
  isSuccess: boolean;
6
- mutate: (args_0: any) => Promise<import("../../model/storefront.model").SessionModel>;
6
+ mutate: (args_0: {
7
+ session: Partial<Omit<import("../../model/storefront.model").SessionModel, "billTo" | "shipTo"> & {
8
+ billTo?: import("../../model/storefront.model").BillToModel | {
9
+ id: string;
10
+ } | null;
11
+ billToId?: string | null;
12
+ shipTo?: import("../../model/storefront.model").ShipToModel | {
13
+ id: string;
14
+ } | null;
15
+ shipToId?: string | null;
16
+ }>;
17
+ }) => Promise<import("../../model/storefront.model").SessionModel>;
7
18
  };
@@ -1 +1,4 @@
1
- export declare function useFetchBillToAddresses(): import("@tanstack/react-query").UseQueryResult<import("../../model/storefront.model").BillToModel[] | null, Error>;
1
+ import { FetchBillToAddressesParams } from '../../services/customer-service';
2
+ export declare function useFetchBillToAddresses({ filter, isEnabled, pageSize, }?: FetchBillToAddressesParams & {
3
+ isEnabled?: boolean;
4
+ }): import("@tanstack/react-query").UseQueryResult<import("../../model/storefront.model").BillToCollectionModel, Error>;
@@ -1,13 +1,12 @@
1
1
  import { useQuery } from '@tanstack/react-query';
2
2
  import { fetchBillToAddresses } from '../../services/customer-service.js';
3
3
 
4
- function useFetchBillToAddresses() {
4
+ function useFetchBillToAddresses({ filter = '', isEnabled = true, pageSize, } = {}) {
5
5
  return useQuery({
6
- queryFn: fetchBillToAddresses,
7
- queryKey: ['customer', 'bill-to-addresses'],
8
- select(body) {
9
- return body.billTos;
10
- },
6
+ enabled: isEnabled,
7
+ placeholderData: prev => prev,
8
+ queryFn: () => fetchBillToAddresses({ filter, pageSize }),
9
+ queryKey: ['customer', 'bill-to-addresses', pageSize, filter],
11
10
  });
12
11
  }
13
12
 
@@ -0,0 +1,2 @@
1
+ import { MarkProductAsRecentlyViewedArgs } from '../../services/product-service';
2
+ export declare function useMarkProductAsRecentlyViewed(args: MarkProductAsRecentlyViewedArgs): import("@tanstack/react-query").UseQueryResult<void, Error>;
@@ -0,0 +1,17 @@
1
+ import { useQueryClient, useQuery } from '@tanstack/react-query';
2
+ import { markProductAsRecentlyViewed } from '../../services/product-service.js';
3
+
4
+ function useMarkProductAsRecentlyViewed(args) {
5
+ const queryClient = useQueryClient();
6
+ return useQuery({
7
+ gcTime: 0,
8
+ queryFn: () => {
9
+ markProductAsRecentlyViewed(args);
10
+ queryClient.removeQueries({ queryKey: ['products', 'recently-viewed'] });
11
+ },
12
+ queryKey: ['mark-product-as-recently-viewed', args.productId],
13
+ staleTime: 0,
14
+ });
15
+ }
16
+
17
+ export { useMarkProductAsRecentlyViewed };
@@ -1,3 +1,4 @@
1
+ import { JSX } from 'react';
1
2
  export interface BaseModel {
2
3
  properties: {
3
4
  [key: string]: string;
@@ -127,7 +128,7 @@ export interface SessionModel extends BaseModel {
127
128
  dashboardIsHomepage: boolean | null;
128
129
  deviceType: string;
129
130
  displayChangeCustomerLink: boolean;
130
- displayMyAccountMenu: boolean;
131
+ displayMySonicMenu: boolean;
131
132
  displayPricingAndInventory: boolean;
132
133
  email: string;
133
134
  firstName: string;
@@ -161,9 +162,11 @@ export type PatchSessionModel = Partial<Omit<SessionModel, 'billTo' | 'shipTo'>
161
162
  billTo?: BillToModel | {
162
163
  id: string;
163
164
  } | null;
165
+ billToId?: string | null;
164
166
  shipTo?: ShipToModel | {
165
167
  id: string;
166
168
  } | null;
169
+ shipToId?: string | null;
167
170
  }>;
168
171
  export interface ShipToModel extends BaseModel {
169
172
  address1: string;
@@ -1,7 +1,11 @@
1
1
  import { BillToCollectionModel, BillToModel, PatchBillToModel, ShipToCollectionModel, ShipToModel } from 'shared/api/storefront/model/storefront.model';
2
2
  export declare function fetchCurrentBillToAddress(): Promise<BillToModel>;
3
3
  export declare function fetchCurrentShipToAddress(): Promise<ShipToModel>;
4
- export declare function fetchBillToAddresses(): Promise<BillToCollectionModel>;
4
+ export interface FetchBillToAddressesParams {
5
+ filter?: string;
6
+ pageSize?: number;
7
+ }
8
+ export declare function fetchBillToAddresses({ filter, pageSize, }?: FetchBillToAddressesParams): Promise<BillToCollectionModel>;
5
9
  export declare function fetchShipToAddresses({ shipToId }: {
6
10
  shipToId: string;
7
11
  }): Promise<ShipToCollectionModel>;
@@ -15,17 +15,17 @@ async function fetchCurrentShipToAddress() {
15
15
  });
16
16
  return body;
17
17
  }
18
- async function fetchBillToAddresses() {
18
+ async function fetchBillToAddresses({ filter, pageSize = 20, } = {}) {
19
19
  const { body } = await request({
20
20
  credentials: 'include',
21
- url: `${config.SHOP_API_URL}/api/v1/billtos?pageSize=999`,
21
+ url: `${config.SHOP_API_URL}/api/v1/billtos?pageSize=${pageSize}${filter ? `&filter=${encodeURIComponent(filter)}` : ''}`,
22
22
  });
23
23
  return body;
24
24
  }
25
25
  async function fetchShipToAddresses({ shipToId }) {
26
26
  const { body } = await request({
27
27
  credentials: 'include',
28
- url: `${config.SHOP_API_URL}/api/v1/billtos/${shipToId}/shiptos?pageSize=999`,
28
+ url: `${config.SHOP_API_URL}/api/v1/billtos/${shipToId}/shiptos?pageSize=20`,
29
29
  });
30
30
  return body;
31
31
  }
@@ -0,0 +1,4 @@
1
+ export interface MarkProductAsRecentlyViewedArgs {
2
+ productId: string;
3
+ }
4
+ export declare function markProductAsRecentlyViewed({ productId, }: MarkProductAsRecentlyViewedArgs): Promise<void>;
@@ -0,0 +1,10 @@
1
+ import { config } from '../../../../config.js';
2
+ import { request } from '../../../fetch/request.js';
3
+
4
+ async function markProductAsRecentlyViewed({ productId, }) {
5
+ await request({
6
+ url: `${config.SHOP_API_URL}/api/v2/products/${productId}?addToRecentlyViewed=true`,
7
+ });
8
+ }
9
+
10
+ export { markProductAsRecentlyViewed };
@@ -1,12 +1,9 @@
1
1
  declare const features: {
2
2
  readonly cartv1: "cartV1";
3
3
  readonly checkoutv1: "checkoutV1";
4
- readonly languagev1: "languageV1";
5
4
  readonly missing: "missing";
6
- readonly navigation: "navigationV2";
7
5
  readonly pdpv1: "pdpV1";
8
6
  readonly plpv1: "plpV1";
9
- readonly searchv1: "searchV1";
10
7
  readonly translations: "translations";
11
8
  };
12
9
  type FeatureKeys = keyof typeof features;
@@ -4,12 +4,9 @@ import qs from 'query-string';
4
4
  const features = {
5
5
  cartv1: 'cartV1',
6
6
  checkoutv1: 'checkoutV1',
7
- languagev1: 'languageV1',
8
7
  missing: 'missing',
9
- navigation: 'navigationV2',
10
8
  pdpv1: 'pdpV1',
11
9
  plpv1: 'plpV1',
12
- searchv1: 'searchV1',
13
10
  translations: 'translations',
14
11
  };
15
12
  function useFeatureFlags() {
@@ -79,7 +79,7 @@ export interface RequestOptionsWithoutBody extends BaseRequestOptions {
79
79
  headers?: RequestHeaders;
80
80
  }
81
81
  export type RequestOptions = RequestOptionsWithBody | RequestOptionsWithoutBody | RequestOptionsWithFormData;
82
- type BeforeRequestHandler = (options?: RequestOptions) => RequestOptions | void;
82
+ type BeforeRequestHandler = (options: RequestOptions) => RequestOptions | void;
83
83
  type BeforeRequestHandlerAsync = (options?: RequestOptions) => Promise<RequestOptions | void>;
84
84
  export interface AfterRequestHandlerArgs<T> {
85
85
  body: T | undefined;
@@ -1,4 +1,4 @@
1
- import { ReactNode } from 'react';
1
+ import { JSX, ReactNode } from 'react';
2
2
  export declare function useGoogleAnalyticsProvider(): {
3
3
  customerNumber: string | undefined;
4
4
  isLoading: boolean;
@@ -3,11 +3,12 @@ interface Observable {
3
3
  ref: React.RefObject<HTMLElement>;
4
4
  }
5
5
  export interface UseIntersectionObserverProps {
6
+ intersectionObserverInit?: IntersectionObserverInit;
6
7
  isDisabled?: boolean;
7
8
  observables: Observable[];
8
9
  onIntersectingChange?: (isIntersecting: boolean) => void;
9
10
  }
10
- export declare function useIntersectionObserver({ isDisabled, observables, onIntersectingChange, }: UseIntersectionObserverProps): {
11
+ export declare function useIntersectionObserver({ intersectionObserverInit, isDisabled, observables, onIntersectingChange, }: UseIntersectionObserverProps): {
11
12
  isIntersecting: boolean;
12
13
  };
13
14
  export {};
@@ -1,8 +1,8 @@
1
1
  "use client";
2
2
  import { useState, useRef, useEffect } from 'react';
3
3
 
4
- function useIntersectionObserver({ isDisabled, observables, onIntersectingChange, }) {
5
- const [isIntersecting, setIntersecting] = useState(true);
4
+ function useIntersectionObserver({ intersectionObserverInit, isDisabled, observables, onIntersectingChange, }) {
5
+ const [isIntersecting, setIntersecting] = useState(false);
6
6
  const state = useRef([]);
7
7
  function disconnectObservers() {
8
8
  state.current.forEach(entry => entry.observer.disconnect());
@@ -25,6 +25,7 @@ function useIntersectionObserver({ isDisabled, observables, onIntersectingChange
25
25
  rootMargin: '0px',
26
26
  threshold: 0,
27
27
  ...observable.options,
28
+ ...intersectionObserverInit,
28
29
  }),
29
30
  };
30
31
  result.observer.observe(observable.ref.current);