@oxy.so/bloom 7.7.0 → 7.8.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 (122) hide show
  1. package/docs/admonition.mdx +12 -3
  2. package/docs/adoption-matrix.mdx +3 -3
  3. package/docs/app-shell.mdx +34 -0
  4. package/docs/chat-composer.mdx +12 -0
  5. package/docs/motion.mdx +11 -0
  6. package/docs/page-footer.mdx +16 -2
  7. package/lib/commonjs/admonition/Admonition.js +53 -31
  8. package/lib/commonjs/admonition/Admonition.js.map +1 -1
  9. package/lib/commonjs/app-shell/AppShellSplit.js +52 -38
  10. package/lib/commonjs/app-shell/AppShellSplit.js.map +1 -1
  11. package/lib/commonjs/app-shell/AppShellSplitMotion.js +199 -0
  12. package/lib/commonjs/app-shell/AppShellSplitMotion.js.map +1 -0
  13. package/lib/commonjs/app-shell/SplitPane.js +47 -0
  14. package/lib/commonjs/app-shell/SplitPane.js.map +1 -0
  15. package/lib/commonjs/app-shell/context.js +9 -1
  16. package/lib/commonjs/app-shell/context.js.map +1 -1
  17. package/lib/commonjs/app-shell/index.js +6 -0
  18. package/lib/commonjs/app-shell/index.js.map +1 -1
  19. package/lib/commonjs/app-shell/index.web.js +6 -0
  20. package/lib/commonjs/app-shell/index.web.js.map +1 -1
  21. package/lib/commonjs/chat-composer/create-chat-composer.js +8 -6
  22. package/lib/commonjs/chat-composer/create-chat-composer.js.map +1 -1
  23. package/lib/commonjs/chat-composer/create-suggestion-list.js +7 -0
  24. package/lib/commonjs/chat-composer/create-suggestion-list.js.map +1 -1
  25. package/lib/commonjs/hooks/use-prefers-reduced-motion.js +28 -0
  26. package/lib/commonjs/hooks/use-prefers-reduced-motion.js.map +1 -0
  27. package/lib/commonjs/page-footer/PageFooter.js +50 -36
  28. package/lib/commonjs/page-footer/PageFooter.js.map +1 -1
  29. package/lib/commonjs/page-footer/use-document-anchor.js +68 -0
  30. package/lib/commonjs/page-footer/use-document-anchor.js.map +1 -0
  31. package/lib/module/admonition/Admonition.js +53 -31
  32. package/lib/module/admonition/Admonition.js.map +1 -1
  33. package/lib/module/app-shell/AppShellSplit.js +50 -38
  34. package/lib/module/app-shell/AppShellSplit.js.map +1 -1
  35. package/lib/module/app-shell/AppShellSplitMotion.js +194 -0
  36. package/lib/module/app-shell/AppShellSplitMotion.js.map +1 -0
  37. package/lib/module/app-shell/SplitPane.js +42 -0
  38. package/lib/module/app-shell/SplitPane.js.map +1 -0
  39. package/lib/module/app-shell/context.js +7 -0
  40. package/lib/module/app-shell/context.js.map +1 -1
  41. package/lib/module/app-shell/index.js +1 -1
  42. package/lib/module/app-shell/index.js.map +1 -1
  43. package/lib/module/app-shell/index.web.js +1 -1
  44. package/lib/module/app-shell/index.web.js.map +1 -1
  45. package/lib/module/chat-composer/create-chat-composer.js +8 -6
  46. package/lib/module/chat-composer/create-chat-composer.js.map +1 -1
  47. package/lib/module/chat-composer/create-suggestion-list.js +7 -0
  48. package/lib/module/chat-composer/create-suggestion-list.js.map +1 -1
  49. package/lib/module/hooks/use-prefers-reduced-motion.js +25 -0
  50. package/lib/module/hooks/use-prefers-reduced-motion.js.map +1 -0
  51. package/lib/module/page-footer/PageFooter.js +51 -37
  52. package/lib/module/page-footer/PageFooter.js.map +1 -1
  53. package/lib/module/page-footer/use-document-anchor.js +65 -0
  54. package/lib/module/page-footer/use-document-anchor.js.map +1 -0
  55. package/lib/typescript/commonjs/admonition/Admonition.d.ts.map +1 -1
  56. package/lib/typescript/commonjs/app-shell/AppShellSplit.d.ts.map +1 -1
  57. package/lib/typescript/commonjs/app-shell/AppShellSplitMotion.d.ts +16 -0
  58. package/lib/typescript/commonjs/app-shell/AppShellSplitMotion.d.ts.map +1 -0
  59. package/lib/typescript/commonjs/app-shell/SplitPane.d.ts +12 -0
  60. package/lib/typescript/commonjs/app-shell/SplitPane.d.ts.map +1 -0
  61. package/lib/typescript/commonjs/app-shell/context.d.ts +4 -0
  62. package/lib/typescript/commonjs/app-shell/context.d.ts.map +1 -1
  63. package/lib/typescript/commonjs/app-shell/index.d.ts +1 -1
  64. package/lib/typescript/commonjs/app-shell/index.d.ts.map +1 -1
  65. package/lib/typescript/commonjs/app-shell/index.web.d.ts +1 -1
  66. package/lib/typescript/commonjs/app-shell/index.web.d.ts.map +1 -1
  67. package/lib/typescript/commonjs/app-shell/types.d.ts +8 -0
  68. package/lib/typescript/commonjs/app-shell/types.d.ts.map +1 -1
  69. package/lib/typescript/commonjs/chat-composer/create-chat-composer.d.ts.map +1 -1
  70. package/lib/typescript/commonjs/chat-composer/create-suggestion-list.d.ts.map +1 -1
  71. package/lib/typescript/commonjs/chat-composer/types.d.ts +2 -1
  72. package/lib/typescript/commonjs/chat-composer/types.d.ts.map +1 -1
  73. package/lib/typescript/commonjs/hooks/use-prefers-reduced-motion.d.ts +3 -0
  74. package/lib/typescript/commonjs/hooks/use-prefers-reduced-motion.d.ts.map +1 -0
  75. package/lib/typescript/commonjs/page-footer/PageFooter.d.ts +1 -1
  76. package/lib/typescript/commonjs/page-footer/PageFooter.d.ts.map +1 -1
  77. package/lib/typescript/commonjs/page-footer/types.d.ts +4 -0
  78. package/lib/typescript/commonjs/page-footer/types.d.ts.map +1 -1
  79. package/lib/typescript/commonjs/page-footer/use-document-anchor.d.ts +9 -0
  80. package/lib/typescript/commonjs/page-footer/use-document-anchor.d.ts.map +1 -0
  81. package/lib/typescript/module/admonition/Admonition.d.ts.map +1 -1
  82. package/lib/typescript/module/app-shell/AppShellSplit.d.ts.map +1 -1
  83. package/lib/typescript/module/app-shell/AppShellSplitMotion.d.ts +16 -0
  84. package/lib/typescript/module/app-shell/AppShellSplitMotion.d.ts.map +1 -0
  85. package/lib/typescript/module/app-shell/SplitPane.d.ts +12 -0
  86. package/lib/typescript/module/app-shell/SplitPane.d.ts.map +1 -0
  87. package/lib/typescript/module/app-shell/context.d.ts +4 -0
  88. package/lib/typescript/module/app-shell/context.d.ts.map +1 -1
  89. package/lib/typescript/module/app-shell/index.d.ts +1 -1
  90. package/lib/typescript/module/app-shell/index.d.ts.map +1 -1
  91. package/lib/typescript/module/app-shell/index.web.d.ts +1 -1
  92. package/lib/typescript/module/app-shell/index.web.d.ts.map +1 -1
  93. package/lib/typescript/module/app-shell/types.d.ts +8 -0
  94. package/lib/typescript/module/app-shell/types.d.ts.map +1 -1
  95. package/lib/typescript/module/chat-composer/create-chat-composer.d.ts.map +1 -1
  96. package/lib/typescript/module/chat-composer/create-suggestion-list.d.ts.map +1 -1
  97. package/lib/typescript/module/chat-composer/types.d.ts +2 -1
  98. package/lib/typescript/module/chat-composer/types.d.ts.map +1 -1
  99. package/lib/typescript/module/hooks/use-prefers-reduced-motion.d.ts +3 -0
  100. package/lib/typescript/module/hooks/use-prefers-reduced-motion.d.ts.map +1 -0
  101. package/lib/typescript/module/page-footer/PageFooter.d.ts +1 -1
  102. package/lib/typescript/module/page-footer/PageFooter.d.ts.map +1 -1
  103. package/lib/typescript/module/page-footer/types.d.ts +4 -0
  104. package/lib/typescript/module/page-footer/types.d.ts.map +1 -1
  105. package/lib/typescript/module/page-footer/use-document-anchor.d.ts +9 -0
  106. package/lib/typescript/module/page-footer/use-document-anchor.d.ts.map +1 -0
  107. package/package.json +1 -1
  108. package/src/admonition/Admonition.tsx +49 -28
  109. package/src/app-shell/AppShellSplit.tsx +24 -29
  110. package/src/app-shell/AppShellSplitMotion.tsx +133 -0
  111. package/src/app-shell/SplitPane.tsx +30 -0
  112. package/src/app-shell/context.ts +7 -0
  113. package/src/app-shell/index.ts +1 -1
  114. package/src/app-shell/index.web.ts +1 -1
  115. package/src/app-shell/types.ts +8 -0
  116. package/src/chat-composer/create-chat-composer.tsx +8 -6
  117. package/src/chat-composer/create-suggestion-list.tsx +8 -1
  118. package/src/chat-composer/types.ts +2 -1
  119. package/src/hooks/use-prefers-reduced-motion.ts +22 -0
  120. package/src/page-footer/PageFooter.tsx +13 -2
  121. package/src/page-footer/types.ts +4 -0
  122. package/src/page-footer/use-document-anchor.ts +52 -0
@@ -7,7 +7,7 @@ export const AppShell = createAppShell(BottomBar, Fab, ContentPanel, BloomColorS
7
7
  export { AppShellHeader } from './AppShellHeader';
8
8
  export { AppShellMenuButton } from './AppShellMenuButton';
9
9
  export { APP_SHELL_DEFAULTS } from './constants';
10
- export { useAppShell } from './context';
10
+ export { useAppShell, useAppShellPaneActive } from './context';
11
11
  export type { AppShellContextValue } from './context';
12
12
  export { NotificationBell } from './NotificationBell';
13
13
  export { ProOfferCard } from './ProOfferCard';
@@ -12,7 +12,7 @@ export const AppShell = createAppShell(BottomBar, Fab, ContentPanel, BloomColorS
12
12
  export { AppShellHeader } from './AppShellHeader';
13
13
  export { AppShellMenuButton } from './AppShellMenuButton';
14
14
  export { APP_SHELL_DEFAULTS } from './constants';
15
- export { useAppShell } from './context';
15
+ export { useAppShell, useAppShellPaneActive } from './context';
16
16
  export type { AppShellContextValue } from './context';
17
17
  export { NotificationBell } from './NotificationBell';
18
18
  export { ProOfferCard } from './ProOfferCard';
@@ -394,6 +394,14 @@ export interface AppShellSplitPanesProps {
394
394
  infoErrorBoundary?: false | PanelErrorBoundaryOptions;
395
395
  /** Joined uses hairline dividers (default); separated leaves a 12px gutter for independent panel surfaces. */
396
396
  variant?: 'joined' | 'separated';
397
+ /**
398
+ * Animate list/detail visibility using live layout geometry. Defaults to none.
399
+ * Showing both panes reveals detail beside a shrinking list; hiding the list
400
+ * slides between full-width panes. Exiting content remains mounted until the
401
+ * expansion motion settles, but is immediately inactive/inaccessible.
402
+ * Info visibility is unchanged. Respects the system reduced-motion setting.
403
+ */
404
+ transition?: 'none' | 'slide';
397
405
  list?: ReactNode;
398
406
  detail?: ReactNode;
399
407
  info?: ReactNode;
@@ -210,13 +210,15 @@ export function createChatComposer({ ComposerAttachmentStrip, ComposerIconButton
210
210
 
211
211
  const trimmed = text.trim();
212
212
  const hasAttachments = !!attachments && attachments.length > 0;
213
- const showSend = canSend ?? (trimmed.length > 0 || hasAttachments);
213
+ const sendEnabled = canSend ?? (trimmed.length > 0 || hasAttachments);
214
+ const hasMic = !!(onMicPress || onMicPressIn || onMicPressOut);
215
+ const showSend = sendEnabled || !hasMic;
214
216
 
215
217
  const submit = useCallback(() => {
216
- if (disabled || !showSend) return;
218
+ if (disabled || !sendEnabled) return;
217
219
  onSend?.(text);
218
220
  if (value === undefined) setText('');
219
- }, [disabled, showSend, onSend, text, value, setText]);
221
+ }, [disabled, sendEnabled, onSend, text, value, setText]);
220
222
 
221
223
  const openSuggestions = !!suggestions && suggestions.length > 0;
222
224
 
@@ -436,12 +438,12 @@ export function createChatComposer({ ComposerAttachmentStrip, ComposerIconButton
436
438
  tone="accent"
437
439
  accessibilityLabel={labels.send}
438
440
  onPress={submit}
439
- disabled={disabled}
441
+ disabled={disabled || !sendEnabled}
440
442
  iconSize={18}
441
443
  testID={testID ? `${testID}-send` : undefined}
442
444
  />
443
445
  </SwapLayer>
444
- <SwapLayer shown={!showSend}>
446
+ {hasMic ? <SwapLayer shown={!showSend}>
445
447
  <ComposerIconButton
446
448
  icon={RiMic2Line}
447
449
  accessibilityLabel={labels.mic}
@@ -451,7 +453,7 @@ export function createChatComposer({ ComposerAttachmentStrip, ComposerIconButton
451
453
  disabled={disabled}
452
454
  testID={testID ? `${testID}-mic` : undefined}
453
455
  />
454
- </SwapLayer>
456
+ </SwapLayer> : null}
455
457
  </View>
456
458
  </>
457
459
  )}
@@ -184,7 +184,14 @@ export function createSuggestionList({ Surface, Loading }: {
184
184
  {...listRole}
185
185
  accessibilityLabel={accessibilityLabel ?? messages.suggestions[kind]}
186
186
  style={{ maxHeight }}
187
- showsVerticalScrollIndicator={false}>
187
+ showsVerticalScrollIndicator={false}
188
+ keyboardShouldPersistTaps="handled"
189
+ {...(IS_WEB ? {
190
+ // Options belong to the input: mouse selection must not blur it
191
+ // before the ensuing click can choose a row. Touch scrolling is
192
+ // unaffected because its pointer default is not cancelled.
193
+ onMouseDown: (event: React.MouseEvent) => event.preventDefault(),
194
+ } : {})}>
188
195
  {suggestions.map((suggestion, index) => {
189
196
  const active = index === activeIndex;
190
197
  const row: WebCssStyle = {
@@ -164,7 +164,8 @@ export interface ChatComposerProps extends PartProps {
164
164
  onEmojiPress?: () => void;
165
165
  /** Draws a camera button between the field and the emoji button. */
166
166
  onCameraPress?: () => void;
167
- /** The mic, shown whenever the draft is empty and there are no attachments. */
167
+ /** The mic, shown for an empty draft only when a mic callback is provided.
168
+ * Without recording callbacks, the empty composer shows a disabled send button. */
168
169
  onMicPress?: () => void;
169
170
  /** Press-and-hold on the mic (native). Both fire on web too. */
170
171
  onMicPressIn?: () => void;
@@ -0,0 +1,22 @@
1
+ import { useEffect, useState } from 'react';
2
+ import { AccessibilityInfo, Platform } from 'react-native';
3
+ import { useReducedMotion } from 'react-native-reanimated';
4
+
5
+ /** Reanimated supplies the launch value; OS changes must also settle live motion. */
6
+ export function usePrefersReducedMotion(): boolean {
7
+ const initial = useReducedMotion();
8
+ const [reduced, setReduced] = useState(initial);
9
+ useEffect(() => {
10
+ if (Platform.OS === 'web') {
11
+ if (typeof window === 'undefined' || !window.matchMedia) return;
12
+ const media = window.matchMedia('(prefers-reduced-motion: reduce)');
13
+ const update = () => setReduced(media.matches);
14
+ update();
15
+ media.addEventListener('change', update);
16
+ return () => media.removeEventListener('change', update);
17
+ }
18
+ const subscription = AccessibilityInfo.addEventListener('reduceMotionChanged', setReduced);
19
+ return () => subscription.remove();
20
+ }, []);
21
+ return reduced;
22
+ }
@@ -12,14 +12,16 @@ import { Z_INDEX } from '../styles/z-index';
12
12
  import { useTheme } from '../theme/use-theme';
13
13
  import { PageFooterContext } from './context';
14
14
  import type { PageFooterProps } from './types';
15
+ import { useDocumentAnchor } from './use-document-anchor';
15
16
 
16
17
  const BAR_HEIGHT = 56;
17
18
 
18
19
  /** Page-local controls floating over a bounded scroller, above app navigation. */
19
20
  function PageFooterComponent({
20
- children, actions, bottomInset, safeArea, scrim = 'always', scrimColor, scrollThreshold = 20, style, testID,
21
+ children, actions, bottomInset, safeArea, position = 'absolute', scrim = 'always', scrimColor, scrollThreshold = 20, style, testID,
21
22
  }: PageFooterProps) {
22
23
  const theme = useTheme();
24
+ const documentAnchor = useDocumentAnchor(position === 'document');
23
25
  const metrics = useScrollMetricsValue();
24
26
  const threshold = Math.max(1, Number.isFinite(scrollThreshold) ? scrollThreshold : 20);
25
27
  const scrimStyle = useAnimatedStyle(() => ({
@@ -52,10 +54,18 @@ function PageFooterComponent({
52
54
  };
53
55
 
54
56
  return (
57
+ <>
58
+ {documentAnchor.enabled ? <View
59
+ ref={documentAnchor.ref}
60
+ onLayout={documentAnchor.measure}
61
+ pointerEvents="none"
62
+ style={{ height: 0, width: '100%' }}
63
+ testID={testID ? `${testID}-anchor` : undefined}
64
+ /> : null}
55
65
  <View
56
66
  testID={testID}
57
67
  pointerEvents="box-none"
58
- style={[styles.container, { bottom, paddingBottom: padBottom }, style]}
68
+ style={[styles.container, { bottom, paddingBottom: padBottom }, documentAnchor.style, style]}
59
69
  >
60
70
  {scrim !== 'none' ? (
61
71
  <Animated.View
@@ -82,6 +92,7 @@ function PageFooterComponent({
82
92
  </BloomScope>
83
93
  </View>
84
94
  </View>
95
+ </>
85
96
  );
86
97
  }
87
98
 
@@ -2,6 +2,10 @@ import type { ReactNode } from 'react';
2
2
  import type { StyleProp, ViewStyle } from 'react-native';
3
3
 
4
4
  export interface PageFooterProps {
5
+ /** Absolute inside a bounded frame (default), or pinned to the document
6
+ * viewport while aligned to this footer's in-flow column on web. Native
7
+ * always uses absolute positioning inside its bounded frame. */
8
+ position?: 'absolute' | 'document';
5
9
  /** Optional content before the actions, for example a selection summary. */
6
10
  children?: ReactNode;
7
11
  /** Controls grouped by the caller; inherits the surrounding Bloom size. */
@@ -0,0 +1,52 @@
1
+ import { useCallback, useLayoutEffect, useRef, useState } from 'react';
2
+ import { Platform, type View, type ViewStyle } from 'react-native';
3
+ import { WEB_POSITION_FIXED } from '../styles/web-view-style';
4
+
5
+ /** A document footer follows its column without owning the page's scroller. */
6
+ export function useDocumentAnchor(documentPosition: boolean) {
7
+ const enabled = documentPosition && Platform.OS === 'web';
8
+ const ref = useRef<View>(null);
9
+ const [bounds, setBounds] = useState<{ left: number; width: number } | null>(null);
10
+ const measure = useCallback(() => {
11
+ const node: unknown = ref.current;
12
+ if (!enabled || typeof HTMLElement === 'undefined' || !(node instanceof HTMLElement)) return;
13
+ const rect = node.getBoundingClientRect();
14
+ if (!Number.isFinite(rect.left) || !Number.isFinite(rect.width)) return;
15
+ setBounds(previous => previous?.left === rect.left && previous.width === rect.width
16
+ ? previous : { left: rect.left, width: rect.width });
17
+ }, [enabled]);
18
+
19
+ useLayoutEffect(() => {
20
+ const node: unknown = ref.current;
21
+ if (!enabled || typeof HTMLElement === 'undefined' || !(node instanceof HTMLElement)) return;
22
+ measure();
23
+ // A sibling rail can change this column's offset without changing its
24
+ // width. Observe the ancestor frames as well as the anchor itself.
25
+ const observer = typeof ResizeObserver === 'undefined' ? null : new ResizeObserver(measure);
26
+ // Direction/class changes may move a column without resizing any frame.
27
+ const attributes = typeof MutationObserver === 'undefined' ? null : new MutationObserver(measure);
28
+ for (let current: HTMLElement | null = node; current; current = current.parentElement) {
29
+ observer?.observe(current);
30
+ attributes?.observe(current, { attributes: true, attributeFilter: ['dir', 'class', 'style'] });
31
+ }
32
+ window.addEventListener('resize', measure);
33
+ // Horizontal document scrolling changes the viewport coordinate. Equality
34
+ // above prevents ordinary vertical scrolling from scheduling a React render.
35
+ window.addEventListener('scroll', measure, { passive: true });
36
+ return () => {
37
+ observer?.disconnect();
38
+ attributes?.disconnect();
39
+ window.removeEventListener('resize', measure);
40
+ window.removeEventListener('scroll', measure);
41
+ };
42
+ }, [enabled, measure]);
43
+
44
+ const style: ViewStyle | undefined = enabled ? {
45
+ position: WEB_POSITION_FIXED,
46
+ left: bounds?.left ?? 0,
47
+ right: undefined,
48
+ width: bounds?.width ?? 0,
49
+ opacity: bounds ? 1 : 0,
50
+ } : undefined;
51
+ return { enabled, ref, measure, style };
52
+ }