@hipay/hipay-material-ui 2.1.0-RC1 → 2.2.0-RC1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/CHANGELOG.md +154 -0
  2. package/HiAlertModal/HiAlertModal.js +32 -7
  3. package/HiAppBar/HiAppBar.js +3 -3
  4. package/HiBreadcrumb/HiBreadcrumb.js +1 -1
  5. package/HiBreadcrumb/HiStepConnector.js +3 -3
  6. package/HiButton/HiButton.js +64 -25
  7. package/HiCell/CellText.js +3 -3
  8. package/HiCheckbox/HiCheckbox.js +3 -3
  9. package/HiChip/HiChipSwitch.js +5 -5
  10. package/HiColoredLabel/HiColoredLabel.js +2 -1
  11. package/HiDatePicker/HiDatePicker.js +1 -5
  12. package/HiDatePicker/Overlays/MonthPickerOverlay.js +3 -3
  13. package/HiDatePicker/Overlays/TimePickerOverlay.js +4 -4
  14. package/HiDatePicker/Overlays/YearPickerOverlay.js +3 -3
  15. package/HiDotsStepper/HiDotsStepper.js +4 -4
  16. package/HiExpansionPanel/HiExpansionPanel.js +19 -10
  17. package/HiForm/HiAddressField.js +7 -7
  18. package/HiForm/HiEmailField.js +3 -3
  19. package/HiForm/HiFormControl.js +6 -6
  20. package/HiForm/HiInput.js +11 -11
  21. package/HiForm/HiPasswordField.js +3 -3
  22. package/HiForm/HiSearchField.js +5 -5
  23. package/HiForm/HiTextField.js +5 -5
  24. package/HiForm/index.js +17 -1
  25. package/HiIcon/HiIcon.js +9 -1
  26. package/HiMap/HiMap.js +6 -6
  27. package/HiMap/HiMapExpand.js +4 -4
  28. package/HiNotice/HiKPI.js +11 -11
  29. package/HiNotice/HiKPINotice.js +1 -1
  30. package/HiSelect/HiDynamicSelect.js +7 -7
  31. package/HiSelect/HiNestedSelect.js +12 -12
  32. package/HiSelect/HiNestedSelectContent.js +9 -9
  33. package/HiSelect/HiSelect.js +56 -58
  34. package/HiSelect/HiSelectContent.js +13 -13
  35. package/HiSelect/HiSelectInput.js +7 -7
  36. package/HiSelect/HiSuggestSelect.js +62 -54
  37. package/HiSelectableList/HiSelectableList.js +28 -9
  38. package/HiSelectableList/HiSelectableListItem.js +6 -5
  39. package/HiTable/HiTable.js +3 -3
  40. package/HiTable/HiTableRow.js +3 -3
  41. package/es/HiAlertModal/HiAlertModal.js +26 -4
  42. package/es/HiBreadcrumb/HiBreadcrumb.js +1 -1
  43. package/es/HiButton/HiButton.js +57 -41
  44. package/es/HiColoredLabel/HiColoredLabel.js +2 -1
  45. package/es/HiDatePicker/HiDatePicker.js +1 -3
  46. package/es/HiExpansionPanel/HiExpansionPanel.js +19 -10
  47. package/es/HiForm/index.js +3 -1
  48. package/es/HiIcon/HiIcon.js +9 -1
  49. package/es/HiNotice/HiKPI.js +8 -8
  50. package/es/HiNotice/HiKPINotice.js +1 -1
  51. package/es/HiSelect/HiSelect.js +30 -27
  52. package/es/HiSelect/HiSuggestSelect.js +61 -52
  53. package/es/HiSelectableList/HiSelectableList.js +26 -8
  54. package/es/HiSelectableList/HiSelectableListItem.js +2 -1
  55. package/index.es.js +1 -1
  56. package/index.js +1 -1
  57. package/package.json +1 -2
  58. package/HiDatePicker/Caption.spec.js +0 -88
  59. package/HiDatePicker/ListPicker.spec.js +0 -67
  60. package/HiDatePicker/NavBar.spec.js +0 -55
  61. package/HiDatePicker/Overlays/MonthPickerOverlay.spec.js +0 -74
  62. package/HiDatePicker/Overlays/Overlay.spec.js +0 -34
  63. package/HiDatePicker/Overlays/TimePickerOverlay.spec.js +0 -71
  64. package/HiDatePicker/Overlays/YearPickerOverlay.spec.js +0 -127
  65. package/es/HiDatePicker/Caption.spec.js +0 -68
  66. package/es/HiDatePicker/ListPicker.spec.js +0 -50
  67. package/es/HiDatePicker/NavBar.spec.js +0 -39
  68. package/es/HiDatePicker/Overlays/MonthPickerOverlay.spec.js +0 -53
  69. package/es/HiDatePicker/Overlays/Overlay.spec.js +0 -25
  70. package/es/HiDatePicker/Overlays/TimePickerOverlay.spec.js +0 -53
  71. package/es/HiDatePicker/Overlays/YearPickerOverlay.spec.js +0 -92
@@ -19,8 +19,6 @@ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime
19
19
 
20
20
  var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
21
21
 
22
- var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
23
-
24
22
  var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
25
23
 
26
24
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
@@ -158,22 +156,22 @@ function (_React$PureComponent) {
158
156
  var search = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
159
157
  var loading = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
160
158
  // build item list
161
- var itemList = [].concat((0, _toConsumableArray2.default)(loading ? [{
159
+ var itemList = (0, _toConsumableArray2.default)(loading ? [{
162
160
  id: '_loading',
163
161
  type: 'loader',
164
162
  disabled: true,
165
163
  centered: true,
166
164
  hideCheckbox: true,
167
165
  label: 'loading'
168
- }] : []), (0, _toConsumableArray2.default)(search !== '' ? (0, _toConsumableArray2.default)(options.filter(function (item) {
166
+ }] : []).concat((0, _toConsumableArray2.default)(search !== '' ? (0, _toConsumableArray2.default)(options.filter(function (item) {
169
167
  return _this.props.filterFunc(item, search);
170
- })) : [].concat((0, _toConsumableArray2.default)(_this.props.hasAll ? [(0, _extends2.default)({
168
+ })) : (0, _toConsumableArray2.default)(_this.props.hasAll ? [(0, _extends2.default)({
171
169
  id: '_all',
172
170
  label: _this.props.translations.all
173
171
  }, _this.props.iconAll && {
174
172
  type: 'icon',
175
173
  icon: _this.props.iconAll
176
- })] : []), (0, _toConsumableArray2.default)(options))));
174
+ })] : []).concat((0, _toConsumableArray2.default)(options))));
177
175
  return {
178
176
  itemList: itemList,
179
177
  inputValue: _this.buildInputValue(options, value, loading)
@@ -210,6 +208,7 @@ function (_React$PureComponent) {
210
208
  className: classes.selectIconLabel
211
209
  }, _react.default.createElement(_HiIcon.default, {
212
210
  className: classes.labelIcon,
211
+ color: item.color,
213
212
  icon: item.icon
214
213
  }), item.label);
215
214
  } else if (type === 'image' || item.type === 'image') {
@@ -455,7 +454,7 @@ function (_React$PureComponent) {
455
454
  return id !== item.id;
456
455
  }), item);
457
456
  } else {
458
- onChange(event, [].concat((0, _toConsumableArray2.default)(value), [item.id]), item);
457
+ onChange(event, (0, _toConsumableArray2.default)(value).concat([item.id]), item);
459
458
  }
460
459
  };
461
460
 
@@ -481,13 +480,13 @@ function (_React$PureComponent) {
481
480
  });
482
481
  } else {
483
482
  _this.setState({
484
- suggestions: [].concat((0, _toConsumableArray2.default)(hasAll ? [(0, _extends2.default)({
483
+ suggestions: (0, _toConsumableArray2.default)(hasAll ? [(0, _extends2.default)({
485
484
  id: '_all',
486
485
  label: translations.all
487
486
  }, iconAll && {
488
487
  type: 'icon',
489
488
  icon: iconAll
490
- })] : []), (0, _toConsumableArray2.default)(suggestions))
489
+ })] : []).concat((0, _toConsumableArray2.default)(suggestions))
491
490
  });
492
491
  }
493
492
  };
@@ -512,6 +511,20 @@ function (_React$PureComponent) {
512
511
  }, '');
513
512
  };
514
513
 
514
+ _this.getLengthItemList = function (itemList) {
515
+ var itemListLength = 0;
516
+ itemList.forEach(function (parent) {
517
+ if (parent.displayed !== false) {
518
+ itemListLength += 1;
519
+
520
+ if (parent.children) {
521
+ itemListLength += _this.getLengthItemList(parent.children);
522
+ }
523
+ }
524
+ });
525
+ return itemListLength;
526
+ };
527
+
515
528
  _this.state = {
516
529
  alertOpen: false,
517
530
  open: false,
@@ -521,16 +534,6 @@ function (_React$PureComponent) {
521
534
  openDown: true,
522
535
  overlayWidth: 0
523
536
  };
524
- _this.handleBlur = _this.handleBlur.bind((0, _assertThisInitialized2.default)(_this));
525
- _this.handleClick = _this.handleClick.bind((0, _assertThisInitialized2.default)(_this));
526
- _this.handleClose = _this.handleClose.bind((0, _assertThisInitialized2.default)(_this));
527
- _this.handleClickAway = _this.handleClickAway.bind((0, _assertThisInitialized2.default)(_this));
528
- _this.handleFocus = _this.handleFocus.bind((0, _assertThisInitialized2.default)(_this));
529
- _this.handleSearch = _this.handleSearch.bind((0, _assertThisInitialized2.default)(_this));
530
- _this.handleSearchReset = _this.handleSearchReset.bind((0, _assertThisInitialized2.default)(_this));
531
- _this.handleSelect = _this.handleSelect.bind((0, _assertThisInitialized2.default)(_this));
532
- _this.handleSuggestions = _this.handleSuggestions.bind((0, _assertThisInitialized2.default)(_this));
533
- _this.getInputElement = _this.getInputElement.bind((0, _assertThisInitialized2.default)(_this));
534
537
  return _this;
535
538
  }
536
539
 
@@ -547,28 +550,11 @@ function (_React$PureComponent) {
547
550
  });
548
551
  }
549
552
  }
550
- }, {
551
- key: "getLengthItemList",
552
- value: function getLengthItemList(itemList) {
553
- var _this2 = this;
554
-
555
- var itemListLength = 0;
556
- itemList.forEach(function (parent) {
557
- if (parent.displayed !== false) {
558
- itemListLength += 1;
559
-
560
- if (parent.children) {
561
- itemListLength += _this2.getLengthItemList(parent.children);
562
- }
563
- }
564
- });
565
- return itemListLength;
566
- }
567
553
  }, {
568
554
  key: "render",
569
555
  value: function render() {
570
556
  var _classNames,
571
- _this3 = this;
557
+ _this2 = this;
572
558
 
573
559
  var _this$props4 = this.props,
574
560
  alert = _this$props4.alert,
@@ -594,6 +580,7 @@ function (_React$PureComponent) {
594
580
  searchValue = _this$props4$searchVa === void 0 ? this.state.searchValue : _this$props4$searchVa,
595
581
  startAdornment = _this$props4.startAdornment,
596
582
  staticPosition = _this$props4.staticPosition,
583
+ maxOptionsDisplayed = _this$props4.maxOptionsDisplayed,
597
584
  _this$props4$buildSel = _this$props4.buildSelectProps,
598
585
  buildSelectProps = _this$props4$buildSel === void 0 ? this.buildSelectProps : _this$props4$buildSel;
599
586
  var _this$state = this.state,
@@ -637,10 +624,10 @@ function (_React$PureComponent) {
637
624
  return _react.default.createElement(_HiInput.default, (0, _extends2.default)({
638
625
  value: searchValue,
639
626
  autoFocus: true,
640
- inputRef: _this3.getInputElement,
641
- onKeyDown: _this3.handleKeyDownSearch,
642
- onChange: _this3.handleSearch,
643
- onReset: _this3.handleSearchReset,
627
+ inputRef: _this2.getInputElement,
628
+ onKeyDown: _this2.handleKeyDownSearch,
629
+ onChange: _this2.handleSearch,
630
+ onReset: _this2.handleSearchReset,
644
631
  placeholder: translations.search,
645
632
  startAdornment: 'search',
646
633
  tabIndex: 0,
@@ -656,7 +643,7 @@ function (_React$PureComponent) {
656
643
  // In case we have a nested list
657
644
  var itemListLength = this.getLengthItemList(itemList); // +1 for search input
658
645
 
659
- var nbItems = itemListLength <= 10 ? itemListLength + 1 : 11;
646
+ var nbItems = itemListLength <= maxOptionsDisplayed - 2 ? itemListLength + 1 : maxOptionsDisplayed - 1;
660
647
  popperStyle.transform = "translate3d(-1px, -".concat(nbItems * 40 + 2, "px, 0px)");
661
648
  } else if (this.placement && this.placement.indexOf('top') < 0 && !!searchable) {
662
649
  popperStyle.transform = 'translate3d(-1px, 40px, 0px)';
@@ -665,12 +652,14 @@ function (_React$PureComponent) {
665
652
  var content = function content(_ref) {
666
653
  var placement = _ref.placement;
667
654
 
668
- if (placement !== _this3.placement) {
669
- _this3.placement = placement;
655
+ if (placement !== _this2.placement) {
656
+ _this2.placement = placement;
670
657
  }
671
658
 
659
+ var nbItemsDisplayed = !!searchable ? maxOptionsDisplayed - 1 : maxOptionsDisplayed;
660
+ var autoHeightMax = nbItemsDisplayed * 40 - 10;
672
661
  return _react.default.createElement(_ClickAwayListener.default, {
673
- onClickAway: _this3.handleClickAway
662
+ onClickAway: _this2.handleClickAway
674
663
  }, _react.default.createElement(_Grow.default, {
675
664
  in: open,
676
665
  id: "menu-list",
@@ -678,30 +667,33 @@ function (_React$PureComponent) {
678
667
  transformOrigin: '0 0 0'
679
668
  }
680
669
  }, _react.default.createElement(_Paper.default, {
670
+ style: maxOptionsDisplayed < 12 ? {
671
+ maxHeight: 40 * maxOptionsDisplayed
672
+ } : {},
681
673
  className: classes.paper
682
- }, (_this3.placement && _this3.placement.indexOf('bottom') >= 0 || staticPosition) && searchInput('bottom'), startAdornment, _react.default.createElement(_reactCustomScrollbars.default, (0, _extends2.default)({
674
+ }, (_this2.placement && _this2.placement.indexOf('bottom') >= 0 || staticPosition) && searchInput('bottom'), startAdornment, _react.default.createElement(_reactCustomScrollbars.default, (0, _extends2.default)({
683
675
  ref: function ref(contentEl) {
684
- _this3.optionsContent = contentEl;
676
+ _this2.optionsContent = contentEl;
685
677
  },
686
678
  autoHeight: true,
687
- autoHeightMax: 430
679
+ autoHeightMax: autoHeightMax
688
680
  }, onScrollReachBottom && {
689
- onScroll: _this3.handleScroll
681
+ onScroll: _this2.handleScroll
690
682
  }), _react.default.createElement(_HiSelectableList.default, (0, _extends2.default)({
691
683
  type: type,
692
684
  itemList: itemList,
693
- onSelect: _this3.handleSelect,
685
+ onSelect: _this2.handleSelect,
694
686
  selectedItemIdList: selectedItemIdList,
695
- fallbackImage: _this3.props.fallbackImage,
696
- overlay: _this3.overlay,
687
+ fallbackImage: _this2.props.fallbackImage,
688
+ overlay: _this2.overlay,
697
689
  value: value
698
- }, hiSelectableListProps))), _this3.placement && _this3.placement.indexOf('top') >= 0 && !staticPosition && searchInput('top'))));
690
+ }, hiSelectableListProps))), _this2.placement && _this2.placement.indexOf('top') >= 0 && !staticPosition && searchInput('top'))));
699
691
  };
700
692
 
701
693
  return !_reactDeviceDetect.isMobile ? _react.default.createElement("div", {
702
694
  className: classes.root,
703
695
  ref: function ref(el) {
704
- _this3.overlay = el;
696
+ _this2.overlay = el;
705
697
  },
706
698
  onKeyDown: this.handleKeyDown,
707
699
  onKeyDownCapture: this.handleKeyDownCapture
@@ -734,7 +726,7 @@ function (_React$PureComponent) {
734
726
  placeholder: placeholder
735
727
  }, hiSelectInputProps, {
736
728
  refElement: function refElement(el) {
737
- _this3.inputEl = el;
729
+ _this2.inputEl = el;
738
730
  }
739
731
  })), open && staticPosition ? _react.default.createElement("div", {
740
732
  style: popperStyle,
@@ -748,7 +740,7 @@ function (_React$PureComponent) {
748
740
  style: popperStyle
749
741
  }, content)) : _react.default.createElement("div", {
750
742
  ref: function ref(el) {
751
- _this3.overlay = el;
743
+ _this2.overlay = el;
752
744
  }
753
745
  }, _react.default.createElement(_HiSelectInput.default, (0, _extends2.default)({
754
746
  id: id,
@@ -767,7 +759,7 @@ function (_React$PureComponent) {
767
759
  placeholder: placeholder
768
760
  }, hiSelectInputProps, {
769
761
  refElement: function refElement(el) {
770
- _this3.inputEl = el;
762
+ _this2.inputEl = el;
771
763
  }
772
764
  })), _react.default.createElement(_HiSelectMobile.default, {
773
765
  onChange: this.handleSelect,
@@ -826,7 +818,8 @@ HiSelect.defaultProps = {
826
818
  one_child: '%s item'
827
819
  },
828
820
  type: 'text',
829
- filterFunc: filterValue
821
+ filterFunc: filterValue,
822
+ maxOptionsDisplayed: 12
830
823
  };
831
824
  HiSelect.propTypes = process.env.NODE_ENV !== "production" ? {
832
825
  /**
@@ -910,6 +903,11 @@ HiSelect.propTypes = process.env.NODE_ENV !== "production" ? {
910
903
  */
911
904
  loading: _propTypes.default.bool,
912
905
 
906
+ /**
907
+ * Nombre max d'items affichés
908
+ */
909
+ maxOptionsDisplayed: _propTypes.default.number,
910
+
913
911
  /**
914
912
  * Autorise la sélection de plusieurs valeurs
915
913
  */
@@ -17,10 +17,10 @@ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime
17
17
 
18
18
  var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
19
19
 
20
- var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
21
-
22
20
  var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
23
21
 
22
+ var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
23
+
24
24
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
25
25
 
26
26
  var _react = _interopRequireDefault(require("react"));
@@ -179,7 +179,7 @@ function (_React$PureComponent) {
179
179
  return id !== item.id;
180
180
  }), item);
181
181
  } else {
182
- onChange(event, [].concat((0, _toConsumableArray2.default)(value), [item.id]), item);
182
+ onChange(event, (0, _toConsumableArray2.default)(value).concat([item.id]), item);
183
183
  }
184
184
  };
185
185
 
@@ -209,13 +209,13 @@ function (_React$PureComponent) {
209
209
  });
210
210
  } else {
211
211
  _this.setState({
212
- suggestions: [].concat((0, _toConsumableArray2.default)(hasAll ? [(0, _extends2.default)({
212
+ suggestions: (0, _toConsumableArray2.default)(hasAll ? [(0, _extends2.default)({
213
213
  id: '_all',
214
214
  label: translations.all
215
215
  }, iconAll && {
216
216
  type: 'icon',
217
217
  icon: iconAll
218
- })] : []), (0, _toConsumableArray2.default)(suggestions))
218
+ })] : []).concat((0, _toConsumableArray2.default)(suggestions))
219
219
  });
220
220
  }
221
221
  };
@@ -251,22 +251,22 @@ function (_React$PureComponent) {
251
251
  var search = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
252
252
  var loading = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
253
253
  // build item list
254
- var itemList = [].concat((0, _toConsumableArray2.default)(loading ? [{
254
+ var itemList = (0, _toConsumableArray2.default)(loading ? [{
255
255
  id: '_loading',
256
256
  type: 'loader',
257
257
  disabled: true,
258
258
  centered: true,
259
259
  hideCheckbox: true,
260
260
  label: 'loading'
261
- }] : []), (0, _toConsumableArray2.default)(search !== '' ? (0, _toConsumableArray2.default)(options.filter(function (item) {
261
+ }] : []).concat((0, _toConsumableArray2.default)(search !== '' ? (0, _toConsumableArray2.default)(options.filter(function (item) {
262
262
  return item.label && _this.props.filterFunc(item, search);
263
- })) : [].concat((0, _toConsumableArray2.default)(_this.props.hasAll ? [(0, _extends2.default)({
263
+ })) : (0, _toConsumableArray2.default)(_this.props.hasAll ? [(0, _extends2.default)({
264
264
  id: '_all',
265
265
  label: _this.props.translations.all
266
266
  }, _this.props.iconAll && {
267
267
  type: 'icon',
268
268
  icon: _this.props.iconAll
269
- })] : []), (0, _toConsumableArray2.default)(options))));
269
+ })] : []).concat((0, _toConsumableArray2.default)(options))));
270
270
  return {
271
271
  itemList: itemList
272
272
  };
@@ -286,10 +286,10 @@ function (_React$PureComponent) {
286
286
  searchValue: props.searchValue ? undefined : '',
287
287
  suggestions: props.options
288
288
  };
289
- _this.handleSearch = _this.handleSearch.bind((0, _assertThisInitialized2.default)(_this));
290
- _this.handleSearchReset = _this.handleSearchReset.bind((0, _assertThisInitialized2.default)(_this));
291
- _this.handleSelect = _this.handleSelect.bind((0, _assertThisInitialized2.default)(_this));
292
- _this.handleSuggestions = _this.handleSuggestions.bind((0, _assertThisInitialized2.default)(_this));
289
+ _this.handleSearch = _this.handleSearch.bind((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)));
290
+ _this.handleSearchReset = _this.handleSearchReset.bind((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)));
291
+ _this.handleSelect = _this.handleSelect.bind((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)));
292
+ _this.handleSuggestions = _this.handleSuggestions.bind((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)));
293
293
  return _this;
294
294
  }
295
295
 
@@ -17,10 +17,10 @@ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime
17
17
 
18
18
  var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
19
19
 
20
- var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
21
-
22
20
  var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
23
21
 
22
+ var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
23
+
24
24
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
25
25
 
26
26
  var _react = _interopRequireDefault(require("react"));
@@ -234,11 +234,11 @@ function (_React$PureComponent) {
234
234
  }
235
235
  };
236
236
 
237
- _this.handleKeyDown = _this.handleKeyDown.bind((0, _assertThisInitialized2.default)(_this));
238
- _this.handleClick = _this.handleClick.bind((0, _assertThisInitialized2.default)(_this));
239
- _this.handleBlur = _this.handleBlur.bind((0, _assertThisInitialized2.default)(_this));
240
- _this.ref = _this.ref.bind((0, _assertThisInitialized2.default)(_this));
241
- _this.handleReset = _this.handleReset.bind((0, _assertThisInitialized2.default)(_this));
237
+ _this.handleKeyDown = _this.handleKeyDown.bind((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)));
238
+ _this.handleClick = _this.handleClick.bind((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)));
239
+ _this.handleBlur = _this.handleBlur.bind((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)));
240
+ _this.ref = _this.ref.bind((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)));
241
+ _this.handleReset = _this.handleReset.bind((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)));
242
242
  return _this;
243
243
  }
244
244
 
@@ -19,8 +19,6 @@ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime
19
19
 
20
20
  var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
21
21
 
22
- var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
23
-
24
22
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
25
23
 
26
24
  var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
@@ -87,7 +85,8 @@ function (_React$PureComponent) {
87
85
  value: function getDerivedStateFromProps(props, state) {
88
86
  if (JSON.stringify(props.options) !== JSON.stringify(state.options)) {
89
87
  return {
90
- options: props.options
88
+ options: props.options,
89
+ suggestionFocusIndex: -1
91
90
  };
92
91
  }
93
92
 
@@ -101,6 +100,14 @@ function (_React$PureComponent) {
101
100
  (0, _classCallCheck2.default)(this, HiSuggestSelect);
102
101
  _this = (0, _possibleConstructorReturn2.default)(this, (0, _getPrototypeOf2.default)(HiSuggestSelect).call(this, props));
103
102
 
103
+ _this.getInputElement = function (el) {
104
+ _this.textInput = el;
105
+
106
+ if (_this.props.inputRef) {
107
+ _this.props.inputRef(_this.textInput);
108
+ }
109
+ };
110
+
104
111
  _this.handleSelect = function (event, value) {
105
112
  document.body.style.overflow = 'auto';
106
113
 
@@ -144,74 +151,73 @@ function (_React$PureComponent) {
144
151
  };
145
152
 
146
153
  _this.handleKeyDownSearch = function (event) {
147
- if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {
148
- document.body.style.overflow = 'hidden'; // On récupère la div parent "overlay"
154
+ if (event.key === 'ArrowDown') {
155
+ event.preventDefault();
149
156
 
150
- var overlay = (0, _reactDom.findDOMNode)(_this.overlay);
151
- setTimeout(function () {
152
- // On recupère tous les items
153
- var items = overlay.getElementsByTagName('li');
157
+ if (_this.state.suggestionFocusIndex < _this.props.options.length - 1) {
158
+ _this.setState(function (prevState) {
159
+ return {
160
+ suggestionFocusIndex: prevState.suggestionFocusIndex + 1
161
+ };
162
+ });
163
+ }
164
+ } else if (event.key === 'ArrowUp') {
165
+ event.preventDefault();
154
166
 
155
- if (items.length) {
156
- // On focus sur le premier
157
- items[0].focus();
158
- }
159
- }, 1);
167
+ if (_this.state.suggestionFocusIndex >= 0) {
168
+ _this.setState(function (prevState) {
169
+ return {
170
+ suggestionFocusIndex: prevState.suggestionFocusIndex - 1
171
+ };
172
+ });
173
+ }
174
+ } else if (event.key === 'Enter' && _this.state.suggestionFocusIndex >= 0) {
175
+ event.preventDefault(); // Suggestion focused
176
+
177
+ _this.handleSelect(event, _this.state.options[_this.state.suggestionFocusIndex]);
160
178
  } else if (event.key === 'Escape') {
161
179
  _this.setState({
162
- options: []
180
+ options: [],
181
+ suggestionFocusIndex: -1
163
182
  });
164
183
  }
165
184
  };
166
185
 
167
- _this.state = {
168
- focused: false,
169
- options: props.options
170
- };
171
- _this.handleSelect = _this.handleSelect.bind((0, _assertThisInitialized2.default)(_this));
172
- _this.handleBlur = _this.handleBlur.bind((0, _assertThisInitialized2.default)(_this));
173
- _this.handleFocus = _this.handleFocus.bind((0, _assertThisInitialized2.default)(_this));
174
- _this.getInputElement = _this.getInputElement.bind((0, _assertThisInitialized2.default)(_this));
175
- return _this;
176
- }
177
-
178
- (0, _createClass2.default)(HiSuggestSelect, [{
179
- key: "getInputElement",
180
- value: function getInputElement(el) {
181
- this.textInput = el;
182
-
183
- if (this.props.inputRef) {
184
- this.props.inputRef(this.textInput);
185
- }
186
- }
187
- }, {
188
- key: "handleFocus",
189
- value: function handleFocus(event) {
190
- this.setState({
186
+ _this.handleFocus = function (event) {
187
+ _this.setState({
191
188
  focused: true
192
189
  });
193
190
 
194
- if (this.props.onFocusInput) {
195
- this.props.onFocusInput(event);
191
+ if (_this.props.onFocusInput) {
192
+ _this.props.onFocusInput(event);
196
193
  }
197
- }
198
- }, {
199
- key: "handleBlur",
200
- value: function handleBlur(event) {
194
+ };
195
+
196
+ _this.handleBlur = function (event) {
201
197
  // Si on click sur un élément de HiInput, on garde le focus
202
198
  // Par exemple sur l'icone reset
203
- if (!event.relatedTarget || !this.overlay || !this.overlay.contains(event.relatedTarget)) {
204
- this.setState({
199
+ if (!event.relatedTarget || !_this.overlay || !_this.overlay.contains(event.relatedTarget)) {
200
+ _this.setState({
205
201
  options: [],
206
- focused: false
202
+ focused: false,
203
+ suggestionFocusIndex: -1
207
204
  });
208
205
 
209
- if (this.props.onBlurInput) {
210
- this.props.onBlurInput(event);
206
+ if (_this.props.onBlurInput) {
207
+ _this.props.onBlurInput(event);
211
208
  }
212
209
  }
213
- }
214
- }, {
210
+ };
211
+
212
+ _this.state = {
213
+ focused: false,
214
+ options: props.options,
215
+ suggestionFocusIndex: -1
216
+ };
217
+ return _this;
218
+ }
219
+
220
+ (0, _createClass2.default)(HiSuggestSelect, [{
215
221
  key: "render",
216
222
  value: function render() {
217
223
  var _this2 = this;
@@ -229,7 +235,8 @@ function (_React$PureComponent) {
229
235
  otherProps = (0, _objectWithoutProperties2.default)(_this$props, ["classes", "id", "loading", "showMinLength", "showNoResults", "onSearch", "translations", "align", "inputClasses"]);
230
236
  var _this$state = this.state,
231
237
  focused = _this$state.focused,
232
- options = _this$state.options;
238
+ options = _this$state.options,
239
+ suggestionFocusIndex = _this$state.suggestionFocusIndex;
233
240
  var optionsShown = options; // If loading
234
241
 
235
242
  if (loading) {
@@ -288,7 +295,8 @@ function (_React$PureComponent) {
288
295
  hideCheckbox: true,
289
296
  onSelect: this.handleSelect,
290
297
  translations: translations,
291
- onKeyDown: this.handleKeyDown
298
+ onKeyDown: this.handleKeyDown,
299
+ suggestionFocusIndex: suggestionFocusIndex
292
300
  })))));
293
301
  }
294
302
  }]);
@@ -11,6 +11,8 @@ exports.default = exports.styles = void 0;
11
11
 
12
12
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
13
13
 
14
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
15
+
14
16
  var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
15
17
 
16
18
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
@@ -39,10 +41,16 @@ var _keycode = _interopRequireDefault(require("keycode"));
39
41
 
40
42
  var _reactLazyload = _interopRequireWildcard(require("react-lazyload"));
41
43
 
42
- var styles = function styles() {
44
+ var _classnames = _interopRequireDefault(require("classnames"));
45
+
46
+ var styles = function styles(theme) {
43
47
  return {
44
48
  root: {
45
49
  padding: 0
50
+ },
51
+ suggestionFocus: {
52
+ backgroundColor: theme.palette.action.hover,
53
+ fontWeight: theme.typography.fontWeightMedium
46
54
  }
47
55
  };
48
56
  };
@@ -96,8 +104,8 @@ function (_React$PureComponent) {
96
104
  }
97
105
  };
98
106
 
99
- _this.buildRecursiveListItem = function (item) {
100
- var level = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
107
+ _this.buildRecursiveListItem = function (item, index) {
108
+ var level = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
101
109
  var _this$props = _this.props,
102
110
  checkedIcon = _this$props.checkedIcon,
103
111
  disabled = _this$props.disabled,
@@ -110,7 +118,9 @@ function (_React$PureComponent) {
110
118
  sort = _this$props.sort,
111
119
  onKeyDown = _this$props.onKeyDown,
112
120
  onKeyUp = _this$props.onKeyUp,
113
- others = (0, _objectWithoutProperties2.default)(_this$props, ["checkedIcon", "disabled", "disabledItemIdList", "hideCheckbox", "hoverIcon", "icon", "lazy", "selectedItemIdList", "sort", "onKeyDown", "onKeyUp"]);
121
+ suggestionFocusIndex = _this$props.suggestionFocusIndex,
122
+ classes = _this$props.classes,
123
+ others = (0, _objectWithoutProperties2.default)(_this$props, ["checkedIcon", "disabled", "disabledItemIdList", "hideCheckbox", "hoverIcon", "icon", "lazy", "selectedItemIdList", "sort", "onKeyDown", "onKeyUp", "suggestionFocusIndex", "classes"]);
114
124
 
115
125
  if (sort && item.children) {
116
126
  item.children.sort(_this.compareItem);
@@ -147,11 +157,14 @@ function (_React$PureComponent) {
147
157
  onKeyUp: onKeyUp,
148
158
  selected: selectedItemIdList.includes(item.id) // item props override upper props (disabled, hideCheckbox, icon, level...)
149
159
  ,
150
- item: item
160
+ item: item,
161
+ classes: {
162
+ listItem: (0, _classnames.default)((0, _defineProperty2.default)({}, classes.suggestionFocus, index === suggestionFocusIndex))
163
+ }
151
164
  }, item)), item.children && item.children.length > 0 && item.children.filter(function (subItem) {
152
165
  return !(subItem.displayed === false);
153
166
  }).map(function (subItem) {
154
- return _this.buildRecursiveListItem(subItem, level + 1);
167
+ return _this.buildRecursiveListItem(subItem, index, level + 1);
155
168
  }));
156
169
 
157
170
  if (lazy) {
@@ -255,8 +268,8 @@ function (_React$PureComponent) {
255
268
  }, itemList.filter(function (item) {
256
269
  return !(item.displayed === false);
257
270
  }) // don't remove if undefined
258
- .map(function (item) {
259
- return _this3.buildRecursiveListItem(item);
271
+ .map(function (item, index) {
272
+ return _this3.buildRecursiveListItem(item, index);
260
273
  }));
261
274
  }
262
275
  }]);
@@ -347,6 +360,11 @@ HiSelectableList.propTypes = process.env.NODE_ENV !== "production" ? {
347
360
  */
348
361
  selectedItemIdList: _propTypes.default.array,
349
362
 
363
+ /**
364
+ * Index de l'item "focus"
365
+ */
366
+ suggestionFocusIndex: _propTypes.default.number,
367
+
350
368
  /**
351
369
  * Tri des éléments selon leur label
352
370
  */
@@ -365,7 +383,8 @@ HiSelectableList.propTypes = process.env.NODE_ENV !== "production" ? {
365
383
 
366
384
  var _default = (0, _withStyles.default)(styles, {
367
385
  hiComponent: true,
368
- name: 'HmuiHiSelectableList'
386
+ name: 'HmuiHiSelectableList',
387
+ index: 51
369
388
  })(HiSelectableList);
370
389
 
371
390
  exports.default = _default;