react-input-emoji 5.2.1 → 5.4.1
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/index.es.js +49 -18
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +48 -17
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
@@ -64,6 +64,7 @@ export default function Example() {
|
|
64
64
|
| `fontFamily` | string | "sans-serif" | The font family of the placeholder and input container. |
|
65
65
|
| `shouldReturn` | boolean | - | Allows the user to use the `Shift + Enter` or `Ctrl + Enter` keyboard shortcut to create a new line. | |
|
66
66
|
| `buttonElement` | HTMLElement | - | An HTMLElement that, when clicked, triggers the emoji picker. If this prop is provided, the default emoji picker button is removed. |
|
67
|
+
| `keepOpened` | boolean | false | If set to true, the emoji picker will remain open after selecting an emoji. Defaults to false. |
|
67
68
|
|
68
69
|
## License
|
69
70
|
|
package/dist/index.es.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import React, { useRef, useCallback, useImperativeHandle, useEffect, forwardRef, useState,
|
1
|
+
import React, { useRef, useCallback, useImperativeHandle, useEffect, forwardRef, useState, memo, useMemo } from 'react';
|
2
2
|
import ReactDOM from 'react-dom';
|
3
3
|
import t from 'prop-types';
|
4
4
|
|
@@ -3925,6 +3925,7 @@ function $e5534fc185f7111e$export$2e2bcd8739ae039(props) {
|
|
3925
3925
|
* @property {function(import("../types/types").EmojiMartItem): void} onSelectEmoji
|
3926
3926
|
* @property {boolean} disableRecent
|
3927
3927
|
* @property {import("emoji-mart").CustomEmoji[]=} customEmojis
|
3928
|
+
* @property {import('../types/types').Languages=} language
|
3928
3929
|
*/
|
3929
3930
|
|
3930
3931
|
/**
|
@@ -3937,7 +3938,8 @@ function EmojiPicker(props) {
|
|
3937
3938
|
var theme = props.theme,
|
3938
3939
|
onSelectEmoji = props.onSelectEmoji,
|
3939
3940
|
disableRecent = props.disableRecent,
|
3940
|
-
customEmojis = props.customEmojis
|
3941
|
+
customEmojis = props.customEmojis,
|
3942
|
+
language = props.language;
|
3941
3943
|
/** @type {string[]} */
|
3942
3944
|
|
3943
3945
|
var categories = useMemo(function () {
|
@@ -3951,6 +3953,13 @@ function EmojiPicker(props) {
|
|
3951
3953
|
categoryies = [].concat(_toConsumableArray(categoryies), ["people", "nature", "foods", "activity", "places", "objects", "symbols", "flags"]);
|
3952
3954
|
return categoryies;
|
3953
3955
|
}, [disableRecent]);
|
3956
|
+
var i18n = useMemo(function () {
|
3957
|
+
if (!language) {
|
3958
|
+
return undefined;
|
3959
|
+
}
|
3960
|
+
|
3961
|
+
return require("@emoji-mart/data/i18n/".concat(language !== null && language !== void 0 ? language : 'en', ".json"));
|
3962
|
+
}, [language]);
|
3954
3963
|
return /*#__PURE__*/React.createElement($e5534fc185f7111e$export$2e2bcd8739ae039, {
|
3955
3964
|
data: undefined,
|
3956
3965
|
theme: theme,
|
@@ -3958,16 +3967,11 @@ function EmojiPicker(props) {
|
|
3958
3967
|
onEmojiSelect: onSelectEmoji,
|
3959
3968
|
custom: customEmojis,
|
3960
3969
|
categories: categories,
|
3961
|
-
set: "apple"
|
3970
|
+
set: "apple",
|
3971
|
+
i18n: i18n
|
3962
3972
|
});
|
3963
3973
|
}
|
3964
3974
|
|
3965
|
-
EmojiPicker.propTypes = {
|
3966
|
-
theme: t.oneOf(["light", "dark", "auto"]),
|
3967
|
-
onSelectEmoji: t.func,
|
3968
|
-
disableRecent: t.bool,
|
3969
|
-
customEmojis: t.array
|
3970
|
-
};
|
3971
3975
|
var EmojiPicker$1 = /*#__PURE__*/memo(EmojiPicker);
|
3972
3976
|
|
3973
3977
|
/**
|
@@ -3978,6 +3982,7 @@ var EmojiPicker$1 = /*#__PURE__*/memo(EmojiPicker);
|
|
3978
3982
|
* @property {boolean} disableRecent
|
3979
3983
|
* @property {import("emoji-mart").CustomEmoji[]=} customEmojis
|
3980
3984
|
* @property {('above' | 'below')=} position
|
3985
|
+
* @property {import('../types/types').Languages=} language
|
3981
3986
|
*/
|
3982
3987
|
|
3983
3988
|
/**
|
@@ -3992,7 +3997,8 @@ function EmojiPickerContainer(_ref) {
|
|
3992
3997
|
handleSelectEmoji = _ref.handleSelectEmoji,
|
3993
3998
|
disableRecent = _ref.disableRecent,
|
3994
3999
|
customEmojis = _ref.customEmojis,
|
3995
|
-
position = _ref.position
|
4000
|
+
position = _ref.position,
|
4001
|
+
language = _ref.language;
|
3996
4002
|
return /*#__PURE__*/React.createElement("div", {
|
3997
4003
|
className: "react-emoji-picker--container"
|
3998
4004
|
}, showPicker && /*#__PURE__*/React.createElement("div", {
|
@@ -4009,7 +4015,8 @@ function EmojiPickerContainer(_ref) {
|
|
4009
4015
|
theme: theme,
|
4010
4016
|
onSelectEmoji: handleSelectEmoji,
|
4011
4017
|
disableRecent: disableRecent,
|
4012
|
-
customEmojis: customEmojis
|
4018
|
+
customEmojis: customEmojis,
|
4019
|
+
language: language
|
4013
4020
|
}))));
|
4014
4021
|
}
|
4015
4022
|
|
@@ -4032,6 +4039,7 @@ var EMOJI_PICKER_CONTAINER_HEIGHT = 435;
|
|
4032
4039
|
* @property {(fn: PolluteFn) => void} addPolluteFn
|
4033
4040
|
* @property {(html: string) => void} appendContent
|
4034
4041
|
* @property {HTMLDivElement=} buttonElement
|
4042
|
+
* @property {import('../types/types').Languages=} language
|
4035
4043
|
*/
|
4036
4044
|
// eslint-disable-next-line valid-jsdoc
|
4037
4045
|
|
@@ -4045,7 +4053,8 @@ var EmojiPickerWrapper = function EmojiPickerWrapper(props) {
|
|
4045
4053
|
addSanitizeFn = props.addSanitizeFn,
|
4046
4054
|
addPolluteFn = props.addPolluteFn,
|
4047
4055
|
appendContent = props.appendContent,
|
4048
|
-
buttonElement = props.buttonElement
|
4056
|
+
buttonElement = props.buttonElement,
|
4057
|
+
language = props.language;
|
4049
4058
|
|
4050
4059
|
var _useState = useState(false),
|
4051
4060
|
_useState2 = _slicedToArray(_useState, 2),
|
@@ -4156,7 +4165,8 @@ var EmojiPickerWrapper = function EmojiPickerWrapper(props) {
|
|
4156
4165
|
handleSelectEmoji: handleSelectEmoji,
|
4157
4166
|
disableRecent: disableRecent,
|
4158
4167
|
customEmojis: customEmojis,
|
4159
|
-
position: emojiPickerPosition
|
4168
|
+
position: emojiPickerPosition,
|
4169
|
+
language: language
|
4160
4170
|
}), /*#__PURE__*/React.createElement(EmojiPickerButton, {
|
4161
4171
|
showPicker: showPicker,
|
4162
4172
|
toggleShowPicker: toggleShowPicker,
|
@@ -4167,7 +4177,8 @@ var EmojiPickerWrapper = function EmojiPickerWrapper(props) {
|
|
4167
4177
|
handleSelectEmoji: handleSelectEmoji,
|
4168
4178
|
disableRecent: disableRecent,
|
4169
4179
|
customEmojis: customEmojis,
|
4170
|
-
position: emojiPickerPosition
|
4180
|
+
position: emojiPickerPosition,
|
4181
|
+
language: language
|
4171
4182
|
}), /*#__PURE__*/React.createElement(EmojiPickerButton, {
|
4172
4183
|
showPicker: showPicker,
|
4173
4184
|
toggleShowPicker: toggleShowPicker
|
@@ -4827,6 +4838,7 @@ function usePollute() {
|
|
4827
4838
|
* @property {number} fontSize
|
4828
4839
|
* @property {string} fontFamily
|
4829
4840
|
* @property {{id: string; name: string; emojis: {id: string; name: string; keywords: string[], skins: {src: string}[]}}[]=} customEmojis
|
4841
|
+
* @property {import('./types/types').Languages=} language
|
4830
4842
|
* @property {(text: string) => Promise<MetionUser[]>=} searchMention
|
4831
4843
|
* @property {HTMLDivElement=} buttonElement
|
4832
4844
|
*/
|
@@ -4857,6 +4869,7 @@ function InputEmoji(props, ref) {
|
|
4857
4869
|
tabIndex = props.tabIndex,
|
4858
4870
|
value = props.value,
|
4859
4871
|
customEmojis = props.customEmojis,
|
4872
|
+
language = props.language,
|
4860
4873
|
searchMention = props.searchMention,
|
4861
4874
|
buttonElement = props.buttonElement,
|
4862
4875
|
borderRadius = props.borderRadius,
|
@@ -5008,8 +5021,24 @@ function InputEmoji(props, ref) {
|
|
5008
5021
|
|
5009
5022
|
|
5010
5023
|
function handleCopy(event) {
|
5011
|
-
|
5012
|
-
|
5024
|
+
var selection = window.getSelection();
|
5025
|
+
|
5026
|
+
if (selection !== null) {
|
5027
|
+
var selectedText = '';
|
5028
|
+
|
5029
|
+
if (selection.anchorNode && selection.anchorNode.nodeType === Node.ELEMENT_NODE) {
|
5030
|
+
// @ts-ignore
|
5031
|
+
selectedText = selection.anchorNode.innerHTML;
|
5032
|
+
} else if (selection.anchorNode && selection.anchorNode.nodeType === Node.TEXT_NODE) {
|
5033
|
+
var _selection$anchorNode;
|
5034
|
+
|
5035
|
+
selectedText = (_selection$anchorNode = selection.anchorNode.textContent) !== null && _selection$anchorNode !== void 0 ? _selection$anchorNode : '';
|
5036
|
+
}
|
5037
|
+
|
5038
|
+
var text = replaceAllTextEmojiToString(selectedText);
|
5039
|
+
event.clipboardData.setData("text", text);
|
5040
|
+
event.preventDefault();
|
5041
|
+
}
|
5013
5042
|
}
|
5014
5043
|
/**
|
5015
5044
|
* Handle past on input
|
@@ -5065,7 +5094,8 @@ function InputEmoji(props, ref) {
|
|
5065
5094
|
addSanitizeFn: addSanitizeFn,
|
5066
5095
|
addPolluteFn: addPolluteFn,
|
5067
5096
|
appendContent: appendContent,
|
5068
|
-
buttonElement: buttonElement
|
5097
|
+
buttonElement: buttonElement,
|
5098
|
+
language: language
|
5069
5099
|
}));
|
5070
5100
|
}
|
5071
5101
|
|
@@ -5082,7 +5112,8 @@ InputEmojiWithRef.defaultProps = {
|
|
5082
5112
|
fontFamily: "sans-serif",
|
5083
5113
|
tabIndex: 0,
|
5084
5114
|
shouldReturn: false,
|
5085
|
-
customEmojis: []
|
5115
|
+
customEmojis: [],
|
5116
|
+
language: undefined
|
5086
5117
|
};
|
5087
5118
|
|
5088
5119
|
export { InputEmojiWithRef as default };
|