@levo-so/blocks 0.3.16 → 0.3.18
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/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@levo-so/blocks",
|
|
3
3
|
"description": "Set of blocks for Levo studio",
|
|
4
|
-
"version": "0.3.
|
|
4
|
+
"version": "0.3.18",
|
|
5
5
|
"author": "Levo Engineering <devs@theinternetfolks.com>",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"clsx": "2.1.1",
|
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
"use-debounce": "10.0.2"
|
|
12
12
|
},
|
|
13
13
|
"devDependencies": {
|
|
14
|
-
"@levo-so/core": "0.3.
|
|
15
|
-
"@levo-so/react": "0.3.
|
|
16
|
-
"@levo-so/studio": "0.3.
|
|
14
|
+
"@levo-so/core": "0.3.18",
|
|
15
|
+
"@levo-so/react": "0.3.18",
|
|
16
|
+
"@levo-so/studio": "0.3.18",
|
|
17
17
|
"@levo/ts-config": "0.0.0",
|
|
18
18
|
"@types/react": "19.2.14",
|
|
19
19
|
"@types/react-dom": "19.2.3",
|
|
@@ -28,9 +28,9 @@
|
|
|
28
28
|
],
|
|
29
29
|
"main": "./src/index.ts",
|
|
30
30
|
"peerDependencies": {
|
|
31
|
-
"@levo-so/core": "0.3.
|
|
32
|
-
"@levo-so/react": "0.3.
|
|
33
|
-
"@levo-so/studio": "0.3.
|
|
31
|
+
"@levo-so/core": "0.3.18",
|
|
32
|
+
"@levo-so/react": "0.3.18",
|
|
33
|
+
"@levo-so/studio": "0.3.18",
|
|
34
34
|
"react": ">=18",
|
|
35
35
|
"react-dom": ">=18"
|
|
36
36
|
},
|
|
@@ -60,12 +60,41 @@ const Ecommerce1: React.FC<ILevoBlockBaseProps<IEcommerce1Content>> = ({ content
|
|
|
60
60
|
}, [CART_KEY]);
|
|
61
61
|
|
|
62
62
|
const setDebouncedSearchKey = useDebouncedCallback((v: string) => {
|
|
63
|
+
if (typeof window !== "undefined") {
|
|
64
|
+
const url = new URL(window.location.href);
|
|
65
|
+
if (v) {
|
|
66
|
+
url.searchParams.set("search", v);
|
|
67
|
+
} else {
|
|
68
|
+
url.searchParams.delete("search");
|
|
69
|
+
}
|
|
70
|
+
window.history.replaceState(null, "", url.toString());
|
|
71
|
+
}
|
|
72
|
+
|
|
63
73
|
if (v) {
|
|
64
74
|
setQuery({ related: v, page: 1 });
|
|
65
75
|
return;
|
|
66
76
|
}
|
|
67
77
|
setQuery({ related: undefined, page: 1 });
|
|
68
|
-
},
|
|
78
|
+
}, 500);
|
|
79
|
+
|
|
80
|
+
useEffect(() => {
|
|
81
|
+
if (typeof window === "undefined") return;
|
|
82
|
+
|
|
83
|
+
const syncSearchFromUrl = () => {
|
|
84
|
+
const params = new URLSearchParams(window.location.search);
|
|
85
|
+
const urlSearch = params.get("search") || params.get("q") || params.get("related");
|
|
86
|
+
if (urlSearch) {
|
|
87
|
+
setSearch(urlSearch);
|
|
88
|
+
setQuery({ related: urlSearch, page: 1 });
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
syncSearchFromUrl();
|
|
93
|
+
window.addEventListener("popstate", syncSearchFromUrl);
|
|
94
|
+
return () => {
|
|
95
|
+
window.removeEventListener("popstate", syncSearchFromUrl);
|
|
96
|
+
};
|
|
97
|
+
}, []);
|
|
69
98
|
|
|
70
99
|
const handleNext = () => setQuery({ page: (query?.page || 1) + 1 });
|
|
71
100
|
const handlePrevious = () => setQuery({ page: Math.max(1, (query?.page || 1) - 1) });
|