@hipay/hipay-material-ui 1.0.0-beta.22 → 1.0.0-beta.25

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. package/HI-CHANGELOG.md +26 -43
  2. package/HiChip/HiChip.js +67 -8
  3. package/HiChip/HiChipSwitch.js +6 -0
  4. package/HiDatePicker/HiDatePicker.js +35 -21
  5. package/HiDatePicker/HiDateRangePicker.js +92 -50
  6. package/HiDatePicker/HiDateRangeSelector.js +15 -4
  7. package/HiDatePicker/Overlays/Overlay.js +1 -1
  8. package/HiDatePicker/stylesheet.js +3 -0
  9. package/HiForm/HiInput.js +12 -2
  10. package/HiForm/HiPasswordField.js +8 -3
  11. package/HiLoader/HiLoader.js +7 -4
  12. package/HiPins/HiPins.js +6 -4
  13. package/HiSelect/HiSelect.js +26 -6
  14. package/HiSelect/HiSuggestSelect.js +2 -1
  15. package/HiSelect/SelectInput.js +3 -8
  16. package/HiSelectableList/HiSelectableList.js +51 -49
  17. package/HiSelectableList/HiSelectableListItem.js +18 -2
  18. package/HiTable/BodyCellBuilder.js +22 -12
  19. package/HiTable/BodyCells/CellAccount.js +13 -4
  20. package/HiTable/BodyCells/CellAccountNumber.js +12 -3
  21. package/HiTable/BodyCells/CellAddress.js +12 -3
  22. package/HiTable/BodyCells/CellCountry.js +12 -3
  23. package/HiTable/BodyCells/CellDate.js +43 -42
  24. package/HiTable/BodyCells/CellIcon.js +12 -3
  25. package/HiTable/BodyCells/CellImage.js +12 -3
  26. package/HiTable/BodyCells/CellNumeric.js +12 -3
  27. package/HiTable/BodyCells/CellRate.js +12 -3
  28. package/HiTable/BodyCells/CellSentinel.js +17 -7
  29. package/HiTable/BodyCells/CellStatus.js +13 -4
  30. package/HiTable/BodyCells/CellText.js +17 -7
  31. package/HiTable/BodyCells/CellThirdPartySecurity.js +12 -3
  32. package/HiTable/BodyRow.js +12 -3
  33. package/HiTable/ColumnFilter.js +2 -5
  34. package/HiTable/HeaderCell.js +21 -11
  35. package/HiTable/HiStickyRow.js +24 -13
  36. package/HiTable/HiTable.js +30 -69
  37. package/HiTable/HiTableBody.js +99 -29
  38. package/HiTable/HiTableContextMenu.js +31 -16
  39. package/HiTable/HiTableFooter.js +9 -0
  40. package/HiTable/HiTableHead.js +15 -7
  41. package/HiTopBar/HiTopBar.js +6 -0
  42. package/README.md +71 -6
  43. package/es/HiChip/HiChip.js +79 -8
  44. package/es/HiChip/HiChipSwitch.js +6 -0
  45. package/es/HiDatePicker/HiDatePicker.js +30 -21
  46. package/es/HiDatePicker/HiDateRangePicker.js +86 -52
  47. package/es/HiDatePicker/HiDateRangeSelector.js +14 -4
  48. package/es/HiDatePicker/Overlays/Overlay.js +1 -1
  49. package/es/HiDatePicker/stylesheet.js +3 -0
  50. package/es/HiForm/HiInput.js +12 -2
  51. package/es/HiForm/HiPasswordField.js +8 -3
  52. package/es/HiLoader/HiLoader.js +3 -3
  53. package/es/HiPins/HiPins.js +4 -4
  54. package/es/HiSelect/HiSelect.js +25 -6
  55. package/es/HiSelect/HiSuggestSelect.js +2 -1
  56. package/es/HiSelect/SelectInput.js +3 -8
  57. package/es/HiSelectableList/HiSelectableList.js +51 -49
  58. package/es/HiSelectableList/HiSelectableListItem.js +15 -2
  59. package/es/HiTable/BodyCellBuilder.js +8 -2
  60. package/es/HiTable/BodyCells/CellAccount.js +7 -2
  61. package/es/HiTable/BodyCells/CellAccountNumber.js +6 -1
  62. package/es/HiTable/BodyCells/CellAddress.js +6 -1
  63. package/es/HiTable/BodyCells/CellCountry.js +6 -1
  64. package/es/HiTable/BodyCells/CellDate.js +28 -37
  65. package/es/HiTable/BodyCells/CellIcon.js +6 -1
  66. package/es/HiTable/BodyCells/CellImage.js +6 -1
  67. package/es/HiTable/BodyCells/CellNumeric.js +6 -1
  68. package/es/HiTable/BodyCells/CellRate.js +6 -1
  69. package/es/HiTable/BodyCells/CellSentinel.js +6 -1
  70. package/es/HiTable/BodyCells/CellStatus.js +7 -2
  71. package/es/HiTable/BodyCells/CellText.js +6 -1
  72. package/es/HiTable/BodyCells/CellThirdPartySecurity.js +6 -1
  73. package/es/HiTable/BodyRow.js +7 -2
  74. package/es/HiTable/ColumnFilter.js +2 -5
  75. package/es/HiTable/HeaderCell.js +16 -9
  76. package/es/HiTable/HiStickyRow.js +20 -13
  77. package/es/HiTable/HiTable.js +4 -40
  78. package/es/HiTable/HiTableBody.js +78 -26
  79. package/es/HiTable/HiTableContextMenu.js +28 -16
  80. package/es/HiTable/HiTableFooter.js +5 -0
  81. package/es/HiTable/HiTableHead.js +11 -6
  82. package/es/HiTopBar/HiTopBar.js +5 -0
  83. package/es/utils/HiIconBuilder.js +6 -2
  84. package/index.es.js +1 -1
  85. package/index.js +1 -1
  86. package/package.json +6 -1
  87. package/umd/hipay-material-ui.development.js +99120 -65306
  88. package/umd/hipay-material-ui.production.min.js +5 -5
  89. package/utils/HiIconBuilder.js +6 -2
package/HI-CHANGELOG.md CHANGED
@@ -1,58 +1,41 @@
1
- ## HEAD
1
+ <a name="1.0.0-beta.25"></a>
2
+ # 1.0.0-beta.25 (2018-08-16)
2
3
 
3
- Changes. Changes everywhere!
4
4
 
5
- ## 1.0.0-beta.10
6
- ###### *17 mai 2018*
5
+ ### Bug Fixes
7
6
 
8
- - Correction du HiSelect
7
+ * **BodyRow:** add locale vars to child BodyRow ([9252382](https://gitlab.hipay.org/backend/hipay-material-ui/commit/9252382))
8
+ * **CellDate:** Handle date with moment & use prop format ([7fa8bf5](https://gitlab.hipay.org/backend/hipay-material-ui/commit/7fa8bf5))
9
+ * **HeaderCell:** set sort icons always on the right of the title ([0704619](https://gitlab.hipay.org/backend/hipay-material-ui/commit/0704619))
10
+ * **HiDateRangePicker:** Keep focus on change dateTo if user types directly into the input to see date selection into calendar ([e998c60](https://gitlab.hipay.org/backend/hipay-material-ui/commit/e998c60))
11
+ * **HiDateRangePicker:** Reset date range picker input to ([b1a66f3](https://gitlab.hipay.org/backend/hipay-material-ui/commit/b1a66f3))
12
+ * **HiDateRangeSelector:** UPD select value from parent component (defaultPreset property) ([90bb994](https://gitlab.hipay.org/backend/hipay-material-ui/commit/90bb994))
13
+ * **HiInput:** Keep focus on reset HiInput ([a84edab](https://gitlab.hipay.org/backend/hipay-material-ui/commit/a84edab))
14
+ * **HiPins:** Add theme business primary color as default background color for HiPins and fix line-height ([23aa2d9](https://gitlab.hipay.org/backend/hipay-material-ui/commit/23aa2d9))
15
+ * **HiSelect:** Display option label instead of all for selects with 1 option ([e47574a](https://gitlab.hipay.org/backend/hipay-material-ui/commit/e47574a))
16
+ * **HiSelect:** Don't try to display unique selected options item when still loading ([116a72a](https://gitlab.hipay.org/backend/hipay-material-ui/commit/116a72a))
17
+ * **HiSelectableList:** item displayed only if item.displayed != false ([e65b865](https://gitlab.hipay.org/backend/hipay-material-ui/commit/e65b865))
18
+ * **HiTable:** Add default translations object to HeaderCell ([4ed766f](https://gitlab.hipay.org/backend/hipay-material-ui/commit/4ed766f))
19
+ * **HiTable:** Performance optimization ([3ca60d3](https://gitlab.hipay.org/backend/hipay-material-ui/commit/3ca60d3))
20
+ * **HiTable:** remove anchorEls from state to remove circular structure in JSON compares ([c064ce9](https://gitlab.hipay.org/backend/hipay-material-ui/commit/c064ce9))
21
+ * **SelectInput:** selected choice label not overflowing on right arrow of HiSelect ([a7d7058](https://gitlab.hipay.org/backend/hipay-material-ui/commit/a7d7058))
9
22
 
10
- ### Breaking change
11
23
 
12
- - N/A
24
+ ### Features
13
25
 
14
- #### Component Fixes / Enhancements
26
+ * **HiDateRangePicker:** Add onBlur prop function to handle date errors properly ([df79494](https://gitlab.hipay.org/backend/hipay-material-ui/commit/df79494))
27
+ * **HiTableContextMenu:** handle hide lookup/exclude menu item for each column ([03e00cb](https://gitlab.hipay.org/backend/hipay-material-ui/commit/03e00cb))
28
+ * **workflow:** Add HI-CHANGELOG generation from commits ([edee0f6](https://gitlab.hipay.org/backend/hipay-material-ui/commit/edee0f6))
15
29
 
16
- - [HiSelect] Ajout d'un param staticPosition dans le HiSelect pour afficher dans une div plutot qu'une popper
17
- - [HiSelect] Fermeture du select au click sur le bouton
18
- - [SelectInput] cursor pointer si noButton
19
- - [HiDateRangeSelector] Suppression du last 24h
20
30
 
21
- ## 1.0.0-beta.4
22
- ###### *06 avril 2018*
23
31
 
24
- - Corrections de styles sur quelques composants
25
- - Fix sur le composant HiSelect avec une value vide
32
+ <a name="1.0.0-beta.24"></a>
33
+ # 1.0.0-beta.24 (2018-07-26)
26
34
 
27
- ### Breaking change
28
35
 
29
- - N/A
36
+ ### Features
30
37
 
31
- #### Component Fixes / Enhancements
38
+ * **workflow:** Add HI-CHANGELOG generation from commits ([edee0f6](https://gitlab.hipay.org/backend/hipay-material-ui/commit/edee0f6))
32
39
 
33
- - [HiTopBar] Ajout d'une props refButtons poutr récupérer la div contenant les boutons "menu" et "back"
34
- - [HiSelect] Gestion d'une value vide
35
- - [HiSelect] Ajout du focus sur l'élement SelectInput à la fermeture du select
36
- - [HiSelectField] Ajout de la props className
37
- - [HiSuggestSelectField] Ajout de la props className
38
- - [HiSuggestSelect] Gestion du focus et du open des suggestions
39
- - [SelectInput] Suppression du soulignage bleu au hover quand champs en erreur
40
- - [HiFormControl] Stop de l'event click sur error pour ne pas ouvrir le select
41
40
 
42
- ## 1.0.0-beta.3
43
- ###### *28 mars 2018*
44
41
 
45
- - Ajout d'un CHANGELOG HiPay ! (HI-CHANGELOG.md)
46
- - Corrections de styles sur quelques composants
47
-
48
- ### Breaking change
49
-
50
- - [HiTopBar] Ajout d'une props "searchInput" obligatoire
51
-
52
- #### Component Fixes / Enhancements
53
-
54
- - [HiTopBar] Ajout du style "overflow: 'inherit'" sur le Collapse si pas "hideable", afin de ne pas cacher les suggestions
55
- - [HiTopBar] Gestion du focus en props plutôt qu'en state
56
- - [HiTopBar] Ajout d'une props "searchInput" obligatoire
57
- - [HiChipSwitch] Ajout d'un title sur la sélection
58
- - [HiDateRangePicker] Correction du focus
package/HiChip/HiChip.js CHANGED
@@ -58,14 +58,24 @@ var styles = exports.styles = function styles(theme) {
58
58
  },
59
59
  '&$deletable': {
60
60
  paddingRight: 4
61
+ },
62
+ '&$leftIccon': {
63
+ paddingLeft: 4
61
64
  }
62
65
  }),
63
66
  leftNavigation: {},
64
67
  rightNavigation: {},
65
68
  deletable: {},
69
+ leftIccon: {},
66
70
  icon: {
67
71
  marginRight: 4
68
72
  },
73
+ iconClickable: {
74
+ cursor: 'pointer',
75
+ '&:hover, &:focus': {
76
+ color: theme.palette.business.primary.normal
77
+ }
78
+ },
69
79
  eraseIcon: {
70
80
  // Remove grey highlight
71
81
  WebkitTapHighlightColor: 'transparent',
@@ -115,17 +125,25 @@ function HiChip(props) {
115
125
  var label = props.label,
116
126
  classes = props.classes,
117
127
  icon = props.icon,
128
+ id = props.id,
118
129
  img = props.img,
119
130
  onPrevious = props.onPrevious,
120
131
  onNext = props.onNext,
121
132
  onDelete = props.onDelete,
122
- prefix = props.prefix;
133
+ prefix = props.prefix,
134
+ onIconClick = props.onIconClick,
135
+ titleDelete = props.titleDelete,
136
+ titleIcon = props.titleIcon,
137
+ titleImg = props.titleImg,
138
+ titleNext = props.titleNext,
139
+ titlePrevious = props.titlePrevious;
123
140
 
124
141
 
125
142
  return _react2.default.createElement(
126
143
  'div',
127
144
  {
128
- className: (0, _classnames2.default)(classes.root, (_classNames = {}, (0, _defineProperty3.default)(_classNames, classes.leftNavigation, onPrevious), (0, _defineProperty3.default)(_classNames, classes.rightNavigation, onNext), (0, _defineProperty3.default)(_classNames, classes.deletable, onDelete), _classNames))
145
+ id: id,
146
+ className: (0, _classnames2.default)(classes.root, (_classNames = {}, (0, _defineProperty3.default)(_classNames, classes.leftNavigation, onPrevious), (0, _defineProperty3.default)(_classNames, classes.rightNavigation, onNext), (0, _defineProperty3.default)(_classNames, classes.deletable, onDelete), (0, _defineProperty3.default)(_classNames, classes.leftIccon, icon), _classNames))
129
147
  },
130
148
  prefix && _react2.default.createElement(
131
149
  'span',
@@ -133,13 +151,20 @@ function HiChip(props) {
133
151
  prefix,
134
152
  ' : '
135
153
  ),
136
- img && _react2.default.createElement('img', { className: classes.badge, src: img, alt: img }),
137
- icon && _react2.default.createElement(_HiIconBuilder2.default, { className: classes.icon, icon: icon, size: 16 }),
154
+ img && _react2.default.createElement('img', { className: classes.badge, src: img, alt: img, title: titleImg }),
155
+ icon && _react2.default.createElement(_HiIconBuilder2.default, {
156
+ className: (0, _classnames2.default)(classes.icon, (0, _defineProperty3.default)({}, classes.iconClickable, onIconClick)),
157
+ icon: icon,
158
+ size: 16,
159
+ onClick: onIconClick,
160
+ titleAccess: titleIcon
161
+ }),
138
162
  onPrevious && _react2.default.createElement(_HiIconBuilder2.default, {
139
163
  className: (0, _classnames2.default)(classes.navigate),
140
164
  icon: 'menuLeft',
141
165
  onClick: onPrevious,
142
- size: 16
166
+ size: 16,
167
+ titleAccess: titlePrevious
143
168
  }),
144
169
  _react2.default.createElement(
145
170
  'span',
@@ -150,13 +175,15 @@ function HiChip(props) {
150
175
  className: (0, _classnames2.default)(classes.navigate),
151
176
  icon: 'menuRight',
152
177
  onClick: onNext,
153
- size: 16
178
+ size: 16,
179
+ titleAccess: titleNext
154
180
  }),
155
181
  onDelete && _react2.default.createElement(_HiIconBuilder2.default, {
156
182
  classes: { root: classes.eraseIcon },
157
183
  icon: 'closeCircle',
158
184
  onClick: onDelete,
159
- size: 16
185
+ size: 16,
186
+ titleAccess: titleDelete
160
187
  })
161
188
  );
162
189
  }
@@ -170,6 +197,10 @@ HiChip.propTypes = process.env.NODE_ENV !== "production" ? {
170
197
  * Icone affiché à gauche
171
198
  */
172
199
  icon: _propTypes2.default.string,
200
+ /**
201
+ * Identifiant de l'élément
202
+ */
203
+ id: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.number]),
173
204
  /**
174
205
  * Ajoute une image à gauche du Chip
175
206
  */
@@ -182,6 +213,10 @@ HiChip.propTypes = process.env.NODE_ENV !== "production" ? {
182
213
  * Fonction de callback au clic sur l'icon close si cancelable = true
183
214
  */
184
215
  onDelete: _propTypes2.default.func,
216
+ /**
217
+ * Fonction de callback au clic sur l'icon à gauche
218
+ */
219
+ onIconClick: _propTypes2.default.func,
185
220
  /**
186
221
  * Fonction de callback au clic sur l'icon next
187
222
  */
@@ -189,7 +224,31 @@ HiChip.propTypes = process.env.NODE_ENV !== "production" ? {
189
224
  /**
190
225
  * Fonction de callback au clic sur l'icon previous
191
226
  */
192
- onPrevious: _propTypes2.default.func
227
+ onPrevious: _propTypes2.default.func,
228
+ /**
229
+ * Préfixe dans le HiChip
230
+ */
231
+ prefix: _propTypes2.default.string,
232
+ /**
233
+ * Titre de l'icône supprimer
234
+ */
235
+ titleDelete: _propTypes2.default.string,
236
+ /**
237
+ * Titre de l'icône
238
+ */
239
+ titleIcon: _propTypes2.default.string,
240
+ /**
241
+ * Titre de la balise img
242
+ */
243
+ titleImg: _propTypes2.default.string,
244
+ /**
245
+ * Titre de la navigation suivante
246
+ */
247
+ titleNext: _propTypes2.default.string,
248
+ /**
249
+ * Titre de la navigation précédente
250
+ */
251
+ titlePrevious: _propTypes2.default.string
193
252
  } : {};
194
253
 
195
254
  exports.default = (0, _withStyles2.default)(styles, { name: 'HmuiHiChip' })(HiChip);
@@ -207,6 +207,7 @@ var HiChipSwitch = function (_React$PureComponent) {
207
207
  _this2 = this;
208
208
 
209
209
  var _props = this.props,
210
+ id = _props.id,
210
211
  label = _props.label,
211
212
  classes = _props.classes,
212
213
  activeIcon = _props.activeIcon,
@@ -232,6 +233,7 @@ var HiChipSwitch = function (_React$PureComponent) {
232
233
  return _react2.default.createElement(
233
234
  'div',
234
235
  {
236
+ id: id,
235
237
  className: (0, _classnames2.default)(classes.root, (_classNames = {}, (0, _defineProperty3.default)(_classNames, classes.active, !!active), (0, _defineProperty3.default)(_classNames, classes.inactive, !active), _classNames)),
236
238
  onClick: onClick,
237
239
  role: 'button',
@@ -285,6 +287,10 @@ HiChipSwitch.propTypes = process.env.NODE_ENV !== "production" ? {
285
287
  * Surcharge les classes du composant
286
288
  */
287
289
  classes: _propTypes2.default.object,
290
+ /**
291
+ * Identifiant de l'élément
292
+ */
293
+ id: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.number]),
288
294
  /**
289
295
  * Label qu'affiche le ChipFilter
290
296
  */
@@ -4,6 +4,10 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
 
7
+ var _typeof2 = require('babel-runtime/helpers/typeof');
8
+
9
+ var _typeof3 = _interopRequireDefault(_typeof2);
10
+
7
11
  var _objectWithoutProperties2 = require('babel-runtime/helpers/objectWithoutProperties');
8
12
 
9
13
  var _objectWithoutProperties3 = _interopRequireDefault(_objectWithoutProperties2);
@@ -114,6 +118,7 @@ var HiDatePicker = function (_React$Component) {
114
118
  _this.renderMonthPickerOverlay = _this.renderMonthPickerOverlay.bind(_this);
115
119
  _this.renderTimePickerOverlay = _this.renderTimePickerOverlay.bind(_this);
116
120
  _this.renderYearPickerOverlay = _this.renderYearPickerOverlay.bind(_this);
121
+ _this.handleInputChange = _this.handleInputChange.bind(_this);
117
122
  return _this;
118
123
  }
119
124
 
@@ -128,29 +133,36 @@ var HiDatePicker = function (_React$Component) {
128
133
  this.handleCurrentMonthChange(new Date());
129
134
  this.props.onReset();
130
135
  }
136
+ }, {
137
+ key: 'handleInputChange',
138
+ value: function handleInputChange(event) {
139
+ this.props.onChange(event.target.value);
140
+ }
131
141
  }, {
132
142
  key: 'handleDayChange',
133
143
  value: function handleDayChange(day, modifiers) {
134
- if (modifiers.selected) {
135
- // Deselect day
136
- this.props.onChange(undefined);
137
- } else {
138
- // Keep Time if set
139
- if (this.props.enableTime && day !== undefined) {
140
- if (this.props.value) {
141
- day.setHours(this.props.value.getHours(), this.props.value.getMinutes());
142
- } else {
143
- day.setHours(0, 0);
144
+ if (day) {
145
+ if (modifiers.selected) {
146
+ // Deselect day
147
+ this.props.onChange(undefined);
148
+ } else {
149
+ // Keep Time if set
150
+ if (this.props.enableTime && day !== undefined) {
151
+ if (this.props.value) {
152
+ day.setHours(this.props.value.getHours(), this.props.value.getMinutes());
153
+ } else {
154
+ day.setHours(0, 0);
155
+ }
144
156
  }
157
+ this.props.onChange(day);
158
+ }
159
+ if (day instanceof Date && !this.props.enableTime && modifiers.selected !== true) {
160
+ // Hide overlay & remove focus on input
161
+ document.activeElement.blur();
162
+ } else if (day instanceof Date && this.props.enableTime && modifiers.selected !== true) {
163
+ // Open Time panel after date selection
164
+ this.openPanel('time');
145
165
  }
146
- this.props.onChange(day);
147
- }
148
- if (day instanceof Date && !this.props.enableTime && modifiers.selected !== true) {
149
- // Hide overlay & remove focus on input
150
- document.activeElement.blur();
151
- } else if (day instanceof Date && this.props.enableTime && modifiers.selected !== true) {
152
- // Open Time panel after date selection
153
- this.openPanel('time');
154
166
  }
155
167
  }
156
168
  }, {
@@ -299,7 +311,7 @@ var HiDatePicker = function (_React$Component) {
299
311
  captionElement: this.renderCaption,
300
312
  classNames: classes,
301
313
  disabledDays: effectiveDisabledDays,
302
- selectedDays: value,
314
+ selectedDays: (typeof value === 'undefined' ? 'undefined' : (0, _typeof3.default)(value)) === 'object' ? value : undefined,
303
315
  locale: locale,
304
316
  firstDayOfWeek: 1,
305
317
  fromMonth: minimumDate,
@@ -315,7 +327,9 @@ var HiDatePicker = function (_React$Component) {
315
327
  onReset: this.handleReset
316
328
  }, {
317
329
  onBlur: this.handleBlur
318
- }, props);
330
+ }, props, {
331
+ onChange: this.handleInputChange
332
+ });
319
333
 
320
334
  return _react2.default.createElement(
321
335
  'div',
@@ -410,6 +424,6 @@ HiDatePicker.propTypes = process.env.NODE_ENV !== "production" ? {
410
424
  /**
411
425
  * Date sélectionnée
412
426
  */
413
- value: _propTypes2.default.instanceOf(Date)
427
+ value: _propTypes2.default.oneOfType([_propTypes2.default.instanceOf(Date), _propTypes2.default.string])
414
428
  } : {};
415
429
  exports.default = (0, _withStyles2.default)(_stylesheet2.default, { name: 'HmuiHiDatePicker' })(HiDatePicker);
@@ -4,6 +4,10 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
 
7
+ var _values = require('babel-runtime/core-js/object/values');
8
+
9
+ var _values2 = _interopRequireDefault(_values);
10
+
7
11
  var _objectWithoutProperties2 = require('babel-runtime/helpers/objectWithoutProperties');
8
12
 
9
13
  var _objectWithoutProperties3 = _interopRequireDefault(_objectWithoutProperties2);
@@ -106,12 +110,28 @@ var HiDateRangePicker = function (_React$Component) {
106
110
 
107
111
  var _this = (0, _possibleConstructorReturn3.default)(this, (HiDateRangePicker.__proto__ || (0, _getPrototypeOf2.default)(HiDateRangePicker)).call(this));
108
112
 
113
+ _this.handleInputChange = function (inputName) {
114
+ return function (event) {
115
+ _this.event = event;
116
+ _this.props.onChange(inputName, event.target.value);
117
+ };
118
+ };
119
+
109
120
  _this.handleDayPickerFocus = function (name) {
110
121
  return function () {
111
122
  _this.setState({ focusedInput: name });
112
123
  };
113
124
  };
114
125
 
126
+ _this.handleDayPickerBlur = function (name) {
127
+ return function () {
128
+ _this.setState({ focusedInput: '' });
129
+ if (_this.props.onBlur) {
130
+ _this.props.onBlur(name);
131
+ }
132
+ };
133
+ };
134
+
115
135
  _this.state = {
116
136
  fromCurrentMonth: props.from ? props.from : new Date(),
117
137
  toCurrentMonth: props.to ? props.to : new Date(),
@@ -141,6 +161,7 @@ var HiDateRangePicker = function (_React$Component) {
141
161
  _this.handleYearClickTo = _this.handleYearClickTo.bind(_this);
142
162
  _this.handleDayPickerFocus = _this.handleDayPickerFocus.bind(_this);
143
163
  _this.handleDayPickerBlur = _this.handleDayPickerBlur.bind(_this);
164
+ _this.handleInputChange = _this.handleInputChange.bind(_this);
144
165
 
145
166
  _this.openPanel = _this.openPanel.bind(_this);
146
167
 
@@ -186,11 +207,7 @@ var HiDateRangePicker = function (_React$Component) {
186
207
  value: function handleReset(name) {
187
208
  var _this3 = this;
188
209
 
189
- if (name === 'from') {
190
- this.handleCurrentMonthChange(name, new Date());
191
- } else {
192
- this.handleCurrentMonthChange(name, this.props.from);
193
- }
210
+ this.handleCurrentMonthChange(name, new Date());
194
211
 
195
212
  this.timeout = setTimeout(function () {
196
213
  if (_this3.props.onReset) {
@@ -203,38 +220,45 @@ var HiDateRangePicker = function (_React$Component) {
203
220
  value: function handleDayChange(name, day, modifiers) {
204
221
  var _this4 = this;
205
222
 
206
- // if time disabled, focus TO input
207
- // else focus current input
208
- if (!this.props.enableTime) {
209
- if (day instanceof Date) {
210
- if (name === 'from' && this.toInput) {
211
- this.toInput.getInput().focus();
212
- } else if (name === 'to') {
213
- document.activeElement.blur();
223
+ if (day) {
224
+ // if time disabled, focus TO input
225
+ // else focus current input
226
+ if (!this.props.enableTime) {
227
+ if (day instanceof Date) {
228
+ if (name === 'from' && this.toInput) {
229
+ this.toInput.getInput().focus();
230
+ } else if (name === 'to') {
231
+ if (typeof this.event === 'undefined' || this.event && this.event.type !== 'change') {
232
+ // trigger blur only if user clicks on date into calendar
233
+ // else keep focus to see day selection into calendar
234
+ document.activeElement.blur();
235
+ }
236
+ delete this.event;
237
+ }
214
238
  }
239
+ } else {
240
+ this.timeout = setTimeout(function () {
241
+ if (_this4[name + 'Input'].getInput()) {
242
+ _this4[name + 'Input'].getInput().focus();
243
+ }
244
+ }, 10);
215
245
  }
216
- } else {
217
- this.timeout = setTimeout(function () {
218
- if (_this4[name + 'Input'].getInput()) {
219
- _this4[name + 'Input'].getInput().focus();
220
- }
221
- }, 10);
222
- }
223
246
 
224
- if (this.props.onChange) {
225
- // Keep Time if set
226
- if (this.props.enableTime) {
227
- if (this.props[name]) {
228
- day.setHours(this.props[name].getHours(), this.props[name].getMinutes());
229
- } else {
230
- day.setHours(0, 0);
247
+ if (this.props.onChange) {
248
+ // Keep Time if set
249
+ if (this.props.enableTime) {
250
+ if (this.props[name]) {
251
+ day.setHours(this.props[name].getHours(), this.props[name].getMinutes());
252
+ } else {
253
+ day.setHours(0, 0);
254
+ }
231
255
  }
256
+ this.props.onChange(name, day);
232
257
  }
233
- this.props.onChange(name, day);
234
- }
235
258
 
236
- if (this.props.enableTime) {
237
- this.openPanel(name, 'time');
259
+ if (this.props.enableTime) {
260
+ this.openPanel(name, 'time');
261
+ }
238
262
  }
239
263
  }
240
264
  }, {
@@ -337,11 +361,6 @@ var HiDateRangePicker = function (_React$Component) {
337
361
  document.activeElement.blur();
338
362
  }
339
363
  }
340
- }, {
341
- key: 'handleDayPickerBlur',
342
- value: function handleDayPickerBlur() {
343
- this.setState({ focusedInput: '' });
344
- }
345
364
  }, {
346
365
  key: 'openPanel',
347
366
  value: function openPanel(name, panel) {
@@ -502,6 +521,20 @@ var HiDateRangePicker = function (_React$Component) {
502
521
  }
503
522
  };
504
523
 
524
+ var selectedDays = [];
525
+ var selected = {};
526
+ if (from instanceof Date) {
527
+ selectedDays.push(from);
528
+ selected.from = from;
529
+ }
530
+ if (to instanceof Date) {
531
+ selectedDays.push(to);
532
+ selected.to = to;
533
+ }
534
+ if ((0, _values2.default)(selected).length > 0) {
535
+ selectedDays.push(selected);
536
+ }
537
+
505
538
  var dayPickerProps = (0, _extends3.default)({
506
539
  classNames: classes,
507
540
  disabledDays: disabledDays,
@@ -511,7 +544,7 @@ var HiDateRangePicker = function (_React$Component) {
511
544
  modifiers: modifiers,
512
545
  modifiersStyles: modifiersStyles,
513
546
  // Both are required ?
514
- selectedDays: [from, { from: from, to: to }],
547
+ selectedDays: selectedDays,
515
548
  todayButton: translations.today,
516
549
  weekdayElement: _Weekday2.default
517
550
  }, props);
@@ -520,9 +553,9 @@ var HiDateRangePicker = function (_React$Component) {
520
553
  // Disable days after 'to' date if define
521
554
 
522
555
  var after = void 0;
523
- if (to && disableFutureDays) {
556
+ if (to instanceof Date && disableFutureDays) {
524
557
  after = to < now ? now : to;
525
- } else if (to) {
558
+ } else if (to instanceof Date) {
526
559
  after = to;
527
560
  } else if (disableFutureDays) {
528
561
  after = now;
@@ -549,9 +582,9 @@ var HiDateRangePicker = function (_React$Component) {
549
582
  // Disable days before 'from' date if define
550
583
 
551
584
  var before = void 0;
552
- if (from && disablePastDays) {
585
+ if (from instanceof Date && disablePastDays) {
553
586
  before = from < now ? now : from;
554
- } else if (from) {
587
+ } else if (from instanceof Date) {
555
588
  before = from;
556
589
  } else if (disablePastDays) {
557
590
  before = now;
@@ -583,7 +616,8 @@ var HiDateRangePicker = function (_React$Component) {
583
616
  }, props, labelFrom && {
584
617
  label: labelFrom
585
618
  }, {
586
- id: id + '-from'
619
+ id: id + '-from',
620
+ onChange: this.handleInputChange('from')
587
621
  });
588
622
 
589
623
  var toInputProps = (0, _extends3.default)({}, onReset && {
@@ -593,11 +627,11 @@ var HiDateRangePicker = function (_React$Component) {
593
627
  }, props, labelTo && {
594
628
  label: labelTo
595
629
  }, {
596
- id: id + '-to'
630
+ id: id + '-to',
631
+ onChange: this.handleInputChange('to')
597
632
  });
598
633
 
599
- var fromClass = (0, _classnames2.default)((_classNames = {}, (0, _defineProperty3.default)(_classNames, classes.absolute, staticPosition === true && this.state.focusedInput === 'to'), (0, _defineProperty3.default)(_classNames, classes.dayPickerMargin, staticPosition === true && this.state.focusedInput === 'to'), _classNames));
600
- var toClass = (0, _classnames2.default)(classes.toInput, (0, _defineProperty3.default)({}, classes.absolute, staticPosition === true && this.state.focusedInput === 'from'));
634
+ var toClass = (0, _classnames2.default)(classes.toInput, (_classNames = {}, (0, _defineProperty3.default)(_classNames, classes.absolute, staticPosition === true && this.state.focusedInput === 'from'), (0, _defineProperty3.default)(_classNames, classes.right4, staticPosition === true && this.state.focusedInput === 'from'), _classNames));
601
635
 
602
636
  return _react2.default.createElement(
603
637
  'div',
@@ -607,11 +641,11 @@ var HiDateRangePicker = function (_React$Component) {
607
641
  {
608
642
  className: classes.fromInput,
609
643
  onFocus: this.handleDayPickerFocus('from'),
610
- onBlur: this.handleDayPickerBlur
644
+ onBlur: this.handleDayPickerBlur('from')
611
645
  },
612
646
  _react2.default.createElement(
613
647
  'div',
614
- { className: fromClass },
648
+ null,
615
649
  _react2.default.createElement(_DayPickerInput2.default, {
616
650
  ref: function ref(el) {
617
651
  _this6.fromInput = el;
@@ -635,7 +669,7 @@ var HiDateRangePicker = function (_React$Component) {
635
669
  {
636
670
  className: toClass,
637
671
  onFocus: this.handleDayPickerFocus('to'),
638
- onBlur: this.handleDayPickerBlur
672
+ onBlur: this.handleDayPickerBlur('to')
639
673
  },
640
674
  _react2.default.createElement(_DayPickerInput2.default, {
641
675
  ref: function ref(el) {
@@ -711,7 +745,7 @@ HiDateRangePicker.propTypes = process.env.NODE_ENV !== "production" ? {
711
745
  /**
712
746
  * Date de début sélectionnée
713
747
  */
714
- from: _propTypes2.default.instanceOf(Date),
748
+ from: _propTypes2.default.oneOfType([_propTypes2.default.instanceOf(Date), _propTypes2.default.string]),
715
749
  /**
716
750
  * Utilisé pour construire les ids des champs from et to en les suffixant "-from" et "-to"
717
751
  */
@@ -734,10 +768,18 @@ HiDateRangePicker.propTypes = process.env.NODE_ENV !== "production" ? {
734
768
  minimumDate: _propTypes2.default.instanceOf(Date),
735
769
  /**
736
770
  * Callback à la sélection d'une date
771
+ * @param {string} nom de l'input
772
+ */
773
+ onBlur: _propTypes2.default.func,
774
+ /**
775
+ * Callback à la sélection d'une date
776
+ * @param {string} nom du champs
777
+ * @param {string} nouvelle valeur du champs
737
778
  */
738
779
  onChange: _propTypes2.default.func,
739
780
  /**
740
781
  * Callback au reset de l'input
782
+ * @param {string} nom du champs réinitialisé
741
783
  */
742
784
  onReset: _propTypes2.default.func,
743
785
  /**
@@ -747,7 +789,7 @@ HiDateRangePicker.propTypes = process.env.NODE_ENV !== "production" ? {
747
789
  /**
748
790
  * Date de fin sélectionnée
749
791
  */
750
- to: _propTypes2.default.instanceOf(Date),
792
+ to: _propTypes2.default.oneOfType([_propTypes2.default.instanceOf(Date), _propTypes2.default.string]),
751
793
  /**
752
794
  * Traductions
753
795
  */