@bgord/ui 0.8.16 → 0.8.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/dist/hooks/index.d.ts
CHANGED
package/dist/hooks/index.js
CHANGED
|
@@ -23,6 +23,5 @@ const OnlineStatusStore = {
|
|
|
23
23
|
getServerSnapshot: () => OnlineStatus.online,
|
|
24
24
|
};
|
|
25
25
|
export function useOnlineStatus() {
|
|
26
|
-
|
|
27
|
-
return status;
|
|
26
|
+
return useSyncExternalStore(OnlineStatusStore.subscribe, OnlineStatusStore.getSnapshot, OnlineStatusStore.getServerSnapshot);
|
|
28
27
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { useSyncExternalStore } from "react";
|
|
2
|
+
const DefaultWindowDimensions = { width: undefined, height: undefined };
|
|
3
|
+
let snapshot = DefaultWindowDimensions;
|
|
4
|
+
const WindowDimensionsStore = {
|
|
5
|
+
subscribe(callback) {
|
|
6
|
+
if (typeof window === "undefined")
|
|
7
|
+
return () => { };
|
|
8
|
+
window.addEventListener("resize", callback);
|
|
9
|
+
return () => window.removeEventListener("resize", callback);
|
|
10
|
+
},
|
|
11
|
+
getSnapshot() {
|
|
12
|
+
if (typeof window === "undefined")
|
|
13
|
+
return DefaultWindowDimensions;
|
|
14
|
+
const width = window.innerWidth;
|
|
15
|
+
const height = window.innerHeight;
|
|
16
|
+
if (snapshot.width === width && snapshot.height === height)
|
|
17
|
+
return snapshot;
|
|
18
|
+
snapshot = { width, height };
|
|
19
|
+
return snapshot;
|
|
20
|
+
},
|
|
21
|
+
getServerSnapshot() {
|
|
22
|
+
return DefaultWindowDimensions;
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
export function useWindowDimensions() {
|
|
26
|
+
return useSyncExternalStore(WindowDimensionsStore.subscribe, WindowDimensionsStore.getSnapshot, WindowDimensionsStore.getServerSnapshot);
|
|
27
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bgord/ui",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.18",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -23,21 +23,22 @@
|
|
|
23
23
|
"access": "public"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@biomejs/biome": "2.3.
|
|
27
|
-
"@commitlint/cli": "20.
|
|
28
|
-
"@commitlint/config-conventional": "20.
|
|
29
|
-
"@happy-dom/global-registrator": "20.0
|
|
26
|
+
"@biomejs/biome": "2.3.11",
|
|
27
|
+
"@commitlint/cli": "20.3.1",
|
|
28
|
+
"@commitlint/config-conventional": "20.3.1",
|
|
29
|
+
"@happy-dom/global-registrator": "20.1.0",
|
|
30
|
+
"@stryker-mutator/core": "9.4.0",
|
|
30
31
|
"@testing-library/dom": "10.4.1",
|
|
31
32
|
"@testing-library/jest-dom": "6.9.1",
|
|
32
33
|
"@testing-library/react": "16.3.1",
|
|
33
34
|
"@testing-library/user-event": "14.6.1",
|
|
34
35
|
"@types/bun": "1.3.5",
|
|
35
36
|
"@types/js-cookie": "3.0.6",
|
|
36
|
-
"@types/react": "19.2.
|
|
37
|
+
"@types/react": "19.2.8",
|
|
37
38
|
"@types/react-dom": "19.2.3",
|
|
38
|
-
"cspell": "9.
|
|
39
|
-
"knip": "5.
|
|
40
|
-
"lefthook": "2.0.
|
|
39
|
+
"cspell": "9.6.0",
|
|
40
|
+
"knip": "5.80.2",
|
|
41
|
+
"lefthook": "2.0.14",
|
|
41
42
|
"lockfile-lint": "4.14.1",
|
|
42
43
|
"only-allow": "1.2.2",
|
|
43
44
|
"shellcheck": "4.1.0",
|