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
package/CHANGELOG.md
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# react-mentions
|
2
|
+
|
3
|
+
## 4.4.6
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- 959625b: Suggestions.js refactored to functional component
|
8
|
+
|
9
|
+
## 4.4.5
|
10
|
+
|
11
|
+
### Patch Changes
|
12
|
+
|
13
|
+
- f40cff2: Fix #507 for forceSuggestionsAboveCursor when suggestionsPortalHost is not being used
|
14
|
+
|
15
|
+
## 4.4.4
|
16
|
+
|
17
|
+
### Patch Changes
|
18
|
+
|
19
|
+
- 748d38a: fix npm publishing
|
20
|
+
|
21
|
+
## 4.4.3
|
22
|
+
|
23
|
+
### Patch Changes
|
24
|
+
|
25
|
+
- e7f35ab: fix npm publishing
|
package/README.md
CHANGED
@@ -1,9 +1,6 @@
|
|
1
1
|
# [React Mentions](https://react-mentions.now.sh)
|
2
2
|
|
3
|
-
[![CircleCI][build-badge]][build]
|
4
|
-
[![codecov][codecov-badge]][codecov]
|
5
3
|
[![npm package][npm-badge]][npm]
|
6
|
-
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
|
7
4
|
|
8
5
|
A React component that let's you mention people in a textarea like you are used to on Facebook or Twitter.
|
9
6
|
|
@@ -58,14 +55,16 @@ The `MentionsInput` supports the following props for configuring the widget:
|
|
58
55
|
| --------------------------- | ------------------------------------------------------- | -------------- | -------------------------------------------------------------------------------------- |
|
59
56
|
| value | string | `''` | The value containing markup for mentions |
|
60
57
|
| onChange | function (event, newValue, newPlainTextValue, mentions) | empty function | A callback that is invoked when the user changes the value in the mentions input |
|
58
|
+
| onKeyDown | function (event) | empty function | A callback that is invoked when the user presses a key in the mentions input |
|
61
59
|
| singleLine | boolean | `false` | Renders a single line text input instead of a textarea, if set to `true` |
|
62
60
|
| onBlur | function (event, clickedSuggestion) | empty function | Passes `true` as second argument if the blur was caused by a mousedown on a suggestion |
|
63
61
|
| allowSpaceInQuery | boolean | false | Keep suggestions open even if the user separates keywords with spaces. |
|
64
62
|
| suggestionsPortalHost | DOM Element | undefined | Render suggestions into the DOM in the supplied host element. |
|
65
63
|
| inputRef | React ref | undefined | Accepts a React ref to forward to the underlying input element |
|
66
64
|
| allowSuggestionsAboveCursor | boolean | false | Renders the SuggestionList above the cursor if there is not enough space below |
|
65
|
+
| forceSuggestionsAboveCursor | boolean | false | Forces the SuggestionList to be rendered above the cursor |
|
67
66
|
| a11ySuggestionsListLabel | string | `''` | This label would be exposed to screen readers when suggestion popup appears |
|
68
|
-
| customSuggestionsContainer
|
67
|
+
| customSuggestionsContainer | function(children) | empty function | Allows customizing the container of the suggestions |
|
69
68
|
|
70
69
|
Each data source is configured using a `Mention` component, which has the following props:
|
71
70
|
|
@@ -77,7 +76,7 @@ Each data source is configured using a `Mention` component, which has the follow
|
|
77
76
|
| markup | string | `'@[__display__](__id__)'` | A template string for the markup to use for mentions |
|
78
77
|
| displayTransform | function (id, display) | returns `display` | Accepts a function for customizing the string that is displayed for a mention |
|
79
78
|
| regex | RegExp | automatically derived from `markup` pattern | Allows providing a custom regular expression for parsing your markup and extracting the placeholder interpolations (optional) | |
|
80
|
-
| onAdd | function (id, display, startPos, endPos)
|
79
|
+
| onAdd | function (id, display, startPos, endPos) | empty function | Callback invoked when a suggestion has been added (optional) |
|
81
80
|
| appendSpaceOnAdd | boolean | `false` | Append a space when a suggestion has been added (optional) |
|
82
81
|
|
83
82
|
If a function is passed as the `data` prop, that function will be called with the current search query as first, and a callback function as second argument. The callback can be used to provide results asynchronously, e.g., after fetch requests. (It can even be called multiple times to update the list of suggestions.)
|
@@ -97,18 +96,7 @@ You can also assign `className` and `style` props to the `Mention` elements to d
|
|
97
96
|
Due to react-mentions' internal cursor tracking it is not good enough to simulate the editing of the textarea value using `ReactTestUtils.Simulate.change`.
|
98
97
|
We recommend using [@testing-library/user-event](https://github.com/testing-library/user-event) for a realistic simulation of events as they would happen in the browser as the user interacts the textarea.
|
99
98
|
|
100
|
-
|
99
|
+
---
|
101
100
|
|
102
|
-
|
103
|
-
|
104
|
-
```
|
105
|
-
yarn start
|
106
|
-
|
107
|
-
```
|
108
|
-
|
109
|
-
[build-badge]: https://circleci.com/gh/signavio/react-mentions/tree/master.svg?style=shield&circle-token=:circle-token
|
110
|
-
[build]: https://circleci.com/gh/signavio/react-mentions/tree/master
|
111
|
-
[npm-badge]: https://img.shields.io/npm/v/react-mentions.png?style=flat-square
|
112
|
-
[npm]: https://www.npmjs.org/package/react-mentions
|
113
|
-
[codecov-badge]: https://img.shields.io/codecov/c/github/signavio/react-mentions.svg
|
114
|
-
[codecov]: https://codecov.io/gh/signavio/react-mentions
|
101
|
+
If you want to contribute, first of all: thank you ❤️.
|
102
|
+
Please check [CONTRIBUTING.md](/CONTRIBUTING.md) and/or create an issue.
|
@@ -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,85 +892,68 @@ var styled = createDefaultStyle({
|
|
886
892
|
});
|
887
893
|
var Highlighter$1 = styled(Highlighter);
|
888
894
|
|
889
|
-
|
890
|
-
|
891
|
-
|
892
|
-
|
893
|
-
|
894
|
-
|
895
|
-
|
895
|
+
function Suggestion(_ref) {
|
896
|
+
var id = _ref.id,
|
897
|
+
focused = _ref.focused,
|
898
|
+
ignoreAccents = _ref.ignoreAccents,
|
899
|
+
index = _ref.index,
|
900
|
+
onClick = _ref.onClick,
|
901
|
+
onMouseEnter = _ref.onMouseEnter,
|
902
|
+
query = _ref.query,
|
903
|
+
renderSuggestion = _ref.renderSuggestion,
|
904
|
+
suggestion = _ref.suggestion,
|
905
|
+
style = _ref.style,
|
906
|
+
className = _ref.className,
|
907
|
+
classNames = _ref.classNames;
|
908
|
+
var rest = {
|
909
|
+
onClick: onClick,
|
910
|
+
onMouseEnter: onMouseEnter
|
911
|
+
};
|
896
912
|
|
897
|
-
|
898
|
-
|
913
|
+
var renderContent = function renderContent() {
|
914
|
+
var display = getDisplay();
|
915
|
+
var highlightedDisplay = renderHighlightedDisplay(display);
|
899
916
|
|
900
|
-
|
901
|
-
|
902
|
-
value: function render() {
|
903
|
-
var rest = omit(this.props, ['style', 'classNames', 'className'], // substyle props
|
904
|
-
keys(Suggestion.propTypes));
|
905
|
-
return React__default.createElement("li", _extends({
|
906
|
-
id: this.props.id,
|
907
|
-
role: "option",
|
908
|
-
"aria-selected": this.props.focused
|
909
|
-
}, rest, this.props.style), this.renderContent());
|
917
|
+
if (renderSuggestion) {
|
918
|
+
return renderSuggestion(suggestion, query, highlightedDisplay, index, focused);
|
910
919
|
}
|
911
|
-
}, {
|
912
|
-
key: "renderContent",
|
913
|
-
value: function renderContent() {
|
914
|
-
var _this$props = this.props,
|
915
|
-
query = _this$props.query,
|
916
|
-
renderSuggestion = _this$props.renderSuggestion,
|
917
|
-
suggestion = _this$props.suggestion,
|
918
|
-
index = _this$props.index,
|
919
|
-
focused = _this$props.focused;
|
920
|
-
var display = this.getDisplay();
|
921
|
-
var highlightedDisplay = this.renderHighlightedDisplay(display, query);
|
922
|
-
|
923
|
-
if (renderSuggestion) {
|
924
|
-
return renderSuggestion(suggestion, query, highlightedDisplay, index, focused);
|
925
|
-
}
|
926
|
-
|
927
|
-
return highlightedDisplay;
|
928
|
-
}
|
929
|
-
}, {
|
930
|
-
key: "getDisplay",
|
931
|
-
value: function getDisplay() {
|
932
|
-
var suggestion = this.props.suggestion;
|
933
920
|
|
934
|
-
|
935
|
-
|
936
|
-
}
|
921
|
+
return highlightedDisplay;
|
922
|
+
};
|
937
923
|
|
938
|
-
|
939
|
-
|
924
|
+
var getDisplay = function getDisplay() {
|
925
|
+
if (typeof suggestion === 'string') {
|
926
|
+
return suggestion;
|
927
|
+
}
|
940
928
|
|
941
|
-
|
942
|
-
|
943
|
-
}
|
929
|
+
var id = suggestion.id,
|
930
|
+
display = suggestion.display;
|
944
931
|
|
945
|
-
|
932
|
+
if (id === undefined || !display) {
|
933
|
+
return id;
|
946
934
|
}
|
947
|
-
}, {
|
948
|
-
key: "renderHighlightedDisplay",
|
949
|
-
value: function renderHighlightedDisplay(display) {
|
950
|
-
var _this$props2 = this.props,
|
951
|
-
ignoreAccents = _this$props2.ignoreAccents,
|
952
|
-
query = _this$props2.query,
|
953
|
-
style = _this$props2.style;
|
954
|
-
var i = getSubstringIndex(display, query, ignoreAccents);
|
955
935
|
|
956
|
-
|
957
|
-
|
958
|
-
|
936
|
+
return display;
|
937
|
+
};
|
938
|
+
|
939
|
+
var renderHighlightedDisplay = function renderHighlightedDisplay(display) {
|
940
|
+
var i = getSubstringIndex(display, query, ignoreAccents);
|
959
941
|
|
960
|
-
|
942
|
+
if (i === -1) {
|
943
|
+
return /*#__PURE__*/React__default.createElement("span", style('display'), display);
|
961
944
|
}
|
962
|
-
}]);
|
963
945
|
|
964
|
-
|
965
|
-
}
|
946
|
+
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));
|
947
|
+
};
|
948
|
+
|
949
|
+
return /*#__PURE__*/React__default.createElement("li", _extends({
|
950
|
+
id: id,
|
951
|
+
role: "option",
|
952
|
+
"aria-selected": focused
|
953
|
+
}, rest, style), renderContent());
|
954
|
+
}
|
966
955
|
|
967
|
-
|
956
|
+
Suggestion.propTypes = {
|
968
957
|
id: PropTypes.string.isRequired,
|
969
958
|
query: PropTypes.string.isRequired,
|
970
959
|
index: PropTypes.number.isRequired,
|
@@ -975,8 +964,7 @@ _defineProperty(Suggestion, "propTypes", {
|
|
975
964
|
})]).isRequired,
|
976
965
|
renderSuggestion: PropTypes.func,
|
977
966
|
focused: PropTypes.bool
|
978
|
-
}
|
979
|
-
|
967
|
+
};
|
980
968
|
var styled$1 = createDefaultStyle({
|
981
969
|
cursor: 'pointer'
|
982
970
|
}, function (props) {
|
@@ -986,20 +974,31 @@ var styled$1 = createDefaultStyle({
|
|
986
974
|
});
|
987
975
|
var Suggestion$1 = styled$1(Suggestion);
|
988
976
|
|
989
|
-
function LoadingIndicator() {
|
990
|
-
var
|
977
|
+
function LoadingIndicator(_ref) {
|
978
|
+
var style = _ref.style,
|
979
|
+
className = _ref.className,
|
980
|
+
classNames = _ref.classNames;
|
981
|
+
var styles = useStyles__default(defaultstyle, {
|
982
|
+
style: style,
|
983
|
+
className: className,
|
984
|
+
classNames: classNames
|
985
|
+
});
|
991
986
|
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']))));
|
987
|
+
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
988
|
}
|
994
989
|
|
995
|
-
var
|
996
|
-
|
997
|
-
function (
|
990
|
+
var defaultstyle = {};
|
991
|
+
|
992
|
+
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); }; }
|
993
|
+
|
994
|
+
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; } }
|
995
|
+
|
996
|
+
var SuggestionsOverlay = /*#__PURE__*/function (_Component) {
|
998
997
|
_inherits(SuggestionsOverlay, _Component);
|
999
998
|
|
1000
|
-
|
1001
|
-
var _getPrototypeOf2;
|
999
|
+
var _super = _createSuper$1(SuggestionsOverlay);
|
1002
1000
|
|
1001
|
+
function SuggestionsOverlay() {
|
1003
1002
|
var _this;
|
1004
1003
|
|
1005
1004
|
_classCallCheck(this, SuggestionsOverlay);
|
@@ -1008,7 +1007,7 @@ function (_Component) {
|
|
1008
1007
|
args[_key] = arguments[_key];
|
1009
1008
|
}
|
1010
1009
|
|
1011
|
-
_this =
|
1010
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
1012
1011
|
|
1013
1012
|
_defineProperty(_assertThisInitialized(_this), "handleMouseEnter", function (index, ev) {
|
1014
1013
|
if (_this.props.onMouseEnter) {
|
@@ -1071,7 +1070,7 @@ function (_Component) {
|
|
1071
1070
|
return null;
|
1072
1071
|
}
|
1073
1072
|
|
1074
|
-
return React__default.createElement("div", _extends({}, useStyles.inline({
|
1073
|
+
return /*#__PURE__*/React__default.createElement("div", _extends({}, useStyles.inline({
|
1075
1074
|
position: position || 'absolute',
|
1076
1075
|
left: left,
|
1077
1076
|
right: right,
|
@@ -1079,7 +1078,7 @@ function (_Component) {
|
|
1079
1078
|
}, style), {
|
1080
1079
|
onMouseDown: onMouseDown,
|
1081
1080
|
ref: containerRef
|
1082
|
-
}), React__default.createElement("ul", _extends({
|
1081
|
+
}), /*#__PURE__*/React__default.createElement("ul", _extends({
|
1083
1082
|
ref: this.setUlElement,
|
1084
1083
|
id: id,
|
1085
1084
|
role: "listbox",
|
@@ -1091,13 +1090,15 @@ function (_Component) {
|
|
1091
1090
|
value: function renderSuggestions() {
|
1092
1091
|
var _this2 = this;
|
1093
1092
|
|
1094
|
-
|
1093
|
+
var customSuggestionsContainer = this.props.customSuggestionsContainer;
|
1094
|
+
var suggestions = Object.values(this.props.suggestions).reduce(function (accResults, _ref) {
|
1095
1095
|
var results = _ref.results,
|
1096
1096
|
queryInfo = _ref.queryInfo;
|
1097
1097
|
return [].concat(_toConsumableArray(accResults), _toConsumableArray(results.map(function (result, index) {
|
1098
1098
|
return _this2.renderSuggestion(result, queryInfo, accResults.length + index);
|
1099
1099
|
})));
|
1100
1100
|
}, []);
|
1101
|
+
if (customSuggestionsContainer) return customSuggestionsContainer(suggestions);else return suggestions;
|
1101
1102
|
}
|
1102
1103
|
}, {
|
1103
1104
|
key: "renderSuggestion",
|
@@ -1109,7 +1110,7 @@ function (_Component) {
|
|
1109
1110
|
query = queryInfo.query;
|
1110
1111
|
var renderSuggestion = React.Children.toArray(this.props.children)[childIndex].props.renderSuggestion;
|
1111
1112
|
var ignoreAccents = this.props.ignoreAccents;
|
1112
|
-
return React__default.createElement(Suggestion$1, {
|
1113
|
+
return /*#__PURE__*/React__default.createElement(Suggestion$1, {
|
1113
1114
|
style: this.props.style('item'),
|
1114
1115
|
key: "".concat(childIndex, "-").concat(getID(result)),
|
1115
1116
|
id: getSuggestionHtmlId(this.props.id, index),
|
@@ -1134,7 +1135,7 @@ function (_Component) {
|
|
1134
1135
|
return;
|
1135
1136
|
}
|
1136
1137
|
|
1137
|
-
return React__default.createElement(LoadingIndicator, {
|
1138
|
+
return /*#__PURE__*/React__default.createElement(LoadingIndicator, {
|
1138
1139
|
style: this.props.style('loadingIndicator')
|
1139
1140
|
});
|
1140
1141
|
}
|
@@ -1191,9 +1192,13 @@ var styled$2 = createDefaultStyle({
|
|
1191
1192
|
});
|
1192
1193
|
var SuggestionsOverlay$1 = styled$2(SuggestionsOverlay);
|
1193
1194
|
|
1194
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
1195
|
+
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
1196
|
|
1196
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
1197
|
+
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; }
|
1198
|
+
|
1199
|
+
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); }; }
|
1200
|
+
|
1201
|
+
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; } }
|
1197
1202
|
var makeTriggerRegex = function makeTriggerRegex(trigger) {
|
1198
1203
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
1199
1204
|
|
@@ -1251,6 +1256,7 @@ var propTypes = {
|
|
1251
1256
|
a11ySuggestionsListLabel: PropTypes.string,
|
1252
1257
|
value: PropTypes.string,
|
1253
1258
|
onKeyDown: PropTypes.func,
|
1259
|
+
customSuggestionsContainer: PropTypes.func,
|
1254
1260
|
onSelect: PropTypes.func,
|
1255
1261
|
onBlur: PropTypes.func,
|
1256
1262
|
onChange: PropTypes.func,
|
@@ -1261,17 +1267,17 @@ var propTypes = {
|
|
1261
1267
|
children: PropTypes.oneOfType([PropTypes.element, PropTypes.arrayOf(PropTypes.element)]).isRequired
|
1262
1268
|
};
|
1263
1269
|
|
1264
|
-
var MentionsInput =
|
1265
|
-
/*#__PURE__*/
|
1266
|
-
function (_React$Component) {
|
1270
|
+
var MentionsInput = /*#__PURE__*/function (_React$Component) {
|
1267
1271
|
_inherits(MentionsInput, _React$Component);
|
1268
1272
|
|
1273
|
+
var _super = _createSuper$2(MentionsInput);
|
1274
|
+
|
1269
1275
|
function MentionsInput(_props) {
|
1270
1276
|
var _this;
|
1271
1277
|
|
1272
1278
|
_classCallCheck(this, MentionsInput);
|
1273
1279
|
|
1274
|
-
_this =
|
1280
|
+
_this = _super.call(this, _props);
|
1275
1281
|
|
1276
1282
|
_defineProperty(_assertThisInitialized(_this), "setContainerElement", function (el) {
|
1277
1283
|
_this.containerElement = el;
|
@@ -1285,17 +1291,17 @@ function (_React$Component) {
|
|
1285
1291
|
|
1286
1292
|
var props = omit(_this.props, ['style', 'classNames', 'className'], // substyle props
|
1287
1293
|
keys(propTypes));
|
1288
|
-
return _objectSpread({}, props,
|
1289
|
-
value: _this.getPlainText()
|
1294
|
+
return _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, props), style('input')), {}, {
|
1295
|
+
value: _this.getPlainText(),
|
1296
|
+
onScroll: _this.updateHighlighterScroll
|
1290
1297
|
}, !readOnly && !disabled && {
|
1291
1298
|
onChange: _this.handleChange,
|
1292
1299
|
onSelect: _this.handleSelect,
|
1293
1300
|
onKeyDown: _this.handleKeyDown,
|
1294
1301
|
onBlur: _this.handleBlur,
|
1295
1302
|
onCompositionStart: _this.handleCompositionStart,
|
1296
|
-
onCompositionEnd: _this.handleCompositionEnd
|
1297
|
-
|
1298
|
-
}, {}, _this.isOpened() && {
|
1303
|
+
onCompositionEnd: _this.handleCompositionEnd
|
1304
|
+
}), _this.isOpened() && {
|
1299
1305
|
role: 'combobox',
|
1300
1306
|
'aria-controls': _this.uuidSuggestionsOverlay,
|
1301
1307
|
'aria-expanded': true,
|
@@ -1312,18 +1318,18 @@ function (_React$Component) {
|
|
1312
1318
|
|
1313
1319
|
var inputProps = _this.getInputProps();
|
1314
1320
|
|
1315
|
-
return React__default.createElement("div", style('control'), _this.renderHighlighter(), singleLine ? _this.renderInput(inputProps) : _this.renderTextarea(inputProps));
|
1321
|
+
return /*#__PURE__*/React__default.createElement("div", style('control'), _this.renderHighlighter(), singleLine ? _this.renderInput(inputProps) : _this.renderTextarea(inputProps));
|
1316
1322
|
});
|
1317
1323
|
|
1318
1324
|
_defineProperty(_assertThisInitialized(_this), "renderInput", function (props) {
|
1319
|
-
return React__default.createElement("input", _extends({
|
1325
|
+
return /*#__PURE__*/React__default.createElement("input", _extends({
|
1320
1326
|
type: "text",
|
1321
1327
|
ref: _this.setInputRef
|
1322
1328
|
}, props));
|
1323
1329
|
});
|
1324
1330
|
|
1325
1331
|
_defineProperty(_assertThisInitialized(_this), "renderTextarea", function (props) {
|
1326
|
-
return React__default.createElement("textarea", _extends({
|
1332
|
+
return /*#__PURE__*/React__default.createElement("textarea", _extends({
|
1327
1333
|
ref: _this.setInputRef
|
1328
1334
|
}, props));
|
1329
1335
|
});
|
@@ -1354,7 +1360,7 @@ function (_React$Component) {
|
|
1354
1360
|
left = _this$state$suggestio.left,
|
1355
1361
|
top = _this$state$suggestio.top,
|
1356
1362
|
right = _this$state$suggestio.right;
|
1357
|
-
var suggestionsNode = React__default.createElement(SuggestionsOverlay$1, {
|
1363
|
+
var suggestionsNode = /*#__PURE__*/React__default.createElement(SuggestionsOverlay$1, {
|
1358
1364
|
id: _this.uuidSuggestionsOverlay,
|
1359
1365
|
style: _this.props.style('suggestions'),
|
1360
1366
|
position: position,
|
@@ -1365,6 +1371,7 @@ function (_React$Component) {
|
|
1365
1371
|
scrollFocusedIntoView: _this.state.scrollFocusedIntoView,
|
1366
1372
|
containerRef: _this.setSuggestionsElement,
|
1367
1373
|
suggestions: _this.state.suggestions,
|
1374
|
+
customSuggestionsContainer: _this.props.customSuggestionsContainer,
|
1368
1375
|
onSelect: _this.addMention,
|
1369
1376
|
onMouseDown: _this.handleSuggestionsMouseDown,
|
1370
1377
|
onMouseEnter: _this.handleSuggestionsMouseEnter,
|
@@ -1375,7 +1382,7 @@ function (_React$Component) {
|
|
1375
1382
|
}, _this.props.children);
|
1376
1383
|
|
1377
1384
|
if (_this.props.suggestionsPortalHost) {
|
1378
|
-
return ReactDOM.createPortal(suggestionsNode, _this.props.suggestionsPortalHost);
|
1385
|
+
return /*#__PURE__*/ReactDOM.createPortal(suggestionsNode, _this.props.suggestionsPortalHost);
|
1379
1386
|
} else {
|
1380
1387
|
return suggestionsNode;
|
1381
1388
|
}
|
@@ -1390,7 +1397,7 @@ function (_React$Component) {
|
|
1390
1397
|
children = _this$props3.children,
|
1391
1398
|
value = _this$props3.value,
|
1392
1399
|
style = _this$props3.style;
|
1393
|
-
return React__default.createElement(Highlighter$1, {
|
1400
|
+
return /*#__PURE__*/React__default.createElement(Highlighter$1, {
|
1394
1401
|
containerRef: _this.setHighlighterElement,
|
1395
1402
|
style: style('highlighter'),
|
1396
1403
|
value: value,
|
@@ -1467,7 +1474,7 @@ function (_React$Component) {
|
|
1467
1474
|
|
1468
1475
|
if (startOfMention !== undefined && _this.state.selectionEnd > startOfMention) {
|
1469
1476
|
// only if a deletion has taken place
|
1470
|
-
selectionStart = startOfMention;
|
1477
|
+
selectionStart = startOfMention + (ev.nativeEvent.data ? ev.nativeEvent.data.length : 0);
|
1471
1478
|
selectionEnd = selectionStart;
|
1472
1479
|
setSelectionAfterMentionChange = true;
|
1473
1480
|
}
|
@@ -1705,7 +1712,7 @@ function (_React$Component) {
|
|
1705
1712
|
// is small enough to NOT cover up the caret
|
1706
1713
|
|
1707
1714
|
|
1708
|
-
if (allowSuggestionsAboveCursor && viewportRelative.top - highlighter.scrollTop + suggestions.offsetHeight > viewportHeight && suggestions.offsetHeight < caretOffsetParentRect.top - caretHeight - highlighter.scrollTop) {
|
1715
|
+
if (allowSuggestionsAboveCursor && viewportRelative.top - highlighter.scrollTop + suggestions.offsetHeight > viewportHeight && suggestions.offsetHeight < caretOffsetParentRect.top - caretHeight - highlighter.scrollTop || forceSuggestionsAboveCursor) {
|
1709
1716
|
position.top = _top - suggestions.offsetHeight - caretHeight;
|
1710
1717
|
} else {
|
1711
1718
|
position.top = _top;
|
@@ -1827,7 +1834,7 @@ function (_React$Component) {
|
|
1827
1834
|
if (queryId !== _this._queryId) return; // save in property so that multiple sync state updates from different mentions sources
|
1828
1835
|
// won't overwrite each other
|
1829
1836
|
|
1830
|
-
_this.suggestions = _objectSpread({}, _this.suggestions, _defineProperty({}, childIndex, {
|
1837
|
+
_this.suggestions = _objectSpread(_objectSpread({}, _this.suggestions), {}, _defineProperty({}, childIndex, {
|
1831
1838
|
queryInfo: {
|
1832
1839
|
childIndex: childIndex,
|
1833
1840
|
query: query,
|
@@ -1973,7 +1980,7 @@ function (_React$Component) {
|
|
1973
1980
|
}, {
|
1974
1981
|
key: "render",
|
1975
1982
|
value: function render() {
|
1976
|
-
return React__default.createElement("div", _extends({
|
1983
|
+
return /*#__PURE__*/React__default.createElement("div", _extends({
|
1977
1984
|
ref: this.setContainerElement
|
1978
1985
|
}, this.props.style), this.renderControl(), this.renderSuggestionsOverlay());
|
1979
1986
|
}
|
@@ -2003,7 +2010,7 @@ function (_React$Component) {
|
|
2003
2010
|
var newValue = spliceString(value, markupStartIndex, markupEndIndex, pastedMentions || pastedData).replace(/\r/g, '');
|
2004
2011
|
var newPlainTextValue = getPlainText(newValue, config);
|
2005
2012
|
var eventMock = {
|
2006
|
-
target: _objectSpread({}, event.target, {
|
2013
|
+
target: _objectSpread(_objectSpread({}, event.target), {}, {
|
2007
2014
|
value: newValue
|
2008
2015
|
})
|
2009
2016
|
};
|
@@ -2016,9 +2023,10 @@ function (_React$Component) {
|
|
2016
2023
|
}, {
|
2017
2024
|
key: "saveSelectionToClipboard",
|
2018
2025
|
value: function saveSelectionToClipboard(event) {
|
2019
|
-
|
2020
|
-
|
2021
|
-
|
2026
|
+
// use the actual selectionStart & selectionEnd instead of the one stored
|
2027
|
+
// in state to ensure copy & paste also works on disabled inputs & textareas
|
2028
|
+
var selectionStart = this.inputElement.selectionStart;
|
2029
|
+
var selectionEnd = this.inputElement.selectionEnd;
|
2022
2030
|
var _this$props8 = this.props,
|
2023
2031
|
children = _this$props8.children,
|
2024
2032
|
value = _this$props8.value;
|
@@ -2060,9 +2068,9 @@ function (_React$Component) {
|
|
2060
2068
|
|
2061
2069
|
event.preventDefault();
|
2062
2070
|
this.saveSelectionToClipboard(event);
|
2063
|
-
var _this$
|
2064
|
-
selectionStart = _this$
|
2065
|
-
selectionEnd = _this$
|
2071
|
+
var _this$state4 = this.state,
|
2072
|
+
selectionStart = _this$state4.selectionStart,
|
2073
|
+
selectionEnd = _this$state4.selectionEnd;
|
2066
2074
|
var _this$props9 = this.props,
|
2067
2075
|
children = _this$props9.children,
|
2068
2076
|
value = _this$props9.value;
|
@@ -2072,7 +2080,7 @@ function (_React$Component) {
|
|
2072
2080
|
var newValue = [value.slice(0, markupStartIndex), value.slice(markupEndIndex)].join('');
|
2073
2081
|
var newPlainTextValue = getPlainText(newValue, config);
|
2074
2082
|
var eventMock = {
|
2075
|
-
target: _objectSpread({}, event.target, {
|
2083
|
+
target: _objectSpread(_objectSpread({}, event.target), {}, {
|
2076
2084
|
value: newPlainTextValue
|
2077
2085
|
})
|
2078
2086
|
};
|
@@ -2162,7 +2170,7 @@ var Mention = function Mention(_ref) {
|
|
2162
2170
|
className: className,
|
2163
2171
|
classNames: classNames
|
2164
2172
|
});
|
2165
|
-
return React__default.createElement("strong", styles, display);
|
2173
|
+
return /*#__PURE__*/React__default.createElement("strong", styles, display);
|
2166
2174
|
};
|
2167
2175
|
|
2168
2176
|
Mention.propTypes = {
|