@sendbird/uikit-utils 2.0.3 → 2.2.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.
Files changed (68) hide show
  1. package/lib/commonjs/hooks/index.js +14 -1
  2. package/lib/commonjs/hooks/index.js.map +1 -1
  3. package/lib/commonjs/index.js +39 -2
  4. package/lib/commonjs/index.js.map +1 -1
  5. package/lib/commonjs/sendbird/channel.js +18 -6
  6. package/lib/commonjs/sendbird/channel.js.map +1 -1
  7. package/lib/commonjs/sendbird/message.js +12 -2
  8. package/lib/commonjs/sendbird/message.js.map +1 -1
  9. package/lib/commonjs/sendbird/user.js +23 -0
  10. package/lib/commonjs/sendbird/user.js.map +1 -0
  11. package/lib/commonjs/shared/bufferedRequest.js +38 -12
  12. package/lib/commonjs/shared/bufferedRequest.js.map +1 -1
  13. package/lib/commonjs/shared/regex.js +52 -6
  14. package/lib/commonjs/shared/regex.js.map +1 -1
  15. package/lib/commonjs/shared/replace.js +14 -0
  16. package/lib/commonjs/shared/replace.js.map +1 -0
  17. package/lib/commonjs/types.js +3 -1
  18. package/lib/commonjs/types.js.map +1 -1
  19. package/lib/commonjs/ui-format/common.js +17 -14
  20. package/lib/commonjs/ui-format/common.js.map +1 -1
  21. package/lib/commonjs/ui-format/groupChannel.js +7 -10
  22. package/lib/commonjs/ui-format/groupChannel.js.map +1 -1
  23. package/lib/module/hooks/index.js +10 -0
  24. package/lib/module/hooks/index.js.map +1 -1
  25. package/lib/module/index.js +4 -2
  26. package/lib/module/index.js.map +1 -1
  27. package/lib/module/sendbird/channel.js +14 -4
  28. package/lib/module/sendbird/channel.js.map +1 -1
  29. package/lib/module/sendbird/message.js +9 -3
  30. package/lib/module/sendbird/message.js.map +1 -1
  31. package/lib/module/sendbird/user.js +12 -0
  32. package/lib/module/sendbird/user.js.map +1 -0
  33. package/lib/module/shared/bufferedRequest.js +39 -12
  34. package/lib/module/shared/bufferedRequest.js.map +1 -1
  35. package/lib/module/shared/regex.js +43 -3
  36. package/lib/module/shared/regex.js.map +1 -1
  37. package/lib/module/shared/replace.js +6 -0
  38. package/lib/module/shared/replace.js.map +1 -0
  39. package/lib/module/types.js +1 -4
  40. package/lib/module/types.js.map +1 -1
  41. package/lib/module/ui-format/common.js +12 -7
  42. package/lib/module/ui-format/common.js.map +1 -1
  43. package/lib/module/ui-format/groupChannel.js +5 -4
  44. package/lib/module/ui-format/groupChannel.js.map +1 -1
  45. package/lib/typescript/src/hooks/index.d.ts +3 -2
  46. package/lib/typescript/src/index.d.ts +4 -2
  47. package/lib/typescript/src/sendbird/channel.d.ts +6 -1
  48. package/lib/typescript/src/sendbird/message.d.ts +4 -2
  49. package/lib/typescript/src/sendbird/user.d.ts +7 -0
  50. package/lib/typescript/src/shared/bufferedRequest.d.ts +6 -4
  51. package/lib/typescript/src/shared/logger.d.ts +1 -1
  52. package/lib/typescript/src/shared/pubsub.d.ts +2 -2
  53. package/lib/typescript/src/shared/regex.d.ts +8 -0
  54. package/lib/typescript/src/shared/replace.d.ts +2 -0
  55. package/lib/typescript/src/types.d.ts +42 -35
  56. package/lib/typescript/src/ui-format/common.d.ts +7 -6
  57. package/package.json +3 -3
  58. package/src/hooks/index.ts +11 -0
  59. package/src/index.ts +14 -2
  60. package/src/sendbird/channel.ts +11 -4
  61. package/src/sendbird/message.ts +13 -3
  62. package/src/sendbird/user.ts +21 -0
  63. package/src/shared/bufferedRequest.ts +37 -12
  64. package/src/shared/regex.ts +35 -0
  65. package/src/shared/replace.ts +5 -0
  66. package/src/types.ts +21 -3
  67. package/src/ui-format/common.ts +9 -7
  68. package/src/ui-format/groupChannel.ts +5 -4
@@ -5,7 +5,8 @@ export const urlRegexStrict = /(https?:\/\/|www\.)[-a-zA-Z0-9@:%._+~#=]{1,256}\.
5
5
  export const urlRegexRough = /(https?:\/\/|www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/g;
6
6
  export const phoneRegex = /[+]?[(]?[0-9]{3}[)]?[-\s.]?[0-9]{3}[-\s.]?[0-9]{4,7}/;
7
7
  export const emailRegex = /\S+@\S+\.\S+/;
8
- export const newLineRegex = /\r\n|\r|\n/g; // const cases = [
8
+ export const newLineRegex = /\r\n|\r|\n/g;
9
+ export const createMentionTemplateRegex = trigger => new RegExp(`(${trigger}[{])(.*?)([}])`, 'g'); // const cases = [
9
10
  // {
10
11
  // type: 'urlStrict',
11
12
  // regex: urlRegexStrict,
@@ -24,6 +25,45 @@ export const newLineRegex = /\r\n|\r|\n/g; // const cases = [
24
25
  // },
25
26
  // ];
26
27
 
28
+ export const replaceWithRegex = (text, regex, replacer, keyPrefix) => {
29
+ const matches = [...text.matchAll(regex)];
30
+ const founds = matches.map(value => {
31
+ const text = value[0];
32
+ const start = value.index ?? 0;
33
+ const end = start + text.length;
34
+ return {
35
+ text,
36
+ start,
37
+ end,
38
+ groups: value,
39
+ matchIndex: value.index
40
+ };
41
+ });
42
+ const items = [text];
43
+ let cursor = 0;
44
+ founds.forEach((_ref, index) => {
45
+ let {
46
+ text,
47
+ start,
48
+ end,
49
+ groups,
50
+ matchIndex
51
+ } = _ref;
52
+ const restText = items.pop();
53
+ const head = restText.slice(0, start - cursor);
54
+ const mid = replacer({
55
+ match: text,
56
+ groups,
57
+ matchIndex,
58
+ index,
59
+ keyPrefix
60
+ });
61
+ const tail = restText.slice(end - cursor);
62
+ items.push(head, mid, tail);
63
+ cursor = end;
64
+ });
65
+ return items;
66
+ };
27
67
  export const replaceUrlAsComponents = (originText, replacer, strict) => {
28
68
  const matches = [...originText.matchAll(strict ? urlRegexStrict : urlRegexRough)];
29
69
  const founds = matches.map(value => {
@@ -38,12 +78,12 @@ export const replaceUrlAsComponents = (originText, replacer, strict) => {
38
78
  });
39
79
  const items = [originText];
40
80
  let cursor = 0;
41
- founds.forEach(_ref => {
81
+ founds.forEach(_ref2 => {
42
82
  let {
43
83
  text,
44
84
  start,
45
85
  end
46
- } = _ref;
86
+ } = _ref2;
47
87
  const restText = items.pop();
48
88
  const head = restText.slice(0, start - cursor);
49
89
  const mid = replacer(text);
@@ -1 +1 @@
1
- {"version":3,"names":["require","shim","urlRegexStrict","urlRegexRough","phoneRegex","emailRegex","newLineRegex","replaceUrlAsComponents","originText","replacer","strict","matches","matchAll","founds","map","value","text","start","index","end","length","items","cursor","forEach","restText","pop","head","slice","mid","tail","push","imageExtRegex","audioExtRegex","videoExtRegex","getFileType","extOrType","indexOf","type","split","match","getFileExtension","filePath","idx","lastIndexOf","toLowerCase","normalizeFileName","fileName","extension"],"sources":["regex.ts"],"sourcesContent":["// For iOS 12 backwards compatibility\nrequire('string.prototype.matchall').shim();\n\nexport const urlRegexStrict =\n /(https?:\\/\\/|www\\.)[-a-zA-Z0-9@:%._+~#=]{1,256}\\.(xn--)?[a-z0-9-]{2,20}\\b([-a-zA-Z0-9@:%_+[\\],.~#?&/=]*[-a-zA-Z0-9@:%_+\\]~#?&/=])*/g;\nexport const urlRegexRough =\n /(https?:\\/\\/|www\\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\\.[a-zA-Z0-9()]{1,6}\\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/g;\nexport const phoneRegex = /[+]?[(]?[0-9]{3}[)]?[-\\s.]?[0-9]{3}[-\\s.]?[0-9]{4,7}/;\nexport const emailRegex = /\\S+@\\S+\\.\\S+/;\nexport const newLineRegex = /\\r\\n|\\r|\\n/g;\n\n// const cases = [\n// {\n// type: 'urlStrict',\n// regex: urlRegexStrict,\n// },\n// {\n// type: 'urlRough',\n// regex: urlRegexStrict,\n// },\n// {\n// type: 'email',\n// regex: emailRegex,\n// },\n// {\n// type: 'phone',\n// regex: urlRegexStrict,\n// },\n// ];\n\nexport const replaceUrlAsComponents = <T>(originText: string, replacer: (url: string) => T, strict?: boolean) => {\n const matches = [...originText.matchAll(strict ? urlRegexStrict : urlRegexRough)];\n const founds = matches.map((value) => {\n const text = value[0];\n const start = value.index ?? 0;\n const end = start + text.length;\n return { text, start, end };\n });\n\n const items: Array<string | T> = [originText];\n let cursor = 0;\n founds.forEach(({ text, start, end }) => {\n const restText = items.pop() as string;\n const head = restText.slice(0, start - cursor);\n const mid = replacer(text);\n const tail = restText.slice(end - cursor);\n items.push(head, mid, tail);\n cursor = end;\n });\n return items;\n};\n\nexport const imageExtRegex = /jpeg|jpg|png|webp|gif/i;\nexport const audioExtRegex = /3gp|aac|aax|act|aiff|flac|gsm|m4a|m4b|m4p|tta|wma|mp3|webm|wav/i;\nexport const videoExtRegex = /mov|vod|mp4|avi/i;\nexport const getFileType = (extOrType: string) => {\n if (extOrType.indexOf('/') > -1) {\n const type = extOrType.split('/')[0];\n if (type === 'video') return 'video';\n if (type === 'audio') return 'audio';\n if (type === 'image') return 'image';\n return 'file';\n }\n\n if (extOrType.match(imageExtRegex)) return 'image';\n if (extOrType.match(audioExtRegex)) return 'audio';\n if (extOrType.match(videoExtRegex)) return 'video';\n return 'file';\n};\nexport function getFileExtension(filePath: string) {\n const idx = filePath.lastIndexOf('.');\n if (idx === -1) return '';\n return filePath.slice(idx - filePath.length).toLowerCase();\n}\nexport function normalizeFileName(fileName: string, extension: string) {\n if (fileName.indexOf(extension) > -1) {\n return fileName;\n } else {\n if (extension.indexOf('.') === 0) {\n return `${fileName}${extension}`;\n } else {\n return `${fileName}.${extension}`;\n }\n }\n}\n"],"mappings":"AAAA;AACAA,OAAO,CAAC,2BAAD,CAAP,CAAqCC,IAArC;;AAEA,OAAO,MAAMC,cAAc,GACzB,qIADK;AAEP,OAAO,MAAMC,aAAa,GACxB,uGADK;AAEP,OAAO,MAAMC,UAAU,GAAG,sDAAnB;AACP,OAAO,MAAMC,UAAU,GAAG,cAAnB;AACP,OAAO,MAAMC,YAAY,GAAG,aAArB,C,CAEP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,MAAMC,sBAAsB,G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Rough","phoneRegex","emailRegex","newLineRegex","createMentionTemplateRegex","trigger","RegExp","replaceWithRegex","text","regex","replacer","keyPrefix","matches","matchAll","founds","map","value","start","index","end","length","groups","matchIndex","items","cursor","forEach","restText","pop","head","slice","mid","match","tail","push","replaceUrlAsComponents","originText","strict","imageExtRegex","audioExtRegex","videoExtRegex","getFileType","extOrType","indexOf","type","split","getFileExtension","filePath","idx","lastIndexOf","toLowerCase","normalizeFileName","fileName","extension"],"sources":["regex.ts"],"sourcesContent":["// For iOS 12 backwards compatibility\nrequire('string.prototype.matchall').shim();\n\nexport const urlRegexStrict =\n /(https?:\\/\\/|www\\.)[-a-zA-Z0-9@:%._+~#=]{1,256}\\.(xn--)?[a-z0-9-]{2,20}\\b([-a-zA-Z0-9@:%_+[\\],.~#?&/=]*[-a-zA-Z0-9@:%_+\\]~#?&/=])*/g;\nexport const urlRegexRough =\n /(https?:\\/\\/|www\\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\\.[a-zA-Z0-9()]{1,6}\\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/g;\nexport const phoneRegex = /[+]?[(]?[0-9]{3}[)]?[-\\s.]?[0-9]{3}[-\\s.]?[0-9]{4,7}/;\nexport const emailRegex = /\\S+@\\S+\\.\\S+/;\nexport const newLineRegex = /\\r\\n|\\r|\\n/g;\n\nexport const createMentionTemplateRegex = (trigger: string) => new RegExp(`(${trigger}[{])(.*?)([}])`, 'g');\n\n// const cases = [\n// {\n// type: 'urlStrict',\n// regex: urlRegexStrict,\n// },\n// {\n// type: 'urlRough',\n// regex: urlRegexStrict,\n// },\n// {\n// type: 'email',\n// regex: emailRegex,\n// },\n// {\n// type: 'phone',\n// regex: urlRegexStrict,\n// },\n// ];\n\nexport const replaceWithRegex = <T>(\n text: string,\n regex: RegExp,\n replacer: (params: {\n match: string;\n groups: string[];\n matchIndex: number | undefined;\n index: number;\n keyPrefix: string;\n }) => T,\n keyPrefix: string,\n) => {\n const matches = [...text.matchAll(regex)];\n const founds = matches.map((value) => {\n const text = value[0];\n const start = value.index ?? 0;\n const end = start + text.length;\n return { text, start, end, groups: value, matchIndex: value.index };\n });\n\n const items: Array<T | string> = [text];\n let cursor = 0;\n founds.forEach(({ text, start, end, groups, matchIndex }, index) => {\n const restText = items.pop() as string;\n const head = restText.slice(0, start - cursor);\n const mid = replacer({ match: text, groups, matchIndex, index, keyPrefix });\n const tail = restText.slice(end - cursor);\n items.push(head, mid, tail);\n cursor = end;\n });\n return items;\n};\n\nexport const replaceUrlAsComponents = <T>(originText: string, replacer: (url: string) => T, strict?: boolean) => {\n const matches = [...originText.matchAll(strict ? urlRegexStrict : urlRegexRough)];\n const founds = matches.map((value) => {\n const text = value[0];\n const start = value.index ?? 0;\n const end = start + text.length;\n return { text, start, end };\n });\n\n const items: Array<string | T> = [originText];\n let cursor = 0;\n founds.forEach(({ text, start, end }) => {\n const restText = items.pop() as string;\n const head = restText.slice(0, start - cursor);\n const mid = replacer(text);\n const tail = restText.slice(end - cursor);\n items.push(head, mid, tail);\n cursor = end;\n });\n return items;\n};\n\nexport const imageExtRegex = /jpeg|jpg|png|webp|gif/i;\nexport const audioExtRegex = /3gp|aac|aax|act|aiff|flac|gsm|m4a|m4b|m4p|tta|wma|mp3|webm|wav/i;\nexport const videoExtRegex = /mov|vod|mp4|avi/i;\nexport const getFileType = (extOrType: string) => {\n if (extOrType.indexOf('/') > -1) {\n const type = extOrType.split('/')[0];\n if (type === 'video') return 'video';\n if (type === 'audio') return 'audio';\n if (type === 'image') return 'image';\n return 'file';\n }\n\n if (extOrType.match(imageExtRegex)) return 'image';\n if (extOrType.match(audioExtRegex)) return 'audio';\n if (extOrType.match(videoExtRegex)) return 'video';\n return 'file';\n};\nexport function getFileExtension(filePath: string) {\n const idx = filePath.lastIndexOf('.');\n if (idx === -1) return '';\n return filePath.slice(idx - filePath.length).toLowerCase();\n}\nexport function normalizeFileName(fileName: string, extension: string) {\n if (fileName.indexOf(extension) > -1) {\n return fileName;\n } else {\n if (extension.indexOf('.') === 0) {\n return `${fileName}${extension}`;\n } else {\n return `${fileName}.${extension}`;\n }\n }\n}\n"],"mappings":"AAAA;AACAA,OAAO,CAAC,2BAAD,CAAP,CAAqCC,IAArC;;AAEA,OAAO,MAAMC,cAAc,GACzB,qIADK;AAEP,OAAO,MAAMC,aAAa,GACxB,uGADK;AAEP,OAAO,MAAMC,UAAU,GAAG,sDAAnB;AACP,OAAO,MAAMC,UAAU,GAAG,cAAnB;AACP,OAAO,MAAMC,YAAY,GAAG,aAArB;AAEP,OAAO,MAAMC,0BAA0B,GAAIC,OAAD,IAAqB,IAAIC,MAAJ,CAAY,IAAGD,OAAQ,gBAAvB,EAAwC,GAAxC,CAAxD,C,CAEP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,MAAME,gBAAgB,GAAG,CAC9BC,IAD8B,EAE9BC,KAF8B,EAG9BC,QAH8B,EAU9BC,SAV8B,KAW3B;EACH,MAAMC,OAAO,GAAG,CAAC,GAAGJ,IAAI,CAACK,QAAL,CAAcJ,KAAd,CAAJ,CAAhB;EACA,MAAMK,MAAM,GAAGF,OAAO,CAACG,GAAR,CAAaC,KAAD,IAAW;IACpC,MAAMR,IAAI,GAAGQ,KAAK,CAAC,CAAD,CAAlB;IACA,MAAMC,KAAK,GAAGD,KAAK,CAACE,KAAN,IAAe,CAA7B;IACA,MAAMC,GAAG,GAAGF,KAAK,GAAGT,IAAI,CAACY,MAAzB;IACA,OAAO;MAAEZ,IAAF;MAAQS,KAAR;MAAeE,GAAf;MAAoBE,MAAM,EAAEL,KAA5B;MAAmCM,UAAU,EAAEN,KAAK,CAACE;IAArD,CAAP;EACD,CALc,CAAf;EAOA,MAAMK,KAAwB,GAAG,CAACf,IAAD,CAAjC;EACA,IAAIgB,MAAM,GAAG,CAAb;EACAV,MAAM,CAACW,OAAP,CAAe,OAA2CP,KAA3C,KAAqD;IAAA,IAApD;MA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,MAAMC,GAAG,GAAGD,QAAQ,CAACE,WAAT,CAAqB,GAArB,CAAZ;EACA,IAAID,GAAG,KAAK,CAAC,CAAb,EAAgB,OAAO,EAAP;EAChB,OAAOD,QAAQ,CAACjB,KAAT,CAAekB,GAAG,GAAGD,QAAQ,CAAC1B,MAA9B,EAAsC6B,WAAtC,EAAP;AACD;AACD,OAAO,SAASC,iBAAT,CAA2BC,QAA3B,EAA6CC,SAA7C,EAAgE;EACrE,IAAID,QAAQ,CAACT,OAAT,CAAiBU,SAAjB,IAA8B,CAAC,CAAnC,EAAsC;IACpC,OAAOD,QAAP;EACD,CAFD,MAEO;IACL,IAAIC,SAAS,CAACV,OAAV,CAAkB,GAAlB,MAA2B,CAA/B,EAAkC;MAChC,OAAQ,GAAES,QAAS,GAAEC,SAAU,EAA/B;IACD,CAFD,MAEO;MACL,OAAQ,GAAED,QAAS,IAAGC,SAAU,EAAhC;IACD;EACF;AACF"}
@@ -0,0 +1,6 @@
1
+ const replace = (original, start, end, str) => {
2
+ return original.slice(0, start) + str + original.slice(end);
3
+ };
4
+
5
+ export default replace;
6
+ //# sourceMappingURL=replace.js.map
@@ -0,0 +1 @@
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"}
@@ -1,5 +1,2 @@
1
- /* eslint-disable @typescript-eslint/no-explicit-any */
2
-
3
- /* eslint-disable @typescript-eslint/no-empty-interface */
4
- import './';
1
+ export {};
5
2
  //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n\n/* eslint-disable @typescript-eslint/no-empty-interface */\nimport type React from 'react';\n\nimport type SendbirdChat from '@sendbird/chat';\nimport type { BaseChannel, SendbirdError as SBError, User, UserUpdateParams } from '@sendbird/chat';\nimport type {\n GroupChannel,\n GroupChannelCollection,\n GroupChannelCreateParams,\n GroupChannelListQuery,\n GroupChannelModule,\n GroupChannelUpdateParams,\n Member,\n MessageCollection,\n} from '@sendbird/chat/groupChannel';\nimport type { ModuleNamespaces, SendableMessage } from '@sendbird/chat/lib/__definition';\nimport type {\n AdminMessage,\n BaseMessage,\n FileMessage,\n FileMessageCreateParams,\n FileMessageUpdateParams,\n PreviousMessageListQuery,\n UserMessage,\n UserMessageCreateParams,\n UserMessageUpdateParams,\n} from '@sendbird/chat/message';\nimport type { OpenChannel, OpenChannelModule } from '@sendbird/chat/openChannel';\n\nimport './';\n\nexport type FilterByValueType<T extends object, Type> = {\n [K in keyof T as T[K] extends Type ? K : never]: T[K];\n};\n\nexport type UnionToIntersection<U> = (U extends unknown ? (k: U) => void : never) extends (k: infer I) => void\n ? I\n : never;\n\nexport type OmittedValues<T, K extends keyof T> = Omit<T, K>[keyof Omit<T, K>];\n\nexport type PartialDeep<T> = T extends object\n ? T extends Function\n ? T\n : {\n [P in keyof T]?: PartialDeep<T[P]>;\n }\n : T;\n\nexport type PartialNullable<T> = {\n [P in keyof T]?: T[P] | null;\n};\n\nexport type Optional<T> = T | undefined;\n\nexport type ContextValue<T extends React.Context<any>> = T extends React.Context<infer V> ? V : never;\n\nexport type SendbirdChatSDK = SendbirdChat & ModuleNamespaces<[GroupChannelModule, OpenChannelModule]>;\nexport type SendbirdMessage = BaseMessage | FileMessage | UserMessage | AdminMessage | SendableMessage;\nexport type SendbirdChannel = BaseChannel | GroupChannel | OpenChannel;\nexport type SendbirdUserMessage = UserMessage;\nexport type SendbirdFileMessage = FileMessage;\nexport type SendbirdAdminMessage = AdminMessage;\nexport type SendbirdBaseMessage = BaseMessage;\nexport type SendbirdSendableMessage = SendableMessage;\nexport type SendbirdFileMessageCreateParams = FileMessageCreateParams;\nexport type SendbirdFileMessageUpdateParams = FileMessageUpdateParams;\nexport type SendbirdUserMessageCreateParams = UserMessageCreateParams;\nexport type SendbirdUserMessageUpdateParams = UserMessageUpdateParams;\nexport type SendbirdGroupChannelCreateParams = GroupChannelCreateParams;\nexport type SendbirdGroupChannelUpdateParams = GroupChannelUpdateParams;\nexport type SendbirdUserUpdateParams = UserUpdateParams;\nexport type SendbirdUser = User;\nexport type SendbirdMember = Member;\nexport type SendbirdGroupChannel = GroupChannel;\nexport type SendbirdBaseChannel = BaseChannel;\nexport type SendbirdOpenChannel = OpenChannel;\n\nexport type SendbirdGroupChannelCollection = GroupChannelCollection;\nexport type SendbirdGroupChannelListQuery = GroupChannelListQuery;\nexport type SendbirdMessageCollection = MessageCollection;\nexport type SendbirdPreviousMessageListQuery = PreviousMessageListQuery;\n\nexport type SendbirdError = SBError;\n\nexport interface SendbirdDataPayload {\n app_id: string;\n audience_type: string;\n category: string;\n channel: {\n channel_unread_message_count: number;\n channel_url: string;\n custom_type: string;\n name: string;\n };\n channel_type: string;\n created_at: number;\n custom_type: string;\n files: NotificationFiles[];\n mentioned_users: NotificationMentionedUsers[];\n message: string;\n message_id: number;\n push_sound: string;\n push_title: null;\n recipient: {\n id: string;\n name: string;\n push_template: string;\n };\n sender?: {\n id: string;\n name: string;\n profile_url: string;\n require_auth_for_profile_image: boolean;\n };\n sqs_ts: number;\n translations: NotificationTranslations;\n type: 'ADMM' | 'MESG' | 'FILE' | string;\n unread_message_count: number;\n}\nexport interface NotificationFiles {\n type: string;\n url: string;\n name: string;\n size: number;\n require_auth: boolean;\n}\n\nexport interface NotificationTranslations {}\nexport interface NotificationMentionedUsers {}\n"],"mappings":"AAAA;;AAEA;AA6BA,OAAO,IAAP"}
1
+ {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n\n/* eslint-disable @typescript-eslint/no-empty-interface */\nimport type React from 'react';\n\nimport type SendbirdChat from '@sendbird/chat';\nimport type {\n BaseChannel,\n Emoji,\n EmojiCategory,\n EmojiContainer,\n RestrictedUser,\n SendbirdError as SBError,\n User,\n UserUpdateParams,\n} from '@sendbird/chat';\nimport type {\n GroupChannel,\n GroupChannelCollection,\n GroupChannelCreateParams,\n GroupChannelListQuery,\n GroupChannelModule,\n GroupChannelUpdateParams,\n Member,\n MessageCollection,\n} from '@sendbird/chat/groupChannel';\nimport type { ModuleNamespaces, SendableMessage } from '@sendbird/chat/lib/__definition';\nimport type {\n AdminMessage,\n BaseMessage,\n FileMessage,\n FileMessageCreateParams,\n FileMessageUpdateParams,\n PreviousMessageListQuery,\n Reaction,\n UserMessage,\n UserMessageCreateParams,\n UserMessageUpdateParams,\n} from '@sendbird/chat/message';\nimport type { OpenChannel, OpenChannelModule } from '@sendbird/chat/openChannel';\n\nexport type FilterByValueType<T extends object, Type> = {\n [K in keyof T as T[K] extends Type ? K : never]: T[K];\n};\n\nexport type UnionToIntersection<U> = (U extends unknown ? (k: U) => void : never) extends (k: infer I) => void\n ? I\n : never;\n\nexport type OmittedValues<T, K extends keyof T> = Omit<T, K>[keyof Omit<T, K>];\n\nexport type PartialDeep<T> = T extends object\n ? T extends Function\n ? T\n : {\n [P in keyof T]?: PartialDeep<T[P]>;\n }\n : T;\n\nexport type PartialNullable<T> = {\n [P in keyof T]?: T[P] | null;\n};\n\nexport type Optional<T> = T | undefined;\n\nexport type ContextValue<T extends React.Context<any>> = T extends React.Context<infer V> ? V : never;\n\nexport interface UserStruct {\n userId: string;\n}\n\nexport type SendbirdChatSDK = SendbirdChat & ModuleNamespaces<[GroupChannelModule, OpenChannelModule]>;\nexport type SendbirdMessage = BaseMessage | FileMessage | UserMessage | AdminMessage | SendableMessage;\nexport type SendbirdChannel = BaseChannel | GroupChannel | OpenChannel;\nexport type SendbirdUserMessage = UserMessage;\nexport type SendbirdFileMessage = FileMessage;\nexport type SendbirdAdminMessage = AdminMessage;\nexport type SendbirdBaseMessage = BaseMessage;\nexport type SendbirdSendableMessage = SendableMessage;\nexport type SendbirdFileMessageCreateParams = FileMessageCreateParams;\nexport type SendbirdFileMessageUpdateParams = FileMessageUpdateParams;\nexport type SendbirdUserMessageCreateParams = UserMessageCreateParams;\nexport type SendbirdUserMessageUpdateParams = UserMessageUpdateParams;\nexport type SendbirdGroupChannelCreateParams = GroupChannelCreateParams;\nexport type SendbirdGroupChannelUpdateParams = GroupChannelUpdateParams;\nexport type SendbirdUserUpdateParams = UserUpdateParams;\nexport type SendbirdUser = User;\nexport type SendbirdRestrictedUser = RestrictedUser;\nexport type SendbirdMember = Member;\nexport type SendbirdGroupChannel = GroupChannel;\nexport type SendbirdBaseChannel = BaseChannel;\nexport type SendbirdOpenChannel = OpenChannel;\n\nexport type SendbirdReaction = Reaction;\nexport type SendbirdEmoji = Emoji;\nexport type SendbirdEmojiCategory = EmojiCategory;\nexport type SendbirdEmojiContainer = EmojiContainer;\n\nexport type SendbirdGroupChannelCollection = GroupChannelCollection;\nexport type SendbirdGroupChannelListQuery = GroupChannelListQuery;\nexport type SendbirdMessageCollection = MessageCollection;\nexport type SendbirdPreviousMessageListQuery = PreviousMessageListQuery;\n\nexport type SendbirdError = SBError;\n\nexport interface SendbirdDataPayload {\n app_id: string;\n audience_type: string;\n category: string;\n channel: {\n channel_unread_message_count: number;\n channel_url: string;\n custom_type: string;\n name: string;\n };\n channel_type: string;\n created_at: number;\n custom_type: string;\n files: NotificationFiles[];\n mentioned_users: NotificationMentionedUsers[];\n message: string;\n message_id: number;\n push_sound: string;\n push_title: null;\n recipient: {\n id: string;\n name: string;\n push_template: string;\n };\n sender?: {\n id: string;\n name: string;\n profile_url: string;\n require_auth_for_profile_image: boolean;\n };\n sqs_ts: number;\n translations: NotificationTranslations;\n type: 'ADMM' | 'MESG' | 'FILE' | string;\n unread_message_count: number;\n}\nexport interface NotificationFiles {\n type: string;\n url: string;\n name: string;\n size: number;\n require_auth: boolean;\n}\n\nexport interface NotificationTranslations {}\nexport interface NotificationMentionedUsers {}\n"],"mappings":""}
@@ -1,4 +1,4 @@
1
- import format from 'date-fns/format';
1
+ import { format, isThisYear } from 'date-fns';
2
2
  const defaultOpts = {
3
3
  mode: 'mid',
4
4
  maxLen: 40,
@@ -43,17 +43,19 @@ export const truncate = function (str) {
43
43
  throw new Error('Invalid truncate mode: ' + mode);
44
44
  };
45
45
  /**
46
- * Badge count truncate util
46
+ * Count truncate util
47
47
  * If count exceed the limit, it comes in the form of "MAX+"
48
48
  *
49
49
  * @param {number} count
50
50
  * @param {number} MAX default 99
51
+ * @param {string} MAX_SUFFIX default +
51
52
  * @returns {string}
52
53
  * */
53
54
 
54
- export const truncatedBadgeCount = function (count) {
55
+ export const truncatedCount = function (count) {
55
56
  let MAX = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 99;
56
- if (count >= MAX) return `${MAX}+`;
57
+ let MAX_SUFFIX = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '+';
58
+ if (count >= MAX) return `${MAX}${MAX_SUFFIX}`;
57
59
  return `${count}`;
58
60
  };
59
61
  /**
@@ -64,8 +66,11 @@ export const truncatedBadgeCount = function (count) {
64
66
  * @returns {string}
65
67
  * */
66
68
 
67
- export const dateSeparator = (date, locale) => {
68
- return format(date, 'E, LLL dd', {
69
+ export const getDateSeparatorFormat = (date, locale) => {
70
+ if (isThisYear(date)) return format(date, 'MMM dd, yyyy', {
71
+ locale
72
+ });
73
+ return format(date, 'E, MMM dd', {
69
74
  locale
70
75
  });
71
76
  };
@@ -77,7 +82,7 @@ export const dateSeparator = (date, locale) => {
77
82
  * @returns {string}
78
83
  * */
79
84
 
80
- export const messageTime = (date, locale) => {
85
+ export const getMessageTimeFormat = (date, locale) => {
81
86
  return format(date, 'p', {
82
87
  locale
83
88
  });
@@ -1 +1 @@
1
- {"version":3,"names":["format","defaultOpts","mode","maxLen","separator","truncate","str","opts","options","length","slice","lead","Math","ceil","trail","floor","Error","truncatedBadgeCount","count","MAX","dateSeparator","date","locale","messageTime"],"sources":["common.ts"],"sourcesContent":["import type { Locale } from 'date-fns';\nimport format from 'date-fns/format';\n\ntype TruncateMode = 'head' | 'mid' | 'tail';\ntype TruncateOption = { mode: TruncateMode; maxLen: number; separator: string };\nconst defaultOpts: TruncateOption = { mode: 'mid', maxLen: 40, separator: '...' };\n\n/**\n * String truncate util\n * @param {string} str\n * @param {Object} opts Options for truncate\n * @param {'head' | 'mid' | 'tail'} opts.mode default \"mid\"\n * @param {number} opts.maxLen default 40\n * @param {string} opts.separator default \"...\"\n * @returns {string}\n * */\nexport const truncate = (str: string, opts: Partial<TruncateOption> = defaultOpts): string => {\n const options = { ...defaultOpts, ...opts };\n const { maxLen, mode, separator } = options;\n\n if (str.length <= maxLen) return str;\n\n if (mode === 'head') {\n return separator + str.slice(-maxLen);\n }\n\n if (mode === 'mid') {\n const lead = Math.ceil(maxLen / 2);\n const trail = Math.floor(maxLen / 2);\n return str.slice(0, lead) + separator + str.slice(-trail);\n }\n\n if (mode === 'tail') {\n return str.slice(0, maxLen) + separator;\n }\n\n throw new Error('Invalid truncate mode: ' + mode);\n};\n\n/**\n * Badge count truncate util\n * If count exceed the limit, it comes in the form of \"MAX+\"\n *\n * @param {number} count\n * @param {number} MAX default 99\n * @returns {string}\n * */\nexport const truncatedBadgeCount = (count: number, MAX = 99) => {\n if (count >= MAX) return `${MAX}+`;\n return `${count}`;\n};\n\n/**\n * Messages date separator format\n *\n * @param {Date} date\n * @param {Locale} [locale]\n * @returns {string}\n * */\nexport const dateSeparator = (date: Date, locale?: Locale): string => {\n return format(date, 'E, LLL dd', { locale });\n};\n\n/**\n * Message time format\n *\n * @param {Date} date\n * @param {Locale} [locale]\n * @returns {string}\n * */\nexport const messageTime = (date: Date, locale?: Locale): string => {\n return format(date, 'p', { locale });\n};\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Aa,uEAAP,EAAO;EAC9D,IAAID,KAAK,IAAIC,GAAb,EAAkB,OAAQ,GAAEA,GAAI,GAAd;EAClB,OAAQ,GAAED,KAAM,EAAhB;AACD,CAHM;AAKP;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAME,aAAa,GAAG,CAACC,IAAD,EAAaC,MAAb,KAAyC;EACpE,OAAOtB,MAAM,CAACqB,IAAD,EAAO,WAAP,EAAoB;IAAEC;EAAF,CAApB,CAAb;AACD,CAFM;AAIP;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,WAAW,GAAG,CAACF,IAAD,EAAaC,MAAb,KAAyC;EAClE,OAAOtB,MAAM,CAACqB,IAAD,EAAO,GAAP,EAAY;IAAEC;EAAF,CAAZ,CAAb;AACD,CAFM"}
1
+ {"version":3,"names":["format","isThisYear","defaultOpts","mode","maxLen","separator","truncate","str","opts","options","length","slice","lead","Math","ceil","trail","floor","Error","truncatedCount","count","MAX","MAX_SUFFIX","getDateSeparatorFormat","date","locale","getMessageTimeFormat"],"sources":["common.ts"],"sourcesContent":["import type { Locale } from 'date-fns';\nimport { format, isThisYear } from 'date-fns';\n\ntype TruncateMode = 'head' | 'mid' | 'tail';\ntype TruncateOption = { mode: TruncateMode; maxLen: number; separator: string };\nconst defaultOpts: TruncateOption = { mode: 'mid', maxLen: 40, separator: '...' };\n\n/**\n * String truncate util\n * @param {string} str\n * @param {Object} opts Options for truncate\n * @param {'head' | 'mid' | 'tail'} opts.mode default \"mid\"\n * @param {number} opts.maxLen default 40\n * @param {string} opts.separator default \"...\"\n * @returns {string}\n * */\nexport const truncate = (str: string, opts: Partial<TruncateOption> = defaultOpts): string => {\n const options = { ...defaultOpts, ...opts };\n const { maxLen, mode, separator } = options;\n\n if (str.length <= maxLen) return str;\n\n if (mode === 'head') {\n return separator + str.slice(-maxLen);\n }\n\n if (mode === 'mid') {\n const lead = Math.ceil(maxLen / 2);\n const trail = Math.floor(maxLen / 2);\n return str.slice(0, lead) + separator + str.slice(-trail);\n }\n\n if (mode === 'tail') {\n return str.slice(0, maxLen) + separator;\n }\n\n throw new Error('Invalid truncate mode: ' + mode);\n};\n\n/**\n * Count truncate util\n * If count exceed the limit, it comes in the form of \"MAX+\"\n *\n * @param {number} count\n * @param {number} MAX default 99\n * @param {string} MAX_SUFFIX default +\n * @returns {string}\n * */\nexport const truncatedCount = (count: number, MAX = 99, MAX_SUFFIX = '+') => {\n if (count >= MAX) return `${MAX}${MAX_SUFFIX}`;\n return `${count}`;\n};\n\n/**\n * Messages date separator format\n *\n * @param {Date} date\n * @param {Locale} [locale]\n * @returns {string}\n * */\nexport const getDateSeparatorFormat = (date: Date, locale?: Locale): string => {\n if (isThisYear(date)) return format(date, 'MMM dd, yyyy', { locale });\n return format(date, 'E, MMM dd', { locale });\n};\n\n/**\n * Message time format\n *\n * @param {Date} date\n * @param {Locale} [locale]\n * @returns {string}\n * */\nexport const getMessageTimeFormat = (date: Date, locale?: Locale): string => {\n return format(date, 'p', { locale });\n};\n"],"mappings":"AACA,SAASA,MAAT,EAAiBC,UAAjB,QAAmC,UAAnC;AAIA,MAAMC,WAA2B,GAAG;EAAEC,IAAI,EAAE,KAAR;EAAeC,MAAM,EAAE,EAAvB;EAA2BC,SAAS,EAAE;AAAtC,CAApC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,QAAQ,GAAG,UAACC,GAAD,EAAsE;EAAA,IAAxDC,IAAwD,uEAAxBN,WAAwB;EAC5F,MAAMO,OAAO,GAAG,EAAE,GAAGP,WAAL;IAAkB,GAAGM;EAArB,CAAhB;EACA,MAAM;IAAEJ,MAAF;IAAUD,IAAV;IAAgBE;EAAhB,IAA8BI,OAApC;EAEA,IAAIF,GAAG,CAACG,MAAJ,IAAcN,MAAlB,EAA0B,OAAOG,GAAP;;EAE1B,IAAIJ,IAAI,KAAK,MAAb,EAAqB;IACnB,OAAOE,SAAS,GAAGE,GAAG,CAACI,KAA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MAAb,KAAyC;EAC3E,OAAOxB,MAAM,CAACuB,IAAD,EAAO,GAAP,EAAY;IAAEC;EAAF,CAAZ,CAAb;AACD,CAFM"}
@@ -1,6 +1,4 @@
1
- import format from 'date-fns/format';
2
- import isToday from 'date-fns/isToday';
3
- import isYesterday from 'date-fns/isYesterday';
1
+ import { format, isThisYear, isToday, isYesterday } from 'date-fns';
4
2
  import { truncate } from './common';
5
3
  export const getGroupChannelTitle = function (currentUserId, channel) {
6
4
  let EMPTY_USERNAME = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '(No name)';
@@ -28,7 +26,10 @@ export const getGroupChannelPreviewTime = (channel, locale) => {
28
26
  locale
29
27
  });
30
28
  if (isYesterday(timestamp)) return 'Yesterday';
31
- return format(timestamp, 'MMM dd', {
29
+ if (isThisYear(timestamp)) return format(timestamp, 'MMM dd', {
30
+ locale
31
+ });
32
+ return format(timestamp, 'yyyy/MM/dd', {
32
33
  locale
33
34
  });
34
35
  };
@@ -1 +1 @@
1
- {"version":3,"names":["format","isToday","isYesterday","truncate","getGroupChannelTitle","currentUserId","channel","EMPTY_USERNAME","NO_MEMBERS","DEFAULT_CHANNEL_NAME","name","memberCount","members","filter","userId","map","nickname","join","getGroupChannelPreviewTime","locale","timestamp","lastMessage","createdAt","joinedAt","getGroupChannelLastMessage","EMPTY_MESSAGE","MAX_LEN","message","isFileMessage","extIdx","lastIndexOf","file","slice","ext","maxLen","isUserMessage","isAdminMessage"],"sources":["groupChannel.ts"],"sourcesContent":["import type { Locale } from 'date-fns';\nimport format from 'date-fns/format';\nimport isToday from 'date-fns/isToday';\nimport isYesterday from 'date-fns/isYesterday';\n\nimport type { SendbirdGroupChannel } from '../types';\nimport { truncate } from './common';\n\nexport const getGroupChannelTitle = (\n currentUserId: string,\n channel: SendbirdGroupChannel,\n EMPTY_USERNAME = '(No name)',\n NO_MEMBERS = '(No members)',\n DEFAULT_CHANNEL_NAME = 'Group Channel',\n) => {\n if (channel.name !== DEFAULT_CHANNEL_NAME && channel.name !== '') return channel.name;\n if (channel.memberCount === 1) return NO_MEMBERS;\n return channel.members\n .filter(({ userId }) => userId !== currentUserId)\n .map(({ nickname }) => nickname || EMPTY_USERNAME)\n .join(', ');\n};\n\nexport const getGroupChannelPreviewTime = (channel: SendbirdGroupChannel, locale?: Locale) => {\n const timestamp = channel.lastMessage?.createdAt || channel.joinedAt * 1000 || channel.createdAt;\n if (isToday(timestamp)) return format(timestamp, 'p', { locale });\n if (isYesterday(timestamp)) return 'Yesterday';\n return format(timestamp, 'MMM dd', { locale });\n};\n\nexport const getGroupChannelLastMessage = (channel: SendbirdGroupChannel, EMPTY_MESSAGE = '', MAX_LEN = 15) => {\n const message = channel.lastMessage;\n if (!message) return EMPTY_MESSAGE;\n\n if (message.isFileMessage()) {\n const extIdx = message.name.lastIndexOf('.');\n if (extIdx > -1) {\n const file = message.name.slice(0, extIdx);\n const ext = message.name.slice(extIdx);\n return truncate(file, { maxLen: MAX_LEN }) + ext;\n }\n\n return truncate(message.name, { maxLen: MAX_LEN });\n }\n\n if (message.isUserMessage()) {\n return message.message ?? EMPTY_MESSAGE;\n }\n\n if (message.isAdminMessage()) {\n return message.message ?? EMPTY_MESSAGE;\n }\n\n return EMPTY_MESSAGE;\n};\n"],"mappings":"AACA,OAAOA,MAAP,MAAmB,iBAAnB;AACA,OAAOC,OAAP,MAAoB,kBAApB;AACA,OAAOC,WAAP,MAAwB,sBAAxB;AAGA,SAASC,QAAT,QAAyB,UAAzB;AAEA,OAAO,MAAMC,oBAAoB,GAAG,UAClCC,aADkC,EAElCC,OAFkC,EAM/B;EAAA,IAHHC,cAGG,uEAHc,WAGd;EAAA,IAFHC,UAEG,uEAFU,cAEV;EAAA,IADHC,oBACG,uEADoB,eACpB;EACH,IAAIH,OAAO,CAACI,IAAR,KAAiBD,oBAAjB,IAAyCH,OAAO,CAACI,IAAR,KAAiB,EAA9D,EAAkE,OAAOJ,OAAO,CAACI,IAAf;EAClE,IAAIJ,OAAO,CAACK,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AAb,CAAmB,CAAnB,EAAsBH,MAAtB,CAAb;MACA,MAAMI,GAAG,GAAGN,OAAO,CAACjB,IAAR,CAAasB,KAAb,CAAmBH,MAAnB,CAAZ;MACA,OAAO1B,QAAQ,CAAC4B,IAAD,EAAO;QAAEG,MAAM,EAAER;MAAV,CAAP,CAAR,GAAsCO,GAA7C;IACD;;IAED,OAAO9B,QAAQ,CAACwB,OAAO,CAACjB,IAAT,EAAe;MAAEwB,MAAM,EAAER;IAAV,CAAf,CAAf;EACD;;EAED,IAAIC,OAAO,CAACQ,aAAR,EAAJ,EAA6B;IAC3B,OAAOR,OAAO,CAACA,OAAR,IAAmBF,aAA1B;EACD;;EAED,IAAIE,OAAO,CAACS,cAAR,EAAJ,EAA8B;IAC5B,OAAOT,OAAO,CAACA,OAAR,IAAmBF,aAA1B;EACD;;EAED,OAAOA,aAAP;AACD,CAxBM"}
1
+ {"version":3,"names":["format","isThisYear","isToday","isYesterday","truncate","getGroupChannelTitle","currentUserId","channel","EMPTY_USERNAME","NO_MEMBERS","DEFAULT_CHANNEL_NAME","name","memberCount","members","filter","userId","map","nickname","join","getGroupChannelPreviewTime","locale","timestamp","lastMessage","createdAt","joinedAt","getGroupChannelLastMessage","EMPTY_MESSAGE","MAX_LEN","message","isFileMessage","extIdx","lastIndexOf","file","slice","ext","maxLen","isUserMessage","isAdminMessage"],"sources":["groupChannel.ts"],"sourcesContent":["import type { Locale } from 'date-fns';\nimport { format, isThisYear, isToday, isYesterday } from 'date-fns';\n\nimport type { SendbirdGroupChannel } from '../types';\nimport { truncate } from './common';\n\nexport const getGroupChannelTitle = (\n currentUserId: string,\n channel: SendbirdGroupChannel,\n EMPTY_USERNAME = '(No name)',\n NO_MEMBERS = '(No members)',\n DEFAULT_CHANNEL_NAME = 'Group Channel',\n) => {\n if (channel.name !== DEFAULT_CHANNEL_NAME && channel.name !== '') return channel.name;\n if (channel.memberCount === 1) return NO_MEMBERS;\n return channel.members\n .filter(({ userId }) => userId !== currentUserId)\n .map(({ nickname }) => nickname || EMPTY_USERNAME)\n .join(', ');\n};\n\nexport const getGroupChannelPreviewTime = (channel: SendbirdGroupChannel, locale?: Locale) => {\n const timestamp = channel.lastMessage?.createdAt || channel.joinedAt * 1000 || channel.createdAt;\n\n if (isToday(timestamp)) return format(timestamp, 'p', { locale });\n if (isYesterday(timestamp)) return 'Yesterday';\n if (isThisYear(timestamp)) return format(timestamp, 'MMM dd', { locale });\n\n return format(timestamp, 'yyyy/MM/dd', { locale });\n};\n\nexport const getGroupChannelLastMessage = (channel: SendbirdGroupChannel, EMPTY_MESSAGE = '', MAX_LEN = 15) => {\n const message = channel.lastMessage;\n if (!message) return EMPTY_MESSAGE;\n\n if (message.isFileMessage()) {\n const extIdx = message.name.lastIndexOf('.');\n if (extIdx > -1) {\n const file = message.name.slice(0, extIdx);\n const ext = message.name.slice(extIdx);\n return truncate(file, { maxLen: MAX_LEN }) + ext;\n }\n\n return truncate(message.name, { maxLen: MAX_LEN });\n }\n\n if (message.isUserMessage()) {\n return message.message ?? EMPTY_MESSAGE;\n }\n\n if (message.isAdminMessage()) {\n return message.message ?? EMPTY_MESSAGE;\n }\n\n return EMPTY_MESSAGE;\n};\n"],"mappings":"AACA,SAASA,MAAT,EAAiBC,UAAjB,EAA6BC,OAA7B,EAAsCC,WAAtC,QAAyD,UAAzD;AAGA,SAASC,QAAT,QAAyB,UAAzB;AAEA,OAAO,MAAMC,oBAAoB,GAAG,UAClCC,aADkC,EAElCC,OAFkC,EAM/B;EAAA,IAHHC,cAGG,uEAHc,WAGd;EAAA,IAFHC,UAEG,uEAFU,cAEV;EAAA,IADHC,oBACG,uEADoB,eACpB;EACH,IAAIH,OAAO,CAACI,IAAR,KAAiBD,oBAAjB,IAAyCH,OAAO,CAACI,IAAR,KAAiB,EAA9D,EAAkE,OAAOJ,OAAO,CAACI,IAAf;EAClE,IAAIJ,OAAO,CAACK,WAAR,KAAwB,CAA5B,EAA+B,OAAOH,UAAP;EAC/B,OAAOF,OAAO,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,EAAiB;MACf,MAAME,IAAI,GAAGJ,OAAO,CAACjB,IAAR,CAAasB,KAAb,CAAmB,CAAnB,EAAsBH,MAAtB,CAAb;MACA,MAAMI,GAAG,GAAGN,OAAO,CAACjB,IAAR,CAAasB,KAAb,CAAmBH,MAAnB,CAAZ;MACA,OAAO1B,QAAQ,CAAC4B,IAAD,EAAO;QAAEG,MAAM,EAAER;MAAV,CAAP,CAAR,GAAsCO,GAA7C;IACD;;IAED,OAAO9B,QAAQ,CAACwB,OAAO,CAACjB,IAAT,EAAe;MAAEwB,MAAM,EAAER;IAAV,CAAf,CAAf;EACD;;EAED,IAAIC,OAAO,CAACQ,aAAR,EAAJ,EAA6B;IAC3B,OAAOR,OAAO,CAACA,OAAR,IAAmBF,aAA1B;EACD;;EAED,IAAIE,OAAO,CAACS,cAAR,EAAJ,EAA8B;IAC5B,OAAOT,OAAO,CAACA,OAAR,IAAmBF,aAA1B;EACD;;EAED,OAAOA,aAAP;AACD,CAxBM"}
@@ -1,11 +1,12 @@
1
1
  import type { DependencyList } from 'react';
2
- declare type Destructor = () => void;
3
- declare type AsyncEffectCallback = () => void | Destructor | Promise<void> | Promise<Destructor>;
2
+ type Destructor = () => void;
3
+ type AsyncEffectCallback = () => void | Destructor | Promise<void> | Promise<Destructor>;
4
4
  export declare const useUniqId: (key: string) => number;
5
5
  export declare const useForceUpdate: () => () => void;
6
6
  export declare const useAsyncEffect: (asyncEffect: AsyncEffectCallback, deps?: DependencyList) => void;
7
7
  export declare const useAsyncLayoutEffect: (asyncEffect: AsyncEffectCallback, deps?: DependencyList) => void;
8
8
  export declare const useIIFE: <T>(callback: () => T) => T;
9
9
  export declare const useIsMountedRef: () => import("react").MutableRefObject<boolean>;
10
+ export declare const useIsFirstMount: () => boolean;
10
11
  export declare const useFreshCallback: <T extends (...args: any[]) => any>(callback: T) => T;
11
12
  export {};
@@ -2,14 +2,16 @@ export { Logger } from './shared/logger';
2
2
  export { default as arrayToMap, arrayToMapWithGetter } from './shared/arrayToMap';
3
3
  export { createPubSub } from './shared/pubsub';
4
4
  export { default as conditionChaining } from './shared/conditionChaining';
5
- export { urlRegexStrict, urlRegexRough, newLineRegex, audioExtRegex, videoExtRegex, imageExtRegex, getFileType, getFileExtension, replaceUrlAsComponents, normalizeFileName, emailRegex, phoneRegex, } from './shared/regex';
5
+ export { urlRegexStrict, urlRegexRough, newLineRegex, audioExtRegex, videoExtRegex, imageExtRegex, getFileType, getFileExtension, replaceUrlAsComponents, normalizeFileName, emailRegex, phoneRegex, replaceWithRegex, createMentionTemplateRegex, } from './shared/regex';
6
6
  export { BufferedRequest } from './shared/bufferedRequest';
7
+ export { default as replace } from './shared/replace';
7
8
  export * from './hooks';
8
9
  export * from './ui-format/groupChannel';
9
10
  export * from './ui-format/common';
10
11
  export * from './sendbird/channel';
11
12
  export * from './sendbird/message';
12
13
  export * from './sendbird/attrs';
14
+ export * from './sendbird/user';
13
15
  export declare const NOOP: () => void;
14
16
  export declare const ASYNC_NOOP: () => Promise<undefined>;
15
17
  export declare const PASS: <T>(val: T) => T;
@@ -21,4 +23,4 @@ export declare const SBErrorCode: {
21
23
  export declare const SBErrorMessage: {
22
24
  ACL: string;
23
25
  };
24
- export type { FilterByValueType, UnionToIntersection, OmittedValues, PartialDeep, Optional, ContextValue, SendbirdMessage, SendbirdChatSDK, SendbirdChannel, SendbirdBaseChannel, SendbirdGroupChannel, SendbirdOpenChannel, SendbirdUser, SendbirdMember, SendbirdBaseMessage, SendbirdUserMessage, SendbirdFileMessage, SendbirdAdminMessage, SendbirdGroupChannelCreateParams, SendbirdFileMessageCreateParams, SendbirdUserMessageCreateParams, SendbirdError, SendbirdMessageCollection, SendbirdGroupChannelCollection, NotificationFiles, NotificationMentionedUsers, NotificationTranslations, PartialNullable, SendbirdDataPayload, SendbirdPreviousMessageListQuery, SendbirdSendableMessage, SendbirdGroupChannelListQuery, SendbirdGroupChannelUpdateParams, SendbirdUserMessageUpdateParams, SendbirdFileMessageUpdateParams, SendbirdUserUpdateParams, } from './types';
26
+ export type { UserStruct, FilterByValueType, UnionToIntersection, OmittedValues, PartialDeep, Optional, ContextValue, SendbirdMessage, SendbirdChatSDK, SendbirdChannel, SendbirdBaseChannel, SendbirdGroupChannel, SendbirdOpenChannel, SendbirdUser, SendbirdMember, SendbirdBaseMessage, SendbirdUserMessage, SendbirdFileMessage, SendbirdAdminMessage, SendbirdGroupChannelCreateParams, SendbirdFileMessageCreateParams, SendbirdUserMessageCreateParams, SendbirdError, SendbirdMessageCollection, SendbirdGroupChannelCollection, NotificationFiles, NotificationMentionedUsers, NotificationTranslations, PartialNullable, SendbirdDataPayload, SendbirdPreviousMessageListQuery, SendbirdSendableMessage, SendbirdGroupChannelListQuery, SendbirdGroupChannelUpdateParams, SendbirdUserMessageUpdateParams, SendbirdFileMessageUpdateParams, SendbirdUserUpdateParams, SendbirdRestrictedUser, SendbirdReaction, SendbirdEmojiContainer, SendbirdEmoji, SendbirdEmojiCategory, } from './types';
@@ -6,10 +6,15 @@ import type { SendbirdBaseChannel, SendbirdChannel, SendbirdGroupChannel, Sendbi
6
6
  * @returns {boolean}
7
7
  * */
8
8
  export declare function isDifferentChannel<T extends SendbirdBaseChannel>(a?: T, b?: T): boolean;
9
- export declare const isGroupChannelChatUnavailable: (channel: SendbirdGroupChannel) => boolean;
9
+ export declare const getGroupChannelChatAvailableState: (channel: SendbirdGroupChannel) => {
10
+ disabled: boolean;
11
+ frozen: boolean;
12
+ muted: boolean;
13
+ };
10
14
  export declare const confirmAndMarkAsRead: (channels: SendbirdBaseChannel[]) => Promise<void>;
11
15
  export declare const confirmAndMarkAsDelivered: (channels: SendbirdBaseChannel[]) => Promise<void>;
12
16
  export declare function isDefaultCoverImage(coverUrl: string): boolean;
13
17
  export declare function getMembersExcludeMe(channel: SendbirdGroupChannel, currentUserId?: string): import("@sendbird/chat/groupChannel").Member[];
14
18
  export declare function getGroupChannels(channels: SendbirdChannel[]): SendbirdGroupChannel[];
15
19
  export declare function getOpenChannels(channels: SendbirdChannel[]): SendbirdOpenChannel[];
20
+ export declare function getChannelUniqId(channel: SendbirdChannel): string;
@@ -1,4 +1,4 @@
1
- import type { SendbirdBaseMessage, SendbirdDataPayload, SendbirdFileMessage, SendbirdMessage, SendbirdSendableMessage } from '../types';
1
+ import type { SendbirdBaseChannel, SendbirdBaseMessage, SendbirdDataPayload, SendbirdFileMessage, SendbirdMessage, SendbirdReaction, SendbirdSendableMessage } from '../types';
2
2
  export declare function isNewMessage(msg: SendbirdMessage, currentUserId?: string): boolean;
3
3
  export declare function isSendableMessage(msg?: SendbirdMessage | null): msg is SendbirdSendableMessage;
4
4
  export declare function isMyMessage(msg?: SendbirdMessage | null, currentUserId?: string): boolean;
@@ -11,11 +11,13 @@ export declare function calcMessageGrouping(groupEnabled: boolean, curr: Sendbir
11
11
  };
12
12
  export declare function getMessageUniqId(msg: SendbirdBaseMessage): string;
13
13
  export declare function getAvailableUriFromFileMessage(message: SendbirdFileMessage): string;
14
- declare type RawSendbirdDataPayload = {
14
+ type RawSendbirdDataPayload = {
15
15
  sendbird: string | object;
16
16
  };
17
17
  export declare function isSendbirdNotification(dataPayload?: {
18
18
  [key: string]: string | object;
19
19
  }): dataPayload is RawSendbirdDataPayload;
20
20
  export declare function parseSendbirdNotification(dataPayload: RawSendbirdDataPayload): SendbirdDataPayload;
21
+ export declare function shouldRenderReaction(channel: SendbirdBaseChannel, reactionEnabled: boolean): boolean;
22
+ export declare function getReactionCount(reaction: SendbirdReaction): number;
21
23
  export {};
@@ -0,0 +1,7 @@
1
+ import type { Role } from '@sendbird/chat';
2
+ import type { UserStruct } from '../types';
3
+ export declare function ifOperator<T>(role: Role, then: T): T | undefined;
4
+ export declare function ifOperator<T, V>(role: Role, then: T, or: V): T | V;
5
+ export declare function ifMuted<T>(muted: boolean, then: T): T | undefined;
6
+ export declare function ifMuted<T, V>(muted: boolean, then: T, or: V): T | V;
7
+ export declare function getUserUniqId<T extends UserStruct>(user: T): string;
@@ -1,25 +1,27 @@
1
- declare type Func = (...args: unknown[]) => Promise<unknown>;
1
+ type Func = (...args: unknown[]) => Promise<unknown>;
2
2
  export declare class BufferedRequest {
3
3
  static markAsRead: {
4
- push(func: Func): void;
4
+ push(func: Func, lane?: string): void;
5
5
  shift(): void;
6
6
  handleIdle(): void;
7
7
  handleProcessing(): void;
8
8
  invoke(): Promise<void>;
9
9
  };
10
10
  static markAsDelivered: {
11
- push(func: Func): void;
11
+ push(func: Func, lane?: string): void;
12
12
  shift(): void;
13
13
  handleIdle(): void;
14
14
  handleProcessing(): void;
15
15
  invoke(): Promise<void>;
16
16
  };
17
+ static updateMarkAsReadOptions(reqPerTimeout: number, timeoutMills: number): void;
18
+ static updateMarkAsDeliveredOptions(reqPerTimeout: number, timeoutMills: number): void;
17
19
  static get reqPerTimeout(): number;
18
20
  static set reqPerTimeout(value: number);
19
21
  static get timeoutMills(): number;
20
22
  static set timeoutMills(value: number);
21
23
  static create(reqPerTimeout?: number, timeoutMills?: number): {
22
- push(func: Func): void;
24
+ push(func: Func, lane?: string): void;
23
25
  shift(): void;
24
26
  handleIdle(): void;
25
27
  handleProcessing(): void;
@@ -6,7 +6,7 @@ declare const LogLevelEnum: {
6
6
  info: number;
7
7
  debug: number;
8
8
  };
9
- declare type LogLevel = keyof typeof LogLevelEnum;
9
+ type LogLevel = keyof typeof LogLevelEnum;
10
10
  export declare const Logger: {
11
11
  LogLevelEnum: {
12
12
  none: number;
@@ -1,7 +1,7 @@
1
- export declare type SubscribeListener = ((...args: unknown[]) => void) & {
1
+ export type SubscribeListener = ((...args: unknown[]) => void) & {
2
2
  onError?: (error: unknown) => void;
3
3
  };
4
- export declare type SubscribeListenerPool = Record<symbol, SubscribeListener>;
4
+ export type SubscribeListenerPool = Record<symbol, SubscribeListener>;
5
5
  export declare const createPubSub: (label?: string) => {
6
6
  subscribe: (event: string, listener: SubscribeListener, subscriber?: string) => () => void;
7
7
  publish: (event: string, ...args: unknown[]) => void;
@@ -3,6 +3,14 @@ export declare const urlRegexRough: RegExp;
3
3
  export declare const phoneRegex: RegExp;
4
4
  export declare const emailRegex: RegExp;
5
5
  export declare const newLineRegex: RegExp;
6
+ export declare const createMentionTemplateRegex: (trigger: string) => RegExp;
7
+ export declare const replaceWithRegex: <T>(text: string, regex: RegExp, replacer: (params: {
8
+ match: string;
9
+ groups: string[];
10
+ matchIndex: number | undefined;
11
+ index: number;
12
+ keyPrefix: string;
13
+ }) => T, keyPrefix: string) => (string | T)[];
6
14
  export declare const replaceUrlAsComponents: <T>(originText: string, replacer: (url: string) => T, strict?: boolean) => (string | T)[];
7
15
  export declare const imageExtRegex: RegExp;
8
16
  export declare const audioExtRegex: RegExp;
@@ -0,0 +1,2 @@
1
+ declare const replace: (original: string, start: number, end: number, str: string) => string;
2
+ export default replace;
@@ -1,49 +1,56 @@
1
1
  import type React from 'react';
2
2
  import type SendbirdChat from '@sendbird/chat';
3
- import type { BaseChannel, SendbirdError as SBError, User, UserUpdateParams } from '@sendbird/chat';
3
+ import type { BaseChannel, Emoji, EmojiCategory, EmojiContainer, RestrictedUser, SendbirdError as SBError, User, UserUpdateParams } from '@sendbird/chat';
4
4
  import type { GroupChannel, GroupChannelCollection, GroupChannelCreateParams, GroupChannelListQuery, GroupChannelModule, GroupChannelUpdateParams, Member, MessageCollection } from '@sendbird/chat/groupChannel';
5
5
  import type { ModuleNamespaces, SendableMessage } from '@sendbird/chat/lib/__definition';
6
- import type { AdminMessage, BaseMessage, FileMessage, FileMessageCreateParams, FileMessageUpdateParams, PreviousMessageListQuery, UserMessage, UserMessageCreateParams, UserMessageUpdateParams } from '@sendbird/chat/message';
6
+ import type { AdminMessage, BaseMessage, FileMessage, FileMessageCreateParams, FileMessageUpdateParams, PreviousMessageListQuery, Reaction, UserMessage, UserMessageCreateParams, UserMessageUpdateParams } from '@sendbird/chat/message';
7
7
  import type { OpenChannel, OpenChannelModule } from '@sendbird/chat/openChannel';
8
- import './';
9
- export declare type FilterByValueType<T extends object, Type> = {
8
+ export type FilterByValueType<T extends object, Type> = {
10
9
  [K in keyof T as T[K] extends Type ? K : never]: T[K];
11
10
  };
12
- export declare type UnionToIntersection<U> = (U extends unknown ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
13
- export declare type OmittedValues<T, K extends keyof T> = Omit<T, K>[keyof Omit<T, K>];
14
- export declare type PartialDeep<T> = T extends object ? T extends Function ? T : {
11
+ export type UnionToIntersection<U> = (U extends unknown ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
12
+ export type OmittedValues<T, K extends keyof T> = Omit<T, K>[keyof Omit<T, K>];
13
+ export type PartialDeep<T> = T extends object ? T extends Function ? T : {
15
14
  [P in keyof T]?: PartialDeep<T[P]>;
16
15
  } : T;
17
- export declare type PartialNullable<T> = {
16
+ export type PartialNullable<T> = {
18
17
  [P in keyof T]?: T[P] | null;
19
18
  };
20
- export declare type Optional<T> = T | undefined;
21
- export declare type ContextValue<T extends React.Context<any>> = T extends React.Context<infer V> ? V : never;
22
- export declare type SendbirdChatSDK = SendbirdChat & ModuleNamespaces<[GroupChannelModule, OpenChannelModule]>;
23
- export declare type SendbirdMessage = BaseMessage | FileMessage | UserMessage | AdminMessage | SendableMessage;
24
- export declare type SendbirdChannel = BaseChannel | GroupChannel | OpenChannel;
25
- export declare type SendbirdUserMessage = UserMessage;
26
- export declare type SendbirdFileMessage = FileMessage;
27
- export declare type SendbirdAdminMessage = AdminMessage;
28
- export declare type SendbirdBaseMessage = BaseMessage;
29
- export declare type SendbirdSendableMessage = SendableMessage;
30
- export declare type SendbirdFileMessageCreateParams = FileMessageCreateParams;
31
- export declare type SendbirdFileMessageUpdateParams = FileMessageUpdateParams;
32
- export declare type SendbirdUserMessageCreateParams = UserMessageCreateParams;
33
- export declare type SendbirdUserMessageUpdateParams = UserMessageUpdateParams;
34
- export declare type SendbirdGroupChannelCreateParams = GroupChannelCreateParams;
35
- export declare type SendbirdGroupChannelUpdateParams = GroupChannelUpdateParams;
36
- export declare type SendbirdUserUpdateParams = UserUpdateParams;
37
- export declare type SendbirdUser = User;
38
- export declare type SendbirdMember = Member;
39
- export declare type SendbirdGroupChannel = GroupChannel;
40
- export declare type SendbirdBaseChannel = BaseChannel;
41
- export declare type SendbirdOpenChannel = OpenChannel;
42
- export declare type SendbirdGroupChannelCollection = GroupChannelCollection;
43
- export declare type SendbirdGroupChannelListQuery = GroupChannelListQuery;
44
- export declare type SendbirdMessageCollection = MessageCollection;
45
- export declare type SendbirdPreviousMessageListQuery = PreviousMessageListQuery;
46
- export declare type SendbirdError = SBError;
19
+ export type Optional<T> = T | undefined;
20
+ export type ContextValue<T extends React.Context<any>> = T extends React.Context<infer V> ? V : never;
21
+ export interface UserStruct {
22
+ userId: string;
23
+ }
24
+ export type SendbirdChatSDK = SendbirdChat & ModuleNamespaces<[GroupChannelModule, OpenChannelModule]>;
25
+ export type SendbirdMessage = BaseMessage | FileMessage | UserMessage | AdminMessage | SendableMessage;
26
+ export type SendbirdChannel = BaseChannel | GroupChannel | OpenChannel;
27
+ export type SendbirdUserMessage = UserMessage;
28
+ export type SendbirdFileMessage = FileMessage;
29
+ export type SendbirdAdminMessage = AdminMessage;
30
+ export type SendbirdBaseMessage = BaseMessage;
31
+ export type SendbirdSendableMessage = SendableMessage;
32
+ export type SendbirdFileMessageCreateParams = FileMessageCreateParams;
33
+ export type SendbirdFileMessageUpdateParams = FileMessageUpdateParams;
34
+ export type SendbirdUserMessageCreateParams = UserMessageCreateParams;
35
+ export type SendbirdUserMessageUpdateParams = UserMessageUpdateParams;
36
+ export type SendbirdGroupChannelCreateParams = GroupChannelCreateParams;
37
+ export type SendbirdGroupChannelUpdateParams = GroupChannelUpdateParams;
38
+ export type SendbirdUserUpdateParams = UserUpdateParams;
39
+ export type SendbirdUser = User;
40
+ export type SendbirdRestrictedUser = RestrictedUser;
41
+ export type SendbirdMember = Member;
42
+ export type SendbirdGroupChannel = GroupChannel;
43
+ export type SendbirdBaseChannel = BaseChannel;
44
+ export type SendbirdOpenChannel = OpenChannel;
45
+ export type SendbirdReaction = Reaction;
46
+ export type SendbirdEmoji = Emoji;
47
+ export type SendbirdEmojiCategory = EmojiCategory;
48
+ export type SendbirdEmojiContainer = EmojiContainer;
49
+ export type SendbirdGroupChannelCollection = GroupChannelCollection;
50
+ export type SendbirdGroupChannelListQuery = GroupChannelListQuery;
51
+ export type SendbirdMessageCollection = MessageCollection;
52
+ export type SendbirdPreviousMessageListQuery = PreviousMessageListQuery;
53
+ export type SendbirdError = SBError;
47
54
  export interface SendbirdDataPayload {
48
55
  app_id: string;
49
56
  audience_type: string;
@@ -1,6 +1,6 @@
1
1
  import type { Locale } from 'date-fns';
2
- declare type TruncateMode = 'head' | 'mid' | 'tail';
3
- declare type TruncateOption = {
2
+ type TruncateMode = 'head' | 'mid' | 'tail';
3
+ type TruncateOption = {
4
4
  mode: TruncateMode;
5
5
  maxLen: number;
6
6
  separator: string;
@@ -16,14 +16,15 @@ declare type TruncateOption = {
16
16
  * */
17
17
  export declare const truncate: (str: string, opts?: Partial<TruncateOption>) => string;
18
18
  /**
19
- * Badge count truncate util
19
+ * Count truncate util
20
20
  * If count exceed the limit, it comes in the form of "MAX+"
21
21
  *
22
22
  * @param {number} count
23
23
  * @param {number} MAX default 99
24
+ * @param {string} MAX_SUFFIX default +
24
25
  * @returns {string}
25
26
  * */
26
- export declare const truncatedBadgeCount: (count: number, MAX?: number) => string;
27
+ export declare const truncatedCount: (count: number, MAX?: number, MAX_SUFFIX?: string) => string;
27
28
  /**
28
29
  * Messages date separator format
29
30
  *
@@ -31,7 +32,7 @@ export declare const truncatedBadgeCount: (count: number, MAX?: number) => strin
31
32
  * @param {Locale} [locale]
32
33
  * @returns {string}
33
34
  * */
34
- export declare const dateSeparator: (date: Date, locale?: Locale) => string;
35
+ export declare const getDateSeparatorFormat: (date: Date, locale?: Locale) => string;
35
36
  /**
36
37
  * Message time format
37
38
  *
@@ -39,5 +40,5 @@ export declare const dateSeparator: (date: Date, locale?: Locale) => string;
39
40
  * @param {Locale} [locale]
40
41
  * @returns {string}
41
42
  * */
42
- export declare const messageTime: (date: Date, locale?: Locale) => string;
43
+ export declare const getMessageTimeFormat: (date: Date, locale?: Locale) => string;
43
44
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sendbird/uikit-utils",
3
- "version": "2.0.3",
3
+ "version": "2.2.0",
4
4
  "description": "UIKit utilities",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -46,7 +46,7 @@
46
46
  "react": "17.0.2",
47
47
  "react-native": "0.67.4",
48
48
  "react-native-builder-bob": "^0.18.0",
49
- "typescript": "^4.1.3"
49
+ "typescript": "4.9.4"
50
50
  },
51
51
  "peerDependencies": {
52
52
  "@sendbird/chat": "^4.0.13",
@@ -76,5 +76,5 @@
76
76
  "readmeFile": "./README.md",
77
77
  "displayName": "@sendbird/uikit-utils"
78
78
  },
79
- "gitHead": "e3a34ae962741ffd2b647a466cf97e38f5006379"
79
+ "gitHead": "bd7ab217a07e91ba644c0cb69694a92b123326bf"
80
80
  }