whatsapp-ui-react 0.0.3 → 0.0.4

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
@@ -1,6 +1,16 @@
1
1
  # whatsapp-ui-react
2
2
 
3
- React component library with a WhatsApp‑Web–inspired UI. Some components are still placeholders and may not be fully functional yet.
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
 
@@ -10,69 +20,74 @@ npm install whatsapp-ui-react
10
20
 
11
21
  **Peer dependencies:** React 18+ and TailwindCSS v4.
12
22
 
13
- ## Setup
14
-
15
- Import the component styles into your CSS entry point:
16
-
17
- ```css
18
- @import 'tailwindcss';
19
- @import 'whatsapp-ui-react/styles';
20
- ```
21
-
22
23
  ## Usage
23
24
 
24
25
  ### Chat
25
26
 
27
+ <!--prettier-ignore-->
26
28
  ```tsx
27
- import { Chat } from 'whatsapp-ui-react'
28
- ;<Chat name="Alice" subtitle="online" />
29
+ import { Chat } from 'whatsapp-ui-react';
30
+ <Chat name="Alice" subtitle="online" />
29
31
  ```
30
32
 
31
33
  ### Messages
32
34
 
35
+ <!--prettier-ignore-->
33
36
  ```tsx
34
- import { Chat, Message, Text } from 'whatsapp-ui-react'
35
- import type { GroupedMessage } from 'whatsapp-ui-react'
36
-
37
- const history: GroupedMessage[] = [
38
- {
39
- id: '1',
40
- senderId: 'alice',
41
- timestamp: new Date(),
42
- node: (
43
- <Message direction="in" mode="neutral" time="09:41">
44
- <Text content="Hey! 👋" />
45
- </Message>
46
- ),
47
- },
48
- ]
37
+ import { Chat, History, Message, Text } from 'whatsapp-ui-react';
38
+
39
+ <Chat name="Alice">
40
+ <History>
41
+ <Message direction="in" senderId="alice" timestamp="2026-03-03T09:41:00Z" mode="neutral" time="09:41">
42
+ <Text content="Hey! 👋" />
43
+ </Message>
44
+ <Message direction="out" senderId="me" timestamp="2026-03-03T09:42:00Z" mode="neutral" time="09:42" status="read">
45
+ <Text content="Hi! How are you?" />
46
+ </Message>
47
+ </History>
48
+ </Chat>
49
+ ```
50
+
51
+ ### Animated messages
49
52
 
50
- <Chat name="Alice" messageHistory={history} />
53
+ <!--prettier-ignore-->
54
+ ```tsx
55
+ import { Chat, History, Message, Text, Animated } from 'whatsapp-ui-react';
56
+
57
+ <Chat name="Support Bot">
58
+ <History>
59
+ <Animated delay={1500}>
60
+ <Message direction="in" senderId="bot" timestamp="2026-03-03T09:00:00Z" mode="neutral" time="09:00">
61
+ <Text content="Hello! How can I help you?" />
62
+ </Message>
63
+ </Animated>
64
+ </History>
65
+ </Chat>
51
66
  ```
52
67
 
53
68
  ### Content types
54
69
 
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 |
70
+ | Component | Description | Implemented |
71
+ | ------------ | ----------------------------- | ----------- |
72
+ | `<Text>` | Plain text | ✅ |
73
+ | `<Image>` | Image with optional caption | |
74
+ | `<Video>` | Video with thumbnail | |
75
+ | `<Audio>` | Audio file attachment | ✅ |
76
+ | `<Voice>` | Voice message with waveform | ✅ |
77
+ | `<Sticker>` | Sticker (frameless image) | ✅ |
78
+ | `<Gif>` | Animated GIF | |
79
+ | `<File>` | Generic file attachment | |
80
+ | `<Contact>` | Contact card | |
81
+ | `<Location>` | Location pin with map preview | |
82
+ | `<Poll>` | Poll with options | |
83
+ | `<Emoji>` | Large emoji message | |
84
+ | `<Event>` | Event card | |
70
85
 
71
86
  ### Reply rules
72
87
 
73
88
  Automated replies that fire when an incoming message matches a trigger:
74
89
 
75
- <!-- prettier-ignore -->
90
+ <!--prettier-ignore-->
76
91
  ```tsx
77
92
  import { Chat, Message, Text, Reply } from 'whatsapp-ui-react';
78
93
 
@@ -108,27 +123,59 @@ Set `locked` to disable sending while still allowing typing:
108
123
  <Chat name="Read-only" locked />
109
124
  ```
110
125
 
126
+ ## `<History>` props
127
+
128
+ | Prop | Type | Default | Description |
129
+ | ----------- | ----------- | ------- | ------------------------------------------------------------------------------------------------ |
130
+ | `children` | `ReactNode` | | `<Message>` elements, optionally wrapped in `<Animated>`. Anything else is passed through as-is. |
131
+ | `className` | `string` | | Additional CSS class names applied to the wrapper element |
132
+
133
+ ## `<Animated>` props
134
+
135
+ | Prop | Type | Default | Description |
136
+ | ----------- | ----------- | ------- | --------------------------------------------------------- |
137
+ | `delay` | `number` | `0` | Milliseconds from mount until the content fades in |
138
+ | `children` | `ReactNode` | | Content to reveal |
139
+ | `className` | `string` | | Additional CSS class names applied to the wrapper element |
140
+
141
+ ## `<Message>` props
142
+
143
+ | Prop | Type | Default | Description |
144
+ | ------------ | ---------------------------------------------- | ---------- | ---------------------------------------------------------------------------------------------------- |
145
+ | `direction` | `'in' \| 'out'` | | Received (`'in'`) or sent (`'out'`) message |
146
+ | `mode` | `'neutral' \| 'free' \| 'custom'` | `'custom'` | Layout mode: `'neutral'` overlays the timestamp; `'free'` floats it below; `'custom'` is unwrapped |
147
+ | `top` | `boolean` | `false` | First message in a consecutive run - renders the bubble tail. Injected automatically by `<History>`. |
148
+ | `group` | `boolean` | `false` | Group chat mode - shows sender avatar when `top` is `true` |
149
+ | `avatarUrl` | `string` | | Sender avatar URL (group chats) |
150
+ | `senderName` | `string` | | Sender display name (group chats) |
151
+ | `time` | `string` | | Formatted time string shown in the bubble footer |
152
+ | `status` | `'sending' \| 'sent' \| 'delivered' \| 'read'` | | Delivery status icon (outgoing messages only) |
153
+ | `senderId` | `string` | | Identifies the sender; used by `<History>` for grouping. No visual effect. |
154
+ | `timestamp` | `string \| Date` | | ISO string or `Date` for the message time; used by `<History>` for day dividers. No visual effect. |
155
+ | `className` | `string` | | Additional CSS class names applied to the root element |
156
+
111
157
  ## `<Chat>` props
112
158
 
113
- | Prop | Type | Default | Description |
114
- | -------------------- | --------------------- | -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
115
- | `name` | `string` | | Contact or group name |
116
- | `avatarUrl` | `string` | | Avatar image URL |
117
- | `subtitle` | `string` | | Status text below the name |
118
- | `messageHistory` | `GroupedMessage[]` | `[]` | Initial message list |
119
- | `showInputfield` | `boolean` | `true` | Show / hide the input bar |
120
- | `locked` | `boolean` | `false` | Allow typing but disable sending |
121
- | `inputPlaceholder` | `string` | `'Enter a message.'` | Textarea placeholder |
122
- | `inputValue` | `string` | | Controlled input value |
123
- | `defaultInputValue` | `string` | | Uncontrolled initial value |
124
- | `onInputValueChange` | `(v: string) => void` | | Called on every keystroke |
125
- | `onSendMessage` | `(v: string) => void` | | Called when a message is sent |
126
- | `onReply` | `ReactNode` | | `<Reply>` rules rendered inside the chat context |
127
- | `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. |
128
- | `onEmojiClick` | `() => void` | | Emoji button click handler |
129
- | `onAttachClick` | `() => void` | | Attach button click handler |
130
- | `onMicClick` | `() => void` | | Mic button click handler |
159
+ | Prop | Type | Default | Description |
160
+ | -------------------- | --------------------------------- | -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
161
+ | `name` | `string` | | Contact or group name |
162
+ | `avatarUrl` | `'online' \| 'typeing' \| string` | | Avatar image URL |
163
+ | `subtitle` | `string` | | Status text below the name |
164
+ | `children` | `ReactNode` | | Static content rendered at the top of the message area. Typically a `<History>` component. |
165
+ | `showInputfield` | `boolean` | `true` | Show / hide the input bar |
166
+ | `locked` | `boolean` | `false` | Allow typing but disable sending |
167
+ | `inputPlaceholder` | `string` | `'Enter a message.'` | Textarea placeholder |
168
+ | `inputValue` | `string` | | Controlled input value (use with `onInputValueChange`) |
169
+ | `defaultInputValue` | `string` | | Uncontrolled initial value (internal state managed by component) |
170
+ | `onInputValueChange` | `(v: string) => void` | | Called on every keystroke |
171
+ | `onSendMessage` | `(v: string) => void` | | Called when a message is sent |
172
+ | `onReply` | `ReactNode` | | `<Reply>` rules rendered inside the chat context |
173
+ | `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. |
174
+ | `onEmojiClick` | `() => void` | | Emoji button click handler |
175
+ | `onAttachClick` | `() => void` | | Attach button click handler |
176
+ | `onCameraClick` | `() => void` | | Camera button click handler |
177
+ | `onMicClick` | `() => void` | | Mic button click handler |
131
178
 
132
179
  ## License
133
180
 
134
- Apache-2.0 © [2hoch1](https://github.com/2hoch1)
181
+ 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,3 @@
1
+ export type * from './Animated';
2
+ export { Animated } from './Animated';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -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
- /** Rendered in the message area when no messages exist yet and `messageHistory` is empty. */
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
- /** Initial message list. Copied into internal state on mount; subsequent external changes are ignored. */
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;
@@ -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;IACjB,6FAA6F;IAC7F,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC1B,8DAA8D;IAC9D,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,0GAA0G;IAC1G,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,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AoD;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,CA4BhG;AAED,OAAO,EAAE,UAAU,EAAE,CAAA;AACrB,YAAY,EAAE,eAAe,EAAE,CAAA"}
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,3 @@
1
+ export type * from './History';
2
+ export { History } from './History';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -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 renders the bubble tail. @defaultValue `false` */
7
+ /** First message in a consecutive run - renders the bubble tail. @defaultValue `false` */
8
8
  top?: boolean;
9
- /** Part of a group chat renders the sender avatar when `top` is `true`. @defaultValue `false` */
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 typically one of the content components (`<Text>`, `<Image>`, etc.). */
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'` standard bubble with overlaid timestamp
22
- * - `'free'` content fills the bubble, timestamp floats below
23
- * - `'custom'` children render directly with no wrapper
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;CACvB;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"}
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;;;GAGG;AACH,iBAAS,UAAU,IAAI,mBAAmB,CAEzC;AAED,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,CAAA"}
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 array of `BAR_COUNT` values in the range `0`–`10`. */
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;AAW/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,CA8D9F;AAED,OAAO,EAAE,QAAQ,EAAE,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
- * Event-listener hook — calls `callback` for every new message that arrives
4
- * in the nearest <Chat>.
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;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,CAAC,OAAO,EAAE,cAAc,KAAK,IAAI,GAAG,IAAI,CAW7E"}
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"}