@connectycube/chat-widget 0.19.0 → 0.21.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.
Files changed (32) hide show
  1. package/CHANGELOG.md +173 -0
  2. package/README.md +5 -3
  3. package/dist/App.d.ts +6 -1
  4. package/dist/components/home/main/chat-info-user.d.ts +2 -2
  5. package/dist/components/home/main/chat-input.d.ts +1 -1
  6. package/dist/components/home/main/group-member.d.ts +1 -1
  7. package/dist/components/home/main/message-attachment.d.ts +1 -1
  8. package/dist/components/home/main/message.d.ts +2 -2
  9. package/dist/components/home/main/my-profile/my-block-list-item.d.ts +1 -1
  10. package/dist/components/home/main/profile-info.d.ts +5 -2
  11. package/dist/components/home/sidebar/chat-item.d.ts +1 -1
  12. package/dist/components/home/sidebar/new-chat/create-group-chat/create-group-chat.d.ts +1 -1
  13. package/dist/components/shared/alert-busy.d.ts +2 -0
  14. package/dist/components/shared/avatar.d.ts +2 -2
  15. package/dist/connectycube-chat-widget-sw.js +19 -0
  16. package/dist/helpers/connectycube.d.ts +5 -2
  17. package/dist/helpers/notifications.d.ts +11 -1
  18. package/dist/hooks/index.d.ts +1 -0
  19. package/dist/hooks/store/useAlertBusyStore.d.ts +11 -0
  20. package/dist/hooks/store/useAppInterfaceStore.d.ts +6 -0
  21. package/dist/hooks/store/useAppNotificationStore.d.ts +12 -0
  22. package/dist/hooks/store/useAppSettingsStore.d.ts +4 -0
  23. package/dist/hooks/store/useUserSettingsStore.d.ts +4 -1
  24. package/dist/hooks/useAppAuthorization.d.ts +1 -1
  25. package/dist/hooks/useNotification.d.ts +2 -2
  26. package/dist/index.es.js +12401 -9232
  27. package/dist/index.umd.js +46 -46
  28. package/dist/lib/utils.d.ts +1 -1
  29. package/dist/locales/el/translation.json.d.ts +7 -3
  30. package/dist/locales/en/translation.json.d.ts +7 -3
  31. package/dist/locales/ua/translation.json.d.ts +7 -3
  32. package/package.json +34 -27
package/CHANGELOG.md ADDED
@@ -0,0 +1,173 @@
1
+ # CHANGELOG
2
+
3
+ ## 0.21.0
4
+
5
+ ### Features
6
+
7
+ - Video-preview for video attachment in chat
8
+
9
+ ### Misc
10
+
11
+ - Added support for node 22
12
+ - Upgraded `connectycube` to 4.2.2 and `@connectycube/use-chat` to 0.18.0 to use import types and enums from "connectycube/types"
13
+
14
+ ### Bug fixes
15
+
16
+ - Web Push Notifications init and fetch with user setting
17
+
18
+ ## 0.20.0
19
+
20
+ ### Features
21
+
22
+ - Push Notifications support (receive notifications when browser tab is closed). New props: `webPushNotifications`, `webPushVapidPublicKey`, `serviceWorkerPath`
23
+ - Allow users search from 3 characters min (was 4)
24
+ - New props - `hideNewUserChatOption`, `hideNewGroupChatOption` - To hide 'New group' / 'New message' options in Create Chat dropdown menu
25
+
26
+ ### Bug fixes
27
+
28
+ - [mobile] can't access own profile page
29
+ - `attachmetsAccept` prop: block sending unsupported attachments when select All Files in file picker
30
+ - Improved block list flow
31
+
32
+ ## 0.19.0
33
+
34
+ ### Bug fixes
35
+
36
+ - fix user session restore
37
+
38
+ ## 0.18.0
39
+
40
+ ### Misc
41
+
42
+ - update styles for chat item for not to interfere with host site styles
43
+
44
+ ## 0.17.0
45
+
46
+ ### Features
47
+
48
+ - added `My Profile`
49
+ - display blocked users list in `My Profile`
50
+ - added Notification Settings in `My Profile` (can on/off notifications and notification sound)
51
+ - shows a toast message when a blocked user tries to send a message;
52
+ - added `attachmentsAccept` prop to specify supported attachments types
53
+ - added `defaultChat` prop to force widget open particular chat
54
+
55
+ ## 0.16.0
56
+
57
+ ### Features
58
+
59
+ - report user feature (via `enableContentReporting` prop)
60
+ - block user feature (via `enableBlockList` prop)
61
+ - notification on new message (via `showNotifications`, `playSound` and `muted` props)
62
+
63
+ ### Bug fixes
64
+
65
+ - change `break-all` to `break-word` for chat messages text
66
+ - chats list: last item is not visible
67
+
68
+ ### Misc
69
+
70
+ - redux store was replaced by [zustand](https://github.com/pmndrs/zustand);
71
+
72
+ ## 0.15.2
73
+
74
+ ### Misc
75
+
76
+ - update styles for chat item for not to interfere with host site styles
77
+
78
+ ## 0.15.1
79
+
80
+ ### Bug fixes
81
+
82
+ - User profile link not displayed when open user profile from Users tab
83
+
84
+ ### Misc
85
+
86
+ - set static height for user profile header
87
+ - set overflow-hidden for user profile container
88
+
89
+ ## 0.15.0
90
+
91
+ ### Features
92
+
93
+ - highlight links in chat messages;
94
+ - updated attachments to support uploading any file;
95
+ - create 1-1 chat on send 1st message, not when click on a user
96
+ - encapsulated chat widget styles to prevent global styling effects;
97
+ - implemented `open` prop to manage chat widget visibility state;
98
+ - implemented `window.ConnectyCubeChatWidget.toggle()` function to manage chat widget visibility state when used as UMD;
99
+ - implemented `onOpenChange` and `onUnreadCountChange` props as callbacks to receive updates on the visibility of the chat widget and the unread message counter, respectively;
100
+ - implemented `hideWidgetButton` prop to hide the chat widget button and use a custom one;
101
+ - implemented browser notifications and `showNotifications` prop to enable the feature;
102
+
103
+ ### Bug fixes
104
+
105
+ - blocked sending files as attachments if they do not have `type` or `size` properties.
106
+ - fixed z-index for Chat button and widget view
107
+
108
+ ### Misc
109
+
110
+ - upgraded tailwindcss to version 4;
111
+ - upgraded ShadCN-UI components to support TailwindCSS version 4;
112
+
113
+ ## 0.14.4
114
+
115
+ ### Bug fixes
116
+
117
+ - fix avatar crash when chat name is empty
118
+
119
+ ## 0.14.3
120
+
121
+ ### Bug fixes
122
+
123
+ - fix missing typings declaration
124
+
125
+ ## 0.14.2
126
+
127
+ ### Bug fixes
128
+
129
+ - fix README
130
+
131
+ ## 0.14.0
132
+
133
+ ### Features
134
+
135
+ - introduce user profile link via `userProfileLink` prop
136
+ - hide new chat button via `hideNewChatButton` prop
137
+ - English, Greek, Ukrainian languages supported via `translation` prop
138
+
139
+ ## 0.13.0
140
+
141
+ ### Features
142
+
143
+ - user avatar
144
+ - suggested messages
145
+
146
+ ## 0.12.0
147
+
148
+ ### Features
149
+
150
+ - message drafts
151
+ - allow to change `userId` prop on the flight
152
+
153
+ ### Bug fixes
154
+
155
+ - fix mobile UI styles
156
+
157
+ ## 0.11.0
158
+
159
+ ### Features
160
+
161
+ - displays total unread messages counter;
162
+ - placeholders for empty lists;
163
+
164
+ ### Bug fixes
165
+
166
+ - can restore expired session;
167
+ - can retrieve messages while the widget is collapsed;
168
+ - incoming notification sound;
169
+ - UI styles;
170
+
171
+ ## 0.10.0
172
+
173
+ Initial release.
package/README.md CHANGED
@@ -150,15 +150,17 @@ See all available recipes <https://developers.connectycube.com/js/chat-widget/#r
150
150
 
151
151
  ## Have an issue?
152
152
 
153
- Join our [Discord](https://discord.gg/wDwbvJmD) for quick answers to your questions
153
+ Join our [Discord](https://discord.com/invite/zqbBWNCCFJ) for quick answers to your questions
154
154
 
155
- ## Community and support
155
+ ## Community
156
156
 
157
- - [Discord](https://discord.gg/wDwbvJmD)
158
157
  - [Blog](https://connectycube.com/blog)
159
158
  - X (twitter)[@ConnectyCube](https://x.com/ConnectyCube)
160
159
  - [Facebook](https://www.facebook.com/ConnectyCube)
161
160
 
161
+ **Want to support our team**:<br>
162
+ <a href="https://www.buymeacoffee.com/connectycube" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-blue.png" alt="Buy Me A Coffee" style="height: 60px !important;width: 217px !important;" ></a>
163
+
162
164
  ## Changelog
163
165
 
164
166
  <https://github.com/ConnectyCube/connectycube-chat-widget-samples/blob/main/CHANGELOG.md>
package/dist/App.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Config } from '../node_modules/connectycube/src/types';
1
+ import { Config } from 'connectycube/types';
2
2
  import { DefaultChat } from './hooks/store/useAppDefaultChatStore';
3
3
  import { QuickActions } from './hooks/store/useAppQuickActionsStore';
4
4
  export type AppProps = {
@@ -13,9 +13,14 @@ export type AppProps = {
13
13
  splitView?: boolean;
14
14
  showOnlineUsersTab?: boolean;
15
15
  hideNewChatButton?: boolean;
16
+ hideNewUserChatOption?: boolean;
17
+ hideNewGroupChatOption?: boolean;
16
18
  muted?: boolean;
17
19
  showNotifications?: boolean;
18
20
  playSound?: boolean;
21
+ webPushNotifications?: boolean;
22
+ webPushVapidPublicKey?: string;
23
+ serviceWorkerPath?: string | URL;
19
24
  attachmentsAccept?: string;
20
25
  enableContentReporting?: boolean;
21
26
  enableBlockList?: boolean;
@@ -1,7 +1,7 @@
1
1
  import { default as React } from 'react';
2
- import { Users } from '../../../../node_modules/connectycube/src/types';
2
+ import { Users } from 'connectycube/types';
3
3
  export interface ChatInfoUserProps {
4
- user?: Users.User;
4
+ user?: Users.User | null;
5
5
  }
6
6
  declare const _default: React.NamedExoticComponent<ChatInfoUserProps>;
7
7
  export default _default;
@@ -1,5 +1,5 @@
1
1
  import { default as React } from 'react';
2
- import { Dialogs } from '../../../../node_modules/connectycube/src/types';
2
+ import { Dialogs } from 'connectycube/types';
3
3
  export interface ChatInputProps {
4
4
  onSendMessage: (message: string, dialog?: Dialogs.Dialog) => void;
5
5
  onSendMessageWithAttachment: (files: File[]) => void;
@@ -2,7 +2,7 @@ import { default as React } from 'react';
2
2
  export interface GroupMemberProps {
3
3
  userId: number;
4
4
  name: string;
5
- avatar?: string;
5
+ avatar?: string | null;
6
6
  }
7
7
  declare const _default: React.NamedExoticComponent<GroupMemberProps>;
8
8
  export default _default;
@@ -1,4 +1,4 @@
1
- import { Messages } from '../../../../node_modules/connectycube/src/types';
1
+ import { Messages } from 'connectycube/types';
2
2
  import { default as React } from 'react';
3
3
  export interface MessageAttachmentProps {
4
4
  attachment: Messages.Attachment;
@@ -1,11 +1,11 @@
1
1
  import { default as React } from 'react';
2
- import { Messages } from '../../../../node_modules/connectycube/src/types';
2
+ import { Messages } from 'connectycube/types';
3
3
  export interface MessageProps {
4
4
  message: Messages.Message;
5
5
  isGroupChat: boolean;
6
6
  dialogName: string;
7
7
  senderName: string;
8
- senderAvatar: string;
8
+ senderAvatar?: string | null;
9
9
  }
10
10
  declare const Message: React.FC<MessageProps>;
11
11
  export default Message;
@@ -1,5 +1,5 @@
1
1
  import { default as React } from 'react';
2
- import { Users } from '../../../../../node_modules/connectycube/src/types';
2
+ import { Users } from 'connectycube/types';
3
3
  export interface MyBlockListItemProps {
4
4
  user?: Users.User;
5
5
  }
@@ -1,3 +1,6 @@
1
1
  import { default as React } from 'react';
2
- declare const ProfileInfo: React.FC;
3
- export default ProfileInfo;
2
+ type ProfileInfoProps = {
3
+ profileClassName: string;
4
+ };
5
+ declare const _default: React.NamedExoticComponent<ProfileInfoProps>;
6
+ export default _default;
@@ -1,5 +1,5 @@
1
1
  import { default as React } from 'react';
2
- import { Dialogs } from '../../../../node_modules/connectycube/src/types';
2
+ import { Dialogs } from 'connectycube/types';
3
3
  export interface ChatItemProps {
4
4
  dialog: Dialogs.Dialog;
5
5
  }
@@ -1,5 +1,5 @@
1
1
  import { default as React } from 'react';
2
- import { Users } from '../../../../../../node_modules/connectycube/src/types';
2
+ import { Users } from 'connectycube/types';
3
3
  export interface CreateGroupChatProps {
4
4
  users: Users.User[];
5
5
  onCreateChat: (name: string) => void;
@@ -0,0 +1,2 @@
1
+ declare const AlertBusy: React.FC;
2
+ export default AlertBusy;
@@ -1,7 +1,7 @@
1
1
  import { default as React } from 'react';
2
2
  export interface AvatarProps {
3
- imageUIDOrUrl?: string;
4
- name: string;
3
+ imageUIDOrUrl?: string | null;
4
+ name?: string;
5
5
  className?: string | undefined;
6
6
  }
7
7
  declare const _default: React.NamedExoticComponent<AvatarProps>;
@@ -0,0 +1,19 @@
1
+ self.addEventListener('install', (event) => {
2
+ self.skipWaiting();
3
+ });
4
+
5
+ self.addEventListener('push', (event) => {
6
+ const { data } = event.data?.json() || {};
7
+ const title = data.title || '';
8
+ const options = {
9
+ body: data.message || '',
10
+ icon: data.photo || '/logo.png',
11
+ };
12
+
13
+ event.waitUntil(self.registration.showNotification(title, options));
14
+ });
15
+
16
+ self.addEventListener('notificationclick', (event) => {
17
+ event.notification.close();
18
+ event.waitUntil(clients.openWindow('/'));
19
+ });
@@ -1,4 +1,5 @@
1
- import { Config, Users, Auth, Chat } from '../../node_modules/connectycube/src/types';
1
+ import { Config, Users, Auth, Chat, EmptyResponse, PushNotifications } from 'connectycube/types';
2
+ import { PushSubscriptionData } from './notifications';
2
3
  export declare const SESSION_KEY = "@connectycube/chat-widget:session";
3
4
  export declare const initConnectyCubeSDK: (credentials: Config.Credentials, config?: Config.Options) => void;
4
5
  export declare const tryReuseSession: (userName?: string, userId?: string, userAvatar?: string, userProfileLink?: string) => Promise<boolean>;
@@ -27,4 +28,6 @@ export declare const sha256: (str: string) => Promise<string>;
27
28
  export declare const getUserName: (user: Users.User | null | undefined, force?: boolean) => string;
28
29
  export declare const getPhotoUrl: (photoOrAvatar?: string | null) => string;
29
30
  export declare const generateConnectyCubeLogin: (userId?: string) => string;
30
- export declare const createUserReport: (reportedUserId: number, reason: string) => Promise<import("@connectycube/types").Data.DataRecord>;
31
+ export declare const createUserReport: (reportedUserId: number, reason: string) => Promise<import("connectycube/types").Data.DataRecord>;
32
+ export declare const subscribeToPushNotifications: (pushSubscriptionData?: PushSubscriptionData) => Promise<PushNotifications.Subscription | undefined>;
33
+ export declare const unsubscribeFromPushNotifications: () => Promise<EmptyResponse[]>;
@@ -1 +1,11 @@
1
- export declare const requestNotificationPermission: () => Promise<void>;
1
+ export type PushSubscriptionData = {
2
+ endpoint: string;
3
+ auth: string;
4
+ p256dh: string;
5
+ } | undefined;
6
+ export declare const requestNotificationPermission: () => Promise<boolean>;
7
+ export declare const registerWidgetServiceWorker: (serviceWorkerPath?: string | URL) => Promise<boolean>;
8
+ export declare const getWidgetServiceWorker: (serviceWorkerPath?: string | URL) => Promise<ServiceWorkerRegistration | void>;
9
+ export declare const getPushManagerSubscriptionData: (subscription?: PushSubscription | null) => PushSubscriptionData;
10
+ export declare const getPushManagerSubscription: (serviceWorkerPath?: string | URL, applicationServerKey?: PushSubscriptionOptionsInit["applicationServerKey"]) => Promise<PushSubscription | null>;
11
+ export declare const unsubscribePushManager: (serviceWorkerPath?: string | URL) => Promise<boolean>;
@@ -1,5 +1,6 @@
1
1
  export declare const resetStore: (force?: boolean) => void;
2
2
  export { default as useActiveTabsStore } from './store/useActiveTabsStore';
3
+ export { default as useAlertBusyStore } from './store/useAlertBusyStore';
3
4
  export { default as useAppDefaultChatStore } from './store/useAppDefaultChatStore';
4
5
  export { default as useAppInterfaceStore } from './store/useAppInterfaceStore';
5
6
  export { default as useAppSettingsStore } from './store/useAppSettingsStore';
@@ -0,0 +1,11 @@
1
+ type AlertBusyStateProps = {
2
+ visible: boolean;
3
+ title: string;
4
+ };
5
+ interface AlertBusyState extends AlertBusyStateProps {
6
+ showAlertBusy: (title: string) => void;
7
+ hideAlertBusy: () => void;
8
+ }
9
+ declare const useAlertBusyStore: import('zustand').UseBoundStore<import('zustand').StoreApi<AlertBusyState>>;
10
+ export declare const resetAlertBusyStore: () => void;
11
+ export default useAlertBusyStore;
@@ -3,16 +3,22 @@ export type AppInterfaceStoreProps = {
3
3
  splitView: boolean;
4
4
  showOnlineUsersTab: boolean;
5
5
  hideNewChatButton: boolean;
6
+ hideNewUserChatOption: boolean;
7
+ hideNewGroupChatOption: boolean;
6
8
  };
7
9
  export interface AppInterfaceStoreState extends AppInterfaceStoreProps {
8
10
  setOpened: (opened: boolean) => void;
9
11
  setSplitView: (splitView: boolean) => void;
10
12
  setShowOnlineUsersTab: (showOnlineUsersTab: boolean) => void;
11
13
  setHideNewChatButton: (hideNewChatButton: boolean) => void;
14
+ setHideNewUserChatOption: (hideNewUserChatOption: boolean) => void;
15
+ setHideNewGroupChatOption: (hideNewGroupChatOption: boolean) => void;
12
16
  resetOpened: () => void;
13
17
  resetSplitView: () => void;
14
18
  resetShowOnlineUsersTab: () => void;
15
19
  resetHideNewChatButton: () => void;
20
+ resetHideNewUserChatOption: () => void;
21
+ resetHideNewGroupChatOption: () => void;
16
22
  }
17
23
  export declare const appInterfaceStoreInitialState: AppInterfaceStoreProps;
18
24
  declare const useAppInterfaceStore: import('zustand').UseBoundStore<import('zustand').StoreApi<AppInterfaceStoreState>>;
@@ -2,6 +2,9 @@ type AppNotificationStoreProps = {
2
2
  muted: boolean;
3
3
  showNotifications: boolean;
4
4
  playSound: boolean;
5
+ webPushNotifications: boolean;
6
+ webPushVapidPublicKey?: string;
7
+ serviceWorkerPath?: string | URL;
5
8
  };
6
9
  export interface AppNotificationStoreState extends AppNotificationStoreProps {
7
10
  setMuted: (muted: boolean) => void;
@@ -10,11 +13,20 @@ export interface AppNotificationStoreState extends AppNotificationStoreProps {
10
13
  resetShowNotifications: () => void;
11
14
  setPlaySound: (playSound: boolean) => void;
12
15
  resetPlaySound: () => void;
16
+ setWebPushNotifications: (webPushNotifications: boolean) => void;
17
+ resetWebPushNotifications: () => void;
18
+ setWebPushVapidPublicKey: (webPushVapidPublicKey?: string) => void;
19
+ resetWebPushVapidPublicKey: () => void;
20
+ setServiceWorkerPath: (serviceWorkerPath?: string | URL) => void;
21
+ resetServiceWorkerPath: () => void;
13
22
  }
14
23
  export declare const notificationStoreInitialState: {
15
24
  muted: boolean;
16
25
  showNotifications: boolean;
17
26
  playSound: boolean;
27
+ webPushNotifications: boolean;
28
+ webPushVapidPublicKey: undefined;
29
+ serviceWorkerPath: undefined;
18
30
  };
19
31
  declare const useAppNotificationStore: import('zustand').UseBoundStore<import('zustand').StoreApi<AppNotificationStoreState>>;
20
32
  export declare const setAppNotificationStore: (state: Partial<AppNotificationStoreProps>) => void;
@@ -1,5 +1,6 @@
1
1
  export type AppSettingStoreProps = {
2
2
  attachmentsAccept: string;
3
+ attachmentsAcceptList: string[];
3
4
  enableContentReporting: boolean;
4
5
  enableBlockList: boolean;
5
6
  };
@@ -10,9 +11,12 @@ export interface AppSettingStoreState extends AppSettingStoreProps {
10
11
  resetAttachmentsAccept: () => void;
11
12
  resetEnableContentReporting: () => void;
12
13
  resetEnableBlockList: () => void;
14
+ isSupportedFile: (file: File) => boolean;
13
15
  }
14
16
  export declare const appSettingsStoreInitialState: AppSettingStoreProps;
15
17
  declare const useAppSettingsStore: import('zustand').UseBoundStore<import('zustand').StoreApi<AppSettingStoreState>>;
16
18
  export declare const setAppSettingsStore: (state: Partial<AppSettingStoreProps>) => void;
17
19
  export declare const resetAppSettingsStore: () => void;
18
20
  export default useAppSettingsStore;
21
+ export declare const getAttachmentsAcceptList: (attachmentsAccept: string) => string[];
22
+ export declare const isSupportedFileMimeType: (file: File, attachmentsAcceptList: AppSettingStoreState["attachmentsAcceptList"]) => boolean;
@@ -1,11 +1,14 @@
1
1
  type UserSettingsStateProps = {
2
2
  isNotifications: boolean;
3
3
  isNotificationSound: boolean;
4
+ isPushNotifications: boolean;
4
5
  };
5
6
  interface UserSettingsState extends UserSettingsStateProps {
6
7
  setIsNotifications: (enabled: boolean) => Promise<void>;
7
8
  setIsNotificationSound: (enabled: boolean) => Promise<void>;
9
+ setIsPushNotifications: (enabled: boolean) => Promise<void>;
8
10
  }
9
11
  declare const useUserSettingsStore: import('zustand').UseBoundStore<import('zustand').StoreApi<UserSettingsState>>;
10
- export declare const restoreUserSettingsStore: () => void;
12
+ export declare const managePushNotificationsSubscription: (enable: boolean) => Promise<boolean>;
13
+ export declare const restoreUserSettingsStore: () => Promise<void>;
11
14
  export default useUserSettingsStore;
@@ -1,4 +1,4 @@
1
- import { Config } from '../../node_modules/connectycube/src/types';
1
+ import { Config } from 'connectycube/types';
2
2
  type AppUser = {
3
3
  id?: string;
4
4
  name?: string;
@@ -1,6 +1,6 @@
1
- import { Chat } from '../../node_modules/connectycube/src/types';
1
+ import { Chat } from 'connectycube/types';
2
2
  type NotificationHook = {
3
- showNotification: (title: string, body: string, icon: string) => Notification | void;
3
+ showNotification: (title: string, body: string, icon: string) => Promise<Notification | void>;
4
4
  notifyOnMessage: (userId: number, message: Chat.Message) => Promise<Notification | void>;
5
5
  playAudio: () => void;
6
6
  };