react-peer-chat 0.2.1 → 0.2.2

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.d.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import React from "react";
2
- import './icons.css';
3
2
  export declare function BiSolidMessageDetail(props: React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>): React.JSX.Element;
4
3
  export declare function BiSolidMessageX(props: React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>): React.JSX.Element;
5
4
  export declare function GrSend(props: React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>): React.JSX.Element;
package/build/icons.js CHANGED
@@ -1,18 +1,17 @@
1
1
  import React from "react";
2
- import './icons.css';
3
2
  export function BiSolidMessageDetail(props) {
4
3
  return React.createElement("span", Object.assign({}, props),
5
- React.createElement("svg", { fill: "currentColor", width: '1.5rem', height: '1.5rem', className: 'scale-down' },
4
+ React.createElement("svg", { fill: "currentColor", width: '1.5rem', height: '1.5rem', className: 'rpc-scale-down' },
6
5
  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" })));
7
6
  }
8
7
  export function BiSolidMessageX(props) {
9
8
  return React.createElement("span", Object.assign({}, props),
10
- React.createElement("svg", { fill: "currentColor", width: '1.5rem', height: '1.5rem', className: 'scale-down' },
9
+ React.createElement("svg", { fill: "currentColor", width: '1.5rem', height: '1.5rem', className: 'rpc-scale-down' },
11
10
  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" })));
12
11
  }
13
12
  export function GrSend(props) {
14
13
  return React.createElement("span", Object.assign({}, props),
15
- React.createElement("svg", { fill: "currentColor", width: '1.5rem', height: '1.5rem', className: 'scale-down invert' },
14
+ React.createElement("svg", { fill: "currentColor", width: '1.5rem', height: '1.5rem', className: 'rpc-scale-down rpc-invert' },
16
15
  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" })));
17
16
  }
18
17
  export function BsFillMicFill(props) {
package/build/index.d.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  import React, { CSSProperties, DetailedHTMLProps, HTMLAttributes, ReactNode, RefObject } from 'react';
2
2
  import { PeerOptions } from 'peerjs';
3
- import './index.css';
4
3
  type Message = {
5
4
  id: string;
6
5
  text: string;
package/build/index.js CHANGED
@@ -21,7 +21,6 @@ var __rest = (this && this.__rest) || function (s, e) {
21
21
  import React, { useEffect, useRef, useState } from 'react';
22
22
  import useStorage, { removeStorage } from './storage';
23
23
  import { BiSolidMessageDetail, BiSolidMessageX, BsFillMicFill, BsFillMicMuteFill, GrSend } from './icons';
24
- import './index.css';
25
24
  export default function Chat(_a) {
26
25
  var { name, peerId, remotePeerId, peerOptions, text = true, voice = true, dialogOptions, onError = () => console.error("Can not access microphone!"), children } = _a, props = __rest(_a, ["name", "peerId", "remotePeerId", "peerOptions", "text", "voice", "dialogOptions", "onError", "children"]);
27
26
  const [peer, setPeer] = useState();
@@ -132,27 +131,27 @@ export default function Chat(_a) {
132
131
  if (container)
133
132
  container.scrollTop = container.scrollHeight;
134
133
  }, [dialog, opponentName, messages]);
135
- return React.createElement("div", Object.assign({ className: 'main' }, props),
134
+ return React.createElement("div", Object.assign({ className: 'rpc-main' }, props),
136
135
  typeof children === 'function' ? children({ notification, messages, addMessage, dialogRef, audio, setAudio }) : React.createElement(React.Fragment, null,
137
136
  text && React.createElement("div", null,
138
137
  dialog ? React.createElement(BiSolidMessageX, { onClick: () => setDialog(false) })
139
- : React.createElement("div", { className: 'notification' },
138
+ : React.createElement("div", { className: 'rpc-notification' },
140
139
  React.createElement(BiSolidMessageDetail, { onClick: () => {
141
140
  setNotification(false);
142
141
  setDialog(true);
143
142
  } }),
144
- notification && React.createElement("span", { className: 'badge' })),
143
+ notification && React.createElement("span", { className: 'rpc-badge' })),
145
144
  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"),
145
+ React.createElement("div", { className: 'rpc-heading' }, "Chat"),
147
146
  React.createElement("hr", null),
148
147
  React.createElement("div", null,
149
- React.createElement("div", { ref: containerRef, className: 'message-container' }, opponentName && messages.map(({ id, text }, i) => React.createElement("div", { key: i },
148
+ React.createElement("div", { ref: containerRef, className: 'rpc-message-container' }, opponentName && messages.map(({ id, text }, i) => React.createElement("div", { key: i },
150
149
  React.createElement("strong", null,
151
150
  id === peerId ? 'You' : opponentName,
152
151
  ": "),
153
152
  React.createElement("span", null, text)))),
154
153
  React.createElement("hr", null),
155
- React.createElement("form", { className: 'input-container', onSubmit: e => {
154
+ React.createElement("form", { className: 'rpc-input-container', onSubmit: e => {
156
155
  var _a;
157
156
  e.preventDefault();
158
157
  const text = (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.value;
@@ -161,7 +160,7 @@ export default function Chat(_a) {
161
160
  addMessage({ id: peerId, text }, true);
162
161
  }
163
162
  } },
164
- React.createElement("input", { ref: inputRef, className: 'input', placeholder: 'Enter a message' }),
163
+ React.createElement("input", { ref: inputRef, className: 'rpc-input', placeholder: 'Enter a message' }),
165
164
  React.createElement("button", { type: 'submit' },
166
165
  React.createElement(GrSend, null)))))),
167
166
  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) }))),
@@ -1,14 +1,14 @@
1
- .main {
1
+ .rpc-main {
2
2
  display: flex;
3
3
  align-items: center;
4
4
  column-gap: 0.5rem;
5
5
  }
6
6
 
7
- .notification {
7
+ .rpc-notification {
8
8
  position: relative;
9
9
  }
10
10
 
11
- .notification .badge {
11
+ .rpc-notification .rpc-badge {
12
12
  background-color: red;
13
13
  position: absolute;
14
14
  top: 0.25rem;
@@ -18,7 +18,7 @@
18
18
  border-radius: 100%;
19
19
  }
20
20
 
21
- .dialog {
21
+ .rpc-dialog {
22
22
  display: flex;
23
23
  flex-direction: column;
24
24
  row-gap: 0.25rem;
@@ -30,52 +30,52 @@
30
30
  font-size: smaller;
31
31
  }
32
32
 
33
- .position-left {
33
+ .rpc-position-left {
34
34
  left: 0.5rem;
35
35
  translate: -100%;
36
36
  }
37
37
 
38
- .position-center {
38
+ .rpc-position-center {
39
39
  translate: -50%;
40
40
  }
41
41
 
42
- .position-right {
42
+ .rpc-position-right {
43
43
  left: 0.5rem;
44
44
  }
45
45
 
46
- .message-container {
46
+ .rpc-message-container {
47
47
  height: 6rem;
48
48
  overflow-y: scroll;
49
49
  padding-inline: 0.5rem;
50
50
  margin-bottom: 0.25rem;
51
51
  }
52
52
 
53
- .message-container::-webkit-scrollbar {
53
+ .rpc-message-container::-webkit-scrollbar {
54
54
  width: 2.5px;
55
55
  }
56
56
 
57
- .message-container::-webkit-scrollbar-track {
57
+ .rpc-message-container::-webkit-scrollbar-track {
58
58
  background: gray;
59
59
  }
60
60
 
61
- .message-container::-webkit-scrollbar-thumb {
61
+ .rpc-message-container::-webkit-scrollbar-thumb {
62
62
  background-color: white;
63
63
  }
64
64
 
65
- .heading {
65
+ .rpc-heading {
66
66
  text-align: center;
67
67
  font-weight: bold;
68
68
  padding-inline: 0.5rem;
69
69
  }
70
70
 
71
- .input-container {
71
+ .rpc-input-container {
72
72
  display: flex;
73
73
  column-gap: 0.25rem;
74
74
  padding-inline: 0.5rem;
75
75
  padding-block: 0.4rem;
76
76
  }
77
77
 
78
- .input {
78
+ .rpc-input {
79
79
  background-color: black;
80
80
  border: none;
81
81
  outline: 1px solid rgba(255, 255, 255, 0.8);
@@ -83,6 +83,14 @@
83
83
  padding-inline: 0.25rem;
84
84
  }
85
85
 
86
- .input:focus {
86
+ .rpc-input:focus {
87
87
  outline: 2px solid white;
88
+ }
89
+
90
+ .rpc-scale-down {
91
+ scale: calc(2/3);
92
+ }
93
+
94
+ .rpc-invert {
95
+ filter: invert(100%);
88
96
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-peer-chat",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "An easy to use react component for impleting peer-to-peer chatting.",
5
5
  "main": "./build/index.js",
6
6
  "type": "module",
package/build/icons.css DELETED
@@ -1,11 +0,0 @@
1
- * {
2
- -webkit-tap-highlight-color: transparent;
3
- }
4
-
5
- .scale-down {
6
- scale: calc(2/3);
7
- }
8
-
9
- .invert {
10
- filter: invert(100%);
11
- }