@sis-cc/dotstatsuite-visions 10.29.0 → 11.0.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.
@@ -1,6 +1,6 @@
1
1
  var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
2
2
 
3
- import React, { useRef, useState, useEffect, useMemo, useCallback } from 'react';
3
+ import React, { useRef, useState, useEffect, useMemo } from 'react';
4
4
  import { makeStyles } from '@material-ui/core/styles';
5
5
  import PropTypes from 'prop-types';
6
6
  import * as R from 'ramda';
@@ -101,8 +101,6 @@ var TableHtml5 = function TableHtml5(_ref) {
101
101
  var headerRef = useRef(null);
102
102
  var subHeadCellsRef = useRef([]);
103
103
 
104
- var cellValueAccessorHandler = useCallback(cellValueAccessor, []);
105
-
106
104
  useEffect(function () {
107
105
  setHeaderHeight(R.pathOr(0, ['current', 'clientHeight'], headerRef));
108
106
  setSubHeadCellsWidth(getCellsWidth(R.prop('current', subHeadCellsRef)));
@@ -185,7 +183,7 @@ var TableHtml5 = function TableHtml5(_ref) {
185
183
  SideIcon: SideIcon,
186
184
  subHeadCellsWidth: subHeadCellsWidth,
187
185
  HTMLRenderer: HTMLRenderer,
188
- cellValueAccessor: cellValueAccessorHandler,
186
+ cellValueAccessor: cellValueAccessor,
189
187
  labelAccessor: labelAccessor,
190
188
  isNoWrap: isNoWrap,
191
189
  textAlign: textAlign
@@ -1,6 +1,6 @@
1
1
  var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
2
2
 
3
- import React, { Fragment, useState, useEffect } from 'react';
3
+ import React, { Fragment, useState, useMemo, useEffect } from 'react';
4
4
  import PropTypes from 'prop-types';
5
5
  import cx from 'classnames';
6
6
  import * as R from 'ramda';
@@ -17,7 +17,7 @@ import { DragDropContext } from 'react-beautiful-dnd';
17
17
  import { withBlank } from '../utils';
18
18
  import TablePreview from '../TablePreview';
19
19
  import Box from './Box';
20
- import { changeLayout, rejectHiddenElement, addHiddenElement } from './lib';
20
+ import { changeLayout, getIsOptionalActivated } from './lib';
21
21
  import { BOX, wcagId } from './constants';
22
22
  import { Button } from '../';
23
23
 
@@ -34,6 +34,12 @@ export var useStyles = makeStyles(function (theme) {
34
34
  flexDirection: 'row',
35
35
  alignItems: 'center',
36
36
  flexFlow: 'nowrap'
37
+ },
38
+ activationButton: {
39
+ backgroundColor: theme.palette.action.hover,
40
+ '&:hover': {
41
+ backgroundColor: theme.palette.action.selected
42
+ }
37
43
  }
38
44
  };
39
45
  });
@@ -46,7 +52,11 @@ var TableLayout = function TableLayout(_ref) {
46
52
  var _boxLabel;
47
53
 
48
54
  var _ref$layout = _ref.layout,
49
- layout = _ref$layout === undefined ? [] : _ref$layout,
55
+ layout = _ref$layout === undefined ? {} : _ref$layout,
56
+ _ref$items = _ref.items,
57
+ items = _ref$items === undefined ? [] : _ref$items,
58
+ _ref$optionalItem = _ref.optionalItem,
59
+ optionalItem = _ref$optionalItem === undefined ? {} : _ref$optionalItem,
50
60
  _ref$itemRenderer = _ref.itemRenderer,
51
61
  itemRenderer = _ref$itemRenderer === undefined ? R.prop('name') : _ref$itemRenderer,
52
62
  itemButtonProps = _ref.itemButtonProps,
@@ -56,40 +66,51 @@ var TableLayout = function TableLayout(_ref) {
56
66
  accessibility = _ref.accessibility;
57
67
 
58
68
  var classes = useStyles();
59
- var hiddenElement = R.map(R.filter(function (_ref2) {
60
- var isHidden = _ref2.isHidden;
61
- return isHidden;
62
- }))(layout);
63
69
 
64
- var _useState = useState([]),
70
+ var _useState = useState(layout),
65
71
  currentLayout = _useState[0],
66
72
  setCurrentLayout = _useState[1];
67
73
 
68
74
  var boxLabel = (_boxLabel = {}, _boxLabel[BOX.header] = labels.column || BOX.header, _boxLabel[BOX.sections] = labels.section || BOX.sections, _boxLabel[BOX.rows] = labels.row || BOX.rows, _boxLabel);
69
-
70
75
  useEffect(function () {
71
- return setCurrentLayout(rejectHiddenElement(layout));
76
+ setCurrentLayout(layout);
72
77
  }, [layout]);
78
+ var indexedItems = useMemo(function () {
79
+ var indexed = R.indexBy(R.prop('id'), items);
80
+ if (!R.isEmpty(optionalItem) && !R.isNil(optionalItem)) {
81
+ return R.assoc(optionalItem.id, optionalItem, indexed);
82
+ }
83
+ return indexed;
84
+ }, [items, optionalItem]);
73
85
 
74
86
  var onChangeLayout = function onChangeLayout(props) {
75
87
  return setCurrentLayout(changeLayout(_extends({}, props)));
76
88
  };
77
89
 
90
+ var activateOptionalItem = function activateOptionalItem() {
91
+ var nextLayout = R.over(R.lensProp('header'), R.append(optionalItem.id), currentLayout);
92
+ setCurrentLayout(nextLayout);
93
+ };
94
+
95
+ var deactivateOptionalItem = function deactivateOptionalItem() {
96
+ setCurrentLayout(R.map(R.reject(R.equals(optionalItem.id)), currentLayout));
97
+ };
98
+
78
99
  var onCommit = function onCommit() {
79
100
  if (R.is(Function)(commit)) {
80
- commit(addHiddenElement(currentLayout)(hiddenElement));
101
+ commit(currentLayout);
81
102
  }
82
103
  };
83
104
 
84
105
  var onCancel = function onCancel() {
85
106
  if (R.is(Function)(setCurrentLayout)) {
86
- setCurrentLayout(rejectHiddenElement(layout));
107
+ setCurrentLayout(layout);
87
108
  }
88
109
  };
89
110
 
90
- var onDragStart = function onDragStart(_ref3, provided) {
91
- var draggableId = _ref3.draggableId,
92
- source = _ref3.source;
111
+ var onDragStart = function onDragStart(_ref2, provided) {
112
+ var draggableId = _ref2.draggableId,
113
+ source = _ref2.source;
93
114
 
94
115
  if (R.is(Function)(labels.wcagDragStart)) {
95
116
  // start.source = droppableId & index
@@ -103,9 +124,9 @@ var TableLayout = function TableLayout(_ref) {
103
124
  }
104
125
  };
105
126
 
106
- var onDragUpdate = function onDragUpdate(_ref4, provided) {
107
- var destination = _ref4.destination,
108
- source = _ref4.source;
127
+ var onDragUpdate = function onDragUpdate(_ref3, provided) {
128
+ var destination = _ref3.destination,
129
+ source = _ref3.source;
109
130
 
110
131
  if (R.isNil(destination)) {
111
132
  return;
@@ -127,10 +148,10 @@ var TableLayout = function TableLayout(_ref) {
127
148
  };
128
149
 
129
150
  var onDragEnd = function onDragEnd(layout) {
130
- return function (_ref5, provided) {
131
- var reason = _ref5.reason,
132
- destination = _ref5.destination,
133
- source = _ref5.source;
151
+ return function (_ref4, provided) {
152
+ var reason = _ref4.reason,
153
+ destination = _ref4.destination,
154
+ source = _ref4.source;
134
155
 
135
156
  if (R.is(String)(labels.wcagDragCancel)) {
136
157
  if (R.equals(reason, 'CANCEL')) {
@@ -164,10 +185,16 @@ var TableLayout = function TableLayout(_ref) {
164
185
  };
165
186
  };
166
187
 
188
+ var getItems = function getItems(level) {
189
+ return R.pipe(R.prop(level), function (ids) {
190
+ return R.props(ids, indexedItems);
191
+ }, R.filter(R.identity))(currentLayout);
192
+ };
193
+
167
194
  var header = React.createElement(Box, {
168
195
  title: labels.column,
169
196
  Icon: ViewColumn,
170
- items: R.prop(BOX.header)(currentLayout),
197
+ items: getItems('header'),
171
198
  labels: labels,
172
199
  dropZoneLabel: BOX.header,
173
200
  itemRenderer: itemRenderer,
@@ -182,7 +209,7 @@ var TableLayout = function TableLayout(_ref) {
182
209
  React.createElement(Box, {
183
210
  title: labels.section,
184
211
  Icon: Reorder,
185
- items: R.prop(BOX.sections)(currentLayout),
212
+ items: getItems('sections'),
186
213
  labels: labels,
187
214
  dropZoneLabel: BOX.sections,
188
215
  itemRenderer: itemRenderer,
@@ -193,7 +220,7 @@ var TableLayout = function TableLayout(_ref) {
193
220
  React.createElement(Box, {
194
221
  title: labels.row,
195
222
  Icon: ViewList,
196
- items: R.prop(BOX.rows)(currentLayout),
223
+ items: getItems('rows'),
197
224
  labels: labels,
198
225
  dropZoneLabel: BOX.rows,
199
226
  itemRenderer: itemRenderer,
@@ -203,6 +230,8 @@ var TableLayout = function TableLayout(_ref) {
203
230
  })
204
231
  );
205
232
 
233
+ var isOptionalActivated = getIsOptionalActivated(currentLayout, R.prop('id', optionalItem));
234
+
206
235
  return React.createElement(
207
236
  Grid,
208
237
  { 'data-testid': 'table-layout-test-id', container: true },
@@ -267,63 +296,101 @@ var TableLayout = function TableLayout(_ref) {
267
296
  labels.table
268
297
  )
269
298
  ),
270
- React.createElement(TablePreview, _extends({}, currentLayout, { itemRenderer: itemRenderer }))
299
+ React.createElement(TablePreview, {
300
+ header: R.props(R.prop('header', currentLayout), indexedItems),
301
+ sections: R.props(R.prop('sections', currentLayout), indexedItems),
302
+ rows: R.props(R.prop('rows', currentLayout), indexedItems),
303
+ itemRenderer: itemRenderer
304
+ })
271
305
  )
272
306
  )
273
307
  )
274
308
  ),
275
309
  React.createElement(
276
310
  Grid,
277
- { container: true, justifyContent: 'flex-end', className: classes.buttonContainer, spacing: 1 },
278
- R.map(function (button) {
279
- return React.createElement(
280
- Grid,
281
- { item: true, key: button.id, 'data-testid': button['data-testid'] },
311
+ {
312
+ container: true,
313
+ justifyContent: 'space-between',
314
+ className: classes.buttonContainer,
315
+ spacing: 1
316
+ },
317
+ React.createElement(
318
+ Grid,
319
+ {
320
+ item: true,
321
+ 'data-testid': isOptionalActivated ? 'table-layout-deactivate-optional' : 'table-layout-activate-optional'
322
+ },
323
+ !R.isNil(optionalItem) && !R.isEmpty(optionalItem) && React.createElement(
324
+ Button,
325
+ {
326
+ className: classes.activationButton,
327
+ 'aria-label': R.prop('activationLabel', optionalItem),
328
+ color: 'primary',
329
+ onClick: isOptionalActivated ? deactivateOptionalItem : activateOptionalItem,
330
+ startIcon: React.createElement(Done, null)
331
+ },
282
332
  React.createElement(
283
- Button,
284
- _extends({ 'aria-label': button.label, color: 'primary' }, button),
285
- React.createElement(
286
- Typography,
287
- { variant: 'body2' },
288
- button.label
289
- )
333
+ Typography,
334
+ { variant: 'body2' },
335
+ R.prop('activationLabel', optionalItem)
290
336
  )
291
- );
292
- })([{
293
- id: 2,
294
- label: labels.cancel,
295
- onClick: onCancel,
296
- startIcon: React.createElement(Undo, null),
297
- 'datatest-id': 'table-layout-cancel'
298
- }, {
299
- id: 1,
300
- label: labels.commit,
301
- onClick: onCommit,
302
- startIcon: React.createElement(Done, null),
303
- variant: 'contained',
304
- alternative: 'siscc',
305
- className: classes.applyButton,
306
- 'data-testid': 'table-layout-apply'
307
- }])
337
+ )
338
+ ),
339
+ React.createElement(
340
+ Grid,
341
+ { item: true },
342
+ React.createElement(
343
+ Grid,
344
+ { container: true, justifyContent: 'flex-end', display: 'flex', spacing: 1 },
345
+ R.map(function (button) {
346
+ return React.createElement(
347
+ Grid,
348
+ { item: true, key: button.id, 'data-testid': button['data-testid'] },
349
+ React.createElement(
350
+ Button,
351
+ _extends({ 'aria-label': button.label, color: 'primary' }, button),
352
+ React.createElement(
353
+ Typography,
354
+ { variant: 'body2' },
355
+ button.label
356
+ )
357
+ )
358
+ );
359
+ })([{
360
+ id: 2,
361
+ label: labels.cancel,
362
+ onClick: onCancel,
363
+ startIcon: React.createElement(Undo, null),
364
+ 'datatest-id': 'table-layout-cancel'
365
+ }, {
366
+ id: 1,
367
+ label: labels.commit,
368
+ onClick: onCommit,
369
+ startIcon: React.createElement(Done, null),
370
+ variant: 'contained',
371
+ alternative: 'siscc',
372
+ className: classes.applyButton,
373
+ 'data-testid': 'table-layout-apply'
374
+ }])
375
+ )
376
+ )
308
377
  )
309
378
  );
310
379
  };
311
380
 
312
- var patern = {
381
+ var patern = PropTypes.shape({
313
382
  id: PropTypes.string,
314
- label: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
315
- values: PropTypes.arrayOf(PropTypes.shape({
316
- id: PropTypes.string,
317
- label: PropTypes.oneOfType([PropTypes.string, PropTypes.element])
318
- }))
319
- };
383
+ count: PropTypes.number
384
+ });
320
385
 
321
386
  TableLayout.propTypes = process.env.NODE_ENV !== "production" ? {
322
387
  layout: PropTypes.shape({
323
- header: PropTypes.arrayOf(PropTypes.shape(patern)),
324
- sections: PropTypes.arrayOf(PropTypes.shape(patern)),
325
- rows: PropTypes.arrayOf(PropTypes.shape(patern))
388
+ header: PropTypes.arrayOf(PropTypes.string),
389
+ sections: PropTypes.arrayOf(PropTypes.string),
390
+ rows: PropTypes.arrayOf(PropTypes.string)
326
391
  }),
392
+ items: PropTypes.arrayOf(patern),
393
+ optionalItem: patern,
327
394
  itemRenderer: PropTypes.func,
328
395
  commit: PropTypes.func,
329
396
  noPreview: PropTypes.bool,
@@ -348,10 +415,10 @@ TableLayout.propTypes = process.env.NODE_ENV !== "production" ? {
348
415
  accessibility: PropTypes.bool
349
416
  } : {};
350
417
 
351
- export default withBlank(function (_ref6) {
352
- var _ref6$layout = _ref6.layout,
353
- layout = _ref6$layout === undefined ? [] : _ref6$layout,
354
- isBlank = _ref6.isBlank;
418
+ export default withBlank(function (_ref5) {
419
+ var _ref5$layout = _ref5.layout,
420
+ layout = _ref5$layout === undefined ? [] : _ref5$layout,
421
+ isBlank = _ref5.isBlank;
355
422
  return {
356
423
  isBlank: R.or(isBlank, R.pipe(R.values, R.all(R.isEmpty))(layout))
357
424
  };
@@ -23,4 +23,9 @@ export var addHiddenElement = function addHiddenElement(layout) {
23
23
  return R.mapObjIndexed(function (values, key) {
24
24
  return R.pipe(R.prop(key), R.concat(values))(layout);
25
25
  });
26
+ };
27
+
28
+ export var getIsOptionalActivated = function getIsOptionalActivated(layout, optionalId) {
29
+ var founded = R.pipe(R.values, R.unnest, R.find(R.equals(optionalId)))(layout);
30
+ return !R.isNil(founded);
26
31
  };
@@ -5,30 +5,28 @@ import * as R from 'ramda';
5
5
  import Table from '@material-ui/core/Table';
6
6
  import TableRow from '@material-ui/core/TableRow';
7
7
  import TableCell from '@material-ui/core/TableCell';
8
+ import Lens from '@material-ui/icons/Lens';
8
9
  import { withBlank } from '../utils';
9
10
  import { useStyles } from './styles';
10
- import { getMaxValuesLength, getEmptyValues, getLabel, getEqualLengthValues, getEnhancedSections } from './lib';
11
+ import { getMaxValuesLength, getEmptyValues, getLabel, valueLabel, maxCount } from './lib';
11
12
 
12
13
  var patern = {
13
14
  id: PropTypes.string,
14
15
  label: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
15
- values: PropTypes.arrayOf(PropTypes.shape({
16
- id: PropTypes.string,
17
- label: PropTypes.oneOfType([PropTypes.string, PropTypes.element])
18
- }))
16
+ count: PropTypes.number
19
17
  };
20
18
 
21
19
  var Header = function Header(_ref) {
22
20
  var header = _ref.header,
23
- colSpan = _ref.colSpan;
21
+ colSpan = _ref.colSpan,
22
+ valuesSpan = _ref.valuesSpan;
24
23
 
25
24
  var classes = useStyles();
26
25
 
27
26
  return R.map(function (_ref2) {
28
27
  var id = _ref2.id,
29
28
  label = _ref2.label,
30
- _ref2$values = _ref2.values,
31
- values = _ref2$values === undefined ? [] : _ref2$values;
29
+ count = _ref2.count;
32
30
  return React.createElement(
33
31
  TableRow,
34
32
  { key: id, className: cx(classes.header, classes.border) },
@@ -43,43 +41,41 @@ var Header = function Header(_ref) {
43
41
  },
44
42
  label
45
43
  ),
46
- R.map(function (_ref3) {
47
- var id = _ref3.id,
48
- label = _ref3.label;
44
+ R.times(function (index) {
49
45
  return React.createElement(
50
46
  TableCell,
51
47
  {
52
- key: id,
48
+ key: id + '-' + index,
53
49
  className: cx(classes.border, classes.cell, classes.headerCell),
54
- title: label,
55
50
  scope: 'col'
56
51
  },
57
- label
52
+ index < count ? valueLabel : ''
58
53
  );
59
- })(values)
54
+ }, valuesSpan)
60
55
  );
61
56
  })(header);
62
57
  };
63
58
 
64
59
  Header.propTypes = process.env.NODE_ENV !== "production" ? {
65
60
  header: PropTypes.array,
66
- colSpan: PropTypes.number
61
+ colSpan: PropTypes.number,
62
+ valuesSpan: PropTypes.number
67
63
  } : {};
68
64
 
69
- var RowHeader = function RowHeader(_ref4) {
70
- var _ref4$id = _ref4.id,
71
- id = _ref4$id === undefined ? 'rowHeader' : _ref4$id,
72
- rows = _ref4.rows,
73
- emptyValues = _ref4.emptyValues;
65
+ var RowHeader = function RowHeader(_ref3) {
66
+ var _ref3$id = _ref3.id,
67
+ id = _ref3$id === undefined ? 'rowHeader' : _ref3$id,
68
+ rows = _ref3.rows,
69
+ emptyValues = _ref3.emptyValues;
74
70
 
75
71
  var classes = useStyles();
76
72
 
77
73
  return React.createElement(
78
74
  TableRow,
79
75
  null,
80
- R.map(function (_ref5) {
81
- var id = _ref5.id,
82
- label = _ref5.label;
76
+ R.map(function (_ref4) {
77
+ var id = _ref4.id,
78
+ label = _ref4.label;
83
79
  return React.createElement(
84
80
  TableCell,
85
81
  {
@@ -107,9 +103,9 @@ RowHeader.propTypes = process.env.NODE_ENV !== "production" ? {
107
103
  emptyValues: PropTypes.array
108
104
  } : {};
109
105
 
110
- var Sections = function Sections(_ref6) {
111
- var sections = _ref6.sections,
112
- colSpan = _ref6.colSpan;
106
+ var Sections = function Sections(_ref5) {
107
+ var sections = _ref5.sections,
108
+ colSpan = _ref5.colSpan;
113
109
 
114
110
  var classes = useStyles();
115
111
 
@@ -119,11 +115,9 @@ var Sections = function Sections(_ref6) {
119
115
  React.createElement(
120
116
  TableCell,
121
117
  { tabIndex: 0, className: cx(classes.border, classes.sections), colSpan: colSpan },
122
- R.map(function (_ref7) {
123
- var id = _ref7.id,
124
- label = _ref7.label,
125
- values = _ref7.values,
126
- Icon = _ref7.Icon;
118
+ R.addIndex(R.map)(function (_ref6, index) {
119
+ var id = _ref6.id,
120
+ label = _ref6.label;
127
121
  return React.createElement(
128
122
  Fragment,
129
123
  { key: id },
@@ -135,8 +129,8 @@ var Sections = function Sections(_ref6) {
135
129
  React.createElement(
136
130
  'span',
137
131
  { className: classes.sectionsCell },
138
- values,
139
- R.isNil(Icon) ? null : React.createElement(Icon, { className: classes.icon })
132
+ valueLabel,
133
+ index === sections.length - 1 ? null : React.createElement(Lens, { className: classes.icon })
140
134
  )
141
135
  );
142
136
  })(sections)
@@ -149,41 +143,41 @@ Sections.propTypes = process.env.NODE_ENV !== "production" ? {
149
143
  colSpan: PropTypes.number
150
144
  } : {};
151
145
 
152
- var RowValues = function RowValues(_ref8) {
153
- var _ref8$id = _ref8.id,
154
- id = _ref8$id === undefined ? 'rowValues' : _ref8$id,
155
- rows = _ref8.rows,
156
- emptyValues = _ref8.emptyValues;
146
+ var RowValues = function RowValues(_ref7) {
147
+ var _ref7$id = _ref7.id,
148
+ id = _ref7$id === undefined ? 'rowValues' : _ref7$id,
149
+ rows = _ref7.rows,
150
+ emptyValues = _ref7.emptyValues;
157
151
 
158
152
  var classes = useStyles();
159
- var rowValues = R.pipe(R.map(function (_ref9) {
160
- var _ref9$values = _ref9.values,
161
- values = _ref9$values === undefined ? [] : _ref9$values;
162
- return R.map(R.identity)(values);
163
- }), R.transpose)(rows);
164
- return R.addIndex(R.map)(function (values, rowIndex) {
153
+
154
+ var totalMaxCount = R.min(maxCount, R.reduce(R.max, 0, R.pluck('count', rows)));
155
+
156
+ return R.times(function (rowIndex) {
165
157
  return React.createElement(
166
158
  TableRow,
167
159
  { key: id + '-' + rowIndex },
168
- R.map(function (_ref10) {
169
- var id = _ref10.id,
170
- label = _ref10.label;
160
+ R.map(function (_ref8) {
161
+ var id = _ref8.id,
162
+ count = _ref8.count;
171
163
  return React.createElement(
172
164
  TableCell,
173
165
  {
174
- key: id,
175
- className: cx(classes.rows, classes.border, classes.cell),
176
- title: label
166
+ key: id + '-' + rowIndex,
167
+ className: cx(classes.rows, classes.border, classes.cell)
177
168
  },
178
- label
169
+ rowIndex < count ? valueLabel : ''
179
170
  );
180
- })(values),
171
+ })(rows),
181
172
  React.createElement(TableCell, { className: cx(classes.separatorValues, classes.separatorSize, classes.border) }),
182
- R.addIndex(R.map)(function (value, valueIndex) {
183
- return React.createElement(TableCell, { key: rowIndex + '-' + valueIndex, className: cx(classes.border, classes.cell) });
184
- })(emptyValues)
173
+ R.times(function (columnIndex) {
174
+ return React.createElement(TableCell, {
175
+ key: rowIndex + '-header-' + columnIndex,
176
+ className: cx(classes.border, classes.cell)
177
+ });
178
+ })(emptyValues.length)
185
179
  );
186
- })(rowValues);
180
+ }, totalMaxCount);
187
181
  };
188
182
 
189
183
  RowValues.propTypes = process.env.NODE_ENV !== "production" ? {
@@ -192,26 +186,25 @@ RowValues.propTypes = process.env.NODE_ENV !== "production" ? {
192
186
  emptyValues: PropTypes.array
193
187
  } : {};
194
188
 
195
- var MyTable = function MyTable(_ref11) {
196
- var _ref11$header = _ref11.header,
197
- header = _ref11$header === undefined ? [] : _ref11$header,
198
- _ref11$sections = _ref11.sections,
199
- sections = _ref11$sections === undefined ? [] : _ref11$sections,
200
- _ref11$rows = _ref11.rows,
201
- rows = _ref11$rows === undefined ? [] : _ref11$rows,
202
- _ref11$labelRenderer = _ref11.labelRenderer,
203
- labelRenderer = _ref11$labelRenderer === undefined ? R.prop('name') : _ref11$labelRenderer;
189
+ var MyTable = function MyTable(_ref9) {
190
+ var _ref9$header = _ref9.header,
191
+ header = _ref9$header === undefined ? [] : _ref9$header,
192
+ _ref9$sections = _ref9.sections,
193
+ sections = _ref9$sections === undefined ? [] : _ref9$sections,
194
+ _ref9$rows = _ref9.rows,
195
+ rows = _ref9$rows === undefined ? [] : _ref9$rows,
196
+ _ref9$labelRenderer = _ref9.labelRenderer,
197
+ labelRenderer = _ref9$labelRenderer === undefined ? R.prop('name') : _ref9$labelRenderer;
204
198
 
205
199
  var classes = useStyles();
206
200
  var nbShowedValuesHeader = getMaxValuesLength(header);
207
- var nbShowedValuesRows = getMaxValuesLength(rows);
208
201
 
209
202
  var emptyValues = getEmptyValues(nbShowedValuesHeader);
210
- var nbColumns = R.max(R.length(header) + nbShowedValuesHeader, R.length(rows) + nbShowedValuesRows) + 2;
203
+ var nbColumns = R.length(rows) + R.max(nbShowedValuesHeader, 1) + 1;
211
204
  var nbColumnRows = R.length(rows) + 1;
212
- var enhancedHeader = R.pipe(getLabel(labelRenderer), getEqualLengthValues(nbShowedValuesHeader))(header);
213
- var enhancedRows = R.pipe(getLabel(labelRenderer), getEqualLengthValues(nbShowedValuesRows))(rows);
214
- var enhancedSections = R.pipe(getLabel(labelRenderer), getEnhancedSections(R.length(sections)))(sections);
205
+ var enhancedHeader = R.pipe(getLabel(labelRenderer))(header);
206
+ var enhancedRows = R.pipe(getLabel(labelRenderer))(rows);
207
+ var enhancedSections = R.pipe(getLabel(labelRenderer))(sections);
215
208
 
216
209
  return React.createElement(
217
210
  Table,
@@ -223,7 +216,11 @@ var MyTable = function MyTable(_ref11) {
223
216
  React.createElement(
224
217
  'tbody',
225
218
  null,
226
- R.isEmpty(enhancedHeader) ? null : React.createElement(Header, { colSpan: nbColumnRows, header: enhancedHeader }),
219
+ R.isEmpty(enhancedHeader) ? null : React.createElement(Header, {
220
+ colSpan: nbColumnRows,
221
+ header: enhancedHeader,
222
+ valuesSpan: nbShowedValuesHeader
223
+ }),
227
224
  React.createElement(RowHeader, { rows: enhancedRows, emptyValues: emptyValues }),
228
225
  R.isEmpty(enhancedSections) ? null : React.createElement(Sections, { colSpan: nbColumns, sections: enhancedSections }),
229
226
  React.createElement(RowValues, { rows: enhancedRows, emptyValues: emptyValues })
@@ -238,10 +235,10 @@ MyTable.propTypes = process.env.NODE_ENV !== "production" ? {
238
235
  labelRenderer: PropTypes.func
239
236
  } : {};
240
237
 
241
- export default withBlank(function (_ref12) {
242
- var _ref12$rows = _ref12.rows,
243
- rows = _ref12$rows === undefined ? [] : _ref12$rows,
244
- isBlank = _ref12.isBlank;
238
+ export default withBlank(function (_ref10) {
239
+ var _ref10$rows = _ref10.rows,
240
+ rows = _ref10$rows === undefined ? [] : _ref10$rows,
241
+ isBlank = _ref10.isBlank;
245
242
  return {
246
243
  isBlank: R.or(isBlank, R.isEmpty(rows))
247
244
  };
@@ -1,12 +1,11 @@
1
1
  import * as R from 'ramda';
2
2
  import Lens from '@material-ui/icons/Lens';
3
3
 
4
- export var getMaxValuesLength = function getMaxValuesLength(lists) {
5
- return Math.max.apply(Math, R.map(function (_ref) {
6
- var _ref$values = _ref.values,
7
- values = _ref$values === undefined ? [] : _ref$values;
8
- return R.length(values);
9
- })(lists));
4
+ export var valueLabel = 'Xxxx';
5
+ export var maxCount = 3;
6
+
7
+ export var getMaxValuesLength = function getMaxValuesLength(items) {
8
+ return Math.min(Math.max.apply(Math, R.pluck('count', items)), maxCount);
10
9
  };
11
10
  export var getEmptyValues = R.ifElse(R.flip(R.lte)(0), R.always(['']), R.times(R.always('')));
12
11
  export var getLabel = function getLabel(itemRenderer) {
@@ -135,8 +135,6 @@ var TableHtml5 = function TableHtml5(_ref) {
135
135
  var headerRef = (0, _react.useRef)(null);
136
136
  var subHeadCellsRef = (0, _react.useRef)([]);
137
137
 
138
- var cellValueAccessorHandler = (0, _react.useCallback)(cellValueAccessor, []);
139
-
140
138
  (0, _react.useEffect)(function () {
141
139
  setHeaderHeight(R.pathOr(0, ['current', 'clientHeight'], headerRef));
142
140
  setSubHeadCellsWidth(getCellsWidth(R.prop('current', subHeadCellsRef)));
@@ -219,7 +217,7 @@ var TableHtml5 = function TableHtml5(_ref) {
219
217
  SideIcon: SideIcon,
220
218
  subHeadCellsWidth: subHeadCellsWidth,
221
219
  HTMLRenderer: HTMLRenderer,
222
- cellValueAccessor: cellValueAccessorHandler,
220
+ cellValueAccessor: cellValueAccessor,
223
221
  labelAccessor: labelAccessor,
224
222
  isNoWrap: isNoWrap,
225
223
  textAlign: textAlign