stream-chat-react 13.1.0 → 13.1.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/InfiniteScrollPaginator/InfiniteScroll.d.ts +1 -1
- package/dist/components/InfiniteScrollPaginator/InfiniteScroll.js +16 -25
- package/dist/components/Message/MessageIsThreadReplyInChannelButtonIndicator.d.ts +2 -0
- package/dist/components/Message/{MessageThreadReplyInChannelButtonIndicator.js → MessageIsThreadReplyInChannelButtonIndicator.js} +2 -2
- package/dist/components/Message/MessageSimple.js +1 -1
- package/dist/context/ComponentContext.d.ts +2 -1
- package/dist/experimental/index.browser.cjs.map +2 -2
- package/dist/experimental/index.node.cjs.map +2 -2
- package/dist/i18n/TranslationBuilder/TranslationBuilder.d.ts +9 -5
- package/dist/i18n/TranslationBuilder/TranslationBuilder.js +37 -13
- package/dist/i18n/TranslationBuilder/notifications/index.d.ts +1 -0
- package/dist/i18n/TranslationBuilder/notifications/index.js +1 -0
- package/dist/i18n/index.d.ts +1 -1
- package/dist/i18n/index.js +1 -1
- package/dist/index.browser.cjs +60 -45
- package/dist/index.browser.cjs.map +4 -4
- package/dist/index.node.cjs +61 -45
- package/dist/index.node.cjs.map +4 -4
- package/package.json +1 -1
- package/dist/components/Message/MessageThreadReplyInChannelButtonIndicator.d.ts +0 -2
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { i18n, TFunction } from 'i18next';
|
|
2
|
+
type TopicName = string;
|
|
3
|
+
type TranslatorName = string;
|
|
2
4
|
export type Translator<O extends Record<string, unknown> = Record<string, unknown>> = (params: {
|
|
3
5
|
key: string;
|
|
4
6
|
value: string;
|
|
@@ -22,10 +24,12 @@ export type TranslationTopicConstructor = new (options: TranslationTopicOptions)
|
|
|
22
24
|
export declare class TranslationBuilder {
|
|
23
25
|
private i18next;
|
|
24
26
|
private topics;
|
|
27
|
+
private translatorRegistrationsBuffer;
|
|
25
28
|
constructor(i18next: i18n);
|
|
26
|
-
registerTopic: (name:
|
|
27
|
-
disableTopic: (topicName:
|
|
28
|
-
getTopic: (topicName:
|
|
29
|
-
registerTranslators(topicName:
|
|
30
|
-
removeTranslators(topicName:
|
|
29
|
+
registerTopic: (name: TopicName, Topic: TranslationTopicConstructor) => TranslationTopic<Record<string, unknown>>;
|
|
30
|
+
disableTopic: (topicName: TopicName) => void;
|
|
31
|
+
getTopic: (topicName: TopicName) => TranslationTopic<Record<string, unknown>> | undefined;
|
|
32
|
+
registerTranslators(topicName: TopicName, translators: Record<TranslatorName, Translator>): void;
|
|
33
|
+
removeTranslators(topicName: TopicName, translators: TranslatorName[]): void;
|
|
31
34
|
}
|
|
35
|
+
export {};
|
|
@@ -21,19 +21,32 @@ export class TranslationBuilder {
|
|
|
21
21
|
constructor(i18next) {
|
|
22
22
|
this.i18next = i18next;
|
|
23
23
|
this.topics = new Map();
|
|
24
|
+
// need to keep a registration buffer so that translators can be registered once a topic is registered
|
|
25
|
+
// what does not happen when Streami18n is instantiated but rather once Streami18n.init() is invoked
|
|
26
|
+
this.translatorRegistrationsBuffer = {};
|
|
24
27
|
this.registerTopic = (name, Topic) => {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
name,
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
28
|
+
let topic = this.topics.get(name);
|
|
29
|
+
if (!topic) {
|
|
30
|
+
topic = new Topic({ i18next: this.i18next });
|
|
31
|
+
this.topics.set(name, topic);
|
|
32
|
+
this.i18next.use({
|
|
33
|
+
name,
|
|
34
|
+
process: (value, key, options) => {
|
|
35
|
+
const topic = this.topics.get(name);
|
|
36
|
+
if (!topic)
|
|
37
|
+
return value;
|
|
38
|
+
return topic.translate(value, key, options);
|
|
39
|
+
},
|
|
40
|
+
type: 'postProcessor',
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
const additionalTranslatorsToRegister = this.translatorRegistrationsBuffer[name];
|
|
44
|
+
if (additionalTranslatorsToRegister) {
|
|
45
|
+
Object.entries(additionalTranslatorsToRegister).forEach(([translatorName, translator]) => {
|
|
46
|
+
topic.setTranslator(translatorName, translator);
|
|
47
|
+
});
|
|
48
|
+
delete this.translatorRegistrationsBuffer[name];
|
|
49
|
+
}
|
|
37
50
|
return topic;
|
|
38
51
|
};
|
|
39
52
|
this.disableTopic = (topicName) => {
|
|
@@ -51,14 +64,25 @@ export class TranslationBuilder {
|
|
|
51
64
|
}
|
|
52
65
|
registerTranslators(topicName, translators) {
|
|
53
66
|
const topic = this.getTopic(topicName);
|
|
54
|
-
if (!topic)
|
|
67
|
+
if (!topic) {
|
|
68
|
+
if (!this.translatorRegistrationsBuffer[topicName])
|
|
69
|
+
this.translatorRegistrationsBuffer[topicName] = {};
|
|
70
|
+
Object.entries(translators).forEach(([translatorName, translator]) => {
|
|
71
|
+
this.translatorRegistrationsBuffer[topicName][translatorName] = translator;
|
|
72
|
+
});
|
|
55
73
|
return;
|
|
74
|
+
}
|
|
56
75
|
Object.entries(translators).forEach(([name, translator]) => {
|
|
57
76
|
topic.setTranslator(name, translator);
|
|
58
77
|
});
|
|
59
78
|
}
|
|
60
79
|
removeTranslators(topicName, translators) {
|
|
61
80
|
const topic = this.getTopic(topicName);
|
|
81
|
+
if (this.translatorRegistrationsBuffer[topicName]) {
|
|
82
|
+
translators.forEach((translatorName) => {
|
|
83
|
+
delete this.translatorRegistrationsBuffer[topicName][translatorName];
|
|
84
|
+
});
|
|
85
|
+
}
|
|
62
86
|
if (!topic)
|
|
63
87
|
return;
|
|
64
88
|
translators.forEach((name) => {
|
package/dist/i18n/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export * from './translations';
|
|
2
2
|
export * from './Streami18n';
|
|
3
|
-
export * from './TranslationBuilder
|
|
3
|
+
export * from './TranslationBuilder';
|
|
4
4
|
export { defaultDateTimeParser, defaultTranslatorFunction, isDate, isDayOrMoment, isLanguageSupported, isNumberOrString, } from './utils';
|
|
5
5
|
export * from './types';
|
package/dist/i18n/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export * from './translations';
|
|
2
2
|
export * from './Streami18n';
|
|
3
|
-
export * from './TranslationBuilder
|
|
3
|
+
export * from './TranslationBuilder';
|
|
4
4
|
export { defaultDateTimeParser, defaultTranslatorFunction, isDate, isDayOrMoment, isLanguageSupported, isNumberOrString, } from './utils';
|
|
5
5
|
export * from './types';
|
package/dist/index.browser.cjs
CHANGED
|
@@ -18017,6 +18017,7 @@ __export(src_exports, {
|
|
|
18017
18017
|
MicIcon: () => MicIcon,
|
|
18018
18018
|
Modal: () => Modal,
|
|
18019
18019
|
ModalGallery: () => ModalGallery,
|
|
18020
|
+
NotificationTranslationTopic: () => NotificationTranslationTopic,
|
|
18020
18021
|
PauseIcon: () => PauseIcon2,
|
|
18021
18022
|
PinIcon: () => PinIcon,
|
|
18022
18023
|
PinIndicator: () => PinIndicator,
|
|
@@ -44087,18 +44088,33 @@ var TranslationBuilder = class {
|
|
|
44087
44088
|
constructor(i18next) {
|
|
44088
44089
|
this.i18next = i18next;
|
|
44089
44090
|
this.topics = /* @__PURE__ */ new Map();
|
|
44091
|
+
// need to keep a registration buffer so that translators can be registered once a topic is registered
|
|
44092
|
+
// what does not happen when Streami18n is instantiated but rather once Streami18n.init() is invoked
|
|
44093
|
+
this.translatorRegistrationsBuffer = {};
|
|
44090
44094
|
this.registerTopic = (name2, Topic) => {
|
|
44091
|
-
|
|
44092
|
-
|
|
44093
|
-
|
|
44094
|
-
|
|
44095
|
-
|
|
44096
|
-
|
|
44097
|
-
|
|
44098
|
-
|
|
44099
|
-
|
|
44100
|
-
|
|
44101
|
-
|
|
44095
|
+
let topic = this.topics.get(name2);
|
|
44096
|
+
if (!topic) {
|
|
44097
|
+
topic = new Topic({ i18next: this.i18next });
|
|
44098
|
+
this.topics.set(name2, topic);
|
|
44099
|
+
this.i18next.use({
|
|
44100
|
+
name: name2,
|
|
44101
|
+
process: (value, key, options) => {
|
|
44102
|
+
const topic2 = this.topics.get(name2);
|
|
44103
|
+
if (!topic2) return value;
|
|
44104
|
+
return topic2.translate(value, key, options);
|
|
44105
|
+
},
|
|
44106
|
+
type: "postProcessor"
|
|
44107
|
+
});
|
|
44108
|
+
}
|
|
44109
|
+
const additionalTranslatorsToRegister = this.translatorRegistrationsBuffer[name2];
|
|
44110
|
+
if (additionalTranslatorsToRegister) {
|
|
44111
|
+
Object.entries(additionalTranslatorsToRegister).forEach(
|
|
44112
|
+
([translatorName, translator]) => {
|
|
44113
|
+
topic.setTranslator(translatorName, translator);
|
|
44114
|
+
}
|
|
44115
|
+
);
|
|
44116
|
+
delete this.translatorRegistrationsBuffer[name2];
|
|
44117
|
+
}
|
|
44102
44118
|
return topic;
|
|
44103
44119
|
};
|
|
44104
44120
|
this.disableTopic = (topicName) => {
|
|
@@ -44115,13 +44131,25 @@ var TranslationBuilder = class {
|
|
|
44115
44131
|
}
|
|
44116
44132
|
registerTranslators(topicName, translators) {
|
|
44117
44133
|
const topic = this.getTopic(topicName);
|
|
44118
|
-
if (!topic)
|
|
44134
|
+
if (!topic) {
|
|
44135
|
+
if (!this.translatorRegistrationsBuffer[topicName])
|
|
44136
|
+
this.translatorRegistrationsBuffer[topicName] = {};
|
|
44137
|
+
Object.entries(translators).forEach(([translatorName, translator]) => {
|
|
44138
|
+
this.translatorRegistrationsBuffer[topicName][translatorName] = translator;
|
|
44139
|
+
});
|
|
44140
|
+
return;
|
|
44141
|
+
}
|
|
44119
44142
|
Object.entries(translators).forEach(([name2, translator]) => {
|
|
44120
44143
|
topic.setTranslator(name2, translator);
|
|
44121
44144
|
});
|
|
44122
44145
|
}
|
|
44123
44146
|
removeTranslators(topicName, translators) {
|
|
44124
44147
|
const topic = this.getTopic(topicName);
|
|
44148
|
+
if (this.translatorRegistrationsBuffer[topicName]) {
|
|
44149
|
+
translators.forEach((translatorName) => {
|
|
44150
|
+
delete this.translatorRegistrationsBuffer[topicName][translatorName];
|
|
44151
|
+
});
|
|
44152
|
+
}
|
|
44125
44153
|
if (!topic) return;
|
|
44126
44154
|
translators.forEach((name2) => {
|
|
44127
44155
|
topic.removeTranslator(name2);
|
|
@@ -45397,7 +45425,7 @@ var mousewheelListener2 = (event) => {
|
|
|
45397
45425
|
var InfiniteScroll = (props) => {
|
|
45398
45426
|
const {
|
|
45399
45427
|
children,
|
|
45400
|
-
element:
|
|
45428
|
+
element: Component2 = "div",
|
|
45401
45429
|
hasMore,
|
|
45402
45430
|
hasMoreNewer,
|
|
45403
45431
|
hasNextPage,
|
|
@@ -45419,17 +45447,17 @@ var InfiniteScroll = (props) => {
|
|
|
45419
45447
|
const loadPreviousPageFn = loadPreviousPage || loadMore;
|
|
45420
45448
|
const hasNextPageFlag = hasNextPage || hasMoreNewer;
|
|
45421
45449
|
const hasPreviousPageFlag = hasPreviousPage || hasMore;
|
|
45422
|
-
const scrollComponent = (0, import_react181.
|
|
45450
|
+
const [scrollComponent, setScrollComponent] = (0, import_react181.useState)(null);
|
|
45423
45451
|
const previousOffset = (0, import_react181.useRef)(void 0);
|
|
45424
45452
|
const previousReverseOffset = (0, import_react181.useRef)(void 0);
|
|
45425
45453
|
const scrollListenerRef = (0, import_react181.useRef)(void 0);
|
|
45426
45454
|
scrollListenerRef.current = () => {
|
|
45427
|
-
const
|
|
45428
|
-
if (!
|
|
45455
|
+
const element4 = scrollComponent;
|
|
45456
|
+
if (!element4 || element4.offsetParent === null) {
|
|
45429
45457
|
return;
|
|
45430
45458
|
}
|
|
45431
|
-
const parentElement =
|
|
45432
|
-
const offset =
|
|
45459
|
+
const parentElement = element4.parentElement;
|
|
45460
|
+
const offset = element4.scrollHeight - parentElement.scrollTop - parentElement.clientHeight;
|
|
45433
45461
|
const reverseOffset = parentElement.scrollTop;
|
|
45434
45462
|
if (listenToScroll) {
|
|
45435
45463
|
listenToScroll(offset, reverseOffset, threshold);
|
|
@@ -45458,7 +45486,7 @@ var InfiniteScroll = (props) => {
|
|
|
45458
45486
|
);
|
|
45459
45487
|
}, []);
|
|
45460
45488
|
(0, import_react181.useEffect)(() => {
|
|
45461
|
-
const scrollElement = scrollComponent
|
|
45489
|
+
const scrollElement = scrollComponent?.parentNode;
|
|
45462
45490
|
if (!scrollElement) return;
|
|
45463
45491
|
const scrollListener = () => scrollListenerRef.current?.();
|
|
45464
45492
|
scrollElement.addEventListener("scroll", scrollListener, useCapture);
|
|
@@ -45468,29 +45496,16 @@ var InfiniteScroll = (props) => {
|
|
|
45468
45496
|
scrollElement.removeEventListener("scroll", scrollListener, useCapture);
|
|
45469
45497
|
scrollElement.removeEventListener("resize", scrollListener, useCapture);
|
|
45470
45498
|
};
|
|
45471
|
-
}, [initialLoad, useCapture]);
|
|
45499
|
+
}, [initialLoad, scrollComponent, useCapture]);
|
|
45472
45500
|
(0, import_react181.useEffect)(() => {
|
|
45473
|
-
const scrollElement = scrollComponent
|
|
45474
|
-
if (scrollElement)
|
|
45475
|
-
|
|
45476
|
-
}
|
|
45501
|
+
const scrollElement = scrollComponent?.parentNode;
|
|
45502
|
+
if (!scrollElement) return;
|
|
45503
|
+
scrollElement.addEventListener("wheel", mousewheelListener2, { passive: false });
|
|
45477
45504
|
return () => {
|
|
45478
|
-
|
|
45479
|
-
scrollElement.removeEventListener("wheel", mousewheelListener2, useCapture);
|
|
45480
|
-
}
|
|
45505
|
+
scrollElement.removeEventListener("wheel", mousewheelListener2, useCapture);
|
|
45481
45506
|
};
|
|
45482
|
-
}, [useCapture]);
|
|
45483
|
-
|
|
45484
|
-
...elementProps,
|
|
45485
|
-
ref: (element5) => {
|
|
45486
|
-
scrollComponent.current = element5;
|
|
45487
|
-
}
|
|
45488
|
-
};
|
|
45489
|
-
const childrenArray = [loader, children];
|
|
45490
|
-
if (head) {
|
|
45491
|
-
childrenArray.unshift(head);
|
|
45492
|
-
}
|
|
45493
|
-
return import_react181.default.createElement(element4, attributes, childrenArray);
|
|
45507
|
+
}, [scrollComponent, useCapture]);
|
|
45508
|
+
return /* @__PURE__ */ import_react181.default.createElement(Component2, { ...elementProps, ref: setScrollComponent }, head, loader, children);
|
|
45494
45509
|
};
|
|
45495
45510
|
|
|
45496
45511
|
// src/components/TypingIndicator/TypingIndicator.tsx
|
|
@@ -46738,10 +46753,10 @@ function VirtualizedMessageList(props) {
|
|
|
46738
46753
|
);
|
|
46739
46754
|
}
|
|
46740
46755
|
|
|
46741
|
-
// src/components/Message/
|
|
46756
|
+
// src/components/Message/MessageIsThreadReplyInChannelButtonIndicator.tsx
|
|
46742
46757
|
var import_react199 = __toESM(require("react"));
|
|
46743
46758
|
var import_stream_chat6 = require("stream-chat");
|
|
46744
|
-
var
|
|
46759
|
+
var MessageIsThreadReplyInChannelButtonIndicator = () => {
|
|
46745
46760
|
const { client } = useChatContext();
|
|
46746
46761
|
const { t } = useTranslationContext();
|
|
46747
46762
|
const { channel } = useChannelStateContext();
|
|
@@ -46762,7 +46777,7 @@ var MessageThreadReplyInChannelButtonIndicator = () => {
|
|
|
46762
46777
|
},
|
|
46763
46778
|
origin: {
|
|
46764
46779
|
context: { threadReply: message },
|
|
46765
|
-
emitter: "
|
|
46780
|
+
emitter: "MessageIsThreadReplyInChannelButtonIndicator"
|
|
46766
46781
|
}
|
|
46767
46782
|
});
|
|
46768
46783
|
});
|
|
@@ -47262,7 +47277,7 @@ var MessageSimpleWithContext = (props) => {
|
|
|
47262
47277
|
MessageBlocked: MessageBlocked2 = MessageBlocked,
|
|
47263
47278
|
MessageBouncePrompt: MessageBouncePrompt2 = MessageBouncePrompt,
|
|
47264
47279
|
MessageDeleted: MessageDeleted2 = MessageDeleted,
|
|
47265
|
-
MessageIsThreadReplyInChannelButtonIndicator =
|
|
47280
|
+
MessageIsThreadReplyInChannelButtonIndicator: MessageIsThreadReplyInChannelButtonIndicator2 = MessageIsThreadReplyInChannelButtonIndicator,
|
|
47266
47281
|
MessageRepliesCountButton: MessageRepliesCountButton2 = MessageRepliesCountButton,
|
|
47267
47282
|
MessageStatus: MessageStatus2 = MessageStatus,
|
|
47268
47283
|
MessageTimestamp: MessageTimestamp2 = MessageTimestamp,
|
|
@@ -47367,7 +47382,7 @@ var MessageSimpleWithContext = (props) => {
|
|
|
47367
47382
|
onClick: handleOpenThread,
|
|
47368
47383
|
reply_count: message.reply_count
|
|
47369
47384
|
}
|
|
47370
|
-
), showIsReplyInChannel && /* @__PURE__ */ import_react207.default.createElement(
|
|
47385
|
+
), showIsReplyInChannel && /* @__PURE__ */ import_react207.default.createElement(MessageIsThreadReplyInChannelButtonIndicator2, null), showMetadata && /* @__PURE__ */ import_react207.default.createElement("div", { className: "str-chat__message-metadata" }, /* @__PURE__ */ import_react207.default.createElement(MessageStatus2, null), !isMyMessage() && !!message.user && /* @__PURE__ */ import_react207.default.createElement("span", { className: "str-chat__message-simple-name" }, message.user.name || message.user.id), /* @__PURE__ */ import_react207.default.createElement(MessageTimestamp2, { customClass: "str-chat__message-simple-timestamp" }), isEdited && /* @__PURE__ */ import_react207.default.createElement("span", { className: "str-chat__mesage-simple-edited" }, t("Edited")), isEdited && /* @__PURE__ */ import_react207.default.createElement(MessageEditedTimestamp, { calendar: true, open: isEditedTimestampOpen }))));
|
|
47371
47386
|
};
|
|
47372
47387
|
var MemoizedMessageSimple = import_react207.default.memo(
|
|
47373
47388
|
MessageSimpleWithContext,
|
|
@@ -52623,7 +52638,7 @@ var useChat = ({
|
|
|
52623
52638
|
};
|
|
52624
52639
|
(0, import_react272.useEffect)(() => {
|
|
52625
52640
|
if (!client) return;
|
|
52626
|
-
const version = "13.1.
|
|
52641
|
+
const version = "13.1.2";
|
|
52627
52642
|
const userAgent = client.getUserAgent();
|
|
52628
52643
|
if (!userAgent.includes("stream-chat-react")) {
|
|
52629
52644
|
client.setUserAgent(`stream-chat-react-${version}-${userAgent}`);
|