@sonic-equipment/ui 202.0.0 → 204.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-info-display/address-info-display.js +1 -0
- package/dist/algolia/filter-section.js +1 -0
- package/dist/badges/badge/icon-with-badge/icon-with-badge.js +1 -0
- package/dist/badges/tag/tag.js +1 -0
- package/dist/breadcrumbs/breadcrumb.js +7 -16
- package/dist/breadcrumbs/breadcrumb.module.css.js +1 -1
- package/dist/buttons/add-to-cart-button/add-to-cart-button.d.ts +1 -1
- package/dist/buttons/add-to-cart-button/add-to-cart-button.js +12 -13
- package/dist/cards/data-card/data-card.js +1 -0
- package/dist/cards/orderline-card/orderline-card.js +1 -0
- package/dist/carousel/category-carousel/category-carousel.js +1 -0
- package/dist/carousel/usp-carousel/product-usp-carousel-slide.js +1 -0
- package/dist/carousel/usp-carousel/product-usp-carousel.js +1 -0
- package/dist/cart-totals/cart-totals-summary.js +1 -0
- package/dist/collapsables/accordion/accordion-item.js +6 -5
- package/dist/collapsables/accordion/accordion.js +1 -0
- package/dist/collapsables/accordion/accordion.module.css.js +1 -1
- package/dist/cookies/client-cookie-context.d.ts +3 -0
- package/dist/cookies/client-cookie-context.js +30 -0
- package/dist/cookies/cookie-context.d.ts +2 -0
- package/dist/cookies/cookie-context.js +6 -0
- package/dist/cookies/cookie-provider.d.ts +6 -0
- package/dist/cookies/cookie-provider.js +10 -0
- package/dist/cookies/readonly-cookie-reader.d.ts +2 -0
- package/dist/cookies/readonly-cookie-reader.js +18 -0
- package/dist/cookies/types.d.ts +14 -0
- package/dist/cookies/types.js +7 -0
- package/dist/{shared/hooks → cookies}/use-cookie.d.ts +1 -2
- package/dist/cookies/use-cookie.js +30 -0
- package/dist/country-select/hooks/use-countries.js +2 -1
- package/dist/country-selector/connected-country-selector.js +1 -1
- package/dist/country-selector/use-countries-languages.js +3 -11
- package/dist/display/info-display/info-display.js +1 -0
- package/dist/display/product-sku/product-sku.js +1 -0
- package/dist/exports.d.ts +6 -1
- package/dist/forms/layout/form/form-segment-group.js +1 -0
- package/dist/forms/layout/form/form-segment.js +1 -0
- package/dist/forms/partials/password-validation/password-validation.js +1 -0
- package/dist/global-search/plugins/categories-plugin.js +1 -0
- package/dist/global-search/plugins/popular-categories-plugin.js +1 -0
- package/dist/global-search/plugins/popular-searches-plugin.js +1 -0
- package/dist/global-search/plugins/query-suggestions-plugin.js +1 -0
- package/dist/global-search/plugins/quick-access-plugin.js +1 -0
- package/dist/global-search/plugins/recent-searches-plugin.js +1 -0
- package/dist/global-search/search-highlight/highlight.js +1 -0
- package/dist/global-search/search-result-panel/sections/section-container.js +1 -0
- package/dist/global-search/search-section/search-list.js +1 -0
- package/dist/global-search/search-section/search-section.js +1 -0
- package/dist/header/buttons/account/connected-account-button.js +1 -8
- package/dist/header/drawers/search-drawer.js +1 -0
- package/dist/header/header-layout/header-layout.js +1 -0
- package/dist/icons/glyph/glyphs-arrow-blackcaps-right-icon.js +1 -0
- package/dist/icons/glyph/glyphs-arrow-boldcaps-left-icon.js +1 -0
- package/dist/icons/glyph/glyphs-arrow-boldcaps-right-icon.js +1 -0
- package/dist/icons/glyph/glyphs-arrow-semibold-right-icon.js +1 -0
- package/dist/icons/glyph/glyphs-chevrons-bold-down-icon.js +1 -0
- package/dist/icons/glyph/glyphs-chevrons-bold-up-icon.js +1 -0
- package/dist/icons/glyph/glyphs-chevrons-slim-down-icon.js +1 -0
- package/dist/icons/glyph/glyphs-chevrons-slim-left-icon.js +1 -0
- package/dist/icons/glyph/glyphs-chevrons-slim-right-icon.js +1 -0
- package/dist/icons/solid/solid-attention-icon.js +1 -0
- package/dist/icons/solid/solid-cart-icon.js +1 -0
- package/dist/icons/solid/solid-close-icon.js +1 -0
- package/dist/icons/solid/solid-favorite-icon.js +1 -0
- package/dist/icons/solid/solid-home-icon.js +1 -0
- package/dist/icons/solid/solid-information-icon.js +1 -0
- package/dist/icons/solid/solid-login-icon.js +1 -0
- package/dist/icons/solid/solid-logout-icon.js +1 -0
- package/dist/icons/solid/solid-news-icon.js +1 -0
- package/dist/icons/solid/solid-notice-icon.js +1 -0
- package/dist/icons/solid/solid-okay-icon.js +1 -0
- package/dist/icons/solid/solid-rating-icon.js +1 -0
- package/dist/icons/solid/solid-salecategory-icon.js +1 -0
- package/dist/icons/solid/solid-tag-icon.js +1 -0
- package/dist/icons/stroke/stroke-categories-icon.js +1 -0
- package/dist/icons/stroke/stroke-checkmark-icon.js +1 -0
- package/dist/icons/stroke/stroke-closebox-icon.js +1 -0
- package/dist/icons/stroke/stroke-dehashed-icon.js +1 -0
- package/dist/icons/stroke/stroke-download-icon.js +1 -0
- package/dist/icons/stroke/stroke-event-icon.js +1 -0
- package/dist/icons/stroke/stroke-favorite-icon.js +1 -0
- package/dist/icons/stroke/stroke-filter-icon.js +1 -0
- package/dist/icons/stroke/stroke-hashed-icon.js +1 -0
- package/dist/icons/stroke/stroke-information-icon.js +1 -0
- package/dist/icons/stroke/stroke-minus-icon.js +1 -0
- package/dist/icons/stroke/stroke-plus-icon.js +1 -0
- package/dist/icons/stroke/stroke-recent-icon.js +1 -0
- package/dist/icons/stroke/stroke-search-icon.js +1 -0
- package/dist/icons/stroke/stroke-trash-icon.js +1 -0
- package/dist/index.js +7 -2
- package/dist/intl/use-formatted-date.js +1 -0
- package/dist/layout/center.js +1 -0
- package/dist/lists/download-document-list/download-document-list.js +1 -0
- package/dist/lists/feature-list/feature-list.js +1 -0
- package/dist/lists/icon-list/icon-list.js +1 -0
- package/dist/lists/menu-list/menu-list-header.js +1 -0
- package/dist/lists/menu-list/use-menu-list-item.js +1 -0
- package/dist/lists/menu-list/use-menu-list.js +1 -0
- package/dist/lists/product-overview-grid/product-overview-grid.js +1 -0
- package/dist/loading/blank-page-spacer.js +1 -0
- package/dist/loading/dynamic-loading-overlay.js +1 -0
- package/dist/loading/loading-overlay.js +1 -0
- package/dist/loading/progress-circle.js +1 -0
- package/dist/media/image-grid/images-grid.d.ts +2 -1
- package/dist/media/image-grid/images-grid.js +2 -2
- package/dist/media/image-lightbox/image-lightbox.d.ts +2 -1
- package/dist/media/image-lightbox/image-lightbox.js +2 -2
- package/dist/message/message.js +1 -0
- package/dist/pages/account/components/create-account-form/create-account-form.js +1 -1
- package/dist/pages/account/create-account-page/create-account-page.js +5 -3
- package/dist/pages/account/layouts/sign-in-page-layout/sign-in-page-layout.d.ts +2 -1
- package/dist/pages/account/layouts/sign-in-page-layout/sign-in-page-layout.js +2 -4
- package/dist/pages/account/sign-in-page/sign-in-page.js +2 -2
- package/dist/pages/checkout/cart-page/cart-page.js +1 -1
- package/dist/pages/checkout/layouts/checkout-page-layout/components/checkout-page-section-content.js +1 -0
- package/dist/pages/checkout/layouts/checkout-page-layout/components/checkout-page-section-header.js +1 -0
- package/dist/pages/checkout/layouts/checkout-page-layout/components/checkout-page-section-link.js +1 -0
- package/dist/pages/checkout/layouts/checkout-page-layout/components/checkout-page-section.js +1 -0
- package/dist/pages/checkout/order-confirmation-page/order-confirmation-page-content.js +1 -1
- package/dist/pages/checkout/payment-page/hooks/use-has-returned-from-adyen.js +1 -0
- package/dist/pages/checkout/shipping-page/hooks/use-patch-shipping-details.js +1 -0
- package/dist/pages/components/page-container/page-container.js +1 -0
- package/dist/pages/components/page-meta-data/page-meta-data.js +1 -0
- package/dist/pages/loading-page/loading-page.js +1 -0
- package/dist/pages/my-sonic/actions/change-password/change-password-dialog.js +1 -0
- package/dist/pages/my-sonic/actions/change-password/change-password.js +1 -0
- package/dist/pages/my-sonic/actions/change-password/connected-change-password-dialog.js +1 -0
- package/dist/pages/my-sonic/navigation/my-sonic-desktop-navigation.js +1 -0
- package/dist/pages/my-sonic/navigation/my-sonic-navigation-items.js +1 -0
- package/dist/pages/my-sonic/widgets/connected-bill-to-address-widget.js +2 -1
- package/dist/pages/my-sonic/widgets/connected-ship-to-address-widget.js +2 -1
- package/dist/pages/product/layouts/product-details-page-layout/product-details-page-layout.js +1 -0
- package/dist/pages/product/product-details-page/components/product-details-images/product-detail-images.js +1 -3
- package/dist/pages/product/product-details-page/components/product-details-images/product-detail-images.module.css.js +1 -1
- package/dist/pages/product/product-details-page/product-details.js +5 -1
- package/dist/pages/product/product-listing-page/no-results/no-results.js +3 -1
- package/dist/promos/promo-banner/promo-banner.js +1 -0
- package/dist/shared/api/bff/hooks/use-fetch-announcements.js +1 -0
- package/dist/shared/api/bff/hooks/use-fetch-navigation-links.js +1 -0
- package/dist/shared/api/bff/hooks/use-fetch-product-details-page-data.js +1 -0
- package/dist/shared/api/bff/hooks/use-fetch-product-listing-page-data.js +1 -0
- package/dist/shared/api/bff/hooks/use-fetch-recently-viewed-products.js +1 -0
- package/dist/shared/api/storefront/hooks/authentication/use-fetch-session.js +1 -0
- package/dist/shared/api/storefront/hooks/authentication/use-invalidate-session.js +1 -0
- package/dist/shared/api/storefront/hooks/authentication/use-is-authenticated.js +1 -0
- package/dist/shared/api/storefront/hooks/authentication/use-patch-session.js +1 -0
- package/dist/shared/api/storefront/hooks/authentication/use-recover-password.js +1 -0
- package/dist/shared/api/storefront/hooks/authentication/use-sign-in.js +1 -0
- package/dist/shared/api/storefront/hooks/authentication/use-sign-out.js +1 -0
- package/dist/shared/api/storefront/hooks/cart/use-add-product-to-current-cart.js +1 -0
- package/dist/shared/api/storefront/hooks/cart/use-delete-cart-line-by-id.js +1 -0
- package/dist/shared/api/storefront/hooks/cart/use-delete-current-cart.js +1 -0
- package/dist/shared/api/storefront/hooks/cart/use-fetch-cart-by-id.js +1 -0
- package/dist/shared/api/storefront/hooks/cart/use-fetch-current-cart-checkout-atp.js +1 -0
- package/dist/shared/api/storefront/hooks/cart/use-fetch-current-cart-count.js +1 -0
- package/dist/shared/api/storefront/hooks/cart/use-fetch-current-cart-lines-with-atp.js +1 -0
- package/dist/shared/api/storefront/hooks/cart/use-fetch-current-cart-lines.js +1 -0
- package/dist/shared/api/storefront/hooks/cart/use-fetch-current-cart-product-atp.js +1 -0
- package/dist/shared/api/storefront/hooks/cart/use-fetch-current-cart-promotions.js +1 -0
- package/dist/shared/api/storefront/hooks/cart/use-fetch-current-cart-with-atp.js +7 -4
- package/dist/shared/api/storefront/hooks/cart/use-fetch-current-cart.js +1 -0
- package/dist/shared/api/storefront/hooks/cart/use-invalidate-current-cart.js +1 -0
- package/dist/shared/api/storefront/hooks/cart/use-patch-cart-line-by-id.js +1 -0
- package/dist/shared/api/storefront/hooks/cart/use-patch-cart.js +1 -0
- package/dist/shared/api/storefront/hooks/cart/use-place-order.js +1 -0
- package/dist/shared/api/storefront/hooks/cart/use-save-cart-for-later.js +1 -0
- package/dist/shared/api/storefront/hooks/customer/use-fetch-bill-to-address.js +1 -0
- package/dist/shared/api/storefront/hooks/customer/use-fetch-bill-to-addresses.js +1 -0
- package/dist/shared/api/storefront/hooks/customer/use-fetch-current-bill-to-address.js +1 -0
- package/dist/shared/api/storefront/hooks/customer/use-fetch-current-ship-to-address.js +1 -0
- package/dist/shared/api/storefront/hooks/customer/use-fetch-fulfillment-methods-by-customer-id.js +1 -0
- package/dist/shared/api/storefront/hooks/customer/use-fetch-fulfillment-methods-for-current-cart.js +1 -0
- package/dist/shared/api/storefront/hooks/customer/use-fetch-ship-to-address.js +1 -0
- package/dist/shared/api/storefront/hooks/customer/use-fetch-ship-to-addresses.js +1 -0
- package/dist/shared/api/storefront/hooks/customer/use-patch-bill-to-address.js +1 -0
- package/dist/shared/api/storefront/hooks/customer/use-patch-ship-to-address.js +1 -0
- package/dist/shared/api/storefront/hooks/customer/use-post-ship-to-address.js +1 -0
- package/dist/shared/api/storefront/hooks/orders/use-fetch-orders.js +1 -0
- package/dist/shared/api/storefront/hooks/payment/use-create-adyen-session.js +1 -0
- package/dist/shared/api/storefront/hooks/payment/use-fetch-adyen-config.js +1 -0
- package/dist/shared/api/storefront/hooks/payment/use-invalidate-adyen.js +1 -0
- package/dist/shared/api/storefront/hooks/product/use-mark-product-as-viewed.d.ts +5 -3
- package/dist/shared/api/storefront/hooks/product/use-mark-product-as-viewed.js +5 -8
- package/dist/shared/api/storefront/hooks/translation/use-fetch-translations.js +1 -0
- package/dist/shared/api/storefront/hooks/website/use-fetch-countries-languages.js +1 -0
- package/dist/shared/api/storefront/hooks/website/use-fetch-countries-with-languages.js +1 -0
- package/dist/shared/api/storefront/hooks/website/use-fetch-country-models.js +1 -0
- package/dist/shared/api/storefront/hooks/website/use-fetch-settings.js +1 -0
- package/dist/shared/api/storefront/hooks/website/use-update-locale.js +1 -0
- package/dist/shared/api/storefront/hooks/wishlist/use-add-wishlist-item-to-current-wishlist.js +1 -0
- package/dist/shared/api/storefront/hooks/wishlist/use-add-wishlist-item-to-wishlist.js +1 -1
- package/dist/shared/api/storefront/hooks/wishlist/use-create-wishlist.js +1 -0
- package/dist/shared/api/storefront/hooks/wishlist/use-delete-wishlist-item-from-wishlist.js +1 -0
- package/dist/shared/api/storefront/hooks/wishlist/use-fetch-all-wishlists-items.js +1 -1
- package/dist/shared/api/storefront/hooks/wishlist/use-fetch-wishlists.js +1 -0
- package/dist/shared/api/storefront/services/website-service.js +9 -0
- package/dist/shared/feature-flags/use-feature-flags.js +1 -0
- package/dist/shared/hooks/use-debounced-callback.d.ts +5 -1
- package/dist/shared/hooks/use-debounced-callback.js +10 -10
- package/dist/shared/providers/react-query-container.d.ts +8 -3
- package/dist/shared/providers/react-query-container.js +4 -4
- package/dist/shared/routing/route-provider.d.ts +1 -0
- package/dist/shared/routing/types.d.ts +1 -0
- package/dist/shared/routing/use-location.js +2 -2
- package/dist/sidebar/sidebar-provider.js +0 -2
- package/dist/styles.css +31 -1
- package/dist/table/elements/col.js +1 -0
- package/dist/table/elements/use-table-row.js +1 -0
- package/dist/table/elements/use-table.js +1 -0
- package/dist/table/elements/use-td.js +1 -0
- package/dist/table/elements/use-th.js +1 -0
- package/dist/text/highlight-text/highlight-text.js +1 -0
- package/dist/text/truncated/truncated.js +1 -0
- package/package.json +3 -3
- package/dist/shared/hooks/use-cookie.js +0 -34
package/dist/badges/tag/tag.js
CHANGED
|
@@ -5,32 +5,23 @@ import clsx from 'clsx';
|
|
|
5
5
|
import { Link } from '../buttons/link/link.js';
|
|
6
6
|
import { GlyphsChevronsSlimLeftIcon } from '../icons/glyph/glyphs-chevrons-slim-left-icon.js';
|
|
7
7
|
import { SolidHomeIcon } from '../icons/solid/solid-home-icon.js';
|
|
8
|
-
import { useIsBreakpoint } from '../shared/hooks/use-is-breakpoint.js';
|
|
9
8
|
import styles from './breadcrumb.module.css.js';
|
|
10
9
|
|
|
11
|
-
function
|
|
10
|
+
function Breadcrumb({ links }) {
|
|
11
|
+
if (links.length <= 1)
|
|
12
|
+
return null;
|
|
13
|
+
const linksWithoutFirst = links.slice(1);
|
|
12
14
|
const homeLink = links[0];
|
|
13
15
|
const previousLink = links.at(-2);
|
|
14
16
|
const isHomeLink = previousLink === undefined || previousLink === homeLink;
|
|
15
17
|
const href = previousLink?.href || homeLink?.href;
|
|
16
18
|
const label = previousLink?.label || homeLink?.label;
|
|
17
|
-
return (jsx(Breadcrumbs, { className: styles.breadcrumbs, children: jsx(Breadcrumb$1, { className: styles.breadcrumb, children: jsxs(Link, { className: styles.link, href: href, isDisabled: false, title: label, children: [jsx(GlyphsChevronsSlimLeftIcon, { className: styles.icon }), isHomeLink ? (jsx(SolidHomeIcon, { className: styles.icon })) : (jsx("span", { children: previousLink.label }))] }) }) }));
|
|
18
|
-
}
|
|
19
|
-
function BreadcrumbLongItem({ index, isDisabled, link, }) {
|
|
20
|
-
return (jsx(Breadcrumb$1, { className: styles.breadcrumb, children: jsxs(Link, { className: styles.link, color: "secondary", href: link.href, isDisabled: isDisabled, title: link.label, children: [jsx(GlyphsChevronsSlimLeftIcon, { className: clsx(styles['previous-icon'], styles.icon) }), link.label] }) }, index));
|
|
21
|
-
}
|
|
22
|
-
function BreadcrumbLong({ links }) {
|
|
23
|
-
const linksWithoutFirst = links.slice(1);
|
|
24
|
-
const homeLink = links[0];
|
|
25
19
|
if (!homeLink)
|
|
26
20
|
return null;
|
|
27
|
-
return (jsxs(Breadcrumbs, { className: styles.breadcrumbs, children: [jsx(Breadcrumb$1, { className: styles.breadcrumb, children: jsx(Link, { className: styles.link, href: homeLink.href, title: homeLink.label, children: jsx(SolidHomeIcon, { className: clsx(styles['home-icon'], styles.icon) }) }) }), linksWithoutFirst.map((link, index) => (jsx(BreadcrumbLongItem, { index: index, isDisabled: linksWithoutFirst.length - 1 === index, link: link }, link.href + link.label || index)))] }));
|
|
21
|
+
return (jsxs(Breadcrumbs, { className: styles.breadcrumbs, children: [jsx(Breadcrumb$1, { className: clsx(styles.breadcrumb, styles.short), children: jsxs(Link, { className: styles.link, href: href, isDisabled: false, title: label, children: [jsx(GlyphsChevronsSlimLeftIcon, { className: styles.icon }), isHomeLink ? (jsx(SolidHomeIcon, { className: styles.icon })) : (jsx("span", { children: previousLink.label }))] }) }), jsx(Breadcrumb$1, { className: clsx(styles.breadcrumb, styles.long), children: jsx(Link, { className: styles.link, href: homeLink.href, title: homeLink.label, children: jsx(SolidHomeIcon, { className: clsx(styles['home-icon'], styles.icon) }) }) }), linksWithoutFirst.map((link, index) => (jsx(BreadcrumbLongItem, { index: index, isDisabled: linksWithoutFirst.length - 1 === index, link: link }, link.href + link.label || index)))] }));
|
|
28
22
|
}
|
|
29
|
-
function
|
|
30
|
-
|
|
31
|
-
if (links.length <= 1)
|
|
32
|
-
return null;
|
|
33
|
-
return isLg ? BreadcrumbLong({ links }) : BreadcrumbShort({ links });
|
|
23
|
+
function BreadcrumbLongItem({ index, isDisabled, link, }) {
|
|
24
|
+
return (jsx(Breadcrumb$1, { className: clsx(styles.breadcrumb, styles.long), children: jsxs(Link, { className: styles.link, color: "secondary", href: link.href, isDisabled: isDisabled, title: link.label, children: [jsx(GlyphsChevronsSlimLeftIcon, { className: clsx(styles['previous-icon'], styles.icon) }), link.label] }) }, index));
|
|
34
25
|
}
|
|
35
26
|
|
|
36
27
|
export { Breadcrumb };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var styles = {"breadcrumbs":"breadcrumb-module-CQGse","breadcrumb":"breadcrumb-module-hxhDY","link":"breadcrumb-module-fp2Q6","icon":"breadcrumb-module-uIn3w","previous-icon":"breadcrumb-module-K-wMJ"};
|
|
1
|
+
var styles = {"breadcrumbs":"breadcrumb-module-CQGse","breadcrumb":"breadcrumb-module-hxhDY","link":"breadcrumb-module-fp2Q6","icon":"breadcrumb-module-uIn3w","previous-icon":"breadcrumb-module-K-wMJ","short":"breadcrumb-module-ToeDB","long":"breadcrumb-module-np5GK"};
|
|
2
2
|
|
|
3
3
|
export { styles as default };
|
|
@@ -3,5 +3,5 @@ interface AddToCartButtonProps {
|
|
|
3
3
|
onChange: (quantity: number) => void;
|
|
4
4
|
quantity: number;
|
|
5
5
|
}
|
|
6
|
-
export declare function AddToCartButton({ isDisabled, onChange, quantity, }: AddToCartButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export declare function AddToCartButton({ isDisabled, onChange: _onChange, quantity: _quantity, }: AddToCartButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
7
7
|
export {};
|
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
2
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
3
|
import { useState, useRef, useEffect, useCallback, useMemo } from 'react';
|
|
4
4
|
import clsx from 'clsx';
|
|
5
5
|
import { NumberField } from '../../forms/fields/number-field/number-field.js';
|
|
6
6
|
import { SolidCartIcon } from '../../icons/solid/solid-cart-icon.js';
|
|
7
7
|
import { useFormattedMessage } from '../../intl/use-formatted-message.js';
|
|
8
|
+
import { useDebouncedCallback } from '../../shared/hooks/use-debounced-callback.js';
|
|
8
9
|
import { ensureNumber } from '../../shared/utils/number.js';
|
|
9
10
|
import { Button } from '../button/button.js';
|
|
10
11
|
import styles from './add-to-cart-button.module.css.js';
|
|
11
12
|
|
|
12
|
-
function AddToCartButton({ isDisabled = false, onChange, quantity, }) {
|
|
13
|
-
return (jsx(InternalAddToCartButton, { isDisabled: isDisabled, onChange: onChange, quantity: quantity }));
|
|
14
|
-
}
|
|
15
|
-
function InternalAddToCartButton({ isDisabled = false, onChange: _onChange, quantity: _quantity, }) {
|
|
13
|
+
function AddToCartButton({ isDisabled = false, onChange: _onChange, quantity: _quantity, }) {
|
|
16
14
|
const [quantity, setQuantity] = useState(_quantity);
|
|
17
15
|
const [currentState, setState] = useState(quantity > 0 ? 'input' : 'initial');
|
|
18
16
|
const [hasFocus, setHasFocus] = useState(false);
|
|
@@ -60,7 +58,6 @@ function InitialState({ buttonRef, hasFocus, isDisabled, onAddToCart, onHasFocus
|
|
|
60
58
|
onAddToCart();
|
|
61
59
|
}, size: "md" }));
|
|
62
60
|
}
|
|
63
|
-
let debounced;
|
|
64
61
|
/* input state: spinner buttons and manual input */
|
|
65
62
|
function InputState({ hasFocus, inputRef, isDisabled, onChange: _onChange, onHasFocussed, quantity, }) {
|
|
66
63
|
const t = useFormattedMessage();
|
|
@@ -68,6 +65,7 @@ function InputState({ hasFocus, inputRef, isDisabled, onChange: _onChange, onHas
|
|
|
68
65
|
const [manualQuantity, setManualQuantity] = useState(null);
|
|
69
66
|
const isManualInput = useMemo(() => manualQuantity !== null, [manualQuantity]);
|
|
70
67
|
const isSpinnerInput = useMemo(() => manualQuantity === null, [manualQuantity]);
|
|
68
|
+
const onChangeDebounced = useDebouncedCallback((quantity) => _onChange(quantity), 1500);
|
|
71
69
|
useEffect(() => {
|
|
72
70
|
if (hasFocus) {
|
|
73
71
|
inputRef?.current?.focus();
|
|
@@ -78,28 +76,29 @@ function InputState({ hasFocus, inputRef, isDisabled, onChange: _onChange, onHas
|
|
|
78
76
|
useEffect(() => {
|
|
79
77
|
// clear debounced when switching to manual input or when quantity is 0 (returning to initial state)
|
|
80
78
|
if (isManualInput)
|
|
81
|
-
|
|
82
|
-
}, [isManualInput]);
|
|
79
|
+
onChangeDebounced.cancel();
|
|
80
|
+
}, [isManualInput, onChangeDebounced]);
|
|
83
81
|
const onKeyUp = (e) => {
|
|
84
82
|
if (isSpinnerInput)
|
|
85
83
|
return;
|
|
86
84
|
if (e.key === 'Enter')
|
|
87
85
|
confirmManualQuantity();
|
|
88
86
|
if (e.key === 'Escape') {
|
|
87
|
+
/* returns to spinner input and restarts a debounce timer for the internalQuantity on the field */
|
|
89
88
|
setManualQuantity(null);
|
|
90
|
-
|
|
89
|
+
onChangeDebounced(internalQuantity);
|
|
91
90
|
}
|
|
92
91
|
};
|
|
93
92
|
const onSpinnerChange = (quantity) => {
|
|
94
|
-
|
|
93
|
+
if (Number.isNaN(quantity))
|
|
94
|
+
return;
|
|
95
95
|
setInternalQuantity(quantity);
|
|
96
96
|
if (quantity === 0) {
|
|
97
|
+
onChangeDebounced.cancel();
|
|
97
98
|
_onChange(0);
|
|
98
99
|
}
|
|
99
100
|
else {
|
|
100
|
-
|
|
101
|
-
_onChange(quantity);
|
|
102
|
-
}, 1500);
|
|
101
|
+
onChangeDebounced(quantity);
|
|
103
102
|
}
|
|
104
103
|
};
|
|
105
104
|
const onManualInput = (e) => {
|
|
@@ -20,14 +20,15 @@ function AccordionItem({ _pseudo = 'none', allowCollapse = true, allowToggle = t
|
|
|
20
20
|
}
|
|
21
21
|
}, [close, initialIsOpen, open]);
|
|
22
22
|
const panelId = `panel-${id}`;
|
|
23
|
-
return (jsxs("div", { className: clsx(className, ...ensureArray(borderType).map(type => styles[`border-type-${type}`]), styles['accordion-item'], isDisabled && styles.disabled, {
|
|
23
|
+
return (jsxs("div", { suppressHydrationWarning: true, className: clsx(className, ...ensureArray(borderType).map(type => styles[`border-type-${type}`]), styles['accordion-item'], isDisabled && styles.disabled, {
|
|
24
24
|
[styles['is-open']]: isOpen,
|
|
25
|
-
[styles['allow-collapse']]: allowCollapse,
|
|
26
25
|
[styles['allow-toggle']]: allowCollapse && allowToggle,
|
|
27
|
-
}), "data-test-selector": dataTestSelector, children: [jsx(Heading, { className: styles.heading, tag: "h3", children:
|
|
28
|
-
|
|
26
|
+
}), "data-test-selector": dataTestSelector, children: [jsx(Heading, { className: styles.heading, tag: "h3", children: jsxs("button", { suppressHydrationWarning: true, "aria-controls": panelId, "aria-expanded": isOpen, className: clsx(styles.button, styles[_pseudo], {
|
|
27
|
+
[styles['disable-collapse']]: !allowCollapse,
|
|
28
|
+
}), disabled: isDisabled, id: id, onClick: () => {
|
|
29
|
+
if (allowToggle && allowCollapse)
|
|
29
30
|
toggle();
|
|
30
|
-
}, tabIndex: allowToggle ? 0 : -1, type: "button", children: [title, jsx("span", { className: styles.icon, children: size === 'lg' ? (jsx(GlyphsChevronsBoldDownIcon, {})) : (jsx(GlyphsChevronsSlimDownIcon, {})) })] })
|
|
31
|
+
}, tabIndex: allowToggle ? 0 : -1, type: "button", children: [title, jsx("span", { className: styles.icon, children: size === 'lg' ? (jsx(GlyphsChevronsBoldDownIcon, {})) : (jsx(GlyphsChevronsSlimDownIcon, {})) })] }) }), jsx("div", { "aria-labelledby": id, className: styles.panel, id: panelId, role: "region", children: jsx("div", { className: styles.content, children: children }) })] }));
|
|
31
32
|
}
|
|
32
33
|
|
|
33
34
|
export { AccordionItem };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var styles = {"accordion":"accordion-module-9WvAH","indented":"accordion-module-6CcEH","white":"accordion-module-CaVdG","accordion-item":"accordion-module-lf9d-","lg":"accordion-module-0qnae","with-seperators":"accordion-module-yOLrW","heading":"accordion-module-d-B4T","button":"accordion-module--Rwpb","icon":"accordion-module-Y50uq","focus":"accordion-module-M4BZs","allow-toggle":"accordion-module-QEO2d","panel":"accordion-module-KZjMo","content":"accordion-module-ejMH3","border-type-bottom":"accordion-module-oTdZK","border-type-top":"accordion-module-0mrLq","border-type-middle":"accordion-module-aAr-R","is-open":"accordion-module-W0F1z","border-type-middle-accentuated":"accordion-module-OB98a","select":"accordion-module-SAbiG","disabled":"accordion-module-ogvYX"};
|
|
1
|
+
var styles = {"accordion":"accordion-module-9WvAH","indented":"accordion-module-6CcEH","white":"accordion-module-CaVdG","accordion-item":"accordion-module-lf9d-","lg":"accordion-module-0qnae","with-seperators":"accordion-module-yOLrW","heading":"accordion-module-d-B4T","button":"accordion-module--Rwpb","icon":"accordion-module-Y50uq","focus":"accordion-module-M4BZs","allow-toggle":"accordion-module-QEO2d","panel":"accordion-module-KZjMo","content":"accordion-module-ejMH3","border-type-bottom":"accordion-module-oTdZK","border-type-top":"accordion-module-0mrLq","border-type-middle":"accordion-module-aAr-R","is-open":"accordion-module-W0F1z","border-type-middle-accentuated":"accordion-module-OB98a","disable-collapse":"accordion-module-RnNRT","select":"accordion-module-SAbiG","disabled":"accordion-module-ogvYX"};
|
|
2
2
|
|
|
3
3
|
export { styles as default };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import Cookies from 'js-cookie';
|
|
2
|
+
import { config } from '../config.js';
|
|
3
|
+
import { TIME } from '../shared/utils/time.js';
|
|
4
|
+
|
|
5
|
+
const defaultCookieOptions = {
|
|
6
|
+
domain: config.COOKIE_DOMAIN,
|
|
7
|
+
expires: new Date(Date.now() + TIME.DAY * 356), // 365,
|
|
8
|
+
path: '/',
|
|
9
|
+
sameSite: 'none',
|
|
10
|
+
secure: true,
|
|
11
|
+
};
|
|
12
|
+
function get(name) {
|
|
13
|
+
if (name)
|
|
14
|
+
return Cookies.get(name);
|
|
15
|
+
return Cookies.get();
|
|
16
|
+
}
|
|
17
|
+
function set(name, value, options) {
|
|
18
|
+
if (value) {
|
|
19
|
+
Cookies.set(name, value, options);
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
Cookies.remove(name);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
const clientCookieContextValue = {
|
|
26
|
+
get,
|
|
27
|
+
set,
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export { clientCookieContextValue, defaultCookieOptions };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { clientCookieContextValue } from './client-cookie-context.js';
|
|
4
|
+
import { CookieContext } from './cookie-context.js';
|
|
5
|
+
|
|
6
|
+
function CookieProvider({ children, value = clientCookieContextValue, }) {
|
|
7
|
+
return (jsx(CookieContext.Provider, { value: value, children: children }));
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export { CookieProvider };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { logger } from '../logging/logger.js';
|
|
2
|
+
|
|
3
|
+
function set(name, value, _options) {
|
|
4
|
+
logger.warn('Attempted to set a cookie on a readonly cookie reader', {
|
|
5
|
+
name,
|
|
6
|
+
value,
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
function createReadonlyCookieReader(cookies) {
|
|
10
|
+
function get(name) {
|
|
11
|
+
if (name)
|
|
12
|
+
return cookies[name];
|
|
13
|
+
return cookies;
|
|
14
|
+
}
|
|
15
|
+
return { get, set };
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export { createReadonlyCookieReader };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface CookieAttributes {
|
|
2
|
+
domain?: string | undefined;
|
|
3
|
+
expires?: Date | undefined;
|
|
4
|
+
path?: string | undefined;
|
|
5
|
+
sameSite?: 'lax' | 'strict' | 'none' | undefined;
|
|
6
|
+
secure?: boolean | undefined;
|
|
7
|
+
}
|
|
8
|
+
export interface CookieGetterSetter {
|
|
9
|
+
get(): Record<string, string> | undefined;
|
|
10
|
+
get(name: string): string | undefined;
|
|
11
|
+
set(name: string, value: string | undefined, options?: CookieAttributes): void;
|
|
12
|
+
}
|
|
13
|
+
export type CookieContextValue = CookieGetterSetter | Record<string, string>;
|
|
14
|
+
export declare function isCookieGetterSetter(value: CookieContextValue): value is CookieGetterSetter;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { CookieAttributes } from '
|
|
2
|
-
export declare const defaultCookieOptions: CookieAttributes;
|
|
1
|
+
import { CookieAttributes } from './types';
|
|
3
2
|
interface SetValueFn {
|
|
4
3
|
(value: string | undefined): void;
|
|
5
4
|
(fn: (value: string | undefined) => string | undefined): void;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useContext, useState } from 'react';
|
|
3
|
+
import { defaultCookieOptions, clientCookieContextValue } from './client-cookie-context.js';
|
|
4
|
+
import { CookieContext } from './cookie-context.js';
|
|
5
|
+
import { createReadonlyCookieReader } from './readonly-cookie-reader.js';
|
|
6
|
+
import { isCookieGetterSetter } from './types.js';
|
|
7
|
+
|
|
8
|
+
function useCookie(name, options = defaultCookieOptions) {
|
|
9
|
+
const context = useContext(CookieContext);
|
|
10
|
+
const Cookies = context
|
|
11
|
+
? isCookieGetterSetter(context)
|
|
12
|
+
? context
|
|
13
|
+
: createReadonlyCookieReader(context)
|
|
14
|
+
: clientCookieContextValue;
|
|
15
|
+
const cookieValue = Cookies.get()?.[name];
|
|
16
|
+
const [stateValue, setStateValue] = useState(cookieValue);
|
|
17
|
+
if (cookieValue !== stateValue) {
|
|
18
|
+
setStateValue(cookieValue);
|
|
19
|
+
}
|
|
20
|
+
function setValue(valueOrFn) {
|
|
21
|
+
setStateValue(oldValue => {
|
|
22
|
+
const newValue = typeof valueOrFn === 'function' ? valueOrFn(oldValue) : valueOrFn;
|
|
23
|
+
Cookies.set(name, newValue, options);
|
|
24
|
+
return newValue;
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
return [stateValue, setValue];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export { useCookie };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import { useMemo } from 'react';
|
|
3
|
+
import { useCookie } from '../../cookies/use-cookie.js';
|
|
2
4
|
import { isCountryCode, isCultureCode, isLanguageCode } from '../../intl/types.js';
|
|
3
5
|
import { useFetchCountriesWithLanguages } from '../../shared/api/storefront/hooks/website/use-fetch-countries-with-languages.js';
|
|
4
|
-
import { useCookie } from '../../shared/hooks/use-cookie.js';
|
|
5
6
|
import { useSessionStorage } from '../../shared/hooks/use-session-storage.js';
|
|
6
7
|
|
|
7
8
|
function useCountries({ enabled = true, } = {}) {
|
|
@@ -38,7 +38,7 @@ function ConnectedCountrySelector({ defaultCountryCode, defaultLanguageCode, onC
|
|
|
38
38
|
logger.error('Error fetching countries and languages:', error);
|
|
39
39
|
return null;
|
|
40
40
|
}
|
|
41
|
-
return (jsxs(Fragment, { children: [jsx(CountrySelectorTrigger, { onClick: open, selectedCountry: selectedCountry, selectedLanguage: selectedLanguage, showCountry: showCountry }), jsx(CountrySelectorDialog, { countries: countries, isDismissable: isDismissable, isOpen: isOpen, onOpenChange: open => {
|
|
41
|
+
return (jsxs(Fragment, { children: [jsx(CountrySelectorTrigger, { onClick: open, selectedCountry: selectedCountry || defaultCountry, selectedLanguage: selectedLanguage || defaultLanguage, showCountry: showCountry }), jsx(CountrySelectorDialog, { countries: countries, isDismissable: isDismissable, isOpen: isOpen, onOpenChange: open => {
|
|
42
42
|
if (!isDismissable)
|
|
43
43
|
return;
|
|
44
44
|
setIsOpen(open);
|
|
@@ -1,24 +1,16 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useEffect } from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import { useCookie } from '../cookies/use-cookie.js';
|
|
4
4
|
import { useFetchCountriesWithLanguages } from '../shared/api/storefront/hooks/website/use-fetch-countries-with-languages.js';
|
|
5
5
|
import { updateLocale } from '../shared/api/storefront/services/website-service.js';
|
|
6
|
-
import { useCookie } from '../shared/hooks/use-cookie.js';
|
|
7
6
|
import { useSessionStorage } from '../shared/hooks/use-session-storage.js';
|
|
8
7
|
import { isCountry } from '../shared/model/countries-languages.js';
|
|
9
8
|
|
|
10
|
-
const cookieOptions = {
|
|
11
|
-
domain: config.COOKIE_DOMAIN,
|
|
12
|
-
expires: 365,
|
|
13
|
-
path: '/',
|
|
14
|
-
sameSite: 'None',
|
|
15
|
-
secure: true,
|
|
16
|
-
};
|
|
17
9
|
function useCountriesLanguages({ defaultCountryCode, defaultLanguageCode, }) {
|
|
18
10
|
const [sessionCountries, setSessionCountries] = useSessionStorage('countries-v1');
|
|
19
|
-
const [currentCountryId] = useCookie('CurrentCountryId'
|
|
11
|
+
const [currentCountryId] = useCookie('CurrentCountryId');
|
|
20
12
|
// const [currentLanguageId] = ['be71b608-4876-420a-b1f5-adfe0093a72a'] // useCookie('CurrentLanguageId', cookieOptions)
|
|
21
|
-
const [currentLanguageId] = useCookie('CurrentLanguageId'
|
|
13
|
+
const [currentLanguageId] = useCookie('CurrentLanguageId');
|
|
22
14
|
const hasSessionCountries = Boolean(sessionCountries?.length);
|
|
23
15
|
const { data: apiCountries, error, isFetching, } = useFetchCountriesWithLanguages({
|
|
24
16
|
enabled: !hasSessionCountries,
|
package/dist/exports.d.ts
CHANGED
|
@@ -72,6 +72,12 @@ export * from './collapsables/show-all/show-all';
|
|
|
72
72
|
export * from './collapsables/unmounter/unmounter';
|
|
73
73
|
export * from './collapsables/unmounter/utils';
|
|
74
74
|
export * from './config';
|
|
75
|
+
export * from './cookies/client-cookie-context';
|
|
76
|
+
export * from './cookies/cookie-context';
|
|
77
|
+
export * from './cookies/cookie-provider';
|
|
78
|
+
export * from './cookies/readonly-cookie-reader';
|
|
79
|
+
export * from './cookies/types';
|
|
80
|
+
export * from './cookies/use-cookie';
|
|
75
81
|
export * from './country-select/country-select';
|
|
76
82
|
export * from './country-select/hooks/use-countries';
|
|
77
83
|
export * from './country-selector/connected-country-selector';
|
|
@@ -374,7 +380,6 @@ export * from './shared/ga/google-analytics-provider';
|
|
|
374
380
|
export * from './shared/ga/types';
|
|
375
381
|
export * from './shared/ga/use-data-layer';
|
|
376
382
|
export * from './shared/hooks/use-breakpoint';
|
|
377
|
-
export * from './shared/hooks/use-cookie';
|
|
378
383
|
export * from './shared/hooks/use-cookiebot';
|
|
379
384
|
export * from './shared/hooks/use-css-link';
|
|
380
385
|
export * from './shared/hooks/use-debounced-callback';
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx } from 'react/jsx-runtime';
|
|
3
|
-
import { useMemo } from 'react';
|
|
4
3
|
import { IconButton } from '../../../buttons/icon-button/icon-button.js';
|
|
5
4
|
import { useFormattedMessage } from '../../../intl/use-formatted-message.js';
|
|
6
5
|
import { AccountIcon } from '../../../navigation/account-icon/account-icon.js';
|
|
@@ -12,13 +11,7 @@ function ConnectedAccountButton({ className, 'data-test-selector': dataTestSelec
|
|
|
12
11
|
const paths = usePaths();
|
|
13
12
|
const t = useFormattedMessage();
|
|
14
13
|
const isAuthenticated = useIsAuthenticated();
|
|
15
|
-
const
|
|
16
|
-
const href = useMemo(() =>
|
|
17
|
-
// TODO: Replace with relative URL when migrated away from Umbraco
|
|
18
|
-
typeof location === 'undefined' ? undefined : location.href,
|
|
19
|
-
// Using the location hook to detect url changes, but not using it directly
|
|
20
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
21
|
-
[_location]);
|
|
14
|
+
const { href } = useLocation();
|
|
22
15
|
return (jsx(IconButton, { className: className, "data-authenticated": isAuthenticated ? true : false, "data-test-selector": dataTestSelector, href: isAuthenticated
|
|
23
16
|
? paths.ACCOUNT
|
|
24
17
|
: `${paths.SIGN_IN}${href ? `?returnUrl=${encodeURIComponent(href)}` : ''}`, onClick: onClick, children: jsx(AccountIcon, { "aria-label": isAuthenticated ? t('My Sonic') : t('Sign in or create account'), isAuthenticated: isAuthenticated }) }));
|