@websolutespa/bom-mixer-hooks 1.4.0 → 1.4.2
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 +33 -13
- package/dist/index.d.ts +85 -39
- package/dist/index.js +177 -72
- package/dist/index.mjs +150 -61
- package/package.json +1 -1
- package/src/index.ts +3 -0
- package/src/useCollectionApi/local.collection.ts +33 -0
- package/src/useCollectionApi/useCollectionApi.test.tsx +196 -0
- package/src/useCollectionApi/useCollectionApi.ts +65 -0
- package/src/useExtra/useExtra.test.tsx +41 -0
- package/src/useExtra/useExtra.tsx +17 -0
- package/src/useFilters/filter.service.ts +1 -2
- package/src/useFilters/filter.ts +1 -2
- package/src/useFilters/useFilters.ts +1 -2
- package/src/usePagination/pagination.service.ts +14 -5
- package/src/useSearchParamsQs/useSearchParamsQs.test.ts +5 -5
- package/src/useSearchParamsQs/useSearchParamsQs.ts +41 -71
package/dist/index.js
CHANGED
|
@@ -73,6 +73,7 @@ __export(src_exports, {
|
|
|
73
73
|
CartProvider: () => CartProvider,
|
|
74
74
|
CheckoutContext: () => CheckoutContext,
|
|
75
75
|
CheckoutProvider: () => CheckoutProvider,
|
|
76
|
+
ExtraProvider: () => ExtraProvider,
|
|
76
77
|
Filter: () => Filter,
|
|
77
78
|
FilterMode: () => FilterMode,
|
|
78
79
|
KeyCode: () => KeyCode,
|
|
@@ -92,12 +93,20 @@ __export(src_exports, {
|
|
|
92
93
|
getOwnerPaddingRight: () => getOwnerPaddingRight,
|
|
93
94
|
getOwnerScrollbarWidth: () => getOwnerScrollbarWidth,
|
|
94
95
|
getPagedItems: () => getPagedItems,
|
|
96
|
+
getPaginationInfo: () => getPaginationInfo,
|
|
95
97
|
getRealSize: () => getRealSize,
|
|
96
98
|
getSearchParams: () => getSearchParams,
|
|
97
99
|
getSearchParamsEncoded: () => getSearchParamsEncoded,
|
|
98
100
|
getSearchParamsQs: () => getSearchParamsQs,
|
|
99
101
|
getUID: () => getUID,
|
|
100
102
|
hasGeolocation: () => hasGeolocation,
|
|
103
|
+
isPaginationInfo: () => isPaginationInfo,
|
|
104
|
+
localCollectionDelete: () => localCollectionDelete,
|
|
105
|
+
localCollectionFetch: () => localCollectionFetch,
|
|
106
|
+
localCollectionGet: () => localCollectionGet,
|
|
107
|
+
localCollectionPatch: () => localCollectionPatch,
|
|
108
|
+
localCollectionPost: () => localCollectionPost,
|
|
109
|
+
localCollectionPut: () => localCollectionPut,
|
|
101
110
|
parseLabel: () => parseLabel,
|
|
102
111
|
parseParams: () => parseParams,
|
|
103
112
|
pushSearchParams: () => pushSearchParams,
|
|
@@ -129,6 +138,12 @@ __export(src_exports, {
|
|
|
129
138
|
useCheckout: () => useCheckout,
|
|
130
139
|
useClickAnyWhere: () => useClickAnyWhere,
|
|
131
140
|
useClickOut: () => useClickOut,
|
|
141
|
+
useCollectionApi: () => useCollectionApi,
|
|
142
|
+
useCollectionApiDelete: () => useCollectionApiDelete,
|
|
143
|
+
useCollectionApiGet: () => useCollectionApiGet,
|
|
144
|
+
useCollectionApiPatch: () => useCollectionApiPatch,
|
|
145
|
+
useCollectionApiPost: () => useCollectionApiPost,
|
|
146
|
+
useCollectionApiPut: () => useCollectionApiPut,
|
|
132
147
|
useCurrency: () => useCurrency,
|
|
133
148
|
useCurrentState: () => useCurrentState,
|
|
134
149
|
useDateTimeFormat: () => useDateTimeFormat,
|
|
@@ -139,6 +154,7 @@ __export(src_exports, {
|
|
|
139
154
|
useDrawer: () => useDrawer,
|
|
140
155
|
useElementSize: () => useElementSize,
|
|
141
156
|
useEventListener: () => useEventListener,
|
|
157
|
+
useExtra: () => useExtra,
|
|
142
158
|
useFilters: () => useFilters,
|
|
143
159
|
useGeolocation: () => useGeolocation,
|
|
144
160
|
useIdle: () => useIdle,
|
|
@@ -595,6 +611,89 @@ function useClickOut(ref, handler) {
|
|
|
595
611
|
}, [ref]);
|
|
596
612
|
}
|
|
597
613
|
|
|
614
|
+
// src/useCollectionApi/local.collection.ts
|
|
615
|
+
var import_bom_core3 = require("@websolutespa/bom-core");
|
|
616
|
+
var import_bom_mixer_store2 = require("@websolutespa/bom-mixer-store");
|
|
617
|
+
function localCollectionFetch(_0) {
|
|
618
|
+
return __async(this, arguments, function* (pathname, options = {}, serviceOptions) {
|
|
619
|
+
const url = new URL((0, import_bom_mixer_store2.getLocalApiUrl)(pathname));
|
|
620
|
+
if (serviceOptions) {
|
|
621
|
+
url.searchParams.append("locale", serviceOptions.locale);
|
|
622
|
+
url.searchParams.append("market", serviceOptions.market);
|
|
623
|
+
}
|
|
624
|
+
const apiOptions = (0, import_bom_core3.merge)(__spreadValues({}, (0, import_bom_mixer_store2.getDefaultApiRequestOptions)()), options);
|
|
625
|
+
const apiResponse = yield (0, import_bom_core3.httpFetch)(url.href, apiOptions);
|
|
626
|
+
return apiResponse;
|
|
627
|
+
});
|
|
628
|
+
}
|
|
629
|
+
function localCollectionGet(_0) {
|
|
630
|
+
return __async(this, arguments, function* (url, options = {}, serviceOptions) {
|
|
631
|
+
return yield localCollectionFetch(url, __spreadProps(__spreadValues({}, options), { method: "GET" }), serviceOptions);
|
|
632
|
+
});
|
|
633
|
+
}
|
|
634
|
+
function localCollectionPost(_0, _1) {
|
|
635
|
+
return __async(this, arguments, function* (url, payload, options = {}, serviceOptions) {
|
|
636
|
+
return yield localCollectionFetch(url, __spreadProps(__spreadValues({}, options), { method: "POST", body: payload ? JSON.stringify(payload) : void 0 }), serviceOptions);
|
|
637
|
+
});
|
|
638
|
+
}
|
|
639
|
+
function localCollectionPut(_0, _1) {
|
|
640
|
+
return __async(this, arguments, function* (url, payload, options = {}, serviceOptions) {
|
|
641
|
+
return yield localCollectionFetch(url, __spreadProps(__spreadValues({}, options), { method: "PUT", body: payload ? JSON.stringify(payload) : void 0 }), serviceOptions);
|
|
642
|
+
});
|
|
643
|
+
}
|
|
644
|
+
function localCollectionPatch(_0, _1) {
|
|
645
|
+
return __async(this, arguments, function* (url, payload, options = {}, serviceOptions) {
|
|
646
|
+
return yield localCollectionFetch(url, __spreadProps(__spreadValues({}, options), { method: "PATCH", body: payload ? JSON.stringify(payload) : void 0 }), serviceOptions);
|
|
647
|
+
});
|
|
648
|
+
}
|
|
649
|
+
function localCollectionDelete(_0) {
|
|
650
|
+
return __async(this, arguments, function* (url, options = {}, serviceOptions) {
|
|
651
|
+
return yield localCollectionFetch(url, __spreadProps(__spreadValues({}, options), { method: "DELETE" }), serviceOptions);
|
|
652
|
+
});
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
// src/useCollectionApi/useCollectionApi.ts
|
|
656
|
+
var import_bom_core4 = require("@websolutespa/bom-core");
|
|
657
|
+
function useCollectionApi() {
|
|
658
|
+
const layout = useLayout();
|
|
659
|
+
return {
|
|
660
|
+
get: (_0, ..._1) => __async(this, [_0, ..._1], function* (pathname, params = {}, options = {}) {
|
|
661
|
+
params.locale = params.locale || layout.locale;
|
|
662
|
+
params.market = params.market || layout.market;
|
|
663
|
+
const qs = (0, import_bom_core4.qsSerialize)(params);
|
|
664
|
+
return localCollectionGet(pathname + (qs ? "?" + qs : ""), options);
|
|
665
|
+
}),
|
|
666
|
+
post: (_0, _1, ..._2) => __async(this, [_0, _1, ..._2], function* (pathname, payload, options = {}) {
|
|
667
|
+
return localCollectionPost(pathname, payload, options, layout);
|
|
668
|
+
}),
|
|
669
|
+
put: (_0, _1, ..._2) => __async(this, [_0, _1, ..._2], function* (pathname, payload, options = {}) {
|
|
670
|
+
return localCollectionPut(pathname, payload, options, layout);
|
|
671
|
+
}),
|
|
672
|
+
patch: (_0, _1, ..._2) => __async(this, [_0, _1, ..._2], function* (pathname, payload, options = {}) {
|
|
673
|
+
return localCollectionPatch(pathname, payload, options, layout);
|
|
674
|
+
}),
|
|
675
|
+
delete: (_0, ..._1) => __async(this, [_0, ..._1], function* (pathname, options = {}) {
|
|
676
|
+
return localCollectionDelete(pathname, options, layout);
|
|
677
|
+
})
|
|
678
|
+
};
|
|
679
|
+
}
|
|
680
|
+
function useCollectionApiGet(pathname, params, options = {}) {
|
|
681
|
+
const api = useApiFetch(pathname, __spreadProps(__spreadValues({}, options), { method: "GET" }));
|
|
682
|
+
return api;
|
|
683
|
+
}
|
|
684
|
+
function useCollectionApiPost(pathname, payload, options = {}) {
|
|
685
|
+
return useApiFetch(pathname, __spreadProps(__spreadValues({}, options), { method: "POST", body: payload ? JSON.stringify(payload) : void 0 }));
|
|
686
|
+
}
|
|
687
|
+
function useCollectionApiPut(pathname, payload, options = {}) {
|
|
688
|
+
return useApiFetch(pathname, __spreadProps(__spreadValues({}, options), { method: "PUT", body: payload ? JSON.stringify(payload) : void 0 }));
|
|
689
|
+
}
|
|
690
|
+
function useCollectionApiPatch(pathname, payload, options = {}) {
|
|
691
|
+
return useApiFetch(pathname, __spreadProps(__spreadValues({}, options), { method: "PATCH", body: payload ? JSON.stringify(payload) : void 0 }));
|
|
692
|
+
}
|
|
693
|
+
function useCollectionApiDelete(pathname, options = {}) {
|
|
694
|
+
return useApiFetch(pathname, __spreadProps(__spreadValues({}, options), { method: "DELETE" }));
|
|
695
|
+
}
|
|
696
|
+
|
|
598
697
|
// src/useNumber/useNumber.ts
|
|
599
698
|
var import_react12 = require("react");
|
|
600
699
|
function useNumber(options, locale) {
|
|
@@ -768,6 +867,13 @@ function useElementSize() {
|
|
|
768
867
|
return [setRef, size];
|
|
769
868
|
}
|
|
770
869
|
|
|
870
|
+
// src/useExtra/useExtra.tsx
|
|
871
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
872
|
+
var [useExtra, ExtraContextProvider] = createGenericContext({});
|
|
873
|
+
function ExtraProvider({ children, extra }) {
|
|
874
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ExtraContextProvider, { value: extra, children });
|
|
875
|
+
}
|
|
876
|
+
|
|
771
877
|
// src/useFilters/filter.ts
|
|
772
878
|
var FilterMode = /* @__PURE__ */ ((FilterMode2) => {
|
|
773
879
|
FilterMode2["SELECT"] = "select";
|
|
@@ -1352,7 +1458,7 @@ var useKeyboard = (handler, keyBindings, options = {}) => {
|
|
|
1352
1458
|
};
|
|
1353
1459
|
|
|
1354
1460
|
// src/useLabel/useLabel.tsx
|
|
1355
|
-
var
|
|
1461
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
1356
1462
|
var [useLabel, LabelContextProvider] = createGenericContext();
|
|
1357
1463
|
function LabelProvider({ children }) {
|
|
1358
1464
|
const { labels } = useLayout();
|
|
@@ -1360,7 +1466,7 @@ function LabelProvider({ children }) {
|
|
|
1360
1466
|
const getLabel = (key, params) => {
|
|
1361
1467
|
return labelService.getLabel(key, params);
|
|
1362
1468
|
};
|
|
1363
|
-
return /* @__PURE__ */ (0,
|
|
1469
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(LabelContextProvider, { value: getLabel, children });
|
|
1364
1470
|
}
|
|
1365
1471
|
var LabelService = class {
|
|
1366
1472
|
constructor(labels) {
|
|
@@ -1387,10 +1493,10 @@ function parseParams(label, params) {
|
|
|
1387
1493
|
}
|
|
1388
1494
|
|
|
1389
1495
|
// src/useLazyModules/useLazyModules.tsx
|
|
1390
|
-
var
|
|
1496
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
1391
1497
|
var [useLazyModules, LazyModulesContextProvider] = createGenericContext({});
|
|
1392
1498
|
function LazyModulesProvider({ children, modules }) {
|
|
1393
|
-
return /* @__PURE__ */ (0,
|
|
1499
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(LazyModulesContextProvider, { value: modules, children });
|
|
1394
1500
|
}
|
|
1395
1501
|
|
|
1396
1502
|
// src/useModal/useModal.ts
|
|
@@ -1420,18 +1526,28 @@ function useMounted() {
|
|
|
1420
1526
|
}
|
|
1421
1527
|
|
|
1422
1528
|
// src/usePage/usePage.tsx
|
|
1423
|
-
var
|
|
1529
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
1424
1530
|
var [usePage, PageContextProvider] = createGenericContext();
|
|
1425
1531
|
function PageProvider({ children, page }) {
|
|
1426
|
-
return /* @__PURE__ */ (0,
|
|
1532
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(PageContextProvider, { value: page, children });
|
|
1427
1533
|
}
|
|
1428
1534
|
|
|
1429
1535
|
// src/usePagination/pagination.service.ts
|
|
1536
|
+
var import_bom_core5 = require("@websolutespa/bom-core");
|
|
1537
|
+
function isPaginationInfo(item) {
|
|
1538
|
+
return (0, import_bom_core5.isObject)(item) && (typeof item.page === "number" && typeof item.pages === "number" && typeof item.total === "number" && (0, import_bom_core5.isArray)(item.items));
|
|
1539
|
+
}
|
|
1430
1540
|
function getPagedItems(items, page, perPage) {
|
|
1431
1541
|
const from = (page - 1) * perPage;
|
|
1432
1542
|
const to = Math.min(page * perPage, items.length);
|
|
1433
1543
|
return items.slice(from, to);
|
|
1434
1544
|
}
|
|
1545
|
+
function getPaginationInfo(items, page = 1, perPage = 15) {
|
|
1546
|
+
const total = items.length;
|
|
1547
|
+
const pages = Math.ceil(total / perPage);
|
|
1548
|
+
const pagedItems = getPagedItems(items, page, perPage);
|
|
1549
|
+
return { items: pagedItems, total, pages, page, perPage };
|
|
1550
|
+
}
|
|
1435
1551
|
|
|
1436
1552
|
// src/usePagination/usePagination.ts
|
|
1437
1553
|
var import_react26 = require("react");
|
|
@@ -1566,7 +1682,7 @@ function useScroll() {
|
|
|
1566
1682
|
}
|
|
1567
1683
|
|
|
1568
1684
|
// src/useScrollTo/useScrollTo.ts
|
|
1569
|
-
var
|
|
1685
|
+
var import_bom_core6 = require("@websolutespa/bom-core");
|
|
1570
1686
|
var import_framer_motion = require("framer-motion");
|
|
1571
1687
|
function useScrollTo(offset = 0) {
|
|
1572
1688
|
const scrollToHash = (event) => {
|
|
@@ -1579,7 +1695,7 @@ function useScrollTo(offset = 0) {
|
|
|
1579
1695
|
return scrollToHash;
|
|
1580
1696
|
}
|
|
1581
1697
|
function scrollToSelector(selector, offset = 0) {
|
|
1582
|
-
if (selector &&
|
|
1698
|
+
if (selector && import_bom_core6.isBrowser) {
|
|
1583
1699
|
const element = document.querySelector(selector);
|
|
1584
1700
|
if (element) {
|
|
1585
1701
|
const rect = element.getBoundingClientRect();
|
|
@@ -1622,7 +1738,7 @@ function useScrolled(callback = DEFAULT_CALLBACK) {
|
|
|
1622
1738
|
}
|
|
1623
1739
|
|
|
1624
1740
|
// src/useSearchParams/useSearchParams.ts
|
|
1625
|
-
var
|
|
1741
|
+
var import_bom_core7 = require("@websolutespa/bom-core");
|
|
1626
1742
|
var import_router = require("next/router");
|
|
1627
1743
|
var import_react32 = require("react");
|
|
1628
1744
|
function replace_(params) {
|
|
@@ -1675,7 +1791,7 @@ function pushSearchParams(router, params) {
|
|
|
1675
1791
|
router.push({ pathname, query });
|
|
1676
1792
|
}
|
|
1677
1793
|
function replaceSearchParamsSilently(params) {
|
|
1678
|
-
if (
|
|
1794
|
+
if (import_bom_core7.isBrowser) {
|
|
1679
1795
|
const searchParams = serialize_(window.location.search, params);
|
|
1680
1796
|
replace_(searchParams);
|
|
1681
1797
|
}
|
|
@@ -1711,19 +1827,19 @@ function useSearchParamsValue(key) {
|
|
|
1711
1827
|
}
|
|
1712
1828
|
|
|
1713
1829
|
// src/useSearchParamsEncoded/useSearchParamsEncoded.ts
|
|
1714
|
-
var
|
|
1830
|
+
var import_bom_core8 = require("@websolutespa/bom-core");
|
|
1715
1831
|
var import_router2 = require("next/router");
|
|
1716
1832
|
var import_react33 = require("react");
|
|
1717
1833
|
var USE_ENCRYPTION = true;
|
|
1718
1834
|
function base64ToString(base64) {
|
|
1719
1835
|
if (!USE_ENCRYPTION)
|
|
1720
1836
|
return base64;
|
|
1721
|
-
return
|
|
1837
|
+
return import_bom_core8.isBrowser ? window.atob(base64) : Buffer.from(base64, "base64").toString();
|
|
1722
1838
|
}
|
|
1723
1839
|
function stringToBase64(text) {
|
|
1724
1840
|
if (!USE_ENCRYPTION)
|
|
1725
1841
|
return text;
|
|
1726
|
-
return
|
|
1842
|
+
return import_bom_core8.isBrowser ? window.btoa(text) : Buffer.from(text).toString("base64");
|
|
1727
1843
|
}
|
|
1728
1844
|
function stringToURLSearchParams(url) {
|
|
1729
1845
|
return new URLSearchParams(url);
|
|
@@ -1812,7 +1928,7 @@ function pushSearchParamsEncoded(router, value, key) {
|
|
|
1812
1928
|
router.push({ pathname, query });
|
|
1813
1929
|
}
|
|
1814
1930
|
function replaceSearchParamsEncodedSilently(value, key) {
|
|
1815
|
-
if (
|
|
1931
|
+
if (import_bom_core8.isBrowser) {
|
|
1816
1932
|
const searchParams = serialize_2(window.location.search, value, key);
|
|
1817
1933
|
replace_2(searchParams);
|
|
1818
1934
|
}
|
|
@@ -1834,18 +1950,25 @@ function useSearchParamsEncoded(key) {
|
|
|
1834
1950
|
}
|
|
1835
1951
|
|
|
1836
1952
|
// src/useSearchParamsQs/useSearchParamsQs.ts
|
|
1837
|
-
var
|
|
1953
|
+
var import_bom_core9 = require("@websolutespa/bom-core");
|
|
1838
1954
|
var import_router3 = require("next/router");
|
|
1839
1955
|
var import_react34 = require("react");
|
|
1840
|
-
function
|
|
1841
|
-
|
|
1956
|
+
function replace(search) {
|
|
1957
|
+
if (window.history) {
|
|
1958
|
+
const title = document.title;
|
|
1959
|
+
const url = `${window.location.href.split("?")[0]}?${search}`;
|
|
1960
|
+
window.history.replaceState(search, title, url);
|
|
1961
|
+
}
|
|
1962
|
+
}
|
|
1963
|
+
function deserialize(encoded, key) {
|
|
1964
|
+
let decoded = {};
|
|
1842
1965
|
if (encoded) {
|
|
1843
|
-
decoded = (0,
|
|
1966
|
+
decoded = (0, import_bom_core9.qsDeserializeRaw)(encoded);
|
|
1844
1967
|
}
|
|
1845
1968
|
if (key && decoded) {
|
|
1846
1969
|
decoded = decoded[key];
|
|
1847
1970
|
}
|
|
1848
|
-
return decoded ||
|
|
1971
|
+
return decoded || {};
|
|
1849
1972
|
}
|
|
1850
1973
|
function encode2(params, value, key) {
|
|
1851
1974
|
if (key) {
|
|
@@ -1855,63 +1978,29 @@ function encode2(params, value, key) {
|
|
|
1855
1978
|
} else {
|
|
1856
1979
|
params = __spreadValues({}, params);
|
|
1857
1980
|
}
|
|
1858
|
-
const
|
|
1859
|
-
return
|
|
1860
|
-
}
|
|
1861
|
-
function stringToURLSearchParams2(url) {
|
|
1862
|
-
return new URLSearchParams(url);
|
|
1863
|
-
}
|
|
1864
|
-
function getURLSearchParams2(url, key) {
|
|
1865
|
-
const params = stringToURLSearchParams2(url);
|
|
1866
|
-
return params.get(key);
|
|
1867
|
-
}
|
|
1868
|
-
function setURLSearchParams2(url, keyOrValue, value) {
|
|
1869
|
-
const params = stringToURLSearchParams2(url);
|
|
1870
|
-
if (value != null) {
|
|
1871
|
-
params.set(keyOrValue, value);
|
|
1872
|
-
} else {
|
|
1873
|
-
params.set(keyOrValue, "");
|
|
1874
|
-
}
|
|
1875
|
-
return params;
|
|
1876
|
-
}
|
|
1877
|
-
function replace_3(params) {
|
|
1878
|
-
if (window.history) {
|
|
1879
|
-
const title = document.title;
|
|
1880
|
-
const url = `${window.location.href.split("?")[0]}?${params.toString()}`;
|
|
1881
|
-
window.history.replaceState(params.toString(), title, url);
|
|
1882
|
-
}
|
|
1883
|
-
}
|
|
1884
|
-
function deserialize_3(url, key) {
|
|
1885
|
-
const encoded = getURLSearchParams2(url, "params");
|
|
1886
|
-
return decode2(encoded, key);
|
|
1981
|
+
const search = (0, import_bom_core9.qsSerializeRaw)(params);
|
|
1982
|
+
return { search, params };
|
|
1887
1983
|
}
|
|
1888
|
-
function
|
|
1889
|
-
const params =
|
|
1984
|
+
function serialize(search, value, key) {
|
|
1985
|
+
const params = deserialize(search);
|
|
1890
1986
|
const encoded = encode2(params, value, key);
|
|
1891
|
-
return
|
|
1987
|
+
return encoded;
|
|
1892
1988
|
}
|
|
1893
|
-
function
|
|
1894
|
-
const
|
|
1895
|
-
const
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
}
|
|
1899
|
-
return result;
|
|
1989
|
+
function getComponents(url) {
|
|
1990
|
+
const components = decodeURI(url).split("?");
|
|
1991
|
+
const pathname = components[0].split("#")[0];
|
|
1992
|
+
const search = components[1] || "";
|
|
1993
|
+
return { pathname, search };
|
|
1900
1994
|
}
|
|
1901
1995
|
function getSearchParamsQs(url, key) {
|
|
1902
|
-
const components = url
|
|
1903
|
-
const
|
|
1904
|
-
const searchParams = new URLSearchParams(search);
|
|
1905
|
-
const params = searchParams.get("params");
|
|
1906
|
-
const value = params ? decode2(params, key) : null;
|
|
1996
|
+
const components = getComponents(url);
|
|
1997
|
+
const value = deserialize(components.search, key);
|
|
1907
1998
|
return value;
|
|
1908
1999
|
}
|
|
1909
|
-
function updateSearchParamsQs(
|
|
1910
|
-
const components =
|
|
1911
|
-
const
|
|
1912
|
-
|
|
1913
|
-
const pathname = components[0] || "";
|
|
1914
|
-
return { pathname, query };
|
|
2000
|
+
function updateSearchParamsQs(url, value, key) {
|
|
2001
|
+
const components = getComponents(url);
|
|
2002
|
+
const { search, params } = serialize(components.search, value, key);
|
|
2003
|
+
return { pathname: components.pathname, query: search };
|
|
1915
2004
|
}
|
|
1916
2005
|
function replaceSearchParamsQs(router, value, key) {
|
|
1917
2006
|
const { pathname, query } = updateSearchParamsQs(router.asPath, value, key);
|
|
@@ -1922,9 +2011,9 @@ function pushSearchParamsQs(router, value, key) {
|
|
|
1922
2011
|
router.push({ pathname, query });
|
|
1923
2012
|
}
|
|
1924
2013
|
function replaceSearchParamsQsSilently(value, key) {
|
|
1925
|
-
if (
|
|
1926
|
-
const
|
|
1927
|
-
|
|
2014
|
+
if (import_bom_core9.isBrowser) {
|
|
2015
|
+
const { search } = serialize(window.location.search, value, key);
|
|
2016
|
+
replace(search);
|
|
1928
2017
|
}
|
|
1929
2018
|
}
|
|
1930
2019
|
function useSearchParamsQs(key) {
|
|
@@ -2028,6 +2117,7 @@ var useUser = (0, import_zustand4.create)((set) => ({
|
|
|
2028
2117
|
CartProvider,
|
|
2029
2118
|
CheckoutContext,
|
|
2030
2119
|
CheckoutProvider,
|
|
2120
|
+
ExtraProvider,
|
|
2031
2121
|
Filter,
|
|
2032
2122
|
FilterMode,
|
|
2033
2123
|
KeyCode,
|
|
@@ -2047,12 +2137,20 @@ var useUser = (0, import_zustand4.create)((set) => ({
|
|
|
2047
2137
|
getOwnerPaddingRight,
|
|
2048
2138
|
getOwnerScrollbarWidth,
|
|
2049
2139
|
getPagedItems,
|
|
2140
|
+
getPaginationInfo,
|
|
2050
2141
|
getRealSize,
|
|
2051
2142
|
getSearchParams,
|
|
2052
2143
|
getSearchParamsEncoded,
|
|
2053
2144
|
getSearchParamsQs,
|
|
2054
2145
|
getUID,
|
|
2055
2146
|
hasGeolocation,
|
|
2147
|
+
isPaginationInfo,
|
|
2148
|
+
localCollectionDelete,
|
|
2149
|
+
localCollectionFetch,
|
|
2150
|
+
localCollectionGet,
|
|
2151
|
+
localCollectionPatch,
|
|
2152
|
+
localCollectionPost,
|
|
2153
|
+
localCollectionPut,
|
|
2056
2154
|
parseLabel,
|
|
2057
2155
|
parseParams,
|
|
2058
2156
|
pushSearchParams,
|
|
@@ -2084,6 +2182,12 @@ var useUser = (0, import_zustand4.create)((set) => ({
|
|
|
2084
2182
|
useCheckout,
|
|
2085
2183
|
useClickAnyWhere,
|
|
2086
2184
|
useClickOut,
|
|
2185
|
+
useCollectionApi,
|
|
2186
|
+
useCollectionApiDelete,
|
|
2187
|
+
useCollectionApiGet,
|
|
2188
|
+
useCollectionApiPatch,
|
|
2189
|
+
useCollectionApiPost,
|
|
2190
|
+
useCollectionApiPut,
|
|
2087
2191
|
useCurrency,
|
|
2088
2192
|
useCurrentState,
|
|
2089
2193
|
useDateTimeFormat,
|
|
@@ -2094,6 +2198,7 @@ var useUser = (0, import_zustand4.create)((set) => ({
|
|
|
2094
2198
|
useDrawer,
|
|
2095
2199
|
useElementSize,
|
|
2096
2200
|
useEventListener,
|
|
2201
|
+
useExtra,
|
|
2097
2202
|
useFilters,
|
|
2098
2203
|
useGeolocation,
|
|
2099
2204
|
useIdle,
|