react-input-emoji 5.6.1 → 5.6.3
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +21 -21
- package/dist/__mocks__/getSelectionMock.d.ts +5 -0
- package/dist/fixtures/examples.d.ts +5 -0
- package/dist/index.es.js +11 -15
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +11 -16
- package/dist/index.js.map +1 -1
- package/dist/src/components/emoji-picker-button.d.ts +21 -0
- package/dist/src/components/emoji-picker-container.d.ts +26 -0
- package/dist/src/components/emoji-picker-wrapper.d.ts +37 -0
- package/dist/src/components/emoji-picker.d.ts +23 -0
- package/dist/src/components/mention-user-list.d.ts +15 -0
- package/dist/src/components/mention-wrapper.d.ts +29 -0
- package/dist/src/components/mention-wrapper.test.d.ts +1 -0
- package/dist/src/hooks/use-emit.d.ts +10 -0
- package/dist/src/hooks/use-event-listeners.d.ts +9 -0
- package/dist/src/hooks/use-event-listeners.test.d.ts +1 -0
- package/dist/src/hooks/use-expose.d.ts +18 -0
- package/dist/src/hooks/use-mention.d.ts +17 -0
- package/dist/src/hooks/use-mention.test.d.ts +1 -0
- package/dist/src/hooks/use-sanitize.d.ts +19 -0
- package/dist/src/hooks/user-pollute.d.ts +9 -0
- package/dist/src/index.d.ts +48 -0
- package/dist/src/text-input.d.ts +30 -0
- package/dist/src/utils/emoji-utils.d.ts +20 -0
- package/dist/src/utils/input-event-utils.d.ts +95 -0
- package/dist/src/utils/mention-utils.d.ts +15 -0
- package/dist/src/utils/observer.d.ts +5 -0
- package/dist/src/utils/use-debounce.d.ts +1 -0
- package/package.json +5 -5
package/README.md
CHANGED
@@ -45,27 +45,27 @@ export default function Example() {
|
|
45
45
|
|
46
46
|
## Props
|
47
47
|
|
48
|
-
| Prop
|
49
|
-
|
|
50
|
-
| `
|
51
|
-
| `
|
52
|
-
| `
|
53
|
-
| `
|
54
|
-
| `
|
55
|
-
| `
|
56
|
-
| `
|
57
|
-
| `
|
58
|
-
| `
|
59
|
-
| `maxLength`
|
60
|
-
| `
|
61
|
-
| `
|
62
|
-
| `
|
63
|
-
| `
|
64
|
-
| `
|
65
|
-
| `
|
66
|
-
| `
|
67
|
-
| `
|
68
|
-
| `
|
48
|
+
| Prop | Type | Default | Description |
|
49
|
+
| ------------------ | ------------------------ | ---------------- | ------------------------------------------------------------------------------------------------------------------------ |
|
50
|
+
| `borderColor` | string | "#EAEAEA" | The border color of the input container. |
|
51
|
+
| `borderRadius` | number | 21 | The border radius of the input container. |
|
52
|
+
| `buttonElement` | HTMLElement | - | An HTMLElement that, when clicked, triggers the emoji picker. If this prop is provided, the default emoji picker button is removed. |
|
53
|
+
| `buttonRef` | React.MutableRefObject | - | A React mutable ref object that, when referenced, triggers the emoji picker. If this prop is provided, the default emoji picker button is removed. |
|
54
|
+
| `cleanOnEnter` | boolean | false | Clean the input value after the keydown event. |
|
55
|
+
| `fontSize` | number | 15 | The font size of the placeholder and input container. |
|
56
|
+
| `fontFamily` | string | "sans-serif" | The font family of the placeholder and input container. |
|
57
|
+
| `height` | number | 40 | The total height of the area in which the element is rendered. |
|
58
|
+
| `keepOpened` | boolean | false | If set to true, the emoji picker will remain open after selecting an emoji. Defaults to false. |
|
59
|
+
| `maxLength` | number | - | The maximum number of characters allowed in the element. |
|
60
|
+
| `onChange` | function | - | This function is called when the value of the input changes. The first argument is the current value. |
|
61
|
+
| `onClick` | function | - | This function is called when the input is clicked. |
|
62
|
+
| `onEnter` | function | - | This function is called after the keydown event is fired with the `keyCode === 13` returning the last value. |
|
63
|
+
| `onFocus` | function | - | This function is called when the input has received focus. |
|
64
|
+
| `onResize` | function | - | This function is called when the width or the height of the input changes. The first argument is the current size value. |
|
65
|
+
| `placeholder` | string | "Type a message" | Set the placeholder of the input. |
|
66
|
+
| `shouldReturn` | boolean | - | Allows the user to use the `Shift + Enter` or `Ctrl + Enter` keyboard shortcut to create a new line. |
|
67
|
+
| `theme` | string | - | Set theme for emoji popup. Available values "light", "dark", "auto" |
|
68
|
+
| `value` | string | "" | The input value. |
|
69
69
|
|
70
70
|
## License
|
71
71
|
|
package/dist/index.es.js
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
import React, { useRef, useCallback, useImperativeHandle, useEffect, forwardRef, useState, memo, useMemo } from 'react';
|
2
2
|
import ReactDOM from 'react-dom';
|
3
|
-
import t from 'prop-types';
|
4
3
|
|
5
4
|
function styleInject(css, ref) {
|
6
5
|
if (ref === void 0) ref = {};
|
@@ -515,7 +514,7 @@ function replaceAllTextEmojis(text) {
|
|
515
514
|
allEmojis = _toConsumableArray(new Set(allEmojis)); // remove duplicates
|
516
515
|
|
517
516
|
allEmojis.forEach(function (emoji) {
|
518
|
-
text = replaceAll(text, emoji, getInputEmojiHTML(emoji));
|
517
|
+
text = replaceAll(text, emoji, getInputEmojiHTML('', emoji));
|
519
518
|
});
|
520
519
|
}
|
521
520
|
return text;
|
@@ -759,7 +758,7 @@ function useExpose(_ref) {
|
|
759
758
|
textInputRef = _ref.textInputRef,
|
760
759
|
setValue = _ref.setValue,
|
761
760
|
emitChange = _ref.emitChange;
|
762
|
-
var _useSanitize = useSanitize(),
|
761
|
+
var _useSanitize = useSanitize(false),
|
763
762
|
sanitize = _useSanitize.sanitize,
|
764
763
|
sanitizedTextRef = _useSanitize.sanitizedTextRef;
|
765
764
|
useImperativeHandle(ref, function () {
|
@@ -874,7 +873,7 @@ var TextInput = function TextInput(_ref, ref) {
|
|
874
873
|
if (textInputRef.current) {
|
875
874
|
textInputRef.current.focus();
|
876
875
|
}
|
877
|
-
if (textInputRef.current && placeholderRef.current && textInputRef.current.innerHTML
|
876
|
+
if (textInputRef.current && placeholderRef.current && replaceAllTextEmojiToString(textInputRef.current.innerHTML) === "") {
|
878
877
|
placeholderRef.current.style.visibility = "visible";
|
879
878
|
} else if (placeholderRef.current) {
|
880
879
|
placeholderRef.current.style.visibility = "hidden";
|
@@ -888,7 +887,8 @@ var TextInput = function TextInput(_ref, ref) {
|
|
888
887
|
textInputRef.current.innerHTML = value;
|
889
888
|
}
|
890
889
|
if (placeholderRef.current) {
|
891
|
-
|
890
|
+
var text = replaceAllTextEmojiToString(value);
|
891
|
+
if (text === "") {
|
892
892
|
placeholderRef.current.style.visibility = "visible";
|
893
893
|
} else {
|
894
894
|
placeholderRef.current.style.visibility = "hidden";
|
@@ -969,9 +969,9 @@ var TextInput = function TextInput(_ref, ref) {
|
|
969
969
|
function handleKeyUp(event) {
|
970
970
|
props.onKeyUp(event);
|
971
971
|
var input = textInputRef.current;
|
972
|
-
if (placeholderRef.current) {
|
973
|
-
var
|
974
|
-
if (
|
972
|
+
if (placeholderRef.current && input) {
|
973
|
+
var text = replaceAllTextEmojiToString(input.innerHTML);
|
974
|
+
if (text === "") {
|
975
975
|
placeholderRef.current.style.visibility = "visible";
|
976
976
|
} else {
|
977
977
|
placeholderRef.current.style.visibility = "hidden";
|
@@ -3493,14 +3493,13 @@ function $e5534fc185f7111e$export$2e2bcd8739ae039(props) {
|
|
3493
3493
|
* @property {'light' | 'dark' | 'auto'} theme
|
3494
3494
|
* @property {function(import("../types/types").EmojiMartItem): void} onSelectEmoji
|
3495
3495
|
* @property {boolean} disableRecent
|
3496
|
-
* @property {
|
3496
|
+
* @property {any[]=} customEmojis
|
3497
3497
|
* @property {import('../types/types').Languages=} language
|
3498
3498
|
*/
|
3499
3499
|
|
3500
3500
|
/**
|
3501
3501
|
* Emoji Picker Component
|
3502
3502
|
* @param {Props} props
|
3503
|
-
* @return {React.FC}
|
3504
3503
|
*/
|
3505
3504
|
function EmojiPicker(props) {
|
3506
3505
|
var theme = props.theme,
|
@@ -3544,7 +3543,7 @@ var EmojiPicker$1 = /*#__PURE__*/memo(EmojiPicker);
|
|
3544
3543
|
* @property {'light' | 'dark' | 'auto'} theme
|
3545
3544
|
* @property {(emoji: import("../types/types").EmojiMartItem) => void} handleSelectEmoji
|
3546
3545
|
* @property {boolean} disableRecent
|
3547
|
-
* @property {
|
3546
|
+
* @property {any[]=} customEmojis
|
3548
3547
|
* @property {('above' | 'below')=} position
|
3549
3548
|
* @property {import('../types/types').Languages=} language
|
3550
3549
|
*/
|
@@ -3598,7 +3597,7 @@ var EMOJI_PICKER_CONTAINER_HEIGHT = 435;
|
|
3598
3597
|
* @property {'light' | 'dark' | 'auto'} theme
|
3599
3598
|
* @property {boolean} keepOpened
|
3600
3599
|
* @property {boolean} disableRecent
|
3601
|
-
* @property {
|
3600
|
+
* @property {any[]=} customEmojis
|
3602
3601
|
* @property {(fn: SanitizeFn) => void} addSanitizeFn
|
3603
3602
|
* @property {(fn: PolluteFn) => void} addPolluteFn
|
3604
3603
|
* @property {(html: string) => void} appendContent
|
@@ -4074,9 +4073,6 @@ var MentionUserList = function MentionUserList(_ref, ref) {
|
|
4074
4073
|
}));
|
4075
4074
|
};
|
4076
4075
|
var MentionUserListWithRef = /*#__PURE__*/forwardRef(MentionUserList);
|
4077
|
-
MentionUserListWithRef.propTypes = {
|
4078
|
-
users: t.array.isRequired
|
4079
|
-
};
|
4080
4076
|
|
4081
4077
|
/**
|
4082
4078
|
* @typedef {import('../types/types').MentionUser} MetionUser
|