@hipay/hipay-material-ui 1.0.0-beta.23 → 1.0.0-beta.26
Sign up to get free protection for your applications and to get access to all the features.
- package/HI-CHANGELOG.md +58 -39
- package/HiChip/HiChip.js +67 -8
- package/HiDatePicker/HiDateRangePicker.js +27 -13
- package/HiDatePicker/HiDateRangeSelector.js +13 -2
- package/HiForm/HiInput.js +1 -0
- package/HiForm/HiPasswordField.js +2 -2
- package/HiPins/HiPins.js +6 -4
- package/HiSelect/HiSelect.js +28 -20
- package/HiSelect/SelectInput.js +3 -8
- package/HiSelectableList/HiSelectableList.js +51 -49
- package/HiSelectableList/HiSelectableListItem.js +7 -5
- package/HiTable/BodyCellBuilder.js +25 -14
- package/HiTable/BodyCells/CellAccount.js +13 -15
- package/HiTable/BodyCells/CellAccountNumber.js +12 -3
- package/HiTable/BodyCells/CellAddress.js +12 -3
- package/HiTable/BodyCells/CellCountry.js +12 -3
- package/HiTable/BodyCells/CellDate.js +56 -52
- package/HiTable/BodyCells/CellIcon.js +12 -3
- package/HiTable/BodyCells/CellImage.js +12 -3
- package/HiTable/BodyCells/CellNumeric.js +12 -3
- package/HiTable/BodyCells/CellRate.js +12 -3
- package/HiTable/BodyCells/CellSentinel.js +17 -7
- package/HiTable/BodyCells/CellStatus.js +12 -3
- package/HiTable/BodyCells/CellText.js +75 -37
- package/HiTable/BodyCells/CellThirdPartySecurity.js +12 -3
- package/HiTable/BodyRow.js +12 -3
- package/HiTable/ColumnFilter.js +1 -4
- package/HiTable/HeaderCell.js +21 -11
- package/HiTable/HiStickyRow.js +27 -16
- package/HiTable/HiTable.js +30 -69
- package/HiTable/HiTableBody.js +99 -29
- package/HiTable/HiTableContextMenu.js +31 -16
- package/HiTable/HiTableFooter.js +9 -0
- package/HiTable/HiTableHead.js +15 -7
- package/HiTopBar/HiTopBar.js +6 -0
- package/README.md +72 -6
- package/es/HiChip/HiChip.js +81 -9
- package/es/HiDatePicker/HiDateRangePicker.js +25 -12
- package/es/HiDatePicker/HiDateRangeSelector.js +12 -2
- package/es/HiForm/HiInput.js +1 -0
- package/es/HiForm/HiPasswordField.js +2 -2
- package/es/HiPins/HiPins.js +4 -4
- package/es/HiSelect/HiSelect.js +25 -16
- package/es/HiSelect/SelectInput.js +3 -8
- package/es/HiSelectableList/HiSelectableList.js +51 -49
- package/es/HiSelectableList/HiSelectableListItem.js +7 -5
- package/es/HiTable/BodyCellBuilder.js +11 -4
- package/es/HiTable/BodyCells/CellAccount.js +7 -5
- package/es/HiTable/BodyCells/CellAccountNumber.js +6 -1
- package/es/HiTable/BodyCells/CellAddress.js +6 -1
- package/es/HiTable/BodyCells/CellCountry.js +6 -1
- package/es/HiTable/BodyCells/CellDate.js +35 -40
- package/es/HiTable/BodyCells/CellIcon.js +6 -1
- package/es/HiTable/BodyCells/CellImage.js +6 -1
- package/es/HiTable/BodyCells/CellNumeric.js +6 -1
- package/es/HiTable/BodyCells/CellRate.js +6 -1
- package/es/HiTable/BodyCells/CellSentinel.js +6 -1
- package/es/HiTable/BodyCells/CellStatus.js +6 -1
- package/es/HiTable/BodyCells/CellText.js +50 -20
- package/es/HiTable/BodyCells/CellThirdPartySecurity.js +6 -1
- package/es/HiTable/BodyRow.js +7 -2
- package/es/HiTable/ColumnFilter.js +1 -4
- package/es/HiTable/HeaderCell.js +16 -9
- package/es/HiTable/HiStickyRow.js +21 -14
- package/es/HiTable/HiTable.js +4 -40
- package/es/HiTable/HiTableBody.js +78 -26
- package/es/HiTable/HiTableContextMenu.js +28 -16
- package/es/HiTable/HiTableFooter.js +5 -0
- package/es/HiTable/HiTableHead.js +11 -6
- package/es/HiTopBar/HiTopBar.js +5 -0
- package/es/svg-icons/Cancel.js +2 -0
- package/es/svg-icons/HiBriefcaseRescue.js +15 -0
- package/es/svg-icons/index.js +2 -1
- package/es/utils/HiIconBuilder.js +6 -2
- package/index.es.js +1 -1
- package/index.js +1 -1
- package/package.json +7 -1
- package/svg-icons/Cancel.js +2 -0
- package/svg-icons/HiBriefcaseRescue.js +30 -0
- package/svg-icons/index.js +9 -0
- package/umd/hipay-material-ui.development.js +110915 -119592
- package/umd/hipay-material-ui.production.min.js +5 -5
- package/utils/HiIconBuilder.js +6 -2
@@ -1,11 +1,13 @@
|
|
1
|
+
import _JSON$stringify from 'babel-runtime/core-js/json/stringify';
|
1
2
|
import React from 'react';
|
2
3
|
import PropTypes from 'prop-types';
|
3
|
-
|
4
4
|
import Tooltip from '../../Tooltip';
|
5
5
|
import withStyles from '../../styles/withStyles';
|
6
6
|
import * as cst from '../constants';
|
7
|
+
import HiColoredLabel from '../../HiColoredLabel';
|
8
|
+
import { getContrastedTextColor } from '../../styles/colorManipulator';
|
7
9
|
|
8
|
-
export const styles =
|
10
|
+
export const styles = {
|
9
11
|
leftEllipsisSpan: {
|
10
12
|
display: 'inline-block',
|
11
13
|
overflow: 'hidden',
|
@@ -17,17 +19,16 @@ export const styles = theme => ({
|
|
17
19
|
display: 'inline-block',
|
18
20
|
overflow: 'hidden',
|
19
21
|
textOverflow: 'ellipsis',
|
20
|
-
whiteSpace: 'pre'
|
21
|
-
width: '100%'
|
22
|
+
whiteSpace: 'pre'
|
22
23
|
},
|
23
24
|
noEllipsisSpan: {
|
24
25
|
display: 'inline-block',
|
25
26
|
overflow: 'hidden',
|
26
27
|
whiteSpace: 'pre'
|
27
28
|
}
|
28
|
-
}
|
29
|
+
};
|
29
30
|
|
30
|
-
class CellText extends React.
|
31
|
+
class CellText extends React.Component {
|
31
32
|
|
32
33
|
constructor(props) {
|
33
34
|
super(props);
|
@@ -43,6 +44,10 @@ class CellText extends React.PureComponent {
|
|
43
44
|
this.buildEllipsis();
|
44
45
|
}
|
45
46
|
|
47
|
+
shouldComponentUpdate(nextProps, nextState) {
|
48
|
+
return _JSON$stringify(this.props) !== _JSON$stringify(nextProps) || _JSON$stringify(this.state) !== _JSON$stringify(nextState);
|
49
|
+
}
|
50
|
+
|
46
51
|
componentDidUpdate() {
|
47
52
|
this.buildEllipsis();
|
48
53
|
}
|
@@ -68,8 +73,9 @@ class CellText extends React.PureComponent {
|
|
68
73
|
|
69
74
|
/**
|
70
75
|
* Calcul l'espace pris par les 2 spans (les 2 moitiés du texte),
|
71
|
-
* si ils dépassent la largeur de la cellule
|
72
|
-
*
|
76
|
+
* si ils dépassent la largeur de la cellule :
|
77
|
+
* - diminue d'autant et proportionnellement chaque span
|
78
|
+
* - ajoute l'ellipse à gauche de la deuxième moitié du texte.
|
73
79
|
*/
|
74
80
|
if (this.props.ellipsis === cst.ELLIPSIS_MIDDLE) {
|
75
81
|
if (this.cellText !== null) {
|
@@ -89,13 +95,13 @@ class CellText extends React.PureComponent {
|
|
89
95
|
}
|
90
96
|
|
91
97
|
render() {
|
92
|
-
const { classes, value, ellipsis } = this.props;
|
98
|
+
const { classes, value, ellipsis, color } = this.props;
|
93
99
|
|
94
100
|
let start,
|
95
101
|
end,
|
96
102
|
valueElement = '';
|
97
103
|
|
98
|
-
|
104
|
+
const valueString = value.toString();
|
99
105
|
|
100
106
|
switch (ellipsis) {
|
101
107
|
case cst.ELLIPSIS_AFTER_FIRST_WORD:
|
@@ -108,13 +114,19 @@ class CellText extends React.PureComponent {
|
|
108
114
|
}
|
109
115
|
valueElement = React.createElement(
|
110
116
|
'div',
|
111
|
-
{
|
117
|
+
{
|
118
|
+
ref: div => {
|
112
119
|
this.cellText = div;
|
113
|
-
}
|
120
|
+
},
|
121
|
+
style: {
|
122
|
+
backgroundColor: color || 'inherit',
|
123
|
+
color: color ? getContrastedTextColor(color, '#4C4C4C', '#FFF') : 'inherit'
|
124
|
+
}
|
125
|
+
},
|
114
126
|
React.createElement(
|
115
127
|
'span',
|
116
128
|
{ className: classes.rightEllipsisSpan },
|
117
|
-
start
|
129
|
+
`${start} `
|
118
130
|
),
|
119
131
|
React.createElement(
|
120
132
|
'span',
|
@@ -130,9 +142,15 @@ class CellText extends React.PureComponent {
|
|
130
142
|
end = valueString.substr(Math.round(valueString.length / 2));
|
131
143
|
valueElement = React.createElement(
|
132
144
|
'div',
|
133
|
-
{
|
145
|
+
{
|
146
|
+
ref: div => {
|
134
147
|
this.cellText = div;
|
135
|
-
}
|
148
|
+
},
|
149
|
+
style: {
|
150
|
+
backgroundColor: color || 'inherit',
|
151
|
+
color: color ? getContrastedTextColor(color, '#4C4C4C', '#FFF') : 'inherit'
|
152
|
+
}
|
153
|
+
},
|
136
154
|
React.createElement(
|
137
155
|
'span',
|
138
156
|
{ className: classes.noEllipsisSpan },
|
@@ -147,7 +165,11 @@ class CellText extends React.PureComponent {
|
|
147
165
|
break;
|
148
166
|
|
149
167
|
case cst.ELLIPSIS_LEFT:
|
150
|
-
valueElement = React.createElement(
|
168
|
+
valueElement = color ? React.createElement(HiColoredLabel, {
|
169
|
+
className: classes.leftEllipsisSpan,
|
170
|
+
label: valueString,
|
171
|
+
color: color
|
172
|
+
}) : React.createElement(
|
151
173
|
'div',
|
152
174
|
{ className: classes.leftEllipsisSpan, style: { width: '100%' } },
|
153
175
|
valueString
|
@@ -156,7 +178,11 @@ class CellText extends React.PureComponent {
|
|
156
178
|
|
157
179
|
case cst.ELLIPSIS_RIGHT:
|
158
180
|
default:
|
159
|
-
valueElement = React.createElement(
|
181
|
+
valueElement = color ? React.createElement(HiColoredLabel, {
|
182
|
+
className: classes.rightEllipsisSpan,
|
183
|
+
label: valueString,
|
184
|
+
color: color
|
185
|
+
}) : React.createElement(
|
160
186
|
'div',
|
161
187
|
{ className: classes.rightEllipsisSpan, style: { width: '100%' } },
|
162
188
|
valueString
|
@@ -178,12 +204,16 @@ CellText.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
178
204
|
*/
|
179
205
|
classes: PropTypes.object,
|
180
206
|
/**
|
181
|
-
*
|
207
|
+
* Couleur du text & du background
|
182
208
|
*/
|
183
|
-
|
209
|
+
color: PropTypes.string,
|
184
210
|
/**
|
185
211
|
* Ellipsis
|
186
212
|
*/
|
187
|
-
ellipsis: PropTypes.oneOf(['left', 'right', 'middle', 'name', 'after-first-word'])
|
213
|
+
ellipsis: PropTypes.oneOf(['left', 'right', 'middle', 'name', 'after-first-word']),
|
214
|
+
/**
|
215
|
+
* Valeur à afficher
|
216
|
+
*/
|
217
|
+
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired
|
188
218
|
} : {};
|
189
219
|
export default withStyles(styles, { name: 'HmuiCellText' })(CellText);
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import _JSON$stringify from 'babel-runtime/core-js/json/stringify';
|
1
2
|
// @inheritedComponent CellLayout
|
2
3
|
|
3
4
|
import React from 'react';
|
@@ -19,7 +20,11 @@ export const styles = {
|
|
19
20
|
/**
|
20
21
|
* Cette cellule permet d'afficher une icône représentant le statut du 3DS.
|
21
22
|
*/
|
22
|
-
class CellThirdPartySecurity extends React.
|
23
|
+
class CellThirdPartySecurity extends React.Component {
|
24
|
+
|
25
|
+
shouldComponentUpdate(nextProps, nextState) {
|
26
|
+
return _JSON$stringify(this.props) !== _JSON$stringify(nextProps) || _JSON$stringify(this.state) !== _JSON$stringify(nextState);
|
27
|
+
}
|
23
28
|
|
24
29
|
render() {
|
25
30
|
const { classes, theme, label, value } = this.props;
|
package/es/HiTable/BodyRow.js
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
import _extends from 'babel-runtime/helpers/extends';
|
2
2
|
import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties';
|
3
|
+
import _JSON$stringify from 'babel-runtime/core-js/json/stringify';
|
3
4
|
|
4
5
|
// @inheritedComponent BodyCellBuilder
|
5
6
|
import React from 'react';
|
@@ -8,7 +9,7 @@ import classNames from 'classnames';
|
|
8
9
|
import { TableRow, TableCell } from 'material-ui/Table';
|
9
10
|
import { fade } from 'material-ui/styles/colorManipulator';
|
10
11
|
import BodyCellBuilder from './BodyCellBuilder';
|
11
|
-
import { withStyles
|
12
|
+
import { withStyles } from '../styles';
|
12
13
|
import * as cst from './constants';
|
13
14
|
|
14
15
|
export const styles = theme => ({
|
@@ -45,7 +46,7 @@ export const styles = theme => ({
|
|
45
46
|
}
|
46
47
|
});
|
47
48
|
|
48
|
-
class BodyRow extends React.
|
49
|
+
class BodyRow extends React.Component {
|
49
50
|
|
50
51
|
constructor(props) {
|
51
52
|
super();
|
@@ -67,6 +68,10 @@ class BodyRow extends React.PureComponent {
|
|
67
68
|
this.handleSelect = this.handleSelect.bind(this);
|
68
69
|
}
|
69
70
|
|
71
|
+
shouldComponentUpdate(nextProps, nextState) {
|
72
|
+
return _JSON$stringify(this.props) !== _JSON$stringify(nextProps) || _JSON$stringify(this.state) !== _JSON$stringify(nextState);
|
73
|
+
}
|
74
|
+
|
70
75
|
componentDidMount() {
|
71
76
|
// Live data animation
|
72
77
|
if (this.state.live) {
|
@@ -30,9 +30,6 @@ export const styles = theme => ({
|
|
30
30
|
padding: 10,
|
31
31
|
color: theme.palette.neutral.normal
|
32
32
|
},
|
33
|
-
menuItemSortable: {
|
34
|
-
paddingLeft: 8
|
35
|
-
},
|
36
33
|
menuItemFilter: _extends({}, theme.typography.body1, {
|
37
34
|
color: theme.palette.neutral.dark,
|
38
35
|
fontWeight: theme.typography.fontWeightMedium,
|
@@ -200,7 +197,7 @@ class ColumnFilter extends React.Component {
|
|
200
197
|
),
|
201
198
|
!!sortable && React.createElement(
|
202
199
|
'div',
|
203
|
-
|
200
|
+
null,
|
204
201
|
React.createElement(
|
205
202
|
MenuItem,
|
206
203
|
{
|
package/es/HiTable/HeaderCell.js
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
import _JSON$stringify from 'babel-runtime/core-js/json/stringify';
|
1
2
|
import _extends from 'babel-runtime/helpers/extends';
|
2
3
|
import React from 'react';
|
3
4
|
import PropTypes from 'prop-types';
|
@@ -78,18 +79,19 @@ export const styles = theme => ({
|
|
78
79
|
/**
|
79
80
|
* Construit une cellule d'entête avec le titre, clickable, triable et filtrable
|
80
81
|
*/
|
81
|
-
class HeaderCell extends React.
|
82
|
+
class HeaderCell extends React.Component {
|
82
83
|
|
83
84
|
constructor(props) {
|
84
85
|
super(props);
|
85
86
|
|
87
|
+
this.anchorEl = null;
|
88
|
+
|
86
89
|
this.onFilterClick = (event, columnDataset) => {
|
87
90
|
this.openFilterMenu(event, columnDataset);
|
88
91
|
};
|
89
92
|
|
90
93
|
this.state = {
|
91
94
|
filterOpen: false,
|
92
|
-
anchorEl: null,
|
93
95
|
menuFilters: []
|
94
96
|
};
|
95
97
|
|
@@ -100,16 +102,21 @@ class HeaderCell extends React.PureComponent {
|
|
100
102
|
this.handleFilterChange = this.handleFilterChange.bind(this);
|
101
103
|
}
|
102
104
|
|
105
|
+
shouldComponentUpdate(nextProps, nextState) {
|
106
|
+
return _JSON$stringify(nextProps) !== _JSON$stringify(this.props) || _JSON$stringify(nextState) !== _JSON$stringify(this.state);
|
107
|
+
}
|
108
|
+
|
103
109
|
openFilterMenu(event, columnDataset) {
|
104
110
|
this.setState({
|
105
111
|
filterOpen: true,
|
106
|
-
anchorEl: event.currentTarget,
|
107
112
|
menuFilters: columnDataset
|
108
113
|
});
|
114
|
+
this.anchorEl = event.currentTarget;
|
109
115
|
}
|
110
116
|
|
111
117
|
handleClose() {
|
112
|
-
this.setState({ filterOpen: false,
|
118
|
+
this.setState({ filterOpen: false, menuFilters: [] });
|
119
|
+
this.anchorEl = null;
|
113
120
|
}
|
114
121
|
|
115
122
|
/**
|
@@ -149,7 +156,7 @@ class HeaderCell extends React.PureComponent {
|
|
149
156
|
translations
|
150
157
|
} = this.props;
|
151
158
|
|
152
|
-
const { filterOpen,
|
159
|
+
const { filterOpen, menuFilters } = this.state;
|
153
160
|
|
154
161
|
const offset = selectable ? dense ? 32 : 40 : padding;
|
155
162
|
|
@@ -233,7 +240,6 @@ class HeaderCell extends React.PureComponent {
|
|
233
240
|
_filterable ? this.onFilterClick(event, filterSource) : this.handleSort(sortDirection === 'asc' ? 'desc' : 'asc');
|
234
241
|
}
|
235
242
|
},
|
236
|
-
align === 'right' && _icons,
|
237
243
|
React.createElement(
|
238
244
|
'span',
|
239
245
|
{
|
@@ -241,7 +247,7 @@ class HeaderCell extends React.PureComponent {
|
|
241
247
|
},
|
242
248
|
view !== 's' ? title : smallTitle || title
|
243
249
|
),
|
244
|
-
|
250
|
+
_icons
|
245
251
|
) : React.createElement(
|
246
252
|
'div',
|
247
253
|
{
|
@@ -268,7 +274,7 @@ class HeaderCell extends React.PureComponent {
|
|
268
274
|
filterValueList: menuFilters,
|
269
275
|
isOpen: filterOpen,
|
270
276
|
onClose: this.handleClose,
|
271
|
-
anchorEl: anchorEl,
|
277
|
+
anchorEl: this.anchorEl,
|
272
278
|
sortable: sortable,
|
273
279
|
onSort: this.handleSort,
|
274
280
|
onFilterChange: this.handleFilterChange,
|
@@ -288,7 +294,8 @@ HeaderCell.defaultProps = {
|
|
288
294
|
dense: false,
|
289
295
|
fixedColumnWidth: true,
|
290
296
|
sticky: true,
|
291
|
-
padding: 8
|
297
|
+
padding: 8,
|
298
|
+
translations: {}
|
292
299
|
};
|
293
300
|
HeaderCell.propTypes = process.env.NODE_ENV !== "production" ? {
|
294
301
|
/**
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import _JSON$stringify from 'babel-runtime/core-js/json/stringify';
|
1
2
|
import React from 'react';
|
2
3
|
import PropTypes from 'prop-types';
|
3
4
|
import { TableRow, TableCell } from 'material-ui/Table';
|
@@ -71,7 +72,11 @@ export const styles = theme => ({
|
|
71
72
|
|
72
73
|
export const ONCHANGE_ERROR_MESSAGE = 'Vous devez saisir la propriété "onChange" pour les lignes "selectable"';
|
73
74
|
|
74
|
-
class HiStickyRow extends React.
|
75
|
+
class HiStickyRow extends React.Component {
|
76
|
+
|
77
|
+
shouldComponentUpdate(nextProps, nextState) {
|
78
|
+
return _JSON$stringify(this.props) !== _JSON$stringify(nextProps) || _JSON$stringify(this.state) !== _JSON$stringify(nextState);
|
79
|
+
}
|
75
80
|
|
76
81
|
render() {
|
77
82
|
const { classes, dense, colSpan, label, length, index, translations, view } = this.props;
|
@@ -112,18 +117,24 @@ class HiStickyRow extends React.PureComponent {
|
|
112
117
|
className: 'stickyRowContent',
|
113
118
|
style: {
|
114
119
|
position: 'relative',
|
115
|
-
top: dense ? 3 : 2
|
120
|
+
top: dense ? 3 : 2,
|
121
|
+
display: 'flex',
|
122
|
+
alignItems: 'center'
|
116
123
|
}
|
117
124
|
},
|
118
125
|
React.createElement(
|
119
|
-
'
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
React.createElement(
|
126
|
+
'div',
|
127
|
+
null,
|
128
|
+
React.createElement(
|
129
|
+
'span',
|
130
|
+
{ id: 'sticky-label', className: classes.label },
|
131
|
+
label
|
132
|
+
),
|
133
|
+
React.createElement(
|
134
|
+
'span',
|
135
|
+
{ id: 'sticky-badge', style: { position: 'relative' } },
|
136
|
+
React.createElement(HiChip, { label: length, classes: { root: classes.badgeRoot } })
|
137
|
+
)
|
127
138
|
),
|
128
139
|
React.createElement(
|
129
140
|
Button,
|
@@ -204,10 +215,6 @@ HiStickyRow.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
204
215
|
* Objet contenant les éléments textuels du composant
|
205
216
|
*/
|
206
217
|
translations: PropTypes.object.isRequired,
|
207
|
-
/**
|
208
|
-
* Valeur de la ligne
|
209
|
-
*/
|
210
|
-
value: PropTypes.string,
|
211
218
|
/**
|
212
219
|
* Taille du tableau (L/M/S),
|
213
220
|
* définit l'espace entre les cellules et leurs tailles par default
|
package/es/HiTable/HiTable.js
CHANGED
@@ -146,27 +146,9 @@ class HiTable extends React.Component {
|
|
146
146
|
|
147
147
|
this.state = {
|
148
148
|
dateUpdate: Date.now(),
|
149
|
-
isScrollToBottom: false
|
150
|
-
groupByIds: {}
|
149
|
+
isScrollToBottom: false
|
151
150
|
};
|
152
151
|
|
153
|
-
// create associative array (object) with sticky row key & its values
|
154
|
-
// => used for sticky row badges
|
155
|
-
if (props.groupBy) {
|
156
|
-
props.dataSource.map(row => {
|
157
|
-
let value = row.datas[props.groupBy].value;
|
158
|
-
let date = new Date(value);
|
159
|
-
|
160
|
-
if (date instanceof Date && isFinite(date)) {
|
161
|
-
value = value.substr(0, 10);
|
162
|
-
}
|
163
|
-
if (!this.state.groupByIds.hasOwnProperty(value)) {
|
164
|
-
this.state.groupByIds[value] = [];
|
165
|
-
}
|
166
|
-
this.state.groupByIds[value].push(row.datas);
|
167
|
-
});
|
168
|
-
}
|
169
|
-
|
170
152
|
// Orderable
|
171
153
|
this.openOrderColumnsMenu = this.openOrderColumnsMenu.bind(this);
|
172
154
|
this.closeOrderColumnsMenu = this.closeOrderColumnsMenu.bind(this);
|
@@ -259,28 +241,10 @@ class HiTable extends React.Component {
|
|
259
241
|
// Only if needed
|
260
242
|
if (this.props.dataSource.length > prevProps.dataSource.length || this.props.dense !== prevProps.dense || this.props.sortedColumnId !== prevProps.sortedColumnId || this.props.sortDirection !== prevProps.sortDirection) {
|
261
243
|
this.updateStickyRowsPosition();
|
262
|
-
if (this.props.dataSource.length
|
244
|
+
if (this.props.dataSource.length !== prevProps.dataSource.length) {
|
263
245
|
this.handleStickyRowPositions();
|
264
246
|
}
|
265
247
|
}
|
266
|
-
if (this.props.dataSource.length > prevProps.dataSource.length && this.props.groupBy) {
|
267
|
-
// create associative array (object) with sticky row key & its values
|
268
|
-
// => used for sticky row badges
|
269
|
-
let groupByIds = {};
|
270
|
-
this.props.dataSource.map(row => {
|
271
|
-
let value = row.datas[this.props.groupBy].value;
|
272
|
-
let date = new Date(value);
|
273
|
-
|
274
|
-
if (date instanceof Date && isFinite(date)) {
|
275
|
-
value = value.substr(0, 10);
|
276
|
-
}
|
277
|
-
if (!groupByIds.hasOwnProperty(value)) {
|
278
|
-
groupByIds[value] = [];
|
279
|
-
}
|
280
|
-
groupByIds[value].push(row.datas);
|
281
|
-
});
|
282
|
-
this.setState({ groupByIds: groupByIds });
|
283
|
-
}
|
284
248
|
|
285
249
|
this.isScrollToBottom(this.scrollTop === this.tBody.scrollHeight - this.tBody.offsetHeight);
|
286
250
|
|
@@ -590,7 +554,7 @@ class HiTable extends React.Component {
|
|
590
554
|
detailRowsOptions
|
591
555
|
} = this.props;
|
592
556
|
|
593
|
-
const { dateUpdate, isScrollToBottom
|
557
|
+
const { dateUpdate, isScrollToBottom } = this.state;
|
594
558
|
|
595
559
|
const headerHeight = dense ? cst.CELL_HEADER_HEIGHT_DENSE : cst.CELL_HEADER_HEIGHT;
|
596
560
|
|
@@ -665,7 +629,6 @@ class HiTable extends React.Component {
|
|
665
629
|
translations: translations.tableBody,
|
666
630
|
groupBy: groupBy,
|
667
631
|
onClickNext: this.handleNextStickyRow,
|
668
|
-
groupByIds: groupByIds,
|
669
632
|
lookupColumns: lookupColumns,
|
670
633
|
loading: loading,
|
671
634
|
fixedColumnWidth: fixedColumnWidth,
|
@@ -691,6 +654,7 @@ class HiTable extends React.Component {
|
|
691
654
|
),
|
692
655
|
React.createElement(HiTableContextMenu, {
|
693
656
|
tabId: tabId,
|
657
|
+
columns: columns,
|
694
658
|
onSearch: this.props.onSearch,
|
695
659
|
onRedirect: this.props.onRedirect
|
696
660
|
}),
|
@@ -1,13 +1,18 @@
|
|
1
1
|
import _extends from 'babel-runtime/helpers/extends';
|
2
|
+
import _Object$values from 'babel-runtime/core-js/object/values';
|
3
|
+
import _JSON$stringify from 'babel-runtime/core-js/json/stringify';
|
2
4
|
import React from 'react';
|
3
5
|
import PropTypes from 'prop-types';
|
4
6
|
import { TableBody, TableRow } from 'material-ui/Table';
|
5
7
|
import classNames from 'classnames';
|
8
|
+
import moment from 'moment';
|
9
|
+
import 'moment/locale/fr';
|
6
10
|
import { withStyles } from '../styles';
|
7
11
|
import BodyRow from './BodyRow';
|
8
12
|
import ChildRow from './ChildRow';
|
9
13
|
import HiStickyRow from './HiStickyRow';
|
10
14
|
import * as cst from './constants';
|
15
|
+
import * as _ from 'lodash';
|
11
16
|
|
12
17
|
export const styles = theme => ({
|
13
18
|
tbody: {
|
@@ -62,7 +67,7 @@ export const styles = theme => ({
|
|
62
67
|
class HiTableBody extends React.Component {
|
63
68
|
|
64
69
|
constructor(props) {
|
65
|
-
super();
|
70
|
+
super(props);
|
66
71
|
|
67
72
|
this.buildIndicator = row => {
|
68
73
|
const { columns, dateLocale } = this.props;
|
@@ -92,15 +97,48 @@ class HiTableBody extends React.Component {
|
|
92
97
|
|
93
98
|
this.state = {
|
94
99
|
openedParentRowId: null,
|
95
|
-
openedDetailsRowIdList: []
|
100
|
+
openedDetailsRowIdList: [],
|
101
|
+
dataSource: props.dataSource,
|
102
|
+
groupByIds: {}
|
96
103
|
};
|
97
104
|
|
105
|
+
if (props.groupBy && props.dataSource) {
|
106
|
+
let groupByIds = {};
|
107
|
+
props.dataSource.map(row => {
|
108
|
+
let value = row.datas[props.groupBy].value;
|
109
|
+
if (!groupByIds.hasOwnProperty(value)) {
|
110
|
+
groupByIds[value] = [];
|
111
|
+
}
|
112
|
+
groupByIds[value].push(row.datas);
|
113
|
+
});
|
114
|
+
this.state.groupByIds = groupByIds;
|
115
|
+
}
|
116
|
+
|
98
117
|
this.buildIndicator = this.buildIndicator.bind(this);
|
99
118
|
this.setOpenedParentRowId = this.setOpenedParentRowId.bind(this);
|
100
119
|
this.toggleOpenedDetailsRowId = this.toggleOpenedDetailsRowId.bind(this);
|
101
120
|
this.positionStickyRowNextButton = this.positionStickyRowNextButton.bind(this);
|
121
|
+
|
122
|
+
//Monkeypatch TableRow
|
123
|
+
/*var that = this;
|
124
|
+
TableRow.prototype.shouldComponentUpdate = function shouldComponentUpdate(nextProps, nextState){
|
125
|
+
return (this.state.hovered !== nextState.hovered || this.props.selected !== nextProps.selected) && true;
|
126
|
+
}*/
|
127
|
+
}
|
128
|
+
|
129
|
+
deepCompare(object, base) {
|
130
|
+
var that = this;
|
131
|
+
return _.transform(object, (result, value, key) => {
|
132
|
+
if (!_.isEqual(value, base[key])) {
|
133
|
+
result[key] = _.isObject(value) && _.isObject(base[key]) ? that.deepCompare(value, base[key]) : value;
|
134
|
+
}
|
135
|
+
}).length > 0;
|
102
136
|
}
|
103
137
|
|
138
|
+
/*shouldComponentUpdate(nextProps, nextState){
|
139
|
+
this.deepCompare(this.props,nextProps) || this.deepCompare(this.state,nextState);
|
140
|
+
}*/
|
141
|
+
|
104
142
|
componentDidMount() {
|
105
143
|
this.positionStickyRowNextButton();
|
106
144
|
}
|
@@ -109,6 +147,30 @@ class HiTableBody extends React.Component {
|
|
109
147
|
this.positionStickyRowNextButton();
|
110
148
|
}
|
111
149
|
|
150
|
+
static getDerivedStateFromProps(props, state) {
|
151
|
+
let nextState = {};
|
152
|
+
if (props.groupBy && props.dataSource && props.dataSource.length > 0) {
|
153
|
+
if (_JSON$stringify(props.dataSource) !== _JSON$stringify(state.dataSource)) {
|
154
|
+
let groupByIds = {};
|
155
|
+
props.dataSource.map(row => {
|
156
|
+
let value = row.datas[props.groupBy].value;
|
157
|
+
if (!groupByIds.hasOwnProperty(value)) {
|
158
|
+
groupByIds[value] = [];
|
159
|
+
}
|
160
|
+
groupByIds[value].push(row.datas);
|
161
|
+
});
|
162
|
+
nextState.groupByIds = groupByIds;
|
163
|
+
}
|
164
|
+
}
|
165
|
+
if (_JSON$stringify(props.dataSource) !== _JSON$stringify(state.dataSource)) {
|
166
|
+
nextState.dataSource = props.dataSource;
|
167
|
+
}
|
168
|
+
if (_Object$values(nextState).length > 0) {
|
169
|
+
return nextState;
|
170
|
+
}
|
171
|
+
return null;
|
172
|
+
}
|
173
|
+
|
112
174
|
/**
|
113
175
|
* Définit l'id de la ligne parente "ouverte" ou null
|
114
176
|
* (remplace la ligne par un sous-tableau)
|
@@ -140,7 +202,7 @@ class HiTableBody extends React.Component {
|
|
140
202
|
}
|
141
203
|
button.parentElement.style.top = '4px';
|
142
204
|
}
|
143
|
-
const label = button.previousSibling
|
205
|
+
const label = button.previousSibling;
|
144
206
|
button.style.left = `${tableContainer.offsetWidth - label.offsetWidth - 48 - 160}px`;
|
145
207
|
}
|
146
208
|
});
|
@@ -177,7 +239,6 @@ class HiTableBody extends React.Component {
|
|
177
239
|
tabId,
|
178
240
|
columns,
|
179
241
|
orderedColumns,
|
180
|
-
dataSource,
|
181
242
|
onRowClick,
|
182
243
|
selectable,
|
183
244
|
onSelect,
|
@@ -192,7 +253,6 @@ class HiTableBody extends React.Component {
|
|
192
253
|
translations,
|
193
254
|
dateLocale,
|
194
255
|
numberLocale,
|
195
|
-
groupByIds,
|
196
256
|
sortedColumnId,
|
197
257
|
lookupColumns,
|
198
258
|
loading,
|
@@ -201,7 +261,7 @@ class HiTableBody extends React.Component {
|
|
201
261
|
detailRowsOptions
|
202
262
|
} = this.props;
|
203
263
|
|
204
|
-
const { openedParentRowId, openedDetailsRowIdList } = this.state;
|
264
|
+
const { openedParentRowId, openedDetailsRowIdList, groupByIds, dataSource } = this.state;
|
205
265
|
|
206
266
|
let nbColumnsDisplayed = 0;
|
207
267
|
orderedColumns.forEach(column => {
|
@@ -219,31 +279,21 @@ class HiTableBody extends React.Component {
|
|
219
279
|
// Gestion du sticky group by
|
220
280
|
if (typeof groupBy !== 'undefined' && groupBy === sortedColumnId) {
|
221
281
|
let currentGroupByValue = row.datas[groupBy].value;
|
222
|
-
|
223
|
-
if (date instanceof Date && isFinite(date)) {
|
224
|
-
currentGroupByValue = currentGroupByValue.substr(0, 10);
|
225
|
-
}
|
282
|
+
|
226
283
|
// TODO => condition for other columns type
|
227
284
|
if (columns[groupBy].type === cst.TYPE_DATE) {
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
weekday: 'long',
|
237
|
-
day: 'numeric'
|
238
|
-
};
|
239
|
-
label = label.toLocaleString(dateLocale, options);
|
240
|
-
label = label.charAt(0).toUpperCase() + label.substr(1);
|
241
|
-
}
|
285
|
+
|
286
|
+
moment.locale(dateLocale);
|
287
|
+
let date = moment(currentGroupByValue);
|
288
|
+
let label = date.format('dddd D MMMM YYYY');
|
289
|
+
|
290
|
+
if (index === 0 || label !== stickyRowValue) {
|
291
|
+
|
292
|
+
stickyRowValue = label;
|
242
293
|
|
243
294
|
tableRows.push(React.createElement(HiStickyRow, {
|
244
295
|
key: `sticky_row_${row.rowId}`,
|
245
296
|
dense: dense,
|
246
|
-
value: stickyRowValue,
|
247
297
|
label: label,
|
248
298
|
length: groupByIds[currentGroupByValue].length,
|
249
299
|
colSpan: nbColumnsDisplayed,
|
@@ -326,7 +376,9 @@ class HiTableBody extends React.Component {
|
|
326
376
|
sticky,
|
327
377
|
isDetail: true,
|
328
378
|
fixedColumnWidth,
|
329
|
-
disableContextMenu
|
379
|
+
disableContextMenu,
|
380
|
+
dateLocale,
|
381
|
+
numberLocale
|
330
382
|
};
|
331
383
|
|
332
384
|
tableRows.push(React.createElement(BodyRow, _extends({ key: `${row.rowId}-${detailRow.rowId}` }, detailRowProps)));
|