@cometchat/chat-uikit-react-native 5.2.9 → 5.2.11

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 (40) hide show
  1. package/package.json +2 -2
  2. package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +47 -11
  3. package/src/CometChatMessageList/CometChatMessageList.tsx +58 -47
  4. package/src/CometChatMessageList/components/MessageListItem.tsx +11 -8
  5. package/src/CometChatSearch/style.ts +3 -3
  6. package/src/shared/formatters/CometChatMentionsFormatter/CometChatMentionsFormatter.tsx +71 -14
  7. package/src/shared/resources/CometChatLocalizeNew/resources/de/translation.json +1 -0
  8. package/src/shared/resources/CometChatLocalizeNew/resources/en/translation.json +1 -0
  9. package/src/shared/resources/CometChatLocalizeNew/resources/es/translation.json +1 -0
  10. package/src/shared/resources/CometChatLocalizeNew/resources/fr/translation.json +1 -0
  11. package/src/shared/resources/CometChatLocalizeNew/resources/hi/translation.json +1 -0
  12. package/src/shared/resources/CometChatLocalizeNew/resources/hu/translation.json +1 -0
  13. package/src/shared/resources/CometChatLocalizeNew/resources/it/translation.json +1 -0
  14. package/src/shared/resources/CometChatLocalizeNew/resources/ja/translation.json +1 -0
  15. package/src/shared/resources/CometChatLocalizeNew/resources/ko/translation.json +1 -0
  16. package/src/shared/resources/CometChatLocalizeNew/resources/lt/translation.json +1 -0
  17. package/src/shared/resources/CometChatLocalizeNew/resources/ms/translation.json +1 -0
  18. package/src/shared/resources/CometChatLocalizeNew/resources/nl/translation.json +1 -0
  19. package/src/shared/resources/CometChatLocalizeNew/resources/pt/translation.json +1 -0
  20. package/src/shared/resources/CometChatLocalizeNew/resources/ru/translation.json +1 -0
  21. package/src/shared/resources/CometChatLocalizeNew/resources/sv/translation.json +1 -0
  22. package/src/shared/resources/CometChatLocalizeNew/resources/tr/translation.json +1 -0
  23. package/src/shared/resources/CometChatLocalizeNew/resources/zh/translation.json +1 -0
  24. package/src/shared/resources/CometChatLocalizeNew/resources/zh-tw/translation.json +1 -0
  25. package/src/shared/utils/MessageUtils.tsx +55 -0
  26. package/src/shared/views/CometChatActionSheet/CometChatActionSheet.tsx +1 -1
  27. package/src/shared/views/CometChatList/Header.tsx +57 -49
  28. package/src/shared/views/CometChatMediaRecorder/CometChatMediaRecorder.tsx +0 -1
  29. package/src/shared/views/CometChatMessageInput/CometChatMessageInput.tsx +4 -3
  30. package/src/shared/views/CometChatQuickReactions/QuickReactionsStyle.tsx +2 -2
  31. package/src/shared/views/CometChatReactionList/ReactionListStyle.tsx +3 -2
  32. package/src/shared/views/CometChatReactions/CometChatReactions.tsx +11 -5
  33. package/src/shared/views/CometChatReactions/style.ts +35 -8
  34. package/src/shared/views/CometChatTextBubble/CometChatTextBubble.tsx +46 -61
  35. package/src/theme/index.ts +1 -1
  36. package/android/.gradle/7.4/checksums/checksums.lock +0 -0
  37. package/android/.gradle/7.4/fileChanges/last-build.bin +0 -0
  38. package/android/.gradle/7.4/fileHashes/fileHashes.lock +0 -0
  39. package/android/.gradle/7.4/gc.properties +0 -0
  40. package/android/.gradle/vcs-1/gc.properties +0 -0
@@ -17,15 +17,19 @@ export const getReactionsStyleLight = (
17
17
  flexDirection: "row",
18
18
  alignItems: "center",
19
19
  gap: 2,
20
+ // Allow reactions row to wrap when system font size causes overflow
21
+ flexWrap: "wrap",
20
22
  },
21
23
  emojiStyle: {
22
24
  containerStyle: {
23
25
  paddingVertical: spacing.padding.p0_5,
24
26
  paddingHorizontal: spacing.padding.p2,
25
- height: 24,
27
+ // Use minHeight instead of fixed height so the container grows
28
+ minHeight: 24,
26
29
  backgroundColor: color.background1,
27
30
  borderRadius: 20,
28
31
  flexDirection: "row",
32
+ alignItems: "center",
29
33
  gap: 4,
30
34
  borderWidth: 1,
31
35
  borderColor: color.borderDark,
@@ -37,10 +41,13 @@ export const getReactionsStyleLight = (
37
41
  containerStyle: {
38
42
  paddingVertical: spacing.padding.p0_5,
39
43
  paddingHorizontal: spacing.padding.p2,
40
- height: 24,
44
+ // Use minHeight instead of fixed height so the container grows
45
+ // when system font/display size is increased (accessibility)
46
+ minHeight: 24,
41
47
  backgroundColor: color.extendedPrimary100,
42
48
  borderRadius: 20,
43
49
  flexDirection: "row",
50
+ alignItems: "center",
44
51
  gap: 4,
45
52
  borderWidth: 1,
46
53
  borderColor: color.borderDark,
@@ -52,10 +59,13 @@ export const getReactionsStyleLight = (
52
59
  containerStyle: {
53
60
  paddingVertical: spacing.padding.p0_5,
54
61
  paddingHorizontal: spacing.padding.p2,
55
- height: 24,
62
+ // Use minHeight instead of fixed height so the container grows
63
+ // when system font/display size is increased (accessibility)
64
+ minHeight: 24,
56
65
  backgroundColor: color.background1,
57
66
  borderRadius: 20,
58
67
  flexDirection: "row",
68
+ alignItems: "center",
59
69
  gap: 4,
60
70
  borderWidth: 1,
61
71
  borderColor: color.borderDark,
@@ -64,10 +74,13 @@ export const getReactionsStyleLight = (
64
74
  activeContainerStyle: {
65
75
  paddingVertical: spacing.padding.p0_5,
66
76
  paddingHorizontal: spacing.padding.p2,
67
- height: 24,
77
+ // Use minHeight instead of fixed height so the container grows
78
+ // when system font/display size is increased (accessibility)
79
+ minHeight: 24,
68
80
  backgroundColor: color.extendedPrimary100,
69
81
  borderRadius: 20,
70
82
  flexDirection: "row",
83
+ alignItems: "center",
71
84
  gap: 4,
72
85
  borderWidth: 1,
73
86
  borderColor: color.borderDark,
@@ -81,15 +94,20 @@ export const getReactionsStyleLight = (
81
94
  flexDirection: "row",
82
95
  alignItems: "center",
83
96
  gap: 2,
97
+ // Allow reactions row to wrap when system font size causes overflow
98
+ flexWrap: "wrap",
84
99
  },
85
100
  emojiStyle: {
86
101
  containerStyle: {
87
102
  paddingVertical: spacing.padding.p0_5,
88
103
  paddingHorizontal: spacing.padding.p2,
89
- height: 24,
104
+ // Use minHeight instead of fixed height so the container grows
105
+ // when system font/display size is increased (accessibility)
106
+ minHeight: 24,
90
107
  backgroundColor: color.background1,
91
108
  borderRadius: 20,
92
109
  flexDirection: "row",
110
+ alignItems: "center",
93
111
  gap: 4,
94
112
  borderWidth: 1,
95
113
  borderColor: color.borderDark,
@@ -101,10 +119,13 @@ export const getReactionsStyleLight = (
101
119
  containerStyle: {
102
120
  paddingVertical: spacing.padding.p0_5,
103
121
  paddingHorizontal: spacing.padding.p2,
104
- height: 24,
122
+ // Use minHeight instead of fixed height so the container grows
123
+ // when system font/display size is increased (accessibility)
124
+ minHeight: 24,
105
125
  backgroundColor: color.extendedPrimary100,
106
126
  borderRadius: 20,
107
127
  flexDirection: "row",
128
+ alignItems: "center",
108
129
  gap: 4,
109
130
  borderWidth: 1,
110
131
  borderColor: color.borderDark,
@@ -116,10 +137,13 @@ export const getReactionsStyleLight = (
116
137
  containerStyle: {
117
138
  paddingVertical: spacing.padding.p0_5,
118
139
  paddingHorizontal: spacing.padding.p2,
119
- height: 24,
140
+ // Use minHeight instead of fixed height so the container grows
141
+ // when system font/display size is increased (accessibility)
142
+ minHeight: 24,
120
143
  backgroundColor: color.background1,
121
144
  borderRadius: 20,
122
145
  flexDirection: "row",
146
+ alignItems: "center",
123
147
  gap: 4,
124
148
  borderWidth: 1,
125
149
  borderColor: color.borderDark,
@@ -128,10 +152,13 @@ export const getReactionsStyleLight = (
128
152
  activeContainerStyle: {
129
153
  paddingVertical: spacing.padding.p0_5,
130
154
  paddingHorizontal: spacing.padding.p2,
131
- height: 24,
155
+ // Use minHeight instead of fixed height so the container grows
156
+ // when system font/display size is increased (accessibility)
157
+ minHeight: 24,
132
158
  backgroundColor: color.extendedPrimary100,
133
159
  borderRadius: 20,
134
160
  flexDirection: "row",
161
+ alignItems: "center",
135
162
  gap: 4,
136
163
  borderWidth: 1,
137
164
  borderColor: color.borderDark,
@@ -1,4 +1,4 @@
1
- import React, { useLayoutEffect, useState, useRef, useCallback } from "react";
1
+ import React, { useLayoutEffect, useState, useRef, useCallback, useMemo } from "react";
2
2
  import {
3
3
  StyleProp,
4
4
  Text,
@@ -63,92 +63,77 @@ export const CometChatTextBubbleText = (
63
63
  toggleTextStyle,
64
64
  } = props;
65
65
 
66
- const [formattedText, setFormattedText] = useState<string>(text);
67
66
  const [isExpanded, setIsExpanded] = useState(false);
68
67
  const [isTruncatable, setIsTruncatable] = useState(false);
69
-
70
- // store container width for accurate measurement
71
68
  const [containerWidth, setContainerWidth] = useState<number | null>(null);
69
+ const [measurementComplete, setMeasurementComplete] = useState(false);
72
70
 
73
- /**
74
- * measuredCache helps avoid re-measuring if the same text+width was already measured.
75
- * Structure: { key: string } where key = `${text}::${width}`
76
- */
71
+ // Refs to track state without causing re-renders
77
72
  const measuredCacheRef = useRef<Record<string, boolean>>({});
73
+ const lastTextRef = useRef<string>(text);
78
74
 
79
- // Only recompute formattedText when the text or textFormatters actually change.
80
- useLayoutEffect(() => {
75
+ // Compute formatted text synchronously - no state update needed
76
+ const formattedText = useMemo(() => {
81
77
  let finalText = text;
82
78
  if (textFormatters && textFormatters.length) {
83
79
  for (let i = 0; i < textFormatters.length; i++) {
84
80
  finalText = textFormatters[i].getFormattedText(finalText);
85
81
  }
86
82
  }
83
+ return finalText as string;
84
+ }, [text, textFormatters]);
87
85
 
88
- // If text content actually changed, update formattedText and reset expansion.
89
- // Do NOT reset on other prop changes (so adding reaction won't collapse/lose toggle).
90
- if (finalText !== formattedText) {
91
- setFormattedText(finalText as string);
86
+ // Reset state only when text actually changes
87
+ useLayoutEffect(() => {
88
+ if (lastTextRef.current !== text) {
89
+ lastTextRef.current = text;
92
90
  setIsExpanded(false);
93
- // measurement cache can stay, but remove entries for previous text (optional)
94
- // measuredCacheRef.current = {}; // not required, we'll rely on keying by text+width
91
+ setIsTruncatable(false);
92
+ setMeasurementComplete(false);
95
93
  }
96
- // eslint-disable-next-line react-hooks/exhaustive-deps
97
- }, [
98
- text /* only textFormatters intentionally omitted from deps if stable; if not stable include it */,
99
- ]);
100
-
101
- // handler to capture container width whenever layout changes
102
- const onContainerLayout = useCallback(
103
- (e: LayoutChangeEvent) => {
104
- const w = Math.round(e.nativeEvent.layout.width);
105
- if (w && w !== containerWidth) {
106
- setContainerWidth(w);
107
- // Do NOT clear isExpanded here — measurement may change truncation but we want to
108
- // preserve user's expanded/collapsed state unless the text itself changed.
109
- }
110
- },
111
- [containerWidth]
112
- );
94
+ }, [text]);
113
95
 
114
- // Called when hidden text is laid out; use it to determine lines count
115
- const onMeasuredTextLayout = (e: TextLayoutEvent) => {
116
- // We rely on containerWidth + formattedText as the measurement key
96
+ // Handler to capture container width - use functional update to avoid dependency
97
+ const onContainerLayout = useCallback((e: LayoutChangeEvent) => {
98
+ const w = Math.round(e.nativeEvent.layout.width);
99
+ if (w > 0) {
100
+ setContainerWidth(prev => prev === w ? prev : w);
101
+ }
102
+ }, []);
103
+
104
+ // Called when hidden text is laid out
105
+ const onMeasuredTextLayout = useCallback((e: TextLayoutEvent) => {
117
106
  const key = `${formattedText}::${containerWidth ?? 0}`;
118
107
 
119
- // If we've already measured this text at this width, skip
120
- if (measuredCacheRef.current[key]) return;
108
+ // Skip if already measured
109
+ if (measuredCacheRef.current[key]) {
110
+ if (!measurementComplete) {
111
+ setMeasurementComplete(true);
112
+ }
113
+ return;
114
+ }
121
115
 
122
116
  const lines = e.nativeEvent.lines;
123
117
  const isNowTruncatable = !!(lines && lines.length > collapseLines);
124
118
 
119
+ measuredCacheRef.current[key] = true;
125
120
  setIsTruncatable(isNowTruncatable);
126
- measuredCacheRef.current[key] = isNowTruncatable;
127
- };
128
-
129
- const toggle = () => setIsExpanded((v) => !v);
130
-
131
- /**
132
- * Hidden measurement `Text`:
133
- * - we render it only when we have containerWidth (so it can measure correctly)
134
- * - style uses same font metrics as visible text because it inherits textStyle
135
- * - opacity: 0 and position absolute so it does not affect layout
136
- *
137
- * Important: We key the hidden Text by formattedText + containerWidth so React remounts
138
- * it and triggers onTextLayout when either changes.
139
- */
121
+ setMeasurementComplete(true);
122
+ }, [formattedText, containerWidth, collapseLines, measurementComplete]);
123
+
124
+ const toggle = useCallback(() => setIsExpanded(v => !v), []);
125
+
140
126
  const hiddenTextKey = `${formattedText}::${containerWidth ?? 0}`;
127
+ const needsMeasurement = containerWidth !== null && !measuredCacheRef.current[hiddenTextKey];
141
128
 
142
129
  return (
143
130
  <View onLayout={onContainerLayout}>
144
- {/* Hidden measurement text: only meaningful after we know container width */}
145
- {containerWidth ? (
131
+ {/* Hidden measurement text - only render if we need to measure */}
132
+ {needsMeasurement && (
146
133
  <Text
147
134
  key={hiddenTextKey}
148
- // make sure the hidden text has same width as container
149
135
  style={[
150
- // width must be exact to get consistent wrapping on both platforms
151
- { position: "absolute", left: 0, top: -10000, width: containerWidth, opacity: 0 },
136
+ { position: "absolute", left: 0, top: -10000, width: containerWidth!, opacity: 0 },
152
137
  textStyle as any,
153
138
  ]}
154
139
  onTextLayout={onMeasuredTextLayout}
@@ -157,7 +142,7 @@ export const CometChatTextBubbleText = (
157
142
  >
158
143
  {formattedText}
159
144
  </Text>
160
- ) : null}
145
+ )}
161
146
 
162
147
  {/* Visible text */}
163
148
  <Text
@@ -168,8 +153,8 @@ export const CometChatTextBubbleText = (
168
153
  {formattedText}
169
154
  </Text>
170
155
 
171
- {/* Toggle (only when truncation is needed) */}
172
- {isTruncatable ? (
156
+ {/* Toggle - only show after measurement is complete to prevent flicker */}
157
+ {measurementComplete && isTruncatable && (
173
158
  <View style={[{ alignItems: "flex-end", marginTop: 6 }, toggleContainerStyle]}>
174
159
  <TouchableOpacity onPress={toggle} accessibilityRole='button'>
175
160
  <Text style={[{ alignSelf: "flex-end" }, textStyle, toggleTextStyle]}>
@@ -177,7 +162,7 @@ export const CometChatTextBubbleText = (
177
162
  </Text>
178
163
  </TouchableOpacity>
179
164
  </View>
180
- ) : null}
165
+ )}
181
166
  </View>
182
167
  );
183
168
  };
@@ -1,3 +1,3 @@
1
1
  export * from "./CometChatThemeHelper";
2
- export { useTheme } from "./hook";
2
+ export { useTheme, useThemeInternal } from "./hook";
3
3
  export { CometChatThemeProvider } from "./provider";
File without changes
File without changes