@sonic-equipment/ui 240.0.0 → 242.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 (27) hide show
  1. package/dist/algolia/algolia-index-config.d.ts +3 -1
  2. package/dist/algolia/algolia-index-config.js +18 -112
  3. package/dist/algolia/algolia-initialization.js +1 -1
  4. package/dist/buttons/button/button.js +1 -1
  5. package/dist/cart-totals/cart-totals-summary.js +1 -1
  6. package/dist/config.d.ts +1 -1
  7. package/dist/delivery-time/delivery-time.js +1 -1
  8. package/dist/display/price/price.js +15 -5
  9. package/dist/info-icon-tooltip/info-icon-tooltip.js +1 -1
  10. package/dist/modals/confirmation/confirmation-dialog.d.ts +1 -1
  11. package/dist/pages/checkout/cart-page/cart-page.js +2 -2
  12. package/dist/pages/checkout/payment-page/components/adyen-payment.d.ts +1 -1
  13. package/dist/pages/product/product-details-page/components/product-details-panel/product-details-panel.d.ts +1 -1
  14. package/dist/pages/product/product-details-page/components/product-details-panel/product-details-panel.js +1 -1
  15. package/dist/shared/api/storefront/hooks/account/use-create-account.d.ts +2 -2
  16. package/dist/shared/api/storefront/hooks/account/use-create-guest-account.d.ts +1 -1
  17. package/dist/shared/api/storefront/hooks/authentication/use-patch-session.js +1 -1
  18. package/dist/shared/api/storefront/hooks/customer/use-patch-bill-to-address.js +1 -1
  19. package/dist/shared/api/storefront/hooks/customer/use-patch-ship-to-address.js +1 -1
  20. package/dist/shared/api/storefront/hooks/customer/use-post-ship-to-address.js +1 -1
  21. package/dist/shared/api/storefront/hooks/payment/use-create-adyen-session.d.ts +2 -2
  22. package/dist/shared/api/storefront/hooks/payment/use-fetch-adyen-config.js +1 -1
  23. package/dist/shared/api/storefront/services/payment-service.d.ts +1 -1
  24. package/dist/shared/utils/price.d.ts +4 -2
  25. package/dist/shared/utils/price.js +8 -5
  26. package/dist/tooltip/tooltip.js +1 -1
  27. package/package.json +2 -1
@@ -8,5 +8,7 @@ export interface Indexes {
8
8
  }[];
9
9
  suggestions: string;
10
10
  }
11
- export declare const algoliaIndexesPerEnvironment: Record<Environment, Indexes>;
11
+ type AlgoliaEnvironment = 'development' | 'production';
12
+ export declare const algoliaIndexesPerEnvironment: Record<AlgoliaEnvironment, Indexes>;
12
13
  export declare const getAlgoliaIndex: (environment: Environment, languageCode: LanguageCode) => Indexes;
14
+ export {};
@@ -4,51 +4,7 @@ const defaultLanguageCodes = {
4
4
  };
5
5
  const getLanguageForAlgoliaIndex = (languageCode) => defaultLanguageCodes[languageCode] || languageCode;
6
6
  const algoliaIndexesPerEnvironment = {
7
- local: {
8
- default: 'dev_sonic_products_<languageCode>',
9
- sort: [
10
- {
11
- index: 'dev_sonic_products_<languageCode>',
12
- name: 'relevance',
13
- },
14
- {
15
- index: 'dev_sonic_products_<languageCode>_is-new_desc',
16
- name: 'newest',
17
- },
18
- {
19
- index: 'dev_sonic_products_<languageCode>_price_asc',
20
- name: 'price_asc',
21
- },
22
- {
23
- index: 'dev_sonic_products_<languageCode>_price_desc',
24
- name: 'price_desc',
25
- },
26
- ],
27
- suggestions: 'dev_sonic_products_<languageCode>_query_suggestions',
28
- },
29
- marketingLocal: {
30
- default: 'dev_sonic_products_<languageCode>',
31
- sort: [
32
- {
33
- index: 'dev_sonic_products_<languageCode>',
34
- name: 'relevance',
35
- },
36
- {
37
- index: 'dev_sonic_products_<languageCode>_is-new_desc',
38
- name: 'newest',
39
- },
40
- {
41
- index: 'dev_sonic_products_<languageCode>_price_asc',
42
- name: 'price_asc',
43
- },
44
- {
45
- index: 'dev_sonic_products_<languageCode>_price_desc',
46
- name: 'price_desc',
47
- },
48
- ],
49
- suggestions: 'dev_sonic_products_<languageCode>_query_suggestions',
50
- },
51
- next: {
7
+ development: {
52
8
  default: 'dev_sonic_products_<languageCode>',
53
9
  sort: [
54
10
  {
@@ -92,76 +48,26 @@ const algoliaIndexesPerEnvironment = {
92
48
  ],
93
49
  suggestions: 'prod_sonic_products_<languageCode>_query_suggestions',
94
50
  },
95
- sandbox: {
96
- default: 'dev_sonic_products_<languageCode>',
97
- sort: [
98
- {
99
- index: 'dev_sonic_products_<languageCode>',
100
- name: 'relevance',
101
- },
102
- {
103
- index: 'dev_sonic_products_<languageCode>_is-new_desc',
104
- name: 'newest',
105
- },
106
- {
107
- index: 'dev_sonic_products_<languageCode>_price_asc',
108
- name: 'price_asc',
109
- },
110
- {
111
- index: 'dev_sonic_products_<languageCode>_price_desc',
112
- name: 'price_desc',
113
- },
114
- ],
115
- suggestions: 'dev_sonic_products_<languageCode>_query_suggestions',
116
- },
117
- 'sandbox-reverse-proxy': {
118
- default: 'dev_sonic_products_<languageCode>',
119
- sort: [
120
- {
121
- index: 'dev_sonic_products_<languageCode>',
122
- name: 'relevance',
123
- },
124
- {
125
- index: 'dev_sonic_products_<languageCode>_is-new_desc',
126
- name: 'newest',
127
- },
128
- {
129
- index: 'dev_sonic_products_<languageCode>_price_asc',
130
- name: 'price_asc',
131
- },
132
- {
133
- index: 'dev_sonic_products_<languageCode>_price_desc',
134
- name: 'price_desc',
135
- },
136
- ],
137
- suggestions: 'dev_sonic_products_<languageCode>_query_suggestions',
138
- },
139
- storybook: {
140
- default: 'dev_sonic_products_<languageCode>',
141
- sort: [
142
- {
143
- index: 'dev_sonic_products_<languageCode>',
144
- name: 'relevance',
145
- },
146
- {
147
- index: 'dev_sonic_products_<languageCode>_is-new_desc',
148
- name: 'newest',
149
- },
150
- {
151
- index: 'dev_sonic_products_<languageCode>_price_asc',
152
- name: 'price_asc',
153
- },
154
- {
155
- index: 'dev_sonic_products_<languageCode>_price_desc',
156
- name: 'price_desc',
157
- },
158
- ],
159
- suggestions: 'dev_sonic_products_<languageCode>_query_suggestions',
160
- },
161
51
  };
52
+ const DEV_LIKE = new Set([
53
+ 'local',
54
+ 'marketingLocal',
55
+ 'sandbox',
56
+ 'sandbox-reverse-proxy',
57
+ 'storybook',
58
+ ]);
162
59
  const getAlgoliaIndex = (environment, languageCode) => {
163
- const environmentIndex = algoliaIndexesPerEnvironment[environment];
60
+ let algoliaIndexEnv = 'development';
164
61
  const language = getLanguageForAlgoliaIndex(languageCode).toLowerCase();
62
+ if (DEV_LIKE.has(environment)) {
63
+ algoliaIndexEnv = 'development';
64
+ }
65
+ else {
66
+ algoliaIndexEnv = process?.env.ALGOLIA_APP_ID?.includes('testing')
67
+ ? 'development'
68
+ : 'production';
69
+ }
70
+ const environmentIndex = algoliaIndexesPerEnvironment[algoliaIndexEnv];
165
71
  return {
166
72
  default: environmentIndex.default.replace(/<languageCode>/, language),
167
73
  sort: environmentIndex.sort.map(({ index, name }) => ({
@@ -1,7 +1,7 @@
1
1
  "use client";
2
- import { config } from '../config.js';
3
2
  import Cookies from 'js-cookie';
4
3
  import aa from 'search-insights';
4
+ import { config } from '../config.js';
5
5
  import { logger } from '../logging/logger.js';
6
6
  import { request } from '../shared/fetch/request.js';
7
7
  import { createUUID } from '../shared/utils/uuid.js';
@@ -2,8 +2,8 @@
2
2
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
3
3
  import { forwardRef, isValidElement } from 'react';
4
4
  import clsx from 'clsx';
5
- import { ProgressCircle } from '../../loading/progress-circle.js';
6
5
  import { GlyphsArrowBoldCapsRightIcon } from '../../icons/glyph/glyphs-arrow-boldcaps-right-icon.js';
6
+ import { ProgressCircle } from '../../loading/progress-circle.js';
7
7
  import { useRouteLink } from '../../shared/routing/use-route-link.js';
8
8
  import buttonStyles from './button.module.css.js';
9
9
 
@@ -1,9 +1,9 @@
1
1
  "use client";
2
2
  import { jsx, jsxs } from 'react/jsx-runtime';
3
3
  import clsx from 'clsx';
4
+ import { Price } from '../display/price/price.js';
4
5
  import { FormattedMessage } from '../intl/formatted-message.js';
5
6
  import { Heading } from '../typography/heading/heading.js';
6
- import { Price } from '../display/price/price.js';
7
7
  import styles from './cart-totals-summary.module.css.js';
8
8
 
9
9
  function CartTotalsSummary({ className, currencyCode, totalAmount, }) {
package/dist/config.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Environment } from 'shared/utils/environment';
1
+ import { Environment } from './shared/utils/environment';
2
2
  interface Config {
3
3
  ALGOLIA_API_KEY: string;
4
4
  ALGOLIA_APP_ID: string;
@@ -1,8 +1,8 @@
1
1
  "use client";
2
2
  import { jsx, jsxs } from 'react/jsx-runtime';
3
3
  import clsx from 'clsx';
4
- import { FormattedMessage } from '../intl/formatted-message.js';
5
4
  import { InfoIconTooltip } from '../info-icon-tooltip/info-icon-tooltip.js';
5
+ import { FormattedMessage } from '../intl/formatted-message.js';
6
6
  import { useFormattedDate } from '../intl/use-formatted-date.js';
7
7
  import { useFormattedMessage } from '../intl/use-formatted-message.js';
8
8
  import styles from './delivery-time.module.css.js';
@@ -6,18 +6,28 @@ import { useIntl } from '../../intl/use-intl.js';
6
6
  import { formatCurrency, parseCurrency } from '../../shared/utils/price.js';
7
7
  import styles from './price.module.css.js';
8
8
 
9
- function SinglePrice({ className, currencyCode, isDiscount, isOld, locale, price, small, variant = 'default', }) {
9
+ function formatAndParse(opts) {
10
10
  const priceString = formatCurrency({
11
- currencyCode,
12
- locale,
13
- price,
11
+ ...opts,
14
12
  replaceNonBreakingSpace: true,
13
+ useGrouping: true,
15
14
  });
16
- const { currency, decimal, fraction, integer, literal, symbolPosition } = parseCurrency({
15
+ const parts = parseCurrency({
16
+ ...opts,
17
+ useGrouping: true,
18
+ });
19
+ return {
20
+ parts,
21
+ priceString,
22
+ };
23
+ }
24
+ function SinglePrice({ className, currencyCode, isDiscount, isOld, locale, price, small, variant = 'default', }) {
25
+ const { parts, priceString } = formatAndParse({
17
26
  currencyCode,
18
27
  locale,
19
28
  price,
20
29
  });
30
+ const { currency, decimal, fraction, integer, literal, symbolPosition } = parts;
21
31
  return (jsxs("data", { className: clsx(className, styles['single-price'], styles[variant], small && styles['small'], isDiscount && styles['is-discount'], isOld && styles['is-old'], styles[`symbol-${symbolPosition}`]), "data-price-string": priceString, value: price, children: [symbolPosition === 'before' && (jsx("span", { className: styles.symbol, children: currency })), jsxs("span", { className: styles.number, children: [literal && jsx("span", { className: styles.literal, children: literal }), jsx("span", { className: styles.integer, children: integer }), decimal && jsx("span", { className: styles.decimal, children: decimal }), fraction && jsx("span", { className: styles.fraction, children: fraction })] }), symbolPosition === 'after' && (jsx("span", { className: styles.symbol, children: currency }))] }));
22
32
  }
23
33
  function Price({ className, currencyCode, 'data-test-selector': dataTestSelector, isVatIncluded = null, locale, originalPrice, price, pricePerUnit, style, unitAmount = 1, unitType = 'pc', variant = 'default', }) {
@@ -1,9 +1,9 @@
1
1
  "use client";
2
2
  import { jsx } from 'react/jsx-runtime';
3
3
  import clsx from 'clsx';
4
+ import { IconButton } from '../buttons/icon-button/icon-button.js';
4
5
  import { SolidInformationIcon } from '../icons/solid/solid-information-icon.js';
5
6
  import { StrokeInformationIcon } from '../icons/stroke/stroke-information-icon.js';
6
- import { IconButton } from '../buttons/icon-button/icon-button.js';
7
7
  import { useFormattedMessage } from '../intl/use-formatted-message.js';
8
8
  import { Tooltip } from '../tooltip/tooltip.js';
9
9
  import styles from './info-icon-tooltip.module.css.js';
@@ -1,4 +1,4 @@
1
- import { TranslationId } from 'intl/translation-id';
1
+ import { TranslationId } from '../../intl/translation-id';
2
2
  interface ConfirmationDialogProps {
3
3
  cancelLabel?: TranslationId;
4
4
  'data-test-selector'?: string;
@@ -1,5 +1,6 @@
1
1
  "use client";
2
2
  import { jsx } from 'react/jsx-runtime';
3
+ import { Button } from '../../../buttons/button/button.js';
3
4
  import { ConnectedOrderLineCard } from '../../../cards/orderline-card/connected-orderline-card.js';
4
5
  import { CartTotals } from '../../../cart-totals/cart-totals.js';
5
6
  import { CartTotalsSummary } from '../../../cart-totals/cart-totals-summary.js';
@@ -14,13 +15,12 @@ import { useSaveCartForLater } from '../../../shared/api/bff/hooks/cart/use-save
14
15
  import { useIsAuthenticated } from '../../../shared/api/storefront/hooks/authentication/use-is-authenticated.js';
15
16
  import { useDeleteCartLineById } from '../../../shared/api/storefront/hooks/cart/use-delete-cart-line-by-id.js';
16
17
  import { useDeleteCurrentCart } from '../../../shared/api/storefront/hooks/cart/use-delete-current-cart.js';
17
- import { useToast } from '../../../toast/use-toast.js';
18
- import { Button } from '../../../buttons/button/button.js';
19
18
  import { useFetchCurrentCartLinesWithAtp } from '../../../shared/api/storefront/hooks/cart/use-fetch-current-cart-lines-with-atp.js';
20
19
  import { useFetchCurrentCartWithAtp } from '../../../shared/api/storefront/hooks/cart/use-fetch-current-cart-with-atp.js';
21
20
  import { getCurrencyCodeBySymbol } from '../../../shared/model/currency.js';
22
21
  import { usePaths } from '../../../shared/routing/use-paths.js';
23
22
  import { ensureNumber } from '../../../shared/utils/number.js';
23
+ import { useToast } from '../../../toast/use-toast.js';
24
24
  import { EmptyCart } from './components/empty-cart-page.js';
25
25
 
26
26
  function CartContent({ cartLines }) {
@@ -1,7 +1,7 @@
1
1
  import { MutableRefObject } from 'react';
2
2
  import Dropin from '@adyen/adyen-web/dist/types/components/Dropin';
3
- import { AdyenPaymentModel } from 'shared/api/storefront/model/storefront.model';
4
3
  import { CountryCode, CurrencyCode } from '../../../../intl/types';
4
+ import { AdyenPaymentModel } from '../../../../shared/api/storefront/model/storefront.model';
5
5
  import '@adyen/adyen-web/dist/adyen.css';
6
6
  interface AdyenPaymentProps {
7
7
  amount: number;
@@ -1,4 +1,4 @@
1
- import { ProductDetails } from 'shared/api/bff/model/bff.model';
1
+ import { ProductDetails } from '../../../../../shared/api/bff/model/bff.model';
2
2
  export declare function ProductDetailsPanel({ priceComponent, product, }: {
3
3
  priceComponent?: React.ReactNode;
4
4
  product: ProductDetails;
@@ -1,5 +1,6 @@
1
1
  "use client";
2
2
  import { jsxs, jsx } from 'react/jsx-runtime';
3
+ import { useAlgoliaInsights } from '../../../../../algolia/use-algolia-insights.js';
3
4
  import { ConnectedAddToCartButton } from '../../../../../buttons/add-to-cart-button/connected-add-to-cart-button.js';
4
5
  import { ConnectedFavoriteButton } from '../../../../../buttons/favorite/connected-favorite-button.js';
5
6
  import { Accordion } from '../../../../../collapsables/accordion/accordion.js';
@@ -11,7 +12,6 @@ import { FormattedMessage } from '../../../../../intl/formatted-message.js';
11
12
  import { DownloadDocumentList } from '../../../../../lists/download-document-list/download-document-list.js';
12
13
  import { FeatureList } from '../../../../../lists/feature-list/feature-list.js';
13
14
  import { Heading } from '../../../../../typography/heading/heading.js';
14
- import { useAlgoliaInsights } from '../../../../../algolia/use-algolia-insights.js';
15
15
  import styles from './product-details-panel.module.css.js';
16
16
 
17
17
  function ProductDetailsPanel({ priceComponent, product, }) {
@@ -1,3 +1,3 @@
1
- import { AccountModel } from 'shared/api/storefront/model/storefront.model';
2
- import { CreateAccountRequestBody } from 'shared/api/storefront/services/account-service';
1
+ import { AccountModel } from '../../model/storefront.model';
2
+ import { CreateAccountRequestBody } from '../../services/account-service';
3
3
  export declare function useCreateAccount(): import("@tanstack/react-query").UseMutationResult<AccountModel, Error, CreateAccountRequestBody, unknown>;
@@ -1,2 +1,2 @@
1
- import { AccountModel } from 'shared/api/storefront/model/storefront.model';
1
+ import { AccountModel } from '../../model/storefront.model';
2
2
  export declare function useCreateGuestAccount(): import("@tanstack/react-query").UseMutationResult<AccountModel, Error, void, unknown>;
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import { useQueryClient } from '@tanstack/react-query';
3
- import { patchSession } from '../../services/authentication-service.js';
4
3
  import { useAwaitableMutation } from '../../../shared/hooks/use-awaitable-mutation.js';
4
+ import { patchSession } from '../../services/authentication-service.js';
5
5
 
6
6
  function usePatchSession() {
7
7
  const queryClient = useQueryClient();
@@ -1,6 +1,6 @@
1
1
  "use client";
2
- import { patchBillToAddress } from '../../services/customer-service.js';
3
2
  import { useAwaitableMutation } from '../../../shared/hooks/use-awaitable-mutation.js';
3
+ import { patchBillToAddress } from '../../services/customer-service.js';
4
4
 
5
5
  function usePatchBillToAddress({ skipInvalidation = false, } = {}) {
6
6
  return useAwaitableMutation({
@@ -1,6 +1,6 @@
1
1
  "use client";
2
- import { patchShipToAddress } from '../../services/customer-service.js';
3
2
  import { useAwaitableMutation } from '../../../shared/hooks/use-awaitable-mutation.js';
3
+ import { patchShipToAddress } from '../../services/customer-service.js';
4
4
 
5
5
  function usePatchShipToAddress({ skipInvalidation = false, } = {}) {
6
6
  return useAwaitableMutation({
@@ -1,6 +1,6 @@
1
1
  "use client";
2
- import { postShipToAddress } from '../../services/customer-service.js';
3
2
  import { useAwaitableMutation } from '../../../shared/hooks/use-awaitable-mutation.js';
3
+ import { postShipToAddress } from '../../services/customer-service.js';
4
4
 
5
5
  function usePostShipToAddress({ skipInvalidation = false, } = {}) {
6
6
  return useAwaitableMutation({
@@ -1,3 +1,3 @@
1
- import { PaymentAuthenticationModel } from 'shared/api/storefront/model/storefront.model';
2
- import { CreateAdyenSessionParameters } from 'shared/api/storefront/services/payment-service';
1
+ import { PaymentAuthenticationModel } from '../../model/storefront.model';
2
+ import { CreateAdyenSessionParameters } from '../../services/payment-service';
3
3
  export declare function useCreateAdyenSession(): import("@tanstack/react-query").UseMutationResult<PaymentAuthenticationModel, Error, CreateAdyenSessionParameters, unknown>;
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import { useQuery } from '@tanstack/react-query';
3
- import { useIsAuthenticated } from '../authentication/use-is-authenticated.js';
4
3
  import { fetchAdyenConfig } from '../../services/payment-service.js';
4
+ import { useIsAuthenticated } from '../authentication/use-is-authenticated.js';
5
5
 
6
6
  function useFetchAdyenConfig() {
7
7
  const isAuthenticated = useIsAuthenticated();
@@ -1,4 +1,4 @@
1
- import { AdyenSettings, PaymentAuthenticationModel } from 'shared/api/storefront/model/storefront.model';
1
+ import { AdyenSettings, PaymentAuthenticationModel } from '../model/storefront.model';
2
2
  export interface CreateAdyenSessionParameters {
3
3
  cartId: string | undefined;
4
4
  orderAmount: number | undefined;