@hipay/hipay-material-ui 2.0.0-beta.46 → 2.0.0-beta.47
Sign up to get free protection for your applications and to get access to all the features.
- package/HiCell/CellIcon.js +14 -6
- package/HiCell/CellNumeric.js +3 -2
- package/HiCell/CellRate.js +2 -1
- package/HiCell/CellSentinel.js +2 -1
- package/HiChip/HiChip.js +8 -8
- package/HiSelect/HiSelect.js +8 -2
- package/HiSelectNew/HiSelect.js +37 -5
- package/HiSelectableList/HiSelectableListItem.js +9 -3
- package/HiTable/HiCellBuilder.js +229 -0
- package/HiTable/HiTable.js +155 -0
- package/HiTable/HiTableBody.js +90 -0
- package/HiTable/HiTableHeader.js +162 -0
- package/HiTable/HiTableRow.js +154 -0
- package/HiTable/constants.js +145 -0
- package/HiTable/index.js +15 -0
- package/es/HiCell/CellIcon.js +14 -6
- package/es/HiCell/CellNumeric.js +3 -2
- package/es/HiCell/CellRate.js +2 -1
- package/es/HiCell/CellSentinel.js +2 -1
- package/es/HiChip/HiChip.js +10 -10
- package/es/HiSelect/HiSelect.js +8 -2
- package/es/HiSelectNew/HiSelect.js +34 -4
- package/es/HiSelectableList/HiSelectableListItem.js +9 -3
- package/es/HiTable/HiCellBuilder.js +181 -0
- package/es/HiTable/HiTable.js +114 -0
- package/es/HiTable/HiTableBody.js +56 -0
- package/es/HiTable/HiTableHeader.js +108 -0
- package/es/HiTable/HiTableRow.js +103 -0
- package/es/HiTable/constants.js +182 -0
- package/es/HiTable/index.js +1 -0
- package/es/index.js +1 -0
- package/es/utils/helpers.js +1 -1
- package/index.es.js +2 -1
- package/index.js +9 -1
- package/package.json +1 -1
- package/umd/hipay-material-ui.development.js +16018 -13677
- package/umd/hipay-material-ui.production.min.js +2 -2
- package/utils/helpers.js +1 -1
- package/yarn-error.log +0 -109
package/es/HiSelect/HiSelect.js
CHANGED
@@ -27,9 +27,11 @@ export const styles = theme => ({
|
|
27
27
|
position: 'relative'
|
28
28
|
},
|
29
29
|
popper: {
|
30
|
-
width: '100% !important',
|
31
30
|
zIndex: 1200
|
32
31
|
},
|
32
|
+
popperWidth: {
|
33
|
+
width: '100% !important'
|
34
|
+
},
|
33
35
|
paper: {
|
34
36
|
borderRadius: '0px 2px',
|
35
37
|
maxHeight: 440,
|
@@ -598,7 +600,7 @@ class HiSelect extends React.PureComponent {
|
|
598
600
|
}
|
599
601
|
|
600
602
|
const popperClass = classNames(classes.popper, {
|
601
|
-
[classes.
|
603
|
+
[classes.popperWidth]: !this.props.containerWidth
|
602
604
|
});
|
603
605
|
let allSelected = false;
|
604
606
|
|
@@ -612,6 +614,10 @@ class HiSelect extends React.PureComponent {
|
|
612
614
|
popperStyle = {
|
613
615
|
width: this.props.containerWidth
|
614
616
|
};
|
617
|
+
|
618
|
+
if (!staticPosition) {
|
619
|
+
popperStyle.position = 'absolute';
|
620
|
+
}
|
615
621
|
}
|
616
622
|
|
617
623
|
if (infiniteScroll && loadingMoreResults) {
|
@@ -15,6 +15,7 @@ import withStyles from '../styles/withStyles';
|
|
15
15
|
import { getNextItemSelectable, foldAccents } from '../utils/helpers';
|
16
16
|
import HiIcon from '../HiIcon';
|
17
17
|
import keycode from 'keycode';
|
18
|
+
import classNames from "classnames";
|
18
19
|
export const styles = theme => ({
|
19
20
|
root: {
|
20
21
|
backgroundColor: theme.palette.background2,
|
@@ -23,9 +24,15 @@ export const styles = theme => ({
|
|
23
24
|
position: 'relative'
|
24
25
|
},
|
25
26
|
popper: {
|
26
|
-
width: '100% !important',
|
27
27
|
zIndex: 1200
|
28
28
|
},
|
29
|
+
popperWidth: {
|
30
|
+
width: '100% !important'
|
31
|
+
},
|
32
|
+
popperRightAlign: {
|
33
|
+
right: 0,
|
34
|
+
left: 'unset!important'
|
35
|
+
},
|
29
36
|
paper: {
|
30
37
|
borderRadius: '0px 2px',
|
31
38
|
maxHeight: 480,
|
@@ -413,6 +420,22 @@ class HiSelect extends React.PureComponent {
|
|
413
420
|
itemList,
|
414
421
|
inputValue = this.buildInputValue(options, selectedItemIdList, loading)
|
415
422
|
} = buildSelectProps(options, selectedItemIdList, searchValue, loading);
|
423
|
+
let popperStyle = {};
|
424
|
+
|
425
|
+
if (this.props.containerWidth > 0) {
|
426
|
+
popperStyle = {
|
427
|
+
width: this.props.containerWidth
|
428
|
+
};
|
429
|
+
|
430
|
+
if (!staticPosition) {
|
431
|
+
popperStyle.position = 'absolute';
|
432
|
+
}
|
433
|
+
}
|
434
|
+
|
435
|
+
const popperClass = classNames(classes.popper, {
|
436
|
+
[classes.popperWidth]: !this.props.containerWidth,
|
437
|
+
[classes.popperRightAlign]: this.props.containerWidth
|
438
|
+
});
|
416
439
|
const content = React.createElement(ClickAwayListener, {
|
417
440
|
onClickAway: this.handleClickAway
|
418
441
|
}, React.createElement(Grow, {
|
@@ -477,13 +500,15 @@ class HiSelect extends React.PureComponent {
|
|
477
500
|
this.inputEl = el;
|
478
501
|
}
|
479
502
|
})), open && staticPosition ? React.createElement("div", {
|
480
|
-
|
503
|
+
style: popperStyle,
|
504
|
+
className: popperClass
|
481
505
|
}, content) : React.createElement(Popper, {
|
482
506
|
anchorEl: this.inputEl,
|
483
507
|
placement: "bottom-start",
|
484
508
|
open: open,
|
485
|
-
className:
|
486
|
-
disablePortal: true
|
509
|
+
className: popperClass,
|
510
|
+
disablePortal: true,
|
511
|
+
style: popperStyle
|
487
512
|
}, content));
|
488
513
|
}
|
489
514
|
|
@@ -517,6 +542,11 @@ HiSelect.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
517
542
|
*/
|
518
543
|
classes: PropTypes.object,
|
519
544
|
|
545
|
+
/**
|
546
|
+
* Popper width
|
547
|
+
*/
|
548
|
+
containerWidth: PropTypes.number,
|
549
|
+
|
520
550
|
/**
|
521
551
|
* Inactif
|
522
552
|
*/
|
@@ -76,6 +76,7 @@ export const styles = theme => ({
|
|
76
76
|
}, theme.typography.b1, {
|
77
77
|
fontWeight: 'inherit',
|
78
78
|
width: '100%',
|
79
|
+
minWidth: '50%',
|
79
80
|
padding: '5px 0',
|
80
81
|
'& strong': {
|
81
82
|
fontWeight: theme.typography.fontWeightMedium
|
@@ -102,11 +103,11 @@ export const styles = theme => ({
|
|
102
103
|
color: theme.palette.neutral.main,
|
103
104
|
fontWeight: theme.typography.fontWeightLight,
|
104
105
|
fontSize: 12,
|
105
|
-
whiteSpace: 'nowrap',
|
106
106
|
textOverflow: 'ellipsis',
|
107
107
|
textAlign: 'right',
|
108
108
|
margin: '4px 12px 4px 8px',
|
109
|
-
alignSelf: 'center'
|
109
|
+
alignSelf: 'center',
|
110
|
+
width: '100%'
|
110
111
|
}),
|
111
112
|
checkbox: {
|
112
113
|
marginTop: 3
|
@@ -378,6 +379,11 @@ HiSelectableListItem.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
378
379
|
*/
|
379
380
|
indeterminate: PropTypes.bool,
|
380
381
|
|
382
|
+
/**
|
383
|
+
* icon à afficher quand le composant a la prop indeterminate.
|
384
|
+
*/
|
385
|
+
indeterminateIcon: PropTypes.string,
|
386
|
+
|
381
387
|
/**
|
382
388
|
* Text d'information affiché à droite de l'élément
|
383
389
|
*/
|
@@ -440,5 +446,5 @@ HiSelectableListItem.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
440
446
|
} : {};
|
441
447
|
export default withStyles(styles, {
|
442
448
|
hiComponent: true,
|
443
|
-
name: '
|
449
|
+
name: 'HmuiHiSelectableListItem'
|
444
450
|
})(HiSelectableListItem);
|
@@ -0,0 +1,181 @@
|
|
1
|
+
// @inheritedComponent CellBuilder
|
2
|
+
import React from 'react';
|
3
|
+
import PropTypes from 'prop-types';
|
4
|
+
import TableCell from '@material-ui/core/TableCell';
|
5
|
+
import CellAddress from '@hipay/hipay-material-ui/HiCell/CellAddress';
|
6
|
+
import CellDate from '@hipay/hipay-material-ui/HiCell/CellDate';
|
7
|
+
import CellIcon from '@hipay/hipay-material-ui/HiCell/CellIcon';
|
8
|
+
import CellImage from '@hipay/hipay-material-ui/HiCell/CellImage';
|
9
|
+
import CellNumeric from '@hipay/hipay-material-ui/HiCell/CellNumeric';
|
10
|
+
import CellSentinel from '@hipay/hipay-material-ui/HiCell/CellSentinel';
|
11
|
+
import CellText from '@hipay/hipay-material-ui/HiCell/CellText';
|
12
|
+
import CellRate from '@hipay/hipay-material-ui/HiCell/CellRate';
|
13
|
+
import CellPinToAction from '@hipay/hipay-material-ui/HiCell/CellPinToAction';
|
14
|
+
import * as cst from './constants';
|
15
|
+
|
16
|
+
class HiCellBuilder extends React.PureComponent {
|
17
|
+
createCell(cell, rowdata, locale) {
|
18
|
+
if (rowdata.datas[cell.colId]) {
|
19
|
+
let datacell = rowdata.datas[cell.colId];
|
20
|
+
|
21
|
+
if (cell.data !== undefined) {
|
22
|
+
const refproperties = cell.data.find(el => el.id === datacell.value);
|
23
|
+
|
24
|
+
if (refproperties) {
|
25
|
+
Object.keys(refproperties).forEach(key => {
|
26
|
+
datacell[key] = refproperties[key];
|
27
|
+
});
|
28
|
+
} else {
|
29
|
+
datacell = undefined;
|
30
|
+
}
|
31
|
+
}
|
32
|
+
|
33
|
+
if (datacell) {
|
34
|
+
switch (cell.type) {
|
35
|
+
case cst.TYPE_NUMERIC:
|
36
|
+
return React.createElement(CellNumeric, {
|
37
|
+
value: datacell.value,
|
38
|
+
view: cell.view ? cell.view : cst.DEFAULT_VIEWS[cell.type],
|
39
|
+
precision: cell.precision,
|
40
|
+
currency: datacell.currency,
|
41
|
+
locale: datacell.locale || cell.locale || locale
|
42
|
+
});
|
43
|
+
|
44
|
+
case cst.TYPE_COUNTRY:
|
45
|
+
return React.createElement(CellImage, {
|
46
|
+
label: datacell.label,
|
47
|
+
shortLabel: datacell.id,
|
48
|
+
path: datacell.img,
|
49
|
+
size: datacell.size,
|
50
|
+
view: cell.view ? cell.view : cst.DEFAULT_VIEWS[cell.type]
|
51
|
+
});
|
52
|
+
|
53
|
+
case cst.TYPE_IMAGE:
|
54
|
+
return React.createElement(CellImage, {
|
55
|
+
label: datacell.label,
|
56
|
+
shortLabel: datacell.id,
|
57
|
+
path: datacell.img,
|
58
|
+
size: datacell.size,
|
59
|
+
view: cell.view ? cell.view : cst.DEFAULT_VIEWS[cell.type]
|
60
|
+
});
|
61
|
+
|
62
|
+
case cst.TYPE_RATE:
|
63
|
+
return React.createElement(CellRate, {
|
64
|
+
indicator: datacell.indicator,
|
65
|
+
isPositive: datacell.isPositive,
|
66
|
+
locale: datacell.locale || cell.locale || locale,
|
67
|
+
value: datacell.value,
|
68
|
+
trendchip: datacell.trendchip,
|
69
|
+
view: cell.view ? cell.view : cst.DEFAULT_VIEWS[cell.type]
|
70
|
+
});
|
71
|
+
|
72
|
+
case cst.TYPE_ADDRESS:
|
73
|
+
return React.createElement(CellAddress, {
|
74
|
+
city: datacell.city,
|
75
|
+
country: datacell.country,
|
76
|
+
isoCountry: datacell.isoCountry,
|
77
|
+
name: datacell.name,
|
78
|
+
postalCode: datacell.postalCode,
|
79
|
+
streetAddress: datacell.streetAddress,
|
80
|
+
view: cell.view ? cell.view : cst.DEFAULT_VIEWS[cell.type]
|
81
|
+
});
|
82
|
+
|
83
|
+
case cst.TYPE_DATE:
|
84
|
+
return React.createElement(CellDate, {
|
85
|
+
date: datacell.date,
|
86
|
+
displayTime: datacell.displayTime,
|
87
|
+
formatShort: datacell.formatShort,
|
88
|
+
locale: datacell.locale || cell.precision || locale,
|
89
|
+
view: cell.view ? cell.view : cst.DEFAULT_VIEWS[cell.type]
|
90
|
+
});
|
91
|
+
|
92
|
+
case cst.TYPE_ICON:
|
93
|
+
return React.createElement(CellIcon, {
|
94
|
+
color: datacell.color,
|
95
|
+
icon: datacell.icon,
|
96
|
+
label: datacell.label,
|
97
|
+
view: cell.view ? cell.view : cst.DEFAULT_VIEWS[cell.type],
|
98
|
+
size: cell.size
|
99
|
+
});
|
100
|
+
|
101
|
+
case cst.TYPE_THIRD_PARTY_SECURITY:
|
102
|
+
return React.createElement(CellIcon, {
|
103
|
+
color: datacell.color,
|
104
|
+
icon: datacell.icon,
|
105
|
+
label: datacell.label,
|
106
|
+
view: cell.view ? cell.view : cst.DEFAULT_VIEWS[cell.type],
|
107
|
+
size: cell.size
|
108
|
+
});
|
109
|
+
|
110
|
+
case cst.TYPE_SENTINEL:
|
111
|
+
return React.createElement(CellSentinel, {
|
112
|
+
automaticFraudReviewResult: datacell.automaticFraudReviewResult,
|
113
|
+
fraudResult: datacell.value,
|
114
|
+
hideFraudResult: datacell.hideFraudResult,
|
115
|
+
pendingManualAction: datacell.pendingManualAction,
|
116
|
+
score: datacell.score,
|
117
|
+
smartDecision: datacell.smartDecision,
|
118
|
+
view: cell.view ? cell.view : cst.DEFAULT_VIEWS[cell.type]
|
119
|
+
});
|
120
|
+
|
121
|
+
case cst.TYPE_PIN_TO_ACTION:
|
122
|
+
return React.createElement(CellPinToAction, {
|
123
|
+
number: datacell.number,
|
124
|
+
onClick: datacell.onClick
|
125
|
+
});
|
126
|
+
|
127
|
+
case cst.TYPE_ACCOUNT_NUMBER:
|
128
|
+
return React.createElement(CellText, {
|
129
|
+
label: datacell.value,
|
130
|
+
color: datacell.color,
|
131
|
+
ellipsis: datacell.ellipse
|
132
|
+
});
|
133
|
+
|
134
|
+
default:
|
135
|
+
return React.createElement(CellText, {
|
136
|
+
label: datacell.value,
|
137
|
+
color: datacell.color,
|
138
|
+
ellipsis: datacell.ellipse,
|
139
|
+
view: cell.view ? cell.view : cst.DEFAULT_VIEWS[cell.type]
|
140
|
+
});
|
141
|
+
}
|
142
|
+
}
|
143
|
+
}
|
144
|
+
|
145
|
+
return null;
|
146
|
+
}
|
147
|
+
|
148
|
+
render() {
|
149
|
+
const {
|
150
|
+
column,
|
151
|
+
data,
|
152
|
+
locale
|
153
|
+
} = this.props;
|
154
|
+
return React.createElement(TableCell, {
|
155
|
+
style: {
|
156
|
+
border: 'none',
|
157
|
+
paddingRight: '13px',
|
158
|
+
paddingLeft: '13px'
|
159
|
+
}
|
160
|
+
}, this.createCell(column, data, locale));
|
161
|
+
}
|
162
|
+
|
163
|
+
}
|
164
|
+
|
165
|
+
HiCellBuilder.propTypes = process.env.NODE_ENV !== "production" ? {
|
166
|
+
/**
|
167
|
+
* Propriétés de la colonne
|
168
|
+
*/
|
169
|
+
column: PropTypes.object.isRequired,
|
170
|
+
|
171
|
+
/**
|
172
|
+
* Données de la cellule
|
173
|
+
*/
|
174
|
+
data: PropTypes.object.isRequired,
|
175
|
+
|
176
|
+
/**
|
177
|
+
* Locale pour afficher les nombres et montants
|
178
|
+
*/
|
179
|
+
locale: PropTypes.string
|
180
|
+
} : {};
|
181
|
+
export default HiCellBuilder;
|
@@ -0,0 +1,114 @@
|
|
1
|
+
// @inheritedComponent Table
|
2
|
+
import React from 'react';
|
3
|
+
import PropTypes from 'prop-types';
|
4
|
+
import withStyles from '../styles/withStyles';
|
5
|
+
import Table from '@material-ui/core/Table';
|
6
|
+
import HiTableHeader from './HiTableHeader';
|
7
|
+
import HiTableBody from './HiTableBody';
|
8
|
+
|
9
|
+
const styles = theme => ({
|
10
|
+
root: {
|
11
|
+
backgroundColor: theme.palette.background3
|
12
|
+
}
|
13
|
+
});
|
14
|
+
|
15
|
+
class HiTable extends React.PureComponent {
|
16
|
+
constructor(props) {
|
17
|
+
super(props);
|
18
|
+
|
19
|
+
this.handleRequestSort = (event, property) => {
|
20
|
+
if (this.props.onSort) {
|
21
|
+
this.props.onSort(property);
|
22
|
+
}
|
23
|
+
};
|
24
|
+
|
25
|
+
this.handleRequestSort = this.handleRequestSort.bind(this);
|
26
|
+
}
|
27
|
+
|
28
|
+
render() {
|
29
|
+
const {
|
30
|
+
classes,
|
31
|
+
data,
|
32
|
+
columns,
|
33
|
+
locale,
|
34
|
+
sortable,
|
35
|
+
onRowClick,
|
36
|
+
dense,
|
37
|
+
order,
|
38
|
+
orderBy
|
39
|
+
} = this.props;
|
40
|
+
return React.createElement(Table, {
|
41
|
+
className: classes.root
|
42
|
+
}, React.createElement(HiTableHeader, {
|
43
|
+
columns: columns,
|
44
|
+
order: order,
|
45
|
+
orderBy: orderBy,
|
46
|
+
onRequestSort: this.handleRequestSort,
|
47
|
+
sortable: sortable,
|
48
|
+
dense: dense
|
49
|
+
}), React.createElement(HiTableBody, {
|
50
|
+
data: data,
|
51
|
+
columns: columns,
|
52
|
+
onClick: onRowClick,
|
53
|
+
dense: dense,
|
54
|
+
locale: locale
|
55
|
+
}));
|
56
|
+
}
|
57
|
+
|
58
|
+
}
|
59
|
+
|
60
|
+
HiTable.propTypes = process.env.NODE_ENV !== "production" ? {
|
61
|
+
/**
|
62
|
+
* Surcharge les classes du composant
|
63
|
+
*/
|
64
|
+
classes: PropTypes.object,
|
65
|
+
|
66
|
+
/**
|
67
|
+
* En-tête des données et leurs paramètres
|
68
|
+
*/
|
69
|
+
columns: PropTypes.object.isRequired,
|
70
|
+
|
71
|
+
/**
|
72
|
+
* Données du tableau
|
73
|
+
*/
|
74
|
+
data: PropTypes.array.isRequired,
|
75
|
+
|
76
|
+
/**
|
77
|
+
* Densité d'affichage (joue sur la hauteur des lignes)
|
78
|
+
*/
|
79
|
+
dense: PropTypes.bool,
|
80
|
+
|
81
|
+
/**
|
82
|
+
* Locale pour afficher les nombres et montants
|
83
|
+
*/
|
84
|
+
locale: PropTypes.string,
|
85
|
+
|
86
|
+
/**
|
87
|
+
* Fonction se déclanchant au clic sur une ligne
|
88
|
+
*/
|
89
|
+
onRowClick: PropTypes.func,
|
90
|
+
|
91
|
+
/**
|
92
|
+
* Fonction de trie des données
|
93
|
+
*/
|
94
|
+
onSort: PropTypes.func,
|
95
|
+
|
96
|
+
/**
|
97
|
+
* Sens du tri
|
98
|
+
*/
|
99
|
+
order: PropTypes.oneOf(['asc', 'desc']),
|
100
|
+
|
101
|
+
/**
|
102
|
+
* Id de la colonne trié
|
103
|
+
*/
|
104
|
+
orderBy: PropTypes.string,
|
105
|
+
|
106
|
+
/**
|
107
|
+
* Le tableau est-il triable ?
|
108
|
+
*/
|
109
|
+
sortable: PropTypes.bool
|
110
|
+
} : {};
|
111
|
+
export default withStyles(styles, {
|
112
|
+
hiComponent: true,
|
113
|
+
name: 'HmuiHiTable'
|
114
|
+
})(HiTable);
|
@@ -0,0 +1,56 @@
|
|
1
|
+
// @inheritedComponent TableBody
|
2
|
+
import React from 'react';
|
3
|
+
import PropTypes from 'prop-types';
|
4
|
+
import TableBody from '@material-ui/core/TableBody/TableBody';
|
5
|
+
import HiTableRow from './HiTableRow';
|
6
|
+
|
7
|
+
class HiTableBody extends React.PureComponent {
|
8
|
+
render() {
|
9
|
+
const {
|
10
|
+
columns,
|
11
|
+
data,
|
12
|
+
dense,
|
13
|
+
locale,
|
14
|
+
onClick
|
15
|
+
} = this.props;
|
16
|
+
return React.createElement(TableBody, null, data.map(n => {
|
17
|
+
return React.createElement(HiTableRow, {
|
18
|
+
columns: columns,
|
19
|
+
rowdata: n,
|
20
|
+
key: n.rowId,
|
21
|
+
onClick: onClick,
|
22
|
+
dense: dense,
|
23
|
+
locale: locale
|
24
|
+
});
|
25
|
+
}));
|
26
|
+
}
|
27
|
+
|
28
|
+
}
|
29
|
+
|
30
|
+
HiTableBody.propTypes = process.env.NODE_ENV !== "production" ? {
|
31
|
+
/**
|
32
|
+
* En-tête des données et leurs paramètres
|
33
|
+
*/
|
34
|
+
columns: PropTypes.object.isRequired,
|
35
|
+
|
36
|
+
/**
|
37
|
+
* Données du tableau
|
38
|
+
*/
|
39
|
+
data: PropTypes.array.isRequired,
|
40
|
+
|
41
|
+
/**
|
42
|
+
* Densité d'affichage (joue sur la hauteur des lignes)
|
43
|
+
*/
|
44
|
+
dense: PropTypes.bool,
|
45
|
+
|
46
|
+
/**
|
47
|
+
* Locale pour afficher les nombres et montants
|
48
|
+
*/
|
49
|
+
locale: PropTypes.string,
|
50
|
+
|
51
|
+
/**
|
52
|
+
* Fonction appelée au clic sur une ligne
|
53
|
+
*/
|
54
|
+
onClick: PropTypes.func
|
55
|
+
} : {};
|
56
|
+
export default HiTableBody;
|
@@ -0,0 +1,108 @@
|
|
1
|
+
// @inheritedComponent TableHeader
|
2
|
+
import React from 'react';
|
3
|
+
import PropTypes from 'prop-types';
|
4
|
+
import withStyles from '../styles/withStyles';
|
5
|
+
import TableCell from '@material-ui/core/TableCell';
|
6
|
+
import TableHead from '@material-ui/core/TableHead';
|
7
|
+
import TableRow from '@material-ui/core/TableRow';
|
8
|
+
import Tooltip from '@material-ui/core/Tooltip';
|
9
|
+
import TableSortLabel from '@material-ui/core/TableSortLabel';
|
10
|
+
import * as cst from './constants';
|
11
|
+
|
12
|
+
const styles = theme => ({
|
13
|
+
icon: {
|
14
|
+
color: '#00ADE9'
|
15
|
+
}
|
16
|
+
});
|
17
|
+
|
18
|
+
class HiTableHeader extends React.PureComponent {
|
19
|
+
constructor(...args) {
|
20
|
+
super(...args);
|
21
|
+
|
22
|
+
this.createSortHandler = property => event => {
|
23
|
+
this.props.onRequestSort(event, property);
|
24
|
+
};
|
25
|
+
}
|
26
|
+
|
27
|
+
render() {
|
28
|
+
const {
|
29
|
+
classes,
|
30
|
+
columns,
|
31
|
+
order,
|
32
|
+
orderBy,
|
33
|
+
sortable,
|
34
|
+
dense
|
35
|
+
} = this.props;
|
36
|
+
return React.createElement(TableHead, null, React.createElement(TableRow, {
|
37
|
+
style: {
|
38
|
+
height: dense ? cst.CELL_HEADER_HEIGHT_DENSE : cst.CELL_HEADER_HEIGHT,
|
39
|
+
whiteSpace: 'nowrap'
|
40
|
+
}
|
41
|
+
}, Object.keys(columns).map(function (key) {
|
42
|
+
const column = columns[key];
|
43
|
+
return React.createElement(TableCell, {
|
44
|
+
key: column.colId,
|
45
|
+
sortDirection: orderBy === column.colId ? order : false,
|
46
|
+
style: {
|
47
|
+
border: 'none',
|
48
|
+
borderBottom: orderBy === column.colId ? 'solid 1px #00ADE9' : 'none',
|
49
|
+
paddingRight: '13px',
|
50
|
+
paddingLeft: '13px'
|
51
|
+
},
|
52
|
+
numeric: !!cst.ALIGN_RIGHT_TYPES.includes(column.type)
|
53
|
+
}, sortable ? React.createElement(Tooltip, {
|
54
|
+
title: "Sort",
|
55
|
+
enterDelay: 300
|
56
|
+
}, React.createElement(TableSortLabel, {
|
57
|
+
active: orderBy === column.colId,
|
58
|
+
direction: order,
|
59
|
+
onClick: this.createSortHandler(column.colId),
|
60
|
+
classes: {
|
61
|
+
icon: classes.icon
|
62
|
+
}
|
63
|
+
}, column.label)) : column.label);
|
64
|
+
}, this)));
|
65
|
+
}
|
66
|
+
|
67
|
+
}
|
68
|
+
|
69
|
+
HiTableHeader.propTypes = process.env.NODE_ENV !== "production" ? {
|
70
|
+
/**
|
71
|
+
* Surcharge les classes du composant
|
72
|
+
*/
|
73
|
+
classes: PropTypes.object,
|
74
|
+
|
75
|
+
/**
|
76
|
+
* En-tête des données et leurs paramètres
|
77
|
+
*/
|
78
|
+
columns: PropTypes.object.isRequired,
|
79
|
+
|
80
|
+
/**
|
81
|
+
* Le tableau est-il triable ?
|
82
|
+
*/
|
83
|
+
dense: PropTypes.bool,
|
84
|
+
|
85
|
+
/**
|
86
|
+
* Fonction d'appel du trie des données
|
87
|
+
*/
|
88
|
+
onRequestSort: PropTypes.func.isRequired,
|
89
|
+
|
90
|
+
/**
|
91
|
+
* Sens du tri
|
92
|
+
*/
|
93
|
+
order: PropTypes.oneOf(['asc', 'desc']),
|
94
|
+
|
95
|
+
/**
|
96
|
+
* Id de la colonne trié
|
97
|
+
*/
|
98
|
+
orderBy: PropTypes.string,
|
99
|
+
|
100
|
+
/**
|
101
|
+
* Densité d'affichage (joue sur la hauteur des lignes)
|
102
|
+
*/
|
103
|
+
sortable: PropTypes.bool
|
104
|
+
} : {};
|
105
|
+
export default withStyles(styles, {
|
106
|
+
hiComponent: true,
|
107
|
+
name: 'HmuiHiTableHeader'
|
108
|
+
})(HiTableHeader);
|
@@ -0,0 +1,103 @@
|
|
1
|
+
// @inheritedComponent TableRow
|
2
|
+
import React from 'react';
|
3
|
+
import PropTypes from 'prop-types';
|
4
|
+
import withStyles from '../styles/withStyles';
|
5
|
+
import TableRow from '@material-ui/core/TableRow';
|
6
|
+
import HiCellBuilder from './HiCellBuilder';
|
7
|
+
import * as cst from './constants';
|
8
|
+
export const styles = theme => ({
|
9
|
+
row: {
|
10
|
+
'&:last-child': {
|
11
|
+
borderBottom: 'solid 1px #E4E7E8'
|
12
|
+
},
|
13
|
+
'&:first-child': {
|
14
|
+
borderTop: 'solid 1px #E4E7E8'
|
15
|
+
},
|
16
|
+
'&:hover': {
|
17
|
+
backgroundColor: `${theme.palette.action.hover} !important`
|
18
|
+
}
|
19
|
+
}
|
20
|
+
});
|
21
|
+
|
22
|
+
class HiTableRow extends React.PureComponent {
|
23
|
+
constructor(props) {
|
24
|
+
super(props);
|
25
|
+
this.handleClick = this.handleClick.bind(this);
|
26
|
+
}
|
27
|
+
|
28
|
+
handleClick(event, rowdata) {
|
29
|
+
if (this.props.onClick) {
|
30
|
+
this.props.onClick(event, rowdata);
|
31
|
+
}
|
32
|
+
}
|
33
|
+
|
34
|
+
render() {
|
35
|
+
const {
|
36
|
+
classes,
|
37
|
+
columns,
|
38
|
+
dense,
|
39
|
+
key,
|
40
|
+
locale,
|
41
|
+
rowdata
|
42
|
+
} = this.props;
|
43
|
+
return React.createElement(TableRow, {
|
44
|
+
className: classes.row,
|
45
|
+
hover: true,
|
46
|
+
onClick: event => this.handleClick(event, rowdata),
|
47
|
+
key: key,
|
48
|
+
style: {
|
49
|
+
height: dense ? cst.CELL_HEIGHT_DENSE : cst.CELL_HEIGHT
|
50
|
+
},
|
51
|
+
tabIndex: -1
|
52
|
+
}, Object.keys(columns).map(key => {
|
53
|
+
return React.createElement(HiCellBuilder, {
|
54
|
+
key: columns[key].colId,
|
55
|
+
column: columns[key],
|
56
|
+
data: rowdata,
|
57
|
+
locale: locale
|
58
|
+
});
|
59
|
+
}, this));
|
60
|
+
}
|
61
|
+
|
62
|
+
}
|
63
|
+
|
64
|
+
HiTableRow.propTypes = process.env.NODE_ENV !== "production" ? {
|
65
|
+
/**
|
66
|
+
* Surcharge les classes du composant
|
67
|
+
*/
|
68
|
+
classes: PropTypes.object,
|
69
|
+
|
70
|
+
/**
|
71
|
+
* En-tête des colonnes et leurs paramètres
|
72
|
+
*/
|
73
|
+
columns: PropTypes.object.isRequired,
|
74
|
+
|
75
|
+
/**
|
76
|
+
* Densité d'affichage (joue sur la hauteur des lignes)
|
77
|
+
*/
|
78
|
+
dense: PropTypes.bool,
|
79
|
+
|
80
|
+
/**
|
81
|
+
* Id de la ligne
|
82
|
+
*/
|
83
|
+
key: PropTypes.string,
|
84
|
+
|
85
|
+
/**
|
86
|
+
* Locale pour afficher les nombres et montants
|
87
|
+
*/
|
88
|
+
locale: PropTypes.string,
|
89
|
+
|
90
|
+
/**
|
91
|
+
* Action au clic sur une ligne
|
92
|
+
*/
|
93
|
+
onClick: PropTypes.func,
|
94
|
+
|
95
|
+
/**
|
96
|
+
* Données de la ligne
|
97
|
+
*/
|
98
|
+
rowdata: PropTypes.object.isRequired
|
99
|
+
} : {};
|
100
|
+
export default withStyles(styles, {
|
101
|
+
hiComponent: true,
|
102
|
+
name: 'HmuiHiTableRow'
|
103
|
+
})(HiTableRow);
|