@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 +29 -0
- package/dist/assets/{ChatInput.stories-pjQKncGw.js → ChatInput.stories-BQcIQDVE.js} +232 -24
- package/dist/assets/{Color-AVL7NMMY-CKkkQz33.js → Color-AVL7NMMY-Q9rY0eHd.js} +1 -1
- package/dist/assets/{DocsRenderer-PQXLIZUC-CVx0v9rK.js → DocsRenderer-PQXLIZUC-B5DlnesB.js} +4 -4
- package/dist/assets/{client-CMlGEQEC.js → client-DTiYOHAb.js} +1 -1
- package/dist/assets/{iframe-Bo_J3UyC.js → iframe-1QrxCBqr.js} +3 -3
- package/dist/assets/{index-D9myAQ7a.js → index-CkqBtKlT.js} +1 -1
- package/dist/assets/{react-18-CVKdgGic.js → react-18-6BKf31wF.js} +1 -1
- package/dist/iframe.html +1 -1
- package/dist/index.html +1 -1
- package/dist/index.json +1 -1
- package/dist/project.json +1 -1
- package/lib/components/ChatInputDesktop.js +146 -141
- package/lib/components/ChatInputMobile.js +12 -6
- package/lib/components/MentionMenu.d.ts +15 -0
- package/lib/components/MentionMenu.js +16 -0
- package/lib/hooks/useMentions.d.ts +38 -0
- package/lib/hooks/useMentions.js +83 -0
- package/lib/index.d.ts +3 -0
- package/lib/index.js +3 -0
- package/lib/mentions/model.d.ts +28 -0
- package/lib/mentions/model.js +40 -0
- package/lib/runtime/chatClient.d.ts +2 -0
- package/lib/runtime/chatClient.js +1 -1
- package/lib/types/chatInput.d.ts +4 -0
- package/package.json +16 -17
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.
|