@webitel/ui-datalist 1.1.68 → 1.1.69
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/package.json +1 -1
- package/src/modules/filters/__tests__/createTableFiltersStore.spec.ts +14 -0
- package/src/modules/filters/createTableFiltersStore.ts +2 -0
- package/src/modules/headers/createTableHeadersStore.ts +2 -1
- package/src/modules/persist/PersistedStorage.types.ts +1 -0
- package/src/modules/persist/__tests__/usePersistedStorage.spec.ts +162 -3
- package/src/modules/persist/__tests__/useWebStoragePersistedStorage.spec.ts +107 -0
- package/src/modules/persist/useLocalStoragePersistedStorage.ts +5 -26
- package/src/modules/persist/usePersistedStorage.ts +27 -12
- package/src/modules/persist/useSessionStoragePersistedStorage.ts +13 -0
- package/src/modules/persist/useWebStoragePersistedStorage.ts +37 -0
- package/types/.tsbuildinfo +1 -1
- package/types/modules/persist/PersistedStorage.types.d.ts +2 -1
- package/types/modules/persist/useSessionStoragePersistedStorage.d.ts +4 -0
- package/types/modules/persist/useWebStoragePersistedStorage.d.ts +5 -0
- package/src/modules/persist/__tests__/useLocalStoragePersistedStorage.spec.ts +0 -66
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { Ref, WatchOptions } from 'vue';
|
|
2
2
|
export declare enum PersistedStorageType {
|
|
3
3
|
LocalStorage = "localStorage",
|
|
4
|
-
Route = "route"
|
|
4
|
+
Route = "route",
|
|
5
|
+
SessionStorage = "sessionStorage"
|
|
5
6
|
}
|
|
6
7
|
export type PersistStorableValue = string;
|
|
7
8
|
export type PersistableValue = PersistStorableValue | {
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { beforeEach, describe, expect, it } from 'vitest';
|
|
2
|
-
|
|
3
|
-
import { useLocalStoragePersistedStorage } from '../useLocalStoragePersistedStorage';
|
|
4
|
-
|
|
5
|
-
describe('useLocalStoragePersistedStorage', () => {
|
|
6
|
-
beforeEach(() => {
|
|
7
|
-
localStorage.clear();
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
it('namespaces keys with the storagePath', async () => {
|
|
11
|
-
const storage = useLocalStoragePersistedStorage({
|
|
12
|
-
storagePath: 'cases/headers',
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
await storage.setItem('fields', 'name,subject');
|
|
16
|
-
|
|
17
|
-
expect(localStorage.getItem('cases/headers/fields')).toBe('name,subject');
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
it('keeps stores with different paths apart', async () => {
|
|
21
|
-
const cases = useLocalStoragePersistedStorage({
|
|
22
|
-
storagePath: 'cases',
|
|
23
|
-
});
|
|
24
|
-
const contacts = useLocalStoragePersistedStorage({
|
|
25
|
-
storagePath: 'contacts',
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
await cases.setItem('fields', 'subject');
|
|
29
|
-
await contacts.setItem('fields', 'name');
|
|
30
|
-
|
|
31
|
-
expect(await cases.getItem('fields')).toBe('subject');
|
|
32
|
-
expect(await contacts.getItem('fields')).toBe('name');
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
it('resolves null for a missing key', async () => {
|
|
36
|
-
const storage = useLocalStoragePersistedStorage({
|
|
37
|
-
storagePath: 'cases',
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
expect(await storage.getItem('fields')).toBeNull();
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
it('stores an array as a comma-joined value', async () => {
|
|
44
|
-
const storage = useLocalStoragePersistedStorage({
|
|
45
|
-
storagePath: 'cases',
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
await storage.setItem('fields', [
|
|
49
|
-
'name',
|
|
50
|
-
'subject',
|
|
51
|
-
]);
|
|
52
|
-
|
|
53
|
-
expect(await storage.getItem('fields')).toBe('name,subject');
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
it('removes a key', async () => {
|
|
57
|
-
const storage = useLocalStoragePersistedStorage({
|
|
58
|
-
storagePath: 'cases',
|
|
59
|
-
});
|
|
60
|
-
await storage.setItem('fields', 'name');
|
|
61
|
-
|
|
62
|
-
await storage.removeItem('fields');
|
|
63
|
-
|
|
64
|
-
expect(await storage.getItem('fields')).toBeNull();
|
|
65
|
-
});
|
|
66
|
-
});
|