@nodeblocks/frontend-chat-conversation-block 0.1.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.
@@ -0,0 +1,86 @@
1
+ import { AvatarProps } from '@basaldev/blocks-frontend-framework';
2
+ import { ReactNode } from 'react';
3
+ type ChatConversationContextValue = {
4
+ /** Callback when submitting a message*/
5
+ onMessageSubmit?: (text: string) => void;
6
+ /** Callback on comment change */
7
+ onInputChange?: (text: string) => void;
8
+ /** Configs for the comment input at the bottom of the page */
9
+ commentInput?: {
10
+ /** Disables input (while submitting or similar) */
11
+ isDisabled?: boolean;
12
+ /** Error message to show below the comment input field */
13
+ errorText?: string;
14
+ };
15
+ /** Configs for the comment input submit button */
16
+ commentSubmitButton?: {
17
+ /** Disables input (while submitting or similar) */
18
+ isDisabled?: boolean;
19
+ };
20
+ /** Chat panel configuration */
21
+ chatView: {
22
+ /** Configuration for the chat view heading above the chat view */
23
+ heading?: {
24
+ avatar?: AvatarProps;
25
+ buttonHref: string;
26
+ };
27
+ /**
28
+ * Loading state for either overall view or for previous methods
29
+ * (depends on whether messages is empty)
30
+ */
31
+ isLoading?: boolean;
32
+ /**
33
+ * Callback when the user has scrolled up and reached the top of the chat view
34
+ * This can be used to fetch more messages from the server.
35
+ */
36
+ onScrollTop?: (earliestMessageId: string) => void;
37
+ };
38
+ /**
39
+ * The list of messages to show in the chat view
40
+ * Messages should always be provided newest-first.
41
+ * They will be displayed with the newest at the bottom.
42
+ *
43
+ * When the latest message id changes, the user scroll will be
44
+ * updated automatically if the user is currently at the bottom, otherwise
45
+ * they will remain where they are.
46
+ */
47
+ messages: {
48
+ /** Avatar used if no image is provided; if not provided, no avatar shown */
49
+ avatarColor?: AvatarProps['avatarColor'];
50
+ /** Avatar link href (requires onNavigate) */
51
+ avatarHref?: AvatarProps['href'];
52
+ /** Avatar picture */
53
+ avatarUrl?: AvatarProps['avatarUrl'];
54
+ /** Message bubble content */
55
+ content: string;
56
+ /**
57
+ * Date time the message was created at, as an ISO string
58
+ * Messages will then be grouped by days based on the configured locale via
59
+ * the luxon library
60
+ */
61
+ createdAt: string;
62
+ /** Identifier for this message (for callbacks) */
63
+ id: string;
64
+ /** Messages that are your own are highlighted */
65
+ isOwnMessage?: boolean;
66
+ /** Title string (appears above the bubble) */
67
+ title?: string;
68
+ }[];
69
+ /** Label text configuration */
70
+ labels: {
71
+ chatViewHeadingButtonText?: string;
72
+ chatViewHeadingText?: string;
73
+ };
74
+ /** Navigation callback (required for href) */
75
+ onNavigate: (url: string) => void;
76
+ /** Placeholder text configuration */
77
+ placeholders: {
78
+ commentInput: string;
79
+ };
80
+ };
81
+ export declare const ChatConversationProvider: ({ children, ...value }: ChatConversationContextValue & {
82
+ children: ReactNode;
83
+ }) => import("react/jsx-runtime").JSX.Element;
84
+ export declare const useChatConversationContext: () => ChatConversationContextValue;
85
+ export {};
86
+ //# sourceMappingURL=context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,qCAAqC,CAAC;AAClE,OAAO,EAAiB,SAAS,EAAc,MAAM,OAAO,CAAC;AAE7D,KAAK,4BAA4B,GAAG;IAClC,wCAAwC;IACxC,eAAe,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC,iCAAiC;IACjC,aAAa,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAEvC,8DAA8D;IAC9D,YAAY,CAAC,EAAE;QACb,mDAAmD;QACnD,UAAU,CAAC,EAAE,OAAO,CAAC;QAIrB,0DAA0D;QAC1D,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,CAAC;IACF,kDAAkD;IAClD,mBAAmB,CAAC,EAAE;QACpB,mDAAmD;QACnD,UAAU,CAAC,EAAE,OAAO,CAAC;KACtB,CAAC;IACF,+BAA+B;IAC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