@tb-dev/vue 3.5.0 → 4.0.1
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.
|
@@ -5,6 +5,7 @@ export interface LocalRefOptions {
|
|
|
5
5
|
listenToStorageChanges?: boolean;
|
|
6
6
|
mergeDefaults?: boolean;
|
|
7
7
|
onError?: (err: unknown) => void;
|
|
8
|
+
shallow?: boolean;
|
|
8
9
|
writeDefaults?: boolean;
|
|
9
10
|
}
|
|
10
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,25 +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,
|
|
165
164
|
mergeDefaults: options?.mergeDefaults ?? true,
|
|
166
165
|
onError: options?.onError ?? handleError,
|
|
166
|
+
shallow: options?.shallow,
|
|
167
167
|
writeDefaults: options?.writeDefaults ?? true,
|
|
168
168
|
serializer: {
|
|
169
169
|
read: JSON.parse,
|
|
170
170
|
write: JSON.stringify
|
|
171
171
|
}
|
|
172
172
|
});
|
|
173
|
-
return computed({
|
|
174
|
-
get: () => local.value.inner,
|
|
175
|
-
set: (value) => {
|
|
176
|
-
local.value.inner = value;
|
|
177
|
-
}
|
|
178
|
-
});
|
|
179
173
|
}
|
|
180
174
|
|
|
181
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.1",
|
|
4
4
|
"description": "Vue utilities",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"@tb-dev/utils": "^7.3.0",
|
|
28
28
|
"@vueuse/core": "^14.2.0",
|
|
29
29
|
"es-toolkit": "^1.44.0",
|
|
30
|
-
"vue": "^3.5.
|
|
30
|
+
"vue": "^3.5.28"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@tb-dev/eslint-config": "^8.2.6",
|