@hipay/hipay-material-ui 2.0.0-beta.59 → 2.0.0-beta.61
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +118 -0
- package/HiCell/CellNumeric.js +1 -1
- package/HiDatePicker/HiDatePicker.js +48 -14
- package/HiDatePicker/HiDateRangePicker.js +119 -64
- package/HiDatePicker/HiDateRangeSelector.js +70 -47
- package/HiDatePicker/Overlays/YearPickerOverlay.js +8 -3
- package/HiDatePicker/stylesheet.js +32 -17
- package/HiForm/HiFormControl.js +26 -11
- package/HiForm/HiFormLabel.js +3 -1
- package/HiForm/HiInput.js +20 -1
- package/HiForm/HiUpload.js +290 -45
- package/HiForm/HiUploadField.js +19 -51
- package/HiForm/HiUploadInput.js +18 -7
- package/HiSelectNew/HiSelect.js +15 -16
- package/HiSelectableList/HiSelectableList.js +9 -0
- package/HiSelectableList/HiSelectableListItem.js +3 -7
- package/README.md +1 -1
- package/es/HiCell/CellNumeric.js +1 -1
- package/es/HiDatePicker/HiDatePicker.js +41 -12
- package/es/HiDatePicker/HiDateRangePicker.js +79 -28
- package/es/HiDatePicker/HiDateRangeSelector.js +59 -37
- package/es/HiDatePicker/Overlays/YearPickerOverlay.js +8 -3
- package/es/HiDatePicker/stylesheet.js +32 -17
- package/es/HiForm/HiFormControl.js +27 -11
- package/es/HiForm/HiFormLabel.js +3 -1
- package/es/HiForm/HiInput.js +19 -1
- package/es/HiForm/HiUpload.js +276 -35
- package/es/HiForm/HiUploadField.js +19 -43
- package/es/HiForm/HiUploadInput.js +16 -7
- package/es/HiSelectNew/HiSelect.js +15 -16
- package/es/HiSelectableList/HiSelectableList.js +9 -0
- package/es/HiSelectableList/HiSelectableListItem.js +3 -7
- package/es/styles/createPalette.js +1 -1
- package/es/utils/helpers.js +15 -6
- package/index.es.js +1 -1
- package/index.js +1 -1
- package/package.json +4 -4
- package/styles/createPalette.js +1 -1
- package/umd/hipay-material-ui.development.js +6301 -383
- package/umd/hipay-material-ui.production.min.js +2 -2
- package/utils/helpers.js +15 -5
package/CHANGELOG.md
CHANGED
@@ -1,3 +1,121 @@
|
|
1
|
+
<a name="2.0.0-beta.61"></a>
|
2
|
+
# [2.0.0-beta.61](https://gitlab.hipay.org/backend/hipay-material-ui/compare/0.0.1...2.0.0-beta.61) (2019-01-24)
|
3
|
+
|
4
|
+
|
5
|
+
### Bug Fixes
|
6
|
+
|
7
|
+
* **eslint:** remove eslint warrnings in components (ignore test files) ([d236c62](https://gitlab.hipay.org/backend/hipay-material-ui/commit/d236c62))
|
8
|
+
* **HiBreadcrumb:** clean eslint warnings ([6db12fb](https://gitlab.hipay.org/backend/hipay-material-ui/commit/6db12fb))
|
9
|
+
* **HiDatePicker:** add static positions for custom overlays ([c3edf24](https://gitlab.hipay.org/backend/hipay-material-ui/commit/c3edf24))
|
10
|
+
* **HiExpansionPanel:** Fix props type a requirement ([cbc3b48](https://gitlab.hipay.org/backend/hipay-material-ui/commit/cbc3b48))
|
11
|
+
* **HiInput:** handle focus state through prop when needed to override default comportment ([9a133cc](https://gitlab.hipay.org/backend/hipay-material-ui/commit/9a133cc))
|
12
|
+
* **HiKpiNotice:** eslint clean warnings ([11b5552](https://gitlab.hipay.org/backend/hipay-material-ui/commit/11b5552))
|
13
|
+
* **HiSelect:** Fix build of HiSelectContent ([4b87f78](https://gitlab.hipay.org/backend/hipay-material-ui/commit/4b87f78))
|
14
|
+
* **HiSelect:** focus on undefined item ([2d084e6](https://gitlab.hipay.org/backend/hipay-material-ui/commit/2d084e6))
|
15
|
+
* **HiSelect:** handle staticPosition & width properly for HiDateRangeSelector usage ([7b19ffb](https://gitlab.hipay.org/backend/hipay-material-ui/commit/7b19ffb))
|
16
|
+
* **HiSelectableListItem:** disabled item checkbox color ([9f10552](https://gitlab.hipay.org/backend/hipay-material-ui/commit/9f10552))
|
17
|
+
* **HiSelectableListItem:** remove item width ([a913945](https://gitlab.hipay.org/backend/hipay-material-ui/commit/a913945))
|
18
|
+
* **HiSelectContent:** Remove compute of input value ([b86db83](https://gitlab.hipay.org/backend/hipay-material-ui/commit/b86db83))
|
19
|
+
* **HiSlider:** eslint clean warnings ([08964b1](https://gitlab.hipay.org/backend/hipay-material-ui/commit/08964b1))
|
20
|
+
* **HiUploadField:** clean eslint warnings ([c76aaf1](https://gitlab.hipay.org/backend/hipay-material-ui/commit/c76aaf1))
|
21
|
+
* **migration:** fix contrast threshold ... ([6fb3b18](https://gitlab.hipay.org/backend/hipay-material-ui/commit/6fb3b18))
|
22
|
+
* **package:** add cross-env ([7098fd6](https://gitlab.hipay.org/backend/hipay-material-ui/commit/7098fd6))
|
23
|
+
|
24
|
+
|
25
|
+
### Features
|
26
|
+
|
27
|
+
* **CellImage:** Handle fallbackImage ([254799d](https://gitlab.hipay.org/backend/hipay-material-ui/commit/254799d))
|
28
|
+
* **CellSentinel:** Uniformize cell api with front CellSentinel ([4e2975b](https://gitlab.hipay.org/backend/hipay-material-ui/commit/4e2975b))
|
29
|
+
* **CellSentinel:** Update CellSentinel to the new way (split each result in different column) ([efe2711](https://gitlab.hipay.org/backend/hipay-material-ui/commit/efe2711))
|
30
|
+
* **CellSentinelScore:** Add CellSentinelScore ([2fff04d](https://gitlab.hipay.org/backend/hipay-material-ui/commit/2fff04d))
|
31
|
+
* **CellText:** Handle active prop in CellText & column views in HiTable ([4366e60](https://gitlab.hipay.org/backend/hipay-material-ui/commit/4366e60))
|
32
|
+
* **HiCells:** Add simple cells types (Address, Date, Icon, Image, Numeric, PinToAction, Rate, Senti ([f688517](https://gitlab.hipay.org/backend/hipay-material-ui/commit/f688517))
|
33
|
+
* **HiDatePicke:** add timezone props ([18360a5](https://gitlab.hipay.org/backend/hipay-material-ui/commit/18360a5))
|
34
|
+
* **HiDatePicker:** BREAKING CHANGE - add local prop to handle calendar translations ([b1b3743](https://gitlab.hipay.org/backend/hipay-material-ui/commit/b1b3743))
|
35
|
+
* **HiIcon:** Add mdi-material-ui as available icons via 'mdi_' prefix ([1091d6d](https://gitlab.hipay.org/backend/hipay-material-ui/commit/1091d6d))
|
36
|
+
* **HiMap:** unregister fetch on unmount ([0afa931](https://gitlab.hipay.org/backend/hipay-material-ui/commit/0afa931))
|
37
|
+
* **HiSelect:** Add (NEW) HiSelect, HiNestedSelect, HiDynamicSelect ([4c6447e](https://gitlab.hipay.org/backend/hipay-material-ui/commit/4c6447e))
|
38
|
+
* **HiSelect:** Reset search input on blur & on close ([d9af584](https://gitlab.hipay.org/backend/hipay-material-ui/commit/d9af584))
|
39
|
+
* **HiSelectableList:** Add sort props to sort item list on label ([f412ddc](https://gitlab.hipay.org/backend/hipay-material-ui/commit/f412ddc))
|
40
|
+
* **HiSelectContent:** Add new HiSelectContent & HiNestedSelectContent ([215ad8f](https://gitlab.hipay.org/backend/hipay-material-ui/commit/215ad8f))
|
41
|
+
* **HiSelectContent:** export utils functions ([7c41d87](https://gitlab.hipay.org/backend/hipay-material-ui/commit/7c41d87))
|
42
|
+
* **HiUploadField:** rename component HiUploadField ([593f77e](https://gitlab.hipay.org/backend/hipay-material-ui/commit/593f77e))
|
43
|
+
* **notice:** Création notice KPI ([bba3f89](https://gitlab.hipay.org/backend/hipay-material-ui/commit/bba3f89))
|
44
|
+
|
45
|
+
|
46
|
+
### Performance Improvements
|
47
|
+
|
48
|
+
* **PureFunction:** Use pure & functional components ([220c686](https://gitlab.hipay.org/backend/hipay-material-ui/commit/220c686))
|
49
|
+
|
50
|
+
|
51
|
+
### BREAKING CHANGES
|
52
|
+
|
53
|
+
* **HiDatePicker:** Required "local" props (use polyglot, p.currentLocal)
|
54
|
+
* **HiUploadField:** Components names changes
|
55
|
+
* **HiCells:** Remove CellCountry, CellThirdParty, CellStatus & CellAccount (use generic type
|
56
|
+
CellImage & CellText)
|
57
|
+
* **HiSelect:** HiSelect API change, use HiNestedSelect or HiDynamicSelect relative to situation
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
# [2.0.0-beta.60](https://gitlab.hipay.org/backend/hipay-material-ui/compare/0.0.1...2.0.0-beta.60) (2019-01-14)
|
62
|
+
|
63
|
+
|
64
|
+
### Bug Fixes
|
65
|
+
|
66
|
+
* **eslint:** remove eslint warrnings in components (ignore test files) ([d236c62](https://gitlab.hipay.org/backend/hipay-material-ui/commit/d236c62))
|
67
|
+
* **HiBreadcrumb:** clean eslint warnings ([6db12fb](https://gitlab.hipay.org/backend/hipay-material-ui/commit/6db12fb))
|
68
|
+
* **HiDatePicker:** add static positions for custom overlays ([c3edf24](https://gitlab.hipay.org/backend/hipay-material-ui/commit/c3edf24))
|
69
|
+
* **HiExpansionPanel:** Fix props type a requirement ([cbc3b48](https://gitlab.hipay.org/backend/hipay-material-ui/commit/cbc3b48))
|
70
|
+
* **HiInput:** handle focus state through prop when needed to override default comportment ([9a133cc](https://gitlab.hipay.org/backend/hipay-material-ui/commit/9a133cc))
|
71
|
+
* **HiKpiNotice:** eslint clean warnings ([11b5552](https://gitlab.hipay.org/backend/hipay-material-ui/commit/11b5552))
|
72
|
+
* **HiSelect:** Fix build of HiSelectContent ([4b87f78](https://gitlab.hipay.org/backend/hipay-material-ui/commit/4b87f78))
|
73
|
+
* **HiSelect:** focus on undefined item ([2d084e6](https://gitlab.hipay.org/backend/hipay-material-ui/commit/2d084e6))
|
74
|
+
* **HiSelect:** handle staticPosition & width properly for HiDateRangeSelector usage ([7b19ffb](https://gitlab.hipay.org/backend/hipay-material-ui/commit/7b19ffb))
|
75
|
+
* **HiSelectableListItem:** disabled item checkbox color ([9f10552](https://gitlab.hipay.org/backend/hipay-material-ui/commit/9f10552))
|
76
|
+
* **HiSelectableListItem:** remove item width ([a913945](https://gitlab.hipay.org/backend/hipay-material-ui/commit/a913945))
|
77
|
+
* **HiSelectContent:** Remove compute of input value ([b86db83](https://gitlab.hipay.org/backend/hipay-material-ui/commit/b86db83))
|
78
|
+
* **HiSlider:** eslint clean warnings ([08964b1](https://gitlab.hipay.org/backend/hipay-material-ui/commit/08964b1))
|
79
|
+
* **HiUploadField:** clean eslint warnings ([c76aaf1](https://gitlab.hipay.org/backend/hipay-material-ui/commit/c76aaf1))
|
80
|
+
* **migration:** fix contrast threshold ... ([6fb3b18](https://gitlab.hipay.org/backend/hipay-material-ui/commit/6fb3b18))
|
81
|
+
* **package:** add cross-env ([7098fd6](https://gitlab.hipay.org/backend/hipay-material-ui/commit/7098fd6))
|
82
|
+
|
83
|
+
|
84
|
+
### Features
|
85
|
+
|
86
|
+
* **CellImage:** Handle fallbackImage ([254799d](https://gitlab.hipay.org/backend/hipay-material-ui/commit/254799d))
|
87
|
+
* **CellSentinel:** Uniformize cell api with front CellSentinel ([4e2975b](https://gitlab.hipay.org/backend/hipay-material-ui/commit/4e2975b))
|
88
|
+
* **CellSentinel:** Update CellSentinel to the new way (split each result in different column) ([efe2711](https://gitlab.hipay.org/backend/hipay-material-ui/commit/efe2711))
|
89
|
+
* **CellSentinelScore:** Add CellSentinelScore ([2fff04d](https://gitlab.hipay.org/backend/hipay-material-ui/commit/2fff04d))
|
90
|
+
* **CellText:** Handle active prop in CellText & column views in HiTable ([4366e60](https://gitlab.hipay.org/backend/hipay-material-ui/commit/4366e60))
|
91
|
+
* **HiCells:** Add simple cells types (Address, Date, Icon, Image, Numeric, PinToAction, Rate, Senti ([f688517](https://gitlab.hipay.org/backend/hipay-material-ui/commit/f688517))
|
92
|
+
* **HiDatePicker:** BREAKING CHANGE - add local prop to handle calendar translations ([b1b3743](https://gitlab.hipay.org/backend/hipay-material-ui/commit/b1b3743))
|
93
|
+
* **HiIcon:** Add mdi-material-ui as available icons via 'mdi_' prefix ([1091d6d](https://gitlab.hipay.org/backend/hipay-material-ui/commit/1091d6d))
|
94
|
+
* **HiMap:** unregister fetch on unmount ([0afa931](https://gitlab.hipay.org/backend/hipay-material-ui/commit/0afa931))
|
95
|
+
* **HiSelect:** Add (NEW) HiSelect, HiNestedSelect, HiDynamicSelect ([4c6447e](https://gitlab.hipay.org/backend/hipay-material-ui/commit/4c6447e))
|
96
|
+
* **HiSelect:** Reset search input on blur & on close ([d9af584](https://gitlab.hipay.org/backend/hipay-material-ui/commit/d9af584))
|
97
|
+
* **HiSelectableList:** Add sort props to sort item list on label ([f412ddc](https://gitlab.hipay.org/backend/hipay-material-ui/commit/f412ddc))
|
98
|
+
* **HiSelectContent:** Add new HiSelectContent & HiNestedSelectContent ([215ad8f](https://gitlab.hipay.org/backend/hipay-material-ui/commit/215ad8f))
|
99
|
+
* **HiSelectContent:** export utils functions ([7c41d87](https://gitlab.hipay.org/backend/hipay-material-ui/commit/7c41d87))
|
100
|
+
* **HiUploadField:** rename component HiUploadField ([593f77e](https://gitlab.hipay.org/backend/hipay-material-ui/commit/593f77e))
|
101
|
+
* **notice:** Création notice KPI ([bba3f89](https://gitlab.hipay.org/backend/hipay-material-ui/commit/bba3f89))
|
102
|
+
|
103
|
+
|
104
|
+
### Performance Improvements
|
105
|
+
|
106
|
+
* **PureFunction:** Use pure & functional components ([220c686](https://gitlab.hipay.org/backend/hipay-material-ui/commit/220c686))
|
107
|
+
|
108
|
+
|
109
|
+
### BREAKING CHANGES
|
110
|
+
|
111
|
+
* **HiDatePicker:** Required "local" props (use polyglot, p.currentLocal)
|
112
|
+
* **HiUploadField:** Components names changes
|
113
|
+
* **HiCells:** Remove CellCountry, CellThirdParty, CellStatus & CellAccount (use generic type
|
114
|
+
CellImage & CellText)
|
115
|
+
* **HiSelect:** HiSelect API change, use HiNestedSelect or HiDynamicSelect relative to situation
|
116
|
+
|
117
|
+
|
118
|
+
|
1
119
|
<a name="2.0.0-beta.59"></a>
|
2
120
|
# [2.0.0-beta.59](https://gitlab.hipay.org/backend/hipay-material-ui/compare/0.0.1...2.0.0-beta.59) (2018-12-27)
|
3
121
|
|
package/HiCell/CellNumeric.js
CHANGED
@@ -63,7 +63,7 @@ function (_React$PureComponent) {
|
|
63
63
|
var title = '';
|
64
64
|
|
65
65
|
if (currency) {
|
66
|
-
displayedValue = (0, _helpers.formatCurrencyAmount)(value, view, locale, currency);
|
66
|
+
displayedValue = (0, _helpers.formatCurrencyAmount)(value, view, locale, currency, precision);
|
67
67
|
title = (0, _helpers.formatCurrencyAmount)(value, 'l', locale, currency);
|
68
68
|
} else {
|
69
69
|
displayedValue = (0, _helpers.formatNumber)(value, view, locale, precision);
|
@@ -7,6 +7,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
7
7
|
});
|
8
8
|
exports.default = void 0;
|
9
9
|
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
11
|
+
|
10
12
|
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
11
13
|
|
12
14
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
@@ -29,6 +31,8 @@ var _react = _interopRequireDefault(require("react"));
|
|
29
31
|
|
30
32
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
31
33
|
|
34
|
+
var _momentTimezone = _interopRequireDefault(require("moment-timezone"));
|
35
|
+
|
32
36
|
var _moment = _interopRequireDefault(require("react-day-picker/moment"));
|
33
37
|
|
34
38
|
var _hiLocaleUtils = _interopRequireDefault(require("./hiLocaleUtils"));
|
@@ -65,9 +69,21 @@ function (_React$Component) {
|
|
65
69
|
|
66
70
|
(0, _classCallCheck2.default)(this, HiDatePicker);
|
67
71
|
_this = (0, _possibleConstructorReturn2.default)(this, (0, _getPrototypeOf2.default)(HiDatePicker).call(this));
|
72
|
+
|
73
|
+
_this.handleKeyDown = function (name) {
|
74
|
+
return function (event) {
|
75
|
+
if (event.key === 'Escape' && !event.shiftKey) {
|
76
|
+
_this.datePickerInput.hideDayPicker();
|
77
|
+
|
78
|
+
event.stopPropagation();
|
79
|
+
}
|
80
|
+
};
|
81
|
+
};
|
82
|
+
|
83
|
+
var today = (0, _momentTimezone.default)().tz(props.timezoneName);
|
68
84
|
_this.state = {
|
69
85
|
openedPanel: 'calendar',
|
70
|
-
currentMonth: props.value ? props.value : new Date()
|
86
|
+
currentMonth: props.value ? props.value : new Date(today.year(), today.month(), today.date(), today.hours(), today.minutes(), today.seconds(), today.milliseconds())
|
71
87
|
}; // this.formatDate = this.formatDate.bind(this);
|
72
88
|
|
73
89
|
_this.handleCalendarClick = _this.handleCalendarClick.bind((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)));
|
@@ -93,17 +109,18 @@ function (_React$Component) {
|
|
93
109
|
value: function componentWillUnmount() {
|
94
110
|
clearTimeout(this.timeout);
|
95
111
|
}
|
96
|
-
}, {
|
97
|
-
key: "handleReset",
|
98
|
-
value: function handleReset() {
|
99
|
-
this.handleCurrentMonthChange(new Date());
|
100
|
-
this.props.onReset();
|
101
|
-
}
|
102
112
|
}, {
|
103
113
|
key: "handleInputChange",
|
104
114
|
value: function handleInputChange(event) {
|
105
115
|
this.props.onChange(event.target.value);
|
106
116
|
}
|
117
|
+
}, {
|
118
|
+
key: "handleReset",
|
119
|
+
value: function handleReset() {
|
120
|
+
var today = (0, _momentTimezone.default)().tz(this.props.timezoneName);
|
121
|
+
this.handleCurrentMonthChange(new Date(today.year(), today.month(), today.date(), today.hours(), today.minutes(), today.seconds(), today.milliseconds()));
|
122
|
+
this.props.onReset();
|
123
|
+
}
|
107
124
|
}, {
|
108
125
|
key: "handleDayChange",
|
109
126
|
value: function handleDayChange(day, modifiers) {
|
@@ -232,7 +249,8 @@ function (_React$Component) {
|
|
232
249
|
value: function renderYearPickerOverlay(propsOverlay) {
|
233
250
|
var yearPickerProps = {
|
234
251
|
value: this.state.currentMonth,
|
235
|
-
onChange: this.handleCurrentMonthChange
|
252
|
+
onChange: this.handleCurrentMonthChange,
|
253
|
+
disableFutureDays: this.props.disableFutureDays
|
236
254
|
};
|
237
255
|
return _react.default.createElement(_YearPickerOverlay.default, (0, _extends2.default)({
|
238
256
|
key: 'year-picker-overlay'
|
@@ -258,10 +276,11 @@ function (_React$Component) {
|
|
258
276
|
hideOnDayClick = _this$props.hideOnDayClick,
|
259
277
|
props = (0, _objectWithoutProperties2.default)(_this$props, ["classes", "disabledDays", "disablePastDays", "disableFutureDays", "enableTime", "format", "locale", "minimumDate", "onReset", "translations", "value", "hideOnDayClick"]);
|
260
278
|
var currentMonth = this.state.currentMonth;
|
279
|
+
var today = (0, _momentTimezone.default)().tz(this.props.timezoneName);
|
261
280
|
var effectiveDisabledDays = (0, _extends2.default)({}, disablePastDays && {
|
262
|
-
before: new Date()
|
281
|
+
before: new Date(today.year(), today.month(), today.date(), today.hours(), today.minutes(), today.seconds(), today.milliseconds())
|
263
282
|
}, disableFutureDays && {
|
264
|
-
after: new Date()
|
283
|
+
after: new Date(today.year(), today.month(), today.date(), today.hours(), today.minutes(), today.seconds(), today.milliseconds())
|
265
284
|
}, disabledDays);
|
266
285
|
var modifiersStyles = {
|
267
286
|
selected: {
|
@@ -286,10 +305,10 @@ function (_React$Component) {
|
|
286
305
|
selectedDays: (0, _typeof2.default)(value) === 'object' ? value : undefined,
|
287
306
|
firstDayOfWeek: 1,
|
288
307
|
fromMonth: minimumDate,
|
289
|
-
modifiers: {
|
308
|
+
modifiers: (0, _defineProperty2.default)({
|
290
309
|
disabled: effectiveDisabledDays,
|
291
310
|
selected: value
|
292
|
-
},
|
311
|
+
}, classes.currentDay, new Date(today.year(), today.month(), today.date(), today.hours(), today.minutes(), today.seconds(), today.milliseconds())),
|
293
312
|
modifiersStyles: modifiersStyles,
|
294
313
|
month: currentMonth
|
295
314
|
}, props, {
|
@@ -299,10 +318,14 @@ function (_React$Component) {
|
|
299
318
|
var inputProps = (0, _extends2.default)({}, onReset && {
|
300
319
|
onReset: this.handleReset
|
301
320
|
}, props, {
|
302
|
-
onChange: this.handleInputChange
|
321
|
+
onChange: this.handleInputChange,
|
322
|
+
HiInputProps: {
|
323
|
+
onSubmit: this.props.onSubmit
|
324
|
+
}
|
303
325
|
});
|
304
326
|
return _react.default.createElement("div", {
|
305
|
-
className: classes.root
|
327
|
+
className: classes.root,
|
328
|
+
onKeyDown: this.handleKeyDown()
|
306
329
|
}, _react.default.createElement(_DayPickerInput.default, {
|
307
330
|
ref: function ref(el) {
|
308
331
|
_this2.datePickerInput = el;
|
@@ -334,6 +357,7 @@ HiDatePicker.defaultProps = {
|
|
334
357
|
locale: 'fr-FR',
|
335
358
|
minimumDate: new Date(2013, 4, 1),
|
336
359
|
// by default 1 May 2013
|
360
|
+
timezoneName: 'Europe/Paris',
|
337
361
|
translations: {
|
338
362
|
today: 'today'
|
339
363
|
}
|
@@ -397,6 +421,16 @@ HiDatePicker.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
397
421
|
*/
|
398
422
|
onReset: _propTypes.default.func,
|
399
423
|
|
424
|
+
/**
|
425
|
+
* Callback lorsque l'utilisateur tape sur "Entrée"
|
426
|
+
*/
|
427
|
+
onSubmit: _propTypes.default.func,
|
428
|
+
|
429
|
+
/**
|
430
|
+
* Timezone de l'utilisateur
|
431
|
+
*/
|
432
|
+
timezoneName: _propTypes.default.string,
|
433
|
+
|
400
434
|
/**
|
401
435
|
* Traductions
|
402
436
|
*/
|
@@ -27,6 +27,8 @@ var _react = _interopRequireDefault(require("react"));
|
|
27
27
|
|
28
28
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
29
29
|
|
30
|
+
var _momentTimezone = _interopRequireDefault(require("moment-timezone"));
|
31
|
+
|
30
32
|
var _moment = _interopRequireDefault(require("react-day-picker/moment"));
|
31
33
|
|
32
34
|
var _hiLocaleUtils = _interopRequireDefault(require("./hiLocaleUtils"));
|
@@ -55,8 +57,6 @@ var _HiForm = require("../HiForm");
|
|
55
57
|
|
56
58
|
var _stylesheet = _interopRequireDefault(require("./stylesheet"));
|
57
59
|
|
58
|
-
var _moment2 = _interopRequireDefault(require("moment"));
|
59
|
-
|
60
60
|
var _HiFormControl = _interopRequireDefault(require("../HiForm/HiFormControl"));
|
61
61
|
|
62
62
|
var HiDateRangePicker =
|
@@ -105,9 +105,11 @@ function (_React$Component) {
|
|
105
105
|
};
|
106
106
|
|
107
107
|
_this.onDayToClick = function (day) {
|
108
|
-
var change = (0,
|
108
|
+
var change = (0, _momentTimezone.default)(day) >= (0, _momentTimezone.default)(_this.props.from);
|
109
|
+
var today = (0, _momentTimezone.default)().tz(_this.props.timezoneName);
|
110
|
+
var todayDate = new Date(today.year(), today.month(), today.date(), 23, 59, 59);
|
109
111
|
|
110
|
-
if (change &&
|
112
|
+
if (change && day > todayDate) {
|
111
113
|
change = false;
|
112
114
|
}
|
113
115
|
|
@@ -137,19 +139,22 @@ function (_React$Component) {
|
|
137
139
|
};
|
138
140
|
|
139
141
|
_this.handleChange = function (name, day) {
|
140
|
-
var
|
142
|
+
var _this$props = _this.props,
|
143
|
+
translations = _this$props.translations,
|
144
|
+
timezoneName = _this$props.timezoneName;
|
141
145
|
var date;
|
142
146
|
var error;
|
143
|
-
var
|
144
|
-
var
|
145
|
-
|
146
|
-
|
147
|
-
|
147
|
+
var today = (0, _momentTimezone.default)().tz(timezoneName);
|
148
|
+
var now = new Date(today.year(), today.month(), today.date(), 23, 59, 59);
|
149
|
+
var _this$props2 = _this.props,
|
150
|
+
minimumDate = _this$props2.minimumDate,
|
151
|
+
disableFutureDays = _this$props2.disableFutureDays,
|
152
|
+
format = _this$props2.format;
|
148
153
|
|
149
154
|
if (day instanceof Date) {
|
150
155
|
date = day;
|
151
156
|
} else if (day) {
|
152
|
-
var parsedValue = (0,
|
157
|
+
var parsedValue = (0, _momentTimezone.default)(day, _this.props.format, true);
|
153
158
|
|
154
159
|
if (parsedValue.isValid()) {
|
155
160
|
date = parsedValue.toDate();
|
@@ -159,14 +164,14 @@ function (_React$Component) {
|
|
159
164
|
}
|
160
165
|
|
161
166
|
if (date) {
|
162
|
-
var comparativeDate = name === 'to' ? (0,
|
167
|
+
var comparativeDate = name === 'to' ? (0, _momentTimezone.default)(_this.props.from) : (0, _momentTimezone.default)(_this.props.to);
|
163
168
|
|
164
|
-
if (name === 'to' && comparativeDate > (0,
|
169
|
+
if (name === 'to' && comparativeDate > (0, _momentTimezone.default)(date) || name === 'from' && comparativeDate < (0, _momentTimezone.default)(date)) {
|
165
170
|
error = translations.to_superior_from;
|
166
|
-
} else if ((0,
|
167
|
-
error = translations.date_inferior_min_date.replace('%s', (0,
|
168
|
-
} else if (disableFutureDays &&
|
169
|
-
error = translations.date_superior_max_date.replace('%s', (0,
|
171
|
+
} else if ((0, _momentTimezone.default)(date).utc() < (0, _momentTimezone.default)(minimumDate).utc().startOf('day')) {
|
172
|
+
error = translations.date_inferior_min_date.replace('%s', (0, _momentTimezone.default)(minimumDate).format(format));
|
173
|
+
} else if (disableFutureDays && date > now) {
|
174
|
+
error = translations.date_superior_max_date.replace('%s', (0, _momentTimezone.default)().tz(timezoneName).format(format));
|
170
175
|
}
|
171
176
|
|
172
177
|
if (!_this.props.enableTime) {
|
@@ -216,13 +221,44 @@ function (_React$Component) {
|
|
216
221
|
|
217
222
|
_this.handleReset = function (name) {
|
218
223
|
_this.handleChange(name, undefined);
|
224
|
+
};
|
219
225
|
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
+
_this.handleKeyDown = function (name) {
|
227
|
+
return function (event) {
|
228
|
+
if (event.key === 'Tab' && !event.shiftKey) {
|
229
|
+
var nodeName = document.activeElement.nodeName;
|
230
|
+
|
231
|
+
if (_this.props[name] && nodeName === 'INPUT' && document.activeElement.nextSibling.children.length > 0) {
|
232
|
+
document.activeElement.nextSibling.focus();
|
233
|
+
} else if (name === 'from') {
|
234
|
+
_this.handleDayPickerBlur('from');
|
235
|
+
|
236
|
+
_this.handleDayPickerFocus('to');
|
237
|
+
|
238
|
+
_this.toInput.handleInputFocus();
|
239
|
+
|
240
|
+
setTimeout(function () {
|
241
|
+
document.getElementById("".concat(_this.props.id, "-to")).focus();
|
242
|
+
}, 1);
|
243
|
+
} else if (name === 'to') {
|
244
|
+
_this.handleDayPickerBlur('to');
|
245
|
+
|
246
|
+
_this.toInput.handleInputBlur(event);
|
247
|
+
|
248
|
+
setTimeout(function () {
|
249
|
+
document.activeElement.blur();
|
250
|
+
}, 1);
|
251
|
+
}
|
252
|
+
} else if (event.key === 'Escape' && !event.shiftKey) {
|
253
|
+
if (name === 'from') {
|
254
|
+
_this.fromInput.hideDayPicker();
|
255
|
+
} else if (name === 'to') {
|
256
|
+
_this.toInput.hideDayPicker();
|
257
|
+
}
|
258
|
+
|
259
|
+
event.stopPropagation();
|
260
|
+
}
|
261
|
+
};
|
226
262
|
};
|
227
263
|
|
228
264
|
_this.openPanel = function (panel) {
|
@@ -310,19 +346,19 @@ function (_React$Component) {
|
|
310
346
|
var yearPickerProps = {
|
311
347
|
value: _this.state.currentMonth,
|
312
348
|
onChange: _this.handleCurrentMonthChange,
|
313
|
-
|
349
|
+
disableFutureDays: _this.props.disableFutureDays
|
314
350
|
};
|
315
351
|
return _react.default.createElement(_YearPickerOverlay.default, (0, _extends2.default)({
|
316
352
|
key: "".concat(name, "-year-picker-overlay")
|
317
353
|
}, yearPickerProps, propsOverlay));
|
318
354
|
};
|
319
355
|
|
356
|
+
var _today = (0, _momentTimezone.default)().tz(_this.props.timezoneName);
|
357
|
+
|
320
358
|
_this.state = {
|
321
|
-
currentMonth: new Date(),
|
359
|
+
currentMonth: new Date(_today.year(), _today.month(), _today.date()),
|
322
360
|
focusedInput: '',
|
323
|
-
openedPanel: 'calendar'
|
324
|
-
keyFrom: 1,
|
325
|
-
keyTo: 1
|
361
|
+
openedPanel: 'calendar'
|
326
362
|
};
|
327
363
|
return _this;
|
328
364
|
}
|
@@ -338,35 +374,37 @@ function (_React$Component) {
|
|
338
374
|
var _this2 = this,
|
339
375
|
_classNames;
|
340
376
|
|
341
|
-
var _this$
|
342
|
-
classes = _this$
|
343
|
-
disabled = _this$
|
344
|
-
disabledDays = _this$
|
345
|
-
disableFutureDays = _this$
|
346
|
-
enableTime = _this$
|
347
|
-
labelFrom = _this$
|
348
|
-
labelTo = _this$
|
349
|
-
locale = _this$
|
350
|
-
format = _this$
|
351
|
-
from = _this$
|
352
|
-
fromError = _this$
|
353
|
-
minimumDate = _this$
|
354
|
-
onReset = _this$
|
355
|
-
to = _this$
|
356
|
-
toError = _this$
|
357
|
-
translations = _this$
|
358
|
-
id = _this$
|
359
|
-
staticPosition = _this$
|
360
|
-
errorText = _this$
|
361
|
-
hasSelector = _this$
|
362
|
-
helperIcon = _this$
|
363
|
-
helperText = _this$
|
364
|
-
|
365
|
-
|
366
|
-
var
|
377
|
+
var _this$props3 = this.props,
|
378
|
+
classes = _this$props3.classes,
|
379
|
+
disabled = _this$props3.disabled,
|
380
|
+
disabledDays = _this$props3.disabledDays,
|
381
|
+
disableFutureDays = _this$props3.disableFutureDays,
|
382
|
+
enableTime = _this$props3.enableTime,
|
383
|
+
labelFrom = _this$props3.labelFrom,
|
384
|
+
labelTo = _this$props3.labelTo,
|
385
|
+
locale = _this$props3.locale,
|
386
|
+
format = _this$props3.format,
|
387
|
+
from = _this$props3.from,
|
388
|
+
fromError = _this$props3.fromError,
|
389
|
+
minimumDate = _this$props3.minimumDate,
|
390
|
+
onReset = _this$props3.onReset,
|
391
|
+
to = _this$props3.to,
|
392
|
+
toError = _this$props3.toError,
|
393
|
+
translations = _this$props3.translations,
|
394
|
+
id = _this$props3.id,
|
395
|
+
staticPosition = _this$props3.staticPosition,
|
396
|
+
errorText = _this$props3.errorText,
|
397
|
+
hasSelector = _this$props3.hasSelector,
|
398
|
+
helperIcon = _this$props3.helperIcon,
|
399
|
+
helperText = _this$props3.helperText,
|
400
|
+
timezoneName = _this$props3.timezoneName,
|
401
|
+
props = (0, _objectWithoutProperties2.default)(_this$props3, ["classes", "disabled", "disabledDays", "disableFutureDays", "enableTime", "labelFrom", "labelTo", "locale", "format", "from", "fromError", "minimumDate", "onReset", "to", "toError", "translations", "id", "staticPosition", "errorText", "hasSelector", "helperIcon", "helperText", "timezoneName"]);
|
402
|
+
var today = (0, _momentTimezone.default)().tz(timezoneName);
|
403
|
+
var now = new Date(today.year(), today.month(), today.date(), 23, 59, 59, 999);
|
404
|
+
var modifiers = (0, _defineProperty2.default)({
|
367
405
|
start: from,
|
368
406
|
end: to
|
369
|
-
};
|
407
|
+
}, classes.currentDay, new Date(today.year(), today.month(), today.date()));
|
370
408
|
var modifiersStyles = {
|
371
409
|
start: {
|
372
410
|
borderTopLeftRadius: '50%',
|
@@ -452,7 +490,10 @@ function (_React$Component) {
|
|
452
490
|
}, {
|
453
491
|
id: "".concat(id, "-from"),
|
454
492
|
onChange: this.handleInputChange('from'),
|
455
|
-
disabled: disabled
|
493
|
+
disabled: disabled,
|
494
|
+
HiInputProps: {
|
495
|
+
onSubmit: this.props.onSubmit
|
496
|
+
}
|
456
497
|
});
|
457
498
|
var toInputProps = (0, _extends2.default)({}, onReset && {
|
458
499
|
onReset: function onReset() {
|
@@ -465,7 +506,10 @@ function (_React$Component) {
|
|
465
506
|
}, {
|
466
507
|
id: "".concat(id, "-to"),
|
467
508
|
onChange: this.handleInputChange('to'),
|
468
|
-
disabled: disabled
|
509
|
+
disabled: disabled,
|
510
|
+
HiInputProps: {
|
511
|
+
onSubmit: this.props.onSubmit
|
512
|
+
}
|
469
513
|
});
|
470
514
|
var toClass = (0, _classnames.default)(classes.toInput, (_classNames = {}, (0, _defineProperty2.default)(_classNames, classes.absolute, staticPosition === true && this.state.focusedInput === 'from'), (0, _defineProperty2.default)(_classNames, classes.right4, staticPosition === true && this.state.focusedInput === 'from'), _classNames));
|
471
515
|
|
@@ -475,10 +519,10 @@ function (_React$Component) {
|
|
475
519
|
className: classes.fromInput,
|
476
520
|
onFocus: function onFocus() {
|
477
521
|
return _this2.handleDayPickerFocus('from');
|
478
|
-
}
|
479
|
-
|
522
|
+
},
|
523
|
+
onKeyDown: this.handleKeyDown('from')
|
480
524
|
}, _react.default.createElement("div", null, _react.default.createElement(_DayPickerInput.default, {
|
481
|
-
key:
|
525
|
+
key: '1',
|
482
526
|
ref: function ref(el) {
|
483
527
|
_this2.fromInput = el;
|
484
528
|
},
|
@@ -502,9 +546,10 @@ function (_React$Component) {
|
|
502
546
|
},
|
503
547
|
onBlur: function onBlur() {
|
504
548
|
return _this2.handleDayPickerBlur('to');
|
505
|
-
}
|
549
|
+
},
|
550
|
+
onKeyDown: this.handleKeyDown('to')
|
506
551
|
}, _react.default.createElement(_DayPickerInput.default, {
|
507
|
-
key:
|
552
|
+
key: '1',
|
508
553
|
ref: function ref(el) {
|
509
554
|
_this2.toInput = el;
|
510
555
|
},
|
@@ -516,8 +561,7 @@ function (_React$Component) {
|
|
516
561
|
inputProps: toInputProps,
|
517
562
|
format: enableTime ? "".concat(format, " HH:mm") : format,
|
518
563
|
formatDate: _moment.default.formatDate,
|
519
|
-
parseDate: _moment.default.parseDate
|
520
|
-
,
|
564
|
+
parseDate: _moment.default.parseDate,
|
521
565
|
placeholder: ''
|
522
566
|
})));
|
523
567
|
|
@@ -550,6 +594,7 @@ HiDateRangePicker.defaultProps = {
|
|
550
594
|
locale: 'fr-FR',
|
551
595
|
minimumDate: new Date(2013, 4, 1),
|
552
596
|
// by default 1 May 2013
|
597
|
+
timezoneName: 'Europe/Paris',
|
553
598
|
translations: {
|
554
599
|
today: 'today',
|
555
600
|
hour: 'Hour',
|
@@ -671,11 +716,21 @@ HiDateRangePicker.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
671
716
|
*/
|
672
717
|
onReset: _propTypes.default.func,
|
673
718
|
|
719
|
+
/**
|
720
|
+
* Callback lorsque l'utilisateur tape sur "Entrée"
|
721
|
+
*/
|
722
|
+
onSubmit: _propTypes.default.func,
|
723
|
+
|
674
724
|
/**
|
675
725
|
* Si true, le calendrier sera dans une div static plutot que dans une popper absolute
|
676
726
|
*/
|
677
727
|
staticPosition: _propTypes.default.bool,
|
678
728
|
|
729
|
+
/**
|
730
|
+
* Timezone de l'utilisateur
|
731
|
+
*/
|
732
|
+
timezoneName: _propTypes.default.string,
|
733
|
+
|
679
734
|
/**
|
680
735
|
* Date de fin sélectionnée
|
681
736
|
*/
|