@hipay/hipay-material-ui 2.0.0-beta.58 → 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 (48) hide show
  1. package/CHANGELOG.md +117 -0
  2. package/HiCell/CellNumeric.js +1 -1
  3. package/HiColoredLabel/HiColoredLabel.js +16 -4
  4. package/HiDatePicker/HiDatePicker.js +11 -2
  5. package/HiDatePicker/HiDateRangePicker.js +49 -8
  6. package/HiDatePicker/HiDateRangeSelector.js +39 -30
  7. package/HiDatePicker/Overlays/YearPickerOverlay.js +8 -3
  8. package/HiForm/HiFormControl.js +26 -11
  9. package/HiForm/HiFormLabel.js +3 -1
  10. package/HiForm/HiInput.js +33 -1
  11. package/HiForm/HiUpload.js +290 -45
  12. package/HiForm/HiUploadField.js +19 -51
  13. package/HiForm/HiUploadInput.js +18 -7
  14. package/HiSelect/HiSuggestSelect.js +3 -3
  15. package/HiSelectNew/HiDynamicSelect.js +3 -3
  16. package/HiSelectNew/HiNestedSelect.js +29 -15
  17. package/HiSelectNew/HiNestedSelectContent.js +29 -15
  18. package/HiSelectNew/HiSelect.js +23 -12
  19. package/HiSelectNew/HiSelectContent.js +23 -11
  20. package/HiSelectNew/HiSelectInput.js +4 -4
  21. package/HiSelectableList/HiSelectableListItem.js +8 -10
  22. package/README.md +1 -1
  23. package/es/HiCell/CellNumeric.js +1 -1
  24. package/es/HiColoredLabel/HiColoredLabel.js +21 -4
  25. package/es/HiDatePicker/HiDatePicker.js +11 -2
  26. package/es/HiDatePicker/HiDateRangePicker.js +42 -8
  27. package/es/HiDatePicker/HiDateRangeSelector.js +38 -27
  28. package/es/HiDatePicker/Overlays/YearPickerOverlay.js +8 -3
  29. package/es/HiForm/HiFormControl.js +27 -11
  30. package/es/HiForm/HiFormLabel.js +3 -1
  31. package/es/HiForm/HiInput.js +32 -1
  32. package/es/HiForm/HiUpload.js +276 -35
  33. package/es/HiForm/HiUploadField.js +19 -43
  34. package/es/HiForm/HiUploadInput.js +16 -7
  35. package/es/HiSelect/HiSuggestSelect.js +3 -3
  36. package/es/HiSelectNew/HiNestedSelect.js +17 -7
  37. package/es/HiSelectNew/HiNestedSelectContent.js +16 -6
  38. package/es/HiSelectNew/HiSelect.js +15 -3
  39. package/es/HiSelectNew/HiSelectContent.js +11 -2
  40. package/es/HiSelectNew/HiSelectInput.js +4 -3
  41. package/es/HiSelectableList/HiSelectableListItem.js +8 -10
  42. package/es/utils/helpers.js +6 -5
  43. package/index.es.js +1 -1
  44. package/index.js +1 -1
  45. package/package.json +3 -2
  46. package/umd/hipay-material-ui.development.js +4632 -1923
  47. package/umd/hipay-material-ui.production.min.js +2 -2
  48. package/utils/helpers.js +6 -4
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports.default = exports.styles = void 0;
8
+ exports.default = exports.filterValue = exports.styles = void 0;
9
9
 
10
10
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
11
11
 
@@ -70,6 +70,12 @@ var styles = function styles(theme) {
70
70
  })
71
71
  };
72
72
  };
73
+
74
+ exports.styles = styles;
75
+
76
+ var filterValue = function filterValue(item, searchValue) {
77
+ return searchValue === '' || (0, _helpers.foldAccents)(item.label.toString().toLowerCase()).search((0, _helpers.foldAccents)(searchValue.toLowerCase())) !== -1;
78
+ };
73
79
  /**
74
80
  *
75
81
  * Utilisé pour tous types de selects dans les formulaires.
@@ -86,7 +92,7 @@ var styles = function styles(theme) {
86
92
  */
87
93
 
88
94
 
89
- exports.styles = styles;
95
+ exports.filterValue = filterValue;
90
96
 
91
97
  var HiSelectContent =
92
98
  /*#__PURE__*/
@@ -173,7 +179,7 @@ function (_React$PureComponent) {
173
179
  return id !== item.id;
174
180
  }), item);
175
181
  } else {
176
- onChange(event, (0, _toConsumableArray2.default)(value).concat([item.id]), item);
182
+ onChange(event, [].concat((0, _toConsumableArray2.default)(value), [item.id]), item);
177
183
  }
178
184
  };
179
185
 
@@ -203,13 +209,13 @@ function (_React$PureComponent) {
203
209
  });
204
210
  } else {
205
211
  _this.setState({
206
- suggestions: (0, _toConsumableArray2.default)(hasAll ? [(0, _extends2.default)({
212
+ suggestions: [].concat((0, _toConsumableArray2.default)(hasAll ? [(0, _extends2.default)({
207
213
  id: '_all',
208
214
  label: translations.all
209
215
  }, iconAll && {
210
216
  type: 'icon',
211
217
  icon: iconAll
212
- })] : []).concat((0, _toConsumableArray2.default)(suggestions))
218
+ })] : []), (0, _toConsumableArray2.default)(suggestions))
213
219
  });
214
220
  }
215
221
  };
@@ -245,22 +251,22 @@ function (_React$PureComponent) {
245
251
  var search = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
246
252
  var loading = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
247
253
  // build item list
248
- var itemList = (0, _toConsumableArray2.default)(loading ? [{
254
+ var itemList = [].concat((0, _toConsumableArray2.default)(loading ? [{
249
255
  id: '_loading',
250
256
  type: 'loader',
251
257
  disabled: true,
252
258
  centered: true,
253
259
  hideCheckbox: true,
254
260
  label: 'loading'
255
- }] : []).concat((0, _toConsumableArray2.default)(search !== '' ? (0, _toConsumableArray2.default)(options.filter(function (item) {
256
- return item.label && (0, _helpers.foldAccents)(item.label.toString().toLowerCase()).search((0, _helpers.foldAccents)(search.toLowerCase())) !== -1;
257
- })) : (0, _toConsumableArray2.default)(_this.props.hasAll ? [(0, _extends2.default)({
261
+ }] : []), (0, _toConsumableArray2.default)(search !== '' ? (0, _toConsumableArray2.default)(options.filter(function (item) {
262
+ return item.label && _this.props.filterFunc(item, search);
263
+ })) : [].concat((0, _toConsumableArray2.default)(_this.props.hasAll ? [(0, _extends2.default)({
258
264
  id: '_all',
259
265
  label: _this.props.translations.all
260
266
  }, _this.props.iconAll && {
261
267
  type: 'icon',
262
268
  icon: _this.props.iconAll
263
- })] : []).concat((0, _toConsumableArray2.default)(options))));
269
+ })] : []), (0, _toConsumableArray2.default)(options))));
264
270
  return {
265
271
  itemList: itemList
266
272
  };
@@ -395,7 +401,8 @@ HiSelectContent.defaultProps = {
395
401
  n_children: '%s items',
396
402
  one_child: '%s item'
397
403
  },
398
- type: 'text'
404
+ type: 'text',
405
+ filterFunc: filterValue
399
406
  };
400
407
  HiSelectContent.propTypes = process.env.NODE_ENV !== "production" ? {
401
408
  autoHeight: _propTypes.default.bool,
@@ -420,6 +427,11 @@ HiSelectContent.propTypes = process.env.NODE_ENV !== "production" ? {
420
427
  */
421
428
  fallbackImage: _propTypes.default.string,
422
429
 
430
+ /*
431
+ * Fonction de filtrage custom
432
+ */
433
+ filterFunc: _propTypes.default.func,
434
+
423
435
  /**
424
436
  * Affiche l'élément 'All'
425
437
  */
@@ -172,8 +172,6 @@ function (_React$PureComponent) {
172
172
 
173
173
  if (_this.props.onKeyDown) {
174
174
  _this.props.onKeyDown(event);
175
-
176
- event.preventDefault();
177
175
  } else if (key === 'down' || key === 'up') {
178
176
  _this.props.onClick();
179
177
  } else if (key === 'enter' && _this.props.onSubmit) {
@@ -215,9 +213,11 @@ function (_React$PureComponent) {
215
213
  _this.handleBlur = function (event) {
216
214
  if ((!_this.input || !_this.input.contains(event.relatedTarget)) && _this.props.onBlur) {
217
215
  _this.props.onBlur(event);
218
- } else if (_this.input && (!_this.resetIcon || !_this.resetIcon.contains(event.relatedTarget))) {
219
- _this.input.focus();
220
216
  }
217
+ /* else if (this.input && (!this.resetIcon || !this.resetIcon.contains(event.relatedTarget))) {
218
+ this.input.focus();
219
+ }*/
220
+
221
221
  };
222
222
 
223
223
  _this.ref = function (el) {
@@ -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
  }
@@ -122,12 +122,13 @@ var styles = function styles(theme) {
122
122
  minWidth: '50%',
123
123
  padding: '5px 0',
124
124
  '&$listItemContentSelected': {
125
- marginBottom: -3,
125
+ marginBottom: 1,
126
126
  marginLeft: -4
127
127
  },
128
128
  '& strong': {
129
129
  fontWeight: theme.typography.fontWeightMedium
130
- }
130
+ },
131
+ display: 'contents'
131
132
  }),
132
133
  listItemContentSelected: {},
133
134
  label: {
@@ -157,7 +158,6 @@ var styles = function styles(theme) {
157
158
  fontSize: 12,
158
159
  textOverflow: 'ellipsis',
159
160
  textAlign: 'right',
160
- padding: '4px 0px 4px 8px',
161
161
  alignSelf: 'center'
162
162
  }),
163
163
  img: {
@@ -171,9 +171,9 @@ var styles = function styles(theme) {
171
171
  verticalAlign: 'middle'
172
172
  },
173
173
  labelContent: {
174
- display: 'flex',
174
+ display: '-webkit-flex',
175
175
  alignItems: 'center',
176
- maxWidth: '70%',
176
+ maxWidth: '85%',
177
177
  '&$labelWithoutSecondaryInline': {
178
178
  maxWidth: '100%'
179
179
  }
@@ -189,9 +189,6 @@ var styles = function styles(theme) {
189
189
  },
190
190
  '&$infosWithoutSecondaryInline': {
191
191
  paddingLeft: 28
192
- },
193
- '&$infosWithSecondaryInline': {
194
- marginTop: -8
195
192
  }
196
193
  },
197
194
  infosInlineWithoutSecondary: {},
@@ -278,7 +275,8 @@ function (_React$PureComponent) {
278
275
  }
279
276
 
280
277
  return _react.default.createElement("div", {
281
- className: classes.label
278
+ className: classes.label,
279
+ title: label
282
280
  }, label);
283
281
  }
284
282
  }, {
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);
@@ -8,7 +8,7 @@ import withStyles from '../styles/withStyles';
8
8
  import { capitalize } from '../utils/helpers';
9
9
  import { fade } from '../styles/colorManipulator';
10
10
  export const styles = theme => ({
11
- root: _objectSpread({}, theme.typography.b3, {
11
+ root: {
12
12
  display: 'inline-block',
13
13
  alignItems: 'baseline',
14
14
  maxWidth: '100%',
@@ -18,7 +18,12 @@ export const styles = theme => ({
18
18
  overflow: 'hidden',
19
19
  whiteSpace: 'nowrap',
20
20
  lineHeight: 1
21
- }),
21
+ },
22
+ body1: _objectSpread({}, theme.typography.b1),
23
+ body2: _objectSpread({}, theme.typography.b2),
24
+ body3: _objectSpread({}, theme.typography.b3),
25
+ body4: _objectSpread({}, theme.typography.b4),
26
+ body5: _objectSpread({}, theme.typography.b5),
22
27
  color: {
23
28
  fontWeight: 400
24
29
  },
@@ -111,6 +116,7 @@ function HiColoredLabel(props) {
111
116
  const {
112
117
  classes,
113
118
  className,
119
+ fontSize,
114
120
  label,
115
121
  color,
116
122
  active,
@@ -119,7 +125,7 @@ function HiColoredLabel(props) {
119
125
  style,
120
126
  theme
121
127
  } = props,
122
- other = _objectWithoutProperties(props, ["classes", "className", "label", "color", "active", "outlined", "fontWeight", "style", "theme"]);
128
+ other = _objectWithoutProperties(props, ["classes", "className", "fontSize", "label", "color", "active", "outlined", "fontWeight", "style", "theme"]);
123
129
 
124
130
  const isHiColor = ['primary', 'secondary', 'positive', 'negative', 'middle', 'neutral'].includes(color);
125
131
  const isHexColor = !isHiColor && /(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(color);
@@ -129,7 +135,12 @@ function HiColoredLabel(props) {
129
135
  [classes.activeColor]: active,
130
136
  [classes.outlined]: outlined,
131
137
  [classes[`activeColor${capitalize(color)}`]]: active && isHiColor,
132
- [classes[`color${capitalize(color)}`]]: !active && isHiColor
138
+ [classes[`color${capitalize(color)}`]]: !active && isHiColor,
139
+ [classes.body1]: fontSize >= 15,
140
+ [classes.body2]: fontSize === 14,
141
+ [classes.body3]: fontSize === 13,
142
+ [classes.body4]: fontSize === 12,
143
+ [classes.body5]: fontSize <= 11
133
144
  }, className),
134
145
  style: _objectSpread({}, style, isHexColor && {
135
146
  backgroundColor: active ? color : fade(color, 0.08),
@@ -162,6 +173,11 @@ HiColoredLabel.propTypes = process.env.NODE_ENV !== "production" ? {
162
173
  */
163
174
  color: PropTypes.string,
164
175
 
176
+ /**
177
+ * Taille du text
178
+ */
179
+ fontSize: PropTypes.number,
180
+
165
181
  /**
166
182
  * Graisse du text
167
183
  */
@@ -180,6 +196,7 @@ HiColoredLabel.propTypes = process.env.NODE_ENV !== "production" ? {
180
196
  HiColoredLabel.defaultProps = {
181
197
  active: false,
182
198
  color: 'primary',
199
+ fontSize: 15,
183
200
  outlined: false
184
201
  };
185
202
  export default withStyles(styles, {
@@ -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
  */
@@ -10,8 +10,15 @@ class YearPickerOverlay extends React.Component {
10
10
  super(props);
11
11
  this.years = [];
12
12
  this.handleYearClick = this.handleYearClick.bind(this);
13
+ let minDate = props.minimumDate;
14
+
15
+ if (!minDate) {
16
+ let today = new Date();
17
+ minDate = new Date(today.getFullYear() - 5, today.getMonth(), today.getDate()); // by default 5 years from now
18
+ }
19
+
13
20
  const currentYear = new Date().getFullYear();
14
- const minimumYear = props.minimumDate.getFullYear();
21
+ const minimumYear = minDate.getFullYear();
15
22
  this.years = [currentYear]; // get years from minimum date to now
16
23
 
17
24
  if (!props.disablePastDays && currentYear > minimumYear) {
@@ -55,8 +62,6 @@ class YearPickerOverlay extends React.Component {
55
62
  }
56
63
 
57
64
  YearPickerOverlay.defaultProps = {
58
- minimumDate: new Date(2013, 4, 1),
59
- // by default 1 May 2013
60
65
  translations: {
61
66
  year: 'Year'
62
67
  }