@sonic-equipment/ui 222.0.0 → 224.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-search-provider.js +2 -2
- package/dist/buttons/reorder-button/connected-reorder-button.js +1 -0
- package/dist/buttons/reorder-button/reorder-button.js +1 -0
- package/dist/carousel/carousel.js +1 -1
- package/dist/carousel/usp-carousel/usp-carousel.js +1 -1
- package/dist/country-select/hooks/use-countries.js +1 -1
- package/dist/country-selector/use-countries-languages.js +1 -1
- package/dist/exports.d.ts +6 -6
- package/dist/global-search/plugins/categories-plugin.js +1 -1
- package/dist/global-search/plugins/popular-categories-plugin.js +1 -1
- package/dist/global-search/plugins/popular-searches-plugin.d.ts +1 -1
- package/dist/global-search/plugins/popular-searches-plugin.js +1 -1
- package/dist/global-search/plugins/query-suggestions-plugin.d.ts +1 -1
- package/dist/global-search/plugins/query-suggestions-plugin.js +1 -1
- package/dist/global-search/plugins/quick-access-plugin.js +1 -1
- package/dist/global-search/plugins/recent-searches-plugin.d.ts +1 -1
- package/dist/global-search/plugins/recent-searches-plugin.js +2 -1
- package/dist/global-search/search-highlight/highlight.d.ts +1 -1
- package/dist/global-search/search-highlight/highlight.js +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +5 -7
- package/dist/media/image-lightbox/image-lightbox.js +1 -1
- package/dist/node_modules/.pnpm/@algolia_autocomplete-core@1.19.2_@algolia_client-search@4.24.0_algoliasearch@4.24.0_search-insights@2.17.3/node_modules/@algolia/autocomplete-core/dist/esm/getDefaultProps.js +2 -2
- package/dist/node_modules/.pnpm/@algolia_autocomplete-core@1.19.2_@algolia_client-search@4.24.0_algoliasearch@4.24.0_search-insights@2.17.3/node_modules/@algolia/autocomplete-core/dist/esm/utils/getNormalizedSources.js +1 -1
- package/dist/node_modules/.pnpm/@algolia_autocomplete-plugin-algolia-insights@1.19.2_@algolia_client-search@4.24.0_algo_a07b7691870c05b2461c74a9a00d6a70/node_modules/@algolia/autocomplete-plugin-algolia-insights/dist/esm/createAlgoliaInsightsPlugin.js +2 -2
- package/dist/node_modules/.pnpm/{@algolia_autocomplete-preset-algolia@1.19.2_@algolia_client-search@4.24.0_algoliasearch@4.24.0/node_modules/@algolia/autocomplete-preset-algolia/dist/esm/highlight/reverseHighlightedParts.js → @algolia_autocomplete-plugin-recent-searches@1.19.2_@algolia_client-search@4.24.0_algol_ca60faa7de036e25f1f4aff1b32494ae/node_modules/@algolia/autocomplete-plugin-recent-searches/dist/esm/addHighlightedAttribute.js} +12 -18
- package/dist/node_modules/.pnpm/@algolia_autocomplete-plugin-recent-searches@1.19.2_@algolia_client-search@4.24.0_algol_ca60faa7de036e25f1f4aff1b32494ae/node_modules/@algolia/autocomplete-plugin-recent-searches/dist/esm/constants.js +10 -0
- package/dist/node_modules/.pnpm/@algolia_autocomplete-plugin-recent-searches@1.19.2_@algolia_client-search@4.24.0_algol_ca60faa7de036e25f1f4aff1b32494ae/node_modules/@algolia/autocomplete-plugin-recent-searches/dist/esm/createLocalStorage.js +36 -0
- package/dist/node_modules/.pnpm/{@algolia_autocomplete-preset-algolia@1.19.2_@algolia_client-search@4.24.0_algoliasearch@4.24.0/node_modules/@algolia/autocomplete-preset-algolia/dist/esm/requester/getAlgoliaFacets.js → @algolia_autocomplete-plugin-recent-searches@1.19.2_@algolia_client-search@4.24.0_algol_ca60faa7de036e25f1f4aff1b32494ae/node_modules/@algolia/autocomplete-plugin-recent-searches/dist/esm/createLocalStorageRecentSearchesPlugin.js} +39 -21
- package/dist/node_modules/.pnpm/@algolia_autocomplete-plugin-recent-searches@1.19.2_@algolia_client-search@4.24.0_algol_ca60faa7de036e25f1f4aff1b32494ae/node_modules/@algolia/autocomplete-plugin-recent-searches/dist/esm/createRecentSearchesPlugin.js +137 -0
- package/dist/node_modules/.pnpm/@algolia_autocomplete-plugin-recent-searches@1.19.2_@algolia_client-search@4.24.0_algol_ca60faa7de036e25f1f4aff1b32494ae/node_modules/@algolia/autocomplete-plugin-recent-searches/dist/esm/createStorageApi.js +16 -0
- package/dist/node_modules/.pnpm/@algolia_autocomplete-plugin-recent-searches@1.19.2_@algolia_client-search@4.24.0_algol_ca60faa7de036e25f1f4aff1b32494ae/node_modules/@algolia/autocomplete-plugin-recent-searches/dist/esm/getLocalStorage.js +33 -0
- package/dist/node_modules/.pnpm/@algolia_autocomplete-plugin-recent-searches@1.19.2_@algolia_client-search@4.24.0_algol_ca60faa7de036e25f1f4aff1b32494ae/node_modules/@algolia/autocomplete-plugin-recent-searches/dist/esm/getTemplates.js +72 -0
- package/dist/node_modules/.pnpm/@algolia_autocomplete-plugin-recent-searches@1.19.2_@algolia_client-search@4.24.0_algol_ca60faa7de036e25f1f4aff1b32494ae/node_modules/@algolia/autocomplete-plugin-recent-searches/dist/esm/search.js +25 -0
- package/dist/node_modules/.pnpm/swiper@11.2.10/node_modules/swiper/swiper-react.js +2 -8
- package/dist/notifications/announcements/connected-announcement-list.js +1 -1
- package/dist/pages/my-sonic/pages/order-details/order-details-content.js +1 -0
- package/dist/shared/api/bff/hooks/use-fetch-favorites.js +1 -0
- package/dist/shared/local-storage/local-storage-context.d.ts +2 -0
- package/dist/shared/local-storage/local-storage-context.js +6 -0
- package/dist/shared/local-storage/local-storage-provider.d.ts +5 -0
- package/dist/shared/local-storage/local-storage-provider.js +14 -0
- package/dist/shared/local-storage/storage-mock.d.ts +10 -0
- package/dist/shared/local-storage/storage-mock.js +34 -0
- package/dist/shared/local-storage/types.d.ts +4 -0
- package/dist/shared/{hooks → local-storage}/use-local-storage.js +5 -1
- package/dist/shared/{hooks → local-storage}/use-session-storage.js +5 -1
- package/dist/styles.css +1 -1
- package/dist/text/status-text/status-text.js +1 -0
- package/package.json +2 -1
- package/dist/node_modules/.pnpm/@algolia_autocomplete-core@1.19.2_@algolia_client-search@4.24.0_algoliasearch@4.24.0_search-insights@2.17.3/node_modules/@algolia/autocomplete-core/dist/esm/index.js +0 -2
- package/dist/node_modules/.pnpm/@algolia_autocomplete-plugin-query-suggestions@1.19.2_@algolia_client-search@4.24.0_alg_bf126b808dc57984d528cd690af7915e/node_modules/@algolia/autocomplete-plugin-query-suggestions/dist/esm/index.js +0 -2
- package/dist/node_modules/.pnpm/@algolia_autocomplete-preset-algolia@1.19.2_@algolia_client-search@4.24.0_algoliasearch@4.24.0/node_modules/@algolia/autocomplete-preset-algolia/dist/esm/highlight/isPartHighlighted.js +0 -27
- package/dist/node_modules/.pnpm/@algolia_autocomplete-preset-algolia@1.19.2_@algolia_client-search@4.24.0_algoliasearch@4.24.0/node_modules/@algolia/autocomplete-preset-algolia/dist/esm/highlight/parseAlgoliaHitReverseHighlight.js +0 -8
- package/dist/node_modules/.pnpm/@algolia_autocomplete-preset-algolia@1.19.2_@algolia_client-search@4.24.0_algoliasearch@4.24.0/node_modules/@algolia/autocomplete-preset-algolia/dist/esm/highlight/parseAlgoliaHitReverseSnippet.js +0 -8
- package/dist/node_modules/.pnpm/@algolia_autocomplete-preset-algolia@1.19.2_@algolia_client-search@4.24.0_algoliasearch@4.24.0/node_modules/@algolia/autocomplete-preset-algolia/dist/esm/highlight/parseAlgoliaHitSnippet.js +0 -25
- package/dist/node_modules/.pnpm/@algolia_autocomplete-preset-algolia@1.19.2_@algolia_client-search@4.24.0_algoliasearch@4.24.0/node_modules/@algolia/autocomplete-preset-algolia/dist/esm/index.js +0 -8
- package/dist/shared/utils/local-storage.d.ts +0 -1
- package/dist/shared/utils/local-storage.js +0 -107
- package/dist/shims/algolia/autocomplete-core.d.ts +0 -3
- package/dist/shims/algolia/autocomplete-core.js +0 -5
- package/dist/shims/algolia/autocomplete-plugin-query-suggestions.d.ts +0 -2
- package/dist/shims/algolia/autocomplete-plugin-query-suggestions.js +0 -5
- package/dist/shims/algolia/autocomplete-plugin-recent-searches.d.ts +0 -3
- package/dist/shims/algolia/autocomplete-plugin-recent-searches.js +0 -8
- package/dist/shims/algolia/autocomplete-preset-algolia.d.ts +0 -3
- package/dist/shims/algolia/autocomplete-preset-algolia.js +0 -5
- package/dist/shims/swiper/react.d.ts +0 -95
- package/dist/shims/swiper/react.js +0 -5
- /package/dist/shared/{hooks → local-storage}/use-local-storage.d.ts +0 -0
- /package/dist/shared/{hooks → local-storage}/use-session-storage.d.ts +0 -0
|
@@ -12,11 +12,11 @@ import { useLanguageCode } from '../intl/use-language-code.js';
|
|
|
12
12
|
import { useDataLayer } from '../shared/ga/use-data-layer.js';
|
|
13
13
|
import { useDebouncedCallback } from '../shared/hooks/use-debounced-callback.js';
|
|
14
14
|
import { environment } from '../shared/utils/environment.js';
|
|
15
|
-
import { createAutocomplete } from '../shims/algolia/autocomplete-core.js';
|
|
16
|
-
import { getAlgoliaResults } from '../shims/algolia/autocomplete-preset-algolia.js';
|
|
17
15
|
import { getAlgoliaIndex } from './algolia-index-config.js';
|
|
18
16
|
import { AlgoliaInsightsProvider } from './algolia-insights-provider.js';
|
|
19
17
|
import { createSonicSearchClient } from './algolia-sonic-searchclient.js';
|
|
18
|
+
import { createAutocomplete } from '../node_modules/.pnpm/@algolia_autocomplete-core@1.19.2_@algolia_client-search@4.24.0_algoliasearch@4.24.0_search-insights@2.17.3/node_modules/@algolia/autocomplete-core/dist/esm/createAutocomplete.js';
|
|
19
|
+
import { getAlgoliaResults } from '../node_modules/.pnpm/@algolia_autocomplete-preset-algolia@1.19.2_@algolia_client-search@4.24.0_algoliasearch@4.24.0/node_modules/@algolia/autocomplete-preset-algolia/dist/esm/requester/getAlgoliaResults.js';
|
|
20
20
|
|
|
21
21
|
const GlobalSearchContext = createContext(null);
|
|
22
22
|
function AlgoliaSearchProvider({ children, searchClient: _searchClient, }) {
|
|
@@ -4,9 +4,9 @@ import { useState, useRef, useMemo } from 'react';
|
|
|
4
4
|
import clsx from 'clsx';
|
|
5
5
|
import Navigation from '../node_modules/.pnpm/swiper@11.2.10/node_modules/swiper/modules/navigation.js';
|
|
6
6
|
import freeMode from '../node_modules/.pnpm/swiper@11.2.10/node_modules/swiper/modules/free-mode.js';
|
|
7
|
+
import { Swiper, SwiperSlide } from '../node_modules/.pnpm/swiper@11.2.10/node_modules/swiper/swiper-react.js';
|
|
7
8
|
import { breakpoints } from '../shared/utils/breakpoints.js';
|
|
8
9
|
import { deepMerge } from '../shared/utils/merge.js';
|
|
9
|
-
import { Swiper, SwiperSlide } from '../shims/swiper/react.js';
|
|
10
10
|
import { CarouselNavigationButton } from './carousel-navigation-button.js';
|
|
11
11
|
import styles from './carousel.module.css.js';
|
|
12
12
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
3
|
import { useRef, useState } from 'react';
|
|
4
|
-
import { Swiper, SwiperSlide } from '../../
|
|
4
|
+
import { Swiper, SwiperSlide } from '../../node_modules/.pnpm/swiper@11.2.10/node_modules/swiper/swiper-react.js';
|
|
5
5
|
import { CarouselPagination } from '../pagination/pagination.js';
|
|
6
6
|
import styles from './usp-carousel.module.css.js';
|
|
7
7
|
|
|
@@ -3,7 +3,7 @@ import { useMemo } from 'react';
|
|
|
3
3
|
import { useCookie } from '../../cookies/use-cookie.js';
|
|
4
4
|
import { isCountryCode, isCultureCode, isLanguageCode } from '../../intl/types.js';
|
|
5
5
|
import { useFetchCountriesWithLanguages } from '../../shared/api/storefront/hooks/website/use-fetch-countries-with-languages.js';
|
|
6
|
-
import { useSessionStorage } from '../../shared/
|
|
6
|
+
import { useSessionStorage } from '../../shared/local-storage/use-session-storage.js';
|
|
7
7
|
|
|
8
8
|
function useCountries({ enabled = true, } = {}) {
|
|
9
9
|
const [sessionCountries, setSessionCountries] = useSessionStorage('countries-v1');
|
|
@@ -3,7 +3,7 @@ import { useEffect } from 'react';
|
|
|
3
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 { useSessionStorage } from '../shared/
|
|
6
|
+
import { useSessionStorage } from '../shared/local-storage/use-session-storage.js';
|
|
7
7
|
import { isCountry } from '../shared/model/countries-languages.js';
|
|
8
8
|
|
|
9
9
|
function useCountriesLanguages({ defaultCountryCode, defaultLanguageCode, }) {
|
package/dist/exports.d.ts
CHANGED
|
@@ -414,8 +414,13 @@ export * from './shared/hooks/use-mutation-observer';
|
|
|
414
414
|
export * from './shared/hooks/use-resize-observer';
|
|
415
415
|
export * from './shared/hooks/use-script';
|
|
416
416
|
export * from './shared/hooks/use-scroll-lock';
|
|
417
|
-
export * from './shared/hooks/use-session-storage';
|
|
418
417
|
export * from './shared/hooks/use-watch-css-property';
|
|
418
|
+
export * from './shared/local-storage/local-storage-context';
|
|
419
|
+
export * from './shared/local-storage/local-storage-provider';
|
|
420
|
+
export * from './shared/local-storage/storage-mock';
|
|
421
|
+
export * from './shared/local-storage/types';
|
|
422
|
+
export * from './shared/local-storage/use-local-storage';
|
|
423
|
+
export * from './shared/local-storage/use-session-storage';
|
|
419
424
|
export * from './shared/model/account';
|
|
420
425
|
export * from './shared/model/address';
|
|
421
426
|
export * from './shared/model/announcement';
|
|
@@ -462,11 +467,6 @@ export * from './shared/utils/string';
|
|
|
462
467
|
export * from './shared/utils/time';
|
|
463
468
|
export * from './shared/utils/types';
|
|
464
469
|
export * from './shared/utils/uuid';
|
|
465
|
-
export * from './shims/algolia/autocomplete-core';
|
|
466
|
-
export * from './shims/algolia/autocomplete-plugin-query-suggestions';
|
|
467
|
-
export * from './shims/algolia/autocomplete-plugin-recent-searches';
|
|
468
|
-
export * from './shims/algolia/autocomplete-preset-algolia';
|
|
469
|
-
export * from './shims/swiper/react';
|
|
470
470
|
export * from './sidebar/sidebar';
|
|
471
471
|
export * from './sidebar/sidebar-provider';
|
|
472
472
|
export * from './sidebar/toggle-sidebar-button';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { getAlgoliaResults } from '../../
|
|
2
|
+
import { getAlgoliaResults } from '../../node_modules/.pnpm/@algolia_autocomplete-preset-algolia@1.19.2_@algolia_client-search@4.24.0_algoliasearch@4.24.0/node_modules/@algolia/autocomplete-preset-algolia/dist/esm/requester/getAlgoliaResults.js';
|
|
3
3
|
|
|
4
4
|
const categoriesPlugin = ({ productsIndexName, searchClient, }) => {
|
|
5
5
|
return {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { getAlgoliaResults } from '../../
|
|
2
|
+
import { getAlgoliaResults } from '../../node_modules/.pnpm/@algolia_autocomplete-preset-algolia@1.19.2_@algolia_client-search@4.24.0_algoliasearch@4.24.0/node_modules/@algolia/autocomplete-preset-algolia/dist/esm/requester/getAlgoliaResults.js';
|
|
3
3
|
|
|
4
4
|
const popularCategoriesPlugin = ({ productsIndexName, searchClient, }) => {
|
|
5
5
|
return {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { createQuerySuggestionsPlugin } from '@algolia/autocomplete-plugin-query-suggestions/dist/esm';
|
|
1
2
|
import { Hit } from '@algolia/client-search';
|
|
2
3
|
import { SearchClient } from 'algoliasearch';
|
|
3
|
-
import { createQuerySuggestionsPlugin } from '../../shims/algolia/autocomplete-plugin-query-suggestions';
|
|
4
4
|
export type PopularSearchHit = Hit<{
|
|
5
5
|
nb_words: number;
|
|
6
6
|
popularity: number;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { createQuerySuggestionsPlugin } from '../../
|
|
2
|
+
import { createQuerySuggestionsPlugin } from '../../node_modules/.pnpm/@algolia_autocomplete-plugin-query-suggestions@1.19.2_@algolia_client-search@4.24.0_alg_bf126b808dc57984d528cd690af7915e/node_modules/@algolia/autocomplete-plugin-query-suggestions/dist/esm/createQuerySuggestionsPlugin.js';
|
|
3
3
|
|
|
4
4
|
const popularSearchesPlugin = ({ searchClient, suggestionsIndexName, }) => createQuerySuggestionsPlugin({
|
|
5
5
|
getSearchParams() {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { createQuerySuggestionsPlugin } from '@algolia/autocomplete-plugin-query-suggestions/dist/esm';
|
|
1
2
|
import { Hit } from '@algolia/client-search';
|
|
2
3
|
import { SearchClient } from 'algoliasearch';
|
|
3
|
-
import { createQuerySuggestionsPlugin } from '../../shims/algolia/autocomplete-plugin-query-suggestions';
|
|
4
4
|
export type QuerySuggestionHit = Hit<{
|
|
5
5
|
nb_words: number;
|
|
6
6
|
popularity: number;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { createQuerySuggestionsPlugin } from '../../
|
|
2
|
+
import { createQuerySuggestionsPlugin } from '../../node_modules/.pnpm/@algolia_autocomplete-plugin-query-suggestions@1.19.2_@algolia_client-search@4.24.0_alg_bf126b808dc57984d528cd690af7915e/node_modules/@algolia/autocomplete-plugin-query-suggestions/dist/esm/createQuerySuggestionsPlugin.js';
|
|
3
3
|
|
|
4
4
|
const querySuggestionsPlugin = ({ searchClient, suggestionsIndexName, }) => createQuerySuggestionsPlugin({
|
|
5
5
|
getSearchParams({ state }) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { getAlgoliaResults } from '../../
|
|
2
|
+
import { getAlgoliaResults } from '../../node_modules/.pnpm/@algolia_autocomplete-preset-algolia@1.19.2_@algolia_client-search@4.24.0_algoliasearch@4.24.0/node_modules/@algolia/autocomplete-preset-algolia/dist/esm/requester/getAlgoliaResults.js';
|
|
3
3
|
|
|
4
4
|
const quickAccessPlugin = ({ productsIndexName, searchClient, }) => {
|
|
5
5
|
return {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { createLocalStorageRecentSearchesPlugin } from '@algolia/autocomplete-plugin-recent-searches/dist/esm';
|
|
1
2
|
import { Hit } from '@algolia/client-search';
|
|
2
|
-
import { createLocalStorageRecentSearchesPlugin } from '../../shims/algolia/autocomplete-plugin-recent-searches';
|
|
3
3
|
export type RecentSearchHit = Hit<{
|
|
4
4
|
id: string;
|
|
5
5
|
label: string;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { createLocalStorageRecentSearchesPlugin
|
|
2
|
+
import { createLocalStorageRecentSearchesPlugin } from '../../node_modules/.pnpm/@algolia_autocomplete-plugin-recent-searches@1.19.2_@algolia_client-search@4.24.0_algol_ca60faa7de036e25f1f4aff1b32494ae/node_modules/@algolia/autocomplete-plugin-recent-searches/dist/esm/createLocalStorageRecentSearchesPlugin.js';
|
|
3
|
+
import { search } from '../../node_modules/.pnpm/@algolia_autocomplete-plugin-recent-searches@1.19.2_@algolia_client-search@4.24.0_algol_ca60faa7de036e25f1f4aff1b32494ae/node_modules/@algolia/autocomplete-plugin-recent-searches/dist/esm/search.js';
|
|
3
4
|
|
|
4
5
|
const recentSearchesPlugin = createLocalStorageRecentSearchesPlugin({
|
|
5
6
|
key: 'recent-algolia-searches',
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { JSX } from 'react';
|
|
2
|
-
import { HighlightedHit } from '
|
|
2
|
+
import { HighlightedHit } from '@algolia/autocomplete-preset-algolia/dist/esm';
|
|
3
3
|
type HighlightHitParams<THit> = {
|
|
4
4
|
/**
|
|
5
5
|
* The attribute to retrieve the highlighted parts from.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { createElement, Fragment } from 'react';
|
|
3
|
-
import { parseAlgoliaHitHighlight } from '../../
|
|
3
|
+
import { parseAlgoliaHitHighlight } from '../../node_modules/.pnpm/@algolia_autocomplete-preset-algolia@1.19.2_@algolia_client-search@4.24.0_algoliasearch@4.24.0/node_modules/@algolia/autocomplete-preset-algolia/dist/esm/highlight/parseAlgoliaHitHighlight.js';
|
|
4
4
|
|
|
5
5
|
function Highlight({ attribute, hit, tagName = 'mark', }) {
|
|
6
6
|
return createElement(Fragment, {}, parseAlgoliaHitHighlight({ attribute, hit }).map(({ isHighlighted, value }, index) => {
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import './shared/utils/local-storage.js';
|
|
2
1
|
import * as bff_model from './shared/api/bff/model/bff.model.js';
|
|
3
2
|
export { bff_model as BffModel };
|
|
4
3
|
import * as storefront_model from './shared/api/storefront/model/storefront.model.js';
|
|
@@ -415,8 +414,12 @@ export { useMutationObserver } from './shared/hooks/use-mutation-observer.js';
|
|
|
415
414
|
export { useResizeObserver } from './shared/hooks/use-resize-observer.js';
|
|
416
415
|
export { useScript } from './shared/hooks/use-script.js';
|
|
417
416
|
export { useScrollLock } from './shared/hooks/use-scroll-lock.js';
|
|
418
|
-
export { useSessionStorage } from './shared/hooks/use-session-storage.js';
|
|
419
417
|
export { useWatchCssProperty } from './shared/hooks/use-watch-css-property.js';
|
|
418
|
+
export { LocalStorageContext } from './shared/local-storage/local-storage-context.js';
|
|
419
|
+
export { LocalStorageProvider } from './shared/local-storage/local-storage-provider.js';
|
|
420
|
+
export { MockStorage } from './shared/local-storage/storage-mock.js';
|
|
421
|
+
export { useLocalStorage } from './shared/local-storage/use-local-storage.js';
|
|
422
|
+
export { useSessionStorage } from './shared/local-storage/use-session-storage.js';
|
|
420
423
|
export { validatePassword } from './shared/model/account.js';
|
|
421
424
|
export { validateEmail, validatePhone } from './shared/model/address.js';
|
|
422
425
|
export { announcementSubTypes, announcementTypes, isAnnouncementSubtype, isAnnouncementType } from './shared/model/announcement.js';
|
|
@@ -461,11 +464,6 @@ export { camelCase } from './shared/utils/string.js';
|
|
|
461
464
|
export { TIME } from './shared/utils/time.js';
|
|
462
465
|
export { has, hasNo, isObject } from './shared/utils/types.js';
|
|
463
466
|
export { createUUID, isUUID } from './shared/utils/uuid.js';
|
|
464
|
-
export { createAutocomplete } from './shims/algolia/autocomplete-core.js';
|
|
465
|
-
export { createQuerySuggestionsPlugin } from './shims/algolia/autocomplete-plugin-query-suggestions.js';
|
|
466
|
-
export { createLocalStorageRecentSearchesPlugin, search } from './shims/algolia/autocomplete-plugin-recent-searches.js';
|
|
467
|
-
export { getAlgoliaResults, parseAlgoliaHitHighlight } from './shims/algolia/autocomplete-preset-algolia.js';
|
|
468
|
-
export { Swiper, SwiperSlide } from './shims/swiper/react.js';
|
|
469
467
|
export { Sidebar } from './sidebar/sidebar.js';
|
|
470
468
|
export { SidebarDetectBreakpoint, SidebarProvider } from './sidebar/sidebar-provider.js';
|
|
471
469
|
export { ToggleSidebarButton } from './sidebar/toggle-sidebar-button.js';
|
|
@@ -4,9 +4,9 @@ import { useState, useRef } from 'react';
|
|
|
4
4
|
import clsx from 'clsx';
|
|
5
5
|
import Navigation from '../../node_modules/.pnpm/swiper@11.2.10/node_modules/swiper/modules/navigation.js';
|
|
6
6
|
import Thumb from '../../node_modules/.pnpm/swiper@11.2.10/node_modules/swiper/modules/thumbs.js';
|
|
7
|
+
import { Swiper, SwiperSlide } from '../../node_modules/.pnpm/swiper@11.2.10/node_modules/swiper/swiper-react.js';
|
|
7
8
|
import { CarouselNavigationButton } from '../../carousel/carousel-navigation-button.js';
|
|
8
9
|
import { CarouselPagination } from '../../carousel/pagination/pagination.js';
|
|
9
|
-
import { Swiper, SwiperSlide } from '../../shims/swiper/react.js';
|
|
10
10
|
import { Image } from '../image/image.js';
|
|
11
11
|
import styles from './image-lightbox.module.css.js';
|
|
12
12
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { getNormalizedSources } from './utils/getNormalizedSources.js';
|
|
2
|
-
import { generateAutocompleteId } from '../../../../../../@algolia_autocomplete-shared@1.19.2_@algolia_client-search@4.24.0_algoliasearch@4.24.0/node_modules/@algolia/autocomplete-shared/dist/esm/generateAutocompleteId.js';
|
|
3
1
|
import { getItemsCount } from '../../../../../../@algolia_autocomplete-shared@1.19.2_@algolia_client-search@4.24.0_algoliasearch@4.24.0/node_modules/@algolia/autocomplete-shared/dist/esm/getItemsCount.js';
|
|
2
|
+
import { generateAutocompleteId } from '../../../../../../@algolia_autocomplete-shared@1.19.2_@algolia_client-search@4.24.0_algoliasearch@4.24.0/node_modules/@algolia/autocomplete-shared/dist/esm/generateAutocompleteId.js';
|
|
3
|
+
import { getNormalizedSources } from './utils/getNormalizedSources.js';
|
|
4
4
|
import { flatten } from '../../../../../../@algolia_autocomplete-shared@1.19.2_@algolia_client-search@4.24.0_algoliasearch@4.24.0/node_modules/@algolia/autocomplete-shared/dist/esm/flatten.js';
|
|
5
5
|
|
|
6
6
|
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { decycle } from '../../../../../../../@algolia_autocomplete-shared@1.19.2_@algolia_client-search@4.24.0_algoliasearch@4.24.0/node_modules/@algolia/autocomplete-shared/dist/esm/decycle.js';
|
|
2
1
|
import { invariant } from '../../../../../../../@algolia_autocomplete-shared@1.19.2_@algolia_client-search@4.24.0_algoliasearch@4.24.0/node_modules/@algolia/autocomplete-shared/dist/esm/invariant.js';
|
|
2
|
+
import { decycle } from '../../../../../../../@algolia_autocomplete-shared@1.19.2_@algolia_client-search@4.24.0_algoliasearch@4.24.0/node_modules/@algolia/autocomplete-shared/dist/esm/decycle.js';
|
|
3
3
|
import { noop } from '../../../../../../../@algolia_autocomplete-shared@1.19.2_@algolia_client-search@4.24.0_algoliasearch@4.24.0/node_modules/@algolia/autocomplete-shared/dist/esm/noop.js';
|
|
4
4
|
|
|
5
5
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
@@ -3,10 +3,10 @@ import { createSearchInsightsApi } from './createSearchInsightsApi.js';
|
|
|
3
3
|
import { createViewedEvents } from './createViewedEvents.js';
|
|
4
4
|
import { isAlgoliaInsightsHit } from './isAlgoliaInsightsHit.js';
|
|
5
5
|
import { safelyRunOnBrowser } from '../../../../../../@algolia_autocomplete-shared@1.19.2_@algolia_client-search@4.24.0_algoliasearch@4.24.0/node_modules/@algolia/autocomplete-shared/dist/esm/safelyRunOnBrowser.js';
|
|
6
|
-
import { isEqual } from '../../../../../../@algolia_autocomplete-shared@1.19.2_@algolia_client-search@4.24.0_algoliasearch@4.24.0/node_modules/@algolia/autocomplete-shared/dist/esm/isEqual.js';
|
|
7
|
-
import { noop } from '../../../../../../@algolia_autocomplete-shared@1.19.2_@algolia_client-search@4.24.0_algoliasearch@4.24.0/node_modules/@algolia/autocomplete-shared/dist/esm/noop.js';
|
|
8
6
|
import { debounce } from '../../../../../../@algolia_autocomplete-shared@1.19.2_@algolia_client-search@4.24.0_algoliasearch@4.24.0/node_modules/@algolia/autocomplete-shared/dist/esm/debounce.js';
|
|
7
|
+
import { isEqual } from '../../../../../../@algolia_autocomplete-shared@1.19.2_@algolia_client-search@4.24.0_algoliasearch@4.24.0/node_modules/@algolia/autocomplete-shared/dist/esm/isEqual.js';
|
|
9
8
|
import { createRef } from '../../../../../../@algolia_autocomplete-shared@1.19.2_@algolia_client-search@4.24.0_algoliasearch@4.24.0/node_modules/@algolia/autocomplete-shared/dist/esm/createRef.js';
|
|
9
|
+
import { noop } from '../../../../../../@algolia_autocomplete-shared@1.19.2_@algolia_client-search@4.24.0_algoliasearch@4.24.0/node_modules/@algolia/autocomplete-shared/dist/esm/noop.js';
|
|
10
10
|
|
|
11
11
|
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
12
12
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
@@ -1,27 +1,21 @@
|
|
|
1
|
-
import { isPartHighlighted } from './isPartHighlighted.js';
|
|
2
|
-
|
|
3
1
|
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
2
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
5
3
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
6
4
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
7
5
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
8
6
|
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
9
|
-
function
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
return parts.map(function (part, i) {
|
|
21
|
-
return _objectSpread(_objectSpread({}, part), {}, {
|
|
22
|
-
isHighlighted: !isPartHighlighted(parts, i)
|
|
23
|
-
});
|
|
7
|
+
function addHighlightedAttribute(_ref) {
|
|
8
|
+
var item = _ref.item,
|
|
9
|
+
query = _ref.query;
|
|
10
|
+
return _objectSpread(_objectSpread({}, item), {}, {
|
|
11
|
+
_highlightResult: {
|
|
12
|
+
label: {
|
|
13
|
+
value: query ? item.label.replace(new RegExp(query.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&'), 'gi'), function (match) {
|
|
14
|
+
return "__aa-highlight__".concat(match, "__/aa-highlight__");
|
|
15
|
+
}) : item.label
|
|
16
|
+
}
|
|
17
|
+
}
|
|
24
18
|
});
|
|
25
19
|
}
|
|
26
20
|
|
|
27
|
-
export {
|
|
21
|
+
export { addHighlightedAttribute };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
var LOCAL_STORAGE_KEY = 'AUTOCOMPLETE_RECENT_SEARCHES';
|
|
2
|
+
var LOCAL_STORAGE_KEY_TEST = '__AUTOCOMPLETE_RECENT_SEARCHES_PLUGIN_TEST_KEY__';
|
|
3
|
+
var defaultTranslations = {
|
|
4
|
+
removeSearchTitle: 'Remove this search',
|
|
5
|
+
fillQueryTitle: function fillQueryTitle(text) {
|
|
6
|
+
return "Fill query with \"".concat(text, "\"");
|
|
7
|
+
}
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export { LOCAL_STORAGE_KEY, LOCAL_STORAGE_KEY_TEST, defaultTranslations };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { getLocalStorage } from './getLocalStorage.js';
|
|
2
|
+
|
|
3
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
4
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
5
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
6
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
7
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
8
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
9
|
+
function createLocalStorage(_ref) {
|
|
10
|
+
var key = _ref.key,
|
|
11
|
+
limit = _ref.limit,
|
|
12
|
+
search = _ref.search;
|
|
13
|
+
var storage = getLocalStorage({
|
|
14
|
+
key: key
|
|
15
|
+
});
|
|
16
|
+
return {
|
|
17
|
+
onAdd: function onAdd(item) {
|
|
18
|
+
storage.setItem([item].concat(_toConsumableArray(storage.getItem())));
|
|
19
|
+
},
|
|
20
|
+
onRemove: function onRemove(id) {
|
|
21
|
+
storage.setItem(storage.getItem().filter(function (x) {
|
|
22
|
+
return x.id !== id;
|
|
23
|
+
}));
|
|
24
|
+
},
|
|
25
|
+
getAll: function getAll() {
|
|
26
|
+
var query = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
27
|
+
return search({
|
|
28
|
+
query: query,
|
|
29
|
+
items: storage.getItem(),
|
|
30
|
+
limit: limit
|
|
31
|
+
}).slice(0, limit);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export { createLocalStorage };
|
|
@@ -1,31 +1,49 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { defaultTranslations, LOCAL_STORAGE_KEY } from './constants.js';
|
|
2
|
+
import { createLocalStorage } from './createLocalStorage.js';
|
|
3
|
+
import { createRecentSearchesPlugin } from './createRecentSearchesPlugin.js';
|
|
4
|
+
import { search } from './search.js';
|
|
3
5
|
|
|
6
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
7
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
5
8
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
6
9
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
7
10
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
8
11
|
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
9
|
-
function
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
12
|
+
function createLocalStorageRecentSearchesPlugin(options) {
|
|
13
|
+
var _getOptions = getOptions(options),
|
|
14
|
+
key = _getOptions.key,
|
|
15
|
+
limit = _getOptions.limit,
|
|
16
|
+
transformSource = _getOptions.transformSource,
|
|
17
|
+
search = _getOptions.search,
|
|
18
|
+
subscribe = _getOptions.subscribe,
|
|
19
|
+
translations = _getOptions.translations;
|
|
20
|
+
var storage = createLocalStorage({
|
|
21
|
+
key: [LOCAL_STORAGE_KEY, key].join(':'),
|
|
22
|
+
limit: limit,
|
|
23
|
+
search: search
|
|
20
24
|
});
|
|
21
|
-
var
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
+
var recentSearchesPlugin = createRecentSearchesPlugin({
|
|
26
|
+
transformSource: transformSource,
|
|
27
|
+
storage: storage,
|
|
28
|
+
subscribe: subscribe,
|
|
29
|
+
translations: translations
|
|
30
|
+
});
|
|
31
|
+
return _objectSpread(_objectSpread({}, recentSearchesPlugin), {}, {
|
|
32
|
+
name: 'aa.localStorageRecentSearchesPlugin',
|
|
33
|
+
__autocomplete_pluginOptions: options
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
function getOptions(options) {
|
|
37
|
+
return _objectSpread(_objectSpread({
|
|
38
|
+
limit: 5,
|
|
39
|
+
search: search,
|
|
40
|
+
transformSource: function transformSource(_ref) {
|
|
41
|
+
var source = _ref.source;
|
|
42
|
+
return source;
|
|
43
|
+
}
|
|
44
|
+
}, options), {}, {
|
|
45
|
+
translations: _objectSpread(_objectSpread({}, defaultTranslations), options.translations)
|
|
25
46
|
});
|
|
26
|
-
return requester(_objectSpread(_objectSpread({}, requestParams), {}, {
|
|
27
|
-
queries: queries
|
|
28
|
-
}));
|
|
29
47
|
}
|
|
30
48
|
|
|
31
|
-
export {
|
|
49
|
+
export { createLocalStorageRecentSearchesPlugin };
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { defaultTranslations } from './constants.js';
|
|
2
|
+
import { createStorageApi } from './createStorageApi.js';
|
|
3
|
+
import { getTemplates } from './getTemplates.js';
|
|
4
|
+
import { createRef } from '../../../../../../@algolia_autocomplete-shared@1.19.2_@algolia_client-search@4.24.0_algoliasearch@4.24.0/node_modules/@algolia/autocomplete-shared/dist/esm/createRef.js';
|
|
5
|
+
import { warn } from '../../../../../../@algolia_autocomplete-shared@1.19.2_@algolia_client-search@4.24.0_algoliasearch@4.24.0/node_modules/@algolia/autocomplete-shared/dist/esm/warn.js';
|
|
6
|
+
|
|
7
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
8
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
9
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
10
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
11
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
12
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
13
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
14
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
15
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
16
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
17
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
18
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
19
|
+
function getDefaultSubscribe(store) {
|
|
20
|
+
return function subscribe(_ref) {
|
|
21
|
+
var onSelect = _ref.onSelect;
|
|
22
|
+
onSelect(function (_ref2) {
|
|
23
|
+
var item = _ref2.item,
|
|
24
|
+
state = _ref2.state,
|
|
25
|
+
source = _ref2.source;
|
|
26
|
+
var inputValue = source.getItemInputValue({
|
|
27
|
+
item: item,
|
|
28
|
+
state: state
|
|
29
|
+
});
|
|
30
|
+
if (source.sourceId === 'querySuggestionsPlugin' && inputValue) {
|
|
31
|
+
var recentItem = {
|
|
32
|
+
id: inputValue,
|
|
33
|
+
label: inputValue,
|
|
34
|
+
category: item.__autocomplete_qsCategory
|
|
35
|
+
};
|
|
36
|
+
store.addItem(recentItem);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function createRecentSearchesPlugin(options) {
|
|
42
|
+
var _getOptions = getOptions(options),
|
|
43
|
+
storage = _getOptions.storage,
|
|
44
|
+
transformSource = _getOptions.transformSource,
|
|
45
|
+
subscribe = _getOptions.subscribe,
|
|
46
|
+
translations = _getOptions.translations;
|
|
47
|
+
var store = createStorageApi(storage);
|
|
48
|
+
var lastItemsRef = createRef([]);
|
|
49
|
+
return {
|
|
50
|
+
name: 'aa.recentSearchesPlugin',
|
|
51
|
+
subscribe: subscribe !== null && subscribe !== void 0 ? subscribe : getDefaultSubscribe(store),
|
|
52
|
+
onSubmit: function onSubmit(_ref3) {
|
|
53
|
+
var state = _ref3.state;
|
|
54
|
+
var query = state.query;
|
|
55
|
+
if (query) {
|
|
56
|
+
var recentItem = {
|
|
57
|
+
id: query,
|
|
58
|
+
label: query
|
|
59
|
+
};
|
|
60
|
+
store.addItem(recentItem);
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
getSources: function getSources(_ref4) {
|
|
64
|
+
var query = _ref4.query,
|
|
65
|
+
setQuery = _ref4.setQuery,
|
|
66
|
+
refresh = _ref4.refresh,
|
|
67
|
+
state = _ref4.state;
|
|
68
|
+
lastItemsRef.current = store.getAll(query);
|
|
69
|
+
function onRemove(id) {
|
|
70
|
+
store.removeItem(id);
|
|
71
|
+
refresh();
|
|
72
|
+
}
|
|
73
|
+
function onTapAhead(item) {
|
|
74
|
+
setQuery(item.label);
|
|
75
|
+
refresh();
|
|
76
|
+
}
|
|
77
|
+
return Promise.resolve(lastItemsRef.current).then(function (items) {
|
|
78
|
+
if (items.length === 0) {
|
|
79
|
+
return [];
|
|
80
|
+
}
|
|
81
|
+
return [transformSource({
|
|
82
|
+
source: {
|
|
83
|
+
sourceId: 'recentSearchesPlugin',
|
|
84
|
+
getItemInputValue: function getItemInputValue(_ref5) {
|
|
85
|
+
var item = _ref5.item;
|
|
86
|
+
return item.label;
|
|
87
|
+
},
|
|
88
|
+
getItems: function getItems() {
|
|
89
|
+
return items;
|
|
90
|
+
},
|
|
91
|
+
templates: getTemplates({
|
|
92
|
+
onRemove: onRemove,
|
|
93
|
+
onTapAhead: onTapAhead,
|
|
94
|
+
translations: translations
|
|
95
|
+
})
|
|
96
|
+
},
|
|
97
|
+
onRemove: onRemove,
|
|
98
|
+
onTapAhead: onTapAhead,
|
|
99
|
+
state: state
|
|
100
|
+
})];
|
|
101
|
+
});
|
|
102
|
+
},
|
|
103
|
+
data: _objectSpread(_objectSpread({}, store), {}, {
|
|
104
|
+
// @ts-ignore SearchOptions `facetFilters` is ReadonlyArray
|
|
105
|
+
getAlgoliaSearchParams: function getAlgoliaSearchParams() {
|
|
106
|
+
var _params$facetFilters, _params$hitsPerPage;
|
|
107
|
+
var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
108
|
+
// If the items returned by `store.getAll` are contained in a Promise,
|
|
109
|
+
// we cannot provide the search params in time when this function is called
|
|
110
|
+
// because we need to resolve the promise before getting the value.
|
|
111
|
+
if (!Array.isArray(lastItemsRef.current)) {
|
|
112
|
+
process.env.NODE_ENV !== 'production' ? warn(false, 'The `getAlgoliaSearchParams` function is not supported with storages that return promises in `getAll`.') : void 0;
|
|
113
|
+
return params;
|
|
114
|
+
}
|
|
115
|
+
return _objectSpread(_objectSpread({}, params), {}, {
|
|
116
|
+
facetFilters: [].concat(_toConsumableArray((_params$facetFilters = params.facetFilters) !== null && _params$facetFilters !== void 0 ? _params$facetFilters : []), _toConsumableArray(lastItemsRef.current.map(function (item) {
|
|
117
|
+
return ["objectID:-".concat(item.label)];
|
|
118
|
+
}))),
|
|
119
|
+
hitsPerPage: Math.max(1, ((_params$hitsPerPage = params.hitsPerPage) !== null && _params$hitsPerPage !== void 0 ? _params$hitsPerPage : 10) - lastItemsRef.current.length)
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
}),
|
|
123
|
+
__autocomplete_pluginOptions: options
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
function getOptions(options) {
|
|
127
|
+
return _objectSpread(_objectSpread({
|
|
128
|
+
transformSource: function transformSource(_ref6) {
|
|
129
|
+
var source = _ref6.source;
|
|
130
|
+
return source;
|
|
131
|
+
}
|
|
132
|
+
}, options), {}, {
|
|
133
|
+
translations: _objectSpread(_objectSpread({}, defaultTranslations), options.translations)
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export { createRecentSearchesPlugin };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
function createStorageApi(storage) {
|
|
2
|
+
return {
|
|
3
|
+
addItem: function addItem(item) {
|
|
4
|
+
storage.onRemove(item.id);
|
|
5
|
+
storage.onAdd(item);
|
|
6
|
+
},
|
|
7
|
+
removeItem: function removeItem(id) {
|
|
8
|
+
storage.onRemove(id);
|
|
9
|
+
},
|
|
10
|
+
getAll: function getAll(query) {
|
|
11
|
+
return storage.getAll(query);
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export { createStorageApi };
|