react-input-emoji 5.6.11 → 5.7.1
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +43 -26
- package/dist/index.es.js +37 -6
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +36 -5
- package/dist/index.js.map +1 -1
- package/dist/src/index.d.ts +3 -0
- package/dist/src/text-input.d.ts +9 -1
- package/package.json +1 -1
package/README.md
CHANGED
@@ -1,22 +1,35 @@
|
|
1
|
-
# react-input-emoji
|
1
|
+
# react-input-emoji 😍 😜 😂 😛
|
2
2
|
|
3
|
-
> A React
|
3
|
+
> A powerful and customizable React component that seamlessly integrates emoji picker functionality into any input element, enhancing user experience.
|
4
4
|
|
5
5
|
[![NPM](https://img.shields.io/npm/v/react-input-emoji.svg)](https://www.npmjs.com/package/react-input-emoji) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)
|
6
6
|
|
7
7
|
<a href="https://cesarwbr.github.io/react-input-emoji/"><img width="500" src="https://cesarwbr.github.io/react-input-emoji/assets/images/screely-1566732641740.png" alt="Demo"></a>
|
8
8
|
|
9
|
-
## About
|
9
|
+
## 📝 About
|
10
10
|
|
11
|
-
InputEmoji provides a simple way to
|
11
|
+
InputEmoji provides a simple and intuitive way to add emoji picker functionality to any input element in your React application. With just a few lines of code, you can enable your users to easily select and insert emojis into their text input.
|
12
12
|
|
13
|
-
|
13
|
+
The component is highly customizable, allowing you to control the styling, positioning and behavior of the emoji picker. It also supports various useful features out of the box, such as:
|
14
|
+
|
15
|
+
- Easy integration with any input element
|
16
|
+
- Customizable appearance via props
|
17
|
+
- Built-in support for cleaning input on enter
|
18
|
+
- Callback functions for onChange, onClick and onEnter events
|
19
|
+
- Ability to keep the picker open after selecting an emoji
|
20
|
+
- Internationalization support for multiple languages
|
21
|
+
|
22
|
+
InputEmoji leverages the power of the emoji-mart library to provide a wide range of emojis across different categories and styles. The internationalization capabilities allow you to cater to users from diverse linguistic backgrounds, making your application more inclusive and accessible.
|
23
|
+
|
24
|
+
Whether you're building a chat app, social media platform, or any other application that could benefit from emoji input, InputEmoji has you covered. Give your users a fun and engaging way to express themselves with this powerful yet easy-to-use component!
|
25
|
+
|
26
|
+
## 📦 Install
|
14
27
|
|
15
28
|
```bash
|
16
29
|
npm install --save react-input-emoji
|
17
30
|
```
|
18
31
|
|
19
|
-
## Usage
|
32
|
+
## 🚀 Usage
|
20
33
|
|
21
34
|
After install import the react-input-emoji component to display your input with emoji support like so:
|
22
35
|
|
@@ -43,29 +56,33 @@ export default function Example() {
|
|
43
56
|
}
|
44
57
|
```
|
45
58
|
|
46
|
-
## Props
|
59
|
+
## 🧩 Props
|
47
60
|
|
48
61
|
| Prop | Type | Default | Description |
|
49
62
|
| ------------------ | ------------------------ | ---------------- | ------------------------------------------------------------------------------------------------------------------------ |
|
50
|
-
| `
|
51
|
-
| `
|
52
|
-
| `
|
53
|
-
| `
|
54
|
-
| `
|
55
|
-
| `
|
56
|
-
| `
|
57
|
-
| `
|
58
|
-
| `
|
59
|
-
| `
|
60
|
-
| `
|
61
|
-
| `
|
62
|
-
| `
|
63
|
-
| `
|
64
|
-
| `
|
65
|
-
| `
|
66
|
-
| `
|
67
|
-
| `
|
68
|
-
| `
|
63
|
+
| `background` | string | "white" | Specifies the background color of the input element. Accepts any valid CSS color value. |
|
64
|
+
| `borderColor` | string | "#EAEAEA" | Specifies the border color of the input container. Accepts any valid CSS color value. |
|
65
|
+
| `borderRadius` | number | 21 | Determines the border radius of the input container in pixels. Higher values result in more rounded corners. |
|
66
|
+
| `buttonElement` | HTMLElement | - | Allows you to provide a custom HTMLElement that, when clicked, triggers the emoji picker. If this prop is provided, the default emoji picker button is removed. |
|
67
|
+
| `buttonRef` | React.MutableRefObject | - | Accepts 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
|
+
| `cleanOnEnter` | boolean | false | When set to true, the input value will be cleared after the user presses the Enter key. |
|
69
|
+
| `color` | string | "black" | Specifies the color of the input text. Accepts any valid CSS color value. |
|
70
|
+
| `fontSize` | number | 15 | Controls the font size (in pixels) of the placeholder text and input value. |
|
71
|
+
| `fontFamily` | string | "sans-serif" | Specifies the font family for the placeholder text and input value. Accepts any valid CSS font-family value. |
|
72
|
+
| `height` | number | 40 | Sets the total height (in pixels) of the area in which the input element is rendered. |
|
73
|
+
| `keepOpened` | boolean | false | When set to true, the emoji picker will remain open after the user selects an emoji. Defaults to false. |
|
74
|
+
| `language` | string | 'en' | Specifies the language to be used for the emoji picker. Available values: 'ar', 'be', 'cs', 'de', 'en', 'es', 'fa', 'fi', 'fr', 'hi', 'it', 'ja', 'kr', 'pl', 'pt', 'ru', 'sa', 'tr', 'uk', 'vi', 'zh'. |
|
75
|
+
| `maxLength` | number | - | Limits the maximum number of characters that can be entered in the input element. |
|
76
|
+
| `onChange` | function | - | A callback function that is invoked whenever the input value changes. It receives the current value as its argument. |
|
77
|
+
| `onClick` | function | - | A callback function that is invoked when the input element is clicked. |
|
78
|
+
| `onEnter` | function | - | A callback function that is invoked when the Enter key is pressed. It receives the current input value as its argument. |
|
79
|
+
| `onFocus` | function | - | A callback function that is invoked when the input element receives focus. |
|
80
|
+
| `onResize` | function | - | A callback function that is invoked when the width or height of the input element changes. It receives the current size value as its argument. |
|
81
|
+
| `placeholder` | string | "Type a message" | Specifies the placeholder text to be displayed when the input is empty. |
|
82
|
+
| `placeholderColor` | string | "#C4C4C4" | Specifies the color of the placeholder text. Accepts any valid CSS color value. |
|
83
|
+
| `shouldReturn` | boolean | - | When set to true, allows the user to create a new line using the `Shift + Enter` or `Ctrl + Enter` keyboard shortcuts. |
|
84
|
+
| `theme` | string | - | Specifies the theme for the emoji picker popup. Available values: "light", "dark", "auto". |
|
85
|
+
| `value` | string | "" | The current value of the input element. |
|
69
86
|
|
70
87
|
## License
|
71
88
|
|
package/dist/index.es.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import React, { useRef, useCallback, useImperativeHandle, useEffect, forwardRef, useState, memo
|
1
|
+
import React, { useRef, useCallback, useImperativeHandle, useEffect, forwardRef, useMemo, useState, memo } from 'react';
|
2
2
|
import ReactDOM from 'react-dom';
|
3
3
|
|
4
4
|
function styleInject(css, ref) {
|
@@ -936,7 +936,7 @@ var _excluded = ["placeholder", "style", "tabIndex", "className", "onChange"];
|
|
936
936
|
* @property {(event: React.ClipboardEvent) => void} onCopy
|
937
937
|
* @property {(event: React.ClipboardEvent) => void} onPaste
|
938
938
|
* @property {string} placeholder
|
939
|
-
* @property {
|
939
|
+
* @property {{borderRadius?: number; color?: string; borderColor?: string; fontSize?: number; fontFamily?: string; background: string; placeholderColor?: string;}} style
|
940
940
|
* @property {number} tabIndex
|
941
941
|
* @property {string} className
|
942
942
|
* @property {(html: string) => void} onChange
|
@@ -1023,6 +1023,24 @@ var TextInput = function TextInput(_ref, ref) {
|
|
1023
1023
|
};
|
1024
1024
|
});
|
1025
1025
|
|
1026
|
+
/** @type {React.CSSProperties} */
|
1027
|
+
var placeholderStyle = useMemo(function () {
|
1028
|
+
var placeholderStyle = {};
|
1029
|
+
if (style.placeholderColor) {
|
1030
|
+
placeholderStyle.color = style.placeholderColor;
|
1031
|
+
}
|
1032
|
+
return placeholderStyle;
|
1033
|
+
}, [style === null || style === void 0 ? void 0 : style.placeholderColor]);
|
1034
|
+
|
1035
|
+
/** @type {React.CSSProperties} */
|
1036
|
+
var inputStyle = useMemo(function () {
|
1037
|
+
var inputStyle = {};
|
1038
|
+
if (style.color) {
|
1039
|
+
inputStyle.color = style.color;
|
1040
|
+
}
|
1041
|
+
return inputStyle;
|
1042
|
+
}, [style === null || style === void 0 ? void 0 : style.color]);
|
1043
|
+
|
1026
1044
|
/** @type {React.MutableRefObject<HTMLDivElement | null>} */
|
1027
1045
|
var placeholderRef = useRef(null);
|
1028
1046
|
/** @type {React.MutableRefObject<HTMLDivElement | null>} */
|
@@ -1086,7 +1104,8 @@ var TextInput = function TextInput(_ref, ref) {
|
|
1086
1104
|
onClick: handleClick
|
1087
1105
|
}, /*#__PURE__*/React.createElement("div", {
|
1088
1106
|
ref: placeholderRef,
|
1089
|
-
className: "react-input-emoji--placeholder"
|
1107
|
+
className: "react-input-emoji--placeholder",
|
1108
|
+
style: placeholderStyle
|
1090
1109
|
}, placeholder), /*#__PURE__*/React.createElement("div", {
|
1091
1110
|
ref: textInputRef,
|
1092
1111
|
onKeyDown: handleKeyDown,
|
@@ -1097,7 +1116,8 @@ var TextInput = function TextInput(_ref, ref) {
|
|
1097
1116
|
onBlur: props.onBlur,
|
1098
1117
|
onCopy: props.onCopy,
|
1099
1118
|
onPaste: props.onPaste,
|
1100
|
-
"data-testid": "react-input-emoji--input"
|
1119
|
+
"data-testid": "react-input-emoji--input",
|
1120
|
+
style: inputStyle
|
1101
1121
|
})));
|
1102
1122
|
};
|
1103
1123
|
var TextInputWithRef = /*#__PURE__*/forwardRef(TextInput);
|
@@ -4490,6 +4510,8 @@ function usePollute() {
|
|
4490
4510
|
* @property {boolean=} cleanOnEnter
|
4491
4511
|
* @property {(text: string) => void=} onEnter
|
4492
4512
|
* @property {string=} placeholder
|
4513
|
+
* @property {string=} placeholderColor
|
4514
|
+
* @property {string=} color
|
4493
4515
|
* @property {(size: {width: number, height: number}) => void=} onResize
|
4494
4516
|
* @property {() => void=} onClick
|
4495
4517
|
* @property {() => void=} onFocus
|
@@ -4506,6 +4528,7 @@ function usePollute() {
|
|
4506
4528
|
* @property {string=} borderColor
|
4507
4529
|
* @property {number=} fontSize
|
4508
4530
|
* @property {string=} fontFamily
|
4531
|
+
* @property {string=} background
|
4509
4532
|
* @property {{id: string; name: string; emojis: {id: string; name: string; keywords: string[], skins: {src: string}[]}}[]=} customEmojis
|
4510
4533
|
* @property {import('./types/types').Languages=} language
|
4511
4534
|
* @property {(text: string) => Promise<MetionUser[]>=} searchMention
|
@@ -4545,7 +4568,10 @@ function InputEmoji(props, ref) {
|
|
4545
4568
|
borderRadius = props.borderRadius,
|
4546
4569
|
borderColor = props.borderColor,
|
4547
4570
|
fontSize = props.fontSize,
|
4548
|
-
fontFamily = props.fontFamily
|
4571
|
+
fontFamily = props.fontFamily,
|
4572
|
+
background = props.background,
|
4573
|
+
placeholderColor = props.placeholderColor,
|
4574
|
+
color = props.color;
|
4549
4575
|
|
4550
4576
|
/** @type {React.MutableRefObject<import('./text-input').Ref | null>} */
|
4551
4577
|
var textInputRef = useRef(null);
|
@@ -4714,7 +4740,10 @@ function InputEmoji(props, ref) {
|
|
4714
4740
|
borderRadius: borderRadius,
|
4715
4741
|
borderColor: borderColor,
|
4716
4742
|
fontSize: fontSize,
|
4717
|
-
fontFamily: fontFamily
|
4743
|
+
fontFamily: fontFamily,
|
4744
|
+
background: background,
|
4745
|
+
placeholderColor: placeholderColor,
|
4746
|
+
color: color
|
4718
4747
|
},
|
4719
4748
|
tabIndex: tabIndex,
|
4720
4749
|
className: inputClass,
|
@@ -4739,8 +4768,10 @@ InputEmojiWithRef.defaultProps = {
|
|
4739
4768
|
placeholder: "Type a message",
|
4740
4769
|
borderRadius: 21,
|
4741
4770
|
borderColor: "#EAEAEA",
|
4771
|
+
color: "black",
|
4742
4772
|
fontSize: 15,
|
4743
4773
|
fontFamily: "sans-serif",
|
4774
|
+
background: "white",
|
4744
4775
|
tabIndex: 0,
|
4745
4776
|
shouldReturn: false,
|
4746
4777
|
customEmojis: [],
|