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 CHANGED
@@ -45,27 +45,27 @@ export default function Example() {
45
45
 
46
46
  ## Props
47
47
 
48
- | Prop | Type | Default | Description |
49
- | -------------- | -------- | ---------------- | ------------------------------------------------------------------------------------------------------------------------ |
50
- | `value` | string | "" | The input value. |
51
- | `onChange` | function | - | This function is called when the value of the input changes. The first argument is the current value. |
52
- | `onResize` | function | - | This function is called when the width or the height of the input changes. The first argument is the current size value. |
53
- | `onClick` | function | - | This function is called when the input is clicked. |
54
- | `onFocus` | function | - | This function is called when the input has received focus. |
55
- | `cleanOnEnter` | boolean | false | Clean the input value after the keydown event. |
56
- | `onEnter` | function | - | This function is called after the keydown event is fired with the `keyCode === 13` returning the last value. |
57
- | `placeholder` | string | "Type a message" | Set the placeholder of the input. |
58
- | `height` | number | 40 | The total height of the area in which the element is rendered. |
59
- | `maxLength` | number | - | The maximum number of characters allowed in the element. |
60
- | `theme` | string | - | Set theme for emoji popup. Available values "light", "dark", "auto" |
61
- | `borderRadius` | number | 21 | The border radius of the input container. |
62
- | `borderColor` | string | "#EAEAEA" | The border color of the input container. |
63
- | `fontSize` | number | 15 | The font size of the placeholder and input container. |
64
- | `fontFamily` | string | "sans-serif" | The font family of the placeholder and input container. |
65
- | `shouldReturn` | boolean | - | Allows the user to use the `Shift + Enter` or `Ctrl + Enter` keyboard shortcut to create a new line. | |
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
- | `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. |
68
- | `keepOpened` | boolean | false | If set to true, the emoji picker will remain open after selecting an emoji. Defaults to false. |
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
 
@@ -0,0 +1,5 @@
1
+ /**
2
+ *
3
+ * @param {string} value
4
+ */
5
+ export function mockGetSelection(value: string): void;
@@ -0,0 +1,5 @@
1
+ export const mentionUsers: {
2
+ id: string;
3
+ name: string;
4
+ image: string;
5
+ }[];
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.trim() === "") {
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
- if (value.trim() === "") {
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 _input$innerText;
974
- if ((input === null || input === void 0 || (_input$innerText = input.innerText) === null || _input$innerText === void 0 ? void 0 : _input$innerText.trim()) === "") {
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 {import("emoji-mart").CustomEmoji[]=} customEmojis
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 {import("emoji-mart").CustomEmoji[]=} customEmojis
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 {import("emoji-mart").CustomEmoji[]=} customEmojis
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