@tellescope/chat 0.0.34 → 0.0.38
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/lib/cjs/chat.d.ts +1 -1
- package/lib/cjs/chat.d.ts.map +1 -1
- package/lib/cjs/chat.js +16 -19
- package/lib/cjs/chat.js.map +1 -1
- package/lib/esm/chat.d.ts +1 -1
- package/lib/esm/chat.d.ts.map +1 -1
- package/lib/esm/chat.js +17 -20
- package/lib/esm/chat.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +9 -9
- package/src/chat.tsx +38 -26
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tellescope/chat",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.38",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./lib/cjs/index.js",
|
|
6
6
|
"module": "./lib/esm/index.js",
|
|
@@ -33,13 +33,13 @@
|
|
|
33
33
|
"@fontsource/roboto": "^4.5.1",
|
|
34
34
|
"@mui/icons-material": "^5.0.1",
|
|
35
35
|
"@mui/material": "^5.0.2",
|
|
36
|
-
"@tellescope/constants": "^0.0.
|
|
37
|
-
"@tellescope/react-components": "^0.0.
|
|
38
|
-
"@tellescope/sdk": "^0.0.
|
|
39
|
-
"@tellescope/types-client": "^0.0.
|
|
40
|
-
"@tellescope/types-models": "^0.0.
|
|
41
|
-
"@tellescope/types-utilities": "^0.0.
|
|
42
|
-
"@tellescope/utilities": "^0.0.
|
|
36
|
+
"@tellescope/constants": "^0.0.38",
|
|
37
|
+
"@tellescope/react-components": "^0.0.38",
|
|
38
|
+
"@tellescope/sdk": "^0.0.38",
|
|
39
|
+
"@tellescope/types-client": "^0.0.38",
|
|
40
|
+
"@tellescope/types-models": "^0.0.38",
|
|
41
|
+
"@tellescope/types-utilities": "^0.0.38",
|
|
42
|
+
"@tellescope/utilities": "^0.0.38",
|
|
43
43
|
"@typescript-eslint/eslint-plugin": "^4.33.0",
|
|
44
44
|
"@typescript-eslint/parser": "^4.33.0",
|
|
45
45
|
"eslint": "^7.32.0",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"react": "^17.0.2",
|
|
51
51
|
"react-dom": "^17.0.2"
|
|
52
52
|
},
|
|
53
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "45291a50d12aef040e73cf30019fe7d30821febe",
|
|
54
54
|
"publishConfig": {
|
|
55
55
|
"access": "public"
|
|
56
56
|
}
|
package/src/chat.tsx
CHANGED
|
@@ -2,6 +2,7 @@ import React, { useCallback, useState, CSSProperties } from "react"
|
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
4
|
DisplayPicture,
|
|
5
|
+
IN_REACT_WEB,
|
|
5
6
|
} from "@tellescope/react-components"
|
|
6
7
|
import {
|
|
7
8
|
List,
|
|
@@ -75,47 +76,48 @@ export {
|
|
|
75
76
|
user_display_name, // for convenience
|
|
76
77
|
}
|
|
77
78
|
|
|
78
|
-
const
|
|
79
|
-
borderRadius: 5,
|
|
80
|
-
}
|
|
79
|
+
const MESSAGE_BORDER_RADIUS = 25
|
|
81
80
|
|
|
82
81
|
const defaultSentContainerStyle: CSSProperties = {
|
|
83
|
-
justifyContent: 'flex-end',
|
|
84
82
|
margin: 5,
|
|
85
|
-
marginLeft: 'auto',
|
|
86
83
|
}
|
|
87
84
|
const defaultReceivedContainerStyle: CSSProperties = {
|
|
88
|
-
justifyContent: 'flex-start',
|
|
89
85
|
margin: 5,
|
|
90
|
-
marginRight: 'auto',
|
|
91
86
|
}
|
|
92
87
|
|
|
93
|
-
const baseMessageStyle = {
|
|
94
|
-
borderRadius:
|
|
88
|
+
const baseMessageStyle: CSSProperties = {
|
|
89
|
+
borderRadius: MESSAGE_BORDER_RADIUS,
|
|
90
|
+
maxWidth: '80%',
|
|
95
91
|
paddingRight: 10,
|
|
96
92
|
paddingLeft: 10,
|
|
97
|
-
|
|
98
|
-
|
|
93
|
+
paddingTop: 6,
|
|
94
|
+
paddingBottom: 6,
|
|
99
95
|
}
|
|
100
96
|
const defaultSentStyle: CSSProperties = {
|
|
101
97
|
...baseMessageStyle,
|
|
98
|
+
marginLeft: 'auto',
|
|
99
|
+
marginRight: 5,
|
|
102
100
|
backgroundColor: PRIMARY_HEX,
|
|
103
101
|
}
|
|
104
102
|
const defaultReceivedStyle: CSSProperties = {
|
|
105
103
|
...baseMessageStyle,
|
|
104
|
+
marginRight: 'auto',
|
|
105
|
+
marginLeft: 5,
|
|
106
106
|
backgroundColor: "#444444",
|
|
107
107
|
}
|
|
108
|
+
|
|
108
109
|
const baseTextStyle = {
|
|
109
110
|
color: "#ffffff",
|
|
110
|
-
padding: 4,
|
|
111
111
|
}
|
|
112
|
-
const
|
|
112
|
+
const defaultSentTextStyle = {
|
|
113
113
|
...baseTextStyle,
|
|
114
|
-
|
|
114
|
+
marginRight: 5,
|
|
115
|
+
marginLeft: 5,
|
|
115
116
|
}
|
|
116
|
-
const
|
|
117
|
+
const defaultReceivedTextStyle = {
|
|
117
118
|
...baseTextStyle,
|
|
118
|
-
|
|
119
|
+
marginRight: 5,
|
|
120
|
+
marginLeft: 5,
|
|
119
121
|
}
|
|
120
122
|
|
|
121
123
|
export interface MessagesHeaderProps {
|
|
@@ -150,10 +152,10 @@ export const Message = ({
|
|
|
150
152
|
iconSize=30,
|
|
151
153
|
sentMessageContainerStyle=defaultSentContainerStyle,
|
|
152
154
|
receivedMessageContainerStyle=defaultReceivedContainerStyle,
|
|
153
|
-
receivedMessageStyle=defaultReceivedStyle,
|
|
154
|
-
receivedMessageTextStyle=defaultTextReceivedStyle,
|
|
155
155
|
sentMessageStyle=defaultSentStyle,
|
|
156
|
-
|
|
156
|
+
receivedMessageStyle=defaultReceivedStyle,
|
|
157
|
+
sentMessageTextStyle=defaultSentTextStyle,
|
|
158
|
+
receivedMessageTextStyle=defaultReceivedTextStyle,
|
|
157
159
|
}: MessageProps) => {
|
|
158
160
|
const session = useResolvedSession()
|
|
159
161
|
const chatUserId = session.userInfo.id
|
|
@@ -164,18 +166,28 @@ export const Message = ({
|
|
|
164
166
|
const displayPicture = (
|
|
165
167
|
<DisplayPicture
|
|
166
168
|
user={displayInfoLookup[message.senderId ?? ''] ?? { id: message.senderId, avatar: '' }}
|
|
167
|
-
size={iconSize}
|
|
169
|
+
size={iconSize} style={{ position: 'relative' }}
|
|
168
170
|
/>
|
|
169
171
|
)
|
|
170
172
|
|
|
173
|
+
const textBGStyle = message.senderId === chatUserId ? sentMessageStyle : receivedMessageStyle
|
|
174
|
+
const textStyle = message.senderId === chatUserId ? sentMessageTextStyle : receivedMessageTextStyle
|
|
175
|
+
|
|
171
176
|
return (
|
|
172
|
-
<Flex
|
|
177
|
+
<Flex style={{ margin: 5 }}>
|
|
173
178
|
{message.senderId !== chatUserId && displayPicture}
|
|
174
|
-
|
|
175
|
-
<Typography style={
|
|
179
|
+
{IN_REACT_WEB ? (
|
|
180
|
+
<Typography component="div" style={{ ...textStyle, ...textBGStyle }}>
|
|
176
181
|
{message.message}
|
|
177
|
-
</Typography>
|
|
178
|
-
|
|
182
|
+
</Typography>
|
|
183
|
+
)
|
|
184
|
+
: (
|
|
185
|
+
<Flex style={{ ...textBGStyle }}>
|
|
186
|
+
<Typography component="div" style={{ ...textStyle }}>
|
|
187
|
+
{message.message}
|
|
188
|
+
</Typography>
|
|
189
|
+
</Flex>
|
|
190
|
+
)}
|
|
179
191
|
{message.senderId === chatUserId && displayPicture}
|
|
180
192
|
</Flex>
|
|
181
193
|
)
|
|
@@ -194,7 +206,7 @@ export const Messages = ({
|
|
|
194
206
|
chatUserId,
|
|
195
207
|
Header=MessagesHeader,
|
|
196
208
|
headerProps,
|
|
197
|
-
style
|
|
209
|
+
style,
|
|
198
210
|
...messageStyles
|
|
199
211
|
}: Messages_T & Styled) => (
|
|
200
212
|
<LoadingLinear data={messages} render={messages => (
|