@oxy.so/bloom 7.7.1 → 7.9.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.
- package/docs/adoption-matrix.mdx +2 -2
- package/docs/ai-chat.mdx +26 -0
- package/docs/app-shell.mdx +34 -0
- package/docs/chat-composer.mdx +20 -0
- package/docs/motion.mdx +11 -0
- package/docs/page-footer.mdx +16 -2
- package/docs/sidebar.mdx +15 -0
- package/lib/commonjs/ai-chat/AiChatMessages.js +8 -3
- package/lib/commonjs/ai-chat/AiChatMessages.js.map +1 -1
- package/lib/commonjs/app-shell/AppShellSplit.js +52 -38
- package/lib/commonjs/app-shell/AppShellSplit.js.map +1 -1
- package/lib/commonjs/app-shell/AppShellSplitMotion.js +199 -0
- package/lib/commonjs/app-shell/AppShellSplitMotion.js.map +1 -0
- package/lib/commonjs/app-shell/SplitPane.js +47 -0
- package/lib/commonjs/app-shell/SplitPane.js.map +1 -0
- package/lib/commonjs/app-shell/context.js +9 -1
- package/lib/commonjs/app-shell/context.js.map +1 -1
- package/lib/commonjs/app-shell/index.js +6 -0
- package/lib/commonjs/app-shell/index.js.map +1 -1
- package/lib/commonjs/app-shell/index.web.js +6 -0
- package/lib/commonjs/app-shell/index.web.js.map +1 -1
- package/lib/commonjs/chat-composer/create-chat-composer.js +15 -10
- package/lib/commonjs/chat-composer/create-chat-composer.js.map +1 -1
- package/lib/commonjs/chat-composer/create-suggestion-list.js +7 -0
- package/lib/commonjs/chat-composer/create-suggestion-list.js.map +1 -1
- package/lib/commonjs/hooks/use-browser-title.js +17 -0
- package/lib/commonjs/hooks/use-browser-title.js.map +1 -0
- package/lib/commonjs/hooks/use-prefers-reduced-motion.js +28 -0
- package/lib/commonjs/hooks/use-prefers-reduced-motion.js.map +1 -0
- package/lib/commonjs/page-footer/PageFooter.js +50 -36
- package/lib/commonjs/page-footer/PageFooter.js.map +1 -1
- package/lib/commonjs/page-footer/use-document-anchor.js +68 -0
- package/lib/commonjs/page-footer/use-document-anchor.js.map +1 -0
- package/lib/commonjs/sidebar/Sidebar.js +5 -6
- package/lib/commonjs/sidebar/Sidebar.js.map +1 -1
- package/lib/commonjs/sidebar/SidebarItem.js +3 -4
- package/lib/commonjs/sidebar/SidebarItem.js.map +1 -1
- package/lib/commonjs/sidebar/SidebarModeSwitcher.js +3 -3
- package/lib/commonjs/sidebar/SidebarModeSwitcher.js.map +1 -1
- package/lib/commonjs/sidebar/SidebarRail.js +6 -1
- package/lib/commonjs/sidebar/SidebarRail.js.map +1 -1
- package/lib/commonjs/sidebar/SidebarRailItem.js +13 -6
- package/lib/commonjs/sidebar/SidebarRailItem.js.map +1 -1
- package/lib/module/ai-chat/AiChatMessages.js +8 -3
- package/lib/module/ai-chat/AiChatMessages.js.map +1 -1
- package/lib/module/app-shell/AppShellSplit.js +50 -38
- package/lib/module/app-shell/AppShellSplit.js.map +1 -1
- package/lib/module/app-shell/AppShellSplitMotion.js +194 -0
- package/lib/module/app-shell/AppShellSplitMotion.js.map +1 -0
- package/lib/module/app-shell/SplitPane.js +42 -0
- package/lib/module/app-shell/SplitPane.js.map +1 -0
- package/lib/module/app-shell/context.js +7 -0
- package/lib/module/app-shell/context.js.map +1 -1
- package/lib/module/app-shell/index.js +1 -1
- package/lib/module/app-shell/index.js.map +1 -1
- package/lib/module/app-shell/index.web.js +1 -1
- package/lib/module/app-shell/index.web.js.map +1 -1
- package/lib/module/chat-composer/create-chat-composer.js +15 -10
- package/lib/module/chat-composer/create-chat-composer.js.map +1 -1
- package/lib/module/chat-composer/create-suggestion-list.js +7 -0
- package/lib/module/chat-composer/create-suggestion-list.js.map +1 -1
- package/lib/module/hooks/use-browser-title.js +14 -0
- package/lib/module/hooks/use-browser-title.js.map +1 -0
- package/lib/module/hooks/use-prefers-reduced-motion.js +25 -0
- package/lib/module/hooks/use-prefers-reduced-motion.js.map +1 -0
- package/lib/module/page-footer/PageFooter.js +51 -37
- package/lib/module/page-footer/PageFooter.js.map +1 -1
- package/lib/module/page-footer/use-document-anchor.js +65 -0
- package/lib/module/page-footer/use-document-anchor.js.map +1 -0
- package/lib/module/sidebar/Sidebar.js +5 -6
- package/lib/module/sidebar/Sidebar.js.map +1 -1
- package/lib/module/sidebar/SidebarItem.js +3 -4
- package/lib/module/sidebar/SidebarItem.js.map +1 -1
- package/lib/module/sidebar/SidebarModeSwitcher.js +3 -3
- package/lib/module/sidebar/SidebarModeSwitcher.js.map +1 -1
- package/lib/module/sidebar/SidebarRail.js +6 -1
- package/lib/module/sidebar/SidebarRail.js.map +1 -1
- package/lib/module/sidebar/SidebarRailItem.js +13 -6
- package/lib/module/sidebar/SidebarRailItem.js.map +1 -1
- package/lib/typescript/commonjs/ai-chat/AiChatMessages.d.ts +1 -1
- package/lib/typescript/commonjs/ai-chat/AiChatMessages.d.ts.map +1 -1
- package/lib/typescript/commonjs/ai-chat/types.d.ts +3 -0
- package/lib/typescript/commonjs/ai-chat/types.d.ts.map +1 -1
- package/lib/typescript/commonjs/app-shell/AppShellSplit.d.ts.map +1 -1
- package/lib/typescript/commonjs/app-shell/AppShellSplitMotion.d.ts +16 -0
- package/lib/typescript/commonjs/app-shell/AppShellSplitMotion.d.ts.map +1 -0
- package/lib/typescript/commonjs/app-shell/SplitPane.d.ts +12 -0
- package/lib/typescript/commonjs/app-shell/SplitPane.d.ts.map +1 -0
- package/lib/typescript/commonjs/app-shell/context.d.ts +4 -0
- package/lib/typescript/commonjs/app-shell/context.d.ts.map +1 -1
- package/lib/typescript/commonjs/app-shell/index.d.ts +1 -1
- package/lib/typescript/commonjs/app-shell/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/app-shell/index.web.d.ts +1 -1
- package/lib/typescript/commonjs/app-shell/index.web.d.ts.map +1 -1
- package/lib/typescript/commonjs/app-shell/types.d.ts +8 -0
- package/lib/typescript/commonjs/app-shell/types.d.ts.map +1 -1
- package/lib/typescript/commonjs/chat-composer/ChatComposer.d.ts +1 -1
- package/lib/typescript/commonjs/chat-composer/ChatComposer.d.ts.map +1 -1
- package/lib/typescript/commonjs/chat-composer/ChatComposer.web.d.ts +1 -1
- package/lib/typescript/commonjs/chat-composer/ChatComposer.web.d.ts.map +1 -1
- package/lib/typescript/commonjs/chat-composer/create-chat-composer.d.ts +1 -1
- package/lib/typescript/commonjs/chat-composer/create-chat-composer.d.ts.map +1 -1
- package/lib/typescript/commonjs/chat-composer/create-suggestion-list.d.ts.map +1 -1
- package/lib/typescript/commonjs/chat-composer/types.d.ts +9 -2
- package/lib/typescript/commonjs/chat-composer/types.d.ts.map +1 -1
- package/lib/typescript/commonjs/hooks/use-browser-title.d.ts +4 -0
- package/lib/typescript/commonjs/hooks/use-browser-title.d.ts.map +1 -0
- package/lib/typescript/commonjs/hooks/use-prefers-reduced-motion.d.ts +3 -0
- package/lib/typescript/commonjs/hooks/use-prefers-reduced-motion.d.ts.map +1 -0
- package/lib/typescript/commonjs/page-footer/PageFooter.d.ts +1 -1
- package/lib/typescript/commonjs/page-footer/PageFooter.d.ts.map +1 -1
- package/lib/typescript/commonjs/page-footer/types.d.ts +4 -0
- package/lib/typescript/commonjs/page-footer/types.d.ts.map +1 -1
- package/lib/typescript/commonjs/page-footer/use-document-anchor.d.ts +9 -0
- package/lib/typescript/commonjs/page-footer/use-document-anchor.d.ts.map +1 -0
- package/lib/typescript/commonjs/sidebar/Sidebar.d.ts.map +1 -1
- package/lib/typescript/commonjs/sidebar/SidebarItem.d.ts.map +1 -1
- package/lib/typescript/commonjs/sidebar/SidebarModeSwitcher.d.ts.map +1 -1
- package/lib/typescript/commonjs/sidebar/SidebarRail.d.ts +1 -1
- package/lib/typescript/commonjs/sidebar/SidebarRail.d.ts.map +1 -1
- package/lib/typescript/commonjs/sidebar/SidebarRailItem.d.ts.map +1 -1
- package/lib/typescript/commonjs/sidebar/types.d.ts +10 -0
- package/lib/typescript/commonjs/sidebar/types.d.ts.map +1 -1
- package/lib/typescript/module/ai-chat/AiChatMessages.d.ts +1 -1
- package/lib/typescript/module/ai-chat/AiChatMessages.d.ts.map +1 -1
- package/lib/typescript/module/ai-chat/types.d.ts +3 -0
- package/lib/typescript/module/ai-chat/types.d.ts.map +1 -1
- package/lib/typescript/module/app-shell/AppShellSplit.d.ts.map +1 -1
- package/lib/typescript/module/app-shell/AppShellSplitMotion.d.ts +16 -0
- package/lib/typescript/module/app-shell/AppShellSplitMotion.d.ts.map +1 -0
- package/lib/typescript/module/app-shell/SplitPane.d.ts +12 -0
- package/lib/typescript/module/app-shell/SplitPane.d.ts.map +1 -0
- package/lib/typescript/module/app-shell/context.d.ts +4 -0
- package/lib/typescript/module/app-shell/context.d.ts.map +1 -1
- package/lib/typescript/module/app-shell/index.d.ts +1 -1
- package/lib/typescript/module/app-shell/index.d.ts.map +1 -1
- package/lib/typescript/module/app-shell/index.web.d.ts +1 -1
- package/lib/typescript/module/app-shell/index.web.d.ts.map +1 -1
- package/lib/typescript/module/app-shell/types.d.ts +8 -0
- package/lib/typescript/module/app-shell/types.d.ts.map +1 -1
- package/lib/typescript/module/chat-composer/ChatComposer.d.ts +1 -1
- package/lib/typescript/module/chat-composer/ChatComposer.d.ts.map +1 -1
- package/lib/typescript/module/chat-composer/ChatComposer.web.d.ts +1 -1
- package/lib/typescript/module/chat-composer/ChatComposer.web.d.ts.map +1 -1
- package/lib/typescript/module/chat-composer/create-chat-composer.d.ts +1 -1
- package/lib/typescript/module/chat-composer/create-chat-composer.d.ts.map +1 -1
- package/lib/typescript/module/chat-composer/create-suggestion-list.d.ts.map +1 -1
- package/lib/typescript/module/chat-composer/types.d.ts +9 -2
- package/lib/typescript/module/chat-composer/types.d.ts.map +1 -1
- package/lib/typescript/module/hooks/use-browser-title.d.ts +4 -0
- package/lib/typescript/module/hooks/use-browser-title.d.ts.map +1 -0
- package/lib/typescript/module/hooks/use-prefers-reduced-motion.d.ts +3 -0
- package/lib/typescript/module/hooks/use-prefers-reduced-motion.d.ts.map +1 -0
- package/lib/typescript/module/page-footer/PageFooter.d.ts +1 -1
- package/lib/typescript/module/page-footer/PageFooter.d.ts.map +1 -1
- package/lib/typescript/module/page-footer/types.d.ts +4 -0
- package/lib/typescript/module/page-footer/types.d.ts.map +1 -1
- package/lib/typescript/module/page-footer/use-document-anchor.d.ts +9 -0
- package/lib/typescript/module/page-footer/use-document-anchor.d.ts.map +1 -0
- package/lib/typescript/module/sidebar/Sidebar.d.ts.map +1 -1
- package/lib/typescript/module/sidebar/SidebarItem.d.ts.map +1 -1
- package/lib/typescript/module/sidebar/SidebarModeSwitcher.d.ts.map +1 -1
- package/lib/typescript/module/sidebar/SidebarRail.d.ts +1 -1
- package/lib/typescript/module/sidebar/SidebarRail.d.ts.map +1 -1
- package/lib/typescript/module/sidebar/SidebarRailItem.d.ts.map +1 -1
- package/lib/typescript/module/sidebar/types.d.ts +10 -0
- package/lib/typescript/module/sidebar/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/__tests__/support/adoption-matrix.ts +683 -0
- package/src/__tests__/support/card-surface.ts +25 -0
- package/src/__tests__/support/collision-fixture-barrel.ts +20 -0
- package/src/__tests__/support/commerce-harness.tsx +97 -0
- package/src/__tests__/support/composite.ts +68 -0
- package/src/__tests__/support/constructed-style-sheets.ts +68 -0
- package/src/__tests__/support/messages-in.ts +10 -0
- package/src/__tests__/support/press-host.ts +30 -0
- package/src/__tests__/support/rendered-style.ts +99 -0
- package/src/__tests__/support/unread-hook-fixture.ts +33 -0
- package/src/__tests__/support/worklet-capture-fixture.tsx +28 -0
- package/src/agent-avatar/__tests__/artwork-golden.json +774 -0
- package/src/agent-creator/__tests__/support/character-runtime-fixture.tsx +26 -0
- package/src/ai-chat/AiChatMessages.tsx +8 -4
- package/src/ai-chat/types.ts +3 -0
- package/src/app-shell/AppShellSplit.tsx +24 -29
- package/src/app-shell/AppShellSplitMotion.tsx +133 -0
- package/src/app-shell/SplitPane.tsx +30 -0
- package/src/app-shell/context.ts +7 -0
- package/src/app-shell/index.ts +1 -1
- package/src/app-shell/index.web.ts +1 -1
- package/src/app-shell/types.ts +8 -0
- package/src/chat-composer/create-chat-composer.tsx +15 -10
- package/src/chat-composer/create-suggestion-list.tsx +8 -1
- package/src/chat-composer/types.ts +9 -2
- package/src/hooks/use-browser-title.ts +13 -0
- package/src/hooks/use-prefers-reduced-motion.ts +22 -0
- package/src/page-footer/PageFooter.tsx +13 -2
- package/src/page-footer/types.ts +4 -0
- package/src/page-footer/use-document-anchor.ts +52 -0
- package/src/sidebar/Sidebar.tsx +5 -3
- package/src/sidebar/SidebarItem.tsx +3 -2
- package/src/sidebar/SidebarModeSwitcher.tsx +4 -2
- package/src/sidebar/SidebarRail.tsx +6 -1
- package/src/sidebar/SidebarRailItem.tsx +12 -5
- package/src/sidebar/types.ts +10 -0
- package/src/theme/__tests__/__fixtures__/golden-resolved-tokens.json +9346 -0
- package/src/theme/__tests__/__fixtures__/tonal-glass-primary-failures.json +69 -0
- package/src/theme/__tests__/fixtures/color-engine-golden.json +1 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ContextType, ReactNode } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
CharacterCapabilitiesContext,
|
|
4
|
+
CharacterRuntimeContext,
|
|
5
|
+
} from '../../../agent-avatar/context';
|
|
6
|
+
|
|
7
|
+
/** Supply both internal channels without starting the browser engine in UI tests. */
|
|
8
|
+
export function CharacterRuntimeFixture({
|
|
9
|
+
value,
|
|
10
|
+
children,
|
|
11
|
+
}: {
|
|
12
|
+
value: ContextType<typeof CharacterRuntimeContext> &
|
|
13
|
+
ContextType<typeof CharacterCapabilitiesContext>;
|
|
14
|
+
children: ReactNode;
|
|
15
|
+
}) {
|
|
16
|
+
const { runtimeUrl, reportCapabilities, ...catalog } = value;
|
|
17
|
+
return (
|
|
18
|
+
<CharacterRuntimeContext.Provider
|
|
19
|
+
value={{ runtimeUrl, reportCapabilities }}
|
|
20
|
+
>
|
|
21
|
+
<CharacterCapabilitiesContext.Provider value={catalog}>
|
|
22
|
+
{children}
|
|
23
|
+
</CharacterCapabilitiesContext.Provider>
|
|
24
|
+
</CharacterRuntimeContext.Provider>
|
|
25
|
+
);
|
|
26
|
+
}
|
|
@@ -3,6 +3,7 @@ import { View, type LayoutChangeEvent } from 'react-native';
|
|
|
3
3
|
|
|
4
4
|
import { RiLinkM } from '../icons/remix/RiLinkM';
|
|
5
5
|
import { Text } from '../typography';
|
|
6
|
+
import { useDirectionProps } from '../hooks/use-is-rtl';
|
|
6
7
|
import { TurnActionButton } from './AiChatControls';
|
|
7
8
|
import { AiChatFeedbackRowBase } from './AiChatFeedbackRowBase';
|
|
8
9
|
import { RevealFade, RevealLine, RevealSequence, useRevealSlot } from './AiChatReveal';
|
|
@@ -60,20 +61,23 @@ function asBlocks(children: React.ReactNode): React.ReactNode {
|
|
|
60
61
|
});
|
|
61
62
|
}
|
|
62
63
|
|
|
63
|
-
export function AiChatUserMessageBase({ children, actions, animate = true, style, testID }: AiChatUserMessageProps) {
|
|
64
|
+
export function AiChatUserMessageBase({ children, actions, animate = true, style, bubbleStyle, testID }: AiChatUserMessageProps) {
|
|
64
65
|
useAiChatWebCss();
|
|
65
66
|
const palette = useAiChatPalette();
|
|
66
67
|
const [column, setColumn] = useState(0);
|
|
68
|
+
const direction = useDirectionProps();
|
|
67
69
|
return (
|
|
68
70
|
<View
|
|
69
71
|
{...dataHook('bloomAiChatTurn')}
|
|
72
|
+
{...direction}
|
|
70
73
|
testID={testID}
|
|
71
74
|
onLayout={(event: LayoutChangeEvent) => setColumn(event.nativeEvent.layout.width)}
|
|
72
75
|
style={[{ width: '100%', alignItems: 'flex-end' }, style]}>
|
|
73
76
|
<RevealFade
|
|
74
77
|
animate={animate}
|
|
75
|
-
|
|
76
|
-
|
|
78
|
+
testID={testID ? `${testID}-bubble` : undefined}
|
|
79
|
+
style={[{
|
|
80
|
+
marginInlineEnd: -6,
|
|
77
81
|
maxWidth: column > 0 ? column / 2 + 6 : '50%',
|
|
78
82
|
flexDirection: 'column',
|
|
79
83
|
borderRadius: CARD_RADIUS,
|
|
@@ -83,7 +87,7 @@ export function AiChatUserMessageBase({ children, actions, animate = true, style
|
|
|
83
87
|
paddingTop: 11,
|
|
84
88
|
paddingBottom: 11,
|
|
85
89
|
boxShadow: palette.shadowCard,
|
|
86
|
-
}}>
|
|
90
|
+
}, typeof bubbleStyle === 'function' ? bubbleStyle(column) : bubbleStyle]}>
|
|
87
91
|
<RevealSequence animate={animate}>{asBlocks(children)}</RevealSequence>
|
|
88
92
|
</RevealFade>
|
|
89
93
|
{actions && actions.length > 0 ? (
|
package/src/ai-chat/types.ts
CHANGED
|
@@ -81,6 +81,9 @@ export interface AiChatFeedbackRowProps {
|
|
|
81
81
|
// ---------------------------------------------------------------------------
|
|
82
82
|
|
|
83
83
|
export interface AiChatUserMessageProps {
|
|
84
|
+
/** Style the bubble itself; a callback receives its measured column width.
|
|
85
|
+
* The callback receives 0 before the initial layout. */
|
|
86
|
+
bubbleStyle?: StyleProp<ViewStyle> | ((columnWidth: number) => StyleProp<ViewStyle>);
|
|
84
87
|
/** `AiChatMessageLine`s — or a string, wrapped in one. */
|
|
85
88
|
children: ReactNode;
|
|
86
89
|
/**
|
|
@@ -15,11 +15,9 @@
|
|
|
15
15
|
* set of the same three bugs.
|
|
16
16
|
*/
|
|
17
17
|
import React, { memo, useCallback, useRef, useState } from 'react';
|
|
18
|
-
import {
|
|
18
|
+
import { View } from 'react-native';
|
|
19
19
|
|
|
20
20
|
import { AiChatResizeHandle } from '../ai-chat/AiChatResizeHandle';
|
|
21
|
-
import { PanelErrorBoundary } from '../error-boundary/PanelErrorBoundary';
|
|
22
|
-
import type { PanelErrorBoundaryOptions } from '../error-boundary/types';
|
|
23
21
|
import { Z_INDEX } from '../styles/z-index';
|
|
24
22
|
import { space } from '../styles/tokens';
|
|
25
23
|
import { useTheme } from '../theme/use-theme';
|
|
@@ -28,35 +26,12 @@ import { APP_SHELL_MESSAGES } from './messages';
|
|
|
28
26
|
|
|
29
27
|
import type { AppShellSplitPanesProps } from './types';
|
|
30
28
|
import { APP_SHELL_DEFAULTS as D } from './constants';
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
function Pane({
|
|
34
|
-
children,
|
|
35
|
-
scroll,
|
|
36
|
-
errorBoundary,
|
|
37
|
-
style,
|
|
38
|
-
testID,
|
|
39
|
-
}: {
|
|
40
|
-
children: React.ReactNode;
|
|
41
|
-
scroll: boolean;
|
|
42
|
-
errorBoundary?: false | PanelErrorBoundaryOptions;
|
|
43
|
-
style: React.ComponentProps<typeof View>['style'];
|
|
44
|
-
testID?: string;
|
|
45
|
-
}) {
|
|
46
|
-
const content = scroll ? (
|
|
47
|
-
<ScrollView style={{ flex: 1 }} contentContainerStyle={{ flexGrow: 1 }}>
|
|
48
|
-
{children}
|
|
49
|
-
</ScrollView>
|
|
50
|
-
) : <View style={{ flex: 1, minHeight: 0 }}>{children}</View>;
|
|
51
|
-
return (
|
|
52
|
-
<View testID={testID} style={[{ minWidth: 0, alignSelf: 'stretch' }, style]}>
|
|
53
|
-
{errorBoundary === false ? content : <PanelErrorBoundary {...errorBoundary}>{content}</PanelErrorBoundary>}
|
|
54
|
-
</View>
|
|
55
|
-
);
|
|
56
|
-
}
|
|
29
|
+
import { SplitPane as Pane } from './SplitPane';
|
|
30
|
+
import { AppShellSplitMotion } from './AppShellSplitMotion';
|
|
57
31
|
|
|
58
32
|
const AppShellSplitPanesComponent: React.FC<AppShellSplitPanesProps> = ({
|
|
59
33
|
variant = 'joined',
|
|
34
|
+
transition = 'none',
|
|
60
35
|
listErrorBoundary,
|
|
61
36
|
detailErrorBoundary,
|
|
62
37
|
infoErrorBoundary,
|
|
@@ -121,6 +96,26 @@ const AppShellSplitPanesComponent: React.FC<AppShellSplitPanesProps> = ({
|
|
|
121
96
|
// Only the panes that are actually drawn count: alone, a pane fills the row.
|
|
122
97
|
const solo = [showList, showDetail, showInfo].filter(Boolean).length === 1;
|
|
123
98
|
|
|
99
|
+
if (transition === 'slide') {
|
|
100
|
+
return <View style={{ flexGrow: 1, flexShrink: 1, minWidth: 0, flexDirection: 'row' }}>
|
|
101
|
+
{(showList || showDetail) && <AppShellSplitMotion
|
|
102
|
+
list={list} detail={detail} showList={showList} showDetail={showDetail}
|
|
103
|
+
width={width} gap={divider.width} paneScroll={paneScroll}
|
|
104
|
+
listErrorBoundary={listErrorBoundary} detailErrorBoundary={detailErrorBoundary}
|
|
105
|
+
dividerStyle={divider} testID={testID}
|
|
106
|
+
resizeHandle={resizable ? <AiChatResizeHandle label={resizeLabel}
|
|
107
|
+
onResizeStart={onResizeStart} onResize={onResize} onNudge={onNudge}
|
|
108
|
+
testID={testID ? `${testID}-divider` : undefined} /> : null}
|
|
109
|
+
/>}
|
|
110
|
+
{showInfo && (showList || showDetail) ? <View style={divider} testID={testID ? `${testID}-info-gap` : undefined} /> : null}
|
|
111
|
+
{showInfo ? <Pane testID={testID ? `${testID}-pane-info` : undefined}
|
|
112
|
+
errorBoundary={infoErrorBoundary} scroll={paneScroll}
|
|
113
|
+
style={solo ? { flexGrow: 1, flexShrink: 1, flexBasis: 0 } : { width: infoWidth, flexShrink: 0 }}>
|
|
114
|
+
{info}
|
|
115
|
+
</Pane> : null}
|
|
116
|
+
</View>;
|
|
117
|
+
}
|
|
118
|
+
|
|
124
119
|
return (
|
|
125
120
|
<View style={{ flexGrow: 1, flexShrink: 1, minWidth: 0, flexDirection: 'row' }}>
|
|
126
121
|
{showList ? (
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import React, { useCallback, useLayoutEffect, useRef, useState } from 'react';
|
|
2
|
+
import { Platform, View, type LayoutChangeEvent, type ViewStyle } from 'react-native';
|
|
3
|
+
import Animated, { cancelAnimation, Easing, ReduceMotion, runOnJS, useAnimatedStyle, useSharedValue, withTiming } from 'react-native-reanimated';
|
|
4
|
+
import { useDirectionProps, useIsRtl } from '../hooks/use-is-rtl';
|
|
5
|
+
import { usePrefersReducedMotion } from '../hooks/use-prefers-reduced-motion';
|
|
6
|
+
import { MOTION_RECIPES } from '../motion/recipes';
|
|
7
|
+
import { WEB_OVERFLOW_CLIP } from '../styles/web-view-style';
|
|
8
|
+
import { AppShellPaneActiveContext } from './context';
|
|
9
|
+
import { SplitPane } from './SplitPane';
|
|
10
|
+
import type { AppShellSplitPanesProps } from './types';
|
|
11
|
+
|
|
12
|
+
type Props = Pick<AppShellSplitPanesProps, 'list' | 'detail' | 'listErrorBoundary' | 'detailErrorBoundary' | 'testID'> & {
|
|
13
|
+
showList: boolean;
|
|
14
|
+
showDetail: boolean;
|
|
15
|
+
paneScroll: boolean;
|
|
16
|
+
width: number;
|
|
17
|
+
gap: number;
|
|
18
|
+
dividerStyle: ViewStyle;
|
|
19
|
+
resizeHandle: React.ReactNode;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
// `clip` prevents horizontal overflow without creating a nested scroll owner.
|
|
23
|
+
// Native has no document scroll and uses its ordinary clipping primitive.
|
|
24
|
+
const clipStyle: ViewStyle = { overflow: Platform.OS === 'web' ? WEB_OVERFLOW_CLIP : 'hidden' };
|
|
25
|
+
|
|
26
|
+
/** One progress value owns both live pane positions; no clones, opacity or layout snapshots. */
|
|
27
|
+
export function AppShellSplitMotion({ list, detail, showList, showDetail, width, gap,
|
|
28
|
+
paneScroll, listErrorBoundary, detailErrorBoundary, dividerStyle, resizeHandle, testID }: Props) {
|
|
29
|
+
const [containerWidth, setContainerWidth] = useState(0);
|
|
30
|
+
const [retained, setRetained] = useState({ list, detail, listVisible: showList, detailVisible: showDetail });
|
|
31
|
+
const previousSplit = useRef(showList);
|
|
32
|
+
const split = showDetail ? showList : previousSplit.current;
|
|
33
|
+
const progress = useSharedValue(showDetail ? 1 : 0);
|
|
34
|
+
const reducedMotion = usePrefersReducedMotion();
|
|
35
|
+
const generation = useRef(0);
|
|
36
|
+
const direction = useIsRtl() ? -1 : 1;
|
|
37
|
+
const directionProps = useDirectionProps();
|
|
38
|
+
|
|
39
|
+
useLayoutEffect(() => {
|
|
40
|
+
previousSplit.current = split;
|
|
41
|
+
setRetained(current => ({
|
|
42
|
+
list: showList ? list : current.list,
|
|
43
|
+
detail: showDetail ? detail : current.detail,
|
|
44
|
+
listVisible: showList || current.listVisible,
|
|
45
|
+
detailVisible: showDetail || current.detailVisible,
|
|
46
|
+
}));
|
|
47
|
+
}, [list, detail, showList, showDetail, split]);
|
|
48
|
+
|
|
49
|
+
const finish = useCallback((id: number, keepList: boolean, keepDetail: boolean) => {
|
|
50
|
+
if (generation.current !== id) return;
|
|
51
|
+
setRetained(current => ({
|
|
52
|
+
list: keepList ? current.list : undefined,
|
|
53
|
+
detail: keepDetail ? current.detail : undefined,
|
|
54
|
+
listVisible: keepList,
|
|
55
|
+
detailVisible: keepDetail,
|
|
56
|
+
}));
|
|
57
|
+
}, []);
|
|
58
|
+
|
|
59
|
+
useLayoutEffect(() => {
|
|
60
|
+
const id = ++generation.current;
|
|
61
|
+
const target = showDetail ? 1 : 0;
|
|
62
|
+
if (reducedMotion) {
|
|
63
|
+
progress.value = target;
|
|
64
|
+
finish(id, showList, showDetail);
|
|
65
|
+
} else {
|
|
66
|
+
// Duration springs in Reanimated 3 cap each frame's integrated time at
|
|
67
|
+
// 64ms, then force their target at the wall-clock deadline. Expensive
|
|
68
|
+
// layout frames can therefore end in a large final jump. Timing samples
|
|
69
|
+
// elapsed time directly and never accumulates that integration deficit.
|
|
70
|
+
progress.value = withTiming(target, {
|
|
71
|
+
duration: MOTION_RECIPES.expand.duration,
|
|
72
|
+
easing: Easing.out(Easing.cubic),
|
|
73
|
+
// The reactive hook above owns this policy; System is a launch snapshot.
|
|
74
|
+
reduceMotion: ReduceMotion.Never,
|
|
75
|
+
}, completed => {
|
|
76
|
+
if (completed) runOnJS(finish)(id, showList, showDetail);
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
return () => { cancelAnimation(progress); };
|
|
80
|
+
}, [showList, showDetail, progress, reducedMotion, finish]);
|
|
81
|
+
|
|
82
|
+
const measure = useCallback((event: LayoutChangeEvent) => {
|
|
83
|
+
setContainerWidth(event.nativeEvent.layout.width);
|
|
84
|
+
}, []);
|
|
85
|
+
const listStyle = useAnimatedStyle(() => ({
|
|
86
|
+
width: containerWidth > 0 ? (split ? containerWidth - (containerWidth - width) * progress.value : containerWidth) : undefined,
|
|
87
|
+
transform: [{ translateX: split ? 0 : -direction * containerWidth * progress.value }],
|
|
88
|
+
}), [containerWidth, width, split, progress, direction]);
|
|
89
|
+
const detailStyle = useAnimatedStyle(() => ({
|
|
90
|
+
width: containerWidth > 0 ? (split ? Math.max(0, containerWidth - width - gap) : containerWidth) : undefined,
|
|
91
|
+
transform: [{ translateX: split ? 0 : direction * containerWidth * (1 - progress.value) }],
|
|
92
|
+
}), [containerWidth, width, gap, split, progress, direction]);
|
|
93
|
+
const gapStyle = useAnimatedStyle(() => ({ width: gap * progress.value }), [gap, progress]);
|
|
94
|
+
|
|
95
|
+
const hasList = showList || retained.listVisible;
|
|
96
|
+
const hasDetail = showDetail || retained.detailVisible;
|
|
97
|
+
const inactive = (active: boolean) => ({
|
|
98
|
+
pointerEvents: active ? 'auto' as const : 'none' as const,
|
|
99
|
+
'aria-hidden': active ? undefined : true,
|
|
100
|
+
importantForAccessibility: active ? 'auto' as const : 'no-hide-descendants' as const,
|
|
101
|
+
accessibilityElementsHidden: !active,
|
|
102
|
+
...(Platform.OS === 'web' && !active ? { inert: true } : null),
|
|
103
|
+
});
|
|
104
|
+
return <View {...directionProps} onLayout={measure} testID={testID ? `${testID}-motion` : undefined}
|
|
105
|
+
style={[{ flexGrow: 1, flexShrink: 1, flexBasis: 0, minWidth: 0, flexDirection: 'row', alignItems: 'stretch' }, clipStyle]}>
|
|
106
|
+
{hasList ? <Animated.View {...inactive(showList)}
|
|
107
|
+
testID={testID ? `${testID}-pane-list` : undefined}
|
|
108
|
+
style={[{ minWidth: 0, flexShrink: 0 }, !split && !showList ? { position: 'absolute', top: 0, start: 0 } : null, listStyle]}>
|
|
109
|
+
<AppShellPaneActiveContext.Provider value={showList}>
|
|
110
|
+
<SplitPane scroll={paneScroll} errorBoundary={listErrorBoundary} style={{ flexGrow: 1 }}>
|
|
111
|
+
{showList ? list : retained.list}
|
|
112
|
+
</SplitPane>
|
|
113
|
+
</AppShellPaneActiveContext.Provider>
|
|
114
|
+
</Animated.View> : null}
|
|
115
|
+
{split && hasList && hasDetail ? <Animated.View
|
|
116
|
+
style={[dividerStyle, gapStyle]} testID={testID ? `${testID}-list-gap` : undefined}>
|
|
117
|
+
{showList && showDetail ? <View pointerEvents="box-none"
|
|
118
|
+
testID={testID ? `${testID}-resize-anchor` : undefined}
|
|
119
|
+
style={{ position: 'absolute', top: 0, bottom: 0, left: '50%', right: '50%', width: 0 }}>
|
|
120
|
+
{resizeHandle}
|
|
121
|
+
</View> : null}
|
|
122
|
+
</Animated.View> : null}
|
|
123
|
+
{hasDetail ? <Animated.View {...inactive(showDetail)}
|
|
124
|
+
testID={testID ? `${testID}-pane-detail` : undefined}
|
|
125
|
+
style={[{ minWidth: 0, flexShrink: 0 }, !split && !showDetail ? { position: 'absolute', top: 0, start: 0 } : null, detailStyle]}>
|
|
126
|
+
<AppShellPaneActiveContext.Provider value={showDetail}>
|
|
127
|
+
<SplitPane scroll={paneScroll} errorBoundary={detailErrorBoundary} style={{ flexGrow: 1 }}>
|
|
128
|
+
{showDetail ? detail : retained.detail}
|
|
129
|
+
</SplitPane>
|
|
130
|
+
</AppShellPaneActiveContext.Provider>
|
|
131
|
+
</Animated.View> : null}
|
|
132
|
+
</View>;
|
|
133
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ScrollView, View } from 'react-native';
|
|
3
|
+
import { PanelErrorBoundary } from '../error-boundary/PanelErrorBoundary';
|
|
4
|
+
import type { PanelErrorBoundaryOptions } from '../error-boundary/types';
|
|
5
|
+
|
|
6
|
+
/** One pane: a bounded column that scrolls its own overflow. */
|
|
7
|
+
export function SplitPane({
|
|
8
|
+
children,
|
|
9
|
+
scroll,
|
|
10
|
+
errorBoundary,
|
|
11
|
+
style,
|
|
12
|
+
testID,
|
|
13
|
+
}: {
|
|
14
|
+
children: React.ReactNode;
|
|
15
|
+
scroll: boolean;
|
|
16
|
+
errorBoundary?: false | PanelErrorBoundaryOptions;
|
|
17
|
+
style: React.ComponentProps<typeof View>['style'];
|
|
18
|
+
testID?: string;
|
|
19
|
+
}) {
|
|
20
|
+
const content = scroll ? (
|
|
21
|
+
<ScrollView style={{ flex: 1 }} contentContainerStyle={{ flexGrow: 1 }}>
|
|
22
|
+
{children}
|
|
23
|
+
</ScrollView>
|
|
24
|
+
) : <View style={{ flex: 1, minHeight: 0 }}>{children}</View>;
|
|
25
|
+
return (
|
|
26
|
+
<View testID={testID} style={[{ minWidth: 0, alignSelf: 'stretch' }, style]}>
|
|
27
|
+
{errorBoundary === false ? content : <PanelErrorBoundary {...errorBoundary}>{content}</PanelErrorBoundary>}
|
|
28
|
+
</View>
|
|
29
|
+
);
|
|
30
|
+
}
|
package/src/app-shell/context.ts
CHANGED
|
@@ -33,3 +33,10 @@ export function useAppShell(): AppShellContextValue {
|
|
|
33
33
|
export function useOptionalAppShell(): AppShellContextValue | null {
|
|
34
34
|
return useContext(AppShellContext);
|
|
35
35
|
}
|
|
36
|
+
|
|
37
|
+
/** Logical pane visibility, including while its exit animation is retained. */
|
|
38
|
+
export const AppShellPaneActiveContext = createContext(true);
|
|
39
|
+
/** Suspend pane-local global shortcuts/effects as soon as a pane is hidden. */
|
|
40
|
+
export function useAppShellPaneActive(): boolean {
|
|
41
|
+
return useContext(AppShellPaneActiveContext);
|
|
42
|
+
}
|
package/src/app-shell/index.ts
CHANGED
|
@@ -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';
|
package/src/app-shell/types.ts
CHANGED
|
@@ -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;
|
|
@@ -150,6 +150,9 @@ export function createChatComposer({ ComposerAttachmentStrip, ComposerIconButton
|
|
|
150
150
|
onBlur,
|
|
151
151
|
labels: labelOverrides,
|
|
152
152
|
style,
|
|
153
|
+
barStyle,
|
|
154
|
+
inputStyle,
|
|
155
|
+
sendIcon: SendIcon = RiSendPlaneLine,
|
|
153
156
|
testID,
|
|
154
157
|
accessibilityLabel,
|
|
155
158
|
}: ChatComposerProps) {
|
|
@@ -210,13 +213,15 @@ export function createChatComposer({ ComposerAttachmentStrip, ComposerIconButton
|
|
|
210
213
|
|
|
211
214
|
const trimmed = text.trim();
|
|
212
215
|
const hasAttachments = !!attachments && attachments.length > 0;
|
|
213
|
-
const
|
|
216
|
+
const sendEnabled = canSend ?? (trimmed.length > 0 || hasAttachments);
|
|
217
|
+
const hasMic = !!(onMicPress || onMicPressIn || onMicPressOut);
|
|
218
|
+
const showSend = sendEnabled || !hasMic;
|
|
214
219
|
|
|
215
220
|
const submit = useCallback(() => {
|
|
216
|
-
if (disabled || !
|
|
221
|
+
if (disabled || !sendEnabled) return;
|
|
217
222
|
onSend?.(text);
|
|
218
223
|
if (value === undefined) setText('');
|
|
219
|
-
}, [disabled,
|
|
224
|
+
}, [disabled, sendEnabled, onSend, text, value, setText]);
|
|
220
225
|
|
|
221
226
|
const openSuggestions = !!suggestions && suggestions.length > 0;
|
|
222
227
|
|
|
@@ -325,7 +330,7 @@ export function createChatComposer({ ComposerAttachmentStrip, ComposerIconButton
|
|
|
325
330
|
) : null}
|
|
326
331
|
|
|
327
332
|
{recorder ?? (
|
|
328
|
-
<View style={bar} testID={testID ? `${testID}-bar` : undefined}>
|
|
333
|
+
<View style={[bar, barStyle]} testID={testID ? `${testID}-bar` : undefined}>
|
|
329
334
|
{notice !== undefined ? (
|
|
330
335
|
<View
|
|
331
336
|
style={{
|
|
@@ -393,7 +398,7 @@ export function createChatComposer({ ComposerAttachmentStrip, ComposerIconButton
|
|
|
393
398
|
selectionColor={palette.accent}
|
|
394
399
|
cursorColor={palette.accent}
|
|
395
400
|
scrollEnabled={height >= maxHeight}
|
|
396
|
-
style={{
|
|
401
|
+
style={[{
|
|
397
402
|
width: '100%',
|
|
398
403
|
height,
|
|
399
404
|
maxHeight,
|
|
@@ -403,7 +408,7 @@ export function createChatComposer({ ComposerAttachmentStrip, ComposerIconButton
|
|
|
403
408
|
fontFamily: IS_WEB ? 'var(--bloom-font-sans)' : 'Inter',
|
|
404
409
|
color: disabled ? palette.textSecondary : palette.text,
|
|
405
410
|
backgroundColor: 'transparent',
|
|
406
|
-
}}
|
|
411
|
+
}, inputStyle]}
|
|
407
412
|
testID={testID ? `${testID}-input` : undefined}
|
|
408
413
|
/>
|
|
409
414
|
</View>
|
|
@@ -432,16 +437,16 @@ export function createChatComposer({ ComposerAttachmentStrip, ComposerIconButton
|
|
|
432
437
|
<View style={{ width: CONTROL_SIZE, height: CONTROL_SIZE, marginLeft: 2 }}>
|
|
433
438
|
<SwapLayer shown={showSend}>
|
|
434
439
|
<ComposerIconButton
|
|
435
|
-
icon={
|
|
440
|
+
icon={SendIcon}
|
|
436
441
|
tone="accent"
|
|
437
442
|
accessibilityLabel={labels.send}
|
|
438
443
|
onPress={submit}
|
|
439
|
-
disabled={disabled}
|
|
444
|
+
disabled={disabled || !sendEnabled}
|
|
440
445
|
iconSize={18}
|
|
441
446
|
testID={testID ? `${testID}-send` : undefined}
|
|
442
447
|
/>
|
|
443
448
|
</SwapLayer>
|
|
444
|
-
<SwapLayer shown={!showSend}>
|
|
449
|
+
{hasMic ? <SwapLayer shown={!showSend}>
|
|
445
450
|
<ComposerIconButton
|
|
446
451
|
icon={RiMic2Line}
|
|
447
452
|
accessibilityLabel={labels.mic}
|
|
@@ -451,7 +456,7 @@ export function createChatComposer({ ComposerAttachmentStrip, ComposerIconButton
|
|
|
451
456
|
disabled={disabled}
|
|
452
457
|
testID={testID ? `${testID}-mic` : undefined}
|
|
453
458
|
/>
|
|
454
|
-
</SwapLayer>
|
|
459
|
+
</SwapLayer> : null}
|
|
455
460
|
</View>
|
|
456
461
|
</>
|
|
457
462
|
)}
|
|
@@ -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 = {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ReactNode, RefObject } from 'react';
|
|
2
|
-
import type { StyleProp, TextInput, ViewStyle } from 'react-native';
|
|
2
|
+
import type { StyleProp, TextInput, TextStyle, ViewStyle } from 'react-native';
|
|
3
3
|
|
|
4
4
|
import type { BloomIconComponent } from '../icons/icon-component';
|
|
5
5
|
|
|
@@ -124,6 +124,12 @@ export interface ChatComposerLabels {
|
|
|
124
124
|
}
|
|
125
125
|
|
|
126
126
|
export interface ChatComposerProps extends PartProps {
|
|
127
|
+
/** Style the input bar itself; outer `style` includes suggestions and banners. */
|
|
128
|
+
barStyle?: StyleProp<ViewStyle>;
|
|
129
|
+
/** Typography and other text styles on the editable field. */
|
|
130
|
+
inputStyle?: StyleProp<TextStyle>;
|
|
131
|
+
/** Send control glyph. Defaults to the paper plane. */
|
|
132
|
+
sendIcon?: ChatComposerIcon;
|
|
127
133
|
/** The draft. Works controlled or uncontrolled. */
|
|
128
134
|
value?: string;
|
|
129
135
|
defaultValue?: string;
|
|
@@ -164,7 +170,8 @@ export interface ChatComposerProps extends PartProps {
|
|
|
164
170
|
onEmojiPress?: () => void;
|
|
165
171
|
/** Draws a camera button between the field and the emoji button. */
|
|
166
172
|
onCameraPress?: () => void;
|
|
167
|
-
/** The mic, shown
|
|
173
|
+
/** The mic, shown for an empty draft only when a mic callback is provided.
|
|
174
|
+
* Without recording callbacks, the empty composer shows a disabled send button. */
|
|
168
175
|
onMicPress?: () => void;
|
|
169
176
|
/** Press-and-hold on the mic (native). Both fire on web too. */
|
|
170
177
|
onMicPressIn?: () => void;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { useCallback, type Ref } from 'react';
|
|
2
|
+
import { Platform } from 'react-native';
|
|
3
|
+
|
|
4
|
+
/** RNW drops title on Pressable/View; bind the browser's own tooltip to its host. */
|
|
5
|
+
export function useBrowserTitle<T>(title: string | undefined, forwardedRef?: Ref<T>) {
|
|
6
|
+
return useCallback((node: T | null): void => {
|
|
7
|
+
if (typeof forwardedRef === 'function') forwardedRef(node);
|
|
8
|
+
else if (forwardedRef) forwardedRef.current = node;
|
|
9
|
+
if (Platform.OS !== 'web' || typeof HTMLElement === 'undefined' || !(node instanceof HTMLElement)) return;
|
|
10
|
+
if (title === undefined) node.removeAttribute('title');
|
|
11
|
+
else node.setAttribute('title', title);
|
|
12
|
+
}, [title, forwardedRef]);
|
|
13
|
+
}
|
|
@@ -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
|
|
package/src/page-footer/types.ts
CHANGED
|
@@ -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
|
+
}
|