@connectycube/chat-widget 0.11.0 → 0.13.0

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/README.md CHANGED
@@ -12,6 +12,18 @@ The ConnectyCube Web Chat Widget for React is designed to simplify the process o
12
12
  - **Responsive Design:** Works seamlessly on both desktop and mobile devices.
13
13
  - **Modular and Extensible:** Adapt the widget to your unique requirements.
14
14
 
15
+ ## Demo
16
+
17
+ <https://connectycube-chat-widget.onrender.com>
18
+
19
+ Split-view chat widget:
20
+
21
+ <kbd><img alt="ConnectyCube chat widget, split view image demo" src="https://developers.connectycube.com/images/chat_widget/chat-widget-1.png" width="400" /></kbd>
22
+
23
+ Single-view chat widget:
24
+
25
+ <kbd><img alt="ConnectyCube chat widget, single view image demo" src="https://developers.connectycube.com/images/chat_widget/chat-widget-2.png" width="400" /></kbd>
26
+
15
27
  ## Installation
16
28
 
17
29
  ### React
@@ -58,11 +70,11 @@ import ConnectyCubeChatWidget from "@connectycube/chat-widget";
58
70
  ...
59
71
 
60
72
  <ConnectyCubeChatWidget
61
- userName={"Samuel"}
62
- userId={111}
63
73
  appId="111"
64
74
  authKey="11111111-2222-3333-4444-55555555"
65
75
  config={{ debug: { mode: 1 } }}
76
+ userId="112233"
77
+ userName="Samuel"
66
78
  showOnlineUsersTab={false}
67
79
  splitView={true}
68
80
  />
@@ -71,7 +83,7 @@ import ConnectyCubeChatWidget from "@connectycube/chat-widget";
71
83
  // userId - a User Id from your system
72
84
  ```
73
85
 
74
- See chat widget code samples https://github.com/ConnectyCube/connectycube-chat-widget-samples as a reference for faster integration.
86
+ See chat widget code samples <https://github.com/ConnectyCube/connectycube-chat-widget-samples> as a reference for faster integration.
75
87
 
76
88
  #### Vanilla JS
77
89
 
@@ -95,11 +107,11 @@ Place the following script in your app:
95
107
  chatWidgetContainer.id = 'ConnectyCube_chat-widget';
96
108
  document.body.appendChild(chatWidgetContainer);
97
109
  const props = {
98
- appId: 1111,
110
+ appId: 111,
99
111
  authKey: '11111111-2222-3333-4444-55555555',
100
112
  config: { debug: { mode: 1 } },
113
+ userId: '112233', // a User Id from your system
101
114
  userName: 'Samuel', // how other users will see your user name
102
- userId: 111, // a User Id from your system
103
115
  showOnlineUsersTab: false,
104
116
  splitView: true,
105
117
  };
@@ -110,26 +122,125 @@ Place the following script in your app:
110
122
  </html>
111
123
  ```
112
124
 
113
- See chat widget code samples https://github.com/ConnectyCube/connectycube-chat-widget-samples as a reference for faster integration.
125
+ See chat widget code samples <https://github.com/ConnectyCube/connectycube-chat-widget-samples> as a reference for faster integration.
114
126
 
115
127
  ## Props
116
128
 
117
- | Prop Name | Type | Description |
118
- | -------------------- | --------------------- | ------------------------------------------------------------- |
119
- | `appId` | `number \| string` | The ConnectyCube Application ID |
120
- | `authKey` | `string` | The ConnectyCube Authentication Key |
121
- | `config` | `object` | _(Optional)_ Configuration options for ConnectyCube SDK |
122
- | `userId` | `string` | A User Id from your system (at least 3 characters) |
123
- | `userName` | `string` | User's name. This is how other users will see your user name |
124
- | `muted` | `boolean` (`false`) | _(Optional)_ Do not play sound on incoming message |
125
- | `splitView` | `boolean` (`false`) | _(Optional)_ Displays the chats in split view or single view |
126
- | `showOnlineUsersTab` | `boolean` (`false`) | _(Optional)_ Displays users tab with the list of online users |
127
- | `buttonStyle` | `React.CSSProperties` | _(Optional)_ Inline styles for the button |
128
- | `portalStyle` | `React.CSSProperties` | _(Optional)_ Inline styles for the portal |
129
- | `badgeStyle` | `React.CSSProperties` | _(Optional)_ Inline styles for the badge |
130
- | `buttonClassName` | `string` | _(Optional)_ CSS class or Tailwind CSS classes for the button |
131
- | `portalClassName` | `string` | _(Optional)_ CSS class or Tailwind CSS classes for the chat |
132
- | `badgeClassName` | `string` | _(Optional)_ CSS class or Tailwind CSS classes for the badge |
129
+ | Prop Name | Type | Description | Default Value |
130
+ | -------------------- | --------------------- | -------------------------------------------------------------------------------------- | ------------- |
131
+ | `appId` | `number \| string` | The ConnectyCube Application ID | |
132
+ | `authKey` | `string` | The ConnectyCube Authentication Key | |
133
+ | `config` | `object` | _(Optional)_ Configuration options for ConnectyCube SDK | |
134
+ | `userId` | `string` | A User Id from your system | |
135
+ | `userName` | `string` | User name. This is how other users will see your user name | |
136
+ | `userAvatar` | `string` | _(Optional)_ User Avatar URL | |
137
+ | `muted` | `boolean` | _(Optional)_ Do not play sound on incoming message | false |
138
+ | `splitView` | `boolean` | _(Optional)_ Displays the chats in split view or single view | false |
139
+ | `showOnlineUsersTab` | `boolean` | _(Optional)_ Displays users tab with the list of online users | false |
140
+ | `buttonTitle` | `string` | _(Optional)_ The text displayed on the chat button | "Chat" |
141
+ | `buttonStyle` | `React.CSSProperties` | _(Optional)_ Inline styles for the button | |
142
+ | `portalStyle` | `React.CSSProperties` | _(Optional)_ Inline styles for the portal | |
143
+ | `badgeStyle` | `React.CSSProperties` | _(Optional)_ Inline styles for the badge | |
144
+ | `buttonClassName` | `string` | _(Optional)_ CSS class or Tailwind CSS classes for the button | |
145
+ | `portalClassName` | `string` | _(Optional)_ CSS class or Tailwind CSS classes for the chat | |
146
+ | `badgeClassName` | `string` | _(Optional)_ CSS class or Tailwind CSS classes for the badge | |
147
+ | `quickActions` | `object` | _(Optional)_ Configuration for quick actions dialog. See [QuickActions](#quickactions) | |
148
+
149
+ ## QuickActions
150
+
151
+ | Prop Name | Type | Description | Default Value |
152
+ | ------------- | ---------- | ------------------------------------------------ | ------------- |
153
+ | `title` | `string` | _(Optional)_ Title for the quick actions section | |
154
+ | `description` | `string` | _(Optional)_ Description for the quick actions | |
155
+ | `actions` | `string[]` | List of action strings | |
156
+
157
+ ## Recipes
158
+
159
+ ### Split view
160
+
161
+ React:
162
+
163
+ ```js
164
+ <ConnectyCubeChatWidget
165
+ ...
166
+ splitView={true}
167
+ />
168
+ ```
169
+
170
+ Vanilla JS:
171
+
172
+ ```js
173
+ const props = {
174
+ ...
175
+ splitView: true,
176
+ };
177
+ ```
178
+
179
+ ### Single view
180
+
181
+ React:
182
+
183
+ ```js
184
+ <ConnectyCubeChatWidget
185
+ ...
186
+ splitView={false}
187
+ />
188
+ ```
189
+
190
+ Vanilla JS:
191
+
192
+ ```js
193
+ const props = {
194
+ ...
195
+ splitView: false,
196
+ };
197
+ ```
198
+
199
+ ### Show online users tab
200
+
201
+ React:
202
+
203
+ ```js
204
+ <ConnectyCubeChatWidget
205
+ ...
206
+ showOnlineUsersTab={true}
207
+ />
208
+ ```
209
+
210
+ Vanilla JS:
211
+
212
+ ```js
213
+ const props = {
214
+ ...
215
+ showOnlineUsersTab: true,
216
+ };
217
+ ```
218
+
219
+ ### Display Chat button bottom left
220
+
221
+ React:
222
+
223
+ ```js
224
+ <ConnectyCubeChatWidget
225
+ ...
226
+ buttonClassName={"left-2 right-auto"}
227
+ portalClassName={"left-2 right-auto"}
228
+ />
229
+ ```
230
+
231
+ Vanilla JS:
232
+
233
+ ```js
234
+ const props = {
235
+ ...
236
+ buttonClassName: "left-2 right-auto",
237
+ portalClassName: "left-2 right-auto"
238
+ };
239
+ ```
240
+
241
+ ## Changelog
242
+
243
+ <https://github.com/ConnectyCube/connectycube-chat-widget-samples/blob/main/CHANGELOG.md>
133
244
 
134
245
  ## Community and support
135
246
 
package/dist/App.d.ts CHANGED
@@ -1,19 +1,3 @@
1
- import { Config } from '../../../node_modules/connectycube/dist/types/types';
2
- type AppProps = {
3
- appId: Config.Credentials['appId'];
4
- authKey: Config.Credentials['authKey'];
5
- userId?: string;
6
- userName?: string;
7
- config?: Config.Options;
8
- muted?: boolean;
9
- splitView?: boolean;
10
- showOnlineUsersTab?: boolean;
11
- buttonStyle?: React.CSSProperties;
12
- portalStyle?: React.CSSProperties;
13
- badgeStyle?: React.CSSProperties;
14
- buttonClassName?: string;
15
- portalClassName?: string;
16
- badgeClassName?: string;
17
- };
1
+ import { AppProps } from './AppContainer';
18
2
  declare const App: React.FC<AppProps>;
19
3
  export default App;
@@ -0,0 +1,23 @@
1
+ import { Config } from '../../../node_modules/connectycube/dist/types/types';
2
+ import { QuickActions } from './redux/slices/quickActions';
3
+ export type AppProps = {
4
+ appId: Config.Credentials['appId'];
5
+ authKey: Config.Credentials['authKey'];
6
+ userId?: string;
7
+ userName?: string;
8
+ userAvatar?: string;
9
+ config?: Config.Options;
10
+ muted?: boolean;
11
+ splitView?: boolean;
12
+ showOnlineUsersTab?: boolean;
13
+ quickActions?: QuickActions;
14
+ buttonTitle?: string;
15
+ buttonStyle?: React.CSSProperties;
16
+ portalStyle?: React.CSSProperties;
17
+ badgeStyle?: React.CSSProperties;
18
+ buttonClassName?: string;
19
+ portalClassName?: string;
20
+ badgeClassName?: string;
21
+ };
22
+ declare const AppContainer: React.FC<AppProps>;
23
+ export default AppContainer;
@@ -0,0 +1,5 @@
1
+ export interface QuickActionsProps {
2
+ sendMessage: (text: string) => void;
3
+ }
4
+ declare const QuickActions: React.FC<QuickActionsProps>;
5
+ export default QuickActions;
@@ -1,6 +1,7 @@
1
1
  type LoginProps = {
2
2
  login?: string;
3
3
  name?: string;
4
+ avatar?: string;
4
5
  };
5
6
  declare const Login: React.FC<LoginProps>;
6
7
  export default Login;
@@ -1,6 +1,6 @@
1
1
  import { default as React } from 'react';
2
2
  export interface AvatarProps {
3
- imageUID?: string;
3
+ imageUIDOrUrl?: string;
4
4
  name: string;
5
5
  className?: string | undefined;
6
6
  }
@@ -1,18 +1,21 @@
1
1
  import { Chat, Users, Auth } from '../../../node_modules/connectycube/dist/types/types';
2
2
  export declare const SESSION_KEY = "@connectycube/chat-widget:session";
3
- export declare const tryReuseSession: (userName?: string) => Promise<boolean>;
3
+ export declare const tryReuseSession: (userName?: string, userId?: string, userAvatar?: string) => Promise<boolean>;
4
4
  export declare const tryRestoreSession: () => Promise<Auth.Session | null>;
5
5
  export declare const createUserSession: (login: string, password: string) => Promise<Auth.Session>;
6
- export declare const createSession: (login?: string, name?: string) => Promise<Auth.Session | null>;
6
+ export declare const createSession: (userId?: string, userName?: string, userAvatar?: string) => Promise<Auth.Session | null>;
7
7
  export declare const destroyUserSession: () => Promise<void>;
8
- export declare const userSignup: (login: string, password: string, name?: string) => Promise<Auth.Session>;
8
+ export declare const userSignup: (login: string, password: string, name?: string, externalId?: string, userAvatar?: string) => Promise<Auth.Session>;
9
9
  export declare const chatCredentials: () => Chat.ConnectionParams | null;
10
- export declare const updateUserProfileIfNeeded: (session: Auth.Session, name?: string) => Promise<void>;
10
+ export declare const updateUserProfileIfNeeded: (session: Auth.Session, name?: string, externalId?: string, avatar?: string) => Promise<Auth.Session>;
11
11
  export declare const setSessionToLocalStorage: (session: Auth.Session) => void;
12
12
  export declare const getSessionFromLocalStorage: () => Auth.Session | null;
13
+ export declare const clearSessionInLocalStorage: () => void;
13
14
  export declare const getCurrentUser: () => Users.User | null | undefined;
14
15
  export declare const getSessionToken: () => string | null;
15
16
  export declare const getSessionUserId: () => number | null;
16
17
  export declare const isSessionExpired: () => boolean;
18
+ export declare const isUserIdChanged: (userId?: string) => boolean;
17
19
  export declare const sha256: (str: string) => Promise<string>;
18
20
  export declare const getUserName: (user: Users.User | null | undefined) => string;
21
+ export declare const generateConnectyCubeLogin: (userId?: string) => string;
@@ -0,0 +1,3 @@
1
+ export declare function debounce<T extends (...args: any[]) => void>(func: T, delay: number): T & {
2
+ cancel: () => void;
3
+ };
@@ -0,0 +1,3 @@
1
+ export declare function throttle<T extends (...args: any[]) => void>(func: T, delay: number): T & {
2
+ cancel: () => void;
3
+ };