@pmate/chat-sdk 0.2.3 → 0.3.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.
package/README.md CHANGED
@@ -3,3 +3,32 @@
3
3
  Shared chat UI primitives, hooks, and state helpers used by PMate chat surfaces.
4
4
 
5
5
  This package contains the reusable chat input, attachment, emoji, and voice-related building blocks that PMate apps compose into product-specific chat experiences.
6
+
7
+ ## Group mentions
8
+
9
+ ### Background
10
+
11
+ A host already knows its group membership. The SDK provides the same @ picker for
12
+ built-in composers and custom textarea UIs without fetching business data.
13
+
14
+ Pass `mentions={{ candidates: [{ id: profileId, name: displayName, avatar }] }}` to
15
+ `ChatInputDesktop` or `ChatInputMobile`. Omit it in direct messages. Typing @ after
16
+ whitespace or punctuation opens the member list; arrows navigate, Enter selects,
17
+ Escape dismisses, and IME composition remains native. The next Enter sends.
18
+
19
+ `onSend` includes `mentions?: ChatMention[]` with stable IDs and UTF-16 `[start, end)`
20
+ ranges into the **untrimmed** `text`. Editing an inserted name removes its mention
21
+ identity. Duplicate names retain distinct IDs. Pass mentions to `sendGroup` along
22
+ with the ordinary group recipients; mention IDs must never replace recipients.
23
+ This is selection metadata, not a push-notification or permission mechanism.
24
+
25
+ For a custom textarea, call `useMentions({ value, onChange, config, disabled })`,
26
+ spread its `inputProps`, render `<MentionMenu {...picker.menuProps} tokens={tokens} />`
27
+ inside a relatively positioned wrapper, and send `picker.getMentions()` with value.
28
+ If overriding `onKeyDown`, call `picker.inputProps.onKeyDown(event)` first and return
29
+ when `event.defaultPrevented`. Hosts supply only valid current group candidates and
30
+ must preserve the text offsets if transforming the message before transport.
31
+
32
+ Storybook: `GroupMentions`, `MobileGroupMentions`, and `DarkGroupMentions` use the
33
+ production components, include duplicate names and scrolling, and support empty
34
+ results by typing an unmatched query.