@sis-cc/dotstatsuite-visions 10.29.0 → 11.1.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.
@@ -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) {
@@ -620,7 +620,7 @@ AdvancedFilterDialog.propTypes = process.env.NODE_ENV !== "production" ? {
620
620
  isOpen: _propTypes2.default.bool,
621
621
  items: _propTypes2.default.array,
622
622
  labels: _propTypes2.default.shape({
623
- placeholder: _propTypes2.default.string,
623
+ placeholder: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.func]),
624
624
  disableItemLabel: _propTypes2.default.string,
625
625
  singleSelection: _propTypes2.default.string,
626
626
  childrenSelection: _propTypes2.default.string,
@@ -38,7 +38,8 @@ var useStyles = (0, _styles.makeStyles)(function () {
38
38
  var NO_RESULT_MESSAGE_ID = 'noResultMessage';
39
39
 
40
40
  var NoData = function NoData(_ref) {
41
- var icon = _ref.icon,
41
+ var _ref$icon = _ref.icon,
42
+ icon = _ref$icon === undefined ? _react2.default.createElement(_Error2.default, { color: 'primary', fontSize: 'large' }) : _ref$icon,
42
43
  message = _ref.message;
43
44
 
44
45
  var classes = useStyles();
@@ -63,9 +64,5 @@ NoData.propTypes = process.env.NODE_ENV !== "production" ? {
63
64
  message: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.element])
64
65
  } : {};
65
66
 
66
- NoData.defaultProps = {
67
- icon: _react2.default.createElement(_Error2.default, { color: 'primary', fontSize: 'large' })
68
- };
69
-
70
67
  exports.default = NoData;
71
68
  module.exports = exports['default'];
@@ -40,7 +40,8 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj;
40
40
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
41
41
 
42
42
  var Field = exports.Field = function Field(_ref) {
43
- var spotlight = _ref.spotlight,
43
+ var _ref$spotlight = _ref.spotlight,
44
+ spotlight = _ref$spotlight === undefined ? {} : _ref$spotlight,
44
45
  onChangeField = _ref.onChangeField,
45
46
  isRtl = _ref.isRtl,
46
47
  classes = _ref.classes;
@@ -128,8 +129,4 @@ Field.propTypes = process.env.NODE_ENV !== "production" ? {
128
129
  }),
129
130
  onChangeField: _propTypes2.default.func.isRequired,
130
131
  isRtl: _propTypes2.default.bool
131
- } : {};
132
-
133
- Field.defaultProps = {
134
- spotlight: {}
135
- };
132
+ } : {};
@@ -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
@@ -90,6 +90,12 @@ var useStyles = exports.useStyles = (0, _styles.makeStyles)(function (theme) {
90
90
  flexDirection: 'row',
91
91
  alignItems: 'center',
92
92
  flexFlow: 'nowrap'
93
+ },
94
+ activationButton: {
95
+ backgroundColor: theme.palette.action.hover,
96
+ '&:hover': {
97
+ backgroundColor: theme.palette.action.selected
98
+ }
93
99
  }
94
100
  };
95
101
  });
@@ -102,7 +108,11 @@ var TableLayout = function TableLayout(_ref) {
102
108
  var _boxLabel;
103
109
 
104
110
  var _ref$layout = _ref.layout,
105
- layout = _ref$layout === undefined ? [] : _ref$layout,
111
+ layout = _ref$layout === undefined ? {} : _ref$layout,
112
+ _ref$items = _ref.items,
113
+ items = _ref$items === undefined ? [] : _ref$items,
114
+ _ref$optionalItem = _ref.optionalItem,
115
+ optionalItem = _ref$optionalItem === undefined ? {} : _ref$optionalItem,
106
116
  _ref$itemRenderer = _ref.itemRenderer,
107
117
  itemRenderer = _ref$itemRenderer === undefined ? R.prop('name') : _ref$itemRenderer,
108
118
  itemButtonProps = _ref.itemButtonProps,
@@ -112,40 +122,51 @@ var TableLayout = function TableLayout(_ref) {
112
122
  accessibility = _ref.accessibility;
113
123
 
114
124
  var classes = useStyles();
115
- var hiddenElement = R.map(R.filter(function (_ref2) {
116
- var isHidden = _ref2.isHidden;
117
- return isHidden;
118
- }))(layout);
119
125
 
120
- var _useState = (0, _react.useState)([]),
126
+ var _useState = (0, _react.useState)(layout),
121
127
  currentLayout = _useState[0],
122
128
  setCurrentLayout = _useState[1];
123
129
 
124
130
  var boxLabel = (_boxLabel = {}, _boxLabel[_constants.BOX.header] = labels.column || _constants.BOX.header, _boxLabel[_constants.BOX.sections] = labels.section || _constants.BOX.sections, _boxLabel[_constants.BOX.rows] = labels.row || _constants.BOX.rows, _boxLabel);
125
-
126
131
  (0, _react.useEffect)(function () {
127
- return setCurrentLayout((0, _lib.rejectHiddenElement)(layout));
132
+ setCurrentLayout(layout);
128
133
  }, [layout]);
134
+ var indexedItems = (0, _react.useMemo)(function () {
135
+ var indexed = R.indexBy(R.prop('id'), items);
136
+ if (!R.isEmpty(optionalItem) && !R.isNil(optionalItem)) {
137
+ return R.assoc(optionalItem.id, optionalItem, indexed);
138
+ }
139
+ return indexed;
140
+ }, [items, optionalItem]);
129
141
 
130
142
  var onChangeLayout = function onChangeLayout(props) {
131
143
  return setCurrentLayout((0, _lib.changeLayout)(_extends({}, props)));
132
144
  };
133
145
 
146
+ var activateOptionalItem = function activateOptionalItem() {
147
+ var nextLayout = R.over(R.lensProp('header'), R.append(optionalItem.id), currentLayout);
148
+ setCurrentLayout(nextLayout);
149
+ };
150
+
151
+ var deactivateOptionalItem = function deactivateOptionalItem() {
152
+ setCurrentLayout(R.map(R.reject(R.equals(optionalItem.id)), currentLayout));
153
+ };
154
+
134
155
  var onCommit = function onCommit() {
135
156
  if (R.is(Function)(commit)) {
136
- commit((0, _lib.addHiddenElement)(currentLayout)(hiddenElement));
157
+ commit(currentLayout);
137
158
  }
138
159
  };
139
160
 
140
161
  var onCancel = function onCancel() {
141
162
  if (R.is(Function)(setCurrentLayout)) {
142
- setCurrentLayout((0, _lib.rejectHiddenElement)(layout));
163
+ setCurrentLayout(layout);
143
164
  }
144
165
  };
145
166
 
146
- var onDragStart = function onDragStart(_ref3, provided) {
147
- var draggableId = _ref3.draggableId,
148
- source = _ref3.source;
167
+ var onDragStart = function onDragStart(_ref2, provided) {
168
+ var draggableId = _ref2.draggableId,
169
+ source = _ref2.source;
149
170
 
150
171
  if (R.is(Function)(labels.wcagDragStart)) {
151
172
  // start.source = droppableId & index
@@ -159,9 +180,9 @@ var TableLayout = function TableLayout(_ref) {
159
180
  }
160
181
  };
161
182
 
162
- var onDragUpdate = function onDragUpdate(_ref4, provided) {
163
- var destination = _ref4.destination,
164
- source = _ref4.source;
183
+ var onDragUpdate = function onDragUpdate(_ref3, provided) {
184
+ var destination = _ref3.destination,
185
+ source = _ref3.source;
165
186
 
166
187
  if (R.isNil(destination)) {
167
188
  return;
@@ -183,10 +204,10 @@ var TableLayout = function TableLayout(_ref) {
183
204
  };
184
205
 
185
206
  var onDragEnd = function onDragEnd(layout) {
186
- return function (_ref5, provided) {
187
- var reason = _ref5.reason,
188
- destination = _ref5.destination,
189
- source = _ref5.source;
207
+ return function (_ref4, provided) {
208
+ var reason = _ref4.reason,
209
+ destination = _ref4.destination,
210
+ source = _ref4.source;
190
211
 
191
212
  if (R.is(String)(labels.wcagDragCancel)) {
192
213
  if (R.equals(reason, 'CANCEL')) {
@@ -220,10 +241,16 @@ var TableLayout = function TableLayout(_ref) {
220
241
  };
221
242
  };
222
243
 
244
+ var getItems = function getItems(level) {
245
+ return R.pipe(R.prop(level), function (ids) {
246
+ return R.props(ids, indexedItems);
247
+ }, R.filter(R.identity))(currentLayout);
248
+ };
249
+
223
250
  var header = _react2.default.createElement(_Box2.default, {
224
251
  title: labels.column,
225
252
  Icon: _ViewColumnOutlined2.default,
226
- items: R.prop(_constants.BOX.header)(currentLayout),
253
+ items: getItems('header'),
227
254
  labels: labels,
228
255
  dropZoneLabel: _constants.BOX.header,
229
256
  itemRenderer: itemRenderer,
@@ -238,7 +265,7 @@ var TableLayout = function TableLayout(_ref) {
238
265
  _react2.default.createElement(_Box2.default, {
239
266
  title: labels.section,
240
267
  Icon: _Reorder2.default,
241
- items: R.prop(_constants.BOX.sections)(currentLayout),
268
+ items: getItems('sections'),
242
269
  labels: labels,
243
270
  dropZoneLabel: _constants.BOX.sections,
244
271
  itemRenderer: itemRenderer,
@@ -249,7 +276,7 @@ var TableLayout = function TableLayout(_ref) {
249
276
  _react2.default.createElement(_Box2.default, {
250
277
  title: labels.row,
251
278
  Icon: _ViewListOutlined2.default,
252
- items: R.prop(_constants.BOX.rows)(currentLayout),
279
+ items: getItems('rows'),
253
280
  labels: labels,
254
281
  dropZoneLabel: _constants.BOX.rows,
255
282
  itemRenderer: itemRenderer,
@@ -259,6 +286,8 @@ var TableLayout = function TableLayout(_ref) {
259
286
  })
260
287
  );
261
288
 
289
+ var isOptionalActivated = (0, _lib.getIsOptionalActivated)(currentLayout, R.prop('id', optionalItem));
290
+
262
291
  return _react2.default.createElement(
263
292
  _Grid2.default,
264
293
  { 'data-testid': 'table-layout-test-id', container: true },
@@ -323,63 +352,101 @@ var TableLayout = function TableLayout(_ref) {
323
352
  labels.table
324
353
  )
325
354
  ),
326
- _react2.default.createElement(_TablePreview2.default, _extends({}, currentLayout, { itemRenderer: itemRenderer }))
355
+ _react2.default.createElement(_TablePreview2.default, {
356
+ header: R.props(R.prop('header', currentLayout), indexedItems),
357
+ sections: R.props(R.prop('sections', currentLayout), indexedItems),
358
+ rows: R.props(R.prop('rows', currentLayout), indexedItems),
359
+ itemRenderer: itemRenderer
360
+ })
327
361
  )
328
362
  )
329
363
  )
330
364
  ),
331
365
  _react2.default.createElement(
332
366
  _Grid2.default,
333
- { container: true, justifyContent: 'flex-end', className: classes.buttonContainer, spacing: 1 },
334
- R.map(function (button) {
335
- return _react2.default.createElement(
336
- _Grid2.default,
337
- { item: true, key: button.id, 'data-testid': button['data-testid'] },
367
+ {
368
+ container: true,
369
+ justifyContent: 'space-between',
370
+ className: classes.buttonContainer,
371
+ spacing: 1
372
+ },
373
+ _react2.default.createElement(
374
+ _Grid2.default,
375
+ {
376
+ item: true,
377
+ 'data-testid': isOptionalActivated ? 'table-layout-deactivate-optional' : 'table-layout-activate-optional'
378
+ },
379
+ !R.isNil(optionalItem) && !R.isEmpty(optionalItem) && _react2.default.createElement(
380
+ _.Button,
381
+ {
382
+ className: classes.activationButton,
383
+ 'aria-label': R.prop('activationLabel', optionalItem),
384
+ color: 'primary',
385
+ onClick: isOptionalActivated ? deactivateOptionalItem : activateOptionalItem,
386
+ startIcon: _react2.default.createElement(_Done2.default, null)
387
+ },
338
388
  _react2.default.createElement(
339
- _.Button,
340
- _extends({ 'aria-label': button.label, color: 'primary' }, button),
341
- _react2.default.createElement(
342
- _Typography2.default,
343
- { variant: 'body2' },
344
- button.label
345
- )
389
+ _Typography2.default,
390
+ { variant: 'body2' },
391
+ R.prop('activationLabel', optionalItem)
346
392
  )
347
- );
348
- })([{
349
- id: 2,
350
- label: labels.cancel,
351
- onClick: onCancel,
352
- startIcon: _react2.default.createElement(_Undo2.default, null),
353
- 'datatest-id': 'table-layout-cancel'
354
- }, {
355
- id: 1,
356
- label: labels.commit,
357
- onClick: onCommit,
358
- startIcon: _react2.default.createElement(_Done2.default, null),
359
- variant: 'contained',
360
- alternative: 'siscc',
361
- className: classes.applyButton,
362
- 'data-testid': 'table-layout-apply'
363
- }])
393
+ )
394
+ ),
395
+ _react2.default.createElement(
396
+ _Grid2.default,
397
+ { item: true },
398
+ _react2.default.createElement(
399
+ _Grid2.default,
400
+ { container: true, justifyContent: 'flex-end', display: 'flex', spacing: 1 },
401
+ R.map(function (button) {
402
+ return _react2.default.createElement(
403
+ _Grid2.default,
404
+ { item: true, key: button.id, 'data-testid': button['data-testid'] },
405
+ _react2.default.createElement(
406
+ _.Button,
407
+ _extends({ 'aria-label': button.label, color: 'primary' }, button),
408
+ _react2.default.createElement(
409
+ _Typography2.default,
410
+ { variant: 'body2' },
411
+ button.label
412
+ )
413
+ )
414
+ );
415
+ })([{
416
+ id: 2,
417
+ label: labels.cancel,
418
+ onClick: onCancel,
419
+ startIcon: _react2.default.createElement(_Undo2.default, null),
420
+ 'datatest-id': 'table-layout-cancel'
421
+ }, {
422
+ id: 1,
423
+ label: labels.commit,
424
+ onClick: onCommit,
425
+ startIcon: _react2.default.createElement(_Done2.default, null),
426
+ variant: 'contained',
427
+ alternative: 'siscc',
428
+ className: classes.applyButton,
429
+ 'data-testid': 'table-layout-apply'
430
+ }])
431
+ )
432
+ )
364
433
  )
365
434
  );
366
435
  };
367
436
 
368
- var patern = {
437
+ var patern = _propTypes2.default.shape({
369
438
  id: _propTypes2.default.string,
370
- label: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.element]),
371
- values: _propTypes2.default.arrayOf(_propTypes2.default.shape({
372
- id: _propTypes2.default.string,
373
- label: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.element])
374
- }))
375
- };
439
+ count: _propTypes2.default.number
440
+ });
376
441
 
377
442
  TableLayout.propTypes = process.env.NODE_ENV !== "production" ? {
378
443
  layout: _propTypes2.default.shape({
379
- header: _propTypes2.default.arrayOf(_propTypes2.default.shape(patern)),
380
- sections: _propTypes2.default.arrayOf(_propTypes2.default.shape(patern)),
381
- rows: _propTypes2.default.arrayOf(_propTypes2.default.shape(patern))
444
+ header: _propTypes2.default.arrayOf(_propTypes2.default.string),
445
+ sections: _propTypes2.default.arrayOf(_propTypes2.default.string),
446
+ rows: _propTypes2.default.arrayOf(_propTypes2.default.string)
382
447
  }),
448
+ items: _propTypes2.default.arrayOf(patern),
449
+ optionalItem: patern,
383
450
  itemRenderer: _propTypes2.default.func,
384
451
  commit: _propTypes2.default.func,
385
452
  noPreview: _propTypes2.default.bool,
@@ -404,10 +471,10 @@ TableLayout.propTypes = process.env.NODE_ENV !== "production" ? {
404
471
  accessibility: _propTypes2.default.bool
405
472
  } : {};
406
473
 
407
- exports.default = (0, _utils.withBlank)(function (_ref6) {
408
- var _ref6$layout = _ref6.layout,
409
- layout = _ref6$layout === undefined ? [] : _ref6$layout,
410
- isBlank = _ref6.isBlank;
474
+ exports.default = (0, _utils.withBlank)(function (_ref5) {
475
+ var _ref5$layout = _ref5.layout,
476
+ layout = _ref5$layout === undefined ? [] : _ref5$layout,
477
+ isBlank = _ref5.isBlank;
411
478
  return {
412
479
  isBlank: R.or(isBlank, R.pipe(R.values, R.all(R.isEmpty))(layout))
413
480
  };