@reltio/components 1.4.2066 → 1.4.2067
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.
|
@@ -67,13 +67,33 @@ var buildRowValues = function (rowValue) {
|
|
|
67
67
|
return (0, ramda_1.assoc)(id, getCellValues(nestedPath, rowValue[id]), acc);
|
|
68
68
|
}, {});
|
|
69
69
|
};
|
|
70
|
-
var
|
|
71
|
-
return
|
|
70
|
+
var areNestedValuesExceedingLimit = function (maxValuesCount) {
|
|
71
|
+
return function (_a) {
|
|
72
72
|
var indexPath = _a.indexPath;
|
|
73
73
|
return indexPath && indexPath.some(function (index) { return index > maxValuesCount - 1; });
|
|
74
|
-
}
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
var getAllRowHiddenValues = function (rowValues, maxValuesCount) {
|
|
77
|
+
if (maxValuesCount === void 0) { maxValuesCount = Infinity; }
|
|
78
|
+
return rowValues.reduce(function (hiddenValues, _a) {
|
|
79
|
+
var _b = _a.values, values = _b === void 0 ? [] : _b, indexPath = _a.indexPath;
|
|
80
|
+
var newHiddenValues = areNestedValuesExceedingLimit(maxValuesCount)({ indexPath: indexPath })
|
|
81
|
+
? values
|
|
82
|
+
: values.slice(maxValuesCount);
|
|
83
|
+
return hiddenValues.concat(newHiddenValues);
|
|
84
|
+
}, []);
|
|
85
|
+
};
|
|
86
|
+
var adjustFirstWithHiddenValues = function (maxValuesCount) {
|
|
87
|
+
if (maxValuesCount === void 0) { maxValuesCount = Infinity; }
|
|
88
|
+
return function (rowValues) {
|
|
89
|
+
var hiddenValues = getAllRowHiddenValues(rowValues, maxValuesCount);
|
|
90
|
+
return (0, ramda_1.adjust)(0, (0, ramda_1.assoc)('allRowHiddenValues', hiddenValues), rowValues);
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
var applyValuesCountConstraint = function (maxValuesCount) {
|
|
94
|
+
return (0, ramda_1.unless)(function () { return maxValuesCount === Infinity; }, (0, ramda_1.map)((0, ramda_1.pipe)(adjustFirstWithHiddenValues(maxValuesCount), (0, ramda_1.reject)(areNestedValuesExceedingLimit(maxValuesCount)), (0, ramda_1.map)((0, ramda_1.evolve)({
|
|
75
95
|
values: (0, ramda_1.slice)(0, maxValuesCount)
|
|
76
|
-
})))))
|
|
96
|
+
})))));
|
|
77
97
|
};
|
|
78
98
|
var defaultGetIdFromRowValue = function (_, rowIndex) { return rowIndex; };
|
|
79
99
|
var getTableRowsData = function (rowValues, columnsData, renderRowCell, getRowCellHeight, getRowMaxValuesCount, getIdFromRowValue) {
|
|
@@ -249,10 +249,51 @@ describe('dataHelpers', function () {
|
|
|
249
249
|
expect((0, dataHelpers_1.getTableRowsData)(rowValues, columnsData, renderRowCell, null, getRowMaxValuesCount)).toEqual([
|
|
250
250
|
{
|
|
251
251
|
data: {
|
|
252
|
-
'n1.a': [
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
252
|
+
'n1.a': [
|
|
253
|
+
{
|
|
254
|
+
allRowHiddenValues: [2, 3],
|
|
255
|
+
values: [1],
|
|
256
|
+
indexPath: [0],
|
|
257
|
+
nestedKey: 'n1.0',
|
|
258
|
+
rowSpan: 1
|
|
259
|
+
}
|
|
260
|
+
],
|
|
261
|
+
'n1.n2.b': [
|
|
262
|
+
{ values: [], allRowHiddenValues: [4, 5, 6], indexPath: [0], nestedKey: 'n1.0', rowSpan: 1 }
|
|
263
|
+
],
|
|
264
|
+
c: [{ allRowHiddenValues: [8, 9, 10], values: [7], rowSpan: 1 }],
|
|
265
|
+
'n1.d': [{ values: [], allRowHiddenValues: [], rowSpan: 1 }]
|
|
266
|
+
},
|
|
267
|
+
id: 0
|
|
268
|
+
}
|
|
269
|
+
]);
|
|
270
|
+
expect(getRowMaxValuesCount).toHaveBeenCalledWith(0);
|
|
271
|
+
});
|
|
272
|
+
it('should apply allRowHiddenValues correctly if maxValuesCount more than 1', function () {
|
|
273
|
+
var rowValues = [
|
|
274
|
+
{
|
|
275
|
+
'n1.n2.a': [[[1, 2]], [[3, 4, 5]]]
|
|
276
|
+
}
|
|
277
|
+
];
|
|
278
|
+
var columnsData = [{ id: 'n1.n2.a', nestedPath: ['n1', 'n2', 'a'], label: 'columnA' }];
|
|
279
|
+
var renderRowCell = function (_a) {
|
|
280
|
+
var cell = _a.cell;
|
|
281
|
+
return cell.values;
|
|
282
|
+
};
|
|
283
|
+
var getRowMaxValuesCount = jest.fn(function () { return 2; });
|
|
284
|
+
expect((0, dataHelpers_1.getTableRowsData)(rowValues, columnsData, renderRowCell, null, getRowMaxValuesCount)).toEqual([
|
|
285
|
+
{
|
|
286
|
+
data: {
|
|
287
|
+
'n1.n2.a': [
|
|
288
|
+
{
|
|
289
|
+
values: [1, 2],
|
|
290
|
+
allRowHiddenValues: [5],
|
|
291
|
+
indexPath: [0, 0],
|
|
292
|
+
nestedKey: 'n1.0.n2.0',
|
|
293
|
+
rowSpan: 1
|
|
294
|
+
},
|
|
295
|
+
{ values: [3, 4], indexPath: [1, 0], nestedKey: 'n1.1.n2.0', rowSpan: 1 }
|
|
296
|
+
]
|
|
256
297
|
},
|
|
257
298
|
id: 0
|
|
258
299
|
}
|
|
@@ -9,7 +9,7 @@ var __assign = (this && this.__assign) || function () {
|
|
|
9
9
|
};
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
|
-
import { add, always, assoc, chain, evolve, isEmpty, isNil, map, mapObjIndexed, max, pipe, pluck, propEq, propOr, reduce, reject, slice, uniq, unless, values } from 'ramda';
|
|
12
|
+
import { add, adjust, always, assoc, chain, evolve, isEmpty, isNil, map, mapObjIndexed, max, pipe, pluck, propEq, propOr, reduce, reject, slice, uniq, unless, values } from 'ramda';
|
|
13
13
|
import { wrapInArrayIfNeeded } from '@reltio/mdm-sdk';
|
|
14
14
|
import { DefaultCellValueRenderer } from '../../DefaultCellValueRenderer';
|
|
15
15
|
import { calcRowSpansForNestedKeys, flattenNestedColumnValues, getNestedKeyForNestedColumnCell, TOTAL_ROW_SPAN_KEY } from './nestedHelpers';
|
|
@@ -64,13 +64,33 @@ var buildRowValues = function (rowValue) {
|
|
|
64
64
|
return assoc(id, getCellValues(nestedPath, rowValue[id]), acc);
|
|
65
65
|
}, {});
|
|
66
66
|
};
|
|
67
|
-
var
|
|
68
|
-
return
|
|
67
|
+
var areNestedValuesExceedingLimit = function (maxValuesCount) {
|
|
68
|
+
return function (_a) {
|
|
69
69
|
var indexPath = _a.indexPath;
|
|
70
70
|
return indexPath && indexPath.some(function (index) { return index > maxValuesCount - 1; });
|
|
71
|
-
}
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
var getAllRowHiddenValues = function (rowValues, maxValuesCount) {
|
|
74
|
+
if (maxValuesCount === void 0) { maxValuesCount = Infinity; }
|
|
75
|
+
return rowValues.reduce(function (hiddenValues, _a) {
|
|
76
|
+
var _b = _a.values, values = _b === void 0 ? [] : _b, indexPath = _a.indexPath;
|
|
77
|
+
var newHiddenValues = areNestedValuesExceedingLimit(maxValuesCount)({ indexPath: indexPath })
|
|
78
|
+
? values
|
|
79
|
+
: values.slice(maxValuesCount);
|
|
80
|
+
return hiddenValues.concat(newHiddenValues);
|
|
81
|
+
}, []);
|
|
82
|
+
};
|
|
83
|
+
var adjustFirstWithHiddenValues = function (maxValuesCount) {
|
|
84
|
+
if (maxValuesCount === void 0) { maxValuesCount = Infinity; }
|
|
85
|
+
return function (rowValues) {
|
|
86
|
+
var hiddenValues = getAllRowHiddenValues(rowValues, maxValuesCount);
|
|
87
|
+
return adjust(0, assoc('allRowHiddenValues', hiddenValues), rowValues);
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
var applyValuesCountConstraint = function (maxValuesCount) {
|
|
91
|
+
return unless(function () { return maxValuesCount === Infinity; }, map(pipe(adjustFirstWithHiddenValues(maxValuesCount), reject(areNestedValuesExceedingLimit(maxValuesCount)), map(evolve({
|
|
72
92
|
values: slice(0, maxValuesCount)
|
|
73
|
-
})))))
|
|
93
|
+
})))));
|
|
74
94
|
};
|
|
75
95
|
var defaultGetIdFromRowValue = function (_, rowIndex) { return rowIndex; };
|
|
76
96
|
var getTableRowsData = function (rowValues, columnsData, renderRowCell, getRowCellHeight, getRowMaxValuesCount, getIdFromRowValue) {
|
|
@@ -244,10 +244,51 @@ describe('dataHelpers', function () {
|
|
|
244
244
|
expect(getTableRowsData(rowValues, columnsData, renderRowCell, null, getRowMaxValuesCount)).toEqual([
|
|
245
245
|
{
|
|
246
246
|
data: {
|
|
247
|
-
'n1.a': [
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
247
|
+
'n1.a': [
|
|
248
|
+
{
|
|
249
|
+
allRowHiddenValues: [2, 3],
|
|
250
|
+
values: [1],
|
|
251
|
+
indexPath: [0],
|
|
252
|
+
nestedKey: 'n1.0',
|
|
253
|
+
rowSpan: 1
|
|
254
|
+
}
|
|
255
|
+
],
|
|
256
|
+
'n1.n2.b': [
|
|
257
|
+
{ values: [], allRowHiddenValues: [4, 5, 6], indexPath: [0], nestedKey: 'n1.0', rowSpan: 1 }
|
|
258
|
+
],
|
|
259
|
+
c: [{ allRowHiddenValues: [8, 9, 10], values: [7], rowSpan: 1 }],
|
|
260
|
+
'n1.d': [{ values: [], allRowHiddenValues: [], rowSpan: 1 }]
|
|
261
|
+
},
|
|
262
|
+
id: 0
|
|
263
|
+
}
|
|
264
|
+
]);
|
|
265
|
+
expect(getRowMaxValuesCount).toHaveBeenCalledWith(0);
|
|
266
|
+
});
|
|
267
|
+
it('should apply allRowHiddenValues correctly if maxValuesCount more than 1', function () {
|
|
268
|
+
var rowValues = [
|
|
269
|
+
{
|
|
270
|
+
'n1.n2.a': [[[1, 2]], [[3, 4, 5]]]
|
|
271
|
+
}
|
|
272
|
+
];
|
|
273
|
+
var columnsData = [{ id: 'n1.n2.a', nestedPath: ['n1', 'n2', 'a'], label: 'columnA' }];
|
|
274
|
+
var renderRowCell = function (_a) {
|
|
275
|
+
var cell = _a.cell;
|
|
276
|
+
return cell.values;
|
|
277
|
+
};
|
|
278
|
+
var getRowMaxValuesCount = jest.fn(function () { return 2; });
|
|
279
|
+
expect(getTableRowsData(rowValues, columnsData, renderRowCell, null, getRowMaxValuesCount)).toEqual([
|
|
280
|
+
{
|
|
281
|
+
data: {
|
|
282
|
+
'n1.n2.a': [
|
|
283
|
+
{
|
|
284
|
+
values: [1, 2],
|
|
285
|
+
allRowHiddenValues: [5],
|
|
286
|
+
indexPath: [0, 0],
|
|
287
|
+
nestedKey: 'n1.0.n2.0',
|
|
288
|
+
rowSpan: 1
|
|
289
|
+
},
|
|
290
|
+
{ values: [3, 4], indexPath: [1, 0], nestedKey: 'n1.1.n2.0', rowSpan: 1 }
|
|
291
|
+
]
|
|
251
292
|
},
|
|
252
293
|
id: 0
|
|
253
294
|
}
|