@linktr.ee/messaging-react 3.30.0-rc-1785750818 → 3.30.0-rc-1785752158
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-CTr4w41J.js → Card-BfahHyTp.js} +2 -2
- package/dist/{Card-CTr4w41J.js.map → Card-BfahHyTp.js.map} +1 -1
- package/dist/{Card-DPSSwUQN.cjs → Card-BfeugzyK.cjs} +2 -2
- package/dist/{Card-DPSSwUQN.cjs.map → Card-BfeugzyK.cjs.map} +1 -1
- package/dist/{index-B-FNsERo.cjs → index-Boy2y2Bl.cjs} +3 -3
- package/dist/{index-B-FNsERo.cjs.map → index-Boy2y2Bl.cjs.map} +1 -1
- package/dist/{index-BggNBgun.js → index-C0sHWtgL.js} +274 -265
- package/dist/{index-BggNBgun.js.map → index-C0sHWtgL.js.map} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/package.json +2 -2
- package/src/components/CustomMessageInput/CustomMessageInput.test.tsx +35 -1
- package/src/components/CustomMessageInput/index.tsx +47 -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-Boy2y2Bl.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.optimizeMessagingAttachmentUrl=e.optimizeMessagingAttachmentUrl;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.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 c, i as u, j as L, k as h, l as p, m as d, n as v, p as C, q as A, s as k, t as F, u as b, v as P, w as f, x, o as y, y as z, z as B, B as S, D as q, E as D, G as E, H as V, I as w } 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 c, i as u, j as L, k as h, l as p, m as d, n as v, p as C, q as A, s as k, t as F, u as b, v as P, w as f, x, o as y, y as z, z as B, B as S, D as q, E as D, G as E, H as V, I as w } from "./index-C0sHWtgL.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.30.0-rc-
|
|
3
|
+
"version": "3.30.0-rc-1785752158",
|
|
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": "2.3.0-rc-
|
|
53
|
+
"@linktr.ee/messaging-core": "2.3.0-rc-1785752158",
|
|
54
54
|
"@linktr.ee/messaging-taxonomy": "^0.5.0",
|
|
55
55
|
"@phosphor-icons/react": "^2.1.10",
|
|
56
56
|
"culori": "^4.0.2"
|
|
@@ -384,13 +384,47 @@ describe('CustomMessageInput', () => {
|
|
|
384
384
|
})
|
|
385
385
|
|
|
386
386
|
it('lets the textarea grow to fit rather than scrolling its own overflow', () => {
|
|
387
|
-
renderCard()
|
|
387
|
+
const card = renderCard()
|
|
388
388
|
|
|
389
389
|
// TextareaComposer defaults an absent maxRows to 1, so this has to be set.
|
|
390
390
|
expect(screen.getByTestId('textarea-composer')).toHaveAttribute(
|
|
391
391
|
'data-max-rows',
|
|
392
392
|
'Infinity'
|
|
393
393
|
)
|
|
394
|
+
// Growing to fit is what keeps it from overflowing; overflow-hidden is
|
|
395
|
+
// what keeps it from becoming a second scrollbar on the occasions the
|
|
396
|
+
// autosize is momentarily out of date (a width change it never hears
|
|
397
|
+
// about, e.g. the card gaining its own scrollbar and rewrapping the text).
|
|
398
|
+
expect(screen.getByTestId('textarea-composer')).toHaveClass(
|
|
399
|
+
'overflow-hidden'
|
|
400
|
+
)
|
|
401
|
+
// And the card stays the one region that does scroll.
|
|
402
|
+
expect(card).toHaveClass('overflow-y-auto')
|
|
403
|
+
})
|
|
404
|
+
|
|
405
|
+
it('leaves plain-text pastes to the browser but lets file pastes reach Stream', () => {
|
|
406
|
+
renderCard()
|
|
407
|
+
|
|
408
|
+
// Stream's paste handler is dispatched from React's root, above this
|
|
409
|
+
// card, so a listener further up stands in for it: the event reaching
|
|
410
|
+
// there means Stream would have handled it (and preventDefault'd the
|
|
411
|
+
// browser's own insert, which is what leaves the composer unresized).
|
|
412
|
+
const reachedStream = vi.fn()
|
|
413
|
+
document.addEventListener('paste', reachedStream)
|
|
414
|
+
|
|
415
|
+
const paste = (files: File[]) => {
|
|
416
|
+
const event = new Event('paste', { bubbles: true, cancelable: true })
|
|
417
|
+
Object.defineProperty(event, 'clipboardData', { value: { files } })
|
|
418
|
+
screen.getByTestId('textarea-composer').dispatchEvent(event)
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
paste([])
|
|
422
|
+
expect(reachedStream).not.toHaveBeenCalled()
|
|
423
|
+
|
|
424
|
+
paste([new File(['x'], 'shot.png', { type: 'image/png' })])
|
|
425
|
+
expect(reachedStream).toHaveBeenCalledTimes(1)
|
|
426
|
+
|
|
427
|
+
document.removeEventListener('paste', reachedStream)
|
|
394
428
|
})
|
|
395
429
|
|
|
396
430
|
it('scrolls the input back into view when the card shrinks under it', () => {
|
|
@@ -103,6 +103,40 @@ const CustomMessageInputInner: React.FC = () => {
|
|
|
103
103
|
return () => observer.disconnect()
|
|
104
104
|
}, [])
|
|
105
105
|
|
|
106
|
+
// Let the browser insert pasted text itself, so the composer grows to fit it
|
|
107
|
+
// immediately (MES-1037). Stream's paste handler calls preventDefault and
|
|
108
|
+
// feeds the text back through composer state asynchronously; TextareaComposer
|
|
109
|
+
// then assigns `textarea.value` in a layout effect, which fires no input event
|
|
110
|
+
// and so never triggers react-textarea-autosize's re-measure — leaving the
|
|
111
|
+
// composer one line tall, with the pasted text hidden, until the next
|
|
112
|
+
// keystroke happens to resize it. Letting the default action run puts pasted
|
|
113
|
+
// text on exactly the path typed text takes, which measures correctly.
|
|
114
|
+
//
|
|
115
|
+
// It has to be a native listener that stops propagation rather than an
|
|
116
|
+
// `onPaste` prop: TextareaComposer takes `onPaste` from the message-input
|
|
117
|
+
// context and applies it after spreading our props, so ours would be
|
|
118
|
+
// overridden, and a React handler on this card would run after the textarea's
|
|
119
|
+
// anyway. Stopping the event here keeps it from reaching React's root, where
|
|
120
|
+
// Stream's handler is dispatched from. Pastes carrying files still go to
|
|
121
|
+
// Stream, which uploads them as attachments.
|
|
122
|
+
React.useEffect(() => {
|
|
123
|
+
const card = cardRef.current
|
|
124
|
+
|
|
125
|
+
if (!card) {
|
|
126
|
+
return
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
const passToBrowser = (event: ClipboardEvent) => {
|
|
130
|
+
if (!event.clipboardData?.files.length) {
|
|
131
|
+
event.stopPropagation()
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
card.addEventListener('paste', passToBrowser)
|
|
136
|
+
|
|
137
|
+
return () => card.removeEventListener('paste', passToBrowser)
|
|
138
|
+
}, [])
|
|
139
|
+
|
|
106
140
|
return (
|
|
107
141
|
// This card is the composer's ONE scroll container: staged previews and the
|
|
108
142
|
// textarea row scroll together past a cap, instead of the previews being
|
|
@@ -167,7 +201,19 @@ const CustomMessageInputInner: React.FC = () => {
|
|
|
167
201
|
containerClassName="min-w-0 flex-1 leading-[0]"
|
|
168
202
|
// bg-transparent: the container has no padding to inset it behind
|
|
169
203
|
// anymore, so an opaque textarea would paint over its rounded corners.
|
|
170
|
-
|
|
204
|
+
//
|
|
205
|
+
// overflow-hidden makes "the card is the only scrollable region" a
|
|
206
|
+
// property of the CSS rather than of the autosize arithmetic always
|
|
207
|
+
// landing exactly right. A textarea's UA default is `overflow: auto`,
|
|
208
|
+
// and TextareaComposer sizes itself by copying the computed style into
|
|
209
|
+
// a detached measuring textarea on input, window resize and font load
|
|
210
|
+
// only — so any width change it does not hear about (most obviously
|
|
211
|
+
// this card gaining its own scrollbar, which narrows the textarea and
|
|
212
|
+
// rewraps the text onto another line) leaves it a line short and
|
|
213
|
+
// sprouts a second scrollbar inside the first. The caret stays visible
|
|
214
|
+
// either way: browsers still scroll an overflow-hidden textarea to
|
|
215
|
+
// reveal it, and the next keystroke re-fits the height.
|
|
216
|
+
className="w-full resize-none overflow-hidden bg-transparent py-3.5 pl-4 pr-4 outline-none leading-5 placeholder:text-black/30 text-sm"
|
|
171
217
|
// While this might usually be considered an anti-pattern, in most
|
|
172
218
|
// cases, when a message thread is rendered, we want the input to
|
|
173
219
|
// gain focus automatically.
|