@zohodesk/components 1.4.8 → 1.4.10-exp-0

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 (47) hide show
  1. package/.cli/propValidation_report.html +1 -1
  2. package/README.md +22 -0
  3. package/es/MultiSelect/AdvancedGroupMultiSelect.js +16 -8
  4. package/es/MultiSelect/AdvancedMultiSelect.js +13 -6
  5. package/es/MultiSelect/EmptyState.js +2 -1
  6. package/es/MultiSelect/MultiSelect.js +36 -15
  7. package/es/MultiSelect/MultiSelectWithAvatar.js +9 -2
  8. package/es/MultiSelect/SelectedOptions.js +4 -2
  9. package/es/MultiSelect/Suggestions.js +174 -97
  10. package/es/MultiSelect/__tests__/MultiSelect.spec.js +25 -0
  11. package/es/MultiSelect/__tests__/Suggestions.spec.js +58 -0
  12. package/es/MultiSelect/__tests__/__snapshots__/MultiSelect.spec.js.snap +253 -0
  13. package/es/MultiSelect/__tests__/__snapshots__/Suggestions.spec.js.snap +343 -0
  14. package/es/MultiSelect/constants.js +6 -0
  15. package/es/MultiSelect/props/defaultProps.js +2 -0
  16. package/es/MultiSelect/props/propTypes.js +18 -55
  17. package/es/Select/Select.js +13 -3
  18. package/es/Select/SelectWithIcon.js +1 -1
  19. package/es/Select/__tests__/Select.spec.js +16 -8
  20. package/es/Select/__tests__/__snapshots__/Select.spec.js.snap +281 -0
  21. package/es/Select/props/defaultProps.js +1 -0
  22. package/es/Select/props/propTypes.js +1 -0
  23. package/es/utils/Common.js +3 -2
  24. package/es/utils/dropDownUtils.js +28 -7
  25. package/lib/MultiSelect/AdvancedGroupMultiSelect.js +94 -83
  26. package/lib/MultiSelect/AdvancedMultiSelect.js +16 -7
  27. package/lib/MultiSelect/EmptyState.js +3 -1
  28. package/lib/MultiSelect/MultiSelect.js +39 -15
  29. package/lib/MultiSelect/MultiSelectWithAvatar.js +11 -3
  30. package/lib/MultiSelect/SelectedOptions.js +4 -2
  31. package/lib/MultiSelect/Suggestions.js +176 -100
  32. package/lib/MultiSelect/__tests__/MultiSelect.spec.js +25 -0
  33. package/lib/MultiSelect/__tests__/Suggestions.spec.js +58 -0
  34. package/lib/MultiSelect/__tests__/__snapshots__/MultiSelect.spec.js.snap +253 -0
  35. package/lib/MultiSelect/__tests__/__snapshots__/Suggestions.spec.js.snap +343 -0
  36. package/lib/MultiSelect/constants.js +13 -0
  37. package/lib/MultiSelect/props/defaultProps.js +2 -0
  38. package/lib/MultiSelect/props/propTypes.js +17 -55
  39. package/lib/Select/Select.js +13 -2
  40. package/lib/Select/SelectWithIcon.js +1 -1
  41. package/lib/Select/__tests__/Select.spec.js +165 -155
  42. package/lib/Select/__tests__/__snapshots__/Select.spec.js.snap +281 -0
  43. package/lib/Select/props/defaultProps.js +1 -0
  44. package/lib/Select/props/propTypes.js +1 -0
  45. package/lib/utils/Common.js +5 -3
  46. package/lib/utils/dropDownUtils.js +27 -4
  47. package/package.json +9 -8
@@ -13,6 +13,8 @@ var _propTypes = require("./props/propTypes");
13
13
 
14
14
  var _defaultProps = require("./props/defaultProps");
15
15
 
16
+ var _constants = require("./constants");
17
+
16
18
  var _Loader = _interopRequireDefault(require("@zohodesk/svg/lib/Loader/Loader"));
17
19
 
18
20
  var _Popup = _interopRequireDefault(require("../Popup/Popup"));
@@ -266,7 +268,9 @@ var AdvancedGroupMultiSelect = /*#__PURE__*/function (_React$Component) {
266
268
  }, {
267
269
  key: "handleSelectedOptionIdChange",
268
270
  value: function handleSelectedOptionIdChange(selectedGroupOptions, normalizedFormatOptions, normalizedSelectedOptions) {
269
- var allowValueFallback = this.props.allowValueFallback;
271
+ var _this$props = this.props,
272
+ allowValueFallback = _this$props.allowValueFallback,
273
+ limit = _this$props.limit;
270
274
  var newSelectedOptions = selectedGroupOptions.map(function (option) {
271
275
  return (0, _dropDownUtils.optionIdGrouping)(option.id, option.groupId);
272
276
  });
@@ -279,16 +283,17 @@ var AdvancedGroupMultiSelect = /*#__PURE__*/function (_React$Component) {
279
283
  selectedOptions: newSelectedOptions,
280
284
  normalizedFormatOptions: formatOptions,
281
285
  selectedOptionsLength: selectedOptionsLength,
282
- allowValueFallback: allowValueFallback
286
+ allowValueFallback: allowValueFallback,
287
+ limit: limit
283
288
  });
284
289
  }
285
290
  }, {
286
291
  key: "togglePopup",
287
292
  value: function togglePopup(e) {
288
- var _this$props = this.props,
289
- togglePopup = _this$props.togglePopup,
290
- defaultDropBoxPosition = _this$props.defaultDropBoxPosition,
291
- isReadOnly = _this$props.isReadOnly;
293
+ var _this$props2 = this.props,
294
+ togglePopup = _this$props2.togglePopup,
295
+ defaultDropBoxPosition = _this$props2.defaultDropBoxPosition,
296
+ isReadOnly = _this$props2.isReadOnly;
292
297
  !isReadOnly && togglePopup(e, defaultDropBoxPosition ? "".concat(defaultDropBoxPosition, "Center") : null);
293
298
  }
294
299
  }, {
@@ -463,12 +468,13 @@ var AdvancedGroupMultiSelect = /*#__PURE__*/function (_React$Component) {
463
468
  lastHighLightedSelectOption = _this$state5.lastHighLightedSelectOption,
464
469
  shiftKeyPressHighLighted = _this$state5.shiftKeyPressHighLighted,
465
470
  selectedOptions = _this$state5.selectedOptionIds;
466
- var _this$props2 = this.props,
467
- isNextOptions = _this$props2.isNextOptions,
468
- getNextOptions = _this$props2.getNextOptions,
469
- isPopupOpen = _this$props2.isPopupOpen,
470
- isPopupOpenOnEnter = _this$props2.isPopupOpenOnEnter,
471
- onKeyDown = _this$props2.onKeyDown;
471
+ var _this$props3 = this.props,
472
+ isNextOptions = _this$props3.isNextOptions,
473
+ getNextOptions = _this$props3.getNextOptions,
474
+ isPopupOpen = _this$props3.isPopupOpen,
475
+ isPopupOpenOnEnter = _this$props3.isPopupOpenOnEnter,
476
+ onKeyDown = _this$props3.onKeyDown,
477
+ limit = _this$props3.limit;
472
478
  var highLightedSelectOptionsLen = highLightedSelectOptions.length;
473
479
 
474
480
  if (isPopupOpen && (keyCode === 38 || keyCode === 40 || keyCode === 13 || keyCode === 27)) {
@@ -519,7 +525,7 @@ var AdvancedGroupMultiSelect = /*#__PURE__*/function (_React$Component) {
519
525
  hoverIndex: hoverIndex + 1
520
526
  });
521
527
  }
522
- } else if (keyCode === 13) {
528
+ } else if (keyCode === 13 && selectedOptions.length < limit) {
523
529
  //enter key
524
530
  var id = suggestions[hoverIndex] || {};
525
531
  isPopupOpen && !(0, _Common.getIsEmptyValue)(id) && this.handleSelectOption(id, null, null, e);
@@ -678,9 +684,9 @@ var AdvancedGroupMultiSelect = /*#__PURE__*/function (_React$Component) {
678
684
  value: function handleSearch(value, e) {
679
685
  var _this4 = this;
680
686
 
681
- var _this$props3 = this.props,
682
- onSearch = _this$props3.onSearch,
683
- isPopupOpen = _this$props3.isPopupOpen;
687
+ var _this$props4 = this.props,
688
+ onSearch = _this$props4.onSearch,
689
+ isPopupOpen = _this$props4.isPopupOpen;
684
690
  !isPopupOpen && e && this.togglePopup(e);
685
691
  var _this$state$searchStr = this.state.searchStr,
686
692
  searchStr = _this$state$searchStr === void 0 ? '' : _this$state$searchStr;
@@ -747,11 +753,11 @@ var AdvancedGroupMultiSelect = /*#__PURE__*/function (_React$Component) {
747
753
  value: function handleChange() {
748
754
  var selectedOptions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
749
755
  var e = arguments.length > 1 ? arguments[1] : undefined;
750
- var _this$props4 = this.props,
751
- onChange = _this$props4.onChange,
752
- needToCloseOnSelect = _this$props4.needToCloseOnSelect,
753
- togglePopup = _this$props4.togglePopup,
754
- isSearchClearOnSelect = _this$props4.isSearchClearOnSelect;
756
+ var _this$props5 = this.props,
757
+ onChange = _this$props5.onChange,
758
+ needToCloseOnSelect = _this$props5.needToCloseOnSelect,
759
+ togglePopup = _this$props5.togglePopup,
760
+ isSearchClearOnSelect = _this$props5.isSearchClearOnSelect;
755
761
  var searchStr = this.state.searchStr;
756
762
  var newSelectedOptions = selectedOptions.map(function (option) {
757
763
  return (0, _dropDownUtils.extractOptionId)(option);
@@ -816,9 +822,9 @@ var AdvancedGroupMultiSelect = /*#__PURE__*/function (_React$Component) {
816
822
  }, {
817
823
  key: "handleInputFocus",
818
824
  value: function handleInputFocus() {
819
- var _this$props5 = this.props,
820
- isDisabled = _this$props5.isDisabled,
821
- isReadOnly = _this$props5.isReadOnly;
825
+ var _this$props6 = this.props,
826
+ isDisabled = _this$props6.isDisabled,
827
+ isReadOnly = _this$props6.isReadOnly;
822
828
  this.searchInput && !isDisabled && !isReadOnly && this.searchInput.focus({
823
829
  preventScroll: true
824
830
  });
@@ -836,13 +842,13 @@ var AdvancedGroupMultiSelect = /*#__PURE__*/function (_React$Component) {
836
842
  }, {
837
843
  key: "componentDidUpdate",
838
844
  value: function componentDidUpdate(prevProps) {
839
- var _this$props6 = this.props,
840
- groupedOptions = _this$props6.groupedOptions,
841
- selectedGroupOptions = _this$props6.selectedGroupOptions,
842
- isPopupOpen = _this$props6.isPopupOpen,
843
- selectedOptionDetails = _this$props6.selectedOptionDetails,
844
- searchStr = _this$props6.searchStr,
845
- notifyPopupToggle = _this$props6.notifyPopupToggle;
845
+ var _this$props7 = this.props,
846
+ groupedOptions = _this$props7.groupedOptions,
847
+ selectedGroupOptions = _this$props7.selectedGroupOptions,
848
+ isPopupOpen = _this$props7.isPopupOpen,
849
+ selectedOptionDetails = _this$props7.selectedOptionDetails,
850
+ searchStr = _this$props7.searchStr,
851
+ notifyPopupToggle = _this$props7.notifyPopupToggle;
846
852
  var _this$state8 = this.state,
847
853
  normalizedFormatOptions = _this$state8.normalizedFormatOptions,
848
854
  hoverIndex = _this$state8.hoverIndex;
@@ -895,10 +901,10 @@ var AdvancedGroupMultiSelect = /*#__PURE__*/function (_React$Component) {
895
901
  var selSuggestion = this["suggestion_".concat(hoverId)];
896
902
  isPopupOpen && (0, _Common.scrollTo)(this.suggestionContainer, selSuggestion); //When suggestions length less than 5, getNextOptions function call
897
903
 
898
- var _this$props7 = this.props,
899
- isNextOptions = _this$props7.isNextOptions,
900
- getNextOptions = _this$props7.getNextOptions,
901
- needLocalSearch = _this$props7.needLocalSearch;
904
+ var _this$props8 = this.props,
905
+ isNextOptions = _this$props8.isNextOptions,
906
+ getNextOptions = _this$props8.getNextOptions,
907
+ needLocalSearch = _this$props8.needLocalSearch;
902
908
 
903
909
  var _this$handleFilterSug3 = this.handleFilterSuggestions(),
904
910
  suggestions = _this$handleFilterSug3.suggestionOptionIds;
@@ -928,56 +934,59 @@ var AdvancedGroupMultiSelect = /*#__PURE__*/function (_React$Component) {
928
934
  value: function render() {
929
935
  var _this5 = this;
930
936
 
931
- var _this$props8 = this.props,
932
- size = _this$props8.size,
933
- textBoxSize = _this$props8.textBoxSize,
934
- selectedGroupOptions = _this$props8.selectedGroupOptions,
935
- placeHolder = _this$props8.placeHolder,
936
- dataId = _this$props8.dataId,
937
- dataSelectorId = _this$props8.dataSelectorId,
938
- isReadOnly = _this$props8.isReadOnly,
939
- isDisabled = _this$props8.isDisabled,
940
- isPopupOpen = _this$props8.isPopupOpen,
941
- isPopupReady = _this$props8.isPopupReady,
942
- defaultDropBoxPosition = _this$props8.defaultDropBoxPosition,
943
- removeClose = _this$props8.removeClose,
944
- needResponsive = _this$props8.needResponsive,
945
- animationStyle = _this$props8.animationStyle,
946
- needSelectAll = _this$props8.needSelectAll,
947
- selectAllText = _this$props8.selectAllText,
948
- dropBoxSize = _this$props8.dropBoxSize,
949
- position = _this$props8.position,
950
- getContainerRef = _this$props8.getContainerRef,
951
- isAbsolutePositioningNeeded = _this$props8.isAbsolutePositioningNeeded,
952
- positionsOffset = _this$props8.positionsOffset,
953
- targetOffset = _this$props8.targetOffset,
954
- isRestrictScroll = _this$props8.isRestrictScroll,
955
- emptyMessage = _this$props8.emptyMessage,
956
- searchEmptyMessage = _this$props8.searchEmptyMessage,
957
- title = _this$props8.title,
958
- variant = _this$props8.variant,
959
- children = _this$props8.children,
960
- listItemSize = _this$props8.listItemSize,
961
- isDataLoaded = _this$props8.isDataLoaded,
962
- needBorder = _this$props8.needBorder,
963
- isNextOptions = _this$props8.isNextOptions,
964
- getFooter = _this$props8.getFooter,
965
- customClass = _this$props8.customClass,
966
- borderColor = _this$props8.borderColor,
967
- isPadding = _this$props8.isPadding,
968
- htmlId = _this$props8.htmlId,
969
- i18nKeys = _this$props8.i18nKeys,
970
- a11y = _this$props8.a11y,
971
- palette = _this$props8.palette,
972
- needEffect = _this$props8.needEffect,
973
- autoComplete = _this$props8.autoComplete,
974
- getTargetRef = _this$props8.getTargetRef,
975
- isFocus = _this$props8.isFocus;
937
+ var _this$props9 = this.props,
938
+ size = _this$props9.size,
939
+ textBoxSize = _this$props9.textBoxSize,
940
+ selectedGroupOptions = _this$props9.selectedGroupOptions,
941
+ placeHolder = _this$props9.placeHolder,
942
+ dataId = _this$props9.dataId,
943
+ dataSelectorId = _this$props9.dataSelectorId,
944
+ isReadOnly = _this$props9.isReadOnly,
945
+ isDisabled = _this$props9.isDisabled,
946
+ isPopupOpen = _this$props9.isPopupOpen,
947
+ isPopupReady = _this$props9.isPopupReady,
948
+ defaultDropBoxPosition = _this$props9.defaultDropBoxPosition,
949
+ removeClose = _this$props9.removeClose,
950
+ needResponsive = _this$props9.needResponsive,
951
+ animationStyle = _this$props9.animationStyle,
952
+ needSelectAll = _this$props9.needSelectAll,
953
+ selectAllText = _this$props9.selectAllText,
954
+ dropBoxSize = _this$props9.dropBoxSize,
955
+ position = _this$props9.position,
956
+ getContainerRef = _this$props9.getContainerRef,
957
+ isAbsolutePositioningNeeded = _this$props9.isAbsolutePositioningNeeded,
958
+ positionsOffset = _this$props9.positionsOffset,
959
+ targetOffset = _this$props9.targetOffset,
960
+ isRestrictScroll = _this$props9.isRestrictScroll,
961
+ emptyMessage = _this$props9.emptyMessage,
962
+ searchEmptyMessage = _this$props9.searchEmptyMessage,
963
+ title = _this$props9.title,
964
+ variant = _this$props9.variant,
965
+ children = _this$props9.children,
966
+ listItemSize = _this$props9.listItemSize,
967
+ isDataLoaded = _this$props9.isDataLoaded,
968
+ needBorder = _this$props9.needBorder,
969
+ isNextOptions = _this$props9.isNextOptions,
970
+ getFooter = _this$props9.getFooter,
971
+ customClass = _this$props9.customClass,
972
+ borderColor = _this$props9.borderColor,
973
+ isPadding = _this$props9.isPadding,
974
+ htmlId = _this$props9.htmlId,
975
+ i18nKeys = _this$props9.i18nKeys,
976
+ a11y = _this$props9.a11y,
977
+ palette = _this$props9.palette,
978
+ needEffect = _this$props9.needEffect,
979
+ autoComplete = _this$props9.autoComplete,
980
+ getTargetRef = _this$props9.getTargetRef,
981
+ isFocus = _this$props9.isFocus,
982
+ limit = _this$props9.limit;
976
983
  var _i18nKeys = i18nKeys,
977
984
  _i18nKeys$clearText = _i18nKeys.clearText,
978
- clearText = _i18nKeys$clearText === void 0 ? 'Clear all' : _i18nKeys$clearText;
985
+ clearText = _i18nKeys$clearText === void 0 ? _constants.MULTISELECT_I18N_KEYS.clearText : _i18nKeys$clearText,
986
+ _i18nKeys$limitReache = _i18nKeys.limitReachedMessage,
987
+ limitReachedMessage = _i18nKeys$limitReache === void 0 ? _constants.MULTISELECT_I18N_KEYS.limitReachedMessage : _i18nKeys$limitReache;
979
988
  var _a11y$clearLabel = a11y.clearLabel,
980
- clearLabel = _a11y$clearLabel === void 0 ? 'Clear all' : _a11y$clearLabel;
989
+ clearLabel = _a11y$clearLabel === void 0 ? _constants.MULTISELECT_I18N_KEYS.clearText : _a11y$clearLabel;
981
990
  i18nKeys = Object.assign({}, i18nKeys, {
982
991
  emptyText: i18nKeys.emptyText || emptyMessage,
983
992
  searchEmptyText: i18nKeys.searchEmptyText || searchEmptyMessage
@@ -1110,7 +1119,7 @@ var AdvancedGroupMultiSelect = /*#__PURE__*/function (_React$Component) {
1110
1119
  }, /*#__PURE__*/_react["default"].createElement(_Card["default"], {
1111
1120
  customClass: "".concat(_MultiSelectModule["default"].box, " ").concat(_MultiSelectModule["default"]["".concat(palette, "Box")]),
1112
1121
  onScroll: _this5.handleScroll
1113
- }, needSelectAll ? /*#__PURE__*/_react["default"].createElement(_Card.CardHeader, null, /*#__PURE__*/_react["default"].createElement(_MultiSelectHeader["default"], {
1122
+ }, needSelectAll && !(limit >= 0) ? /*#__PURE__*/_react["default"].createElement(_Card.CardHeader, null, /*#__PURE__*/_react["default"].createElement(_MultiSelectHeader["default"], {
1114
1123
  onSelect: _this5.handleSelectAll,
1115
1124
  selectAllText: selectAllText,
1116
1125
  suggestions: suggestionOptionIds,
@@ -1148,6 +1157,8 @@ var AdvancedGroupMultiSelect = /*#__PURE__*/function (_React$Component) {
1148
1157
  a11y: {
1149
1158
  role: 'option'
1150
1159
  },
1160
+ limit: limit,
1161
+ limitReachedMessage: limitReachedMessage,
1151
1162
  dataId: "".concat(dataId, "_Options")
1152
1163
  }));
1153
1164
  }) : /*#__PURE__*/_react["default"].createElement(_EmptyState["default"], {
@@ -13,6 +13,8 @@ var _propTypes = require("./props/propTypes");
13
13
 
14
14
  var _defaultProps = require("./props/defaultProps");
15
15
 
16
+ var _constants = require("./constants");
17
+
16
18
  var _MultiSelect = require("./MultiSelect");
17
19
 
18
20
  var _SelectedOptions = _interopRequireDefault(require("./SelectedOptions"));
@@ -249,7 +251,8 @@ var AdvancedMultiSelectComponent = /*#__PURE__*/function (_MultiSelectComponent)
249
251
 
250
252
  var selectedOptionsLimit = props.selectedOptionsLimit,
251
253
  selectedOptionDetails = props.selectedOptionDetails,
252
- allowValueFallback = props.allowValueFallback;
254
+ allowValueFallback = props.allowValueFallback,
255
+ limit = props.limit;
253
256
  showedSelectedOptionsCount = (0, _Common.getIsEmptyValue)(showedSelectedOptionsCount) ? selectedOptionsLimit : showedSelectedOptionsCount;
254
257
 
255
258
  var _this$handleFormatSel = this.handleFormatSelectedOptions(selectedOptionDetails, props),
@@ -263,7 +266,8 @@ var AdvancedMultiSelectComponent = /*#__PURE__*/function (_MultiSelectComponent)
263
266
  selectedOptions: selectedOptions,
264
267
  normalizedFormatOptions: formatOptions,
265
268
  selectedOptionsLength: showedSelectedOptionsCount,
266
- allowValueFallback: allowValueFallback
269
+ allowValueFallback: allowValueFallback,
270
+ limit: limit
267
271
  });
268
272
  }
269
273
  }, {
@@ -454,7 +458,8 @@ var AdvancedMultiSelectComponent = /*#__PURE__*/function (_MultiSelectComponent)
454
458
  positionsOffset = _this$props6.positionsOffset,
455
459
  targetOffset = _this$props6.targetOffset,
456
460
  isRestrictScroll = _this$props6.isRestrictScroll,
457
- isFocus = _this$props6.isFocus;
461
+ isFocus = _this$props6.isFocus,
462
+ limit = _this$props6.limit;
458
463
  var _customProps$Suggesti = customProps.SuggestionsProps,
459
464
  SuggestionsProps = _customProps$Suggesti === void 0 ? {} : _customProps$Suggesti,
460
465
  _customProps$DropBoxP = customProps.DropBoxProps,
@@ -463,9 +468,11 @@ var AdvancedMultiSelectComponent = /*#__PURE__*/function (_MultiSelectComponent)
463
468
  containerClass = _customClass$containe === void 0 ? '' : _customClass$containe;
464
469
  var _i18nKeys = i18nKeys,
465
470
  _i18nKeys$clearText = _i18nKeys.clearText,
466
- clearText = _i18nKeys$clearText === void 0 ? 'Clear all' : _i18nKeys$clearText;
471
+ clearText = _i18nKeys$clearText === void 0 ? _constants.MULTISELECT_I18N_KEYS.clearText : _i18nKeys$clearText,
472
+ _i18nKeys$limitReache = _i18nKeys.limitReachedMessage,
473
+ limitReachedMessage = _i18nKeys$limitReache === void 0 ? _constants.MULTISELECT_I18N_KEYS.limitReachedMessage : _i18nKeys$limitReache;
467
474
  var _a11y$clearLabel = a11y.clearLabel,
468
- clearLabel = _a11y$clearLabel === void 0 ? 'Clear all' : _a11y$clearLabel;
475
+ clearLabel = _a11y$clearLabel === void 0 ? _constants.MULTISELECT_I18N_KEYS.clearText : _a11y$clearLabel;
469
476
  i18nKeys = Object.assign({}, i18nKeys, {
470
477
  emptyText: i18nKeys.emptyText || emptyMessage,
471
478
  noMoreText: i18nKeys.noMoreText || noMoreOptionsMessage,
@@ -604,7 +611,7 @@ var AdvancedMultiSelectComponent = /*#__PURE__*/function (_MultiSelectComponent)
604
611
  }, /*#__PURE__*/_react["default"].createElement(_Card["default"], {
605
612
  customClass: _MultiSelectModule["default"].box,
606
613
  onScroll: _this4.handleScroll
607
- }, needSelectAll ? /*#__PURE__*/_react["default"].createElement(_Card.CardHeader, null, /*#__PURE__*/_react["default"].createElement(_MultiSelectHeader["default"], {
614
+ }, needSelectAll && !(limit >= 0) ? /*#__PURE__*/_react["default"].createElement(_Card.CardHeader, null, /*#__PURE__*/_react["default"].createElement(_MultiSelectHeader["default"], {
608
615
  onSelect: _this4.handleSelectAll,
609
616
  selectAllText: selectAllText,
610
617
  suggestions: suggestions,
@@ -625,7 +632,9 @@ var AdvancedMultiSelectComponent = /*#__PURE__*/function (_MultiSelectComponent)
625
632
  a11y: {
626
633
  role: 'option'
627
634
  },
628
- dataId: "".concat(dataIdMultiSelectComp, "_Options")
635
+ dataId: "".concat(dataIdMultiSelectComp, "_Options"),
636
+ limit: limit,
637
+ limitReachedMessage: limitReachedMessage
629
638
  }, SuggestionsProps)) : /*#__PURE__*/_react["default"].createElement(_EmptyState["default"], {
630
639
  isLoading: isFetchingOptions,
631
640
  options: options,
@@ -13,6 +13,8 @@ var _propTypes = require("./props/propTypes");
13
13
 
14
14
  var _defaultProps = require("./props/defaultProps");
15
15
 
16
+ var _constants = require("./constants");
17
+
16
18
  var _MultiSelectModule = _interopRequireDefault(require("./MultiSelect.module.css"));
17
19
 
18
20
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
@@ -66,7 +68,7 @@ var EmptyState = /*#__PURE__*/function (_React$PureComponent) {
66
68
  htmlId = _this$props.htmlId,
67
69
  a11y = _this$props.a11y;
68
70
  var _i18nKeys$loadingText = i18nKeys.loadingText,
69
- loadingText = _i18nKeys$loadingText === void 0 ? 'Loading' : _i18nKeys$loadingText,
71
+ loadingText = _i18nKeys$loadingText === void 0 ? _constants.MULTISELECT_I18N_KEYS.loadingText : _i18nKeys$loadingText,
70
72
  _i18nKeys$emptyText = i18nKeys.emptyText,
71
73
  emptyText = _i18nKeys$emptyText === void 0 ? emptyMessage : _i18nKeys$emptyText,
72
74
  _i18nKeys$noMoreText = i18nKeys.noMoreText,
@@ -15,6 +15,8 @@ var _defaultProps = require("./props/defaultProps");
15
15
 
16
16
  var _defaultProps2 = require("./MobileHeader/props/defaultProps");
17
17
 
18
+ var _constants = require("./constants");
19
+
18
20
  var _Popup = _interopRequireDefault(require("../Popup/Popup"));
19
21
 
20
22
  var _TextBoxIcon = _interopRequireDefault(require("../TextBoxIcon/TextBoxIcon"));
@@ -160,6 +162,7 @@ var MultiSelectComponent = /*#__PURE__*/function (_React$Component) {
160
162
  _this.handleSearchOptions = (0, _Common.debounce)(_this.handleSearchOptions.bind(_assertThisInitialized(_this)), searchDebounceTime);
161
163
  _this.handleScroll = _this.handleScroll.bind(_assertThisInitialized(_this));
162
164
  _this.handleScrollFuncCall = (0, _Common.debounce)(_this.handleScrollFuncCall.bind(_assertThisInitialized(_this)), 500);
165
+ _this.setSuggestionsVirtualizerContainerRefFunction = _this.setSuggestionsVirtualizerContainerRefFunction.bind(_assertThisInitialized(_this));
163
166
  return _this;
164
167
  }
165
168
 
@@ -316,11 +319,13 @@ var MultiSelectComponent = /*#__PURE__*/function (_React$Component) {
316
319
  }, {
317
320
  key: "handleGetSelectedOptions",
318
321
  value: function handleGetSelectedOptions(selectedOptions, normalizedFormatOptions, props) {
319
- var allowValueFallback = props.allowValueFallback;
322
+ var allowValueFallback = props.allowValueFallback,
323
+ limit = props.limit;
320
324
  return this.getSelectedOptions({
321
325
  selectedOptions: selectedOptions,
322
326
  normalizedFormatOptions: normalizedFormatOptions,
323
- allowValueFallback: allowValueFallback
327
+ allowValueFallback: allowValueFallback,
328
+ limit: limit
324
329
  });
325
330
  }
326
331
  }, {
@@ -393,7 +398,9 @@ var MultiSelectComponent = /*#__PURE__*/function (_React$Component) {
393
398
  getNextOptions = _this$props5.getNextOptions,
394
399
  isPopupOpen = _this$props5.isPopupOpen,
395
400
  isPopupOpenOnEnter = _this$props5.isPopupOpenOnEnter,
396
- onKeyDown = _this$props5.onKeyDown;
401
+ onKeyDown = _this$props5.onKeyDown,
402
+ limit = _this$props5.limit;
403
+ var allowKeyboardActions = !limit || limit && selectedOptions.length < limit;
397
404
  var highLightedSelectOptionsLen = highLightedSelectOptions.length;
398
405
 
399
406
  if (isPopupOpen && (keyCode === 38 || keyCode === 40 || keyCode === 13 || keyCode === 27 || keyCode === 9)) {
@@ -413,7 +420,7 @@ var MultiSelectComponent = /*#__PURE__*/function (_React$Component) {
413
420
 
414
421
  var suggestionsLen = suggestions.length;
415
422
 
416
- if (suggestionsLen && isPopupOpen && keyCode === 38) {
423
+ if (suggestionsLen && isPopupOpen && keyCode === 38 && allowKeyboardActions) {
417
424
  //up arrow
418
425
 
419
426
  /*if (hoverOption === 0) { //disable first to last option higlight
@@ -424,7 +431,7 @@ var MultiSelectComponent = /*#__PURE__*/function (_React$Component) {
424
431
  hoverOption: hoverOption - 1
425
432
  });
426
433
  }
427
- } else if (suggestionsLen && isPopupOpen && keyCode === 40) {
434
+ } else if (suggestionsLen && isPopupOpen && keyCode === 40 && allowKeyboardActions) {
428
435
  //down arrow
429
436
 
430
437
  /*else if (hoverOption === suggestionsLen - 1 || hoverOption === null) {
@@ -441,8 +448,8 @@ var MultiSelectComponent = /*#__PURE__*/function (_React$Component) {
441
448
  hoverOption: hoverOption + 1
442
449
  });
443
450
  }
444
- } else if (keyCode === 13) {
445
- //enter key
451
+ } else if (keyCode === 13 && allowKeyboardActions) {
452
+ //enter ke
446
453
  var selectedOption = suggestions[hoverOption] || {};
447
454
  var id = selectedOption.id;
448
455
  isPopupOpen && !(0, _Common.getIsEmptyValue)(id) && this.handleSelectOption(id, e);
@@ -809,12 +816,14 @@ var MultiSelectComponent = /*#__PURE__*/function (_React$Component) {
809
816
  togglePopup = _this$props10.togglePopup,
810
817
  propSelectedOptions = _this$props10.selectedOptions,
811
818
  _this$props10$disable = _this$props10.disabledOptions,
812
- disabledOptions = _this$props10$disable === void 0 ? dummyArray : _this$props10$disable;
819
+ disabledOptions = _this$props10$disable === void 0 ? dummyArray : _this$props10$disable,
820
+ limit = _this$props10.limit;
813
821
 
814
822
  var _filterSelectedOption = (0, _dropDownUtils.filterSelectedOptions)({
815
823
  selectedOptions: selectedOptions,
816
824
  propSelectedOptions: propSelectedOptions,
817
- disabledOptions: disabledOptions
825
+ disabledOptions: disabledOptions,
826
+ limit: limit
818
827
  }),
819
828
  newSelectedOptions = _filterSelectedOption.newSelectedOptions;
820
829
 
@@ -872,6 +881,7 @@ var MultiSelectComponent = /*#__PURE__*/function (_React$Component) {
872
881
  key: "suggestionContainerRef",
873
882
  value: function suggestionContainerRef(el) {
874
883
  this.suggestionContainer = el;
884
+ typeof this.setSuggestionsVirtualizerRef === 'function' && this.setSuggestionsVirtualizerRef(el);
875
885
  }
876
886
  }, {
877
887
  key: "suggestionItemRef",
@@ -934,6 +944,12 @@ var MultiSelectComponent = /*#__PURE__*/function (_React$Component) {
934
944
  openPopupOnly: openPopupOnly
935
945
  });
936
946
  }
947
+ }, {
948
+ key: "setSuggestionsVirtualizerContainerRefFunction",
949
+ value: function setSuggestionsVirtualizerContainerRefFunction(refFunc) {
950
+ this.setSuggestionsVirtualizerRef = refFunc;
951
+ this.suggestionContainer && refFunc(this.suggestionContainer);
952
+ }
937
953
  }, {
938
954
  key: "getSelectionUI",
939
955
  value: function getSelectionUI() {
@@ -973,9 +989,9 @@ var MultiSelectComponent = /*#__PURE__*/function (_React$Component) {
973
989
  highLightedSelectOptions = _this$state8.highLightedSelectOptions,
974
990
  searchStr = _this$state8.searchStr;
975
991
  var _i18nKeys$clearText = i18nKeys.clearText,
976
- clearText = _i18nKeys$clearText === void 0 ? 'Clear all' : _i18nKeys$clearText;
992
+ clearText = _i18nKeys$clearText === void 0 ? _constants.MULTISELECT_I18N_KEYS.clearText : _i18nKeys$clearText;
977
993
  var _a11y$clearLabel = a11y.clearLabel,
978
- clearLabel = _a11y$clearLabel === void 0 ? 'Clear all' : _a11y$clearLabel,
994
+ clearLabel = _a11y$clearLabel === void 0 ? _constants.MULTISELECT_I18N_KEYS.clearLabel : _a11y$clearLabel,
979
995
  ariaLabelledby = a11y.ariaLabelledby;
980
996
 
981
997
  var _this$getIsShowClearI = this.getIsShowClearIcon({
@@ -1110,7 +1126,9 @@ var MultiSelectComponent = /*#__PURE__*/function (_React$Component) {
1110
1126
  boxSize = _this$props15.boxSize,
1111
1127
  isLoading = _this$props15.isLoading,
1112
1128
  selectAllText = _this$props15.selectAllText,
1113
- needSelectAll = _this$props15.needSelectAll;
1129
+ needSelectAll = _this$props15.needSelectAll,
1130
+ isVirtualizerEnabled = _this$props15.isVirtualizerEnabled,
1131
+ limit = _this$props15.limit;
1114
1132
  var _this$state9 = this.state,
1115
1133
  selectedOptions = _this$state9.selectedOptions,
1116
1134
  searchStr = _this$state9.searchStr,
@@ -1120,7 +1138,9 @@ var MultiSelectComponent = /*#__PURE__*/function (_React$Component) {
1120
1138
  selectedOptionIds = _this$state9.selectedOptionIds;
1121
1139
  var _i18nKeys = i18nKeys,
1122
1140
  _i18nKeys$searchText = _i18nKeys.searchText,
1123
- searchText = _i18nKeys$searchText === void 0 ? 'Searching...' : _i18nKeys$searchText;
1141
+ searchText = _i18nKeys$searchText === void 0 ? _constants.MULTISELECT_I18N_KEYS.searchText : _i18nKeys$searchText,
1142
+ _i18nKeys$limitReache = _i18nKeys.limitReachedMessage,
1143
+ limitReachedMessage = _i18nKeys$limitReache === void 0 ? _constants.MULTISELECT_I18N_KEYS.limitReachedMessage : _i18nKeys$limitReache;
1124
1144
  var suggestions = this.handleFilterSuggestions();
1125
1145
  var setAriaId = this.getNextAriaId();
1126
1146
  var ariaErrorId = this.getNextAriaId();
@@ -1173,7 +1193,7 @@ var MultiSelectComponent = /*#__PURE__*/function (_React$Component) {
1173
1193
  onClick: this.handlePopupClose
1174
1194
  }, /*#__PURE__*/_react["default"].createElement("div", {
1175
1195
  className: _MultiSelectModule["default"].effect
1176
- }, this.getSelectionUI(true))) : null, needSelectAll ? /*#__PURE__*/_react["default"].createElement(_Card.CardHeader, null, /*#__PURE__*/_react["default"].createElement(_MultiSelectHeader["default"], {
1196
+ }, this.getSelectionUI(true))) : null, needSelectAll && !(limit >= 0) ? /*#__PURE__*/_react["default"].createElement(_Card.CardHeader, null, /*#__PURE__*/_react["default"].createElement(_MultiSelectHeader["default"], {
1177
1197
  onSelect: this.handleSelectAll,
1178
1198
  selectAllText: selectAllText,
1179
1199
  suggestions: suggestions,
@@ -1189,6 +1209,8 @@ var MultiSelectComponent = /*#__PURE__*/function (_React$Component) {
1189
1209
  className: _MultiSelectModule["default"][palette]
1190
1210
  }, searchText) : suggestions.length ? /*#__PURE__*/_react["default"].createElement(_Suggestions["default"], {
1191
1211
  suggestions: suggestions,
1212
+ isVirtualizerEnabled: isVirtualizerEnabled,
1213
+ setVirtualizerContainerRefFunction: this.setSuggestionsVirtualizerContainerRefFunction,
1192
1214
  getRef: this.suggestionItemRef,
1193
1215
  hoverOption: hoverOption,
1194
1216
  onClick: this.handleSelectOption,
@@ -1199,7 +1221,9 @@ var MultiSelectComponent = /*#__PURE__*/function (_React$Component) {
1199
1221
  selectedOptions: selectedOptionIds,
1200
1222
  a11y: {
1201
1223
  role: 'option'
1202
- }
1224
+ },
1225
+ limit: limit,
1226
+ limitReachedMessage: limitReachedMessage
1203
1227
  }) : /*#__PURE__*/_react["default"].createElement(_EmptyState["default"], {
1204
1228
  isLoading: isFetchingOptions,
1205
1229
  options: options,
@@ -15,6 +15,8 @@ var _defaultProps = require("./props/defaultProps");
15
15
 
16
16
  var _defaultProps2 = require("./MobileHeader/props/defaultProps");
17
17
 
18
+ var _constants = require("./constants");
19
+
18
20
  var _MultiSelect = require("./MultiSelect");
19
21
 
20
22
  var _Popup = _interopRequireDefault(require("../Popup/Popup"));
@@ -151,9 +153,13 @@ var MultiSelectWithAvatarComponent = /*#__PURE__*/function (_MultiSelectComponen
151
153
  needEffect = _this$props.needEffect,
152
154
  isLoading = _this$props.isLoading,
153
155
  keepSelectedOptions = _this$props.keepSelectedOptions,
154
- customProps = _this$props.customProps;
156
+ customProps = _this$props.customProps,
157
+ limit = _this$props.limit;
155
158
  var _customProps$Suggesti = customProps.SuggestionsProps,
156
159
  SuggestionsProps = _customProps$Suggesti === void 0 ? {} : _customProps$Suggesti;
160
+ var _i18nKeys = i18nKeys,
161
+ _i18nKeys$limitReache = _i18nKeys.limitReachedMessage,
162
+ limitReachedMessage = _i18nKeys$limitReache === void 0 ? _constants.MULTISELECT_I18N_KEYS.limitReachedMessage : _i18nKeys$limitReache;
157
163
  i18nKeys = Object.assign({}, _defaultProps2.defaultProps.i18nKeys, i18nKeys, {
158
164
  emptyText: i18nKeys.emptyText || emptyMessage,
159
165
  searchEmptyText: i18nKeys.searchEmptyText || searchEmptyMessage,
@@ -213,7 +219,7 @@ var MultiSelectWithAvatarComponent = /*#__PURE__*/function (_MultiSelectComponen
213
219
  onClick: this.handlePopupClose
214
220
  }, /*#__PURE__*/_react["default"].createElement("div", {
215
221
  className: _MultiSelectModule["default"].effect
216
- }, this.getSelectionUI(true)))) : null, needSelectAll ? /*#__PURE__*/_react["default"].createElement(_Card.CardHeader, null, /*#__PURE__*/_react["default"].createElement(_MultiSelectHeader["default"], {
222
+ }, this.getSelectionUI(true)))) : null, needSelectAll && !(limit >= 0) ? /*#__PURE__*/_react["default"].createElement(_Card.CardHeader, null, /*#__PURE__*/_react["default"].createElement(_MultiSelectHeader["default"], {
217
223
  onSelect: this.handleSelectAll,
218
224
  selectAllText: selectAllText,
219
225
  suggestions: suggestions,
@@ -238,7 +244,9 @@ var MultiSelectWithAvatarComponent = /*#__PURE__*/function (_MultiSelectComponen
238
244
  selectedOptions: selectedOptionIds,
239
245
  a11y: {
240
246
  role: 'option'
241
- }
247
+ },
248
+ limit: limit,
249
+ limitReachedMessage: limitReachedMessage
242
250
  }, SuggestionsProps)) : /*#__PURE__*/_react["default"].createElement(_EmptyState["default"], {
243
251
  isLoading: isFetchingOptions,
244
252
  options: options,
@@ -67,9 +67,11 @@ var SelectedOptions = /*#__PURE__*/function (_React$PureComponent) {
67
67
  onSelect = _this$props.onSelect,
68
68
  size = _this$props.size,
69
69
  palette = _this$props.palette,
70
- dataId = _this$props.dataId;
70
+ dataId = _this$props.dataId,
71
+ limit = _this$props.limit;
71
72
  var isDarkPalette = palette === 'dark' ? 'dark' : 'danger';
72
- return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, selectedOptions.map(function (option) {
73
+ var selectedData = limit && limit > 0 ? selectedOptions.slice(0, limit) : selectedOptions;
74
+ return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, selectedData.map(function (option) {
73
75
  var id = option.id,
74
76
  value = option.value,
75
77
  photoURL = option.photoURL,