@linktr.ee/messaging-react 3.11.0 → 3.12.0-rc-1783766425
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/dist/{Card-V5d6qhDT.js → Card-BnbNynLQ.js} +2 -2
- package/dist/{Card-V5d6qhDT.js.map → Card-BnbNynLQ.js.map} +1 -1
- package/dist/{Card-CyWdUMCB.cjs → Card-UnwKmYzt.cjs} +2 -2
- package/dist/{Card-CyWdUMCB.cjs.map → Card-UnwKmYzt.cjs.map} +1 -1
- package/dist/{index-Bx_zjNMR.cjs → index-CyHyftBi.cjs} +2 -2
- package/dist/{index-Bx_zjNMR.cjs.map → index-CyHyftBi.cjs.map} +1 -1
- package/dist/{index-DFZrAiLB.js → index-DJXjS2H9.js} +494 -482
- package/dist/{index-DFZrAiLB.js.map → index-DJXjS2H9.js.map} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +32 -0
- package/dist/index.js +1 -1
- package/package.json +2 -2
- package/src/components/ChannelList/index.test.tsx +46 -0
- package/src/components/ChannelList/index.tsx +12 -0
- package/src/index.ts +1 -0
- package/src/types.ts +34 -1
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-CyHyftBi.cjs");exports.ActionButton=e.ActionButton;exports.Avatar=e.Avatar;exports.ChannelEmptyState=e.ChannelEmptyState;exports.ChannelList=e.ChannelList;exports.ChannelView=e.ChannelView;exports.CustomMessageProvider=e.CustomMessageProvider;exports.FaqList=e.FaqList;exports.FaqListItem=e.FaqListItem;exports.LinkAttachment=e.LinkAttachment;exports.LockedAttachment=e.LockedAttachment;exports.MediaMessage=e.MediaMessage;exports.MessageAttachment=e.MessageAttachment;exports.MessageBubble=e.MessageBubble;exports.MessageVoteButtons=e.MessageVoteButtons;exports.MessagingProvider=e.MessagingProvider;exports.MessagingShell=e.MessagingShell;exports.buildCompactMetaLabel=e.buildCompactMetaLabel;exports.formatFileSize=e.formatFileSize;exports.formatRelativeTime=e.formatRelativeTime;exports.getFileExtensionLabel=e.getFileExtensionLabel;exports.getMessageDisplayText=e.getMessageDisplayText;exports.isLinkAttachment=e.isLinkAttachment;exports.isUuidLike=e.isUuidLike;exports.messageAttachmentGroupPositionFromStream=e.bubbleGroupPositionFromStream;exports.normalizeLanguageCode=e.normalizeLanguageCode;exports.resolveConversationParticipant=e.resolveConversationParticipant;exports.resolveLinkAttachment=e.resolveLinkAttachment;exports.resolveMediaFromMessage=e.resolveMediaFromMessage;exports.resolveParticipantDisplayName=e.resolveParticipantDisplayName;exports.useComposerLocked=e.useComposerLocked;exports.useCustomMessage=e.useCustomMessage;exports.useMessageVote=e.useMessageVote;exports.useMessaging=e.useMessaging;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.d.ts
CHANGED
|
@@ -6,7 +6,9 @@ import { ChannelPreviewUIComponentProps } from 'stream-chat-react';
|
|
|
6
6
|
import { ChannelSort } from 'stream-chat';
|
|
7
7
|
import { ComponentType } from 'react';
|
|
8
8
|
import { default as default_2 } from 'react';
|
|
9
|
+
import { Dispatch } from 'react';
|
|
9
10
|
import { EmptyStateIndicatorProps } from 'stream-chat-react';
|
|
11
|
+
import { Event as Event_2 } from 'stream-chat';
|
|
10
12
|
import { FC } from 'react';
|
|
11
13
|
import { InfiniteScrollProps } from 'stream-chat-react';
|
|
12
14
|
import { JSX as JSX_2 } from 'react/jsx-runtime';
|
|
@@ -14,6 +16,7 @@ import { LocalMessage } from 'stream-chat';
|
|
|
14
16
|
import { MessagingUser } from '@linktr.ee/messaging-core';
|
|
15
17
|
import { Provider } from 'react';
|
|
16
18
|
import { SendMessageAPIResponse } from 'stream-chat';
|
|
19
|
+
import { SetStateAction } from 'react';
|
|
17
20
|
import { StreamChat } from 'stream-chat';
|
|
18
21
|
import { StreamChatService } from '@linktr.ee/messaging-core';
|
|
19
22
|
import { StreamChatServiceConfig } from '@linktr.ee/messaging-core';
|
|
@@ -153,8 +156,37 @@ export declare interface ChannelListProps {
|
|
|
153
156
|
* Falls back to message.text when no matching translation exists.
|
|
154
157
|
*/
|
|
155
158
|
viewerLanguage?: string;
|
|
159
|
+
/**
|
|
160
|
+
* Lock the visible channel order so live events don't promote a channel to
|
|
161
|
+
* the top. Forwarded to Stream's `<ChannelList>`. Note `lockChannelOrder`
|
|
162
|
+
* alone doesn't cover `notification.message_new` or `channel.visible`; pair it
|
|
163
|
+
* with the event handlers below to fully neutralize promotion.
|
|
164
|
+
*/
|
|
165
|
+
lockChannelOrder?: boolean;
|
|
166
|
+
/**
|
|
167
|
+
* Live channel-list event handlers forwarded verbatim to Stream's
|
|
168
|
+
* `<ChannelList>`. Left undefined, Stream applies its default "move the
|
|
169
|
+
* changed channel to the top" behaviour.
|
|
170
|
+
*
|
|
171
|
+
* Hosts that order by a custom channel field (`last_conversation_at` for the
|
|
172
|
+
* inbox, `priority_score` for Spotlight) use these to neutralize promotion on
|
|
173
|
+
* new-message / visibility events and re-sort on `channel.updated` instead.
|
|
174
|
+
* Each receives Stream's `setChannels` dispatcher and the triggering event.
|
|
175
|
+
* See MES-1214 / MES-1219.
|
|
176
|
+
*/
|
|
177
|
+
onMessageNewHandler?: ChannelListReorderHandler;
|
|
178
|
+
onMessageNew?: ChannelListReorderHandler;
|
|
179
|
+
onChannelVisible?: ChannelListReorderHandler;
|
|
180
|
+
onAddedToChannel?: ChannelListReorderHandler;
|
|
181
|
+
onChannelUpdated?: ChannelListReorderHandler;
|
|
156
182
|
}
|
|
157
183
|
|
|
184
|
+
/**
|
|
185
|
+
* Signature of Stream's `<ChannelList>` live-event handlers: mutate the loaded
|
|
186
|
+
* channel array via `setChannels` in response to a websocket `event`.
|
|
187
|
+
*/
|
|
188
|
+
export declare type ChannelListReorderHandler = (setChannels: Dispatch<SetStateAction<Channel[]>>, event: Event_2) => void;
|
|
189
|
+
|
|
158
190
|
declare type ChannelMember = ChannelMembers[string];
|
|
159
191
|
|
|
160
192
|
declare type ChannelMembers = NonNullable<Channel['state']>['members'];
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as e, b as t, C as i, c as o, d as n, e as m, F as r, f as g, L as l, h as M, M as u, i as c, j as L, k as h, l as d, m as p, n as v, o as C, p as A, q as k, s as F, t as b, u as P, v as f, w as x, x as y, y as B, z as S, B as q, D as z, E as D, G as E, H as V } from "./index-
|
|
1
|
+
import { a as e, b as t, C as i, c as o, d as n, e as m, F as r, f as g, L as l, h as M, M as u, i as c, j as L, k as h, l as d, m as p, n as v, o as C, p as A, q as k, s as F, t as b, u as P, v as f, w as x, x as y, y as B, z as S, B as q, D as z, E as D, G as E, H as V } from "./index-DJXjS2H9.js";
|
|
2
2
|
export {
|
|
3
3
|
e as ActionButton,
|
|
4
4
|
t as Avatar,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@linktr.ee/messaging-react",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.12.0-rc-1783766425",
|
|
4
4
|
"description": "React messaging components built on messaging-core for web applications",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
52
|
"@linktr.ee/component-library": "11.8.6",
|
|
53
|
-
"@linktr.ee/messaging-core": "
|
|
53
|
+
"@linktr.ee/messaging-core": "2.3.0-rc-1783766425",
|
|
54
54
|
"@phosphor-icons/react": "^2.1.10"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
@@ -125,6 +125,52 @@ describe('ChannelList', () => {
|
|
|
125
125
|
})
|
|
126
126
|
})
|
|
127
127
|
|
|
128
|
+
it('leaves live-reorder controls undefined by default so Stream keeps its default ordering', () => {
|
|
129
|
+
renderWithProviders(<ChannelList {...defaultProps} />)
|
|
130
|
+
|
|
131
|
+
expect(streamChannelListMock).toHaveBeenCalledOnce()
|
|
132
|
+
const streamProps = streamChannelListMock.mock.calls[0][0] as Record<
|
|
133
|
+
string,
|
|
134
|
+
unknown
|
|
135
|
+
>
|
|
136
|
+
expect(streamProps.lockChannelOrder).toBeUndefined()
|
|
137
|
+
expect(streamProps.onMessageNewHandler).toBeUndefined()
|
|
138
|
+
expect(streamProps.onMessageNew).toBeUndefined()
|
|
139
|
+
expect(streamProps.onChannelVisible).toBeUndefined()
|
|
140
|
+
expect(streamProps.onAddedToChannel).toBeUndefined()
|
|
141
|
+
expect(streamProps.onChannelUpdated).toBeUndefined()
|
|
142
|
+
})
|
|
143
|
+
|
|
144
|
+
it('forwards live-reorder controls to Stream ChannelList when provided', () => {
|
|
145
|
+
const onMessageNewHandler = vi.fn()
|
|
146
|
+
const onMessageNew = vi.fn()
|
|
147
|
+
const onChannelVisible = vi.fn()
|
|
148
|
+
const onAddedToChannel = vi.fn()
|
|
149
|
+
const onChannelUpdated = vi.fn()
|
|
150
|
+
|
|
151
|
+
renderWithProviders(
|
|
152
|
+
<ChannelList
|
|
153
|
+
{...defaultProps}
|
|
154
|
+
lockChannelOrder
|
|
155
|
+
onMessageNewHandler={onMessageNewHandler}
|
|
156
|
+
onMessageNew={onMessageNew}
|
|
157
|
+
onChannelVisible={onChannelVisible}
|
|
158
|
+
onAddedToChannel={onAddedToChannel}
|
|
159
|
+
onChannelUpdated={onChannelUpdated}
|
|
160
|
+
/>
|
|
161
|
+
)
|
|
162
|
+
|
|
163
|
+
expect(streamChannelListMock).toHaveBeenCalledOnce()
|
|
164
|
+
expect(streamChannelListMock.mock.calls[0][0]).toMatchObject({
|
|
165
|
+
lockChannelOrder: true,
|
|
166
|
+
onMessageNewHandler,
|
|
167
|
+
onMessageNew,
|
|
168
|
+
onChannelVisible,
|
|
169
|
+
onAddedToChannel,
|
|
170
|
+
onChannelUpdated,
|
|
171
|
+
})
|
|
172
|
+
})
|
|
173
|
+
|
|
128
174
|
it('wraps channelRenderFilterFn to restore pending messages and delegates to consumer filter', () => {
|
|
129
175
|
const filterFn = vi.fn((channels: Channel[]) => channels)
|
|
130
176
|
|
|
@@ -32,6 +32,12 @@ export const ChannelList = React.memo<ChannelListProps>(
|
|
|
32
32
|
channelPreview,
|
|
33
33
|
renderMessagePreview,
|
|
34
34
|
viewerLanguage,
|
|
35
|
+
lockChannelOrder,
|
|
36
|
+
onMessageNewHandler,
|
|
37
|
+
onMessageNew,
|
|
38
|
+
onChannelVisible,
|
|
39
|
+
onAddedToChannel,
|
|
40
|
+
onChannelUpdated,
|
|
35
41
|
}) => {
|
|
36
42
|
// Track renders
|
|
37
43
|
const renderCountRef = React.useRef(0)
|
|
@@ -100,6 +106,12 @@ export const ChannelList = React.memo<ChannelListProps>(
|
|
|
100
106
|
allowNewMessagesFromUnfilteredChannels
|
|
101
107
|
}
|
|
102
108
|
channelRenderFilterFn={wrappedChannelRenderFilterFn}
|
|
109
|
+
lockChannelOrder={lockChannelOrder}
|
|
110
|
+
onMessageNewHandler={onMessageNewHandler}
|
|
111
|
+
onMessageNew={onMessageNew}
|
|
112
|
+
onChannelVisible={onChannelVisible}
|
|
113
|
+
onAddedToChannel={onAddedToChannel}
|
|
114
|
+
onChannelUpdated={onChannelUpdated}
|
|
103
115
|
Paginator={Paginator}
|
|
104
116
|
Preview={CustomChannelPreview}
|
|
105
117
|
EmptyStateIndicator={customEmptyStateIndicator}
|
package/src/index.ts
CHANGED
package/src/types.ts
CHANGED
|
@@ -2,12 +2,13 @@ import type {
|
|
|
2
2
|
MessagingUser,
|
|
3
3
|
StreamChatServiceConfig,
|
|
4
4
|
} from '@linktr.ee/messaging-core'
|
|
5
|
-
import type { ComponentType } from 'react'
|
|
5
|
+
import type { ComponentType, Dispatch, SetStateAction } from 'react'
|
|
6
6
|
import type {
|
|
7
7
|
Channel,
|
|
8
8
|
ChannelFilters,
|
|
9
9
|
ChannelMemberResponse,
|
|
10
10
|
ChannelSort,
|
|
11
|
+
Event,
|
|
11
12
|
LocalMessage,
|
|
12
13
|
SendMessageAPIResponse,
|
|
13
14
|
StreamChat,
|
|
@@ -122,8 +123,40 @@ export interface ChannelListProps {
|
|
|
122
123
|
* Falls back to message.text when no matching translation exists.
|
|
123
124
|
*/
|
|
124
125
|
viewerLanguage?: string
|
|
126
|
+
/**
|
|
127
|
+
* Lock the visible channel order so live events don't promote a channel to
|
|
128
|
+
* the top. Forwarded to Stream's `<ChannelList>`. Note `lockChannelOrder`
|
|
129
|
+
* alone doesn't cover `notification.message_new` or `channel.visible`; pair it
|
|
130
|
+
* with the event handlers below to fully neutralize promotion.
|
|
131
|
+
*/
|
|
132
|
+
lockChannelOrder?: boolean
|
|
133
|
+
/**
|
|
134
|
+
* Live channel-list event handlers forwarded verbatim to Stream's
|
|
135
|
+
* `<ChannelList>`. Left undefined, Stream applies its default "move the
|
|
136
|
+
* changed channel to the top" behaviour.
|
|
137
|
+
*
|
|
138
|
+
* Hosts that order by a custom channel field (`last_conversation_at` for the
|
|
139
|
+
* inbox, `priority_score` for Spotlight) use these to neutralize promotion on
|
|
140
|
+
* new-message / visibility events and re-sort on `channel.updated` instead.
|
|
141
|
+
* Each receives Stream's `setChannels` dispatcher and the triggering event.
|
|
142
|
+
* See MES-1214 / MES-1219.
|
|
143
|
+
*/
|
|
144
|
+
onMessageNewHandler?: ChannelListReorderHandler
|
|
145
|
+
onMessageNew?: ChannelListReorderHandler
|
|
146
|
+
onChannelVisible?: ChannelListReorderHandler
|
|
147
|
+
onAddedToChannel?: ChannelListReorderHandler
|
|
148
|
+
onChannelUpdated?: ChannelListReorderHandler
|
|
125
149
|
}
|
|
126
150
|
|
|
151
|
+
/**
|
|
152
|
+
* Signature of Stream's `<ChannelList>` live-event handlers: mutate the loaded
|
|
153
|
+
* channel array via `setChannels` in response to a websocket `event`.
|
|
154
|
+
*/
|
|
155
|
+
export type ChannelListReorderHandler = (
|
|
156
|
+
setChannels: Dispatch<SetStateAction<Channel[]>>,
|
|
157
|
+
event: Event
|
|
158
|
+
) => void
|
|
159
|
+
|
|
127
160
|
/**
|
|
128
161
|
* ChannelView component props
|
|
129
162
|
*/
|