@hipay/hipay-material-ui 2.0.0-beta.55 → 2.0.0-beta.57
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 +116 -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 +13 -1
- package/HiCell/CellRate.js +6 -3
- package/HiCell/CellSentinel.js +7 -10
- package/HiCell/CellTextStyled.js +29 -1
- package/HiColoredLabel/HiColoredLabel.js +1 -1
- package/HiDatePicker/Caption.js +16 -10
- package/HiDatePicker/HiDatePicker.js +9 -3
- package/HiDatePicker/HiDateRangePicker.js +36 -22
- package/HiDatePicker/HiDateRangeSelector.js +75 -21
- package/HiDatePicker/NavBar.js +8 -1
- package/HiDatePicker/Overlays/CustomOverlayLayout.js +26 -17
- package/HiDatePicker/Overlays/CustomOverlayLayoutWithoutFooter.js +123 -0
- package/HiDatePicker/Overlays/MonthPickerOverlay.js +4 -4
- 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 +4 -6
- package/HiDatePicker/Overlays/YearPickerOverlay.spec.js +1 -0
- package/HiDatePicker/hiLocaleUtils.js +144 -0
- package/HiDatePicker/stylesheet.js +33 -7
- 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/HiFormControl.js +2 -0
- package/HiForm/HiInput.js +3 -3
- 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 +96 -0
- package/HiNotice/index.js +23 -0
- package/HiPdfReader/HiPdfReader.js +269 -0
- package/HiPdfReader/index.js +15 -0
- package/HiPin/HiPin.js +1 -1
- package/HiRadio/HiRadio.js +74 -0
- package/HiRadio/index.js +15 -0
- package/HiSelect/HiSelect.js +73 -84
- package/HiSelect/HiSuggestSelect.js +35 -4
- package/HiSelect/SelectInput.js +9 -1
- package/HiSelectNew/HiNestedSelectContent.js +5 -1
- package/HiSelectNew/HiSelect.js +260 -179
- package/HiSelectNew/HiSelectContent.js +0 -8
- package/HiSelectNew/HiSelectInput.js +8 -9
- package/HiSelectableList/HiSelectableList.js +39 -4
- package/HiSelectableList/HiSelectableListItem.js +81 -38
- package/HiTable/HiCellBuilder.js +25 -12
- package/HiTable/HiTableHeader.js +16 -17
- package/HiTable/constants.js +3 -1
- package/README.md +248 -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 +13 -1
- package/es/HiCell/CellRate.js +6 -3
- package/es/HiCell/CellSentinel.js +7 -10
- package/es/HiCell/CellTextStyled.js +28 -1
- package/es/HiColoredLabel/HiColoredLabel.js +1 -1
- package/es/HiDatePicker/Caption.js +14 -10
- package/es/HiDatePicker/HiDatePicker.js +8 -3
- package/es/HiDatePicker/HiDateRangePicker.js +40 -28
- package/es/HiDatePicker/HiDateRangeSelector.js +69 -21
- package/es/HiDatePicker/ListPicker.js +1 -1
- package/es/HiDatePicker/NavBar.js +7 -1
- package/es/HiDatePicker/Overlays/CustomOverlayLayout.js +30 -19
- package/es/HiDatePicker/Overlays/CustomOverlayLayoutWithoutFooter.js +106 -0
- package/es/HiDatePicker/Overlays/MonthPickerOverlay.js +5 -5
- 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 +4 -6
- package/es/HiDatePicker/Overlays/YearPickerOverlay.spec.js +1 -0
- package/es/HiDatePicker/hiLocaleUtils.js +131 -0
- package/es/HiDatePicker/stylesheet.js +32 -7
- 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/HiFormControl.js +2 -0
- package/es/HiForm/HiInput.js +3 -3
- 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 +78 -0
- package/es/HiNotice/index.js +2 -0
- package/es/HiPdfReader/HiPdfReader.js +214 -0
- package/es/HiPdfReader/index.js +1 -0
- package/es/HiPin/HiPin.js +1 -1
- 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 +30 -4
- package/es/HiSelect/SelectInput.js +9 -1
- package/es/HiSelectNew/HiNestedSelectContent.js +5 -1
- package/es/HiSelectNew/HiSelect.js +246 -162
- package/es/HiSelectNew/HiSelectContent.js +0 -7
- package/es/HiSelectNew/HiSelectInput.js +8 -9
- package/es/HiSelectableList/HiSelectableList.js +34 -6
- package/es/HiSelectableList/HiSelectableListItem.js +92 -40
- package/es/HiTable/HiCellBuilder.js +130 -123
- package/es/HiTable/HiTableHeader.js +14 -12
- package/es/HiTable/constants.js +1 -0
- package/es/index.js +9 -1
- package/es/utils/helpers.js +1 -1
- package/index.es.js +9 -1
- package/index.js +66 -2
- package/package.json +5 -2
- package/umd/hipay-material-ui.development.js +44450 -40930
- package/umd/hipay-material-ui.production.min.js +2 -2
- package/utils/helpers.js +1 -1
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'
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
2
3
|
import HiColoredLabel from '../HiColoredLabel';
|
|
3
4
|
const styleRoot = {
|
|
4
5
|
width: '100%',
|
|
@@ -43,7 +44,7 @@ const CellTextStyled = ({
|
|
|
43
44
|
const valueString = label ? label.toString() : value.toString();
|
|
44
45
|
return React.createElement("div", {
|
|
45
46
|
style: styleRoot,
|
|
46
|
-
title: title
|
|
47
|
+
title: title || valueString
|
|
47
48
|
}, color ? React.createElement(HiColoredLabel, {
|
|
48
49
|
style: styleColorLabel,
|
|
49
50
|
label: valueString,
|
|
@@ -54,4 +55,30 @@ const CellTextStyled = ({
|
|
|
54
55
|
}, valueString));
|
|
55
56
|
};
|
|
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
|
+
} : {};
|
|
57
84
|
export default CellTextStyled;
|
|
@@ -8,7 +8,7 @@ import withStyles from '../styles/withStyles';
|
|
|
8
8
|
import { capitalize } from '../utils/helpers';
|
|
9
9
|
import { fade } from '../styles/colorManipulator';
|
|
10
10
|
export const styles = theme => ({
|
|
11
|
-
root: _objectSpread({}, theme.typography.
|
|
11
|
+
root: _objectSpread({}, theme.typography.b3, {
|
|
12
12
|
display: 'inline-block',
|
|
13
13
|
alignItems: 'baseline',
|
|
14
14
|
maxWidth: '100%',
|
|
@@ -2,35 +2,34 @@ 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 = ({
|
|
20
18
|
classes,
|
|
21
19
|
date,
|
|
20
|
+
locale = 'en_US',
|
|
22
21
|
localeUtils,
|
|
23
22
|
onMonthClick,
|
|
24
23
|
onYearClick
|
|
25
24
|
}) => {
|
|
26
|
-
const months = localeUtils.getMonths();
|
|
25
|
+
const months = localeUtils.getMonths(locale);
|
|
27
26
|
return React.createElement("div", {
|
|
28
27
|
className: classes.caption
|
|
29
|
-
}, React.createElement(
|
|
30
|
-
|
|
28
|
+
}, React.createElement(HiButton, {
|
|
29
|
+
size: "small",
|
|
31
30
|
onClick: onMonthClick
|
|
32
|
-
}, months[date.getMonth()]),
|
|
33
|
-
|
|
31
|
+
}, months[date.getMonth()]), React.createElement(HiButton, {
|
|
32
|
+
size: "small",
|
|
34
33
|
onClick: onYearClick
|
|
35
34
|
}, date.getFullYear()));
|
|
36
35
|
};
|
|
@@ -46,6 +45,11 @@ Caption.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
46
45
|
*/
|
|
47
46
|
date: PropTypes.object.isRequired,
|
|
48
47
|
|
|
48
|
+
/**
|
|
49
|
+
* ReactDayPicker prop
|
|
50
|
+
*/
|
|
51
|
+
locale: PropTypes.string,
|
|
52
|
+
|
|
49
53
|
/**
|
|
50
54
|
* ReactDayPicker prop
|
|
51
55
|
*/
|
|
@@ -4,6 +4,7 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import MomentLocaleUtils from 'react-day-picker/moment';
|
|
7
|
+
import HiLocaleUtils from './hiLocaleUtils';
|
|
7
8
|
import DayPickerInput from 'react-day-picker/DayPickerInput';
|
|
8
9
|
import withStyles from '../styles/withStyles';
|
|
9
10
|
import Caption from './Caption';
|
|
@@ -216,12 +217,13 @@ class HiDatePicker extends React.Component {
|
|
|
216
217
|
navbarElement: props2 => React.createElement(NavBar, _extends({
|
|
217
218
|
showClockButton: enableTime,
|
|
218
219
|
onClockClick: this.handleClockClick
|
|
219
|
-
}, props2
|
|
220
|
+
}, props2, {
|
|
221
|
+
localeUtils: HiLocaleUtils
|
|
222
|
+
})),
|
|
220
223
|
captionElement: this.renderCaption,
|
|
221
224
|
classNames: classes,
|
|
222
225
|
disabledDays: effectiveDisabledDays,
|
|
223
226
|
selectedDays: typeof value === 'object' ? value : undefined,
|
|
224
|
-
locale,
|
|
225
227
|
firstDayOfWeek: 1,
|
|
226
228
|
fromMonth: minimumDate,
|
|
227
229
|
modifiers: {
|
|
@@ -230,7 +232,10 @@ class HiDatePicker extends React.Component {
|
|
|
230
232
|
},
|
|
231
233
|
modifiersStyles,
|
|
232
234
|
month: currentMonth
|
|
233
|
-
}, props
|
|
235
|
+
}, props, {
|
|
236
|
+
locale,
|
|
237
|
+
localeUtils: HiLocaleUtils
|
|
238
|
+
});
|
|
234
239
|
|
|
235
240
|
const inputProps = _objectSpread({}, onReset && {
|
|
236
241
|
onReset: this.handleReset
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
2
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
3
2
|
import _objectSpread from "@babel/runtime/helpers/objectSpread";
|
|
3
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import MomentLocaleUtils from 'react-day-picker/moment';
|
|
7
|
+
import HiLocaleUtils from './hiLocaleUtils';
|
|
7
8
|
import DayPickerInput from 'react-day-picker/DayPickerInput';
|
|
8
9
|
import classNames from 'classnames';
|
|
9
10
|
import withStyles from '../styles/withStyles';
|
|
@@ -21,7 +22,7 @@ import HiFormControl from '../HiForm/HiFormControl';
|
|
|
21
22
|
|
|
22
23
|
class HiDateRangePicker extends React.Component {
|
|
23
24
|
constructor(props) {
|
|
24
|
-
super();
|
|
25
|
+
super(props);
|
|
25
26
|
|
|
26
27
|
this.handleDayChange = (name, day) => {
|
|
27
28
|
if (day) {
|
|
@@ -58,12 +59,11 @@ class HiDateRangePicker extends React.Component {
|
|
|
58
59
|
this.onDayToClick = day => {
|
|
59
60
|
let change = moment(day) >= moment(this.props.from);
|
|
60
61
|
|
|
61
|
-
if (change && this.props.disableFutureDays && moment(day) > moment()) {
|
|
62
|
+
if (change && this.props.disableFutureDays && moment(day).utc() > moment().utc().endOf('day')) {
|
|
62
63
|
change = false;
|
|
63
64
|
}
|
|
64
65
|
|
|
65
66
|
if (change) {
|
|
66
|
-
console.log(_objectSpread({}, this.props));
|
|
67
67
|
this.handleDayChange('to', day);
|
|
68
68
|
document.activeElement.blur();
|
|
69
69
|
}
|
|
@@ -87,9 +87,9 @@ class HiDateRangePicker extends React.Component {
|
|
|
87
87
|
const {
|
|
88
88
|
translations
|
|
89
89
|
} = this.props;
|
|
90
|
-
let date
|
|
91
|
-
let error
|
|
92
|
-
|
|
90
|
+
let date;
|
|
91
|
+
let error;
|
|
92
|
+
const now = new Date();
|
|
93
93
|
const {
|
|
94
94
|
minimumDate,
|
|
95
95
|
disableFutureDays,
|
|
@@ -99,7 +99,7 @@ class HiDateRangePicker extends React.Component {
|
|
|
99
99
|
if (day instanceof Date) {
|
|
100
100
|
date = day;
|
|
101
101
|
} else if (day) {
|
|
102
|
-
|
|
102
|
+
const parsedValue = moment(day, this.props.format, true);
|
|
103
103
|
|
|
104
104
|
if (parsedValue.isValid()) {
|
|
105
105
|
date = parsedValue.toDate();
|
|
@@ -109,14 +109,14 @@ class HiDateRangePicker extends React.Component {
|
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
if (date) {
|
|
112
|
-
|
|
112
|
+
const comparativeDate = name === 'to' ? moment(this.props.from) : moment(this.props.to);
|
|
113
113
|
|
|
114
114
|
if (name === 'to' && comparativeDate > moment(date) || name === 'from' && comparativeDate < moment(date)) {
|
|
115
115
|
error = translations.to_superior_from;
|
|
116
|
-
} else if (date < minimumDate) {
|
|
117
|
-
error = translations.date_inferior_min_date.replace(
|
|
118
|
-
} else if (disableFutureDays && date > now) {
|
|
119
|
-
error = translations.date_superior_max_date.replace(
|
|
116
|
+
} else if (moment(date).utc() < moment(minimumDate).utc().startOf('day')) {
|
|
117
|
+
error = translations.date_inferior_min_date.replace('%s', moment(minimumDate).format(format));
|
|
118
|
+
} else if (disableFutureDays && moment(date).utc() > moment(now).utc().endOf('day')) {
|
|
119
|
+
error = translations.date_superior_max_date.replace('%s', moment().format(format));
|
|
120
120
|
}
|
|
121
121
|
|
|
122
122
|
if (!this.props.enableTime) {
|
|
@@ -165,10 +165,10 @@ class HiDateRangePicker extends React.Component {
|
|
|
165
165
|
|
|
166
166
|
this.handleReset = name => {
|
|
167
167
|
this.handleChange(name, undefined);
|
|
168
|
-
this.setState({
|
|
169
|
-
keyFrom:
|
|
170
|
-
keyTo:
|
|
171
|
-
});
|
|
168
|
+
this.setState(prevState => ({
|
|
169
|
+
keyFrom: prevState.keyFrom === 1 ? 2 : 1,
|
|
170
|
+
keyTo: prevState.keyTo === 1 ? 2 : 1
|
|
171
|
+
}));
|
|
172
172
|
};
|
|
173
173
|
|
|
174
174
|
this.openPanel = panel => {
|
|
@@ -197,7 +197,7 @@ class HiDateRangePicker extends React.Component {
|
|
|
197
197
|
staticPosition
|
|
198
198
|
});
|
|
199
199
|
|
|
200
|
-
switch (this.state
|
|
200
|
+
switch (this.state.openedPanel) {
|
|
201
201
|
case 'time':
|
|
202
202
|
return this.renderTimePickerOverlay(name, rangeOverlayProps);
|
|
203
203
|
|
|
@@ -208,6 +208,7 @@ class HiDateRangePicker extends React.Component {
|
|
|
208
208
|
return this.renderYearPickerOverlay(name, rangeOverlayProps);
|
|
209
209
|
|
|
210
210
|
case 'calendar':
|
|
211
|
+
default:
|
|
211
212
|
return React.createElement(Overlay, rangeOverlayProps);
|
|
212
213
|
}
|
|
213
214
|
};
|
|
@@ -222,7 +223,7 @@ class HiDateRangePicker extends React.Component {
|
|
|
222
223
|
|
|
223
224
|
this.renderMonthPickerOverlay = (name, propsOverlay) => {
|
|
224
225
|
const monthPickerProps = {
|
|
225
|
-
value: this.state
|
|
226
|
+
value: this.state.currentMonth,
|
|
226
227
|
onChange: this.handleCurrentMonthChange
|
|
227
228
|
};
|
|
228
229
|
return React.createElement(MonthPickerOverlay, _extends({
|
|
@@ -243,7 +244,7 @@ class HiDateRangePicker extends React.Component {
|
|
|
243
244
|
|
|
244
245
|
this.renderYearPickerOverlay = (name, propsOverlay) => {
|
|
245
246
|
const yearPickerProps = {
|
|
246
|
-
value: this.state
|
|
247
|
+
value: this.state.currentMonth,
|
|
247
248
|
onChange: this.handleCurrentMonthChange,
|
|
248
249
|
disabledFutureDays: this.props.disableFutureDays
|
|
249
250
|
};
|
|
@@ -343,13 +344,15 @@ class HiDateRangePicker extends React.Component {
|
|
|
343
344
|
onTodayButtonClick: this.handleCurrentMonthChange,
|
|
344
345
|
navbarElement: this.renderNavBar,
|
|
345
346
|
captionElement: this.renderCaption,
|
|
346
|
-
disabledDays: _objectSpread({
|
|
347
|
+
disabledDays: _objectSpread({}, dayPickerProps.disabledDays, {
|
|
347
348
|
before: minimumDate
|
|
348
349
|
}, disableFutureDays && {
|
|
349
350
|
after: now
|
|
350
351
|
}, to && {
|
|
351
352
|
after: to
|
|
352
353
|
}),
|
|
354
|
+
locale,
|
|
355
|
+
localeUtils: HiLocaleUtils,
|
|
353
356
|
month: this.state.currentMonth,
|
|
354
357
|
modifiers: _objectSpread({}, modifiers)
|
|
355
358
|
});
|
|
@@ -359,13 +362,15 @@ class HiDateRangePicker extends React.Component {
|
|
|
359
362
|
navbarElement: this.renderNavBar,
|
|
360
363
|
onDayClick: this.onDayToClick,
|
|
361
364
|
captionElement: this.renderCaption,
|
|
362
|
-
disabledDays: _objectSpread({
|
|
365
|
+
disabledDays: _objectSpread({}, dayPickerProps.disabledDays, {
|
|
363
366
|
before: minimumDate
|
|
364
367
|
}, disableFutureDays && {
|
|
365
368
|
after: now
|
|
366
369
|
}, from && {
|
|
367
370
|
before: from
|
|
368
371
|
}),
|
|
372
|
+
locale,
|
|
373
|
+
localeUtils: HiLocaleUtils,
|
|
369
374
|
month: this.state.currentMonth,
|
|
370
375
|
modifiers: _objectSpread({}, modifiers)
|
|
371
376
|
}); // From & To InputProps
|
|
@@ -380,7 +385,7 @@ class HiDateRangePicker extends React.Component {
|
|
|
380
385
|
}, {
|
|
381
386
|
id: `${id}-from`,
|
|
382
387
|
onChange: this.handleInputChange('from'),
|
|
383
|
-
disabled
|
|
388
|
+
disabled
|
|
384
389
|
});
|
|
385
390
|
|
|
386
391
|
const toInputProps = _objectSpread({}, onReset && {
|
|
@@ -392,7 +397,7 @@ class HiDateRangePicker extends React.Component {
|
|
|
392
397
|
}, {
|
|
393
398
|
id: `${id}-to`,
|
|
394
399
|
onChange: this.handleInputChange('to'),
|
|
395
|
-
disabled
|
|
400
|
+
disabled
|
|
396
401
|
});
|
|
397
402
|
|
|
398
403
|
const toClass = classNames(classes.toInput, {
|
|
@@ -438,7 +443,7 @@ class HiDateRangePicker extends React.Component {
|
|
|
438
443
|
inputProps: toInputProps,
|
|
439
444
|
format: enableTime ? `${format} HH:mm` : format,
|
|
440
445
|
formatDate: MomentLocaleUtils.formatDate,
|
|
441
|
-
parseDate: MomentLocaleUtils.parseDate //onDayChange={(day) => this.handleDayChange('to', day)}
|
|
446
|
+
parseDate: MomentLocaleUtils.parseDate // onDayChange={(day) => this.handleDayChange('to', day)}
|
|
442
447
|
,
|
|
443
448
|
placeholder: ''
|
|
444
449
|
})));
|
|
@@ -460,7 +465,7 @@ class HiDateRangePicker extends React.Component {
|
|
|
460
465
|
}
|
|
461
466
|
|
|
462
467
|
HiDateRangePicker.defaultProps = {
|
|
463
|
-
disabledDays:
|
|
468
|
+
disabledDays: {},
|
|
464
469
|
disableFutureDays: true,
|
|
465
470
|
staticPosition: false,
|
|
466
471
|
enableTime: false,
|
|
@@ -469,6 +474,8 @@ HiDateRangePicker.defaultProps = {
|
|
|
469
474
|
labelFrom: 'Start',
|
|
470
475
|
labelTo: 'End',
|
|
471
476
|
locale: 'fr-FR',
|
|
477
|
+
minimumDate: new Date(2013, 4, 1),
|
|
478
|
+
// by default 1 May 2013
|
|
472
479
|
translations: {
|
|
473
480
|
today: 'today',
|
|
474
481
|
hour: 'Hour',
|
|
@@ -494,6 +501,11 @@ HiDateRangePicker.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
494
501
|
*/
|
|
495
502
|
disabled: PropTypes.bool,
|
|
496
503
|
|
|
504
|
+
/**
|
|
505
|
+
* http://react-day-picker.js.org/api/DayPicker#disabledDays
|
|
506
|
+
*/
|
|
507
|
+
disabledDays: PropTypes.object,
|
|
508
|
+
|
|
497
509
|
/**
|
|
498
510
|
* Uniquement la sélection de date antérieures à aujourd'hui (inclu)
|
|
499
511
|
*/
|
|
@@ -518,7 +530,7 @@ HiDateRangePicker.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
518
530
|
* Date de début sélectionnée
|
|
519
531
|
*/
|
|
520
532
|
from: PropTypes.instanceOf(Date),
|
|
521
|
-
//from: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.string]),
|
|
533
|
+
// from: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.string]),
|
|
522
534
|
|
|
523
535
|
/**
|
|
524
536
|
* Erreur sur date from
|
|
@@ -564,7 +576,7 @@ HiDateRangePicker.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
564
576
|
/**
|
|
565
577
|
* Date minimale sélectionnable
|
|
566
578
|
*/
|
|
567
|
-
minimumDate: PropTypes.instanceOf(Date)
|
|
579
|
+
minimumDate: PropTypes.instanceOf(Date),
|
|
568
580
|
|
|
569
581
|
/**
|
|
570
582
|
* Callback à la sélection d'une date
|
|
@@ -9,6 +9,49 @@ import withStyles from '../styles/withStyles';
|
|
|
9
9
|
import HiSelectField from '../HiSelectNew/HiSelectField';
|
|
10
10
|
import HiDateRangePicker from './HiDateRangePicker';
|
|
11
11
|
import HiFormControl from '../HiForm/HiFormControl';
|
|
12
|
+
export function findSeparator(format) {
|
|
13
|
+
let str = '';
|
|
14
|
+
|
|
15
|
+
if (format.search('[/]') >= 0) {
|
|
16
|
+
str = '/';
|
|
17
|
+
} else if (format.search('[-]') >= 0) {
|
|
18
|
+
str = '-';
|
|
19
|
+
} else if (format.search('[.]') >= 0) {
|
|
20
|
+
str = '.';
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return str;
|
|
24
|
+
}
|
|
25
|
+
export function yearAndMonth(format, date) {
|
|
26
|
+
const findY = el => {
|
|
27
|
+
return el.toUpperCase().search('Y') >= 0;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const findM = el => {
|
|
31
|
+
return el.toUpperCase().search('M') >= 0;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const s = findSeparator(format);
|
|
35
|
+
const split = format.split(s);
|
|
36
|
+
const indexY = split.findIndex(findY);
|
|
37
|
+
const indexM = split.findIndex(findM);
|
|
38
|
+
return indexY < indexM ? date.format(split[indexY] + s + split[indexM]) : date.format(split[indexM] + s + split[indexY]);
|
|
39
|
+
}
|
|
40
|
+
export function yearAndQuarter(format, date, t) {
|
|
41
|
+
const findY = el => {
|
|
42
|
+
return el.toUpperCase().search('Y') >= 0;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const findM = el => {
|
|
46
|
+
return el.toUpperCase().search('M') >= 0;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const s = findSeparator(format);
|
|
50
|
+
const split = format.split(s);
|
|
51
|
+
const indexY = split.findIndex(findY);
|
|
52
|
+
const indexM = split.findIndex(findM);
|
|
53
|
+
return indexY < indexM ? date.format(`${split[indexY]}${s}[${t.short_quarter}]Q`) : date.format(`[${t.short_quarter}]Q${s}${split[indexY]}`);
|
|
54
|
+
}
|
|
12
55
|
export function buildDateRangeOptionByKey(key, t, format) {
|
|
13
56
|
let from;
|
|
14
57
|
let label;
|
|
@@ -68,21 +111,21 @@ export function buildDateRangeOptionByKey(key, t, format) {
|
|
|
68
111
|
label = t.previous_month;
|
|
69
112
|
from = moment().subtract(1, 'month').startOf('month');
|
|
70
113
|
to = moment().subtract(1, 'month').endOf('month');
|
|
71
|
-
info = `${from
|
|
114
|
+
info = `${yearAndMonth(format, from)}, ${from.daysInMonth()} ${t.days}`;
|
|
72
115
|
break;
|
|
73
116
|
|
|
74
117
|
case 'cq':
|
|
75
118
|
label = t.current_quarter;
|
|
76
119
|
from = moment().startOf('quarter');
|
|
77
120
|
to = moment();
|
|
78
|
-
info = `${from
|
|
121
|
+
info = `${yearAndQuarter(format, from, t)}, ${from.format(format)} ${t.to_now}, ${to.diff(from, 'days') + 1} ${t.days}`;
|
|
79
122
|
break;
|
|
80
123
|
|
|
81
124
|
case 'pq':
|
|
82
125
|
label = t.previous_quarter;
|
|
83
126
|
from = moment().subtract(1, 'quarter').startOf('quarter');
|
|
84
127
|
to = moment().subtract(1, 'quarter').endOf('quarter');
|
|
85
|
-
info = `${from
|
|
128
|
+
info = `${yearAndQuarter(format, from, t)}, ${to.diff(from, 'days') + 1} ${t.days}`;
|
|
86
129
|
break;
|
|
87
130
|
|
|
88
131
|
case 'cy':
|
|
@@ -105,7 +148,7 @@ export function buildDateRangeOptionByKey(key, t, format) {
|
|
|
105
148
|
type
|
|
106
149
|
};
|
|
107
150
|
}
|
|
108
|
-
export const styles =
|
|
151
|
+
export const styles = () => ({
|
|
109
152
|
root: {
|
|
110
153
|
maxWidth: 500,
|
|
111
154
|
marginLeft: -4,
|
|
@@ -116,7 +159,8 @@ export const styles = theme => ({
|
|
|
116
159
|
marginTop: 1
|
|
117
160
|
},
|
|
118
161
|
dateRangePicker: {
|
|
119
|
-
width: 'calc(100% + 8px)'
|
|
162
|
+
width: 'calc(100% + 8px)',
|
|
163
|
+
marginTop: 0
|
|
120
164
|
},
|
|
121
165
|
smSelect: {},
|
|
122
166
|
smRangePicker: {}
|
|
@@ -127,17 +171,22 @@ class HiDateRangeSelector extends React.Component {
|
|
|
127
171
|
super();
|
|
128
172
|
this.options = [];
|
|
129
173
|
|
|
130
|
-
this.
|
|
174
|
+
this.handleBlur = event => {
|
|
131
175
|
if (event instanceof Object && this.props.onblur) {
|
|
132
176
|
this.props.onBlur(event);
|
|
133
177
|
}
|
|
134
178
|
};
|
|
135
179
|
|
|
180
|
+
this.handleReset = name => {
|
|
181
|
+
this.props.onChange(name, undefined);
|
|
182
|
+
this.props.onChange(`${name}Error`, undefined);
|
|
183
|
+
};
|
|
184
|
+
|
|
136
185
|
this.handleSelectChange = name => (event, value) => {
|
|
137
|
-
this.setState({
|
|
186
|
+
this.setState(prevState => ({
|
|
138
187
|
[name]: value,
|
|
139
|
-
key:
|
|
140
|
-
});
|
|
188
|
+
key: prevState.key === 1 ? 2 : 1
|
|
189
|
+
}));
|
|
141
190
|
const selectedOption = this.options.find(option => option.id === value);
|
|
142
191
|
|
|
143
192
|
if (selectedOption) {
|
|
@@ -152,7 +201,6 @@ class HiDateRangeSelector extends React.Component {
|
|
|
152
201
|
}
|
|
153
202
|
};
|
|
154
203
|
|
|
155
|
-
this.handleReset = this.handleReset.bind(this);
|
|
156
204
|
this.handleSelectChange = this.handleSelectChange.bind(this);
|
|
157
205
|
this.options = props.availableOptionKeys.map(key => buildDateRangeOptionByKey(key, props.translations, props.format));
|
|
158
206
|
this.state = {
|
|
@@ -161,8 +209,8 @@ class HiDateRangeSelector extends React.Component {
|
|
|
161
209
|
};
|
|
162
210
|
}
|
|
163
211
|
|
|
164
|
-
static getDerivedStateFromProps(props
|
|
165
|
-
if (props.
|
|
212
|
+
static getDerivedStateFromProps(props) {
|
|
213
|
+
if (props.returnSelectValue) {
|
|
166
214
|
return {
|
|
167
215
|
selectedPreset: props.defaultPreset
|
|
168
216
|
};
|
|
@@ -183,11 +231,6 @@ class HiDateRangeSelector extends React.Component {
|
|
|
183
231
|
clearTimeout(this.timeout); // TODO : supprimer ?
|
|
184
232
|
}
|
|
185
233
|
|
|
186
|
-
handleReset(name) {
|
|
187
|
-
this.props.onChange(name, undefined);
|
|
188
|
-
this.props.onChange(`${name}Error`, undefined);
|
|
189
|
-
}
|
|
190
|
-
|
|
191
234
|
render() {
|
|
192
235
|
const _this$props = this.props,
|
|
193
236
|
{
|
|
@@ -230,7 +273,9 @@ class HiDateRangeSelector extends React.Component {
|
|
|
230
273
|
container: true,
|
|
231
274
|
spacing: 8,
|
|
232
275
|
className: classes.root,
|
|
233
|
-
ref: container =>
|
|
276
|
+
ref: container => {
|
|
277
|
+
this.container = container;
|
|
278
|
+
}
|
|
234
279
|
}, React.createElement(Grid, {
|
|
235
280
|
item: true,
|
|
236
281
|
xs: 12,
|
|
@@ -280,7 +325,7 @@ class HiDateRangeSelector extends React.Component {
|
|
|
280
325
|
disabled: disabled || selectedPreset !== 'custom',
|
|
281
326
|
translations: translations,
|
|
282
327
|
staticPosition: staticPosition,
|
|
283
|
-
onBlur: this.
|
|
328
|
+
onBlur: this.handleBlur,
|
|
284
329
|
hasSelector: true
|
|
285
330
|
}, props)))));
|
|
286
331
|
}
|
|
@@ -294,6 +339,8 @@ HiDateRangeSelector.defaultProps = {
|
|
|
294
339
|
staticPosition: false,
|
|
295
340
|
locale: 'fr-FR',
|
|
296
341
|
format: 'YYYY-DD-MM',
|
|
342
|
+
minimumDate: new Date(2013, 4, 1),
|
|
343
|
+
// by default 1 May 2013
|
|
297
344
|
translations: {
|
|
298
345
|
today: 'Today',
|
|
299
346
|
hour: 'Hour',
|
|
@@ -302,6 +349,7 @@ HiDateRangeSelector.defaultProps = {
|
|
|
302
349
|
quarter: 'Quarter',
|
|
303
350
|
week: 'Week',
|
|
304
351
|
short_week: 'W',
|
|
352
|
+
short_quarter: 'Q',
|
|
305
353
|
yearAndMonth: 'YYYY[-]MM',
|
|
306
354
|
yearAndQuarter: 'YYYY[-Q]Q',
|
|
307
355
|
year: 'Year',
|
|
@@ -404,7 +452,7 @@ HiDateRangeSelector.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
404
452
|
/**
|
|
405
453
|
* Date minimale sélectionnable
|
|
406
454
|
*/
|
|
407
|
-
minimumDate: PropTypes.instanceOf(Date)
|
|
455
|
+
minimumDate: PropTypes.instanceOf(Date),
|
|
408
456
|
|
|
409
457
|
/**
|
|
410
458
|
* Callback à la sélection d'une date
|
|
@@ -419,7 +467,7 @@ HiDateRangeSelector.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
419
467
|
/**
|
|
420
468
|
* Retourne la valeur du select de la période au change du select
|
|
421
469
|
*/
|
|
422
|
-
returnSelectValue: PropTypes.bool
|
|
470
|
+
returnSelectValue: PropTypes.bool,
|
|
423
471
|
|
|
424
472
|
/**
|
|
425
473
|
* Props passées au HiSelectField
|