@sonic-equipment/ui 133.0.0 → 135.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.
- package/dist/address/address.d.ts +5 -2
- package/dist/address/address.js +3 -2
- package/dist/algolia/{algolia-intialization.js → algolia-initialization.js} +7 -0
- package/dist/algolia/algolia-insights-provider.js +7 -0
- package/dist/algolia/algolia-search-provider.js +19 -0
- package/dist/algolia/use-algolia-insights.d.ts +13 -6
- package/dist/algolia/use-algolia-insights.js +93 -10
- package/dist/buttons/button/button.d.ts +4 -1
- package/dist/buttons/button/button.js +2 -2
- package/dist/country-selector/country-select/country-select.d.ts +1 -0
- package/dist/country-selector/country-select/country-select.js +2 -2
- package/dist/delivery-time/delivery-time.js +1 -1
- package/dist/exports.d.ts +10 -2
- package/dist/forms/checkbox/checkbox.d.ts +2 -1
- package/dist/forms/checkbox/checkbox.js +2 -2
- package/dist/forms/field-error/field-error.d.ts +2 -1
- package/dist/forms/field-error/field-error.js +3 -2
- package/dist/forms/input/input.d.ts +1 -0
- package/dist/forms/input/input.js +2 -2
- package/dist/forms/label/label.d.ts +3 -1
- package/dist/forms/label/label.js +3 -2
- package/dist/forms/switch/switch.d.ts +2 -1
- package/dist/forms/switch/switch.js +2 -2
- package/dist/forms/text-field/text-field.d.ts +3 -1
- package/dist/forms/text-field/text-field.js +4 -3
- package/dist/forms/text-field/text-field.module.css.js +1 -1
- package/dist/forms/textarea/textarea.d.ts +1 -0
- package/dist/forms/textarea/textarea.js +3 -2
- package/dist/global-search/plugins/categories-plugin.js +2 -1
- package/dist/global-search/plugins/popular-categories-plugin.js +2 -0
- package/dist/global-search/plugins/query-suggestions-plugin.js +1 -0
- package/dist/global-search/plugins/quick-access-plugin.js +2 -2
- package/dist/global-search/search-result-panel/sections/with-results.js +0 -1
- package/dist/header/hamburger-button/hamburger-button.d.ts +6 -0
- package/dist/header/hamburger-button/hamburger-button.js +14 -0
- package/dist/header/hamburger-button/hamburger-button.module.css.js +3 -0
- package/dist/header/header-layout/header-layout.d.ts +9 -0
- package/dist/header/header-layout/header-layout.js +8 -0
- package/dist/header/header-layout/header-layout.module.css.js +3 -0
- package/dist/header/sonic-logo/sonic-logo.d.ts +5 -0
- package/dist/header/sonic-logo/sonic-logo.js +11 -0
- package/dist/header/sonic-logo/sonic-logo.module.css.js +3 -0
- package/dist/index.js +11 -3
- package/dist/info-icon-tooltip/info-icon-tooltip.d.ts +7 -0
- package/dist/info-icon-tooltip/info-icon-tooltip.js +20 -0
- package/dist/info-icon-tooltip/info-icon-tooltip.module.css.js +3 -0
- package/dist/intl/translation-id.d.ts +1 -1
- package/dist/pages/checkout/components/billing-and-invoice-information.js +1 -1
- package/dist/pages/checkout/order-confirmation-page/order-confirmation-page-content.d.ts +5 -0
- package/dist/pages/checkout/order-confirmation-page/order-confirmation-page-content.js +83 -0
- package/dist/pages/checkout/order-confirmation-page/order-confirmation-page.js +3 -77
- package/dist/pages/checkout/payment-page/components/payment.js +49 -4
- package/dist/pages/checkout/payment-page/payment-page-content.d.ts +15 -0
- package/dist/pages/checkout/payment-page/payment-page-content.js +43 -0
- package/dist/pages/checkout/payment-page/payment-page.js +3 -37
- package/dist/pages/checkout/shipping-page/components/edit-address.js +3 -3
- package/dist/pages/checkout/shipping-page/components/readonly-address.js +25 -1
- package/dist/pages/checkout/shipping-page/shipping-page-content.d.ts +14 -0
- package/dist/pages/checkout/shipping-page/shipping-page-content.js +40 -0
- package/dist/pages/checkout/shipping-page/shipping-page.js +45 -54
- package/dist/pages/product/product-details-page/components/product-details-panel/product-details-panel.js +11 -1
- package/dist/pages/product/product-listing-page/product-listing-product-overview/product-listing-product-overview.js +0 -1
- package/dist/pages/product/search-result-page/search-result-product-overview/search-result-product-overview.js +0 -1
- package/dist/shared/fetch/request.d.ts +18 -13
- package/dist/shared/fetch/request.js +22 -9
- package/dist/shared/ga/use-data-layer.d.ts +7 -3
- package/dist/shared/ga/use-data-layer.js +6 -1
- package/dist/shared/utils/promise.d.ts +2 -0
- package/dist/shared/utils/promise.js +9 -0
- package/dist/sign-in-form/sign-in-form.d.ts +19 -0
- package/dist/sign-in-form/sign-in-form.js +49 -0
- package/dist/sign-in-form/sign-in-form.module.css.js +3 -0
- package/dist/styles.css +338 -44
- package/dist/tooltip/tooltip.d.ts +3 -2
- package/dist/tooltip/tooltip.js +5 -4
- package/package.json +1 -1
- package/dist/shared/utils/wait.d.ts +0 -1
- package/dist/shared/utils/wait.js +0 -5
- /package/dist/algolia/{algolia-intialization.d.ts → algolia-initialization.d.ts} +0 -0
|
@@ -49,10 +49,10 @@ export declare class InternalServerErrorRequestError extends RequestError {
|
|
|
49
49
|
constructor(responseOrError: Response | unknown, options?: RequestErrorOptions);
|
|
50
50
|
}
|
|
51
51
|
export type RequestHeaders = Record<string, string | null | undefined>;
|
|
52
|
-
type RequestHeadersWithBody = RequestHeaders & {
|
|
52
|
+
export type RequestHeadersWithBody = RequestHeaders & {
|
|
53
53
|
'Content-Type': string;
|
|
54
54
|
};
|
|
55
|
-
interface BaseRequestOptions {
|
|
55
|
+
export interface BaseRequestOptions {
|
|
56
56
|
cache?: RequestCache;
|
|
57
57
|
credentials?: RequestCredentials;
|
|
58
58
|
headers?: RequestHeaders;
|
|
@@ -65,38 +65,43 @@ interface BaseRequestOptions {
|
|
|
65
65
|
timeout?: number;
|
|
66
66
|
url: string;
|
|
67
67
|
}
|
|
68
|
-
interface RequestOptionsWithFormData extends BaseRequestOptions {
|
|
68
|
+
export interface RequestOptionsWithFormData extends BaseRequestOptions {
|
|
69
69
|
body: FormData;
|
|
70
70
|
headers: RequestHeaders;
|
|
71
71
|
}
|
|
72
|
-
interface RequestOptionsWithBody extends BaseRequestOptions {
|
|
72
|
+
export interface RequestOptionsWithBody extends BaseRequestOptions {
|
|
73
73
|
body: unknown;
|
|
74
74
|
headers: RequestHeadersWithBody;
|
|
75
75
|
}
|
|
76
|
-
interface RequestOptionsWithoutBody extends BaseRequestOptions {
|
|
76
|
+
export interface RequestOptionsWithoutBody extends BaseRequestOptions {
|
|
77
77
|
body?: never;
|
|
78
78
|
headers?: RequestHeaders;
|
|
79
79
|
}
|
|
80
|
-
type RequestOptions = RequestOptionsWithBody | RequestOptionsWithoutBody | RequestOptionsWithFormData;
|
|
81
|
-
type
|
|
80
|
+
export type RequestOptions = RequestOptionsWithBody | RequestOptionsWithoutBody | RequestOptionsWithFormData;
|
|
81
|
+
type BeforeRequestHandler = (options?: RequestOptions) => RequestOptions | void;
|
|
82
|
+
type BeforeRequestHandlerAsync = (options?: RequestOptions) => Promise<RequestOptions | void>;
|
|
83
|
+
export interface AfterRequestHandlerArgs<T> {
|
|
82
84
|
body: T | undefined;
|
|
83
85
|
error?: RequestError;
|
|
84
86
|
options: RequestOptions;
|
|
85
87
|
response?: Response;
|
|
86
|
-
}
|
|
87
|
-
type
|
|
88
|
-
type
|
|
88
|
+
}
|
|
89
|
+
export type AfterRequestHandler<T> = (args: AfterRequestHandlerArgs<T>) => void;
|
|
90
|
+
export type AfterRequestHandlerAsync<T> = (args: AfterRequestHandlerArgs<T>) => Promise<void>;
|
|
91
|
+
export declare const isJsonBody: (options: RequestOptions) => boolean;
|
|
92
|
+
export declare const isFormData: (body: unknown) => body is FormData;
|
|
93
|
+
export type RequestReturnType<T> = Promise<{
|
|
89
94
|
body: T;
|
|
90
95
|
headers: Headers;
|
|
91
96
|
status: number;
|
|
92
97
|
statusText: string;
|
|
93
98
|
}>;
|
|
94
|
-
interface Request {
|
|
99
|
+
export interface Request {
|
|
95
100
|
<T>(options: RequestOptions): RequestReturnType<T>;
|
|
96
|
-
_afterHandlers: AfterRequestHandler<any>[];
|
|
97
|
-
_beforeHandlers: BeforeRequestHandler[];
|
|
98
101
|
after<T = any>(handler: AfterRequestHandler<T>): void;
|
|
102
|
+
after<T = any>(handler: AfterRequestHandlerAsync<T>): void;
|
|
99
103
|
before(handler: BeforeRequestHandler): void;
|
|
104
|
+
before(handler: BeforeRequestHandlerAsync): void;
|
|
100
105
|
headers: Omit<RequestHeaders, 'Content-Type'>;
|
|
101
106
|
}
|
|
102
107
|
export declare const request: Request;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import qs from 'query-string';
|
|
2
|
+
import { isPromise } from '../utils/promise.js';
|
|
2
3
|
|
|
3
4
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4
5
|
const isResponse = (response) => Boolean(response?.json);
|
|
@@ -181,17 +182,20 @@ const createBody = (options) => {
|
|
|
181
182
|
throw new Error(`request: Unknown body type for request ${url}. Unable to send request.`);
|
|
182
183
|
};
|
|
183
184
|
const createHeaders = (...headers) => {
|
|
184
|
-
const allHeaders =
|
|
185
|
+
const allHeaders = new Headers();
|
|
185
186
|
for (const header of headers) {
|
|
186
187
|
if (!header)
|
|
187
188
|
continue;
|
|
188
189
|
for (const key of Object.keys(header)) {
|
|
189
190
|
if (header[key])
|
|
190
|
-
allHeaders
|
|
191
|
+
allHeaders.append(key, String(header[key]));
|
|
191
192
|
}
|
|
192
193
|
}
|
|
193
194
|
return allHeaders;
|
|
194
195
|
};
|
|
196
|
+
const beforeHandlers = [];
|
|
197
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
198
|
+
const afterHandlers = [];
|
|
195
199
|
/* Because of a bug in the rollup dts package the following code must be put inside of a IIFE.
|
|
196
200
|
* The bug occurs when assigning properties to the request function at the top level of this file.
|
|
197
201
|
* request.headers = {}
|
|
@@ -204,7 +208,12 @@ const request = (function createRequestFunction() {
|
|
|
204
208
|
let error;
|
|
205
209
|
let isTimeout = false;
|
|
206
210
|
try {
|
|
207
|
-
|
|
211
|
+
for await (const handler of beforeHandlers) {
|
|
212
|
+
const promiseOrOptions = handler(options);
|
|
213
|
+
options = isPromise(promiseOrOptions)
|
|
214
|
+
? (await promiseOrOptions) || options
|
|
215
|
+
: promiseOrOptions || options;
|
|
216
|
+
}
|
|
208
217
|
options.timeout = options.timeout || 1000 * 60 * 2;
|
|
209
218
|
const url = qs.stringifyUrl({ query: options.params, url: options.url });
|
|
210
219
|
const controller = new AbortController();
|
|
@@ -245,19 +254,23 @@ const request = (function createRequestFunction() {
|
|
|
245
254
|
throw error;
|
|
246
255
|
}
|
|
247
256
|
finally {
|
|
248
|
-
|
|
257
|
+
for await (const handler of afterHandlers) {
|
|
258
|
+
const promiseOrVoid = handler({ body, error, options, response });
|
|
259
|
+
if (isPromise(promiseOrVoid))
|
|
260
|
+
await promiseOrVoid;
|
|
261
|
+
}
|
|
249
262
|
}
|
|
250
263
|
};
|
|
251
264
|
request.headers = {};
|
|
252
|
-
request._afterHandlers = [];
|
|
253
|
-
request._beforeHandlers = [];
|
|
254
265
|
request.after = (handler) => {
|
|
255
|
-
|
|
266
|
+
afterHandlers.push(
|
|
267
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
268
|
+
handler);
|
|
256
269
|
};
|
|
257
270
|
request.before = (handler) => {
|
|
258
|
-
|
|
271
|
+
beforeHandlers.push(handler);
|
|
259
272
|
};
|
|
260
273
|
return request;
|
|
261
274
|
})();
|
|
262
275
|
|
|
263
|
-
export { BadRequestError, ForbiddenRequestError, InternalServerErrorRequestError, NotFoundRequestError, RequestError, TimeoutRequestError, UnauthorizedRequestError, UnprocessableContentRequestError, isRequestError, request };
|
|
276
|
+
export { BadRequestError, ForbiddenRequestError, InternalServerErrorRequestError, NotFoundRequestError, RequestError, TimeoutRequestError, UnauthorizedRequestError, UnprocessableContentRequestError, isFormData, isJsonBody, isRequestError, request };
|
|
@@ -8,9 +8,13 @@ interface GAProductModel {
|
|
|
8
8
|
unitListPriceDisplay: string;
|
|
9
9
|
}
|
|
10
10
|
interface GACartModel {
|
|
11
|
-
cartLines
|
|
11
|
+
cartLines?: CartModel['cartLines'];
|
|
12
12
|
currencySymbol: string;
|
|
13
|
+
orderGrandTotal: number;
|
|
13
14
|
orderSubTotal: number;
|
|
15
|
+
shippingAndHandling: number;
|
|
16
|
+
totalTax: number;
|
|
17
|
+
trackId: string;
|
|
14
18
|
}
|
|
15
19
|
interface GACartLineModel {
|
|
16
20
|
erpNumber: string;
|
|
@@ -26,12 +30,12 @@ interface CreateEcommerceEventArgsWithCartLine {
|
|
|
26
30
|
event: GAEcommerceEvent;
|
|
27
31
|
}
|
|
28
32
|
interface CreateEcommerceEventArgsWithCart {
|
|
33
|
+
cart: GACartModel;
|
|
29
34
|
event: GAEcommerceEvent;
|
|
30
|
-
product: GAProductModel;
|
|
31
35
|
}
|
|
32
36
|
interface CreateEcommerceEventArgsWithProduct {
|
|
33
|
-
cart: GACartModel;
|
|
34
37
|
event: GAEcommerceEvent;
|
|
38
|
+
product: GAProductModel;
|
|
35
39
|
}
|
|
36
40
|
interface CreateEcommerceEvent {
|
|
37
41
|
(args: CreateEcommerceEventArgsWithCart): GAEcommerceEvent;
|
|
@@ -12,7 +12,8 @@ function useDataLayer(eventOrArgs) {
|
|
|
12
12
|
...event,
|
|
13
13
|
ecommerce: {
|
|
14
14
|
...event.ecommerce,
|
|
15
|
-
currency: event.ecommerce?.currency ??
|
|
15
|
+
currency: event.ecommerce?.currency ??
|
|
16
|
+
currencySymbolToISO[cart.currencySymbol],
|
|
16
17
|
customer: event.ecommerce?.customer ?? customerNumber,
|
|
17
18
|
items: cart.cartLines?.map(cartLine => ({
|
|
18
19
|
item_id: cartLine.erpNumber,
|
|
@@ -20,6 +21,10 @@ function useDataLayer(eventOrArgs) {
|
|
|
20
21
|
price: cartLine.pricing?.unitNetPrice,
|
|
21
22
|
quantity: cartLine.qtyOrdered ?? 0,
|
|
22
23
|
})) ?? [],
|
|
24
|
+
shipping: cart.shippingAndHandling,
|
|
25
|
+
tax: cart.totalTax,
|
|
26
|
+
transaction_id: cart.trackId,
|
|
27
|
+
value: cart.orderGrandTotal,
|
|
23
28
|
},
|
|
24
29
|
value: event.value ?? cart.orderSubTotal ?? 0,
|
|
25
30
|
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
function wait(ms) {
|
|
2
|
+
return new Promise(resolve => setTimeout(resolve, ms));
|
|
3
|
+
}
|
|
4
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5
|
+
function isPromise(value) {
|
|
6
|
+
return value && typeof value.then === 'function';
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export { isPromise, wait };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
interface LoginData {
|
|
2
|
+
email: string;
|
|
3
|
+
guestSignin: false;
|
|
4
|
+
password: string;
|
|
5
|
+
remember?: boolean;
|
|
6
|
+
}
|
|
7
|
+
interface GuestLoginData {
|
|
8
|
+
guestSignin: true;
|
|
9
|
+
}
|
|
10
|
+
export interface SignInFormProps {
|
|
11
|
+
allowGuestSignIn?: boolean;
|
|
12
|
+
initialEmail?: string;
|
|
13
|
+
initialRemember?: boolean;
|
|
14
|
+
onSubmit?: ({ data }: {
|
|
15
|
+
data: LoginData | GuestLoginData;
|
|
16
|
+
}) => void;
|
|
17
|
+
}
|
|
18
|
+
export declare function SignInForm({ allowGuestSignIn, initialEmail, initialRemember, onSubmit, }: SignInFormProps): import("react/jsx-runtime").JSX.Element;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { Form } from 'react-aria-components';
|
|
4
|
+
import clsx from 'clsx';
|
|
5
|
+
import { Button } from '../buttons/button/button.js';
|
|
6
|
+
import { Link } from '../buttons/link/link.js';
|
|
7
|
+
import { Switch } from '../forms/switch/switch.js';
|
|
8
|
+
import { TextField } from '../forms/text-field/text-field.js';
|
|
9
|
+
import { useFormattedMessage } from '../intl/use-formatted-message.js';
|
|
10
|
+
import { Heading } from '../typography/heading/heading.js';
|
|
11
|
+
import styles from './sign-in-form.module.css.js';
|
|
12
|
+
|
|
13
|
+
const GUEST_SIGN_IN_BUTTON_NAME = 'guestSignin';
|
|
14
|
+
function SignInForm({ allowGuestSignIn = false, initialEmail, initialRemember, onSubmit = () => { }, }) {
|
|
15
|
+
const t = useFormattedMessage();
|
|
16
|
+
const handleSubmit = (event) => {
|
|
17
|
+
event.preventDefault();
|
|
18
|
+
const form = event.currentTarget;
|
|
19
|
+
const formData = new FormData(form);
|
|
20
|
+
// in case of guest sign-in submit
|
|
21
|
+
const submitter = event.nativeEvent.submitter;
|
|
22
|
+
if (submitter?.name === GUEST_SIGN_IN_BUTTON_NAME) {
|
|
23
|
+
return onSubmit({
|
|
24
|
+
data: {
|
|
25
|
+
guestSignin: true,
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
// regular sign-in
|
|
30
|
+
const email = formData.get('email')?.toString();
|
|
31
|
+
const password = formData.get('password')?.toString();
|
|
32
|
+
const remember = Boolean(formData.get('remember'));
|
|
33
|
+
if (!email)
|
|
34
|
+
throw new Error('Email value is required');
|
|
35
|
+
if (!password)
|
|
36
|
+
throw new Error('Password value is required');
|
|
37
|
+
onSubmit({
|
|
38
|
+
data: {
|
|
39
|
+
email,
|
|
40
|
+
guestSignin: false,
|
|
41
|
+
password,
|
|
42
|
+
remember,
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
return (jsxs(Form, { "aria-label": t('sign in'), autoComplete: "off", className: clsx(styles['sign-in-form'], styles['form']), onSubmit: handleSubmit, validationBehavior: "native", children: [jsx("header", { className: styles['form-header'], children: jsx(Heading, { "data-test-selector": "PageTitle", italic: true, size: "m", tag: "h1", uppercase: true, children: t('sign in') }) }), jsxs("fieldset", { className: clsx(styles['form-fieldset'], styles['columns']), children: [jsx("div", { className: styles['form-segment'], children: jsx(TextField, { "data-test-selector": "signIn_userName", defaultValue: initialEmail, isRequired: true, label: t('Email'), name: "email", showLabel: true, type: "email" }) }), jsx("div", { className: styles['form-segment'], children: jsx(TextField, { "data-test-selector": "signIn_password", isRequired: true, label: t('Password'), name: "password", showLabel: true, type: "password" }) })] }), jsxs("footer", { className: styles['form-footer'], children: [jsx("div", { className: styles['form-segment'], children: jsx(Switch, { className: styles['floating'], defaultSelected: initialRemember, name: "remember", value: "true", children: t('Remember me') }) }), jsx("div", { className: styles['form-segment'], children: jsx(Button, { "data-test-selector": "signIn_submit", type: "submit", withArrow: true, children: t('sign in') }) }), jsxs("div", { className: styles['form-segment'], children: [jsx("p", { children: jsx(Link, { "data-test-selector": "signIn_forgotPassword", hasUnderline: true, href: "#", children: t('Forgot password?') }) }), jsxs("p", { children: [t('New user?'), ' ', jsx(Link, { "data-test-selector": "signInCreateNewAccount_createNewAccount", hasUnderline: true, href: "#", children: t('create account') })] })] }), allowGuestSignIn && (jsx("div", { className: styles['form-segment'], children: jsx(Button, { color: "secondary", isValidating: false, name: GUEST_SIGN_IN_BUTTON_NAME, type: "submit", value: "true", variant: "outline", children: t('Or sign in as guest') }) }))] })] }));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export { SignInForm };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
var styles = {"sign-in-form":"sign-in-form-module-4DkkP","form":"sign-in-form-module-bGXUd","form-segment":"sign-in-form-module-TumIz","floating":"sign-in-form-module-bIzyz","form-fieldset":"sign-in-form-module-EoTYu","columns":"sign-in-form-module-9eIx-","form-footer":"sign-in-form-module-aYBAy"};
|
|
2
|
+
|
|
3
|
+
export { styles as default };
|