@linktr.ee/messaging-react 1.8.5 → 1.8.6
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/assets/index.css +1 -1
- package/dist/index.js +508 -427
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/ChannelView.tsx +66 -48
- package/src/components/CustomMessageInput/index.tsx +61 -0
- package/src/styles.css +4 -0
package/package.json
CHANGED
|
@@ -13,7 +13,6 @@ import {
|
|
|
13
13
|
Channel,
|
|
14
14
|
Window,
|
|
15
15
|
MessageList,
|
|
16
|
-
MessageInput,
|
|
17
16
|
useChannelStateContext,
|
|
18
17
|
} from 'stream-chat-react'
|
|
19
18
|
|
|
@@ -23,7 +22,7 @@ import type { ChannelViewProps } from '../types'
|
|
|
23
22
|
import ActionButton from './ActionButton'
|
|
24
23
|
import { Avatar } from './Avatar'
|
|
25
24
|
import { CloseButton } from './CloseButton'
|
|
26
|
-
import {
|
|
25
|
+
import { CustomMessageInput } from './CustomMessageInput'
|
|
27
26
|
import { ChannelEmptyState } from './MessagingShell/ChannelEmptyState'
|
|
28
27
|
|
|
29
28
|
// Custom user type with email and username
|
|
@@ -37,21 +36,6 @@ type BlockedUser = {
|
|
|
37
36
|
blocked_user_id: string
|
|
38
37
|
}
|
|
39
38
|
|
|
40
|
-
/**
|
|
41
|
-
* Custom message input component with render prop for actions
|
|
42
|
-
*/
|
|
43
|
-
const CustomMessageInput: React.FC<{
|
|
44
|
-
renderActions?: () => React.ReactNode
|
|
45
|
-
}> = ({ renderActions }) => (
|
|
46
|
-
<div className="message-input flex items-center gap-2 p-4">
|
|
47
|
-
{renderActions && renderActions()}
|
|
48
|
-
|
|
49
|
-
<div className="flex-1">
|
|
50
|
-
<MessageInput focus maxRows={4} />
|
|
51
|
-
</div>
|
|
52
|
-
</div>
|
|
53
|
-
)
|
|
54
|
-
|
|
55
39
|
/**
|
|
56
40
|
* Custom channel header component
|
|
57
41
|
*/
|
|
@@ -76,39 +60,73 @@ const CustomChannelHeader: React.FC<{
|
|
|
76
60
|
const participantImage = participant?.user?.image
|
|
77
61
|
|
|
78
62
|
return (
|
|
79
|
-
<div className="
|
|
80
|
-
<div className="flex items-center
|
|
81
|
-
|
|
63
|
+
<div className="@container">
|
|
64
|
+
<div className="flex justify-between items-center @md:hidden">
|
|
65
|
+
<button
|
|
66
|
+
className={classNames(
|
|
67
|
+
'size-10 rounded-full bg-[#F1F0EE] flex items-center justify-center',
|
|
68
|
+
!showBackButton && 'invisible'
|
|
69
|
+
)}
|
|
70
|
+
onClick={onBack || (() => {})}
|
|
71
|
+
>
|
|
72
|
+
<ArrowLeftIcon className="size-5 text-black/90" />
|
|
73
|
+
</button>
|
|
74
|
+
<div className="flex flex-col gap-1 items-center">
|
|
75
|
+
<Avatar
|
|
76
|
+
id={participant?.user?.id || channel.id || 'unknown'}
|
|
77
|
+
name={participantName}
|
|
78
|
+
image={participantImage}
|
|
79
|
+
size={40}
|
|
80
|
+
/>
|
|
81
|
+
<h1 className="text-xs font-medium text-black/90">
|
|
82
|
+
{participantName}
|
|
83
|
+
</h1>
|
|
84
|
+
</div>
|
|
85
|
+
<button
|
|
86
|
+
className={classNames(
|
|
87
|
+
'size-10 rounded-full bg-[#F1F0EE] flex items-center justify-center'
|
|
88
|
+
)}
|
|
89
|
+
onClick={onShowInfo || (() => {})}
|
|
90
|
+
>
|
|
91
|
+
<DotsThreeIcon className="size-5 text-black/90" />
|
|
92
|
+
</button>
|
|
93
|
+
</div>
|
|
94
|
+
<div className="hidden @md:flex items-center justify-between gap-3 min-h-12">
|
|
95
|
+
<div className="flex items-center gap-4 min-w-0">
|
|
96
|
+
{showBackButton && onBack && (
|
|
97
|
+
<button
|
|
98
|
+
type="button"
|
|
99
|
+
onClick={onBack}
|
|
100
|
+
className="size-10 rounded-full bg-[#F1F0EE] flex items-center justify-center"
|
|
101
|
+
aria-label="Back to conversations"
|
|
102
|
+
>
|
|
103
|
+
<ArrowLeftIcon className="size-5 text-black/90" />
|
|
104
|
+
</button>
|
|
105
|
+
)}
|
|
106
|
+
{/* Avatar */}
|
|
107
|
+
<Avatar
|
|
108
|
+
id={participant?.user?.id || channel.id || 'unknown'}
|
|
109
|
+
name={participantName}
|
|
110
|
+
image={participantImage}
|
|
111
|
+
size={40}
|
|
112
|
+
/>
|
|
113
|
+
<div className="min-w-0">
|
|
114
|
+
<h1 className="font-medium text-black/90 truncate">
|
|
115
|
+
{participantName}
|
|
116
|
+
</h1>
|
|
117
|
+
</div>
|
|
118
|
+
</div>
|
|
119
|
+
{canShowInfo && onShowInfo && (
|
|
82
120
|
<button
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
121
|
+
className={classNames(
|
|
122
|
+
'size-10 rounded-full bg-[#F1F0EE] flex items-center justify-center'
|
|
123
|
+
)}
|
|
124
|
+
onClick={onShowInfo}
|
|
87
125
|
>
|
|
88
|
-
<
|
|
126
|
+
<DotsThreeIcon className="size-5 text-black/90" />
|
|
89
127
|
</button>
|
|
90
128
|
)}
|
|
91
|
-
|
|
92
|
-
{/* Avatar */}
|
|
93
|
-
<Avatar
|
|
94
|
-
id={participant?.user?.id || channel.id || 'unknown'}
|
|
95
|
-
name={participantName}
|
|
96
|
-
image={participantImage}
|
|
97
|
-
size={40}
|
|
98
|
-
/>
|
|
99
|
-
|
|
100
|
-
<div className="min-w-0">
|
|
101
|
-
<h1 className="text-lg font-semibold text-charcoal truncate">
|
|
102
|
-
{participantName}
|
|
103
|
-
</h1>
|
|
104
|
-
</div>
|
|
105
129
|
</div>
|
|
106
|
-
|
|
107
|
-
{canShowInfo && onShowInfo && (
|
|
108
|
-
<IconButton label="Chat info" onClick={onShowInfo}>
|
|
109
|
-
<DotsThreeIcon className="h-6 w-6 text-charcoal" weight="bold" />
|
|
110
|
-
</IconButton>
|
|
111
|
-
)}
|
|
112
130
|
</div>
|
|
113
131
|
)
|
|
114
132
|
}
|
|
@@ -446,7 +464,7 @@ const ChannelViewInner: React.FC<{
|
|
|
446
464
|
<>
|
|
447
465
|
<Window>
|
|
448
466
|
{/* Custom Channel Header */}
|
|
449
|
-
<div className="
|
|
467
|
+
<div className="p-4">
|
|
450
468
|
<CustomChannelHeader
|
|
451
469
|
onBack={onBack}
|
|
452
470
|
showBackButton={showBackButton}
|
|
@@ -461,7 +479,7 @@ const ChannelViewInner: React.FC<{
|
|
|
461
479
|
|
|
462
480
|
{/* Show custom empty state when no messages */}
|
|
463
481
|
{!hasMessages && CustomChannelEmptyState && (
|
|
464
|
-
<div className="absolute inset-0 w-full h-full
|
|
482
|
+
<div className="absolute inset-0 w-full h-full">
|
|
465
483
|
<CustomChannelEmptyState />
|
|
466
484
|
</div>
|
|
467
485
|
)}
|
|
@@ -503,7 +521,7 @@ export const ChannelView: React.FC<ChannelViewProps> = ({
|
|
|
503
521
|
return (
|
|
504
522
|
<div
|
|
505
523
|
className={classNames(
|
|
506
|
-
'messaging-channel-view h-full flex flex-col',
|
|
524
|
+
'messaging-channel-view h-full flex flex-col bg-[#FBFAF9]',
|
|
507
525
|
className
|
|
508
526
|
)}
|
|
509
527
|
>
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { ArrowUpIcon } from '@phosphor-icons/react'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
import {
|
|
4
|
+
AttachmentPreviewList,
|
|
5
|
+
LinkPreviewList,
|
|
6
|
+
MessageInput,
|
|
7
|
+
QuotedMessagePreview,
|
|
8
|
+
SimpleAttachmentSelector,
|
|
9
|
+
TextareaComposer,
|
|
10
|
+
useMessageComposerHasSendableData,
|
|
11
|
+
useMessageInputContext,
|
|
12
|
+
} from 'stream-chat-react'
|
|
13
|
+
|
|
14
|
+
const CustomMessageInputInner: React.FC = () => {
|
|
15
|
+
const { handleSubmit } = useMessageInputContext()
|
|
16
|
+
const hasSendableData = useMessageComposerHasSendableData()
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<>
|
|
20
|
+
<div className="left-container">
|
|
21
|
+
<SimpleAttachmentSelector />
|
|
22
|
+
</div>
|
|
23
|
+
<div className="central-container w-full p-2 bg-white rounded-lg shadow-[0_4px_16px_0_rgba(0,0,0,0.08),0_1px_2px_0_rgba(0,0,0,0.04),0_0_0_1px_rgba(0,0,0,0.04)]">
|
|
24
|
+
<QuotedMessagePreview />
|
|
25
|
+
<LinkPreviewList />
|
|
26
|
+
<AttachmentPreviewList />
|
|
27
|
+
<div className="flex">
|
|
28
|
+
<div className="w-full ml-2 mr-4">
|
|
29
|
+
<TextareaComposer
|
|
30
|
+
className="align-middle w-full resize-none outline-none"
|
|
31
|
+
maxRows={4}
|
|
32
|
+
/>
|
|
33
|
+
</div>
|
|
34
|
+
<button
|
|
35
|
+
aria-label="Send"
|
|
36
|
+
className="str-chat__send-button mt-auto flex justify-center items-center flex-shrink-0 rounded-full size-8 bg-[#121110] disabled:bg-[#F1F0EE] disabled:text-black/20 text-white"
|
|
37
|
+
data-testid="send-button"
|
|
38
|
+
disabled={!hasSendableData}
|
|
39
|
+
onClick={handleSubmit}
|
|
40
|
+
type="button"
|
|
41
|
+
>
|
|
42
|
+
<ArrowUpIcon className="size-4" />
|
|
43
|
+
</button>
|
|
44
|
+
</div>
|
|
45
|
+
</div>
|
|
46
|
+
</>
|
|
47
|
+
)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface CustomMessageInputProps {
|
|
51
|
+
renderActions?: () => React.ReactNode
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export const CustomMessageInput: React.FC<CustomMessageInputProps> = ({
|
|
55
|
+
renderActions,
|
|
56
|
+
}) => (
|
|
57
|
+
<div className="message-input flex items-center gap-2 p-4">
|
|
58
|
+
{renderActions && renderActions?.()}
|
|
59
|
+
<MessageInput Input={CustomMessageInputInner} />
|
|
60
|
+
</div>
|
|
61
|
+
)
|
package/src/styles.css
CHANGED