@scalar/use-hooks 0.4.2 → 0.4.5
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
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @scalar/use-hooks
|
|
2
2
|
|
|
3
|
+
## 0.4.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#9211](https://github.com/scalar/scalar/pull/9211): chore: remove zod
|
|
8
|
+
|
|
9
|
+
## 0.4.4
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#8844](https://github.com/scalar/scalar/pull/8844): chore: remove zod
|
|
14
|
+
|
|
15
|
+
## 0.4.3
|
|
16
|
+
|
|
3
17
|
## 0.4.2
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useColorMode.d.ts","sourceRoot":"","sources":["../../src/useColorMode/useColorMode.ts"],"names":[],"mappings":"AAOA,2BAA2B;AAC3B,KAAK,SAAS,GAAG,OAAO,GAAG,MAAM,GAAG,QAAQ,CAAA;AAE5C,+BAA+B;AAC/B,KAAK,aAAa,GAAG,OAAO,GAAG,MAAM,CAAA;AAErC;;GAEG;AACH,wBAAgB,YAAY,CAC1B,IAAI,GAAE;IACJ,oCAAoC;IACpC,gBAAgB,CAAC,EAAE,SAAS,CAAA;IAC5B,8BAA8B;IAC9B,iBAAiB,CAAC,EAAE,SAAS,CAAA;CACzB;
|
|
1
|
+
{"version":3,"file":"useColorMode.d.ts","sourceRoot":"","sources":["../../src/useColorMode/useColorMode.ts"],"names":[],"mappings":"AAOA,2BAA2B;AAC3B,KAAK,SAAS,GAAG,OAAO,GAAG,MAAM,GAAG,QAAQ,CAAA;AAE5C,+BAA+B;AAC/B,KAAK,aAAa,GAAG,OAAO,GAAG,MAAM,CAAA;AAErC;;GAEG;AACH,wBAAgB,YAAY,CAC1B,IAAI,GAAE;IACJ,oCAAoC;IACpC,gBAAgB,CAAC,EAAE,SAAS,CAAA;IAC5B,8BAA8B;IAC9B,iBAAiB,CAAC,EAAE,SAAS,CAAA;CACzB;IA6FJ,yCAAyC;;IAKzC,+CAA+C;;IAE/C,yDAAyD;;IAEzD,qDAAqD;;IAErD,kDAAkD;0BAvFvB,SAAS;IAyFpC,uCAAuC;mCAhFL,aAAa;EAmFlD"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { literal, union, validate } from '@scalar/validation';
|
|
1
2
|
import { computed, onMounted, onUnmounted, ref, watch } from 'vue';
|
|
2
|
-
import { z } from 'zod';
|
|
3
3
|
const colorMode = ref('dark');
|
|
4
|
-
const colorModeSchema =
|
|
4
|
+
const colorModeSchema = union([literal('system'), literal('dark'), literal('light')]);
|
|
5
5
|
/**
|
|
6
6
|
* A composable hook that provides color mode (dark/light) functionality.
|
|
7
7
|
*/
|
|
@@ -60,8 +60,11 @@ export function useColorMode(opts = {}) {
|
|
|
60
60
|
document.body.classList.remove('dark-mode');
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
|
-
// Priority
|
|
64
|
-
|
|
63
|
+
// Priority: overrideColorMode -> localStorage -> initialColorMode
|
|
64
|
+
// Without `window` (SSR/SSG), there is no storage — treat preference as `system` so we do not
|
|
65
|
+
// fall through to `initialColorMode` and diverge from client hydration (see useColorMode tests).
|
|
66
|
+
const storedValue = typeof window === 'undefined' ? 'system' : window?.localStorage?.getItem('colorMode');
|
|
67
|
+
const savedColorMode = validate(colorModeSchema, storedValue) ? storedValue : null;
|
|
65
68
|
colorMode.value = overrideColorMode ?? savedColorMode ?? initialColorMode;
|
|
66
69
|
// Watch for colorMode changes and update the body class
|
|
67
70
|
watch(colorMode, applyColorMode, { immediate: true });
|
package/package.json
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"url": "git+https://github.com/scalar/scalar.git",
|
|
11
11
|
"directory": "packages/use-hooks"
|
|
12
12
|
},
|
|
13
|
-
"version": "0.4.
|
|
13
|
+
"version": "0.4.5",
|
|
14
14
|
"engines": {
|
|
15
15
|
"node": ">=22"
|
|
16
16
|
},
|
|
@@ -43,11 +43,11 @@
|
|
|
43
43
|
],
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@vueuse/core": "13.9.0",
|
|
46
|
-
"cva": "1.0.0-beta.
|
|
47
|
-
"tailwind-merge": "3.
|
|
46
|
+
"cva": "1.0.0-beta.4",
|
|
47
|
+
"tailwind-merge": "3.5.0",
|
|
48
48
|
"vue": "^3.5.30",
|
|
49
|
-
"
|
|
50
|
-
"@scalar/
|
|
49
|
+
"@scalar/use-toasts": "0.10.2",
|
|
50
|
+
"@scalar/validation": "0.5.0"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@vue/test-utils": "2.4.6",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
},
|
|
56
56
|
"scripts": {
|
|
57
57
|
"build": "tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json",
|
|
58
|
-
"test": "vitest",
|
|
58
|
+
"test": "vitest --run",
|
|
59
59
|
"types:check": "vue-tsc --noEmit"
|
|
60
60
|
}
|
|
61
61
|
}
|