@hipay/hipay-material-ui 2.0.0-beta.35 → 2.0.0-beta.37

Sign up to get free protection for your applications and to get access to all the features.
Files changed (87) hide show
  1. package/HiAppBar/HiAppBar.js +0 -2
  2. package/HiCell/CellAddress.js +140 -0
  3. package/HiCell/CellDate.js +140 -0
  4. package/HiCell/CellIcon.js +122 -0
  5. package/HiCell/CellImage.js +132 -0
  6. package/HiCell/CellNumeric.js +122 -0
  7. package/HiCell/CellPinToAction.js +92 -0
  8. package/HiCell/CellRate.js +184 -0
  9. package/HiCell/CellSentinel.js +179 -0
  10. package/HiCell/CellText.js +250 -0
  11. package/HiCell/index.js +71 -0
  12. package/HiCheckbox/HiCheckbox.js +15 -9
  13. package/HiDatePicker/Caption.js +0 -1
  14. package/HiDatePicker/HiDatePicker.js +1 -1
  15. package/HiDatePicker/HiDateRangePicker.js +756 -0
  16. package/HiDatePicker/HiDateRangeSelector.js +495 -0
  17. package/HiDatePicker/ListPicker.js +0 -1
  18. package/HiDatePicker/ListPicker.spec.js +1 -2
  19. package/HiDatePicker/NavBar.js +2 -2
  20. package/HiDatePicker/NavBar.spec.js +4 -5
  21. package/HiDatePicker/Overlays/CustomOverlayLayout.js +0 -1
  22. package/HiDatePicker/Overlays/MonthPickerOverlay.js +0 -1
  23. package/HiDatePicker/Overlays/MonthPickerOverlay.spec.js +0 -1
  24. package/HiDatePicker/Overlays/Overlay.js +0 -1
  25. package/HiDatePicker/Overlays/Overlay.spec.js +0 -5
  26. package/HiDatePicker/Overlays/TimePickerOverlay.js +0 -1
  27. package/HiDatePicker/Overlays/TimePickerOverlay.spec.js +0 -1
  28. package/HiDatePicker/Overlays/YearPickerOverlay.js +0 -1
  29. package/HiDatePicker/Overlays/YearPickerOverlay.spec.js +0 -1
  30. package/HiDatePicker/Weekday.js +0 -1
  31. package/HiDatePicker/stylesheet.js +7 -3
  32. package/HiForm/HiFormControl.js +23 -3
  33. package/HiForm/HiInput.js +2 -2
  34. package/HiIcon/HiIcon.js +7 -23
  35. package/HiSelect/HiSelect.js +1 -1
  36. package/HiSelect/HiSuggestSelect.js +8 -8
  37. package/HiSelectableList/HiSelectableList.js +3 -1
  38. package/HiSelectableList/HiSelectableListItem.js +21 -14
  39. package/es/HiAppBar/HiAppBar.js +0 -2
  40. package/es/HiCell/CellAddress.js +97 -0
  41. package/es/HiCell/CellDate.js +94 -0
  42. package/es/HiCell/CellIcon.js +83 -0
  43. package/es/HiCell/CellImage.js +91 -0
  44. package/es/HiCell/CellNumeric.js +80 -0
  45. package/es/HiCell/CellPinToAction.js +53 -0
  46. package/es/HiCell/CellRate.js +142 -0
  47. package/es/HiCell/CellSentinel.js +140 -0
  48. package/es/HiCell/CellText.js +198 -0
  49. package/es/HiCell/index.js +8 -0
  50. package/es/HiCheckbox/HiCheckbox.js +16 -10
  51. package/es/HiDatePicker/Caption.js +0 -1
  52. package/es/HiDatePicker/HiDatePicker.js +3 -3
  53. package/es/HiDatePicker/HiDateRangePicker.js +661 -0
  54. package/es/HiDatePicker/HiDateRangeSelector.js +432 -0
  55. package/es/HiDatePicker/ListPicker.js +0 -1
  56. package/es/HiDatePicker/ListPicker.spec.js +1 -2
  57. package/es/HiDatePicker/NavBar.js +2 -2
  58. package/es/HiDatePicker/NavBar.spec.js +4 -5
  59. package/es/HiDatePicker/Overlays/CustomOverlayLayout.js +0 -1
  60. package/es/HiDatePicker/Overlays/MonthPickerOverlay.js +0 -1
  61. package/es/HiDatePicker/Overlays/MonthPickerOverlay.spec.js +0 -1
  62. package/es/HiDatePicker/Overlays/Overlay.js +0 -1
  63. package/es/HiDatePicker/Overlays/Overlay.spec.js +0 -3
  64. package/es/HiDatePicker/Overlays/TimePickerOverlay.js +0 -1
  65. package/es/HiDatePicker/Overlays/TimePickerOverlay.spec.js +0 -1
  66. package/es/HiDatePicker/Overlays/YearPickerOverlay.js +0 -1
  67. package/es/HiDatePicker/Overlays/YearPickerOverlay.spec.js +0 -1
  68. package/es/HiDatePicker/Overlays/index.js +0 -1
  69. package/es/HiDatePicker/Weekday.js +0 -1
  70. package/es/HiDatePicker/stylesheet.js +7 -3
  71. package/es/HiForm/HiFormControl.js +22 -3
  72. package/es/HiForm/HiInput.js +2 -2
  73. package/es/HiIcon/HiIcon.js +7 -23
  74. package/es/HiSelect/HiSelect.js +1 -1
  75. package/es/HiSelect/HiSuggestSelect.js +8 -8
  76. package/es/HiSelectableList/HiSelectableList.js +3 -1
  77. package/es/HiSelectableList/HiSelectableListItem.js +21 -14
  78. package/es/index.js +2 -1
  79. package/es/styles/createPalette.js +4 -3
  80. package/es/utils/helpers.js +117 -0
  81. package/index.es.js +3 -2
  82. package/index.js +1 -1
  83. package/package.json +3 -1
  84. package/styles/createPalette.js +3 -3
  85. package/umd/hipay-material-ui.development.js +63 -48
  86. package/umd/hipay-material-ui.production.min.js +2 -2
  87. package/utils/helpers.js +134 -0
@@ -0,0 +1,661 @@
1
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
2
+ import _objectSpread from "@babel/runtime/helpers/objectSpread";
3
+ import _extends from "@babel/runtime/helpers/extends";
4
+ import React from 'react';
5
+ import PropTypes from 'prop-types';
6
+ import MomentLocaleUtils from 'react-day-picker/moment';
7
+ import DayPickerInput from 'react-day-picker/DayPickerInput';
8
+ import classNames from 'classnames';
9
+ import withStyles from '../styles/withStyles';
10
+ import { capitalize } from '../utils/helpers';
11
+ import Caption from './Caption';
12
+ import Overlay from './Overlays/Overlay';
13
+ import TimePickerOverlay from './Overlays/TimePickerOverlay';
14
+ import MonthPickerOverlay from './Overlays/MonthPickerOverlay';
15
+ import YearPickerOverlay from './Overlays/YearPickerOverlay';
16
+ import NavBar from './NavBar';
17
+ import Weekday from './Weekday';
18
+ import { HiTextField } from '../HiForm';
19
+ import styles from './stylesheet';
20
+
21
+ class HiDateRangePicker extends React.Component {
22
+ constructor(props) {
23
+ super();
24
+
25
+ this.handleInputChange = inputName => event => {
26
+ this.event = event;
27
+ this.props.onChange(inputName, event.target.value);
28
+ };
29
+
30
+ this.handleDayPickerFocus = name => () => {
31
+ this.setState({
32
+ focusedInput: name
33
+ });
34
+ };
35
+
36
+ this.handleDayPickerBlur = name => () => {
37
+ this.setState({
38
+ focusedInput: ''
39
+ });
40
+
41
+ if (this.props.onBlur) {
42
+ this.props.onBlur(name);
43
+ }
44
+ };
45
+
46
+ this.state = {
47
+ fromCurrentMonth: props.from ? props.from : new Date(),
48
+ toCurrentMonth: props.to ? props.to : new Date(),
49
+ focusedInput: ''
50
+ };
51
+ this.handleReset = this.handleReset.bind(this);
52
+ this.handleDayChange = this.handleDayChange.bind(this);
53
+ this.handleDayChangeFrom = this.handleDayChangeFrom.bind(this);
54
+ this.handleDayChangeTo = this.handleDayChangeTo.bind(this);
55
+ this.handleCurrentMonthChange = this.handleCurrentMonthChange.bind(this);
56
+ this.handleCurrentMonthChangeFrom = this.handleCurrentMonthChangeFrom.bind(this);
57
+ this.handleCurrentMonthChangeTo = this.handleCurrentMonthChangeTo.bind(this);
58
+ this.handleTimeChange = this.handleTimeChange.bind(this);
59
+ this.handleCalendarClick = this.handleCalendarClick.bind(this);
60
+ this.handleCalendarClickFrom = this.handleCalendarClickFrom.bind(this);
61
+ this.handleCalendarClickTo = this.handleCalendarClickTo.bind(this);
62
+ this.handleClockClick = this.handleClockClick.bind(this);
63
+ this.handleClockClickFrom = this.handleClockClickFrom.bind(this);
64
+ this.handleClockClickTo = this.handleClockClickTo.bind(this);
65
+ this.handleMonthClick = this.handleMonthClick.bind(this);
66
+ this.handleMonthClickFrom = this.handleMonthClickFrom.bind(this);
67
+ this.handleMonthClickTo = this.handleMonthClickTo.bind(this);
68
+ this.handleYearClick = this.handleYearClick.bind(this);
69
+ this.handleYearClickFrom = this.handleYearClickFrom.bind(this);
70
+ this.handleYearClickTo = this.handleYearClickTo.bind(this);
71
+ this.handleDayPickerFocus = this.handleDayPickerFocus.bind(this);
72
+ this.handleDayPickerBlur = this.handleDayPickerBlur.bind(this);
73
+ this.handleInputChange = this.handleInputChange.bind(this);
74
+ this.openPanel = this.openPanel.bind(this);
75
+ this.renderCaption = this.renderCaption.bind(this);
76
+ this.renderCaptionFrom = this.renderCaptionFrom.bind(this);
77
+ this.renderCaptionTo = this.renderCaptionTo.bind(this);
78
+ this.renderNavBar = this.renderNavBar.bind(this);
79
+ this.renderNavBarFrom = this.renderNavBarFrom.bind(this);
80
+ this.renderNavBarTo = this.renderNavBarTo.bind(this);
81
+ this.renderOverlay = this.renderOverlay.bind(this);
82
+ this.renderOverlayFrom = this.renderOverlayFrom.bind(this);
83
+ this.renderOverlayTo = this.renderOverlayTo.bind(this);
84
+ this.renderMonthPickerOverlay = this.renderMonthPickerOverlay.bind(this);
85
+ this.renderTimePickerOverlay = this.renderTimePickerOverlay.bind(this);
86
+ this.renderYearPickerOverlay = this.renderYearPickerOverlay.bind(this);
87
+ }
88
+
89
+ componentDidUpdate(prevProps) {
90
+ // Focus From input on enabling
91
+ if (prevProps.disabled === true && this.props.disabled === false) {
92
+ this.timeout = setTimeout(() => {
93
+ if (this.fromInput.getInput()) {
94
+ this.fromInput.getInput().focus();
95
+ }
96
+ }, 0);
97
+ }
98
+ }
99
+
100
+ componentWillUnmount() {
101
+ clearTimeout(this.timeout);
102
+ }
103
+
104
+ handleDayChange(name, day, modifiers) {
105
+ if (day) {
106
+ // if time disabled, focus TO input
107
+ // else focus current input
108
+ if (!this.props.enableTime) {
109
+ if (day instanceof Date) {
110
+ if (name === 'from' && this.toInput) {
111
+ this.toInput.getInput().focus();
112
+ } else if (name === 'to') {
113
+ if (typeof this.event === 'undefined' || this.event && this.event.type !== 'change') {
114
+ // trigger blur only if user clicks on date into calendar
115
+ // else keep focus to see day selection into calendar
116
+ document.activeElement.blur();
117
+ }
118
+
119
+ delete this.event;
120
+ }
121
+ }
122
+ } else {
123
+ this.timeout = setTimeout(() => {
124
+ if (this[`${name}Input`].getInput()) {
125
+ this[`${name}Input`].getInput().focus();
126
+ }
127
+ }, 10);
128
+ }
129
+
130
+ if (this.props.onChange) {
131
+ // Keep Time if set
132
+ if (this.props.enableTime) {
133
+ if (this.props[name]) {
134
+ day.setHours(this.props[name].getHours(), this.props[name].getMinutes());
135
+ } else {
136
+ day.setHours(0, 0);
137
+ }
138
+ }
139
+
140
+ this.props.onChange(name, day);
141
+ }
142
+
143
+ if (this.props.enableTime) {
144
+ this.openPanel(name, 'time');
145
+ }
146
+ }
147
+ }
148
+
149
+ handleDayChangeFrom(day, modifiers) {
150
+ this.handleDayChange('from', day, modifiers);
151
+ }
152
+
153
+ handleDayChangeTo(day, modifiers) {
154
+ this.handleDayChange('to', day, modifiers);
155
+ }
156
+
157
+ handleCurrentMonthChange(name, day) {
158
+ this.setState({
159
+ [`${name}CurrentMonth`]: day,
160
+ [`${name}OpenedPanel`]: 'calendar'
161
+ });
162
+ }
163
+
164
+ handleCurrentMonthChangeFrom(day) {
165
+ this.handleCurrentMonthChange('from', day);
166
+ }
167
+
168
+ handleCurrentMonthChangeTo(day) {
169
+ this.handleCurrentMonthChange('to', day);
170
+ }
171
+
172
+ handleCalendarClick(name) {
173
+ this.openPanel(name, 'calendar');
174
+ }
175
+
176
+ handleCalendarClickFrom() {
177
+ this.handleCalendarClick('from');
178
+ }
179
+
180
+ handleCalendarClickTo() {
181
+ this.handleCalendarClick('to');
182
+ }
183
+
184
+ handleClockClick(name) {
185
+ this.openPanel(name, 'time');
186
+ }
187
+
188
+ handleClockClickFrom() {
189
+ this.handleClockClick('from');
190
+ }
191
+
192
+ handleClockClickTo() {
193
+ this.handleClockClick('to');
194
+ }
195
+
196
+ handleMonthClick(name) {
197
+ this.openPanel(name, 'months');
198
+ }
199
+
200
+ handleMonthClickFrom() {
201
+ this.handleMonthClick('from');
202
+ }
203
+
204
+ handleMonthClickTo() {
205
+ this.handleMonthClick('to');
206
+ }
207
+
208
+ handleYearClick(name) {
209
+ this.openPanel(name, 'years');
210
+ }
211
+
212
+ handleYearClickFrom() {
213
+ this.handleYearClick('from');
214
+ }
215
+
216
+ handleYearClickTo() {
217
+ this.handleYearClick('to');
218
+ }
219
+
220
+ handleTimeChange(name, date, precision) {
221
+ this.props.onChange(name, date);
222
+
223
+ if (name === 'from' && precision === 'minute') {
224
+ this.fromInput.hideDayPicker();
225
+ this.toInput.getInput().focus();
226
+ this.toInput.showDayPicker();
227
+ } else if (name === 'to' && precision === 'minute') {
228
+ this.toInput.hideDayPicker();
229
+ document.activeElement.blur();
230
+ }
231
+ }
232
+
233
+ handleReset(name) {
234
+ this.handleCurrentMonthChange(name, new Date());
235
+ this.timeout = setTimeout(() => {
236
+ if (this.props.onReset) {
237
+ this.props.onReset(name);
238
+ }
239
+ }, 0);
240
+ }
241
+
242
+ openPanel(name, panel) {
243
+ this.setState({
244
+ [`${name}OpenedPanel`]: panel
245
+ });
246
+ }
247
+
248
+ renderCaption(name, propsCaption) {
249
+ return React.createElement(Caption, _extends({
250
+ onMonthClick: this[`handleMonthClick${capitalize(name)}`],
251
+ onYearClick: this[`handleYearClick${capitalize(name)}`]
252
+ }, propsCaption));
253
+ }
254
+
255
+ renderCaptionFrom(propsCaption) {
256
+ return this.renderCaption('from', propsCaption);
257
+ }
258
+
259
+ renderCaptionTo(propsCaption) {
260
+ return this.renderCaption('to', propsCaption);
261
+ }
262
+
263
+ renderNavBar(name, propsNavBar) {
264
+ return React.createElement(NavBar, _extends({
265
+ showClockButton: this.props.enableTime,
266
+ onClockClick: this[`handleClockClick${capitalize(name)}`]
267
+ }, propsNavBar));
268
+ }
269
+
270
+ renderNavBarFrom(propsNavBar) {
271
+ return this.renderNavBar('from', propsNavBar);
272
+ }
273
+
274
+ renderNavBarTo(propsNavBar) {
275
+ return this.renderNavBar('to', propsNavBar);
276
+ }
277
+
278
+ renderOverlay(name, propsOverlay, staticPosition) {
279
+ const rangeOverlayProps = _objectSpread({}, propsOverlay, {
280
+ side: name,
281
+ staticPosition
282
+ });
283
+
284
+ switch (this.state[`${name}OpenedPanel`]) {
285
+ case 'time':
286
+ return this.renderTimePickerOverlay(name, rangeOverlayProps);
287
+
288
+ case 'months':
289
+ return this.renderMonthPickerOverlay(name, rangeOverlayProps);
290
+
291
+ case 'years':
292
+ return this.renderYearPickerOverlay(name, rangeOverlayProps);
293
+
294
+ case 'calendar':
295
+ default:
296
+ return React.createElement(Overlay, rangeOverlayProps);
297
+ }
298
+ }
299
+
300
+ renderOverlayFrom(propsOverlay) {
301
+ return this.renderOverlay('from', propsOverlay, this.props.staticPosition);
302
+ }
303
+
304
+ renderOverlayTo(propsOverlay) {
305
+ return this.renderOverlay('to', propsOverlay, this.props.staticPosition);
306
+ }
307
+
308
+ renderMonthPickerOverlay(name, propsOverlay) {
309
+ const monthPickerProps = {
310
+ value: this.state[`${name}CurrentMonth`],
311
+ onChange: this[`handleCurrentMonthChange${capitalize(name)}`]
312
+ };
313
+ return React.createElement(MonthPickerOverlay, _extends({
314
+ key: `${name}-month-picker-overlay`
315
+ }, monthPickerProps, propsOverlay));
316
+ }
317
+
318
+ renderTimePickerOverlay(name, propsOverlay) {
319
+ const timePickerProps = {
320
+ value: this.props[name],
321
+ onChange: (date, precision) => this.handleTimeChange(name, date, precision),
322
+ onCalendarClick: this[`handleCalendarClick${capitalize(name)}`]
323
+ };
324
+ return React.createElement(TimePickerOverlay, _extends({
325
+ key: `${name}-time-picker-overlay`
326
+ }, timePickerProps, propsOverlay));
327
+ }
328
+
329
+ renderYearPickerOverlay(name, propsOverlay) {
330
+ const yearPickerProps = {
331
+ value: this.state[`${name}CurrentMonth`],
332
+ onChange: this[`handleCurrentMonthChange${capitalize(name)}`],
333
+ disabledFutureDays: this.props.disableFutureDays,
334
+ disabledPastDays: this.props.disablePastDays
335
+ };
336
+ return React.createElement(YearPickerOverlay, _extends({
337
+ key: `${name}-year-picker-overlay`
338
+ }, yearPickerProps, propsOverlay));
339
+ }
340
+
341
+ render() {
342
+ const _this$props = this.props,
343
+ {
344
+ classes,
345
+ disabledDays,
346
+ disablePastDays,
347
+ disableFutureDays,
348
+ enableTime,
349
+ labelFrom,
350
+ labelTo,
351
+ locale,
352
+ format,
353
+ from,
354
+ minimumDate,
355
+ onReset,
356
+ to,
357
+ translations,
358
+ id,
359
+ staticPosition
360
+ } = _this$props,
361
+ props = _objectWithoutProperties(_this$props, ["classes", "disabledDays", "disablePastDays", "disableFutureDays", "enableTime", "labelFrom", "labelTo", "locale", "format", "from", "minimumDate", "onReset", "to", "translations", "id", "staticPosition"]);
362
+
363
+ const {
364
+ fromCurrentMonth,
365
+ toCurrentMonth
366
+ } = this.state;
367
+ const now = new Date();
368
+ const modifiers = {
369
+ start: from,
370
+ end: to
371
+ };
372
+ const modifiersStyles = {
373
+ start: {
374
+ borderTopLeftRadius: '50%',
375
+ borderBottomLeftRadius: '50%'
376
+ },
377
+ end: {
378
+ borderTopRightRadius: '50%',
379
+ borderBottomRightRadius: '50%'
380
+ }
381
+ };
382
+ const selectedDays = [];
383
+ const selected = {};
384
+
385
+ if (from instanceof Date) {
386
+ selectedDays.push(from);
387
+ selected.from = from;
388
+ }
389
+
390
+ if (to instanceof Date) {
391
+ selectedDays.push(to);
392
+ selected.to = to;
393
+ }
394
+
395
+ if (Object.values(selected).length > 0) {
396
+ selectedDays.push(selected);
397
+ }
398
+
399
+ const dayPickerProps = _objectSpread({
400
+ classNames: classes,
401
+ disabledDays,
402
+ firstDayOfWeek: 1,
403
+ fromMonth: minimumDate,
404
+ locale,
405
+ modifiers,
406
+ modifiersStyles,
407
+ // Both are required ?
408
+ selectedDays,
409
+ todayButton: translations.today,
410
+ weekdayElement: Weekday
411
+ }, props); // Build Props for the From DatePicker
412
+ // Disable days after 'to' date if define
413
+
414
+
415
+ let after;
416
+
417
+ if (to instanceof Date && disableFutureDays) {
418
+ after = to < now ? now : to;
419
+ } else if (to instanceof Date) {
420
+ after = to;
421
+ } else if (disableFutureDays) {
422
+ after = now;
423
+ }
424
+
425
+ const disabledDaysFrom = _objectSpread({}, disablePastDays && {
426
+ before: now
427
+ }, (to || disableFutureDays) && {
428
+ after
429
+ }, disabledDays);
430
+
431
+ const fromDayPickerProps = _objectSpread({}, dayPickerProps, {
432
+ onTodayButtonClick: this.handleCurrentMonthChangeFrom,
433
+ NavBarElement: this.renderNavBarFrom,
434
+ captionElement: this.renderCaptionFrom,
435
+ disabledDays: disabledDaysFrom,
436
+ month: fromCurrentMonth,
437
+ modifiers: _objectSpread({}, modifiers, {
438
+ disabled: disabledDaysFrom
439
+ })
440
+ }); // Build Props for the To DatePicker
441
+ // Disable days before 'from' date if define
442
+
443
+
444
+ let before;
445
+
446
+ if (from instanceof Date && disablePastDays) {
447
+ before = from < now ? now : from;
448
+ } else if (from instanceof Date) {
449
+ before = from;
450
+ } else if (disablePastDays) {
451
+ before = now;
452
+ }
453
+
454
+ const disabledDaysTo = _objectSpread({}, (from || disablePastDays) && {
455
+ before
456
+ }, disableFutureDays && {
457
+ after: now
458
+ }, disabledDays);
459
+
460
+ const toDayPickerProps = _objectSpread({}, dayPickerProps, {
461
+ onTodayButtonClick: this.handleCurrentMonthChangeTo,
462
+ NavBarElement: this.renderNavBarTo,
463
+ captionElement: this.renderCaptionTo,
464
+ disabledDays: disabledDaysTo,
465
+ month: toCurrentMonth,
466
+ modifiers: _objectSpread({}, modifiers, {
467
+ disabled: disabledDaysTo
468
+ })
469
+ }); // From & To InputProps
470
+
471
+
472
+ const fromInputProps = _objectSpread({}, onReset && {
473
+ onReset: () => this.handleReset('from')
474
+ }, props, labelFrom && {
475
+ label: labelFrom
476
+ }, {
477
+ id: `${id}-from`,
478
+ onChange: this.handleInputChange('from')
479
+ });
480
+
481
+ const toInputProps = _objectSpread({}, onReset && {
482
+ onReset: () => this.handleReset('to')
483
+ }, props, labelTo && {
484
+ label: labelTo
485
+ }, {
486
+ id: `${id}-to`,
487
+ onChange: this.handleInputChange('to')
488
+ });
489
+
490
+ const toClass = classNames(classes.toInput, {
491
+ [classes.absolute]: staticPosition === true && this.state.focusedInput === 'from',
492
+ [classes.right4]: staticPosition === true && this.state.focusedInput === 'from'
493
+ });
494
+ return React.createElement("div", {
495
+ className: classNames(classes.root, classes.rangePickerContainer)
496
+ }, React.createElement("div", {
497
+ className: classes.fromInput,
498
+ onFocus: this.handleDayPickerFocus('from'),
499
+ onBlur: this.handleDayPickerBlur('from')
500
+ }, React.createElement("div", null, React.createElement(DayPickerInput, {
501
+ ref: el => {
502
+ this.fromInput = el;
503
+ },
504
+ value: from,
505
+ hideOnDayClick: false,
506
+ overlayComponent: this.renderOverlayFrom,
507
+ dayPickerProps: fromDayPickerProps,
508
+ component: HiTextField,
509
+ inputProps: fromInputProps,
510
+ format: enableTime ? `${format} HH:mm` : format,
511
+ formatDate: MomentLocaleUtils.formatDate,
512
+ parseDate: MomentLocaleUtils.parseDate,
513
+ onDayChange: this.handleDayChangeFrom,
514
+ placeholder: ''
515
+ }))), React.createElement("div", {
516
+ className: toClass,
517
+ onFocus: this.handleDayPickerFocus('to'),
518
+ onBlur: this.handleDayPickerBlur('to')
519
+ }, React.createElement(DayPickerInput, {
520
+ ref: el => {
521
+ this.toInput = el;
522
+ },
523
+ value: to,
524
+ hideOnDayClick: false,
525
+ overlayComponent: this.renderOverlayTo,
526
+ dayPickerProps: toDayPickerProps,
527
+ component: HiTextField,
528
+ inputProps: toInputProps,
529
+ format: enableTime ? `${format} HH:mm` : format,
530
+ formatDate: MomentLocaleUtils.formatDate,
531
+ parseDate: MomentLocaleUtils.parseDate,
532
+ onDayChange: this.handleDayChangeTo,
533
+ placeholder: ''
534
+ })));
535
+ }
536
+
537
+ }
538
+
539
+ HiDateRangePicker.defaultProps = {
540
+ disabledDays: [],
541
+ disablePastDays: false,
542
+ disableFutureDays: false,
543
+ staticPosition: false,
544
+ enableTime: false,
545
+ format: 'YYYY-DD-MM',
546
+ labelFrom: 'Start',
547
+ labelTo: 'End',
548
+ locale: 'fr-FR',
549
+ minimumDate: new Date(2013, 4, 1),
550
+ // by default 1 May 2013
551
+ translations: {
552
+ today: 'today',
553
+ hour: 'Hour',
554
+ minute: 'Minute',
555
+ month: 'Month',
556
+ year: 'Year'
557
+ }
558
+ };
559
+ HiDateRangePicker.propTypes = process.env.NODE_ENV !== "production" ? {
560
+ /**
561
+ * Useful to extend the style applied to components.
562
+ */
563
+ classes: PropTypes.object,
564
+
565
+ /**
566
+ * Inactif
567
+ */
568
+ disabled: PropTypes.bool,
569
+
570
+ /**
571
+ * Définie les jours non sélectionnables
572
+ */
573
+ disabledDays: PropTypes.oneOfType([PropTypes.array, PropTypes.object, PropTypes.instanceOf(Date)]),
574
+
575
+ /**
576
+ * Uniquement la sélection de date antérieures à aujourd'hui (inclu)
577
+ */
578
+ disableFutureDays: PropTypes.bool,
579
+
580
+ /**
581
+ * Uniquement la sélection de date postérieures à aujourd'hui (inclu)
582
+ */
583
+ disablePastDays: PropTypes.bool,
584
+
585
+ /**
586
+ * Ajoute la gestion de l'heure
587
+ */
588
+ enableTime: PropTypes.bool,
589
+
590
+ /**
591
+ * Format des dates affichées
592
+ */
593
+ format: PropTypes.string,
594
+
595
+ /**
596
+ * Date de début sélectionnée
597
+ */
598
+ from: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.string]),
599
+
600
+ /**
601
+ * Utilisé pour construire les ids des champs from et to en les suffixant "-from" et "-to"
602
+ */
603
+ id: PropTypes.string.isRequired,
604
+
605
+ /**
606
+ * Label du champs de début
607
+ */
608
+ labelFrom: PropTypes.string,
609
+
610
+ /**
611
+ * Label du champs de fin
612
+ */
613
+ labelTo: PropTypes.string,
614
+
615
+ /**
616
+ * Locale utilisée
617
+ */
618
+ locale: PropTypes.string,
619
+
620
+ /**
621
+ * Date minimale sélectionnable
622
+ */
623
+ minimumDate: PropTypes.instanceOf(Date),
624
+
625
+ /**
626
+ * Callback à la sélection d'une date
627
+ * @param {string} nom de l'input
628
+ */
629
+ onBlur: PropTypes.func,
630
+
631
+ /**
632
+ * Callback à la sélection d'une date
633
+ * @param {string} nom du champs
634
+ * @param {string} nouvelle valeur du champs
635
+ */
636
+ onChange: PropTypes.func,
637
+
638
+ /**
639
+ * Callback au reset de l'input
640
+ * @param {string} nom du champs réinitialisé
641
+ */
642
+ onReset: PropTypes.func,
643
+
644
+ /**
645
+ * Si true, le calendrier sera dans une div static plutot que dans une popper absolute
646
+ */
647
+ staticPosition: PropTypes.bool,
648
+
649
+ /**
650
+ * Date de fin sélectionnée
651
+ */
652
+ to: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.string]),
653
+
654
+ /**
655
+ * Traductions
656
+ */
657
+ translations: PropTypes.object
658
+ } : {};
659
+ export default withStyles(styles, {
660
+ name: 'HmuiHiDateRangePicker'
661
+ })(HiDateRangePicker);