@sendbird/uikit-utils 2.2.0 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonjs/hooks/index.js +38 -1
- package/lib/commonjs/hooks/index.js.map +1 -1
- package/lib/commonjs/hooks/react-native.js +54 -0
- package/lib/commonjs/hooks/react-native.js.map +1 -0
- package/lib/commonjs/index.js +53 -21
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/sendbird/channel.js +29 -1
- package/lib/commonjs/sendbird/channel.js.map +1 -1
- package/lib/commonjs/sendbird/message.js +56 -1
- package/lib/commonjs/sendbird/message.js.map +1 -1
- package/lib/commonjs/sendbird/user.js +0 -6
- package/lib/commonjs/sendbird/user.js.map +1 -1
- package/lib/commonjs/shared/index.js +86 -0
- package/lib/commonjs/shared/index.js.map +1 -0
- package/lib/commonjs/types.js.map +1 -1
- package/lib/commonjs/ui-format/openChannel.js +22 -0
- package/lib/commonjs/ui-format/openChannel.js.map +1 -0
- package/lib/module/hooks/index.js +29 -1
- package/lib/module/hooks/index.js.map +1 -1
- package/lib/module/hooks/react-native.js +37 -0
- package/lib/module/hooks/react-native.js.map +1 -0
- package/lib/module/index.js +10 -3
- package/lib/module/index.js.map +1 -1
- package/lib/module/sendbird/channel.js +23 -1
- package/lib/module/sendbird/channel.js.map +1 -1
- package/lib/module/sendbird/message.js +51 -1
- package/lib/module/sendbird/message.js.map +1 -1
- package/lib/module/sendbird/user.js +0 -4
- package/lib/module/sendbird/user.js.map +1 -1
- package/lib/module/shared/index.js +67 -0
- package/lib/module/shared/index.js.map +1 -0
- package/lib/module/types.js.map +1 -1
- package/lib/module/ui-format/openChannel.js +10 -0
- package/lib/module/ui-format/openChannel.js.map +1 -0
- package/lib/typescript/src/hooks/index.d.ts +3 -0
- package/lib/typescript/src/hooks/react-native.d.ts +12 -0
- package/lib/typescript/src/index.d.ts +9 -4
- package/lib/typescript/src/sendbird/channel.d.ts +10 -1
- package/lib/typescript/src/sendbird/message.d.ts +3 -0
- package/lib/typescript/src/sendbird/user.d.ts +0 -2
- package/lib/typescript/src/shared/index.d.ts +32 -0
- package/lib/typescript/src/types.d.ts +8 -3
- package/lib/typescript/src/ui-format/openChannel.d.ts +3 -0
- package/package.json +5 -4
- package/src/hooks/index.ts +31 -1
- package/src/hooks/react-native.ts +54 -0
- package/src/index.ts +20 -3
- package/src/sendbird/channel.ts +33 -2
- package/src/sendbird/message.ts +54 -1
- package/src/sendbird/user.ts +0 -7
- package/src/shared/index.ts +66 -0
- package/src/types.ts +17 -2
- package/src/ui-format/openChannel.ts +11 -0
- package/lib/commonjs/shared/conditionChaining.js +0 -15
- package/lib/commonjs/shared/conditionChaining.js.map +0 -1
- package/lib/commonjs/shared/replace.js +0 -14
- package/lib/commonjs/shared/replace.js.map +0 -1
- package/lib/module/shared/conditionChaining.js +0 -7
- package/lib/module/shared/conditionChaining.js.map +0 -1
- package/lib/module/shared/replace.js +0 -6
- package/lib/module/shared/replace.js.map +0 -1
- package/lib/typescript/src/shared/conditionChaining.d.ts +0 -2
- package/lib/typescript/src/shared/replace.d.ts +0 -2
- package/src/shared/conditionChaining.ts +0 -6
- package/src/shared/replace.ts +0 -5
package/src/types.ts
CHANGED
|
@@ -9,6 +9,7 @@ import type {
|
|
|
9
9
|
Emoji,
|
|
10
10
|
EmojiCategory,
|
|
11
11
|
EmojiContainer,
|
|
12
|
+
Participant,
|
|
12
13
|
RestrictedUser,
|
|
13
14
|
SendbirdError as SBError,
|
|
14
15
|
User,
|
|
@@ -24,7 +25,12 @@ import type {
|
|
|
24
25
|
Member,
|
|
25
26
|
MessageCollection,
|
|
26
27
|
} from '@sendbird/chat/groupChannel';
|
|
27
|
-
import type {
|
|
28
|
+
import type {
|
|
29
|
+
ModuleNamespaces,
|
|
30
|
+
OpenChannelCreateParams,
|
|
31
|
+
OpenChannelUpdateParams,
|
|
32
|
+
SendableMessage,
|
|
33
|
+
} from '@sendbird/chat/lib/__definition';
|
|
28
34
|
import type {
|
|
29
35
|
AdminMessage,
|
|
30
36
|
BaseMessage,
|
|
@@ -37,7 +43,7 @@ import type {
|
|
|
37
43
|
UserMessageCreateParams,
|
|
38
44
|
UserMessageUpdateParams,
|
|
39
45
|
} from '@sendbird/chat/message';
|
|
40
|
-
import type { OpenChannel, OpenChannelModule } from '@sendbird/chat/openChannel';
|
|
46
|
+
import type { OpenChannel, OpenChannelListQuery, OpenChannelModule } from '@sendbird/chat/openChannel';
|
|
41
47
|
|
|
42
48
|
export type FilterByValueType<T extends object, Type> = {
|
|
43
49
|
[K in keyof T as T[K] extends Type ? K : never]: T[K];
|
|
@@ -65,6 +71,8 @@ export type Optional<T> = T | undefined;
|
|
|
65
71
|
|
|
66
72
|
export type ContextValue<T extends React.Context<any>> = T extends React.Context<infer V> ? V : never;
|
|
67
73
|
|
|
74
|
+
export type OnBeforeHandler<T> = (params: T) => T | Promise<T>;
|
|
75
|
+
|
|
68
76
|
export interface UserStruct {
|
|
69
77
|
userId: string;
|
|
70
78
|
}
|
|
@@ -81,12 +89,18 @@ export type SendbirdFileMessageCreateParams = FileMessageCreateParams;
|
|
|
81
89
|
export type SendbirdFileMessageUpdateParams = FileMessageUpdateParams;
|
|
82
90
|
export type SendbirdUserMessageCreateParams = UserMessageCreateParams;
|
|
83
91
|
export type SendbirdUserMessageUpdateParams = UserMessageUpdateParams;
|
|
92
|
+
|
|
84
93
|
export type SendbirdGroupChannelCreateParams = GroupChannelCreateParams;
|
|
85
94
|
export type SendbirdGroupChannelUpdateParams = GroupChannelUpdateParams;
|
|
95
|
+
export type SendbirdOpenChannelCreateParams = OpenChannelCreateParams;
|
|
96
|
+
export type SendbirdOpenChannelUpdateParams = OpenChannelUpdateParams;
|
|
97
|
+
|
|
86
98
|
export type SendbirdUserUpdateParams = UserUpdateParams;
|
|
87
99
|
export type SendbirdUser = User;
|
|
88
100
|
export type SendbirdRestrictedUser = RestrictedUser;
|
|
89
101
|
export type SendbirdMember = Member;
|
|
102
|
+
export type SendbirdParticipant = Participant;
|
|
103
|
+
|
|
90
104
|
export type SendbirdGroupChannel = GroupChannel;
|
|
91
105
|
export type SendbirdBaseChannel = BaseChannel;
|
|
92
106
|
export type SendbirdOpenChannel = OpenChannel;
|
|
@@ -98,6 +112,7 @@ export type SendbirdEmojiContainer = EmojiContainer;
|
|
|
98
112
|
|
|
99
113
|
export type SendbirdGroupChannelCollection = GroupChannelCollection;
|
|
100
114
|
export type SendbirdGroupChannelListQuery = GroupChannelListQuery;
|
|
115
|
+
export type SendbirdOpenChannelListQuery = OpenChannelListQuery;
|
|
101
116
|
export type SendbirdMessageCollection = MessageCollection;
|
|
102
117
|
export type SendbirdPreviousMessageListQuery = PreviousMessageListQuery;
|
|
103
118
|
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { SendbirdOpenChannel } from '../types';
|
|
2
|
+
|
|
3
|
+
export const getOpenChannelTitle = (channel: SendbirdOpenChannel, DEFAULT_CHANNEL_NAME = 'Open Channel') => {
|
|
4
|
+
const trimmedChannelName = channel.name.trim();
|
|
5
|
+
if (trimmedChannelName === '') return DEFAULT_CHANNEL_NAME;
|
|
6
|
+
return trimmedChannelName;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export const getOpenChannelParticipants = (channel: SendbirdOpenChannel) => {
|
|
10
|
+
return `${channel.participantCount} participants`;
|
|
11
|
+
};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
const conditionChaining = (conditions, values) => {
|
|
9
|
-
const idx = conditions.findIndex(state => Boolean(state));
|
|
10
|
-
return idx > -1 ? values[idx] : values[values.length - 1];
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
var _default = conditionChaining;
|
|
14
|
-
exports.default = _default;
|
|
15
|
-
//# sourceMappingURL=conditionChaining.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["conditionChaining","conditions","values","idx","findIndex","state","Boolean","length"],"sources":["conditionChaining.ts"],"sourcesContent":["const conditionChaining = <T, V>(conditions: T[], values: V[]) => {\n const idx = conditions.findIndex((state) => Boolean(state));\n return idx > -1 ? values[idx] : values[values.length - 1];\n};\n\nexport default conditionChaining;\n"],"mappings":";;;;;;;AAAA,MAAMA,iBAAiB,GAAG,CAAOC,UAAP,EAAwBC,MAAxB,KAAwC;EAChE,MAAMC,GAAG,GAAGF,UAAU,CAACG,SAAX,CAAsBC,KAAD,IAAWC,OAAO,CAACD,KAAD,CAAvC,CAAZ;EACA,OAAOF,GAAG,GAAG,CAAC,CAAP,GAAWD,MAAM,CAACC,GAAD,CAAjB,GAAyBD,MAAM,CAACA,MAAM,CAACK,MAAP,GAAgB,CAAjB,CAAtC;AACD,CAHD;;eAKeP,iB"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
const replace = (original, start, end, str) => {
|
|
9
|
-
return original.slice(0, start) + str + original.slice(end);
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
var _default = replace;
|
|
13
|
-
exports.default = _default;
|
|
14
|
-
//# sourceMappingURL=replace.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["replace","original","start","end","str","slice"],"sources":["replace.ts"],"sourcesContent":["const replace = (original: string, start: number, end: number, str: string) => {\n return original.slice(0, start) + str + original.slice(end);\n};\n\nexport default replace;\n"],"mappings":";;;;;;;AAAA,MAAMA,OAAO,GAAG,CAACC,QAAD,EAAmBC,KAAnB,EAAkCC,GAAlC,EAA+CC,GAA/C,KAA+D;EAC7E,OAAOH,QAAQ,CAACI,KAAT,CAAe,CAAf,EAAkBH,KAAlB,IAA2BE,GAA3B,GAAiCH,QAAQ,CAACI,KAAT,CAAeF,GAAf,CAAxC;AACD,CAFD;;eAIeH,O"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["conditionChaining","conditions","values","idx","findIndex","state","Boolean","length"],"sources":["conditionChaining.ts"],"sourcesContent":["const conditionChaining = <T, V>(conditions: T[], values: V[]) => {\n const idx = conditions.findIndex((state) => Boolean(state));\n return idx > -1 ? values[idx] : values[values.length - 1];\n};\n\nexport default conditionChaining;\n"],"mappings":"AAAA,MAAMA,iBAAiB,GAAG,CAAOC,UAAP,EAAwBC,MAAxB,KAAwC;EAChE,MAAMC,GAAG,GAAGF,UAAU,CAACG,SAAX,CAAsBC,KAAD,IAAWC,OAAO,CAACD,KAAD,CAAvC,CAAZ;EACA,OAAOF,GAAG,GAAG,CAAC,CAAP,GAAWD,MAAM,CAACC,GAAD,CAAjB,GAAyBD,MAAM,CAACA,MAAM,CAACK,MAAP,GAAgB,CAAjB,CAAtC;AACD,CAHD;;AAKA,eAAeP,iBAAf"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["replace","original","start","end","str","slice"],"sources":["replace.ts"],"sourcesContent":["const replace = (original: string, start: number, end: number, str: string) => {\n return original.slice(0, start) + str + original.slice(end);\n};\n\nexport default replace;\n"],"mappings":"AAAA,MAAMA,OAAO,GAAG,CAACC,QAAD,EAAmBC,KAAnB,EAAkCC,GAAlC,EAA+CC,GAA/C,KAA+D;EAC7E,OAAOH,QAAQ,CAACI,KAAT,CAAe,CAAf,EAAkBH,KAAlB,IAA2BE,GAA3B,GAAiCH,QAAQ,CAACI,KAAT,CAAeF,GAAf,CAAxC;AACD,CAFD;;AAIA,eAAeH,OAAf"}
|