react-peer-chat 0.2.0 → 0.2.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/build/icons.js +17 -27
- package/build/index.css +12 -1
- package/build/index.d.ts +1 -1
- package/build/index.js +35 -44
- package/package.json +1 -1
package/build/icons.js
CHANGED
|
@@ -1,39 +1,29 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import './icons.css';
|
|
3
3
|
export function BiSolidMessageDetail(props) {
|
|
4
|
-
return
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
</svg>
|
|
8
|
-
</span>;
|
|
4
|
+
return React.createElement("span", Object.assign({}, props),
|
|
5
|
+
React.createElement("svg", { fill: "currentColor", width: '1.5rem', height: '1.5rem', className: 'scale-down' },
|
|
6
|
+
React.createElement("path", { d: "M20 2H4c-1.103 0-2 .894-2 1.992v12.016C2 17.106 2.897 18 4 18h3v4l6.351-4H20c1.103 0 2-.894 2-1.992V3.992A1.998 1.998 0 0 0 20 2zm-6 11H7v-2h7v2zm3-4H7V7h10v2z" })));
|
|
9
7
|
}
|
|
10
8
|
export function BiSolidMessageX(props) {
|
|
11
|
-
return
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
</svg>
|
|
15
|
-
</span>;
|
|
9
|
+
return React.createElement("span", Object.assign({}, props),
|
|
10
|
+
React.createElement("svg", { fill: "currentColor", width: '1.5rem', height: '1.5rem', className: 'scale-down' },
|
|
11
|
+
React.createElement("path", { d: "M20 2H4c-1.103 0-2 .894-2 1.992v12.016C2 17.106 2.897 18 4 18h3v4l6.351-4H20c1.103 0 2-.894 2-1.992V3.992A1.998 1.998 0 0 0 20 2zm-3.293 11.293-1.414 1.414L12 11.414l-3.293 3.293-1.414-1.414L10.586 10 7.293 6.707l1.414-1.414L12 8.586l3.293-3.293 1.414 1.414L13.414 10l3.293 3.293z" })));
|
|
16
12
|
}
|
|
17
13
|
export function GrSend(props) {
|
|
18
|
-
return
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
</svg>
|
|
22
|
-
</span>;
|
|
14
|
+
return React.createElement("span", Object.assign({}, props),
|
|
15
|
+
React.createElement("svg", { fill: "currentColor", width: '1.5rem', height: '1.5rem', className: 'scale-down invert' },
|
|
16
|
+
React.createElement("path", { fill: "none", stroke: "#000", strokeWidth: 2, d: "M22,3 L2,11 L20.5,19 L22,3 Z M10,20.5 L13,16 M15.5,9.5 L9,14 L9.85884537,20.0119176 C9.93680292,20.5576204 10.0751625,20.5490248 10.1651297,20.009222 L11,15 L15.5,9.5 Z" })));
|
|
23
17
|
}
|
|
24
18
|
export function BsFillMicFill(props) {
|
|
25
|
-
return
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
</svg>
|
|
30
|
-
</span>;
|
|
19
|
+
return React.createElement("span", Object.assign({}, props),
|
|
20
|
+
React.createElement("svg", { fill: "currentColor", width: '1rem', height: '1rem' },
|
|
21
|
+
React.createElement("path", { d: "M5 3a3 3 0 0 1 6 0v5a3 3 0 0 1-6 0V3z" }),
|
|
22
|
+
React.createElement("path", { d: "M3.5 6.5A.5.5 0 0 1 4 7v1a4 4 0 0 0 8 0V7a.5.5 0 0 1 1 0v1a5 5 0 0 1-4.5 4.975V15h3a.5.5 0 0 1 0 1h-7a.5.5 0 0 1 0-1h3v-2.025A5 5 0 0 1 3 8V7a.5.5 0 0 1 .5-.5z" })));
|
|
31
23
|
}
|
|
32
24
|
export function BsFillMicMuteFill(props) {
|
|
33
|
-
return
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
</svg>
|
|
38
|
-
</span>;
|
|
25
|
+
return React.createElement("span", Object.assign({}, props),
|
|
26
|
+
React.createElement("svg", { fill: "currentColor", width: '1rem', height: '1rem' },
|
|
27
|
+
React.createElement("path", { d: "M13 8c0 .564-.094 1.107-.266 1.613l-.814-.814A4.02 4.02 0 0 0 12 8V7a.5.5 0 0 1 1 0v1zm-5 4c.818 0 1.578-.245 2.212-.667l.718.719a4.973 4.973 0 0 1-2.43.923V15h3a.5.5 0 0 1 0 1h-7a.5.5 0 0 1 0-1h3v-2.025A5 5 0 0 1 3 8V7a.5.5 0 0 1 1 0v1a4 4 0 0 0 4 4zm3-9v4.879L5.158 2.037A3.001 3.001 0 0 1 11 3z" }),
|
|
28
|
+
React.createElement("path", { d: "M9.486 10.607 5 6.12V8a3 3 0 0 0 4.486 2.607zm-7.84-9.253 12 12 .708-.708-12-12-.708.708z" })));
|
|
39
29
|
}
|
package/build/index.css
CHANGED
|
@@ -28,8 +28,19 @@
|
|
|
28
28
|
outline: 2px solid white;
|
|
29
29
|
border-radius: 0.25rem;
|
|
30
30
|
font-size: smaller;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.position-left {
|
|
34
|
+
left: 0.5rem;
|
|
35
|
+
translate: -100%;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.position-center {
|
|
31
39
|
translate: -50%;
|
|
32
|
-
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.position-right {
|
|
43
|
+
left: 0.5rem;
|
|
33
44
|
}
|
|
34
45
|
|
|
35
46
|
.message-container {
|
package/build/index.d.ts
CHANGED
|
@@ -30,5 +30,5 @@ type Props = {
|
|
|
30
30
|
children?: ReactNode | ((childrenOptions: ChildrenOptions) => ReactNode);
|
|
31
31
|
} & DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>;
|
|
32
32
|
export default function Chat({ name, peerId, remotePeerId, peerOptions, text, voice, dialogOptions, onError, children, ...props }: Props): React.JSX.Element;
|
|
33
|
-
export declare const
|
|
33
|
+
export declare const clearChat: () => void;
|
|
34
34
|
export {};
|
package/build/index.js
CHANGED
|
@@ -132,48 +132,39 @@ export default function Chat(_a) {
|
|
|
132
132
|
if (container)
|
|
133
133
|
container.scrollTop = container.scrollHeight;
|
|
134
134
|
}, [dialog, opponentName, messages]);
|
|
135
|
-
return
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
:
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
</div>
|
|
170
|
-
</dialog>
|
|
171
|
-
</div>}
|
|
172
|
-
{voice && <div>
|
|
173
|
-
{audio ? <BsFillMicFill title="Turn mic off" onClick={() => setAudio(false)}/> : <BsFillMicMuteFill title="Turn mic on" onClick={() => setAudio(true)}/>}
|
|
174
|
-
</div>}
|
|
175
|
-
</>}
|
|
176
|
-
{voice && audio && <audio ref={streamRef} autoPlay style={{ display: 'none' }}/>}
|
|
177
|
-
</div>;
|
|
135
|
+
return React.createElement("div", Object.assign({ className: 'main' }, props),
|
|
136
|
+
typeof children === 'function' ? children({ notification, messages, addMessage, dialogRef, audio, setAudio }) : React.createElement(React.Fragment, null,
|
|
137
|
+
text && React.createElement("div", null,
|
|
138
|
+
dialog ? React.createElement(BiSolidMessageX, { onClick: () => setDialog(false) })
|
|
139
|
+
: React.createElement("div", { className: 'notification' },
|
|
140
|
+
React.createElement(BiSolidMessageDetail, { onClick: () => {
|
|
141
|
+
setNotification(false);
|
|
142
|
+
setDialog(true);
|
|
143
|
+
} }),
|
|
144
|
+
notification && React.createElement("span", { className: 'badge' })),
|
|
145
|
+
React.createElement("dialog", { ref: dialogRef, className: `${dialog ? 'dialog' : ''} position-${(dialogOptions === null || dialogOptions === void 0 ? void 0 : dialogOptions.position) || 'center'}`, style: dialogOptions === null || dialogOptions === void 0 ? void 0 : dialogOptions.style },
|
|
146
|
+
React.createElement("div", { className: 'heading' }, "Chat"),
|
|
147
|
+
React.createElement("hr", null),
|
|
148
|
+
React.createElement("div", null,
|
|
149
|
+
React.createElement("div", { ref: containerRef, className: 'message-container' }, opponentName && messages.map(({ id, text }, i) => React.createElement("div", { key: i },
|
|
150
|
+
React.createElement("strong", null,
|
|
151
|
+
id === peerId ? 'You' : opponentName,
|
|
152
|
+
": "),
|
|
153
|
+
React.createElement("span", null, text)))),
|
|
154
|
+
React.createElement("hr", null),
|
|
155
|
+
React.createElement("form", { className: 'input-container', onSubmit: e => {
|
|
156
|
+
var _a;
|
|
157
|
+
e.preventDefault();
|
|
158
|
+
const text = (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.value;
|
|
159
|
+
if (text) {
|
|
160
|
+
inputRef.current.value = '';
|
|
161
|
+
addMessage({ id: peerId, text }, true);
|
|
162
|
+
}
|
|
163
|
+
} },
|
|
164
|
+
React.createElement("input", { ref: inputRef, className: 'input', placeholder: 'Enter a message' }),
|
|
165
|
+
React.createElement("button", { type: 'submit' },
|
|
166
|
+
React.createElement(GrSend, null)))))),
|
|
167
|
+
voice && React.createElement("div", null, audio ? React.createElement(BsFillMicFill, { title: "Turn mic off", onClick: () => setAudio(false) }) : React.createElement(BsFillMicMuteFill, { title: "Turn mic on", onClick: () => setAudio(true) }))),
|
|
168
|
+
voice && audio && React.createElement("audio", { ref: streamRef, autoPlay: true, style: { display: 'none' } }));
|
|
178
169
|
}
|
|
179
|
-
export const
|
|
170
|
+
export const clearChat = () => removeStorage('rpc-messages');
|