stream-chat-react 13.0.0-rc.2 → 13.0.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/dist/components/Channel/Channel.d.ts +1 -1
- package/dist/components/Channel/Channel.js +2 -0
- package/dist/components/Chat/hooks/useChat.js +1 -1
- package/dist/components/MessageInput/EditMessageForm.js +1 -1
- package/dist/components/MessageInput/MessageInput.d.ts +1 -3
- package/dist/components/MessageInput/MessageInputFlat.js +2 -2
- package/dist/components/MessageInput/hooks/useCreateMessageInputContext.js +1 -3
- package/dist/components/MessageInput/hooks/useMessageInputControls.d.ts +0 -1
- package/dist/components/MessageInput/hooks/useMessageInputControls.js +3 -4
- package/dist/components/MessageInput/hooks/usePasteHandler.d.ts +1 -1
- package/dist/components/MessageInput/hooks/usePasteHandler.js +4 -4
- package/dist/components/MessageInput/hooks/{useMessageInputText.d.ts → useTextareaRef.d.ts} +1 -2
- package/dist/components/MessageInput/hooks/useTextareaRef.js +14 -0
- package/dist/components/TextareaComposer/TextareaComposer.d.ts +3 -5
- package/dist/components/TextareaComposer/TextareaComposer.js +13 -8
- package/dist/context/ComponentContext.d.ts +3 -3
- package/dist/experimental/index.browser.cjs.map +2 -2
- package/dist/experimental/index.node.cjs.map +2 -2
- package/dist/index.browser.cjs +264 -282
- package/dist/index.browser.cjs.map +4 -4
- package/dist/index.node.cjs +264 -282
- package/dist/index.node.cjs.map +4 -4
- package/dist/plugins/Emojis/EmojiPicker.js +9 -4
- package/dist/plugins/Emojis/index.browser.cjs +208 -96
- package/dist/plugins/Emojis/index.browser.cjs.map +4 -4
- package/dist/plugins/Emojis/index.node.cjs +208 -96
- package/dist/plugins/Emojis/index.node.cjs.map +4 -4
- package/dist/plugins/Emojis/middleware/textComposerEmojiMiddleware.d.ts +4 -48
- package/dist/plugins/Emojis/middleware/textComposerEmojiMiddleware.js +52 -58
- package/package.json +3 -3
- package/dist/components/MessageInput/hooks/useMessageInputText.js +0 -44
package/dist/index.browser.cjs
CHANGED
|
@@ -17666,11 +17666,11 @@ __export(src_exports, {
|
|
|
17666
17666
|
module.exports = __toCommonJS(src_exports);
|
|
17667
17667
|
|
|
17668
17668
|
// src/components/Attachment/Attachment.tsx
|
|
17669
|
-
var
|
|
17669
|
+
var import_react255 = __toESM(require("react"));
|
|
17670
17670
|
var import_stream_chat10 = require("stream-chat");
|
|
17671
17671
|
|
|
17672
17672
|
// src/components/Attachment/AttachmentContainer.tsx
|
|
17673
|
-
var
|
|
17673
|
+
var import_react254 = __toESM(require("react"));
|
|
17674
17674
|
var import_react_player2 = __toESM(require("react-player"));
|
|
17675
17675
|
var import_clsx65 = __toESM(require("clsx"));
|
|
17676
17676
|
var linkify = __toESM(require("linkifyjs"));
|
|
@@ -18915,7 +18915,7 @@ var UnMemoizedAudio = (props) => {
|
|
|
18915
18915
|
var Audio = import_react29.default.memo(UnMemoizedAudio);
|
|
18916
18916
|
|
|
18917
18917
|
// src/components/Attachment/VoiceRecording.tsx
|
|
18918
|
-
var
|
|
18918
|
+
var import_react250 = __toESM(require("react"));
|
|
18919
18919
|
|
|
18920
18920
|
// src/components/ReactFileUtilities/FileIcon/FileIcon.tsx
|
|
18921
18921
|
var import_react31 = __toESM(require("react"));
|
|
@@ -19878,7 +19878,7 @@ var FileIcon = (props) => {
|
|
|
19878
19878
|
// src/components/ReactFileUtilities/UploadButton.tsx
|
|
19879
19879
|
var import_clsx63 = __toESM(require("clsx"));
|
|
19880
19880
|
var import_nanoid5 = require("nanoid");
|
|
19881
|
-
var
|
|
19881
|
+
var import_react249 = __toESM(require("react"));
|
|
19882
19882
|
|
|
19883
19883
|
// src/components/ReactFileUtilities/utils.ts
|
|
19884
19884
|
var import_react32 = require("react");
|
|
@@ -47796,49 +47796,17 @@ var useCooldownTimer = () => {
|
|
|
47796
47796
|
};
|
|
47797
47797
|
};
|
|
47798
47798
|
|
|
47799
|
-
// src/components/MessageInput/hooks/
|
|
47799
|
+
// src/components/MessageInput/hooks/useTextareaRef.ts
|
|
47800
47800
|
var import_react224 = require("react");
|
|
47801
|
-
var
|
|
47802
|
-
text: state.text
|
|
47803
|
-
});
|
|
47804
|
-
var useMessageInputText = (props) => {
|
|
47801
|
+
var useTextareaRef = (props) => {
|
|
47805
47802
|
const { focus } = props;
|
|
47806
|
-
const messageComposer = useMessageComposer();
|
|
47807
47803
|
const textareaRef = (0, import_react224.useRef)(void 0);
|
|
47808
|
-
const { text: text8 } = useStateStore(
|
|
47809
|
-
messageComposer.textComposer.state,
|
|
47810
|
-
messageComposerStateSelector
|
|
47811
|
-
);
|
|
47812
47804
|
(0, import_react224.useEffect)(() => {
|
|
47813
47805
|
if (focus && textareaRef.current) {
|
|
47814
47806
|
textareaRef.current.focus();
|
|
47815
47807
|
}
|
|
47816
47808
|
}, [focus]);
|
|
47817
|
-
const newCursorPosition = (0, import_react224.useRef)(void 0);
|
|
47818
|
-
const insertText = (0, import_react224.useCallback)(
|
|
47819
|
-
(textToInsert) => {
|
|
47820
|
-
const selection = textareaRef?.current && {
|
|
47821
|
-
end: textareaRef.current.selectionEnd,
|
|
47822
|
-
start: textareaRef.current.selectionStart
|
|
47823
|
-
};
|
|
47824
|
-
messageComposer.textComposer.insertText({
|
|
47825
|
-
selection,
|
|
47826
|
-
text: textToInsert
|
|
47827
|
-
});
|
|
47828
|
-
if (selection) newCursorPosition.current = selection.start + textToInsert.length;
|
|
47829
|
-
},
|
|
47830
|
-
[messageComposer, newCursorPosition, textareaRef]
|
|
47831
|
-
);
|
|
47832
|
-
(0, import_react224.useEffect)(() => {
|
|
47833
|
-
const textareaElement = textareaRef.current;
|
|
47834
|
-
if (textareaElement && newCursorPosition.current !== void 0) {
|
|
47835
|
-
textareaElement.selectionStart = newCursorPosition.current;
|
|
47836
|
-
textareaElement.selectionEnd = newCursorPosition.current;
|
|
47837
|
-
newCursorPosition.current = void 0;
|
|
47838
|
-
}
|
|
47839
|
-
}, [text8, newCursorPosition]);
|
|
47840
47809
|
return {
|
|
47841
|
-
insertText,
|
|
47842
47810
|
textareaRef
|
|
47843
47811
|
};
|
|
47844
47812
|
};
|
|
@@ -47898,8 +47866,8 @@ var useSubmitHandler = (props) => {
|
|
|
47898
47866
|
|
|
47899
47867
|
// src/components/MessageInput/hooks/usePasteHandler.ts
|
|
47900
47868
|
var import_react226 = require("react");
|
|
47901
|
-
var usePasteHandler = (
|
|
47902
|
-
const { attachmentManager } = useMessageComposer();
|
|
47869
|
+
var usePasteHandler = () => {
|
|
47870
|
+
const { attachmentManager, textComposer } = useMessageComposer();
|
|
47903
47871
|
const onPaste = (0, import_react226.useCallback)(
|
|
47904
47872
|
(clipboardEvent) => {
|
|
47905
47873
|
(async (event) => {
|
|
@@ -47920,13 +47888,13 @@ var usePasteHandler = (insertText) => {
|
|
|
47920
47888
|
const fileLikes = await dataTransferItemsToFiles(Array.from(items));
|
|
47921
47889
|
if (plainTextPromise) {
|
|
47922
47890
|
const pastedText = await plainTextPromise;
|
|
47923
|
-
insertText(pastedText);
|
|
47891
|
+
textComposer.insertText({ text: pastedText });
|
|
47924
47892
|
} else {
|
|
47925
47893
|
attachmentManager.uploadFiles(fileLikes);
|
|
47926
47894
|
}
|
|
47927
47895
|
})(clipboardEvent);
|
|
47928
47896
|
},
|
|
47929
|
-
[attachmentManager,
|
|
47897
|
+
[attachmentManager, textComposer]
|
|
47930
47898
|
);
|
|
47931
47899
|
return { onPaste };
|
|
47932
47900
|
};
|
|
@@ -47995,7 +47963,7 @@ var useMediaRecorder = ({
|
|
|
47995
47963
|
// src/components/MessageInput/hooks/useMessageInputControls.ts
|
|
47996
47964
|
var useMessageInputControls = (props) => {
|
|
47997
47965
|
const { asyncMessagesMultiSendEnabled, audioRecordingConfig, audioRecordingEnabled } = props;
|
|
47998
|
-
const {
|
|
47966
|
+
const { textareaRef } = useTextareaRef(props);
|
|
47999
47967
|
const { handleSubmit } = useSubmitHandler(props);
|
|
48000
47968
|
const recordingController = useMediaRecorder({
|
|
48001
47969
|
asyncMessagesMultiSendEnabled,
|
|
@@ -48003,10 +47971,9 @@ var useMessageInputControls = (props) => {
|
|
|
48003
47971
|
handleSubmit,
|
|
48004
47972
|
recordingConfig: audioRecordingConfig
|
|
48005
47973
|
});
|
|
48006
|
-
const { onPaste } = usePasteHandler(
|
|
47974
|
+
const { onPaste } = usePasteHandler();
|
|
48007
47975
|
return {
|
|
48008
47976
|
handleSubmit,
|
|
48009
|
-
insertText,
|
|
48010
47977
|
onPaste,
|
|
48011
47978
|
recordingController,
|
|
48012
47979
|
textareaRef
|
|
@@ -48138,13 +48105,13 @@ var CooldownTimer = ({ cooldownInterval }) => {
|
|
|
48138
48105
|
};
|
|
48139
48106
|
|
|
48140
48107
|
// src/components/MessageInput/EditMessageForm.tsx
|
|
48141
|
-
var
|
|
48108
|
+
var import_react248 = __toESM(require("react"));
|
|
48142
48109
|
|
|
48143
48110
|
// src/components/MessageInput/MessageInput.tsx
|
|
48144
|
-
var
|
|
48111
|
+
var import_react247 = __toESM(require("react"));
|
|
48145
48112
|
|
|
48146
48113
|
// src/components/MessageInput/MessageInputFlat.tsx
|
|
48147
|
-
var
|
|
48114
|
+
var import_react245 = __toESM(require("react"));
|
|
48148
48115
|
|
|
48149
48116
|
// src/components/MessageInput/SendButton.tsx
|
|
48150
48117
|
var import_react231 = __toESM(require("react"));
|
|
@@ -48267,7 +48234,7 @@ var linkPreviewsManagerStateSelector = (state) => ({
|
|
|
48267
48234
|
(preview) => import_stream_chat9.LinkPreviewsManager.previewIsLoaded(preview) || import_stream_chat9.LinkPreviewsManager.previewIsLoading(preview)
|
|
48268
48235
|
)
|
|
48269
48236
|
});
|
|
48270
|
-
var
|
|
48237
|
+
var messageComposerStateSelector = (state) => ({
|
|
48271
48238
|
quotedMessage: state.quotedMessage
|
|
48272
48239
|
});
|
|
48273
48240
|
var LinkPreviewList = () => {
|
|
@@ -48275,7 +48242,7 @@ var LinkPreviewList = () => {
|
|
|
48275
48242
|
const { linkPreviewsManager } = messageComposer;
|
|
48276
48243
|
const { quotedMessage } = useStateStore(
|
|
48277
48244
|
messageComposer.state,
|
|
48278
|
-
|
|
48245
|
+
messageComposerStateSelector
|
|
48279
48246
|
);
|
|
48280
48247
|
const { linkPreviews } = useStateStore(
|
|
48281
48248
|
linkPreviewsManager.state,
|
|
@@ -48501,8 +48468,10 @@ var SuggestionList = ({
|
|
|
48501
48468
|
};
|
|
48502
48469
|
|
|
48503
48470
|
// src/components/TextareaComposer/TextareaComposer.tsx
|
|
48471
|
+
var import_lodash19 = __toESM(require("lodash.debounce"));
|
|
48504
48472
|
var import_clsx61 = __toESM(require("clsx"));
|
|
48505
|
-
var import_react240 =
|
|
48473
|
+
var import_react240 = require("react");
|
|
48474
|
+
var import_react241 = __toESM(require("react"));
|
|
48506
48475
|
var import_react_textarea_autosize = __toESM(require("react-textarea-autosize"));
|
|
48507
48476
|
var textComposerStateSelector2 = (state) => ({
|
|
48508
48477
|
selection: state.selection,
|
|
@@ -48521,33 +48490,32 @@ var TextareaComposer = ({
|
|
|
48521
48490
|
className,
|
|
48522
48491
|
closeSuggestionsOnClickOutside,
|
|
48523
48492
|
containerClassName,
|
|
48524
|
-
// dropdownClassName, // todo: X find a different way to prevent prop drilling
|
|
48525
|
-
grow: growProp,
|
|
48526
|
-
// itemClassName, // todo: X find a different way to prevent prop drilling
|
|
48527
48493
|
listClassName,
|
|
48528
48494
|
maxRows: maxRowsProp = 1,
|
|
48495
|
+
minRows: minRowsProp,
|
|
48529
48496
|
onBlur,
|
|
48530
48497
|
onChange,
|
|
48531
48498
|
onKeyDown,
|
|
48532
48499
|
onScroll,
|
|
48500
|
+
onSelect,
|
|
48533
48501
|
placeholder: placeholderProp,
|
|
48534
48502
|
shouldSubmit: shouldSubmitProp,
|
|
48535
|
-
...
|
|
48503
|
+
...restTextareaProps
|
|
48536
48504
|
}) => {
|
|
48537
48505
|
const { t } = useTranslationContext();
|
|
48538
48506
|
const { AutocompleteSuggestionList = SuggestionList } = useComponentContext();
|
|
48539
48507
|
const {
|
|
48540
48508
|
additionalTextareaProps,
|
|
48541
48509
|
cooldownRemaining,
|
|
48542
|
-
grow: growContext,
|
|
48543
48510
|
handleSubmit,
|
|
48544
48511
|
maxRows: maxRowsContext,
|
|
48512
|
+
minRows: minRowsContext,
|
|
48545
48513
|
onPaste,
|
|
48546
48514
|
shouldSubmit: shouldSubmitContext,
|
|
48547
48515
|
textareaRef
|
|
48548
48516
|
} = useMessageInputContext();
|
|
48549
|
-
const grow = growProp ?? growContext;
|
|
48550
48517
|
const maxRows = maxRowsProp ?? maxRowsContext;
|
|
48518
|
+
const minRows = minRowsProp ?? minRowsContext;
|
|
48551
48519
|
const placeholder = placeholderProp ?? additionalTextareaProps?.placeholder;
|
|
48552
48520
|
const shouldSubmit = shouldSubmitProp ?? shouldSubmitContext ?? defaultShouldSubmit;
|
|
48553
48521
|
const messageComposer = useMessageComposer();
|
|
@@ -48558,10 +48526,10 @@ var TextareaComposer = ({
|
|
|
48558
48526
|
);
|
|
48559
48527
|
const { enabled } = useStateStore(messageComposer.configState, configStateSelector);
|
|
48560
48528
|
const { isLoadingItems } = useStateStore(suggestions?.searchSource.state, searchSourceStateSelector2) ?? {};
|
|
48561
|
-
const containerRef = (0,
|
|
48562
|
-
const [focusedItemIndex, setFocusedItemIndex] = (0,
|
|
48563
|
-
const [isComposing, setIsComposing] = (0,
|
|
48564
|
-
const changeHandler = (0,
|
|
48529
|
+
const containerRef = (0, import_react241.useRef)(null);
|
|
48530
|
+
const [focusedItemIndex, setFocusedItemIndex] = (0, import_react241.useState)(0);
|
|
48531
|
+
const [isComposing, setIsComposing] = (0, import_react241.useState)(false);
|
|
48532
|
+
const changeHandler = (0, import_react241.useCallback)(
|
|
48565
48533
|
(e) => {
|
|
48566
48534
|
if (onChange) {
|
|
48567
48535
|
onChange(e);
|
|
@@ -48578,13 +48546,13 @@ var TextareaComposer = ({
|
|
|
48578
48546
|
},
|
|
48579
48547
|
[onChange, textComposer, textareaRef]
|
|
48580
48548
|
);
|
|
48581
|
-
const onCompositionEnd = (0,
|
|
48549
|
+
const onCompositionEnd = (0, import_react241.useCallback)(() => {
|
|
48582
48550
|
setIsComposing(false);
|
|
48583
48551
|
}, []);
|
|
48584
|
-
const onCompositionStart = (0,
|
|
48552
|
+
const onCompositionStart = (0, import_react241.useCallback)(() => {
|
|
48585
48553
|
setIsComposing(true);
|
|
48586
48554
|
}, []);
|
|
48587
|
-
const keyDownHandler = (0,
|
|
48555
|
+
const keyDownHandler = (0, import_react241.useCallback)(
|
|
48588
48556
|
(event) => {
|
|
48589
48557
|
if (onKeyDown) {
|
|
48590
48558
|
onKeyDown(event);
|
|
@@ -48638,7 +48606,7 @@ var TextareaComposer = ({
|
|
|
48638
48606
|
textareaRef
|
|
48639
48607
|
]
|
|
48640
48608
|
);
|
|
48641
|
-
const scrollHandler = (0,
|
|
48609
|
+
const scrollHandler = (0, import_react241.useCallback)(
|
|
48642
48610
|
(event) => {
|
|
48643
48611
|
if (onScroll) {
|
|
48644
48612
|
onScroll(event);
|
|
@@ -48648,18 +48616,32 @@ var TextareaComposer = ({
|
|
|
48648
48616
|
},
|
|
48649
48617
|
[onScroll, textComposer]
|
|
48650
48618
|
);
|
|
48651
|
-
(0, import_react240.
|
|
48619
|
+
const setSelectionDebounced = (0, import_react240.useMemo)(
|
|
48620
|
+
() => (0, import_lodash19.default)(
|
|
48621
|
+
(e) => {
|
|
48622
|
+
onSelect?.(e);
|
|
48623
|
+
textComposer.setSelection({
|
|
48624
|
+
end: e.target.selectionEnd,
|
|
48625
|
+
start: e.target.selectionStart
|
|
48626
|
+
});
|
|
48627
|
+
},
|
|
48628
|
+
100,
|
|
48629
|
+
{ leading: false, trailing: true }
|
|
48630
|
+
),
|
|
48631
|
+
[onSelect, textComposer]
|
|
48632
|
+
);
|
|
48633
|
+
(0, import_react241.useEffect)(() => {
|
|
48652
48634
|
if (textareaRef.current && !isComposing) {
|
|
48653
48635
|
textareaRef.current.selectionStart = selection.start;
|
|
48654
48636
|
textareaRef.current.selectionEnd = selection.end;
|
|
48655
48637
|
}
|
|
48656
48638
|
}, [text8, textareaRef, selection.start, selection.end, isComposing]);
|
|
48657
|
-
(0,
|
|
48639
|
+
(0, import_react241.useEffect)(() => {
|
|
48658
48640
|
if (textComposer.suggestions) {
|
|
48659
48641
|
setFocusedItemIndex(0);
|
|
48660
48642
|
}
|
|
48661
48643
|
}, [textComposer.suggestions]);
|
|
48662
|
-
return /* @__PURE__ */
|
|
48644
|
+
return /* @__PURE__ */ import_react241.default.createElement(
|
|
48663
48645
|
"div",
|
|
48664
48646
|
{
|
|
48665
48647
|
className: (0, import_clsx61.default)(
|
|
@@ -48672,10 +48654,10 @@ var TextareaComposer = ({
|
|
|
48672
48654
|
),
|
|
48673
48655
|
ref: containerRef
|
|
48674
48656
|
},
|
|
48675
|
-
/* @__PURE__ */
|
|
48657
|
+
/* @__PURE__ */ import_react241.default.createElement(
|
|
48676
48658
|
import_react_textarea_autosize.default,
|
|
48677
48659
|
{
|
|
48678
|
-
...
|
|
48660
|
+
...{ ...additionalTextareaProps, ...restTextareaProps },
|
|
48679
48661
|
"aria-label": cooldownRemaining ? t("Slow Mode ON") : placeholder,
|
|
48680
48662
|
className: (0, import_clsx61.default)(
|
|
48681
48663
|
"rta__textarea",
|
|
@@ -48684,7 +48666,8 @@ var TextareaComposer = ({
|
|
|
48684
48666
|
),
|
|
48685
48667
|
"data-testid": "message-input",
|
|
48686
48668
|
disabled: !enabled || !!cooldownRemaining,
|
|
48687
|
-
maxRows
|
|
48669
|
+
maxRows,
|
|
48670
|
+
minRows,
|
|
48688
48671
|
onBlur,
|
|
48689
48672
|
onChange: changeHandler,
|
|
48690
48673
|
onCompositionEnd,
|
|
@@ -48692,6 +48675,7 @@ var TextareaComposer = ({
|
|
|
48692
48675
|
onKeyDown: keyDownHandler,
|
|
48693
48676
|
onPaste,
|
|
48694
48677
|
onScroll: scrollHandler,
|
|
48678
|
+
onSelect: setSelectionDebounced,
|
|
48695
48679
|
placeholder: placeholder || t("Type your message"),
|
|
48696
48680
|
ref: (ref) => {
|
|
48697
48681
|
textareaRef.current = ref;
|
|
@@ -48699,7 +48683,7 @@ var TextareaComposer = ({
|
|
|
48699
48683
|
value: text8
|
|
48700
48684
|
}
|
|
48701
48685
|
),
|
|
48702
|
-
!isComposing && /* @__PURE__ */
|
|
48686
|
+
!isComposing && /* @__PURE__ */ import_react241.default.createElement(
|
|
48703
48687
|
AutocompleteSuggestionList,
|
|
48704
48688
|
{
|
|
48705
48689
|
className: listClassName,
|
|
@@ -48712,10 +48696,10 @@ var TextareaComposer = ({
|
|
|
48712
48696
|
};
|
|
48713
48697
|
|
|
48714
48698
|
// src/components/AIStateIndicator/AIStateIndicator.tsx
|
|
48715
|
-
var
|
|
48699
|
+
var import_react243 = __toESM(require("react"));
|
|
48716
48700
|
|
|
48717
48701
|
// src/components/AIStateIndicator/hooks/useAIState.ts
|
|
48718
|
-
var
|
|
48702
|
+
var import_react242 = require("react");
|
|
48719
48703
|
var AIStates = {
|
|
48720
48704
|
Error: "AI_STATE_ERROR",
|
|
48721
48705
|
ExternalSources: "AI_STATE_EXTERNAL_SOURCES",
|
|
@@ -48724,8 +48708,8 @@ var AIStates = {
|
|
|
48724
48708
|
Thinking: "AI_STATE_THINKING"
|
|
48725
48709
|
};
|
|
48726
48710
|
var useAIState = (channel) => {
|
|
48727
|
-
const [aiState, setAiState] = (0,
|
|
48728
|
-
(0,
|
|
48711
|
+
const [aiState, setAiState] = (0, import_react242.useState)(AIStates.Idle);
|
|
48712
|
+
(0, import_react242.useEffect)(() => {
|
|
48729
48713
|
if (!channel) {
|
|
48730
48714
|
return;
|
|
48731
48715
|
}
|
|
@@ -48762,21 +48746,21 @@ var AIStateIndicator = ({
|
|
|
48762
48746
|
[AIStates.Thinking]: t("Thinking..."),
|
|
48763
48747
|
[AIStates.Generating]: t("Generating...")
|
|
48764
48748
|
};
|
|
48765
|
-
return aiState in allowedStates ? /* @__PURE__ */
|
|
48749
|
+
return aiState in allowedStates ? /* @__PURE__ */ import_react243.default.createElement("div", { className: "str-chat__ai-state-indicator-container" }, /* @__PURE__ */ import_react243.default.createElement("p", { className: "str-chat__ai-state-indicator-text" }, allowedStates[aiState])) : null;
|
|
48766
48750
|
};
|
|
48767
48751
|
|
|
48768
48752
|
// src/components/MessageInput/WithDragAndDropUpload.tsx
|
|
48769
|
-
var
|
|
48753
|
+
var import_react244 = __toESM(require("react"));
|
|
48770
48754
|
var import_react_dropzone = require("react-dropzone");
|
|
48771
48755
|
var import_clsx62 = __toESM(require("clsx"));
|
|
48772
|
-
var DragAndDropUploadContext =
|
|
48756
|
+
var DragAndDropUploadContext = import_react244.default.createContext({
|
|
48773
48757
|
subscribeToDrop: null
|
|
48774
48758
|
});
|
|
48775
|
-
var useDragAndDropUploadContext = () => (0,
|
|
48759
|
+
var useDragAndDropUploadContext = () => (0, import_react244.useContext)(DragAndDropUploadContext);
|
|
48776
48760
|
var useRegisterDropHandlers = () => {
|
|
48777
48761
|
const { subscribeToDrop } = useDragAndDropUploadContext();
|
|
48778
48762
|
const messageComposer = useMessageComposer();
|
|
48779
|
-
(0,
|
|
48763
|
+
(0, import_react244.useEffect)(() => {
|
|
48780
48764
|
const unsubscribe = subscribeToDrop?.(messageComposer.attachmentManager.uploadFiles);
|
|
48781
48765
|
return unsubscribe;
|
|
48782
48766
|
}, [subscribeToDrop, messageComposer]);
|
|
@@ -48791,7 +48775,7 @@ var WithDragAndDropUpload = ({
|
|
|
48791
48775
|
component: Component2 = "div",
|
|
48792
48776
|
style
|
|
48793
48777
|
}) => {
|
|
48794
|
-
const dropHandlersRef = (0,
|
|
48778
|
+
const dropHandlersRef = (0, import_react244.useRef)(/* @__PURE__ */ new Set());
|
|
48795
48779
|
const { t } = useTranslationContext();
|
|
48796
48780
|
const messageInputContext = useMessageInputContext();
|
|
48797
48781
|
const dragAndDropUploadContext = useDragAndDropUploadContext();
|
|
@@ -48802,20 +48786,20 @@ var WithDragAndDropUpload = ({
|
|
|
48802
48786
|
attachmentManagerConfigStateSelector
|
|
48803
48787
|
);
|
|
48804
48788
|
const isWithinMessageInputContext = Object.keys(messageInputContext).length > 0;
|
|
48805
|
-
const accept = (0,
|
|
48789
|
+
const accept = (0, import_react244.useMemo)(
|
|
48806
48790
|
() => acceptedFiles.reduce((mediaTypeMap, mediaType) => {
|
|
48807
48791
|
mediaTypeMap[mediaType] ?? (mediaTypeMap[mediaType] = []);
|
|
48808
48792
|
return mediaTypeMap;
|
|
48809
48793
|
}, {}),
|
|
48810
48794
|
[acceptedFiles]
|
|
48811
48795
|
);
|
|
48812
|
-
const subscribeToDrop = (0,
|
|
48796
|
+
const subscribeToDrop = (0, import_react244.useCallback)((fn) => {
|
|
48813
48797
|
dropHandlersRef.current.add(fn);
|
|
48814
48798
|
return () => {
|
|
48815
48799
|
dropHandlersRef.current.delete(fn);
|
|
48816
48800
|
};
|
|
48817
48801
|
}, []);
|
|
48818
|
-
const handleDrop = (0,
|
|
48802
|
+
const handleDrop = (0, import_react244.useCallback)((files) => {
|
|
48819
48803
|
dropHandlersRef.current.forEach((fn) => fn(files));
|
|
48820
48804
|
}, []);
|
|
48821
48805
|
const { getRootProps, isDragActive, isDragReject } = (0, import_react_dropzone.useDropzone)({
|
|
@@ -48828,24 +48812,24 @@ var WithDragAndDropUpload = ({
|
|
|
48828
48812
|
onDrop: isWithinMessageInputContext ? messageComposer.attachmentManager.uploadFiles : handleDrop
|
|
48829
48813
|
});
|
|
48830
48814
|
if (dragAndDropUploadContext.subscribeToDrop !== null) {
|
|
48831
|
-
return /* @__PURE__ */
|
|
48815
|
+
return /* @__PURE__ */ import_react244.default.createElement(Component2, { className }, children);
|
|
48832
48816
|
}
|
|
48833
|
-
return /* @__PURE__ */
|
|
48817
|
+
return /* @__PURE__ */ import_react244.default.createElement(
|
|
48834
48818
|
DragAndDropUploadContext.Provider,
|
|
48835
48819
|
{
|
|
48836
48820
|
value: {
|
|
48837
48821
|
subscribeToDrop
|
|
48838
48822
|
}
|
|
48839
48823
|
},
|
|
48840
|
-
/* @__PURE__ */
|
|
48824
|
+
/* @__PURE__ */ import_react244.default.createElement(Component2, { ...getRootProps({ className, style }) }, isDragActive && /* @__PURE__ */ import_react244.default.createElement(
|
|
48841
48825
|
"div",
|
|
48842
48826
|
{
|
|
48843
48827
|
className: (0, import_clsx62.default)("str-chat__dropzone-container", {
|
|
48844
48828
|
"str-chat__dropzone-container--not-accepted": isDragReject
|
|
48845
48829
|
})
|
|
48846
48830
|
},
|
|
48847
|
-
!isDragReject && /* @__PURE__ */
|
|
48848
|
-
isDragReject && /* @__PURE__ */
|
|
48831
|
+
!isDragReject && /* @__PURE__ */ import_react244.default.createElement("p", null, t("Drag your files here")),
|
|
48832
|
+
isDragReject && /* @__PURE__ */ import_react244.default.createElement("p", null, t("Some of the files will not be accepted"))
|
|
48849
48833
|
), children)
|
|
48850
48834
|
);
|
|
48851
48835
|
};
|
|
@@ -48872,37 +48856,38 @@ var MessageInputFlat = () => {
|
|
|
48872
48856
|
RecordingPermissionDeniedNotification: RecordingPermissionDeniedNotification2 = RecordingPermissionDeniedNotification,
|
|
48873
48857
|
SendButton: SendButton2 = SendButton,
|
|
48874
48858
|
StartRecordingAudioButton: StartRecordingAudioButton2 = StartRecordingAudioButton,
|
|
48875
|
-
StopAIGenerationButton: StopAIGenerationButtonOverride
|
|
48876
|
-
|
|
48859
|
+
StopAIGenerationButton: StopAIGenerationButtonOverride,
|
|
48860
|
+
TextareaComposer: TextareaComposer2 = TextareaComposer
|
|
48861
|
+
} = useComponentContext();
|
|
48877
48862
|
const { channel } = useChatContext("MessageInputFlat");
|
|
48878
48863
|
const { aiState } = useAIState(channel);
|
|
48879
|
-
const stopGenerating = (0,
|
|
48864
|
+
const stopGenerating = (0, import_react245.useCallback)(() => channel?.stopAIResponse(), [channel]);
|
|
48880
48865
|
const [
|
|
48881
48866
|
showRecordingPermissionDeniedNotification,
|
|
48882
48867
|
setShowRecordingPermissionDeniedNotification
|
|
48883
|
-
] = (0,
|
|
48884
|
-
const closePermissionDeniedNotification = (0,
|
|
48868
|
+
] = (0, import_react245.useState)(false);
|
|
48869
|
+
const closePermissionDeniedNotification = (0, import_react245.useCallback)(() => {
|
|
48885
48870
|
setShowRecordingPermissionDeniedNotification(false);
|
|
48886
48871
|
}, []);
|
|
48887
48872
|
const { attachments } = useAttachmentManagerState();
|
|
48888
|
-
if (recordingController.recordingState) return /* @__PURE__ */
|
|
48873
|
+
if (recordingController.recordingState) return /* @__PURE__ */ import_react245.default.createElement(AudioRecorder2, null);
|
|
48889
48874
|
const recordingEnabled = !!(recordingController.recorder && navigator.mediaDevices);
|
|
48890
48875
|
const isRecording = !!recordingController.recordingState;
|
|
48891
48876
|
const StopAIGenerationButton2 = StopAIGenerationButtonOverride === void 0 ? StopAIGenerationButton : StopAIGenerationButtonOverride;
|
|
48892
48877
|
const shouldDisplayStopAIGeneration = [AIStates.Thinking, AIStates.Generating].includes(aiState) && !!StopAIGenerationButton2;
|
|
48893
|
-
return /* @__PURE__ */
|
|
48878
|
+
return /* @__PURE__ */ import_react245.default.createElement(WithDragAndDropUpload, { className: "str-chat__message-input", component: "div" }, recordingEnabled && recordingController.permissionState === "denied" && showRecordingPermissionDeniedNotification && /* @__PURE__ */ import_react245.default.createElement(
|
|
48894
48879
|
RecordingPermissionDeniedNotification2,
|
|
48895
48880
|
{
|
|
48896
48881
|
onClose: closePermissionDeniedNotification,
|
|
48897
48882
|
permissionName: "microphone" /* MIC */
|
|
48898
48883
|
}
|
|
48899
|
-
), /* @__PURE__ */
|
|
48884
|
+
), /* @__PURE__ */ import_react245.default.createElement(LinkPreviewList2, null), /* @__PURE__ */ import_react245.default.createElement(QuotedMessagePreviewHeader, null), /* @__PURE__ */ import_react245.default.createElement("div", { className: "str-chat__message-input-inner" }, /* @__PURE__ */ import_react245.default.createElement(AttachmentSelector2, null), /* @__PURE__ */ import_react245.default.createElement("div", { className: "str-chat__message-textarea-container" }, /* @__PURE__ */ import_react245.default.createElement(QuotedMessagePreview2, null), /* @__PURE__ */ import_react245.default.createElement(AttachmentPreviewList2, null), /* @__PURE__ */ import_react245.default.createElement("div", { className: "str-chat__message-textarea-with-emoji-picker" }, /* @__PURE__ */ import_react245.default.createElement(TextareaComposer2, null), EmojiPicker && /* @__PURE__ */ import_react245.default.createElement(EmojiPicker, null))), shouldDisplayStopAIGeneration ? /* @__PURE__ */ import_react245.default.createElement(StopAIGenerationButton2, { onClick: stopGenerating }) : !hideSendButton && /* @__PURE__ */ import_react245.default.createElement(import_react245.default.Fragment, null, cooldownRemaining ? /* @__PURE__ */ import_react245.default.createElement(
|
|
48900
48885
|
CooldownTimer2,
|
|
48901
48886
|
{
|
|
48902
48887
|
cooldownInterval: cooldownRemaining,
|
|
48903
48888
|
setCooldownRemaining
|
|
48904
48889
|
}
|
|
48905
|
-
) : /* @__PURE__ */
|
|
48890
|
+
) : /* @__PURE__ */ import_react245.default.createElement(import_react245.default.Fragment, null, /* @__PURE__ */ import_react245.default.createElement(SendButton2, { sendMessage: handleSubmit }), recordingEnabled && /* @__PURE__ */ import_react245.default.createElement(
|
|
48906
48891
|
StartRecordingAudioButton2,
|
|
48907
48892
|
{
|
|
48908
48893
|
disabled: isRecording || !asyncMessagesMultiSendEnabled && attachments.some(
|
|
@@ -48917,7 +48902,7 @@ var MessageInputFlat = () => {
|
|
|
48917
48902
|
};
|
|
48918
48903
|
|
|
48919
48904
|
// src/components/MessageInput/hooks/useCreateMessageInputContext.ts
|
|
48920
|
-
var
|
|
48905
|
+
var import_react246 = require("react");
|
|
48921
48906
|
var useCreateMessageInputContext = (value) => {
|
|
48922
48907
|
const {
|
|
48923
48908
|
additionalTextareaProps,
|
|
@@ -48928,10 +48913,8 @@ var useCreateMessageInputContext = (value) => {
|
|
|
48928
48913
|
cooldownRemaining,
|
|
48929
48914
|
emojiSearchIndex,
|
|
48930
48915
|
focus,
|
|
48931
|
-
grow,
|
|
48932
48916
|
handleSubmit,
|
|
48933
48917
|
hideSendButton,
|
|
48934
|
-
insertText,
|
|
48935
48918
|
isThreadInput,
|
|
48936
48919
|
maxRows,
|
|
48937
48920
|
minRows,
|
|
@@ -48943,7 +48926,7 @@ var useCreateMessageInputContext = (value) => {
|
|
|
48943
48926
|
textareaRef
|
|
48944
48927
|
} = value;
|
|
48945
48928
|
const parentId = parent?.id;
|
|
48946
|
-
const messageInputContext = (0,
|
|
48929
|
+
const messageInputContext = (0, import_react246.useMemo)(
|
|
48947
48930
|
() => ({
|
|
48948
48931
|
additionalTextareaProps,
|
|
48949
48932
|
asyncMessagesMultiSendEnabled,
|
|
@@ -48953,10 +48936,8 @@ var useCreateMessageInputContext = (value) => {
|
|
|
48953
48936
|
cooldownRemaining,
|
|
48954
48937
|
emojiSearchIndex,
|
|
48955
48938
|
focus,
|
|
48956
|
-
grow,
|
|
48957
48939
|
handleSubmit,
|
|
48958
48940
|
hideSendButton,
|
|
48959
|
-
insertText,
|
|
48960
48941
|
isThreadInput,
|
|
48961
48942
|
maxRows,
|
|
48962
48943
|
minRows,
|
|
@@ -48997,13 +48978,13 @@ var MessageInputProvider = (props) => {
|
|
|
48997
48978
|
emojiSearchIndex: props.emojiSearchIndex ?? emojiSearchIndex
|
|
48998
48979
|
});
|
|
48999
48980
|
const messageComposer = useMessageComposer();
|
|
49000
|
-
(0,
|
|
48981
|
+
(0, import_react247.useEffect)(
|
|
49001
48982
|
() => () => {
|
|
49002
48983
|
messageComposer.createDraft();
|
|
49003
48984
|
},
|
|
49004
48985
|
[messageComposer]
|
|
49005
48986
|
);
|
|
49006
|
-
(0,
|
|
48987
|
+
(0, import_react247.useEffect)(() => {
|
|
49007
48988
|
const threadId = messageComposer.threadId;
|
|
49008
48989
|
if (!threadId || !messageComposer.channel || !messageComposer.compositionIsEmpty)
|
|
49009
48990
|
return;
|
|
@@ -49014,16 +48995,16 @@ var MessageInputProvider = (props) => {
|
|
|
49014
48995
|
});
|
|
49015
48996
|
}, [messageComposer]);
|
|
49016
48997
|
useRegisterDropHandlers();
|
|
49017
|
-
return /* @__PURE__ */
|
|
48998
|
+
return /* @__PURE__ */ import_react247.default.createElement(MessageInputContextProvider, { value: messageInputContextValue }, props.children);
|
|
49018
48999
|
};
|
|
49019
49000
|
var UnMemoizedMessageInput = (props) => {
|
|
49020
49001
|
const { Input: PropInput } = props;
|
|
49021
49002
|
const { Input: ContextInput } = useComponentContext("MessageInput");
|
|
49022
49003
|
const Input3 = PropInput || ContextInput || MessageInputFlat;
|
|
49023
49004
|
const dialogManagerId = props.isThreadInput ? "message-input-dialog-manager-thread" : "message-input-dialog-manager";
|
|
49024
|
-
return /* @__PURE__ */
|
|
49005
|
+
return /* @__PURE__ */ import_react247.default.createElement(DialogManagerProvider, { id: dialogManagerId }, /* @__PURE__ */ import_react247.default.createElement(MessageInputProvider, { ...props }, /* @__PURE__ */ import_react247.default.createElement(Input3, null)));
|
|
49025
49006
|
};
|
|
49026
|
-
var MessageInput =
|
|
49007
|
+
var MessageInput = import_react247.default.memo(
|
|
49027
49008
|
UnMemoizedMessageInput
|
|
49028
49009
|
);
|
|
49029
49010
|
|
|
@@ -49031,7 +49012,7 @@ var MessageInput = import_react246.default.memo(
|
|
|
49031
49012
|
var EditMessageFormSendButton = () => {
|
|
49032
49013
|
const { t } = useTranslationContext();
|
|
49033
49014
|
const hasSendableData = useMessageComposerHasSendableData();
|
|
49034
|
-
return /* @__PURE__ */
|
|
49015
|
+
return /* @__PURE__ */ import_react248.default.createElement(
|
|
49035
49016
|
"button",
|
|
49036
49017
|
{
|
|
49037
49018
|
className: "str-chat__edit-message-send",
|
|
@@ -49046,26 +49027,26 @@ var EditMessageForm = () => {
|
|
|
49046
49027
|
const { t } = useTranslationContext("EditMessageForm");
|
|
49047
49028
|
const messageComposer = useMessageComposer();
|
|
49048
49029
|
const { clearEditingState, handleSubmit } = useMessageInputContext("EditMessageForm");
|
|
49049
|
-
const cancel = (0,
|
|
49030
|
+
const cancel = (0, import_react248.useCallback)(() => {
|
|
49050
49031
|
clearEditingState?.();
|
|
49051
49032
|
messageComposer.restore();
|
|
49052
49033
|
}, [clearEditingState, messageComposer]);
|
|
49053
|
-
(0,
|
|
49034
|
+
(0, import_react248.useEffect)(() => {
|
|
49054
49035
|
const onKeyDown = (event) => {
|
|
49055
49036
|
if (event.key === "Escape") cancel();
|
|
49056
49037
|
};
|
|
49057
49038
|
document.addEventListener("keydown", onKeyDown);
|
|
49058
49039
|
return () => document.removeEventListener("keydown", onKeyDown);
|
|
49059
49040
|
}, [cancel]);
|
|
49060
|
-
return /* @__PURE__ */
|
|
49041
|
+
return /* @__PURE__ */ import_react248.default.createElement(
|
|
49061
49042
|
"form",
|
|
49062
49043
|
{
|
|
49063
49044
|
autoComplete: "off",
|
|
49064
49045
|
className: "str-chat__edit-message-form",
|
|
49065
49046
|
onSubmit: handleSubmit
|
|
49066
49047
|
},
|
|
49067
|
-
/* @__PURE__ */
|
|
49068
|
-
/* @__PURE__ */
|
|
49048
|
+
/* @__PURE__ */ import_react248.default.createElement(MessageInputFlat, null),
|
|
49049
|
+
/* @__PURE__ */ import_react248.default.createElement("div", { className: "str-chat__edit-message-form-options" }, /* @__PURE__ */ import_react248.default.createElement(
|
|
49069
49050
|
"button",
|
|
49070
49051
|
{
|
|
49071
49052
|
className: "str-chat__edit-message-cancel",
|
|
@@ -49073,7 +49054,7 @@ var EditMessageForm = () => {
|
|
|
49073
49054
|
onClick: cancel
|
|
49074
49055
|
},
|
|
49075
49056
|
t("Cancel")
|
|
49076
|
-
), /* @__PURE__ */
|
|
49057
|
+
), /* @__PURE__ */ import_react248.default.createElement(EditMessageFormSendButton, null))
|
|
49077
49058
|
);
|
|
49078
49059
|
};
|
|
49079
49060
|
var EditMessageModal = ({
|
|
@@ -49082,22 +49063,21 @@ var EditMessageModal = ({
|
|
|
49082
49063
|
const { EditMessageInput = EditMessageForm } = useComponentContext();
|
|
49083
49064
|
const { clearEditingState } = useMessageContext();
|
|
49084
49065
|
const messageComposer = useMessageComposer();
|
|
49085
|
-
const onEditModalClose = (0,
|
|
49066
|
+
const onEditModalClose = (0, import_react248.useCallback)(() => {
|
|
49086
49067
|
clearEditingState();
|
|
49087
49068
|
messageComposer.restore();
|
|
49088
49069
|
}, [clearEditingState, messageComposer]);
|
|
49089
|
-
return /* @__PURE__ */
|
|
49070
|
+
return /* @__PURE__ */ import_react248.default.createElement(
|
|
49090
49071
|
Modal,
|
|
49091
49072
|
{
|
|
49092
49073
|
className: "str-chat__edit-message-modal",
|
|
49093
49074
|
onClose: onEditModalClose,
|
|
49094
49075
|
open: true
|
|
49095
49076
|
},
|
|
49096
|
-
/* @__PURE__ */
|
|
49077
|
+
/* @__PURE__ */ import_react248.default.createElement(
|
|
49097
49078
|
MessageInput,
|
|
49098
49079
|
{
|
|
49099
49080
|
clearEditingState,
|
|
49100
|
-
grow: true,
|
|
49101
49081
|
hideSendButton: true,
|
|
49102
49082
|
Input: EditMessageInput,
|
|
49103
49083
|
...additionalMessageInputProps
|
|
@@ -49111,12 +49091,12 @@ var attachmentManagerConfigStateSelector2 = (state) => ({
|
|
|
49111
49091
|
acceptedFiles: state.attachments.acceptedFiles,
|
|
49112
49092
|
maxNumberOfFilesPerMessage: state.attachments.maxNumberOfFilesPerMessage
|
|
49113
49093
|
});
|
|
49114
|
-
var UploadButton = (0,
|
|
49094
|
+
var UploadButton = (0, import_react249.forwardRef)(function UploadButton2({ onFileChange, resetOnChange = true, ...rest }, ref) {
|
|
49115
49095
|
const handleInputChange = useHandleFileChangeWrapper(resetOnChange, onFileChange);
|
|
49116
|
-
return /* @__PURE__ */
|
|
49096
|
+
return /* @__PURE__ */ import_react249.default.createElement("input", { onChange: handleInputChange, ref, type: "file", ...rest });
|
|
49117
49097
|
});
|
|
49118
49098
|
var FileInput = UploadButton;
|
|
49119
|
-
var UploadFileInput = (0,
|
|
49099
|
+
var UploadFileInput = (0, import_react249.forwardRef)(function UploadFileInput2({
|
|
49120
49100
|
className,
|
|
49121
49101
|
onFileChange: onFileChangeCustom,
|
|
49122
49102
|
...props
|
|
@@ -49130,15 +49110,15 @@ var UploadFileInput = (0, import_react248.forwardRef)(function UploadFileInput2(
|
|
|
49130
49110
|
messageComposer.configState,
|
|
49131
49111
|
attachmentManagerConfigStateSelector2
|
|
49132
49112
|
);
|
|
49133
|
-
const id = (0,
|
|
49134
|
-
const onFileChange = (0,
|
|
49113
|
+
const id = (0, import_react249.useMemo)(() => (0, import_nanoid5.nanoid)(), []);
|
|
49114
|
+
const onFileChange = (0, import_react249.useCallback)(
|
|
49135
49115
|
(files) => {
|
|
49136
49116
|
attachmentManager.uploadFiles(files);
|
|
49137
49117
|
onFileChangeCustom?.(files);
|
|
49138
49118
|
},
|
|
49139
49119
|
[onFileChangeCustom, attachmentManager]
|
|
49140
49120
|
);
|
|
49141
|
-
return /* @__PURE__ */
|
|
49121
|
+
return /* @__PURE__ */ import_react249.default.createElement(
|
|
49142
49122
|
FileInput,
|
|
49143
49123
|
{
|
|
49144
49124
|
accept: acceptedFiles?.join(","),
|
|
@@ -49185,7 +49165,7 @@ var VoiceRecordingPlayer = ({
|
|
|
49185
49165
|
});
|
|
49186
49166
|
if (!asset_url) return null;
|
|
49187
49167
|
const displayedDuration = secondsElapsed || duration;
|
|
49188
|
-
return /* @__PURE__ */
|
|
49168
|
+
return /* @__PURE__ */ import_react250.default.createElement("div", { className: rootClassName, "data-testid": "voice-recording-widget" }, /* @__PURE__ */ import_react250.default.createElement("audio", { ref: audioRef }, /* @__PURE__ */ import_react250.default.createElement("source", { "data-testid": "audio-source", src: asset_url, type: mime_type })), /* @__PURE__ */ import_react250.default.createElement(PlayButton, { isPlaying, onClick: togglePlay }), /* @__PURE__ */ import_react250.default.createElement("div", { className: "str-chat__message-attachment__voice-recording-widget__metadata" }, /* @__PURE__ */ import_react250.default.createElement(
|
|
49189
49169
|
"div",
|
|
49190
49170
|
{
|
|
49191
49171
|
className: "str-chat__message-attachment__voice-recording-widget__title",
|
|
@@ -49193,25 +49173,25 @@ var VoiceRecordingPlayer = ({
|
|
|
49193
49173
|
title
|
|
49194
49174
|
},
|
|
49195
49175
|
title
|
|
49196
|
-
), /* @__PURE__ */
|
|
49176
|
+
), /* @__PURE__ */ import_react250.default.createElement("div", { className: "str-chat__message-attachment__voice-recording-widget__audio-state" }, /* @__PURE__ */ import_react250.default.createElement("div", { className: "str-chat__message-attachment__voice-recording-widget__timer" }, attachment.duration ? displayDuration(displayedDuration) : /* @__PURE__ */ import_react250.default.createElement(
|
|
49197
49177
|
FileSizeIndicator,
|
|
49198
49178
|
{
|
|
49199
49179
|
fileSize: attachment.file_size,
|
|
49200
49180
|
maximumFractionDigits: 0
|
|
49201
49181
|
}
|
|
49202
|
-
)), /* @__PURE__ */
|
|
49182
|
+
)), /* @__PURE__ */ import_react250.default.createElement(
|
|
49203
49183
|
WaveProgressBar,
|
|
49204
49184
|
{
|
|
49205
49185
|
progress,
|
|
49206
49186
|
seek,
|
|
49207
49187
|
waveformData: waveform_data || []
|
|
49208
49188
|
}
|
|
49209
|
-
))), /* @__PURE__ */
|
|
49189
|
+
))), /* @__PURE__ */ import_react250.default.createElement("div", { className: "str-chat__message-attachment__voice-recording-widget__right-section" }, isPlaying ? /* @__PURE__ */ import_react250.default.createElement(PlaybackRateButton, { disabled: !audioRef.current, onClick: increasePlaybackRate }, playbackRate.toFixed(1), "x") : /* @__PURE__ */ import_react250.default.createElement(FileIcon, { big: true, mimeType: mime_type, size: 40 })));
|
|
49210
49190
|
};
|
|
49211
49191
|
var QuotedVoiceRecording = ({ attachment }) => {
|
|
49212
49192
|
const { t } = useTranslationContext();
|
|
49213
49193
|
const title = attachment.title || t("Voice message");
|
|
49214
|
-
return /* @__PURE__ */
|
|
49194
|
+
return /* @__PURE__ */ import_react250.default.createElement("div", { className: rootClassName, "data-testid": "quoted-voice-recording-widget" }, /* @__PURE__ */ import_react250.default.createElement("div", { className: "str-chat__message-attachment__voice-recording-widget__metadata" }, title && /* @__PURE__ */ import_react250.default.createElement(
|
|
49215
49195
|
"div",
|
|
49216
49196
|
{
|
|
49217
49197
|
className: "str-chat__message-attachment__voice-recording-widget__title",
|
|
@@ -49219,18 +49199,18 @@ var QuotedVoiceRecording = ({ attachment }) => {
|
|
|
49219
49199
|
title
|
|
49220
49200
|
},
|
|
49221
49201
|
title
|
|
49222
|
-
), /* @__PURE__ */
|
|
49202
|
+
), /* @__PURE__ */ import_react250.default.createElement("div", { className: "str-chat__message-attachment__voice-recording-widget__audio-state" }, /* @__PURE__ */ import_react250.default.createElement("div", { className: "str-chat__message-attachment__voice-recording-widget__timer" }, attachment.duration ? displayDuration(attachment.duration) : /* @__PURE__ */ import_react250.default.createElement(
|
|
49223
49203
|
FileSizeIndicator,
|
|
49224
49204
|
{
|
|
49225
49205
|
fileSize: attachment.file_size,
|
|
49226
49206
|
maximumFractionDigits: 0
|
|
49227
49207
|
}
|
|
49228
|
-
)))), /* @__PURE__ */
|
|
49208
|
+
)))), /* @__PURE__ */ import_react250.default.createElement(FileIcon, { big: true, mimeType: attachment.mime_type, size: 34 }));
|
|
49229
49209
|
};
|
|
49230
|
-
var VoiceRecording = ({ attachment, isQuoted }) => isQuoted ? /* @__PURE__ */
|
|
49210
|
+
var VoiceRecording = ({ attachment, isQuoted }) => isQuoted ? /* @__PURE__ */ import_react250.default.createElement(QuotedVoiceRecording, { attachment }) : /* @__PURE__ */ import_react250.default.createElement(VoiceRecordingPlayer, { attachment });
|
|
49231
49211
|
|
|
49232
49212
|
// src/components/Attachment/Card.tsx
|
|
49233
|
-
var
|
|
49213
|
+
var import_react251 = __toESM(require("react"));
|
|
49234
49214
|
var import_clsx64 = __toESM(require("clsx"));
|
|
49235
49215
|
var import_react_player = __toESM(require("react-player"));
|
|
49236
49216
|
var getHostFromURL = (url) => {
|
|
@@ -49242,26 +49222,26 @@ var getHostFromURL = (url) => {
|
|
|
49242
49222
|
};
|
|
49243
49223
|
var UnableToRenderCard = ({ type }) => {
|
|
49244
49224
|
const { t } = useTranslationContext("Card");
|
|
49245
|
-
return /* @__PURE__ */
|
|
49225
|
+
return /* @__PURE__ */ import_react251.default.createElement(
|
|
49246
49226
|
"div",
|
|
49247
49227
|
{
|
|
49248
49228
|
className: (0, import_clsx64.default)("str-chat__message-attachment-card", {
|
|
49249
49229
|
[`str-chat__message-attachment-card--${type}`]: type
|
|
49250
49230
|
})
|
|
49251
49231
|
},
|
|
49252
|
-
/* @__PURE__ */
|
|
49232
|
+
/* @__PURE__ */ import_react251.default.createElement("div", { className: "str-chat__message-attachment-card--content" }, /* @__PURE__ */ import_react251.default.createElement("div", { className: "str-chat__message-attachment-card--text" }, t("this content could not be displayed")))
|
|
49253
49233
|
);
|
|
49254
49234
|
};
|
|
49255
49235
|
var SourceLink = ({
|
|
49256
49236
|
author_name,
|
|
49257
49237
|
url
|
|
49258
|
-
}) => /* @__PURE__ */
|
|
49238
|
+
}) => /* @__PURE__ */ import_react251.default.createElement(
|
|
49259
49239
|
"div",
|
|
49260
49240
|
{
|
|
49261
49241
|
className: "str-chat__message-attachment-card--source-link",
|
|
49262
49242
|
"data-testid": "card-source-link"
|
|
49263
49243
|
},
|
|
49264
|
-
/* @__PURE__ */
|
|
49244
|
+
/* @__PURE__ */ import_react251.default.createElement(
|
|
49265
49245
|
SafeAnchor,
|
|
49266
49246
|
{
|
|
49267
49247
|
className: "str-chat__message-attachment-card--url",
|
|
@@ -49276,7 +49256,7 @@ var CardHeader3 = (props) => {
|
|
|
49276
49256
|
const { asset_url, dimensions, image: image4, image_url, thumb_url, title, type } = props;
|
|
49277
49257
|
let visual = null;
|
|
49278
49258
|
if (asset_url && type === "video") {
|
|
49279
|
-
visual = /* @__PURE__ */
|
|
49259
|
+
visual = /* @__PURE__ */ import_react251.default.createElement(
|
|
49280
49260
|
import_react_player.default,
|
|
49281
49261
|
{
|
|
49282
49262
|
className: "react-player",
|
|
@@ -49287,7 +49267,7 @@ var CardHeader3 = (props) => {
|
|
|
49287
49267
|
}
|
|
49288
49268
|
);
|
|
49289
49269
|
} else if (image4) {
|
|
49290
|
-
visual = /* @__PURE__ */
|
|
49270
|
+
visual = /* @__PURE__ */ import_react251.default.createElement(
|
|
49291
49271
|
ImageComponent,
|
|
49292
49272
|
{
|
|
49293
49273
|
dimensions,
|
|
@@ -49297,7 +49277,7 @@ var CardHeader3 = (props) => {
|
|
|
49297
49277
|
}
|
|
49298
49278
|
);
|
|
49299
49279
|
}
|
|
49300
|
-
return visual ? /* @__PURE__ */
|
|
49280
|
+
return visual ? /* @__PURE__ */ import_react251.default.createElement(
|
|
49301
49281
|
"div",
|
|
49302
49282
|
{
|
|
49303
49283
|
className: "str-chat__message-attachment-card--header str-chat__message-attachment-card-react--header",
|
|
@@ -49309,7 +49289,7 @@ var CardHeader3 = (props) => {
|
|
|
49309
49289
|
var CardContent = (props) => {
|
|
49310
49290
|
const { author_name, og_scrape_url, text: text8, title, title_link, type } = props;
|
|
49311
49291
|
const url = title_link || og_scrape_url;
|
|
49312
|
-
return /* @__PURE__ */
|
|
49292
|
+
return /* @__PURE__ */ import_react251.default.createElement("div", { className: "str-chat__message-attachment-card--content" }, type === "audio" ? /* @__PURE__ */ import_react251.default.createElement(CardAudio, { og: props }) : /* @__PURE__ */ import_react251.default.createElement("div", { className: "str-chat__message-attachment-card--flex" }, url && /* @__PURE__ */ import_react251.default.createElement(SourceLink, { author_name, url }), title && /* @__PURE__ */ import_react251.default.createElement("div", { className: "str-chat__message-attachment-card--title" }, title), text8 && /* @__PURE__ */ import_react251.default.createElement("div", { className: "str-chat__message-attachment-card--text" }, text8)));
|
|
49313
49293
|
};
|
|
49314
49294
|
var CardAudio = ({
|
|
49315
49295
|
og: { asset_url, author_name, mime_type, og_scrape_url, text: text8, title, title_link }
|
|
@@ -49320,7 +49300,7 @@ var CardAudio = ({
|
|
|
49320
49300
|
const url = title_link || og_scrape_url;
|
|
49321
49301
|
const dataTestId = "card-audio-widget";
|
|
49322
49302
|
const rootClassName2 = "str-chat__message-attachment-card-audio-widget";
|
|
49323
|
-
return /* @__PURE__ */
|
|
49303
|
+
return /* @__PURE__ */ import_react251.default.createElement("div", { className: rootClassName2, "data-testid": dataTestId }, asset_url && /* @__PURE__ */ import_react251.default.createElement(import_react251.default.Fragment, null, /* @__PURE__ */ import_react251.default.createElement("audio", { ref: audioRef }, /* @__PURE__ */ import_react251.default.createElement("source", { "data-testid": "audio-source", src: asset_url, type: "audio/mp3" })), /* @__PURE__ */ import_react251.default.createElement("div", { className: "str-chat__message-attachment-card-audio-widget--first-row" }, /* @__PURE__ */ import_react251.default.createElement("div", { className: "str-chat__message-attachment-audio-widget--play-controls" }, /* @__PURE__ */ import_react251.default.createElement(PlayButton, { isPlaying, onClick: togglePlay })), /* @__PURE__ */ import_react251.default.createElement(ProgressBar, { onClick: seek, progress }))), /* @__PURE__ */ import_react251.default.createElement("div", { className: "str-chat__message-attachment-audio-widget--second-row" }, url && /* @__PURE__ */ import_react251.default.createElement(SourceLink, { author_name, url }), title && /* @__PURE__ */ import_react251.default.createElement("div", { className: "str-chat__message-attachment-audio-widget--title" }, title), text8 && /* @__PURE__ */ import_react251.default.createElement("div", { className: "str-chat__message-attachment-audio-widget--description" }, text8)));
|
|
49324
49304
|
};
|
|
49325
49305
|
var UnMemoizedCard = (props) => {
|
|
49326
49306
|
const { asset_url, giphy, image_url, thumb_url, title, title_link, type } = props;
|
|
@@ -49334,45 +49314,45 @@ var UnMemoizedCard = (props) => {
|
|
|
49334
49314
|
dimensions.width = giphyVersion.width;
|
|
49335
49315
|
}
|
|
49336
49316
|
if (!title && !title_link && !asset_url && !image4) {
|
|
49337
|
-
return /* @__PURE__ */
|
|
49317
|
+
return /* @__PURE__ */ import_react251.default.createElement(UnableToRenderCard, null);
|
|
49338
49318
|
}
|
|
49339
|
-
return /* @__PURE__ */
|
|
49319
|
+
return /* @__PURE__ */ import_react251.default.createElement(
|
|
49340
49320
|
"div",
|
|
49341
49321
|
{
|
|
49342
49322
|
className: `str-chat__message-attachment-card str-chat__message-attachment-card--${type}`
|
|
49343
49323
|
},
|
|
49344
|
-
/* @__PURE__ */
|
|
49345
|
-
/* @__PURE__ */
|
|
49324
|
+
/* @__PURE__ */ import_react251.default.createElement(CardHeader3, { ...props, dimensions, image: image4 }),
|
|
49325
|
+
/* @__PURE__ */ import_react251.default.createElement(CardContent, { ...props })
|
|
49346
49326
|
);
|
|
49347
49327
|
};
|
|
49348
|
-
var Card3 =
|
|
49328
|
+
var Card3 = import_react251.default.memo(UnMemoizedCard);
|
|
49349
49329
|
|
|
49350
49330
|
// src/components/Attachment/FileAttachment.tsx
|
|
49351
|
-
var
|
|
49352
|
-
var UnMemoizedFileAttachment = ({ attachment }) => /* @__PURE__ */
|
|
49331
|
+
var import_react252 = __toESM(require("react"));
|
|
49332
|
+
var UnMemoizedFileAttachment = ({ attachment }) => /* @__PURE__ */ import_react252.default.createElement("div", { className: "str-chat__message-attachment-file--item", "data-testid": "attachment-file" }, /* @__PURE__ */ import_react252.default.createElement(FileIcon, { className: "str-chat__file-icon", mimeType: attachment.mime_type }), /* @__PURE__ */ import_react252.default.createElement("div", { className: "str-chat__message-attachment-file--item-text" }, /* @__PURE__ */ import_react252.default.createElement("div", { className: "str-chat__message-attachment-file--item-first-row" }, /* @__PURE__ */ import_react252.default.createElement(
|
|
49353
49333
|
"div",
|
|
49354
49334
|
{
|
|
49355
49335
|
className: "str-chat__message-attachment-file--item-name",
|
|
49356
49336
|
"data-testid": "file-title"
|
|
49357
49337
|
},
|
|
49358
49338
|
attachment.title
|
|
49359
|
-
), /* @__PURE__ */
|
|
49360
|
-
var FileAttachment =
|
|
49339
|
+
), /* @__PURE__ */ import_react252.default.createElement(DownloadButton, { assetUrl: attachment.asset_url })), /* @__PURE__ */ import_react252.default.createElement(FileSizeIndicator, { fileSize: attachment.file_size })));
|
|
49340
|
+
var FileAttachment = import_react252.default.memo(
|
|
49361
49341
|
UnMemoizedFileAttachment
|
|
49362
49342
|
);
|
|
49363
49343
|
|
|
49364
49344
|
// src/components/Attachment/UnsupportedAttachment.tsx
|
|
49365
|
-
var
|
|
49345
|
+
var import_react253 = __toESM(require("react"));
|
|
49366
49346
|
var UnsupportedAttachment = ({ attachment }) => {
|
|
49367
49347
|
const { t } = useTranslationContext("UnsupportedAttachment");
|
|
49368
|
-
return /* @__PURE__ */
|
|
49348
|
+
return /* @__PURE__ */ import_react253.default.createElement(
|
|
49369
49349
|
"div",
|
|
49370
49350
|
{
|
|
49371
49351
|
className: "str-chat__message-attachment-unsupported",
|
|
49372
49352
|
"data-testid": "attachment-unsupported"
|
|
49373
49353
|
},
|
|
49374
|
-
/* @__PURE__ */
|
|
49375
|
-
/* @__PURE__ */
|
|
49354
|
+
/* @__PURE__ */ import_react253.default.createElement(FileIcon, { className: "str-chat__file-icon" }),
|
|
49355
|
+
/* @__PURE__ */ import_react253.default.createElement("div", { className: "str-chat__message-attachment-unsupported__metadata" }, /* @__PURE__ */ import_react253.default.createElement(
|
|
49376
49356
|
"div",
|
|
49377
49357
|
{
|
|
49378
49358
|
className: "str-chat__message-attachment-unsupported__title",
|
|
@@ -49404,7 +49384,7 @@ var AttachmentWithinContainer = ({
|
|
|
49404
49384
|
"str-chat__message-attachment-with-actions": extra === "actions"
|
|
49405
49385
|
}
|
|
49406
49386
|
);
|
|
49407
|
-
return /* @__PURE__ */
|
|
49387
|
+
return /* @__PURE__ */ import_react254.default.createElement("div", { className: classNames }, children);
|
|
49408
49388
|
};
|
|
49409
49389
|
var AttachmentActionsContainer = ({
|
|
49410
49390
|
actionHandler,
|
|
@@ -49412,7 +49392,7 @@ var AttachmentActionsContainer = ({
|
|
|
49412
49392
|
AttachmentActions: AttachmentActions2 = AttachmentActions
|
|
49413
49393
|
}) => {
|
|
49414
49394
|
if (!attachment.actions?.length) return null;
|
|
49415
|
-
return /* @__PURE__ */
|
|
49395
|
+
return /* @__PURE__ */ import_react254.default.createElement(
|
|
49416
49396
|
AttachmentActions2,
|
|
49417
49397
|
{
|
|
49418
49398
|
...attachment,
|
|
@@ -49443,10 +49423,10 @@ var GalleryContainer = ({
|
|
|
49443
49423
|
attachment,
|
|
49444
49424
|
Gallery: Gallery2 = Gallery
|
|
49445
49425
|
}) => {
|
|
49446
|
-
const imageElements = (0,
|
|
49426
|
+
const imageElements = (0, import_react254.useRef)([]);
|
|
49447
49427
|
const { imageAttachmentSizeHandler } = useChannelStateContext();
|
|
49448
|
-
const [attachmentConfigurations, setAttachmentConfigurations] = (0,
|
|
49449
|
-
(0,
|
|
49428
|
+
const [attachmentConfigurations, setAttachmentConfigurations] = (0, import_react254.useState)([]);
|
|
49429
|
+
(0, import_react254.useLayoutEffect)(() => {
|
|
49450
49430
|
if (imageElements.current && imageElements.current.every((element4) => !!element4) && imageAttachmentSizeHandler) {
|
|
49451
49431
|
const newConfigurations = [];
|
|
49452
49432
|
imageElements.current.forEach((element4, i) => {
|
|
@@ -49463,15 +49443,15 @@ var GalleryContainer = ({
|
|
|
49463
49443
|
attachment.images[i]?.image_url || attachment.images[i]?.thumb_url || ""
|
|
49464
49444
|
)
|
|
49465
49445
|
}));
|
|
49466
|
-
return /* @__PURE__ */
|
|
49446
|
+
return /* @__PURE__ */ import_react254.default.createElement(AttachmentWithinContainer, { attachment, componentType: "gallery" }, /* @__PURE__ */ import_react254.default.createElement(Gallery2, { images: images || [], innerRefs: imageElements, key: "gallery" }));
|
|
49467
49447
|
};
|
|
49468
49448
|
var ImageContainer = (props) => {
|
|
49469
49449
|
const { attachment, Image: Image4 = ImageComponent } = props;
|
|
49470
49450
|
const componentType = "image";
|
|
49471
|
-
const imageElement = (0,
|
|
49451
|
+
const imageElement = (0, import_react254.useRef)(null);
|
|
49472
49452
|
const { imageAttachmentSizeHandler } = useChannelStateContext();
|
|
49473
|
-
const [attachmentConfiguration, setAttachmentConfiguration] = (0,
|
|
49474
|
-
(0,
|
|
49453
|
+
const [attachmentConfiguration, setAttachmentConfiguration] = (0, import_react254.useState)(void 0);
|
|
49454
|
+
(0, import_react254.useLayoutEffect)(() => {
|
|
49475
49455
|
if (imageElement.current && imageAttachmentSizeHandler) {
|
|
49476
49456
|
const config = imageAttachmentSizeHandler(attachment, imageElement.current);
|
|
49477
49457
|
setAttachmentConfiguration(config);
|
|
@@ -49483,41 +49463,41 @@ var ImageContainer = (props) => {
|
|
|
49483
49463
|
style: getCssDimensionsVariables(attachment.image_url || attachment.thumb_url || "")
|
|
49484
49464
|
};
|
|
49485
49465
|
if (attachment.actions && attachment.actions.length) {
|
|
49486
|
-
return /* @__PURE__ */
|
|
49466
|
+
return /* @__PURE__ */ import_react254.default.createElement(AttachmentWithinContainer, { attachment, componentType }, /* @__PURE__ */ import_react254.default.createElement("div", { className: "str-chat__attachment" }, /* @__PURE__ */ import_react254.default.createElement(Image4, { ...imageConfig, innerRef: imageElement }), /* @__PURE__ */ import_react254.default.createElement(AttachmentActionsContainer, { ...props })));
|
|
49487
49467
|
}
|
|
49488
|
-
return /* @__PURE__ */
|
|
49468
|
+
return /* @__PURE__ */ import_react254.default.createElement(AttachmentWithinContainer, { attachment, componentType }, /* @__PURE__ */ import_react254.default.createElement(Image4, { ...imageConfig, innerRef: imageElement }));
|
|
49489
49469
|
};
|
|
49490
49470
|
var CardContainer = (props) => {
|
|
49491
49471
|
const { attachment, Card: Card4 = Card3 } = props;
|
|
49492
49472
|
const componentType = "card";
|
|
49493
49473
|
if (attachment.actions && attachment.actions.length) {
|
|
49494
|
-
return /* @__PURE__ */
|
|
49474
|
+
return /* @__PURE__ */ import_react254.default.createElement(AttachmentWithinContainer, { attachment, componentType }, /* @__PURE__ */ import_react254.default.createElement("div", { className: "str-chat__attachment" }, /* @__PURE__ */ import_react254.default.createElement(Card4, { ...attachment }), /* @__PURE__ */ import_react254.default.createElement(AttachmentActionsContainer, { ...props })));
|
|
49495
49475
|
}
|
|
49496
|
-
return /* @__PURE__ */
|
|
49476
|
+
return /* @__PURE__ */ import_react254.default.createElement(AttachmentWithinContainer, { attachment, componentType }, /* @__PURE__ */ import_react254.default.createElement(Card4, { ...attachment }));
|
|
49497
49477
|
};
|
|
49498
49478
|
var FileContainer = ({
|
|
49499
49479
|
attachment,
|
|
49500
49480
|
File: File2 = FileAttachment
|
|
49501
49481
|
}) => {
|
|
49502
49482
|
if (!attachment.asset_url) return null;
|
|
49503
|
-
return /* @__PURE__ */
|
|
49483
|
+
return /* @__PURE__ */ import_react254.default.createElement(AttachmentWithinContainer, { attachment, componentType: "file" }, /* @__PURE__ */ import_react254.default.createElement(File2, { attachment }));
|
|
49504
49484
|
};
|
|
49505
49485
|
var AudioContainer = ({
|
|
49506
49486
|
attachment,
|
|
49507
49487
|
Audio: Audio2 = Audio
|
|
49508
|
-
}) => /* @__PURE__ */
|
|
49488
|
+
}) => /* @__PURE__ */ import_react254.default.createElement(AttachmentWithinContainer, { attachment, componentType: "audio" }, /* @__PURE__ */ import_react254.default.createElement("div", { className: "str-chat__attachment" }, /* @__PURE__ */ import_react254.default.createElement(Audio2, { og: attachment })));
|
|
49509
49489
|
var VoiceRecordingContainer = ({
|
|
49510
49490
|
attachment,
|
|
49511
49491
|
isQuoted,
|
|
49512
49492
|
VoiceRecording: VoiceRecording2 = VoiceRecording
|
|
49513
|
-
}) => /* @__PURE__ */
|
|
49493
|
+
}) => /* @__PURE__ */ import_react254.default.createElement(AttachmentWithinContainer, { attachment, componentType: "voiceRecording" }, /* @__PURE__ */ import_react254.default.createElement("div", { className: "str-chat__attachment" }, /* @__PURE__ */ import_react254.default.createElement(VoiceRecording2, { attachment, isQuoted })));
|
|
49514
49494
|
var MediaContainer = (props) => {
|
|
49515
49495
|
const { attachment, Media = import_react_player2.default } = props;
|
|
49516
49496
|
const componentType = "media";
|
|
49517
49497
|
const { shouldGenerateVideoThumbnail, videoAttachmentSizeHandler } = useChannelStateContext();
|
|
49518
|
-
const videoElement = (0,
|
|
49519
|
-
const [attachmentConfiguration, setAttachmentConfiguration] = (0,
|
|
49520
|
-
(0,
|
|
49498
|
+
const videoElement = (0, import_react254.useRef)(null);
|
|
49499
|
+
const [attachmentConfiguration, setAttachmentConfiguration] = (0, import_react254.useState)();
|
|
49500
|
+
(0, import_react254.useLayoutEffect)(() => {
|
|
49521
49501
|
if (videoElement.current && videoAttachmentSizeHandler) {
|
|
49522
49502
|
const config = videoAttachmentSizeHandler(
|
|
49523
49503
|
attachment,
|
|
@@ -49527,7 +49507,7 @@ var MediaContainer = (props) => {
|
|
|
49527
49507
|
setAttachmentConfiguration(config);
|
|
49528
49508
|
}
|
|
49529
49509
|
}, [videoElement, videoAttachmentSizeHandler, attachment]);
|
|
49530
|
-
const content3 = /* @__PURE__ */
|
|
49510
|
+
const content3 = /* @__PURE__ */ import_react254.default.createElement(
|
|
49531
49511
|
"div",
|
|
49532
49512
|
{
|
|
49533
49513
|
className: "str-chat__player-wrapper",
|
|
@@ -49535,7 +49515,7 @@ var MediaContainer = (props) => {
|
|
|
49535
49515
|
ref: videoElement,
|
|
49536
49516
|
style: getCssDimensionsVariables(attachment.thumb_url || "")
|
|
49537
49517
|
},
|
|
49538
|
-
/* @__PURE__ */
|
|
49518
|
+
/* @__PURE__ */ import_react254.default.createElement(
|
|
49539
49519
|
Media,
|
|
49540
49520
|
{
|
|
49541
49521
|
className: "react-player",
|
|
@@ -49547,12 +49527,12 @@ var MediaContainer = (props) => {
|
|
|
49547
49527
|
}
|
|
49548
49528
|
)
|
|
49549
49529
|
);
|
|
49550
|
-
return attachment.actions?.length ? /* @__PURE__ */
|
|
49530
|
+
return attachment.actions?.length ? /* @__PURE__ */ import_react254.default.createElement(AttachmentWithinContainer, { attachment, componentType }, /* @__PURE__ */ import_react254.default.createElement("div", { className: "str-chat__attachment" }, content3, /* @__PURE__ */ import_react254.default.createElement(AttachmentActionsContainer, { ...props }))) : /* @__PURE__ */ import_react254.default.createElement(AttachmentWithinContainer, { attachment, componentType }, content3);
|
|
49551
49531
|
};
|
|
49552
49532
|
var UnsupportedAttachmentContainer = ({
|
|
49553
49533
|
attachment,
|
|
49554
49534
|
UnsupportedAttachment: UnsupportedAttachment2 = UnsupportedAttachment
|
|
49555
|
-
}) => /* @__PURE__ */
|
|
49535
|
+
}) => /* @__PURE__ */ import_react254.default.createElement(import_react254.default.Fragment, null, /* @__PURE__ */ import_react254.default.createElement(UnsupportedAttachment2, { attachment }));
|
|
49556
49536
|
|
|
49557
49537
|
// src/components/Attachment/Attachment.tsx
|
|
49558
49538
|
var CONTAINER_MAP = {
|
|
@@ -49575,12 +49555,12 @@ var ATTACHMENT_GROUPS_ORDER = [
|
|
|
49575
49555
|
];
|
|
49576
49556
|
var Attachment = (props) => {
|
|
49577
49557
|
const { attachments } = props;
|
|
49578
|
-
const groupedAttachments = (0,
|
|
49558
|
+
const groupedAttachments = (0, import_react255.useMemo)(
|
|
49579
49559
|
() => renderGroupedAttachments(props),
|
|
49580
49560
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
49581
49561
|
[attachments]
|
|
49582
49562
|
);
|
|
49583
|
-
return /* @__PURE__ */
|
|
49563
|
+
return /* @__PURE__ */ import_react255.default.createElement("div", { className: "str-chat__attachment-list" }, ATTACHMENT_GROUPS_ORDER.reduce(
|
|
49584
49564
|
(acc, groupName) => [...acc, ...groupedAttachments[groupName]],
|
|
49585
49565
|
[]
|
|
49586
49566
|
));
|
|
@@ -49597,7 +49577,7 @@ var renderGroupedAttachments = ({
|
|
|
49597
49577
|
const attachmentType = getAttachmentType(attachment);
|
|
49598
49578
|
const Container = CONTAINER_MAP[attachmentType];
|
|
49599
49579
|
typeMap[attachmentType].push(
|
|
49600
|
-
/* @__PURE__ */
|
|
49580
|
+
/* @__PURE__ */ import_react255.default.createElement(
|
|
49601
49581
|
Container,
|
|
49602
49582
|
{
|
|
49603
49583
|
key: `${attachmentType}-${typeMap[attachmentType].length}`,
|
|
@@ -49624,7 +49604,7 @@ var renderGroupedAttachments = ({
|
|
|
49624
49604
|
);
|
|
49625
49605
|
if (uploadedImages.length > 1) {
|
|
49626
49606
|
containers["gallery"] = [
|
|
49627
|
-
/* @__PURE__ */
|
|
49607
|
+
/* @__PURE__ */ import_react255.default.createElement(
|
|
49628
49608
|
GalleryContainer,
|
|
49629
49609
|
{
|
|
49630
49610
|
key: "gallery-container",
|
|
@@ -49638,7 +49618,7 @@ var renderGroupedAttachments = ({
|
|
|
49638
49618
|
];
|
|
49639
49619
|
} else if (uploadedImages.length === 1) {
|
|
49640
49620
|
containers["image"] = [
|
|
49641
|
-
/* @__PURE__ */
|
|
49621
|
+
/* @__PURE__ */ import_react255.default.createElement(ImageContainer, { key: "image-container", ...rest, attachment: uploadedImages[0] })
|
|
49642
49622
|
];
|
|
49643
49623
|
}
|
|
49644
49624
|
return containers;
|
|
@@ -49659,11 +49639,11 @@ var getAttachmentType = (attachment) => {
|
|
|
49659
49639
|
};
|
|
49660
49640
|
|
|
49661
49641
|
// src/components/Channel/Channel.tsx
|
|
49662
|
-
var
|
|
49642
|
+
var import_react261 = __toESM(require("react"));
|
|
49663
49643
|
var import_clsx66 = __toESM(require("clsx"));
|
|
49664
|
-
var
|
|
49665
|
-
var
|
|
49666
|
-
var
|
|
49644
|
+
var import_lodash20 = __toESM(require("lodash.debounce"));
|
|
49645
|
+
var import_lodash21 = __toESM(require("lodash.defaultsdeep"));
|
|
49646
|
+
var import_lodash22 = __toESM(require("lodash.throttle"));
|
|
49667
49647
|
var import_stream_chat11 = require("stream-chat");
|
|
49668
49648
|
|
|
49669
49649
|
// src/components/Channel/channelState.ts
|
|
@@ -49840,7 +49820,7 @@ var initialState = {
|
|
|
49840
49820
|
};
|
|
49841
49821
|
|
|
49842
49822
|
// src/components/Channel/hooks/useCreateChannelStateContext.ts
|
|
49843
|
-
var
|
|
49823
|
+
var import_react256 = require("react");
|
|
49844
49824
|
var useCreateChannelStateContext = (value) => {
|
|
49845
49825
|
const {
|
|
49846
49826
|
channel,
|
|
@@ -49899,7 +49879,7 @@ var useCreateChannelStateContext = (value) => {
|
|
|
49899
49879
|
const memoizedThreadMessageData = threadMessages.map(
|
|
49900
49880
|
({ deleted_at, latest_reactions, pinned, status, updated_at, user }) => `${deleted_at}${latest_reactions ? latest_reactions.map(({ type }) => type).join() : ""}${pinned}${status}${updated_at && (isDayOrMoment(updated_at) || isDate(updated_at)) ? updated_at.toISOString() : updated_at || ""}${user?.updated_at}`
|
|
49901
49881
|
).join();
|
|
49902
|
-
const channelStateContext = (0,
|
|
49882
|
+
const channelStateContext = (0, import_react256.useMemo)(
|
|
49903
49883
|
() => ({
|
|
49904
49884
|
channel,
|
|
49905
49885
|
channelCapabilities,
|
|
@@ -49963,11 +49943,11 @@ var useCreateChannelStateContext = (value) => {
|
|
|
49963
49943
|
};
|
|
49964
49944
|
|
|
49965
49945
|
// src/components/Channel/hooks/useCreateTypingContext.ts
|
|
49966
|
-
var
|
|
49946
|
+
var import_react257 = require("react");
|
|
49967
49947
|
var useCreateTypingContext = (value) => {
|
|
49968
49948
|
const { typing } = value;
|
|
49969
49949
|
const typingValue = Object.keys(typing || {}).join();
|
|
49970
|
-
const typingContext = (0,
|
|
49950
|
+
const typingContext = (0, import_react257.useMemo)(
|
|
49971
49951
|
() => ({
|
|
49972
49952
|
typing
|
|
49973
49953
|
}),
|
|
@@ -49991,10 +49971,10 @@ var useEditMessageHandler = (doUpdateMessageRequest) => {
|
|
|
49991
49971
|
};
|
|
49992
49972
|
|
|
49993
49973
|
// src/components/Channel/hooks/useIsMounted.ts
|
|
49994
|
-
var
|
|
49974
|
+
var import_react258 = require("react");
|
|
49995
49975
|
var useIsMounted = () => {
|
|
49996
|
-
const isMounted = (0,
|
|
49997
|
-
(0,
|
|
49976
|
+
const isMounted = (0, import_react258.useRef)(false);
|
|
49977
|
+
(0, import_react258.useEffect)(() => {
|
|
49998
49978
|
isMounted.current = true;
|
|
49999
49979
|
return () => {
|
|
50000
49980
|
isMounted.current = false;
|
|
@@ -50004,8 +49984,8 @@ var useIsMounted = () => {
|
|
|
50004
49984
|
};
|
|
50005
49985
|
|
|
50006
49986
|
// src/components/Channel/hooks/useMentionsHandlers.ts
|
|
50007
|
-
var
|
|
50008
|
-
var useMentionsHandlers = (onMentionsHover, onMentionsClick) => (0,
|
|
49987
|
+
var import_react259 = require("react");
|
|
49988
|
+
var useMentionsHandlers = (onMentionsHover, onMentionsClick) => (0, import_react259.useCallback)(
|
|
50009
49989
|
(event, mentioned_users) => {
|
|
50010
49990
|
if (!onMentionsHover && !onMentionsClick || !(event.target instanceof HTMLElement)) {
|
|
50011
49991
|
return;
|
|
@@ -50029,11 +50009,11 @@ var useMentionsHandlers = (onMentionsHover, onMentionsClick) => (0, import_react
|
|
|
50029
50009
|
);
|
|
50030
50010
|
|
|
50031
50011
|
// src/components/Channel/LoadingChannel.tsx
|
|
50032
|
-
var
|
|
50033
|
-
var LoadingMessage = () => /* @__PURE__ */
|
|
50034
|
-
var LoadingMessageInput = () => /* @__PURE__ */
|
|
50035
|
-
var LoadingChannelHeader = () => /* @__PURE__ */
|
|
50036
|
-
var LoadingChannel = () => /* @__PURE__ */
|
|
50012
|
+
var import_react260 = __toESM(require("react"));
|
|
50013
|
+
var LoadingMessage = () => /* @__PURE__ */ import_react260.default.createElement("div", { className: "str-chat__loading-channel-message" }, /* @__PURE__ */ import_react260.default.createElement("div", { className: "str-chat__loading-channel-message-avatar" }), /* @__PURE__ */ import_react260.default.createElement("div", { className: "str-chat__loading-channel-message-end" }, /* @__PURE__ */ import_react260.default.createElement("div", { className: "str-chat__loading-channel-message-sender" }), /* @__PURE__ */ import_react260.default.createElement("div", { className: "str-chat__loading-channel-message-last-row" }, /* @__PURE__ */ import_react260.default.createElement("div", { className: "str-chat__loading-channel-message-text" }), /* @__PURE__ */ import_react260.default.createElement("div", { className: "str-chat__loading-channel-message-date" }))));
|
|
50014
|
+
var LoadingMessageInput = () => /* @__PURE__ */ import_react260.default.createElement("div", { className: "str-chat__loading-channel-message-input-row" }, /* @__PURE__ */ import_react260.default.createElement("div", { className: "str-chat__loading-channel-message-input" }), /* @__PURE__ */ import_react260.default.createElement("div", { className: "str-chat__loading-channel-message-send" }));
|
|
50015
|
+
var LoadingChannelHeader = () => /* @__PURE__ */ import_react260.default.createElement("div", { className: "str-chat__loading-channel-header" }, /* @__PURE__ */ import_react260.default.createElement("div", { className: "str-chat__loading-channel-header-avatar" }), /* @__PURE__ */ import_react260.default.createElement("div", { className: "str-chat__loading-channel-header-end" }, /* @__PURE__ */ import_react260.default.createElement("div", { className: "str-chat__loading-channel-header-name" }), /* @__PURE__ */ import_react260.default.createElement("div", { className: "str-chat__loading-channel-header-info" })));
|
|
50016
|
+
var LoadingChannel = () => /* @__PURE__ */ import_react260.default.createElement("div", { className: "str-chat__loading-channel" }, /* @__PURE__ */ import_react260.default.createElement(LoadingChannelHeader, null), /* @__PURE__ */ import_react260.default.createElement("div", { className: "str-chat__loading-channel-message-list" }, Array.from(Array(3)).map((_, i) => /* @__PURE__ */ import_react260.default.createElement(LoadingMessage, { key: `loading-message-${i}` }))), /* @__PURE__ */ import_react260.default.createElement(LoadingMessageInput, null));
|
|
50037
50017
|
|
|
50038
50018
|
// src/components/Channel/hooks/useChannelContainerClasses.ts
|
|
50039
50019
|
var useImageFlagEmojisOnWindowsClass = () => {
|
|
@@ -50220,7 +50200,7 @@ var ChannelContainer = ({
|
|
|
50220
50200
|
customClasses
|
|
50221
50201
|
});
|
|
50222
50202
|
const className = (0, import_clsx66.default)(chatClass, theme, channelClass, additionalClassName);
|
|
50223
|
-
return /* @__PURE__ */
|
|
50203
|
+
return /* @__PURE__ */ import_react261.default.createElement("div", { id: CHANNEL_CONTAINER_ID, ...props, className }, children);
|
|
50224
50204
|
};
|
|
50225
50205
|
var UnMemoizedChannel = (props) => {
|
|
50226
50206
|
const {
|
|
@@ -50232,15 +50212,15 @@ var UnMemoizedChannel = (props) => {
|
|
|
50232
50212
|
const { channel: contextChannel, channelsQueryState } = useChatContext("Channel");
|
|
50233
50213
|
const channel = propsChannel || contextChannel;
|
|
50234
50214
|
if (channelsQueryState.queryInProgress === "reload" && LoadingIndicator2) {
|
|
50235
|
-
return /* @__PURE__ */
|
|
50215
|
+
return /* @__PURE__ */ import_react261.default.createElement(ChannelContainer, null, /* @__PURE__ */ import_react261.default.createElement(LoadingIndicator2, null));
|
|
50236
50216
|
}
|
|
50237
50217
|
if (channelsQueryState.error && LoadingErrorIndicator2) {
|
|
50238
|
-
return /* @__PURE__ */
|
|
50218
|
+
return /* @__PURE__ */ import_react261.default.createElement(ChannelContainer, null, /* @__PURE__ */ import_react261.default.createElement(LoadingErrorIndicator2, { error: channelsQueryState.error }));
|
|
50239
50219
|
}
|
|
50240
50220
|
if (!channel?.cid) {
|
|
50241
|
-
return /* @__PURE__ */
|
|
50221
|
+
return /* @__PURE__ */ import_react261.default.createElement(ChannelContainer, null, EmptyPlaceholder2);
|
|
50242
50222
|
}
|
|
50243
|
-
return /* @__PURE__ */
|
|
50223
|
+
return /* @__PURE__ */ import_react261.default.createElement(ChannelInner, { ...props, channel, key: channel.cid });
|
|
50244
50224
|
};
|
|
50245
50225
|
var ChannelInner = (props) => {
|
|
50246
50226
|
const {
|
|
@@ -50260,8 +50240,8 @@ var ChannelInner = (props) => {
|
|
|
50260
50240
|
onMentionsHover,
|
|
50261
50241
|
skipMessageDataMemoization
|
|
50262
50242
|
} = props;
|
|
50263
|
-
const channelQueryOptions = (0,
|
|
50264
|
-
() => (0,
|
|
50243
|
+
const channelQueryOptions = (0, import_react261.useMemo)(
|
|
50244
|
+
() => (0, import_lodash21.default)(propChannelQueryOptions, {
|
|
50265
50245
|
messages: { limit: DEFAULT_INITIAL_CHANNEL_PAGE_SIZE }
|
|
50266
50246
|
}),
|
|
50267
50247
|
[propChannelQueryOptions]
|
|
@@ -50271,12 +50251,12 @@ var ChannelInner = (props) => {
|
|
|
50271
50251
|
const chatContainerClass = getChatContainerClass(customClasses?.chatContainer);
|
|
50272
50252
|
const windowsEmojiClass = useImageFlagEmojisOnWindowsClass();
|
|
50273
50253
|
const thread = useThreadContext();
|
|
50274
|
-
const [channelConfig, setChannelConfig] = (0,
|
|
50275
|
-
const [notifications, setNotifications] = (0,
|
|
50276
|
-
const notificationTimeouts = (0,
|
|
50277
|
-
const [channelUnreadUiState, _setChannelUnreadUiState] = (0,
|
|
50278
|
-
const channelReducer = (0,
|
|
50279
|
-
const [state, dispatch] = (0,
|
|
50254
|
+
const [channelConfig, setChannelConfig] = (0, import_react261.useState)(channel.getConfig());
|
|
50255
|
+
const [notifications, setNotifications] = (0, import_react261.useState)([]);
|
|
50256
|
+
const notificationTimeouts = (0, import_react261.useRef)([]);
|
|
50257
|
+
const [channelUnreadUiState, _setChannelUnreadUiState] = (0, import_react261.useState)();
|
|
50258
|
+
const channelReducer = (0, import_react261.useMemo)(() => makeChannelReducer(), []);
|
|
50259
|
+
const [state, dispatch] = (0, import_react261.useReducer)(
|
|
50280
50260
|
channelReducer,
|
|
50281
50261
|
// channel.initialized === false if client.channel().query() was not called, e.g. ChannelList is not used
|
|
50282
50262
|
// => Channel will call channel.watch() in useLayoutEffect => state.loading is used to signal the watch() call state
|
|
@@ -50288,14 +50268,14 @@ var ChannelInner = (props) => {
|
|
|
50288
50268
|
);
|
|
50289
50269
|
const jumpToMessageFromSearch = useSearchFocusedMessage();
|
|
50290
50270
|
const isMounted = useIsMounted();
|
|
50291
|
-
const originalTitle = (0,
|
|
50292
|
-
const lastRead = (0,
|
|
50293
|
-
const online = (0,
|
|
50294
|
-
const clearHighlightedMessageTimeoutId = (0,
|
|
50271
|
+
const originalTitle = (0, import_react261.useRef)("");
|
|
50272
|
+
const lastRead = (0, import_react261.useRef)(void 0);
|
|
50273
|
+
const online = (0, import_react261.useRef)(true);
|
|
50274
|
+
const clearHighlightedMessageTimeoutId = (0, import_react261.useRef)(
|
|
50295
50275
|
null
|
|
50296
50276
|
);
|
|
50297
50277
|
const channelCapabilitiesArray = channel.data?.own_capabilities;
|
|
50298
|
-
const throttledCopyStateFromChannel = (0,
|
|
50278
|
+
const throttledCopyStateFromChannel = (0, import_lodash22.default)(
|
|
50299
50279
|
() => dispatch({ channel, type: "copyStateFromChannelOnEvent" }),
|
|
50300
50280
|
500,
|
|
50301
50281
|
{
|
|
@@ -50303,15 +50283,15 @@ var ChannelInner = (props) => {
|
|
|
50303
50283
|
trailing: true
|
|
50304
50284
|
}
|
|
50305
50285
|
);
|
|
50306
|
-
const setChannelUnreadUiState = (0,
|
|
50307
|
-
() => (0,
|
|
50286
|
+
const setChannelUnreadUiState = (0, import_react261.useMemo)(
|
|
50287
|
+
() => (0, import_lodash22.default)(_setChannelUnreadUiState, 200, {
|
|
50308
50288
|
leading: true,
|
|
50309
50289
|
trailing: false
|
|
50310
50290
|
}),
|
|
50311
50291
|
[]
|
|
50312
50292
|
);
|
|
50313
|
-
const markRead = (0,
|
|
50314
|
-
() => (0,
|
|
50293
|
+
const markRead = (0, import_react261.useMemo)(
|
|
50294
|
+
() => (0, import_lodash22.default)(
|
|
50315
50295
|
async (options) => {
|
|
50316
50296
|
const { updateChannelUiUnreadState = true } = options ?? {};
|
|
50317
50297
|
if (channel.disconnected || !channelConfig?.read_events) {
|
|
@@ -50413,7 +50393,7 @@ var ChannelInner = (props) => {
|
|
|
50413
50393
|
}
|
|
50414
50394
|
throttledCopyStateFromChannel();
|
|
50415
50395
|
};
|
|
50416
|
-
(0,
|
|
50396
|
+
(0, import_react261.useLayoutEffect)(() => {
|
|
50417
50397
|
let errored = false;
|
|
50418
50398
|
let done = false;
|
|
50419
50399
|
(async () => {
|
|
@@ -50479,12 +50459,12 @@ var ChannelInner = (props) => {
|
|
|
50479
50459
|
channelConfig?.read_events,
|
|
50480
50460
|
initializeOnMount
|
|
50481
50461
|
]);
|
|
50482
|
-
(0,
|
|
50462
|
+
(0, import_react261.useEffect)(() => {
|
|
50483
50463
|
if (!state.thread) return;
|
|
50484
50464
|
const message = state.messages?.find((m) => m.id === state.thread?.id);
|
|
50485
50465
|
if (message) dispatch({ message, type: "setThread" });
|
|
50486
50466
|
}, [state.messages, state.thread]);
|
|
50487
|
-
const handleHighlightedMessageChange = (0,
|
|
50467
|
+
const handleHighlightedMessageChange = (0, import_react261.useCallback)(
|
|
50488
50468
|
({
|
|
50489
50469
|
highlightDuration,
|
|
50490
50470
|
highlightedMessageId
|
|
@@ -50507,16 +50487,16 @@ var ChannelInner = (props) => {
|
|
|
50507
50487
|
},
|
|
50508
50488
|
[channel, searchController]
|
|
50509
50489
|
);
|
|
50510
|
-
(0,
|
|
50490
|
+
(0, import_react261.useEffect)(() => {
|
|
50511
50491
|
if (!jumpToMessageFromSearch?.id) return;
|
|
50512
50492
|
handleHighlightedMessageChange({ highlightedMessageId: jumpToMessageFromSearch.id });
|
|
50513
50493
|
}, [jumpToMessageFromSearch, handleHighlightedMessageChange]);
|
|
50514
|
-
const addNotification = (0,
|
|
50494
|
+
const addNotification = (0, import_react261.useMemo)(
|
|
50515
50495
|
() => makeAddNotifications(setNotifications, notificationTimeouts.current),
|
|
50516
50496
|
[]
|
|
50517
50497
|
);
|
|
50518
|
-
const loadMoreFinished = (0,
|
|
50519
|
-
(0,
|
|
50498
|
+
const loadMoreFinished = (0, import_react261.useCallback)(
|
|
50499
|
+
(0, import_lodash20.default)(
|
|
50520
50500
|
(hasMore, messages) => {
|
|
50521
50501
|
if (!isMounted.current) return;
|
|
50522
50502
|
dispatch({ hasMore, messages, type: "loadMoreFinished" });
|
|
@@ -50576,7 +50556,7 @@ var ChannelInner = (props) => {
|
|
|
50576
50556
|
});
|
|
50577
50557
|
return queryResponse.messages.length;
|
|
50578
50558
|
};
|
|
50579
|
-
const jumpToMessage = (0,
|
|
50559
|
+
const jumpToMessage = (0, import_react261.useCallback)(
|
|
50580
50560
|
async (messageId, messageLimit = DEFAULT_JUMP_TO_PAGE_SIZE, highlightDuration = DEFAULT_HIGHLIGHT_DURATION) => {
|
|
50581
50561
|
dispatch({ loadingMore: true, type: "setLoadingMore" });
|
|
50582
50562
|
await channel.state.loadMessageIntoState(messageId, void 0, messageLimit);
|
|
@@ -50588,14 +50568,14 @@ var ChannelInner = (props) => {
|
|
|
50588
50568
|
},
|
|
50589
50569
|
[channel, handleHighlightedMessageChange, loadMoreFinished]
|
|
50590
50570
|
);
|
|
50591
|
-
const jumpToLatestMessage = (0,
|
|
50571
|
+
const jumpToLatestMessage = (0, import_react261.useCallback)(async () => {
|
|
50592
50572
|
await channel.state.loadMessageIntoState("latest");
|
|
50593
50573
|
loadMoreFinished(channel.state.messagePagination.hasPrev, channel.state.messages);
|
|
50594
50574
|
dispatch({
|
|
50595
50575
|
type: "jumpToLatestMessage"
|
|
50596
50576
|
});
|
|
50597
50577
|
}, [channel, loadMoreFinished]);
|
|
50598
|
-
const jumpToFirstUnreadMessage = (0,
|
|
50578
|
+
const jumpToFirstUnreadMessage = (0, import_react261.useCallback)(
|
|
50599
50579
|
async (queryMessageLimit = DEFAULT_JUMP_TO_PAGE_SIZE, highlightDuration = DEFAULT_HIGHLIGHT_DURATION) => {
|
|
50600
50580
|
if (!channelUnreadUiState?.unread_messages) return;
|
|
50601
50581
|
let lastReadMessageId = channelUnreadUiState?.last_read_message_id;
|
|
@@ -50718,7 +50698,7 @@ var ChannelInner = (props) => {
|
|
|
50718
50698
|
channelUnreadUiState
|
|
50719
50699
|
]
|
|
50720
50700
|
);
|
|
50721
|
-
const deleteMessage = (0,
|
|
50701
|
+
const deleteMessage = (0, import_react261.useCallback)(
|
|
50722
50702
|
async (message) => {
|
|
50723
50703
|
if (!message?.id) {
|
|
50724
50704
|
throw new Error("Cannot delete a message - missing message ID.");
|
|
@@ -50836,8 +50816,8 @@ var ChannelInner = (props) => {
|
|
|
50836
50816
|
event?.preventDefault();
|
|
50837
50817
|
dispatch({ type: "closeThread" });
|
|
50838
50818
|
};
|
|
50839
|
-
const loadMoreThreadFinished = (0,
|
|
50840
|
-
(0,
|
|
50819
|
+
const loadMoreThreadFinished = (0, import_react261.useCallback)(
|
|
50820
|
+
(0, import_lodash20.default)(
|
|
50841
50821
|
(threadHasMore, threadMessages) => {
|
|
50842
50822
|
dispatch({
|
|
50843
50823
|
threadHasMore,
|
|
@@ -50891,7 +50871,7 @@ var ChannelInner = (props) => {
|
|
|
50891
50871
|
videoAttachmentSizeHandler: props.videoAttachmentSizeHandler || getVideoAttachmentConfiguration,
|
|
50892
50872
|
watcher_count: state.watcherCount
|
|
50893
50873
|
});
|
|
50894
|
-
const channelActionContextValue = (0,
|
|
50874
|
+
const channelActionContextValue = (0, import_react261.useMemo)(
|
|
50895
50875
|
() => ({
|
|
50896
50876
|
addNotification,
|
|
50897
50877
|
closeThread,
|
|
@@ -50928,7 +50908,7 @@ var ChannelInner = (props) => {
|
|
|
50928
50908
|
setChannelUnreadUiState
|
|
50929
50909
|
]
|
|
50930
50910
|
);
|
|
50931
|
-
const componentContextValue = (0,
|
|
50911
|
+
const componentContextValue = (0, import_react261.useMemo)(
|
|
50932
50912
|
() => ({
|
|
50933
50913
|
Attachment: props.Attachment,
|
|
50934
50914
|
AttachmentPreviewList: props.AttachmentPreviewList,
|
|
@@ -50982,6 +50962,7 @@ var ChannelInner = (props) => {
|
|
|
50982
50962
|
StartRecordingAudioButton: props.StartRecordingAudioButton,
|
|
50983
50963
|
StopAIGenerationButton: props.StopAIGenerationButton,
|
|
50984
50964
|
StreamedMessageText: props.StreamedMessageText,
|
|
50965
|
+
TextareaComposer: props.TextareaComposer,
|
|
50985
50966
|
ThreadHead: props.ThreadHead,
|
|
50986
50967
|
ThreadHeader: props.ThreadHeader,
|
|
50987
50968
|
ThreadStart: props.ThreadStart,
|
|
@@ -51044,6 +51025,7 @@ var ChannelInner = (props) => {
|
|
|
51044
51025
|
props.StartRecordingAudioButton,
|
|
51045
51026
|
props.StopAIGenerationButton,
|
|
51046
51027
|
props.StreamedMessageText,
|
|
51028
|
+
props.TextareaComposer,
|
|
51047
51029
|
props.ThreadHead,
|
|
51048
51030
|
props.ThreadHeader,
|
|
51049
51031
|
props.ThreadStart,
|
|
@@ -51058,26 +51040,26 @@ var ChannelInner = (props) => {
|
|
|
51058
51040
|
typing
|
|
51059
51041
|
});
|
|
51060
51042
|
if (state.error) {
|
|
51061
|
-
return /* @__PURE__ */
|
|
51043
|
+
return /* @__PURE__ */ import_react261.default.createElement(ChannelContainer, null, /* @__PURE__ */ import_react261.default.createElement(LoadingErrorIndicator2, { error: state.error }));
|
|
51062
51044
|
}
|
|
51063
51045
|
if (state.loading) {
|
|
51064
|
-
return /* @__PURE__ */
|
|
51046
|
+
return /* @__PURE__ */ import_react261.default.createElement(ChannelContainer, null, /* @__PURE__ */ import_react261.default.createElement(LoadingIndicator2, null));
|
|
51065
51047
|
}
|
|
51066
51048
|
if (!channel.watch) {
|
|
51067
|
-
return /* @__PURE__ */
|
|
51049
|
+
return /* @__PURE__ */ import_react261.default.createElement(ChannelContainer, null, /* @__PURE__ */ import_react261.default.createElement("div", null, t("Channel Missing")));
|
|
51068
51050
|
}
|
|
51069
|
-
return /* @__PURE__ */
|
|
51051
|
+
return /* @__PURE__ */ import_react261.default.createElement(ChannelContainer, { className: windowsEmojiClass }, /* @__PURE__ */ import_react261.default.createElement(ChannelStateProvider, { value: channelStateContextValue }, /* @__PURE__ */ import_react261.default.createElement(ChannelActionProvider, { value: channelActionContextValue }, /* @__PURE__ */ import_react261.default.createElement(WithComponents, { overrides: componentContextValue }, /* @__PURE__ */ import_react261.default.createElement(TypingProvider, { value: typingContextValue }, /* @__PURE__ */ import_react261.default.createElement("div", { className: (0, import_clsx66.default)(chatContainerClass) }, children))))));
|
|
51070
51052
|
};
|
|
51071
|
-
var Channel =
|
|
51053
|
+
var Channel = import_react261.default.memo(UnMemoizedChannel);
|
|
51072
51054
|
|
|
51073
51055
|
// src/components/ChannelHeader/ChannelHeader.tsx
|
|
51074
|
-
var
|
|
51056
|
+
var import_react263 = __toESM(require("react"));
|
|
51075
51057
|
|
|
51076
51058
|
// src/components/ChannelHeader/icons.tsx
|
|
51077
|
-
var
|
|
51059
|
+
var import_react262 = __toESM(require("react"));
|
|
51078
51060
|
var MenuIcon2 = ({ title }) => {
|
|
51079
51061
|
const { t } = useTranslationContext("MenuIcon");
|
|
51080
|
-
return /* @__PURE__ */
|
|
51062
|
+
return /* @__PURE__ */ import_react262.default.createElement("svg", { "data-testid": "menu-icon", viewBox: "0 0 448 512", xmlns: "http://www.w3.org/2000/svg" }, /* @__PURE__ */ import_react262.default.createElement("title", null, title ?? t("Menu")), /* @__PURE__ */ import_react262.default.createElement(
|
|
51081
51063
|
"path",
|
|
51082
51064
|
{
|
|
51083
51065
|
d: "M0 88C0 74.75 10.75 64 24 64H424C437.3 64 448 74.75 448 88C448 101.3 437.3 112 424 112H24C10.75 112 0 101.3 0 88zM0 248C0 234.7 10.75 224 24 224H424C437.3 224 448 234.7 448 248C448 261.3 437.3 272 424 272H24C10.75 272 0 261.3 0 248zM424 432H24C10.75 432 0 421.3 0 408C0 394.7 10.75 384 24 384H424C437.3 384 448 394.7 448 408C448 421.3 437.3 432 424 432z",
|
|
@@ -51104,15 +51086,15 @@ var ChannelHeader = (props) => {
|
|
|
51104
51086
|
overrideTitle
|
|
51105
51087
|
});
|
|
51106
51088
|
const { member_count, subtitle } = channel?.data || {};
|
|
51107
|
-
return /* @__PURE__ */
|
|
51089
|
+
return /* @__PURE__ */ import_react263.default.createElement("div", { className: "str-chat__channel-header" }, /* @__PURE__ */ import_react263.default.createElement(
|
|
51108
51090
|
"button",
|
|
51109
51091
|
{
|
|
51110
51092
|
"aria-label": t("aria/Menu"),
|
|
51111
51093
|
className: "str-chat__header-hamburger",
|
|
51112
51094
|
onClick: openMobileNav
|
|
51113
51095
|
},
|
|
51114
|
-
/* @__PURE__ */
|
|
51115
|
-
), /* @__PURE__ */
|
|
51096
|
+
/* @__PURE__ */ import_react263.default.createElement(MenuIcon3, null)
|
|
51097
|
+
), /* @__PURE__ */ import_react263.default.createElement(
|
|
51116
51098
|
Avatar2,
|
|
51117
51099
|
{
|
|
51118
51100
|
className: "str-chat__avatar--channel-header",
|
|
@@ -51120,36 +51102,36 @@ var ChannelHeader = (props) => {
|
|
|
51120
51102
|
image: displayImage,
|
|
51121
51103
|
name: displayTitle
|
|
51122
51104
|
}
|
|
51123
|
-
), /* @__PURE__ */
|
|
51105
|
+
), /* @__PURE__ */ import_react263.default.createElement("div", { className: "str-chat__channel-header-end" }, /* @__PURE__ */ import_react263.default.createElement("p", { className: "str-chat__channel-header-title" }, displayTitle, " ", live && /* @__PURE__ */ import_react263.default.createElement("span", { className: "str-chat__header-livestream-livelabel" }, t("live"))), subtitle && /* @__PURE__ */ import_react263.default.createElement("p", { className: "str-chat__channel-header-subtitle" }, subtitle), /* @__PURE__ */ import_react263.default.createElement("p", { className: "str-chat__channel-header-info" }, !live && !!member_count && member_count > 0 && /* @__PURE__ */ import_react263.default.createElement(import_react263.default.Fragment, null, t("{{ memberCount }} members", {
|
|
51124
51106
|
memberCount: member_count
|
|
51125
51107
|
}), ",", " "), t("{{ watcherCount }} online", { watcherCount: watcher_count }))));
|
|
51126
51108
|
};
|
|
51127
51109
|
|
|
51128
51110
|
// src/components/Chat/Chat.tsx
|
|
51129
|
-
var
|
|
51111
|
+
var import_react267 = __toESM(require("react"));
|
|
51130
51112
|
var import_stream_chat12 = require("stream-chat");
|
|
51131
51113
|
|
|
51132
51114
|
// src/components/Chat/hooks/useChat.ts
|
|
51133
|
-
var
|
|
51115
|
+
var import_react264 = require("react");
|
|
51134
51116
|
var useChat = ({
|
|
51135
51117
|
client,
|
|
51136
51118
|
defaultLanguage = "en",
|
|
51137
51119
|
i18nInstance,
|
|
51138
51120
|
initialNavOpen
|
|
51139
51121
|
}) => {
|
|
51140
|
-
const [translators, setTranslators] = (0,
|
|
51122
|
+
const [translators, setTranslators] = (0, import_react264.useState)({
|
|
51141
51123
|
t: (key) => key,
|
|
51142
51124
|
tDateTimeParser: defaultDateTimeParser,
|
|
51143
51125
|
userLanguage: "en"
|
|
51144
51126
|
});
|
|
51145
|
-
const [channel, setChannel] = (0,
|
|
51146
|
-
const [mutes, setMutes] = (0,
|
|
51147
|
-
const [navOpen, setNavOpen] = (0,
|
|
51148
|
-
const [latestMessageDatesByChannels, setLatestMessageDatesByChannels] = (0,
|
|
51127
|
+
const [channel, setChannel] = (0, import_react264.useState)();
|
|
51128
|
+
const [mutes, setMutes] = (0, import_react264.useState)([]);
|
|
51129
|
+
const [navOpen, setNavOpen] = (0, import_react264.useState)(initialNavOpen);
|
|
51130
|
+
const [latestMessageDatesByChannels, setLatestMessageDatesByChannels] = (0, import_react264.useState)({});
|
|
51149
51131
|
const clientMutes = client.user?.mutes ?? [];
|
|
51150
51132
|
const closeMobileNav = () => setNavOpen(false);
|
|
51151
51133
|
const openMobileNav = () => setTimeout(() => setNavOpen(true), 100);
|
|
51152
|
-
const appSettings = (0,
|
|
51134
|
+
const appSettings = (0, import_react264.useRef)(null);
|
|
51153
51135
|
const getAppSettings = () => {
|
|
51154
51136
|
if (appSettings.current) {
|
|
51155
51137
|
return appSettings.current;
|
|
@@ -51157,9 +51139,9 @@ var useChat = ({
|
|
|
51157
51139
|
appSettings.current = client.getAppSettings();
|
|
51158
51140
|
return appSettings.current;
|
|
51159
51141
|
};
|
|
51160
|
-
(0,
|
|
51142
|
+
(0, import_react264.useEffect)(() => {
|
|
51161
51143
|
if (!client) return;
|
|
51162
|
-
const version = "13.0.0
|
|
51144
|
+
const version = "13.0.0";
|
|
51163
51145
|
const userAgent = client.getUserAgent();
|
|
51164
51146
|
if (!userAgent.includes("stream-chat-react")) {
|
|
51165
51147
|
client.setUserAgent(`stream-chat-react-${version}-${userAgent}`);
|
|
@@ -51171,7 +51153,7 @@ var useChat = ({
|
|
|
51171
51153
|
client.polls.unregisterSubscriptions();
|
|
51172
51154
|
};
|
|
51173
51155
|
}, [client]);
|
|
51174
|
-
(0,
|
|
51156
|
+
(0, import_react264.useEffect)(() => {
|
|
51175
51157
|
setMutes(clientMutes);
|
|
51176
51158
|
const handleEvent = (event) => {
|
|
51177
51159
|
setMutes(event.me?.mutes || []);
|
|
@@ -51179,7 +51161,7 @@ var useChat = ({
|
|
|
51179
51161
|
client.on("notification.mutes_updated", handleEvent);
|
|
51180
51162
|
return () => client.off("notification.mutes_updated", handleEvent);
|
|
51181
51163
|
}, [clientMutes?.length]);
|
|
51182
|
-
(0,
|
|
51164
|
+
(0, import_react264.useEffect)(() => {
|
|
51183
51165
|
let userLanguage = client.user?.language;
|
|
51184
51166
|
if (!userLanguage) {
|
|
51185
51167
|
const browserLanguage = window.navigator.language.slice(0, 2);
|
|
@@ -51196,7 +51178,7 @@ var useChat = ({
|
|
|
51196
51178
|
});
|
|
51197
51179
|
});
|
|
51198
51180
|
}, [i18nInstance]);
|
|
51199
|
-
const setActiveChannel = (0,
|
|
51181
|
+
const setActiveChannel = (0, import_react264.useCallback)(
|
|
51200
51182
|
async (activeChannel, watchers = {}, event) => {
|
|
51201
51183
|
if (event && event.preventDefault) event.preventDefault();
|
|
51202
51184
|
if (activeChannel && Object.keys(watchers).length) {
|
|
@@ -51207,7 +51189,7 @@ var useChat = ({
|
|
|
51207
51189
|
},
|
|
51208
51190
|
[]
|
|
51209
51191
|
);
|
|
51210
|
-
(0,
|
|
51192
|
+
(0, import_react264.useEffect)(() => {
|
|
51211
51193
|
setLatestMessageDatesByChannels({});
|
|
51212
51194
|
}, [client.user?.id]);
|
|
51213
51195
|
return {
|
|
@@ -51224,7 +51206,7 @@ var useChat = ({
|
|
|
51224
51206
|
};
|
|
51225
51207
|
|
|
51226
51208
|
// src/components/Chat/hooks/useCreateChatContext.ts
|
|
51227
|
-
var
|
|
51209
|
+
var import_react265 = require("react");
|
|
51228
51210
|
var useCreateChatContext = (value) => {
|
|
51229
51211
|
const {
|
|
51230
51212
|
channel,
|
|
@@ -51249,7 +51231,7 @@ var useCreateChatContext = (value) => {
|
|
|
51249
51231
|
const clientValues = `${client.clientID}${Object.keys(client.activeChannels).length}${Object.keys(client.listeners).length}${client.mutedChannels.length}
|
|
51250
51232
|
${client.user?.id}`;
|
|
51251
51233
|
const mutedUsersLength = mutes.length;
|
|
51252
|
-
const chatContext = (0,
|
|
51234
|
+
const chatContext = (0, import_react265.useMemo)(
|
|
51253
51235
|
() => ({
|
|
51254
51236
|
channel,
|
|
51255
51237
|
channelsQueryState,
|
|
@@ -51284,10 +51266,10 @@ var useCreateChatContext = (value) => {
|
|
|
51284
51266
|
};
|
|
51285
51267
|
|
|
51286
51268
|
// src/components/Chat/hooks/useChannelsQueryState.ts
|
|
51287
|
-
var
|
|
51269
|
+
var import_react266 = require("react");
|
|
51288
51270
|
var useChannelsQueryState = () => {
|
|
51289
|
-
const [error, setError] = (0,
|
|
51290
|
-
const [queryInProgress, setQueryInProgress] = (0,
|
|
51271
|
+
const [error, setError] = (0, import_react266.useState)(null);
|
|
51272
|
+
const [queryInProgress, setQueryInProgress] = (0, import_react266.useState)("uninitialized");
|
|
51291
51273
|
return {
|
|
51292
51274
|
error,
|
|
51293
51275
|
queryInProgress,
|
|
@@ -51322,7 +51304,7 @@ var Chat = (props) => {
|
|
|
51322
51304
|
translators
|
|
51323
51305
|
} = useChat({ client, defaultLanguage, i18nInstance, initialNavOpen });
|
|
51324
51306
|
const channelsQueryState = useChannelsQueryState();
|
|
51325
|
-
const searchController = (0,
|
|
51307
|
+
const searchController = (0, import_react267.useMemo)(
|
|
51326
51308
|
() => customChannelSearchController ?? new import_stream_chat12.SearchController({
|
|
51327
51309
|
sources: [
|
|
51328
51310
|
new import_stream_chat12.ChannelSearchSource(client),
|
|
@@ -51350,11 +51332,11 @@ var Chat = (props) => {
|
|
|
51350
51332
|
useImageFlagEmojisOnWindows
|
|
51351
51333
|
});
|
|
51352
51334
|
if (!translators.t) return null;
|
|
51353
|
-
return /* @__PURE__ */
|
|
51335
|
+
return /* @__PURE__ */ import_react267.default.createElement(ChatProvider, { value: chatContextValue }, /* @__PURE__ */ import_react267.default.createElement(TranslationProvider, { value: translators }, children));
|
|
51354
51336
|
};
|
|
51355
51337
|
|
|
51356
51338
|
// src/components/Chat/hooks/useCreateChatClient.ts
|
|
51357
|
-
var
|
|
51339
|
+
var import_react268 = require("react");
|
|
51358
51340
|
var import_stream_chat13 = require("stream-chat");
|
|
51359
51341
|
var useCreateChatClient = ({
|
|
51360
51342
|
apiKey,
|
|
@@ -51362,13 +51344,13 @@ var useCreateChatClient = ({
|
|
|
51362
51344
|
tokenOrProvider,
|
|
51363
51345
|
userData
|
|
51364
51346
|
}) => {
|
|
51365
|
-
const [chatClient, setChatClient] = (0,
|
|
51366
|
-
const [cachedUserData, setCachedUserData] = (0,
|
|
51347
|
+
const [chatClient, setChatClient] = (0, import_react268.useState)(null);
|
|
51348
|
+
const [cachedUserData, setCachedUserData] = (0, import_react268.useState)(userData);
|
|
51367
51349
|
if (userData.id !== cachedUserData.id) {
|
|
51368
51350
|
setCachedUserData(userData);
|
|
51369
51351
|
}
|
|
51370
|
-
const [cachedOptions] = (0,
|
|
51371
|
-
(0,
|
|
51352
|
+
const [cachedOptions] = (0, import_react268.useState)(options);
|
|
51353
|
+
(0, import_react268.useEffect)(() => {
|
|
51372
51354
|
const client = new import_stream_chat13.StreamChat(apiKey, void 0, cachedOptions);
|
|
51373
51355
|
let didUserConnectInterrupt = false;
|
|
51374
51356
|
const connectionPromise = client.connectUser(cachedUserData, tokenOrProvider).then(() => {
|
|
@@ -51386,12 +51368,12 @@ var useCreateChatClient = ({
|
|
|
51386
51368
|
};
|
|
51387
51369
|
|
|
51388
51370
|
// src/components/Window/Window.tsx
|
|
51389
|
-
var
|
|
51371
|
+
var import_react269 = __toESM(require("react"));
|
|
51390
51372
|
var import_clsx67 = __toESM(require("clsx"));
|
|
51391
51373
|
var UnMemoizedWindow = (props) => {
|
|
51392
51374
|
const { children, thread: propThread } = props;
|
|
51393
51375
|
const { thread: contextThread } = useChannelStateContext("Window");
|
|
51394
|
-
return /* @__PURE__ */
|
|
51376
|
+
return /* @__PURE__ */ import_react269.default.createElement(
|
|
51395
51377
|
"div",
|
|
51396
51378
|
{
|
|
51397
51379
|
className: (0, import_clsx67.default)("str-chat__main-panel", {
|
|
@@ -51401,7 +51383,7 @@ var UnMemoizedWindow = (props) => {
|
|
|
51401
51383
|
children
|
|
51402
51384
|
);
|
|
51403
51385
|
};
|
|
51404
|
-
var Window =
|
|
51386
|
+
var Window = import_react269.default.memo(UnMemoizedWindow);
|
|
51405
51387
|
/*! Bundled license information:
|
|
51406
51388
|
|
|
51407
51389
|
is-buffer/index.js:
|