@hipay/hipay-material-ui 2.0.0-beta.52 → 2.0.0-beta.54

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. package/HiCell/CellSentinel.js +33 -109
  2. package/HiCell/CellSentinelScore.js +100 -0
  3. package/HiChip/HiChip.js +11 -4
  4. package/HiColoredLabel/HiColoredLabel.js +14 -4
  5. package/HiDatePicker/HiDatePicker.js +1 -1
  6. package/HiDatePicker/HiDateRangePicker.js +339 -420
  7. package/HiDatePicker/HiDateRangeSelector.js +81 -61
  8. package/HiDatePicker/NavBar.js +2 -1
  9. package/HiDatePicker/Overlays/TimePickerOverlay.js +1 -1
  10. package/HiDatePicker/Overlays/YearPickerOverlay.js +3 -3
  11. package/HiForm/HiFormControl.js +5 -4
  12. package/HiPin/HiPin.js +1 -1
  13. package/HiSelectNew/HiSelect.js +4 -1
  14. package/HiSelectableList/HiSelectableListItem.js +9 -1
  15. package/HiSwitch/HiSwitch.js +2 -1
  16. package/HiTable/HiCellBuilder.js +14 -7
  17. package/HiTable/constants.js +7 -5
  18. package/es/HiCell/CellSentinel.js +32 -108
  19. package/es/HiCell/CellSentinelScore.js +60 -0
  20. package/es/HiChip/HiChip.js +11 -4
  21. package/es/HiColoredLabel/HiColoredLabel.js +14 -3
  22. package/es/HiDatePicker/HiDatePicker.js +1 -1
  23. package/es/HiDatePicker/HiDateRangePicker.js +304 -364
  24. package/es/HiDatePicker/HiDateRangeSelector.js +71 -55
  25. package/es/HiDatePicker/NavBar.js +2 -1
  26. package/es/HiDatePicker/Overlays/TimePickerOverlay.js +1 -1
  27. package/es/HiDatePicker/Overlays/YearPickerOverlay.js +3 -3
  28. package/es/HiForm/HiFormControl.js +5 -4
  29. package/es/HiPin/HiPin.js +1 -1
  30. package/es/HiSelectNew/HiSelect.js +4 -1
  31. package/es/HiSelectableList/HiSelectableListItem.js +9 -1
  32. package/es/HiSwitch/HiSwitch.js +2 -1
  33. package/es/HiTable/HiCellBuilder.js +13 -7
  34. package/es/HiTable/constants.js +8 -1
  35. package/es/styles/createPalette.js +3 -3
  36. package/index.es.js +1 -1
  37. package/index.js +1 -1
  38. package/package.json +3 -2
  39. package/styles/createPalette.js +3 -3
  40. package/umd/hipay-material-ui.development.js +919 -1136
  41. package/umd/hipay-material-ui.production.min.js +2 -2
@@ -1,13 +1,13 @@
1
- /** @license HiPay-Material-UI v2.0.0-beta.52
1
+ /** @license HiPay-Material-UI v2.0.0-beta.53
2
2
  *
3
3
  * This source code is licensed under the MIT license found in the
4
4
  * LICENSE file in the root directory of this source tree.
5
5
  */
6
6
  (function (global, factory) {
7
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('react-dom'), require('@hipay/hipay-material-ui/HiCell/CellAddress'), require('@hipay/hipay-material-ui/HiCell/CellDate'), require('@hipay/hipay-material-ui/HiCell/CellIcon'), require('@hipay/hipay-material-ui/HiCell/CellImage'), require('@hipay/hipay-material-ui/HiCell/CellNumeric'), require('@hipay/hipay-material-ui/HiCell/CellSentinel'), require('@hipay/hipay-material-ui/HiCell/CellText'), require('@hipay/hipay-material-ui/HiCell/CellRate'), require('@hipay/hipay-material-ui/HiCell/CellPinToAction')) :
8
- typeof define === 'function' && define.amd ? define(['exports', 'react', 'react-dom', '@hipay/hipay-material-ui/HiCell/CellAddress', '@hipay/hipay-material-ui/HiCell/CellDate', '@hipay/hipay-material-ui/HiCell/CellIcon', '@hipay/hipay-material-ui/HiCell/CellImage', '@hipay/hipay-material-ui/HiCell/CellNumeric', '@hipay/hipay-material-ui/HiCell/CellSentinel', '@hipay/hipay-material-ui/HiCell/CellText', '@hipay/hipay-material-ui/HiCell/CellRate', '@hipay/hipay-material-ui/HiCell/CellPinToAction'], factory) :
9
- (factory((global['hipay-material-ui'] = {}),global.React,global.ReactDOM,global.CellAddress,global.CellDate,global.CellIcon,global.CellImage,global.CellNumeric,global.CellSentinel,global.CellText,global.CellRate,global.CellPinToAction));
10
- }(this, (function (exports,React,require$$11,CellAddress,CellDate,CellIcon,CellImage,CellNumeric,CellSentinel,CellText,CellRate,CellPinToAction) { 'use strict';
7
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('react-dom'), require('@hipay/hipay-material-ui/HiCell/CellAddress'), require('@hipay/hipay-material-ui/HiCell/CellDate'), require('@hipay/hipay-material-ui/HiCell/CellIcon'), require('@hipay/hipay-material-ui/HiCell/CellImage'), require('@hipay/hipay-material-ui/HiCell/CellNumeric'), require('@hipay/hipay-material-ui/HiCell/CellSentinel'), require('@hipay/hipay-material-ui/HiCell/CellSentinelScore'), require('@hipay/hipay-material-ui/HiCell/CellText'), require('@hipay/hipay-material-ui/HiCell/CellRate'), require('@hipay/hipay-material-ui/HiCell/CellPinToAction')) :
8
+ typeof define === 'function' && define.amd ? define(['exports', 'react', 'react-dom', '@hipay/hipay-material-ui/HiCell/CellAddress', '@hipay/hipay-material-ui/HiCell/CellDate', '@hipay/hipay-material-ui/HiCell/CellIcon', '@hipay/hipay-material-ui/HiCell/CellImage', '@hipay/hipay-material-ui/HiCell/CellNumeric', '@hipay/hipay-material-ui/HiCell/CellSentinel', '@hipay/hipay-material-ui/HiCell/CellSentinelScore', '@hipay/hipay-material-ui/HiCell/CellText', '@hipay/hipay-material-ui/HiCell/CellRate', '@hipay/hipay-material-ui/HiCell/CellPinToAction'], factory) :
9
+ (factory((global['hipay-material-ui'] = {}),global.React,global.ReactDOM,global.CellAddress,global.CellDate,global.CellIcon,global.CellImage,global.CellNumeric,global.CellSentinel,global.CellSentinelScore,global.CellText,global.CellRate,global.CellPinToAction));
10
+ }(this, (function (exports,React,require$$11,CellAddress,CellDate,CellIcon,CellImage,CellNumeric,CellSentinel,CellSentinelScore,CellText,CellRate,CellPinToAction) { 'use strict';
11
11
 
12
12
  var React__default = 'default' in React ? React['default'] : React;
13
13
  var require$$11__default = 'default' in require$$11 ? require$$11['default'] : require$$11;
@@ -17,6 +17,7 @@
17
17
  CellImage = CellImage && CellImage.hasOwnProperty('default') ? CellImage['default'] : CellImage;
18
18
  CellNumeric = CellNumeric && CellNumeric.hasOwnProperty('default') ? CellNumeric['default'] : CellNumeric;
19
19
  CellSentinel = CellSentinel && CellSentinel.hasOwnProperty('default') ? CellSentinel['default'] : CellSentinel;
20
+ CellSentinelScore = CellSentinelScore && CellSentinelScore.hasOwnProperty('default') ? CellSentinelScore['default'] : CellSentinelScore;
20
21
  CellText = CellText && CellText.hasOwnProperty('default') ? CellText['default'] : CellText;
21
22
  CellRate = CellRate && CellRate.hasOwnProperty('default') ? CellRate['default'] : CellRate;
22
23
  CellPinToAction = CellPinToAction && CellPinToAction.hasOwnProperty('default') ? CellPinToAction['default'] : CellPinToAction;
@@ -1072,7 +1073,7 @@
1072
1073
  } : _palette$primary,
1073
1074
  _palette$secondary = palette.secondary,
1074
1075
  secondary = _palette$secondary === void 0 ? {
1075
- light: '#ffcf21',
1076
+ light: '#ffd94f',
1076
1077
  main: '#ffcf21',
1077
1078
  dark: '#E9BE30',
1078
1079
  contrastText: '#FFFFFF'
@@ -1121,7 +1122,7 @@
1121
1122
  _palette$type = palette.type,
1122
1123
  type = _palette$type === void 0 ? 'light' : _palette$type,
1123
1124
  _palette$contrastThre = palette.contrastThreshold,
1124
- contrastThreshold = _palette$contrastThre === void 0 ? 2.9 : _palette$contrastThre,
1125
+ contrastThreshold = _palette$contrastThre === void 0 ? 2.2 : _palette$contrastThre,
1125
1126
  _palette$tonalOffset = palette.tonalOffset,
1126
1127
  tonalOffset = _palette$tonalOffset === void 0 ? 0.2 : _palette$tonalOffset,
1127
1128
  _palette$context = palette.context,
@@ -1136,7 +1137,7 @@
1136
1137
 
1137
1138
  {
1138
1139
  var contrast = getContrastRatio(background, contrastText);
1139
- warning_1(contrast >= 3, ["Material-UI: the contrast ratio of ".concat(contrast, ":1 for ").concat(contrastText, " on ").concat(background), 'falls below the WACG recommended absolute minimum contrast ratio of 3:1.', 'https://www.w3.org/TR/2008/REC-WCAG20-20081211/#visual-audio-contrast-contrast'].join('\n'));
1140
+ warning_1(contrast >= 2.2, ["Material-UI: the contrast ratio of ".concat(contrast, ":1 for ").concat(contrastText, " on ").concat(background), 'falls below the WACG recommended absolute minimum contrast ratio of 3:1.', 'https://www.w3.org/TR/2008/REC-WCAG20-20081211/#visual-audio-contrast-contrast'].join('\n'));
1140
1141
  }
1141
1142
 
1142
1143
  return contrastText;
@@ -15058,25 +15059,6 @@
15058
15059
  function escapeHTML(unsafeStr) {
15059
15060
  return unsafeStr.replace(/<br\/?>/g, '[br]').replace(/<strong>/g, '[[').replace(/<\/?strong>/g, ']]').replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/'/g, '&#39;').replace(/\[\[/g, '<strong>').replace(/\]\]/g, '</strong>').replace(/\[br\]/g, '<br>');
15060
15061
  }
15061
- /**
15062
- * Remove duplicate items from array useful after concat arrays
15063
- *
15064
- * arrayUnique(array1.concat(array2))
15065
- *
15066
- * @param array
15067
- */
15068
-
15069
- function arrayUnique(array) {
15070
- var a = toConsumableArray(array);
15071
-
15072
- for (var i = 0; i < a.length; i + 1) {
15073
- for (var j = i + 1; j < a.length; j + 1) {
15074
- if (a[i] === a[j]) a.splice(j - 1, 1);
15075
- }
15076
- }
15077
-
15078
- return a;
15079
- }
15080
15062
  /**
15081
15063
  * Retourne l'item selectionnable suivant.
15082
15064
  * @param node
@@ -66296,7 +66278,7 @@
66296
66278
  position: 'relative',
66297
66279
  cursor: 'pointer',
66298
66280
  '&:hover, &:focus': {
66299
- color: theme.palette.primary.main
66281
+ color: theme.palette.neutral.dark
66300
66282
  }
66301
66283
  },
66302
66284
  label: {
@@ -66322,7 +66304,8 @@
66322
66304
  '&:hover, &:focus': {
66323
66305
  backgroundColor: theme.palette.primary.main,
66324
66306
  color: theme.palette.grey[300]
66325
- }
66307
+ },
66308
+ position: 'relative'
66326
66309
  },
66327
66310
  badge: {
66328
66311
  height: 16,
@@ -66342,7 +66325,7 @@
66342
66325
  function HiChip(props) {
66343
66326
  var _classNames;
66344
66327
 
66345
- var label = props.label,
66328
+ var className = props.className,
66346
66329
  classes = props.classes,
66347
66330
  fallbackImage = props.fallbackImage,
66348
66331
  icon = props.icon,
@@ -66350,6 +66333,7 @@
66350
66333
  iconSize = _props$iconSize === void 0 ? 20 : _props$iconSize,
66351
66334
  id = props.id,
66352
66335
  img = props.img,
66336
+ label = props.label,
66353
66337
  onPrevious = props.onPrevious,
66354
66338
  onNext = props.onNext,
66355
66339
  onDelete = props.onDelete,
@@ -66363,7 +66347,7 @@
66363
66347
  titlePrevious = props.titlePrevious;
66364
66348
  return React__default.createElement("div", {
66365
66349
  id: id,
66366
- className: classnames(classes.root, (_classNames = {}, defineProperty(_classNames, classes.leftNavigation, onPrevious), defineProperty(_classNames, classes.rightNavigation, onNext), defineProperty(_classNames, classes.deletable, onDelete), defineProperty(_classNames, classes.leftIcon, icon), _classNames)),
66350
+ className: classnames(classes.root, className, (_classNames = {}, defineProperty(_classNames, classes.leftNavigation, onPrevious), defineProperty(_classNames, classes.rightNavigation, onNext), defineProperty(_classNames, classes.deletable, onDelete), defineProperty(_classNames, classes.leftIcon, icon), _classNames)),
66367
66351
  title: title$$1
66368
66352
  }, icon && React__default.createElement(HiIcon$1, {
66369
66353
  className: classnames(classes.icon, defineProperty({}, classes.iconClickable, onIconClick)),
@@ -66432,6 +66416,11 @@
66432
66416
  */
66433
66417
  classes: propTypes.object,
66434
66418
 
66419
+ /**
66420
+ * Surcharge les classes du composant
66421
+ */
66422
+ className: propTypes.object,
66423
+
66435
66424
  /**
66436
66425
  * Chemin vers l'image à afficher par défaut si une image n'est pas trouvée
66437
66426
  */
@@ -73698,6 +73687,7 @@
73698
73687
  position: 'absolute',
73699
73688
  right: 5,
73700
73689
  cursor: 'pointer',
73690
+ zIndex: 1,
73701
73691
  top: '-5px',
73702
73692
  '&$iconButtonError': {
73703
73693
  color: theme.palette.negative.main
@@ -73882,7 +73872,7 @@
73882
73872
  required: required,
73883
73873
  disabled: disabled,
73884
73874
  focused: !disabled && (focused || hovered)
73885
- }, InputLabelProps), error && React__default.createElement(HiIconButton$1, {
73875
+ }, InputLabelProps), error && errorText && React__default.createElement(HiIconButton$1, {
73886
73876
  className: classnames(classes.iconButton, classes.iconButtonError),
73887
73877
  onClick: this.handleHelperClick,
73888
73878
  onKeyDown: this.handleKeyDown
@@ -73915,8 +73905,8 @@
73915
73905
  required: true,
73916
73906
  disabled: false,
73917
73907
  error: false,
73918
- errorText: '',
73919
- helperText: '',
73908
+ errorText: undefined,
73909
+ helperText: undefined,
73920
73910
  helperIcon: false,
73921
73911
  multiline: false,
73922
73912
  nbChars: 0,
@@ -73951,7 +73941,7 @@
73951
73941
  /**
73952
73942
  * Texte de l'erreur
73953
73943
  */
73954
- errorText: propTypes.string,
73944
+ errorText: propTypes.oneOfType([propTypes.string, propTypes.bool]),
73955
73945
 
73956
73946
  /**
73957
73947
  * Propriétés appliquées au composant FormHelperText
@@ -74487,7 +74477,8 @@
74487
74477
  display: 'inline-flex',
74488
74478
  width: 62,
74489
74479
  position: 'relative',
74490
- flexShrink: 0
74480
+ flexShrink: 0,
74481
+ zIndex: 0
74491
74482
  },
74492
74483
  bar: {
74493
74484
  borderRadius: 7,
@@ -79931,7 +79922,7 @@
79931
79922
 
79932
79923
  var TableSortLabel$2 = unwrapExports(TableSortLabel$1);
79933
79924
 
79934
- var _TYPE_ACCOUNT, _TYPE_ACCOUNT_NUMBER, _TYPE_ADDRESS, _TYPE_CHECKBOX, _TYPE_COUNTRY, _TYPE_DATE, _TYPE_ICON, _TYPE_IMAGE, _TYPE_NUMERIC, _TYPE_RATE, _TYPE_SENTINEL, _TYPE_STATUS, _TYPE_TEXT, _TYPE_THIRD_PARTY_SEC, _DEFAULT_WIDTHS, _DEFAULT_VIEWS, _DEFAULT_PADDING;
79925
+ var _TYPE_ACCOUNT, _TYPE_ACCOUNT_NUMBER, _TYPE_ADDRESS, _TYPE_CHECKBOX, _TYPE_COUNTRY, _TYPE_DATE, _TYPE_ICON, _TYPE_IMAGE, _TYPE_NUMERIC, _TYPE_RATE, _TYPE_SENTINEL, _TYPE_SENTINEL_SCORE, _TYPE_STATUS, _TYPE_TEXT, _TYPE_THIRD_PARTY_SEC, _DEFAULT_WIDTHS, _DEFAULT_VIEWS, _DEFAULT_PADDING;
79935
79926
  /**
79936
79927
  * Cell height (px)
79937
79928
  */
@@ -79955,6 +79946,7 @@
79955
79946
  var TYPE_NUMERIC = 'numeric';
79956
79947
  var TYPE_RATE = 'rate';
79957
79948
  var TYPE_SENTINEL = 'sentinel';
79949
+ var TYPE_SENTINEL_SCORE = 'sentinel_score';
79958
79950
  var TYPE_STATUS = 'status';
79959
79951
  var TYPE_COUNTRY = 'country';
79960
79952
  var TYPE_TEXT = 'text';
@@ -79974,13 +79966,13 @@
79974
79966
  * @type {{}}
79975
79967
  */
79976
79968
 
79977
- var DEFAULT_WIDTHS = (_DEFAULT_WIDTHS = {}, defineProperty(_DEFAULT_WIDTHS, TYPE_ACCOUNT, (_TYPE_ACCOUNT = {}, defineProperty(_TYPE_ACCOUNT, VIEWS.LARGE, 160), defineProperty(_TYPE_ACCOUNT, VIEWS.MEDIUM, 120), defineProperty(_TYPE_ACCOUNT, VIEWS.SMALL, 80), _TYPE_ACCOUNT)), defineProperty(_DEFAULT_WIDTHS, TYPE_ACCOUNT_NUMBER, (_TYPE_ACCOUNT_NUMBER = {}, defineProperty(_TYPE_ACCOUNT_NUMBER, VIEWS.LARGE, 100), defineProperty(_TYPE_ACCOUNT_NUMBER, VIEWS.MEDIUM, 80), defineProperty(_TYPE_ACCOUNT_NUMBER, VIEWS.SMALL, 60), _TYPE_ACCOUNT_NUMBER)), defineProperty(_DEFAULT_WIDTHS, TYPE_ADDRESS, (_TYPE_ADDRESS = {}, defineProperty(_TYPE_ADDRESS, VIEWS.LARGE, 120), defineProperty(_TYPE_ADDRESS, VIEWS.MEDIUM, 100), defineProperty(_TYPE_ADDRESS, VIEWS.SMALL, 80), _TYPE_ADDRESS)), defineProperty(_DEFAULT_WIDTHS, TYPE_CHECKBOX, (_TYPE_CHECKBOX = {}, defineProperty(_TYPE_CHECKBOX, VIEWS.LARGE, 40), defineProperty(_TYPE_CHECKBOX, VIEWS.MEDIUM, 40), defineProperty(_TYPE_CHECKBOX, VIEWS.SMALL, 40), _TYPE_CHECKBOX)), defineProperty(_DEFAULT_WIDTHS, TYPE_COUNTRY, (_TYPE_COUNTRY = {}, defineProperty(_TYPE_COUNTRY, VIEWS.LARGE, 120), defineProperty(_TYPE_COUNTRY, VIEWS.MEDIUM, 80), defineProperty(_TYPE_COUNTRY, VIEWS.SMALL, 40), _TYPE_COUNTRY)), defineProperty(_DEFAULT_WIDTHS, TYPE_DATE, (_TYPE_DATE = {}, defineProperty(_TYPE_DATE, VIEWS.LARGE, 220), defineProperty(_TYPE_DATE, VIEWS.MEDIUM, 140), defineProperty(_TYPE_DATE, VIEWS.SMALL, 120), _TYPE_DATE)), defineProperty(_DEFAULT_WIDTHS, TYPE_ICON, (_TYPE_ICON = {}, defineProperty(_TYPE_ICON, VIEWS.LARGE, 140), defineProperty(_TYPE_ICON, VIEWS.MEDIUM, 100), defineProperty(_TYPE_ICON, VIEWS.SMALL, 60), _TYPE_ICON)), defineProperty(_DEFAULT_WIDTHS, TYPE_IMAGE, (_TYPE_IMAGE = {}, defineProperty(_TYPE_IMAGE, VIEWS.LARGE, 140), defineProperty(_TYPE_IMAGE, VIEWS.MEDIUM, 100), defineProperty(_TYPE_IMAGE, VIEWS.SMALL, 60), _TYPE_IMAGE)), defineProperty(_DEFAULT_WIDTHS, TYPE_NUMERIC, (_TYPE_NUMERIC = {}, defineProperty(_TYPE_NUMERIC, VIEWS.LARGE, 120), defineProperty(_TYPE_NUMERIC, VIEWS.MEDIUM, 100), defineProperty(_TYPE_NUMERIC, VIEWS.SMALL, 80), _TYPE_NUMERIC)), defineProperty(_DEFAULT_WIDTHS, TYPE_RATE, (_TYPE_RATE = {}, defineProperty(_TYPE_RATE, VIEWS.LARGE, 100), defineProperty(_TYPE_RATE, VIEWS.MEDIUM, 90), defineProperty(_TYPE_RATE, VIEWS.SMALL, 80), _TYPE_RATE)), defineProperty(_DEFAULT_WIDTHS, TYPE_SENTINEL, (_TYPE_SENTINEL = {}, defineProperty(_TYPE_SENTINEL, VIEWS.LARGE, 80), defineProperty(_TYPE_SENTINEL, VIEWS.MEDIUM, 80), defineProperty(_TYPE_SENTINEL, VIEWS.SMALL, 80), _TYPE_SENTINEL)), defineProperty(_DEFAULT_WIDTHS, TYPE_STATUS, (_TYPE_STATUS = {}, defineProperty(_TYPE_STATUS, VIEWS.LARGE, 120), defineProperty(_TYPE_STATUS, VIEWS.MEDIUM, 100), defineProperty(_TYPE_STATUS, VIEWS.SMALL, 80), _TYPE_STATUS)), defineProperty(_DEFAULT_WIDTHS, TYPE_TEXT, (_TYPE_TEXT = {}, defineProperty(_TYPE_TEXT, VIEWS.LARGE, 200), defineProperty(_TYPE_TEXT, VIEWS.MEDIUM, 120), defineProperty(_TYPE_TEXT, VIEWS.SMALL, 80), _TYPE_TEXT)), defineProperty(_DEFAULT_WIDTHS, TYPE_THIRD_PARTY_SECURITY, (_TYPE_THIRD_PARTY_SEC = {}, defineProperty(_TYPE_THIRD_PARTY_SEC, VIEWS.LARGE, 40), defineProperty(_TYPE_THIRD_PARTY_SEC, VIEWS.MEDIUM, 40), defineProperty(_TYPE_THIRD_PARTY_SEC, VIEWS.SMALL, 40), _TYPE_THIRD_PARTY_SEC)), _DEFAULT_WIDTHS);
79969
+ var DEFAULT_WIDTHS = (_DEFAULT_WIDTHS = {}, defineProperty(_DEFAULT_WIDTHS, TYPE_ACCOUNT, (_TYPE_ACCOUNT = {}, defineProperty(_TYPE_ACCOUNT, VIEWS.LARGE, 160), defineProperty(_TYPE_ACCOUNT, VIEWS.MEDIUM, 120), defineProperty(_TYPE_ACCOUNT, VIEWS.SMALL, 80), _TYPE_ACCOUNT)), defineProperty(_DEFAULT_WIDTHS, TYPE_ACCOUNT_NUMBER, (_TYPE_ACCOUNT_NUMBER = {}, defineProperty(_TYPE_ACCOUNT_NUMBER, VIEWS.LARGE, 100), defineProperty(_TYPE_ACCOUNT_NUMBER, VIEWS.MEDIUM, 80), defineProperty(_TYPE_ACCOUNT_NUMBER, VIEWS.SMALL, 60), _TYPE_ACCOUNT_NUMBER)), defineProperty(_DEFAULT_WIDTHS, TYPE_ADDRESS, (_TYPE_ADDRESS = {}, defineProperty(_TYPE_ADDRESS, VIEWS.LARGE, 120), defineProperty(_TYPE_ADDRESS, VIEWS.MEDIUM, 100), defineProperty(_TYPE_ADDRESS, VIEWS.SMALL, 80), _TYPE_ADDRESS)), defineProperty(_DEFAULT_WIDTHS, TYPE_CHECKBOX, (_TYPE_CHECKBOX = {}, defineProperty(_TYPE_CHECKBOX, VIEWS.LARGE, 40), defineProperty(_TYPE_CHECKBOX, VIEWS.MEDIUM, 40), defineProperty(_TYPE_CHECKBOX, VIEWS.SMALL, 40), _TYPE_CHECKBOX)), defineProperty(_DEFAULT_WIDTHS, TYPE_COUNTRY, (_TYPE_COUNTRY = {}, defineProperty(_TYPE_COUNTRY, VIEWS.LARGE, 120), defineProperty(_TYPE_COUNTRY, VIEWS.MEDIUM, 80), defineProperty(_TYPE_COUNTRY, VIEWS.SMALL, 40), _TYPE_COUNTRY)), defineProperty(_DEFAULT_WIDTHS, TYPE_DATE, (_TYPE_DATE = {}, defineProperty(_TYPE_DATE, VIEWS.LARGE, 220), defineProperty(_TYPE_DATE, VIEWS.MEDIUM, 140), defineProperty(_TYPE_DATE, VIEWS.SMALL, 120), _TYPE_DATE)), defineProperty(_DEFAULT_WIDTHS, TYPE_ICON, (_TYPE_ICON = {}, defineProperty(_TYPE_ICON, VIEWS.LARGE, 140), defineProperty(_TYPE_ICON, VIEWS.MEDIUM, 100), defineProperty(_TYPE_ICON, VIEWS.SMALL, 60), _TYPE_ICON)), defineProperty(_DEFAULT_WIDTHS, TYPE_IMAGE, (_TYPE_IMAGE = {}, defineProperty(_TYPE_IMAGE, VIEWS.LARGE, 140), defineProperty(_TYPE_IMAGE, VIEWS.MEDIUM, 100), defineProperty(_TYPE_IMAGE, VIEWS.SMALL, 60), _TYPE_IMAGE)), defineProperty(_DEFAULT_WIDTHS, TYPE_NUMERIC, (_TYPE_NUMERIC = {}, defineProperty(_TYPE_NUMERIC, VIEWS.LARGE, 120), defineProperty(_TYPE_NUMERIC, VIEWS.MEDIUM, 100), defineProperty(_TYPE_NUMERIC, VIEWS.SMALL, 80), _TYPE_NUMERIC)), defineProperty(_DEFAULT_WIDTHS, TYPE_RATE, (_TYPE_RATE = {}, defineProperty(_TYPE_RATE, VIEWS.LARGE, 100), defineProperty(_TYPE_RATE, VIEWS.MEDIUM, 90), defineProperty(_TYPE_RATE, VIEWS.SMALL, 80), _TYPE_RATE)), defineProperty(_DEFAULT_WIDTHS, TYPE_SENTINEL, (_TYPE_SENTINEL = {}, defineProperty(_TYPE_SENTINEL, VIEWS.LARGE, 64), defineProperty(_TYPE_SENTINEL, VIEWS.MEDIUM, 64), defineProperty(_TYPE_SENTINEL, VIEWS.SMALL, 64), _TYPE_SENTINEL)), defineProperty(_DEFAULT_WIDTHS, TYPE_SENTINEL_SCORE, (_TYPE_SENTINEL_SCORE = {}, defineProperty(_TYPE_SENTINEL_SCORE, VIEWS.LARGE, 80), defineProperty(_TYPE_SENTINEL_SCORE, VIEWS.MEDIUM, 80), defineProperty(_TYPE_SENTINEL_SCORE, VIEWS.SMALL, 80), _TYPE_SENTINEL_SCORE)), defineProperty(_DEFAULT_WIDTHS, TYPE_STATUS, (_TYPE_STATUS = {}, defineProperty(_TYPE_STATUS, VIEWS.LARGE, 120), defineProperty(_TYPE_STATUS, VIEWS.MEDIUM, 100), defineProperty(_TYPE_STATUS, VIEWS.SMALL, 80), _TYPE_STATUS)), defineProperty(_DEFAULT_WIDTHS, TYPE_TEXT, (_TYPE_TEXT = {}, defineProperty(_TYPE_TEXT, VIEWS.LARGE, 200), defineProperty(_TYPE_TEXT, VIEWS.MEDIUM, 120), defineProperty(_TYPE_TEXT, VIEWS.SMALL, 80), _TYPE_TEXT)), defineProperty(_DEFAULT_WIDTHS, TYPE_THIRD_PARTY_SECURITY, (_TYPE_THIRD_PARTY_SEC = {}, defineProperty(_TYPE_THIRD_PARTY_SEC, VIEWS.LARGE, 40), defineProperty(_TYPE_THIRD_PARTY_SEC, VIEWS.MEDIUM, 40), defineProperty(_TYPE_THIRD_PARTY_SEC, VIEWS.SMALL, 40), _TYPE_THIRD_PARTY_SEC)), _DEFAULT_WIDTHS);
79978
79970
  /**
79979
79971
  * Cell default width for each views
79980
79972
  * @type {{}}
79981
79973
  */
79982
79974
 
79983
- var DEFAULT_VIEWS = (_DEFAULT_VIEWS = {}, defineProperty(_DEFAULT_VIEWS, TYPE_ACCOUNT, VIEWS.LARGE), defineProperty(_DEFAULT_VIEWS, TYPE_ACCOUNT_NUMBER, VIEWS.LARGE), defineProperty(_DEFAULT_VIEWS, TYPE_ADDRESS, VIEWS.LARGE), defineProperty(_DEFAULT_VIEWS, TYPE_CHECKBOX, VIEWS.LARGE), defineProperty(_DEFAULT_VIEWS, TYPE_COUNTRY, VIEWS.LARGE), defineProperty(_DEFAULT_VIEWS, TYPE_DATE, VIEWS.LARGE), defineProperty(_DEFAULT_VIEWS, TYPE_ICON, VIEWS.LARGE), defineProperty(_DEFAULT_VIEWS, TYPE_IMAGE, VIEWS.LARGE), defineProperty(_DEFAULT_VIEWS, TYPE_NUMERIC, VIEWS.LARGE), defineProperty(_DEFAULT_VIEWS, TYPE_RATE, VIEWS.LARGE), defineProperty(_DEFAULT_VIEWS, TYPE_SENTINEL, VIEWS.LARGE), defineProperty(_DEFAULT_VIEWS, TYPE_STATUS, VIEWS.LARGE), defineProperty(_DEFAULT_VIEWS, TYPE_TEXT, VIEWS.LARGE), defineProperty(_DEFAULT_VIEWS, TYPE_THIRD_PARTY_SECURITY, VIEWS.LARGE), _DEFAULT_VIEWS);
79975
+ var DEFAULT_VIEWS = (_DEFAULT_VIEWS = {}, defineProperty(_DEFAULT_VIEWS, TYPE_ACCOUNT, VIEWS.LARGE), defineProperty(_DEFAULT_VIEWS, TYPE_ACCOUNT_NUMBER, VIEWS.LARGE), defineProperty(_DEFAULT_VIEWS, TYPE_ADDRESS, VIEWS.LARGE), defineProperty(_DEFAULT_VIEWS, TYPE_CHECKBOX, VIEWS.LARGE), defineProperty(_DEFAULT_VIEWS, TYPE_COUNTRY, VIEWS.LARGE), defineProperty(_DEFAULT_VIEWS, TYPE_DATE, VIEWS.LARGE), defineProperty(_DEFAULT_VIEWS, TYPE_ICON, VIEWS.LARGE), defineProperty(_DEFAULT_VIEWS, TYPE_IMAGE, VIEWS.LARGE), defineProperty(_DEFAULT_VIEWS, TYPE_NUMERIC, VIEWS.LARGE), defineProperty(_DEFAULT_VIEWS, TYPE_RATE, VIEWS.LARGE), defineProperty(_DEFAULT_VIEWS, TYPE_SENTINEL, VIEWS.LARGE), defineProperty(_DEFAULT_VIEWS, TYPE_SENTINEL_SCORE, VIEWS.LARGE), defineProperty(_DEFAULT_VIEWS, TYPE_STATUS, VIEWS.LARGE), defineProperty(_DEFAULT_VIEWS, TYPE_TEXT, VIEWS.LARGE), defineProperty(_DEFAULT_VIEWS, TYPE_THIRD_PARTY_SECURITY, VIEWS.LARGE), _DEFAULT_VIEWS);
79984
79976
  /**
79985
79977
  * Cell default side padding (one side) for each views
79986
79978
  * @type {{}}
@@ -79992,7 +79984,7 @@
79992
79984
  * @type {*[]}
79993
79985
  */
79994
79986
 
79995
- var ALIGN_RIGHT_TYPES = [TYPE_NUMERIC, TYPE_RATE, TYPE_SENTINEL];
79987
+ var ALIGN_RIGHT_TYPES = [TYPE_NUMERIC, TYPE_RATE, TYPE_SENTINEL, TYPE_SENTINEL_SCORE];
79996
79988
 
79997
79989
  var styles$c = function styles(theme) {
79998
79990
  return {
@@ -80340,13 +80332,18 @@
80340
80332
 
80341
80333
  case TYPE_SENTINEL:
80342
80334
  return React__default.createElement(CellSentinel, {
80343
- automaticFraudReviewResult: datacell.automaticFraudReviewResult,
80344
- fraudResult: datacell.value,
80345
- hideFraudResult: datacell.hideFraudResult,
80346
- pendingManualAction: datacell.pendingManualAction,
80347
- score: datacell.score,
80348
- smartDecision: datacell.smartDecision,
80349
- view: cell.view ? cell.view : DEFAULT_VIEWS[cell.type]
80335
+ color: datacell.color,
80336
+ label: datacell.label,
80337
+ letter: datacell.label2,
80338
+ active: datacell.active,
80339
+ reviewer: datacell.reviewer,
80340
+ outlined: datacell.outlined
80341
+ });
80342
+
80343
+ case TYPE_SENTINEL_SCORE:
80344
+ return React__default.createElement(CellSentinelScore, {
80345
+ value: datacell.value,
80346
+ result: datacell.result
80350
80347
  });
80351
80348
 
80352
80349
  case TYPE_PIN_TO_ACTION:
@@ -91173,7 +91170,7 @@
91173
91170
  bottom: 0,
91174
91171
  height: 32,
91175
91172
  width: 32,
91176
- margin: '4px 24px'
91173
+ margin: '0px 24px'
91177
91174
  },
91178
91175
  calendarButton: {
91179
91176
  fontWeight: theme.typography.fontWeightMedium
@@ -91466,8 +91463,8 @@
91466
91463
  }(React__default.Component);
91467
91464
 
91468
91465
  YearPickerOverlay.defaultProps = {
91469
- disableFutureDays: false,
91470
- disablePastDays: false,
91466
+ // disableFutureDays: true,
91467
+ // disablePastDays: false,
91471
91468
  minimumDate: new Date(2013, 4, 1),
91472
91469
  // by default 1 May 2013
91473
91470
  translations: {
@@ -91503,7 +91500,7 @@
91503
91500
  /**
91504
91501
  * Date minimale sélectionnable
91505
91502
  */
91506
- minimumDate: propTypes.instanceOf(Date),
91503
+ minimumDate: propTypes.instanceOf(Date).isRequired,
91507
91504
 
91508
91505
  /**
91509
91506
  * Fonction de callback
@@ -91610,7 +91607,8 @@
91610
91607
  button: {
91611
91608
  height: 32,
91612
91609
  width: 32,
91613
- margin: '4px 24px'
91610
+ margin: '4px 24px',
91611
+ padding: 0
91614
91612
  },
91615
91613
  left: {
91616
91614
  float: 'left'
@@ -92168,7 +92166,7 @@
92168
92166
  todayButton: translations.today,
92169
92167
  onTodayButtonClick: this.handleCurrentMonthChange,
92170
92168
  weekdayElement: Weekday$1,
92171
- NavBarElement: function NavBarElement(props2) {
92169
+ navbarElement: function navbarElement(props2) {
92172
92170
  return React__default.createElement(NavBar$1, _extends_1({
92173
92171
  showClockButton: enableTime,
92174
92172
  onClockClick: _this2.handleClockClick
@@ -92477,400 +92475,288 @@
92477
92475
 
92478
92476
  _this = possibleConstructorReturn(this, getPrototypeOf(HiDateRangePicker).call(this));
92479
92477
 
92480
- _this.handleInputChange = function (inputName) {
92481
- return function (event) {
92482
- _this.event = event;
92478
+ _this.handleDayChange = function (name, day) {
92479
+ if (day) {
92480
+ // if time disabled, focus TO input
92481
+ // else focus current input
92482
+ if (!_this.props.enableTime) {
92483
+ if (day instanceof Date) {
92484
+ if (name === 'from' && _this.toInput) {
92485
+ _this.toInput.getInput().focus();
92486
+ }
92487
+ }
92488
+ } else {
92489
+ _this.timeout = setTimeout(function () {
92490
+ if (_this["".concat(name, "Input")].getInput()) {
92491
+ _this["".concat(name, "Input")].getInput().focus();
92492
+ }
92493
+ }, 10);
92494
+ }
92483
92495
 
92484
- _this.props.onChange(inputName, event.target.value);
92485
- };
92496
+ if (_this.props.onChange) {
92497
+ _this.handleChange(name, day);
92498
+ }
92499
+
92500
+ if (_this.props.enableTime) {
92501
+ _this.openPanel('time');
92502
+ }
92503
+ }
92486
92504
  };
92487
92505
 
92488
- _this.handleDayPickerFocus = function (name) {
92489
- return function () {
92490
- _this.setState({
92491
- focusedInput: name
92492
- });
92506
+ _this.handleInputChange = function (inputName) {
92507
+ return function (event) {
92508
+ _this.handleChange(inputName, event.target.value);
92493
92509
  };
92494
92510
  };
92495
92511
 
92496
- _this.handleDayPickerBlur = function (name) {
92497
- return function () {
92498
- _this.setState({
92499
- focusedInput: ''
92500
- });
92512
+ _this.onDayToClick = function (day) {
92513
+ _this.handleDayChange('to', day);
92501
92514
 
92502
- if (_this.props.onBlur) {
92503
- _this.props.onBlur(name);
92504
- }
92505
- };
92515
+ document.activeElement.blur();
92506
92516
  };
92507
92517
 
92508
- _this.state = {
92509
- fromCurrentMonth: props.from ? props.from : new Date(),
92510
- toCurrentMonth: props.to ? props.to : new Date(),
92511
- focusedInput: ''
92512
- };
92513
- _this.handleReset = _this.handleReset.bind(assertThisInitialized(assertThisInitialized(_this)));
92514
- _this.handleDayChange = _this.handleDayChange.bind(assertThisInitialized(assertThisInitialized(_this)));
92515
- _this.handleDayChangeFrom = _this.handleDayChangeFrom.bind(assertThisInitialized(assertThisInitialized(_this)));
92516
- _this.handleDayChangeTo = _this.handleDayChangeTo.bind(assertThisInitialized(assertThisInitialized(_this)));
92517
- _this.handleCurrentMonthChange = _this.handleCurrentMonthChange.bind(assertThisInitialized(assertThisInitialized(_this)));
92518
- _this.handleCurrentMonthChangeFrom = _this.handleCurrentMonthChangeFrom.bind(assertThisInitialized(assertThisInitialized(_this)));
92519
- _this.handleCurrentMonthChangeTo = _this.handleCurrentMonthChangeTo.bind(assertThisInitialized(assertThisInitialized(_this)));
92520
- _this.handleTimeChange = _this.handleTimeChange.bind(assertThisInitialized(assertThisInitialized(_this)));
92521
- _this.handleCalendarClick = _this.handleCalendarClick.bind(assertThisInitialized(assertThisInitialized(_this)));
92522
- _this.handleCalendarClickFrom = _this.handleCalendarClickFrom.bind(assertThisInitialized(assertThisInitialized(_this)));
92523
- _this.handleCalendarClickTo = _this.handleCalendarClickTo.bind(assertThisInitialized(assertThisInitialized(_this)));
92524
- _this.handleClockClick = _this.handleClockClick.bind(assertThisInitialized(assertThisInitialized(_this)));
92525
- _this.handleClockClickFrom = _this.handleClockClickFrom.bind(assertThisInitialized(assertThisInitialized(_this)));
92526
- _this.handleClockClickTo = _this.handleClockClickTo.bind(assertThisInitialized(assertThisInitialized(_this)));
92527
- _this.handleMonthClick = _this.handleMonthClick.bind(assertThisInitialized(assertThisInitialized(_this)));
92528
- _this.handleMonthClickFrom = _this.handleMonthClickFrom.bind(assertThisInitialized(assertThisInitialized(_this)));
92529
- _this.handleMonthClickTo = _this.handleMonthClickTo.bind(assertThisInitialized(assertThisInitialized(_this)));
92530
- _this.handleYearClick = _this.handleYearClick.bind(assertThisInitialized(assertThisInitialized(_this)));
92531
- _this.handleYearClickFrom = _this.handleYearClickFrom.bind(assertThisInitialized(assertThisInitialized(_this)));
92532
- _this.handleYearClickTo = _this.handleYearClickTo.bind(assertThisInitialized(assertThisInitialized(_this)));
92533
- _this.handleDayPickerFocus = _this.handleDayPickerFocus.bind(assertThisInitialized(assertThisInitialized(_this)));
92534
- _this.handleDayPickerBlur = _this.handleDayPickerBlur.bind(assertThisInitialized(assertThisInitialized(_this)));
92535
- _this.handleInputChange = _this.handleInputChange.bind(assertThisInitialized(assertThisInitialized(_this)));
92536
- _this.openPanel = _this.openPanel.bind(assertThisInitialized(assertThisInitialized(_this)));
92537
- _this.renderCaption = _this.renderCaption.bind(assertThisInitialized(assertThisInitialized(_this)));
92538
- _this.renderCaptionFrom = _this.renderCaptionFrom.bind(assertThisInitialized(assertThisInitialized(_this)));
92539
- _this.renderCaptionTo = _this.renderCaptionTo.bind(assertThisInitialized(assertThisInitialized(_this)));
92540
- _this.renderNavBar = _this.renderNavBar.bind(assertThisInitialized(assertThisInitialized(_this)));
92541
- _this.renderNavBarFrom = _this.renderNavBarFrom.bind(assertThisInitialized(assertThisInitialized(_this)));
92542
- _this.renderNavBarTo = _this.renderNavBarTo.bind(assertThisInitialized(assertThisInitialized(_this)));
92543
- _this.renderOverlay = _this.renderOverlay.bind(assertThisInitialized(assertThisInitialized(_this)));
92544
- _this.renderOverlayFrom = _this.renderOverlayFrom.bind(assertThisInitialized(assertThisInitialized(_this)));
92545
- _this.renderOverlayTo = _this.renderOverlayTo.bind(assertThisInitialized(assertThisInitialized(_this)));
92546
- _this.renderMonthPickerOverlay = _this.renderMonthPickerOverlay.bind(assertThisInitialized(assertThisInitialized(_this)));
92547
- _this.renderTimePickerOverlay = _this.renderTimePickerOverlay.bind(assertThisInitialized(assertThisInitialized(_this)));
92548
- _this.renderYearPickerOverlay = _this.renderYearPickerOverlay.bind(assertThisInitialized(assertThisInitialized(_this)));
92549
- return _this;
92550
- }
92518
+ _this.handleTimeChange = function (name, date, precision) {
92519
+ _this.handleChange(name, date);
92551
92520
 
92552
- createClass(HiDateRangePicker, [{
92553
- key: "componentDidUpdate",
92554
- value: function componentDidUpdate(prevProps) {
92555
- var _this2 = this;
92521
+ if (name === 'from' && precision === 'minute') {
92522
+ _this.fromInput.hideDayPicker();
92556
92523
 
92557
- // Focus From input on enabling
92558
- if (prevProps.disabled === true && this.props.disabled === false) {
92559
- this.timeout = setTimeout(function () {
92560
- if (_this2.fromInput.getInput()) {
92561
- _this2.fromInput.getInput().focus();
92562
- }
92563
- }, 0);
92524
+ _this.toInput.getInput().focus();
92525
+
92526
+ _this.toInput.showDayPicker();
92527
+
92528
+ _this.openPanel('calendar');
92529
+ } else if (name === 'to' && precision === 'minute') {
92530
+ _this.toInput.hideDayPicker();
92531
+
92532
+ document.activeElement.blur();
92564
92533
  }
92565
- }
92566
- }, {
92567
- key: "componentWillUnmount",
92568
- value: function componentWillUnmount() {
92569
- clearTimeout(this.timeout);
92570
- }
92571
- }, {
92572
- key: "handleDayChange",
92573
- value: function handleDayChange(name, day, modifiers) {
92574
- var _this3 = this;
92534
+ };
92575
92535
 
92576
- if (day) {
92577
- // if time disabled, focus TO input
92578
- // else focus current input
92579
- if (!this.props.enableTime) {
92580
- if (day instanceof Date) {
92581
- if (name === 'from' && this.toInput) {
92582
- this.toInput.getInput().focus();
92583
- } else if (name === 'to') {
92584
- if (typeof this.event === 'undefined' || this.event && this.event.type !== 'change') {
92585
- // trigger blur only if user clicks on date into calendar
92586
- // else keep focus to see day selection into calendar
92587
- document.activeElement.blur();
92588
- }
92536
+ _this.handleChange = function (name, day) {
92537
+ var translations = _this.props.translations;
92538
+ var date = undefined;
92539
+ var error = undefined;
92540
+ var now = new Date();
92541
+ var _this$props = _this.props,
92542
+ minimumDate = _this$props.minimumDate,
92543
+ disableFutureDays = _this$props.disableFutureDays,
92544
+ format = _this$props.format;
92589
92545
 
92590
- delete this.event;
92591
- }
92592
- }
92546
+ if (day instanceof Date) {
92547
+ date = day;
92548
+ } else if (day) {
92549
+ var parsedValue = moment(day, _this.props.format, true);
92550
+
92551
+ if (parsedValue.isValid()) {
92552
+ date = parsedValue.toDate();
92593
92553
  } else {
92594
- this.timeout = setTimeout(function () {
92595
- if (_this3["".concat(name, "Input")].getInput()) {
92596
- _this3["".concat(name, "Input")].getInput().focus();
92597
- }
92598
- }, 10);
92554
+ error = translations.invalid_format;
92599
92555
  }
92556
+ }
92600
92557
 
92601
- if (this.props.onChange) {
92602
- // Keep Time if set
92603
- if (this.props.enableTime) {
92604
- if (this.props[name]) {
92605
- day.setHours(this.props[name].getHours(), this.props[name].getMinutes());
92606
- } else {
92607
- day.setHours(0, 0);
92608
- }
92609
- }
92558
+ if (date) {
92559
+ var comparativeDate = name === 'to' ? moment(_this.props.from) : moment(_this.props.to);
92610
92560
 
92611
- this.props.onChange(name, day);
92561
+ if (name === 'to' && comparativeDate > moment(date) || name === 'from' && comparativeDate < moment(date)) {
92562
+ error = translations.to_superior_from;
92563
+ } else if (date < minimumDate) {
92564
+ error = translations.date_inferior_min_date.replace("%s", moment(minimumDate).format(format));
92565
+ } else if (disableFutureDays && date > now) {
92566
+ error = translations.date_superior_max_date.replace("%s", moment().format(format));
92612
92567
  }
92613
92568
 
92614
- if (this.props.enableTime) {
92615
- this.openPanel(name, 'time');
92569
+ if (!_this.props.enableTime) {
92570
+ if (name === 'from') {
92571
+ date.setHours(0, 0);
92572
+ } else {
92573
+ date.setHours(23, 59);
92574
+ }
92616
92575
  }
92617
92576
  }
92618
- }
92619
- }, {
92620
- key: "handleDayChangeFrom",
92621
- value: function handleDayChangeFrom(day, modifiers) {
92622
- this.handleDayChange('from', day, modifiers);
92623
- }
92624
- }, {
92625
- key: "handleDayChangeTo",
92626
- value: function handleDayChangeTo(day, modifiers) {
92627
- this.handleDayChange('to', day, modifiers);
92628
- }
92629
- }, {
92630
- key: "handleCurrentMonthChange",
92631
- value: function handleCurrentMonthChange(name, day) {
92632
- var _this$setState;
92633
92577
 
92634
- this.setState((_this$setState = {}, defineProperty(_this$setState, "".concat(name, "CurrentMonth"), day), defineProperty(_this$setState, "".concat(name, "OpenedPanel"), 'calendar'), _this$setState));
92635
- }
92636
- }, {
92637
- key: "handleCurrentMonthChangeFrom",
92638
- value: function handleCurrentMonthChangeFrom(day) {
92639
- this.handleCurrentMonthChange('from', day);
92640
- }
92641
- }, {
92642
- key: "handleCurrentMonthChangeTo",
92643
- value: function handleCurrentMonthChangeTo(day) {
92644
- this.handleCurrentMonthChange('to', day);
92645
- }
92646
- }, {
92647
- key: "handleCalendarClick",
92648
- value: function handleCalendarClick(name) {
92649
- this.openPanel(name, 'calendar');
92650
- }
92651
- }, {
92652
- key: "handleCalendarClickFrom",
92653
- value: function handleCalendarClickFrom() {
92654
- this.handleCalendarClick('from');
92655
- }
92656
- }, {
92657
- key: "handleCalendarClickTo",
92658
- value: function handleCalendarClickTo() {
92659
- this.handleCalendarClick('to');
92660
- }
92661
- }, {
92662
- key: "handleClockClick",
92663
- value: function handleClockClick(name) {
92664
- this.openPanel(name, 'time');
92665
- }
92666
- }, {
92667
- key: "handleClockClickFrom",
92668
- value: function handleClockClickFrom() {
92669
- this.handleClockClick('from');
92670
- }
92671
- }, {
92672
- key: "handleClockClickTo",
92673
- value: function handleClockClickTo() {
92674
- this.handleClockClick('to');
92675
- }
92676
- }, {
92677
- key: "handleMonthClick",
92678
- value: function handleMonthClick(name) {
92679
- this.openPanel(name, 'months');
92680
- }
92681
- }, {
92682
- key: "handleMonthClickFrom",
92683
- value: function handleMonthClickFrom() {
92684
- this.handleMonthClick('from');
92685
- }
92686
- }, {
92687
- key: "handleMonthClickTo",
92688
- value: function handleMonthClickTo() {
92689
- this.handleMonthClick('to');
92690
- }
92691
- }, {
92692
- key: "handleYearClick",
92693
- value: function handleYearClick(name) {
92694
- this.openPanel(name, 'years');
92695
- }
92696
- }, {
92697
- key: "handleYearClickFrom",
92698
- value: function handleYearClickFrom() {
92699
- this.handleYearClick('from');
92700
- }
92701
- }, {
92702
- key: "handleYearClickTo",
92703
- value: function handleYearClickTo() {
92704
- this.handleYearClick('to');
92705
- }
92706
- }, {
92707
- key: "handleTimeChange",
92708
- value: function handleTimeChange(name, date, precision) {
92709
- this.props.onChange(name, date);
92578
+ _this.props.onChange(name, date);
92710
92579
 
92711
- if (name === 'from' && precision === 'minute') {
92712
- this.fromInput.hideDayPicker();
92713
- this.toInput.getInput().focus();
92714
- this.toInput.showDayPicker();
92715
- } else if (name === 'to' && precision === 'minute') {
92716
- this.toInput.hideDayPicker();
92717
- document.activeElement.blur();
92580
+ _this.props.onChange("".concat(name, "Error"), error);
92581
+ };
92582
+
92583
+ _this.handleCurrentMonthChange = function (day) {
92584
+ _this.setState({
92585
+ currentMonth: day,
92586
+ openedPanel: 'calendar'
92587
+ });
92588
+ };
92589
+
92590
+ _this.handleDayPickerFocus = function (name) {
92591
+ _this.setState({
92592
+ focusedInput: name
92593
+ });
92594
+ };
92595
+
92596
+ _this.handleDayPickerBlur = function (name) {
92597
+ _this.setState({
92598
+ focusedInput: ''
92599
+ });
92600
+
92601
+ if (_this.props.onBlur) {
92602
+ _this.props.onBlur(name);
92718
92603
  }
92719
- }
92720
- }, {
92721
- key: "handleReset",
92722
- value: function handleReset(name) {
92723
- var _this4 = this;
92724
92604
 
92725
- this.handleCurrentMonthChange(name, new Date());
92726
- this.timeout = setTimeout(function () {
92727
- if (_this4.props.onReset) {
92728
- _this4.props.onReset(name);
92605
+ _this.timeout = setTimeout(function () {
92606
+ if (!['from', 'to'].includes(_this.state.focusedInput)) {
92607
+ _this.setState({
92608
+ openedPanel: 'calendar'
92609
+ });
92729
92610
  }
92730
- }, 0);
92731
- }
92732
- }, {
92733
- key: "openPanel",
92734
- value: function openPanel(name, panel) {
92735
- this.setState(defineProperty({}, "".concat(name, "OpenedPanel"), panel));
92736
- }
92737
- }, {
92738
- key: "renderCaption",
92739
- value: function renderCaption(name, propsCaption) {
92611
+ }, 100);
92612
+ };
92613
+
92614
+ _this.handleReset = function (name) {
92615
+ _this.handleChange(name, undefined);
92616
+
92617
+ _this.setState({
92618
+ keyFrom: _this.state.keyFrom === 1 ? 2 : 1,
92619
+ keyTo: _this.state.keyTo === 1 ? 2 : 1
92620
+ });
92621
+ };
92622
+
92623
+ _this.openPanel = function (panel) {
92624
+ _this.setState({
92625
+ openedPanel: panel
92626
+ });
92627
+ };
92628
+
92629
+ _this.renderCaption = function (propsCaption) {
92740
92630
  return React__default.createElement(Caption$2, _extends_1({
92741
- onMonthClick: this["handleMonthClick".concat(capitalize(name))],
92742
- onYearClick: this["handleYearClick".concat(capitalize(name))]
92631
+ onMonthClick: function onMonthClick() {
92632
+ return _this.openPanel('months');
92633
+ },
92634
+ onYearClick: function onYearClick() {
92635
+ return _this.openPanel('years');
92636
+ }
92743
92637
  }, propsCaption));
92744
- }
92745
- }, {
92746
- key: "renderCaptionFrom",
92747
- value: function renderCaptionFrom(propsCaption) {
92748
- return this.renderCaption('from', propsCaption);
92749
- }
92750
- }, {
92751
- key: "renderCaptionTo",
92752
- value: function renderCaptionTo(propsCaption) {
92753
- return this.renderCaption('to', propsCaption);
92754
- }
92755
- }, {
92756
- key: "renderNavBar",
92757
- value: function renderNavBar(name, propsNavBar) {
92638
+ };
92639
+
92640
+ _this.renderNavBar = function (propsNavBar) {
92758
92641
  return React__default.createElement(NavBar$1, _extends_1({
92759
- showClockButton: this.props.enableTime,
92760
- onClockClick: this["handleClockClick".concat(capitalize(name))]
92642
+ showClockButton: _this.props.enableTime,
92643
+ onClockClick: function onClockClick() {
92644
+ return _this.openPanel('time');
92645
+ }
92761
92646
  }, propsNavBar));
92762
- }
92763
- }, {
92764
- key: "renderNavBarFrom",
92765
- value: function renderNavBarFrom(propsNavBar) {
92766
- return this.renderNavBar('from', propsNavBar);
92767
- }
92768
- }, {
92769
- key: "renderNavBarTo",
92770
- value: function renderNavBarTo(propsNavBar) {
92771
- return this.renderNavBar('to', propsNavBar);
92772
- }
92773
- }, {
92774
- key: "renderOverlay",
92775
- value: function renderOverlay(name, propsOverlay, staticPosition) {
92647
+ };
92648
+
92649
+ _this.renderOverlay = function (name, propsOverlay, staticPosition) {
92776
92650
  var rangeOverlayProps = _extends_1({}, propsOverlay, {
92777
92651
  side: name,
92778
92652
  staticPosition: staticPosition
92779
92653
  });
92780
92654
 
92781
- switch (this.state["".concat(name, "OpenedPanel")]) {
92655
+ switch (_this.state['openedPanel']) {
92782
92656
  case 'time':
92783
- return this.renderTimePickerOverlay(name, rangeOverlayProps);
92657
+ return _this.renderTimePickerOverlay(name, rangeOverlayProps);
92784
92658
 
92785
92659
  case 'months':
92786
- return this.renderMonthPickerOverlay(name, rangeOverlayProps);
92660
+ return _this.renderMonthPickerOverlay(name, rangeOverlayProps);
92787
92661
 
92788
92662
  case 'years':
92789
- return this.renderYearPickerOverlay(name, rangeOverlayProps);
92663
+ return _this.renderYearPickerOverlay(name, rangeOverlayProps);
92790
92664
 
92791
92665
  case 'calendar':
92792
- default:
92793
92666
  return React__default.createElement(Overlay$1, rangeOverlayProps);
92794
92667
  }
92795
- }
92796
- }, {
92797
- key: "renderOverlayFrom",
92798
- value: function renderOverlayFrom(propsOverlay) {
92799
- return this.renderOverlay('from', propsOverlay, this.props.staticPosition);
92800
- }
92801
- }, {
92802
- key: "renderOverlayTo",
92803
- value: function renderOverlayTo(propsOverlay) {
92804
- return this.renderOverlay('to', propsOverlay, this.props.staticPosition);
92805
- }
92806
- }, {
92807
- key: "renderMonthPickerOverlay",
92808
- value: function renderMonthPickerOverlay(name, propsOverlay) {
92668
+ };
92669
+
92670
+ _this.renderOverlayFrom = function (propsOverlay) {
92671
+ return _this.renderOverlay('from', propsOverlay, _this.props.staticPosition);
92672
+ };
92673
+
92674
+ _this.renderOverlayTo = function (propsOverlay) {
92675
+ return _this.renderOverlay('to', propsOverlay, _this.props.staticPosition);
92676
+ };
92677
+
92678
+ _this.renderMonthPickerOverlay = function (name, propsOverlay) {
92809
92679
  var monthPickerProps = {
92810
- value: this.state["".concat(name, "CurrentMonth")],
92811
- onChange: this["handleCurrentMonthChange".concat(capitalize(name))]
92680
+ value: _this.state['currentMonth'],
92681
+ onChange: _this.handleCurrentMonthChange
92812
92682
  };
92813
92683
  return React__default.createElement(MonthPickerOverlay, _extends_1({
92814
92684
  key: "".concat(name, "-month-picker-overlay")
92815
92685
  }, monthPickerProps, propsOverlay));
92816
- }
92817
- }, {
92818
- key: "renderTimePickerOverlay",
92819
- value: function renderTimePickerOverlay(name, propsOverlay) {
92820
- var _this5 = this;
92686
+ };
92821
92687
 
92688
+ _this.renderTimePickerOverlay = function (name, propsOverlay) {
92822
92689
  var timePickerProps = {
92823
- value: this.props[name],
92690
+ value: _this.props[name],
92824
92691
  onChange: function onChange(date, precision) {
92825
- return _this5.handleTimeChange(name, date, precision);
92692
+ return _this.handleTimeChange(name, date, precision);
92826
92693
  },
92827
- onCalendarClick: this["handleCalendarClick".concat(capitalize(name))]
92694
+ onCalendarClick: function onCalendarClick() {
92695
+ return _this.openPanel('calendar');
92696
+ }
92828
92697
  };
92829
92698
  return React__default.createElement(TimePickerOverlay$1, _extends_1({
92830
92699
  key: "".concat(name, "-time-picker-overlay")
92831
92700
  }, timePickerProps, propsOverlay));
92832
- }
92833
- }, {
92834
- key: "renderYearPickerOverlay",
92835
- value: function renderYearPickerOverlay(name, propsOverlay) {
92701
+ };
92702
+
92703
+ _this.renderYearPickerOverlay = function (name, propsOverlay) {
92836
92704
  var yearPickerProps = {
92837
- value: this.state["".concat(name, "CurrentMonth")],
92838
- onChange: this["handleCurrentMonthChange".concat(capitalize(name))],
92839
- disabledFutureDays: this.props.disableFutureDays,
92840
- disabledPastDays: this.props.disablePastDays
92705
+ value: _this.state['currentMonth'],
92706
+ onChange: _this.handleCurrentMonthChange,
92707
+ disabledFutureDays: _this.props.disableFutureDays
92841
92708
  };
92842
92709
  return React__default.createElement(YearPickerOverlay, _extends_1({
92843
92710
  key: "".concat(name, "-year-picker-overlay")
92844
92711
  }, yearPickerProps, propsOverlay));
92712
+ };
92713
+
92714
+ _this.state = {
92715
+ currentMonth: new Date(),
92716
+ focusedInput: '',
92717
+ openedPanel: 'calendar',
92718
+ keyFrom: 1,
92719
+ keyTo: 1
92720
+ };
92721
+ return _this;
92722
+ }
92723
+
92724
+ createClass(HiDateRangePicker, [{
92725
+ key: "componentWillUnmount",
92726
+ value: function componentWillUnmount() {
92727
+ clearTimeout(this.timeout);
92845
92728
  }
92846
92729
  }, {
92847
92730
  key: "render",
92848
92731
  value: function render() {
92849
- var _this6 = this,
92732
+ var _this2 = this,
92850
92733
  _classNames;
92851
92734
 
92852
- var _this$props = this.props,
92853
- classes = _this$props.classes,
92854
- disabledDays = _this$props.disabledDays,
92855
- disablePastDays = _this$props.disablePastDays,
92856
- disableFutureDays = _this$props.disableFutureDays,
92857
- enableTime = _this$props.enableTime,
92858
- labelFrom = _this$props.labelFrom,
92859
- labelTo = _this$props.labelTo,
92860
- locale = _this$props.locale,
92861
- format = _this$props.format,
92862
- from = _this$props.from,
92863
- minimumDate = _this$props.minimumDate,
92864
- onReset = _this$props.onReset,
92865
- to = _this$props.to,
92866
- translations = _this$props.translations,
92867
- id = _this$props.id,
92868
- staticPosition = _this$props.staticPosition,
92869
- props = objectWithoutProperties(_this$props, ["classes", "disabledDays", "disablePastDays", "disableFutureDays", "enableTime", "labelFrom", "labelTo", "locale", "format", "from", "minimumDate", "onReset", "to", "translations", "id", "staticPosition"]);
92735
+ var _this$props2 = this.props,
92736
+ classes = _this$props2.classes,
92737
+ disabled = _this$props2.disabled,
92738
+ disabledDays = _this$props2.disabledDays,
92739
+ disableFutureDays = _this$props2.disableFutureDays,
92740
+ enableTime = _this$props2.enableTime,
92741
+ labelFrom = _this$props2.labelFrom,
92742
+ labelTo = _this$props2.labelTo,
92743
+ locale = _this$props2.locale,
92744
+ format = _this$props2.format,
92745
+ from = _this$props2.from,
92746
+ fromError = _this$props2.fromError,
92747
+ minimumDate = _this$props2.minimumDate,
92748
+ onReset = _this$props2.onReset,
92749
+ to = _this$props2.to,
92750
+ toError = _this$props2.toError,
92751
+ translations = _this$props2.translations,
92752
+ id = _this$props2.id,
92753
+ staticPosition = _this$props2.staticPosition,
92754
+ errorText = _this$props2.errorText,
92755
+ hasSelector = _this$props2.hasSelector,
92756
+ helperIcon = _this$props2.helperIcon,
92757
+ helperText = _this$props2.helperText,
92758
+ props = objectWithoutProperties(_this$props2, ["classes", "disabled", "disabledDays", "disableFutureDays", "enableTime", "labelFrom", "labelTo", "locale", "format", "from", "fromError", "minimumDate", "onReset", "to", "toError", "translations", "id", "staticPosition", "errorText", "hasSelector", "helperIcon", "helperText"]);
92870
92759
 
92871
- var _this$state = this.state,
92872
- fromCurrentMonth = _this$state.fromCurrentMonth,
92873
- toCurrentMonth = _this$state.toCurrentMonth;
92874
92760
  var now = new Date();
92875
92761
  var modifiers = {
92876
92762
  start: from,
@@ -92915,99 +92801,81 @@
92915
92801
  selectedDays: selectedDays,
92916
92802
  todayButton: translations.today,
92917
92803
  weekdayElement: Weekday$1
92918
- }, props); // Build Props for the From DatePicker
92919
- // Disable days after 'to' date if define
92920
-
92921
-
92922
- var after;
92923
-
92924
- if (to instanceof Date && disableFutureDays) {
92925
- after = to < now ? now : to;
92926
- } else if (to instanceof Date) {
92927
- after = to;
92928
- } else if (disableFutureDays) {
92929
- after = now;
92930
- }
92931
-
92932
- var disabledDaysFrom = _extends_1({}, disablePastDays && {
92933
- before: now
92934
- }, (to || disableFutureDays) && {
92935
- after: after
92936
- }, disabledDays);
92804
+ }, props);
92937
92805
 
92938
92806
  var fromDayPickerProps = _extends_1({}, dayPickerProps, {
92939
- onTodayButtonClick: this.handleCurrentMonthChangeFrom,
92940
- NavBarElement: this.renderNavBarFrom,
92941
- captionElement: this.renderCaptionFrom,
92942
- disabledDays: disabledDaysFrom,
92943
- month: fromCurrentMonth,
92944
- modifiers: _extends_1({}, modifiers, {
92945
- disabled: disabledDaysFrom
92946
- })
92947
- }); // Build Props for the To DatePicker
92948
- // Disable days before 'from' date if define
92949
-
92950
-
92951
- var before;
92952
-
92953
- if (from instanceof Date && disablePastDays) {
92954
- before = from < now ? now : from;
92955
- } else if (from instanceof Date) {
92956
- before = from;
92957
- } else if (disablePastDays) {
92958
- before = now;
92959
- }
92960
-
92961
- var disabledDaysTo = _extends_1({}, (from || disablePastDays) && {
92962
- before: before
92963
- }, disableFutureDays && {
92964
- after: now
92965
- }, disabledDays);
92807
+ onTodayButtonClick: this.handleCurrentMonthChange,
92808
+ navbarElement: this.renderNavBar,
92809
+ captionElement: this.renderCaption,
92810
+ disabledDays: _extends_1({
92811
+ before: minimumDate
92812
+ }, disableFutureDays && {
92813
+ after: now
92814
+ }, to && {
92815
+ after: to
92816
+ }),
92817
+ month: this.state.currentMonth,
92818
+ modifiers: _extends_1({}, modifiers)
92819
+ });
92966
92820
 
92967
92821
  var toDayPickerProps = _extends_1({}, dayPickerProps, {
92968
- onTodayButtonClick: this.handleCurrentMonthChangeTo,
92969
- NavBarElement: this.renderNavBarTo,
92970
- captionElement: this.renderCaptionTo,
92971
- disabledDays: disabledDaysTo,
92972
- month: toCurrentMonth,
92973
- modifiers: _extends_1({}, modifiers, {
92974
- disabled: disabledDaysTo
92975
- })
92822
+ onTodayButtonClick: this.handleCurrentMonthChange,
92823
+ navbarElement: this.renderNavBar,
92824
+ onDayClick: this.onDayToClick,
92825
+ captionElement: this.renderCaption,
92826
+ disabledDays: _extends_1({
92827
+ before: minimumDate
92828
+ }, disableFutureDays && {
92829
+ after: now
92830
+ }, from && {
92831
+ before: from
92832
+ }),
92833
+ month: this.state.currentMonth,
92834
+ modifiers: _extends_1({}, modifiers)
92976
92835
  }); // From & To InputProps
92977
92836
 
92978
92837
 
92979
92838
  var fromInputProps = _extends_1({}, onReset && {
92980
92839
  onReset: function onReset() {
92981
- return _this6.handleReset('from');
92840
+ return _this2.handleReset('from');
92982
92841
  }
92983
- }, props, labelFrom && {
92842
+ }, props, fromError && {
92843
+ error: true
92844
+ }, labelFrom && {
92984
92845
  label: labelFrom
92985
92846
  }, {
92986
92847
  id: "".concat(id, "-from"),
92987
- onChange: this.handleInputChange('from')
92848
+ onChange: this.handleInputChange('from'),
92849
+ disabled: disabled
92988
92850
  });
92989
92851
 
92990
92852
  var toInputProps = _extends_1({}, onReset && {
92991
92853
  onReset: function onReset() {
92992
- return _this6.handleReset('to');
92854
+ return _this2.handleReset('to');
92993
92855
  }
92994
- }, props, labelTo && {
92856
+ }, props, toError && {
92857
+ error: true
92858
+ }, labelTo && {
92995
92859
  label: labelTo
92996
92860
  }, {
92997
92861
  id: "".concat(id, "-to"),
92998
- onChange: this.handleInputChange('to')
92862
+ onChange: this.handleInputChange('to'),
92863
+ disabled: disabled
92999
92864
  });
93000
92865
 
93001
92866
  var toClass = classnames(classes.toInput, (_classNames = {}, defineProperty(_classNames, classes.absolute, staticPosition === true && this.state.focusedInput === 'from'), defineProperty(_classNames, classes.right4, staticPosition === true && this.state.focusedInput === 'from'), _classNames));
93002
- return React__default.createElement("div", {
92867
+ var content = React__default.createElement("div", {
93003
92868
  className: classnames(classes.root, classes.rangePickerContainer)
93004
92869
  }, React__default.createElement("div", {
93005
92870
  className: classes.fromInput,
93006
- onFocus: this.handleDayPickerFocus('from'),
93007
- onBlur: this.handleDayPickerBlur('from')
92871
+ onFocus: function onFocus() {
92872
+ return _this2.handleDayPickerFocus('from');
92873
+ } // onBlur={() => this.handleDayPickerBlur('from')}
92874
+
93008
92875
  }, React__default.createElement("div", null, React__default.createElement(DayPickerInput_1$1, {
92876
+ key: this.state.keyFrom,
93009
92877
  ref: function ref(el) {
93010
- _this6.fromInput = el;
92878
+ _this2.fromInput = el;
93011
92879
  },
93012
92880
  value: from,
93013
92881
  hideOnDayClick: false,
@@ -93018,15 +92886,22 @@
93018
92886
  format: enableTime ? "".concat(format, " HH:mm") : format,
93019
92887
  formatDate: moment$1.formatDate,
93020
92888
  parseDate: moment$1.parseDate,
93021
- onDayChange: this.handleDayChangeFrom,
92889
+ onDayChange: function onDayChange(day) {
92890
+ return _this2.handleDayChange('from', day);
92891
+ },
93022
92892
  placeholder: ''
93023
92893
  }))), React__default.createElement("div", {
93024
92894
  className: toClass,
93025
- onFocus: this.handleDayPickerFocus('to'),
93026
- onBlur: this.handleDayPickerBlur('to')
92895
+ onFocus: function onFocus() {
92896
+ return _this2.handleDayPickerFocus('to');
92897
+ },
92898
+ onBlur: function onBlur() {
92899
+ return _this2.handleDayPickerBlur('to');
92900
+ }
93027
92901
  }, React__default.createElement(DayPickerInput_1$1, {
92902
+ key: this.state.keyTo,
93028
92903
  ref: function ref(el) {
93029
- _this6.toInput = el;
92904
+ _this2.toInput = el;
93030
92905
  },
93031
92906
  value: to,
93032
92907
  hideOnDayClick: false,
@@ -93036,10 +92911,23 @@
93036
92911
  inputProps: toInputProps,
93037
92912
  format: enableTime ? "".concat(format, " HH:mm") : format,
93038
92913
  formatDate: moment$1.formatDate,
93039
- parseDate: moment$1.parseDate,
93040
- onDayChange: this.handleDayChangeTo,
92914
+ parseDate: moment$1.parseDate //onDayChange={(day) => this.handleDayChange('to', day)}
92915
+ ,
93041
92916
  placeholder: ''
93042
92917
  })));
92918
+
92919
+ if (!hasSelector) {
92920
+ content = React__default.createElement(HiFormControl$1, {
92921
+ disabled: disabled,
92922
+ helperIcon: helperIcon,
92923
+ helperText: helperText,
92924
+ errorText: errorText,
92925
+ error: fromError || toError,
92926
+ label: ' '
92927
+ }, content);
92928
+ }
92929
+
92930
+ return content;
93043
92931
  }
93044
92932
  }]);
93045
92933
 
@@ -93048,22 +92936,26 @@
93048
92936
 
93049
92937
  HiDateRangePicker.defaultProps = {
93050
92938
  disabledDays: [],
93051
- disablePastDays: false,
93052
- disableFutureDays: false,
92939
+ disableFutureDays: true,
93053
92940
  staticPosition: false,
93054
92941
  enableTime: false,
93055
- format: 'YYYY-DD-MM',
92942
+ hasSelector: false,
92943
+ format: 'YYYY-MM-DD',
93056
92944
  labelFrom: 'Start',
93057
92945
  labelTo: 'End',
93058
92946
  locale: 'fr-FR',
93059
- minimumDate: new Date(2013, 4, 1),
93060
- // by default 1 May 2013
93061
92947
  translations: {
93062
92948
  today: 'today',
93063
92949
  hour: 'Hour',
93064
92950
  minute: 'Minute',
93065
92951
  month: 'Month',
93066
- year: 'Year'
92952
+ year: 'Year',
92953
+ invalid_format: 'The date format is not valid',
92954
+ to_superior_from: 'Date from cannot be greater than date to',
92955
+ missing_date_from: 'Missing date from',
92956
+ missing_date_to: 'Missing date to',
92957
+ date_superior_max_date: 'Date from cannot be greater than %s',
92958
+ date_inferior_min_date: 'Date from cannot be before than %s'
93067
92959
  }
93068
92960
  };
93069
92961
  HiDateRangePicker.propTypes = {
@@ -93077,25 +92969,20 @@
93077
92969
  */
93078
92970
  disabled: propTypes.bool,
93079
92971
 
93080
- /**
93081
- * Définie les jours non sélectionnables
93082
- */
93083
- disabledDays: propTypes.oneOfType([propTypes.array, propTypes.object, propTypes.instanceOf(Date)]),
93084
-
93085
92972
  /**
93086
92973
  * Uniquement la sélection de date antérieures à aujourd'hui (inclu)
93087
92974
  */
93088
92975
  disableFutureDays: propTypes.bool,
93089
92976
 
93090
92977
  /**
93091
- * Uniquement la sélection de date postérieures à aujourd'hui (inclu)
92978
+ * Ajoute la gestion de l'heure
93092
92979
  */
93093
- disablePastDays: propTypes.bool,
92980
+ enableTime: propTypes.bool,
93094
92981
 
93095
92982
  /**
93096
- * Ajoute la gestion de l'heure
92983
+ * Texte de l'erreur
93097
92984
  */
93098
- enableTime: propTypes.bool,
92985
+ errorText: propTypes.string,
93099
92986
 
93100
92987
  /**
93101
92988
  * Format des dates affichées
@@ -93105,7 +92992,29 @@
93105
92992
  /**
93106
92993
  * Date de début sélectionnée
93107
92994
  */
93108
- from: propTypes.oneOfType([propTypes.instanceOf(Date), propTypes.string]),
92995
+ from: propTypes.instanceOf(Date),
92996
+ //from: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.string]),
92997
+
92998
+ /**
92999
+ * Erreur sur date from
93000
+ */
93001
+ fromError: propTypes.bool,
93002
+
93003
+ /**
93004
+ * @ignore
93005
+ * Si true, on n'enveloppe pas le composant avec un HiFormControl
93006
+ */
93007
+ hasSelector: propTypes.bool,
93008
+
93009
+ /**
93010
+ * Si "true", le texte d'aide s'affichera seulement au clic sur l'icône "Information"
93011
+ */
93012
+ helperIcon: propTypes.bool,
93013
+
93014
+ /**
93015
+ * Texte de l'aide
93016
+ */
93017
+ helperText: propTypes.string,
93109
93018
 
93110
93019
  /**
93111
93020
  * Utilisé pour construire les ids des champs from et to en les suffixant "-from" et "-to"
@@ -93130,7 +93039,7 @@
93130
93039
  /**
93131
93040
  * Date minimale sélectionnable
93132
93041
  */
93133
- minimumDate: propTypes.instanceOf(Date),
93042
+ minimumDate: propTypes.instanceOf(Date).isRequired,
93134
93043
 
93135
93044
  /**
93136
93045
  * Callback à la sélection d'une date
@@ -93143,7 +93052,7 @@
93143
93052
  * @param {string} nom du champs
93144
93053
  * @param {string} nouvelle valeur du champs
93145
93054
  */
93146
- onChange: propTypes.func,
93055
+ onChange: propTypes.func.isRequired,
93147
93056
 
93148
93057
  /**
93149
93058
  * Callback au reset de l'input
@@ -93159,7 +93068,12 @@
93159
93068
  /**
93160
93069
  * Date de fin sélectionnée
93161
93070
  */
93162
- to: propTypes.oneOfType([propTypes.instanceOf(Date), propTypes.string]),
93071
+ to: propTypes.instanceOf(Date),
93072
+
93073
+ /**
93074
+ * Erreur sur date to
93075
+ */
93076
+ toError: propTypes.bool,
93163
93077
 
93164
93078
  /**
93165
93079
  * Traductions
@@ -94060,6 +93974,9 @@
94060
93974
  activeColorNeutral: {
94061
93975
  color: theme.palette.neutral.contrastText,
94062
93976
  backgroundColor: theme.palette.neutral.main
93977
+ },
93978
+ outlined: {
93979
+ border: '1px solid'
94063
93980
  }
94064
93981
  };
94065
93982
  };
@@ -94077,15 +93994,16 @@
94077
93994
  label = props.label,
94078
93995
  color = props.color,
94079
93996
  active = props.active,
93997
+ outlined = props.outlined,
94080
93998
  fontWeight = props.fontWeight,
94081
93999
  style = props.style,
94082
94000
  theme = props.theme,
94083
- other = objectWithoutProperties(props, ["classes", "className", "label", "color", "active", "fontWeight", "style", "theme"]);
94001
+ other = objectWithoutProperties(props, ["classes", "className", "label", "color", "active", "outlined", "fontWeight", "style", "theme"]);
94084
94002
 
94085
94003
  var isHiColor = ['primary', 'secondary', 'positive', 'negative', 'middle', 'neutral'].includes(color);
94086
94004
  var isHexColor = !isHiColor && /(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(color);
94087
94005
  return React__default.createElement("div", _extends_1({
94088
- className: classnames(classes.root, (_classNames = {}, defineProperty(_classNames, classes.color, !active), defineProperty(_classNames, classes.activeColor, active), defineProperty(_classNames, classes["activeColor".concat(capitalize(color))], active && isHiColor), defineProperty(_classNames, classes["color".concat(capitalize(color))], !active && isHiColor), _classNames), className),
94006
+ className: classnames(classes.root, (_classNames = {}, defineProperty(_classNames, classes.color, !active), defineProperty(_classNames, classes.activeColor, active), defineProperty(_classNames, classes.outlined, outlined), defineProperty(_classNames, classes["activeColor".concat(capitalize(color))], active && isHiColor), defineProperty(_classNames, classes["color".concat(capitalize(color))], !active && isHiColor), _classNames), className),
94089
94007
  style: _extends_1({}, style, isHexColor && {
94090
94008
  backgroundColor: active ? color : fade(color, 0.08),
94091
94009
  color: active ? theme.palette.getContrastText(color) : color
@@ -94125,11 +94043,17 @@
94125
94043
  /**
94126
94044
  * Label à afficher
94127
94045
  */
94128
- label: propTypes.oneOfType([propTypes.string, propTypes.number, propTypes.node]).isRequired
94046
+ label: propTypes.oneOfType([propTypes.string, propTypes.number, propTypes.node]).isRequired,
94047
+
94048
+ /**
94049
+ * Ajoute une bordure
94050
+ */
94051
+ outlined: propTypes.bool
94129
94052
  };
94130
94053
  HiColoredLabel.defaultProps = {
94131
94054
  active: false,
94132
- color: 'primary'
94055
+ color: 'primary',
94056
+ outlined: false
94133
94057
  };
94134
94058
  var HiColoredLabel$1 = withStyles(styles$o, {
94135
94059
  hiComponent: true,
@@ -98190,6 +98114,7 @@
98190
98114
  fallbackImage = _this$props2.fallbackImage,
98191
98115
  hideCheckbox = _this$props2.hideCheckbox,
98192
98116
  onSelect = _this$props2.onSelect,
98117
+ onKeyDown = _this$props2.onKeyDown,
98193
98118
  indeterminate = _this$props2.indeterminate,
98194
98119
  indeterminateIcon = _this$props2.indeterminateIcon,
98195
98120
  icon = _this$props2.icon,
@@ -98235,12 +98160,14 @@
98235
98160
  }, disabled || {
98236
98161
  onClick: onSelect,
98237
98162
  onMouseEnter: this.setHover(true),
98238
- onMouseLeave: this.setHover(false)
98163
+ onMouseLeave: this.setHover(false),
98164
+ onKeyDown: onKeyDown
98239
98165
  }, {
98240
98166
  style: {
98241
98167
  paddingLeft: "".concat(paddingLeft + level * 32, "px")
98242
98168
  }
98243
98169
  }), !hideCheckbox && !pinned && React__default.createElement(HiCheckbox$1, {
98170
+ tabIndex: onKeyDown ? '-1' : 0,
98244
98171
  checked: selected,
98245
98172
  checkedIcon: checkedIcon,
98246
98173
  classes: {
@@ -98385,6 +98312,11 @@
98385
98312
  */
98386
98313
  onSelect: propTypes.func,
98387
98314
 
98315
+ /**
98316
+ * Fonction de callback à la sélection de l'élément
98317
+ */
98318
+ onKeyDown: propTypes.func,
98319
+
98388
98320
  /**
98389
98321
  * Padding par défaut des éléments
98390
98322
  */
@@ -98830,6 +98762,31 @@
98830
98762
  name: 'HmuiHiSelectableListHierarchic'
98831
98763
  })(HiSelectableListHierarchic);
98832
98764
 
98765
+ var ArrowDropDown = createCommonjsModule(function (module, exports) {
98766
+
98767
+
98768
+
98769
+ Object.defineProperty(exports, "__esModule", {
98770
+ value: true
98771
+ });
98772
+ exports.default = void 0;
98773
+
98774
+ var _react = interopRequireDefault(React__default);
98775
+
98776
+ var _createSvgIcon = interopRequireDefault(createSvgIcon_1);
98777
+
98778
+ var _default = (0, _createSvgIcon.default)(_react.default.createElement(_react.default.Fragment, null, _react.default.createElement("path", {
98779
+ d: "M7 10l5 5 5-5z"
98780
+ }), _react.default.createElement("path", {
98781
+ fill: "none",
98782
+ d: "M0 0h24v24H0z"
98783
+ })), 'ArrowDropDown');
98784
+
98785
+ exports.default = _default;
98786
+ });
98787
+
98788
+ var ArrowDropDownIcon = unwrapExports(ArrowDropDown);
98789
+
98833
98790
  var styles$s = function styles(theme) {
98834
98791
  return {
98835
98792
  root: {
@@ -98896,13 +98853,13 @@
98896
98853
  transform: 'scaleX(1)'
98897
98854
  },
98898
98855
  '&$error': {
98899
- border: "1px solid ".concat(theme.palette.negative.normal),
98856
+ border: "1px solid ".concat(theme.palette.negative.main),
98900
98857
  borderRadius: 2
98901
98858
  }
98902
98859
  }
98903
98860
  },
98904
98861
  disabled: {
98905
- color: "".concat(theme.palette.text.disabled),
98862
+ color: theme.palette.text.disabled,
98906
98863
  '&:before': {
98907
98864
  display: 'none'
98908
98865
  }
@@ -98919,13 +98876,17 @@
98919
98876
  display: 'inline-flex',
98920
98877
  width: '100%'
98921
98878
  }),
98879
+ placeholder: {
98880
+ color: theme.palette.grey[400]
98881
+ },
98922
98882
  icon: {
98923
98883
  transition: theme.transitions.create(['opacity', 'transform'], {
98924
98884
  duration: theme.transitions.duration.shorter
98925
98885
  })
98926
98886
  },
98927
98887
  iconOpen: {
98928
- transform: 'rotate(90deg)'
98888
+ transform: 'rotate(90deg)',
98889
+ color: theme.palette.primary.main
98929
98890
  },
98930
98891
  iconClose: {
98931
98892
  transform: 'rotate(0deg)'
@@ -98936,24 +98897,26 @@
98936
98897
  * @ignore - internal component.
98937
98898
  */
98938
98899
 
98939
- var SelectInput =
98900
+ var _ref$5 = React__default.createElement(ArrowDropDownIcon, null);
98901
+
98902
+ var HiSelectInput =
98940
98903
  /*#__PURE__*/
98941
98904
  function (_React$PureComponent) {
98942
- inherits(SelectInput, _React$PureComponent);
98905
+ inherits(HiSelectInput, _React$PureComponent);
98943
98906
 
98944
- function SelectInput(props) {
98907
+ function HiSelectInput(props) {
98945
98908
  var _this;
98946
98909
 
98947
- classCallCheck(this, SelectInput);
98910
+ classCallCheck(this, HiSelectInput);
98948
98911
 
98949
- _this = possibleConstructorReturn(this, getPrototypeOf(SelectInput).call(this, props));
98912
+ _this = possibleConstructorReturn(this, getPrototypeOf(HiSelectInput).call(this, props));
98950
98913
 
98951
98914
  _this.handleKeyDown = function (event) {
98952
98915
  var key = keycode(event);
98953
98916
 
98954
- if (['up', 'down', 'space'].includes(key)) {
98955
- event.preventDefault();
98956
-
98917
+ if (_this.props.onKeyDown) {
98918
+ _this.props.onKeyDown(event);
98919
+ } else if (key === 'down' || key === 'up') {
98957
98920
  _this.props.onClick();
98958
98921
  } else if (key === 'enter' && _this.props.onSubmit) {
98959
98922
  event.preventDefault();
@@ -98962,18 +98925,58 @@
98962
98925
  }
98963
98926
  };
98964
98927
 
98928
+ _this.handleKeyDownReset = function (event) {
98929
+ var key = keycode(event);
98930
+
98931
+ if (key === 'enter' || key === 'space') {
98932
+ _this.handleReset(event);
98933
+
98934
+ event.stopPropagation();
98935
+ event.preventDefault();
98936
+ }
98937
+ };
98938
+
98965
98939
  _this.handleClick = function (event) {
98966
98940
  if ((!_this.resetIcon || !_this.resetIcon.contains(event.target)) && _this.props.onClick) {
98967
98941
  _this.props.onClick(event);
98968
98942
  }
98969
98943
  };
98970
98944
 
98945
+ _this.handleReset = function (event) {
98946
+ _this.props.onReset(event);
98947
+
98948
+ if (_this.input) {
98949
+ _this.input.focus();
98950
+ }
98951
+ };
98952
+
98953
+ _this.handleBlur = function (event) {
98954
+ if ((!_this.input || !_this.input.contains(event.relatedTarget)) && _this.props.onBlur) {
98955
+ _this.props.onBlur(event);
98956
+ } else {
98957
+ if (_this.input && (!_this.resetIcon || !_this.resetIcon.contains(event.relatedTarget))) {
98958
+ _this.input.focus();
98959
+ }
98960
+ }
98961
+ };
98962
+
98963
+ _this.handleRef = function (el) {
98964
+ _this.input = el;
98965
+
98966
+ if (_this.props.refElement) {
98967
+ _this.props.refElement(el);
98968
+ }
98969
+ };
98970
+
98971
98971
  _this.handleKeyDown = _this.handleKeyDown.bind(assertThisInitialized(assertThisInitialized(_this)));
98972
98972
  _this.handleClick = _this.handleClick.bind(assertThisInitialized(assertThisInitialized(_this)));
98973
+ _this.handleBlur = _this.handleBlur.bind(assertThisInitialized(assertThisInitialized(_this)));
98974
+ _this.handleRef = _this.handleRef.bind(assertThisInitialized(assertThisInitialized(_this)));
98975
+ _this.handleReset = _this.handleReset.bind(assertThisInitialized(assertThisInitialized(_this)));
98973
98976
  return _this;
98974
98977
  }
98975
98978
 
98976
- createClass(SelectInput, [{
98979
+ createClass(HiSelectInput, [{
98977
98980
  key: "render",
98978
98981
  value: function render() {
98979
98982
  var _classNames,
@@ -98991,16 +98994,14 @@
98991
98994
  focused = _this$props.focused,
98992
98995
  error = _this$props.error,
98993
98996
  id = _this$props.id,
98994
- refElement = _this$props.refElement,
98995
- theme = _this$props.theme; // On utilise classNames pour variabiliser les styles et merge les classes appliquées
98997
+ placeholder = _this$props.placeholder; // On utilise classNames pour variabiliser les styles et merge les classes appliquées
98996
98998
 
98997
98999
  var rootClass = classnames(classes.root, classes.inkbar, classes.underline, (_classNames = {}, defineProperty(_classNames, classes.disabled, disabled), defineProperty(_classNames, classes.focused, focused), defineProperty(_classNames, classes.error, error && !focused), _classNames));
98998
99000
  var iconClass = classnames(classes.icon, (_classNames2 = {}, defineProperty(_classNames2, classes.iconOpen, open), defineProperty(_classNames2, classes.iconClose, !open), _classNames2));
98999
- var render = noButton ? React__default.createElement("div", {
99001
+ return noButton ? React__default.createElement("div", {
99000
99002
  id: id,
99001
99003
  className: rootClass,
99002
99004
  onClick: onClick,
99003
- disabled: disabled,
99004
99005
  onMouseEnter: this.props.onMouseEnter,
99005
99006
  onMouseLeave: this.props.onMouseLeave,
99006
99007
  onKeyDown: this.handleKeyDown,
@@ -99008,59 +99009,54 @@
99008
99009
  onBlur: this.props.onBlur,
99009
99010
  role: "button",
99010
99011
  tabIndex: "0",
99011
- ref: function ref(el) {
99012
- if (refElement) refElement(el);
99013
- }
99012
+ ref: this.handleRef
99014
99013
  }, React__default.createElement("span", {
99015
- className: classes.label
99016
- }, value), React__default.createElement(HiIcon$1, {
99017
- className: iconClass,
99018
- icon: "arrow_drop_down"
99014
+ className: classnames(classes.label, defineProperty({}, classes.placeholder, value === undefined))
99015
+ }, value || placeholder), React__default.createElement(ArrowDropDownIcon, {
99016
+ className: iconClass
99019
99017
  })) : React__default.createElement(ButtonBase$2, {
99020
99018
  id: id,
99021
- classes: {
99022
- root: rootClass
99023
- },
99019
+ className: rootClass,
99024
99020
  onClick: this.handleClick,
99025
99021
  disabled: disabled,
99026
99022
  onMouseEnter: this.props.onMouseEnter,
99027
99023
  onMouseLeave: this.props.onMouseLeave,
99028
99024
  onKeyDown: this.handleKeyDown,
99029
99025
  onFocus: this.props.onFocus,
99030
- onBlur: this.props.onBlur,
99031
- buttonRef: function buttonRef(el) {
99032
- if (refElement) refElement(el);
99033
- }
99026
+ onBlur: this.handleBlur,
99027
+ buttonRef: this.handleRef
99034
99028
  }, React__default.createElement("span", {
99035
- className: classes.label
99036
- }, value), onReset && focused && React__default.createElement("div", {
99029
+ className: classnames(classes.label, defineProperty({}, classes.placeholder, value === undefined))
99030
+ }, value || placeholder), onReset && focused && React__default.createElement("div", {
99037
99031
  ref: function ref(el) {
99038
99032
  _this2.resetIcon = el;
99039
99033
  }
99040
99034
  }, React__default.createElement(HiIcon$1, {
99041
99035
  icon: "close",
99042
- size: 24,
99043
- color: theme.palette.neutral.main,
99044
- onClick: onReset
99045
- })), React__default.createElement(HiIcon$1, {
99046
- className: iconClass,
99047
- icon: "arrow_drop_down"
99048
- }));
99049
- return render;
99036
+ size: 20,
99037
+ color: "neutral",
99038
+ onClick: this.handleReset,
99039
+ onKeyDown: this.handleKeyDownReset,
99040
+ tabIndex: 0
99041
+ })), React__default.createElement(Icon$2, {
99042
+ classes: {
99043
+ root: iconClass
99044
+ }
99045
+ }, _ref$5));
99050
99046
  }
99051
99047
  }]);
99052
99048
 
99053
- return SelectInput;
99049
+ return HiSelectInput;
99054
99050
  }(React__default.PureComponent);
99055
99051
 
99056
- SelectInput.defaultProps = {
99052
+ HiSelectInput.defaultProps = {
99057
99053
  disabled: false,
99058
99054
  open: false,
99059
99055
  focused: false,
99060
99056
  noButton: false,
99061
99057
  error: false
99062
99058
  };
99063
- SelectInput.propTypes = {
99059
+ HiSelectInput.propTypes = {
99064
99060
  /**
99065
99061
  * Useful to extend the style applied to components.
99066
99062
  */
@@ -99108,12 +99104,17 @@
99108
99104
  onFocus: propTypes.func,
99109
99105
 
99110
99106
  /**
99111
- * Fonction de callback appelée lorsqu'on survole le champs
99107
+ * Fonction de callback à la pression de touche
99108
+ */
99109
+ onKeyDown: propTypes.func,
99110
+
99111
+ /**
99112
+ * Fonction de callback au survol de l'input
99112
99113
  */
99113
99114
  onMouseEnter: propTypes.func,
99114
99115
 
99115
99116
  /**
99116
- * Fonction de callback appelée lorsque le curseur quitte le champs
99117
+ * Fonction de callback à la sortie du survol de l'input
99117
99118
  */
99118
99119
  onMouseLeave: propTypes.func,
99119
99120
 
@@ -99132,6 +99133,11 @@
99132
99133
  */
99133
99134
  open: propTypes.bool,
99134
99135
 
99136
+ /**
99137
+ * Placeholder
99138
+ */
99139
+ placeholder: propTypes.string,
99140
+
99135
99141
  /**
99136
99142
  * Use that property to pass a ref callback to the native component.
99137
99143
  */
@@ -99142,11 +99148,10 @@
99142
99148
  */
99143
99149
  value: propTypes.oneOfType([propTypes.string, propTypes.number, propTypes.node])
99144
99150
  };
99145
- var SelectInput$1 = withStyles(styles$s, {
99151
+ var HiSelectInput$1 = withStyles(styles$s, {
99146
99152
  hiComponent: true,
99147
- name: 'HmuiSelectInput',
99148
- withTheme: true
99149
- })(SelectInput);
99153
+ name: 'HmuiHiSelectInput'
99154
+ })(HiSelectInput);
99150
99155
 
99151
99156
  var styles$t = function styles(theme) {
99152
99157
  return {
@@ -99162,14 +99167,24 @@
99162
99167
  popperWidth: {
99163
99168
  width: '100% !important'
99164
99169
  },
99170
+ popperRightAlign: {
99171
+ right: 0,
99172
+ left: 'unset!important'
99173
+ },
99165
99174
  paper: {
99166
99175
  borderRadius: '0px 2px',
99167
- maxHeight: 440,
99176
+ maxHeight: 480,
99168
99177
  transition: 'none !important'
99169
99178
  },
99170
99179
  labelIcon: {
99171
99180
  marginRight: 10
99172
99181
  },
99182
+ labelImg: {
99183
+ height: 18,
99184
+ width: 'auto',
99185
+ margin: '0 4px',
99186
+ verticalAlign: 'middle'
99187
+ },
99173
99188
  selectIconLabel: _extends_1({
99174
99189
  whiteSpace: 'nowrap',
99175
99190
  overflow: 'hidden',
@@ -99178,6 +99193,15 @@
99178
99193
  }, theme.typography.b1, {
99179
99194
  display: 'inline-flex',
99180
99195
  width: '100%'
99196
+ }),
99197
+ selectImgLabel: _extends_1({
99198
+ whiteSpace: 'nowrap',
99199
+ overflow: 'hidden',
99200
+ textOverflow: 'ellipsis',
99201
+ paddingRight: 16
99202
+ }, theme.typography.b1, {
99203
+ display: 'inline-flex',
99204
+ width: '100%'
99181
99205
  })
99182
99206
  };
99183
99207
  };
@@ -99191,9 +99215,8 @@
99191
99215
  * - prise en compte du type des éléments (text, image, icon, ...)
99192
99216
  *
99193
99217
  * Ce composant réuni les sous-composants
99194
- * - SelectInput : affiche l'élément dans le formulaire
99195
- * - HiSearchField : intègre une barre de recherche dans le Popper,
99196
- * il filtre la liste des suggestions
99218
+ * - HiSelectInput : affiche l'élément dans le formulaire
99219
+ * - HiSearchField : intègre une barre de recherche dans le Popper, il filtre la liste des suggestions
99197
99220
  * - HiSelectableList : affiche la liste des suggestions selon le type des éléments
99198
99221
  */
99199
99222
 
@@ -99202,12 +99225,12 @@
99202
99225
  function (_React$PureComponent) {
99203
99226
  inherits(HiSelect, _React$PureComponent);
99204
99227
 
99205
- function HiSelect(_props) {
99228
+ function HiSelect(props) {
99206
99229
  var _this;
99207
99230
 
99208
99231
  classCallCheck(this, HiSelect);
99209
99232
 
99210
- _this = possibleConstructorReturn(this, getPrototypeOf(HiSelect).call(this, _props));
99233
+ _this = possibleConstructorReturn(this, getPrototypeOf(HiSelect).call(this, props));
99211
99234
 
99212
99235
  _this.handleClick = function () {
99213
99236
  if (_this.state.open) {
@@ -99217,101 +99240,51 @@
99217
99240
  open: true
99218
99241
  });
99219
99242
 
99220
- var options = _this.props.options.slice();
99221
-
99222
- _this.handleSuggestions(options);
99223
-
99224
- if (_this.props.onClick) {
99225
- _this.props.onClick();
99226
- } // Gestion du focus
99243
+ _this.handleSuggestions(_this.props.options);
99227
99244
 
99245
+ if (_this.props.onClick) _this.props.onClick(); // Gestion du focus
99228
99246
 
99229
99247
  if (!_this.props.searchable) {
99230
- // sinon focus sur le dernier élément selectionné
99231
- _this.focusOnSelectedItem();
99248
+ // sinon focus sur le premier élément de la liste
99249
+ _this.focusOnFirstItem();
99232
99250
  }
99233
99251
  }
99234
99252
  };
99235
99253
 
99236
- _this.buildHierarchyTrees = function (props) {
99237
- // Construct two associative arrays
99238
- // hierarchy[parentId] => children
99239
- // hierarchySelected[parentId] => selected children
99240
- var hierarchy = {};
99241
- var hierarchySelected = {};
99242
- var value = props.value || [];
99243
- if (!Array.isArray(value)) value = [props.value];
99244
- props.options.forEach(function (option) {
99245
- if (option.hasChildren === true && !hierarchy.hasOwnProperty(option.id)) {
99246
- hierarchy[option.id] = [];
99247
- hierarchySelected[option.id] = [];
99248
- } else if (option.hasOwnProperty('parentId')) {
99249
- hierarchy[option.parentId].push(option.id);
99250
-
99251
- if (value.includes(option.id)) {
99252
- hierarchySelected[option.parentId].push(option.id);
99253
- }
99254
- }
99255
- });
99256
- return {
99257
- hierarchy: hierarchy,
99258
- hierarchySelected: hierarchySelected
99259
- };
99260
- };
99261
-
99262
- _this.focusOnSelectedItem = function () {
99263
- // On récupère la div parent "overlay"
99254
+ _this.focusOnFirstItem = function () {
99264
99255
  var overlay = require$$11.findDOMNode(_this.overlay);
99265
- var multiple = _this.props.multiple;
99266
- var value = _this.props.value;
99267
- var selectedIdList = Array.isArray(value) ? value : [value];
99268
99256
  setTimeout(function () {
99269
- var focused = false; // Si un ou plusieurs items sont selectionnés, on focus sur le dernier
99270
-
99271
- if (selectedIdList.length > 0) {
99272
- var itemSelected = overlay.querySelector("[data-id=\"".concat(selectedIdList[selectedIdList.length - 1], "\"]"));
99273
-
99274
- if (itemSelected && itemSelected.parentElement.tagName === 'LI') {
99275
- itemSelected.parentElement.focus();
99276
- focused = true;
99277
- }
99278
- } // Si pas d'item selectionné, ou pas visible (en cas de recherche), focus sur le premier
99279
-
99280
-
99281
- if (selectedIdList.length === 0 || !focused) {
99282
- // On recupère tous les items
99283
- var items = overlay.getElementsByTagName('li');
99284
- var itemToFocus = items[0]; // Si select multiple, et qu'au moins un selectionné, focus sur le 2e item
99285
-
99286
- if (multiple && selectedIdList.length > 0) {
99287
- itemToFocus = items[1];
99288
- }
99289
-
99290
- if (itemToFocus) {
99291
- itemToFocus.focus();
99292
- }
99293
- }
99257
+ var item = overlay.getElementsByTagName('li')[0];
99258
+ item.focus();
99294
99259
  }, 1);
99295
99260
  };
99296
99261
 
99297
99262
  _this.handleKeyDown = function (event) {
99298
99263
  var nextItem;
99264
+ var key = keycode(event);
99299
99265
 
99300
- if (event.key === 'ArrowDown') {
99266
+ if (key === 'down') {
99267
+ event.preventDefault();
99301
99268
  nextItem = getNextItemSelectable(document.activeElement, 'down');
99302
- } else if (event.key === 'ArrowUp') {
99269
+ } else if (key === 'up') {
99270
+ event.preventDefault();
99303
99271
  nextItem = getNextItemSelectable(document.activeElement, 'up');
99304
- } else if (event.key === 'Tab') {
99305
- /* if (!this.props.staticPosition) {
99306
- document.body.style.overflow = 'auto';
99307
- } */
99272
+ } else if (key === 'tab' || key === 'esc') {
99308
99273
  _this.setState({
99309
99274
  open: false
99310
99275
  });
99311
- } else if (event.key === 'Escape') {
99312
- _this.setState({
99313
- open: false
99276
+ } else if (key === 'space' || key === 'enter' && !_this.props.multiple) {
99277
+ event.preventDefault();
99278
+
99279
+ var item = _this.props.options.find(function (elem) {
99280
+ return String(elem.id) === event.target.id;
99314
99281
  });
99282
+
99283
+ _this.handleSelect(null, item);
99284
+ } else if (key === 'enter' && _this.props.multiple) {
99285
+ event.preventDefault();
99286
+
99287
+ _this.handleClose();
99315
99288
  }
99316
99289
 
99317
99290
  if (nextItem) {
@@ -99320,10 +99293,14 @@
99320
99293
  };
99321
99294
 
99322
99295
  _this.handleKeyDownSearch = function (event) {
99323
- if (_this.overlay && (event.key === 'ArrowDown' || event.key === 'ArrowUp')) {
99324
- _this.focusOnSelectedItem();
99325
- } else if (event.key === 'Enter' && _this.props.onSubmit) {
99326
- _this.props.onSubmit(event);
99296
+ var key = keycode(event);
99297
+
99298
+ if (_this.overlay && (key === 'down' || key === 'up')) {
99299
+ _this.focusOnFirstItem();
99300
+ } else if (_this.overlay && key === 'esc' || key === 'enter') {
99301
+ event.preventDefault();
99302
+
99303
+ _this.handleClose();
99327
99304
  }
99328
99305
  };
99329
99306
 
@@ -99340,426 +99317,273 @@
99340
99317
  };
99341
99318
 
99342
99319
  _this.handleClose = function () {
99320
+ _this.setState({
99321
+ open: false
99322
+ });
99323
+
99343
99324
  if (_this.props.onClose) {
99344
99325
  _this.props.onClose();
99345
99326
  }
99346
99327
 
99347
- if (_this.selectInputElement) {
99348
- _this.selectInputElement.focus();
99328
+ if (_this.inputEl) {
99329
+ _this.inputEl.focus();
99349
99330
  }
99350
-
99351
- _this.setState({
99352
- open: false
99353
- });
99354
99331
  };
99355
99332
 
99356
99333
  _this.handleClickAway = function (event) {
99357
99334
  // Au clic sur le bouton, on laisse le handleClick fermer le select
99358
- if (!_this.selectInputElement.contains(event.target)) {
99335
+ if (!_this.inputEl.contains(event.target)) {
99359
99336
  _this.handleClose(event);
99360
99337
  }
99361
99338
  };
99362
99339
 
99363
99340
  _this.handleSelect = function (event, item) {
99364
99341
  var _this$props = _this.props,
99342
+ hasAll = _this$props.hasAll,
99365
99343
  multiple = _this$props.multiple,
99366
- value = _this$props.value,
99367
99344
  onChange = _this$props.onChange,
99368
99345
  options = _this$props.options,
99369
- hierarchic = _this$props.hierarchic,
99370
- pinnedItem = _this$props.pinnedItem;
99371
- var _this$state = _this.state,
99372
- hierarchySelected = _this$state.hierarchySelected,
99373
- hierarchy = _this$state.hierarchy,
99374
- nbOptions = _this$state.nbOptions;
99346
+ value = _this$props.value;
99375
99347
 
99376
- var hiSelected = _extends_1({}, hierarchySelected);
99377
-
99378
- if (multiple) {
99379
- var valueList = value;
99380
-
99381
- if (item.id === '_all') {
99382
- if (valueList.length === nbOptions) {
99383
- valueList = [];
99384
-
99385
- if (hierarchic) {
99386
- // if hierarchic select => empty associative array of selected children
99387
- Object.keys(hiSelected).forEach(function (key) {
99388
- hiSelected[key] = [];
99389
- });
99390
- }
99391
- } else {
99392
- options.forEach(function (option) {
99393
- if (option.hasChildren !== true && !valueList.includes(option.id) && option.id !== '_all') {
99394
- valueList.push(option.id);
99395
- } else if (option.hasChildren === true) {
99396
- // if hierarchic select => fill associative array of selected children
99397
- hiSelected[option.id] = hierarchy[option.id];
99398
- }
99399
- });
99400
- }
99401
- } else if (valueList.includes(item.id) || item.hasChildren === true && hierarchySelected[item.id].length === hierarchy[item.id].length) {
99402
- // item déjà sélectionné => on le déselectionne
99403
- if (item.hasChildren !== true) {
99404
- valueList = valueList.filter(function (val) {
99405
- return val !== item.id;
99406
- });
99407
- }
99348
+ if (!multiple) {
99349
+ // single value
99350
+ _this.handleClose();
99408
99351
 
99409
- if (item.hasChildren === true) {
99410
- // remove all children
99411
- valueList = valueList.filter(function (val) {
99412
- return !_this.state.hierarchy[item.id].includes(val);
99413
- });
99414
- hiSelected[item.id] = [];
99415
- } else if (item.hasOwnProperty('parentId')) {
99416
- // Si item est un enfant on l'enlève du tableau associatif des
99417
- // elmts sélectionnés
99418
- hiSelected[item.parentId].splice(hiSelected[item.parentId].indexOf(item.id), 1);
99419
- }
99352
+ onChange(event, item.id, item);
99353
+ } else if (hasAll && item.id === '_all') {
99354
+ if (value.length === options.length) {
99355
+ // unselect _all options
99356
+ onChange(event, [], item);
99420
99357
  } else {
99421
- if (pinnedItem && item.id === pinnedItem.id) {
99422
- Object.keys(hiSelected).map(function (parentItemId) {
99423
- hiSelected[parentItemId] = [];
99424
- return true;
99425
- });
99426
- valueList = [item.id];
99427
- } else {
99428
- // item non sélectionné => on le sélectionne
99429
- if (item.hasChildren !== true) valueList.push(item.id);
99430
-
99431
- if (pinnedItem && valueList.includes(pinnedItem.id)) {
99432
- valueList.splice(valueList.indexOf(pinnedItem.id), 1);
99433
- }
99434
- }
99435
-
99436
- if (item.hasChildren === true) {
99437
- // Si item parent => on ajoute tous les enfants
99438
- // Ou on les supprime s'ils sont déjà tous sélectionnés (dans une liste filtrée)
99439
- var idsInSuggestions = [];
99440
-
99441
- _this.state.suggestions.forEach(function (suggestion) {
99442
- if (_this.state.hierarchy[item.id].includes(suggestion.id)) {
99443
- idsInSuggestions.push(suggestion.id);
99444
- }
99445
- }); // if(hierarchySelected[item.id].length > 0) {}
99446
-
99447
-
99448
- var allChildrenSuggestionsSelected = true;
99449
- idsInSuggestions.forEach(function (id) {
99450
- if (!hierarchySelected[item.id].includes(id)) {
99451
- allChildrenSuggestionsSelected = false;
99452
- }
99453
- });
99454
-
99455
- if (allChildrenSuggestionsSelected === true) {
99456
- // On supprime les enfants car déjà tous sélectionnés
99457
- idsInSuggestions.forEach(function (id) {
99458
- valueList.splice(valueList.indexOf(id), 1);
99459
- hiSelected[item.id].splice(hiSelected[item.id].indexOf(id), 1);
99460
- });
99461
- } else {
99462
- // On ajoute tous les enfants filtrés au éléments sélectionnés
99463
- valueList = arrayUnique(valueList.concat(idsInSuggestions));
99464
- hiSelected[item.id] = arrayUnique(hiSelected[item.id].concat(idsInSuggestions));
99465
- }
99466
-
99467
- _this.setState({
99468
- hierarchySelected: hiSelected
99469
- });
99470
- } else if (item.hasOwnProperty('parentId')) {
99471
- // Si item est un enfant on l'ajoute du tableau associatif des
99472
- // elmts sélectionnés
99473
- hiSelected[item.parentId].push(item.id);
99474
- }
99358
+ // select _all options
99359
+ onChange(event, options.map(function (option) {
99360
+ return option.id;
99361
+ }), item);
99475
99362
  }
99476
-
99477
- _this.setState({
99478
- hierarchySelected: hiSelected
99479
- });
99480
-
99481
- onChange(event, valueList, item);
99363
+ } else if (value.includes(item.id)) {
99364
+ // unselect item
99365
+ onChange(event, value.filter(function (id) {
99366
+ return id !== item.id;
99367
+ }), item);
99482
99368
  } else {
99483
- onChange(event, item.id, item);
99484
-
99485
- _this.handleClose();
99369
+ onChange(event, toConsumableArray(value).concat([item.id]), item);
99486
99370
  }
99487
99371
  };
99488
99372
 
99489
99373
  _this.handleSuggestions = function (suggestions) {
99490
99374
  var _this$props2 = _this.props,
99491
- options = _this$props2.options,
99492
99375
  hasAll = _this$props2.hasAll,
99493
99376
  iconAll = _this$props2.iconAll,
99494
- translations = _this$props2.translations,
99495
- multiple = _this$props2.multiple;
99377
+ translations = _this$props2.translations;
99496
99378
 
99497
99379
  if (suggestions.length === 0) {
99498
- // Handle No Result
99499
- // FIX to remove all item
99500
- suggestions = [];
99501
- suggestions.push({
99502
- id: '_no_result',
99503
- type: 'text',
99504
- disabled: true,
99505
- centered: true,
99506
- checkbox: false,
99507
- label: translations.no_result_match
99380
+ // Add '_no_result' suggestion
99381
+ _this.setState(function (prevState) {
99382
+ return _extends_1({}, prevState, {
99383
+ suggestions: [{
99384
+ id: '_no_result',
99385
+ type: 'text',
99386
+ disabled: true,
99387
+ centered: true,
99388
+ hideCheckbox: true,
99389
+ label: translations.no_result_match
99390
+ }]
99391
+ });
99508
99392
  });
99509
- } else if (hasAll && suggestions.length > 0 && suggestions.length === options.length && multiple === true) {
99510
- // Handle 'All'
99511
- if (suggestions.filter(function (suggestion) {
99512
- return suggestion.id === '_all';
99513
- }).length === 0) {
99514
- var allItem = {
99393
+ } else {
99394
+ _this.setState({
99395
+ suggestions: toConsumableArray(hasAll ? [_extends_1({
99515
99396
  id: '_all',
99516
- icon: iconAll,
99517
99397
  label: translations.all
99518
- };
99519
-
99520
- if (iconAll !== false) {
99521
- allItem.type = 'icon';
99522
- }
99523
-
99524
- suggestions.unshift(allItem);
99525
- }
99398
+ }, iconAll && {
99399
+ type: 'icon',
99400
+ icon: iconAll
99401
+ })] : []).concat(toConsumableArray(suggestions))
99402
+ });
99526
99403
  }
99527
-
99528
- _this.setState({
99529
- suggestions: suggestions
99530
- });
99531
99404
  };
99532
99405
 
99533
- _this.handleRequestDelete = function (evt) {
99534
- evt.stopPropagation();
99535
-
99536
- _this.props.onChange(_this.props.name, []);
99406
+ _this.handleScroll = function (e) {
99407
+ if (e.target.scrollHeight - e.target.clientHeight - e.target.scrollTop < 15) {
99408
+ _this.props.onScrollReachBottom();
99409
+ }
99537
99410
  };
99538
99411
 
99539
- _this.handleScroll = function (event) {
99540
- if (!_this.props.loadingMoreResults && _this.props.hasMore && event.target.scrollHeight - event.target.clientHeight - event.target.scrollTop < 15) {
99541
- _this.props.loadMoreResults(_this.state.resultsPageNumber + 1);
99412
+ _this.handleSearch = function (e, inputValue) {
99413
+ var searchValue = inputValue && e.target.value ? inputValue : e.target.value;
99542
99414
 
99543
- _this.setState(function (prevState) {
99544
- return {
99545
- resultsPageNumber: prevState.resultsPageNumber + 1
99546
- };
99415
+ if (_this.props.onSearch) {
99416
+ _this.props.onSearch(e, searchValue);
99417
+ } else {
99418
+ _this.setState({
99419
+ searchValue: searchValue
99547
99420
  });
99548
99421
  }
99549
99422
  };
99550
99423
 
99551
- _this.state = {
99552
- open: false,
99553
- focused: false,
99554
- suggestions: [],
99555
- hierarchySelected: {},
99556
- hierarchy: {},
99557
- nbOptions: 0,
99558
- dynamic: _props.dynamic || false,
99559
- resultsPageNumber: 1
99560
- }; // Check if value is in options
99561
-
99562
- var valueInOptions = false;
99563
- var _val = _props.value; // No options provided.
99564
-
99565
- if (!_props.options.length || !_val || !_val.length) {
99566
- valueInOptions = true;
99567
- } else {
99568
- // Check if an option match value prop.
99569
- _props.options.forEach(function (item) {
99570
- if (!valueInOptions && _val.indexOf(item.id) !== -1) {
99571
- valueInOptions = true;
99572
- }
99573
- });
99574
-
99575
- if (!valueInOptions && _props.pinnedItem) {
99576
- if (_props.value.indexOf(_props.pinnedItem.id) >= 0) {
99577
- valueInOptions = true;
99424
+ _this.handleSearchReset = function () {
99425
+ _this.handleSearch({
99426
+ target: {
99427
+ value: ''
99578
99428
  }
99579
- }
99580
- }
99581
-
99582
- if (!valueInOptions) {
99583
- throw new Error('prop value provided does not match any option.');
99584
- }
99429
+ }, '');
99430
+ };
99585
99431
 
99586
- if (_props.hierarchic === true && _props.options.length > 1) {
99587
- var hierarchyTrees = _this.buildHierarchyTrees(_props);
99432
+ _this.buildSelectProps = function (options) {
99433
+ var value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
99434
+ var search = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
99435
+ var loading = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
99436
+
99437
+ // build item list
99438
+ var itemList = toConsumableArray(loading ? [{
99439
+ id: '_loading',
99440
+ type: 'loader',
99441
+ disabled: true,
99442
+ centered: true,
99443
+ hideCheckbox: true,
99444
+ label: 'loading'
99445
+ }] : []).concat(toConsumableArray(search !== '' ? toConsumableArray(options.filter(function (item) {
99446
+ return item.label && foldAccents(item.label.toString().toLowerCase()).search(foldAccents(search.toLowerCase())) !== -1;
99447
+ })) : toConsumableArray(_this.props.hasAll ? [_extends_1({
99448
+ id: '_all',
99449
+ label: _this.props.translations.all
99450
+ }, _this.props.iconAll && {
99451
+ type: 'icon',
99452
+ icon: _this.props.iconAll
99453
+ })] : []).concat(toConsumableArray(options))));
99588
99454
 
99589
- _this.state.hierarchy = hierarchyTrees.hierarchy;
99590
- _this.state.hierarchySelected = hierarchyTrees.hierarchySelected;
99591
- }
99455
+ return {
99456
+ itemList: itemList,
99457
+ inputValue: _this.buildInputValue(options, value, loading)
99458
+ };
99459
+ };
99592
99460
 
99593
- if (_props.options.length > 0) {
99594
- // Get real options number (parent & _all are not real options)
99595
- var optionsLength = 0;
99461
+ _this.buildInputValue = function (options) {
99462
+ var value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
99463
+ var loading = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
99464
+ var _this$props3 = _this.props,
99465
+ classes = _this$props3.classes,
99466
+ hasAll = _this$props3.hasAll,
99467
+ translations = _this$props3.translations,
99468
+ type = _this$props3.type; // build input value
99469
+
99470
+ var inputValue;
99471
+
99472
+ if (loading && value.length === 1) {
99473
+ inputValue = translations.one_item_selected;
99474
+ } else if (hasAll && options.length === value.length) {
99475
+ inputValue = translations.all;
99476
+ value.unshift('_all');
99477
+ } else if (value.length > 1) {
99478
+ inputValue = translations.n_items_selected.replace('%s', value.length);
99479
+ } else if (value.length === 1) {
99480
+ var item = options.find(function (o) {
99481
+ return o.id === value[0];
99482
+ });
99596
99483
 
99597
- _props.options.forEach(function (option) {
99598
- if (option.hasChildren !== true && option.id !== '_all') {
99599
- optionsLength += 1;
99484
+ if (item === undefined) {
99485
+ inputValue = translations.one_item_selected;
99486
+ } else if (type === 'icon' || item.type === 'icon') {
99487
+ inputValue = React__default.createElement("span", {
99488
+ className: classes.selectIconLabel
99489
+ }, React__default.createElement(HiIcon$1, {
99490
+ className: classes.labelIcon,
99491
+ icon: item.icon
99492
+ }), item.label);
99493
+ } else if (type === 'image' || item.type === 'image') {
99494
+ inputValue = React__default.createElement("span", {
99495
+ className: classes.selectIconLabel
99496
+ }, React__default.createElement("img", {
99497
+ className: classes.labelImg,
99498
+ src: item.img,
99499
+ alt: item.label
99500
+ }), item.label);
99501
+ } else {
99502
+ inputValue = item.label;
99600
99503
  }
99601
- });
99504
+ }
99602
99505
 
99603
- _this.state.nbOptions = optionsLength;
99604
- } else if (!_props.dynamic) {
99605
- _this.state.dynamic = true;
99606
- }
99506
+ return inputValue;
99507
+ };
99607
99508
 
99608
- _this.handleSelect = _this.handleSelect.bind(assertThisInitialized(assertThisInitialized(_this)));
99509
+ _this.state = {
99510
+ open: false,
99511
+ focused: false,
99512
+ searchValue: props.searchValue ? undefined : '',
99513
+ suggestions: props.options
99514
+ };
99609
99515
  _this.handleClick = _this.handleClick.bind(assertThisInitialized(assertThisInitialized(_this)));
99610
99516
  _this.handleClose = _this.handleClose.bind(assertThisInitialized(assertThisInitialized(_this)));
99611
99517
  _this.handleClickAway = _this.handleClickAway.bind(assertThisInitialized(assertThisInitialized(_this)));
99612
- _this.handleRequestDelete = _this.handleRequestDelete.bind(assertThisInitialized(assertThisInitialized(_this)));
99613
- _this.handleSuggestions = _this.handleSuggestions.bind(assertThisInitialized(assertThisInitialized(_this)));
99614
99518
  _this.handleFocus = _this.handleFocus.bind(assertThisInitialized(assertThisInitialized(_this)));
99615
99519
  _this.handleBlur = _this.handleBlur.bind(assertThisInitialized(assertThisInitialized(_this)));
99616
- _this.handleScroll = _this.handleScroll.bind(assertThisInitialized(assertThisInitialized(_this)));
99520
+ _this.handleSearch = _this.handleSearch.bind(assertThisInitialized(assertThisInitialized(_this)));
99521
+ _this.handleSearchReset = _this.handleSearchReset.bind(assertThisInitialized(assertThisInitialized(_this)));
99522
+ _this.handleSelect = _this.handleSelect.bind(assertThisInitialized(assertThisInitialized(_this)));
99523
+ _this.handleSuggestions = _this.handleSuggestions.bind(assertThisInitialized(assertThisInitialized(_this)));
99524
+ _this.getInputElement = _this.getInputElement.bind(assertThisInitialized(assertThisInitialized(_this)));
99617
99525
  return _this;
99618
99526
  }
99619
99527
 
99620
99528
  createClass(HiSelect, [{
99621
- key: "componentWillReceiveProps",
99622
- value: function componentWillReceiveProps(nextProps) {
99623
- if (typeof this.props.onSearch !== 'undefined' && this.props.options && this.props.options.length > 0) {
99624
- this.handleSuggestions(nextProps.options);
99625
- var optionsLength = 0;
99626
- nextProps.options.forEach(function (option) {
99627
- if (option.hasChildren !== true && option.id !== '_all') {
99628
- optionsLength += 1;
99629
- }
99630
- });
99631
- this.setState({
99632
- nbOptions: optionsLength
99633
- });
99634
- }
99529
+ key: "getInputElement",
99530
+ value: function getInputElement(el) {
99531
+ this.searchField = el;
99635
99532
 
99636
- if (nextProps.hierarchic === true && nextProps.options.length > 1) {
99637
- var hierarchyTrees = this.buildHierarchyTrees(nextProps);
99638
- this.setState({
99639
- hierarchy: hierarchyTrees.hierarchy,
99640
- hierarchySelected: hierarchyTrees.hierarchySelected
99641
- });
99642
- }
99643
- }
99644
- }, {
99645
- key: "handleReset",
99646
- value: function handleReset(event) {
99647
- if (this.props.onReset) {
99648
- event.stopPropagation();
99649
- this.props.onReset(event);
99533
+ if (this.props.inputRef) {
99534
+ this.props.inputRef(this.searchField);
99650
99535
  }
99651
99536
  }
99652
99537
  }, {
99653
99538
  key: "render",
99654
99539
  value: function render() {
99655
- var _this2 = this;
99656
-
99657
- var _this$props3 = this.props,
99658
- classes = _this$props3.classes,
99659
- disabled = _this$props3.disabled,
99660
- error = _this$props3.error,
99661
- loading = _this$props3.loading,
99662
- options = _this$props3.options,
99663
- searchable = _this$props3.searchable,
99664
- displayAsChip = _this$props3.displayAsChip,
99665
- type = _this$props3.type,
99666
- value = _this$props3.value,
99667
- translations = _this$props3.translations,
99668
- parentItemSelectable = _this$props3.parentItemSelectable,
99669
- icon = _this$props3.icon,
99670
- parentIcon = _this$props3.parentIcon,
99671
- hoverIcon = _this$props3.hoverIcon,
99672
- checkedIcon = _this$props3.checkedIcon,
99673
- id = _this$props3.id,
99674
- placeholder = _this$props3.placeholder,
99675
- staticPosition = _this$props3.staticPosition,
99676
- pinnedItem = _this$props3.pinnedItem,
99677
- hasAll = _this$props3.hasAll,
99678
- infiniteScroll = _this$props3.infiniteScroll,
99679
- loadingMoreResults = _this$props3.loadingMoreResults,
99680
- multiple = _this$props3.multiple,
99681
- other = objectWithoutProperties(_this$props3, ["classes", "disabled", "error", "loading", "options", "searchable", "displayAsChip", "type", "value", "translations", "parentItemSelectable", "icon", "parentIcon", "hoverIcon", "checkedIcon", "id", "placeholder", "staticPosition", "pinnedItem", "hasAll", "infiniteScroll", "loadingMoreResults", "multiple"]);
99682
-
99683
- var _this$state2 = this.state,
99684
- open = _this$state2.open,
99685
- stateSuggestions = _this$state2.suggestions,
99686
- focused = _this$state2.focused,
99687
- dynamic = _this$state2.dynamic;
99688
- var display = '';
99689
- var selectedIdList;
99690
-
99691
- if (Array.isArray(value)) {
99692
- selectedIdList = value;
99693
- } else if (value) {
99694
- selectedIdList = [value];
99695
- } else {
99696
- selectedIdList = [];
99697
- }
99698
-
99699
- var suggestions = toConsumableArray(stateSuggestions);
99700
-
99701
- if (pinnedItem) {
99702
- suggestions.unshift(pinnedItem);
99703
- } // If loading
99704
-
99705
-
99706
- if (loading && !loadingMoreResults) {
99707
- suggestions.unshift({
99708
- id: '_loading',
99709
- type: 'loader',
99710
- disabled: true,
99711
- centered: true,
99712
- checkbox: false,
99713
- label: 'loading'
99714
- });
99715
- }
99716
-
99717
- if ((dynamic || loading) && selectedIdList.length === 1) {
99718
- display = translations.one_item_selected;
99719
- } else if ((this.state.nbOptions !== selectedIdList.length || !hasAll) && selectedIdList.length > 1) {
99720
- display = translations.n_items_selected.replace('%s', selectedIdList.length);
99721
- } else if (this.state.nbOptions === selectedIdList.length && this.state.nbOptions > 1) {
99722
- display = translations.all;
99723
- } else if (selectedIdList.length === 1) {
99724
- var item = options.find(function (o) {
99725
- return o.id === selectedIdList[0];
99726
- });
99540
+ var _classNames,
99541
+ _this2 = this;
99727
99542
 
99728
- if (item === undefined) {
99729
- display = translations.one_item_selected;
99730
- } else if (type !== 'icon') {
99731
- if (pinnedItem) {
99732
- item = pinnedItem;
99733
- }
99543
+ var _this$props4 = this.props,
99544
+ classes = _this$props4.classes,
99545
+ disabled = _this$props4.disabled,
99546
+ error = _this$props4.error,
99547
+ loading = _this$props4.loading,
99548
+ options = _this$props4.options,
99549
+ searchable = _this$props4.searchable,
99550
+ displayAsChip = _this$props4.displayAsChip,
99551
+ type = _this$props4.type,
99552
+ value = _this$props4.value,
99553
+ multiple = _this$props4.multiple,
99554
+ translations = _this$props4.translations,
99555
+ hiSelectableListProps = _this$props4.hiSelectableListProps,
99556
+ hiSelectInputProps = _this$props4.hiSelectInputProps,
99557
+ id = _this$props4.id,
99558
+ onScrollReachBottom = _this$props4.onScrollReachBottom,
99559
+ onSubmit = _this$props4.onSubmit,
99560
+ placeholder = _this$props4.placeholder,
99561
+ startAdornment = _this$props4.startAdornment,
99562
+ staticPosition = _this$props4.staticPosition,
99563
+ _this$props4$searchVa = _this$props4.searchValue,
99564
+ searchValue = _this$props4$searchVa === void 0 ? this.state.searchValue : _this$props4$searchVa,
99565
+ _this$props4$buildSel = _this$props4.buildSelectProps,
99566
+ buildSelectProps = _this$props4$buildSel === void 0 ? this.buildSelectProps : _this$props4$buildSel;
99567
+ var _this$state = this.state,
99568
+ open = _this$state.open,
99569
+ focused = _this$state.focused;
99734
99570
 
99735
- display = item.label;
99736
- } else {
99737
- display = React__default.createElement("span", {
99738
- className: classes.selectIconLabel
99739
- }, React__default.createElement(HiIcon$1, {
99740
- icon: item.icon,
99741
- className: classes.labelIcon
99742
- }), item.label);
99571
+ if (multiple) {
99572
+ if (!Array.isArray(value)) {
99573
+ throw new Error('HiPay Material-UI: the `value` property must be an array ' + 'when using the `HiSelect` component with `multiple`.');
99743
99574
  }
99744
99575
  }
99745
99576
 
99746
- if (displayAsChip) {
99747
- var chipFilter = React__default.createElement(HiChip$1, {
99748
- label: placeholder || display,
99749
- onDelete: this.handleRequestDelete
99750
- });
99577
+ var selectedItemIdList = [];
99751
99578
 
99752
- if (display) {
99753
- display = chipFilter;
99754
- }
99579
+ if (value) {
99580
+ selectedItemIdList = multiple ? toConsumableArray(value) : [value];
99755
99581
  }
99756
99582
 
99757
- var popperClass = classnames(classes.popper, defineProperty({}, classes.popperWidth, !this.props.containerWidth));
99758
- var allSelected = false;
99759
-
99760
- if (selectedIdList.length === this.state.nbOptions) {
99761
- allSelected = true;
99762
- }
99583
+ var _buildSelectProps = buildSelectProps(options, selectedItemIdList, searchValue, loading),
99584
+ itemList = _buildSelectProps.itemList,
99585
+ _buildSelectProps$inp = _buildSelectProps.inputValue,
99586
+ inputValue = _buildSelectProps$inp === void 0 ? this.buildInputValue(options, selectedItemIdList, loading) : _buildSelectProps$inp;
99763
99587
 
99764
99588
  var popperStyle = {};
99765
99589
 
@@ -99773,17 +99597,7 @@
99773
99597
  }
99774
99598
  }
99775
99599
 
99776
- if (infiniteScroll && loadingMoreResults) {
99777
- suggestions.push({
99778
- id: '_loading',
99779
- type: 'loader',
99780
- disabled: true,
99781
- centered: true,
99782
- checkbox: false,
99783
- label: 'loading'
99784
- });
99785
- }
99786
-
99600
+ var popperClass = classnames(classes.popper, (_classNames = {}, defineProperty(_classNames, classes.popperWidth, !this.props.containerWidth), defineProperty(_classNames, classes.popperRightAlign, this.props.containerWidth && this.props.align === 'right'), _classNames));
99787
99601
  var content = React__default.createElement(ClickAwayListener$2, {
99788
99602
  onClickAway: this.handleClickAway
99789
99603
  }, React__default.createElement(Grow$2, {
@@ -99794,48 +99608,41 @@
99794
99608
  }
99795
99609
  }, React__default.createElement(Paper$2, {
99796
99610
  className: classes.paper
99797
- }, !!searchable && React__default.createElement(HiSearchField, {
99798
- itemList: options,
99799
- onFilteredList: this.handleSuggestions,
99800
- filterPropertyList: ['label'],
99801
- placeholder: translations.search,
99611
+ }, !!searchable && React__default.createElement(HiInput$1, {
99612
+ value: searchValue,
99802
99613
  autoFocus: true,
99803
- onSearch: this.props.onSearch,
99804
- inputRef: function inputRef(el) {
99805
- _this2.searchField = el;
99806
- },
99807
- onKeyDown: this.handleKeyDownSearch
99808
- }), React__default.createElement(Scrollbars, {
99614
+ inputRef: this.getInputElement,
99615
+ onKeyDown: this.handleKeyDownSearch,
99616
+ onChange: this.handleSearch,
99617
+ onReset: this.handleSearchReset,
99618
+ placeholder: translations.search,
99619
+ startAdornment: 'search',
99620
+ tabIndex: 0
99621
+ }), startAdornment, React__default.createElement(Scrollbars, _extends_1({
99809
99622
  ref: function ref(contentEl) {
99810
99623
  _this2.optionsContent = contentEl;
99811
99624
  },
99812
99625
  autoHeight: true,
99813
- autoHeightMax: 400,
99626
+ autoHeightMax: 400 // TODO ?
99627
+
99628
+ }, onScrollReachBottom && {
99814
99629
  onScroll: this.handleScroll
99815
- }, React__default.createElement(HiSelectableList$1, _extends_1({
99630
+ }), React__default.createElement(HiSelectableList$1, _extends_1({
99816
99631
  type: type,
99817
- parentItemSelectable: parentItemSelectable,
99818
- itemList: suggestions,
99632
+ itemList: itemList,
99633
+ onKeyDown: this.handleKeyDown,
99819
99634
  onSelect: this.handleSelect,
99820
- selectedItemIdList: selectedIdList,
99821
- hideCheckbox: !multiple,
99822
- translations: translations,
99823
- icon: icon,
99824
- parentIcon: parentIcon,
99825
- hoverIcon: hoverIcon,
99826
- checkedIcon: checkedIcon,
99827
- allSelected: allSelected,
99828
- value: value,
99829
- onKeyDown: this.handleKeyDown
99830
- }, other))))));
99635
+ selectedItemIdList: selectedItemIdList,
99636
+ fallbackImage: this.props.fallbackImage
99637
+ }, hiSelectableListProps))))));
99831
99638
  return React__default.createElement("div", {
99832
99639
  className: classes.root,
99833
99640
  ref: function ref(el) {
99834
99641
  _this2.overlay = el;
99835
99642
  }
99836
- }, React__default.createElement(SelectInput$1, {
99643
+ }, React__default.createElement(HiSelectInput$1, _extends_1({
99837
99644
  id: id,
99838
- value: placeholder || display,
99645
+ value: inputValue,
99839
99646
  open: open,
99840
99647
  focused: focused,
99841
99648
  type: type,
@@ -99845,43 +99652,55 @@
99845
99652
  onClick: this.handleClick,
99846
99653
  onFocus: this.handleFocus,
99847
99654
  onBlur: this.handleBlur,
99655
+ onSubmit: onSubmit,
99848
99656
  onMouseEnter: this.props.onMouseEnter,
99849
99657
  onMouseLeave: this.props.onMouseLeave,
99658
+ onReset: this.props.onReset,
99659
+ placeholder: placeholder
99660
+ }, hiSelectInputProps, {
99850
99661
  refElement: function refElement(el) {
99851
- _this2.selectInputElement = el;
99852
- },
99853
- onReset: this.props.onReset
99854
- }), open && staticPosition ? React__default.createElement("div", {
99855
- style: popperStyle
99662
+ _this2.inputEl = el;
99663
+ }
99664
+ })), open && staticPosition ? React__default.createElement("div", {
99665
+ style: popperStyle,
99666
+ className: popperClass
99856
99667
  }, content) : React__default.createElement(Popper$3, {
99857
99668
  anchorEl: this.inputEl,
99858
99669
  placement: "bottom-start",
99859
99670
  open: open,
99860
99671
  className: popperClass,
99861
- style: popperStyle,
99862
- disablePortal: true
99672
+ disablePortal: true,
99673
+ style: popperStyle
99863
99674
  }, content));
99864
99675
  }
99676
+ }], [{
99677
+ key: "getDerivedStateFromProps",
99678
+ value: function getDerivedStateFromProps(nextProps, prevState) {
99679
+ if (nextProps.options !== prevState.suggestions) {
99680
+ return _extends_1({}, prevState, {
99681
+ suggestions: nextProps.options
99682
+ });
99683
+ }
99684
+
99685
+ return null;
99686
+ }
99865
99687
  }]);
99866
99688
 
99867
99689
  return HiSelect;
99868
99690
  }(React__default.PureComponent);
99869
99691
 
99870
99692
  HiSelect.defaultProps = {
99871
- containerWidth: 0,
99693
+ align: 'left',
99872
99694
  disabled: false,
99873
99695
  displayAsChip: false,
99874
- dynamic: false,
99875
99696
  error: false,
99876
99697
  hasAll: false,
99877
- hasMore: false,
99878
- hierarchic: false,
99879
- iconAll: false,
99880
- infiniteScroll: false,
99881
- loadingMoreResults: false,
99698
+ hiSelectableListProps: {},
99699
+ hiSelectInputProps: {},
99882
99700
  multiple: false,
99883
- parentItemSelectable: false,
99884
- type: 'text',
99701
+ placeholder: '',
99702
+ searchable: false,
99703
+ staticPosition: false,
99885
99704
  translations: {
99886
99705
  all: 'All',
99887
99706
  no_result_match: 'No result match',
@@ -99891,14 +99710,10 @@
99891
99710
  n_children: '%s items',
99892
99711
  one_child: '%s item'
99893
99712
  },
99894
- searchable: false,
99895
- staticPosition: false
99713
+ type: 'text'
99896
99714
  };
99897
99715
  HiSelect.propTypes = {
99898
- /**
99899
- * Icon affiché lorsque l'item est sélectionné
99900
- */
99901
- checkedIcon: propTypes.node,
99716
+ align: propTypes.oneOf(['left', 'right']),
99902
99717
 
99903
99718
  /**
99904
99719
  * Useful to extend the style applied to components.
@@ -99920,77 +99735,46 @@
99920
99735
  */
99921
99736
  displayAsChip: propTypes.bool,
99922
99737
 
99923
- /**
99924
- * Option permettant de définir si les options du select sont dynamiques.
99925
- * Si les options du select sont initialisées à vide, alors ce sera mis à true
99926
- * automatiquement.
99927
- */
99928
- dynamic: propTypes.bool,
99929
-
99930
99738
  /**
99931
99739
  * Applique le style error
99932
99740
  */
99933
99741
  error: propTypes.bool,
99934
99742
 
99935
99743
  /**
99936
- * Affiche l'élément 'All'
99937
- */
99938
- hasAll: propTypes.bool,
99939
-
99940
- /**
99941
- * Indique si l'infinite scroll doit rechercher de nouveaux résultats
99744
+ * Chemin vers l'image à afficher par défaut si une image n'est pas trouvée
99942
99745
  */
99943
- hasMore: propTypes.bool,
99746
+ fallbackImage: propTypes.string,
99944
99747
 
99945
99748
  /**
99946
- * Les items sont hiérarchisés
99749
+ * Affiche l'élément 'All'
99947
99750
  */
99948
- hierarchic: propTypes.bool,
99751
+ hasAll: propTypes.bool,
99949
99752
 
99950
99753
  /**
99951
- * Icon affiché lorsque l'item n'est pas sélectionné et qu'on le survole
99754
+ * Override HiSelectableList props (
99952
99755
  */
99953
- hoverIcon: propTypes.node,
99756
+ hiSelectableListProps: propTypes.object,
99954
99757
 
99955
99758
  /**
99956
- * Icon affiché lorsque l'item n'est pas sélectionné
99759
+ * Override HiSelectInput props
99957
99760
  */
99958
- icon: propTypes.node,
99761
+ hiSelectInputProps: propTypes.object,
99959
99762
 
99960
99763
  /**
99961
99764
  * Nom de l'icône
99962
99765
  */
99963
- iconAll: propTypes.oneOfType([propTypes.string, propTypes.bool]),
99766
+ iconAll: propTypes.string,
99964
99767
 
99965
99768
  /**
99966
99769
  * id du select
99967
99770
  */
99968
99771
  id: propTypes.string,
99969
99772
 
99970
- /**
99971
- * Infinite scroll dans le select dans le cas où il y a beaucoup de résultats à afficher
99972
- * afin d'éviter un lag du navigateur
99973
- */
99974
- infiniteScroll: propTypes.bool,
99975
-
99976
99773
  /**
99977
99774
  * Ajoute un loader
99978
99775
  */
99979
99776
  loading: propTypes.bool,
99980
99777
 
99981
- /**
99982
- * Ajoute un loader en bas pour l'infiniteScroll
99983
- */
99984
- loadingMoreResults: propTypes.bool,
99985
-
99986
- /**
99987
- * Fonction de callback appelée lorsque l'utilisateur arrive en bas de la liste des options
99988
- * afin de charger les nouvelles options
99989
- *
99990
- * @param {int} pageNumber
99991
- */
99992
- loadMoreResults: propTypes.func,
99993
-
99994
99778
  /**
99995
99779
  * Autorise la sélection de plusieurs valeurs
99996
99780
  */
@@ -100009,11 +99793,6 @@
100009
99793
  */
100010
99794
  onChange: propTypes.func.isRequired,
100011
99795
 
100012
- /**
100013
- * Fonction de callback appelée click dans l'input
100014
- */
100015
- onClick: propTypes.func,
100016
-
100017
99796
  /**
100018
99797
  * Fonction de callback appelée lorsqu'on ferme le select
100019
99798
  */
@@ -100035,18 +99814,14 @@
100035
99814
  onReset: propTypes.func,
100036
99815
 
100037
99816
  /**
100038
- * Fonction de callback appelée lorsqu'on écrit dans la barre de recherche
100039
- * A utiliser pour les selects avec des données dynamiques
100040
- *
100041
- * @param {object} event
100042
- * @param {string} value
99817
+ * Fonction de callback appelée lorsque le scroll atteint le bas de la liste
100043
99818
  */
100044
- onSearch: propTypes.func,
99819
+ onScrollReachBottom: propTypes.func,
100045
99820
 
100046
99821
  /**
100047
- * Fonction de callback à la pression de la touche "Entrée"
99822
+ * Fonction de callback appelée lorsque le champs de recherche est utilisé
100048
99823
  */
100049
- onSubmit: propTypes.func,
99824
+ onSearch: propTypes.func,
100050
99825
 
100051
99826
  /**
100052
99827
  * Listes des options du select
@@ -100054,23 +99829,7 @@
100054
99829
  options: propTypes.array.isRequired,
100055
99830
 
100056
99831
  /**
100057
- * Icon affiché lorsqu'un item parent n'est pas sélectionné
100058
- */
100059
- parentIcon: propTypes.node,
100060
-
100061
- /**
100062
- * Les items parents sont sélectionnables
100063
- */
100064
- parentItemSelectable: propTypes.bool,
100065
-
100066
- /**
100067
- * Item épinglé en début de liste
100068
- */
100069
- pinnedItem: propTypes.object,
100070
-
100071
- /**
100072
- * Placeholder affiché lorsque le select est fermé
100073
- * Surcharge le placeholder par défaut
99832
+ * Placeholder affiché lorsque l'input est vide
100074
99833
  */
100075
99834
  placeholder: propTypes.string,
100076
99835
 
@@ -100080,7 +99839,12 @@
100080
99839
  searchable: propTypes.bool,
100081
99840
 
100082
99841
  /**
100083
- * Si true, le contenu du select sera dans une div static plutot que dans une popper absolute
99842
+ * Node qui s'ajoute entre la barre de recherche et la liste de résultats
99843
+ */
99844
+ startAdornment: propTypes.object,
99845
+
99846
+ /**
99847
+ * Si true, le contenu du select sera dans une div static plutôt que dans une popper absolute
100084
99848
  */
100085
99849
  staticPosition: propTypes.bool,
100086
99850
 
@@ -100235,6 +99999,8 @@
100235
99999
  switch (key) {
100236
100000
  case 'custom':
100237
100001
  label = t.custom_period;
100002
+ from = moment().subtract(15, 'day').startOf('day');
100003
+ to = moment().endOf('day');
100238
100004
  type = 'primary-highlight';
100239
100005
  break;
100240
100006
 
@@ -100270,35 +100036,35 @@
100270
100036
  label = t.current_month;
100271
100037
  from = moment().startOf('month');
100272
100038
  to = moment();
100273
- info = "".concat(from.format(format), " ").concat(t.to_now, ", ").concat(to.diff(from, 'days'), " ").concat(t.days);
100039
+ info = "".concat(from.format(format), " ").concat(t.to_now, ", ").concat(to.diff(from, 'days') + 1, " ").concat(t.days);
100274
100040
  break;
100275
100041
 
100276
100042
  case 'pm':
100277
100043
  label = t.previous_month;
100278
100044
  from = moment().subtract(1, 'month').startOf('month');
100279
100045
  to = moment().subtract(1, 'month').endOf('month');
100280
- info = "".concat(from.format('YYYY-MM'), ", ").concat(to.diff(from, 'days'), " ").concat(t.days);
100046
+ info = "".concat(from.format(t.yearAndMonth), ", ").concat(from.daysInMonth(), " ").concat(t.days);
100281
100047
  break;
100282
100048
 
100283
100049
  case 'cq':
100284
100050
  label = t.current_quarter;
100285
100051
  from = moment().startOf('quarter');
100286
100052
  to = moment();
100287
- info = "".concat(from.format(format), " ").concat(t.to_now, ", ").concat(to.diff(from, 'days'), " ").concat(t.days);
100053
+ info = "".concat(from.format(t.yearAndQuarter), ", ").concat(from.format(format), " ").concat(t.to_now, ", ").concat(to.diff(from, 'days') + 1, " ").concat(t.days);
100288
100054
  break;
100289
100055
 
100290
100056
  case 'pq':
100291
100057
  label = t.previous_quarter;
100292
100058
  from = moment().subtract(1, 'quarter').startOf('quarter');
100293
100059
  to = moment().subtract(1, 'quarter').endOf('quarter');
100294
- info = "".concat(from.format('YYYY'), "-").concat(t.short_quarter).concat(from.format('Q'), ", ").concat(to.diff(from, 'days'), " ").concat(t.days);
100060
+ info = "".concat(from.format(t.yearAndQuarter), ", ").concat(to.diff(from, 'days') + 1, " ").concat(t.days);
100295
100061
  break;
100296
100062
 
100297
100063
  case 'cy':
100298
100064
  label = t.current_year;
100299
100065
  from = moment().startOf('year');
100300
100066
  to = moment();
100301
- info = "".concat(from.format(format), " ").concat(t.to_now, ", ").concat(to.diff(from, 'days'), " ").concat(t.days);
100067
+ info = "".concat(from.format(format), " ").concat(t.to_now, ", ").concat(to.diff(from, 'days') + 1, " ").concat(t.days);
100302
100068
  break;
100303
100069
 
100304
100070
  default:
@@ -100346,25 +100112,30 @@
100346
100112
  _this = possibleConstructorReturn(this, getPrototypeOf(HiDateRangeSelector).call(this));
100347
100113
  _this.options = [];
100348
100114
 
100115
+ _this.onBlur = function (event) {
100116
+ if (event instanceof Object && _this.props.onblur) {
100117
+ _this.props.onBlur(event);
100118
+ }
100119
+ };
100120
+
100349
100121
  _this.handleSelectChange = function (name) {
100350
100122
  return function (event, value) {
100351
- _this.setState(defineProperty({}, name, value));
100123
+ var _this$setState;
100352
100124
 
100353
- if (value !== 'custom') {
100354
- var selectedOption = _this.options.find(function (option) {
100355
- return option.id === value;
100356
- });
100125
+ _this.setState((_this$setState = {}, defineProperty(_this$setState, name, value), defineProperty(_this$setState, "key", _this.state.key === 1 ? 2 : 1), _this$setState));
100357
100126
 
100358
- if (selectedOption) {
100359
- _this.props.onChange('from', selectedOption.from.toDate());
100127
+ var selectedOption = _this.options.find(function (option) {
100128
+ return option.id === value;
100129
+ });
100360
100130
 
100361
- _this.props.onChange('to', selectedOption.to.toDate());
100362
- }
100363
- } else {
100364
- _this.setState({
100365
- defaultFrom: undefined,
100366
- defaultTo: undefined
100367
- });
100131
+ if (selectedOption) {
100132
+ _this.props.onChange('from', selectedOption.from.toDate());
100133
+
100134
+ _this.props.onChange('to', selectedOption.to.toDate());
100135
+
100136
+ _this.props.onChange('fromError', false);
100137
+
100138
+ _this.props.onChange('toError', false);
100368
100139
  }
100369
100140
 
100370
100141
  if (_this.props.returnSelectValue === true) {
@@ -100378,25 +100149,9 @@
100378
100149
  _this.options = props.availableOptionKeys.map(function (key) {
100379
100150
  return buildDateRangeOptionByKey(key, props.translations, props.format);
100380
100151
  });
100381
- var from;
100382
- var to;
100383
-
100384
- if (props.defaultPreset !== 'custom') {
100385
- var selectedOption = _this.options.find(function (option) {
100386
- return option.id === props.defaultPreset;
100387
- });
100388
-
100389
- if (selectedOption) {
100390
- from = selectedOption.from.toDate();
100391
- to = selectedOption.to.toDate();
100392
- }
100393
- }
100394
-
100395
100152
  _this.state = {
100396
100153
  selectedPreset: props.defaultPreset,
100397
- containerWidth: 0,
100398
- defaultFrom: from,
100399
- defaultTo: to
100154
+ containerWidth: 0
100400
100155
  };
100401
100156
  return _this;
100402
100157
  }
@@ -100406,8 +100161,9 @@
100406
100161
  value: function componentDidMount() {
100407
100162
  if (this.container) {
100408
100163
  this.setState({
100409
- containerWidth: require$$11.findDOMNode(this.container).clientWidth
100164
+ containerWidth: require$$11.findDOMNode(this.container).clientWidth - 5
100410
100165
  });
100166
+ this.handleSelectChange('selectedPreset')(undefined, this.state.selectedPreset);
100411
100167
  }
100412
100168
  }
100413
100169
  }, {
@@ -100419,6 +100175,7 @@
100419
100175
  key: "handleReset",
100420
100176
  value: function handleReset(name) {
100421
100177
  this.props.onChange(name, undefined);
100178
+ this.props.onChange("".concat(name, "Error"), undefined);
100422
100179
  }
100423
100180
  }, {
100424
100181
  key: "render",
@@ -100428,12 +100185,14 @@
100428
100185
  var _this$props = this.props,
100429
100186
  disabled = _this$props.disabled,
100430
100187
  enableTime = _this$props.enableTime,
100431
- error = _this$props.error,
100432
100188
  errorText = _this$props.errorText,
100189
+ fromError = _this$props.fromError,
100190
+ toError = _this$props.toError,
100433
100191
  helperIcon = _this$props.helperIcon,
100434
100192
  helperText = _this$props.helperText,
100435
100193
  idRange = _this$props.idRange,
100436
100194
  idSelect = _this$props.idSelect,
100195
+ minimumDate = _this$props.minimumDate,
100437
100196
  label = _this$props.label,
100438
100197
  from = _this$props.from,
100439
100198
  onChange = _this$props.onChange,
@@ -100443,18 +100202,25 @@
100443
100202
  classes = _this$props.classes,
100444
100203
  selectProps = _this$props.selectProps,
100445
100204
  staticPosition = _this$props.staticPosition,
100446
- props = objectWithoutProperties(_this$props, ["disabled", "enableTime", "error", "errorText", "helperIcon", "helperText", "idRange", "idSelect", "label", "from", "onChange", "required", "to", "translations", "classes", "selectProps", "staticPosition"]);
100205
+ props = objectWithoutProperties(_this$props, ["disabled", "enableTime", "errorText", "fromError", "toError", "helperIcon", "helperText", "idRange", "idSelect", "minimumDate", "label", "from", "onChange", "required", "to", "translations", "classes", "selectProps", "staticPosition"]);
100447
100206
 
100448
- var _this$state = this.state,
100449
- defaultFrom = _this$state.defaultFrom,
100450
- defaultTo = _this$state.defaultTo,
100451
- selectedPreset = _this$state.selectedPreset;
100452
- return React__default.createElement(Grid$4, {
100207
+ var selectedPreset = this.state.selectedPreset;
100208
+ var hiSelectableListProps = {
100209
+ hideCheckbox: true
100210
+ };
100211
+ return React__default.createElement(HiFormControl$1, {
100212
+ disabled: disabled,
100213
+ helperIcon: helperIcon,
100214
+ helperText: helperText,
100215
+ errorText: errorText,
100216
+ error: !!(fromError || toError),
100217
+ label: ' '
100218
+ }, React__default.createElement(Grid$4, {
100453
100219
  container: true,
100454
100220
  spacing: 8,
100455
100221
  className: classes.root,
100456
100222
  ref: function ref(container) {
100457
- _this2.container = container;
100223
+ return _this2.container = container;
100458
100224
  }
100459
100225
  }, React__default.createElement(Grid$4, {
100460
100226
  item: true,
@@ -100465,12 +100231,10 @@
100465
100231
  }
100466
100232
  }, React__default.createElement(HiSelectField, _extends_1({
100467
100233
  disabled: disabled,
100468
- error: error,
100469
- errorText: errorText,
100470
- helperIcon: helperIcon,
100471
- helperText: helperText,
100472
100234
  id: idSelect,
100473
100235
  label: label,
100236
+ hideCheckbox: true,
100237
+ hiSelectableListProps: hiSelectableListProps,
100474
100238
  name: 'selectedPreset',
100475
100239
  options: this.options,
100476
100240
  onChange: this.handleSelectChange('selectedPreset'),
@@ -100490,19 +100254,26 @@
100490
100254
  'grid-sm-8': classes.smRangePicker
100491
100255
  }
100492
100256
  }, React__default.createElement(HiDateRangePicker$1, _extends_1({
100257
+ key: this.state.key,
100493
100258
  classes: {
100494
100259
  root: classes.dateRangePicker
100495
100260
  },
100496
100261
  id: idRange,
100497
- from: from || defaultFrom,
100498
- to: to || defaultTo,
100262
+ from: from,
100263
+ to: to,
100499
100264
  enableTime: enableTime,
100500
100265
  onChange: onChange,
100266
+ toError: toError,
100267
+ fromError: fromError,
100268
+ minimumDate: minimumDate,
100269
+ errorText: null,
100501
100270
  onReset: this.handleReset,
100502
100271
  disabled: disabled || selectedPreset !== 'custom',
100503
100272
  translations: translations,
100504
- staticPosition: staticPosition
100505
- }, props))));
100273
+ staticPosition: staticPosition,
100274
+ onBlur: this.onBlur,
100275
+ hasSelector: true
100276
+ }, props)))));
100506
100277
  }
100507
100278
  }], [{
100508
100279
  key: "getDerivedStateFromProps",
@@ -100536,7 +100307,8 @@
100536
100307
  quarter: 'Quarter',
100537
100308
  week: 'Week',
100538
100309
  short_week: 'W',
100539
- short_quarter: 'Q',
100310
+ yearAndMonth: 'YYYY[-]MM',
100311
+ yearAndQuarter: 'YYYY[-Q]Q',
100540
100312
  year: 'Year',
100541
100313
  days: 'days',
100542
100314
  custom_period: 'Custom Period',
@@ -100549,7 +100321,13 @@
100549
100321
  previous_month: 'Previous Month',
100550
100322
  current_quarter: 'Current Quarter',
100551
100323
  previous_quarter: 'Previous Quarter',
100552
- current_year: 'Current Year'
100324
+ current_year: 'Current Year',
100325
+ invalid_format: 'The date format is not valid',
100326
+ to_superior_from: 'Date from cannot be greater than date to',
100327
+ date_superior_max_date: 'Date from cannot be greater than %s',
100328
+ date_inferior_min_date: 'Date from cannot be before than %s',
100329
+ missing_date_from: 'Missing date from',
100330
+ missing_date_to: 'Missing date to'
100553
100331
  }
100554
100332
  };
100555
100333
  HiDateRangeSelector.propTypes = {
@@ -100586,7 +100364,7 @@
100586
100364
  /**
100587
100365
  * Texte de l'erreur
100588
100366
  */
100589
- errorText: propTypes.string,
100367
+ errorText: propTypes.oneOfType([propTypes.string, propTypes.bool]),
100590
100368
 
100591
100369
  /**
100592
100370
  * Format de date utilisé
@@ -100628,6 +100406,11 @@
100628
100406
  */
100629
100407
  locale: propTypes.string,
100630
100408
 
100409
+ /**
100410
+ * Date minimale sélectionnable
100411
+ */
100412
+ minimumDate: propTypes.instanceOf(Date).isRequired,
100413
+
100631
100414
  /**
100632
100415
  * Callback à la sélection d'une date
100633
100416
  */