whatsapp-ui-react 0.0.3 → 0.0.5
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 +120 -57
- package/dist/components/Animated/Animated.d.ts +17 -0
- package/dist/components/Animated/Animated.d.ts.map +1 -0
- package/dist/components/Animated/index.d.ts +3 -0
- package/dist/components/Animated/index.d.ts.map +1 -0
- package/dist/components/Chat/Chat.d.ts +15 -3
- package/dist/components/Chat/Chat.d.ts.map +1 -1
- package/dist/components/Chat/Header.d.ts.map +1 -1
- package/dist/components/History/History.d.ts +16 -0
- package/dist/components/History/History.d.ts.map +1 -0
- package/dist/components/History/index.d.ts +3 -0
- package/dist/components/History/index.d.ts.map +1 -0
- package/dist/components/Message/Message.d.ts +17 -6
- package/dist/components/Message/Message.d.ts.map +1 -1
- package/dist/components/Message/MessageContext.d.ts +1 -4
- package/dist/components/Message/MessageContext.d.ts.map +1 -1
- package/dist/components/Message/Voice/Waveform.d.ts +1 -1
- package/dist/components/Message/Voice/Waveform.d.ts.map +1 -1
- package/dist/hooks/useMessages.d.ts +2 -8
- package/dist/hooks/useMessages.d.ts.map +1 -1
- package/dist/index.cjs +156 -25
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +6 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +156 -25
- package/dist/index.js.map +1 -1
- package/dist/style.css +688 -0
- package/dist/utils/groupMessages.d.ts +1 -1
- package/package.json +8 -5
- package/src/css/dark.css +31 -0
- package/src/css/light.css +31 -0
- package/src/css/preset.css +1 -0
- package/dist/tailwind.css +0 -2
package/README.md
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
# whatsapp-ui-react
|
|
2
2
|
|
|
3
|
-
React component library
|
|
3
|
+
A React component library that provides a chat window interface inspired by the design and interaction patterns of WhatsApp Web.
|
|
4
|
+
|
|
5
|
+
**Notice:** Some components are still placeholders and may not be fully functional; breaking changes may occur between releases.
|
|
6
|
+
|
|
7
|
+
## Goal
|
|
8
|
+
|
|
9
|
+
This library was created to better understand WhatsApp's design system and interaction patterns. It is intended purely for educational purposes, including studying UI architecture, component composition, and interaction modeling. **It is not intended to be an official client or production-ready replacement.**
|
|
10
|
+
|
|
11
|
+
## Disclaimer
|
|
12
|
+
|
|
13
|
+
This project is not affiliated, associated, authorized, endorsed by, or in any way officially connected with WhatsApp or any of its subsidiaries or its affiliates. The official WhatsApp website can be found at whatsapp.com. "WhatsApp" as well as related names, marks, emblems and images are registered trademarks of their respective owners.
|
|
4
14
|
|
|
5
15
|
## Install
|
|
6
16
|
|
|
@@ -12,67 +22,87 @@ npm install whatsapp-ui-react
|
|
|
12
22
|
|
|
13
23
|
## Setup
|
|
14
24
|
|
|
15
|
-
Import the component styles into your CSS entry point:
|
|
16
|
-
|
|
17
25
|
```css
|
|
26
|
+
/* global.css */
|
|
18
27
|
@import 'tailwindcss';
|
|
19
|
-
@import 'whatsapp-ui-react/
|
|
28
|
+
@import 'whatsapp-ui-react/css/dark.css';
|
|
29
|
+
@import 'whatsapp-ui-react/css/preset.css';
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Use `light.css` instead for a light theme:
|
|
33
|
+
|
|
34
|
+
```css
|
|
35
|
+
@import 'whatsapp-ui-react/css/light.css';
|
|
20
36
|
```
|
|
21
37
|
|
|
22
38
|
## Usage
|
|
23
39
|
|
|
24
40
|
### Chat
|
|
25
41
|
|
|
42
|
+
<!--prettier-ignore-->
|
|
26
43
|
```tsx
|
|
27
|
-
import { Chat } from 'whatsapp-ui-react'
|
|
28
|
-
|
|
44
|
+
import { Chat } from 'whatsapp-ui-react';
|
|
45
|
+
<Chat name="Alice" subtitle="online" />
|
|
29
46
|
```
|
|
30
47
|
|
|
31
48
|
### Messages
|
|
32
49
|
|
|
50
|
+
<!--prettier-ignore-->
|
|
33
51
|
```tsx
|
|
34
|
-
import { Chat, Message, Text } from 'whatsapp-ui-react'
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
timestamp:
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
52
|
+
import { Chat, History, Message, Text } from 'whatsapp-ui-react';
|
|
53
|
+
|
|
54
|
+
<Chat name="Alice">
|
|
55
|
+
<History>
|
|
56
|
+
<Message direction="in" senderId="alice" timestamp="2026-03-03T09:41:00Z" mode="neutral" time="09:41">
|
|
57
|
+
<Text content="Hey! 👋" />
|
|
58
|
+
</Message>
|
|
59
|
+
<Message direction="out" senderId="me" timestamp="2026-03-03T09:42:00Z" mode="neutral" time="09:42" status="read">
|
|
60
|
+
<Text content="Hi! How are you?" />
|
|
61
|
+
</Message>
|
|
62
|
+
</History>
|
|
63
|
+
</Chat>
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Animated messages
|
|
49
67
|
|
|
50
|
-
|
|
68
|
+
<!--prettier-ignore-->
|
|
69
|
+
```tsx
|
|
70
|
+
import { Chat, History, Message, Text, Animated } from 'whatsapp-ui-react';
|
|
71
|
+
|
|
72
|
+
<Chat name="Support Bot">
|
|
73
|
+
<History>
|
|
74
|
+
<Animated delay={1500}>
|
|
75
|
+
<Message direction="in" senderId="bot" timestamp="2026-03-03T09:00:00Z" mode="neutral" time="09:00">
|
|
76
|
+
<Text content="Hello! How can I help you?" />
|
|
77
|
+
</Message>
|
|
78
|
+
</Animated>
|
|
79
|
+
</History>
|
|
80
|
+
</Chat>
|
|
51
81
|
```
|
|
52
82
|
|
|
53
83
|
### Content types
|
|
54
84
|
|
|
55
|
-
| Component | Description |
|
|
56
|
-
| ------------ | ----------------------------- |
|
|
57
|
-
| `<Text>` | Plain text |
|
|
58
|
-
| `<Image>` | Image with optional caption |
|
|
59
|
-
| `<Video>` | Video with thumbnail |
|
|
60
|
-
| `<Audio>` | Audio file attachment |
|
|
61
|
-
| `<Voice>` | Voice message with waveform |
|
|
62
|
-
| `<Sticker>` | Sticker (frameless image) |
|
|
63
|
-
| `<Gif>` | Animated GIF |
|
|
64
|
-
| `<File>` | Generic file attachment |
|
|
65
|
-
| `<Contact>` | Contact card |
|
|
66
|
-
| `<Location>` | Location pin with map preview |
|
|
67
|
-
| `<Poll>` | Poll with options |
|
|
68
|
-
| `<Emoji>` | Large emoji message |
|
|
69
|
-
| `<Event>` | Event card |
|
|
85
|
+
| Component | Description | Implemented |
|
|
86
|
+
| ------------ | ----------------------------- | ----------- |
|
|
87
|
+
| `<Text>` | Plain text | ✅ |
|
|
88
|
+
| `<Image>` | Image with optional caption | |
|
|
89
|
+
| `<Video>` | Video with thumbnail | |
|
|
90
|
+
| `<Audio>` | Audio file attachment | ✅ |
|
|
91
|
+
| `<Voice>` | Voice message with waveform | ✅ |
|
|
92
|
+
| `<Sticker>` | Sticker (frameless image) | ✅ |
|
|
93
|
+
| `<Gif>` | Animated GIF | |
|
|
94
|
+
| `<File>` | Generic file attachment | |
|
|
95
|
+
| `<Contact>` | Contact card | |
|
|
96
|
+
| `<Location>` | Location pin with map preview | |
|
|
97
|
+
| `<Poll>` | Poll with options | |
|
|
98
|
+
| `<Emoji>` | Large emoji message | |
|
|
99
|
+
| `<Event>` | Event card | |
|
|
70
100
|
|
|
71
101
|
### Reply rules
|
|
72
102
|
|
|
73
103
|
Automated replies that fire when an incoming message matches a trigger:
|
|
74
104
|
|
|
75
|
-
<!--
|
|
105
|
+
<!--prettier-ignore-->
|
|
76
106
|
```tsx
|
|
77
107
|
import { Chat, Message, Text, Reply } from 'whatsapp-ui-react';
|
|
78
108
|
|
|
@@ -108,27 +138,60 @@ Set `locked` to disable sending while still allowing typing:
|
|
|
108
138
|
<Chat name="Read-only" locked />
|
|
109
139
|
```
|
|
110
140
|
|
|
141
|
+
## `<History>` props
|
|
142
|
+
|
|
143
|
+
| Prop | Type | Default | Description |
|
|
144
|
+
| ----------- | ----------- | ------- | ------------------------------------------------------------------------------------------------ |
|
|
145
|
+
| `children` | `ReactNode` | | `<Message>` elements, optionally wrapped in `<Animated>`. Anything else is passed through as-is. |
|
|
146
|
+
| `className` | `string` | | Additional CSS class names applied to the wrapper element |
|
|
147
|
+
|
|
148
|
+
## `<Animated>` props
|
|
149
|
+
|
|
150
|
+
| Prop | Type | Default | Description |
|
|
151
|
+
| ----------- | ----------- | ------- | --------------------------------------------------------- |
|
|
152
|
+
| `delay` | `number` | `0` | Milliseconds from mount until the content fades in |
|
|
153
|
+
| `children` | `ReactNode` | | Content to reveal |
|
|
154
|
+
| `className` | `string` | | Additional CSS class names applied to the wrapper element |
|
|
155
|
+
|
|
156
|
+
## `<Message>` props
|
|
157
|
+
|
|
158
|
+
| Prop | Type | Default | Description |
|
|
159
|
+
| ------------ | ---------------------------------------------- | ---------- | ---------------------------------------------------------------------------------------------------- |
|
|
160
|
+
| `direction` | `'in' \| 'out'` | | Received (`'in'`) or sent (`'out'`) message |
|
|
161
|
+
| `mode` | `'neutral' \| 'free' \| 'custom'` | `'custom'` | Layout mode: `'neutral'` overlays the timestamp; `'free'` floats it below; `'custom'` is unwrapped |
|
|
162
|
+
| `top` | `boolean` | `false` | First message in a consecutive run - renders the bubble tail. Injected automatically by `<History>`. |
|
|
163
|
+
| `group` | `boolean` | `false` | Group chat mode - shows sender avatar when `top` is `true` |
|
|
164
|
+
| `avatarUrl` | `string` | | Sender avatar URL (group chats) |
|
|
165
|
+
| `senderName` | `string` | | Sender display name (group chats) |
|
|
166
|
+
| `time` | `string` | | Formatted time string shown in the bubble footer |
|
|
167
|
+
| `status` | `'sending' \| 'sent' \| 'delivered' \| 'read'` | | Delivery status icon (outgoing messages only) |
|
|
168
|
+
| `senderId` | `string` | | Identifies the sender; used by `<History>` for grouping. No visual effect. |
|
|
169
|
+
| `timestamp` | `string \| Date` | | ISO string or `Date` for the message time; used by `<History>` for day dividers. No visual effect. |
|
|
170
|
+
| `className` | `string` | | Additional CSS class names applied to the root element |
|
|
171
|
+
|
|
111
172
|
## `<Chat>` props
|
|
112
173
|
|
|
113
|
-
| Prop | Type
|
|
114
|
-
| -------------------- |
|
|
115
|
-
| `name` | `string`
|
|
116
|
-
| `avatarUrl` | `string`
|
|
117
|
-
| `subtitle` | `string`
|
|
118
|
-
| `
|
|
119
|
-
| `showInputfield` | `boolean`
|
|
120
|
-
| `locked` | `boolean`
|
|
121
|
-
| `inputPlaceholder` | `string`
|
|
122
|
-
| `inputValue` | `string`
|
|
123
|
-
| `defaultInputValue` | `string`
|
|
124
|
-
| `onInputValueChange` | `(v: string) => void`
|
|
125
|
-
| `onSendMessage` | `(v: string) => void`
|
|
126
|
-
| `onReply` | `ReactNode`
|
|
127
|
-
| `background` | `string \| null`
|
|
128
|
-
| `onEmojiClick` | `() => void`
|
|
129
|
-
| `onAttachClick` | `() => void`
|
|
130
|
-
| `
|
|
174
|
+
| Prop | Type | Default | Description |
|
|
175
|
+
| -------------------- | --------------------------------- | -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
|
|
176
|
+
| `name` | `string` | | Contact or group name |
|
|
177
|
+
| `avatarUrl` | `'online' \| 'typeing' \| string` | | Avatar image URL |
|
|
178
|
+
| `subtitle` | `string` | | Status text below the name |
|
|
179
|
+
| `children` | `ReactNode` | | Static content rendered at the top of the message area. Typically a `<History>` component. |
|
|
180
|
+
| `showInputfield` | `boolean` | `true` | Show / hide the input bar |
|
|
181
|
+
| `locked` | `boolean` | `false` | Allow typing but disable sending |
|
|
182
|
+
| `inputPlaceholder` | `string` | `'Enter a message.'` | Textarea placeholder |
|
|
183
|
+
| `inputValue` | `string` | | Controlled input value (use with `onInputValueChange`) |
|
|
184
|
+
| `defaultInputValue` | `string` | | Uncontrolled initial value (internal state managed by component) |
|
|
185
|
+
| `onInputValueChange` | `(v: string) => void` | | Called on every keystroke |
|
|
186
|
+
| `onSendMessage` | `(v: string) => void` | | Called when a message is sent |
|
|
187
|
+
| `onReply` | `ReactNode` | | `<Reply>` rules rendered inside the chat context |
|
|
188
|
+
| `background` | `string \| null` | background image | Message area background. Hex color string for a solid fill; `null` or `'none'` for plain `#0a0a0a`; omit to use the default tiled image. |
|
|
189
|
+
| `onEmojiClick` | `() => void` | | Emoji button click handler |
|
|
190
|
+
| `onAttachClick` | `() => void` | | Attach button click handler |
|
|
191
|
+
| `onCameraClick` | `() => void` | | Camera button click handler |
|
|
192
|
+
| `onMicClick` | `() => void` | | Mic button click handler |
|
|
193
|
+
| `theme` | `'dark' \| 'light'` | | Sets `data-wa-theme` theme for the chat |
|
|
131
194
|
|
|
132
195
|
## License
|
|
133
196
|
|
|
134
|
-
Apache
|
|
197
|
+
This project is licensed under the Apache License 2.0.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
/** Props for the {@link Animated} component. */
|
|
3
|
+
export interface AnimatedProps {
|
|
4
|
+
/** Delay in milliseconds from mount until the content fades in. @defaultValue `0` */
|
|
5
|
+
delay?: number;
|
|
6
|
+
/** Content to reveal. */
|
|
7
|
+
children: React.ReactNode;
|
|
8
|
+
/** Additional CSS class names applied to the wrapper element. */
|
|
9
|
+
className?: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Reveals children with a fade-in transition after `delay` ms from mount.
|
|
13
|
+
* Returns an empty fragment until the delay fires, so hidden content takes no space.
|
|
14
|
+
*/
|
|
15
|
+
declare function Animated({ delay, children, className }: AnimatedProps): React.JSX.Element;
|
|
16
|
+
export { Animated };
|
|
17
|
+
//# sourceMappingURL=Animated.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Animated.d.ts","sourceRoot":"","sources":["../../../src/components/Animated/Animated.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,gDAAgD;AAChD,MAAM,WAAW,aAAa;IAC5B,qFAAqF;IACrF,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,yBAAyB;IACzB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,iEAAiE;IACjE,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED;;;GAGG;AACH,iBAAS,QAAQ,CAAC,EAAE,KAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,aAAa,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CAiCtF;AAED,OAAO,EAAE,QAAQ,EAAE,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Animated/index.ts"],"names":[],"mappings":"AAAA,mBAAmB,YAAY,CAAA;AAC/B,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA"}
|
|
@@ -15,12 +15,18 @@ export interface ChatProps {
|
|
|
15
15
|
/** URL of the avatar image. Falls back to initials derived from `name` when omitted. */
|
|
16
16
|
avatarUrl?: string;
|
|
17
17
|
/** Secondary line displayed below `name` in the header (e.g. `"online"` or `"typing..."`). */
|
|
18
|
-
subtitle?: string;
|
|
19
|
-
/**
|
|
18
|
+
subtitle?: 'online' | 'typing...' | string;
|
|
19
|
+
/**
|
|
20
|
+
* Static content rendered at the top of the message area. Typically a `<History>` component.
|
|
21
|
+
* Rendered unconditionally above any dynamically added messages.
|
|
22
|
+
*/
|
|
20
23
|
children?: React.ReactNode;
|
|
21
24
|
/** Additional CSS class names applied to the root element. */
|
|
22
25
|
className?: string;
|
|
23
|
-
/**
|
|
26
|
+
/**
|
|
27
|
+
* Initial message list. Copied into internal state on mount; subsequent external changes are ignored.
|
|
28
|
+
* @deprecated Pass a `<History>` as `children` instead.
|
|
29
|
+
*/
|
|
24
30
|
messageHistory?: GroupedMessage[];
|
|
25
31
|
/** Controls visibility of the input bar. @defaultValue `true` */
|
|
26
32
|
showInputfield?: boolean;
|
|
@@ -53,6 +59,12 @@ export interface ChatProps {
|
|
|
53
59
|
onCameraClick?: () => void;
|
|
54
60
|
/** Handler for the microphone button in the input bar. */
|
|
55
61
|
onMicClick?: () => void;
|
|
62
|
+
/**
|
|
63
|
+
* Visual colour theme for the chat window.
|
|
64
|
+
* - `'dark'` (default): WhatsApp dark style.
|
|
65
|
+
* - `'light'`: WhatsApp light style.
|
|
66
|
+
*/
|
|
67
|
+
theme?: 'dark' | 'light';
|
|
56
68
|
}
|
|
57
69
|
/**
|
|
58
70
|
* Top-level chat component. Manages the message list state and composes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Chat.d.ts","sourceRoot":"","sources":["../../../src/components/Chat/Chat.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,OAAO,CAAA;AAIzB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAKnD,2DAA2D;AAC3D,MAAM,WAAW,UAAU;IACzB,0DAA0D;IAC1D,UAAU,EAAE,CAAC,OAAO,EAAE;QAAE,IAAI,EAAE,KAAK,CAAC,SAAS,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAA;CAC5E;AAED,4CAA4C;AAC5C,MAAM,WAAW,SAAS;IACxB,6CAA6C;IAC7C,IAAI,EAAE,MAAM,CAAA;IACZ,wFAAwF;IACxF,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,8FAA8F;IAC9F,QAAQ,CAAC,EAAE,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"Chat.d.ts","sourceRoot":"","sources":["../../../src/components/Chat/Chat.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,OAAO,CAAA;AAIzB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAKnD,2DAA2D;AAC3D,MAAM,WAAW,UAAU;IACzB,0DAA0D;IAC1D,UAAU,EAAE,CAAC,OAAO,EAAE;QAAE,IAAI,EAAE,KAAK,CAAC,SAAS,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAA;CAC5E;AAED,4CAA4C;AAC5C,MAAM,WAAW,SAAS;IACxB,6CAA6C;IAC7C,IAAI,EAAE,MAAM,CAAA;IACZ,wFAAwF;IACxF,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,8FAA8F;IAC9F,QAAQ,CAAC,EAAE,QAAQ,GAAG,WAAW,GAAG,MAAM,CAAA;IAC1C;;;OAGG;IACH,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC1B,8DAA8D;IAC9D,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB;;;OAGG;IACH,cAAc,CAAC,EAAE,cAAc,EAAE,CAAA;IACjC,iEAAiE;IACjE,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,iIAAiI;IACjI,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,4EAA4E;IAC5E,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,qGAAqG;IACrG,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,2CAA2C;IAC3C,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,oEAAoE;IACpE,kBAAkB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IAC5C,sHAAsH;IACtH,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IACvC,4GAA4G;IAC5G,OAAO,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB;;;;;OAKG;IACH,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1B,6DAA6D;IAC7D,YAAY,CAAC,EAAE,MAAM,IAAI,CAAA;IACzB,0DAA0D;IAC1D,aAAa,CAAC,EAAE,MAAM,IAAI,CAAA;IAC1B,sDAAsD;IACtD,aAAa,CAAC,EAAE,MAAM,IAAI,CAAA;IAC1B,0DAA0D;IAC1D,UAAU,CAAC,EAAE,MAAM,IAAI,CAAA;IACvB;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;CACzB;AAED;;;;;;GAMG;AACH,QAAA,MAAM,IAAI,8EA0IR,CAAA;AAEF,OAAO,EAAE,IAAI,EAAE,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Header.d.ts","sourceRoot":"","sources":["../../../src/components/Chat/Header.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,gBAAgB;AAChB,UAAU,eAAe;IACvB,8DAA8D;IAC9D,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,oDAAoD;IACpD,IAAI,EAAE,MAAM,CAAA;IACZ,wFAAwF;IACxF,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,iFAAiF;IACjF,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAED,iBAAS,UAAU,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,eAAe,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,
|
|
1
|
+
{"version":3,"file":"Header.d.ts","sourceRoot":"","sources":["../../../src/components/Chat/Header.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,gBAAgB;AAChB,UAAU,eAAe;IACvB,8DAA8D;IAC9D,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,oDAAoD;IACpD,IAAI,EAAE,MAAM,CAAA;IACZ,wFAAwF;IACxF,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,iFAAiF;IACjF,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAED,iBAAS,UAAU,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,eAAe,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CA2BhG;AAED,OAAO,EAAE,UAAU,EAAE,CAAA;AACrB,YAAY,EAAE,eAAe,EAAE,CAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
/** Props for the {@link History} component. */
|
|
3
|
+
export interface HistoryProps {
|
|
4
|
+
/** `<Message>` elements to render, optionally wrapped in `<Animated>`. Manual `<DayDivider>` elements are passed through unchanged. */
|
|
5
|
+
children?: React.ReactNode;
|
|
6
|
+
/** Additional CSS class names applied to the wrapper element. */
|
|
7
|
+
className?: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Renders a static chat history from JSX children.
|
|
11
|
+
* Automatically injects `top={true}` into the first message of each consecutive sender group,
|
|
12
|
+
* inserts `<DayDivider>` between calendar days, and shows a "Today" divider when the history is empty.
|
|
13
|
+
*/
|
|
14
|
+
declare function History({ children, className }: HistoryProps): React.JSX.Element;
|
|
15
|
+
export { History };
|
|
16
|
+
//# sourceMappingURL=History.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"History.d.ts","sourceRoot":"","sources":["../../../src/components/History/History.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,+CAA+C;AAC/C,MAAM,WAAW,YAAY;IAC3B,uIAAuI;IACvI,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC1B,iEAAiE;IACjE,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED;;;;GAIG;AACH,iBAAS,OAAO,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,YAAY,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CAgHzE;AAED,OAAO,EAAE,OAAO,EAAE,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/History/index.ts"],"names":[],"mappings":"AAAA,mBAAmB,WAAW,CAAA;AAC9B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA"}
|
|
@@ -4,23 +4,23 @@ import { MessageDirection, MessageStatus } from './MessageContext';
|
|
|
4
4
|
export interface MessageProps {
|
|
5
5
|
/** `'in'` for received messages, `'out'` for sent. */
|
|
6
6
|
direction: MessageDirection;
|
|
7
|
-
/** First message in a consecutive run
|
|
7
|
+
/** First message in a consecutive run - renders the bubble tail. @defaultValue `false` */
|
|
8
8
|
top?: boolean;
|
|
9
|
-
/** Part of a group chat
|
|
9
|
+
/** Part of a group chat - renders the sender avatar when `top` is `true`. @defaultValue `false` */
|
|
10
10
|
group?: boolean;
|
|
11
11
|
/** Sender avatar URL (group chats). */
|
|
12
12
|
avatarUrl?: string;
|
|
13
13
|
/** Sender display name (group chats). */
|
|
14
14
|
senderName?: string;
|
|
15
|
-
/** Message content
|
|
15
|
+
/** Message content - typically one of the content components (`<Text>`, `<Image>`, etc.). */
|
|
16
16
|
children: React.ReactNode;
|
|
17
17
|
/** Additional CSS class names applied to the root element. */
|
|
18
18
|
className?: string;
|
|
19
19
|
/**
|
|
20
20
|
* Layout mode.
|
|
21
|
-
* - `'neutral'`
|
|
22
|
-
* - `'free'`
|
|
23
|
-
* - `'custom'`
|
|
21
|
+
* - `'neutral'` - standard bubble with overlaid timestamp
|
|
22
|
+
* - `'free'` - content fills the bubble, timestamp floats below
|
|
23
|
+
* - `'custom'` - children render directly with no wrapper
|
|
24
24
|
* @defaultValue `'custom'`
|
|
25
25
|
*/
|
|
26
26
|
mode?: 'neutral' | 'free' | 'custom';
|
|
@@ -28,6 +28,17 @@ export interface MessageProps {
|
|
|
28
28
|
time?: string;
|
|
29
29
|
/** Delivery status icon shown on outgoing messages. */
|
|
30
30
|
status?: MessageStatus;
|
|
31
|
+
/**
|
|
32
|
+
* Identifies the sender; used by `<History>` to group consecutive messages.
|
|
33
|
+
* Use `'me'` for the local user. Has no visual effect on its own.
|
|
34
|
+
*/
|
|
35
|
+
senderId?: string;
|
|
36
|
+
/**
|
|
37
|
+
* ISO string or `Date` marking when the message was sent.
|
|
38
|
+
* Used by `<History>` to insert day-dividers and detect grouping boundaries.
|
|
39
|
+
* Has no visual effect on its own.
|
|
40
|
+
*/
|
|
41
|
+
timestamp?: string | Date;
|
|
31
42
|
}
|
|
32
43
|
declare function Message({ direction, top, group, avatarUrl, senderName, children, className, mode, time, status, }: MessageProps): React.JSX.Element;
|
|
33
44
|
export { Message };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Message.d.ts","sourceRoot":"","sources":["../../../src/components/Message/Message.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAIvE,+CAA+C;AAC/C,MAAM,WAAW,YAAY;IAC3B,sDAAsD;IACtD,SAAS,EAAE,gBAAgB,CAAA;IAC3B,0FAA0F;IAC1F,GAAG,CAAC,EAAE,OAAO,CAAA;IACb,mGAAmG;IACnG,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,uCAAuC;IACvC,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,yCAAyC;IACzC,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,6FAA6F;IAC7F,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,8DAA8D;IAC9D,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB;;;;;;OAMG;IACH,IAAI,CAAC,EAAE,SAAS,GAAG,MAAM,GAAG,QAAQ,CAAA;IACpC,wDAAwD;IACxD,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,uDAAuD;IACvD,MAAM,CAAC,EAAE,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"Message.d.ts","sourceRoot":"","sources":["../../../src/components/Message/Message.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAIvE,+CAA+C;AAC/C,MAAM,WAAW,YAAY;IAC3B,sDAAsD;IACtD,SAAS,EAAE,gBAAgB,CAAA;IAC3B,0FAA0F;IAC1F,GAAG,CAAC,EAAE,OAAO,CAAA;IACb,mGAAmG;IACnG,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,uCAAuC;IACvC,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,yCAAyC;IACzC,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,6FAA6F;IAC7F,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,8DAA8D;IAC9D,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB;;;;;;OAMG;IACH,IAAI,CAAC,EAAE,SAAS,GAAG,MAAM,GAAG,QAAQ,CAAA;IACpC,wDAAwD;IACxD,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,uDAAuD;IACvD,MAAM,CAAC,EAAE,aAAa,CAAA;IACtB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAC1B;AAED,iBAAS,OAAO,CAAC,EACf,SAAS,EACT,GAAW,EACX,KAAa,EACb,SAAS,EACT,UAAU,EACV,QAAQ,EACR,SAAS,EACT,IAAe,EACf,IAAI,EACJ,MAAM,GACP,EAAE,YAAY,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CA6FlC;AAED,OAAO,EAAE,OAAO,EAAE,CAAA"}
|
|
@@ -23,10 +23,7 @@ export interface MessageContextValue {
|
|
|
23
23
|
status?: MessageStatus;
|
|
24
24
|
}
|
|
25
25
|
declare const MessageContext: React.Context<MessageContextValue>;
|
|
26
|
-
/**
|
|
27
|
-
* Returns the context provided by the nearest ancestor {@link Message}.
|
|
28
|
-
* Use inside custom message content components.
|
|
29
|
-
*/
|
|
26
|
+
/** Returns the context provided by the nearest ancestor `<Message>`. */
|
|
30
27
|
declare function useMessage(): MessageContextValue;
|
|
31
28
|
export { MessageContext, useMessage };
|
|
32
29
|
//# sourceMappingURL=MessageContext.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MessageContext.d.ts","sourceRoot":"","sources":["../../../src/components/Message/MessageContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,qCAAqC;AACrC,MAAM,MAAM,gBAAgB,GAAG,IAAI,GAAG,KAAK,CAAA;AAE3C,8CAA8C;AAC9C,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,MAAM,GAAG,WAAW,GAAG,MAAM,CAAA;AAErE,+CAA+C;AAC/C,MAAM,MAAM,WAAW,GACnB,MAAM,GACN,OAAO,GACP,KAAK,GACL,OAAO,GACP,OAAO,GACP,SAAS,GACT,MAAM,GACN,QAAQ,CAAA;AAEZ,iEAAiE;AACjE,MAAM,WAAW,mBAAmB;IAClC,+CAA+C;IAC/C,SAAS,EAAE,gBAAgB,CAAA;IAC3B,gGAAgG;IAChG,GAAG,EAAE,OAAO,CAAA;IACZ,wFAAwF;IACxF,KAAK,EAAE,OAAO,CAAA;IACd,qDAAqD;IACrD,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,mDAAmD;IACnD,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,kCAAkC;IAClC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,uBAAuB;IACvB,MAAM,CAAC,EAAE,aAAa,CAAA;CACvB;AAED,QAAA,MAAM,cAAc,oCAIlB,CAAA;AAEF
|
|
1
|
+
{"version":3,"file":"MessageContext.d.ts","sourceRoot":"","sources":["../../../src/components/Message/MessageContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,qCAAqC;AACrC,MAAM,MAAM,gBAAgB,GAAG,IAAI,GAAG,KAAK,CAAA;AAE3C,8CAA8C;AAC9C,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,MAAM,GAAG,WAAW,GAAG,MAAM,CAAA;AAErE,+CAA+C;AAC/C,MAAM,MAAM,WAAW,GACnB,MAAM,GACN,OAAO,GACP,KAAK,GACL,OAAO,GACP,OAAO,GACP,SAAS,GACT,MAAM,GACN,QAAQ,CAAA;AAEZ,iEAAiE;AACjE,MAAM,WAAW,mBAAmB;IAClC,+CAA+C;IAC/C,SAAS,EAAE,gBAAgB,CAAA;IAC3B,gGAAgG;IAChG,GAAG,EAAE,OAAO,CAAA;IACZ,wFAAwF;IACxF,KAAK,EAAE,OAAO,CAAA;IACd,qDAAqD;IACrD,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,mDAAmD;IACnD,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,kCAAkC;IAClC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,uBAAuB;IACvB,MAAM,CAAC,EAAE,aAAa,CAAA;CACvB;AAED,QAAA,MAAM,cAAc,oCAIlB,CAAA;AAEF,wEAAwE;AACxE,iBAAS,UAAU,IAAI,mBAAmB,CAEzC;AAED,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,CAAA"}
|
|
@@ -2,7 +2,7 @@ import { default as React } from 'react';
|
|
|
2
2
|
export declare const CANVAS_WIDTH = 200;
|
|
3
3
|
/** @internal */
|
|
4
4
|
export interface WaveformProps {
|
|
5
|
-
/** Amplitude bars to render
|
|
5
|
+
/** Amplitude bars to render - array of `BAR_COUNT` values in the range `0`–`10`. */
|
|
6
6
|
bars: number[];
|
|
7
7
|
/** Playback progress in the range `0`–`1`; determines the played/unplayed colour split. */
|
|
8
8
|
progress: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Waveform.d.ts","sourceRoot":"","sources":["../../../../src/components/Message/Voice/Waveform.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA4B,MAAM,OAAO,CAAA;AAGhD,eAAO,MAAM,YAAY,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"Waveform.d.ts","sourceRoot":"","sources":["../../../../src/components/Message/Voice/Waveform.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA4B,MAAM,OAAO,CAAA;AAGhD,eAAO,MAAM,YAAY,MAAM,CAAA;AAc/B,gBAAgB;AAChB,MAAM,WAAW,aAAa;IAC5B,oFAAoF;IACpF,IAAI,EAAE,MAAM,EAAE,CAAA;IACd,2FAA2F;IAC3F,QAAQ,EAAE,MAAM,CAAA;IAChB,kFAAkF;IAClF,KAAK,EAAE,OAAO,CAAA;IACd,8EAA8E;IAC9E,SAAS,EAAE,OAAO,CAAA;IAClB,+FAA+F;IAC/F,IAAI,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAA;CACjC;AAED,iBAAS,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,aAAa,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CA0D9F;AAED,OAAO,EAAE,QAAQ,EAAE,CAAA"}
|
|
@@ -1,13 +1,7 @@
|
|
|
1
1
|
import { GroupedMessage } from '../utils/groupMessages';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* Must be rendered inside a component that is a descendant of <Chat>
|
|
7
|
-
* (i.e. inside the `onReply` prop or any other child rendered in context).
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* useMessages(msg => console.log(msg.senderId, msg.node))
|
|
3
|
+
* Calls `callback` for every new message that arrives in the nearest `<Chat>`.
|
|
4
|
+
* Must be rendered as a descendant of `<Chat>` (e.g. via the `onReply` prop).
|
|
11
5
|
*/
|
|
12
6
|
export declare function useMessages(callback: (message: GroupedMessage) => void): void;
|
|
13
7
|
//# sourceMappingURL=useMessages.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMessages.d.ts","sourceRoot":"","sources":["../../src/hooks/useMessages.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAI3D
|
|
1
|
+
{"version":3,"file":"useMessages.d.ts","sourceRoot":"","sources":["../../src/hooks/useMessages.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAI3D;;;GAGG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,CAAC,OAAO,EAAE,cAAc,KAAK,IAAI,GAAG,IAAI,CAW7E"}
|