@sonic-equipment/ui 259.0.2 → 260.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/algolia/algolia-active-categories.js +2 -2
- package/dist/algolia/algolia-categories-filters.js +2 -2
- package/dist/badges/badge/badge.d.ts +5 -3
- package/dist/badges/badge/badge.js +4 -4
- package/dist/badges/badge/badge.module.css.js +1 -1
- package/dist/badges/badge/icon-with-badge/icon-with-badge.d.ts +11 -6
- package/dist/badges/badge/icon-with-badge/icon-with-badge.js +5 -2
- package/dist/badges/badge/icon-with-badge/icon-with-badge.module.css.js +1 -1
- package/dist/base.css +2 -2
- package/dist/breadcrumbs/breadcrumb.js +3 -4
- package/dist/buttons/add-to-cart-button/add-to-cart-button.js +2 -2
- package/dist/buttons/button/button.js +2 -2
- package/dist/buttons/close-button/close-button.d.ts +12 -0
- package/dist/buttons/close-button/close-button.js +11 -0
- package/dist/buttons/close-button/close-button.module.css.js +3 -0
- package/dist/buttons/favorite/favorite-button.js +3 -3
- package/dist/buttons/icon-button/icon-button.d.ts +13 -5
- package/dist/buttons/icon-button/icon-button.js +6 -5
- package/dist/buttons/icon-button/icon-button.module.css.js +1 -1
- package/dist/buttons/link/link.d.ts +2 -0
- package/dist/buttons/link/link.js +4 -7
- package/dist/cards/orderline-card/connected-remove-button.js +1 -2
- package/dist/carousel/carousel-navigation-button.js +2 -3
- package/dist/collapsables/accordion/accordion-item.js +2 -3
- package/dist/collapsables/show-all/show-all.js +2 -2
- package/dist/collapsables/unmounter/utils.js +4 -1
- package/dist/country-language-selection-list/connected-country-language-selection-list.d.ts +1 -0
- package/dist/country-language-selection-list/connected-country-language-selection-list.js +268 -0
- package/dist/country-language-selection-list/country-language-selection-list.d.ts +18 -0
- package/dist/country-language-selection-list/country-language-selection-list.js +54 -0
- package/dist/country-language-selection-list/country-language-selection-list.module.css.js +3 -0
- package/dist/country-language-selector/connected-country-language-selector.d.ts +10 -0
- package/dist/country-language-selector/connected-country-language-selector.js +129 -0
- package/dist/country-language-selector/country-language-selector.d.ts +18 -0
- package/dist/country-language-selector/country-language-selector.js +52 -0
- package/dist/country-language-selector/country-language-selector.module.css.js +3 -0
- package/dist/country-language-selector-button/connected-country-language-selector-button.d.ts +1 -0
- package/dist/country-language-selector-button/connected-country-language-selector-button.js +22 -0
- package/dist/country-language-selector-button/country-language-selector-button.d.ts +7 -0
- package/dist/country-language-selector-button/country-language-selector-button.js +18 -0
- package/dist/country-language-selector-button/country-language-selector-button.module.css.js +3 -0
- package/dist/country-selector/country-selector-trigger/country-selector-trigger.js +2 -2
- package/dist/country-selector/country-selector-trigger/country-selector-trigger.module.css.js +1 -1
- package/dist/country-selector/use-countries-languages.d.ts +2 -2
- package/dist/country-selector/use-countries-languages.js +1 -1
- package/dist/delivery-time/delivery-time.js +1 -1
- package/dist/display/details/details.js +2 -2
- package/dist/exports.d.ts +71 -3
- package/dist/filters/active-filters/active-filters.js +1 -2
- package/dist/filters/active-filters/active-filters.module.css.js +1 -1
- package/dist/filters/pagination/pagination.js +1 -3
- package/dist/filters/pagination/pagination.module.css.js +1 -1
- package/dist/flag/flag.d.ts +8 -0
- package/dist/flag/flag.js +11 -0
- package/dist/flag/flag.module.css.js +3 -0
- package/dist/flags/flag-ad.d.ts +1 -0
- package/dist/flags/flag-ad.js +7 -0
- package/dist/flags/flag-ae.d.ts +1 -0
- package/dist/flags/flag-ae.js +7 -0
- package/dist/flags/flag-al.d.ts +1 -0
- package/dist/flags/flag-al.js +7 -0
- package/dist/flags/flag-at.d.ts +1 -0
- package/dist/flags/flag-at.js +7 -0
- package/dist/flags/flag-ba.d.ts +1 -0
- package/dist/flags/flag-ba.js +7 -0
- package/dist/flags/flag-be.d.ts +1 -0
- package/dist/flags/flag-be.js +7 -0
- package/dist/flags/flag-bg.d.ts +1 -0
- package/dist/flags/flag-bg.js +7 -0
- package/dist/flags/flag-br.d.ts +1 -0
- package/dist/flags/flag-br.js +7 -0
- package/dist/flags/flag-ca.d.ts +1 -0
- package/dist/flags/flag-ca.js +7 -0
- package/dist/flags/flag-ch.d.ts +1 -0
- package/dist/flags/flag-ch.js +7 -0
- package/dist/flags/flag-cy.d.ts +1 -0
- package/dist/flags/flag-cy.js +7 -0
- package/dist/flags/flag-cz.d.ts +1 -0
- package/dist/flags/flag-cz.js +7 -0
- package/dist/flags/flag-de.d.ts +1 -0
- package/dist/flags/flag-de.js +7 -0
- package/dist/flags/flag-dj.d.ts +1 -0
- package/dist/flags/flag-dj.js +7 -0
- package/dist/flags/flag-dk.d.ts +1 -0
- package/dist/flags/flag-dk.js +7 -0
- package/dist/flags/flag-ec.d.ts +1 -0
- package/dist/flags/flag-ec.js +7 -0
- package/dist/flags/flag-ee.d.ts +1 -0
- package/dist/flags/flag-ee.js +7 -0
- package/dist/flags/flag-es.d.ts +1 -0
- package/dist/flags/flag-es.js +7 -0
- package/dist/flags/flag-eu.d.ts +1 -0
- package/dist/flags/flag-eu.js +7 -0
- package/dist/flags/flag-fi.d.ts +1 -0
- package/dist/flags/flag-fi.js +7 -0
- package/dist/flags/flag-fr.d.ts +1 -0
- package/dist/flags/flag-fr.js +7 -0
- package/dist/flags/flag-gb.d.ts +1 -0
- package/dist/flags/flag-gb.js +7 -0
- package/dist/flags/flag-gr.d.ts +1 -0
- package/dist/flags/flag-gr.js +7 -0
- package/dist/flags/flag-hr.d.ts +1 -0
- package/dist/flags/flag-hr.js +7 -0
- package/dist/flags/flag-hu.d.ts +1 -0
- package/dist/flags/flag-hu.js +7 -0
- package/dist/flags/flag-ie.d.ts +1 -0
- package/dist/flags/flag-ie.js +7 -0
- package/dist/flags/flag-iq.d.ts +1 -0
- package/dist/flags/flag-iq.js +7 -0
- package/dist/flags/flag-is.d.ts +1 -0
- package/dist/flags/flag-is.js +7 -0
- package/dist/flags/flag-it.d.ts +1 -0
- package/dist/flags/flag-it.js +7 -0
- package/dist/flags/flag-kw.d.ts +1 -0
- package/dist/flags/flag-kw.js +7 -0
- package/dist/flags/flag-kz.d.ts +1 -0
- package/dist/flags/flag-kz.js +7 -0
- package/dist/flags/flag-lb.d.ts +1 -0
- package/dist/flags/flag-lb.js +7 -0
- package/dist/flags/flag-lt.d.ts +1 -0
- package/dist/flags/flag-lt.js +7 -0
- package/dist/flags/flag-lu.d.ts +1 -0
- package/dist/flags/flag-lu.js +7 -0
- package/dist/flags/flag-lv.d.ts +1 -0
- package/dist/flags/flag-lv.js +7 -0
- package/dist/flags/flag-ma.d.ts +1 -0
- package/dist/flags/flag-ma.js +7 -0
- package/dist/flags/flag-mc.d.ts +1 -0
- package/dist/flags/flag-mc.js +7 -0
- package/dist/flags/flag-md.d.ts +1 -0
- package/dist/flags/flag-md.js +7 -0
- package/dist/flags/flag-me.d.ts +1 -0
- package/dist/flags/flag-me.js +7 -0
- package/dist/flags/flag-mk.d.ts +1 -0
- package/dist/flags/flag-mk.js +7 -0
- package/dist/flags/flag-mt.d.ts +1 -0
- package/dist/flags/flag-mt.js +7 -0
- package/dist/flags/flag-mx.d.ts +1 -0
- package/dist/flags/flag-mx.js +7 -0
- package/dist/flags/flag-my.d.ts +1 -0
- package/dist/flags/flag-my.js +7 -0
- package/dist/flags/flag-nl.d.ts +1 -0
- package/dist/flags/flag-nl.js +7 -0
- package/dist/flags/flag-no.d.ts +1 -0
- package/dist/flags/flag-no.js +7 -0
- package/dist/flags/flag-pl.d.ts +1 -0
- package/dist/flags/flag-pl.js +7 -0
- package/dist/flags/flag-pt.d.ts +1 -0
- package/dist/flags/flag-pt.js +7 -0
- package/dist/flags/flag-ro.d.ts +1 -0
- package/dist/flags/flag-ro.js +7 -0
- package/dist/flags/flag-rs.d.ts +1 -0
- package/dist/flags/flag-rs.js +7 -0
- package/dist/flags/flag-sa.d.ts +1 -0
- package/dist/flags/flag-sa.js +7 -0
- package/dist/flags/flag-se.d.ts +1 -0
- package/dist/flags/flag-se.js +7 -0
- package/dist/flags/flag-sg.d.ts +1 -0
- package/dist/flags/flag-sg.js +7 -0
- package/dist/flags/flag-si.d.ts +1 -0
- package/dist/flags/flag-si.js +7 -0
- package/dist/flags/flag-sk.d.ts +1 -0
- package/dist/flags/flag-sk.js +7 -0
- package/dist/flags/flag-tr.d.ts +1 -0
- package/dist/flags/flag-tr.js +7 -0
- package/dist/flags/flag-tw.d.ts +1 -0
- package/dist/flags/flag-tw.js +7 -0
- package/dist/flags/flag-ua.d.ts +1 -0
- package/dist/flags/flag-ua.js +7 -0
- package/dist/flags/flag-us.d.ts +1 -0
- package/dist/flags/flag-us.js +7 -0
- package/dist/flags/flag-vn.d.ts +1 -0
- package/dist/flags/flag-vn.js +7 -0
- package/dist/flags/flag-xk.d.ts +1 -0
- package/dist/flags/flag-xk.js +7 -0
- package/dist/flags/flag-za.d.ts +1 -0
- package/dist/flags/flag-za.js +7 -0
- package/dist/flags/index.d.ts +1 -0
- package/dist/flags/index.js +88 -0
- package/dist/footer/connected-footer.d.ts +1 -3
- package/dist/footer/connected-footer.js +3 -5
- package/dist/forms/elements/checkbox/checkbox.module.css.js +1 -1
- package/dist/forms/elements/select/select.js +3 -4
- package/dist/forms/fields/number-field/number-field.js +2 -4
- package/dist/forms/fields/search-field/search-field.js +2 -2
- package/dist/forms/fields/select-field/select-field.d.ts +8 -1
- package/dist/forms/fields/select-field/select-field.js +30 -9
- package/dist/forms/fields/select-field/select-field.module.css.js +1 -1
- package/dist/forms/fields/text-field/password-reveal-toggle/password-reveal-toggle.js +2 -3
- package/dist/forms/layout/form/form.js +1 -1
- package/dist/global-search/search-input/search-input.js +5 -4
- package/dist/global-search/search-result-panel/sections/no-search.js +3 -4
- package/dist/global-search/search-result-panel/sections/with-results.js +4 -4
- package/dist/global-search/search-section/search-list-item.js +1 -2
- package/dist/header/buttons/account/connected-account-button.js +1 -2
- package/dist/header/buttons/cart/connected-cart-button.js +1 -2
- package/dist/header/buttons/favorites/connected-favorites-button.js +1 -3
- package/dist/header/buttons/hamburger/hamburger-button.js +1 -1
- package/dist/header/buttons/hamburger/hamburger-button.module.css.js +1 -1
- package/dist/header/buttons/search/search-button.js +1 -2
- package/dist/header/header.js +1 -1
- package/dist/header/link-list/navigation-link-list.js +2 -2
- package/dist/header/link-list/navigation-link-list.module.css.js +1 -1
- package/dist/header/sonic-logo/sonic-logo.js +7 -2
- package/dist/header/sonic-logo/sonic-logo.module.css.js +1 -1
- package/dist/icon/icon.d.ts +10 -0
- package/dist/icon/icon.js +11 -0
- package/dist/icon/icon.module.css.js +3 -0
- package/dist/icons/glyph/glyphs-arrow-boldcaps-left-icon.js +0 -1
- package/dist/icons/glyph/glyphs-arrow-boldcaps-right-icon.js +0 -1
- package/dist/icons/glyph/glyphs-chevrons-bold-down-icon.js +0 -1
- package/dist/icons/glyph/glyphs-chevrons-bold-left-icon.js +7 -0
- package/dist/icons/glyph/glyphs-chevrons-bold-right-icon.js +0 -1
- package/dist/icons/glyph/glyphs-chevrons-bold-up-icon.js +0 -1
- package/dist/icons/glyph/glyphs-chevrons-slim-down-icon.js +0 -1
- package/dist/icons/glyph/glyphs-chevrons-slim-left-icon.js +0 -1
- package/dist/icons/glyph/glyphs-chevrons-slim-right-icon.js +0 -1
- package/dist/icons/glyph/glyphs-chevrons-slim-up-icon.js +7 -0
- package/dist/icons/index.d.ts +87 -0
- package/dist/icons/index.js +90 -0
- package/dist/icons/solid/solid-attention-icon.js +0 -1
- package/dist/icons/solid/solid-cart-icon.js +0 -1
- package/dist/icons/solid/solid-close-icon.js +0 -1
- package/dist/icons/solid/solid-edit-icon.js +0 -1
- package/dist/icons/solid/solid-favorite-icon.js +0 -1
- package/dist/icons/solid/solid-home-icon.js +0 -1
- package/dist/icons/solid/solid-information-icon.js +0 -1
- package/dist/icons/solid/solid-login-icon.js +0 -1
- package/dist/icons/solid/solid-logout-icon.js +0 -1
- package/dist/icons/solid/solid-news-icon.js +0 -1
- package/dist/icons/solid/solid-notice-icon.js +0 -1
- package/dist/icons/solid/solid-okay-icon.js +0 -1
- package/dist/icons/solid/solid-rating-icon.js +0 -1
- package/dist/icons/solid/solid-salecategory-icon.js +0 -1
- package/dist/icons/solid/solid-tag-icon.js +0 -1
- package/dist/icons/stroke/stroke-arrowdown-icon.d.ts +1 -0
- package/dist/icons/stroke/stroke-arrowleft-icon.d.ts +1 -0
- package/dist/icons/stroke/stroke-arrowleft-icon.js +7 -0
- package/dist/icons/stroke/stroke-arrowright-icon.d.ts +1 -0
- package/dist/icons/stroke/stroke-arrowright-icon.js +7 -0
- package/dist/icons/stroke/stroke-arrowup-icon.d.ts +1 -0
- package/dist/icons/stroke/stroke-categories-icon.js +0 -1
- package/dist/icons/stroke/stroke-checkmark-icon.js +0 -1
- package/dist/icons/stroke/stroke-closebox-icon.js +0 -1
- package/dist/icons/stroke/stroke-dehashed-icon.js +0 -1
- package/dist/icons/stroke/stroke-download-icon.js +0 -1
- package/dist/icons/stroke/stroke-event-icon.js +0 -1
- package/dist/icons/stroke/stroke-favorite-icon.js +0 -1
- package/dist/icons/stroke/stroke-filter-icon.js +0 -1
- package/dist/icons/stroke/stroke-hashed-icon.js +0 -1
- package/dist/icons/stroke/stroke-information-icon.js +0 -1
- package/dist/icons/stroke/stroke-minus-icon.js +0 -1
- package/dist/icons/stroke/stroke-notice-icon.js +7 -0
- package/dist/icons/stroke/stroke-plus-icon.js +0 -1
- package/dist/icons/stroke/stroke-recent-icon.js +0 -1
- package/dist/icons/stroke/stroke-search-icon.js +0 -1
- package/dist/icons/stroke/stroke-trash-icon.js +0 -1
- package/dist/index.js +72 -4
- package/dist/info-icon-tooltip/info-icon-tooltip.d.ts +3 -1
- package/dist/info-icon-tooltip/info-icon-tooltip.js +6 -8
- package/dist/intl/intl-context.d.ts +2 -0
- package/dist/intl/intl-provider.js +5 -0
- package/dist/intl/translation-id.d.ts +1 -1
- package/dist/intl/types.d.ts +3 -0
- package/dist/intl/types.js +6 -1
- package/dist/lists/download-document-list/download-document-list.js +4 -8
- package/dist/lists/download-document-list/download-document-list.module.css.js +1 -1
- package/dist/lists/feature-list/feature-list.js +5 -4
- package/dist/lists/feature-list/feature-list.module.css.js +1 -1
- package/dist/lists/icon-list/icon-list.d.ts +2 -1
- package/dist/lists/icon-list/icon-list.js +3 -2
- package/dist/lists/icon-list/icon-list.module.css.js +1 -1
- package/dist/lists/menu-list/menu-list-back-button.js +2 -2
- package/dist/lists/menu-list/menu-list-header.js +2 -2
- package/dist/lists/menu-list/menu-list-item.js +2 -2
- package/dist/lists/orderline-list/orderline-list.js +2 -2
- package/dist/lists/orderline-list/orderline-list.module.css.js +1 -1
- package/dist/media/image/image.js +1 -1
- package/dist/message/message.js +5 -8
- package/dist/modals/dialog/dialog.js +1 -4
- package/dist/modals/favorite/add-to-favorite-dialog.js +1 -1
- package/dist/modals/modal/modal.js +3 -2
- package/dist/modals/recover-password/recover-password-dialog.js +1 -1
- package/dist/modals/signin/sign-in-dialog.js +2 -2
- package/dist/navigation/mobile-navigation/mobile-navigation.js +2 -4
- package/dist/navigation/mobile-navigation/mobile-navigation.module.css.js +1 -1
- package/dist/notifications/announcements/announcement-list.js +7 -3
- package/dist/notifications/announcements/announcement-list.module.css.js +1 -1
- package/dist/notifications/announcements/announcement.js +12 -18
- package/dist/pages/checkout/payment-page/components/payment.js +1 -1
- package/dist/pages/checkout/shipping-page/components/edit-checkout-bill-to-address-form.js +1 -1
- package/dist/pages/countries-page/countries-page.d.ts +1 -0
- package/dist/pages/countries-page/countries-page.js +18 -0
- package/dist/pages/error-page/error-page.js +1 -1
- package/dist/pages/my-sonic/actions/change-customer/change-customer.js +2 -2
- package/dist/pages/my-sonic/navigation/my-sonic-desktop-navigation.js +2 -1
- package/dist/pages/my-sonic/navigation/my-sonic-navigation-items.d.ts +2 -2
- package/dist/pages/my-sonic/navigation/my-sonic-navigation-items.js +4 -8
- package/dist/pages/my-sonic/pages/order-details/order-details-content.js +1 -1
- package/dist/pages/my-sonic/pages/order-history/order-history-page.js +2 -2
- package/dist/pages/my-sonic/widgets/connected-address-book-widget.js +2 -2
- package/dist/shared/api/storefront/hooks/authentication/use-patch-session.d.ts +4 -1
- package/dist/shared/api/storefront/model/storefront.model.d.ts +4 -1
- package/dist/shared/error/default-error-view.js +2 -2
- package/dist/shared/hooks/use-resize-observer.js +1 -0
- package/dist/sidebar/sidebar.js +3 -2
- package/dist/sidebar/toggle-sidebar-button.js +2 -2
- package/dist/styles.css +1032 -686
- package/dist/table/elements/table-sort-button.js +2 -2
- package/dist/toast/toast.js +8 -10
- package/dist/tooltip/tooltip.js +3 -2
- package/dist/tooltip/tooltip.module.css.js +1 -1
- package/package.json +2 -1
- package/dist/icons/glyph/glyphs-arrow-blackcaps-right-icon.js +0 -8
- package/dist/icons/glyph/glyphs-arrow-semibold-right-icon.js +0 -8
- package/dist/navigation/account-icon/account-icon.d.ts +0 -5
- package/dist/navigation/account-icon/account-icon.js +0 -13
- package/dist/navigation/cart-icon/cart-icon.d.ts +0 -5
- package/dist/navigation/cart-icon/cart-icon.js +0 -13
- package/dist/navigation/favorite-icon/favorite-icon.d.ts +0 -5
- package/dist/navigation/favorite-icon/favorite-icon.js +0 -13
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { useCookie } from '../cookies/use-cookie.js';
|
|
4
|
+
import { useCountriesLanguages } from '../country-selector/use-countries-languages.js';
|
|
5
|
+
import { CountryLanguageSelectionList } from './country-language-selection-list.js';
|
|
6
|
+
|
|
7
|
+
function ConnectedCountryLanguageSelectionList() {
|
|
8
|
+
const cookieExpiryDate = new Date(Date.now() + 365 * 24 * 60 * 60 * 1000); // 365 days
|
|
9
|
+
const [_, setCLSelectorCookie] = useCookie('CountryLanguage', {
|
|
10
|
+
expires: cookieExpiryDate,
|
|
11
|
+
});
|
|
12
|
+
const { countries } = useCountriesLanguages({});
|
|
13
|
+
const items = [];
|
|
14
|
+
const itemGroups = [
|
|
15
|
+
{
|
|
16
|
+
countries: [
|
|
17
|
+
'af',
|
|
18
|
+
'au',
|
|
19
|
+
'bd',
|
|
20
|
+
'bn',
|
|
21
|
+
'bt',
|
|
22
|
+
'cn',
|
|
23
|
+
'fj',
|
|
24
|
+
'fm',
|
|
25
|
+
'id',
|
|
26
|
+
'jp',
|
|
27
|
+
'kh',
|
|
28
|
+
'ki',
|
|
29
|
+
'kp',
|
|
30
|
+
'kr',
|
|
31
|
+
'la',
|
|
32
|
+
'lk',
|
|
33
|
+
'mh',
|
|
34
|
+
'mm',
|
|
35
|
+
'mn',
|
|
36
|
+
'mv',
|
|
37
|
+
'my',
|
|
38
|
+
'np',
|
|
39
|
+
'nr',
|
|
40
|
+
'nz',
|
|
41
|
+
'pg',
|
|
42
|
+
'ph',
|
|
43
|
+
'pk',
|
|
44
|
+
'pw',
|
|
45
|
+
'sb',
|
|
46
|
+
'sg',
|
|
47
|
+
'th',
|
|
48
|
+
'tl',
|
|
49
|
+
'to',
|
|
50
|
+
'tv',
|
|
51
|
+
'tw',
|
|
52
|
+
'vn',
|
|
53
|
+
'vu',
|
|
54
|
+
'ws',
|
|
55
|
+
],
|
|
56
|
+
key: 'asia_pacific',
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
countries: [
|
|
60
|
+
'ad',
|
|
61
|
+
'at',
|
|
62
|
+
'be',
|
|
63
|
+
'cy',
|
|
64
|
+
'dk',
|
|
65
|
+
'ee',
|
|
66
|
+
'fi',
|
|
67
|
+
'fr',
|
|
68
|
+
'de',
|
|
69
|
+
'gr',
|
|
70
|
+
'is',
|
|
71
|
+
'ie',
|
|
72
|
+
'it',
|
|
73
|
+
'li',
|
|
74
|
+
'lu',
|
|
75
|
+
'mt',
|
|
76
|
+
'mc',
|
|
77
|
+
'nl',
|
|
78
|
+
'no',
|
|
79
|
+
'pt',
|
|
80
|
+
'sm',
|
|
81
|
+
'rs',
|
|
82
|
+
'es',
|
|
83
|
+
'se',
|
|
84
|
+
'ch',
|
|
85
|
+
'gb',
|
|
86
|
+
'va',
|
|
87
|
+
],
|
|
88
|
+
key: 'central_western_europe',
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
countries: [
|
|
92
|
+
'al',
|
|
93
|
+
'am',
|
|
94
|
+
'az',
|
|
95
|
+
'ba',
|
|
96
|
+
'bg',
|
|
97
|
+
'by',
|
|
98
|
+
'bg',
|
|
99
|
+
'cz',
|
|
100
|
+
'ge',
|
|
101
|
+
'hr',
|
|
102
|
+
'hu',
|
|
103
|
+
'lt',
|
|
104
|
+
'lv',
|
|
105
|
+
'md',
|
|
106
|
+
'me',
|
|
107
|
+
'mk',
|
|
108
|
+
'pl',
|
|
109
|
+
'ro',
|
|
110
|
+
'ru',
|
|
111
|
+
'si',
|
|
112
|
+
'sk',
|
|
113
|
+
'ua',
|
|
114
|
+
'kz',
|
|
115
|
+
'kg',
|
|
116
|
+
'tj',
|
|
117
|
+
'tm',
|
|
118
|
+
'uz',
|
|
119
|
+
],
|
|
120
|
+
key: 'eastern_europe_central_asia',
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
countries: [
|
|
124
|
+
'ag',
|
|
125
|
+
'ar',
|
|
126
|
+
'bs',
|
|
127
|
+
'bb',
|
|
128
|
+
'bz',
|
|
129
|
+
'bo',
|
|
130
|
+
'br',
|
|
131
|
+
'cl',
|
|
132
|
+
'co',
|
|
133
|
+
'cr',
|
|
134
|
+
'cu',
|
|
135
|
+
'dm',
|
|
136
|
+
'do',
|
|
137
|
+
'ec',
|
|
138
|
+
'sv',
|
|
139
|
+
'gd',
|
|
140
|
+
'gt',
|
|
141
|
+
'gy',
|
|
142
|
+
'ht',
|
|
143
|
+
'hn',
|
|
144
|
+
'jm',
|
|
145
|
+
'kn',
|
|
146
|
+
'lc',
|
|
147
|
+
'mx',
|
|
148
|
+
'ni',
|
|
149
|
+
'pa',
|
|
150
|
+
'py',
|
|
151
|
+
'pe',
|
|
152
|
+
'sr',
|
|
153
|
+
'tt',
|
|
154
|
+
'uy',
|
|
155
|
+
've',
|
|
156
|
+
'vc',
|
|
157
|
+
],
|
|
158
|
+
key: 'south_america',
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
countries: [
|
|
162
|
+
'kz',
|
|
163
|
+
'kg',
|
|
164
|
+
'tj',
|
|
165
|
+
'tm',
|
|
166
|
+
'uz',
|
|
167
|
+
'ae',
|
|
168
|
+
'bh',
|
|
169
|
+
'il',
|
|
170
|
+
'in',
|
|
171
|
+
'iq',
|
|
172
|
+
'ir',
|
|
173
|
+
'jo',
|
|
174
|
+
'kw',
|
|
175
|
+
'lb',
|
|
176
|
+
'om',
|
|
177
|
+
'qa',
|
|
178
|
+
'sa',
|
|
179
|
+
'sy',
|
|
180
|
+
'tr',
|
|
181
|
+
'ye',
|
|
182
|
+
'dz',
|
|
183
|
+
'ao',
|
|
184
|
+
'bj',
|
|
185
|
+
'bw',
|
|
186
|
+
'bf',
|
|
187
|
+
'bi',
|
|
188
|
+
'cv',
|
|
189
|
+
'cm',
|
|
190
|
+
'cf',
|
|
191
|
+
'td',
|
|
192
|
+
'km',
|
|
193
|
+
'cg',
|
|
194
|
+
'cd',
|
|
195
|
+
'ci',
|
|
196
|
+
'dj',
|
|
197
|
+
'eg',
|
|
198
|
+
'gq',
|
|
199
|
+
'er',
|
|
200
|
+
'sz',
|
|
201
|
+
'et',
|
|
202
|
+
'ga',
|
|
203
|
+
'gm',
|
|
204
|
+
'gh',
|
|
205
|
+
'gn',
|
|
206
|
+
'gw',
|
|
207
|
+
'ke',
|
|
208
|
+
'ls',
|
|
209
|
+
'lr',
|
|
210
|
+
'ly',
|
|
211
|
+
'mg',
|
|
212
|
+
'mw',
|
|
213
|
+
'ml',
|
|
214
|
+
'mr',
|
|
215
|
+
'mu',
|
|
216
|
+
'ma',
|
|
217
|
+
'mz',
|
|
218
|
+
'na',
|
|
219
|
+
'ne',
|
|
220
|
+
'ng',
|
|
221
|
+
'rw',
|
|
222
|
+
'st',
|
|
223
|
+
'sn',
|
|
224
|
+
'sc',
|
|
225
|
+
'sl',
|
|
226
|
+
'ps',
|
|
227
|
+
'so',
|
|
228
|
+
'za',
|
|
229
|
+
'ss',
|
|
230
|
+
'sd',
|
|
231
|
+
'tz',
|
|
232
|
+
'tg',
|
|
233
|
+
'tn',
|
|
234
|
+
'ug',
|
|
235
|
+
'zm',
|
|
236
|
+
'zw',
|
|
237
|
+
],
|
|
238
|
+
key: 'africa_middle_east_india',
|
|
239
|
+
},
|
|
240
|
+
{
|
|
241
|
+
countries: ['us', 'ca', 'pr'],
|
|
242
|
+
key: 'north_america',
|
|
243
|
+
},
|
|
244
|
+
];
|
|
245
|
+
countries?.forEach(country => {
|
|
246
|
+
const countryCode = country.abbreviation.toLowerCase();
|
|
247
|
+
const languageCodes = country.languages.map(({ languageCode }) => languageCode.toLowerCase());
|
|
248
|
+
languageCodes.forEach(languageCode => {
|
|
249
|
+
const itemKey = `${languageCode}-${countryCode}`;
|
|
250
|
+
items.push({
|
|
251
|
+
country: countryCode,
|
|
252
|
+
key: itemKey,
|
|
253
|
+
language: languageCode,
|
|
254
|
+
path: `/${languageCode}-${countryCode}`,
|
|
255
|
+
});
|
|
256
|
+
});
|
|
257
|
+
});
|
|
258
|
+
const handleSelect = (selectedItem) => {
|
|
259
|
+
const item = items.find(item => item.key === selectedItem);
|
|
260
|
+
if (!item)
|
|
261
|
+
return;
|
|
262
|
+
const { country, language } = item;
|
|
263
|
+
setCLSelectorCookie(`closed=true;language=${language};country=${country}`);
|
|
264
|
+
};
|
|
265
|
+
return (jsx(CountryLanguageSelectionList, { itemGroups: itemGroups, items: items, onSelect: handleSelect }));
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
export { ConnectedCountryLanguageSelectionList };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { CountryCode, CountryLanguageCode, LanguageCode } from '../intl/types';
|
|
2
|
+
export interface CountryLanguageSelectionItem {
|
|
3
|
+
country: Lowercase<CountryCode>;
|
|
4
|
+
key: CountryLanguageCode;
|
|
5
|
+
language: Lowercase<LanguageCode>;
|
|
6
|
+
path: string;
|
|
7
|
+
}
|
|
8
|
+
export interface CountryLanguageSelectionItemGroup {
|
|
9
|
+
countries: Array<Lowercase<CountryCode>>;
|
|
10
|
+
key: string;
|
|
11
|
+
}
|
|
12
|
+
interface CountryLanguageSelectionListProps {
|
|
13
|
+
itemGroups?: CountryLanguageSelectionItemGroup[];
|
|
14
|
+
items: CountryLanguageSelectionItem[];
|
|
15
|
+
onSelect?: (key: CountryLanguageCode) => void;
|
|
16
|
+
}
|
|
17
|
+
export declare function CountryLanguageSelectionList({ itemGroups, items, onSelect, }: CountryLanguageSelectionListProps): import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
+
import { Link } from '../buttons/link/link.js';
|
|
3
|
+
import { useFormattedMessage } from '../intl/use-formatted-message.js';
|
|
4
|
+
import { Heading } from '../typography/heading/heading.js';
|
|
5
|
+
import styles from './country-language-selection-list.module.css.js';
|
|
6
|
+
|
|
7
|
+
function CountryLanguageSelectionSublist({ handleClick, items, }) {
|
|
8
|
+
const t = useFormattedMessage();
|
|
9
|
+
return (jsx("ul", { className: styles.list, children: items.map(({ country, key, language, path }) => {
|
|
10
|
+
const label = t(`clselector.country.${country}.${language}`);
|
|
11
|
+
return (jsx("li", { children: jsx(Link, { color: "secondary", "data-country": country, "data-language": language, "data-test-selector": "clselector-option", href: path, hrefLang: language, onClick: () => handleClick(key), children: jsx("span", { lang: language, children: label }) }) }, key));
|
|
12
|
+
}) }));
|
|
13
|
+
}
|
|
14
|
+
function CountryLanguageSelectionList({ itemGroups, items, onSelect, }) {
|
|
15
|
+
const t = useFormattedMessage();
|
|
16
|
+
const handleClick = (key) => {
|
|
17
|
+
onSelect?.(key);
|
|
18
|
+
};
|
|
19
|
+
const getItemsByCountry = (country) => {
|
|
20
|
+
return (items
|
|
21
|
+
.filter(item => item.country === country)
|
|
22
|
+
// sort by their translated label
|
|
23
|
+
.sort((a, b) => {
|
|
24
|
+
const labelA = t(`clselector.country.${country}.${a.language}`);
|
|
25
|
+
const labelB = t(`clselector.country.${country}.${b.language}`);
|
|
26
|
+
return labelA.localeCompare(labelB);
|
|
27
|
+
}));
|
|
28
|
+
};
|
|
29
|
+
// filter group to only those with items, based on items prop
|
|
30
|
+
const filteredGroups = itemGroups
|
|
31
|
+
?.map(({ countries, key }) => {
|
|
32
|
+
return {
|
|
33
|
+
items: countries
|
|
34
|
+
// sort countries alphabetically by translated label of first item in set
|
|
35
|
+
.sort((a, b) => {
|
|
36
|
+
const labelA = t(`clselector.country.${a}.${getItemsByCountry(a)[0]?.language}`);
|
|
37
|
+
const labelB = t(`clselector.country.${b}.${getItemsByCountry(b)[0]?.language}`);
|
|
38
|
+
return labelA.localeCompare(labelB);
|
|
39
|
+
})
|
|
40
|
+
.flatMap(country => getItemsByCountry(country)),
|
|
41
|
+
key,
|
|
42
|
+
label: t(`clselector.continent.${key}`),
|
|
43
|
+
};
|
|
44
|
+
})
|
|
45
|
+
// sort groups alphabetically by group label
|
|
46
|
+
.sort((a, b) => {
|
|
47
|
+
return a.label.localeCompare(b.label);
|
|
48
|
+
});
|
|
49
|
+
return (jsx("section", { className: styles['country-language-selection-list'], children: itemGroups && filteredGroups ? (filteredGroups.map(({ items, key, label }) => {
|
|
50
|
+
return items.length > 0 ? (jsxs("section", { className: styles['group'], children: [jsx(Heading, { className: styles['heading'], size: "xs", tag: "h2", children: label }), jsx(CountryLanguageSelectionSublist, { handleClick: handleClick, items: items })] }, key)) : null;
|
|
51
|
+
})) : (jsx(CountryLanguageSelectionSublist, { handleClick: handleClick, items: items })) }));
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export { CountryLanguageSelectionList };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
var styles = {"country-language-selection-list":"country-language-selection-list-module-TIz6H","list":"country-language-selection-list-module-MYQLz","group":"country-language-selection-list-module-xqJhq","heading":"country-language-selection-list-module-jXkw-"};
|
|
2
|
+
|
|
3
|
+
export { styles as default };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { CountryCode, LanguageCode } from '../intl/types';
|
|
2
|
+
export interface ConnectedCountryLanguageSelectorProps {
|
|
3
|
+
className?: string;
|
|
4
|
+
countries?: CountryCode[];
|
|
5
|
+
isOpen?: boolean;
|
|
6
|
+
selectedCountry?: CountryCode;
|
|
7
|
+
selectedLanguage?: LanguageCode;
|
|
8
|
+
sticky?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare function ConnectedCountryLanguageSelector({ className, countries: _countries, isOpen: _isOpen, selectedCountry, selectedLanguage, sticky, }: ConnectedCountryLanguageSelectorProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { useState, useEffect } from 'react';
|
|
4
|
+
import { useCookie } from '../cookies/use-cookie.js';
|
|
5
|
+
import { useCountriesLanguages } from '../country-selector/use-countries-languages.js';
|
|
6
|
+
import { useFormattedMessage } from '../intl/use-formatted-message.js';
|
|
7
|
+
import { useIntl } from '../intl/use-intl.js';
|
|
8
|
+
import { useNavigate } from '../shared/routing/use-navigate.js';
|
|
9
|
+
import { CountryLanguageSelector } from './country-language-selector.js';
|
|
10
|
+
|
|
11
|
+
/* eslint-disable @eslint-react/hooks-extra/no-direct-set-state-in-use-effect */
|
|
12
|
+
// eslint-disable-next-line no-warning-comments
|
|
13
|
+
/* TODO:
|
|
14
|
+
- defaultSelected based on current Country and Language (from URL path, determined by intlProvider)
|
|
15
|
+
- suggested value is best option from an offered list of options
|
|
16
|
+
- based on geoIP (region) and browser language preferences
|
|
17
|
+
- browser language preferences can be multiple and are listed in priority
|
|
18
|
+
- redirect to /xx-yy homepage? or map the current path to the new locale (...)?
|
|
19
|
+
*/
|
|
20
|
+
const pathToCLSelectionList = '/countries';
|
|
21
|
+
function ConnectedCountryLanguageSelector({ className, countries: _countries, isOpen: _isOpen, selectedCountry, selectedLanguage, sticky, }) {
|
|
22
|
+
const t = useFormattedMessage();
|
|
23
|
+
const { navigate } = useNavigate();
|
|
24
|
+
const { setShowSelector, showSelector } = useIntl();
|
|
25
|
+
const cookieExpiryDate = new Date(Date.now() + 365 * 24 * 60 * 60 * 1000); // 365 days
|
|
26
|
+
const [CLSelectorCookie, setCLSelectorCookie] = useCookie('countryLanguageSelector', {
|
|
27
|
+
expires: cookieExpiryDate,
|
|
28
|
+
});
|
|
29
|
+
const [isOpen, setIsOpen] = useState(_isOpen ?? !CLSelectorCookie?.includes('closed=true'));
|
|
30
|
+
const { countries } = useCountriesLanguages({});
|
|
31
|
+
// options for the selector menu
|
|
32
|
+
const menuOptions = {
|
|
33
|
+
other: t('Choose your country or region…'),
|
|
34
|
+
};
|
|
35
|
+
// option groups for the selector menu to sort the menu options under
|
|
36
|
+
const menuOptionGroups = [];
|
|
37
|
+
// array to hold option data for easy lookup on submit
|
|
38
|
+
const optionData = [];
|
|
39
|
+
// construct menu options, groups and option data
|
|
40
|
+
countries?.forEach(country => {
|
|
41
|
+
const options = [];
|
|
42
|
+
const countryCode = country.abbreviation.toLowerCase();
|
|
43
|
+
// stop if countryCode is not included in _countries prop
|
|
44
|
+
if (_countries && !_countries.includes(country.abbreviation)) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
const languageCodes = country.languages
|
|
48
|
+
.map(({ languageCode }) => languageCode.toLowerCase())
|
|
49
|
+
.sort();
|
|
50
|
+
// group label to sort on
|
|
51
|
+
const groupLabel = t(`clselector.country.${countryCode}.${languageCodes[0]}`);
|
|
52
|
+
// group reactNode to display
|
|
53
|
+
const groupReactNode = languageCodes.flatMap((languageCode, index) => {
|
|
54
|
+
const translation = t(`clselector.country.${countryCode}.${languageCode}`);
|
|
55
|
+
return index === 0
|
|
56
|
+
? [
|
|
57
|
+
jsx("span", { lang: languageCode, children: translation }, languageCode),
|
|
58
|
+
]
|
|
59
|
+
: [
|
|
60
|
+
'/',
|
|
61
|
+
jsx("span", { lang: languageCode, children: translation }, languageCode),
|
|
62
|
+
];
|
|
63
|
+
});
|
|
64
|
+
languageCodes.forEach(languageCode => {
|
|
65
|
+
const optionKey = `${languageCode}-${countryCode}`;
|
|
66
|
+
const optionCountryLabel = `clselector.country.${countryCode}.${languageCode}`;
|
|
67
|
+
const optionLanguageLabel = `clselector.language.${languageCode}.${languageCode}`;
|
|
68
|
+
// add option key/value to menu options
|
|
69
|
+
menuOptions[optionKey] = (jsx("span", { lang: languageCode, children: `${t(optionCountryLabel)} - ${t(optionLanguageLabel)}` }));
|
|
70
|
+
// add option key to group's options
|
|
71
|
+
options.push(optionKey);
|
|
72
|
+
// add to option data
|
|
73
|
+
optionData.push({
|
|
74
|
+
country: countryCode,
|
|
75
|
+
key: optionKey,
|
|
76
|
+
language: languageCode,
|
|
77
|
+
path: `/${languageCode}-${countryCode}`,
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
// push new group to groups
|
|
81
|
+
menuOptionGroups.push({
|
|
82
|
+
key: countryCode,
|
|
83
|
+
label: groupLabel,
|
|
84
|
+
options,
|
|
85
|
+
reactNode: groupReactNode,
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
// sort groups alphabetically by label
|
|
89
|
+
menuOptionGroups.sort((a, b) => a.label.localeCompare(b.label));
|
|
90
|
+
// determine default selected option
|
|
91
|
+
const defaultSelectedLanguageCountry = selectedLanguage && selectedCountry
|
|
92
|
+
? `${selectedLanguage.toLowerCase()}-${selectedCountry.toLowerCase()}`
|
|
93
|
+
: undefined;
|
|
94
|
+
const defaultSelectedOption = defaultSelectedLanguageCountry &&
|
|
95
|
+
Object.keys(menuOptions).includes(defaultSelectedLanguageCountry)
|
|
96
|
+
? defaultSelectedLanguageCountry
|
|
97
|
+
: undefined;
|
|
98
|
+
// handle close action
|
|
99
|
+
const handleClose = () => {
|
|
100
|
+
setIsOpen(false);
|
|
101
|
+
setCLSelectorCookie('closed=true');
|
|
102
|
+
};
|
|
103
|
+
// handle submit action
|
|
104
|
+
const handleSubmit = (selectedOption) => {
|
|
105
|
+
setIsOpen(false);
|
|
106
|
+
if (selectedOption === 'other') {
|
|
107
|
+
setCLSelectorCookie('closed=true');
|
|
108
|
+
navigate(pathToCLSelectionList);
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
const option = optionData.find(option => option.key === selectedOption);
|
|
112
|
+
if (!option)
|
|
113
|
+
return;
|
|
114
|
+
const { country, language, path } = option;
|
|
115
|
+
setCLSelectorCookie(`closed=true;language=${language};country=${country}`);
|
|
116
|
+
navigate(path);
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
// react to CountryLanguageSelectorButton clicked
|
|
120
|
+
useEffect(() => {
|
|
121
|
+
if (showSelector) {
|
|
122
|
+
setShowSelector(false);
|
|
123
|
+
setIsOpen(true);
|
|
124
|
+
}
|
|
125
|
+
}, [showSelector, setShowSelector]);
|
|
126
|
+
return (jsx(CountryLanguageSelector, { className: className, defaultSelectedOption: defaultSelectedOption, isOpen: isOpen, onClose: handleClose, onSubmit: handleSubmit, optionGroups: menuOptionGroups, options: menuOptions, sticky: sticky }));
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export { ConnectedCountryLanguageSelector };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { SelectFieldOptionGroup } from '../forms/fields/select-field/select-field';
|
|
2
|
+
import { CountryLanguageCode } from '../intl/types';
|
|
3
|
+
export type CountryLanguageSelectorOptions = {
|
|
4
|
+
[K in CountryLanguageCode]: string | React.ReactNode;
|
|
5
|
+
} & {
|
|
6
|
+
other?: string | React.ReactNode;
|
|
7
|
+
};
|
|
8
|
+
export interface CountryLanguageSelectorProps {
|
|
9
|
+
className?: string;
|
|
10
|
+
defaultSelectedOption?: CountryLanguageCode | 'other';
|
|
11
|
+
isOpen?: boolean;
|
|
12
|
+
onClose?: () => void;
|
|
13
|
+
onSubmit: (selectedOption: CountryLanguageCode | 'other') => void;
|
|
14
|
+
optionGroups?: SelectFieldOptionGroup<CountryLanguageCode>[];
|
|
15
|
+
options: CountryLanguageSelectorOptions;
|
|
16
|
+
sticky?: boolean;
|
|
17
|
+
}
|
|
18
|
+
export declare function CountryLanguageSelector({ className, defaultSelectedOption, isOpen, onClose, onSubmit, optionGroups, options, sticky, }: CountryLanguageSelectorProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
|
+
import { useState, useRef, useEffect } from 'react';
|
|
4
|
+
import { clsx } from 'clsx';
|
|
5
|
+
import { Button } from '../buttons/button/button.js';
|
|
6
|
+
import { CloseButton } from '../buttons/close-button/close-button.js';
|
|
7
|
+
import { SelectField } from '../forms/fields/select-field/select-field.js';
|
|
8
|
+
import { Form } from '../forms/layout/form/form.js';
|
|
9
|
+
import { useFormattedMessage } from '../intl/use-formatted-message.js';
|
|
10
|
+
import { useResizeObserver } from '../shared/hooks/use-resize-observer.js';
|
|
11
|
+
import styles from './country-language-selector.module.css.js';
|
|
12
|
+
|
|
13
|
+
function CountryLanguageSelector({ className, defaultSelectedOption, isOpen, onClose, onSubmit, optionGroups, options, sticky = true, }) {
|
|
14
|
+
const t = useFormattedMessage();
|
|
15
|
+
const title = t('Select a region and language');
|
|
16
|
+
const [selectedKey, setSelectedKey] = useState(defaultSelectedOption);
|
|
17
|
+
const [isInitialized, setIsInitialized] = useState(false);
|
|
18
|
+
const { ref: clSelectorRef } = useResizeObserver((_, size) => {
|
|
19
|
+
const height = size.height;
|
|
20
|
+
document?.documentElement.style.setProperty('--clselector-height', `${height}px`);
|
|
21
|
+
});
|
|
22
|
+
const focusTimeoutRef = useRef();
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
// eslint-disable-next-line @eslint-react/hooks-extra/no-direct-set-state-in-use-effect
|
|
25
|
+
setIsInitialized(true);
|
|
26
|
+
}, []);
|
|
27
|
+
const handleSubmit = () => {
|
|
28
|
+
if (selectedKey)
|
|
29
|
+
onSubmit(selectedKey);
|
|
30
|
+
};
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
if (isOpen) {
|
|
33
|
+
const el = document?.getElementById('country-language-selector');
|
|
34
|
+
el?.scrollIntoView();
|
|
35
|
+
focusTimeoutRef.current = window?.setTimeout(() => {
|
|
36
|
+
el?.focus();
|
|
37
|
+
}, 100);
|
|
38
|
+
}
|
|
39
|
+
return () => {
|
|
40
|
+
if (focusTimeoutRef.current) {
|
|
41
|
+
clearTimeout(focusTimeoutRef.current);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
}, [clSelectorRef, isOpen]);
|
|
45
|
+
return (jsx("header", { ref: clSelectorRef, "aria-label": title, className: clsx(styles['country-language-selector'], isInitialized && styles['is-initialized'], isOpen && styles['is-open'], sticky && styles['sticky'], className), "data-test-selector": "country-language-selector", id: "country-language-selector",
|
|
46
|
+
// eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
|
|
47
|
+
tabIndex: 0, children: jsxs("div", { className: styles['body'], children: [jsx("p", { className: styles['explanation'], children: t('Choose another region if you want to see the content for your location and shop online.') }), jsxs(Form, { className: styles['form'], onSubmit: handleSubmit, children: [jsx(SelectField, { className: styles['menu'], "data-test-selector": "country-language-selector-menu", defaultSelectedOption: defaultSelectedOption === 'other'
|
|
48
|
+
? undefined
|
|
49
|
+
: defaultSelectedOption, label: title, name: "cl", onChange: key => setSelectedKey(key), optionGroups: optionGroups, options: options, placeholder: title, showLabel: false, variant: "solid" }), jsx(Button, { light: true, className: styles['submit'], "data-test-selector": "country-language-selector-submit", isDisabled: !selectedKey, size: "sm", type: "submit", variant: "solid", children: t('Continue') })] }), jsx(CloseButton, { className: styles['close'], "data-test-selector": "country-language-selector-close", label: t('Close and don’t show again'), onClick: onClose, size: "sm" })] }) }));
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export { CountryLanguageSelector };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
var styles = {"country-language-selector":"country-language-selector-module-lW6eg","sticky":"country-language-selector-module-fsfbv","is-open":"country-language-selector-module-XttBY","is-initialized":"country-language-selector-module-lfI2j","body":"country-language-selector-module-4qE7H","explanation":"country-language-selector-module-UvT-P","form":"country-language-selector-module-pZ3tL","close":"country-language-selector-module-sJF5B"};
|
|
2
|
+
|
|
3
|
+
export { styles as default };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function ConnectedCountryLanguageSelectorButton(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { useCountriesLanguages } from '../country-selector/use-countries-languages.js';
|
|
4
|
+
import { useIntl } from '../intl/use-intl.js';
|
|
5
|
+
import { useFetchSession } from '../shared/api/storefront/hooks/authentication/use-fetch-session.js';
|
|
6
|
+
import { CountryLanguageSelectorButton } from './country-language-selector-button.js';
|
|
7
|
+
|
|
8
|
+
function ConnectedCountryLanguageSelectorButton() {
|
|
9
|
+
const { setShowSelector } = useIntl();
|
|
10
|
+
const { data: sessionData } = useFetchSession();
|
|
11
|
+
const { defaultCountry, defaultLanguage, selectedCountry, selectedLanguage } = useCountriesLanguages({
|
|
12
|
+
billToCountryId: sessionData?.billTo?.country?.id,
|
|
13
|
+
});
|
|
14
|
+
const onClick = () => {
|
|
15
|
+
setShowSelector(true);
|
|
16
|
+
};
|
|
17
|
+
const countryCode = selectedCountry?.abbreviation ?? defaultCountry?.abbreviation;
|
|
18
|
+
const languageCode = selectedLanguage?.languageCode ?? defaultLanguage?.languageCode;
|
|
19
|
+
return (jsx(CountryLanguageSelectorButton, { countryCode: countryCode, languageCode: languageCode, onClick: onClick }));
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export { ConnectedCountryLanguageSelectorButton };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { CountryCode, LanguageCode } from '../intl/types';
|
|
2
|
+
export interface CountryLanguageSelectorButtonProps {
|
|
3
|
+
countryCode?: CountryCode;
|
|
4
|
+
languageCode?: LanguageCode;
|
|
5
|
+
onClick?: () => void;
|
|
6
|
+
}
|
|
7
|
+
export declare function CountryLanguageSelectorButton({ countryCode, languageCode, onClick, }: CountryLanguageSelectorButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
|
+
import { Link } from '../buttons/link/link.js';
|
|
4
|
+
import { Flag } from '../flag/flag.js';
|
|
5
|
+
import { useFormattedMessage } from '../intl/use-formatted-message.js';
|
|
6
|
+
import styles from './country-language-selector-button.module.css.js';
|
|
7
|
+
|
|
8
|
+
function CountryLanguageSelectorButton({ countryCode, languageCode, onClick, }) {
|
|
9
|
+
const t = useFormattedMessage();
|
|
10
|
+
const title = t('Select another country or language…');
|
|
11
|
+
if (!countryCode || !languageCode)
|
|
12
|
+
return jsx("span", { className: styles['country-language-selector-button'] });
|
|
13
|
+
const countryLabel = t(`clselector.country.${countryCode.toLowerCase()}.${languageCode.toLowerCase()}`);
|
|
14
|
+
const languageLabel = t(`clselector.language.${languageCode.toLowerCase()}.${languageCode.toLowerCase()}`);
|
|
15
|
+
return (jsxs(Link, { "aria-label": title, className: styles['country-language-selector-button'], "data-test-selector": "country-language-selector-button", onClick: onClick, title: title, children: [jsx(Flag, { className: styles.flag, country: countryCode, label: "" }), jsxs("div", { className: styles['label'], children: [jsx("data", { className: styles['country'], children: countryLabel }), jsx("data", { className: styles['language'], children: languageLabel })] })] }));
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export { CountryLanguageSelectorButton };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
var styles = {"country-language-selector-button":"country-language-selector-button-module-SN6I2","label":"country-language-selector-button-module-gV7Cp","country":"country-language-selector-button-module-1Cz2x","language":"country-language-selector-button-module-Ix4GQ"};
|
|
2
|
+
|
|
3
|
+
export { styles as default };
|
|
@@ -13,12 +13,12 @@ function CountrySelectorTrigger({ onClick, selectedCountry, selectedLanguage, })
|
|
|
13
13
|
const countryName = t(`clSelector.${selectedCountry.abbreviation}`, {
|
|
14
14
|
noTranslationId: true,
|
|
15
15
|
});
|
|
16
|
-
return (jsxs("button", { "aria-label": "Open country selector dialog", className: styles['country-selector-trigger'], onClick: onClick, type: "button", children: [jsx(Image, { className: styles.flag,
|
|
16
|
+
return (jsxs("button", { "aria-label": "Open country selector dialog", className: styles['country-selector-trigger'], onClick: onClick, type: "button", children: [jsx(Image, { className: styles.flag, image: {
|
|
17
17
|
1: flagSrc,
|
|
18
18
|
2: flagSrc,
|
|
19
19
|
3: flagSrc,
|
|
20
20
|
altText: countryName,
|
|
21
|
-
}, title:
|
|
21
|
+
}, title: "" }), jsx("div", { className: styles.text, children: selectedLanguage.description })] }));
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
export { CountrySelectorTrigger };
|
package/dist/country-selector/country-selector-trigger/country-selector-trigger.module.css.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var styles = {"country-selector-trigger":"country-selector-trigger-module-aioDu","flag":"country-selector-trigger-module-zOSJK"
|
|
1
|
+
var styles = {"country-selector-trigger":"country-selector-trigger-module-aioDu","flag":"country-selector-trigger-module-zOSJK"};
|
|
2
2
|
|
|
3
3
|
export { styles as default };
|
|
@@ -2,8 +2,8 @@ import { CountryCode, LanguageCode } from '../intl/types';
|
|
|
2
2
|
import { Country, Language } from '../shared/model/countries-languages';
|
|
3
3
|
interface UseCountriesLanguagesArgs {
|
|
4
4
|
billToCountryId?: string;
|
|
5
|
-
defaultCountryCode
|
|
6
|
-
defaultLanguageCode
|
|
5
|
+
defaultCountryCode?: CountryCode;
|
|
6
|
+
defaultLanguageCode?: LanguageCode;
|
|
7
7
|
}
|
|
8
8
|
interface UseCountriesLanguagesReturnTypeError {
|
|
9
9
|
countries: undefined;
|