@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
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { LOCAL_STORAGE_KEY_TEST } from './constants.js';
|
|
2
|
+
|
|
3
|
+
function isLocalStorageSupported() {
|
|
4
|
+
try {
|
|
5
|
+
localStorage.setItem(LOCAL_STORAGE_KEY_TEST, '');
|
|
6
|
+
localStorage.removeItem(LOCAL_STORAGE_KEY_TEST);
|
|
7
|
+
return true;
|
|
8
|
+
} catch (error) {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
function getLocalStorage(_ref) {
|
|
13
|
+
var key = _ref.key;
|
|
14
|
+
if (!isLocalStorageSupported()) {
|
|
15
|
+
return {
|
|
16
|
+
setItem: function setItem() {},
|
|
17
|
+
getItem: function getItem() {
|
|
18
|
+
return [];
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
return {
|
|
23
|
+
setItem: function setItem(items) {
|
|
24
|
+
return window.localStorage.setItem(key, JSON.stringify(items));
|
|
25
|
+
},
|
|
26
|
+
getItem: function getItem() {
|
|
27
|
+
var items = window.localStorage.getItem(key);
|
|
28
|
+
return items ? JSON.parse(items) : [];
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export { getLocalStorage };
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/** @jsxRuntime classic */
|
|
2
|
+
/** @jsx createElement */
|
|
3
|
+
|
|
4
|
+
function getTemplates(_ref) {
|
|
5
|
+
var onRemove = _ref.onRemove,
|
|
6
|
+
onTapAhead = _ref.onTapAhead,
|
|
7
|
+
translations = _ref.translations;
|
|
8
|
+
return {
|
|
9
|
+
item: function item(_ref2) {
|
|
10
|
+
var item = _ref2.item,
|
|
11
|
+
createElement = _ref2.createElement,
|
|
12
|
+
components = _ref2.components;
|
|
13
|
+
return createElement("div", {
|
|
14
|
+
className: "aa-ItemWrapper"
|
|
15
|
+
}, createElement("div", {
|
|
16
|
+
className: "aa-ItemContent"
|
|
17
|
+
}, createElement("div", {
|
|
18
|
+
className: "aa-ItemIcon aa-ItemIcon--noBorder"
|
|
19
|
+
}, createElement("svg", {
|
|
20
|
+
viewBox: "0 0 24 24",
|
|
21
|
+
fill: "currentColor"
|
|
22
|
+
}, createElement("path", {
|
|
23
|
+
d: "M12.516 6.984v5.25l4.5 2.672-0.75 1.266-5.25-3.188v-6h1.5zM12 20.016q3.281 0 5.648-2.367t2.367-5.648-2.367-5.648-5.648-2.367-5.648 2.367-2.367 5.648 2.367 5.648 5.648 2.367zM12 2.016q4.125 0 7.055 2.93t2.93 7.055-2.93 7.055-7.055 2.93-7.055-2.93-2.93-7.055 2.93-7.055 7.055-2.93z"
|
|
24
|
+
}))), createElement("div", {
|
|
25
|
+
className: "aa-ItemContentBody"
|
|
26
|
+
}, createElement("div", {
|
|
27
|
+
className: "aa-ItemContentTitle"
|
|
28
|
+
}, createElement(components.ReverseHighlight, {
|
|
29
|
+
hit: item,
|
|
30
|
+
attribute: "label"
|
|
31
|
+
}), item.category && createElement("span", {
|
|
32
|
+
className: "aa-ItemContentSubtitle aa-ItemContentSubtitle--inline"
|
|
33
|
+
}, createElement("span", {
|
|
34
|
+
className: "aa-ItemContentSubtitleIcon"
|
|
35
|
+
}), " in", ' ', createElement("span", {
|
|
36
|
+
className: "aa-ItemContentSubtitleCategory"
|
|
37
|
+
}, item.category))))), createElement("div", {
|
|
38
|
+
className: "aa-ItemActions"
|
|
39
|
+
}, createElement("button", {
|
|
40
|
+
type: "button",
|
|
41
|
+
className: "aa-ItemActionButton",
|
|
42
|
+
title: translations.removeSearchTitle,
|
|
43
|
+
onClick: function onClick(event) {
|
|
44
|
+
event.preventDefault();
|
|
45
|
+
event.stopPropagation();
|
|
46
|
+
onRemove(item.id);
|
|
47
|
+
}
|
|
48
|
+
}, createElement("svg", {
|
|
49
|
+
viewBox: "0 0 24 24",
|
|
50
|
+
fill: "currentColor"
|
|
51
|
+
}, createElement("path", {
|
|
52
|
+
d: "M18 7v13c0 0.276-0.111 0.525-0.293 0.707s-0.431 0.293-0.707 0.293h-10c-0.276 0-0.525-0.111-0.707-0.293s-0.293-0.431-0.293-0.707v-13zM17 5v-1c0-0.828-0.337-1.58-0.879-2.121s-1.293-0.879-2.121-0.879h-4c-0.828 0-1.58 0.337-2.121 0.879s-0.879 1.293-0.879 2.121v1h-4c-0.552 0-1 0.448-1 1s0.448 1 1 1h1v13c0 0.828 0.337 1.58 0.879 2.121s1.293 0.879 2.121 0.879h10c0.828 0 1.58-0.337 2.121-0.879s0.879-1.293 0.879-2.121v-13h1c0.552 0 1-0.448 1-1s-0.448-1-1-1zM9 5v-1c0-0.276 0.111-0.525 0.293-0.707s0.431-0.293 0.707-0.293h4c0.276 0 0.525 0.111 0.707 0.293s0.293 0.431 0.293 0.707v1zM9 11v6c0 0.552 0.448 1 1 1s1-0.448 1-1v-6c0-0.552-0.448-1-1-1s-1 0.448-1 1zM13 11v6c0 0.552 0.448 1 1 1s1-0.448 1-1v-6c0-0.552-0.448-1-1-1s-1 0.448-1 1z"
|
|
53
|
+
}))), createElement("button", {
|
|
54
|
+
type: "button",
|
|
55
|
+
className: "aa-ItemActionButton",
|
|
56
|
+
title: translations.fillQueryTitle(item.label),
|
|
57
|
+
onClick: function onClick(event) {
|
|
58
|
+
event.preventDefault();
|
|
59
|
+
event.stopPropagation();
|
|
60
|
+
onTapAhead(item);
|
|
61
|
+
}
|
|
62
|
+
}, createElement("svg", {
|
|
63
|
+
viewBox: "0 0 24 24",
|
|
64
|
+
fill: "currentColor"
|
|
65
|
+
}, createElement("path", {
|
|
66
|
+
d: "M8 17v-7.586l8.293 8.293c0.391 0.391 1.024 0.391 1.414 0s0.391-1.024 0-1.414l-8.293-8.293h7.586c0.552 0 1-0.448 1-1s-0.448-1-1-1h-10c-0.552 0-1 0.448-1 1v10c0 0.552 0.448 1 1 1s1-0.448 1-1z"
|
|
67
|
+
})))));
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export { getTemplates };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { addHighlightedAttribute } from './addHighlightedAttribute.js';
|
|
2
|
+
|
|
3
|
+
function search(_ref) {
|
|
4
|
+
var query = _ref.query,
|
|
5
|
+
items = _ref.items,
|
|
6
|
+
limit = _ref.limit;
|
|
7
|
+
if (!query) {
|
|
8
|
+
return items.slice(0, limit).map(function (item) {
|
|
9
|
+
return addHighlightedAttribute({
|
|
10
|
+
item: item,
|
|
11
|
+
query: query
|
|
12
|
+
});
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
return items.filter(function (item) {
|
|
16
|
+
return item.label.toLowerCase().includes(query.toLowerCase());
|
|
17
|
+
}).slice(0, limit).map(function (item) {
|
|
18
|
+
return addHighlightedAttribute({
|
|
19
|
+
item: item,
|
|
20
|
+
query: query
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export { search };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { forwardRef, useState, useRef, useEffect, createContext, useLayoutEffect
|
|
1
|
+
import React, { forwardRef, useState, useRef, useEffect, createContext, useLayoutEffect } from 'react';
|
|
2
2
|
import { S as Swiper$1 } from './shared/swiper-core.js';
|
|
3
3
|
import { g as getParams, m as mountSwiper, a as getChangedParams, u as updateOnVirtualData } from './shared/update-on-virtual-data.js';
|
|
4
4
|
import { d as uniqueClasses, w as wrapperClass, n as needsNavigation, b as needsScrollbar, a as needsPagination, e as extend, u as updateSwiper } from './shared/update-swiper.js';
|
|
@@ -120,13 +120,7 @@ function useIsomorphicLayoutEffect(callback, deps) {
|
|
|
120
120
|
}
|
|
121
121
|
|
|
122
122
|
const SwiperSlideContext = /*#__PURE__*/createContext(null);
|
|
123
|
-
const useSwiperSlide = () => {
|
|
124
|
-
return useContext(SwiperSlideContext);
|
|
125
|
-
};
|
|
126
123
|
const SwiperContext = /*#__PURE__*/createContext(null);
|
|
127
|
-
const useSwiper = () => {
|
|
128
|
-
return useContext(SwiperContext);
|
|
129
|
-
};
|
|
130
124
|
|
|
131
125
|
const Swiper = /*#__PURE__*/forwardRef(function (_temp, externalElRef) {
|
|
132
126
|
let {
|
|
@@ -392,4 +386,4 @@ const SwiperSlide = /*#__PURE__*/forwardRef(function (_temp, externalRef) {
|
|
|
392
386
|
});
|
|
393
387
|
SwiperSlide.displayName = 'SwiperSlide';
|
|
394
388
|
|
|
395
|
-
export { Swiper, SwiperSlide
|
|
389
|
+
export { Swiper, SwiperSlide };
|
|
@@ -3,7 +3,7 @@ import { jsx } from 'react/jsx-runtime';
|
|
|
3
3
|
import { useCultureCode } from '../../intl/use-culture-code.js';
|
|
4
4
|
import { useLogError } from '../../logging/use-log-error.js';
|
|
5
5
|
import { useFetchAnnouncements } from '../../shared/api/bff/hooks/use-fetch-announcements.js';
|
|
6
|
-
import { useLocalStorage } from '../../shared/
|
|
6
|
+
import { useLocalStorage } from '../../shared/local-storage/use-local-storage.js';
|
|
7
7
|
import { AnnouncementList } from './announcement-list.js';
|
|
8
8
|
|
|
9
9
|
function ConnectedAnnouncementList({ className, }) {
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { useMemo } from 'react';
|
|
4
|
+
import { LocalStorageContext } from './local-storage-context.js';
|
|
5
|
+
|
|
6
|
+
function LocalStorageProvider({ children, localStorage, sessionStorage, }) {
|
|
7
|
+
const value = useMemo(() => ({
|
|
8
|
+
localStorage,
|
|
9
|
+
sessionStorage,
|
|
10
|
+
}), [localStorage, sessionStorage]);
|
|
11
|
+
return (jsx(LocalStorageContext.Provider, { value: value, children: children }));
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export { LocalStorageProvider };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare class MockStorage implements Storage {
|
|
2
|
+
private _state;
|
|
3
|
+
constructor();
|
|
4
|
+
get length(): number;
|
|
5
|
+
clear(): void;
|
|
6
|
+
getItem(key: string): string | null;
|
|
7
|
+
key(index: number): string | null;
|
|
8
|
+
removeItem(key: string): void;
|
|
9
|
+
setItem(key: string, value: string): void;
|
|
10
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
class MockStorage {
|
|
2
|
+
constructor() {
|
|
3
|
+
Object.defineProperty(this, "_state", {
|
|
4
|
+
enumerable: true,
|
|
5
|
+
configurable: true,
|
|
6
|
+
writable: true,
|
|
7
|
+
value: {}
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
get length() {
|
|
11
|
+
return Object.keys(this._state).length;
|
|
12
|
+
}
|
|
13
|
+
clear() {
|
|
14
|
+
this._state = {};
|
|
15
|
+
}
|
|
16
|
+
getItem(key) {
|
|
17
|
+
return Object.prototype.hasOwnProperty.call(this._state, key)
|
|
18
|
+
? this._state[key] || null
|
|
19
|
+
: null;
|
|
20
|
+
}
|
|
21
|
+
key(index) {
|
|
22
|
+
const keys = Object.keys(this._state);
|
|
23
|
+
return index >= 0 && index < keys.length ? keys[index] || null : null;
|
|
24
|
+
}
|
|
25
|
+
removeItem(key) {
|
|
26
|
+
if (Object.prototype.hasOwnProperty.call(this._state, key))
|
|
27
|
+
delete this._state[key];
|
|
28
|
+
}
|
|
29
|
+
setItem(key, value) {
|
|
30
|
+
this._state[key] = value;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export { MockStorage };
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { useState } from 'react';
|
|
2
|
+
import { useContext, useState } from 'react';
|
|
3
|
+
import { LocalStorageContext } from './local-storage-context.js';
|
|
3
4
|
|
|
4
5
|
function useLocalStorage(key, initialState) {
|
|
6
|
+
const { localStorage } = useContext(LocalStorageContext) ?? {
|
|
7
|
+
localStorage: typeof window === 'undefined' ? undefined : window.localStorage,
|
|
8
|
+
};
|
|
5
9
|
const storedValue = localStorage?.getItem(key);
|
|
6
10
|
const [internalValue, setInternalValue] = useState(storedValue ? JSON.parse(storedValue) : initialState);
|
|
7
11
|
function setValue(value) {
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { useState } from 'react';
|
|
2
|
+
import { useContext, useState } from 'react';
|
|
3
|
+
import { LocalStorageContext } from './local-storage-context.js';
|
|
3
4
|
|
|
4
5
|
function useSessionStorage(key, initialState) {
|
|
6
|
+
const { sessionStorage } = useContext(LocalStorageContext) ?? {
|
|
7
|
+
sessionStorage: typeof window === 'undefined' ? undefined : window.sessionStorage,
|
|
8
|
+
};
|
|
5
9
|
const storedValue = sessionStorage?.getItem(key);
|
|
6
10
|
const [internalValue, setInternalValue] = useState(storedValue ? JSON.parse(storedValue) : initialState);
|
|
7
11
|
function setValue(value) {
|
package/dist/styles.css
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sonic-equipment/ui",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "224.0.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"engines": {
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
"default": "./dist/index.js"
|
|
16
16
|
}
|
|
17
17
|
},
|
|
18
|
+
"sideEffects": false,
|
|
18
19
|
"files": ["dist", "README.md"],
|
|
19
20
|
"main": "dist/index.js",
|
|
20
21
|
"types": "./dist/index.d.ts",
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
var htmlEscapes = {
|
|
2
|
-
'&': '&',
|
|
3
|
-
'<': '<',
|
|
4
|
-
'>': '>',
|
|
5
|
-
'"': '"',
|
|
6
|
-
''': "'"
|
|
7
|
-
};
|
|
8
|
-
var hasAlphanumeric = new RegExp(/\w/i);
|
|
9
|
-
var regexEscapedHtml = /&(amp|quot|lt|gt|#39);/g;
|
|
10
|
-
var regexHasEscapedHtml = RegExp(regexEscapedHtml.source);
|
|
11
|
-
function unescape(value) {
|
|
12
|
-
return value && regexHasEscapedHtml.test(value) ? value.replace(regexEscapedHtml, function (character) {
|
|
13
|
-
return htmlEscapes[character];
|
|
14
|
-
}) : value;
|
|
15
|
-
}
|
|
16
|
-
function isPartHighlighted(parts, i) {
|
|
17
|
-
var _parts, _parts2;
|
|
18
|
-
var current = parts[i];
|
|
19
|
-
var isNextHighlighted = ((_parts = parts[i + 1]) === null || _parts === void 0 ? void 0 : _parts.isHighlighted) || true;
|
|
20
|
-
var isPreviousHighlighted = ((_parts2 = parts[i - 1]) === null || _parts2 === void 0 ? void 0 : _parts2.isHighlighted) || true;
|
|
21
|
-
if (!hasAlphanumeric.test(unescape(current.value)) && isPreviousHighlighted === isNextHighlighted) {
|
|
22
|
-
return isPreviousHighlighted;
|
|
23
|
-
}
|
|
24
|
-
return current.isHighlighted;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export { isPartHighlighted };
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { parseAlgoliaHitHighlight } from './parseAlgoliaHitHighlight.js';
|
|
2
|
-
import { reverseHighlightedParts } from './reverseHighlightedParts.js';
|
|
3
|
-
|
|
4
|
-
function parseAlgoliaHitReverseHighlight(props) {
|
|
5
|
-
return reverseHighlightedParts(parseAlgoliaHitHighlight(props));
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export { parseAlgoliaHitReverseHighlight };
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { parseAlgoliaHitSnippet } from './parseAlgoliaHitSnippet.js';
|
|
2
|
-
import { reverseHighlightedParts } from './reverseHighlightedParts.js';
|
|
3
|
-
|
|
4
|
-
function parseAlgoliaHitReverseSnippet(props) {
|
|
5
|
-
return reverseHighlightedParts(parseAlgoliaHitSnippet(props));
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export { parseAlgoliaHitReverseSnippet };
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { parseAttribute } from './parseAttribute.js';
|
|
2
|
-
import { getAttributeValueByPath } from '../../../../../../../@algolia_autocomplete-shared@1.19.2_@algolia_client-search@4.24.0_algoliasearch@4.24.0/node_modules/@algolia/autocomplete-shared/dist/esm/getAttributeValueByPath.js';
|
|
3
|
-
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';
|
|
4
|
-
|
|
5
|
-
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
6
|
-
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."); }
|
|
7
|
-
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); }
|
|
8
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
9
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
10
|
-
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; }
|
|
11
|
-
function parseAlgoliaHitSnippet(_ref) {
|
|
12
|
-
var hit = _ref.hit,
|
|
13
|
-
attribute = _ref.attribute;
|
|
14
|
-
var path = Array.isArray(attribute) ? attribute : [attribute];
|
|
15
|
-
var highlightedValue = getAttributeValueByPath(hit, ['_snippetResult'].concat(_toConsumableArray(path), ['value']));
|
|
16
|
-
if (typeof highlightedValue !== 'string') {
|
|
17
|
-
process.env.NODE_ENV !== 'production' ? warn(false, "The attribute \"".concat(path.join('.'), "\" described by the path ").concat(JSON.stringify(path), " does not exist on the hit. Did you set it in `attributesToSnippet`?") + '\nSee https://www.algolia.com/doc/api-reference/api-parameters/attributesToSnippet/') : void 0;
|
|
18
|
-
highlightedValue = getAttributeValueByPath(hit, path) || '';
|
|
19
|
-
}
|
|
20
|
-
return parseAttribute({
|
|
21
|
-
highlightedValue: highlightedValue
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export { parseAlgoliaHitSnippet };
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export { parseAlgoliaHitHighlight } from './highlight/parseAlgoliaHitHighlight.js';
|
|
2
|
-
export { parseAlgoliaHitReverseHighlight } from './highlight/parseAlgoliaHitReverseHighlight.js';
|
|
3
|
-
export { parseAlgoliaHitReverseSnippet } from './highlight/parseAlgoliaHitReverseSnippet.js';
|
|
4
|
-
export { parseAlgoliaHitSnippet } from './highlight/parseAlgoliaHitSnippet.js';
|
|
5
|
-
export { createRequester } from './requester/createRequester.js';
|
|
6
|
-
export { getAlgoliaFacets } from './requester/getAlgoliaFacets.js';
|
|
7
|
-
export { getAlgoliaResults } from './requester/getAlgoliaResults.js';
|
|
8
|
-
export { fetchAlgoliaResults } from './search/fetchAlgoliaResults.js';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { voidFunction } from '../model/defaults.js';
|
|
3
|
-
|
|
4
|
-
/** Mocks the localStorage and sessionStorage API in Node.js
|
|
5
|
-
* @see https://gitlab.com/kaictl/node/mock-local-storage */
|
|
6
|
-
const HAS_LOCAL_STORAGE_SUPPORT = typeof localStorage !== 'undefined';
|
|
7
|
-
function mockStorage() {
|
|
8
|
-
if (HAS_LOCAL_STORAGE_SUPPORT)
|
|
9
|
-
return;
|
|
10
|
-
// const global = require('global')
|
|
11
|
-
// const window = require('global/window')
|
|
12
|
-
let win;
|
|
13
|
-
if (typeof global !== 'undefined') {
|
|
14
|
-
win = global;
|
|
15
|
-
}
|
|
16
|
-
else if (typeof self === 'undefined') {
|
|
17
|
-
win = {};
|
|
18
|
-
}
|
|
19
|
-
else {
|
|
20
|
-
win = self;
|
|
21
|
-
}
|
|
22
|
-
Object.defineProperty(global, 'Storage', {
|
|
23
|
-
value: createStorage,
|
|
24
|
-
});
|
|
25
|
-
Object.defineProperty(win, 'Storage', {
|
|
26
|
-
value: createStorage,
|
|
27
|
-
});
|
|
28
|
-
Object.defineProperty(global, 'localStorage', {
|
|
29
|
-
value: createStorage(),
|
|
30
|
-
});
|
|
31
|
-
Object.defineProperty(win, 'localStorage', {
|
|
32
|
-
value: global.localStorage,
|
|
33
|
-
});
|
|
34
|
-
Object.defineProperty(global, 'sessionStorage', {
|
|
35
|
-
value: createStorage(),
|
|
36
|
-
});
|
|
37
|
-
Object.defineProperty(win, 'sessionStorage', {
|
|
38
|
-
value: global.sessionStorage,
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
function createStorage() {
|
|
42
|
-
const UNSET = Symbol();
|
|
43
|
-
const s = {};
|
|
44
|
-
let _itemInsertionCallback = voidFunction;
|
|
45
|
-
Object.defineProperty(s, 'setItem', {
|
|
46
|
-
get: () => {
|
|
47
|
-
return (k, v = UNSET) => {
|
|
48
|
-
if (v === UNSET) {
|
|
49
|
-
throw new TypeError(`Failed to execute 'setItem' on 'Storage': 2 arguments required, but only 1 present.`);
|
|
50
|
-
}
|
|
51
|
-
if (!s.hasOwnProperty(String(k))) {
|
|
52
|
-
_itemInsertionCallback();
|
|
53
|
-
}
|
|
54
|
-
s[String(k)] = String(v);
|
|
55
|
-
};
|
|
56
|
-
},
|
|
57
|
-
});
|
|
58
|
-
Object.defineProperty(s, 'getItem', {
|
|
59
|
-
get: () => {
|
|
60
|
-
return (k) => {
|
|
61
|
-
return s.hasOwnProperty(String(k)) ? s[String(k)] : null;
|
|
62
|
-
};
|
|
63
|
-
},
|
|
64
|
-
});
|
|
65
|
-
Object.defineProperty(s, 'removeItem', {
|
|
66
|
-
get: () => {
|
|
67
|
-
return (k) => {
|
|
68
|
-
if (s.hasOwnProperty(String(k))) {
|
|
69
|
-
delete s[String(k)];
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
},
|
|
73
|
-
});
|
|
74
|
-
Object.defineProperty(s, 'clear', {
|
|
75
|
-
get: () => {
|
|
76
|
-
return () => {
|
|
77
|
-
for (const k in s) {
|
|
78
|
-
delete s[String(k)];
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
},
|
|
82
|
-
});
|
|
83
|
-
Object.defineProperty(s, 'length', {
|
|
84
|
-
get: () => {
|
|
85
|
-
return Object.keys(s).length;
|
|
86
|
-
},
|
|
87
|
-
});
|
|
88
|
-
Object.defineProperty(s, 'key', {
|
|
89
|
-
value: (k) => {
|
|
90
|
-
return Object.keys(s)[k] || null;
|
|
91
|
-
},
|
|
92
|
-
});
|
|
93
|
-
Object.defineProperty(s, 'itemInsertionCallback', {
|
|
94
|
-
get: () => {
|
|
95
|
-
return _itemInsertionCallback;
|
|
96
|
-
},
|
|
97
|
-
set: v => {
|
|
98
|
-
if (!v || typeof v != 'function') {
|
|
99
|
-
v = voidFunction;
|
|
100
|
-
}
|
|
101
|
-
_itemInsertionCallback = v;
|
|
102
|
-
},
|
|
103
|
-
});
|
|
104
|
-
return s;
|
|
105
|
-
}
|
|
106
|
-
// Mock localStorage
|
|
107
|
-
mockStorage();
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import * as index 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/index.js';
|
|
2
|
-
|
|
3
|
-
const { createAutocomplete } = index;
|
|
4
|
-
|
|
5
|
-
export { createAutocomplete };
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import * as index 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/index.js';
|
|
2
|
-
|
|
3
|
-
const { createQuerySuggestionsPlugin } = index;
|
|
4
|
-
|
|
5
|
-
export { createQuerySuggestionsPlugin };
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import * as module1 from '@algolia/autocomplete-plugin-recent-searches';
|
|
2
|
-
|
|
3
|
-
const { search } = module1;
|
|
4
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5
|
-
const createLocalStorageRecentSearchesPlugin = module1.default
|
|
6
|
-
.createLocalStorageRecentSearchesPlugin;
|
|
7
|
-
|
|
8
|
-
export { createLocalStorageRecentSearchesPlugin, search };
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import * as requester from '@algolia/autocomplete-preset-algolia/dist/esm';
|
|
2
|
-
export declare const getAlgoliaResults: typeof requester.getAlgoliaResults, parseAlgoliaHitHighlight: typeof requester.parseAlgoliaHitHighlight;
|
|
3
|
-
export type { HighlightedHit } from '@algolia/autocomplete-preset-algolia/dist/esm';
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import * as index 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/index.js';
|
|
2
|
-
|
|
3
|
-
const { getAlgoliaResults, parseAlgoliaHitHighlight } = index;
|
|
4
|
-
|
|
5
|
-
export { getAlgoliaResults, parseAlgoliaHitHighlight };
|