@websolutespa/bom-mixer-hooks 1.2.0 → 1.3.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/CHANGELOG.md +63 -49
- package/dist/index.d.ts +42 -23
- package/dist/index.js +177 -40
- package/dist/index.mjs +157 -26
- package/package.json +2 -2
- package/src/index.ts +1 -0
- package/src/useDateTimeFormat/useDateTimeFormat.test.tsx +2 -2
- package/src/useDateTimeFormat/useDateTimeFormat.ts +1 -1
- package/src/useElementSize/useElementSize.test.ts +5 -5
- package/src/useEventListener/useEventListener.test.ts +10 -10
- package/src/useFilters/useFilters.test.ts +1 -1
- package/src/useGeolocation/useGeolocation.test.ts +2 -2
- package/src/useInfiniteLoader/useInfiniteLoader.ts +1 -1
- package/src/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.ts +2 -1
- package/src/useKeyboard/useKeyboard.test.tsx +11 -11
- package/src/useKeyboard/useKeyboard.ts +2 -2
- package/src/useLabel/useLabel.tsx +30 -20
- package/src/useNumber/useNumber.test.tsx +1 -1
- package/src/useScrollTo/useScrollTo.ts +5 -4
- package/src/useSearchParams/useSearchParams.test.ts +1 -1
- package/src/useSearchParams/useSearchParams.ts +17 -15
- package/src/useSearchParamsEncoded/useSearchParamsEncoded.test.ts +1 -1
- package/src/useSearchParamsEncoded/useSearchParamsEncoded.ts +13 -13
- package/src/useSearchParamsQs/useSearchParamsQs.test.ts +80 -0
- package/src/useSearchParamsQs/useSearchParamsQs.ts +136 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,49 +1,63 @@
|
|
|
1
|
-
# @websolutespa/bom-mixer-hooks
|
|
2
|
-
|
|
3
|
-
## 1.
|
|
4
|
-
|
|
5
|
-
### Minor Changes
|
|
6
|
-
|
|
7
|
-
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
1
|
+
# @websolutespa/bom-mixer-hooks
|
|
2
|
+
|
|
3
|
+
## 1.3.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Added: useSearchParamsQs.
|
|
8
|
+
- Modified: useSearchParamsEncoded, useSearchParams, useScrollTo.
|
|
9
|
+
|
|
10
|
+
## 1.2.1
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Added: LabelService.
|
|
15
|
+
- Modified: useLabels, useScrollTo.
|
|
16
|
+
|
|
17
|
+
## 1.2.0
|
|
18
|
+
|
|
19
|
+
### Minor Changes
|
|
20
|
+
|
|
21
|
+
- Updating: next 13.
|
|
22
|
+
|
|
23
|
+
## 1.1.0
|
|
24
|
+
|
|
25
|
+
### Minor Changes
|
|
26
|
+
|
|
27
|
+
- Modified: useHttp, useApi.
|
|
28
|
+
|
|
29
|
+
## 1.0.0
|
|
30
|
+
|
|
31
|
+
### Minor Changes
|
|
32
|
+
|
|
33
|
+
- Added: useScrolled.
|
|
34
|
+
|
|
35
|
+
## 0.2.2
|
|
36
|
+
|
|
37
|
+
### Patch Changes
|
|
38
|
+
|
|
39
|
+
- Modified: useBreakpoint theme mediaQuery.
|
|
40
|
+
|
|
41
|
+
## 0.2.1
|
|
42
|
+
|
|
43
|
+
### Patch Changes
|
|
44
|
+
|
|
45
|
+
- Added: source files.
|
|
46
|
+
|
|
47
|
+
## 0.2.0
|
|
48
|
+
|
|
49
|
+
### Minor Changes
|
|
50
|
+
|
|
51
|
+
- Added: splat routes.
|
|
52
|
+
|
|
53
|
+
## 0.1.0
|
|
54
|
+
|
|
55
|
+
### Minor Changes
|
|
56
|
+
|
|
57
|
+
- Added: @websolutespa/bom-core.
|
|
58
|
+
|
|
59
|
+
## 0.0.2
|
|
60
|
+
|
|
61
|
+
### Patch Changes
|
|
62
|
+
|
|
63
|
+
- Added: first release.
|
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
|
5
5
|
import * as zustand_middleware from 'zustand/middleware';
|
|
6
6
|
import { StateStorage } from 'zustand/middleware';
|
|
7
7
|
import * as zustand from 'zustand';
|
|
8
|
-
import { ISchema, IEquatable, ILayout, IPage } from '@websolutespa/bom-core';
|
|
8
|
+
import { ISchema, IEquatable, ILabel, ILocalizable, ILayout, IPage } from '@websolutespa/bom-core';
|
|
9
9
|
import { ICartItem, ICartAddItem, IAddressOptions, ICheckoutPartial, IFeatureType, IUser } from '@websolutespa/bom-mixer-models';
|
|
10
10
|
import { NextRouter } from 'next/router';
|
|
11
11
|
|
|
@@ -252,7 +252,7 @@ declare function useGeolocation(options?: PositionOptions): GeoLocationSensorSta
|
|
|
252
252
|
|
|
253
253
|
declare function useIdle(delay?: number, immediate?: boolean): boolean;
|
|
254
254
|
|
|
255
|
-
declare function useInfiniteLoader(items:
|
|
255
|
+
declare function useInfiniteLoader<T = any>(items: T[], perPage?: number, delayInMs?: number): [T[], () => void, boolean];
|
|
256
256
|
|
|
257
257
|
declare const useIsomorphicLayoutEffect: typeof useEffect;
|
|
258
258
|
|
|
@@ -371,16 +371,19 @@ type KeyboardResult = {
|
|
|
371
371
|
type UseKeyboardHandler = (event: React__default.KeyboardEvent | KeyboardEvent) => void;
|
|
372
372
|
type UseKeyboard = (handler: UseKeyboardHandler, keyBindings: Array<number> | number, options?: KeyboardOptions) => KeyboardResult;
|
|
373
373
|
|
|
374
|
-
type ILabelContext = (key: string, params?:
|
|
375
|
-
[key: string]: any;
|
|
376
|
-
}) => string;
|
|
374
|
+
type ILabelContext = (key: string, params?: Record<string, any>) => string;
|
|
377
375
|
declare const useLabel: () => ILabelContext;
|
|
378
376
|
declare function LabelProvider({ children }: {
|
|
379
377
|
children?: React__default.ReactNode;
|
|
380
378
|
}): react_jsx_runtime.JSX.Element;
|
|
381
|
-
declare
|
|
382
|
-
|
|
383
|
-
|
|
379
|
+
declare class LabelService {
|
|
380
|
+
labels: ILabel[];
|
|
381
|
+
dictionary: Record<string, ILocalizable | undefined>;
|
|
382
|
+
constructor(labels: ILabel[]);
|
|
383
|
+
getLabel(key: string, params?: Record<string, any>): string;
|
|
384
|
+
}
|
|
385
|
+
declare function parseLabel(dictionary: Record<string, ILocalizable | undefined>, key: string, params?: Record<string, any>): string;
|
|
386
|
+
declare function parseParams(label: string, params: Record<string, any>): string;
|
|
384
387
|
|
|
385
388
|
type ILayoutContext = ILayout;
|
|
386
389
|
declare const useLayout: () => ILayout;
|
|
@@ -451,14 +454,13 @@ type Scroll = {
|
|
|
451
454
|
};
|
|
452
455
|
declare function useScroll(): Scroll;
|
|
453
456
|
|
|
454
|
-
declare function useScrollTo(): (event: React.MouseEvent<HTMLElement>) => void;
|
|
457
|
+
declare function useScrollTo(offset?: number): (event: React.MouseEvent<HTMLElement>) => void;
|
|
455
458
|
declare function scrollToSelector(selector?: string, offset?: number): void;
|
|
456
459
|
declare function scrollToRelativeY(y?: number, offset?: number): void;
|
|
457
460
|
declare function scrollToY(y?: number): void;
|
|
458
461
|
|
|
459
462
|
declare function useScrolled(callback?: (top: number, left: number) => boolean): boolean;
|
|
460
463
|
|
|
461
|
-
declare const isBrowser: boolean;
|
|
462
464
|
declare function getSearchParams(url: string, key?: string): IParams | string | null;
|
|
463
465
|
declare function updateSearchParams(currentPath: string, params: IParams): {
|
|
464
466
|
pathname: string;
|
|
@@ -470,21 +472,20 @@ declare function replaceSearchParams(router: NextRouter, params: IParams): void;
|
|
|
470
472
|
declare function pushSearchParams(router: NextRouter, params: IParams): void;
|
|
471
473
|
declare function replaceSearchParamsSilently(params: IParams): void;
|
|
472
474
|
declare function useSearchParams(): IUseSearchParamsResult;
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
params: IParams;
|
|
476
|
-
replaceParamsSilently: (params: IParams) => void;
|
|
477
|
-
replaceParams: (params: IParams) => void;
|
|
475
|
+
type IParams = {
|
|
476
|
+
[key: string]: string;
|
|
478
477
|
};
|
|
479
478
|
type IUseSearchParamsValueResult = {
|
|
480
479
|
params: string | null;
|
|
481
480
|
replaceParamsSilently: (params: IParams) => void;
|
|
482
481
|
};
|
|
483
|
-
type
|
|
484
|
-
|
|
482
|
+
type IUseSearchParamsResult = {
|
|
483
|
+
params: IParams;
|
|
484
|
+
replaceParamsSilently: (params: IParams) => void;
|
|
485
|
+
replaceParams: (params: IParams) => void;
|
|
485
486
|
};
|
|
487
|
+
declare function useSearchParamsValue(key: string): IUseSearchParamsValueResult;
|
|
486
488
|
|
|
487
|
-
declare function decode(encoded: string | null | undefined, key?: string): IParamsEncoded;
|
|
488
489
|
declare function getSearchParamsEncoded(url: string, key?: string): {} | null;
|
|
489
490
|
declare function updateSearchParamsEncoded(currentPath: string, value: IParamsEncoded, key?: string): {
|
|
490
491
|
pathname: string;
|
|
@@ -495,15 +496,33 @@ declare function updateSearchParamsEncoded(currentPath: string, value: IParamsEn
|
|
|
495
496
|
declare function replaceSearchParamsEncoded(router: NextRouter, value: IParamsEncoded, key?: string): void;
|
|
496
497
|
declare function pushSearchParamsEncoded(router: NextRouter, value: IParamsEncoded, key?: string): void;
|
|
497
498
|
declare function replaceSearchParamsEncodedSilently(value: IParamsEncoded, key?: string): void;
|
|
498
|
-
|
|
499
|
+
type IParamsEncoded = {
|
|
500
|
+
[key: string]: any;
|
|
501
|
+
} | null;
|
|
499
502
|
type IUseSearchParamsEncodedResult = {
|
|
500
503
|
params: IParamsEncoded;
|
|
501
504
|
replaceParamsSilently: (params: IParamsEncoded) => void;
|
|
502
505
|
replaceParams: (params: IParamsEncoded) => void;
|
|
503
506
|
};
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
} | null;
|
|
507
|
+
declare function useSearchParamsEncoded(key?: string): IUseSearchParamsEncodedResult;
|
|
508
|
+
|
|
509
|
+
declare function getSearchParamsQs(url: string, key?: string): {} | null;
|
|
510
|
+
declare function updateSearchParamsQs(currentPath: string, value: IParamsQs, key?: string): {
|
|
511
|
+
pathname: string;
|
|
512
|
+
query: {
|
|
513
|
+
[key: string]: string;
|
|
514
|
+
};
|
|
515
|
+
};
|
|
516
|
+
declare function replaceSearchParamsQs(router: NextRouter, value: IParamsQs, key?: string): void;
|
|
517
|
+
declare function pushSearchParamsQs(router: NextRouter, value: IParamsQs, key?: string): void;
|
|
518
|
+
declare function replaceSearchParamsQsSilently(value: IParamsQs, key?: string): void;
|
|
519
|
+
type IParamsQs = {};
|
|
520
|
+
type IUseSearchParamsQsResult = {
|
|
521
|
+
params: Record<string, any> | null;
|
|
522
|
+
replaceParamsSilently: (params: IParamsQs) => void;
|
|
523
|
+
replaceParams: (params: IParamsQs) => void;
|
|
524
|
+
};
|
|
525
|
+
declare function useSearchParamsQs(key?: string): IUseSearchParamsQsResult;
|
|
507
526
|
|
|
508
527
|
type Sorting<T> = {
|
|
509
528
|
items: T[];
|
|
@@ -552,4 +571,4 @@ type WindowSize = {
|
|
|
552
571
|
};
|
|
553
572
|
declare function useWindowSize(): WindowSize;
|
|
554
573
|
|
|
555
|
-
export { BodyScrollOptions, CartContext, CartProvider, CheckoutContext, CheckoutProvider, ClickOutGetContainer, CurrentStateType, ElementStackItem, Filter, FilterMode, FilterParams, FilterValues, GeoLocationSensorState, IFilter, IFilterOption, IGeolocationPositionError, ILabelContext, ILayoutContext, IPageContext, IPaginationInfo, IParams, IParamsEncoded, IUseSearchParamsEncodedResult, IUseSearchParamsResult, IUseSearchParamsValueResult, KeyCode, KeyMod, KeyboardOptions, KeyboardResult, LabelProvider, LayoutProvider, PageProvider, SSRState, SizeResult, SizeType, Sorting, UIReducer, UIValue, UseFiltersResultType, UseKeyboard, UseKeyboardHandler, createElementWithId, createGenericContext,
|
|
574
|
+
export { BodyScrollOptions, CartContext, CartProvider, CheckoutContext, CheckoutProvider, ClickOutGetContainer, CurrentStateType, ElementStackItem, Filter, FilterMode, FilterParams, FilterValues, GeoLocationSensorState, IFilter, IFilterOption, IGeolocationPositionError, ILabelContext, ILayoutContext, IPageContext, IPaginationInfo, IParams, IParamsEncoded, IParamsQs, IUseSearchParamsEncodedResult, IUseSearchParamsQsResult, IUseSearchParamsResult, IUseSearchParamsValueResult, KeyCode, KeyMod, KeyboardOptions, KeyboardResult, LabelProvider, LabelService, LayoutProvider, PageProvider, SSRState, SizeResult, SizeType, Sorting, UIReducer, UIValue, UseFiltersResultType, UseKeyboard, UseKeyboardHandler, createElementWithId, createGenericContext, detectIsBrowser, filtersToParams, getCurrentPosition, getFilteredItems, getFilters, getOwnerPaddingRight, getOwnerScrollbarWidth, getPagedItems, getRealSize, getSearchParams, getSearchParamsEncoded, getSearchParamsQs, getUID, hasGeolocation, parseLabel, parseParams, pushSearchParams, pushSearchParamsEncoded, pushSearchParamsQs, replaceSearchParams, replaceSearchParamsEncoded, replaceSearchParamsEncodedSilently, replaceSearchParamsQs, replaceSearchParamsQsSilently, replaceSearchParamsSilently, scrollToRelativeY, scrollToSelector, scrollToY, setFilters, updateSearchParams, updateSearchParamsEncoded, updateSearchParamsQs, useApi, useApiDelete, useApiFetch, useApiGet, useApiPatch, useApiPost, useApiPut, useBodyScroll, useBreakpoint, useCart, useCheckout, useClickAnyWhere, useClickOut, useCurrency, useCurrentState, useDateTimeFormat, useDebounce, useDebounceCallback, useDebugChangedProps, useDomObserver, useDrawer, useElementSize, useEventListener, useFilters, useGeolocation, useIdle, useInfiniteLoader, useIsomorphicLayoutEffect, useKeyboard, useLabel, useLayout, useModal, useMounted, useNumber, usePage, usePagination, usePortal, usePrevious, useRealSize, useResize, useSSR, useScroll, useScrollTo, useScrolled, useSearchParams, useSearchParamsEncoded, useSearchParamsQs, useSearchParamsValue, useSorting, useSwiperIndex, useSyncedRef, useUI, useUnit, useUnmountEffect, useUser, useWindowSize };
|
package/dist/index.js
CHANGED
|
@@ -78,11 +78,11 @@ __export(src_exports, {
|
|
|
78
78
|
KeyCode: () => KeyCode,
|
|
79
79
|
KeyMod: () => KeyMod,
|
|
80
80
|
LabelProvider: () => LabelProvider,
|
|
81
|
+
LabelService: () => LabelService,
|
|
81
82
|
LayoutProvider: () => LayoutProvider,
|
|
82
83
|
PageProvider: () => PageProvider,
|
|
83
84
|
createElementWithId: () => createElementWithId,
|
|
84
85
|
createGenericContext: () => createGenericContext,
|
|
85
|
-
decode: () => decode,
|
|
86
86
|
detectIsBrowser: () => detectIsBrowser,
|
|
87
87
|
filtersToParams: () => filtersToParams,
|
|
88
88
|
getCurrentPosition: () => getCurrentPosition,
|
|
@@ -94,15 +94,19 @@ __export(src_exports, {
|
|
|
94
94
|
getRealSize: () => getRealSize,
|
|
95
95
|
getSearchParams: () => getSearchParams,
|
|
96
96
|
getSearchParamsEncoded: () => getSearchParamsEncoded,
|
|
97
|
+
getSearchParamsQs: () => getSearchParamsQs,
|
|
97
98
|
getUID: () => getUID,
|
|
98
99
|
hasGeolocation: () => hasGeolocation,
|
|
99
|
-
|
|
100
|
+
parseLabel: () => parseLabel,
|
|
100
101
|
parseParams: () => parseParams,
|
|
101
102
|
pushSearchParams: () => pushSearchParams,
|
|
102
103
|
pushSearchParamsEncoded: () => pushSearchParamsEncoded,
|
|
104
|
+
pushSearchParamsQs: () => pushSearchParamsQs,
|
|
103
105
|
replaceSearchParams: () => replaceSearchParams,
|
|
104
106
|
replaceSearchParamsEncoded: () => replaceSearchParamsEncoded,
|
|
105
107
|
replaceSearchParamsEncodedSilently: () => replaceSearchParamsEncodedSilently,
|
|
108
|
+
replaceSearchParamsQs: () => replaceSearchParamsQs,
|
|
109
|
+
replaceSearchParamsQsSilently: () => replaceSearchParamsQsSilently,
|
|
106
110
|
replaceSearchParamsSilently: () => replaceSearchParamsSilently,
|
|
107
111
|
scrollToRelativeY: () => scrollToRelativeY,
|
|
108
112
|
scrollToSelector: () => scrollToSelector,
|
|
@@ -110,6 +114,7 @@ __export(src_exports, {
|
|
|
110
114
|
setFilters: () => setFilters,
|
|
111
115
|
updateSearchParams: () => updateSearchParams,
|
|
112
116
|
updateSearchParamsEncoded: () => updateSearchParamsEncoded,
|
|
117
|
+
updateSearchParamsQs: () => updateSearchParamsQs,
|
|
113
118
|
useApi: () => useApi,
|
|
114
119
|
useApiDelete: () => useApiDelete,
|
|
115
120
|
useApiFetch: () => useApiFetch,
|
|
@@ -156,6 +161,7 @@ __export(src_exports, {
|
|
|
156
161
|
useScrolled: () => useScrolled,
|
|
157
162
|
useSearchParams: () => useSearchParams,
|
|
158
163
|
useSearchParamsEncoded: () => useSearchParamsEncoded,
|
|
164
|
+
useSearchParamsQs: () => useSearchParamsQs,
|
|
159
165
|
useSearchParamsValue: () => useSearchParamsValue,
|
|
160
166
|
useSorting: () => useSorting,
|
|
161
167
|
useSwiperIndex: () => useSwiperIndex,
|
|
@@ -332,8 +338,9 @@ var import_react6 = require("react");
|
|
|
332
338
|
var import_react5 = require("react");
|
|
333
339
|
|
|
334
340
|
// src/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.ts
|
|
341
|
+
var import_bom_core2 = require("@websolutespa/bom-core");
|
|
335
342
|
var import_react4 = require("react");
|
|
336
|
-
var useIsomorphicLayoutEffect =
|
|
343
|
+
var useIsomorphicLayoutEffect = import_bom_core2.isBrowser ? import_react4.useLayoutEffect : import_react4.useEffect;
|
|
337
344
|
|
|
338
345
|
// src/useEventListener/useEventListener.ts
|
|
339
346
|
function useEventListener_(eventName, handler, element, options) {
|
|
@@ -1346,16 +1353,28 @@ var useKeyboard = (handler, keyBindings, options = {}) => {
|
|
|
1346
1353
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
1347
1354
|
var [useLabel, LabelContextProvider] = createGenericContext();
|
|
1348
1355
|
function LabelProvider({ children }) {
|
|
1349
|
-
const {
|
|
1350
|
-
const
|
|
1351
|
-
const
|
|
1352
|
-
|
|
1353
|
-
if (params) {
|
|
1354
|
-
return parseParams(label, params);
|
|
1355
|
-
}
|
|
1356
|
-
return label;
|
|
1356
|
+
const { labels } = useLayout();
|
|
1357
|
+
const labelService = new LabelService(labels);
|
|
1358
|
+
const getLabel = (key, params) => {
|
|
1359
|
+
return labelService.getLabel(key, params);
|
|
1357
1360
|
};
|
|
1358
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(LabelContextProvider, { value:
|
|
1361
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(LabelContextProvider, { value: getLabel, children });
|
|
1362
|
+
}
|
|
1363
|
+
var LabelService = class {
|
|
1364
|
+
constructor(labels) {
|
|
1365
|
+
this.labels = labels;
|
|
1366
|
+
this.dictionary = Object.fromEntries(labels.map((l) => [l.id, l.text]));
|
|
1367
|
+
}
|
|
1368
|
+
getLabel(key, params) {
|
|
1369
|
+
return parseLabel(this.dictionary, key, params);
|
|
1370
|
+
}
|
|
1371
|
+
};
|
|
1372
|
+
function parseLabel(dictionary, key, params) {
|
|
1373
|
+
const label = dictionary[key] != null ? dictionary[key] : key;
|
|
1374
|
+
if (params) {
|
|
1375
|
+
return parseParams(label, params);
|
|
1376
|
+
}
|
|
1377
|
+
return label;
|
|
1359
1378
|
}
|
|
1360
1379
|
function parseParams(label, params) {
|
|
1361
1380
|
const TEMPLATE_REGEXP = /@(\w+)/g;
|
|
@@ -1444,9 +1463,9 @@ function usePagination($items, $page = 1, $perPage = 15) {
|
|
|
1444
1463
|
var import_react27 = require("react");
|
|
1445
1464
|
var namespace = "theme";
|
|
1446
1465
|
function usePortal(name = getUID(), getContainer) {
|
|
1447
|
-
const { isBrowser:
|
|
1466
|
+
const { isBrowser: isBrowser6 } = useSSR();
|
|
1448
1467
|
const id = `${namespace}-${name}`;
|
|
1449
|
-
const [portal, setPortal] = (0, import_react27.useState)(
|
|
1468
|
+
const [portal, setPortal] = (0, import_react27.useState)(isBrowser6 ? createElementWithId(id) : null);
|
|
1450
1469
|
(0, import_react27.useEffect)(() => {
|
|
1451
1470
|
const container = typeof getContainer === "function" ? getContainer() : null;
|
|
1452
1471
|
const parentElement = container || document.body;
|
|
@@ -1538,19 +1557,20 @@ function useScroll() {
|
|
|
1538
1557
|
}
|
|
1539
1558
|
|
|
1540
1559
|
// src/useScrollTo/useScrollTo.ts
|
|
1560
|
+
var import_bom_core3 = require("@websolutespa/bom-core");
|
|
1541
1561
|
var import_framer_motion = require("framer-motion");
|
|
1542
|
-
function useScrollTo() {
|
|
1562
|
+
function useScrollTo(offset = 0) {
|
|
1543
1563
|
const scrollToHash = (event) => {
|
|
1544
1564
|
const href = event.currentTarget.getAttribute("href");
|
|
1545
1565
|
if (href && href.indexOf("#") !== -1) {
|
|
1546
1566
|
const hashId = `#${href.split("#")[1]}`;
|
|
1547
|
-
scrollToSelector(hashId);
|
|
1567
|
+
scrollToSelector(hashId, offset);
|
|
1548
1568
|
}
|
|
1549
1569
|
};
|
|
1550
1570
|
return scrollToHash;
|
|
1551
1571
|
}
|
|
1552
1572
|
function scrollToSelector(selector, offset = 0) {
|
|
1553
|
-
if (selector &&
|
|
1573
|
+
if (selector && import_bom_core3.isBrowser) {
|
|
1554
1574
|
const element = document.querySelector(selector);
|
|
1555
1575
|
if (element) {
|
|
1556
1576
|
const rect = element.getBoundingClientRect();
|
|
@@ -1593,9 +1613,9 @@ function useScrolled(callback = DEFAULT_CALLBACK) {
|
|
|
1593
1613
|
}
|
|
1594
1614
|
|
|
1595
1615
|
// src/useSearchParams/useSearchParams.ts
|
|
1616
|
+
var import_bom_core4 = require("@websolutespa/bom-core");
|
|
1596
1617
|
var import_router = require("next/router");
|
|
1597
1618
|
var import_react32 = require("react");
|
|
1598
|
-
var isBrowser = typeof window !== "undefined";
|
|
1599
1619
|
function replace_(params) {
|
|
1600
1620
|
if (window.history) {
|
|
1601
1621
|
const title = document.title;
|
|
@@ -1646,7 +1666,7 @@ function pushSearchParams(router, params) {
|
|
|
1646
1666
|
router.push({ pathname, query });
|
|
1647
1667
|
}
|
|
1648
1668
|
function replaceSearchParamsSilently(params) {
|
|
1649
|
-
if (isBrowser) {
|
|
1669
|
+
if (import_bom_core4.isBrowser) {
|
|
1650
1670
|
const searchParams = serialize_(window.location.search, params);
|
|
1651
1671
|
replace_(searchParams);
|
|
1652
1672
|
}
|
|
@@ -1682,18 +1702,19 @@ function useSearchParamsValue(key) {
|
|
|
1682
1702
|
}
|
|
1683
1703
|
|
|
1684
1704
|
// src/useSearchParamsEncoded/useSearchParamsEncoded.ts
|
|
1705
|
+
var import_bom_core5 = require("@websolutespa/bom-core");
|
|
1685
1706
|
var import_router2 = require("next/router");
|
|
1686
1707
|
var import_react33 = require("react");
|
|
1687
1708
|
var USE_ENCRYPTION = true;
|
|
1688
1709
|
function base64ToString(base64) {
|
|
1689
1710
|
if (!USE_ENCRYPTION)
|
|
1690
1711
|
return base64;
|
|
1691
|
-
return isBrowser ? window.atob(base64) : Buffer.from(base64, "base64").toString();
|
|
1712
|
+
return import_bom_core5.isBrowser ? window.atob(base64) : Buffer.from(base64, "base64").toString();
|
|
1692
1713
|
}
|
|
1693
1714
|
function stringToBase64(text) {
|
|
1694
1715
|
if (!USE_ENCRYPTION)
|
|
1695
1716
|
return text;
|
|
1696
|
-
return isBrowser ? window.btoa(text) : Buffer.from(text).toString("base64");
|
|
1717
|
+
return import_bom_core5.isBrowser ? window.btoa(text) : Buffer.from(text).toString("base64");
|
|
1697
1718
|
}
|
|
1698
1719
|
function stringToURLSearchParams(url) {
|
|
1699
1720
|
return new URLSearchParams(url);
|
|
@@ -1782,7 +1803,7 @@ function pushSearchParamsEncoded(router, value, key) {
|
|
|
1782
1803
|
router.push({ pathname, query });
|
|
1783
1804
|
}
|
|
1784
1805
|
function replaceSearchParamsEncodedSilently(value, key) {
|
|
1785
|
-
if (isBrowser) {
|
|
1806
|
+
if (import_bom_core5.isBrowser) {
|
|
1786
1807
|
const searchParams = serialize_2(window.location.search, value, key);
|
|
1787
1808
|
replace_2(searchParams);
|
|
1788
1809
|
}
|
|
@@ -1803,13 +1824,123 @@ function useSearchParamsEncoded(key) {
|
|
|
1803
1824
|
return { params, replaceParamsSilently, replaceParams };
|
|
1804
1825
|
}
|
|
1805
1826
|
|
|
1806
|
-
// src/
|
|
1827
|
+
// src/useSearchParamsQs/useSearchParamsQs.ts
|
|
1828
|
+
var import_bom_core6 = require("@websolutespa/bom-core");
|
|
1829
|
+
var import_router3 = require("next/router");
|
|
1807
1830
|
var import_react34 = require("react");
|
|
1831
|
+
function decode2(encoded, key) {
|
|
1832
|
+
let decoded = null;
|
|
1833
|
+
if (encoded) {
|
|
1834
|
+
decoded = (0, import_bom_core6.qsDeserializeRaw)(encoded);
|
|
1835
|
+
}
|
|
1836
|
+
if (key && decoded) {
|
|
1837
|
+
decoded = decoded[key];
|
|
1838
|
+
}
|
|
1839
|
+
return decoded || null;
|
|
1840
|
+
}
|
|
1841
|
+
function encode2(params, value, key) {
|
|
1842
|
+
if (key) {
|
|
1843
|
+
params = __spreadProps(__spreadValues({}, params), { [key]: value });
|
|
1844
|
+
} else if (typeof value === "object") {
|
|
1845
|
+
params = __spreadValues(__spreadValues({}, params), value);
|
|
1846
|
+
} else {
|
|
1847
|
+
params = __spreadValues({}, params);
|
|
1848
|
+
}
|
|
1849
|
+
const encoded = (0, import_bom_core6.qsSerializeRaw)(params);
|
|
1850
|
+
return encoded;
|
|
1851
|
+
}
|
|
1852
|
+
function stringToURLSearchParams2(url) {
|
|
1853
|
+
return new URLSearchParams(url);
|
|
1854
|
+
}
|
|
1855
|
+
function getURLSearchParams2(url, key) {
|
|
1856
|
+
const params = stringToURLSearchParams2(url);
|
|
1857
|
+
return params.get(key);
|
|
1858
|
+
}
|
|
1859
|
+
function setURLSearchParams2(url, keyOrValue, value) {
|
|
1860
|
+
const params = stringToURLSearchParams2(url);
|
|
1861
|
+
if (value != null) {
|
|
1862
|
+
params.set(keyOrValue, value);
|
|
1863
|
+
} else {
|
|
1864
|
+
params.set(keyOrValue, "");
|
|
1865
|
+
}
|
|
1866
|
+
return params;
|
|
1867
|
+
}
|
|
1868
|
+
function replace_3(params) {
|
|
1869
|
+
if (window.history) {
|
|
1870
|
+
const title = document.title;
|
|
1871
|
+
const url = `${window.location.href.split("?")[0]}?${params.toString()}`;
|
|
1872
|
+
window.history.replaceState(params.toString(), title, url);
|
|
1873
|
+
}
|
|
1874
|
+
}
|
|
1875
|
+
function deserialize_3(url, key) {
|
|
1876
|
+
const encoded = getURLSearchParams2(url, "params");
|
|
1877
|
+
return decode2(encoded, key);
|
|
1878
|
+
}
|
|
1879
|
+
function serialize_3(url, value, key) {
|
|
1880
|
+
const params = deserialize_3(url);
|
|
1881
|
+
const encoded = encode2(params, value, key);
|
|
1882
|
+
return setURLSearchParams2(url, "params", encoded);
|
|
1883
|
+
}
|
|
1884
|
+
function searchParamsToObject_3(params) {
|
|
1885
|
+
const entries = params.entries();
|
|
1886
|
+
const result = {};
|
|
1887
|
+
for (const [key, value] of entries) {
|
|
1888
|
+
result[key] = value;
|
|
1889
|
+
}
|
|
1890
|
+
return result;
|
|
1891
|
+
}
|
|
1892
|
+
function getSearchParamsQs(url, key) {
|
|
1893
|
+
const components = url.split("?");
|
|
1894
|
+
const search = components[1] || "";
|
|
1895
|
+
const searchParams = new URLSearchParams(search);
|
|
1896
|
+
const params = searchParams.get("params");
|
|
1897
|
+
const value = params ? decode2(params, key) : null;
|
|
1898
|
+
return value;
|
|
1899
|
+
}
|
|
1900
|
+
function updateSearchParamsQs(currentPath, value, key) {
|
|
1901
|
+
const components = currentPath.split("?");
|
|
1902
|
+
const searchParams = serialize_3(components[1] || "", value, key);
|
|
1903
|
+
const query = searchParamsToObject_3(searchParams);
|
|
1904
|
+
const pathname = components[0] || "";
|
|
1905
|
+
return { pathname, query };
|
|
1906
|
+
}
|
|
1907
|
+
function replaceSearchParamsQs(router, value, key) {
|
|
1908
|
+
const { pathname, query } = updateSearchParamsQs(router.asPath, value, key);
|
|
1909
|
+
router.replace({ pathname, query });
|
|
1910
|
+
}
|
|
1911
|
+
function pushSearchParamsQs(router, value, key) {
|
|
1912
|
+
const { pathname, query } = updateSearchParamsQs(router.asPath, value, key);
|
|
1913
|
+
router.push({ pathname, query });
|
|
1914
|
+
}
|
|
1915
|
+
function replaceSearchParamsQsSilently(value, key) {
|
|
1916
|
+
if (import_bom_core6.isBrowser) {
|
|
1917
|
+
const searchParams = serialize_3(window.location.search, value, key);
|
|
1918
|
+
replace_3(searchParams);
|
|
1919
|
+
}
|
|
1920
|
+
}
|
|
1921
|
+
function useSearchParamsQs(key) {
|
|
1922
|
+
const router = (0, import_router3.useRouter)();
|
|
1923
|
+
const initialValue = (0, import_react34.useMemo)(() => {
|
|
1924
|
+
const value = getSearchParamsQs(router.asPath, key);
|
|
1925
|
+
return value;
|
|
1926
|
+
}, [key, router.asPath]);
|
|
1927
|
+
const params = initialValue;
|
|
1928
|
+
const replaceParamsSilently = (0, import_react34.useCallback)((params2) => {
|
|
1929
|
+
replaceSearchParamsQsSilently(params2, key);
|
|
1930
|
+
}, [key]);
|
|
1931
|
+
const replaceParams = (0, import_react34.useCallback)((params2) => {
|
|
1932
|
+
replaceSearchParamsQs(router, params2, key);
|
|
1933
|
+
}, [key, router]);
|
|
1934
|
+
return { params, replaceParamsSilently, replaceParams };
|
|
1935
|
+
}
|
|
1936
|
+
|
|
1937
|
+
// src/useSorting/useSorting.ts
|
|
1938
|
+
var import_react35 = require("react");
|
|
1808
1939
|
function useSorting(items_, callback_, sort_) {
|
|
1809
|
-
const [sort, setSort] = (0,
|
|
1810
|
-
const [items, setItems] = (0,
|
|
1811
|
-
const isInitialMount = (0,
|
|
1812
|
-
(0,
|
|
1940
|
+
const [sort, setSort] = (0, import_react35.useState)(sort_);
|
|
1941
|
+
const [items, setItems] = (0, import_react35.useState)(callback_(items_.slice(), sort));
|
|
1942
|
+
const isInitialMount = (0, import_react35.useRef)(true);
|
|
1943
|
+
(0, import_react35.useEffect)(() => {
|
|
1813
1944
|
if (isInitialMount.current) {
|
|
1814
1945
|
isInitialMount.current = false;
|
|
1815
1946
|
} else {
|
|
@@ -1825,18 +1956,18 @@ function useSorting(items_, callback_, sort_) {
|
|
|
1825
1956
|
}
|
|
1826
1957
|
|
|
1827
1958
|
// src/useSwiperIndex/useSwiperIndex.ts
|
|
1828
|
-
var
|
|
1829
|
-
var
|
|
1959
|
+
var import_react36 = require("react");
|
|
1960
|
+
var import_react37 = require("swiper/react");
|
|
1830
1961
|
function useSwiperIndex() {
|
|
1831
|
-
const swiper = (0,
|
|
1832
|
-
const [index, setIndex] = (0,
|
|
1833
|
-
const slideTo = (0,
|
|
1962
|
+
const swiper = (0, import_react37.useSwiper)();
|
|
1963
|
+
const [index, setIndex] = (0, import_react36.useState)(swiper.realIndex);
|
|
1964
|
+
const slideTo = (0, import_react36.useCallback)((index2) => {
|
|
1834
1965
|
swiper.slideTo(index2);
|
|
1835
1966
|
}, [swiper]);
|
|
1836
1967
|
const onSlideChange = (swiper2) => {
|
|
1837
1968
|
setIndex(swiper2.realIndex);
|
|
1838
1969
|
};
|
|
1839
|
-
(0,
|
|
1970
|
+
(0, import_react36.useEffect)(() => {
|
|
1840
1971
|
if (swiper) {
|
|
1841
1972
|
swiper.on("slideChange", onSlideChange);
|
|
1842
1973
|
}
|
|
@@ -1850,11 +1981,11 @@ function useSwiperIndex() {
|
|
|
1850
1981
|
}
|
|
1851
1982
|
|
|
1852
1983
|
// src/useSyncedRef/useSyncedRef.ts
|
|
1853
|
-
var
|
|
1984
|
+
var import_react38 = require("react");
|
|
1854
1985
|
function useSyncedRef(value) {
|
|
1855
|
-
const ref = (0,
|
|
1986
|
+
const ref = (0, import_react38.useRef)(value);
|
|
1856
1987
|
ref.current = value;
|
|
1857
|
-
return (0,
|
|
1988
|
+
return (0, import_react38.useMemo)(() => Object.freeze({
|
|
1858
1989
|
get current() {
|
|
1859
1990
|
return ref.current;
|
|
1860
1991
|
}
|
|
@@ -1867,10 +1998,10 @@ function useUnit(unit = "kilometer", locale) {
|
|
|
1867
1998
|
}
|
|
1868
1999
|
|
|
1869
2000
|
// src/useUnmountEffect/useUnmountEffect.ts
|
|
1870
|
-
var
|
|
2001
|
+
var import_react39 = require("react");
|
|
1871
2002
|
function useUnmountEffect(effect) {
|
|
1872
2003
|
const effectRef = useSyncedRef(effect);
|
|
1873
|
-
(0,
|
|
2004
|
+
(0, import_react39.useEffect)(() => () => {
|
|
1874
2005
|
effectRef.current();
|
|
1875
2006
|
}, []);
|
|
1876
2007
|
}
|
|
@@ -1893,11 +2024,11 @@ var useUser = (0, import_zustand4.create)((set) => ({
|
|
|
1893
2024
|
KeyCode,
|
|
1894
2025
|
KeyMod,
|
|
1895
2026
|
LabelProvider,
|
|
2027
|
+
LabelService,
|
|
1896
2028
|
LayoutProvider,
|
|
1897
2029
|
PageProvider,
|
|
1898
2030
|
createElementWithId,
|
|
1899
2031
|
createGenericContext,
|
|
1900
|
-
decode,
|
|
1901
2032
|
detectIsBrowser,
|
|
1902
2033
|
filtersToParams,
|
|
1903
2034
|
getCurrentPosition,
|
|
@@ -1909,15 +2040,19 @@ var useUser = (0, import_zustand4.create)((set) => ({
|
|
|
1909
2040
|
getRealSize,
|
|
1910
2041
|
getSearchParams,
|
|
1911
2042
|
getSearchParamsEncoded,
|
|
2043
|
+
getSearchParamsQs,
|
|
1912
2044
|
getUID,
|
|
1913
2045
|
hasGeolocation,
|
|
1914
|
-
|
|
2046
|
+
parseLabel,
|
|
1915
2047
|
parseParams,
|
|
1916
2048
|
pushSearchParams,
|
|
1917
2049
|
pushSearchParamsEncoded,
|
|
2050
|
+
pushSearchParamsQs,
|
|
1918
2051
|
replaceSearchParams,
|
|
1919
2052
|
replaceSearchParamsEncoded,
|
|
1920
2053
|
replaceSearchParamsEncodedSilently,
|
|
2054
|
+
replaceSearchParamsQs,
|
|
2055
|
+
replaceSearchParamsQsSilently,
|
|
1921
2056
|
replaceSearchParamsSilently,
|
|
1922
2057
|
scrollToRelativeY,
|
|
1923
2058
|
scrollToSelector,
|
|
@@ -1925,6 +2060,7 @@ var useUser = (0, import_zustand4.create)((set) => ({
|
|
|
1925
2060
|
setFilters,
|
|
1926
2061
|
updateSearchParams,
|
|
1927
2062
|
updateSearchParamsEncoded,
|
|
2063
|
+
updateSearchParamsQs,
|
|
1928
2064
|
useApi,
|
|
1929
2065
|
useApiDelete,
|
|
1930
2066
|
useApiFetch,
|
|
@@ -1971,6 +2107,7 @@ var useUser = (0, import_zustand4.create)((set) => ({
|
|
|
1971
2107
|
useScrolled,
|
|
1972
2108
|
useSearchParams,
|
|
1973
2109
|
useSearchParamsEncoded,
|
|
2110
|
+
useSearchParamsQs,
|
|
1974
2111
|
useSearchParamsValue,
|
|
1975
2112
|
useSorting,
|
|
1976
2113
|
useSwiperIndex,
|