@reltio/components 1.4.1928 → 1.4.1929
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/cjs/BasicTable/basicTableViewState.d.ts +63 -15
- package/cjs/BasicTable/basicTableViewState.js +38 -20
- package/cjs/BasicTable/basicTableViewState.test.js +20 -0
- package/cjs/contexts/ProfileTablesContext/index.d.ts +6 -0
- package/cjs/contexts/ProfileTablesContext/index.js +8 -0
- package/cjs/helpers/basicTable.d.ts +3 -1
- package/cjs/helpers/basicTable.js +12 -1
- package/cjs/hooks/useSavedState/useSavedState.d.ts +1 -1
- package/cjs/hooks/useSavedStateForEntityType/useSavedStateForEntityType.d.ts +1 -1
- package/cjs/index.d.ts +4 -2
- package/cjs/index.js +6 -2
- package/cjs/test-utils/index.js +1 -1
- package/cjs/types/basicTable.d.ts +5 -0
- package/cjs/types/preferences.d.ts +8 -0
- package/cjs/types/preferences.js +2 -0
- package/esm/BasicTable/basicTableViewState.d.ts +63 -15
- package/esm/BasicTable/basicTableViewState.js +37 -19
- package/esm/BasicTable/basicTableViewState.test.js +20 -0
- package/esm/contexts/ProfileTablesContext/index.d.ts +6 -0
- package/esm/contexts/ProfileTablesContext/index.js +5 -0
- package/esm/helpers/basicTable.d.ts +3 -1
- package/esm/helpers/basicTable.js +10 -0
- package/esm/hooks/useSavedState/useSavedState.d.ts +1 -1
- package/esm/hooks/useSavedStateForEntityType/useSavedStateForEntityType.d.ts +1 -1
- package/esm/index.d.ts +4 -2
- package/esm/index.js +3 -1
- package/esm/test-utils/index.js +1 -1
- package/esm/types/basicTable.d.ts +5 -0
- package/esm/types/preferences.d.ts +8 -0
- package/esm/types/preferences.js +1 -0
- package/package.json +2 -2
|
@@ -1,34 +1,82 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { createStandardAction } from '@reltio/mdm-sdk';
|
|
2
|
+
import { ColumnData, ColumnFilter, ColumnSize, Sorting } from '../types/basicTable';
|
|
3
|
+
export declare enum ActionTypes {
|
|
4
|
+
CHANGE_COLUMNS = "CHANGE_COLUMNS",
|
|
5
|
+
TOGGLE_FILTERS = "TOGGLE_FILTERS",
|
|
6
|
+
CHANGE_FILTER = "CHANGE_FILTER",
|
|
7
|
+
TOGGLE_SORT = "TOGGLE_SORT",
|
|
8
|
+
CHANGE_PAGE = "CHANGE_PAGE",
|
|
9
|
+
CHANGE_ROWS_PER_PAGE = "CHANGE_ROWS_PER_PAGE"
|
|
10
|
+
}
|
|
11
|
+
export type BasicTableState = {
|
|
12
|
+
visibleColumns: ColumnData['id'][];
|
|
13
|
+
columnsSize?: ColumnSize[];
|
|
14
|
+
filters?: Record<ColumnData['id'], ColumnFilter>;
|
|
15
|
+
sorting?: Sorting;
|
|
16
|
+
page: number;
|
|
17
|
+
rowsPerPage: number;
|
|
18
|
+
rowsPerPageOptions?: number[];
|
|
19
|
+
[key: string]: unknown;
|
|
20
|
+
};
|
|
21
|
+
export type BasicTableAction = ReturnType<ReturnType<typeof createStandardAction>>;
|
|
22
|
+
export type BasicTableReducer = <TableState extends BasicTableState, TableAction extends BasicTableAction>(state: TableState, action: TableAction) => TableState;
|
|
23
|
+
export declare const actions: {
|
|
24
|
+
changeColumns: (payload: any) => {
|
|
3
25
|
type: any;
|
|
4
26
|
payload: any;
|
|
5
27
|
};
|
|
6
|
-
|
|
28
|
+
toggleFilters: (payload: any) => {
|
|
7
29
|
type: any;
|
|
8
30
|
payload: any;
|
|
9
31
|
};
|
|
10
|
-
|
|
32
|
+
changeFilter: (payload: any) => {
|
|
11
33
|
type: any;
|
|
12
34
|
payload: any;
|
|
13
35
|
};
|
|
14
|
-
|
|
36
|
+
toggleSort: (payload: any) => {
|
|
15
37
|
type: any;
|
|
16
38
|
payload: any;
|
|
17
39
|
};
|
|
18
|
-
|
|
40
|
+
changePage: (payload: any) => {
|
|
19
41
|
type: any;
|
|
20
42
|
payload: any;
|
|
21
43
|
};
|
|
22
|
-
|
|
44
|
+
changeRowsPerPage: (payload: any) => {
|
|
23
45
|
type: any;
|
|
24
46
|
payload: any;
|
|
25
47
|
};
|
|
26
|
-
}
|
|
27
|
-
export
|
|
28
|
-
export
|
|
29
|
-
declare
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
48
|
+
};
|
|
49
|
+
export declare const changeVisibleColumns: (state: BasicTableState, nextVisibleColumns?: BasicTableState['visibleColumns']) => any;
|
|
50
|
+
export declare const reducer: BasicTableReducer;
|
|
51
|
+
declare const _default: {
|
|
52
|
+
reducer: BasicTableReducer;
|
|
53
|
+
actions: {
|
|
54
|
+
changeColumns: (payload: any) => {
|
|
55
|
+
type: any;
|
|
56
|
+
payload: any;
|
|
57
|
+
};
|
|
58
|
+
toggleFilters: (payload: any) => {
|
|
59
|
+
type: any;
|
|
60
|
+
payload: any;
|
|
61
|
+
};
|
|
62
|
+
changeFilter: (payload: any) => {
|
|
63
|
+
type: any;
|
|
64
|
+
payload: any;
|
|
65
|
+
};
|
|
66
|
+
toggleSort: (payload: any) => {
|
|
67
|
+
type: any;
|
|
68
|
+
payload: any;
|
|
69
|
+
};
|
|
70
|
+
changePage: (payload: any) => {
|
|
71
|
+
type: any;
|
|
72
|
+
payload: any;
|
|
73
|
+
};
|
|
74
|
+
changeRowsPerPage: (payload: any) => {
|
|
75
|
+
type: any;
|
|
76
|
+
payload: any;
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
ActionTypes: typeof ActionTypes;
|
|
80
|
+
changeVisibleColumns: (state: BasicTableState, nextVisibleColumns?: string[]) => any;
|
|
81
|
+
};
|
|
34
82
|
export default _default;
|
|
@@ -11,28 +11,42 @@ var __assign = (this && this.__assign) || function () {
|
|
|
11
11
|
return __assign.apply(this, arguments);
|
|
12
12
|
};
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.reducer = exports.changeVisibleColumns = exports.actions = void 0;
|
|
14
|
+
exports.reducer = exports.changeVisibleColumns = exports.actions = exports.ActionTypes = void 0;
|
|
15
15
|
var mdm_sdk_1 = require("@reltio/mdm-sdk");
|
|
16
16
|
var ramda_1 = require("ramda");
|
|
17
|
-
var
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
17
|
+
var ActionTypes;
|
|
18
|
+
(function (ActionTypes) {
|
|
19
|
+
ActionTypes["CHANGE_COLUMNS"] = "CHANGE_COLUMNS";
|
|
20
|
+
ActionTypes["TOGGLE_FILTERS"] = "TOGGLE_FILTERS";
|
|
21
|
+
ActionTypes["CHANGE_FILTER"] = "CHANGE_FILTER";
|
|
22
|
+
ActionTypes["TOGGLE_SORT"] = "TOGGLE_SORT";
|
|
23
|
+
ActionTypes["CHANGE_PAGE"] = "CHANGE_PAGE";
|
|
24
|
+
ActionTypes["CHANGE_ROWS_PER_PAGE"] = "CHANGE_ROWS_PER_PAGE";
|
|
25
|
+
})(ActionTypes || (exports.ActionTypes = ActionTypes = {}));
|
|
23
26
|
exports.actions = {
|
|
24
|
-
changeColumns: (0, mdm_sdk_1.createStandardAction)(CHANGE_COLUMNS),
|
|
25
|
-
toggleFilters: (0, mdm_sdk_1.createStandardAction)(TOGGLE_FILTERS),
|
|
26
|
-
changeFilter: (0, mdm_sdk_1.createStandardAction)(CHANGE_FILTER),
|
|
27
|
-
toggleSort: (0, mdm_sdk_1.createStandardAction)(TOGGLE_SORT),
|
|
28
|
-
changePage: (0, mdm_sdk_1.createStandardAction)(CHANGE_PAGE),
|
|
29
|
-
changeRowsPerPage: (0, mdm_sdk_1.createStandardAction)(CHANGE_ROWS_PER_PAGE)
|
|
27
|
+
changeColumns: (0, mdm_sdk_1.createStandardAction)(ActionTypes.CHANGE_COLUMNS),
|
|
28
|
+
toggleFilters: (0, mdm_sdk_1.createStandardAction)(ActionTypes.TOGGLE_FILTERS),
|
|
29
|
+
changeFilter: (0, mdm_sdk_1.createStandardAction)(ActionTypes.CHANGE_FILTER),
|
|
30
|
+
toggleSort: (0, mdm_sdk_1.createStandardAction)(ActionTypes.TOGGLE_SORT),
|
|
31
|
+
changePage: (0, mdm_sdk_1.createStandardAction)(ActionTypes.CHANGE_PAGE),
|
|
32
|
+
changeRowsPerPage: (0, mdm_sdk_1.createStandardAction)(ActionTypes.CHANGE_ROWS_PER_PAGE)
|
|
30
33
|
};
|
|
31
34
|
var changeVisibleColumns = function (state, nextVisibleColumns) {
|
|
35
|
+
if (nextVisibleColumns === void 0) { nextVisibleColumns = []; }
|
|
32
36
|
var removedColumns = (0, ramda_1.difference)(state.visibleColumns, nextVisibleColumns);
|
|
33
37
|
var isRemovedColumn = function (columnId) { return removedColumns.includes(columnId); };
|
|
34
38
|
return (0, ramda_1.evolve)({
|
|
35
39
|
visibleColumns: (0, ramda_1.always)(nextVisibleColumns),
|
|
40
|
+
columnsSize: function (columnsSize) {
|
|
41
|
+
if (columnsSize === void 0) { columnsSize = []; }
|
|
42
|
+
return nextVisibleColumns.map(function (columnId) {
|
|
43
|
+
var columnSize = columnsSize.find(function (_a) {
|
|
44
|
+
var id = _a.id;
|
|
45
|
+
return id === columnId;
|
|
46
|
+
});
|
|
47
|
+
return __assign({ id: columnId, size: (columnSize === null || columnSize === void 0 ? void 0 : columnSize.manuallyChanged) ? columnSize.size : 0 }, ((columnSize === null || columnSize === void 0 ? void 0 : columnSize.manuallyChanged) ? { manuallyChanged: true } : {}));
|
|
48
|
+
});
|
|
49
|
+
},
|
|
36
50
|
sorting: (0, ramda_1.when)(function (sorting) {
|
|
37
51
|
if (sorting === void 0) { sorting = {}; }
|
|
38
52
|
return isRemovedColumn(sorting.field);
|
|
@@ -41,26 +55,29 @@ var changeVisibleColumns = function (state, nextVisibleColumns) {
|
|
|
41
55
|
return { field: nextSortField, order: 'asc' };
|
|
42
56
|
}),
|
|
43
57
|
filters: function (filters) {
|
|
44
|
-
|
|
58
|
+
if (filters === void 0) { filters = {}; }
|
|
59
|
+
return (0, ramda_1.keys)(filters).reduce(function (acc, columnId) {
|
|
60
|
+
return isRemovedColumn(columnId) ? (0, ramda_1.dissoc)(columnId, acc) : acc;
|
|
61
|
+
}, filters);
|
|
45
62
|
}
|
|
46
63
|
}, state);
|
|
47
64
|
};
|
|
48
65
|
exports.changeVisibleColumns = changeVisibleColumns;
|
|
49
66
|
var reducer = function (state, action) {
|
|
50
67
|
switch (action.type) {
|
|
51
|
-
case CHANGE_COLUMNS: {
|
|
68
|
+
case ActionTypes.CHANGE_COLUMNS: {
|
|
52
69
|
var columnIds = action.payload;
|
|
53
70
|
return (0, exports.changeVisibleColumns)(state, columnIds);
|
|
54
71
|
}
|
|
55
|
-
case TOGGLE_FILTERS: {
|
|
72
|
+
case ActionTypes.TOGGLE_FILTERS: {
|
|
56
73
|
var enableFilters = !state.filters;
|
|
57
74
|
return __assign(__assign({}, state), { filters: enableFilters ? {} : null, page: enableFilters ? state.page : 0 });
|
|
58
75
|
}
|
|
59
|
-
case CHANGE_FILTER: {
|
|
76
|
+
case ActionTypes.CHANGE_FILTER: {
|
|
60
77
|
var _a = action.payload, columnId = _a.columnId, filter = _a.filter;
|
|
61
78
|
return (0, ramda_1.evolve)({ filters: filter ? (0, ramda_1.assoc)(columnId, filter) : (0, ramda_1.dissoc)(columnId), page: (0, ramda_1.always)(0) }, state);
|
|
62
79
|
}
|
|
63
|
-
case TOGGLE_SORT: {
|
|
80
|
+
case ActionTypes.TOGGLE_SORT: {
|
|
64
81
|
var nextSortField = action.payload;
|
|
65
82
|
var prevSortField = (0, ramda_1.path)(['sorting', 'field'], state);
|
|
66
83
|
var prevSortOrder = (0, ramda_1.path)(['sorting', 'order'], state);
|
|
@@ -69,9 +86,9 @@ var reducer = function (state, action) {
|
|
|
69
86
|
order: (0, mdm_sdk_1.toggleSortOrder)(nextSortField === prevSortField ? prevSortOrder : null)
|
|
70
87
|
}, page: 0 });
|
|
71
88
|
}
|
|
72
|
-
case CHANGE_PAGE:
|
|
89
|
+
case ActionTypes.CHANGE_PAGE:
|
|
73
90
|
return __assign(__assign({}, state), { page: action.payload });
|
|
74
|
-
case CHANGE_ROWS_PER_PAGE:
|
|
91
|
+
case ActionTypes.CHANGE_ROWS_PER_PAGE:
|
|
75
92
|
return __assign(__assign({}, state), { rowsPerPage: action.payload });
|
|
76
93
|
default:
|
|
77
94
|
return state;
|
|
@@ -81,5 +98,6 @@ exports.reducer = reducer;
|
|
|
81
98
|
exports.default = {
|
|
82
99
|
reducer: exports.reducer,
|
|
83
100
|
actions: exports.actions,
|
|
101
|
+
ActionTypes: ActionTypes,
|
|
84
102
|
changeVisibleColumns: exports.changeVisibleColumns
|
|
85
103
|
};
|
|
@@ -13,6 +13,26 @@ describe('basicTableViewState tests', function () {
|
|
|
13
13
|
};
|
|
14
14
|
expect((0, basicTableViewState_1.changeVisibleColumns)(prevState, visibleColumns)).toEqual(nextState);
|
|
15
15
|
});
|
|
16
|
+
it('should update columns size on changing visible columns', function () {
|
|
17
|
+
var prevState = {
|
|
18
|
+
visibleColumns: ['column1', 'column2', 'column3', 'column4'],
|
|
19
|
+
columnsSize: [
|
|
20
|
+
{ id: 'column1', size: 100, manuallyChanged: true },
|
|
21
|
+
{ id: 'column2', size: 200 },
|
|
22
|
+
{ id: 'column3', size: 300, manuallyChanged: true },
|
|
23
|
+
{ id: 'column4', size: 400 }
|
|
24
|
+
]
|
|
25
|
+
};
|
|
26
|
+
var visibleColumns = ['column1', 'column4'];
|
|
27
|
+
var nextState = {
|
|
28
|
+
visibleColumns: visibleColumns,
|
|
29
|
+
columnsSize: [
|
|
30
|
+
{ id: 'column1', size: 100, manuallyChanged: true },
|
|
31
|
+
{ id: 'column4', size: 0 }
|
|
32
|
+
]
|
|
33
|
+
};
|
|
34
|
+
expect((0, basicTableViewState_1.changeVisibleColumns)(prevState, visibleColumns)).toEqual(nextState);
|
|
35
|
+
});
|
|
16
36
|
it('should remove filters for columns that are no longer visible', function () {
|
|
17
37
|
var prevState = {
|
|
18
38
|
visibleColumns: ['column1', 'column2'],
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ProfileTablesPreferences } from '../../types/preferences';
|
|
3
|
+
export declare const ProfileTablesContext: import("react").Context<{
|
|
4
|
+
profileTablesPreferences: ProfileTablesPreferences;
|
|
5
|
+
setProfileTablesPreferences: (profileTablesPreferences: ProfileTablesPreferences) => void;
|
|
6
|
+
}>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ProfileTablesContext = void 0;
|
|
4
|
+
var react_1 = require("react");
|
|
5
|
+
exports.ProfileTablesContext = (0, react_1.createContext)({
|
|
6
|
+
profileTablesPreferences: {},
|
|
7
|
+
setProfileTablesPreferences: function () { }
|
|
8
|
+
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { FacetFilter } from '@reltio/mdm-sdk';
|
|
2
|
-
import { ColumnData, ColumnFilter } from '../types/basicTable';
|
|
2
|
+
import { ColumnData, ColumnFilter, ColumnSize } from '../types/basicTable';
|
|
3
|
+
import { ColumnsSizeById } from '../types/preferences';
|
|
3
4
|
export declare const defaultGetRowCellHeight: ({ columnData, cell }: {
|
|
4
5
|
columnData: any;
|
|
5
6
|
cell: any;
|
|
@@ -11,3 +12,4 @@ export declare const defaultRenderRowCell: ({ cell, CellValueRenderer, ...otherP
|
|
|
11
12
|
}) => any;
|
|
12
13
|
export declare const columnFilterToMdmFilter: (columnData: Pick<ColumnData, 'id' | 'dataTypeDefinition'>, columnFilter?: ColumnFilter) => FacetFilter;
|
|
13
14
|
export declare const buildColumnsFilter: (columnsData: ColumnData[], filters?: Record<string, ColumnFilter>) => string;
|
|
15
|
+
export declare const buildColumnsSizeById: (columnsSize?: ColumnSize[]) => ColumnsSizeById;
|
|
@@ -25,7 +25,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
25
25
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
26
26
|
};
|
|
27
27
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
-
exports.buildColumnsFilter = exports.columnFilterToMdmFilter = exports.defaultRenderRowCell = exports.defaultGetRowCellHeight = void 0;
|
|
28
|
+
exports.buildColumnsSizeById = exports.buildColumnsFilter = exports.columnFilterToMdmFilter = exports.defaultRenderRowCell = exports.defaultGetRowCellHeight = void 0;
|
|
29
29
|
var react_1 = __importDefault(require("react"));
|
|
30
30
|
var ramda_1 = require("ramda");
|
|
31
31
|
var mdm_sdk_1 = require("@reltio/mdm-sdk");
|
|
@@ -76,3 +76,14 @@ var buildColumnsFilter = function (columnsData, filters) {
|
|
|
76
76
|
.orSome('');
|
|
77
77
|
};
|
|
78
78
|
exports.buildColumnsFilter = buildColumnsFilter;
|
|
79
|
+
var buildColumnsSizeById = function (columnsSize) {
|
|
80
|
+
if (columnsSize === void 0) { columnsSize = []; }
|
|
81
|
+
return columnsSize.reduce(function (columnsSizeById, _a) {
|
|
82
|
+
var id = _a.id, size = _a.size, manuallyChanged = _a.manuallyChanged;
|
|
83
|
+
if (manuallyChanged) {
|
|
84
|
+
columnsSizeById[id] = size;
|
|
85
|
+
}
|
|
86
|
+
return columnsSizeById;
|
|
87
|
+
}, {});
|
|
88
|
+
};
|
|
89
|
+
exports.buildColumnsSizeById = buildColumnsSizeById;
|
package/cjs/index.d.ts
CHANGED
|
@@ -222,6 +222,7 @@ export { MaskedAttributesProvider, useMaskAttributeValue, useUnmaskAttributeValu
|
|
|
222
222
|
export { RowCollapseContext as BasicTableRowCollapseContext } from './contexts/RowCollapseContext';
|
|
223
223
|
export { BasicTableContext } from './contexts/BasicTableContext';
|
|
224
224
|
export { HiddenAttributesContext } from './contexts/HiddenAttributesContext';
|
|
225
|
+
export { ProfileTablesContext } from './contexts/ProfileTablesContext';
|
|
225
226
|
export { useScrollToAttributeError } from './hooks/useScrollToAttributeError';
|
|
226
227
|
export { useMatchesColumnsData } from './hooks/useMatchesColumnsData';
|
|
227
228
|
export { useActions } from './hooks/useActions';
|
|
@@ -260,7 +261,7 @@ export { useClickableChartStyle as useClickableStyle } from './hooks/useClickabl
|
|
|
260
261
|
export { useDynamicRowCellHeight } from './hooks/useDynamicRowCellHeight';
|
|
261
262
|
export { useKeyboardNavigation } from './hooks/useKeyboardNavigation';
|
|
262
263
|
export { useMaskedAttribute } from './hooks/useMaskedAttribute';
|
|
263
|
-
export { buildColumnsFilter, columnFilterToMdmFilter, defaultGetRowCellHeight, defaultRenderRowCell } from './helpers/basicTable';
|
|
264
|
+
export { buildColumnsFilter, buildColumnsSizeById, columnFilterToMdmFilter, defaultGetRowCellHeight, defaultRenderRowCell } from './helpers/basicTable';
|
|
264
265
|
export { enrichDataWithPercents } from './helpers/charts';
|
|
265
266
|
export { showDefaultErrorMessage, showErrorMessage } from './helpers/errors';
|
|
266
267
|
export { getChecked, getValue, isControlOrCommandPressed } from './helpers/events';
|
|
@@ -268,7 +269,8 @@ export { mergeClasses } from './helpers/classes';
|
|
|
268
269
|
export type { AttributeFiltersComponentProps } from './AttributesFiltersBuilder';
|
|
269
270
|
export type { ChartData } from './types/charts';
|
|
270
271
|
export type { AddInlineAttributeEvent, DeleteInlineAttributeEvent, EditInlineAttributeEvent, IgnoreInlineAttributeEvent, PinInlineAttributeEvent } from './types/inlineAttributes';
|
|
271
|
-
export type { ColumnData, ColumnFilter, Sorting, GroupedColumnsData, GroupedColumns, RenderRowCellProps, RowId, ElementsRowsData, TableRowsData, RowValue } from './types/basicTable';
|
|
272
|
+
export type { ColumnData, ColumnSize, ColumnFilter, Sorting, GroupedColumnsData, GroupedColumns, RenderRowCellProps, RowId, ElementsRowsData, TableRowsData, RowValue } from './types/basicTable';
|
|
273
|
+
export * from './types/preferences';
|
|
272
274
|
export * from './types';
|
|
273
275
|
export * from './constants';
|
|
274
276
|
export { TestPerspectivesSettingsProvider } from './test-utils/TestPerspectiveSettingsProvider';
|
package/cjs/index.js
CHANGED
|
@@ -19,8 +19,8 @@ exports.ErrorMessage = exports.ConfigureColumnsPopup = exports.ConnectionEditor
|
|
|
19
19
|
exports.PotentialMatchReviewCard = exports.PopupWithArrow = exports.Popper = exports.MultipleInput = exports.ModeSwitcherSelect = exports.ModeSwitcher = exports.TransitiveMatchBlock = exports.SimpleMatchRulesBuilder = exports.SimpleMatchRulesBlock = exports.SimpleMatchRules = exports.MatchRulesBlock = exports.LoadingSpinner = exports.Link = exports.LinearLoadIndicator = exports.ImportButton = exports.ReadableSearchQuery = exports.LogicOperator = exports.TableSkeleton = exports.StepNavigation = exports.TenantLabel = exports.RelevanceScoreBadge = exports.RequiredMark = exports.SettingsMenu = exports.TenantsDropDownSelector = exports.TenantIcon = exports.SourceSystemsSelector = exports.MatchRulesSelector = exports.MultiValueSelector = exports.ProfilesList = exports.NotMatchButton = exports.MergeButton = exports.ProfileMatchCard = exports.ImageGalleryDialog = exports.RelationTypesSelector = exports.ScreenProfileBand = exports.ProfileBandNavigation = exports.EmptyStub = exports.SaveSegmentDialog = exports.MaskingSwitcher = exports.FileTypeEditor = exports.EmptySearchResult = exports.DropDownEditor = exports.FilterValueEditor = exports.MultiValueChip = exports.TextEditor = exports.DateRangeEditor = exports.NumberEditor = exports.DataTypeValueEditor = exports.DateEditor = exports.ErrorWrapper = void 0;
|
|
20
20
|
exports.PivotingAttributeContext = exports.UsersContext = exports.InitialCollaborationContextValue = exports.CollaborationContextProvider = exports.CollaborationContext = exports.BlockImageGalleryDialogContext = exports.PopupBoundariesContext = exports.HistoryDiffContext = exports.AsyncMountContext = exports.MdmModuleProvider = exports.withTableContext = exports.withFilterAtBottom = exports.withPercents = exports.withContext = exports.withDateRangeSelector = exports.withDragHandle = exports.withAsyncMount = exports.withTooltip = exports.GaugeChart = exports.RelationEditor = exports.ReltioMap = exports.Marginator = exports.LightArrowTooltip = exports.ScrollableTabs = exports.VirtualGroupedList = exports.ViewMoreToggle = exports.VerticalHeadingsTable = exports.VerticalDivider = exports.AttributeTitle = exports.Spacer = exports.SimpleDropDownSelector = exports.SidePanelContentHeader = exports.SidePanel = exports.SidePanelEmptyState = exports.SideButtonsPanel = exports.SelectorWithOnlyOptionAutoSelect = exports.SelectionPopup = exports.WhiteSearchInput = exports.SearchInput = exports.ProfileResizablePanes = exports.ResizablePanes = exports.ReltioGridLayout = exports.RCTree = exports.reactSortableTreeHelpers = exports.ReactSortableTree = exports.MultiSelect = exports.QueryBuilderRowsGroup = exports.QueryBuilderRow = exports.ProfileCard = exports.ProfileBand = void 0;
|
|
21
21
|
exports.BasicTableRowCollapseContext = exports.useUnmaskedAttributeValue = exports.useUnmaskAttributeValue = exports.useMaskAttributeValue = exports.MaskedAttributesProvider = exports.SegmentationContext = exports.useReloadData = exports.ReloadDataProvider = exports.useAttributeValueConfigPermissions = exports.ConfigPermissionsContextProvider = exports.ConfigPermissionsContext = exports.useActionsHook = exports.ActionsHookProvider = exports.PageRequestsAbortingContext = exports.DependentLookupAutopopulationContext = exports.FeaturesContext = exports.LabelsContext = exports.UrlGeneratorsContext = exports.isHighlightedAttributeType = exports.isHighlightedErrorType = exports.ScrollType = exports.ScrollToElementProvider = exports.ScrollToElementContext = exports.SearchValueContext = exports.InterceptHandlersContext = exports.HighlightedValuesContext = exports.SnackbarContext = exports.SearchFiltersContext = exports.useReloadFacet = exports.ReloadFacetProvider = exports.useReloadAllFacets = exports.SandboxAPIContext = exports.EntityContext = exports.RelatedObjectUrisContext = exports.WorkflowTasksContext = exports.useEntityLoadingIndication = exports.EntityLoadingIndicationProvider = exports.EntityMarkerContext = exports.useAttributeExpanded = exports.ExpandedAttributesProvider = exports.useHighlightedCrosswalks = exports.useCrosswalkHighlight = exports.useCrosswalkFocus = exports.useCrosswalkColor = exports.CrosswalksDisplayProvider = exports.EntitiesMapContext = exports.IdContext = exports.ProfilePerspectiveViewContext = exports.usePerspectivesSettings = exports.PerspectivesSettingsContext = void 0;
|
|
22
|
-
exports.
|
|
23
|
-
exports.FakeMouseEvent = exports.rerenderWrapper = exports.mockElementSizes = exports.fixClicksOnResizablePanes = exports.mockBasicTableSizing = exports.getMuiIconsByName = exports.getMuiIconByName = exports.delayPromise = exports.deepFreeze = exports.awaitMockPromises = exports.TestStylesProvider = exports.TestPerspectivesSettingsProvider = exports.mergeClasses = exports.isControlOrCommandPressed = void 0;
|
|
22
|
+
exports.showErrorMessage = exports.showDefaultErrorMessage = exports.enrichDataWithPercents = exports.defaultRenderRowCell = exports.defaultGetRowCellHeight = exports.columnFilterToMdmFilter = exports.buildColumnsSizeById = exports.buildColumnsFilter = exports.useMaskedAttribute = exports.useKeyboardNavigation = exports.useDynamicRowCellHeight = exports.useClickableStyle = exports.BasicTableCellRenderer = exports.useBasicTableCellRenderer = exports.useHiddenAttributes = exports.useSavedSearchesRequest = exports.useRequestDCRReview = exports.useAutoFocus = exports.useExpandInvalidRelations = exports.useLayoutResetter = exports.useIsMountedRef = exports.useSnackbar = exports.useSavedStateForEntityType = exports.useReadableSearchState = exports.useEditableConnection = exports.useCustomScripts = exports.useMarkAsNotMatchRequest = exports.useMergeAllRequest = exports.usePagingSimulator = exports.useMatchesLoader = exports.useConfigPermissions = exports.useWhyDidYouUpdate = exports.useUsers = exports.useSavedState = exports.useSafePromise = exports.useRunOnceAfterValueInitialization = exports.useRelationsLoader = exports.useRelationTypeSelector = exports.usePrevious = exports.useDidUpdateEffect = exports.useCommentsEntitiesMap = exports.useCollaboration = exports.useAsyncMount = exports.useAPI = exports.useActions = exports.useMatchesColumnsData = exports.useScrollToAttributeError = exports.ProfileTablesContext = exports.HiddenAttributesContext = exports.BasicTableContext = void 0;
|
|
23
|
+
exports.FakeMouseEvent = exports.rerenderWrapper = exports.mockElementSizes = exports.fixClicksOnResizablePanes = exports.mockBasicTableSizing = exports.getMuiIconsByName = exports.getMuiIconByName = exports.delayPromise = exports.deepFreeze = exports.awaitMockPromises = exports.TestStylesProvider = exports.TestPerspectivesSettingsProvider = exports.mergeClasses = exports.isControlOrCommandPressed = exports.getValue = exports.getChecked = void 0;
|
|
24
24
|
// components
|
|
25
25
|
var ActionButton_1 = require("./ActionButton");
|
|
26
26
|
Object.defineProperty(exports, "ActionButton", { enumerable: true, get: function () { return ActionButton_1.ActionButton; } });
|
|
@@ -500,6 +500,8 @@ var BasicTableContext_1 = require("./contexts/BasicTableContext");
|
|
|
500
500
|
Object.defineProperty(exports, "BasicTableContext", { enumerable: true, get: function () { return BasicTableContext_1.BasicTableContext; } });
|
|
501
501
|
var HiddenAttributesContext_1 = require("./contexts/HiddenAttributesContext");
|
|
502
502
|
Object.defineProperty(exports, "HiddenAttributesContext", { enumerable: true, get: function () { return HiddenAttributesContext_1.HiddenAttributesContext; } });
|
|
503
|
+
var ProfileTablesContext_1 = require("./contexts/ProfileTablesContext");
|
|
504
|
+
Object.defineProperty(exports, "ProfileTablesContext", { enumerable: true, get: function () { return ProfileTablesContext_1.ProfileTablesContext; } });
|
|
503
505
|
// hooks
|
|
504
506
|
var useScrollToAttributeError_1 = require("./hooks/useScrollToAttributeError");
|
|
505
507
|
Object.defineProperty(exports, "useScrollToAttributeError", { enumerable: true, get: function () { return useScrollToAttributeError_1.useScrollToAttributeError; } });
|
|
@@ -581,6 +583,7 @@ Object.defineProperty(exports, "useMaskedAttribute", { enumerable: true, get: fu
|
|
|
581
583
|
// helpers
|
|
582
584
|
var basicTable_1 = require("./helpers/basicTable");
|
|
583
585
|
Object.defineProperty(exports, "buildColumnsFilter", { enumerable: true, get: function () { return basicTable_1.buildColumnsFilter; } });
|
|
586
|
+
Object.defineProperty(exports, "buildColumnsSizeById", { enumerable: true, get: function () { return basicTable_1.buildColumnsSizeById; } });
|
|
584
587
|
Object.defineProperty(exports, "columnFilterToMdmFilter", { enumerable: true, get: function () { return basicTable_1.columnFilterToMdmFilter; } });
|
|
585
588
|
Object.defineProperty(exports, "defaultGetRowCellHeight", { enumerable: true, get: function () { return basicTable_1.defaultGetRowCellHeight; } });
|
|
586
589
|
Object.defineProperty(exports, "defaultRenderRowCell", { enumerable: true, get: function () { return basicTable_1.defaultRenderRowCell; } });
|
|
@@ -595,6 +598,7 @@ Object.defineProperty(exports, "getValue", { enumerable: true, get: function ()
|
|
|
595
598
|
Object.defineProperty(exports, "isControlOrCommandPressed", { enumerable: true, get: function () { return events_1.isControlOrCommandPressed; } });
|
|
596
599
|
var classes_1 = require("./helpers/classes");
|
|
597
600
|
Object.defineProperty(exports, "mergeClasses", { enumerable: true, get: function () { return classes_1.mergeClasses; } });
|
|
601
|
+
__exportStar(require("./types/preferences"), exports);
|
|
598
602
|
__exportStar(require("./types"), exports);
|
|
599
603
|
// constants
|
|
600
604
|
__exportStar(require("./constants"), exports);
|
package/cjs/test-utils/index.js
CHANGED
|
@@ -131,7 +131,7 @@ var mockElementSizes = function (element, defaults) {
|
|
|
131
131
|
};
|
|
132
132
|
exports.mockElementSizes = mockElementSizes;
|
|
133
133
|
var mockBasicTableSizing = function (_a) {
|
|
134
|
-
var _b = _a === void 0 ? {} : _a, _c = _b.width, width = _c === void 0 ?
|
|
134
|
+
var _b = _a === void 0 ? {} : _a, _c = _b.width, width = _c === void 0 ? 2100 : _c, _d = _b.height, height = _d === void 0 ? 1000 : _d;
|
|
135
135
|
var _e = (0, exports.mockElementSizes)(window.HTMLElement.prototype, { offsetHeight: height, offsetWidth: width }), mock = _e.mock, unmock = _e.unmock;
|
|
136
136
|
mock();
|
|
137
137
|
return unmock;
|
|
@@ -33,6 +33,11 @@ export type ColumnData = {
|
|
|
33
33
|
filterOptions?: ColumnFilterOptions;
|
|
34
34
|
[key: string]: unknown;
|
|
35
35
|
};
|
|
36
|
+
export type ColumnSize = {
|
|
37
|
+
id: string;
|
|
38
|
+
size: number;
|
|
39
|
+
manuallyChanged?: boolean;
|
|
40
|
+
};
|
|
36
41
|
export type GroupedColumns<TColumnData = ColumnData> = {
|
|
37
42
|
id: string;
|
|
38
43
|
label: string;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { BaseProfileViewConfig } from '@reltio/mdm-sdk';
|
|
2
|
+
import { ColumnData, ColumnSize } from './basicTable';
|
|
3
|
+
export type ColumnsSizeById = Record<ColumnSize['id'], ColumnSize['size']>;
|
|
4
|
+
export type TablePreferences = {
|
|
5
|
+
visibleColumns?: ColumnData['id'][];
|
|
6
|
+
columnsSizeById?: ColumnsSizeById;
|
|
7
|
+
};
|
|
8
|
+
export type ProfileTablesPreferences = Record<BaseProfileViewConfig['id'], TablePreferences>;
|
|
@@ -1,34 +1,82 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { createStandardAction } from '@reltio/mdm-sdk';
|
|
2
|
+
import { ColumnData, ColumnFilter, ColumnSize, Sorting } from '../types/basicTable';
|
|
3
|
+
export declare enum ActionTypes {
|
|
4
|
+
CHANGE_COLUMNS = "CHANGE_COLUMNS",
|
|
5
|
+
TOGGLE_FILTERS = "TOGGLE_FILTERS",
|
|
6
|
+
CHANGE_FILTER = "CHANGE_FILTER",
|
|
7
|
+
TOGGLE_SORT = "TOGGLE_SORT",
|
|
8
|
+
CHANGE_PAGE = "CHANGE_PAGE",
|
|
9
|
+
CHANGE_ROWS_PER_PAGE = "CHANGE_ROWS_PER_PAGE"
|
|
10
|
+
}
|
|
11
|
+
export type BasicTableState = {
|
|
12
|
+
visibleColumns: ColumnData['id'][];
|
|
13
|
+
columnsSize?: ColumnSize[];
|
|
14
|
+
filters?: Record<ColumnData['id'], ColumnFilter>;
|
|
15
|
+
sorting?: Sorting;
|
|
16
|
+
page: number;
|
|
17
|
+
rowsPerPage: number;
|
|
18
|
+
rowsPerPageOptions?: number[];
|
|
19
|
+
[key: string]: unknown;
|
|
20
|
+
};
|
|
21
|
+
export type BasicTableAction = ReturnType<ReturnType<typeof createStandardAction>>;
|
|
22
|
+
export type BasicTableReducer = <TableState extends BasicTableState, TableAction extends BasicTableAction>(state: TableState, action: TableAction) => TableState;
|
|
23
|
+
export declare const actions: {
|
|
24
|
+
changeColumns: (payload: any) => {
|
|
3
25
|
type: any;
|
|
4
26
|
payload: any;
|
|
5
27
|
};
|
|
6
|
-
|
|
28
|
+
toggleFilters: (payload: any) => {
|
|
7
29
|
type: any;
|
|
8
30
|
payload: any;
|
|
9
31
|
};
|
|
10
|
-
|
|
32
|
+
changeFilter: (payload: any) => {
|
|
11
33
|
type: any;
|
|
12
34
|
payload: any;
|
|
13
35
|
};
|
|
14
|
-
|
|
36
|
+
toggleSort: (payload: any) => {
|
|
15
37
|
type: any;
|
|
16
38
|
payload: any;
|
|
17
39
|
};
|
|
18
|
-
|
|
40
|
+
changePage: (payload: any) => {
|
|
19
41
|
type: any;
|
|
20
42
|
payload: any;
|
|
21
43
|
};
|
|
22
|
-
|
|
44
|
+
changeRowsPerPage: (payload: any) => {
|
|
23
45
|
type: any;
|
|
24
46
|
payload: any;
|
|
25
47
|
};
|
|
26
|
-
}
|
|
27
|
-
export
|
|
28
|
-
export
|
|
29
|
-
declare
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
48
|
+
};
|
|
49
|
+
export declare const changeVisibleColumns: (state: BasicTableState, nextVisibleColumns?: BasicTableState['visibleColumns']) => any;
|
|
50
|
+
export declare const reducer: BasicTableReducer;
|
|
51
|
+
declare const _default: {
|
|
52
|
+
reducer: BasicTableReducer;
|
|
53
|
+
actions: {
|
|
54
|
+
changeColumns: (payload: any) => {
|
|
55
|
+
type: any;
|
|
56
|
+
payload: any;
|
|
57
|
+
};
|
|
58
|
+
toggleFilters: (payload: any) => {
|
|
59
|
+
type: any;
|
|
60
|
+
payload: any;
|
|
61
|
+
};
|
|
62
|
+
changeFilter: (payload: any) => {
|
|
63
|
+
type: any;
|
|
64
|
+
payload: any;
|
|
65
|
+
};
|
|
66
|
+
toggleSort: (payload: any) => {
|
|
67
|
+
type: any;
|
|
68
|
+
payload: any;
|
|
69
|
+
};
|
|
70
|
+
changePage: (payload: any) => {
|
|
71
|
+
type: any;
|
|
72
|
+
payload: any;
|
|
73
|
+
};
|
|
74
|
+
changeRowsPerPage: (payload: any) => {
|
|
75
|
+
type: any;
|
|
76
|
+
payload: any;
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
ActionTypes: typeof ActionTypes;
|
|
80
|
+
changeVisibleColumns: (state: BasicTableState, nextVisibleColumns?: string[]) => any;
|
|
81
|
+
};
|
|
34
82
|
export default _default;
|
|
@@ -11,25 +11,39 @@ var __assign = (this && this.__assign) || function () {
|
|
|
11
11
|
};
|
|
12
12
|
import { toggleSortOrder, createStandardAction } from '@reltio/mdm-sdk';
|
|
13
13
|
import { always, assoc, difference, dissoc, evolve, keys, path, when } from 'ramda';
|
|
14
|
-
var
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
export var ActionTypes;
|
|
15
|
+
(function (ActionTypes) {
|
|
16
|
+
ActionTypes["CHANGE_COLUMNS"] = "CHANGE_COLUMNS";
|
|
17
|
+
ActionTypes["TOGGLE_FILTERS"] = "TOGGLE_FILTERS";
|
|
18
|
+
ActionTypes["CHANGE_FILTER"] = "CHANGE_FILTER";
|
|
19
|
+
ActionTypes["TOGGLE_SORT"] = "TOGGLE_SORT";
|
|
20
|
+
ActionTypes["CHANGE_PAGE"] = "CHANGE_PAGE";
|
|
21
|
+
ActionTypes["CHANGE_ROWS_PER_PAGE"] = "CHANGE_ROWS_PER_PAGE";
|
|
22
|
+
})(ActionTypes || (ActionTypes = {}));
|
|
20
23
|
export var actions = {
|
|
21
|
-
changeColumns: createStandardAction(CHANGE_COLUMNS),
|
|
22
|
-
toggleFilters: createStandardAction(TOGGLE_FILTERS),
|
|
23
|
-
changeFilter: createStandardAction(CHANGE_FILTER),
|
|
24
|
-
toggleSort: createStandardAction(TOGGLE_SORT),
|
|
25
|
-
changePage: createStandardAction(CHANGE_PAGE),
|
|
26
|
-
changeRowsPerPage: createStandardAction(CHANGE_ROWS_PER_PAGE)
|
|
24
|
+
changeColumns: createStandardAction(ActionTypes.CHANGE_COLUMNS),
|
|
25
|
+
toggleFilters: createStandardAction(ActionTypes.TOGGLE_FILTERS),
|
|
26
|
+
changeFilter: createStandardAction(ActionTypes.CHANGE_FILTER),
|
|
27
|
+
toggleSort: createStandardAction(ActionTypes.TOGGLE_SORT),
|
|
28
|
+
changePage: createStandardAction(ActionTypes.CHANGE_PAGE),
|
|
29
|
+
changeRowsPerPage: createStandardAction(ActionTypes.CHANGE_ROWS_PER_PAGE)
|
|
27
30
|
};
|
|
28
31
|
export var changeVisibleColumns = function (state, nextVisibleColumns) {
|
|
32
|
+
if (nextVisibleColumns === void 0) { nextVisibleColumns = []; }
|
|
29
33
|
var removedColumns = difference(state.visibleColumns, nextVisibleColumns);
|
|
30
34
|
var isRemovedColumn = function (columnId) { return removedColumns.includes(columnId); };
|
|
31
35
|
return evolve({
|
|
32
36
|
visibleColumns: always(nextVisibleColumns),
|
|
37
|
+
columnsSize: function (columnsSize) {
|
|
38
|
+
if (columnsSize === void 0) { columnsSize = []; }
|
|
39
|
+
return nextVisibleColumns.map(function (columnId) {
|
|
40
|
+
var columnSize = columnsSize.find(function (_a) {
|
|
41
|
+
var id = _a.id;
|
|
42
|
+
return id === columnId;
|
|
43
|
+
});
|
|
44
|
+
return __assign({ id: columnId, size: (columnSize === null || columnSize === void 0 ? void 0 : columnSize.manuallyChanged) ? columnSize.size : 0 }, ((columnSize === null || columnSize === void 0 ? void 0 : columnSize.manuallyChanged) ? { manuallyChanged: true } : {}));
|
|
45
|
+
});
|
|
46
|
+
},
|
|
33
47
|
sorting: when(function (sorting) {
|
|
34
48
|
if (sorting === void 0) { sorting = {}; }
|
|
35
49
|
return isRemovedColumn(sorting.field);
|
|
@@ -38,25 +52,28 @@ export var changeVisibleColumns = function (state, nextVisibleColumns) {
|
|
|
38
52
|
return { field: nextSortField, order: 'asc' };
|
|
39
53
|
}),
|
|
40
54
|
filters: function (filters) {
|
|
41
|
-
|
|
55
|
+
if (filters === void 0) { filters = {}; }
|
|
56
|
+
return keys(filters).reduce(function (acc, columnId) {
|
|
57
|
+
return isRemovedColumn(columnId) ? dissoc(columnId, acc) : acc;
|
|
58
|
+
}, filters);
|
|
42
59
|
}
|
|
43
60
|
}, state);
|
|
44
61
|
};
|
|
45
62
|
export var reducer = function (state, action) {
|
|
46
63
|
switch (action.type) {
|
|
47
|
-
case CHANGE_COLUMNS: {
|
|
64
|
+
case ActionTypes.CHANGE_COLUMNS: {
|
|
48
65
|
var columnIds = action.payload;
|
|
49
66
|
return changeVisibleColumns(state, columnIds);
|
|
50
67
|
}
|
|
51
|
-
case TOGGLE_FILTERS: {
|
|
68
|
+
case ActionTypes.TOGGLE_FILTERS: {
|
|
52
69
|
var enableFilters = !state.filters;
|
|
53
70
|
return __assign(__assign({}, state), { filters: enableFilters ? {} : null, page: enableFilters ? state.page : 0 });
|
|
54
71
|
}
|
|
55
|
-
case CHANGE_FILTER: {
|
|
72
|
+
case ActionTypes.CHANGE_FILTER: {
|
|
56
73
|
var _a = action.payload, columnId = _a.columnId, filter = _a.filter;
|
|
57
74
|
return evolve({ filters: filter ? assoc(columnId, filter) : dissoc(columnId), page: always(0) }, state);
|
|
58
75
|
}
|
|
59
|
-
case TOGGLE_SORT: {
|
|
76
|
+
case ActionTypes.TOGGLE_SORT: {
|
|
60
77
|
var nextSortField = action.payload;
|
|
61
78
|
var prevSortField = path(['sorting', 'field'], state);
|
|
62
79
|
var prevSortOrder = path(['sorting', 'order'], state);
|
|
@@ -65,9 +82,9 @@ export var reducer = function (state, action) {
|
|
|
65
82
|
order: toggleSortOrder(nextSortField === prevSortField ? prevSortOrder : null)
|
|
66
83
|
}, page: 0 });
|
|
67
84
|
}
|
|
68
|
-
case CHANGE_PAGE:
|
|
85
|
+
case ActionTypes.CHANGE_PAGE:
|
|
69
86
|
return __assign(__assign({}, state), { page: action.payload });
|
|
70
|
-
case CHANGE_ROWS_PER_PAGE:
|
|
87
|
+
case ActionTypes.CHANGE_ROWS_PER_PAGE:
|
|
71
88
|
return __assign(__assign({}, state), { rowsPerPage: action.payload });
|
|
72
89
|
default:
|
|
73
90
|
return state;
|
|
@@ -76,5 +93,6 @@ export var reducer = function (state, action) {
|
|
|
76
93
|
export default {
|
|
77
94
|
reducer: reducer,
|
|
78
95
|
actions: actions,
|
|
96
|
+
ActionTypes: ActionTypes,
|
|
79
97
|
changeVisibleColumns: changeVisibleColumns
|
|
80
98
|
};
|
|
@@ -11,6 +11,26 @@ describe('basicTableViewState tests', function () {
|
|
|
11
11
|
};
|
|
12
12
|
expect(changeVisibleColumns(prevState, visibleColumns)).toEqual(nextState);
|
|
13
13
|
});
|
|
14
|
+
it('should update columns size on changing visible columns', function () {
|
|
15
|
+
var prevState = {
|
|
16
|
+
visibleColumns: ['column1', 'column2', 'column3', 'column4'],
|
|
17
|
+
columnsSize: [
|
|
18
|
+
{ id: 'column1', size: 100, manuallyChanged: true },
|
|
19
|
+
{ id: 'column2', size: 200 },
|
|
20
|
+
{ id: 'column3', size: 300, manuallyChanged: true },
|
|
21
|
+
{ id: 'column4', size: 400 }
|
|
22
|
+
]
|
|
23
|
+
};
|
|
24
|
+
var visibleColumns = ['column1', 'column4'];
|
|
25
|
+
var nextState = {
|
|
26
|
+
visibleColumns: visibleColumns,
|
|
27
|
+
columnsSize: [
|
|
28
|
+
{ id: 'column1', size: 100, manuallyChanged: true },
|
|
29
|
+
{ id: 'column4', size: 0 }
|
|
30
|
+
]
|
|
31
|
+
};
|
|
32
|
+
expect(changeVisibleColumns(prevState, visibleColumns)).toEqual(nextState);
|
|
33
|
+
});
|
|
14
34
|
it('should remove filters for columns that are no longer visible', function () {
|
|
15
35
|
var prevState = {
|
|
16
36
|
visibleColumns: ['column1', 'column2'],
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ProfileTablesPreferences } from '../../types/preferences';
|
|
3
|
+
export declare const ProfileTablesContext: import("react").Context<{
|
|
4
|
+
profileTablesPreferences: ProfileTablesPreferences;
|
|
5
|
+
setProfileTablesPreferences: (profileTablesPreferences: ProfileTablesPreferences) => void;
|
|
6
|
+
}>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { FacetFilter } from '@reltio/mdm-sdk';
|
|
2
|
-
import { ColumnData, ColumnFilter } from '../types/basicTable';
|
|
2
|
+
import { ColumnData, ColumnFilter, ColumnSize } from '../types/basicTable';
|
|
3
|
+
import { ColumnsSizeById } from '../types/preferences';
|
|
3
4
|
export declare const defaultGetRowCellHeight: ({ columnData, cell }: {
|
|
4
5
|
columnData: any;
|
|
5
6
|
cell: any;
|
|
@@ -11,3 +12,4 @@ export declare const defaultRenderRowCell: ({ cell, CellValueRenderer, ...otherP
|
|
|
11
12
|
}) => any;
|
|
12
13
|
export declare const columnFilterToMdmFilter: (columnData: Pick<ColumnData, 'id' | 'dataTypeDefinition'>, columnFilter?: ColumnFilter) => FacetFilter;
|
|
13
14
|
export declare const buildColumnsFilter: (columnsData: ColumnData[], filters?: Record<string, ColumnFilter>) => string;
|
|
15
|
+
export declare const buildColumnsSizeById: (columnsSize?: ColumnSize[]) => ColumnsSizeById;
|
|
@@ -66,3 +66,13 @@ export var buildColumnsFilter = function (columnsData, filters) {
|
|
|
66
66
|
.map(buildFilterQueryString())
|
|
67
67
|
.orSome('');
|
|
68
68
|
};
|
|
69
|
+
export var buildColumnsSizeById = function (columnsSize) {
|
|
70
|
+
if (columnsSize === void 0) { columnsSize = []; }
|
|
71
|
+
return columnsSize.reduce(function (columnsSizeById, _a) {
|
|
72
|
+
var id = _a.id, size = _a.size, manuallyChanged = _a.manuallyChanged;
|
|
73
|
+
if (manuallyChanged) {
|
|
74
|
+
columnsSizeById[id] = size;
|
|
75
|
+
}
|
|
76
|
+
return columnsSizeById;
|
|
77
|
+
}, {});
|
|
78
|
+
};
|
package/esm/index.d.ts
CHANGED
|
@@ -222,6 +222,7 @@ export { MaskedAttributesProvider, useMaskAttributeValue, useUnmaskAttributeValu
|
|
|
222
222
|
export { RowCollapseContext as BasicTableRowCollapseContext } from './contexts/RowCollapseContext';
|
|
223
223
|
export { BasicTableContext } from './contexts/BasicTableContext';
|
|
224
224
|
export { HiddenAttributesContext } from './contexts/HiddenAttributesContext';
|
|
225
|
+
export { ProfileTablesContext } from './contexts/ProfileTablesContext';
|
|
225
226
|
export { useScrollToAttributeError } from './hooks/useScrollToAttributeError';
|
|
226
227
|
export { useMatchesColumnsData } from './hooks/useMatchesColumnsData';
|
|
227
228
|
export { useActions } from './hooks/useActions';
|
|
@@ -260,7 +261,7 @@ export { useClickableChartStyle as useClickableStyle } from './hooks/useClickabl
|
|
|
260
261
|
export { useDynamicRowCellHeight } from './hooks/useDynamicRowCellHeight';
|
|
261
262
|
export { useKeyboardNavigation } from './hooks/useKeyboardNavigation';
|
|
262
263
|
export { useMaskedAttribute } from './hooks/useMaskedAttribute';
|
|
263
|
-
export { buildColumnsFilter, columnFilterToMdmFilter, defaultGetRowCellHeight, defaultRenderRowCell } from './helpers/basicTable';
|
|
264
|
+
export { buildColumnsFilter, buildColumnsSizeById, columnFilterToMdmFilter, defaultGetRowCellHeight, defaultRenderRowCell } from './helpers/basicTable';
|
|
264
265
|
export { enrichDataWithPercents } from './helpers/charts';
|
|
265
266
|
export { showDefaultErrorMessage, showErrorMessage } from './helpers/errors';
|
|
266
267
|
export { getChecked, getValue, isControlOrCommandPressed } from './helpers/events';
|
|
@@ -268,7 +269,8 @@ export { mergeClasses } from './helpers/classes';
|
|
|
268
269
|
export type { AttributeFiltersComponentProps } from './AttributesFiltersBuilder';
|
|
269
270
|
export type { ChartData } from './types/charts';
|
|
270
271
|
export type { AddInlineAttributeEvent, DeleteInlineAttributeEvent, EditInlineAttributeEvent, IgnoreInlineAttributeEvent, PinInlineAttributeEvent } from './types/inlineAttributes';
|
|
271
|
-
export type { ColumnData, ColumnFilter, Sorting, GroupedColumnsData, GroupedColumns, RenderRowCellProps, RowId, ElementsRowsData, TableRowsData, RowValue } from './types/basicTable';
|
|
272
|
+
export type { ColumnData, ColumnSize, ColumnFilter, Sorting, GroupedColumnsData, GroupedColumns, RenderRowCellProps, RowId, ElementsRowsData, TableRowsData, RowValue } from './types/basicTable';
|
|
273
|
+
export * from './types/preferences';
|
|
272
274
|
export * from './types';
|
|
273
275
|
export * from './constants';
|
|
274
276
|
export { TestPerspectivesSettingsProvider } from './test-utils/TestPerspectiveSettingsProvider';
|
package/esm/index.js
CHANGED
|
@@ -225,6 +225,7 @@ export { MaskedAttributesProvider, useMaskAttributeValue, useUnmaskAttributeValu
|
|
|
225
225
|
export { RowCollapseContext as BasicTableRowCollapseContext } from './contexts/RowCollapseContext';
|
|
226
226
|
export { BasicTableContext } from './contexts/BasicTableContext';
|
|
227
227
|
export { HiddenAttributesContext } from './contexts/HiddenAttributesContext';
|
|
228
|
+
export { ProfileTablesContext } from './contexts/ProfileTablesContext';
|
|
228
229
|
// hooks
|
|
229
230
|
export { useScrollToAttributeError } from './hooks/useScrollToAttributeError';
|
|
230
231
|
export { useMatchesColumnsData } from './hooks/useMatchesColumnsData';
|
|
@@ -265,11 +266,12 @@ export { useDynamicRowCellHeight } from './hooks/useDynamicRowCellHeight';
|
|
|
265
266
|
export { useKeyboardNavigation } from './hooks/useKeyboardNavigation';
|
|
266
267
|
export { useMaskedAttribute } from './hooks/useMaskedAttribute';
|
|
267
268
|
// helpers
|
|
268
|
-
export { buildColumnsFilter, columnFilterToMdmFilter, defaultGetRowCellHeight, defaultRenderRowCell } from './helpers/basicTable';
|
|
269
|
+
export { buildColumnsFilter, buildColumnsSizeById, columnFilterToMdmFilter, defaultGetRowCellHeight, defaultRenderRowCell } from './helpers/basicTable';
|
|
269
270
|
export { enrichDataWithPercents } from './helpers/charts';
|
|
270
271
|
export { showDefaultErrorMessage, showErrorMessage } from './helpers/errors';
|
|
271
272
|
export { getChecked, getValue, isControlOrCommandPressed } from './helpers/events';
|
|
272
273
|
export { mergeClasses } from './helpers/classes';
|
|
274
|
+
export * from './types/preferences';
|
|
273
275
|
export * from './types';
|
|
274
276
|
// constants
|
|
275
277
|
export * from './constants';
|
package/esm/test-utils/index.js
CHANGED
|
@@ -123,7 +123,7 @@ export var mockElementSizes = function (element, defaults) {
|
|
|
123
123
|
return { mock: mock, unmock: unmock };
|
|
124
124
|
};
|
|
125
125
|
export var mockBasicTableSizing = function (_a) {
|
|
126
|
-
var _b = _a === void 0 ? {} : _a, _c = _b.width, width = _c === void 0 ?
|
|
126
|
+
var _b = _a === void 0 ? {} : _a, _c = _b.width, width = _c === void 0 ? 2100 : _c, _d = _b.height, height = _d === void 0 ? 1000 : _d;
|
|
127
127
|
var _e = mockElementSizes(window.HTMLElement.prototype, { offsetHeight: height, offsetWidth: width }), mock = _e.mock, unmock = _e.unmock;
|
|
128
128
|
mock();
|
|
129
129
|
return unmock;
|
|
@@ -33,6 +33,11 @@ export type ColumnData = {
|
|
|
33
33
|
filterOptions?: ColumnFilterOptions;
|
|
34
34
|
[key: string]: unknown;
|
|
35
35
|
};
|
|
36
|
+
export type ColumnSize = {
|
|
37
|
+
id: string;
|
|
38
|
+
size: number;
|
|
39
|
+
manuallyChanged?: boolean;
|
|
40
|
+
};
|
|
36
41
|
export type GroupedColumns<TColumnData = ColumnData> = {
|
|
37
42
|
id: string;
|
|
38
43
|
label: string;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { BaseProfileViewConfig } from '@reltio/mdm-sdk';
|
|
2
|
+
import { ColumnData, ColumnSize } from './basicTable';
|
|
3
|
+
export type ColumnsSizeById = Record<ColumnSize['id'], ColumnSize['size']>;
|
|
4
|
+
export type TablePreferences = {
|
|
5
|
+
visibleColumns?: ColumnData['id'][];
|
|
6
|
+
columnsSizeById?: ColumnsSizeById;
|
|
7
|
+
};
|
|
8
|
+
export type ProfileTablesPreferences = Record<BaseProfileViewConfig['id'], TablePreferences>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reltio/components",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.1929",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE FILE",
|
|
5
5
|
"main": "./cjs/index.js",
|
|
6
6
|
"module": "./esm/index.js",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"@fluentui/react-context-selector": "^9.1.26",
|
|
9
9
|
"@react-google-maps/api": "2.7.0",
|
|
10
10
|
"@react-sigma/core": "3.4.0",
|
|
11
|
-
"@reltio/mdm-sdk": "^1.4.
|
|
11
|
+
"@reltio/mdm-sdk": "^1.4.1845",
|
|
12
12
|
"classnames": "^2.2.5",
|
|
13
13
|
"d3-cloud": "^1.2.5",
|
|
14
14
|
"d3-geo": "^2.0.1",
|