@hipay/hipay-material-ui 1.0.0-beta.22 → 1.0.0-beta.25

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. package/HI-CHANGELOG.md +26 -43
  2. package/HiChip/HiChip.js +67 -8
  3. package/HiChip/HiChipSwitch.js +6 -0
  4. package/HiDatePicker/HiDatePicker.js +35 -21
  5. package/HiDatePicker/HiDateRangePicker.js +92 -50
  6. package/HiDatePicker/HiDateRangeSelector.js +15 -4
  7. package/HiDatePicker/Overlays/Overlay.js +1 -1
  8. package/HiDatePicker/stylesheet.js +3 -0
  9. package/HiForm/HiInput.js +12 -2
  10. package/HiForm/HiPasswordField.js +8 -3
  11. package/HiLoader/HiLoader.js +7 -4
  12. package/HiPins/HiPins.js +6 -4
  13. package/HiSelect/HiSelect.js +26 -6
  14. package/HiSelect/HiSuggestSelect.js +2 -1
  15. package/HiSelect/SelectInput.js +3 -8
  16. package/HiSelectableList/HiSelectableList.js +51 -49
  17. package/HiSelectableList/HiSelectableListItem.js +18 -2
  18. package/HiTable/BodyCellBuilder.js +22 -12
  19. package/HiTable/BodyCells/CellAccount.js +13 -4
  20. package/HiTable/BodyCells/CellAccountNumber.js +12 -3
  21. package/HiTable/BodyCells/CellAddress.js +12 -3
  22. package/HiTable/BodyCells/CellCountry.js +12 -3
  23. package/HiTable/BodyCells/CellDate.js +43 -42
  24. package/HiTable/BodyCells/CellIcon.js +12 -3
  25. package/HiTable/BodyCells/CellImage.js +12 -3
  26. package/HiTable/BodyCells/CellNumeric.js +12 -3
  27. package/HiTable/BodyCells/CellRate.js +12 -3
  28. package/HiTable/BodyCells/CellSentinel.js +17 -7
  29. package/HiTable/BodyCells/CellStatus.js +13 -4
  30. package/HiTable/BodyCells/CellText.js +17 -7
  31. package/HiTable/BodyCells/CellThirdPartySecurity.js +12 -3
  32. package/HiTable/BodyRow.js +12 -3
  33. package/HiTable/ColumnFilter.js +2 -5
  34. package/HiTable/HeaderCell.js +21 -11
  35. package/HiTable/HiStickyRow.js +24 -13
  36. package/HiTable/HiTable.js +30 -69
  37. package/HiTable/HiTableBody.js +99 -29
  38. package/HiTable/HiTableContextMenu.js +31 -16
  39. package/HiTable/HiTableFooter.js +9 -0
  40. package/HiTable/HiTableHead.js +15 -7
  41. package/HiTopBar/HiTopBar.js +6 -0
  42. package/README.md +71 -6
  43. package/es/HiChip/HiChip.js +79 -8
  44. package/es/HiChip/HiChipSwitch.js +6 -0
  45. package/es/HiDatePicker/HiDatePicker.js +30 -21
  46. package/es/HiDatePicker/HiDateRangePicker.js +86 -52
  47. package/es/HiDatePicker/HiDateRangeSelector.js +14 -4
  48. package/es/HiDatePicker/Overlays/Overlay.js +1 -1
  49. package/es/HiDatePicker/stylesheet.js +3 -0
  50. package/es/HiForm/HiInput.js +12 -2
  51. package/es/HiForm/HiPasswordField.js +8 -3
  52. package/es/HiLoader/HiLoader.js +3 -3
  53. package/es/HiPins/HiPins.js +4 -4
  54. package/es/HiSelect/HiSelect.js +25 -6
  55. package/es/HiSelect/HiSuggestSelect.js +2 -1
  56. package/es/HiSelect/SelectInput.js +3 -8
  57. package/es/HiSelectableList/HiSelectableList.js +51 -49
  58. package/es/HiSelectableList/HiSelectableListItem.js +15 -2
  59. package/es/HiTable/BodyCellBuilder.js +8 -2
  60. package/es/HiTable/BodyCells/CellAccount.js +7 -2
  61. package/es/HiTable/BodyCells/CellAccountNumber.js +6 -1
  62. package/es/HiTable/BodyCells/CellAddress.js +6 -1
  63. package/es/HiTable/BodyCells/CellCountry.js +6 -1
  64. package/es/HiTable/BodyCells/CellDate.js +28 -37
  65. package/es/HiTable/BodyCells/CellIcon.js +6 -1
  66. package/es/HiTable/BodyCells/CellImage.js +6 -1
  67. package/es/HiTable/BodyCells/CellNumeric.js +6 -1
  68. package/es/HiTable/BodyCells/CellRate.js +6 -1
  69. package/es/HiTable/BodyCells/CellSentinel.js +6 -1
  70. package/es/HiTable/BodyCells/CellStatus.js +7 -2
  71. package/es/HiTable/BodyCells/CellText.js +6 -1
  72. package/es/HiTable/BodyCells/CellThirdPartySecurity.js +6 -1
  73. package/es/HiTable/BodyRow.js +7 -2
  74. package/es/HiTable/ColumnFilter.js +2 -5
  75. package/es/HiTable/HeaderCell.js +16 -9
  76. package/es/HiTable/HiStickyRow.js +20 -13
  77. package/es/HiTable/HiTable.js +4 -40
  78. package/es/HiTable/HiTableBody.js +78 -26
  79. package/es/HiTable/HiTableContextMenu.js +28 -16
  80. package/es/HiTable/HiTableFooter.js +5 -0
  81. package/es/HiTable/HiTableHead.js +11 -6
  82. package/es/HiTopBar/HiTopBar.js +5 -0
  83. package/es/utils/HiIconBuilder.js +6 -2
  84. package/index.es.js +1 -1
  85. package/index.js +1 -1
  86. package/package.json +6 -1
  87. package/umd/hipay-material-ui.development.js +99120 -65306
  88. package/umd/hipay-material-ui.production.min.js +5 -5
  89. package/utils/HiIconBuilder.js +6 -2
@@ -9,6 +9,10 @@ var _defineProperty2 = require('babel-runtime/helpers/defineProperty');
9
9
 
10
10
  var _defineProperty3 = _interopRequireDefault(_defineProperty2);
11
11
 
12
+ var _stringify = require('babel-runtime/core-js/json/stringify');
13
+
14
+ var _stringify2 = _interopRequireDefault(_stringify);
15
+
12
16
  var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of');
13
17
 
14
18
  var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
@@ -150,21 +154,22 @@ var styles = exports.styles = function styles(theme) {
150
154
  * Construit une cellule d'entête avec le titre, clickable, triable et filtrable
151
155
  */
152
156
 
153
- var HeaderCell = function (_React$PureComponent) {
154
- (0, _inherits3.default)(HeaderCell, _React$PureComponent);
157
+ var HeaderCell = function (_React$Component) {
158
+ (0, _inherits3.default)(HeaderCell, _React$Component);
155
159
 
156
160
  function HeaderCell(props) {
157
161
  (0, _classCallCheck3.default)(this, HeaderCell);
158
162
 
159
163
  var _this = (0, _possibleConstructorReturn3.default)(this, (HeaderCell.__proto__ || (0, _getPrototypeOf2.default)(HeaderCell)).call(this, props));
160
164
 
165
+ _this.anchorEl = null;
166
+
161
167
  _this.onFilterClick = function (event, columnDataset) {
162
168
  _this.openFilterMenu(event, columnDataset);
163
169
  };
164
170
 
165
171
  _this.state = {
166
172
  filterOpen: false,
167
- anchorEl: null,
168
173
  menuFilters: []
169
174
  };
170
175
 
@@ -177,18 +182,24 @@ var HeaderCell = function (_React$PureComponent) {
177
182
  }
178
183
 
179
184
  (0, _createClass3.default)(HeaderCell, [{
185
+ key: 'shouldComponentUpdate',
186
+ value: function shouldComponentUpdate(nextProps, nextState) {
187
+ return (0, _stringify2.default)(nextProps) !== (0, _stringify2.default)(this.props) || (0, _stringify2.default)(nextState) !== (0, _stringify2.default)(this.state);
188
+ }
189
+ }, {
180
190
  key: 'openFilterMenu',
181
191
  value: function openFilterMenu(event, columnDataset) {
182
192
  this.setState({
183
193
  filterOpen: true,
184
- anchorEl: event.currentTarget,
185
194
  menuFilters: columnDataset
186
195
  });
196
+ this.anchorEl = event.currentTarget;
187
197
  }
188
198
  }, {
189
199
  key: 'handleClose',
190
200
  value: function handleClose() {
191
- this.setState({ filterOpen: false, anchorEl: null, menuFilters: [] });
201
+ this.setState({ filterOpen: false, menuFilters: [] });
202
+ this.anchorEl = null;
192
203
  }
193
204
 
194
205
  /**
@@ -236,7 +247,6 @@ var HeaderCell = function (_React$PureComponent) {
236
247
  translations = _props.translations;
237
248
  var _state = this.state,
238
249
  filterOpen = _state.filterOpen,
239
- anchorEl = _state.anchorEl,
240
250
  menuFilters = _state.menuFilters;
241
251
 
242
252
 
@@ -318,7 +328,6 @@ var HeaderCell = function (_React$PureComponent) {
318
328
  _filterable ? _this2.onFilterClick(event, filterSource) : _this2.handleSort(sortDirection === 'asc' ? 'desc' : 'asc');
319
329
  }
320
330
  },
321
- align === 'right' && _icons,
322
331
  _react2.default.createElement(
323
332
  'span',
324
333
  {
@@ -326,7 +335,7 @@ var HeaderCell = function (_React$PureComponent) {
326
335
  },
327
336
  view !== 's' ? title : smallTitle || title
328
337
  ),
329
- align !== 'right' && _icons
338
+ _icons
330
339
  ) : _react2.default.createElement(
331
340
  'div',
332
341
  {
@@ -353,7 +362,7 @@ var HeaderCell = function (_React$PureComponent) {
353
362
  filterValueList: menuFilters,
354
363
  isOpen: filterOpen,
355
364
  onClose: this.handleClose,
356
- anchorEl: anchorEl,
365
+ anchorEl: this.anchorEl,
357
366
  sortable: sortable,
358
367
  onSort: this.handleSort,
359
368
  onFilterChange: this.handleFilterChange,
@@ -363,7 +372,7 @@ var HeaderCell = function (_React$PureComponent) {
363
372
  }
364
373
  }]);
365
374
  return HeaderCell;
366
- }(_react2.default.PureComponent);
375
+ }(_react2.default.Component);
367
376
 
368
377
  HeaderCell.defaultProps = {
369
378
  selectable: false,
@@ -375,7 +384,8 @@ HeaderCell.defaultProps = {
375
384
  dense: false,
376
385
  fixedColumnWidth: true,
377
386
  sticky: true,
378
- padding: 8
387
+ padding: 8,
388
+ translations: {}
379
389
  };
380
390
  HeaderCell.propTypes = process.env.NODE_ENV !== "production" ? {
381
391
  /**
@@ -9,6 +9,10 @@ var _defineProperty2 = require('babel-runtime/helpers/defineProperty');
9
9
 
10
10
  var _defineProperty3 = _interopRequireDefault(_defineProperty2);
11
11
 
12
+ var _stringify = require('babel-runtime/core-js/json/stringify');
13
+
14
+ var _stringify2 = _interopRequireDefault(_stringify);
15
+
12
16
  var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of');
13
17
 
14
18
  var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
@@ -138,6 +142,11 @@ var HiStickyRow = function (_React$PureComponent) {
138
142
  }
139
143
 
140
144
  (0, _createClass3.default)(HiStickyRow, [{
145
+ key: 'shouldComponentUpdate',
146
+ value: function shouldComponentUpdate(nextProps, nextState) {
147
+ return (0, _stringify2.default)(this.props) !== (0, _stringify2.default)(nextProps) || (0, _stringify2.default)(this.state) !== (0, _stringify2.default)(nextState);
148
+ }
149
+ }, {
141
150
  key: 'render',
142
151
  value: function render() {
143
152
  var _this2 = this;
@@ -189,18 +198,24 @@ var HiStickyRow = function (_React$PureComponent) {
189
198
  className: 'stickyRowContent',
190
199
  style: {
191
200
  position: 'relative',
192
- top: dense ? 3 : 2
201
+ top: dense ? 3 : 2,
202
+ display: 'flex',
203
+ alignItems: 'center'
193
204
  }
194
205
  },
195
206
  _react2.default.createElement(
196
- 'span',
197
- { id: 'sticky-label', className: classes.label },
198
- label
199
- ),
200
- _react2.default.createElement(
201
- 'span',
202
- { id: 'sticky-badge', style: { position: 'relative' } },
203
- _react2.default.createElement(_HiChip2.default, { label: length, classes: { root: classes.badgeRoot } })
207
+ 'div',
208
+ null,
209
+ _react2.default.createElement(
210
+ 'span',
211
+ { id: 'sticky-label', className: classes.label },
212
+ label
213
+ ),
214
+ _react2.default.createElement(
215
+ 'span',
216
+ { id: 'sticky-badge', style: { position: 'relative' } },
217
+ _react2.default.createElement(_HiChip2.default, { label: length, classes: { root: classes.badgeRoot } })
218
+ )
204
219
  ),
205
220
  _react2.default.createElement(
206
221
  _Button2.default,
@@ -287,10 +302,6 @@ HiStickyRow.propTypes = process.env.NODE_ENV !== "production" ? {
287
302
  * Objet contenant les éléments textuels du composant
288
303
  */
289
304
  translations: _propTypes2.default.object.isRequired,
290
- /**
291
- * Valeur de la ligne
292
- */
293
- value: _propTypes2.default.string,
294
305
  /**
295
306
  * Taille du tableau (L/M/S),
296
307
  * définit l'espace entre les cellules et leurs tailles par default
@@ -221,27 +221,9 @@ var HiTable = function (_React$Component) {
221
221
 
222
222
  _this.state = {
223
223
  dateUpdate: Date.now(),
224
- isScrollToBottom: false,
225
- groupByIds: {}
224
+ isScrollToBottom: false
226
225
  };
227
226
 
228
- // create associative array (object) with sticky row key & its values
229
- // => used for sticky row badges
230
- if (props.groupBy) {
231
- props.dataSource.map(function (row) {
232
- var value = row.datas[props.groupBy].value;
233
- var date = new Date(value);
234
-
235
- if (date instanceof Date && isFinite(date)) {
236
- value = value.substr(0, 10);
237
- }
238
- if (!_this.state.groupByIds.hasOwnProperty(value)) {
239
- _this.state.groupByIds[value] = [];
240
- }
241
- _this.state.groupByIds[value].push(row.datas);
242
- });
243
- }
244
-
245
227
  // Orderable
246
228
  _this.openOrderColumnsMenu = _this.openOrderColumnsMenu.bind(_this);
247
229
  _this.closeOrderColumnsMenu = _this.closeOrderColumnsMenu.bind(_this);
@@ -313,8 +295,6 @@ var HiTable = function (_React$Component) {
313
295
  }, {
314
296
  key: 'componentDidUpdate',
315
297
  value: function componentDidUpdate(prevProps, prevState, prevContext) {
316
- var _this2 = this;
317
-
318
298
  this.wrapperScrollOffset = this.wrapperDiv.scrollWidth - this.wrapperDiv.offsetWidth;
319
299
 
320
300
  // If orderedColumns has change, possibly the sticky cells has changed too
@@ -342,28 +322,10 @@ var HiTable = function (_React$Component) {
342
322
  // Only if needed
343
323
  if (this.props.dataSource.length > prevProps.dataSource.length || this.props.dense !== prevProps.dense || this.props.sortedColumnId !== prevProps.sortedColumnId || this.props.sortDirection !== prevProps.sortDirection) {
344
324
  this.updateStickyRowsPosition();
345
- if (this.props.dataSource.length > prevProps.dataSource.length) {
325
+ if (this.props.dataSource.length !== prevProps.dataSource.length) {
346
326
  this.handleStickyRowPositions();
347
327
  }
348
328
  }
349
- if (this.props.dataSource.length > prevProps.dataSource.length && this.props.groupBy) {
350
- // create associative array (object) with sticky row key & its values
351
- // => used for sticky row badges
352
- var groupByIds = {};
353
- this.props.dataSource.map(function (row) {
354
- var value = row.datas[_this2.props.groupBy].value;
355
- var date = new Date(value);
356
-
357
- if (date instanceof Date && isFinite(date)) {
358
- value = value.substr(0, 10);
359
- }
360
- if (!groupByIds.hasOwnProperty(value)) {
361
- groupByIds[value] = [];
362
- }
363
- groupByIds[value].push(row.datas);
364
- });
365
- this.setState({ groupByIds: groupByIds });
366
- }
367
329
 
368
330
  this.isScrollToBottom(this.scrollTop === this.tBody.scrollHeight - this.tBody.offsetHeight);
369
331
 
@@ -375,7 +337,7 @@ var HiTable = function (_React$Component) {
375
337
  }, {
376
338
  key: 'updateStickyRowsPosition',
377
339
  value: function updateStickyRowsPosition() {
378
- var _this3 = this;
340
+ var _this2 = this;
379
341
 
380
342
  var rowHeight = this.props.dense ? cst.CELL_HEIGHT_DENSE : cst.CELL_HEIGHT;
381
343
  this.groupByRowsPositions = [];
@@ -384,7 +346,7 @@ var HiTable = function (_React$Component) {
384
346
  var stickyRows = tableBody.getElementsByClassName('stickyGroupBy');
385
347
  if (stickyRows.length > 0) {
386
348
  Array.prototype.filter.call(stickyRows, function (stickyRow) {
387
- _this3.groupByRowsPositions.push(stickyRow.nextSibling.nextSibling.offsetTop - rowHeight);
349
+ _this2.groupByRowsPositions.push(stickyRow.nextSibling.nextSibling.offsetTop - rowHeight);
388
350
  });
389
351
  }
390
352
  }
@@ -509,7 +471,7 @@ var HiTable = function (_React$Component) {
509
471
  }, {
510
472
  key: 'handleStickyRowPositions',
511
473
  value: function handleStickyRowPositions() {
512
- var _this4 = this;
474
+ var _this3 = this;
513
475
 
514
476
  var tableBody = document.getElementById(this.props.tabId + '-body');
515
477
  var stickyRows = tableBody.getElementsByClassName('stickyGroupBy');
@@ -517,14 +479,14 @@ var HiTable = function (_React$Component) {
517
479
  if (stickyRows.length > 0) {
518
480
  Array.prototype.filter.call(stickyRows, function (stickyRow, index) {
519
481
  var fakeTr = stickyRow.nextSibling;
520
- if (tableBody.scrollTop > _this4.groupByRowsPositions[index]) {
482
+ if (tableBody.scrollTop > _this3.groupByRowsPositions[index]) {
521
483
  // Calcul de la position du 'pinned' item
522
484
  // positionnement juste en dessous du header
523
485
  if (typeof stickyRows[index + 1] === 'undefined' || tableBody.scrollTop < stickyRows[index + 1].offsetTop) {
524
486
  // Si la prochaine ligne est aussi un 'pinned' item,
525
487
  // il pousse le précédent vers le haut
526
- if (typeof _this4.groupByRowsPositions[index + 1] !== 'undefined' && _this4.groupByRowsPositions[index + 1] - tableBody.scrollTop < rowHeight - 10) {
527
- stickyRow.style.top = tableBody.scrollTop + _this4.groupByRowsPositions[index + 1] - tableBody.scrollTop - rowHeight + '\n px';
488
+ if (typeof _this3.groupByRowsPositions[index + 1] !== 'undefined' && _this3.groupByRowsPositions[index + 1] - tableBody.scrollTop < rowHeight - 10) {
489
+ stickyRow.style.top = tableBody.scrollTop + _this3.groupByRowsPositions[index + 1] - tableBody.scrollTop - rowHeight + '\n px';
528
490
  } else {
529
491
  stickyRow.style.top = tableBody.scrollTop + 'px';
530
492
  }
@@ -533,13 +495,13 @@ var HiTable = function (_React$Component) {
533
495
  // Repositionnement des éléments dans une row en position absolute
534
496
  stickyRow.style.position = 'absolute';
535
497
  fakeTr.style.display = 'inline-block';
536
- stickyRow.style.height = _this4.props.dense ? cst.CELL_HEIGHT_DENSE - 8 + 'px' : cst.CELL_HEIGHT - 8 + 'px';
537
- stickyRow.querySelector('button').style.maxHeight = _this4.props.dense ? cst.CELL_HEIGHT_DENSE - 16 + 'px' : cst.CELL_HEIGHT - 16 + 'px';
538
- stickyRow.querySelector('button').style.minHeight = _this4.props.dense ? cst.CELL_HEIGHT_DENSE - 16 + 'px' : cst.CELL_HEIGHT - 16 + 'px';
498
+ stickyRow.style.height = _this3.props.dense ? cst.CELL_HEIGHT_DENSE - 8 + 'px' : cst.CELL_HEIGHT - 8 + 'px';
499
+ stickyRow.querySelector('button').style.maxHeight = _this3.props.dense ? cst.CELL_HEIGHT_DENSE - 16 + 'px' : cst.CELL_HEIGHT - 16 + 'px';
500
+ stickyRow.querySelector('button').style.minHeight = _this3.props.dense ? cst.CELL_HEIGHT_DENSE - 16 + 'px' : cst.CELL_HEIGHT - 16 + 'px';
539
501
  stickyRow.querySelector('button').style.top = '-3px';
540
- stickyRow.querySelector('#stickyRowContent').style.top = !_this4.props.dense ? '4px' : '-3px';
541
- stickyRow.querySelector('td').style.height = _this4.props.dense ? cst.CELL_HEIGHT_DENSE - 8 + 'px' : cst.CELL_HEIGHT - 8 + 'px';
542
- if (_this4.props.dense) {
502
+ stickyRow.querySelector('#stickyRowContent').style.top = !_this3.props.dense ? '4px' : '-3px';
503
+ stickyRow.querySelector('td').style.height = _this3.props.dense ? cst.CELL_HEIGHT_DENSE - 8 + 'px' : cst.CELL_HEIGHT - 8 + 'px';
504
+ if (_this3.props.dense) {
543
505
  stickyRow.querySelector('button').style.top = '0px';
544
506
  stickyRow.querySelector('button span').style.position = 'relative';
545
507
  stickyRow.querySelector('button span').style.top = '-4px';
@@ -551,13 +513,13 @@ var HiTable = function (_React$Component) {
551
513
  stickyRow.style.position = 'relative';
552
514
  stickyRow.style.top = '0px';
553
515
  fakeTr.style.display = 'none';
554
- stickyRow.style.height = _this4.props.dense ? cst.CELL_HEIGHT_DENSE + 'px' : cst.CELL_HEIGHT + 'px';
516
+ stickyRow.style.height = _this3.props.dense ? cst.CELL_HEIGHT_DENSE + 'px' : cst.CELL_HEIGHT + 'px';
555
517
  stickyRow.querySelector('#sticky-badge').style.top = '0px';
556
518
  stickyRow.querySelector('#stickyRowContent').style.top = '2px';
557
- stickyRow.querySelector('td').style.height = _this4.props.dense ? cst.CELL_HEIGHT_DENSE + 'px' : cst.CELL_HEIGHT + 'px';
558
- stickyRow.querySelector('button').style.maxHeight = _this4.props.dense ? cst.CELL_HEIGHT_DENSE - 2 + 'px' : cst.CELL_HEIGHT - 8 + 'px';
559
- stickyRow.querySelector('button').style.minHeight = _this4.props.dense ? cst.CELL_HEIGHT_DENSE - 2 + 'px' : cst.CELL_HEIGHT - 8 + 'px';
560
- if (_this4.props.dense) {
519
+ stickyRow.querySelector('td').style.height = _this3.props.dense ? cst.CELL_HEIGHT_DENSE + 'px' : cst.CELL_HEIGHT + 'px';
520
+ stickyRow.querySelector('button').style.maxHeight = _this3.props.dense ? cst.CELL_HEIGHT_DENSE - 2 + 'px' : cst.CELL_HEIGHT - 8 + 'px';
521
+ stickyRow.querySelector('button').style.minHeight = _this3.props.dense ? cst.CELL_HEIGHT_DENSE - 2 + 'px' : cst.CELL_HEIGHT - 8 + 'px';
522
+ if (_this3.props.dense) {
561
523
  stickyRow.querySelector('button span').style.top = '0px';
562
524
  }
563
525
  }
@@ -572,7 +534,7 @@ var HiTable = function (_React$Component) {
572
534
  }, {
573
535
  key: 'placeHorizontalFloatingElement',
574
536
  value: function placeHorizontalFloatingElement() {
575
- var _this5 = this;
537
+ var _this4 = this;
576
538
 
577
539
  // live datas notification
578
540
  if (this.liveDataSpan) {
@@ -581,7 +543,7 @@ var HiTable = function (_React$Component) {
581
543
 
582
544
  // Replace left padding cells
583
545
  [].concat((0, _toConsumableArray3.default)(this.tBodyLeftPaddingElements), [this.tHeadLeftPadding]).forEach(function (element) {
584
- element.style.left = _this5.scrollLeft + 'px';
546
+ element.style.left = _this4.scrollLeft + 'px';
585
547
  });
586
548
 
587
549
  // TODO - FIX
@@ -590,15 +552,15 @@ var HiTable = function (_React$Component) {
590
552
 
591
553
  // Replace right padding cells
592
554
  [].concat((0, _toConsumableArray3.default)(this.tBodyRightPaddingElements), [this.tHeadRightPadding]).forEach(function (element) {
593
- element.style.right = Math.max(0, _this5.wrapperScrollOffset - _this5.scrollLeft - _this5.tBodyScrollbarWidth) + 'px';
555
+ element.style.right = Math.max(0, _this4.wrapperScrollOffset - _this4.scrollLeft - _this4.tBodyScrollbarWidth) + 'px';
594
556
  });
595
557
 
596
558
  // Replace first cells & add right shadows
597
559
  if (this.props.sticky) {
598
560
  var shadowRight = '1px 0px 0px 0px rgba(128, 128, 128, 0.32)';
599
561
  [].concat((0, _toConsumableArray3.default)(this.tBodyFirstElements), [this.tHeadFirst]).forEach(function (element) {
600
- element.style.left = _this5.scrollLeft + 'px';
601
- element.style['box-shadow'] = _this5.scrollLeft > 0 ? shadowRight : 'none';
562
+ element.style.left = _this4.scrollLeft + 'px';
563
+ element.style['box-shadow'] = _this4.scrollLeft > 0 ? shadowRight : 'none';
602
564
  });
603
565
  }
604
566
 
@@ -612,7 +574,7 @@ var HiTable = function (_React$Component) {
612
574
  var stickyRowContentDiv = tableBody.getElementsByClassName('stickyRowContent');
613
575
  if (stickyRowContentDiv.length > 0) {
614
576
  Array.prototype.filter.call(stickyRowContentDiv, function (div) {
615
- div.style.left = _this5.wrapperDiv.scrollLeft + (_this5.props.selectable ? 25 : 0) + 'px';
577
+ div.style.left = _this4.wrapperDiv.scrollLeft + (_this4.props.selectable ? 25 : 0) + 'px';
616
578
  });
617
579
  }
618
580
  }
@@ -677,7 +639,7 @@ var HiTable = function (_React$Component) {
677
639
  }, {
678
640
  key: 'render',
679
641
  value: function render() {
680
- var _this6 = this;
642
+ var _this5 = this;
681
643
 
682
644
  var _props = this.props,
683
645
  classes = _props.classes,
@@ -717,8 +679,7 @@ var HiTable = function (_React$Component) {
717
679
  detailRowsOptions = _props.detailRowsOptions;
718
680
  var _state = this.state,
719
681
  dateUpdate = _state.dateUpdate,
720
- isScrollToBottom = _state.isScrollToBottom,
721
- groupByIds = _state.groupByIds;
682
+ isScrollToBottom = _state.isScrollToBottom;
722
683
 
723
684
 
724
685
  var headerHeight = dense ? cst.CELL_HEADER_HEIGHT_DENSE : cst.CELL_HEADER_HEIGHT;
@@ -739,7 +700,7 @@ var HiTable = function (_React$Component) {
739
700
  id: tabId,
740
701
  className: classes.tableWrapper,
741
702
  ref: function ref(div) {
742
- return _this6.wrapperDiv = div;
703
+ return _this5.wrapperDiv = div;
743
704
  },
744
705
  onScroll: this.handleHorizontalScroll
745
706
  },
@@ -796,7 +757,6 @@ var HiTable = function (_React$Component) {
796
757
  translations: translations.tableBody,
797
758
  groupBy: groupBy,
798
759
  onClickNext: this.handleNextStickyRow,
799
- groupByIds: groupByIds,
800
760
  lookupColumns: lookupColumns,
801
761
  loading: loading,
802
762
  fixedColumnWidth: fixedColumnWidth,
@@ -822,6 +782,7 @@ var HiTable = function (_React$Component) {
822
782
  ),
823
783
  _react2.default.createElement(_HiTableContextMenu2.default, {
824
784
  tabId: tabId,
785
+ columns: columns,
825
786
  onSearch: this.props.onSearch,
826
787
  onRedirect: this.props.onRedirect
827
788
  }),
@@ -835,7 +796,7 @@ var HiTable = function (_React$Component) {
835
796
  color: 'primary',
836
797
  className: classes.backToTopButton,
837
798
  onClick: function onClick() {
838
- return _this6.scrollToTop();
799
+ return _this5.scrollToTop();
839
800
  }
840
801
  },
841
802
  _react2.default.createElement(_ArrowUp2.default, { className: classes.backToTopButtonArrow }),
@@ -5,6 +5,14 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.styles = undefined;
7
7
 
8
+ var _values = require('babel-runtime/core-js/object/values');
9
+
10
+ var _values2 = _interopRequireDefault(_values);
11
+
12
+ var _stringify = require('babel-runtime/core-js/json/stringify');
13
+
14
+ var _stringify2 = _interopRequireDefault(_stringify);
15
+
8
16
  var _defineProperty2 = require('babel-runtime/helpers/defineProperty');
9
17
 
10
18
  var _defineProperty3 = _interopRequireDefault(_defineProperty2);
@@ -51,6 +59,12 @@ var _classnames = require('classnames');
51
59
 
52
60
  var _classnames2 = _interopRequireDefault(_classnames);
53
61
 
62
+ var _moment = require('moment');
63
+
64
+ var _moment2 = _interopRequireDefault(_moment);
65
+
66
+ require('moment/locale/fr');
67
+
54
68
  var _styles = require('../styles');
55
69
 
56
70
  var _BodyRow = require('./BodyRow');
@@ -69,6 +83,10 @@ var _constants = require('./constants');
69
83
 
70
84
  var cst = _interopRequireWildcard(_constants);
71
85
 
86
+ var _lodash = require('lodash');
87
+
88
+ var _ = _interopRequireWildcard(_lodash);
89
+
72
90
  function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
73
91
 
74
92
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -132,7 +150,7 @@ var HiTableBody = function (_React$Component) {
132
150
  function HiTableBody(props) {
133
151
  (0, _classCallCheck3.default)(this, HiTableBody);
134
152
 
135
- var _this = (0, _possibleConstructorReturn3.default)(this, (HiTableBody.__proto__ || (0, _getPrototypeOf2.default)(HiTableBody)).call(this));
153
+ var _this = (0, _possibleConstructorReturn3.default)(this, (HiTableBody.__proto__ || (0, _getPrototypeOf2.default)(HiTableBody)).call(this, props));
136
154
 
137
155
  _this.buildIndicator = function (row) {
138
156
  var _this$props = _this.props,
@@ -165,17 +183,52 @@ var HiTableBody = function (_React$Component) {
165
183
 
166
184
  _this.state = {
167
185
  openedParentRowId: null,
168
- openedDetailsRowIdList: []
186
+ openedDetailsRowIdList: [],
187
+ dataSource: props.dataSource,
188
+ groupByIds: {}
169
189
  };
170
190
 
191
+ if (props.groupBy && props.dataSource) {
192
+ var groupByIds = {};
193
+ props.dataSource.map(function (row) {
194
+ var value = row.datas[props.groupBy].value;
195
+ if (!groupByIds.hasOwnProperty(value)) {
196
+ groupByIds[value] = [];
197
+ }
198
+ groupByIds[value].push(row.datas);
199
+ });
200
+ _this.state.groupByIds = groupByIds;
201
+ }
202
+
171
203
  _this.buildIndicator = _this.buildIndicator.bind(_this);
172
204
  _this.setOpenedParentRowId = _this.setOpenedParentRowId.bind(_this);
173
205
  _this.toggleOpenedDetailsRowId = _this.toggleOpenedDetailsRowId.bind(_this);
174
206
  _this.positionStickyRowNextButton = _this.positionStickyRowNextButton.bind(_this);
207
+
208
+ //Monkeypatch TableRow
209
+ /*var that = this;
210
+ TableRow.prototype.shouldComponentUpdate = function shouldComponentUpdate(nextProps, nextState){
211
+ return (this.state.hovered !== nextState.hovered || this.props.selected !== nextProps.selected) && true;
212
+ }*/
175
213
  return _this;
176
214
  }
177
215
 
178
216
  (0, _createClass3.default)(HiTableBody, [{
217
+ key: 'deepCompare',
218
+ value: function deepCompare(object, base) {
219
+ var that = this;
220
+ return _.transform(object, function (result, value, key) {
221
+ if (!_.isEqual(value, base[key])) {
222
+ result[key] = _.isObject(value) && _.isObject(base[key]) ? that.deepCompare(value, base[key]) : value;
223
+ }
224
+ }).length > 0;
225
+ }
226
+
227
+ /*shouldComponentUpdate(nextProps, nextState){
228
+ this.deepCompare(this.props,nextProps) || this.deepCompare(this.state,nextState);
229
+ }*/
230
+
231
+ }, {
179
232
  key: 'componentDidMount',
180
233
  value: function componentDidMount() {
181
234
  this.positionStickyRowNextButton();
@@ -185,6 +238,9 @@ var HiTableBody = function (_React$Component) {
185
238
  value: function componentDidUpdate(prevProps, prevState, prevContext) {
186
239
  this.positionStickyRowNextButton();
187
240
  }
241
+ }, {
242
+ key: 'setOpenedParentRowId',
243
+
188
244
 
189
245
  /**
190
246
  * Définit l'id de la ligne parente "ouverte" ou null
@@ -193,9 +249,6 @@ var HiTableBody = function (_React$Component) {
193
249
  *
194
250
  * @param row
195
251
  */
196
-
197
- }, {
198
- key: 'setOpenedParentRowId',
199
252
  value: function setOpenedParentRowId(row) {
200
253
  this.setState(function (prevState) {
201
254
  return {
@@ -225,7 +278,7 @@ var HiTableBody = function (_React$Component) {
225
278
  }
226
279
  button.parentElement.style.top = '4px';
227
280
  }
228
- var label = button.previousSibling.previousSibling;
281
+ var label = button.previousSibling;
229
282
  button.style.left = tableContainer.offsetWidth - label.offsetWidth - 48 - 160 + 'px';
230
283
  }
231
284
  });
@@ -272,7 +325,6 @@ var HiTableBody = function (_React$Component) {
272
325
  tabId = _props.tabId,
273
326
  columns = _props.columns,
274
327
  orderedColumns = _props.orderedColumns,
275
- dataSource = _props.dataSource,
276
328
  onRowClick = _props.onRowClick,
277
329
  selectable = _props.selectable,
278
330
  onSelect = _props.onSelect,
@@ -287,7 +339,6 @@ var HiTableBody = function (_React$Component) {
287
339
  translations = _props.translations,
288
340
  dateLocale = _props.dateLocale,
289
341
  numberLocale = _props.numberLocale,
290
- groupByIds = _props.groupByIds,
291
342
  sortedColumnId = _props.sortedColumnId,
292
343
  lookupColumns = _props.lookupColumns,
293
344
  loading = _props.loading,
@@ -296,7 +347,9 @@ var HiTableBody = function (_React$Component) {
296
347
  detailRowsOptions = _props.detailRowsOptions;
297
348
  var _state = this.state,
298
349
  openedParentRowId = _state.openedParentRowId,
299
- openedDetailsRowIdList = _state.openedDetailsRowIdList;
350
+ openedDetailsRowIdList = _state.openedDetailsRowIdList,
351
+ groupByIds = _state.groupByIds,
352
+ dataSource = _state.dataSource;
300
353
 
301
354
 
302
355
  var nbColumnsDisplayed = 0;
@@ -315,31 +368,21 @@ var HiTableBody = function (_React$Component) {
315
368
  // Gestion du sticky group by
316
369
  if (typeof groupBy !== 'undefined' && groupBy === sortedColumnId) {
317
370
  var currentGroupByValue = row.datas[groupBy].value;
318
- var date = new Date(currentGroupByValue);
319
- if (date instanceof Date && isFinite(date)) {
320
- currentGroupByValue = currentGroupByValue.substr(0, 10);
321
- }
371
+
322
372
  // TODO => condition for other columns type
323
373
  if (columns[groupBy].type === cst.TYPE_DATE) {
324
- if (index === 0 || currentGroupByValue !== stickyRowValue) {
325
- stickyRowValue = currentGroupByValue;
326
- var label = stickyRowValue;
327
- if (date instanceof Date && isFinite(date)) {
328
- label = new Date(label);
329
- var options = {
330
- year: 'numeric',
331
- month: 'long',
332
- weekday: 'long',
333
- day: 'numeric'
334
- };
335
- label = label.toLocaleString(dateLocale, options);
336
- label = label.charAt(0).toUpperCase() + label.substr(1);
337
- }
374
+
375
+ _moment2.default.locale(dateLocale);
376
+ var date = (0, _moment2.default)(currentGroupByValue);
377
+ var label = date.format('dddd D MMMM YYYY');
378
+
379
+ if (index === 0 || label !== stickyRowValue) {
380
+
381
+ stickyRowValue = label;
338
382
 
339
383
  tableRows.push(_react2.default.createElement(_HiStickyRow2.default, {
340
384
  key: 'sticky_row_' + row.rowId,
341
385
  dense: dense,
342
- value: stickyRowValue,
343
386
  label: label,
344
387
  length: groupByIds[currentGroupByValue].length,
345
388
  colSpan: nbColumnsDisplayed,
@@ -424,7 +467,9 @@ var HiTableBody = function (_React$Component) {
424
467
  sticky: sticky,
425
468
  isDetail: true,
426
469
  fixedColumnWidth: fixedColumnWidth,
427
- disableContextMenu: disableContextMenu
470
+ disableContextMenu: disableContextMenu,
471
+ dateLocale: dateLocale,
472
+ numberLocale: numberLocale
428
473
  };
429
474
 
430
475
  tableRows.push(_react2.default.createElement(_BodyRow2.default, (0, _extends3.default)({ key: row.rowId + '-' + detailRow.rowId }, detailRowProps)));
@@ -453,6 +498,31 @@ var HiTableBody = function (_React$Component) {
453
498
  })
454
499
  );
455
500
  }
501
+ }], [{
502
+ key: 'getDerivedStateFromProps',
503
+ value: function getDerivedStateFromProps(props, state) {
504
+ var nextState = {};
505
+ if (props.groupBy && props.dataSource && props.dataSource.length > 0) {
506
+ if ((0, _stringify2.default)(props.dataSource) !== (0, _stringify2.default)(state.dataSource)) {
507
+ var groupByIds = {};
508
+ props.dataSource.map(function (row) {
509
+ var value = row.datas[props.groupBy].value;
510
+ if (!groupByIds.hasOwnProperty(value)) {
511
+ groupByIds[value] = [];
512
+ }
513
+ groupByIds[value].push(row.datas);
514
+ });
515
+ nextState.groupByIds = groupByIds;
516
+ }
517
+ }
518
+ if ((0, _stringify2.default)(props.dataSource) !== (0, _stringify2.default)(state.dataSource)) {
519
+ nextState.dataSource = props.dataSource;
520
+ }
521
+ if ((0, _values2.default)(nextState).length > 0) {
522
+ return nextState;
523
+ }
524
+ return null;
525
+ }
456
526
  }]);
457
527
  return HiTableBody;
458
528
  }(_react2.default.Component);