@peachy/hooks 0.0.11 → 0.0.13
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 +4 -0
- package/dist/adw/index.mjs +1 -2
- package/dist/adw/use-accent-color.d.mts +4 -4
- package/dist/adw/use-accent-color.mjs +1 -3
- package/dist/adw/use-dark-mode.d.mts +1 -1
- package/dist/adw/use-dark-mode.mjs +1 -3
- package/dist/base/index.mjs +1 -2
- package/dist/base/use-reference.d.mts +2 -2
- package/dist/base/use-reference.mjs +1 -3
- package/dist/gio/index.mjs +1 -2
- package/dist/gio/use-network-monitor.mjs +1 -3
- package/dist/gio/use-setting.mjs +1 -3
- package/dist/gobject/index.mjs +1 -2
- package/dist/gobject/use-binding.mjs +1 -3
- package/dist/index.d.mts +0 -2
- package/dist/index.mjs +1 -2
- package/package.json +6 -6
- package/src/adw/use-accent-color.ts +1 -1
- package/src/adw/use-dark-mode.ts +3 -3
- package/tsconfig.json +1 -1
- package/tsdown.config.mjs +3 -1
package/CHANGELOG.md
CHANGED
package/dist/adw/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
//#region src/adw/use-accent-color.d.ts
|
|
2
2
|
/**
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
declare function useAccentColor():
|
|
3
|
+
* Query the system's accent color if supported
|
|
4
|
+
* @returns [accentColor] - accent color or null
|
|
5
|
+
*/
|
|
6
|
+
declare function useAccentColor(): [accentColor: number | null];
|
|
7
7
|
//#endregion
|
|
8
8
|
export { useAccentColor };
|
|
@@ -2,7 +2,6 @@ import { useBinding } from "../gobject/use-binding.mjs";
|
|
|
2
2
|
import "../gobject/index.mjs";
|
|
3
3
|
import { useRef } from "react";
|
|
4
4
|
import Adw from "gi://Adw?version=1";
|
|
5
|
-
|
|
6
5
|
//#region src/adw/use-accent-color.ts
|
|
7
6
|
/**
|
|
8
7
|
* Query the system's accent color if supported
|
|
@@ -14,6 +13,5 @@ function useAccentColor() {
|
|
|
14
13
|
const [systemSupportsAccentColors] = useBinding(styleManager, "system-supports-accent-colors");
|
|
15
14
|
return [systemSupportsAccentColors ? accentColor : null];
|
|
16
15
|
}
|
|
17
|
-
|
|
18
16
|
//#endregion
|
|
19
|
-
export { useAccentColor };
|
|
17
|
+
export { useAccentColor };
|
|
@@ -2,7 +2,6 @@ import { useBinding } from "../gobject/use-binding.mjs";
|
|
|
2
2
|
import "../gobject/index.mjs";
|
|
3
3
|
import { useCallback, useRef } from "react";
|
|
4
4
|
import Adw from "gi://Adw?version=1";
|
|
5
|
-
|
|
6
5
|
//#region src/adw/use-dark-mode.ts
|
|
7
6
|
function useDarkMode() {
|
|
8
7
|
const styleManager = useRef(Adw.StyleManager.get_default());
|
|
@@ -11,6 +10,5 @@ function useDarkMode() {
|
|
|
11
10
|
styleManager.current.set_color_scheme(value ? Adw.ColorScheme.PREFER_DARK : Adw.ColorScheme.PREFER_LIGHT);
|
|
12
11
|
}, [styleManager])];
|
|
13
12
|
}
|
|
14
|
-
|
|
15
13
|
//#endregion
|
|
16
|
-
export { useDarkMode };
|
|
14
|
+
export { useDarkMode };
|
package/dist/base/index.mjs
CHANGED
|
@@ -2,8 +2,8 @@ import { RefObject } from "react";
|
|
|
2
2
|
|
|
3
3
|
//#region src/base/use-reference.d.ts
|
|
4
4
|
/**
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
* Returns the value inside a `ref`, correctly checking it after the initial render
|
|
6
|
+
*/
|
|
7
7
|
declare function useReference<T>(value: T | RefObject<T>, defaultValue?: T): T | null;
|
|
8
8
|
//#endregion
|
|
9
9
|
export { useReference };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { useEffect, useState } from "react";
|
|
2
|
-
|
|
3
2
|
//#region src/base/use-reference.ts
|
|
4
3
|
/**
|
|
5
4
|
* Returns the value inside a `ref`, correctly checking it after the initial render
|
|
@@ -19,6 +18,5 @@ function getValue(object) {
|
|
|
19
18
|
function isRef(object) {
|
|
20
19
|
return typeof object === "object" && object !== null && "current" in object;
|
|
21
20
|
}
|
|
22
|
-
|
|
23
21
|
//#endregion
|
|
24
|
-
export { useReference };
|
|
22
|
+
export { useReference };
|
package/dist/gio/index.mjs
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
2
2
|
import Gio from "gi://Gio?version=2.0";
|
|
3
|
-
|
|
4
3
|
//#region src/gio/use-network-monitor.ts
|
|
5
4
|
function useNetworkMonitor() {
|
|
6
5
|
const monitor = useRef(Gio.NetworkMonitor.get_default());
|
|
@@ -24,6 +23,5 @@ function useNetworkMonitor() {
|
|
|
24
23
|
}, [calculateState]);
|
|
25
24
|
return state;
|
|
26
25
|
}
|
|
27
|
-
|
|
28
26
|
//#endregion
|
|
29
|
-
export { useNetworkMonitor };
|
|
27
|
+
export { useNetworkMonitor };
|
package/dist/gio/use-setting.mjs
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
2
2
|
import Gio from "gi://Gio?version=2.0";
|
|
3
|
-
|
|
4
3
|
//#region src/gio/use-setting.ts
|
|
5
4
|
function useSetting(schema, key) {
|
|
6
5
|
const settings = useRef(Gio.Settings.new(schema));
|
|
@@ -21,6 +20,5 @@ function useSetting(schema, key) {
|
|
|
21
20
|
settings.current.set_value(key, newValue);
|
|
22
21
|
}, [key])];
|
|
23
22
|
}
|
|
24
|
-
|
|
25
23
|
//#endregion
|
|
26
|
-
export { useSetting };
|
|
24
|
+
export { useSetting };
|
package/dist/gobject/index.mjs
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { useReference } from "../base/use-reference.mjs";
|
|
2
2
|
import "../base/index.mjs";
|
|
3
3
|
import { useEffect, useState } from "react";
|
|
4
|
-
|
|
5
4
|
//#region src/gobject/use-binding.ts
|
|
6
5
|
function useBinding(object, property, defaultValue) {
|
|
7
6
|
const value = useReference(object);
|
|
@@ -20,6 +19,5 @@ function useBinding(object, property, defaultValue) {
|
|
|
20
19
|
}, [value, property]);
|
|
21
20
|
return [result];
|
|
22
21
|
}
|
|
23
|
-
|
|
24
22
|
//#endregion
|
|
25
|
-
export { useBinding };
|
|
23
|
+
export { useBinding };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { useAccentColor } from "./adw/use-accent-color.mjs";
|
|
2
2
|
import { useDarkMode } from "./adw/use-dark-mode.mjs";
|
|
3
3
|
import { useReference } from "./base/use-reference.mjs";
|
|
4
|
-
import "./base/index.mjs";
|
|
5
4
|
import { useBinding } from "./gobject/use-binding.mjs";
|
|
6
|
-
import "./gobject/index.mjs";
|
|
7
5
|
export { useAccentColor, useBinding, useDarkMode, useReference };
|
package/dist/index.mjs
CHANGED
|
@@ -5,5 +5,4 @@ import "./gobject/index.mjs";
|
|
|
5
5
|
import { useAccentColor } from "./adw/use-accent-color.mjs";
|
|
6
6
|
import { useDarkMode } from "./adw/use-dark-mode.mjs";
|
|
7
7
|
import "./adw/index.mjs";
|
|
8
|
-
|
|
9
|
-
export { useAccentColor, useBinding, useDarkMode, useReference };
|
|
8
|
+
export { useAccentColor, useBinding, useDarkMode, useReference };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@peachy/hooks",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.13",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "",
|
|
@@ -16,11 +16,11 @@
|
|
|
16
16
|
}
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
|
-
"@types/react": "^19.2.
|
|
20
|
-
"react": "^19.2.
|
|
21
|
-
"tsdown": "0.
|
|
22
|
-
"typescript": "^
|
|
23
|
-
"@peachy/react": "0.0.
|
|
19
|
+
"@types/react": "^19.2.14",
|
|
20
|
+
"react": "^19.2.5",
|
|
21
|
+
"tsdown": "0.21.7",
|
|
22
|
+
"typescript": "^6.0.2",
|
|
23
|
+
"@peachy/react": "0.0.13"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
26
|
"react": "^19.2.0"
|
|
@@ -8,7 +8,7 @@ import { useBinding } from "../gobject";
|
|
|
8
8
|
* Query the system's accent color if supported
|
|
9
9
|
* @returns [accentColor] - accent color or null
|
|
10
10
|
*/
|
|
11
|
-
export function useAccentColor() {
|
|
11
|
+
export function useAccentColor(): [accentColor: number | null] {
|
|
12
12
|
const styleManager = useRef(Adw.StyleManager.get_default());
|
|
13
13
|
|
|
14
14
|
const [accentColor] = useBinding(styleManager, "accent-color");
|
package/src/adw/use-dark-mode.ts
CHANGED
|
@@ -4,12 +4,12 @@ import { useCallback, useRef } from "react";
|
|
|
4
4
|
|
|
5
5
|
import { useBinding } from "../gobject";
|
|
6
6
|
|
|
7
|
-
export function useDarkMode() {
|
|
7
|
+
export function useDarkMode(): [isDark: boolean, setDarkMode: (value: boolean) => void] {
|
|
8
8
|
const styleManager = useRef(Adw.StyleManager.get_default());
|
|
9
9
|
|
|
10
10
|
const [isDark] = useBinding(styleManager, "dark");
|
|
11
11
|
const setDarkMode = useCallback(
|
|
12
|
-
(value: boolean) => {
|
|
12
|
+
(value: boolean): void => {
|
|
13
13
|
styleManager.current.set_color_scheme(
|
|
14
14
|
value ? Adw.ColorScheme.PREFER_DARK : Adw.ColorScheme.PREFER_LIGHT,
|
|
15
15
|
);
|
|
@@ -17,5 +17,5 @@ export function useDarkMode() {
|
|
|
17
17
|
[styleManager],
|
|
18
18
|
);
|
|
19
19
|
|
|
20
|
-
return [isDark, setDarkMode];
|
|
20
|
+
return [isDark, setDarkMode] as const;
|
|
21
21
|
}
|
package/tsconfig.json
CHANGED
package/tsdown.config.mjs
CHANGED