Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
@doodle/components / controls / Input / MultiEmailSelect / MultiEmailSelect.js
Size: Mime:
"use strict";

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

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

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

var _propTypes = _interopRequireDefault(require("prop-types"));

var _uniqueBy = _interopRequireDefault(require("unique-by"));

var _fastDeepEqual = _interopRequireDefault(require("fast-deep-equal"));

var _creatable = _interopRequireDefault(require("react-select/creatable"));

var _classnames = _interopRequireDefault(require("classnames"));

var _InputFeedback = _interopRequireDefault(require("../InputFeedback"));

var _LimitIndicator = _interopRequireDefault(require("./LimitIndicator"));

var _Option = _interopRequireDefault(require("./Option"));

var _Menu = _interopRequireDefault(require("./Menu"));

var _ColoredMultiValueContainer = _interopRequireDefault(require("./ColoredMultiValueContainer"));

var _Button = _interopRequireDefault(require("../../Button/Button"));

var _ButtonLabel = _interopRequireDefault(require("../../Button/ButtonLabel"));

var _LoadingButton = _interopRequireDefault(require("../../Button/LoadingButton"));

var _validation = require("../../../utils/validation");

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

function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }

function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (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 _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) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_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" && Symbol.iterator in Object(iter)) 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 ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }

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); 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 } }); if (superClass) _setPrototypeOf(subClass, superClass); }

function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || 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; } 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 { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }

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

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

var valueContainer;
var KEYCODE_ENTER = 13;
var KEYCODE_SPACE = 32;
var INPUT_BLUR = 'input-blur';
var SET_VALUE = 'set-value';

var MultiEmailSelect = /*#__PURE__*/function (_Component) {
  _inherits(MultiEmailSelect, _Component);

  var _super = _createSuper(MultiEmailSelect);

  function MultiEmailSelect(props) {
    var _this;

    _classCallCheck(this, MultiEmailSelect);

    _this = _super.call(this, props);

    _defineProperty(_assertThisInitialized(_this), "onAddButtonClickHandler", function () {
      _this.props.onAddButtonClick(_this.state.value);
    });

    _defineProperty(_assertThisInitialized(_this), "onChangeHandler", function (value) {
      /**
       * Null value returned when trigger removal of last item
       */
      var existingValue = [];
      if (value !== null) existingValue = value;
      var lastOption = existingValue.slice(-1)[0];
      /**
       * Add indicator to each value according to validation rules
       */

      var validatedValues = existingValue.map(function (valueEntry) {
        return _objectSpread(_objectSpread({}, valueEntry), {}, {
          valid: !_this.isInvalidValue(valueEntry)
        });
      });

      var valuesWithAdditionalData = _this.props.onValueChange(validatedValues);

      var finalProvidedValues = existingValue;

      if (valuesWithAdditionalData) {
        finalProvidedValues = valuesWithAdditionalData;
      }

      if (lastOption && lastOption.initalOptions) {
        value.pop();

        _this.setState({
          value: _this.selectInitialOptions(finalProvidedValues.concat(lastOption.initalOptions), _this.state.value)
        });
      } else {
        _this.setState({
          value: finalProvidedValues
        });
      }

      _this.setState({
        inputValue: ''
      });
    });

    _defineProperty(_assertThisInitialized(_this), "onInputChangeHandler", function (inputValue, event) {
      var onInputChange = _this.props.onInputChange;

      if (inputValue || _this.state.inputValue.length === 1) {
        onInputChange(inputValue);

        _this.setState({
          inputValue: inputValue
        });
      } else if (event.action === INPUT_BLUR) {
        // When a user clicks outside the text field,
        // the text should be kept and set in state rather than being removed
        onInputChange(_this.state.inputValue);

        _this.setState({
          inputValue: _this.state.inputValue
        });
      } else if (event.action === SET_VALUE) {
        // This acts as a patch for the input-blur behaviour above
        // because input-blur gets called on mobile when a selection
        // is made so the inputValue should be set back to an empty string.
        // Previously, this was causing a duplicate email bug on mobile
        // - SE-308
        _this.setState({
          inputValue: ''
        });
      }

      _this.toggleMenu(inputValue, false, event.action);
    });

    _defineProperty(_assertThisInitialized(_this), "onFocusHandler", function () {
      if (_this.extraSmallDevices) {
        _this.setState({
          mobile: true
        });
      }

      _this.toggleMenu(_this.state.inputValue, true, false);
    });

    _defineProperty(_assertThisInitialized(_this), "onPasteHandler", function (event) {
      var clipboardContents = event && event.clipboardData && event.clipboardData.getData('text/plain');
      var clipboardContentsForIECompatibility = window && window.clipboardData && window.clipboardData.getData('Text');
      var pastedText = clipboardContents || clipboardContentsForIECompatibility;

      if (pastedText) {
        event.preventDefault();

        var pastedEmails = _this.extractEmailfromText(pastedText);

        var alreadySelectedOptions = _this.state.value.map(function (entry) {
          return entry.value;
        });

        var uniqueEmails = _this.getUniqEmails(pastedEmails, alreadySelectedOptions);

        var newValue = [].concat(_toConsumableArray(_this.state.value), _toConsumableArray(uniqueEmails));

        _this.onChangeHandler(newValue);
      }
    });

    _defineProperty(_assertThisInitialized(_this), "onKeyDownInput", function (e) {
      // Select value on space press

      /**
       * Add check for keycode on enter see onInputChangeHandler
       */
      if ((e.keyCode === KEYCODE_ENTER || e.keyCode === KEYCODE_SPACE) && _this.multiEmailSelect.select.select.state.focusedOption) {
        e.preventDefault(); // Create new option

        var option = _this.multiEmailSelect.select.select.state.focusedOption;
        var newValue = {
          label: option.label || option.value.trim(),
          value: option.value.trim(),
          __isNew__: true
        }; // Check if options exists

        var exists = _this.state.value.filter(function (item) {
          return item.value === option.value;
        });

        if (!exists.length) {
          // Add option to selection
          var selectedValue = [].concat(_toConsumableArray(_this.state.value), [newValue]);

          _this.multiEmailSelect.select.select.setValue(selectedValue);
        }
      }
    });

    _defineProperty(_assertThisInitialized(_this), "getUniqEmails", function (emails, alreadySelectedOptions) {
      if (emails.length) {
        return (0, _uniqueBy["default"])(emails, 'emailAddress').filter(function (newEmail) {
          var duplicate = alreadySelectedOptions.find(function (email) {
            return email === newEmail.emailAddress;
          });
          return !duplicate;
        }).map(function (newContact) {
          return {
            label: newContact.name || newContact.emailAddress,
            value: newContact.emailAddress,
            __isNew__: true
          };
        });
      }

      return [];
    });

    _defineProperty(_assertThisInitialized(_this), "getDecoratedValue", function () {
      var decorateValue = _this.props.decorateValue;
      return _this.state.value.map(function (valueEntry) {
        return _objectSpread(_objectSpread({}, valueEntry), decorateValue(valueEntry));
      });
    });

    _defineProperty(_assertThisInitialized(_this), "extractEmailfromText", function (text) {
      var emailAddresses = [];
      var currentMatch; // eslint-disable-next-line no-cond-assign

      var _loop = function _loop() {
        var options = _this.props.options;
        var email = currentMatch[2];
        var name = null;

        if (options) {
          var existingOption = options.filter(function (option) {
            return option.value === email;
          });

          if (existingOption.length >= 1) {
            name = existingOption[0].label;
          }
        }

        emailAddresses.push({
          name: name,
          emailAddress: email
        });
      };

      while ((currentMatch = _validation.TEXT_WITH_NAME_REGEX.exec(text)) && !_this.isEmailsLimit()) {
        _loop();
      }

      return emailAddresses;
    });

    _defineProperty(_assertThisInitialized(_this), "toggleMenu", function (inputValue, onFocus, action) {
      if (_this.props.initialOptions !== null && (onFocus || action !== 'menu-close' && action !== 'input-blur' && inputValue.length < 1)) {
        _this.setState({
          menuIsOpen: true,
          currentOptions: _this.transformInitialOptions(_this.props.initialOptions, _this.state.value)
        });
      } else if (!_this.isEmailsLimit() && (inputValue.length >= 3 || _this.props.activateSuggestions !== null)) {
        // When activateSuggestions params are given, the handlers of its buttons will call the closeMenu method
        _this.setState({
          menuIsOpen: true,
          currentOptions: _this.props.options
        });
      } else if (_this.state.menuIsOpen && inputValue.length < 3) {
        _this.setState({
          menuIsOpen: false
        });
      } else {
        _this.setState({
          menuIsOpen: false
        });
      }
    });

    _defineProperty(_assertThisInitialized(_this), "closeMenu", function () {
      _this.setState({
        menuIsOpen: false
      });
    });

    _defineProperty(_assertThisInitialized(_this), "isEmailsLimit", function () {
      var emailsLength = _this.state.value.length;
      return emailsLength >= _this.props.emailsLimit;
    });

    _defineProperty(_assertThisInitialized(_this), "isOptionDisabled", function (option, selectValue) {
      var found = selectValue.find(function (value) {
        return value.value === option.value;
      });
      return found !== undefined;
    });

    _defineProperty(_assertThisInitialized(_this), "transformInitialOptions", function (initialOptions, selectValue) {
      if (initialOptions !== null) {
        var transformedInitialOptions = [];
        Object.entries(initialOptions).forEach(function (entry) {
          var count = 0;
          selectValue.forEach(function (obj) {
            entry[1].options.forEach(function (obj2) {
              if ((0, _fastDeepEqual["default"])(obj.value, obj2.value)) {
                count += 1;
              }
            });
          });
          var optionsAlreadyAdded = count === entry[1].options.length;

          if (!optionsAlreadyAdded) {
            var emailLabels = [];
            entry[1].options.forEach(function (item) {
              emailLabels.push(item.label);
            });
            transformedInitialOptions.push({
              value: emailLabels.join(', '),
              label: entry[1].label,
              initalOptions: entry[1].options,
              icon: entry[1].icon
            });
          }
        });
        return transformedInitialOptions;
      }
    });

    _defineProperty(_assertThisInitialized(_this), "selectInitialOptions", function (initialOptions, alreadySelectedOptions) {
      var filteredOptions = initialOptions.filter(function (initialOption) {
        var duplicate = alreadySelectedOptions.find(function (option) {
          return option.value === initialOption.value;
        });
        return !duplicate;
      });
      return [].concat(_toConsumableArray(alreadySelectedOptions), _toConsumableArray(filteredOptions));
    });

    _defineProperty(_assertThisInitialized(_this), "disableButton", function () {
      return _this.state.value.length === 0 || _this.hasInvalidValues() || _this.exceededEmailsLimit() || _this.props.isButtonDisabled;
    });

    _defineProperty(_assertThisInitialized(_this), "isInvalidValue", function (valueEntry) {
      return !(0, _validation.isEmailValidForWhitelist)(valueEntry.value) || !_validation.STRICT_EMAIL_REGEX.test(valueEntry.value);
    });

    _defineProperty(_assertThisInitialized(_this), "hasInvalidValues", function () {
      var invalidValues = _this.state.value.filter(function (valueEntry) {
        return _this.isInvalidValue(valueEntry);
      });

      return invalidValues.length >= 1;
    });

    _defineProperty(_assertThisInitialized(_this), "isError", function () {
      var _this$props = _this.props,
          limitExceededText = _this$props.limitExceededText,
          invalidFormatText = _this$props.invalidFormatText;
      return _this.hasInvalidValues() && invalidFormatText || _this.exceededEmailsLimit() && limitExceededText;
    });

    _defineProperty(_assertThisInitialized(_this), "exceededEmailsLimit", function () {
      var value = _this.state.value;
      var emailsLimit = _this.props.emailsLimit;
      var invalidValues = value.filter(function (valueEntry) {
        return _this.isInvalidValue(valueEntry);
      });
      var validEmailsLength = value.length - invalidValues.length;
      return validEmailsLength > emailsLimit;
    });

    _defineProperty(_assertThisInitialized(_this), "limitExceededError", function () {
      return _this.exceededEmailsLimit() && _this.props.limitExceededText;
    });

    _defineProperty(_assertThisInitialized(_this), "invalidFormatError", function () {
      return _this.hasInvalidValues() && _this.props.invalidFormatText;
    });

    var initValues = props.initialValues.length ? props.initialValues : [];
    _this.state = {
      menuIsOpen: false,
      value: initValues,
      inputValue: '',
      mobile: false,
      currentOptions: _this.props.options
    };
    return _this;
  }

  _createClass(MultiEmailSelect, [{
    key: "componentDidMount",
    value: function componentDidMount() {
      this.multiEmailSelectContainer.querySelector('input').onpaste = this.onPasteHandler;

      var _document$getElements = document.getElementsByClassName('MultiEmailSelect__value-container');

      var _document$getElements2 = _slicedToArray(_document$getElements, 1);

      valueContainer = _document$getElements2[0];
      this.extraSmallDevices = window.innerWidth < 480;
    }
  }, {
    key: "componentDidUpdate",
    value: function componentDidUpdate(prevProps, prevState) {
      if (prevState.value !== this.state.value) {
        if (this.extraSmallDevices) {
          valueContainer.scrollTop = valueContainer.scrollHeight - valueContainer.offsetHeight;
          this.multiEmailSelect.focus();
        }

        if (this.props.initialOptions !== null) {
          /* eslint-disable */
          // this is fine per react docs, hance the es lint disable
          // https://reactjs.org/docs/react-component.html#componentdidupdate
          this.setState({
            currentOptions: this.transformInitialOptions(this.props.initialOptions, this.state.value)
          });
        }
      }

      if (prevProps.options !== this.props.options) {
        this.setState({
          currentOptions: this.props.options
        });
      }
      /* eslint-enable */

    }
    /**
     * Calls the function provided by the onAddButtonClick prop and can be used to work with the selected options outside of this component.
     */

  }, {
    key: "render",
    value: function render() {
      var _this2 = this;

      var _this$props2 = this.props,
          placeholderText = _this$props2.placeholderText,
          buttonText = _this$props2.buttonText,
          emailsLimit = _this$props2.emailsLimit,
          alreadyInListText = _this$props2.alreadyInListText,
          activateSuggestions = _this$props2.activateSuggestions,
          newOptionText = _this$props2.newOptionText,
          addDomainText = _this$props2.addDomainText,
          hideAddButton = _this$props2.hideAddButton,
          styles = _this$props2.styles,
          noteText = _this$props2.noteText,
          limitExceededText = _this$props2.limitExceededText,
          invalidFormatText = _this$props2.invalidFormatText,
          isLoading = _this$props2.isLoading,
          isDisabled = _this$props2.isDisabled,
          formatOptionLabel = _this$props2.formatOptionLabel;
      var createableSelectClassNames = (0, _classnames["default"])('MultiEmailSelect', {
        'MultiEmailSelect--no-input': hideAddButton,
        'MultiEmailSelect--error': this.isError()
      });
      return /*#__PURE__*/_react["default"].createElement("div", {
        className: "MultiEmailSelect__container".concat(this.state.mobile ? ' extraSmallDevices' : ''),
        ref: function ref(_ref2) {
          _this2.multiEmailSelectContainer = _ref2;
        }
      }, /*#__PURE__*/_react["default"].createElement(_creatable["default"], {
        ref: function ref(_ref) {
          _this2.multiEmailSelect = _ref;
        },
        className: createableSelectClassNames,
        classNamePrefix: "MultiEmailSelect",
        onChange: this.onChangeHandler,
        onInputChange: this.onInputChangeHandler,
        onFocus: this.onFocusHandler,
        onPaste: this.onPaste,
        value: this.getDecoratedValue(),
        inputValue: this.state.inputValue,
        options: this.state.currentOptions,
        activateSuggestions: activateSuggestions,
        menuIsOpen: this.state.menuIsOpen,
        closeMenu: this.closeMenu,
        closeMenuOnSelect: false,
        components: {
          IndicatorSeparator: _LimitIndicator["default"],
          Option: _Option["default"],
          Menu: _Menu["default"],
          MultiValueContainer: _ColoredMultiValueContainer["default"]
        },
        styles: styles,
        isOptionDisabled: this.isOptionDisabled,
        isMulti: true,
        isSearchable: true,
        isDisabled: isDisabled,
        isClearable: false,
        hideSelectedOptions: false,
        createOptionPosition: "first",
        noOptionsMessage: function noOptionsMessage() {
          return null;
        },
        formatCreateLabel: function formatCreateLabel() {
          return null;
        },
        emailsLimit: emailsLimit,
        alreadyInListText: alreadyInListText,
        placeholder: placeholderText,
        newOptionText: newOptionText,
        addDomainText: addDomainText,
        onKeyDown: this.onKeyDownInput,
        formatOptionLabel: formatOptionLabel
      }), !hideAddButton && /*#__PURE__*/_react["default"].createElement(_Button["default"], {
        variant: "blue",
        onClick: this.onAddButtonClickHandler,
        type: "submit",
        disabled: this.disableButton(),
        inputButtonClass: isLoading ? 'loading' : null
      }, /*#__PURE__*/_react["default"].createElement(_ButtonLabel["default"], null, buttonText), /*#__PURE__*/_react["default"].createElement(_LoadingButton["default"], null)), noteText && /*#__PURE__*/_react["default"].createElement(_InputFeedback["default"], {
        type: "note"
      }, noteText), this.limitExceededError() && /*#__PURE__*/_react["default"].createElement(_InputFeedback["default"], {
        type: "error"
      }, limitExceededText), this.invalidFormatError() && /*#__PURE__*/_react["default"].createElement(_InputFeedback["default"], {
        type: "error"
      }, invalidFormatText));
    }
  }]);

  return MultiEmailSelect;
}(_react.Component);

_defineProperty(MultiEmailSelect, "propTypes", {
  /** Provides the options for the searchable select component as an array of objects containing a value and label key  */
  options: _propTypes["default"].arrayOf(_propTypes["default"].shape({
    value: _propTypes["default"].string.isRequired,
    label: _propTypes["default"].string
  })),

  /** Provides groups of invitees from a poll as initial options */
  initialOptions: _propTypes["default"].shape({
    participated: _propTypes["default"].shape({
      label: _propTypes["default"].string,
      icon: _propTypes["default"].any,
      options: _propTypes["default"].arrayOf(_propTypes["default"].shape({
        value: _propTypes["default"].string,
        label: _propTypes["default"].string
      }))
    }),
    notParticipated: _propTypes["default"].shape({
      label: _propTypes["default"].string,
      icon: _propTypes["default"].any,
      options: _propTypes["default"].arrayOf(_propTypes["default"].shape({
        value: _propTypes["default"].string,
        label: _propTypes["default"].string
      }))
    }),
    everyone: _propTypes["default"].shape({
      label: _propTypes["default"].string,
      icon: _propTypes["default"].any,
      options: _propTypes["default"].arrayOf(_propTypes["default"].shape({
        value: _propTypes["default"].string,
        label: _propTypes["default"].string
      }))
    })
  }),

  /** Provide this object if the user should see the activateSuggestions */
  activateSuggestions: _propTypes["default"].shape({
    headline: _propTypes["default"].string,
    text: _propTypes["default"].string,
    buttonText: _propTypes["default"].string,
    buttonLink: _propTypes["default"].string,
    silentButtonText: _propTypes["default"].string,
    onSilentButtonClick: _propTypes["default"].func
  }),
  placeholderText: _propTypes["default"].string,
  noteText: _propTypes["default"].string,
  buttonText: _propTypes["default"].string,
  isButtonDisabled: _propTypes["default"].bool,
  alreadyInListText: _propTypes["default"].string,
  newOptionText: _propTypes["default"].string,
  addDomainText: _propTypes["default"].string,

  /** Limit of emails the select component can hold */
  emailsLimit: _propTypes["default"].number,

  /** A function that takes all selected options as an argument */
  onAddButtonClick: _propTypes["default"].func,
  hideAddButton: _propTypes["default"].bool,

  /** A function that takes current values, each with an indicator of whether it's valid or not */
  onValueChange: _propTypes["default"].func,
  onInputChange: _propTypes["default"].func,
  styles: _propTypes["default"].object,
  initialValues: _propTypes["default"].arrayOf(_propTypes["default"].shape({
    value: _propTypes["default"].string.isRequired,
    label: _propTypes["default"].string
  })),

  /**
   * Optional prop that decorates the value object with additional properties.
   * Used for example to render values with a different colour.
   * Note: only return the additional properties. No need to return the original object.
   * You can pass a `style` object or a `className` string to customise the style
   * of the contact chips.
   * @param {{ label: string, value: string }} valueEntry The value to decorate
   * @returns {Object} The additional properties to enrich the value entry with.
   * @see {ColoredMultiValueContainer}
   */
  decorateValue: _propTypes["default"].func,
  invalidFormatText: _propTypes["default"].string,
  limitExceededText: _propTypes["default"].string,
  isLoading: _propTypes["default"].bool,
  isDisabled: _propTypes["default"].bool,

  /**
   * (Inherited from CreatableSelect) Formats the option text. This can affect both
   * options in the dropdown menu and selected values.
   * @param {{label: string, value: string, data: Object}} option
   * @param {{context: 'menu'|'value', inputValue: string, selectValue: Object[]}} parameters
   * @returns {ReactNode}
   * @see https://react-select.com/props
   */
  formatOptionLabel: _propTypes["default"].func
});

_defineProperty(MultiEmailSelect, "defaultProps", {
  onAddButtonClick: function onAddButtonClick() {},
  placeholderText: null,
  activateSuggestions: null,
  initialOptions: null,
  alreadyInListText: null,
  addDomainText: null,
  options: null,
  noteText: null,
  buttonText: null,
  isButtonDisabled: false,
  emailsLimit: 9999,
  newOptionText: null,
  hideAddButton: false,
  onValueChange: function onValueChange() {},
  onInputChange: function onInputChange() {},
  styles: {},
  initialValues: [],
  decorateValue: function decorateValue() {},
  invalidFormatText: '',
  limitExceededText: '',
  isLoading: false,
  isDisabled: false,
  formatOptionLabel: null
});

var _default = MultiEmailSelect;
exports["default"] = _default;