react-mention-input 1.0.7 → 1.0.8
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/dist/MentionInput.css
CHANGED
|
@@ -1,61 +1,61 @@
|
|
|
1
|
-
.mention-container {
|
|
2
|
-
position: relative;
|
|
3
|
-
display: flex;
|
|
4
|
-
align-items: center;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
.mention-input {
|
|
8
|
-
width: 100%;
|
|
9
|
-
padding: 12px 16px;
|
|
10
|
-
border: 1px solid #ccc;
|
|
11
|
-
border-radius: 8px;
|
|
12
|
-
outline: none;
|
|
13
|
-
font-size: 16px;
|
|
14
|
-
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
|
15
|
-
transition: border 0.2s, box-shadow 0.2s;
|
|
16
|
-
}
|
|
17
|
-
.mention-input:focus {
|
|
18
|
-
border: 1px solid #007BFF;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
.send-button {
|
|
22
|
-
padding: 8px 12px;
|
|
23
|
-
border: none;
|
|
24
|
-
background-color: #007BFF;
|
|
25
|
-
color: #fff;
|
|
26
|
-
border-radius: 50%;
|
|
27
|
-
cursor: pointer;
|
|
28
|
-
font-size: 18px;
|
|
29
|
-
display: flex;
|
|
30
|
-
align-items: center;
|
|
31
|
-
justify-content: center;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
.suggestion-list {
|
|
35
|
-
position: absolute;
|
|
36
|
-
top: 100%;
|
|
37
|
-
left: 0;
|
|
38
|
-
right: 0;
|
|
39
|
-
background-color: #fff;
|
|
40
|
-
border: 1px solid #ddd;
|
|
41
|
-
border-radius: 4px;
|
|
42
|
-
list-style: none;
|
|
43
|
-
margin: 4px 0;
|
|
44
|
-
padding: 0;
|
|
45
|
-
max-height: 150px;
|
|
46
|
-
overflow-y: auto;
|
|
47
|
-
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
|
48
|
-
z-index: 1;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
.suggestion-item {
|
|
52
|
-
padding: 8px 12px;
|
|
53
|
-
cursor: pointer;
|
|
54
|
-
border-bottom: 1px solid #ddd;
|
|
55
|
-
transition: background-color 0.2s;
|
|
56
|
-
}
|
|
57
|
-
.suggestion-item:hover {
|
|
58
|
-
background-color: #f5f5f5;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/*# sourceMappingURL=MentionInput.css.map */
|
|
1
|
+
.mention-container {
|
|
2
|
+
position: relative;
|
|
3
|
+
display: flex;
|
|
4
|
+
align-items: center;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.mention-input {
|
|
8
|
+
width: 100%;
|
|
9
|
+
padding: 12px 16px;
|
|
10
|
+
border: 1px solid #ccc;
|
|
11
|
+
border-radius: 8px;
|
|
12
|
+
outline: none;
|
|
13
|
+
font-size: 16px;
|
|
14
|
+
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
|
15
|
+
transition: border 0.2s, box-shadow 0.2s;
|
|
16
|
+
}
|
|
17
|
+
.mention-input:focus {
|
|
18
|
+
border: 1px solid #007BFF;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.send-button {
|
|
22
|
+
padding: 8px 12px;
|
|
23
|
+
border: none;
|
|
24
|
+
background-color: #007BFF;
|
|
25
|
+
color: #fff;
|
|
26
|
+
border-radius: 50%;
|
|
27
|
+
cursor: pointer;
|
|
28
|
+
font-size: 18px;
|
|
29
|
+
display: flex;
|
|
30
|
+
align-items: center;
|
|
31
|
+
justify-content: center;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.suggestion-list {
|
|
35
|
+
position: absolute;
|
|
36
|
+
top: 100%;
|
|
37
|
+
left: 0;
|
|
38
|
+
right: 0;
|
|
39
|
+
background-color: #fff;
|
|
40
|
+
border: 1px solid #ddd;
|
|
41
|
+
border-radius: 4px;
|
|
42
|
+
list-style: none;
|
|
43
|
+
margin: 4px 0;
|
|
44
|
+
padding: 0;
|
|
45
|
+
max-height: 150px;
|
|
46
|
+
overflow-y: auto;
|
|
47
|
+
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
|
48
|
+
z-index: 1;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.suggestion-item {
|
|
52
|
+
padding: 8px 12px;
|
|
53
|
+
cursor: pointer;
|
|
54
|
+
border-bottom: 1px solid #ddd;
|
|
55
|
+
transition: background-color 0.2s;
|
|
56
|
+
}
|
|
57
|
+
.suggestion-item:hover {
|
|
58
|
+
background-color: #f5f5f5;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/*# sourceMappingURL=MentionInput.css.map */
|
package/dist/MentionInput.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import './MentionInput.
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
import './MentionInput.css';
|
|
3
3
|
interface User {
|
|
4
4
|
id: number;
|
|
5
5
|
name: string;
|
|
@@ -11,6 +11,7 @@ interface MentionInputProps {
|
|
|
11
11
|
inputClassName?: string;
|
|
12
12
|
suggestionListClassName?: string;
|
|
13
13
|
suggestionItemClassName?: string;
|
|
14
|
+
sendButtonIcon?: ReactNode;
|
|
14
15
|
onSendMessage?: (message: string) => void;
|
|
15
16
|
}
|
|
16
17
|
declare const MentionInput: React.FC<MentionInputProps>;
|
package/dist/MentionInput.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
|
-
import './MentionInput.
|
|
2
|
+
import './MentionInput.css'; // Import the SCSS file
|
|
3
3
|
var MentionInput = function (_a) {
|
|
4
|
-
var users = _a.users, placeholder = _a.placeholder, containerClassName = _a.containerClassName, inputClassName = _a.inputClassName, suggestionListClassName = _a.suggestionListClassName, suggestionItemClassName = _a.suggestionItemClassName, onSendMessage = _a.onSendMessage;
|
|
4
|
+
var users = _a.users, placeholder = _a.placeholder, containerClassName = _a.containerClassName, inputClassName = _a.inputClassName, suggestionListClassName = _a.suggestionListClassName, suggestionItemClassName = _a.suggestionItemClassName, sendButtonIcon = _a.sendButtonIcon, onSendMessage = _a.onSendMessage;
|
|
5
5
|
var _b = useState(''), inputValue = _b[0], setInputValue = _b[1];
|
|
6
6
|
var _c = useState([]), suggestions = _c[0], setSuggestions = _c[1];
|
|
7
7
|
var _d = useState(false), showSuggestions = _d[0], setShowSuggestions = _d[1];
|
|
@@ -41,7 +41,7 @@ var MentionInput = function (_a) {
|
|
|
41
41
|
};
|
|
42
42
|
return (React.createElement("div", { className: "mention-container ".concat(containerClassName || '') },
|
|
43
43
|
React.createElement("input", { type: "text", value: inputValue, onChange: handleInputChange, onKeyPress: handleKeyPress, placeholder: placeholder || 'Type a message...', className: "mention-input ".concat(inputClassName || '') }),
|
|
44
|
-
React.createElement("button", { onClick: handleSendMessage, className: "send-button" }, "
|
|
44
|
+
React.createElement("button", { onClick: handleSendMessage, className: "send-button" }, sendButtonIcon ? (typeof sendButtonIcon === 'string' ? (React.createElement("img", { src: sendButtonIcon, alt: "Send Icon", style: { width: '20px', height: '20px' } })) : (sendButtonIcon)) : ('➤')),
|
|
45
45
|
showSuggestions && (React.createElement("ul", { className: "suggestion-list ".concat(suggestionListClassName || '') }, suggestions.map(function (user) { return (React.createElement("li", { key: user.id, onClick: function () { return handleSuggestionClick(user); }, className: "suggestion-item ".concat(suggestionItemClassName || '') }, user.name)); })))));
|
|
46
46
|
};
|
|
47
47
|
export default MentionInput;
|
package/package.json
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-mention-input",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.8",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
8
|
-
"build": "tsc && npm run
|
|
9
|
-
"
|
|
10
|
-
"watch-css": "sass --watch src/MentionInput.scss:dist/MentionInput.css"
|
|
8
|
+
"build": "tsc && npm run copy-css",
|
|
9
|
+
"copy-css": "copyfiles -u 1 src/**/*.css dist"
|
|
11
10
|
},
|
|
12
11
|
"keywords": [
|
|
13
12
|
"mention",
|
|
@@ -28,6 +27,7 @@
|
|
|
28
27
|
"@types/node": "^22.9.0",
|
|
29
28
|
"@types/react": "^18.3.12",
|
|
30
29
|
"@types/react-dom": "^18.3.1",
|
|
30
|
+
"copyfiles": "^2.4.1",
|
|
31
31
|
"csstype": "^3.1.3",
|
|
32
32
|
"sass": "^1.81.0",
|
|
33
33
|
"typescript": "^5.6.3"
|
|
@@ -13,10 +13,9 @@
|
|
|
13
13
|
font-size: 16px;
|
|
14
14
|
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
|
15
15
|
transition: border 0.2s, box-shadow 0.2s;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
16
|
+
}
|
|
17
|
+
.mention-input:focus {
|
|
18
|
+
border: 1px solid #007BFF;
|
|
20
19
|
}
|
|
21
20
|
|
|
22
21
|
.send-button {
|
|
@@ -54,8 +53,9 @@
|
|
|
54
53
|
cursor: pointer;
|
|
55
54
|
border-bottom: 1px solid #ddd;
|
|
56
55
|
transition: background-color 0.2s;
|
|
57
|
-
|
|
58
|
-
&:hover {
|
|
59
|
-
background-color: #f5f5f5;
|
|
60
|
-
}
|
|
61
56
|
}
|
|
57
|
+
.suggestion-item:hover {
|
|
58
|
+
background-color: #f5f5f5;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/*# sourceMappingURL=MentionInput.css.map */
|
package/src/MentionInput.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React, { useState, ChangeEvent, KeyboardEvent } from 'react';
|
|
2
|
-
import './MentionInput.
|
|
1
|
+
import React, { useState, ChangeEvent, KeyboardEvent, ReactNode } from 'react';
|
|
2
|
+
import './MentionInput.css'; // Import the SCSS file
|
|
3
3
|
|
|
4
4
|
interface User {
|
|
5
5
|
id: number;
|
|
@@ -9,10 +9,11 @@ interface User {
|
|
|
9
9
|
interface MentionInputProps {
|
|
10
10
|
users: User[];
|
|
11
11
|
placeholder?: string;
|
|
12
|
-
containerClassName?: string;
|
|
13
|
-
inputClassName?: string;
|
|
14
|
-
suggestionListClassName?: string;
|
|
15
|
-
suggestionItemClassName?: string;
|
|
12
|
+
containerClassName?: string;
|
|
13
|
+
inputClassName?: string;
|
|
14
|
+
suggestionListClassName?: string;
|
|
15
|
+
suggestionItemClassName?: string;
|
|
16
|
+
sendButtonIcon?: ReactNode; // New prop for button icon (MUI icon or image path)
|
|
16
17
|
onSendMessage?: (message: string) => void;
|
|
17
18
|
}
|
|
18
19
|
|
|
@@ -23,6 +24,7 @@ const MentionInput: React.FC<MentionInputProps> = ({
|
|
|
23
24
|
inputClassName,
|
|
24
25
|
suggestionListClassName,
|
|
25
26
|
suggestionItemClassName,
|
|
27
|
+
sendButtonIcon,
|
|
26
28
|
onSendMessage,
|
|
27
29
|
}) => {
|
|
28
30
|
const [inputValue, setInputValue] = useState<string>('');
|
|
@@ -81,7 +83,15 @@ const MentionInput: React.FC<MentionInputProps> = ({
|
|
|
81
83
|
onClick={handleSendMessage}
|
|
82
84
|
className="send-button"
|
|
83
85
|
>
|
|
84
|
-
|
|
86
|
+
{sendButtonIcon ? (
|
|
87
|
+
typeof sendButtonIcon === 'string' ? (
|
|
88
|
+
<img src={sendButtonIcon} alt="Send Icon" style={{ width: '20px', height: '20px' }} />
|
|
89
|
+
) : (
|
|
90
|
+
sendButtonIcon
|
|
91
|
+
)
|
|
92
|
+
) : (
|
|
93
|
+
'➤'
|
|
94
|
+
)}
|
|
85
95
|
</button>
|
|
86
96
|
{showSuggestions && (
|
|
87
97
|
<ul className={`suggestion-list ${suggestionListClassName || ''}`}>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sourceRoot":"","sources":["../src/MentionInput.scss"],"names":[],"mappings":"AAAA;EACE;EACA;EACA;;;AAGF;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAEA;EACE;;;AAIJ;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;AAGF;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;AAGF;EACE;EACA;EACA;EACA;;AAEA;EACE","file":"MentionInput.css"}
|