UNPKG

@zohodesk/components

Version:

Dot UI is a customizable React component library built to deliver a clean, accessible, and developer-friendly UI experience. It offers a growing set of reusable components designed to align with modern design systems and streamline application development

1,230 lines 58.8 kB
"use strict";

function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = exports.MultiSelectComponent = void 0;

var _react = _interopRequireDefault(require("react"));

var _propTypes = require("./props/propTypes");

var _defaultProps = require("./props/defaultProps");

var _defaultProps2 = require("./MobileHeader/props/defaultProps");

var _Popup = _interopRequireDefault(require("../Popup/Popup"));

var _TextBoxIcon = _interopRequireDefault(require("../TextBoxIcon/TextBoxIcon"));

var _Layout = require("../Layout");

var _Card = _interopRequireWildcard(require("../Card/Card"));

var _SelectedOptions = _interopRequireDefault(require("./SelectedOptions"));

var _Suggestions = _interopRequireDefault(require("./Suggestions"));

var _EmptyState = _interopRequireDefault(require("./EmptyState"));

var _CssProvider = _interopRequireDefault(require("../Provider/CssProvider"));

var _IdProvider = require("../Provider/IdProvider");

var _ResponsiveDropBox = _interopRequireDefault(require("../ResponsiveDropBox/ResponsiveDropBox"));

var _MultiSelectHeader = _interopRequireDefault(require("./MultiSelectHeader"));

var _Loader = _interopRequireDefault(require("@zohodesk/svg/lib/Loader/Loader"));

var _isMobilePopover = _interopRequireDefault(require("../DropBox/utils/isMobilePopover"));

var _icons = require("@zohodesk/icons");

var _MultiSelectModule = _interopRequireDefault(require("./MultiSelect.module.css"));

var _Common = require("../utils/Common.js");

var _dropDownUtils = require("../utils/dropDownUtils");

var _MobileHeader = _interopRequireDefault(require("./MobileHeader/MobileHeader"));

function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }

function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }

function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }

function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }

function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }

function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }

function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }

function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }

function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }

function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }

function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }

function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }

function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }

function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }

function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }

function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }

function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }

function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }

function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }

function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }

/* eslint-disable react/forbid-component-props */

/* eslint-disable react/no-unused-prop-types */
var dummyArray = [];

var MultiSelectComponent = /*#__PURE__*/function (_React$Component) {
  _inherits(MultiSelectComponent, _React$Component);

  var _super = _createSuper(MultiSelectComponent);

  function MultiSelectComponent(props) {
    var _this;

    _classCallCheck(this, MultiSelectComponent);

    _this = _super.call(this, props);
    _this.getNextAriaId = (0, _IdProvider.getUniqueId)(_assertThisInitialized(_this));
    _this.getFilterSuggestions = (0, _dropDownUtils.makeGetMultiSelectFilterSuggestions)();
    _this.formatOptions = (0, _dropDownUtils.makeFormatOptions)();
    _this.getSelectedOptions = (0, _dropDownUtils.makeGetMultiSelectSelectedOptions)();
    _this.getIsShowClearIcon = (0, _dropDownUtils.makeGetIsShowClearIcon)(); //Use in AdvancedMultiSelect component

    _this.objectConcat = (0, _dropDownUtils.makeObjectConcat)();
    _this.formatSelectedOptions = (0, _dropDownUtils.makeFormatOptions)();
    var _this$props = _this.props,
        selectedOptions = _this$props.selectedOptions,
        _this$props$searchDeb = _this$props.searchDebounceTime,
        searchDebounceTime = _this$props$searchDeb === void 0 ? 500 : _this$props$searchDeb;

    var _this$handleFormatOpt = _this.handleFormatOptions(_this.props),
        allOptions = _this$handleFormatOpt.allOptions,
        normalizedAllOptions = _this$handleFormatOpt.normalizedAllOptions,
        normalizedFormatOptions = _this$handleFormatOpt.normalizedFormatOptions;

    var _this$handleGetSelect = _this.handleGetSelectedOptions(selectedOptions, normalizedFormatOptions, _this.props),
        formatSelectedOptions = _this$handleGetSelect.formatSelectedOptions,
        normalizedSelectedOptions = _this$handleGetSelect.normalizedSelectedOptions,
        selectedOptionIds = _this$handleGetSelect.selectedOptionIds;

    _this.state = {
      options: allOptions,
      optionsNormalize: normalizedAllOptions,
      selectedOptions: formatSelectedOptions,
      selectedOptionIds: selectedOptionIds,
      searchStr: '',
      hoverOption: 0,
      isFetchingOptions: false,
      highLightedSelectOptions: [],
      lastHighLightedSelectOption: '',
      shiftKeyPressHighLighted: 0,
      isActive: false
    };
    _this.allSelectedOptionsDetails = normalizedSelectedOptions;
    _this.suggestionsOrder = [];
    _this._isMounted = false;

    _Common.bind.apply(_assertThisInitialized(_this), ['handleInputCick', 'handleFilterSuggestions', 'handleKeyDown', 'handleSelectAll', 'handleDeselectAll', 'handleSelectOption', 'handleRemoveOption', 'handleSearch', 'handleClickSelectedOption', 'handleChange', 'handlePopupClose', 'togglePopup', 'selectedOptionRef', 'searchInputRef', 'suggestionContainerRef', 'suggestionItemRef', 'selectedOptionContainerRef', 'handleActive', 'handleInactive', 'handleMouseEnter', 'handleFetchOptions', 'handleFormatOptions', 'handleGetSelectedOptions', 'handleComponentDidUpdate', 'handleInputFocus', 'handleExposedPublicMethods', 'getSelectionUI', 'moveFocusToTextbox']);

    _this.handleSearchOptions = (0, _Common.debounce)(_this.handleSearchOptions.bind(_assertThisInitialized(_this)), searchDebounceTime);
    _this.handleScroll = _this.handleScroll.bind(_assertThisInitialized(_this));
    _this.handleScrollFuncCall = (0, _Common.debounce)(_this.handleScrollFuncCall.bind(_assertThisInitialized(_this)), 500);
    return _this;
  }

  _createClass(MultiSelectComponent, [{
    key: "componentDidMount",
    value: function componentDidMount() {
      // let { suggestionContainer } = this;
      this._isMounted = true;
      this.handleExposedPublicMethods(); // suggestionContainer &&
      //   suggestionContainer.addEventListener('scroll', this.handleScroll);
    }
  }, {
    key: "componentWillReceiveProps",
    value: function componentWillReceiveProps(nextProps) {
      var _this2 = this;

      var selectedOptions = nextProps.selectedOptions,
          options = nextProps.options,
          valueField = nextProps.valueField,
          textField = nextProps.textField,
          prefixText = nextProps.prefixText;
      var oldProps = this.props;

      if (selectedOptions !== oldProps.selectedOptions || options !== oldProps.options || valueField !== oldProps.valueField || textField !== oldProps.textField || prefixText !== oldProps.prefixText //For GroupMultiSelect component
      ) {
        var _this$handleFormatOpt2 = this.handleFormatOptions(nextProps),
            allOptions = _this$handleFormatOpt2.allOptions,
            normalizedAllOptions = _this$handleFormatOpt2.normalizedAllOptions,
            normalizedFormatOptions = _this$handleFormatOpt2.normalizedFormatOptions;

        var oldAllSelectedOptionsDetails = this.allSelectedOptionsDetails;
        var optionsDetails = Object.assign({}, oldAllSelectedOptionsDetails, normalizedFormatOptions);

        var _this$handleGetSelect2 = this.handleGetSelectedOptions(selectedOptions, optionsDetails, nextProps),
            formatSelectedOptions = _this$handleGetSelect2.formatSelectedOptions,
            normalizedSelectedOptions = _this$handleGetSelect2.normalizedSelectedOptions,
            selectedOptionIds = _this$handleGetSelect2.selectedOptionIds;

        this.allSelectedOptionsDetails = Object.assign(oldAllSelectedOptionsDetails, normalizedSelectedOptions);
        this.setState({
          options: allOptions,
          optionsNormalize: normalizedAllOptions,
          selectedOptions: formatSelectedOptions,
          selectedOptionIds: selectedOptionIds
        }, function () {
          var hoverOption = _this2.state.hoverOption;

          var suggestions = _this2.handleFilterSuggestions();

          var suggestionsLen = suggestions.length;

          var _ref = suggestions[hoverOption] || {},
              id = _ref.id;

          var newHoverOption = !(0, _Common.getIsEmptyValue)(id) ? hoverOption : suggestionsLen ? suggestionsLen - 1 : 0;

          _this2.setState({
            hoverOption: newHoverOption
          });
        });
      }
    }
  }, {
    key: "componentDidUpdate",
    value: function componentDidUpdate(prevProps, prevState) {
      var suggestionContainer = this.suggestionContainer,
          selectedOptionContainer = this.selectedOptionContainer,
          suggestionsOrder = this.suggestionsOrder;
      var _this$state = this.state,
          hoverOption = _this$state.hoverOption,
          highLightedSelectOptions = _this$state.highLightedSelectOptions,
          selectedOptions = _this$state.selectedOptions,
          searchStr = _this$state.searchStr;
      var _this$props2 = this.props,
          needLocalSearch = _this$props2.needLocalSearch,
          isPopupOpen = _this$props2.isPopupOpen,
          onDropBoxClose = _this$props2.onDropBoxClose,
          onDropBoxOpen = _this$props2.onDropBoxOpen,
          isSearchClearOnClose = _this$props2.isSearchClearOnClose; //handle dropbox open & close

      if (prevProps.isPopupOpen !== isPopupOpen) {
        isPopupOpen && onDropBoxOpen && this.handleFetchOptions(onDropBoxOpen, searchStr);

        if (!isPopupOpen) {
          this.setState({
            hoverOption: 0
          });
          isSearchClearOnClose && searchStr && this.handleSearch('');
          onDropBoxClose && onDropBoxClose();
        }
      } //scrollTo handling


      var hoverId = suggestionsOrder[hoverOption] || '';
      var selectedSuggestion = this["suggestion_".concat(hoverId)];
      var lastHighLightedSelectOption = highLightedSelectOptions.slice(-1).length ? highLightedSelectOptions.slice(-1)[0] : null;
      var selectedOption = this["selectedOption_".concat(lastHighLightedSelectOption)];
      isPopupOpen && (0, _Common.scrollTo)(suggestionContainer, selectedSuggestion);
      selectedOptions.length && selectedOption && (0, _Common.scrollTo)(selectedOptionContainer, selectedOption); //When suggestions length less than 5, getNextOptions function call

      var _this$props3 = this.props,
          isNextOptions = _this$props3.isNextOptions,
          getNextOptions = _this$props3.getNextOptions; // let { searchStr } = this.state;

      var suggestions = this.handleFilterSuggestions();
      var suggestionsLen = suggestions.length;

      if (isPopupOpen && suggestionsLen <= 5 && isNextOptions && getNextOptions && !needLocalSearch) {
        this.handleFetchOptions(getNextOptions, searchStr);
      } //Need To MultiselectNew Component


      this.handleComponentDidUpdate(prevProps, prevState); // if (isPopupOpen && isNextOptions && prevProps.selectedOptions.length !== selectedOptions.length) {
      //   let { scrollHeight, clientHeight } = this.suggestionContainer || {};
      //   let isElementScrollable = scrollHeight > clientHeight;
      //   if (!isElementScrollable) {
      //     this.handleScrollFuncCall();
      //   }
      // }
    }
  }, {
    key: "componentWillUnmount",
    value: function componentWillUnmount() {
      // let { suggestionContainer } = this;
      this._isMounted = false; // suggestionContainer &&
      //   suggestionContainer.removeEventListener('scroll', this.handleScroll);
    }
  }, {
    key: "handleComponentDidUpdate",
    value: function handleComponentDidUpdate() {
      return;
    }
  }, {
    key: "handleFormatOptions",
    value: function handleFormatOptions(props) {
      var options = props.options,
          valueField = props.valueField,
          textField = props.textField,
          prefixText = props.prefixText,
          disabledOptions = props.disabledOptions,
          allowValueFallback = props.allowValueFallback,
          searchFields = props.searchFields;
      return this.formatOptions({
        options: options,
        valueField: valueField,
        textField: textField,
        prefixText: prefixText,
        optionType: 'default',
        disabledOptions: disabledOptions,
        allowValueFallback: allowValueFallback,
        searchFields: searchFields
      });
    }
  }, {
    key: "handleGetSelectedOptions",
    value: function handleGetSelectedOptions(selectedOptions, normalizedFormatOptions, props) {
      var allowValueFallback = props.allowValueFallback;
      return this.getSelectedOptions({
        selectedOptions: selectedOptions,
        normalizedFormatOptions: normalizedFormatOptions,
        allowValueFallback: allowValueFallback
      });
    }
  }, {
    key: "handleInputCick",
    value: function handleInputCick(e) {
      var removeClose = this.props.removeClose;
      var _this$state2 = this.state,
          highLightedSelectOptions = _this$state2.highLightedSelectOptions,
          _this$state2$searchSt = _this$state2.searchStr,
          searchStr = _this$state2$searchSt === void 0 ? '' : _this$state2$searchSt;

      if (highLightedSelectOptions.length) {
        this.setState({
          highLightedSelectOptions: [],
          shiftKeyPressHighLighted: 0,
          lastHighLightedSelectOption: ''
        });
        removeClose(e);
      } else if (searchStr.length) {
        removeClose(e);
      } else {
        this.togglePopup(e);
      }
    }
  }, {
    key: "handleFilterSuggestions",
    value: function handleFilterSuggestions() {
      var _this$state3 = this.state,
          _this$state3$options = _this$state3.options,
          options = _this$state3$options === void 0 ? dummyArray : _this$state3$options,
          _this$state3$searchSt = _this$state3.searchStr,
          searchStr = _this$state3$searchSt === void 0 ? '' : _this$state3$searchSt;
      var _this$props4 = this.props,
          selectedOptions = _this$props4.selectedOptions,
          needLocalSearch = _this$props4.needLocalSearch,
          keepSelectedOptions = _this$props4.keepSelectedOptions,
          searchFields = _this$props4.searchFields;

      var _this$getFilterSugges = this.getFilterSuggestions({
        options: options,
        selectedOptions: selectedOptions,
        searchStr: (0, _Common.getSearchString)(searchStr),
        needSearch: needLocalSearch,
        keepSelectedOptions: keepSelectedOptions,
        searchFields: searchFields
      }),
          suggestions = _this$getFilterSugges.suggestions,
          suggestionIds = _this$getFilterSugges.suggestionIds;

      this.suggestionsOrder = suggestionIds;
      return suggestions;
    }
  }, {
    key: "handleKeyDown",
    value: function handleKeyDown(e) {
      var keyCode = e.keyCode,
          ctrlKey = e.ctrlKey,
          metaKey = e.metaKey,
          shiftKey = e.shiftKey;
      var suggestions = [];
      var _this$state4 = this.state,
          hoverOption = _this$state4.hoverOption,
          searchStr = _this$state4.searchStr,
          highLightedSelectOptions = _this$state4.highLightedSelectOptions,
          lastHighLightedSelectOption = _this$state4.lastHighLightedSelectOption,
          shiftKeyPressHighLighted = _this$state4.shiftKeyPressHighLighted,
          selectedOptions = _this$state4.selectedOptionIds;
      var _this$props5 = this.props,
          isNextOptions = _this$props5.isNextOptions,
          getNextOptions = _this$props5.getNextOptions,
          isPopupOpen = _this$props5.isPopupOpen,
          isPopupOpenOnEnter = _this$props5.isPopupOpenOnEnter,
          onKeyDown = _this$props5.onKeyDown;
      var highLightedSelectOptionsLen = highLightedSelectOptions.length;

      if (isPopupOpen && (keyCode === 38 || keyCode === 40 || keyCode === 13 || keyCode === 27 || keyCode === 9)) {
        suggestions = this.handleFilterSuggestions();
      }

      if (!isPopupOpen && !isPopupOpenOnEnter) {
        onKeyDown && onKeyDown(e);
      }

      if (!isPopupOpen && keyCode === 40) {
        //down arrow press popup open
        e.preventDefault(); //prevent body scroll

        this.togglePopup(e);
      }

      var suggestionsLen = suggestions.length;

      if (suggestionsLen && isPopupOpen && keyCode === 38) {
        //up arrow

        /*if (hoverOption === 0) { //disable first to last option higlight
          !isNextOptions && this.setState({ hoverOption: suggestionsLen - 1 });
        }*/
        if (hoverOption) {
          this.setState({
            hoverOption: hoverOption - 1
          });
        }
      } else if (suggestionsLen && isPopupOpen && keyCode === 40) {
        //down arrow

        /*else if (hoverOption === suggestionsLen - 1 || hoverOption === null) {
          //disable last to first option higlight
          !isNextOptions && this.setState({ hoverOption: 0 });
        }*/
        if (isNextOptions && suggestionsLen >= 5 && hoverOption === suggestionsLen - 3) {
          getNextOptions && this.handleFetchOptions(getNextOptions, searchStr);
          this.setState({
            hoverOption: hoverOption + 1
          });
        } else if (suggestionsLen - 1 > hoverOption) {
          this.setState({
            hoverOption: hoverOption + 1
          });
        }
      } else if (keyCode === 13) {
        //enter key
        var selectedOption = suggestions[hoverOption] || {};
        var id = selectedOption.id;
        isPopupOpen && !(0, _Common.getIsEmptyValue)(id) && this.handleSelectOption(id, e);
        !isPopupOpen && isPopupOpenOnEnter && this.togglePopup(e);
      } else if (selectedOptions.length && keyCode === 8 && !searchStr.length) {
        //backspace key
        if (highLightedSelectOptionsLen) {
          this.handleRemoveOption(highLightedSelectOptions);
        } else {
          this.handleRemoveOption(selectedOptions.slice(-1)); // this.setState({
          //   highLightedSelectOptions: selectedOptions.slice(-1)
          // });
        }
      } else if (selectedOptions && keyCode === 65 && (ctrlKey || metaKey) && !searchStr.length) {
        //ctrl+a key
        this.setState({
          highLightedSelectOptions: selectedOptions,
          shiftKeyPressHighLighted: 0
        });
      } else if (keyCode === 39 && shiftKey && selectedOptions.length && !searchStr.length) {
        //shift+right arrow=39
        var lastHighLightedSelectOptionIndex = lastHighLightedSelectOption && selectedOptions.indexOf(lastHighLightedSelectOption) >= 0 ? selectedOptions.indexOf(lastHighLightedSelectOption) : 0;
        var newShiftKeyPressHighLighted = shiftKeyPressHighLighted ? shiftKeyPressHighLighted : shiftKeyPressHighLighted + 1;
        var newHighLightedSelectOption = lastHighLightedSelectOptionIndex !== null ? selectedOptions[lastHighLightedSelectOptionIndex + newShiftKeyPressHighLighted] : selectedOptions[0];

        if (!(0, _Common.getIsEmptyValue)(newHighLightedSelectOption)) {
          var newLastHighLightedSelectOption = lastHighLightedSelectOption ? lastHighLightedSelectOption : selectedOptions[0];
          highLightedSelectOptions = !shiftKeyPressHighLighted ? [newLastHighLightedSelectOption] : highLightedSelectOptions;
          var isRemove = highLightedSelectOptions.indexOf(newHighLightedSelectOption) >= 0 && newHighLightedSelectOption !== lastHighLightedSelectOption ? true : false;
          var newHighLightedSelectOptions = isRemove ? highLightedSelectOptions.filter(function (option) {
            return option !== newHighLightedSelectOption;
          }) : [].concat(_toConsumableArray(highLightedSelectOptions), [newHighLightedSelectOption]);
          this.setState({
            highLightedSelectOptions: newHighLightedSelectOptions,
            shiftKeyPressHighLighted: newShiftKeyPressHighLighted + 1,
            lastHighLightedSelectOption: newLastHighLightedSelectOption
          });
        }
      } else if (keyCode === 37 && shiftKey && selectedOptions.length && !searchStr.length) {
        // shift+left arrow=37
        var _lastHighLightedSelectOptionIndex = lastHighLightedSelectOption ? selectedOptions.indexOf(lastHighLightedSelectOption) : selectedOptions.length - 1;

        var _newShiftKeyPressHighLighted = shiftKeyPressHighLighted !== 1 ? shiftKeyPressHighLighted : shiftKeyPressHighLighted - 1;

        var _newHighLightedSelectOption = selectedOptions[_lastHighLightedSelectOptionIndex + _newShiftKeyPressHighLighted - 1];

        if (!(0, _Common.getIsEmptyValue)(_newHighLightedSelectOption)) {
          var _newLastHighLightedSelectOption = lastHighLightedSelectOption ? lastHighLightedSelectOption : selectedOptions.slice(-1)[0];

          highLightedSelectOptions = !shiftKeyPressHighLighted ? [_newLastHighLightedSelectOption] : highLightedSelectOptions;

          var _isRemove = highLightedSelectOptions.indexOf(_newHighLightedSelectOption) >= 0 && _newHighLightedSelectOption !== lastHighLightedSelectOption ? true : false;

          var _newHighLightedSelectOptions = _isRemove ? highLightedSelectOptions.filter(function (option) {
            return option !== _newHighLightedSelectOption;
          }) : [].concat(_toConsumableArray(highLightedSelectOptions), [_newHighLightedSelectOption]);

          this.setState({
            highLightedSelectOptions: _newHighLightedSelectOptions,
            shiftKeyPressHighLighted: _newShiftKeyPressHighLighted - 1,
            lastHighLightedSelectOption: _newLastHighLightedSelectOption
          });
        }
      } else if ((keyCode === 39 || keyCode === 37) && selectedOptions.length && !searchStr.length) {
        var isRightArrow = keyCode === 39 ? true : false; // let isLefttArrow = keyCode === 37 ? true : false;

        if (highLightedSelectOptions.length) {
          var _highLightedSelectOpt = highLightedSelectOptions.slice(-1),
              _highLightedSelectOpt2 = _slicedToArray(_highLightedSelectOpt, 1),
              _lastHighLightedSelectOption = _highLightedSelectOpt2[0];

          var _lastHighLightedSelectOptionIndex2 = selectedOptions.indexOf(_lastHighLightedSelectOption);

          var newLastHighLightedSelectOptionIndex = isRightArrow ? _lastHighLightedSelectOptionIndex2 === selectedOptions.length - 1 ? _lastHighLightedSelectOptionIndex2 : _lastHighLightedSelectOptionIndex2 + 1 : _lastHighLightedSelectOptionIndex2 - 1;
          var _newLastHighLightedSelectOption2 = selectedOptions[newLastHighLightedSelectOptionIndex];
          var isEmptyHighlighted = isRightArrow && highLightedSelectOptions.length === 1 && selectedOptions.slice(-1)[0] === _lastHighLightedSelectOption ? true : false;

          if (!(0, _Common.getIsEmptyValue)(_newLastHighLightedSelectOption2)) {
            this.setState({
              lastHighLightedSelectOption: isEmptyHighlighted ? '' : _newLastHighLightedSelectOption2,
              highLightedSelectOptions: isEmptyHighlighted ? [] : [_newLastHighLightedSelectOption2],
              shiftKeyPressHighLighted: 0
            });
          }
        } else {
          var _ref2 = isRightArrow ? selectedOptions : selectedOptions.slice(-1),
              _ref3 = _slicedToArray(_ref2, 1),
              _newLastHighLightedSelectOption3 = _ref3[0];

          this.setState({
            lastHighLightedSelectOption: _newLastHighLightedSelectOption3,
            highLightedSelectOptions: [_newLastHighLightedSelectOption3],
            shiftKeyPressHighLighted: 0
          });
        }
      } else if (keyCode === 27) {// this.handlePopupClose(e);
      } else if (keyCode === 9) {
        this.handlePopupClose(e);
      }
    }
  }, {
    key: "handleSelectAll",
    value: function handleSelectAll(e) {
      e && e.preventDefault();
      var suggestions = this.handleFilterSuggestions();
      var selectedOptions = this.props.selectedOptions;
      var newSelectedOptions = [];
      suggestions.forEach(function (option) {
        var id = option.id;

        if (selectedOptions.indexOf(id) === -1) {
          newSelectedOptions.push(id);
        }
      });
      this.handleChange([].concat(_toConsumableArray(selectedOptions), newSelectedOptions)); // this.handlePopupClose(e);
    }
  }, {
    key: "handleDeselectAll",
    value: function handleDeselectAll(e) {
      e && e.preventDefault();
      var removeClose = this.props.removeClose;
      var highLightedSelectOptions = this.state.highLightedSelectOptions;

      if (highLightedSelectOptions.length) {
        this.setState({
          highLightedSelectOptions: [],
          lastHighLightedSelectOption: ''
        });
      }

      removeClose(e);
      this.handleChange([]);
    }
  }, {
    key: "handleSelectOption",
    value: function handleSelectOption(option, value, index, e) {
      var _this$props6 = this.props,
          selectedOptions = _this$props6.selectedOptions,
          isSearchClearOnSelect = _this$props6.isSearchClearOnSelect,
          keepSelectedOptions = _this$props6.keepSelectedOptions;
      var searchStr = this.state.searchStr;

      if (searchStr.trim() != '' && isSearchClearOnSelect) {
        this.handleSearch('');
      }

      if (keepSelectedOptions && selectedOptions.indexOf(option) != -1) {
        var newSelectedOptions = selectedOptions.filter(function (id) {
          return id != option;
        });
        this.handleChange(newSelectedOptions, e);
      } else {
        this.handleChange([].concat(_toConsumableArray(selectedOptions), [option]), e);
      }
    }
  }, {
    key: "handleRemoveOption",
    value: function handleRemoveOption(options) {
      var newOptions = !(0, _Common.getIsEmptyValue)(options) && !Array.isArray(options) ? [options] : options;
      var _this$props7 = this.props,
          selectedOptions = _this$props7.selectedOptions,
          isReadOnly = _this$props7.isReadOnly;
      var _this$state5 = this.state,
          highLightedSelectOptions = _this$state5.highLightedSelectOptions,
          lastHighLightedSelectOption = _this$state5.lastHighLightedSelectOption,
          shiftKeyPressHighLighted = _this$state5.shiftKeyPressHighLighted;

      if (newOptions.length && !isReadOnly) {
        var newSelectedOptions = selectedOptions.filter(function (option) {
          return newOptions.indexOf(option) === -1;
        });
        var newHighLightedSelectOptions = highLightedSelectOptions.filter(function (option) {
          return newSelectedOptions.indexOf(option) >= 0;
        });
        var isHighlightedRemoved = false;
        var newOptionsLen = newOptions.length;

        for (var i = 0; i < newOptionsLen; i++) {
          var removedOption = newOptions[i];

          if (highLightedSelectOptions.indexOf(removedOption) >= 0) {
            isHighlightedRemoved = true;
            break;
          }
        }

        this.setState({
          lastHighLightedSelectOption: newSelectedOptions.indexOf(lastHighLightedSelectOption) >= 0 && !isHighlightedRemoved ? lastHighLightedSelectOption : '',
          highLightedSelectOptions: isHighlightedRemoved ? [] : newHighLightedSelectOptions,
          shiftKeyPressHighLighted: isHighlightedRemoved ? 0 : shiftKeyPressHighLighted
        });
        this.handleChange(newSelectedOptions);
      }

      this.moveFocusToTextbox();
    }
  }, {
    key: "handleMouseEnter",
    value: function handleMouseEnter(id, val, hoverOptionIndex, e) {
      e && e.preventDefault();
      var hoverOption = this.state.hoverOption;
      var suggestionsOrder = this.suggestionsOrder;
      var newHoverIndex = suggestionsOrder.indexOf(id);

      if (newHoverIndex !== hoverOption) {
        this.setState({
          hoverOption: newHoverIndex
        });
      }
    }
  }, {
    key: "handleFetchOptions",
    value: function handleFetchOptions() {
      var _this3 = this;

      for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
        args[_key] = arguments[_key];
      }

      var APICall = args[0],
          searchStr = args[1];
      var isFetchingOptions = this.state.isFetchingOptions;
      var _isMounted = this._isMounted;
      var isForce = isFetchingOptions && searchStr ? true : false;

      if (!isFetchingOptions && APICall || isForce) {
        this.setState({
          isFetchingOptions: true
        });

        try {
          return APICall(searchStr).then(function () {
            _isMounted && _this3.setState({
              isFetchingOptions: false
            });
          }, function () {
            _isMounted && _this3.setState({
              isFetchingOptions: false
            });
          });
        } catch (e) {
          _isMounted && this.setState({
            isFetchingOptions: false
          });
        }
      }
    }
  }, {
    key: "handleSearchOptions",
    value: function handleSearchOptions() {
      var onSearch = this.props.onSearch;
      var searchStr = this.state.searchStr;
      searchStr && this.handleFetchOptions(onSearch, searchStr);
    }
  }, {
    key: "handleSearch",
    value: function handleSearch(value, e) {
      var _this4 = this;

      var _this$props8 = this.props,
          onSearch = _this$props8.onSearch,
          isPopupOpen = _this$props8.isPopupOpen;
      !isPopupOpen && e && this.togglePopup(e);
      var _this$state$searchStr = this.state.searchStr,
          searchStr = _this$state$searchStr === void 0 ? '' : _this$state$searchStr;
      var searchStrRegex = (0, _Common.getSearchString)(searchStr);
      var valueStrRegex = (0, _Common.getSearchString)(value);
      var isSearch = searchStrRegex !== valueStrRegex ? true : false;
      this.setState({
        searchStr: value
      }, function () {
        if (!value) {
          onSearch && onSearch('');
        } else if (isSearch && onSearch) {
          _this4.handleSearchOptions();
        }
      });
    }
  }, {
    key: "handleClickSelectedOption",
    value: function handleClickSelectedOption() {
      var id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
      var e = arguments.length > 1 ? arguments[1] : undefined;
      var selectedOptions = this.props.selectedOptions;
      var _this$state6 = this.state,
          highLightedSelectOptions = _this$state6.highLightedSelectOptions,
          lastHighLightedSelectOption = _this$state6.lastHighLightedSelectOption;
      var metaKey = e.metaKey,
          ctrlKey = e.ctrlKey,
          shiftKey = e.shiftKey;

      if (e && shiftKey) {
        //shift+click
        var from = selectedOptions.indexOf(lastHighLightedSelectOption) >= 0 ? selectedOptions.indexOf(lastHighLightedSelectOption) : 0;
        var to = id && selectedOptions.indexOf(id) >= 0 ? selectedOptions.indexOf(id) : null;

        if (to >= 0 && to < from) {
          var _ref4 = [from, from = to];
          to = _ref4[0];
        }

        to += 1;
        var newSelectedHighlights = to ? selectedOptions.slice(from, to) : [];
        to && this.setState({
          highLightedSelectOptions: newSelectedHighlights,
          lastHighLightedSelectOption: id
        });
      } else if (e && (ctrlKey || metaKey)) {
        //ctrl+click
        var isRemove = highLightedSelectOptions.indexOf(id) >= 0;
        var _newSelectedHighlights = [];

        if (isRemove) {
          lastHighLightedSelectOption = id === lastHighLightedSelectOption ? '' : lastHighLightedSelectOption;
          _newSelectedHighlights = highLightedSelectOptions.filter(function (option) {
            return option !== id;
          });
        } else {
          lastHighLightedSelectOption = id;
          _newSelectedHighlights = [].concat(_toConsumableArray(highLightedSelectOptions), [id]);
        }

        this.setState({
          highLightedSelectOptions: _newSelectedHighlights,
          lastHighLightedSelectOption: lastHighLightedSelectOption
        });
      } else {
        this.setState({
          highLightedSelectOptions: [id],
          lastHighLightedSelectOption: id
        });
      }

      this.setState({
        shiftKeyPressHighLighted: 0
      });
      this.moveFocusToTextbox();
    }
  }, {
    key: "handleScroll",
    value: function handleScroll(e) {
      var ele = e.target;
      var isScrollReachedBottom = (0, _Common.findScrollEnd)(ele);
      isScrollReachedBottom && this.handleScrollFuncCall();
    }
  }, {
    key: "handleScrollFuncCall",
    value: function handleScrollFuncCall() {
      var _this$props9 = this.props,
          getNextOptions = _this$props9.getNextOptions,
          isNextOptions = _this$props9.isNextOptions;
      var searchStr = this.state.searchStr;
      isNextOptions && getNextOptions && this.handleFetchOptions(getNextOptions, searchStr);
    }
  }, {
    key: "handleChange",
    value: function handleChange() {
      var selectedOptions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
      var e = arguments.length > 1 ? arguments[1] : undefined;
      var optionsNormalize = this.state.optionsNormalize;
      var _this$props10 = this.props,
          onChange = _this$props10.onChange,
          needToCloseOnSelect = _this$props10.needToCloseOnSelect,
          togglePopup = _this$props10.togglePopup,
          propSelectedOptions = _this$props10.selectedOptions,
          _this$props10$disable = _this$props10.disabledOptions,
          disabledOptions = _this$props10$disable === void 0 ? dummyArray : _this$props10$disable;

      var _filterSelectedOption = (0, _dropDownUtils.filterSelectedOptions)({
        selectedOptions: selectedOptions,
        propSelectedOptions: propSelectedOptions,
        disabledOptions: disabledOptions
      }),
          newSelectedOptions = _filterSelectedOption.newSelectedOptions;

      var selectedOptionsLen = newSelectedOptions.length;
      var allSelectedOptionsDetails = [];

      for (var i = 0; i < selectedOptionsLen; i++) {
        var id = newSelectedOptions[i];
        allSelectedOptionsDetails.push(optionsNormalize[id]);
      }

      onChange && onChange(newSelectedOptions, allSelectedOptionsDetails); // this.setState({ searchStr: '' });

      this.moveFocusToTextbox();

      if (needToCloseOnSelect) {
        togglePopup(e);
      }
    }
  }, {
    key: "togglePopup",
    value: function togglePopup(e) {
      var _this$props11 = this.props,
          togglePopup = _this$props11.togglePopup,
          defaultDropBoxPosition = _this$props11.defaultDropBoxPosition,
          isReadOnly = _this$props11.isReadOnly;
      !isReadOnly && togglePopup(e, defaultDropBoxPosition ? "".concat(defaultDropBoxPosition) : null);
    }
  }, {
    key: "handlePopupClose",
    value: function handlePopupClose(e) {
      var closePopupOnly = this.props.closePopupOnly;
      closePopupOnly(e);
    }
  }, {
    key: "searchInputRef",
    value: function searchInputRef(el) {
      var getRef = this.props.getRef;
      this.searchInput = el;
      getRef && getRef(el);
    }
  }, {
    key: "selectedOptionContainerRef",
    value: function selectedOptionContainerRef(el) {
      var getTargetRef = this.props.getTargetRef;
      this.selectedOptionContainer = el;
      getTargetRef(el);
    }
  }, {
    key: "selectedOptionRef",
    value: function selectedOptionRef(el, id) {
      this["selectedOption_".concat(id)] = el;
    }
  }, {
    key: "suggestionContainerRef",
    value: function suggestionContainerRef(el) {
      this.suggestionContainer = el;
    }
  }, {
    key: "suggestionItemRef",
    value: function suggestionItemRef(el, index, id) {
      this["suggestion_".concat(id)] = el;
    }
  }, {
    key: "handleActive",
    value: function handleActive(e) {
      var _this$state7 = this.state,
          searchStr = _this$state7.searchStr,
          isActive = _this$state7.isActive;

      if (!isActive) {
        this.setState({
          isActive: true
        });
      }

      var _ref5 = e || {},
          target = _ref5.target;

      target && target.setSelectionRange(target, 0);
      var onFocus = this.props.onFocus;
      onFocus && onFocus(searchStr);
    }
  }, {
    key: "handleInactive",
    value: function handleInactive() {
      var isActive = this.state.isActive;

      if (isActive) {
        this.setState({
          isActive: false
        });
      }
    }
  }, {
    key: "handleInputFocus",
    value: function handleInputFocus() {
      var _this$props12 = this.props,
          isDisabled = _this$props12.isDisabled,
          isReadOnly = _this$props12.isReadOnly;
      !isDisabled && !isReadOnly && this.moveFocusToTextbox();
    }
  }, {
    key: "moveFocusToTextbox",
    value: function moveFocusToTextbox() {
      this.searchInput && this.searchInput.focus({
        preventScroll: true
      });
    }
  }, {
    key: "handleExposedPublicMethods",
    value: function handleExposedPublicMethods() {
      var _this$props13 = this.props,
          getPublicMethods = _this$props13.getPublicMethods,
          openPopupOnly = _this$props13.openPopupOnly;
      getPublicMethods && getPublicMethods({
        openPopupOnly: openPopupOnly
      });
    }
  }, {
    key: "getSelectionUI",
    value: function getSelectionUI() {
      var isResponsive = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
      var _this$props14 = this.props,
          size = _this$props14.size,
          needBorder = _this$props14.needBorder,
          disableAction = _this$props14.disableAction,
          borderColor = _this$props14.borderColor,
          placeHolder = _this$props14.placeHolder,
          textBoxSize = _this$props14.textBoxSize,
          variant = _this$props14.variant,
          textBoxClass = _this$props14.textBoxClass,
          needAutoFocus = _this$props14.needAutoFocus,
          htmlId = _this$props14.htmlId,
          children = _this$props14.children,
          customChildrenClass = _this$props14.customChildrenClass,
          autoComplete = _this$props14.autoComplete,
          a11y = _this$props14.a11y,
          disabledOptions = _this$props14.disabledOptions,
          i18nKeys = _this$props14.i18nKeys,
          isReadOnly = _this$props14.isReadOnly,
          isDisabled = _this$props14.isDisabled,
          palette = _this$props14.palette,
          dataId = _this$props14.dataId,
          setAriaId = _this$props14.setAriaId,
          isPopupOpen = _this$props14.isPopupOpen,
          ariaErrorId = _this$props14.ariaErrorId,
          customProps = _this$props14.customProps,
          isFocus = _this$props14.isFocus,
          isPopupReady = _this$props14.isPopupReady,
          renderCustomClearComponent = _this$props14.renderCustomClearComponent,
          renderCustomToggleIndicator = _this$props14.renderCustomToggleIndicator;
      var _this$state8 = this.state,
          isActive = _this$state8.isActive,
          selectedOptions = _this$state8.selectedOptions,
          highLightedSelectOptions = _this$state8.highLightedSelectOptions,
          searchStr = _this$state8.searchStr;
      var _i18nKeys$clearText = i18nKeys.clearText,
          clearText = _i18nKeys$clearText === void 0 ? 'Clear all' : _i18nKeys$clearText;
      var _a11y$clearLabel = a11y.clearLabel,
          clearLabel = _a11y$clearLabel === void 0 ? 'Clear all' : _a11y$clearLabel,
          ariaLabelledby = a11y.ariaLabelledby;

      var _this$getIsShowClearI = this.getIsShowClearIcon({
        selectedOptions: selectedOptions,
        disabledOptions: disabledOptions
      }),
          isShowClear = _this$getIsShowClearI.isShowClearIcon;

      var isShowClearIcon = !isReadOnly && !isDisabled && !disableAction && isShowClear;
      var isEditable = !(isReadOnly || isDisabled || disableAction);
      var _customProps$TextBoxI = customProps.TextBoxIconProps,
          TextBoxIconProps = _customProps$TextBoxI === void 0 ? {} : _customProps$TextBoxI;
      return /*#__PURE__*/_react["default"].createElement(_Layout.Container, {
        align: "vertical",
        alignBox: "row",
        className: "".concat(_MultiSelectModule["default"].container, " ").concat(_MultiSelectModule["default"][size], " ").concat(needBorder ? !disableAction ? _MultiSelectModule["default"]["borderColor_".concat(borderColor)] : _MultiSelectModule["default"].borderColor_transparent : '', " ").concat(isActive && needBorder || isResponsive || isEditable && isFocus && needBorder ? _MultiSelectModule["default"].active : '', " ").concat(textBoxClass, " ").concat(needBorder ? _MultiSelectModule["default"].hasBorder : ''),
        eleRef: this.selectedOptionContainerRef,
        wrap: "wrap"
      }, /*#__PURE__*/_react["default"].createElement(_SelectedOptions["default"], {
        selectedOptions: selectedOptions,
        highLightedSelectOptions: highLightedSelectOptions,
        isReadOnly: isReadOnly,
        getRef: this.selectedOptionRef,
        onRemove: this.handleRemoveOption,
        onSelect: this.handleClickSelectedOption,
        size: size,
        palette: palette,
        dataId: "".concat(dataId, "_selectedOptions")
      }), /*#__PURE__*/_react["default"].createElement(_Layout.Box, {
        flexible: true,
        className: _MultiSelectModule["default"].wrapper,
        adjust: true,
        shrink: true
      }, /*#__PURE__*/_react["default"].createElement("span", {
        className: " ".concat(_MultiSelectModule["default"].custmSpan, " ").concat(textBoxSize === 'xmedium' ? _MultiSelectModule["default"].custmSpanXmedium : _MultiSelectModule["default"].custmSpanMedium, " ").concat(isShowClearIcon ? _MultiSelectModule["default"].clearIconSpace : '', "\n          ").concat(customChildrenClass ? customChildrenClass : '')
      }, searchStr), /*#__PURE__*/_react["default"].createElement(_TextBoxIcon["default"], _extends({
        isDisabled: isDisabled,
        inputRef: this.searchInputRef,
        needBorder: false,
        onBlur: this.handleInactive,
        onChange: this.handleSearch,
        onClick: !isResponsive ? this.handleInputCick : undefined,
        onFocus: this.handleActive,
        onKeyDown: this.handleKeyDown,
        autofocus: needAutoFocus,
        placeHolder: selectedOptions.length >= 1 ? '' : placeHolder,
        size: textBoxSize,
        value: searchStr,
        variant: variant,
        dataId: "".concat(dataId, "_textBox"),
        isReadOnly: isReadOnly,
        tabindex: isDisabled && '-1',
        customClass: {
          customTBoxWrap: _MultiSelectModule["default"].custmInputWrapper
        },
        htmlId: htmlId,
        a11y: {
          role: 'combobox',
          ariaOwns: setAriaId,
          ariaControls: setAriaId,
          ariaExpanded: !isReadOnly && !isDisabled && !disableAction && isPopupOpen ? true : false,
          ariaHaspopup: true,
          ariaRequired: true,
          ariaDescribedby: ariaErrorId,
          ariaLabelledby: ariaLabelledby
        },
        autoComplete: autoComplete,
        renderRightPlaceholderNode: typeof renderCustomToggleIndicator == 'function' ? renderCustomToggleIndicator({
          togglePopup: this.togglePopup,
          isPopupOpened: isPopupReady,
          isReadOnly: isReadOnly,
          isDisabled: isDisabled
        }) : renderCustomToggleIndicator
      }, TextBoxIconProps), /*#__PURE__*/_react["default"].createElement(_Layout.Container, {
        isInline: true,
        isCover: false,
        alignBox: "row",
        align: "vertical",
        className: _MultiSelectModule["default"].rightPlaceholder
      }, isShowClearIcon ? typeof renderCustomClearComponent === 'function' ? renderCustomClearComponent({
        clearText: clearText,
        isPopupOpened: isPopupReady,
        handleClearAll: this.handleDeselectAll
      }) : /*#__PURE__*/_react["default"].createElement(_Layout.Box, {
        className: "".concat(_MultiSelectModule["default"]["delete"], " ").concat(_MultiSelectModule["default"]["".concat(palette, "Delete")]),
        dataId: "".concat(dataId, "_clearIcon"),
        "data-title": clearText,
        onClick: this.handleDeselectAll,
        tagName: "button",
        "aria-label": clearLabel
      }, /*#__PURE__*/_react["default"].createElement(_icons.Icon, {
        name: "ZD-delete",
        size: "15"
      })) : null, children ? /*#__PURE__*/_react["default"].createElement(_Layout.Box, {
        dataId: "".concat(dataId, "_children")
      }, children) : null))));
    }
  }, {
    key: "render",
    value: function render() {
      var _this$props15 = this.props,
          isReadOnly = _this$props15.isReadOnly,
          searchEmptyMessage = _this$props15.searchEmptyMessage,
          emptyMessage = _this$props15.emptyMessage,
          noMoreOptionsMessage = _this$props15.noMoreOptionsMessage,
          dropBoxSize = _this$props15.dropBoxSize,
          isPopupOpen = _this$props15.isPopupOpen,
          isPopupReady = _this$props15.isPopupReady,
          position = _this$props15.position,
          defaultDropBoxPosition = _this$props15.defaultDropBoxPosition,
          getContainerRef = _this$props15.getContainerRef,
          removeClose = _this$props15.removeClose,
          isAnimate = _this$props15.isAnimate,
          animationStyle = _this$props15.animationStyle,
          isDisabled = _this$props15.isDisabled,
          title = _this$props15.title,
          needResponsive = _this$props15.needResponsive,
          dataId = _this$props15.dataId,
          dataSelectorId = _this$props15.dataSelectorId,
          isSearching = _this$props15.isSearching,
          borderColor = _this$props15.borderColor,
          disableAction = _this$props15.disableAction,
          isBoxPaddingNeed = _this$props15.isBoxPaddingNeed,
          isAbsolutePositioningNeeded = _this$props15.isAbsolutePositioningNeeded,
          positionsOffset = _this$props15.positionsOffset,
          targetOffset = _this$props15.targetOffset,
          isRestrictScroll = _this$props15.isRestrictScroll,
          palette = _this$props15.palette,
          i18nKeys = _this$props15.i18nKeys,
          getFooter = _this$props15.getFooter,
          needEffect = _this$props15.needEffect,
          boxSize = _this$props15.boxSize,
          isLoading = _this$props15.isLoading,
          selectAllText = _this$props15.selectAllText,
          needSelectAll = _this$props15.needSelectAll;
      var _this$state9 = this.state,
          selectedOptions = _this$state9.selectedOptions,
          searchStr = _this$state9.searchStr,
          hoverOption = _this$state9.hoverOption,
          options = _this$state9.options,
          isFetchingOptions = _this$state9.isFetchingOptions,
          selectedOptionIds = _this$state9.selectedOptionIds;
      var _i18nKeys = i18nKeys,
          _i18nKeys$searchText = _i18nKeys.searchText,
          searchText = _i18nKeys$searchText === void 0 ? 'Searching...' : _i18nKeys$searchText;
      var suggestions = this.handleFilterSuggestions();
      var setAriaId = this.getNextAriaId();
      var ariaErrorId = this.getNextAriaId();
      i18nKeys = Object.assign({}, _defaultProps2.defaultProps.i18nKeys, i18nKeys, {
        emptyText: i18nKeys.emptyText || emptyMessage,
        searchEmptyText: i18nKeys.searchEmptyText || searchEmptyMessage,
        noMoreText: i18nKeys.noMoreText || noMoreOptionsMessage
      });
      var isModel = (0, _isMobilePopover["default"])(needResponsive);
      return /*#__PURE__*/_react["default"].createElement("div", {
        className: "".concat(_MultiSelectModule["default"].wrapper, " ").concat(isDisabled ? _MultiSelectModule["default"].disabled : '', " ").concat(isReadOnly ? _MultiSelectModule["default"].readOnly : '', " ").concat(disableAction ? (0, _CssProvider["default"])('isBlock') : '', " ").concat(borderColor === 'transparent' ? _MultiSelectModule["default"].transparentContainer : '', " ").concat(needEffect && !(isDisabled || isReadOnly) ? _MultiSelectModule["default"].effect : ''),
        "data-id": "".concat(isDisabled ? "".concat(dataId, "_disabled") : isReadOnly ? "".concat(dataId, "_readOnly") : dataId),
        "data-test-id": "".concat(isDisabled ? "".concat(dataId, "_disabled") : isReadOnly ? "".concat(dataId, "_readOnly") : dataId),
        "data-title": isDisabled ? title : null,
        onClick: this.handleInputFocus,
        "data-selector-id": dataSelectorId
      }, this.getSelectionUI(), !isReadOnly && !isDisabled && !disableAction && isPopupOpen ? /*#__PURE__*/_react["default"].createElement(_ResponsiveDropBox["default"], {
        animationStyle: animationStyle,
        boxPosition: position || "".concat(defaultDropBoxPosition),
        getRef: getContainerRef,
        isActive: isPopupReady,
        isAnimate: isAnimate,
        isArrow: false,
        onClick: removeClose,
        needResponsive: needResponsive,
        isPadding: false,
        isBoxPaddingNeed: isBoxPaddingNeed,
        isAbsolutePositioningNeeded: isAbsolutePositioningNeeded,
        positionsOffset: positionsOffset,
        targetOffset: targetOffset,
        isRestrictScroll: isRestrictScroll,
        palette: palette,
        htmlId: setAriaId,
        a11y: {
          role: 'listbox',
          ariaMultiselectable: true
        },
        size: boxSize,
        alignBox: "row",
        isResponsivePadding: getFooter ? false : true,
        dataId: "".concat(dataId, "_dropbox")
      }, /*#__PURE__*/_react["default"].createElement(_Layout.Box, {
        flexible: true
      }, /*#__PURE__*/_react["default"].createElement(_Card["default"], {
        customClass: "".concat(_MultiSelectModule["default"].box, " ").concat(_MultiSelectModule["default"]["".concat(palette, "Box")]),
        onScroll: this.handleScroll
      }, isModel ? /*#__PURE__*/_react["default"].createElement(_MobileHeader["default"], {
        selectedOptions: selectedOptions,
        i18nKeys: i18nKeys,
        onClick: this.handlePopupClose
      }, /*#__PURE__*/_react["default"].createElement("div", {
        className: _MultiSelectModule["default"].effect
      }, this.getSelectionUI(true))) : null, needSelectAll ? /*#__PURE__*/_react["default"].createElement(_Card.CardHeader, null, /*#__PURE__*/_react["default"].createElement(_MultiSelectHeader["default"], {
        onSelect: this.handleSelectAll,
        selectAllText: selectAllText,
        suggestions: suggestions,
        dataId: dataId
      })) : null, isLoading ? /*#__PURE__*/_react["default"].createElement(_Layout.Container, {
        align: "both",
        className: _MultiSelectModule["default"].loader
      }, /*#__PURE__*/_react["default"].createElement(_Loader["default"], null)) : /*#__PURE__*/_react["default"].createElement(_Card.CardContent, {
        shrink: true,
        customClass: !isModel && dropBoxSize ? _MultiSelectModule["default"][dropBoxSize] : '',
        eleRef: this.suggestionContainerRef
      }, isSearching ? /*#__PURE__*/_react["default"].createElement("div", {
        className: _MultiSelectModule["default"][palette]
      }, searchText) : suggestions.length ? /*#__PURE__*/_react["default"].createElement(_Suggestions["default"], {
        suggestions: suggestions,
        getRef: this.suggestionItemRef,
        hoverOption: hoverOption,
        onClick: this.handleSelectOption,
        onMouseEnter: this.handleMouseEnter,
        needBorder: false,
        dataId: "".concat(dataId, "_Options"),
        palette: palette,
        selectedOptions: selectedOptionIds,
        a11y: {
          role: 'option'
        }
      }) : /*#__PURE__*/_react["default"].createElement(_EmptyState["default"], {
        isLoading: isFetchingOptions,
        options: options,
        searchString: searchStr,
        suggestions: suggestions,
        dataId: dataId,
        palette: palette,
        i18nKeys: i18nKeys,
        htmlId: ariaErrorId
      }), isFetchingOptions && /*#__PURE__*/_react["default"].createElement(_Layout.Container, {
        isCover: false,
        align: "both"
      }, /*#__PURE__*/_react["default"].createElement(_Loader["default"], null))), getFooter ? /*#__PURE__*/_react["default"].createElement(_Card.CardFooter, null, getFooter()) : null))) : null);
    }
  }]);

  return MultiSelectComponent;
}(_react["default"].Component);

exports.MultiSelectComponent = MultiSelectComponent;
MultiSelectComponent.propTypes = _propTypes.MultiSelect_propTypes;
MultiSelectComponent.defaultProps = _defaultProps.MultiSelect_defaultProps;
MultiSelectComponent.displayName = 'MultiSelect';
var MultiSelect = (0, _Popup["default"])(MultiSelectComponent);
MultiSelect.propTypes = MultiSelectComponent.propTypes;
MultiSelect.defaultProps = MultiSelectComponent.defaultProps;
var _default = MultiSelect;
exports["default"] = _default;