@sendbird/uikit-utils 3.7.6 → 3.8.1

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 (71) hide show
  1. package/lib/commonjs/hooks/index.js +2 -5
  2. package/lib/commonjs/hooks/index.js.map +1 -1
  3. package/lib/commonjs/hooks/react-native.js +23 -7
  4. package/lib/commonjs/hooks/react-native.js.map +1 -1
  5. package/lib/commonjs/index.js +16 -6
  6. package/lib/commonjs/index.js.map +1 -1
  7. package/lib/commonjs/sendbird/attrs.js +2 -4
  8. package/lib/commonjs/sendbird/attrs.js.map +1 -1
  9. package/lib/commonjs/sendbird/channel.js.map +1 -1
  10. package/lib/commonjs/sendbird/message.js +6 -11
  11. package/lib/commonjs/sendbird/message.js.map +1 -1
  12. package/lib/commonjs/sendbird/user.js.map +1 -1
  13. package/lib/commonjs/shared/arrayToMap.js.map +1 -1
  14. package/lib/commonjs/shared/bufferedRequest.js +8 -8
  15. package/lib/commonjs/shared/bufferedRequest.js.map +1 -1
  16. package/lib/commonjs/shared/file.js +5 -10
  17. package/lib/commonjs/shared/file.js.map +1 -1
  18. package/lib/commonjs/shared/index.js.map +1 -1
  19. package/lib/commonjs/shared/logger.js +7 -24
  20. package/lib/commonjs/shared/logger.js.map +1 -1
  21. package/lib/commonjs/shared/regex.js +17 -24
  22. package/lib/commonjs/shared/regex.js.map +1 -1
  23. package/lib/commonjs/shared/rtl.js +52 -0
  24. package/lib/commonjs/shared/rtl.js.map +1 -0
  25. package/lib/commonjs/types.js.map +1 -1
  26. package/lib/commonjs/ui-format/common.js +4 -9
  27. package/lib/commonjs/ui-format/common.js.map +1 -1
  28. package/lib/commonjs/ui-format/groupChannel.js +7 -17
  29. package/lib/commonjs/ui-format/groupChannel.js.map +1 -1
  30. package/lib/commonjs/ui-format/openChannel.js +1 -2
  31. package/lib/commonjs/ui-format/openChannel.js.map +1 -1
  32. package/lib/module/hooks/index.js +2 -5
  33. package/lib/module/hooks/index.js.map +1 -1
  34. package/lib/module/hooks/react-native.js +24 -8
  35. package/lib/module/hooks/react-native.js.map +1 -1
  36. package/lib/module/index.js +1 -0
  37. package/lib/module/index.js.map +1 -1
  38. package/lib/module/sendbird/attrs.js.map +1 -1
  39. package/lib/module/sendbird/channel.js.map +1 -1
  40. package/lib/module/sendbird/message.js +6 -11
  41. package/lib/module/sendbird/message.js.map +1 -1
  42. package/lib/module/sendbird/user.js.map +1 -1
  43. package/lib/module/shared/arrayToMap.js.map +1 -1
  44. package/lib/module/shared/bufferedRequest.js +8 -8
  45. package/lib/module/shared/bufferedRequest.js.map +1 -1
  46. package/lib/module/shared/file.js +2 -4
  47. package/lib/module/shared/file.js.map +1 -1
  48. package/lib/module/shared/index.js.map +1 -1
  49. package/lib/module/shared/logger.js +6 -22
  50. package/lib/module/shared/logger.js.map +1 -1
  51. package/lib/module/shared/regex.js +12 -14
  52. package/lib/module/shared/regex.js.map +1 -1
  53. package/lib/module/shared/rtl.js +44 -0
  54. package/lib/module/shared/rtl.js.map +1 -0
  55. package/lib/module/types.js.map +1 -1
  56. package/lib/module/ui-format/common.js +4 -9
  57. package/lib/module/ui-format/common.js.map +1 -1
  58. package/lib/module/ui-format/groupChannel.js +7 -17
  59. package/lib/module/ui-format/groupChannel.js.map +1 -1
  60. package/lib/module/ui-format/openChannel.js +1 -2
  61. package/lib/module/ui-format/openChannel.js.map +1 -1
  62. package/lib/typescript/src/hooks/react-native.d.ts +3 -3
  63. package/lib/typescript/src/index.d.ts +1 -0
  64. package/lib/typescript/src/shared/rtl.d.ts +2 -0
  65. package/lib/typescript/src/types.d.ts +2 -1
  66. package/package.json +3 -3
  67. package/src/hooks/react-native.ts +28 -9
  68. package/src/index.ts +1 -0
  69. package/src/sendbird/message.ts +1 -1
  70. package/src/shared/rtl.ts +45 -0
  71. package/src/types.ts +2 -0
@@ -0,0 +1,45 @@
1
+ const isRTLString = (dir: 'start' | 'end', str?: string) => {
2
+ if (!str || str.length === 0) {
3
+ return false;
4
+ }
5
+
6
+ const trimmedStr = str.trimStart();
7
+ if (trimmedStr.length === 0) {
8
+ return false;
9
+ }
10
+
11
+ const char = dir === 'start' ? Array.from(trimmedStr)[0] : Array.from(trimmedStr).pop();
12
+ const point = char?.codePointAt(0);
13
+ if (point === undefined) {
14
+ return false;
15
+ }
16
+
17
+ return isRTLCodePoint(point);
18
+ };
19
+
20
+ export const isStartsWithRTL = (str?: string): boolean => {
21
+ return isRTLString('start', str);
22
+ };
23
+
24
+ export const isEndsWithRTL = (str?: string): boolean => {
25
+ return isRTLString('end', str);
26
+ };
27
+
28
+ const isRTLCodePoint = (codePoint: number) => {
29
+ for (const [start, end] of rtlCodePointRanges) {
30
+ if (codePoint >= start && codePoint <= end) {
31
+ return true;
32
+ }
33
+ }
34
+ return false;
35
+ };
36
+
37
+ const rtlCodePointRanges = [
38
+ [0x0590, 0x05ff], // Hebrew
39
+ [0x0600, 0x06ff], // Arabic
40
+ [0x0750, 0x077f], // Arabic Supplement
41
+ [0x08a0, 0x08ff], // Hebrew Supplement
42
+ [0xfb1d, 0xfb4f], // Hebrew Presentation Forms
43
+ [0xfe70, 0xfeff], // Arabic Presentation Forms-B
44
+ [0x1ee00, 0x1eeff], // Arabic Mathematical Alphabetic Symbols
45
+ ];
package/src/types.ts CHANGED
@@ -39,6 +39,7 @@ import type {
39
39
  MessageSearchQuery,
40
40
  MultipleFilesMessage,
41
41
  PreviousMessageListQuery,
42
+ ReactedUserInfo,
42
43
  Reaction,
43
44
  UserMessage,
44
45
  UserMessageCreateParams,
@@ -112,6 +113,7 @@ export type SendbirdOpenChannel = OpenChannel;
112
113
  export type SendbirdFeedChannel = FeedChannel;
113
114
 
114
115
  export type SendbirdReaction = Reaction;
116
+ export type SendbirdReactedUserInfo = ReactedUserInfo;
115
117
  export type SendbirdEmoji = Emoji;
116
118
  export type SendbirdEmojiCategory = EmojiCategory;
117
119
  export type SendbirdEmojiContainer = EmojiContainer;