@webitel/ui-datalist 1.1.67 → 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/__tests__/createTableHeadersStore.spec.ts +144 -1
- package/src/modules/headers/createTableHeadersStore.ts +23 -5
- 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/src/modules/types/tableStore.types.ts +7 -0
- package/types/.tsbuildinfo +1 -1
- package/types/modules/filter-presets/stores/createFilterPresetsStore.d.ts +3 -0
- package/types/modules/headers/createTableHeadersStore.d.ts +6 -0
- package/types/modules/permissions-page/stores/createPermissionsStore.d.ts +6 -0
- 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/types/modules/table/createTableStore.store.d.ts +6 -0
- package/types/modules/types/tableStore.types.d.ts +7 -0
- package/src/modules/persist/__tests__/useLocalStoragePersistedStorage.spec.ts +0 -66
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { StorageLike } from './PersistedStorage.types.ts';
|
|
2
|
+
import { useWebStoragePersistedStorage } from './useWebStoragePersistedStorage';
|
|
3
|
+
|
|
4
|
+
export const useSessionStoragePersistedStorage = ({
|
|
5
|
+
storagePath = '',
|
|
6
|
+
}: {
|
|
7
|
+
storagePath?: string;
|
|
8
|
+
}): StorageLike => {
|
|
9
|
+
return useWebStoragePersistedStorage({
|
|
10
|
+
storage: () => sessionStorage,
|
|
11
|
+
storagePath,
|
|
12
|
+
});
|
|
13
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { StorageLike } from './PersistedStorage.types.ts';
|
|
2
|
+
|
|
3
|
+
const separator = ';';
|
|
4
|
+
|
|
5
|
+
const makePath = (storagePath: string, key: string) => `${storagePath}/${key}`;
|
|
6
|
+
|
|
7
|
+
/* `storage` is a getter, so the global is touched at call time, not at module load */
|
|
8
|
+
export const useWebStoragePersistedStorage = ({
|
|
9
|
+
storage,
|
|
10
|
+
storagePath = '',
|
|
11
|
+
}: {
|
|
12
|
+
storage: () => Storage;
|
|
13
|
+
storagePath?: string;
|
|
14
|
+
}): StorageLike => {
|
|
15
|
+
const getItem = async (key: string) => {
|
|
16
|
+
const value = storage().getItem(makePath(storagePath, key));
|
|
17
|
+
if (value === null) return null;
|
|
18
|
+
return value.split(separator).join();
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const setItem = async (key: string, inputValue: string | string[]) => {
|
|
22
|
+
const value = Array.isArray(inputValue)
|
|
23
|
+
? inputValue.join(separator)
|
|
24
|
+
: inputValue;
|
|
25
|
+
storage().setItem(makePath(storagePath, key), value);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const removeItem = async (key: string) => {
|
|
29
|
+
storage().removeItem(makePath(storagePath, key));
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
return {
|
|
33
|
+
getItem,
|
|
34
|
+
setItem,
|
|
35
|
+
removeItem,
|
|
36
|
+
};
|
|
37
|
+
};
|
|
@@ -13,6 +13,13 @@ import type { DatalistStoreProviderType } from './StoreProvider';
|
|
|
13
13
|
export type DatalistTableHeader = WtTableHeader & {
|
|
14
14
|
field: string;
|
|
15
15
|
shouldBeInitialized?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Access gate supplied by the consuming app, evaluated once when the headers
|
|
18
|
+
* store is created. Returning `false` drops the column completely: absent
|
|
19
|
+
* from the column picker, never rendered, never requested, and not
|
|
20
|
+
* restorable from persisted state. Omitted means allowed.
|
|
21
|
+
*/
|
|
22
|
+
access?: () => boolean | Ref<boolean>;
|
|
16
23
|
};
|
|
17
24
|
|
|
18
25
|
export type TrackSelectedRowBy<T> = (row: T) => T;
|