@hipay/hipay-material-ui 2.0.0-beta.54 → 2.0.0-beta.56
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.
- package/CHANGELOG.md +57 -0
- package/HiBreadcrumb/HiBreadcrumb.js +14 -4
- package/HiBreadcrumb/HiStep.js +4 -1
- package/HiBreadcrumb/HiStepContent.js +0 -1
- package/HiBreadcrumb/HiStepLabel.js +12 -4
- package/HiBreadcrumb/HiStepper.js +1 -1
- package/HiButton/HiButton.js +7 -1
- package/HiCell/CellIcon.js +4 -4
- package/HiCell/CellImage.js +28 -4
- package/HiCell/CellNumeric.js +1 -2
- package/HiCell/CellRate.js +6 -3
- package/HiCell/CellSentinel.js +7 -10
- package/HiCell/CellSentinelScore.js +4 -4
- package/HiCell/CellTextStyled.js +99 -0
- package/HiCell/index.js +9 -1
- package/HiChip/HiChip.js +1 -0
- package/HiDatePicker/Caption.js +8 -9
- package/HiDatePicker/HiDateRangePicker.js +37 -19
- package/HiDatePicker/HiDateRangeSelector.js +24 -22
- package/HiDatePicker/Overlays/CustomOverlayLayout.js +26 -17
- package/HiDatePicker/Overlays/MonthPickerOverlay.spec.js +1 -0
- package/HiDatePicker/Overlays/Overlay.js +15 -8
- package/HiDatePicker/Overlays/Overlay.spec.js +1 -0
- package/HiDatePicker/Overlays/TimePickerOverlay.js +2 -2
- package/HiDatePicker/Overlays/TimePickerOverlay.spec.js +1 -0
- package/HiDatePicker/Overlays/YearPickerOverlay.js +2 -4
- package/HiDatePicker/Overlays/YearPickerOverlay.spec.js +1 -0
- package/HiDatePicker/stylesheet.js +3 -2
- package/HiDotsStepper/HiDot.js +108 -0
- package/HiDotsStepper/HiDotsStepper.js +121 -0
- package/HiExpansionPanel/HiExpansionPanel.js +1 -1
- package/HiForm/HiAddressField.js +176 -0
- package/HiForm/HiSlider.js +352 -0
- package/HiForm/HiUpload.js +204 -0
- package/HiForm/HiUploadField.js +182 -0
- package/HiForm/HiUploadInput.js +459 -0
- package/HiForm/index.js +16 -0
- package/HiMap/HiMap.js +345 -0
- package/HiMap/HiMapExpand.js +210 -0
- package/HiMap/index.js +23 -0
- package/HiNotice/HiKPI.js +238 -0
- package/HiNotice/HiKPINotice.js +93 -0
- package/HiNotice/index.js +23 -0
- package/HiPdfReader/HiPdfReader.js +269 -0
- package/HiPdfReader/index.js +15 -0
- package/HiRadio/HiRadio.js +74 -0
- package/HiRadio/index.js +15 -0
- package/HiSelect/HiSelect.js +73 -84
- package/HiSelect/HiSuggestSelect.js +32 -5
- package/HiSelect/SelectInput.js +5 -0
- package/HiSelectNew/HiNestedSelectContent.js +5 -1
- package/HiSelectNew/HiSelect.js +174 -137
- package/HiSelectNew/HiSelectContent.js +0 -8
- package/HiSelectNew/HiSelectInput.js +8 -9
- package/HiSelectableList/HiSelectableList.js +32 -4
- package/HiSelectableList/HiSelectableListItem.js +62 -24
- package/HiTable/HiCellBuilder.js +42 -32
- package/HiTable/HiTableHeader.js +28 -21
- package/HiTable/constants.js +3 -1
- package/README.md +249 -98
- package/es/HiBreadcrumb/HiBreadcrumb.js +14 -4
- package/es/HiBreadcrumb/HiStep.js +4 -1
- package/es/HiBreadcrumb/HiStepContent.js +0 -1
- package/es/HiBreadcrumb/HiStepLabel.js +13 -4
- package/es/HiBreadcrumb/HiStepper.js +1 -1
- package/es/HiButton/HiButton.js +7 -0
- package/es/HiCell/CellIcon.js +5 -5
- package/es/HiCell/CellImage.js +25 -2
- package/es/HiCell/CellNumeric.js +1 -2
- package/es/HiCell/CellRate.js +6 -3
- package/es/HiCell/CellSentinel.js +7 -10
- package/es/HiCell/CellSentinelScore.js +4 -4
- package/es/HiCell/CellTextStyled.js +84 -0
- package/es/HiCell/index.js +2 -1
- package/es/HiChip/HiChip.js +1 -0
- package/es/HiDatePicker/Caption.js +7 -9
- package/es/HiDatePicker/HiDateRangePicker.js +41 -25
- package/es/HiDatePicker/HiDateRangeSelector.js +24 -22
- package/es/HiDatePicker/ListPicker.js +1 -1
- package/es/HiDatePicker/Overlays/CustomOverlayLayout.js +30 -19
- package/es/HiDatePicker/Overlays/MonthPickerOverlay.js +2 -2
- package/es/HiDatePicker/Overlays/MonthPickerOverlay.spec.js +1 -0
- package/es/HiDatePicker/Overlays/Overlay.js +16 -9
- package/es/HiDatePicker/Overlays/Overlay.spec.js +1 -0
- package/es/HiDatePicker/Overlays/TimePickerOverlay.js +2 -2
- package/es/HiDatePicker/Overlays/TimePickerOverlay.spec.js +1 -0
- package/es/HiDatePicker/Overlays/YearPickerOverlay.js +2 -4
- package/es/HiDatePicker/Overlays/YearPickerOverlay.spec.js +1 -0
- package/es/HiDatePicker/stylesheet.js +3 -2
- package/es/HiDotsStepper/HiDot.js +66 -0
- package/es/HiDotsStepper/HiDotsStepper.js +73 -0
- package/es/HiExpansionPanel/HiExpansionPanel.js +1 -1
- package/es/HiForm/HiAddressField.js +134 -0
- package/es/HiForm/HiSlider.js +302 -0
- package/es/HiForm/HiUpload.js +158 -0
- package/es/HiForm/HiUploadField.js +140 -0
- package/es/HiForm/HiUploadInput.js +411 -0
- package/es/HiForm/index.js +2 -0
- package/es/HiMap/HiMap.js +290 -0
- package/es/HiMap/HiMapExpand.js +162 -0
- package/es/HiMap/index.js +2 -0
- package/es/HiNotice/HiKPI.js +196 -0
- package/es/HiNotice/HiKPINotice.js +77 -0
- package/es/HiNotice/index.js +2 -0
- package/es/HiPdfReader/HiPdfReader.js +214 -0
- package/es/HiPdfReader/index.js +1 -0
- package/es/HiRadio/HiRadio.js +55 -0
- package/es/HiRadio/index.js +1 -0
- package/es/HiSelect/HiSelect.js +68 -78
- package/es/HiSelect/HiSuggestSelect.js +27 -6
- package/es/HiSelect/SelectInput.js +5 -0
- package/es/HiSelectNew/HiNestedSelectContent.js +5 -1
- package/es/HiSelectNew/HiSelect.js +156 -120
- package/es/HiSelectNew/HiSelectContent.js +0 -7
- package/es/HiSelectNew/HiSelectInput.js +8 -9
- package/es/HiSelectableList/HiSelectableList.js +28 -6
- package/es/HiSelectableList/HiSelectableListItem.js +71 -24
- package/es/HiTable/HiCellBuilder.js +140 -136
- package/es/HiTable/HiTableHeader.js +26 -18
- package/es/HiTable/constants.js +1 -0
- package/es/index.js +7 -0
- package/es/utils/helpers.js +1 -1
- package/index.es.js +8 -1
- package/index.js +57 -1
- package/package.json +6 -3
- package/umd/hipay-material-ui.development.js +42114 -35120
- package/umd/hipay-material-ui.production.min.js +2 -2
- package/utils/helpers.js +1 -1
package/es/HiCell/CellImage.js
CHANGED
|
@@ -17,12 +17,21 @@ export const styles = () => ({
|
|
|
17
17
|
alignItems: 'center'
|
|
18
18
|
}
|
|
19
19
|
});
|
|
20
|
+
|
|
21
|
+
const handleError = fallbackImage => e => {
|
|
22
|
+
if (fallbackImage) {
|
|
23
|
+
e.target.src = `${fallbackImage}`;
|
|
24
|
+
} else {
|
|
25
|
+
e.target.style.display = 'none';
|
|
26
|
+
}
|
|
27
|
+
};
|
|
20
28
|
/**
|
|
21
29
|
* Cette cellule permet d'afficher une image/logo (24px largeur) et un label (optionnel).
|
|
22
30
|
* En vue large, aucun tooltip n'est affiché
|
|
23
31
|
* En vue small (s) elle affiche uniquement l'image avec une largeur fixe.
|
|
24
32
|
*/
|
|
25
33
|
|
|
34
|
+
|
|
26
35
|
class CellImage extends React.PureComponent {
|
|
27
36
|
render() {
|
|
28
37
|
const {
|
|
@@ -31,7 +40,9 @@ class CellImage extends React.PureComponent {
|
|
|
31
40
|
label,
|
|
32
41
|
shortLabel,
|
|
33
42
|
view,
|
|
34
|
-
size
|
|
43
|
+
size,
|
|
44
|
+
fallbackImage,
|
|
45
|
+
title
|
|
35
46
|
} = this.props;
|
|
36
47
|
if (!path || path === '') return '';
|
|
37
48
|
return React.createElement("div", {
|
|
@@ -40,8 +51,10 @@ class CellImage extends React.PureComponent {
|
|
|
40
51
|
}, React.createElement("img", {
|
|
41
52
|
src: path,
|
|
42
53
|
alt: label,
|
|
54
|
+
title: title,
|
|
43
55
|
className: classes.img,
|
|
44
|
-
width: size
|
|
56
|
+
width: size,
|
|
57
|
+
onError: handleError(fallbackImage)
|
|
45
58
|
}), shortLabel && view === 'm' && React.createElement("span", {
|
|
46
59
|
className: classes.label
|
|
47
60
|
}, shortLabel), label && (view === 'l' || view === 'm' && !shortLabel) && React.createElement("span", {
|
|
@@ -61,6 +74,11 @@ CellImage.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
61
74
|
*/
|
|
62
75
|
classes: PropTypes.object,
|
|
63
76
|
|
|
77
|
+
/**
|
|
78
|
+
* Fallback image path
|
|
79
|
+
*/
|
|
80
|
+
fallbackImage: PropTypes.string,
|
|
81
|
+
|
|
64
82
|
/**
|
|
65
83
|
* Label
|
|
66
84
|
*/
|
|
@@ -81,6 +99,11 @@ CellImage.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
81
99
|
*/
|
|
82
100
|
size: PropTypes.number,
|
|
83
101
|
|
|
102
|
+
/**
|
|
103
|
+
* Title.
|
|
104
|
+
*/
|
|
105
|
+
title: PropTypes.string,
|
|
106
|
+
|
|
84
107
|
/**
|
|
85
108
|
* View (L/M/S)
|
|
86
109
|
*/
|
package/es/HiCell/CellNumeric.js
CHANGED
package/es/HiCell/CellRate.js
CHANGED
|
@@ -11,7 +11,8 @@ export const styles = theme => ({
|
|
|
11
11
|
justifyContent: 'center',
|
|
12
12
|
overflow: 'hidden',
|
|
13
13
|
position: 'relative',
|
|
14
|
-
textAlign: 'right'
|
|
14
|
+
textAlign: 'right',
|
|
15
|
+
paddingTop: '1em'
|
|
15
16
|
},
|
|
16
17
|
trendChipIcon: {
|
|
17
18
|
width: 14,
|
|
@@ -29,7 +30,6 @@ export const styles = theme => ({
|
|
|
29
30
|
color: theme.palette.neutral.main
|
|
30
31
|
},
|
|
31
32
|
spanIndicator: {
|
|
32
|
-
fontSize: 11,
|
|
33
33
|
float: 'right',
|
|
34
34
|
color: '#737373',
|
|
35
35
|
position: 'relative',
|
|
@@ -92,7 +92,10 @@ class CellRate extends React.PureComponent {
|
|
|
92
92
|
}, React.createElement("div", {
|
|
93
93
|
className: typeof indicator === 'undefined' && classes.rateDiv || ''
|
|
94
94
|
}, displayedRate, trendIcon), typeof indicator !== 'undefined' && React.createElement("span", {
|
|
95
|
-
className: classes.spanIndicator
|
|
95
|
+
className: classes.spanIndicator,
|
|
96
|
+
style: {
|
|
97
|
+
fontSize: view !== 'l' ? 10 : 11
|
|
98
|
+
}
|
|
96
99
|
}, indicator));
|
|
97
100
|
}
|
|
98
101
|
|
|
@@ -25,21 +25,18 @@ class CellSentinel extends React.PureComponent {
|
|
|
25
25
|
reviewer,
|
|
26
26
|
value
|
|
27
27
|
} = this.props;
|
|
28
|
-
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
const _letter = letter ? letter : _label[0];
|
|
32
|
-
|
|
28
|
+
const effectiveLabel = label || value;
|
|
29
|
+
const effectiveLetter = letter || effectiveLabel[0];
|
|
33
30
|
return React.createElement("div", {
|
|
34
31
|
className: classes.flexContent,
|
|
35
|
-
title: reviewer ? `${
|
|
32
|
+
title: reviewer ? `${effectiveLabel}\n${reviewer}` : effectiveLabel
|
|
36
33
|
}, React.createElement(HiColoredLabel, {
|
|
37
34
|
active: active,
|
|
38
35
|
classes: {
|
|
39
36
|
root: classes.label
|
|
40
37
|
},
|
|
41
38
|
color: color,
|
|
42
|
-
label:
|
|
39
|
+
label: effectiveLetter,
|
|
43
40
|
outlined: outlined
|
|
44
41
|
}));
|
|
45
42
|
}
|
|
@@ -51,14 +48,14 @@ CellSentinel.defaultProps = {
|
|
|
51
48
|
outlined: false
|
|
52
49
|
};
|
|
53
50
|
CellSentinel.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
51
|
+
active: PropTypes.bool,
|
|
54
52
|
classes: PropTypes.object,
|
|
55
|
-
value: PropTypes.string,
|
|
56
53
|
color: PropTypes.string,
|
|
57
54
|
label: PropTypes.string,
|
|
58
55
|
letter: PropTypes.string,
|
|
59
|
-
|
|
56
|
+
outlined: PropTypes.bool,
|
|
60
57
|
reviewer: PropTypes.string,
|
|
61
|
-
|
|
58
|
+
value: PropTypes.string
|
|
62
59
|
} : {};
|
|
63
60
|
export default withStyles(styles, {
|
|
64
61
|
name: 'HmuiCellSentinel'
|
|
@@ -15,7 +15,6 @@ export const sentinelColorById = {
|
|
|
15
15
|
AUTHENTICATE: '#484A4B',
|
|
16
16
|
FORCE_AUTHENTICATE: '#20272B',
|
|
17
17
|
PENDING: '#3987AD',
|
|
18
|
-
TO_BE_REVIEWED: '#FF8F01',
|
|
19
18
|
CHALLENGED: '#FF8F01',
|
|
20
19
|
BLOCKED: '#D50000',
|
|
21
20
|
ALLOWED: '#00AF01',
|
|
@@ -28,6 +27,7 @@ export const sentinelColorById = {
|
|
|
28
27
|
class CellSentinelScore extends React.PureComponent {
|
|
29
28
|
render() {
|
|
30
29
|
const {
|
|
30
|
+
active,
|
|
31
31
|
classes,
|
|
32
32
|
result,
|
|
33
33
|
value
|
|
@@ -35,7 +35,7 @@ class CellSentinelScore extends React.PureComponent {
|
|
|
35
35
|
return React.createElement("div", {
|
|
36
36
|
className: classes.flexContent
|
|
37
37
|
}, React.createElement(HiColoredLabel, {
|
|
38
|
-
active:
|
|
38
|
+
active: active,
|
|
39
39
|
classes: {
|
|
40
40
|
root: classes.label
|
|
41
41
|
},
|
|
@@ -47,10 +47,10 @@ class CellSentinelScore extends React.PureComponent {
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
CellSentinelScore.defaultProps = {
|
|
50
|
-
active: false
|
|
51
|
-
outlined: false
|
|
50
|
+
active: false
|
|
52
51
|
};
|
|
53
52
|
CellSentinelScore.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
53
|
+
active: PropTypes.bool,
|
|
54
54
|
classes: PropTypes.object,
|
|
55
55
|
result: PropTypes.string,
|
|
56
56
|
value: PropTypes.number
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import HiColoredLabel from '../HiColoredLabel';
|
|
4
|
+
const styleRoot = {
|
|
5
|
+
width: '100%',
|
|
6
|
+
height: 19,
|
|
7
|
+
margin: 'auto 0',
|
|
8
|
+
display: 'flex',
|
|
9
|
+
lineHeight: '15px'
|
|
10
|
+
};
|
|
11
|
+
const styleColorLabel = {
|
|
12
|
+
display: 'inline-block',
|
|
13
|
+
overflow: 'hidden',
|
|
14
|
+
textOverflow: 'ellipsis',
|
|
15
|
+
whiteSpace: 'pre'
|
|
16
|
+
};
|
|
17
|
+
const styleLabel = {
|
|
18
|
+
display: 'inline-block',
|
|
19
|
+
overflow: 'hidden',
|
|
20
|
+
textOverflow: 'ellipsis',
|
|
21
|
+
whiteSpace: 'pre',
|
|
22
|
+
width: '100%'
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* CellText functional component
|
|
26
|
+
* (don't includes complex ellipsis: middle, after-first-word...)
|
|
27
|
+
*
|
|
28
|
+
* @param label
|
|
29
|
+
* @param color
|
|
30
|
+
* @param value
|
|
31
|
+
* @param active
|
|
32
|
+
* @param title
|
|
33
|
+
* @returns {*}
|
|
34
|
+
* @constructor
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
const CellTextStyled = ({
|
|
38
|
+
label,
|
|
39
|
+
color,
|
|
40
|
+
value = '',
|
|
41
|
+
active = false,
|
|
42
|
+
title = ''
|
|
43
|
+
}) => {
|
|
44
|
+
const valueString = label ? label.toString() : value.toString();
|
|
45
|
+
return React.createElement("div", {
|
|
46
|
+
style: styleRoot,
|
|
47
|
+
title: title || valueString
|
|
48
|
+
}, color ? React.createElement(HiColoredLabel, {
|
|
49
|
+
style: styleColorLabel,
|
|
50
|
+
label: valueString,
|
|
51
|
+
color: color,
|
|
52
|
+
active: active
|
|
53
|
+
}) : React.createElement("div", {
|
|
54
|
+
style: styleLabel
|
|
55
|
+
}, valueString));
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
CellTextStyled.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
59
|
+
/**
|
|
60
|
+
* Will forward active prop to HiColoredLabel
|
|
61
|
+
*/
|
|
62
|
+
active: PropTypes.bool,
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Couleur du text & du background
|
|
66
|
+
*/
|
|
67
|
+
color: PropTypes.string,
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Label
|
|
71
|
+
*/
|
|
72
|
+
label: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Tooltip
|
|
76
|
+
*/
|
|
77
|
+
title: PropTypes.string,
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Value
|
|
81
|
+
*/
|
|
82
|
+
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
|
|
83
|
+
} : {};
|
|
84
|
+
export default CellTextStyled;
|
package/es/HiCell/index.js
CHANGED
|
@@ -5,4 +5,5 @@ export { default as CellImage } from './CellImage';
|
|
|
5
5
|
export { default as CellNumeric } from './CellNumeric';
|
|
6
6
|
export { default as CellRate } from './CellRate';
|
|
7
7
|
export { default as CellSentinel } from './CellSentinel';
|
|
8
|
-
export { default as CellText } from './CellText';
|
|
8
|
+
export { default as CellText } from './CellText';
|
|
9
|
+
export { default as CellTextStyled } from './CellTextStyled';
|
package/es/HiChip/HiChip.js
CHANGED
|
@@ -2,18 +2,16 @@ import _objectSpread from "@babel/runtime/helpers/objectSpread";
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import withStyles from '../styles/withStyles';
|
|
5
|
+
import HiButton from '../HiButton';
|
|
5
6
|
export const styles = theme => ({
|
|
6
7
|
caption: _objectSpread({
|
|
7
8
|
display: 'table-caption',
|
|
8
9
|
height: 40,
|
|
9
10
|
textAlign: 'center',
|
|
10
|
-
padding: '
|
|
11
|
+
padding: '4px 0'
|
|
11
12
|
}, theme.typography.body1, {
|
|
12
13
|
color: theme.palette.neutral.main
|
|
13
|
-
})
|
|
14
|
-
clickableSpan: {
|
|
15
|
-
cursor: 'pointer'
|
|
16
|
-
}
|
|
14
|
+
})
|
|
17
15
|
});
|
|
18
16
|
|
|
19
17
|
const Caption = ({
|
|
@@ -26,11 +24,11 @@ const Caption = ({
|
|
|
26
24
|
const months = localeUtils.getMonths();
|
|
27
25
|
return React.createElement("div", {
|
|
28
26
|
className: classes.caption
|
|
29
|
-
}, React.createElement(
|
|
30
|
-
|
|
27
|
+
}, React.createElement(HiButton, {
|
|
28
|
+
size: "small",
|
|
31
29
|
onClick: onMonthClick
|
|
32
|
-
}, months[date.getMonth()]),
|
|
33
|
-
|
|
30
|
+
}, months[date.getMonth()]), React.createElement(HiButton, {
|
|
31
|
+
size: "small",
|
|
34
32
|
onClick: onYearClick
|
|
35
33
|
}, date.getFullYear()));
|
|
36
34
|
};
|
|
@@ -21,7 +21,7 @@ import HiFormControl from '../HiForm/HiFormControl';
|
|
|
21
21
|
|
|
22
22
|
class HiDateRangePicker extends React.Component {
|
|
23
23
|
constructor(props) {
|
|
24
|
-
super();
|
|
24
|
+
super(props);
|
|
25
25
|
|
|
26
26
|
this.handleDayChange = (name, day) => {
|
|
27
27
|
if (day) {
|
|
@@ -56,8 +56,16 @@ class HiDateRangePicker extends React.Component {
|
|
|
56
56
|
};
|
|
57
57
|
|
|
58
58
|
this.onDayToClick = day => {
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
let change = moment(day) >= moment(this.props.from);
|
|
60
|
+
|
|
61
|
+
if (change && this.props.disableFutureDays && moment(day) > moment()) {
|
|
62
|
+
change = false;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (change) {
|
|
66
|
+
this.handleDayChange('to', day);
|
|
67
|
+
document.activeElement.blur();
|
|
68
|
+
}
|
|
61
69
|
};
|
|
62
70
|
|
|
63
71
|
this.handleTimeChange = (name, date, precision) => {
|
|
@@ -78,9 +86,9 @@ class HiDateRangePicker extends React.Component {
|
|
|
78
86
|
const {
|
|
79
87
|
translations
|
|
80
88
|
} = this.props;
|
|
81
|
-
let date
|
|
82
|
-
let error
|
|
83
|
-
|
|
89
|
+
let date;
|
|
90
|
+
let error;
|
|
91
|
+
const now = new Date();
|
|
84
92
|
const {
|
|
85
93
|
minimumDate,
|
|
86
94
|
disableFutureDays,
|
|
@@ -90,7 +98,7 @@ class HiDateRangePicker extends React.Component {
|
|
|
90
98
|
if (day instanceof Date) {
|
|
91
99
|
date = day;
|
|
92
100
|
} else if (day) {
|
|
93
|
-
|
|
101
|
+
const parsedValue = moment(day, this.props.format, true);
|
|
94
102
|
|
|
95
103
|
if (parsedValue.isValid()) {
|
|
96
104
|
date = parsedValue.toDate();
|
|
@@ -100,14 +108,14 @@ class HiDateRangePicker extends React.Component {
|
|
|
100
108
|
}
|
|
101
109
|
|
|
102
110
|
if (date) {
|
|
103
|
-
|
|
111
|
+
const comparativeDate = name === 'to' ? moment(this.props.from) : moment(this.props.to);
|
|
104
112
|
|
|
105
113
|
if (name === 'to' && comparativeDate > moment(date) || name === 'from' && comparativeDate < moment(date)) {
|
|
106
114
|
error = translations.to_superior_from;
|
|
107
115
|
} else if (date < minimumDate) {
|
|
108
|
-
error = translations.date_inferior_min_date.replace(
|
|
116
|
+
error = translations.date_inferior_min_date.replace('%s', moment(minimumDate).format(format));
|
|
109
117
|
} else if (disableFutureDays && date > now) {
|
|
110
|
-
error = translations.date_superior_max_date.replace(
|
|
118
|
+
error = translations.date_superior_max_date.replace('%s', moment().format(format));
|
|
111
119
|
}
|
|
112
120
|
|
|
113
121
|
if (!this.props.enableTime) {
|
|
@@ -156,10 +164,10 @@ class HiDateRangePicker extends React.Component {
|
|
|
156
164
|
|
|
157
165
|
this.handleReset = name => {
|
|
158
166
|
this.handleChange(name, undefined);
|
|
159
|
-
this.setState({
|
|
160
|
-
keyFrom:
|
|
161
|
-
keyTo:
|
|
162
|
-
});
|
|
167
|
+
this.setState(prevState => ({
|
|
168
|
+
keyFrom: prevState.keyFrom === 1 ? 2 : 1,
|
|
169
|
+
keyTo: prevState.keyTo === 1 ? 2 : 1
|
|
170
|
+
}));
|
|
163
171
|
};
|
|
164
172
|
|
|
165
173
|
this.openPanel = panel => {
|
|
@@ -188,7 +196,7 @@ class HiDateRangePicker extends React.Component {
|
|
|
188
196
|
staticPosition
|
|
189
197
|
});
|
|
190
198
|
|
|
191
|
-
switch (this.state
|
|
199
|
+
switch (this.state.openedPanel) {
|
|
192
200
|
case 'time':
|
|
193
201
|
return this.renderTimePickerOverlay(name, rangeOverlayProps);
|
|
194
202
|
|
|
@@ -199,6 +207,7 @@ class HiDateRangePicker extends React.Component {
|
|
|
199
207
|
return this.renderYearPickerOverlay(name, rangeOverlayProps);
|
|
200
208
|
|
|
201
209
|
case 'calendar':
|
|
210
|
+
default:
|
|
202
211
|
return React.createElement(Overlay, rangeOverlayProps);
|
|
203
212
|
}
|
|
204
213
|
};
|
|
@@ -213,7 +222,7 @@ class HiDateRangePicker extends React.Component {
|
|
|
213
222
|
|
|
214
223
|
this.renderMonthPickerOverlay = (name, propsOverlay) => {
|
|
215
224
|
const monthPickerProps = {
|
|
216
|
-
value: this.state
|
|
225
|
+
value: this.state.currentMonth,
|
|
217
226
|
onChange: this.handleCurrentMonthChange
|
|
218
227
|
};
|
|
219
228
|
return React.createElement(MonthPickerOverlay, _extends({
|
|
@@ -234,7 +243,7 @@ class HiDateRangePicker extends React.Component {
|
|
|
234
243
|
|
|
235
244
|
this.renderYearPickerOverlay = (name, propsOverlay) => {
|
|
236
245
|
const yearPickerProps = {
|
|
237
|
-
value: this.state
|
|
246
|
+
value: this.state.currentMonth,
|
|
238
247
|
onChange: this.handleCurrentMonthChange,
|
|
239
248
|
disabledFutureDays: this.props.disableFutureDays
|
|
240
249
|
};
|
|
@@ -334,7 +343,7 @@ class HiDateRangePicker extends React.Component {
|
|
|
334
343
|
onTodayButtonClick: this.handleCurrentMonthChange,
|
|
335
344
|
navbarElement: this.renderNavBar,
|
|
336
345
|
captionElement: this.renderCaption,
|
|
337
|
-
disabledDays: _objectSpread({
|
|
346
|
+
disabledDays: _objectSpread({}, dayPickerProps.disabledDays, {
|
|
338
347
|
before: minimumDate
|
|
339
348
|
}, disableFutureDays && {
|
|
340
349
|
after: now
|
|
@@ -350,7 +359,7 @@ class HiDateRangePicker extends React.Component {
|
|
|
350
359
|
navbarElement: this.renderNavBar,
|
|
351
360
|
onDayClick: this.onDayToClick,
|
|
352
361
|
captionElement: this.renderCaption,
|
|
353
|
-
disabledDays: _objectSpread({
|
|
362
|
+
disabledDays: _objectSpread({}, dayPickerProps.disabledDays, {
|
|
354
363
|
before: minimumDate
|
|
355
364
|
}, disableFutureDays && {
|
|
356
365
|
after: now
|
|
@@ -371,7 +380,7 @@ class HiDateRangePicker extends React.Component {
|
|
|
371
380
|
}, {
|
|
372
381
|
id: `${id}-from`,
|
|
373
382
|
onChange: this.handleInputChange('from'),
|
|
374
|
-
disabled
|
|
383
|
+
disabled
|
|
375
384
|
});
|
|
376
385
|
|
|
377
386
|
const toInputProps = _objectSpread({}, onReset && {
|
|
@@ -383,7 +392,7 @@ class HiDateRangePicker extends React.Component {
|
|
|
383
392
|
}, {
|
|
384
393
|
id: `${id}-to`,
|
|
385
394
|
onChange: this.handleInputChange('to'),
|
|
386
|
-
disabled
|
|
395
|
+
disabled
|
|
387
396
|
});
|
|
388
397
|
|
|
389
398
|
const toClass = classNames(classes.toInput, {
|
|
@@ -429,7 +438,7 @@ class HiDateRangePicker extends React.Component {
|
|
|
429
438
|
inputProps: toInputProps,
|
|
430
439
|
format: enableTime ? `${format} HH:mm` : format,
|
|
431
440
|
formatDate: MomentLocaleUtils.formatDate,
|
|
432
|
-
parseDate: MomentLocaleUtils.parseDate //onDayChange={(day) => this.handleDayChange('to', day)}
|
|
441
|
+
parseDate: MomentLocaleUtils.parseDate // onDayChange={(day) => this.handleDayChange('to', day)}
|
|
433
442
|
,
|
|
434
443
|
placeholder: ''
|
|
435
444
|
})));
|
|
@@ -451,7 +460,7 @@ class HiDateRangePicker extends React.Component {
|
|
|
451
460
|
}
|
|
452
461
|
|
|
453
462
|
HiDateRangePicker.defaultProps = {
|
|
454
|
-
disabledDays:
|
|
463
|
+
disabledDays: {},
|
|
455
464
|
disableFutureDays: true,
|
|
456
465
|
staticPosition: false,
|
|
457
466
|
enableTime: false,
|
|
@@ -460,6 +469,8 @@ HiDateRangePicker.defaultProps = {
|
|
|
460
469
|
labelFrom: 'Start',
|
|
461
470
|
labelTo: 'End',
|
|
462
471
|
locale: 'fr-FR',
|
|
472
|
+
minimumDate: new Date(2013, 4, 1),
|
|
473
|
+
// by default 1 May 2013
|
|
463
474
|
translations: {
|
|
464
475
|
today: 'today',
|
|
465
476
|
hour: 'Hour',
|
|
@@ -485,6 +496,11 @@ HiDateRangePicker.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
485
496
|
*/
|
|
486
497
|
disabled: PropTypes.bool,
|
|
487
498
|
|
|
499
|
+
/**
|
|
500
|
+
* http://react-day-picker.js.org/api/DayPicker#disabledDays
|
|
501
|
+
*/
|
|
502
|
+
disabledDays: PropTypes.object,
|
|
503
|
+
|
|
488
504
|
/**
|
|
489
505
|
* Uniquement la sélection de date antérieures à aujourd'hui (inclu)
|
|
490
506
|
*/
|
|
@@ -509,7 +525,7 @@ HiDateRangePicker.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
509
525
|
* Date de début sélectionnée
|
|
510
526
|
*/
|
|
511
527
|
from: PropTypes.instanceOf(Date),
|
|
512
|
-
//from: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.string]),
|
|
528
|
+
// from: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.string]),
|
|
513
529
|
|
|
514
530
|
/**
|
|
515
531
|
* Erreur sur date from
|
|
@@ -555,7 +571,7 @@ HiDateRangePicker.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
555
571
|
/**
|
|
556
572
|
* Date minimale sélectionnable
|
|
557
573
|
*/
|
|
558
|
-
minimumDate: PropTypes.instanceOf(Date)
|
|
574
|
+
minimumDate: PropTypes.instanceOf(Date),
|
|
559
575
|
|
|
560
576
|
/**
|
|
561
577
|
* Callback à la sélection d'une date
|
|
@@ -105,7 +105,7 @@ export function buildDateRangeOptionByKey(key, t, format) {
|
|
|
105
105
|
type
|
|
106
106
|
};
|
|
107
107
|
}
|
|
108
|
-
export const styles =
|
|
108
|
+
export const styles = () => ({
|
|
109
109
|
root: {
|
|
110
110
|
maxWidth: 500,
|
|
111
111
|
marginLeft: -4,
|
|
@@ -116,7 +116,8 @@ export const styles = theme => ({
|
|
|
116
116
|
marginTop: 1
|
|
117
117
|
},
|
|
118
118
|
dateRangePicker: {
|
|
119
|
-
width: 'calc(100% + 8px)'
|
|
119
|
+
width: 'calc(100% + 8px)',
|
|
120
|
+
marginTop: 1
|
|
120
121
|
},
|
|
121
122
|
smSelect: {},
|
|
122
123
|
smRangePicker: {}
|
|
@@ -127,17 +128,22 @@ class HiDateRangeSelector extends React.Component {
|
|
|
127
128
|
super();
|
|
128
129
|
this.options = [];
|
|
129
130
|
|
|
130
|
-
this.
|
|
131
|
+
this.handleBlur = event => {
|
|
131
132
|
if (event instanceof Object && this.props.onblur) {
|
|
132
133
|
this.props.onBlur(event);
|
|
133
134
|
}
|
|
134
135
|
};
|
|
135
136
|
|
|
137
|
+
this.handleReset = name => {
|
|
138
|
+
this.props.onChange(name, undefined);
|
|
139
|
+
this.props.onChange(`${name}Error`, undefined);
|
|
140
|
+
};
|
|
141
|
+
|
|
136
142
|
this.handleSelectChange = name => (event, value) => {
|
|
137
|
-
this.setState({
|
|
143
|
+
this.setState(prevState => ({
|
|
138
144
|
[name]: value,
|
|
139
|
-
key:
|
|
140
|
-
});
|
|
145
|
+
key: prevState.key === 1 ? 2 : 1
|
|
146
|
+
}));
|
|
141
147
|
const selectedOption = this.options.find(option => option.id === value);
|
|
142
148
|
|
|
143
149
|
if (selectedOption) {
|
|
@@ -152,7 +158,6 @@ class HiDateRangeSelector extends React.Component {
|
|
|
152
158
|
}
|
|
153
159
|
};
|
|
154
160
|
|
|
155
|
-
this.handleReset = this.handleReset.bind(this);
|
|
156
161
|
this.handleSelectChange = this.handleSelectChange.bind(this);
|
|
157
162
|
this.options = props.availableOptionKeys.map(key => buildDateRangeOptionByKey(key, props.translations, props.format));
|
|
158
163
|
this.state = {
|
|
@@ -161,8 +166,8 @@ class HiDateRangeSelector extends React.Component {
|
|
|
161
166
|
};
|
|
162
167
|
}
|
|
163
168
|
|
|
164
|
-
static getDerivedStateFromProps(props
|
|
165
|
-
if (props.
|
|
169
|
+
static getDerivedStateFromProps(props) {
|
|
170
|
+
if (props.returnSelectValue) {
|
|
166
171
|
return {
|
|
167
172
|
selectedPreset: props.defaultPreset
|
|
168
173
|
};
|
|
@@ -176,7 +181,6 @@ class HiDateRangeSelector extends React.Component {
|
|
|
176
181
|
this.setState({
|
|
177
182
|
containerWidth: findDOMNode(this.container).clientWidth - 5
|
|
178
183
|
});
|
|
179
|
-
this.handleSelectChange('selectedPreset')(undefined, this.state.selectedPreset);
|
|
180
184
|
}
|
|
181
185
|
}
|
|
182
186
|
|
|
@@ -184,11 +188,6 @@ class HiDateRangeSelector extends React.Component {
|
|
|
184
188
|
clearTimeout(this.timeout); // TODO : supprimer ?
|
|
185
189
|
}
|
|
186
190
|
|
|
187
|
-
handleReset(name) {
|
|
188
|
-
this.props.onChange(name, undefined);
|
|
189
|
-
this.props.onChange(`${name}Error`, undefined);
|
|
190
|
-
}
|
|
191
|
-
|
|
192
191
|
render() {
|
|
193
192
|
const _this$props = this.props,
|
|
194
193
|
{
|
|
@@ -231,7 +230,9 @@ class HiDateRangeSelector extends React.Component {
|
|
|
231
230
|
container: true,
|
|
232
231
|
spacing: 8,
|
|
233
232
|
className: classes.root,
|
|
234
|
-
ref: container =>
|
|
233
|
+
ref: container => {
|
|
234
|
+
this.container = container;
|
|
235
|
+
}
|
|
235
236
|
}, React.createElement(Grid, {
|
|
236
237
|
item: true,
|
|
237
238
|
xs: 12,
|
|
@@ -269,8 +270,8 @@ class HiDateRangeSelector extends React.Component {
|
|
|
269
270
|
root: classes.dateRangePicker
|
|
270
271
|
},
|
|
271
272
|
id: idRange,
|
|
272
|
-
from: from,
|
|
273
|
-
to: to,
|
|
273
|
+
from: selectedPreset ? from : undefined,
|
|
274
|
+
to: selectedPreset ? to : undefined,
|
|
274
275
|
enableTime: enableTime,
|
|
275
276
|
onChange: onChange,
|
|
276
277
|
toError: toError,
|
|
@@ -281,7 +282,7 @@ class HiDateRangeSelector extends React.Component {
|
|
|
281
282
|
disabled: disabled || selectedPreset !== 'custom',
|
|
282
283
|
translations: translations,
|
|
283
284
|
staticPosition: staticPosition,
|
|
284
|
-
onBlur: this.
|
|
285
|
+
onBlur: this.handleBlur,
|
|
285
286
|
hasSelector: true
|
|
286
287
|
}, props)))));
|
|
287
288
|
}
|
|
@@ -290,12 +291,13 @@ class HiDateRangeSelector extends React.Component {
|
|
|
290
291
|
|
|
291
292
|
HiDateRangeSelector.defaultProps = {
|
|
292
293
|
availableOptionKeys: ['cd', 'pd', 'cw', 'pw', 'cm', 'pm', 'cq', 'pq', 'cy', 'custom'],
|
|
293
|
-
defaultPreset: 'cd',
|
|
294
294
|
enableTime: false,
|
|
295
295
|
returnSelectValue: false,
|
|
296
296
|
staticPosition: false,
|
|
297
297
|
locale: 'fr-FR',
|
|
298
298
|
format: 'YYYY-DD-MM',
|
|
299
|
+
minimumDate: new Date(2013, 4, 1),
|
|
300
|
+
// by default 1 May 2013
|
|
299
301
|
translations: {
|
|
300
302
|
today: 'Today',
|
|
301
303
|
hour: 'Hour',
|
|
@@ -406,7 +408,7 @@ HiDateRangeSelector.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
406
408
|
/**
|
|
407
409
|
* Date minimale sélectionnable
|
|
408
410
|
*/
|
|
409
|
-
minimumDate: PropTypes.instanceOf(Date)
|
|
411
|
+
minimumDate: PropTypes.instanceOf(Date),
|
|
410
412
|
|
|
411
413
|
/**
|
|
412
414
|
* Callback à la sélection d'une date
|
|
@@ -421,7 +423,7 @@ HiDateRangeSelector.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
421
423
|
/**
|
|
422
424
|
* Retourne la valeur du select de la période au change du select
|
|
423
425
|
*/
|
|
424
|
-
returnSelectValue: PropTypes.bool
|
|
426
|
+
returnSelectValue: PropTypes.bool,
|
|
425
427
|
|
|
426
428
|
/**
|
|
427
429
|
* Props passées au HiSelectField
|