@sonic-equipment/ui 132.0.0 → 134.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 +2 -13
- 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/add-to-cart-button/connected-add-to-cart-button.js +1 -1
- package/dist/buttons/button/button.d.ts +4 -1
- package/dist/buttons/button/button.js +3 -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 +6 -5
- package/dist/display/info-display/info-display.d.ts +7 -0
- package/dist/display/info-display/info-display.js +8 -0
- package/dist/display/info-display/info-display.module.css.js +3 -0
- package/dist/exports.d.ts +20 -7
- 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 +2 -0
- package/dist/forms/input/input.js +5 -3
- package/dist/forms/input/input.module.css.js +1 -1
- package/dist/forms/label/label.d.ts +3 -1
- package/dist/forms/label/label.js +3 -2
- package/dist/forms/switch/switch.d.ts +3 -1
- package/dist/forms/switch/switch.js +2 -2
- package/dist/forms/text-field/password-reveal-toggle/password-reveal-toggle.d.ts +10 -0
- package/dist/forms/text-field/password-reveal-toggle/password-reveal-toggle.js +18 -0
- package/dist/forms/text-field/password-reveal-toggle/password-reveal-toggle.module.css.js +3 -0
- package/dist/forms/text-field/text-field.d.ts +5 -3
- package/dist/forms/text-field/text-field.js +11 -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/icons/stroke/stroke-dehashed-icon.js +7 -0
- package/dist/icons/stroke/stroke-hashed-icon.js +7 -0
- package/dist/index.js +22 -9
- 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/cart-page/cart-page.js +6 -9
- package/dist/pages/checkout/cart-page/components/empty-cart-page.d.ts +1 -0
- package/dist/pages/checkout/cart-page/components/empty-cart-page.js +11 -0
- package/dist/pages/checkout/components/billing-and-invoice-information.d.ts +7 -0
- package/dist/pages/checkout/components/billing-and-invoice-information.js +12 -0
- package/dist/pages/checkout/components/billing-and-invoice-information.module.css.js +3 -0
- package/dist/pages/checkout/constants.d.ts +8 -0
- package/dist/pages/checkout/constants.js +10 -0
- package/dist/pages/checkout/layouts/checkout-page-layout/components/checkout-page-section.module.css.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.d.ts +4 -0
- package/dist/pages/checkout/order-confirmation-page/order-confirmation-page.js +41 -0
- package/dist/pages/checkout/order-confirmation-page/order-confirmation-page.module.css.js +3 -0
- package/dist/{checkout → pages/checkout/payment-page/components}/adyen-payment.js +5 -5
- package/dist/pages/checkout/payment-page/components/adyen-payment.module.css.js +3 -0
- package/dist/{checkout → pages/checkout/payment-page/components}/payment.d.ts +4 -2
- package/dist/pages/checkout/payment-page/components/payment.js +288 -0
- package/dist/pages/checkout/payment-page/components/payment.module.css.js +3 -0
- 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 +13 -41
- package/dist/{checkout → pages/checkout/payment-page/utils}/parse-amount.js +1 -1
- package/dist/pages/checkout/shipping-page/components/edit-address.js +11 -7
- package/dist/pages/checkout/shipping-page/hooks/use-patch-shipping-details.d.ts +12 -0
- package/dist/pages/checkout/shipping-page/hooks/use-patch-shipping-details.js +21 -0
- 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 +55 -78
- package/dist/pages/checkout/shipping-page/shipping-page.module.css.js +1 -1
- package/dist/pages/components/page/page.d.ts +3 -2
- package/dist/pages/components/page/page.js +3 -2
- package/dist/pages/components/page-meta-data/page-meta-data.d.ts +3 -4
- package/dist/pages/components/page-meta-data/page-meta-data.js +2 -2
- package/dist/pages/product/product-details-page/components/product-details-panel/product-details-panel.js +11 -1
- package/dist/pages/product/product-details-page/product-details-page.js +2 -10
- package/dist/pages/product/product-details-page/product-details.js +10 -4
- package/dist/pages/product/product-listing-page/product-listing-page-data-types.d.ts +1 -1
- package/dist/pages/product/product-listing-page/product-listing-page.js +2 -10
- package/dist/pages/product/product-listing-page/product-listing-product-overview/product-listing-product-overview.js +0 -1
- package/dist/pages/product/product-listing-page/product-listing.js +8 -1
- package/dist/pages/product/search-result-page/search-result-product-overview/search-result-product-overview.js +0 -1
- package/dist/pages/product/search-result-page/search-results-page.js +4 -7
- package/dist/shared/api/bff/model/bff.model.d.ts +4 -4
- package/dist/shared/api/bff/services/bff-service.js +1 -4
- package/dist/shared/api/storefront/hooks/cart/use-fetch-cart-by-id.d.ts +8 -0
- package/dist/shared/api/storefront/hooks/cart/use-fetch-cart-by-id.js +20 -0
- package/dist/shared/api/storefront/hooks/cart/use-fetch-current-cart-count.d.ts +1 -1
- package/dist/shared/api/storefront/hooks/cart/use-fetch-current-cart-count.js +3 -3
- package/dist/shared/api/storefront/hooks/cart/use-fetch-current-cart.d.ts +2 -5
- package/dist/shared/api/storefront/hooks/cart/use-fetch-current-cart.js +3 -16
- package/dist/shared/api/storefront/hooks/cart/use-patch-cart.js +11 -8
- package/dist/shared/api/storefront/hooks/cart/use-place-order.js +2 -2
- 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/model/address.d.ts +13 -0
- package/dist/shared/providers/react-query-container.d.ts +2 -1
- package/dist/shared/providers/react-query-container.js +2 -2
- package/dist/shared/utils/date.d.ts +2 -0
- package/dist/shared/utils/date.js +11 -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 +532 -314
- package/dist/tooltip/tooltip.d.ts +3 -2
- package/dist/tooltip/tooltip.js +12 -6
- package/package.json +1 -1
- package/dist/checkout/adyen-payment.module.css.js +0 -3
- package/dist/checkout/payment.js +0 -213
- package/dist/checkout/payment.module.css.js +0 -3
- 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
- /package/dist/{checkout → pages/checkout/payment-page/components}/adyen-payment.d.ts +0 -0
- /package/dist/{checkout → pages/checkout/payment-page/hooks}/use-get-adyen-redirect-result.d.ts +0 -0
- /package/dist/{checkout → pages/checkout/payment-page/hooks}/use-get-adyen-redirect-result.js +0 -0
- /package/dist/{checkout → pages/checkout/payment-page/hooks}/use-has-returned-from-adyen.d.ts +0 -0
- /package/dist/{checkout → pages/checkout/payment-page/hooks}/use-has-returned-from-adyen.js +0 -0
- /package/dist/{checkout → pages/checkout/payment-page/utils}/parse-amount.d.ts +0 -0
|
@@ -1,14 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
address2?: string;
|
|
4
|
-
address3?: string;
|
|
5
|
-
city?: string;
|
|
6
|
-
companyName?: string;
|
|
7
|
-
country?: string;
|
|
8
|
-
email?: string;
|
|
9
|
-
firstName?: string;
|
|
10
|
-
lastName?: string;
|
|
11
|
-
phone?: string;
|
|
12
|
-
postalCode?: string;
|
|
13
|
-
}
|
|
1
|
+
import { AddressType } from '../shared/model/address';
|
|
2
|
+
export type AddressProps = AddressType;
|
|
14
3
|
export declare function Address({ address1, address2, address3, city, companyName, country, email, firstName, lastName, phone, postalCode, }: AddressProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { config } from '../config.js';
|
|
3
3
|
import Cookies from 'js-cookie';
|
|
4
4
|
import aa from 'search-insights';
|
|
5
|
+
import { request } from '../shared/fetch/request.js';
|
|
5
6
|
import { createUUID } from '../shared/utils/uuid.js';
|
|
6
7
|
|
|
7
8
|
let userToken = generateUserToken();
|
|
@@ -19,6 +20,12 @@ aa('getUserToken', {}, (err, value) => {
|
|
|
19
20
|
aa('onUserTokenChange', value => {
|
|
20
21
|
userToken = value === undefined ? generateUserToken() : String(value);
|
|
21
22
|
});
|
|
23
|
+
request.after(({ body, options: { url } }) => {
|
|
24
|
+
if (url.toLocaleLowerCase().includes('/api/v1/sessions/current')) {
|
|
25
|
+
const userToken = body?.userProfileId || generateUserToken();
|
|
26
|
+
aa('setUserToken', userToken);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
22
29
|
function generateUserToken() {
|
|
23
30
|
return `anonymous-${createUUID()}`;
|
|
24
31
|
}
|
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx } from 'react/jsx-runtime';
|
|
3
3
|
import { createContext, useContext } from 'react';
|
|
4
|
+
import { useCultureCode } from '../intl/use-culture-code.js';
|
|
5
|
+
import { getLanguageCodeFromCultureCode } from '../intl/utils.js';
|
|
6
|
+
import { environment } from '../shared/utils/environment.js';
|
|
7
|
+
import { getAlgoliaIndex } from './algolia-index-config.js';
|
|
4
8
|
import { useAlgoliaInsightsGlobalState } from './use-algolia-insights-provider-global-state.js';
|
|
5
9
|
|
|
6
10
|
const AlgoliaInsightsProviderContext = createContext({});
|
|
7
11
|
function AlgoliaInsightsProvider({ children, value, }) {
|
|
12
|
+
const cultureCode = useCultureCode();
|
|
13
|
+
const algoliaIndex = getAlgoliaIndex(environment, getLanguageCodeFromCultureCode(cultureCode));
|
|
8
14
|
const [globalState] = useAlgoliaInsightsGlobalState();
|
|
9
15
|
const context = useContext(AlgoliaInsightsProviderContext);
|
|
10
16
|
const combinedValue = {
|
|
17
|
+
index: algoliaIndex.default,
|
|
11
18
|
...globalState,
|
|
12
19
|
...context,
|
|
13
20
|
...value,
|
|
@@ -11,6 +11,7 @@ import { querySuggestionsPlugin } from '../global-search/plugins/query-suggestio
|
|
|
11
11
|
import { quickAccessPlugin } from '../global-search/plugins/quick-access-plugin.js';
|
|
12
12
|
import { recentSearchesPlugin } from '../global-search/plugins/recent-searches-plugin.js';
|
|
13
13
|
import { useLanguageCode } from '../intl/use-language-code.js';
|
|
14
|
+
import { useDataLayer } from '../shared/ga/use-data-layer.js';
|
|
14
15
|
import { useDebouncedCallback } from '../shared/hooks/use-debounced-callback.js';
|
|
15
16
|
import { environment } from '../shared/utils/environment.js';
|
|
16
17
|
import { getAlgoliaIndex } from './algolia-index-config.js';
|
|
@@ -19,6 +20,7 @@ import { createSonicSearchClient } from './algolia-sonic-searchclient.js';
|
|
|
19
20
|
|
|
20
21
|
const GlobalSearchContext = createContext(null);
|
|
21
22
|
function AlgoliaSearchProvider({ children, searchClient: _searchClient, }) {
|
|
23
|
+
const { dataLayer } = useDataLayer();
|
|
22
24
|
const [state, setState] = useState({
|
|
23
25
|
activeItemId: null,
|
|
24
26
|
collections: [],
|
|
@@ -42,6 +44,9 @@ function AlgoliaSearchProvider({ children, searchClient: _searchClient, }) {
|
|
|
42
44
|
return [
|
|
43
45
|
{
|
|
44
46
|
getItems() {
|
|
47
|
+
if (!query) {
|
|
48
|
+
return [];
|
|
49
|
+
}
|
|
45
50
|
return getAlgoliaResults({
|
|
46
51
|
queries: [
|
|
47
52
|
{
|
|
@@ -53,6 +58,20 @@ function AlgoliaSearchProvider({ children, searchClient: _searchClient, }) {
|
|
|
53
58
|
},
|
|
54
59
|
],
|
|
55
60
|
searchClient,
|
|
61
|
+
transformResponse({ hits, results }) {
|
|
62
|
+
dataLayer.push({
|
|
63
|
+
brands_numSearchResults: null,
|
|
64
|
+
categories_numSearchResults: null,
|
|
65
|
+
content_numSearchResults: null,
|
|
66
|
+
correctedQuery: undefined,
|
|
67
|
+
event: 'searchResults',
|
|
68
|
+
numSearchResults: results[0].nbHits,
|
|
69
|
+
product_numSearchResults: null,
|
|
70
|
+
searchQuery: query,
|
|
71
|
+
searchTerm: null,
|
|
72
|
+
});
|
|
73
|
+
return hits;
|
|
74
|
+
},
|
|
56
75
|
});
|
|
57
76
|
},
|
|
58
77
|
sourceId: 'productsPlugin',
|
|
@@ -1,19 +1,23 @@
|
|
|
1
|
-
import { CartLineModel } from '../shared/api/storefront/model/storefront.model';
|
|
1
|
+
import { CartLineModel, CartModel } from '../shared/api/storefront/model/storefront.model';
|
|
2
2
|
import { AlgoliaInsightsProviderGlobalState } from './use-algolia-insights-provider-global-state';
|
|
3
3
|
export interface UseAlgoliaEventResult {
|
|
4
4
|
context: Readonly<AlgoliaInsightsProviderGlobalState>;
|
|
5
|
-
|
|
5
|
+
sendAddToCartFromProductDetailsPageEvent({ cartLine, }: {
|
|
6
6
|
cartLine: CartLineModel;
|
|
7
|
-
objectId: string;
|
|
8
7
|
}): void;
|
|
9
|
-
|
|
8
|
+
sendAddToCartFromProductListPageEvent({ cartLine, }: {
|
|
9
|
+
cartLine: CartLineModel;
|
|
10
|
+
}): void;
|
|
11
|
+
sendAddToCartFromSearchEvent({ cartLine, queryId, }: {
|
|
10
12
|
cartLine: CartLineModel;
|
|
11
|
-
objectId: string;
|
|
12
13
|
queryId: string;
|
|
13
14
|
}): void;
|
|
14
|
-
sendAddToCartFromSearchResultPageEvent({ cartLine,
|
|
15
|
+
sendAddToCartFromSearchResultPageEvent({ cartLine, }: {
|
|
15
16
|
cartLine: CartLineModel;
|
|
17
|
+
}): void;
|
|
18
|
+
sendAddToWishListFromProductDetailsPageEvent({ objectId, position, }: {
|
|
16
19
|
objectId: string;
|
|
20
|
+
position?: number;
|
|
17
21
|
}): void;
|
|
18
22
|
sendAddToWishListFromProductListPageEvent({ objectId, position, }: {
|
|
19
23
|
objectId: string;
|
|
@@ -41,5 +45,8 @@ export interface UseAlgoliaEventResult {
|
|
|
41
45
|
objectId: string;
|
|
42
46
|
position: number;
|
|
43
47
|
}): void;
|
|
48
|
+
sendPurchaseEventFromPaymentPage({ cart }: {
|
|
49
|
+
cart: CartModel;
|
|
50
|
+
}): void;
|
|
44
51
|
}
|
|
45
52
|
export declare function useAlgoliaInsights(): UseAlgoliaEventResult;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { useContext } from 'react';
|
|
2
|
+
import { useContext, useMemo } from 'react';
|
|
3
3
|
import aa from 'search-insights';
|
|
4
4
|
import { currencySymbolToISO } from '../shared/model/currency.js';
|
|
5
5
|
import { ensureArray } from '../shared/utils/array.js';
|
|
6
|
+
import { userToken } from './algolia-initialization.js';
|
|
6
7
|
import { AlgoliaInsightsProviderContext } from './algolia-insights-provider.js';
|
|
7
|
-
import { userToken } from './algolia-intialization.js';
|
|
8
8
|
import { useAlgoliaInsightsGlobalState } from './use-algolia-insights-provider-global-state.js';
|
|
9
9
|
|
|
10
10
|
function getCurrencyFromPriceString(priceString) {
|
|
@@ -14,9 +14,46 @@ function getCurrencyFromPriceString(priceString) {
|
|
|
14
14
|
function useAlgoliaInsights() {
|
|
15
15
|
const context = useContext(AlgoliaInsightsProviderContext);
|
|
16
16
|
const [, setGlobalState] = useAlgoliaInsightsGlobalState();
|
|
17
|
-
|
|
17
|
+
const result = useMemo(() => ({
|
|
18
18
|
context,
|
|
19
|
-
|
|
19
|
+
sendAddToCartFromProductDetailsPageEvent({ cartLine }) {
|
|
20
|
+
if (!context.index)
|
|
21
|
+
return console.warn('Unable to send clickedObjectIDsAfterSearch event, no index', context);
|
|
22
|
+
if (context.queryId) {
|
|
23
|
+
aa('addedToCartObjectIDsAfterSearch', {
|
|
24
|
+
currency: getCurrencyFromPriceString(cartLine.pricing?.actualPriceDisplay),
|
|
25
|
+
eventName: 'PDP: AddToCart Clicked',
|
|
26
|
+
index: context.index,
|
|
27
|
+
objectData: [
|
|
28
|
+
{
|
|
29
|
+
price: cartLine.pricing?.actualPrice || undefined,
|
|
30
|
+
quantity: cartLine.qtyOrdered || undefined,
|
|
31
|
+
queryID: context.queryId,
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
objectIDs: [cartLine.erpNumber],
|
|
35
|
+
queryID: context.queryId,
|
|
36
|
+
userToken,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
aa('addedToCartObjectIDs', {
|
|
41
|
+
currency: getCurrencyFromPriceString(cartLine.pricing?.actualPriceDisplay),
|
|
42
|
+
eventName: 'PDP: AddToCart Clicked',
|
|
43
|
+
index: context.index,
|
|
44
|
+
objectData: [
|
|
45
|
+
{
|
|
46
|
+
price: cartLine.pricing?.actualPrice || undefined,
|
|
47
|
+
quantity: cartLine.qtyOrdered || undefined,
|
|
48
|
+
queryID: context.queryId,
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
objectIDs: [cartLine.erpNumber],
|
|
52
|
+
userToken,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
sendAddToCartFromProductListPageEvent({ cartLine }) {
|
|
20
57
|
if (!context.index)
|
|
21
58
|
return console.warn('Unable to send clickedObjectIDsAfterSearch event, no index', context);
|
|
22
59
|
if (!context.queryId)
|
|
@@ -32,12 +69,12 @@ function useAlgoliaInsights() {
|
|
|
32
69
|
queryID: context.queryId,
|
|
33
70
|
},
|
|
34
71
|
],
|
|
35
|
-
objectIDs: [
|
|
72
|
+
objectIDs: [cartLine.erpNumber],
|
|
36
73
|
queryID: context.queryId,
|
|
37
74
|
userToken,
|
|
38
75
|
});
|
|
39
76
|
},
|
|
40
|
-
sendAddToCartFromSearchEvent({ cartLine,
|
|
77
|
+
sendAddToCartFromSearchEvent({ cartLine, queryId }) {
|
|
41
78
|
if (!context.index)
|
|
42
79
|
return console.warn('Unable to send clickedObjectIDsAfterSearch event, no index', context);
|
|
43
80
|
aa('addedToCartObjectIDsAfterSearch', {
|
|
@@ -51,12 +88,12 @@ function useAlgoliaInsights() {
|
|
|
51
88
|
queryID: context.queryId,
|
|
52
89
|
},
|
|
53
90
|
],
|
|
54
|
-
objectIDs: [
|
|
91
|
+
objectIDs: [cartLine.erpNumber],
|
|
55
92
|
queryID: queryId,
|
|
56
93
|
userToken,
|
|
57
94
|
});
|
|
58
95
|
},
|
|
59
|
-
sendAddToCartFromSearchResultPageEvent({ cartLine
|
|
96
|
+
sendAddToCartFromSearchResultPageEvent({ cartLine }) {
|
|
60
97
|
if (!context.index)
|
|
61
98
|
return console.warn('Unable to send clickedObjectIDsAfterSearch event, no index', context);
|
|
62
99
|
if (!context.queryId)
|
|
@@ -72,11 +109,35 @@ function useAlgoliaInsights() {
|
|
|
72
109
|
queryID: context.queryId,
|
|
73
110
|
},
|
|
74
111
|
],
|
|
75
|
-
objectIDs: [
|
|
112
|
+
objectIDs: [cartLine.erpNumber],
|
|
76
113
|
queryID: context.queryId,
|
|
77
114
|
userToken,
|
|
78
115
|
});
|
|
79
116
|
},
|
|
117
|
+
sendAddToWishListFromProductDetailsPageEvent({ objectId, position }) {
|
|
118
|
+
if (!context.index)
|
|
119
|
+
return console.warn('Unable to send clickedObjectIDsAfterSearch event, no index', context);
|
|
120
|
+
if (context.queryId) {
|
|
121
|
+
if (!position)
|
|
122
|
+
return console.warn('Unable to send clickedObjectIDsAfterSearch event, no position', context, objectId);
|
|
123
|
+
aa('clickedObjectIDsAfterSearch', {
|
|
124
|
+
eventName: 'PDP: Product Added to Wishlist',
|
|
125
|
+
index: context.index,
|
|
126
|
+
objectIDs: [objectId],
|
|
127
|
+
positions: [position],
|
|
128
|
+
queryID: context.queryId,
|
|
129
|
+
userToken,
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
aa('clickedObjectIDs', {
|
|
134
|
+
eventName: 'PDP: Product Added to Wishlist',
|
|
135
|
+
index: context.index,
|
|
136
|
+
objectIDs: [objectId],
|
|
137
|
+
userToken,
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
},
|
|
80
141
|
sendAddToWishListFromProductListPageEvent({ objectId, position }) {
|
|
81
142
|
if (!context.index)
|
|
82
143
|
return console.warn('Unable to send clickedObjectIDsAfterSearch event, no index', context);
|
|
@@ -175,7 +236,29 @@ function useAlgoliaInsights() {
|
|
|
175
236
|
queryId: context.queryId,
|
|
176
237
|
});
|
|
177
238
|
},
|
|
178
|
-
|
|
239
|
+
sendPurchaseEventFromPaymentPage({ cart }) {
|
|
240
|
+
if (!context.index)
|
|
241
|
+
return console.warn('Unable to send clickedObjectIDsAfterSearch event, no index', context);
|
|
242
|
+
if (!cart.cartLines || cart.cartLines.length === 0)
|
|
243
|
+
return console.warn('Unable to send purchasedObjectIDs event, no cartLines', cart);
|
|
244
|
+
aa('purchasedObjectIDs', {
|
|
245
|
+
currency: currencySymbolToISO[cart.currencySymbol],
|
|
246
|
+
eventName: 'Purchase Successful',
|
|
247
|
+
index: context.index,
|
|
248
|
+
objectData: cart.cartLines.map(cartLine => ({
|
|
249
|
+
price: cartLine.pricing?.actualPrice || undefined,
|
|
250
|
+
quantity: cartLine.qtyOrdered || undefined,
|
|
251
|
+
queryID: context.queryId,
|
|
252
|
+
})),
|
|
253
|
+
objectIDs: cart.cartLines
|
|
254
|
+
.map(cartLine => cartLine.erpNumber)
|
|
255
|
+
.slice(0, 20),
|
|
256
|
+
userToken,
|
|
257
|
+
value: cart.orderSubTotal,
|
|
258
|
+
});
|
|
259
|
+
},
|
|
260
|
+
}), [context, setGlobalState]);
|
|
261
|
+
return result;
|
|
179
262
|
}
|
|
180
263
|
|
|
181
264
|
export { useAlgoliaInsights };
|
|
@@ -13,7 +13,7 @@ import { AddToCartButton } from './add-to-cart-button.js';
|
|
|
13
13
|
const ConnectedAddToCartButton = ({ onAddToCart, productId }) => {
|
|
14
14
|
const { createEcommerceEvent, dataLayer } = useDataLayer();
|
|
15
15
|
const { isPending: isPendingAddToCart, mutate: addToCart } = useAddProductToCurrentCart();
|
|
16
|
-
const { data: cartLines,
|
|
16
|
+
const { data: cartLines, isFetching: isLoadingCartLines } = useFetchCurrentCartLines();
|
|
17
17
|
const { isPending: isPendingDeleteCartLine, mutate: deleteCartLine } = useDeleteCartLineById();
|
|
18
18
|
const { mutate: updateCartLine } = usePatchCartLineById();
|
|
19
19
|
const { addToast } = useToast();
|
|
@@ -11,10 +11,13 @@ export interface ButtonProps {
|
|
|
11
11
|
iconPosition?: 'left' | 'right';
|
|
12
12
|
isDisabled?: boolean;
|
|
13
13
|
isLoading?: string | ReactNode | boolean;
|
|
14
|
+
isValidating?: boolean;
|
|
15
|
+
name?: string;
|
|
14
16
|
onClick?: (event: MouseEvent<HTMLButtonElement>) => void;
|
|
15
17
|
size?: 'sm' | 'md' | 'lg';
|
|
16
18
|
type?: 'button' | 'submit' | 'reset';
|
|
19
|
+
value?: string;
|
|
17
20
|
variant?: 'solid' | 'outline' | 'ghost';
|
|
18
21
|
withArrow?: boolean;
|
|
19
22
|
}
|
|
20
|
-
export declare function Button({ _pseudo, children, className, color, condensed, 'data-test-selector': dataTestSelector, form, icon, iconPosition, isDisabled, isLoading, onClick: _onClick, size, type, variant, withArrow, }: ButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
23
|
+
export declare function Button({ _pseudo, children, className, color, condensed, 'data-test-selector': dataTestSelector, form, icon, iconPosition, isDisabled, isLoading, isValidating, name, onClick: _onClick, size, type, value, variant, withArrow, }: ButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -6,9 +6,10 @@ import { ProgressCircle } from '../../loading/progress-circle.js';
|
|
|
6
6
|
import { GlyphsArrowBoldCapsRightIcon } from '../../icons/glyph/glyphs-arrow-boldcaps-right-icon.js';
|
|
7
7
|
import buttonStyles from './button.module.css.js';
|
|
8
8
|
|
|
9
|
-
function Button({ _pseudo = 'none', children, className, color = 'primary', condensed, 'data-test-selector': dataTestSelector, form, icon, iconPosition = 'left', isDisabled, isLoading = false, onClick: _onClick, size = 'lg', type = 'button', variant = 'solid', withArrow = false, }) {
|
|
9
|
+
function Button({ _pseudo = 'none', children, className, color = 'primary', condensed, 'data-test-selector': dataTestSelector, form, icon, iconPosition = 'left', isDisabled, isLoading = false, isValidating = true, name, onClick: _onClick, size = 'lg', type = 'button', value, variant = 'solid', withArrow = false, }) {
|
|
10
10
|
const showIconOnLeft = icon && iconPosition === 'left';
|
|
11
11
|
const showIconOnRight = icon && iconPosition === 'right';
|
|
12
|
+
const iconElement = icon && jsx("span", { className: buttonStyles.icon, children: icon });
|
|
12
13
|
const onClick = (e) => {
|
|
13
14
|
if (_onClick)
|
|
14
15
|
_onClick(e);
|
|
@@ -20,7 +21,7 @@ function Button({ _pseudo = 'none', children, className, color = 'primary', cond
|
|
|
20
21
|
return (jsx("button", { className: clsx({ [buttonStyles.condensed]: condensed }, { [buttonStyles.icon]: icon }, { [buttonStyles['loading-uninformative']]: isLoading === true }, {
|
|
21
22
|
[buttonStyles['loading-informative']]: isLoading &&
|
|
22
23
|
(typeof isLoading === 'string' || isValidElement(isLoading)),
|
|
23
|
-
}, buttonStyles.button, buttonStyles[variant], buttonStyles[size], buttonStyles[color], buttonStyles[_pseudo], className), "data-disabled": isDisabled ? true : undefined, "data-test-selector": dataTestSelector, disabled: isDisabled, form: form, onClick: onClick, type: type, children: jsxs(Fragment, { children: [showIconOnLeft &&
|
|
24
|
+
}, buttonStyles.button, buttonStyles[variant], buttonStyles[size], buttonStyles[color], buttonStyles[_pseudo], className), "data-disabled": isDisabled ? true : undefined, "data-test-selector": dataTestSelector, disabled: isDisabled, form: form, formNoValidate: isValidating ? undefined : true, name: name, onClick: onClick, type: type, value: value, children: jsxs(Fragment, { children: [showIconOnLeft && iconElement, jsx("span", { className: buttonStyles.children, children: isLoading ? (isLoading === true ? children : isLoading) : children }), withArrow && (jsx(GlyphsArrowBoldCapsRightIcon, { className: buttonStyles['right-arrow-icon'] })), showIconOnRight && iconElement, isLoading && (jsx(ProgressCircle, { className: buttonStyles.spinner, size: "sm", variant: color === 'primary' ? 'white' : 'gray' }))] }) }));
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
export { Button };
|
|
@@ -3,6 +3,7 @@ import { Country } from '../../shared/model/countries-languages';
|
|
|
3
3
|
interface CountrySelectProps<T extends Country | CountryModel> {
|
|
4
4
|
countries: T[];
|
|
5
5
|
'data-test-selector'?: string;
|
|
6
|
+
isDisabled?: boolean;
|
|
6
7
|
isRequired?: boolean;
|
|
7
8
|
name?: string;
|
|
8
9
|
showLabel?: boolean;
|
|
@@ -3,7 +3,7 @@ import { useMemo } from 'react';
|
|
|
3
3
|
import { Select } from '../../forms/select/select.js';
|
|
4
4
|
import { useFormattedMessage } from '../../intl/use-formatted-message.js';
|
|
5
5
|
|
|
6
|
-
function CountrySelect({ countries, 'data-test-selector': dataTestSelector, isRequired, name, onCountryChange, selectedCountry, showLabel = true, }) {
|
|
6
|
+
function CountrySelect({ countries, 'data-test-selector': dataTestSelector, isDisabled, isRequired, name, onCountryChange, selectedCountry, showLabel = true, }) {
|
|
7
7
|
const t = useFormattedMessage();
|
|
8
8
|
const countryOptions = useMemo(() => countries.reduce((acc, country) => ({
|
|
9
9
|
...acc,
|
|
@@ -11,7 +11,7 @@ function CountrySelect({ countries, 'data-test-selector': dataTestSelector, isRe
|
|
|
11
11
|
}), {}),
|
|
12
12
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
13
13
|
[countries]);
|
|
14
|
-
return (jsx(Select, { "data-test-selector": dataTestSelector, isRequired: isRequired, label: t('Country'), name: name, onChange: value => onCountryChange?.(countries.find(country => country.id === value)), options: countryOptions, selectedOption: selectedCountry?.id, showLabel: showLabel, showPlaceholder: false, variant: "solid" }));
|
|
14
|
+
return (jsx(Select, { "data-test-selector": dataTestSelector, isDisabled: isDisabled, isRequired: isRequired, label: t('Country'), name: name, onChange: value => onCountryChange?.(countries.find(country => country.id === value)), options: countryOptions, selectedOption: selectedCountry?.id, showLabel: showLabel, showPlaceholder: false, variant: "solid" }));
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
export { CountrySelect };
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
3
|
import clsx from 'clsx';
|
|
4
4
|
import { FormattedMessage } from '../intl/formatted-message.js';
|
|
5
5
|
import { useFormattedMessage } from '../intl/use-formatted-message.js';
|
|
6
6
|
import { getDateUnitObject } from '../shared/utils/date.js';
|
|
7
|
+
import { Tooltip } from '../tooltip/tooltip.js';
|
|
7
8
|
import styles from './delivery-time.module.css.js';
|
|
8
9
|
|
|
9
10
|
function DeliveryTime({ className, deliveryDate }) {
|
|
10
11
|
const t = useFormattedMessage();
|
|
11
12
|
const { number, unit } = getDateUnitObject(deliveryDate);
|
|
12
|
-
return (
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
return (jsxs("div", { className: clsx(styles['delivery-time'], className), children: [jsx("p", { children: jsx(FormattedMessage, { id: "Delivery expected in {0} {1}", replacementValues: {
|
|
14
|
+
'0': number.toString(),
|
|
15
|
+
'1': t.pluralize('unit', unit, number),
|
|
16
|
+
} }) }), jsx(Tooltip, { children: jsx(FormattedMessage, { id: "The expected delivery is an indication based on the product availability and the shipping location." }) })] }));
|
|
16
17
|
}
|
|
17
18
|
|
|
18
19
|
export { DeliveryTime };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import styles from './info-display.module.css.js';
|
|
3
|
+
|
|
4
|
+
function InfoDisplay({ id, label, value }) {
|
|
5
|
+
return (jsxs("div", { className: styles['info-display'], children: [jsx("span", { className: styles.label, id: id, children: label }), typeof value === 'string' ? (jsx("p", { "aria-labelledby": id, className: styles.value, children: value })) : (jsx("div", { "aria-labelledby": id, children: value }))] }));
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export { InfoDisplay };
|
package/dist/exports.d.ts
CHANGED
|
@@ -7,10 +7,10 @@ export * from './algolia/algolia-filter-panel';
|
|
|
7
7
|
export * from './algolia/algolia-hit-type';
|
|
8
8
|
export * from './algolia/algolia-hits-provider';
|
|
9
9
|
export * from './algolia/algolia-index-config';
|
|
10
|
+
export * from './algolia/algolia-initialization';
|
|
10
11
|
export * from './algolia/algolia-insight-instant-search-provider';
|
|
11
12
|
export * from './algolia/algolia-insights-provider';
|
|
12
13
|
export * from './algolia/algolia-instant-search-state-provider';
|
|
13
|
-
export * from './algolia/algolia-intialization';
|
|
14
14
|
export * from './algolia/algolia-multi-select-filter-section';
|
|
15
15
|
export * from './algolia/algolia-pagination';
|
|
16
16
|
export * from './algolia/algolia-provider';
|
|
@@ -56,11 +56,6 @@ export * from './carousel/usp-carousel/product-usp-carousel-slide';
|
|
|
56
56
|
export * from './carousel/usp-carousel/usp-carousel';
|
|
57
57
|
export * from './cart-totals/cart-totals';
|
|
58
58
|
export * from './cart-totals/cart-totals-summary';
|
|
59
|
-
export * from './checkout/adyen-payment';
|
|
60
|
-
export * from './checkout/parse-amount';
|
|
61
|
-
export * from './checkout/payment';
|
|
62
|
-
export * from './checkout/use-get-adyen-redirect-result';
|
|
63
|
-
export * from './checkout/use-has-returned-from-adyen';
|
|
64
59
|
export * from './collapsables/accordion/accordion';
|
|
65
60
|
export * from './collapsables/accordion/accordion-item';
|
|
66
61
|
export * from './collapsables/show-all/show-all';
|
|
@@ -71,6 +66,7 @@ export * from './country-selector/country-selector-dialog/country-selector-dialo
|
|
|
71
66
|
export * from './country-selector/country-selector-trigger/country-selector-trigger';
|
|
72
67
|
export * from './country-selector/use-countries-languages';
|
|
73
68
|
export * from './delivery-time/delivery-time';
|
|
69
|
+
export * from './display/info-display/info-display';
|
|
74
70
|
export * from './display/product-price/product-price';
|
|
75
71
|
export * from './display/product-price/product-total-price';
|
|
76
72
|
export * from './display/product-sku/product-sku';
|
|
@@ -85,6 +81,7 @@ export * from './forms/label/label';
|
|
|
85
81
|
export * from './forms/number-field/number-field';
|
|
86
82
|
export * from './forms/select/select';
|
|
87
83
|
export * from './forms/switch/switch';
|
|
84
|
+
export * from './forms/text-field/password-reveal-toggle/password-reveal-toggle';
|
|
88
85
|
export * from './forms/text-field/text-field';
|
|
89
86
|
export * from './forms/textarea/textarea';
|
|
90
87
|
export * from './global-search/categories-grid/categories-grid';
|
|
@@ -111,6 +108,7 @@ export * from './global-search/search-section/search-list-item';
|
|
|
111
108
|
export * from './global-search/search-section/search-section';
|
|
112
109
|
export * from './global-search/types';
|
|
113
110
|
export * from './header/cart-icon/connected-cart-icon';
|
|
111
|
+
export * from './info-icon-tooltip/info-icon-tooltip';
|
|
114
112
|
export * from './intl/formatted-message';
|
|
115
113
|
export * from './intl/intl-context';
|
|
116
114
|
export * from './intl/intl-provider';
|
|
@@ -143,16 +141,29 @@ export * from './notifications/announcements/announcement-provider';
|
|
|
143
141
|
export * from './notifications/announcements/connected-announcement';
|
|
144
142
|
export * from './observers/intersection-observer';
|
|
145
143
|
export * from './pages/checkout/cart-page/cart-page';
|
|
144
|
+
export * from './pages/checkout/cart-page/components/empty-cart-page';
|
|
145
|
+
export * from './pages/checkout/components/billing-and-invoice-information';
|
|
146
|
+
export * from './pages/checkout/constants';
|
|
146
147
|
export * from './pages/checkout/layouts/checkout-page-layout/checkout-page-layout';
|
|
147
148
|
export * from './pages/checkout/layouts/checkout-page-layout/components/checkout-page-section';
|
|
148
149
|
export * from './pages/checkout/layouts/checkout-page-layout/components/checkout-page-section-content';
|
|
149
150
|
export * from './pages/checkout/layouts/checkout-page-layout/components/checkout-page-section-header';
|
|
150
151
|
export * from './pages/checkout/layouts/checkout-page-layout/components/checkout-page-section-link';
|
|
152
|
+
export * from './pages/checkout/order-confirmation-page/order-confirmation-page';
|
|
153
|
+
export * from './pages/checkout/order-confirmation-page/order-confirmation-page-content';
|
|
154
|
+
export * from './pages/checkout/payment-page/components/adyen-payment';
|
|
155
|
+
export * from './pages/checkout/payment-page/components/payment';
|
|
156
|
+
export * from './pages/checkout/payment-page/hooks/use-get-adyen-redirect-result';
|
|
157
|
+
export * from './pages/checkout/payment-page/hooks/use-has-returned-from-adyen';
|
|
151
158
|
export * from './pages/checkout/payment-page/payment-page';
|
|
159
|
+
export * from './pages/checkout/payment-page/payment-page-content';
|
|
160
|
+
export * from './pages/checkout/payment-page/utils/parse-amount';
|
|
152
161
|
export * from './pages/checkout/shipping-page/components/edit-address';
|
|
153
162
|
export * from './pages/checkout/shipping-page/components/readonly-address';
|
|
154
163
|
export * from './pages/checkout/shipping-page/components/sonic-address';
|
|
164
|
+
export * from './pages/checkout/shipping-page/hooks/use-patch-shipping-details';
|
|
155
165
|
export * from './pages/checkout/shipping-page/shipping-page';
|
|
166
|
+
export * from './pages/checkout/shipping-page/shipping-page-content';
|
|
156
167
|
export * from './pages/components/page-container/page-container';
|
|
157
168
|
export * from './pages/components/page-meta-data/page-meta-data';
|
|
158
169
|
export * from './pages/components/page/page';
|
|
@@ -193,6 +204,7 @@ export * from './shared/api/storefront/hooks/authentication/use-sign-out';
|
|
|
193
204
|
export * from './shared/api/storefront/hooks/cart/use-add-product-to-current-cart';
|
|
194
205
|
export * from './shared/api/storefront/hooks/cart/use-delete-cart-line-by-id';
|
|
195
206
|
export * from './shared/api/storefront/hooks/cart/use-delete-current-cart';
|
|
207
|
+
export * from './shared/api/storefront/hooks/cart/use-fetch-cart-by-id';
|
|
196
208
|
export * from './shared/api/storefront/hooks/cart/use-fetch-current-cart';
|
|
197
209
|
export * from './shared/api/storefront/hooks/cart/use-fetch-current-cart-checkout-atp';
|
|
198
210
|
export * from './shared/api/storefront/hooks/cart/use-fetch-current-cart-count';
|
|
@@ -279,17 +291,18 @@ export * from './shared/utils/environment';
|
|
|
279
291
|
export * from './shared/utils/event-emitter';
|
|
280
292
|
export * from './shared/utils/merge';
|
|
281
293
|
export * from './shared/utils/price';
|
|
294
|
+
export * from './shared/utils/promise';
|
|
282
295
|
export * from './shared/utils/random';
|
|
283
296
|
export * from './shared/utils/string';
|
|
284
297
|
export * from './shared/utils/time';
|
|
285
298
|
export * from './shared/utils/types';
|
|
286
299
|
export * from './shared/utils/uuid';
|
|
287
|
-
export * from './shared/utils/wait';
|
|
288
300
|
export * from './sidebar/sidebar';
|
|
289
301
|
export * from './sidebar/sidebar-provider';
|
|
290
302
|
export * from './sidebar/toggle-sidebar-button';
|
|
291
303
|
export * from './sidebar/types';
|
|
292
304
|
export * from './sidebar/use-sidebar';
|
|
305
|
+
export * from './sign-in-form/sign-in-form';
|
|
293
306
|
export * from './toast/toast';
|
|
294
307
|
export * from './toast/toast-provider';
|
|
295
308
|
export * from './toast/types';
|
|
@@ -4,9 +4,10 @@ export interface CheckboxProps {
|
|
|
4
4
|
children?: ReactNode;
|
|
5
5
|
className?: string;
|
|
6
6
|
'data-test-selector'?: string;
|
|
7
|
+
defaultSelected?: boolean;
|
|
7
8
|
isDisabled?: boolean;
|
|
8
9
|
isSelected?: boolean;
|
|
9
10
|
onChange?: (isSelected: boolean) => void;
|
|
10
11
|
value?: string;
|
|
11
12
|
}
|
|
12
|
-
export declare function Checkbox({ _pseudo, children, className, 'data-test-selector': dataTestSelector, isDisabled, isSelected, onChange, value, }: CheckboxProps): import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export declare function Checkbox({ _pseudo, children, className, 'data-test-selector': dataTestSelector, defaultSelected, isDisabled, isSelected, onChange, value, }: CheckboxProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -4,8 +4,8 @@ import { Checkbox as Checkbox$1 } from 'react-aria-components';
|
|
|
4
4
|
import clsx from 'clsx';
|
|
5
5
|
import styles from './checkbox.module.css.js';
|
|
6
6
|
|
|
7
|
-
function Checkbox({ _pseudo = 'none', children, className, 'data-test-selector': dataTestSelector, isDisabled, isSelected, onChange, value, }) {
|
|
8
|
-
return (jsxs(Checkbox$1, { className: clsx(className, styles.checkbox, styles[_pseudo]), "data-test-selector": dataTestSelector, isDisabled: isDisabled, isSelected: isSelected, onChange: onChange, value: value, children: [jsx("div", { className: styles.box, children: jsx("svg", { "aria-hidden": "true", className: styles.checkmark, viewBox: "0 0
|
|
7
|
+
function Checkbox({ _pseudo = 'none', children, className, 'data-test-selector': dataTestSelector, defaultSelected, isDisabled, isSelected, onChange, value, }) {
|
|
8
|
+
return (jsxs(Checkbox$1, { className: clsx(className, styles.checkbox, styles[_pseudo]), "data-test-selector": dataTestSelector, defaultSelected: defaultSelected, isDisabled: isDisabled, isSelected: isSelected, onChange: onChange, value: value, children: [jsx("div", { className: styles.box, children: jsx("svg", { "aria-hidden": "true", className: styles.checkmark, viewBox: "0 0 10 7", children: jsx("path", { d: "m1 2.845 3 3L8.845 1" }) }) }), children] }));
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
export { Checkbox };
|
|
@@ -13,6 +13,7 @@ interface FieldErrorProps {
|
|
|
13
13
|
children?: ReactNode | ((values: ValidationResult & {
|
|
14
14
|
defaultChildren: ReactNode;
|
|
15
15
|
}) => ReactNode);
|
|
16
|
+
className?: string;
|
|
16
17
|
}
|
|
17
|
-
export declare function FieldError({ children }: FieldErrorProps): import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
export declare function FieldError({ children, className }: FieldErrorProps): import("react/jsx-runtime").JSX.Element;
|
|
18
19
|
export {};
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx } from 'react/jsx-runtime';
|
|
3
3
|
import { FieldError as FieldError$1 } from 'react-aria-components';
|
|
4
|
+
import clsx from 'clsx';
|
|
4
5
|
import { useFormattedMessage } from '../../intl/use-formatted-message.js';
|
|
5
6
|
import styles from './field-error.module.css.js';
|
|
6
7
|
|
|
7
|
-
function FieldError({ children }) {
|
|
8
|
+
function FieldError({ children, className }) {
|
|
8
9
|
const t = useFormattedMessage();
|
|
9
|
-
return (jsx(FieldError$1, { className: styles['field-error'], children: children ||
|
|
10
|
+
return (jsx(FieldError$1, { className: clsx(className, styles['field-error']), children: children ||
|
|
10
11
|
(result => {
|
|
11
12
|
if (!result.isInvalid)
|
|
12
13
|
return;
|
|
@@ -3,6 +3,8 @@ import { Input as AriaInput } from 'react-aria-components';
|
|
|
3
3
|
export interface InputProps extends Omit<ComponentProps<typeof AriaInput>, 'size'> {
|
|
4
4
|
_pseudo?: 'focus' | 'none';
|
|
5
5
|
autoGrow?: boolean;
|
|
6
|
+
className?: string;
|
|
7
|
+
inlineElement?: React.ReactNode;
|
|
6
8
|
label: string;
|
|
7
9
|
size?: 'md' | 'lg';
|
|
8
10
|
value?: string | number;
|
|
@@ -9,7 +9,7 @@ import styles from './input.module.css.js';
|
|
|
9
9
|
* This component is used to create an input that grows as the user types.
|
|
10
10
|
* It uses a shadow input to calculate the width of the input.
|
|
11
11
|
*/
|
|
12
|
-
const Input = forwardRef(({ _pseudo = 'none', autoGrow, label, size = 'lg', ...inputProps }, inputRef) => {
|
|
12
|
+
const Input = forwardRef(({ _pseudo = 'none', autoGrow, className, inlineElement, label, size = 'lg', ...inputProps }, inputRef) => {
|
|
13
13
|
const [props, ref] = useContextProps(inputProps, inputRef, InputContext);
|
|
14
14
|
const { defaultValue, onChange, value: controlledValue } = props;
|
|
15
15
|
const [uncontrolledValue, setUncontrolledValue] = useState(defaultValue);
|
|
@@ -18,11 +18,13 @@ const Input = forwardRef(({ _pseudo = 'none', autoGrow, label, size = 'lg', ...i
|
|
|
18
18
|
const handleChange = (event) => isControlled
|
|
19
19
|
? onChange?.(event)
|
|
20
20
|
: setUncontrolledValue(event.target.value);
|
|
21
|
-
return (jsx("div", { className: clsx(styles['input-container'], styles[size], styles[_pseudo]), children: jsxs("div", { className: clsx(
|
|
21
|
+
return (jsx("div", { className: clsx(className, styles['input-container'], styles[size], styles[_pseudo]), children: jsxs("div", { className: clsx(styles.input, {
|
|
22
|
+
[styles['growing-input']]: autoGrow,
|
|
23
|
+
}), children: [jsx(Input$1, { "aria-label": label, size: autoGrow ? 1 : undefined, ...props, ref: ref, onChange: handleChange, onClick: e => {
|
|
22
24
|
e.preventDefault();
|
|
23
25
|
e.stopPropagation();
|
|
24
26
|
e.target.focus();
|
|
25
|
-
} }), autoGrow && jsx("span", { className: styles['shadow-input'], children: value })] }) }));
|
|
27
|
+
} }), inlineElement && (jsx("div", { className: styles['inline-element'], children: inlineElement })), autoGrow && jsx("span", { className: styles['shadow-input'], children: value })] }) }));
|
|
26
28
|
});
|
|
27
29
|
Input.displayName = 'Input';
|
|
28
30
|
|