@cloud-ru/ds-table 2.2.3 → 2.2.4-preview-01f86b34.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.
- package/dist/cjs/components/Table/hooks/useColumnSettings/useColumnSettings.js +8 -8
- package/dist/esm/components/Table/hooks/useColumnSettings/useColumnSettings.js +10 -10
- package/dist/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/tsconfig.esm.tsbuildinfo +1 -1
- package/package.json +20 -20
- package/src/components/Table/hooks/useColumnSettings/useColumnSettings.ts +12 -11
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloud-ru/ds-table",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.4-preview-01f86b34.0",
|
|
4
4
|
"description": "Таблица данных: клиентская Table, серверная ServerTable и preset-обёртки с упрощённым API.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -48,25 +48,25 @@
|
|
|
48
48
|
"@tanstack/react-table": "^8.21.3",
|
|
49
49
|
"@tanstack/react-virtual": "^3.14.8",
|
|
50
50
|
"classnames": "^2.5.1",
|
|
51
|
-
"@cloud-ru/ds-
|
|
52
|
-
"@cloud-ru/ds-
|
|
53
|
-
"@cloud-ru/ds-
|
|
54
|
-
"@cloud-ru/ds-
|
|
55
|
-
"@cloud-ru/ds-
|
|
56
|
-
"@cloud-ru/ds-
|
|
57
|
-
"@cloud-ru/ds-
|
|
58
|
-
"@cloud-ru/ds-
|
|
59
|
-
"@cloud-ru/ds-
|
|
60
|
-
"@cloud-ru/ds-
|
|
61
|
-
"@cloud-ru/ds-
|
|
62
|
-
"@cloud-ru/ds-
|
|
63
|
-
"@cloud-ru/ds-
|
|
64
|
-
"@cloud-ru/ds-
|
|
65
|
-
"@cloud-ru/ds-
|
|
66
|
-
"@cloud-ru/ds-
|
|
67
|
-
"@cloud-ru/ds-
|
|
68
|
-
"@cloud-ru/ds-
|
|
69
|
-
"@cloud-ru/ds-
|
|
51
|
+
"@cloud-ru/ds-adaptive": "1.0.3",
|
|
52
|
+
"@cloud-ru/ds-card": "1.0.31",
|
|
53
|
+
"@cloud-ru/ds-button": "1.0.5",
|
|
54
|
+
"@cloud-ru/ds-chips": "1.2.7",
|
|
55
|
+
"@cloud-ru/ds-drag-and-drop": "1.1.4",
|
|
56
|
+
"@cloud-ru/ds-info-block": "1.0.4",
|
|
57
|
+
"@cloud-ru/ds-icons": "1.7.1",
|
|
58
|
+
"@cloud-ru/ds-list": "3.0.6",
|
|
59
|
+
"@cloud-ru/ds-locale": "1.0.0",
|
|
60
|
+
"@cloud-ru/ds-pagination": "1.1.8",
|
|
61
|
+
"@cloud-ru/ds-materials": "2.0.2",
|
|
62
|
+
"@cloud-ru/ds-scroll": "1.0.6",
|
|
63
|
+
"@cloud-ru/ds-skeleton": "1.0.3",
|
|
64
|
+
"@cloud-ru/ds-status": "1.1.14",
|
|
65
|
+
"@cloud-ru/ds-toggles": "1.1.14",
|
|
66
|
+
"@cloud-ru/ds-toolbar": "2.1.3",
|
|
67
|
+
"@cloud-ru/ds-truncate-string": "1.0.17",
|
|
68
|
+
"@cloud-ru/ds-tooltip": "1.0.16",
|
|
69
|
+
"@cloud-ru/ds-utils": "1.3.0"
|
|
70
70
|
},
|
|
71
71
|
"publishConfig": {
|
|
72
72
|
"access": "public"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { FiltersState } from '@cloud-ru/ds-chips';
|
|
2
2
|
import { GroupSelectItemProps } from '@cloud-ru/ds-list';
|
|
3
3
|
import { isBrowser } from '@cloud-ru/ds-utils';
|
|
4
|
-
import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
4
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
5
5
|
|
|
6
6
|
import { MasterSelectionOptions } from '../../../../helpers';
|
|
7
7
|
import { tableLocale } from '../../../../locale';
|
|
@@ -10,7 +10,6 @@ import { TableProps } from '../../../types';
|
|
|
10
10
|
import { getColumnIdentifier, getTableColumnsDefinitions, PinnedGroupsState } from '../../utils';
|
|
11
11
|
import {
|
|
12
12
|
getEnabledColumnsInitialState,
|
|
13
|
-
isColumnEnabledInitially,
|
|
14
13
|
isFilterableColumn,
|
|
15
14
|
prepareColumnsSettings,
|
|
16
15
|
prepareReorderableColumnsSettings,
|
|
@@ -64,17 +63,19 @@ export function useColumnSettings<TData extends object, TFilters extends Filters
|
|
|
64
63
|
getEnabledColumnsInitialState(configurableColumns, savedState, localStorageKey),
|
|
65
64
|
);
|
|
66
65
|
|
|
66
|
+
const knownColumnIdsRef = useRef(configurableColumns.map(getColumnIdentifier));
|
|
67
|
+
|
|
67
68
|
useEffect(() => {
|
|
69
|
+
const currentIds = configurableColumns.map(getColumnIdentifier);
|
|
70
|
+
const knownIds = knownColumnIdsRef.current;
|
|
71
|
+
knownColumnIdsRef.current = currentIds;
|
|
72
|
+
|
|
73
|
+
const newColumns = configurableColumns.filter(col => !knownIds.includes(getColumnIdentifier(col)));
|
|
74
|
+
const addedIds = newColumns.length ? getEnabledColumnsInitialState(newColumns, savedState, localStorageKey) : [];
|
|
75
|
+
|
|
68
76
|
setEnabledColumns(prev => {
|
|
69
|
-
const currentIds = configurableColumns.map(getColumnIdentifier);
|
|
70
77
|
const kept = prev.filter(id => currentIds.includes(id));
|
|
71
|
-
const added =
|
|
72
|
-
.filter(id => !kept.includes(id))
|
|
73
|
-
.filter(id => {
|
|
74
|
-
const colDef = configurableColumns.find(col => getColumnIdentifier(col) === id);
|
|
75
|
-
|
|
76
|
-
return colDef ? isColumnEnabledInitially(colDef) : false;
|
|
77
|
-
});
|
|
78
|
+
const added = addedIds.filter(id => !kept.includes(id));
|
|
78
79
|
const reconciled = [...kept, ...added];
|
|
79
80
|
|
|
80
81
|
if (reconciled.length === prev.length && reconciled.every((id, i) => id === prev[i])) {
|
|
@@ -83,7 +84,7 @@ export function useColumnSettings<TData extends object, TFilters extends Filters
|
|
|
83
84
|
|
|
84
85
|
return reconciled;
|
|
85
86
|
});
|
|
86
|
-
}, [configurableColumns]);
|
|
87
|
+
}, [configurableColumns, localStorageKey, savedState]);
|
|
87
88
|
|
|
88
89
|
const setEnabledColumnsOuter = useCallback(
|
|
89
90
|
(value: string[]) => {
|