@poolse/react-native 2.22.0 → 2.22.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.
package/dist/index.d.cts CHANGED
@@ -243,9 +243,9 @@ interface MessageBubbleProps {
243
243
  /**
244
244
  * One message bubble, structured as stacked sections rather than one
245
245
  * padded box: media bleeds to a 3px frame, text carries its own
246
- * padding, and the timestamp lives ON the last text line (reserved by
247
- * an invisible twin) instead of a full-width row of its own — which
248
- * is what makes "ok" a one-line bubble instead of a squat rectangle.
246
+ * padding, and the timestamp shares the last text line when measured
247
+ * room allows — which is what makes "ok" a one-line bubble instead of
248
+ * a squat rectangle.
249
249
  */
250
250
  declare function MessageBubble({ message, currentUserId, readState, labelFor, onQuotedClick, groupPosition, maxBodyLength, showSenderName, actionsTrigger, showAttachments, markdown, onLongPress, }: MessageBubbleProps): react_jsx_runtime.JSX.Element;
251
251
 
package/dist/index.d.ts CHANGED
@@ -243,9 +243,9 @@ interface MessageBubbleProps {
243
243
  /**
244
244
  * One message bubble, structured as stacked sections rather than one
245
245
  * padded box: media bleeds to a 3px frame, text carries its own
246
- * padding, and the timestamp lives ON the last text line (reserved by
247
- * an invisible twin) instead of a full-width row of its own — which
248
- * is what makes "ok" a one-line bubble instead of a squat rectangle.
246
+ * padding, and the timestamp shares the last text line when measured
247
+ * room allows — which is what makes "ok" a one-line bubble instead of
248
+ * a squat rectangle.
249
249
  */
250
250
  declare function MessageBubble({ message, currentUserId, readState, labelFor, onQuotedClick, groupPosition, maxBodyLength, showSenderName, actionsTrigger, showAttachments, markdown, onLongPress, }: MessageBubbleProps): react_jsx_runtime.JSX.Element;
251
251
 
package/dist/index.js CHANGED
@@ -2759,6 +2759,9 @@ function MessageBubble({
2759
2759
  const { width: screenWidth } = useWindowDimensions();
2760
2760
  const isSelf = currentUserId !== null && message.sender_id === currentUserId;
2761
2761
  const [expanded, setExpanded] = useState(false);
2762
+ const [lastLineWidth, setLastLineWidth] = useState(null);
2763
+ const [textBoxWidth, setTextBoxWidth] = useState(null);
2764
+ const [metaWidth, setMetaWidth] = useState(null);
2762
2765
  const bubbleMaxWidth = Math.floor(screenWidth * 0.78);
2763
2766
  const mediaWidth = Math.min(bubbleMaxWidth - 6, 420);
2764
2767
  const sender = useUser(!isSelf ? message.sender_external_id : null);
@@ -2794,7 +2797,7 @@ function MessageBubble({
2794
2797
  const jumboCount = hasBody && !hasMedia && !hasFiles && !message.quoted_message_id ? emojiOnlyCount(body) : 0;
2795
2798
  const inlineMeta = hasBody && jumboCount === 0 && !trimmable && (!markdown || !hasMarkdown(truncated));
2796
2799
  const sectionAbove = hasMedia || hasFiles || !!message.quoted_message || isDeleted;
2797
- const ghost = ` ${isEdited ? "edited " : ""}${time}${isSelf && readState ? " \u2713\u2713" : ""}`;
2800
+ const metaFits = lastLineWidth !== null && textBoxWidth !== null && metaWidth !== null && lastLineWidth + metaWidth + 14 <= textBoxWidth;
2798
2801
  const metaRow = (variant) => {
2799
2802
  const color = variant === "overlay" ? "#FFFFFF" : variant === "jumbo" ? theme.colors.ink3 : mutedOnBubble;
2800
2803
  return /* @__PURE__ */ jsxs(
@@ -2803,6 +2806,7 @@ function MessageBubble({
2803
2806
  style: [
2804
2807
  styles15.metaRow,
2805
2808
  variant === "inline" && styles15.metaInline,
2809
+ variant === "wrapped" && styles15.metaWrapped,
2806
2810
  variant === "overlay" && styles15.metaOverlay,
2807
2811
  variant === "block" && styles15.metaBlock,
2808
2812
  // File-only bubble: the meta row follows the cards directly —
@@ -2810,6 +2814,7 @@ function MessageBubble({
2810
2814
  variant === "block" && hasFiles && !hasBody && styles15.metaBlockAfterFiles,
2811
2815
  variant === "jumbo" && styles15.metaJumbo
2812
2816
  ],
2817
+ onLayout: variant === "inline" || variant === "wrapped" ? (e) => setMetaWidth(e.nativeEvent.layout.width) : void 0,
2813
2818
  pointerEvents: "none",
2814
2819
  children: [
2815
2820
  isEdited ? /* @__PURE__ */ jsx(Text, { style: [styles15.editedTag, { color, opacity: 0.8 }], children: "edited" }) : null,
@@ -2907,51 +2912,53 @@ function MessageBubble({
2907
2912
  children: body
2908
2913
  }
2909
2914
  ) }) : null,
2910
- hasBody && jumboCount === 0 ? /* @__PURE__ */ jsxs(View, { style: [styles15.textBlock, sectionAbove && styles15.textBlockAfter], children: [
2911
- markdown && !inlineMeta ? renderMarkdown(truncated, {
2912
- textColor,
2913
- linkColor: isSelf ? theme.colors.onBrand : theme.colors.brand,
2914
- fontFamily: theme.type.fontBody,
2915
- fontSize: theme.type.bodySize,
2916
- lineHeight: theme.type.lineHeight,
2917
- onLinkPress: (url) => {
2918
- void Linking.openURL(url).catch(() => void 0);
2919
- return false;
2920
- }
2921
- }) : /* @__PURE__ */ jsxs(
2922
- Text,
2923
- {
2924
- style: {
2925
- color: textColor,
2915
+ hasBody && jumboCount === 0 ? /* @__PURE__ */ jsxs(
2916
+ View,
2917
+ {
2918
+ style: [styles15.textBlock, sectionAbove && styles15.textBlockAfter],
2919
+ onLayout: inlineMeta ? (e) => setTextBoxWidth(e.nativeEvent.layout.width - 24) : void 0,
2920
+ children: [
2921
+ markdown && !inlineMeta ? renderMarkdown(truncated, {
2922
+ textColor,
2923
+ linkColor: isSelf ? theme.colors.onBrand : theme.colors.brand,
2926
2924
  fontFamily: theme.type.fontBody,
2927
2925
  fontSize: theme.type.bodySize,
2928
- lineHeight: theme.type.lineHeight
2929
- },
2930
- children: [
2931
- truncated,
2932
- inlineMeta ? (
2933
- // The invisible twin: reserves the meta's footprint
2934
- // at the end of the last line so the absolutely-
2935
- // positioned real meta never covers a glyph — and
2936
- // when the line is full, the reservation wraps and
2937
- // the meta drops down, flush right.
2938
- /* @__PURE__ */ jsx(Text, { style: styles15.ghost, children: ghost })
2939
- ) : null
2940
- ]
2941
- }
2942
- ),
2943
- trimmable ? /* @__PURE__ */ jsx(Pressable, { onPress: () => setExpanded((e) => !e), children: /* @__PURE__ */ jsx(
2944
- Text,
2945
- {
2946
- style: [
2947
- styles15.readMore,
2948
- { color: isSelf ? theme.colors.onBrand : theme.colors.brand }
2949
- ],
2950
- children: expanded ? "Show less" : "Read more"
2951
- }
2952
- ) }) : null,
2953
- inlineMeta ? metaRow("inline") : null
2954
- ] }) : null,
2926
+ lineHeight: theme.type.lineHeight,
2927
+ onLinkPress: (url) => {
2928
+ void Linking.openURL(url).catch(() => void 0);
2929
+ return false;
2930
+ }
2931
+ }) : /* @__PURE__ */ jsx(
2932
+ Text,
2933
+ {
2934
+ style: {
2935
+ color: textColor,
2936
+ fontFamily: theme.type.fontBody,
2937
+ fontSize: theme.type.bodySize,
2938
+ lineHeight: theme.type.lineHeight
2939
+ },
2940
+ onTextLayout: inlineMeta ? (e) => {
2941
+ const lines = e.nativeEvent.lines;
2942
+ const last = lines[lines.length - 1];
2943
+ setLastLineWidth(last ? Math.ceil(last.width) : 0);
2944
+ } : void 0,
2945
+ children: truncated
2946
+ }
2947
+ ),
2948
+ trimmable ? /* @__PURE__ */ jsx(Pressable, { onPress: () => setExpanded((e) => !e), children: /* @__PURE__ */ jsx(
2949
+ Text,
2950
+ {
2951
+ style: [
2952
+ styles15.readMore,
2953
+ { color: isSelf ? theme.colors.onBrand : theme.colors.brand }
2954
+ ],
2955
+ children: expanded ? "Show less" : "Read more"
2956
+ }
2957
+ ) }) : null,
2958
+ inlineMeta ? metaRow(metaFits ? "inline" : "wrapped") : null
2959
+ ]
2960
+ }
2961
+ ) : null,
2955
2962
  !inlineMeta && !metaOverlay && jumboCount === 0 ? metaRow("block") : null,
2956
2963
  actionsTrigger ? /* @__PURE__ */ jsx(View, { style: styles15.actionsSlot, children: actionsTrigger }) : null
2957
2964
  ]
@@ -3047,9 +3054,11 @@ var styles15 = StyleSheet.create({
3047
3054
  jumboBlock: {
3048
3055
  paddingVertical: 2
3049
3056
  },
3050
- ghost: {
3051
- color: "transparent",
3052
- fontSize: 11
3057
+ // The meta on its own line inside the text block, flush right —
3058
+ // the fallback whenever the last text line has no room for it.
3059
+ metaWrapped: {
3060
+ alignSelf: "flex-end",
3061
+ marginTop: 3
3053
3062
  },
3054
3063
  readMore: {
3055
3064
  fontSize: 12,