react-mentions 4.4.2 → 4.4.6
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +25 -0
- package/README.md +7 -19
- package/dist/react-mentions.cjs.dev.js +132 -124
- package/dist/react-mentions.cjs.prod.js +138 -67
- package/dist/react-mentions.esm.js +132 -124
- package/package.json +7 -6
@@ -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';
|
@@ -651,13 +651,15 @@ var omit = function omit(obj) {
|
|
651
651
|
}, {});
|
652
652
|
};
|
653
653
|
|
654
|
+
var _excluded = ["style", "className", "classNames"];
|
655
|
+
|
654
656
|
function createDefaultStyle(defaultStyle, getModifiers) {
|
655
657
|
var enhance = function enhance(ComponentToWrap) {
|
656
658
|
var DefaultStyleEnhancer = function DefaultStyleEnhancer(_ref) {
|
657
659
|
var style = _ref.style,
|
658
660
|
className = _ref.className,
|
659
661
|
classNames = _ref.classNames,
|
660
|
-
rest = _objectWithoutProperties(_ref,
|
662
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
661
663
|
|
662
664
|
var modifiers = getModifiers ? getModifiers(rest) : undefined;
|
663
665
|
var styles = useStyles(defaultStyle, {
|
@@ -665,7 +667,7 @@ function createDefaultStyle(defaultStyle, getModifiers) {
|
|
665
667
|
className: className,
|
666
668
|
classNames: classNames
|
667
669
|
}, modifiers);
|
668
|
-
return React.createElement(ComponentToWrap, _extends({}, rest, {
|
670
|
+
return /*#__PURE__*/React.createElement(ComponentToWrap, _extends({}, rest, {
|
669
671
|
style: styles
|
670
672
|
}));
|
671
673
|
};
|
@@ -678,6 +680,10 @@ function createDefaultStyle(defaultStyle, getModifiers) {
|
|
678
680
|
return enhance;
|
679
681
|
}
|
680
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
|
+
|
681
687
|
var _generateComponentKey = function _generateComponentKey(usedKeys, id) {
|
682
688
|
if (!usedKeys.hasOwnProperty(id)) {
|
683
689
|
usedKeys[id] = 0;
|
@@ -688,17 +694,17 @@ var _generateComponentKey = function _generateComponentKey(usedKeys, id) {
|
|
688
694
|
return id + '_' + usedKeys[id];
|
689
695
|
};
|
690
696
|
|
691
|
-
var Highlighter =
|
692
|
-
/*#__PURE__*/
|
693
|
-
function (_Component) {
|
697
|
+
var Highlighter = /*#__PURE__*/function (_Component) {
|
694
698
|
_inherits(Highlighter, _Component);
|
695
699
|
|
700
|
+
var _super = _createSuper(Highlighter);
|
701
|
+
|
696
702
|
function Highlighter() {
|
697
703
|
var _this;
|
698
704
|
|
699
705
|
_classCallCheck(this, Highlighter);
|
700
706
|
|
701
|
-
_this =
|
707
|
+
_this = _super.apply(this, arguments);
|
702
708
|
|
703
709
|
_defineProperty(_assertThisInitialized(_this), "setCaretElement", function (el) {
|
704
710
|
_this.caretElement = el;
|
@@ -801,7 +807,7 @@ function (_Component) {
|
|
801
807
|
resultComponents.push(this.renderHighlighterCaret(components));
|
802
808
|
}
|
803
809
|
|
804
|
-
return React.createElement("div", _extends({}, style, {
|
810
|
+
return /*#__PURE__*/React.createElement("div", _extends({}, style, {
|
805
811
|
ref: containerRef
|
806
812
|
}), resultComponents);
|
807
813
|
}
|
@@ -809,7 +815,7 @@ function (_Component) {
|
|
809
815
|
key: "renderSubstring",
|
810
816
|
value: function renderSubstring(string, key) {
|
811
817
|
// set substring span to hidden, so that Emojis are not shown double in Mobile Safari
|
812
|
-
return React.createElement("span", _extends({}, this.props.style('substring'), {
|
818
|
+
return /*#__PURE__*/React.createElement("span", _extends({}, this.props.style('substring'), {
|
813
819
|
key: key
|
814
820
|
}), string);
|
815
821
|
} // Returns a clone of the Mention child applicable for the specified type to be rendered inside the highlighter
|
@@ -823,13 +829,13 @@ function (_Component) {
|
|
823
829
|
key: key
|
824
830
|
};
|
825
831
|
var child = Children.toArray(this.props.children)[mentionChildIndex];
|
826
|
-
return React.cloneElement(child, props);
|
832
|
+
return /*#__PURE__*/React.cloneElement(child, props);
|
827
833
|
} // Renders an component to be inserted in the highlighter at the current caret position
|
828
834
|
|
829
835
|
}, {
|
830
836
|
key: "renderHighlighterCaret",
|
831
837
|
value: function renderHighlighterCaret(children) {
|
832
|
-
return React.createElement("span", _extends({}, this.props.style('caret'), {
|
838
|
+
return /*#__PURE__*/React.createElement("span", _extends({}, this.props.style('caret'), {
|
833
839
|
ref: this.setCaretElement,
|
834
840
|
key: "caret"
|
835
841
|
}), children);
|
@@ -878,85 +884,68 @@ var styled = createDefaultStyle({
|
|
878
884
|
});
|
879
885
|
var Highlighter$1 = styled(Highlighter);
|
880
886
|
|
881
|
-
|
882
|
-
|
883
|
-
|
884
|
-
|
885
|
-
|
886
|
-
|
887
|
-
|
887
|
+
function Suggestion(_ref) {
|
888
|
+
var id = _ref.id,
|
889
|
+
focused = _ref.focused,
|
890
|
+
ignoreAccents = _ref.ignoreAccents,
|
891
|
+
index = _ref.index,
|
892
|
+
onClick = _ref.onClick,
|
893
|
+
onMouseEnter = _ref.onMouseEnter,
|
894
|
+
query = _ref.query,
|
895
|
+
renderSuggestion = _ref.renderSuggestion,
|
896
|
+
suggestion = _ref.suggestion,
|
897
|
+
style = _ref.style,
|
898
|
+
className = _ref.className,
|
899
|
+
classNames = _ref.classNames;
|
900
|
+
var rest = {
|
901
|
+
onClick: onClick,
|
902
|
+
onMouseEnter: onMouseEnter
|
903
|
+
};
|
888
904
|
|
889
|
-
|
890
|
-
|
905
|
+
var renderContent = function renderContent() {
|
906
|
+
var display = getDisplay();
|
907
|
+
var highlightedDisplay = renderHighlightedDisplay(display);
|
891
908
|
|
892
|
-
|
893
|
-
|
894
|
-
value: function render() {
|
895
|
-
var rest = omit(this.props, ['style', 'classNames', 'className'], // substyle props
|
896
|
-
keys(Suggestion.propTypes));
|
897
|
-
return React.createElement("li", _extends({
|
898
|
-
id: this.props.id,
|
899
|
-
role: "option",
|
900
|
-
"aria-selected": this.props.focused
|
901
|
-
}, rest, this.props.style), this.renderContent());
|
909
|
+
if (renderSuggestion) {
|
910
|
+
return renderSuggestion(suggestion, query, highlightedDisplay, index, focused);
|
902
911
|
}
|
903
|
-
}, {
|
904
|
-
key: "renderContent",
|
905
|
-
value: function renderContent() {
|
906
|
-
var _this$props = this.props,
|
907
|
-
query = _this$props.query,
|
908
|
-
renderSuggestion = _this$props.renderSuggestion,
|
909
|
-
suggestion = _this$props.suggestion,
|
910
|
-
index = _this$props.index,
|
911
|
-
focused = _this$props.focused;
|
912
|
-
var display = this.getDisplay();
|
913
|
-
var highlightedDisplay = this.renderHighlightedDisplay(display, query);
|
914
|
-
|
915
|
-
if (renderSuggestion) {
|
916
|
-
return renderSuggestion(suggestion, query, highlightedDisplay, index, focused);
|
917
|
-
}
|
918
|
-
|
919
|
-
return highlightedDisplay;
|
920
|
-
}
|
921
|
-
}, {
|
922
|
-
key: "getDisplay",
|
923
|
-
value: function getDisplay() {
|
924
|
-
var suggestion = this.props.suggestion;
|
925
912
|
|
926
|
-
|
927
|
-
|
928
|
-
}
|
913
|
+
return highlightedDisplay;
|
914
|
+
};
|
929
915
|
|
930
|
-
|
931
|
-
|
916
|
+
var getDisplay = function getDisplay() {
|
917
|
+
if (typeof suggestion === 'string') {
|
918
|
+
return suggestion;
|
919
|
+
}
|
932
920
|
|
933
|
-
|
934
|
-
|
935
|
-
}
|
921
|
+
var id = suggestion.id,
|
922
|
+
display = suggestion.display;
|
936
923
|
|
937
|
-
|
924
|
+
if (id === undefined || !display) {
|
925
|
+
return id;
|
938
926
|
}
|
939
|
-
}, {
|
940
|
-
key: "renderHighlightedDisplay",
|
941
|
-
value: function renderHighlightedDisplay(display) {
|
942
|
-
var _this$props2 = this.props,
|
943
|
-
ignoreAccents = _this$props2.ignoreAccents,
|
944
|
-
query = _this$props2.query,
|
945
|
-
style = _this$props2.style;
|
946
|
-
var i = getSubstringIndex(display, query, ignoreAccents);
|
947
927
|
|
948
|
-
|
949
|
-
|
950
|
-
|
928
|
+
return display;
|
929
|
+
};
|
930
|
+
|
931
|
+
var renderHighlightedDisplay = function renderHighlightedDisplay(display) {
|
932
|
+
var i = getSubstringIndex(display, query, ignoreAccents);
|
951
933
|
|
952
|
-
|
934
|
+
if (i === -1) {
|
935
|
+
return /*#__PURE__*/React.createElement("span", style('display'), display);
|
953
936
|
}
|
954
|
-
}]);
|
955
937
|
|
956
|
-
|
957
|
-
}
|
938
|
+
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));
|
939
|
+
};
|
940
|
+
|
941
|
+
return /*#__PURE__*/React.createElement("li", _extends({
|
942
|
+
id: id,
|
943
|
+
role: "option",
|
944
|
+
"aria-selected": focused
|
945
|
+
}, rest, style), renderContent());
|
946
|
+
}
|
958
947
|
|
959
|
-
|
948
|
+
Suggestion.propTypes = {
|
960
949
|
id: PropTypes.string.isRequired,
|
961
950
|
query: PropTypes.string.isRequired,
|
962
951
|
index: PropTypes.number.isRequired,
|
@@ -967,8 +956,7 @@ _defineProperty(Suggestion, "propTypes", {
|
|
967
956
|
})]).isRequired,
|
968
957
|
renderSuggestion: PropTypes.func,
|
969
958
|
focused: PropTypes.bool
|
970
|
-
}
|
971
|
-
|
959
|
+
};
|
972
960
|
var styled$1 = createDefaultStyle({
|
973
961
|
cursor: 'pointer'
|
974
962
|
}, function (props) {
|
@@ -978,20 +966,31 @@ var styled$1 = createDefaultStyle({
|
|
978
966
|
});
|
979
967
|
var Suggestion$1 = styled$1(Suggestion);
|
980
968
|
|
981
|
-
function LoadingIndicator() {
|
982
|
-
var
|
969
|
+
function LoadingIndicator(_ref) {
|
970
|
+
var style = _ref.style,
|
971
|
+
className = _ref.className,
|
972
|
+
classNames = _ref.classNames;
|
973
|
+
var styles = useStyles(defaultstyle, {
|
974
|
+
style: style,
|
975
|
+
className: className,
|
976
|
+
classNames: classNames
|
977
|
+
});
|
983
978
|
var spinnerStyles = styles('spinner');
|
984
|
-
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']))));
|
979
|
+
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']))));
|
985
980
|
}
|
986
981
|
|
987
|
-
var
|
988
|
-
|
989
|
-
function (
|
982
|
+
var defaultstyle = {};
|
983
|
+
|
984
|
+
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); }; }
|
985
|
+
|
986
|
+
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; } }
|
987
|
+
|
988
|
+
var SuggestionsOverlay = /*#__PURE__*/function (_Component) {
|
990
989
|
_inherits(SuggestionsOverlay, _Component);
|
991
990
|
|
992
|
-
|
993
|
-
var _getPrototypeOf2;
|
991
|
+
var _super = _createSuper$1(SuggestionsOverlay);
|
994
992
|
|
993
|
+
function SuggestionsOverlay() {
|
995
994
|
var _this;
|
996
995
|
|
997
996
|
_classCallCheck(this, SuggestionsOverlay);
|
@@ -1000,7 +999,7 @@ function (_Component) {
|
|
1000
999
|
args[_key] = arguments[_key];
|
1001
1000
|
}
|
1002
1001
|
|
1003
|
-
_this =
|
1002
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
1004
1003
|
|
1005
1004
|
_defineProperty(_assertThisInitialized(_this), "handleMouseEnter", function (index, ev) {
|
1006
1005
|
if (_this.props.onMouseEnter) {
|
@@ -1063,7 +1062,7 @@ function (_Component) {
|
|
1063
1062
|
return null;
|
1064
1063
|
}
|
1065
1064
|
|
1066
|
-
return React.createElement("div", _extends({}, inline({
|
1065
|
+
return /*#__PURE__*/React.createElement("div", _extends({}, inline({
|
1067
1066
|
position: position || 'absolute',
|
1068
1067
|
left: left,
|
1069
1068
|
right: right,
|
@@ -1071,7 +1070,7 @@ function (_Component) {
|
|
1071
1070
|
}, style), {
|
1072
1071
|
onMouseDown: onMouseDown,
|
1073
1072
|
ref: containerRef
|
1074
|
-
}), React.createElement("ul", _extends({
|
1073
|
+
}), /*#__PURE__*/React.createElement("ul", _extends({
|
1075
1074
|
ref: this.setUlElement,
|
1076
1075
|
id: id,
|
1077
1076
|
role: "listbox",
|
@@ -1083,13 +1082,15 @@ function (_Component) {
|
|
1083
1082
|
value: function renderSuggestions() {
|
1084
1083
|
var _this2 = this;
|
1085
1084
|
|
1086
|
-
|
1085
|
+
var customSuggestionsContainer = this.props.customSuggestionsContainer;
|
1086
|
+
var suggestions = Object.values(this.props.suggestions).reduce(function (accResults, _ref) {
|
1087
1087
|
var results = _ref.results,
|
1088
1088
|
queryInfo = _ref.queryInfo;
|
1089
1089
|
return [].concat(_toConsumableArray(accResults), _toConsumableArray(results.map(function (result, index) {
|
1090
1090
|
return _this2.renderSuggestion(result, queryInfo, accResults.length + index);
|
1091
1091
|
})));
|
1092
1092
|
}, []);
|
1093
|
+
if (customSuggestionsContainer) return customSuggestionsContainer(suggestions);else return suggestions;
|
1093
1094
|
}
|
1094
1095
|
}, {
|
1095
1096
|
key: "renderSuggestion",
|
@@ -1101,7 +1102,7 @@ function (_Component) {
|
|
1101
1102
|
query = queryInfo.query;
|
1102
1103
|
var renderSuggestion = Children.toArray(this.props.children)[childIndex].props.renderSuggestion;
|
1103
1104
|
var ignoreAccents = this.props.ignoreAccents;
|
1104
|
-
return React.createElement(Suggestion$1, {
|
1105
|
+
return /*#__PURE__*/React.createElement(Suggestion$1, {
|
1105
1106
|
style: this.props.style('item'),
|
1106
1107
|
key: "".concat(childIndex, "-").concat(getID(result)),
|
1107
1108
|
id: getSuggestionHtmlId(this.props.id, index),
|
@@ -1126,7 +1127,7 @@ function (_Component) {
|
|
1126
1127
|
return;
|
1127
1128
|
}
|
1128
1129
|
|
1129
|
-
return React.createElement(LoadingIndicator, {
|
1130
|
+
return /*#__PURE__*/React.createElement(LoadingIndicator, {
|
1130
1131
|
style: this.props.style('loadingIndicator')
|
1131
1132
|
});
|
1132
1133
|
}
|
@@ -1183,9 +1184,13 @@ var styled$2 = createDefaultStyle({
|
|
1183
1184
|
});
|
1184
1185
|
var SuggestionsOverlay$1 = styled$2(SuggestionsOverlay);
|
1185
1186
|
|
1186
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
1187
|
+
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; }
|
1187
1188
|
|
1188
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
1189
|
+
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; }
|
1190
|
+
|
1191
|
+
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); }; }
|
1192
|
+
|
1193
|
+
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; } }
|
1189
1194
|
var makeTriggerRegex = function makeTriggerRegex(trigger) {
|
1190
1195
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
1191
1196
|
|
@@ -1243,6 +1248,7 @@ var propTypes = {
|
|
1243
1248
|
a11ySuggestionsListLabel: PropTypes.string,
|
1244
1249
|
value: PropTypes.string,
|
1245
1250
|
onKeyDown: PropTypes.func,
|
1251
|
+
customSuggestionsContainer: PropTypes.func,
|
1246
1252
|
onSelect: PropTypes.func,
|
1247
1253
|
onBlur: PropTypes.func,
|
1248
1254
|
onChange: PropTypes.func,
|
@@ -1253,17 +1259,17 @@ var propTypes = {
|
|
1253
1259
|
children: PropTypes.oneOfType([PropTypes.element, PropTypes.arrayOf(PropTypes.element)]).isRequired
|
1254
1260
|
};
|
1255
1261
|
|
1256
|
-
var MentionsInput =
|
1257
|
-
/*#__PURE__*/
|
1258
|
-
function (_React$Component) {
|
1262
|
+
var MentionsInput = /*#__PURE__*/function (_React$Component) {
|
1259
1263
|
_inherits(MentionsInput, _React$Component);
|
1260
1264
|
|
1265
|
+
var _super = _createSuper$2(MentionsInput);
|
1266
|
+
|
1261
1267
|
function MentionsInput(_props) {
|
1262
1268
|
var _this;
|
1263
1269
|
|
1264
1270
|
_classCallCheck(this, MentionsInput);
|
1265
1271
|
|
1266
|
-
_this =
|
1272
|
+
_this = _super.call(this, _props);
|
1267
1273
|
|
1268
1274
|
_defineProperty(_assertThisInitialized(_this), "setContainerElement", function (el) {
|
1269
1275
|
_this.containerElement = el;
|
@@ -1277,17 +1283,17 @@ function (_React$Component) {
|
|
1277
1283
|
|
1278
1284
|
var props = omit(_this.props, ['style', 'classNames', 'className'], // substyle props
|
1279
1285
|
keys(propTypes));
|
1280
|
-
return _objectSpread({}, props,
|
1281
|
-
value: _this.getPlainText()
|
1286
|
+
return _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, props), style('input')), {}, {
|
1287
|
+
value: _this.getPlainText(),
|
1288
|
+
onScroll: _this.updateHighlighterScroll
|
1282
1289
|
}, !readOnly && !disabled && {
|
1283
1290
|
onChange: _this.handleChange,
|
1284
1291
|
onSelect: _this.handleSelect,
|
1285
1292
|
onKeyDown: _this.handleKeyDown,
|
1286
1293
|
onBlur: _this.handleBlur,
|
1287
1294
|
onCompositionStart: _this.handleCompositionStart,
|
1288
|
-
onCompositionEnd: _this.handleCompositionEnd
|
1289
|
-
|
1290
|
-
}, {}, _this.isOpened() && {
|
1295
|
+
onCompositionEnd: _this.handleCompositionEnd
|
1296
|
+
}), _this.isOpened() && {
|
1291
1297
|
role: 'combobox',
|
1292
1298
|
'aria-controls': _this.uuidSuggestionsOverlay,
|
1293
1299
|
'aria-expanded': true,
|
@@ -1304,18 +1310,18 @@ function (_React$Component) {
|
|
1304
1310
|
|
1305
1311
|
var inputProps = _this.getInputProps();
|
1306
1312
|
|
1307
|
-
return React.createElement("div", style('control'), _this.renderHighlighter(), singleLine ? _this.renderInput(inputProps) : _this.renderTextarea(inputProps));
|
1313
|
+
return /*#__PURE__*/React.createElement("div", style('control'), _this.renderHighlighter(), singleLine ? _this.renderInput(inputProps) : _this.renderTextarea(inputProps));
|
1308
1314
|
});
|
1309
1315
|
|
1310
1316
|
_defineProperty(_assertThisInitialized(_this), "renderInput", function (props) {
|
1311
|
-
return React.createElement("input", _extends({
|
1317
|
+
return /*#__PURE__*/React.createElement("input", _extends({
|
1312
1318
|
type: "text",
|
1313
1319
|
ref: _this.setInputRef
|
1314
1320
|
}, props));
|
1315
1321
|
});
|
1316
1322
|
|
1317
1323
|
_defineProperty(_assertThisInitialized(_this), "renderTextarea", function (props) {
|
1318
|
-
return React.createElement("textarea", _extends({
|
1324
|
+
return /*#__PURE__*/React.createElement("textarea", _extends({
|
1319
1325
|
ref: _this.setInputRef
|
1320
1326
|
}, props));
|
1321
1327
|
});
|
@@ -1346,7 +1352,7 @@ function (_React$Component) {
|
|
1346
1352
|
left = _this$state$suggestio.left,
|
1347
1353
|
top = _this$state$suggestio.top,
|
1348
1354
|
right = _this$state$suggestio.right;
|
1349
|
-
var suggestionsNode = React.createElement(SuggestionsOverlay$1, {
|
1355
|
+
var suggestionsNode = /*#__PURE__*/React.createElement(SuggestionsOverlay$1, {
|
1350
1356
|
id: _this.uuidSuggestionsOverlay,
|
1351
1357
|
style: _this.props.style('suggestions'),
|
1352
1358
|
position: position,
|
@@ -1357,6 +1363,7 @@ function (_React$Component) {
|
|
1357
1363
|
scrollFocusedIntoView: _this.state.scrollFocusedIntoView,
|
1358
1364
|
containerRef: _this.setSuggestionsElement,
|
1359
1365
|
suggestions: _this.state.suggestions,
|
1366
|
+
customSuggestionsContainer: _this.props.customSuggestionsContainer,
|
1360
1367
|
onSelect: _this.addMention,
|
1361
1368
|
onMouseDown: _this.handleSuggestionsMouseDown,
|
1362
1369
|
onMouseEnter: _this.handleSuggestionsMouseEnter,
|
@@ -1367,7 +1374,7 @@ function (_React$Component) {
|
|
1367
1374
|
}, _this.props.children);
|
1368
1375
|
|
1369
1376
|
if (_this.props.suggestionsPortalHost) {
|
1370
|
-
return ReactDOM.createPortal(suggestionsNode, _this.props.suggestionsPortalHost);
|
1377
|
+
return /*#__PURE__*/ReactDOM.createPortal(suggestionsNode, _this.props.suggestionsPortalHost);
|
1371
1378
|
} else {
|
1372
1379
|
return suggestionsNode;
|
1373
1380
|
}
|
@@ -1382,7 +1389,7 @@ function (_React$Component) {
|
|
1382
1389
|
children = _this$props3.children,
|
1383
1390
|
value = _this$props3.value,
|
1384
1391
|
style = _this$props3.style;
|
1385
|
-
return React.createElement(Highlighter$1, {
|
1392
|
+
return /*#__PURE__*/React.createElement(Highlighter$1, {
|
1386
1393
|
containerRef: _this.setHighlighterElement,
|
1387
1394
|
style: style('highlighter'),
|
1388
1395
|
value: value,
|
@@ -1459,7 +1466,7 @@ function (_React$Component) {
|
|
1459
1466
|
|
1460
1467
|
if (startOfMention !== undefined && _this.state.selectionEnd > startOfMention) {
|
1461
1468
|
// only if a deletion has taken place
|
1462
|
-
selectionStart = startOfMention;
|
1469
|
+
selectionStart = startOfMention + (ev.nativeEvent.data ? ev.nativeEvent.data.length : 0);
|
1463
1470
|
selectionEnd = selectionStart;
|
1464
1471
|
setSelectionAfterMentionChange = true;
|
1465
1472
|
}
|
@@ -1697,7 +1704,7 @@ function (_React$Component) {
|
|
1697
1704
|
// is small enough to NOT cover up the caret
|
1698
1705
|
|
1699
1706
|
|
1700
|
-
if (allowSuggestionsAboveCursor && viewportRelative.top - highlighter.scrollTop + suggestions.offsetHeight > viewportHeight && suggestions.offsetHeight < caretOffsetParentRect.top - caretHeight - highlighter.scrollTop) {
|
1707
|
+
if (allowSuggestionsAboveCursor && viewportRelative.top - highlighter.scrollTop + suggestions.offsetHeight > viewportHeight && suggestions.offsetHeight < caretOffsetParentRect.top - caretHeight - highlighter.scrollTop || forceSuggestionsAboveCursor) {
|
1701
1708
|
position.top = _top - suggestions.offsetHeight - caretHeight;
|
1702
1709
|
} else {
|
1703
1710
|
position.top = _top;
|
@@ -1819,7 +1826,7 @@ function (_React$Component) {
|
|
1819
1826
|
if (queryId !== _this._queryId) return; // save in property so that multiple sync state updates from different mentions sources
|
1820
1827
|
// won't overwrite each other
|
1821
1828
|
|
1822
|
-
_this.suggestions = _objectSpread({}, _this.suggestions, _defineProperty({}, childIndex, {
|
1829
|
+
_this.suggestions = _objectSpread(_objectSpread({}, _this.suggestions), {}, _defineProperty({}, childIndex, {
|
1823
1830
|
queryInfo: {
|
1824
1831
|
childIndex: childIndex,
|
1825
1832
|
query: query,
|
@@ -1965,7 +1972,7 @@ function (_React$Component) {
|
|
1965
1972
|
}, {
|
1966
1973
|
key: "render",
|
1967
1974
|
value: function render() {
|
1968
|
-
return React.createElement("div", _extends({
|
1975
|
+
return /*#__PURE__*/React.createElement("div", _extends({
|
1969
1976
|
ref: this.setContainerElement
|
1970
1977
|
}, this.props.style), this.renderControl(), this.renderSuggestionsOverlay());
|
1971
1978
|
}
|
@@ -1995,7 +2002,7 @@ function (_React$Component) {
|
|
1995
2002
|
var newValue = spliceString(value, markupStartIndex, markupEndIndex, pastedMentions || pastedData).replace(/\r/g, '');
|
1996
2003
|
var newPlainTextValue = getPlainText(newValue, config);
|
1997
2004
|
var eventMock = {
|
1998
|
-
target: _objectSpread({}, event.target, {
|
2005
|
+
target: _objectSpread(_objectSpread({}, event.target), {}, {
|
1999
2006
|
value: newValue
|
2000
2007
|
})
|
2001
2008
|
};
|
@@ -2008,9 +2015,10 @@ function (_React$Component) {
|
|
2008
2015
|
}, {
|
2009
2016
|
key: "saveSelectionToClipboard",
|
2010
2017
|
value: function saveSelectionToClipboard(event) {
|
2011
|
-
|
2012
|
-
|
2013
|
-
|
2018
|
+
// use the actual selectionStart & selectionEnd instead of the one stored
|
2019
|
+
// in state to ensure copy & paste also works on disabled inputs & textareas
|
2020
|
+
var selectionStart = this.inputElement.selectionStart;
|
2021
|
+
var selectionEnd = this.inputElement.selectionEnd;
|
2014
2022
|
var _this$props8 = this.props,
|
2015
2023
|
children = _this$props8.children,
|
2016
2024
|
value = _this$props8.value;
|
@@ -2052,9 +2060,9 @@ function (_React$Component) {
|
|
2052
2060
|
|
2053
2061
|
event.preventDefault();
|
2054
2062
|
this.saveSelectionToClipboard(event);
|
2055
|
-
var _this$
|
2056
|
-
selectionStart = _this$
|
2057
|
-
selectionEnd = _this$
|
2063
|
+
var _this$state4 = this.state,
|
2064
|
+
selectionStart = _this$state4.selectionStart,
|
2065
|
+
selectionEnd = _this$state4.selectionEnd;
|
2058
2066
|
var _this$props9 = this.props,
|
2059
2067
|
children = _this$props9.children,
|
2060
2068
|
value = _this$props9.value;
|
@@ -2064,7 +2072,7 @@ function (_React$Component) {
|
|
2064
2072
|
var newValue = [value.slice(0, markupStartIndex), value.slice(markupEndIndex)].join('');
|
2065
2073
|
var newPlainTextValue = getPlainText(newValue, config);
|
2066
2074
|
var eventMock = {
|
2067
|
-
target: _objectSpread({}, event.target, {
|
2075
|
+
target: _objectSpread(_objectSpread({}, event.target), {}, {
|
2068
2076
|
value: newPlainTextValue
|
2069
2077
|
})
|
2070
2078
|
};
|
@@ -2154,7 +2162,7 @@ var Mention = function Mention(_ref) {
|
|
2154
2162
|
className: className,
|
2155
2163
|
classNames: classNames
|
2156
2164
|
});
|
2157
|
-
return React.createElement("strong", styles, display);
|
2165
|
+
return /*#__PURE__*/React.createElement("strong", styles, display);
|
2158
2166
|
};
|
2159
2167
|
|
2160
2168
|
Mention.propTypes = {
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "react-mentions",
|
3
|
-
"version": "4.4.
|
3
|
+
"version": "4.4.6",
|
4
4
|
"description": "React mentions input",
|
5
5
|
"main": "dist/react-mentions.cjs.js",
|
6
6
|
"module": "dist/react-mentions.esm.js",
|
@@ -12,9 +12,11 @@
|
|
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
14
|
"start": "cross-env NODE_OPTIONS=--openssl-legacy-provider NODE_ENV=development webpack-dev-server --config demo/webpack.config.js",
|
15
|
-
"semantic-release": "semantic-release",
|
16
15
|
"test": "jest",
|
17
|
-
"now-build": "webpack --config demo/webpack.config.js"
|
16
|
+
"now-build": "webpack --config demo/webpack.config.js",
|
17
|
+
"prerelease": "yarn build",
|
18
|
+
"release": "changeset publish",
|
19
|
+
"change": "changeset"
|
18
20
|
},
|
19
21
|
"repository": {
|
20
22
|
"type": "git",
|
@@ -31,7 +33,7 @@
|
|
31
33
|
"safari >= 10",
|
32
34
|
"ie >= 11"
|
33
35
|
],
|
34
|
-
"author": "
|
36
|
+
"author": "SAP-Signavio",
|
35
37
|
"license": "BSD-3-Clause",
|
36
38
|
"bugs": {
|
37
39
|
"url": "https://github.com/signavio/react-mentions/issues"
|
@@ -47,13 +49,13 @@
|
|
47
49
|
"@babel/preset-env": "^7.4.5",
|
48
50
|
"@babel/preset-flow": "^7.0.0",
|
49
51
|
"@babel/preset-react": "^7.0.0",
|
52
|
+
"@changesets/cli": "^2.23.0",
|
50
53
|
"@testing-library/dom": "^8.13.0",
|
51
54
|
"@testing-library/jest-dom": "^5.16.4",
|
52
55
|
"@testing-library/react": "^13.2.0",
|
53
56
|
"babel-eslint": "^7.2.3",
|
54
57
|
"babel-loader": "^8.0.6",
|
55
58
|
"case-sensitive-paths-webpack-plugin": "^2.2.0",
|
56
|
-
"condition-circle": "^2.0.2",
|
57
59
|
"core-js": "^3.1.4",
|
58
60
|
"cross-env": "^5.2.1",
|
59
61
|
"css-loader": "^3.0.0",
|
@@ -77,7 +79,6 @@
|
|
77
79
|
"react-dom": "16.8.6",
|
78
80
|
"recompose": "^0.30.0",
|
79
81
|
"regenerator-runtime": "^0.13.2",
|
80
|
-
"semantic-release": "^19.0.2",
|
81
82
|
"style-loader": "^0.23.1",
|
82
83
|
"substyle-jss": "^4.0.1",
|
83
84
|
"webpack": "^4.35.2",
|