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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/CHANGELOG.md +58 -0
  2. package/HiCell/CellNumeric.js +1 -1
  3. package/HiDatePicker/HiDatePicker.js +11 -2
  4. package/HiDatePicker/HiDateRangePicker.js +49 -8
  5. package/HiDatePicker/HiDateRangeSelector.js +39 -30
  6. package/HiDatePicker/Overlays/YearPickerOverlay.js +8 -3
  7. package/HiForm/HiFormControl.js +26 -11
  8. package/HiForm/HiFormLabel.js +3 -1
  9. package/HiForm/HiInput.js +20 -1
  10. package/HiForm/HiUpload.js +290 -45
  11. package/HiForm/HiUploadField.js +19 -51
  12. package/HiForm/HiUploadInput.js +18 -7
  13. package/HiSelectNew/HiDynamicSelect.js +3 -3
  14. package/HiSelectNew/HiNestedSelect.js +9 -9
  15. package/HiSelectNew/HiNestedSelectContent.js +9 -9
  16. package/HiSelectNew/HiSelect.js +22 -23
  17. package/HiSelectNew/HiSelectContent.js +7 -7
  18. package/HiSelectableList/HiSelectableListItem.js +3 -7
  19. package/README.md +1 -1
  20. package/es/HiCell/CellNumeric.js +1 -1
  21. package/es/HiDatePicker/HiDatePicker.js +11 -2
  22. package/es/HiDatePicker/HiDateRangePicker.js +42 -8
  23. package/es/HiDatePicker/HiDateRangeSelector.js +38 -27
  24. package/es/HiDatePicker/Overlays/YearPickerOverlay.js +8 -3
  25. package/es/HiForm/HiFormControl.js +27 -11
  26. package/es/HiForm/HiFormLabel.js +3 -1
  27. package/es/HiForm/HiInput.js +19 -1
  28. package/es/HiForm/HiUpload.js +276 -35
  29. package/es/HiForm/HiUploadField.js +19 -43
  30. package/es/HiForm/HiUploadInput.js +16 -7
  31. package/es/HiSelectNew/HiSelect.js +15 -16
  32. package/es/HiSelectableList/HiSelectableListItem.js +3 -7
  33. package/es/utils/helpers.js +6 -5
  34. package/index.es.js +1 -1
  35. package/index.js +1 -1
  36. package/package.json +3 -2
  37. package/umd/hipay-material-ui.development.js +29594 -21713
  38. package/umd/hipay-material-ui.production.min.js +2 -2
  39. package/utils/helpers.js +6 -4
@@ -47,12 +47,12 @@ var _helpers = require("../utils/helpers");
47
47
  */
48
48
  function getRecursiveFinalItemIdList(itemList) {
49
49
  var finalItemIdList = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
50
- return (0, _toConsumableArray2.default)(finalItemIdList).concat((0, _toConsumableArray2.default)(itemList.reduce(function (memo, item) {
50
+ return [].concat((0, _toConsumableArray2.default)(finalItemIdList), (0, _toConsumableArray2.default)(itemList.reduce(function (memo, item) {
51
51
  if (item.children) {
52
52
  return getRecursiveFinalItemIdList(item.children, memo);
53
53
  }
54
54
 
55
- return (0, _toConsumableArray2.default)(memo).concat([item.id]);
55
+ return [].concat((0, _toConsumableArray2.default)(memo), [item.id]);
56
56
  }, [])));
57
57
  }
58
58
  /**
@@ -128,7 +128,7 @@ function buildFilteredItemList(itemList) {
128
128
  }
129
129
 
130
130
  return {
131
- l: (0, _toConsumableArray2.default)(memoItemList).concat([(0, _extends2.default)({}, item, disabledParent && {
131
+ l: [].concat((0, _toConsumableArray2.default)(memoItemList), [(0, _extends2.default)({}, item, disabledParent && {
132
132
  disabled: true,
133
133
  hideCheckbox: true // don't display checkbox on disabled parent
134
134
 
@@ -147,7 +147,7 @@ function buildFilteredItemList(itemList) {
147
147
 
148
148
  var itemSelected = selectedItemIdList.includes(item.id);
149
149
  return {
150
- l: (0, _toConsumableArray2.default)(memoItemList).concat([(0, _extends2.default)({
150
+ l: [].concat((0, _toConsumableArray2.default)(memoItemList), [(0, _extends2.default)({
151
151
  displayed: itemVisible || visibleParent
152
152
  }, item)]),
153
153
  s: itemSelected && memoSelected,
@@ -266,9 +266,9 @@ function (_React$PureComponent) {
266
266
  }), item);
267
267
  } else {
268
268
  // select parent > add each selectable child without duplicates.
269
- onChange(event, (0, _toConsumableArray2.default)(value.filter(function (vid) {
269
+ onChange(event, [].concat((0, _toConsumableArray2.default)(value.filter(function (vid) {
270
270
  return !parentSelectableItemIdList.includes(vid);
271
- })).concat((0, _toConsumableArray2.default)(parentSelectableItemIdList)), item);
271
+ })), (0, _toConsumableArray2.default)(parentSelectableItemIdList)), item);
272
272
  }
273
273
  } else if (value.includes(item.id)) {
274
274
  // unselect item
@@ -276,7 +276,7 @@ function (_React$PureComponent) {
276
276
  return id !== item.id;
277
277
  }), item);
278
278
  } else {
279
- onChange(event, (0, _toConsumableArray2.default)(value).concat([item.id]), item);
279
+ onChange(event, [].concat((0, _toConsumableArray2.default)(value), [item.id]), item);
280
280
  }
281
281
  };
282
282
 
@@ -315,14 +315,14 @@ function (_React$PureComponent) {
315
315
  centered: true,
316
316
  hideCheckbox: true,
317
317
  label: translations.no_result_match
318
- }]) : (0, _toConsumableArray2.default)(loading ? [{
318
+ }]) : [].concat((0, _toConsumableArray2.default)(loading ? [{
319
319
  id: '_loading',
320
320
  type: 'loader',
321
321
  disabled: true,
322
322
  centered: true,
323
323
  hideCheckbox: true,
324
324
  label: 'loading'
325
- }] : []).concat((0, _toConsumableArray2.default)(hasAll ? [{
325
+ }] : []), (0, _toConsumableArray2.default)(hasAll ? [{
326
326
  id: '_all',
327
327
  iconAll: iconAll,
328
328
  label: translations.all,
@@ -43,12 +43,12 @@ var _helpers = require("../utils/helpers");
43
43
  */
44
44
  function getRecursiveFinalItemIdList(itemList) {
45
45
  var finalItemIdList = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
46
- return (0, _toConsumableArray2.default)(finalItemIdList).concat((0, _toConsumableArray2.default)(itemList.reduce(function (memo, item) {
46
+ return [].concat((0, _toConsumableArray2.default)(finalItemIdList), (0, _toConsumableArray2.default)(itemList.reduce(function (memo, item) {
47
47
  if (item.children) {
48
48
  return getRecursiveFinalItemIdList(item.children, memo);
49
49
  }
50
50
 
51
- return (0, _toConsumableArray2.default)(memo).concat([item.id]);
51
+ return [].concat((0, _toConsumableArray2.default)(memo), [item.id]);
52
52
  }, [])));
53
53
  }
54
54
  /**
@@ -124,7 +124,7 @@ function buildFilteredItemList(itemList) {
124
124
  }
125
125
 
126
126
  return {
127
- l: (0, _toConsumableArray2.default)(memoItemList).concat([(0, _extends2.default)({}, item, disabledParent && {
127
+ l: [].concat((0, _toConsumableArray2.default)(memoItemList), [(0, _extends2.default)({}, item, disabledParent && {
128
128
  disabled: true,
129
129
  hideCheckbox: true // don't display checkbox on disabled parent
130
130
 
@@ -143,7 +143,7 @@ function buildFilteredItemList(itemList) {
143
143
 
144
144
  var itemSelected = selectedItemIdList.includes(item.id);
145
145
  return {
146
- l: (0, _toConsumableArray2.default)(memoItemList).concat([(0, _extends2.default)({
146
+ l: [].concat((0, _toConsumableArray2.default)(memoItemList), [(0, _extends2.default)({
147
147
  displayed: itemVisible || visibleParent
148
148
  }, item)]),
149
149
  s: itemSelected && memoSelected,
@@ -223,9 +223,9 @@ function (_React$PureComponent) {
223
223
  }), item);
224
224
  } else {
225
225
  // select parent > add each selectable child without duplicates.
226
- onChange(event, (0, _toConsumableArray2.default)(value.filter(function (vid) {
226
+ onChange(event, [].concat((0, _toConsumableArray2.default)(value.filter(function (vid) {
227
227
  return !parentSelectableItemIdList.includes(vid);
228
- })).concat((0, _toConsumableArray2.default)(parentSelectableItemIdList)), item);
228
+ })), (0, _toConsumableArray2.default)(parentSelectableItemIdList)), item);
229
229
  }
230
230
  } else if (value.includes(item.id)) {
231
231
  // unselect item
@@ -233,7 +233,7 @@ function (_React$PureComponent) {
233
233
  return id !== item.id;
234
234
  }), item);
235
235
  } else {
236
- onChange(event, (0, _toConsumableArray2.default)(value).concat([item.id]), item);
236
+ onChange(event, [].concat((0, _toConsumableArray2.default)(value), [item.id]), item);
237
237
  }
238
238
  };
239
239
 
@@ -271,14 +271,14 @@ function (_React$PureComponent) {
271
271
  centered: true,
272
272
  hideCheckbox: true,
273
273
  label: translations.no_result_match
274
- }]) : (0, _toConsumableArray2.default)(loading ? [{
274
+ }]) : [].concat((0, _toConsumableArray2.default)(loading ? [{
275
275
  id: '_loading',
276
276
  type: 'loader',
277
277
  disabled: true,
278
278
  centered: true,
279
279
  hideCheckbox: true,
280
280
  label: 'loading'
281
- }] : []).concat((0, _toConsumableArray2.default)(hasAll ? [{
281
+ }] : []), (0, _toConsumableArray2.default)(hasAll ? [{
282
282
  id: '_all',
283
283
  iconAll: iconAll,
284
284
  label: translations.all,
@@ -148,22 +148,22 @@ function (_React$PureComponent) {
148
148
  var search = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
149
149
  var loading = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
150
150
  // build item list
151
- var itemList = (0, _toConsumableArray2.default)(loading ? [{
151
+ var itemList = [].concat((0, _toConsumableArray2.default)(loading ? [{
152
152
  id: '_loading',
153
153
  type: 'loader',
154
154
  disabled: true,
155
155
  centered: true,
156
156
  hideCheckbox: true,
157
157
  label: 'loading'
158
- }] : []).concat((0, _toConsumableArray2.default)(search !== '' ? (0, _toConsumableArray2.default)(options.filter(function (item) {
158
+ }] : []), (0, _toConsumableArray2.default)(search !== '' ? (0, _toConsumableArray2.default)(options.filter(function (item) {
159
159
  return _this.props.filterFunc(item, search);
160
- })) : (0, _toConsumableArray2.default)(_this.props.hasAll ? [(0, _extends2.default)({
160
+ })) : [].concat((0, _toConsumableArray2.default)(_this.props.hasAll ? [(0, _extends2.default)({
161
161
  id: '_all',
162
162
  label: _this.props.translations.all
163
163
  }, _this.props.iconAll && {
164
164
  type: 'icon',
165
165
  icon: _this.props.iconAll
166
- })] : []).concat((0, _toConsumableArray2.default)(options))));
166
+ })] : []), (0, _toConsumableArray2.default)(options))));
167
167
  return {
168
168
  itemList: itemList,
169
169
  inputValue: _this.buildInputValue(options, value, loading)
@@ -271,22 +271,20 @@ function (_React$PureComponent) {
271
271
  };
272
272
 
273
273
  _this.focusOnSelectedItem = function (selectedValue) {
274
- if (_this.overlay && _this.overlay.getElementsByTagName('li')[0]) {
275
- setTimeout(function () {
276
- // On initialise au premier élément pour être sûr de ne pas se retrouver avec un focus of undefined
277
- var item = _this.overlay.getElementsByTagName('li')[0];
278
-
279
- if (selectedValue && typeof selectedValue === 'string') {
280
- item = _this.overlay.getElementsByTagName('li')[selectedValue];
281
- } else if (selectedValue && typeof selectedValue === 'number') {
282
- item = _this.overlay.getElementsByTagName('li')[selectedValue - 1];
283
- }
274
+ setTimeout(function () {
275
+ // On initialise au premier élément pour être sûr de ne pas se retrouver avec un focus of undefined
276
+ var item = _this.overlay.getElementsByTagName('li')[0];
277
+
278
+ if (selectedValue && typeof selectedValue === 'string') {
279
+ item = _this.overlay.getElementsByTagName('li')[selectedValue];
280
+ } else if (selectedValue && typeof selectedValue === 'number') {
281
+ item = _this.overlay.getElementsByTagName('li')[selectedValue - 1];
282
+ }
284
283
 
285
- if (item) {
286
- item.focus();
287
- }
288
- }, 1);
289
- }
284
+ if (item) {
285
+ item.focus();
286
+ }
287
+ }, 1);
290
288
  };
291
289
 
292
290
  _this.handleClickAway = function (event) {
@@ -464,7 +462,7 @@ function (_React$PureComponent) {
464
462
  return id !== item.id;
465
463
  }), item);
466
464
  } else {
467
- onChange(event, (0, _toConsumableArray2.default)(value).concat([item.id]), item);
465
+ onChange(event, [].concat((0, _toConsumableArray2.default)(value), [item.id]), item);
468
466
  }
469
467
  };
470
468
 
@@ -490,13 +488,13 @@ function (_React$PureComponent) {
490
488
  });
491
489
  } else {
492
490
  _this.setState({
493
- suggestions: (0, _toConsumableArray2.default)(hasAll ? [(0, _extends2.default)({
491
+ suggestions: [].concat((0, _toConsumableArray2.default)(hasAll ? [(0, _extends2.default)({
494
492
  id: '_all',
495
493
  label: translations.all
496
494
  }, iconAll && {
497
495
  type: 'icon',
498
496
  icon: iconAll
499
- })] : []).concat((0, _toConsumableArray2.default)(suggestions))
497
+ })] : []), (0, _toConsumableArray2.default)(suggestions))
500
498
  });
501
499
  }
502
500
  };
@@ -528,11 +526,12 @@ function (_React$PureComponent) {
528
526
  suggestions: props.options,
529
527
  openDown: true
530
528
  };
529
+ _this.handleBlur = _this.handleBlur.bind((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)));
531
530
  _this.handleClick = _this.handleClick.bind((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)));
532
531
  _this.handleClose = _this.handleClose.bind((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)));
533
532
  _this.handleClickAway = _this.handleClickAway.bind((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)));
534
533
  _this.handleFocus = _this.handleFocus.bind((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)));
535
- _this.handleBlur = _this.handleBlur.bind((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)));
534
+ _this.handleKeyDownInput = _this.handleKeyDownInput.bind((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)));
536
535
  _this.handleSearch = _this.handleSearch.bind((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)));
537
536
  _this.handleSearchReset = _this.handleSearchReset.bind((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)));
538
537
  _this.handleSelect = _this.handleSelect.bind((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)));
@@ -179,7 +179,7 @@ function (_React$PureComponent) {
179
179
  return id !== item.id;
180
180
  }), item);
181
181
  } else {
182
- onChange(event, (0, _toConsumableArray2.default)(value).concat([item.id]), item);
182
+ onChange(event, [].concat((0, _toConsumableArray2.default)(value), [item.id]), item);
183
183
  }
184
184
  };
185
185
 
@@ -209,13 +209,13 @@ function (_React$PureComponent) {
209
209
  });
210
210
  } else {
211
211
  _this.setState({
212
- suggestions: (0, _toConsumableArray2.default)(hasAll ? [(0, _extends2.default)({
212
+ suggestions: [].concat((0, _toConsumableArray2.default)(hasAll ? [(0, _extends2.default)({
213
213
  id: '_all',
214
214
  label: translations.all
215
215
  }, iconAll && {
216
216
  type: 'icon',
217
217
  icon: iconAll
218
- })] : []).concat((0, _toConsumableArray2.default)(suggestions))
218
+ })] : []), (0, _toConsumableArray2.default)(suggestions))
219
219
  });
220
220
  }
221
221
  };
@@ -251,22 +251,22 @@ function (_React$PureComponent) {
251
251
  var search = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
252
252
  var loading = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
253
253
  // build item list
254
- var itemList = (0, _toConsumableArray2.default)(loading ? [{
254
+ var itemList = [].concat((0, _toConsumableArray2.default)(loading ? [{
255
255
  id: '_loading',
256
256
  type: 'loader',
257
257
  disabled: true,
258
258
  centered: true,
259
259
  hideCheckbox: true,
260
260
  label: 'loading'
261
- }] : []).concat((0, _toConsumableArray2.default)(search !== '' ? (0, _toConsumableArray2.default)(options.filter(function (item) {
261
+ }] : []), (0, _toConsumableArray2.default)(search !== '' ? (0, _toConsumableArray2.default)(options.filter(function (item) {
262
262
  return item.label && _this.props.filterFunc(item, search);
263
- })) : (0, _toConsumableArray2.default)(_this.props.hasAll ? [(0, _extends2.default)({
263
+ })) : [].concat((0, _toConsumableArray2.default)(_this.props.hasAll ? [(0, _extends2.default)({
264
264
  id: '_all',
265
265
  label: _this.props.translations.all
266
266
  }, _this.props.iconAll && {
267
267
  type: 'icon',
268
268
  icon: _this.props.iconAll
269
- })] : []).concat((0, _toConsumableArray2.default)(options))));
269
+ })] : []), (0, _toConsumableArray2.default)(options))));
270
270
  return {
271
271
  itemList: itemList
272
272
  };
@@ -71,7 +71,7 @@ var styles = function styles(theme) {
71
71
  display: 'block'
72
72
  },
73
73
  '&$inline': {
74
- maxHeight: 40,
74
+ minHeight: 40,
75
75
  '& $secondaryLabel': {
76
76
  display: 'inline-block'
77
77
  }
@@ -128,7 +128,7 @@ var styles = function styles(theme) {
128
128
  '& strong': {
129
129
  fontWeight: theme.typography.fontWeightMedium
130
130
  },
131
- display: 'inline-flex'
131
+ display: 'contents'
132
132
  }),
133
133
  listItemContentSelected: {},
134
134
  label: {
@@ -158,7 +158,6 @@ var styles = function styles(theme) {
158
158
  fontSize: 12,
159
159
  textOverflow: 'ellipsis',
160
160
  textAlign: 'right',
161
- padding: '4px 0px 4px 8px',
162
161
  alignSelf: 'center'
163
162
  }),
164
163
  img: {
@@ -172,7 +171,7 @@ var styles = function styles(theme) {
172
171
  verticalAlign: 'middle'
173
172
  },
174
173
  labelContent: {
175
- display: 'flex',
174
+ display: '-webkit-flex',
176
175
  alignItems: 'center',
177
176
  maxWidth: '85%',
178
177
  '&$labelWithoutSecondaryInline': {
@@ -190,9 +189,6 @@ var styles = function styles(theme) {
190
189
  },
191
190
  '&$infosWithoutSecondaryInline': {
192
191
  paddingLeft: 28
193
- },
194
- '&$infosWithSecondaryInline': {
195
- marginTop: -8
196
192
  }
197
193
  },
198
194
  infosInlineWithoutSecondary: {},
package/README.md CHANGED
@@ -226,7 +226,7 @@ npm install -g conventional-changelog-cli
226
226
  npm install -g cz-conventional-changelog
227
227
  ```
228
228
 
229
- 1. Changer la version dans packages/hipay-material-ui/package.json
229
+ 1. Changer la version dans package.json et dans packages/hipay-material-ui/package.json
230
230
  2. Générer le fichier HI-CHANGELOG.md : ```npm run changelog```
231
231
  3. Commiter la release : ```git ci -am "chore(release): VERSION DATE```
232
232
  4. Build : ```npm run build```
@@ -25,7 +25,7 @@ class CellNumeric extends React.PureComponent {
25
25
  let title = '';
26
26
 
27
27
  if (currency) {
28
- displayedValue = formatCurrencyAmount(value, view, locale, currency);
28
+ displayedValue = formatCurrencyAmount(value, view, locale, currency, precision);
29
29
  title = formatCurrencyAmount(value, 'l', locale, currency);
30
30
  } else {
31
31
  displayedValue = formatNumber(value, view, locale, precision);
@@ -169,7 +169,8 @@ class HiDatePicker extends React.Component {
169
169
  renderYearPickerOverlay(propsOverlay) {
170
170
  const yearPickerProps = {
171
171
  value: this.state.currentMonth,
172
- onChange: this.handleCurrentMonthChange
172
+ onChange: this.handleCurrentMonthChange,
173
+ disableFutureDays: this.props.disableFutureDays
173
174
  };
174
175
  return React.createElement(YearPickerOverlay, _extends({
175
176
  key: 'year-picker-overlay'
@@ -240,7 +241,10 @@ class HiDatePicker extends React.Component {
240
241
  const inputProps = _objectSpread({}, onReset && {
241
242
  onReset: this.handleReset
242
243
  }, props, {
243
- onChange: this.handleInputChange
244
+ onChange: this.handleInputChange,
245
+ HiInputProps: {
246
+ onSubmit: this.props.onSubmit
247
+ }
244
248
  });
245
249
 
246
250
  return React.createElement("div", {
@@ -338,6 +342,11 @@ HiDatePicker.propTypes = process.env.NODE_ENV !== "production" ? {
338
342
  */
339
343
  onReset: PropTypes.func,
340
344
 
345
+ /**
346
+ * Callback lorsque l'utilisateur tape sur "Entrée"
347
+ */
348
+ onSubmit: PropTypes.func,
349
+
341
350
  /**
342
351
  * Traductions
343
352
  */
@@ -171,6 +171,29 @@ class HiDateRangePicker extends React.Component {
171
171
  }));
172
172
  };
173
173
 
174
+ this.handleKeyDown = name => event => {
175
+ if (event.key === 'Tab' && !event.shiftKey) {
176
+ let nodeName = document.activeElement.nodeName;
177
+
178
+ if (this.props[name] && nodeName === 'INPUT' && document.activeElement.nextSibling.children.length > 0) {
179
+ document.activeElement.nextSibling.focus();
180
+ } else if (name === 'from') {
181
+ this.handleDayPickerBlur('from');
182
+ this.handleDayPickerFocus('to');
183
+ this.toInput.handleInputFocus();
184
+ setTimeout(() => {
185
+ document.getElementById(`${this.props.id}-to`).focus();
186
+ }, 1);
187
+ } else if (name === 'to') {
188
+ this.handleDayPickerBlur('to');
189
+ this.toInput.handleInputBlur(event);
190
+ setTimeout(() => {
191
+ document.activeElement.blur();
192
+ }, 1);
193
+ }
194
+ }
195
+ };
196
+
174
197
  this.openPanel = panel => {
175
198
  this.setState({
176
199
  openedPanel: panel
@@ -246,7 +269,7 @@ class HiDateRangePicker extends React.Component {
246
269
  const yearPickerProps = {
247
270
  value: this.state.currentMonth,
248
271
  onChange: this.handleCurrentMonthChange,
249
- disabledFutureDays: this.props.disableFutureDays
272
+ disableFutureDays: this.props.disableFutureDays
250
273
  };
251
274
  return React.createElement(YearPickerOverlay, _extends({
252
275
  key: `${name}-year-picker-overlay`
@@ -385,7 +408,10 @@ class HiDateRangePicker extends React.Component {
385
408
  }, {
386
409
  id: `${id}-from`,
387
410
  onChange: this.handleInputChange('from'),
388
- disabled
411
+ disabled,
412
+ HiInputProps: {
413
+ onSubmit: this.props.onSubmit
414
+ }
389
415
  });
390
416
 
391
417
  const toInputProps = _objectSpread({}, onReset && {
@@ -397,7 +423,10 @@ class HiDateRangePicker extends React.Component {
397
423
  }, {
398
424
  id: `${id}-to`,
399
425
  onChange: this.handleInputChange('to'),
400
- disabled
426
+ disabled,
427
+ HiInputProps: {
428
+ onSubmit: this.props.onSubmit
429
+ }
401
430
  });
402
431
 
403
432
  const toClass = classNames(classes.toInput, {
@@ -408,8 +437,8 @@ class HiDateRangePicker extends React.Component {
408
437
  className: classNames(classes.root, classes.rangePickerContainer)
409
438
  }, React.createElement("div", {
410
439
  className: classes.fromInput,
411
- onFocus: () => this.handleDayPickerFocus('from') // onBlur={() => this.handleDayPickerBlur('from')}
412
-
440
+ onFocus: () => this.handleDayPickerFocus('from'),
441
+ onKeyDown: this.handleKeyDown('from')
413
442
  }, React.createElement("div", null, React.createElement(DayPickerInput, {
414
443
  key: this.state.keyFrom,
415
444
  ref: el => {
@@ -429,7 +458,8 @@ class HiDateRangePicker extends React.Component {
429
458
  }))), React.createElement("div", {
430
459
  className: toClass,
431
460
  onFocus: () => this.handleDayPickerFocus('to'),
432
- onBlur: () => this.handleDayPickerBlur('to')
461
+ onBlur: () => this.handleDayPickerBlur('to'),
462
+ onKeyDown: this.handleKeyDown('to')
433
463
  }, React.createElement(DayPickerInput, {
434
464
  key: this.state.keyTo,
435
465
  ref: el => {
@@ -443,8 +473,7 @@ class HiDateRangePicker extends React.Component {
443
473
  inputProps: toInputProps,
444
474
  format: enableTime ? `${format} HH:mm` : format,
445
475
  formatDate: MomentLocaleUtils.formatDate,
446
- parseDate: MomentLocaleUtils.parseDate // onDayChange={(day) => this.handleDayChange('to', day)}
447
- ,
476
+ parseDate: MomentLocaleUtils.parseDate,
448
477
  placeholder: ''
449
478
  })));
450
479
 
@@ -597,6 +626,11 @@ HiDateRangePicker.propTypes = process.env.NODE_ENV !== "production" ? {
597
626
  */
598
627
  onReset: PropTypes.func,
599
628
 
629
+ /**
630
+ * Callback lorsque l'utilisateur tape sur "Entrée"
631
+ */
632
+ onSubmit: PropTypes.func,
633
+
600
634
  /**
601
635
  * Si true, le calendrier sera dans une div static plutot que dans une popper absolute
602
636
  */
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
3
  import React from 'react';
4
4
  import PropTypes from 'prop-types';
5
- import moment from 'moment';
5
+ import moment from 'moment-timezone';
6
6
  import { findDOMNode } from 'react-dom';
7
7
  import Grid from '@material-ui/core/Grid';
8
8
  import withStyles from '../styles/withStyles';
@@ -52,7 +52,7 @@ export function yearAndQuarter(format, date, t) {
52
52
  const indexM = split.findIndex(findM);
53
53
  return indexY < indexM ? date.format(`${split[indexY]}${s}[${t.short_quarter}]Q`) : date.format(`[${t.short_quarter}]Q${s}${split[indexY]}`);
54
54
  }
55
- export function buildDateRangeOptionByKey(key, t, format) {
55
+ export function buildDateRangeOptionByKey(key, t, format, timezoneName) {
56
56
  let from;
57
57
  let label;
58
58
  let info;
@@ -67,71 +67,71 @@ export function buildDateRangeOptionByKey(key, t, format) {
67
67
  switch (key) {
68
68
  case 'custom':
69
69
  label = t.custom_period;
70
- from = moment().subtract(15, 'day').startOf('day');
71
- to = moment().endOf('day');
70
+ from = moment().tz(timezoneName).subtract(15, 'day').startOf('day');
71
+ to = moment().tz(timezoneName).endOf('day');
72
72
  type = 'primary-highlight';
73
73
  break;
74
74
 
75
75
  case 'cd':
76
76
  label = t.today;
77
- from = moment().startOf('day');
78
- to = moment().endOf('day');
77
+ from = moment().tz(timezoneName).startOf('day');
78
+ to = moment().tz(timezoneName).endOf('day');
79
79
  info = `${from.format(format)}`;
80
80
  break;
81
81
 
82
82
  case 'pd':
83
83
  label = t.yesterday;
84
- from = moment().subtract(1, 'day').startOf('day');
85
- to = moment().subtract(1, 'day').endOf('day');
84
+ from = moment().tz(timezoneName).subtract(1, 'day').startOf('day');
85
+ to = moment().tz(timezoneName).subtract(1, 'day').endOf('day');
86
86
  info = `${from.format(format)}`;
87
87
  break;
88
88
 
89
89
  case 'cw':
90
90
  label = t.current_week;
91
- from = moment().startOf('week');
92
- to = moment();
91
+ from = moment().tz(timezoneName).startOf('week');
92
+ to = moment().tz(timezoneName);
93
93
  info = `${t.short_week}${from.format('w')}, \n ${from.format(format)} ${t.to_now}`;
94
94
  break;
95
95
 
96
96
  case 'pw':
97
97
  label = t.previous_week;
98
- from = moment().subtract(1, 'week').startOf('week');
99
- to = moment().subtract(1, 'week').endOf('week');
98
+ from = moment().tz(timezoneName).subtract(1, 'week').startOf('week');
99
+ to = moment().tz(timezoneName).subtract(1, 'week').endOf('week');
100
100
  info = `${t.short_week}${from.format('w')}, ${from.format(format)} ${t.to} ${to.format(format)}`;
101
101
  break;
102
102
 
103
103
  case 'cm':
104
104
  label = t.current_month;
105
- from = moment().startOf('month');
106
- to = moment();
105
+ from = moment().tz(timezoneName).startOf('month');
106
+ to = moment().tz(timezoneName);
107
107
  info = `${from.format(format)} ${t.to_now}, ${to.diff(from, 'days') + 1} ${t.days}`;
108
108
  break;
109
109
 
110
110
  case 'pm':
111
111
  label = t.previous_month;
112
- from = moment().subtract(1, 'month').startOf('month');
113
- to = moment().subtract(1, 'month').endOf('month');
112
+ from = moment().tz(timezoneName).subtract(1, 'month').startOf('month');
113
+ to = moment().tz(timezoneName).subtract(1, 'month').endOf('month');
114
114
  info = `${yearAndMonth(format, from)}, ${from.daysInMonth()} ${t.days}`;
115
115
  break;
116
116
 
117
117
  case 'cq':
118
118
  label = t.current_quarter;
119
- from = moment().startOf('quarter');
120
- to = moment();
119
+ from = moment().tz(timezoneName).startOf('quarter');
120
+ to = moment().tz(timezoneName);
121
121
  info = `${yearAndQuarter(format, from, t)}, ${from.format(format)} ${t.to_now}, ${to.diff(from, 'days') + 1} ${t.days}`;
122
122
  break;
123
123
 
124
124
  case 'pq':
125
125
  label = t.previous_quarter;
126
- from = moment().subtract(1, 'quarter').startOf('quarter');
127
- to = moment().subtract(1, 'quarter').endOf('quarter');
126
+ from = moment().tz(timezoneName).subtract(1, 'quarter').startOf('quarter');
127
+ to = moment().tz(timezoneName).subtract(1, 'quarter').endOf('quarter');
128
128
  info = `${yearAndQuarter(format, from, t)}, ${to.diff(from, 'days') + 1} ${t.days}`;
129
129
  break;
130
130
 
131
131
  case 'cy':
132
132
  label = t.current_year;
133
- from = moment().startOf('year');
134
- to = moment();
133
+ from = moment().tz(timezoneName).startOf('year');
134
+ to = moment().tz(timezoneName);
135
135
  info = `${from.format(format)} ${t.to_now}, ${to.diff(from, 'days') + 1} ${t.days}`;
136
136
  break;
137
137
 
@@ -190,8 +190,8 @@ class HiDateRangeSelector extends React.Component {
190
190
  const selectedOption = this.options.find(option => option.id === value);
191
191
 
192
192
  if (selectedOption) {
193
- this.props.onChange('from', selectedOption.from.toDate());
194
- this.props.onChange('to', selectedOption.to.toDate());
193
+ this.props.onChange('from', new Date(selectedOption.from.format('YYYY-MM-DD HH:mm:ss')));
194
+ this.props.onChange('to', new Date(selectedOption.to.format('YYYY-MM-DD HH:mm:ss')));
195
195
  this.props.onChange('fromError', false);
196
196
  this.props.onChange('toError', false);
197
197
  }
@@ -201,8 +201,7 @@ class HiDateRangeSelector extends React.Component {
201
201
  }
202
202
  };
203
203
 
204
- this.handleSelectChange = this.handleSelectChange.bind(this);
205
- this.options = props.availableOptionKeys.map(key => buildDateRangeOptionByKey(key, props.translations, props.format));
204
+ this.options = props.availableOptionKeys.map(key => buildDateRangeOptionByKey(key, props.translations, props.format, props.timezoneName));
206
205
  this.state = {
207
206
  selectedPreset: props.defaultPreset,
208
207
  containerWidth: 0
@@ -299,7 +298,8 @@ class HiDateRangeSelector extends React.Component {
299
298
  classes: {
300
299
  root: classes.dateSelect
301
300
  },
302
- staticPosition: staticPosition
301
+ staticPosition: staticPosition,
302
+ onSubmit: this.props.onSubmit
303
303
  }, selectProps))), React.createElement(Grid, {
304
304
  item: true,
305
305
  xs: 12,
@@ -341,6 +341,7 @@ HiDateRangeSelector.defaultProps = {
341
341
  format: 'YYYY-DD-MM',
342
342
  minimumDate: new Date(2013, 4, 1),
343
343
  // by default 1 May 2013
344
+ timezoneName: 'Europe/Paris',
344
345
  translations: {
345
346
  today: 'Today',
346
347
  hour: 'Hour',
@@ -459,6 +460,11 @@ HiDateRangeSelector.propTypes = process.env.NODE_ENV !== "production" ? {
459
460
  */
460
461
  onChange: PropTypes.func.isRequired,
461
462
 
463
+ /**
464
+ * Callback lorsque l'utilisateur tape sur "Entrée"
465
+ */
466
+ onSubmit: PropTypes.func,
467
+
462
468
  /**
463
469
  * true si champs obligatoire
464
470
  */
@@ -479,6 +485,11 @@ HiDateRangeSelector.propTypes = process.env.NODE_ENV !== "production" ? {
479
485
  */
480
486
  staticPosition: PropTypes.bool,
481
487
 
488
+ /**
489
+ * Timezone de l'utilisateur
490
+ */
491
+ timezoneName: PropTypes.string,
492
+
482
493
  /**
483
494
  * Date de fin sélectionnée
484
495
  */