@cometchat/skills 3.0.0 → 4.0.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 (101) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +44 -17
  3. package/bin/install.js +389 -43
  4. package/package.json +19 -9
  5. package/skills/cometchat/SKILL.md +1066 -265
  6. package/skills/cometchat-android-v5/SKILL.md +120 -0
  7. package/skills/cometchat-android-v5-components/SKILL.md +430 -0
  8. package/skills/cometchat-android-v5-core/SKILL.md +468 -0
  9. package/skills/cometchat-android-v5-customization/SKILL.md +305 -0
  10. package/skills/cometchat-android-v5-extensions/SKILL.md +124 -0
  11. package/skills/cometchat-android-v5-features/SKILL.md +130 -0
  12. package/skills/cometchat-android-v5-placement/SKILL.md +276 -0
  13. package/skills/cometchat-android-v5-production/SKILL.md +94 -0
  14. package/skills/cometchat-android-v5-push/SKILL.md +620 -0
  15. package/skills/cometchat-android-v5-testing/SKILL.md +187 -0
  16. package/skills/cometchat-android-v5-theming/SKILL.md +166 -0
  17. package/skills/cometchat-android-v5-troubleshooting/SKILL.md +73 -0
  18. package/skills/cometchat-android-v6/SKILL.md +107 -0
  19. package/skills/cometchat-android-v6-builder-settings/SKILL.md +145 -0
  20. package/skills/cometchat-android-v6-compose-components/SKILL.md +202 -0
  21. package/skills/cometchat-android-v6-compose-customization/SKILL.md +280 -0
  22. package/skills/cometchat-android-v6-compose-placement/SKILL.md +213 -0
  23. package/skills/cometchat-android-v6-compose-theming/SKILL.md +224 -0
  24. package/skills/cometchat-android-v6-core/SKILL.md +354 -0
  25. package/skills/cometchat-android-v6-events/SKILL.md +212 -0
  26. package/skills/cometchat-android-v6-extensions/SKILL.md +191 -0
  27. package/skills/cometchat-android-v6-features/SKILL.md +130 -0
  28. package/skills/cometchat-android-v6-kotlin-components/SKILL.md +197 -0
  29. package/skills/cometchat-android-v6-kotlin-customization/SKILL.md +268 -0
  30. package/skills/cometchat-android-v6-kotlin-placement/SKILL.md +248 -0
  31. package/skills/cometchat-android-v6-kotlin-theming/SKILL.md +202 -0
  32. package/skills/cometchat-android-v6-production/SKILL.md +187 -0
  33. package/skills/cometchat-android-v6-push/SKILL.md +274 -0
  34. package/skills/cometchat-android-v6-testing/SKILL.md +279 -0
  35. package/skills/cometchat-android-v6-troubleshooting/SKILL.md +249 -0
  36. package/skills/cometchat-angular-components/SKILL.md +706 -0
  37. package/skills/cometchat-angular-core/SKILL.md +444 -0
  38. package/skills/cometchat-angular-customization/SKILL.md +424 -0
  39. package/skills/cometchat-angular-features/SKILL.md +447 -0
  40. package/skills/cometchat-angular-patterns/SKILL.md +447 -0
  41. package/skills/cometchat-angular-placement/SKILL.md +685 -0
  42. package/skills/cometchat-angular-production/SKILL.md +415 -0
  43. package/skills/cometchat-angular-theming/SKILL.md +365 -0
  44. package/skills/cometchat-angular-troubleshooting/SKILL.md +329 -0
  45. package/skills/cometchat-astro-patterns/SKILL.md +3 -3
  46. package/skills/cometchat-components/SKILL.md +11 -0
  47. package/skills/cometchat-core/SKILL.md +11 -6
  48. package/skills/cometchat-customization/references/component-catalog.md +1 -1
  49. package/skills/cometchat-features/SKILL.md +176 -108
  50. package/skills/cometchat-flutter-v5/SKILL.md +167 -0
  51. package/skills/cometchat-flutter-v5-calls/SKILL.md +192 -0
  52. package/skills/cometchat-flutter-v5-conversations/SKILL.md +117 -0
  53. package/skills/cometchat-flutter-v5-core/SKILL.md +221 -0
  54. package/skills/cometchat-flutter-v5-customization/SKILL.md +227 -0
  55. package/skills/cometchat-flutter-v5-events/SKILL.md +155 -0
  56. package/skills/cometchat-flutter-v5-messages/SKILL.md +258 -0
  57. package/skills/cometchat-flutter-v5-production/SKILL.md +207 -0
  58. package/skills/cometchat-flutter-v5-push/SKILL.md +284 -0
  59. package/skills/cometchat-flutter-v5-theming/SKILL.md +160 -0
  60. package/skills/cometchat-flutter-v5-troubleshooting/SKILL.md +129 -0
  61. package/skills/cometchat-flutter-v5-users-groups/SKILL.md +151 -0
  62. package/skills/cometchat-flutter-v6/SKILL.md +445 -0
  63. package/skills/cometchat-flutter-v6-calls/SKILL.md +333 -0
  64. package/skills/cometchat-flutter-v6-components/SKILL.md +365 -0
  65. package/skills/cometchat-flutter-v6-conversations/SKILL.md +210 -0
  66. package/skills/cometchat-flutter-v6-core/SKILL.md +305 -0
  67. package/skills/cometchat-flutter-v6-customization/SKILL.md +666 -0
  68. package/skills/cometchat-flutter-v6-events/SKILL.md +216 -0
  69. package/skills/cometchat-flutter-v6-features/SKILL.md +406 -0
  70. package/skills/cometchat-flutter-v6-messages/SKILL.md +333 -0
  71. package/skills/cometchat-flutter-v6-migration/SKILL.md +381 -0
  72. package/skills/cometchat-flutter-v6-placement/SKILL.md +398 -0
  73. package/skills/cometchat-flutter-v6-production/SKILL.md +632 -0
  74. package/skills/cometchat-flutter-v6-theming/SKILL.md +260 -0
  75. package/skills/cometchat-flutter-v6-troubleshooting/SKILL.md +726 -0
  76. package/skills/cometchat-flutter-v6-users-groups/SKILL.md +216 -0
  77. package/skills/cometchat-ios/SKILL.md +323 -0
  78. package/skills/cometchat-ios-components/SKILL.md +651 -0
  79. package/skills/cometchat-ios-core/SKILL.md +822 -0
  80. package/skills/cometchat-ios-customization/SKILL.md +825 -0
  81. package/skills/cometchat-ios-features/SKILL.md +725 -0
  82. package/skills/cometchat-ios-placement/SKILL.md +750 -0
  83. package/skills/cometchat-ios-production/SKILL.md +730 -0
  84. package/skills/cometchat-ios-push/SKILL.md +582 -0
  85. package/skills/cometchat-ios-theming/SKILL.md +631 -0
  86. package/skills/cometchat-ios-troubleshooting/SKILL.md +983 -0
  87. package/skills/cometchat-native-bare-patterns/SKILL.md +470 -0
  88. package/skills/cometchat-native-components/SKILL.md +594 -0
  89. package/skills/cometchat-native-core/SKILL.md +407 -0
  90. package/skills/cometchat-native-customization/SKILL.md +594 -0
  91. package/skills/cometchat-native-expo-patterns/SKILL.md +485 -0
  92. package/skills/cometchat-native-features/SKILL.md +608 -0
  93. package/skills/cometchat-native-placement/SKILL.md +500 -0
  94. package/skills/cometchat-native-production/SKILL.md +694 -0
  95. package/skills/cometchat-native-push/SKILL.md +593 -0
  96. package/skills/cometchat-native-testing/SKILL.md +583 -0
  97. package/skills/cometchat-native-theming/SKILL.md +656 -0
  98. package/skills/cometchat-native-troubleshooting/SKILL.md +433 -0
  99. package/skills/cometchat-nextjs-patterns/SKILL.md +5 -5
  100. package/skills/cometchat-production/SKILL.md +60 -0
  101. package/skills/cometchat-react-router-patterns/SKILL.md +23 -21
@@ -0,0 +1,594 @@
1
+ ---
2
+ name: cometchat-native-customization
3
+ description: "Customize the CometChat React Native UI Kit without forking — four-tier model: props → request builders → text formatters + message templates → DataSource decorators + event bus."
4
+ license: "MIT"
5
+ compatibility: "Node.js >=18; React Native >=0.70; @cometchat/chat-uikit-react-native ^5"
6
+ allowed-tools: "executeBash, readFile, fileSearch, listDirectory, AskUserQuestion"
7
+ metadata:
8
+ author: "CometChat"
9
+ version: "3.0.0"
10
+ tags: "cometchat react-native customization formatters events datasource templates"
11
+ ---
12
+
13
+ ## Purpose
14
+
15
+ Teaches Claude how to change the behavior or appearance of the React Native UI Kit **without modifying the kit itself**. Four tiers, from cheapest to deepest:
16
+
17
+ ```
18
+ Tier 1 — Props (95% of asks solved here)
19
+ Tier 2 — RequestBuilder (filter what data loads)
20
+ Tier 3 — Formatters + Templates (change how text / messages render)
21
+ Tier 4 — DataSource decorators + Events (last resort, powerful)
22
+ ```
23
+
24
+ **Always try Tier 1 first.** Escalate only when the tier can't do what the user wants.
25
+
26
+ **Read `cometchat-native-components` first** — the catalog is the source of truth for prop names, slot views, and event listener names that this skill builds on.
27
+
28
+ Ground truth: `docs/ui-kit/react-native/custom-text-formatter-guide.mdx`, `mentions-formatter-guide.mdx`, `shortcut-formatter-guide.mdx`, `url-formatter-guide.mdx`, `events.mdx`, `methods.mdx`, `property-changes.mdx`, and the kit's source at `packages/ChatUiKit/src/shared/formatters/` and `packages/ChatUiKit/src/shared/events/`.
29
+
30
+ ---
31
+
32
+ ## Four-tier triage — pick the right tier before writing any code
33
+
34
+ When a user says "I want X" for a CometChat component:
35
+
36
+ | If they want to... | Use Tier | Cost |
37
+ |---|---|---|
38
+ | Hide a feature (thread option, receipts, edit, etc.) | Tier 1 — `hide*` / `*Visibility` props | 1 line of JSX |
39
+ | Customize a subsection (header title, subtitle, avatar, empty state) | Tier 1 — `<Slot>View` prop | 1 component |
40
+ | Filter what loads (only show online users, exclude blocked, include tags) | Tier 2 — `*RequestBuilder` | 1 builder |
41
+ | Change how URLs / mentions / hashtags / emojis render inline | Tier 3 — `textFormatters` | Subclass of `CometChatTextFormatter` |
42
+ | Render a custom message type (custom bubble, custom interactive msg) | Tier 3 — `templates` + `CometChatMessageTemplate` | 1 template + 1 renderer |
43
+ | React to events from another component ("they deleted a message, now reload my view") | Tier 4 — `CometChatUIEventHandler` | Listener |
44
+ | Rewrite how data flows through the kit (custom conversation sorting, override user-fetch logic) | Tier 4 — `DataSourceDecorator` | Class extension |
45
+
46
+ If a user's ask fits Tier 1 but you jumped to Tier 3, you've written 50 lines that a 1-line prop could have replaced. Start low.
47
+
48
+ ---
49
+
50
+ ## Tier 1 — Props (hide / slot views / styles)
51
+
52
+ `cometchat-native-components` is the full catalog. Three prop families cover most customization:
53
+
54
+ ### 1a. `hide*` / `*Visibility` flags
55
+
56
+ Turn features off with a single prop:
57
+
58
+ ```tsx
59
+ <CometChatMessageList
60
+ user={selectedUser}
61
+ hideReplyInThreadOption // already mandatory — see components § 11
62
+ hideReceipts
63
+ hideReactions={false}
64
+ hideTranslateMessageOption
65
+ hideMessagePrivatelyOption
66
+ hideReplyOption={false}
67
+ />
68
+ ```
69
+
70
+ Full list of `hide*` props per component: `cometchat-native-components`. Check there before writing custom code.
71
+
72
+ ### 1b. `<Slot>View` props — replace a section
73
+
74
+ Every component has PascalCase slot props for replacing named sections of its default UI:
75
+
76
+ ```tsx
77
+ <CometChatMessageHeader
78
+ user={selectedUser}
79
+ TitleView={(user, group) => <Text style={styles.customTitle}>{user?.getName()}</Text>}
80
+ SubtitleView={(user, group) => <OnlineStatus user={user} />}
81
+ LeadingView={(user, group) => <CustomAvatar user={user} />}
82
+ TrailingView={(user, group) => <CustomActions user={user} />}
83
+ AuxiliaryButtonView={(user, group) => <CometChatCallButtons user={user} group={group} />}
84
+ />
85
+ ```
86
+
87
+ Slot functions receive the same data the default view would have (typically `user`, `group`, or a single entity). They return RN JSX.
88
+
89
+ **For custom views that should match the theme**, use `useTheme()`:
90
+
91
+ ```tsx
92
+ import { useTheme } from "@cometchat/chat-uikit-react-native";
93
+
94
+ function CustomTitle({ user }: any) {
95
+ const theme = useTheme();
96
+ return (
97
+ <Text style={{
98
+ color: theme.color.textPrimary,
99
+ fontFamily: theme.typography.heading3.fontFamily,
100
+ fontSize: theme.typography.heading3.fontSize,
101
+ }}>
102
+ {user?.getName()}
103
+ </Text>
104
+ );
105
+ }
106
+ ```
107
+
108
+ See `cometchat-native-theming` § 8 for more on `useTheme()`.
109
+
110
+ ### 1c. `style={{ ... }}` prop — nested styling
111
+
112
+ Each component accepts a nested-object `style` prop (see `cometchat-native-components` § 13):
113
+
114
+ ```tsx
115
+ <CometChatConversations
116
+ style={{
117
+ containerStyle: { backgroundColor: "#FAFAFA" },
118
+ itemStyle: {
119
+ avatarStyle: { containerStyle: { borderRadius: 8 } },
120
+ },
121
+ }}
122
+ />
123
+ ```
124
+
125
+ Prefer theme-level changes (via `cometchat-native-theming`) for app-wide color shifts; use `style={{}}` only for one-off overrides on a single component instance.
126
+
127
+ ---
128
+
129
+ ## Tier 2 — RequestBuilder filtering
130
+
131
+ For "I want to show a subset of X", use the matching `*RequestBuilder`. Never post-filter in-render.
132
+
133
+ ```tsx
134
+ import { CometChat } from "@cometchat/chat-sdk-react-native";
135
+
136
+ // Only conversations in a specific tag group
137
+ <CometChatConversations
138
+ conversationsRequestBuilder={
139
+ new CometChat.ConversationsRequestBuilder()
140
+ .setLimit(20)
141
+ .setUserTags(["premium"])
142
+ .setConversationType(CometChat.RECEIVER_TYPE.USER)
143
+ }
144
+ />
145
+
146
+ // Only online users, exclude blocked
147
+ <CometChatUsers
148
+ usersRequestBuilder={
149
+ new CometChat.UsersRequestBuilder()
150
+ .setLimit(30)
151
+ .setStatus("online")
152
+ .setSearchKeyword("")
153
+ .friendsOnly(false)
154
+ }
155
+ />
156
+
157
+ // Only groups you've joined
158
+ <CometChatGroups
159
+ groupsRequestBuilder={
160
+ new CometChat.GroupsRequestBuilder()
161
+ .setLimit(30)
162
+ .joinedOnly(true)
163
+ }
164
+ />
165
+
166
+ // Message list — exclude system messages
167
+ <CometChatMessageList
168
+ user={user}
169
+ messageRequestBuilder={
170
+ new CometChat.MessagesRequestBuilder()
171
+ .setUID(user.getUid())
172
+ .setLimit(30)
173
+ .setCategories(["message"]) // exclude "call", "action"
174
+ .hideReplies(false)
175
+ }
176
+ hideReplyInThreadOption
177
+ />
178
+ ```
179
+
180
+ Each request builder is chainable. The `@cometchat/chat-sdk-react-native` exports the builder classes — import them from the SDK, not the UI Kit.
181
+
182
+ ### Finding the right method
183
+
184
+ Request builder methods are documented at `cometchat.com/docs/sdk/react-native` (or query the docs MCP). Common ones:
185
+
186
+ | Builder | Useful methods |
187
+ |---|---|
188
+ | `ConversationsRequestBuilder` | `.setLimit(n)`, `.setUserTags([...])`, `.setGroupTags([...])`, `.setConversationType(type)`, `.withTags(true)`, `.withUserAndGroupTags(true)` |
189
+ | `UsersRequestBuilder` | `.setLimit(n)`, `.setStatus("online")`, `.setSearchKeyword(str)`, `.friendsOnly(bool)`, `.setTags([...])`, `.setUIDs([...])`, `.hideBlockedUsers(bool)` |
190
+ | `GroupsRequestBuilder` | `.setLimit(n)`, `.setSearchKeyword(str)`, `.joinedOnly(bool)`, `.setTags([...])`, `.setGroupTypes([...])` |
191
+ | `MessagesRequestBuilder` | `.setUID(uid)` / `.setGUID(guid)`, `.setLimit(n)`, `.setCategories([...])`, `.setTypes([...])`, `.hideReplies(bool)`, `.setTags([...])`, `.setParentMessageId(id)` |
192
+ | `GroupMembersRequestBuilder` | `.setLimit(n)`, `.setSearchKeyword(str)`, `.setScopes([...])` |
193
+
194
+ ---
195
+
196
+ ## Tier 3 — Text formatters + message templates
197
+
198
+ For "change how text or messages render", Tier 3 is the right level. Two sub-patterns:
199
+
200
+ ### 3a. Custom text formatter — inline text patterns
201
+
202
+ `CometChatTextFormatter` is an abstract base class for matching inline text patterns (hashtags, keywords, emoji shortcodes, custom tags) and replacing them with custom JSX.
203
+
204
+ ```tsx
205
+ import {
206
+ CometChatTextFormatter,
207
+ SuggestionItem,
208
+ } from "@cometchat/chat-uikit-react-native";
209
+ import { CometChat } from "@cometchat/chat-sdk-react-native";
210
+ import { Text, View, StyleSheet } from "react-native";
211
+
212
+ class HashtagFormatter extends CometChatTextFormatter {
213
+ constructor() {
214
+ super();
215
+ this.setTrackingCharacter("#"); // optional — triggers suggestion list
216
+ this.setRegexPatterns([/\B#(\w+)\b/g]); // all matches get formatted
217
+ }
218
+
219
+ // Called for each bubble's text; return string | JSX
220
+ getFormattedText(
221
+ inputText: string | null | React.ReactNode,
222
+ ): string | React.ReactNode {
223
+ if (typeof inputText !== "string") return inputText;
224
+ const parts = inputText.split(/(\B#\w+\b)/g);
225
+ return (
226
+ <Text>
227
+ {parts.map((part, i) =>
228
+ part.match(/^#\w+$/)
229
+ ? <Text key={i} style={styles.hashtag} onPress={() => openHashtag(part)}>{part}</Text>
230
+ : <Text key={i}>{part}</Text>,
231
+ )}
232
+ </Text>
233
+ );
234
+ }
235
+
236
+ // Optional — called before a message is sent. Transform the outgoing message.
237
+ handlePreMessageSend(message: CometChat.TextMessage): CometChat.TextMessage {
238
+ // e.g. attach the list of hashtags to the message metadata
239
+ return message;
240
+ }
241
+
242
+ // Optional — for suggestion-list support (triggered by `#`)
243
+ search(searchKey: string): void {
244
+ // Fetch matching hashtags from your backend, then:
245
+ // this.setSearchData([{ id: "tag1", title: "#typescript" }]);
246
+ }
247
+ }
248
+
249
+ const styles = StyleSheet.create({
250
+ hashtag: { color: "#2563EB", fontWeight: "600" },
251
+ });
252
+ ```
253
+
254
+ Register the formatter by passing it to both `CometChatMessageList` and `CometChatMessageComposer`:
255
+
256
+ ```tsx
257
+ const formatters = [
258
+ new CometChatMentionsFormatter(), // keep the built-in ones
259
+ new CometChatUrlsFormatter(),
260
+ new HashtagFormatter(), // add yours
261
+ ];
262
+
263
+ <CometChatMessageList
264
+ user={selectedUser}
265
+ textFormatters={formatters}
266
+ hideReplyInThreadOption
267
+ />
268
+ <CometChatMessageComposer
269
+ user={selectedUser}
270
+ textFormatters={formatters}
271
+ />
272
+ ```
273
+
274
+ ### 3b. Custom message template — entire custom bubble
275
+
276
+ For rendering a totally custom message type (interactive cards, scheduling, forms), use `CometChatMessageTemplate`.
277
+
278
+ ```tsx
279
+ import {
280
+ CometChatMessageTemplate,
281
+ CometChatUiKitConstants,
282
+ } from "@cometchat/chat-uikit-react-native";
283
+
284
+ const pollTemplate = new CometChatMessageTemplate({
285
+ type: "poll",
286
+ category: CometChatUiKitConstants.MessageCategoryConstants.custom,
287
+ ContentView: (message, alignment) => (
288
+ <PollBubble message={message} alignment={alignment} />
289
+ ),
290
+ BottomView: (message, alignment) => (
291
+ <PollVoteCounts message={message} />
292
+ ),
293
+ options: (loggedInUser, message, group) => [
294
+ /* CometChatMessageOption[] — custom long-press menu items */
295
+ ],
296
+ });
297
+
298
+ <CometChatMessageList
299
+ user={selectedUser}
300
+ templates={[pollTemplate, ...defaultTemplates]} // merge with defaults
301
+ hideReplyInThreadOption
302
+ />
303
+ ```
304
+
305
+ Getting the default templates to merge with:
306
+
307
+ ```tsx
308
+ import { ChatConfigurator } from "@cometchat/chat-uikit-react-native";
309
+ const defaults = ChatConfigurator.getDataSource().getAllMessageTemplates();
310
+ <CometChatMessageList templates={[pollTemplate, ...defaults]} />
311
+ ```
312
+
313
+ ### When to use text formatter vs message template
314
+
315
+ | Use formatter (Tier 3a) | Use template (Tier 3b) |
316
+ |---|---|
317
+ | Change how TEXT inside a bubble renders (hashtags, URLs, mentions, emoji shortcodes) | Render a completely different bubble body |
318
+ | Content is still a `TextMessage` | Content is a custom message type (sent via `CometChat.sendCustomMessage`) |
319
+ | Doesn't need its own long-press options | Needs custom message options (vote, claim, accept, etc.) |
320
+
321
+ ---
322
+
323
+ ## Tier 4 — DataSource decorators + event bus
324
+
325
+ When Tiers 1-3 can't do it, you're modifying how data flows through the UI Kit. Two mechanisms:
326
+
327
+ ### 4a. Event bus — `CometChatUIEventHandler`
328
+
329
+ Subscribe to events that UI Kit components emit so your own code can react.
330
+
331
+ ```tsx
332
+ import { CometChatUIEventHandler } from "@cometchat/chat-uikit-react-native";
333
+ import { useEffect } from "react";
334
+
335
+ function AppScreen() {
336
+ useEffect(() => {
337
+ const listenerId = "APP_MESSAGE_LISTENER";
338
+
339
+ CometChatUIEventHandler.addMessageListener(listenerId, {
340
+ ccMessageSent: ({ message, status }) => {
341
+ // status === "inProgress" | "sent"
342
+ analytics.track("message_sent", { id: message.getId() });
343
+ },
344
+ ccMessageEdited: ({ message }) => { /* ... */ },
345
+ ccMessageDeleted: ({ message }) => { /* ... */ },
346
+ ccMessageRead: ({ message }) => { /* ... */ },
347
+ ccLiveReaction: ({ reaction }) => { /* ... */ },
348
+ });
349
+
350
+ return () => CometChatUIEventHandler.removeMessageListener(listenerId);
351
+ }, []);
352
+
353
+ return /* ... */;
354
+ }
355
+ ```
356
+
357
+ ### Event listener API reference
358
+
359
+ | Listener | Use when... |
360
+ |---|---|
361
+ | `addMessageListener` | reacting to any message-related event (sent, edited, deleted, read, reactions) |
362
+ | `addConversationListener` | reacting to conversation-level events (`ccConversationDeleted`, `ccUpdateConversation`) |
363
+ | `addUserListener` | reacting to user actions (`ccUserBlocked`, `ccUserUnblocked`) |
364
+ | `addGroupListener` | reacting to group lifecycle (`ccGroupCreated`, `ccGroupDeleted`, `ccGroupLeft`, `ccGroupMemberScopeChanged`, `ccGroupMemberKicked`, `ccGroupMemberBanned`, `ccGroupMemberJoined`, `ccGroupMemberAdded`, `ccOwnershipChanged`, etc.) |
365
+ | `addCallListener` | reacting to call events (`onIncomingCallAccepted`, `onCallEnded`, `onCallInitiated`, etc.) |
366
+
367
+ Every pair has a matching `remove*Listener(id)` — **always call it in the cleanup of your `useEffect`** to avoid duplicate listeners on re-render.
368
+
369
+ **Listener ID uniqueness matters.** Use a constant per component/feature. Colliding IDs cause only the latest-registered listener to fire.
370
+
371
+ ### 4b. DataSource decorators
372
+
373
+ `DataSourceDecorator` and `MessageDataSource` wrap the kit's internal data source to override specific methods without forking the whole kit.
374
+
375
+ When to reach for this: overriding how user data is fetched, how conversations are sorted, adding custom message metadata to every sent message, intercepting attachment uploads.
376
+
377
+ Minimum pattern:
378
+
379
+ ```tsx
380
+ import {
381
+ DataSource,
382
+ DataSourceDecorator,
383
+ ChatConfigurator,
384
+ } from "@cometchat/chat-uikit-react-native";
385
+
386
+ class MyDataSource extends DataSourceDecorator {
387
+ constructor(source: DataSource) {
388
+ super(source);
389
+ }
390
+
391
+ // Override only the method you want to change
392
+ getConversationsRequestBuilder() {
393
+ const builder = super.getConversationsRequestBuilder();
394
+ builder.setUserAndGroupTags(true);
395
+ return builder;
396
+ }
397
+
398
+ getMessageTemplate() {
399
+ const defaults = super.getMessageTemplate();
400
+ return [myCustomTemplate, ...defaults];
401
+ }
402
+ }
403
+
404
+ // Register the decorator before init — wraps the default data source
405
+ ChatConfigurator.dataSource = new MyDataSource(ChatConfigurator.getDataSource());
406
+ await CometChatUIKit.init(settings);
407
+ ```
408
+
409
+ **This is an escape hatch, not a first tool.** If you find yourself reaching for Tier 4, re-check whether Tier 1 (props) or Tier 3 (templates) could have solved it. Templates + slot views cover most "custom behavior" asks.
410
+
411
+ ### 4c. Extensions datasource (for extension-like deep behavior)
412
+
413
+ `ExtensionsDataSource` is the base class for registering an extension-shaped chunk of behavior (its own composer action + its own bubble + its own data handling) — this is what `PollsExtension`, `StickersExtension`, etc. extend internally. You'd only subclass this if you're shipping a reusable feature module across apps.
414
+
415
+ For a single app, use `DataSourceDecorator` instead.
416
+
417
+ ---
418
+
419
+ ## 5. Sample app reference (when Tiers 1–4 don't have what you need)
420
+
421
+ If none of Tiers 1–4 covered the user's request, **don't immediately conclude they need custom code**. The RN UI Kit ships two reference sample apps that compose multiple kit components into common chat UX patterns that aren't shipped as named exports:
422
+
423
+ > Bare RN: https://github.com/cometchat/cometchat-uikit-react-native/tree/v5/examples/SampleApp
424
+ >
425
+ > Expo: https://github.com/cometchat/cometchat-uikit-react-native/tree/v5/examples/SampleAppExpo
426
+
427
+ (Use the branch matching your installed UI-Kit major version — confirm via `package.json`. If the user is on v5, use `v5`; for v6 use `v6`. The folder layout is identical between the two flavors — `src/components`, `src/screens`, `src/utils` — so the same lookup table works for both.)
428
+
429
+ Examples that look like "missing components" but are in the sample app:
430
+
431
+ | User asks for | Sample app reference path |
432
+ |---|---|
433
+ | User / group details screen | `examples/SampleApp(Expo)/src/components/CometChatDetails/` (`CometChatUserDetails.tsx` + group-details inline in the home screen) |
434
+ | Threaded messages screen layout | `examples/SampleApp(Expo)/src/components/CometChatDetails/CometChatThreadedMessages.tsx` |
435
+ | Top-level chat shell (tabs + screens + drawer) | `examples/SampleApp(Expo)/src/components/CometChatHome/` + `App.tsx` |
436
+ | Multi-tab chat (Chats / Calls / Users / Groups) | `examples/SampleApp(Expo)/src/components/CometChatTabs/` |
437
+ | New conversation modal with user/group picker | `examples/SampleApp(Expo)/src/components/CometChatNewChat/` |
438
+ | Search screen (conversations + messages) | `examples/SampleApp(Expo)/src/components/CometChatSearch/` |
439
+ | Call log details / history / recordings | `examples/SampleApp(Expo)/src/components/CometChatCallLog/` |
440
+ | App-state / active-chat React context | `examples/SampleApp(Expo)/src/context/AppContext.tsx` |
441
+
442
+ **Discovery commands (works against either repo flavor):**
443
+
444
+ ```bash
445
+ # List the sample app's components directory via the GitHub API (bare RN)
446
+ curl -s "https://api.github.com/repos/cometchat/cometchat-uikit-react-native/contents/examples/SampleApp/src/components?ref=v5" \
447
+ | grep -oE '"name":\s*"[^"]+"' | head -30
448
+
449
+ # Same, for Expo
450
+ curl -s "https://api.github.com/repos/cometchat/cometchat-uikit-react-native/contents/examples/SampleAppExpo/src/components?ref=v5" \
451
+ | grep -oE '"name":\s*"[^"]+"' | head -30
452
+
453
+ # Fetch a specific component file directly
454
+ curl -s "https://raw.githubusercontent.com/cometchat/cometchat-uikit-react-native/v5/examples/SampleApp/src/components/CometChatDetails/CometChatUserDetails.tsx"
455
+ ```
456
+
457
+ You can also use `WebFetch` on the URLs above. The docs MCP does NOT index the sample apps — fetch them from GitHub directly.
458
+
459
+ **If you find a matching reference implementation:**
460
+
461
+ 1. Read the `.tsx` file. Note: RN sample-app components use `StyleSheet.create({...})` blocks colocated in the same file (no separate stylesheet file like the web sample app — RN doesn't have CSS).
462
+ 2. Mirror the sample's file/folder structure in the user's project, e.g. `src/cometchat/CometChatDetails/CometChatUserDetails.tsx`. Don't rename, don't simplify the structure — match it exactly so future patches against the sample apply cleanly.
463
+ 3. Adapt navigation: SampleApp uses React Navigation; if the user is on Expo Router, swap `navigation.navigate(...)` → `router.push(...)` and `useRoute()` → `useLocalSearchParams()`. Everything else carries over.
464
+ 4. The kit's `useTheme()` hook works identically inside copied sample components — keep the calls intact rather than hardcoding colors.
465
+
466
+ ---
467
+
468
+ ## 6. Recipes (common customization asks → right tier)
469
+
470
+ ### "Filter the conversation list to just premium users"
471
+ **Tier 2** — `conversationsRequestBuilder` with `.setUserTags(["premium"])`.
472
+
473
+ ### "Custom empty state for the users list"
474
+ **Tier 1** — `EmptyStateView` slot prop on `CometChatUsers`.
475
+
476
+ ### "Custom message bubble for incoming messages only"
477
+ **Tier 3b** — `CometChatMessageTemplate` with a `ContentView` that branches on `alignment === "receive"`. Or simpler — **Tier 1** `messageListStyles.receiveBubbleStyle` in the theme (see `cometchat-native-theming` § 6).
478
+
479
+ ### "Show a custom view when the user types @"
480
+ **Tier 3a** — subclass `CometChatMentionsFormatter` (or extend `CometChatTextFormatter`), implement `search(key)` + `setSearchData([...])` with your own suggestion source.
481
+
482
+ ### "When a message is sent, log it to our analytics"
483
+ **Tier 4a** — `CometChatUIEventHandler.addMessageListener` with `ccMessageSent` handler.
484
+
485
+ ### "When a group is deleted, remove it from my local cache + navigate away"
486
+ **Tier 4a** — `addGroupListener` with `ccGroupDeleted` handler.
487
+
488
+ ### "Render custom avatars for all users based on their department"
489
+ **Tier 1** — `LeadingView` slot on `CometChatConversations` + `CometChatUsers` + `CometChatMessageHeader`.
490
+
491
+ ### "Disable the file attachment option"
492
+ **Tier 1** — filter the `attachmentOptions` prop on `CometChatMessageComposer`:
493
+
494
+ ```tsx
495
+ <CometChatMessageComposer
496
+ user={user}
497
+ attachmentOptions={(user, group) => {
498
+ const defaults = /* default actions from ChatConfigurator */;
499
+ return defaults.filter((opt) => opt.id !== "attachment-file");
500
+ }}
501
+ />
502
+ ```
503
+
504
+ ### "Show only message types that contain the word 'urgent'"
505
+ **Tier 2** — `messageRequestBuilder` with `.setSearchKeyword("urgent")`.
506
+
507
+ ### "Custom message type: a 'ping' message"
508
+ **Tier 3b** — create a `CometChatMessageTemplate` with `category: "custom"` + `type: "ping"`, render a custom `ContentView`, send via `CometChat.sendCustomMessage`.
509
+
510
+ ### "Completely replace the kit's conversation-loading logic"
511
+ **Tier 4b** — `DataSourceDecorator` overriding `getConversationsRequestBuilder()` + possibly wrapping the fetch itself. Rare. Try Tier 2 first.
512
+
513
+ ---
514
+
515
+ ## 6. Anti-patterns
516
+
517
+ 1. **Don't hand-roll a bubble when a template will do.** `CometChatMessageTemplate` (Tier 3b) gives you full control over rendering + options without losing theming, reactions, typing, receipts.
518
+
519
+ 2. **Don't post-filter a list's data after render.** If you want "only online users," use Tier 2 `usersRequestBuilder.setStatus("online")` — don't fetch everyone then hide rows.
520
+
521
+ 3. **Don't forget to remove listeners in `useEffect` cleanup.** RN re-renders on every navigation can register duplicate listeners; each fires your handler once per registration.
522
+
523
+ 4. **Don't collide listener IDs.** Use `APP_MESSAGE_LISTENER` or `${componentName}_MESSAGE_LISTENER` — constant, unique. Colliding IDs silently drop earlier registrations.
524
+
525
+ 5. **Don't put `CometChatTextFormatter` instances in component state.** Construct them once at module scope (or in a `useMemo`); re-creating them on every render loses the internal suggestion state.
526
+
527
+ 6. **Don't fork or patch `@cometchat/chat-uikit-react-native` directly.** Every customization should be possible via Tiers 1-4. Forking breaks on kit upgrades.
528
+
529
+ 7. **Don't reach for Tier 4 before trying 1-3.** DataSource decorators are powerful but fragile to kit internal changes. Props, request builders, and templates are stable surface area.
530
+
531
+ 8. **Don't change component behavior via monkey-patching (e.g., `Component.defaultProps = ...`).** Use the actual prop API. Monkey-patching is broken by design in React 19+.
532
+
533
+ ---
534
+
535
+ ## 7. Wiring a custom formatter end-to-end (full working example)
536
+
537
+ Say the user wants `:emoji:` shortcodes (e.g., `:smile:` → 😀):
538
+
539
+ ```tsx
540
+ // 1. Define the formatter — module scope, constructed once
541
+ import { CometChatTextFormatter } from "@cometchat/chat-uikit-react-native";
542
+ import { Text } from "react-native";
543
+
544
+ const EMOJI_MAP: Record<string, string> = {
545
+ ":smile:": "😀", ":heart:": "❤️", ":thumbsup:": "👍", ":fire:": "🔥",
546
+ };
547
+
548
+ class EmojiShortcodeFormatter extends CometChatTextFormatter {
549
+ constructor() {
550
+ super();
551
+ this.setRegexPatterns([/:[a-z_]+:/g]);
552
+ }
553
+
554
+ getFormattedText(input: string | null | React.ReactNode) {
555
+ if (typeof input !== "string") return input;
556
+ const parts = input.split(/(:[a-z_]+:)/g);
557
+ return (
558
+ <Text>
559
+ {parts.map((p, i) =>
560
+ EMOJI_MAP[p] ? <Text key={i}>{EMOJI_MAP[p]}</Text> : <Text key={i}>{p}</Text>,
561
+ )}
562
+ </Text>
563
+ );
564
+ }
565
+ }
566
+
567
+ // 2. Build the formatters array at module scope
568
+ import { CometChatMentionsFormatter, CometChatUrlsFormatter } from "@cometchat/chat-uikit-react-native";
569
+ export const TEXT_FORMATTERS = [
570
+ new CometChatMentionsFormatter(),
571
+ new CometChatUrlsFormatter(),
572
+ new EmojiShortcodeFormatter(),
573
+ ];
574
+
575
+ // 3. Wire into list + composer (same array — must match)
576
+ import { TEXT_FORMATTERS } from "./formatters";
577
+ <CometChatMessageList user={user} textFormatters={TEXT_FORMATTERS} hideReplyInThreadOption />
578
+ <CometChatMessageComposer user={user} textFormatters={TEXT_FORMATTERS} />
579
+ ```
580
+
581
+ ---
582
+
583
+ ## Skill routing reference
584
+
585
+ | Skill | When to route |
586
+ |---|---|
587
+ | `cometchat-native-core` | Init / login / provider chain |
588
+ | `cometchat-native-components` | Prop reference — which `hide*`, `<Slot>View`, `*RequestBuilder` is available (prerequisite for Tiers 1–2) |
589
+ | `cometchat-native-placement` | Where to put the customized components |
590
+ | `cometchat-native-theming` | App-wide color / typography / dark mode — Tier 1 alternative to `style={{}}` |
591
+ | `cometchat-native-features` | Which out-of-the-box features exist (so you know what needs customizing vs. what's already there) |
592
+ | `cometchat-native-customization` | This skill — four-tier triage + custom formatters / templates / DataSource / events |
593
+ | `cometchat-native-production` | When customization depends on production auth (token refresh, user-ID mapping) |
594
+ | `cometchat-native-troubleshooting` | Formatter doesn't apply, listener fires twice, slot view renders nothing, template not showing |