react-mentions 4.3.2 → 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.
- package/README.md +1 -0
- package/dist/react-mentions.cjs.dev.js +78 -57
- package/dist/react-mentions.cjs.prod.js +133 -26
- package/dist/react-mentions.esm.js +78 -57
- package/package.json +4 -7
package/README.md
CHANGED
@@ -65,6 +65,7 @@ The `MentionsInput` supports the following props for configuring the widget:
|
|
65
65
|
| inputRef | React ref | undefined | Accepts a React ref to forward to the underlying input element |
|
66
66
|
| allowSuggestionsAboveCursor | boolean | false | Renders the SuggestionList above the cursor if there is not enough space below |
|
67
67
|
| a11ySuggestionsListLabel | string | `''` | This label would be exposed to screen readers when suggestion popup appears |
|
68
|
+
| customSuggestionsContainer | function(children) | empty function | Allows customizing the container of the suggestions |
|
68
69
|
|
69
70
|
Each data source is configured using a `Mention` component, which has the following props:
|
70
71
|
|
@@ -8,10 +8,10 @@ var _toConsumableArray = _interopDefault(require('@babel/runtime/helpers/toConsu
|
|
8
8
|
var _extends = _interopDefault(require('@babel/runtime/helpers/extends'));
|
9
9
|
var _classCallCheck = _interopDefault(require('@babel/runtime/helpers/classCallCheck'));
|
10
10
|
var _createClass = _interopDefault(require('@babel/runtime/helpers/createClass'));
|
11
|
-
var _possibleConstructorReturn = _interopDefault(require('@babel/runtime/helpers/possibleConstructorReturn'));
|
12
|
-
var _getPrototypeOf = _interopDefault(require('@babel/runtime/helpers/getPrototypeOf'));
|
13
11
|
var _assertThisInitialized = _interopDefault(require('@babel/runtime/helpers/assertThisInitialized'));
|
14
12
|
var _inherits = _interopDefault(require('@babel/runtime/helpers/inherits'));
|
13
|
+
var _possibleConstructorReturn = _interopDefault(require('@babel/runtime/helpers/possibleConstructorReturn'));
|
14
|
+
var _getPrototypeOf = _interopDefault(require('@babel/runtime/helpers/getPrototypeOf'));
|
15
15
|
var _defineProperty = _interopDefault(require('@babel/runtime/helpers/defineProperty'));
|
16
16
|
var React = require('react');
|
17
17
|
var React__default = _interopDefault(React);
|
@@ -659,13 +659,15 @@ var omit = function omit(obj) {
|
|
659
659
|
}, {});
|
660
660
|
};
|
661
661
|
|
662
|
+
var _excluded = ["style", "className", "classNames"];
|
663
|
+
|
662
664
|
function createDefaultStyle(defaultStyle, getModifiers) {
|
663
665
|
var enhance = function enhance(ComponentToWrap) {
|
664
666
|
var DefaultStyleEnhancer = function DefaultStyleEnhancer(_ref) {
|
665
667
|
var style = _ref.style,
|
666
668
|
className = _ref.className,
|
667
669
|
classNames = _ref.classNames,
|
668
|
-
rest = _objectWithoutProperties(_ref,
|
670
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
669
671
|
|
670
672
|
var modifiers = getModifiers ? getModifiers(rest) : undefined;
|
671
673
|
var styles = useStyles__default(defaultStyle, {
|
@@ -673,7 +675,7 @@ function createDefaultStyle(defaultStyle, getModifiers) {
|
|
673
675
|
className: className,
|
674
676
|
classNames: classNames
|
675
677
|
}, modifiers);
|
676
|
-
return React__default.createElement(ComponentToWrap, _extends({}, rest, {
|
678
|
+
return /*#__PURE__*/React__default.createElement(ComponentToWrap, _extends({}, rest, {
|
677
679
|
style: styles
|
678
680
|
}));
|
679
681
|
};
|
@@ -686,6 +688,10 @@ function createDefaultStyle(defaultStyle, getModifiers) {
|
|
686
688
|
return enhance;
|
687
689
|
}
|
688
690
|
|
691
|
+
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); }; }
|
692
|
+
|
693
|
+
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; } }
|
694
|
+
|
689
695
|
var _generateComponentKey = function _generateComponentKey(usedKeys, id) {
|
690
696
|
if (!usedKeys.hasOwnProperty(id)) {
|
691
697
|
usedKeys[id] = 0;
|
@@ -696,17 +702,17 @@ var _generateComponentKey = function _generateComponentKey(usedKeys, id) {
|
|
696
702
|
return id + '_' + usedKeys[id];
|
697
703
|
};
|
698
704
|
|
699
|
-
var Highlighter =
|
700
|
-
/*#__PURE__*/
|
701
|
-
function (_Component) {
|
705
|
+
var Highlighter = /*#__PURE__*/function (_Component) {
|
702
706
|
_inherits(Highlighter, _Component);
|
703
707
|
|
708
|
+
var _super = _createSuper(Highlighter);
|
709
|
+
|
704
710
|
function Highlighter() {
|
705
711
|
var _this;
|
706
712
|
|
707
713
|
_classCallCheck(this, Highlighter);
|
708
714
|
|
709
|
-
_this =
|
715
|
+
_this = _super.apply(this, arguments);
|
710
716
|
|
711
717
|
_defineProperty(_assertThisInitialized(_this), "setCaretElement", function (el) {
|
712
718
|
_this.caretElement = el;
|
@@ -809,7 +815,7 @@ function (_Component) {
|
|
809
815
|
resultComponents.push(this.renderHighlighterCaret(components));
|
810
816
|
}
|
811
817
|
|
812
|
-
return React__default.createElement("div", _extends({}, style, {
|
818
|
+
return /*#__PURE__*/React__default.createElement("div", _extends({}, style, {
|
813
819
|
ref: containerRef
|
814
820
|
}), resultComponents);
|
815
821
|
}
|
@@ -817,7 +823,7 @@ function (_Component) {
|
|
817
823
|
key: "renderSubstring",
|
818
824
|
value: function renderSubstring(string, key) {
|
819
825
|
// set substring span to hidden, so that Emojis are not shown double in Mobile Safari
|
820
|
-
return React__default.createElement("span", _extends({}, this.props.style('substring'), {
|
826
|
+
return /*#__PURE__*/React__default.createElement("span", _extends({}, this.props.style('substring'), {
|
821
827
|
key: key
|
822
828
|
}), string);
|
823
829
|
} // Returns a clone of the Mention child applicable for the specified type to be rendered inside the highlighter
|
@@ -831,13 +837,13 @@ function (_Component) {
|
|
831
837
|
key: key
|
832
838
|
};
|
833
839
|
var child = React.Children.toArray(this.props.children)[mentionChildIndex];
|
834
|
-
return React__default.cloneElement(child, props);
|
840
|
+
return /*#__PURE__*/React__default.cloneElement(child, props);
|
835
841
|
} // Renders an component to be inserted in the highlighter at the current caret position
|
836
842
|
|
837
843
|
}, {
|
838
844
|
key: "renderHighlighterCaret",
|
839
845
|
value: function renderHighlighterCaret(children) {
|
840
|
-
return React__default.createElement("span", _extends({}, this.props.style('caret'), {
|
846
|
+
return /*#__PURE__*/React__default.createElement("span", _extends({}, this.props.style('caret'), {
|
841
847
|
ref: this.setCaretElement,
|
842
848
|
key: "caret"
|
843
849
|
}), children);
|
@@ -886,15 +892,19 @@ var styled = createDefaultStyle({
|
|
886
892
|
});
|
887
893
|
var Highlighter$1 = styled(Highlighter);
|
888
894
|
|
889
|
-
var
|
890
|
-
|
891
|
-
function (
|
895
|
+
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); }; }
|
896
|
+
|
897
|
+
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; } }
|
898
|
+
|
899
|
+
var Suggestion = /*#__PURE__*/function (_Component) {
|
892
900
|
_inherits(Suggestion, _Component);
|
893
901
|
|
902
|
+
var _super = _createSuper$1(Suggestion);
|
903
|
+
|
894
904
|
function Suggestion() {
|
895
905
|
_classCallCheck(this, Suggestion);
|
896
906
|
|
897
|
-
return
|
907
|
+
return _super.apply(this, arguments);
|
898
908
|
}
|
899
909
|
|
900
910
|
_createClass(Suggestion, [{
|
@@ -902,7 +912,7 @@ function (_Component) {
|
|
902
912
|
value: function render() {
|
903
913
|
var rest = omit(this.props, ['style', 'classNames', 'className'], // substyle props
|
904
914
|
keys(Suggestion.propTypes));
|
905
|
-
return React__default.createElement("li", _extends({
|
915
|
+
return /*#__PURE__*/React__default.createElement("li", _extends({
|
906
916
|
id: this.props.id,
|
907
917
|
role: "option",
|
908
918
|
"aria-selected": this.props.focused
|
@@ -954,10 +964,10 @@ function (_Component) {
|
|
954
964
|
var i = getSubstringIndex(display, query, ignoreAccents);
|
955
965
|
|
956
966
|
if (i === -1) {
|
957
|
-
return React__default.createElement("span", style('display'), display);
|
967
|
+
return /*#__PURE__*/React__default.createElement("span", style('display'), display);
|
958
968
|
}
|
959
969
|
|
960
|
-
return React__default.createElement("span", style('display'), display.substring(0, i), React__default.createElement("b", style('highlight'), display.substring(i, i + query.length)), display.substring(i + query.length));
|
970
|
+
return /*#__PURE__*/React__default.createElement("span", style('display'), display.substring(0, i), /*#__PURE__*/React__default.createElement("b", style('highlight'), display.substring(i, i + query.length)), display.substring(i + query.length));
|
961
971
|
}
|
962
972
|
}]);
|
963
973
|
|
@@ -989,17 +999,19 @@ var Suggestion$1 = styled$1(Suggestion);
|
|
989
999
|
function LoadingIndicator() {
|
990
1000
|
var styles = useStyles__default();
|
991
1001
|
var spinnerStyles = styles('spinner');
|
992
|
-
return React__default.createElement("div", styles, React__default.createElement("div", spinnerStyles, React__default.createElement("div", spinnerStyles(['element', 'element1'])), React__default.createElement("div", spinnerStyles(['element', 'element2'])), React__default.createElement("div", spinnerStyles(['element', 'element3'])), React__default.createElement("div", spinnerStyles(['element', 'element4'])), React__default.createElement("div", spinnerStyles(['element', 'element5']))));
|
1002
|
+
return /*#__PURE__*/React__default.createElement("div", styles, /*#__PURE__*/React__default.createElement("div", spinnerStyles, /*#__PURE__*/React__default.createElement("div", spinnerStyles(['element', 'element1'])), /*#__PURE__*/React__default.createElement("div", spinnerStyles(['element', 'element2'])), /*#__PURE__*/React__default.createElement("div", spinnerStyles(['element', 'element3'])), /*#__PURE__*/React__default.createElement("div", spinnerStyles(['element', 'element4'])), /*#__PURE__*/React__default.createElement("div", spinnerStyles(['element', 'element5']))));
|
993
1003
|
}
|
994
1004
|
|
995
|
-
var
|
996
|
-
|
997
|
-
function (
|
1005
|
+
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); }; }
|
1006
|
+
|
1007
|
+
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; } }
|
1008
|
+
|
1009
|
+
var SuggestionsOverlay = /*#__PURE__*/function (_Component) {
|
998
1010
|
_inherits(SuggestionsOverlay, _Component);
|
999
1011
|
|
1000
|
-
|
1001
|
-
var _getPrototypeOf2;
|
1012
|
+
var _super = _createSuper$2(SuggestionsOverlay);
|
1002
1013
|
|
1014
|
+
function SuggestionsOverlay() {
|
1003
1015
|
var _this;
|
1004
1016
|
|
1005
1017
|
_classCallCheck(this, SuggestionsOverlay);
|
@@ -1008,7 +1020,7 @@ function (_Component) {
|
|
1008
1020
|
args[_key] = arguments[_key];
|
1009
1021
|
}
|
1010
1022
|
|
1011
|
-
_this =
|
1023
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
1012
1024
|
|
1013
1025
|
_defineProperty(_assertThisInitialized(_this), "handleMouseEnter", function (index, ev) {
|
1014
1026
|
if (_this.props.onMouseEnter) {
|
@@ -1071,7 +1083,7 @@ function (_Component) {
|
|
1071
1083
|
return null;
|
1072
1084
|
}
|
1073
1085
|
|
1074
|
-
return React__default.createElement("div", _extends({}, useStyles.inline({
|
1086
|
+
return /*#__PURE__*/React__default.createElement("div", _extends({}, useStyles.inline({
|
1075
1087
|
position: position || 'absolute',
|
1076
1088
|
left: left,
|
1077
1089
|
right: right,
|
@@ -1079,7 +1091,7 @@ function (_Component) {
|
|
1079
1091
|
}, style), {
|
1080
1092
|
onMouseDown: onMouseDown,
|
1081
1093
|
ref: containerRef
|
1082
|
-
}), React__default.createElement("ul", _extends({
|
1094
|
+
}), /*#__PURE__*/React__default.createElement("ul", _extends({
|
1083
1095
|
ref: this.setUlElement,
|
1084
1096
|
id: id,
|
1085
1097
|
role: "listbox",
|
@@ -1091,13 +1103,15 @@ function (_Component) {
|
|
1091
1103
|
value: function renderSuggestions() {
|
1092
1104
|
var _this2 = this;
|
1093
1105
|
|
1094
|
-
|
1106
|
+
var customSuggestionsContainer = this.props.customSuggestionsContainer;
|
1107
|
+
var suggestions = Object.values(this.props.suggestions).reduce(function (accResults, _ref) {
|
1095
1108
|
var results = _ref.results,
|
1096
1109
|
queryInfo = _ref.queryInfo;
|
1097
1110
|
return [].concat(_toConsumableArray(accResults), _toConsumableArray(results.map(function (result, index) {
|
1098
1111
|
return _this2.renderSuggestion(result, queryInfo, accResults.length + index);
|
1099
1112
|
})));
|
1100
1113
|
}, []);
|
1114
|
+
if (customSuggestionsContainer) return customSuggestionsContainer(suggestions);else return suggestions;
|
1101
1115
|
}
|
1102
1116
|
}, {
|
1103
1117
|
key: "renderSuggestion",
|
@@ -1109,7 +1123,7 @@ function (_Component) {
|
|
1109
1123
|
query = queryInfo.query;
|
1110
1124
|
var renderSuggestion = React.Children.toArray(this.props.children)[childIndex].props.renderSuggestion;
|
1111
1125
|
var ignoreAccents = this.props.ignoreAccents;
|
1112
|
-
return React__default.createElement(Suggestion$1, {
|
1126
|
+
return /*#__PURE__*/React__default.createElement(Suggestion$1, {
|
1113
1127
|
style: this.props.style('item'),
|
1114
1128
|
key: "".concat(childIndex, "-").concat(getID(result)),
|
1115
1129
|
id: getSuggestionHtmlId(this.props.id, index),
|
@@ -1134,7 +1148,7 @@ function (_Component) {
|
|
1134
1148
|
return;
|
1135
1149
|
}
|
1136
1150
|
|
1137
|
-
return React__default.createElement(LoadingIndicator, {
|
1151
|
+
return /*#__PURE__*/React__default.createElement(LoadingIndicator, {
|
1138
1152
|
style: this.props.style('loadingIndicator')
|
1139
1153
|
});
|
1140
1154
|
}
|
@@ -1191,9 +1205,13 @@ var styled$2 = createDefaultStyle({
|
|
1191
1205
|
});
|
1192
1206
|
var SuggestionsOverlay$1 = styled$2(SuggestionsOverlay);
|
1193
1207
|
|
1194
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
1208
|
+
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; }
|
1195
1209
|
|
1196
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
1210
|
+
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; }
|
1211
|
+
|
1212
|
+
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); }; }
|
1213
|
+
|
1214
|
+
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; } }
|
1197
1215
|
var makeTriggerRegex = function makeTriggerRegex(trigger) {
|
1198
1216
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
1199
1217
|
|
@@ -1251,6 +1269,7 @@ var propTypes = {
|
|
1251
1269
|
a11ySuggestionsListLabel: PropTypes.string,
|
1252
1270
|
value: PropTypes.string,
|
1253
1271
|
onKeyDown: PropTypes.func,
|
1272
|
+
customSuggestionsContainer: PropTypes.func,
|
1254
1273
|
onSelect: PropTypes.func,
|
1255
1274
|
onBlur: PropTypes.func,
|
1256
1275
|
onChange: PropTypes.func,
|
@@ -1261,17 +1280,17 @@ var propTypes = {
|
|
1261
1280
|
children: PropTypes.oneOfType([PropTypes.element, PropTypes.arrayOf(PropTypes.element)]).isRequired
|
1262
1281
|
};
|
1263
1282
|
|
1264
|
-
var MentionsInput =
|
1265
|
-
/*#__PURE__*/
|
1266
|
-
function (_React$Component) {
|
1283
|
+
var MentionsInput = /*#__PURE__*/function (_React$Component) {
|
1267
1284
|
_inherits(MentionsInput, _React$Component);
|
1268
1285
|
|
1286
|
+
var _super = _createSuper$3(MentionsInput);
|
1287
|
+
|
1269
1288
|
function MentionsInput(_props) {
|
1270
1289
|
var _this;
|
1271
1290
|
|
1272
1291
|
_classCallCheck(this, MentionsInput);
|
1273
1292
|
|
1274
|
-
_this =
|
1293
|
+
_this = _super.call(this, _props);
|
1275
1294
|
|
1276
1295
|
_defineProperty(_assertThisInitialized(_this), "setContainerElement", function (el) {
|
1277
1296
|
_this.containerElement = el;
|
@@ -1285,7 +1304,7 @@ function (_React$Component) {
|
|
1285
1304
|
|
1286
1305
|
var props = omit(_this.props, ['style', 'classNames', 'className'], // substyle props
|
1287
1306
|
keys(propTypes));
|
1288
|
-
return _objectSpread({}, props,
|
1307
|
+
return _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, props), style('input')), {}, {
|
1289
1308
|
value: _this.getPlainText()
|
1290
1309
|
}, !readOnly && !disabled && {
|
1291
1310
|
onChange: _this.handleChange,
|
@@ -1295,7 +1314,7 @@ function (_React$Component) {
|
|
1295
1314
|
onCompositionStart: _this.handleCompositionStart,
|
1296
1315
|
onCompositionEnd: _this.handleCompositionEnd,
|
1297
1316
|
onScroll: _this.updateHighlighterScroll
|
1298
|
-
},
|
1317
|
+
}), _this.isOpened() && {
|
1299
1318
|
role: 'combobox',
|
1300
1319
|
'aria-controls': _this.uuidSuggestionsOverlay,
|
1301
1320
|
'aria-expanded': true,
|
@@ -1312,18 +1331,18 @@ function (_React$Component) {
|
|
1312
1331
|
|
1313
1332
|
var inputProps = _this.getInputProps();
|
1314
1333
|
|
1315
|
-
return React__default.createElement("div", style('control'), _this.renderHighlighter(), singleLine ? _this.renderInput(inputProps) : _this.renderTextarea(inputProps));
|
1334
|
+
return /*#__PURE__*/React__default.createElement("div", style('control'), _this.renderHighlighter(), singleLine ? _this.renderInput(inputProps) : _this.renderTextarea(inputProps));
|
1316
1335
|
});
|
1317
1336
|
|
1318
1337
|
_defineProperty(_assertThisInitialized(_this), "renderInput", function (props) {
|
1319
|
-
return React__default.createElement("input", _extends({
|
1338
|
+
return /*#__PURE__*/React__default.createElement("input", _extends({
|
1320
1339
|
type: "text",
|
1321
1340
|
ref: _this.setInputRef
|
1322
1341
|
}, props));
|
1323
1342
|
});
|
1324
1343
|
|
1325
1344
|
_defineProperty(_assertThisInitialized(_this), "renderTextarea", function (props) {
|
1326
|
-
return React__default.createElement("textarea", _extends({
|
1345
|
+
return /*#__PURE__*/React__default.createElement("textarea", _extends({
|
1327
1346
|
ref: _this.setInputRef
|
1328
1347
|
}, props));
|
1329
1348
|
});
|
@@ -1354,7 +1373,7 @@ function (_React$Component) {
|
|
1354
1373
|
left = _this$state$suggestio.left,
|
1355
1374
|
top = _this$state$suggestio.top,
|
1356
1375
|
right = _this$state$suggestio.right;
|
1357
|
-
var suggestionsNode = React__default.createElement(SuggestionsOverlay$1, {
|
1376
|
+
var suggestionsNode = /*#__PURE__*/React__default.createElement(SuggestionsOverlay$1, {
|
1358
1377
|
id: _this.uuidSuggestionsOverlay,
|
1359
1378
|
style: _this.props.style('suggestions'),
|
1360
1379
|
position: position,
|
@@ -1365,6 +1384,7 @@ function (_React$Component) {
|
|
1365
1384
|
scrollFocusedIntoView: _this.state.scrollFocusedIntoView,
|
1366
1385
|
containerRef: _this.setSuggestionsElement,
|
1367
1386
|
suggestions: _this.state.suggestions,
|
1387
|
+
customSuggestionsContainer: _this.props.customSuggestionsContainer,
|
1368
1388
|
onSelect: _this.addMention,
|
1369
1389
|
onMouseDown: _this.handleSuggestionsMouseDown,
|
1370
1390
|
onMouseEnter: _this.handleSuggestionsMouseEnter,
|
@@ -1375,7 +1395,7 @@ function (_React$Component) {
|
|
1375
1395
|
}, _this.props.children);
|
1376
1396
|
|
1377
1397
|
if (_this.props.suggestionsPortalHost) {
|
1378
|
-
return ReactDOM.createPortal(suggestionsNode, _this.props.suggestionsPortalHost);
|
1398
|
+
return /*#__PURE__*/ReactDOM.createPortal(suggestionsNode, _this.props.suggestionsPortalHost);
|
1379
1399
|
} else {
|
1380
1400
|
return suggestionsNode;
|
1381
1401
|
}
|
@@ -1390,7 +1410,7 @@ function (_React$Component) {
|
|
1390
1410
|
children = _this$props3.children,
|
1391
1411
|
value = _this$props3.value,
|
1392
1412
|
style = _this$props3.style;
|
1393
|
-
return React__default.createElement(Highlighter$1, {
|
1413
|
+
return /*#__PURE__*/React__default.createElement(Highlighter$1, {
|
1394
1414
|
containerRef: _this.setHighlighterElement,
|
1395
1415
|
style: style('highlighter'),
|
1396
1416
|
value: value,
|
@@ -1467,7 +1487,7 @@ function (_React$Component) {
|
|
1467
1487
|
|
1468
1488
|
if (startOfMention !== undefined && _this.state.selectionEnd > startOfMention) {
|
1469
1489
|
// only if a deletion has taken place
|
1470
|
-
selectionStart = startOfMention;
|
1490
|
+
selectionStart = startOfMention + (ev.nativeEvent.data ? ev.nativeEvent.data.length : 0);
|
1471
1491
|
selectionEnd = selectionStart;
|
1472
1492
|
setSelectionAfterMentionChange = true;
|
1473
1493
|
}
|
@@ -1827,7 +1847,7 @@ function (_React$Component) {
|
|
1827
1847
|
if (queryId !== _this._queryId) return; // save in property so that multiple sync state updates from different mentions sources
|
1828
1848
|
// won't overwrite each other
|
1829
1849
|
|
1830
|
-
_this.suggestions = _objectSpread({}, _this.suggestions, _defineProperty({}, childIndex, {
|
1850
|
+
_this.suggestions = _objectSpread(_objectSpread({}, _this.suggestions), {}, _defineProperty({}, childIndex, {
|
1831
1851
|
queryInfo: {
|
1832
1852
|
childIndex: childIndex,
|
1833
1853
|
query: query,
|
@@ -1973,7 +1993,7 @@ function (_React$Component) {
|
|
1973
1993
|
}, {
|
1974
1994
|
key: "render",
|
1975
1995
|
value: function render() {
|
1976
|
-
return React__default.createElement("div", _extends({
|
1996
|
+
return /*#__PURE__*/React__default.createElement("div", _extends({
|
1977
1997
|
ref: this.setContainerElement
|
1978
1998
|
}, this.props.style), this.renderControl(), this.renderSuggestionsOverlay());
|
1979
1999
|
}
|
@@ -2003,7 +2023,7 @@ function (_React$Component) {
|
|
2003
2023
|
var newValue = spliceString(value, markupStartIndex, markupEndIndex, pastedMentions || pastedData).replace(/\r/g, '');
|
2004
2024
|
var newPlainTextValue = getPlainText(newValue, config);
|
2005
2025
|
var eventMock = {
|
2006
|
-
target: _objectSpread({}, event.target, {
|
2026
|
+
target: _objectSpread(_objectSpread({}, event.target), {}, {
|
2007
2027
|
value: newValue
|
2008
2028
|
})
|
2009
2029
|
};
|
@@ -2016,9 +2036,10 @@ function (_React$Component) {
|
|
2016
2036
|
}, {
|
2017
2037
|
key: "saveSelectionToClipboard",
|
2018
2038
|
value: function saveSelectionToClipboard(event) {
|
2019
|
-
|
2020
|
-
|
2021
|
-
|
2039
|
+
// use the actual selectionStart & selectionEnd instead of the one stored
|
2040
|
+
// in state to ensure copy & paste also works on disabled inputs & textareas
|
2041
|
+
var selectionStart = this.inputElement.selectionStart;
|
2042
|
+
var selectionEnd = this.inputElement.selectionEnd;
|
2022
2043
|
var _this$props8 = this.props,
|
2023
2044
|
children = _this$props8.children,
|
2024
2045
|
value = _this$props8.value;
|
@@ -2060,9 +2081,9 @@ function (_React$Component) {
|
|
2060
2081
|
|
2061
2082
|
event.preventDefault();
|
2062
2083
|
this.saveSelectionToClipboard(event);
|
2063
|
-
var _this$
|
2064
|
-
selectionStart = _this$
|
2065
|
-
selectionEnd = _this$
|
2084
|
+
var _this$state4 = this.state,
|
2085
|
+
selectionStart = _this$state4.selectionStart,
|
2086
|
+
selectionEnd = _this$state4.selectionEnd;
|
2066
2087
|
var _this$props9 = this.props,
|
2067
2088
|
children = _this$props9.children,
|
2068
2089
|
value = _this$props9.value;
|
@@ -2072,7 +2093,7 @@ function (_React$Component) {
|
|
2072
2093
|
var newValue = [value.slice(0, markupStartIndex), value.slice(markupEndIndex)].join('');
|
2073
2094
|
var newPlainTextValue = getPlainText(newValue, config);
|
2074
2095
|
var eventMock = {
|
2075
|
-
target: _objectSpread({}, event.target, {
|
2096
|
+
target: _objectSpread(_objectSpread({}, event.target), {}, {
|
2076
2097
|
value: newPlainTextValue
|
2077
2098
|
})
|
2078
2099
|
};
|
@@ -2162,7 +2183,7 @@ var Mention = function Mention(_ref) {
|
|
2162
2183
|
className: className,
|
2163
2184
|
classNames: classNames
|
2164
2185
|
});
|
2165
|
-
return React__default.createElement("strong", styles, display);
|
2186
|
+
return /*#__PURE__*/React__default.createElement("strong", styles, display);
|
2166
2187
|
};
|
2167
2188
|
|
2168
2189
|
Mention.propTypes = {
|
@@ -8,7 +8,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
8
8
|
value: !0
|
9
9
|
});
|
10
10
|
|
11
|
-
var _toConsumableArray = _interopDefault(require("@babel/runtime/helpers/toConsumableArray")), _extends = _interopDefault(require("@babel/runtime/helpers/extends")), _classCallCheck = _interopDefault(require("@babel/runtime/helpers/classCallCheck")), _createClass = _interopDefault(require("@babel/runtime/helpers/createClass")),
|
11
|
+
var _toConsumableArray = _interopDefault(require("@babel/runtime/helpers/toConsumableArray")), _extends = _interopDefault(require("@babel/runtime/helpers/extends")), _classCallCheck = _interopDefault(require("@babel/runtime/helpers/classCallCheck")), _createClass = _interopDefault(require("@babel/runtime/helpers/createClass")), _assertThisInitialized = _interopDefault(require("@babel/runtime/helpers/assertThisInitialized")), _inherits = _interopDefault(require("@babel/runtime/helpers/inherits")), _possibleConstructorReturn = _interopDefault(require("@babel/runtime/helpers/possibleConstructorReturn")), _getPrototypeOf = _interopDefault(require("@babel/runtime/helpers/getPrototypeOf")), _defineProperty = _interopDefault(require("@babel/runtime/helpers/defineProperty")), React = require("react"), React__default = _interopDefault(React), invariant = _interopDefault(require("invariant")), _slicedToArray = _interopDefault(require("@babel/runtime/helpers/slicedToArray")), _objectWithoutProperties = _interopDefault(require("@babel/runtime/helpers/objectWithoutProperties")), useStyles = require("substyle"), useStyles__default = _interopDefault(useStyles), PropTypes = _interopDefault(require("prop-types")), ReactDOM = _interopDefault(require("react-dom")), escapeRegex = function(str) {
|
12
12
|
return str.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
|
13
13
|
}, PLACEHOLDERS = {
|
14
14
|
id: "__id__",
|
@@ -418,12 +418,12 @@ var _toConsumableArray = _interopDefault(require("@babel/runtime/helpers/toConsu
|
|
418
418
|
return obj.hasOwnProperty(k) && !keys.includes(k) && void 0 !== obj[k] && (acc[k] = obj[k]),
|
419
419
|
acc;
|
420
420
|
}, {});
|
421
|
-
};
|
421
|
+
}, _excluded = [ "style", "className", "classNames" ];
|
422
422
|
|
423
423
|
function createDefaultStyle(defaultStyle, getModifiers) {
|
424
424
|
return function(ComponentToWrap) {
|
425
425
|
var DefaultStyleEnhancer = function(_ref) {
|
426
|
-
var style = _ref.style, className = _ref.className, classNames = _ref.classNames, rest = _objectWithoutProperties(_ref,
|
426
|
+
var style = _ref.style, className = _ref.className, classNames = _ref.classNames, rest = _objectWithoutProperties(_ref, _excluded), modifiers = getModifiers ? getModifiers(rest) : void 0, styles = useStyles__default(defaultStyle, {
|
427
427
|
style: style,
|
428
428
|
className: className,
|
429
429
|
classNames: classNames
|
@@ -437,12 +437,38 @@ function createDefaultStyle(defaultStyle, getModifiers) {
|
|
437
437
|
};
|
438
438
|
}
|
439
439
|
|
440
|
+
function _createSuper(Derived) {
|
441
|
+
var hasNativeReflectConstruct = _isNativeReflectConstruct();
|
442
|
+
return function() {
|
443
|
+
var result, Super = _getPrototypeOf(Derived);
|
444
|
+
if (hasNativeReflectConstruct) {
|
445
|
+
var NewTarget = _getPrototypeOf(this).constructor;
|
446
|
+
result = Reflect.construct(Super, arguments, NewTarget);
|
447
|
+
} else result = Super.apply(this, arguments);
|
448
|
+
return _possibleConstructorReturn(this, result);
|
449
|
+
};
|
450
|
+
}
|
451
|
+
|
452
|
+
function _isNativeReflectConstruct() {
|
453
|
+
if ("undefined" == typeof Reflect || !Reflect.construct) return !1;
|
454
|
+
if (Reflect.construct.sham) return !1;
|
455
|
+
if ("function" == typeof Proxy) return !0;
|
456
|
+
try {
|
457
|
+
return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {})),
|
458
|
+
!0;
|
459
|
+
} catch (e) {
|
460
|
+
return !1;
|
461
|
+
}
|
462
|
+
}
|
463
|
+
|
440
464
|
var _generateComponentKey = function(usedKeys, id) {
|
441
465
|
return usedKeys.hasOwnProperty(id) ? usedKeys[id]++ : usedKeys[id] = 0, id + "_" + usedKeys[id];
|
442
466
|
}, Highlighter = function(_Component) {
|
467
|
+
_inherits(Highlighter, _Component);
|
468
|
+
var _super = _createSuper(Highlighter);
|
443
469
|
function Highlighter() {
|
444
470
|
var _this;
|
445
|
-
return _classCallCheck(this, Highlighter), _this =
|
471
|
+
return _classCallCheck(this, Highlighter), _this = _super.apply(this, arguments),
|
446
472
|
_defineProperty(_assertThisInitialized(_this), "setCaretElement", function(el) {
|
447
473
|
_this.caretElement = el;
|
448
474
|
}), _this.state = {
|
@@ -450,7 +476,7 @@ var _generateComponentKey = function(usedKeys, id) {
|
|
450
476
|
top: void 0
|
451
477
|
}, _this;
|
452
478
|
}
|
453
|
-
return
|
479
|
+
return _createClass(Highlighter, [ {
|
454
480
|
key: "componentDidMount",
|
455
481
|
value: function() {
|
456
482
|
this.notifyCaretPosition();
|
@@ -557,11 +583,39 @@ var styled = createDefaultStyle({
|
|
557
583
|
return {
|
558
584
|
"&singleLine": props.singleLine
|
559
585
|
};
|
560
|
-
}), Highlighter$1 = styled(Highlighter)
|
586
|
+
}), Highlighter$1 = styled(Highlighter);
|
587
|
+
|
588
|
+
function _createSuper$1(Derived) {
|
589
|
+
var hasNativeReflectConstruct = _isNativeReflectConstruct$1();
|
590
|
+
return function() {
|
591
|
+
var result, Super = _getPrototypeOf(Derived);
|
592
|
+
if (hasNativeReflectConstruct) {
|
593
|
+
var NewTarget = _getPrototypeOf(this).constructor;
|
594
|
+
result = Reflect.construct(Super, arguments, NewTarget);
|
595
|
+
} else result = Super.apply(this, arguments);
|
596
|
+
return _possibleConstructorReturn(this, result);
|
597
|
+
};
|
598
|
+
}
|
599
|
+
|
600
|
+
function _isNativeReflectConstruct$1() {
|
601
|
+
if ("undefined" == typeof Reflect || !Reflect.construct) return !1;
|
602
|
+
if (Reflect.construct.sham) return !1;
|
603
|
+
if ("function" == typeof Proxy) return !0;
|
604
|
+
try {
|
605
|
+
return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {})),
|
606
|
+
!0;
|
607
|
+
} catch (e) {
|
608
|
+
return !1;
|
609
|
+
}
|
610
|
+
}
|
611
|
+
|
612
|
+
var Suggestion = function(_Component) {
|
613
|
+
_inherits(Suggestion, _Component);
|
614
|
+
var _super = _createSuper$1(Suggestion);
|
561
615
|
function Suggestion() {
|
562
|
-
return _classCallCheck(this, Suggestion),
|
616
|
+
return _classCallCheck(this, Suggestion), _super.apply(this, arguments);
|
563
617
|
}
|
564
|
-
return
|
618
|
+
return _createClass(Suggestion, [ {
|
565
619
|
key: "render",
|
566
620
|
value: function() {
|
567
621
|
var rest = omit(this.props, [ "style", "classNames", "className" ], keys(Suggestion.propTypes));
|
@@ -620,13 +674,38 @@ function LoadingIndicator() {
|
|
620
674
|
return React__default.createElement("div", styles, React__default.createElement("div", spinnerStyles, React__default.createElement("div", spinnerStyles([ "element", "element1" ])), React__default.createElement("div", spinnerStyles([ "element", "element2" ])), React__default.createElement("div", spinnerStyles([ "element", "element3" ])), React__default.createElement("div", spinnerStyles([ "element", "element4" ])), React__default.createElement("div", spinnerStyles([ "element", "element5" ]))));
|
621
675
|
}
|
622
676
|
|
677
|
+
function _createSuper$2(Derived) {
|
678
|
+
var hasNativeReflectConstruct = _isNativeReflectConstruct$2();
|
679
|
+
return function() {
|
680
|
+
var result, Super = _getPrototypeOf(Derived);
|
681
|
+
if (hasNativeReflectConstruct) {
|
682
|
+
var NewTarget = _getPrototypeOf(this).constructor;
|
683
|
+
result = Reflect.construct(Super, arguments, NewTarget);
|
684
|
+
} else result = Super.apply(this, arguments);
|
685
|
+
return _possibleConstructorReturn(this, result);
|
686
|
+
};
|
687
|
+
}
|
688
|
+
|
689
|
+
function _isNativeReflectConstruct$2() {
|
690
|
+
if ("undefined" == typeof Reflect || !Reflect.construct) return !1;
|
691
|
+
if (Reflect.construct.sham) return !1;
|
692
|
+
if ("function" == typeof Proxy) return !0;
|
693
|
+
try {
|
694
|
+
return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {})),
|
695
|
+
!0;
|
696
|
+
} catch (e) {
|
697
|
+
return !1;
|
698
|
+
}
|
699
|
+
}
|
700
|
+
|
623
701
|
var SuggestionsOverlay = function(_Component) {
|
702
|
+
_inherits(SuggestionsOverlay, _Component);
|
703
|
+
var _super = _createSuper$2(SuggestionsOverlay);
|
624
704
|
function SuggestionsOverlay() {
|
625
|
-
var
|
705
|
+
var _this;
|
626
706
|
_classCallCheck(this, SuggestionsOverlay);
|
627
707
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) args[_key] = arguments[_key];
|
628
|
-
return _this =
|
629
|
-
_defineProperty(_assertThisInitialized(_this), "handleMouseEnter", function(index, ev) {
|
708
|
+
return _this = _super.call.apply(_super, [ this ].concat(args)), _defineProperty(_assertThisInitialized(_this), "handleMouseEnter", function(index, ev) {
|
630
709
|
_this.props.onMouseEnter && _this.props.onMouseEnter(index);
|
631
710
|
}), _defineProperty(_assertThisInitialized(_this), "select", function(suggestion, queryInfo) {
|
632
711
|
_this.props.onSelect(suggestion, queryInfo);
|
@@ -634,7 +713,7 @@ var SuggestionsOverlay = function(_Component) {
|
|
634
713
|
_this.ulElement = el;
|
635
714
|
}), _this;
|
636
715
|
}
|
637
|
-
return
|
716
|
+
return _createClass(SuggestionsOverlay, [ {
|
638
717
|
key: "componentDidUpdate",
|
639
718
|
value: function() {
|
640
719
|
if (this.ulElement && !(this.ulElement.offsetHeight >= this.ulElement.scrollHeight) && this.props.scrollFocusedIntoView) {
|
@@ -664,13 +743,13 @@ var SuggestionsOverlay = function(_Component) {
|
|
664
743
|
}, {
|
665
744
|
key: "renderSuggestions",
|
666
745
|
value: function() {
|
667
|
-
var _this2 = this
|
668
|
-
return Object.values(this.props.suggestions).reduce(function(accResults, _ref) {
|
746
|
+
var _this2 = this, customSuggestionsContainer = this.props.customSuggestionsContainer, suggestions = Object.values(this.props.suggestions).reduce(function(accResults, _ref) {
|
669
747
|
var results = _ref.results, queryInfo = _ref.queryInfo;
|
670
748
|
return [].concat(_toConsumableArray(accResults), _toConsumableArray(results.map(function(result, index) {
|
671
749
|
return _this2.renderSuggestion(result, queryInfo, accResults.length + index);
|
672
750
|
})));
|
673
751
|
}, []);
|
752
|
+
return customSuggestionsContainer ? customSuggestionsContainer(suggestions) : suggestions;
|
674
753
|
}
|
675
754
|
}, {
|
676
755
|
key: "renderSuggestion",
|
@@ -757,15 +836,39 @@ function ownKeys(object, enumerableOnly) {
|
|
757
836
|
function _objectSpread(target) {
|
758
837
|
for (var i = 1; i < arguments.length; i++) {
|
759
838
|
var source = null != arguments[i] ? arguments[i] : {};
|
760
|
-
i % 2 ? ownKeys(source, !0).forEach(function(key) {
|
839
|
+
i % 2 ? ownKeys(Object(source), !0).forEach(function(key) {
|
761
840
|
_defineProperty(target, key, source[key]);
|
762
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(source).forEach(function(key) {
|
841
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function(key) {
|
763
842
|
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
764
843
|
});
|
765
844
|
}
|
766
845
|
return target;
|
767
846
|
}
|
768
847
|
|
848
|
+
function _createSuper$3(Derived) {
|
849
|
+
var hasNativeReflectConstruct = _isNativeReflectConstruct$3();
|
850
|
+
return function() {
|
851
|
+
var result, Super = _getPrototypeOf(Derived);
|
852
|
+
if (hasNativeReflectConstruct) {
|
853
|
+
var NewTarget = _getPrototypeOf(this).constructor;
|
854
|
+
result = Reflect.construct(Super, arguments, NewTarget);
|
855
|
+
} else result = Super.apply(this, arguments);
|
856
|
+
return _possibleConstructorReturn(this, result);
|
857
|
+
};
|
858
|
+
}
|
859
|
+
|
860
|
+
function _isNativeReflectConstruct$3() {
|
861
|
+
if ("undefined" == typeof Reflect || !Reflect.construct) return !1;
|
862
|
+
if (Reflect.construct.sham) return !1;
|
863
|
+
if ("function" == typeof Proxy) return !0;
|
864
|
+
try {
|
865
|
+
return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {})),
|
866
|
+
!0;
|
867
|
+
} catch (e) {
|
868
|
+
return !1;
|
869
|
+
}
|
870
|
+
}
|
871
|
+
|
769
872
|
var makeTriggerRegex = function(trigger) {
|
770
873
|
var options = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {};
|
771
874
|
if (trigger instanceof RegExp) return trigger;
|
@@ -794,6 +897,7 @@ var makeTriggerRegex = function(trigger) {
|
|
794
897
|
a11ySuggestionsListLabel: PropTypes.string,
|
795
898
|
value: PropTypes.string,
|
796
899
|
onKeyDown: PropTypes.func,
|
900
|
+
customSuggestionsContainer: PropTypes.func,
|
797
901
|
onSelect: PropTypes.func,
|
798
902
|
onBlur: PropTypes.func,
|
799
903
|
onChange: PropTypes.func,
|
@@ -803,14 +907,16 @@ var makeTriggerRegex = function(trigger) {
|
|
803
907
|
}) ]),
|
804
908
|
children: PropTypes.oneOfType([ PropTypes.element, PropTypes.arrayOf(PropTypes.element) ]).isRequired
|
805
909
|
}, MentionsInput = function(_React$Component) {
|
910
|
+
_inherits(MentionsInput, _React$Component);
|
911
|
+
var _super = _createSuper$3(MentionsInput);
|
806
912
|
function MentionsInput(_props) {
|
807
913
|
var _this;
|
808
|
-
return _classCallCheck(this, MentionsInput), _this =
|
914
|
+
return _classCallCheck(this, MentionsInput), _this = _super.call(this, _props),
|
809
915
|
_defineProperty(_assertThisInitialized(_this), "setContainerElement", function(el) {
|
810
916
|
_this.containerElement = el;
|
811
917
|
}), _defineProperty(_assertThisInitialized(_this), "getInputProps", function() {
|
812
918
|
var _this$props = _this.props, readOnly = _this$props.readOnly, disabled = _this$props.disabled, style = _this$props.style;
|
813
|
-
return _objectSpread({}, omit(_this.props, [ "style", "classNames", "className" ], keys(propTypes)),
|
919
|
+
return _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, omit(_this.props, [ "style", "classNames", "className" ], keys(propTypes))), style("input")), {}, {
|
814
920
|
value: _this.getPlainText()
|
815
921
|
}, !readOnly && !disabled && {
|
816
922
|
onChange: _this.handleChange,
|
@@ -820,7 +926,7 @@ var makeTriggerRegex = function(trigger) {
|
|
820
926
|
onCompositionStart: _this.handleCompositionStart,
|
821
927
|
onCompositionEnd: _this.handleCompositionEnd,
|
822
928
|
onScroll: _this.updateHighlighterScroll
|
823
|
-
},
|
929
|
+
}), _this.isOpened() && {
|
824
930
|
role: "combobox",
|
825
931
|
"aria-controls": _this.uuidSuggestionsOverlay,
|
826
932
|
"aria-expanded": !0,
|
@@ -859,6 +965,7 @@ var makeTriggerRegex = function(trigger) {
|
|
859
965
|
scrollFocusedIntoView: _this.state.scrollFocusedIntoView,
|
860
966
|
containerRef: _this.setSuggestionsElement,
|
861
967
|
suggestions: _this.state.suggestions,
|
968
|
+
customSuggestionsContainer: _this.props.customSuggestionsContainer,
|
862
969
|
onSelect: _this.addMention,
|
863
970
|
onMouseDown: _this.handleSuggestionsMouseDown,
|
864
971
|
onMouseEnter: _this.handleSuggestionsMouseEnter,
|
@@ -900,7 +1007,7 @@ var makeTriggerRegex = function(trigger) {
|
|
900
1007
|
}, config);
|
901
1008
|
newPlainTextValue = getPlainText(newValue, config);
|
902
1009
|
var selectionStart = ev.target.selectionStart, selectionEnd = ev.target.selectionEnd, setSelectionAfterMentionChange = !1, startOfMention = findStartOfMentionInPlainText(value, config, selectionStart);
|
903
|
-
void 0 !== startOfMention && _this.state.selectionEnd > startOfMention && (selectionEnd = selectionStart = startOfMention,
|
1010
|
+
void 0 !== startOfMention && _this.state.selectionEnd > startOfMention && (selectionEnd = selectionStart = startOfMention + (ev.nativeEvent.data ? ev.nativeEvent.data.length : 0),
|
904
1011
|
setSelectionAfterMentionChange = !0), _this.setState({
|
905
1012
|
selectionStart: selectionStart,
|
906
1013
|
selectionEnd: selectionEnd,
|
@@ -1045,7 +1152,7 @@ var makeTriggerRegex = function(trigger) {
|
|
1045
1152
|
syncResult instanceof Array && _this.updateSuggestions(_this._queryId, childIndex, query, querySequenceStart, querySequenceEnd, plainTextValue, syncResult);
|
1046
1153
|
}), _defineProperty(_assertThisInitialized(_this), "updateSuggestions", function(queryId, childIndex, query, querySequenceStart, querySequenceEnd, plainTextValue, results) {
|
1047
1154
|
if (queryId === _this._queryId) {
|
1048
|
-
_this.suggestions = _objectSpread({}, _this.suggestions, _defineProperty({}, childIndex, {
|
1155
|
+
_this.suggestions = _objectSpread(_objectSpread({}, _this.suggestions), {}, _defineProperty({}, childIndex, {
|
1049
1156
|
queryInfo: {
|
1050
1157
|
childIndex: childIndex,
|
1051
1158
|
query: query,
|
@@ -1100,7 +1207,7 @@ var makeTriggerRegex = function(trigger) {
|
|
1100
1207
|
suggestionsPosition: {}
|
1101
1208
|
}, _this;
|
1102
1209
|
}
|
1103
|
-
return
|
1210
|
+
return _createClass(MentionsInput, [ {
|
1104
1211
|
key: "componentDidMount",
|
1105
1212
|
value: function() {
|
1106
1213
|
document.addEventListener("copy", this.handleCopy), document.addEventListener("cut", this.handleCut),
|
@@ -1133,7 +1240,7 @@ var makeTriggerRegex = function(trigger) {
|
|
1133
1240
|
if (event.target === this.inputElement && this.supportsClipboardActions(event)) {
|
1134
1241
|
event.preventDefault();
|
1135
1242
|
var _this$state3 = this.state, selectionStart = _this$state3.selectionStart, selectionEnd = _this$state3.selectionEnd, _this$props7 = this.props, value = _this$props7.value, children = _this$props7.children, config = readConfigFromChildren(children), markupStartIndex = mapPlainTextIndex(value, config, selectionStart, "START"), markupEndIndex = mapPlainTextIndex(value, config, selectionEnd, "END"), pastedMentions = event.clipboardData.getData("text/react-mentions"), pastedData = event.clipboardData.getData("text/plain"), newValue = spliceString(value, markupStartIndex, markupEndIndex, pastedMentions || pastedData).replace(/\r/g, ""), newPlainTextValue = getPlainText(newValue, config), eventMock = {
|
1136
|
-
target: _objectSpread({}, event.target, {
|
1243
|
+
target: _objectSpread(_objectSpread({}, event.target), {}, {
|
1137
1244
|
value: newValue
|
1138
1245
|
})
|
1139
1246
|
};
|
@@ -1145,7 +1252,7 @@ var makeTriggerRegex = function(trigger) {
|
|
1145
1252
|
}, {
|
1146
1253
|
key: "saveSelectionToClipboard",
|
1147
1254
|
value: function(event) {
|
1148
|
-
var
|
1255
|
+
var selectionStart = this.inputElement.selectionStart, selectionEnd = this.inputElement.selectionEnd, _this$props8 = this.props, children = _this$props8.children, value = _this$props8.value, config = readConfigFromChildren(children), markupStartIndex = mapPlainTextIndex(value, config, selectionStart, "START"), markupEndIndex = mapPlainTextIndex(value, config, selectionEnd, "END");
|
1149
1256
|
event.clipboardData.setData("text/plain", event.target.value.slice(selectionStart, selectionEnd)),
|
1150
1257
|
event.clipboardData.setData("text/react-mentions", value.slice(markupStartIndex, markupEndIndex));
|
1151
1258
|
}
|
@@ -1165,8 +1272,8 @@ var makeTriggerRegex = function(trigger) {
|
|
1165
1272
|
value: function(event) {
|
1166
1273
|
if (event.target === this.inputElement && this.supportsClipboardActions(event)) {
|
1167
1274
|
event.preventDefault(), this.saveSelectionToClipboard(event);
|
1168
|
-
var _this$
|
1169
|
-
target: _objectSpread({}, event.target, {
|
1275
|
+
var _this$state4 = this.state, selectionStart = _this$state4.selectionStart, selectionEnd = _this$state4.selectionEnd, _this$props9 = this.props, children = _this$props9.children, value = _this$props9.value, config = readConfigFromChildren(children), markupStartIndex = mapPlainTextIndex(value, config, selectionStart, "START"), markupEndIndex = mapPlainTextIndex(value, config, selectionEnd, "END"), newValue = [ value.slice(0, markupStartIndex), value.slice(markupEndIndex) ].join(""), newPlainTextValue = getPlainText(newValue, config), eventMock = {
|
1276
|
+
target: _objectSpread(_objectSpread({}, event.target), {}, {
|
1170
1277
|
value: newPlainTextValue
|
1171
1278
|
})
|
1172
1279
|
};
|
@@ -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,15 +884,19 @@ var styled = createDefaultStyle({
|
|
878
884
|
});
|
879
885
|
var Highlighter$1 = styled(Highlighter);
|
880
886
|
|
881
|
-
var
|
882
|
-
|
883
|
-
function (
|
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) {
|
884
892
|
_inherits(Suggestion, _Component);
|
885
893
|
|
894
|
+
var _super = _createSuper$1(Suggestion);
|
895
|
+
|
886
896
|
function Suggestion() {
|
887
897
|
_classCallCheck(this, Suggestion);
|
888
898
|
|
889
|
-
return
|
899
|
+
return _super.apply(this, arguments);
|
890
900
|
}
|
891
901
|
|
892
902
|
_createClass(Suggestion, [{
|
@@ -894,7 +904,7 @@ function (_Component) {
|
|
894
904
|
value: function render() {
|
895
905
|
var rest = omit(this.props, ['style', 'classNames', 'className'], // substyle props
|
896
906
|
keys(Suggestion.propTypes));
|
897
|
-
return React.createElement("li", _extends({
|
907
|
+
return /*#__PURE__*/React.createElement("li", _extends({
|
898
908
|
id: this.props.id,
|
899
909
|
role: "option",
|
900
910
|
"aria-selected": this.props.focused
|
@@ -946,10 +956,10 @@ function (_Component) {
|
|
946
956
|
var i = getSubstringIndex(display, query, ignoreAccents);
|
947
957
|
|
948
958
|
if (i === -1) {
|
949
|
-
return React.createElement("span", style('display'), display);
|
959
|
+
return /*#__PURE__*/React.createElement("span", style('display'), display);
|
950
960
|
}
|
951
961
|
|
952
|
-
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));
|
953
963
|
}
|
954
964
|
}]);
|
955
965
|
|
@@ -981,17 +991,19 @@ var Suggestion$1 = styled$1(Suggestion);
|
|
981
991
|
function LoadingIndicator() {
|
982
992
|
var styles = useStyles();
|
983
993
|
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']))));
|
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']))));
|
985
995
|
}
|
986
996
|
|
987
|
-
var
|
988
|
-
|
989
|
-
function (
|
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) {
|
990
1002
|
_inherits(SuggestionsOverlay, _Component);
|
991
1003
|
|
992
|
-
|
993
|
-
var _getPrototypeOf2;
|
1004
|
+
var _super = _createSuper$2(SuggestionsOverlay);
|
994
1005
|
|
1006
|
+
function SuggestionsOverlay() {
|
995
1007
|
var _this;
|
996
1008
|
|
997
1009
|
_classCallCheck(this, SuggestionsOverlay);
|
@@ -1000,7 +1012,7 @@ function (_Component) {
|
|
1000
1012
|
args[_key] = arguments[_key];
|
1001
1013
|
}
|
1002
1014
|
|
1003
|
-
_this =
|
1015
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
1004
1016
|
|
1005
1017
|
_defineProperty(_assertThisInitialized(_this), "handleMouseEnter", function (index, ev) {
|
1006
1018
|
if (_this.props.onMouseEnter) {
|
@@ -1063,7 +1075,7 @@ function (_Component) {
|
|
1063
1075
|
return null;
|
1064
1076
|
}
|
1065
1077
|
|
1066
|
-
return React.createElement("div", _extends({}, inline({
|
1078
|
+
return /*#__PURE__*/React.createElement("div", _extends({}, inline({
|
1067
1079
|
position: position || 'absolute',
|
1068
1080
|
left: left,
|
1069
1081
|
right: right,
|
@@ -1071,7 +1083,7 @@ function (_Component) {
|
|
1071
1083
|
}, style), {
|
1072
1084
|
onMouseDown: onMouseDown,
|
1073
1085
|
ref: containerRef
|
1074
|
-
}), React.createElement("ul", _extends({
|
1086
|
+
}), /*#__PURE__*/React.createElement("ul", _extends({
|
1075
1087
|
ref: this.setUlElement,
|
1076
1088
|
id: id,
|
1077
1089
|
role: "listbox",
|
@@ -1083,13 +1095,15 @@ function (_Component) {
|
|
1083
1095
|
value: function renderSuggestions() {
|
1084
1096
|
var _this2 = this;
|
1085
1097
|
|
1086
|
-
|
1098
|
+
var customSuggestionsContainer = this.props.customSuggestionsContainer;
|
1099
|
+
var suggestions = Object.values(this.props.suggestions).reduce(function (accResults, _ref) {
|
1087
1100
|
var results = _ref.results,
|
1088
1101
|
queryInfo = _ref.queryInfo;
|
1089
1102
|
return [].concat(_toConsumableArray(accResults), _toConsumableArray(results.map(function (result, index) {
|
1090
1103
|
return _this2.renderSuggestion(result, queryInfo, accResults.length + index);
|
1091
1104
|
})));
|
1092
1105
|
}, []);
|
1106
|
+
if (customSuggestionsContainer) return customSuggestionsContainer(suggestions);else return suggestions;
|
1093
1107
|
}
|
1094
1108
|
}, {
|
1095
1109
|
key: "renderSuggestion",
|
@@ -1101,7 +1115,7 @@ function (_Component) {
|
|
1101
1115
|
query = queryInfo.query;
|
1102
1116
|
var renderSuggestion = Children.toArray(this.props.children)[childIndex].props.renderSuggestion;
|
1103
1117
|
var ignoreAccents = this.props.ignoreAccents;
|
1104
|
-
return React.createElement(Suggestion$1, {
|
1118
|
+
return /*#__PURE__*/React.createElement(Suggestion$1, {
|
1105
1119
|
style: this.props.style('item'),
|
1106
1120
|
key: "".concat(childIndex, "-").concat(getID(result)),
|
1107
1121
|
id: getSuggestionHtmlId(this.props.id, index),
|
@@ -1126,7 +1140,7 @@ function (_Component) {
|
|
1126
1140
|
return;
|
1127
1141
|
}
|
1128
1142
|
|
1129
|
-
return React.createElement(LoadingIndicator, {
|
1143
|
+
return /*#__PURE__*/React.createElement(LoadingIndicator, {
|
1130
1144
|
style: this.props.style('loadingIndicator')
|
1131
1145
|
});
|
1132
1146
|
}
|
@@ -1183,9 +1197,13 @@ var styled$2 = createDefaultStyle({
|
|
1183
1197
|
});
|
1184
1198
|
var SuggestionsOverlay$1 = styled$2(SuggestionsOverlay);
|
1185
1199
|
|
1186
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
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; }
|
1187
1201
|
|
1188
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
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; }
|
1203
|
+
|
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; } }
|
1189
1207
|
var makeTriggerRegex = function makeTriggerRegex(trigger) {
|
1190
1208
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
1191
1209
|
|
@@ -1243,6 +1261,7 @@ var propTypes = {
|
|
1243
1261
|
a11ySuggestionsListLabel: PropTypes.string,
|
1244
1262
|
value: PropTypes.string,
|
1245
1263
|
onKeyDown: PropTypes.func,
|
1264
|
+
customSuggestionsContainer: PropTypes.func,
|
1246
1265
|
onSelect: PropTypes.func,
|
1247
1266
|
onBlur: PropTypes.func,
|
1248
1267
|
onChange: PropTypes.func,
|
@@ -1253,17 +1272,17 @@ var propTypes = {
|
|
1253
1272
|
children: PropTypes.oneOfType([PropTypes.element, PropTypes.arrayOf(PropTypes.element)]).isRequired
|
1254
1273
|
};
|
1255
1274
|
|
1256
|
-
var MentionsInput =
|
1257
|
-
/*#__PURE__*/
|
1258
|
-
function (_React$Component) {
|
1275
|
+
var MentionsInput = /*#__PURE__*/function (_React$Component) {
|
1259
1276
|
_inherits(MentionsInput, _React$Component);
|
1260
1277
|
|
1278
|
+
var _super = _createSuper$3(MentionsInput);
|
1279
|
+
|
1261
1280
|
function MentionsInput(_props) {
|
1262
1281
|
var _this;
|
1263
1282
|
|
1264
1283
|
_classCallCheck(this, MentionsInput);
|
1265
1284
|
|
1266
|
-
_this =
|
1285
|
+
_this = _super.call(this, _props);
|
1267
1286
|
|
1268
1287
|
_defineProperty(_assertThisInitialized(_this), "setContainerElement", function (el) {
|
1269
1288
|
_this.containerElement = el;
|
@@ -1277,7 +1296,7 @@ function (_React$Component) {
|
|
1277
1296
|
|
1278
1297
|
var props = omit(_this.props, ['style', 'classNames', 'className'], // substyle props
|
1279
1298
|
keys(propTypes));
|
1280
|
-
return _objectSpread({}, props,
|
1299
|
+
return _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, props), style('input')), {}, {
|
1281
1300
|
value: _this.getPlainText()
|
1282
1301
|
}, !readOnly && !disabled && {
|
1283
1302
|
onChange: _this.handleChange,
|
@@ -1287,7 +1306,7 @@ function (_React$Component) {
|
|
1287
1306
|
onCompositionStart: _this.handleCompositionStart,
|
1288
1307
|
onCompositionEnd: _this.handleCompositionEnd,
|
1289
1308
|
onScroll: _this.updateHighlighterScroll
|
1290
|
-
},
|
1309
|
+
}), _this.isOpened() && {
|
1291
1310
|
role: 'combobox',
|
1292
1311
|
'aria-controls': _this.uuidSuggestionsOverlay,
|
1293
1312
|
'aria-expanded': true,
|
@@ -1304,18 +1323,18 @@ function (_React$Component) {
|
|
1304
1323
|
|
1305
1324
|
var inputProps = _this.getInputProps();
|
1306
1325
|
|
1307
|
-
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));
|
1308
1327
|
});
|
1309
1328
|
|
1310
1329
|
_defineProperty(_assertThisInitialized(_this), "renderInput", function (props) {
|
1311
|
-
return React.createElement("input", _extends({
|
1330
|
+
return /*#__PURE__*/React.createElement("input", _extends({
|
1312
1331
|
type: "text",
|
1313
1332
|
ref: _this.setInputRef
|
1314
1333
|
}, props));
|
1315
1334
|
});
|
1316
1335
|
|
1317
1336
|
_defineProperty(_assertThisInitialized(_this), "renderTextarea", function (props) {
|
1318
|
-
return React.createElement("textarea", _extends({
|
1337
|
+
return /*#__PURE__*/React.createElement("textarea", _extends({
|
1319
1338
|
ref: _this.setInputRef
|
1320
1339
|
}, props));
|
1321
1340
|
});
|
@@ -1346,7 +1365,7 @@ function (_React$Component) {
|
|
1346
1365
|
left = _this$state$suggestio.left,
|
1347
1366
|
top = _this$state$suggestio.top,
|
1348
1367
|
right = _this$state$suggestio.right;
|
1349
|
-
var suggestionsNode = React.createElement(SuggestionsOverlay$1, {
|
1368
|
+
var suggestionsNode = /*#__PURE__*/React.createElement(SuggestionsOverlay$1, {
|
1350
1369
|
id: _this.uuidSuggestionsOverlay,
|
1351
1370
|
style: _this.props.style('suggestions'),
|
1352
1371
|
position: position,
|
@@ -1357,6 +1376,7 @@ function (_React$Component) {
|
|
1357
1376
|
scrollFocusedIntoView: _this.state.scrollFocusedIntoView,
|
1358
1377
|
containerRef: _this.setSuggestionsElement,
|
1359
1378
|
suggestions: _this.state.suggestions,
|
1379
|
+
customSuggestionsContainer: _this.props.customSuggestionsContainer,
|
1360
1380
|
onSelect: _this.addMention,
|
1361
1381
|
onMouseDown: _this.handleSuggestionsMouseDown,
|
1362
1382
|
onMouseEnter: _this.handleSuggestionsMouseEnter,
|
@@ -1367,7 +1387,7 @@ function (_React$Component) {
|
|
1367
1387
|
}, _this.props.children);
|
1368
1388
|
|
1369
1389
|
if (_this.props.suggestionsPortalHost) {
|
1370
|
-
return ReactDOM.createPortal(suggestionsNode, _this.props.suggestionsPortalHost);
|
1390
|
+
return /*#__PURE__*/ReactDOM.createPortal(suggestionsNode, _this.props.suggestionsPortalHost);
|
1371
1391
|
} else {
|
1372
1392
|
return suggestionsNode;
|
1373
1393
|
}
|
@@ -1382,7 +1402,7 @@ function (_React$Component) {
|
|
1382
1402
|
children = _this$props3.children,
|
1383
1403
|
value = _this$props3.value,
|
1384
1404
|
style = _this$props3.style;
|
1385
|
-
return React.createElement(Highlighter$1, {
|
1405
|
+
return /*#__PURE__*/React.createElement(Highlighter$1, {
|
1386
1406
|
containerRef: _this.setHighlighterElement,
|
1387
1407
|
style: style('highlighter'),
|
1388
1408
|
value: value,
|
@@ -1459,7 +1479,7 @@ function (_React$Component) {
|
|
1459
1479
|
|
1460
1480
|
if (startOfMention !== undefined && _this.state.selectionEnd > startOfMention) {
|
1461
1481
|
// only if a deletion has taken place
|
1462
|
-
selectionStart = startOfMention;
|
1482
|
+
selectionStart = startOfMention + (ev.nativeEvent.data ? ev.nativeEvent.data.length : 0);
|
1463
1483
|
selectionEnd = selectionStart;
|
1464
1484
|
setSelectionAfterMentionChange = true;
|
1465
1485
|
}
|
@@ -1819,7 +1839,7 @@ function (_React$Component) {
|
|
1819
1839
|
if (queryId !== _this._queryId) return; // save in property so that multiple sync state updates from different mentions sources
|
1820
1840
|
// won't overwrite each other
|
1821
1841
|
|
1822
|
-
_this.suggestions = _objectSpread({}, _this.suggestions, _defineProperty({}, childIndex, {
|
1842
|
+
_this.suggestions = _objectSpread(_objectSpread({}, _this.suggestions), {}, _defineProperty({}, childIndex, {
|
1823
1843
|
queryInfo: {
|
1824
1844
|
childIndex: childIndex,
|
1825
1845
|
query: query,
|
@@ -1965,7 +1985,7 @@ function (_React$Component) {
|
|
1965
1985
|
}, {
|
1966
1986
|
key: "render",
|
1967
1987
|
value: function render() {
|
1968
|
-
return React.createElement("div", _extends({
|
1988
|
+
return /*#__PURE__*/React.createElement("div", _extends({
|
1969
1989
|
ref: this.setContainerElement
|
1970
1990
|
}, this.props.style), this.renderControl(), this.renderSuggestionsOverlay());
|
1971
1991
|
}
|
@@ -1995,7 +2015,7 @@ function (_React$Component) {
|
|
1995
2015
|
var newValue = spliceString(value, markupStartIndex, markupEndIndex, pastedMentions || pastedData).replace(/\r/g, '');
|
1996
2016
|
var newPlainTextValue = getPlainText(newValue, config);
|
1997
2017
|
var eventMock = {
|
1998
|
-
target: _objectSpread({}, event.target, {
|
2018
|
+
target: _objectSpread(_objectSpread({}, event.target), {}, {
|
1999
2019
|
value: newValue
|
2000
2020
|
})
|
2001
2021
|
};
|
@@ -2008,9 +2028,10 @@ function (_React$Component) {
|
|
2008
2028
|
}, {
|
2009
2029
|
key: "saveSelectionToClipboard",
|
2010
2030
|
value: function saveSelectionToClipboard(event) {
|
2011
|
-
|
2012
|
-
|
2013
|
-
|
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;
|
2014
2035
|
var _this$props8 = this.props,
|
2015
2036
|
children = _this$props8.children,
|
2016
2037
|
value = _this$props8.value;
|
@@ -2052,9 +2073,9 @@ function (_React$Component) {
|
|
2052
2073
|
|
2053
2074
|
event.preventDefault();
|
2054
2075
|
this.saveSelectionToClipboard(event);
|
2055
|
-
var _this$
|
2056
|
-
selectionStart = _this$
|
2057
|
-
selectionEnd = _this$
|
2076
|
+
var _this$state4 = this.state,
|
2077
|
+
selectionStart = _this$state4.selectionStart,
|
2078
|
+
selectionEnd = _this$state4.selectionEnd;
|
2058
2079
|
var _this$props9 = this.props,
|
2059
2080
|
children = _this$props9.children,
|
2060
2081
|
value = _this$props9.value;
|
@@ -2064,7 +2085,7 @@ function (_React$Component) {
|
|
2064
2085
|
var newValue = [value.slice(0, markupStartIndex), value.slice(markupEndIndex)].join('');
|
2065
2086
|
var newPlainTextValue = getPlainText(newValue, config);
|
2066
2087
|
var eventMock = {
|
2067
|
-
target: _objectSpread({}, event.target, {
|
2088
|
+
target: _objectSpread(_objectSpread({}, event.target), {}, {
|
2068
2089
|
value: newPlainTextValue
|
2069
2090
|
})
|
2070
2091
|
};
|
@@ -2154,7 +2175,7 @@ var Mention = function Mention(_ref) {
|
|
2154
2175
|
className: className,
|
2155
2176
|
classNames: classNames
|
2156
2177
|
});
|
2157
|
-
return React.createElement("strong", styles, display);
|
2178
|
+
return /*#__PURE__*/React.createElement("strong", styles, display);
|
2158
2179
|
};
|
2159
2180
|
|
2160
2181
|
Mention.propTypes = {
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "react-mentions",
|
3
|
-
"version": "4.
|
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.
|
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": "^
|
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
|
}
|