@oxy.so/bloom 7.8.0 → 7.9.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 (100) hide show
  1. package/docs/ai-chat.mdx +26 -0
  2. package/docs/chat-composer.mdx +13 -0
  3. package/docs/sidebar.mdx +15 -0
  4. package/lib/commonjs/ai-chat/AiChatMessages.js +8 -3
  5. package/lib/commonjs/ai-chat/AiChatMessages.js.map +1 -1
  6. package/lib/commonjs/chat-composer/create-chat-composer.js +11 -6
  7. package/lib/commonjs/chat-composer/create-chat-composer.js.map +1 -1
  8. package/lib/commonjs/hooks/use-browser-title.js +17 -0
  9. package/lib/commonjs/hooks/use-browser-title.js.map +1 -0
  10. package/lib/commonjs/hooks/use-textarea-autosize.js +22 -1
  11. package/lib/commonjs/hooks/use-textarea-autosize.js.map +1 -1
  12. package/lib/commonjs/sidebar/Sidebar.js +5 -6
  13. package/lib/commonjs/sidebar/Sidebar.js.map +1 -1
  14. package/lib/commonjs/sidebar/SidebarItem.js +3 -4
  15. package/lib/commonjs/sidebar/SidebarItem.js.map +1 -1
  16. package/lib/commonjs/sidebar/SidebarModeSwitcher.js +3 -3
  17. package/lib/commonjs/sidebar/SidebarModeSwitcher.js.map +1 -1
  18. package/lib/commonjs/sidebar/SidebarRail.js +6 -1
  19. package/lib/commonjs/sidebar/SidebarRail.js.map +1 -1
  20. package/lib/commonjs/sidebar/SidebarRailItem.js +13 -6
  21. package/lib/commonjs/sidebar/SidebarRailItem.js.map +1 -1
  22. package/lib/module/ai-chat/AiChatMessages.js +8 -3
  23. package/lib/module/ai-chat/AiChatMessages.js.map +1 -1
  24. package/lib/module/chat-composer/create-chat-composer.js +12 -7
  25. package/lib/module/chat-composer/create-chat-composer.js.map +1 -1
  26. package/lib/module/hooks/use-browser-title.js +14 -0
  27. package/lib/module/hooks/use-browser-title.js.map +1 -0
  28. package/lib/module/hooks/use-textarea-autosize.js +22 -1
  29. package/lib/module/hooks/use-textarea-autosize.js.map +1 -1
  30. package/lib/module/sidebar/Sidebar.js +5 -6
  31. package/lib/module/sidebar/Sidebar.js.map +1 -1
  32. package/lib/module/sidebar/SidebarItem.js +3 -4
  33. package/lib/module/sidebar/SidebarItem.js.map +1 -1
  34. package/lib/module/sidebar/SidebarModeSwitcher.js +3 -3
  35. package/lib/module/sidebar/SidebarModeSwitcher.js.map +1 -1
  36. package/lib/module/sidebar/SidebarRail.js +6 -1
  37. package/lib/module/sidebar/SidebarRail.js.map +1 -1
  38. package/lib/module/sidebar/SidebarRailItem.js +13 -6
  39. package/lib/module/sidebar/SidebarRailItem.js.map +1 -1
  40. package/lib/typescript/commonjs/ai-chat/AiChatMessages.d.ts +1 -1
  41. package/lib/typescript/commonjs/ai-chat/AiChatMessages.d.ts.map +1 -1
  42. package/lib/typescript/commonjs/ai-chat/types.d.ts +3 -0
  43. package/lib/typescript/commonjs/ai-chat/types.d.ts.map +1 -1
  44. package/lib/typescript/commonjs/chat-composer/ChatComposer.d.ts +1 -1
  45. package/lib/typescript/commonjs/chat-composer/ChatComposer.d.ts.map +1 -1
  46. package/lib/typescript/commonjs/chat-composer/ChatComposer.web.d.ts +1 -1
  47. package/lib/typescript/commonjs/chat-composer/ChatComposer.web.d.ts.map +1 -1
  48. package/lib/typescript/commonjs/chat-composer/create-chat-composer.d.ts +1 -1
  49. package/lib/typescript/commonjs/chat-composer/create-chat-composer.d.ts.map +1 -1
  50. package/lib/typescript/commonjs/chat-composer/types.d.ts +7 -1
  51. package/lib/typescript/commonjs/chat-composer/types.d.ts.map +1 -1
  52. package/lib/typescript/commonjs/hooks/use-browser-title.d.ts +4 -0
  53. package/lib/typescript/commonjs/hooks/use-browser-title.d.ts.map +1 -0
  54. package/lib/typescript/commonjs/hooks/use-textarea-autosize.d.ts +1 -1
  55. package/lib/typescript/commonjs/hooks/use-textarea-autosize.d.ts.map +1 -1
  56. package/lib/typescript/commonjs/sidebar/Sidebar.d.ts.map +1 -1
  57. package/lib/typescript/commonjs/sidebar/SidebarItem.d.ts.map +1 -1
  58. package/lib/typescript/commonjs/sidebar/SidebarModeSwitcher.d.ts.map +1 -1
  59. package/lib/typescript/commonjs/sidebar/SidebarRail.d.ts +1 -1
  60. package/lib/typescript/commonjs/sidebar/SidebarRail.d.ts.map +1 -1
  61. package/lib/typescript/commonjs/sidebar/SidebarRailItem.d.ts.map +1 -1
  62. package/lib/typescript/commonjs/sidebar/types.d.ts +10 -0
  63. package/lib/typescript/commonjs/sidebar/types.d.ts.map +1 -1
  64. package/lib/typescript/module/ai-chat/AiChatMessages.d.ts +1 -1
  65. package/lib/typescript/module/ai-chat/AiChatMessages.d.ts.map +1 -1
  66. package/lib/typescript/module/ai-chat/types.d.ts +3 -0
  67. package/lib/typescript/module/ai-chat/types.d.ts.map +1 -1
  68. package/lib/typescript/module/chat-composer/ChatComposer.d.ts +1 -1
  69. package/lib/typescript/module/chat-composer/ChatComposer.d.ts.map +1 -1
  70. package/lib/typescript/module/chat-composer/ChatComposer.web.d.ts +1 -1
  71. package/lib/typescript/module/chat-composer/ChatComposer.web.d.ts.map +1 -1
  72. package/lib/typescript/module/chat-composer/create-chat-composer.d.ts +1 -1
  73. package/lib/typescript/module/chat-composer/create-chat-composer.d.ts.map +1 -1
  74. package/lib/typescript/module/chat-composer/types.d.ts +7 -1
  75. package/lib/typescript/module/chat-composer/types.d.ts.map +1 -1
  76. package/lib/typescript/module/hooks/use-browser-title.d.ts +4 -0
  77. package/lib/typescript/module/hooks/use-browser-title.d.ts.map +1 -0
  78. package/lib/typescript/module/hooks/use-textarea-autosize.d.ts +1 -1
  79. package/lib/typescript/module/hooks/use-textarea-autosize.d.ts.map +1 -1
  80. package/lib/typescript/module/sidebar/Sidebar.d.ts.map +1 -1
  81. package/lib/typescript/module/sidebar/SidebarItem.d.ts.map +1 -1
  82. package/lib/typescript/module/sidebar/SidebarModeSwitcher.d.ts.map +1 -1
  83. package/lib/typescript/module/sidebar/SidebarRail.d.ts +1 -1
  84. package/lib/typescript/module/sidebar/SidebarRail.d.ts.map +1 -1
  85. package/lib/typescript/module/sidebar/SidebarRailItem.d.ts.map +1 -1
  86. package/lib/typescript/module/sidebar/types.d.ts +10 -0
  87. package/lib/typescript/module/sidebar/types.d.ts.map +1 -1
  88. package/package.json +1 -1
  89. package/src/ai-chat/AiChatMessages.tsx +8 -4
  90. package/src/ai-chat/types.ts +3 -0
  91. package/src/chat-composer/create-chat-composer.tsx +13 -6
  92. package/src/chat-composer/types.ts +7 -1
  93. package/src/hooks/use-browser-title.ts +13 -0
  94. package/src/hooks/use-textarea-autosize.ts +24 -4
  95. package/src/sidebar/Sidebar.tsx +5 -3
  96. package/src/sidebar/SidebarItem.tsx +3 -2
  97. package/src/sidebar/SidebarModeSwitcher.tsx +4 -2
  98. package/src/sidebar/SidebarRail.tsx +6 -1
  99. package/src/sidebar/SidebarRailItem.tsx +12 -5
  100. package/src/sidebar/types.ts +10 -0
@@ -20,8 +20,8 @@ import type { TextInput } from 'react-native';
20
20
  * stands: one layout, the same one the frame was going to do anyway.
21
21
  * - a field already at its floor cannot shrink, so it is never collapsed.
22
22
  * - anything else — a deletion, a replacement, a programmatic `value` such as
23
- * the clear after send, a change of floor — collapses, reads and restores
24
- * in the same task, so nothing is painted in between.
23
+ * the clear after send, a change of floor or available width — collapses,
24
+ * reads and restores in the same task, so nothing is painted in between.
25
25
  *
26
26
  * The one thing insertion cannot promise is soft-wrap: inserting a character
27
27
  * could in principle reflow a wrapped word onto fewer lines. The field then
@@ -88,8 +88,8 @@ export function useTextareaAutosize(
88
88
  ): void {
89
89
  // What the field held at the last measurement, and the floor it was held to.
90
90
  const last = useRef<{ text: string; minHeight: number } | null>(null);
91
- const latest = useRef({ height, onMeasure });
92
- latest.current = { height, onMeasure };
91
+ const latest = useRef({ height, minHeight, onMeasure });
92
+ latest.current = { height, minHeight, onMeasure };
93
93
 
94
94
  useLayoutEffect(() => {
95
95
  if (!enabled) return;
@@ -103,4 +103,24 @@ export function useTextareaAutosize(
103
103
  const measured = measureTextarea(node, collapse);
104
104
  if (measured > 0) latest.current.onMeasure(measured);
105
105
  }, [enabled, ref, text, minHeight]);
106
+
107
+ useLayoutEffect(() => {
108
+ if (!enabled || typeof ResizeObserver === 'undefined') return;
109
+ const node = ref.current as unknown as HTMLTextAreaElement | null;
110
+ if (!node) return;
111
+ let previousWidth: number | undefined;
112
+ const observer = new ResizeObserver(entries => {
113
+ const width = entries[0]?.contentRect.width;
114
+ // Height changes are our own output. Never feed those back into measurement.
115
+ if (!width || width === previousWidth) return;
116
+ previousWidth = width;
117
+ const current = latest.current;
118
+ const measured = measureTextarea(node, current.height > current.minHeight);
119
+ if (measured > 0) current.onMeasure(measured);
120
+ });
121
+ // The first delivery also repairs a measurement made before initial layout
122
+ // (for example a fixed footer whose column bounds arrive after mount).
123
+ observer.observe(node);
124
+ return () => observer.disconnect();
125
+ }, [enabled, ref]);
106
126
  }
@@ -25,6 +25,7 @@ import Animated, {
25
25
  import { Badge } from '../badge';
26
26
  import { CloseButton } from '../button';
27
27
  import { useControllableState } from '../hooks/use-controllable-state';
28
+ import { useBrowserTitle } from '../hooks/use-browser-title';
28
29
  import { useInteractionState } from '../hooks/use-interaction-state';
29
30
  import { useDirectionProps, useIsRtl } from '../hooks/use-is-rtl';
30
31
  import { RiCloseLine } from '../icons/remix/RiCloseLine';
@@ -251,6 +252,7 @@ const SidebarPanel: React.FC<SidebarProps> = ({
251
252
  const [suppressUserHover, setSuppressUserHover] = useState(false);
252
253
  const searchFieldRef = useRef<View>(null);
253
254
  const searchTriggerRef = useRef<View>(null);
255
+ const searchTooltipRef = useBrowserTitle<View>(collapsed ? searchLabel : undefined, searchTriggerRef);
254
256
  const searchInputRef = useRef<TextInput>(null);
255
257
  const normalized = query.trim().toLocaleLowerCase();
256
258
  const searchHover = useInteractionState();
@@ -484,7 +486,7 @@ const SidebarPanel: React.FC<SidebarProps> = ({
484
486
  }}
485
487
  >
486
488
  <Pressable
487
- ref={searchTriggerRef}
489
+ ref={searchTooltipRef}
488
490
  {...(IS_WEB ? { dataSet: { bloomSidebar: 'ring' } } : {})}
489
491
  role="button"
490
492
  accessibilityLabel={searchButtonLabel}
@@ -566,8 +568,8 @@ const SidebarPanel: React.FC<SidebarProps> = ({
566
568
  </View>
567
569
  ) : (
568
570
  <AnimatedPressable
569
- ref={searchTriggerRef}
570
- {...(IS_WEB ? { dataSet: { bloomSidebar: 'ring' }, ...(collapsed ? { title: searchLabel } : null) } : {})}
571
+ ref={searchTooltipRef}
572
+ {...(IS_WEB ? { dataSet: { bloomSidebar: 'ring' } } : {})}
571
573
  role="button"
572
574
  accessibilityLabel={searchLabel}
573
575
  onPress={activateSearch}
@@ -3,6 +3,7 @@ import { View, type GestureResponderEvent } from 'react-native';
3
3
  import { StyledPressable } from '../styles/styled-primitives';
4
4
  import Animated, { useAnimatedStyle } from 'react-native-reanimated';
5
5
 
6
+ import { useBrowserTitle } from '../hooks/use-browser-title';
6
7
  import { useInteractionState } from '../hooks/use-interaction-state';
7
8
  import type { WebCssStyle } from '../styles/web-view-style';
8
9
  import { Text } from '../typography';
@@ -59,6 +60,7 @@ const SidebarItemComponent: React.FC<SidebarItemProps> = ({
59
60
  testID,
60
61
  }) => {
61
62
  const palette = useSidebarPalette();
63
+ const tooltipRef = useBrowserTitle<View>(collapsed ? label : undefined, ref);
62
64
  const metrics = useSidebarMetrics(size);
63
65
  useSidebarWebCss();
64
66
  const { state: hovered, onIn, onOut } = useInteractionState();
@@ -106,14 +108,13 @@ const SidebarItemComponent: React.FC<SidebarItemProps> = ({
106
108
  dataSet: { bloomSidebar: 'ring' },
107
109
  ...(href ? { href } : null),
108
110
  ...(selected ? { 'aria-current': 'page' } : null),
109
- ...(collapsed ? { title: label } : null),
110
111
  }
111
112
  : {};
112
113
 
113
114
  return (
114
115
  <AnimatedPressable
115
116
  {...webProps}
116
- ref={ref}
117
+ ref={tooltipRef}
117
118
  className={className}
118
119
  disabled={disabled}
119
120
  nativeID={nativeID}
@@ -1,5 +1,5 @@
1
1
  import React, { memo, useEffect } from 'react';
2
- import { Pressable } from 'react-native';
2
+ import { Pressable, type View } from 'react-native';
3
3
  import Animated, {
4
4
  Easing,
5
5
  useAnimatedStyle,
@@ -10,6 +10,7 @@ import Animated, {
10
10
  } from 'react-native-reanimated';
11
11
 
12
12
  import { SEGMENTED_THUMB_EASE_BEZIER, SEGMENTED_THUMB_MS } from '../button/shared';
13
+ import { useBrowserTitle } from '../hooks/use-browser-title';
13
14
  import { useInteractionState } from '../hooks/use-interaction-state';
14
15
  import { borderRadius } from '../styles/tokens';
15
16
  import type { WebCssStyle } from '../styles/web-view-style';
@@ -68,6 +69,7 @@ function ModeRow({
68
69
  testID?: string;
69
70
  }) {
70
71
  const palette = useSidebarPalette();
72
+ const tooltipRef = useBrowserTitle<View>(collapsed ? mode.label : undefined);
71
73
  const { state: hovered, onIn, onOut } = useInteractionState();
72
74
  const Icon = mode.icon;
73
75
  const foreground = selected ? palette.text : palette.textSecondary;
@@ -96,7 +98,7 @@ function ModeRow({
96
98
  return (
97
99
  <AnimatedPressable
98
100
  {...webHook('ring')}
99
- {...(IS_WEB && collapsed ? { title: mode.label } : null)}
101
+ ref={tooltipRef}
100
102
  role="radio"
101
103
  aria-checked={selected}
102
104
  accessibilityState={{ checked: selected }}
@@ -30,6 +30,9 @@ export const SIDEBAR_RAIL_WIDTH = 80;
30
30
  */
31
31
  export function SidebarRail({
32
32
  logo,
33
+ railLabels = 'visible',
34
+ railSelection = 'pill',
35
+ railWidth = SIDEBAR_RAIL_WIDTH,
33
36
  items = [],
34
37
  primaryAction,
35
38
  contentAlignment = 'start',
@@ -57,6 +60,8 @@ export function SidebarRail({
57
60
  icon={item.icon}
58
61
  activeIcon={item.activeIcon}
59
62
  label={item.label}
63
+ labelVisibility={railLabels}
64
+ selectedAppearance={railSelection}
60
65
  href={item.href}
61
66
  selected={isSelected}
62
67
  onPress={onPress}
@@ -83,7 +88,7 @@ export function SidebarRail({
83
88
  testID={testID}
84
89
  style={[
85
90
  {
86
- width: SIDEBAR_RAIL_WIDTH,
91
+ width: Number.isFinite(railWidth) ? Math.max(64, railWidth) : SIDEBAR_RAIL_WIDTH,
87
92
  height: '100%',
88
93
  flexShrink: 0,
89
94
  flexDirection: 'column',
@@ -2,6 +2,7 @@ import React, { memo, useEffect } from 'react';
2
2
  import Animated, { Easing, interpolateColor, useAnimatedStyle, useReducedMotion, useSharedValue, withTiming } from 'react-native-reanimated';
3
3
  import { Pressable, View, type GestureResponderEvent } from 'react-native';
4
4
 
5
+ import { useBrowserTitle } from '../hooks/use-browser-title';
5
6
  import { useInteractionState } from '../hooks/use-interaction-state';
6
7
  import { borderRadius } from '../styles/tokens';
7
8
  import type { WebCssStyle } from '../styles/web-view-style';
@@ -34,6 +35,8 @@ const SidebarRailItemComponent: React.FC<SidebarRailItemProps> = ({
34
35
  icon: Icon,
35
36
  activeIcon: ActiveIcon,
36
37
  label,
38
+ labelVisibility = 'visible',
39
+ selectedAppearance = 'pill',
37
40
  href,
38
41
  badge,
39
42
  selected = false,
@@ -46,12 +49,15 @@ const SidebarRailItemComponent: React.FC<SidebarRailItemProps> = ({
46
49
  useSidebarWebCss();
47
50
  const { state: hovered, onIn, onOut } = useInteractionState();
48
51
  const SelectedGlyph = ActiveIcon ?? Icon;
52
+ const iconOnly = labelVisibility === 'hidden';
53
+ const tooltipRef = useBrowserTitle<View>(iconOnly ? label : undefined);
54
+ const selectedFill = selectedAppearance === 'icon' ? (hovered ? palette.rowHover : 'transparent') : palette.selected;
49
55
  const reducedMotion = useReducedMotion();
50
56
  const selection = useSharedValue(selected ? 1 : 0);
51
57
  useEffect(() => {
52
58
  selection.value = reducedMotion ? (selected ? 1 : 0) : withTiming(selected ? 1 : 0, { duration: SELECTION_DURATION, easing: Easing.bezier(0.2, 0, 0, 1) });
53
59
  }, [selected, reducedMotion, selection]);
54
- const indicatorStyle = useAnimatedStyle(() => ({ backgroundColor: interpolateColor(selection.value, [0, 1], [hovered ? palette.rowHover : 'transparent', palette.selected]) }), [selection, hovered, palette.rowHover, palette.selected]);
60
+ const indicatorStyle = useAnimatedStyle(() => ({ backgroundColor: interpolateColor(selection.value, [0, 1], [hovered ? palette.rowHover : 'transparent', selectedFill]) }), [selection, hovered, palette.rowHover, selectedFill]);
55
61
  const inactiveStyle = useAnimatedStyle(() => ({ opacity: 1 - selection.value }), [selection]);
56
62
  const activeStyle = useAnimatedStyle(() => ({ opacity: selection.value }), [selection]);
57
63
  const labelStyle = useAnimatedStyle(() => ({ color: interpolateColor(selection.value, [0, 1], [palette.textSecondary, palette.text]) }), [selection, palette.textSecondary, palette.text]);
@@ -66,6 +72,7 @@ const SidebarRailItemComponent: React.FC<SidebarRailItemProps> = ({
66
72
 
67
73
  return (
68
74
  <Pressable
75
+ ref={tooltipRef}
69
76
  {...webProps}
70
77
  role={href ? 'link' : 'button'}
71
78
  accessibilityLabel={label}
@@ -81,7 +88,7 @@ const SidebarRailItemComponent: React.FC<SidebarRailItemProps> = ({
81
88
  style={[
82
89
  {
83
90
  alignSelf: 'stretch',
84
- minHeight: 64,
91
+ minHeight: iconOnly ? 48 : 64,
85
92
  alignItems: 'center',
86
93
  justifyContent: 'center',
87
94
  gap: 5,
@@ -108,7 +115,7 @@ const SidebarRailItemComponent: React.FC<SidebarRailItemProps> = ({
108
115
  <Icon width={ICON_SIZE} height={ICON_SIZE} fill={palette.textSecondary} />
109
116
  </Animated.View>
110
117
  <Animated.View testID={testID ? `${testID}-active-glyph` : undefined} pointerEvents="none" aria-hidden accessibilityElementsHidden style={[{ position: 'absolute', width: ICON_SIZE, height: ICON_SIZE }, activeStyle]}>
111
- <SelectedGlyph width={ICON_SIZE} height={ICON_SIZE} fill={palette.selectedForeground} />
118
+ <SelectedGlyph width={ICON_SIZE} height={ICON_SIZE} fill={selectedAppearance === 'icon' ? palette.text : palette.selectedForeground} />
112
119
  </Animated.View>
113
120
  {badge != null ? (
114
121
  <View pointerEvents="none" style={{ position: 'absolute', top: -6, insetInlineStart: INDICATOR_WIDTH - 16 }}>
@@ -116,7 +123,7 @@ const SidebarRailItemComponent: React.FC<SidebarRailItemProps> = ({
116
123
  </View>
117
124
  ) : null}
118
125
  </Animated.View>
119
- <AnimatedText
126
+ {!iconOnly ? <AnimatedText
120
127
  variant="caption-2-regular"
121
128
  numberOfLines={1}
122
129
  style={[{
@@ -129,7 +136,7 @@ const SidebarRailItemComponent: React.FC<SidebarRailItemProps> = ({
129
136
  }, labelStyle]}
130
137
  >
131
138
  {label}
132
- </AnimatedText>
139
+ </AnimatedText> : null}
133
140
  </Pressable>
134
141
  );
135
142
  };
@@ -123,6 +123,10 @@ export interface SidebarToolbarProps {
123
123
  }
124
124
 
125
125
  export interface SidebarRailItemProps {
126
+ /** Keep the accessible name while hiding the visual caption. Default visible. */
127
+ labelVisibility?: 'visible' | 'hidden';
128
+ /** Selected pill, or emphasis on the glyph alone. Default pill. */
129
+ selectedAppearance?: 'pill' | 'icon';
126
130
  icon: SidebarIcon;
127
131
  /** The glyph while selected (e.g. the filled icon); defaults to `icon`. */
128
132
  activeIcon?: SidebarIcon;
@@ -311,6 +315,12 @@ export interface SidebarProps {
311
315
  };
312
316
  /** Defaults to `panel`. */
313
317
  variant?: SidebarVariant;
318
+ /** Rail captions; hidden retains accessible names and native browser tooltips. */
319
+ railLabels?: 'visible' | 'hidden';
320
+ /** Rail selection uses an accent pill by default, or only an emphasized icon. */
321
+ railSelection?: 'pill' | 'icon';
322
+ /** Rail width, owned by the navigation layout. Default 80, minimum 64. */
323
+ railWidth?: number;
314
324
  /** Primary navigation rows. */
315
325
  items?: SidebarNavItem[];
316
326
  /**