@hipay/hipay-material-ui 2.0.0-beta.60 → 2.0.0-beta.62

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. package/CHANGELOG.md +126 -0
  2. package/HiDatePicker/HiDatePicker.js +37 -12
  3. package/HiDatePicker/HiDateRangePicker.js +71 -57
  4. package/HiDatePicker/HiDateRangeSelector.js +34 -20
  5. package/HiDatePicker/stylesheet.js +32 -17
  6. package/HiSelect/HiSelect.js +489 -607
  7. package/HiSelect/index.js +41 -3
  8. package/HiSelectableList/HiSelectableList.js +68 -3
  9. package/HiSelectableList/HiSelectableListItem.js +22 -10
  10. package/README.md +15 -0
  11. package/es/HiDatePicker/HiDatePicker.js +30 -10
  12. package/es/HiDatePicker/HiDateRangePicker.js +38 -21
  13. package/es/HiDatePicker/HiDateRangeSelector.js +24 -13
  14. package/es/HiDatePicker/stylesheet.js +32 -17
  15. package/es/{HiSelectNew → HiSelect}/HiNestedSelect.js +1 -1
  16. package/es/{HiSelectNew → HiSelect}/HiNestedSelectContent.js +1 -1
  17. package/es/HiSelect/HiSelect.js +441 -564
  18. package/es/{HiSelectNew → HiSelect}/HiSelectContent.js +1 -1
  19. package/es/HiSelect/index.js +4 -1
  20. package/es/HiSelectableList/HiSelectableList.js +65 -4
  21. package/es/HiSelectableList/HiSelectableListItem.js +18 -10
  22. package/es/styles/createPalette.js +1 -1
  23. package/es/utils/helpers.js +9 -1
  24. package/index.es.js +1 -1
  25. package/index.js +1 -1
  26. package/package.json +1 -1
  27. package/styles/createPalette.js +1 -1
  28. package/umd/hipay-material-ui.development.js +7860 -7749
  29. package/umd/hipay-material-ui.production.min.js +2 -2
  30. package/utils/helpers.js +9 -1
  31. package/HiSelect/SelectInput.js +0 -369
  32. package/HiSelectNew/HiSelect.js +0 -929
  33. package/HiSelectNew/HiSelectField.js +0 -146
  34. package/HiSelectNew/index.js +0 -69
  35. package/es/HiSelect/SelectInput.js +0 -321
  36. package/es/HiSelectNew/HiSelect.js +0 -852
  37. package/es/HiSelectNew/HiSelectField.js +0 -111
  38. package/es/HiSelectNew/index.js +0 -6
  39. /package/{HiSelectNew → HiSelect}/HiDynamicSelect.js +0 -0
  40. /package/{HiSelectNew → HiSelect}/HiDynamicSelectField.js +0 -0
  41. /package/{HiSelectNew → HiSelect}/HiNestedSelect.js +0 -0
  42. /package/{HiSelectNew → HiSelect}/HiNestedSelectContent.js +0 -0
  43. /package/{HiSelectNew → HiSelect}/HiNestedSelectField.js +0 -0
  44. /package/{HiSelectNew → HiSelect}/HiSelectContent.js +0 -0
  45. /package/{HiSelectNew → HiSelect}/HiSelectInput.js +0 -0
  46. /package/es/{HiSelectNew → HiSelect}/HiDynamicSelect.js +0 -0
  47. /package/es/{HiSelectNew → HiSelect}/HiDynamicSelectField.js +0 -0
  48. /package/es/{HiSelectNew → HiSelect}/HiNestedSelectField.js +0 -0
  49. /package/es/{HiSelectNew → HiSelect}/HiSelectInput.js +0 -0
package/CHANGELOG.md CHANGED
@@ -1,3 +1,129 @@
1
+ # [2.0.0-beta.62](https://gitlab.hipay.org/backend/hipay-material-ui/compare/0.0.1...2.0.0-beta.62) (2019-02-01)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **eslint:** remove eslint warrnings in components (ignore test files) ([d236c62](https://gitlab.hipay.org/backend/hipay-material-ui/commit/d236c62))
7
+ * **HiBreadcrumb:** clean eslint warnings ([6db12fb](https://gitlab.hipay.org/backend/hipay-material-ui/commit/6db12fb))
8
+ * **HiDatePicker:** add static positions for custom overlays ([c3edf24](https://gitlab.hipay.org/backend/hipay-material-ui/commit/c3edf24))
9
+ * **HiExpansionPanel:** Fix props type a requirement ([cbc3b48](https://gitlab.hipay.org/backend/hipay-material-ui/commit/cbc3b48))
10
+ * **HiInput:** handle focus state through prop when needed to override default comportment ([9a133cc](https://gitlab.hipay.org/backend/hipay-material-ui/commit/9a133cc))
11
+ * **HiKpiNotice:** eslint clean warnings ([11b5552](https://gitlab.hipay.org/backend/hipay-material-ui/commit/11b5552))
12
+ * **HiSelect:** Fix build of HiSelectContent ([4b87f78](https://gitlab.hipay.org/backend/hipay-material-ui/commit/4b87f78))
13
+ * **HiSelect:** focus on undefined item ([2d084e6](https://gitlab.hipay.org/backend/hipay-material-ui/commit/2d084e6))
14
+ * **HiSelect:** handle staticPosition & width properly for HiDateRangeSelector usage ([7b19ffb](https://gitlab.hipay.org/backend/hipay-material-ui/commit/7b19ffb))
15
+ * **HiSelect:** remove HiSelectNew calls ([cc5397d](https://gitlab.hipay.org/backend/hipay-material-ui/commit/cc5397d))
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
+ ### Code Refactoring
26
+
27
+ * deleting the old HiSelect and replacing it by the new (PSYCHE-1382) ([d5fc252](https://gitlab.hipay.org/backend/hipay-material-ui/commit/d5fc252))
28
+
29
+
30
+ ### Features
31
+
32
+ * **CellImage:** Handle fallbackImage ([254799d](https://gitlab.hipay.org/backend/hipay-material-ui/commit/254799d))
33
+ * **CellSentinel:** Uniformize cell api with front CellSentinel ([4e2975b](https://gitlab.hipay.org/backend/hipay-material-ui/commit/4e2975b))
34
+ * **CellSentinel:** Update CellSentinel to the new way (split each result in different column) ([efe2711](https://gitlab.hipay.org/backend/hipay-material-ui/commit/efe2711))
35
+ * **CellSentinelScore:** Add CellSentinelScore ([2fff04d](https://gitlab.hipay.org/backend/hipay-material-ui/commit/2fff04d))
36
+ * **CellText:** Handle active prop in CellText & column views in HiTable ([4366e60](https://gitlab.hipay.org/backend/hipay-material-ui/commit/4366e60))
37
+ * **HiCells:** Add simple cells types (Address, Date, Icon, Image, Numeric, PinToAction, Rate, Senti ([f688517](https://gitlab.hipay.org/backend/hipay-material-ui/commit/f688517))
38
+ * **HiDatePicke:** add timezone props ([18360a5](https://gitlab.hipay.org/backend/hipay-material-ui/commit/18360a5))
39
+ * **HiDatePicker:** BREAKING CHANGE - add local prop to handle calendar translations ([b1b3743](https://gitlab.hipay.org/backend/hipay-material-ui/commit/b1b3743))
40
+ * **HiIcon:** Add mdi-material-ui as available icons via 'mdi_' prefix ([1091d6d](https://gitlab.hipay.org/backend/hipay-material-ui/commit/1091d6d))
41
+ * **HiMap:** unregister fetch on unmount ([0afa931](https://gitlab.hipay.org/backend/hipay-material-ui/commit/0afa931))
42
+ * **HiSelect:** Add (NEW) HiSelect, HiNestedSelect, HiDynamicSelect ([4c6447e](https://gitlab.hipay.org/backend/hipay-material-ui/commit/4c6447e))
43
+ * **HiSelect:** Reset search input on blur & on close ([d9af584](https://gitlab.hipay.org/backend/hipay-material-ui/commit/d9af584))
44
+ * **HiSelectableList:** Add sort props to sort item list on label ([f412ddc](https://gitlab.hipay.org/backend/hipay-material-ui/commit/f412ddc))
45
+ * **HiSelectContent:** Add new HiSelectContent & HiNestedSelectContent ([215ad8f](https://gitlab.hipay.org/backend/hipay-material-ui/commit/215ad8f))
46
+ * **HiSelectContent:** export utils functions ([7c41d87](https://gitlab.hipay.org/backend/hipay-material-ui/commit/7c41d87))
47
+ * **HiUploadField:** rename component HiUploadField ([593f77e](https://gitlab.hipay.org/backend/hipay-material-ui/commit/593f77e))
48
+ * **notice:** Création notice KPI ([bba3f89](https://gitlab.hipay.org/backend/hipay-material-ui/commit/bba3f89))
49
+
50
+
51
+ ### Performance Improvements
52
+
53
+ * **PureFunction:** Use pure & functional components ([220c686](https://gitlab.hipay.org/backend/hipay-material-ui/commit/220c686))
54
+
55
+
56
+ ### BREAKING CHANGES
57
+
58
+ * HiSelectNew no longer exist, make sure you're importing HiSelect instead
59
+ * **HiDatePicker:** Required "local" props (use polyglot, p.currentLocal)
60
+ * **HiUploadField:** Components names changes
61
+ * **HiCells:** Remove CellCountry, CellThirdParty, CellStatus & CellAccount (use generic type
62
+ CellImage & CellText)
63
+ * **HiSelect:** HiSelect API change, use HiNestedSelect or HiDynamicSelect relative to situation
64
+
65
+
66
+
67
+ <a name="2.0.0-beta.61"></a>
68
+ # [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)
69
+
70
+
71
+ ### Bug Fixes
72
+
73
+ * **eslint:** remove eslint warrnings in components (ignore test files) ([d236c62](https://gitlab.hipay.org/backend/hipay-material-ui/commit/d236c62))
74
+ * **HiBreadcrumb:** clean eslint warnings ([6db12fb](https://gitlab.hipay.org/backend/hipay-material-ui/commit/6db12fb))
75
+ * **HiDatePicker:** add static positions for custom overlays ([c3edf24](https://gitlab.hipay.org/backend/hipay-material-ui/commit/c3edf24))
76
+ * **HiExpansionPanel:** Fix props type a requirement ([cbc3b48](https://gitlab.hipay.org/backend/hipay-material-ui/commit/cbc3b48))
77
+ * **HiInput:** handle focus state through prop when needed to override default comportment ([9a133cc](https://gitlab.hipay.org/backend/hipay-material-ui/commit/9a133cc))
78
+ * **HiKpiNotice:** eslint clean warnings ([11b5552](https://gitlab.hipay.org/backend/hipay-material-ui/commit/11b5552))
79
+ * **HiSelect:** Fix build of HiSelectContent ([4b87f78](https://gitlab.hipay.org/backend/hipay-material-ui/commit/4b87f78))
80
+ * **HiSelect:** focus on undefined item ([2d084e6](https://gitlab.hipay.org/backend/hipay-material-ui/commit/2d084e6))
81
+ * **HiSelect:** handle staticPosition & width properly for HiDateRangeSelector usage ([7b19ffb](https://gitlab.hipay.org/backend/hipay-material-ui/commit/7b19ffb))
82
+ * **HiSelectableListItem:** disabled item checkbox color ([9f10552](https://gitlab.hipay.org/backend/hipay-material-ui/commit/9f10552))
83
+ * **HiSelectableListItem:** remove item width ([a913945](https://gitlab.hipay.org/backend/hipay-material-ui/commit/a913945))
84
+ * **HiSelectContent:** Remove compute of input value ([b86db83](https://gitlab.hipay.org/backend/hipay-material-ui/commit/b86db83))
85
+ * **HiSlider:** eslint clean warnings ([08964b1](https://gitlab.hipay.org/backend/hipay-material-ui/commit/08964b1))
86
+ * **HiUploadField:** clean eslint warnings ([c76aaf1](https://gitlab.hipay.org/backend/hipay-material-ui/commit/c76aaf1))
87
+ * **migration:** fix contrast threshold ... ([6fb3b18](https://gitlab.hipay.org/backend/hipay-material-ui/commit/6fb3b18))
88
+ * **package:** add cross-env ([7098fd6](https://gitlab.hipay.org/backend/hipay-material-ui/commit/7098fd6))
89
+
90
+
91
+ ### Features
92
+
93
+ * **CellImage:** Handle fallbackImage ([254799d](https://gitlab.hipay.org/backend/hipay-material-ui/commit/254799d))
94
+ * **CellSentinel:** Uniformize cell api with front CellSentinel ([4e2975b](https://gitlab.hipay.org/backend/hipay-material-ui/commit/4e2975b))
95
+ * **CellSentinel:** Update CellSentinel to the new way (split each result in different column) ([efe2711](https://gitlab.hipay.org/backend/hipay-material-ui/commit/efe2711))
96
+ * **CellSentinelScore:** Add CellSentinelScore ([2fff04d](https://gitlab.hipay.org/backend/hipay-material-ui/commit/2fff04d))
97
+ * **CellText:** Handle active prop in CellText & column views in HiTable ([4366e60](https://gitlab.hipay.org/backend/hipay-material-ui/commit/4366e60))
98
+ * **HiCells:** Add simple cells types (Address, Date, Icon, Image, Numeric, PinToAction, Rate, Senti ([f688517](https://gitlab.hipay.org/backend/hipay-material-ui/commit/f688517))
99
+ * **HiDatePicke:** add timezone props ([18360a5](https://gitlab.hipay.org/backend/hipay-material-ui/commit/18360a5))
100
+ * **HiDatePicker:** BREAKING CHANGE - add local prop to handle calendar translations ([b1b3743](https://gitlab.hipay.org/backend/hipay-material-ui/commit/b1b3743))
101
+ * **HiIcon:** Add mdi-material-ui as available icons via 'mdi_' prefix ([1091d6d](https://gitlab.hipay.org/backend/hipay-material-ui/commit/1091d6d))
102
+ * **HiMap:** unregister fetch on unmount ([0afa931](https://gitlab.hipay.org/backend/hipay-material-ui/commit/0afa931))
103
+ * **HiSelect:** Add (NEW) HiSelect, HiNestedSelect, HiDynamicSelect ([4c6447e](https://gitlab.hipay.org/backend/hipay-material-ui/commit/4c6447e))
104
+ * **HiSelect:** Reset search input on blur & on close ([d9af584](https://gitlab.hipay.org/backend/hipay-material-ui/commit/d9af584))
105
+ * **HiSelectableList:** Add sort props to sort item list on label ([f412ddc](https://gitlab.hipay.org/backend/hipay-material-ui/commit/f412ddc))
106
+ * **HiSelectContent:** Add new HiSelectContent & HiNestedSelectContent ([215ad8f](https://gitlab.hipay.org/backend/hipay-material-ui/commit/215ad8f))
107
+ * **HiSelectContent:** export utils functions ([7c41d87](https://gitlab.hipay.org/backend/hipay-material-ui/commit/7c41d87))
108
+ * **HiUploadField:** rename component HiUploadField ([593f77e](https://gitlab.hipay.org/backend/hipay-material-ui/commit/593f77e))
109
+ * **notice:** Création notice KPI ([bba3f89](https://gitlab.hipay.org/backend/hipay-material-ui/commit/bba3f89))
110
+
111
+
112
+ ### Performance Improvements
113
+
114
+ * **PureFunction:** Use pure & functional components ([220c686](https://gitlab.hipay.org/backend/hipay-material-ui/commit/220c686))
115
+
116
+
117
+ ### BREAKING CHANGES
118
+
119
+ * **HiDatePicker:** Required "local" props (use polyglot, p.currentLocal)
120
+ * **HiUploadField:** Components names changes
121
+ * **HiCells:** Remove CellCountry, CellThirdParty, CellStatus & CellAccount (use generic type
122
+ CellImage & CellText)
123
+ * **HiSelect:** HiSelect API change, use HiNestedSelect or HiDynamicSelect relative to situation
124
+
125
+
126
+
1
127
  # [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)
2
128
 
3
129
 
@@ -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) {
@@ -259,10 +276,11 @@ function (_React$Component) {
259
276
  hideOnDayClick = _this$props.hideOnDayClick,
260
277
  props = (0, _objectWithoutProperties2.default)(_this$props, ["classes", "disabledDays", "disablePastDays", "disableFutureDays", "enableTime", "format", "locale", "minimumDate", "onReset", "translations", "value", "hideOnDayClick"]);
261
278
  var currentMonth = this.state.currentMonth;
279
+ var today = (0, _momentTimezone.default)().tz(this.props.timezoneName);
262
280
  var effectiveDisabledDays = (0, _extends2.default)({}, disablePastDays && {
263
- before: new Date()
281
+ before: new Date(today.year(), today.month(), today.date(), today.hours(), today.minutes(), today.seconds(), today.milliseconds())
264
282
  }, disableFutureDays && {
265
- after: new Date()
283
+ after: new Date(today.year(), today.month(), today.date(), today.hours(), today.minutes(), today.seconds(), today.milliseconds())
266
284
  }, disabledDays);
267
285
  var modifiersStyles = {
268
286
  selected: {
@@ -287,10 +305,10 @@ function (_React$Component) {
287
305
  selectedDays: (0, _typeof2.default)(value) === 'object' ? value : undefined,
288
306
  firstDayOfWeek: 1,
289
307
  fromMonth: minimumDate,
290
- modifiers: {
308
+ modifiers: (0, _defineProperty2.default)({
291
309
  disabled: effectiveDisabledDays,
292
310
  selected: value
293
- },
311
+ }, classes.currentDay, new Date(today.year(), today.month(), today.date(), today.hours(), today.minutes(), today.seconds(), today.milliseconds())),
294
312
  modifiersStyles: modifiersStyles,
295
313
  month: currentMonth
296
314
  }, props, {
@@ -306,7 +324,8 @@ function (_React$Component) {
306
324
  }
307
325
  });
308
326
  return _react.default.createElement("div", {
309
- className: classes.root
327
+ className: classes.root,
328
+ onKeyDown: this.handleKeyDown()
310
329
  }, _react.default.createElement(_DayPickerInput.default, {
311
330
  ref: function ref(el) {
312
331
  _this2.datePickerInput = el;
@@ -338,6 +357,7 @@ HiDatePicker.defaultProps = {
338
357
  locale: 'fr-FR',
339
358
  minimumDate: new Date(2013, 4, 1),
340
359
  // by default 1 May 2013
360
+ timezoneName: 'Europe/Paris',
341
361
  translations: {
342
362
  today: 'today'
343
363
  }
@@ -406,6 +426,11 @@ HiDatePicker.propTypes = process.env.NODE_ENV !== "production" ? {
406
426
  */
407
427
  onSubmit: _propTypes.default.func,
408
428
 
429
+ /**
430
+ * Timezone de l'utilisateur
431
+ */
432
+ timezoneName: _propTypes.default.string,
433
+
409
434
  /**
410
435
  * Traductions
411
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, _moment2.default)(day) >= (0, _moment2.default)(_this.props.from);
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 && _this.props.disableFutureDays && (0, _moment2.default)(day).utc() > (0, _moment2.default)().utc().endOf('day')) {
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 translations = _this.props.translations;
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 now = new Date();
144
- var _this$props = _this.props,
145
- minimumDate = _this$props.minimumDate,
146
- disableFutureDays = _this$props.disableFutureDays,
147
- format = _this$props.format;
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, _moment2.default)(day, _this.props.format, true);
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, _moment2.default)(_this.props.from) : (0, _moment2.default)(_this.props.to);
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, _moment2.default)(date) || name === 'from' && comparativeDate < (0, _moment2.default)(date)) {
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, _moment2.default)(date).utc() < (0, _moment2.default)(minimumDate).utc().startOf('day')) {
167
- error = translations.date_inferior_min_date.replace('%s', (0, _moment2.default)(minimumDate).format(format));
168
- } else if (disableFutureDays && (0, _moment2.default)(date).utc() > (0, _moment2.default)(now).utc().endOf('day')) {
169
- error = translations.date_superior_max_date.replace('%s', (0, _moment2.default)().format(format));
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,6 @@ function (_React$Component) {
216
221
 
217
222
  _this.handleReset = function (name) {
218
223
  _this.handleChange(name, undefined);
219
-
220
- _this.setState(function (prevState) {
221
- return {
222
- keyFrom: prevState.keyFrom === 1 ? 2 : 1,
223
- keyTo: prevState.keyTo === 1 ? 2 : 1
224
- };
225
- });
226
224
  };
227
225
 
228
226
  _this.handleKeyDown = function (name) {
@@ -251,6 +249,14 @@ function (_React$Component) {
251
249
  document.activeElement.blur();
252
250
  }, 1);
253
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();
254
260
  }
255
261
  };
256
262
  };
@@ -347,12 +353,12 @@ function (_React$Component) {
347
353
  }, yearPickerProps, propsOverlay));
348
354
  };
349
355
 
356
+ var _today = (0, _momentTimezone.default)().tz(_this.props.timezoneName);
357
+
350
358
  _this.state = {
351
- currentMonth: new Date(),
359
+ currentMonth: new Date(_today.year(), _today.month(), _today.date()),
352
360
  focusedInput: '',
353
- openedPanel: 'calendar',
354
- keyFrom: 1,
355
- keyTo: 1
361
+ openedPanel: 'calendar'
356
362
  };
357
363
  return _this;
358
364
  }
@@ -368,35 +374,37 @@ function (_React$Component) {
368
374
  var _this2 = this,
369
375
  _classNames;
370
376
 
371
- var _this$props2 = this.props,
372
- classes = _this$props2.classes,
373
- disabled = _this$props2.disabled,
374
- disabledDays = _this$props2.disabledDays,
375
- disableFutureDays = _this$props2.disableFutureDays,
376
- enableTime = _this$props2.enableTime,
377
- labelFrom = _this$props2.labelFrom,
378
- labelTo = _this$props2.labelTo,
379
- locale = _this$props2.locale,
380
- format = _this$props2.format,
381
- from = _this$props2.from,
382
- fromError = _this$props2.fromError,
383
- minimumDate = _this$props2.minimumDate,
384
- onReset = _this$props2.onReset,
385
- to = _this$props2.to,
386
- toError = _this$props2.toError,
387
- translations = _this$props2.translations,
388
- id = _this$props2.id,
389
- staticPosition = _this$props2.staticPosition,
390
- errorText = _this$props2.errorText,
391
- hasSelector = _this$props2.hasSelector,
392
- helperIcon = _this$props2.helperIcon,
393
- helperText = _this$props2.helperText,
394
- props = (0, _objectWithoutProperties2.default)(_this$props2, ["classes", "disabled", "disabledDays", "disableFutureDays", "enableTime", "labelFrom", "labelTo", "locale", "format", "from", "fromError", "minimumDate", "onReset", "to", "toError", "translations", "id", "staticPosition", "errorText", "hasSelector", "helperIcon", "helperText"]);
395
- var now = new Date();
396
- var modifiers = {
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)({
397
405
  start: from,
398
406
  end: to
399
- };
407
+ }, classes.currentDay, new Date(today.year(), today.month(), today.date()));
400
408
  var modifiersStyles = {
401
409
  start: {
402
410
  borderTopLeftRadius: '50%',
@@ -514,7 +522,7 @@ function (_React$Component) {
514
522
  },
515
523
  onKeyDown: this.handleKeyDown('from')
516
524
  }, _react.default.createElement("div", null, _react.default.createElement(_DayPickerInput.default, {
517
- key: this.state.keyFrom,
525
+ key: '1',
518
526
  ref: function ref(el) {
519
527
  _this2.fromInput = el;
520
528
  },
@@ -541,7 +549,7 @@ function (_React$Component) {
541
549
  },
542
550
  onKeyDown: this.handleKeyDown('to')
543
551
  }, _react.default.createElement(_DayPickerInput.default, {
544
- key: this.state.keyTo,
552
+ key: '1',
545
553
  ref: function ref(el) {
546
554
  _this2.toInput = el;
547
555
  },
@@ -586,6 +594,7 @@ HiDateRangePicker.defaultProps = {
586
594
  locale: 'fr-FR',
587
595
  minimumDate: new Date(2013, 4, 1),
588
596
  // by default 1 May 2013
597
+ timezoneName: 'Europe/Paris',
589
598
  translations: {
590
599
  today: 'today',
591
600
  hour: 'Hour',
@@ -717,6 +726,11 @@ HiDateRangePicker.propTypes = process.env.NODE_ENV !== "production" ? {
717
726
  */
718
727
  staticPosition: _propTypes.default.bool,
719
728
 
729
+ /**
730
+ * Timezone de l'utilisateur
731
+ */
732
+ timezoneName: _propTypes.default.string,
733
+
720
734
  /**
721
735
  * Date de fin sélectionnée
722
736
  */
@@ -39,7 +39,7 @@ var _Grid = _interopRequireDefault(require("@material-ui/core/Grid"));
39
39
 
40
40
  var _withStyles = _interopRequireDefault(require("../styles/withStyles"));
41
41
 
42
- var _HiSelectField = _interopRequireDefault(require("../HiSelectNew/HiSelectField"));
42
+ var _HiSelectField = _interopRequireDefault(require("../HiSelect/HiSelectField"));
43
43
 
44
44
  var _HiDateRangePicker = _interopRequireDefault(require("./HiDateRangePicker"));
45
45
 
@@ -243,23 +243,7 @@ function (_React$Component) {
243
243
  return _ref = {}, (0, _defineProperty2.default)(_ref, name, value), (0, _defineProperty2.default)(_ref, "key", prevState.key === 1 ? 2 : 1), _ref;
244
244
  });
245
245
 
246
- var selectedOption = _this.options.find(function (option) {
247
- return option.id === value;
248
- });
249
-
250
- if (selectedOption) {
251
- _this.props.onChange('from', new Date(selectedOption.from.format('YYYY-MM-DD HH:mm:ss')));
252
-
253
- _this.props.onChange('to', new Date(selectedOption.to.format('YYYY-MM-DD HH:mm:ss')));
254
-
255
- _this.props.onChange('fromError', false);
256
-
257
- _this.props.onChange('toError', false);
258
- }
259
-
260
- if (_this.props.returnSelectValue === true) {
261
- _this.props.onChange('period', value);
262
- }
246
+ _this.updateDates(value);
263
247
  };
264
248
  };
265
249
 
@@ -282,15 +266,45 @@ function (_React$Component) {
282
266
  });
283
267
  }
284
268
  }
269
+ }, {
270
+ key: "componentDidUpdate",
271
+ value: function componentDidUpdate(prevProps) {
272
+ var _this2 = this;
273
+
274
+ if (prevProps.timezoneName !== this.props.timezoneName) {
275
+ this.options = this.props.availableOptionKeys.map(function (key) {
276
+ return buildDateRangeOptionByKey(key, _this2.props.translations, _this2.props.format, _this2.props.timezoneName);
277
+ });
278
+ this.updateDates(this.state.selectedPreset);
279
+ }
280
+ }
285
281
  }, {
286
282
  key: "componentWillUnmount",
287
283
  value: function componentWillUnmount() {
288
284
  clearTimeout(this.timeout); // TODO : supprimer ?
289
285
  }
286
+ }, {
287
+ key: "updateDates",
288
+ value: function updateDates(value) {
289
+ var selectedOption = this.options.find(function (option) {
290
+ return option.id === value;
291
+ });
292
+
293
+ if (selectedOption) {
294
+ this.props.onChange('from', new Date(selectedOption.from.format('YYYY-MM-DD HH:mm:ss')));
295
+ this.props.onChange('to', new Date(selectedOption.to.format('YYYY-MM-DD HH:mm:ss')));
296
+ this.props.onChange('fromError', false);
297
+ this.props.onChange('toError', false);
298
+ }
299
+
300
+ if (this.props.returnSelectValue === true) {
301
+ this.props.onChange('period', value);
302
+ }
303
+ }
290
304
  }, {
291
305
  key: "render",
292
306
  value: function render() {
293
- var _this2 = this;
307
+ var _this3 = this;
294
308
 
295
309
  var _this$props = this.props,
296
310
  disabled = _this$props.disabled,
@@ -329,7 +343,7 @@ function (_React$Component) {
329
343
  spacing: 8,
330
344
  className: classes.root,
331
345
  ref: function ref(container) {
332
- _this2.container = container;
346
+ _this3.container = container;
333
347
  }
334
348
  }, _react.default.createElement(_Grid.default, {
335
349
  item: true,
@@ -184,23 +184,22 @@ var _default = function _default(theme) {
184
184
 
185
185
  /* default modifiers */
186
186
  // Added to the day's cell for the current day
187
- today: {
188
- // color: theme.palette.primary.light,
189
- position: 'relative',
190
- borderRadius: '50%',
191
- color: "".concat(theme.palette.neutral.dark, " !important"),
192
- fontWeight: theme.typography.fontWeightMedium,
193
- '&:before': {
194
- content: '""',
195
- position: 'absolute',
196
- top: 0,
197
- left: 0,
198
- display: 'inline-block',
199
- width: '100%',
200
- height: '100%',
201
- borderRadius: '50%',
202
- boxShadow: "inset 0 0 0 2px ".concat(theme.palette.neutral.main)
203
- }
187
+ today: {// color: theme.palette.primary.light,
188
+ // position: 'relative',
189
+ // borderRadius: '50%',
190
+ // color: `${theme.palette.neutral.dark} !important`,
191
+ // fontWeight: theme.typography.fontWeightMedium,
192
+ // '&:before': {
193
+ // content: '""',
194
+ // position: 'absolute',
195
+ // top: 0,
196
+ // left: 0,
197
+ // display: 'inline-block',
198
+ // width: '100%',
199
+ // height: '100%',
200
+ // borderRadius: '50%',
201
+ // boxShadow: `inset 0 0 0 2px ${theme.palette.neutral.main}`,
202
+ // },
204
203
  },
205
204
  // Added to the day's cell outside the current month
206
205
  outside: {
@@ -228,6 +227,22 @@ var _default = function _default(theme) {
228
227
  color: theme.palette.primary.contrastText,
229
228
  borderRadius: '0%',
230
229
  border: 'none'
230
+ },
231
+ currentDay: {
232
+ position: 'relative',
233
+ color: "".concat(theme.palette.neutral.dark, " !important"),
234
+ fontWeight: theme.typography.fontWeightMedium,
235
+ '&:before': {
236
+ content: '""',
237
+ position: 'absolute',
238
+ top: 0,
239
+ left: 0,
240
+ display: 'inline-block',
241
+ width: '100%',
242
+ height: '100%',
243
+ borderRadius: '50%',
244
+ boxShadow: "inset 0 0 0 2px ".concat(theme.palette.neutral.main)
245
+ }
231
246
  }
232
247
  };
233
248
  };