stream-chat-react 13.0.0-rc.1 → 13.0.0-rc.2
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/Chat/hooks/useChat.js +1 -1
- package/dist/components/TextareaComposer/SuggestionList/CommandItem.d.ts +2 -8
- package/dist/components/TextareaComposer/SuggestionList/SuggestionList.d.ts +6 -8
- package/dist/components/TextareaComposer/SuggestionList/SuggestionList.js +7 -6
- package/dist/components/TextareaComposer/SuggestionList/SuggestionListItem.d.ts +10 -10
- package/dist/components/TextareaComposer/SuggestionList/SuggestionListItem.js +1 -2
- package/dist/index.browser.cjs +239 -239
- package/dist/index.browser.cjs.map +2 -2
- package/dist/index.node.cjs +239 -239
- package/dist/index.node.cjs.map +2 -2
- package/package.json +3 -3
package/dist/index.node.cjs
CHANGED
|
@@ -20473,11 +20473,11 @@ __export(src_exports, {
|
|
|
20473
20473
|
module.exports = __toCommonJS(src_exports);
|
|
20474
20474
|
|
|
20475
20475
|
// src/components/Attachment/Attachment.tsx
|
|
20476
|
-
var
|
|
20476
|
+
var import_react253 = __toESM(require("react"));
|
|
20477
20477
|
var import_stream_chat10 = require("stream-chat");
|
|
20478
20478
|
|
|
20479
20479
|
// src/components/Attachment/AttachmentContainer.tsx
|
|
20480
|
-
var
|
|
20480
|
+
var import_react252 = __toESM(require("react"));
|
|
20481
20481
|
var import_react_player2 = __toESM(require("react-player"));
|
|
20482
20482
|
var import_clsx65 = __toESM(require("clsx"));
|
|
20483
20483
|
var linkify = __toESM(require("linkifyjs"));
|
|
@@ -21722,7 +21722,7 @@ var UnMemoizedAudio = (props) => {
|
|
|
21722
21722
|
var Audio = import_react29.default.memo(UnMemoizedAudio);
|
|
21723
21723
|
|
|
21724
21724
|
// src/components/Attachment/VoiceRecording.tsx
|
|
21725
|
-
var
|
|
21725
|
+
var import_react248 = __toESM(require("react"));
|
|
21726
21726
|
|
|
21727
21727
|
// src/components/ReactFileUtilities/FileIcon/FileIcon.tsx
|
|
21728
21728
|
var import_react31 = __toESM(require("react"));
|
|
@@ -22685,7 +22685,7 @@ var FileIcon = (props) => {
|
|
|
22685
22685
|
// src/components/ReactFileUtilities/UploadButton.tsx
|
|
22686
22686
|
var import_clsx63 = __toESM(require("clsx"));
|
|
22687
22687
|
var import_nanoid5 = require("nanoid");
|
|
22688
|
-
var
|
|
22688
|
+
var import_react247 = __toESM(require("react"));
|
|
22689
22689
|
|
|
22690
22690
|
// src/components/ReactFileUtilities/utils.ts
|
|
22691
22691
|
var import_react32 = require("react");
|
|
@@ -52815,13 +52815,13 @@ var CooldownTimer = ({ cooldownInterval }) => {
|
|
|
52815
52815
|
};
|
|
52816
52816
|
|
|
52817
52817
|
// src/components/MessageInput/EditMessageForm.tsx
|
|
52818
|
-
var
|
|
52818
|
+
var import_react246 = __toESM(require("react"));
|
|
52819
52819
|
|
|
52820
52820
|
// src/components/MessageInput/MessageInput.tsx
|
|
52821
|
-
var
|
|
52821
|
+
var import_react245 = __toESM(require("react"));
|
|
52822
52822
|
|
|
52823
52823
|
// src/components/MessageInput/MessageInputFlat.tsx
|
|
52824
|
-
var
|
|
52824
|
+
var import_react243 = __toESM(require("react"));
|
|
52825
52825
|
|
|
52826
52826
|
// src/components/MessageInput/SendButton.tsx
|
|
52827
52827
|
var import_react230 = __toESM(require("react"));
|
|
@@ -53031,23 +53031,22 @@ var EmoticonItem = (props) => {
|
|
|
53031
53031
|
|
|
53032
53032
|
// src/components/TextareaComposer/SuggestionList/SuggestionList.tsx
|
|
53033
53033
|
var import_clsx60 = __toESM(require("clsx"));
|
|
53034
|
-
var
|
|
53034
|
+
var import_react238 = __toESM(require("react"));
|
|
53035
53035
|
|
|
53036
53036
|
// src/components/TextareaComposer/SuggestionList/SuggestionListItem.tsx
|
|
53037
53037
|
var import_clsx58 = __toESM(require("clsx"));
|
|
53038
|
-
var import_react236 = require("react");
|
|
53039
|
-
var
|
|
53040
|
-
var SuggestionListItem = import_react237.default.forwardRef(function SuggestionListItem2({ className, component: Component2, focused, item, onMouseEnter }, innerRef) {
|
|
53038
|
+
var import_react236 = __toESM(require("react"));
|
|
53039
|
+
var SuggestionListItem = import_react236.default.forwardRef(function SuggestionListItem2({ className, component: Component2, focused, item, onMouseEnter }, innerRef) {
|
|
53041
53040
|
const { textComposer } = useMessageComposer();
|
|
53042
|
-
const containerRef = (0,
|
|
53043
|
-
const handleSelect = (0,
|
|
53041
|
+
const containerRef = (0, import_react236.useRef)(null);
|
|
53042
|
+
const handleSelect = (0, import_react236.useCallback)(() => {
|
|
53044
53043
|
textComposer.handleSelect(item);
|
|
53045
53044
|
}, [item, textComposer]);
|
|
53046
53045
|
(0, import_react236.useLayoutEffect)(() => {
|
|
53047
53046
|
if (!focused) return;
|
|
53048
53047
|
containerRef.current?.scrollIntoView({ behavior: "instant", block: "nearest" });
|
|
53049
53048
|
}, [focused, containerRef]);
|
|
53050
|
-
return /* @__PURE__ */
|
|
53049
|
+
return /* @__PURE__ */ import_react236.default.createElement(
|
|
53051
53050
|
"li",
|
|
53052
53051
|
{
|
|
53053
53052
|
className: (0, import_clsx58.default)("str-chat__suggestion-list-item", className, {
|
|
@@ -53056,7 +53055,7 @@ var SuggestionListItem = import_react237.default.forwardRef(function SuggestionL
|
|
|
53056
53055
|
onMouseEnter,
|
|
53057
53056
|
ref: containerRef
|
|
53058
53057
|
},
|
|
53059
|
-
/* @__PURE__ */
|
|
53058
|
+
/* @__PURE__ */ import_react236.default.createElement(
|
|
53060
53059
|
"button",
|
|
53061
53060
|
{
|
|
53062
53061
|
onClick: handleSelect,
|
|
@@ -53067,13 +53066,13 @@ var SuggestionListItem = import_react237.default.forwardRef(function SuggestionL
|
|
|
53067
53066
|
},
|
|
53068
53067
|
ref: innerRef
|
|
53069
53068
|
},
|
|
53070
|
-
/* @__PURE__ */
|
|
53069
|
+
/* @__PURE__ */ import_react236.default.createElement(Component2, { entity: item, focused })
|
|
53071
53070
|
)
|
|
53072
53071
|
);
|
|
53073
53072
|
});
|
|
53074
53073
|
|
|
53075
53074
|
// src/components/TextareaComposer/SuggestionList/UserItem.tsx
|
|
53076
|
-
var
|
|
53075
|
+
var import_react237 = __toESM(require("react"));
|
|
53077
53076
|
var import_clsx59 = __toESM(require("clsx"));
|
|
53078
53077
|
var UserItem = ({ Avatar: Avatar2 = Avatar, entity }) => {
|
|
53079
53078
|
const hasEntity = !!Object.keys(entity).length;
|
|
@@ -53082,7 +53081,7 @@ var UserItem = ({ Avatar: Avatar2 = Avatar, entity }) => {
|
|
|
53082
53081
|
const renderName = () => parts.map((part, i) => {
|
|
53083
53082
|
const matches = part.toLowerCase() === token;
|
|
53084
53083
|
const partWithHTMLSpacesAround = part.replace(/^\s+|\s+$/g, "\xA0");
|
|
53085
|
-
return /* @__PURE__ */
|
|
53084
|
+
return /* @__PURE__ */ import_react237.default.createElement(
|
|
53086
53085
|
"span",
|
|
53087
53086
|
{
|
|
53088
53087
|
className: (0, import_clsx59.default)({
|
|
@@ -53094,14 +53093,14 @@ var UserItem = ({ Avatar: Avatar2 = Avatar, entity }) => {
|
|
|
53094
53093
|
partWithHTMLSpacesAround
|
|
53095
53094
|
);
|
|
53096
53095
|
});
|
|
53097
|
-
return /* @__PURE__ */
|
|
53096
|
+
return /* @__PURE__ */ import_react237.default.createElement("div", { className: "str-chat__user-item" }, /* @__PURE__ */ import_react237.default.createElement(
|
|
53098
53097
|
Avatar2,
|
|
53099
53098
|
{
|
|
53100
53099
|
className: "str-chat__avatar--autocomplete-item",
|
|
53101
53100
|
image: entity.image,
|
|
53102
53101
|
name: entity.name || entity.id
|
|
53103
53102
|
}
|
|
53104
|
-
), /* @__PURE__ */
|
|
53103
|
+
), /* @__PURE__ */ import_react237.default.createElement("span", { className: "str-chat__user-item--name", "data-testid": "user-item-name" }, renderName()), /* @__PURE__ */ import_react237.default.createElement("div", { className: "str-chat__user-item-at" }, "@"));
|
|
53105
53104
|
};
|
|
53106
53105
|
|
|
53107
53106
|
// src/components/TextareaComposer/SuggestionList/SuggestionList.tsx
|
|
@@ -53112,25 +53111,26 @@ var searchSourceStateSelector = (nextValue) => ({
|
|
|
53112
53111
|
items: nextValue.items ?? []
|
|
53113
53112
|
});
|
|
53114
53113
|
var defaultComponents = {
|
|
53115
|
-
"/": CommandItem,
|
|
53116
|
-
":": EmoticonItem,
|
|
53117
|
-
"@": UserItem
|
|
53114
|
+
"/": (props) => /* @__PURE__ */ import_react238.default.createElement(CommandItem, { entity: props.entity }),
|
|
53115
|
+
":": (props) => /* @__PURE__ */ import_react238.default.createElement(EmoticonItem, { entity: props.entity }),
|
|
53116
|
+
"@": (props) => /* @__PURE__ */ import_react238.default.createElement(UserItem, { entity: props.entity })
|
|
53118
53117
|
};
|
|
53119
53118
|
var SuggestionList = ({
|
|
53120
53119
|
className,
|
|
53121
53120
|
closeOnClickOutside = true,
|
|
53122
53121
|
containerClassName,
|
|
53123
53122
|
focusedItemIndex,
|
|
53124
|
-
setFocusedItemIndex
|
|
53123
|
+
setFocusedItemIndex,
|
|
53124
|
+
suggestionItemComponents = defaultComponents
|
|
53125
53125
|
}) => {
|
|
53126
53126
|
const { AutocompleteSuggestionItem = SuggestionListItem } = useComponentContext();
|
|
53127
53127
|
const messageComposer = useMessageComposer();
|
|
53128
53128
|
const { textComposer } = messageComposer;
|
|
53129
53129
|
const { suggestions } = useStateStore(textComposer.state, textComposerStateSelector);
|
|
53130
53130
|
const { items } = useStateStore(suggestions?.searchSource.state, searchSourceStateSelector) ?? {};
|
|
53131
|
-
const [container, setContainer] = (0,
|
|
53132
|
-
const component = suggestions?.trigger
|
|
53133
|
-
(0,
|
|
53131
|
+
const [container, setContainer] = (0, import_react238.useState)(null);
|
|
53132
|
+
const component = suggestions?.trigger ? suggestionItemComponents[suggestions?.trigger] : void 0;
|
|
53133
|
+
(0, import_react238.useEffect)(() => {
|
|
53134
53134
|
if (!closeOnClickOutside || !suggestions || !container) return;
|
|
53135
53135
|
const handleClick = (event) => {
|
|
53136
53136
|
if (container.contains(event.target)) return;
|
|
@@ -53142,19 +53142,19 @@ var SuggestionList = ({
|
|
|
53142
53142
|
};
|
|
53143
53143
|
}, [closeOnClickOutside, suggestions, container, textComposer]);
|
|
53144
53144
|
if (!suggestions || !items?.length || !component) return null;
|
|
53145
|
-
return /* @__PURE__ */
|
|
53145
|
+
return /* @__PURE__ */ import_react238.default.createElement(
|
|
53146
53146
|
"div",
|
|
53147
53147
|
{
|
|
53148
53148
|
className: (0, import_clsx60.default)("str-chat__suggestion-list-container", containerClassName),
|
|
53149
53149
|
ref: setContainer
|
|
53150
53150
|
},
|
|
53151
|
-
/* @__PURE__ */
|
|
53151
|
+
/* @__PURE__ */ import_react238.default.createElement(
|
|
53152
53152
|
InfiniteScrollPaginator,
|
|
53153
53153
|
{
|
|
53154
53154
|
loadNextOnScrollToBottom: suggestions.searchSource.search,
|
|
53155
53155
|
threshold: 100
|
|
53156
53156
|
},
|
|
53157
|
-
/* @__PURE__ */
|
|
53157
|
+
/* @__PURE__ */ import_react238.default.createElement(
|
|
53158
53158
|
"ul",
|
|
53159
53159
|
{
|
|
53160
53160
|
className: (0, import_clsx60.default)(
|
|
@@ -53162,7 +53162,7 @@ var SuggestionList = ({
|
|
|
53162
53162
|
className
|
|
53163
53163
|
)
|
|
53164
53164
|
},
|
|
53165
|
-
items.map((item, i) => /* @__PURE__ */
|
|
53165
|
+
items.map((item, i) => /* @__PURE__ */ import_react238.default.createElement(
|
|
53166
53166
|
AutocompleteSuggestionItem,
|
|
53167
53167
|
{
|
|
53168
53168
|
component,
|
|
@@ -53179,7 +53179,7 @@ var SuggestionList = ({
|
|
|
53179
53179
|
|
|
53180
53180
|
// src/components/TextareaComposer/TextareaComposer.tsx
|
|
53181
53181
|
var import_clsx61 = __toESM(require("clsx"));
|
|
53182
|
-
var
|
|
53182
|
+
var import_react239 = __toESM(require("react"));
|
|
53183
53183
|
var import_react_textarea_autosize = __toESM(require("react-textarea-autosize"));
|
|
53184
53184
|
var textComposerStateSelector2 = (state) => ({
|
|
53185
53185
|
selection: state.selection,
|
|
@@ -53235,10 +53235,10 @@ var TextareaComposer = ({
|
|
|
53235
53235
|
);
|
|
53236
53236
|
const { enabled } = useStateStore(messageComposer.configState, configStateSelector);
|
|
53237
53237
|
const { isLoadingItems } = useStateStore(suggestions?.searchSource.state, searchSourceStateSelector2) ?? {};
|
|
53238
|
-
const containerRef = (0,
|
|
53239
|
-
const [focusedItemIndex, setFocusedItemIndex] = (0,
|
|
53240
|
-
const [isComposing, setIsComposing] = (0,
|
|
53241
|
-
const changeHandler = (0,
|
|
53238
|
+
const containerRef = (0, import_react239.useRef)(null);
|
|
53239
|
+
const [focusedItemIndex, setFocusedItemIndex] = (0, import_react239.useState)(0);
|
|
53240
|
+
const [isComposing, setIsComposing] = (0, import_react239.useState)(false);
|
|
53241
|
+
const changeHandler = (0, import_react239.useCallback)(
|
|
53242
53242
|
(e) => {
|
|
53243
53243
|
if (onChange) {
|
|
53244
53244
|
onChange(e);
|
|
@@ -53255,13 +53255,13 @@ var TextareaComposer = ({
|
|
|
53255
53255
|
},
|
|
53256
53256
|
[onChange, textComposer, textareaRef]
|
|
53257
53257
|
);
|
|
53258
|
-
const onCompositionEnd = (0,
|
|
53258
|
+
const onCompositionEnd = (0, import_react239.useCallback)(() => {
|
|
53259
53259
|
setIsComposing(false);
|
|
53260
53260
|
}, []);
|
|
53261
|
-
const onCompositionStart = (0,
|
|
53261
|
+
const onCompositionStart = (0, import_react239.useCallback)(() => {
|
|
53262
53262
|
setIsComposing(true);
|
|
53263
53263
|
}, []);
|
|
53264
|
-
const keyDownHandler = (0,
|
|
53264
|
+
const keyDownHandler = (0, import_react239.useCallback)(
|
|
53265
53265
|
(event) => {
|
|
53266
53266
|
if (onKeyDown) {
|
|
53267
53267
|
onKeyDown(event);
|
|
@@ -53315,7 +53315,7 @@ var TextareaComposer = ({
|
|
|
53315
53315
|
textareaRef
|
|
53316
53316
|
]
|
|
53317
53317
|
);
|
|
53318
|
-
const scrollHandler = (0,
|
|
53318
|
+
const scrollHandler = (0, import_react239.useCallback)(
|
|
53319
53319
|
(event) => {
|
|
53320
53320
|
if (onScroll) {
|
|
53321
53321
|
onScroll(event);
|
|
@@ -53325,18 +53325,18 @@ var TextareaComposer = ({
|
|
|
53325
53325
|
},
|
|
53326
53326
|
[onScroll, textComposer]
|
|
53327
53327
|
);
|
|
53328
|
-
(0,
|
|
53328
|
+
(0, import_react239.useEffect)(() => {
|
|
53329
53329
|
if (textareaRef.current && !isComposing) {
|
|
53330
53330
|
textareaRef.current.selectionStart = selection.start;
|
|
53331
53331
|
textareaRef.current.selectionEnd = selection.end;
|
|
53332
53332
|
}
|
|
53333
53333
|
}, [text7, textareaRef, selection.start, selection.end, isComposing]);
|
|
53334
|
-
(0,
|
|
53334
|
+
(0, import_react239.useEffect)(() => {
|
|
53335
53335
|
if (textComposer.suggestions) {
|
|
53336
53336
|
setFocusedItemIndex(0);
|
|
53337
53337
|
}
|
|
53338
53338
|
}, [textComposer.suggestions]);
|
|
53339
|
-
return /* @__PURE__ */
|
|
53339
|
+
return /* @__PURE__ */ import_react239.default.createElement(
|
|
53340
53340
|
"div",
|
|
53341
53341
|
{
|
|
53342
53342
|
className: (0, import_clsx61.default)(
|
|
@@ -53349,7 +53349,7 @@ var TextareaComposer = ({
|
|
|
53349
53349
|
),
|
|
53350
53350
|
ref: containerRef
|
|
53351
53351
|
},
|
|
53352
|
-
/* @__PURE__ */
|
|
53352
|
+
/* @__PURE__ */ import_react239.default.createElement(
|
|
53353
53353
|
import_react_textarea_autosize.default,
|
|
53354
53354
|
{
|
|
53355
53355
|
...restProps,
|
|
@@ -53376,7 +53376,7 @@ var TextareaComposer = ({
|
|
|
53376
53376
|
value: text7
|
|
53377
53377
|
}
|
|
53378
53378
|
),
|
|
53379
|
-
!isComposing && /* @__PURE__ */
|
|
53379
|
+
!isComposing && /* @__PURE__ */ import_react239.default.createElement(
|
|
53380
53380
|
AutocompleteSuggestionList,
|
|
53381
53381
|
{
|
|
53382
53382
|
className: listClassName,
|
|
@@ -53389,10 +53389,10 @@ var TextareaComposer = ({
|
|
|
53389
53389
|
};
|
|
53390
53390
|
|
|
53391
53391
|
// src/components/AIStateIndicator/AIStateIndicator.tsx
|
|
53392
|
-
var
|
|
53392
|
+
var import_react241 = __toESM(require("react"));
|
|
53393
53393
|
|
|
53394
53394
|
// src/components/AIStateIndicator/hooks/useAIState.ts
|
|
53395
|
-
var
|
|
53395
|
+
var import_react240 = require("react");
|
|
53396
53396
|
var AIStates = {
|
|
53397
53397
|
Error: "AI_STATE_ERROR",
|
|
53398
53398
|
ExternalSources: "AI_STATE_EXTERNAL_SOURCES",
|
|
@@ -53401,8 +53401,8 @@ var AIStates = {
|
|
|
53401
53401
|
Thinking: "AI_STATE_THINKING"
|
|
53402
53402
|
};
|
|
53403
53403
|
var useAIState = (channel) => {
|
|
53404
|
-
const [aiState, setAiState] = (0,
|
|
53405
|
-
(0,
|
|
53404
|
+
const [aiState, setAiState] = (0, import_react240.useState)(AIStates.Idle);
|
|
53405
|
+
(0, import_react240.useEffect)(() => {
|
|
53406
53406
|
if (!channel) {
|
|
53407
53407
|
return;
|
|
53408
53408
|
}
|
|
@@ -53439,21 +53439,21 @@ var AIStateIndicator = ({
|
|
|
53439
53439
|
[AIStates.Thinking]: t("Thinking..."),
|
|
53440
53440
|
[AIStates.Generating]: t("Generating...")
|
|
53441
53441
|
};
|
|
53442
|
-
return aiState in allowedStates ? /* @__PURE__ */
|
|
53442
|
+
return aiState in allowedStates ? /* @__PURE__ */ import_react241.default.createElement("div", { className: "str-chat__ai-state-indicator-container" }, /* @__PURE__ */ import_react241.default.createElement("p", { className: "str-chat__ai-state-indicator-text" }, allowedStates[aiState])) : null;
|
|
53443
53443
|
};
|
|
53444
53444
|
|
|
53445
53445
|
// src/components/MessageInput/WithDragAndDropUpload.tsx
|
|
53446
|
-
var
|
|
53446
|
+
var import_react242 = __toESM(require("react"));
|
|
53447
53447
|
var import_react_dropzone = require("react-dropzone");
|
|
53448
53448
|
var import_clsx62 = __toESM(require("clsx"));
|
|
53449
|
-
var DragAndDropUploadContext =
|
|
53449
|
+
var DragAndDropUploadContext = import_react242.default.createContext({
|
|
53450
53450
|
subscribeToDrop: null
|
|
53451
53451
|
});
|
|
53452
|
-
var useDragAndDropUploadContext = () => (0,
|
|
53452
|
+
var useDragAndDropUploadContext = () => (0, import_react242.useContext)(DragAndDropUploadContext);
|
|
53453
53453
|
var useRegisterDropHandlers = () => {
|
|
53454
53454
|
const { subscribeToDrop } = useDragAndDropUploadContext();
|
|
53455
53455
|
const messageComposer = useMessageComposer();
|
|
53456
|
-
(0,
|
|
53456
|
+
(0, import_react242.useEffect)(() => {
|
|
53457
53457
|
const unsubscribe = subscribeToDrop?.(messageComposer.attachmentManager.uploadFiles);
|
|
53458
53458
|
return unsubscribe;
|
|
53459
53459
|
}, [subscribeToDrop, messageComposer]);
|
|
@@ -53468,7 +53468,7 @@ var WithDragAndDropUpload = ({
|
|
|
53468
53468
|
component: Component2 = "div",
|
|
53469
53469
|
style
|
|
53470
53470
|
}) => {
|
|
53471
|
-
const dropHandlersRef = (0,
|
|
53471
|
+
const dropHandlersRef = (0, import_react242.useRef)(/* @__PURE__ */ new Set());
|
|
53472
53472
|
const { t } = useTranslationContext();
|
|
53473
53473
|
const messageInputContext = useMessageInputContext();
|
|
53474
53474
|
const dragAndDropUploadContext = useDragAndDropUploadContext();
|
|
@@ -53479,20 +53479,20 @@ var WithDragAndDropUpload = ({
|
|
|
53479
53479
|
attachmentManagerConfigStateSelector
|
|
53480
53480
|
);
|
|
53481
53481
|
const isWithinMessageInputContext = Object.keys(messageInputContext).length > 0;
|
|
53482
|
-
const accept = (0,
|
|
53482
|
+
const accept = (0, import_react242.useMemo)(
|
|
53483
53483
|
() => acceptedFiles.reduce((mediaTypeMap, mediaType) => {
|
|
53484
53484
|
mediaTypeMap[mediaType] ?? (mediaTypeMap[mediaType] = []);
|
|
53485
53485
|
return mediaTypeMap;
|
|
53486
53486
|
}, {}),
|
|
53487
53487
|
[acceptedFiles]
|
|
53488
53488
|
);
|
|
53489
|
-
const subscribeToDrop = (0,
|
|
53489
|
+
const subscribeToDrop = (0, import_react242.useCallback)((fn) => {
|
|
53490
53490
|
dropHandlersRef.current.add(fn);
|
|
53491
53491
|
return () => {
|
|
53492
53492
|
dropHandlersRef.current.delete(fn);
|
|
53493
53493
|
};
|
|
53494
53494
|
}, []);
|
|
53495
|
-
const handleDrop = (0,
|
|
53495
|
+
const handleDrop = (0, import_react242.useCallback)((files) => {
|
|
53496
53496
|
dropHandlersRef.current.forEach((fn) => fn(files));
|
|
53497
53497
|
}, []);
|
|
53498
53498
|
const { getRootProps, isDragActive, isDragReject } = (0, import_react_dropzone.useDropzone)({
|
|
@@ -53505,24 +53505,24 @@ var WithDragAndDropUpload = ({
|
|
|
53505
53505
|
onDrop: isWithinMessageInputContext ? messageComposer.attachmentManager.uploadFiles : handleDrop
|
|
53506
53506
|
});
|
|
53507
53507
|
if (dragAndDropUploadContext.subscribeToDrop !== null) {
|
|
53508
|
-
return /* @__PURE__ */
|
|
53508
|
+
return /* @__PURE__ */ import_react242.default.createElement(Component2, { className }, children);
|
|
53509
53509
|
}
|
|
53510
|
-
return /* @__PURE__ */
|
|
53510
|
+
return /* @__PURE__ */ import_react242.default.createElement(
|
|
53511
53511
|
DragAndDropUploadContext.Provider,
|
|
53512
53512
|
{
|
|
53513
53513
|
value: {
|
|
53514
53514
|
subscribeToDrop
|
|
53515
53515
|
}
|
|
53516
53516
|
},
|
|
53517
|
-
/* @__PURE__ */
|
|
53517
|
+
/* @__PURE__ */ import_react242.default.createElement(Component2, { ...getRootProps({ className, style }) }, isDragActive && /* @__PURE__ */ import_react242.default.createElement(
|
|
53518
53518
|
"div",
|
|
53519
53519
|
{
|
|
53520
53520
|
className: (0, import_clsx62.default)("str-chat__dropzone-container", {
|
|
53521
53521
|
"str-chat__dropzone-container--not-accepted": isDragReject
|
|
53522
53522
|
})
|
|
53523
53523
|
},
|
|
53524
|
-
!isDragReject && /* @__PURE__ */
|
|
53525
|
-
isDragReject && /* @__PURE__ */
|
|
53524
|
+
!isDragReject && /* @__PURE__ */ import_react242.default.createElement("p", null, t("Drag your files here")),
|
|
53525
|
+
isDragReject && /* @__PURE__ */ import_react242.default.createElement("p", null, t("Some of the files will not be accepted"))
|
|
53526
53526
|
), children)
|
|
53527
53527
|
);
|
|
53528
53528
|
};
|
|
@@ -53553,33 +53553,33 @@ var MessageInputFlat = () => {
|
|
|
53553
53553
|
} = useComponentContext("MessageInputFlat");
|
|
53554
53554
|
const { channel } = useChatContext("MessageInputFlat");
|
|
53555
53555
|
const { aiState } = useAIState(channel);
|
|
53556
|
-
const stopGenerating = (0,
|
|
53556
|
+
const stopGenerating = (0, import_react243.useCallback)(() => channel?.stopAIResponse(), [channel]);
|
|
53557
53557
|
const [
|
|
53558
53558
|
showRecordingPermissionDeniedNotification,
|
|
53559
53559
|
setShowRecordingPermissionDeniedNotification
|
|
53560
|
-
] = (0,
|
|
53561
|
-
const closePermissionDeniedNotification = (0,
|
|
53560
|
+
] = (0, import_react243.useState)(false);
|
|
53561
|
+
const closePermissionDeniedNotification = (0, import_react243.useCallback)(() => {
|
|
53562
53562
|
setShowRecordingPermissionDeniedNotification(false);
|
|
53563
53563
|
}, []);
|
|
53564
53564
|
const { attachments } = useAttachmentManagerState();
|
|
53565
|
-
if (recordingController.recordingState) return /* @__PURE__ */
|
|
53565
|
+
if (recordingController.recordingState) return /* @__PURE__ */ import_react243.default.createElement(AudioRecorder2, null);
|
|
53566
53566
|
const recordingEnabled = !!(recordingController.recorder && navigator.mediaDevices);
|
|
53567
53567
|
const isRecording = !!recordingController.recordingState;
|
|
53568
53568
|
const StopAIGenerationButton2 = StopAIGenerationButtonOverride === void 0 ? StopAIGenerationButton : StopAIGenerationButtonOverride;
|
|
53569
53569
|
const shouldDisplayStopAIGeneration = [AIStates.Thinking, AIStates.Generating].includes(aiState) && !!StopAIGenerationButton2;
|
|
53570
|
-
return /* @__PURE__ */
|
|
53570
|
+
return /* @__PURE__ */ import_react243.default.createElement(WithDragAndDropUpload, { className: "str-chat__message-input", component: "div" }, recordingEnabled && recordingController.permissionState === "denied" && showRecordingPermissionDeniedNotification && /* @__PURE__ */ import_react243.default.createElement(
|
|
53571
53571
|
RecordingPermissionDeniedNotification2,
|
|
53572
53572
|
{
|
|
53573
53573
|
onClose: closePermissionDeniedNotification,
|
|
53574
53574
|
permissionName: "microphone" /* MIC */
|
|
53575
53575
|
}
|
|
53576
|
-
), /* @__PURE__ */
|
|
53576
|
+
), /* @__PURE__ */ import_react243.default.createElement(LinkPreviewList2, null), /* @__PURE__ */ import_react243.default.createElement(QuotedMessagePreviewHeader, null), /* @__PURE__ */ import_react243.default.createElement("div", { className: "str-chat__message-input-inner" }, /* @__PURE__ */ import_react243.default.createElement(AttachmentSelector2, null), /* @__PURE__ */ import_react243.default.createElement("div", { className: "str-chat__message-textarea-container" }, /* @__PURE__ */ import_react243.default.createElement(QuotedMessagePreview2, null), /* @__PURE__ */ import_react243.default.createElement(AttachmentPreviewList2, null), /* @__PURE__ */ import_react243.default.createElement("div", { className: "str-chat__message-textarea-with-emoji-picker" }, /* @__PURE__ */ import_react243.default.createElement(TextareaComposer, null), EmojiPicker && /* @__PURE__ */ import_react243.default.createElement(EmojiPicker, null))), shouldDisplayStopAIGeneration ? /* @__PURE__ */ import_react243.default.createElement(StopAIGenerationButton2, { onClick: stopGenerating }) : !hideSendButton && /* @__PURE__ */ import_react243.default.createElement(import_react243.default.Fragment, null, cooldownRemaining ? /* @__PURE__ */ import_react243.default.createElement(
|
|
53577
53577
|
CooldownTimer2,
|
|
53578
53578
|
{
|
|
53579
53579
|
cooldownInterval: cooldownRemaining,
|
|
53580
53580
|
setCooldownRemaining
|
|
53581
53581
|
}
|
|
53582
|
-
) : /* @__PURE__ */
|
|
53582
|
+
) : /* @__PURE__ */ import_react243.default.createElement(import_react243.default.Fragment, null, /* @__PURE__ */ import_react243.default.createElement(SendButton2, { sendMessage: handleSubmit }), recordingEnabled && /* @__PURE__ */ import_react243.default.createElement(
|
|
53583
53583
|
StartRecordingAudioButton2,
|
|
53584
53584
|
{
|
|
53585
53585
|
disabled: isRecording || !asyncMessagesMultiSendEnabled && attachments.some(
|
|
@@ -53594,7 +53594,7 @@ var MessageInputFlat = () => {
|
|
|
53594
53594
|
};
|
|
53595
53595
|
|
|
53596
53596
|
// src/components/MessageInput/hooks/useCreateMessageInputContext.ts
|
|
53597
|
-
var
|
|
53597
|
+
var import_react244 = require("react");
|
|
53598
53598
|
var useCreateMessageInputContext = (value) => {
|
|
53599
53599
|
const {
|
|
53600
53600
|
additionalTextareaProps,
|
|
@@ -53620,7 +53620,7 @@ var useCreateMessageInputContext = (value) => {
|
|
|
53620
53620
|
textareaRef
|
|
53621
53621
|
} = value;
|
|
53622
53622
|
const parentId = parent?.id;
|
|
53623
|
-
const messageInputContext = (0,
|
|
53623
|
+
const messageInputContext = (0, import_react244.useMemo)(
|
|
53624
53624
|
() => ({
|
|
53625
53625
|
additionalTextareaProps,
|
|
53626
53626
|
asyncMessagesMultiSendEnabled,
|
|
@@ -53674,13 +53674,13 @@ var MessageInputProvider = (props) => {
|
|
|
53674
53674
|
emojiSearchIndex: props.emojiSearchIndex ?? emojiSearchIndex
|
|
53675
53675
|
});
|
|
53676
53676
|
const messageComposer = useMessageComposer();
|
|
53677
|
-
(0,
|
|
53677
|
+
(0, import_react245.useEffect)(
|
|
53678
53678
|
() => () => {
|
|
53679
53679
|
messageComposer.createDraft();
|
|
53680
53680
|
},
|
|
53681
53681
|
[messageComposer]
|
|
53682
53682
|
);
|
|
53683
|
-
(0,
|
|
53683
|
+
(0, import_react245.useEffect)(() => {
|
|
53684
53684
|
const threadId = messageComposer.threadId;
|
|
53685
53685
|
if (!threadId || !messageComposer.channel || !messageComposer.compositionIsEmpty)
|
|
53686
53686
|
return;
|
|
@@ -53691,16 +53691,16 @@ var MessageInputProvider = (props) => {
|
|
|
53691
53691
|
});
|
|
53692
53692
|
}, [messageComposer]);
|
|
53693
53693
|
useRegisterDropHandlers();
|
|
53694
|
-
return /* @__PURE__ */
|
|
53694
|
+
return /* @__PURE__ */ import_react245.default.createElement(MessageInputContextProvider, { value: messageInputContextValue }, props.children);
|
|
53695
53695
|
};
|
|
53696
53696
|
var UnMemoizedMessageInput = (props) => {
|
|
53697
53697
|
const { Input: PropInput } = props;
|
|
53698
53698
|
const { Input: ContextInput } = useComponentContext("MessageInput");
|
|
53699
53699
|
const Input = PropInput || ContextInput || MessageInputFlat;
|
|
53700
53700
|
const dialogManagerId = props.isThreadInput ? "message-input-dialog-manager-thread" : "message-input-dialog-manager";
|
|
53701
|
-
return /* @__PURE__ */
|
|
53701
|
+
return /* @__PURE__ */ import_react245.default.createElement(DialogManagerProvider, { id: dialogManagerId }, /* @__PURE__ */ import_react245.default.createElement(MessageInputProvider, { ...props }, /* @__PURE__ */ import_react245.default.createElement(Input, null)));
|
|
53702
53702
|
};
|
|
53703
|
-
var MessageInput =
|
|
53703
|
+
var MessageInput = import_react245.default.memo(
|
|
53704
53704
|
UnMemoizedMessageInput
|
|
53705
53705
|
);
|
|
53706
53706
|
|
|
@@ -53708,7 +53708,7 @@ var MessageInput = import_react246.default.memo(
|
|
|
53708
53708
|
var EditMessageFormSendButton = () => {
|
|
53709
53709
|
const { t } = useTranslationContext();
|
|
53710
53710
|
const hasSendableData = useMessageComposerHasSendableData();
|
|
53711
|
-
return /* @__PURE__ */
|
|
53711
|
+
return /* @__PURE__ */ import_react246.default.createElement(
|
|
53712
53712
|
"button",
|
|
53713
53713
|
{
|
|
53714
53714
|
className: "str-chat__edit-message-send",
|
|
@@ -53723,26 +53723,26 @@ var EditMessageForm = () => {
|
|
|
53723
53723
|
const { t } = useTranslationContext("EditMessageForm");
|
|
53724
53724
|
const messageComposer = useMessageComposer();
|
|
53725
53725
|
const { clearEditingState, handleSubmit } = useMessageInputContext("EditMessageForm");
|
|
53726
|
-
const cancel = (0,
|
|
53726
|
+
const cancel = (0, import_react246.useCallback)(() => {
|
|
53727
53727
|
clearEditingState?.();
|
|
53728
53728
|
messageComposer.restore();
|
|
53729
53729
|
}, [clearEditingState, messageComposer]);
|
|
53730
|
-
(0,
|
|
53730
|
+
(0, import_react246.useEffect)(() => {
|
|
53731
53731
|
const onKeyDown = (event) => {
|
|
53732
53732
|
if (event.key === "Escape") cancel();
|
|
53733
53733
|
};
|
|
53734
53734
|
document.addEventListener("keydown", onKeyDown);
|
|
53735
53735
|
return () => document.removeEventListener("keydown", onKeyDown);
|
|
53736
53736
|
}, [cancel]);
|
|
53737
|
-
return /* @__PURE__ */
|
|
53737
|
+
return /* @__PURE__ */ import_react246.default.createElement(
|
|
53738
53738
|
"form",
|
|
53739
53739
|
{
|
|
53740
53740
|
autoComplete: "off",
|
|
53741
53741
|
className: "str-chat__edit-message-form",
|
|
53742
53742
|
onSubmit: handleSubmit
|
|
53743
53743
|
},
|
|
53744
|
-
/* @__PURE__ */
|
|
53745
|
-
/* @__PURE__ */
|
|
53744
|
+
/* @__PURE__ */ import_react246.default.createElement(MessageInputFlat, null),
|
|
53745
|
+
/* @__PURE__ */ import_react246.default.createElement("div", { className: "str-chat__edit-message-form-options" }, /* @__PURE__ */ import_react246.default.createElement(
|
|
53746
53746
|
"button",
|
|
53747
53747
|
{
|
|
53748
53748
|
className: "str-chat__edit-message-cancel",
|
|
@@ -53750,7 +53750,7 @@ var EditMessageForm = () => {
|
|
|
53750
53750
|
onClick: cancel
|
|
53751
53751
|
},
|
|
53752
53752
|
t("Cancel")
|
|
53753
|
-
), /* @__PURE__ */
|
|
53753
|
+
), /* @__PURE__ */ import_react246.default.createElement(EditMessageFormSendButton, null))
|
|
53754
53754
|
);
|
|
53755
53755
|
};
|
|
53756
53756
|
var EditMessageModal = ({
|
|
@@ -53759,18 +53759,18 @@ var EditMessageModal = ({
|
|
|
53759
53759
|
const { EditMessageInput = EditMessageForm } = useComponentContext();
|
|
53760
53760
|
const { clearEditingState } = useMessageContext();
|
|
53761
53761
|
const messageComposer = useMessageComposer();
|
|
53762
|
-
const onEditModalClose = (0,
|
|
53762
|
+
const onEditModalClose = (0, import_react246.useCallback)(() => {
|
|
53763
53763
|
clearEditingState();
|
|
53764
53764
|
messageComposer.restore();
|
|
53765
53765
|
}, [clearEditingState, messageComposer]);
|
|
53766
|
-
return /* @__PURE__ */
|
|
53766
|
+
return /* @__PURE__ */ import_react246.default.createElement(
|
|
53767
53767
|
Modal,
|
|
53768
53768
|
{
|
|
53769
53769
|
className: "str-chat__edit-message-modal",
|
|
53770
53770
|
onClose: onEditModalClose,
|
|
53771
53771
|
open: true
|
|
53772
53772
|
},
|
|
53773
|
-
/* @__PURE__ */
|
|
53773
|
+
/* @__PURE__ */ import_react246.default.createElement(
|
|
53774
53774
|
MessageInput,
|
|
53775
53775
|
{
|
|
53776
53776
|
clearEditingState,
|
|
@@ -53788,12 +53788,12 @@ var attachmentManagerConfigStateSelector2 = (state) => ({
|
|
|
53788
53788
|
acceptedFiles: state.attachments.acceptedFiles,
|
|
53789
53789
|
maxNumberOfFilesPerMessage: state.attachments.maxNumberOfFilesPerMessage
|
|
53790
53790
|
});
|
|
53791
|
-
var UploadButton = (0,
|
|
53791
|
+
var UploadButton = (0, import_react247.forwardRef)(function UploadButton2({ onFileChange, resetOnChange = true, ...rest }, ref) {
|
|
53792
53792
|
const handleInputChange = useHandleFileChangeWrapper(resetOnChange, onFileChange);
|
|
53793
|
-
return /* @__PURE__ */
|
|
53793
|
+
return /* @__PURE__ */ import_react247.default.createElement("input", { onChange: handleInputChange, ref, type: "file", ...rest });
|
|
53794
53794
|
});
|
|
53795
53795
|
var FileInput = UploadButton;
|
|
53796
|
-
var UploadFileInput = (0,
|
|
53796
|
+
var UploadFileInput = (0, import_react247.forwardRef)(function UploadFileInput2({
|
|
53797
53797
|
className,
|
|
53798
53798
|
onFileChange: onFileChangeCustom,
|
|
53799
53799
|
...props
|
|
@@ -53807,15 +53807,15 @@ var UploadFileInput = (0, import_react248.forwardRef)(function UploadFileInput2(
|
|
|
53807
53807
|
messageComposer.configState,
|
|
53808
53808
|
attachmentManagerConfigStateSelector2
|
|
53809
53809
|
);
|
|
53810
|
-
const id = (0,
|
|
53811
|
-
const onFileChange = (0,
|
|
53810
|
+
const id = (0, import_react247.useMemo)(() => (0, import_nanoid5.nanoid)(), []);
|
|
53811
|
+
const onFileChange = (0, import_react247.useCallback)(
|
|
53812
53812
|
(files) => {
|
|
53813
53813
|
attachmentManager.uploadFiles(files);
|
|
53814
53814
|
onFileChangeCustom?.(files);
|
|
53815
53815
|
},
|
|
53816
53816
|
[onFileChangeCustom, attachmentManager]
|
|
53817
53817
|
);
|
|
53818
|
-
return /* @__PURE__ */
|
|
53818
|
+
return /* @__PURE__ */ import_react247.default.createElement(
|
|
53819
53819
|
FileInput,
|
|
53820
53820
|
{
|
|
53821
53821
|
accept: acceptedFiles?.join(","),
|
|
@@ -53862,7 +53862,7 @@ var VoiceRecordingPlayer = ({
|
|
|
53862
53862
|
});
|
|
53863
53863
|
if (!asset_url) return null;
|
|
53864
53864
|
const displayedDuration = secondsElapsed || duration;
|
|
53865
|
-
return /* @__PURE__ */
|
|
53865
|
+
return /* @__PURE__ */ import_react248.default.createElement("div", { className: rootClassName, "data-testid": "voice-recording-widget" }, /* @__PURE__ */ import_react248.default.createElement("audio", { ref: audioRef }, /* @__PURE__ */ import_react248.default.createElement("source", { "data-testid": "audio-source", src: asset_url, type: mime_type })), /* @__PURE__ */ import_react248.default.createElement(PlayButton, { isPlaying, onClick: togglePlay }), /* @__PURE__ */ import_react248.default.createElement("div", { className: "str-chat__message-attachment__voice-recording-widget__metadata" }, /* @__PURE__ */ import_react248.default.createElement(
|
|
53866
53866
|
"div",
|
|
53867
53867
|
{
|
|
53868
53868
|
className: "str-chat__message-attachment__voice-recording-widget__title",
|
|
@@ -53870,25 +53870,25 @@ var VoiceRecordingPlayer = ({
|
|
|
53870
53870
|
title
|
|
53871
53871
|
},
|
|
53872
53872
|
title
|
|
53873
|
-
), /* @__PURE__ */
|
|
53873
|
+
), /* @__PURE__ */ import_react248.default.createElement("div", { className: "str-chat__message-attachment__voice-recording-widget__audio-state" }, /* @__PURE__ */ import_react248.default.createElement("div", { className: "str-chat__message-attachment__voice-recording-widget__timer" }, attachment.duration ? displayDuration(displayedDuration) : /* @__PURE__ */ import_react248.default.createElement(
|
|
53874
53874
|
FileSizeIndicator,
|
|
53875
53875
|
{
|
|
53876
53876
|
fileSize: attachment.file_size,
|
|
53877
53877
|
maximumFractionDigits: 0
|
|
53878
53878
|
}
|
|
53879
|
-
)), /* @__PURE__ */
|
|
53879
|
+
)), /* @__PURE__ */ import_react248.default.createElement(
|
|
53880
53880
|
WaveProgressBar,
|
|
53881
53881
|
{
|
|
53882
53882
|
progress,
|
|
53883
53883
|
seek,
|
|
53884
53884
|
waveformData: waveform_data || []
|
|
53885
53885
|
}
|
|
53886
|
-
))), /* @__PURE__ */
|
|
53886
|
+
))), /* @__PURE__ */ import_react248.default.createElement("div", { className: "str-chat__message-attachment__voice-recording-widget__right-section" }, isPlaying ? /* @__PURE__ */ import_react248.default.createElement(PlaybackRateButton, { disabled: !audioRef.current, onClick: increasePlaybackRate }, playbackRate.toFixed(1), "x") : /* @__PURE__ */ import_react248.default.createElement(FileIcon, { big: true, mimeType: mime_type, size: 40 })));
|
|
53887
53887
|
};
|
|
53888
53888
|
var QuotedVoiceRecording = ({ attachment }) => {
|
|
53889
53889
|
const { t } = useTranslationContext();
|
|
53890
53890
|
const title = attachment.title || t("Voice message");
|
|
53891
|
-
return /* @__PURE__ */
|
|
53891
|
+
return /* @__PURE__ */ import_react248.default.createElement("div", { className: rootClassName, "data-testid": "quoted-voice-recording-widget" }, /* @__PURE__ */ import_react248.default.createElement("div", { className: "str-chat__message-attachment__voice-recording-widget__metadata" }, title && /* @__PURE__ */ import_react248.default.createElement(
|
|
53892
53892
|
"div",
|
|
53893
53893
|
{
|
|
53894
53894
|
className: "str-chat__message-attachment__voice-recording-widget__title",
|
|
@@ -53896,18 +53896,18 @@ var QuotedVoiceRecording = ({ attachment }) => {
|
|
|
53896
53896
|
title
|
|
53897
53897
|
},
|
|
53898
53898
|
title
|
|
53899
|
-
), /* @__PURE__ */
|
|
53899
|
+
), /* @__PURE__ */ import_react248.default.createElement("div", { className: "str-chat__message-attachment__voice-recording-widget__audio-state" }, /* @__PURE__ */ import_react248.default.createElement("div", { className: "str-chat__message-attachment__voice-recording-widget__timer" }, attachment.duration ? displayDuration(attachment.duration) : /* @__PURE__ */ import_react248.default.createElement(
|
|
53900
53900
|
FileSizeIndicator,
|
|
53901
53901
|
{
|
|
53902
53902
|
fileSize: attachment.file_size,
|
|
53903
53903
|
maximumFractionDigits: 0
|
|
53904
53904
|
}
|
|
53905
|
-
)))), /* @__PURE__ */
|
|
53905
|
+
)))), /* @__PURE__ */ import_react248.default.createElement(FileIcon, { big: true, mimeType: attachment.mime_type, size: 34 }));
|
|
53906
53906
|
};
|
|
53907
|
-
var VoiceRecording = ({ attachment, isQuoted }) => isQuoted ? /* @__PURE__ */
|
|
53907
|
+
var VoiceRecording = ({ attachment, isQuoted }) => isQuoted ? /* @__PURE__ */ import_react248.default.createElement(QuotedVoiceRecording, { attachment }) : /* @__PURE__ */ import_react248.default.createElement(VoiceRecordingPlayer, { attachment });
|
|
53908
53908
|
|
|
53909
53909
|
// src/components/Attachment/Card.tsx
|
|
53910
|
-
var
|
|
53910
|
+
var import_react249 = __toESM(require("react"));
|
|
53911
53911
|
var import_clsx64 = __toESM(require("clsx"));
|
|
53912
53912
|
var import_react_player = __toESM(require("react-player"));
|
|
53913
53913
|
var getHostFromURL = (url) => {
|
|
@@ -53919,26 +53919,26 @@ var getHostFromURL = (url) => {
|
|
|
53919
53919
|
};
|
|
53920
53920
|
var UnableToRenderCard = ({ type }) => {
|
|
53921
53921
|
const { t } = useTranslationContext("Card");
|
|
53922
|
-
return /* @__PURE__ */
|
|
53922
|
+
return /* @__PURE__ */ import_react249.default.createElement(
|
|
53923
53923
|
"div",
|
|
53924
53924
|
{
|
|
53925
53925
|
className: (0, import_clsx64.default)("str-chat__message-attachment-card", {
|
|
53926
53926
|
[`str-chat__message-attachment-card--${type}`]: type
|
|
53927
53927
|
})
|
|
53928
53928
|
},
|
|
53929
|
-
/* @__PURE__ */
|
|
53929
|
+
/* @__PURE__ */ import_react249.default.createElement("div", { className: "str-chat__message-attachment-card--content" }, /* @__PURE__ */ import_react249.default.createElement("div", { className: "str-chat__message-attachment-card--text" }, t("this content could not be displayed")))
|
|
53930
53930
|
);
|
|
53931
53931
|
};
|
|
53932
53932
|
var SourceLink = ({
|
|
53933
53933
|
author_name,
|
|
53934
53934
|
url
|
|
53935
|
-
}) => /* @__PURE__ */
|
|
53935
|
+
}) => /* @__PURE__ */ import_react249.default.createElement(
|
|
53936
53936
|
"div",
|
|
53937
53937
|
{
|
|
53938
53938
|
className: "str-chat__message-attachment-card--source-link",
|
|
53939
53939
|
"data-testid": "card-source-link"
|
|
53940
53940
|
},
|
|
53941
|
-
/* @__PURE__ */
|
|
53941
|
+
/* @__PURE__ */ import_react249.default.createElement(
|
|
53942
53942
|
SafeAnchor,
|
|
53943
53943
|
{
|
|
53944
53944
|
className: "str-chat__message-attachment-card--url",
|
|
@@ -53953,7 +53953,7 @@ var CardHeader = (props) => {
|
|
|
53953
53953
|
const { asset_url, dimensions, image: image3, image_url, thumb_url, title, type } = props;
|
|
53954
53954
|
let visual = null;
|
|
53955
53955
|
if (asset_url && type === "video") {
|
|
53956
|
-
visual = /* @__PURE__ */
|
|
53956
|
+
visual = /* @__PURE__ */ import_react249.default.createElement(
|
|
53957
53957
|
import_react_player.default,
|
|
53958
53958
|
{
|
|
53959
53959
|
className: "react-player",
|
|
@@ -53964,7 +53964,7 @@ var CardHeader = (props) => {
|
|
|
53964
53964
|
}
|
|
53965
53965
|
);
|
|
53966
53966
|
} else if (image3) {
|
|
53967
|
-
visual = /* @__PURE__ */
|
|
53967
|
+
visual = /* @__PURE__ */ import_react249.default.createElement(
|
|
53968
53968
|
ImageComponent,
|
|
53969
53969
|
{
|
|
53970
53970
|
dimensions,
|
|
@@ -53974,7 +53974,7 @@ var CardHeader = (props) => {
|
|
|
53974
53974
|
}
|
|
53975
53975
|
);
|
|
53976
53976
|
}
|
|
53977
|
-
return visual ? /* @__PURE__ */
|
|
53977
|
+
return visual ? /* @__PURE__ */ import_react249.default.createElement(
|
|
53978
53978
|
"div",
|
|
53979
53979
|
{
|
|
53980
53980
|
className: "str-chat__message-attachment-card--header str-chat__message-attachment-card-react--header",
|
|
@@ -53986,7 +53986,7 @@ var CardHeader = (props) => {
|
|
|
53986
53986
|
var CardContent = (props) => {
|
|
53987
53987
|
const { author_name, og_scrape_url, text: text7, title, title_link, type } = props;
|
|
53988
53988
|
const url = title_link || og_scrape_url;
|
|
53989
|
-
return /* @__PURE__ */
|
|
53989
|
+
return /* @__PURE__ */ import_react249.default.createElement("div", { className: "str-chat__message-attachment-card--content" }, type === "audio" ? /* @__PURE__ */ import_react249.default.createElement(CardAudio, { og: props }) : /* @__PURE__ */ import_react249.default.createElement("div", { className: "str-chat__message-attachment-card--flex" }, url && /* @__PURE__ */ import_react249.default.createElement(SourceLink, { author_name, url }), title && /* @__PURE__ */ import_react249.default.createElement("div", { className: "str-chat__message-attachment-card--title" }, title), text7 && /* @__PURE__ */ import_react249.default.createElement("div", { className: "str-chat__message-attachment-card--text" }, text7)));
|
|
53990
53990
|
};
|
|
53991
53991
|
var CardAudio = ({
|
|
53992
53992
|
og: { asset_url, author_name, mime_type, og_scrape_url, text: text7, title, title_link }
|
|
@@ -53997,7 +53997,7 @@ var CardAudio = ({
|
|
|
53997
53997
|
const url = title_link || og_scrape_url;
|
|
53998
53998
|
const dataTestId = "card-audio-widget";
|
|
53999
53999
|
const rootClassName2 = "str-chat__message-attachment-card-audio-widget";
|
|
54000
|
-
return /* @__PURE__ */
|
|
54000
|
+
return /* @__PURE__ */ import_react249.default.createElement("div", { className: rootClassName2, "data-testid": dataTestId }, asset_url && /* @__PURE__ */ import_react249.default.createElement(import_react249.default.Fragment, null, /* @__PURE__ */ import_react249.default.createElement("audio", { ref: audioRef }, /* @__PURE__ */ import_react249.default.createElement("source", { "data-testid": "audio-source", src: asset_url, type: "audio/mp3" })), /* @__PURE__ */ import_react249.default.createElement("div", { className: "str-chat__message-attachment-card-audio-widget--first-row" }, /* @__PURE__ */ import_react249.default.createElement("div", { className: "str-chat__message-attachment-audio-widget--play-controls" }, /* @__PURE__ */ import_react249.default.createElement(PlayButton, { isPlaying, onClick: togglePlay })), /* @__PURE__ */ import_react249.default.createElement(ProgressBar, { onClick: seek, progress }))), /* @__PURE__ */ import_react249.default.createElement("div", { className: "str-chat__message-attachment-audio-widget--second-row" }, url && /* @__PURE__ */ import_react249.default.createElement(SourceLink, { author_name, url }), title && /* @__PURE__ */ import_react249.default.createElement("div", { className: "str-chat__message-attachment-audio-widget--title" }, title), text7 && /* @__PURE__ */ import_react249.default.createElement("div", { className: "str-chat__message-attachment-audio-widget--description" }, text7)));
|
|
54001
54001
|
};
|
|
54002
54002
|
var UnMemoizedCard = (props) => {
|
|
54003
54003
|
const { asset_url, giphy, image_url, thumb_url, title, title_link, type } = props;
|
|
@@ -54011,45 +54011,45 @@ var UnMemoizedCard = (props) => {
|
|
|
54011
54011
|
dimensions.width = giphyVersion.width;
|
|
54012
54012
|
}
|
|
54013
54013
|
if (!title && !title_link && !asset_url && !image3) {
|
|
54014
|
-
return /* @__PURE__ */
|
|
54014
|
+
return /* @__PURE__ */ import_react249.default.createElement(UnableToRenderCard, null);
|
|
54015
54015
|
}
|
|
54016
|
-
return /* @__PURE__ */
|
|
54016
|
+
return /* @__PURE__ */ import_react249.default.createElement(
|
|
54017
54017
|
"div",
|
|
54018
54018
|
{
|
|
54019
54019
|
className: `str-chat__message-attachment-card str-chat__message-attachment-card--${type}`
|
|
54020
54020
|
},
|
|
54021
|
-
/* @__PURE__ */
|
|
54022
|
-
/* @__PURE__ */
|
|
54021
|
+
/* @__PURE__ */ import_react249.default.createElement(CardHeader, { ...props, dimensions, image: image3 }),
|
|
54022
|
+
/* @__PURE__ */ import_react249.default.createElement(CardContent, { ...props })
|
|
54023
54023
|
);
|
|
54024
54024
|
};
|
|
54025
|
-
var Card =
|
|
54025
|
+
var Card = import_react249.default.memo(UnMemoizedCard);
|
|
54026
54026
|
|
|
54027
54027
|
// src/components/Attachment/FileAttachment.tsx
|
|
54028
|
-
var
|
|
54029
|
-
var UnMemoizedFileAttachment = ({ attachment }) => /* @__PURE__ */
|
|
54028
|
+
var import_react250 = __toESM(require("react"));
|
|
54029
|
+
var UnMemoizedFileAttachment = ({ attachment }) => /* @__PURE__ */ import_react250.default.createElement("div", { className: "str-chat__message-attachment-file--item", "data-testid": "attachment-file" }, /* @__PURE__ */ import_react250.default.createElement(FileIcon, { className: "str-chat__file-icon", mimeType: attachment.mime_type }), /* @__PURE__ */ import_react250.default.createElement("div", { className: "str-chat__message-attachment-file--item-text" }, /* @__PURE__ */ import_react250.default.createElement("div", { className: "str-chat__message-attachment-file--item-first-row" }, /* @__PURE__ */ import_react250.default.createElement(
|
|
54030
54030
|
"div",
|
|
54031
54031
|
{
|
|
54032
54032
|
className: "str-chat__message-attachment-file--item-name",
|
|
54033
54033
|
"data-testid": "file-title"
|
|
54034
54034
|
},
|
|
54035
54035
|
attachment.title
|
|
54036
|
-
), /* @__PURE__ */
|
|
54037
|
-
var FileAttachment =
|
|
54036
|
+
), /* @__PURE__ */ import_react250.default.createElement(DownloadButton, { assetUrl: attachment.asset_url })), /* @__PURE__ */ import_react250.default.createElement(FileSizeIndicator, { fileSize: attachment.file_size })));
|
|
54037
|
+
var FileAttachment = import_react250.default.memo(
|
|
54038
54038
|
UnMemoizedFileAttachment
|
|
54039
54039
|
);
|
|
54040
54040
|
|
|
54041
54041
|
// src/components/Attachment/UnsupportedAttachment.tsx
|
|
54042
|
-
var
|
|
54042
|
+
var import_react251 = __toESM(require("react"));
|
|
54043
54043
|
var UnsupportedAttachment = ({ attachment }) => {
|
|
54044
54044
|
const { t } = useTranslationContext("UnsupportedAttachment");
|
|
54045
|
-
return /* @__PURE__ */
|
|
54045
|
+
return /* @__PURE__ */ import_react251.default.createElement(
|
|
54046
54046
|
"div",
|
|
54047
54047
|
{
|
|
54048
54048
|
className: "str-chat__message-attachment-unsupported",
|
|
54049
54049
|
"data-testid": "attachment-unsupported"
|
|
54050
54050
|
},
|
|
54051
|
-
/* @__PURE__ */
|
|
54052
|
-
/* @__PURE__ */
|
|
54051
|
+
/* @__PURE__ */ import_react251.default.createElement(FileIcon, { className: "str-chat__file-icon" }),
|
|
54052
|
+
/* @__PURE__ */ import_react251.default.createElement("div", { className: "str-chat__message-attachment-unsupported__metadata" }, /* @__PURE__ */ import_react251.default.createElement(
|
|
54053
54053
|
"div",
|
|
54054
54054
|
{
|
|
54055
54055
|
className: "str-chat__message-attachment-unsupported__title",
|
|
@@ -54081,7 +54081,7 @@ var AttachmentWithinContainer = ({
|
|
|
54081
54081
|
"str-chat__message-attachment-with-actions": extra === "actions"
|
|
54082
54082
|
}
|
|
54083
54083
|
);
|
|
54084
|
-
return /* @__PURE__ */
|
|
54084
|
+
return /* @__PURE__ */ import_react252.default.createElement("div", { className: classNames }, children);
|
|
54085
54085
|
};
|
|
54086
54086
|
var AttachmentActionsContainer = ({
|
|
54087
54087
|
actionHandler,
|
|
@@ -54089,7 +54089,7 @@ var AttachmentActionsContainer = ({
|
|
|
54089
54089
|
AttachmentActions: AttachmentActions2 = AttachmentActions
|
|
54090
54090
|
}) => {
|
|
54091
54091
|
if (!attachment.actions?.length) return null;
|
|
54092
|
-
return /* @__PURE__ */
|
|
54092
|
+
return /* @__PURE__ */ import_react252.default.createElement(
|
|
54093
54093
|
AttachmentActions2,
|
|
54094
54094
|
{
|
|
54095
54095
|
...attachment,
|
|
@@ -54120,10 +54120,10 @@ var GalleryContainer = ({
|
|
|
54120
54120
|
attachment,
|
|
54121
54121
|
Gallery: Gallery2 = Gallery
|
|
54122
54122
|
}) => {
|
|
54123
|
-
const imageElements = (0,
|
|
54123
|
+
const imageElements = (0, import_react252.useRef)([]);
|
|
54124
54124
|
const { imageAttachmentSizeHandler } = useChannelStateContext();
|
|
54125
|
-
const [attachmentConfigurations, setAttachmentConfigurations] = (0,
|
|
54126
|
-
(0,
|
|
54125
|
+
const [attachmentConfigurations, setAttachmentConfigurations] = (0, import_react252.useState)([]);
|
|
54126
|
+
(0, import_react252.useLayoutEffect)(() => {
|
|
54127
54127
|
if (imageElements.current && imageElements.current.every((element3) => !!element3) && imageAttachmentSizeHandler) {
|
|
54128
54128
|
const newConfigurations = [];
|
|
54129
54129
|
imageElements.current.forEach((element3, i) => {
|
|
@@ -54140,15 +54140,15 @@ var GalleryContainer = ({
|
|
|
54140
54140
|
attachment.images[i]?.image_url || attachment.images[i]?.thumb_url || ""
|
|
54141
54141
|
)
|
|
54142
54142
|
}));
|
|
54143
|
-
return /* @__PURE__ */
|
|
54143
|
+
return /* @__PURE__ */ import_react252.default.createElement(AttachmentWithinContainer, { attachment, componentType: "gallery" }, /* @__PURE__ */ import_react252.default.createElement(Gallery2, { images: images || [], innerRefs: imageElements, key: "gallery" }));
|
|
54144
54144
|
};
|
|
54145
54145
|
var ImageContainer = (props) => {
|
|
54146
54146
|
const { attachment, Image: Image2 = ImageComponent } = props;
|
|
54147
54147
|
const componentType = "image";
|
|
54148
|
-
const imageElement = (0,
|
|
54148
|
+
const imageElement = (0, import_react252.useRef)(null);
|
|
54149
54149
|
const { imageAttachmentSizeHandler } = useChannelStateContext();
|
|
54150
|
-
const [attachmentConfiguration, setAttachmentConfiguration] = (0,
|
|
54151
|
-
(0,
|
|
54150
|
+
const [attachmentConfiguration, setAttachmentConfiguration] = (0, import_react252.useState)(void 0);
|
|
54151
|
+
(0, import_react252.useLayoutEffect)(() => {
|
|
54152
54152
|
if (imageElement.current && imageAttachmentSizeHandler) {
|
|
54153
54153
|
const config = imageAttachmentSizeHandler(attachment, imageElement.current);
|
|
54154
54154
|
setAttachmentConfiguration(config);
|
|
@@ -54160,41 +54160,41 @@ var ImageContainer = (props) => {
|
|
|
54160
54160
|
style: getCssDimensionsVariables(attachment.image_url || attachment.thumb_url || "")
|
|
54161
54161
|
};
|
|
54162
54162
|
if (attachment.actions && attachment.actions.length) {
|
|
54163
|
-
return /* @__PURE__ */
|
|
54163
|
+
return /* @__PURE__ */ import_react252.default.createElement(AttachmentWithinContainer, { attachment, componentType }, /* @__PURE__ */ import_react252.default.createElement("div", { className: "str-chat__attachment" }, /* @__PURE__ */ import_react252.default.createElement(Image2, { ...imageConfig, innerRef: imageElement }), /* @__PURE__ */ import_react252.default.createElement(AttachmentActionsContainer, { ...props })));
|
|
54164
54164
|
}
|
|
54165
|
-
return /* @__PURE__ */
|
|
54165
|
+
return /* @__PURE__ */ import_react252.default.createElement(AttachmentWithinContainer, { attachment, componentType }, /* @__PURE__ */ import_react252.default.createElement(Image2, { ...imageConfig, innerRef: imageElement }));
|
|
54166
54166
|
};
|
|
54167
54167
|
var CardContainer = (props) => {
|
|
54168
54168
|
const { attachment, Card: Card2 = Card } = props;
|
|
54169
54169
|
const componentType = "card";
|
|
54170
54170
|
if (attachment.actions && attachment.actions.length) {
|
|
54171
|
-
return /* @__PURE__ */
|
|
54171
|
+
return /* @__PURE__ */ import_react252.default.createElement(AttachmentWithinContainer, { attachment, componentType }, /* @__PURE__ */ import_react252.default.createElement("div", { className: "str-chat__attachment" }, /* @__PURE__ */ import_react252.default.createElement(Card2, { ...attachment }), /* @__PURE__ */ import_react252.default.createElement(AttachmentActionsContainer, { ...props })));
|
|
54172
54172
|
}
|
|
54173
|
-
return /* @__PURE__ */
|
|
54173
|
+
return /* @__PURE__ */ import_react252.default.createElement(AttachmentWithinContainer, { attachment, componentType }, /* @__PURE__ */ import_react252.default.createElement(Card2, { ...attachment }));
|
|
54174
54174
|
};
|
|
54175
54175
|
var FileContainer = ({
|
|
54176
54176
|
attachment,
|
|
54177
54177
|
File: File2 = FileAttachment
|
|
54178
54178
|
}) => {
|
|
54179
54179
|
if (!attachment.asset_url) return null;
|
|
54180
|
-
return /* @__PURE__ */
|
|
54180
|
+
return /* @__PURE__ */ import_react252.default.createElement(AttachmentWithinContainer, { attachment, componentType: "file" }, /* @__PURE__ */ import_react252.default.createElement(File2, { attachment }));
|
|
54181
54181
|
};
|
|
54182
54182
|
var AudioContainer = ({
|
|
54183
54183
|
attachment,
|
|
54184
54184
|
Audio: Audio2 = Audio
|
|
54185
|
-
}) => /* @__PURE__ */
|
|
54185
|
+
}) => /* @__PURE__ */ import_react252.default.createElement(AttachmentWithinContainer, { attachment, componentType: "audio" }, /* @__PURE__ */ import_react252.default.createElement("div", { className: "str-chat__attachment" }, /* @__PURE__ */ import_react252.default.createElement(Audio2, { og: attachment })));
|
|
54186
54186
|
var VoiceRecordingContainer = ({
|
|
54187
54187
|
attachment,
|
|
54188
54188
|
isQuoted,
|
|
54189
54189
|
VoiceRecording: VoiceRecording2 = VoiceRecording
|
|
54190
|
-
}) => /* @__PURE__ */
|
|
54190
|
+
}) => /* @__PURE__ */ import_react252.default.createElement(AttachmentWithinContainer, { attachment, componentType: "voiceRecording" }, /* @__PURE__ */ import_react252.default.createElement("div", { className: "str-chat__attachment" }, /* @__PURE__ */ import_react252.default.createElement(VoiceRecording2, { attachment, isQuoted })));
|
|
54191
54191
|
var MediaContainer = (props) => {
|
|
54192
54192
|
const { attachment, Media = import_react_player2.default } = props;
|
|
54193
54193
|
const componentType = "media";
|
|
54194
54194
|
const { shouldGenerateVideoThumbnail, videoAttachmentSizeHandler } = useChannelStateContext();
|
|
54195
|
-
const videoElement = (0,
|
|
54196
|
-
const [attachmentConfiguration, setAttachmentConfiguration] = (0,
|
|
54197
|
-
(0,
|
|
54195
|
+
const videoElement = (0, import_react252.useRef)(null);
|
|
54196
|
+
const [attachmentConfiguration, setAttachmentConfiguration] = (0, import_react252.useState)();
|
|
54197
|
+
(0, import_react252.useLayoutEffect)(() => {
|
|
54198
54198
|
if (videoElement.current && videoAttachmentSizeHandler) {
|
|
54199
54199
|
const config = videoAttachmentSizeHandler(
|
|
54200
54200
|
attachment,
|
|
@@ -54204,7 +54204,7 @@ var MediaContainer = (props) => {
|
|
|
54204
54204
|
setAttachmentConfiguration(config);
|
|
54205
54205
|
}
|
|
54206
54206
|
}, [videoElement, videoAttachmentSizeHandler, attachment]);
|
|
54207
|
-
const content3 = /* @__PURE__ */
|
|
54207
|
+
const content3 = /* @__PURE__ */ import_react252.default.createElement(
|
|
54208
54208
|
"div",
|
|
54209
54209
|
{
|
|
54210
54210
|
className: "str-chat__player-wrapper",
|
|
@@ -54212,7 +54212,7 @@ var MediaContainer = (props) => {
|
|
|
54212
54212
|
ref: videoElement,
|
|
54213
54213
|
style: getCssDimensionsVariables(attachment.thumb_url || "")
|
|
54214
54214
|
},
|
|
54215
|
-
/* @__PURE__ */
|
|
54215
|
+
/* @__PURE__ */ import_react252.default.createElement(
|
|
54216
54216
|
Media,
|
|
54217
54217
|
{
|
|
54218
54218
|
className: "react-player",
|
|
@@ -54224,12 +54224,12 @@ var MediaContainer = (props) => {
|
|
|
54224
54224
|
}
|
|
54225
54225
|
)
|
|
54226
54226
|
);
|
|
54227
|
-
return attachment.actions?.length ? /* @__PURE__ */
|
|
54227
|
+
return attachment.actions?.length ? /* @__PURE__ */ import_react252.default.createElement(AttachmentWithinContainer, { attachment, componentType }, /* @__PURE__ */ import_react252.default.createElement("div", { className: "str-chat__attachment" }, content3, /* @__PURE__ */ import_react252.default.createElement(AttachmentActionsContainer, { ...props }))) : /* @__PURE__ */ import_react252.default.createElement(AttachmentWithinContainer, { attachment, componentType }, content3);
|
|
54228
54228
|
};
|
|
54229
54229
|
var UnsupportedAttachmentContainer = ({
|
|
54230
54230
|
attachment,
|
|
54231
54231
|
UnsupportedAttachment: UnsupportedAttachment2 = UnsupportedAttachment
|
|
54232
|
-
}) => /* @__PURE__ */
|
|
54232
|
+
}) => /* @__PURE__ */ import_react252.default.createElement(import_react252.default.Fragment, null, /* @__PURE__ */ import_react252.default.createElement(UnsupportedAttachment2, { attachment }));
|
|
54233
54233
|
|
|
54234
54234
|
// src/components/Attachment/Attachment.tsx
|
|
54235
54235
|
var CONTAINER_MAP = {
|
|
@@ -54252,12 +54252,12 @@ var ATTACHMENT_GROUPS_ORDER = [
|
|
|
54252
54252
|
];
|
|
54253
54253
|
var Attachment = (props) => {
|
|
54254
54254
|
const { attachments } = props;
|
|
54255
|
-
const groupedAttachments = (0,
|
|
54255
|
+
const groupedAttachments = (0, import_react253.useMemo)(
|
|
54256
54256
|
() => renderGroupedAttachments(props),
|
|
54257
54257
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
54258
54258
|
[attachments]
|
|
54259
54259
|
);
|
|
54260
|
-
return /* @__PURE__ */
|
|
54260
|
+
return /* @__PURE__ */ import_react253.default.createElement("div", { className: "str-chat__attachment-list" }, ATTACHMENT_GROUPS_ORDER.reduce(
|
|
54261
54261
|
(acc, groupName) => [...acc, ...groupedAttachments[groupName]],
|
|
54262
54262
|
[]
|
|
54263
54263
|
));
|
|
@@ -54274,7 +54274,7 @@ var renderGroupedAttachments = ({
|
|
|
54274
54274
|
const attachmentType = getAttachmentType(attachment);
|
|
54275
54275
|
const Container = CONTAINER_MAP[attachmentType];
|
|
54276
54276
|
typeMap[attachmentType].push(
|
|
54277
|
-
/* @__PURE__ */
|
|
54277
|
+
/* @__PURE__ */ import_react253.default.createElement(
|
|
54278
54278
|
Container,
|
|
54279
54279
|
{
|
|
54280
54280
|
key: `${attachmentType}-${typeMap[attachmentType].length}`,
|
|
@@ -54301,7 +54301,7 @@ var renderGroupedAttachments = ({
|
|
|
54301
54301
|
);
|
|
54302
54302
|
if (uploadedImages.length > 1) {
|
|
54303
54303
|
containers["gallery"] = [
|
|
54304
|
-
/* @__PURE__ */
|
|
54304
|
+
/* @__PURE__ */ import_react253.default.createElement(
|
|
54305
54305
|
GalleryContainer,
|
|
54306
54306
|
{
|
|
54307
54307
|
key: "gallery-container",
|
|
@@ -54315,7 +54315,7 @@ var renderGroupedAttachments = ({
|
|
|
54315
54315
|
];
|
|
54316
54316
|
} else if (uploadedImages.length === 1) {
|
|
54317
54317
|
containers["image"] = [
|
|
54318
|
-
/* @__PURE__ */
|
|
54318
|
+
/* @__PURE__ */ import_react253.default.createElement(ImageContainer, { key: "image-container", ...rest, attachment: uploadedImages[0] })
|
|
54319
54319
|
];
|
|
54320
54320
|
}
|
|
54321
54321
|
return containers;
|
|
@@ -54336,7 +54336,7 @@ var getAttachmentType = (attachment) => {
|
|
|
54336
54336
|
};
|
|
54337
54337
|
|
|
54338
54338
|
// src/components/Channel/Channel.tsx
|
|
54339
|
-
var
|
|
54339
|
+
var import_react259 = __toESM(require("react"));
|
|
54340
54340
|
var import_clsx66 = __toESM(require("clsx"));
|
|
54341
54341
|
var import_lodash19 = __toESM(require("lodash.debounce"));
|
|
54342
54342
|
var import_lodash20 = __toESM(require("lodash.defaultsdeep"));
|
|
@@ -54517,7 +54517,7 @@ var initialState = {
|
|
|
54517
54517
|
};
|
|
54518
54518
|
|
|
54519
54519
|
// src/components/Channel/hooks/useCreateChannelStateContext.ts
|
|
54520
|
-
var
|
|
54520
|
+
var import_react254 = require("react");
|
|
54521
54521
|
var useCreateChannelStateContext = (value) => {
|
|
54522
54522
|
const {
|
|
54523
54523
|
channel,
|
|
@@ -54576,7 +54576,7 @@ var useCreateChannelStateContext = (value) => {
|
|
|
54576
54576
|
const memoizedThreadMessageData = threadMessages.map(
|
|
54577
54577
|
({ 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}`
|
|
54578
54578
|
).join();
|
|
54579
|
-
const channelStateContext = (0,
|
|
54579
|
+
const channelStateContext = (0, import_react254.useMemo)(
|
|
54580
54580
|
() => ({
|
|
54581
54581
|
channel,
|
|
54582
54582
|
channelCapabilities,
|
|
@@ -54640,11 +54640,11 @@ var useCreateChannelStateContext = (value) => {
|
|
|
54640
54640
|
};
|
|
54641
54641
|
|
|
54642
54642
|
// src/components/Channel/hooks/useCreateTypingContext.ts
|
|
54643
|
-
var
|
|
54643
|
+
var import_react255 = require("react");
|
|
54644
54644
|
var useCreateTypingContext = (value) => {
|
|
54645
54645
|
const { typing } = value;
|
|
54646
54646
|
const typingValue = Object.keys(typing || {}).join();
|
|
54647
|
-
const typingContext = (0,
|
|
54647
|
+
const typingContext = (0, import_react255.useMemo)(
|
|
54648
54648
|
() => ({
|
|
54649
54649
|
typing
|
|
54650
54650
|
}),
|
|
@@ -54668,10 +54668,10 @@ var useEditMessageHandler = (doUpdateMessageRequest) => {
|
|
|
54668
54668
|
};
|
|
54669
54669
|
|
|
54670
54670
|
// src/components/Channel/hooks/useIsMounted.ts
|
|
54671
|
-
var
|
|
54671
|
+
var import_react256 = require("react");
|
|
54672
54672
|
var useIsMounted = () => {
|
|
54673
|
-
const isMounted = (0,
|
|
54674
|
-
(0,
|
|
54673
|
+
const isMounted = (0, import_react256.useRef)(false);
|
|
54674
|
+
(0, import_react256.useEffect)(() => {
|
|
54675
54675
|
isMounted.current = true;
|
|
54676
54676
|
return () => {
|
|
54677
54677
|
isMounted.current = false;
|
|
@@ -54681,8 +54681,8 @@ var useIsMounted = () => {
|
|
|
54681
54681
|
};
|
|
54682
54682
|
|
|
54683
54683
|
// src/components/Channel/hooks/useMentionsHandlers.ts
|
|
54684
|
-
var
|
|
54685
|
-
var useMentionsHandlers = (onMentionsHover, onMentionsClick) => (0,
|
|
54684
|
+
var import_react257 = require("react");
|
|
54685
|
+
var useMentionsHandlers = (onMentionsHover, onMentionsClick) => (0, import_react257.useCallback)(
|
|
54686
54686
|
(event, mentioned_users) => {
|
|
54687
54687
|
if (!onMentionsHover && !onMentionsClick || !(event.target instanceof HTMLElement)) {
|
|
54688
54688
|
return;
|
|
@@ -54706,11 +54706,11 @@ var useMentionsHandlers = (onMentionsHover, onMentionsClick) => (0, import_react
|
|
|
54706
54706
|
);
|
|
54707
54707
|
|
|
54708
54708
|
// src/components/Channel/LoadingChannel.tsx
|
|
54709
|
-
var
|
|
54710
|
-
var LoadingMessage = () => /* @__PURE__ */
|
|
54711
|
-
var LoadingMessageInput = () => /* @__PURE__ */
|
|
54712
|
-
var LoadingChannelHeader = () => /* @__PURE__ */
|
|
54713
|
-
var LoadingChannel = () => /* @__PURE__ */
|
|
54709
|
+
var import_react258 = __toESM(require("react"));
|
|
54710
|
+
var LoadingMessage = () => /* @__PURE__ */ import_react258.default.createElement("div", { className: "str-chat__loading-channel-message" }, /* @__PURE__ */ import_react258.default.createElement("div", { className: "str-chat__loading-channel-message-avatar" }), /* @__PURE__ */ import_react258.default.createElement("div", { className: "str-chat__loading-channel-message-end" }, /* @__PURE__ */ import_react258.default.createElement("div", { className: "str-chat__loading-channel-message-sender" }), /* @__PURE__ */ import_react258.default.createElement("div", { className: "str-chat__loading-channel-message-last-row" }, /* @__PURE__ */ import_react258.default.createElement("div", { className: "str-chat__loading-channel-message-text" }), /* @__PURE__ */ import_react258.default.createElement("div", { className: "str-chat__loading-channel-message-date" }))));
|
|
54711
|
+
var LoadingMessageInput = () => /* @__PURE__ */ import_react258.default.createElement("div", { className: "str-chat__loading-channel-message-input-row" }, /* @__PURE__ */ import_react258.default.createElement("div", { className: "str-chat__loading-channel-message-input" }), /* @__PURE__ */ import_react258.default.createElement("div", { className: "str-chat__loading-channel-message-send" }));
|
|
54712
|
+
var LoadingChannelHeader = () => /* @__PURE__ */ import_react258.default.createElement("div", { className: "str-chat__loading-channel-header" }, /* @__PURE__ */ import_react258.default.createElement("div", { className: "str-chat__loading-channel-header-avatar" }), /* @__PURE__ */ import_react258.default.createElement("div", { className: "str-chat__loading-channel-header-end" }, /* @__PURE__ */ import_react258.default.createElement("div", { className: "str-chat__loading-channel-header-name" }), /* @__PURE__ */ import_react258.default.createElement("div", { className: "str-chat__loading-channel-header-info" })));
|
|
54713
|
+
var LoadingChannel = () => /* @__PURE__ */ import_react258.default.createElement("div", { className: "str-chat__loading-channel" }, /* @__PURE__ */ import_react258.default.createElement(LoadingChannelHeader, null), /* @__PURE__ */ import_react258.default.createElement("div", { className: "str-chat__loading-channel-message-list" }, Array.from(Array(3)).map((_, i) => /* @__PURE__ */ import_react258.default.createElement(LoadingMessage, { key: `loading-message-${i}` }))), /* @__PURE__ */ import_react258.default.createElement(LoadingMessageInput, null));
|
|
54714
54714
|
|
|
54715
54715
|
// src/components/Channel/hooks/useChannelContainerClasses.ts
|
|
54716
54716
|
var useImageFlagEmojisOnWindowsClass = () => {
|
|
@@ -54897,7 +54897,7 @@ var ChannelContainer = ({
|
|
|
54897
54897
|
customClasses
|
|
54898
54898
|
});
|
|
54899
54899
|
const className = (0, import_clsx66.default)(chatClass, theme, channelClass, additionalClassName);
|
|
54900
|
-
return /* @__PURE__ */
|
|
54900
|
+
return /* @__PURE__ */ import_react259.default.createElement("div", { id: CHANNEL_CONTAINER_ID, ...props, className }, children);
|
|
54901
54901
|
};
|
|
54902
54902
|
var UnMemoizedChannel = (props) => {
|
|
54903
54903
|
const {
|
|
@@ -54909,15 +54909,15 @@ var UnMemoizedChannel = (props) => {
|
|
|
54909
54909
|
const { channel: contextChannel, channelsQueryState } = useChatContext("Channel");
|
|
54910
54910
|
const channel = propsChannel || contextChannel;
|
|
54911
54911
|
if (channelsQueryState.queryInProgress === "reload" && LoadingIndicator2) {
|
|
54912
|
-
return /* @__PURE__ */
|
|
54912
|
+
return /* @__PURE__ */ import_react259.default.createElement(ChannelContainer, null, /* @__PURE__ */ import_react259.default.createElement(LoadingIndicator2, null));
|
|
54913
54913
|
}
|
|
54914
54914
|
if (channelsQueryState.error && LoadingErrorIndicator2) {
|
|
54915
|
-
return /* @__PURE__ */
|
|
54915
|
+
return /* @__PURE__ */ import_react259.default.createElement(ChannelContainer, null, /* @__PURE__ */ import_react259.default.createElement(LoadingErrorIndicator2, { error: channelsQueryState.error }));
|
|
54916
54916
|
}
|
|
54917
54917
|
if (!channel?.cid) {
|
|
54918
|
-
return /* @__PURE__ */
|
|
54918
|
+
return /* @__PURE__ */ import_react259.default.createElement(ChannelContainer, null, EmptyPlaceholder2);
|
|
54919
54919
|
}
|
|
54920
|
-
return /* @__PURE__ */
|
|
54920
|
+
return /* @__PURE__ */ import_react259.default.createElement(ChannelInner, { ...props, channel, key: channel.cid });
|
|
54921
54921
|
};
|
|
54922
54922
|
var ChannelInner = (props) => {
|
|
54923
54923
|
const {
|
|
@@ -54937,7 +54937,7 @@ var ChannelInner = (props) => {
|
|
|
54937
54937
|
onMentionsHover,
|
|
54938
54938
|
skipMessageDataMemoization
|
|
54939
54939
|
} = props;
|
|
54940
|
-
const channelQueryOptions = (0,
|
|
54940
|
+
const channelQueryOptions = (0, import_react259.useMemo)(
|
|
54941
54941
|
() => (0, import_lodash20.default)(propChannelQueryOptions, {
|
|
54942
54942
|
messages: { limit: DEFAULT_INITIAL_CHANNEL_PAGE_SIZE }
|
|
54943
54943
|
}),
|
|
@@ -54948,12 +54948,12 @@ var ChannelInner = (props) => {
|
|
|
54948
54948
|
const chatContainerClass = getChatContainerClass(customClasses?.chatContainer);
|
|
54949
54949
|
const windowsEmojiClass = useImageFlagEmojisOnWindowsClass();
|
|
54950
54950
|
const thread = useThreadContext();
|
|
54951
|
-
const [channelConfig, setChannelConfig] = (0,
|
|
54952
|
-
const [notifications, setNotifications] = (0,
|
|
54953
|
-
const notificationTimeouts = (0,
|
|
54954
|
-
const [channelUnreadUiState, _setChannelUnreadUiState] = (0,
|
|
54955
|
-
const channelReducer = (0,
|
|
54956
|
-
const [state, dispatch] = (0,
|
|
54951
|
+
const [channelConfig, setChannelConfig] = (0, import_react259.useState)(channel.getConfig());
|
|
54952
|
+
const [notifications, setNotifications] = (0, import_react259.useState)([]);
|
|
54953
|
+
const notificationTimeouts = (0, import_react259.useRef)([]);
|
|
54954
|
+
const [channelUnreadUiState, _setChannelUnreadUiState] = (0, import_react259.useState)();
|
|
54955
|
+
const channelReducer = (0, import_react259.useMemo)(() => makeChannelReducer(), []);
|
|
54956
|
+
const [state, dispatch] = (0, import_react259.useReducer)(
|
|
54957
54957
|
channelReducer,
|
|
54958
54958
|
// channel.initialized === false if client.channel().query() was not called, e.g. ChannelList is not used
|
|
54959
54959
|
// => Channel will call channel.watch() in useLayoutEffect => state.loading is used to signal the watch() call state
|
|
@@ -54965,10 +54965,10 @@ var ChannelInner = (props) => {
|
|
|
54965
54965
|
);
|
|
54966
54966
|
const jumpToMessageFromSearch = useSearchFocusedMessage();
|
|
54967
54967
|
const isMounted = useIsMounted();
|
|
54968
|
-
const originalTitle = (0,
|
|
54969
|
-
const lastRead = (0,
|
|
54970
|
-
const online = (0,
|
|
54971
|
-
const clearHighlightedMessageTimeoutId = (0,
|
|
54968
|
+
const originalTitle = (0, import_react259.useRef)("");
|
|
54969
|
+
const lastRead = (0, import_react259.useRef)(void 0);
|
|
54970
|
+
const online = (0, import_react259.useRef)(true);
|
|
54971
|
+
const clearHighlightedMessageTimeoutId = (0, import_react259.useRef)(
|
|
54972
54972
|
null
|
|
54973
54973
|
);
|
|
54974
54974
|
const channelCapabilitiesArray = channel.data?.own_capabilities;
|
|
@@ -54980,14 +54980,14 @@ var ChannelInner = (props) => {
|
|
|
54980
54980
|
trailing: true
|
|
54981
54981
|
}
|
|
54982
54982
|
);
|
|
54983
|
-
const setChannelUnreadUiState = (0,
|
|
54983
|
+
const setChannelUnreadUiState = (0, import_react259.useMemo)(
|
|
54984
54984
|
() => (0, import_lodash21.default)(_setChannelUnreadUiState, 200, {
|
|
54985
54985
|
leading: true,
|
|
54986
54986
|
trailing: false
|
|
54987
54987
|
}),
|
|
54988
54988
|
[]
|
|
54989
54989
|
);
|
|
54990
|
-
const markRead = (0,
|
|
54990
|
+
const markRead = (0, import_react259.useMemo)(
|
|
54991
54991
|
() => (0, import_lodash21.default)(
|
|
54992
54992
|
async (options) => {
|
|
54993
54993
|
const { updateChannelUiUnreadState = true } = options ?? {};
|
|
@@ -55090,7 +55090,7 @@ var ChannelInner = (props) => {
|
|
|
55090
55090
|
}
|
|
55091
55091
|
throttledCopyStateFromChannel();
|
|
55092
55092
|
};
|
|
55093
|
-
(0,
|
|
55093
|
+
(0, import_react259.useLayoutEffect)(() => {
|
|
55094
55094
|
let errored = false;
|
|
55095
55095
|
let done = false;
|
|
55096
55096
|
(async () => {
|
|
@@ -55156,12 +55156,12 @@ var ChannelInner = (props) => {
|
|
|
55156
55156
|
channelConfig?.read_events,
|
|
55157
55157
|
initializeOnMount
|
|
55158
55158
|
]);
|
|
55159
|
-
(0,
|
|
55159
|
+
(0, import_react259.useEffect)(() => {
|
|
55160
55160
|
if (!state.thread) return;
|
|
55161
55161
|
const message = state.messages?.find((m) => m.id === state.thread?.id);
|
|
55162
55162
|
if (message) dispatch({ message, type: "setThread" });
|
|
55163
55163
|
}, [state.messages, state.thread]);
|
|
55164
|
-
const handleHighlightedMessageChange = (0,
|
|
55164
|
+
const handleHighlightedMessageChange = (0, import_react259.useCallback)(
|
|
55165
55165
|
({
|
|
55166
55166
|
highlightDuration,
|
|
55167
55167
|
highlightedMessageId
|
|
@@ -55184,15 +55184,15 @@ var ChannelInner = (props) => {
|
|
|
55184
55184
|
},
|
|
55185
55185
|
[channel, searchController]
|
|
55186
55186
|
);
|
|
55187
|
-
(0,
|
|
55187
|
+
(0, import_react259.useEffect)(() => {
|
|
55188
55188
|
if (!jumpToMessageFromSearch?.id) return;
|
|
55189
55189
|
handleHighlightedMessageChange({ highlightedMessageId: jumpToMessageFromSearch.id });
|
|
55190
55190
|
}, [jumpToMessageFromSearch, handleHighlightedMessageChange]);
|
|
55191
|
-
const addNotification = (0,
|
|
55191
|
+
const addNotification = (0, import_react259.useMemo)(
|
|
55192
55192
|
() => makeAddNotifications(setNotifications, notificationTimeouts.current),
|
|
55193
55193
|
[]
|
|
55194
55194
|
);
|
|
55195
|
-
const loadMoreFinished = (0,
|
|
55195
|
+
const loadMoreFinished = (0, import_react259.useCallback)(
|
|
55196
55196
|
(0, import_lodash19.default)(
|
|
55197
55197
|
(hasMore, messages) => {
|
|
55198
55198
|
if (!isMounted.current) return;
|
|
@@ -55253,7 +55253,7 @@ var ChannelInner = (props) => {
|
|
|
55253
55253
|
});
|
|
55254
55254
|
return queryResponse.messages.length;
|
|
55255
55255
|
};
|
|
55256
|
-
const jumpToMessage = (0,
|
|
55256
|
+
const jumpToMessage = (0, import_react259.useCallback)(
|
|
55257
55257
|
async (messageId, messageLimit = DEFAULT_JUMP_TO_PAGE_SIZE, highlightDuration = DEFAULT_HIGHLIGHT_DURATION) => {
|
|
55258
55258
|
dispatch({ loadingMore: true, type: "setLoadingMore" });
|
|
55259
55259
|
await channel.state.loadMessageIntoState(messageId, void 0, messageLimit);
|
|
@@ -55265,14 +55265,14 @@ var ChannelInner = (props) => {
|
|
|
55265
55265
|
},
|
|
55266
55266
|
[channel, handleHighlightedMessageChange, loadMoreFinished]
|
|
55267
55267
|
);
|
|
55268
|
-
const jumpToLatestMessage = (0,
|
|
55268
|
+
const jumpToLatestMessage = (0, import_react259.useCallback)(async () => {
|
|
55269
55269
|
await channel.state.loadMessageIntoState("latest");
|
|
55270
55270
|
loadMoreFinished(channel.state.messagePagination.hasPrev, channel.state.messages);
|
|
55271
55271
|
dispatch({
|
|
55272
55272
|
type: "jumpToLatestMessage"
|
|
55273
55273
|
});
|
|
55274
55274
|
}, [channel, loadMoreFinished]);
|
|
55275
|
-
const jumpToFirstUnreadMessage = (0,
|
|
55275
|
+
const jumpToFirstUnreadMessage = (0, import_react259.useCallback)(
|
|
55276
55276
|
async (queryMessageLimit = DEFAULT_JUMP_TO_PAGE_SIZE, highlightDuration = DEFAULT_HIGHLIGHT_DURATION) => {
|
|
55277
55277
|
if (!channelUnreadUiState?.unread_messages) return;
|
|
55278
55278
|
let lastReadMessageId = channelUnreadUiState?.last_read_message_id;
|
|
@@ -55395,7 +55395,7 @@ var ChannelInner = (props) => {
|
|
|
55395
55395
|
channelUnreadUiState
|
|
55396
55396
|
]
|
|
55397
55397
|
);
|
|
55398
|
-
const deleteMessage = (0,
|
|
55398
|
+
const deleteMessage = (0, import_react259.useCallback)(
|
|
55399
55399
|
async (message) => {
|
|
55400
55400
|
if (!message?.id) {
|
|
55401
55401
|
throw new Error("Cannot delete a message - missing message ID.");
|
|
@@ -55513,7 +55513,7 @@ var ChannelInner = (props) => {
|
|
|
55513
55513
|
event?.preventDefault();
|
|
55514
55514
|
dispatch({ type: "closeThread" });
|
|
55515
55515
|
};
|
|
55516
|
-
const loadMoreThreadFinished = (0,
|
|
55516
|
+
const loadMoreThreadFinished = (0, import_react259.useCallback)(
|
|
55517
55517
|
(0, import_lodash19.default)(
|
|
55518
55518
|
(threadHasMore, threadMessages) => {
|
|
55519
55519
|
dispatch({
|
|
@@ -55568,7 +55568,7 @@ var ChannelInner = (props) => {
|
|
|
55568
55568
|
videoAttachmentSizeHandler: props.videoAttachmentSizeHandler || getVideoAttachmentConfiguration,
|
|
55569
55569
|
watcher_count: state.watcherCount
|
|
55570
55570
|
});
|
|
55571
|
-
const channelActionContextValue = (0,
|
|
55571
|
+
const channelActionContextValue = (0, import_react259.useMemo)(
|
|
55572
55572
|
() => ({
|
|
55573
55573
|
addNotification,
|
|
55574
55574
|
closeThread,
|
|
@@ -55605,7 +55605,7 @@ var ChannelInner = (props) => {
|
|
|
55605
55605
|
setChannelUnreadUiState
|
|
55606
55606
|
]
|
|
55607
55607
|
);
|
|
55608
|
-
const componentContextValue = (0,
|
|
55608
|
+
const componentContextValue = (0, import_react259.useMemo)(
|
|
55609
55609
|
() => ({
|
|
55610
55610
|
Attachment: props.Attachment,
|
|
55611
55611
|
AttachmentPreviewList: props.AttachmentPreviewList,
|
|
@@ -55735,26 +55735,26 @@ var ChannelInner = (props) => {
|
|
|
55735
55735
|
typing
|
|
55736
55736
|
});
|
|
55737
55737
|
if (state.error) {
|
|
55738
|
-
return /* @__PURE__ */
|
|
55738
|
+
return /* @__PURE__ */ import_react259.default.createElement(ChannelContainer, null, /* @__PURE__ */ import_react259.default.createElement(LoadingErrorIndicator2, { error: state.error }));
|
|
55739
55739
|
}
|
|
55740
55740
|
if (state.loading) {
|
|
55741
|
-
return /* @__PURE__ */
|
|
55741
|
+
return /* @__PURE__ */ import_react259.default.createElement(ChannelContainer, null, /* @__PURE__ */ import_react259.default.createElement(LoadingIndicator2, null));
|
|
55742
55742
|
}
|
|
55743
55743
|
if (!channel.watch) {
|
|
55744
|
-
return /* @__PURE__ */
|
|
55744
|
+
return /* @__PURE__ */ import_react259.default.createElement(ChannelContainer, null, /* @__PURE__ */ import_react259.default.createElement("div", null, t("Channel Missing")));
|
|
55745
55745
|
}
|
|
55746
|
-
return /* @__PURE__ */
|
|
55746
|
+
return /* @__PURE__ */ import_react259.default.createElement(ChannelContainer, { className: windowsEmojiClass }, /* @__PURE__ */ import_react259.default.createElement(ChannelStateProvider, { value: channelStateContextValue }, /* @__PURE__ */ import_react259.default.createElement(ChannelActionProvider, { value: channelActionContextValue }, /* @__PURE__ */ import_react259.default.createElement(WithComponents, { overrides: componentContextValue }, /* @__PURE__ */ import_react259.default.createElement(TypingProvider, { value: typingContextValue }, /* @__PURE__ */ import_react259.default.createElement("div", { className: (0, import_clsx66.default)(chatContainerClass) }, children))))));
|
|
55747
55747
|
};
|
|
55748
|
-
var Channel =
|
|
55748
|
+
var Channel = import_react259.default.memo(UnMemoizedChannel);
|
|
55749
55749
|
|
|
55750
55750
|
// src/components/ChannelHeader/ChannelHeader.tsx
|
|
55751
|
-
var
|
|
55751
|
+
var import_react261 = __toESM(require("react"));
|
|
55752
55752
|
|
|
55753
55753
|
// src/components/ChannelHeader/icons.tsx
|
|
55754
|
-
var
|
|
55754
|
+
var import_react260 = __toESM(require("react"));
|
|
55755
55755
|
var MenuIcon2 = ({ title }) => {
|
|
55756
55756
|
const { t } = useTranslationContext("MenuIcon");
|
|
55757
|
-
return /* @__PURE__ */
|
|
55757
|
+
return /* @__PURE__ */ import_react260.default.createElement("svg", { "data-testid": "menu-icon", viewBox: "0 0 448 512", xmlns: "http://www.w3.org/2000/svg" }, /* @__PURE__ */ import_react260.default.createElement("title", null, title ?? t("Menu")), /* @__PURE__ */ import_react260.default.createElement(
|
|
55758
55758
|
"path",
|
|
55759
55759
|
{
|
|
55760
55760
|
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",
|
|
@@ -55781,15 +55781,15 @@ var ChannelHeader = (props) => {
|
|
|
55781
55781
|
overrideTitle
|
|
55782
55782
|
});
|
|
55783
55783
|
const { member_count, subtitle } = channel?.data || {};
|
|
55784
|
-
return /* @__PURE__ */
|
|
55784
|
+
return /* @__PURE__ */ import_react261.default.createElement("div", { className: "str-chat__channel-header" }, /* @__PURE__ */ import_react261.default.createElement(
|
|
55785
55785
|
"button",
|
|
55786
55786
|
{
|
|
55787
55787
|
"aria-label": t("aria/Menu"),
|
|
55788
55788
|
className: "str-chat__header-hamburger",
|
|
55789
55789
|
onClick: openMobileNav
|
|
55790
55790
|
},
|
|
55791
|
-
/* @__PURE__ */
|
|
55792
|
-
), /* @__PURE__ */
|
|
55791
|
+
/* @__PURE__ */ import_react261.default.createElement(MenuIcon3, null)
|
|
55792
|
+
), /* @__PURE__ */ import_react261.default.createElement(
|
|
55793
55793
|
Avatar2,
|
|
55794
55794
|
{
|
|
55795
55795
|
className: "str-chat__avatar--channel-header",
|
|
@@ -55797,36 +55797,36 @@ var ChannelHeader = (props) => {
|
|
|
55797
55797
|
image: displayImage,
|
|
55798
55798
|
name: displayTitle
|
|
55799
55799
|
}
|
|
55800
|
-
), /* @__PURE__ */
|
|
55800
|
+
), /* @__PURE__ */ import_react261.default.createElement("div", { className: "str-chat__channel-header-end" }, /* @__PURE__ */ import_react261.default.createElement("p", { className: "str-chat__channel-header-title" }, displayTitle, " ", live && /* @__PURE__ */ import_react261.default.createElement("span", { className: "str-chat__header-livestream-livelabel" }, t("live"))), subtitle && /* @__PURE__ */ import_react261.default.createElement("p", { className: "str-chat__channel-header-subtitle" }, subtitle), /* @__PURE__ */ import_react261.default.createElement("p", { className: "str-chat__channel-header-info" }, !live && !!member_count && member_count > 0 && /* @__PURE__ */ import_react261.default.createElement(import_react261.default.Fragment, null, t("{{ memberCount }} members", {
|
|
55801
55801
|
memberCount: member_count
|
|
55802
55802
|
}), ",", " "), t("{{ watcherCount }} online", { watcherCount: watcher_count }))));
|
|
55803
55803
|
};
|
|
55804
55804
|
|
|
55805
55805
|
// src/components/Chat/Chat.tsx
|
|
55806
|
-
var
|
|
55806
|
+
var import_react265 = __toESM(require("react"));
|
|
55807
55807
|
var import_stream_chat12 = require("stream-chat");
|
|
55808
55808
|
|
|
55809
55809
|
// src/components/Chat/hooks/useChat.ts
|
|
55810
|
-
var
|
|
55810
|
+
var import_react262 = require("react");
|
|
55811
55811
|
var useChat = ({
|
|
55812
55812
|
client,
|
|
55813
55813
|
defaultLanguage = "en",
|
|
55814
55814
|
i18nInstance,
|
|
55815
55815
|
initialNavOpen
|
|
55816
55816
|
}) => {
|
|
55817
|
-
const [translators, setTranslators] = (0,
|
|
55817
|
+
const [translators, setTranslators] = (0, import_react262.useState)({
|
|
55818
55818
|
t: (key) => key,
|
|
55819
55819
|
tDateTimeParser: defaultDateTimeParser,
|
|
55820
55820
|
userLanguage: "en"
|
|
55821
55821
|
});
|
|
55822
|
-
const [channel, setChannel] = (0,
|
|
55823
|
-
const [mutes, setMutes] = (0,
|
|
55824
|
-
const [navOpen, setNavOpen] = (0,
|
|
55825
|
-
const [latestMessageDatesByChannels, setLatestMessageDatesByChannels] = (0,
|
|
55822
|
+
const [channel, setChannel] = (0, import_react262.useState)();
|
|
55823
|
+
const [mutes, setMutes] = (0, import_react262.useState)([]);
|
|
55824
|
+
const [navOpen, setNavOpen] = (0, import_react262.useState)(initialNavOpen);
|
|
55825
|
+
const [latestMessageDatesByChannels, setLatestMessageDatesByChannels] = (0, import_react262.useState)({});
|
|
55826
55826
|
const clientMutes = client.user?.mutes ?? [];
|
|
55827
55827
|
const closeMobileNav = () => setNavOpen(false);
|
|
55828
55828
|
const openMobileNav = () => setTimeout(() => setNavOpen(true), 100);
|
|
55829
|
-
const appSettings = (0,
|
|
55829
|
+
const appSettings = (0, import_react262.useRef)(null);
|
|
55830
55830
|
const getAppSettings = () => {
|
|
55831
55831
|
if (appSettings.current) {
|
|
55832
55832
|
return appSettings.current;
|
|
@@ -55834,9 +55834,9 @@ var useChat = ({
|
|
|
55834
55834
|
appSettings.current = client.getAppSettings();
|
|
55835
55835
|
return appSettings.current;
|
|
55836
55836
|
};
|
|
55837
|
-
(0,
|
|
55837
|
+
(0, import_react262.useEffect)(() => {
|
|
55838
55838
|
if (!client) return;
|
|
55839
|
-
const version = "13.0.0-rc.
|
|
55839
|
+
const version = "13.0.0-rc.2";
|
|
55840
55840
|
const userAgent = client.getUserAgent();
|
|
55841
55841
|
if (!userAgent.includes("stream-chat-react")) {
|
|
55842
55842
|
client.setUserAgent(`stream-chat-react-${version}-${userAgent}`);
|
|
@@ -55848,7 +55848,7 @@ var useChat = ({
|
|
|
55848
55848
|
client.polls.unregisterSubscriptions();
|
|
55849
55849
|
};
|
|
55850
55850
|
}, [client]);
|
|
55851
|
-
(0,
|
|
55851
|
+
(0, import_react262.useEffect)(() => {
|
|
55852
55852
|
setMutes(clientMutes);
|
|
55853
55853
|
const handleEvent = (event) => {
|
|
55854
55854
|
setMutes(event.me?.mutes || []);
|
|
@@ -55856,7 +55856,7 @@ var useChat = ({
|
|
|
55856
55856
|
client.on("notification.mutes_updated", handleEvent);
|
|
55857
55857
|
return () => client.off("notification.mutes_updated", handleEvent);
|
|
55858
55858
|
}, [clientMutes?.length]);
|
|
55859
|
-
(0,
|
|
55859
|
+
(0, import_react262.useEffect)(() => {
|
|
55860
55860
|
let userLanguage = client.user?.language;
|
|
55861
55861
|
if (!userLanguage) {
|
|
55862
55862
|
const browserLanguage = window.navigator.language.slice(0, 2);
|
|
@@ -55873,7 +55873,7 @@ var useChat = ({
|
|
|
55873
55873
|
});
|
|
55874
55874
|
});
|
|
55875
55875
|
}, [i18nInstance]);
|
|
55876
|
-
const setActiveChannel = (0,
|
|
55876
|
+
const setActiveChannel = (0, import_react262.useCallback)(
|
|
55877
55877
|
async (activeChannel, watchers = {}, event) => {
|
|
55878
55878
|
if (event && event.preventDefault) event.preventDefault();
|
|
55879
55879
|
if (activeChannel && Object.keys(watchers).length) {
|
|
@@ -55884,7 +55884,7 @@ var useChat = ({
|
|
|
55884
55884
|
},
|
|
55885
55885
|
[]
|
|
55886
55886
|
);
|
|
55887
|
-
(0,
|
|
55887
|
+
(0, import_react262.useEffect)(() => {
|
|
55888
55888
|
setLatestMessageDatesByChannels({});
|
|
55889
55889
|
}, [client.user?.id]);
|
|
55890
55890
|
return {
|
|
@@ -55901,7 +55901,7 @@ var useChat = ({
|
|
|
55901
55901
|
};
|
|
55902
55902
|
|
|
55903
55903
|
// src/components/Chat/hooks/useCreateChatContext.ts
|
|
55904
|
-
var
|
|
55904
|
+
var import_react263 = require("react");
|
|
55905
55905
|
var useCreateChatContext = (value) => {
|
|
55906
55906
|
const {
|
|
55907
55907
|
channel,
|
|
@@ -55926,7 +55926,7 @@ var useCreateChatContext = (value) => {
|
|
|
55926
55926
|
const clientValues = `${client.clientID}${Object.keys(client.activeChannels).length}${Object.keys(client.listeners).length}${client.mutedChannels.length}
|
|
55927
55927
|
${client.user?.id}`;
|
|
55928
55928
|
const mutedUsersLength = mutes.length;
|
|
55929
|
-
const chatContext = (0,
|
|
55929
|
+
const chatContext = (0, import_react263.useMemo)(
|
|
55930
55930
|
() => ({
|
|
55931
55931
|
channel,
|
|
55932
55932
|
channelsQueryState,
|
|
@@ -55961,10 +55961,10 @@ var useCreateChatContext = (value) => {
|
|
|
55961
55961
|
};
|
|
55962
55962
|
|
|
55963
55963
|
// src/components/Chat/hooks/useChannelsQueryState.ts
|
|
55964
|
-
var
|
|
55964
|
+
var import_react264 = require("react");
|
|
55965
55965
|
var useChannelsQueryState = () => {
|
|
55966
|
-
const [error, setError] = (0,
|
|
55967
|
-
const [queryInProgress, setQueryInProgress] = (0,
|
|
55966
|
+
const [error, setError] = (0, import_react264.useState)(null);
|
|
55967
|
+
const [queryInProgress, setQueryInProgress] = (0, import_react264.useState)("uninitialized");
|
|
55968
55968
|
return {
|
|
55969
55969
|
error,
|
|
55970
55970
|
queryInProgress,
|
|
@@ -55999,7 +55999,7 @@ var Chat = (props) => {
|
|
|
55999
55999
|
translators
|
|
56000
56000
|
} = useChat({ client, defaultLanguage, i18nInstance, initialNavOpen });
|
|
56001
56001
|
const channelsQueryState = useChannelsQueryState();
|
|
56002
|
-
const searchController = (0,
|
|
56002
|
+
const searchController = (0, import_react265.useMemo)(
|
|
56003
56003
|
() => customChannelSearchController ?? new import_stream_chat12.SearchController({
|
|
56004
56004
|
sources: [
|
|
56005
56005
|
new import_stream_chat12.ChannelSearchSource(client),
|
|
@@ -56027,11 +56027,11 @@ var Chat = (props) => {
|
|
|
56027
56027
|
useImageFlagEmojisOnWindows
|
|
56028
56028
|
});
|
|
56029
56029
|
if (!translators.t) return null;
|
|
56030
|
-
return /* @__PURE__ */
|
|
56030
|
+
return /* @__PURE__ */ import_react265.default.createElement(ChatProvider, { value: chatContextValue }, /* @__PURE__ */ import_react265.default.createElement(TranslationProvider, { value: translators }, children));
|
|
56031
56031
|
};
|
|
56032
56032
|
|
|
56033
56033
|
// src/components/Chat/hooks/useCreateChatClient.ts
|
|
56034
|
-
var
|
|
56034
|
+
var import_react266 = require("react");
|
|
56035
56035
|
var import_stream_chat13 = require("stream-chat");
|
|
56036
56036
|
var useCreateChatClient = ({
|
|
56037
56037
|
apiKey,
|
|
@@ -56039,13 +56039,13 @@ var useCreateChatClient = ({
|
|
|
56039
56039
|
tokenOrProvider,
|
|
56040
56040
|
userData
|
|
56041
56041
|
}) => {
|
|
56042
|
-
const [chatClient, setChatClient] = (0,
|
|
56043
|
-
const [cachedUserData, setCachedUserData] = (0,
|
|
56042
|
+
const [chatClient, setChatClient] = (0, import_react266.useState)(null);
|
|
56043
|
+
const [cachedUserData, setCachedUserData] = (0, import_react266.useState)(userData);
|
|
56044
56044
|
if (userData.id !== cachedUserData.id) {
|
|
56045
56045
|
setCachedUserData(userData);
|
|
56046
56046
|
}
|
|
56047
|
-
const [cachedOptions] = (0,
|
|
56048
|
-
(0,
|
|
56047
|
+
const [cachedOptions] = (0, import_react266.useState)(options);
|
|
56048
|
+
(0, import_react266.useEffect)(() => {
|
|
56049
56049
|
const client = new import_stream_chat13.StreamChat(apiKey, void 0, cachedOptions);
|
|
56050
56050
|
let didUserConnectInterrupt = false;
|
|
56051
56051
|
const connectionPromise = client.connectUser(cachedUserData, tokenOrProvider).then(() => {
|
|
@@ -56063,12 +56063,12 @@ var useCreateChatClient = ({
|
|
|
56063
56063
|
};
|
|
56064
56064
|
|
|
56065
56065
|
// src/components/Window/Window.tsx
|
|
56066
|
-
var
|
|
56066
|
+
var import_react267 = __toESM(require("react"));
|
|
56067
56067
|
var import_clsx67 = __toESM(require("clsx"));
|
|
56068
56068
|
var UnMemoizedWindow = (props) => {
|
|
56069
56069
|
const { children, thread: propThread } = props;
|
|
56070
56070
|
const { thread: contextThread } = useChannelStateContext("Window");
|
|
56071
|
-
return /* @__PURE__ */
|
|
56071
|
+
return /* @__PURE__ */ import_react267.default.createElement(
|
|
56072
56072
|
"div",
|
|
56073
56073
|
{
|
|
56074
56074
|
className: (0, import_clsx67.default)("str-chat__main-panel", {
|
|
@@ -56078,7 +56078,7 @@ var UnMemoizedWindow = (props) => {
|
|
|
56078
56078
|
children
|
|
56079
56079
|
);
|
|
56080
56080
|
};
|
|
56081
|
-
var Window =
|
|
56081
|
+
var Window = import_react267.default.memo(UnMemoizedWindow);
|
|
56082
56082
|
// Annotate the CommonJS export names for ESM import in node:
|
|
56083
56083
|
0 && (module.exports = {
|
|
56084
56084
|
ACTIONS_NOT_WORKING_IN_THREAD,
|