react-mentions 4.3.0 → 4.4.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.
@@ -2,10 +2,10 @@ import _toConsumableArray from '@babel/runtime/helpers/esm/toConsumableArray';
2
2
  import _extends from '@babel/runtime/helpers/esm/extends';
3
3
  import _classCallCheck from '@babel/runtime/helpers/esm/classCallCheck';
4
4
  import _createClass from '@babel/runtime/helpers/esm/createClass';
5
- import _possibleConstructorReturn from '@babel/runtime/helpers/esm/possibleConstructorReturn';
6
- import _getPrototypeOf from '@babel/runtime/helpers/esm/getPrototypeOf';
7
5
  import _assertThisInitialized from '@babel/runtime/helpers/esm/assertThisInitialized';
8
6
  import _inherits from '@babel/runtime/helpers/esm/inherits';
7
+ import _possibleConstructorReturn from '@babel/runtime/helpers/esm/possibleConstructorReturn';
8
+ import _getPrototypeOf from '@babel/runtime/helpers/esm/getPrototypeOf';
9
9
  import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
10
10
  import React, { Children, Component } from 'react';
11
11
  import invariant from 'invariant';
@@ -621,6 +621,10 @@ var getSubstringIndex = function getSubstringIndex(str, substr, ignoreAccents) {
621
621
  return normalizeString(str).indexOf(normalizeString(substr));
622
622
  };
623
623
 
624
+ var isIE = function isIE() {
625
+ return !!document.documentMode;
626
+ };
627
+
624
628
  var isNumber = function isNumber(val) {
625
629
  return typeof val === 'number';
626
630
  };
@@ -647,13 +651,15 @@ var omit = function omit(obj) {
647
651
  }, {});
648
652
  };
649
653
 
654
+ var _excluded = ["style", "className", "classNames"];
655
+
650
656
  function createDefaultStyle(defaultStyle, getModifiers) {
651
657
  var enhance = function enhance(ComponentToWrap) {
652
658
  var DefaultStyleEnhancer = function DefaultStyleEnhancer(_ref) {
653
659
  var style = _ref.style,
654
660
  className = _ref.className,
655
661
  classNames = _ref.classNames,
656
- rest = _objectWithoutProperties(_ref, ["style", "className", "classNames"]);
662
+ rest = _objectWithoutProperties(_ref, _excluded);
657
663
 
658
664
  var modifiers = getModifiers ? getModifiers(rest) : undefined;
659
665
  var styles = useStyles(defaultStyle, {
@@ -661,7 +667,7 @@ function createDefaultStyle(defaultStyle, getModifiers) {
661
667
  className: className,
662
668
  classNames: classNames
663
669
  }, modifiers);
664
- return React.createElement(ComponentToWrap, _extends({}, rest, {
670
+ return /*#__PURE__*/React.createElement(ComponentToWrap, _extends({}, rest, {
665
671
  style: styles
666
672
  }));
667
673
  };
@@ -674,6 +680,10 @@ function createDefaultStyle(defaultStyle, getModifiers) {
674
680
  return enhance;
675
681
  }
676
682
 
683
+ 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); }; }
684
+
685
+ 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; } }
686
+
677
687
  var _generateComponentKey = function _generateComponentKey(usedKeys, id) {
678
688
  if (!usedKeys.hasOwnProperty(id)) {
679
689
  usedKeys[id] = 0;
@@ -684,17 +694,17 @@ var _generateComponentKey = function _generateComponentKey(usedKeys, id) {
684
694
  return id + '_' + usedKeys[id];
685
695
  };
686
696
 
687
- var Highlighter =
688
- /*#__PURE__*/
689
- function (_Component) {
697
+ var Highlighter = /*#__PURE__*/function (_Component) {
690
698
  _inherits(Highlighter, _Component);
691
699
 
700
+ var _super = _createSuper(Highlighter);
701
+
692
702
  function Highlighter() {
693
703
  var _this;
694
704
 
695
705
  _classCallCheck(this, Highlighter);
696
706
 
697
- _this = _possibleConstructorReturn(this, _getPrototypeOf(Highlighter).apply(this, arguments));
707
+ _this = _super.apply(this, arguments);
698
708
 
699
709
  _defineProperty(_assertThisInitialized(_this), "setCaretElement", function (el) {
700
710
  _this.caretElement = el;
@@ -797,7 +807,7 @@ function (_Component) {
797
807
  resultComponents.push(this.renderHighlighterCaret(components));
798
808
  }
799
809
 
800
- return React.createElement("div", _extends({}, style, {
810
+ return /*#__PURE__*/React.createElement("div", _extends({}, style, {
801
811
  ref: containerRef
802
812
  }), resultComponents);
803
813
  }
@@ -805,7 +815,7 @@ function (_Component) {
805
815
  key: "renderSubstring",
806
816
  value: function renderSubstring(string, key) {
807
817
  // set substring span to hidden, so that Emojis are not shown double in Mobile Safari
808
- return React.createElement("span", _extends({}, this.props.style('substring'), {
818
+ return /*#__PURE__*/React.createElement("span", _extends({}, this.props.style('substring'), {
809
819
  key: key
810
820
  }), string);
811
821
  } // Returns a clone of the Mention child applicable for the specified type to be rendered inside the highlighter
@@ -819,13 +829,13 @@ function (_Component) {
819
829
  key: key
820
830
  };
821
831
  var child = Children.toArray(this.props.children)[mentionChildIndex];
822
- return React.cloneElement(child, props);
832
+ return /*#__PURE__*/React.cloneElement(child, props);
823
833
  } // Renders an component to be inserted in the highlighter at the current caret position
824
834
 
825
835
  }, {
826
836
  key: "renderHighlighterCaret",
827
837
  value: function renderHighlighterCaret(children) {
828
- return React.createElement("span", _extends({}, this.props.style('caret'), {
838
+ return /*#__PURE__*/React.createElement("span", _extends({}, this.props.style('caret'), {
829
839
  ref: this.setCaretElement,
830
840
  key: "caret"
831
841
  }), children);
@@ -874,15 +884,19 @@ var styled = createDefaultStyle({
874
884
  });
875
885
  var Highlighter$1 = styled(Highlighter);
876
886
 
877
- var Suggestion =
878
- /*#__PURE__*/
879
- function (_Component) {
887
+ function _createSuper$1(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$1(); 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); }; }
888
+
889
+ function _isNativeReflectConstruct$1() { 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; } }
890
+
891
+ var Suggestion = /*#__PURE__*/function (_Component) {
880
892
  _inherits(Suggestion, _Component);
881
893
 
894
+ var _super = _createSuper$1(Suggestion);
895
+
882
896
  function Suggestion() {
883
897
  _classCallCheck(this, Suggestion);
884
898
 
885
- return _possibleConstructorReturn(this, _getPrototypeOf(Suggestion).apply(this, arguments));
899
+ return _super.apply(this, arguments);
886
900
  }
887
901
 
888
902
  _createClass(Suggestion, [{
@@ -890,7 +904,7 @@ function (_Component) {
890
904
  value: function render() {
891
905
  var rest = omit(this.props, ['style', 'classNames', 'className'], // substyle props
892
906
  keys(Suggestion.propTypes));
893
- return React.createElement("li", _extends({
907
+ return /*#__PURE__*/React.createElement("li", _extends({
894
908
  id: this.props.id,
895
909
  role: "option",
896
910
  "aria-selected": this.props.focused
@@ -942,10 +956,10 @@ function (_Component) {
942
956
  var i = getSubstringIndex(display, query, ignoreAccents);
943
957
 
944
958
  if (i === -1) {
945
- return React.createElement("span", style('display'), display);
959
+ return /*#__PURE__*/React.createElement("span", style('display'), display);
946
960
  }
947
961
 
948
- return React.createElement("span", style('display'), display.substring(0, i), React.createElement("b", style('highlight'), display.substring(i, i + query.length)), display.substring(i + query.length));
962
+ return /*#__PURE__*/React.createElement("span", style('display'), display.substring(0, i), /*#__PURE__*/React.createElement("b", style('highlight'), display.substring(i, i + query.length)), display.substring(i + query.length));
949
963
  }
950
964
  }]);
951
965
 
@@ -977,17 +991,19 @@ var Suggestion$1 = styled$1(Suggestion);
977
991
  function LoadingIndicator() {
978
992
  var styles = useStyles();
979
993
  var spinnerStyles = styles('spinner');
980
- return React.createElement("div", styles, React.createElement("div", spinnerStyles, React.createElement("div", spinnerStyles(['element', 'element1'])), React.createElement("div", spinnerStyles(['element', 'element2'])), React.createElement("div", spinnerStyles(['element', 'element3'])), React.createElement("div", spinnerStyles(['element', 'element4'])), React.createElement("div", spinnerStyles(['element', 'element5']))));
994
+ return /*#__PURE__*/React.createElement("div", styles, /*#__PURE__*/React.createElement("div", spinnerStyles, /*#__PURE__*/React.createElement("div", spinnerStyles(['element', 'element1'])), /*#__PURE__*/React.createElement("div", spinnerStyles(['element', 'element2'])), /*#__PURE__*/React.createElement("div", spinnerStyles(['element', 'element3'])), /*#__PURE__*/React.createElement("div", spinnerStyles(['element', 'element4'])), /*#__PURE__*/React.createElement("div", spinnerStyles(['element', 'element5']))));
981
995
  }
982
996
 
983
- var SuggestionsOverlay =
984
- /*#__PURE__*/
985
- function (_Component) {
997
+ function _createSuper$2(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$2(); 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); }; }
998
+
999
+ function _isNativeReflectConstruct$2() { 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; } }
1000
+
1001
+ var SuggestionsOverlay = /*#__PURE__*/function (_Component) {
986
1002
  _inherits(SuggestionsOverlay, _Component);
987
1003
 
988
- function SuggestionsOverlay() {
989
- var _getPrototypeOf2;
1004
+ var _super = _createSuper$2(SuggestionsOverlay);
990
1005
 
1006
+ function SuggestionsOverlay() {
991
1007
  var _this;
992
1008
 
993
1009
  _classCallCheck(this, SuggestionsOverlay);
@@ -996,7 +1012,7 @@ function (_Component) {
996
1012
  args[_key] = arguments[_key];
997
1013
  }
998
1014
 
999
- _this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(SuggestionsOverlay)).call.apply(_getPrototypeOf2, [this].concat(args)));
1015
+ _this = _super.call.apply(_super, [this].concat(args));
1000
1016
 
1001
1017
  _defineProperty(_assertThisInitialized(_this), "handleMouseEnter", function (index, ev) {
1002
1018
  if (_this.props.onMouseEnter) {
@@ -1052,20 +1068,22 @@ function (_Component) {
1052
1068
  containerRef = _this$props.containerRef,
1053
1069
  position = _this$props.position,
1054
1070
  left = _this$props.left,
1071
+ right = _this$props.right,
1055
1072
  top = _this$props.top; // do not show suggestions until there is some data
1056
1073
 
1057
1074
  if (!isOpened) {
1058
1075
  return null;
1059
1076
  }
1060
1077
 
1061
- return React.createElement("div", _extends({}, inline({
1078
+ return /*#__PURE__*/React.createElement("div", _extends({}, inline({
1062
1079
  position: position || 'absolute',
1063
1080
  left: left,
1081
+ right: right,
1064
1082
  top: top
1065
1083
  }, style), {
1066
1084
  onMouseDown: onMouseDown,
1067
1085
  ref: containerRef
1068
- }), React.createElement("ul", _extends({
1086
+ }), /*#__PURE__*/React.createElement("ul", _extends({
1069
1087
  ref: this.setUlElement,
1070
1088
  id: id,
1071
1089
  role: "listbox",
@@ -1077,13 +1095,15 @@ function (_Component) {
1077
1095
  value: function renderSuggestions() {
1078
1096
  var _this2 = this;
1079
1097
 
1080
- return Object.values(this.props.suggestions).reduce(function (accResults, _ref) {
1098
+ var customSuggestionsContainer = this.props.customSuggestionsContainer;
1099
+ var suggestions = Object.values(this.props.suggestions).reduce(function (accResults, _ref) {
1081
1100
  var results = _ref.results,
1082
1101
  queryInfo = _ref.queryInfo;
1083
1102
  return [].concat(_toConsumableArray(accResults), _toConsumableArray(results.map(function (result, index) {
1084
1103
  return _this2.renderSuggestion(result, queryInfo, accResults.length + index);
1085
1104
  })));
1086
1105
  }, []);
1106
+ if (customSuggestionsContainer) return customSuggestionsContainer(suggestions);else return suggestions;
1087
1107
  }
1088
1108
  }, {
1089
1109
  key: "renderSuggestion",
@@ -1095,7 +1115,7 @@ function (_Component) {
1095
1115
  query = queryInfo.query;
1096
1116
  var renderSuggestion = Children.toArray(this.props.children)[childIndex].props.renderSuggestion;
1097
1117
  var ignoreAccents = this.props.ignoreAccents;
1098
- return React.createElement(Suggestion$1, {
1118
+ return /*#__PURE__*/React.createElement(Suggestion$1, {
1099
1119
  style: this.props.style('item'),
1100
1120
  key: "".concat(childIndex, "-").concat(getID(result)),
1101
1121
  id: getSuggestionHtmlId(this.props.id, index),
@@ -1120,7 +1140,7 @@ function (_Component) {
1120
1140
  return;
1121
1141
  }
1122
1142
 
1123
- return React.createElement(LoadingIndicator, {
1143
+ return /*#__PURE__*/React.createElement(LoadingIndicator, {
1124
1144
  style: this.props.style('loadingIndicator')
1125
1145
  });
1126
1146
  }
@@ -1136,6 +1156,7 @@ _defineProperty(SuggestionsOverlay, "propTypes", {
1136
1156
  focusIndex: PropTypes.number,
1137
1157
  position: PropTypes.string,
1138
1158
  left: PropTypes.number,
1159
+ right: PropTypes.number,
1139
1160
  top: PropTypes.number,
1140
1161
  scrollFocusedIntoView: PropTypes.bool,
1141
1162
  isLoading: PropTypes.bool,
@@ -1176,9 +1197,13 @@ var styled$2 = createDefaultStyle({
1176
1197
  });
1177
1198
  var SuggestionsOverlay$1 = styled$2(SuggestionsOverlay);
1178
1199
 
1179
- 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; }
1200
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
1201
+
1202
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
1180
1203
 
1181
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
1204
+ function _createSuper$3(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$3(); 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); }; }
1205
+
1206
+ function _isNativeReflectConstruct$3() { 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; } }
1182
1207
  var makeTriggerRegex = function makeTriggerRegex(trigger) {
1183
1208
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1184
1209
 
@@ -1236,6 +1261,7 @@ var propTypes = {
1236
1261
  a11ySuggestionsListLabel: PropTypes.string,
1237
1262
  value: PropTypes.string,
1238
1263
  onKeyDown: PropTypes.func,
1264
+ customSuggestionsContainer: PropTypes.func,
1239
1265
  onSelect: PropTypes.func,
1240
1266
  onBlur: PropTypes.func,
1241
1267
  onChange: PropTypes.func,
@@ -1246,17 +1272,17 @@ var propTypes = {
1246
1272
  children: PropTypes.oneOfType([PropTypes.element, PropTypes.arrayOf(PropTypes.element)]).isRequired
1247
1273
  };
1248
1274
 
1249
- var MentionsInput =
1250
- /*#__PURE__*/
1251
- function (_React$Component) {
1275
+ var MentionsInput = /*#__PURE__*/function (_React$Component) {
1252
1276
  _inherits(MentionsInput, _React$Component);
1253
1277
 
1278
+ var _super = _createSuper$3(MentionsInput);
1279
+
1254
1280
  function MentionsInput(_props) {
1255
1281
  var _this;
1256
1282
 
1257
1283
  _classCallCheck(this, MentionsInput);
1258
1284
 
1259
- _this = _possibleConstructorReturn(this, _getPrototypeOf(MentionsInput).call(this, _props));
1285
+ _this = _super.call(this, _props);
1260
1286
 
1261
1287
  _defineProperty(_assertThisInitialized(_this), "setContainerElement", function (el) {
1262
1288
  _this.containerElement = el;
@@ -1270,7 +1296,7 @@ function (_React$Component) {
1270
1296
 
1271
1297
  var props = omit(_this.props, ['style', 'classNames', 'className'], // substyle props
1272
1298
  keys(propTypes));
1273
- return _objectSpread({}, props, {}, style('input'), {
1299
+ return _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, props), style('input')), {}, {
1274
1300
  value: _this.getPlainText()
1275
1301
  }, !readOnly && !disabled && {
1276
1302
  onChange: _this.handleChange,
@@ -1280,7 +1306,7 @@ function (_React$Component) {
1280
1306
  onCompositionStart: _this.handleCompositionStart,
1281
1307
  onCompositionEnd: _this.handleCompositionEnd,
1282
1308
  onScroll: _this.updateHighlighterScroll
1283
- }, {}, _this.isOpened() && {
1309
+ }), _this.isOpened() && {
1284
1310
  role: 'combobox',
1285
1311
  'aria-controls': _this.uuidSuggestionsOverlay,
1286
1312
  'aria-expanded': true,
@@ -1297,18 +1323,18 @@ function (_React$Component) {
1297
1323
 
1298
1324
  var inputProps = _this.getInputProps();
1299
1325
 
1300
- return React.createElement("div", style('control'), _this.renderHighlighter(), singleLine ? _this.renderInput(inputProps) : _this.renderTextarea(inputProps));
1326
+ return /*#__PURE__*/React.createElement("div", style('control'), _this.renderHighlighter(), singleLine ? _this.renderInput(inputProps) : _this.renderTextarea(inputProps));
1301
1327
  });
1302
1328
 
1303
1329
  _defineProperty(_assertThisInitialized(_this), "renderInput", function (props) {
1304
- return React.createElement("input", _extends({
1330
+ return /*#__PURE__*/React.createElement("input", _extends({
1305
1331
  type: "text",
1306
1332
  ref: _this.setInputRef
1307
1333
  }, props));
1308
1334
  });
1309
1335
 
1310
1336
  _defineProperty(_assertThisInitialized(_this), "renderTextarea", function (props) {
1311
- return React.createElement("textarea", _extends({
1337
+ return /*#__PURE__*/React.createElement("textarea", _extends({
1312
1338
  ref: _this.setInputRef
1313
1339
  }, props));
1314
1340
  });
@@ -1337,17 +1363,20 @@ function (_React$Component) {
1337
1363
  var _this$state$suggestio = _this.state.suggestionsPosition,
1338
1364
  position = _this$state$suggestio.position,
1339
1365
  left = _this$state$suggestio.left,
1340
- top = _this$state$suggestio.top;
1341
- var suggestionsNode = React.createElement(SuggestionsOverlay$1, {
1366
+ top = _this$state$suggestio.top,
1367
+ right = _this$state$suggestio.right;
1368
+ var suggestionsNode = /*#__PURE__*/React.createElement(SuggestionsOverlay$1, {
1342
1369
  id: _this.uuidSuggestionsOverlay,
1343
1370
  style: _this.props.style('suggestions'),
1344
1371
  position: position,
1345
1372
  left: left,
1346
1373
  top: top,
1374
+ right: right,
1347
1375
  focusIndex: _this.state.focusIndex,
1348
1376
  scrollFocusedIntoView: _this.state.scrollFocusedIntoView,
1349
1377
  containerRef: _this.setSuggestionsElement,
1350
1378
  suggestions: _this.state.suggestions,
1379
+ customSuggestionsContainer: _this.props.customSuggestionsContainer,
1351
1380
  onSelect: _this.addMention,
1352
1381
  onMouseDown: _this.handleSuggestionsMouseDown,
1353
1382
  onMouseEnter: _this.handleSuggestionsMouseEnter,
@@ -1358,7 +1387,7 @@ function (_React$Component) {
1358
1387
  }, _this.props.children);
1359
1388
 
1360
1389
  if (_this.props.suggestionsPortalHost) {
1361
- return ReactDOM.createPortal(suggestionsNode, _this.props.suggestionsPortalHost);
1390
+ return /*#__PURE__*/ReactDOM.createPortal(suggestionsNode, _this.props.suggestionsPortalHost);
1362
1391
  } else {
1363
1392
  return suggestionsNode;
1364
1393
  }
@@ -1373,7 +1402,7 @@ function (_React$Component) {
1373
1402
  children = _this$props3.children,
1374
1403
  value = _this$props3.value,
1375
1404
  style = _this$props3.style;
1376
- return React.createElement(Highlighter$1, {
1405
+ return /*#__PURE__*/React.createElement(Highlighter$1, {
1377
1406
  containerRef: _this.setHighlighterElement,
1378
1407
  style: style('highlighter'),
1379
1408
  value: value,
@@ -1417,13 +1446,16 @@ function (_React$Component) {
1417
1446
  });
1418
1447
 
1419
1448
  _defineProperty(_assertThisInitialized(_this), "handleChange", function (ev) {
1420
- isComposing = false; // if we are inside iframe, we need to find activeElement within its contentDocument
1449
+ isComposing = false;
1421
1450
 
1422
- var currentDocument = document.activeElement && document.activeElement.contentDocument || document;
1451
+ if (isIE()) {
1452
+ // if we are inside iframe, we need to find activeElement within its contentDocument
1453
+ var currentDocument = document.activeElement && document.activeElement.contentDocument || document;
1423
1454
 
1424
- if (currentDocument.activeElement !== ev.target) {
1425
- // fix an IE bug (blur from empty input element with placeholder attribute trigger "input" event)
1426
- return;
1455
+ if (currentDocument.activeElement !== ev.target) {
1456
+ // fix an IE bug (blur from empty input element with placeholder attribute trigger "input" event)
1457
+ return;
1458
+ }
1427
1459
  }
1428
1460
 
1429
1461
  var value = _this.props.value || '';
@@ -1447,7 +1479,7 @@ function (_React$Component) {
1447
1479
 
1448
1480
  if (startOfMention !== undefined && _this.state.selectionEnd > startOfMention) {
1449
1481
  // only if a deletion has taken place
1450
- selectionStart = startOfMention;
1482
+ selectionStart = startOfMention + (ev.nativeEvent.data ? ev.nativeEvent.data.length : 0);
1451
1483
  selectionEnd = selectionStart;
1452
1484
  setSelectionAfterMentionChange = true;
1453
1485
  }
@@ -1807,7 +1839,7 @@ function (_React$Component) {
1807
1839
  if (queryId !== _this._queryId) return; // save in property so that multiple sync state updates from different mentions sources
1808
1840
  // won't overwrite each other
1809
1841
 
1810
- _this.suggestions = _objectSpread({}, _this.suggestions, _defineProperty({}, childIndex, {
1842
+ _this.suggestions = _objectSpread(_objectSpread({}, _this.suggestions), {}, _defineProperty({}, childIndex, {
1811
1843
  queryInfo: {
1812
1844
  childIndex: childIndex,
1813
1845
  query: query,
@@ -1953,7 +1985,7 @@ function (_React$Component) {
1953
1985
  }, {
1954
1986
  key: "render",
1955
1987
  value: function render() {
1956
- return React.createElement("div", _extends({
1988
+ return /*#__PURE__*/React.createElement("div", _extends({
1957
1989
  ref: this.setContainerElement
1958
1990
  }, this.props.style), this.renderControl(), this.renderSuggestionsOverlay());
1959
1991
  }
@@ -1983,18 +2015,23 @@ function (_React$Component) {
1983
2015
  var newValue = spliceString(value, markupStartIndex, markupEndIndex, pastedMentions || pastedData).replace(/\r/g, '');
1984
2016
  var newPlainTextValue = getPlainText(newValue, config);
1985
2017
  var eventMock = {
1986
- target: _objectSpread({}, event.target, {
2018
+ target: _objectSpread(_objectSpread({}, event.target), {}, {
1987
2019
  value: newValue
1988
2020
  })
1989
2021
  };
1990
- this.executeOnChange(eventMock, newValue, newPlainTextValue, getMentions(newValue, config));
2022
+ this.executeOnChange(eventMock, newValue, newPlainTextValue, getMentions(newValue, config)); // Move the cursor position to the end of the pasted data
2023
+
2024
+ var startOfMention = findStartOfMentionInPlainText(value, config, selectionStart);
2025
+ var nextPos = (startOfMention || selectionStart) + getPlainText(pastedMentions || pastedData, config).length;
2026
+ this.setSelection(nextPos, nextPos);
1991
2027
  }
1992
2028
  }, {
1993
2029
  key: "saveSelectionToClipboard",
1994
2030
  value: function saveSelectionToClipboard(event) {
1995
- var _this$state4 = this.state,
1996
- selectionStart = _this$state4.selectionStart,
1997
- selectionEnd = _this$state4.selectionEnd;
2031
+ // use the actual selectionStart & selectionEnd instead of the one stored
2032
+ // in state to ensure copy & paste also works on disabled inputs & textareas
2033
+ var selectionStart = this.inputElement.selectionStart;
2034
+ var selectionEnd = this.inputElement.selectionEnd;
1998
2035
  var _this$props8 = this.props,
1999
2036
  children = _this$props8.children,
2000
2037
  value = _this$props8.value;
@@ -2036,9 +2073,9 @@ function (_React$Component) {
2036
2073
 
2037
2074
  event.preventDefault();
2038
2075
  this.saveSelectionToClipboard(event);
2039
- var _this$state5 = this.state,
2040
- selectionStart = _this$state5.selectionStart,
2041
- selectionEnd = _this$state5.selectionEnd;
2076
+ var _this$state4 = this.state,
2077
+ selectionStart = _this$state4.selectionStart,
2078
+ selectionEnd = _this$state4.selectionEnd;
2042
2079
  var _this$props9 = this.props,
2043
2080
  children = _this$props9.children,
2044
2081
  value = _this$props9.value;
@@ -2048,7 +2085,7 @@ function (_React$Component) {
2048
2085
  var newValue = [value.slice(0, markupStartIndex), value.slice(markupEndIndex)].join('');
2049
2086
  var newPlainTextValue = getPlainText(newValue, config);
2050
2087
  var eventMock = {
2051
- target: _objectSpread({}, event.target, {
2088
+ target: _objectSpread(_objectSpread({}, event.target), {}, {
2052
2089
  value: newPlainTextValue
2053
2090
  })
2054
2091
  };
@@ -2138,7 +2175,7 @@ var Mention = function Mention(_ref) {
2138
2175
  className: className,
2139
2176
  classNames: classNames
2140
2177
  });
2141
- return React.createElement("strong", styles, display);
2178
+ return /*#__PURE__*/React.createElement("strong", styles, display);
2142
2179
  };
2143
2180
 
2144
2181
  Mention.propTypes = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-mentions",
3
- "version": "4.3.0",
3
+ "version": "4.4.0",
4
4
  "description": "React mentions input",
5
5
  "main": "dist/react-mentions.cjs.js",
6
6
  "module": "dist/react-mentions.esm.js",
@@ -11,7 +11,7 @@
11
11
  "build": "preconstruct build",
12
12
  "format": "prettier --write --no-semi --single-quote --trailing-comma es5 \"{src,test,demo/src}/**/*.js\"",
13
13
  "lint": "eslint --max-warnings=0 --ext .js src test demo",
14
- "start": "cross-env NODE_ENV=development webpack-dev-server --config demo/webpack.config.js",
14
+ "start": "cross-env NODE_OPTIONS=--openssl-legacy-provider NODE_ENV=development webpack-dev-server --config demo/webpack.config.js",
15
15
  "semantic-release": "semantic-release",
16
16
  "test": "jest",
17
17
  "now-build": "webpack --config demo/webpack.config.js"
@@ -50,7 +50,7 @@
50
50
  "babel-eslint": "^7.2.3",
51
51
  "babel-loader": "^8.0.6",
52
52
  "case-sensitive-paths-webpack-plugin": "^2.2.0",
53
- "condition-circle": "^2.0.1",
53
+ "condition-circle": "^2.0.2",
54
54
  "core-js": "^3.1.4",
55
55
  "cross-env": "^5.2.1",
56
56
  "css-loader": "^3.0.0",
@@ -74,7 +74,7 @@
74
74
  "react-dom": "16.8.6",
75
75
  "recompose": "^0.30.0",
76
76
  "regenerator-runtime": "^0.13.2",
77
- "semantic-release": "^12.4.1",
77
+ "semantic-release": "^19.0.2",
78
78
  "style-loader": "^0.23.1",
79
79
  "substyle-jss": "^4.0.1",
80
80
  "webpack": "^4.35.2",
@@ -90,8 +90,5 @@
90
90
  "peerDependencies": {
91
91
  "react": ">=16.8.3",
92
92
  "react-dom": ">=16.8.3"
93
- },
94
- "release": {
95
- "verifyConditions": "condition-circle"
96
93
  }
97
94
  }