@sonic-equipment/ui 183.0.0 → 185.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 (98) hide show
  1. package/dist/cards/data-card/data-card.js +37 -20
  2. package/dist/cards/data-card/data-card.module.css.js +1 -1
  3. package/dist/country-selector/country-selector-dialog/country-selector-dialog.js +1 -5
  4. package/dist/exports.d.ts +20 -2
  5. package/dist/forms/form/form.d.ts +7 -3
  6. package/dist/forms/form/form.js +2 -2
  7. package/dist/forms/password-validation/password-validation.d.ts +4 -0
  8. package/dist/forms/password-validation/password-validation.js +32 -0
  9. package/dist/forms/select/select.d.ts +2 -1
  10. package/dist/forms/select/select.js +2 -2
  11. package/dist/header/connected-header.js +1 -1
  12. package/dist/header/header.d.ts +1 -3
  13. package/dist/header/header.js +2 -2
  14. package/dist/index.js +21 -3
  15. package/dist/intl/translation-id.d.ts +1 -1
  16. package/dist/intl/use-formatted-message.js +2 -1
  17. package/dist/lists/menu-list/menu-list.d.ts +2 -1
  18. package/dist/lists/menu-list/menu-list.js +2 -2
  19. package/dist/lists/widget-grid/widget-grid.d.ts +5 -0
  20. package/dist/lists/widget-grid/widget-grid.js +9 -0
  21. package/dist/lists/widget-grid/widget-grid.module.css.js +3 -0
  22. package/dist/lists/widget-grid/widget.d.ts +6 -0
  23. package/dist/lists/widget-grid/widget.js +10 -0
  24. package/dist/modals/dialog/dialog.d.ts +5 -5
  25. package/dist/modals/dialog/dialog.js +18 -18
  26. package/dist/modals/dialog/dialog.module.css.js +1 -1
  27. package/dist/modals/recover-password/recover-password-dialog.js +1 -3
  28. package/dist/pages/account/components/create-account-form/create-account-form.js +2 -17
  29. package/dist/pages/account/create-account-page/create-account-page.js +4 -5
  30. package/dist/pages/account/layouts/sign-in-page-layout/sign-in-page-layout.js +1 -1
  31. package/dist/pages/account/sign-in-page/sign-in-page.js +2 -3
  32. package/dist/pages/checkout/layouts/checkout-page-layout/checkout-page-layout.js +2 -1
  33. package/dist/pages/checkout/shipping-page/hooks/use-patch-shipping-details.d.ts +1 -0
  34. package/dist/pages/components/page-container/page-container.js +1 -1
  35. package/dist/pages/my-sonic/actions/change-customer/change-customer-dialog.d.ts +4 -3
  36. package/dist/pages/my-sonic/actions/change-customer/change-customer-dialog.js +10 -4
  37. package/dist/pages/my-sonic/actions/change-customer/change-customer.d.ts +5 -2
  38. package/dist/pages/my-sonic/actions/change-customer/change-customer.js +16 -7
  39. package/dist/pages/my-sonic/actions/change-customer/change-customer.module.css.js +1 -1
  40. package/dist/pages/my-sonic/actions/change-customer/connected-change-customer-dialog.d.ts +7 -2
  41. package/dist/pages/my-sonic/actions/change-customer/connected-change-customer-dialog.js +9 -6
  42. package/dist/pages/my-sonic/actions/change-password/change-password-dialog.d.ts +10 -0
  43. package/dist/pages/my-sonic/actions/change-password/change-password-dialog.js +24 -0
  44. package/dist/pages/my-sonic/actions/change-password/change-password.d.ts +7 -0
  45. package/dist/pages/my-sonic/actions/change-password/change-password.js +35 -0
  46. package/dist/pages/my-sonic/actions/change-password/change-password.module.css.js +3 -0
  47. package/dist/pages/my-sonic/actions/change-password/connected-change-password-dialog.d.ts +5 -0
  48. package/dist/pages/my-sonic/actions/change-password/connected-change-password-dialog.js +39 -0
  49. package/dist/pages/my-sonic/actions/edit-user-info/connected-edit-user-info-dialog.d.ts +5 -0
  50. package/dist/pages/my-sonic/actions/edit-user-info/connected-edit-user-info-dialog.js +56 -0
  51. package/dist/pages/my-sonic/actions/edit-user-info/edit-user-info-dialog.d.ts +10 -0
  52. package/dist/pages/my-sonic/actions/edit-user-info/edit-user-info-dialog.js +15 -0
  53. package/dist/pages/my-sonic/actions/edit-user-info/edit-user-info.d.ts +11 -0
  54. package/dist/pages/my-sonic/actions/edit-user-info/edit-user-info.js +29 -0
  55. package/dist/pages/my-sonic/actions/edit-user-info/edit-user-info.module.css.js +3 -0
  56. package/dist/pages/my-sonic/layouts/my-sonic-layout/my-sonic-layout-aside.d.ts +4 -0
  57. package/dist/pages/my-sonic/layouts/my-sonic-layout/my-sonic-layout-aside.js +9 -0
  58. package/dist/pages/my-sonic/layouts/my-sonic-layout/my-sonic-layout-main.d.ts +4 -0
  59. package/dist/pages/my-sonic/layouts/my-sonic-layout/my-sonic-layout-main.js +9 -0
  60. package/dist/pages/my-sonic/layouts/my-sonic-layout/my-sonic-layout-page.d.ts +5 -0
  61. package/dist/pages/my-sonic/layouts/my-sonic-layout/my-sonic-layout-page.js +10 -0
  62. package/dist/pages/my-sonic/layouts/my-sonic-layout/my-sonic-layout-pre-aside.d.ts +4 -0
  63. package/dist/pages/my-sonic/layouts/my-sonic-layout/my-sonic-layout-pre-aside.js +9 -0
  64. package/dist/pages/my-sonic/layouts/my-sonic-layout/my-sonic-layout-title.d.ts +4 -0
  65. package/dist/pages/my-sonic/layouts/my-sonic-layout/my-sonic-layout-title.js +10 -0
  66. package/dist/pages/my-sonic/layouts/my-sonic-layout/my-sonic-layout.d.ts +5 -0
  67. package/dist/pages/my-sonic/layouts/my-sonic-layout/my-sonic-layout.js +10 -0
  68. package/dist/pages/my-sonic/layouts/my-sonic-layout/my-sonic-layout.module.css.js +3 -0
  69. package/dist/pages/my-sonic/navigation/connected-my-sonic-navigation.js +3 -4
  70. package/dist/pages/my-sonic/navigation/connected-my-sonic-navigation.module.css.js +3 -0
  71. package/dist/pages/my-sonic/navigation/my-sonic-desktop-navigation.d.ts +2 -1
  72. package/dist/pages/my-sonic/navigation/my-sonic-desktop-navigation.js +2 -2
  73. package/dist/pages/my-sonic/navigation/my-sonic-mobile-navigation.d.ts +2 -1
  74. package/dist/pages/my-sonic/navigation/my-sonic-mobile-navigation.js +2 -2
  75. package/dist/pages/my-sonic/widgets/connected-customer-information-widget.js +3 -3
  76. package/dist/pages/my-sonic/widgets/connected-user-account-widget.js +16 -5
  77. package/dist/shared/api/shared/hooks/use-awaitable-mutation.d.ts +1 -0
  78. package/dist/shared/api/shared/hooks/use-awaitable-mutation.js +6 -0
  79. package/dist/shared/api/storefront/hooks/{authentication → account}/use-create-account.d.ts +1 -1
  80. package/dist/shared/api/storefront/hooks/{authentication → account}/use-create-account.js +3 -1
  81. package/dist/shared/api/storefront/hooks/{authentication → account}/use-create-guest-account.js +3 -1
  82. package/dist/shared/api/storefront/hooks/account/use-fetch-current-account.d.ts +3 -0
  83. package/dist/shared/api/storefront/hooks/account/use-fetch-current-account.js +13 -0
  84. package/dist/shared/api/storefront/hooks/account/use-patch-current-account.d.ts +11 -0
  85. package/dist/shared/api/storefront/hooks/account/use-patch-current-account.js +20 -0
  86. package/dist/shared/api/storefront/hooks/authentication/use-patch-session.d.ts +1 -0
  87. package/dist/shared/api/storefront/hooks/authentication/use-patch-session.js +1 -1
  88. package/dist/shared/api/storefront/hooks/cart/use-patch-cart.d.ts +1 -0
  89. package/dist/shared/api/storefront/hooks/cart/use-place-order.d.ts +1 -0
  90. package/dist/shared/api/storefront/hooks/customer/use-patch-bill-to-address.d.ts +1 -0
  91. package/dist/shared/api/storefront/services/account-service.d.ts +31 -0
  92. package/dist/shared/api/storefront/services/account-service.js +84 -0
  93. package/dist/shared/api/storefront/services/authentication-service.d.ts +7 -26
  94. package/dist/shared/api/storefront/services/authentication-service.js +38 -65
  95. package/dist/shared/hooks/use-watch-css-property.js +9 -1
  96. package/dist/styles.css +354 -241
  97. package/package.json +1 -1
  98. /package/dist/shared/api/storefront/hooks/{authentication → account}/use-create-guest-account.d.ts +0 -0
@@ -0,0 +1,84 @@
1
+ import { config } from '../../../../config.js';
2
+ import { request, RequestError, isRequestError } from '../../../fetch/request.js';
3
+
4
+ async function fetchCurrentAccount() {
5
+ const { body } = await request({
6
+ url: `${config.SHOP_API_URL}/api/v1/accounts/current`,
7
+ });
8
+ return body;
9
+ }
10
+ class ExistingAccountError extends RequestError {
11
+ constructor(error) {
12
+ super(error);
13
+ this.name = 'ExistingAccountError';
14
+ }
15
+ }
16
+ async function createAccount({ companyName, countryCode, email, firstName, isPrivateAccount, isSubscribed, lastName, password, }) {
17
+ try {
18
+ const { body } = await request({
19
+ body: {
20
+ email,
21
+ firstName,
22
+ isSubscribed,
23
+ lastName,
24
+ password,
25
+ properties: {
26
+ PrivateAccount: isPrivateAccount,
27
+ companyName,
28
+ countryCode,
29
+ },
30
+ userName: '',
31
+ },
32
+ headers: {
33
+ 'Content-Type': 'application/json',
34
+ },
35
+ method: 'POST',
36
+ url: `${config.SHOP_API_URL}/api/v1/accounts`,
37
+ });
38
+ return body;
39
+ }
40
+ catch (error) {
41
+ if (isRequestError(error) &&
42
+ error.status === 400 &&
43
+ error.body?.message === 'Email Address already exists')
44
+ throw new ExistingAccountError(error);
45
+ throw error;
46
+ }
47
+ }
48
+ async function createGuestAccount({ defaultWarehouseId, }) {
49
+ const { body } = await request({
50
+ body: {
51
+ defaultFulfillmentMethod: 'Ship',
52
+ defaultWarehouseId,
53
+ isGuest: true,
54
+ },
55
+ headers: {
56
+ 'Content-Type': 'application/json',
57
+ },
58
+ method: 'POST',
59
+ url: `${config.SHOP_API_URL}/api/v1/accounts`,
60
+ });
61
+ return body;
62
+ }
63
+ async function patchCurrentAccount({ account, }) {
64
+ try {
65
+ const { body } = await request({
66
+ body: account,
67
+ headers: {
68
+ 'Content-Type': 'application/json',
69
+ },
70
+ method: 'PATCH',
71
+ url: `${config.SHOP_API_URL}/api/v1/accounts/current`,
72
+ });
73
+ return body;
74
+ }
75
+ catch (error) {
76
+ if (isRequestError(error) &&
77
+ error.status === 400 &&
78
+ error.body?.message === 'Email Address already exists')
79
+ throw new ExistingAccountError(error);
80
+ throw error;
81
+ }
82
+ }
83
+
84
+ export { ExistingAccountError, createAccount, createGuestAccount, fetchCurrentAccount, patchCurrentAccount };
@@ -1,6 +1,12 @@
1
1
  import { RequestError } from '../../../fetch/request';
2
- import { AccountModel, PatchSessionModel, SessionModel } from '../model/storefront.model';
2
+ import { PatchSessionModel, SessionModel } from '../model/storefront.model';
3
3
  export declare function fetchSession(): Promise<SessionModel>;
4
+ export declare class InvalidPasswordError extends Error {
5
+ constructor(error: RequestError);
6
+ }
7
+ export declare class NonUniquePasswordError extends Error {
8
+ constructor(error: RequestError);
9
+ }
4
10
  export declare function patchSession({ session, }: {
5
11
  session: PatchSessionModel;
6
12
  }): Promise<SessionModel>;
@@ -26,31 +32,6 @@ export declare function createSession({ accessToken, isGuest, keepMeSignedIn, pa
26
32
  accessToken: string;
27
33
  } & CreateSessionRequestBody): Promise<SessionModel>;
28
34
  export declare function signOut(): Promise<void>;
29
- export declare function createGuestAccount({ defaultWarehouseId, }: {
30
- defaultWarehouseId: string;
31
- }): Promise<AccountModel>;
32
35
  export declare function recoverPassword({ userName, }: {
33
36
  userName: string;
34
37
  }): Promise<SessionModel>;
35
- export declare class ExistingAccountError extends RequestError {
36
- constructor(error: Error);
37
- }
38
- export interface CreateAccountRequestBase {
39
- email: string;
40
- firstName?: string;
41
- isSubscribed: boolean;
42
- lastName: string;
43
- password: string;
44
- }
45
- export interface CreatePrivateAccountRequestBody extends CreateAccountRequestBase {
46
- companyName?: string | undefined;
47
- countryCode: string;
48
- isPrivateAccount: true;
49
- }
50
- export interface CreateBusinessAccountRequestBody extends CreateAccountRequestBase {
51
- companyName: string;
52
- countryCode: string;
53
- isPrivateAccount: false;
54
- }
55
- export type CreateAccountRequestBody = CreatePrivateAccountRequestBody | CreateBusinessAccountRequestBody;
56
- export declare function createAccount({ companyName, countryCode, email, firstName, isPrivateAccount, isSubscribed, lastName, password, }: CreateAccountRequestBody): Promise<AccountModel>;
@@ -1,5 +1,5 @@
1
1
  import { config } from '../../../../config.js';
2
- import { request, isRequestError, RequestError } from '../../../fetch/request.js';
2
+ import { request, isRequestError } from '../../../fetch/request.js';
3
3
 
4
4
  async function fetchSession() {
5
5
  const { body } = await request({
@@ -8,17 +8,43 @@ async function fetchSession() {
8
8
  });
9
9
  return body;
10
10
  }
11
+ class InvalidPasswordError extends Error {
12
+ constructor(error) {
13
+ super(error.body?.message || error.message);
14
+ this.name = 'InvalidPasswordError';
15
+ }
16
+ }
17
+ class NonUniquePasswordError extends Error {
18
+ constructor(error) {
19
+ super(error.body?.message || error.message);
20
+ this.name = 'NonUniquePasswordError';
21
+ }
22
+ }
11
23
  async function patchSession({ session, }) {
12
- const { body } = await request({
13
- body: session,
14
- credentials: 'include',
15
- headers: {
16
- 'Content-Type': 'application/json',
17
- },
18
- method: 'PATCH',
19
- url: `${config.SHOP_API_URL}/api/v1/sessions/current`,
20
- });
21
- return body;
24
+ try {
25
+ const { body } = await request({
26
+ body: session,
27
+ credentials: 'include',
28
+ headers: {
29
+ 'Content-Type': 'application/json',
30
+ },
31
+ method: 'PATCH',
32
+ url: `${config.SHOP_API_URL}/api/v1/sessions/current`,
33
+ });
34
+ return body;
35
+ }
36
+ catch (error) {
37
+ if (isRequestError(error) && error.status === 400) {
38
+ if (error.body?.message ===
39
+ 'New Password is required and must be different than Current Password') {
40
+ throw new NonUniquePasswordError(error);
41
+ }
42
+ if (error.body?.message === 'Current Password is invalid') {
43
+ throw new InvalidPasswordError(error);
44
+ }
45
+ }
46
+ throw error;
47
+ }
22
48
  }
23
49
  async function signIn({ password, userName, }) {
24
50
  const params = new URLSearchParams();
@@ -70,21 +96,6 @@ async function signOut() {
70
96
  throw error;
71
97
  }
72
98
  }
73
- async function createGuestAccount({ defaultWarehouseId, }) {
74
- const { body } = await request({
75
- body: {
76
- defaultFulfillmentMethod: 'Ship',
77
- defaultWarehouseId,
78
- isGuest: true,
79
- },
80
- headers: {
81
- 'Content-Type': 'application/json',
82
- },
83
- method: 'POST',
84
- url: `${config.SHOP_API_URL}/api/v1/accounts`,
85
- });
86
- return body;
87
- }
88
99
  async function recoverPassword({ userName, }) {
89
100
  const { body } = await request({
90
101
  body: {
@@ -99,43 +110,5 @@ async function recoverPassword({ userName, }) {
99
110
  });
100
111
  return body;
101
112
  }
102
- class ExistingAccountError extends RequestError {
103
- constructor(error) {
104
- super(error);
105
- this.name = 'ExistingAccountError';
106
- }
107
- }
108
- async function createAccount({ companyName, countryCode, email, firstName, isPrivateAccount, isSubscribed, lastName, password, }) {
109
- try {
110
- const { body } = await request({
111
- body: {
112
- email,
113
- firstName,
114
- isSubscribed,
115
- lastName,
116
- password,
117
- properties: {
118
- PrivateAccount: isPrivateAccount,
119
- companyName,
120
- countryCode,
121
- },
122
- userName: '',
123
- },
124
- headers: {
125
- 'Content-Type': 'application/json',
126
- },
127
- method: 'POST',
128
- url: `${config.SHOP_API_URL}/api/v1/accounts`,
129
- });
130
- return body;
131
- }
132
- catch (error) {
133
- if (isRequestError(error) &&
134
- error.status === 400 &&
135
- error.body?.message === 'Email Address already exists')
136
- throw new ExistingAccountError(error);
137
- throw error;
138
- }
139
- }
140
113
 
141
- export { ExistingAccountError, createAccount, createGuestAccount, createSession, fetchSession, patchSession, recoverPassword, signIn, signOut };
114
+ export { InvalidPasswordError, NonUniquePasswordError, createSession, fetchSession, patchSession, recoverPassword, signIn, signOut };
@@ -3,7 +3,15 @@ import { useState, useEffect } from 'react';
3
3
  import { getCssPropertyValue } from '../utils/css.js';
4
4
 
5
5
  function useWatchCssProperty(property) {
6
- const [value, setValue] = useState(() => getCssPropertyValue(property));
6
+ const [value, setValue] = useState(() => {
7
+ try {
8
+ return getCssPropertyValue(property);
9
+ }
10
+ catch {
11
+ // If the property can not be retrieved, return undefined
12
+ return;
13
+ }
14
+ });
7
15
  useEffect(() => {
8
16
  if (typeof MutationObserver === 'undefined' ||
9
17
  typeof document === 'undefined')