@tb-dev/vue 3.4.5 → 4.0.0
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.
|
@@ -3,7 +3,9 @@ export interface LocalRefOptions {
|
|
|
3
3
|
deep?: boolean;
|
|
4
4
|
initOnMounted?: boolean;
|
|
5
5
|
listenToStorageChanges?: boolean;
|
|
6
|
+
mergeDefaults?: boolean;
|
|
6
7
|
onError?: (err: unknown) => void;
|
|
8
|
+
shallow?: boolean;
|
|
7
9
|
writeDefaults?: boolean;
|
|
8
10
|
}
|
|
9
11
|
export declare function localRef<T>(key: string, initial: T, options?: LocalRefOptions): Ref<T>;
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { unwrap, isNil } from '@tb-dev/utils';
|
|
2
|
-
import { inject as inject$1, toValue, toRef, ref, readonly,
|
|
2
|
+
import { inject as inject$1, toValue, toRef, ref, readonly, effectScope, computed } from 'vue';
|
|
3
3
|
import { watchImmediate, useAsyncState, useLocalStorage, tryOnScopeDispose, onKeyStroke, useSessionStorage, computedAsync, useWindowSize, useElementSize as useElementSize$1, useBreakpoints as useBreakpoints$1, breakpointsTailwind } from '@vueuse/core';
|
|
4
4
|
export { useWindowSize } from '@vueuse/core';
|
|
5
5
|
import { Mutex } from 'es-toolkit';
|
|
@@ -157,24 +157,19 @@ function asyncRef(initial, fn, options = {}) {
|
|
|
157
157
|
}
|
|
158
158
|
|
|
159
159
|
function localRef(key, initial, options) {
|
|
160
|
-
|
|
161
|
-
const local = useLocalStorage(key, defaultValue, {
|
|
160
|
+
return useLocalStorage(key, initial, {
|
|
162
161
|
deep: options?.deep ?? true,
|
|
163
162
|
initOnMounted: options?.initOnMounted ?? true,
|
|
164
163
|
listenToStorageChanges: options?.listenToStorageChanges ?? true,
|
|
164
|
+
mergeDefaults: options?.mergeDefaults ?? true,
|
|
165
165
|
onError: options?.onError ?? handleError,
|
|
166
|
+
shallow: options?.shallow,
|
|
166
167
|
writeDefaults: options?.writeDefaults ?? true,
|
|
167
168
|
serializer: {
|
|
168
169
|
read: JSON.parse,
|
|
169
170
|
write: JSON.stringify
|
|
170
171
|
}
|
|
171
172
|
});
|
|
172
|
-
return computed({
|
|
173
|
-
get: () => local.value.inner,
|
|
174
|
-
set: (value) => {
|
|
175
|
-
local.value.inner = value;
|
|
176
|
-
}
|
|
177
|
-
});
|
|
178
173
|
}
|
|
179
174
|
|
|
180
175
|
function onKeyDown(key, handler, options = {}) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tb-dev/vue",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "Vue utilities",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -24,14 +24,14 @@
|
|
|
24
24
|
"composables"
|
|
25
25
|
],
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@tb-dev/utils": "^7.
|
|
27
|
+
"@tb-dev/utils": "^7.3.0",
|
|
28
28
|
"@vueuse/core": "^14.2.0",
|
|
29
29
|
"es-toolkit": "^1.44.0",
|
|
30
30
|
"vue": "^3.5.27"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@tb-dev/eslint-config": "^8.2.6",
|
|
34
|
-
"@types/node": "^25.2.
|
|
34
|
+
"@types/node": "^25.2.2",
|
|
35
35
|
"eslint": "^9.39.2",
|
|
36
36
|
"tslib": "^2.8.1",
|
|
37
37
|
"typedoc": "^0.28.16",
|