@greatapps/greatchat-ui 0.1.1 → 0.1.3
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/dist/index.d.ts +290 -1
- package/dist/index.js +1534 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
- package/src/components/contact-avatar.tsx +59 -0
- package/src/components/contact-info-panel.tsx +139 -0
- package/src/components/inbox-item.tsx +149 -0
- package/src/components/inbox-sidebar.tsx +148 -0
- package/src/components/index.ts +15 -0
- package/src/components/new-conversation-dialog.tsx +172 -0
- package/src/components/ui/avatar.tsx +51 -0
- package/src/components/ui/command.tsx +106 -0
- package/src/components/ui/dialog.tsx +133 -0
- package/src/components/ui/input.tsx +19 -0
- package/src/components/ui/scroll-area.tsx +50 -0
- package/src/components/ui/separator.tsx +26 -0
- package/src/components/ui/tabs.tsx +64 -0
- package/src/components/ui/tooltip.tsx +58 -0
- package/src/hooks/index.ts +14 -0
- package/src/hooks/types.ts +40 -0
- package/src/hooks/use-channels.ts +163 -0
- package/src/hooks/use-contacts.ts +94 -0
- package/src/hooks/use-inbox-messages.ts +405 -0
- package/src/hooks/use-inboxes.ts +127 -0
- package/src/index.ts +23 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { ClassValue } from 'clsx';
|
|
2
|
+
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
3
|
+
import * as _tanstack_query_core from '@tanstack/query-core';
|
|
2
4
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
5
|
|
|
4
6
|
interface ApiResponse<T> {
|
|
@@ -147,6 +149,244 @@ declare function groupMessagesByDate(messages: InboxMessage[]): {
|
|
|
147
149
|
declare function formatDateGroup(dateStr: string): string;
|
|
148
150
|
declare function formatMessageTime(dateStr: string): string;
|
|
149
151
|
|
|
152
|
+
interface GchatHookConfig {
|
|
153
|
+
accountId: number;
|
|
154
|
+
token: string;
|
|
155
|
+
baseUrl: string;
|
|
156
|
+
language?: string;
|
|
157
|
+
idWl?: number;
|
|
158
|
+
}
|
|
159
|
+
declare const DEFAULT_INBOX_POLLING = 5000;
|
|
160
|
+
declare const DEFAULT_MESSAGES_POLLING = 3000;
|
|
161
|
+
declare const DEFAULT_CHANNEL_STATUS_POLLING = 5000;
|
|
162
|
+
declare const DEFAULT_QR_POLLING = 2000;
|
|
163
|
+
|
|
164
|
+
declare function useInboxes(config: GchatHookConfig, statusFilter?: string, pollingInterval?: number): _tanstack_react_query.UseQueryResult<Inbox[], Error>;
|
|
165
|
+
declare function useInbox(config: GchatHookConfig, id: number | null): _tanstack_react_query.UseQueryResult<Inbox, Error>;
|
|
166
|
+
declare function useInboxStats(config: GchatHookConfig, pollingInterval?: number): _tanstack_react_query.UseQueryResult<InboxStats, Error>;
|
|
167
|
+
declare function useCreateInbox(config: GchatHookConfig): _tanstack_react_query.UseMutationResult<ApiResponse<Inbox>, Error, {
|
|
168
|
+
id_channel: number;
|
|
169
|
+
id_contact: number;
|
|
170
|
+
}, unknown>;
|
|
171
|
+
declare function useUpdateInbox(config: GchatHookConfig): _tanstack_react_query.UseMutationResult<ApiResponse<Inbox>, Error, {
|
|
172
|
+
id: number;
|
|
173
|
+
body: Partial<Pick<Inbox, "status" | "id_agent">>;
|
|
174
|
+
}, unknown>;
|
|
175
|
+
declare function useDeleteInbox(config: GchatHookConfig): _tanstack_react_query.UseMutationResult<ApiResponse<void>, Error, number, unknown>;
|
|
176
|
+
|
|
177
|
+
declare function useInboxMessages(config: GchatHookConfig, idInbox: number | null, pollingInterval?: number): {
|
|
178
|
+
data: InboxMessage[];
|
|
179
|
+
error: Error;
|
|
180
|
+
isError: true;
|
|
181
|
+
isPending: false;
|
|
182
|
+
isLoading: false;
|
|
183
|
+
isLoadingError: false;
|
|
184
|
+
isRefetchError: true;
|
|
185
|
+
isSuccess: false;
|
|
186
|
+
isPlaceholderData: false;
|
|
187
|
+
status: "error";
|
|
188
|
+
dataUpdatedAt: number;
|
|
189
|
+
errorUpdatedAt: number;
|
|
190
|
+
failureCount: number;
|
|
191
|
+
failureReason: Error | null;
|
|
192
|
+
errorUpdateCount: number;
|
|
193
|
+
isFetched: boolean;
|
|
194
|
+
isFetchedAfterMount: boolean;
|
|
195
|
+
isFetching: boolean;
|
|
196
|
+
isInitialLoading: boolean;
|
|
197
|
+
isPaused: boolean;
|
|
198
|
+
isRefetching: boolean;
|
|
199
|
+
isStale: boolean;
|
|
200
|
+
isEnabled: boolean;
|
|
201
|
+
refetch: (options?: _tanstack_query_core.RefetchOptions) => Promise<_tanstack_query_core.QueryObserverResult<InboxMessage[], Error>>;
|
|
202
|
+
fetchStatus: _tanstack_query_core.FetchStatus;
|
|
203
|
+
promise: Promise<InboxMessage[]>;
|
|
204
|
+
} | {
|
|
205
|
+
data: InboxMessage[];
|
|
206
|
+
error: null;
|
|
207
|
+
isError: false;
|
|
208
|
+
isPending: false;
|
|
209
|
+
isLoading: false;
|
|
210
|
+
isLoadingError: false;
|
|
211
|
+
isRefetchError: false;
|
|
212
|
+
isSuccess: true;
|
|
213
|
+
isPlaceholderData: false;
|
|
214
|
+
status: "success";
|
|
215
|
+
dataUpdatedAt: number;
|
|
216
|
+
errorUpdatedAt: number;
|
|
217
|
+
failureCount: number;
|
|
218
|
+
failureReason: Error | null;
|
|
219
|
+
errorUpdateCount: number;
|
|
220
|
+
isFetched: boolean;
|
|
221
|
+
isFetchedAfterMount: boolean;
|
|
222
|
+
isFetching: boolean;
|
|
223
|
+
isInitialLoading: boolean;
|
|
224
|
+
isPaused: boolean;
|
|
225
|
+
isRefetching: boolean;
|
|
226
|
+
isStale: boolean;
|
|
227
|
+
isEnabled: boolean;
|
|
228
|
+
refetch: (options?: _tanstack_query_core.RefetchOptions) => Promise<_tanstack_query_core.QueryObserverResult<InboxMessage[], Error>>;
|
|
229
|
+
fetchStatus: _tanstack_query_core.FetchStatus;
|
|
230
|
+
promise: Promise<InboxMessage[]>;
|
|
231
|
+
} | {
|
|
232
|
+
data: InboxMessage[];
|
|
233
|
+
error: Error;
|
|
234
|
+
isError: true;
|
|
235
|
+
isPending: false;
|
|
236
|
+
isLoading: false;
|
|
237
|
+
isLoadingError: true;
|
|
238
|
+
isRefetchError: false;
|
|
239
|
+
isSuccess: false;
|
|
240
|
+
isPlaceholderData: false;
|
|
241
|
+
status: "error";
|
|
242
|
+
dataUpdatedAt: number;
|
|
243
|
+
errorUpdatedAt: number;
|
|
244
|
+
failureCount: number;
|
|
245
|
+
failureReason: Error | null;
|
|
246
|
+
errorUpdateCount: number;
|
|
247
|
+
isFetched: boolean;
|
|
248
|
+
isFetchedAfterMount: boolean;
|
|
249
|
+
isFetching: boolean;
|
|
250
|
+
isInitialLoading: boolean;
|
|
251
|
+
isPaused: boolean;
|
|
252
|
+
isRefetching: boolean;
|
|
253
|
+
isStale: boolean;
|
|
254
|
+
isEnabled: boolean;
|
|
255
|
+
refetch: (options?: _tanstack_query_core.RefetchOptions) => Promise<_tanstack_query_core.QueryObserverResult<InboxMessage[], Error>>;
|
|
256
|
+
fetchStatus: _tanstack_query_core.FetchStatus;
|
|
257
|
+
promise: Promise<InboxMessage[]>;
|
|
258
|
+
} | {
|
|
259
|
+
data: InboxMessage[];
|
|
260
|
+
error: null;
|
|
261
|
+
isError: false;
|
|
262
|
+
isPending: true;
|
|
263
|
+
isLoading: true;
|
|
264
|
+
isLoadingError: false;
|
|
265
|
+
isRefetchError: false;
|
|
266
|
+
isSuccess: false;
|
|
267
|
+
isPlaceholderData: false;
|
|
268
|
+
status: "pending";
|
|
269
|
+
dataUpdatedAt: number;
|
|
270
|
+
errorUpdatedAt: number;
|
|
271
|
+
failureCount: number;
|
|
272
|
+
failureReason: Error | null;
|
|
273
|
+
errorUpdateCount: number;
|
|
274
|
+
isFetched: boolean;
|
|
275
|
+
isFetchedAfterMount: boolean;
|
|
276
|
+
isFetching: boolean;
|
|
277
|
+
isInitialLoading: boolean;
|
|
278
|
+
isPaused: boolean;
|
|
279
|
+
isRefetching: boolean;
|
|
280
|
+
isStale: boolean;
|
|
281
|
+
isEnabled: boolean;
|
|
282
|
+
refetch: (options?: _tanstack_query_core.RefetchOptions) => Promise<_tanstack_query_core.QueryObserverResult<InboxMessage[], Error>>;
|
|
283
|
+
fetchStatus: _tanstack_query_core.FetchStatus;
|
|
284
|
+
promise: Promise<InboxMessage[]>;
|
|
285
|
+
} | {
|
|
286
|
+
data: InboxMessage[];
|
|
287
|
+
error: null;
|
|
288
|
+
isError: false;
|
|
289
|
+
isPending: true;
|
|
290
|
+
isLoadingError: false;
|
|
291
|
+
isRefetchError: false;
|
|
292
|
+
isSuccess: false;
|
|
293
|
+
isPlaceholderData: false;
|
|
294
|
+
status: "pending";
|
|
295
|
+
dataUpdatedAt: number;
|
|
296
|
+
errorUpdatedAt: number;
|
|
297
|
+
failureCount: number;
|
|
298
|
+
failureReason: Error | null;
|
|
299
|
+
errorUpdateCount: number;
|
|
300
|
+
isFetched: boolean;
|
|
301
|
+
isFetchedAfterMount: boolean;
|
|
302
|
+
isFetching: boolean;
|
|
303
|
+
isLoading: boolean;
|
|
304
|
+
isInitialLoading: boolean;
|
|
305
|
+
isPaused: boolean;
|
|
306
|
+
isRefetching: boolean;
|
|
307
|
+
isStale: boolean;
|
|
308
|
+
isEnabled: boolean;
|
|
309
|
+
refetch: (options?: _tanstack_query_core.RefetchOptions) => Promise<_tanstack_query_core.QueryObserverResult<InboxMessage[], Error>>;
|
|
310
|
+
fetchStatus: _tanstack_query_core.FetchStatus;
|
|
311
|
+
promise: Promise<InboxMessage[]>;
|
|
312
|
+
} | {
|
|
313
|
+
data: InboxMessage[];
|
|
314
|
+
isError: false;
|
|
315
|
+
error: null;
|
|
316
|
+
isPending: false;
|
|
317
|
+
isLoading: false;
|
|
318
|
+
isLoadingError: false;
|
|
319
|
+
isRefetchError: false;
|
|
320
|
+
isSuccess: true;
|
|
321
|
+
isPlaceholderData: true;
|
|
322
|
+
status: "success";
|
|
323
|
+
dataUpdatedAt: number;
|
|
324
|
+
errorUpdatedAt: number;
|
|
325
|
+
failureCount: number;
|
|
326
|
+
failureReason: Error | null;
|
|
327
|
+
errorUpdateCount: number;
|
|
328
|
+
isFetched: boolean;
|
|
329
|
+
isFetchedAfterMount: boolean;
|
|
330
|
+
isFetching: boolean;
|
|
331
|
+
isInitialLoading: boolean;
|
|
332
|
+
isPaused: boolean;
|
|
333
|
+
isRefetching: boolean;
|
|
334
|
+
isStale: boolean;
|
|
335
|
+
isEnabled: boolean;
|
|
336
|
+
refetch: (options?: _tanstack_query_core.RefetchOptions) => Promise<_tanstack_query_core.QueryObserverResult<InboxMessage[], Error>>;
|
|
337
|
+
fetchStatus: _tanstack_query_core.FetchStatus;
|
|
338
|
+
promise: Promise<InboxMessage[]>;
|
|
339
|
+
};
|
|
340
|
+
declare function useSendMessage(config: GchatHookConfig): _tanstack_react_query.UseMutationResult<ApiResponse<InboxMessage>, Error, {
|
|
341
|
+
idInbox: number;
|
|
342
|
+
content: string;
|
|
343
|
+
}, {
|
|
344
|
+
optimisticMsg: InboxMessage;
|
|
345
|
+
}>;
|
|
346
|
+
declare function useRetryMessage(config: GchatHookConfig): (message: InboxMessage) => Promise<void>;
|
|
347
|
+
declare function useRevokeMessage(config: GchatHookConfig): _tanstack_react_query.UseMutationResult<ApiResponse<void>, Error, {
|
|
348
|
+
id: number;
|
|
349
|
+
idInbox: number;
|
|
350
|
+
}, unknown>;
|
|
351
|
+
declare function useEditMessage(config: GchatHookConfig): _tanstack_react_query.UseMutationResult<ApiResponse<void>, Error, {
|
|
352
|
+
id: number;
|
|
353
|
+
idInbox: number;
|
|
354
|
+
content: string;
|
|
355
|
+
}, unknown>;
|
|
356
|
+
|
|
357
|
+
declare function useContacts(config: GchatHookConfig, params?: Record<string, string>): _tanstack_react_query.UseQueryResult<{
|
|
358
|
+
data: Contact[];
|
|
359
|
+
total: number;
|
|
360
|
+
}, Error>;
|
|
361
|
+
declare function useGetContact(config: GchatHookConfig, contactId: number | null): _tanstack_react_query.UseQueryResult<Contact, Error>;
|
|
362
|
+
declare function useCreateContact(config: GchatHookConfig): _tanstack_react_query.UseMutationResult<ApiResponse<Contact>, Error, {
|
|
363
|
+
name: string;
|
|
364
|
+
phone_number?: string;
|
|
365
|
+
identifier?: string;
|
|
366
|
+
}, unknown>;
|
|
367
|
+
declare function useUpdateContact(config: GchatHookConfig): _tanstack_react_query.UseMutationResult<ApiResponse<Contact>, Error, {
|
|
368
|
+
id: number;
|
|
369
|
+
body: {
|
|
370
|
+
name?: string;
|
|
371
|
+
phone_number?: string;
|
|
372
|
+
identifier?: string;
|
|
373
|
+
};
|
|
374
|
+
}, unknown>;
|
|
375
|
+
declare function useDeleteContact(config: GchatHookConfig): _tanstack_react_query.UseMutationResult<ApiResponse<void>, Error, number, unknown>;
|
|
376
|
+
|
|
377
|
+
declare function useChannels(config: GchatHookConfig): _tanstack_react_query.UseQueryResult<Channel[], Error>;
|
|
378
|
+
declare function useChannelWhatsappStatus(config: GchatHookConfig, channelId: number | null, enabled?: boolean, pollingInterval?: number): _tanstack_react_query.UseQueryResult<WhatsappStatus, Error>;
|
|
379
|
+
declare function useChannelQR(config: GchatHookConfig, channelId: number | null, enabled?: boolean, pollingInterval?: number): _tanstack_react_query.UseQueryResult<string | null, Error>;
|
|
380
|
+
declare function useCreateChannel(config: GchatHookConfig): _tanstack_react_query.UseMutationResult<ApiResponse<Channel>, Error, Pick<Channel, "name" | "type" | "provider"> & Partial<Pick<Channel, "id_agent" | "identifier">>, unknown>;
|
|
381
|
+
declare function useUpdateChannel(config: GchatHookConfig): _tanstack_react_query.UseMutationResult<ApiResponse<Channel>, Error, {
|
|
382
|
+
id: number;
|
|
383
|
+
body: Partial<Pick<Channel, "name" | "identifier" | "status" | "id_agent">>;
|
|
384
|
+
}, unknown>;
|
|
385
|
+
declare function useDeleteChannel(config: GchatHookConfig): _tanstack_react_query.UseMutationResult<ApiResponse<void>, Error, number, unknown>;
|
|
386
|
+
declare function useConnectChannel(config: GchatHookConfig): _tanstack_react_query.UseMutationResult<ApiResponse<unknown>, Error, number, unknown>;
|
|
387
|
+
declare function useDisconnectChannel(config: GchatHookConfig): _tanstack_react_query.UseMutationResult<ApiResponse<unknown>, Error, number, unknown>;
|
|
388
|
+
declare function useLogoutChannel(config: GchatHookConfig): _tanstack_react_query.UseMutationResult<ApiResponse<unknown>, Error, number, unknown>;
|
|
389
|
+
|
|
150
390
|
interface ChatViewProps {
|
|
151
391
|
messages: InboxMessage[];
|
|
152
392
|
isLoading: boolean;
|
|
@@ -177,4 +417,53 @@ interface MessageBubbleProps {
|
|
|
177
417
|
}
|
|
178
418
|
declare function MessageBubble({ message, onRetry, onRevoke, onEdit, renderActions, }: MessageBubbleProps): react_jsx_runtime.JSX.Element;
|
|
179
419
|
|
|
180
|
-
|
|
420
|
+
interface ContactAvatarProps {
|
|
421
|
+
name: string | null;
|
|
422
|
+
className?: string;
|
|
423
|
+
size?: "sm" | "md" | "lg";
|
|
424
|
+
}
|
|
425
|
+
declare function ContactAvatar({ name, className, size, }: ContactAvatarProps): react_jsx_runtime.JSX.Element;
|
|
426
|
+
|
|
427
|
+
interface InboxItemProps {
|
|
428
|
+
inbox: Inbox;
|
|
429
|
+
isSelected: boolean;
|
|
430
|
+
onClick: () => void;
|
|
431
|
+
onDelete?: (id: number) => void;
|
|
432
|
+
renderActions?: (inbox: Inbox) => React.ReactNode;
|
|
433
|
+
}
|
|
434
|
+
declare function InboxItem({ inbox, isSelected, onClick, onDelete, renderActions, }: InboxItemProps): react_jsx_runtime.JSX.Element;
|
|
435
|
+
|
|
436
|
+
interface InboxSidebarProps {
|
|
437
|
+
inboxes: Inbox[] | undefined;
|
|
438
|
+
isLoading: boolean;
|
|
439
|
+
selectedInboxId: number | null;
|
|
440
|
+
onSelectInbox: (inbox: Inbox) => void;
|
|
441
|
+
onDeleteInbox?: (id: number) => void;
|
|
442
|
+
onCreateInbox?: () => void;
|
|
443
|
+
filterChannelId?: number | null;
|
|
444
|
+
renderHeader?: React.ReactNode;
|
|
445
|
+
renderFooter?: React.ReactNode;
|
|
446
|
+
}
|
|
447
|
+
declare function InboxSidebar({ inboxes, isLoading, selectedInboxId, onSelectInbox, onDeleteInbox, onCreateInbox, filterChannelId, renderHeader, renderFooter, }: InboxSidebarProps): react_jsx_runtime.JSX.Element;
|
|
448
|
+
|
|
449
|
+
interface ContactInfoPanelProps {
|
|
450
|
+
contact: Contact | null;
|
|
451
|
+
isLoading?: boolean;
|
|
452
|
+
onClose?: () => void;
|
|
453
|
+
className?: string;
|
|
454
|
+
}
|
|
455
|
+
declare function ContactInfoPanel({ contact, isLoading, onClose, className, }: ContactInfoPanelProps): react_jsx_runtime.JSX.Element;
|
|
456
|
+
|
|
457
|
+
interface NewConversationDialogProps {
|
|
458
|
+
open: boolean;
|
|
459
|
+
onOpenChange: (open: boolean) => void;
|
|
460
|
+
contacts: Contact[];
|
|
461
|
+
channels: Channel[];
|
|
462
|
+
existingInboxes?: Inbox[];
|
|
463
|
+
onCreateInbox: (contactId: number, channelId: number) => void;
|
|
464
|
+
isCreating?: boolean;
|
|
465
|
+
onCreated?: (inboxId: number) => void;
|
|
466
|
+
}
|
|
467
|
+
declare function NewConversationDialog({ open, onOpenChange, contacts, channels, existingInboxes, onCreateInbox, isCreating, onCreated, }: NewConversationDialogProps): react_jsx_runtime.JSX.Element;
|
|
468
|
+
|
|
469
|
+
export { type ApiResponse, type Channel, ChatInput, type ChatInputProps, ChatView, type ChatViewProps, type Contact, ContactAvatar, type ContactAvatarProps, ContactInfoPanel, type ContactInfoPanelProps, DEFAULT_CHANNEL_STATUS_POLLING, DEFAULT_INBOX_POLLING, DEFAULT_MESSAGES_POLLING, DEFAULT_QR_POLLING, type GchatClientConfig, type GchatHookConfig, type Inbox, InboxItem, type InboxItemProps, type InboxMessage, InboxSidebar, type InboxSidebarProps, type InboxStats, MessageBubble, type MessageBubbleProps, type MessageContentType, NewConversationDialog, type NewConversationDialogProps, type WhatsappStatus, cn, createGchatClient, formatDateGroup, formatMessageTime, groupMessagesByDate, useChannelQR, useChannelWhatsappStatus, useChannels, useConnectChannel, useContacts, useCreateChannel, useCreateContact, useCreateInbox, useDeleteChannel, useDeleteContact, useDeleteInbox, useDisconnectChannel, useEditMessage, useGetContact, useInbox, useInboxMessages, useInboxStats, useInboxes, useLogoutChannel, useRetryMessage, useRevokeMessage, useSendMessage, useUpdateChannel, useUpdateContact, useUpdateInbox };
|