@hipay/hipay-material-ui 2.0.0-beta.53 → 2.0.0-beta.55

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. package/HiCell/CellImage.js +16 -4
  2. package/HiCell/CellNumeric.js +1 -2
  3. package/HiCell/CellSentinel.js +33 -109
  4. package/HiCell/CellSentinelScore.js +100 -0
  5. package/HiCell/CellTextStyled.js +71 -0
  6. package/HiCell/index.js +9 -1
  7. package/HiChip/HiChip.js +2 -1
  8. package/HiColoredLabel/HiColoredLabel.js +14 -4
  9. package/HiDatePicker/HiDatePicker.js +1 -1
  10. package/HiDatePicker/HiDateRangePicker.js +349 -420
  11. package/HiDatePicker/HiDateRangeSelector.js +80 -62
  12. package/HiDatePicker/NavBar.js +2 -1
  13. package/HiDatePicker/Overlays/TimePickerOverlay.js +1 -1
  14. package/HiDatePicker/Overlays/YearPickerOverlay.js +3 -3
  15. package/HiForm/HiFormControl.js +5 -4
  16. package/HiSelect/HiSuggestSelect.js +16 -2
  17. package/HiSelectNew/HiSelect.js +4 -1
  18. package/HiSelectableList/HiSelectableListItem.js +3 -1
  19. package/HiSwitch/HiSwitch.js +2 -1
  20. package/HiTable/HiCellBuilder.js +31 -27
  21. package/HiTable/HiTableHeader.js +21 -13
  22. package/HiTable/constants.js +7 -5
  23. package/es/HiCell/CellImage.js +13 -2
  24. package/es/HiCell/CellNumeric.js +1 -2
  25. package/es/HiCell/CellSentinel.js +32 -108
  26. package/es/HiCell/CellSentinelScore.js +60 -0
  27. package/es/HiCell/CellTextStyled.js +57 -0
  28. package/es/HiCell/index.js +2 -1
  29. package/es/HiChip/HiChip.js +2 -1
  30. package/es/HiColoredLabel/HiColoredLabel.js +14 -3
  31. package/es/HiDatePicker/HiDatePicker.js +1 -1
  32. package/es/HiDatePicker/HiDateRangePicker.js +312 -363
  33. package/es/HiDatePicker/HiDateRangeSelector.js +70 -56
  34. package/es/HiDatePicker/NavBar.js +2 -1
  35. package/es/HiDatePicker/Overlays/TimePickerOverlay.js +1 -1
  36. package/es/HiDatePicker/Overlays/YearPickerOverlay.js +3 -3
  37. package/es/HiForm/HiFormControl.js +5 -4
  38. package/es/HiSelect/HiSuggestSelect.js +16 -3
  39. package/es/HiSelectNew/HiSelect.js +4 -1
  40. package/es/HiSelectableList/HiSelectableListItem.js +3 -1
  41. package/es/HiSwitch/HiSwitch.js +2 -1
  42. package/es/HiTable/HiCellBuilder.js +30 -27
  43. package/es/HiTable/HiTableHeader.js +20 -14
  44. package/es/HiTable/constants.js +8 -1
  45. package/es/styles/createPalette.js +3 -3
  46. package/index.es.js +1 -1
  47. package/index.js +1 -1
  48. package/package.json +1 -1
  49. package/styles/createPalette.js +3 -3
  50. package/umd/hipay-material-ui.development.js +9843 -6197
  51. package/umd/hipay-material-ui.production.min.js +2 -2
  52. package/yarn-error.log +0 -110
@@ -7,12 +7,12 @@ 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 _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
11
13
 
12
14
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
13
15
 
14
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
15
-
16
16
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
17
17
 
18
18
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
@@ -23,8 +23,6 @@ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/ge
23
23
 
24
24
  var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
25
25
 
26
- var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
27
-
28
26
  var _react = _interopRequireDefault(require("react"));
29
27
 
30
28
  var _propTypes = _interopRequireDefault(require("prop-types"));
@@ -37,8 +35,6 @@ var _classnames = _interopRequireDefault(require("classnames"));
37
35
 
38
36
  var _withStyles = _interopRequireDefault(require("../styles/withStyles"));
39
37
 
40
- var _helpers = require("../utils/helpers");
41
-
42
38
  var _Caption = _interopRequireDefault(require("./Caption"));
43
39
 
44
40
  var _Overlay = _interopRequireDefault(require("./Overlays/Overlay"));
@@ -57,6 +53,10 @@ var _HiForm = require("../HiForm");
57
53
 
58
54
  var _stylesheet = _interopRequireDefault(require("./stylesheet"));
59
55
 
56
+ var _moment2 = _interopRequireDefault(require("moment"));
57
+
58
+ var _HiFormControl = _interopRequireDefault(require("../HiForm/HiFormControl"));
59
+
60
60
  var HiDateRangePicker =
61
61
  /*#__PURE__*/
62
62
  function (_React$Component) {
@@ -68,399 +68,297 @@ function (_React$Component) {
68
68
  (0, _classCallCheck2.default)(this, HiDateRangePicker);
69
69
  _this = (0, _possibleConstructorReturn2.default)(this, (0, _getPrototypeOf2.default)(HiDateRangePicker).call(this));
70
70
 
71
- _this.handleInputChange = function (inputName) {
72
- return function (event) {
73
- _this.event = event;
71
+ _this.handleDayChange = function (name, day) {
72
+ if (day) {
73
+ // if time disabled, focus TO input
74
+ // else focus current input
75
+ if (!_this.props.enableTime) {
76
+ if (day instanceof Date) {
77
+ if (name === 'from' && _this.toInput) {
78
+ _this.toInput.getInput().focus();
79
+ }
80
+ }
81
+ } else {
82
+ _this.timeout = setTimeout(function () {
83
+ if (_this["".concat(name, "Input")].getInput()) {
84
+ _this["".concat(name, "Input")].getInput().focus();
85
+ }
86
+ }, 10);
87
+ }
74
88
 
75
- _this.props.onChange(inputName, event.target.value);
76
- };
89
+ if (_this.props.onChange) {
90
+ _this.handleChange(name, day);
91
+ }
92
+
93
+ if (_this.props.enableTime) {
94
+ _this.openPanel('time');
95
+ }
96
+ }
77
97
  };
78
98
 
79
- _this.handleDayPickerFocus = function (name) {
80
- return function () {
81
- _this.setState({
82
- focusedInput: name
83
- });
99
+ _this.handleInputChange = function (inputName) {
100
+ return function (event) {
101
+ _this.handleChange(inputName, event.target.value);
84
102
  };
85
103
  };
86
104
 
87
- _this.handleDayPickerBlur = function (name) {
88
- return function () {
89
- _this.setState({
90
- focusedInput: ''
91
- });
105
+ _this.onDayToClick = function (day) {
106
+ var change = (0, _moment2.default)(day) >= (0, _moment2.default)(_this.props.from);
92
107
 
93
- if (_this.props.onBlur) {
94
- _this.props.onBlur(name);
95
- }
96
- };
97
- };
108
+ if (change && _this.props.disableFutureDays && (0, _moment2.default)(day) > (0, _moment2.default)()) {
109
+ change = false;
110
+ }
98
111
 
99
- _this.state = {
100
- fromCurrentMonth: props.from ? props.from : new Date(),
101
- toCurrentMonth: props.to ? props.to : new Date(),
102
- focusedInput: ''
112
+ if (change) {
113
+ console.log((0, _extends2.default)({}, _this.props));
114
+
115
+ _this.handleDayChange('to', day);
116
+
117
+ document.activeElement.blur();
118
+ }
103
119
  };
104
- _this.handleReset = _this.handleReset.bind((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)));
105
- _this.handleDayChange = _this.handleDayChange.bind((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)));
106
- _this.handleDayChangeFrom = _this.handleDayChangeFrom.bind((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)));
107
- _this.handleDayChangeTo = _this.handleDayChangeTo.bind((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)));
108
- _this.handleCurrentMonthChange = _this.handleCurrentMonthChange.bind((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)));
109
- _this.handleCurrentMonthChangeFrom = _this.handleCurrentMonthChangeFrom.bind((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)));
110
- _this.handleCurrentMonthChangeTo = _this.handleCurrentMonthChangeTo.bind((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)));
111
- _this.handleTimeChange = _this.handleTimeChange.bind((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)));
112
- _this.handleCalendarClick = _this.handleCalendarClick.bind((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)));
113
- _this.handleCalendarClickFrom = _this.handleCalendarClickFrom.bind((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)));
114
- _this.handleCalendarClickTo = _this.handleCalendarClickTo.bind((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)));
115
- _this.handleClockClick = _this.handleClockClick.bind((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)));
116
- _this.handleClockClickFrom = _this.handleClockClickFrom.bind((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)));
117
- _this.handleClockClickTo = _this.handleClockClickTo.bind((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)));
118
- _this.handleMonthClick = _this.handleMonthClick.bind((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)));
119
- _this.handleMonthClickFrom = _this.handleMonthClickFrom.bind((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)));
120
- _this.handleMonthClickTo = _this.handleMonthClickTo.bind((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)));
121
- _this.handleYearClick = _this.handleYearClick.bind((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)));
122
- _this.handleYearClickFrom = _this.handleYearClickFrom.bind((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)));
123
- _this.handleYearClickTo = _this.handleYearClickTo.bind((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)));
124
- _this.handleDayPickerFocus = _this.handleDayPickerFocus.bind((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)));
125
- _this.handleDayPickerBlur = _this.handleDayPickerBlur.bind((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)));
126
- _this.handleInputChange = _this.handleInputChange.bind((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)));
127
- _this.openPanel = _this.openPanel.bind((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)));
128
- _this.renderCaption = _this.renderCaption.bind((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)));
129
- _this.renderCaptionFrom = _this.renderCaptionFrom.bind((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)));
130
- _this.renderCaptionTo = _this.renderCaptionTo.bind((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)));
131
- _this.renderNavBar = _this.renderNavBar.bind((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)));
132
- _this.renderNavBarFrom = _this.renderNavBarFrom.bind((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)));
133
- _this.renderNavBarTo = _this.renderNavBarTo.bind((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)));
134
- _this.renderOverlay = _this.renderOverlay.bind((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)));
135
- _this.renderOverlayFrom = _this.renderOverlayFrom.bind((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)));
136
- _this.renderOverlayTo = _this.renderOverlayTo.bind((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)));
137
- _this.renderMonthPickerOverlay = _this.renderMonthPickerOverlay.bind((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)));
138
- _this.renderTimePickerOverlay = _this.renderTimePickerOverlay.bind((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)));
139
- _this.renderYearPickerOverlay = _this.renderYearPickerOverlay.bind((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)));
140
- return _this;
141
- }
142
120
 
143
- (0, _createClass2.default)(HiDateRangePicker, [{
144
- key: "componentDidUpdate",
145
- value: function componentDidUpdate(prevProps) {
146
- var _this2 = this;
147
-
148
- // Focus From input on enabling
149
- if (prevProps.disabled === true && this.props.disabled === false) {
150
- this.timeout = setTimeout(function () {
151
- if (_this2.fromInput.getInput()) {
152
- _this2.fromInput.getInput().focus();
153
- }
154
- }, 0);
121
+ _this.handleTimeChange = function (name, date, precision) {
122
+ _this.handleChange(name, date);
123
+
124
+ if (name === 'from' && precision === 'minute') {
125
+ _this.fromInput.hideDayPicker();
126
+
127
+ _this.toInput.getInput().focus();
128
+
129
+ _this.toInput.showDayPicker();
130
+
131
+ _this.openPanel('calendar');
132
+ } else if (name === 'to' && precision === 'minute') {
133
+ _this.toInput.hideDayPicker();
134
+
135
+ document.activeElement.blur();
155
136
  }
156
- }
157
- }, {
158
- key: "componentWillUnmount",
159
- value: function componentWillUnmount() {
160
- clearTimeout(this.timeout);
161
- }
162
- }, {
163
- key: "handleDayChange",
164
- value: function handleDayChange(name, day, modifiers) {
165
- var _this3 = this;
137
+ };
166
138
 
167
- if (day) {
168
- // if time disabled, focus TO input
169
- // else focus current input
170
- if (!this.props.enableTime) {
171
- if (day instanceof Date) {
172
- if (name === 'from' && this.toInput) {
173
- this.toInput.getInput().focus();
174
- } else if (name === 'to') {
175
- if (typeof this.event === 'undefined' || this.event && this.event.type !== 'change') {
176
- // trigger blur only if user clicks on date into calendar
177
- // else keep focus to see day selection into calendar
178
- document.activeElement.blur();
179
- }
180
-
181
- delete this.event;
182
- }
183
- }
139
+ _this.handleChange = function (name, day) {
140
+ var translations = _this.props.translations;
141
+ var date = undefined;
142
+ var error = undefined;
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;
148
+
149
+ if (day instanceof Date) {
150
+ date = day;
151
+ } else if (day) {
152
+ var parsedValue = (0, _moment2.default)(day, _this.props.format, true);
153
+
154
+ if (parsedValue.isValid()) {
155
+ date = parsedValue.toDate();
184
156
  } else {
185
- this.timeout = setTimeout(function () {
186
- if (_this3["".concat(name, "Input")].getInput()) {
187
- _this3["".concat(name, "Input")].getInput().focus();
188
- }
189
- }, 10);
157
+ error = translations.invalid_format;
190
158
  }
159
+ }
191
160
 
192
- if (this.props.onChange) {
193
- // Keep Time if set
194
- if (this.props.enableTime) {
195
- if (this.props[name]) {
196
- day.setHours(this.props[name].getHours(), this.props[name].getMinutes());
197
- } else {
198
- day.setHours(0, 0);
199
- }
200
- }
161
+ if (date) {
162
+ var comparativeDate = name === 'to' ? (0, _moment2.default)(_this.props.from) : (0, _moment2.default)(_this.props.to);
201
163
 
202
- this.props.onChange(name, day);
164
+ if (name === 'to' && comparativeDate > (0, _moment2.default)(date) || name === 'from' && comparativeDate < (0, _moment2.default)(date)) {
165
+ error = translations.to_superior_from;
166
+ } else if (date < minimumDate) {
167
+ error = translations.date_inferior_min_date.replace("%s", (0, _moment2.default)(minimumDate).format(format));
168
+ } else if (disableFutureDays && date > now) {
169
+ error = translations.date_superior_max_date.replace("%s", (0, _moment2.default)().format(format));
203
170
  }
204
171
 
205
- if (this.props.enableTime) {
206
- this.openPanel(name, 'time');
172
+ if (!_this.props.enableTime) {
173
+ if (name === 'from') {
174
+ date.setHours(0, 0);
175
+ } else {
176
+ date.setHours(23, 59);
177
+ }
207
178
  }
208
179
  }
209
- }
210
- }, {
211
- key: "handleDayChangeFrom",
212
- value: function handleDayChangeFrom(day, modifiers) {
213
- this.handleDayChange('from', day, modifiers);
214
- }
215
- }, {
216
- key: "handleDayChangeTo",
217
- value: function handleDayChangeTo(day, modifiers) {
218
- this.handleDayChange('to', day, modifiers);
219
- }
220
- }, {
221
- key: "handleCurrentMonthChange",
222
- value: function handleCurrentMonthChange(name, day) {
223
- var _this$setState;
224
180
 
225
- this.setState((_this$setState = {}, (0, _defineProperty2.default)(_this$setState, "".concat(name, "CurrentMonth"), day), (0, _defineProperty2.default)(_this$setState, "".concat(name, "OpenedPanel"), 'calendar'), _this$setState));
226
- }
227
- }, {
228
- key: "handleCurrentMonthChangeFrom",
229
- value: function handleCurrentMonthChangeFrom(day) {
230
- this.handleCurrentMonthChange('from', day);
231
- }
232
- }, {
233
- key: "handleCurrentMonthChangeTo",
234
- value: function handleCurrentMonthChangeTo(day) {
235
- this.handleCurrentMonthChange('to', day);
236
- }
237
- }, {
238
- key: "handleCalendarClick",
239
- value: function handleCalendarClick(name) {
240
- this.openPanel(name, 'calendar');
241
- }
242
- }, {
243
- key: "handleCalendarClickFrom",
244
- value: function handleCalendarClickFrom() {
245
- this.handleCalendarClick('from');
246
- }
247
- }, {
248
- key: "handleCalendarClickTo",
249
- value: function handleCalendarClickTo() {
250
- this.handleCalendarClick('to');
251
- }
252
- }, {
253
- key: "handleClockClick",
254
- value: function handleClockClick(name) {
255
- this.openPanel(name, 'time');
256
- }
257
- }, {
258
- key: "handleClockClickFrom",
259
- value: function handleClockClickFrom() {
260
- this.handleClockClick('from');
261
- }
262
- }, {
263
- key: "handleClockClickTo",
264
- value: function handleClockClickTo() {
265
- this.handleClockClick('to');
266
- }
267
- }, {
268
- key: "handleMonthClick",
269
- value: function handleMonthClick(name) {
270
- this.openPanel(name, 'months');
271
- }
272
- }, {
273
- key: "handleMonthClickFrom",
274
- value: function handleMonthClickFrom() {
275
- this.handleMonthClick('from');
276
- }
277
- }, {
278
- key: "handleMonthClickTo",
279
- value: function handleMonthClickTo() {
280
- this.handleMonthClick('to');
281
- }
282
- }, {
283
- key: "handleYearClick",
284
- value: function handleYearClick(name) {
285
- this.openPanel(name, 'years');
286
- }
287
- }, {
288
- key: "handleYearClickFrom",
289
- value: function handleYearClickFrom() {
290
- this.handleYearClick('from');
291
- }
292
- }, {
293
- key: "handleYearClickTo",
294
- value: function handleYearClickTo() {
295
- this.handleYearClick('to');
296
- }
297
- }, {
298
- key: "handleTimeChange",
299
- value: function handleTimeChange(name, date, precision) {
300
- this.props.onChange(name, date);
181
+ _this.props.onChange(name, date);
301
182
 
302
- if (name === 'from' && precision === 'minute') {
303
- this.fromInput.hideDayPicker();
304
- this.toInput.getInput().focus();
305
- this.toInput.showDayPicker();
306
- } else if (name === 'to' && precision === 'minute') {
307
- this.toInput.hideDayPicker();
308
- document.activeElement.blur();
183
+ _this.props.onChange("".concat(name, "Error"), error);
184
+ };
185
+
186
+ _this.handleCurrentMonthChange = function (day) {
187
+ _this.setState({
188
+ currentMonth: day,
189
+ openedPanel: 'calendar'
190
+ });
191
+ };
192
+
193
+ _this.handleDayPickerFocus = function (name) {
194
+ _this.setState({
195
+ focusedInput: name
196
+ });
197
+ };
198
+
199
+ _this.handleDayPickerBlur = function (name) {
200
+ _this.setState({
201
+ focusedInput: ''
202
+ });
203
+
204
+ if (_this.props.onBlur) {
205
+ _this.props.onBlur(name);
309
206
  }
310
- }
311
- }, {
312
- key: "handleReset",
313
- value: function handleReset(name) {
314
- var _this4 = this;
315
-
316
- this.handleCurrentMonthChange(name, new Date());
317
- this.timeout = setTimeout(function () {
318
- if (_this4.props.onReset) {
319
- _this4.props.onReset(name);
207
+
208
+ _this.timeout = setTimeout(function () {
209
+ if (!['from', 'to'].includes(_this.state.focusedInput)) {
210
+ _this.setState({
211
+ openedPanel: 'calendar'
212
+ });
320
213
  }
321
- }, 0);
322
- }
323
- }, {
324
- key: "openPanel",
325
- value: function openPanel(name, panel) {
326
- this.setState((0, _defineProperty2.default)({}, "".concat(name, "OpenedPanel"), panel));
327
- }
328
- }, {
329
- key: "renderCaption",
330
- value: function renderCaption(name, propsCaption) {
214
+ }, 100);
215
+ };
216
+
217
+ _this.handleReset = function (name) {
218
+ _this.handleChange(name, undefined);
219
+
220
+ _this.setState({
221
+ keyFrom: _this.state.keyFrom === 1 ? 2 : 1,
222
+ keyTo: _this.state.keyTo === 1 ? 2 : 1
223
+ });
224
+ };
225
+
226
+ _this.openPanel = function (panel) {
227
+ _this.setState({
228
+ openedPanel: panel
229
+ });
230
+ };
231
+
232
+ _this.renderCaption = function (propsCaption) {
331
233
  return _react.default.createElement(_Caption.default, (0, _extends2.default)({
332
- onMonthClick: this["handleMonthClick".concat((0, _helpers.capitalize)(name))],
333
- onYearClick: this["handleYearClick".concat((0, _helpers.capitalize)(name))]
234
+ onMonthClick: function onMonthClick() {
235
+ return _this.openPanel('months');
236
+ },
237
+ onYearClick: function onYearClick() {
238
+ return _this.openPanel('years');
239
+ }
334
240
  }, propsCaption));
335
- }
336
- }, {
337
- key: "renderCaptionFrom",
338
- value: function renderCaptionFrom(propsCaption) {
339
- return this.renderCaption('from', propsCaption);
340
- }
341
- }, {
342
- key: "renderCaptionTo",
343
- value: function renderCaptionTo(propsCaption) {
344
- return this.renderCaption('to', propsCaption);
345
- }
346
- }, {
347
- key: "renderNavBar",
348
- value: function renderNavBar(name, propsNavBar) {
241
+ };
242
+
243
+ _this.renderNavBar = function (propsNavBar) {
349
244
  return _react.default.createElement(_NavBar.default, (0, _extends2.default)({
350
- showClockButton: this.props.enableTime,
351
- onClockClick: this["handleClockClick".concat((0, _helpers.capitalize)(name))]
245
+ showClockButton: _this.props.enableTime,
246
+ onClockClick: function onClockClick() {
247
+ return _this.openPanel('time');
248
+ }
352
249
  }, propsNavBar));
353
- }
354
- }, {
355
- key: "renderNavBarFrom",
356
- value: function renderNavBarFrom(propsNavBar) {
357
- return this.renderNavBar('from', propsNavBar);
358
- }
359
- }, {
360
- key: "renderNavBarTo",
361
- value: function renderNavBarTo(propsNavBar) {
362
- return this.renderNavBar('to', propsNavBar);
363
- }
364
- }, {
365
- key: "renderOverlay",
366
- value: function renderOverlay(name, propsOverlay, staticPosition) {
250
+ };
251
+
252
+ _this.renderOverlay = function (name, propsOverlay, staticPosition) {
367
253
  var rangeOverlayProps = (0, _extends2.default)({}, propsOverlay, {
368
254
  side: name,
369
255
  staticPosition: staticPosition
370
256
  });
371
257
 
372
- switch (this.state["".concat(name, "OpenedPanel")]) {
258
+ switch (_this.state['openedPanel']) {
373
259
  case 'time':
374
- return this.renderTimePickerOverlay(name, rangeOverlayProps);
260
+ return _this.renderTimePickerOverlay(name, rangeOverlayProps);
375
261
 
376
262
  case 'months':
377
- return this.renderMonthPickerOverlay(name, rangeOverlayProps);
263
+ return _this.renderMonthPickerOverlay(name, rangeOverlayProps);
378
264
 
379
265
  case 'years':
380
- return this.renderYearPickerOverlay(name, rangeOverlayProps);
266
+ return _this.renderYearPickerOverlay(name, rangeOverlayProps);
381
267
 
382
268
  case 'calendar':
383
- default:
384
269
  return _react.default.createElement(_Overlay.default, rangeOverlayProps);
385
270
  }
386
- }
387
- }, {
388
- key: "renderOverlayFrom",
389
- value: function renderOverlayFrom(propsOverlay) {
390
- return this.renderOverlay('from', propsOverlay, this.props.staticPosition);
391
- }
392
- }, {
393
- key: "renderOverlayTo",
394
- value: function renderOverlayTo(propsOverlay) {
395
- return this.renderOverlay('to', propsOverlay, this.props.staticPosition);
396
- }
397
- }, {
398
- key: "renderMonthPickerOverlay",
399
- value: function renderMonthPickerOverlay(name, propsOverlay) {
271
+ };
272
+
273
+ _this.renderOverlayFrom = function (propsOverlay) {
274
+ return _this.renderOverlay('from', propsOverlay, _this.props.staticPosition);
275
+ };
276
+
277
+ _this.renderOverlayTo = function (propsOverlay) {
278
+ return _this.renderOverlay('to', propsOverlay, _this.props.staticPosition);
279
+ };
280
+
281
+ _this.renderMonthPickerOverlay = function (name, propsOverlay) {
400
282
  var monthPickerProps = {
401
- value: this.state["".concat(name, "CurrentMonth")],
402
- onChange: this["handleCurrentMonthChange".concat((0, _helpers.capitalize)(name))]
283
+ value: _this.state['currentMonth'],
284
+ onChange: _this.handleCurrentMonthChange
403
285
  };
404
286
  return _react.default.createElement(_MonthPickerOverlay.default, (0, _extends2.default)({
405
287
  key: "".concat(name, "-month-picker-overlay")
406
288
  }, monthPickerProps, propsOverlay));
407
- }
408
- }, {
409
- key: "renderTimePickerOverlay",
410
- value: function renderTimePickerOverlay(name, propsOverlay) {
411
- var _this5 = this;
289
+ };
412
290
 
291
+ _this.renderTimePickerOverlay = function (name, propsOverlay) {
413
292
  var timePickerProps = {
414
- value: this.props[name],
293
+ value: _this.props[name],
415
294
  onChange: function onChange(date, precision) {
416
- return _this5.handleTimeChange(name, date, precision);
295
+ return _this.handleTimeChange(name, date, precision);
417
296
  },
418
- onCalendarClick: this["handleCalendarClick".concat((0, _helpers.capitalize)(name))]
297
+ onCalendarClick: function onCalendarClick() {
298
+ return _this.openPanel('calendar');
299
+ }
419
300
  };
420
301
  return _react.default.createElement(_TimePickerOverlay.default, (0, _extends2.default)({
421
302
  key: "".concat(name, "-time-picker-overlay")
422
303
  }, timePickerProps, propsOverlay));
423
- }
424
- }, {
425
- key: "renderYearPickerOverlay",
426
- value: function renderYearPickerOverlay(name, propsOverlay) {
304
+ };
305
+
306
+ _this.renderYearPickerOverlay = function (name, propsOverlay) {
427
307
  var yearPickerProps = {
428
- value: this.state["".concat(name, "CurrentMonth")],
429
- onChange: this["handleCurrentMonthChange".concat((0, _helpers.capitalize)(name))],
430
- disabledFutureDays: this.props.disableFutureDays,
431
- disabledPastDays: this.props.disablePastDays
308
+ value: _this.state['currentMonth'],
309
+ onChange: _this.handleCurrentMonthChange,
310
+ disabledFutureDays: _this.props.disableFutureDays
432
311
  };
433
312
  return _react.default.createElement(_YearPickerOverlay.default, (0, _extends2.default)({
434
313
  key: "".concat(name, "-year-picker-overlay")
435
314
  }, yearPickerProps, propsOverlay));
315
+ };
316
+
317
+ _this.state = {
318
+ currentMonth: new Date(),
319
+ focusedInput: '',
320
+ openedPanel: 'calendar',
321
+ keyFrom: 1,
322
+ keyTo: 1
323
+ };
324
+ return _this;
325
+ }
326
+
327
+ (0, _createClass2.default)(HiDateRangePicker, [{
328
+ key: "componentWillUnmount",
329
+ value: function componentWillUnmount() {
330
+ clearTimeout(this.timeout);
436
331
  }
437
332
  }, {
438
333
  key: "render",
439
334
  value: function render() {
440
- var _this6 = this,
335
+ var _this2 = this,
441
336
  _classNames;
442
337
 
443
- var _this$props = this.props,
444
- classes = _this$props.classes,
445
- disabledDays = _this$props.disabledDays,
446
- disablePastDays = _this$props.disablePastDays,
447
- disableFutureDays = _this$props.disableFutureDays,
448
- enableTime = _this$props.enableTime,
449
- labelFrom = _this$props.labelFrom,
450
- labelTo = _this$props.labelTo,
451
- locale = _this$props.locale,
452
- format = _this$props.format,
453
- from = _this$props.from,
454
- minimumDate = _this$props.minimumDate,
455
- onReset = _this$props.onReset,
456
- to = _this$props.to,
457
- translations = _this$props.translations,
458
- id = _this$props.id,
459
- staticPosition = _this$props.staticPosition,
460
- props = (0, _objectWithoutProperties2.default)(_this$props, ["classes", "disabledDays", "disablePastDays", "disableFutureDays", "enableTime", "labelFrom", "labelTo", "locale", "format", "from", "minimumDate", "onReset", "to", "translations", "id", "staticPosition"]);
461
- var _this$state = this.state,
462
- fromCurrentMonth = _this$state.fromCurrentMonth,
463
- toCurrentMonth = _this$state.toCurrentMonth;
338
+ var _this$props2 = this.props,
339
+ classes = _this$props2.classes,
340
+ disabled = _this$props2.disabled,
341
+ disabledDays = _this$props2.disabledDays,
342
+ disableFutureDays = _this$props2.disableFutureDays,
343
+ enableTime = _this$props2.enableTime,
344
+ labelFrom = _this$props2.labelFrom,
345
+ labelTo = _this$props2.labelTo,
346
+ locale = _this$props2.locale,
347
+ format = _this$props2.format,
348
+ from = _this$props2.from,
349
+ fromError = _this$props2.fromError,
350
+ minimumDate = _this$props2.minimumDate,
351
+ onReset = _this$props2.onReset,
352
+ to = _this$props2.to,
353
+ toError = _this$props2.toError,
354
+ translations = _this$props2.translations,
355
+ id = _this$props2.id,
356
+ staticPosition = _this$props2.staticPosition,
357
+ errorText = _this$props2.errorText,
358
+ hasSelector = _this$props2.hasSelector,
359
+ helperIcon = _this$props2.helperIcon,
360
+ helperText = _this$props2.helperText,
361
+ 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"]);
464
362
  var now = new Date();
465
363
  var modifiers = {
466
364
  start: from,
@@ -505,92 +403,77 @@ function (_React$Component) {
505
403
  selectedDays: selectedDays,
506
404
  todayButton: translations.today,
507
405
  weekdayElement: _Weekday.default
508
- }, props); // Build Props for the From DatePicker
509
- // Disable days after 'to' date if define
510
-
511
- var after;
512
-
513
- if (to instanceof Date && disableFutureDays) {
514
- after = to < now ? now : to;
515
- } else if (to instanceof Date) {
516
- after = to;
517
- } else if (disableFutureDays) {
518
- after = now;
519
- }
520
-
521
- var disabledDaysFrom = (0, _extends2.default)({}, disablePastDays && {
522
- before: now
523
- }, (to || disableFutureDays) && {
524
- after: after
525
- }, disabledDays);
406
+ }, props);
526
407
  var fromDayPickerProps = (0, _extends2.default)({}, dayPickerProps, {
527
- onTodayButtonClick: this.handleCurrentMonthChangeFrom,
528
- NavBarElement: this.renderNavBarFrom,
529
- captionElement: this.renderCaptionFrom,
530
- disabledDays: disabledDaysFrom,
531
- month: fromCurrentMonth,
532
- modifiers: (0, _extends2.default)({}, modifiers, {
533
- disabled: disabledDaysFrom
534
- })
535
- }); // Build Props for the To DatePicker
536
- // Disable days before 'from' date if define
537
-
538
- var before;
539
-
540
- if (from instanceof Date && disablePastDays) {
541
- before = from < now ? now : from;
542
- } else if (from instanceof Date) {
543
- before = from;
544
- } else if (disablePastDays) {
545
- before = now;
546
- }
547
-
548
- var disabledDaysTo = (0, _extends2.default)({}, (from || disablePastDays) && {
549
- before: before
550
- }, disableFutureDays && {
551
- after: now
552
- }, disabledDays);
408
+ onTodayButtonClick: this.handleCurrentMonthChange,
409
+ navbarElement: this.renderNavBar,
410
+ captionElement: this.renderCaption,
411
+ disabledDays: (0, _extends2.default)({
412
+ before: minimumDate
413
+ }, disableFutureDays && {
414
+ after: now
415
+ }, to && {
416
+ after: to
417
+ }),
418
+ month: this.state.currentMonth,
419
+ modifiers: (0, _extends2.default)({}, modifiers)
420
+ });
553
421
  var toDayPickerProps = (0, _extends2.default)({}, dayPickerProps, {
554
- onTodayButtonClick: this.handleCurrentMonthChangeTo,
555
- NavBarElement: this.renderNavBarTo,
556
- captionElement: this.renderCaptionTo,
557
- disabledDays: disabledDaysTo,
558
- month: toCurrentMonth,
559
- modifiers: (0, _extends2.default)({}, modifiers, {
560
- disabled: disabledDaysTo
561
- })
422
+ onTodayButtonClick: this.handleCurrentMonthChange,
423
+ navbarElement: this.renderNavBar,
424
+ onDayClick: this.onDayToClick,
425
+ captionElement: this.renderCaption,
426
+ disabledDays: (0, _extends2.default)({
427
+ before: minimumDate
428
+ }, disableFutureDays && {
429
+ after: now
430
+ }, from && {
431
+ before: from
432
+ }),
433
+ month: this.state.currentMonth,
434
+ modifiers: (0, _extends2.default)({}, modifiers)
562
435
  }); // From & To InputProps
563
436
 
564
437
  var fromInputProps = (0, _extends2.default)({}, onReset && {
565
438
  onReset: function onReset() {
566
- return _this6.handleReset('from');
439
+ return _this2.handleReset('from');
567
440
  }
568
- }, props, labelFrom && {
441
+ }, props, fromError && {
442
+ error: true
443
+ }, labelFrom && {
569
444
  label: labelFrom
570
445
  }, {
571
446
  id: "".concat(id, "-from"),
572
- onChange: this.handleInputChange('from')
447
+ onChange: this.handleInputChange('from'),
448
+ disabled: disabled
573
449
  });
574
450
  var toInputProps = (0, _extends2.default)({}, onReset && {
575
451
  onReset: function onReset() {
576
- return _this6.handleReset('to');
452
+ return _this2.handleReset('to');
577
453
  }
578
- }, props, labelTo && {
454
+ }, props, toError && {
455
+ error: true
456
+ }, labelTo && {
579
457
  label: labelTo
580
458
  }, {
581
459
  id: "".concat(id, "-to"),
582
- onChange: this.handleInputChange('to')
460
+ onChange: this.handleInputChange('to'),
461
+ disabled: disabled
583
462
  });
584
463
  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));
585
- return _react.default.createElement("div", {
464
+
465
+ var content = _react.default.createElement("div", {
586
466
  className: (0, _classnames.default)(classes.root, classes.rangePickerContainer)
587
467
  }, _react.default.createElement("div", {
588
468
  className: classes.fromInput,
589
- onFocus: this.handleDayPickerFocus('from'),
590
- onBlur: this.handleDayPickerBlur('from')
469
+ onFocus: function onFocus() {
470
+ return _this2.handleDayPickerFocus('from');
471
+ } // onBlur={() => this.handleDayPickerBlur('from')}
472
+
591
473
  }, _react.default.createElement("div", null, _react.default.createElement(_DayPickerInput.default, {
474
+ key: this.state.keyFrom,
592
475
  ref: function ref(el) {
593
- _this6.fromInput = el;
476
+ _this2.fromInput = el;
594
477
  },
595
478
  value: from,
596
479
  hideOnDayClick: false,
@@ -601,15 +484,22 @@ function (_React$Component) {
601
484
  format: enableTime ? "".concat(format, " HH:mm") : format,
602
485
  formatDate: _moment.default.formatDate,
603
486
  parseDate: _moment.default.parseDate,
604
- onDayChange: this.handleDayChangeFrom,
487
+ onDayChange: function onDayChange(day) {
488
+ return _this2.handleDayChange('from', day);
489
+ },
605
490
  placeholder: ''
606
491
  }))), _react.default.createElement("div", {
607
492
  className: toClass,
608
- onFocus: this.handleDayPickerFocus('to'),
609
- onBlur: this.handleDayPickerBlur('to')
493
+ onFocus: function onFocus() {
494
+ return _this2.handleDayPickerFocus('to');
495
+ },
496
+ onBlur: function onBlur() {
497
+ return _this2.handleDayPickerBlur('to');
498
+ }
610
499
  }, _react.default.createElement(_DayPickerInput.default, {
500
+ key: this.state.keyTo,
611
501
  ref: function ref(el) {
612
- _this6.toInput = el;
502
+ _this2.toInput = el;
613
503
  },
614
504
  value: to,
615
505
  hideOnDayClick: false,
@@ -619,10 +509,23 @@ function (_React$Component) {
619
509
  inputProps: toInputProps,
620
510
  format: enableTime ? "".concat(format, " HH:mm") : format,
621
511
  formatDate: _moment.default.formatDate,
622
- parseDate: _moment.default.parseDate,
623
- onDayChange: this.handleDayChangeTo,
512
+ parseDate: _moment.default.parseDate //onDayChange={(day) => this.handleDayChange('to', day)}
513
+ ,
624
514
  placeholder: ''
625
515
  })));
516
+
517
+ if (!hasSelector) {
518
+ content = _react.default.createElement(_HiFormControl.default, {
519
+ disabled: disabled,
520
+ helperIcon: helperIcon,
521
+ helperText: helperText,
522
+ errorText: errorText,
523
+ error: fromError || toError,
524
+ label: ' '
525
+ }, content);
526
+ }
527
+
528
+ return content;
626
529
  }
627
530
  }]);
628
531
  return HiDateRangePicker;
@@ -630,22 +533,26 @@ function (_React$Component) {
630
533
 
631
534
  HiDateRangePicker.defaultProps = {
632
535
  disabledDays: [],
633
- disablePastDays: false,
634
- disableFutureDays: false,
536
+ disableFutureDays: true,
635
537
  staticPosition: false,
636
538
  enableTime: false,
637
- format: 'YYYY-DD-MM',
539
+ hasSelector: false,
540
+ format: 'YYYY-MM-DD',
638
541
  labelFrom: 'Start',
639
542
  labelTo: 'End',
640
543
  locale: 'fr-FR',
641
- minimumDate: new Date(2013, 4, 1),
642
- // by default 1 May 2013
643
544
  translations: {
644
545
  today: 'today',
645
546
  hour: 'Hour',
646
547
  minute: 'Minute',
647
548
  month: 'Month',
648
- year: 'Year'
549
+ year: 'Year',
550
+ invalid_format: 'The date format is not valid',
551
+ to_superior_from: 'Date from cannot be greater than date to',
552
+ missing_date_from: 'Missing date from',
553
+ missing_date_to: 'Missing date to',
554
+ date_superior_max_date: 'Date from cannot be greater than %s',
555
+ date_inferior_min_date: 'Date from cannot be before than %s'
649
556
  }
650
557
  };
651
558
  HiDateRangePicker.propTypes = process.env.NODE_ENV !== "production" ? {
@@ -659,25 +566,20 @@ HiDateRangePicker.propTypes = process.env.NODE_ENV !== "production" ? {
659
566
  */
660
567
  disabled: _propTypes.default.bool,
661
568
 
662
- /**
663
- * Définie les jours non sélectionnables
664
- */
665
- disabledDays: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.object, _propTypes.default.instanceOf(Date)]),
666
-
667
569
  /**
668
570
  * Uniquement la sélection de date antérieures à aujourd'hui (inclu)
669
571
  */
670
572
  disableFutureDays: _propTypes.default.bool,
671
573
 
672
574
  /**
673
- * Uniquement la sélection de date postérieures à aujourd'hui (inclu)
575
+ * Ajoute la gestion de l'heure
674
576
  */
675
- disablePastDays: _propTypes.default.bool,
577
+ enableTime: _propTypes.default.bool,
676
578
 
677
579
  /**
678
- * Ajoute la gestion de l'heure
580
+ * Texte de l'erreur
679
581
  */
680
- enableTime: _propTypes.default.bool,
582
+ errorText: _propTypes.default.string,
681
583
 
682
584
  /**
683
585
  * Format des dates affichées
@@ -687,7 +589,29 @@ HiDateRangePicker.propTypes = process.env.NODE_ENV !== "production" ? {
687
589
  /**
688
590
  * Date de début sélectionnée
689
591
  */
690
- from: _propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.string]),
592
+ from: _propTypes.default.instanceOf(Date),
593
+ //from: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.string]),
594
+
595
+ /**
596
+ * Erreur sur date from
597
+ */
598
+ fromError: _propTypes.default.bool,
599
+
600
+ /**
601
+ * @ignore
602
+ * Si true, on n'enveloppe pas le composant avec un HiFormControl
603
+ */
604
+ hasSelector: _propTypes.default.bool,
605
+
606
+ /**
607
+ * Si "true", le texte d'aide s'affichera seulement au clic sur l'icône "Information"
608
+ */
609
+ helperIcon: _propTypes.default.bool,
610
+
611
+ /**
612
+ * Texte de l'aide
613
+ */
614
+ helperText: _propTypes.default.string,
691
615
 
692
616
  /**
693
617
  * Utilisé pour construire les ids des champs from et to en les suffixant "-from" et "-to"
@@ -712,7 +636,7 @@ HiDateRangePicker.propTypes = process.env.NODE_ENV !== "production" ? {
712
636
  /**
713
637
  * Date minimale sélectionnable
714
638
  */
715
- minimumDate: _propTypes.default.instanceOf(Date),
639
+ minimumDate: _propTypes.default.instanceOf(Date).isRequired,
716
640
 
717
641
  /**
718
642
  * Callback à la sélection d'une date
@@ -725,7 +649,7 @@ HiDateRangePicker.propTypes = process.env.NODE_ENV !== "production" ? {
725
649
  * @param {string} nom du champs
726
650
  * @param {string} nouvelle valeur du champs
727
651
  */
728
- onChange: _propTypes.default.func,
652
+ onChange: _propTypes.default.func.isRequired,
729
653
 
730
654
  /**
731
655
  * Callback au reset de l'input
@@ -741,7 +665,12 @@ HiDateRangePicker.propTypes = process.env.NODE_ENV !== "production" ? {
741
665
  /**
742
666
  * Date de fin sélectionnée
743
667
  */
744
- to: _propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.string]),
668
+ to: _propTypes.default.instanceOf(Date),
669
+
670
+ /**
671
+ * Erreur sur date to
672
+ */
673
+ toError: _propTypes.default.bool,
745
674
 
746
675
  /**
747
676
  * Traductions