@connectycube/chat-widget 0.11.0 → 0.12.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,7 +122,7 @@ 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
 
@@ -119,11 +131,12 @@ See chat widget code samples https://github.com/ConnectyCube/connectycube-chat-w
119
131
  | `appId` | `number \| string` | The ConnectyCube Application ID |
120
132
  | `authKey` | `string` | The ConnectyCube Authentication Key |
121
133
  | `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 |
134
+ | `userId` | `string` | A User Id from your system |
135
+ | `userName` | `string` | User name. This is how other users will see your user name |
124
136
  | `muted` | `boolean` (`false`) | _(Optional)_ Do not play sound on incoming message |
125
137
  | `splitView` | `boolean` (`false`) | _(Optional)_ Displays the chats in split view or single view |
126
138
  | `showOnlineUsersTab` | `boolean` (`false`) | _(Optional)_ Displays users tab with the list of online users |
139
+ | `buttonTitle` | `string` ("Chat") | _(Optional)_ The text displayed on the chat button |
127
140
  | `buttonStyle` | `React.CSSProperties` | _(Optional)_ Inline styles for the button |
128
141
  | `portalStyle` | `React.CSSProperties` | _(Optional)_ Inline styles for the portal |
129
142
  | `badgeStyle` | `React.CSSProperties` | _(Optional)_ Inline styles for the badge |
@@ -131,6 +144,90 @@ See chat widget code samples https://github.com/ConnectyCube/connectycube-chat-w
131
144
  | `portalClassName` | `string` | _(Optional)_ CSS class or Tailwind CSS classes for the chat |
132
145
  | `badgeClassName` | `string` | _(Optional)_ CSS class or Tailwind CSS classes for the badge |
133
146
 
147
+ ## Recipes
148
+
149
+ ### Split view
150
+
151
+ React:
152
+
153
+ ```js
154
+ <ConnectyCubeChatWidget
155
+ ...
156
+ splitView={true}
157
+ />
158
+ ```
159
+
160
+ Vanilla JS:
161
+
162
+ ```js
163
+ const props = {
164
+ ...
165
+ splitView: true,
166
+ };
167
+ ```
168
+
169
+ ### Single view
170
+
171
+ React:
172
+
173
+ ```js
174
+ <ConnectyCubeChatWidget
175
+ ...
176
+ splitView={false}
177
+ />
178
+ ```
179
+
180
+ Vanilla JS:
181
+
182
+ ```js
183
+ const props = {
184
+ ...
185
+ splitView: false,
186
+ };
187
+ ```
188
+
189
+ ### Show online users tab
190
+
191
+ React:
192
+
193
+ ```js
194
+ <ConnectyCubeChatWidget
195
+ ...
196
+ showOnlineUsersTab={true}
197
+ />
198
+ ```
199
+
200
+ Vanilla JS:
201
+
202
+ ```js
203
+ const props = {
204
+ ...
205
+ showOnlineUsersTab: true,
206
+ };
207
+ ```
208
+
209
+ ### Display Chat button bottom left
210
+
211
+ React:
212
+
213
+ ```js
214
+ <ConnectyCubeChatWidget
215
+ ...
216
+ buttonClassName={"left-2 right-auto"}
217
+ portalClassName={"left-2 right-auto"}
218
+ />
219
+ ```
220
+
221
+ Vanilla JS:
222
+
223
+ ```js
224
+ const props = {
225
+ ...
226
+ buttonClassName: "left-2 right-auto",
227
+ portalClassName: "left-2 right-auto"
228
+ };
229
+ ```
230
+
134
231
  ## Community and support
135
232
 
136
233
  - [Blog](https://connectycube.com/blog)
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,20 @@
1
+ import { Config } from '../../../node_modules/connectycube/dist/types/types';
2
+ export 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
+ buttonTitle?: string;
12
+ buttonStyle?: React.CSSProperties;
13
+ portalStyle?: React.CSSProperties;
14
+ badgeStyle?: React.CSSProperties;
15
+ buttonClassName?: string;
16
+ portalClassName?: string;
17
+ badgeClassName?: string;
18
+ };
19
+ declare const AppContainer: React.FC<AppProps>;
20
+ export default AppContainer;
@@ -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) => 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) => 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) => 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) => Promise<void>;
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
+ };